Admidio API
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Packages

  • com
    • tecnick
      • tcpdf
  • None
  • PHPMailer
    • easypeasyics
  • PHPWavUtils
  • Securimage
    • classes

Classes

  • Securimage
  • Securimage_Color

Class Securimage

Securimage CAPTCHA Class.

A class for creating and validating secure CAPTCHA images and audio.

The class contains many options regarding appearance, security, storage of captcha data and image/audio generation options.

Package: Securimage\classes
Copyright: 2016 Drew Phillips
Author: Drew Phillips drew@drew-phillips.com
Version: 3.5.2
Located at securimage.php

Methods summary

public
# __construct( array $options = array() )

Create a new securimage object, pass options to set in the constructor.

Create a new securimage object, pass options to set in the constructor.

The object can then be used to display a captcha, play an audible captcha, or validate a submission.

Parameters

$options

Options to initialize the class. May be any class property.

$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);
public static string
# getPath( )

Return the absolute path to the Securimage directory.

Return the absolute path to the Securimage directory.

Returns

string
The path to the securimage base directory
public static null|string
# getCaptchaId( boolean $new = true, array $options = array() )

Generate a new captcha ID or retrieve the current ID (if exists).

Generate a new captcha ID or retrieve the current ID (if exists).

Parameters

$new
If true, generates a new challenge and returns and ID. If false, the existing captcha ID is returned, or null if none exists.
$options

Additional options to be passed to Securimage. $options must include database settings if they are not set directly in securimage.php

Returns

null|string
Returns null if no captcha id set and new was false, or the captcha ID
public static boolean
# checkByCaptchaId( string $id, string $value, array $options = array() )

Validate a captcha code input against a captcha ID

Validate a captcha code input against a captcha ID

Parameters

$id
The captcha ID to check
$value
The captcha value supplied by the user
$options

Array of options to construct Securimage with. Options must include database options if they are not set in securimage.php

Returns

boolean
true if the code was valid for the given captcha ID, false if not or if database failed to open

See

Securimage::$database_driver
public
# show( string $background_image = '' )

Generates a new challenge and serves a captcha image.

Generates a new challenge and serves a captcha image.

Appropriate headers will be sent to the browser unless the send_headers option is false.

Parameters

$background_image

The absolute or relative path to the background image to use as the background of the captcha image.

$img = new Securimage();
$img->code_length = 6;
$img->num_lines   = 5;
$img->noise_level = 5;

$img->show(); // sends the image and appropriate headers to browser
exit;
public boolean
# check( string $code )

Checks a given code against the correct value from the session and/or database.

Checks a given code against the correct value from the session and/or database.

Parameters

$code

The captcha code to check

$code = $_POST['code'];
$img  = new Securimage();
if ($img->check($code) == true) {
    $captcha_valid = true;
} else {
    $captcha_valid = false;
}

Returns

boolean
true if the given code was correct, false if not.
public static string
# getCaptchaHtml( array $options = array(), integer $parts = Securimage::HTML_ALL )

Returns HTML code for displaying the captcha image, audio button, and form text input.

Returns HTML code for displaying the captcha image, audio button, and form text input.

Options can be specified to modify the output of the HTML. Accepted options: 'securimage_path': Optional: The URI to where securimage is installed (e.g. /securimage) 'show_image_url': Path to the securimage_show.php script (useful when integrating with a framework or moving outside the securimage directory) This will be passed as a urlencoded string to the tag for outputting the captcha image 'audio_play_url': Same as show_image_url, except this indicates the URL of the audio playback script 'image_id': A string that sets the "id" attribute of the captcha image (default: captcha_image) 'image_alt_text': The alt text of the captcha image (default: CAPTCHA Image) 'show_audio_button': true/false Whether or not to show the audio button (default: true) 'disable_flash_fallback':) Allow only HTML5 audio and disable Flash fallback 'show_refresh_button': true/false Whether or not to show a button to refresh the image (default: true) 'audio_icon_url': URL to the image used for showing the HTML5 audio icon 'icon_size': Size (for both height & width) in pixels of the audio and refresh buttons 'show_text_input': true/false Whether or not to show the text input for the captcha (default: true) 'refresh_alt_text': Alt text for the refresh image (default: Refresh Image) 'refresh_title_text': Title text for the refresh image link (default: Refresh Image) 'input_id': A string that sets the "id" attribute of the captcha text input (default: captcha_code) 'input_name': A string that sets the "name" attribute of the captcha text input (default: same as input_id) 'input_text': A string that sets the text of the label for the captcha text input (default: Type the text:) 'input_attributes': An array of additional HTML tag attributes to pass to the text input tag (default: empty) 'image_attributes': An array of additional HTML tag attributes to pass to the captcha image tag (default: empty) 'error_html': Optional HTML markup to be shown above the text input field 'namespace': The optional captcha namespace to use for showing the image and playing back the audio. Namespaces are for using multiple captchas on the same page.

Parameters

$options
Array of options for modifying the HTML code.
$parts
Securiage::HTML_* constant controlling what component of the captcha HTML to display

Returns

string
The generated HTML code for displaying the captcha
public integer
# getTimeToSolve( )

Get the time in seconds that it took to solve the captcha.

Get the time in seconds that it took to solve the captcha.

Returns

integer
The time in seconds from when the code was created, to when it was solved
public
# setNamespace( string $namespace )

Set the namespace for the captcha being stored in the session or database.

Set the namespace for the captcha being stored in the session or database.

Namespaces are useful when multiple captchas need to be displayed on a single page.

Parameters

$namespace
Namespace value, String consisting of characters "a-zA-Z0-9_-"
public
# outputAudioFile( string $format = null )

Generate an audible captcha in WAV format and send it to the browser with appropriate headers. Example:

Generate an audible captcha in WAV format and send it to the browser with appropriate headers. Example:

$img = new Securimage(); $img->outputAudioFile(); // outputs a wav file to the browser exit;

Parameters

$format
public
# rangeDownload( string $audio )

Output audio data with http range support. Typically this shouldn't be called directly unless being used with a custom implentation. Use Securimage::outputAudioFile instead.

Output audio data with http range support. Typically this shouldn't be called directly unless being used with a custom implentation. Use Securimage::outputAudioFile instead.

Parameters

$audio
Raw wav or mp3 audio file content
public array|string
# getCode( boolean $array = false, boolean $returnExisting = false )

Return the code from the session or database (if configured). If none exists or was found, an empty string is returned.

Return the code from the session or database (if configured). If none exists or was found, an empty string is returned.

Parameters

$array
true to receive an array containing the code and properties, false to receive just the code.
$returnExisting
If true, and the class property code is set, it will be returned instead of getting the code from the session or database.

Returns

array|string
Return is an array if $array = true, otherwise a string containing the code
protected
# doImage( )

The main image drawing routing, responsible for constructing the entire image and serving it

The main image drawing routing, responsible for constructing the entire image and serving it

protected
# allocateColors( )

Allocate the colors to be used for the image

Allocate the colors to be used for the image

protected
# setBackground( )

The the background color, or background image to be used

The the background color, or background image to be used

protected string|boolean
# getBackgroundFromDirectory( )

Scan the directory for a background image to use

Scan the directory for a background image to use

Returns

string|boolean
public
# createCode( )

This method generates a new captcha code.

This method generates a new captcha code.

Generates a random captcha code based on charset, math problem, or captcha from the wordlist and saves the value to the session and/or database.

protected
# drawWord( )

Draws the captcha code on the image

Draws the captcha code on the image

protected
# distortedCopy( )

Copies the captcha image to the final image with distortion applied

Copies the captcha image to the final image with distortion applied

protected
# drawLines( )

Draws distorted lines on the image

Draws distorted lines on the image

protected
# drawNoise( )

Draws random noise on the image

Draws random noise on the image

protected
# addSignature( )

Print signature text on image

Print signature text on image

protected
# output( )

Sends the appropriate image and cache headers and outputs image to the browser

Sends the appropriate image and cache headers and outputs image to the browser

protected string
# getAudibleCode( )

Generates an audio captcha in WAV format

Generates an audio captcha in WAV format

Returns

string
The audio representation of the captcha in Wav format
protected string|array|boolean
# readCodeFromFile( integer $numWords = 1 )

Gets a captcha code from a file containing a list of words.

Gets a captcha code from a file containing a list of words.

Seek to a random offset in the file and reads a block of data and returns a line from the file.

Parameters

$numWords
Number of words (lines) to read from the file

Returns

string|array|boolean
Returns a string if only one word is to be read, or an array of words
protected string
# generateCode( )

Generates a random captcha code from the set character set

Generates a random captcha code from the set character set

