<?php $captcha = new captcha(); $captcha->CreateImage(); class captcha { public $width = 150; public $height = 50; public $font_path = 'fonts/'; public $minWordLength = 5; public $maxWordLength = 5; public $backgroundColor = array(255, 255, 255); public $colors = array(array(27, 78, 181), array(22, 163, 35), array(214, 36, 7)); public $shadowColor = null; public $fonts = array('Antykwa' => array('spacing' => -3, 'minSize' => 27, 'maxSize' => 30, 'font' => 'AntykwaBold.ttf'), 'Candice' => array('spacing' => -1.5, 'minSize' => 28, 'maxSize' => 31, 'font' => 'Candice.ttf'), 'DingDong' => array('spacing' => -2, 'minSize' => 24, 'maxSize' => 30, 'font' => 'Ding-DongDaddyO.ttf'), 'Duality' => array('spacing' => -2, 'minSize' => 30, 'maxSize' => 38, 'font' => 'Duality.ttf'), 'Heineken' => array('spacing' => -2, 'minSize' => 24, 'maxSize' => 34, 'font' => 'Heineken.ttf'), 'Jura' => array('spacing' => -2, 'minSize' => 28, 'maxSize' => 32, 'font' => 'Jura.ttf'), 'StayPuft' => array('spacing' => -1.5, 'minSize' => 28, 'maxSize' => 32, 'font' => 'StayPuft.ttf'), 'Times' => array('spacing' => -2, 'minSize' => 28, 'maxSize' => 34, 'font' => 'TimesNewRomanBold.ttf'), 'VeraSans' => array('spacing' => -1, 'minSize' => 20, 'maxSize' => 28, 'font' => 'VeraSansBold.ttf')); public $Yperiod = 12; public $Yamplitude = 14; public $Xperiod = 11; public $Xamplitude = 5; public $maxRotation = 8; public $scale = 2; public $blur = false; public $imageFormat = 'png'; public $im; public function CreateImage() { $ini = microtime(true); $this->ImageAllocate(); $text = $this->GetCaptchaText(); $fontcfg = $this->fonts[array_rand($this->fonts)]; $this->WriteText($text, $fontcfg);
/** * Cria o captcha caso o nĂºmero de tentativas de login falhos seja maior ou igual a 5 */ public function captcha() { $captcha = new captcha(); if ($_SESSION['ntentativaLogin'] >= 5) { $captcha->CreateImage(); } else { echo false; } }