Description: Captcha is a system plugin to produce and verify captcha images. We use freecap lib from: http://www.puremango.co.uk/cm_php_captcha_script_113.php Download:Available from Joomlacode here: http://joomlacode.org/gf/project/ostwigits/frs/?action=FrsReleaseBrowse&frs_package_id=2652 Functions: null display() -- Produces the image, see example
bool confirm( $word ) -- Confirms if the passed word matches the captcha image produced in display.
* See configuration items in plugin params
Examples (Non-Trigger):Displaying an image: In order to show the image, your component is used to build the data and display to user. The recommended way is to implement the following code in your controler class: function displayimg() { // By default, just display an image $document = &JFactory::getDocument(); $doc = &JDocument::getInstance('raw'); // Swap the objects $document = $doc; plgSystemCaptcha::display(); } This will produce a raw output of the image. When displaying your form, you would then just call your own component with &task=displayimg appending the url: echo "<form method='post'>"; echo "<img src='/index.php?option=com_freecap&task=displayimg'><BR>"; echo "<input type='text' name='word'><BR>"; echo "<input type='submit'>"; Confirming the word:A simple way to confirm the word would be the following code (Assuming the word is given via the post variable "word"): $word = JRequest::getVar('word', false, '', 'CMD'); if (plgSystemCaptcha::confirm($word)) { echo "You got it right<BR><BR>"; }
Examples (Using Trigger):Displaying an image: In order to show the image, your component is used to build the data and display to user. The recommended way is to implement the following code in your controler class: function displayimg() { global $mainframe; // By default, just display an image $document = &JFactory::getDocument(); $doc = &JDocument::getInstance('raw'); // Swap the objects $document = $doc; $mainframe->triggerEvent('onCaptcha_display', array()); } This will produce a raw output of the image. When displaying your form, you would then just call your own component with &task=displayimg appending the url: echo "<form method='post'>"; echo "<img src='/index.php?option=com_freecap&task=displayimg'><BR>"; echo "<input type='text' name='word'><BR>"; echo "<input type='submit'>"; Confirming the word:A simple way to confirm the word would be the following code (Assuming the word is given via the post variable "word"): global $mainframe; $return = false; $word = JRequest::getVar('word', false, '', 'CMD'); $mainframe->triggerEvent('onCaptcha_confirm', array($word, &$return)); if ($return) { echo "You got it right<BR><BR>"; }
|