MyBB Community Forums

Full Version: show online now
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Yes, done that and still can't see it. Sad
Where is your page located ? If it is outside the forum's folder then there would be index.php file path's issue.
The page is located at example.com/index.php and the forum is located at example.com/topics/index.php

Try this;
<?php
define("IN_MYBB", 1);
require_once ('http://example.com/topics/global.php');
require_once ('http://example.com/topics/index.php');
echo $whosonline;
?>

Change http://example.com/topics/ to the correct forum's path.
Ok, tried that, I just get a blank page.
(2011-08-03, 12:22 AM)Yaldaram Wrote: [ -> ]Try this;
<?php
define("IN_MYBB", 1);
require_once ('http://example.com/topics/global.php');
require_once ('http://example.com/topics/index.php');
echo $whosonline;
?>

Change http://example.com/topics/ to the correct forum's path.

Erm, that wouldn't work.

You could just take the who's online code from index.php and put it in your custom page.
Would it be this?

// Build the who's online bit on the index page.
	$onlinecount = $membercount + $guestcount + $botcount;
	
	if($onlinecount != 1)
	{
		$onlinebit = $lang->online_online_plural;
	}
	else
	{
		$onlinebit = $lang->online_online_singular;
	}
	if($membercount != 1)
	{
		$memberbit = $lang->online_member_plural;
	}
	else
	{
		$memberbit = $lang->online_member_singular;
	}
	if($anoncount != 1)
	{
		$anonbit = $lang->online_anon_plural;
	}
	else
	{
		$anonbit = $lang->online_anon_singular;
	}
	if($guestcount != 1)
	{
		$guestbit = $lang->online_guest_plural;
	}
	else
	{
		$guestbit = $lang->online_guest_singular;
	}
	$lang->online_note = $lang->sprintf($lang->online_note, my_number_format($onlinecount), $onlinebit, $mybb->settings['wolcutoffmins'], my_number_format($membercount), $memberbit, my_number_format($anoncount), $anonbit, my_number_format($guestcount), $guestbit);
	eval("\$whosonline = \"".$templates->get("index_whosonline")."\";");
}

OR

// Get the online users.
	$timesearch = TIME_NOW - $mybb->settings['wolcutoff'];
	$comma = '';
	$query = $db->query("
		SELECT s.sid, s.ip, s.uid, s.time, s.location, s.location1, u.username, u.invisible, u.usergroup, u.displaygroup
		FROM ".TABLE_PREFIX."sessions s
		LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
		WHERE s.time>'$timesearch'
		ORDER BY u.username ASC, s.time DESC
	");

	$forum_viewers = array();
	$membercount = 0;
	$onlinemembers = '';
	$guestcount = 0;
	$anoncount = 0;
	$doneusers = array();
Pages: 1 2