note 68296 deleted from ref.image by tularis

From: Date: Sun, 29 Jun 2008 21:01:33 +0000
Subject: note 68296 deleted from ref.image by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-140921@lists.php.net to get a copy of this message
Note Submitter: sampathperera at hotmail dot com - Sri Lanka ---- I have used following function to generate Security Images to authenticate users are real humans. Need to have GD graphic library with FreeType enabled. Used a gif file as background, put random text on it & creates a new gif file as output. <?php function createImage(){ // creates the images, writes the file $fileRand = md5(rand(100000,999999)); $string_a = array("A","B","C","D","E","F","G","H","J","K", "L","M","N","P","R","S","T","U","V","W","X","Y","Z", "2","3","4","5","6","7","8","9"); $keys = array_rand($string_a, 6); foreach($keys as $n=>$v){ $string .= $string_a[$v]; } $backgroundimage = "security_background.gif"; $im=imagecreatefromgif($backgroundimage); $colour = imagecolorallocate($im, rand(0,255), rand(0,255), rand(0,255)); $font = 'Arial'; $angle = rand(-5,5); // Add the text imagettftext($im, 16, $angle, 15, 25, $colour, $font, $string); $outfile= "$fileRand.gif"; imagegif($im,$outfile); return $outfile; } echo "<IMG SRC=".createImage()." name=secimg>"; ?>

« previous php.notes (#140921) next »