From a682ee28905e45ef7372471510226ebc0548fd89 Mon Sep 17 00:00:00 2001 From: "remi.biette" Date: Thu, 9 May 2019 16:35:10 +0200 Subject: [PATCH 01/31] Ajout page profil --- WEB/profil.css | 22 ++++++++++++++ WEB/profil.php | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 WEB/profil.css create mode 100644 WEB/profil.php diff --git a/WEB/profil.css b/WEB/profil.css new file mode 100644 index 0000000..d73e97f --- /dev/null +++ b/WEB/profil.css @@ -0,0 +1,22 @@ +*{ + margin: 0; + padding: 0; + font-family: "Arial"; +} + +#divImgProfil{ + width: 100%; + display: flex; + flex-wrap: nowrap; + justify-content: center; +} + +#imgProfil{ + background-color: white; + margin-top: 2.5em; + width: 60%; + height: 60%; + max-width: 210px; + max-height: 210px; + border-radius: 10px; +} \ No newline at end of file diff --git a/WEB/profil.php b/WEB/profil.php new file mode 100644 index 0000000..362991b --- /dev/null +++ b/WEB/profil.php @@ -0,0 +1,78 @@ + + + + + + + + Profil + + + +
+

Profil

+
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
+

Si vous avez déjà un compte cliquez ici.

+
+ + From 2ab4061db9636796c7f379cfeb4a4961dfe62eca Mon Sep 17 00:00:00 2001 From: flavien Date: Thu, 9 May 2019 17:24:23 +0200 Subject: [PATCH 02/31] simplified the echo --- WEB/ressources/navbarhtml.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/WEB/ressources/navbarhtml.php b/WEB/ressources/navbarhtml.php index aca21e8..1502692 100644 --- a/WEB/ressources/navbarhtml.php +++ b/WEB/ressources/navbarhtml.php @@ -1,5 +1,20 @@ -'.$title.''; -} -?> + + + + + + + <?php echo $title;?> + + + + From 158d2825e08c20ae8ceffd4939c5425f1c5b1adc Mon Sep 17 00:00:00 2001 From: "remi.biette" Date: Fri, 10 May 2019 09:43:17 +0200 Subject: [PATCH 03/31] Modification du systeme de connexion a la bd --- WEB/connectionBD.php | 14 +------------- WEB/deconnexion.php | 26 ++++++++------------------ WEB/index.php | 3 +-- WEB/inscription.php | 3 +-- 4 files changed, 11 insertions(+), 35 deletions(-) diff --git a/WEB/connectionBD.php b/WEB/connectionBD.php index 8ee39c4..4541648 100644 --- a/WEB/connectionBD.php +++ b/WEB/connectionBD.php @@ -1,19 +1,7 @@ - + $db = pg_connect("host=$host port=5432 dbname=$dbname user=$user password=$pass") or die("Erreur lors de la connexion à la base de données."); \ No newline at end of file diff --git a/WEB/deconnexion.php b/WEB/deconnexion.php index c4dfb65..02d7c42 100644 --- a/WEB/deconnexion.php +++ b/WEB/deconnexion.php @@ -1,21 +1,11 @@ Date: Fri, 10 May 2019 09:46:22 +0200 Subject: [PATCH 04/31] Modification connexion bd dans tableauBord.php --- WEB/tableauBord/tableauBord.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WEB/tableauBord/tableauBord.php b/WEB/tableauBord/tableauBord.php index a20fe97..541fee7 100644 --- a/WEB/tableauBord/tableauBord.php +++ b/WEB/tableauBord/tableauBord.php @@ -1,10 +1,10 @@  Date: Fri, 10 May 2019 10:21:34 +0200 Subject: [PATCH 05/31] Modification agencement des fonctions appelant la bd --- WEB/{connectionBD.php => connexionBD.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename WEB/{connectionBD.php => connexionBD.php} (100%) diff --git a/WEB/connectionBD.php b/WEB/connexionBD.php similarity index 100% rename from WEB/connectionBD.php rename to WEB/connexionBD.php From a81a2169fe13097d1a875cdf60999cbebee8e63c Mon Sep 17 00:00:00 2001 From: "remi.biette" Date: Fri, 10 May 2019 10:23:27 +0200 Subject: [PATCH 06/31] Modification agencement des fonctions et fichiers appelant la bd --- WEB/deconnexion.php | 2 +- WEB/index.php | 62 +++++++-------- WEB/inscription.php | 131 +++++++++++++++----------------- WEB/tableauBord/tableauBord.php | 67 +++++++--------- 4 files changed, 115 insertions(+), 147 deletions(-) diff --git a/WEB/deconnexion.php b/WEB/deconnexion.php index 02d7c42..3941d16 100644 --- a/WEB/deconnexion.php +++ b/WEB/deconnexion.php @@ -1,6 +1,6 @@ diff --git a/WEB/inscription.php b/WEB/inscription.php index e0a58dd..2bdf50f 100644 --- a/WEB/inscription.php +++ b/WEB/inscription.php @@ -1,17 +1,58 @@ 0) { + echo "

