-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfil.php
More file actions
153 lines (137 loc) · 4.19 KB
/
Profil.php
File metadata and controls
153 lines (137 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
define('TARGET', 'Photos/'); // Repertoire cible
define('MAX_SIZE', 10000000); // Taille max en octets du fichier
define('WIDTH_MAX', 3000); // Largeur max de l'image en pixels
define('HEIGHT_MAX', 3000);
include_once("includes/AccesBase.php");
include_once("Modeles/fonction.php");
if(empty($_SESSION)) /*OR $_SESSION['Type'] != 'Administrateur'*/{
header("Location: connexion.php");
}
else{
$erreur="";
$resultat="";
$login=$_SESSION['login'];
$Mdp=$_SESSION['Mdp'];
$Type=$_SESSION['Type'];
$Mail=$_SESSION['Mail'];
$Prenom=$_SESSION['Prenom'];
$Nom=$_SESSION['Nom'];
$Sexe=$_SESSION['Sexe'];
$Taille=$_SESSION['Taille'];
$DateDeNaissance=$_SESSION['DateDeNaissance'];
$Poids=$_SESSION['Poids'];
$idUser=$_SESSION['idUser'];
$cheminPhoto=$_SESSION['cheminPhoto'];
if(empty($cheminPhoto)){
$cheminPhoto="ressources/PhotoDeProfil.png";
}
if(!empty($_FILES['photo']['name'])){
$extension=pathinfo($_FILES['photo']['name'], PATHINFO_EXTENSION);
if($extension=='jpg' || $extension=='jpeg'|| $extension=='png'){
$infosImage = getimagesize($_FILES['photo']['tmp_name']);
if($infosImage[2] >= 1 && $infosImage[2] <= 14){
if(($infosImage[0] <= WIDTH_MAX) && ($infosImage[1] <= HEIGHT_MAX) && (filesize($_FILES['photo']['tmp_name']) <= MAX_SIZE)){
if(isset($_FILES['photo']['error']) && UPLOAD_ERR_OK === $_FILES['photo']['error']){
$nomImage=md5(uniqid()) .'.'. $extension;
//upload du fichier
if(move_uploaded_file($_FILES['photo']['tmp_name'], TARGET.$nomImage)){
$resultat = 'Upload réussi !';
$cheminPhoto=TARGET.$nomImage;
$req=modificationInformationUtilisateur($db, $cheminPhoto, 'Photos', $idUser);
}
else{
// Sinon on affiche une erreur systeme
$resultat = 'Problème lors de l\'upload !';
}
}
else{
$erreur="Erreur lors de l'upload du fichier";
}
}
else{
$erreur="La taille de votre fichier est trop grande ou le format est non admis";
}
}
else{
$erreur="le fichier n'est pas une image";
}
}
else{
$erreur = "extension non permise";
}
}
if(!empty($_POST['Poids'])){
$Poids=$_POST['Poids'];
$req=modificationInformationUtilisateur($db, $Poids, 'Poids', $idUser);
if($resultat!=""){
$resultat .="-Votre Poids a bien été mis à jour.<br/>";
}
else{
$resultat ="-Votre Poids a bien été mis à jour. <br/>";
}
}
if(!empty($_POST['mdpActuel'])){
$mdpActuel=$_POST['mdpActuel'];
if(!empty($_POST['nouveauMDP'])){
if(password_verify($mdpActuel, $Mdp)){
$nouveauMDP=$_POST['nouveauMDP'];
$nouveauMDP = password_hash($nouveauMDP,PASSWORD_DEFAULT);
$req=modificationInformationUtilisateur($db, $nouveauMDP, 'Mdp', $idUser);
$resultat="-Votre mot de passe a bien été modifié. /n";
}
else{
$erreur="-Le mot de passe actuel est érroné /n";
}
}
else{
$erreur="Veuillez choisir un nouveau mot de passe";
}
}
if(!empty($_POST['listeSexe'])){
$Sexe=$_POST['listeSexe'];
switch ($Sexe) {
case '1':
$Sexe="Homme";
break;
case '2':
$Sexe="Femme";
break;
case '3':
$Sexe="Autre";
break;
default:
$Sexe="Homme";
break;
}
$req=modificationInformationUtilisateur($db, $Sexe, 'Sexe', $idUser);
if($resultat!=""){
$resultat .='-Votre sexe a bien été mis à jour.<br/>';
}
else{
$resultat='-Votre sexe a bien été mis à jour.<br/>';
}
}
if(!empty($_POST['Taille'])){
$Taille=$_POST['Taille'];
$req=modificationInformationUtilisateur($db, $Taille, 'Taille', $idUser);
if($resultat!=""){
$resultat .="-Votre taille a bien été mise à jour. <br/>";
}
else{
$resultat='-Votre taille a bien été mise à jour. <br/>';
}
}
if(!empty($_POST['DateDeNaissance'])){
$DateDeNaissance=$_POST['DateDeNaissance'];
$req=modificationInformationUtilisateur($db, $DateDeNaissance, 'DateDeNaissance', $idUser);
if($resultat!=""){
$resultat .="-Votre date de naissance a bien été mise à jour.<br/>";
}
else{
$resultat='-Votre date de naissance a bien été mise à jour.<br/>';
}
}
}
include_once('Vues/Profil.vue.php');
?>