GameQ - PHP библиотека для мониторинга серверов

MFS

Участник
Сообщения
1,533
Реакции
787
GameQ это библиотека PHP5 для мониторинга одного или нескольких игровых серверов с использованием протокола UDP. Возвращает результаты в виде массива. Разработчик tombuskens@users.sourceforge.net.

Примеры на http://gameq.sourceforge.net/

Для мониторинга серверов Valve (counterstrike, left4dead, team fortress 2 ) нужно, чтобы на хостинге был установлен bzip2, т.к. протокол обмена изначально сжат.
См. http://php.net/bzip2.setup



example.php
<?php
error_reporting(E_ALL);


require_once 'GameQ.php';


// Define your servers,
// see list.php for all supported games and identifiers.
$servers = array(
'server 1' => array('quake3', '194.109.69.61'),
'server 2' => array('cssource', '194.109.69.51', 27015),
'server 3' => array('bf2142', '194.109.69.21'),
'server 4' => array('ts3', 'voice.planetteamspeak.com')
);


// Call the class, and add your servers.
$gq = new GameQ();
$gq->addServers($servers);


// You can optionally specify some settings
$gq->setOption('timeout', 200);


// You can optionally specify some output filters,
// these will be applied to the results obtained.
$gq->setFilter('normalise');
$gq->setFilter('sortplayers', 'gq_ping');

// Send requests, and parse the data
$results = $gq->requestData();






// Some functions to print the results
function print_results($results) {

foreach ($results as $id => $data) {

printf("<h2>%s</h2>\n", $id);
print_table($data);
}

}

function print_table($data) {

$gqs = array('gq_online', 'gq_address', 'gq_port', 'gq_prot', 'gq_type');


if (!$data['gq_online']) {
printf("<p>The server did not respond within the specified time.</p>\n");
return;
}

print("<table><thead><tr><td>Variable</td><td>Value</td></tr></thead><tbody>\n");

foreach ($data as $key => $val) {

if (is_array($val)) continue;

$cls = empty($cls) ? ' class="uneven"' : '';

if (substr($key, 0, 3) == 'gq_') {
$kcls = (in_array($key, $gqs)) ? 'always' : 'normalise';
$key = sprintf("<span class=\"key-%s\">%s</span>", $kcls, $key);
}

printf("<tr%s><td>%s</td><td>%s</td></tr>\n", $cls, $key, $val);
}

print("</tbody></table>\n");

}








?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>GameQ - Example script</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
* {
font-size: 9pt;
font-family: Verdana, sans-serif;
}
h1 {
font-size: 12pt;
}
h2 {
margin-top:2em;
font-size: 10pt;
}
table {
border: 1px solid #000;
background-color: #DDD;
border-spacing:1px 1px;
}
table thead {
font-weight: bold;
background-color: #CCC;
}
table tr.uneven td {
background-color:#FFF;
}
table td {
padding: 5px 8px;
}
table tbody {
background-color: #F9F9F9;
}
.note {
color: #333;
font-style:italic;
}
.key-always {
color:red;
font-weight:bold;
}
.key-normalise {
color:red;
}
</style>
</head>
<body>
<h1>GameQ - Example script</h1>
<div class="note">
Players are never displayed in this example. <br/>
<span class="key-always">Bold, red</span> variables are always set by gameq.
Additionally, the normal <span class="key-normalise">red</span> variables are always set when the normalise filter is enabled.<br/>
gq_online will always contain a boolean indicating if the server responded to the request.<br/>
<br/>
Click <a href="list.php">here</a> for a list of supported games.
</div>
<?php
print_results($results);
?>
</body>
</html>

Известные баги

Поддержка 170 игр.
(Поддерживает простые VoIP сервера Teamspeak 2 и Ventrilo)

