File: /var/www/likoholding/old.liko-holding.com.ua/modules/auth/antispamimg.php
<?
//$path = pathinfo(__FILE__);
//$pathtodir = $path['dirname'];
//echo $pathtodir;
$arr_letter=array('1','2','3','4','5','6','7','8','9','0');
$handle = opendir('modules/auth/tmp');
while (false !== ($file = readdir($handle)))
{
if ($file!='..' && $file!='.')
unlink('modules/auth/tmp/'.$file);
}
closedir($handle);
unset($_SESSION['aspam']);
for ($i_zn = 0; $i_zn < 5; $i_zn++)
{
$_SESSION['aspam']['leters'][] = $arr_letter[rand(0,count($arr_letter)-1)];
}
$_SESSION['aspam']['code'] = implode("", $_SESSION['aspam']['leters']);
$im = imagecreate(90, 30);
$bg = imagecolorallocate($im, 0xAA,0xAA,0xAA);
$tc = imagecolorallocate($im, 0xFF,0xFF,0xAA);
$pixcolor = imagecolorallocate($im, 180,160,200);
$arr_x = array(3,19,35,51,68);
for($i = 1; $i < 150; $i++)
imagesetpixel($im, Rand(1,90), Rand(1, 30), $tc);
for ($i_zn = 0; $i_zn < count($_SESSION['aspam']['leters']); $i_zn++)
{
$i_rands = $_SESSION['aspam']['leters'][$i_zn];
imagettftext($im, 15, rand(-15,15), $arr_x[$i_zn], rand(15,25), $tc, $_SERVER['DOCUMENT_ROOT'].'/modules/auth/fonts/cambriab.ttf', $i_rands);
}
imagejpeg($im, $_SERVER['DOCUMENT_ROOT'].'/modules/auth/tmp/'.md5($_SESSION['aspam']['code']));
imagedestroy($im);
print ("<img src='/modules/auth/tmp/".md5($_SESSION['aspam']['code'])."' width='90' height='30' style='position:relative; top:-5px;'>");
?>