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 3   Go Down
  Print  
Author Topic: Recaptcha integration  (Read 77101 times)
0 Members and 1 Guest are viewing this topic.
Grinse
Jr. Member
**

Karma: 0
Offline Offline

Posts: 10


« on: December 20, 2009, 19:36:48 »

Hi there,
I figured out how to integrate ReCaptcha into JComments (instead of the build in KCaptcha).
I noticed a thread on http://joomlaforum.ru/index.php?topic=80311.0 but as it is written in Russian I decided to open a new thread here.

What you have to do to add ReCaptcha support:
Code:
<html><body bgcolor="#FFFFFF"></body></html>
  • Modifiy jcomments.ajax.php (components/com_jcomments/jcomments.ajax.php):
Replace (lines 215 - 226):
Code:
if ($acl->check('enable_captcha') == 1) {
require_once( JCOMMENTS_BASE.DS.'jcomments.captcha.php' );

if (!JCommentsCaptcha::check($values['captcha-refid'])) {
JCommentsAJAX::showErrorMessage($response, 'captcha', JText::_('ERROR_CAPTCHA'), true);
if (JCommentsCaptcha::attempts() > 3) {
JCommentsCaptcha::destroy();
$response->addScript("jcomments.clear('captcha');");
}
return $response;
}
}
with:
Code:
if ($acl->check('enable_captcha') == 1) {
require_once( JCOMMENTS_BASE.DS.'jcomments.captcha.php' );

$captcha = 'recaptcha';
if ($captcha == '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 ($captcha == 'kcaptcha') {
if (!JCommentsCaptcha::check($values['captcha-refid'])) {
JCommentsAJAX::showErrorMessage($response, 'captcha', JText::_('ERROR_CAPTCHA'), true);
if (JCommentsCaptcha::attempts() > 3) {
JCommentsCaptcha::destroy();
$response->addScript("jcomments.clear('captcha');");
}
return $response;
}
}
}
  • Modifiy tpl_form.php (components/com_jcomments/tpl/default/tpl_form.php):
