MyBB Community Forums

Full Version: Max Post Views Guest by Edson Ordaz question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
are bot and spiders views is affected on these plugin?
Sorry to bump such old post, but i too need answer for same. I have been setting up one of my friends forum and need to be clear on bots / spiders question asked by OP

cheers

EDIT:
Talking about this plugin: http://mods.mybb.com/view/max-post-views-guest

Note: He use Google SEO  from frostschutz

i'm sure plugin will block spiders and bots too [google,baidu etc], since they also use cookies! so how to add exception to bot's - spider's if they are blocked! [plugin mod!]

Plugin code: [stock]
<?php 
$plugins->add_hook("showthread_start", "MaxPostViewsGuest");

function MaxPostViewsGuest_info()
{
	return array(
		"name"			=> "Max Post Views Guest",
		"description"	=> "Limita el numero de post que pueden ver los invitados",
		"website"		=> "mailto:[email protected]",
		"author"		=> "Edson Ordaz developer de SoporteMyBB",
		"authorsite"	=> "mailto:[email protected]",
		'version'		=> '1.0',
		"guid" 			=> "231ea7c6c1e1ca8863a5933f127245f7",
		"compatibility" => "*"
	);
}

function MaxPostViewsGuest_activate()
{
	global $mybb, $db;
	
	$MaxPostViewsGuest = array(
		"gid"			=> "NULL",
		"name"			=> "MPVG",
		"title" 		=> "Max Post Views Guest",
		"description"	=> "Limita el numero de post que pueden ver los invitados",
		"disporder"		=> "0",
		"isdefault"		=> "no",
	);
	$db->insert_query("settinggroups", $MaxPostViewsGuest);
	$gid = $db->insert_id();
	
	$MaxPostViewsGuest_1 = array(
		"name"			=> "MaxPostViewsGuest",
		"title"			=> "Numero de post a ver",
		"description"	=> "ingresa el numero de post maximo a ver los invitados (ingresa 0 para deshabilitar)",
		"optionscode"	=> "text",
		"value"		=> "5",
        "disporder" => "1",
        "gid" => intval($gid),
	);
	
	$MaxPostViewsGuest_2 = array(
		"name"			=> "MaxPostViewsGuest_text",
		"title"			=> "Mensaje de error",
		"description"	=> "ingresa el numero de post maximo a ver los invitados (ingresa 0 para deshabilitar) puedes usar<br />
<b>[MaxPost]</b> Para mostrar el numeor maximo de post que un invitado puede ver<br />
<b>[Registrarse]</b> Para mostrar la palabra Registrarse con link hacia el registro<br />
<b>[iniciar_sesion]</b> Para mostrar la palabra Iniciar sesion con Link hacia el logueo",
		"optionscode"	=> "textarea",
		"value"		=> "Has limitado el maximo numero de post ([MaxPost]) que puedes ver como invitado. Para remover este mensaje debes dar click en [Registrarse] y podras ver todos los post normal!
<br /><br />
Ya eres miembro? Entonces da click en [iniciar_sesion] y se eliminara este mensaje.",
        "disporder" => "2",
        "gid" => intval($gid),
	);
	$db->insert_query("settings",$MaxPostViewsGuest_1);
	$db->insert_query("settings",$MaxPostViewsGuest_2);

  rebuild_settings();

}

function MaxPostViewsGuest_deactivate()
{
	global $db;
	$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='MPVG'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='MaxPostViewsGuest'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='MaxPostViewsGuest_text'");

  rebuild_settings();
}

function MaxPostViewsGuest()
{
	global $mybb;
	
 if($mybb->user['usergroup'] != "1" || !$mybb->settings['MaxPostViewsGuest'])
	return;
	$text_error = $mybb->settings['MaxPostViewsGuest_text'];
	if(!isset($mybb->cookies['MaxPostViewsGuest']))
	{
		my_setcookie("MaxPostViewsGuest", "1");
	}
	else
	{
		$MaxPostViewsGuest = $mybb->cookies['MaxPostViewsGuest'] + 1;
		my_setcookie("MaxPostViewsGuest", $MaxPostViewsGuest);
	}
	
	if($mybb->cookies['MaxPostViewsGuest'] > $mybb->settings['MaxPostViewsGuest'])
	{
	$errormessage = <<<MESSAGE
	{$text_error}
MESSAGE;
		$errormessage = preg_replace("!\[MaxPost\]!Us", $mybb->settings['MaxPostViewsGuest'], $errormessage);
		$errormessage = preg_replace("!\[Registrarse\]!Us", "<a href=member.php?action=register>Registrarse</a>", $errormessage);
		$errormessage = preg_replace("!\[iniciar_sesion\]!Us", "<a href=member.php?action=login>Iniciar sesion</a>", $errormessage);
		error($errormessage);
	}
}

?>
Any news on above code!
Cheers
@Donald_Duck, I didn't understand your request, can you explain me it so I can help you? (P.S. I don't know english very well)
@ chack1172,
 Hello,
actually the plug code i quoted works pretty well by showing warning to guests after defined views.

Now i want  to avoid crawlers like google,baidu bots / spiders from getting blocked after defined view count. Need to check useragent for those bots and add exception to those trusted crawlers.

If we don't do that then its bad from SEO point of view
Try to change
if($mybb->user['usergroup'] != "1" || !$mybb->settings['MaxPostViewsGuest'])

with
if($mybb->user['usergroup'] != "1" || !$mybb->settings['MaxPostViewsGuest'] || my_strpos($mybb->user['sid'], "bot=") !== false)
(2016-08-08, 04:58 PM)chack1172 Wrote: [ -> ]Try to change
if($mybb->user['usergroup'] != "1" || !$mybb->settings['MaxPostViewsGuest'])

with
if($mybb->user['usergroup'] != "1" || !$mybb->settings['MaxPostViewsGuest'] || my_strpos($mybb->user['sid'], "bot=") !== false)

Very nice and thanks.
just a note to whomesoever will use this, Yesterday i modified the plug and today saw few crawlers errors in google webmaster tool for my friends website.

Still the spiders - bots are blocked (after defined view count), what else might be the solution!
I use the plugin too but I tried something a bit different. I added a group called bots and made a specific permission for the bots I wanted to crawl. It seems to be working. Smile

Sure Donald Duck.. I went into groups in the admin panel , I added a group called Bots then for the permissions for that group, I allowed them to crawl threads and forums. Then I went to the left menu and clicked spiders and bots and edited each bot like google, facebook . I set them up the new bot group with the specified permissions..
How are they blocked, can you explain?
(2016-08-15, 02:30 PM)chack1172 Wrote: [ -> ]How are they blocked, can you explain?
Google crawl error log and the external test link i pm'd you...sorry for late response