|
1
|
|
|
<?php |
|
2
|
|
|
ini_set('display_errors', 1); |
|
3
|
|
|
error_reporting(E_ALL); |
|
4
|
|
|
|
|
5
|
|
View Code Duplication |
if(strpos($_SERVER['REQUEST_URI'], '//') !== false) |
|
|
|
|
|
|
6
|
|
|
{ |
|
7
|
|
|
$uri = str_replace('//', '/', $_SERVER['REQUEST_URI']); |
|
8
|
|
|
header("Location: https://".$_SERVER["HTTP_HOST"].$uri); |
|
9
|
|
|
exit(); |
|
10
|
|
|
} |
|
11
|
|
|
|
|
12
|
|
|
require_once('class.ProfilesPage.php'); |
|
13
|
|
|
$page = new ProfilesPage('Burning Flipside Password Change'); |
|
14
|
|
|
$auth = AuthProvider::getInstance(); |
|
15
|
|
|
$require_current_pass = true; |
|
16
|
|
|
$user = $page->user; |
|
17
|
|
|
if($user === false || $user === null) |
|
18
|
|
|
{ |
|
19
|
|
|
//We might be reseting a user's forgotten password... |
|
20
|
|
|
if(isset($_GET['hash'])) |
|
21
|
|
|
{ |
|
22
|
|
|
$user = $auth->getUserByResetHash($_GET['hash']); |
|
23
|
|
|
$require_current_pass = false; |
|
24
|
|
|
} |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
if($user === false || $user === null) |
|
28
|
|
|
{ |
|
29
|
|
|
if(isset($_GET['hash'])) |
|
30
|
|
|
{ |
|
31
|
|
|
$page->addNotification('This reset hash is no longer valid. Please select the neweset reset link in your email', ProfilesPage::NOTIFICATION_FAILED); |
|
32
|
|
|
} |
|
33
|
|
|
else |
|
34
|
|
|
{ |
|
35
|
|
|
$page->addNotification('Please Log in first!', ProfilesPage::NOTIFICATION_FAILED); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
else |
|
39
|
|
|
{ |
|
40
|
|
|
$page->addJS('js/change.js'); |
|
41
|
|
|
$page->addJS('js/zxcvbn-async.js'); |
|
42
|
|
|
$current = ''; |
|
43
|
|
|
if($require_current_pass) |
|
44
|
|
|
{ |
|
45
|
|
|
$current = '<div class="form-group"><input class="form-control" type="password" id="current" name="current" placeholder="Current Password" required autofocus/></div>'; |
|
46
|
|
|
} |
|
47
|
|
|
else |
|
48
|
|
|
{ |
|
49
|
|
|
$current = '<input type="hidden" id="hash" name="hash" value="'.$_GET['hash'].'"/>'; |
|
50
|
|
|
} |
|
51
|
|
|
$page->body = ' |
|
52
|
|
|
<div id="content" class="container"> |
|
53
|
|
|
<h3>Burning Flipside Password Change</h3> |
|
54
|
|
|
<form name="form" id="form" role="form"> |
|
55
|
|
|
'.$current.' |
|
56
|
|
|
<div class="form-group"><input class="form-control" type="password" id="password" name="password" placeholder="New Password" required/></div> |
|
57
|
|
|
<div class="form-group"><input class="form-control" type="password" id="password2" name="password2" placeholder="Confirm Password" required/></div> |
|
58
|
|
|
<button class="btn btn-lg btn-primary btn-block" type="submit">Change Password</button> |
|
59
|
|
|
</form> |
|
60
|
|
|
</div>'; |
|
61
|
|
|
} |
|
62
|
|
|
$page->printPage(); |
|
63
|
|
|
/* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.