PHP a ignoré les données POST à ​​cause d'une requête dépassant post_max_size (" . ini_get('post_max_size') . ").

"; + exit(); + } + if (isset($_POST['mail_field'])) { + $login = htmlentities(pg_escape_string($_POST['login_field'])); + $password = htmlentities(pg_escape_string($_POST['password'])); + $prenom = htmlentities(pg_escape_string($_POST['prenom'])); + $nom = htmlentities(pg_escape_string($_POST['nom'])); + $dateN = htmlentities(pg_escape_string($_POST['dateN'])); + $mail = strtolower(htmlentities(pg_escape_string($_POST['mail_field']))); + $phone = htmlentities(pg_escape_string($_POST['phone'])); + + if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) { + header('Location: inscription.php?error=1'); + exit(); + } elseif (!isMailUnique($db, $mail)) { + header('Location: inscription.php?error=2'); + exit(); + } elseif (!isLoginUnique($db, $login)) { + header('Location: inscription.php?error=3'); + exit(); + } else { + uploadAvatar($mail); + $result = creerUtilisateur($db, $mail, $password, $prenom, $nom, $login, $phone, $dateN); + if ($result) { + header('Location: index.php'); + } else { + header('Location: inscription.php?error=6'); + } + } + + } +} else { + header('Location: tableauBord/tableauBord.php'); +} + +function printError() +{ + if (isset($_GET['error'])) { $erreur = getError($_GET['error']); echo "

$erreur

"; } } -function getError($code){ - switch ($code){ +function getError($code) +{ + switch ($code) { case 1: return "L'adresse mail est invalide."; case 2: @@ -28,99 +69,51 @@ function getError($code){ } } -function isMailUnique($mail){ - global $db; +function isMailUnique($db, $mail) +{ $result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail)); - if($result){ + if ($result) { $row = pg_fetch_array($result); return (strcmp($row['mail'], $mail) != 0); } return false; } -function isLoginUnique($login){ - global $db; +function isLoginUnique($db, $login) +{ $result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE login = $1;", array($login)); - if($result){ + if ($result) { $row = pg_fetch_array($result); return (strcmp($row['login'], $login) != 0); } return false; } -function creerUtilisateur($mail, $password, $prenom, $nom, $login, $phone, $dateN){ - global $db; +function creerUtilisateur($db, $mail, $password, $prenom, $nom, $login, $phone, $dateN) +{ $result = pg_query_params($db, "INSERT INTO Utilisateur VALUES ($1, $2, $3, $4, $5, $6, to_date($7, 'YYYY/MM/DD'), false);", array($mail, $password, $prenom, $nom, $login, $phone, $dateN)); return $result; } -function uploadAvatar($mail){ - if(isset($_FILES['avatar']) and $_FILES['avatar']['name'] != "") { +function uploadAvatar($mail) +{ + if (isset($_FILES['avatar']) and $_FILES['avatar']['name'] != "") { $target_file = "imageProfil/$mail.png"; $file_tmp = $_FILES['avatar']['tmp_name']; $extension = end(explode('.', $_FILES['avatar']['name'])); $check = getimagesize($file_tmp); - if($check === false or !in_array($extension, array('png'))) { + if ($check === false or !in_array($extension, array('png'))) { header('Location: inscription.php?error=4'); exit(); - } - else if ($_FILES['avatar']['size'] > 2 * 1024 * 1024){ + } else if ($_FILES['avatar']['size'] > 2 * 1024 * 1024) { header('Location: inscription.php?error=5'); exit(); - } - else{ + } else { move_uploaded_file($file_tmp, $target_file); } } } - -function init(){ - session_start(); - if(!isset($_SESSION['mail'])){ - if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) && empty($_FILES) && $_SERVER['CONTENT_LENGTH'] > 0 ){ - echo "

