Public Member Functions | |
__construct ($options=array()) | |
show ($background_image= '') | |
check ($code) | |
outputAudioFile () | |
getCode ($array=false) | |
getRandomNoiseFile () | |
frand () | |
errorHandler ($errno, $errstr, $errfile= '', $errline=0, $errcontext=array()) |
Static Public Member Functions | |
static | getPath () |
static | getCaptchaId ($new=true, array $options=array()) |
static | checkByCaptchaId ($id, $value) |
Protected Member Functions | |
doImage () | |
allocateColors () | |
setBackground () | |
getBackgroundFromDirectory () | |
createCode () | |
drawWord () | |
distortedCopy () | |
drawLines () | |
drawNoise () | |
addSignature () | |
output () | |
getAudibleCode () | |
readCodeFromFile () | |
generateCode () | |
validate () | |
saveData () | |
saveCodeToDatabase () | |
openDatabase () | |
getCodeFromDatabase () | |
clearCodeFromDatabase () | |
purgeOldCodesFromDatabase () | |
isCodeExpired ($creation_time) | |
generateWAV ($letters) | |
audioError () | |
canSendHeaders () | |
initColor ($color, $default) |
Static Protected Attributes | |
static | $_captchaId = null |
Definition at line 150 of file securimage.php.
Securimage::__construct | ( | $options = array() | ) |
Create a new securimage object, pass options to set in the constructor.
This can be used to display a captcha, play an audible captcha, or validate an entry
array | $options | $options = array( 'text_color' => new Securimage_Color('#013020'), 'code_length' => 5, 'num_lines' => 5, 'noise_level' => 3, 'font_file' => Securimage::getPath() . '/custom.ttf' ); |
$img = new Securimage($options);
Definition at line 507 of file securimage.php.
References initColor().
|
protected |
Print signature text on image
Definition at line 1203 of file securimage.php.
Referenced by doImage().
|
protected |
Allocate the colors to be used for the image
Definition at line 871 of file securimage.php.
Referenced by doImage().
|
protected |
Return a wav file saying there was an error generating file
Definition at line 1678 of file securimage.php.
Referenced by outputAudioFile().
|
protected |
Checks to see if headers can be sent and if any error has been output to the browser
Definition at line 1688 of file securimage.php.
Referenced by output(), and outputAudioFile().
Securimage::check | ( | $code | ) |
Check a submitted code against the stored value
string | $code | The captcha code to check $code = $_POST['code']; $img = new Securimage(); if ($img->check($code) == true) { $captcha_valid = true; } else { $captcha_valid = false; } |
Definition at line 698 of file securimage.php.
References validate().
|
static |
Validate a captcha code input against a captcha ID
string | $id | The captcha ID to check |
string | $value | The captcha value supplied by the user |
Definition at line 636 of file securimage.php.
|
protected |
Remove an entered code from the database
Definition at line 1521 of file securimage.php.
Referenced by validate().
|
protected |
Generates the code or math problem and saves the value to the session
Definition at line 992 of file securimage.php.
References generateCode(), readCodeFromFile(), and saveData().
Referenced by doImage(), and getAudibleCode().
|
protected |
Copies the captcha image to the final image with distortion applied
Definition at line 1076 of file securimage.php.
References frand().
Referenced by doImage().
|
protected |
The main image drawing routing, responsible for constructing the entire image and serving it
Definition at line 800 of file securimage.php.
References addSignature(), allocateColors(), createCode(), distortedCopy(), drawLines(), drawNoise(), drawWord(), getCaptchaId(), getCodeFromDatabase(), openDatabase(), output(), and setBackground().
Referenced by show().
|
protected |
Draws distorted lines on the image
Definition at line 1127 of file securimage.php.
References frand().
Referenced by doImage().
|
protected |
Draws random noise on the image
Definition at line 1164 of file securimage.php.
Referenced by doImage().
|
protected |
Draws the captcha code on the image
Definition at line 1038 of file securimage.php.
Referenced by doImage().
Securimage::errorHandler | ( | $errno, | |
$errstr, | |||
$errfile = '' , |
|||
$errline = 0 , |
|||
$errcontext = array() |
|||
) |
Error handler used when outputting captcha image or audio. This error handler helps determine if any errors raised would prevent captcha image or audio from displaying. If they have no effect on the output buffer or headers, true is returned so the script can continue processing. See https://github.com/dapphp/securimage/issues/15
int | $errno | |
string | $errstr | |
string | $errfile | |
int | $errline | |
array | $errcontext |
Definition at line 1748 of file securimage.php.
Securimage::frand | ( | ) |
Return a random float between 0 and 0.9999
Definition at line 1706 of file securimage.php.
Referenced by distortedCopy(), and drawLines().
|
protected |
Generates a random captcha code from the set character set
Definition at line 1330 of file securimage.php.
Referenced by createCode().
|
protected |
Generate a wav file given the $letters in the code
array | $letters |
Definition at line 1567 of file securimage.php.
Referenced by getAudibleCode().
|
protected |
Gets the code and returns the binary audio file for the stored captcha code
Definition at line 1263 of file securimage.php.
References createCode(), generateWAV(), and getCode().
Referenced by outputAudioFile().
|
protected |
Scan the directory for a background image to use
Definition at line 970 of file securimage.php.
Referenced by setBackground().
|
static |
Generate a new captcha ID or retrieve the current ID
$new | bool If true, generates a new challenge and returns and ID |
$options | array Additional options to be passed to Securimage |
Definition at line 612 of file securimage.php.
Referenced by doImage(), and saveCodeToDatabase().
Securimage::getCode | ( | $array = false | ) |
Return the code from the session or sqlite database if used. If none exists yet, an empty string is returned
$array | bool True to receive an array containing the code and properties |
Definition at line 766 of file securimage.php.
References getCodeFromDatabase(), isCodeExpired(), and openDatabase().
Referenced by getAudibleCode(), and validate().
|
protected |
Get a code from the sqlite database for ip address/captchaId.
Definition at line 1486 of file securimage.php.
References isCodeExpired().
Referenced by doImage(), and getCode().
|
static |
Return the absolute path to the Securimage directory
Definition at line 599 of file securimage.php.
|
protected |
Convert an html color code to a Securimage_Color
string | $color | |
Securimage_Color | $default | The defalt color to use if $color is invalid |
Definition at line 1716 of file securimage.php.
Referenced by __construct().
|
protected |
Checks to see if the captcha code has expired and cannot be used
unknown_type | $creation_time |
Definition at line 1548 of file securimage.php.
Referenced by getCode(), and getCodeFromDatabase().
|
protected |
Open sqlite database
Definition at line 1434 of file securimage.php.
References purgeOldCodesFromDatabase().
Referenced by doImage(), getCode(), and saveCodeToDatabase().
|
protected |
Sends the appropriate image and cache headers and outputs image to the browser
Definition at line 1216 of file securimage.php.
References canSendHeaders().
Referenced by doImage().
Securimage::outputAudioFile | ( | ) |
Output a wav file of the captcha code to the browser
$img = new Securimage(); $img->outputAudioFile(); // outputs a wav file to the browser exit;
Definition at line 714 of file securimage.php.
References audioError(), canSendHeaders(), and getAudibleCode().
|
protected |
Deletes old codes from sqlite database
Definition at line 1534 of file securimage.php.
Referenced by openDatabase().
|
protected |
Gets a captcha code from a wordlist
Definition at line 1302 of file securimage.php.
Referenced by createCode().
|
protected |
Saves the code to the sqlite database
Definition at line 1403 of file securimage.php.
References getCaptchaId(), and openDatabase().
Referenced by saveData().
|
protected |
Save data to session namespace and database if used
Definition at line 1383 of file securimage.php.
References saveCodeToDatabase().
Referenced by createCode().
|
protected |
The the background color, or background image to be used
Definition at line 922 of file securimage.php.
References getBackgroundFromDirectory().
Referenced by doImage().
Securimage::show | ( | $background_image = '' | ) |
Used to serve a captcha image to the browser
string | $background_image | The path to the background image to use $img = new Securimage(); $img->code_length = 6; $img->num_lines = 5; $img->noise_level = 5; |
$img->show(); // sends the image to browser exit;
Definition at line 674 of file securimage.php.
References doImage().
|
protected |
Checks the entered code against the value stored in the session or sqlite database, handles case sensitivity Also clears the stored codes if the code was entered correctly to prevent re-use
Definition at line 1347 of file securimage.php.
References clearCodeFromDatabase(), and getCode().
Referenced by check().