Replace (lines 111 - 120):
Code:
if ($this->getVar('comments-form-captcha', 0) == 1) {
$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
}
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') {
$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
}
}
    You can change $lang to any of the predefined values:
    • English:  en
    • Dutch:  nl
    • French:  fr
    • German:  de
    • Portuguese:  pt
    • Russian:  ru
    • Spanish:  es
    • Turkish:  tr

    You also can change $theme to any of the predefined values:
    • red
    • white
    • blackglass
    • clean
    • custom

    You also can change $captcha (in both files!) to any of the predefined values:
    • recaptcha:  Recaptcha validation
    • kcaptcha:  build in KCaptcha validation


    What can be improved in the future:
    • Automatic detection of the used site language (but somehow my site language parameter seems to be empty?).
    • Ability to change the parameters ($publickey, $privatekey, $lang, $theme, $captcha, custom theme configuration) within the administration site.


    Bugs:
    • I noticed that when you type in one word correct and the other is wrong, the challange succeed. Also when you type in nothing the challange fails but don't tells you why. But when you type in both words correct it succeeds and when you type in nothing right the challange fails.
    • The field does not refresh when you make a misstake.
    I try to fix the bugs so the addon works in the right way. Maybe someone can help?


    Have fun
    Grinse
    « Last Edit: February 02, 2011, 22:15:31 by Grinse » Logged
    smart
    Administrator
    Hero Member
    *****

    Karma: 186
    Offline Offline

    Gender: Male
    Posts: 1913



    WWW
    « Reply #1 on: December 20, 2009, 23:03:42 »

    Thank you for this job! It would be good temporary solution!

    In January I'm going to release JComments plugin to support 3rd party CAPTCHA's (reCAPTCHA already implemented and now testing on some sites).
    Logged

    If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
    Grinse
    Jr. Member
    **

    Karma: 0
    Offline Offline

    Posts: 10


    « Reply #2 on: December 21, 2009, 04:24:37 »

    So do you plan to support ReCaptcha by your own implementation or do you want to support 3rd Party Captcha-Plugins (like the plugin mentioned in the Russian Forum)?

    I'm looking forward to that addon.

    Btw. do you also plan to support Akismt one day? Especially for Guestbooks, Comments etc. it is a good tool to detect spam.

    Thanks
    Grinse
    Logged
    smart
    Administrator
    Hero Member
    *****

    Karma: 186
    Offline Offline

    Gender: Male
    Posts: 1913



    WWW
    « Reply #3 on: December 21, 2009, 04:40:19 »

    In upcoming JComments version already implemented support new type of plugin for CAPTCHA. And I have already made first plugin for support reCAPTCHA . When this plugin is installed and published in JComments settings administrator can select between KCAPTCHA and reCAPTCHA (in future I'm going expand this plugin with other CAPTCHA's).

    Concerning Akismet - this service already supported in JComments Antispam plugin. But this plugin at this moment isn't public because it needs some rework. It was made about year ago and did not updated for this time.

    If you wish to take part in testing a new version of the component and plugin JComments CAPTCHA, I can send you a newer version. Contact me via PM for more details.

    Logged

    If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
    marco
    Newbie
    *

    Karma: 0
    Offline Offline

    Posts: 4


    « Reply #4 on: January 23, 2010, 15:40:05 »

    Concerning Akismet - this service already supported in JComments Antispam plugin. But this plugin at this moment isn't public because it needs some rework. It was made about year ago and did not updated for this time.

    Have you made any progress on the akismet development? What will be the release date?

    I'm want to use jcomments on my site, however, I really need akismet protection.
    I will not do migration without it.
    Logged
    marco
    Newbie
    *

    Karma: 0
    Offline Offline

    Posts: 4


    « Reply #5 on: January 28, 2010, 13:42:11 »

    bump.

    Any news? When will akismet be availlable?
    Logged
    marco
    Newbie
    *

    Karma: 0
    Offline Offline

    Posts: 4


    « Reply #6 on: February 08, 2010, 17:33:11 »

    sorry to see that nobody wants to answer this question.
    Logged
    marco
    Newbie
    *

    Karma: 0
    Offline Offline

    Posts: 4


    « Reply #7 on: February 17, 2010, 23:02:05 »



    Concerning Akismet - this service already supported in JComments Antispam plugin. But this plugin at this moment isn't public because it needs some rework. It was made about year ago and did not updated for this time.

    If you wish to take part in testing a new version of the component and plugin JComments CAPTCHA, I can send you a newer version. Contact me via PM for more details.



    Come on guys, please take a look at this question.
    Logged
    Beauty
    Newbie
    *

    Karma: 0
    Offline Offline

    Gender: Female
    Posts: 1


    Beauty Loves Beasty xXx


    WWW
    « Reply #8 on: April 28, 2010, 23:59:46 »

     Angry
    I've got captcha issues so i thought i'd give this a go - but i couldn't get it to work

    SMART - i would love to try out the new reCaptcha plugin (beta) its must be safer than disabling my captcha - which is what i have had to do now!

    Beauty
    x
    Logged
    Grinse
    Jr. Member
    **

    Karma: 0
    Offline Offline

    Posts: 10


    « Reply #9 on: April 29, 2010, 02:52:20 »

    I tried to get the recaptcha plugin too - but he's not replying.
    Logged
    scyllar
    Newbie
    *

    Karma: 0
    Offline Offline

    Posts: 7


    Email
    « Reply #10 on: May 12, 2010, 17:19:38 »

    Quote
    In upcoming JComments version already implemented support new type of plugin for CAPTCHA. And I have already made first plugin for support reCAPTCHA . When this plugin is installed and published in JComments settings administrator can select between KCAPTCHA and reCAPTCHA (in future I'm going expand this plugin with other CAPTCHA's).

    V2.2 is available and i am happy to read about the following in the release note v2.2.0:

    Quote
    CAPTCHA
    Added support of 3rd party CAPTCHA implementations (via plugins).
    CAPTCHA switched off automatically if GD library isn't installed.
    Added a small hack to allow CAPTCHA image display even if some notice or warning occurred.

    But the option is still grey after install v2.2 so the plugin isn't included in the new version package. Can't wait to see the plugin! Smiley



    « Last Edit: May 13, 2010, 16:49:24 by scyllar » Logged
    smart
    Administrator
    Hero Member
    *****

    Karma: 186
    Offline Offline

    Gender: Male
    Posts: 1913



    WWW
    « Reply #11 on: May 20, 2010, 14:32:21 »

    But the option is still grey after install v2.2 so the plugin isn't included in the new version package. Can't wait to see the plugin! Smiley
    It is grey because no captcha plugin was installed and used only built-in CAPTCHA implementation...  I'll release custom CAPTCHA plugin in nearest future...  It will support reCAPTCHA and w3captcha implementations... Be patient please Wink I'm alone develper and couldn't make all things at once...
    Logged

    If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
    Grinse
    Jr. Member
    **

    Karma: 0
    Offline Offline

    Posts: 10


    « Reply #12 on: February 02, 2011, 05:18:02 »

    So did you finish your 3rd party captcha plugins (so we can use recaptcha via plugin now)?
    You laos mentioned once that you plan to offer a akismet plugin. What happened to that?

    At the moment I think about the right Comment system for my community site. JComments is nice (it's free n my template as already a design to support JComments) but Jomcomment has already all these plugins so I'm not sure.

    Greetings
    Grinse
    Logged
    Brandala
    Newbie
    *

    Karma: 0
    Offline Offline

    Posts: 3


    « Reply #13 on: February 20, 2011, 08:48:59 »

    Dear Joomlatune,

    I really would like to add ReCaptha to Jcomments on my site.  I have tried to follow the above instructions , but it did not work for me.  I cannot find the exact following codes to edit:

    Modifiy jcomments.ajax.php (components/com_jcomments/jcomments.ajax.php):
    Replace (lines 215 - 226):

             if ($acl->check('enable_captcha') == 1) {
                   require_once( JCOMMENTS_BASE.DS.'jcomments.captcha.php' );

                   if (!JCommentsCaptcha::check($values['captcha-refid'])) {
                      JCommentsAJAX::showErrorMessage($response, 'captcha', JText::_('ERROR_CAPTCHA'), true);
                      if (JCommentsCaptcha::attempts() > 3) {
                         JCommentsCaptcha::destroy();
                         $response->addScript("jcomments.clear('captcha');");
                      }
                      return $response;
                   }
                }


    AND

    Modifiy tpl_form.php (components/com_jcomments/tpl/default/tpl_form.php):
    Replace (lines 111 - 120):

          if ($this->getVar('comments-form-captcha', 0) == 1) {
             $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
          }



    Have these codes changed?  Because I cannot find them in their relevant files.  If so, can you please provide the new codes to edit?  Thank you for your help and for providing such a great Joomla comments component!

    Best wishes,

    Brandala.com
    « Last Edit: February 20, 2011, 08:50:44 by Brandala » Logged
    petunia
    Newbie
    *

    Karma: 0
    Offline Offline

    Posts: 6


    « Reply #14 on: June 21, 2011, 22:20:39 »

    any news on this???

    i would like to have a recaptcha integration plzzz!!

    This thread is old but i cant found any news on this

     Huh
    Logged
    Pages: [1] 2 3   Go Up
      Print  
    JoomlaTune Support Forum    JComments component    Integration with third-party extensions    Topic: Recaptcha integration
     
    Jump to: