<?php
header("Content-Type:image/jpeg");
$fontFile=realpath("ZXSPK___.TTF");
$session_path=realpath(dirname($fontFile)."/");
ini_set("session.save_path","{$session_path}/session/");
if(!session_id())session_start();
$im=imagecreate(90,30);
$td_bgColor=imagecolorallocate($im,255,255,255);
$fontColor=imagecolorallocate($im,83,170,219);
imagealphablending($im,true);
$wz_x=1;
$wz_y=0;
$str="";
$i=0;
while(true)
{
	$temp=mt_rand(48,122);
    if(($temp>=48 && $temp<=57) || ($temp>=65 && $temp<=90) || ($temp>=97 && $temp<=122))
    {
		$i++;
		if($i>4){
			break;
		}
		$chr=chr($temp);
		$str.=$chr;
		$font_size=mt_rand(14,22);
		$angle=mt_rand(-25,35);
		$wz_x=$i==0?mt_rand(-5,5):$wz_x+mt_rand(10,20);
		$wz_y=mt_rand(20,30);
		imagettftext($im,$font_size,$angle,$wz_x,$wz_y,$fontColor,$fontFile,$chr);
    }else{
		continue;
	}
}
$_SESSION["code"]=$str;
imagejpeg($im);
imagedestroy($im);
?>