Client 11 loginWebService:

Display remaining time of premium account.
 External game server support.

config adjustments:
gameserver info (ip, port, name) for loginWebService.
Some cleanup.
This commit is contained in:
Znote 2016-11-23 20:42:29 +01:00
parent 6617966cc9
commit 9173619e77
3 changed files with 166 additions and 160 deletions

File diff suppressed because one or more lines are too long

View File

@ -26,24 +26,21 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['TFSVersion'] === 'TF
$password = SHA1($jsonObject->password); $password = SHA1($jsonObject->password);
$token = (isset($jsonObject->token)) ? sanitize($jsonObject->token) : false; $token = (isset($jsonObject->token)) ? sanitize($jsonObject->token) : false;
$twofa = ($config['twoFactorAuthenticator'] === true) ? true : false; $fields = '`id`, `premdays`';
$fields = ($twofa) ? '`id`, `secret`' : '`id`'; if ($config['twoFactorAuthenticator']) $fields .= ', `secret`';
$account = mysql_select_single("SELECT {$fields} FROM `accounts` WHERE `name`='{$username}' AND `password`='{$password}' LIMIT 1;"); $account = mysql_select_single("SELECT {$fields} FROM `accounts` WHERE `name`='{$username}' AND `password`='{$password}' LIMIT 1;");
if ($account === false) { if ($account === false) {
jsonError('Wrong username and/or password.'); jsonError('Wrong username and/or password.');
} }
if ($twofa) { if ($config['twoFactorAuthenticator'] === true && $account['secret'] !== null) {
if ($account['secret'] !== null) { if ($token === false) {
if ($token === false) { jsonError('Submit a valid two-factor authentication token.', 6);
jsonError('Submit a valid two-factor authentication token.', 6); } else {
} else { require_once("engine/function/rfc6238.php");
require_once("engine/function/rfc6238.php"); if (TokenAuth6238::verify($account['secret'], $token) !== true) {
if (TokenAuth6238::verify($account['secret'], $token) !== true) { jsonError('Two-factor authentication failed, token is wrong.', 6);
jsonError('Two-factor authentication failed, token is wrong.', 6);
} else {
}
} }
} }
} }
@ -51,21 +48,22 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['TFSVersion'] === 'TF
$players = mysql_select_multi("SELECT `name` FROM `players` WHERE `account_id`='".$account['id']."';"); $players = mysql_select_multi("SELECT `name` FROM `players` WHERE `account_id`='".$account['id']."';");
if ($players !== false) { if ($players !== false) {
$gameserver = $config['gameserver'];
$response = array( $response = array(
'session' => array( 'session' => array(
'sessionkey' => $username."\n".$jsonObject->password."\n".$token."\n".floor(time() / 30), 'sessionkey' => $username."\n".$jsonObject->password."\n".$token."\n".floor(time() / 30),
'lastlogintime' => 0, 'lastlogintime' => 0,
'ispremium' => false, // ($Premdays > 0 || $freePremium ? "true" : "false") 'ispremium' => ($account['premdays'] > 0) ? true : false,
'premiumuntil' => 0, // ($freePremium ? "0" : time() + ($Premdays * 86400)) 'premiumuntil' => time() + ($account['premdays'] * 86400),
'status' => 'active' 'status' => 'active'
), ),
'playdata' => array( 'playdata' => array(
'worlds' => array( 'worlds' => array(
array( array(
'id' => 1, 'id' => 1,
'name' => 'OTserv', 'name' => $gameserver['name'],
'externaladdress' => $_SERVER["SERVER_ADDR"], 'externaladdress' => $gameserver['ip'],
'externalport' => 7172, 'externalport' => $gameserver['port'],
'previewstate' => 0 'previewstate' => 0
) )
), ),

View File

@ -25,7 +25,6 @@ if ($config['TFSVersion'] !== 'TFS_10') {
mysql_update("UPDATE `znote_accounts` SET `secret`= '$scrtString' WHERE `account_id`='$session_user_id';"); mysql_update("UPDATE `znote_accounts` SET `secret`= '$scrtString' WHERE `account_id`='$session_user_id';");
$query['znote_secret'] = $scrtString; $query['znote_secret'] = $scrtString;
} }
// HTML rendering // HTML rendering
?> ?>
<h1>Two-Factor Authentication</h1> <h1>Two-Factor Authentication</h1>