|
yan发布的服务器状态查询网页,只能对2834以前的服务端版本有用,但无法查询到3329 3213 3382的服务端版本,总是显示服务器关闭.请懂php代码的高手指教,需要怎样修改,下面是源码;
<?
$Server="广州新力量网吧CS1.6";
$HostIP="nPower.vicp.net:27016";
$ip="127.0.0.1:27016";
if(!empty($_GET['ip'])){
$ip = $_GET['ip'];
$HostIP=$ip;
}
?>
<?
function strcut($strx,$type){
$a=strpos($strx,":");
$port=substr($strx,$a+1,5);
if(empty($a)){
$a=strlen($strx);
$port="27015";
}
$ip=substr($strx,0,$a);
if(empty($ip))
$ip="127.0.0.1";
if ($type==1)
return $ip;
else
return $port;
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><?echo $Server?>-#1即时状态</title>
</head>
<style>
<style>
body{
color:white
}
td{
COLOR: white
}
</style>
<body background=mappics/background.jpg bgproperties="fixed" TOPMARGIN=0>
<center>
<?function send($fp,$cmd)
{fputs($fp,"\xff\xff\xff\xff$cmd");
$c=fread($fp,1);
if($c=="") return false;
$fpstatus=socket_get_status($fp);
return $c.fread($fp,$fpstatus["unread_bytes"]);
}
$fp=fsockopen("udp://".strcut($ip,1),strcut($ip,2),&$errno,&$errstr,2);
if(!$fp) exit("错误 - $errno : $errstr");
stream_set_timeout($fp,3);
if(!$c=send($fp,"infostring")) exit("<h2><a href='javascript:history.go(-1)'><font color=white>".$ip."服务器未启动</font>");
$a=explode("\\",substr($c,24));
for($i=0;$i<count($a);$i+=2)
$info[$a[$i]]=$a[$i+1];
//".$info['hostname']."
if(!empty($_GET['ip']))
$Server=$info["hostname"];
echo "<table width=760 border=0 height=150 style='border-collapse: collapse' bordercolor='#0092f2' cellspacing=1 cellpadding=1 ><tr><td width=15% background=mappics/".$info["map"].".jpg align=center><b><font color=white>服务器名称:". $Server."<br>服务器IP:".$HostIP."<br>当前地图:".$info["map"]."<br>当前玩家:<b>".$info["players"]."</b>/".$info["max"]."(".$info["bots"]." BOTs)<br><a href='cstop.php' ><font color=white>".$Server."-#1实时排行</a><br><a href='?ip=127.0.0.1:27015' ><font color=white>". $Server."-#2即时状态</a></b></table><table border=1 width=760 border=1 style='border-collapse: collapse' bordercolor='white' cellspacing=1 cellpadding=1 ><tr><th bgcolor=#AABBFF onmouseover=this.style.backgroundcolor='#88A0FF' onmouseout=this.style.backgroundcolor='#AABBFF' align='center'>No.<th bgcolor=#AABBFF onmouseover=this.style.backgroundcolor='#88A0FF' onmouseout=this.style.backgroundcolor='#AABBFF' align='center'>当前玩家ID<th bgcolor=#AABBFF onmouseover=this.style.backgroundcolor='#88A0FF' onmouseout=this.style.backgroundcolor='#AABBFF' align='center'>得分<th bgcolor=#AABBFF onmouseover=this.style.backgroundcolor='#88A0FF' onmouseout=this.style.backgroundcolor='#AABBFF' align='center'>游戏时间";
$c=substr(send($fp,"players"),6);
for($i=1;strlen($c)>0;$i++)
{$tmp=strpos($c,"\x00");
echo "<tr ><td align=center width=15>$i<td>".substr($c,1,$tmp)."";
echo "<td width=90>".(ord($c[$tmp+1])+(ord($c[$tmp+2])<<8)+(ord($c[$tmp+3])<<16)+(ord($c[$tmp+4])<<24));
$tmptime=@unpack('ftime',substr($c,$tmp+5,4));
$t=round($tmptime['time']);$h=floor($t/3600);$m=floor(($t-$h*3600)/60);$sec=floor($t-$h*3600-$m*60);
echo "<td width=153>$h:$m:$sec";
$c=substr($c,$tmp+9);
}
fclose($fp);
for(;$i<=$info["players"];$i++)
echo "<tr align=center><td>$i<td>正在连接...<td> <td> ";
?></table>
<br>
<hr size=1 width=95%>
<font color=white>如有更好意见或建议请<a target=_blank href="http://nPower.vicp.net/book.asp">留言</a>!
<p align="right"><u><font face="Fixedsys">Yan Online</u>,<br><a href="http://yanexp.126.com" target=_blank title="最后更新日期Yan!"></a>
<script>document.write(document.lastModified);</script><br> |
|