Completed
Pull Request — develop (#51)
by Patrick
02:44
created

change.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
ini_set('display_errors', 1);
3
error_reporting(E_ALL);
4
//Redirect users to https
5 View Code Duplication
if($_SERVER["HTTPS"] != "on")
6
{
7
    header("Location: https://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]);
8
    exit();
9
}
10
require_once('class.ProfilesPage.php');
11
$page = new ProfilesPage('Burning Flipside Password Change');
12
$auth = AuthProvider::getInstance();
13
$require_current_pass = true;
14
$user = $page->user;
15
if($user === false || $user === null)
16
{
17
    //We might be reseting a user's forgotten password...
18
    if(isset($_GET['hash']))
19
    {
20
        $user = $auth->getUserByResetHash($_GET['hash']);
21
        $require_current_pass = false;
22
    }
23
}
24
25
if($user === false || $user === null)
26
{
27
    if(isset($_GET['hash']))
28
    {
29
        $page->addNotification('This reset hash is no longer valid. Please select the neweset reset link in your email', FlipPage::NOTIFICATION_FAILED);
30
    }
31
    else
32
    {
33
        $page->addNotification('Please Log in first!', FlipPage::NOTIFICATION_FAILED);
34
    }
35
}
36
else
37
{
38
    $page->addJSByURI('js/zxcvbn-async.js');
39
    $page->addJSByURI('js/change.js');
40
    $current = '';
41
    if($require_current_pass)
42
    {
43
        $current = '<div class="form-group"><input class="form-control" type="password" id="current" name="current" placeholder="Current Password" required autofocus/></div>';
44
    }
45
    else
46
    {
47
        $current = '<input type="hidden" id="hash" name="hash" value="'.$_GET['hash'].'"/>';
48
    }
49
    $page->body = '
50
        <div id="content" class="container">
51
            <h3>Burning Flipside Password Change</h3>
52
            <form name="form" id="form" role="form">
53
                '.$current.'
54
                <div class="form-group"><input class="form-control" type="password" id="password" name="password" placeholder="New Password" required/></div>
55
                <div class="form-group"><input class="form-control" type="password" id="password2" name="password2" placeholder="Confirm Password" required/></div>
56
                <button class="btn btn-lg btn-primary btn-block" type="submit">Change Password</button>
57
            </form>
58
        </div>';
59
}
60
$page->printPage();
61
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
62
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
63
64
65