Nowadays, spammers are a real threat for websites. Because each website has a contact from, such forms are used by spammers in order to send spam over internet. In this article I share a way how one can protect by captcha field the “Product enquiry” form in Virtuemart 1.8 which works on Joomla 1.5.26.
The simple way is to install tinCaptcha component and plugin. We can download it from here: tinCaptcha v.1.1.
- First of all, we are to unpack the archive and get 2 files for component and plugin.
- Install the component first;
- Install the plugin;
- Go to “Extensions”->”Plugin Manager” and enable the plugin with the name as follows: “System - TinCaptcha”;
- By now, we are to change the code of VirtueMart as it is described in tincaptcha-v0.1.txt file which one can find in the same directory where the whole package was unpacked at step 1 of the guide:
- File: components/com_virtuemart/themes/default/templates/pages/shop.ask.tpl.php
LINE ~34:
[Code]
-------------------------------------------------------------------------
<textarea rows="10" cols="60" name="text" id="contact_text" class="inputbox">
</textarea><br />
ADD AFTER:
[Code]
------------------------------------------------------------------------
<label for="tincaptcha">
- LINE ~61 (before aforementioned update):
[Code]
------------------------------------------------------------------------
} else {
document.emailForm.action = ""
document.emailForm.submit();
}
ADD BEFORE:
[Code]
------------------------------------------------------------------------
} else if ( document.emailForm.captcha.value == "" ) {
alert( "" );
- File: administrator/components/com_virtuemart/classes/ps_communication.php
IN FUNCTION: mail_question()
LINE ~138:
[Code]
------------------------------------------------------------------------
if ($db->f("product_sku") @$d["product_sku"] ) {
$vmLogger->err( $VM_LANG->_('NOT_AUTH',false) );
return false;
}
ADD AFTER:
[Code]
------------------------------------------------------------------------
if (JPluginHelper::isEnabled('system', 'tincaptcha'))
{
$checkSecurity = plgSystemTincaptcha::check( vmRequest::getVar('captcha', '', 'post') );
if ($checkSecurity !== true)
{
JError::raiseError(500, $checkSecurity);
return false;
}
}
- File: components/com_virtuemart/themes/default/templates/pages/shop.ask.tpl.php
We are done, enjoy!