MyBB Community Forums

Full Version: MediaWiki and MyBB online users
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,

I wanted that when people go to my main site (a mediawiki site), they are added to the MyBB online list. So, I added the following code to a new file in the Mediawiki index, wikiline.php:

define("IN_MYBB", 1);
require './global.php';

if($mybb->settings['showwol'] != "no" && $mybb->usergroup['canviewonline'] != "no")
{
	// Get the online users.
	$timesearch = time() - $mybb->settings['wolcutoffmins']*60;
	$comma = '';
	$query = $db->query("
		SELECT s.sid, s.ip, s.uid, s.time, s.location, 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
	");
	$membercount = 0;
	$onlinemembers = '';
	$guestcount = 0;
	$anoncount = 0;
	$doneusers = array();

	// Loop through all users.
	while($user = $db->fetch_array($query))
	{
		// Create a key to test if this user is a search bot.
		$botkey = strtolower(str_replace("bot=", '', $user['sid']));

		// Decide what type of user we are dealing with.
		if($user['uid'] > 0)
		{
			// The user is registered.
			if($doneusers[$user['uid']] < $user['time'] || !$doneusers[$user['uid']])
			{
				// If the user is logged in anonymously, update the count for that.
				if($user['invisible'] == "yes")
				{
					++$anoncount;
				}
				++$membercount;
				if($user['invisible'] != "yes" || $mybb->usergroup['canviewwolinvis'] == "yes" || $user['uid'] == $mybb->user['uid'])
				{
					// If this usergroup can see anonymously logged-in users, mark them.
					if($user['invisible'] == "yes")
					{
						$invisiblemark = "*";
					}
					else
					{
						$invisiblemark = '';
					}

					// Properly format the username and assign the template.
					$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
					eval("\$onlinemembers .= \"".$templates->get("index_whosonline_memberbit", 1, 0)."\";");
					$comma = ", ";
				}
				// This user has been handled.
				$doneusers[$user['uid']] = $user['time'];
			}
		}
		elseif(strstr($user['sid'], "bot=") !== false && $session->bots[$botkey])
		{
			// The user is a search bot.
			$onlinemembers .= $comma.format_name($session->bots[$botkey], $session->botgroup);
			$comma = ", ";
			++$botcount;
		}
		else
		{
			// The user is a guest.
			++$guestcount;
		}
	}
	}

And require('./forums/wikiline.php'); to the wiki skin file in /skins/modobook.php

But I'm getting:

Warning: include(./global.php) [function.include]: failed to open stream: No such file or directory in /home/coolguy/public_html/forums/wikiline.php on line 4

Warning: include() [function.include]: Failed opening './global.php' for inclusion (include_path='/home/coolguy/public_html:/home/coolguy/public_html/includes:/home/coolguy/public_html/languages:.:/usr/local/php5/lib/php') in /home/coolguy/public_html/forums/wikiline.php on line 4

Fatal error: Call to a member function query() on a non-object in /home/coolguy/public_html/forums/wikiline.php on line 11
Right here is your problem, it looks like:

define("IN_MYBB", 1);
require './forums/global.php';

MediaWiki is out in the root directory, your forum is under /forums
So, when you place the code in the MediaWiki index.php file, you are telling that function to go back yet another folder to find /forums/global.php

I would try removing the ./ in front of forums, and mess around with it like that.

Dr Small