<?php
/*
copyright: copyright 2004 Php Image Host. All Rights Reserved. You may modify this file for use on your
					site running a licenced copy of the Php Image Host scripts.
					You must not distribute this file or derivations of it.
Nullified By CrAcKlOvE
*/

error_reporting(E_ALL);
session_start();

require_once(dirname(__FILE__).'/../../includes/db.inc.php');
require_once(dirname(__FILE__).'/../../classes/ace.class.php');
$ace =& new ace($conn);
$config = $ace->loadsettings();
if( $config == 0 || $config->installed == 0 ){
	header('Location: ../install/index.php');
	exit();
}

$adminloggedin = false;
$username = '';

if( $ace->getstr('login', $_POST) != '' ){
	$username = $ace->getstr('username', $_POST);
	$password = $ace->getstr('password', $_POST);
	if( strcmp($username, $config->admin_username) == 0 && strcmp($password, $config->admin_password) == 0){
		$_SESSION['admin_loggedin'] = true;
	}
}elseif( $ace->getstr('logout', $_REQUEST) != '' ){
	unset($_SESSION['admin_loggedin']);
}

if( isset($_SESSION['admin_loggedin']) ) $adminloggedin = $_SESSION['admin_loggedin'];

if( !$adminloggedin ){
?>
<html>
<head>
<title>Php Image Host Admin</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body onLoad="document.forms['loginform'].username.focus();">
<form name="loginform" action="index.php" method="post">
<table class="formtable" align="center" cellspacing="1" cellpadding="0" border="0">
<tr>
	<td colspan="2" class="formheading">Login</td>
</tr>
<tr>
<td class="formlabel">Username:</td>
<td class="formfield">
<input type="text" name="username" value="<?php echo htmlspecialchars($username);?>" />
</td>
</tr>
<tr>
<td class="formlabel">Password:</td>
<td class="formfield"><input type="password" name="password" /></td>
</tr>
<tr>
<td class="formlabel">&nbsp;</td>
<td class="formfield"><input type="submit" name="login" value="Login" /></td>
</tr>
</table>
</form>
</body>
</html>
<?php
	exit();
}

?>
