goker

göker

cebeci

developer

edirne

goker.cebeci :: yaşam için hayata dair geliştirme çabaları :: Web Developer Olmak :: captcha gd

captcha gd

yazım: 24 Mart 09 10:29 / güncelleme: 25 Mart 09 20:26

php gd ile captcha

php gd ile captcha örneği

session_start();   $charCount = 6;   $width = 100;   $height = 35;   $im=@imagecreate($width, $height);   $width = $width - 10;   if($width/$charCount > $height) {       $fontSize = $height;    } else {       $fontSize = $width/$charCount >> 0;      $padding = $height - $fontSize;   }   imagecolorallocate($im, 0, 0, 0);   $white = imagecolorallocate($im, 255, 255, 255);   $color = imagecolorallocate($im,rand(150,255),rand(150,255),rand(150,255));   imageline($im, rand(3,$width), rand(3,$height), rand(3,$width), rand(3,$height), imagecolorallocate($im, 150, 150, 150));   $possible = '23456789bcdfghjkmnpqrstvwxyz';   $codeText = '';   $i = 0;   $left = 5;   $font = 'lib/captcha/captcha.ttf';      while ($i < $charCount) {      $codeColor=imagecolorallocate($im,255-rand(100,255),255-rand(100,255),255-rand(100,255));      $codeText .= $codeChar = (rand(0,10)>5)?strtoupper(substr($possible, rand(0, strlen($possible)-1), 1)):(substr($possible, rand(0, strlen($possible)-1), 1));      $size = $height * rand(5,7)*.1;      imagettftext($im, $fontSize, rand(-21,21), $left, ($height+$padding)*.5, $codeColor, $font, $codeChar);      $left += $fontSize;      $i++;   }    header("Content-type: image/jpeg");   header("Content-Disposition:inline ; filename=secure.jpg");   imagejpeg($im);   imagedestroy($im);   $_SESSION['captcha'] = $codeText;
anahtar kelimeler: captcha php gd

Yorumlar

Sitede yer alan yorumlar, kullanıcıların kendi görüşleridir. Kullanıcı yorumlarından goker.cebeci sorumlu tutulamaz.

Yorum yazmak için üye girişi yapın.

loader

Web Developer Olmak

Web Developer'ın bitmeyen geliştirme çabaları.

Konular

fPlayer (1) Web Developer Olmak (25) Bilgisayar Dertleri (4) Genel (3) az LAf ÇOK iŞ (3) beN'im gözümden (1)
ubuntu server php5 powered mysql database mootools 1.2 w3c xhtml 1.1 w3c css
Sitedeki içerikler bilgi amaçlı olup, kullanımından doğacak sorunlardan göker.cebeci sorumlu tutulamaz.