mirror of
https://git.code.sf.net/p/quake/website
synced 2024-11-27 06:22:31 +00:00
Add a password-change page for members.
This commit is contained in:
parent
bc27b04492
commit
d2579a0001
2 changed files with 71 additions and 0 deletions
70
chpass.php
Normal file
70
chpass.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<? // Preamble
|
||||
$pageName = "Change Password";
|
||||
$need = 'auth';
|
||||
|
||||
require "parts/preamble.php"; // Load most of document
|
||||
|
||||
$test = $_POST['test'];
|
||||
$oldpass = addSlashes ($_POST['oldpass']);
|
||||
$newpass = addSlashes ($_POST['newpass']);
|
||||
$confirm = addSlashes ($_POST['confirm']);
|
||||
|
||||
$user = $userInfo['u_username'];
|
||||
|
||||
need ('sql');
|
||||
|
||||
function chkpass ($pass, $copy) {
|
||||
global $passwdError;
|
||||
$ret = false;
|
||||
$passwdError = null;
|
||||
|
||||
if ($pass && $copy && $pass == $copy && strlen ($pass) > 5) {
|
||||
$ret = true;
|
||||
} else {
|
||||
if (!$pass) {
|
||||
$passwdError = "No password given!";
|
||||
} elseif ((!$copy) || ($pass != $copy)) {
|
||||
$passwdError = "Passwords don't match!";
|
||||
} elseif (strlen ($pass) <= 5) {
|
||||
$passwdError = "Password too short.";
|
||||
} else {
|
||||
$passwdError = "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if ($test) {
|
||||
if (chkpass ($newpass, $confirm)) {
|
||||
$query = "UPDATE members SET u_password=ENCRYPT('$newpass', '$user')"
|
||||
." WHERE u_username='$user'"
|
||||
." AND u_password=ENCRYPT('$oldpass', '$user')";
|
||||
|
||||
$result = sqlWriteQuery ($query);
|
||||
if ($result === null) {
|
||||
echo "<P>Sorry, couldn't talk to the database. Nothing changed.</P>";
|
||||
} elseif ($result === false) {
|
||||
echo "<P>Something went wrong, MySQL said '$sqlError'.</P>";
|
||||
} elseif ($result == 0) {
|
||||
echo "<P>Your old password was entered incorrectly, or was the same as the old one.</P>";
|
||||
} elseif ($result == 1) {
|
||||
echo "<P>Your password has been changed.</P>";
|
||||
} else {
|
||||
echo "<P>Uh oh, SERIOUSLY bad mojo. Find Deek ASAP!</P>";
|
||||
}
|
||||
} else {
|
||||
echo $passwdError;
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<FORM action="<? thisURL ?>" method="post">
|
||||
<P>Old Password: <INPUT name="oldpass" size="12" type="password" value="<?=$oldpass?>"></P>
|
||||
<P>New Password: <INPUT name="newpass" size="12" type="password" value="<?=$newpass?>"></P>
|
||||
<P>Confirm: <INPUT name="confirm" size="12" type="password" value="<?=$confirm?>"></P>
|
||||
<INPUT name="test" type="hidden" value="1">
|
||||
<INPUT type="submit" name="Change Password" value="Change Password">
|
||||
</FORM>
|
||||
<?
|
||||
}
|
||||
?>
|
|
@ -5,6 +5,7 @@
|
|||
?>
|
||||
<P>News: [ <A href="news_add.php">Post</A> ]</P>
|
||||
<P>Plan: [ <A href="plan_add.php">Post</A> ]</P>
|
||||
<P>Password: [ <A href="chpass.php">Change</A> ]</P>
|
||||
<?
|
||||
featureClose ();
|
||||
|
||||
|
|
Loading…
Reference in a new issue