Captcha Library



( ZN >= 0.0.9 )

It was created to create and modify security code. The methods of the Security Code library are listed in the table below.

 

 

# Configuration


It is located in the captcha section in the following file to make predefined security code settings  .

File: Config / ViewObjects.php
Int $ charLength = 6 It is specified how many characters will be in length.
String $ bgColor = '80 | 80 | 80' Background is used to adjust the color. Colors R (0-255) | G (0-255) | B ( 0255 ) .
Array $ background = [] Used to give the background a picture. You can add more than one image with lined up order. These images will change randomly each time the security code is renewed. The path of the pictures is specified starting from the root node. For example, FILES_DIR . Like 'captcha / 1.jpg' .
String $ textColor = '255 | 255 | 255' Used to set the text color. Colors R (0-255) | G (0-255) | B ( 0255 ) .
Bool $ border = false The security code determines whether there is a frame in the visual.
String $ borderColor = '0 | 0 | 0' Used to adjust the color of the frame, if any. Colors R (0-255) | G (0-255) | B ( 0255 ) .
Int $ width = 180 The security code is the pixel width value of the visual.
Int $ height = 40 The security code is the height value of the visual in pixels.
Array $ imageString = [] Used to specify the size and position information of the text in the security code.
Int $ size = 5 The size of the text.
Int $ x = 65 The position of the text in the yacht.
Int $ y = 13 Vertical position of text.
Bool $ grid = true The security code is used to determine whether a visual is a grid.
Array $ gridSpace = [] Used to set the number of gutter spaces.
Int $ x = 12 Number of gaps between the grooved rows.
Int $ y = 12 Vertical grid spacing.
String $ gridColor = '50 | 50 | 50' Used to adjust the color of the grid. Colors R (0-255) | G (0-255) | B ( 0255 ) .
Int $ angel = 0 The text is used to give an angle. In order for this value to work , it is necessary to load the external font with the ttf setting.
Array $ ttf = [] Used to load font with external .ttf extension.

 

 

# Methods


String create ( Boolean $ img = false , Array $ configs = [] )
this size ( Int $ width , Int $ height )
this length ( Int $ param )
this borderColor ( String $ color = NULL )
this bgColor ( String $ color )
this bgImage ( Mixed $ image )
this textSize ( Int $ size )
this textCoordinate ( Int $ x , Int $ y )
this textColor ( String $ color )
this gridColor ( String $ color = NULL )
this gridSpace ( Int $ x = 0 , Int $ y = 0 )
this angle ( Float $ angle )
this ttf ( Array $ ttf )
String getCode ( Void )

 

 

# Create ( ZN> = 0.0.9 )


Used to create an image of the security code.

Parameters

Bool $ img = false Whether the link to the generated image is normal, or not with the < img > tag.
return String

Examples

echo Captcha::create();
echo Captcha::create(true);
https://www.xxx.xxx/projects/frontend/resources/files/capcha.png

 

 

# Size ( ZN >= 0.0.9 )


The security code is used to set the width and height of the visual .

Parameters

Int $ width Width.
Int $ height Height.
return this

Examples

echo Captcha::size(400, 400)->create(true);

 

 

# Length ( ZN >= 0.0.9 )


It is used to set the character length of the text in the security code.

Parameters

Int $ length Number of characters.
return this

Examples

echo Captcha::size(250, 60)
            ->length(8)
            ->create(true);

 

 

# BorderColor ( ZN >= 0.0.9 )


Used to set the color of the security code frame.

Parameters

String $ Color Frame color.
return this

Examples

echo Captcha::size(250, 60)
            ->length(8)
            ->borderColor('255|0|0')
            ->create(true);

 

 

# BgColor ( ZN >= 0.0.9 )


The security code is used to set the color of the background.

Parameters

String $ Color Background color
return this

Examples

echo Captcha::size(250, 60)
            ->length(8)
            ->borderColor('255|0|0')
            ->bgColor('255|255|255')
            ->create(true);

 

 

