<?php
if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0") {
@error_reporting(0);
@ini_set('display_errors', 'Off');
header("Content-Type: application/json");
$loginInfo = json_decode(file_get_contents("php://input"));
$accountName = $loginInfo->{"accountname"};
$password = $loginInfo->{"password"};
if($accountName == "" || password == "") {
die('{"errorCode":3,"errorMessage":"Account name or password is incorrect."}');
}
$MySQL_Host = "127.0.0.1";
$MySQL_User = "root";
$MySQL_Password = "tested87";
$MySQL_DB = "test1100";
$SQL = new mysqli($MySQL_Host, $MySQL_User, $MySQL_Password, $MySQL_DB);
if(mysqli_connect_error()) {
die('{"errorCode":3,"errorMessage":"Internal error. Please try again later or contact customer support if the problem persists."}');
}
$AccountQuery = $SQL->query("SELECT * FROM `accounts` WHERE `name` = '".$SQL->real_escape_string($accountName)."' AND `password` = '".SHA1($SQL->real_escape_string($password))."'")->fetch_array(MYSQLI_ASSOC);
if($AccountQuery["name"] != $accountName) {
die('{"errorCode":3,"errorMessage":"Account name or password is incorrect."}');
}
$AccountID = $AccountQuery["id"];
$Secret = $AccountQuery["secret"];
$Premdays = $AccountQuery["premdays"];
$CharacterQuery = $SQL->query("SELECT `name` FROM `players` WHERE `account_id` = '".$AccountID."'")->fetch_all(MYSQLI_ASSOC);
$worldID = 0;
$worldName = "OTSERVERTEST Full Rl 10.94 - 11.0";
$serverAddress = $_SERVER["SERVER_ADDR"];
$serverPort = 7172;
$freePremium = false;
echo '{"session":{"sessionkey":"'.$accountName.'\n'.$password.'\n'.$secret.'\n'.(floor(time() / 30)).'","lastlogintime":0,"ispremium":'.($Premdays > 0 || $freePremium ? "true" : "false").',"premiumuntil":'.($freePremium ? "0" : time() + ($Premdays * 86400)).',"status":"active"},"playdata":{"worlds":[{"id":'.$worldID.',"name":"'.$worldName.'","externaladdress":"'.$serverAddress.'","externalport":'.$serverPort.',"previewstate":0}],"characters":[';
foreach($CharacterQuery as $Character) {
if($Character != $CharacterQuery[0]) {
echo ',';
}
echo '{"worldid":'.$worldID.',"name":"'.$Character["name"].'"}';
}
echo ']}}';
return;
}
?>
<?php
// comment to show E_NOTICE [undefinied variable etc.], comment if you want make script and see all errors
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE);
// true = show sent queries and SQL queries status/status code/error message
//define('DEBUG_DATABASE', true);
define('DEBUG_DATABASE', false);
define('INITIALIZED', true);
date_default_timezone_set('America/New_York');
// if not defined before, set 'false' to load all normal
if(!defined('ONLY_PAGE'))
define('ONLY_PAGE', false);
// check if site is disabled/requires installation
include_once('./system/load.loadCheck.php');
// fix user data, load config, enable class auto loader
include_once('./system/load.init.php');
// DATABASE
include_once('./system/load.database.php');
if(DEBUG_DATABASE)
Website::getDBHandle()->setPrintQueries(true);
// DATABASE END
// LOGIN
if(!ONLY_PAGE)
include_once('./system/load.login.php');
// LOGIN END
// COMPAT
// some parts in that file can be blocked because of ONLY_PAGE constant
include_once('./system/load.compat.php');
// COMPAT END
// LOAD PAGE
include_once('./system/load.page.php');
// LOAD PAGE END
// LAYOUT
// with ONLY_PAGE we return only page text, not layout
if(!ONLY_PAGE)
include_once('./system/load.layout.php');
else
echo $main_content;
// LAYOUT END