diff --git a/WEB/Recherche.php b/WEB/Recherche.php index 89c5c47..8c55cbe 100644 --- a/WEB/Recherche.php +++ b/WEB/Recherche.php @@ -1,53 +1,18 @@ - - - - - - - - - - - - - -
- -

Rechercher un trajet

- -
- -

- - - -

- -

- - - -

- -

- - - -

- - -

- - - -

- -
- -
- - - - \ No newline at end of file + + + + + +
+

Rechercher un trajet

+
+

+

+

+

+
+
+ + diff --git a/WEB/connexionBD.php b/WEB/connexionBD.php new file mode 100644 index 0000000..4541648 --- /dev/null +++ b/WEB/connexionBD.php @@ -0,0 +1,7 @@ + diff --git a/WEB/inscription.php b/WEB/inscription.php index 8c5a3a7..2bdf50f 100644 --- a/WEB/inscription.php +++ b/WEB/inscription.php @@ -1,18 +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: @@ -29,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'); - } -} - ?> @@ -172,7 +164,7 @@ function init(){ diff --git a/WEB/ressources/navbarhtml.css b/WEB/ressources/navbarhtml.css new file mode 100644 index 0000000..dd8061b --- /dev/null +++ b/WEB/ressources/navbarhtml.css @@ -0,0 +1,39 @@ +#menuDiv{ + width: 100%; + display: block; +} + +#menuDiv a{ + font-family: "Arial"; + font-size: 1em; +} + +#menu { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + background-color: rgb(65, 154, 28); +} + +.menuItem { + display: flex; + flex-wrap: nowrap; + align-items: center; + justify-content: center; + color: white; + width: 10%; + min-width: 5em; + font-weight: bold; + text-decoration: none; + padding: 0.8em; + border-bottom: 4px solid rgb(65, 154, 28); + border-top: 4px solid rgb(65, 154, 28); + font-size: 1.1em; + text-align: center; +} + +.menuItem:hover{ + cursor: pointer; + border-bottom: 4px solid orange; +} \ No newline at end of file diff --git a/WEB/ressources/navbarhtml.php b/WEB/ressources/navbarhtml.php new file mode 100644 index 0000000..4902d71 --- /dev/null +++ b/WEB/ressources/navbarhtml.php @@ -0,0 +1,19 @@ + + \ No newline at end of file diff --git a/WEB/tableauBord/tableauBord.php b/WEB/tableauBord/tableauBord.php index 5dafd9f..c478833 100644 --- a/WEB/tableauBord/tableauBord.php +++ b/WEB/tableauBord/tableauBord.php @@ -1,245 +1,210 @@ = current_date;", array($mail)); - if($result){ - $row = pg_fetch_array($result); - return $row[0]; - } - return 0; - } - - function getTrajetsReserves($mail){ - global $db; - $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); - return $row[0]; - } - return 0; - } - - function getMessagesNonLus($mail){ - global $db; - $result = pg_query_params($db, "SELECT COUNT(*) from Message WHERE mailRecepteur = $1 AND estLu = FALSE;", array($mail)); - if($result){ - $row = pg_fetch_array($result); - $login = $row[0]; - return $login; - } +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; +$modele = isset($_POST['modele']) ? $_POST['modele'] : NULL; +$nbplaces = isset($_POST['nbplaces']) ? $_POST['nbplaces'] : NULL; +$anneefab = isset($_POST['anneefab']) ? $_POST['anneefab'] : NULL; + +if(isset($_POST['submitadd'])){ + addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab); +} +if(isset($_POST['submitchange'])){ + changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab); +} +if(isset($_POST['submitshow'])){ + showVoiture($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); + $prenom = $row[0]; + return $prenom; + } + return null; +} + +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); + $login = $row[0]; + return $login; + } + return null; +} + +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); + return $row[0]; + } + return 0; +} + +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); + return $row[0]; + } + return 0; +} + +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); + $login = $row[0]; + return $login; + } +} + +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){ + $row = pg_fetch_array($result); + $login = $row[0]; + return $login; + } +} + +function getPathImgProfil($mail){ + if (file_exists("../imageProfil/$mail.png")){ + return "../imageProfil/$mail.png"; + } + return "../imageProfil/default.svg"; +} + +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($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($db){ + $requete = "SELECT * FROM public.voiture WHERE voiture.mail = '".$_SESSION['mail']."';"; + if($donnees = pg_query($db, $requete)){ + while($res = pg_fetch_assoc($donnees)){ + echo "matricule = ".$res['matricule']."
"; + echo "marque = ".$res['marque']."
"; + echo "modele = ".$res['modele']."
"; + echo "nombre de places = ".$res['nbplaces']."
"; + echo "année de fabrication = ".$res['anneefab']."
"; } - - function getAvisNonLus($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){ - $row = pg_fetch_array($result); - $login = $row[0]; - return $login; - } - } - - function getPathImgProfil($mail){ - if (file_exists("../imageProfil/$mail.png")){ - return "../imageProfil/$mail.png"; - } - return "../imageProfil/default.svg"; - } - - function addVoiture($matricule, $marque, $modele, $nbplaces, $anneefab){ - global $db; - $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; - $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; - $requete = "SELECT * FROM public.voiture WHERE voiture.mail = '".$_SESSION['mail']."';"; - if($donnees = pg_query($db, $requete)){ - while($res = pg_fetch_assoc($donnees)){ - echo "matricule = ".$res['matricule']."
"; - echo "marque = ".$res['marque']."
"; - echo "modele = ".$res['modele']."
"; - echo "nombre de places = ".$res['nbplaces']."
"; - echo "année de fabrication = ".$res['anneefab']."
"; - } - } - } - + } +} ?> - - - - - Tableau de bord - - + + + Tableau de bord -
+ + +
-

