Merge branch 'master' into plannification

This commit is contained in:
Flavien Haas 2019-05-22 16:50:53 +02:00
commit 9801d58650
34 changed files with 12119 additions and 652 deletions

View File

@ -1,34 +1,27 @@
.centrage{
text-align : center;
font-size: 20px;
}
}
.global {
position: absolute; /* postulat de départ */
position: absolute; /* postulat de départ */
top: 45%; left: 50%; /* à 50%/50% du parent référent */
transform: translate(-50%, -50%); /* décalage de 50% de sa propre taille */
text-align : center;
}
}
.fort {
font-weight: bold;
font-weight: bold;
text-align : center;
text-decoration: underline;
font-size : 30px;
}
}
.bord{
border-radius: 20px;
border-left: 2px solid black;
border-right: 2px solid black;
border-top: 2px solid black;
border-bottom: 2px solid black;
padding : 20px 80px 60px 80px;
}
border-radius: 20px;
border-left: 2px solid black;
border-right: 2px solid black;
border-top: 2px solid black;
border-bottom: 2px solid black;
padding : 20px 80px 60px 80px;
}

View File

@ -1,19 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: REMI
* Date: 16/04/2019
* Time: 14:46
*/
function connexionBD(){
$host = "localhost";
$dbname = "projet";
$user = "utilisateur";
$pass = "-stri-";
$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.");
return $db;
}
?>

7
WEB/connexionBD.php Normal file
View File

@ -0,0 +1,7 @@
<?php
$host = "localhost";
$dbname = "projet";
$user = "utilisateur";
$pass = "-stri-";
$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.");
?>

View File

@ -1,21 +1,11 @@
<?php
/**
* Created by PhpStorm.
* User: REMI
* Date: 19/04/2019
* Time: 10:10
*/
require 'connectionBD.php';
$db = connexionBD();
init();
require_once ('connexionBD.php');
function init(){
session_start();
if (isset($_SESSION['mail'])){
session_unset();
session_destroy();
}
header('Location: index.php');
exit();
}
session_start();
if (isset($_SESSION['mail'])){
session_unset();
session_destroy();
}
header('Location: index.php');

View File

@ -0,0 +1,96 @@
*{
font-family: "Arial";
padding: 0;
margin: 0;
}
body{
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: center;
align-items: center;
}
h1{
font-size: 2em;
text-align: center;
margin-bottom: 3em;
}
.villeSelect, .villeText{
box-sizing: border-box;
margin-bottom: 0.7em;
}
.villeText{
width: 20%;
}
.villeSelect{
margin-bottom: 0.7em;
margin-left: 2%;
width: 33%;
}
#supprimerEtape{
display: none;
}
#boutonEtape{
margin-top: 1.5em;
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: space-between;
}
#submit{
margin-top: 1em;
margin-left: 50%;
transform: translate(-50%);
}
#formulaire{
background-color: white;
border-radius: 10px;
padding: 4em;
width: 40%;
}
.form{
box-sizing: border-box;
width: 55%;
margin-bottom: 0.7em;
}
.button{
cursor: pointer;
font-weight: bold;
padding: 8px;
color: white;
background-color: rgb(65, 154, 28);
border-radius: 5em;
border: none;
}
.line{
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: left;
width: 100%;
}
.error{
margin-top: 1em;
color: red;
text-align: center;
}
.label{
box-sizing: border-box;
font-size: 1.1em;
width: 45%;
min-width: 8em;
}

View File

@ -0,0 +1,55 @@
$(document).ready(function () {
//copy options
let options = $('#villeDepart option').clone();
//react on keyup in textbox
$('#villeDepartText').keyup(function () {
let val = $(this).val().toString().toLowerCase();
$('#villeDepart').empty();
//take only the options containing your filter text or all if empty
options.filter(function (idx, el) {
return val === '' || $(el).text().toLowerCase().indexOf(val) >= 0;
}).appendTo('#villeDepart');//add it to list
});
//copy options
let optionsEtape = $('#villeEtape option').clone();
//react on keyup in textbox
$('#villeEtapeText').keyup(function () {
let val = $(this).val().toString().toLowerCase();
$('#villeEtape').empty();
//take only the options containing your filter text or all if empty
optionsEtape.filter(function (idx, el) {
return val === '' || $(el).text().toLowerCase().indexOf(val) >= 0;
}).appendTo('#villeEtape');//add it to list
});
$("#ajoutEtape").click(function () {
let depart = $("#villeDepart");
let etape = $("#villeEtape");
let nbEtape = $("#nbEtapes");
if(etape.val() != null && etape.val() !== "" && depart.val() != null && depart.val() !== ""){
let option = $("#villeEtape option:selected");
let numero = (parseInt(nbEtape.val()));
$(this).parent().before("<div class='line etape'>" +
"<lablel class='label' for='etape" + numero + "'>Etape " + numero + " :</lablel>" +
"<input type='text' class='form' value='" + option.text() + "' readonly>" +
"<input type='hidden' name='etape" + numero + "' value='" + option.val() + "' readonly></div>");
nbEtape.attr('value', parseInt(nbEtape.val())+1);
//$("#supprimerEtape").css("display", "initial");
$("#supprimerEtape").show();
}
});
$("#supprimerEtape").click(function () {
let etape = $(".etape:last");
let nbEtape = $("#nbEtapes");
if (parseInt(nbEtape.val())>0){
etape.remove();
nbEtape.attr('value', parseInt(nbEtape.val())-1);
if (parseInt(nbEtape.val())<=1){
//$("#supprimerEtape").css("display", "none");
$("#supprimerEtape").hide();
}
}
});
});

View File

@ -0,0 +1,111 @@
<?php
require_once('../connexionBD.php');
require_once('../ressources/trajet.php');
require_once ('../ressources/verifconnecte.php');
//Tester que tous les champs ont été renseignés
if (isset($_POST['dateDepart']) && isset($_POST['dateArrivee']) && isset($_POST['voiture']) && isset($_POST['villeDepart']) && isset($_POST['nbEtapes']) && isset($_POST['etape1'])) {
//Récupérer tous les $_POST en variables
$nbEtapes = htmlspecialchars(pg_escape_string($_POST['nbEtapes']));
$dateDepart = htmlspecialchars(pg_escape_string($_POST['dateDepart']));
$dateArrivee = htmlspecialchars(pg_escape_string($_POST['dateArrivee']));
$voiture = htmlspecialchars(pg_escape_string($_POST['voiture']));
$villeDepart = htmlspecialchars(pg_escape_string($_POST['villeDepart']));
$arrEtapes = array();
$i=1;
//Ajouter les étapes à un tableau
array_push($arrEtapes, htmlspecialchars(pg_escape_string($_POST['villeDepart'])));
while (isset($_POST['etape'.$i])){
array_push($arrEtapes, htmlspecialchars(pg_escape_string($_POST['etape'.$i])));
$i++;
}
//Vérifie le nombre d'étapes entré par l'utilisateur
if (count($arrEtapes) == 0 || intval($nbEtapes)<1 || intval($nbEtapes) != count($arrEtapes)){
header('Location: depotTrajet.php?error=1');
exit();
}
//Vérifie que les dates entrées par l'utilisateur ne se chevauchent pas et sont correctes
if (!checkDates($db, $mail, $dateDepart, $dateArrivee)){
header('Location: depotTrajet.php?error=2');
exit();
}
//Vérifie la voiture de l'utilisateur est correcte
if (!checkVoiture($db, $mail, $voiture)){
header('Location: depotTrajet.php?error=3');
exit();
}
//Creer le trajet en bd
$result = creerTrajet($db, $mail, $dateDepart, $dateArrivee, $voiture);
if ($result){
$codeTrajet = pg_fetch_array($result)[0];
//Creer les etapes en bd
$result = creerEtapes($db, $codeTrajet, $arrEtapes);
}
if (!$result){
header('Location: depotTrajet.php?error=4');
exit();
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../ressources/libs/jquery-ui.min.css">
<link rel="stylesheet" href="../ressources/navbarhtml.css">
<link rel="stylesheet" href="depotTrajet.css">
<title>Déposer un trajet</title>
</head>
<body>
<script type="application/javascript" src="../ressources/libs/jquery-3.4.1.js"></script>
<script type="application/javascript" src="../ressources/libs/jquery-ui.min.js"></script>
<script type="application/javascript" src="../ressources/libs/chosen.jquery.min.js"></script>
<?php require_once ("../ressources/navbarhtml.php"); ?>
<div id="formulaire">
<h1>Déposer un trajet</h1>
<form method="post" enctype="multipart/form-data" action="depotTrajet.php">
<div class="line">
<label class="label" for="dateDepart">Date départ : </label>
<input type="datetime-local" class="form" name="dateDepart" id="dateDepart" required>
</div>
<div class="line">
<label class="label" for="dateArrivee">Date arrivée : </label>
<input type="datetime-local" class="form" name="dateArrivee" id="dateArrivee" required>
</div>
<div class="line">
<label class="label" for="voiture">Voiture : </label>
<select class="form" name="voiture" id="voiture" required>
<option selected></option>
<?php afficherVoitures($db, $mail); ?>
</select>
</div>
<div class="line">
<label class="label" for="villeDepart">Ville de départ : </label>
<input type="text" class="form, villeText" name="villeDepartText" id="villeDepartText">
<select class="form, villeSelect" name="villeDepart" id="villeDepart" required>
<option selected></option>
<?php afficherVilles($db); ?>
</select>
</div>
<div id="villeEtapeDiv" class="line">
<label class="label" for="villeEtape">Etape : </label>
<input type="text" class="form, villeText" id="villeEtapeText" name="villeEtapeText">
<select class="form, villeSelect" name="villeEtape" id="villeEtape" required>
<option selected></option>
<?php afficherVilles($db); ?>
</select>
</div>
<div id="boutonEtape" class="line">
<input class="button" id="ajoutEtape" type="button" value="Ajouter une étape">
<input id="supprimerEtape" class='button' type='button' value='Supprimer une étape'>
<input id="nbEtapes" name="nbEtapes" type="hidden" value="1" required>
</div>
<?php getErrorDepotTrajet($_GET['error']); ?>
<div class="line">
<input id="submit" class="button" type="submit" value="Poster le trajet">
</div>
</form>
<script src="depotTrajet.js"></script>
</div>
</body>
</html>

View File

@ -1,3 +1,10 @@
/*
Crée par PALAFFRE Raphael
Fonction:Depot d'avis
Page PHP : deposer_avis.php
Page HTML : deposer_avis.html
*/
body {
color:black;
background-color:white;
@ -33,16 +40,18 @@ h1{
.rating {
direction: rtl;
}
.rating a {
color: #aaa;
text-decoration: none;
font-size: 3em;
transition: color .4s;
}
.rating a:hover,
.rating a:focus,
.rating a:hover ~ a,
.rating a:focus ~ a {
color: orange;
cursor: pointer;
}
}

View File

@ -1,3 +1,10 @@
<!--
Crée par PALAFFRE Raphael
Fonction:Depot d'avis
Page PHP : deposer_avis.php
Page CSS : deposer_avis.css
-->
<!DOCTYPE html>
<html lang = "fr">
<head>
@ -18,15 +25,24 @@
<div>
<textarea id="avis_laisse" name="avis_laisse" form="formulaire_avis" rows="10" cols="100" placeholder="Avis"></textarea>
</div>
<h2>NOTE</h2>
<div class="rating"><!--
--><a href="#1" title="Donner 1 étoile"></a><!--
--><a href="#2" title="Donner 2 étoiles"></a><!--
--><a href="#3" title="Donner 3 étoiles"></a><!--
--><a href="#4" title="Donner 4 étoiles"></a><!--
--><a href="#5" title="Donner 5 étoiles"></a>
<div class="rating">
<input type="radio" name="note" id="note5" value="5"/>
<a href="#5" label for ="note5" title="Donner 5 étoile"></a>
<input type="radio" name="note" id="note4" value="4"/>
<a href="#4" label for ="note4" title="Donner 4 étoiles"></a>
<input type="radio" name="note" id="note3" value="3"/>
<a href="#3" label for ="note3" title="Donner 3 étoiles"></a>
<input type="radio" name="note" id="note2" value="2"/>
<a href="#2" label for ="note2" title="Donner 2 étoiles"></a>
<input type="radio" name="note" id="note1" value="1"/>
<a href="#1" label for ="note1" title="Donner 1 étoiles"></a>
</div>
</br>
<div>
<input type="submit" value="Valider" id="submit">
</div>

View File

@ -0,0 +1,38 @@
<!--
Crée par PALAFFRE Raphael
Fonction:Depot d'avis
Page HTML : deposer_avis.html
Page CSS : deposer_avis.css
-->
<?PHP
require_once (connexionBD.php);
require_once (user.php);
if (!isset($_SESSION['mail'])) {
header('Location: ../index.php');
exit();
}
if (isset($_GET['codeTrajet'])) {
$mail = $_SESSION['mail'];
$avis = $_POST['avis_laisse'];
$note = $_POST['note'];
$date = date("Y-m-d H:i:s");
$estLu = 0;
$codeTrajet = $_GET['codeTrajet'];
$requete = "INSERT INTO Avis(mailEmetteur,codeTrajet,commentaire,dateAvis,note,estLu) VALUES ($mail,$codeTrajet,$avis,$date,$note,$estLu);";
$envoi = pg_query($db,$requete);
if ($envoi == FALSE){
echo 'Erreur d\'ecriture dans la BD';
}
}else{
echo 'Erreur codeTrajet';
}
?>

View File

@ -1,71 +1,35 @@
<?php
session_start();
require_once("connexionBD.php");
require_once ('./ressources/user.php');
require("connectionBD.php");
$db = connexionBD();
init();
if(!isset($_SESSION['mail'])){
if (isset($_POST['mail_field'])){
function printError(){
if(isset($_GET['error'])){
$erreur = getError($_GET['error']);
echo "<p class = 'error'>$erreur</p>";
}
}
function getError($code){
switch ($code){
case 1:
return "Adresse mail ou mot de passe invalide.";
}
}
function authentification($mail, $password){
global $db;
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
if ($result){
$row = pg_fetch_array($result);
return (strcmp($row["passwd"], $password)) == 0;
}
return false;
}
function init(){
global $db;
session_start();
/*if(isset($_COOKIE['mail']) && isset($_COOKIE['password'])){
if (authentification($_COOKIE['mail'], $_COOKIE['mail'])){
$_SESSION['mail'] = $_COOKIE['mail'];
$mail = strtolower(htmlentities(pg_escape_string ($_POST['mail_field'])));
$password = htmlentities(pg_escape_string($_POST['password']));
$result = authentification($db, $mail, $password);
if($result) {
$_SESSION['mail'] = $mail;
header('Location: tableauBord/tableauBord.php');
exit();
}
}*/
if(!isset($_SESSION['mail'])){
if (isset($_POST['mail_field'])){
$mail = strtolower(htmlentities(pg_escape_string ($_POST['mail_field'])));
$password = htmlentities(pg_escape_string($_POST['password']));
$result = authentification($mail, $password);
if($result) {
$_SESSION['mail'] = $mail;
header('Location: tableauBord/tableauBord.php');
exit();
}
else {
header('Location: index.php?error=1');
exit();
}
else {
header('Location: index.php?error=1');
exit();
}
}
else{
header('Location: tableauBord/tableauBord.php');
exit();
}
}
else{
header('Location: tableauBord/tableauBord.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="index_inscription.css">
<link rel="stylesheet" href="index.css">
<title>Bienvenue sur Upssi'Covoit</title>
</head>
<body>
@ -82,13 +46,13 @@ function init(){
</div>
<?php
if(isset($_GET['error'])){
$erreur = getError($_GET['error']);
$erreur = getErrorIndex($_GET['error']);
echo "<p class = 'error'>$erreur</p>";
}
?>
<input id="submit" class="button" type="submit" value="Se connecter">
</form>
<p id="enregistrer">Si vous n'avez pas de compte <a href="inscription.php" title="Créer un compte">cliquez ici</a>.</p>
<p id="enregistrer">Si vous n'avez pas de compte <a href="./inscription/inscription.php" title="Créer un compte">cliquez ici</a>.</p>
</div>
</body>
</html>
</html>

View File

@ -1,182 +0,0 @@
<?php
require ('connectionBD.php');
$db = connexionBD();
init();
function printError(){
if(isset($_GET['error'])){
$erreur = getError($_GET['error']);
echo "<p class = 'error'>$erreur</p>";
}
}
function getError($code){
switch ($code){
case 1:
return "L'adresse mail est invalide.";
case 2:
return "Cette adresse est déjà associée à un compte.";
case 3:
return "Ce login est déjà associé à un compte.";
case 4:
return "Le fichier envoyé doit être une image au format PNG.";
case 5:
return "La taille de l'image ne doit pas dépasser 2 MB.";
case 6:
return "Erreur lors de la création du compte.";
}
}
function isMailUnique($mail){
global $db;
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
if($result){
$row = pg_fetch_array($result);
return (strcmp($row['mail'], $mail) != 0);
}
return false;
}
function isLoginUnique($login){
global $db;
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE login = $1;", array($login));
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;
$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'] != "") {
$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'))) {
header('Location: inscription.php?error=4');
exit();
}
else if ($_FILES['avatar']['size'] > 2 * 1024 * 1024){
header('Location: inscription.php?error=5');
exit();
}
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 "<p class='error'>PHP a ignoré les données POST à cause d'une requête dépassant post_max_size (".ini_get('post_max_size').").</p>";
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');
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="index_inscription.css">
<title>Inscription</title>
<script src="inscription.js"></script>
</head>
<body>
<div id="formulaire">
<h1>Inscription</h1>
<form method="post" enctype="multipart/form-data" action="inscription.php">
<div class="line">
<label for="mail_field">Adresse mail : </label>
<input id="mail_field" class="form" name="mail_field" type="email" maxlength="100" required>
</div>
<div class="line">
<label for="login_field">Login : </label>
<input id="login_field" class="form" name="login_field" type="text" maxlength="50" required>
</div>
<div class="line">
<label for="password">Mot de passe : </label>
<input class="form" id="password" name="password" type="password" maxlength="50" required>
</div>
<div class="line">
<label for="confirmation">Confirmation : </label>
<input class="form" id="confirmation" name="confirmation" type="password" maxlength="16">
</div>
<div class="line">
<label for="prenom_field">Prénom : </label>
<input id="prenom_field" class="form" name="prenom" type="text" maxlength="50" required>
</div>
<div class="line">
<label for="nom_field">Nom : </label>
<input id="nom_field" class="form" name="nom" type="text" maxlength="50" required>
</div>
<div class="line">
<label for="dateN_field">Date de naissance : </label>
<input id="dateN_field" class="form" name="dateN" type="date" required>
</div>
<div class="line">
<label for="phone_field">Numéro de téléphone : </label>
<input id="phone_field" class="form" name="phone" type="tel" pattern="[0-9]{10}" maxlength="10" required>
</div>
<div class="line">
<label for="avatar">Image du Profil :</label>
<input type="file" id="avatar" class="form" name="avatar" accept="image/png">
</div>
<?php
printError();
?>
<input id="submit" class="button" type="submit" value="S'inscrire">
</form>
<p id="enregistrer">Si vous avez déjà un compte <a href="index.php" title="S'identifier">cliquez ici</a>.</p>
</div>
</body>
</html>

View File

@ -0,0 +1,109 @@
*{
margin: 0;
padding: 0;
font-family: "Arial";
font-size: 1em;
}
html, body{
height: 100%;
}
body{
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: center;
align-items: center;
}
#formulaire{
background-color: white;
border-radius: 10px;
padding: 4em;
width: 40%;
}
#enregistrer{
margin-top: 1em;
text-align: center;
}
h1{
text-align: center;
}
form{
margin-top: 3em;
}
.form{
box-sizing: border-box;
width: 55%;
border: 1px solid grey;
margin-bottom: 0.7em;
}
#avatar{
border-style: none;
}
.button{
cursor: pointer;
font-weight: bold;
padding: 8px;
color: white;
background-color: rgb(65, 154, 28);
border-radius: 5em;
border: none;
}
.button:hover{
background-color: rgb(48, 112, 20);
border-color: rgb(48, 112, 20);
}
.button:disabled{
cursor: not-allowed;
background-color: grey;
}
#submit{
margin-top: 1em;
margin-left: 50%;
transform: translate(-50%);
}
.line{
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: left;
width: 100%;
}
#error{
margin-bottom: 1em;
}
.error{
color: red;
text-align: center;
}
label{
box-sizing: border-box;
font-size: 1.1em;
width: 45%;
min-width: 8em;
}
h1{
font-size: 2em;
}
button{
color: forestgreen;
border-color: forestgreen;
border-radius: 5em;
}

View File

@ -0,0 +1,117 @@
<?php
session_start();
require_once('../connexionBD.php');
require_once('../ressources/user.php');
if (!isset($_SESSION['mail'])){
if (isset($_POST['login']) || isset($_FILES['avatar'])){
if (isset($_POST['login']) && isset($_POST['password']) && isset($_POST['confirmation']) && isset($_POST['prenom']) && isset($_POST['nom']) && isset($_POST['phone'])){
$login = htmlentities(pg_escape_string($_POST['login']));
$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'])));
$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 {
if (isset($_FILES['avatar']) and !empty($_FILES['avatar']['name'])) {
$fic = $_FILES['avatar'];
$res = uploadAvatar($mail, $fic);
switch ($res){
case -1:
header('Location: inscription.php?error=4');
exit();
case -2:
header('Location: inscription.php?error=5');
exit();
case -3:
header('Location: inscription.php?error=6');
exit();
}
}
$result = creerUtilisateur($db, $mail, $password, $prenom, $nom, $login, $phone, $dateN);
if ($result) {
header('Location: ../index.php');
exit();
}
else{
header('Location: inscription.php?error=6');
exit();
}
}
}
}
}
else {
header('Location: ../tableauBord/tableauBord.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="inscription.css">
<title>Inscription</title>
</head>
<body>
<div id="formulaire">
<h1>Inscription</h1>
<form method="post" enctype="multipart/form-data" action="inscription.php">
<div class="line">
<label for="mail">Adresse mail : </label>
<input id="mail" class="form" name="mail" type="email" maxlength="100" required>
</div>
<div class="line">
<label for="login">Login : </label>
<input id="login" class="form" name="login" type="text" maxlength="50" required>
</div>
<div class="line">
<label for="password">Mot de passe : </label>
<input class="form" id="password" name="password" type="password" maxlength="50" required>
</div>
<div class="line">
<label for="confirmation">Confirmation : </label>
<input class="form" id="confirmation" name="confirmation" type="password" maxlength="16">
</div>
<div class="line">
<label for="prenom">Prénom : </label>
<input id="prenom" class="form" name="prenom" type="text" maxlength="50" required>
</div>
<div class="line">
<label for="nom">Nom : </label>
<input id="nom" class="form" name="nom" type="text" maxlength="50" required>
</div>
<div class="line">
<label for="dateN">Date de naissance : </label>
<input id="dateN" class="form" name="dateN" type="date" required>
</div>
<div class="line">
<label for="phone">Numéro de téléphone : </label>
<input id="phone" class="form" name="phone" type="tel" pattern="[0-9]{10}" maxlength="10" required>
</div>
<div class="line">
<label for="avatar">Image du Profil :</label>
<input type="file" id="avatar" class="form" name="avatar" accept="image/png, image/jpeg">
</div>
<?php getErrorInscription($_GET['error']); ?>
<input id="submit" class="button" type="submit" value="S'inscrire">
</form>
<p id="enregistrer">Si vous avez déjà un compte <a href="index.php" title="S'identifier">cliquez ici</a>.</p>
</div>
<script src="inscription.js"></script>
</body>
</html>

100
WEB/profil/admin.php Normal file
View File

@ -0,0 +1,100 @@
<?php
session_start();
require_once('../connexionBD.php');
require_once ('../ressources/user.php');
require_once ('../ressources/verifconnecte.php');
$user = getUser($db, $mail);
if (!$user){
header('Location: profil.php?error=3');
exit();
}
if (isset($_POST['login']) || isset($_FILES['avatar'])){
if (isset($_FILES['avatar']) and !empty($_FILES['avatar']['name'])) {
$fic = $_FILES['avatar'];
supprimerAvatar($mail);
$res = uploadAvatar($mail, $fic);
switch ($res){
case -1:
header('Location: profil.php?error=4');
exit();
case -2:
header('Location: profil.php?error=5');
exit();
case -3:
header('Location: profil.php?error=6');
exit();
}
}
if (isset($_POST['login']) && isset($_POST['password']) && isset($_POST['confirmation']) && isset($_POST['prenom']) && isset($_POST['nom']) && isset($_POST['phone'])) {
$login = htmlentities(pg_escape_string($_POST['login']));
$password = htmlentities(pg_escape_string($_POST['password']));
$confirmation = htmlentities(pg_escape_string($_POST['confirmation']));
$prenom = htmlentities(pg_escape_string($_POST['prenom']));
$nom = htmlentities(pg_escape_string($_POST['nom']));
$phone = htmlentities(pg_escape_string($_POST['phone']));
if (loginChange($user, $login)) {
if (!isLoginUniqueModifier($db, $mail, $login)) {
header('Location: profil.php?error=1');
exit();
} else {
if (!modifierLogin($db, $mail, $login)) {
header('Location: profil.php?error=6');
exit();
}
}
}
if (strcmp($password, $confirmation) != 0) {
header('Location: profil.php?error=2');
exit();
}
if (!modifierUtilisateur($db, $mail, $prenom, $nom, $password, $phone)) {
header('Location: profil.php?error=6');
exit();
}
}
sleep(0.85);
header('Location: profil.php');
exit();
}
$delmail = $_POST['delmail'];
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="admin.css">
<link rel="stylesheet" href="../ressources/navbaradminhtml.css">
<link rel="stylesheet" href="../index.css">
<script src="../inscription/inscription.js"></script>
<title>Administration</title>
</head>
<body>
<?php require_once("../ressources/navbaradminhtml.php"); ?>
<div id="formulaire">
<h1>Administration</h1>
<div>
<h1>Supprimer un utilisateur</h1>
<fieldset>
<form action="admin.php" method="post">
<table>
<tr>
<td><p>mail de l'utilisateur a supprimer :</p></td>
<td><input type="text" name="delmail"/></td>
</tr>
<tr>
<td><p><input type="submit" name="deluserbutton" value="supprimer l'utilisateur"></td>
</tr>
<tr>
<td><?php if (isset($_POST['delmail'])) { deluser($delmail); }?></td>
</tr>
</table>
</form>
</fieldset>
</div>
</body>
</html>

30
WEB/profil/profil.css Normal file
View File

@ -0,0 +1,30 @@
*{
margin: 0;
padding: 0;
font-family: "Arial", sans-serif;
}
#divImgProfil{
width: 100%;
display: flex;
flex-wrap: nowrap;
justify-content: center;
}
#mail, #dateN{
background-color: lightgray;
}
#imgProfil{
background-color: white;
margin-top: 2.5em;
width: 60%;
height: 60%;
max-width: 210px;
max-height: 210px;
border-radius: 10px;
}
#changePass{
margin-bottom: 0.7em;
}

270
WEB/profil/profil.php Normal file
View File

@ -0,0 +1,270 @@
<?php
session_start();
require_once('../connexionBD.php');
require_once ('../ressources/user.php');
require_once ('../ressources/voiture.php');
$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($_SESSION['mail'])) {
header('Location: index.php');
exit();
}
if (isset($_POST['submitadd'])) {
addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab);
}
if (isset($_POST['submitchange'])) {
changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab);
}
$user = getUser($db, $mail);
if (!$user){
header('Location: profil.php?error=3');
exit();
}
if (isset($_POST['login']) || isset($_FILES['avatar'])){
if (isset($_FILES['avatar']) and !empty($_FILES['avatar']['name'])) {
$fic = $_FILES['avatar'];
supprimerAvatar($mail);
$res = uploadAvatar($mail, $fic);
switch ($res){
case -1:
header('Location: profil.php?error=4');
exit();
case -2:
header('Location: profil.php?error=5');
exit();
case -3:
header('Location: profil.php?error=6');
exit();
}
}
if (isset($_POST['login']) && isset($_POST['password']) && isset($_POST['confirmation']) && isset($_POST['prenom']) && isset($_POST['nom']) && isset($_POST['phone'])) {
$login = htmlentities(pg_escape_string($_POST['login']));
$password = htmlentities(pg_escape_string($_POST['password']));
$confirmation = htmlentities(pg_escape_string($_POST['confirmation']));
$prenom = htmlentities(pg_escape_string($_POST['prenom']));
$nom = htmlentities(pg_escape_string($_POST['nom']));
$phone = htmlentities(pg_escape_string($_POST['phone']));
if (loginChange($user, $login)) {
if (!isLoginUniqueModifier($db, $mail, $login)) {
header('Location: profil.php?error=1');
exit();
} else {
if (!modifierLogin($db, $mail, $login)) {
header('Location: profil.php?error=6');
exit();
}
}
}
if (strcmp($password, $confirmation) != 0) {
header('Location: profil.php?error=2');
exit();
}
if (!modifierUtilisateur($db, $mail, $prenom, $nom, $password, $phone)) {
header('Location: profil.php?error=6');
exit();
}
}
sleep(0.85);
header('Location: profil.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="profil.css">
<link rel="stylesheet" href="../ressources/navbarhtml.css">
<link rel="stylesheet" href="../index.css">
<script src="../inscription/inscription.js"></script>
<title>Profil</title>
</head>
<body>
<?php require_once("../ressources/navbarhtml.php"); ?>
<div id="formulaire">
<h1>Profil de <?php echo $user['prenom']; ?></h1>
<div id="divImgProfil">
<img id="imgProfil" src="<?php echo getPathImgProfil($mail); ?>">
</div>
<script type="text/javascript">
function visibilite(thingId){
var targetElement;
var elements;
targetElement = document.getElementById(thingId) ;
elements = document.getElementsByClassName("Element")
for (var i = 0; i < elements.length; i++){
if(!targetElement.isSameNode(elements[i])){
elements[i].style.display = "none" ;
}
}
if (targetElement.style.display == "none"){
targetElement.style.display = "";
}
else{
targetElement.style.display = "none" ;
}
}
</script>
<ul class="profil-nav">
<li class="FT"><a href="" onclick="javascript:visibilite('profilgeneral'); return false;">Profil général</a></li>
<li class="FT"><a href="" onclick="javascript:visibilite('profilvoiture'); return false;">Profil voiture</a></li>
</ul>
<div id="profilgeneral" class="Element" style="display:none;">
<form method="post" action="profil.php" enctype="multipart/form-data">
<div class="line">
<label for="mail">Adresse mail : </label>
<input id="mail" class="form" type="email" maxlength="100" readonly value="<?php echo $user['mail']; ?>">
</div>
<div class="line">
<label for="login">Login : </label>
<input id="login" class="form" name="login" type="text" maxlength="50"
value="<?php echo $user['login']; ?>" required>
</div>
<div class="line">
<label for="password">Mot de passe : </label>
<input class="form" id="password" name="password" type="password" maxlength="50"
value="<?php echo $user['passwd']; ?>" required>
</div>
<div class="line">
<label for="confirmation">Confirmation : </label>
<input class="form" id="confirmation" name="confirmation" type="password" maxlength="16"
value="<?php echo $user['passwd']; ?>" required>
</div>
<div class="line">
<label for="prenom">Prénom : </label>
<input id="prenom" class="form" name="prenom" type="text" maxlength="50"
value="<?php echo $user['prenom']; ?>" required>
</div>
<div class="line">
<label for="nom">Nom : </label>
<input id="nom" class="form" name="nom" type="text" maxlength="50" value="<?php echo $user['nom']; ?>"
required>
</div>
<div class="line">
<label for="dateN">Date de naissance : </label>
<input id="dateN" class="form" readonly="readonly" type="date"
value="<?php echo $user['datenaissance']; ?>" required>
</div>
<div class="line">
<label for="phone">Numéro de téléphone : </label>
<input id="phone" class="form" name="phone" type="tel" pattern="[0-9]{10}" maxlength="10"
value="<?php echo $user['telephone']; ?>" required>
</div>
<div class="line">
<label for="avatar">Image du Profil :</label>
<input type="file" id="avatar" class="form" name="avatar" accept="image/png, image/jpeg">
</div>
<?php getErrorProfil($_GET['error']); ?>
<input id="submit" class="button" type="submit" value="Modifier">
</form>
</div>
<div id="profilvoiture" class="Element" style="display:none;">
<script type="text/javascript">
function ShowTab(E) {
document.getElementById("addVoiture").style.display = (E == 1) ? 'block' : 'none';
document.getElementById("changeVoiture").style.display = (E == 2) ? 'block' : 'none';
document.getElementById("showVoiture").style.display = (E == 3) ? 'block' : 'none';
}
</script>
<form id="choixFormeTestVoiture">
<div>
<input type="radio" name="TabCheck" onclick="ShowTab(1)"/>Ajouter une voiture
<input type="radio" name="TabCheck" onclick="ShowTab(2)"/>Modifier ma voiture
<input type="radio" name="TabCheck" onclick="ShowTab(3)"/>Afficher ma voiture
</div>
</form>
<div id="addVoiture" style="display: none;">
<h1>Ajouter une voiture</h1>
<fieldset>
<form action="profil.php" method="post">
<table>
<tr>
<td><p>matricule :</p></td>
<td><input type="text" name="matricule"/></td>
</tr>
<tr>
<td><p>marque :</p></td>
<td><input type="text" name="marque"/></td>
</tr>
<tr>
<td><p>modele :</p></td>
<td><input type="text" name="modele"/></td>
</tr>
<tr>
<td><p>nombre de places :</p></td>
<td><input type="number" maxlength="1" name="nbplaces"/></td>
</tr>
<tr>
<td><p>année de fabrication :</p></td>
<td><input type="number" nmaxlength="4" name="anneefab"/></td>
</tr>
<tr>
<td><p><input type="submit" name="submitadd" value="ajouter une voiture"></td>
</tr>
</table>
</form>
</fieldset>
</div>
<div id="changeVoiture" style="display: none;">
<h1>Modifier une voiture</h1>
<fieldset>
<form action="profil.php" method="post">
<table>
<tr>
<td><p>matricule :</p></td>
<td><input type="text" name="matricule"/></td>
</tr>
<tr>
<td><p>marque :</p></td>
<td><input type="text" name="marque"/></td>
</tr>
<tr>
<td><p>modele :</p></td>
<td><input type="text" name="modele"/></td>
</tr>
<tr>
<td><p>nombre de places :</p></td>
<td><input type="number" maxlength="1" name="nbplaces"/></td>
</tr>
<tr>
<td><p>année de fabrication :</p></td>
<td><input type="number" nmaxlength="4" name="anneefab"/></td>
</tr>
<tr>
<td><p><input type="submit" name="submitchange" value="modifier une voiture"></td>
</tr>
</table>
</form>
</fieldset>
</div>
<div id="showVoiture" style="display: none;">
<h1>Afficher ma voiture</h1>
<fieldset>
<form action="profil.php" method="post">
<table>
<tr>
<td><p><input type="submit" name="submitshow" value="afficher ma voiture"></p></td>
</tr>
<tr>
<td><?php if (isset($_POST['submitshow'])) { showVoiture($db); }?></td>
</tr>
</table>
</form>
</fieldset>
</div>
</div>
</body>
</html>

10598
WEB/ressources/libs/jquery-3.4.1.js vendored Normal file

File diff suppressed because it is too large Load Diff

7
WEB/ressources/libs/jquery-ui.min.css vendored Normal file

File diff suppressed because one or more lines are too long

13
WEB/ressources/libs/jquery-ui.min.js vendored Normal file

File diff suppressed because one or more lines are too long

BIN
WEB/ressources/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@ -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;
}

View File

@ -0,0 +1,18 @@
<?php
$path = "..";
if (file_exists("./inscription.php")) {
$path = ".";
}
?>
<div id="menuDiv">
<nav id="menu">
<a class="menuItem" href="<?php echo $path ; ?>/tableauBord/tableauBord.php">Tableau de bord</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Trajets publiés</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Trajets réservés</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Messagerie</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Avis reçus</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Avis laissés</a>
<a class="menuItem" href="<?php echo $path ; ?>/admin/admin.php">Administration</a>
<a class="menuItem" href="<?php echo $path ; ?>/deconnexion.php">Se déconnecter</a>
</nav>
</div>

View File

@ -1,42 +1,41 @@
*{
margin: 0;
padding: 0;
font-family: "Calibri Light";
}
h1{
font-size: 3em;
text-align: center;
text-decoration: underline;
}
#content{
min-width: 320px;
#menuDiv {
width: 100%;
display: flex;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
display: block;
}
#tableauBord{
margin: 2em;
padding: 1em;
width: 100%;
#menuDiv a {
font-family: Ubuntu, Helvetica, sans-serif;
font-size: 1em;
height: 20%;
}
.menu {
#menu {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
background-color: rgb(65, 154, 28);
align-items: center;
background-color: rgb(35, 35, 35);
}
#logo {
width: 50%;
height: auto;
}
#divFlex{
display: flex;
flex-wrap: nowrap;
width: 10%;
min-width: 5em;
padding: 0;
text-align: center;
align-items: center;
}
.menuItem {
display: flex;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
color: white;
width: 10%;
@ -44,85 +43,13 @@ h1{
font-weight: bold;
text-decoration: none;
padding: 0.8em;
border-bottom: 4px solid rgb(65, 154, 28);
border-bottom: 4px solid rgb(35, 35, 35);
border-top: 4px solid rgb(35, 35, 35);
font-size: 1.1em;
text-align: center;
align-items: baseline;
}
.menuItem:hover{
cursor: pointer;
border-bottom: 4px solid orange;
}
#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;
}
#trajet{
margin-top: 2em;
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: center;
text-align: center;
width: 100%;
}
.btnTrajet{
display: flex;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
text-decoration: none;
padding: 0.4em;
color: black;
background-color: lightgray;
border: 1px solid black;
}
.btnTrajet:hover{
background-color: grey;
}
#btnTrajet2{
margin-left: 10%;
}
#recap{
margin-top: 2.5em;
width: 50%;
margin-left: 50%;
transform: translate(-50%);
}
.recapLine{
margin-bottom: 1.5em;
display: flex;
flex-wrap: nowrap;
justify-content: left;
align-items: center;
width: 100%;
}
.recapIcon{
width: 50px;
height: 50px;
}
p{
margin-left: 10%;
.menuItem:hover {
border-bottom: 4px solid rgb(65, 154, 28);
}

View File

@ -1,5 +1,18 @@
<?php
function navbarHTML($title){
echo '<!DOCTYPE html><html lang="fr"><head><meta charset="UTF-8"><link rel="stylesheet" href="tableauBord.css"><link rel="icon" type="image/png" href=""/><title>'.$title.'</title><nav class="menu"><a class="menuItem" href="./../inscription.php">Tableau de bord</a><a class="menuItem" href="../inscription.php">Trajets publiés</a><a class="menuItem" href="../inscription.php">Trajets réservés</a><a class="menuItem" href="../inscription.php">Messagerie</a><a class="menuItem" href="../inscription.php">Avis reçus</a><a class="menuItem" href="../inscription.php">Avis laissés</a><a class="menuItem" href="../inscription.php">Profil</a><a class="menuItem" href="../deconnexion.php">Se déconnecter</a></nav></head><body>';
<?php
$path = "..";
if (file_exists("./inscription.php")) {
$path = ".";
}
?>
<div id="menuDiv">
<nav id="menu">
<div id="divFlex"><div id="divlogo"><img src="../ressources/logo.png" alt="logo Upssi'Covoit" id="logo"/></div></div>
<a class="menuItem" href="<?php echo $path ; ?>../tableauBord/tableauBord.php">Tableau de bord</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Trajets publiés</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Trajets réservés</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Avis reçus</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Avis laissés</a>
<a class="menuItem" href="<?php echo $path ; ?>../profil/profil.php">Profil</a>
<a class="menuItem" href="<?php echo $path ; ?>../deconnexion.php">Se déconnecter</a>
</nav>
</div>

115
WEB/ressources/trajet.php Normal file
View File

@ -0,0 +1,115 @@
<?php
//Récupérer la liste complete des villes
function getListeVilles($db) {
$result = pg_query($db, "SELECT * FROM Ville;");
return $result;
}
//Créer un trajet en bd
function creerTrajet($db, $mail, $dateDepart, $datArrivee, $matricule){
$date = date('Y-m-d H:i:s');
$result = pg_query_params($db, "INSERT INTO Trajet (datedepart, datearrivee, dateproposition, estannule, mailproposition, matricule) VALUES ($1, $2, $3, false, $4, $5) RETURNING codeTrajet;", array($dateDepart,$datArrivee, $date, $mail, $matricule));
return $result;
}
//Creer les étapes d'un trajet
function creerEtapes($db, $codeTrajet, $etapes){
$result = true;
for ($i=0; $i<count($etapes) && $result; $i++){
$arr = explode("%%", $etapes[$i]);
$result = pg_query_params($db, "INSERT INTO traverser (codetrajet, nomville, codepostal, numeroetape) VALUES ($1, $2, $3, $4);", array($codeTrajet, $arr[0], $arr[1], $i+1));
}
return $result;
}
//Vérifier la cohérence des dates
function checkDates($db, $mail, $dateDepart, $dateArrivee) {
$valide = $dateDepart < $dateArrivee && $dateDepart > date('Y-m-d H:i:s');
$result = pg_query_params($db, "SELECT COUNT(*) From Trajet WHERE mailproposition = $1 AND $2 BETWEEN datedepart AND datearrivee;", array($mail, $dateDepart));
$row = pg_fetch_array($result);
return $row[0] == 0 && $valide;
}
//Vérifier que l'utilisateur est bien associé à cette voiture
function checkVoiture($db, $mail, $matricule){
$result = pg_query_params($db, "SELECT matricule From Voiture WHERE mail = $1 AND matricule = $2;", array($mail, $matricule));
$row = pg_fetch_array($result);
return !strcmp($matricule, $row[0]);
}
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;
}
}
//Récupérer la liste des voitures concernant un utilisateur
function getListeVoitures($db, $mail){
$result = pg_query_params($db, "SELECT * FROM Voiture WHERE mail = $1;", array($mail));
return $result;
}
//Afficher les voitures dans un select
function afficherVoitures($db, $mail){
$voitures = getListeVoitures($db, $mail);
while ($row = pg_fetch_array($voitures)) {
$modele = $row['modele'];
$matricule = $row['matricule'];
echo "<option value='$matricule'>$modele</option>";
}
}
//Afficher les voitures dans un select
function afficherVilles($db){
$villes = getListeVilles($db);
while ($row = pg_fetch_array($villes)) {
$nom = $row['nomville'];
$cp = $row['codepostal'];
echo "<option value='$nom%%$cp'>$nom ($cp)</option>";
}
}
function getErrorDepotTrajet($code){
switch ($code) {
case 1:
return "Erreur lors de la vérification des étapes.";
case 2:
return "Erreur lors de la vérification des dates.";
case 3:
return "Ce compte n'est pas associé à la voiture sélectionnée.";
case 4:
return "Erreur lors de l'enregistrement du trajet.";
}
}
?>

190
WEB/ressources/user.php Normal file
View File

@ -0,0 +1,190 @@
<?php
//geterror de l'index
function getErrorIndex($code){
switch ($code){
case 1:
return "Adresse mail ou mot de passe invalide.";
}
}
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.";
}
}
function getErrorInscription($code){
switch ($code) {
case 1:
return "L'adresse mail est invalide.";
case 2:
return "Cette adresse est déjà associée à un compte.";
case 3:
return "Ce login est déjà associé à un compte.";
case 4:
return "Le fichier envoyé doit être une image au format PNG.";
case 5:
return "La taille de l'image ne doit pas dépasser 2 MB.";
case 6:
return "Erreur lors de la création du compte.";
}
}
function authentification($db, $mail, $password){
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
if ($result){
$row = pg_fetch_array($result);
return (strcmp($row["passwd"], $password)) == 0;
}
return false;
}
function loginChange($user, $login){
return strcmp($user['login'], $login);
}
function isLoginUniqueModifier($db, $mail, $login){
$result = pg_query_params($db, "SELECT login 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 modifierLogin($db, $mail, $login){
$result = pg_query_params($db, "UPDATE Utilisateur SET login = $1 WHERE mail = $2;", array($login, $mail));
return $result;
}
function modifierUtilisateur($db, $mail, $prenom, $nom, $password, $phone){
$result = pg_query_params($db, "UPDATE Utilisateur SET prenom = $1, nom = $2, telephone = $3 , passwd = $4 WHERE mail = $5;", array($prenom, $nom, $phone, $password, $mail));
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 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 false;
}
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 false;
}
function getPathImgProfilTableau($mail){
$list = scandir("../imageProfil");
foreach ($list as $entry) {
if (strpos($entry, $mail) !== false) {
return "../imageProfil/$entry";
}
}
return "../imageProfil/default.svg";
}
function getPathImgProfil($mail){
$list = scandir("../imageProfil");
foreach ($list as $entry) {
if (strpos($entry, $mail) !== false) {
return "../imageProfil/$entry";
}
}
return "../imageProfil/default.svg";
}
function supprimerAvatar($mail){
$list = scandir("../imageProfil");
foreach ($list as $entry) {
if (strpos($entry, $mail) !== false) {
unlink("../imageProfil/$entry");
}
}
}
function isMailUnique($db, $mail){
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
if ($result) {
$row = pg_fetch_array($result);
return (strcmp($row['mail'], $mail) != 0);
}
return false;
}
function isLoginUnique($db, $login){
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE login = $1;", array($login));
if ($result) {
$row = pg_fetch_array($result);
return (strcmp($row['login'], $login) != 0);
}
return false;
}
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, $fic){
$tmp = explode('.', $fic['name']);
$extension = end($tmp);
$target_file = "../imageProfil/$mail.$extension";
$file_tmp = $fic['tmp_name'];
$check = getimagesize($file_tmp);
if ($check === false or !in_array($extension, array('png', 'jpg', 'jpeg', 'pjpeg', 'jfif', 'pjp'))) {
return -1;
} else if ($fic['size'] > 2 * 1024 * 1024) {
return -2;
} else {
if(!move_uploaded_file($file_tmp, $target_file)){
return -3;
}
}
return 0;
}
function deluser($delmail){
/*
$requete = "UPDATE public.utilisateur SET (mail, passwd, prenom, nom, login, telephone, datenaissance, estadmin) = ('utilisateur_supprime@local', '', '', '', 'utilisateur_supprime', '', to_date('1970/01/01','YYYY/MM/DD'), false) WHERE mail = '".$delmail."';";
marche pas
ERROR: duplicate key value violates unique constraint "pk_utilisateur"
DETAIL: Key (mail)=(utilisateur_supprime@local) already exists.
*/
/*
a faire = array('' => , );Delete l'utilisateur du reste de la base
*/
$requete = "DELETE FROM public.utilisateur WHERE mail = '".$delmail."';";
if(pg_query($db, $requete)){
supprimerAvatar($delmail);
echo "c'est supprimé";
}
}
?>

View File

@ -0,0 +1,8 @@
<?php
//Si on est pas connecté redirection vers la page de connexion
if (!isset($_SESSION['mail'])) {
header('Location: ../index.php');
exit();
}
$mail = $_SESSION['mail'];
?>

11
WEB/ressources/ville.php Normal file
View File

@ -0,0 +1,11 @@
<?php
require_once ('../connexionBD.php');
//Envoyer en json les villes correspondantes au champ de saisie pour les villes
if (isset($_GET['search'])){
$ville = strtolower(htmlentities(pg_escape_string ($_GET['search'])));
$result = pg_query_params($db, "SELECT codepostal, nomville FROM ville WHERE lower(nomVille) like lower($1);", array("%$ville%"));
$return_arr = pg_fetch_all($result);
echo json_encode($return_arr);
}

View File

@ -0,0 +1,24 @@
<?php
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'] . "';";
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']."<br>";
echo "marque = ".$res['marque']."<br>";
echo "modele = ".$res['modele']."<br>";
echo "nombre de places = ".$res['nbplaces']."<br>";
echo "année de fabrication = ".$res['anneefab']."<br>";
}
}
}
?>

View File

@ -1,7 +1,7 @@
*{
margin: 0;
padding: 0;
font-family: "Calibri Light";
font-family: "Arial";
}
h1{
@ -25,35 +25,6 @@ h1{
width: 100%;
}
.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);
font-size: 1.1em;
text-align: center;
}
.menuItem:hover{
cursor: pointer;
border-bottom: 4px solid orange;
}
#divImgProfil{
width: 100%;
display: flex;
@ -125,4 +96,4 @@ h1{
p{
margin-left: 10%;
}
}

View File

@ -1,221 +1,50 @@
<?php
include '../ressources/navbarHTML.php';
navbarHTML("Tableau de bord");
require ('../connectionBD.php');
$mail = null;
$db = connexionBD();
init();
$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($matricule, $marque, $modele, $nbplaces, $anneefab);
}
if(isset($_POST['submitchange'])){
changeVoiture($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'];
}
}
function getPrenom($mail){
global $db;
$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($mail){
global $db;
$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($mail){
global $db;
$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($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;
}
}
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']."<br>";
echo "marque = ".$res['marque']."<br>";
echo "modele = ".$res['modele']."<br>";
echo "nombre de places = ".$res['nbplaces']."<br>";
echo "année de fabrication = ".$res['anneefab']."<br>";
}
}
}
session_start();
require_once('../connexionBD.php');
require_once ('../ressources/user.php');
require_once ('../ressources/trajet.php');
require_once ('../ressources/verifconnecte.php');
?>
<script type="text/javascript">
function ShowTab (E){
document.getElementById("addVoiture").style.display = (E == 1) ? 'block' : 'none';
document.getElementById("changeVoiture").style.display = (E == 2) ? 'block' : 'none';
document.getElementById("showVoiture").style.display = (E == 3) ? 'block' : 'none';
}
</script>
<div id="content">
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="tableauBord.css">
<link rel="stylesheet" href="../ressources/navbarhtml.css">
<link rel="icon" type="image/png" href=""/>
<title>Tableau de bord</title>
</head>
<body>
<?php require('../ressources/navbarhtml.php'); ?>
<div id="content">
<div id="tableauBord">
<h1>Bienvenue <?php echo getLogin($mail); ?></h1>
<div id="divImgProfil">
<img id="imgProfil" src="<?php echo getPathImgProfil($mail); ?>">
</div>
<div id="trajet">
<a class="btnTrajet" href="../ah.php">Déposer un trajet</a>
<a id="btnTrajet2" class="btnTrajet" href="../ah.php">Rechercher un trajet</a>
</div>
<div id="recap">
<div class="recapLine">
<img class="recapIcon" src="../car.png">
<p>Vous avez <?php echo getTrajetsProposes($mail); ?> trajets proposés à effectuer.</p>
<h1>Bienvenue <?php echo getLogin($db, $mail); ?></h1>
<div id="divImgProfil">
<img id="imgProfil" src="<?php echo getPathImgProfilTableau($mail); ?>">
</div>
<div class="recapLine">
<img class="recapIcon" src="../car.png">
<p>Vous avez <?php echo getTrajetsReserves($mail); ?> trajets réservés à effectuer.</p>
<div id="trajet">
<a class="btnTrajet" href="../ah.php">Déposer un trajet</a>
<a id="btnTrajet2" class="btnTrajet" href="../ah.php">Rechercher un trajet</a>
</div>
<div class="recapLine">
<img class="recapIcon" src="../mail.svg">
<p>Vous avez <?php echo getMessagesNonLus($mail); ?> messages non lus.</p>
<div id="recap">
<div class="recapLine">
<img class="recapIcon" src="../car.png">
<p>Vous avez <?php echo getTrajetsProposes($db, $mail); ?> trajets proposés à effectuer.</p>
</div>
<div class="recapLine">
<img class="recapIcon" src="../car.png">
<p>Vous avez <?php echo getTrajetsReserves($db, $mail); ?> trajets réservés à effectuer.</p>
</div>
<div class="recapLine">
<img class="recapIcon" src="../mail.svg">
<p>Vous avez <?php echo getMessagesNonLus($db, $mail); ?> messages non lus.</p>
</div>
<div class="recapLine">
<img class="recapIcon" src="../star.png">
<p>Vous avez <?php echo getAvisNonLus($db, $mail); ?> avis non lus.</p>
</div>
</div>
<div class="recapLine">
<img class="recapIcon" src="../star.png">
<p>Vous avez <?php echo getAvisNonLus($mail); ?> avis non lus.</p>
</div>
</div>
<form id="choixFormeTestVoiture">
<div>
<input type="radio" name="TabCheck" onclick="ShowTab(1)"/>Ajouter une voiture
<input type="radio" name="TabCheck" onclick="ShowTab(2)"/>Modifier ma voiture
<input type="radio" name="TabCheck" onclick="ShowTab(3)"/>Afficher ma voiture
</div>
</form>
<div id="addVoiture" style="display: none;">
<h1>Ajouter une voiture</h1>
<fieldset>
<form action="tableauBord.php" method="post">
<table>
<tr><td><p>matricule :</p></td><td><input type="text" name="matricule"/></td></tr>
<tr><td><p>marque :</p></td><td><input type="text" name="marque"/></td></tr>
<tr><td><p>modele :</p></td><td><input type="text" name="modele"/></td></tr>
<tr><td><p>nombre de places :</p></td><td><input type="number" maxlength="1" name="nbplaces"/></td></tr>
<tr><td><p>année de fabrication :</p></td><td><input type="number" nmaxlength="4" name="anneefab"/></td></tr>
<tr><td><p><input type="submit" name="submitadd" value="ajouter une voiture"></td></tr>
</table>
</form>
</fieldset>
</div>
<div id="changeVoiture" style="display: none;">
<h1>Modifier une voiture</h1>
<fieldset>
<form action="tableauBord.php" method="post">
<table>
<tr><td><p>matricule :</p></td><td><input type="text" name="matricule"/></td></tr>
<tr><td><p>marque :</p></td><td><input type="text" name="marque"/></td></tr>
<tr><td><p>modele :</p></td><td><input type="text" name="modele"/></td></tr>
<tr><td><p>nombre de places :</p></td><td><input type="number" maxlength="1" name="nbplaces"/></td></tr>
<tr><td><p>année de fabrication :</p></td><td><input type="number" nmaxlength="4" name="anneefab"/></td></tr>
<tr><td><p><input type="submit" name="submitchange" value="modifier une voiture"></td></tr>
</table>
</form>
</fieldset>
</div>
<div id="showVoiture" style="display: none;">
<h1>Afficher ma voiture</h1>
<fieldset>
<form action="tableauBord.php" method="post">
<table>
<tr><td><p><input type="submit" name="submitshow" value="afficher ma voiture"></td></tr>
</table>
</form>
</fieldset>
</div>
</div>
</div>
</div>
</body>
</html>