This commit is contained in:
2024-03-25 23:13:12 +05:00
parent ba933a0712
commit 975d9ee310
16 changed files with 4710 additions and 0 deletions

View File

@ -0,0 +1,68 @@
<?php
@session_start(['cookie_lifetime' => 43200,'cookie_secure' => true,'cookie_httponly' => true]);
//if(isset($_SESSION['REMOTE_ADDR']) && $_SESSION['REMOTE_ADDR'] != $_SERVER['REMOTE_ADDR']) unset($_SESSION["USER_ID"]); //Делаемся не авторизованным если зашли с другого ip адреса
if (isset($_REQUEST['id'])) $id = $_REQUEST['id']; else $id = '';
$width = 115; //Ширина изображения
$height = 40; //Высота изображения
$font_size = 14; //Размер шрифта
$let_amount = 5; //Количество символов, которые нужно набрать
$fon_let_amount = 40; //Количество символов, которые находятся на фоне
$path_fonts = getcwd().'/fonts/'; //Путь к шрифтам
//$letters = array('a','b','c','d','e','f','g','h','j','k','m','n','p','q','r','s','t','u','v','w','x','y','z','2','3','4','5','6','7','9');
$letters = array('0','1','2','3','4','5','6','7','8','9');
//$colors = array('100','200','150','170','190','210','190','160','170','190','210'); //для тёмного стиля
$colors = array('50','100','75','85','95','105','90','80','85','95','105'); //Для светлого стиля
$src = imagecreatetruecolor($width,$height);
//$fon = imagecolorallocate($src,58,58,58); //Для тёмного стиля
$fon = imagecolorallocate($src,241,241,241); //Для светлого стиля
imagefill($src,0,0,$fon);
$fonts = array();
$dir=opendir($path_fonts);
while($fontName = readdir($dir))
{
if($fontName != "." && $fontName != ".." && pathinfo($fontName, PATHINFO_EXTENSION)=='ttf')
{
$fonts[] = $fontName;
}
}
closedir($dir);
for($i=0;$i<$fon_let_amount;$i++)
{
$color = imagecolorallocatealpha($src,rand(0,255),rand(0,255),rand(0,255),100);
$font = $path_fonts.$fonts[rand(0,sizeof($fonts)-1)];
$letter = $letters[rand(0,sizeof($letters)-1)];
$size = rand($font_size-2,$font_size+2);
imagettftext(
$src,
$size,
rand(0,45),
rand((int)($width*0.1),(int)($width-$width*0.1)),
rand((int)($height*0.2),$height),
$color,
$font,
$letter
);
}
for($i=0;$i<$let_amount;$i++)
{
$color = imagecolorallocatealpha($src,$colors[rand(0,sizeof($colors)-1)],$colors[rand(0,sizeof($colors)-1)],$colors[rand(0,sizeof($colors)-1)],rand(20,40));
$font = $path_fonts.$fonts[rand(0,sizeof($fonts)-1)];
$letter = $letters[rand(0,sizeof($letters)-1)];
$size = rand((int)($font_size*2.1-2),(int)($font_size*2.1+2));
$x = (int)(($i+0.9)*$font_size + rand(4,7));
$y = (int)((($height*2.3)/3) + rand(0,5));
$cod[] = $letter;
imagettftext($src,$size,rand(0,15),$x,$y,$color,$font,$letter);
}
$_SESSION['secpic'.$id] = implode('',$cod);
header ("Content-type: image/gif");
imagegif($src);