-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathforgot.php
More file actions
196 lines (165 loc) · 6.69 KB
/
forgot.php
File metadata and controls
196 lines (165 loc) · 6.69 KB
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
<?php
/*================================================================+\
|| # PHPRetro - An extendable virtual hotel site and management
|+==================================================================
|| # Copyright (C) 2009 Yifan Lu. All rights reserved.
|| # http://www.yifanlu.com
|| # Parts Copyright (C) 2009 Meth0d. All rights reserved.
|| # http://www.meth0d.org
|| # All images, scripts, and layouts
|| # Copyright (C) 2009 Sulake Ltd. All rights reserved.
|+==================================================================
|| # PHPRetro is provided "as is" and comes without
|| # warrenty of any kind. PHPRetro is free software!
|| # License: GNU Public License 3.0
|| # http://opensource.org/licenses/gpl-license.php
\+================================================================*/
require_once('./includes/core.php');
$data = new forgot_sql;
$lang->addLocale("landing.forgot");
$page['name'] = $lang->loc['pagename.forgot.password'];
$page['bodyid'] = "";
session_start();
require_once('./templates/login_header.php');
$mailer = new HoloMail;
if(isset($_POST['actionForgot'])){
$lang->addLocale("forgot.email");
$forgot_name = $input->FilterText($_POST['forgottenpw-username']);
$forgot_mail = $input->FilterText($_POST['forgottenpw-email']);
$sql = $serverdb->query("SELECT id,name,email FROM ".PREFIX."users WHERE name = '".$forgot_name."' AND email = '".$forgot_mail."' AND email_verified = '1'");
if($serverdb->num_rows($sql) > 0){
$password = "";
$length = 8;
$possible = "0123456789qwertyuiopasdfghjkzxcvbnm";
$i = 0;
while ($i < $length) {
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
if (!strstr($password, $char)) {
$password .= $char;
$i++;
}
}
$row = $db->fetch_row($sql);
$hashed_pass = $input->HoloHash($password, $row[1]);
$success = $lang->loc['forgot.mail.send'];
$data->update1($row[0], $hashed_pass);
$subject = $lang->loc['forgot.mail.subject'];
$html =
'<h1>'.$lang->loc['forgot.mail.header'].'</h1>
<p>
'.$lang->loc['hello'].' <b>'.$forgot_name.'</b>'.$lang->loc['your.password'].'<br /><b>'.$password.'</b><br />'.$lang->loc['please.change'].'
</p>';
$mailer->sendSimpleMessage($forgot_mail,$subject,$html);
}else{
$result = $lang->loc['forgot.error.invalid'];
}
}elseif(isset($_POST['actionList'])){
$lang->addLocale("forgot.email");
$forgot_mail = $_POST['ownerEmailAddress'];
if($serverdb->num_rows($serverdb->query("SELECT name FROM ".PREFIX."users WHERE email = '".$forgot_mail."'")) > 0){
$plain_text = SHORTNAME."\n\n".$lang->loc['list.of.accounts']."\n\n".$lang->loc['hello']." ".$forgot_mail.",\n\n".$lang->loc['forgot.email.all.accounts'].$forgot_mail.":\n";
$html =
$lang->loc['list.of.accounts']."
<p>
".$lang->loc['hello']." <b>".$forgot_mail."</b></p>
<p>".$lang->loc['forgot.email.all.accounts']." <b>".$forgot_mail."</b>:</p><blockquote>";
$sql = $serverdb->query("SELECT name FROM ".PREFIX."users WHERE email = '".$forgot_mail."'");
while($row = $db->fetch_row($sql)){
$plain_text .= $lang->loc['account'].": ".$row[0]."\n\n";
$html .= "<p>".$lang->loc['account'].": <b>".$row[0]."</b><br /></p>\n";
}
$plain_text .= "\n\n\n* * *\n\n".$lang->loc['forgot.email.footer'];
$html .= "</blockquote>";
$subject = $lang->loc['forgot.name.subject'];
$mailer->sendSimpleMessage($forgot_mail,$subject,$html,$plain_text);
$success = $lang->loc['forgot.mail.send'];
}else{
$result2 = $lang->loc['forgot.error.invalid'];
}
}
if(!isset($success)){
?>
<style type="text/css">
div.left-column { float: left; width: 50% }
div.right-column { float: right; width: 49% }
label { display: block }
input { width: 98% }
input.process-button { width: auto; float: right }
</style>
<div id="process-content">
<div class="left-column">
<div class="cbb clearfix">
<h2 class="title"><?php echo $lang->loc['forgot.pass']; ?></h2>
<div class="box-content">
<?php if(!empty($result)){ ?>
<div class="rounded rounded-red">
<?php echo $result; ?> <br />
</div>
<div class="clear"></div>
<?php } ?>
<p><?php echo $lang->loc['forgot.pass.content']; ?></p>
<div class="clear"></div>
<form method="post" action="forgot" id="forgottenpw-form">
<p>
<label for="forgottenpw-username"><?php echo $lang->loc['forgot.username']; ?></label>
<input type="text" name="forgottenpw-username" id="forgottenpw-username" value="" />
</p>
<p>
<label for="forgottenpw-email"><?php echo $lang->loc['forgot.email']; ?></label>
<input type="text" name="forgottenpw-email" id="forgottenpw-email" value="" />
</p>
<p>
<input type="submit" value="<?php echo $lang->loc['forgot.button']; ?>" name="actionForgot" class="submit process-button" id="forgottenpw-submit" />
</p>
<input type="hidden" value="default" name="origin" />
</form>
</div>
</div>
</div>
<div class="right-column">
<div class="cbb clearfix">
<h2 class="title"><?php echo $lang->loc['forgot.name']; ?></h2>
<div class="box-content">
<?php if(!empty($result2)){ ?>
<div class="rounded rounded-red">
<?php echo $result2; ?> <br />
</div>
<div class="clear"></div>
<?php } ?>
<p><?php echo $lang->loc['forgot.name.message']; ?></p>
<div class="clear"></div>
<form method="post" action="forgot" id="accountlist-form">
<p>
<label for="accountlist-owner-email"><?php echo $lang->loc['forgot.email']; ?></label>
<input type="text" name="ownerEmailAddress" id="accountlist-owner-email" value="" />
</p>
<p>
<input type="submit" value="<?php echo $lang->loc['forgot.button.get.accounts']; ?>" name="actionList" class="submit process-button" id="accountlist-submit" />
</p>
<input type="hidden" value="default" name="origin" />
</form>
</div>
</div>
<div class="cbb clearfix">
<h2 class="title"><?php echo $lang->loc['forgot.false.alarm']; ?></h2>
<div class="box-content">
<p><?php echo $lang->loc['forgot.false.alarm.content']; ?></p>
<p><a href="<?php echo PATH; ?>/"><?php echo $lang->loc['forgot.back']; ?> »</a></p>
</div>
</div>
</div>
<?php
}else{
?>
<div id="process-content">
<div class="cbb clearfix">
<h2 class="title"><?php echo $lang->loc['forgot.success.header']; ?></h2>
<div class="box-content">
<p><?php echo $success; ?></p>
<p><a href="<?php echo PATH; ?>/">Back to homepage »</a></p>
</div>
</div>
<?php
}
require('./templates/login_footer.php');
?>