<?php
define('X_SCRIPT', 'updatepw.php');
require 'header.php';
if (!X_MEMBER) {
header('HTTP/1.0 403 Forbidden');
loadtemplates('misc_feature_notavailable');
eval('$css = "'.template('css').'";');
nav('Update Password');
eval('$header = "'.template('header').'";');
eval('$featureoff = "'.template('misc_feature_notavailable').'";');
end_time();
eval('$footer = "'.template('footer').'";');
echo $header;
echo "<style>".$css."</style>";
echo $featureoff, $footer;
exit();
}
if (X_MEMBER) {
$query = $db->query("SELECT COUNT(*) FROM ".X_PREFIX."members WHERE username='$xmbuser' AND LENGTH(password) > '33'");
$result = $db->result($query, 0);
$db->free_result($query);
if($result > 0)
{
header('HTTP/1.0 403 Forbidden');
loadtemplates('misc_feature_notavailable');
//eval('$css = "'.template('css').'";');
nav('Update Password');
eval('$header = "'.template('header').'";');
eval('$featureoff = "'.template('misc_feature_notavailable').'";');
end_time();
eval('$footer = "'.template('footer').'";');
echo $header;
echo "<style>".$css."</style>";
echo $featureoff, $footer;
exit();
}
}
nav('One-Time Password Update');
eval('$header = "'.template('header').'";');
eval('$css = "'.template('css').'";');
end_time();
eval('$footer = "'.template('footer').'";');
echo $header;
echo "<style>".$css."</style>";
if(isset($_POST['updatepw']) && isset($_POST['updatepwcf']))
{
//Form submitted
if($_POST['updatepw'] != $_POST['updatepwcf'])
{
echo "<center><font class='mediumtxt'><b>The passwords you typed do not match!</b></font></center><br>";
echo "<center><form method='post' action='updatepw.php?runonce=true'>";
echo "<font class='smalltxt'>Enter new password: <input type='password' name='updatepw'> Enter again to confirm: <input type='password' name='updatepwcf'></font>";
echo " <input type='submit' name='updatebtn' value='Update'></form></center>";
}elseif(strlen($_POST['updatepw']) < 7 || strlen($_POST['updatepwcf']) < 7){
echo "<center><font class='mediumtxt'><b>The password you selected is too short! Longer passwords are more secure. Enter at least 7 characters.</b></font></center><br>";
echo "<center><form method='post' action='updatepw.php?runonce=true'>";
echo "<font class='smalltxt'>Enter new password: <input type='password' name='updatepw'> Enter again to confirm: <input type='password' name='updatepwcf'></font>";
echo " <input type='submit' name='updatebtn' value='Update'></form></center>";
}else{
$betterpassword = hash("sha256", $_POST['updatepw'] . $self['regdate'] . $self['regip']);
$db->query("UPDATE ".X_PREFIX."members SET password='$betterpassword' WHERE username='$xmbuser' LIMIT 1");
echo "<center><font class='mediumtxt'><b>Your password has been updated! Please <a href='index.php'>return to the forum index</a> and login using your new password.</b></font></center><br>";
}
}else{
//Collect new PW combo from form
echo "<center><form method='post' action='updatepw.php?runonce=true'>";
echo "<font class='smalltxt'>Enter new password: <input type='password' name='updatepw'> Enter again to confirm: <input type='password' name='updatepwcf'></font>";
echo " <input type='submit' name='updatebtn' value='Update'></form></center>";
}
echo $footer;
?>
|