Exemplo n.º 1
0
 function QueryServer($server)
 {
     $benchmark = new Benchmark();
     $benchmark->StartTimer("lgsl");
     $result = lgsl_query_live($server->protocol, $server->address, $server->cport, $server->qport, $server->sport, "sep");
     $benchmark->EndTimer("lgsl");
     $queryinfo = $result["b"];
     $serverinfo = $result["s"];
     $servervars = $result["e"];
     $players = $result["p"];
     /*foreach($result as $k => $v)
     	 {
     		echo "<br/><br/>$k<br/>";
     		var_dump($v);
     		}*/
     //If the server is online then copy the data over.
     if ($queryinfo["status"] == 1) {
         $server->ping = $benchmark->GetBenchmarkMilliSeconds("lgsl");
         $server->hostname = $serverinfo["name"];
         $server->game = $serverinfo["game"];
         $server->map = $serverinfo["map"];
         $server->maxplayers = $serverinfo["playersmax"];
         $server->password = $serverinfo["password"];
         if (isset($servervars["dedicated"])) {
             $server->dedicated = streq($servervars["dedicated"], "d");
         } else {
             $server->dedicated = 1;
         }
         if (isset($servervars["description"])) {
             $server->gamename = $servervars["description"];
         } else {
             $server->gamename = $server->game;
         }
         $server->setServerVars($servervars);
         $playerlist = array();
         foreach ($players as $k => $v) {
             $player = new Lan_servers_player();
             $player->name = $v["name"];
             if (isset($v["score"])) {
                 $player->score = $v["score"];
             } else {
                 if (isset($v["frags"])) {
                     $player->score = $v["frags"];
                 } else {
                     if (isset($v["rank"])) {
                         $player->score = $v["rank"];
                     } else {
                         $player->Score = "0";
                     }
                 }
             }
             if (isset($v["time"])) {
                 $player->time = $v["time"];
             } else {
                 $player->time = "";
             }
             $playerlist[] = $player;
         }
         $server->setPlayers($playerlist);
         $server->playercount = count($playerlist);
     } else {
         $server->ping = "-1";
         $playerlist = array();
         $server->setPlayers($playerlist);
         $server->maxplayers = "";
         $server->playercount = "";
     }
     return $server;
 }
Exemplo n.º 2
0
<?php

//Load System functions
require_once 'util.php';
require_once 'integration/integration.php';
$benchmark = new Benchmark();
$benchmark->StartTimer("gen");
//Load system config
require_once 'config.php';
//require_once ('integration/integration.php');
//Load template libary
require_once 'libs/smarty/Smarty.class.php';
//Load Data objects
LoadDataObjects();
//Load Master
$master = new Master();
// Check LAN ID
if (getCurrentLID() == "0" || isset($_GET["lanid"])) {
    if (isset($_GET["lanid"])) {
        $lan = new Lan_events();
        $lan->id = $lan->escape($_GET["lanid"]);
        $lan->find();
        if (!$lan->fetch()) {
            die("Unknown LAN :-O");
        }
        $_SESSION["lanmode"] = $lan->mode_id;
        setCurrentLID($_GET["lanid"]);
        $master->Smarty->assign("lan", $lan);
    } else {
        die("Unknown LAN :-(");
    }