<?php
/******************************************
 * Created on Dec 28, 2008
 *
 * Project  : LEAPJ
 * FileName : verifyCode.php
 * Author   : Leacen
 * Version  : 0.0.1
 * Copyright: Scweb Network Studio, Inc.
 */$image = imagecreatetruecolor(90,30);
session_start();
$_SESSION["verify"] = "";$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$str = "abcdefghijklmnopqrstuvwxyz0123456789";
imagefill($image,0,0,$white);$verifyLen = 4;
$verifyCode = "";for($i = 0; $i < 100; $i++){
$color = imagecolorallocate($image,rand(180,255),rand(180,255),rand(180,255));
//imagearc($image,rand(0,imagesx($image)),rand(0,imagesy($image)),rand(0,5),rand(0,5),0,rand(0,360),$color);
imageline($image,rand(0,imagesx($image)),rand(0,imagesy($image)),rand(0,imagesx($image)),rand(0,imagesy($image)),$color);
}for($i = 0; $i < $verifyLen; $i++){
$color = imagecolorallocate($image,rand(0,150),rand(0,150),rand(0,150));
$tmpIndex = rand(0,strlen($str)-1);
$verifyCode .= $str[$tmpIndex];
@imagettftext($image, 20, rand(-15,15), $i*20+10,25,$color,'Verdana.ttf', $str[$tmpIndex]) or imagechar($image,5,$i*10+3,1,$str[$tmpIndex],$color);;

}
$_SESSION["verify"] = $verifyCode;header('Content-type: image/png');
imagepng($image);
imagedestroy($image);?>