<?php
include("system/environment.php");
include("system/functions.php")
?>
<html>
<?php
include("system/head.php");
?>
<body>
<div class="logo"><img src="system/imgs/runsmall.png"></div>
<?php
if ($_POST['submit']) {
//first check that the password is not empty (null)
if ($_POST['NewPassword'] == '') {
$passEmpty = 1;
} else {
$passEmpty = 0;
}
//check that the two entered passwords are the same. if they aren't assign 1 to $passnomatch, if they are assign 0 to $passnomatch
if ($_POST['NewPassword'] != $_POST['RetypeNewPassword']) {
$passnomatch = 1;
} else {
$passnomatch = 0;
}
if ($passEmpty == 1 || $passnomatch == 1) {
//if the two passwords do not match, display the form below, with a warning that passwords do not match
?>
<div class="content">
<p class="header">Run Settings</p>
<table width="300px" border="0">
<tr>
<td colspan="2" class="left">Use the form below to change the password for the Run administrative account.</td>
</tr>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<tr>
<td class="right">Enter New Password:</td>
<td class="left"><input type="password" name="NewPassword" size="20" maxlength="40" class="form"></td>
</tr>
<tr>
<td class="right">Retype New Password:</td>
<td class="left"><input type="password" name="RetypeNewPassword" size="20" maxlength="40" class="form"></td>
<?php
if ($passEmpty == 1) {
echo "<tr><td colspan=\"2\"><span class=\"warning\">You must enter a password.</span></td></tr>";
} elseif ($passnomatch == 1) {
echo "<tr><td colspan=\"2\"><span class=\"warning\">Entered passwords don't match. Retype both passwords.</span></td></tr>";
}
?>
<tr>
<td></td>
<td class="left"><input type="submit" name="submit" value="Submit" accesskey="s" class="form"> <input type="submit" value="Wipe" accesskey="w" class="form"></td>
</tr>
</form>
<tr><td> </td></tr>
<?php
/*
<tr>
<td colspan="2" class="left">When you click the Backup button you will be asked where you want to save the backup copy of the Run database.</td>
</tr>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<tr>
<td class="right">Backup Run Data?</td>
<td class="left"><input type="submit" name="backup" value="Backup" accesskey="b" class="form"></td>
</tr>
</form>
*/
?>
<tr><td colspan="2" class="close"><a href="javascript:window.close();" title="Close This Window: Alt+C" accesskey="c" class="url><u>C</u>lose</a></td></tr>
</table>
</div>
<?php
} elseif ($passEmpty == 0 && $passnomatch == 0) {
//if password is entered and the two entered passwords are the same (i.e. match) encrypt the password using sha1 and update the database entry for admininistrator's passowrd
$password = sha1($_POST['NewPassword']);
$query = "update $mysqlTableRunners set Password='$password' where RunnerID='Administrator'";
$update = mysql_query($query);
//put the sha1 of the new password in the CookieRun, so that Administrator can remain logged in after password change has been made
setcookie("CookieRun", $password, time()+3600);
//after password has been updated and written into a cookie, display the following message that the change was successful and redisplay the settings.php page $_server['php_self']
echo "
<html>
<head>
<meta http-equiv=\"refresh\" content=\"3; url={$_SERVER['PHP_SELF']}\">
</head>
<body>
<div class=\"inputconfirm\">
You have successfully changed the password for the Run administrative account.
</div>
</body>
</html>
";
}
/*
} elseif ($_POST['backup']) {
system('mysqldump RunLab > test.sql');
*/
} else {
//however, if the file was just opened, display this empty form
?>
<div class="content">
<p class="header">Run Settings</p>
<table width="300px" border="0">
<tr>
<td colspan="2" class="left">Use the form below to change the password for the Run administrative account.</td>
</tr>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<tr>
<td class="right">Enter New Password:</td>
<td class="left"><input type="password" name="NewPassword" size="20" maxlength="40" class="form"></td>
</tr>
<tr>
<td class="right">Retype New Password:</td>
<td class="left"><input type="password" name="RetypeNewPassword" size="20" maxlength="40" class="form"></td>
<tr>
<td></td>
<td class="left"><input type="submit" name="submit" value="Submit" accesskey="s" class="form"> <input type="submit" value="Wipe" accesskey="w" class="form"></td>
</tr>
</form>
<tr><td> </td></tr>
<?php
/*
<tr>
<td colspan="2" class="left">When you click the Backup button you will be asked where you want to save the backup copy of the Run database.</td>
</tr>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<tr>
<td class="right">Backup Run Data?</td>
<td class="left"><input type="submit" name="backup" value="Backup" accesskey="b" class="form"></td>
</tr>
</form>
*/
?>
<tr><td colspan="2" class="close"><a href="javascript:window.close();" title="Close This Window: Alt+C" accesskey="c" class="url><u>C</u>lose</a></td></tr>
</table>
<?php
}
?>
</div>
</body>
</html>