<?php
@session_start();
$msg = '';
if (isset($_POST['password'])) {
	$query = yasDB_select("select password from settings where id = '1'",false);
	$pass_result = $query->fetch_array(MYSQLI_NUM);
	$query->close();
	$password = $pass_result[0];
	
	if($password == md5($_POST['password'])) {
		$_SESSION['admin'] = "logged";
		header("Location:index.php");
		exit();
	} else {
		header("Location:index.php?act=login&error=wrongpassword");
		exit();
	}
}
if(isset($_GET['error']) && $_GET['error'] == "wrongpassword") {
	echo '<script type="text/javascript">alert("Wrong password, sorry.");</script>';
	$msg = "<center>Wrong password, sorry.</center>";
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" type="text/css" href="css/loginstyle.css" media="screen" title="Style" />
</head>	
</body>
<html>
<div align="center">
<div id="admincontent"><br/>
<noscript>
<div id="message"><?php echo $msg; ?></div>
</noscript>
<h3>Please login to access the admin area.</h3><br />
<form name="login" method="post" action="index.php?act=login">
Admin Password:<br />
<input type="password" name="password"/><br /><br/>
<input type="submit" name="login" value="Login" /><br/><br/>
</form>
</div></div>
</body>
</html>