Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Posts
    53

    Help: Form requiring verification of random message?

    It's just slipping my mind. I'm trying to protect a form with one of those "Type what this box says" using random values, but I just can't seem to get it working correctly.

    I can make it with a database of stuff I enter, however, after a while, it will be the same thing...

    Does anyone have code that can do that, but randomly generates numbers and whatnot instead of looking them up in a MySQL database? GoDaddy, Paypal, and others use something similar.

  2. #2
    Join Date
    Jan 2002
    Location
    Ohio
    Posts
    3,155
    Here is the code that generates the passwords on my "PHPNuke Fetchmod Script"...

    PHP Code:
    function makePass() {
        
    $cons "bcdfghjklmnpqrstvwxyz";
        
    $vocs "aeiou1234567890";
        for (
    $x=0$x 6$x++) {
            
    mt_srand ((double) microtime() * 1000000);
            
    $con[$x] = substr($consmt_rand(0strlen($cons)-1), 1);
            
    $voc[$x] = substr($vocsmt_rand(0strlen($vocs)-1), 1);
        }
        
    $makepass $con[0] . $voc[0] .$con[2] . $con[1] . $voc[1] . $con[3] . $voc[3] . $con[4];
        return(
    $makepass);

    Don't like what I say? Ignore me.

  3. #3
    Join Date
    Mar 2003
    Posts
    53

    Thanks... much easier than I thought

    Hate when I make things more complex than they should be... So simple.

    Anyway, this is what I threw it into:

    PHP Code:
    <?php

    /* Creates a Random word image, to prevent automatic signup
    Automatically creates some background circles which
    will be randomised to a lighter colour than the text
    $circle is the number of background circles
    */

    $circles=5;
    $width=100;
    $height=40;
    $font=5;

    $string=makePass();

    $fontwidth ImageFontWidth($font) * strlen($string);
    $fontheight ImageFontHeight($font);

    $im = @imagecreate ($width,$height);
    $background_color imagecolorallocate ($im255255255);
    $text_color imagecolorallocate ($imrand(0,100), rand(0,100),
    rand(0,100)); // Random Text

    for ($i=1;$i<=$circles;$i++) {
    $randomcolor imagecolorallocate ($im rand(100,255),
    rand(100,255),rand(100,255));
    imagefilledellipse($im,rand(0,$width-10),rand(0,$height-3),
    rand(20,70),rand(20,70),$randomcolor);
    }

    imagerectangle($im,0,0,$width-1,$height-1,$text_color);
    imagestring ($im$fontrand(3$width-$fontwidth-3),
    rand(2,$height-$fontheight-3),  $string$text_color);
    header ("Content-type: image/jpeg");
    imagejpeg ($im,'',80);

    function 
    makePass() {
        
    $cons "bcdfghjklmnpqrstvwxyz";
        
    $vocs "aeiou1234567890";
        for (
    $x=0$x 6$x++) {
            
    mt_srand ((double) microtime() * 1000000);
            
    $con[$x] = substr($consmt_rand(0strlen($cons)-1), 1);
            
    $voc[$x] = substr($vocsmt_rand(0strlen($vocs)-1), 1);
        }
        
    $makepass $con[0] . $voc[0] .$con[2] . $con[1] . $voc[1] . $con[3] . $voc[3] . $con[4];
        return(
    $makepass);
    }

    ?>

Posting Permissions

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