public function processAction()
 {
     $error = array();
     $defaultNamespace = new Zend_Session_Namespace('Default');
     $options = array('authentication' => array('email' => $this->getRequest()->getParam('admin_email'), 'password' => $this->getRequest()->getParam('admin_password')), 'settings' => array('default_from' => $this->getRequest()->getParam('default_from'), 'keep_history' => $this->getRequest()->getParam('keep_history'), 'alchemy_api_key' => $this->getRequest()->getParam('alchemy_api_key')), 'resources' => array('db' => array('adapter' => 'PDO_MYSQL', 'params' => array('host' => $this->getRequest()->getParam('db_host'), 'username' => $this->getRequest()->getParam('db_user'), 'password' => $this->getRequest()->getParam('db_password'), 'dbname' => $this->getRequest()->getParam('db_name'), 'prefix' => $this->getRequest()->getParam('db_prefix')))), 'template' => $this->getRequest()->getParam('template'));
     $validator = new Zend_Validate_EmailAddress();
     if (!$validator->isValid($options['authentication']['email'])) {
         $error['admin_email'] = 'Administrator e-mail is invalid';
     }
     if (!trim($options['authentication']['password'])) {
         $error['admin_password'] = '******';
     }
     if (!$validator->isValid($options['settings']['default_from'])) {
         $error['default_from'] = 'Default "from" e-mail is invalid';
     }
     if (!trim($options['resources']['db']['params']['host'])) {
         $error['db_host'] = 'Database host can not be blank';
     }
     if (!trim($options['resources']['db']['params']['username'])) {
         $error['db_user'] = '******';
     }
     if (!trim($options['resources']['db']['params']['dbname'])) {
         $error['db_name'] = 'Database name can not be blank';
     }
     if ((int) $options['settings']['keep_history'] <= 0) {
         $error['keep_history'] = 'Timeline display length have to be positive integer';
     }
     if (!($db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => $options['resources']['db']['params']['host'], 'username' => $options['resources']['db']['params']['username'], 'password' => $options['resources']['db']['params']['password'], 'dbname' => $options['resources']['db']['params']['dbname'])))) {
         $error[] = 'Incorrect database connection details';
     }
     if (count($error)) {
         /**
          * Redirect back
          */
         $defaultNamespace->error = $error;
         $defaultNamespace->options = $options;
         $this->_helper->redirector('index', 'index', 'install');
     } else {
         /**
          * Write .ini file
          */
         unset($defaultNamespace->options);
         /** @var $bootstrap Bootstrap */
         $bootstrap = $this->getInvokeArg('bootstrap');
         $options = new Zend_Config($options);
         $writer = new Zend_Config_Writer_Xml();
         $writer->write($bootstrap->getOption('local_config'), $options);
         $options = $bootstrap->getOptions();
         $options = new Zend_Config($options);
         $writer->write('application.xml', $options);
         $this->_helper->redirector('index', 'index', 'default');
     }
 }
示例#2
0
 /**
  * SW-8258 - check if email addresses with new domains like .berlin are valid
  */
 public function testValidEmailAddresses()
 {
     $emailAddresses = array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**');
     $invalidEmailAddresses = array('test', 'test@example', 'test@.de', '@example', '@example.de', '@.', ' @ .de');
     $validator = new Zend_Validate_EmailAddress();
     $validator->getHostnameValidator()->setValidateTld(false);
     foreach ($emailAddresses as $email) {
         $this->assertTrue($validator->isValid($email));
     }
     foreach ($invalidEmailAddresses as $email) {
         $this->assertFalse($validator->isValid($email));
     }
 }
示例#3
0
 /**
  * Make sure the user is valid
  *
  * @return void
  */
 public function isValid($value)
 {
     $valid = true;
     $this->_user = $value;
     $namePartsValidator = new Zend_Validate();
     $namePartsValidator->addValidator(new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING))->addValidator(new Zend_Validate_Alpha(array('allowWhiteSpace' => true)))->addValidator(new Zend_Validate_StringLength(array('min' => 2)));
     if (!$namePartsValidator->isValid($this->_user->getFirstName())) {
         $valid = false;
         $this->_error($this->_view->translate('The first name must have at least 2 characters and consist only of letters'));
     }
     if (!$namePartsValidator->isValid($this->_user->getLastName())) {
         $valid = false;
         $this->_error($this->_view->translate('The last name must have at least 2 characters and consist only of letters'));
     }
     $emailValidator = new Zend_Validate_EmailAddress();
     if (!$emailValidator->isValid($this->_user->getEmail())) {
         $valid = false;
         $this->_error($this->_view->translate('You must entre a valid email'));
     }
     if ($this->_user->isNew()) {
         $usernameValidator = new Zend_Validate();
         $usernameValidator->addValidator(new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING))->addValidator(new Zend_Validate_Alnum(array('allowWhiteSpace' => false)))->addValidator(new Zend_Validate_StringLength(array('min' => 5)));
         if (!$usernameValidator->isValid($this->_user->getUsername())) {
             $this->_error($this->_view->translate('The username must have at least 5 characters and contains no white spaces'));
         }
     }
     return $valid;
 }
示例#4
0
文件: Gravatar.php 项目: kminkov/Blog
 /**
  * Returns an avatar from gravatar's service.
  *
  * @link http://pl.gravatar.com/site/implement/url
  * @throws Zend_View_Exception
  *
  * @param string|null $email Valid email adress
  * @param null|array $options Options
  * 'imgSize' height of img to return
  * 'defaultImg' img to return if email adress has not found
  * 'rating' rating parameter for avatar
  * @param null|array $attribs Attribs for img tag (title, alt etc.)
  * @param null|bool Use HTTPS? Default false.
  * @link http://pl.gravatar.com/site/implement/url More information about gravatar's service.
  * @return string|Zend_View_Helper_Gravatar
  */
 public function gravatar($email = null, $options = array(), $attribs = array(), $flag = false)
 {
     if ($email === null) {
         return null;
     }
     if (count($options) > 0) {
         if (isset($options['imgSize'])) {
             $this->setImgSize($options['imgSize']);
         }
         if (isset($options['defaultImg'])) {
             $this->setDefaultImg($options['defaultImg']);
         }
         if (isset($options['rating'])) {
             $this->setRating($options['rating']);
         }
     }
     /**
      * @see Zend_Validate_EmailAddress
      */
     require_once 'Zend/Validate/EmailAddress.php';
     $validatorEmail = new Zend_Validate_EmailAddress();
     $validatorResult = $validatorEmail->isValid($email);
     if ($validatorResult === false) {
         return null;
     }
     $hashEmail = md5($email);
     $src = $this->getGravatarUrl($flag) . '/' . $hashEmail . '?s=' . $this->getImgSize() . '&d=' . $this->getDefaultImg() . '&r=' . $this->getRating();
     $attribs['src'] = $src;
     $html = '<img' . $this->_htmlAttribs($attribs) . $this->getClosingBracket();
     return $html;
 }
 /**
  * Validate that the receiver ID is well-formed according to it's type
  *
  * @param  string $value
  * @param  string $type Either EMAIL or PAYPAL ID
  * @return boolean
  */
 public static function validateReceiverType($value, $type)
 {
     switch ($type) {
         case self::RT_EMAIL:
             if (!self::$emailValidator) {
                 require_once 'Zend/Validate/EmailAddress.php';
                 self::$emailValidator = new Zend_Validate_EmailAddress();
             }
             return self::$emailValidator->isValid($value);
             break;
         case self::RT_USERID:
             if (!self::$useridValidator) {
                 require_once 'Zend/Validate.php';
                 require_once 'Zend/Validate/StringLength.php';
                 require_once 'Zend/Validate/Alnum.php';
                 self::$useridValidator = new Zend_Validate();
                 self::$useridValidator->addValidator(new Zend_Validate_StringLength(13))->addValidator(new Zend_Validate_Alnum());
             }
             return self::$useridValidator->isValid($value);
             break;
         default:
             require_once 'Zend/Service/PayPal/Data/Exception.php';
             throw new Zend_Service_PayPal_Data_Exception("'{$type}' is not a valid Receiver ID type");
             break;
     }
 }
 protected function _validateEmail($value = null)
 {
     if ($value) {
         $validator = new Zend_Validate_EmailAddress();
         $validator->setMessage(Mage::helper('eav')->__('"%s" invalid type entered.', $value), Zend_Validate_EmailAddress::INVALID);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid email address.', $value), Zend_Validate_EmailAddress::INVALID_FORMAT);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid hostname.', $value), Zend_Validate_EmailAddress::INVALID_HOSTNAME);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid hostname.', $value), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid hostname.', $value), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid email address.', $value), Zend_Validate_EmailAddress::DOT_ATOM);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid email address.', $value), Zend_Validate_EmailAddress::QUOTED_STRING);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid email address.', $value), Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
         $validator->setMessage(Mage::helper('eav')->__('"%s" exceeds the allowed length.', $value), 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());
         }
     }
     return;
 }
 public function ceospeaksAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         // action body
         $emails_str = str_replace(" ", "", $request->getParam('emails'));
         // strips whitespace from string
         $emails = explode(",", $emails_str);
         // splits string into an array using comma to split
         $validator = new Zend_Validate_EmailAddress();
         foreach ($emails as $email) {
             if (!$validator->isValid($email)) {
                 array_shift($emails);
                 // Remove invalid emails
             }
         }
         $mail = new Zend_Mail();
         $mail->setFrom('*****@*****.**', 'winsandwants.com');
         $mail->setReplyTo('*****@*****.**', 'winsandwants.com');
         $mail->addTo($emails);
         $mail->setSubject('Sharing winsandwants.com');
         $txt = "A friend would like to share with you this wonderful free site on goal-setting and the mastermind concept. Please visit: http://winsandwants.com";
         $mail->setBodyText($txt, 'UTF-8');
         $mail->send();
         $this->view->msg = "Thank you for sharing this site. A link to this site has been sent to the following emails: " . implode(",", $emails) . ".";
     }
 }
 /**
  * Ensures that the validator follows expected behavior for valid email addresses with complex local parts
  *
  * @return void
  */
 public function testComplexLocalValid()
 {
     $emailAddresses = array('*****@*****.**', 'Bob.Jones!@domain.com', 'Bob&Jones@domain.com', '/Bob.Jones@domain.com', '#Bob.Jones@domain.com', 'Bob.Jones?@domain.com');
     foreach ($emailAddresses as $input) {
         $this->assertTrue($this->_validator->isValid($input));
     }
 }
