Ejemplo n.º 1
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;
     }
 }
 public function indexAction()
 {
     $emailValidator = new Zend_Validate_EmailAddress();
     $nameValidator = new Zend_Validate_NotEmpty(array(Zend_Validate_NotEmpty::STRING, Zend_Validate_NotEmpty::SPACE));
     $password1_Validator = new Zend_Validate();
     $password1_Validator->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))->addValidator(new Zend_Validate_Alnum());
     $password2_Validator = new Zend_Validate();
     $password2_Validator->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))->addValidator(new Zend_Validate_Alnum());
     $captcha = new Zend_Captcha_Image();
     $captcha->setName('captchaword')->setFont(APPLICATION_PATH . '/data/arial.ttf')->setFontSize(28)->setImgDir(APPLICATION_PATH . '/../public/img')->setImgUrl('/img')->setWordLen(5)->setDotNoiseLevel(20)->setExpiration(300);
     $request = $this->getRequest();
     $post = $request->getPost();
     // $passwordIdentical = new Zend_Validate_Identical(array('token' => $post['password1']));
     $messages = array();
     $error = array();
     $noValiError = true;
     if ($this->getRequest()->isPost()) {
         if (!$emailValidator->isValid($post['user-email'])) {
             $error['user-emailVali'] = '請輸入正確的Email帳號';
             $noValiError = false;
         }
         if (!$nameValidator->isValid($post['name'])) {
             $error['nameVali'] = '姓名必填';
             $noValiError = false;
         }
         if (!$password1_Validator->isValid($post['password1'])) {
             $error['password1_Vali'] = '1.密碼長度需介於6~12之間,而且只能使用數字、英文';
             $noValiError = false;
         }
         if (!$password2_Validator->isValid($post['password2'])) {
             $error['password2_Vali'] = '1.密碼長度需介於6~12之間,而且只能使用數字、英文';
             $noValiError = false;
         }
         if (isset($post['password1']) && isset($post['password2']) && !($post['password1'] == $post['password2'])) {
             $error['passwordIdentical'] = '2.密碼輸入不同';
             $noValiError = false;
         }
         if (!($post['agree'] == 1)) {
             $error['agreeVali'] = '需同意服務條款及隱私權政策,才可以註冊';
             $noValiError = false;
         }
         if (!$captcha->isValid($post['captchaword'])) {
             $error['captchawordVali'] = '認證碼輸入錯誤';
             $noValiError = false;
         }
         if ($noValiError) {
             // register process
             $this->_signup($post);
             $this->view->messages = $post;
             $this->redirect('index/index');
         } else {
             $this->_genCaptcha($captcha);
             $this->view->error = $error;
             $this->view->messages = $post;
         }
     } else {
         $this->_genCaptcha($captcha);
     }
 }
Ejemplo n.º 3
0
 private function _createCaptcha()
 {
     $captchaAdapter = new Zend_Captcha_Image();
     $captchaAdapter->setFont('./fonts/times.ttf')->setWordlen(5)->setLineNoiseLevel(4)->setDotNoiseLevel(20)->setMessage('Làm ơn nhập mã xác nhận.', 'badCaptcha');
     $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => $captchaAdapter));
     $captcha->setLabel('Mã xác nhận: ')->setRequired(true);
     $captcha = $this->_customizeFormElement($captcha);
     return $captcha;
 }
Ejemplo n.º 4
0
 public function onSubmit(array $data = array())
 {
     unset($data['enabled']);
     try {
         $captcha = new Zend_Captcha_Image($data);
         $captcha->render();
         $this->_data = $data;
         return true;
     } catch (Exception $e) {
         $this->getForm()->addError('Test failed: ' . $e->getMessage());
         return false;
     }
 }
Ejemplo n.º 5
0
 public function init()
 {
     /* Form Elements & Other Definitions Here ... */
     $emailAddress = $this->createElement('text', 'emailAddress');
     $emailAddress->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '40')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter your Email.'))))->addValidator('EmailAddress', false, array('messages' => array(Zend_Validate_EmailAddress::INVALID => 'Please enter a valid Host Name')))->addErrorMessage('Pleaes Enter Valid Email Address')->setValue('')->addFilter('StringToLower')->setRequired(true);
     $password = $this->createElement('password', 'password');
     $password->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '20')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter your Password.')), array('StringLength', false, array(6, 20, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => 'Your password is too short(>6).', Zend_Validate_StringLength::TOO_LONG => 'Your password is too long(<20).')))))->setRequired(true)->setValue('');
     $imageCaptcha = new Zend_Captcha_Image();
     $imageCaptcha->setWidth(120)->setWordlen(4)->setHeight(50)->setTimeout(900)->setFontSize(20)->setGcFreq(5)->setFont('Fonts/tahoma.ttf')->setImgDir('images/captcha/')->setImgUrl('/images/captcha/')->setDotNoiseLevel(0)->setLineNoiseLevel(0);
     $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => $imageCaptcha));
     $captcha->removeDecorator('Label')->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->setAttrib('style', 'position:relative;margin-top:20px')->setRequired(false);
     $login = $this->createElement('submit', 'login');
     $login->setLabel("")->removeDecorator('DtDdWrapper')->setAttrib('class', 'submitBtnLgn login')->setIgnore(true);
     $InvalidAttempts = $this->createElement('hidden', 'InvalidAttempts');
     $InvalidAttempts->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label');
     $this->addElements(array($emailAddress, $password, $captcha, $login, $InvalidAttempts));
 }
Ejemplo n.º 6
0
 /**
  * Validate captcha
  *
  * @return boolean
  */
 protected function _validateCaptcha()
 {
     $captcha = array('id' => $this->captcha->getId(), 'input' => $this->userCaptcha);
     if (!$this->captcha->isValid($captcha)) {
         $this->errors['captcha'] = $this->captcha->getMessages();
         return false;
     }
     return true;
 }
Ejemplo n.º 7
0
 public function init()
 {
     $contact = array();
     $contact[] = array('key' => 'email', 'value' => ' Email');
     $contact[] = array('key' => 'phone', 'value' => ' Phone');
     $this->setAttrib('enctype', 'multipart/form-data');
     $contactName = $this->createElement('text', 'contactName');
     $contactName->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '100')->setAttrib('class', 'input w90 required')->setAttrib('placeholder', 'Contact Name')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->setValue('')->setRequired(true);
     $address = $this->createElement('text', 'address');
     $address->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '500')->setAttrib('class', 'input w90')->setAttrib('placeholder', 'Address')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields')), array('StringLength', false, array(1, 500, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'address is too long(>510).')))))->setValue('')->setRequired(false);
     $city = $this->createElement('text', 'city');
     $city->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'input w90')->setAttrib('placeholder', 'City')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->addValidator('StringLength', false, array(1, 100))->setValue('')->setAttrib('maxlength', '100')->setRequired(false);
     $state = $this->createElement('text', 'state');
     $state->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'uinp1')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->addValidator('StringLength', false, array(1, 200))->setValue('')->setAttrib('maxlength', '200')->setRequired(false);
     $country = $this->createElement('text', 'country');
     $country->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'uinp1')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->addValidator('StringLength', false, array(1, 100))->setValue('')->setAttrib('maxlength', '100')->setRequired(false);
     $postalCode = $this->createElement('text', 'postalCode');
     $postalCode->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'uinp1')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->addValidator('StringLength', false, array(1, 10))->setValue('')->setAttrib('maxlength', '10')->setRequired(false);
     $phone = $this->createElement('text', 'phone');
     $phone->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'input w90')->setAttrib('placeholder', 'Phone')->setAttrib('maxlength', '15')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->setValue('')->setRequired(false);
     $emailAddress = $this->createElement('text', 'emailAddress');
     $emailAddress->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '40')->setAttrib('class', 'input w90')->setAttrib('placeholder', 'Email')->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields')), array('StringLength', false, array(5, 40))))->addValidator('EmailAddress')->addFilters(array('StringTrim'))->setRequired(true);
     $fax = $this->createElement('text', 'fax');
     $fax->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'uinp1')->setAttrib('maxlength', '15')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->setValue('')->setRequired(false);
     $website = $this->createElement('text', 'website');
     $website->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'uinp1')->setAttrib('maxlength', '255')->addFilters(array('StringTrim'))->setValue('')->setRequired(false);
     $moreinfo = $this->createElement('checkbox', 'moreinfo');
     $moreinfo->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'addcontact')->setRequired(false)->setChecked(false);
     $comments = $this->createElement('textarea', 'comments');
     $comments->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '1000')->setAttrib('rows', '3')->setAttrib('cols', '25')->setAttrib('class', 'input w90 textarea')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->setRequired(true);
     $imageCaptcha = new Zend_Captcha_Image();
     $imageCaptcha->setWidth(120)->setWordlen(4)->setHeight(50)->setTimeout(900)->setFontSize(20)->setGcFreq(5)->setFont('Fonts/tahoma.ttf')->setImgDir('images/captcha/')->setImgUrl('/images/captcha/')->setDotNoiseLevel(0)->setLineNoiseLevel(0);
     $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => $imageCaptcha));
     $captcha->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('style', 'position:relative;float:left; width:200px;');
     $contactType = new Zend_Form_Element_Radio('contactType');
     $contactType->removeDecorator('Label')->removeDecorator('HtmlTag')->setMultiOptions($contact)->setValue('email')->setSeparator('&nbsp;&nbsp;&nbsp;')->setRequired(false);
     $submit = $this->createElement('button', 'submit');
     $submit->removeDecorator('Label')->removeDecorator('DtDdWrapper')->setValue('Submit')->setAttrib('class', 'submitBtn')->setIgnore(true);
     $type = $this->createElement('hidden', 'type');
     $type->removeDecorator('HtmlTag')->removeDecorator('Label');
     $this->addElements(array($contactName, $address, $city, $state, $country, $postalCode, $phone, $emailAddress, $fax, $website, $moreinfo, $comments, $contactType, $type, $captcha, $submit));
 }
 /**
  * login page : 1. Validation 2. Login process
  */
 public function indexAction()
 {
     $passwordValidator = new Zend_Validate();
     $passwordValidator->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))->addValidator(new Zend_Validate_Alnum());
     $emailValidator = new Zend_Validate_EmailAddress();
     $captcha = new Zend_Captcha_Image();
     $captcha->setName('captchaword')->setFont(APPLICATION_PATH . '/data/arial.ttf')->setFontSize(28)->setImgDir(APPLICATION_PATH . '/../public/img')->setImgUrl('/img')->setWordLen(5)->setDotNoiseLevel(20)->setExpiration(300);
     $request = $this->getRequest();
     $post = $request->getPost();
     $messages = array();
     $noValiError = true;
     if ($this->getRequest()->isPost()) {
         if (!$passwordValidator->isValid($post['password'])) {
             $messages['passwordVali'] = '密碼長度需介於6~12之間,而且只能使用數字、英文';
             $noValiError = false;
         }
         if (!$emailValidator->isValid($post['user-email'])) {
             $messages['user-emailVali'] = '請輸入正確的Email帳號';
             $noValiError = false;
         }
         if (!$captcha->isValid($post['captchaword'])) {
             $messages['captchawordVali'] = '認證碼輸入錯誤';
             $noValiError = false;
         }
         $messages['password'] = $post['password'];
         $messages['user-email'] = $post['user-email'];
         if ($noValiError) {
             // login process
             $this->_checkAccount($post);
             $this->view->messages = $messages;
         } else {
             $this->_genCaptcha($captcha);
             $this->view->messages = $messages;
         }
     } else {
         $this->_genCaptcha($captcha);
     }
     if (Zend_Auth::getInstance()->hasIdentity() && $noValiError) {
         $this->redirect('index/index');
     }
 }
