MyBB Hacks

Full Version: More online users list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Here is the code that is displaying only 14 online users per line and starting the next list new line, leaving extra spaces as in pic.

Code:
<?php

/*////////////////////////////////////////////////////////////////////
 * Displays Who's Online Today On Board Statistics On The Forum Index
 * Displays who was online today on the forum index.
 *////////////////////////////////////////////////////////////////////

$plugins->add_hook('index_start', 'who_online');

function who_online_info()
{
	return array(
		'name'			=> 'Who Was Online Today ?',
		'description'	=> 'Displays who was online today on forum index (Board Stats',
		'website'		=> 'http://mybbextras.com',
		'author'		=> 'Janota',
		'authorsite'	=> 'http://mybbextras.com',
		'version'		=> '1.0',
		"compatibility" => "16*"

	);
}


function who_online_activate()
{
	global $db;


}

function who_online()
{
	global $db,$ontoday,$lang,$theme, $mybb, $templates;
	$lang->load("online");
$todaycount = 0;
	$stime = TIME_NOW-(60*60*24);
	$todayrows = '';
	$query = $db->query("
		SELECT u.*
		FROM ".TABLE_PREFIX."users u
		LEFT JOIN ".TABLE_PREFIX."usergroups g ON (g.gid=u.usergroup)
		WHERE u.lastactive > $stime
		ORDER BY u.lastactive DESC
	");
	$total=$db->num_rows($query);
	$i=1;
	$x=0;
	while($online = $db->fetch_array($query))
	{
		if($online['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $online['uid'] == $mybb->user['uid'])
		{
			if($online['invisible'] == 1)
			{
				$invisiblemark = "*";
			}
			else
			{
				$invisiblemark = "";
			}
			$username = $online['username'];
			$username = format_name($username, $online['usergroup'], $online['displaygroup']);
			$online['profilelink'] = build_profile_link($username, $online['uid']);
			$onlinetime = my_date($mybb->settings['timeformat'], $online['lastactive']);
			$onToday.=$online['profilelink'];
		}

		if ($i != $total)
		{
		$onToday.=", ";
		}
		if ($x == 14)
		{
			$onToday.="<br/>";
			$x=0;
}
		$x++;
		$i++;
		++$todaycount;
	}
	if($todaycount == 1)
	{
		$who_online = $lang->member_online_today;
	}
	else
	{
		$who_online = $lang->sprintf($lang->members_were_online_today, $todaycount);
	}

        if(in_array($GLOBALS['mybb']->user['usergroup'], array(3,4,6))) 
        {
	$ontoday=<<<HERE
<td class="trow1"><a href="/forum/online.php?action=today" target="_blank"><img src="./images/oll.png" title="" class="statistics" style="float:left; height:38px; margin-right:5px; padding:8px; width:38px;"/></a>
<span class="smalltext">{$who_online}</span><br />$onToday
</td>
</tr>
HERE;
        }
        else
        {
        $ontoday=<<<HERE
<td class="trow1"><img src="./images/oll.png" title="" class="statistics" style="float:left; height:38px; margin-right:5px; padding:8px; width:38px;"/>
<span class="smalltext">{$who_online}</span><br />$onToday
</td>
</tr>
HERE;
        }

}

function who_online_deactivate()
{

}


?>


How can we make it display the whole available online users without any link breaks?

[attachment=256]


is it possible that it increments the counter for every member that comes to online and display the who users online list without breaking?
You want to make a limit of users ? If yes, You have to use query something like this query;

PHP Code:
	$query = $db->query("
		SELECT u.*
		FROM ".TABLE_PREFIX."users u
		LEFT JOIN ".TABLE_PREFIX."usergroups g ON (g.gid=u.usergroup)
		WHERE u.lastactive > $stime
		ORDER BY u.lastactive DESC
LIMIT ".$mybb->settings['how_many_users']."");
	");

no, i dont want to limit users for now, i just want to display whole users list without breaking lines as in picture after every 14 users
For this, search <br /> in the code and remove it. e.g. this one;

PHP Code:
	$ontoday=<<<HERE
<td class="trow1"><a href="/forum/online.php?action=today" target="_blank"><img src="./images/oll.png" title="" class="statistics" style="float:left; height:38px; margin-right:5px; padding:8px; width:38px;"/></a>
<span class="smalltext">{$who_online}</span><br />$onToday
</td>
</tr>
HERE;
        }
        else
        {
        $ontoday=<<<HERE
<td class="trow1"><img src="./images/oll.png" title="" class="statistics" style="float:left; height:38px; margin-right:5px; padding:8px; width:38px;"/>
<span class="smalltext">{$who_online}</span><br />$onToday
</td>
</tr>
HERE;

this will make the users displayed right after the  "- members online today" text without a line break.
i'm not asking this. if you see yellow circles, they appear because, after 14users display in single or 2 lines, the remaining space doesnt display usernames, and it starts in next line with fresh 14 users list. now i want to display users list uninterruptedly.
i figured out that increasing this value (14) in the code "if ($x == 14)" displays that many numbers without any break. but without setting this value to high, is their anyway that it automatically increases the counter and displays the whole users list?
i figured out that this code controls the display of online users

Code:
		if ($x == 14)
		{
			$onToday.="<br/>";
			$x=0;
}

Changing the $x== 14 value is displaying that many online users, suppose if it is $x==100, then it is displaying 100 online users continuosly without line breaks. But if there is also some space after 100th member, the 101th member if being displayed in next line leaving a huge gap like in first post attachment image. Now i want that value to be incremented automatically to show the full online users display without any line breaks. If users are 220, it must all 220 or 300 must show all 300 without any line breaks.

How about just removing that piece of code? Tongue
ahh..... being an IT student i failed to check that "if" clause. my bad. thank you very much yumi.
problem fixed
How can it show title for online members? . for example: in mouse over show "last visit:9:40 AM" Thanks.
{$onlinetime} or {$onlinedate}
Reference URL's