<?php
session_start();
$width = 100;
$height = 40;
$len = 3;
$fontsize = 15;
$keys = "abcdefghijklmnopqrstuvwxyz0123456789";
unset($random_text);
$lchar = 0;
$char = 0;
$max=strlen($keys)-1;
for ($i=0;$i < $len;$i++) {
$random_text .= substr($keys, rand(0, $max), 1);
}
$fontwidth = ImageFontWidth($fontsize) * strlen($random_text);
$fontheight = ImageFontHeight($fontsize);
$im = @imagecreate($width,$height);
$background_colour = imagecolorallocate($im, rand(0,255), rand(0,100), rand(0,100));
$text_colour = imagecolorallocate($im, rand(150,255), rand(150,255), rand(150,255));
imagerectangle($im, 0, 0, $width-1, $height-1, $text_colour);
imagestring($im, $fontsize, rand(3, $width-$fontwidth-3), rand(2, $height-$fontheight-3), $random_text, $text_colour);
header("Content-type: image/png");
imagepng($im,'',80);
imagedestroy($im);
$_SESSION["verify"] = $random_text;
?>
|