PHP a ignoré les données POST à ​​cause d'une requête dépassant post_max_size (".ini_get('post_max_size').").

"; - exit(); - } - if(isset($_POST['mail_field'])){ - $login = htmlentities(pg_escape_string ($_POST['login_field'])); - $password = htmlentities(pg_escape_string ($_POST['password'])); - $prenom = htmlentities(pg_escape_string ($_POST['prenom'])); - $nom = htmlentities(pg_escape_string ($_POST['nom'])); - $dateN = htmlentities(pg_escape_string ($_POST['dateN'])); - $mail = strtolower(htmlentities(pg_escape_string ($_POST['mail_field']))); - $phone = htmlentities(pg_escape_string ($_POST['phone'])); - - if(!filter_var($mail, FILTER_VALIDATE_EMAIL)){ - header('Location: inscription.php?error=1'); - exit(); - } - elseif(!isMailUnique($mail)){ - header('Location: inscription.php?error=2'); - exit(); - } - elseif(!isLoginUnique($login)){ - header('Location: inscription.php?error=3'); - exit(); - } - else{ - uploadAvatar($mail); - $result = creerUtilisateur($mail, $password, $prenom, $nom, $login, $phone, $dateN); - if($result){ - header('Location: index.php'); - } - else{ - header('Location: inscription.php?error=6'); - } - } - - } - } - else{ - header('Location: tableauBord/tableauBord.php'); - } -} - ?> @@ -171,7 +164,7 @@ function init(){ diff --git a/WEB/tableauBord/tableauBord.php b/WEB/tableauBord/tableauBord.php index 541fee7..138707c 100644 --- a/WEB/tableauBord/tableauBord.php +++ b/WEB/tableauBord/tableauBord.php @@ -3,9 +3,15 @@ include '../ressources/navbarHTML.php'; navbarHTML("Tableau de bord"); -require_once ('../connectionBD.php'); -$mail = null; -init(); +require_once('../connexionBD.php'); +session_start(); + +//Si on est pas connecté redirection vers la page de connexion +if(!isset($_SESSION['mail'])){ + header('Location: ../index.php'); + exit(); +} +$mail = $_SESSION['mail']; $matricule = isset($_POST['matricule']) ? $_POST['matricule'] : NULL; //recuperation valeur formulaire, isset pour eviter l'erreur "Notice: Undefined index" $marque = isset($_POST['marque']) ? $_POST['marque'] : NULL; @@ -14,30 +20,16 @@ $nbplaces = isset($_POST['nbplaces']) ? $_POST['nbplaces'] : NULL; $anneefab = isset($_POST['anneefab']) ? $_POST['anneefab'] : NULL; if(isset($_POST['submitadd'])){ - addVoiture($matricule, $marque, $modele, $nbplaces, $anneefab); + addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab); } if(isset($_POST['submitchange'])){ - changeVoiture($matricule, $marque, $modele, $nbplaces, $anneefab); + changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab); } if(isset($_POST['submitshow'])){ - showVoiture(); -} - -function init(){ - session_start(); - global $mail; - //Si on est pas connecté redirection vers la page de connexion - if(!isset($_SESSION['mail'])){ - header('Location: ../index.php'); - exit(); - } - else{ - $mail = $_SESSION['mail']; - } + showVoiture($db); } -function getPrenom($mail){ - global $db; +function getPrenom($db, $mail){ $result = pg_query_params($db, "SELECT prenom from Utilisateur WHERE mail = $1;", array($mail)); if($result){ $row = pg_fetch_array($result); @@ -47,8 +39,7 @@ function getPrenom($mail){ return null; } -function getLogin($mail){ - global $db; +function getLogin($db, $mail){ $result = pg_query_params($db, "SELECT login from Utilisateur WHERE mail = $1;", array($mail)); if($result){ $row = pg_fetch_array($result); @@ -58,8 +49,7 @@ function getLogin($mail){ return null; } -function getTrajetsProposes($mail){ - global $db; +function getTrajetsProposes($db, $mail){ $result = pg_query_params($db, "SELECT COUNT(*) from Trajet WHERE mailProposition = $1 AND estAnnule = false AND datedepart >= current_date;", array($mail)); if($result){ $row = pg_fetch_array($result); @@ -68,8 +58,7 @@ function getTrajetsProposes($mail){ return 0; } -function getTrajetsReserves($mail){ - global $db; +function getTrajetsReserves($db, $mail){ $result = pg_query_params($db, "SELECT COUNT(*) FROM trajet tr, reserver r WHERE r.codetrajet = tr.codetrajet AND mailutilisateur = $1 AND etatres != 'Annulée' AND estAnnule = false AND datedepart >= current_date;", array($mail)); if($result){ $row = pg_fetch_array($result); @@ -78,8 +67,7 @@ function getTrajetsReserves($mail){ return 0; } -function getMessagesNonLus($mail){ - global $db; +function getMessagesNonLus($db, $mail){ $result = pg_query_params($db, "SELECT COUNT(*) from Message WHERE mailRecepteur = $1 AND estLu = FALSE;", array($mail)); if($result){ $row = pg_fetch_array($result); @@ -88,7 +76,7 @@ function getMessagesNonLus($mail){ } } -function getAvisNonLus($mail){ +function getAvisNonLus($db, $mail){ global $db; $result = pg_query_params($db, "SELECT COUNT(tr.mailProposition) FROM Trajet tr, Avis av WHERE tr.codeTrajet = av.codeTrajet AND av.estLu = false AND tr.mailProposition = $1;", array($mail)); if($result){ @@ -105,21 +93,18 @@ function getPathImgProfil($mail){ return "../imageProfil/default.svg"; } -function addVoiture($matricule, $marque, $modele, $nbplaces, $anneefab){ - global $db; +function addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab){ $requete = "INSERT INTO public.voiture (matricule, marque, modele, nbplaces, anneefab, mail) VALUES ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."','".$_SESSION['mail']."');"; pg_query($db, $requete); } -function changeVoiture($matricule, $marque, $modele, $nbplaces, $anneefab){ - global $db; +function changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab){ $requete = "UPDATE public.voiture SET (matricule, marque, modele, nbplaces, anneefab) = ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."') WHERE mail = '".$_SESSION['mail']."';"; echo "requete =".$requete; pg_query($db, $requete); } -function showVoiture(){ - global $db; +function showVoiture($db){ $requete = "SELECT * FROM public.voiture WHERE voiture.mail = '".$_SESSION['mail']."';"; if($donnees = pg_query($db, $requete)){ while($res = pg_fetch_assoc($donnees)){ @@ -142,7 +127,7 @@ function showVoiture(){
-

Bienvenue

+

Bienvenue

@@ -153,19 +138,19 @@ function showVoiture(){
-

Vous avez trajets proposés à effectuer.

+

Vous avez trajets proposés à effectuer.

-

Vous avez trajets réservés à effectuer.

+

Vous avez trajets réservés à effectuer.

-

Vous avez messages non lus.

+

Vous avez messages non lus.

-

Vous avez avis non lus.

+

Vous avez avis non lus.

From eda70327ac8c0aa949d2fa422957daf7acea0b89 Mon Sep 17 00:00:00 2001 From: "remi.biette" Date: Sat, 11 May 2019 12:44:29 +0200 Subject: [PATCH 07/31] Page profil v1 --- WEB/connectionBD.php | 19 ------ WEB/profil.css | 8 +++ WEB/profil.php | 155 ++++++++++++++++++++++++++++++++++++++----- 3 files changed, 147 insertions(+), 35 deletions(-) delete mode 100644 WEB/connectionBD.php diff --git a/WEB/connectionBD.php b/WEB/connectionBD.php deleted file mode 100644 index 8ee39c4..0000000 --- a/WEB/connectionBD.php +++ /dev/null @@ -1,19 +0,0 @@ - - diff --git a/WEB/profil.css b/WEB/profil.css index d73e97f..b977ff1 100644 --- a/WEB/profil.css +++ b/WEB/profil.css @@ -11,6 +11,10 @@ justify-content: center; } +#mail_field, #dateN_field{ + background-color: lightgray; +} + #imgProfil{ background-color: white; margin-top: 2.5em; @@ -19,4 +23,8 @@ max-width: 210px; max-height: 210px; border-radius: 10px; +} + +#changePass{ + margin-bottom: 0.7em; } \ No newline at end of file diff --git a/WEB/profil.php b/WEB/profil.php index 362991b..f1c21ae 100644 --- a/WEB/profil.php +++ b/WEB/profil.php @@ -1,41 +1,160 @@ 2 * 1024 * 1024){ + header('Location: inscription.php?error=5'); + exit(); + } + else{ + move_uploaded_file($file_tmp, $target_file); + } +} + +function modifierUtilisateur($db, $prenom, $nom, $login, $phone){ + $result = pg_query_params($db, "UPDATE Utilisateur SET prenom = $1, nom = $2, login = $3, telephone = $4;", array($prenom, $nom, $login, $phone)); + return $result; +} + +function getUser($db, $mail){ $result = pg_query_params($db,"SELECT * FROM Utilisateur WHERE mail = $1;", array($mail)); return pg_fetch_array($result); } +function printError(){ + if(isset($_GET['error'])){ + $erreur = getErrorProfil($_GET['error']); + echo "

$erreur

"; + } +} + +function isLoginUniqueModifier($db, $mail, $login){ + $result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE login = $1 AND mail != $2;", array($login, $mail)); + if($result){ + $row = pg_fetch_array($result); + return (strcmp($row['login'], $login) != 0); + } + return false; +} + +function getErrorProfil($code){ + switch ($code){ + case 1: + return "Ce login est déjà associé à un compte."; + case 2: + return "Les mots de passe ne correspondent pas."; + case 3: + return "Erreur lors de la récupération des informations de profil."; + case 4: + return "Le fichier envoyé doit être une image au format PNG ou JPEG."; + case 5: + return "La taille de l'image ne doit pas dépasser 2 MB."; + case 6: + return "Erreur lors de la modification du compte."; + + } +} + ?> - - Profil + + + Profil

