Location: PHPKode > projects > Fretsweb > fretsweb-1.2/fretsweb/admin/adminpasswd.php
<?php

/*
Fretsweb - A Frets on Fire chart server
Copyright (C) 2009, Daan Sprenkels

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


// Include the common file
require_once "common.php";

// Incluede log
require_once "log.php";


//Login Test
session_start();
if($_SESSION['in'] < 2)
{
	header('location: login.php?need=admin');
	die();
}



if(isset($_POST['changepasswd']))
{
	if($_POST['oldpassword'] == $admin_passwd)
	{
		if($_POST['newpassword'] == $_POST['confirmpassword'])
		{
			if(strlen($_POST['newpassword']) >= 4 )
			{
				$newpass = $_POST['newpassword'];
				$sql = "UPDATE `contest_config` SET `value` = '$newpass' WHERE `name` = 'admin_password';";
				mysql_query($sql);
				$info = 'Password succesfully changed.';
				clog('Password changed.');
			}
			else
				$info = 'New password must be 4 or more characters!';
				clog('Password change error: too short');
		}
		else
			$info = 'New passwords are not identical!';
			clog('Password change error: not identical');
	}
	else
		$info = 'Wrong old password!';
		clog('Password change error: wrong old password');
}
mysql_close();

?>
<html>
 <head>
  <title>Change Admin Password</title>
  <link href="../css.php" rel="stylesheet" type="text/css" />
  <link href="../images/favicon.png" rel="icon">
 </head>
 <body>
  <center>
    <h2>Change Admin Password</h2>
    <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
    <?php

if(isset($info))
{
	echo '<p class="info" align="center">'.$info.'</p>';
}

?>
    <p>Old password: <input type="password" name="oldpassword"></p>
    <p>New password: <input type="password" name="newpassword"></p>
    <p>Again: <input type="password" name="confirmpassword"></p>
    <p><input type="submit" name="changepasswd" value="Change password"></p>
   </form>
   <p><b><a href="index.php">Back to main administration panel</a></b><p>
  </center>
 </body>
</html>
Return current item: Fretsweb