Vous êtes sur la page 1sur 14

Class Details

[line 95]
Securimage CAPTCHA Class.

[ Top ]

Class Variables

$audio_format =

[line 336]

Type of audio file to generate (mp3 or wav)

Type: string

[ Top ]

$audio_path =

[line 329]

Full path to the WAV files to use to make the audio files, include trailing /.
Name Files [A-Z0-9].wav

Tags:

1.0.
since:
1

Type: string

[ Top ]

$background_directory = null
[line 236]

Scan this directory for gif, jpg, and png files to use as background images.

A random image file will be picked each time.


Change from null to the full path to your directory.
i.e. var $background_directory = $_SERVER['DOCUMENT_ROOT'] .
'/securimage/backgrounds'; Make sure not to pass a background image to the show function,
otherwise this directive is ignored.

Type: string

[ Top ]

$charset =

[line 133]

The character set for individual characters in the image.


Letters are converted to uppercase.
The font must support the letters or there may be problematic substitutions.

Type: string

[ Top ]

$code_length =

[line 124]

The length of the code to generate.

Type: int

[ Top ]
$draw_lines_over_text =

[line 304]

Draw the lines over the text.


If fales lines will be drawn before putting the text on the image.

Type: boolean

[ Top ]

$gd_font_file =

[line 157]

Note: Use of GD fonts is not recommended as many distortion features are not available
The GD font to use.
Internal gd fonts can be loaded by their number.
Alternatively, a file path can be given and the font will be loaded from file.

Type: mixed

[ Top ]

$gd_font_size =

[line 166]

The approximate size of the font in pixels.


This does not control the size of the font because that is determined by the GD font itself.
This is used to aid the calculations of positioning used by this class.

Type: int

[ Top ]

$image_bg_color =
[line 225]

The background color for the image as a Securimage_Color.

Type: Securimage_Color

[ Top ]

$image_height =

[line 109]

The desired width of the CAPTCHA image.

Type: int

[ Top ]

$image_signature =

[line 312]

Text to write at the bottom corner of captcha image

Tags:

var: Signature text


since: 2.0

Type: string

[ Top ]

$image_type =

[line 117]
The image format for output.
Valid options: SI_IMAGE_PNG, SI_IMAGE_JPG, SI_IMAGE_GIF

Type: int

[ Top ]

$image_width =

[line 102]

The desired width of the CAPTCHA image.

Type: int

[ Top ]

$line_color =

[line 296]

Color of lines drawn over text

Type: string

[ Top ]

$multi_text_color =

[line 261]

Array of Securimage_Colors which will be randomly selected for each letter.

arra
Type:
y
[ Top ]

$num_lines =

[line 289]

Draw vertical and horizontal lines on the image.

Tags:

see: Securimage::$draw_lines_over_text
see: Securimage::$line_color

Type: boolean

[ Top ]

$perturbation =

[line 190]

How much to distort image, higher = more distortion.


Distortion is only available when using TTF fonts.

Type: float

[ Top ]

$session_name = ''

[line 345]

The session name to use if not the default. Blank for none

Tags:
see: http://php.net/session_name
since: 2.0

Type: string

[ Top ]

$signature_color =

[line 320]

Color to use for writing signature text

Tags:

2.
since:
0

Type: Securimage_Color

[ Top ]

$text_angle_maximum =

[line 209]

The minimum angle in degrees, with 0 degrees being left-to-right reading text.
Higher values represent a counter-clockwise rotation.
For example, a value of 90 would result in bottom-to-top reading text.

Type: int

[ Top ]

$text_angle_minimum =

[line 200]
The minimum angle in degrees, with 0 degrees being left-to-right reading text.

Higher values represent a counter-clockwise rotation.


For example, a value of 90 would result in bottom-to-top reading text.
This value along with maximum angle distance do not need to be very high with perturbation

Type: int

[ Top ]

$text_color =

[line 246]

The text color to use for drawing characters as a Securimage_Color.


This value is ignored if $use_multi_text is set to true.
Make sure this contrasts well with the background color or image.

Tags:

see: Securimage::$use_multi_text

Type: Securimage_Color

[ Top ]

$text_transparency_percentage =

[line 278]

The percentage of transparency, 0 to 100.


A value of 0 is completely opaque, 100 is completely transparent (invisble)

Tags:
see: Securimage::$use_transparent_text

Type: int

[ Top ]

$text_x_start =

[line 218]

The X-Position on the image where letter drawing will begin.


This value is in pixels from the left side of the image.

Tags:

2.
deprecated:
0

Type: int

[ Top ]

$ttf_file =

[line 182]

The path to the TTF font file to load.

Type: string

[ Top ]

$use_gd_font =

[line 173]
Use a gd font instead of TTF

Tags:

var: true for gd font, false for TTF

Type: bool

[ Top ]

$use_multi_text =

[line 254]

Set to true to use multiple colors for each character.

Tags:

see: Securimage::$multi_text_color

Type: boolean

[ Top ]

$use_transparent_text =

[line 269]

Set to true to make the characters appear transparent.

Tags:

see: Securimage::$text_transparency_percentage

Type: boolean
[ Top ]

$use_wordlist = false

[line 147]

Use wordlist of not

Tags:

var: true to use wordlist file, false to use random code

Type: bool

[ Top ]

$wordlist_file =

[line 140]

Create codes using this word list

Tags:

var: The path to the word list to use for creating CAPTCHA codes

Type: string

[ Top ]

Class Methods

constructor Securimage [line 419]

Securimage Securimage( )
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.

1. $securimage = new Securimage();

[ Top ]

method check [line 512]

boolean check( string $code)

Validate the code entered by the user.

1. $code = $_POST['code'];
2. if ($securimage->check($code) == false) {
3. die("Sorry, the code entered did not match.");
4. } else {
5. $valid = true;
6. }

Tags:

return: true if the code was correct, false if not

Parameters:

string $code The code the user entered

[ Top ]

method getAudibleCode [line 973]

string 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
Tags:

return: WAV or MP3 data


since: 1.0.1

Parameters:

$format

[ Top ]

method getCode [line 1047]

string getCode( )

Get the captcha code

Tags:

1.0.
since:
1

[ Top ]

method outputAudioFile [line 530]

void outputAudioFile( )

Output audio file with HTTP headers to browser

1. $sound = new Securimage();


2. $sound->audio_format = 'mp3';
3. $sound->outputAudioFile();

Tags:
2.
since:
0

[ Top ]

method setAudioPath [line 1000]

bool setAudioPath( $audio_directory)

Set the path to the audio directory.

Tags:

return: true if the directory exists and is readble, false if not


since: 1.0.4

Parameters:

$audio_directory

[ Top ]

method show [line 489]

void show( [string $background_image = ""])

Generate a code and output the image to the browser.

1. <?php
2. include 'securimage.php';
3. $securimage = new Securimage();
4. $securimage->show('bg.jpg');
5. ?>

Parameters:

string $background_image The path to an image to use as the background for the CAPTCHA