Profil

- +
+ +
+
@@ -45,7 +164,12 @@ function getUser($mail){
- Changer de mot de passe. + + +
+
+ +
@@ -65,14 +189,13 @@ function getUser($mail){
- +
- + -

Si vous avez déjà un compte cliquez ici.

From f9410e6bdd0109488219e9dc6760916f4b2d4bc4 Mon Sep 17 00:00:00 2001 From: flavien Date: Thu, 16 May 2019 11:13:05 +0200 Subject: [PATCH 08/31] updated name of navbarhtml function to match debians file system --- WEB/ressources/navbarhtml.php | 2 +- WEB/tableauBord/tableauBord.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/WEB/ressources/navbarhtml.php b/WEB/ressources/navbarhtml.php index 1502692..4a15e22 100644 --- a/WEB/ressources/navbarhtml.php +++ b/WEB/ressources/navbarhtml.php @@ -1,4 +1,4 @@ - + diff --git a/WEB/tableauBord/tableauBord.php b/WEB/tableauBord/tableauBord.php index a20fe97..0c6b7ca 100644 --- a/WEB/tableauBord/tableauBord.php +++ b/WEB/tableauBord/tableauBord.php @@ -1,6 +1,6 @@  Date: Thu, 16 May 2019 11:23:12 +0200 Subject: [PATCH 09/31] now navbarhtml.php has only the navbarhtml --- WEB/ressources/navbarhtml.php | 12 +----------- WEB/tableauBord/tableauBord.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/WEB/ressources/navbarhtml.php b/WEB/ressources/navbarhtml.php index 4a15e22..79d979b 100644 --- a/WEB/ressources/navbarhtml.php +++ b/WEB/ressources/navbarhtml.php @@ -1,11 +1,4 @@ - - - - - - - <?php echo $title;?> -