upload
This commit is contained in:
commit
a54152fcc0
18 changed files with 658 additions and 0 deletions
52
captcha.php
Executable file
52
captcha.php
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
session_start();
|
||||
/*
|
||||
A very primitive captcha implementation
|
||||
*/
|
||||
|
||||
/* Create Imagick object */
|
||||
$Imagick = new Imagick();
|
||||
|
||||
/* Create the ImagickPixel object (used to set the background color on image) */
|
||||
$bg = new ImagickPixel();
|
||||
|
||||
/* Set the pixel color to white */
|
||||
$bg->setColor( 'white');
|
||||
|
||||
/* Create a drawing object and set the font size */
|
||||
$ImagickDraw = new ImagickDraw();
|
||||
|
||||
/* Set font and font size. You can also specify /path/to/font.ttf */
|
||||
$ImagickDraw->setFont( 'captchafont.ttf' );
|
||||
$ImagickDraw->setFontSize( 25 );
|
||||
|
||||
/* Create the text */
|
||||
$alphanum = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz';
|
||||
$string = substr( str_shuffle( $alphanum ), 2, 5 );
|
||||
$_SESSION['captcha_code'] = $string;
|
||||
/* Create new empty image */
|
||||
$Imagick->newImage( 80, 25, $bg );
|
||||
|
||||
/* Write the text on the image */
|
||||
$Imagick->annotateImage( $ImagickDraw, 4, 20, 0, $string );
|
||||
|
||||
/* Add some swirl */
|
||||
$Imagick->swirlImage( rand(10,20) );
|
||||
|
||||
/* Create a few random lines */
|
||||
/*
|
||||
$ImagickDraw->line( rand( 0, 70 ), rand( 0, 30 ), rand( 0, 70 ), rand( 0, 30 ) );
|
||||
$ImagickDraw->line( rand( 0, 70 ), rand( 0, 30 ), rand( 0, 70 ), rand( 0, 30 ) );
|
||||
$ImagickDraw->line( rand( 0, 70 ), rand( 0, 30 ), rand( 0, 70 ), rand( 0, 30 ) );
|
||||
$ImagickDraw->line( rand( 0, 70 ), rand( 0, 30 ), rand( 0, 70 ), rand( 0, 30 ) );
|
||||
$ImagickDraw->line( rand( 0, 70 ), rand( 0, 30 ), rand( 0, 70 ), rand( 0, 30 ) );
|
||||
*/
|
||||
/* Draw the ImagickDraw object contents to the image. */
|
||||
$Imagick->drawImage( $ImagickDraw );
|
||||
|
||||
/* Give the image a format */
|
||||
$Imagick->setImageFormat( 'jpg' );
|
||||
/* Send headers and output the image */
|
||||
header( "Content-Type: image/{$Imagick->getImageFormat()}" );
|
||||
echo $Imagick->getImageBlob( );
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue