Merge branch 'admin'
This commit is contained in:
commit
1a55ad8382
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once("connexionBD.php");
|
||||
require_once ('./ressources/user.php');
|
||||
|
||||
if(!isset($_SESSION['mail'])){
|
||||
if (isset($_POST['mail_field'])){
|
||||
@ -23,30 +24,6 @@ else{
|
||||
header('Location: tableauBord/tableauBord.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
function printError(){
|
||||
if(isset($_GET['error'])){
|
||||
$erreur = getError($_GET['error']);
|
||||
echo "<p class = 'error'>$erreur</p>";
|
||||
}
|
||||
}
|
||||
|
||||
function getError($code){
|
||||
switch ($code){
|
||||
case 1:
|
||||
return "Adresse mail ou mot de passe invalide.";
|
||||
}
|
||||
}
|
||||
|
||||
function authentification($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;
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
@ -75,7 +52,7 @@ function authentification($db, $mail, $password){
|
||||
?>
|
||||
<input id="submit" class="button" type="submit" value="Se connecter">
|
||||
</form>
|
||||
<p id="enregistrer">Si vous n'avez pas de compte <a href="inscription.php" title="Créer un compte">cliquez ici</a>.</p>
|
||||
<p id="enregistrer">Si vous n'avez pas de compte <a href="./inscription/inscription.php" title="Créer un compte">cliquez ici</a>.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -57,32 +57,6 @@ else {
|
||||
exit();
|
||||
}
|
||||
|
||||
function printError()
|
||||
{
|
||||
if (isset($_GET['error'])) {
|
||||
$erreur = getError($_GET['error']);
|
||||
echo "<p class = 'error'>$erreur</p>";
|
||||
}
|
||||
}
|
||||
|
||||
function getError($code)
|
||||
{
|
||||
switch ($code) {
|
||||
case 1:
|
||||
return "L'adresse mail est invalide.";
|
||||
case 2:
|
||||
return "Cette adresse est déjà associée à un compte.";
|
||||
case 3:
|
||||
return "Ce login est déjà associé à un compte.";
|
||||
case 4:
|
||||
return "Le fichier envoyé doit être une image au format PNG.";
|
||||
case 5:
|
||||
return "La taille de l'image ne doit pas dépasser 2 MB.";
|
||||
case 6:
|
||||
return "Erreur lors de la création du compte.";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
106
WEB/profil/admin.php
Normal file
106
WEB/profil/admin.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once('../connexionBD.php');
|
||||
require_once ('../ressources/user.php');
|
||||
|
||||
$mail = $_SESSION['mail'];
|
||||
|
||||
if (!isset($_SESSION['mail'])) {
|
||||
header('Location: index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
$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>
|
@ -2,6 +2,7 @@
|
||||
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"
|
||||
@ -10,53 +11,6 @@ $modele = isset($_POST['modele']) ? $_POST['modele'] : NULL;
|
||||
$nbplaces = isset($_POST['nbplaces']) ? $_POST['nbplaces'] : NULL;
|
||||
$anneefab = isset($_POST['anneefab']) ? $_POST['anneefab'] : NULL;
|
||||
|
||||
function printError(){
|
||||
if (isset($_GET['error'])) {
|
||||
$erreur = getErrorProfil($_GET['error']);
|
||||
echo "<p class = 'error'>$erreur</p>";
|
||||
}
|
||||
}
|
||||
|
||||
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 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>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['mail'])) {
|
||||
header('Location: index.php');
|
||||
exit();
|
||||
@ -134,8 +88,8 @@ if (isset($_POST['login']) || isset($_FILES['avatar'])){
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="profil.css">
|
||||
<link rel="stylesheet" href="../ressources/navbarhtml.css">
|
||||
<link rel="stylesheet" href="../index_inscription.css">
|
||||
<script src="../inscription.js"></script>
|
||||
<link rel="stylesheet" href="../index.css">
|
||||
<script src="../inscription/inscription.js"></script>
|
||||
<title>Profil</title>
|
||||
</head>
|
||||
<body>
|
||||
@ -303,7 +257,9 @@ if (isset($_POST['login']) || isset($_FILES['avatar'])){
|
||||
<table>
|
||||
<tr>
|
||||
<td><p><input type="submit" name="submitshow" value="afficher ma voiture"></p></td>
|
||||
<?php if (isset($_POST['submitshow'])) { showVoiture($db); }?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php if (isset($_POST['submitshow'])) { showVoiture($db); }?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
39
WEB/ressources/navbaradminhtml.css
Normal file
39
WEB/ressources/navbaradminhtml.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;
|
||||
}
|
18
WEB/ressources/navbaradminhtml.php
Normal file
18
WEB/ressources/navbaradminhtml.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
$path = "..";
|
||||
if (file_exists("./inscription.php")) {
|
||||
$path = ".";
|
||||
}
|
||||
?>
|
||||
<div id="menuDiv">
|
||||
<nav id="menu">
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/tableauBord/tableauBord.php">Tableau de bord</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Trajets publiés</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Trajets réservés</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Messagerie</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Avis reçus</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Avis laissés</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/admin/admin.php">Administration</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/deconnexion.php">Se déconnecter</a>
|
||||
</nav>
|
||||
</div>
|
@ -1,4 +1,42 @@
|
||||
<?php
|
||||
function getError($code){
|
||||
switch ($code){
|
||||
case 1:
|
||||
return "Adresse mail ou mot de passe invalide.";
|
||||
}
|
||||
}
|
||||
|
||||
//trouver dans Inscription
|
||||
/*
|
||||
function getError($code)
|
||||
{
|
||||
switch ($code) {
|
||||
case 1:
|
||||
return "L'adresse mail est invalide.";
|
||||
case 2:
|
||||
return "Cette adresse est déjà associée à un compte.";
|
||||
case 3:
|
||||
return "Ce login est déjà associé à un compte.";
|
||||
case 4:
|
||||
return "Le fichier envoyé doit être une image au format PNG.";
|
||||
case 5:
|
||||
return "La taille de l'image ne doit pas dépasser 2 MB.";
|
||||
case 6:
|
||||
return "Erreur lors de la création du compte.";
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
function 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);
|
||||
}
|
||||
@ -116,4 +154,48 @@ function uploadAvatar($mail, $fic){
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function printError(){
|
||||
if (isset($_GET['error'])) {
|
||||
$erreur = getErrorProfil($_GET['error']);
|
||||
echo "<p class = 'error'>$erreur</p>";
|
||||
}
|
||||
}
|
||||
|
||||
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 deluser($delmail){
|
||||
echo "c'est supprimé";
|
||||
/*
|
||||
$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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Delete l'utilisateur du reste de la base
|
||||
*/
|
||||
|
||||
$requete = "DELETE FROM public.utilisateur WHERE mail = '".$delmail."';";
|
||||
|
||||
pg_query($db, $requete);
|
||||
supprimerAvatar($delmail);
|
||||
}
|
||||
|
||||
?>
|
||||
|
24
WEB/ressources/voiture.php
Normal file
24
WEB/ressources/voiture.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
function addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab){
|
||||
$requete = "INSERT INTO public.voiture (matricule, marque, modele, nbplaces, anneefab, mail) VALUES ('" . $matricule . "','" . $marque . "','" . $modele . "','" . $nbplaces . "','" . $anneefab . "','" . $_SESSION['mail'] . "');";
|
||||
pg_query($db, $requete);
|
||||
}
|
||||
|
||||
function changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab){
|
||||
$requete = "UPDATE public.voiture SET (matricule, marque, modele, nbplaces, anneefab) = ('" . $matricule . "','" . $marque . "','" . $modele . "','" . $nbplaces . "','" . $anneefab . "') WHERE mail = '" . $_SESSION['mail'] . "';";
|
||||
pg_query($db, $requete);
|
||||
}
|
||||
|
||||
function showVoiture($db){
|
||||
$requete = "SELECT * FROM public.voiture WHERE voiture.mail = '" . $_SESSION['mail'] . "';";
|
||||
if ($donnees = pg_query($db, $requete)) {
|
||||
while ($res = pg_fetch_assoc($donnees)) {
|
||||
echo "matricule = ".$res['matricule']."<br>";
|
||||
echo "marque = ".$res['marque']."<br>";
|
||||
echo "modele = ".$res['modele']."<br>";
|
||||
echo "nombre de places = ".$res['nbplaces']."<br>";
|
||||
echo "année de fabrication = ".$res['anneefab']."<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user