Text_CAPTCHA
[ class tree: Text_CAPTCHA ] [ index: Text_CAPTCHA ] [ all elements ]

Class: Text_CAPTCHA_Driver_Equation

Source Location: /Text_CAPTCHA-0.2.0/CAPTCHA/Driver/Equation.php

Class Overview

Text_CAPTCHA
   |
   --Text_CAPTCHA_Driver_Equation

Equation driver for Text_CAPTCHA.


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods

Class: Text_CAPTCHA

Text_CAPTCHA::factory()
Create a new Text_CAPTCHA object
Text_CAPTCHA::getPhrase()
Return secret CAPTCHA phrase
Text_CAPTCHA::setPhrase()
Sets secret CAPTCHA phrase

Class Details

[line 10]
Equation driver for Text_CAPTCHA.

Returns simple equations as string, e.g. "9 - 2"



[ Top ]


Class Variables

$_equation =  null

[line 35]

The equation to solve.
  • Access: protected

Type:   string


[ Top ]

$_error =  null

[line 77]

Last error
  • Access: protected

Type:   PEAR_Error


[ Top ]

$_max =  10

[line 51]

Maximum number to use in an equation.
  • Access: protected

Type:   int


[ Top ]

$_min =  1

[line 43]

Minimal number to use in an equation.
  • Access: protected

Type:   int


[ Top ]

$_numbersToText =  false

[line 59]

Whether numbers shall be converted to text
  • Access: protected

Type:   bool


[ Top ]

$_operators = array(
        '%s * %s',
        '%s + %s',
        '%s - %s',
        'min(%s, %s)',
        'max(%s, %s)'
    )

[line 21]

Operators that may be used in the equation.

Two numbers have to be filled in, and %s is needed since number2text conversion may be applied and strings filled in.

  • Access: protected

Type:   array


[ Top ]

$_severity =  1

[line 69]

Complexity of the generated equations.

  1. - simple ones such as "1 + 10"
  2. - harder ones such as "(3-2)*(min(5,6))"

  • Access: protected

Type:   int


[ Top ]



Method Detail

getCAPTCHA   [line 218]

string getCAPTCHA( )

Returns the CAPTCHA (as a string)
  • Access: public

[ Top ]

getPhrase   [line 196]

string getPhrase( )

Return the solution to the equation.

This method returns the CAPTCHA phrase, which is the solution to the equation.

  • Return: secret phrase
  • Access: public

Overrides Text_CAPTCHA::getPhrase() (Return secret CAPTCHA phrase)
[ Top ]

init   [line 86]

true init( [ $options = array()])

Initialize the driver.
  • Return: on success, PEAR_Error on error.
  • Access: public

Parameters:

   $options     

[ Top ]

_createCAPTCHA   [line 208]

PEAR_Error _createCAPTCHA( )

Creates the captcha. This method is a placeholder, since the equation is created in _createPhrase()
  • Access: protected

[ Top ]

_createPhrase   [line 128]

mixed _createPhrase( )

Create random CAPTCHA equation.

This method creates a random equation. The equation is stored in $this->_equation, the solution in $this->_phrase.

  • Return: true on success, PEAR_Error on error
  • Access: protected

[ Top ]

_createSimpleEquation   [line 156]

array _createSimpleEquation( )

Creates a simple equation of type (number operator number)
  • Return: Array with equation and solution
  • Access: protected

[ Top ]

_solveSimpleEquation   [line 174]

array _solveSimpleEquation( $one, $two, $operator)

Solves a simple equation with two given numbers and one operator as defined in $this->_operators.

Also converts the numbers to words if required.

  • Return: Array with equation and solution
  • Access: protected

Parameters:

   $one     
   $two     
   $operator     

[ Top ]


Documentation generated on Sun, 24 Dec 2006 09:00:09 -0500 by phpDocumentor 1.3.0. PEAR Logo Copyright © PHP Group 2004.