查看完整版本: [-- 【转贴】模拟器对战服务器状态查看代码(转自kofgame.com) --]

【 浮游城 - Castle in the Sky | 开放邀请注册,PS|SS|WII|DC下载研究中心 】 -> 【 模拟新闻评论区 | Comments On Emulator News 】 -> 【转贴】模拟器对战服务器状态查看代码(转自kofgame.com) [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

谷者 2006-09-26 09:43

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

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

本段代码是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>";

?>

pan820417 2006-09-26 10:23
完全看不懂

xiao555 2006-09-26 12:58
这个........用K来看不就可以了木?


查看完整版本: [-- 【转贴】模拟器对战服务器状态查看代码(转自kofgame.com) --] [-- top --]


Powered by PHPWind Code © 2003-08 PHPWind
Gzip enabled

You can contact us