-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmembership_passwordReset.php
230 lines (213 loc) · 7.23 KB
/
membership_passwordReset.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
$d=dirname(__FILE__);
include("$d/defaultLang.php");
include("$d/language.php");
include("$d/lib.php");
include("$d/header.php");
#_______________________________________________________________________________
# Step 4: Final step; change the password
#_______________________________________________________________________________
if($_POST['changePassword'] && $_SESSION['resetUsername']!=$adminConfig['adminUsername']){
echo StyleSheet();
if($_POST['key']!=$_SESSION['resetKey'] || !$_POST['key']){
?>
<div class="Error">
<?php echo $Translation['password reset invalid']; ?>
</div>
<?php
exit;
}
if($_POST['newPassword']!=$_POST['confirmPassword'] || !$_POST['newPassword']){
?>
<div class="Error">
<?php echo $Translation['password no match']; ?>
</div>
<?php
exit;
}
sql("update membership_users set passMD5='".md5($_POST['newPassword'])."' where lcase(memberID)='".strtolower($_SESSION['resetUsername'])."'");
?>
<div style="width:500px; margin:0px auto; text-align:left;">
<div class="TableTitle">
<?php echo $Translation['password reset done']; ?>
</div>
</div>
<?php
exit;
}
#_______________________________________________________________________________
# Step 3: This is the special link that came to the member by email. This is
# where the member enters his new password.
#_______________________________________________________________________________
if($_GET['key']){
echo StyleSheet();
if($_GET['key']==$_SESSION['resetKey'] && $_SESSION['resetUsername']!=$adminConfig['adminUsername']){
$res=sql("select * from membership_users where lcase(memberID)='".strtolower($_SESSION['resetUsername'])."'");
if(!$row=mysql_fetch_assoc($res)){
?>
<div class="Error">
<?php echo $Translation['password reset invalid']; ?>
</div>
<?php
exit;
}
?>
<div align="center">
<form method="post" action="membership_passwordReset.php">
<table border="0" cellspacing="1" cellpadding="4" align="center" width="500">
<tr>
<td colspan="2" class="TableHeader">
<div class="TableTitle"><?php echo $Translation['password change']; ?></div>
</td>
</tr>
<tr>
<td align="right" class="TableHeader" width="160" <?php echo $highlight; ?>>
<?php echo $Translation['username']; ?>
</td>
<td align="left" class="TableBody" width="340">
<?php echo $row['memberID']; ?>
</td>
</tr>
<tr>
<td align="right" class="TableHeader">
<?php echo $Translation['new password']; ?>
</td>
<td align="left" class="TableBody">
<input type="password" name="newPassword" value="" size="20" class="TextBox">
</td>
</tr>
<tr>
<td align="right" class="TableHeader">
<?php echo $Translation['confirm password']; ?>
</td>
<td align="left" class="TableBody">
<input type="password" name="confirmPassword" value="" size="20" class="TextBox">
</td>
</tr>
<tr>
<td colspan="2" align="right" class="TableHeader">
<input type="submit" name="changePassword" value="<?php echo $Translation['ok']; ?>">
</td>
</tr>
</table>
<input type="hidden" name="key" value="<?php echo $_GET['key']; ?>">
</form>
</div>
<?php
exit;
}else{
?>
<div class="Error">
<?php echo $Translation['password reset invalid']; ?>
</div>
<?php
exit;
}
}
#_______________________________________________________________________________
# Step 2: Send email to member containing the reset link
#_______________________________________________________________________________
if($_POST['reset']){
$username=makeSafe(strtolower($_POST['username']));
$email=isEmail($_POST['email']);
if((!$username && !$email) || ($username==$adminConfig['adminUsername'])){
redirect("membership_passwordReset.php?emptyData=1");
}
echo StyleSheet();
$res=sql("select * from membership_users where lcase(memberID)='$username' or email='$email' limit 1");
if(!$row=mysql_fetch_assoc($res)){
?>
<div class="Error">
<?php echo $Translation['password reset invalid']; ?>
</div>
<?php
exit;
}else{
// avoid admin password change
if($row['memberID']==$adminConfig['adminUsername']){
?>
<div class="Error">
<?php echo $Translation['password reset invalid']; ?>
</div>
<?php
exit;
}
// generate and store unique key
$key=md5(microtime());
$_SESSION['resetKey']=$key;
$_SESSION['resetUsername']=$row['memberID'];
// determine password reset URL
$host=$_SERVER['HTTP_HOST'];
$uri=rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$http=(strtolower($_SERVER['HTTPS']) == 'on' ? 'https:' : 'http:');
$ResetLink="$http//$host$uri/"."membership_passwordReset.php?key=$key";
// send reset instructions
@mail($row['email'], $Translation['password reset subject'], str_replace('<ResetLink>', $ResetLink, $Translation['password reset message']), "From: ".$adminConfig['senderName']." <".$adminConfig['senderEmail'].">");
}
// display confirmation
?>
<div style="width:500px; margin:0px auto; text-align:left;">
<div class="TableTitle">
<?php echo $Translation['password reset ready']; ?>
</div>
</div>
<?php
exit;
}
#_______________________________________________________________________________
# Step 1: get the username or email of the member who wants to reset his password
#_______________________________________________________________________________
echo StyleSheet();
if($_GET['emptyData']){
$highlight="style=\"color: red;\"";
}
?>
<div align="center">
<form method="post" action="membership_passwordReset.php">
<table border="0" cellspacing="1" cellpadding="4" align="center" width="500">
<tr>
<td colspan="2" class="TableHeader">
<div class="TableTitle"><?php echo $Translation['password reset']; ?></div>
</td>
</tr>
<tr>
<td colspan="2" class="TableBody" align="left">
<div class="TableBody"><?php echo $Translation['password reset details']; ?></div>
</td>
</tr>
<tr>
<td align="right" class="TableHeader" width="160" <?php echo $highlight; ?>>
<?php echo $Translation['username']; ?>
</td>
<td align="left" class="TableBody" width="340">
<input type="text" name="username" value="" size="20" class="TextBox">
</td>
</tr>
<tr>
<td align="right" class="TableHeader" <?php echo $highlight; ?>>
<?php echo '<i>'.$Translation['or'].':</i> '.$Translation['email']; ?>
</td>
<td align="left" class="TableBody">
<input type="text" name="email" value="" size="45" class="TextBox">
</td>
</tr>
<tr>
<td colspan="2" align="right" class="TableHeader">
<input type="submit" name="reset" value="<?php echo $Translation['ok']; ?>">
</td>
</tr>
<tr>
<td colspan="2" align="center" class="TableHeader">
<?php echo $Translation['browse as guest']; ?>
</td>
</tr>
</table>
</form>
<br /><br />
<div class="TableFooter">
<b><a href=http://www.bigprof.com/appgini/>BigProf Software</a> - <?php echo $Translation['powered by']; ?> AppGini 4.52</b>
</div>
</div>
<?php
?>
<?php include("$d/footer.php"); ?>