Просмотр файла img.php

Размер файла: 1.37Kb
<?
/**********************************
*	@year: 2015				      *
*	@author: Klubv	              *
*   @icq: 611940693			      *
*	@link: http://klubv.ru        *
**********************************/
session_name('PHP');
session_start();
$out = (string) $_SESSION['codes'];
$im = imagecreate (80, 30) or die ("Cannot initialize new GD image stream!");
$bg = imagecolorallocate ($im, 232, 238, 247);

//выводим символы кода
for ($i = 0; $i < strlen($out); $i++) {
$color = imagecolorallocate ($im, rand(0,255), rand(0,128), rand(0,255)); //задаём цвет
$x = 5 + $i * 20;
$y = rand(1, 10);
imagechar ($im, 6, $x, $y, $out[$i], $color);
}

//создаём шум на фоне
for ($i=0; $i<210; $i++) {
$color = imagecolorallocate ($im, rand(0,255), rand(0,255), rand(0,255)); //задаём цвет
imagesetpixel($im, rand(2,80), rand(2,30), $color); //рисуем пиксель
}

//создание рисунка в зависимости от доступного формата
if (function_exists("imagepng")) {
header("Content-type: image/png");
imagepng($im);
} elseif (function_exists("imagegif")) {
header("Content-type: image/gif");
imagegif($im);
} elseif (function_exists("imagejpeg")) {
header("Content-type: image/jpeg");
imagejpeg($im);
} else {
die("No image support in this PHP server!");
}
imagedestroy ($im);
?>