|
|
@ -51,7 +51,8 @@ if (!$user){
|
|
|
|
exit();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getPathImgProfil($mail){
|
|
|
|
function getPathImgProfil($mail)
|
|
|
|
|
|
|
|
{
|
|
|
|
$protocol = "https";
|
|
|
|
$protocol = "https";
|
|
|
|
if (!isset($_SERVER['HTTPS_HOST'])) {
|
|
|
|
if (!isset($_SERVER['HTTPS_HOST'])) {
|
|
|
|
$protocol = "http";
|
|
|
|
$protocol = "http";
|
|
|
@ -65,7 +66,8 @@ function getPathImgProfil($mail){
|
|
|
|
return "$protocol://" . $_SERVER['HTTP_HOST'] . "/imageProfil/default.svg";
|
|
|
|
return "$protocol://" . $_SERVER['HTTP_HOST'] . "/imageProfil/default.svg";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function supprimerAvatar($mail){
|
|
|
|
function supprimerAvatar($mail)
|
|
|
|
|
|
|
|
{
|
|
|
|
$list = scandir($_SERVER['DOCUMENT_ROOT'] . "/imageProfil");
|
|
|
|
$list = scandir($_SERVER['DOCUMENT_ROOT'] . "/imageProfil");
|
|
|
|
foreach ($list as $entry) {
|
|
|
|
foreach ($list as $entry) {
|
|
|
|
if (strpos($entry, $mail) !== false) {
|
|
|
|
if (strpos($entry, $mail) !== false) {
|
|
|
@ -74,7 +76,8 @@ function supprimerAvatar($mail){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function uploadAvatar($mail, $fic){
|
|
|
|
function uploadAvatar($mail, $fic)
|
|
|
|
|
|
|
|
{
|
|
|
|
$tmp = explode('.', $fic['name']);
|
|
|
|
$tmp = explode('.', $fic['name']);
|
|
|
|
$extension = end($tmp);
|
|
|
|
$extension = end($tmp);
|
|
|
|
$target_file = "imageProfil/$mail.$extension";
|
|
|
|
$target_file = "imageProfil/$mail.$extension";
|
|
|
@ -83,34 +86,36 @@ function uploadAvatar($mail, $fic){
|
|
|
|
if ($check === false or !in_array($extension, array('png', 'jpg', 'jpeg', 'pjpeg', 'jfif', 'pjp'))) {
|
|
|
|
if ($check === false or !in_array($extension, array('png', 'jpg', 'jpeg', 'pjpeg', 'jfif', 'pjp'))) {
|
|
|
|
header('Location: inscription.php?error=4');
|
|
|
|
header('Location: inscription.php?error=4');
|
|
|
|
exit();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
} else if ($fic['size'] > 2 * 1024 * 1024) {
|
|
|
|
else if ($fic['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 modifierUtilisateur($db, $prenom, $nom, $login, $phone){
|
|
|
|
function modifierUtilisateur($db, $prenom, $nom, $login, $phone)
|
|
|
|
|
|
|
|
{
|
|
|
|
$result = pg_query_params($db, "UPDATE Utilisateur SET prenom = $1, nom = $2, login = $3, telephone = $4;", array($prenom, $nom, $login, $phone));
|
|
|
|
$result = pg_query_params($db, "UPDATE Utilisateur SET prenom = $1, nom = $2, login = $3, telephone = $4;", array($prenom, $nom, $login, $phone));
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getUser($db, $mail){
|
|
|
|
function getUser($db, $mail)
|
|
|
|
|
|
|
|
{
|
|
|
|
$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));
|
|
|
|
return pg_fetch_array($result);
|
|
|
|
return pg_fetch_array($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function printError(){
|
|
|
|
function printError()
|
|
|
|
|
|
|
|
{
|
|
|
|
if (isset($_GET['error'])) {
|
|
|
|
if (isset($_GET['error'])) {
|
|
|
|
$erreur = getErrorProfil($_GET['error']);
|
|
|
|
$erreur = getErrorProfil($_GET['error']);
|
|
|
|
echo "<p class = 'error'>$erreur</p>";
|
|
|
|
echo "<p class = 'error'>$erreur</p>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function isLoginUniqueModifier($db, $mail, $login){
|
|
|
|
function isLoginUniqueModifier($db, $mail, $login)
|
|
|
|
|
|
|
|
{
|
|
|
|
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE login = $1 AND mail != $2;", array($login, $mail));
|
|
|
|
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE login = $1 AND mail != $2;", array($login, $mail));
|
|
|
|
if ($result) {
|
|
|
|
if ($result) {
|
|
|
|
$row = pg_fetch_array($result);
|
|
|
|
$row = pg_fetch_array($result);
|
|
|
@ -119,7 +124,8 @@ function isLoginUniqueModifier($db, $mail, $login){
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getErrorProfil($code){
|
|
|
|
function getErrorProfil($code)
|
|
|
|
|
|
|
|
{
|
|
|
|
switch ($code) {
|
|
|
|
switch ($code) {
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
return "Ce login est déjà associé à un compte.";
|
|
|
|
return "Ce login est déjà associé à un compte.";
|
|
|
@ -144,11 +150,13 @@ function getErrorProfil($code){
|
|
|
|
<head>
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<link rel="stylesheet" href="profil.css">
|
|
|
|
<link rel="stylesheet" href="profil.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="ressources/navbarhtml.css">
|
|
|
|
<link rel="stylesheet" href="index_inscription.css">
|
|
|
|
<link rel="stylesheet" href="index_inscription.css">
|
|
|
|
<script src="inscription.js"></script>
|
|
|
|
<script src="inscription.js"></script>
|
|
|
|
<title>Profil</title>
|
|
|
|
<title>Profil</title>
|
|
|
|
</head>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<?php require_once("ressources/navbarhtml.php"); ?>
|
|
|
|
<div id="formulaire">
|
|
|
|
<div id="formulaire">
|
|
|
|
<h1>Profil</h1>
|
|
|
|
<h1>Profil</h1>
|
|
|
|
<div id="divImgProfil">
|
|
|
|
<div id="divImgProfil">
|
|
|
@ -157,35 +165,43 @@ function getErrorProfil($code){
|
|
|
|
<form method="post" enctype="multipart/form-data" action="profil.php">
|
|
|
|
<form method="post" enctype="multipart/form-data" action="profil.php">
|
|
|
|
<div class="line">
|
|
|
|
<div class="line">
|
|
|
|
<label for="mail_field">Adresse mail : </label>
|
|
|
|
<label for="mail_field">Adresse mail : </label>
|
|
|
|
<input id="mail_field" class="form" type="email" maxlength="100" readonly value="<?php echo $user['mail']; ?>">
|
|
|
|
<input id="mail_field" class="form" type="email" maxlength="100" readonly
|
|
|
|
|
|
|
|
value="<?php echo $user['mail']; ?>">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="line">
|
|
|
|
<div class="line">
|
|
|
|
<label for="login_field">Login : </label>
|
|
|
|
<label for="login_field">Login : </label>
|
|
|
|
<input id="login_field" class="form" name="login_field" type="text" maxlength="50" value="<?php echo $user['login'];?>" required>
|
|
|
|
<input id="login_field" class="form" name="login_field" type="text" maxlength="50"
|
|
|
|
|
|
|
|
value="<?php echo $user['login']; ?>" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="line">
|
|
|
|
<div class="line">
|
|
|
|
<label for="password">Mot de passe : </label>
|
|
|
|
<label for="password">Mot de passe : </label>
|
|
|
|
<input class="form" id="password" name="password" type="password" maxlength="50" value="<?php echo $user['passwd'];?>" required>
|
|
|
|
<input class="form" id="password" name="password" type="password" maxlength="50"
|
|
|
|
|
|
|
|
value="<?php echo $user['passwd']; ?>" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="line">
|
|
|
|
<div class="line">
|
|
|
|
<label for="confirmation">Confirmation : </label>
|
|
|
|
<label for="confirmation">Confirmation : </label>
|
|
|
|
<input class="form" id="confirmation" name="confirmation" type="password" maxlength="16" value="<?php echo $user['passwd'];?>" required>
|
|
|
|
<input class="form" id="confirmation" name="confirmation" type="password" maxlength="16"
|
|
|
|
|
|
|
|
value="<?php echo $user['passwd']; ?>" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="line">
|
|
|
|
<div class="line">
|
|
|
|
<label for="prenom_field">Prénom : </label>
|
|
|
|
<label for="prenom_field">Prénom : </label>
|
|
|
|
<input id="prenom_field" class="form" name="prenom" type="text" maxlength="50" value="<?php echo $user['prenom'];?>" required>
|
|
|
|
<input id="prenom_field" class="form" name="prenom" type="text" maxlength="50"
|
|
|
|
|
|
|
|
value="<?php echo $user['prenom']; ?>" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="line">
|
|
|
|
<div class="line">
|
|
|
|
<label for="nom_field">Nom : </label>
|
|
|
|
<label for="nom_field">Nom : </label>
|
|
|
|
<input id="nom_field" class="form" name="nom" type="text" maxlength="50" value="<?php echo $user['nom'];?>" required>
|
|
|
|
<input id="nom_field" class="form" name="nom" type="text" maxlength="50" value="<?php echo $user['nom']; ?>"
|
|
|
|
|
|
|
|
required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="line">
|
|
|
|
<div class="line">
|
|
|
|
<label for="dateN_field">Date de naissance : </label>
|
|
|
|
<label for="dateN_field">Date de naissance : </label>
|
|
|
|
<input id="dateN_field" class="form" readonly="readonly" type="date" value="<?php echo $user['datenaissance'];?>" required>
|
|
|
|
<input id="dateN_field" class="form" readonly="readonly" type="date"
|
|
|
|
|
|
|
|
value="<?php echo $user['datenaissance']; ?>" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="line">
|
|
|
|
<div class="line">
|
|
|
|
<label for="phone_field">Numéro de téléphone : </label>
|
|
|
|
<label for="phone_field">Numéro de téléphone : </label>
|
|
|
|
<input id="phone_field" class="form" name="phone" type="tel" pattern="[0-9]{10}" maxlength="10" value="<?php echo $user['telephone'];?>" required>
|
|
|
|
<input id="phone_field" class="form" name="phone" type="tel" pattern="[0-9]{10}" maxlength="10"
|
|
|
|
|
|
|
|
value="<?php echo $user['telephone']; ?>" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="line">
|
|
|
|
<div class="line">
|
|
|
|
<label for="avatar">Image du Profil :</label>
|
|
|
|
<label for="avatar">Image du Profil :</label>
|
|
|
|