<?php

require 'includes/tm_gery_config.php';
require 'includes/GbxRemote.php';

$login = 'SuperAdmin';

function Error($errstr, $errline){
  if($errline != -1000){
 	 echo("Error: $errstr [$errline]\n\r");
  }
}

if($ip && $port && $login && $password){

	$islogedin = true;

	$client = new IXR_Client_Gbx;
	if (!$client->InitWithIp($ip, $port)) {
		Error($client->getErrorMessage(), $client->getErrorCode());
		$islogedin = false;
	}

	if (!$client->query("Authenticate", $login, $password)) {
		Error($client->getErrorMessage(), $client->getErrorCode());
		$islogedin = false;
	}	
}

if($islogedin){
	if(!@$client->query("StopServer")){
		Error($client->getErrorMessage(), $client->getErrorCode());
	}
	sleep (5);		
	if(!@$client->query("QuitGame")){
		Error($client->getErrorMessage(), $client->getErrorCode());
	}
}

$client->Terminate();

?>
