Stop Spam:Managed to integrate Recaptcha for comments

e107 CMS » Forums » e107 Code » Code Modification / Plugin / Announcement and Releases << Previous thread | Next thread >>
Go to page  1 2
Reshadat
Feb 09 2008, 08:00AM
Registered Member #36834
Joined: May 30 2007, 08:34AM
Posts: 189
Hi. I just managed to integrate recaptcha for comments for members(not for guest because i'm using ecaptcha for them).since then , the porn comments stopped. Actually the spammers first registered then used a script to automatically post comments. Not now. Its working like a charm. Till now 5 spammers registered but no comments.hurray....Its a hack. Do the following:
1) goto [-link-] and register for your account.
2) Copy recaptchalib.php to e107_handlers
3) Open e107_handlers/comment_class.php
4) Goto line 135, just after "//end rating area", replace the following code
if (ANON == TRUE && USER == FALSE)
			{
				$text .= "<tr>\n<td style='width:20%; vertical-align:top;'>".COMLAN_16."</td>\n<td style='width:80%'>\n<input class='tbox comment author' type='text' name='author_name' size='61' value='$author_name' maxlength='100' />\n</td>\n</tr>";
			}
			$text .= $rate."<tr> \n
			<td style='width:20%; vertical-align:top;'>".COMLAN_8.":</td>\n<td id='commentform' style='width:80%;'>\n<textarea class='tbox comment' id='comment' name='comment' cols='62' rows='7' onselect='storeCaret(this);' [sanitised]onclick=[/sanitised]'storeCaret(this);' onkeyup='storeCaret(this);'>$comval</textarea>\n<br />
			".display_help('helpb',"comment")."</td></tr>\n<tr style='vertical-align:top'> \n<td style='width:20%'>".$text2."</td>\n<td id='commentformbutton' style='width:80%;'>\n". (isset($action) && $action == "reply" ? "<input type='hidden' name='pid' value='$id' />" : '').(isset($eaction) && $eaction == "edit" ? "<input type='hidden' name='editpid' value='$id' />" : "").(isset($content_type) && $content_type ? "<input type='hidden' name='content_type' value='$content_type' />" : ''). "<input class='button' type='submit' name='".$action."submit' value='".(isset($eaction) && $eaction == "edit" ? COMLAN_320 : COMLAN_9)."' />\n</td>\n</tr>\n</table>\n</form></div>";



with



	if (ANON == TRUE && USER == FALSE)
			{
				$text .= "<tr>\n<td style='width:20%; vertical-align:top;'>".COMLAN_16."</td>\n<td style='width:80%'>\n<input class='tbox comment author' type='text' name='author_name' size='61' value='$author_name' maxlength='100' />\n</td>\n</tr>";
			}
require_once(e_HANDLER."recaptchalib.php");
$publickey = "yourpublickey";
if(USER)
{
$test=recaptcha_get_html($publickey);
}
			$text .= $rate."<tr> \n
			<td style='width:20%; vertical-align:top;'>".COMLAN_8.":</td>\n<td id='commentform' style='width:80%;'>\n<textarea class='tbox comment' id='comment' name='comment' cols='62' rows='7' onselect='storeCaret(this);' [sanitised]onclick=[/sanitised]'storeCaret(this);' onkeyup='storeCaret(this);'>$comval</textarea>\n<br />
			".display_help('helpb',"comment")."</td></tr>\n<tr style='vertical-align:top'> \n<td style='width:20%'>".$text2."</td>\n<td id='commentformbutton' style='width:80%;'>\n". (isset($action) && $action == "reply" ? "<input type='hidden' name='pid' value='$id' />" : '').(isset($eaction) && $eaction == "edit" ? "<input type='hidden' name='editpid' value='$id' />" : "").(isset($content_type) && $content_type ? "<input type='hidden' name='content_type' value='$content_type' />" : ''). "\n".$test."\n<input class='button' type='submit' name='".$action."submit' value='".(isset($eaction) && $eaction == "edit" ? COMLAN_320 : COMLAN_9)."' />\n</td>\n</tr>\n</table>\n</form></div>";