Ejemplo n.º 9
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);
 }
Ejemplo n.º 10
0
 /**
  * The constructor generates a Captcha image.
  *
  * @param int $dotNoise  The dot noise level. Default: 100.
  * @param int $lineNoise The line noise level. Default: 5.
  * @param int $wordLen   The length of the Captcha word. Default: 6.
  * @param int $timeout   The timeout in seconds. Default: 1800.
  * @return OSS_Captcha_Image
  */
 public function __construct($dotNoise = 100, $lineNoise = 5, $wordLen = 6, $timeout = 1800)
 {
     parent::__construct();
     $captchaDir = OSS_Utils::getTempDir() . '/captchas';
     if (!file_exists($captchaDir)) {
         mkdir($captchaDir, 0777, true);
     }
     if (strpos(dirname(__FILE__), 'src/') === false) {
         $font = dirname(__FILE__) . '/../../data/font/freeserif.ttf';
     } else {
         $font = dirname(__FILE__) . '/../../../data/font/freeserif.ttf';
     }
     $this->setTimeout($timeout)->setWordLen($wordLen)->setHeight(80)->setFont($font)->setFontSize(40)->setImgDir($captchaDir)->setDotNoiseLevel($dotNoise)->setLineNoiseLevel($lineNoise);
     return $this;
 }
Ejemplo n.º 11
0
 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);
 }
Ejemplo n.º 12
0
 public function captchaReloadAction()
 {
     $baseDir = $this->view->baseUrl();
     $captcha_image = new Zend_Captcha_Image(array('captcha' => 'Word', 'wordLen' => 6, 'height' => 50, 'width' => 150, 'timeout' => 600, 'dotNoiseLevel' => 0, 'lineNoiseLevel' => 0, 'font' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/fonts/ARIAL.TTF", 'imgDir' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/tmp", 'imgUrl' => "{$baseDir}/captcha/tmp"));
     $image = $captcha_image->generate();
     $captcha['id'] = $captcha_image->getId();
     $captcha['word'] = $captcha_image->getWord();
     $captcha['url'] = $captcha_image->getImgUrl() . $image . $captcha_image->getSuffix();
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     echo Zend_Json::encode($captcha);
 }
Ejemplo n.º 13
0
 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 &amp; image
 }
Ejemplo n.º 14
0
 public function indexAction()
 {
     $this->codeSession = new Zend_Session_Namespace('code');
     //在默认构造函数里实例化
     $captcha = new Zend_Captcha_Image(array('font' => APPLICATION_PATH . '/../public/fonts/ShadowsAroundUs.ttf', 'fontsize' => 24, 'imgdir' => './images/', 'session' => $this->codeSession, 'width' => 100, 'height' => 50, 'wordlen' => 5, 'LineNoiseLevel' => 0, 'DotNoiseLevel' => 20));
     //字母数
     $captcha->setExpiration(1);
     $captcha->setGcFreq(3);
     //设置删除生成的旧的验证码图片的随机几率
     $captcha->generate();
     //生成图片
     $this->view->ImgDir = $captcha->getImgDir();
     $this->view->captchaId = $captcha->getId();
     //获取文件名,md5编码
     $this->codeSession->code = $captcha->getWord();
     //获取当前生成的验证字符串
     $this->view->code = $this->codeSession->code;
 }
Ejemplo n.º 15
0
 function orderAction()
 {
     $yourCart = new Zend_Session_Namespace('cart');
     if ($this->_request->isPost()) {
         $itemProduct = $this->_arrParam['itemProduct'];
         if (count($itemProduct) > 0) {
             foreach ($itemProduct as $key => $val) {
                 if ($val == 0) {
                     unset($itemProduct[$key]);
                 }
             }
         }
         $yourCart->cart = $itemProduct;
     }
     //echo count ($yourCart->cart);
     $ssInfo = $yourCart->getIterator();
     //var_dump($ssInfo);
     $tblProduct = new Default_Model_Cart();
     $this->_arrParam['cart'] = $ssInfo['cart'];
     if (count($this->_arrParam['cart']) > 0) {
         $this->view->Items = $tblProduct->listcart($this->_arrParam);
         $this->view->cart = $ssInfo['cart'];
         $buy = "";
         foreach ($ssInfo['cart'] as $key => $val) {
             $item[] = $key;
             $demo[] = $val;
             //  echo $key;
             //  echo $val;
         }
         for ($i = 0; $i < count($ssInfo['cart']); $i++) {
             $id = $item[$i];
             $sl = $demo[$i];
             $buy = $buy . "{$id}" . "___" . "{$sl}" . "______";
         }
         $buy = substr($buy, 0, -6);
         // thanh toan
         $muser = new Default_Model_Cart();
         $captcha = new Zend_Captcha_Image();
         $vi = new Zend_View();
         $base = $vi->baseurl();
         if (!$this->_request->isPost()) {
             $captcha->setTimeout('300')->setWordLen('4')->setHeight('50')->setWidth('320')->setImgDir(APPLICATION_PATH . '/../public_html/captcha/images/')->setImgUrl($base . '/captcha/images/')->setFont(APPLICATION_PATH . '/../public_html/font/UTM-Avo.ttf');
             $captcha->generate();
             $this->view->captcha = $captcha->render($this->view);
             $this->view->captchaID = $captcha->getId();
             // Dua chuoi Captcha vao session
             $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captcha->getId());
             $captchaSession->word = $captcha->getWord();
         } else {
             $captchaID = $this->_request->captcha_id;
             $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaID);
             $captchaIterator = $captchaSession->getIterator();
             $captchaWord = $captchaIterator['word'];
             if ($this->_request->captcha == $captchaWord) {
                 $session = new Zend_Session_Namespace('identity');
                 $username = $session->username;
                 $this->view->purifier = Zend_Registry::get('purifier');
                 $conf = HTMLPurifier_Config::createDefault();
                 $purifier = new HTMLPurifier($conf);
                 $fullname = $purifier->purify($this->_request->getParam('fullname'));
                 $address = $purifier->purify($this->_request->getParam('address'));
                 $phone = $purifier->purify($this->_request->getParam('phone'));
                 $email = $purifier->purify($this->_request->getParam('email'));
                 $coment = $purifier->purify($this->_request->getParam('coment'));
                 $title = $purifier->purify($this->_request->getParam('title'));
                 $emaillh = "*****@*****.**";
                 $tinnhan = "\n\t\t\tHọ tên : {$fullname} <br>\n\t\t\tEmail : {$email}<br>\n\t\t\tĐịa chỉ : {$address}<br>\n\t\t\tĐiện thoại : {$phone}<br>\n\t\t\t\n\t\t\tNội dung : {$coment}<br>";
                 $to = $emaillh;
                 $subject = $title;
                 $message = $tinnhan;
                 $headers = 'Content-type: text/html;charset=utf-8';
                 mail($to, $subject, $message, $headers);
                 // Thiết lập SMTP Server
                 require 'ham/class.phpmailer.php';
                 require 'ham/class.pop3.php';
                 // nạp thư viện
                 $mailer = new PHPMailer();
                 // khởi tạo đối tượng
                 $mailer->IsSMTP();
                 // gọi class smtp để đăng nhập
                 $mailer->CharSet = "utf-8";
                 // bảng mã unicode
                 //Đăng nhập Gmail
                 $mailer->SMTPAuth = true;
                 // Đăng nhập
                 $mailer->SMTPSecure = "ssl";
                 // Giao thức SSL
                 $mailer->Host = "smtp.gmail.com";
                 // SMTP của GMAIL
                 $mailer->Port = 465;
                 // cổng SMTP
                 // Phải chỉnh sửa lại
                 $mailer->Username = "******";
                 // GMAIL username
                 $mailer->Password = "******";
                 // GMAIL password
                 $mailer->AddAddress("{$emaillh}", 'Recipient Name');
                 //email người nhận
                 // Chuẩn bị gửi thư nào
                 $mailer->FromName = "{$fullname}";
                 // tên người gửi
                 $mailer->From = "{$email}";
                 // mail người gửi
                 $mailer->Subject = "{$base}";
                 $mailer->IsHTML(true);
                 //Bật HTML không thích thì false
                 // Nội dung lá thư
                 $mailer->Body = "{$tinnhan}";
                 // Gửi email
                 if (!$mailer->Send()) {
                     // Gửi không được, đưa ra thông báo lỗi
                     echo "Không gửi được ";
                     echo "Lỗi: " . $mailer->ErrorInfo;
                 } else {
                     $muser->insert_order($address, $email, $phone, $coment, $username, $fullname, $buy);
                     Zend_Session::namespaceUnset('cart');
                     thongbao("Cảm ơn bạn đã liên hệ cho chúng tôi");
                     chuyen_trang($base);
                 }
             } else {
                 thongbao('Bạn nhập sai chuỗi Captcha');
                 trang_truoc();
             }
             $this->_helper->viewRenderer->setNoRender();
             $mask = APPLICATION_PATH . "/../public_html/captcha/images/*.png";
             array_map("unlink", glob($mask));
         }
     } else {
         //echo "Bạn chưa mua hàng";
     }
 }
