Advertisement
hasib_mo

I Love You, PUE

Dec 11th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2. ini_set("display_errors", "1");
  3. error_reporting(E_ALL);
  4.  
  5. //Set the content type
  6. header('content-type: image/png');
  7.  
  8. //Create our basic image stream 300x300 pixels
  9.  
  10. $image = imagecreate(440,100);
  11. $back=imagecolorallocate($image,240,240,240);
  12. $color=imagecolorallocate($image,rand(0,200),rand(0,200),rand(0,200));
  13.  
  14. $font_list=array('advent_light.ttf','BRADHITC.TTF','HARNGTON.TTF', 'JOKERMAN.TTF', 'RosewoodStd-Regular.otf', 'ITCEDSCR.TTF');
  15. $font=$font_list[rand(0,count($font_list)-1)];
  16.  
  17.  
  18.  
  19.  
  20.  
  21. if($_SERVER['HTTP_HOST']!='127.0.0.1')
  22. {
  23.     $fontpath = realpath('./font/');
  24.     putenv('GDFONTPATH='.$fontpath);
  25.  
  26. }
  27.  
  28.  
  29.  
  30.  
  31. $captcha='I LOVE YOU PUE';
  32.  
  33.  
  34.  
  35. for($i=0; $i<count($captcha); $i++)
  36. {
  37.     if(rand(0,1000000) %2 == 0)
  38.     {
  39.         $captcha[$i] = strtolower($captcha[$i]);
  40.     }
  41. }
  42.  
  43.  
  44.  
  45. $str_pos=imagettfbbox(30,0,$font,$captcha);
  46. $x=(400-$str_pos[2])/2;
  47.  
  48.  
  49. $y=75;
  50. $i=strlen($captcha);
  51. $len_minus=$i-1;
  52. while($i--)
  53. {
  54.     $ch=$captcha[$len_minus-$i];
  55.     imagettftext($image,30,(rand(0,100)>50?1:-1)*rand(0,25),$x,$y,imagecolorallocate($image,rand(0,200),rand(0,200),rand(0,200)),$font_list[rand(0,count($font_list)-1)],$ch);
  56.    
  57.     $x=$x+25;
  58.  
  59.    
  60.    
  61.    
  62. }
  63. imagepng($image);
  64.  
  65. imagedestroy($image);
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement