ILIAS
release_4-3 Revision
|
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. | |
frand () |
Static Public Member Functions | |
static | getPath () |
Return the absolute path to the Securimage directory. |
Data Fields | |
const | SI_IMAGE_JPEG = 1 |
const | SI_IMAGE_PNG = 2 |
const | SI_IMAGE_GIF = 3 |
const | SI_CAPTCHA_STRING = 0 |
const | SI_CAPTCHA_MATHEMATIC = 1 |
$image_width = 215 | |
$image_height = 80 | |
$image_type = self::SI_IMAGE_PNG | |
$image_bg_color = '#ffffff' | |
$text_color = '#707070' | |
$line_color = '#707070' | |
$noise_color = '#707070' | |
$text_transparency_percentage = 50 | |
$use_transparent_text = false | |
$code_length = 6 | |
$case_sensitive = false | |
$charset = 'ABCDEFGHKLMNPRSTUVWYZabcdefghklmnprstuvwyz23456789' | |
$expiry_time = 900 | |
$session_name = null | |
$use_wordlist = false | |
$perturbation = 0.75 | |
$num_lines = 8 | |
$noise_level = 0 | |
$image_signature = '' | |
$signature_color = '#707070' | |
$signature_font | |
$use_sqlite_db = false | |
$captcha_type = self::SI_CAPTCHA_STRING | |
$namespace | |
$ttf_file | |
$wordlist_file | |
$background_directory | |
$sqlite_database | |
$audio_path |
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. | |
createCode () | |
Generates the code or math problem and saves the value to the session. | |
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 ($format= 'wav') | |
Gets the code and returns the binary audio file for the stored captcha code. | |
readCodeFromFile () | |
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. | |
getCode () | |
Return the code from the session or sqlite database if used. | |
saveData () | |
Save data to session namespace and database if used. | |
saveCodeToDatabase () | |
Saves the code to the sqlite database. | |
openDatabase () | |
Open sqlite database. | |
getCodeFromDatabase () | |
Get a code from the sqlite database for ip address. | |
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. | |
generateMP3 () | |
Generate an MP3 audio file of the captcha image. | |
generateWAV ($letters) | |
Generate a wav file given the $letters in the code. | |
scrambleAudioData (&$data, $format) | |
Randomizes the audio data to add noise and prevent binary recognition. | |
audioError () | |
Return a wav file saying there was an error generating file. | |
initColor ($color, $default) | |
Convert an html color code to a Securimage_Color. |
Protected Attributes | |
$im | |
$tmpimg | |
$bgimg | |
$iscale = 5 | |
$securimage_path = null | |
$code | |
$code_display | |
$captcha_code | |
$sqlite_handle | |
$gdbgcolor | |
$gdtextcolor | |
$gdlinecolor | |
$gdsignaturecolor |
Definition at line 122 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 364 of file securimage.php.
References $ttf_file, code_length, image_bg_color, initColor(), line_color, noise_color, perturbation, signature_color, and text_color.
|
protected |
Print signature text on image.
Definition at line 872 of file securimage.php.
References image_height, image_signature, and image_width.
Referenced by doImage().
|
protected |
Allocate the colors to be used for the image.
Definition at line 542 of file securimage.php.
References image_bg_color, line_color, noise_color, signature_color, text_color, text_transparency_percentage, and use_transparent_text.
Referenced by doImage().
|
protected |
Return a wav file saying there was an error generating file.
Definition at line 1307 of file securimage.php.
Referenced by generateWAV().
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 463 of file securimage.php.
References $code, and validate().
|
protected |
Remove an entered code from the database.
Definition at line 1119 of file securimage.php.
Referenced by validate().
|
protected |
Generates the code or math problem and saves the value to the session.
Definition at line 663 of file securimage.php.
References $case_sensitive, $code, code_length, generateCode(), readCodeFromFile(), saveData(), and use_wordlist.
Referenced by doImage(), and getAudibleCode().
|
protected |
Copies the captcha image to the final image with distortion applied.
Definition at line 745 of file securimage.php.
References $image_height, $image_width, $iscale, frand(), image_height, image_width, and perturbation.
Referenced by doImage().
|
protected |
The main image drawing routing, responsible for constructing the entire image and serving it.
Definition at line 500 of file securimage.php.
References addSignature(), allocateColors(), createCode(), distortedCopy(), drawLines(), drawNoise(), drawWord(), image_height, image_signature, image_width, noise_level, num_lines, output(), perturbation, setBackground(), and use_transparent_text.
Referenced by show().
|
protected |
Draws distorted lines on the image.
Definition at line 796 of file securimage.php.
References $image_width, $n, $num_lines, frand(), image_height, and image_width.
Referenced by doImage().
|
protected |
Draws random noise on the image.
Definition at line 833 of file securimage.php.
References $iscale, $noise_level, $size, $t, image_height, image_width, and noise_level.
Referenced by doImage().
|
protected |
Draws the captcha code on the image.
Definition at line 707 of file securimage.php.
References $iscale, image_height, image_width, and perturbation.
Referenced by doImage().
Securimage::frand | ( | ) |
Definition at line 1312 of file securimage.php.
Referenced by distortedCopy(), and drawLines().
|
protected |
Generates a random captcha code from the set character set.
Definition at line 972 of file securimage.php.
References $code, and $code_length.
Referenced by createCode().
|
protected |
Generate an MP3 audio file of the captcha image.
Definition at line 1165 of file securimage.php.
Referenced by getAudibleCode().
|
protected |
Generate a wav file given the $letters in the code.
array | $letters |
Definition at line 1176 of file securimage.php.
References $data, $file, $filename, audioError(), and scrambleAudioData().
Referenced by getAudibleCode().
|
protected |
Gets the code and returns the binary audio file for the stored captcha code.
string | $format | WAV only |
Definition at line 916 of file securimage.php.
References $code, createCode(), generateMP3(), generateWAV(), and getCode().
Referenced by outputAudioFile().
|
protected |
Scan the directory for a background image to use.
Definition at line 641 of file securimage.php.
References $file.
Referenced by setBackground().
|
protected |
Return the code from the session or sqlite database if used.
If none exists yet, an empty string is returned
Definition at line 1019 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.
Definition at line 1096 of file securimage.php.
References $code, $res, and isCodeExpired().
Referenced by getCode().
|
static |
Return the absolute path to the Securimage directory.
Definition at line 423 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 1322 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 1146 of file securimage.php.
Referenced by getCode(), and getCodeFromDatabase().
|
protected |
Open sqlite database.
Definition at line 1073 of file securimage.php.
References $res, and $sqlite_handle.
Referenced by getCode(), and saveCodeToDatabase().
|
protected |
Sends the appropriate image and cache headers and outputs image to the browser.
Definition at line 885 of file securimage.php.
References 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 479 of file securimage.php.
References exit, and getAudibleCode().
|
protected |
Deletes old codes from sqlite database.
Definition at line 1132 of file securimage.php.
|
protected |
Gets a captcha code from a wordlist.
Definition at line 944 of file securimage.php.
References $data.
Referenced by createCode().
|
protected |
Saves the code to the sqlite database.
Definition at line 1052 of file securimage.php.
References $_SESSION, $code, $namespace, $success, and openDatabase().
Referenced by saveData().
|
protected |
Save data to session namespace and database if used.
Definition at line 1041 of file securimage.php.
References $_SESSION, $code, $namespace, and saveCodeToDatabase().
Referenced by createCode().
|
protected |
Randomizes the audio data to add noise and prevent binary recognition.
string | $data | The binary audio file data |
string | $format | The format of the sound file (wav only) |
Definition at line 1273 of file securimage.php.
References $data.
Referenced by generateWAV().
|
protected |
The the background color, or background image to be used.
Definition at line 593 of file securimage.php.
References $img, getBackgroundFromDirectory(), image_height, and image_width.
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 441 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 989 of file securimage.php.
References $_SESSION, $code, $namespace, clearCodeFromDatabase(), and getCode().
Referenced by check().
Securimage::$audio_path |
Definition at line 326 of file securimage.php.
Securimage::$background_directory |
Definition at line 313 of file securimage.php.
|
protected |
Definition at line 332 of file securimage.php.
|
protected |
Definition at line 340 of file securimage.php.
Securimage::$captcha_type = self::SI_CAPTCHA_STRING |
Definition at line 280 of file securimage.php.
Securimage::$case_sensitive = false |
Definition at line 212 of file securimage.php.
Referenced by createCode().
Securimage::$charset = 'ABCDEFGHKLMNPRSTUVWYZabcdefghklmnprstuvwyz23456789' |
Definition at line 217 of file securimage.php.
|
protected |
Definition at line 337 of file securimage.php.
Referenced by check(), createCode(), generateCode(), getAudibleCode(), getCode(), getCodeFromDatabase(), saveCodeToDatabase(), saveData(), and validate().
|
protected |
Definition at line 338 of file securimage.php.
Securimage::$code_length = 6 |
Definition at line 207 of file securimage.php.
Referenced by generateCode().
Securimage::$expiry_time = 900 |
Definition at line 222 of file securimage.php.
|
protected |
Definition at line 343 of file securimage.php.
|
protected |
Definition at line 345 of file securimage.php.
|
protected |
Definition at line 346 of file securimage.php.
|
protected |
Definition at line 344 of file securimage.php.
|
protected |
Definition at line 330 of file securimage.php.
Securimage::$image_bg_color = '#ffffff' |
Definition at line 175 of file securimage.php.
Securimage::$image_height = 80 |
Definition at line 164 of file securimage.php.
Referenced by distortedCopy().
Securimage::$image_signature = '' |
Definition at line 257 of file securimage.php.
Securimage::$image_type = self::SI_IMAGE_PNG |
Definition at line 169 of file securimage.php.
Securimage::$image_width = 215 |
Definition at line 159 of file securimage.php.
Referenced by distortedCopy(), and drawLines().
|
protected |
Definition at line 333 of file securimage.php.
Referenced by distortedCopy(), drawNoise(), and drawWord().
Securimage::$line_color = '#707070' |
Definition at line 185 of file securimage.php.
Securimage::$namespace |
Definition at line 297 of file securimage.php.
Referenced by getCode(), saveCodeToDatabase(), saveData(), and validate().
Securimage::$noise_color = '#707070' |
Definition at line 190 of file securimage.php.
Securimage::$noise_level = 0 |
Definition at line 251 of file securimage.php.
Referenced by drawNoise().
Securimage::$num_lines = 8 |
Definition at line 246 of file securimage.php.
Referenced by drawLines().
Securimage::$perturbation = 0.75 |
Definition at line 241 of file securimage.php.
|
protected |
Definition at line 335 of file securimage.php.
Securimage::$session_name = null |
Definition at line 229 of file securimage.php.
Securimage::$signature_color = '#707070' |
Definition at line 262 of file securimage.php.
Securimage::$signature_font |
Definition at line 267 of file securimage.php.
Securimage::$sqlite_database |
Definition at line 318 of file securimage.php.
|
protected |
Definition at line 341 of file securimage.php.
Referenced by openDatabase().
Securimage::$text_color = '#707070' |
Definition at line 180 of file securimage.php.
Securimage::$text_transparency_percentage = 50 |
Definition at line 196 of file securimage.php.
|
protected |
Definition at line 331 of file securimage.php.
Securimage::$ttf_file |
Definition at line 303 of file securimage.php.
Referenced by __construct().
Securimage::$use_sqlite_db = false |
Definition at line 273 of file securimage.php.
Securimage::$use_transparent_text = false |
Definition at line 201 of file securimage.php.
Securimage::$use_wordlist = false |
Definition at line 235 of file securimage.php.
Securimage::$wordlist_file |
Definition at line 308 of file securimage.php.
const Securimage::SI_CAPTCHA_MATHEMATIC = 1 |
Definition at line 153 of file securimage.php.
const Securimage::SI_CAPTCHA_STRING = 0 |
Definition at line 148 of file securimage.php.
const Securimage::SI_IMAGE_GIF = 3 |
Definition at line 142 of file securimage.php.
const Securimage::SI_IMAGE_JPEG = 1 |
Definition at line 132 of file securimage.php.
const Securimage::SI_IMAGE_PNG = 2 |
Definition at line 137 of file securimage.php.