示例#9
0
 /**
  * Returns an avatar from gravatar's service.
  *
  * @link http://en.gravatar.com/site/implement/images/php/
  * @throws Zend_View_Exception
  *
  * @param string|null $email Valid email adress
  * @param array $options Options
  * 'imgSize' height of img to return
  * 'defaultImg' img to return if email adress has not found
  * 'rating' rating parametr for avatar
  * @param array $attribs Attribs for img tag (title, alt etc.)
  * @param bool $flag Use HTTPS? Default false.
  * @return string
  */
 public function gravatar($email = null, $options = array(), $attribs = array(), $flag = false)
 {
     if ($email === null) {
         return '';
     }
     if (count($options) > 0) {
         if (isset($options['imgSize'])) {
             $this->setImgSize($options['imgSize']);
         }
         if (isset($options['defaultImg'])) {
             $this->setDefaultImg($options['defaultImg']);
         }
         if (isset($options['rating'])) {
             $this->setRating($options['rating']);
         }
     }
     $validatorEmail = new Zend_Validate_EmailAddress();
     $validatorResult = $validatorEmail->isValid($email);
     if ($validatorResult === false) {
         throw new Zend_View_Exception(current($validatorEmail->getMessages()));
     }
     $hashEmail = md5($email);
     $src = $this->getGravatarUrl($flag) . '/' . $hashEmail . '?s=' . $this->getImgSize() . '&d=' . $this->getDefaultImg() . '&r=' . $this->getRating();
     $attribs['src'] = $src;
     $html = '<img' . $this->_htmlAttribs($attribs) . $this->getClosingBracket();
     return $html;
 }
 public function mailAction()
 {
     $error = array();
     $posts = array('First Name' => $_POST['first_name'], 'Last Name' => $_POST['last_name'], 'Email' => $_POST['email'], 'Message' => $_POST['message']);
     $validatorChain = new Zend_Validate();
     $validatorChain->addValidator(new Zend_Validate_NotEmpty());
     $valid_email = new Zend_Validate_EmailAddress();
     if ($valid_email->isValid($posts['Email'])) {
     } else {
         foreach ($valid_email->getMessages() as $message) {
             $error[] = "Email {$message}\n";
         }
     }
     foreach ($posts as $key => $post) {
         if ($validatorChain->isValid($post)) {
         } else {
             foreach ($validatorChain->getMessages() as $message) {
                 $error[] = "{$key} {$message}\n";
             }
         }
     }
     if (count($error) != 0) {
         $this->view->alerts = $error;
     } else {
         $to = '*****@*****.**';
         $subject = 'Email from Illustrated Portland';
         $message = $posts['Message'];
         $headers = "From: {$posts['First Name']} {$posts['Last Name']} <{$posts['Email']}>";
         mail($to, $subject, $message, $headers);
         //$this->view->alerts = array("Thank You! Your message has been sent.");
     }
 }
示例#11
0
 public function registerAction()
 {
     $name = $this->_getParam('name');
     $avatar = $this->_getParam('avatar');
     $sex = $this->_getParam('sex');
     $birthday = $this->_getParam('birthday');
     $email = $this->_getParam('email');
     $passwd = $this->_getParam('passwd');
     $phone = $this->_getParam('phone');
     $department = $this->_getParam('department');
     $city = $this->_getParam('city');
     //$certified  = $this->_getParam('certified');
     $special = $this->_getParam('special');
     $country = $this->_getParam('country');
     $introduction = $this->_getParam('introduction');
     $hospital = $this->_getParam('hospital');
     $area = $this->_getParam('area');
     $qualification = $this->_getParam('qualification');
     if (!$passwd) {
         $out['errno'] = '3';
         $out['msg'] = Yy_ErrMsg_Doctor::getMsg('register', $out['errno']);
         Yy_Utils::jsonOut($out);
         return;
     }
     $validatorEmail = new Zend_Validate_EmailAddress();
     if ($validatorEmail->isValid($email)) {
         $bool = Application_Model_M_Doctor::fetchByEmail($email);
         if ($bool) {
             //已注册
             $out['errno'] = '1';
         } else {
             $out['errno'] = '0';
             $doctor = new Application_Model_O_Doctor();
             $doctor->setName($name)->setSex($sex)->setBirthday($birthday)->setEmail($email)->setPasswd(md5($passwd))->setPhone($phone)->setDepartment($department)->setCity($city)->setSpecial($special)->setCountry($country)->setIntroduction($introduction)->setHospital($hospital)->setArea($area)->setQualification($qualification)->setCtime(date('Y-m-d H:i:s'));
             $certified = ceil(count($doctor->getModifiedFields()) / 3);
             $doctor->setCertified($certified);
             $doctor->save();
             //保存医生头像
             $adapter = new Zend_File_Transfer_Adapter_Http();
             $wrdir = Yy_Utils::getWriteDir();
             $adapter->setDestination($wrdir);
             if (!$adapter->receive()) {
                 $messages = $adapter->getMessages();
                 //echo implode("\n", $messages);
             }
             $filename = $adapter->getFileName();
             if (is_string($filename)) {
                 $handle = fopen($filename, 'rb');
                 $avatar = addslashes(fread($handle, filesize($filename)));
                 fclose($handle);
                 Application_Model_M_Doctor::updateAvatar($doctor->getId(), $avatar);
             }
         }
     } else {
         $out['errno'] = '2';
     }
     $out['msg'] = Yy_ErrMsg_Doctor::getMsg('register', $out['errno']);
     Yy_Utils::jsonOut($out);
 }
 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);
     }
 }
 public function setSandboxPrimaryEmail($email)
 {
     $validator = new Zend_Validate_EmailAddress();
     if (!$validator->isValid($email)) {
         throw new Exception($email . ' is not a valid email address!');
     }
     $this->_sandboxPrimaryEmail = $email;
 }
