搜索
查看: 2594|回复: 6

服务器状态查询网页,只能对2834以前的服务端版本有用,但无法查询到3329 3213 3382的

[复制链接]
发表于 2007-2-17 14:13:16 | 显示全部楼层 |阅读模式 来自 中国–山东–烟台–龙口市
php代码求助   

--------------------------------------------------------------------------------

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>&nbsp;<td>&nbsp;";
?></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>
 楼主| 发表于 2007-2-22 19:25:59 | 显示全部楼层 来自 中国–山东–烟台–龙口市

回复: 服务器状态查询网页,只能对2834以前的服务端版本有用,但无法查询到3329 3213

DDDDDDDDDDDDDDDDDDDDDDDDDDD
回复

使用道具 举报

 楼主| 发表于 2007-3-2 22:57:39 | 显示全部楼层 来自 中国–山东–烟台–龙口市

回复: 服务器状态查询网页,只能对2834以前的服务端版本有用,但无法查询到3329 3213

DDDDddDDDDDDDDDDDDDDDD
回复

使用道具 举报

发表于 2007-3-5 11:27:58 | 显示全部楼层 来自 中国–新疆–乌鲁木齐

回复: 服务器状态查询网页,只能对2834以前的服务端版本有用,但无法查询到3329 3213

支持一下啊。。这个东西改出来大家都可以用么,高手看看
回复

使用道具 举报

发表于 2007-3-16 23:20:58 | 显示全部楼层 来自 中国–山东

回复: 服务器状态查询网页,只能对2834以前的服务端版本有用,但无法查询到3329 3213

DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
回复

使用道具 举报

 楼主| 发表于 2007-3-21 17:59:14 | 显示全部楼层 来自 中国–山东–烟台

回复: 服务器状态查询网页,只能对2834以前的服务端版本有用,但无法查询到3329 3213

DDDDDDDDDDDDDDDDDDDDDDDDDDDD
回复

使用道具 举报

发表于 2007-3-25 07:40:21 | 显示全部楼层 来自 中国–浙江–杭州–拱墅区

回复: 服务器状态查询网页,只能对2834以前的服务端版本有用,但无法查询到3329 3213

期待中啊。CS现在也很牛了。还可以注册ID 呵呵
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表