• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Validate_Alnum类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Zend_Validate_Alnum的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Alnum类的具体用法?PHP Zend_Validate_Alnum怎么用?PHP Zend_Validate_Alnum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Zend_Validate_Alnum类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: init

 public function init()
 {
     // валидаторы
     $alnum = new Zend_Validate_Alnum();
     $alnum->setMessage($this->messageAlnum);
     $notEmpty = new Zend_Validate_NotEmpty();
     $notEmpty->setMessage($this->notEmpty, "isEmpty");
     // создаем форму
     $this->setName('interview');
     $this->setAttribs(array('method' => "post", "class" => "form-horizontal"));
     $this->setDecorators(array('FormElements', 'Form'));
     $this->createFormElements($this, $this->elementsForm());
     return $this;
 }
开发者ID:MichaelGogeshvili,项目名称:strap,代码行数:14,代码来源:FormCyprus.php


示例2: testInvalidValueResultsInProperValidationFailureErrors

 /**
  * @return void
  * @deprecated Since 1.5.0
  */
 public function testInvalidValueResultsInProperValidationFailureErrors()
 {
     $this->assertFalse($this->_validator->isValid('#'));
     $errors = $this->_validator->getErrors();
     $arrayExpected = array(Zend_Validate_Alnum::NOT_ALNUM);
     $this->assertThat($errors, $this->identicalTo($arrayExpected));
 }
开发者ID:lortnus,项目名称:zf1,代码行数:11,代码来源:AlnumTest.php


示例3: init

 public function init()
 {
     // валидаторы
     $alnum = new Zend_Validate_Alnum();
     $alnum->setMessage($this->messageAlnum);
     $notEmpty = new Zend_Validate_NotEmpty();
     $notEmpty->setMessage($this->notEmpty, "isEmpty");
     // фильтры
     $stringTrim = new Zend_Filter_StringTrim();
     $stripTags = new Zend_Filter_StripTags();
     // добавляем элементы формы в массив, потом будем собирать форму в цыкле
     $elementsForm = array('surname' => array('type' => 'text', 'label' => 'ФИО', 'attribs' => array('class' => 'span12', 'placeholder' => 'Фамилия')), 'name' => array('label' => 'Имя', 'attribs' => array('class' => 'span12', 'placeholder' => 'Имя')), 'patronymic' => array('label' => 'Отчество', 'attribs' => array('class' => 'span12', 'placeholder' => 'Отчество')), 'sex' => array('type' => 'select', 'label' => 'Пол', 'multiOptions' => array('male' => 'Мужской', 'female' => 'Женский')), 'birthday' => array('label' => 'Дата Рождения', 'attribs' => $this->datepicker), 'maidenName' => array('label' => 'Девичья фамилия (если менялась)'), 'placeOfBirth' => array('label' => 'Место рождения (по паспорту)'), 'oldCountry' => array('label' => 'Страна рождения', 'attribs' => array('class' => 'span12')), 'nationality' => array('label' => 'Текущее гражданство', 'attribs' => array('class' => 'span12')), 'citizenship' => array('label' => 'Гражданство (при рождении)', 'attribs' => array('class' => 'span12')), 'FIFather' => array('label' => 'И.Ф Отца', 'attribs' => array('class' => 'span12')), 'FIMother' => array('label' => 'И.Ф Матери', 'attribs' => array('class' => 'span12')), 'maritalStatus' => array('type' => 'select', 'label' => 'Семейное Положение', 'multiOptions' => array('married' => 'женат/замужем', 'single' => 'холост/незамужем')), 'addressOfRegistration' => array('label' => 'Адрес (по прописке)'), 'telephoneNumber' => array('label' => 'Номер телефона'), 'profession' => array('label' => 'Профессия'), 'refsCompany' => array('label' => 'Назв. фирмы'), 'cityWhereTriesFirm' => array('label' => 'Город, где находится фирма'), 'workPhone' => array('label' => 'Раб телефон'), 'firstBorderCrossing' => array('label' => 'Первый пункт пересечения границы'), 'foreignPassport' => array('type' => 'text', 'label' => 'Данные заграничного пасспорта', 'attribs' => array('class' => 'span12', 'placeholder' => 'Серия и номер')), 'startDate' => array('type' => 'text', 'label' => 'Дата выдачи', 'attribs' => array('class' => 'span12 datepicker', 'readonly' => '', 'placeholder' => 'Дата выдачи')), 'endDate' => array('type' => 'text', 'label' => 'Дата окончания', 'attribs' => array('class' => 'span12 datepicker', 'readonly' => '', 'placeholder' => 'Дата окончания')), 'issued' => array('type' => 'text', 'label' => 'Кем выдан', 'attribs' => array('class' => 'span12', 'placeholder' => 'Кем выдан')), 'schengenVisasLast' => array('type' => 'textarea', 'label' => 'Шенгенские визы за последние 3 года', 'attribs' => $this->textareaAttribs), 'serNumPassport' => array('label' => 'Серия, номер гражданского паспорта'), 'addressActual' => array('label' => 'Адрес (фактический)'), 'theseSpouse' => array('type' => 'textarea', 'label' => 'Данные супруга(и)Девичья фамилия, дата рождения, место рождения', 'attribs' => $this->textareaAttribs), 'forMinors' => array('type' => 'textarea', 'label' => 'Для несовершеннолетних: ФИО, адрес и гражданство законного представителя', 'attribs' => $this->textareaAttribs), 'whoPays' => array('type' => 'select', 'label' => 'Кто оплачивает поездку', 'multiOptions' => array('myself' => 'Сам турист', 'sponsor' => 'Спонсор')), 'sponsor' => array('label' => 'Кто является спонсором'));
     // создаем форму
     $this->setName('interview');
     $this->setAttribs(array('method' => "post", "class" => "form-horizontal"));
     $this->setDecorators(array('FormElements', 'Form'));
     $this->createFormElements($this, $elementsForm, $this->elementDecorators, $this->buttonLabel, $this->buttonDecorators);
     return $this;
 }