示例#14
0
 public function setEmail($email)
 {
     $validator = new Zend_Validate_EmailAddress();
     if (!$validator->isValid($email)) {
         throw new Exception('Invalid e-mail address specified');
     }
     $this->_email = $email;
 }
 /**
  * Validate attributes
  * 
  * @param string $validation attribute validation class name
  * @param string $value attribute value
  * @return array returns success and errors as array keys
  */
 protected function validateAttributeValue($validation, $value)
 {
     $valid = array('success' => TRUE, 'errors' => '');
     switch ($validation) {
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_DECIMAL:
             if (!$this->decimalValidation) {
                 $this->decimalValidation = new Zend_Validate_Float();
             }
             $valid['success'] = $this->decimalValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" contains invalid digits.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_EMAIL:
             if (!$this->emailValidation) {
                 $this->emailValidation = new Zend_Validate_EmailAddress();
             }
             $valid['success'] = $this->emailValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid email address.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_INT:
             if (!$this->intValidation) {
                 $this->intValidation = new Zend_Validate_Int();
             }
             $valid['success'] = $this->intValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid integer.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_LETTERS:
             if (!$this->letterValidation) {
                 $this->letterValidation = new Zend_Validate_Alpha(true);
             }
             $valid['success'] = $this->letterValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" contains invalid characters.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_DATE:
             $valid['success'] = strtotime($value) > 0;
             $valid['errors'] = '"' . $value . '" is invalid date.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_URL:
             if (!$this->urlValidation) {
                 $this->urlValidation = new Uni_Validate_Url();
             }
             $valid['success'] = $this->urlValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid url.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_IMAGE:
             if (empty($this->validExtensions)) {
                 $this->validExtensions = array('jpg', 'jpeg', 'png', 'bmp', 'gif', 'tiff');
             }
             $extPos = strrpos($value, '.');
             if (!$extPos || !empty($this->validExtensions) && !in_array(substr($value, $extPos + 1), $this->validExtensions)) {
                 $valid['success'] = FALSE;
                 $valid['errors'] = 'Invalid image was given.';
             }
             break;
         default:
             break;
     }
     return $valid;
 }
示例#16
0
 public function isValid($value)
 {
     $valid = parent::isValid($value);
     if ($valid == false) {
         $this->_error(self::INVALID);
         return false;
     }
     return true;
 }
示例#17
0
 public function registerAction()
 {
     $name = $this->_getParam('name');
     $avatar = $this->_getParam('avatar');
     $email = $this->_getParam('email');
     $phone = $this->_getParam('phone');
     $departments = $this->_getParam('departments');
     $type = $this->_getParam('type');
     $city = $this->_getParam('city');
     $label = $this->_getParam('label');
     $country = $this->_getParam('country');
     $area = $this->_getParam('area');
     $passwd = $this->_getParam('passwd');
     $introduction = $this->_getParam('introduction');
     $longitude = $this->_getParam('longitude');
     $latitude = $this->_getParam('latitude');
     if (!$passwd) {
         $out['errno'] = '3';
         $out['msg'] = Yy_ErrMsg_Hospital::getMsg('register', $out['errno']);
         Yy_Utils::jsonOut($out);
         return;
     }
     $validatorEmail = new Zend_Validate_EmailAddress();
     if ($validatorEmail->isValid($email)) {
         $bool = Application_Model_M_Hospital::fetchByEmail($email);
         if ($bool) {
             //已注册
             $out['errno'] = '1';
         } else {
             $out['errno'] = '0';
             $hospital = new Application_Model_O_Hospital();
             $hospital->setName($name)->setEmail($email)->setPasswd(md5($passwd))->setPhone($phone)->setDepartments($departments)->setType($type)->setCity($city)->setLabel($label)->setCountry($country)->setArea($area)->setIntroduction($introduction)->setLongitude($longitude)->setLatitude($latitude);
             $certified = ceil(count($hospital->getModifiedFields()) / 3);
             $hospital->setCertified($certified);
             $hospital->save();
             //保存医院头像
             $adapter = new Zend_File_Transfer_Adapter_Http();
             $wrdir = Yy_Utils::getWriteDir();
             $adapter->setDestination($wrdir);
             if (!$adapter->receive()) {
                 $messages = $adapter->getMessages();
                 //echo implode("\n", $messages);
             }
             $filename = $adapter->getFileName();
             if (is_string($filename)) {
                 $handle = fopen($filename, 'rb');
                 $avatar = addslashes(fread($handle, filesize($filename)));
                 fclose($handle);
                 Application_Model_M_Hospital::updateAvatar($hospital->getId(), $avatar);
             }
         }
     } else {
         $out['errno'] = '2';
     }
     $out['msg'] = Yy_ErrMsg_Hospital::getMsg('register', $out['errno']);
     Yy_Utils::jsonOut($out);
 }
