Eliminate initial AJAX request to login server

Instead of making an AJAX request to action.php?act=upkeep, this
commit now includes the initial token directly in index.php.
This commit is contained in:
Cathy J. Fitzpatrick
2013-02-06 17:08:32 -07:00
parent 417d95c392
commit 0ccaf286ce
3 changed files with 12 additions and 11 deletions

View File

@@ -20,6 +20,7 @@ header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
$defaultserver = 'showdown';
include '../pokemonshowdown.com/config/servers.inc.php';
include '../pokemonshowdown.com/lib/ntbb-session.lib.php';
$server = @$_REQUEST['server'];
$serverport = 0;
@@ -77,6 +78,13 @@ $serverlibs = array(
);
$serverlibrary = $serverlibs[$serverprotocol];
$upkeep = array();
unset($curuser['userdata']);
$upkeep['curuser'] = $curuser;
if (empty($_COOKIE['showdown_username'])) $userid = $curuser['userid'];
else $userid = $users->userid($_COOKIE['showdown_username']);
$upkeep['assertion'] = $users->getAssertion($userid, $server);
?>
<!DOCTYPE html>
<html>
@@ -100,7 +108,8 @@ $serverlibrary = $serverlibs[$serverprotocol];
serverid: '<?php echo $serverid ?>',
serverport: <?php echo $serverport ?>,
serverprotocol: '<?php echo $serverprotocol ?>',
urlPrefix: '<?php if ($serverid && $serverid !== 'showdown') echo '~~',$serverid,'/'; ?>'
urlPrefix: '<?php if ($serverid && $serverid !== 'showdown') echo '~~',$serverid,'/'; ?>',
upkeep: <?php echo json_encode($upkeep) ?>
};
<?php if (false) { ?>
alert('We should be open to the public again in a few minutes.');

View File

@@ -3226,12 +3226,5 @@ if (!Config.down) {
};
}
}
if (Config.testclient) {
onConnect(Config);
} else {
$.post(actionphp, {
act: 'upkeep',
name: name
}, Tools.safeJson(onConnect), 'text');
}
onConnect(Config.upkeep);
}

View File

@@ -14,8 +14,7 @@
<script>
var text = prompt("Input config data");
if (text[0] === ']') text = text.substr(1);
var Config = JSON.parse(text);
Config.testclient = true;
var Config = { upkeep: JSON.parse(text) };
</script>
<!--[if lte IE 8]><script>
oldie = true;