/var/www/onesolution.com.hk/onesupport/user/password.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
<?php
require_once(__DIR__ '/../checkuser.php');
function 
changePassword() {
    global 
$dbh;
    
    
$message null;
    
    
$sql "SELECT * FROM sys_login WHERE id = ?";
    
$parameters = array($_SESSION['webadmin']['id']);
    if (!(
$sth $dbh->prepare($sql))) {
        throw new 
Exception("sql prepare statement failure: $sql");
    }
    
$sth->setFetchMode(PDO::FETCH_ASSOC);
    if (!
$sth->execute($parameters)) {
        throw new 
Exception("sql execute statement failure: $sql");
    }
    
$staff $sth->fetch(PDO::FETCH_ASSOC);
    
    require(
__DIR__ '/passwordmodify.php');
    
    return array(
        
'staff' => $staff,
        
'message' => $message,
    );
}
extract(changePassword());
?><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    
    <?php require(__DIR__ '/../inc/_head_meta.php'); ?>
    
    <?php require(__DIR__ '/../inc/_head_css.php'); ?>
    
    <style type="text/css">
        body {
            padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
            padding-bottom: 40px;
        }
    </style>
    
    <?php require(__DIR__ '/../inc/_head_script.php'); ?>
    
</head>
<body>
    
    <?php require(__DIR__ '/../inc/_navbar.php'); ?>
    
    <div class="container">
        
        <?php if (isset($message) && !empty($message)): ?>
        <div class="alert alert-info">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <h5 class="alert-heading">Note:</h5>
            <p><?=$message?></p>
        </div>
        <?php endif; ?>
        
        <h2>Change password</h2>
        
        <form id="form" class="form-horizontal" method="post">
            <?php $attribute 'id'?>
            <input type="hidden" name="<?=$attribute?>" value="<?=h($staff[$attribute])?>" />
            <div class="control-group">
                <?php $attribute 'loginpw'$label 'Password'?>
                <label class="control-label" for="<?=$attribute?>"><?=$label?></label>
                <div class="controls">
                    <input type="password" id="<?=$attribute?>" name="<?=$attribute?>" value="" class="required span6" placeholder="<?=$label?>" />
                </div>
            </div>
            <div class="control-group">
                <?php $attribute 'loginpw2'$label 'Re-enter password'?>
                <label class="control-label" for="<?=$attribute?>"><?=$label?></label>
                <div class="controls">
                    <input type="password" id="<?=$attribute?>" name="<?=$attribute?>" value="" class="required span6" placeholder="<?=$label?>" />
                </div>
            </div>
            <div class="control-group">
                <div class="controls">
                    <button type="submit" class="btn btn-primary">Change</button>
                </div>
            </div>
        </form>

        <script type="text/javascript">
            $(function() {
                $('#form').validate({
                    rules: {
                        loginpw: {
                            minlength: 6
                        },
                        loginpw2: {
                            equalTo: '#loginpw'
                        }
                    }
                });
            });
        </script>
        
        
        <?php require( __DIR__ '/../inc/_footer.php'); ?>

    </div> <!-- /container -->
</body>
</html>