Advertisement:

Author Topic: [Tip/Trick] Blocking bots from comment posting  (Read 12595 times)

navjottomer

  • Tutor
  • Sr. Member
  • *
  • Posts: 378
  • I am here
[Tip/Trick] Blocking bots from comment posting
« on: October 07, 2012, 12:59:43 am »
I was thinking about alternative ways to block comment spam the other day and it occurred to me that there’s potentially a simpler solution than captcha's. Keep in mind that this trick isn't foolproof but it is enough to make major number of bots confused. So here is a step by step tutorial for implementing this invisible captcha.

1. Create a input field which will be hidden by css to your comment form like below:
Code: [Select]
<input id="spamlover" name="spamlover" value="" />

before this line you can find in your theme item.php file.
Code: [Select]
<label for="title"><?php _e('Title''modern') ; ?>:</label><?php CommentForm::title_input_text(); ?><br />
2. Now add this css style in your theme style.css you can find in your theme folder:
Code: [Select]
/*we love spam */
#spamlover {display:none }

3. now open itemActions.php you can find in oc-includes/osclass folder and put this code

Code: [Select]

$spam           = $_POST['spamlover'];
if ($spam === "") {} else {
                Session::newInstance()->_setForm('commentAuthorName', $authorName);
                Session::newInstance()->_setForm('commentTitle', $title);
                Session::newInstance()->_setForm('commentAuthorEmail', $authorEmail);
                Session::newInstance()->_setForm('commentBody', $body);
                return -1;
             }

before these lines

Code: [Select]
if( !preg_match('|^.*?@.{2,}\..{2,3}$|', $authorEmail)) {
                Session::newInstance()->_setForm('commentAuthorName', $authorName);
                Session::newInstance()->_setForm('commentTitle', $title);
                Session::newInstance()->_setForm('commentBody', $body);
                return 3;
            }

Save every file and TADA !!! now bot will not be able to post comments on your website easily.  ;)
I have seen huge reduction in comments spam by implementing it. I was getting over 500 spam comments daily but now those are reduced to 2-3 spam daily(You can't stop human spammers anyway and i still moderate comments manually. :( ). For added security change "spamlover" to something else.

And as i already said that, there's nothing stopping a bot from rendering the page and determining which fields are actually visible to the user before filling any in - but that kind of bot would be considerably more complex than one that just looked at the form html. A invisible captcha is likely to be very effective at stopping simple bots.

If you have any better and simple idea or I have missed something please do share.


 
« Last Edit: October 07, 2012, 01:07:02 am by navjottomer »

nootkan

  • Sr. Member
  • ****
  • Posts: 259
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #1 on: October 29, 2012, 08:25:59 pm »
Can we apply this tip to the other forms in osclass without making changes to your code?   I cannot seem to make it work with the contact form.  Has anyone got this to work with the other forms and if so please post here on how you were able to do it.  Thanks in advance.

localsales

  • Full Member
  • ***
  • Posts: 130
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #2 on: October 30, 2012, 01:08:16 am »
i suggest facebook comment for this.

nootkan

  • Sr. Member
  • ****
  • Posts: 259
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #3 on: October 30, 2012, 10:37:26 pm »
i suggest facebook comment for this.
Not sure what you are saying here.  Please elaborate.

navjottomer

  • Tutor
  • Sr. Member
  • *
  • Posts: 378
  • I am here
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #4 on: October 31, 2012, 11:33:32 pm »
I have applied it on my Item-contact form and on contact page and it working fine you have to change this code a little bit.

nootkan

  • Sr. Member
  • ****
  • Posts: 259
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #5 on: November 01, 2012, 09:59:42 am »
What changes did you make to get it to work?  I cannot seem to get it to work anywhere except on the comment form.

vsync

  • Newbie
  • *
  • Posts: 8
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #6 on: November 24, 2012, 03:09:06 am »
This idea is long implemented on the internet and it's known as the "honey-pot" technique

navjottomer

  • Tutor
  • Sr. Member
  • *
  • Posts: 378
  • I am here
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #7 on: November 24, 2012, 06:26:17 am »
This idea is long implemented on the internet and it's known as the "honey-pot" technique
of-course it is but the idea is that, How it can be implemented with osclass.

stevekane

  • Newbie
  • *
  • Posts: 9
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #8 on: December 26, 2012, 09:36:00 pm »
This idea is long implemented on the internet and it's known as the "honey-pot" technique
of-course it is but the idea is that, How it can be implemented with osclass.

I would like to implement this on Listing an ad, Reply to an add, register and contact. If some can help with the codes I am willing to pay

Legion

  • Hero Member
  • *****
  • Posts: 622
  • I am founder of top20remedies.com buyeradvise.com
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #9 on: December 27, 2012, 04:42:26 pm »
in my site only login can comment

cus

  • Full Member
  • ***
  • Posts: 139
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #10 on: June 21, 2013, 01:17:42 am »
I would like to try this with the bender_black theme on the contact seller form.  I believe the file is item-sidebar.php?
Can you tell me how to implement?

Thanks,
Tim

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #11 on: June 21, 2013, 02:16:32 am »
Yes, item-sidebar.php, I think this should work (Line 69):

Code: [Select]
<ul id="error_list"></ul>
            <form action="<?php echo osc_base_url(true); ?>" method="post" name="contact_form" id="contact_form">
                <?php osc_prepare_user_info(); ?>
                 <input type="hidden" name="action" value="contact_post" />
                    <input type="hidden" name="page" value="item" />
                    <input type="hidden" name="id" value="<?php echo osc_item_id(); ?>" />

                <input id="spamlover" name="spamlover" value="" />

                <div class="control-group">

Regards

cus

  • Full Member
  • ***
  • Posts: 139
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #12 on: June 21, 2013, 04:17:56 pm »
Thanks Teseo,

Do I still need to add codes to the css and itemActions files?

Tim

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #13 on: June 21, 2013, 04:42:08 pm »
Yes, that is what really does the trick.

Regards

cus

  • Full Member
  • ***
  • Posts: 139
Re: [Tip/Trick] Blocking bots from comment posting
« Reply #14 on: June 21, 2013, 05:25:34 pm »
ok I added the codes.  the new box is showing up.   See link:  http://canadausedsports.com/sports-services/camps/youngstars-youth-developmental-soccer-academy_i68    I added the css code to the bottom of the css file.