Returns

string
A randomly generated CAPTCHA code

See

Securimage::$charset Charset option
protected
# validate( )

Validate a code supplied by the user

Validate a code supplied by the user

Checks the entered code against the value stored in the session and/or database (if configured). Handles case sensitivity. Also removes the code from session/database if the code was entered correctly to prevent re-use attack.

This function does not return a value.

See

Securimage::$correct_code 'correct_code' property
protected
# saveData( )

Save CAPTCHA data to session and database (if configured)

Save CAPTCHA data to session and database (if configured)

protected
# saveAudioData( string $data )

Save audio data to session and/or the configured database

Save audio data to session and/or the configured database

Parameters

$data
The CAPTCHA audio data
protected string|boolean
# getAudioData( )

Gets audio file contents from the session or database

Gets audio file contents from the session or database

Returns

string|boolean
Audio contents on success, or false if no audio found in session or DB
protected
# saveCodeToDatabase( )

Saves the CAPTCHA data to the configured database.

Saves the CAPTCHA data to the configured database.

protected boolean
# saveAudioToDatabase( string $data )

Saves CAPTCHA audio to the configured database

Saves CAPTCHA audio to the configured database

Parameters

$data
Audio data

Returns

boolean
true on success, false on failure
protected boolean
# openDatabase( )

Opens a connection to the configured database.

Opens a connection to the configured database.

Returns

boolean
true if the database connection was successful, false if not

See

Securimage::$use_database Use database
Securimage::$database_driver Database driver
Securimage::$pdo_conn pdo_conn
protected string
# getDsn( )

Get the PDO DSN string for connecting to the database

Get the PDO DSN string for connecting to the database

Returns

string
The DSN for connecting to the database

Throws

Exception
If database specific options are not configured

See

Securimage::$database_driver Database driver
protected boolean
# checkTablesExist( )

Checks if the necessary database tables for storing captcha codes exist

Checks if the necessary database tables for storing captcha codes exist

Returns

boolean
true if the database do exist, false if not

Throws

Exception
If the table check failed for some reason
protected boolean
# createDatabaseTables( )

Create the necessary databaes table for storing captcha codes.

Create the necessary databaes table for storing captcha codes.

Based on the database adapter used, the tables will created in the existing connection.

Returns

boolean
true if the tables were created, false if not

See

Securimage::$database_driver Database driver
protected string|array
# getCodeFromDatabase( )

Retrieves a stored code from the database for based on the captchaId or IP address if captcha ID not used.

Retrieves a stored code from the database for based on the captchaId or IP address if captcha ID not used.

Returns

string|array

Empty string if no code was found or has expired, otherwise returns array of code information.

protected
# clearCodeFromDatabase( )

Remove a stored code from the database based on captchaId or IP address.

Remove a stored code from the database based on captchaId or IP address.

protected
# purgeOldCodesFromDatabase( )

Deletes old (expired) codes from the database

Deletes old (expired) codes from the database

protected boolean
# isCodeExpired( integer $creation_time )

Checks to see if the captcha code has expired and can no longer be used.

Checks to see if the captcha code has expired and can no longer be used.

Parameters

$creation_time
The Unix timestamp of when the captcha code was created

Returns

boolean
true if the code is expired, false if it is still valid

See

Securimage::$expiry_time expiry_time
protected string
# generateWAV( array $letters )

Generate a wav file given the $letters in the code

Generate a wav file given the $letters in the code

Parameters

$letters
The letters making up the captcha

Returns

string
The audio content in WAV format
public boolean|string
# getRandomNoiseFile( )

Gets and returns the path to a random noise file from the audio noise directory.

Gets and returns the path to a random noise file from the audio noise directory.

Returns

boolean|string
false if a file could not be found, or a string containing the path to the file.
protected string
# getSoxEffectChain( integer $numEffects = 2 )

Get a random effect or chain of effects to apply to a segment of the audio file.

Get a random effect or chain of effects to apply to a segment of the audio file.

These effects should increase the randomness of the audio for a particular letter/number by modulating the signal. The SoX effects used are bend, chorus, overdrive, pitch, reverb, tempo, and tremolo.

For each effect selected, random parameters are supplied to the effect.

Parameters

$numEffects
How many effects to chain together

Returns

string
A string of valid SoX effects and their respective options.
protected string
# getSoxNoiseData( float $duration, integer $numChannels, integer $sampleRate, integer $bitRate )