开发者ID:MichaelGogeshvili,项目名称:strap,代码行数:19,代码来源:Test.php


示例4: init

 public function init()
 {
     $dbValidator = new Zend_Validate_Db_RecordExists(array('table' => 'users', 'field' => 'login'));
     $dbValidator->setMessage('Пользователя с таким именем нет в наших записях.');
     $alnum = new Zend_Validate_Alnum();
     $alnum->setMessage('Только буквы и цыфры!');
     $notEmpty = new Zend_Validate_NotEmpty();
     $notEmpty->setMessage('Поле обязательно для заполнения', 'isEmpty');
     $stringLength = new Zend_Validate_StringLength(array('min' => 3));
     $stringLength->setMessage('Длина поля должна быть больше трех символов.');
     if (!empty($_GET['referer'])) {
         $referer = $_GET['referer'];
     } else {
         $referer = '/';
     }
     $elementsForm = array('login' => array('type' => 'text', 'label' => 'Введите логин'), 'password' => array('type' => 'text', 'label' => 'Введите пароль', 'validators' => array('alnum' => $alnum, 'notEmpty' => $notEmpty, 'dbValidator' => $dbValidator, 'stringLength' => $stringLength)), 'redirect' => array('type' => 'hidden', 'attribs' => array('value' => $referer)));
     // имя формы;
     $this->setName('auth');
     $this->setAttribs(array('method' => "post", "role" => "form", "class" => "form-horizontal"));
     $this->createFormElements($this, $elementsForm, $this->elementDecorators, 'Войти', $this->buttonDecorators);
     return $this;
 }
开发者ID:MichaelGogeshvili,项目名称:strap,代码行数:22,代码来源:Auth.php


示例5: validateFormAndGetCRL

 private function validateFormAndGetCRL(&$validationErrors)
 {
     $registry = Zend_Registry::getInstance();
     $translate = $registry->get("Zend_Translate");
     $validationErrors = array();
     $crl = new SSLCRL();
     $validate_alnum_wspace = new Zend_Validate_Alnum(array('allowWhiteSpace' => true));
     // TODO: validate id field?
     $id = $_POST['crl_id'];
     $crl->setId($id);
     $name = $_POST['crl_name'];
     if (!$validate_alnum_wspace->isValid($name)) {
         $validationErrors['crl_name'] = $translate->translate("The CRL name must be only alpha-numeric characters");
     }
     $crl->setDisplayName($_POST['crl_name']);
     if (isset($_FILES['crl_file']) && !empty($_FILES['crl_file']['name'])) {
         if (!$_FILES['crl_file']['error']) {
             $contents = file_get_contents($_FILES['crl_file']['tmp_name']);
             if ($contents !== false) {
                 $crl->setContent($contents);
             } else {
                 $validationErrors['crl_file'] = $translate->translate("There was an error getting contents of CRL file.");
             }
         } else {
             $validationErrors['crl_file'] = $translate->translate("There was an error uploading file: ") . $_FILES['content']['error'];
         }
     } else {
         if (empty($id)) {
             $validationErrors['crl_file'] = $translate->translate("Please upload a CRL file.");
         }
     }
     return $crl;
 }
开发者ID:kyroskoh,项目名称:apigrove,代码行数:33,代码来源:CertificateController.php


示例6: _validateInputRule

 /**
  * Validate value by attribute input validation rule
  *
  * @param string $value
  * @return string
  */
 protected function _validateInputRule($value)
 {
     // skip validate empty value
     if (empty($value)) {
         return true;
     }
     $label = $this->getAttribute()->getStoreLabel();
     $validateRules = $this->getAttribute()->getValidateRules();
     if (!empty($validateRules['input_validation'])) {
         switch ($validateRules['input_validation']) {
             case 'alphanumeric':
                 $validator = new Zend_Validate_Alnum(true);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Alnum::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" has not only alphabetic and digit characters.', $label), Zend_Validate_Alnum::NOT_ALNUM);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Alnum::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'numeric':
                 $validator = new Zend_Validate_Digits();
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Digits::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" contains not only digit characters.', $label), Zend_Validate_Digits::NOT_DIGITS);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Digits::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'alpha':
                 $validator = new Zend_Validate_Alpha(true);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Alpha::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" has not only alphabetic characters.', $label), Zend_Validate_Alpha::NOT_ALPHA);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Alpha::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'email':
                 $validator = new Zend_Validate_EmailAddress();
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_EmailAddress::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::INVALID_FORMAT);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_HOSTNAME);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::DOT_ATOM);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::QUOTED_STRING);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" exceeds the allowed length.', $label), Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
                 break;
             case 'url':
                 $parsedUrl = parse_url($value);
                 if ($parsedUrl === false || empty($parsedUrl['scheme']) || empty($parsedUrl['host'])) {
                     return array(Mage::helper('customer')->__('"%s" is not a valid URL.', $label));
                 }
                 $validator = new Zend_Validate_Hostname();
                 if (!$validator->isValid($parsedUrl['host'])) {
                     return array(Mage::helper('customer')->__('"%s" is not a valid URL.', $label));
                 }
                 break;
             case 'date':
                 $format = Mage::app()->getLocale()->getDateFormat(Varien_Date::DATE_INTERNAL_FORMAT);
                 $validator = new Zend_Validate_Date($format);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Date::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid date.', $label), Zend_Validate_Date::INVALID_DATE);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" does not fit the entered date format.', $label), Zend_Validate_Date::FALSEFORMAT);
                 break;
         }
     }
     return true;
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:79,代码来源:Abstract.php


示例7: _validateInputRule

 /**
  * Validate value by attribute input validation rule
  *
  * @param string $value
  * @return string
  */
 protected function _validateInputRule($value)
 {
     // skip validate empty value
     if (empty($value)) {
         return true;
     }
     $label = Mage::helper('customer')->__($this->getAttribute()->getStoreLabel());
     $validateRules = $this->getAttribute()->getValidateRules();
     if (!empty($validateRules['input_validation'])) {
         switch ($validateRules['input_validation']) {
             case 'alphanumeric':
                 $validator = new Zend_Validate_Alnum(true);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Alnum::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" has not only alphabetic and digit characters.', $label), Zend_Validate_Alnum::NOT_ALNUM);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Alnum::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'numeric':
                 $validator = new Zend_Validate_Digits();
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Digits::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" contains not only digit characters.', $label), Zend_Validate_Digits::NOT_DIGITS);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Digits::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'alpha':
                 $validator = new Zend_Validate_Alpha(true);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Alpha::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" has not only alphabetic characters.', $label), Zend_Validate_Alpha::NOT_ALPHA);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Alpha::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'email':
                 /**
                 $this->__("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded")
                 $this->__("Invalid type given. String expected")
                 $this->__("'%value%' appears to be a DNS hostname but contains a dash in an invalid position")
                 $this->__("'%value%' does not match the expected structure for a DNS hostname")
                 $this->__("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'")
                 $this->__("'%value%' does not appear to be a valid local network name")
                 $this->__("'%value%' does not appear to be a valid URI hostname")
                 $this->__("'%value%' appears to be an IP address, but IP addresses are not allowed")
                 $this->__("'%value%' appears to be a local network name but local network names are not allowed")
                 $this->__("'%value%' appears to be a DNS hostname but cannot extract TLD part")
                 $this->__("'%value%' appears to be a DNS hostname but cannot match TLD against known list")
                 */
                 $validator = new Zend_Validate_EmailAddress();
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_EmailAddress::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::INVALID_FORMAT);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_HOSTNAME);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::DOT_ATOM);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::QUOTED_STRING);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" exceeds the allowed length.', $label), Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be an IP address, but IP addresses are not allowed"), Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot match TLD against known list"), Zend_Validate_Hostname::UNKNOWN_TLD);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but contains a dash in an invalid position"), Zend_Validate_Hostname::INVALID_DASH);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'"), Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot extract TLD part"), Zend_Validate_Hostname::UNDECIPHERABLE_TLD);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' does not appear to be a valid local network name"), Zend_Validate_Hostname::INVALID_LOCAL_NAME);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a local network name but local network names are not allowed"), Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded"), Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
                 break;
             case 'url':
                 $parsedUrl = parse_url($value);
                 if ($parsedUrl === false || empty($parsedUrl['scheme']) || empty($parsedUrl['host'])) {
                     return array(Mage::helper('customer')->__('"%s" is not a valid URL.', $label));
                 }
                 $validator = new Zend_Validate_Hostname();
                 if (!$validator->isValid($parsedUrl['host'])) {
                     return array(Mage::helper('customer')->__('"%s" is not a valid URL.', $label));
                 }
                 break;
             case 'date':
                 $validator = new Zend_Validate_Date(Varien_Date::DATE_INTERNAL_FORMAT);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Date::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid date.', $label), Zend_Validate_Date::INVALID_DATE);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" does not fit the entered date format.', $label), Zend_Validate_Date::FALSEFORMAT);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
                 break;
         }
     }
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:emporiodopara,代码行数:101,代码来源:Abstract.php


示例8: _validateInputRule

 /**
  * Validate value by attribute input validation rule
  *
  * @param string $value
  * @return array|true
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _validateInputRule($value)
 {
     // skip validate empty value
     if (empty($value)) {
         return true;
     }
     $label = $this->getAttribute()->getStoreLabel();
     $validateRules = $this->getAttribute()->getValidationRules();
     $inputValidation = ArrayObjectSearch::getArrayElementByName($validateRules, 'input_validation');
     if (!is_null($inputValidation)) {
         switch ($inputValidation) {
             case 'alphanumeric':
                 $validator = new \Zend_Validate_Alnum(true);
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Alnum::INVALID);
                 $validator->setMessage(__('"%1" contains non-alphabetic or non-numeric characters.', $label), \Zend_Validate_Alnum::NOT_ALNUM);
                 $validator->setMessage(__('"%1" is an empty string.', $label), \Zend_Validate_Alnum::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'numeric':
                 $validator = new \Zend_Validate_Digits();
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Digits::INVALID);
                 $validator->setMessage(__('"%1" contains non-numeric characters.', $label), \Zend_Validate_Digits::NOT_DIGITS);
                 $validator->setMessage(__('"%1" is an empty string.', $label), \Zend_Validate_Digits::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'alpha':
                 $validator = new \Zend_Validate_Alpha(true);
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Alpha::INVALID);
                 $validator->setMessage(__('"%1" contains non-alphabetic characters.', $label), \Zend_Validate_Alpha::NOT_ALPHA);
                 $validator->setMessage(__('"%1" is an empty string.', $label), \Zend_Validate_Alpha::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'email':
                 /**
                 __("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded")
                 __("Invalid type given. String expected")
                 __("'%value%' appears to be a DNS hostname but contains a dash in an invalid position")
                 __("'%value%' does not match the expected structure for a DNS hostname")
                 __("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'")
                 __("'%value%' does not appear to be a valid local network name")
                 __("'%value%' does not appear to be a valid URI hostname")
                 __("'%value%' appears to be an IP address, but IP addresses are not allowed")
                 __("'%value%' appears to be a local network name but local network names are not allowed")
                 __("'%value%' appears to be a DNS hostname but cannot extract TLD part")
                 __("'%value%' appears to be a DNS hostname but cannot match TLD against known list")
                 */
                 $validator = new \Zend_Validate_EmailAddress();
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_EmailAddress::INVALID);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::INVALID_FORMAT);
                 $validator->setMessage(__('"%1" is not a valid hostname.', $label), \Zend_Validate_EmailAddress::INVALID_HOSTNAME);
                 $validator->setMessage(__('"%1" is not a valid hostname.', $label), \Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(__('"%1" is not a valid hostname.', $label), \Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::DOT_ATOM);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::QUOTED_STRING);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
                 $validator->setMessage(__('"%1" uses too many characters.', $label), \Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
                 $validator->setMessage(__("'%value%' looks like an IP address, which is not an acceptable format."), \Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but we cannot match the TLD against known list."), \Zend_Validate_Hostname::UNKNOWN_TLD);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but contains a dash in an invalid position."), \Zend_Validate_Hostname::INVALID_DASH);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but we cannot match it against the hostname schema for TLD '%tld%'."), \Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but cannot extract TLD part."), \Zend_Validate_Hostname::UNDECIPHERABLE_TLD);
                 $validator->setMessage(__("'%value%' does not look like a valid local network name."), \Zend_Validate_Hostname::INVALID_LOCAL_NAME);
                 $validator->setMessage(__("'%value%' looks like a local network name, which is not an acceptable format."), \Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED);
                 $validator->setMessage(__("'%value%' appears to be a DNS hostname, but the given punycode notation cannot be decoded."), \Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
                 break;
             case 'url':
                 $parsedUrl = parse_url($value);
                 if ($parsedUrl === false || empty($parsedUrl['scheme']) || empty($parsedUrl['host'])) {
                     return [__('"%1" is not a valid URL.', $label)];
                 }
                 $validator = new \Zend_Validate_Hostname();
                 if (!$validator->isValid($parsedUrl['host'])) {
                     return [__('"%1" is not a valid URL.', $label)];
                 }
                 break;
             case 'date':
                 $validator = new \Zend_Validate_Date(\Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT);
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Date::INVALID);
                 $validator->setMessage(__('"%1" is not a valid date.', $label), \Zend_Validate_Date::INVALID_DATE);
                 $validator->setMessage(__('"%1" does not fit the entered date format.', $label), \Zend_Validate_Date::FALSEFORMAT);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
//.........这里部分代码省略.........
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:101,代码来源:AbstractData.php