# BgImage ( ZN >= 0.0.9 )


The security code is used to add images to the background.

Parameters

Mixed $ images Background pictures.
return this

Examples

echo Captcha::bgImage
            ([
                FILES_DIR.'captcha/images/1.jpg',
                FILES_DIR.'captcha/images/2.jpg',
                FILES_DIR.'captcha/images/3.jpg'
            ])
            ->create(true);

 

 

# TextSize ( ZN >= 0.0.9 )


The security code is used to set the size of the text.

Parameters

Int $ you The size of the text.
return this

Examples

echo Captcha::size(250, 60)
            ->length(8)
            ->borderColor('0|0|255')
            ->bgColor('255|255|255')
            ->textSize(3)
            ->create(true);

 

 

# TextCoordinate ( ZN >= 0.0.9 )


The security code is used to set the position of the text in the x and y plane.

Parameters

Int $ x Position in the yacht.
Int $ y Vertical position.
return this

Examples

echo Captcha::size(250, 60)
            ->length(8)
            ->borderColor('0|0|255')
            ->bgColor('255|255|255')
            ->textSize(5)
            ->textCoordinate(90,22)
            ->create(true);

 

 

# TextColor ( ZN >= 0.0.9 )


The security code is used to set the color of the text.

Parameters

String $ Color The color of the text.
return this

Examples

echo Captcha::size(250, 60)
            ->length(8)
            ->borderColor('0|0|255')
            ->bgColor('255|255|255')
            ->textSize(5)
            ->textCoordinate(90,22)
            ->textColor('90|210|180')
            ->create(true);

 

 

# GridColor ( ZN >= 0.0.9 )


It is used to set the color of the security code grid.

Parameters

String $ Color Grid color.
return this

Examples

echo Captcha::size(250, 60)
            ->length(8)
            ->borderColor('0|0|255')
            ->bgColor('255|255|255')
            ->textSize(5)
            ->textCoordinate(90,22)
            ->textColor('90|210|180')
            ->gridColor('90|210|180')
            ->create(true);

 

 

# GridSpace ( ZN >= 0.0.9 )


It is used to determine the number of gaps between grids in the horizontal and vertical direction.

Parameters

Int $ x Number of spaces in horizontal.
Int $ y Vertical spacing.
return this

Examples

echo Captcha::size(250, 60)
            ->length(8)
            ->borderColor('0|0|255')
            ->bgColor('255|255|255')
            ->textSize(5)
            ->textCoordinate(90,22)
            ->textColor('90|210|180')
            ->gridColor('90|210|180')
            ->gridSpace(6, 2)
            ->create(true);

 

 

# Angle ( ZN >= 4.0.24 )


The security code is used to give an angle to the text. This method ttfneeds to be set up or ttf () method to be able to work.

Parameters

float $ Angle Angle value.
return this

Examples

echo Captcha::ttf
([
    FILES_DIR.'captcha/fonts/font1.ttf',
    FILES_DIR.'captcha/fonts/font2.ttf',
    FILES_DIR.'captcha/fonts/font3.ttf'
])
->angle(90)->create(true);

 

 

# TTF ( ZN >= 4.0.24 )


Security code is for using fonts with the extension ttf to change the font of the text . If more than one font is used, every time the security code visual is updated, a random font is selected from the specified fonts.

Parameters

Array $ fonts Fonts with a .ttf extension.
return this

Examples

echo Captcha::ttf
([
    FILES_DIR.'captcha/fonts/font1.ttf',
    FILES_DIR.'captcha/fonts/font2.ttf',
    FILES_DIR.'captcha/fonts/font3.ttf'
])
->create(true);

 

 

# GetCode ( ZN >= 0.0.9 )


Gives the textual proof of the resulting visual after the last security code has been refreshed.

Parameters

void
return this

Examples

echo Captcha::getCode();
b0900124