Чтение RSS каналов

Форум

Открыть Ответить

Мониторинг игровых серверов

5

5
1
03.12.2008 12:30:48
Меня интересует блок мониторинга COD4
<?php

if (!defined('BLOCK_FILE')) {
	Header(&quot;Location: ../index.php&quot;);
	exit;
}

$server=&quot;152.168.6.8&quot;;
$qw=chr(32);
$fp = fsockopen (&quot;udp://&quot;.$server,&quot;28960&quot;);
if (!$fp) {
    echo &quot;ERROR: $errno - $errstr<br>\n&quot;;
    } else {
    fwrite($fp,&quot;яяяяgetinfo&quot;);
					socket_set_timeout($fp,2,1);
    $st=fread($fp,1);
    $r=socket_get_status($fp);
    $r=$r[&quot;unread_bytes&quot;];
    $st.=fread($fp,$r);
    fclose($fp);
    $posname1=strpos($st,&quot;hostname&quot;);
    $posname2=strpos($st,&quot;mapname&quot;);
    $posname3=strpos($st,&quot;\clients&quot;);
    $posname4=strpos($st,&quot;sv_maxclients&quot;);
    $posname5=strpos($st,&quot;gametype&quot;);

    $name=substr($st,$posname1+9,$posname2-$posname1-10);
    $map=substr($st,$posname2+8,$posname3-$posname2-8);
    $current=substr($st,$posname3+9,$posname4-$posname3-10);
    $max=substr($st,$posname4+14,$posname5-$posname4-15);
    }
$show_map=&quot;<img src=/images/cod/&quot;.$map.&quot;.jpg width=\&quot;130\&quot; height=\&quot;98\&quot;>&quot;;
$content=(&quot;

<table width=\&quot;145\&quot; border=\&quot;0\&quot; cellpadding=\&quot;1\&quot; cellspacing=\&quot;1\&quot; align=\&quot;center\&quot;>
<tr>
<td rowspan=\&quot;7\&quot;>
<center><font color=\&quot;#8c7952\&quot;>$show_map</font></center>
</td>
</tr>
</table>

<table width=\&quot;145\&quot; border=\&quot;0\&quot; cellpadding=\&quot;1\&quot; cellspacing=\&quot;1\&quot; align=\&quot;center\&quot;>
<tr>
<td<b>Карта:</b> <b>$map</b></td>
</tr>
</table>

<table width=\&quot;145\&quot; border=\&quot;0\&quot; cellpadding=\&quot;1\&quot; cellspacing=\&quot;1\&quot; align=\&quot;center\&quot;>
<tr>
<td>
<b>Имя:</b> <b>$name</b></td>
</table>

<table width=\&quot;145\&quot; border=\&quot;0\&quot; cellpadding=\&quot;1\&quot; cellspacing=\&quot;1\&quot; align=\&quot;center\&quot;>
<tr>
<td><b>Адрес:</b></td>
<td><b>$server</b></td>
</tr>
</table>

<table width=\&quot;145\&quot; border=\&quot;0\&quot; cellpadding=\&quot;1\&quot; cellspacing=\&quot;1\&quot; align=\&quot;center\&quot;>
<tr><td><b>Игроков: $current/$max</td></tr>
</table>
<head>
<!-- HEAD START HERE -->
<script language=\&quot;JavaScript\&quot;>
<!--
function winopcoduo()
{
windop = window.open(\&quot;/codmon/monitor/player.php\&quot;,\&quot;mywin\&quot; ,\&quot;height=800,width=300 ,scrollbars=yes\&quot;);
}
-->
</script>

<!-- HEAD END HERE -->




</head>
<body bgcolor=\&quot;#EDEDED\&quot; text=\&quot;#000000\&quot; link=\&quot;#000000\&quot; topmargin=\&quot;0\&quot; leftmargin=\&quot;0\&quot;>
<center>

<!-- BODY START HERE -->

<a href=\&quot;Java Scriptwinopcoduo();\&quot;><b><font color=\&quot;red\&quot;>Кто играет ?</font></b></a>





&quot;);

if($posname3==0){$content= &quot;<table width=\&quot;101%\&quot; border=\&quot;0\&quot; cellpadding=\&quot;1\&quot; cellspacing=\&quot;1\&quot; align=\&quot;center\&quot; bgcolor=\&quot;535353\&quot;>
  <tr>
    <td colspan=\&quot;1\&quot;><center><b>Сервер пуст!</b></center></td>
  </tr>
  </table>&quot;;}
$fp = fsockopen (&quot;udp://&quot;.$server,&quot;28960&quot;);
if (!$fp) {
    echo &quot;ERROR: $errno - $errstr<br>\n&quot;;
    } else {
    fwrite($fp,&quot;яяяяgetinfo&quot;);
    $st=fread($fp,1);
    $r=socket_get_status($fp);
    $r=$r[&quot;unread_bytes&quot;];
    $st.=fread($fp,$r);
    fclose($fp);
    $playersn=ord(substr($st,5,1));
    $st=substr($st,6);
    if ($playersn !=0 )
        Echo(&quot;</body></html>&quot;);

    }

?>


Как зделать чтобы в блоке отображалось всего навсего
Call of Duty 4: 0(количество играков на сервер)/20(макс играков на сервере)
А то пишется когда неково нету сервер пуст это меня раздрожает и когда кто играет выдаётся полная иформация


Версия PHP: PHP 5
Сервер: Локальный сервер
Открыть Ответить
Хотите опробовать SLAED CMS в действии?

Технологии

PHP MySQL HTML 5 CSS 3 jQuery jQuery UI

Контакты

  • D-49179, Deutschland
    Ostercappeln, Im Siek 6
  • +49 176 61966679

  • https://slaed.net
Идеи и предложения
Обратная связь