Ejemplo n.º 16
0
 /**
  * @author      : VinhNT
  * @name        : ajaxsendmailAction
  * @copyright   : FPT Online
  * @todo        : ajaxsendmail Action
  * @return      : array('error' => 0, 'message' => '', 'body' => '')
  */
 public function ajaxsendmailAction()
 {
     //Disable layout
     $this->_helper->layout->disableLayout(true);
     //Set no render view
     $this->_helper->viewRenderer->setNoRender(true);
     //default return
     $response = array('error' => 0, 'message' => '');
     /* -----------------------------------------------------------------
         Get param sent to job send mail
        */
     try {
         $arrParams = $this->_request->getPost();
         //Trim captcha id
         $arrCaptcha['id'] = trim($arrParams['captchaID']);
         $arrCaptcha['input'] = trim($arrParams['txtCode']);
         // Creating a Zend_Captcha_Image instance
         $captcha = new Zend_Captcha_Image();
         // would be key/value array: id => captcha ID, input => captcha value
         if ($captcha->isValid($arrCaptcha)) {
             // Include config send mail
             include APPLICATION_PATH . '/configs/mail.php';
             //Check config sender
             if (is_array($configsender) && !empty($configsender)) {
                 // Get Url to send
                 $url_send = $arrParams['url'];
                 $url_send = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($url_send))));
                 $url_send = str_replace('http://thethao.vnexpress.net', 'http://seagames.vnexpress.net', $url_send);
                 // Get name of the sender
                 $sender_name = $arrParams['sender_name'];
                 $sender_name = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($sender_name))));
                 if (empty($sender_name)) {
                     $response['error'] = 1;
                     $response['message'] = 'Xin hãy nhập họ tên người gửi.';
                     echo Zend_Json::encode($response);
                     exit;
                 }
                 // Get user email
                 $email_user = $arrParams['email_user'];
                 $email_user = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($email_user))));
                 //Check email user
                 if (empty($email_user)) {
                     $response['error'] = 1;
                     $response['message'] = 'Xin hãy nhập email người gửi.';
                     echo Zend_Json::encode($response);
                     exit;
                 }
                 // Get title of send mail
                 $title_email = urldecode($arrParams['title_email']);
                 $title_email = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($title_email))));
                 //Set parrams email sender
                 $sender_email = $configsender['message']['email'];
                 // Get email of the reciever
                 $reciever_mail = $arrParams['receiver_mail'];
                 $reciever_mail = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($reciever_mail))));
                 //Check reciever mail
                 if (empty($reciever_mail)) {
                     $response['error'] = 1;
                     $response['message'] = 'Xin hãy nhập email người nhận.';
                     echo Zend_Json::encode($response);
                     exit;
                 }
                 // Get message mail
                 $message_mail = $arrParams['message_mail'];
                 $message_mail = trim(strip_tags($message_mail));
                 //Get body message
                 $body_message = '<strong>' . $sender_name . '(' . $email_user . ')</strong><br/>Đã gửi cho bạn bài báo tại link: <a href="' . $url_send . '" title="' . $title_email . '">' . $url_send . '</a>';
                 //Check message mail
                 if (!empty($message_mail)) {
                     $body_message .= '<br/>Với nội dung: </br>' . $message_mail;
                 }
                 $body_message .= '<hr><br/>Email này được gửi bằng tiện ích "Gửi cho bạn bè" của <b>SEAGames.VnExpress.net<b>';
                 //Get array mail
                 $arrEmail = explode(';', $reciever_mail);
                 $arrEmailReciever = array();
                 //Check array email
                 if (!empty($arrEmail)) {
                     foreach ($arrEmail as $email) {
                         $email = trim($email);
                         //If email is NOT valid
                         if (@(!eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)+\$", (string) $email))) {
                             //if (@!Fpt_Valid::isEmail($email))
                             continue;
                         }
                         //Put data to arrReciever
                         $arrEmailReciever[] = array('email' => $email, 'alias' => $email);
                     }
                     if (!empty($arrEmailReciever)) {
                         //push job call send mail
                         $jobParams = array('class' => 'Job_Thethao_JobMessage', 'function' => 'sendMail', 'args' => array('sender' => $sender_email, 'name' => 'VNE SEA Games', 'reciever' => $arrEmailReciever, 'subject' => $title_email, 'body' => $body_message));
                         //get application config
                         $config = Thethao_Global::getApplicationIni();
                         //To array
                         $jobConfiguration = $config['job']['task']['sport']['send_mail'];
                         //get job send mail instance
                         $jobClient = Thethao_Global::getJobClientInstance('sport');
                         //Register job
                         $result = $jobClient->doBackgroundTask($jobConfiguration, $jobParams);
                         if (!$result) {
                             $response['error'] = 1;
                             $response['message'] = 'Không gửi được email. Xin vui lòng thử lại sau.';
                             echo Zend_Json::encode($response);
                             exit;
                         } else {
                             $response['error'] = 0;
                             $response['message'] = 'Gửi email thành công.';
                             echo Zend_Json::encode($response);
                             exit;
                         }
                     } else {
                         $response['error'] = 1;
                         $response['message'] = 'Email gửi đến không hợp lệ';
                         echo Zend_Json::encode($response);
                         exit;
                     }
                 }
             } else {
                 $response['error'] = 1;
                 $response['message'] = 'Empty recipient.';
                 echo Zend_Json::encode($response);
                 exit;
             }
         } else {
             $response['error'] = 2;
             $response['message'] = 'Mã xác nhận không đúng.';
             echo Zend_Json::encode($response);
             exit;
         }
     } catch (Exception $ex) {
         // Log error
         Thethao_Global::sendLog($ex);
     }
     echo Zend_Json::encode($response);
     exit;
 }
