TinCaptcha v0.1.1 Tutorial
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I. INTEGRATED WITH JOOMLA CONTACT FORM
1. Install both com_tincaptcha and plg_tincaptcha
(remember active plugin, we can change some settings in the plugin)
2. In File components/com_contact/controller.php,
FIND and ADD like this:
[Code]
------------------------------------------------------------------------
function submit()
{
global $mainframe;
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
// tincaptcha-
$captchk = plgSystemTincaptcha::check(JRequest::getVar('captcha', '', 'post'));
if ($captchk !== true)
{
JError::raiseWarning(0, $captchk);
return false;
}
// -tincaptcha
========================================================================
3. In File components/com_contact/views/contact/tmpl/default_form.php,
FIND and ADD:
[Code]
------------------------------------------------------------------------
========================================================================
* Note1:
Use this code for image tag above if you want the user click on the
image for refeshing
[Code]
------------------------------------------------------------------------
========================================================================
* Note2:
I do not put "$this->display()" after "JError::raiseWarning()" because
it just displays an empty form.
You might want to use "raiseError()" instead, it will display only error
page
[Code]
------------------------------------------------------------------------
JError::raiseError(500, $captchk);
========================================================================
* Note3: when we typed wrong captcha and go back, all form data are
cleared. They can be stored by changing code in:
libraries/joomla/environment/response.php
[Code]
------------------------------------------------------------------------
//JResponse::setHeader( 'Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false ); // <-- browsers can not remember form
JResponse::setHeader( 'Cache-Control', 'post-check=0, pre-check=0', false ); // <--browsers can with this
========================================================================
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
II. INTEGRATE WITH VIRTUEMART V1.1.1 REGISTRATION
http://forum.virtuemart.net/index.php?topic=40043.0
1. Install com_tincaptcha and plg_tincaptcha.
2. FILE: administrator/components/com_virtuemart/html/admin.user_field_form.php
LINE ~81:
[Code]
------------------------------------------------------------------------
if( file_exists($mosConfig_absolute_path.'/administrator/components/com_securityimages/client.php')) {
========================================================================
REPLACE WITH:
[Code]
------------------------------------------------------------------------
if (JPluginHelper::isEnabled('system', 'tincaptcha')) { // tincaptcha
========================================================================
3. FILE: administrator/components/com_virtuemart/classes/ps_userfield.php
LINE ~429:
[Code]
------------------------------------------------------------------------
if (file_exists($mosConfig_absolute_path.'/administrator/components/com_securityimages/client.php')) {
include ($mosConfig_absolute_path.'/administrator/components/com_securityimages/client.php');
// Note that this package name must be used on the validation site too! If both are not equal, validation will fail
$packageName = 'securityVMRegistrationCheck';
echo insertSecurityImage($packageName);
echo getSecurityImageText($packageName);
}
========================================================================
REPLACE WITH:
[Code]
------------------------------------------------------------------------
if (JPluginHelper::isEnabled('system', 'tincaptcha'))
{
echo ' '."\n";
}
========================================================================
4. FILE: administrator/components/com_virtuemart/classes/ps_shopper.php
*) LINE ~76:
[Code]
------------------------------------------------------------------------
if( file_exists($mosConfig_absolute_path.'/administrator/components/com_securityimages/server.php')) {
include_once( $mosConfig_absolute_path.'/administrator/components/com_securityimages/server.php');
$packageName = 'securityVMRegistrationCheck';
$security_refid = vmGet($_POST, $packageName.'_refid');
$security_try = vmGet($_POST, $packageName.'_try');
$security_reload = vmGet($_POST, $packageName.'_reload');
$checkSecurity = checkSecurityImage($security_refid, $security_try );
if( !$checkSecurity ) {
$provided_required = false;
$missing .= $field->name . ",";
}
}
========================================================================
REPLACE WITH:
[Code]
------------------------------------------------------------------------
if (JPluginHelper::isEnabled('system', 'tincaptcha'))
{
$checkSecurity = plgSystemTincaptcha::check($d[$field->name]);
if ($checkSecurity !== true)
{
$provided_required = false;
$missing .= $field->name . ",";
JError::raiseWarning(0, $checkSecurity);
}
}
========================================================================
*) LINE ~176:
[Code]
------------------------------------------------------------------------
if( file_exists($mosConfig_absolute_path.'/administrator/components/com_securityimages/server.php')) {
include_once( $mosConfig_absolute_path.'/administrator/components/com_securityimages/server.php');
$packageName = 'securityVMRegistrationCheck';
$security_refid = vmGet($_POST, $packageName.'_refid');
$security_try = vmGet($_POST, $packageName.'_try');
$security_reload = vmGet($_POST, $packageName.'_reload');
$checkSecurity = checkSecurityImage($security_refid, $security_try );
if( !$checkSecurity ) {
$provided_required = false;
$missing .= $field->name . ",";
}
}
========================================================================
REPLACE WITH:
[Code]
------------------------------------------------------------------------
if (JPluginHelper::isEnabled('system', 'tincaptcha'))
{
$checkSecurity = plgSystemTincaptcha::check($d[$field->name]);
if ($checkSecurity !== true)
{
$provided_required = false;
$missing .= $field->name . ",";
JError::raiseWarning(0, $checkSecurity);
}
}
========================================================================
5. Create new field.
http://img131.imageshack.us/img131/2211/vmep9.jpg
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
II. INTEGRATE WITH VIRTUEMART V1.1.1 PRODUCT ENQUIRY
This hack does not show the form if we enter wrong captcha.
Instead, it shows the joomla error page. We can back and try again,
for form caching, please read the post in Joomla forum.
1. File: components/com_virtuemart/themes/default/templates/pages/shop.ask.tpl.php
LINE ~34:
[Code]
------------------------------------------------------------------------
========================================================================
ADD AFTER:
[Code]
------------------------------------------------------------------------