Location: PHPKode > projects > Tagging manager > version 1.02/captcha.php
<?php
/**
 * random image generator (number)
 *
 * generate image(png) with random passcode  
 * saves md5 hash of the pass in session['code']
 *
 * @author hide@address.com
 * @version 1.0
 * @package TaggingManager
 */

 
 
  $root_path = './';
  
  include_once($root_path.'config.php');
  session_start();
  
  

	// generate random letters
	$code = "";
	for($i = 0; $i<$passlen; $i++){
   	$code = $code .
		substr($possiblechars,rand(0,strlen($possiblechars)-1),1);
	}


	// create image
	$im = imagecreate($width, $height);
	$bg = imagecolorallocate($im, 255, 255, 255);
	$textcolor = imagecolorallocate($im, 120, 120, 120);
	$bordercolor = imagecolorallocate($im, 80, 80, 80);
	imagerectangle($im,0,0,$width-1,$height-1,$bordercolor);

	// enter code in image
	imagestring($im, 5, 15, 2, $code, $textcolor);

	// output the image (no-cache)
	header("Expires: Wed, 1 Jan 1997 00:00:00 GMT");
	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
	header("Cache-Control: no-store, no-cache, must-revalidate");
	header("Cache-Control: post-check=0, pre-check=0", false);
	header("Pragma: no-cache");
	header("Content-type: image/png");
	imagepng($im);
	imageDestroy($im); // destroy image to free memory

	// insert code in session
	$_SESSION['code'] = md5($code);
	
?>
Return current item: Tagging manager