예제 #1
0
 /**
  * @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;
 }
예제 #2
0
 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;
     }
 }
예제 #3
0
파일: Sonda.php 프로젝트: hYOUstone/tsg
 public function init()
 {
     $Ankieta = new Application_Model_DbTable_AnkietyPytania();
     $select = $Ankieta->select(array('id', 'pytanie', 'czy_obrazek'))->where('czy_wyswietlac = ?', 't')->where('sekcja = ?', 'lewa')->where('rodzaj = ?', 'normal')->order('kolejnosc DESC')->order('data_dodania DESC')->order('pytanie ASC')->limit(1);
     //echo $select->__toString();
     $ankieda = $Ankieta->fetchAll($select);
     foreach ($ankieda as $pytanie) {
         $pytania_id[] = $pytanie->id;
         $pytania[] = $pytanie->pytanie;
         $odpowiedziFetch = $pytanie->findApplication_Model_DbTable_AnkietyOdpowiedzi();
         // sortowanie
         $odpowiedziArray = $odpowiedziFetch->toArray();
         usort($odpowiedziArray, create_function('$a, $b', 'if ($a["kolejnosc"] == $b["kolejnosc"]) return 0; return ($a["kolejnosc"] < $b["kolejnosc"]) ? -1 : 1;'));
         // usort($odpowiedziArray, sort_answers($a, $b){
         // return strcmp($a["kolejnosc"], $b["kolejnosc"]);
         // });// sort
         foreach ($odpowiedziArray as $odpowiedz) {
             $odpowiedzi_id[] = $odpowiedz['id'];
             $odpowiedzi[] = $odpowiedz['odpowiedz'];
         }
     }
     $this->addElement('hidden', 'plaintext', array('description' => '<dt id="odpowiedzi-label"><h3 class="tytul">' . $pytania[0] . '</h3></dt>', 'decorators' => array(array('Description', array('escape' => false, 'tag' => '')))));
     $kontrolkaRadio = new Zend_Form_Element_Radio("odpowiedzi[]", array('multiOptions' => array_combine($odpowiedzi_id, $odpowiedzi), 'registerInArrayValidator' => false, 'validators' => array('NotEmpty' => array('validator' => 'NotEmpty', 'options' => array('messages' => 'Musisz wybrać jedną odpowiedź.')))));
     $kontrolkaRadio->setRequired(true);
     $kontrolkaRadio->removeDecorator('Label');
     $kontrolkaRadio->setSeparator(false);
     $this->addElement($kontrolkaRadio);
     if ($ankieda[0]->czy_obrazek == 't') {
         //first create an image type captcha
         $captchaimg = new Zend_Captcha_Image('captchaimg');
         $captchaimg->setFont(APPLICATION_PATH . '/../public/images/tresci/captcha/Tahoma.ttf');
         $captchaimg->setImgDir(APPLICATION_PATH . '/../public/images/tresci/captcha');
         $captchaimg->setImgUrl('/images/tresci/captcha');
         $captchaimg->setWordlen('5');
         $captchaimg->setMessages(array('badCaptcha' => 'Wpisany kod jest nieprawidłowy'));
         //            $captchaimg->generate();
         //create user input for captcha and include the captchaimg in form
         $adcaptcha = new Zend_Form_Element_Captcha('adcaptcha', array('captcha' => $captchaimg));
         $adcaptcha->setLabel('Wpisz kod z obrazka:');
         $adcaptcha->setRequired(true);
         $this->addElement($adcaptcha);
     }
     $kontrolkaSubmit = new Zend_Form_Element_Submit("submit", "Głosuj");
     //        $kontrolkaSubmit->removeDecorator('DtDdWrapper');
     //        $kontrolkaSubmit->setAttribs(array('style' => 'margin-left:130px;'));
     $kontrolkaSubmit->removeDecorator('Label');
     $this->addElement($kontrolkaSubmit);
     $this->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'sonda-content')), array('Form', array('class' => 'sonda-form'))));
     //echo $pytania_id[0];
     $this->setMethod('post');
     //$url = $view->url(array('controller' => 'sonda', 'action' => 'edit', 'id' => $pytania_id[0]), 'default');
     $url = $this->getView()->url(array('controller' => 'sonda', 'action' => 'edit', 'id' => $pytania_id[0]), 'default');
     $this->setAction($url);
 }
예제 #4
0
 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);
 }
예제 #5
0
 /**
  *
  * @return \Zend_Captcha_Image
  */
 private function getImageCaptcha()
 {
     self::initSessionConfig();
     $appPath = APP_PATH;
     $captcha = new \Zend_Captcha_Image();
     $captcha->setSession($this->getSession());
     $captcha->setKeepSession(true);
     $captcha->setFont($appPath . '/data/fonts/consola.ttf');
     $captcha->setImgDir(dirname($appPath) . '/public/_captcha');
     $captcha->setImgUrl('/_captcha');
     $captcha->setExpiration(600);
     $captcha->setWordlen(5);
     $captcha->setUseNumbers(false);
     return $captcha;
 }
 public function profileAction()
 {
     $handle = $this->_request->getParam('handle');
     $this->view->headTitle("Gamer Profile: {$handle}");
     $user = new Default_Model_User();
     $this->view->gamer = $user->getUserByHandle($handle);
     if (!isset($this->view->gamer->id)) {
         $this->view->errors = "This user does not exist.";
         return;
     }
     //Determine gender for outputting phrase
     $gender = $this->view->gamer->gender == 'm' ? 'his' : 'her';
     //Google MAP
     $this->view->map->setHeight(300);
     $this->view->map->setWidth(300);
     $this->view->map->disableMapControls();
     $coords = $this->view->map->getGeocode($this->view->gamer->address);
     $this->view->map->setCenterCoords($coords['lon'], $coords['lat']);
     $this->view->map->addMarkerByAddress($this->view->gamer->address, "This is {$gender} place!");
     $this->view->map->disableDirections();
     $this->view->map->setZoomLevel(14);
     //Get list of friends based on user handle
     $this->view->friends = $this->view->gamer->getFriends();
     //Display invitation if user is logged
     $this->view->loggedEmail = $this->loggedEmail;
     //Insert user_id of logged user that's going to comment on profile
     $this->view->loggedId = $this->loggedId;
     //Insert handle of logged user for removing comment
     $this->view->loggedHandle = $this->loggedHandle;
     //get current page
     $currpage = $this->getRequest()->getQuery('page');
     $paginationCount = 3;
     //Get list of comments
     $comment = new Default_Model_Comment();
     $this->view->comments = $comment->getUserComments($this->view->gamer->id, $paginationCount, $currpage);
     $session = new Zend_Session_Namespace('captcha');
     if (isset($session->phrase)) {
         $phrase = $session->phrase;
     }
     //generate captcha
     $captcha = new Zend_Captcha_Image(array('wordLen' => 5));
     $captcha->setFont("game\\library\\data\\VeraBd.ttf");
     $captcha->setImgDir("game\\public\\images");
     $captcha->setImgUrl($this->view->siteWideProperty . "/images/");
     $captcha->generate();
     $session->phrase = $captcha->getWord();
     $this->view->captcha = $captcha->render($this->view);
     if ($this->getRequest()->getQuery('captchaerr')) {
         $this->view->captchaerr = 1;
         $this->view->errors[] = "Invalid captcha";
     }
 }