mirror of
https://grond.iut-fbleau.fr/stiti/SAE_2.02
synced 2024-11-12 22:01:41 +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();
|
||||
$autoload['helper'] = array('url', 'form', 'html', 'cookie');
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
|
@ -33,36 +33,18 @@ class Albums extends CI_Controller {
|
||||
$data['genres'] = $this->model_music->getGenres();
|
||||
$data['artists'] = $this->model_music->getArtists();
|
||||
|
||||
include 'temporaire.php';
|
||||
if($logged == true){
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('layout/header_logged_dark');
|
||||
$this->load->view('albums_list', $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('albums_list', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('albums_list', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
|
||||
public function view($id){
|
||||
$album = $this->model_music->get_album_by_id($id);
|
||||
$data['album'] = $album;
|
||||
|
||||
include 'temporaire.php';
|
||||
if($logged == true){
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('layout/header_logged_dark');
|
||||
$this->load->view('album_view', $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('album_view', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
$this->load->view('layout/header_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['mostUsedGenre'] = $mostUsedGenre; // Passer $mostUsedGenre à la vue
|
||||
|
||||
include 'temporaire.php';
|
||||
if($logged == true){
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('layout/header_logged_dark');
|
||||
$this->load->view('artiste_details', $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('artiste_details', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('artiste_details', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
|
||||
} else {
|
||||
// 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['current_order'] = $order;
|
||||
|
||||
include 'temporaire.php';
|
||||
if($logged == true){
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('layout/header_logged_dark');
|
||||
$this->load->view('artists_list', $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('artists_list', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
$this->load->view('layout/header_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();
|
||||
|
||||
// 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_logged_dark');
|
||||
$this->load->view('accueil', $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('accueil', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('accueil', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
}
|
||||
?>
|
@ -11,18 +11,9 @@ class MentionsLegales extends CI_Controller {
|
||||
|
||||
public function index()
|
||||
{
|
||||
include 'temporaire.php';
|
||||
if($logged == true){
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('layout/header_logged_dark');
|
||||
$this->load->view('mentions-legals');
|
||||
$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');
|
||||
}
|
||||
$this->load->view('layout/header_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
|
||||
|
||||
// Charger la vue
|
||||
include 'temporaire.php';
|
||||
if($logged == true){
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('layout/header_logged_dark');
|
||||
$this->load->view('musiques_list', $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('musiques_list', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
$this->load->view('layout/header_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['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_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('layout/footer_dark');
|
||||
}
|
||||
return;
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('search_results', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
|
||||
// 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['artistes'] = $artistes;
|
||||
|
||||
if($logged == true){
|
||||
$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('layout/footer_dark');
|
||||
}
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('search_results', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,12 @@ class Utilisateur extends CI_Controller {
|
||||
|
||||
public function __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->model('Utilisateur_model');
|
||||
$this->load->helper('html');
|
||||
}
|
||||
|
||||
|
||||
public function inscription(){
|
||||
// Définir les règles de validation
|
||||
@ -24,7 +25,6 @@ class Utilisateur extends CI_Controller {
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
// Charger la vue avec les erreurs
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('layout/header_not_logged_dark');
|
||||
$this->load->view('inscription');
|
||||
$this->load->view('layout/footer_dark');
|
||||
} else {
|
||||
@ -43,7 +43,6 @@ class Utilisateur extends CI_Controller {
|
||||
} else {
|
||||
$data['error'] = 'Une erreur est survenue. Veuillez réessayer.';
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('layout/header_not_logged_dark');
|
||||
$this->load->view('inscription', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
@ -58,7 +57,6 @@ class Utilisateur extends CI_Controller {
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
// Charger la vue avec les erreurs
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('layout/header_not_logged_dark');
|
||||
$this->load->view('connexion');
|
||||
$this->load->view('layout/footer_dark');
|
||||
} else {
|
||||
@ -72,16 +70,36 @@ class Utilisateur extends CI_Controller {
|
||||
if ($user && password_verify($password, $user->password)) {
|
||||
// Connexion réussie, enregistrer l'utilisateur dans la session
|
||||
$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');
|
||||
} else {
|
||||
$data['error'] = 'Email ou mot de passe incorrect.';
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('layout/header_logged_dark');
|
||||
$this->load->view('connexion', $data);
|
||||
$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(){
|
||||
if(!$this->session->userdata('user_id')){
|
||||
redirect('utilisateur/connexion');
|
||||
@ -93,12 +111,10 @@ class Utilisateur extends CI_Controller {
|
||||
|
||||
// Charger les vues
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('layout/header_logged_dark');
|
||||
$this->load->view('dashboard', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
|
||||
|
||||
public function modifier(){
|
||||
if(!$this->session->userdata('user_id')){
|
||||
redirect('utilisateur/connexion');
|
||||
@ -127,10 +143,8 @@ class Utilisateur extends CI_Controller {
|
||||
|
||||
$data['user'] = $this->Utilisateur_model->get_user_by_id($user_id);
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('layout/header_logged_dark');
|
||||
$this->load->view('dashboard', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,11 +4,11 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<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>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>Bienvenue, <?php echo $user->prenom; ?></h2>
|
||||
<h2>Bienvenue, <?php echo $user->prenom; ?> 👋 !</h2>
|
||||
|
||||
<?php if (isset($success)): ?>
|
||||
<p class="success"><?php echo $success; ?></p>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<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(array(
|
||||
'href'=>'assets/img/Logo_ONZEUR.png',
|
||||
@ -11,4 +11,16 @@
|
||||
'type'=>'image/x-icon'
|
||||
))?>
|
||||
<?=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;
|
||||
}
|
||||
|
||||
.success {
|
||||
color: green;
|
||||
margin-top: 5px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
|
Loading…
Reference in New Issue
Block a user