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 init() { $subForm = new Zend_Form_SubForm(); $subForm->setLegend('adsFields'); $validateNonZeroValue = new Zend_Validate_GreaterThan(0); $validateDate = new Zend_Validate_Date('Y-m-d'); $elementUserId = new Zend_Form_Element_Hidden('user_id'); $elementLanguageId = new Zend_Form_Element_Hidden('language_id'); $elementActive = new Zend_Form_Element_Hidden('active'); $elementActive->setValue(1); $elementAdsCategoryId = new Zend_Form_Element_Select('ads_category_id'); $elementAdsCategoryId->setLabel('adsCategoryId'); $elementAdsCategoryId->setMultiOptions(Ads_Categories::getSelectOptions()); $elementAdsCategoryId->addValidator($validateNonZeroValue); $elementAdsCategoryId->setRequired(true); $elementAdsTypeId = new Zend_Form_Element_Select('ads_type_id'); $elementAdsTypeId->setLabel('adsTypeId'); $elementAdsTypeId->setMultiOptions(Ads_Types::getSelectOptions()); $elementAdsTypeId->addValidator($validateNonZeroValue); $elementAdsTypeId->setRequired(true); $elementValidBefore = new Standart_Form_Element_Date('valid_until'); $elementValidBefore->setLabel('adsValidUntil'); $elementValidBefore->addValidator($validateDate); $elementValidBefore->setRequired(true); $elementTitle = new Zend_Form_Element_Text('title'); $elementTitle->setLabel('adsTitle'); $elementTitle->setAttrib('size', 75); $elementTitle->setRequired(true); $elementDescription = new Zend_Form_Element_Textarea('description'); $elementDescription->setLabel('adsDescription'); $elementDescription->setRequired(true); $captchaImage = new Zend_Captcha_Image(); $captchaImage->setFont(Standart_Main::getDirs('fonts', 'arial.ttf')); $captchaImage->setFontSize(30); $captchaImage->setWordlen(6); $captchaImage->setImgDir(Standart_Main::getDirs('wwwStatic', array('images', 'captcha'))); $captchaImage->setImgUrl(Zend_Registry::get('config')->host->static . '/images/captcha/'); $captchaImage->setWidth(175); $captchaImage->setHeight(75); $captchaImage->setName('captcha'); $elementCaptcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => $captchaImage)); $elementDoSave = new Zend_Form_Element_Submit('doSave'); $subForm->addElements(array($elementUserId, $elementLanguageId, $elementActive, $elementAdsCategoryId, $elementAdsTypeId, $elementValidBefore, $elementTitle, $elementDescription, $elementCaptcha)); $this->addSubForm($subForm, 'ads'); $this->addElement($elementDoSave); }