/** * Generate captcha * * @return string */ public function generate() { if (!Mage::helper('uaudio_storage')->isEnabled()) { return parent::generate(); } $storageModel = Mage::getSingleton('core/file_storage')->getStorageModel(); $id = Zend_Captcha_Word::generate(); $tries = 5; // If there's already such file, try creating a new ID while ($tries-- && $storageModel->fileExists($this->getImgDir() . $id . $this->getSuffix())) { $id = $this->_generateRandomId(); $this->_setId($id); } $this->_generateImage($id, $this->getWord()); if (mt_rand(1, $this->getGcFreq()) == 1) { $this->_gc(); } $imgFile = $this->getImgDir() . $id . $this->getSuffix(); $storageModel->moveFile($imgFile, $imgFile); return $id; }
/** * Generate captcha * * @return string captcha ID */ public function generate() { $id = parent::generate(); $tries = 5; // If there's already such file, try creating a new ID while ($tries-- && file_exists($this->getImgDir() . $id . $this->getSuffix())) { $id = $this->_generateRandomId(); $this->_setId($id); } $this->_generateImage($id, $this->getWord()); if (mt_rand(1, $this->getGcFreq()) == 1) { $this->_gc(); } return $id; }
/** * Generate new captcha * * @return string */ public function generate() { $this->_useNumbers = false; return parent::generate(); }
/** * Generate captcha * * @return string captcha ID */ public function generate() { $id = parent::generate(); $this->_generateImage($id, $this->getWord()); if (mt_rand(0, $this->getGcFreq()) == 1) { $this->_gc(); } return $id; }