MyBB Community Forums

Full Version: Remove spiders from forum's count
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
When entering a forum, at the top there is the "User(s) browsing this forum:" and it shows the users and guest count browsing this forum. I know that the guest count also includes the spiders. Can I remove them from the guest count? I have all my spiders/bots in a special group (so that it will never be able to post - only view).
I'm sure a bit of code modification is needed, but I don't know where to look.


Ori...
Admin CP » Templates & Styles » Templates » *you're template* » Forum Display Templates » forumdisplay_usersbrowsing
This will remove ALL guests (or users if I want), not just the spiders/bots (that, as I said, are counted as guests).


Ori...
Can someone direct me of what to do?


Ori...
Please help. I realy don't understand why spiders/bots are, even, counted (and shown to users).
(2009-02-12, 08:03 PM)okitai Wrote: [ -> ]Can someone direct me of what to do?

Ori...

Please be more patient.. Did you try searching?

(2009-02-12, 08:03 PM)okitai Wrote: [ -> ]Please help. I realy don't understand why spiders/bots are, even, counted (and shown to users).
Their counted because the name of the stats are "Who's online?" and bots are technically people who are online..
TomL,
Did you see when I posted first (3 days ago - more then a day old thread will never be answered as it is "pushed" beyond page no. 3). No one answer, except "who rules", and he (as well as you) didn't understand what I want.
I'm not looking to remove spiders/bots count from the "Who's Online" stats (that I already did - with help from you, among others). What I want is to remove the count of spiders/bots from the "User(s) browsing this forum:" on the top of each forum page. The default for MyBB is to count guests and spiders/bots and show both as guests. I only want guest to be counted (and thus shown) as guests (spiders/bots should not be counted in this place).


Ori...
(2009-02-15, 08:36 AM)okitai Wrote: [ -> ]TomL,
Did you see when I posted first (3 days ago - more then a day old thread will never be answered as it is "pushed" beyond page no. 3). No one answer, except "who rules", and he (as well as you) didn't understand what I want.
I'm not looking to remove spiders/bots count from the "Who's Online" stats (that I already did - with help from you, among others). What I want is to remove the count of spiders/bots from the "User(s) browsing this forum:" on the top of each forum page. The default for MyBB is to count guests and spiders/bots and show both as guests. I only want guest to be counted (and thus shown) as guests (spiders/bots should not be counted in this place).


Ori...
I still answered your question correctly, though. Bots+guests are still "users", which is why their counted. I'll have to look into how to remove it and get back to you.

Kind Regards,
TomL
Sorry... It looked to me like you where talking about the "Who's Online" stats.
btw, on the "Who's Online" stats I show guests and spiders/bots in two(2) separate infos.

Ori...
The forum display/view doesn't have the capability to differ guests from spiders. As far as the coding goes, it counts anything that doesn't have a uid as a guest - unfortunately, this includes Bots - from the database.

I'm guessing you'll need to alter the coding in forumdisplay.php. Where it counts $guestcount, you'll need to grab whether the guest is a Bot. Try this: (severely untested, I don't have access to a forum where bots are allowed at the moment)...

In forumdisplay.php, circa line 207, change this:

	$query = $db->query("
		SELECT s.ip, s.uid, u.username, s.time, u.invisible, u.usergroup, u.usergroup, u.displaygroup
		FROM ".TABLE_PREFIX."sessions s
		LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
		WHERE s.time > '$timecut' AND location1='$fid' AND nopermission != 1
		ORDER BY u.username ASC, s.time DESC
	");
	while($user = $db->fetch_array($query))
	{
		if($user['uid'] == 0)
		{
			++$guestcount;
		}
		else
		{

... to ...

	$query = $db->query("
		SELECT s.ip, s.uid, s.sid, u.username, s.time, u.invisible, u.usergroup, u.usergroup, u.displaygroup
		FROM ".TABLE_PREFIX."sessions s
		LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
		WHERE s.time > '$timecut' AND location1='$fid' AND nopermission != 1
		ORDER BY u.username ASC, s.time DESC
	");
	while($user = $db->fetch_array($query))
	{
		if($user['uid'] == 0)
		{
			if(my_strpos($user['sid'], "bot=") !== false)
			{
				$guestcount = $guestcount; // Don't add anything to the guestcount if this is a bot
			}
			else
			{
				++$guestcount; // Add guest to guestcount
			}
		}
		else
		{
Tom.M thanks,
I just tried it and it seems to work. I think you should take all the threads on removing spiders/bots that you (and others) help me do this and combine them into an article. I see that from time to time some MyBB admins do ask about this.
btw, after I'll do some more tests, I'll probably change your code so that admins (and moderators) will see this count (as I did with the "Who's Online).


Ori...
Hopefully people will search if they need something like this - I don't want to actively promote mass-changing of coding for both security reasons and for my sanity... imagine the support requests if everyone started to change core coding that didn't really need to.

Although I don't mind if someone wants to take this and make a tutorial. It is quite simple to make a plugin for this kind of thing though.

Edit: If there's a collection of things that you think would benefit people as a plugin, I'd happily take a look...