Ejemplo n.º 17
0
 function postingAction()
 {
     $captcha = new Zend_Captcha_Image();
     $vi = new Zend_View();
     $base = $vi->baseurl();
     $muser = new Admin_Model_Page();
     $paginator = Zend_Paginator::factory($muser->option_page());
     $paginator->setItemCountPerPage(10);
     $paginator->setPageRange(10);
     $currentPage = $this->_request->getParam('page', 1);
     $paginator->setCurrentPageNumber($currentPage);
     $this->view->books = $paginator;
     $system = new Admin_Model_Category();
     $menu = $system->option_menu();
     $this->view->bookss = $menu;
     $district = $system->option_dictrict();
     $this->view->bokk = $district;
     if (!$this->_request->isPost()) {
         $captcha->setTimeout('300')->setWordLen('4')->setHeight('60')->setWidth('320')->setImgDir(APPLICATION_PATH . '/../public_html/captcha/images/')->setImgUrl($base . '/captcha/images/')->setFont(APPLICATION_PATH . '/../public_html/font/AHGBold.ttf')->setFontSize(24);
         $captcha->generate();
         $this->view->captcha = $captcha->render($this->view);
         $this->view->captchaID = $captcha->getId();
         // Dua chuoi Captcha vao session
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captcha->getId());
         $captchaSession->word = $captcha->getWord();
     } else {
         $captchaID = $this->_request->captcha_id;
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaID);
         $captchaIterator = $captchaSession->getIterator();
         $captchaWord = $captchaIterator['word'];
         if ($this->_request->captcha == $captchaWord) {
             $this->view->purifier = Zend_Registry::get('purifier');
             $conf = HTMLPurifier_Config::createDefault();
             $purifier = new HTMLPurifier($conf);
             $content = $purifier->purify($this->_request->getParam('content'));
             $menu_id = $purifier->purify($this->_request->getParam('parent_id'));
             $title = $purifier->purify($this->_request->getParam('title'));
             $dis = $purifier->purify($this->_request->getParam('dis'));
             $key = $purifier->purify($this->_request->getParam('key'));
             $description = $purifier->purify($this->_request->getParam('description'));
             // $home = $purifier->purify($this->_request->getParam('home'));
             $upload = new Zend_File_Transfer();
             $images = $upload->addValidator('Extension', false, 'jpg,png,gif');
             //print_r($images, FALSE) ;
             $images = $upload->getFilename();
             $images = basename($images);
             $url = khongdau($title);
             $random_digit = rand(00, 99999);
             if (basename($images)) {
                 $img = $url . "-" . $random_digit . $images;
                 $filterRename = new Zend_Filter_File_Rename(array('target' => 'Upload/' . $img, 'overwrite' => false));
                 $upload->addFilter($filterRename);
                 if (!$upload->receive()) {
                     thongbao("Vui lòng nhập đúng định dạng hình ảnh");
                     trang_truoc();
                     return;
                 }
                 $upload->receive();
             } else {
                 $img == "no-img.png";
             }
             // $position = $purifier->purify($this->_request->getParam('position'));
             //  $active = $purifier->purify($this->_request->getParam('active'));
             $price = $purifier->purify($this->_request->getParam('price'));
             $state = $purifier->purify($this->_request->getParam('state'));
             $sales = $purifier->purify($this->_request->getParam('sales'));
             $made_in = $purifier->purify($this->_request->getParam('made_in'));
             //$members = $purifier->purify($this->_request->getParam('members'));
             $session = new Zend_Session_Namespace('identity');
             $members = $session->username;
             $dictrict_id = $purifier->purify($this->_request->getParam('dictrict_id'));
             //  $type = $purifier->purify($this->_request->getParam('type'));
             $add = new Admin_Model_Products();
             $add->insert_products($title, $description, $img, $content, $menu_id, $price, $state, $sales, $dis, $key, "", 1, 2, $made_in, $members, $dictrict_id, 1);
             thongbao("Chúc mừng {$members}, bạn đã đăng tin thành công");
             chuyen_trang($base . "/thanh-vien.html");
         } else {
             thongbao('Ban nhap sai chuoi Captcha');
             trang_truoc();
         }
         $this->_helper->viewRenderer->setNoRender();
         $mask = APPLICATION_PATH . "/../public_html/captcha/images/*.png";
         array_map("unlink", glob($mask));
     }
 }
Ejemplo n.º 18
0
 public function init()
 {
     $passwordConfirm = new Rdine_Validate_PasswordConfirmation();
     $salutionList = array(array('key' => 'Mr', 'value' => 'Mr'), array('key' => 'Ms', 'value' => 'Ms'), array('key' => 'Mrs', 'value' => 'Mrs'));
     $gengerList = array(array('key' => 'Male', 'value' => 'Male'), array('key' => 'Female', 'value' => 'Female'));
     $emailAddress = $this->createElement('text', 'emailAddress');
     $emailAddress->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '40')->setAttrib('class', 'inp1')->setAttrib('placeholder', 'Email Address*')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter your EmailAddress.'))))->addValidator('StringLength', false, array(5, 50))->addValidator('EmailAddress', false, array('messages' => array(Zend_Validate_EmailAddress::INVALID => 'Please enter a valid Host Name')))->addErrorMessage('Pleaes Enter Valid Email Address')->addFilters(array('StringTrim'))->setValue('')->addFilter('StringToLower')->setRequired(true);
     $password = $this->createElement('password', 'password');
     $password->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '20')->setAttrib('class', 'inp1')->setAttrib('placeholder', 'Password*')->addValidators(array($passwordConfirm, array('NotEmpty', true, array('messages' => 'Please enter your Password.')), array('StringLength', false, array(6, 20, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => 'Your password is too short(>6).', Zend_Validate_StringLength::TOO_LONG => 'Your password is too long(<20).')))))->setRequired(true)->setValue('')->setIgnore(false);
     $confirmPassword = $this->createElement('password', 'password_confirm');
     $confirmPassword->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '20')->setAttrib('class', 'inp1')->setAttrib('placeholder', 'Confirm Password*')->addValidators(array($passwordConfirm, array('NotEmpty', true, array('messages' => 'Please enter confirm Password.'))))->setRequired(true)->setValue('')->setIgnore(false);
     $salution = $this->createElement('select', 'salution');
     $salution->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'sel2')->addMultiOptions($salutionList)->setRequired(false);
     $firstName = $this->createElement('text', 'firstName');
     $firstName->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '30')->setAttrib('class', 'inp1')->setAttrib('placeholder', 'First Name*')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter FirstName.')), array('Alnum')))->setValue('')->setRequired(true);
     $lastName = $this->createElement('text', 'lastName');
     $lastName->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '30')->setAttrib('class', 'inp1')->setAttrib('placeholder', 'Last Name')->addFilters(array('StringTrim'))->addValidators(array(array('StringLength', false, array(0, 30)), array('Alnum')))->setValue('')->setRequired(false);
     //        $gender = $this->createElement('select','gender');
     //        $gender->removeDecorator('Label')
     //        		->removeDecorator('HtmlTag')
     //        		->setAttrib('class', 'sel2')
     //                ->addMultiOptions($gengerList)
     //                ->setRequired(false);
     $address = $this->createElement('textarea', 'address', array('rows' => '1', 'cols' => '22'));
     $address->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '200')->setAttrib('class', 'inp1')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter your Address.'))))->addValidator('StringLength', false, array(1, 200, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => 'address should be minimum 10 charactors', Zend_Validate_StringLength::TOO_LONG => 'address is too long(>200).')))->addFilters(array('StringTrim'))->setValue('')->setRequired(false);
     //		$city = $this->createElement('select', 'city');
     //        $city->removeDecorator('Label')
     //        	 ->removeDecorator('HtmlTag')
     //        	 ->setAttrib('class', 'sel1')
     //        	 ->addValidators(array
     //        		 				  (array('NotEmpty', true, array('messages' => 'Please select City.'))))
     //        	 ->setRegisterInArrayValidator(false)
     //             ->setRequired(true);
     //
     //
     //        $neighborhood = $this->createElement('select','neighborhood');
     //        $neighborhood->removeDecorator('Label')
     //        			 ->removeDecorator('HtmlTag')
     //        			 ->setAttrib('class', 'sel1')
     //        			 ->addValidators(array
     //        		 				  (array('NotEmpty', true, array('messages' => 'Please select Neighborhood.'))))
     //        			 ->setRegisterInArrayValidator(false)
     //        			 ->setRequired(true);
     //
     //
     //		$region = $this->createElement('select','region');
     //        $region->removeDecorator('Label')
     //        	  ->removeDecorator('HtmlTag')
     //        	  ->setAttrib('class', 'sel1')
     //              ->addValidators(array
     //        		 				  (array('NotEmpty', true, array('messages' => 'Please select Region.'))))
     //        	  ->setRegisterInArrayValidator(false)
     //              ->setRequired(true);
     //
     //        $state = $this->createElement('select','state');
     //        $state->removeDecorator('Label')
     //        	  ->removeDecorator('HtmlTag')
     //        	  ->setAttrib('class', 'sel1')
     //              ->addValidators(array
     //        		 				  (array('NotEmpty', true, array('messages' => 'Please select State.'))))
     //        	  ->addMultiOptions($stateList)
     //              ->setRequired(true);
     //
     //        $timezone = $this->createElement('select','timezone');
     //        $timezone->removeDecorator('label')
     //        		 ->removeDecorator('HtmlTag')
     //        		 ->setAttrib('class','sel1')
     //        		 ->addValidators(array
     //        		 					 (array('NotEmpty', true, array('messages' => 'Please select TimeZone.'))))
     //        		 ->addMultiOptions($timezoneList)
     //        		 ->setRequired(true);
     $postalCode = $this->createElement('text', 'postalCode');
     $postalCode->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '10')->setAttrib('class', 'inp1')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter Zipcode.'))))->setValue('')->setRequired(false);
     $countryCode = $this->createElement('text', 'countryCode');
     $countryCode->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('style', 'width:116px; float:left')->setAttrib('placeholder', 'Code')->addFilters(array('StringTrim'))->setAttrib('placeholder', 'Code')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select country code.'))))->setValue('')->setAttrib('maxlength', '5')->setRequired(false);
     $phone = $this->createElement('text', 'phone');
     $phone->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('style', 'float:right;')->setAttrib('placeholder', 'Phone*')->setAttrib('maxlength', '15')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter Your Phone Number.'))))->addValidator('regex', false, array('pattern' => '/^[0-9 ]+$/', 'messages' => 'Enter a valid Phone Number'))->setValue('')->setRequired(false);
     $mobile = $this->createElement('text', 'mobile');
     $mobile->removeDecorator('Label')->removeDecorator('HtmlTag')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '15')->addFilters(array('StringTrim'))->setValue('');
     //        $favoritefood = $this->createElement('textArea', 'favoritefood');
     //        $favoritefood->removeDecorator('Label')
     //        		->removeDecorator('HtmlTag')
     //        		->setAttrib('maxlength', '1000')
     //        		->setAttrib('cols', '40')
     //			    ->setAttrib('rows', '4')
     //			    ->addFilters(array('StringTrim'))
     //        		->setValue('');
     //
     //        $favoritemusic =  $this->createElement('textArea', 'favoritemusic');
     //		$favoritemusic->removeDecorator('label')
     //					  ->removeDecorator('HtmlTag')
     //					  ->setAttrib('cols', '40')
     //			   		  ->setAttrib('rows', '4')
     //        			  ->setAttrib('maxlength', '1000')
     //        			  ->addFilters(array('StringTrim'))
     //        			  ->setvalue('')
     //        			  ->setrequired(false);
     $imageCaptcha = new Zend_Captcha_Image();
     $imageCaptcha->setWidth(120)->setWordlen(4)->setHeight(50)->setTimeout(900)->setFontSize(20)->setGcFreq(5)->setFont('Fonts/tahoma.ttf')->setImgDir('images/captcha/')->setImgUrl('/images/captcha/')->setDotNoiseLevel(0)->setLineNoiseLevel(0);
     $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => $imageCaptcha));
     $captcha->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->setAttrib('style', 'position:relative;margin-top:-10px;width:182px;');
     $register = $this->createElement('submit', 'register');
     $register->setLabel("Register")->removeDecorator('DtDdWrapper')->setAttrib('class', 'submitBtn')->setIgnore(true);
     $reset = $this->createElement('reset', 'reset');
     $reset->removeDecorator('Label')->removeDecorator('DtDdWrapper')->setLabel("Reset")->setAttrib('class', 'submitBtn')->setIgnore(true);
     $this->addElements(array($emailAddress, $password, $confirmPassword, $salution, $firstName, $lastName, $address, $postalCode, $phone, $countryCode, $mobile, $register, $reset, $captcha));
 }
