Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

JoomlaTune Support Forum    JComments component    Integration with third-party extensions    Topic: JComments 2.3.0 Recaptcha Integration Joomla 2.5.8
Pages: [1]   Go Down
  Print  
Author Topic: JComments 2.3.0 Recaptcha Integration Joomla 2.5.8  (Read 22724 times)
0 Members and 1 Guest are viewing this topic.
stopyz
Newbie
*

Karma: 0
Offline Offline

Posts: 9


Email
« on: October 25, 2013, 05:47:13 »

METHOD FOR    Joomla 2.5 -> JComments 2.3.0




IMPORTANT


 Please Note this for Jcomments Recaptcha Integration


 Joomla 3.0 -> JComments 3.0.0

 Joomla 2.5 -> JComments 2.3.0

 Joomla 1.7 -> JComments 2.2.0.2  *NOT TESTED*

 Joomla 1.5 -> JComments 2.2.0.2  *NOT TESTED*


DON'T FORGET to insert you private and public key (or susbscribe) in your Joomla Panel administrator site (extension/plugin-manager/Captcha - ReCaptcha -> go to parameters en insert yours keys, you can select differents recaptcha theme)


METHOD FOR    Joomla 2.5 -> JComments 2.3.0



STEP 1

go to : administrator/components/com_jcomments/admin.jcomments.php at line 1066


REPLACE

Code:
$captcha[] = JCommentsHTML::makeOption('kcaptcha', 'KCAPTCHA');

WITH THIS

Code:
$captcha[] = JCommentsHTML::makeOption('kcaptcha', 'KCAPTCHA');
$captcha[] = JCommentsHTML::makeOption('recaptcha', 'RECAPTCHA');

STEP 2

go to your Joomla Panel administrator site -> Component > JComment > Settings > Layout

in CAPTCHA inputbox you can now select reCaptcha (scroll down or zoom)

STEP 3

go to : components/com_jcomments/tpl/default/tpl_form.php at line 114

REPLACE


Code:
<?php
}
if (
$this->getVar('comments-form-captcha'0) == 1) {
            
$html $this->getVar('comments-form-captcha-html');
            if (
$html != '') {
                echo 
$html;
            } else {
                
$link JCommentsFactory::getLink('captcha');
?>

<p>
    <span>
        <img class="captcha" onclick="jcomments.clear('captcha');" id="comments-form-captcha-image" src="/<?php echo $link?>" width="121" height="60" alt="<?php echo JText::_('FORM_CAPTCHA'); ?>" /><br />
        <span class="captcha" onclick="jcomments.clear('captcha');"><?php echo JText::_('FORM_CAPTCHA_REFRESH'); ?></span><br />
        <input class="captcha" id="comments-form-captcha" type="text" name="captcha_refid" value="" size="5" tabindex="6" /><br />
    </span>
</p>
<?php
            
}
        }
?>

WITH THIS

Code:
<?php
}
if (
$this->getVar('comments-form-captcha'0) == 1) {
            
$html $this->getVar('comments-form-captcha-html','kcaptcha');
            if (
$html == 'kcaptcha') {
                
$link JCommentsFactory::getLink('captcha');
?>

<p>
    <span>
        <img class="captcha" onclick="jcomments.clear('captcha');" id="comments-form-captcha-image" src="/<?php echo $link?>" width="121" height="60" alt="<?php echo JText::_('FORM_CAPTCHA'); ?>" /><br />
        <span class="captcha" onclick="jcomments.clear('captcha');"><?php echo JText::_('FORM_CAPTCHA_REFRESH'); ?></span><br />
        <input class="captcha" id="comments-form-captcha" type="text" name="captcha_refid" value="" size="5" tabindex="6" /><br />
    </span>
</p>
<?php
            
} else {
                
$link JCommentsFactory::getLink('captcha');
                                            
JPluginHelper::importPlugin('captcha');
                                            
$dispatcher JDispatcher::getInstance();
                                            
$dispatcher->trigger('onInit','dynamic_recaptcha_1');
?>

<p>
    <span>
        <div id="dynamic_recaptcha_1"></div>
    </span>
</p>
<?php
            
}
        }
?>

STEP 4

go to : components\com_jcomments\jcomments.ajax.php at line 275


REPLACE

Code:
if ($acl->check('enable_captcha') == 1)
{                    
    $captchaEngine = $config->get('captcha_engine', 'kcaptcha');
    if ($captchaEngine == 'kcaptcha')
    {
        require_once( JCOMMENTS_BASE.DS.'jcomments.captcha.php' );
        if (!JCommentsCaptcha::check($values['captcha_refid']))
        {
            self::showErrorMessage(JText::_('ERROR_CAPTCHA'), 'captcha');
            JCommentsCaptcha::destroy();
            $response->addScript("jcomments.clear('captcha');");
            return $response;
        }
    }
    else
    {
        $result = JCommentsEvent::trigger('onJCommentsCaptchaVerify', array($values['captcha_refid'], &$response));
        // if all plugins returns false
        if (!in_array(true, $result, true))
        {
            self::showErrorMessage(JText::_('ERROR_CAPTCHA'));
            return $response;
        }
    }
}

WITH THIS

Code:
if ($acl->check('enable_captcha') == 1)
{
    $captchaEngine = $config->get('captcha_engine', 'kcaptcha');
                            
    if ($captchaEngine == "recaptcha")
    {                                                                                            
        $post = JRequest::get('post');  
        JPluginHelper::importPlugin('captcha');
        $dispatcher = JDispatcher::getInstance();
        $resp = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response_field']);                                                                                                            
        
        if(!$resp[0]){
            self::showErrorMessage(JText::_('ERROR_CAPTCHA'), 'captcha');
            $response->addScript("Recaptcha.reload()");
            return $response;
        }
        else
        {
            $response->addScript("Recaptcha.reload()");
        }
    }elseif ($captchaEngine == 'kcaptcha')
    {
        require_once( JCOMMENTS_BASE.DS.'jcomments.captcha.php' );
        if (!JCommentsCaptcha::check($values['captcha_refid']))
        {
            self::showErrorMessage(JText::_('ERROR_CAPTCHA'), 'captcha');
            JCommentsCaptcha::destroy();
            $response->addScript("jcomments.clear('captcha');");
            return $response;
        }
    } else
    {
        $result = JCommentsEvent::trigger('onJCommentsCaptchaVerify', array($values['captcha_refid'], &$response));
        // if all plugins returns false
        if (!in_array(true, $result, true))
        {
            self::showErrorMessage(JText::_('ERROR_CAPTCHA'));
            return $response;
        }
    }
}

STEP 5

FINISH and you can apply css modification.


PLEASE REPORT ME IF THIS METHOD WORKING. THANKS.
« Last Edit: October 25, 2013, 19:30:28 by stopyz » Logged
libby
Newbie
*

Karma: 0
Offline Offline

Posts: 2


« Reply #1 on: March 17, 2014, 15:34:25 »

Hi
I have tried this with Joomla 2.5.19 and Jcomments 2.3.0
and I get this error message:
You have no rights to post comments

on permissions the public have the ability to post comments.

Any advice?
Logged
Pages: [1]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    Integration with third-party extensions    Topic: JComments 2.3.0 Recaptcha Integration Joomla 2.5.8
 
Jump to: