-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditmember.php
48 lines (38 loc) · 1.61 KB
/
editmember.php
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
<?php
include('db.php');
if(isset($_FILES) && !empty($_FILES)){
$m = $membre->getById($_SESSION['id']);
$uploaddir = 'img/avatar/';
$uploadfile = $uploaddir . basename($_SESSION['id'] .".". pathinfo($_FILES['avatar']['name'], PATHINFO_EXTENSION));
if(file_exists('img/avatar/'. basename($_SESSION['id']) .".png")){
unlink('img/avatar/'. basename($_SESSION['id']) .".png");
}
if(file_exists('img/avatar/'. basename($_SESSION['id']) .".jpg")){
unlink('img/avatar/'. basename($_SESSION['id']) .".jpg");
}
move_uploaded_file($_FILES['avatar']['tmp_name'], $uploadfile);
$m->setAvatar($uploadfile);
$membre->update($m);
if($_FILES['avatar']['size'] < 2097152){
echo "avatar";
}else{
echo "fat";
}
}
if(isset($_POST) && !empty($_POST)){
if(isset($_POST['password_old']) && $_POST['password_old'] != "" && isset($_POST['password_new']) && $_POST['password_new'] != "" && isset($_POST['password_confirm']) && $_POST['password_confirm'] != ""){
$m = $membre->getById($_SESSION['id']);
if($m->password() == md5($_POST['password_old'])){
if($_POST['password_new'] == $_POST['password_confirm']){
$m->setPassword(md5($_POST['password_new']));
$membre->update($m);
echo "ok";
}else{
echo "noot";
}
}else{
echo "old";
}
}
}
?>