5)Save it and close the file.

6) Open comment.php in your site root.

7) Goto line 76. Just after "$clean_subject = $_POST['subject'];", add the following code:

require_once(e_HANDLER."recaptchalib.php");
$privatekey = "yourprivatekey";
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {

  header("location: ".e_BASE."wrongcaptcha.php");
		exit;
}


8) Save the file and close it.

9) Make a new file in your e107 base directory named wrongcaptcha.php. Write the following code in it:
<?php
require_once("class2.php");
require_once(HEADERF);

$text = "
<div style='text-align:left;'>
<big>The Captcha you've entered is wrong. Please <a href='javascript:history.go(-1)'>Go back</a> and enter it again!<br><br>
<center><a href='javascript:history.go(-1)'>GO BACK</a></big>
</div>
";

$title = "Wrong Captcha Entered";

$ns -> tablerender($title, $text);

require_once(FOOTERF);
?>


Save it. Thats it!

I tested it and found that it works! although I cant say if it is bug free. One thing is for sure...There wont be any porn comments in e107 based sites.

For the faint hearted people, here is the zip file containing all the files. Just overwrite them. Make sure you replace "yourprivatekey" and "yourpublickey" with you private and public keys respectively. Enjoy. And yeah...if you want to thank me...please come over to my site(my sig) and post it in my forums. thanks.

Readymade Files: [-link-]

[ Edited Feb 09 2008, 07:45PM ]
Go to top
SecretR
Feb 09 2008, 02:19PM
secretr
  • e107 Main site administrator
  • e107 Core developer
  • e107 Design Team
Registered Member #11345
Joined: Oct 14 2004, 08:06AM
Location: Bulgaria
Posts: 1802
I'm planning to implement this as a part of some kind of Spam killer plugin (no core changes).
Go to top
Website
Rashan
Feb 09 2008, 03:03PM
Registered Member #8393
Joined: Jun 19 2004, 08:23AM
Posts: 309
hey, thanks for this. I look forward to a plugin that doesn't change core files, but untill that gets here (any idea of a timeline, SecretR?) this'll be a good tool to have.
Go to top
NFM
Feb 09 2008, 05:25PM
Registered Member #38450
Joined: Jul 20 2007, 02:19PM
Posts: 17
I'm keeping an eye on this thread too....since I even have captcha set up and these guys are still able to register. I don't want to edit my core files...so Secret let us know when you're ready to release.
Go to top
Reshadat
Feb 09 2008, 07:43PM
Registered Member #36834
Joined: May 30 2007, 08:34AM
Posts: 189
Plugin for this is a good idea. Maybe changing the core file on the fly using e_meta.php. not sure though. It would be great if somebody launches this as a plugin. You can also download the files and overwrite them!!
[ Edited Feb 09 2008, 07:43PM ]
Go to top
Xtreme Nitro
Feb 10 2008, 08:52AM
Registered Member #41841
Joined: Dec 10 2007, 07:17PM
Posts: 105
@Reshadat, what about the chatbox? hehe..
Go to top
Website
Reshadat
Feb 10 2008, 09:19AM
Registered Member #36834
Joined: May 30 2007, 08:34AM
Posts: 189
This is just for news comments. Not for chatboxes..
Go to top
Xtreme Nitro
Feb 13 2008, 09:20PM
Registered Member #41841
Joined: Dec 10 2007, 07:17PM
Posts: 105
@Reshadat, how can I get recaptchalib.php ?

edit: ok, i got it. time to edit now. ^^
[ Edited Feb 13 2008, 09:23PM ]
Go to top
Website
Xtreme Nitro
Feb 13 2008, 09:38PM
Registered Member #41841
Joined: Dec 10 2007, 07:17PM
Posts: 105
@Reshadat, when I try to post as a guest. Captcha doesn't appears. But when I try to post as member the code just appears. :?: Is there any errors?

How to make like this scenario, when a guest posting the code is appears, but when member posting the code doesn't appears. ^^

Update:
I try to edit at line 141, this is the original one:
if(USER)
{
$test=recaptcha_get_html($publickey);
}