示例9: Zend_Service_ReCaptcha

 $private_key = '6LfeneMSAAAAABRYmV5zuUe9AO4i9wppVJAclRlM';
 $recaptcha = new Zend_Service_ReCaptcha($public_key, $private_key);
 if (isset($_POST['send'])) {
     // validate the user input
     //
     if (empty($_POST['recaptcha_response_field'])) {
         $errors['recaptcha'] = 'reCAPTCHA field is required';
     } else {
         $result = $recaptcha->verify($_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
         if (!$result->isValid()) {
             $errors['recaptcha'] = 'Try again';
         }
     }
     // Validate nmae
     //
     $val = new Zend_Validate_Alnum(TRUE);
     if (!$val->isValid($_POST['name'])) {
         $errors['name'] = 'Name is required';
     }
     // Validate email address
     //
     $val = new Zend_Validate_EmailAddress();
     if (!$val->isValid($_POST['email'])) {
         $errors['email'] = 'Email address is required';
     }
     // Validate comments
     //
     $val = new Zend_Validate_StringLength(10);
     if (!$val->isValid($_POST['comments'])) {
         $errors['comments'] = 'Required';
     }
开发者ID:colasad,项目名称:code,代码行数:31,代码来源:process_comments.php


示例10: getValidator

 /**
  * returns an validator for a single category
  *
  * @return Zend_Filter_Input validator
  */
 protected function getValidator()
 {
     // define filter
     $filterTrim = new Zend_Filter_StringTrim();
     $filterUtf8 = new application_filter_utf8();
     $filter = array('id' => $filterTrim, 'name' => array($filterTrim, $filterUtf8), 'position' => $filterTrim);
     // define validators
     $validatorId = new application_validate_categoryid();
     $validatorId->setMessage(Zend_Registry::get('language')->translate("category doesn't exists"), application_validate_categoryid::NOT_EXISTS);
     $validatorNotEmpty = new Zend_Validate_NotEmpty();
     $validatorNotEmpty->setMessage(Zend_Registry::get('language')->translate("Value is required and can't be empty"), Zend_Validate_NotEmpty::IS_EMPTY);
     $validatorAlnum = new Zend_Validate_Alnum(true);
     $validatorAlnum->setMessage(Zend_Registry::get('language')->translate('Only alphanummeric values allowed'), Zend_Validate_Alnum::NOT_ALNUM);
     $validatorAlnum->setMessage(Zend_Registry::get('language')->translate("Value is required and can't be empty"), Zend_Validate_Alnum::STRING_EMPTY);
     $validatorNum = new Zend_Validate_Digits(false);
     $validatorNum->setMessage(Zend_Registry::get('language')->translate('Only digits allowed'), Zend_Validate_Digits::NOT_DIGITS);
     $validatorNum->setMessage(Zend_Registry::get('language')->translate("Value is required and can't be empty"), Zend_Validate_Digits::STRING_EMPTY);
     $validators = array('id' => array($validatorId, Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'name' => array($validatorNotEmpty, Zend_Filter_Input::ALLOW_EMPTY => false, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED), 'position' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL));
     // create validation main object
     $validator = new Zend_Filter_Input($filter, $validators, array(), array(Zend_Filter_Input::NOT_EMPTY_MESSAGE => Zend_Registry::get('language')->translate("Value is required and can't be empty"), Zend_Filter_Input::BREAK_CHAIN => false));
     // return filter input object
     return $validator;
 }
开发者ID:google-code-backups,项目名称:rsslounge,代码行数:28,代码来源:categories.php


示例11: indexAction

 /**
  * The default action is "indexAction", unless explcitly set to something else.
  */
 public function indexAction()
 {
     // STAGE 4: Apply business logic to create a presentation model for the view.
     $origRequest = $this->getInvokeArg('origRequest');
     $this->view->rerouteToReason = $this->getInvokeArg('rerouteToReason');
     $this->view->origRequestUri = $origRequest->REQUEST_URI;
     // if no credentials
     if (empty($_REQUEST['username'])) {
         // should be _POST, but this makes demo easier to tweak
         // STAGE 5: Choose view template and submit presentation model to view template for rendering.
         // if an admin area was requested, and authentication has been enabled in config.ini
         if (isset($this->authSpace->authenticationId)) {
             ZFDemo_Log::log(_('already have authentication id, showing logout form'));
             $this->_forward('logoutDecision');
             // show logout form
         } else {
             ZFDemo_Log::log(_('no authentication id, showing login form'));
             $this->renderToSegment('body');
             // show login form
         }
         return;
     }
     // prepare to authenticate credentials received from a form
     require_once 'Zend/Auth/Result.php';
     require_once 'Zend/Auth/Adapter/Digest.php';
     $config = Zend_Registry::get('config');
     $username = trim($_REQUEST['username']);
     // ought to be _POST, but this simplifies experimentation
     $password = trim($_REQUEST['password']);
     // by the reader of the tutorial
     // filtering will be added in a later section
     /////////////////////////////
     // ==> SECTION: filter <==
     require_once 'Zend/Validate/Alnum.php';
     require_once 'Zend/Validate/Regex.php';
     // input filtering is enabled, so ..
     $validator_name = new Zend_Validate_Alnum();
     // alphabetic and numeric characters are permitted
     if (!$validator_name->isValid($username)) {
         $this->renderToSegment('body', 'invalidUsername');
         return;
     }
     // this application has "special" requirements, so we show how to use custom regex:
     $validator_password = new Zend_Validate_Regex('/^[a-z0-9_]{5,16}$/');
     if (!$validator_password->isValid($password)) {
         $this->renderToSegment('body', 'invalidPassword');
         return;
     }
     /////////////////////////////
     // ==> SECTION: auth <==
     $result = false;
     try {
         // try to authenticate using the md5 "digest" adapter
         $filename = $config->authenticate->filename;
         // file containing username:realm:password digests
         if ($filename[0] !== DIRECTORY_SEPARATOR) {
             $filename = Zend_Registry::get('dataDir') . $filename;
             // prepend path, if filename not absolute
         }
         $adapter = new Zend_Auth_Adapter_Digest($filename, $config->authenticate->realm, $username, $password);
         $result = $adapter->authenticate();
         // result of trying to authenticate credentials
         $this->view->resultCode = $result->getCode();
         // allow view to see result status (reason)
     } catch (Exception $exception) {
         $this->view->exception = ZFDemo::filterException($exception);
         // record exception description
         $this->view->resultCode = false;
     }
     if ($result && $result->isValid()) {
         // if successful authentication, save the authentication identity ( http://framework.zend.com/wiki/x/fUw )
         $id = $result->getIdentity();
         Zend_Registry::set('authenticationId', $id);
         // publish the identity (really need Observer pattern)
         $this->authSpace->authenticationId = $id;
         $this->authSpace->date = time();
         // save the timestamp when authenticated successfully
         $this->authSpace->attempts = 0;
         // success, so forget the number of previous login failures
         // @TODO: filter this ...
         $this->_redirect($_REQUEST['origPathInfo']);
         // now return to wherever user came from
     } else {
         $this->authSpace->attempts++;
         // record the authentication failure
         if ($this->authSpace->attempts > $config->authenticate->maxAttempts) {
             // Overly simplistic account "lockout" lasts for at least 10 seconds,
             // but increases with repeated failures.
             $this->view->lockout = 5 * $this->authSpace->attempts;
             // Lockout time will be "forgotten" later, and expired from session, allowing logins.
             $this->authSpace->setExpirationSeconds($this->view->lockout);
             $this->blockHacker();
             // show a view indicating account lockout
             return;
         }
     }
     // STAGE 5: Choose view template and submit presentation model to view template for rendering.
//.........这里部分代码省略.........
开发者ID:jorgenils,项目名称:zend-framework,代码行数:101,代码来源:LogonController.php


示例12: registerAction

 public function registerAction()
 {
     //Check to see if user is already login
     if ($this->loggedEmail) {
         $this->_redirect('/');
         return;
     }
     //get referrer
     $ns = new Zend_Session_Namespace('referrer');
     $this->view->referby = $ns->referrer;
     if ($this->getRequest()->isPost()) {
         //Validation
         // Valid email address?
         if (!Zend_Validate::is($this->_request->getPost('email'), 'EmailAddress') && $this->_request->getPost('email') != 'me2@localhost') {
             $this->view->errors[] = "Invalid e-mail address.";
         }
         //E-mail cannot already exist in the database
         $user = new Default_Model_User();
         $foundUser = $user->getUserByEmail($this->_request->getPost('email'));
         if (isset($foundUser->id)) {
             $this->view->errors[] = "Email address already in database.";
         }
         //Handle must be between 2-20 characters
         $validator = new Zend_Validate_StringLength(2, 20);
         if (!$validator->isValid($this->_request->getPost('handle'))) {
             $this->view->errors[] = "Handle must be between 2 and 14 characters.";
         }
         // Handle must consist solely of alphanumeric characters
         $validHandle = new Zend_Validate_Alnum();
         if (!$validHandle->isValid($this->_request->getPost('handle'))) {
             $this->view->errors[] = "Handle must consist of letters and numbers.";
         }
         // end valid handle
         // Handle cannot already exist in database
         $foundUser = $user->getUserByHandle($this->_request->getPost('handle'));
         if (isset($foundUser->id)) {
             $this->view->errors[] = "Handle already exists in database.";
         }
         // Password must between 6 to 20 characters
         $validPswd = new Zend_Validate_StringLength(6, 20);
         if (!$validPswd->isValid($this->_request->getPost('password'))) {
             $this->view->errors[] = "Password must be at least 6 characters.";
         }
         // end valid password
         // First name must not be empty
         $validFirstName = new Zend_Validate_NotEmpty();
         if (!$validFirstName->isValid($this->_request->getPost('first_name'))) {
             $this->view->errors[] = "Please provide your first name.";
         }
         // end valid first name
         // Last name must not be empty
         $validLastName = new Zend_Validate_NotEmpty();
         if (!$validLastName->isValid($this->_request->getPost('last_name'))) {
             $this->view->errors[] = "Please provide your last name.";
         }
         // end valid last name
         // Valid gender?
         if (!Zend_Validate::is($this->_request->getPost('gender'), 'NotEmpty')) {
             $this->view->errors[] = "Please identify your gender.";
         }
         // end valid gender
         //Address not empty?
         if (!Zend_Validate::is($this->_request->getPost('address'), 'NotEmpty')) {
             $this->view->errors[] = "Please enter your address.";
         }
         //if errors exist, prepopulate the form
         if (count($this->view->errors) > 0) {
             $this->view->email = $this->_request->getPost('email');
             $this->view->handle = $this->_request->getPost('handle');
             $this->view->first_name = $this->_request->getPost('first_name');
             $this->view->last_name = $this->_request->getPost('last_name');
             $this->view->gender = $this->_request->getPost('gender');
             $this->view->address = $this->_request->getPost('address');
         } else {
             //No errors, add user to the database and send confirmation e-mail
             //Generate random keys used for registration confirmation
             $registrationKey = $this->_helper->generator(32, 'alpha');
             // Prepare the data array for database insertion
             $data = array('email' => $this->_request->getPost('email'), 'password' => md5($this->_request->getPost('password')), 'registration_key' => $registrationKey, 'handle' => $this->_request->getPost('handle'), 'first_name' => $this->_request->getPost('first_name'), 'last_name' => $this->_request->getPost('last_name'), 'gender' => $this->_request->getPost('gender'), 'address' => $this->_request->getPost('address'), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'), 'last_login' => date('Y-m-d H:i:s'), 'referby' => $this->_request->getPost('referrer'));
             //Create a new mail object
             try {
                 $mail = new Zend_Mail();
                 // Set the From, To, and Subject headers
                 $mail->setFrom($this->config->email->from_admin);
                 $mail->addTo($this->_request->getPost('email'), "{$this->_request->getPost('first_name')}\n\t\t\t\t\t {$this->_request->getPost('last_name')}");
                 $mail->setSubject('Your game account has been created');
                 // Retrieve the e-mail template
                 include "emailTemplates/_email-confirm-registration.phtml";
                 // Attach the e-mail template to the e-mail and send it
                 $mail->setBodyText($email);
                 $mail->send();
                 $this->view->success = 1;
             } catch (Exception $e) {
                 $this->view->errors[] = "We were unable to send your confirmation \t\t\n\t\t\t\t\t\t e-mail.\n\t\t\t\t\tPlease contact {$this->config->email->support}.";
             }
             //If succcessful at sending mail, insert into database
             if ($this->view->success == 1) {
                 // Insert the registration data into the database
                 $user = new Default_Model_User();
                 $user->insert($data);
//.........这 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Validate_Alpha类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Validate_Abstract类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap