Php captcha sınıfı

Ana sayfa Forumlar PROGRAMLAMA PHP Php captcha sınıfı

  • Bu konu 1 yanıt içerir, 2 izleyen vardır ve en son 12 yıl önce Bahadir tarafından güncellenmiştir.
2 yazı görüntüleniyor - 1 ile 2 arası (toplam 2)
  • Yazar
    Yazılar
  • #12716
    Gökhan
    İzleyici

    width;
    ++$this->height;

    $this->im = imagecreatetruecolor($this->width,$this->height);
    $bg = imagecolorallocate($this->im,$this->bgcolor[0],$this->bgcolor[1],$this->bgcolor[2]);
    imagefill($this->im,0,0,$bg);

    $linecolors = imagecolorallocate($this->im,$this->linecolor[0],$this->linecolor[1],$this->linecolor[2]);
    for($i = 0 ; $i <= $this->width ; $i = $i+10 )
    {
    imageline($this->im,0,$i,$this->width,$i,$linecolors);
    imageline($this->im,$i,0,$i,$this->height,$linecolors);
    }
    }

    public function create()
    {

    header(‘Content-Type:image/png’);
    $this->write();
    imagepng($this->im);
    imagedestroy($this->im);
    }

    public function chars()
    {
    $chr = ‘abcdefghijklmnoprstuxvyz1234567890ABCDEFGHIJKLMNOPRSTUWXYZ’;
    for($i = 0 ; $i < $this->chars; $i++)
    {
    $key .= $chr[rand(0,strlen($chr)-1)];
    }
    if($this->case_sensivty)
    {
    $_SESSION[$this->session_name] = $key;
    }
    else
    {
    $_SESSION[$this->session_name] = strtolower($key);
    }
    return $key;
    }

    private function write()
    {
    $fonts = $this->getfonts();
    $chars = $this->chars();
    $y_orgin = ($this->size > 35) ? 60 : 40;
    $space = ($this->size > 35) ? 60 : 30;
    if($fonts !== FALSE):
    for($i = 0 ; $i < $this->chars ; $i++)
    {
    $angle = rand(-15,15);
    $font = rand(0,count($fonts)-1);
    $color = rand(0,count($this->colors)-1);
    $color = explode(‘,’,$this->colors[$color]);
    $color = imagecolorallocate($this->im,$color[0],$color[1],$color[2]);
    imagettftext($this->im, $this->size ,$angle, 10 + ($i * $space) , $y_orgin , $color, $this->font_dir . DIRECTORY_SEPARATOR . $fonts[$font] ,$chars[$i]);
    }
    endif;
    }

    private function getfonts()
    {
    $read = opendir($this->font_dir);
    if($read)
    {
    while($list = readdir($read))
    {
    if($list != ‘.’ && $list != ‘..’ && preg_match(‘/(.ttf)$/’,$list))
    {
    $this->fonts[] = $list;
    }
    }
    return $this->fonts;
    }
    else
    {
    return false;
    }

    }
    }

    ?>

    Örmek1:
    start();
    $captcha->create();
    ?>

    Örnek2:
    bgcolor = array(112,138,144);
    $captcha->linecolor = array(255,228,225);
    $captcha->width = 250;
    $captcha->height = 60;
    $captcha->chars = 7;
    $captcha->size = 30;
    $captcha->session_name = ‘secret’;
    $captcha->colors = array(‘49,79,79′,’25,25,112′,’34,139,34’);
    $captcha->start();
    $captcha->create();
    ?>

    İndex Örneği:



    #12720
    Bahadir
    Üye

    çok teşekkürler.

2 yazı görüntüleniyor - 1 ile 2 arası (toplam 2)
  • Bu konuyu yanıtlamak için giriş yapmış olmalısınız.
Bana Ders Anlat © 2008-2022