-
Notifications
You must be signed in to change notification settings - Fork 0
/
passwd.php
138 lines (116 loc) · 4.64 KB
/
passwd.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
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
<?php
/*
* Page that permits to an user to change his password
*/
include_once dirname(__FILE__) . "/classes/User.php";
include_once dirname(__FILE__) . "/functions/functions.php";
session_start();
if (!isset($_SESSION['USERNAME']))
{
redirect("login.php", 301);
} else
{
//TODO check Session Duration
try
{
$user = new User($_SESSION['USERNAME']);
if (isset($_POST['OLDPWD']) && isset($_POST['PWD']) && isset($_POST['PWDR']))
{
if ($_POST['OLDPWD'] == "" || $_POST['PWD'] == "" || $_POST['PWDR'] == "")
throw new Exception("Fields cannot be empty");
try
{
if ($user->HasPassword($_POST['OLDPWD']))
{
$user->ChangePassword($_POST['PWD'], $_POST['PWDR']);
} else
{
$error = "Wrong Password";
$_SESSION = array();
if (ini_get("session.use_cookies"))
{
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 3600 * 24, $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
}
session_destroy();
}
} catch (Exception $e)
{
$error = $e->getMessage();
}
$msg = "Password Changed Successfully";
}
} catch (Exception $e)
{
$error = $e->getMessage();
}
}
?>
<html>
<head>
<title>RaspiControl</title>
<meta charset="utf-8"/>
<meta name="viewport"
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi"/>
<meta name="msapplication-tap-highlight" content="no"/>
<meta name="apple-mobile-web-app-capable" content="no">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<!-- Stylesheet -->
<link rel="stylesheet" href="style/style.css"/>
<!--Google Fonts !-->
<link href='http://fonts.googleapis.com/css?family=Economica:400,700' rel='stylesheet' type='text/css'>
<link rel="shortcut icon" href="style/images/favicon.ico">
<link rel="icon" sizes="128x128" href="style/images/android.png" type="image/png"/>
<link rel="icon" sizes="192x192" href="style/images/android-hd.png" type="image/png"/>
<link rel="apple-touch-icon" sizes="120x120" href="style/images/apple-iphone.png" type="image/png"/>
<link rel="apple-touch-icon" sizes="152x152" href="style/images/apple-ipad.png" type="image/png"/>
<link rel="mask-icon" color="#d6264f" href="style/images/iconP.svg">
</head>
<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" onresize="setFooterWidth()"
onload="setFooterWidth()">
<div class="page passwd" data-role="page" data-theme="b">
<header>
RaspiControl
</header>
<form id="passwd_Form" class="passwd" action="passwd.php" method="POST" data-ajax="false">
<?php
if (isset($error))
echo "<p class='error'>$error</p>";
else if (isset($msg))
echo "<p class='message'>$msg</p>";
else
{
?>
<p class="input">
<label for="oldpwd">Old Password:</label>
<input id="oldpwd" type="password" name="OLDPWD" value=""
placeholder="Old Password" onkeypress="return submitOnEnter(event, 'passwd_Form')"/>
<label for="pwd1">New Password:</label>
<input id="pwd1" type="password" name="PWD" value=""
placeholder="Password" onkeypress="return submitOnEnter(event, 'passwd_Form')"/>
<label for="pwd2">Repeat new Password:</label>
<input id="pwd2" type="password" name="PWDR" value=""
placeholder="Repeat Password" onkeypress="return submitOnEnter(event, 'passwd_Form')"/>
</p>
<p class="input button" id="passwd" onclick="submitForm(this)">CHANGE</p>
<?php } ?>
</form>
<footer>
<ul>
<li class="footerTab">
<?php
if (isset($error))
echo "<a href=\"passwd.php\">BACK</a>";
else echo "<a href=\"index.php\">BACK</a>";
?>
</li>
<li class="footerTab">
<a href="index.php?LOGOUT">LOGOUT</a>
</li>
</ul>
</footer>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="scripts/function.js"></script>
</body>
</html>