This function is not yet used.

This function is not yet used.

Generate random background noise from sweeping oscillators

Parameters

$duration
How long in seconds the generated sound will be
$numChannels
Number of channels in output wav
$sampleRate
Sample rate of output wav
$bitRate
Bits per sample (8, 16, 24)

Returns

string
Audio data in wav format
protected string
# wavToMp3( string $data )

Convert WAV data to MP3 using the Lame MP3 encoder binary

Convert WAV data to MP3 using the Lame MP3 encoder binary

Parameters

$data
Contents of the WAV file to convert

Returns

string
MP3 file data
protected string
# audioError( )

Return a wav file saying there was an error generating file

Return a wav file saying there was an error generating file

Returns

string
The binary audio contents
protected boolean
# canSendHeaders( )

Checks to see if headers can be sent and if any error has been output to the browser

Checks to see if headers can be sent and if any error has been output to the browser

Returns

boolean
true if it is safe to send headers, false if not
public float
# frand( )

Return a random float between 0 and 0.9999

Return a random float between 0 and 0.9999

Returns

float
Random float between 0 and 0.9999
protected
# initColor( string $color, Securimage_Color|string $default )

Convert an html color code to a Securimage_Color

Convert an html color code to a Securimage_Color

Parameters

$color
$default
The defalt color to use if $color is invalid
public boolean
# errorHandler( integer $errno, string $errstr, string $errfile = '', integer $errline = 0, array $errcontext = array() )

The error handling function used when outputting captcha image or audio.

The error handling function 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

Parameters

$errno
PHP error number
$errstr
String description of the error
$errfile
File error occurred in
$errline
Line the error occurred on in file
$errcontext
Additional context information

Returns

boolean
true if the error was handled, false if PHP should handle the error

Constants summary

integer SI_IMAGE_JPEG

Constant for rendering captcha as a JPEG image

Constant for rendering captcha as a JPEG image

# 1
integer SI_IMAGE_PNG

Constant for rendering captcha as a PNG image (default)

Constant for rendering captcha as a PNG image (default)

# 2
integer SI_IMAGE_GIF

Constant for rendering captcha as a GIF image

Constant for rendering captcha as a GIF image

# 3
integer SI_CAPTCHA_STRING

Constant for generating a normal alphanumeric captcha based on the character set

Constant for generating a normal alphanumeric captcha based on the character set

See

Securimage::$charset charset property
# 0
integer SI_CAPTCHA_MATHEMATIC

Constant for generating a captcha consisting of a simple math problem

Constant for generating a captcha consisting of a simple math problem

# 1
integer SI_CAPTCHA_WORDS

Constant for generating a word based captcha using 2 words from a list

Constant for generating a word based captcha using 2 words from a list

# 2
string SI_DRIVER_MYSQL

MySQL option identifier for database storage option

MySQL option identifier for database storage option

# 'mysql'
string SI_DRIVER_PGSQL

PostgreSQL option identifier for database storage option

PostgreSQL option identifier for database storage option

# 'pgsql'
string SI_DRIVER_SQLITE3

SQLite option identifier for database storage option

SQLite option identifier for database storage option

# 'sqlite'
integer HTML_IMG

getCaptchaHtml() display constant for HTML Captcha Image

getCaptchaHtml() display constant for HTML Captcha Image

# 1
integer HTML_AUDIO

getCaptchaHtml() display constant for HTML5 Audio code

getCaptchaHtml() display constant for HTML5 Audio code

# 2
integer HTML_INPUT

getCaptchaHtml() display constant for Captcha Input text box

getCaptchaHtml() display constant for Captcha Input text box

# 4
integer HTML_INPUT_LABEL

getCaptchaHtml() display constant for Captcha Text HTML label

getCaptchaHtml() display constant for Captcha Text HTML label

# 8
integer HTML_ICON_REFRESH

getCaptchaHtml() display constant for HTML Refresh button

getCaptchaHtml() display constant for HTML Refresh button

# 16
integer HTML_ALL

getCaptchaHtml() display constant for all HTML elements (default)

getCaptchaHtml() display constant for all HTML elements (default)

# 0xffffffff

Properties summary

public integer $image_width

The width of the captcha image

The width of the captcha image

# 215
public integer $image_height

The height of the captcha image

The height of the captcha image

# 80
public float $font_ratio

Font size is calculated by image height and this ratio. Leave blank for default ratio of 0.4.

Font size is calculated by image height and this ratio. Leave blank for default ratio of 0.4.

Valid range: 0.1 - 0.99.

Depending on image_width, values > 0.6 are probably too large and values < 0.3 are too small.

#
public integer $image_type

The type of the image, default = png

The type of the image, default = png

See

Securimage::SI_IMAGE_PNG SI_IMAGE_PNG
Securimage::SI_IMAGE_JPEG SI_IMAGE_JPEG
Securimage::SI_IMAGE_GIF SI_IMAGE_GIF
# self::SI_IMAGE_PNG
public Securimage_Color|string $image_bg_color

The background color of the captcha

The background color of the captcha

# '#ffffff'
public Securimage_Color|string $text_color

The color of the captcha text

The color of the captcha text

# '#707070'
public Securimage_Color|string $line_color

The color of the lines over the captcha

The color of the lines over the captcha

# '#707070'
public Securimage_Color|string $noise_color

The color of the noise that is drawn

The color of the noise that is drawn

# '#707070'
public integer $text_transparency_percentage

How transparent to make the text.

How transparent to make the text.

0 = completely opaque, 100 = invisible

# 20
public boolean $use_transparent_text

Whether or not to draw the text transparently.

Whether or not to draw the text transparently.

true = use transparency, false = no transparency

# true
public integer $code_length

The length of the captcha code

The length of the captcha code

# 6
public boolean $case_sensitive

Whether the captcha should be case sensitive or not.

Whether the captcha should be case sensitive or not.

Not recommended, use only for maximum protection.

# false
public string $charset

The character set to use for generating the captcha code

The character set to use for generating the captcha code

# 'ABCDEFGHKLMNPRSTUVWYZabcdefghklmnprstuvwyz23456789'
public integer $expiry_time

How long in seconds a captcha remains valid, after this time it will be considered incorrect.

How long in seconds a captcha remains valid, after this time it will be considered incorrect.

# 900
public string $session_name

The session name securimage should use.

The session name securimage should use.

Only use if your application uses a custom session name (e.g. Joomla). It is recommended to set this value here so it is used by all securimage scripts (i.e. securimage_show.php)

# null
public boolean $use_wordlist

true to use the wordlist file, false to generate random captcha codes

true to use the wordlist file, false to generate random captcha codes

# false
public float $perturbation

The level of distortion.

The level of distortion.

0.75 = normal, 1.0 = very high distortion

# 0.85
public integer $num_lines

How many lines to draw over the captcha code to increase security

How many lines to draw over the captcha code to increase security

# 5
public integer $noise_level

The level of noise (random dots) to place on the image, 0-10

The level of noise (random dots) to place on the image, 0-10

# 2
public string $image_signature

The signature text to draw on the bottom corner of the image

The signature text to draw on the bottom corner of the image

# ''
public Securimage_Color|string $signature_color

The color of the signature text

The color of the signature text

# '#707070'
public string $signature_font

The path to the ttf font file to use for the signature text. Defaults to $ttf_file (AHGBold.ttf)

The path to the ttf font file to use for the signature text. Defaults to $ttf_file (AHGBold.ttf)

See

Securimage::$ttf_file
#
public boolean $use_sqlite_db

No longer used.

No longer used.

Use an SQLite database to store data (for users that do not support cookies)

Deprecated

3.2RC4

See

Securimage::$database_driver database_driver property
# false
public boolean $use_database

Use a database backend for code storage. Provides a fallback to users with cookies disabled. Required when using captcha IDs.

Use a database backend for code storage. Provides a fallback to users with cookies disabled. Required when using captcha IDs.

See

Securimage::$database_driver
# false
public boolean $skip_table_check

Whether or not to skip checking if Securimage tables exist when using a database.

Whether or not to skip checking if Securimage tables exist when using a database.

Turn this to true once database functionality is working to improve performance.

# false
public string $database_driver

Database driver to use for database support. Allowable values: mysql, pgsql, sqlite. Default: sqlite

Database driver to use for database support. Allowable values: mysql, pgsql, sqlite. Default: sqlite

# self::SI_DRIVER_SQLITE3
public string $database_host

Database host to connect to when using mysql or postgres

Database host to connect to when using mysql or postgres

On Linux use "localhost" for Unix domain socket, otherwise uses TCP/IP

