-
Notifications
You must be signed in to change notification settings - Fork 8
/
reset-password.php
144 lines (123 loc) · 5.99 KB
/
reset-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
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
<?php
/*
_ _ _ _
| | (_) | | | |
_ __ ___ | |__ _ _ __ ______ __| | __ _ ___| |__
| '__/ _ \| '_ \| | '_ \______/ _` |/ _` / __| '_ \
| | | (_) | |_) | | | | | | (_| | (_| \__ \ | | |
|_| \___/|_.__/|_|_| |_| \__,_|\__,_|___/_| |_|
robin-dash: Centralized Controller for Robin-Mesh networking devices
Copyright (C) 2010-2011 Cody Cooper.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if(file_exists("settings.php")) {require("settings.php");}
else {header("Location: oobe.php");exit;}
if(isset($_GET['user']) && isset($_GET['email']) && file_exists($dir . "data/" . $_GET['user'] . ".xml")) {
$xmlp = simplexml_load_file($dir . "data/" . $_GET['user'] . ".xml");
function generatePassword() {
$vowels = 'aeuy';
$consonants = 'bdghjmnpqrstvz23456789';
$password = '';
$alt = time() % 2;
for ($i = 0; $i < 9; $i++) {
if ($alt == 1) {
$password .= $consonants[(rand() % strlen($consonants))];
$alt = 0;
}
else {
$password .= $vowels[(rand() % strlen($vowels))];
$alt = 1;
}
}
return $password;
}
if($xmlp->robindash->notifymail == $_GET['email']) {
$password = generatepassword();
mail($xmlp->robindash->notifymail, "Your " . $brand . " accounts password has been reset", "Hi there " . $_GET['user'] . ",\n\nThis is an email to let you know that your accounts password at " . $brand . " has been reset.\nYour new password will be: " . $password . "\n\nPlease login to your account at: http://" . $sn . $wdir . " to change it to something more memorable soon.\n\nRegards,\nThe " . $brand . " Team");
$fc = file_get_contents($dir . "data/" . $_GET['user'] . ".xml");
$fc = str_replace($xmlp->robindash->password, md5($password), $fc);
$fh = fopen($dir . "data/" . $_GET['user'] . ".xml", 'w') or die("Can't write to the data file.");
fwrite($fh, $fc);
fclose($fh);
header("Location: " . $wdir . "reset-password.php?status=reset&is_modal=" . $_GET['is_modal']);
exit;
}
else {
header("Location: " . $wdir . "reset-password.php?status=wrong-email&is_modal=" . $_GET['is_modal']);
exit;
}
}
else if(isset($_GET['user']) && isset($_GET['email'])) {
header("Location: " . $wdir . "reset-password.php?status=wrong-user&is_modal=" . $_GET['is_modal']);
exit;
}
else if($_GET['type'] == "modal") {
?>
Simply enter your username and registered email address in the form below to reset your password:
<br />
<br />
<form action="reset-password.php" id="myform" onsubmit="return false;">
<label for="user"><strong>Username:</strong></label>
<input type="text" id="user" name="user" style="width:90%;" /><br />
<label for="email"><strong>Email:</strong></label>
<input type="text" size="30" id="email" name="email" style="width:90%;" /><br />
<input type="hidden" name="is_modal" value="true" />
<input type="submit" value="Reset Password" onclick="Modalbox.show('reset-password.php', {title: 'Reset Password', width: 500, params:Form.serialize('myform') }); return false;" /> or <a href="#" title="Cancel & Close window" onclick="Modalbox.hide(); return false;">Cancel & close window</a>
</form>
<?php
exit;
}
?>
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Reset Password: <?php echo $brand; ?></title>
<link rel="stylesheet" type="text/css" href="<?php echo $wdir; ?>resources/style.css" />
<link rel="shortcut icon" href="<?php echo $wdir; ?>resources/favicon.ico"/>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<?php
if(isset($_GET['is_modal']) && $_GET['is_modal'] == "true") {echo "";}
else {
?>
<div id="login-panel">
<h2 class="nospacing">Reset Password for</h2>
<h1><?php echo $brand; ?></h1>
<div id="page-content">
<?php
}
if(!isset($_GET['status'])) {
echo "You may reset the password for your " . $brand . " account here. Simply enter your username and email address below:<br /><br />";
echo "<form action=\"" . $wdir . "reset-password.php\" method=\"GET\" id=\"login-form\">";
echo "<label for=\"user\">Username</label><input type=\"text\" id=\"user\" name=\"user\" value=\"\" />";
echo "<label for=\"email\">Email</label><input type=\"text\" id=\"email\" name=\"email\" value=\"\" />";
echo "<input type=\"submit\" name=\"submit\" value=\"Reset Password\" class=\"btn-login\" />";
echo "</form>";
}
else if($_GET['status'] == "reset") {echo "More details have been sent to your registered email address.";}
else if($_GET['status'] == "wrong-email") {echo "You entered an incorrect email address.<br />Please <a href=\"" . $wdir . "reset-password.php\">try again</a>.";}
else if($_GET['status'] == "wrong-user") {echo "You entered an incorrect username.<br />Please <a href=\"" . $wdir . "reset-password.php\">try again</a>.";}
else {echo "Unknown status sent.";}
if(isset($_GET['is_modal']) && $_GET['is_modal'] == "true") {echo "";}
else {
?>
<br />
<p style="color:grey;text-align:center;margin-bottom:-20px;">You're usage of this website is subject to<br />the <a href="<?php echo $wdir; ?>resources/extras/legal.pdf" title="Terms and Conditions" style="color:grey;font-style:italic;text-decoration:underline;">Terms and Conditions</a>.</p>
</div>
</div>
<?php
}
echo $tracker;
?>
</body>
</html>