forked from OS4ED/openSIS-Classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ForgotPass.php
468 lines (415 loc) · 23.5 KB
/
ForgotPass.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
<?php
#**************************************************************************
# openSIS is a free student information system for public and non-public
# schools from Open Solutions for Education, Inc. web: www.os4ed.com
#
# openSIS is web-based, open source, and comes packed with features that
# include student demographic info, scheduling, grade book, attendance,
# report cards, eligibility, transcripts, parent portal,
# student portal and more.
#
# Visit the openSIS web site at http://www.opensis.com to learn more.
# If you have question regarding this system or the license, please send
# an email to [email protected].
#
# This program is released under the terms of the GNU General Public License as
# published by the Free Software Foundation, version 2 of the License.
# See license.txt.
#
# 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, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************************
error_reporting(0);
session_start();
include("functions/ParamLibFnc.php");
include("Data.php");
include("functions/DbGetFnc.php");
include("functions/MonthNwSwitchFnc.php");
include("functions/ProperDateFnc.php");
require_once("functions/PragRepFnc.php");
function DateInputAY($value, $name, $counter = 1, $placeholder = "Enter Date") {
$show = "";
$date_sep = "";
$monthVal = "";
$yearVal = "";
$dayVal = "";
$display = "";
if ($value != '')
return '<table><tr><td><div id="date_div_' . $counter . '" style="display: inline" >' . ProperDateAY($value) . ' </div></td><td><input type=text id="date_' . $counter . '" ' . $show . ' style="display:none" readonly></td><td><a onClick="init(' . $counter . ',2);"><img src="assets/calendar.gif" /></a></td><td><input type=hidden ' . $monthVal . ' id="monthSelect' . $counter . '" name="month_' . $name . '" ><input type=hidden ' . $dayVal . ' id="daySelect' . $counter . '" name="day_' . $name . '"><input type=hidden ' . $yearVal . ' id="yearSelect' . $counter . '" name="year_' . $name . '" ></td></tr></table>';
else {
if ($counter == 2)
return '<input type="date" id="date_' . $counter . '" required data-placeholder="' . $placeholder . '" class="form-control"><input type=hidden ' . $monthVal . ' id="monthSelect' . $counter . '" name="month_' . $name . '" disabled=disabled><input type=hidden ' . $dayVal . ' id="daySelect' . $counter . '" name="day_' . $name . '" disabled=disabled><input type=hidden ' . $yearVal . ' id="yearSelect' . $counter . '" name="year_' . $name . '" disabled=disabled>';
else
return '<input type="date" id="date_' . $counter . '" required data-placeholder="' . $placeholder . '" class="form-control"><input type=hidden ' . $monthVal . ' id="monthSelect' . $counter . '" name="month_' . $name . '" ><input type=hidden ' . $dayVal . ' id="daySelect' . $counter . '" name="day_' . $name . '"><input type=hidden ' . $yearVal . ' id="yearSelect' . $counter . '" name="year_' . $name . '" >';
}
}
function db_start() {
global $DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort, $DatabaseType;
switch ($DatabaseType) {
case 'mysqli':
$connection = new mysqli($DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName);
break;
}
// Error code for both.
if ($connection === false) {
switch ($DatabaseType) {
case 'mysqli':
$errormessage = mysqli_error($connection);
break;
}
db_show_error("", "Could not Connect to Database: $DatabaseServer", $errstring);
}
return $connection;
}
// This function connects, and does the passed query, then returns a connection identifier.
// Not receiving the return == unusable search.
// ie, $processable_results = DBQuery("select * from students");
function DBQuery($sql) {
global $DatabaseType, $_openSIS;
$connection = db_start();
switch ($DatabaseType) {
case 'mysqli':
$sql = str_replace('&', "", $sql);
$sql = str_replace('"', "", $sql);
$sql = str_replace(''', "", $sql);
$sql = str_replace('<', "", $sql);
$sql = str_replace('>', "", $sql);
$sql = par_rep("/([,\(=])[\r\n\t ]*''/", '\\1NULL', $sql);
if (preg_match_all("/'(\d\d-[A-Za-z]{3}-\d{2,4})'/", $sql, $matches)) {
foreach ($matches[1] as $match) {
$dt = date('Y-m-d', strtotime($match));
$sql = par_rep("/'$match'/", "'$dt'", $sql);
}
}
if (substr($sql, 0, 6) == "BEGIN;") {
$array = explode(";", $sql);
foreach ($array as $value) {
if ($value != "") {
$result = $connection->query($value);
if (!$result) {
$connection->query("ROLLBACK");
die(db_show_error($sql, "DB Execute Failed.", mysql_error()));
}
}
}
} else {
$result = $connection->query($sql) or die(db_show_error($sql, "DB Execute Failed.", mysql_error()));
}
break;
}
return $result;
}
// return next row.
function db_fetch_row($result) {
global $DatabaseType;
switch ($DatabaseType) {
case 'mysqli':
$return = $result->fetch_assoc();
if (is_array($return)) {
foreach ($return as $key => $value) {
if (is_int($key))
unset($return[$key]);
}
}
break;
}
return @array_change_key_case($return, CASE_UPPER);
}
// returns code to go into SQL statement for accessing the next value of a sequence function db_seq_nextval($seqname)
function db_seq_nextval($seqname) {
global $DatabaseType;
if ($DatabaseType == 'mysqli')
$seq = "fn_" . strtolower($seqname) . "()";
return $seq;
}
function db_case($array) {
global $DatabaseType;
$counter = 0;
if ($DatabaseType == 'mysqli') {
$array_count = count($array);
$string = " CASE WHEN $array[0] =";
$counter++;
$arr_count = count($array);
for ($i = 1; $i < $arr_count; $i++) {
$value = $array[$i];
if ($value == "''" && substr($string, -1) == '=') {
$value = ' IS NULL';
$string = substr($string, 0, -1);
}
$string.="$value";
if ($counter == ($array_count - 2) && $array_count % 2 == 0)
$string.=" ELSE ";
elseif ($counter == ($array_count - 1))
$string.=" END ";
elseif ($counter % 2 == 0)
$string.=" WHEN $array[0]=";
elseif ($counter % 2 == 1)
$string.=" THEN ";
$counter++;
}
}
return $string;
}
function db_properties($table) {
global $DatabaseType, $DatabaseUsername;
switch ($DatabaseType) {
case 'mysqli':
$result = DBQuery("SHOW COLUMNS FROM $table");
while ($row = db_fetch_row($result)) {
$properties[strtoupper($row['FIELD'])]['TYPE'] = strtoupper($row['TYPE'], strpos($row['TYPE'], '('));
if (!$pos = strpos($row['TYPE'], ','))
$pos = strpos($row['TYPE'], ')');
else
$properties[strtoupper($row['FIELD'])]['SCALE'] = substr($row['TYPE'], $pos + 1);
$properties[strtoupper($row['FIELD'])]['SIZE'] = substr($row['TYPE'], strpos($row['TYPE'], '(') + 1, $pos);
if ($row['NULL'] != '')
$properties[strtoupper($row['FIELD'])]['NULL'] = "Y";
else
$properties[strtoupper($row['FIELD'])]['NULL'] = "N";
}
break;
}
return $properties;
}
function db_show_error($sql, $failnote, $additional = '') {
global $openSISTitle, $openSISVersion, $openSISNotifyAddress, $openSISMode;
$tb = debug_backtrace();
$error = $tb[1]['file'] . " at " . $tb[1]['line'];
echo "
<TABLE CELLSPACING=10 BORDER=0>
<TD align=right><b>Date:</TD>
<TD><pre>" . date("m/d/Y h:i:s") . "</pre></TD>
</TR><TR>
<TD align=right><b>Failure Notice:</b></TD>
<TD><pre> $failnote </pre></TD>
</TR><TR>
<TD align=right><b>SQL:</b></TD>
<TD>$sql</TD>
</TR>
</TR><TR>
<TD align=right><b>Traceback:</b></TD>
<TD>$error</TD>
</TR>
</TR><TR>
<TD align=right><b>Additional Information:</b></TD>
<TD>$additional</TD>
</TR>
</TABLE>";
echo "
<TABLE CELLSPACING=10 BORDER=0>
<TR><TD align=right><b>Date:</TD>
<TD><pre>" . date("m/d/Y h:i:s") . "</pre></TD>
</TR><TR>
<TD align=right></TD>
<TD>openSIS has encountered an error that could have resulted from any of the following:
<br/>
<ul>
<li>Invalid data input</li>
<li>Database SQL error</li>
<li>Program error</li>
</ul>
Please take this screen shot and send it to your openSIS representative for debugging and resolution.
</TD>
</TR>
</TABLE>";
echo "<!-- SQL STATEMENT: \n\n $sql \n\n -->";
if ($openSISNotifyAddress) {
$message = "System: $openSISTitle \n";
$message .= "Date: " . date("m/d/Y h:i:s") . "\n";
$message .= "Page: " . $_SERVER['PHP_SELF'] . ' ' . ProgramTitle() . " \n\n";
$message .= "Failure Notice: $failnote \n";
$message .= "Additional Info: $additional \n";
$message .= "\n $sql \n";
$message .= "Request Array: \n" . ShowVar($_REQUEST, 'Y', 'N');
$message .= "\n\nSession Array: \n" . ShowVar($_SESSION, 'Y', 'N');
mail($openSISNotifyAddress, 'openSIS Database Error', $message);
}
die();
}
$log_msg = DBGet(DBQuery("SELECT MESSAGE FROM login_message WHERE DISPLAY='Y'"));
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>openSIS Student Information System</title>
<link rel="shortcut icon" href="favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700,400italic,600italic" rel="stylesheet" type="text/css">
<link href="styles/fonts/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/login.css">
<script src='js/Ajaxload.js'></script>
<script src='js/Validation.js'></script>
<script src='js/Validator.js'></script>
<script src='js/ForgotPass.js'></script>
<script type='text/javascript'>
function init(param, param2) {
calendar.set('date_' + param);
document.getElementById('date_' + param).click();
}
</script>
<script src="assets/js/core/libraries/jquery.min.js"></script>
<script src="assets/js/core/libraries/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
var newDate = new Date();
newDate.setDate(newDate.getDate());
$('#Date').html(dayNames[newDate.getDay()] + ", " + monthNames[newDate.getMonth()] + ' ' + newDate.getDate() + ', ' + newDate.getFullYear());
setInterval(function () {
// Create a newDate() object and extract the minutes of the current time on the visitor's
var minutes = new Date().getMinutes();
// Add a leading zero to the minutes value
$("#min").html((minutes < 10 ? "0" : "") + minutes);
}, 1000);
setInterval(function () {
// Create a newDate() object and extract the hours of the current time on the visitor's
var hours = new Date().getHours();
// Add a leading zero to the hours value
$("#hours").html((hours < 10 ? "0" : "") + hours);
}, 1000);
});
</script>
<!--custom script-->
<script src="js/custom.js"></script>
</head>
<body>
<div class="clock">
<ul>
<li id="hours"></li>
<li id="point">:</li>
<li id="min"></li>
</ul>
<div id="Date"></div>
</div>
<section class="section-forgot-password">
<div class="login-wrapper clearfix">
<div class="panel">
<div class="panel-heading">
<div class="logo">
<img src="assets/images/opensis_logo.png" alt="openSIS" />
</div>
</div>
<div class="panel-inside">
<div class="panel-heading">
<ul class="forgot-tabs clearfix">
<li class="active"><a data-toggle="tab" href="#forgot_password">Forgot Password</a></li>
<li><a data-toggle="tab" href="#forgot_username">Forgot Username</a></li>
</ul>
</div>
<div class="panel-body">
<div class="tab-content">
<div id="forgot_password" class="tab-pane fade in active">
<form name="f1" id="f1" method="post" action="ResetUserInfo.php">
<div class="form-group">
<label>I am a</label>
<div class="radio styled-radio">
<label><input type="radio" name="pass_user_type" id="pass_student" value="pass_student" checked="checked" onclick="show_fields('student');
forgotpassusername_init(this.value);" /><span></span>Student</label>
<label><input type="radio" name="pass_user_type" id="pass_staff" value="pass_staff" onclick="show_fields('staff');
forgotpassusername_init(this.value);
forgotpassemail_init('pass_email');" /><span></span>Staff</label>
<label><input type="radio" name="pass_user_type" id="pass_parent" value="pass_parent" onclick="show_fields('parent');
forgotpassusername_init(this.value);
forgotpassemail_init('pass_email');" /><span></span>Parent</label>
</div>
<input type="hidden" name="pass_type_form" id="pass_type_form" value="password"/>
</div>
<input type="hidden" id="valid_func" value="N"/>
<div id="divErr">
<?php
if ($_SESSION['err_msg'] != '')
echo $_SESSION['err_msg'];
unset($_SESSION['err_msg']);
?>
</div>
<div class="form-group" id="pass_stu_id">
<input type="text" name="password_stn_id" id="password_stn_id" placeholder="Student ID" class="form-control" onkeydown="return numberOnly(event);" onblur="return check_input_val(this.value, 'password_stn_id');"/>
</div>
<div class="form-group">
<input type="text" name="uname" id="uname" placeholder="Username" class="form-control" onkeydown=" return withoutspace_forgotpass(event);" onblur="return withoutspace_forgotpass(event);"/>
<span style="display: none" id="calculating"><img src="assets/ajax_loader.gif"/></span>
<p id="err_msg"></p>
</div>
<div class="form-group" id="pass_stu_dob">
<?php echo DateInputAY('', 'password_dob', 1, 'Date of Birth') ?>
</div>
<div id="pass_stf_email" class="form-group" style="display: none">
<input type="hidden" name="pass_email" id="pass_email" value=""/>
<input type="text" name="password_stf_email" id="password_stf_email" placeholder="Email Address" class="form-control" onblur="forgotpassemail_init('pass_email');" />
<span style="display: none" id="pass_calculating_email"><img src="assets/ajax_loader.gif"/></span>
<span id="pass_err_msg_email"></span>
</div>
<div class="row">
<div class="col-xs-6">
<input type="submit" class="btn btn-success btn-lg btn-block" value="Confirm" onClick="return forgotpass();" />
</div>
<div class="col-xs-6">
<a href="index.php" class="btn btn-default btn-rounded btn-lg btn-block">Cancel</a>
</div>
</div>
</form>
</div>
<div id="forgot_username" class="tab-pane fade">
<form name="f1" id="f1" method="post" action="ResetUserInfo.php">
<div class="form-group">
<label>I am a</label>
<div class="radio styled-radio">
<label onclick="uname_show_fields('student')"><input type="radio" name="uname_user_type" id="uname_student" value="uname_student" checked="checked" /><span></span>Student</label>
<label onclick="uname_show_fields('staff');
forgotpassemail_init('uname_email');"><input type="radio" name="uname_user_type" id="uname_staff" value="uname_staff" /><span></span>Staff</label>
<label onclick="uname_show_fields('parent');
forgotpassemail_init('uname_email');"><input type="radio" name="uname_user_type" id="uname_parent" value="uname_parent" /><span></span>Parent</label>
</div>
<input type="hidden" name="user_type_form" id="user_type_form" value="username" disabled="disabled"/>
</div>
<div class="form-group" id="uname_stu_id">
<input type="text" name="username_stn_id" id="username_stn_id" class="form-control" placeholder="Student ID" onblur="return check_input_val(this.value, 'username_stn_id');" onkeydown="return numberOnly(event);"/>
</div>
<div class="form-group">
<input type="password" name="pass" id="pass" class="form-control" placeholder="Password" />
</div>
<div class="form-group" id="uname_stu_dob">
<?php echo DateInputAY('', 'username_dob', 2, 'Date of Birth') ?>
</div>
<div class="form-group" id="uname_stf_email" style="display: none">
<input type="hidden" name="un_email" id="un_email" value=""/>
<input type="text" name="username_stf_email" id="username_stf_email" class="form-control" placeholder="Email Address" onblur="forgotpassemail_init('uname_email');" />
<span style="display: none" id="uname_calculating_email"><img src="assets/ajax_loader.gif"/></span>
<span id="uname_err_msg_email"></span>
</div>
<div class="row">
<div class="col-xs-6">
<input type="submit" class="btn btn-success btn-lg btn-block" name="save" onClick="return forgotusername();" value="Confirm" />
</div>
<div class="col-xs-6">
<a href="index.php" class="btn btn-default btn-rounded btn-lg btn-block">Cancel</a>
</div>
</div>
</form>
</div>
</div>
</form>
</div>
</div>
<!-- <div class="panel-footer">
<p class="info-text"><?php echo $log_msg[1]['MESSAGE']; ?></p>
</div>-->
</div>
<footer>
openSIS is a product of Open Solutions for Education, Inc. (<a href='http://www.os4ed.com' target='_blank'>OS4ED</a>) and is licensed under the <a href='http://www.gnu.org/licenses/gpl.html' target='_blank'>GPL license</a>.
</footer>
</div>
</section>
</body>
</html>