<?php
$string_length = 4; //NUMBER OF CHARS TO DISPLAY
$large_letters = array('m','w');
$rand_string = '';
for ($i=0; $i<$string_length; $i++) {
//PICK A RANDOM LOWERCASE LETTER USING ASCII CODE
}
//IMAGE VARIABLES
//$width = 100;
//$height = 36;
$width = 60;
$height = 25;
//INIT IMAGE
//ALLOCATE COLORS
//FILL BACKGROUND
//ADD NOISE - DRAW background squares
$square_count = 6;
for ($i = 0; $i < 10; $i++) {
$cx = (int
)rand(0, $width/2);
$cy = (int
)rand(0, $height);
$h = $cy + (int
)rand(0, $height/5);
$w = $cx + (int
)rand($width/3, $width);
}
//ADD NOISE - DRAW ELLIPSES
$ellipse_count = 5;
for ($i = 0; $i < $ellipse_count; $i++) {
$cx = (int
)rand(-1*($width/2), $width + ($width/2));
$cy = (int
)rand(-1*($height/2), $height + ($height/2));
$h = (int
)rand($height/2, 2*$height);
$w = (int
)rand($width/2, 2*$width);
}
//REPLACE THIS WITH THE FONT YOU UPLOAD
$font = '../tiff/DejaVuSerifCondensed-Italic.ttf';
//$font = 'monofont.ttf';
$font_size = 16;
//CALC APPROX LOCATION - CUSTOMIZED FOR ABOVE FONT
$y_value = ($height/2) + ($font_size/2);
$x_value = 0;
//DRAW STRING USING TRUE TYPE FUNCTION
for ($i = 0; $i < $string_length; $i++) {
$chr = substr($rand_string, $i, 1);
$x_value += 3 * ($font_size/5);
imagettftext($img, $font_size, 0, $x_value, $y_value, $black, $font, $chr);
//check to see if larger than normal letters, if so add more horiz space
$x_value += 4;
}
}
$auth_type = isset($_REQUEST['type'])?
$_REQUEST['type']:'';
if($auth_type=="login")
{
$_SESSION['authcode_login']=$rand_string;
}
else
{
//$_SESSION['encoded_captcha'] = md5($rand_string . 'my_secret_key');
$_SESSION['authcode']=$rand_string;
}
//OUTPUT IMAGE HEADER AND SEND TO BROWSER
header("Content-Type: image/png");
?>