MyBB Community Forums

Full Version: Who was online on main index?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hey guys i just want to know if it's possible if i can put the list of users who were online today stat on the main index page at the bottom in the board statistics? Is it possible? If so how can it be done?
Curious as well.
Open index.php.
Before...
	eval("\$whosonline = \"".$templates->get("index_whosonline")."\";");
Add...
	$stime = time()-(60*60*24);
	$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");
	$todaycomma = '';
	$onlinetoday = '';
	while($online = $db->fetch_array($query))
	{
		if($online['invisible'] != "yes" || $mybb->usergroup['canviewwolinvis'] == "yes")
		{
			if($online['invisible'] == "yes")
			{
				$invisiblemark = "*";
			}
			else
			{
				$invisiblemark = "";
			}
			$onlinetoday .= $todaycomma.formatname($online['username'], $online['usergroup'], $online['displaygroup']).$invisiblemark;
			$todaycomma = ', ';
		}
	}

Then go into the template manager in the Admin CP, and find the index_whosonline template, and add the $onlinetoday variable where you want the list added
Tried adding that to index.php and got the following error on a white page when going to my forum:

mySQL error: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY u.lastactive DESC' at line 1
Query: SELECT u.* FROM mybb_users u LEFT JOIN mybb_usergroups g ON (g.gid=u.usergroup) WHERE u.lastactive > ORDER BY u.lastactive DESC
yeah i got that mysql error too, i panicked and replaced the Index php file with a back up. I wont try that again unless there is more modifictions if we can get this to work.
No worries.
-I'm sure DennisTT or someone else will be able to help out.
I got this message also;

mySQL error: 1064
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY u.lastactive DESC' at line 1
Query: SELECT u.* FROM mybb_users u LEFT JOIN mybb_usergroups g ON (g.gid=u.usergroup) WHERE u.lastactive > ORDER BY u.lastactive DESC
I tried having a go at playing around with the last bit of the line and see if i could get it to work. I think its the first part that you add to the Index Page, apparently there is a syntax error according to MYSQL. Perhap there is an error somewhere in therE? It doesnt look like it was coming from the index_online template at all.
Looks like there's just some missing code. This should be the first line of the code that DennisTT posted...
$stime = time()-(60*60*24);
Thanks WDZ. I updated my code above to suit.
Pages: 1 2 3