Big CAPTCHA Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jeigh
    New Member
    • Jul 2007
    • 73

    Big CAPTCHA Problem

    My host has been 'upgrading' lately and its caused me a whole mess of problems. The last of which being that my CAPTCHA form no longer works. I remember to get the CAPTCHA working it took me weeks to do (this was a long time ago too), and at some point I recall editing it in a Hex editor before finally getting it to work, basically I do not have a clue what this thing needs to do to work.

    One day I tried my registration form (without editing anything), and it just kept refreshing itself when it submitted. So I sent an email to the support people and whatever they did messed up my CAPTCHA, it just shows up as a red X now. Here is what they said:

    "We had noticed that the custom php.ini file for your account was not setup fine. Hence, you were experiencing issues with the functionality of the registration form at the URL "

    "We would like you to know that we have now reset the custom php.ini file for your account properly from our end. "

    Would this file being reset be a likely cause for the CAPTCHA not working?

    I'm using 'freecap' which was the script I downloaded for the CAPTCHA.

    If anyone here has any ideas on what could be going wrong I'd greatly appreciate any help. If theres any specific snippets of code you'd like me to post, please tell me.

    Thank You.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    Could you show us the code that generates and shows the image, and perhaps the code that receives and validates the code?

    This could be a problem with register_global s. Many hosts have disabled this now that PHP is not longer supporting it.

    Comment

    • Jeigh
      New Member
      • Jul 2007
      • 73

      #3
      Hi thanks for the response, here is a snippet of code that I think will be the most relevant (the entire thing is quite long):

      [PHP]
      function make_seed() {
      // from http://php.net/srand
      list($usec, $sec) = explode(' ', microtime());
      return (float) $sec + ((float) $usec * 100000);
      }

      function rand_color() {
      global $bg_type,$rand_ func;
      if($bg_type==3)
      {
      // needs darker colour..
      return $rand_func(10,1 00);
      } else {
      return $rand_func(60,1 70);
      }
      }

      function myImageBlur($im )
      {
      // w00t. my very own blur function
      // in GD2, there's a gaussian blur function. bunch of bloody show-offs... :-)

      $width = imagesx($im);
      $height = imagesy($im);

      $temp_im = ImageCreateTrue Color($width,$h eight);
      $bg = ImageColorAlloc ate($temp_im,15 0,150,150);

      // preserves transparency if in orig image
      ImageColorTrans parent($temp_im ,$bg);

      // fill bg
      ImageFill($temp _im,0,0,$bg);

      // anything higher than 3 makes it totally unreadable
      // might be useful in a 'real' blur function, though (ie blurring pictures not text)
      $distance = 1;
      // use $distance=30 to have multiple copies of the word. not sure if this is useful.

      // blur by merging with itself at different x/y offsets:
      ImageCopyMerge( $temp_im, $im, 0, 0, 0, $distance, $width, $height-$distance, 70);
      ImageCopyMerge( $im, $temp_im, 0, 0, $distance, 0, $width-$distance, $height, 70);
      ImageCopyMerge( $temp_im, $im, 0, $distance, 0, 0, $width, $height, 70);
      ImageCopyMerge( $im, $temp_im, $distance, 0, 0, 0, $width, $height, 70);
      // remove temp image
      ImageDestroy($t emp_im);

      return $im;
      }

      function sendImage($pic)
      {
      // output image with appropriate headers
      global $output,$im,$im 2,$im3;
      header(base64_d ecode("WC1DYXB0 Y2hhOiBmcmVlQ2F wIDEuNCAtIHd3dy 5wdXJlbWFuZ28uY 28udWs="));
      switch($output)
      {
      // add other cases as desired
      case "jpg":
      header("Content-Type: image/jpeg");
      ImageJPEG($pic) ;
      break;
      case "gif":
      header("Content-Type: image/gif");
      ImageGIF($pic);
      break;
      case "png":
      default:
      header("Content-Type: image/png");
      ImagePNG($pic);
      break;
      }

      // kill GD images (removes from memory)
      ImageDestroy($i m);
      ImageDestroy($i m2);
      ImageDestroy($p ic);
      if(!empty($im3) )
      {
      ImageDestroy($i m3);
      }
      exit();
      }
      [/PHP]

      And the image is called with:

      <img src="freecap.ph p" id="freecap">

      Comment

      • Jeigh
        New Member
        • Jul 2007
        • 73

        #4
        For now I've just wrote a new registration script (the other one was beyond salvagable). So at least people visiting my site can register now but there is no CAPTCHA (which for now is not a problem). If anyone still has any ideas as to why that may have happened please post or if you can recommend another CAPTCHA script I could look into I'd appreciate that.

        Thanks.

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          I can't see where you create, save or retrieve the captcha validation code.
          What is in the 'freecap.php' file?

          Comment

          Working...