示例#18
0
 public function __construct($email)
 {
     $email = trim($email);
     $validator = new Zend_Validate_EmailAddress();
     if (!$validator->isValid($email)) {
         throw new SimpleCal_Exception('Not a valid email address for creating an invitation');
     }
     $this->_email = $email;
 }
示例#19
0
 /**
  * Validates email address
  * 
  * @return bool
  */
 protected function _validateEmail()
 {
     $validator = new Zend_Validate_EmailAddress();
     $msg = Sanmax_MessageStack::getInstance('SxCms_User');
     if (!$validator->isValid($this->_user->getEmail())) {
         $msg->addMessage('email', array($this->_user->getEmail()));
     }
     return false == $msg->getMessages('email');
 }
示例#20
0
 function send()
 {
     $mail = new Zend_Mail();
     $mensaje = array();
     try {
         $mail->setFrom($this->_from['mail'], $this->_from['nameSend']);
         if (!empty($this->_destinatario)) {
             foreach ($this->_destinatario as $index => $value) {
                 $validate = new Zend_Validate_EmailAddress();
                 if (is_array($value)) {
                     if (array_key_exists('mail', $value)) {
                         if ($validate->isValid($value['mail'])) {
                             $mail->addTo($value['mail'], isset($value['name']) ? $value['name'] : '');
                         } else {
                             $mensaje['EmailInvalid'][] = $value;
                         }
                     } else {
                         $mensaje['formatInvalid'][] = $value;
                     }
                 } else {
                     if ($validate->isValid($value)) {
                         $mail->addTo($value, '');
                     } else {
                         $mensaje['EmailInvalid'][] = $value;
                     }
                 }
             }
         } else {
             $mensaje['errorAplication'][] = 'debe tener almenos un destinatario';
             $this->_error = $mensaje;
         }
         if (!empty($mensaje)) {
             $this->_error = $mensaje;
             return false;
         }
         $mail->setSubject($this->_subject);
         $mail->setBodyHtml($this->_mensaje);
         $mail->send($this->_transport);
     } catch (Exception $exc) {
         $mensaje['errorAplication'][] = $exc->getMessage();
         $this->_error = $mensaje['errorAplication'];
         return false;
     }
 }
示例#21
0
 public function validate(array $attributes)
 {
     if (empty($attributes[$this->_attributeName])) {
         return true;
     }
     $attributeValues = $attributes[$this->_attributeName];
     switch ($this->_options) {
         case 'URN':
             $urnValidator = new EngineBlock_Validator_Urn();
             foreach ($attributeValues as $attributeValue) {
                 if (!$urnValidator->validate($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_URN, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         case 'HostName':
             $hostnameValidator = new Zend_Validate_Hostname();
             foreach ($attributeValues as $attributeValue) {
                 if (!$hostnameValidator->isValid($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_HOSTNAME, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         case 'URL':
             foreach ($attributeValues as $attributeValue) {
                 if (!Zend_Uri::check($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_URL, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         case 'URI':
             $uriValidator = new EngineBlock_Validator_Uri();
             foreach ($attributeValues as $attributeValue) {
                 if (!$uriValidator->validate($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_URI, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         case 'EmailAddress':
             $emailValidator = new Zend_Validate_EmailAddress();
             foreach ($attributeValues as $attributeValue) {
                 if (!$emailValidator->isValid($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_EMAIL, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         default:
             throw new EngineBlock_Exception("Unknown validate option '{$this->_options}' for attribute validation");
     }
     return true;
 }
示例#22
0
文件: Email.php 项目: sfie/pimcore
 /**
  * Helper to validate a email address
  *
  * @static
  * @param $emailAddress
  * @return string | null - returns "null" if the email address is invalid otherwise the email address is returned
  */
 public static function validateEmailAddress($emailAddress)
 {
     if (is_null(self::$validator)) {
         self::$validator = new \Zend_Validate_EmailAddress();
     }
     $emailAddress = trim($emailAddress);
     if (self::$validator->isValid($emailAddress)) {
         return $emailAddress;
     }
 }
示例#23
0
 public function isValid($value)
 {
     $valid = parent::isValid($value);
     // only one error message
     if (!$valid) {
         $this->_messages = array(current($this->_messages));
         $this->_errors = array(current($this->_errors));
     }
     return $valid;
 }
 /**
  * Validiert und setzt die übergebene E-Mail Adresse
  * @param string $emailaddress
  * @throws Dragon_Application_Exception_User
  * @return DragonX_Emailaddress_Record_Emailaddress
  */
 public function validateEmailaddress($emailaddress)
 {
     $emailaddress = strtolower($emailaddress);
     $validatorEmailaddress = new Zend_Validate_EmailAddress();
     if (!$validatorEmailaddress->isValid($emailaddress)) {
         throw new Dragon_Application_Exception_User('invalid emailaddress', array('emailaddress' => $emailaddress));
     }
     $this->emailaddress = $emailaddress;
     return $this;
 }
示例#25
0
 /**
  * Validates an e-mail address
  *
  * @param   string $address Address
  * @throws  Opus_Mail_Exception Thrown if the e-mail address is not valid
  * @return  string              Address
  */
 public static function validateAddress($address)
 {
     $validator = new Zend_Validate_EmailAddress();
     if ($validator->isValid($address) === false) {
         foreach ($validator->getMessages() as $message) {
             throw new Opus_Mail_Exception($message);
         }
     }
     return $address;
 }
示例#26
0
 public function isValid($value, $context = null)
 {
     if (parent::isValid($value)) {
         return true;
     }
     $this->_messages = array();
     $this->_errors = array();
     $this->_error(self::INVALID);
     return false;
 }
示例#27
0
 public function validateEmail($email)
 {
     //Check each post variable for blanks or spaces
     $email_validator = new Zend_Validate_EmailAddress();
     if (!$email_validator->isValid($email)) {
         foreach ($email_validator->getMessages() as $error) {
             array_push($this->messages, $error);
         }
     }
     return $this->messages;
 }
示例#28
0
 protected function _isValidEmail($supervisorEmails)
 {
     $emails = explode(',', $supervisorEmails);
     $emailValidator = new Zend_Validate_EmailAddress();
     foreach ($emails as $email) {
         if (!$emailValidator->isValid($email)) {
             return false;
         }
     }
     return true;
 }
示例#29
0
 public function process(Zend_Controller_Request_Abstract $request)
 {
     // validate the username
     $this->username = trim($request->getPost('username'));
     if (strlen($this->username) == 0) {
         $this->addError('username', 'Please enter a username');
     } else {
         if (!DatabaseObject_User::IsValidUsername($this->username)) {
             $this->addError('username', 'Please enter a valid username');
         } else {
             if ($this->user->usernameExists($this->username)) {
                 $this->addError('username', 'The selected username already exists');
             } else {
                 $this->user->username = $this->username;
             }
         }
     }
     // validate first and last name
     $this->first_name = $this->sanitize($request->getPost('first_name'));
     if (strlen($this->first_name) == 0) {
         $this->addError('first_name', 'Please enter your first name');
     } else {
         $this->user->profile->first_name = $this->first_name;
     }
     $this->last_name = $this->sanitize($request->getPost('last_name'));
     if (strlen($this->last_name) == 0) {
         $this->addError('last_name', 'Please enter your last name');
     } else {
         $this->user->profile->last_name = $this->last_name;
     }
     // validate the e-mail address
     $this->email = $this->sanitize($request->getPost('email'));
     $validator = new Zend_Validate_EmailAddress();
     if (strlen($this->email) == 0) {
         $this->addError('email', 'Please enter your e-mail address');
     } else {
         if (!$validator->isValid($this->email)) {
             $this->addError('email', 'Please enter a valid e-mail address');
         } else {
             $this->user->profile->email = $this->email;
         }
     }
     // validate CAPTCHA phrase
     $session = new Zend_Session_Namespace('captcha');
     $this->captcha = $this->sanitize($request->getPost('captcha'));
     if ($this->captcha != $session->phrase) {
         $this->addError('captcha', 'Please enter the correct phrase');
     }
     if (!$this->_validateOnly && !$this->hasError()) {
         $this->user->save();
         unset($session->phrase);
     }
     return !$this->hasError();
 }
示例#30
0
 /**
  * Constructor.
  * @param $affiliateWindow
  * @return Oara_Network_Aw_Api
  */
 public function __construct($credentials)
 {
     ini_set('default_socket_timeout', '120');
     $user = $credentials['user'];
     $password = $credentials['apiPassword'];
     $passwordExport = $credentials['password'];
     $this->_exportOverviewParameters = array(new Oara_Curl_Parameter('post', 'yes'), new Oara_Curl_Parameter('merchant', ''), new Oara_Curl_Parameter('limit', '25'), new Oara_Curl_Parameter('submit.x', '75'), new Oara_Curl_Parameter('submit.y', '11'), new Oara_Curl_Parameter('submit', 'submit'));
     //Login to the website
     $validator = new Zend_Validate_EmailAddress();
     if ($validator->isValid($user)) {
         //login through darwin
         $loginUrl = 'https://darwin.affiliatewindow.com/login?';
         $valuesLogin = array(new Oara_Curl_Parameter('email', $user), new Oara_Curl_Parameter('password', $passwordExport), new Oara_Curl_Parameter('formuserloginlogin', ''));
         $this->_exportClient = new Oara_Curl_Access($loginUrl, $valuesLogin, $credentials);
         $urls = array();
         $urls[] = new Oara_Curl_Request('http://darwin.affiliatewindow.com/user/', array());
         $exportReport = $this->_exportClient->get($urls);
         if (preg_match_all("/id=\"goDarwin(.*)\"/", $exportReport[0], $matches)) {
             foreach ($matches[1] as $user) {
                 $urls = array();
                 $urls[] = new Oara_Curl_Request('http://darwin.affiliatewindow.com/affiliate/' . $user, array());
                 $exportReport = $this->_exportClient->get($urls);
                 if (preg_match("/<li>Payment<ul><li><a class=\"arrow sectionList\" href=\"(.*)\">/", $exportReport[0], $matches)) {
                     $urls = array();
                     $urls[] = new Oara_Curl_Request('http://darwin.affiliatewindow.com' . $matches[1], array());
                     $exportReport = $this->_exportClient->get($urls);
                 } else {
                     throw new Exception("It couldn't connect to darwin");
                 }
                 $urls = array();
                 $urls[] = new Oara_Curl_Request('https://www.affiliatewindow.com/affiliates/accountdetails.php', array());
                 $exportReport = $this->_exportClient->get($urls);
                 $dom = new Zend_Dom_Query($exportReport[0]);
                 $apiPassword = $dom->query('#aw_api_password_hash');
                 $apiPassword = $apiPassword->current();
                 if ($apiPassword != null && $apiPassword->nodeValue == $password) {
                     break;
                 }
             }
         }
     } else {
         throw new Exception("It's not an email");
     }
     $nameSpace = 'http://api.affiliatewindow.com/';
     $wsdlUrl = 'http://api.affiliatewindow.com/v3/AffiliateService?wsdl';
     //Setting the client.
     $this->_apiClient = new Oara_Import_Soap_Client($wsdlUrl, array('login' => $user, 'encoding' => 'UTF-8', 'password' => $password, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE, 'soap_version' => SOAP_1_1));
     //Setting the headers
     $soapHeader1 = new SoapHeader($nameSpace, 'UserAuthentication', array('iId' => $user, 'sPassword' => $password, 'sType' => 'affiliate'), true, $nameSpace);
     $soapHeader2 = new SoapHeader($nameSpace, 'getQuota', true, true, $nameSpace);
     //Adding the headers
     $this->_apiClient->addSoapInputHeader($soapHeader1, true);
     $this->_apiClient->addSoapInputHeader($soapHeader2, true);
 }