WebOrbiton
v1.0.3

PriviMetrics 2

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