-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgotPassword.php
executable file
·149 lines (122 loc) · 4.32 KB
/
forgotPassword.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
<?php
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// throw this flag to tell funcLib not to redirect us to login.php which it
// would try to do if the user is not logged in
$ignoreSession = true;
include "funcLib.php";
?>
<HTML>
<link rel=stylesheet href=style.css type=text/css>
<head>
<title>Forgot password</title>
</head>
<?php
$userid = $_REQUEST["userid"];
$password = $_REQUEST["password"];
if($userid != ""){
if($_REQUEST["changePassword"] == "true"){
// come up with random password
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
$query = "update people set password='" . md5($pass) .
"' where userid='" . $_REQUEST["userid"] . "'";
$result = mysql_query($query) or die("Could not query: " . mysql_error());
$to = $_REQUEST["email"];
$from = "";
$subject = "Your new WishList Password";
$message = "Your new password is <b>" .
$pass . "</b><p>You can change your password by going to <b>Update Your Account</b> and clicking on the <b>Change Password</b> button ";
sendEmail($to,$from,$subject,$message,0);
?>
<BODY>
<table cellspacing="0" cellpadding="5" width="100%" height="100%" bgcolor="#FFFFFF" nosave border="0" style="border: 1px solid rgb(128,255,128)">
<tr>
<td valign="top" align=center>
<p>
<p>
You should receive an email shortly with your new password
<br>
<a href="login.php">Return to login<a>
<?php
}
else{
$query = "Select * from people where userid='" . $userid . "'";
$result = mysql_query($query) or die("Could not query: " . mysql_error());
if($row = mysql_fetch_assoc($result)){
?>
<BODY>
<table cellspacing="0" cellpadding="5" width="100%" height="100%" bgcolor="#FFFFFF" nosave border="0" style="border: 1px solid rgb(128,255,128)">
<tr>
<td valign="top" align=center>
<p>
<p>
<form name=theForm method=post action=forgotPassword.php>
<input type=hidden name=email value=<?php echo $row["email"] ?>>
<input type=hidden name=changePassword value="true">
<input type=hidden name=userid value=<?php echo $_REQUEST["userid"] ?>>
<b>Click here to reset you password</b><br> <input type=submit value="Reset Password">
</form>
<?php
}
else{
?>
<body>
<table cellspacing="0" cellpadding="5" width="100%" height="100%" bgcolor="#FFFFFF" nosave border="0" style="border: 1px solid rgb(128,255,128)">
<tr>
<td valign="top" align=center>
<p>
<p>
No user found with that id - <a href="forgotPassword.php">Try Again?</a>
<p><a href="login.php">Return to login page</a>
<?php
}
}
}
else{
?>
<BODY onLoad="document.theForm.userid.focus();">
<table cellspacing="0" cellpadding="5" width="100%" height="100%" bgcolor="#FFFFFF" nosave border="0" style="border: 1px solid rgb(128,255,128)">
<tr>
<td valign="top" align=center>
<p>
<p>
<form name=theForm method=post action=forgotPassword.php>
<table style="border-collapse: collapse;" id="AutoNumber1" border="1" bordercolor="#11111" cellpadding="2" cellspacing="0" bgcolor="lightyellow">
<tr><td colspan="2" align="center" bgcolor="#6702cc"> <b><font size=3 color="#ffffff">
Forgot Password?
</td></tr>
<tr>
<td><b>Enter your WishList userid</b></td>
<td><input type=text name=userid></td>
</tr>
<tr><td colspan=2 bgcolor="#c0c0c0" align=center>
<input type=submit value=Submit>
</td>
</tr>
</table>
</form>
<?php
}
?>
</td>
</tr>
</table>
</body>
</html>