The final script is server status ("independent")
I'll leave it here, can someone come in handy
=================================
PHP Code:
<?php
//для потомков: by Damage 2015(C)!
{
$xuivrot="";
$server_ip = '12.13.14.15'; //ipserver
$server_port = '28960'; //portserver
$rcon_password = 'SuperRconPassword123abc';
function currentplayers($infaoservere2)
{
$backinfo='';
preg_match_all('/(\d+) (\d+) "([^"]+)"/', $infaoservere2, $players3);
$backinfo=sizeof($players3[3]);
return $backinfo;
}
function utochinfo($samainfaoservere)
{
if($samainfaoservere=='zom')
{
$vozvratka='Zombies/Zom-mod';
return $vozvratka; //поднимаем в прошлую функцию
sleep(0.1);
}
else if($samainfaoservere=='tdm')
{ $vozvratka='Team DeathMatch'; sleep(0.1); return $vozvratka; }
else if($samainfaoservere=='dm')
{ $vozvratka='Deathmatch'; sleep(0.1); return $vozvratka; }
else if($samainfaoservere=='sd')
{ $vozvratka='Search and Destroy'; sleep(0.1); return $vozvratka; }
else if($samainfaoservere=='mp_toujane')
{ $vozvratka='Toujane, Tunissia'; sleep(0.1); return $vozvratka; }
else if($samainfaoservere=='mp_carentan')
{ $vozvratka='Carentan, France'; sleep(0.1); return $vozvratka; }
else if($samainfaoservere=='mp_burgundy')
{ $vozvratka='Bugundy'; sleep(0.1); return $vozvratka; }
else { return $samainfaoservere; }
}
function lookinfo($InfoOservere)
{
$linesinfo = explode('\\', $InfoOservere);
{
for($i=1;$i<count($linesinfo);$i+=1)
{
usleep(10000);
if($linesinfo[$i] == 'g_gametype') { echo "<div style=\"color:red;\"><br>Game type: " . utochinfo($linesinfo[$i+1]); usleep(10000); } //режим игры
if($linesinfo[$i] == 'mapname') { echo "<div style=\"color:green;\"><br>Server map: " . utochinfo($linesinfo[$i+1]); usleep(10000); } //карта
if($linesinfo[$i] == 'sv_hostname') { echo "<div style=\"color:blue;\"><br>Server name: " . utochinfo($linesinfo[$i+1]); usleep(10000); } //название сервера
if($linesinfo[$i] == 'sv_maxclients') { echo "<div style=\"color:orange;\"><br>Max clients: " . utochinfo($linesinfo[$i+1]) . " Client(s)"; usleep(10000); } //макс. слотов
if($linesinfo[$i] == 'mod') { echo "<div style=\"color:purple;\"><br>Current players: " . currentplayers($InfoOservere) . " Client(s)"; usleep(10000); }
}
}
}
$errno = $errstr = null;
$server_info = "udp://" . $server_ip;
$sendpacket = "\xff\xff\xff\xffgetstatus"; // \xff\xff\xff\xffrcon thyPassword status // \xff\xff\xff\xffgetstatus
@$connectpacket = fsockopen($server_info, $server_port, $errno, $errstr, $timeout);
if(!$connectpacket)
{
die('Нету подключения к серверу/Или сервер несуществует!');
}
socket_set_timeout ($connectpacket, 1, 0);
{
fwrite ($connectpacket, $sendpacket); //диалог с мастер-сервером.
$infoserver = '';
while ($status1 = fread ($connectpacket, 10000)) //постоянное автообновление, и чек полученый инфы.
{
$infoserver .= $status1;
if($infoserver!='яяяяdisconnect' && $infoserver!='яяяяneedcdkey' && $infoserver!='яяяяprint Invalid password.')
{
//echo $infoserver; //-= FULL INFO
lookinfo($infoserver); //==--INFO FILTERS--==
}
else if($infoserver=='яяяяdisconnect') { echo "Сервер не отвечает на запросы!"; } if($infoserver=='яяяяneedcdkey') { echo "Ключ диска не введен!"; } if($infoserver=='яяяяprint Invalid password.') { echo "Неверный пароль"; }
//lookinfo($infoserver);
}
}
fclose ($connectpacket); //
}
?>
Many superfluous, who prevents clean, can refine the pattern!
FILE.php == https://dropmefiles.com/DtWVz == FILE.php