<?
	require_once('user.php');
	require_once('mysql.php');
	require_once('fb.php');

	ob_start();
	session_start();

	$mysqldb1 = new mysql($host, $user, $pswd, $db); $mysqldb1->connect(); $mysqldb1->select();

	if ($_GET['logout']) {

		setcookie('user_id', '', 0, "/", "", 0);
		$goto = '<script language = "JavaScript">top.location = "http://'.$domain.'/control/index.html";</script>';
		print $goto;

	} else {

		$md5 = md5($_GET['username'].$_GET['password']);
        echo md5($owner_email.$_SERVER['HTTP_HOST']);
		if (strlen($_GET['md5']) == 32 and $_GET['md5'] == $md5) { // PREVENT HACKING BY SQL INJECTION (andreaginnproperties.co.za was hacked on 31 AUGUST 2009)
		$query = "SELECT * FROM user WHERE md5='".$md5."' AND status='enabled' LIMIT 1";
		}
		$mysqldb1->query($query);
		$user = $mysqldb1->fetchArray();
		
		if ($user['id'] != '') {
			//setcookie('user_id', $user['id'], time() + (60 * 60 * 24), "/", "", 0);
			if (md5($owner_email.$_SERVER['HTTP_HOST']) == $key) {
				setcookie('user_id', $user['id'], 0, "/", "", 0);
				//print '<a href="../index.php" target="_parent"><img src="../styles/default/proceed.png" border="0" alt="" /></a>';
				$goto = '<script language = "JavaScript">top.location = "http://'.$domain.'/control/";</script>';
				print $goto;
			} else {
				print '<strong>This Control Panel has been disabled!</strong>';
			}
		} else {
			print '<a href="javascript:login();"><img src="../styles/default/fail.png" border="0" alt="" /></a>';
		}

	}
?>
<?
	$mysqldb1->close();
?>