![]() |
|
Adding CAPTCHA-validation to stop comment spam - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: Adding CAPTCHA-validation to stop comment spam (/thread-1662.html) |
Adding CAPTCHA-validation to stop comment spam - ulfben - 2007-09-20 I want to add reCaptcha to my zenphoto installation. Looking through the code in class-image.php revealed that Problem is, I'm not certain how the form data (POST) gets sent to $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); Adding CAPTCHA-validation to stop comment spam - ulfben - 2007-09-21 It seems zp_handle_comment() in functions_controller.php is what I'm looking for. I'll report back in a while. Adding CAPTCHA-validation to stop comment spam - ulfben - 2007-09-21 Got it working. I'll post the code when I've cleaned it up a bit. Adding CAPTCHA-validation to stop comment spam - ulfben - 2007-09-21 Here's my edits. Note that this will [i]not[/i] remember what's in the comment textbox if the visitor fail their captcha - they'll have to start over again. My next post has the code needed to keep the text intact. [b]image.php:[/b]
` [b]functions-controller.php:[/b] if (in_context(ZP_IMAGE) && isset($_POST['name']) && isset($_POST['email']) && isset($_POST['comment'])) {
` Adding CAPTCHA-validation to stop comment spam - ulfben - 2007-09-21 [b]NOTE:[/b] I am not a web developer. I'm frightingly unaware of safe practices and standards. What I'll show you now might quite possibly feed bad data to your server, prompting the return of SATAN and a premature end of mankind. [b]However[/b], it does seem to work pretty well for me. If you've got more knowledge that I do, please inform us all. If you just got more sense than I do, stay away. Here goes: In [b]functions-controller.php[/b], this is what happens if the user fail their submission (bad captcha or no name/email/comment): $stored = array($_POST['name'], $_POST['email'], $website, $_POST['comment'], false);
` Specifically note Now, here's my ugly workaround: $stored = array($_POST['name'], $_POST['email'], $website, $_POST['comment'], false);
` Simply added a sixth field and keeping the comment text safe in there. To get this back out into the comment form, heres what you need to add in [b]image.php[/b]:
|