WebOrbiton
v3.0.0.0

FlatlyPage

111 lines · 3.9 KB
  1. <?php
  2. require_once __DIR__ . '/config.php';
  3. ​
  4. if (session_status() === PHP_SESSION_NONE) {
  5. session_start();
  6. }
  7. ​
  8. function antibot_generate_text($length = 6) {
  9. $chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
  10. $text = '';
  11. for ($i = 0; $i < $length; $i++) {
  12. $text .= $chars[random_int(0, strlen($chars) - 1)];
  13. }
  14. return $text;
  15. }
  16. ​
  17. function antibot_render_svg($text) {
  18. $width = 200;
  19. $height = 70;
  20. $len = strlen($text);
  21. ​
  22. $svg = '<svg xmlns="http://www.w3.org/2000/svg" width="' . $width . '" height="' . $height . '" viewBox="0 0 ' . $width . ' ' . $height . '">';
  23. ​
  24. $svg .= '<defs>';
  25. $svg .= '<filter id="n">';
  26. $svg .= '<feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/>';
  27. $svg .= '<feColorMatrix type="saturate" values="0"/>';
  28. $svg .= '<feBlend in="SourceGraphic" mode="multiply" result="blend"/>';
  29. $svg .= '<feComposite in="blend" in2="SourceGraphic" operator="in"/>';
  30. $svg .= '</filter>';
  31. $svg .= '</defs>';
  32. ​
  33. $bg_colors = ['#f0f4ff', '#fff4f0', '#f0fff4', '#fdfdf0', '#f4f0ff'];
  34. $bg = $bg_colors[array_rand($bg_colors)];
  35. $svg .= '<rect width="' . $width . '" height="' . $height . '" fill="' . $bg . '" rx="6"/>';
  36. ​
  37. $svg .= '<filter id="wave">';
  38. $svg .= '<feTurbulence type="turbulence" baseFrequency="0.02 0.05" numOctaves="2" result="turb"/>';
  39. $svg .= '<feDisplacementMap in="SourceGraphic" in2="turb" scale="4" xChannelSelector="R" yChannelSelector="G"/>';
  40. $svg .= '</filter>';
  41. ​
  42. $line_colors = ['#c0c8e0', '#e0c0c0', '#c0e0c0', '#d0d0c0', '#d0c0e0'];
  43. for ($i = 0; $i < 6; $i++) {
  44. $x1 = random_int(0, $width);
  45. $y1 = random_int(0, $height);
  46. $x2 = random_int(0, $width);
  47. $y2 = random_int(0, $height);
  48. $color = $line_colors[array_rand($line_colors)];
  49. $stroke_w = round(random_int(10, 20) / 10, 1);
  50. $svg .= '<line x1="' . $x1 . '" y1="' . $y1 . '" x2="' . $x2 . '" y2="' . $y2 . '" stroke="' . $color . '" stroke-width="' . $stroke_w . '" opacity="0.7"/>';
  51. }
  52. ​
  53. for ($i = 0; $i < 40; $i++) {
  54. $cx = random_int(0, $width);
  55. $cy = random_int(0, $height);
  56. $r = random_int(1, 3);
  57. $dot_colors = ['#9090b0', '#b09090', '#90b090'];
  58. $c = $dot_colors[array_rand($dot_colors)];
  59. $svg .= '<circle cx="' . $cx . '" cy="' . $cy . '" r="' . $r . '" fill="' . $c . '" opacity="0.5"/>';
  60. }
  61. ​
  62. $char_colors = [
  63. '#1a3a8f', '#8f1a1a', '#1a6e1a', '#6e1a6e',
  64. '#1a5a6e', '#8f4a00', '#2a2a8f', '#6e1a3a',
  65. ];
  66. ​
  67. $slot_w = ($width - 20) / $len;
  68. ​
  69. for ($i = 0; $i < $len; $i++) {
  70. $char = $text[$i];
  71. ​
  72. $x = 10 + $slot_w * $i + $slot_w / 2;
  73. $y = random_int(38, 50);
  74. ​
  75. $rotate = random_int(-18, 18);
  76. $scale_x = round(random_int(85, 115) / 100, 2);
  77. $scale_y = round(random_int(90, 110) / 100, 2);
  78. $font_sz = random_int(26, 34);
  79. ​
  80. $color = $char_colors[array_rand($char_colors)];
  81. ​
  82. $svg .= '<text'
  83. . ' x="' . round($x, 1) . '"'
  84. . ' y="' . $y . '"'
  85. . ' font-size="' . $font_sz . '"'
  86. . ' font-family="Georgia, serif"'
  87. . ' font-weight="bold"'
  88. . ' fill="' . $color . '"'
  89. . ' text-anchor="middle"'
  90. . ' transform="rotate(' . $rotate . ' ' . round($x, 1) . ' ' . $y . ') scale(' . $scale_x . ' ' . $scale_y . ')"'
  91. . ' filter="url(#wave)"'
  92. . '>' . htmlspecialchars($char, ENT_XML1) . '</text>';
  93. }
  94. ​
  95. $svg .= '<rect width="' . $width . '" height="' . $height . '" fill="url(#n)" opacity="0.08" rx="6"/>';
  96. ​
  97. $svg .= '</svg>';
  98. return $svg;
  99. }
  100. ​
  101. $text = antibot_generate_text(6);
  102. $_SESSION['antibot_answer'] = strtoupper($text);
  103. $_SESSION['antibot_time'] = time();
  104. ​
  105. header('Content-Type: image/svg+xml');
  106. header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
  107. header('Pragma: no-cache');
  108. header('Expires: Sat, 01 Jan 2000 00:00:00 GMT');
  109. ​
  110. echo antibot_render_svg($text);
  111. ​