|
<?php
ob_start();
session_start();
$img = imagecreatetruecolor(100, 30);
$black = imagecolorallocate($img, 0, 0, 0);
$white = imagecolorallocate($img, 255, 255, 255);
$red = imagecolorallocate($img, 255, 0, 0);
$pink = imagecolorallocate($img, 200, 0, 150);
$grey = imagecolorallocate($img, 150, 150, 150);
$blue = imagecolorallocate($img, 51, 167, 198);
function randomString($length) {
$chars = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghjklmnpqrstuvwxyz";
srand((double)microtime()*1000000);
$str = "";
$i = 0;
while($i <= $length) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$str = $str . $tmp;
$i++;
}
return $str;
}
for($i=1; $i <= rand(1, 1000); $i++) {
$color = (rand(1, 2) == 1) ? $grey : $black;
//imageline($img, rand(0, 100), rand(0, 20), rand(0, 100)+5, rand(0, 20)+5, $color);
}
imagefill($img, 0, 0, $blue);
$string = randomString(rand(4, 5));
$_SESSION['string'] = $string;
$font = array("Arial,ttf", "Dungeon,ttf");
imagettftext($img, rand(10, 13), rand(-5, 5), rand(5, 25), rand(16, 22), $white, "Dungeon,ttf", $string);
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
ob_end_flush();
?>
|