forked from smillie/gas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword.php
More file actions
75 lines (70 loc) · 3.03 KB
/
password.php
File metadata and controls
75 lines (70 loc) · 3.03 KB
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
<?php require 'ldapconnect.php'; ?>
<?php
$pageTitle = " - Change Password";
if (isset($_POST['oldpw'])) {
if (ldap_bind($con, $userdn, $_POST['oldpw'])===true) {
if ($_POST['confirmpw'] == $_POST['newpw']) {
mt_srand((double)microtime()*1000000);
$salt = pack("CCCCCCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand());
$password = "{SSHA}" . base64_encode( sha1( $_POST['newpw'] . $salt, true) . $salt );
$entry=array();
$entry['userpassword']=$password;
$_SESSION['password']=$_POST['newpw'];
ldap_modify($con,$userdn,$entry);
$success = "Password updated successfully.";
} else {
$error = "<strong>Error:</strong> Passwords do not match.";
}
} else {
$error = "<strong>Error:</strong> Password incorrect.";
}
}
?>
<?php require 'header.php'; ?>
<?php require 'menu.php'; ?>
<div class="span10">
<div class="row">
<div class="span5">
<form id="form" class="form-horizontal" action="password.php" method="post">
<fieldset>
<legend>Change Password</legend>
<div class="control-group">
<?php if (isset($error)) : ?>
<div class="alert alert-error">
<?php echo "$error"; ?>
</div>
<?php elseif (isset($success)) : ?>
<div class="alert alert-success">
<?php echo "$success"; ?>
</div>
<?php endif; ?>
<label class="control-label" for="oldpw">Old Password</label>
<div class="controls">
<input type="password" class="input-xlarge required" name="oldpw" id="oldpw">
</div>
</div>
<div class="control-group">
<label class="control-label" for="newpw">New Password</label>
<div class="controls">
<input type="password" class="input-xlarge required" name="newpw" id="newpw" minlength="8">
</div>
</div>
<div class="control-group">
<label class="control-label" for="confirmpw">Confirm Password</label>
<div class="controls">
<input type="password" class="input-xlarge required" name="confirmpw" id="confirmpw">
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Update Password</button>
</div>
</fieldset>
</form>
</div><!--/span-->
<div class="span4 offset1">
<h3>Note</h3>
<p>This password will be used for all GeekSoc services. Please choose something secure.</code></p>
</div>
</div><!--/row-->
</div><!--/span-->
<?php require 'footer.php'; ?>