|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/pathumthani_eoffice/application/mxblog/capcha/ |
Upload File : |
<?php
header("Content-type: image/png");
session_start();
function generateCode($characters) {
/* list all possible characters, similar looking characters and vowels have been removed */
$possible = '23456789bcdfghjkmnpqrstvwxyz';
$code = '';
$i = 0;
while ($i < $characters) {
$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$i++;
}
return $code;
}
$code = generateCode($_GET[characters]);
$im = imagecreate($_GET[width], $_GET[height]);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
$new_string = $code;
imagefill($im, 0, 0, $black);
imagestring($im, 4, 25, 3, $new_string, $white);
$_SESSION["security_code"]=$new_string;
imagepng($im);
imagedestroy($im);
?>