Mam stronę na której można dodać serwery popularnej gry counter strike, strona pokazuje ile graczy jest aktualnie na wszystkich serwerach i co chwile aktualizuję te dane. Chcę zrobić taki napis: Rekordowa ilość graczy online: xxxx. tylko nie wiem jak to zrobić.
Podam tutaj kod tej podstrony.
<?php include_once("config.php"); /////////////////////////////////////////////////////////////////////////////////////////////////// if($main['debug']) else include_once("inc/functions.php"); include_once("inc/class_PQ.php"); if(!class_exists("XTemplate")) include_once("inc/xtemplate.php"); /////////////////////////////////////////////////////////////////////////////////////////////////// // $id represents server id, depending on config.php, notice, id cannot be zero (it refers to all servers) //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// if($id) // show specific server { $id--; if(cache_read($cache,$main['cache'],$id) && ( (time() - $cache[$id]['hlss_update_time']) < $main['cache_outdate'])) { //cache read ok and no need for update $pqinfo = $cache[$id]; } else { $pq = PQ::create($server[$id]); $pqinfo = $pq->query(array('info','rules','players')); //this is the moment when we check server status } if(!@$pqinfo['ping']) $pqinfo['timeout'] = 1 ; else $pqinfo['timeout'] = 0 ; $server[$id]['id'] = $id+1; $server[$id]["name"] = htmlspecialchars($server[$id]["name"],ENT_QUOTES);// replace strange chars with html equivalents if(!@$server[$id]["offline_img"]) $server[$id]["offline_img"] = $main['offline_img']; if(!@$server[$id]["online_img"]) $server[$id]["online_img"] = $main['online_img']; if(!@$server[$id]['nicklength']) $server[$id]['nicklength'] = $main['nicklength']; { //default is template display mode, otherwise return image contents // image return mode works only for single server!!! load_template($tpl,$server[$id]['template']); $tpl->assign($server[$id]); $tpl->assign($pqinfo); } if($pqinfo['timeout']) { { {// if we got plr var then we want to return players number on server switch($_GET['plr']) { default: case "1": //image depend on player number $server[$id]["online_img_plr_off"] = @$main["online_img_plr_off"]; output_img($server[$id]["online_img_plr_off"]); break; case "2": //return image depend on percentage of server fill $server[$id]["online_img_plr_off%"] = @$main["online_img_plr_off%"]; output_img($server[$id]["online_img_plr_off%"]); break; } } else { output_img($server[$id]["offline_img"]); //automaticaly invoked php exit on } } else { $tpl->parse("MAIN.TIMEOUT"); } } else { // fix images, transport from $main to $server[$id] for ($i=0;$i<=32;$i++) //server maxplayers is 32, we run from 0 slot server to 32 (yea, a bit ugly) { $server[$id]["online_img_plr_".$i] = @$main["online_img_plr_".$i]; for ($j=0;$j<=$i;$j++) { if($i==0) break;//division by zero fix $server[$id]["online_img_plr_".$plr."%"] = @$main["online_img_plr_".$plr."%"]; } } $plr = ""; { { switch($_GET['plr']) { default: case "1": //image depend on player number $plr = $pqinfo['totalplayers']; output_img($server[$id]["online_img_plr_".$plr]); break; case "2": //return image depend on percentage of server fill, but output_img($server[$id]["online_img_plr_".$plr."%"]); break; } } else { output_img($server[$id]["online_img"]);//automaticaly invoked php exit on } } else { //////////////////////////////////////////////////////////////////////////// $jj=0; //////////////////////////////////////////////////////////////////////////// } } if($main['showall']) else $tpl->assign($main); $tpl->parse("MAIN"); $tpl->out("MAIN"); $cache[$id] = $pqinfo; } //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// // show all servers else { load_template($tpl,$main['template']); $totalPlayers = 0; $maxPlayers = 0; foreach ($server as $skey =>$sval){ if($sval['disable']) continue;//server disabled, do not display it in list mode if(cache_read($cache,$main['cache'],$skey) && ( (time() - $cache[$skey]['hlss_update_time']) < $main['cache_outdate'])) { //cache read ok and no need for update $pqinfo = $cache[$skey]; } else { $pq = PQ::create($server[$skey]); $pqinfo = $pq->query(array('info','rules','players')); //this is the moment when we check server status // notice that udate_time is set only everytime server query is performed, even if server is not responding } if(!@$pqinfo['ping']) $pqinfo['timeout'] = 1 ; else $pqinfo['timeout'] = 0 ; $sval['id'] = $skey+1; if(!@$sval['nicklength']) $sval['nicklength'] = $main['nicklength']; $totalPlayers += $pqinfo['totalplayers']; $maxPlayers += $pqinfo['maxplayers']; $wolnych = ($maxPlayers - $totalPlayers); $tpl->assign($sval); $tpl->assign($pqinfo); if($pqinfo['timeout']) { $tpl->parse("MAIN.TIMEOUT"); } else { //////////////////////////////////////////////////////////////////////////// $jj=0; foreach($pqinfo['players'] as $plr) { $player['player_shortname'] = htmlspecialchars(substr($player['player_name'],0,$sval['nicklength']-3)."...",ENT_QUOTES); $player['player_id'] = $plr['id']; $player['player_kills'] = $plr['kills']; $player['player_time'] = $plr['onlinetime']; //seconds $player['j']=$jj; $player['i']=($jj++%2); $tpl->assign($player); $tpl->parse("MAIN.STATUS.PLAYERS.PLAYER"); } $tpl->parse("MAIN.STATUS.PLAYERS"); $tpl->parse("MAIN.STATUS"); //////////////////////////////////////////////////////////////////////////// } $cache[$skey] = $pqinfo; } if($main['showall']) else $tpl->assign( 'graczy', $totalPlayers ); $tpl->assign( 'wolnych', $wolnych ); $tpl->assign($main); $tpl->parse("MAIN"); $tpl->out("MAIN"); } //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// cache_write($cache,$main['cache']); //ob_flush(); ?>