This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
account.php
80 lines (74 loc) · 2.53 KB
/
account.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
<?php // vim:set ts=4 sw=4 sts=4 et:
require_once "config.php";
require_once "html.php";
require_once "db-func.php";
require_once "utils.php";
// Redirect to the login page, if not logged in
$uid = isLoggedIn();
// Start HTML
head("account", "Account Overview");
$passwd = '';
if (isset($_POST['changepwd'])) {
$passwd = change_password($uid, $_POST['oldpass'],
$_POST['pass1'], $_POST['pass2']);
}
if ($passwd == 'changed') {
echo '<div class="okmsg">Password Changed!</div>';
} elseif ($passwd == 'wrong') {
echo '<div class="errormsg">Incorrect Old Password</div>';
} elseif ($passwd == 'invalid') {
echo '<div class="errormsg">Invalid New Password</div>';
} elseif ($passwd == 'short') {
echo '<div class="errormsg">Password Must Be At Least 6 Characters</div>';
} elseif ($passwd == 'error') {
echo '<div class="errormsg">An Error Occurred While Changing Password</div>';
}
printPerson(getPerson($uid));
?>
<p class="pad-bottom"><a href="<?php echo URL ?>/edit-account.php">Edit your information</a></p>
<script type="text/javascript">
//<![CDATA[
function validate(f) {
if (f.oldpass.value == "") {
alert("You must enter your password.");
return false;
} elseif (f.pass1.value == "") {
alert("You must enter a new password.");
return false;
} elseif (f.pass2.value == "") {
alert("You must re-enter your new password.");
return false;
} elseif (f.pass1.value != f.pass2.value) {
alert("Passwords do not match.");
return false;
} elseif (f.pass1.length < 7) {
alert("Password must be at least 6 characters.");
return false;
}
return true;
}
//]]>
</script>
<form method="post" action="<?php echo SELF; ?>" onsubmit="return validate(this)" class="boxedform">
<table>
<tr>
<td>Current Password</td>
<td><input type="password" name="oldpass" value=""/></td>
</tr>
<tr>
<td>New Password</td>
<td><input type="password" name="pass1" value=""/></td>
</tr>
<tr>
<td>New Password, Again</td>
<td><input type="password" name="pass2" value=""/></td>
</tr>
<tr>
<td><input type="hidden" name="uid" value="<?php echo($uid); ?>" /></td>
<td><input type="submit" name="changepwd" value="Change Password" /></td>
</tr>
</table>
</form>
<?php
// End HTML
foot();