View Full Version : Captcha and comments
Cyclist
12th of July 2008 (Sat), 15:59
I was wondering if there is already a working solution of implementing CAPTCHA for comments ? Or if this will be done in future? Ufortunately I have no idea how to change the existing code to implement such a solution.
marecki
15th of July 2008 (Tue), 06:28
I was wondering if there is already a working solution of implementing CAPTCHA for comments ? Or if this will be done in future? Ufortunately I have no idea how to change the existing code to implement such a solution.
I think both Comments and Guestbook forms should use captcha.
There is a working script for contact form with captcha. Maybe it is possible to put it into Comments and Guestbook?
Pekka
15th of July 2008 (Tue), 16:47
Would this do: http://photography-on-the.net/gallery/guestbook.php (click "WRITE YOUR OWN GUESTBOOK ENTRY")?
It uses both spam word filter and ReCaptcha and tells which went wrong if the input can not be accepted.
Cyclist
15th of July 2008 (Tue), 18:18
Would this do: http://photography-on-the.net/gallery/guestbook.php (click "WRITE YOUR OWN GUESTBOOK ENTRY")?
It uses both spam word filter and ReCaptcha and tells which went wrong if the input can not be accepted.
Fantastic! That's exactly what I was looking for. Is this possible for the comments as well? Could you maybe give some instruction how to implement such a solution? That would be really great!
marecki
17th of July 2008 (Thu), 03:07
Would this do: http://photography-on-the.net/gallery/guestbook.php (click "WRITE YOUR OWN GUESTBOOK ENTRY")?
It uses both spam word filter and ReCaptcha and tells which went wrong if the input can not be accepted.
It is great! Can you add this Captcha script also to comments?
Pekka
17th of July 2008 (Thu), 16:49
Yes, I'll add it to comments as well. I have also coded it to remember previous entry if something is wrong in text or captcha. I'll post the code soon.
marecki
24th of July 2008 (Thu), 15:54
Yes, I'll add it to comments as well. I have also coded it to remember previous entry if something is wrong in text or captcha. I'll post the code soon.
Pekka, you have some new information with these?
Pekka
24th of July 2008 (Thu), 18:07
I'll publish the codes in about a week. I'm terribly busy with other things right now.
marecki
17th of August 2008 (Sun), 07:05
I'll publish the codes in about a week. I'm terribly busy with other things right now.
I hope you still remember about captcha ;)
Taligent
23rd of September 2008 (Tue), 17:28
Hi folks,
Here's the quick version (spent around 14 minutes working on it) of reCAPTCHA (http://recaptcha.net) that I added to comments and guestbook to get rid of the thousands of spam messages being posted. This is a straight implementation of the PHP plugin from reCAPTCHA and does not include the user-friendly error messages in Pekka's example... yet. : )
Feel free to test it out at the following test gallery of EE 2.02:
http://www.taligentx.com/photos-beta/
Adding reCAPTCHA to EE 2.02:
Create a reCAPTCHA account at http://recaptcha.net
Download the reCAPTCHA PHP plugin from: http://recaptcha.net/plugins/php/
Extract the reCAPTCHA PHP plugin file contents on your local system.
Upload recaptchalib.php to the /basecode directory (should be uploaded in ASCII mode - don't worry if this doesn't mean anything to you).
Open /basecode/SCRIPT_comments.php
Locate the following section:
if (isset($_POST['submit_comment'])) {
$ip = ee_user_ip();
Change to:
if (isset($_POST['submit_comment'])) {
require_once('recaptchalib.php');
$privatekey = "...";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
}
$ip = ee_user_ip();
Replace ... in $privatekey with the private key provided in your reCAPTCHA account.
Locate the following section:
<?php
ob_start();
?>
<input type="submit" name="submit_comment" class="ee_css_comment_submit_button" value="<?php print ee_translate_C($translated["send_comment"]); if ($show_this_rating == "1") print " " . ee_translate_C($translated["and_ratings"]); ?>" />
Change to:
<?php
ob_start();
?>
<script>
var RecaptchaOptions = {
theme : 'blackglass',
};
</script>
<?php
require_once('recaptchalib.php');
$publickey = "...";
echo recaptcha_get_html($publickey);
?>
<br />
<input type="submit" name="submit_comment" class="ee_css_comment_submit_button" value="<?php print ee_translate_C($translated["send_comment"]); if ($show_this_rating == "1") print " " . ee_translate_C($translated["and_ratings"]); ?>" />
Replace ... in $publickey with the public key provided in your reCAPTCHA account.
Save the file and test the comments form.
Open /basecode/SCRIPT_guestbook.php
Locate the following section:
if (isset($_POST['submit_guestbook'])) {
$homepageurl = "";
Change to:
if (isset($_POST['submit_guestbook'])) {
require_once('recaptchalib.php');
$privatekey = "...";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
}
$homepageurl = "";
Replace ... in $privatekey with the private key provided in your reCAPTCHA account.
Locate the following section:
ob_start();
?>
<input type="submit" name="submit_guestbook" value="<?php print ee_translate_C($translated["send_guestbook"]); ?>" />
Change to:
ob_start();
?>
<script>
var RecaptchaOptions = {
theme : 'blackglass',
};
</script>
<?php
require_once('recaptchalib.php');
$publickey = "...";
echo recaptcha_get_html($publickey);
?>
<br />
<input type="submit" name="submit_guestbook" value="<?php print ee_translate_C($translated["send_guestbook"]); ?>" />
Replace ... in $publickey with the public key provided in your reCAPTCHA account.
Complete!
You can customize the reCAPTCHA display using the documentation at:
http://recaptcha.net/apidocs/captcha/client.html
This includes a few different styles for the reCAPTCHA plugin - in the above example, I used "blackglass".
This approach is functional but ugly since there isn't a graceful failure if the CAPTCHA is entered incorrectly - the user receives a plain-text message and would need to hit the back button to try again. Pekka's implementation is the way to go - hopefully he'll share his code with us so we don't have to do the work. : )
Let me know if you run into any issues with the above code!
-Nikhil
Edit: Looks like IE ignores the <script> tags in the middle of the HTML, so the appearance defaults back to the red interface. I'll take a look at it later....
Cyclist
29th of September 2008 (Mon), 16:54
This includes a few different styles for the reCAPTCHA plugin - in the above example, I used "blackglass".
This approach is functional but ugly since there isn't a graceful failure if the CAPTCHA is entered incorrectly - the user receives a plain-text message and would need to hit the back button to try again. Pekka's implementation is the way to go - hopefully he'll share his code with us so we don't have to do the work. : )
Hi haven't had the time yet testing your code but hopefully Pekka is going to find the time to post his code soon, so the same coding hasn't to be done twice.
vBulletin® v3.6.12, Copyright ©2000-2012, Jelsoft Enterprises Ltd.