web_dor_captcha

The Business Responsive web dor captcha function.

Description

web_dor_captcha(); 

Usage

  1. if ( !function_exists( 'web_dor_captcha' ) ) { 
  2. require_once '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = web_dor_captcha(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/functions.php  
  1. function web_dor_captcha() 
  2. if(isset($_GET['action']) && $_GET['action']=='themewdcaptcha') { 
  3. $cap_width=80; 
  4. $cap_height=30; 
  5. $cap_quality=100; 
  6. $cap_length_min=6; 
  7. $cap_length_max=6; 
  8. $cap_digital=1; 
  9. $cap_latin_char=1; 
  10. function web_dor_code_generic($_length, $_digital=1, $_latin_char=1) 
  11. $dig=array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); 
  12. $lat=array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'o',  
  13. 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); 
  14. $main=array(); 
  15. if ($_digital) $main=array_merge($main, $dig); 
  16. if ($_latin_char) $main=array_merge($main, $lat); 
  17. shuffle($main); 
  18. $pass=substr(implode('', $main), 0, $_length); 
  19. return $pass; 
  20. if(isset($_GET['checkcap'])=='1') { 
  21. if($_GET['checkcap']=='1') 
  22. @session_start(); 
  23. if(isset($_GET['cap_code'])) {  
  24. if($_GET['cap_code']==$_SESSION['web_dor_them_cap_code']) 
  25. echo 1; 
  26. else echo 0; 
  27. }} 
  28. else 
  29. $l=rand($cap_length_min, $cap_length_max); 
  30. $code=web_dor_code_generic($l, $cap_digital, $cap_latin_char); 
  31. @session_start(); 
  32. $_SESSION['web_dor_them_cap_code']= $code; 
  33. $canvas=imagecreatetruecolor($cap_width, $cap_height); 
  34. $c=imagecolorallocate($canvas, rand(150, 255), rand(150, 255), rand(150, 255)); 
  35. imagefilledrectangle($canvas, 0, 0, $cap_width, $cap_height, $c); 
  36. $count=strlen($code); 
  37. $color_text=imagecolorallocate($canvas, 0, 0, 0); 
  38. for($it=0;$it<$count;$it++) 
  39. { $letter=$code[$it]; 
  40. imagestring($canvas, 6, (10*$it+10), $cap_height/4, $letter, $color_text); 
  41. for ($c = 0; $c < 150; $c++) { 
  42. $x = rand(0, 79); 
  43. $y = rand(0, 29); 
  44. $col='0x'.rand(0, 9).'0'.rand(0, 9).'0'.rand(0, 9).'0'; 
  45. imagesetpixel($canvas, $x, $y, $col); 
  46. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');  
  47. header('Cache-Control: no-store, no-cache, must-revalidate');  
  48. header('Cache-Control: post-check=0, pre-check=0', false); 
  49. header('Pragma: no-cache'); 
  50. header('Content-Type: image/jpeg'); 
  51. imagejpeg($canvas, null, $cap_quality); 
  52.  
  53. }  
  54. die('');