| Contact section of Joomla! 1.5 using SecurityImages 5.0 |
|
|
| Thursday, 20 March 2008 19:38 | ||||||||||
|
SecurityImages BETA will be available in no more than 2 days... Note that SecurityImages is still WAY to intrusive toward Joomla! as core file has to be changed in order to use Captcha. Lets take the contact section of Joomla! as an example.
It is always recommended to use a switch in all your component to activate deactivate SecurityImages per components through the administrator control panel. This is done by adding to administrator/components/com_contact/contact_items.xml the following code: <param name="useSecurityImages" type="radio" default="1" label="Use SecurityImage Captcha" description="Enable Captcha verification"> Joomla will read this xml file on the fly and build the graphical user interface for the contact settings. Since Joomla! 1.5 now use a Model View Controller paradigm, we have to alter the controller, and add a new Task displaySecurityImagesCaptcha()in components/com_contact/controller.php: function displaySecurityImagesCaptcha() { global $mainframe; //Per contact you can define if the user has to resolve the capctha $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('useSecurityImages')) { $check = null; $mainframe->triggerEvent('onSecurityImagesDisplay', array($check)); if (!$check) { echo "<br/>Erreur affichage du Captcha<br/>"; } } } The next step is to add the task checkSecurityImagesCaptcha() checking the captcha in the components/com_contact/controller.php function checkSecurityImagesCaptcha() { 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 ); //check if that user has a capctha if (!$params->get('useSecurityImages')) { return true; } $return = false; $securityImagesJoomlaContactUserTry = JRequest::getVar('securityImagesJoomlaContactUserTry', false, '', 'CMD'); $mainframe->triggerEvent('onSecurityImagesCheck', array($securityImagesJoomlaContactUserTry &$return)); return $return; } global $mainframe; if (!$this->checkSecurityImagesCaptcha()) { JError::raiseWarning("999","Invalid Captcha Code"); $this->display(); return false; } to display the Captcha field <?php if ($this->params->get('useSecurityImages')) { ?> <img src="/index.php?option=com_contact&task=displaySecurityImagesCaptcha&contact_id=<?php echo $this->contact->id; ?>"> <br /> <input type="text" name="securityImagesJoomlaContactUserTry" /> <br /> <?php } ?>
Powered by !JoomlaComment 3.20
3.20 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."
|
||||||||||
| Last Updated on Thursday, 20 March 2008 18:40 |
| Another articles: |
|---|
|
| Powered By relatedArticle |












Tags
