corrected a lot of bugs

admin
Flavien Haas 6 years ago
parent c63d1b76db
commit 4ea87ca98a

@ -1,7 +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,8 +1,6 @@
<?php
require_once("connexionBD.php");
session_start();
require_once("connexionBD.php");
if(!isset($_SESSION['mail'])){
if (isset($_POST['mail_field'])){
@ -54,7 +52,7 @@ function authentification($db, $mail, $password){
<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>

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

@ -1,9 +1,7 @@
<?php
require_once('connexionBD.php');
require_once('ressources/user.php');
session_start();
require_once('../connexionBD.php');
require_once('../ressources/user.php');
if (!isset($_SESSION['mail'])) {
if (isset($_POST['login']) || isset($_FILES['avatar'])) {
@ -43,7 +41,7 @@ if (!isset($_SESSION['mail'])) {
}
$result = creerUtilisateur($db, $mail, $password, $prenom, $nom, $login, $phone, $dateN);
if ($result) {
header('Location: index.php');
header('Location: ../index.php');
exit();
} else {
header('Location: inscription.php?error=6');
@ -55,7 +53,7 @@ if (!isset($_SESSION['mail'])) {
}
}
else {
header('Location: tableauBord/tableauBord.php');
header('Location: ../tableauBord/tableauBord.php');
exit();
}
@ -91,7 +89,7 @@ function getError($code)
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="index_inscription.css">
<link rel="stylesheet" href="inscription.css">
<title>Inscription</title>
</head>
<body>

@ -1,12 +1,9 @@
<?php
function loginChange($user, $login)
{
function loginChange($user, $login){
return strcmp($user['login'], $login);
}
function isLoginUniqueModifier($db, $mail, $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);
@ -15,26 +12,22 @@ function isLoginUniqueModifier($db, $mail, $login)
return false;
}
function modifierLogin($db, $mail, $login)
{
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)
{
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)
{
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)
{
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);
@ -44,8 +37,7 @@ function getPrenom($db, $mail)
return false;
}
function getLogin($db, $mail)
{
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);
@ -55,9 +47,8 @@ function getLogin($db, $mail)
return false;
}
function getPathImgProfilTableau($mail)
{
$list = scandir($_SERVER['DOCUMENT_ROOT'] . "../imageProfil");
function getPathImgProfilTableau($mail){
$list = scandir("../imageProfil");
foreach ($list as $entry) {
if (strpos($entry, $mail) !== false) {
return "../imageProfil/$entry";
@ -66,29 +57,26 @@ function getPathImgProfilTableau($mail)
return "../imageProfil/default.svg";
}
function getPathImgProfil($mail)
{
$list = scandir($_SERVER['DOCUMENT_ROOT'] . "../imageProfil");
function getPathImgProfil($mail){
$list = scandir("../imageProfil");
foreach ($list as $entry) {
if (strpos($entry, $mail) !== false) {
return "/./imageProfil/$entry";
return "../imageProfil/$entry";
}
}
return "../imageProfil/default.svg";
}
function supprimerAvatar($mail)
{
$list = scandir($_SERVER['DOCUMENT_ROOT'] . "../imageProfil");
function supprimerAvatar($mail){
$list = scandir("../imageProfil");
foreach ($list as $entry) {
if (strpos($entry, $mail) !== false) {
unlink($_SERVER['DOCUMENT_ROOT'] . "../imageProfil/$entry");
unlink("../imageProfil/$entry");
}
}
}
function isMailUnique($db, $mail)
{
function isMailUnique($db, $mail){
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
if ($result) {
$row = pg_fetch_array($result);
@ -97,8 +85,7 @@ function isMailUnique($db, $mail)
return false;
}
function isLoginUnique($db, $login)
{
function isLoginUnique($db, $login){
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE login = $1;", array($login));
if ($result) {
$row = pg_fetch_array($result);
@ -107,14 +94,12 @@ function isLoginUnique($db, $login)
return false;
}
function creerUtilisateur($db, $mail, $password, $prenom, $nom, $login, $phone, $dateN)
{
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)
{
function uploadAvatar($mail, $fic){
$tmp = explode('.', $fic['name']);
$extension = end($tmp);
$target_file = "../imageProfil/$mail.$extension";
@ -131,3 +116,4 @@ function uploadAvatar($mail, $fic)
}
return 0;
}
?>

@ -1,19 +1,9 @@
<?php
session_start();
require_once('../connexionBD.php');
require_once ('../ressources/user.php');
session_start();
//Si on est pas connecté redirection vers la page de connexion
if (!isset($_SESSION['mail'])) {
header('Location: ../index.php');
exit();
}
$mail = $_SESSION['mail'];
function getTrajetsProposes($db, $mail)
{
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);
@ -22,8 +12,7 @@ function getTrajetsProposes($db, $mail)
return 0;
}
function getTrajetsReserves($db, $mail)
{
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);
@ -32,8 +21,7 @@ function getTrajetsReserves($db, $mail)
return 0;
}
function getMessagesNonLus($db, $mail)
{
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);
@ -42,8 +30,7 @@ function getMessagesNonLus($db, $mail)
}
}
function getAvisNonLus($db, $mail)
{
function getAvisNonLus($db, $mail){
global $db;
$result = pg_query_params($db, "SELECT COUNT(tr.mailProposition) FROM Trajet tr, Avis av WHERE tr.codeTrajet = av.codeTrajet AND av.estLu = false AND tr.mailProposition = $1;", array($mail));
if ($result) {
@ -52,6 +39,13 @@ function getAvisNonLus($db, $mail)
return $login;
}
}
//Si on est pas connecté redirection vers la page de connexion
if (!isset($_SESSION['mail'])) {
header('Location: ../index.php');
exit();
}
$mail = $_SESSION['mail'];
?>
<!DOCTYPE html>
<html lang="fr">

Loading…
Cancel
Save