<?php
@session_start();
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($_GET['error'] == "wrongpassword") {
	echo "<script>alert('Sorry, wrong password.');</script>";
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Admin</title>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
	<style media="all" type="text/css">@import "css/all.css";</style>
</head>
<body>
<div id="main">
	<div id="header">
		<a href="index.html" class="logo"><img src="img/logo.png" width="101" height="29" alt="" /></a>
		<ul id="top-navigation">
			<li<?php if ($_GET['act'] == 'general') echo ' class="active"';?>><span><span><a href="index.php?act=general" title="Home">Home</a></span></span></li>
			<li<?php if ($_GET['act'] == 'settings') echo ' class="active"';?>><span><span><a href="index.php?act=settings" title="Settings">Settings</a></span></span></li>
			<li<?php if ($_GET['act'] == 'categories') echo ' class="active"';?>><span><span><a href="index.php?act=categories" title="Categories">Categories</a></span></span></li>
			<li<?php if ($_GET['act'] == 'manage_users') echo ' class="active"';?>><span><span><a href="index.php?act=manage_users" title="Users">Users</a></span></span></li>
			<li<?php if ($_GET['act'] == 'news') echo ' class="active"';?>><span><span><a href="index.php?act=news" title="News">News</a></span></span></li>
			<li<?php if ($_GET['act'] == 'managegames') echo ' class="active"';?>><span><span><a href="index.php?act=managegames" title="Games">Games</a></span></span></li>
			<li<?php if ($_GET['act'] == 'links') echo ' class="active"';?>><span><span><a href="index.php?act=links" title="Links">Links</a></span></span></li>
			<li<?php if ($_GET['act'] == 'addlink') echo ' class="active"';?>><span><span><a href="index.php?act=addlink" title="Add Link">Add link</a></span></span></li>
			<li<?php if ($_GET['act'] == 'logout') echo ' class="active"';?>><span><span><a href="index.php?act=logout" title="Logout">Logout</a></span></span></li>
		</ul>
	</div>
	<div id="middle">
		<div id="left-column">
			<?php include ("left_column.php");?>
		</div>
		<div id="center-column">
<div class="top-bar">
<h1>Cpanel - Login</h1>
<div class="breadcrumbs"></div>
</div><br />
<div class="select-bar">
<label>
<h3>Login</h3>
</label>
</div>
<center>
<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></center>
</div>
<div id="right-column"><?php include ("right_column.php");?></div>
	</div>
	<div id="footer"></div>
</div>


</body>
</html>