first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

61
web/captcha.php Normal file
View File

@@ -0,0 +1,61 @@
<?php
if (empty($_GET['id'])) {
exit;
}
$charHeight = 20;
$font = 5;
$lines = 2;
$dots = 200;
if (!empty($cfg['captcha']['difficulty'])) {
$lines *= $cfg['captcha']['difficulty'];
$dots *= $cfg['captcha']['difficulty'];
}
if (!empty($cfg['captcha']['size'])) {
$charHeight = intval($cfg['captcha']['size']);
$font = $charHeight / 2.5;
}
$charWidth = $charHeight;
$code = $_GET['id'];
$hash = generateCaptcha($code);
$length = strlen($hash);
header('Content-type: image/png');
$width = $length * $charWidth;
$height = $charHeight;
$image = imagecreate($width, $charHeight);
$colorBg = imagecolorallocate($image, 255, 255, 255);
// Text
foreach (str_split($hash) as $index => $char) {
$color = imagecolorallocate($image, rand(0, 30), rand(10, 20), rand(0, 255));
if ($font > 5) {
imagettftext($image, $font, rand(-30, 30), ($index + 0.2) * $charWidth + rand(-4, 5), $charHeight * 0.7 + rand(-6, 2), $color, realpath('./static/fonts/arialbd.ttf'), $char);
} else {
imagechar($image, $font, ($index + 0.2) * $charWidth + rand(-4, 5), $charHeight * 0.2 + rand(-6, 2), $char, $color);
}
}
// Lines
$line_color = imagecolorallocate($image, 0, 200 + rand() % 50, 0);
for ($i = 0; $i < $lines; $i++) {
imageline($image, rand() % $width / 2, rand() % $height, rand() % $width / 2 + $width / 2, rand() % $height, $line_color);
}
// Dots
$pixel_color = imagecolorallocate($image, 255, 0, 0);
for ($i = 0; $i < $dots; $i++) {
imagesetpixel($image, rand() % $width, rand() % $height, $pixel_color);
}
imagepng($image);
imagedestroy($image);