Ejemplo n.º 19
0
 public function contentAction()
 {
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     $url = $this->_getParam('url');
     $proxy = new SxCms_Page_Proxy();
     $page = $proxy->getPageByUrl($url, null, $this->_getParam('lng', 'nl'));
     if ($page->getId() === false) {
         throw new Zend_Controller_Action_Exception('Page not found', 404);
     }
     $identity = Zend_Auth::getInstance()->getIdentity();
     if (!$page->isAllowed($identity)) {
         $this->_forward('unauthorized', 'index', null, array('url' => $this->view->url()));
         return;
     }
     if ($page->isExpired()) {
         throw new Zend_Controller_Action_Exception('Page expired', 404);
     }
     if ($page->getInvisible()) {
         throw new Zend_Controller_Action_Exception('Page expired', 404);
     }
     /** Gebruik Nederlandse vertaling indien nodig * */
     if ($page->hasContentFallback()) {
         $pageFallback = $proxy->getPageById($page->getId(), 'nl');
         $page->setContent($pageFallback->getContent());
     }
     $this->view->page = $page;
     $this->_helper->layout->setLayout($page->getLayout());
     if ($page->getType() == SxCms_Page::SUMMARY) {
         $children = $proxy->getPagesByParentId($page->getId(), null, $this->_getParam('lng', 'nl'), true, true);
         $childrenArr = array();
         foreach ($children as $child) {
             $pageFallback = false;
             if ($child->hasSummaryFallback()) {
                 $pageFallback = $proxy->getPageById($child->getId(), 'nl');
                 $child->setSummary($pageFallback->getSummary());
             }
             array_push($childrenArr, $child);
         }
         $this->view->children = $childrenArr;
         $this->renderScript('index/summary.phtml');
         return;
     }
     if ($page->getType() == SxCms_Page::ARTICLE) {
         $this->view->comment = new SxCms_Comment();
         $captchaSession = new Zend_Session_Namespace('captcha');
         $captchaSession->setExpirationHops(3);
         if ($captchaSession->token) {
             $captcha = $captchaSession->token;
         } else {
             $captcha = new Zend_Captcha_Image();
             $captcha->setName('captcha')->setWordLen(6)->setDotNoiseLevel(20)->setLineNoiseLevel(0)->setFont(APPLICATION_PATH . '/var/fonts/BRLNSR.TTF')->setImgDir(APPLICATION_ROOT . '/public_html/images/captcha');
             $captcha->generate();
             $captchaSession->token = $captcha;
         }
         $this->view->captcha = $captcha;
     }
     if ($page->getPageform()) {
         if ($this->getRequest()->isGet()) {
             $this->view->captchaId = $this->generateCaptcha();
         }
         $pageformproxy = new SxModule_Pageform_Proxy();
         $subscription = new SxModule_Pageform_Subscription();
         $pageform = $pageformproxy->getActiveById($page->getPageform(), $_SESSION['System']['lng']);
         $this->view->pageform = $pageform;
         if ($this->getRequest()->isPost() && $this->_getParam('comment-submit')) {
             $this->view->errors = array();
             $validator = new SxCms_Comment_BaseValidator();
             $validator->setCaptcha($captcha)->setUserCaptcha($this->_getParam('captcha'));
             $comment = new SxCms_Comment();
             $comment->setMessage($this->_getParam('message'));
             $author = new SxCms_Comment_Author();
             $author->setName($this->_getParam('name'))->setEmail($this->_getParam('email'))->setWebsite($this->_getParam('website'));
             $comment->setPage($page);
             $comment->setCommenter($author);
             if (!$validator->validate($comment)) {
                 $this->view->errors = $validator->getErrors();
                 $this->view->comment = $comment;
                 $this->view->userCaptcha = $this->_getParam('captcha');
             } else {
                 $mapper = new SxCms_Comment_DataMapper();
                 $mapper->save($comment);
                 $captchaSession->unsetAll();
                 $this->_helper->flashMessenger->addMessage('Uw bericht werd succcesvol verwerk.
                 Na goedkeuring door een administrator zal dit op de website verschijnen.');
                 $this->_helper->redirector->gotoRoute(array('url' => $page->getLink()), 'content');
             }
         }
         if ($this->getRequest()->isPost() && $this->_getParam('pageform-submit')) {
             $data = $this->_getParam('pageform');
             $subscription->setPageformId($pageform->getId())->setPageformname($pageform->getName())->setIp($this->getRequest()->getServer('REMOTE_ADDR'))->setAgent($this->getRequest()->getServer('HTTP_USER_AGENT'))->setLng($this->_getParam('lng'))->setUrl('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
             foreach ($pageform->getField() as $field) {
                 if (isset($data[$field->getKey()])) {
                     # Tijd instellen
                     if ($field->getFieldType() == 'text' && $field->getValidation() == 'time' && is_array($data[$field->getKey()])) {
                         $data[$field->getKey()] = $data[$field->getKey()]['hh'] . ':' . $data[$field->getKey()]['mm'];
                     }
                     # Tijd & datum instellen
                     if ($field->getFieldType() == 'text' && $field->getValidation() == 'datetime' && is_array($data[$field->getKey()])) {
                         $data[$field->getKey()] = $data[$field->getKey()]['date'] . ' ' . $data[$field->getKey()]['hh'] . ':' . $data[$field->getKey()]['mm'];
                     }
                 }
                 $metaObject = new SxModule_Pageform_Subscription_Meta();
                 $metaObject->setFieldId($field->getId())->setLabel($field->getTsl()->getName())->setName($field->getKey())->setValue(isset($data[$field->getKey()]) ? $data[$field->getKey()] : null);
                 $subscription->addMeta($metaObject);
             }
             $fielderrors = APPLICATION_ROOT . '/application/var/locale/fielderrors.tmx';
             $validator = new SxModule_Pageform_Subscription_Validator();
             $validator->setTmx(new Zend_Translate('tmx', $fielderrors, $_SESSION['System']['lng']));
             //$validator->setTmx( new Zend_Translate('tmx', APPLICATION_ROOT . '/application/var/locale/pageform.tmx', $_SESSION['System']['lng']) );
             $captchaOk = true;
             if ($pageform->getCaptcha()) {
                 $captchaOk = false;
                 $captcha = $this->_getParam('captcha');
                 if ($this->validateCaptcha($captcha)) {
                     $captchaOk = true;
                 }
             }
             $this->view->captchaId = $this->generateCaptcha();
             if ($captchaOk) {
                 if ($validator->validate($subscription, $pageform)) {
                     $subscription->save();
                     if ($pageform->getMailoption() == 1) {
                         $mail = new Zend_Mail('utf-8');
                         $mail->setSubject('Formulier verzonden op website: ' . $pageform->getName())->setFrom(Zend_Registry::get('config')->company->email, "formulier: " . $pageform->getName());
                         $body = 'Datum : ' . date('Y-m-d H:i:s') . "\n";
                         foreach ($subscription->getMeta() as $meta) {
                             $body .= " " . $meta->getLabel() . ": " . $meta->getValue() . "\n";
                         }
                         $mail->setBodyText($body);
                         $mail->addTo($pageform->getMailto());
                         $mail->send();
                     }
                     if ($pageform->getTsl()->getConfirm() == 1) {
                         foreach ($subscription->getMeta() as $meta) {
                             if ($meta->getLabel() == $pageform->getTsl()->getConfirmto()) {
                                 $sendto = $meta->getValue();
                             }
                         }
                         $mail = new Zend_Mail('utf-8');
                         $mail->setSubject($pageform->getTsl()->getConfirmsubject())->setFrom(Zend_Registry::get('config')->company->email, Zend_Registry::get('config')->company->name);
                         $mail->setBodyHtml($pageform->getTsl()->getConfirmcontent());
                         $mail->addTo($sendto);
                         $mail->send();
                     }
                     $subscription = new SxModule_Pageform_Subscription();
                     $this->view->message = "Formulier verzonden!";
                 } else {
                     $this->view->error = "Er ging iets mis...";
                     //var_dump($subscription->getMeta());
                     //exit;
                 }
             } else {
                 $this->view->error = "Neem de captcha code correct over...";
             }
         }
         $this->view->subscription = $subscription;
     }
     $this->view->mode = $this->_getParam('mode') ? $this->_getParam('mode') : '';
     $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Pageform_Subscription');
 }
 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";
     }
 }
