Location: PHPKode > projects > Astanda Open Directory Project > adp-1.3b/captcha.php
<?php
//-------------------------------------------------//
//                                                 //
//        ASTANDA DIRECTORY PROJECT  [ADP]         //
//                  Version 1.3b                   //
//               License: SHAREWARE                //
//             http://www.astanda.com              //
//      © Copyright 2005, 2006, Pavel Golovko      //
//                                                 //
//-------------------------------------------------//
//                                                 //
// Any attempt to remove or alter "Powered by ADP" //
// recip link will automatically wave your rights  //
// to any use of ADP software!                     //
//                                                 //
// Reverse engineering and redistribution of       //
// ADP code or any part of its code is strictly    //
// prohibited!                                     //
//                                                 //
//-------------------------------------------------//
//                                                 //
// ADP is distributed in the hope that it will be  //
// useful, but WITHOUT ANY WARRANTY; without even  //
// the implied warranty of MERCHANTABILITY or      //
// FITNESS FOR A PARTICULAR PURPOSE.               //
//                                                 //
//-------------------------------------------------//

session_start();
function random_string($len=5,$str=''){
	for($i=1;$i<=$len;$i++){
		$ord=rand(48,90);
		if((($ord >= 48) && ($ord <= 57)) || (($ord >= 65) && ($ord <= 90))){ $str.=chr($ord); }
		else{ $str.=random_string(1); }
		}
	return $str;
	}
$rand_str=random_string(5);
$_SESSION['image_value'] = md5($rand_str);
header('Content-type: image/jpeg');
$image = imagecreatetruecolor(250, 70);
$font = "admin/fonts/captcha.ttf";
$alpha_string = '';
for($i=0;$i<25;$i++){ $alpha_string .= random_string(50).random_string(50).random_string(50)."\n"; }
imagefill($image,0,0,imagecolorallocate($image,rand(175,225),rand(175,225),rand(175,225)));
imagettftext($image,rand(10,30),rand(-10,10),-20,-20,imagecolorallocate($image,rand(230,255),rand(230,255),rand(230,255)),$font,$alpha_string);
imagettftext($image,rand(20,40),rand(-10,10),5,rand(10,35)+25,rand(0,175),$font,substr($rand_str,0,1));
imagettftext($image,rand(20,40),rand(-10,10),55,rand(10,35)+25,rand(0,175),$font,substr($rand_str,1,1));
imagettftext($image,rand(20,40),rand(-10,10),105,rand(10,35)+25,rand(0,175),$font,substr($rand_str,2,1));
imagettftext($image,rand(20,40),rand(-10,10),155,rand(10,35)+25,rand(0,175),$font,substr($rand_str,3,1));
imagettftext($image,rand(20,40),rand(-10,10),205,rand(10,35)+25,rand(0,175),$font,substr($rand_str,4,1));
imagejpeg($image, null, 100);
imagedestroy($image);
?>
Return current item: Astanda Open Directory Project