public function post(Request $request, Application $app)
 {
     $sourceQuery = new \SourceQuery();
     try {
         $ip = $request->get('serverIp');
         $port = $request->get('port');
         $appId = $request->get('appid');
         $sourceQuery->Connect($ip, $port, 1, $appId);
         $result = array('success' => true, 'data' => array('info' => $sourceQuery->GetInfo(), 'players' => $sourceQuery->GetPlayers()));
         $result['success'] = is_array($result['data']['info']) && is_array($result['data']['players']);
         return new JsonResponse($result);
     } catch (\Exception $e) {
         return new JsonResponse(array('success' => FALSE, 'message' => $e->getMessage()));
     }
     $sourceQuery->Disconnect();
 }
Пример #2
0
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 {
			margin-top: 30px;
			border-radius: 0;
		}
		
Пример #3
0
// Print Output
foreach ($SelectServers as $PrintServers) {
    // Query Server
    define('SQ_TIMEOUT', 1);
    define('SQ_ENGINE', SourceQuery::SOURCE);
    $ServerQuery = new SourceQuery();
    $ServerInfo = array();
    $ServerPlayers = array();
    try {
        $ServerQuery->Connect($PrintServers['IPAddress'], $PrintServers['Port'], SQ_TIMEOUT, SQ_ENGINE);
        $ServerInfo = $ServerQuery->GetInfo();
        $ServerPlayers = $ServerQuery->GetPlayers();
    } catch (Exception $e) {
        echo "Something went wrong try again later!";
    }
    $ServerQuery->Disconnect();
    echo "\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td><b>" . $PrintServers['ServerID'] . "</b></td>\n\t\t\t\t\t\t\t\t<td><a href='steam://connect/" . $PrintServers['IPAddress'] . ":" . $PrintServers['Port'] . "'>" . $PrintServers['IPAddress'] . ":" . $PrintServers['Port'] . "</a></td>\n\t\t\t\t\t\t\t\t<td>" . $PrintServers['HostName'] . "</td>\n\t\t\t\t\t\t\t\t<td>" . htmlspecialchars($ServerInfo['ModDesc']) . "</td>\n\t\t\t\t\t\t\t\t<td>" . htmlspecialchars($ServerInfo['Map']) . "</td>\n\t\t\t\t\t\t\t\t<td>" . htmlspecialchars($ServerInfo['Players']) . " / " . htmlspecialchars($ServerInfo['MaxPlayers']) . "</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t";
}
?>
            </tbody>
        </table>
        </div>
        <!-- ./Servers -->
    
        <!-- Bans -->
        <div class="panel panel-<?php 
echo $PColor;
?>
">
		<div class="panel-heading"><b><?php 
echo $T_BanList;