And I replace with this:
if(ANON)
{
$test=recaptcha_get_html($publickey);
}


But the code is not working. I can posting as a guest without entering the code.
[ Edited Feb 13 2008, 09:43PM ]
Go to top
Website
ChoSoi
Feb 17 2008, 08:28AM
Registered Member #20206
Joined: Aug 18 2005, 12:41AM
Posts: 1
thx for this

i have little problems.
it works great a comments in a newspost, but not on
downloads.

someone knows to fix my problem?

thanks for your help
Go to top
Lolo Irie
Feb 28 2008, 04:29AM
Registered Member #331
Joined: Oct 18 2002, 01:14PM
Posts: 100
eTCaptcha (currently in beta) will allow you to protect ALL your e107 forms if required (and plugins), without adding any code lines in your HTML forms.

Just download the beta on etalkers.tuxfamily.org and let me know what you are thinking about.
Final release out next days...
Go to top
Tiberun
Mar 06 2008, 06:38AM
Registered Member #43728
Joined: Mar 06 2008, 06:32AM
Posts: 3
Lolo Irie wrote ...

eTCaptcha (currently in beta) will allow you to protect ALL your e107 forms if required (and plugins), without adding any code lines in your HTML forms.

Just download the beta on etalkers.tuxfamily.org and let me know what you are thinking about.
Final release out next days...

Installed your polug-in and now my whole site is corrupt, I only get this error message:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /mnt/home/_a/atlas/www.doener.se/e107/e107_plugins/etcaptcha/class.php on line 1853


Please help out here since the complete site is down due to this.
Go to top
Lolo Irie
Mar 12 2008, 12:55PM
Registered Member #331
Joined: Oct 18 2002, 01:14PM
Posts: 100
Apologize to answer only now.

Hm forgot, eTCaptcha is only working for PHP5.
Try to update your system, it's recommended for the future anyway !..
[ Edited Mar 12 2008, 02:48PM ]
Go to top
SecretR
Mar 12 2008, 01:12PM
secretr
  • e107 Main site administrator
  • e107 Core developer
  • e107 Design Team
Registered Member #11345
Joined: Oct 14 2004, 08:06AM
Location: Bulgaria
Posts: 1802
Anti-spam Control Center plugin is in beta state and ready for testing. At this point includes only Re-Captcha service.
I'll start implementing Askimet soon.
I'll publish the plugin as soon as I can.
Go to top
Website
Xtreme Nitro
Mar 28 2008, 06:01PM
Registered Member #41841
Joined: Dec 10 2007, 07:17PM
Posts: 105
my little mod with simple captcha: [-link-]
Go to top
Website
Jezza101
Aug 21 2008, 01:10AM
Registered Member #29493
Joined: Aug 05 2006, 05:44AM
Posts: 441
Whilst we are waiting for these plugins, my comment stop plugin has proved great at keeping control of spam. It allows you to limit which classes can post links. So you can set a class of trusted members etc.

Also allows you to moderate comments.

Install comment stop now!
Go to top
whoisrich
Mar 22 2009, 11:48AM
Registered Member #4268
Joined: Nov 09 2003, 02:11PM
Location: UK
Posts: 520
eCaptcha 3.0 released with reCAPTCHA support.

http://e107.org/e107_plugins/forum/forum_viewtopic.php?171110

And yes, you can have reCAPTCHA for guests, and eCAPTCHA for members
Go to top
Website
whoisrich
Mar 23 2009, 09:06AM
Registered Member #4268
Joined: Nov 09 2003, 02:11PM
Location: UK
Posts: 520
eCaptcha 3.1 released.
Go to top
Website
whoisrich
Mar 23 2009, 08:05PM
Registered Member #4268
Joined: Nov 09 2003, 02:11PM
Location: UK
Posts: 520
eCaptcha 3.2 released.
Go to top
Website
whoisrich
Apr 25 2009, 06:37AM
Registered Member #4268
Joined: Nov 09 2003, 02:11PM
Location: UK
Posts: 520
eCaptcha 3.4 Released.
Go to top
Website
Go to page  1 2  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System