Guest User

Untitled

a guest
Jul 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. $width = 120;
  5. $height = 40;
  6. $length = 5;
  7.  
  8. $baseList = '0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  9.  
  10. $code = "";
  11. $counter = 0;
  12.  
  13. $image = @imagecreate($width, $height) or die('Cannot initialize GD!');
  14.  
  15. for( $i=0; $i<10; $i++ ) {
  16. imageline($image,
  17. mt_rand(0,$width), mt_rand(0,$height),
  18. mt_rand(0,$width), mt_rand(0,$height),
  19. imagecolorallocate($image, mt_rand(150,255),
  20. mt_rand(150,255),
  21. mt_rand(150,255)));
  22. }
  23.  
  24. for( $i=0, $x=0; $i<$length; $i++ ) {
  25. $actChar = substr($baseList, rand(0, strlen($baseList)-1), 1);
  26. $x += 10 + mt_rand(0,10);
  27. imagechar($image, mt_rand(3,5), $x, mt_rand(5,20), $actChar,
  28. imagecolorallocate($image, mt_rand(0,155), mt_rand(0,155), mt_rand(0,155)));
  29. $code .= strtolower($actChar);
  30. }
  31.  
  32. header('Content-Type: image/jpeg');
  33. imagejpeg($image);
  34. imagedestroy($image);
  35.  
  36. $_SESSION['securityCode'] = $code;
  37.  
  38. ?>
Add Comment
Please, Sign In to add comment