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: Recaptcha integration
Pages: 1 [2]   Go Down
  Print  
Author Topic: Recaptcha integration  (Read 12354 times)
0 Members and 3 Guests are viewing this topic.
Grinse
Newbie
*

Karma: 0
Offline Offline

Posts: 15


« Reply #15 on: June 22, 2011, 00:06:49 »

Ok, I updated my instructions as followed now (should work with JComments 2.2.0.2):

Modifiy jcomments.ajax.php (components/com_jcomments/jcomments.ajax.php):
Replace (lines 254 - 285):
Code:
if ($acl->check('enable_captcha') == 1) {

$captchaEngine = $config->get('captcha_engine', 'kcaptcha');

if ($captchaEngine == 'kcaptcha') {
with:
Code:
$captchaEngine = $config->get('captcha_engine', 'recaptcha');

if ($captchaEngine == 'recaptcha') {

require_once(JCOMMENTS_BASE.DS.'libraries/recaptcha/'.'recaptchalib.php');
$privatekey = "<place your own private key here>";
$resp = null;
$error = null;
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$error = $resp->error;
JCommentsAJAX::showErrorMessage($response, 'captcha', JText::_('ERROR_CAPTCHA'), true);
# if (JCommentsCaptcha::attempts() > 3) {
# JCommentsCaptcha::destroy();
# $response->addScript("jcomments.clear('captcha');");
# }
return $response;
}
} elseif ($captchaEngine == 'kcaptcha') {


Modifiy tpl_form.php (components/com_jcomments/tpl/default/tpl_form.php):
Replace (lines 100 - 113):
Code:
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>
<img class="captcha" onclick="jcomments.clear('captcha');" id="comments-form-captcha-image" name="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 />
</p>
<?php
                 }
with:
Code:
if ($this->getVar('comments-form-captcha', 0) == 1) {
$captcha = 'recaptcha';
if ($captcha == 'recaptcha') {
$publickey = "<place your own pubilc key here>";
$theme = "white";
$lang = "de";
require_once(JCOMMENTS_BASE.DS.'libraries/recaptcha/'.'recaptchalib.php');
$js = "var RecaptchaOptions = {"."\n";
$js .= "theme : '".$theme."',"."\n";
$js .= "lang : '".$lang."'"."\n";
$js .= "};";
$recaptchaOptions =& JFactory::getDocument();
$recaptchaOptions->addScriptDeclaration($js);
?>
<span id="comments-form-captcha" name="captcha-refid"><?php echo recaptcha_get_html($publickey$error); ?></span>
<?php
} elseif ($captcha == 'kcaptcha') {
$html $this->getVar('comments-form-captcha-html');
if ($html != '') {
echo $html;
} else {
$link JCommentsFactory::getLink('captcha');
?>

<p>
<img class="captcha" onclick="jcomments.clear('captcha');" id="comments-form-captcha-image" name="captcha-image" src="<?php echo $link?>" width="120" 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 />
</p>
<?php
}
}
}

The rest should be the same like I mentioned before.
Logged
thulasi
Newbie
*

Karma: 0
Offline Offline

Posts: 2


« Reply #16 on: July 28, 2011, 16:01:57 »

i am using 2.2.0.2 version of jcomments.

i  try to implement recaptcha by following your instruction. recaptcha is displaying in comment section but i am not able to post new commnet.

please send solution
Logged
Grinse
Newbie
*

Karma: 0
Offline Offline

Posts: 15


« Reply #17 on: July 28, 2011, 16:42:08 »

Ok I attached all the needed files here. Just unzip them into your Joomla root directory.

Don't forget to insert your private key and public key inside jcomments.ajax.php and tpl_form.php and to change the theme and language to your needs (at the moment it's set to red and english).

My mod is compatible with Jcomments 2.2.0.2 and uses the Recaptcha PHP Framework 1.11.


Also check your configuration if your user has the needed rights to post comments and check also if you use a template override for Jcomments within your templates folder.

* jcomments_recaptcha-0.2.zip (17.31 KB - downloaded 121 times.)
« Last Edit: July 28, 2011, 16:44:13 by Grinse » Logged
thulasi
Newbie
*

Karma: 0
Offline Offline

Posts: 2


« Reply #18 on: August 02, 2011, 12:58:51 »

i followed ur guidelines but,this is not working for me.
Logged
Grinse
Newbie
*

Karma: 0
Offline Offline

Posts: 15


« Reply #19 on: August 02, 2011, 15:41:40 »

Hm, you already made the recaptcha registration for your domain?
I' don't have aclue at the moment what you make wrong.

I tested my previously attached files on a Joomla 1.5.24 and JComments2.2.0.2 installation and it works.

Check your JComments configuration if your user group has rights to write comments and if the captcha use is enabled there.

At the moment you just need to enable captcha in general in the configuration. I used a hardcoded value in the modified files so it's always used recaptcha (and not kcaptcha).

And again: Checkif you have atemplate override in your joomla templates folder where you missed to add the modifications.

At the moment I'mnot home so I can't access my testing enviroment or the servers I added the recaptcha mod to. But I can check it out in a few days.

Greetings Grinse


Btw. There seems to be a recaptcha plugin developed by Smart but he's not publishing it. Smiley
Maybe you can ask him if he will soon (I tried in the past already).

Logged
joerinehart
Newbie
*

Karma: 0
Offline Offline

Gender: Male
Posts: 1



WWW
« Reply #20 on: December 29, 2011, 01:05:34 »

Spent hours on the problem, using every recommended change, but only got a white screen! 

Using:
Joomla Version 1.5.25
com_jcomments_v2.2.0.2.zip
FreeBSD 8.2p5
PHP 5.3.8


Finally decided to remove Jcomments completely, not that it wasn't a great component, but rather, people calling me to inform me my captcha's don't work, and the alternative is insanity Sad

Logged
automatix
Newbie
*

Karma: 0
Offline Offline

Posts: 1


Email
« Reply #21 on: February 11, 2012, 00:48:19 »

Hi, I'm wondering about how to integrate ReCaptcha in JComments

the line

echo recaptcha_get_html($publickey);

outputs this code:

<script src="http://www.google.com/recaptcha/api/challenge?k=my_public_key_here" type="text/javascript"/>
   <noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=my_public_key_here" height="300" width="500" frameborder="0"></iframe>


But after ajax load the javascript not load.

I need know how add some javascript after form load or how execute the javascript included on showform call.

Sorry for my english and thank you for your great component.

Logged
wcpreston
Newbie
*

Karma: 0
Offline Offline

Posts: 1


« Reply #22 on: February 17, 2012, 07:07:18 »

Like the previous poster, I also got a white screen when trying to use this.

I tried editing the files myself and downloaded the files you provided.  I am registered with recaptcha  and put my public and private keys in the two places.  (There are only two places, right?  publickey in one file and privatekey in the other file? I ask this because you say nothing about this in your instructions.)

I am using
Joomla 1.5.20
Jcomments 2.2.0.2

I have nothing in my tpl directory by default.  I have already enabled guest comments.
Logged
Pages: 1 [2]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    Integration with third-party extensions    Topic: Recaptcha integration
 
Jump to: