v3.0.0.2
FlatlyPage
- <?php
- require_once __DIR__ . '/config.php';
-
- if (session_status() === PHP_SESSION_NONE) {
- session_start();
- }
-
- function antibot_generate_text($length = 6) {
- $chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
- $text = '';
- for ($i = 0; $i < $length; $i++) {
- $text .= $chars[random_int(0, strlen($chars) - 1)];
- }
- return $text;
- }
-
- function antibot_render_svg($text) {
- $width = 200;
- $height = 70;
- $len = strlen($text);
-
- $svg = '<svg xmlns="http://www.w3.org/2000/svg" width="' . $width . '" height="' . $height . '" viewBox="0 0 ' . $width . ' ' . $height . '">';
-
- $svg .= '<defs>';
- $svg .= '<filter id="n">';
- $svg .= '<feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/>';
- $svg .= '<feColorMatrix type="saturate" values="0"/>';
- $svg .= '<feBlend in="SourceGraphic" mode="multiply" result="blend"/>';
- $svg .= '<feComposite in="blend" in2="SourceGraphic" operator="in"/>';
- $svg .= '</filter>';
- $svg .= '</defs>';
-
- $bg_colors = ['#f0f4ff', '#fff4f0', '#f0fff4', '#fdfdf0', '#f4f0ff'];
- $bg = $bg_colors[array_rand($bg_colors)];
- $svg .= '<rect width="' . $width . '" height="' . $height . '" fill="' . $bg . '" rx="6"/>';
-
- $svg .= '<filter id="wave">';
- $svg .= '<feTurbulence type="turbulence" baseFrequency="0.02 0.05" numOctaves="2" result="turb"/>';
- $svg .= '<feDisplacementMap in="SourceGraphic" in2="turb" scale="4" xChannelSelector="R" yChannelSelector="G"/>';
- $svg .= '</filter>';
-
- $line_colors = ['#c0c8e0', '#e0c0c0', '#c0e0c0', '#d0d0c0', '#d0c0e0'];
- for ($i = 0; $i < 6; $i++) {
- $x1 = random_int(0, $width);
- $y1 = random_int(0, $height);
- $x2 = random_int(0, $width);
- $y2 = random_int(0, $height);
- $color = $line_colors[array_rand($line_colors)];
- $stroke_w = round(random_int(10, 20) / 10, 1);
- $svg .= '<line x1="' . $x1 . '" y1="' . $y1 . '" x2="' . $x2 . '" y2="' . $y2 . '" stroke="' . $color . '" stroke-width="' . $stroke_w . '" opacity="0.7"/>';
- }
-
- for ($i = 0; $i < 40; $i++) {
- $cx = random_int(0, $width);
- $cy = random_int(0, $height);
- $r = random_int(1, 3);
- $dot_colors = ['#9090b0', '#b09090', '#90b090'];
- $c = $dot_colors[array_rand($dot_colors)];
- $svg .= '<circle cx="' . $cx . '" cy="' . $cy . '" r="' . $r . '" fill="' . $c . '" opacity="0.5"/>';
- }
-
- $char_colors = [
- '#1a3a8f', '#8f1a1a', '#1a6e1a', '#6e1a6e',
- '#1a5a6e', '#8f4a00', '#2a2a8f', '#6e1a3a',
- ];
-
- $slot_w = ($width - 20) / $len;
-
- for ($i = 0; $i < $len; $i++) {
- $char = $text[$i];
-
- $x = 10 + $slot_w * $i + $slot_w / 2;
- $y = random_int(38, 50);
-
- $rotate = random_int(-18, 18);
- $scale_x = round(random_int(85, 115) / 100, 2);
- $scale_y = round(random_int(90, 110) / 100, 2);
- $font_sz = random_int(26, 34);
-
- $color = $char_colors[array_rand($char_colors)];
-
- $svg .= '<text'
- . ' x="' . round($x, 1) . '"'
- . ' y="' . $y . '"'
- . ' font-size="' . $font_sz . '"'
- . ' font-family="Georgia, serif"'
- . ' font-weight="bold"'
- . ' fill="' . $color . '"'
- . ' text-anchor="middle"'
- . ' transform="rotate(' . $rotate . ' ' . round($x, 1) . ' ' . $y . ') scale(' . $scale_x . ' ' . $scale_y . ')"'
- . ' filter="url(#wave)"'
- . '>' . htmlspecialchars($char, ENT_XML1) . '</text>';
- }
-
- $svg .= '<rect width="' . $width . '" height="' . $height . '" fill="url(#n)" opacity="0.08" rx="6"/>';
-
- $svg .= '</svg>';
- return $svg;
- }
-
- $text = antibot_generate_text(6);
- $_SESSION['antibot_answer'] = strtoupper($text);
- $_SESSION['antibot_time'] = time();
-
- header('Content-Type: image/svg+xml');
- header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
- header('Pragma: no-cache');
- header('Expires: Sat, 01 Jan 2000 00:00:00 GMT');
-
- echo antibot_render_svg($text);
-