• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Who is Online - Gesior Acc

Gabriel Tibiano

New Member
Joined
Nov 21, 2009
Messages
420
Reaction score
4
Hi..
can someone fix that for me?
that's not appears PLAYER_ONLINE tag at the top right of the site.

topzq.png

Whoisonline.php

PHP:
<?PHP
if ($_REQUEST['world'] == ''){
$worldtype = $config['server']['worldType'];
if ($worldtype == 'pvp')
         $world .= 'PvP';
if ($worldtype == 'non-pvp')
         $world .= 'Non-PvP';
if ($worldtype == 'pvp-enforced')
         $world .= 'PvP-Enforced';
$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>World</B></TD><TD ALIGN=center CLASS=white><B>Players Online</B></TD><TD ALIGN=center CLASS=white><B>Additional Information</B></TD></TR>';
	foreach($config['site']['worlds'] as $id => $world_n)
	{
		if(is_int($worlds / 2))
			$bgcolor = $config['site']['darkborder'];
		else
			$bgcolor = $config['site']['lightborder'];
			$worlds++;
		$main_content .= '<TR BGCOLOR='.$bgcolor.'><TD WIDTH=140><a href="?subtopic=whoisonline&world='.$id.'">'.$world_n.'</a></TD><TD WIDTH=140 ALIGN=center>'.$config['status']['serverStatus_players'].'</TD><TD ALIGN=center>'.$world.'</TD></TR>';
	}

$main_content .= '</table>';
}
else {
if($id == (int) $_GET['world'])
{
	$world_id = $id;
	$world_name = $world_n;
}
if(!isset($world_id))
{
	$world_id = 0;
	$world_name = $config['server']['serverName'];
}
$order = $_REQUEST['order'];
if($order == 'level')
	$orderby = 'level';
elseif($order == 'vocation')
	$orderby = 'vocation';
if(empty($orderby))
	$orderby = 'name';
$players_online_data = $SQL->query('SELECT * FROM players WHERE world_id = '.(int) $world_id.' AND online = 1 ORDER BY '.$orderby);
$number_of_players_online = 0;
foreach($players_online_data as $player) {
	$number_of_players_online++;
	if(is_int($number_of_players_online / 2))
		$bgcolor = $config['site']['darkborder'];
	else
		$bgcolor = $config['site']['lightborder'];
	$players_rows .= '<TR BGCOLOR='.$bgcolor.'><TD WIDTH=70%><A HREF="?subtopic=characters&name='.urlencode($player['name']).'">'.$player['name'].'</A></TD><TD WIDTH=10%>'.$player['level'].'</TD><TD WIDTH=20%>'.$vocation_name[$world_id][$player['promotion']][$player['vocation']].'</TD></TR>';
}
if($number_of_players_online == 0)
	//server status - server empty
	$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><B>Server Status</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1><TR><TD>Currently no one is playing on <b>'.$config['site']['worlds'][$_REQUEST['world']].'</b>.</TD></TR></TABLE></TD></TR></TABLE><BR>';
else
{
	//server status - someone is online
	$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><B>Server Status</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1><TR><TD>Currently '.$number_of_players_online.' players are online on <b>'.$config['site']['worlds'][$_REQUEST['world']].'</b>.</TD></TR></TABLE></TD></TR></TABLE><BR>';
	//list of players
	$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD><A HREF="?subtopic=whoisonline&world='.$_REQUEST['world'].'&order=name" CLASS=white>Name</A></TD><TD><A HREF="?subtopic=whoisonline&world='.$_REQUEST['world'].'&order=level" CLASS=white>Level</A></TD><TD><A HREF="?subtopic=whoisonline&world='.$_REQUEST['world'].'&order=vocation" CLASS=white>Vocation</TD></TR>'.$players_rows.'</TABLE>';
	//search bar
	$main_content .= '<BR><FORM ACTION="?subtopic=characters" METHOD=post>  <TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4><TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" CLASS=white><B>Search Character</B></TD></TR><TR><TD BGCOLOR="'.$config['site']['darkborder'].'"><TABLE BORDER=0 CELLPADDING=1><TR><TD>Name:</TD><TD><INPUT NAME="name" VALUE=""SIZE=29 MAXLENGTH=29></TD><TD><INPUT TYPE=image NAME="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18></TD></TR></TABLE></TD></TR></TABLE></FORM>';
}
}
?>


Layout.php

Code:
<a href='index.php?subtopic=whoisonline'>
<div id='submenu_whoisonline' class='Submenuitem' onMouseOver='MouseOverSubmenuItem(this)' onMouseOut='MouseOutSubmenuItem(this)'>
<div class='LeftChain' style='background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);'></div>
<div id='ActiveSubmenuItemIcon_whoisonline' class='ActiveSubmenuItemIcon' style='background-image:url(<?PHP echo $layout_name; ?>/images/menu/icon-activesubmenu.gif);'></div>
<div class='SubmenuitemLabel'>Who Is Online?</div>
<div class='RightChain' style='background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);'></div>
</div>
</a>

--------------------- Second Piece

