Jump to content

Recommended Posts

my security image does not include letters eventhough i believe its supposed to.

 

<?php
class passGen {

    var $size;
    var $password;

// ------------------------------------------------

    function passGen($size=0){
                $this->size = $size;
    }

// ------------------------------------------------

        function password($return_letters=1, $return_numbers=1){

        $letters = 'abcdefghijklmnopqrstuvwxyz';
        $numbers = '0123456789';

        $passString = '';
            $option = $return_letters . $return_numbers;

        for($i = 0; $i < $this->size; $i++){
                switch($option){
                case '01':
                        $c = $numbers[mt_rand(0, 9)];
                break;
                case '10':
                        $c = $letters[mt_rand(0, 25)];
                break;
                case '11':
                    $j = mt_rand(0, 1);
                                        $c = ($j == 0 ? $letters[mt_rand(0, 25)] : $numbers[mt_rand(0, 9)]);
                break;
            }
            $this->password[$i] = $c;
            $passString .= $c;
        }
        return md5($passString);
    }

// ------------------------------------------------

        function images($path, $extension, $preImage='', $width='', $height='', $css=''){
        $images='';
            for($i = 0; $i < $this->size; $i++){
                $images .= '<img';
            if($css != ''){ $images .= ' class="'. $css .'"'; }
            $images .= ' src="'. $path .'/'. $preImage . $this->password[$i] .'.'. $extension .'" width="'. $width .'"  height="'. $height .'" alt="" border=0>';
        }
        return $images;
    }

// ------------------------------------------------

        function verify($input, $hash){
                if(md5($input) == $hash){ return true ; }
        else { return false; }
    }

// ------------------------------------------------

}

?>

 

2nd part

<?include('class.passgen.php');
$passGen = new passGen(5);

    $validate = 0;

    if(isset($_POST['submit'])){
    	$hash = $_POST['hash'];
        $pass = $_POST['pass'];

        if($passGen->verify($pass, $hash)){
        	$validate = 1;
            echo 'Validation OK';
        }
        else {
        	echo 'Validation not OK';
        }
        echo '<br>';
    }

    if($validate == 0){
    $hash = $passGen->password(0, 1);

    echo '<br>';
    echo $passGen->images('font', 'gif', 'f_', '16', '20');
    echo '<br><br>';
    echo'<p><label for="securitycode">Anti-Spam Security: (Required)</label><span style="color:#FF0000;">*</span><br>';
echo '<small>Type The Combination Shown In The Picture.</small><br>';
                    echo '<input type="hidden" value="'. $hash .'" name="hash">';
    echo '<input type="text" value="'. $pass .'" name="pass" size="5" maxlength="5">';
        echo '<br><br>';
    	    
    }

?>

Link to comment
https://forums.phpfreaks.com/topic/71204-security-image-only-showing-numbers/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.