here cap.php
<?php
session_start();
$w = 124; // height of the image
$h = 35; // width of the image
$l = 6; // length of security code
$baseList = '0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; // the characters to be used when generating the code
$code = "";
$counter = 0;
$img = @imagecreate($w, $h) or die('Cannot initialize GD!'); // create image
for ($i = 0; $i < 10; $i++)
{
imageline($img, mt_rand(0, $w), mt_rand(0, $h), mt_rand(0, $w), mt_rand(0, $h),
imagecolorallocate($img, mt_rand(150, 255), mt_rand(150, 255), mt_rand(150, 255)));
}
for ($i = 0, $x = 0; $i < $l; $i++)
{
$randChar = substr($baseList, rand(0, strlen($baseList) - 1), 1);
$x += 10 + mt_rand(0, 10);
imagechar($img, mt_rand(3, 5), $x, mt_rand(5, 20), $randChar, imagecolorallocate
($img, mt_rand(0, 155), mt_rand(0, 155), mt_rand(0, 155)));
$code .= strtolower($randChar);
}
header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
$_SESSION['verify'] = $code;
?>
and in core
echo "
success
";
unset($_SESSION['verify']);
$result = true;
}else{
echo "
unsuccess
";
$result = false;
}