ZenphotoCMS Forum
Simple captcha protection for comment. Easy to install - 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: Simple captcha protection for comment. Easy to install (/thread-526.html)



Simple captcha protection for comment. Easy to install - gregb34 - 2006-05-28

Hi,

I have developped a simple captcha protection to prevent spam attacks on comment.

Demo : http://www.gregserveur.com/zenphoto/

Download : http://www.gregserveur.com/public/scripts/zenphoto_comment_protection.zip


Simple captcha protection for comment. Easy to install - DarrellD - 2006-05-29

Thank you!


Simple captcha protection for comment. Easy to install - DarrellD - 2006-06-04

The link no longer works. Please fix this so I can put it on the wiki.


Simple captcha protection for comment. Easy to install - gregb34 - 2006-06-05

my serve have crashed and i have lost the archive, if anyone has downloaded it before...

In other case, i will rebuild it Wink


Simple captcha protection for comment. Easy to install - gregb34 - 2006-06-05

UPDATED Wink


Simple captcha protection for comment. Easy to install - slidenby - 2006-06-05

Seems to be down again.... mirror?


Simple captcha protection for comment. Easy to install - gregb34 - 2006-06-05

http://gregb.no-ip.com/public/scripts/zenphoto_comment_protection.zip

or
http://gratulog.free.fr/up/zenphoto_comment_protection.zip


Simple captcha protection for comment. Easy to install - DarrellD - 2006-06-06

Thanks. Would you mind if I upload a copy of the .zip onto the wiki?


Simple captcha protection for comment. Easy to install - gregb34 - 2006-06-06

if i have did this hack it's to share it Wink so you can Wink

(Sorry for my bad english, i'm french)


Simple captcha protection for comment. Easy to install - gregb34 - 2007-01-04

Updated for 1.0.6...

http://gregoryb.dyndns.org/public/scripts/zenphoto_comment_protection.zip
http://www.gregserveur.com/public/scripts/zenphoto_comment_protection.zip


Simple captcha protection for comment. Easy to install - simonef - 2007-05-20

None of your links worked for me, so I downloaded it from the Wiki. The Readme there didn't work at all, but I figured it out. The files changed where you have to add the code. This is how I made it work:

1. Upload generate_image.php to the /zen folder, change the permisson on this file to 777 (allow write to everybody).
Upload code.png to the /zen/images folder
2. Open the image.php in the folder of your current theme.
Add `<? include('zen/generate_code.php');?>`
Add `<label for="code"><img src='/zenphoto/zen/images/code.png' alt="Code"/></label>` where you ant the picture with the Captcha to be, add `<input type="text" id="code" name="code" size="3" class="inputbox" /><input type="hidden" name="code_h" value="<? echo $code; ?>"/>`where you want the input box to be.
In the default theme this would mean to find
`<tr>

<td><label for="website">Site:</label></td>

<td><input type="text" id="website" name="website" size="40" value="<?php echo $stored[2];?>" class="inputbox" /></td>

</tr>`
and after this add
`<tr>

<? include('zen/generate_code.php');?>

<td><label for="code"><img src='/zenphoto/zen/images/code.png' alt="Code"/></label></td>

<td><input type="text" id="code" name="code" size="3" class="inputbox" /><input type="hidden" name="code_h" value="<? echo $code; ?>"/></td>

</tr>`

4. Open [b] /zen/functions-controller.php[/b]
Find the lines
` $commentadded = $_zp_current_image->addComment(strip_tags($_POST['name']), strip_tags($_POST['email']),

$website, kses($_POST['comment'], zp_conf('allowed_tags')));`
in the zp_handle_comment function.
Change this to
`$commentadded = $_zp_current_image->addComment(strip_tags($_POST['name']), strip_tags($_POST['email']), $website,

kses($_POST['comment'], zp_conf('allowed_tags'))`[b]`,strip_tags($_POST['code']),$_POST['code_h']);`[/b]

5. Open [b]/zen/class-image.php[/b]
Find the `function addComment($name, $email, $website, $comment) {`
and replace this line with `function addComment($name, $email, $website, $comment,$code,$code_ok) {`
A few lines further in this function you'll find ` $comment = trim($comment);`.
After this add [b]`$code = trim($code);

$code_ok = trim($code_ok);`[/b]
and replace ` if (empty($email) || !is_valid_email_zp($email) || empty($name) || empty($comment)) {`
with ` if (empty($email) || !is_valid_email_zp($email) || empty($name) || empty($comment) || (md5($code)<>$code_ok)) {`


Simple captcha protection for comment. Easy to install - gregb34 - 2007-12-23

Updated for Zenphoto 1.1.3 !!!


Simple captcha protection for comment. Easy to install - sbillard - 2007-12-24

Adapted for general use in the SVN shortly


Simple captcha protection for comment. Easy to install - gregb34 - 2007-12-24

I'm waiting this Wink


Simple captcha protection for comment. Easy to install - sbillard - 2007-12-24

I am done and have sent it off. All distributed themes will provide Captcha via a theme option--Use Captcha.

Other themes will have to add a printCaptcha() function call to their comment input block.