Does not apply to SQLite

# 'localhost'
public string $database_user

Database username for connection (mysql, postgres only) Default is an empty string

Database username for connection (mysql, postgres only) Default is an empty string

# ''
public string $database_pass

Database password for connection (mysql, postgres only) Default is empty string

Database password for connection (mysql, postgres only) Default is empty string

# ''
public string $database_name

Name of the database to select (mysql, postgres only)

Name of the database to select (mysql, postgres only)

See

Securimage::$database_file for SQLite
# ''
public string $database_table

Database table where captcha codes are stored

Database table where captcha codes are stored

Note: Securimage will attempt to create this table for you if it does not exist. If the table cannot be created, an E_USER_WARNING is emitted

# 'captcha_codes'
public string $database_file

Fully qualified path to the database file when using SQLite3.

Fully qualified path to the database file when using SQLite3.

This value is only used when $database_driver == sqlite and does not apply when no database is used, or when using MySQL or PostgreSQL.

On *nix, file must have permissions of 0666.

Make sure the directory containing this file is NOT web accessible

#
public integer $captcha_type

The type of captcha to create.

The type of captcha to create.

Either alphanumeric based on charset, a simple math problem, or an image consisting of 2 words from the word list.

See

Securimage::SI_CAPTCHA_STRING SI_CAPTCHA_STRING
Securimage::SI_CAPTCHA_MATHEMATIC SI_CAPTCHA_MATHEMATIC
Securimage::SI_CAPTCHA_WORDS SI_CAPTCHA_WORDS
Securimage::$charset charset property
Securimage::$wordlist_file wordlist_file property
# self::SI_CAPTCHA_STRING
public string $namespace

The captcha namespace used for having multiple captchas on a page or to separate captchas from differen forms on your site. Example:

The captcha namespace used for having multiple captchas on a page or to separate captchas from differen forms on your site. Example:

<?php // use // or manually in securimage_show.php $img->setNamespace('contact_form'); // in form validator $img->setNamespace('contact_form'); if ($img->check($code) == true) { echo "Valid!"; }

#
public string $ttf_file

The TTF font file to use to draw the captcha code.

The TTF font file to use to draw the captcha code.

Leave blank for default font AHGBold.ttf

#
public string $wordlist_file

The path to the wordlist file to use.

The path to the wordlist file to use.

Leave blank for default words/words.txt

#
public string $wordlist_file_encoding

Character encoding of the wordlist file. Requires PHP Multibyte String (mbstring) support. Allows word list to contain characters other than US-ASCII (requires compatible TTF font).

Character encoding of the wordlist file. Requires PHP Multibyte String (mbstring) support. Allows word list to contain characters other than US-ASCII (requires compatible TTF font).

Since

3.6.3

See

http://php.net/manual/en/mbstring.supported-encodings.php
# null
public string $background_directory

The directory to scan for background images, if set a random background will be chosen from this folder

The directory to scan for background images, if set a random background will be chosen from this folder

#
public string $sqlite_database

No longer used

No longer used

The path to the SQLite database file to use

Deprecated

3.2RC4

See

Securimage::$database_file database_file property
#
public string $audio_path

The path to the audio files to be used for audio captchas.

The path to the audio files to be used for audio captchas.

Can also be set in securimage_play.php

Example: $img->audio_path = '/home/yoursite/public_html/securimage/audio/en/';

#
public boolean $audio_use_sox

Use SoX (The Swiss Army knife of audio manipulation) for audio effects and processing.

Use SoX (The Swiss Army knife of audio manipulation) for audio effects and processing.

Using SoX should make it more difficult for bots to solve audio captchas

See

Securimage::$sox_binary_path sox_binary_path property
# false
public string $sox_binary_path

The path to the SoX binary on your system

The path to the SoX binary on your system

# '/usr/bin/sox'
public static string $lame_binary_path

The path to the lame (mp3 encoder) binary on your system Static so that Securimage::getCaptchaHtml() has access to this value.

The path to the lame (mp3 encoder) binary on your system Static so that Securimage::getCaptchaHtml() has access to this value.

Since

3.6
# '/usr/bin/lame'
public string $audio_noise_path

The path to the directory containing audio files that will be selected randomly and mixed with the captcha audio.

The path to the directory containing audio files that will be selected randomly and mixed with the captcha audio.

#
public boolean $audio_use_noise

Whether or not to mix background noise files into captcha audio

