Yesideez Posted December 23, 2008 Share Posted December 23, 2008 Here's one I wrote: <?php session_start(); $imgWidth=130; $imgHeight=34; $chars='abcdefghijkmnqrstuvwxyz0123456789ABCDEFGHIJKLMNPQRSTUVWXYZ'; $strText=''; for ($i=1;$i<7;$i++) {$strText.=substr($chars,mt_rand(0,strlen($chars)-1),1);} $_SESSION['vercode']=md5($strText); header("Content-type: image/png"); $img=imagecreatetruecolor($imgWidth,$imgHeight); //enable if plain colored background is to be used //$img=imagecreatefrompng('gfx/codebg.png'); //enable if patterned background image is to be used $colBG=imagecolorallocate($img,0x11,0x11,0x11); for ($i=0;$i<strlen($strText);$i++) { $colFG=imagecolorallocate($img,mt_rand(50,255),mt_rand(50,255),mt_rand(50,255)); imagettftext($img,20,mt_rand(-40,40),10+($i*20),27,$colFG,'fonts/times.ttf',substr($strText,$i,1)); } imagepng($img); imagedestroy($img); ?> Just make sure your TFF font is in the same place as specified by the imagettftext line. Just MD5 the input from your user and check it with $_SESSION['vercode'] Call with: <img src="makeimg.php?<?=mt_rand(1,100000)?>" /> Quote Link to comment https://forums.phpfreaks.com/topic/131693-php-captchas/page/2/#findComment-722312 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.