Fixed Client 11 loginWebService. Tested on OTX 3.9 TFS 1.3 flavor for client 11. (Otxserver-new Global) on github.

This commit is contained in:
Znote 2017-06-21 19:07:51 +02:00
parent ef4a8f9e73
commit 30c789855f

View File

@ -26,7 +26,7 @@ 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;
$fields = '`id`, `premdays`'; $fields = '`id`, `premdays`, `secret`';
if ($config['twoFactorAuthenticator']) $fields .= ', `secret`'; 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;");
@ -45,13 +45,16 @@ 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`, `sex` FROM `players` WHERE `account_id`='".$account['id']."';");
if ($players !== false) { if ($players !== false) {
$gameserver = $config['gameserver']; $gameserver = $config['gameserver'];
// todo: Fix dynamic desition to pass along token. (and verify that it works). Hostname: otx11.lan
$sessionKey = $username."\n".$jsonObject->password;
if (strlen($account['secret']) > 5) $sessionKey .= "\n".$token."\n".floor(time() / 30);
$response = array( $response = array(
'session' => array( 'session' => array(
'sessionkey' => $username."\n".$jsonObject->password."\n".$token."\n".floor(time() / 30), 'sessionkey' => $sessionKey,
'lastlogintime' => 0, 'lastlogintime' => 0,
'ispremium' => ($account['premdays'] > 0) ? true : false, 'ispremium' => ($account['premdays'] > 0) ? true : false,
'premiumuntil' => time() + ($account['premdays'] * 86400), 'premiumuntil' => time() + ($account['premdays'] * 86400),
@ -64,17 +67,25 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['TFSVersion'] === 'TF
'name' => $gameserver['name'], 'name' => $gameserver['name'],
'externaladdress' => $gameserver['ip'], 'externaladdress' => $gameserver['ip'],
'externalport' => $gameserver['port'], 'externalport' => $gameserver['port'],
'previewstate' => 0 'previewstate' => 0,
'location' => 'ALL',
'externaladdressunprotected' => $gameserver['ip'],
'externaladdressprotected' => $gameserver['ip']
) )
), ),
'characters' => array( 'characters' => array(
//array( 'worldid' => ASD, 'name' => asd ), //array( 'worldid' => ASD, 'name' => asd, 'ismale' => true, 'tutorial' => false ),
) )
) )
); );
foreach ($players as $player) { foreach ($players as $player) {
$response['playdata']['characters'][] = array('worldid' => 0, 'name' => $player['name']); $response['playdata']['characters'][] = array(
'worldid' => 0,
'name' => $player['name'],
'ismale' => ($player['sex'] === 1) ? true : false,
'tutorial' => false
);
} }
//error_log("= SESSION KEY: " . $response['session']['sessionkey']); //error_log("= SESSION KEY: " . $response['session']['sessionkey']);