Permalink
Browse files

Fixed broken recaptcha urls

  • Loading branch information...
SniperSister committed Nov 7, 2013
1 parent ffcfba0 commit 01e3c84d653c4331f7e11c85aa605426c00bbf6a
Showing with 3 additions and 3 deletions.
  1. +3 −3 plugins/captcha/recaptcha/recaptcha.php
@@ -19,9 +19,9 @@
*/
class PlgCaptchaRecaptcha extends JPlugin
{
- const RECAPTCHA_API_SERVER = "http://api.recaptcha.net";
+ const RECAPTCHA_API_SERVER = "http://www.google.com/recaptcha/api";
const RECAPTCHA_API_SECURE_SERVER = "https://www.google.com/recaptcha/api";
- const RECAPTCHA_VERIFY_SERVER = "api-verify.recaptcha.net";
+ const RECAPTCHA_VERIFY_SERVER = "www.google.com";
/**
* Load the language file on instantiation.
@@ -126,7 +126,7 @@ public function onCheckAnswer($code)
}
$response = $this->_recaptcha_http_post(
- self::RECAPTCHA_VERIFY_SERVER, "/verify",
+ self::RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
array(
'privatekey' => $privatekey,
'remoteip' => $remoteip,

8 comments on commit 01e3c84

@carlitorweb

This comment has been minimized.

Show comment Hide comment
@carlitorweb

carlitorweb Nov 15, 2013

+1

@mixerp2

This comment has been minimized.

Show comment Hide comment
@mixerp2

mixerp2 Feb 15, 2014

Thanks

Thanks

@hbagheri

This comment has been minimized.

Show comment Hide comment
@hbagheri

hbagheri May 21, 2014

ّI have changed all. but captcha do not accept !

ّI have changed all. but captcha do not accept !

@mehdiyazdani

This comment has been minimized.

Show comment Hide comment
@mehdiyazdani

mehdiyazdani Jun 16, 2014

Thanks

Thanks

@oxnxo

This comment has been minimized.

Show comment Hide comment
@oxnxo

oxnxo Aug 25, 2014

nice. Works perfectly!

nice. Works perfectly!

@adcp

This comment has been minimized.

Show comment Hide comment
@adcp

adcp Apr 13, 2015

I use Joomla 2.5.7 and it's work!. Thanks!.

adcp replied Apr 13, 2015

I use Joomla 2.5.7 and it's work!. Thanks!.

@toneeedotcom

This comment has been minimized.

Show comment Hide comment
@toneeedotcom

toneeedotcom Aug 3, 2015

The code is written differently in Joomla! 3.4.3. The URLs referenced in plugins/captcha/recaptcha/recaptcha.php are indeed correct, but the reCAPTCHA plugin fails to insert the proper JavaScript into the document head. See below:

class PlgCaptchaRecaptcha extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @SInCE 3.1
*/
protected $autoloadLanguage = true;

/**
 * Initialise the captcha
 *
 * @param   string  $id  The id of the field.
 *
 * @return  Boolean True on success, false otherwise
 *
 * @throws  Exception
 *
 * @since  2.5
 */
public function onInit($id = 'dynamic_recaptcha_1')
{
    $document = JFactory::getDocument();
    $app      = JFactory::getApplication();

    JHtml::_('jquery.framework');

    $lang       = $this->_getLanguage();
    $version    = $this->params->get('version', '1.0');
    $pubkey     = $this->params->get('public_key', '');

    if ($pubkey == null || $pubkey == '')
    {
        throw new Exception(JText::_('PLG_RECAPTCHA_ERROR_NO_PUBLIC_KEY'));
    }

    switch ($version)
    {
        case '1.0':
            $theme = $this->params->get('theme', 'clean');

            $file = $app->isSSLConnection() ? 'https' : 'http';
            $file .= '://www.google.com/recaptcha/api/js/recaptcha_ajax.js';
            JHtml::_('script', $file);

            $document->addScriptDeclaration('jQuery( document ).ready(function()
            {
                Recaptcha.create("' . $pubkey . '", "' . $id . '", {theme: "' . $theme . '",' . $lang . 'tabindex: 0});});'
            );
            break;
        case '2.0':
            $theme = $this->params->get('theme2', 'light');

            $file = $app->isSSLConnection() ? 'https' : 'http';
            $file .= '://www.google.com/recaptcha/api.js?hl=' . JFactory::getLanguage()
                    ->getTag() . '&render=explicit';

            JHtml::_('script', $file, true, true);

            $document->addScriptDeclaration('jQuery(document).ready(function($) {$(window).load(function() {'
                . 'grecaptcha.render("' . $id . '", {sitekey: "' . $pubkey . '", theme: "' . $theme . '"});'
                . '});});'
            );
            break;
    }

    return true;
}

The code is written differently in Joomla! 3.4.3. The URLs referenced in plugins/captcha/recaptcha/recaptcha.php are indeed correct, but the reCAPTCHA plugin fails to insert the proper JavaScript into the document head. See below:

class PlgCaptchaRecaptcha extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @SInCE 3.1
*/
protected $autoloadLanguage = true;

/**
 * Initialise the captcha
 *
 * @param   string  $id  The id of the field.
 *
 * @return  Boolean True on success, false otherwise
 *
 * @throws  Exception
 *
 * @since  2.5
 */
public function onInit($id = 'dynamic_recaptcha_1')
{
    $document = JFactory::getDocument();
    $app      = JFactory::getApplication();

    JHtml::_('jquery.framework');

    $lang       = $this->_getLanguage();
    $version    = $this->params->get('version', '1.0');
    $pubkey     = $this->params->get('public_key', '');

    if ($pubkey == null || $pubkey == '')
    {
        throw new Exception(JText::_('PLG_RECAPTCHA_ERROR_NO_PUBLIC_KEY'));
    }

    switch ($version)
    {
        case '1.0':
            $theme = $this->params->get('theme', 'clean');

            $file = $app->isSSLConnection() ? 'https' : 'http';
            $file .= '://www.google.com/recaptcha/api/js/recaptcha_ajax.js';
            JHtml::_('script', $file);

            $document->addScriptDeclaration('jQuery( document ).ready(function()
            {
                Recaptcha.create("' . $pubkey . '", "' . $id . '", {theme: "' . $theme . '",' . $lang . 'tabindex: 0});});'
            );
            break;
        case '2.0':
            $theme = $this->params->get('theme2', 'light');

            $file = $app->isSSLConnection() ? 'https' : 'http';
            $file .= '://www.google.com/recaptcha/api.js?hl=' . JFactory::getLanguage()
                    ->getTag() . '&render=explicit';

            JHtml::_('script', $file, true, true);

            $document->addScriptDeclaration('jQuery(document).ready(function($) {$(window).load(function() {'
                . 'grecaptcha.render("' . $id . '", {sitekey: "' . $pubkey . '", theme: "' . $theme . '"});'
                . '});});'
            );
            break;
    }

    return true;
}
@yimilan

This comment has been minimized.

Show comment Hide comment
@yimilan

yimilan Oct 20, 2017

Tengo un problema con recaptcha en la versión de joomla 3.7 y el modulo K2 al configurarlo me lanza un mensaje que todos los campos deben estar llenos y todos lo estan.

Tengo un problema con recaptcha en la versión de joomla 3.7 y el modulo K2 al configurarlo me lanza un mensaje que todos los campos deben estar llenos y todos lo estan.

Please sign in to comment.