joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.76k stars 3.64k forks source link

Verify recaptcha after calling to external plugin #6543

Closed queengab closed 8 years ago

queengab commented 9 years ago

Hi,

thanks for your work on this plugin! I update my recaptcha.php code with your last edit and solve some issues. Now i'm trying to do something ... unusual.

I'm trying to include the recaptcha in my own plugin that simply have a form, write on db data, send data via post ajax with return json error, and send mail. I used the method above on my html page and so add a dvi before the send button:

<?php JPluginHelper::importPlugin('captcha'); $dispatcher = JEventDispatcher::getInstance(); $dispatcher->trigger('onInit','dynamic_recaptcha_1'); ?>

from here :http://stackoverflow.com/questions/12840015/how-to-use-joomla-recaptcha-plugin-to-my-custom-module, and i can view it!

But now two things are strange: The captcha won't load when i simply refresh the page but only when i refresh with erase browser cache, The onInit initialise the plugin only one time per session? But most important how can i verify capctha on submit? I tried it, on my php send file but the page return me a ajax error.

//Verify captcha $post = JFactory::getApplication()->input->post;
JPluginHelper::importPlugin('captcha'); $dispatcher = JEventDispatcher::getInstance(); $res = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response_field']); if($res) === TRUE) { $jsonObj = sprintf($status, 1, "ok"); } else { $jsonObj = sprintf($status, 0, "Insert captcha"); }

Have you some suggestions, please? Thanks Gabriele

queengab commented 9 years ago

I found solution to verification here: http://stackoverflow.com/questions/28065375/how-to-add-recaptcha-to-contact-form Watch peter response!

I only have to understand why recaptcha won't load each time i refresh the page. Suggestions?

Thanks Gabriele

gbula commented 9 years ago

I think it's a bug in file /plugins/captcha/recaptcha/recaptcha.php in line 80. Instead of . '}' should be: . '};' Lack of semicolon causes an javascript error when after code generated by the captcha plugin exists some other code.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6543.

queengab commented 9 years ago

Thanks Gbula! I tried it but without fortune. I don't know but seems there be. maybe in my case, a conflict with mootols or jquery.

Is there a way to force always initliase a plugin in the same session? [code]$dispatcher = JEventDispatcher::getInstance(); $dispatcher->trigger('onInit','dynamic_recaptcha_1'); ?>[/code]

I don't know how to debug it... In console message there are no errors.

I'm feeling thus close to solution but thus far from handle it :)

I'll do more tries. Thanks Gabriele

SylvainMartel commented 9 years ago

I am in the same boat. reCaptcha simply won't load on a refresh.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6543.

brianteeman commented 8 years ago

As the recaptcha has been refactored a lot and considerable changes have been made since this was submitted I am assuming that it has already been fixed elsewhere and am closing this. If you still have the problem please update the issue with the correct line number in the current version of Joomla and it can be reopened


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6543.