noalyss Version-9
|
Public Member Functions | |
__construct () | |
Class constructor. More... | |
addSignature () | |
Print signature text on image. More... | |
allocateColors () | |
Allocate all colors that will be used in the CAPTCHA image. More... | |
check ($code) | |
Validate the code entered by the user. More... | |
checkCode () | |
Check if the user entered code was correct. More... | |
clearCodeFromDatabase () | |
Delete a code from the database by ip address hash. More... | |
createCode () | |
Create a code and save to the session. More... | |
distortedCopy () | |
Warp text from temporary image onto final image. More... | |
doImage () | |
Generate and output the image. More... | |
drawLines () | |
Draw random curvy lines over the image Modified code from HKCaptcha. More... | |
drawWord () | |
Draw the CAPTCHA code over the image. More... | |
frand () | |
Generate random number less than 1. More... | |
generateCode ($len) | |
Generate a code. More... | |
generateMP3 ($letters) | |
Generate an mp3 file by concatenating individual files. More... | |
generateWAV ($letters) | |
Generate a wav file by concatenating individual files. More... | |
getAudibleCode ($format='wav') | |
Get WAV or MP3 file data of the spoken code. More... | |
getBackgroundFromDirectory () | |
Return the full path to a random gif, jpg, or png from the background directory. More... | |
getCode () | |
Get the captcha code. More... | |
getCodeFromDatabase () | |
Get stored captcha code from sqlite database based on ip address hash. More... | |
getIPHash () | |
Get hashed IP address of remote user. More... | |
isCodeExpired ($creation_time) | |
Check a code to see if it is expired based on creation time. More... | |
openDatabase () | |
Open SQLite database. More... | |
output () | |
Output image to the browser. More... | |
outputAudioFile () | |
Output audio file with HTTP headers to browser. More... | |
purgeOldCodesFromDatabase () | |
Purge codes over a day old from database. More... | |
readCodeFromFile () | |
Reads a word list file to get a code. More... | |
saveCodeToDatabase () | |
Save captcha code to sqlite database. More... | |
saveData () | |
Save the code in the session. More... | |
scrambleAudioData (&$data, $format) | |
Randomly modify the audio data to scramble sound and prevent binary recognition. More... | |
setAudioPath ($audio_directory) | |
Set the path to the audio directory. More... | |
setBackground () | |
Set the background of the CAPTCHA image. More... | |
show ($background_image="") | |
Generate a code and output the image to the browser. More... | |
validate () | |
Validate the code to the user code. More... | |
Definition at line 107 of file securimage.php.
Securimage::__construct | ( | ) |
Class constructor.
Because the class uses sessions, this will attempt to start a session if there is no previous one.
If you do not start a session before calling the class, the constructor must be called before any output is sent to the browser.
$securimage = new Securimage();
Definition at line 506 of file securimage.php.
References audio_format, code_length, image_bg_color, image_height, image_signature, image_type, image_width, line_color, multi_text_color, num_lines, perturbation, signature_color, text_angle_maximum, text_angle_minimum, text_color, text_transparency_percentage, use_multi_text, use_transparent_text, and use_wordlist.
Securimage::addSignature | ( | ) |
Print signature text on image.
Definition at line 1376 of file securimage.php.
References image_height, image_signature, and image_width.
Referenced by doImage().
Securimage::allocateColors | ( | ) |
Allocate all colors that will be used in the CAPTCHA image.
Definition at line 692 of file securimage.php.
References $color, elseif, image_bg_color, line_color, multi_text_color, signature_color, text_color, text_transparency_percentage, use_multi_text, and use_transparent_text.
Referenced by doImage().
Securimage::check | ( | $code | ) |
Validate the code entered by the user.
$code = $_POST['code']; if ($securimage->check($code) == false) { die("Sorry, the code entered did not match."); } else { $valid = true; }
string | $code | The code the user entered |
Definition at line 605 of file securimage.php.
References $code, $correct_code, and validate().
Securimage::checkCode | ( | ) |
Check if the user entered code was correct.
@access private
Definition at line 1215 of file securimage.php.
References $correct_code.
Securimage::clearCodeFromDatabase | ( | ) |
Delete a code from the database by ip address hash.
@access private
Definition at line 1486 of file securimage.php.
References getIPHash().
Referenced by validate().
Securimage::createCode | ( | ) |
Create a code and save to the session.
@access private
Definition at line 996 of file securimage.php.
References code_length, generateCode(), readCodeFromFile(), saveData(), and use_wordlist.
Referenced by doImage(), and getAudibleCode().
Securimage::distortedCopy | ( | ) |
Warp text from temporary image onto final image.
Modified for securimage
@access private
Definition at line 936 of file securimage.php.
References $i, $image_height, $image_width, $iscale, $ix, $r, $rad, $tmp, frand(), image_height, image_width, and perturbation.
Referenced by doImage().
Securimage::doImage | ( | ) |
Generate and output the image.
@access private
Definition at line 652 of file securimage.php.
References addSignature(), allocateColors(), bgimg, createCode(), distortedCopy(), drawLines(), drawWord(), image_height, image_signature, image_width, num_lines, output(), setBackground(), and use_transparent_text.
Referenced by show().
Securimage::drawLines | ( | ) |
Draw random curvy lines over the image
Modified code from HKCaptcha.
Definition at line 813 of file securimage.php.
References $i, $image_width, $line, $num_lines, $step, $w, frand(), image_height, and image_width.
Referenced by doImage().
Securimage::drawWord | ( | ) |
Draw the CAPTCHA code over the image.
@access private
Definition at line 853 of file securimage.php.
References $gd_font_file, $gdtextcolor, $i, $iscale, image_height, image_width, multi_text_color, text_angle_maximum, text_angle_minimum, and use_multi_text.
Referenced by doImage().
Securimage::frand | ( | ) |
Generate random number less than 1.
Definition at line 1364 of file securimage.php.
Referenced by distortedCopy(), and drawLines().
Securimage::generateCode | ( | $len | ) |
Generate a code.
@access private
int | $len | The code length |
Definition at line 1018 of file securimage.php.
Referenced by createCode().
Securimage::generateMP3 | ( | $letters | ) |
Generate an mp3 file by concatenating individual files.
array | $letters | Array of letters to build a file from |
Definition at line 1336 of file securimage.php.
References $data, $letter, and scrambleAudioData().
Referenced by getAudibleCode().
Securimage::generateWAV | ( | $letters | ) |
Generate a wav file by concatenating individual files.
array | $letters | Array of letters to build a file from |
Definition at line 1228 of file securimage.php.
References $data, $file, $header, $i, $letter, $p, and scrambleAudioData().
Referenced by getAudibleCode().
Securimage::getAudibleCode | ( | $format = 'wav' | ) |
Get WAV or MP3 file data of the spoken code.
This is appropriate for output to the browser as audio/x-wav or audio/mpeg
Definition at line 1104 of file securimage.php.
References $code, $i, createCode(), generateMP3(), generateWAV(), and getCode().
Referenced by outputAudioFile().
Securimage::getBackgroundFromDirectory | ( | ) |
Return the full path to a random gif, jpg, or png from the background directory.
@access private
Definition at line 786 of file securimage.php.
References $file, and background_directory.
Referenced by setBackground().
Securimage::getCode | ( | ) |
Get the captcha code.
Definition at line 1198 of file securimage.php.
References getCodeFromDatabase(), and openDatabase().
Referenced by getAudibleCode().
Securimage::getCodeFromDatabase | ( | ) |
Get stored captcha code from sqlite database based on ip address hash.
@access private
Definition at line 1460 of file securimage.php.
References $code, $res, getIPHash(), and isCodeExpired().
Referenced by getCode(), and validate().
Securimage::getIPHash | ( | ) |
Get hashed IP address of remote user.
@access private
Definition at line 1398 of file securimage.php.
Referenced by clearCodeFromDatabase(), getCodeFromDatabase(), and saveCodeToDatabase().
Securimage::isCodeExpired | ( | $creation_time | ) |
Check a code to see if it is expired based on creation time.
@access private
$creation_time | unix timestamp of code creation time |
Definition at line 1519 of file securimage.php.
Referenced by getCodeFromDatabase(), and validate().
Securimage::openDatabase | ( | ) |
Open SQLite database.
@access private
Definition at line 1410 of file securimage.php.
References $error, $res, and $sqlite_handle.
Referenced by getCode(), saveCodeToDatabase(), and validate().
Securimage::output | ( | ) |
Output image to the browser.
@access private
Definition at line 1066 of file securimage.php.
References exit, and image_type.
Referenced by doImage().
Securimage::outputAudioFile | ( | ) |
Output audio file with HTTP headers to browser.
$sound = new Securimage(); $sound->audio_format = 'mp3'; $sound->outputAudioFile();
Definition at line 623 of file securimage.php.
References $ext, audio_format, exit, and getAudibleCode().
Securimage::purgeOldCodesFromDatabase | ( | ) |
Purge codes over a day old from database.
@access private
Definition at line 1501 of file securimage.php.
References $limit.
Securimage::readCodeFromFile | ( | ) |
Reads a word list file to get a code.
@access private
Definition at line 1035 of file securimage.php.
References $data, $end, $max, and $start.
Referenced by createCode().
Securimage::saveCodeToDatabase | ( | ) |
Save captcha code to sqlite database.
@access private
Definition at line 1437 of file securimage.php.
References $code, getIPHash(), and openDatabase().
Referenced by saveData().
Securimage::saveData | ( | ) |
Save the code in the session.
@access private
Definition at line 1147 of file securimage.php.
References saveCodeToDatabase().
Referenced by createCode().
Securimage::scrambleAudioData | ( | & | $data, |
$format | |||
) |
Randomly modify the audio data to scramble sound and prevent binary recognition.
Take care not to "break" the audio file by leaving the header data intact.
$data | Sound data in mp3 of wav format |
Definition at line 1309 of file securimage.php.
References $data, $i, and $start.
Referenced by generateMP3(), and generateWAV().
Securimage::setAudioPath | ( | $audio_directory | ) |
Set the path to the audio directory.
Definition at line 1131 of file securimage.php.
Securimage::setBackground | ( | ) |
Set the background of the CAPTCHA image.
@access private
Definition at line 746 of file securimage.php.
References $img, background_directory, bgimg, getBackgroundFromDirectory(), image_height, and image_width.
Referenced by doImage().
Securimage::show | ( | $background_image = "" | ) |
Generate a code and output the image to the browser.
<?php include 'securimage.php'; $securimage = new Securimage(); $securimage->show('bg.jpg'); ?>
string | $background_image | The path to an image to use as the background for the CAPTCHA |
Definition at line 582 of file securimage.php.
References bgimg, and doImage().
Securimage::validate | ( | ) |
Validate the code to the user code.
@access private
Definition at line 1161 of file securimage.php.
References $code, $code_entered, clearCodeFromDatabase(), getCodeFromDatabase(), isCodeExpired(), and openDatabase().
Referenced by check().
Securimage::$audio_format |
Definition at line 348 of file securimage.php.
Securimage::$audio_path |
Definition at line 341 of file securimage.php.
Securimage::$background_directory = null |
Definition at line 248 of file securimage.php.
Securimage::$bgimg |
Definition at line 420 of file securimage.php.
Securimage::$charset |
Definition at line 145 of file securimage.php.
Securimage::$code |
Definition at line 428 of file securimage.php.
Referenced by check(), generateCode(), getAudibleCode(), getCodeFromDatabase(), saveCodeToDatabase(), and validate().
Securimage::$code_entered |
Definition at line 436 of file securimage.php.
Referenced by validate().
Securimage::$code_length |
Definition at line 136 of file securimage.php.
Securimage::$correct_code |
Definition at line 444 of file securimage.php.
Referenced by check(), and checkCode().
Securimage::$draw_lines_over_text |
Definition at line 316 of file securimage.php.
Securimage::$expiry_time |
Definition at line 366 of file securimage.php.
Securimage::$gd_font_file |
Definition at line 169 of file securimage.php.
Referenced by drawWord().
Securimage::$gd_font_size |
Definition at line 178 of file securimage.php.
Securimage::$gdbgcolor |
Definition at line 492 of file securimage.php.
Securimage::$gdlinecolor |
Definition at line 460 of file securimage.php.
Securimage::$gdmulticolor |
Definition at line 468 of file securimage.php.
Securimage::$gdsignaturecolor |
Definition at line 484 of file securimage.php.
Securimage::$gdtextcolor |
Definition at line 476 of file securimage.php.
Referenced by drawWord().
Securimage::$im |
Definition at line 395 of file securimage.php.
Securimage::$image_bg_color |
Definition at line 237 of file securimage.php.
Securimage::$image_height |
Definition at line 121 of file securimage.php.
Referenced by distortedCopy().
Securimage::$image_signature |
Definition at line 324 of file securimage.php.
Securimage::$image_type |
Definition at line 129 of file securimage.php.
Securimage::$image_width |
Definition at line 114 of file securimage.php.
Referenced by distortedCopy(), and drawLines().
Securimage::$iscale |
Definition at line 412 of file securimage.php.
Referenced by distortedCopy(), and drawWord().
Securimage::$line_color |
Definition at line 308 of file securimage.php.
Securimage::$multi_text_color |
Definition at line 273 of file securimage.php.
Securimage::$num_lines |
Definition at line 301 of file securimage.php.
Referenced by drawLines().
Securimage::$perturbation |
Definition at line 202 of file securimage.php.
Securimage::$session_name = '' |
Definition at line 357 of file securimage.php.
Securimage::$signature_color |
Definition at line 332 of file securimage.php.
Securimage::$sqlite_database |
Definition at line 377 of file securimage.php.
Securimage::$sqlite_handle |
Definition at line 452 of file securimage.php.
Referenced by openDatabase().
Securimage::$text_angle_maximum |
Definition at line 221 of file securimage.php.
Securimage::$text_angle_minimum |
Definition at line 212 of file securimage.php.
Securimage::$text_color |
Definition at line 258 of file securimage.php.
Securimage::$text_transparency_percentage |
Definition at line 290 of file securimage.php.
Securimage::$text_x_start |
Definition at line 230 of file securimage.php.
Securimage::$tmpimg |
Definition at line 403 of file securimage.php.
Securimage::$ttf_file |
Definition at line 194 of file securimage.php.
Securimage::$use_gd_font |
Definition at line 185 of file securimage.php.
Securimage::$use_multi_text |
Definition at line 266 of file securimage.php.
Securimage::$use_sqlite_db |
Use an SQLite database for storing codes as a backup to sessions.
Note: Sessions will still be used
Definition at line 383 of file securimage.php.
Securimage::$use_transparent_text |
Definition at line 281 of file securimage.php.
Securimage::$use_wordlist = false |
Definition at line 159 of file securimage.php.
Securimage::$wordlist_file |
Definition at line 152 of file securimage.php.