forked from simplerisk/code
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreset.php
More file actions
170 lines (153 loc) · 6.51 KB
/
reset.php
File metadata and controls
170 lines (153 loc) · 6.51 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
<?php
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Include required functions file
require_once(realpath(__DIR__ . '/includes/functions.php'));
require_once(realpath(__DIR__ . '/includes/authenticate.php'));
// Add various security headers
header("X-Frame-Options: DENY");
header("X-XSS-Protection: 1; mode=block");
// If we want to enable the Content Security Policy (CSP) - This may break Chrome
if (CSP_ENABLED == "true")
{
// Add the Content-Security-Policy header
header("Content-Security-Policy: default-src 'self'; script-src 'unsafe-inline'; style-src 'unsafe-inline'");
}
// Session handler is database
if (USE_DATABASE_FOR_SESSIONS == "true")
{
session_set_save_handler('sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy', 'sess_gc');
}
// Start session
session_set_cookie_params(0, '/', '', isset($_SERVER["HTTPS"]), true);
session_start('SimpleRisk');
// Include the language file
require_once(language_file());
// Default is no alert
$alert = false;
// Check if a password reset email was requested
if (isset($_POST['send_reset_email']))
{
$username = $_POST['user'];
// Try to generate a password reset token
password_reset_by_username($username);
// Send an alert message
$alert = "good";
$alert_message = "If the user exists in the system, then a password reset e-mail should be on it's way.";
}
// Check if a password reset was requested
if (isset($_POST['password_reset']))
{
$username = $_POST['user'];
$token = $_POST['token'];
$password = $_POST['password'];
$repeat_password = $_POST['repeat_password'];
// If a password reset was submitted
if (password_reset_by_token($username, $token, $password, $repeat_password))
{
$alert = "good";
$alert_message = "Your password has been reset successfully.";
}
else
{
$alert = "bad";
$alert_message = "There was a problem with your password reset request. Please try again.";
}
}
?>
<!doctype html>
<html>
<head>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<title>SimpleRisk: Enterprise Risk Management Simplified</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap-responsive.css">
</head>
<body>
<title>SimpleRisk: Enterprise Risk Management Simplified</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap-responsive.css">
<link rel="stylesheet" href="css/divshot-util.css">
<link rel="stylesheet" href="css/divshot-canvas.css">
<link rel="stylesheet" href="css/display.css">
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="http://www.simplerisk.org/">SimpleRisk</a>
<div class="navbar-content">
<ul class="nav">
<li class="active">
<a href="index.php"><?php echo $lang['Home']; ?></a>
</li>
<li>
<a href="management/index.php"><?php echo $lang['RiskManagement']; ?></a>
</li>
<li>
<a href="reports/index.php"><?php echo $lang['Reporting']; ?></a>
</li>
</ul>
</div>
</div>
</div>
</div>
<?php
if ($alert == "good")
{
echo "<div id=\"alert\" class=\"container-fluid\">\n";
echo "<div class=\"row-fluid\">\n";
echo "<div class=\"span12 greenalert\">" . $alert_message . "</div>\n";
echo "</div>\n";
echo "</div>\n";
echo "<br />\n";
}
else if ($alert == "bad")
{
echo "<div id=\"alert\" class=\"container-fluid\">\n";
echo "<div class=\"row-fluid\">\n";
echo "<div class=\"span12 redalert\">" . $alert_message . "</div>\n";
echo "</div>\n";
echo "</div>\n";
echo "<br />\n";
}
?>
<div class="container-fluid">
<div class="row-fluid">
<div class="span9">
<div class="well">
<p><label><u><?php echo $lang['SendPasswordResetEmail']; ?></u></label></p>
<form name="send_reset_email" method="post" action="">
<?php echo $lang['Username']; ?>: <input class="input-medium" name="user" id="user" type="text" maxlength="20" />
<div class="form-actions">
<button type="submit" name="send_reset_email" class="btn btn-primary"><?php echo $lang['Send']; ?></button>
<input class="btn" value="<?php echo $lang['Reset']; ?>" type="reset">
</div>
</form>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span9">
<div class="well">
<p><label><u><?php echo $lang['PasswordReset']; ?></u></label></p>
<form name="password_reset" method="post" action="">
<?php echo $lang['Username']; ?>: <input class="input-medium" name="user" id="user" type="text" maxlength="20" /><br />
<?php echo $lang['ResetToken']; ?>: <input class="input-medium" name="token" id="token" type="password" maxlength="20" /><br />
<?php echo $lang['Password']; ?>: <input class="input-medium" name="password" id="password" type="password" maxlength="50" autocomplete="off" /><br />
<?php echo $lang['RepeatPassword']; ?>: <input class="input-medium" name="repeat_password" id="repeat_password" type="password" maxlength="50" autocomplete="off" />
<div class="form-actions">
<button type="submit" name="password_reset" class="btn btn-primary"><?php echo $lang['Submit']; ?></button>
<input class="btn" value="<?php echo $lang['Reset']; ?>" type="reset">
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>