msFontPath=str_replace("\\","/",dirname(__FILE__))."/ttf/"; $this->masFonts["arial"]=$this->msFontPath."arial.ttf"; $this->masFonts["cour"]=$this->msFontPath."arial.ttf"; $this->masFonts["rotis"]=$this->msFontPath."arial.ttf"; } function generateRandomKey($lLength) { for($i=0;$i<$lLength;$i++) { $asReturn[]=chr(mt_rand(65,90)); } return join($asReturn); } function generateRandomKeyImage($sRandomKey=false) { if($sRandomKey===false) $sRandomKey=$this->generateRandomKey(10); $this->pImage=imagecreate(400,80); $white=imagecolorallocate($this->pImage,255,255,255); $black=imagecolorallocate($this->pImage,0,0,0); $xPos=10; $size=20; $yPos=30; for($i=0;$imasFonts[$this->getRandomFont()]; $angle=mt_rand(-10,10); $char=substr($sRandomKey,$i,1); if(!$asDataOf=@imagettfbbox($size,$angle,$sFontPath,$char)) { return false; } if(!@imagettftext($this->pImage,$size,$angle,$xPos,$yPos,$this->getRandomCol(),$sFontPath,$char)) { return false; } $xAdd=abs(max(abs($asDataOf[IMG_BLOCK_URX])+abs($asDataOf[IMG_BLOCK_ULX]),abs($asDataOf[IMG_BLOCK_ORX])+abs($asDataOf[IMG_BLOCK_OLX]))); $xPos+=$xAdd; } } function PNG() { imagepng($this->pImage);//,"c:/test.png"); } function getRandomCol() { $a=mt_rand(0,50); $b=mt_rand(0,100); $upper=max($a,$b); $lower=min($a,$b); return imagecolorallocate($this->pImage,mt_rand(10,200),mt_rand(10,200),mt_rand(10,200)); } function getRandomFont() { $asFont[0]="rotis"; $asFont[1]="arial"; return "arial"; return $asFont[mt_rand(0,1)]; } }?>