stuppid_bot

Untitled

May 3rd, 2013
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. session_start();
  5. $size = 32;
  6. $half_size = $size / 2;
  7. $font_file = 'OptimusPrincepsSemiBold.ttf';
  8. $_SESSION['captcha'] = $text = substr( md5( microtime() ), 0, 4 );
  9. list(,,$width) = imagettfbbox($size, 0, $font_file, $text);
  10. $im = imagecreate($width += $size, $height = $size * 2);
  11. $bg = array( rand(170, 255), rand(170, 255), rand(170, 255) );
  12. imagecolorallocate($im, $bg[0], $bg[1], $bg[2]);
  13. $fc = array( rand(0, 85), rand(0, 85), rand(0, 85) );
  14. $font_color = imagecolorallocate( $im, $fc[0], $fc[1], $fc[2] );
  15. imagettftext($im, $size, 0, + $half_size, $size + $half_size, $font_color, $font_file, $text);
  16.  
  17. $width1 = 200;
  18. $height1 = 80;
  19. $offset_x = ($width1 - $width) / 2;
  20. $offset_y = ($height1 - $height) / 2;
  21. $rand1 = rand($half_size, $size) / 1000;
  22. $rand2 = rand(0, $width / 2);
  23.  
  24. // так эта ебланская библиотека нихуя не рисует
  25. // $im1 = imagecreate($width1, $height1);
  26. // imagecolorallocate($im1, 255, 255, 255);
  27. $im1 = imagecreatetruecolor($width1, $height1);
  28. imagefilledrectangle( $im1, 0, 0, $width1, $height1, imagecolorallocate($im1, $bg[0], $bg[1], $bg[2]) );
  29.  
  30. for ($y = 0; $y < $height; ++$y) {
  31.     for ($x = 0; $x < $width; ++$x) {
  32.         $colors = imagecolorsforindex( $im, imagecolorat($im, $x, $y) );
  33.         $color = imagecolorallocate( $im1, $colors['red'], $colors['green'], $colors['blue']);    
  34.         $z = $y + floor( $half_size * sin($rand1 * $x + $rand2) );
  35.         imagesetpixel($im1, $offset_x + $x, $offset_y + $z, $color);      
  36.     }
  37. }
  38.  
  39. $line_color = imagecolorallocate( $im1, $fc[0], $fc[1], $fc[2] );
  40. // линии
  41. for ($i = 0, $c = rand(3, 5); $i < $c; ++$i) {
  42.     imageline( $im1, rand(0, $width1 - 1), rand(0, $height1 - 1), rand(0, $width1 - 1), rand(0, $height1 - 1), $line_color );
  43. }
  44.  
  45. imagefilter($im1, IMG_FILTER_GAUSSIAN_BLUR);
  46. header('Cache-Control: no-cache, must-revalidate');
  47. header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
  48. header('Content-type: image/png');
  49. imagepng($im1);
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment