readConfig(); //Captcha $this->captcha['width'] = $config->getConfig('captcha_width'); $this->captcha['height'] = $config->getConfig('captcha_height'); $this->captcha['output'] = $config->getConfig('captcha_output'); //RandomWord $this->randomword['type'] = $config->getConfig('randomword_type'); $this->randomword['dict'] = $config->getConfig('randomword_dict'); $this->randomword['length'] = $config->getConfig('randomword_length'); //Noise $this->noise['type'] = $config->getConfig('noise_type'); $this->noise['dir'] = $config->getConfig('noise_dir'); //WordArt $this->wordart['dir'] = $config->getConfig('wordart_dir'); $this->wordart['capital'] = $config->getConfig('wordart_capital'); $this->wordart['color'] = $config->getConfig('wordart_color'); $this->wordart['angle'] = $config->getConfig('wordart_angle'); $this->wordart['typing'] = $config->getConfig('wordart_typing'); $this->wordart['filter'] = $config->getConfig('wordart_filter'); } function setCaptcha() { /* get the CAPTCHA image */ $this->im = $this->getCaptcha(); /* set variable session for verification */ if(isset($_SESSION['veriword'])) unset($_SESSION['veriword']); $_SESSION['veriword'] = md5(strtolower($this->getWord())); } function getWord() { return $this->word; } function outputImage() { /* make it not case sensitive*/ $this->imtype = strtolower($this->captcha['output']); /* check image type availability */ $this->validateType(); /* show the image */ switch($this->imtype){ case 'jpeg' : case 'jpg' : header("Content-type: image/jpeg"); imagejpeg($this->im); break; case 'gif' : header("Content-type: image/gif"); imagegif($this->im); break; case 'png' : header("Content-type: image/png"); imagepng($this->im); break; case 'wbmp' : header("Content-type: image/vnd.wap.wbmp"); imagewbmp($this->im); break; } } function validateType() { /* check image type availability*/ $is_available = FALSE; switch($this->imtype){ case 'jpeg' : case 'jpg' : if(function_exists("imagejpeg")) $is_available = TRUE; break; case 'gif' : if(function_exists("imagegif")) $is_available = TRUE; break; case 'png' : if(function_exists("imagepng")) $is_available = TRUE; break; case 'wbmp' : if(function_exists("imagewbmp")) $is_available = TRUE; break; } if(!$is_available && function_exists("imagejpeg")){ /* if not available, cast image type to jpeg*/ $this->imtype = "jpeg"; return TRUE; } else if(!$is_available && !function_exists("imagejpeg")){ die("No image support in this PHP server"); } else return TRUE; } } ?>