setTimeoutgames(intval(ParseINI::parseValue('c4ms_timeoutgames', $config))); $server->setDeletegames(intval(ParseINI::parseValue('c4ms_deletegames', $config))); $server->setMaxgames(intval(ParseINI::parseValue('c4ms_maxgames', $config))); $protect = new FloodProtection($link, ParseINI::parseValue('mysql_prefix', $config)); $protect->setMaxflood(intval(ParseINI::parseValue('flood_maxrequests', $config))); if($protect->checkRequest($_SERVER['REMOTE_ADDR'])) { //flood protection $link = NULL; $db = NULL; } else { $server->cleanUp(); } } function GetGamesList() { if(!gotConnection()) return; $games = ''; $list = references(); $players = ''; foreach($list as $reference) { if($reference['valid']) { $games .= ''; $games .= ''.htmlspecialchars(ParseINI::parseValue('Title', $reference['data'])).''; $games .= ''.htmlspecialchars(ParseINI::parseValue('State', $reference['data'])).''; $games .= ''.date("Y-m-d H:i", $reference['start']).''; $players = ''; $player_list = ParseINI::parseValuesByCategory('Name', 'Player', $reference['data']); foreach($player_list as $player) { if(!empty($players)) $players .= ', '; $players .= $player; } $games .= ''.htmlspecialchars($players).''; } } $games = C4Network::cleanString($games); $result = ""; if(!empty($games)) { $result .= ''; $result .= ''; $result .= $games; $result .= '
RoundStateBeginPlayers
'; } else { $result .= '

No games are currently running.

'; } return $result; } function GetGamesCountText($time = 86400) { // default: last 24 hours if(!gotConnection()) return; $count = 0; $list = references(); foreach($list as $reference) { if((ParseINI::parseValue('State', $reference['data']) == 'Running') && $reference['time'] >= time() - $time) { $count++; } } $last = $time / 60 / 60; if($count > 0) { if($count > 1) { return $count.' games in the last '.$last.' hours.'; } else { return 'One game in the last '.$last.' hours.'; } } else { return 'No games running in the last '.$last.' hours.'; } } function GetServerLink() { $dirname = dirname($_SERVER['SCRIPT_NAME']); $path = ''; if($dirname != '/') { $path .= '/'; } $dirname .= $path.'server/'; $server_link = strtolower($_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$dirname); return $server_link; } function gotConnection() { global $link, $db; return $link && $db; } function references() { global $reflist, $server; if(!gotConnection()) return; if(!$reflist) $reflist = $server->getReferenceArray(true); return $reflist; } ?>