Parašė JaWa· 2010 Bal. 10 17:04:59
#1
Sveiki. Galetumete pagelbeti. Stai cia turiu cs serverio skripta kuris rodo kas zaidzia ir kiek nukilino. Ar galima butu padaryt kad butu vaizduojama tam tikra tvarka, kas yra daugiau nuzudes, tas saraso virshuje ir taip mazejimo tvarka. Bandziau per sort() funkcija, bet neisheina .
<?php
error_reporting(E_ALL);
error_reporting(0);
if (!isset($port))
{
$port='27015';
}
if (!isset($server))
{
$server='cslt.alive.lt';
}
$qw=chr(32);
$fp = @fsockopen ("udp://".$server,$port);
@stream_set_timeout($fp, 3);
if (!$fp) return false;
{
fwrite($fp,"\377\377\377\377players".chr(10));
//fwrite($fp,"\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00".chr(10));
$st=fread($fp,1);
$r=socket_get_status($fp);
$r=$r["unread_bytes"];
$st.=fread($fp,$r);
fclose($fp);
$playersn=ord(substr($st,5,1));
$st=substr($st,6);
}
if ($playersn != 0 )
{
echo ("\n<meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1251\">
<body>
<center>
<table align='center' cellpadding='0' cellspacing='1' width='400' class='tbl-border'>
<tr>
<td width='1%' class='tbl1' style='white-space:nowrap'>Players</td>
<td class='tbl1'>Kills</td>
</tr>\n");
for ($i=1;$i<=$playersn;$i++){
$n=ord(substr($st,0,1));
$st=substr($st,1);
$name=substr($st,0,strpos($st,chr(0)));
$kills=ord(substr($st,strpos($st,chr(0))+1,1));
if ($kills==255){$kills=-1;}
if ($kills==254){$kills=-2;}
if ($kills==253){$kills=-3;}
if ($kills==252){$kills=-4;}
$st=substr($st,strpos($st,chr(0)));
$st=substr($st,9);
echo("
<tr>
<td width='1%' class='tbl1' style='white-space:nowrap'><b>$name</b></td>
<td class='tbl1'>$kills</td>
</tr>\n");
}
echo("</table></body>");
}
else
echo "Offline";
?>