CAPTCHA.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. /**
  4. * Rule for HTML_QuickForm to display a CAPTCHA image
  5. *
  6. * This package requires the use of a PHP session.
  7. *
  8. * PHP versions 4 and 5
  9. *
  10. * @category HTML
  11. * @package HTML_QuickForm_CAPTCHA
  12. * @author Philippe Jausions <Philippe.Jausions@11abacus.com>
  13. * @copyright 2006-2008 by Philippe Jausions / 11abacus
  14. * @license http://www.opensource.org/licenses/bsd-license.php New BSD
  15. * @version CVS: $Id: CAPTCHA.php,v 1.1 2008/04/26 23:27:30 jausions Exp $
  16. * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA
  17. */
  18. require_once 'HTML/QuickForm/Rule.php';
  19. /**
  20. * Rule to compare a field with a CAPTCHA image
  21. *
  22. * @category HTML
  23. * @package HTML_QuickForm_CAPTCHA
  24. * @author Philippe Jausions <Philippe.Jausions@11abacus.com>
  25. * @copyright 2006-2008 by Philippe Jausions / 11abacus
  26. * @license http://www.opensource.org/licenses/bsd-license.php New BSD
  27. * @version Release: 0.3.0
  28. * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA
  29. */
  30. class HTML_QuickForm_Rule_CAPTCHA extends HTML_QuickForm_Rule
  31. {
  32. /**
  33. * Validates the data entered matches the CAPTCHA image that was
  34. * displayed
  35. *
  36. * @param string $value data to validate
  37. * @param HTML_QuickForm_CAPTCHA_Common $captcha element to check against
  38. *
  39. * @return boolean TRUE if valid, FALSE otherwise
  40. * @access public
  41. * @static
  42. */
  43. function validate($value, $captcha)
  44. {
  45. return ($value == $captcha->getValue());
  46. }
  47. }