Install CAPTCHA into default Joomla 1.5 Contact form

captcha imageWith all the loads of SPAM people get on a daily basis you would think that the Joomla Dev team would have integrated a CAPTCHA feature into their contact form at the very least. Good thing we got a great community who have attempted to create CAPTCHA functionality for a few of the most widley used forms in Joomla. One of them being the default contact form.

This is a tutorial to install a CAPTCHA plugin into Joomla!. It's a hack as well as a plugin. But hey, It Works! I wish I could say the same for other CAPTCHA extensions out there.

Download the BIGO CAPTCHA 1.2 plugin from here: http://extensions.joomla.org/extensions/access-&-security/captcha/3499/details

Install the plugin into your Joomla 1.5 website.

Next we have to change the following files:

administrator/components/com_contact/contact_items.xml

components/com_contact/controller.php

components/com_contact/views/contact/tmpl/default_form.php

First we will change the administrator/components/com_contact/contact_items.xml file to give it a new parameter on the backend of Joomla.

After the on line 96 insert the following:

<param name="use_captcha" type="radio" default="1" label="Use Captcha" description="Enable Captcha verification">
<option value="0">No</option>
<option value="1">Yes</option>
</param>

Next we will change the components/com_contact/controller.php

After line 122 insert the following code:

/**
Captcha
*/
if (!$this->_checkCaptcha()) {
JError::raiseWarning("666","You have entered the wrong CAPTCHA sequence. Please try again.");
$this->display();
return false;
}


After line 395 insert the following:

/**
@author bigo
@date januray, 2008
*/
function displaycaptcha() {
global $mainframe;
$contactId = JRequest::getVar('contact_id', 0, '', 'int');
// load the contact details
$model    = &$this->getModel('contact');
$qOptions['id'] = $contactId;
$contact        = $model->getContact( $qOptions );
$params = new JParameter( $contact->params );
if ($params->get('use_captcha')) {
$Ok = null;
$mainframe->triggerEvent('onCaptcha_Display', array($Ok));
if (!$Ok) {
echo "<br/>Error displaying Captcha<br/>";
}
}
}

function _checkCaptcha() {
global $mainframe;
$contactId = JRequest::getVar('id', 0, '', 'int');
// load the contact details
$model = &$this->getModel('contact');
$qOptions['id'] = $contactId;
$contact = $model->getContact( $qOptions );
$params = new JParameter( $contact->params );
// not using captcha!
if (!$params->get('use_captcha')) {
return true;
}
$return = false;
$word = JRequest::getVar('word', false, '', 'CMD');
$mainframe->triggerEvent('onCaptcha_confirm', array($word, &$return));
if ($return) {
return true;
} else return false;
}

The above code allows our captcha to be displayed if chosen in the backend, checked and processed.

Last step is to add it to the contact form.

Open components/com_contact/views/contact/tmpl/default_form.php
Add the following code after line 63:

<?php if ($this->params->get('use_captcha')) { ?>
<!-- Bigo Captcha -->
<img src="/index.php?option=com_contact&task=displaycaptcha&contact_id=<?php echo $this->contact->id; ?>">
<br />
<input type="text" name="word" />
<br />
<?php } ?>

 

registered user groupThe Joomla!(R) name is used under a limited license from Open Source Matters in the United States and other countries.The Joomla! name and variations on it such as J, Joom, etc, is used under a limited license granted by Open Source Matters. The Joomla User Group San Diego is independent of and does not represent Open Source Matters or the Joomla! Project.

Backlink Reklam:
hack temizlik şirketi digiturk söve döküm forklift film izle Chat siteleri iyitube seri ilan youtube video indir çizgi film izle dizi izle oyun oyna kral oyun çizgi film oyunları kuran dinle evden eve nakliyat
vbulletin indir pvp server Yemek tarifi Oyun Oyna Film izle çizgi film bedava oyun oyna backlink satıs