Recent Topics

1 Jul 16, 2006 18:03    

I've just upgraded from 0.91 to 1.8, I'm having problems getting the captcha plugin to be visible and work. I've installed it after getting around the memory issue and it appears listed in my installed plugin list. If I edit it and use the 'create test image' link it creates the image. However, on the sites live pages (the comment pages) it doesn't appear anywhere. When ii try to leave a test comment I get the following error:

Cannot post comment, please correct these errors:
Please fill in your name.
Please fill in your email.
Please do not send empty comments.
The captcha code was invalid: You do not seem to come from the intended page.
[Back to comment editing]

Do I need to add something to my skin in the comment area ? I see that the plugin variable 'code' is blank. Should this be set to something ? What about the 'Apply rendering' option, what should that be set to ?

Sorry to seem a noob, but this new plugin system is new to me. Is there an in-depth guide to installing and using plugins in 1.8 ? What things like 'Apply rendering' and 'code' mean and are used for ?

Also, the other plugins like 'smilies' installed and worked straight away.

Any help appreciated :D

2 Jul 16, 2006 18:11

An addition:

I've uninstalled capcha and I still get the above error, without the captcha part... Anyone know what is causing this ?

3 Jul 17, 2006 03:12

Well I've worked out the problem was the _feedback.php page from the 1.6 skin I'm using. I've fixed that up and now the captcha code is displaying when adding comments and/or email.

However now I get this error after submitting either a comment or email if I'm not logged in:

Cannot send email, please correct these errors:
The captcha code was invalid: No stored private key has been found. You probably do not have cookies enabled or the timeout of 7200 minutes has expired.
[Back to email editing]

If I log in I can add comments/send mail. logged out, as per Joe Public, and I can't send either and get the message above.

This happens with the original 1.8 skin as well.

I'm super confused what this might be. Is captcha working for others logged out ? Any ideas what might be wrong ?

4 Jul 17, 2006 10:55

Can't seem to figure out the new workings of 1.8, I installed captcha for 1.8 but it won't show in the other skins that came with the 1.8 installer.

How can I make it to show?

Thanks

5 Jul 17, 2006 21:26

Laibcoms: The plugin hooks the DisplayCommentFormFieldset event to display the payload part. See the /skins/_feedback.php file to also apply it to your custom /skins/YOURSKIN/_feedback.php file, if you do not use the generic /skins/_feedback.php file.
It should show up in the custom skin and all those, which use the /skins/_feedback.php file (by requiring it).

Sirimo: Sure. I've just tried it at the demo site. The captcha_img_plugin is available there now (for the stable release 1.8-beta) and should be in the "display available plugins list" after the demo has been reset.

6 Jul 17, 2006 22:44

Yup, it shows in the Custom skin and nifty_corners, but with the wp/wpc skins and some other skins that came with the 1.8 installer zip file, the captcha isn't showing.

I tried looking for what's missing, but as it appears, the skins where the captcha isn't showing seems to be not yet updated to 1.8?

I guess I have to readopt those skins' feedback.php, can't seem to see the code for the plugins to copy & paste for the default skins' feedback.php

EDIT:
Tried it again, and weird, now it works as intended.

And now gives me:

Cannot post comment, please correct these errors:

* Please fill in your name.
* Please fill in your email.
* Please do not send empty comments.

Looks like some of the skins included really need some workout..

thanks.. that'll be a start..

7 Jul 17, 2006 23:16

blueyed - if I go to the demo site, it works fine. I can install the plugin, then post captcha validated comments. But going back to my site it still throws up the same error message every time I try to add a comment.

Cannot send email, please correct these errors:
The captcha code was invalid: No stored private key has been found. You probably do not have cookies enabled or the timeout of 7200 minutes has expired.
[Back to email editing]

I've checked the DB and the private/public keys are being created.

I've turned captcha off for now as otherwise people can't comment at all. Any idea what might be causing the problem ?

8 Jul 17, 2006 23:33

Sirimo,

