Page 1 of 1

[FIXED] Mambots fired on Modules

Posted: Mon Jun 26, 2006 8:14 pm
by PhilTaylor-Prazgod
Ref: http://forum.joomla.org/index.php/topic ... #msg374349
It appears that mambots are now fired on module content as well as content items! This was not the case before Joomla 1.0.10 (Or at least it never appeared so). this could effect all mambots

Please read my blog post on the difference and the impact it had on the Tags component (was ok on J 1.0.9 before Joomla 1.0.10, tags mambot never changed)
http://blog.phil-taylor.com/2006/06/26/ ... component/
Apparently its not just my components! Here is an email from a customer with a free module from someone else:
Hey Phil

It seems that as a result of the upgrade to ver 1.10.0, joomla is now treating the "Creative commons license module" as a comment item - thats why the joomla deliciousbot bot was putting links above (and then below when I changed the bot settings) the CC liscense module in the left sidebar.

So, for now, I just turned off the CC module. I'd like to get this straightened out, but....

....

Re: [J1.0.10] Mambots fired on Modules

Posted: Mon Jun 26, 2006 10:12 pm
by stingrey
Short answer is that yes content mambots will now affect custom/new module content as of 1.0.10

It was deemed a shortfall that was addressed in previous versions of 1.0.x and fixed in 1.0.10

Re: [J1.0.10] Mambots fired on Modules

Posted: Tue Jun 27, 2006 6:01 am
by eyezberg
What does that mean now?
It is a feature, not a bug?
How can this be turned of?
:(

Re: [J1.0.10] Mambots fired on Modules

Posted: Tue Jun 27, 2006 7:16 am
by PhilTaylor-Prazgod
stingrey wrote: Short answer is that yes content mambots will now affect custom/new module content as of 1.0.10

It was deemed a shortfall that was addressed in previous versions of 1.0.x and fixed in 1.0.10
Thank you for the confirmation.  Now that I know I was not going crazy I can patch all my components as almost all of them are effected :-)

I think this is going to become a FAQ :-)

Re: [J1.0.10] Mambots fired on Modules

Posted: Tue Jun 27, 2006 8:24 am
by eyezberg
Phil, any pointers as to how to patch everything to get rid of this?

Re: [J1.0.10] Mambots fired on Modules

Posted: Tue Jun 27, 2006 8:42 am
by PhilTaylor-Prazgod
~Well according to the devs it doesnt need fixing as its meant to be that way :-)

However, I know my components do not need this "feature" so I have added a few lines of code in my mambot to check if the $row it is processing is a module or a content item.  There seems to be no easy way to guess which it is. Mambots process content's $row->text (Which is a join of introtext and fulltext), and content doesnt have the $row->content var when inside the mambot (Only modules send this into $row)

So based on this (loose) observation I have the following code at the right point (near the top of the bot's function) that simple returns if the $row->content is set or has a value (It appears to work, and the reports from customers confirm that this is a useable fix),

Code: Select all

if (@$row->content){
   return;
}

Re: [J1.0.10] Mambots fired on Modules

Posted: Tue Jun 27, 2006 9:06 am
by eyezberg
Thank you, will test on a few bots ;)

Re: [J1.0.10] Mambots fired on Modules

Posted: Tue Jun 27, 2006 1:46 pm
by Predator
Thanks Phil,

easy and simple solution works without a prob ;)

Re: [J1.0.10] Mambots fired on Modules

Posted: Tue Jun 27, 2006 8:29 pm
by eyezberg
Phil,
just added that code to various bots: works GREAT!
Thanks a bunch.

Re: [J1.0.10] Mambots fired on Modules

Posted: Wed Jun 28, 2006 2:38 pm
by stingrey
Will look to add a param to allow enabling/diabling of mambot parsing per custom/new module

Re: [J1.0.10] Mambots fired on Modules

Posted: Fri Jun 30, 2006 10:13 pm
by dealbro
Thank You for the solution.

BSB
PhilTaylor-Prazgod wrote: ~Well according to the devs it doesnt need fixing as its meant to be that way :-)

However, I know my components do not need this "feature" so I have added a few lines of code in my mambot to check if the $row it is processing is a module or a content item.  There seems to be no easy way to guess which it is. Mambots process content's $row->text (Which is a join of introtext and fulltext), and content doesnt have the $row->content var when inside the mambot (Only modules send this into $row)