Whether or not to mix background noise files into captcha audio

Mixing random background audio with noise can help improve security of audio captcha.

Default: securimage/audio/noise

Since

3.0.3

See

Securimage::$audio_noise_path audio_noise_path property
#
public float $audio_mix_normalization

The method and threshold (or gain factor) used to normalize the mixing with background noise.

The method and threshold (or gain factor) used to normalize the mixing with background noise.

See http://www.voegler.eu/pub/audio/ for more information.

Default: 0.6

Valid: >= 1 Normalize by multiplying by the threshold (boost - positive gain). A value of 1 in effect means no normalization (and results in clipping). <= -1 Normalize by dividing by the the absolute value of threshold (attenuate - negative gain). A factor of 2 (-2) is about 6dB reduction in volume. [0, 1) (open inverval - not including 1) The threshold above which amplitudes are comressed logarithmically. e.g. 0.6 to leave amplitudes up to 60% "as is" and compressabove. (-1, 0) (open inverval - not including -1 and 0) The threshold above which amplitudes are comressed linearly. e.g. -0.6 to leave amplitudes up to 60% "as is" and compress above.

Since

3.0.4
# 0.8
public boolean $degrade_audio

Whether or not to degrade audio by introducing random noise.

Whether or not to degrade audio by introducing random noise.

Current research shows this may not increase the security of audible captchas.

Default: true

Since

3.0.3
#
public float $audio_gap_min

Minimum delay to insert between captcha audio letters in milliseconds

Minimum delay to insert between captcha audio letters in milliseconds

Since

3.0.3
# 0
public float $audio_gap_max

Maximum delay to insert between captcha audio letters in milliseconds

Maximum delay to insert between captcha audio letters in milliseconds

Since

3.0.3
# 3000
protected static string $_captchaId

Captcha ID if using static captcha

Captcha ID if using static captcha

# null
protected resource $im

The GD image resource of the captcha image

The GD image resource of the captcha image

#
protected resource $tmpimg

A temporary GD image resource of the captcha image for distortion

A temporary GD image resource of the captcha image for distortion

#
protected string $bgimg

The background image GD resource

The background image GD resource

#
protected integer $iscale

Scale factor for magnification of distorted captcha image

Scale factor for magnification of distorted captcha image

# 5
public string $securimage_path

Absolute path to securimage directory.

Absolute path to securimage directory.

This is calculated at runtime

# null
protected string|boolean $code

The captcha challenge value.

The captcha challenge value.

Either the case-sensitive/insensitive word captcha, or the solution to the math captcha.

#
protected string $code_display

The display value of the captcha to draw on the image

The display value of the captcha to draw on the image

Either the word captcha or the math equation to present to the user

#
public string $display_value

Alternate text to draw as the captcha image text

Alternate text to draw as the captcha image text

A value that can be passed to the constructor that can be used to generate a captcha image with a given value.

This value does not get stored in the session or database and is only used when calling Securimage::show().

If a display_value was passed to the constructor and the captcha image is generated, the display_value will be used as the string to draw on the captcha image.

Used only if captcha codes are generated and managed by a 3rd party app/library

#
protected string $captcha_code

Captcha code supplied by user [set from Securimage::check()]

Captcha code supplied by user [set from Securimage::check()]

#
protected integer $_timeToSolve

Time (in seconds) that the captcha was solved in (correctly or incorrectly).

Time (in seconds) that the captcha was solved in (correctly or incorrectly).

This is from the time of code creation, to when validation was attempted.

# 0
protected boolean $no_exit

Flag that can be specified telling securimage not to call exit after generating a captcha image or audio file

Flag that can be specified telling securimage not to call exit after generating a captcha image or audio file

#
protected boolean $no_session

Flag indicating whether or not a PHP session should be started and used

Flag indicating whether or not a PHP session should be started and used

#
protected boolean $send_headers

Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio

Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio

#
protected PDO|boolean $pdo_conn

PDO connection when a database is used

PDO connection when a database is used

#
protected integer $gdbgcolor

The GD color for the background color

The GD color for the background color

#
protected integer $gdtextcolor

The GD color for the text color

The GD color for the text color

#
protected integer $gdlinecolor

The GD color for the line color

The GD color for the line color

#
protected integer $gdsignaturecolor

The GD color for the signature text color

The GD color for the signature text color

#
Admidio API API documentation generated by ApiGen