<div id="ThemeboxesColumn">
 <div id="RightArtwork">
 <img id="Monster" src="monsters/<?PHP echo logo_monster() ?>.gif" onClick="window.location = 'index.php?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 = 'index.php?subtopic=whoisonline'">
<?PHP
if($config['status']['serverStatus_online'] == 1)
echo $config['status']['serverStatus_players'].'<br />Players Online';
else
echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
?></div>
</div>

<div id="Themeboxes">



REPP++
 
Last edited:
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"/>
		  <?PHP
		  if(count($config['site']['worlds']) > 1)
			  $whoisonlineworld = '?subtopic=whoisonline'; 
		  else
			  $whoisonlineworld = '?subtopic=whoisonline&world=0';
		  ?>
             <div id="PlayersOnline" onClick="window.location='<?PHP echo $whoisonlineworld; ?>'">

		  <?PHP
			if($config['status']['serverStatus_online'] == 1)
				echo $config['status']['serverStatus_players'].'<br />Players Online';
			else
				echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
		  ?></div>
        </div>

  <div id="Themeboxes">
 
layout.php

PHP:
<a href='index.php?subtopic=whoisonline'>
<div id='submenu_whoisonline' class='Submenuitem' onMouseOver='MouseOverSubmenuItem(this)' onMouseOut='MouseOutSubmenuItem(this)'>
<div class='LeftChain' style='background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);'></div>
<div id='ActiveSubmenuItemIcon_whoisonline' class='ActiveSubmenuItemIcon' style='background-image:url(<?PHP echo $layout_name; ?>/images/menu/icon-activesubmenu.gif);'></div>
<div class='SubmenuitemLabel'>Who Is Online?</div>
<div class='RightChain' style='background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);'></div>
</div>
</a>

--------------------- Second Piece

<div id="ThemeboxesColumn">
 <div id="RightArtwork">
 <img id="Monster" src="monsters/<?PHP echo logo_monster() ?>.gif" onClick="window.location = 'index.php?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 = 'index.php?subtopic=whoisonline'">
		  <?PHP
			if($config['status']['serverStatus_online'] == 1)
				echo $config['status']['serverStatus_players'].'<br />Players Online';
			else
				echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
		  ?></div>
        </div>

<div id="Themeboxes">
 
Bring
Up
My
Post


config-and-funcions.php

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("127.0.0.1", $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);
}
 
Yes i got this, but how to add this 'debug code'?

LUA:
loginPort = 7171
gamePort = 7172
adminPort = 7171
statusPort = 7171
loginTries = 10
retryTimeout = 5 * 1000
loginTimeout = 60 * 1000
maxPlayers = 3000
 
I'm sorry if I'm being stupid, but ..
where do I put this code?

could edit for me @Cyko :DD!


LUA:
loginPort = 7171
gamePort = 7172
adminPort = 7171
statusPort = 7171
loginTries = 10
retryTimeout = 5 * 1000
loginTimeout = 60 * 1000
maxPlayers = 3000


config and functions.php


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("127.0.0.1", $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);
}


layout.php

PHP:
<a href='index.php?subtopic=whoisonline'>
<div id='submenu_whoisonline' class='Submenuitem' onMouseOver='MouseOverSubmenuItem(this)' onMouseOut='MouseOutSubmenuItem(this)'>
<div class='LeftChain' style='background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);'></div>
<div id='ActiveSubmenuItemIcon_whoisonline' class='ActiveSubmenuItemIcon' style='background-image:url(<?PHP echo $layout_name; ?>/images/menu/icon-activesubmenu.gif);'></div>
<div class='SubmenuitemLabel'>Who Is Online?</div>
<div class='RightChain' style='background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);'></div>
</div>
</a>

--------------------- Second Piece

<div id="ThemeboxesColumn">
 <div id="RightArtwork">
 <img id="Monster" src="monsters/<?PHP echo logo_monster() ?>.gif" onClick="window.location = 'index.php?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 = 'index.php?subtopic=whoisonline'">
<?PHP
if($config['status']['serverStatus_online'] == 1)
echo $config['status']['serverStatus_players'].'<br />Players Online';
else
echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
?></div>
</div>

<div id="Themeboxes">
 
Code:
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.1", $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);
}

echo '<font color="white">'.var_dump($config['status']).'</font>';
 
returning an error

PHP:
array(10) { ["serverStatus_checkInterval"]=> int(3) ["serverStatus_lastCheck"]=> int(1303398563) ["serverStatus_online"]=> int(1) ["serverStatus_players"]=> NULL ["serverStatus_playersMax"]=> NULL ["serverStatus_uptime"]=> string(5) "0h 0m" ["serverStatus_monsters"]=> NULL ["serverStatus_npc"]=> string(1) "0" ["serverStatus_npcs"]=> string(0) "" ["npcs"]=> string(0) "" }

and still not working ;\\
 
that's not an error. it works once every 5 minutes, and then it fails to save the data it fetched into /config/serverstatus
Sweddy had a similar problem, but on Linux. Make sure the file serverstatus exists and is writable
 
Back
Top