<?php

try{
	include("inc/config.php");
	include("inc/database.class.php");
if (!session_id()){
	session_start();
	$_SESSION['user'];
	$_SESSION['id'];
}
// Prevent anyone from illegally accessing this.
if (!isset($_SESSION["user"]) && !(isset($_GET["sas"]) && isset($_GET["pid"]) && isset($_GET["sid"]))) exit;
if (!isset($_SESSION["user"]) && (!is_numeric($_GET["pid"]) || !is_numeric($_GET["sid"]))) exit;

$db = new database;
if (!isset($_SESSION["user"])){
	$id = mysql_fetch_object(mysql_query('SELECT account_id FROM '.$db->gamedb["player"].'.player WHERE id="'.(int)$_GET["pid"].'"',$db->game));
	if (!$id) exit;
	$id = $id->account_id;
	if ($_GET["sas"] = md5($_GET["pid"].$id."GF9001")){
		$res = mysql_fetch_object(mysql_query('SELECT login FROM '.$db->gamedb["account"].'.account WHERE id="'.$id.'"',$db->game));
		$_SESSION["user"] = $res->login;
		$_SESSION["id"] = $id;
	}else exit;
}

}
catch(Exception $e){
	new error($e->__toString());
}
catch(ErrorException $e){
	new error($e->__toString());
}
if ( $id_session ) {

} else {

echo "<meta http-equiv='refresh' content='1; URL=index.php'>";

}
?>
