Jestem nowym użytkownikiem i mam problem z jednym z skrytpów php wyświetlającym status serwera gry counter strike
Błędy można zobaczyć tutaj http://www.bykowinateam.ovh.org/stan.php
a tutaj zamieszczam źródło pliku stan.php
Kod
<?php
/**
* pobiera informacje z serwera i zwraca tablice z tymi danymi
*
* @param string $intServerIP Adres IP serwera
* @param integer $intServerPort Port serwera
* @return array
*/
function RetriveInfo ( $strServerIP = '85.114.134.28', $intServerPort = 27019 )
{
$connection = fsockopen( "udp:" . $strServerIP, $intServerPort );
fwrite( $connection, sprintf( '%c%c%c%c%s%c', 0xFF, 0xFF, 0xFF, 0xFF, "infostring", 0x00 ) );
fread( $connection, 24 );
$status = socket_get_status( $connection );
if ( $status["unread_bytes"] != 0 )
{
$return = "";
while ( $status["unread_bytes"] != 0 )
{
$return .= fread( $connection, 1 );
$status = socket_get_status( $connection );
}
$return = explode( '', $return );
$arr = array();
$arr['ip'] = $intServerIP;
$arr['port'] = $intServerPort;
$arr['hostname'] = $return[19];
$arr['game'] = $return[17];
$arr['players'] = $return[5];
$arr['maxplayers'] = $return[11];
$arr['system'] = ( $return[25] == "w" ) ? "Windows" : "Linux";
$arr['game_dir'] = $return[15];
$arr['map'] = $return[21];
$arr['password'] = ( $return[25] == "0" ) ? "false" : "true";
$arr['secure'] = $return[29];
return $arr;
}
else
{
// blad?
return $arr;
}
}
?>
<?php
$arr = RetriveInfo("85.114.134.28", "27019"); // gdzie te parametry to IP oraz port
echo "IP: " . $arr['ip'];
echo "<BR>";
echo "Port: " . $arr['port'];
echo "<BR>";
echo "Nazwa servera: " . $arr['hostname'];
echo "<BR>";
echo "Gra: " . $arr['game'];
echo "<BR>";
echo "Ilosc graczy: " . $arr['players'];
echo "<BR>";
echo "Max graczy: " . $arr['maxplayers'];
echo "<BR>";
echo "System: " . $arr['system'];
echo "<BR>";
echo "Cos tam: " . $arr['game_dir'];
echo "<BR>";
echo "Mapa: " . $arr['players'];
echo "<BR>";
echo "Haslo: " . $arr['password'];
echo "<BR>";
echo "VAC: " . $arr[secure];
echo "<BR>";
?>
/**
* pobiera informacje z serwera i zwraca tablice z tymi danymi
*
* @param string $intServerIP Adres IP serwera
* @param integer $intServerPort Port serwera
* @return array
*/
function RetriveInfo ( $strServerIP = '85.114.134.28', $intServerPort = 27019 )
{
$connection = fsockopen( "udp:" . $strServerIP, $intServerPort );
fwrite( $connection, sprintf( '%c%c%c%c%s%c', 0xFF, 0xFF, 0xFF, 0xFF, "infostring", 0x00 ) );
fread( $connection, 24 );
$status = socket_get_status( $connection );
if ( $status["unread_bytes"] != 0 )
{
$return = "";
while ( $status["unread_bytes"] != 0 )
{
$return .= fread( $connection, 1 );
$status = socket_get_status( $connection );
}
$return = explode( '', $return );
$arr = array();
$arr['ip'] = $intServerIP;
$arr['port'] = $intServerPort;
$arr['hostname'] = $return[19];
$arr['game'] = $return[17];
$arr['players'] = $return[5];
$arr['maxplayers'] = $return[11];
$arr['system'] = ( $return[25] == "w" ) ? "Windows" : "Linux";
$arr['game_dir'] = $return[15];
$arr['map'] = $return[21];
$arr['password'] = ( $return[25] == "0" ) ? "false" : "true";
$arr['secure'] = $return[29];
return $arr;
}
else
{
// blad?
return $arr;
}
}
?>
<?php
$arr = RetriveInfo("85.114.134.28", "27019"); // gdzie te parametry to IP oraz port
echo "IP: " . $arr['ip'];
echo "<BR>";
echo "Port: " . $arr['port'];
echo "<BR>";
echo "Nazwa servera: " . $arr['hostname'];
echo "<BR>";
echo "Gra: " . $arr['game'];
echo "<BR>";
echo "Ilosc graczy: " . $arr['players'];
echo "<BR>";
echo "Max graczy: " . $arr['maxplayers'];
echo "<BR>";
echo "System: " . $arr['system'];
echo "<BR>";
echo "Cos tam: " . $arr['game_dir'];
echo "<BR>";
echo "Mapa: " . $arr['players'];
echo "<BR>";
echo "Haslo: " . $arr['password'];
echo "<BR>";
echo "VAC: " . $arr[secure];
echo "<BR>";
?>
Nie wiem co zrobić aby wyświetał to poprawnie, zależy mi na tym z góry dzieki
P.S. Sory za post poniżej był źle zrobiony