CAPTCHA.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. /**
  19. * Rule to compare a field with a CAPTCHA image
  20. *
  21. * @category HTML
  22. * @package HTML_QuickForm_CAPTCHA
  23. * @author Philippe Jausions <Philippe.Jausions@11abacus.com>
  24. * @copyright 2006-2008 by Philippe Jausions / 11abacus
  25. * @license http://www.opensource.org/licenses/bsd-license.php New BSD
  26. * @version Release: 0.3.0
  27. * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA
  28. */
  29. class HTML_QuickForm_Rule_CAPTCHA extends HTML_QuickForm_Rule
  30. {
  31. /**
  32. * Validates the data entered matches the CAPTCHA image that was
  33. * displayed
  34. *
  35. * @param string $value data to validate
  36. * @param HTML_QuickForm_CAPTCHA_Common $captcha element to check against
  37. *
  38. * @return boolean TRUE if valid, FALSE otherwise
  39. * @access public
  40. * @static
  41. */
  42. function validate($value, $captcha)
  43. {
  44. return ($value == $captcha->getValue());
  45. }
  46. }