/**
 *	@author João Reis
 *	@return array
 */
function _getStatus()
{
    global $_ip, $_portaQuery, $_objQuery;
    // Objeto para Query's
    $_objQuery = new SourceQuery();
    try {
        // Conectar-se ao servidor
        $_objQuery->Connect($_ip, $_portaQuery, 1, SourceQuery::GOLDSOURCE);
        #print_r($_objQuery);
        $Info = array();
        $Jogadores = array();
        $Regras = array();
        // Retornar Plugins neste caso sao Regras
        $_Regras = $_objQuery->GetRules();
        // Retornar lista de Jogadores
        $Jogadores = $_objQuery->GetPlayers();
        // Retornar Informação do servidor.
        $Info = $_objQuery->GetInfo();
        $_MapaAtual = $Info['Map'];
        $_SlotsUsados = $Info['Players'];
        $_MaxSlots = $Info['MaxPlayers'];
        $_Versao = $Info['Version'];
        // Passar lista de jogadores recebida em algo Global para que o painel perceba.
        $JogadoresJ = array();
        if (count($Jogadores) > 0 && $Info != null) {
            foreach ($Jogadores as $Jogador) {
                $JogadoresJ[] = utf8_encode($Jogador["Name"]);
            }
        }
        $_Jogadores = $JogadoresJ;
        $_Plugins = $Regras;
    } catch (Exception $e) {
        $_MapaAtual = ".....";
        $_SlotsUsados = ".....";
        $_MaxSlots = ".....";
        $_Versao = "1.0.0";
    }
    return array("Map" => $_MapaAtual, "Players" => $_SlotsUsados, "MaxPlayers" => $_MaxSlots, "Playerlist" => $_Jogadores, "Plugins" => $_Regras, "Versao" => $_Versao);
}
// Edit this ->
define('SQ_SERVER_ADDR', 'localhost');
define('SQ_SERVER_PORT', 27015);
define('SQ_TIMEOUT', 1);
define('SQ_ENGINE', SourceQuery::SOURCE);
// Edit this <-
$Timer = MicroTime(true);
$Query = new SourceQuery();
$Info = array();
$Rules = array();
$Players = array();
try {
    $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE);
    $Info = $Query->GetInfo();
    $Players = $Query->GetPlayers();
    $Rules = $Query->GetRules();
} catch (Exception $e) {
    $Exception = $e;
}
$Query->Disconnect();
$Timer = Number_Format(MicroTime(true) - $Timer, 4, '.', '');
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Source Query PHP Class</title>
	
	<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css">
	<style type="text/css">
		.jumbotron {
Exemple #3
0
<?php

require __DIR__ . '/SourceQuery/SourceQuery.class.php';
// For the sake of this example
Header('Content-Type: text/plain');
Header('X-Content-Type-Options: nosniff');
// Edit this ->
define('SQ_SERVER_ADDR', 'localhost');
define('SQ_SERVER_PORT', 27015);
define('SQ_TIMEOUT', 1);
define('SQ_ENGINE', SourceQuery::SOURCE);
// Edit this <-
$Query = new SourceQuery();
try {
    $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE);
    print_r($Query->GetInfo());
    print_r($Query->GetPlayers());
    print_r($Query->GetRules());
} catch (Exception $e) {
    echo $e->getMessage();
}
$Query->Disconnect();