rendered paste body$language = array(
'pvpgnonline' => 'The PvPGN server is <font color="#00FF00">online</font>.',
'pvpgnoffline' => 'The PvPGN server is <font color="#FF0000">offline</font>.',
'd2realmonline' => 'The Diablo 2 realm is <font color="#00FF00">online</font> (%d of %d gameservers running).',
// This will end up like: (3 of 5 gameservers running)
'd2realmoffline' => 'The Diablo 2 realm is <font color="#FF0000">offline</font>.',
);
// Connection timeout in seconds. If the script cannot connect to a server before this timeout,
// then that server is considered to be offline. Don't make this too big or your website could
// take a long time to load.
$timeout = 1;
$pvpgn = array(
'check' => true, // Should we check the status of the PvPGN server? (true or false)
'ip' => '10.0.0.253', // IP of the PvPGN server
'port' => 6112, // Port of the PvPGN server
);
// ---------------------------------------------------------------------------------------------- //
// If you are not running a Diablo 2 closed realm, there is no need to change anything below here //
// ---------------------------------------------------------------------------------------------- //
$d2realm = array(
'check' => true, // Should we check the status of the Diablo 2 realm? (true or false)
'd2cs' => array(
'ip' => '10.0.0.253', // d2cs IP address
'port' => 6113, // d2cs port
),
'd2dbs' => array(
'ip' => '10.0.0.253', // d2dbs IP address
'port' => 6114, // d2dbs port
),
'd2gs' => array(
// The following is a list of your Diablo 2 gameservers. Add as many entries
// as you need, with a comma (,) after each one. Make sure you have
// quotes '' around each IP address.
'10.0.0.253',
),
);
// A Diablo 2 realm is considered to be online if:
// The Diablo 2 character server (d2cs) is running,
// the Diablo 2 database server (d2dbs) is running,
// and at least one Diablo 2 gameserver is running.
// ------------------------------------------------------------------------------------------ //
// //
// Configuration finished, no need to change anything below here //
// //
// ------------------------------------------------------------------------------------------ //
$output = "";
if ($pvpgn['check']) {
if ($fp = @fsockopen($pvpgn['ip'], $pvpgn['port'], $errno, $errstr, $timeout)) {
fclose($fp);
$pvpgn_online = true;
$output .= "<p>\n";
$output .= " ".$language['pvpgnonline']."\n";
$output .= "</p>\n";
} else {
$pvpgn_online = false;
$output .= "<p>\n";
$output .= " ".$language['pvpgnoffline']."\n";
$output .= "</p>\n";
}
}
if ($d2realm['check']) {
$d2realm_online = false;
if ($fp = @fsockopen($d2realm['d2cs']['ip'], $d2realm['d2cs']['port'], $errno, $errstr, $timeout)) {
fclose($fp);
if ($fp = @fsockopen($d2realm['d2dbs']['ip'], $d2realm['d2dbs']['port'], $errno, $errstr, $timeout)) {
fclose($fp);
$a = 0;
$b = 0;
foreach ($d2realm['d2gs'] as $ip) {
$a++;
if ($fp = @fsockopen($ip, 4000, $errno, $errstr, $timeout)) {
fclose($fp);
$b++;
$d2realm_online = true;
}
}
}
}
if ($d2realm_online) {
$output .= "<p>\n";
$output .= " ".sprintf($language['d2realmonline'],$b,$a)."\n";
$output .= "</p>\n";
} else {
$output .= "<p>\n";
$output .= " ".$language['d2realmoffline']."\n";
$output .= "</p>\n";
}
}
//echo $output -> $header;
//$ns -> tablerender("PvPGN Status",$output);
// Path to server.dat
// $statusfile = './server.dat';
$statusfile = '/var/www/html/pvpgn/server.dat';
// What info should be shown?
$show = array(
'STATUS' => true,
'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 = "/var/www/html/pvpgn/gameicons";
// Enable profile links?
$profilelink_enable = false;
$profilelink_url = "/pvpgn/index.php"; // URL to pvpgn-stats
// Display the list of users/games/channels side by side rather than in a vertical list?
$sidebyside = false;
// Language constants. Translate into your native language if needed.
$language = array(
'STATUSDETAIL' => 'PvPGN Server Status',
'USERSDETAIL' => 'Users currently online',
'GAMESDETAIL' => 'Games currently online',
'CHANNELSDETAIL' => 'Channels currently online',
'Version' => 'PvPGN version',
'Uptime' => 'Uptime',
'Users' => 'Users',
'Games' => 'Games',
'Channels' => 'Channels',
'UserAccounts' => 'User accounts',
'none' => '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']."\">".$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;
$ns -> tablerender("PvPGN Status",$output);
?>