goker

göker

cebeci

developer

edirne

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

captcha

yazım: 23 Mart 09 13:37 / güncelleme: 25 Mart 09 20:26

imagick ile captcha yapımı

php imagick ile captcha örneği

/** * captcha function, session is must * * @param imageFile $bg * @param int $charCount */   public function captcha($bg,$charCount = 4){      header('Content-type: image/jpeg');      $captcha = new imagick($bg);            $width = $captcha->getImageWidth()-8;      $height = $captcha->getImageHeight()-8;            $line = new imagickDraw();      $line->setStrokeWidth(2);      $line->setStrokeColor (new ImagickPixel('#cdcdde'));      //$line->setStrokeLineJoin(3);      for( $i=0; $iline(rand(3,$width), rand(3,$height), rand(3,$width), rand(3,$height));      }      $captcha->drawImage($line);            $possible = '23456789bcdfghjkmnpqrstvwxyz';      $codeText = '';      $i = 0;      $left = 5;      $code = new imagickDraw();      while ($i < $charCount) {         $codeText .= $codeChar = (rand(0,10)>5)?strtoupper(substr($possible, rand(0, strlen($possible)-1), 1)):(substr($possible, rand(0, strlen($possible)-1), 1));               $fontSize = $height * (rand(50,70)/100);                        $code->setFont('lib/captcha/captcha.ttf');          $code->setFontSize($fontSize);         $code->setFillColor(new ImagickPixel('#dd'.rand(11,22).''.rand(11,22)));         $code->setTextAlignment(1);         $code->setStrokeWidth(2);         $code->setStrokeColor (new ImagickPixel('#cc'.rand(11,22).'00'));                           $captcha->annotateImage($code, $left, 41, rand(-21,21), $codeChar);         $left += $fontSize;         $i++;      }            $_SESSION['captcha'] = $codeText;      echo $captcha;   }
anahtar kelimeler: captcha imagick php image magick

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.