mirror of
https://grond.iut-fbleau.fr/stiti/SAE_2.02
synced 2024-12-28 09:32:19 +01:00
Modification des headers + ajout de cookies de connexion
This commit is contained in:
parent
3ee078d36e
commit
de3f0c7cb5
@ -89,7 +89,7 @@ $autoload['drivers'] = array();
|
|||||||
|
|
|
|
||||||
| $autoload['helper'] = array('url', 'file');
|
| $autoload['helper'] = array('url', 'file');
|
||||||
*/
|
*/
|
||||||
$autoload['helper'] = array();
|
$autoload['helper'] = array('url', 'form', 'html', 'cookie');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
| -------------------------------------------------------------------
|
| -------------------------------------------------------------------
|
||||||
|
@ -33,36 +33,18 @@ class Albums extends CI_Controller {
|
|||||||
$data['genres'] = $this->model_music->getGenres();
|
$data['genres'] = $this->model_music->getGenres();
|
||||||
$data['artists'] = $this->model_music->getArtists();
|
$data['artists'] = $this->model_music->getArtists();
|
||||||
|
|
||||||
include 'temporaire.php';
|
|
||||||
if($logged == true){
|
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_logged_dark');
|
|
||||||
$this->load->view('albums_list', $data);
|
$this->load->view('albums_list', $data);
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
} else {
|
|
||||||
$this->load->view('layout/header_dark');
|
|
||||||
$this->load->view('layout/header_not_logged_dark');
|
|
||||||
$this->load->view('albums_list', $data);
|
|
||||||
$this->load->view('layout/footer_dark');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function view($id){
|
public function view($id){
|
||||||
$album = $this->model_music->get_album_by_id($id);
|
$album = $this->model_music->get_album_by_id($id);
|
||||||
$data['album'] = $album;
|
$data['album'] = $album;
|
||||||
|
|
||||||
include 'temporaire.php';
|
|
||||||
if($logged == true){
|
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_logged_dark');
|
|
||||||
$this->load->view('album_view', $data);
|
$this->load->view('album_view', $data);
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
} else {
|
|
||||||
$this->load->view('layout/header_dark');
|
|
||||||
$this->load->view('layout/header_not_logged_dark');
|
|
||||||
$this->load->view('album_view', $data);
|
|
||||||
$this->load->view('layout/footer_dark');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,18 +25,9 @@ class Artiste extends CI_Controller {
|
|||||||
$data['albums'] = $albums;
|
$data['albums'] = $albums;
|
||||||
$data['mostUsedGenre'] = $mostUsedGenre; // Passer $mostUsedGenre à la vue
|
$data['mostUsedGenre'] = $mostUsedGenre; // Passer $mostUsedGenre à la vue
|
||||||
|
|
||||||
include 'temporaire.php';
|
|
||||||
if($logged == true){
|
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_logged_dark');
|
|
||||||
$this->load->view('artiste_details', $data);
|
$this->load->view('artiste_details', $data);
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
} else {
|
|
||||||
$this->load->view('layout/header_dark');
|
|
||||||
$this->load->view('layout/header_not_logged_dark');
|
|
||||||
$this->load->view('artiste_details', $data);
|
|
||||||
$this->load->view('layout/footer_dark');
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Gérer le cas où l'artiste n'est pas trouvé == afficher un error 404
|
// Gérer le cas où l'artiste n'est pas trouvé == afficher un error 404
|
||||||
@ -56,18 +47,9 @@ class Artiste extends CI_Controller {
|
|||||||
$data['artists'] = $artists;
|
$data['artists'] = $artists;
|
||||||
$data['current_order'] = $order;
|
$data['current_order'] = $order;
|
||||||
|
|
||||||
include 'temporaire.php';
|
|
||||||
if($logged == true){
|
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_logged_dark');
|
|
||||||
$this->load->view('artists_list', $data);
|
$this->load->view('artists_list', $data);
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
} else {
|
|
||||||
$this->load->view('layout/header_dark');
|
|
||||||
$this->load->view('layout/header_not_logged_dark');
|
|
||||||
$this->load->view('artists_list', $data);
|
|
||||||
$this->load->view('layout/footer_dark');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -16,19 +16,9 @@ public function index() {
|
|||||||
$data['covers'] = $this->Cover_model->get_covers();
|
$data['covers'] = $this->Cover_model->get_covers();
|
||||||
|
|
||||||
// Charger la vue avec les données récupérées
|
// Charger la vue avec les données récupérées
|
||||||
|
|
||||||
include 'temporaire.php';
|
|
||||||
if($logged == true){
|
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_logged_dark');
|
|
||||||
$this->load->view('accueil', $data);
|
$this->load->view('accueil', $data);
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
} else {
|
|
||||||
$this->load->view('layout/header_dark');
|
|
||||||
$this->load->view('layout/header_not_logged_dark');
|
|
||||||
$this->load->view('accueil', $data);
|
|
||||||
$this->load->view('layout/footer_dark');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -11,18 +11,9 @@ class MentionsLegales extends CI_Controller {
|
|||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
include 'temporaire.php';
|
|
||||||
if($logged == true){
|
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_logged_dark');
|
|
||||||
$this->load->view('mentions-legals');
|
$this->load->view('mentions-legals');
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
} else {
|
|
||||||
$this->load->view('layout/header_dark');
|
|
||||||
$this->load->view('layout/header_not_logged_dark');
|
|
||||||
$this->load->view('mentions-legals');
|
|
||||||
$this->load->view('layout/footer_dark');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,18 +37,9 @@ class Musiques extends CI_Controller {
|
|||||||
$data['sort'] = $sort; // Passer la valeur de tri à la vue
|
$data['sort'] = $sort; // Passer la valeur de tri à la vue
|
||||||
|
|
||||||
// Charger la vue
|
// Charger la vue
|
||||||
include 'temporaire.php';
|
|
||||||
if($logged == true){
|
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_logged_dark');
|
|
||||||
$this->load->view('musiques_list', $data);
|
$this->load->view('musiques_list', $data);
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
} else {
|
|
||||||
$this->load->view('layout/header_dark');
|
|
||||||
$this->load->view('layout/header_not_logged_dark');
|
|
||||||
$this->load->view('musiques_list', $data);
|
|
||||||
$this->load->view('layout/footer_dark');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,19 +25,9 @@ class Search extends CI_Controller {
|
|||||||
$data['artistes'] = [];
|
$data['artistes'] = [];
|
||||||
$data['error'] = "La requête de recherche ne peut pas être vide.";
|
$data['error'] = "La requête de recherche ne peut pas être vide.";
|
||||||
|
|
||||||
|
|
||||||
if($logged == true){
|
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_logged_dark');
|
|
||||||
$this->load->view('search_results', $data);
|
$this->load->view('search_results', $data);
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
} else {
|
|
||||||
$this->load->view('layout/header_dark');
|
|
||||||
$this->load->view('layout/header_not_logged_dark');
|
|
||||||
$this->load->view('search_results', $data);
|
|
||||||
$this->load->view('layout/footer_dark');
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Faire une recherche dans les musiques, les albums, les genres et les artistes
|
// Faire une recherche dans les musiques, les albums, les genres et les artistes
|
||||||
@ -53,16 +43,8 @@ class Search extends CI_Controller {
|
|||||||
$data['genres'] = $genres;
|
$data['genres'] = $genres;
|
||||||
$data['artistes'] = $artistes;
|
$data['artistes'] = $artistes;
|
||||||
|
|
||||||
if($logged == true){
|
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_logged_dark');
|
|
||||||
$this->load->view('search_results', $data);
|
|
||||||
$this->load->view('layout/footer_dark');
|
|
||||||
} else {
|
|
||||||
$this->load->view('layout/header_dark');
|
|
||||||
$this->load->view('layout/header_not_logged_dark');
|
|
||||||
$this->load->view('search_results', $data);
|
$this->load->view('search_results', $data);
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -5,12 +5,13 @@ class Utilisateur extends CI_Controller {
|
|||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->load->helper(array('form', 'url'));
|
$this->load->helper(array('form', 'url', 'cookie'));
|
||||||
$this->load->library(array('form_validation', 'session'));
|
$this->load->library(array('form_validation', 'session'));
|
||||||
$this->load->model('Utilisateur_model');
|
$this->load->model('Utilisateur_model');
|
||||||
$this->load->helper('html');
|
$this->load->helper('html');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function inscription(){
|
public function inscription(){
|
||||||
// Définir les règles de validation
|
// Définir les règles de validation
|
||||||
$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[utilisateur.email]');
|
$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[utilisateur.email]');
|
||||||
@ -24,7 +25,6 @@ class Utilisateur extends CI_Controller {
|
|||||||
if ($this->form_validation->run() == FALSE) {
|
if ($this->form_validation->run() == FALSE) {
|
||||||
// Charger la vue avec les erreurs
|
// Charger la vue avec les erreurs
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_not_logged_dark');
|
|
||||||
$this->load->view('inscription');
|
$this->load->view('inscription');
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
} else {
|
} else {
|
||||||
@ -43,7 +43,6 @@ class Utilisateur extends CI_Controller {
|
|||||||
} else {
|
} else {
|
||||||
$data['error'] = 'Une erreur est survenue. Veuillez réessayer.';
|
$data['error'] = 'Une erreur est survenue. Veuillez réessayer.';
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_not_logged_dark');
|
|
||||||
$this->load->view('inscription', $data);
|
$this->load->view('inscription', $data);
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
}
|
}
|
||||||
@ -58,7 +57,6 @@ class Utilisateur extends CI_Controller {
|
|||||||
if ($this->form_validation->run() == FALSE) {
|
if ($this->form_validation->run() == FALSE) {
|
||||||
// Charger la vue avec les erreurs
|
// Charger la vue avec les erreurs
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_not_logged_dark');
|
|
||||||
$this->load->view('connexion');
|
$this->load->view('connexion');
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
} else {
|
} else {
|
||||||
@ -72,16 +70,36 @@ class Utilisateur extends CI_Controller {
|
|||||||
if ($user && password_verify($password, $user->password)) {
|
if ($user && password_verify($password, $user->password)) {
|
||||||
// Connexion réussie, enregistrer l'utilisateur dans la session
|
// Connexion réussie, enregistrer l'utilisateur dans la session
|
||||||
$this->session->set_userdata('user_id', $user->id);
|
$this->session->set_userdata('user_id', $user->id);
|
||||||
|
// Définir un cookie pour indiquer que l'utilisateur est connecté
|
||||||
|
$cookie = array(
|
||||||
|
'name' => 'user_logged_in',
|
||||||
|
'value' => '1',
|
||||||
|
'expire' => '86500', // durée de vie du cookie (1 jour)
|
||||||
|
'secure' => TRUE
|
||||||
|
);
|
||||||
|
$this->input->set_cookie($cookie);
|
||||||
redirect('utilisateur/dashboard');
|
redirect('utilisateur/dashboard');
|
||||||
} else {
|
} else {
|
||||||
$data['error'] = 'Email ou mot de passe incorrect.';
|
$data['error'] = 'Email ou mot de passe incorrect.';
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_logged_dark');
|
|
||||||
$this->load->view('connexion', $data);
|
$this->load->view('connexion', $data);
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deconnexion(){
|
||||||
|
// Détruire la session de l'utilisateur
|
||||||
|
$this->session->unset_userdata('user_id');
|
||||||
|
$this->session->sess_destroy();
|
||||||
|
|
||||||
|
// Supprimer le cookie
|
||||||
|
delete_cookie('user_logged_in');
|
||||||
|
|
||||||
|
// Rediriger vers la page de connexion
|
||||||
|
redirect('utilisateur/connexion');
|
||||||
|
}
|
||||||
|
|
||||||
public function dashboard(){
|
public function dashboard(){
|
||||||
if(!$this->session->userdata('user_id')){
|
if(!$this->session->userdata('user_id')){
|
||||||
redirect('utilisateur/connexion');
|
redirect('utilisateur/connexion');
|
||||||
@ -93,12 +111,10 @@ class Utilisateur extends CI_Controller {
|
|||||||
|
|
||||||
// Charger les vues
|
// Charger les vues
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_logged_dark');
|
|
||||||
$this->load->view('dashboard', $data);
|
$this->load->view('dashboard', $data);
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function modifier(){
|
public function modifier(){
|
||||||
if(!$this->session->userdata('user_id')){
|
if(!$this->session->userdata('user_id')){
|
||||||
redirect('utilisateur/connexion');
|
redirect('utilisateur/connexion');
|
||||||
@ -127,10 +143,8 @@ class Utilisateur extends CI_Controller {
|
|||||||
|
|
||||||
$data['user'] = $this->Utilisateur_model->get_user_by_id($user_id);
|
$data['user'] = $this->Utilisateur_model->get_user_by_id($user_id);
|
||||||
$this->load->view('layout/header_dark');
|
$this->load->view('layout/header_dark');
|
||||||
$this->load->view('layout/header_logged_dark');
|
|
||||||
$this->load->view('dashboard', $data);
|
$this->load->view('dashboard', $data);
|
||||||
$this->load->view('layout/footer_dark');
|
$this->load->view('layout/footer_dark');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Dashboard</title>
|
<title>Dashboard</title>
|
||||||
<link rel="stylesheet" href="<?php echo base_url('assets/css/inscription'); ?>">
|
<link rel="stylesheet" href="<?php echo base_url('assets/css/inscription.css'); ?>">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>Bienvenue, <?php echo $user->prenom; ?></h2>
|
<h2>Bienvenue, <?php echo $user->prenom; ?> 👋 !</h2>
|
||||||
|
|
||||||
<?php if (isset($success)): ?>
|
<?php if (isset($success)): ?>
|
||||||
<p class="success"><?php echo $success; ?></p>
|
<p class="success"><?php echo $success; ?></p>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<?=link_tag('assets/css/header_not_logged_dark')?>
|
<?=link_tag('assets/css/header_not_logged_dark.css')?>
|
||||||
<?=link_tag('assets/img/Logo_ONZEUR.png')?>
|
<?=link_tag('assets/img/Logo_ONZEUR.png')?>
|
||||||
<?=link_tag(array(
|
<?=link_tag(array(
|
||||||
'href'=>'assets/img/Logo_ONZEUR.png',
|
'href'=>'assets/img/Logo_ONZEUR.png',
|
||||||
@ -12,3 +12,15 @@
|
|||||||
))?>
|
))?>
|
||||||
<?=link_tag('assets/css/footer_dark.css')?>
|
<?=link_tag('assets/css/footer_dark.css')?>
|
||||||
</head>
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php if (get_cookie('user_logged_in')): ?>
|
||||||
|
<!-- Utilisateur connecté -->
|
||||||
|
<?php $this->load->view('layout/header_logged_dark'); ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<!-- Utilisateur non connecté -->
|
||||||
|
<?php $this->load->view('layout/header_not_logged_dark'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<!-- Contenu de la page -->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
@ -90,6 +90,12 @@ label {
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.success {
|
||||||
|
color: green;
|
||||||
|
margin-top: 5px;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
.user-info {
|
.user-info {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
Loading…
Reference in New Issue
Block a user