Lieber Besucher, herzlich willkommen bei: sourceserver.info. Falls dies dein erster Besuch auf dieser Seite ist, lies bitte die Hilfe durch. Dort wird dir die Bedienung dieser Seite näher erläutert. Darüber hinaus solltest du dich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutze das Registrierungsformular, um dich zu registrieren oder informiere dich ausführlich über den Registrierungsvorgang. Falls du dich bereits zu einem früheren Zeitpunkt registriert hast, kannst du dich hier anmelden.
![]() |
PHP-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
/**
* =============================================================================
* This class will get infos from a HL2 server over php
*
* @author HSFighter
* @special thx to Chrisber
* @version 1.1.0
* @package PHP Server-Query Script
* @link http://sourceserver.info
*
* @version 1.1.0: serverstatus.class.php by hsfighter $
* =============================================================================
*/
class HLServerAbfrage {
var $server_address;
var $ip;
var $port;
var $fp;
var $challenge;
var $serverinfo;
var $playerlist;
var $cvarlist;
var $A2S_SERVERQUERY_GETCHALLENGE = "\x55\xFF\xFF\xFF\xFF"; // challenge
var $A2S_INFO = "TSource Engine Query\x00"; // info
var $A2S_PLAYER = "\x55"; // player
var $A2S_RULES = "\x56"; // rules
// IP und PORT trennen
function hlserver($server_address = 0) {
list($this->ip, $this->port) = explode(":", $server_address);
}
// Verbindung zum Server aufbauen
function connect() {
$this->fp = fsockopen("udp://".$this->ip, $this->port, $errno, $errstr, 3);
if (!$this->fp) {
$Fehler = 1;
}
}
// String-Command" senden
function send_strcmd($strcmd) {
fwrite($this->fp, sprintf('%c%c%c%c%s%c', 0xFF, 0xFF, 0xFF, 0xFF, $strcmd, 0x00));
}
// 1 Byte vom Server holen
function get_byte() {
return ord(fread($this->fp, 1));
}
// 1 Zeichen (1 Byte) vom Server holen
function get_char() {
return fread($this->fp, 1);
}
// einen int16-Wert (2 Bytes) vom Server holen
function get_int16() {
$unpacked = unpack('sint', fread($this->fp, 2));
return $unpacked["int"];
}
// einen int32-Wert (4 Bytes) vom Server holen
function get_int32() {
$unpacked = unpack('iint', fread($this->fp, 4));
return $unpacked["int"];
}
// einen float32-Wert (4 Bytes) vom Server holen
function get_float32() {
$unpacked = unpack('fint', fread($this->fp, 4));
return $unpacked["int"];
}
// einen String vom Server holen
function get_string() {
$str = '';
while(($char = fread($this->fp, 1)) != chr(0)) {
$str .= $char;
}
return $str;
}
// 4 bytes von der challenge holen
function get_4()
{
return fread($this->fp, 4);
}
// Challenger vom Server holen
function challenge() {
$this->connect();
$this->send_strcmd($this->A2S_SERVERQUERY_GETCHALLENGE);
$this->get_int32();
$this->get_byte();
$challenge = $this->get_4();
fclose($this->fp);
return $challenge;
}
// Infos vom Server holen
function infos() {
$this->connect();
$this->send_strcmd($this -> A2S_INFO);
$this->get_int32();
$this->get_byte();
$this->serverinfo["network_version"] = $this->get_byte();
$this->serverinfo["name"] = $this->get_string();
$this->serverinfo["map"] = $this->get_string();
$this->serverinfo["directory"] = $this->get_string();
$this->serverinfo["discription"]= $this->get_string();
$this->serverinfo["steam_id"] = $this->get_int16();
$this->serverinfo["players"] = $this->get_byte();
$this->serverinfo["maxplayers"] = $this->get_byte();
$this->serverinfo["bot"] = $this->get_byte();
$this->serverinfo["dedicated"] = $this->get_char();
$this->serverinfo["os"] = $this->get_char();
$this->serverinfo["password"] = $this->get_byte();
$this->serverinfo["secure"] = $this->get_byte();
$this->serverinfo["version"] = $this->get_string();
fclose($this->fp);
return $this->serverinfo;
}
// Player-Liste vom Server holen
function players() {
$challenge = $this->challenge();
$this->connect();
$this->send_strcmd($this->A2S_PLAYER.$challenge);
$this->get_int32();
$this->get_byte();
$playercount = $this->get_byte();
for($i=1; $i <= $playercount; $i++) {
$this->playerlist["index"][$i] = $this->get_byte();
$this->playerlist["name"][$i] = $this->get_string();
$this->playerlist["frags"][$i] = $this->get_int32();
$this->playerlist["time"][$i] = date('H:i:s', round($this->get_float32(), 0)+82800);
}
fclose($this->fp);
return $this->playerlist;
}
// Rules-Liste (CVARs) vom Server holen
function cvars() {
$challenge = $this->challenge();
$this->connect();
$this->send_strcmd($this->A2S_RULES.$challenge);
$this->get_int32();
$this->get_byte();
$cvarcount = $this->get_int16();
for($i=1; $i <= $cvarcount; $i++) {
$this->cvarlist[$this->get_string()] = $this->get_string();
}
fclose($this->fp);
return $this->cvarlist;
}
}
|
![]() |
PHP-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
// Server Angaben
$ip = '85.214.238.171';
$port = '27026';
$mappic_path = 'http://www.nsc-radio.com/assa/css_server/bhop/bilder/';
// Klasse Laden
include ("serverstatus.class.php");
// Verbindung zum Server herstellen
$verbindung = new HLServerAbfrage;
$verbindung -> hlserver($ip.':'.$port);
// Serverinfos abfragen
$infos = $verbindung->infos();
//$infos["os"] = str_replace("l", 'Linux', $infos["os"]);
//$infos["os"] = str_replace("w", 'Windows', $infos["os"]);
//$infos["password"] = str_replace("1", 'Yes', $infos["password"]);
//$infos["password"] = str_replace("0", 'No', $infos["password"]);
//$infos["secure"] = str_replace("1", 'VAC2', $infos["secure"]);
//$infos["secure"] = str_replace("0", 'None', $infos["secure"]);
//$infos["dedicated"] = str_replace("l", 'Listen', $infos["dedicated"]);
//$infos["dedicated"] = str_replace("d", 'Dedicated', $infos["dedicated"]);
//$infos["dedicated"] = str_replace("p", 'SourceTV', $infos["dedicated"]);
// Serverinfos abfragen
echo 'Name: '.$infos["name"].'<br>';
echo '<IMG src="'.$mappic_path.$infos["map"].'.jpg" border=0><br>';
?>
IP: <a href="steam://85.214.238.171:27026" target='_blank'>85.214.238.171:27026</a><br>
<?php
//echo 'OS: '.$infos["os"].'<br>';
//echo 'Dedicated: '.$infos["dedicated"].'<br>';
//echo 'Version: '.$infos["version"].'<br>';
//echo 'Discription: '.$infos["discription"].'<br>';
echo 'Map: '.$infos["map"].'<br>';
echo 'Players: '.$infos["players"].'/'.$infos["maxplayers"].'<br>';
//echo 'Bots: '.$infos["bot"].'<br>';
//echo 'VAC: '.$infos["secure"].'<br>';
//echo 'Password: '.$infos["password"].'<br>';
// Playerinfos abfragen
$players = $verbindung->players();
if (isSet($players)){
arsort ($players["frags"]); // Player nach Frags sortieren
$x = 0;
foreach($players["frags"] as $key => $value) {
$x++;
// Echo '#'.$x.' -- '; // Nummer
// Echo ''.$players["index"][$key].' -- '; // Index
// Echo ''.$players["name"][$key].' -- '; // Name
// Echo ''.$players["frags"][$key].' -- '; // Frags
// Echo ''.$players["time"][$key].' -- '; // Zeit
Echo '<br>';
}
}else
//{
// echo "server leer";
//}
// Cvarinfos abfragen
//$nextmap = 'Unknow!!!';
//$cvars = $verbindung->cvars();
// Schleife um das Array aus zu lesen
//foreach($cvars as $key => $value) {
// Prüfung des Key's.
// if ($key == 'amx_nextmap')$nextmap = $value;
// if ($key == 'cm_nextmap')$nextmap = $value;
// if ($key == 'am_nextmap')$nextmap = $value;
// if ($key == 'mp_nextmap')$nextmap = $value;
// if ($key == 'mani_nextmap')$nextmap = $value;
// // Anzeige aller Cvars!!!
// Echo ''.$key.' = '.$value.'<br>';
//
//Echo '<br>Next map is: <b>'.$nextmap.'</b><br>';
|
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »Razzer2406« (13. Februar 2013, 01:47)
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »server-aufsetzen« (13. Februar 2013, 17:50)