主题 : 【转贴】模拟器对战服务器状态查看代码(转自kofgame.com)
级别: 模拟小生
UID: 126021
精华: 0
发帖: 1
威望: 0 星
金钱: 2544 浮游币
贡献值: 0 点
好评度: 1 点
人气: 0 点
在线时间: 0(时)
注册时间: 2006-06-27
最后登录: 2006-09-26
楼主  发表于: 2006-09-26 09:43

【转贴】模拟器对战服务器状态查看代码(转自kofgame.com)

送给大家一段用来查看模拟器网战服务器状态的代码,有网站的朋友可以架设自己的查询.

让大家不必启动模拟器登陆游戏 就知道服务器的状态

本段代码是PHP代码不会PHP的朋友只要找到

$ip = "221.204.254.55:27888";

把里面的IP和端口替换成你的服务器地址即可

希望精通PHP的朋友能改进一下 让程序更完美

演示地址 http://www.kofgame.com/kofserver.php

<?php
// *********************************************
// *     模拟器'网站服务器'检测程序                           *
// *             谷者   guzhe.kofgame.com                 *
// *         www.kofgame.com                     *
// *********************************************

error_reporting(7);

// Here's where you type the name of your server
//
// Example:
// $servname = "Kaillera Server";
$servname = "【模拟器网站服务器检测程序】";

// Here is where you type the ip/address of your
// Kaillera server, including the port
//
// Example:
// $ip = "1.2.3.4:27888";

$ip = "221.204.254.55:27888";
// You can mess with this if you want,
// because this is the page header.
// Just make sure you know what you're
// doing.

echo '<strong><font size="+2"></font>测试服务器IP:</strong>' . $ip . '<br> ';

// Here's where the script starts.
// I don't recommend editing anything
// beyond this point.
function sec2hms ($sec, $padHours = false)
{
  $hms = "";
  $hours = intval(intval($sec) / 3600);
  $hms .= ($padHours)
  ? str_pad($hours, 2, "0", STR_PAD_LEFT) . ':'
  : $hours . ':';

  $minutes = intval(($sec / 60) % 60);
  $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT) . ':';
  $seconds = intval($sec % 60);
  $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
  return $hms;
}

$filename = "http://" . $ip . "/index.html?page=status";
$myFile = fopen($filename, "r");
if (! $myFile) {
  print ("File could not be opened.");
  exit;
}

$fcontents = file($filename);

$limit = 30;

$uptime = $fcontents[3];
$uptime2 = explode(" ", $uptime);
$uptime3 = round($uptime2[1], 0);
$uptimenum = sec2hms($uptime3);
$numplayers = $fcontents[5];
$numplayers2 = explode(" ", $numplayers);
$numgames = $fcontents[6];
$numgames2 = explode(" ", $numgames);

echo "<strong>检测时间:</strong> " . $uptimenum . "<br \>";
echo "<strong>游戏人数:</strong> " . $numplayers2[2] . "<br \>";
echo "<strong>建立游戏数:</strong> " . $numgames2[2] . "<br \>";

$i = 10;
$g = 0;
$count = count($fcontents) - 3;

echo '<strong></strong><br \><table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
  <td width="125"><strong>游戏者</strong></td>
  <td width="250"><strong>模拟器</strong></td>
  <td width="125"><strong>连接类型 </strong></td>
  <td width="125"><strong>游戏状态</strong></td>
</tr>';

while ($i < $count) {
  if ($fcontents[$i] != "\n") {
    $line = $fcontents[$i];
    $display[$i] = explode("\t", $line);

    echo '
  <tr>
  <td>' . $display[$i][0] . '</td>
  <td>' . $display[$i][1] . '</td>
  <td>' . $display[$i][2] . '</td>
  <td>' . $display[$i][3] . '</td>
  </tr>';
  } else {
    $i = $i + 2;
    $g = 1;
    echo '</table><strong></strong><br \><table width="600" border="0" cellspacing="0" cellpadding="0">
  <tr>
  <td width="300"><strong>游戏名字</strong></td>
  <td width="150"><strong>游戏者</strong></td>
  <td width="150"><strong>游戏状态</strong></td>
  </tr>';
  } //end if
  $i++;
} //end while
echo '</table>';
fclose($myFile);

echo "<br \>本程序由拳皇部落提供: <a href=http://www.kofgame.com>www.kofgame.com</a>";

?>
级别: 模拟新血
UID: 143216
精华: 0
发帖: 11
威望: 0 星
金钱: 2546 浮游币
贡献值: 0 点
好评度: 32 点
人气: 0 点
在线时间: 0(时)
注册时间: 2006-09-22
最后登录: 2007-07-26
沙发  发表于: 2006-09-26 10:23

完全看不懂
级别: 论坛版主
UID: 10256
精华: 1
发帖: 10905
威望: 18 星
金钱: 5383 浮游币
贡献值: 8859 点
好评度: 30446 点
人气: 1086 点
在线时间: 935(时)
注册时间: 2004-07-27
最后登录: 2024-03-04
板凳  发表于: 2006-09-26 12:58

这个........用K来看不就可以了木?
(σ`・д・)σ 你不是那个原来住顶楼的笨蛋吗?