| 
            
            
                    
            
             
 
 
                    
                    | Random image password generator
                    Auteur: Tri - 08 januari 2005 - 15:04 - Gekeurd door: Dennisvb - Hits: 10411  - Aantal punten: 4.17 (3 stemmen)
                     
                         
 
 Alles spreekt voor zich denk ik, lees anders de broncode.
 
 Veel plezier ermee!
 
 Tri
 |  
 
                    
                    | Code: |  
                    | 
    
    
        
            
                
<?php
/*
October 2004
*** Random Image-Password Generator ***
This script generates a random string, displayed
on an image.
It can be very useful to prevent bots from automatic
logins or sign-ups.
Example:
You have a form and you want to be sure that no bots
automatically sign-up to gain e.g. extra credit.
To prevent this, let the user type the 'random' string,
that is displayed on the image, in a field. When this is
correct, you're sure that it's a human filling in :)
NOTE: You need to have GD library installed!!!
by Tri Pham
www.tripham.nl
tri[at]tripham.nl
*/
$width      = 200; // width of image
$height     =  80; // height of image
$len        =  10; // length of string
$fontsize   =   5; // fontsize
unset($random_text);
$lchar = 0;
$char  = 0;
/**************************************************
$random_text will hold the secret and random text!
**************************************************/
// create 'random' text
for($i = 0; $i < $len; $i++) {
    while($char == $lchar) {
        $char = rand(48, 109);
        if($char > 57) $char += 7;
        if($char > 90) $char += 6;
    }
    $random_text .= chr($char);
    $lchar = $char;
}
$fontwidth  = ImageFontWidth($fontsize) * strlen($random_text);
$fontheight = ImageFontHeight($fontsize);
// create handle for image
$im = @imagecreate($width,$height);
// white background
$background_colour = imagecolorallocate($im, 255, 255, 255);
// give the 'random' text a nice colour
$text_colour = imagecolorallocate($im, rand(0,100), rand(0,100), rand(0,100));
// give the border a colour too ;)
imagerectangle($im, 0, 0, $width-1, $height-1, $text_colour);
// draw the string horizontally
imagestring($im, $fontsize, rand(3, $width-$fontwidth-3), rand(2, $height-$fontheight-3), $random_text, $text_colour);
// lets output!
header("Content-type: image/png");
imagepng($im,'',80);
imagedestroy($im);
?> 
 <?php/*October 2004*** Random Image-Password Generator ***This script generates a random string, displayedon an image. It can be very useful to prevent bots from automaticlogins or sign-ups. Example:You have a form and you want to be sure that no botsautomatically sign-up to gain e.g. extra credit.To prevent this, let the user type the 'random' string,that is displayed on the image, in a field. When this iscorrect, you're sure that it's a human filling in :) NOTE: You need to have GD library installed!!!  by Tri Phamwww.tripham.nltri[at]tripham.nl*/  $width      = 200; // width of image$height     =  80; // height of image$len        =  10; // length of string$fontsize   =   5; // fontsize  $lchar = 0;$char  = 0;/**************************************************$random_text will hold the secret and random text!**************************************************/// create 'random' textfor($i = 0; $i < $len; $i++) {    while($char == $lchar) {        if($char > 57) $char += 7;        if($char > 90) $char += 6;    }    $random_text .= chr($char);    $lchar = $char;} $fontwidth  = ImageFontWidth($fontsize) * strlen($random_text);$fontheight = ImageFontHeight($fontsize); // create handle for image$im = @imagecreate($width,$height); // white background$background_colour = imagecolorallocate($im, 255, 255, 255); // give the 'random' text a nice colour$text_colour = imagecolorallocate($im, rand(0,100), rand(0,100), rand(0,100)); // give the border a colour too ;)imagerectangle($im, 0, 0, $width-1, $height-1, $text_colour); // draw the string horizontallyimagestring($im, $fontsize, rand(3, $width-$fontwidth-3), rand(2, $height-$fontheight-3), $random_text, $text_colour); // lets output!header("Content-type: image/png");imagepng($im,'',80); imagedestroy($im);?>
    Download code (.txt) |  
 
                    
                    |  |  
            
            
                    
            
             | 
                
                |  Stemmen |  
                | Niet ingelogd. |  
 |