So based on this (loose) observation I have the following code at the right point (near the top of the bot's function) that simple returns if the $row->content is set or has a value (It appears to work, and the reports from customers confirm that this is a useable fix),

Code: Select all

if (@$row->content){
   return;
}

Re: [TODO] Mambots fired on Modules

Posted: Mon Jul 03, 2006 3:36 pm
by kai920
Thanks Phil, this worked great for the Google AdSense mambot.

Re: [TODO] Mambots fired on Modules

Posted: Tue Aug 15, 2006 7:21 pm
by cmeinck
As an absolute non-coder, where in the mambot do I place this code? FWIW, I'm looking to edit ComboMax.

Thanks.

Re: [TODO] Mambots fired on Modules

Posted: Wed Aug 16, 2006 9:54 am
by kai920
kai920 wrote: Thanks Phil, this worked great for the Google AdSense mambot.
Actually, if anyone is still reading this... I have a question... how do I stop this mambot from firing for components?

In my SMF logs I see a ton (and I mean A TON) of bot_adsense errors when users access the forums (com_smf).

Re: [TODO] Mambots fired on Modules

Posted: Wed Aug 16, 2006 12:53 pm
by friesengeist
kai920 wrote: Actually, if anyone is still reading this... I have a question... how do I stop this mambot from firing for components?

In my SMF logs I see a ton (and I mean A TON) of bot_adsense errors when users access the forums (com_smf).
Content mambots are only fired for content items by Joomla!. If a content mambot is fired for com_smf, then this component does so itself.

Insert this into the mambot function to stop it from working when com_smf is called:

Code: Select all

global $option;
 if ($option == 'com_smf') {
     return;
 }

Re: [TODO] Mambots fired on Modules

Posted: Wed Aug 16, 2006 12:59 pm
by friesengeist
cmeinck wrote: As an absolute non-coder, where in the mambot do I place this code? FWIW, I'm looking to edit ComboMax.
You need to put it into the mambot function. Usually, a mambot looks like this:
$_MAMBOTS->registerFunction( 'onAfterStart', 'botSomething' );
function botSomething() {
    [INSERT HERE]
    [OLD MAMBOT CODE HERE]
}

Re: [TODO] Mambots fired on Modules

Posted: Wed Aug 16, 2006 1:06 pm
by PhilTaylor-Prazgod
Content mambots are only fired for content items by Joomla!
Factually incorrect.

Content Mambots are fired on modules as well as content items since Joomla 1.0.10 (It was considered a bug that they did not fire on modules before this version so the developers "fixed" the bug and introduced this annoying "feature")

Re: [TODO] Mambots fired on Modules

Posted: Wed Aug 16, 2006 1:11 pm
by friesengeist
PhilTaylor-Prazgod wrote:
Content mambots are only fired for content items by Joomla!
Factually incorrect.

Content Mambots are fired on modules as well as content items since Joomla 1.0.10 (It was considered a bug that they did not fire on modules before this version so the developers "fixed" the bug and introduced this annoying "feature")
That's how soon one can forget about changes ;)
Phil, you are absolutely right

Re: [TODO] Mambots fired on Modules

Posted: Wed Aug 16, 2006 2:36 pm
by kai920
$option = mosGetParam($_REQUEST, 'option');

global $option;

What are the differences between the above two lines?

Re: [TODO] Mambots fired on Modules

Posted: Wed Aug 16, 2006 2:47 pm
by PhilTaylor-Prazgod
kai920 wrote: $option = mosGetParam($_REQUEST, 'option');
This will read what the option equals in the URL
global $option;


This will read what the option equals in the global scope

(Note: the following are generic notes and not just about $option, they apply to all varibles passed by url and required in a script)

The url value and the global scope are probably going to be the same (as Joomla sets $option in the global scope), however if you are relying on getting the right value from the URL you should use the first one and not the second one.  It is also more secure as mosGetParam cleans the value,

Re: [TODO] Mambots fired on Modules

Posted: Fri Aug 18, 2006 8:48 pm
by stingrey
In 1.0.11 SVN there is now a new param for custom modules that will allow you to disable or enable mambots to act upon these content modules.
When creating new modules the default setting is to 'enable' mambot firing.

For existing custom mambots, the defailt is to 'disable' mambot firing.



Please note this issue should only affect 'custom/new' modules and not 3PD modules.

not fixed??? Mambots fired on Modules

Posted: Fri Oct 27, 2006 7:21 pm
by averan
friesengeist wrote: $_MAMBOTS->registerFunction( 'onAfterStart', 'botSomething' );
function botSomething() {
    [INSERT HERE]
    [OLD MAMBOT CODE HERE]
}
this simply isn't working for me.  i'm having this issue with the ijoomla magazine component mambot: mos_magazine.php

its replacing text inside newsflash modules.  i followed your directions and inserted "if (@$row->content){ return;}" at the beginning of the function that is called out in registerFunction as well as tried it in other functions inside the bot, but with absolutely no effect whatsoever.

here's the beginning of the bot:

"$_MAMBOTS->registerFunction( 'onPrepareContent', 'botMagQuotes' );"

and here's the function being called out with Phil's conditional statement inserted:

"function botMagQuotes( $published, &$row, &$params, $page=0 ) {

if (@$row->content){
  return;
}

    global $_MAMBOTS, $my, $mosConfig_absolute_path,$mainframe,$database,$mosConfig_lang, $mosConfig_live_site;
    global $css_article_quote1,$css_article_quote2,$css_article_quote3,$Itemid,$_CONFIG;"


i should mention that i'm using Joomla 1.0.11.  i don't see any parameter options in the newsflash module to disable bots....i see the option for custom modules, but isn't newsflash a core module?  shouldn't it be set to disable bots by default??

anyone have any other ideas?  can i hack the newsflash module to ignore this specific bot?

Re: [FIXED] Mambots fired on Modules

Posted: Sun Jan 07, 2007 6:13 am
by redgsr
Works fine for me after some tweaking

Re: [FIXED] Mambots fired on Modules

Posted: Sun Jul 01, 2007 2:31 am
by ruigato
sorry to come to this post again but i am having some hard times with the google adsense mambot.

I is something i realy need to one site, its a simple way to get some revenue, but unfortunately the bot is fired in some components that break with the google ad code inside.

Is there anyone willing to help on this?