Re: HN CAPTCHA at http://www.phpclasses.org

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/16/06, Roger Thomas <sniper@xxxxxxxxxxx> wrote:
> I am currently testing HN CAPTCHA and noticed that the range of alphabets that were produced ranges from A..F only. My PHP skill is quite limited to change that to A..Z so if ppl here have any experience with that class, appreciate your thoughts. TIA.

The reason this CAPTCHA class only returns letters between A-F is
because it uses the md5() function in php to get a (more or less)
random string. MD5 hashes contains of a 32-character hexadecimal
numbers, which in turn ranges from 0 to F.

To solve your problem, replace the generate_private() function in
hn_captcha.class.php - starting at row 756 - with this code:

   function generate_private($public="")
   {
      $letters = "1234567890abcdefghijklmnopqrstuvwxyz";
      $maxsize = strlen($letters)-1;
      for($i=0;$i<6;$i++){
            $rstring .= $letters{mt_rand(0, $maxsize)};
      }
      return $rstring;
   }

This should yield a 6 char "random" string containing digits 0-9 and
letters a-z.

Good luck!

--
Kim Christensen
kim.christensen@xxxxxxxxx

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux