diff -r 7eef739a5b81 -r 6ae6e387a0e3 includes/captcha/engine_default.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/includes/captcha/engine_default.php Wed Feb 06 18:41:47 2008 -0500 @@ -0,0 +1,150 @@ +get_code()); + + /** + * The next part is orginnaly written by ted from mastercode.nl and modified for use in Enano. + **/ + header("content-type:image/png"); + header('Cache-control: no-cache, no-store'); + $breedte = 320; + $hoogte = 60; + $img = imagecreatetruecolor($breedte,$hoogte); + $achtergrond = imagecolorallocate($img, $this->color("bg"), $this->color("bg"), $this->color("bg")); + + imagefilledrectangle($img, 0, 0, $breedte-1, $hoogte-1, $achtergrond); + for($g = 0;$g < 30; $g++) + { + $t = $this->dss_rand(); + $t = $t[0]; + + $ypos = rand(0,$hoogte); + $xpos = rand(0,$breedte); + + $kleur = imagecolorallocate($img, $this->color("bgtekst"), $this->color("bgtekst"), $this->color("bgtekst")); + + imagettftext($img, $this->size(), $this->move(), $xpos, $ypos, $kleur, $this->font(), $t); + } + $stukje = $breedte / (strlen($code) + 3); + + for($j = 0;$j < strlen($code); $j++) + { + + + $tek = $code[$j]; + $ypos = rand(33,43); + $xpos = $stukje * ($j+1); + + $kleur2 = imagecolorallocate($img, $this->color("tekst"), $this->color("tekst"), $this->color("tekst")); + + imagettftext($img, $this->size(), $this->move(), $xpos, $ypos, $kleur2, $this->font() , $tek); + } + + imagepng($img); + } + + /** + * Some functions :) + * Also orginally written by mastercode.nl + **/ + /** + * Function to create a random color + * @param $type string Mode for the color + * @return int + **/ + function color($type) + { + switch($type) + { + case "bg": + $kleur = rand(224,255); + break; + case "tekst": + $kleur = rand(0,127); + break; + case "bgtekst": + $kleur = rand(200,224); + break; + default: + $kleur = rand(0,255); + break; + } + return $kleur; + } + /** + * Function to ranom the size + * @return int + **/ + function size() + { + $grootte = rand(14,30); + return $grootte; + } + /** + * Function to random the posistion + * @return int + **/ + function move() + { + $draai = rand(-25,25); + return $draai; + } + + /** + * Function to return a ttf file from fonts map + * @return string + **/ + function font() + { + $f = @opendir(ENANO_ROOT . '/includes/captcha/fonts/'); + if(!$f) die('Can\'t open includes/captcha/fonts/ for reading'); + $ar = array(); + while(($file = @readdir($f)) !== false) + { + if(!in_array($file, array('.','..')) && strstr($file, '.ttf')) + { + $ar[] = $file; + } + } + if(count($ar)) + { + shuffle($ar); + $i = rand(0,(count($ar) - 1)); + return ENANO_ROOT . '/includes/captcha/fonts/' . $ar[$i]; + } + } + function dss_rand() + { + $val = microtime() . mt_rand(); + $val = md5($val . 'a'); + return substr($val, 4, 16); + } +}