KyleMassacre

blah.php

Jan 6th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. <?php
  2. session_start();
  3. define('CAPTCHA_NUMCHARS', 4);
  4.  
  5. $pass_phrase = "";
  6. for($i = 0; $i < CAPTCHA_NUMCHARS; $i++) {
  7.  
  8. $pass_phrase .= chr(rand(97, 122));
  9.  
  10. }
  11. $_SESSION['cap_code'] = $pass_phrase;
  12.  
  13. define('CAPTCHA_WIDTH', 70); define('CAPTCHA_HEIGHT', 20);
  14.  
  15. $img = imagecreatetruecolor(CAPTCHA_WIDTH, CAPTCHA_HEIGHT);
  16. $gc = rand(1, 1);
  17.  
  18. if($gc == '1')
  19. {
  20. //blue bg 30-144-255
  21. //white text 225-225-225
  22. $bg_color = imagecolorallocate($img, 105,105,105);
  23. $text_color = imagecolorallocate($img, 192,192,192);
  24. }
  25.  
  26. if($gc == '2')
  27. {
  28. //green bg 124-252-0
  29. //black text 0-0-0
  30. //red lines 255-0-0
  31. //green dots 124-252-0
  32. $bg_color = imagecolorallocate($img, 124, 252, 0);
  33. $text_color = imagecolorallocate($img, 0, 0, 0);
  34. $graphic_line_color = imagecolorallocate($img, 225, 0, 0);
  35. $graphic_dot_color = imagecolorallocate($img, 124, 252, 0);
  36. }
  37.  
  38. if($gc == '3')
  39. {
  40. //red bg 255-0-0
  41. //blue text 30-144-255
  42. //black lines 0-0-0
  43. //green dots 124-252-0
  44. $bg_color = imagecolorallocate($img, 225, 0, 0);
  45. $text_color = imagecolorallocate($img, 30, 144, 255);
  46. $graphic_line_color = imagecolorallocate($img, 0, 0, 0);
  47. $graphic_dot_color = imagecolorallocate($img, 124, 252, 0);
  48. }
  49.  
  50. if($gc == '4')
  51. {
  52. //yellow bg 255-255-0
  53. //red text 255-0-0
  54. //blue lines 30-144-255
  55. //black dots 0-0-0
  56. $bg_color = imagecolorallocate($img, 225, 225, 0);
  57. $text_color = imagecolorallocate($img, 225, 0, 0);
  58. $graphic_line_color = imagecolorallocate($img, 30, 144, 255);
  59. $graphic_dot_color = imagecolorallocate($img, 0, 0, 0);
  60. }
  61.  
  62. if($gc == '5')
  63. {
  64. //blue bg 30-144-255
  65. //yellow text 255-255-0
  66. //green lines 124-252-0
  67. //red dots 255-0-0
  68. $bg_color = imagecolorallocate($img, 30, 144, 255);
  69. $text_color = imagecolorallocate($img, 225, 225, 0);
  70. $graphic_line_color = imagecolorallocate($img, 124, 252, 0);
  71. $graphic_dot_color = imagecolorallocate($img, 225, 0, 0);
  72. }
  73.  
  74.  
  75. imagefilledrectangle($img, 0, 0, CAPTCHA_WIDTH, CAPTCHA_HEIGHT, $bg_color);
  76.  
  77. for($i = 0; $i < 15; $i++) {
  78.  
  79. imageline($img, 0, rand() % CAPTCHA_HEIGHT, CAPTCHA_WIDTH, rand() % CAPTCHA_HEIGHT, $graphic_line_color);
  80. }
  81.  
  82. for($i = 0; $i < 150; $i++) {
  83.  
  84. imagesetpixel($img, rand() % CAPTCHA_WIDTH, rand() % CAPTCHA_HEIGHT, $graphic_dot__color);
  85. }
  86.  
  87. imagettftext($img, 13, 0, rand(12,22), CAPTCHA_HEIGHT - rand(5, 10), $text_color, 'ariblk.ttf', $pass_phrase);
  88.  
  89. header('Content-type: image/png');
  90. imagepng($img);
  91. destroyimage($img);
  92.  
  93. ?>
Advertisement
Add Comment
Please, Sign In to add comment