Age of Empires II
Alien vs Predator 2
All-Seeing Eye Protocol
America's Army
America's Army 3
Alien Arena
Armed Assault
Assault Cube
Baldur's Gate
Battlefield 1942
Battlefield 2
Battlefield 2142
Battlefield Vietnam
Breed
Call of Duty
Call of Duty - United Offensive
Call of Duty 2
Call of Duty 3
Call of Duty 4
Call of Duty 5: World at War
Call of Juarez
Chaser
Chrome
Codename Eagle
Commandos 3: Destination Berlin
C&C: Renegade
Contract J.A.C.K
Cross Racing Championship
Counter-Strike 2d
Counter-Strike (old protocol)
Counter-Strike
Counter-Strike: Source
Cube Engine
Crysis
Crysis Wars
Daikatana
Day of Defeat
Day of Defeat: Source
Deadly Dozen: Pacific Theater
Descent 3
Deus Ex
Devastation
Dirt Track Racing II
Doom 3
Drakan: Order of the Flame
F1 2002
FarCry
Bla
FEAR
Frontline: Fuel of War
Freelancer
Gamespy Protocol
Gamespy 2 Protocol
Gamespy 3 Protocol
Giants: Citizen Kabuto
Global Operations
Gore
Ghost Recon
Ghost Recon: Advanced Warfighter
Ghost Recon: Advanced Warfighter 2
Half-Life
Half-Life 2
Halo: Combat Evolved
Halo 2
Heretic 2
Hexen 2
Hexen World
Old Halflife Protocol
Homeworld 2
IGI 2
IL-2 Sturmovik
Iron Storm
Natural Selection
James Bond: Nightfire
OpenTTD
Kingpin: Life of Crime
Killing Floor
KISS Psycho Circus
Left 4 Dead
Dark Messiah of Might and Magic
Medal of Honor: Allied Assault
Medal of Honor: Breakthrough
Medal of Honor: Pacific Assault
Medal of Honor: Spearhead
Multi Theft Auto
Multi Theft Auto: Vice City
Multi Theft Auto: San Andreas
Need For Speed: Hot Pursuit 2
Nerf Arena Blast
Neverwinter Nights
Neverwinter Nights 2
Nexuiz
Nitro Family
No One Lives Forever
No One Lives Forever 2
Operation Flashpoint
Painkiller
Postal 2
Purge Jihad
Prey
Quakeworld
Quake 2
Quake 3: Arena
Quake 4
Enemy Territory: Quake Wars
Rag Doll Kung Fu
Rainbow 6
Rainbow 6: Rogue Spear
RalliSport Challenge
Rally Masters
Redline
Red Faction
Red Orchestra: Ostfront 41-45
rFactor
Return to Castle Wolfenstein
Rise of Nations
Rune
San Andreas: Multiplayer
Savage: Battle for Newerth
Savage 2: A Tortured Soul
Sauerbraten Engine
Serious Sam
Serious Sam 2
The Ship
Shogo: Mobile Armor Division
SiN
SiN 1 Multiplayer
Soldat
Soldier of Fortune
Soldier of Fortune 2: Double Helix
Source Engine
S.T.A.L.K.E.R: Shadow of Chernobyl
Star Trek: Bridge Commander
Star Trek Voyager: Elite Forc
Star Trek Voyager: Elite Force 2
Star Wars: Battlefront
Star Wars: Battlefront 2
Star Wars Jedi Knight II: Jedi Outcast
Star Wars Jedi Knight: Jedi Academy
Sum of All Fears
SWAT 4
Tactical Operations
Team Factor
Teamspeak 2
Teeworlds
Terminus
Team Fortress 2
Tony Hawk's Pro Skater 3
Tony Hawk's Pro Skater 4
Tony Hawk Underground 2
Tremulous
Starsiege: Tribes
Tribes 2
Tribes: Vengeance
Tron 2.0
Turok 2
Universal Combat
Unreal
Unreal 2 Engine
Unreal 2 XMP
Unreal Tournament
Unreal Tournament 2003
Unreal Tournament 2004
Unreal Tournament 3
V8 Supercar Challenge
Ventrilo
Vietcong
Vietcong 2
Warsow
Wheel of Time
Wolfenstein: Enemy Territory
Xpand Rally
 

Вложения

  • gameq.1.12.zip
    87.5 КБ · Просмотры: 65

Webman

Nevermind
Сообщения
803
Реакции
330
Скрипт не всегда выдает результаты. Иногда возвращает пустые данные, даже если сервер включен.
Автором уже почти 4 года не обновляется скрипт.
А за это время многое изменилось. Некоторые протоколы не поддерживает.
 
Сверху Снизу