Equation.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. /**
  4. * Element for HTML_QuickForm to display a CAPTCHA equation
  5. *
  6. * The HTML_QuickForm_CAPTCHA package adds an element to the
  7. * HTML_QuickForm package to display a CAPTCHA equation.
  8. *
  9. * This package requires the use of a PHP session.
  10. *
  11. * PHP versions 4 and 5
  12. *
  13. * @category HTML
  14. * @package HTML_QuickForm_CAPTCHA
  15. * @author Philippe Jausions <Philippe.Jausions@11abacus.com>
  16. * @copyright 2006-2008 by Philippe Jausions / 11abacus
  17. * @license http://www.opensource.org/licenses/bsd-license.php New BSD
  18. * @version CVS: $Id: Equation.php,v 1.1 2008/04/26 23:27:30 jausions Exp $
  19. * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA
  20. */
  21. /**
  22. * Required packages
  23. */
  24. require_once 'HTML/QuickForm/CAPTCHA.php';
  25. require_once 'Text/CAPTCHA/Driver/Equation.php';
  26. /**
  27. * Element for HTML_QuickForm to display a CAPTCHA equation question
  28. *
  29. * The HTML_QuickForm_CAPTCHA package adds an element to the
  30. * HTML_QuickForm package to display a CAPTCHA equation question.
  31. *
  32. * Options for the element
  33. * <ul>
  34. * <li>'min' (integer) Minimal number to use in an equation.</li>
  35. * <li>'max' (integer) Maximal number to use in an equation.</li>
  36. * <li>'severity' (integer) Complexity of the equation to resolve
  37. * (1 = easy, 2 = harder)</li>
  38. * <li>'numbersToText' (boolean) Whether to use the Numbers_Words
  39. * package to convert numbers to text,</li>
  40. * <li>'sessionVar' (string) name of session variable containing
  41. * the Text_CAPTCHA instance (defaults to
  42. * _HTML_QuickForm_CAPTCHA.)</li>
  43. * </ul>
  44. *
  45. * This package requires the use of a PHP session.
  46. *
  47. * @category HTML
  48. * @package HTML_QuickForm_CAPTCHA
  49. * @author Philippe Jausions <Philippe.Jausions@11abacus.com>
  50. * @copyright 2006-2008 by Philippe Jausions / 11abacus
  51. * @license http://www.opensource.org/licenses/bsd-license.php New BSD
  52. * @version Release: 0.3.0
  53. * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA
  54. * @see Text_CAPTCHA_Driver_Equation
  55. */
  56. class HTML_QuickForm_CAPTCHA_Equation extends HTML_QuickForm_CAPTCHA
  57. {
  58. /**
  59. * Default options
  60. *
  61. * @var array
  62. * @access protected
  63. */
  64. var $_options = array(
  65. 'sessionVar' => '_HTML_QuickForm_CAPTCHA',
  66. 'severity' => 1,
  67. 'numbersToText' => false,
  68. 'phrase' => null,
  69. );
  70. /**
  71. * CAPTCHA driver
  72. *
  73. * @var string
  74. * @access protected
  75. */
  76. var $_CAPTCHA_driver = 'Equation';
  77. }
  78. /**
  79. * Registers the class with QuickForm
  80. */
  81. if (class_exists('HTML_QuickForm')) {
  82. HTML_QuickForm::registerElementType('CAPTCHA_Equation',
  83. 'HTML/QuickForm/CAPTCHA/Equation.php',
  84. 'HTML_QuickForm_CAPTCHA_Equation');
  85. }
  86. ?>