Mise à jour avec branche bandeau
@ -1,53 +1,18 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
<head>
|
<meta charset="utf-8"/>
|
||||||
|
<link rel="stylesheet" href="Recherche.css"/>
|
||||||
<meta charset="utf-8" />
|
</head>
|
||||||
<link rel="stylesheet" href="Recherche.css" />
|
<body>
|
||||||
|
<div class="global bord">
|
||||||
|
<p class="fort">Rechercher un trajet</p>
|
||||||
</head>
|
<form method="post" action="Liste.php">
|
||||||
|
<p><input name="lieu_depart" type="text" placeholder="Lieu de départ" class="centrage"></p>
|
||||||
|
<p><input name="lieu_arrivée" type="text" placeholder="Lieu d'arrivée" class="centrage"></p>
|
||||||
<body>
|
<p><input name="date_heure" type="text" placeholder="Date et heure de départ" class="centrage"></p>
|
||||||
|
<p><input name="submit" type="submit" value="Rechercher" class="centrage"></p>
|
||||||
<div class="global bord">
|
</form>
|
||||||
|
</div>
|
||||||
<p class="fort">Rechercher un trajet</p>
|
</body>
|
||||||
|
|
||||||
<form method="post" action="Liste.php">
|
|
||||||
|
|
||||||
<p>
|
|
||||||
|
|
||||||
<input name="lieu_depart" type="text" placeholder="Lieu de départ" class="centrage">
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
|
|
||||||
<input name="lieu_arrivée" type="text" placeholder="Lieu d'arrivée" class="centrage" >
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
|
|
||||||
<input name="date_heure" type="text" placeholder="Date et heure de départ" class="centrage" >
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
<p>
|
|
||||||
|
|
||||||
<input name="submit" type="submit" value="Rechercher" class="centrage">
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
</html>
|
7
WEB/connexionBD.php
Normal 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.");
|
@ -1,21 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: REMI
|
|
||||||
* Date: 19/04/2019
|
|
||||||
* Time: 10:10
|
|
||||||
*/
|
|
||||||
|
|
||||||
require 'connectionBD.php';
|
require_once ('connexionBD.php');
|
||||||
$db = connexionBD();
|
|
||||||
init();
|
|
||||||
|
|
||||||
function init(){
|
session_start();
|
||||||
session_start();
|
|
||||||
if (isset($_SESSION['mail'])){
|
if (isset($_SESSION['mail'])){
|
||||||
session_unset();
|
session_unset();
|
||||||
session_destroy();
|
session_destroy();
|
||||||
}
|
|
||||||
header('Location: index.php');
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
|
header('Location: index.php');
|
@ -1,8 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require("connectionBD.php");
|
require_once("connexionBD.php");
|
||||||
$db = connexionBD();
|
|
||||||
init();
|
session_start();
|
||||||
|
|
||||||
|
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($db, $mail, $password);
|
||||||
|
if($result) {
|
||||||
|
$_SESSION['mail'] = $mail;
|
||||||
|
header('Location: tableauBord/tableauBord.php');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
header('Location: index.php?error=1');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
header('Location: tableauBord/tableauBord.php');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
function printError(){
|
function printError(){
|
||||||
if(isset($_GET['error'])){
|
if(isset($_GET['error'])){
|
||||||
@ -18,8 +40,7 @@ function getError($code){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function authentification($mail, $password){
|
function authentification($db, $mail, $password){
|
||||||
global $db;
|
|
||||||
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
|
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
|
||||||
if ($result){
|
if ($result){
|
||||||
$row = pg_fetch_array($result);
|
$row = pg_fetch_array($result);
|
||||||
@ -28,38 +49,6 @@ function authentification($mail, $password){
|
|||||||
return false;
|
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'];
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
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: tableauBord/tableauBord.php');
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
@ -1,18 +1,58 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require ('connectionBD.php');
|
require_once('connexionBD.php');
|
||||||
$db = connexionBD();
|
|
||||||
init();
|
|
||||||
|
|
||||||
function printError(){
|
session_start();
|
||||||
if(isset($_GET['error'])){
|
|
||||||
|
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($db, $mail)) {
|
||||||
|
header('Location: inscription.php?error=2');
|
||||||
|
exit();
|
||||||
|
} elseif (!isLoginUnique($db, $login)) {
|
||||||
|
header('Location: inscription.php?error=3');
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
uploadAvatar($mail);
|
||||||
|
$result = creerUtilisateur($db, $mail, $password, $prenom, $nom, $login, $phone, $dateN);
|
||||||
|
if ($result) {
|
||||||
|
header('Location: index.php');
|
||||||
|
} else {
|
||||||
|
header('Location: inscription.php?error=6');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
header('Location: tableauBord/tableauBord.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
function printError()
|
||||||
|
{
|
||||||
|
if (isset($_GET['error'])) {
|
||||||
$erreur = getError($_GET['error']);
|
$erreur = getError($_GET['error']);
|
||||||
echo "<p class = 'error'>$erreur</p>";
|
echo "<p class = 'error'>$erreur</p>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getError($code){
|
function getError($code)
|
||||||
switch ($code){
|
{
|
||||||
|
switch ($code) {
|
||||||
case 1:
|
case 1:
|
||||||
return "L'adresse mail est invalide.";
|
return "L'adresse mail est invalide.";
|
||||||
case 2:
|
case 2:
|
||||||
@ -29,99 +69,51 @@ function getError($code){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMailUnique($mail){
|
function isMailUnique($db, $mail)
|
||||||
global $db;
|
{
|
||||||
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
|
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
|
||||||
if($result){
|
if ($result) {
|
||||||
$row = pg_fetch_array($result);
|
$row = pg_fetch_array($result);
|
||||||
return (strcmp($row['mail'], $mail) != 0);
|
return (strcmp($row['mail'], $mail) != 0);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isLoginUnique($login){
|
function isLoginUnique($db, $login)
|
||||||
global $db;
|
{
|
||||||
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE login = $1;", array($login));
|
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE login = $1;", array($login));
|
||||||
if($result){
|
if ($result) {
|
||||||
$row = pg_fetch_array($result);
|
$row = pg_fetch_array($result);
|
||||||
return (strcmp($row['login'], $login) != 0);
|
return (strcmp($row['login'], $login) != 0);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function creerUtilisateur($mail, $password, $prenom, $nom, $login, $phone, $dateN){
|
function creerUtilisateur($db, $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));
|
$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;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function uploadAvatar($mail){
|
function uploadAvatar($mail)
|
||||||
if(isset($_FILES['avatar']) and $_FILES['avatar']['name'] != "") {
|
{
|
||||||
|
if (isset($_FILES['avatar']) and $_FILES['avatar']['name'] != "") {
|
||||||
$target_file = "imageProfil/$mail.png";
|
$target_file = "imageProfil/$mail.png";
|
||||||
$file_tmp = $_FILES['avatar']['tmp_name'];
|
$file_tmp = $_FILES['avatar']['tmp_name'];
|
||||||
$extension = end(explode('.', $_FILES['avatar']['name']));
|
$extension = end(explode('.', $_FILES['avatar']['name']));
|
||||||
$check = getimagesize($file_tmp);
|
$check = getimagesize($file_tmp);
|
||||||
if($check === false or !in_array($extension, array('png'))) {
|
if ($check === false or !in_array($extension, array('png'))) {
|
||||||
header('Location: inscription.php?error=4');
|
header('Location: inscription.php?error=4');
|
||||||
exit();
|
exit();
|
||||||
}
|
} else if ($_FILES['avatar']['size'] > 2 * 1024 * 1024) {
|
||||||
else if ($_FILES['avatar']['size'] > 2 * 1024 * 1024){
|
|
||||||
header('Location: inscription.php?error=5');
|
header('Location: inscription.php?error=5');
|
||||||
exit();
|
exit();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
move_uploaded_file($file_tmp, $target_file);
|
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>
|
<!DOCTYPE html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
@ -172,7 +164,7 @@ function init(){
|
|||||||
<input type="file" id="avatar" class="form" name="avatar" accept="image/png">
|
<input type="file" id="avatar" class="form" name="avatar" accept="image/png">
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
printError();
|
printError();
|
||||||
?>
|
?>
|
||||||
<input id="submit" class="button" type="submit" value="S'inscrire">
|
<input id="submit" class="button" type="submit" value="S'inscrire">
|
||||||
</form>
|
</form>
|
||||||
|
39
WEB/ressources/navbarhtml.css
Normal 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;
|
||||||
|
}
|
19
WEB/ressources/navbarhtml.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
$protocol = "https";
|
||||||
|
if (!isset($_SERVER['HTTPS_HOST'])){
|
||||||
|
$protocol = "http";
|
||||||
|
}
|
||||||
|
$path = "$protocol://".$_SERVER['HTTP_HOST'];
|
||||||
|
?>
|
||||||
|
<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 ; ?>/profil.php">Profil</a>
|
||||||
|
<a class="menuItem" href="<?php echo $path ; ?>/deconnexion.php">Se déconnecter</a>
|
||||||
|
</nav>
|
||||||
|
</div>
|
@ -1,245 +1,210 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require_once('../connexionBD.php');
|
||||||
|
session_start();
|
||||||
|
|
||||||
require ('../connectionBD.php');
|
//Si on est pas connecté redirection vers la page de connexion
|
||||||
$mail = null;
|
if(!isset($_SESSION['mail'])){
|
||||||
$db = connexionBD();
|
header('Location: ../index.php');
|
||||||
init();
|
exit();
|
||||||
|
}
|
||||||
|
$mail = $_SESSION['mail'];
|
||||||
|
|
||||||
$matricule = isset($_POST['matricule']) ? $_POST['matricule'] : NULL; //recuperation valeur formulaire, isset pour eviter l'erreur "Notice: Undefined index"
|
$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;
|
$marque = isset($_POST['marque']) ? $_POST['marque'] : NULL;
|
||||||
$modele = isset($_POST['modele']) ? $_POST['modele'] : NULL;
|
$modele = isset($_POST['modele']) ? $_POST['modele'] : NULL;
|
||||||
$nbplaces = isset($_POST['nbplaces']) ? $_POST['nbplaces'] : NULL;
|
$nbplaces = isset($_POST['nbplaces']) ? $_POST['nbplaces'] : NULL;
|
||||||
$anneefab = isset($_POST['anneefab']) ? $_POST['anneefab'] : NULL;
|
$anneefab = isset($_POST['anneefab']) ? $_POST['anneefab'] : NULL;
|
||||||
|
|
||||||
if(isset($_POST['submitadd']))
|
if(isset($_POST['submitadd'])){
|
||||||
{
|
addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab);
|
||||||
addVoiture($matricule, $marque, $modele, $nbplaces, $anneefab);
|
}
|
||||||
|
if(isset($_POST['submitchange'])){
|
||||||
|
changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab);
|
||||||
|
}
|
||||||
|
if(isset($_POST['submitshow'])){
|
||||||
|
showVoiture($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPrenom($db, $mail){
|
||||||
|
$result = pg_query_params($db, "SELECT prenom from Utilisateur WHERE mail = $1;", array($mail));
|
||||||
|
if($result){
|
||||||
|
$row = pg_fetch_array($result);
|
||||||
|
$prenom = $row[0];
|
||||||
|
return $prenom;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLogin($db, $mail){
|
||||||
|
$result = pg_query_params($db, "SELECT login from Utilisateur WHERE mail = $1;", array($mail));
|
||||||
|
if($result){
|
||||||
|
$row = pg_fetch_array($result);
|
||||||
|
$login = $row[0];
|
||||||
|
return $login;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTrajetsProposes($db, $mail){
|
||||||
|
$result = pg_query_params($db, "SELECT COUNT(*) from Trajet WHERE mailProposition = $1 AND estAnnule = false AND datedepart >= current_date;", array($mail));
|
||||||
|
if($result){
|
||||||
|
$row = pg_fetch_array($result);
|
||||||
|
return $row[0];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTrajetsReserves($db, $mail){
|
||||||
|
$result = pg_query_params($db, "SELECT COUNT(*) FROM trajet tr, reserver r WHERE r.codetrajet = tr.codetrajet AND mailutilisateur = $1 AND etatres != 'Annulée' AND estAnnule = false AND datedepart >= current_date;", array($mail));
|
||||||
|
if($result){
|
||||||
|
$row = pg_fetch_array($result);
|
||||||
|
return $row[0];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMessagesNonLus($db, $mail){
|
||||||
|
$result = pg_query_params($db, "SELECT COUNT(*) from Message WHERE mailRecepteur = $1 AND estLu = FALSE;", array($mail));
|
||||||
|
if($result){
|
||||||
|
$row = pg_fetch_array($result);
|
||||||
|
$login = $row[0];
|
||||||
|
return $login;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAvisNonLus($db, $mail){
|
||||||
|
global $db;
|
||||||
|
$result = pg_query_params($db, "SELECT COUNT(tr.mailProposition) FROM Trajet tr, Avis av WHERE tr.codeTrajet = av.codeTrajet AND av.estLu = false AND tr.mailProposition = $1;", array($mail));
|
||||||
|
if($result){
|
||||||
|
$row = pg_fetch_array($result);
|
||||||
|
$login = $row[0];
|
||||||
|
return $login;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPathImgProfil($mail){
|
||||||
|
if (file_exists("../imageProfil/$mail.png")){
|
||||||
|
return "../imageProfil/$mail.png";
|
||||||
|
}
|
||||||
|
return "../imageProfil/default.svg";
|
||||||
|
}
|
||||||
|
|
||||||
|
function addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab){
|
||||||
|
$requete = "INSERT INTO public.voiture (matricule, marque, modele, nbplaces, anneefab, mail) VALUES ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."','".$_SESSION['mail']."');";
|
||||||
|
pg_query($db, $requete);
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab){
|
||||||
|
$requete = "UPDATE public.voiture SET (matricule, marque, modele, nbplaces, anneefab) = ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."') WHERE mail = '".$_SESSION['mail']."';";
|
||||||
|
echo "requete =".$requete;
|
||||||
|
pg_query($db, $requete);
|
||||||
|
}
|
||||||
|
|
||||||
|
function showVoiture($db){
|
||||||
|
$requete = "SELECT * FROM public.voiture WHERE voiture.mail = '".$_SESSION['mail']."';";
|
||||||
|
if($donnees = pg_query($db, $requete)){
|
||||||
|
while($res = pg_fetch_assoc($donnees)){
|
||||||
|
echo "matricule = ".$res['matricule']."<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>";
|
||||||
}
|
}
|
||||||
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>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" href="tableauBord.css">
|
<link rel="stylesheet" href="tableauBord.css"><link rel="icon" type="image/png" href=""/>
|
||||||
<link rel="icon" type="image/png" href="" />
|
<title>Tableau de bord</title>
|
||||||
<title>Tableau de bord</title>
|
|
||||||
<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>
|
|
||||||
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="content">
|
<?php require ('../ressources/navbarhtml.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">
|
||||||
<div id="tableauBord">
|
<div id="tableauBord">
|
||||||
<h1>Bienvenue <?php echo getLogin($mail); ?></h1>
|
<h1>Bienvenue <?php echo getLogin($db, $mail); ?></h1>
|
||||||
<div id="divImgProfil">
|
<div id="divImgProfil">
|
||||||
<img id="imgProfil" src="<?php echo getPathImgProfil($mail); ?>">
|
<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($db, $mail); ?> trajets proposés à effectuer.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="trajet">
|
<div class="recapLine">
|
||||||
<a class="btnTrajet" href="../ah.php">Déposer un trajet</a>
|
<img class="recapIcon" src="../car.png">
|
||||||
<a id="btnTrajet2" class="btnTrajet" href="../ah.php">Rechercher un trajet</a>
|
<p>Vous avez <?php echo getTrajetsReserves($db, $mail); ?> trajets réservés à effectuer.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="recap">
|
<div class="recapLine">
|
||||||
<div class="recapLine">
|
<img class="recapIcon" src="../mail.svg">
|
||||||
<img class="recapIcon" src="../car.png">
|
<p>Vous avez <?php echo getMessagesNonLus($db, $mail); ?> messages non lus.</p>
|
||||||
<p>Vous avez <?php echo getTrajetsProposes($mail); ?> trajets proposés à effectuer.</p>
|
|
||||||
</div>
|
|
||||||
<div class="recapLine">
|
|
||||||
<img class="recapIcon" src="../car.png">
|
|
||||||
<p>Vous avez <?php echo getTrajetsReserves($mail); ?> trajets réservés à effectuer.</p>
|
|
||||||
</div>
|
|
||||||
<div class="recapLine">
|
|
||||||
<img class="recapIcon" src="../mail.svg">
|
|
||||||
<p>Vous avez <?php echo getMessagesNonLus($mail); ?> messages non lus.</p>
|
|
||||||
</div>
|
|
||||||
<div class="recapLine">
|
|
||||||
<img class="recapIcon" src="../star.png">
|
|
||||||
<p>Vous avez <?php echo getAvisNonLus($mail); ?> avis non lus.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<form id="choixFormeTestVoiture">
|
<div class="recapLine">
|
||||||
<div>
|
<img class="recapIcon" src="../star.png">
|
||||||
<input type="radio" name="TabCheck" onclick="ShowTab(1)"/>Ajouter une voiture
|
<p>Vous avez <?php echo getAvisNonLus($db, $mail); ?> avis non lus.</p>
|
||||||
<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>
|
||||||
|
</div>
|
||||||
<div id="changeVoiture" style="display: none;">
|
<form id="choixFormeTestVoiture">
|
||||||
<h1>Modifier une voiture</h1>
|
<div>
|
||||||
<fieldset>
|
<input type="radio" name="TabCheck" onclick="ShowTab(1)"/>Ajouter une voiture
|
||||||
<form action="tableauBord.php" method="post">
|
<input type="radio" name="TabCheck" onclick="ShowTab(2)"/>Modifier ma voiture
|
||||||
<table>
|
<input type="radio" name="TabCheck" onclick="ShowTab(3)"/>Afficher ma voiture
|
||||||
<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>
|
||||||
|
</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>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Before Width: | Height: | Size: 259 KiB After Width: | Height: | Size: 259 KiB |
Before Width: | Height: | Size: 250 KiB After Width: | Height: | Size: 250 KiB |
Before Width: | Height: | Size: 889 KiB After Width: | Height: | Size: 889 KiB |
Before Width: | Height: | Size: 887 KiB After Width: | Height: | Size: 887 KiB |
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 132 KiB |