try replacing:


		// Save the private and public key to DB
		$DB->query( 'INSERT INTO '.$this->get_sql_table('data').'
			( cpt_public, cpt_private, cpt_sess_ID, cpt_timestamp ) VALUES
			( '.$DB->quote( $this->public_key ).', '.$DB->quote( $this->private_key ).', '.$Session->ID.', NOW() )' );

with:


		// Save the private and public key to DB
		$DB->query( 'INSERT INTO '.$this->get_sql_table('data').'
			( cpt_public, cpt_private, cpt_sess_ID, cpt_timestamp ) VALUES
			( '.$DB->quote( $this->public_key ).', '.$DB->quote( $this->private_key ).', '.$Session->ID.', FROM_UNIXTIME('.$localtimenow.') )' );

I think the NOW() is the culprit here.. stupid bug then.

edit: added FROM_UNIXTIME (found out below)..

9 Jul 17, 2006 23:34

..and add the $localtimenow to the global variable list of CaptchaPayload:


	function CaptchaPayload( & $params )
	{
		global $DB, $Session, $localtimenow;

10 Jul 18, 2006 00:36

blueyed - I added the updates and get the same error. Running with the idea of a timeout I changed the timeout length to 1200000 minutes and got the same error... :(

11 Jul 18, 2006 00:56

Damn.

Ok, please find the following in function CaptchaValidated and comment out the last to WHERE clauses:


	$posted_private = param( 'captcha_img_'.$this->ID.'_private', 'string', '' );
	$saved_private = $DB->get_var( '
			SELECT cpt_private FROM '.$this->get_sql_table('data').'
			 WHERE cpt_public = '.$DB->quote($posted_public).'
			   AND cpt_sess_ID = '.$Session->ID.'
				   AND UNIX_TIMESTAMP(cpt_timestamp) > '.( $localtimenow - $this->Settings->get('timeout_key')*60 ) );

so it looks like:


	$posted_private = param( 'captcha_img_'.$this->ID.'_private', 'string', '' );
	$saved_private = $DB->get_var( '
			SELECT cpt_private FROM '.$this->get_sql_table('data').'
			 WHERE cpt_public = '.$DB->quote($posted_public).'
			   #AND cpt_sess_ID = '.$Session->ID.'
			   #AND UNIX_TIMESTAMP(cpt_timestamp) > '.( $localtimenow - $this->Settings->get('timeout_key')*60 ) );

It may also be a session problem (if you get a new session ID with each request), which would mean that cookies do not hold.

If that does not help, I'd be interested in what $posted_private is..

How have you integrated the DisplayCommentFormFieldset event? Do you pass a "Form" in the params?

Could you try validating the generated HTML where the captcha gets integrated, especially, if there's a new <form> inside of the comment's <form>, which may cause the captcha_img_ID_private input field to not get sent with the comment's form.

12 Jul 18, 2006 01:25

That made it work!

I'll take a look at the HTML and see if I can spot anything.

13 Jul 18, 2006 01:47

Commenting out the SQL worked?

So, then it's either the Session ID or the timeout.. the form field's value gets through then.

Try commenting in one of the two lines in the SQL again, then we should know more.

14 Jul 18, 2006 02:40

OK were starting to win.

		$posted_private = param( 'captcha_img_'.$this->ID.'_private', 'string', '' );
		$saved_private = $DB->get_var( '
				SELECT cpt_private FROM '.$this->get_sql_table('data').'
				 WHERE cpt_public = '.$DB->quote($posted_public).'
				   AND cpt_sess_ID = '.$Session->ID.'
				  # AND UNIX_TIMESTAMP(cpt_timestamp) > '.( $localtimenow - $this->Settings->get('timeout_key')*60 ) );

The above works.

		$posted_private = param( 'captcha_img_'.$this->ID.'_private', 'string', '' );
		$saved_private = $DB->get_var( '
				SELECT cpt_private FROM '.$this->get_sql_table('data').'
				 WHERE cpt_public = '.$DB->quote($posted_public).'
				  # AND cpt_sess_ID = '.$Session->ID.'
				   AND UNIX_TIMESTAMP(cpt_timestamp) > '.( $localtimenow - $this->Settings->get('timeout_key')*60 ) );

The above doesn't.

15 Jul 18, 2006 03:00

I've made another bad mistake (and didn't test it):
where we've replaced NOW() with $locatimenow, it should be:


		// Save the private and public key to DB
		$DB->query( 'INSERT INTO '.$this->get_sql_table('data').'
			( cpt_public, cpt_private, cpt_sess_ID, cpt_timestamp ) VALUES
			( '.$DB->quote( $this->public_key ).', '.$DB->quote( $this->private_key ).', '.$Session->ID.', FROM_UNIXTIME('.$localtimenow.') )' );


instead (wrapped with FROM_UNIXTIMESTAMP).

I'll add a note in the above post.

Sorry..

16 Jul 18, 2006 03:17

OK I've uncommented the line and added the FROM_UNIXTIMESTAMP wrap and it works !

Thanks a million blueyed :)

17 Aug 06, 2006 06:15

Hi,

I'm not sure why but when one of my post was entitled "Replicating the Real-World in Sim City" the captcha image won't show up. After renaming the title and permalink, it works. Could be a word interfering with the captcha plugin or something? Thanks, just a heads up.


Form is loading...