View file www/verifyimage.php

File size: 1.03Kb
<?php

ob_start();

$img = ImageCreate(48, 22);

$black = ImageColorAllocate($img, 0, 0, 0);
ImageFill($img, 0, 0, $brown);

srand((double)microtime()*1000000); 

for($i = 0; $i < 20; ++$i)
{
	$x = rand(2, 46);
	$y = rand(2, 20);
	$color = ImageColorAllocate($img, rand(0, 200), rand(0, 200), rand(0, 200));
	
	imageline($img, $x, $y, $x + rand(-1, 1), $y + rand(-1, 1), $color);
}

srand((double)microtime()*1000000); 

$string = str_shuffle(md5(rand(0,9999))); 
$verify_string = substr($string, 3, 4);

$index = rand(0, 3);
$verify_string[$index] = strtoupper($verify_string[$index]);

$signs = "@#$%^&";
$signs = str_shuffle($signs);

$index = rand(0, 6);
if($index <= 2)
{
	$verify_string[$index] = $signs[0];
}

$white = ImageColorAllocate($img, rand(200, 255), rand(200, 255), rand(200, 255));
ImageString($img, 5, 6, 3, $verify_string, $white);

imagejpeg($img, '', 80);
ImageDestroy($img); 


session_start();
$_SESSION['VERIFY_IMG_STR'] = $verify_string;

header("Content-type: image/jpeg");

$p = ob_get_contents();
ob_end_clean();
echo $p;

?>