-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_password.php
71 lines (67 loc) · 1.86 KB
/
change_password.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!doctype html>
<html>
<head>
<title>Change Password</title>
</head>
<body>
<?php
include "read_users.php";
$group_files = array("user_passwords.conf","reader_passwords.conf");
function save_config($file,$users){
$fp=fopen($file,"w");
foreach($users as $user => $pass){
fwrite($fp,"$user\t$pass[0]".($pass[1]==''?"\n":"\t$pass[1]\n"));
}
fclose($fp);
}
session_start();
//$users = read_users("#",$conf_files);
unset($_SESSION['adb_password']);
unset($_SESSION['user']);
if(isset($_POST['name']) && isset($_POST['o_pass']) && isset($_POST['n_pass'])){
$name = $_POST['name'];
$o_pass = $_POST['o_pass'];
$n_pass = $_POST['n_pass'];
foreach($group_files as $file){
$users = read_all("#",array($file));
if(isset($users[$name]) && $users[$name][0] == $o_pass){
$users[$name][0] = $n_pass;
save_config($file,$users);
echo "<h2>Password Successfully Changed</h2></body></html>";
exit;
}
}
?>
<font face=verdana size=2>
<center>
Error: Incorrect Username or Password
<B><a href=<?php echo $_SERVER['PHP_SELF'] ?>>Click here</a></b> to login again.<P>
</center>
</font>
<?php
}else{
$form_to = "http://$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]";
if(isset($_SERVER['QUERY_STRING'])){$form_to .= "?". $_SERVER['QUERY_STRING'];}
?>
<center>
<form method="post" action="<?php echo $form_to; ?>">
<table border=0 width=350>
<tr>
<td><font face="verdana" size=2><B>User Name</B></font></td>
<td><input type="text" name="name" size=20></td>
</tr><tr>
<td><font face="verdana" size=2><B>Old Password</B></font></td>
<td><input type="password" name="o_pass" size=20></td>
</tr><tr id="mailrow">
<td><font face="verdana" size=2><B>New Password</B></font></td>
<td><input type="password" name="n_pass" size=20></td>
</tr>
</table>
<input type="submit" value="Change Password">
</form>
</center>
<?php
}
?>
</body>
</html>