一、运行环境:
1、在discuz 5.x测试正常。
2、PVPGN必须开启服务器状态输出。
二、安装方法:
1、将status.php存放到pvpgn-stat的目录中。
<style type="text/css"><!--
.STYLE2 {font-family: Arial, Helvetica, sans-serif}
.STYLE3 {
color: #2F5ACC;
font-family: "Times New Roman", Times, serif;
}
-->
</style>
<p><a href="../bbs/forumdisplay.php?fid=9" target="_blank" class="STYLE3" ><font size="3"><strong>★★★★★战网服务器正常运行中★★★★★</strong></font></font></a></p>
<p></p>
<link href="../start/ocean.css" rel="stylesheet" type="text/css" />
<?php
// Path to server.dat
$statusfile = 'C:/Inetpub/PvPGN/var/status/server.dat';
// What info should be shown?
$show = array(
'STATUS' => false,
'USERS' => true,
'GAMES' => true,
'CHANNELS' => false,
);
// Display game icons next to users/games online?
$displayicons = true;
// URL of directory containing the game icons. No trailing slash.
$iconsdir = "./gameicons";
// Enable profile links?
$profilelink_enable = true;
$profilelink_url = "/battle/stats.php"; // URL to pvpgn-stats
// Display the list of users/games/channels side by side rather than in a vertical list?
$sidebyside = ture;
// Language constants. Translate into your native language if needed.
$language = array(
'STATUSDETAIL' => 'BN服务器当前状态',
'USERSDETAIL' => '当前在线用户列表:',
'GAMESDETAIL' => '当前进行的自定义游戏列表:',
'CHANNELSDETAIL' => '当前聊天频道列表:',
'Version' => '服务器版本',
'Uptime' => '服务器已经运行了',
'Users' => '当前BN在线用户数',
'Games' => '当前进行的游戏数',
'Channels' => '当前的聊天频道数',
'UserAccounts' => 'BN总共注册用户数',
'none' => '无',
);
// ------------------------------------------------------------------------------------------ //
// //
// Configuration finished, no need to change anything below here //
// //
// ------------------------------------------------------------------------------------------ //
function parse_statusfile($filename) {
$ini_array = array();
$lines = file($filename);
foreach($lines as $line) {
$line = trim($line);
if ($line == "") {
continue;
} else if ($line[0] == "[" && $line[strlen($line) - 1] == "]") {
$sec_name = substr($line, 1, strlen($line) - 2);
} else {
$pos = strpos($line, "=");
$property = substr($line, 0, $pos);
$value = substr($line, $pos + 1);
if ($sec_name == 'USERS' $sec_name == 'GAMES') {
list($ini_array[$sec_name][$property]['ctag'],$ini_array[$sec_name][$property]['name']) = explode(',',$value);
} else {
$ini_array[$sec_name][$property] = $value;
}
}
}
return $ini_array;
}
function namedisplay($user) {
global $profilelink_enable, $profilelink_url;
if ($profilelink_enable && $user['ctag'] != 'CHAT') {
return "<a href=/"".$profilelink_url."?game=".$user['ctag']."&user=".$user['name']."/" target=_blank >".$user['name']."</a>";
} else {
return $user['name'];
}
}
$status_array = parse_statusfile($statusfile);
if ($sidebyside) {
$output = "<div>/n";
foreach ($show as $type => $show) {
if ($show == true) {
$output .= "<strong>".$language[$type.'DETAIL']."</strong><br>/n";
if (empty($status_array[$type])) {
$output .= $language['none']."<br><br>/n";
} else {
switch ($type) {
case 'STATUS':
foreach ($status_array[$type] as $key => $value) {
$output .= $language[$key].": ".$value."<br>";
}
break;
case 'USERS':
foreach ($status_array[$type] as $key => $value) {
$output .= namedisplay($value).", ";
}
break;
case 'GAMES':
foreach ($status_array[$type] as $key => $value) {
$output .= $value['name'].", ";
}
break;
case 'CHANNELS':
foreach ($status_array[$type] as $key => $value) {
$output .= $value.", ";
}
break;
}
$output = substr($output,0,-4);
$output .= "<br><br>/n";
}
}
}
} else {
$output = "<table cellspacing=/"0/">/n";
foreach ($show as $type => $show) {
if ($show == true) {
$output .= " <tr>/n";
$output .= " <td colspan=/"2/">/n";
$output .= " <strong>".$language[$type.'DETAIL']."</strong>/n";
$output .= " </td>/n";
$output .= " </tr>/n";
if ($status_array[$type] == true) {
foreach ($status_array[$type] as $key => $value) {
if ($type == 'STATUS') {
$output .= " <tr>/n";
$output .= " <td colspan=/"2/">/n";
$output .= " ".$language[$key].": ".$value."/n";
$output .= " </td>/n";
$output .= " </tr>/n";
} else {
$output .= " <tr>/n";
if ($type != 'CHANNELS') {
$output .= " <td width=/"1%/">/n";
if ($displayicons)
$output .= " <img src=/"".$iconsdir."/".$value['ctag'].".jpg/">/n";
else
$output .= " /n";
$output .= " </td>/n";
$output .= " <td>/n";
if ($type == 'USERS') {
$output .= " ".namedisplay($value)."/n";
} else {
$output .= " ".$value['name']."/n";
}
$output .= " </td>/n";
$output .= " </tr>/n";
} else {
$output .= " <tr>/n";
$output .= " <td colspan=/"2/">/n";
$output .= " ".$value."/n";
$output .= " </td>/n";
$output .= " </tr>/n";
}
}
}
} else {
$output .= " <tr>/n";
$output .= " <td colspan=/"2/">/n";
$output .= " <strong>".$language['none']."</strong>/n";
$output .= " </td>/n";
$output .= " </tr>/n";
}
$output .= " <tr>/n";
$output .= " <td colspan=/"2/" height=/"7/">/n";
$output .= " </td>/n";
$output .= " </tr>/n";
}
}
$output .= "</table>/n";
}
echo $output;
?><style type="text/css">
<!--
.STYLE2 {font-family: Arial, Helvetica, sans-serif}
.STYLE3 {
color: #2F5ACC;
font-family: "Times New Roman", Times, serif;
}
-->
</style>
<p><a href="../bbs/forumdisplay.php?fid=9" target="_blank" class="STYLE3" ><font size="3"><strong>★★★★★战网服务器正常运行中★★★★★</strong></font></font></a></p>
<p></p>
<link href="../start/ocean.css" rel="stylesheet" type="text/css" />
<?php
// Path to server.dat
$statusfile = 'C:/Inetpub/PvPGN/var/status/server.dat';
// What info should be shown?
$show = array(
'STATUS' => false,
'USERS' => true,
'GAMES' => true,
'CHANNELS' => false,
);
// Display game icons next to users/games online?
$displayicons = true;
// URL of directory containing the game icons. No trailing slash.
$iconsdir = "./gameicons";
// Enable profile links?
$profilelink_enable = true;
$profilelink_url = "/battle/stats.php"; // URL to pvpgn-stats
// Display the list of users/games/channels side by side rather than in a vertical list?
$sidebyside = ture;
// Language constants. Translate into your native language if needed.
$language = array(
'STATUSDETAIL' => 'BN服务器当前状态',
'USERSDETAIL' => '当前在线用户列表:',
'GAMESDETAIL' => '当前进行的自定义游戏列表:',
'CHANNELSDETAIL' => '当前聊天频道列表:',
'Version' => '服务器版本',
'Uptime' => '服务器已经运行了',
'Users' => '当前BN在线用户数',
'Games' => '当前进行的游戏数',
'Channels' => '当前的聊天频道数',
'UserAccounts' => 'BN总共注册用户数',
'none' => '无',
);
// ------------------------------------------------------------------------------------------ //
// //
// Configuration finished, no need to change anything below here //
// //
// ------------------------------------------------------------------------------------------ //
function parse_statusfile($filename) {
$ini_array = array();
$lines = file($filename);
foreach($lines as $line) {
$line = trim($line);
if ($line == "") {
continue;
} else if ($line[0] == "[" && $line[strlen($line) - 1] == "]") {
$sec_name = substr($line, 1, strlen($line) - 2);
} else {
$pos = strpos($line, "=");
$property = substr($line, 0, $pos);
$value = substr($line, $pos + 1);
if ($sec_name == 'USERS' $sec_name == 'GAMES') {
list($ini_array[$sec_name][$property]['ctag'],$ini_array[$sec_name][$property]['name']) = explode(',',$value);
} else {
$ini_array[$sec_name][$property] = $value;
}
}
}
return $ini_array;
}
function namedisplay($user) {
global $profilelink_enable, $profilelink_url;
if ($profilelink_enable && $user['ctag'] != 'CHAT') {
return "<a href=/"".$profilelink_url."?game=".$user['ctag']."&user=".$user['name']."/" target=_blank >".$user['name']."</a>";
} else {
return $user['name'];
}
}
$status_array = parse_statusfile($statusfile);
$output = "<div>/n";
foreach ($show as $type => $show) {
if ($show == true) {
$output .= "<strong>".$language[$type.'DETAIL']."</strong><br>/n";
if (empty($status_array[$type])) {
$output .= $language['none']."<br><br>/n";
} else {
switch ($type) {
case 'STATUS':
foreach ($status_array[$type] as $key => $value) {
$output .= $language[$key].": ".$value."<br>";
}
break;
case 'USERS':
foreach ($status_array[$type] as $key => $value) {
$output .= namedisplay($value).", ";
}
break;
case 'GAMES':
foreach ($status_array[$type] as $key => $value) {
$output .= $value['name'].", ";
}
break;
case 'CHANNELS':
foreach ($status_array[$type] as $key => $value) {
$output .= $value.", ";
}
break;
}
$output = substr($output,0,-4);
$output .= "<br><br>/n";
}
}
}
} else {
$output = "<table cellspacing=/"0/">/n";
foreach ($show as $type => $show) {
if ($show == true) {
$output .= " <tr>/n";
$output .= " <td colspan=/"2/">/n";
$output .= " <strong>".$language[$type.'DETAIL']."</strong>/n";
$output .= " </td>/n";
$output .= " </tr>/n";
if ($status_array[$type] == true) {
foreach ($status_array[$type] as $key => $value) {
if ($type == 'STATUS') {
$output .= " <tr>/n";
$output .= " <td colspan=/"2/">/n";
$output .= " ".$language[$key].": ".$value."/n";
$output .= " </td>/n";
$output .= " </tr>/n";
} else {
$output .= " <tr>/n";
if ($type != 'CHANNELS') {
$output .= " <td width=/"1%/">/n";
if ($displayicons)
$output .= " <img src=/"".$iconsdir."/".$value['ctag'].".jpg/">/n";
else
$output .= " /n";
$output .= " </td>/n";
$output .= " <td>/n";
if ($type == 'USERS') {
$output .= " ".namedisplay($value)."/n";
} else {
$output .= " ".$value['name']."/n";
}
$output .= " </td>/n";
$output .= " </tr>/n";
} else {
$output .= " <tr>/n";
$output .= " <td colspan=/"2/">/n";
$output .= " ".$value."/n";
$output .= " </td>/n";
$output .= " </tr>/n";
}
}
}
} else {
$output .= " <tr>/n";
$output .= " <td colspan=/"2/">/n";
$output .= " <strong>".$language['none']."</strong>/n";
$output .= " </td>/n";
$output .= " </tr>/n";
}
$output .= " <tr>/n";
$output .= " <td colspan=/"2/" height=/"7/">/n";
$output .= " </td>/n";
$output .= " </tr>/n";
}
}
$output .= "</table>/n";
}
echo $output;
?>
★找到
<!--{if $whosonlinestatus}-->
★在其上面加上
{HEADERTEXT}">BN在线状态列表</td></tr>
</tbody>
<tbody><tr height = "160"><td colspan="3" class="smalltxt" style="font-weight: normal; color:
{HEADERTEXT}" scrolling=no><IFRAME src=" ../pvpgn-stat目录/status.php(相对目录)" frameBorder=0 width="100%" scrolling=no height="100%"></IFRAME>
</td></tr></tbody>