Ejemplo n.º 21
0
 /**
  * Validate the word
  *
  * @see    Zend_Validate_Interface::isValid()
  * @param  mixed      $value
  * @param  array|null $context
  * @return boolean
  */
 public function isValid($value, $context = null)
 {
     $captchaValue = Zend_Controller_Front::getInstance()->getRequest()->getParam('captcha', array());
     return parent::isValid($captchaValue, $context);
 }
Ejemplo n.º 22
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;
 }
Ejemplo n.º 23
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;
 }
Ejemplo n.º 24
0
 /**
  * 制作验证图片
  *
  * @return arrya $captcha_all
  */
 public function makeCaptcha()
 {
     $captcha_all = array();
     // Originating request:
     $captcha = new Zend_Captcha_Image(array('session' => new Zend_Session_Namespace(), 'wordLen' => 4, 'width' => 155, 'height' => 50, 'timeout' => 300, 'font' => BOOT_PATH . '/others/fonts/MONACO.TTF', 'fontsize' => 24, 'imgDir' => BOOT_PATH . '/public/temp/', 'imgUrl' => PUBLIC_URL . 'temp/'));
     $captcha_id = $captcha->generate();
     $captcha_session = $captcha->getSession();
     $captcha_all['captcha_html'] = (string) $captcha->render();
     $captcha_all['captcha_id'] = $captcha_id;
     return $captcha_all;
 }
