Securimage is highly customizable and its options can be changed in several places depending on your needs and the option being set. Settings can be changed directly in securimage.php which would apply to all of your captchas, or programmatticaly in securimage_show.php which shows captcha images, in securimage_play.php which plays captcha audio, and in your PHP script(s) (e.g. form processors) that validate captcha input from users.
Changes made in securimage.php are applied to all of your captchas unless overridden elsewhere. It is often useful to enter database connection settings in securimage.php so that you don’t have to set it in securimage_show.php and in your form processor. It also makes sense to specify the PHP $session_name to use if a different default session_name is used for your application.
Changes effecting captcha output or captchas targetted at a specific form can be set in securimage_show.php and/or your form processor. The options can be passed to the constructor as shown below, or set once you have created a Securimage object.
Example – Setting options in the constructor and on an object:
// Passing array of options to the constructor $options = array('no_session' => true, /* dont use sessions */ 'use_database' => true, /* use sqlite db */ 'captcha_type' => Securimage::SI_CAPTCHA_MATHEMATIC /* use math captcha */, ); $img = new Securimage($options); // settings in $options are used // Changing properties on the object $img->code_length = 4; // set length of captcha generated $img->text_color = '#000000'; // change text color $img->perturbation = 0.9; // set distortion to high
Where to change options
To change options globally in securimage.php, open it in a text editor and search for the name of the property you wish to change (e.g. $text_color, $use_database) and set the appropriate value directly in the code.
public $session_name = 'PHPSESSID'; // use custom session name public $text_color = '#003A96'; // change text color for all captchas
To change options in securimage_show.php or securimage_play.php open the file you wish to edit and set the appropriate option by changing the securimage object.
$img = new Securimage(); //... in securimage_show.php $img->namespace = 'contact_form'; //... in form processor $img->namespace = 'contact_form'; //... in securimage_play.php $img->audio_path = $img->securimage_path . '/audio/de/';