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

change.php (1 issue)

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")
0 ignored issues
show
This code seems to be duplicated across your project.

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.

Loading history...
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
63
64