Ejemplo n.º 25
0
 public function init()
 {
     $stateMapper = new Application_Model_CountrybdMapper();
     $states = $stateMapper->fetchAll();
     $stateList = array();
     $stateList[] = array('key' => '', 'value' => 'Select Country');
     foreach ($states as $state) {
         $stateList[] = array('key' => $state->getId(), 'value' => $state->getDescription());
     }
     $stateList[] = array('key' => 'find', 'value' => 'cant find your Country');
     $sourceofrestaurantMapper = new Application_Model_SourceofRestaurantDataMapper();
     $sources = $sourceofrestaurantMapper->fetchAll();
     $sourceList = array();
     $sourceList[] = array('key' => '', 'value' => 'Select Source');
     foreach ($sources as $source) {
         $sourceList[] = array('key' => $source->getId(), 'value' => $source->getDescription());
     }
     $passwordConfirm = new Rdine_Validate_PasswordConfirmation();
     //  	$confirmEmail = new Rdine_Validate_EMailConfirmation();
     $emailAddress = $this->createElement('text', 'emailAddress');
     $emailAddress->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '40')->setAttrib('title', 'Email Address')->setAttrib('placeholder', 'Email Address*')->addValidator('NotEmpty', true, array('messages' => 'Please enter your EmailAddress.'))->addValidator('EmailAddress', false, array('messages' => array(Zend_Validate_EmailAddress::INVALID => 'Please enter a valid Host Name')))->addErrorMessage('Pleaes Enter Valid Email Address')->addFilters(array('StringTrim'))->setValue('')->addFilter('StringToLower')->setRequired(true);
     //	   $confirmEmailAdd = $this->createElement('text', 'confirmEmailAddress');
     //       $confirmEmailAdd->removeDecorator('Label')
     //        			->removeDecorator('HtmlTag')
     //        			->setAttrib('class','inp1')
     //        			->setAttrib('maxlength', '40')
     //        			->setAttrib('title', 'Confirm Email Address')
     //        			->setAttrib('placeholder', 'Confirm Email Address*')
     //                	->addValidators(array($confirmEmail,
     //                						  array('NotEmpty', true, array('messages' => 'Please confirm your EmailAddress.'))
     //                				))
     //                	->setValue('')
     //                	->addFilters(array('StringTrim'))
     //                	->addFilter('StringToLower')
     //                	->setRequired(true);
     $password = $this->createElement('password', 'password');
     $password->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '20')->setAttrib('title', 'Password')->setAttrib('placeholder', 'Password*')->addValidators(array($passwordConfirm, array('NotEmpty', true, array('messages' => 'Please enter your Password.')), array('StringLength', false, array(6, 20, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => 'Your password is too short(>6).', Zend_Validate_StringLength::TOO_LONG => 'Your password is too long(<20).')))))->setRequired(true)->setValue('');
     $confirmPassword = $this->createElement('password', 'password_confirm');
     $confirmPassword->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '20')->setAttrib('title', 'Confirm Password')->setAttrib('placeholder', 'Confirm Password*')->addValidators(array($passwordConfirm, array('NotEmpty', true, array('messages' => 'Please Confirm your password.'))))->setRequired(true)->setValue('');
     $firstName = $this->createElement('text', 'firstName');
     $firstName->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'First Name')->setAttrib('placeholder', 'First Name*')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter FirstName.')), array('StringLength', false, array(0, 30))))->setValue('')->setRequired(true);
     $lastName = $this->createElement('text', 'lastName');
     $lastName->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '30')->addFilters(array('StringTrim'))->setAttrib('title', 'Last Name')->setAttrib('placeholder', 'Last Name')->addValidators(array(array('StringLength', false, array(0, 30))))->setAttrib('class', 'inp1')->setValue('')->setRequired(false);
     $countryCode = $this->createElement('text', 'countryCode');
     $countryCode->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('style', 'width:116px; float:left')->setAttrib('readonly', 'readonly')->setAttrib('placeholder', 'Code')->setAttrib('title', 'Country Code')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select country code.'))))->setValue('')->setAttrib('maxlength', '5')->setRequired(false);
     $phone = $this->createElement('text', 'phone');
     $phone->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '10')->setAttrib('title', 'Phone')->setAttrib('style', 'width:325px; float:right;')->setAttrib('placeholder', 'Phone*')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter Your Phone Number.'))))->addValidator('regex', false, array('pattern' => '/^[0-9 ]+$/', 'messages' => 'Enter a valid Phone Number'))->setValue('')->setRequired(false);
     $rastaurantname = $this->createElement('text', 'restaurantName');
     $rastaurantname->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '225')->setAttrib('title', 'Restaurant/Group')->setAttrib('placeholder', 'Restaurant/Group*')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter RestaurantName.'))))->setvalue('')->setrequired(true);
     $resownercountry = $this->createElement('text', 'resownercountry');
     $resownercountry->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'Country')->setAttrib('placeholder', 'Country*')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter Country.')), array('StringLength', false, array(0, 30)), array('Alnum')))->setValue('')->setRequired(false);
     $resownercity = $this->createElement('text', 'resownercity');
     $resownercity->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'City')->setAttrib('placeholder', 'City*')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter City.')), array('StringLength', false, array(0, 30))))->setValue('')->setRequired(false);
     $resownerzipcode = $this->createElement('text', 'resownerzipcode');
     $resownerzipcode->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '10')->setAttrib('title', 'Zipcode')->setAttrib('placeholder', 'Zipcode')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter Zipcode.')), array('StringLength', false, array(0, 10)), array('Alnum')))->setValue('')->setRequired(false);
     $region = $this->createElement('select', 'region');
     $region->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'sel1')->setAttrib('title', 'State')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select Region.'))))->setRegisterInArrayValidator(false)->setRequired(true);
     $state = $this->createElement('select', 'state');
     $state->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'sel1')->setAttrib('title', 'Country')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select State.'))))->addMultiOptions($stateList)->setRequired(true);
     $source = $this->createElement('select', 'source');
     $source->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'sel1')->setAttrib('title', 'How did you hear about us?')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select source.'))))->addMultiOptions($sourceList)->setRequired(false);
     $sourcedescription = $this->createElement('textarea', 'sourcedescription');
     $sourcedescription->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '5000')->setAttrib('cols', '40')->setAttrib('rows', '4')->setAttrib('class', 'inp1')->setAttrib('title', 'Source Description')->setAttrib('placeholder', 'Would you like to provide more information')->setValue('')->addValidators(array(array('StringLength', false, array(1, 200, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Description is too long(>5000).')))))->setRequired(false);
     $city = $this->createElement('select', 'city');
     $city->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'sel1')->setAttrib('title', 'City')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select City.'))))->setRegisterInArrayValidator(false)->setRequired(true);
     $cantfind = $this->createElement('hidden', 'cantfind');
     $cantfind->removeDecorator('HtmlTag')->removeDecorator('Label');
     $cantfindcity = $this->createElement('text', 'cantfindcity');
     $cantfindcity->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'Cant Find City')->setAttrib('placeholder', 'Enter Your City')->addValidators(array(array('StringLength', false, array(0, 30))))->setValue('')->setRequired(false);
     $cantfindstate = $this->createElement('text', 'cantfindstate');
     $cantfindstate->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'Cant Find Country')->setAttrib('placeholder', 'Enter Your Country')->addValidators(array(array('StringLength', false, array(0, 30))))->setValue('')->setRequired(false);
     $cantfindregion = $this->createElement('text', 'cantfindregion');
     $cantfindregion->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'Cant Find State')->setAttrib('placeholder', 'Enter Your State')->addValidators(array(array('StringLength', false, array(0, 30))))->setValue('')->setRequired(false);
     $description = $this->createElement('textarea', 'description');
     $description->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '5000')->setAttrib('cols', '40')->setAttrib('rows', '4')->setAttrib('class', 'inp1')->setAttrib('title', 'Description')->setAttrib('placeholder', 'Enter your comments')->setValue('')->addValidators(array(array('StringLength', false, array(1, 5000, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Description is too long(>5000).')))))->setRequired(false);
     $website = $this->createElement('text', 'website');
     $website->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'Website')->setAttrib('placeholder', 'Website')->addValidators(array(array('StringLength', false, array(0, 30))))->setValue('')->setRequired(false);
     $dateofbirth = $this->createElement('text', 'dateofbirth');
     $dateofbirth->removeDecorator('Label')->setAttrib('class', 'inp1 datepicker')->removeDecorator('HtmlTag')->setAttrib('title', 'Date of Birth')->setAttrib('placeholder', 'Date of Birth')->addFilters(array('StringTrim'))->setValue('');
     $imageCaptcha = new Zend_Captcha_Image();
     $imageCaptcha->setWidth(200)->setWordlen(4)->setHeight(50)->setTimeout(900)->setFontSize(20)->setGcFreq(5)->setFont('Fonts/tahoma.ttf')->setImgDir('images/captcha/')->setImgUrl('/images/captcha/')->setDotNoiseLevel(0)->setLineNoiseLevel(0);
     $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => $imageCaptcha));
     $captcha->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->setAttrib('title', 'Captcha')->setAttrib('placeholder', 'Enter characters as shown in box *')->setAttrib('style', 'position:relative;margin-top:-10px;width:182px;');
     $register = $this->createElement('submit', 'register');
     $register->setLabel("Register")->removeDecorator('DtDdWrapper')->setAttrib('class', 'submitBtn')->setIgnore(true);
     $reset = $this->createElement('reset', 'reset');
     $reset->removeDecorator('Label')->removeDecorator('DtDdWrapper')->setLabel("Reset")->setAttrib('class', 'submitBtn')->setIgnore(true);
     $comapnyid = $this->createElement('hidden', 'comapnyid');
     $comapnyid->removeDecorator('HtmlTag')->removeDecorator('Label')->removeDecorator('DtDdWrapper');
     $this->addElements(array($firstName, $lastName, $emailAddress, $password, $confirmPassword, $rastaurantname, $description, $phone, $source, $sourcedescription, $website, $dateofbirth, $register, $reset, $captcha, $comapnyid, $countryCode, $resownercity, $resownerzipcode));
 }
Ejemplo n.º 26
0
 function contactAction()
 {
     $muser = new Default_Model_System();
     $conten = $muser->list_system();
     $this->view->book = $conten;
     $captcha = new Zend_Captcha_Image();
     $vi = new Zend_View();
     $base = $vi->baseurl();
     if (!$this->_request->isPost()) {
         $captcha->setTimeout('300')->setWordLen('4')->setHeight('50')->setWidth('320')->setImgDir(APPLICATION_PATH . '/../captcha/images/')->setImgUrl($base . '/captcha/images/')->setFont(APPLICATION_PATH . '/../font/UTM-Avo.ttf');
         $captcha->generate();
         $this->view->captcha = $captcha->render($this->view);
         $this->view->captchaID = $captcha->getId();
         // Dua chuoi Captcha vao session
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captcha->getId());
         $captchaSession->word = $captcha->getWord();
     } else {
         $captchaID = $this->_request->captcha_id;
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaID);
         $captchaIterator = $captchaSession->getIterator();
         $captchaWord = $captchaIterator['word'];
         if ($this->_request->captcha == $captchaWord) {
             $this->view->purifier = Zend_Registry::get('purifier');
             $conf = HTMLPurifier_Config::createDefault();
             $purifier = new HTMLPurifier($conf);
             $fullname = $purifier->purify($this->_request->getParam('fullname'));
             $address = $purifier->purify($this->_request->getParam('address'));
             $phone = $purifier->purify($this->_request->getParam('phone'));
             $email = $purifier->purify($this->_request->getParam('email'));
             $content = $purifier->purify($this->_request->getParam('content'));
             $title = $purifier->purify($this->_request->getParam('title'));
             $emaillh = $purifier->purify($this->_request->getParam('emaillh'));
             $tinnhan = "\n\t\t\tHọ tên : {$fullname} <br>\n\t\t\tEmail : {$email}<br>\n\t\t\tĐịa chỉ : {$address}<br>\n\t\t\tĐiện thoại : {$phone}<br>\n\t\t\t\n\t\t\tNội dung : {$content}<br>";
             $to = $emaillh;
             $subject = $title;
             $message = $tinnhan;
             $headers = 'Content-type: text/html;charset=utf-8';
             // mail($to, $subject, $message, $headers);
             //$html ="<img title=\"夕食:ル・バンドーム(フランス料理)\" alt=\"夕食:ル・バンドーム(フランス料理)\" src=\"http://toursystem.biz/uploads/product/1378725993LE_VENDOME_12.jpg\">";
             //         $mail = new Zend_Mail('UTF-8');
             //          $mail->setBodyHtml("$tinnhan");
             //          $mail->setFrom("$email", "$title");
             //          $mail->addTo("*****@*****.**", 'Ly Le');
             //          $mail->addTo("$emaillh", "$fullname");
             //          $mail->setSubject("Thông tin liên hệ  ngày  : ".date("F j, Y"));
             //          $mail->send();
             // Thiết lập SMTP Server
             require 'ham/class.phpmailer.php';
             require 'ham/class.pop3.php';
             // nạp thư viện
             $mailer = new PHPMailer();
             // khởi tạo đối tượng
             $mailer->IsSMTP();
             // gọi class smtp để đăng nhập
             $mailer->CharSet = "utf-8";
             // bảng mã unicode
             //Đăng nhập Gmail
             $mailer->SMTPAuth = true;
             // Đăng nhập
             $mailer->SMTPSecure = "ssl";
             // Giao thức SSL
             $mailer->Host = "smtp.gmail.com";
             // SMTP của GMAIL
             $mailer->Port = 465;
             // cổng SMTP
             // Phải chỉnh sửa lại
             $mailer->Username = "******";
             // GMAIL username
             $mailer->Password = "******";
             // GMAIL password
             $mailer->AddAddress("{$emaillh}", 'Recipient Name');
             //email người nhận
             // Chuẩn bị gửi thư nào
             $mailer->FromName = "{$fullname}";
             // tên người gửi
             $mailer->From = "{$email}";
             // mail người gửi
             $mailer->Subject = "{$base}";
             $mailer->IsHTML(true);
             //Bật HTML không thích thì false
             // Nội dung lá thư
             $mailer->Body = "{$tinnhan}";
             // Gửi email
             if (!$mailer->Send()) {
                 // Gửi không được, đưa ra thông báo lỗi
                 echo "Không gửi được ";
                 echo "Lỗi: " . $mailer->ErrorInfo;
             } else {
                 $muser->contact($fullname, $address, $phone, $email, $title, $content);
                 thongbao("Cảm ơn bạn đã liên hệ cho chúng tôi");
                 trangtruoc();
             }
         } else {
             thongbao('Bạn nhập sai chuỗi Captcha');
             trang_truoc();
         }
         $this->_helper->viewRenderer->setNoRender();
         $mask = APPLICATION_PATH . "/../captcha/images/*.png";
         array_map("unlink", glob($mask));
     }
 }
