AntiBK/engline/secpic.php
Ivor Barhansky 36bf662112 code-upload (#1)
Upload code

Изменил(а) на 'README.md'

Изменил(а) на 'README.md'

Reviewed-on: https://src.lopar.us/lopar/AntiBK/pulls/1
Co-Authored-By: Ivor Barhansky <lopar@noreply.lopar.us>
Co-Committed-By: Ivor Barhansky <lopar@noreply.lopar.us>
2021-02-11 16:13:04 +00:00

53 lines
1.8 KiB
PHP

<?
session_start();
$width = 157; //Øèðèíà èçîáðàæåíèÿ
$height = 49; //Âûñîòà èçîáðàæåíèÿ
$font_size = 13; //Ðàçìåð øðèôòà
$let_amount = 6; //Êîëè÷åñòâî ñèìâîëîâ, êîòîðûå íóæíî íàáðàòü
$fon_let_amount = 30; //Êîëè÷åñòâî ñèìâîëîâ, êîòîðûå íàõîäÿòñÿ íà ôîíå
$path_fonts = '../fonts/'; //Ïóòü ê øðèôòàì
$letters = array('0','1','2','3','4','5','6','7','9');
$colors = array('0');
$src = imagecreatetruecolor($width, $height);
$fon = imagecolorallocate($src, 200, 200, 200);
imagefill($src, 0, 0, $fon);
$fonts = array();
$dir = opendir($path_fonts);
while($fontName = readdir($dir))
{
if($fontName != "." && $fontName != "..")
$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($width*0.1,$width-$width*0.1), rand($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(0,50));
$font = $path_fonts.$fonts[rand(0,sizeof($fonts)-1)];
$letter = $letters[rand(0,sizeof($letters)-1)];
$size = rand($font_size*2.1-2, $font_size*2.1+2);
$x = ($i == 0) ?$font_size + rand(5,10) :$x + $font_size + rand(-5,10);
$y = (($height*2)/3) + rand(-5,15);
$cod[] = $letter;
imagettftext($src, $size, rand(0,15), $x, $y, $color, $font, $letter);
}
$_SESSION['secpic'] = implode('', $cod);
header("Content-type: image/gif");
imagegif($src);
?>