-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaccount_changepassword.php
145 lines (114 loc) · 4.37 KB
/
account_changepassword.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
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
<?
function showError($code) {
global $lang;
echo "<br /><font color=\"#FF0000\">".$lang["account_changepassword_error_".$code].".</font>";
}
$has_errors = 0;
$do_not_display = 0;
$errors = array();
if (($_GET["cmd"]=="update")&&(form_key_verify("ACCOUNT_CHANGEPASSWORD", sql_injection_check($_POST["code"])))) {
$password_old = sql_injection_check($_POST["password_old"]);
$password_new1 = sql_injection_check($_POST["password_new1"]);
$password_new2 = sql_injection_check($_POST["password_new2"]);
/*** Validate Old Password ***/
if ($user_data["password"]!=md5($password_old)) {
$has_errors = 1;
array_push($errors, "oldpassword_incorrect");
}
/*** Validate New Password ***/
if (strlen($password_new1)<3) {
$has_errors = 1;
array_push($errors, "newpassword_short");
}
if (strlen($password_new1)>150) {
$has_errors = 1;
array_push($errors, "newpassword_long");
}
/*** Validate New Password - Confirm ***/
if ($password_new1!=$password_new2) {
$has_errors = 1;
array_push($errors, "newpassword_nomatch");
}
if ($has_errors==0) {
$do_not_display = 1;
$new_pass = md5($password_new1);
$seed = generate_password(30);
$timestamp = date("Ymdhis");
$ip = $_SERVER['REMOTE_ADDR'];
$key = md5($seed.$timestamp.$ip);
SqlQuery("INSERT INTO users_changepassword (userid, newpassword, verifykey) VALUES ('".$user_data["id"]."', '$new_pass', '$key')");
$emailSubject = GetRow("SELECT subject FROM emails WHERE code = 'CHANGE_PASSWORD'");
$emailContent = GetRow("SELECT content FROM emails WHERE code = 'CHANGE_PASSWORD'");
$emailContent = str_replace("%%LINK%%", "http://www.reidobingo-net.umbler.net/".$links["ACCOUNT_CONFIRM_CHANGEPASSWORD"].$qr."key=$key", $emailContent);
send_email($user_data["email"], $emailSubject, $emailContent);
showContent("MYACCOUNT_CHANGEPASSWORD_EMAIL");
}
}
if ($do_not_display==0) {
?>
<h1><?=$lang["account_changepassword_title"]?></h1>
<form method="post" action="<?=$links["ACCOUNT_CHANGEPASSWORD_UPD"]?>" onSubmit="return verify_form_change_password();"?>" onSubmit="return verify_form_change_password();"?>" onSubmit="return verify_form_change_password();">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" height="10"></td>
</tr>
<tr>
<td align="right" width="190" class="registration_<?checkError("oldpassword_incorrect")?>"?>"><?=$lang["account_changepassword_old_password"]?>:</td>
<td width="20"> </td>
<td class="registration_text">
<input type="password" name="password_old" id="password_old" class="registration_text" />
<?
if (in_array("oldpassword_incorrect", $errors)) {
showError("oldpassword_incorrect");
}
?>
</td>
</tr>
<tr>
<td colspan="3" height="10"></td>
</tr>
<tr>
<td align="right" width="190" class="registration_<?checkError("newpassword_short,newpassword_long")?>"?>"><?=$lang["account_changepassword_new_password1"]?>:</td>
<td width="20"> </td>
<td class="registration_text">
<input type="password" name="password_new1" id="password_new1" class="registration_text" />
<?
if (in_array("newpassword_short", $errors)) {
showError("newpassword_short");
} else {
if (in_array("newpassword_long", $errors)) {
showError("newpassword_long");
}
}
?>
</td>
</tr>
<tr>
<td colspan="3" height="10"></td>
</tr>
<tr>
<td align="right" width="190" class="registration_<?checkError("newpassword_nomatch")?>"?>"><?=$lang["account_changepassword_new_password2"]?>:</td>
<td width="20"> </td>
<td class="registration_text">
<input type="password" name="password_new2" id="password_new2" class="registration_text" />
<?
if (in_array("newpassword_nomatch", $errors)) {
showError("newpassword_nomatch");
}
?>
</td>
</tr>
<tr>
<td colspan="3" height="10"></td>
</tr>
<tr>
<td width="170"></td>
<td width="20"> </td>
<td>
<input type="submit" name="submitbutton" id="submitbutton" value="<?=$lang["account_changepassword_submit"]?>" class="registration_text"?>" class="registration_text"?>" class="registration_text" /></td>
</tr>
</table>
<input type="hidden" name="code" value="<?=form_key_create("ACCOUNT_CHANGEPASSWORD")?>"?>"?>" />
</form>
<? } ?>
<br /><br /><a href="<?=$links["ACCOUNT"]?>" class="blink"?>" class="blink"?>" class="blink"><?=$lang["account_transfers_back"]?></a>