-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange_password.php
More file actions
33 lines (31 loc) · 1.18 KB
/
change_password.php
File metadata and controls
33 lines (31 loc) · 1.18 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
<?php
require('verifco.php');
$name = 'password.txt';
if(connected()) {
if(check($_POST)) {
if(check($_POST['currentpassword']) && check($_POST['newpassword']) && check($_POST['confirmnewpassword'])) {
if(file_exists($name)) {
if(file_get_contents($name) == sec($_POST['currentpassword']) && sec($_POST['newpassword']) == sec($_POST['confirmnewpassword'])) {
$writepassword = fopen('password.txt', 'w');
fwrite($writepassword, sec($_POST['newpassword']));
fclose($writepassword);
} else {
echo "incorrect passwords";
http_response_code(304); // not modified
}
} else {
echo "password.txt file not found";
http_response_code(404);
}
} else {
echo "Include currentpassword, newpassword and confirmnewpassword keys";
http_response_code(400); // bad request
}
} else {
echo "No correct POST content";
http_response_code(400); // bad request
}
} else {
echo "not connected";
http_response_code(401); // forbidden
}