ILIAS
Release_4_4_x_branch Revision 61816
|
Public Member Functions | |
__construct ($options=array()) | |
Create a new securimage object, pass options to set in the constructor. | |
show ($background_image= '') | |
Used to serve a captcha image to the browser. | |
check ($code) | |
Check a submitted code against the stored value. | |
outputAudioFile () | |
Output a wav file of the captcha code to the browser. | |
getCode ($array=false, $returnExisting=false) | |
Return the code from the session or sqlite database if used. | |
createCode () | |
Generates the code or math problem and saves the value to the session. | |
getRandomNoiseFile () | |
frand () | |
Return a random float between 0 and 0.9999. | |
errorHandler ($errno, $errstr, $errfile= '', $errline=0, $errcontext=array()) | |
Error handler used when outputting captcha image or audio. |
Static Public Member Functions | |
static | getPath () |
Return the absolute path to the Securimage directory. | |
static | getCaptchaId ($new=true, array $options=array()) |
Generate a new captcha ID or retrieve the current ID. | |
static | checkByCaptchaId ($id, $value, array $options=array()) |
Validate a captcha code input against a captcha ID. |
Protected Member Functions | |
doImage () | |
The main image drawing routing, responsible for constructing the entire image and serving it. | |
allocateColors () | |
Allocate the colors to be used for the image. | |
setBackground () | |
The the background color, or background image to be used. | |
getBackgroundFromDirectory () | |
Scan the directory for a background image to use. | |
drawWord () | |
Draws the captcha code on the image. | |
distortedCopy () | |
Copies the captcha image to the final image with distortion applied. | |
drawLines () | |
Draws distorted lines on the image. | |
drawNoise () | |
Draws random noise on the image. | |
addSignature () | |
Print signature text on image. | |
output () | |
Sends the appropriate image and cache headers and outputs image to the browser. | |
getAudibleCode () | |
Gets the code and returns the binary audio file for the stored captcha code. | |
readCodeFromFile ($numWords=1) | |
Gets a captcha code from a wordlist. | |
generateCode () | |
Generates a random captcha code from the set character set. | |
validate () | |
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. | |
saveData () | |
Save data to session namespace and database if used. | |
saveCodeToDatabase () | |
Saves the code to the sqlite database. | |
openDatabase () | |
Open sqlite database. | |
getDsn () | |
checkTablesExist () | |
createDatabaseTables () | |
getCodeFromDatabase () | |
Get a code from the sqlite database for ip address/captchaId. | |
clearCodeFromDatabase () | |
Remove an entered code from the database. | |
purgeOldCodesFromDatabase () | |
Deletes old codes from sqlite database. | |
isCodeExpired ($creation_time) | |
Checks to see if the captcha code has expired and cannot be used. | |
generateWAV ($letters) | |
Generate a wav file given the $letters in the code. | |
audioError () | |
Return a wav file saying there was an error generating file. | |
canSendHeaders () | |
Checks to see if headers can be sent and if any error has been output to the browser. | |
initColor ($color, $default) | |
Convert an html color code to a Securimage_Color. |
Protected Attributes | |
$im | |
$tmpimg | |
$bgimg | |
$iscale = 5 | |
$code | |
$code_display | |
$captcha_code | |
$no_exit | |
$no_session | |
$send_headers | |
$pdo_conn | |
$gdbgcolor | |
$gdtextcolor | |
$gdlinecolor | |
$gdsignaturecolor |
Static Protected Attributes | |
static | $_captchaId = null |
Definition at line 165 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 629 of file securimage.php.
References $_captchaId, $options, $ttf_file, and initColor().
|
protected |
Print signature text on image.
Definition at line 1353 of file securimage.php.
Referenced by doImage().
|
protected |
Allocate the colors to be used for the image.
Definition at line 1015 of file securimage.php.
Referenced by doImage().
|
protected |
Return a wav file saying there was an error generating file.
Definition at line 2031 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 2041 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 831 of file securimage.php.
References $code, and 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 |
array | $options | Array of options to construct Securimage with. Options must include database options if they are not set in securimage.php |
Definition at line 763 of file securimage.php.
|
protected |
Definition at line 1701 of file securimage.php.
References $query, and $result.
Referenced by openDatabase().
|
protected |
Remove an entered code from the database.
Definition at line 1856 of file securimage.php.
References $_captchaId, $query, and $result.
Referenced by saveCodeToDatabase(), and validate().
Securimage::createCode | ( | ) |
Generates the code or math problem and saves the value to the session.
Definition at line 1136 of file securimage.php.
References $case_sensitive, $code, generateCode(), readCodeFromFile(), and saveData().
Referenced by doImage(), and getAudibleCode().
|
protected |
Definition at line 1743 of file securimage.php.
References $query, and $result.
Referenced by openDatabase().
|
protected |
Copies the captcha image to the final image with distortion applied.
Definition at line 1226 of file securimage.php.
References $image_height, $image_width, $iscale, and frand().
Referenced by doImage().
|
protected |
The main image drawing routing, responsible for constructing the entire image and serving it.
Definition at line 944 of file securimage.php.
References $case_sensitive, $code, $display_value, 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 1277 of file securimage.php.
References $image_width, $n, $num_lines, and frand().
Referenced by doImage().
|
protected |
Draws random noise on the image.
Definition at line 1314 of file securimage.php.
References $iscale, $noise_level, $size, and $t.
Referenced by doImage().
|
protected |
Draws the captcha code on the image.
Definition at line 1188 of file securimage.php.
References $iscale.
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 2101 of file securimage.php.
Securimage::frand | ( | ) |
Return a random float between 0 and 0.9999.
Definition at line 2059 of file securimage.php.
Referenced by distortedCopy(), and drawLines().
|
protected |
Generates a random captcha code from the set character set.
Definition at line 1499 of file securimage.php.
References $code, and $code_length.
Referenced by createCode().
|
protected |
Generate a wav file given the $letters in the code.
array | $letters |
Definition at line 1920 of file securimage.php.
References $audio_mix_normalization, WavFile\FILTER_DEGRADE, WavFile\FILTER_MIX, WavFile\FILTER_NORMALIZE, and getRandomNoiseFile().
Referenced by getAudibleCode().
|
protected |
Gets the code and returns the binary audio file for the stored captcha code.
Definition at line 1413 of file securimage.php.
References $code, createCode(), generateWAV(), and getCode().
Referenced by outputAudioFile().
|
protected |
Scan the directory for a background image to use.
Definition at line 1114 of file securimage.php.
References $file.
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. Must include database options if not set directly in securimage.php |
Definition at line 735 of file securimage.php.
References $_captchaId, $options, and $si.
Referenced by doImage(), and saveCodeToDatabase().
Securimage::getCode | ( | $array = false , |
|
$returnExisting = 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 899 of file securimage.php.
References $_SESSION, $code, $namespace, getCodeFromDatabase(), isCodeExpired(), and openDatabase().
Referenced by getAudibleCode(), and validate().
|
protected |
Get a code from the sqlite database for ip address/captchaId.
Definition at line 1813 of file securimage.php.
References $_captchaId, $code, $namespace, $query, $result, $row, and isCodeExpired().
Referenced by doImage(), and getCode().
|
protected |
Definition at line 1680 of file securimage.php.
References $database_file.
Referenced by openDatabase().
|
static |
Return the absolute path to the Securimage directory.
Definition at line 721 of file securimage.php.
Securimage::getRandomNoiseFile | ( | ) |
Definition at line 2001 of file securimage.php.
References $file.
Referenced by generateWAV().
|
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 2069 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 1901 of file securimage.php.
Referenced by getCode(), and getCodeFromDatabase().
|
protected |
Open sqlite database.
Definition at line 1623 of file securimage.php.
References $options, $pdo_conn, checkTablesExist(), createDatabaseTables(), getDsn(), and purgeOldCodesFromDatabase().
Referenced by doImage(), getCode(), and saveCodeToDatabase().
|
protected |
Sends the appropriate image and cache headers and outputs image to the browser.
Definition at line 1366 of file securimage.php.
References canSendHeaders(), and exit.
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 847 of file securimage.php.
References audioError(), canSendHeaders(), exit, and getAudibleCode().
|
protected |
Deletes old codes from sqlite database.
Definition at line 1882 of file securimage.php.
References $query, and $result.
Referenced by openDatabase().
|
protected |
Gets a captcha code from a wordlist.
Definition at line 1456 of file securimage.php.
Referenced by createCode().
|
protected |
Saves the code to the sqlite database.
Definition at line 1584 of file securimage.php.
References $code, $code_display, $query, $success, clearCodeFromDatabase(), getCaptchaId(), and openDatabase().
Referenced by saveData().
|
protected |
Save data to session namespace and database if used.
Definition at line 1562 of file securimage.php.
References $_SESSION, $code, $code_display, $namespace, and saveCodeToDatabase().
Referenced by createCode().
|
protected |
The the background color, or background image to be used.
Definition at line 1066 of file securimage.php.
References $img, and 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 807 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 1520 of file securimage.php.
References $_SESSION, $code, $namespace, clearCodeFromDatabase(), and getCode().
Referenced by check().
|
staticprotected |
Definition at line 539 of file securimage.php.
Referenced by __construct(), clearCodeFromDatabase(), getCaptchaId(), and getCodeFromDatabase().
Securimage::$audio_gap_max = 600 |
Definition at line 533 of file securimage.php.
Securimage::$audio_gap_min = 0 |
Definition at line 526 of file securimage.php.
Securimage::$audio_mix_normalization = 0.6 |
Definition at line 511 of file securimage.php.
Referenced by generateWAV().
Securimage::$audio_noise_path |
Definition at line 479 of file securimage.php.
Securimage::$audio_path |
Definition at line 472 of file securimage.php.
Securimage::$audio_use_noise |
Definition at line 489 of file securimage.php.
Securimage::$background_directory |
Definition at line 458 of file securimage.php.
|
protected |
Definition at line 543 of file securimage.php.
|
protected |
Definition at line 577 of file securimage.php.
Securimage::$captcha_type = self::SI_CAPTCHA_STRING |
Definition at line 425 of file securimage.php.
Securimage::$case_sensitive = false |
Definition at line 284 of file securimage.php.
Referenced by createCode(), and doImage().
Securimage::$charset = 'ABCDEFGHKLMNPRSTUVWYZabcdefghklmnprstuvwyz23456789' |
Definition at line 289 of file securimage.php.
|
protected |
Definition at line 553 of file securimage.php.
Referenced by check(), checkByCaptchaId(), createCode(), doImage(), generateCode(), getAudibleCode(), getCode(), getCodeFromDatabase(), saveCodeToDatabase(), saveData(), and validate().
|
protected |
Definition at line 560 of file securimage.php.
Referenced by saveCodeToDatabase(), and saveData().
Securimage::$code_length = 6 |
Definition at line 279 of file securimage.php.
Referenced by generateCode().
Securimage::$database_driver = self::SI_DRIVER_SQLITE3 |
Definition at line 367 of file securimage.php.
Securimage::$database_file |
Definition at line 418 of file securimage.php.
Referenced by getDsn().
Securimage::$database_host = 'localhost' |
Definition at line 376 of file securimage.php.
Securimage::$database_name = '' |
Definition at line 400 of file securimage.php.
Securimage::$database_pass = '' |
Definition at line 392 of file securimage.php.
Securimage::$database_table = 'captcha_codes' |
Definition at line 409 of file securimage.php.
Securimage::$database_user = '' |
Definition at line 384 of file securimage.php.
Securimage::$degrade_audio |
Definition at line 519 of file securimage.php.
Securimage::$display_value |
Definition at line 570 of file securimage.php.
Referenced by doImage().
Securimage::$expiry_time = 900 |
Definition at line 294 of file securimage.php.
|
protected |
Definition at line 608 of file securimage.php.
|
protected |
Definition at line 610 of file securimage.php.
|
protected |
Definition at line 611 of file securimage.php.
|
protected |
Definition at line 609 of file securimage.php.
|
protected |
Definition at line 541 of file securimage.php.
Securimage::$image_bg_color = '#ffffff' |
Definition at line 247 of file securimage.php.
Securimage::$image_height = 80 |
Definition at line 236 of file securimage.php.
Referenced by distortedCopy().
Securimage::$image_signature = '' |
Definition at line 329 of file securimage.php.
Securimage::$image_type = self::SI_IMAGE_PNG |
Definition at line 241 of file securimage.php.
Securimage::$image_width = 215 |
Definition at line 231 of file securimage.php.
Referenced by distortedCopy(), and drawLines().
|
protected |
Definition at line 544 of file securimage.php.
Referenced by distortedCopy(), drawNoise(), and drawWord().
Securimage::$line_color = '#707070' |
Definition at line 257 of file securimage.php.
Securimage::$namespace |
Definition at line 442 of file securimage.php.
Referenced by getCode(), getCodeFromDatabase(), saveData(), and validate().
|
protected |
Definition at line 584 of file securimage.php.
|
protected |
Definition at line 591 of file securimage.php.
Securimage::$noise_color = '#707070' |
Definition at line 262 of file securimage.php.
Securimage::$noise_level = 2 |
Definition at line 323 of file securimage.php.
Referenced by drawNoise().
Securimage::$num_lines = 5 |
Definition at line 318 of file securimage.php.
Referenced by drawLines().
|
protected |
Definition at line 605 of file securimage.php.
Referenced by openDatabase().
Securimage::$perturbation = 0.85 |
Definition at line 313 of file securimage.php.
Securimage::$securimage_path = null |
Definition at line 546 of file securimage.php.
|
protected |
Definition at line 598 of file securimage.php.
Securimage::$session_name = null |
Definition at line 301 of file securimage.php.
Securimage::$signature_color = '#707070' |
Definition at line 334 of file securimage.php.
Securimage::$signature_font |
Definition at line 339 of file securimage.php.
Securimage::$sqlite_database |
Definition at line 464 of file securimage.php.
Securimage::$text_color = '#707070' |
Definition at line 252 of file securimage.php.
Securimage::$text_transparency_percentage = 20 |
Definition at line 268 of file securimage.php.
|
protected |
Definition at line 542 of file securimage.php.
Securimage::$ttf_file |
Definition at line 448 of file securimage.php.
Referenced by __construct().
Securimage::$use_database = false |
Definition at line 358 of file securimage.php.
Securimage::$use_sqlite_db = false |
Definition at line 348 of file securimage.php.
Securimage::$use_transparent_text = true |
Definition at line 273 of file securimage.php.
Securimage::$use_wordlist = false |
Definition at line 307 of file securimage.php.
Securimage::$wordlist_file |
Definition at line 453 of file securimage.php.
const Securimage::SI_CAPTCHA_MATHEMATIC = 1 |
Definition at line 196 of file securimage.php.
const Securimage::SI_CAPTCHA_STRING = 0 |
Definition at line 191 of file securimage.php.
const Securimage::SI_CAPTCHA_WORDS = 2 |
Definition at line 201 of file securimage.php.
const Securimage::SI_DRIVER_MYSQL = 'mysql' |
Definition at line 208 of file securimage.php.
const Securimage::SI_DRIVER_PGSQL = 'pgsql' |
Definition at line 215 of file securimage.php.
const Securimage::SI_DRIVER_SQLITE3 = 'sqlite' |
Definition at line 222 of file securimage.php.
const Securimage::SI_IMAGE_GIF = 3 |
Definition at line 185 of file securimage.php.
const Securimage::SI_IMAGE_JPEG = 1 |
Definition at line 175 of file securimage.php.
const Securimage::SI_IMAGE_PNG = 2 |
Definition at line 180 of file securimage.php.