• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Summary server status on Multiworld

TomCrusher

Jeg er ingenting
Joined
Dec 31, 2008
Messages
663
Reaction score
19
Location
Norway
Hello, I'm nevbie in the php scripting but I maked some modifications on Gesior Accmaker and I have summary status under monster pedestal from two servers.
You can check on:
Fire-Magma OTS Who is online?


So begin>>>

1. First open your www/config/config.ini file and change to:
PHP:
install = "no"
server_path = "first server"
server_path1 = "second server"
signatures = "1"

2. Next into this folder www/config/ copy "serverstatus" file and rename it to "serverstatus1"

3.Go to www folder and find config-and-function.php open it and replace:

PHP:
//load server config
$config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
$config['server1'] = parse_ini_file($config['site']['server_path1'].'config.lua');

after in the same file find and replace:

PHP:
//set monster of week
function logo_monster() {
	return str_replace(" ", "", trim(mb_strtolower($GLOBALS['layout_ini']['logo_monster'])));
}
$statustimeout = 1;
foreach(explode("*", str_replace(" ", "", $config['server']['statusTimeout'])) as $status_var)
	if($status_var > 0)
		$statustimeout = $statustimeout * $status_var;
$statustimeout = $statustimeout / 1000;
$config['status'] = parse_ini_file('config/serverstatus');
if($config['status']['serverStatus_lastCheck']+$statustimeout < time())
{
	$config['status']['serverStatus_checkInterval'] = $statustimeout+3;
	$config['status']['serverStatus_lastCheck'] = time();
	$info = chr(6).chr(0).chr(255).chr(255).'info';
	$sock = @fsockopen("127.0.0.0", $config['server']['statusPort'], $errno, $errstr, 1);
	if ($sock)
	{
		fwrite($sock, $info); 
		$data=''; 
		while (!feof($sock))
			$data .= fgets($sock, 1024);
		fclose($sock);
		preg_match('/players online="(\d+)" max="(\d+)"/', $data, $matches);
		$config['status']['serverStatus_online'] = 1;
		$config['status']['serverStatus_players'] = $matches[1];
		$config['status']['serverStatus_playersMax'] = $matches[2];
		preg_match('/uptime="(\d+)"/', $data, $matches);
		$h = floor($matches[1] / 3600);
		$m = floor(($matches[1] - $h*3600) / 60);
		$config['status']['serverStatus_uptime'] = $h.'h '.$m.'m';
		preg_match('/monsters total="(\d+)"/', $data, $matches);
		$config['status']['serverStatus_monsters'] = $matches[1];
	}
	else
	{
		$config['status']['serverStatus_online'] = 0;
		$config['status']['serverStatus_players'] = 0;
		$config['status']['serverStatus_playersMax'] = 0;
	}
	$file = fopen("config/serverstatus", "w");
	foreach($config['status'] as $param => $data)
	{
$file_data .= $param.' = "'.str_replace('"', '', $data).'"
';
	}
	rewind($file);
	fwrite($file, $file_data);
	fclose($file);
// do server file 2

$status1timeout = 1;
foreach(explode("*", str_replace(" ", "", $config['server1']['statusTimeout'])) as $status1_var)
	if($status1_var > 0)
		$status1timeout = $status1timeout * $status1_var;
$status1timeout = $status1timeout / 500;
$config['status1'] = parse_ini_file('config/serverstatus1');
if($config['status1']['serverStatus1_lastCheck']+$status1timeout < time())
{
	$config['status1']['serverStatus1_checkInterval'] = $status1timeout+3;
	$config['status1']['serverStatus1_lastCheck'] = time();
	$info = chr(6).chr(0).chr(255).chr(255).'info';
	$sock = @fsockopen("127.0.0.0", $config['server1']['statusPort'], $errno, $errstr, 1);
	if ($sock)
	{
		fwrite($sock, $info); 
		$data=''; 
		while (!feof($sock))
			$data .= fgets($sock, 1024);
		fclose($sock);
		preg_match('/players online="(\d+)" max="(\d+)"/', $data, $matches);
		$config['status1']['serverStatus1_online'] = 1;
		$config['status1']['serverStatus1_players'] = $matches[1];
		$config['status1']['serverStatus1_playersMax'] = $matches[2];
		preg_match('/uptime="(\d+)"/', $data, $matches);
		$h = floor($matches[1] / 3600);
		$m = floor(($matches[1] - $h*3600) / 60);
		$config['status1']['serverStatus1_uptime'] = $h.'h '.$m.'m';
		preg_match('/monsters total="(\d+)"/', $data, $matches);
		$config['status1']['serverStatus1_monsters'] = $matches[1];

	}
	else
	{
		$config['status1']['serverStatus1_online'] = 0;
		$config['status1']['serverStatus1_players'] = 0;
		$config['status1']['serverStatus1_playersMax'] = 0;
	}
	$file1 = fopen("config/serverstatus1", "w");
	foreach($config['status1'] as $param => $data)
	{
$file1_data .= $param.' = "'.str_replace('"', '', $data).'"
';
	}
	rewind($file1);
	fwrite($file1, $file1_data);
	fclose($file1);

}

4. End last modification in www/layouts/tibiacom/layout.php find and replace:

PHP:
        <div id="ThemeboxesColumn">
          <div id="RightArtwork">
            <img id="Monster" src="monsters/<?PHP echo logo_monster() ?>.gif" onClick="window.location = '?subtopic=creatures&amp;creature=<?PHP echo logo_monster() ?>';" alt="Monster of the Week" />
            <img id="PedestalAndOnline" src="<?PHP echo $layout_name; ?>/images/header/pedestal-and-online.gif" alt="Monster Pedestal and Players Online Box"/>
          <div id="PlayersOnline" onClick="window.location = '?subtopic=whoisonline'">
		  <?PHP
$config['status1'] = parse_ini_file('config/serverstatus1');
			if($config['status']['serverStatus_online'] == 1) 
				echo $config['status']['serverStatus_players']+$config['status1']['serverStatus1_players'].'/'.$config['status']['serverStatus_playersMax'].'<br />Uptime:'.$config['status']['serverStatus_uptime'].'';
			else
				echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
			?></div>
        </div>

And DONE...

If have you another idea only post here, this modifications work for me. :thumbup:
 
nice
I have a question on how to make a list of records online.

Hello you need to replace:

1. In config-and-functions.php this:

PHP:
function logo_monster() {
	return str_replace(" ", "", trim(mb_strtolower($GLOBALS['layout_ini']['logo_monster'])));
}
$statustimeout = 1;
foreach(explode("*", str_replace(" ", "", $config['server']['statusTimeout'])) as $status_var)
	if($status_var > 0)
		$statustimeout = $statustimeout * $status_var;
$statustimeout = $statustimeout / 1000;
$config['status'] = parse_ini_file('config/serverstatus');
if($config['status']['serverStatus_lastCheck']+$statustimeout < time())
{
	$config['status']['serverStatus_checkInterval'] = $statustimeout+3;
	$config['status']['serverStatus_lastCheck'] = time();
	$info = chr(6).chr(0).chr(255).chr(255).'info';
	$sock = @fsockopen("94.23.61.186", $config['server']['statusPort'], $errno, $errstr, 1);
	if ($sock)
	{
		fwrite($sock, $info); 
		$data=''; 
		while (!feof($sock))
			$data .= fgets($sock, 1024);
		fclose($sock);
		preg_match('/players online="(\d+)" max="(\d+)" peak="(\d+)"/', $data, $matches);
		$config['status']['serverStatus_online'] = 1;
		$config['status']['serverStatus_players'] = $matches[1];
		$config['status']['serverStatus_playersMax'] = $matches[2];
		$config['status']['serverStatus_playersPeak'] = $matches[3];
		preg_match('/uptime="(\d+)"/', $data, $matches);
		$h = floor($matches[1] / 3600);
		$m = floor(($matches[1] - $h*3600) / 60);
		$config['status']['serverStatus_uptime'] = $h.'h '.$m.'m';
		preg_match('/monsters total="(\d+)"/', $data, $matches);
		$config['status']['serverStatus_monsters'] = $matches[1];
	}
	else
	{
		$config['status']['serverStatus_online'] = 0;
		$config['status']['serverStatus_players'] = 0;
		$config['status']['serverStatus_playersMax'] = 0;
	}
	$file = fopen("config/serverstatus", "w");
	foreach($config['status'] as $param => $data)
	{
$file_data .= $param.' = "'.str_replace('"', '', $data).'"
';
	}
	rewind($file);
	fwrite($file, $file_data);
	fclose($file);
// do server file 2

$status1timeout = 1;
foreach(explode("*", str_replace(" ", "", $config['server1']['statusTimeout'])) as $status1_var)
	if($status1_var > 0)
		$status1timeout = $status1timeout * $status1_var;
$status1timeout = $status1timeout / 500;
$config['status1'] = parse_ini_file('config/serverstatus1');
if($config['status1']['serverStatus1_lastCheck']+$status1timeout < time())
{
	$config['status1']['serverStatus1_checkInterval'] = $status1timeout+3;
	$config['status1']['serverStatus1_lastCheck'] = time();
	$info = chr(6).chr(0).chr(255).chr(255).'info';
	$sock = @fsockopen("94.23.61.186", $config['server1']['statusPort'], $errno, $errstr, 1);
	if ($sock)
	{
		fwrite($sock, $info); 
		$data=''; 
		while (!feof($sock))
			$data .= fgets($sock, 1024);
		fclose($sock);
		preg_match('/players online="(\d+)" max="(\d+)" peak="(\d+)"/', $data, $matches);
		$config['status1']['serverStatus1_online'] = 1;
		$config['status1']['serverStatus1_players'] = $matches[1];
		$config['status1']['serverStatus1_playersMax'] = $matches[2];
		$config['status1']['serverStatus1_playersPeak'] = $matches[3];
		preg_match('/uptime="(\d+)"/', $data, $matches);
		$h = floor($matches[1] / 3600);
		$m = floor(($matches[1] - $h*3600) / 60);
		$config['status1']['serverStatus1_uptime'] = $h.'h '.$m.'m';
		preg_match('/monsters total="(\d+)"/', $data, $matches);
		$config['status1']['serverStatus1_monsters'] = $matches[1];
	}
	else
	{
		$config['status1']['serverStatus1_online'] = 0;
		$config['status1']['serverStatus1_players'] = 0;
		$config['status1']['serverStatus1_playersMax'] = 0;
	}
	$file1 = fopen("config/serverstatus1", "w");
	foreach($config['status1'] as $param => $data)
	{
$file1_data .= $param.' = "'.str_replace('"', '', $data).'"
';
	}
	rewind($file1);
	fwrite($file1, $file1_data);
	fclose($file1);

}
}

2. and into layout.php this:

PHP:
        <div id="ThemeboxesColumn">
          <div id="RightArtwork">
            <img id="Monster" src="monsters/<?PHP echo logo_monster() ?>.gif" onClick="window.location = '?subtopic=creatures&amp;creature=<?PHP echo logo_monster() ?>';" alt="Monster of the Week" />
            <img id="PedestalAndOnline" src="<?PHP echo $layout_name; ?>/images/header/pedestal-and-online.gif" alt="Monster Pedestal and Players Online Box"/>
          <div id="PlayersOnline" onClick="window.location = '?subtopic=whoisonline'">
		  <?PHP
$config['status1'] = parse_ini_file('config/serverstatus1');
			if($config['status']['serverStatus_online'] == 1) 
				echo $config['status']['serverStatus_players']+$config['status1']['serverStatus1_players'].'/'.$config['status']['serverStatus_playersPeak'].'<br />Uptime:'.$config['status']['serverStatus_uptime'].'';
			else
				echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
			?></div>
        </div>

You welcome.:)
 
-.-
PHP:
Parse error: parse error in C:\xampp\htdocs\config-and-functions.php on line 461

why? I have tfs 0.2/8.42
followed all tutorials fine any help?
 
EDIT@UP: already fixed
 
Back
Top