Results 1 to 3 of 3
  1. #1

    captcha problems...

    Ok so I've been trying for 3hours to make a working captcha script, I came pritty close few times however tehre's always something wrong

    So here's how it should be :p:
    I got this function that generates an 8 digit key that contains numbers and letters, I just want to place this on a png/jpg/gif/whatever image so that people have to enter the generated key into a textfield for anti spam validation. I got pritty close at one time however it only outputted the first letter/number instead of all of them :p

    The generating script:
    PHP Code:
    //use the random digit maker by: $i=makeRandomDigit(8,false); 
    function makeRandomDigit($passlength=20,$eqparts=false) {
        if((!
    is_int($passlength))){
            
    $errmsg="Funtion error: funtion random digit: Length must be positive<br />\r\n";
        }
        if(!
    is_bool($eqparts)){
            
    $errmsg.="Funtion error: funtion random digit: 2nd parameter has to be true or false\r\n";
        }
        if(isset(
    $errmsg)){
            return 
    $errmsg;
        }
        
        
    $salt "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        
    srand((double)microtime()*1000000);
        
    $i 0;
        if(
    $eqparts==true){
            
    $length=$passlength;
        }else{
            
    $length=0;
        }
        while (
    $i <= $passlength) {
            
    $num rand() % (strlen($salt)-1);
            switch(
    $num){
                case 
    $num<26:$teller[1]++;
                break;
                case 
    $num>25 and $num<35:$teller[2]++;
                break;
                case 
    $num<61 :$teller[3]++;
                break;
            }
            
    $tmp substr($salt$num1);
            
    $pass $pass $tmp;
            
    $i++;
            if(
    strlen($pass)==$passlength){
                if(
    $teller[1]>=(int)($length/3) and $teller[2]>=(int)($length/3) and $teller[3]>=(int)($length/3)){
                    return 
    $pass;
                }
                
    $i 0;
                
    $pass='';
                unset(
    $teller);
            }
        }

    Is tehre a possibilty to do this with a trnasparent image cause it's on a pritty hard background otherwise > http://ahab.undreamedstudios.be

  2. #2
    anyone?

  3. #3
    Join Date
    Nov 2005
    Posts
    123
    nm........
    Last edited by bigfan; 11-02-2005 at 02:07 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •