Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <?
  2. session_start();
  3. $pool = '0123456789';
  4. $img_width = 80;
  5. $img_height = 30;
  6. $str = '';
  7. for ($i = 0; $i < 4; $i++){
  8. $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
  9. }
  10. $string = $str;
  11. $im = imagecreate($img_width, $img_height);
  12. $bg_color = imagecolorallocate($im,103,103,103);
  13. $font_color = imagecolorallocate($im,252,252,252);
  14. $grid_color = imagecolorallocate($im,31,0,0);
  15. $border_color = imagecolorallocate ($im, 174, 174, 174);
  16. imagefill($im,1,1,$bg_color);
  17. for($i=0; $i<500; $i++){
  18.  
  19. $rand1 = rand(0,$img_width);
  20. $rand2 = rand(0,$img_height);
  21. imageline($im, $rand1, $rand2, $rand1, $rand2, $grid_color);
  22.  
  23. }
  24. $x = rand(5, $img_width/(7/2));
  25. imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color);
  26. for($a=0; $a < 4; $a++){
  27.  
  28. imagestring($im, 5, $x, rand(6 , $img_height/5), substr($string, $a, 1), $font_color);
  29. $x += (5*2); #odstęp
  30. }
  31. $_SESSION['string'] = $string;
  32. header("Content-type: image/gif");
  33. imagegif($im);
  34. imagedestroy($im);
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement