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 captcha */ $this->word = $this->getRandomWord(); /* set variable session for verification */ if(isset($_SESSION['veriword'])) unset($_SESSION['veriword']); $_SESSION['veriword'] = md5(strtolower($this->word)); } function getWord() { return $this->word; } function getWidth() { return $this->captcha['width']; } function getHeight() { return $this->captcha['height']; } function createFlash() { $w = $this->getWidth(); $h = $this->getHeight(); $xFont=new SWFFont("_sans"); $xText=new SWFText(); $xText->setFont($xFont); $xText->setColor(0,0,0); $xText->setHeight(40); $xText->addString($this->getWord()); $txtWidth = $xText->getWidth($this->getWord()); $txtHeight = $xText->getAscent()+$xText->getDescent();; $txtMovie = new SWFMovie(); $txtMovie->setDimension($w,$h); $txtMovie->setBackground(255,255,255); $txSprite=$txtMovie->add($xText); $txSprite->moveto(($w-$txtWidth)/2,2*$h/3); $swf = "tmp/".uniqid(time()).".swf"; $txtMovie->save($swf); //animation SWF $aniMovie = new SWFMovie(); $aniMovie->setDimension($w,$h); $aniMovie->setBackground(255,255,255); $aniMovie->add(new SWFAction(" loadMovie('$swf','_level0'); loadMovie('movies/ball.swf','_level1'); loadMovie('movies/bar.swf','_level2'); ")); $aniMovie->nextFrame(); $this->flashcaptcha = $aniMovie; } function outputFlash() { $this->createFlash(); $this->swfname = "tmp/".uniqid(time()).".swf"; $this->flashcaptcha->save($this->swfname); chmod($swf,755); unlink ($swf); } function getSWFName () { return $this->swfname; } } ?>