Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 9 Years, 2 Months, 2 Weeks ago How do I disable bot views?
#1
Solved: 9 Years, 2 Months, 2 Weeks ago
On my board I only have 3 members but on every thread there are 70 to 100 views. I think that I know the problem. I think when the bots navigate the board it is registering the views from them which is making the view skyrocket! How do I disable this?
#2
Solved: 9 Years, 2 Months, 2 Weeks ago
It'll require a core edit. I wrote a tutorial for it a few years ago but I can't seem to find it back. Luckily I still have it on my hard drive.

Open showthread.php with a text editor, find:

if($mybb->settings['delayedthreadviews'] == 1)
{
$db->shutdown_query("INSERT INTO ".TABLE_PREFIX."threadviews (tid) VALUES('{$tid}')");
}
else
{
$db->shutdown_query("UPDATE ".TABLE_PREFIX."threads SET views=views+1 WHERE tid='{$tid}'");
}

and replace with:

if($mybb->settings['delayedthreadviews'] == 1 && $session->is_spider == false)
{
$db->shutdown_query("INSERT INTO ".TABLE_PREFIX."threadviews (tid) VALUES('{$tid}')");
}
elseif($session->is_spider == false)
{
$db->shutdown_query("UPDATE ".TABLE_PREFIX."threads SET views=views+1 WHERE tid='{$tid}'");
}
No longer involved in the MyBB project.
#3
Solved: 9 Years, 2 Months, 2 Weeks ago
Nice one, so guests will not affect the view counter, thanks for it.
#4
Solved: 9 Years, 2 Months, 2 Weeks ago
(2012-07-09, 09:49 PM)Omar G. Wrote: Nice one, so guests will not affect the view counter, thanks for it.

Guests will, spiders which are on the spiders and bots list won't. Smile
No longer involved in the MyBB project.
#5
Solved: 9 Years, 2 Months, 2 Weeks ago
Oh, you are right ... suppose that will be enough then. Guests are "real" members compared to spiders. Still going to use it.
#6
Solved: 9 Years, 2 Months, 2 Weeks ago
Thank you for the reply. I did the code edit!
#7
Solved: 9 Years, 2 Months, 2 Weeks ago
If you don't want thread authors to increase the threa views count as well, use this instead of Nathan's code:
if(!$session->is_spider && $mybb->user['uid'] != $thread['uid'])
{
	if($mybb->settings['delayedthreadviews'])
	{
		$db->shutdown_query("INSERT INTO ".TABLE_PREFIX."threadviews (tid) VALUES('{$tid}')");
	}
	else
	{
		$db->shutdown_query("UPDATE ".TABLE_PREFIX."threads SET views=views+1 WHERE tid='{$tid}'");
	}
}
#8
Solved: 9 Years, 2 Months, 2 Weeks ago
thanks for the answers! this could be a new feature for new versions, no?


Forum Jump:


Users browsing this thread: 1 Guest(s)