This repository was archived by the owner on Feb 8, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathcaptcha.php
More file actions
58 lines (42 loc) · 2.44 KB
/
Copy pathcaptcha.php
File metadata and controls
58 lines (42 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/*
Appointment: АнтиБОТ
File: antibot.php
*/
session_start();
$width = 120; //Ширина изображения
$height = 50; //Высота изображения
$font_size = 16; //Размер шрифта
$let_amount = 5; //Количество символов, которые нужно набрать
$fon_let_amount = 30; //Количество символов на фоне
$font = dirname(__FILE__) . "/content/fc.ttf"; //Путь к шрифту
//набор символов
$letters = array('8', '1', '3', '5', '7', '9', '6', '4', '2');
//Цвета для фона
$background_color = array(mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255));
//Цвета для обводки
$foreground_color = array(mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
$src = imagecreatetruecolor($width, $height); //создаем изображение
$fon = imagecolorallocate($src, $background_color[0], $background_color[1], $background_color[2]); //создаем фон
imagefill($src, 0, 0, $fon); //заливаем изображение фоном
//то же самое для основных букв
for ($i=0; $i < $let_amount; $i++) {
$color = imagecolorallocatealpha($src, $foreground_color[0], $foreground_color[1], $foreground_color[2], rand(20, 40)); //Цвет шрифта
$letter = $letters[rand(0, sizeof($letters)-1)];
$size = rand($font_size*2-2, $font_size*2+2);
$x = ($i+1)*$font_size + rand(7, 9); //даем каждому символу случайное смещение
$y = (($height*2)/3) + rand(0, 5);
$cod[] = $letter; //запоминаем код
imagettftext($src, $size, rand(0, 15), $x, $y, $color, $font, $letter);
imageline($src, rand(0, 20), rand(1, 50), rand(150, 180), rand(1, 50), $color);
imageline($src, rand(0, 20), rand(1, 50), rand(100, 200), rand(1, 50), $color);
}
$foreground = imagecolorallocate($src, $foreground_color[0], $foreground_color[1], $foreground_color[2]);
imageline($src, 0, 0, $width, 0, $foreground);
imageline($src, 0, 0, 0, $height, $foreground);
imageline($src, 0, $height-1, $width, $height-1, $foreground);
imageline($src, $width-1, 0, $width-1, $height, $foreground);
$cod = implode("", $cod); //переводим код в строку
header("Content-type: image/gif"); //выводим готовую картинку
imagegif($src);
$_SESSION['sec_code'] = $cod; //Добавляем код в сессию