-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgot.php
93 lines (78 loc) · 3.2 KB
/
forgot.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
<?php
/**************************************************************************
FILENAME : forgot.php
PURPOSE OF FILE : Resets users password and emails user with new password.
LAST UPDATED : 13 February 2006
COPYRIGHT : © 2005 CMScout Group
WWW : www.cmscout.za.net
LICENSE : GPL vs2.0
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**************************************************************************/
?>
<?php
if (!defined('SCOUT_NUKE'))
die("You have accessed this page illegally, please go use the main menu");
if ($check['id'] != -1)
{
show_message("You can change your password in your profile", "index.php?page=profile");
}
if ($_POST['submit'] == "Submit")
{
$email = safesql($_POST['email'], "text");
$uname = safesql($_POST['uname'], "text");
$sql = $data->select_query("users", "WHERE email=$email AND uname=$uname");
if ($data->num_rows($sql) > 0)
{
$temp = $data->fetch_array($sql);
$id = safesql($temp['id'], "text");
$password = "";
srand(time(NULL));
$passlen = rand(6,10);
for($i=0;$i<=$passlen;$i++)
{
$what = rand(0,3);
if($what == 1)
{
$password .= chr(rand(48, 57));
}
elseif ($what == 2)
{
$password .= chr(rand(65, 90));
}
elseif ($what == 3)
{
$password .= chr(rand(97, 122));
}
elseif ($what == 0)
{
$password .= chr(rand(48, 57));
}
}
$mdpassword = safesql(md5($password), "text");
$data->update_query("users", "passwd=$mdpassword", "id=$id");
$email = $data->select_fetch_one_row("emails", "WHERE type='pwreset'");
$cmscoutTags = array("!#uname#!", "!#postuname#!", "!#title#!", "!#type#!", "!#link#!", "!#extract#!", "!#website#!", "!#password#!");
$replacements = array($temp['uname'], '', '', '', '', '', $config['troopname'], $password);
$emailContent = str_replace($cmscoutTags, $replacements, $email['email']);
sendMail($temp['email'], $temp['uname'], $email['subject'], $emailContent);
show_message("Your new password has been emailed to you.");
}
elseif ($data->num_rows($sql) == 0)
{
show_message("That email address does not seem to exist in our database.");
}
}
$dbpage = true;
$pagename='forgot';
$location = "Password Reset";
?>