public function init() { $this->_flashMessenger = $this->_helper->getHelper('FlashMessenger'); /*********** To check for publisher session data *********************/ $storage_publisher = new Zend_Auth_Storage_Session('publisher_type'); $publisher_data = $storage_publisher->read(); $storage_company = new Zend_Auth_Storage_Session('company_type'); $company_data = $storage_company->read(); if ($publisher_data && $publisher_data != null) { $this->modelPublisher = new Model_DbTable_Users(); $this->sessPublisherInfo = $this->modelPublisher->getInfoByUserId($publisher_data->id); $this->view->sessPublisherInfo = $this->sessPublisherInfo; } elseif ($company_data && $company_data != null) { $this->modelCompany = new Model_DbTable_Companies(); $this->sessCompanyInfo = $this->modelCompany->getInfoByUserId($company_data->id); $this->view->sessCompanyInfo = $this->sessCompanyInfo; } $this->modelPage = new Model_DbTable_Page(); $this->modelEnquiry = new Admin_Model_DbTable_Enquirys(); /************* To Set The active section and links *******************/ $controller = $this->_getParam('controller'); $action = $this->_getParam('action'); $title = $this->_getParam('title'); $this->view->currentController = $controller; $this->view->currentAction = $action; $this->view->currentTitle = $title; $this->view->class_active = 'class="active"'; /************* To Set The active section and links *******************/ if ($title == 'contact-us') { $captcha = new Zend_Captcha_Image(); $captcha->setImgDir('public/css/captcha/images/'); $captcha->setImgUrl($this->view->serverUrl . $this->view->baseUrl() . '/public/css/captcha/images/'); $captcha->setFont('public/css/captcha/fonts/times_new_yorker.ttf'); $captcha->setWordlen(5); $captcha->setFontSize(28); $captcha->setLineNoiseLevel(3); $captcha->setWidth(161); $captcha->setHeight(75); $captcha->generate(); /*$captcha= new Zend_Form_Element_Captcha('captcha', array( 'label' => "Please verify you're a human", 'captcha' => array( 'captcha' => 'image', 'font'=>'public/css/captcha/fonts/times_new_yorker.ttf', 'imgDir'=>'public/css/captcha/images/', 'imgUrl'=>$this->view->serverUrl.$this->view->baseUrl().'/public/css/captcha/images/', 'wordLen' => 4, 'fsize'=>20, 'height'=>60, 'width'=>250, 'gcFreq'=>50, 'expiration' => 300 ) )); */ $this->view->captcha = $captcha; } }
/** * @author : PhongTX - 10/08/2012 * @name : showAction * @copyright : FPT Online * @todo : Show Action */ public function showAction() { //Disable layout $this->_helper->layout->disableLayout(true); //Set no render view $this->_helper->viewRenderer->setNoRender(true); $wordlen = $this->_request->getParam('wordlen', '4'); $width = $this->_request->getParam('width', '60'); $height = $this->_request->getParam('height', '40'); $captcha_id = trim(strip_tags($this->_request->getParam('captcha_id'))); $captcha_id = !empty($captcha_id) ? $captcha_id : 'captchaID'; //captcha new object if (APPLICATION_ENV != 'development') { $captcha = new Fpt_Captcha_ImageMem(); } else { $captcha = new Zend_Captcha_Image(); } //Set lenght string captcha $captcha->setWordLen($wordlen); //Set time out $captcha->setTimeout('300'); //Set height image captcha $captcha->setHeight($height); //Set width image captcha $captcha->setWidth($width); //Set font captcha $captcha->setFontSize(14); $captcha->setDotNoiseLevel(0); $captcha->setLineNoiseLevel(0); if (APPLICATION_ENV != 'development') { //set image captcha url $captcha->setImgUrl($this->view->configView['url'] . '/captcha/viewimg/id'); } else { //Set dir folder image captcha $captcha->setImgDir(APPLICATION_PATH . '/../public/captcha'); //set image captcha url $captcha->setImgUrl($this->view->configView['url'] . '/captcha'); } //Set file font use captcha $captcha->setFont(APPLICATION_PATH . '/data/fonts/tahoma.ttf'); //set image captcha alt $captcha->setImgAlt('Mã xác nhận gửi bài viết đến tòa soạn'); //Generate captcha $captcha->generate(); //Render image captcha $image = $captcha->render(); // difine out captcha id $input = '<input type="hidden" name="' . $captcha_id . '" id="' . $captcha_id . '" value ="' . $captcha->getId() . '" />'; //Get word captcha $word = $captcha->getWord(); //set session word captcha $_SESSION['word'] = $word; //Define array response $arrResponse = array('html' => $image . $input); //Return data json echo Zend_Json::encode($arrResponse); exit; }
public function generateCaptcha() { //generate new captcha $path = APPLICATION_ROOT . '/public_html/images/captcha'; $captcha = new Zend_Captcha_Image(); $captcha->setDotNoiseLevel(4); $captcha->setLineNoiseLevel(4); $captcha->setTimeout(300)->setDotNoiseLevel(3)->setLineNoiseLevel(1)->setWidth(140)->setWordLen(5)->setHeight(36)->setFontSize(18)->setFont(APPLICATION_ROOT . '/application/var/fonts/BRLNSR.TTF')->setImgDir($path); $captcha->generate(); //command to generate session + create image return $captcha->getId(); //returns the ID given to session & image }