Bienvenue

-
- +

Bienvenue

+
+ +
+ +
+
+ +

Vous avez trajets proposés à effectuer.

-
- Déposer un trajet - Rechercher un trajet +
+ +

Vous avez trajets réservés à effectuer.

-
-
- -

Vous avez trajets proposés à effectuer.

-
-
- -

Vous avez trajets réservés à effectuer.

-
-
- -

Vous avez messages non lus.

-
-
- -

Vous avez avis non lus.

-
+
+ +

Vous avez messages non lus.

-
-
- Ajouter une voiture - Modifier ma voiture - Afficher ma voiture -
-
- - - - -
+
diff --git a/54255712_405391970020373_6737760332493619200_n.jpg b/doc/54255712_405391970020373_6737760332493619200_n.jpg similarity index 100% rename from 54255712_405391970020373_6737760332493619200_n.jpg rename to doc/54255712_405391970020373_6737760332493619200_n.jpg diff --git a/Cahier_des_charges_G1_E.pdf b/doc/Cahier_des_charges_G1_E.pdf similarity index 100% rename from Cahier_des_charges_G1_E.pdf rename to doc/Cahier_des_charges_G1_E.pdf diff --git a/Dossier_de_Conception_G1_E.pdf b/doc/Dossier_de_Conception_G1_E.pdf similarity index 100% rename from Dossier_de_Conception_G1_E.pdf rename to doc/Dossier_de_Conception_G1_E.pdf diff --git a/Ordre de passage MCD 21 mars.docx b/doc/Ordre de passage MCD 21 mars.docx similarity index 100% rename from Ordre de passage MCD 21 mars.docx rename to doc/Ordre de passage MCD 21 mars.docx diff --git a/a changer mcd.docx b/doc/a changer mcd.docx similarity index 100% rename from a changer mcd.docx rename to doc/a changer mcd.docx diff --git a/anciennes années/Rapport_du_projet_UML_Co-voiturage_2017.pdf b/doc/anciennes années/Rapport_du_projet_UML_Co-voiturage_2017.pdf similarity index 100% rename from anciennes années/Rapport_du_projet_UML_Co-voiturage_2017.pdf rename to doc/anciennes années/Rapport_du_projet_UML_Co-voiturage_2017.pdf diff --git a/diagramme d'activité.pdf b/doc/diagramme d'activité.pdf similarity index 100% rename from diagramme d'activité.pdf rename to doc/diagramme d'activité.pdf diff --git a/diagrammeSequenceDetailleClient.pdf b/doc/diagrammeSequenceDetailleClient.pdf similarity index 100% rename from diagrammeSequenceDetailleClient.pdf rename to doc/diagrammeSequenceDetailleClient.pdf diff --git a/diagrammeSequenceDetailleClient.png b/doc/diagrammeSequenceDetailleClient.png similarity index 100% rename from diagrammeSequenceDetailleClient.png rename to doc/diagrammeSequenceDetailleClient.png diff --git a/idees.docx b/doc/idees.docx similarity index 100% rename from idees.docx rename to doc/idees.docx diff --git a/mcd.mcd b/doc/mcd.mcd similarity index 100% rename from mcd.mcd rename to doc/mcd.mcd diff --git a/mcd.png b/doc/mcd.png similarity index 100% rename from mcd.png rename to doc/mcd.png diff --git a/mld.png b/doc/mld.png similarity index 100% rename from mld.png rename to doc/mld.png diff --git a/partie.docx b/doc/partie.docx similarity index 100% rename from partie.docx rename to doc/partie.docx diff --git a/projet pack surf wifi.png b/doc/projet pack surf wifi.png similarity index 100% rename from projet pack surf wifi.png rename to doc/projet pack surf wifi.png diff --git a/repartition.txt b/doc/repartition.txt similarity index 100% rename from repartition.txt rename to doc/repartition.txt