cvs: pear /HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA Equation.php Figlet.php Image.php Word.php /HTML_QuickForm_CAPTCHA/HTML/QuickForm/Rule CAPTCHA.php
[email protected] ("Philippe Jausions")
| Newsgroups | php.pear.cvs |
|---|---|
| Message-ID | <cvsjausions1209252450@cvsserver> |
jausions Sat Apr 26 23:27:30 2008 UTC
Added files:
/pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA Equation.php
Figlet.php
Image.php
Word.php
/pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/Rule CAPTCHA.php
Log:
Finally checking in the code of HTML_QuickForm_CAPTCHA 0.3.0
jausions-20080426232730.txt
(text/plain, 17.1 KB)
http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA/Equation.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA/Equation.php +++ pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA/Equation.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Element for HTML_QuickForm to display a CAPTCHA equation * * The HTML_QuickForm_CAPTCHA package adds an element to the * HTML_QuickForm package to display a CAPTCHA equation. * * This package requires the use of a PHP session. * * PHP versions 4 and 5 * * @category HTML * @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <[email protected]> * @copyright 2006-2008 by Philippe Jausions / 11abacus * @license http://www.opensource.org/licenses/bsd-license.php New BSD * @version CVS: $Id: Equation.php,v 1.1 2008/04/26 23:27:30 jausions Exp $ * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA */ /** * Required packages */ require_once 'HTML/QuickForm/CAPTCHA.php'; require_once 'Text/CAPTCHA/Driver/Equation.php'; /** * Element for HTML_QuickForm to display a CAPTCHA equation question * * The HTML_QuickForm_CAPTCHA package adds an element to the * HTML_QuickForm package to display a CAPTCHA equation question. * * Options for the element * <ul> * <li>'min' (integer) Minimal number to use in an equation.</li> * <li>'max' (integer) Maximal number to use in an equation.</li> * <li>'severity' (integer) Complexity of the equation to resolve * (1 = easy, 2 = harder)</li> * <li>'numbersToText' (boolean) Whether to use the Numbers_Words * package to convert numbers to text,</li> * <li>'sessionVar' (string) name of session variable containing * the Text_CAPTCHA instance (defaults to * _HTML_QuickForm_CAPTCHA.)</li> * </ul> * * This package requires the use of a PHP session. * * @category HTML * @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <[email protected]> * @copyright 2006-2008 by Philippe Jausions / 11abacus * @license http://www.opensource.org/licenses/bsd-license.php New BSD * @version Release: @package_version@ * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA * @see Text_CAPTCHA_Driver_Equation */ class HTML_QuickForm_CAPTCHA_Equation extends HTML_QuickForm_CAPTCHA { /** * Default options * * @var array * @access protected */ var $_options = array( 'sessionVar' => '_HTML_QuickForm_CAPTCHA', 'severity' => 1, 'numbersToText' => false, 'phrase' => null, ); /** * CAPTCHA driver * * @var string * @access protected */ var $_CAPTCHA_driver = 'Equation'; } /** * Registers the class with QuickForm */ if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('CAPTCHA_Equation', 'HTML/QuickForm/CAPTCHA/Equation.php', 'HTML_QuickForm_CAPTCHA_Equation'); } ?> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA/Figlet.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA/Figlet.php +++ pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA/Figlet.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Element for HTML_QuickForm to display a CAPTCHA figlet * * The HTML_QuickForm_CAPTCHA package adds an element to the * HTML_QuickForm package to display a CAPTCHA figlet. * * This package requires the use of a PHP session. * * PHP versions 4 and 5 * * @category HTML * @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <[email protected]> * @copyright 2006-2008 by Philippe Jausions / 11abacus * @license http://www.opensource.org/licenses/bsd-license.php New BSD * @version CVS: $Id: Figlet.php,v 1.1 2008/04/26 23:27:30 jausions Exp $ * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA */ /** * Required packages */ require_once 'HTML/QuickForm/CAPTCHA.php'; require_once 'Text/CAPTCHA/Driver/Figlet.php'; /** * Element for HTML_QuickForm to display a CAPTCHA figlet * * The HTML_QuickForm_CAPTCHA package adds an element to the * HTML_QuickForm package to display a CAPTCHA figlet * * Options for the element * <ul> * <li>'width' (integer) Width of figlet (default is 200px)</li> * <li>'output' (string) Output format: "html", "text" or * "javascript" (default is "html").</li> * <li>'length' (integer) number of letters in the figlet * (default is 6)</li> * <li>'options' (array) only index supported is "font_file", which * should either be one figlet font file path, * or an array of figlet font file paths * (one we be picked randomly)</li> * <li>'sessionVar' (string) name of session variable containing * the Text_CAPTCHA instance (defaults to * _HTML_QuickForm_CAPTCHA.)</li> * </ul> * * This package requires the use of a PHP session. * * @category HTML * @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <[email protected]> * @copyright 2006-2008 by Philippe Jausions / 11abacus * @license http://www.opensource.org/licenses/bsd-license.php New BSD * @version Release: @package_version@ * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA * @see Text_CAPTCHA_Driver_Figlet */ class HTML_QuickForm_CAPTCHA_Figlet extends HTML_QuickForm_CAPTCHA { /** * Default options * * @var array * @access protected */ var $_options = array( 'sessionVar' => '_HTML_QuickForm_CAPTCHA', 'output' => 'html', 'width' => 200, 'length' => 6, 'phrase' => null, ); /** * CAPTCHA driver * * @var string * @access protected */ var $_CAPTCHA_driver = 'Figlet'; /** * Returns the HTML for the CAPTCHA * * This can be overwritten by sub-classes for specific output behavior * (for instance the Image CAPTCHA displays an image) * * @access public * @return string */ function toHtml() { $result = $this->_initCAPTCHA(); if (PEAR::isError($result)) { return $result; } $attr = $this->_attributes; unset($attr['type']); unset($attr['value']); unset($attr['name']); $html = $this->_getTabs() . '<div' . $this->_getAttrString($attr) . '>' . $_SESSION[$this->_options['sessionVar']]->getCAPTCHA() . '</div>'; return $html; } } /** * Registers the class with QuickForm */ if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('CAPTCHA_Figlet', 'HTML/QuickForm/CAPTCHA/Figlet.php', 'HTML_QuickForm_CAPTCHA_Figlet'); } ?> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA/Image.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA/Image.php +++ pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA/Image.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Element for HTML_QuickForm to display a CAPTCHA image * * The HTML_QuickForm_CAPTCHA package adds an element to the * HTML_QuickForm package to display a CAPTCHA image. * * This package requires the use of a PHP session. * * PHP versions 4 and 5 * * @category HTML * @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <[email protected]> * @copyright 2006-2008 by Philippe Jausions / 11abacus * @license http://www.opensource.org/licenses/bsd-license.php New BSD * @version CVS: $Id: Image.php,v 1.1 2008/04/26 23:27:30 jausions Exp $ * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA */ /** * Required packages */ require_once 'HTML/QuickForm/CAPTCHA.php'; require_once 'Text/CAPTCHA/Driver/Image.php'; /** * Element for HTML_QuickForm to display a CAPTCHA image * * The HTML_QuickForm_CAPTCHA package adds an element to the * HTML_QuickForm package to display a CAPTCHA image. * * Options for the element * <ul> * <li>'width' (integer) width of the image,</li> * <li>'height' (integer) height of the image,</li> * <li>'imageOptions' (array) options passed to the Image_Text * constructor,</li> * <li>'callback' (string) URL of callback script that will generate * and output the image itself,</li> * <li>'alt' (string) the alt text for the image,</li> * <li>'sessionVar' (string) name of session variable containing * the Text_CAPTCHA instance (defaults to * _HTML_QuickForm_CAPTCHA.)</li> * </ul> * * This package requires the use of a PHP session. * * @category HTML * @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <[email protected]> * @copyright 2006-2008 by Philippe Jausions / 11abacus * @license http://www.opensource.org/licenses/bsd-license.php New BSD * @version Release: @package_version@ * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA * @see Text_CAPTCHA_Driver_Image */ class HTML_QuickForm_CAPTCHA_Image extends HTML_QuickForm_CAPTCHA { /** * Default options * * @var array * @access protected */ var $_options = array( 'sessionVar' => '_HTML_QuickForm_CAPTCHA', 'width' => '200', 'height' => '80', 'alt' => 'Click to view another image', 'callback' => '', 'imageOptions' => null, 'phrase' => null, ); /** * CAPTCHA driver * * @var string * @access protected */ var $_CAPTCHA_driver = 'Image'; /** * Returns the HTML for the CAPTCHA image * * @return string * @access public */ function toHtml() { if ($this->_flagFrozen) { return ''; } $result = parent::_initCAPTCHA(); if (PEAR::isError($result)) { return $result; } $html = ''; $tabs = $this->_getTabs(); $inputName = $this->getName(); $imgName = 'QF_CAPTCHA_'.$inputName; if ($this->getComment() != '') { $html .= $tabs.'<!-- '.$this->getComment().' // -->'; } $attr = $this->_attributes; unset($attr['type']); unset($attr['value']); unset($attr['name']); $html = $tabs.'<a href="'.$this->_options['callback'] .'" target="_blank" ' .$this->_getAttrString($attr) .' onclick="var cancelClick = false; ' .$this->getOnclickJs($imgName) .' return !cancelClick;"><img src="' .$this->_options['callback'].'" name="'.$imgName .'" id="'.$imgName.'" width="'.$this->_options['width'] .'" height="'.$this->_options['height'].'" title="' .htmlspecialchars($this->_options['alt']).'" /></a>'; return $html; } /** * Creates the javascript for the onclick event which will * reload a new CAPTCHA image * * @param string $imageName The image name/id * * @return string * @access public */ function getOnclickJs($imageName) { $onclickJs = '' .'if (document.images) {' .' var img = new Image();' .' var d = new Date();' .' img.src = this.href + ((this.href.indexOf(\'?\') == -1) ' .'? \'?\' : \'&\') + d.getTime();' .' document.images[\''.addslashes($imageName).'\'].src = img.src;' .' cancelClick = true;' .'}'; return $onclickJs; } } /** * Registers the class with QuickForm */ if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('CAPTCHA_Image', 'HTML/QuickForm/CAPTCHA/Image.php', 'HTML_QuickForm_CAPTCHA_Image'); } ?> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA/Word.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA/Word.php +++ pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/CAPTCHA/Word.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Element for HTML_QuickForm to display a CAPTCHA "Word" * * The HTML_QuickForm_CAPTCHA package adds an element to the * HTML_QuickForm package to display a CAPTCHA "word". * * This package requires the use of a PHP session. * * PHP versions 4 and 5 * * @category HTML * @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <[email protected]> * @copyright 2006-2008 by Philippe Jausions / 11abacus * @license http://www.opensource.org/licenses/bsd-license.php New BSD * @version CVS: $Id: Word.php,v 1.1 2008/04/26 23:27:30 jausions Exp $ * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA */ /** * Required packages */ require_once 'HTML/QuickForm/CAPTCHA.php'; require_once 'Text/CAPTCHA/Driver/Word.php'; /** * Element for HTML_QuickForm to display a CAPTCHA "word" question * * The HTML_QuickForm_CAPTCHA package adds an element to the * HTML_QuickForm package to display a CAPTCHA "word" question. * * Options for the element * <ul> * <li>'length' (integer) the length of the Word.</li> * <li>'mode' (string) 'single' for separated words.</li> * <li>'locale' (string) locale for Numbers_Words package</li> * <li>'sessionVar' (string) name of session variable containing * the Text_CAPTCHA instance (defaults to * _HTML_QuickForm_CAPTCHA.)</li> * </ul> * * This package requires the use of a PHP session. * * @category HTML * @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <[email protected]> * @copyright 2006-2008 by Philippe Jausions / 11abacus * @license http://www.opensource.org/licenses/bsd-license.php New BSD * @version Release: @package_version@ * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA * @see Text_CAPTCHA_Driver_Equation */ class HTML_QuickForm_CAPTCHA_Word extends HTML_QuickForm_CAPTCHA { /** * Default options * * @var array * @access protected */ var $_options = array( 'sessionVar' => '_HTML_QuickForm_CAPTCHA', 'length' => 4, 'mode' => 'single', 'locale' => 'en_US', 'phrase' => null, ); /** * CAPTCHA driver * * @var string * @access protected */ var $_CAPTCHA_driver = 'Word'; } /** * Registers the class with QuickForm */ if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('CAPTCHA_Word', 'HTML/QuickForm/CAPTCHA/Word.php', 'HTML_QuickForm_CAPTCHA_Word'); } ?> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/Rule/CAPTCHA.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/Rule/CAPTCHA.php +++ pear/HTML_QuickForm_CAPTCHA/HTML/QuickForm/Rule/CAPTCHA.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Rule for HTML_QuickForm to display a CAPTCHA image * * This package requires the use of a PHP session. * * PHP versions 4 and 5 * * @category HTML * @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <[email protected]> * @copyright 2006-2008 by Philippe Jausions / 11abacus * @license http://www.opensource.org/licenses/bsd-license.php New BSD * @version CVS: $Id: CAPTCHA.php,v 1.1 2008/04/26 23:27:30 jausions Exp $ * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA */ require_once 'HTML/QuickForm/Rule.php'; /** * Rule to compare a field with a CAPTCHA image * * @category HTML * @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <[email protected]> * @copyright 2006-2008 by Philippe Jausions / 11abacus * @license http://www.opensource.org/licenses/bsd-license.php New BSD * @version Release: @package_version@ * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA */ class HTML_QuickForm_Rule_CAPTCHA extends HTML_QuickForm_Rule { /** * Validates the data entered matches the CAPTCHA image that was * displayed * * @param string $value data to validate * @param HTML_QuickForm_CAPTCHA_Common $captcha element to check against * * @return boolean TRUE if valid, FALSE otherwise * @access public * @static */ function validate($value, $captcha) { return ($value == $captcha->getValue()); } } HTML_QuickForm::registerRule('CAPTCHA', 'rule', 'HTML_QuickForm_Rule_CAPTCHA', 'HTML/QuickForm/Rule/CAPTCHA.php'); ?>