Skip to Content Skip to Menu

Using the "CB Captcha" feature in own CB plugin

17 years 4 weeks ago #48652 by freakshowtm
Replied by freakshowtm on topic Re:Using the "CB Captcha" feature in own CB plugin
thanks in advance..

i'll be looking forward to that..:P

Please Log in or Create an account to join the conversation.

  • beat
  • beat
  • ONLINE
  • Posts: 2169
  • Thanks: 463
  • Karma: 352
17 years 4 weeks ago #48654 by beat
I'm posting this as a reference, and also to give you a hint on how to use CB plugins from other CB plugins, or joomla/mambo modules, components or mambots:

Check the code of mod_cblogin.php of CB 1.1 and also of CB captcha 2.0, you will see that using any CB-compatible captcha engine, including CB captcha v2.0 (not v1.0) from another CB plugin is matter of a few lines of code (basically, generating the CB-event to get the captcha html code, and another event to check):

We have defined new events in CB 1.1 which are not yet official, since they are experimental, so not sure that the next major release of CB will support this, but hey, it's a few lines of code...:

Something like this should work (not tested):

within your <form> :

[code:1]
<?php
if ( $cb_plugins_captcha ) {
include_once( $absolute_path . "/administrator/components/com_comprofiler/plugin.class.php"«»);
global $_PLUGINS;

$generateFullHtml = true;

$_PLUGINS->loadPluginGroup('user');
$pluginsResults = $_PLUGINS->trigger( 'onGetCaptchaHtmlElements', array( generateFullHtml ) );
if ( implode( $pluginsResults ) != '' ) {
$divHtml = '<div class="your_formatting">' ;
echo $divHtml . implode( '</div>' . $divHtml, $pluginsResults ) . '</div>';
}
}
[/code:1]

To check the captcha posted:

[code:1]
<?php
if ( $cb_plugins_captcha ) {
include_once( $absolute_path . "/administrator/components/com_comprofiler/plugin.class.php"«»);
global $_PLUGINS;

$_PLUGINS->loadPluginGroup('user');
$pluginsResults = $_PLUGINS->trigger( 'onCheckCaptchaHtmlElements', array( ) );
$passed = true;
foreach( $pluginsResults as $thisResult ) {
if ( ! $thisResult ) {
$passed = false;
}
}
if ( ! $passed ) {
// do here whatever you need to do when check isn't passed.
}
}
[/code:1]

in the code above, this line:

[code:1] include_once( $absolute_path . "/administrator/components/com_comprofiler/plugin.class.php"«»);
[/code:1]

is needed in joomla/mambo modules and other components, but not in other CB plugins.

Advantages:
1) not a hack
2) This should allow you to insert accessible captcha anywhere: CB plugins, any module, any component.
3) using clean CB API methods.

I need to issue a warning here: don't put captcha everywhere: it's a pain for users, and it will not stop determined spammers. Your site processes and business model should really be the human-test factor.

Hope the code above works, as i didn't test it. Please give feedbacks here, and continue share your progress and implementations with the community here. :)

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in or Create an account to join the conversation.

  • Kampp
  • Kampp
  • OFFLINE
  • Posts: 76
  • Thanks: 10
  • Karma: 12
17 years 4 weeks ago #48664 by Kampp
Hi Beat

Thanks for you post. I have yesterday improved the "Public Mail" plugin with many many new features and additions (and a bugfix), but I got stuck at the Captcha part.

What is the difference between Captcha 1.1 and 2.0?
Are there diferences in the way the code is initiated?
Should/could I add the option of using both of them in my plugin (one at a time!)?
I can't find the 2.0 version any where?

Is the code in your post writeen for J! 1.5 or 1.x?
What captcha do I need to have installed in order to test it (1.1 or 2.0)?

Cheers, Kampp

Creator of the CB plugins: "User IP log" and "Public Mail"
Joomla! services/coding: www.toolmaster.dk
Joomla! services/coding: joomla-konsulent.dk
Danish Joomla! hosting: www.joomla-hosting.dk

Please Log in or Create an account to join the conversation.

17 years 4 weeks ago #48707 by freakshowtm
Replied by freakshowtm on topic Re:Using the "CB Captcha" feature in own CB plugin
i'm also trying to integrate captcha using beat's suggested code but no luck..:(

please post if anyone have better luck integrating captcha in public mail plugin than me..:P

Please Log in or Create an account to join the conversation.

16 years 11 months ago #51703 by freakshowtm
Replied by freakshowtm on topic Re:Using the "CB Captcha" feature in own CB plugin
any update on this?..

@Kampp

any update on integrating captcha in your public email plugin?..

Please Log in or Create an account to join the conversation.

  • beat
  • beat
  • ONLINE
  • Posts: 2169
  • Thanks: 463
  • Karma: 352
16 years 11 months ago #52400 by beat
My code above is for CB captcha v2.0 ( captcha v1.0 doesn't include all these events and html outputs, sorry) and for CB 1.1 with Joomla 1.0 and 1.5 and Mambo 4.5 and 4.6.

CB captcha 2.0 is a "thank you bonus" downloadable for our documentation subscribers and active contributors from the downloads menu. Please see our homepage for the announcement.

There are a lot of other differences between Captcha 1.0 and Captcha 2.0, Captcha version 2.0 is a rewrite and a lot lot lot of testing to make it work accross all major browsers, and with almost all (actually didn't see one where it doesn't work) site templates.

Sorry that there is a confusion between captcha 1.0 and 2.0, as we decided to keep captcha version 1.0 freely downloadable for some time. But upgrade to Captcha 2.0 is a recommended one, as it's much less sensible to bugs and errors in other code.

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum