· 9 years ago · Oct 12, 2016, 04:52 AM
1<?php
2require('../../../includes/config.php');
3require('../../../structure/database.php');
4require('../../../structure/base.php');
5require('../../../structure/user.php');
6
7$database = new database($db_host, $db_name, $db_user, $db_password);
8$base = new base($database);
9$user = new user($database);
10
11//set some basic vars
12$username = $user->getUsername($_COOKIE['user'], 2);
13$rank = $user->getRank($username);
14?>
15<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
16<html xmlns:IE>
17
18<head>
19 <meta http-equiv="Expires" content="0">
20 <meta http-equiv="Pragma" content="no-cache">
21 <meta http-equiv="Cache-Control" content="no-cache">
22 <meta name="MSSmartTagsPreventParsing" content="TRUE">
23 <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
24 <title><?php echo $data['wb_title']; ?></title>
25 <link href="../../../css/basic-3.css" rel="stylesheet" type="text/css" media="all">
26 <link href="../../../css/main/title-5.css" rel="stylesheet" type="text/css" media="all">
27 <script src="http://code.jquery.com/jquery-latest.min.js"></script>
28 <link rel="shortcut icon" href="../../../img/favicon.ico"/>
29 <?php include('../../../includes/google_analytics.html'); ?>
30 <style>
31 fieldset {
32 text-align: left;
33 border: 2px solid #625437;
34 width: 95%;
35 position: relative;
36 margin: 10px;
37 padding-left: 10px;
38 background-color: transparent;
39 }
40
41 legend {
42 color: #625437;
43 font-weight: bold;
44 font-size: 15px;
45 }
46
47 label {
48 display: block;
49 height: 20px;
50 text-align: center;
51 }
52
53 textarea {
54 display: block;
55 width: 200px;
56 height: 100px;
57 }
58
59 </style>
60 <script type="text/javascript">
61 function goBack() {
62 window.history.back();
63 }
64 </script>
65</head>
66
67<div id="body">
68 <?php //$base->getNavBar($username, $path, $rank); ?>
69
70 <div style="text-align: center; background: none;">
71 <div class="titleframe e">
72 <b>Password Support</b><br/>
73 <a href="../../../index">ScapeRune Home</a>
74 </div>
75 </div>
76</div>
77
78<div class="frame e" style="overflow:auto;">
79 <?php
80 //make sure user doesn't already have a recovery request submitted
81 $database->processQuery("SELECT * FROM `tracking` WHERE " . time() . " - `time` < 7200 AND `ip` = ? LIMIT 1", array($_SERVER['REMOTE_ADDR']), false);
82
83 if ($database->getRowCount() >= 1) {
84 echo '<center>Oops! You have already submitted a recovery request.<br /><br /> <a href="../../../index"Main Menu</a></center>';
85
86 } elseif (!isset($_REQUEST['username'])) {
87 ?>
88
89 <form action="recover_password.php" method="POST">
90 <input type="text" name="username" maxlength="12"><input type="submit" value="Continue">
91 </form>
92
93 <?php
94 } elseif (!$user->doesExist($_REQUEST['username'])) {
95 echo 'No user exists with that username!<br /> <input type="button" value="Back" onclick="goBack()" />';
96 } else {
97
98 $questions[] = array();
99 $questions[0] = 'Where was your first vacation?:';
100 $questions[1] = 'Who was your first best friend?:';
101 $questions[2] = 'What was your first pets name?:';
102 $questions[3] = 'Who was your first boyfriend/girlfriend?:';
103 $questions[4] = 'What color was your first bedroom?:';
104 $questions[5] = 'Who is your favorite musical artist?';
105
106 //extract data
107 $data = $database->processQuery("SELECT * FROM `recoveries` WHERE `id` = ? LIMIT 1", array($user->getIdByName($_REQUEST['username'])), false);
108
109 if ($database->getRowCount() == 0 || $user->getUsername($_COOKIE['user'], 2) == $_REQUEST['username']) {
110 echo 'Temporarily disabled! <input type="button" value="Back" onclick="goBack()" />';
111 } elseif (!isset($_POST['answer']) && !isset($_POST['bypass'])) {
112 ?>
113 <fieldset class="question">
114 <legend>Important Information</legend>
115 This form will allow you to request that a new password is set for the account: <b><?php echo '"'.$_REQUEST['username']. '"'; ?></b>.
116 <br /><br />
117 <img style="float: left" src="/img/title2/lock.gif">
118 <span style="font-weight: bold; color: rgb(255, 187, 34);">Want to be back in game sooner? If you want to get back in game quickly, here are a few tips:</span><br/><br/>
119
120 Please answer all the questions below to confirm that you are the real owner of the account.<br/><br/>
121 Enter the earliest and most specific information about the account that you can.<br/><br/>
122 Take the time to remember as much detail as possible. The more detail you give us, <b>the quicker you
123 can be
124 back in game</b>
125 <br/><br/>
126 If you really don't know the answer to a question, leave the answer box blank.<br/><br/>
127 <b>Remember:</b> The more questions you answer correctly, the sooner you can be back in game!
128 </fieldset>
129 <br/>
130
131 <fieldset class="question">
132 <legend>Answer Recovery Questions</legend>
133 <p style="text-align: center">If you have set these, you must try to answer at least three. Recovery
134 answers
135 have a minimum length of 3 characters.
136 Recovery answers can only contain the characters A-Z, 0-9 and accented characters such as é or
137 ü.
138 Other characters will not count towards the length.</p>
139
140 <label><b>I have not set any recovery questions</b>
141 <input type="checkbox" class="input_control" value="subject"/></label>
142
143 <form action="recover_password.php" method="POST">
144 <input type="hidden" name="username" value="<?php echo $_REQUEST['username']; ?>">
145 <table cellpadding="6" style="margin-left:auto;margin-right:auto;">
146 <?php
147 $i = 0;
148 foreach ($questions as $question) {
149 $i++;
150 ?>
151 <tr>
152 </tr>
153 <tr>
154 <td><?php echo $question; ?> 
155 <input type="text" class="textbox" name="answer[]" maxlength="40"
156 style="display: block;"></td>
157 </tr>
158 <?php
159 }
160 ?>
161 </table>
162 </form>
163 </fieldset>
164
165 <fieldset class="question">
166 <legend>Your New Password</legend>
167 <p style="text-align: center">These must match exactly for the appeal to proceed.<br/>
168 For advice on setting a good password, please click <a style="color: rgb(255, 187, 34);"
169 target="_blank"
170 href="/kbase/viewarticle7564.html?article_id=2087">here</a>
171 (Opens in a new window).</p>
172 <table>
173 <tr>
174 <td style="vertical-align: middle"><b>Enter a new password for your account: <input type="text"
175 name="username"></b>
176 </td>
177 </tr>
178 <tr>
179 <td style="vertical-align: middle"><b>          Please
180 enter it again: <input type="text" name="username"></b></td>
181 </tr>
182 </table>
183 </fieldset>
184
185 <form action="recover_password.php" method="POST">
186 <input type="hidden" name="username" value="<?php echo $_REQUEST['username']; ?>">
187 <input type="hidden" name="bypass">
188 <fieldset class="question">
189 <legend>Other Details</legend>
190 When did you create this account?
191 <table>
192 <tr>
193 <td style="vertical-align: middle">
194 If you have any other details which would help you prove your ownership of this
195 account, please enter them here.<br/>
196 Please <b>do not</b> provide us with any of this following personal information, your full
197 name, home
198 address, email address or telephone number.<br/><br/>
199 <span class='textcounter' id="counter1">You have 300 characters remaining</span>
200 </td>
201 <td>
202 <textarea style="height: 120px; width: 450px;" class="textlimited"
203 data-textcounterid="counter1" maxlength="300" rows="4" cols="50"></textarea><br/>
204 </td>
205 </tr>
206 </table>
207 <input type="submit" value="Submit"/>
208 </form>
209 </fieldset>
210 <?php
211 } else if(isset($_POST['answers'])) {
212 //validate answers
213 $errors = array();
214 $answers = $_POST['answer'];
215 $i = 0;
216
217 foreach ($answers as $answer) {
218 $i++;
219
220 if (strlen($answer) < 3 || strlen($answer) > 35) {
221 $errors[] = 'Question #' . $i . ' must be at least three characters and no more than 26 characters.';
222 }
223
224 if (preg_match('#[^a-zA-Z0-9$/^[\p{L}-]*$/u ]#', $answer)) {
225 $errors[] = 'Question #' . $i . ' contains illegal characters.';
226 }
227 }
228
229 if (count($errors) >= 1) {
230 //back button
231 ?>
232 <center><input type="button" value="Back" onclick="goBack()"/></center> <?php
233
234 //display errors
235 foreach ($errors as $error) {
236 echo $error . '<br/>';
237 }
238 } else {
239 //generate a tracking ID
240 $rand_hash = $base->randomString(11);
241 $tracking_id = substr($rand_hash, 0, 3) . '-' . substr($rand_hash, 4, 3) . '-' . substr($rand_hash, 7, 3);
242
243 //create the recovery request
244 $database->processQuery("INSERT INTO `tracking` VALUES (null, ?, ?, NOW(), ?, ?, 0, ?, ?, ?, ?, ?, ?)", array($user->getIdByName($_REQUEST['username']), $_SERVER['REMOTE_ADDR'], time(), $tracking_id, $answers[0], $answers[1], $answers[2], $answers[3], $answers[4], $answers[5]), false);
245
246 ?>
247 <fieldset class="question">
248 <legend>Success!</legend>
249 You have successfully submitted an account recovery request. Your request will be
250 reviewed and processed within the next 48 hours. To track your account recovery
251 progress you can use the <b>recovery tracking ID</b>.<br><br> <b>Please make
252 note</b> of the the tracking ID provided to you and store it in a <b>safe</b>,
253 <b>secure</b> location so you don't lose or forget it.</b>
254 </fieldset>
255 <br/>
256 <br/>
257 <b>Tracking ID: <?php echo $tracking_id; ?></b>
258
259 <?php
260 }
261 } else if(isset($_POST['bypass'])) {
262 //generate a tracking ID
263 $rand_hash = $base->randomString(11);
264 $tracking_id = substr($rand_hash, 0, 3) . '-' . substr($rand_hash, 4, 3) . '-' . substr($rand_hash, 7, 3);
265
266 //create the recovery request
267 $database->processQuery("INSERT INTO `tracking` VALUES (null, ?, ?, NOW(), ?, ?, 0, ?, ?, ?, ?, ?, ?)", array($user->getIdByName($_REQUEST['username']), $_SERVER['REMOTE_ADDR'], time(), $tracking_id, 'answer0', 'answer1', 'answer2', 'answer3', 'answer4', 'answer5'), false);
268
269 ?>
270 <fieldset class="question">
271 <legend>Success!</legend>
272 You have successfully submitted an account recovery request. Your request will be
273 reviewed and processed within the next 48 hours. To track your account recovery
274 progress you can use the <b>recovery tracking ID</b>.<br><br> <b>Please make
275 note</b> of the the tracking ID provided to you and store it in a <b>safe</b>,
276 <b>secure</b> location so you don't lose or forget it.</b>
277 </fieldset>
278 <br/>
279 <br/>
280 <b>Tracking ID: <?php echo $tracking_id; ?></b>
281
282 <?php
283 } else {
284 echo 'Error: dead end.';
285 }
286 }
287 ?>
288 <br/>
289 <br/>
290
291 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
292 <script type="text/javascript">
293 //checks how many characters are remaining
294 // the selector below will catch the keyup events of elements decorated with class textlimited and have a maxlength
295 $('.textlimited[maxlength]').keyup(function () {
296 //get the fields limit
297 var maxLength = $(this).attr("maxlength");
298
299 // check if the limit is passed
300 if (this.value.length > maxLength) {
301 return false;
302 }
303
304 // find the counter element by the id specified in the source input element
305 var counterElement = $(".textcounter#" + $(this).data("textcounterid"));
306 // update counter 's text
307 counterElement.html("You have " + (maxLength - this.value.length) + " chararacters remaining");
308 });
309
310 //checks if the user has selected no recoveries and disables the textareas
311 $(document).ready(function () {
312 $('.input_control').change(function () {
313 $(".textbox").prop('disabled', this.checked);
314 $(".textarea").prop('disabled', this.checked);
315 });
316 $('.input_control').prop('checked', false);
317 $('.input_control').trigger('change');
318 });
319
320 // for future development
321 var months = [
322 {DaysInMonth: 31, Name: "January"},
323 {DaysInMonth: 31, Name: "February"},
324 {DaysInMonth: 31, Name: "March"},
325 {DaysInMonth: 31, Name: "April"},
326 {DaysInMonth: 31, Name: "May"},
327 {DaysInMonth: 31, Name: "June"},
328 {DaysInMonth: 31, Name: "July"},
329 {DaysInMonth: 31, Name: "August"},
330 {DaysInMonth: 31, Name: "September"},
331 {DaysInMonth: 31, Name: "October"},
332 {DaysInMonth: 31, Name: "November"},
333 {DaysInMonth: 31, Name: "December"}
334 ];
335 $(function () {
336 var monthSelector = $('select[name=month]');
337 $.each(months, function (index, month) {
338 $('<option></option>')
339 .attr('label', month.Name)
340 .attr('value', index)
341 .html(month.DaysInMonth)
342 .appendTo(monthSelector);
343 });
344
345 var yearSelector = $('select[name=ano]');
346 for (var year = 2015; year <= 2016; year++)
347 $('<option></option>')
348 .attr('label', year)
349 .attr('value', year)
350 .html(year)
351 .appendTo(yearSelector);
352 });
353
354 //limits the characters input in the 'other details' text area
355 function charLimit(limitField, limitNum) {
356 if (limitField.value.length > limitNum) {
357 limitField.value = limitField.value.substring(0, limitNum);
358 }
359 }
360 </script>
361 <div style="clear: both;"></div>
362</div>
363</div>
364</div>
365</div>
366
367<div class="tandc"><?php echo $data['wb_foot']; ?></div>
368</div>
369</body>
370</html>