Merge branch 'master' into plannification
commit
9801d58650
@ -1,34 +1,27 @@
|
||||
.centrage{
|
||||
text-align : center;
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.global {
|
||||
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;
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
?>
|
||||
|
@ -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.");
|
||||
?>
|
@ -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_start();
|
||||
|
||||
if (isset($_SESSION['mail'])){
|
||||
session_unset();
|
||||
session_destroy();
|
||||
}
|
||||
header('Location: index.php');
|
||||
exit();
|
||||
}
|
||||
header('Location: index.php');
|
@ -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;
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
@ -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>
|
@ -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';
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
@ -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>
|
@ -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>
|
@ -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;
|
||||
}
|
@ -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>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
@ -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;
|
||||
}
|
@ -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>
|
@ -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.";
|
||||
}
|
||||
}
|
||||
?>
|
@ -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é";
|
||||
}
|
||||
}
|
||||
?>
|
@ -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'];
|
||||
?>
|
@ -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);
|
||||
}
|
@ -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>";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue