<?php
@error_reporting(0);
@ini_set('display_errors',0);
@session_start();
$width=55;
$height=20;
$im=imagecreate($width,$height);
$bg=imagecolorallocate($im,0,0,0);
$len=5;
$chars='0123456789';
$string='';
for($i=0;$i<$len;$i++)
{
$pos=rand(0,mb_strlen($chars)-1);
$string.=$chars{$pos};
}
$_SESSION['imagine_secur']=md5($string);
$grid_color=imagecolorallocate($im,175,0,0);
$number_to_loop=ceil($width/20);
for($i=0;$i<$number_to_loop;$i++)
{
$x=($i+1)*20;
imageline($im,$x,0,$x,$height,$grid_color);
}
$number_to_loop=ceil($height/10);
for($i=0;$i<$number_to_loop;$i++)
{
$y=($i+1)*10;
imageline($im,0,$y,$width,$y,$grid_color);
}
$line_color=imagecolorallocate($im,130,0,0);
for($i=0;$i<30;$i++)
{
$rand_x_1=rand(0,$width-1);
$rand_x_2=rand(0,$width-1);
$rand_y_1=rand(0,$height-1);
$rand_y_2=rand(0,$height-1);
imageline($im,$rand_x_1,$rand_y_1,$rand_x_2,$rand_y_2,$line_color);
}
$text_color=imagecolorallocate($im,255,255,255);
$rand_x=rand(0,$width-50);
$rand_y=rand(0,$height-15);
imagestring($im,10,$rand_x,$rand_y,$string,$text_color);
header('Content-type: image/png');
header('Last-Modified: '.gmdate('D, d M Y H:i:s T'));
header('Cache-Control: no-store,no-cache,must-revalidate,max-age=0,post-check=0,pre-check=0');
header('Expires: -1');
imagepng($im);
imagedestroy($im);
exit;