Skip to content

Commit

Permalink
Implement updateuserstats action
Browse files Browse the repository at this point in the history
  • Loading branch information
cathyjf committed Feb 23, 2013
1 parent 36836fc commit ba75dce
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,27 @@ function getServerHostName($serverid) {
$serverhostname = htmlspecialchars($serverhostname); // Protect against theoretical IE6 XSS
die($users->getAssertion($userid, $serverhostname, null, $challengekeyid, $challenge));
break;
case 'updateuserstats':
$serverid = @$reqData['serverid'];
$server = @$PokemonServers[$serverid];

if (!$server ||
($users->getIp() !== gethostbyname($server['server'])) ||
(!empty($server['token']) && ($server['token'] !== md5($reqData['servertoken'])))) {
$out = 0;
break;
}

$date = @$reqData['date'];
$usercount = @$reqData['users'];
if (!is_numeric($date) || !is_numeric($usercount)) break;

$out = !!$db->query("INSERT INTO `ntbb_userstats` (`serverid`, `date`, `usercount`) VALUES ('" . $db->escape($serverid) . "', '" . $db->escape($date) . "', '" . $db->escape($usercount) . "')'");

if ($serverid !== 'showdown') {
$db->query("DELETE FROM `ntbb_userstats` WHERE `serverid` = '" . $db->escape($serverid) . "' AND id < " . $db->insert_id());
}
break;
case 'ladderupdate':
include_once 'lib/ntbb-ladder.lib.php';

Expand Down

0 comments on commit ba75dce

Please sign in to comment.