PDA

View Full Version : Captcha addon fpr PP1.71


joerg
01-24-2008, 08:36 AM
Hi,

I can't get the captcha addon to work with PP1.71. I tried it in the simple template and the delicious template, copied the _captcha folder to the addons folder and inserted the <CAPTCHA> tag in the comments form. It shows the input box and the picture in the comments form, but it doesn't check the result - and I don't see why it should either. Where is the call of the audit function?

Any suggestions how to make it work?

I don't like akismet and defensio. I just don't trust them so I browse through the spam comments and often find normal comments that were filtered. And doing that with 100+ spam comments a day is a pain in the a**.

Dkozikowski
01-24-2008, 09:04 AM
Open the and addons/_captcha/libraries/captcha.php file add:


$captcha_fontcolor = '';
$captcha_linecolor = '';
$captcha_bgcolor = '';


before:

$testbild = imagecreate(120, 30);

So the end result looks like:


$captcha_fontcolor = '';
$captcha_linecolor = '';
$captcha_bgcolor = '';

$testbild = imagecreate(120, 30);


Enjoy!

joerg
01-24-2008, 10:51 AM
Thanks for the quick reply but it's not about the testbild. It works.
I have enabled captcha on my blog now so you can test it. You can input any number you want, captcha won't complain...so it doesn't filter anything.

Dkozikowski
01-24-2008, 10:54 AM
I sent a comment, and i do not see it. are they moderated?

Dkozikowski
01-24-2008, 10:56 AM
Captcha seems to work for me. I sent 3 test comments. two with a bogus captcha and one with the correct captcha. the correct captcha comment was posted, the others were not.

joerg
01-24-2008, 11:35 AM
The two wrong captchas and one more of your comments were caught by defensio...I don't think captcha has something to do with it, since it should block them completely, right?

Dkozikowski
01-24-2008, 11:51 AM
OK. I took a look at the code and you're right. It should block them completely.

Open addons/_captcha/front_captcha.php and replace all the code inside with the following:


<?php
/**************************
SVN file version:
$Id: admin_editexif.php 57 2007-10-28 19:10:34Z schonhose $
**************************/

/*

Captcha version 1.0
Written for Pixelpost by Dennis Mooibroek, http://foto.schonhose.nl

License: http://www.gnu.org/copyleft/gpl.html

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/

// Same info as non admin addons
$addon_name = "CAPTCHA addon (frontpage functions)";
$addon_description = "This file contains the frontpage functions for the CAPTCHA addon. This addon tries to prevent spam by using so called CAPTCHAS (graphical numbers in this case). Add the &lt;CAPTCHA&gt; tag below the email-form-line in your image or comments template (depends where your comments-form is)";
$addon_version = "1.0";

// The workspace stuff
add_front_functions("check_captcha", "comment_passed", "", "");

function audit() {
//session_start();

if(!isset($_SESSION['digit']) || !is_numeric($_SESSION['digit'])) {
return false;
}

$digit = $_SESSION['digit'];
//error_log("CAPTCHA session value" . $_SESSION['digit'] ,0);
$userinput = $_POST['userinput'];
//error_log("CAPTCHA sent value" . $_POST['userinput'] , 0 );
session_destroy();

if (($digit == $userinput) && ($digit > 1) ) {
return true;
} else {
return false;
}
die("woot");

}


function check_captcha(){
$wrong_captcha_title="wrong code entered";
$wrong_captcha_body="looks like you are a robot, if not please try again and enter the correct code<p /><a href=" . $_SERVER['HTTP_REFERER'] . ">try again</a><p />";
if(!audit()) {
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>
<meta http-equiv="refresh" content="8; URL=' . $_SERVER['HTTP_REFERER'] . '" />
<title>' . $wrong_captcha_title . '</title>
<link rel="stylesheet" href="admin/admin_index.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body> '.
$wrong_captcha_body
.'
</body></html>';
exit;
}
}
?>


Also, do as I said in post #2, http://www.pixelpost.org/forum/showpost.php?p=53944&postcount=2

Does this help?

joerg
01-24-2008, 12:43 PM
No, no change at all. I really get the impression that I am doing something fundamentally wrong here.
It _should_ be as easy as this, right?:

# Extract the zip and upload the folder _captcha to the addons folder. Do NOT change the name of the folder.
# Add the <CAPTCHA> tag below the email-form-line in your image or comments template (depends where your comments-form is)

Are you sure the function audit is really called? I haven't yet understood where the addon code is used.

Dkozikowski
01-24-2008, 12:45 PM
That should be all. Just make sure BOTH addon files are turned on.

And I don't know what is "wrong" with your blog but this addon works without error on my local blog.

austriaka
01-24-2008, 01:40 PM
1) the <CAPTCHA> Tag is not replaced in your page right now. This is usually a sign that you didn't turn on the Addon (or did you give it up?)

2) Perhaps I didn't understand you correct, but you should not use Defension AND Akismet together. Either the one or the other.

3) Try turn off Defensio and test the Captcha again. Could be that they won't work together.

joerg
01-24-2008, 05:25 PM
D'OH!!! Thanks a lot!

1) Yes I gave up.
2) I used only defensio.
3) That's it. I turned defensio off and captcha on again and it works now.

It even works without the modifications dwilkinsjr suggested, but thanks anyway.

Dkozikowski
01-24-2008, 05:40 PM
My modifications consisted of variable and code cleanup that produced header and sessions warnings. On my local instal, the CAPTCHA image would not display due to these warnings.

I'm glad it works on your blog unmodified but if you want clean code, you will apply my modifications anyway. ;)

And it's funny, I too was going to suggest to turn off all other spam defenses but the CAPTCHA continued to work even with Akismet / Defensio turned on. Go figure :p

austriaka
01-24-2008, 08:04 PM
Dave, I guess both Addons rely to the same workspace, don't they? (comment_accepted). So it depends on the order in which the Addons are called which is almost random.

Dkozikowski
01-24-2008, 10:25 PM
True, I didn't think of that.

austriaka
01-25-2008, 07:47 AM
I had the same problem with my Reply-To-Comments Addon (http://www.pixelpost.org/extend/addons/reply-to-comments/) which was sometimes called before Akismet and so the replying comments were not checked.

To make it work together with Akismet, you can use the workspaces provided by Akismet Addon after checking:
$result_aks = mysql_query("SELECT * FROM {$pixelpost_db_prefix}addons WHERE addon_name='admin_akismet_comment' AND status='on'");
if (mysql_num_rows($result_aks) > 0) { //It's on!!
add_front_functions('update_thread_id','comment_pa ssed_askimet');
add_front_functions('update_thread_id','comment_bl ocked_askimet');
}
else add_front_functions('update_thread_id','comment_ac cepted');

As far as I have seen so far Defensio Addon doesn't provide a workspace after its check so it will be difficult (or impossible) to teach the Captcha Addon to hook in after Defensio check. But for Akismet it should work :-)

Dennis
01-25-2008, 09:24 AM
It is true Defensio doesn't provide a workspace after that. There won't be a need for these fixes when we get the addon order sorted out.

Gromitch
12-15-2008, 07:37 AM
Great addon, thanks Dennis!

gheatza
01-21-2009, 08:21 AM
Hey there,

And thanks for this great add-on :), which does work, but it doesn't work, at least for me. Let me explain, I think the add-on works great, but I'm having a bit of a problem, and that is, the add-on only displays the CAPTCHA on the very first page of the blog (I think it's something to do with the last post, not sure though). If for example you go to http://www.stargazer.eu (http://www.stargazer.eu/), on the very first page you get the captcha, you can comment, and everything is fine, but as soon as you do previous, or after you return to the first image, no more captcha, no more image, byebye comments as well (no errors returned etc, it just seems you ARE posting the comment, but nothing reaches the database).
Now, I know it's probably my fault, or it has to do something with the template ( simplicious, a bit modified), but I would really appreciate if someone could look a bit into it, whenever you guys have a bit of time and would like to laugh a bit at me :)


Thank you.

ps. sorry, I didn't open a new thread just in case someone does look and manages to help me fix it, so it might help others as well, let me know if I should thread-ify it.