Ejemplo n.º 27
0
 /**
  * Generate new captcha session occurrence and image
  *
  * @static
  * @return string new captcha id
  */
 public static function generateCaptcha()
 {
     $websiteHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('website');
     $captcha = new Zend_Captcha_Image();
     return $captcha->setTimeout('300')->setWordLen('5')->setHeight(45)->setFont($websiteHelper->getPath() . 'system/fonts/Alcohole.ttf')->setImgDir($websiteHelper->getPath() . $websiteHelper->getTmp())->setFontSize(20)->setDotNoiseLevel(0)->setLineNoiseLevel(0)->generate();
 }
Ejemplo n.º 28
0
 public function viewAction()
 {
     $id = $this->_request->getParam('id');
     $captchaCode = $this->_request->getParam('captcha_code');
     $modelBlog = new Page();
     $blog = $modelBlog->getPage($id);
     if ($blog) {
         $this->view->blog = $blog;
         // tags
         $modelTags = new Tags();
         $where = array('blog_id' => $id);
         $tags = $modelTags->getTags($where);
         if ($tags) {
             $this->view->tags = $tags;
         }
         // 评论
         $modelComment = new Comment();
         $comments = $modelComment->getComments($id);
         $this->view->comments = $comments;
         $dataComment = $this->_request->getPost();
         // 获取表单提交值
         if ($dataComment) {
             if ($dataComment['captcha'] == $captchaCode) {
                 // 定义过滤规则
                 $filters = array('name' => array('StringTrim'), 'comment' => 'StripTags');
                 // 定义验证规则
                 $validators = array('name' => array(array('StringLength', 3, 16), 'NotEmpty', Zend_Filter_Input::MESSAGES => array(array(Zend_Validate_StringLength::INVALID => "请输入一个合法的字符串", Zend_Validate_StringLength::TOO_SHORT => "请输入字符长度为3-16", Zend_Validate_StringLength::TOO_LONG => "请输入字符长度为3-16"))), 'email' => array('EmailAddress', Zend_Filter_Input::MESSAGES => array(array(Zend_Validate_EmailAddress::INVALID_FORMAT => "邮件格式不正确,请重新输入。"))), 'comment' => array());
                 // 实例化过滤器并进行过滤验证
                 $data = $_POST;
                 $filterPost = new Zend_Filter_Input($filters, $validators, $data);
                 if ($filterPost->hasInvalid() || $filterPost->hasMissing()) {
                     $messages = $filterPost->getMessages();
                     foreach ($messages as $message) {
                         foreach ($message as $value) {
                             echo $value . "<br />";
                         }
                     }
                 }
                 // 将经过验证的数据写入数据库
                 $modelComment = new Comment();
                 $newComment = $modelComment->createComment($pid = $id, $filterPost->name, $filterPost->email, $filterPost->comment);
                 if ($newComment) {
                     $this->_redirect('/blog/view/id/' . $id);
                 } else {
                     echo "评论提交出错!";
                 }
             } else {
                 echo "验证码错误,请刷新后重新输入。";
             }
         }
         // 生成验证码
         $this->captcha_session = new Zend_Session_Namespace('captcha');
         //在默认构造函数里实例化
         $captcha = new Zend_Captcha_Image(array('font' => 'images/SIMYOU.TTF', 'session' => $this->captcha_session, 'fontsize' => 15, 'imgdir' => 'images/code/', 'width' => 120, 'height' => 30, 'gcFreq' => 3, 'dotNoiseLevel' => 5, 'lineNoiseLevel' => 1, 'wordlen' => 4));
         $captcha->generate();
         // 生成图片
         // 界面方式
         $this->view->img_dir = $captcha->getImgDir();
         $this->view->captcha_id = $captcha->getId();
         //图片文件名,md5编码
         $this->view->captcha_code = $captcha->getWord();
         $this->view->id = $id;
     } else {
         echo "该博客文章不存在!";
     }
 }
Ejemplo n.º 29
0
 function contactAction()
 {
     $muser = new Default_Model_System();
     $conten = $muser->list_system();
     $this->view->book = $conten;
     $captcha = new Zend_Captcha_Image();
     $vi = new Zend_View();
     $base = $vi->baseUrl();
     if (!$this->_request->isPost()) {
         $captcha->setTimeout('300')->setWordLen('4')->setHeight('50')->setWidth('200')->setImgDir(APPLICATION_PATH . '/../captcha/images/')->setImgUrl($base . '/captcha/images/')->setFont(APPLICATION_PATH . '/../font/UTM-Avo.ttf');
         $captcha->generate();
         $this->view->captcha = $captcha->render($this->view);
         $this->view->captchaID = $captcha->getId();
         // Dua chuoi Captcha vao session
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captcha->getId());
         $captchaSession->word = $captcha->getWord();
     } else {
         $captchaID = $this->_request->captcha_id;
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaID);
         $captchaIterator = $captchaSession->getIterator();
         $captchaWord = $captchaIterator['word'];
         if ($this->_request->captcha == $captchaWord) {
             $this->view->purifier = Zend_Registry::get('purifier');
             $conf = HTMLPurifier_Config::createDefault();
             $purifier = new HTMLPurifier($conf);
             $fullname = $purifier->purify($this->_request->getParam('fullname'));
             $address = $purifier->purify($this->_request->getParam('address'));
             $phone = $purifier->purify($this->_request->getParam('phone'));
             $email = $purifier->purify($this->_request->getParam('email'));
             $content = $purifier->purify($this->_request->getParam('content'));
             $title = $purifier->purify($this->_request->getParam('title'));
             $emaillh = $conten[0]['email'];
             $tinnhan = "\n\t\t\tHọ tên : {$fullname} <br>\n\t\t\tEmail : {$email}<br>\n\t\t\tĐịa chỉ : {$address}<br>\n\t\t\tĐiện thoại : {$phone}<br>\n\t\t\t\n\t\t\tNội dung : {$content}<br>";
             require 'ham/class.phpmailer.php';
             require 'ham/class.pop3.php';
             // nạp thư viện
             $mail = new PHPMailer();
             // khởi tạo đối tượng
             $mail->IsSMTP();
             // gọi class smtp để đăng nhập
             $mail->CharSet = "utf-8";
             // bảng mã unicode
             //Đăng nhập Gmail
             $mail->SMTPAuth = true;
             // Đăng nhập
             $mail->SMTPSecure = "ssl";
             // Giao thức SSL
             $mail->Host = "smtp.gmail.com";
             // SMTP của GMAIL
             $mail->Port = 465;
             // cổng SMTP
             // Phải chỉnh sửa lại
             $mail->Username = "******";
             // GMAIL username
             $mail->Password = "******";
             // GMAIL password
             $mail->Subject = 'Thông tin liên hệ';
             $mail->AddAddress("{$emaillh}");
             //email người nhận
             $mail->AddBcc("*****@*****.**");
             // Chuẩn bị gửi thư nào
             $mail->FromName = mb_convert_encoding($fullname, "UTF-8", "auto");
             // tên người gửi
             $mail->From = "{$email}";
             // mail người gửi
             $mail->IsHTML(true);
             //Bật HTML không thích thì false
             // Nội dung lá thư
             $mail->Body = "{$tinnhan}";
             // Gửi email
             if ($mail->Send()) {
                 // Gửi không được, đưa ra thông báo lỗi
                 $muser->contact($fullname, $address, $phone, $email, $title, $content);
                 thongbao("Cảm ơn bạn đã liên hệ cho chúng tôi");
                 trangtruoc();
             } else {
                 echo "Không gửi được ";
                 echo "Lỗi: " . $mail->ErrorInfo;
             }
         } else {
             thongbao('Bạn nhập sai chuỗi Captcha');
             trang_truoc();
         }
         $this->_helper->viewRenderer->setNoRender();
         $mask = APPLICATION_PATH . "/../captcha/images/*.png";
         array_map("unlink", glob($mask));
     }
 }