当前位置: 首页>>代码示例>>PHP>>正文


PHP Validator::isEmail方法代码示例

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


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

示例1: validated

 public final function validated()
 {
     $okay = true;
     if (trim($this->agentId) == "") {
         $this->setError("Agent id not set or there is an error during the submission of the form contact administrator");
         $okay = false;
     } else {
         if (!Validator::isEmail($this->email)) {
             $this->setError("Enter a valid email address");
             $okay = false;
         } else {
             if (!Validator::isWord($this->firstname) || strlen(trim($this->firstname)) <= 2) {
                 $this->setError("Enter a valid firstname!");
                 $okay = false;
             } else {
                 if (!Validator::isWord($this->lastname) || strlen(trim($this->lastname)) <= 2) {
                     $this->setError("Enter a valid lastname!");
                     $okay = false;
                 } else {
                     if (!Validator::isNumber($this->phonenumber)) {
                         $this->setError("Enter a valid  phone number e.g +44(0)7765441232!");
                         $okay = false;
                     } else {
                         if (strlen(trim($this->password)) < 6) {
                             $this->setError("Enter a valid password that is more than 5 character!");
                             $okay = false;
                         }
                     }
                 }
             }
         }
     }
     return $okay;
 }
开发者ID:jimobama,项目名称:app,代码行数:34,代码来源:Agent.php

示例2: validate

 private function validate(User $user)
 {
     $okay = false;
     if ($user == null) {
         return $okay;
     }
     if (!Validator::isEmail($user->getEmail())) {
         $email = $user->getEmail();
         if ($email == "" || $email == null) {
             $this->message = "User email address required";
         } else {
             $this->message = "Invalid email[{$email}] entry";
         }
     } elseif (!Validator::IsWord($user->getFullname())) {
         $fullname = $user->getFullname();
         if ($fullname == null || $fullname == "") {
             $this->message = "User fullname is required!";
         } else {
             $this->message = "Enter a valid user name ";
         }
     } else {
         if (Validator::IsWord($user->getGender())) {
             $this->message = "Enter your gender";
         } else {
             $okay = true;
         }
     }
     return $okay;
 }
开发者ID:jimobama,项目名称:fffddffd,代码行数:29,代码来源:TryCreateUserController.php

示例3: test_isEmail

 public function test_isEmail()
 {
     $arrEmails = array('test@test.ch' => true, 'test@test.c' => false, 'test@test.' => false, 'test@test' => false, 'test@' => false, 'test' => false, Idna::encodeEmail('test@tèst.ch') => true);
     foreach ($arrEmails as $strAddress => $blnValidity) {
         $this->assertEquals(Validator::isEmail($strAddress), $blnValidity);
     }
 }
开发者ID:anthu,项目名称:contao-unittests,代码行数:7,代码来源:ValidatorTest.php

示例4: importUserHook

 /**
  * This Hook provides case-insensitive contao-login by email usernames
  *
  * RFC 5321, section-2.3.11 says that email addresses should be treated as case-insensitive
  *
  * @param $strUser
  * @param $strPassword
  * @param $strTable
  *
  * @return bool
  */
 public function importUserHook($strUser, $strPassword, $strTable)
 {
     if (!\Validator::isEmail($strUser)) {
         return false;
     }
     switch ($strTable) {
         case 'tl_member':
             $objUser = \FrontendUser::getInstance();
             if ($objUser->findBy('LOWER(username)', strtolower($strUser)) !== false) {
                 // set post user name to the users username
                 \Input::setPost('username', $objUser->username);
                 return true;
             }
             break;
     }
     return false;
 }
开发者ID:heimrichhannot,项目名称:contao-email2username,代码行数:28,代码来源:Hooks.php

示例5: generate

 /**
  * Store Login Module ID in Session, required by LdapAuth (Module config)
  * @return string
  */
 public function generate()
 {
     // Login
     if (\Input::post('FORM_SUBMIT') == 'tl_login') {
         if (\Input::post('username', true) && \Input::post('password', true)) {
             $objMember = \MemberModel::findBy('username', \Input::post('username', true));
             if ($objMember !== null) {
                 // always reset the password to a random value, otherwise checkCredentialsHook will never be triggered
                 LdapMember::resetPassword($objMember, \Input::post('username', true));
             }
         }
         // validate email
         if ($GLOBALS['TL_CONFIG']['ldap_uid'] == 'mail' && !\Validator::isEmail(\Input::post('username', true))) {
             \Message::addError($GLOBALS['TL_LANG']['ERR']['email']);
             $this->reload();
         }
     }
     $strParent = parent::generate();
     return $strParent;
 }
开发者ID:heimrichhannot,项目名称:contao-ldap,代码行数:24,代码来源:ModuleLdapLogin.php

示例6: send

    /**
     * Renturn a form to choose an existing style sheet and import it
     * @param \DataContainer
     * @return string
     */
    public function send(\DataContainer $objDc)
    {
        if (TL_MODE == 'BE') {
            $GLOBALS['TL_CSS'][] = 'system/modules/newsletter_content/assets/css/style.css';
            if ($this->isFlexible) {
                $GLOBALS['TL_CSS'][] = 'system/modules/newsletter_content/assets/css/style-flexible.css';
            }
        }
        $objNewsletter = $this->Database->prepare("SELECT n.*, c.useSMTP, c.smtpHost, c.smtpPort, c.smtpUser, c.smtpPass FROM tl_newsletter n LEFT JOIN tl_newsletter_channel c ON n.pid=c.id WHERE n.id=?")->limit(1)->execute($objDc->id);
        // Return if there is no newsletter
        if ($objNewsletter->numRows < 1) {
            return '';
        }
        // Overwrite the SMTP configuration
        if ($objNewsletter->useSMTP) {
            $GLOBALS['TL_CONFIG']['useSMTP'] = true;
            $GLOBALS['TL_CONFIG']['smtpHost'] = $objNewsletter->smtpHost;
            $GLOBALS['TL_CONFIG']['smtpUser'] = $objNewsletter->smtpUser;
            $GLOBALS['TL_CONFIG']['smtpPass'] = $objNewsletter->smtpPass;
            $GLOBALS['TL_CONFIG']['smtpEnc'] = $objNewsletter->smtpEnc;
            $GLOBALS['TL_CONFIG']['smtpPort'] = $objNewsletter->smtpPort;
        }
        // Add default sender address
        if ($objNewsletter->sender == '') {
            list($objNewsletter->senderName, $objNewsletter->sender) = \String::splitFriendlyEmail($GLOBALS['TL_CONFIG']['adminEmail']);
        }
        $arrAttachments = array();
        $blnAttachmentsFormatError = false;
        // Add attachments
        if ($objNewsletter->addFile) {
            $files = deserialize($objNewsletter->files);
            if (!empty($files) && is_array($files)) {
                $objFiles = \FilesModel::findMultipleByUuids($files);
                if ($objFiles === null) {
                    if (!\Validator::isUuid($files[0])) {
                        $blnAttachmentsFormatError = true;
                        \Message::addError($GLOBALS['TL_LANG']['ERR']['version2format']);
                    }
                } else {
                    while ($objFiles->next()) {
                        if (is_file(TL_ROOT . '/' . $objFiles->path)) {
                            $arrAttachments[] = $objFiles->path;
                        }
                    }
                }
            }
        }
        // Get content
        $html = '';
        $objContentElements = \ContentModel::findPublishedByPidAndTable($objNewsletter->id, 'tl_newsletter');
        if ($objContentElements !== null) {
            if (!defined('NEWSLETTER_CONTENT_PREVIEW')) {
                define('NEWSLETTER_CONTENT_PREVIEW', true);
            }
            while ($objContentElements->next()) {
                $html .= $this->getContentElement($objContentElements->id);
            }
        }
        // Replace insert tags
        $text = $this->replaceInsertTags($objNewsletter->text);
        $html = $this->replaceInsertTags($html);
        // Convert relative URLs
        $html = $this->convertRelativeUrls($html);
        // Set back to object
        $objNewsletter->content = $html;
        // Send newsletter
        if (!$blnAttachmentsFormatError && \Input::get('token') != '' && \Input::get('token') == $this->Session->get('tl_newsletter_send')) {
            $referer = preg_replace('/&(amp;)?(start|mpc|token|recipient|preview)=[^&]*/', '', \Environment::get('request'));
            // Preview
            if (isset($_GET['preview'])) {
                // Check the e-mail address
                if (!\Validator::isEmail(\Input::get('recipient', true))) {
                    $_SESSION['TL_PREVIEW_MAIL_ERROR'] = true;
                    $this->redirect($referer);
                }
                // get preview recipient
                $arrRecipient = array();
                $strEmail = urldecode(\Input::get('recipient', true));
                $objRecipient = $this->Database->prepare("SELECT * FROM tl_member m WHERE email=? ORDER BY email")->limit(1)->execute($strEmail);
                if ($objRecipient->num_rows < 1) {
                    $arrRecipient['email'] = $strEmail;
                } else {
                    $arrRecipient = $objRecipient->row();
                }
                $arrRecipient = array_merge($arrRecipient, array('extra' => '&preview=1', 'tracker_png' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $strEmail . '&preview=1&t=png', 'tracker_gif' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $strEmail . '&preview=1&t=gif', 'tracker_css' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $strEmail . '&preview=1&t=css', 'tracker_js' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $strEmail . '&preview=1&t=js'));
                // Send
                $objEmail = $this->generateEmailObject($objNewsletter, $arrAttachments);
                $objNewsletter->email = $strEmail;
                $this->sendNewsletter($objEmail, $objNewsletter, $arrRecipient, $text, $html);
                // Redirect
                \Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_newsletter']['confirm'], 1));
                $this->redirect($referer);
            }
            // Get the total number of recipients
            $objTotal = $this->Database->prepare("SELECT COUNT(DISTINCT email) AS count FROM tl_newsletter_recipients WHERE pid=? AND active=1")->execute($objNewsletter->pid);
//.........这里部分代码省略.........
开发者ID:naitsirk68,项目名称:newsletter_content,代码行数:101,代码来源:NewsletterContent.php

示例7: Validator

	if($validator->isValid()) {
		$auth->avatar($db, $user_id, $avatar);
		move_uploaded_file($_FILES['avatar']['tmp_name'], $avatar);
		$info_user->avatar = $avatar;
	}
	else { 
		$errors = $validator->getErrors();
	}*/
if (isset($_POST['email_modif'])) {
    $validator = new Validator($_POST);
    if (!empty($_POST['pass']) && !empty($_POST['email'])) {
        $pass = $_POST['pass'];
        $password = $auth->hashPassword($pass);
        $email = htmlspecialchars($_POST['email']);
        if ($password == $info_user->password) {
            $validator->isEmail('email', "Votre email n'est pas valide");
            if ($validator->isValid()) {
                $validator->isUniq('email', $db, 'users', 'Cet email est déjà utilisé pour un autre compte');
            }
            if ($validator->isValid()) {
                $db->query('UPDATE users SET email = ? WHERE id_user = ?', [$email, $user_id]);
                $_SESSION['flash']['success'] = "Votre email a bien été mis à jour";
                $info_user->email = $email;
            } else {
                $errors = $validator->getErrors();
            }
        } else {
            $_SESSION['flash']['danger'] = "Erreur dans le mot de passs actuel";
        }
    } else {
        $_SESSION['flash']['danger'] = "Veuillez remplir tous les champs";
开发者ID:Harmeko,项目名称:tweet_academie,代码行数:31,代码来源:account.php

示例8: removeRecipient

 /**
  * Remove the recipient
  */
 protected function removeRecipient()
 {
     $arrChannels = \Input::post('channels');
     $arrChannels = array_intersect($arrChannels, $this->nl_channels);
     // see #3240
     // Check the selection
     if (!is_array($arrChannels) || empty($arrChannels)) {
         $_SESSION['UNSUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['noChannels'];
         $this->reload();
     }
     $varInput = \Idna::encodeEmail(\Input::post('email', true));
     // Validate e-mail address
     if (!\Validator::isEmail($varInput)) {
         $_SESSION['UNSUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['email'];
         $this->reload();
     }
     $arrSubscriptions = array();
     // Get the existing active subscriptions
     if (($objSubscription = \NewsletterRecipientsModel::findBy(array("email=? AND active=1"), $varInput)) !== null) {
         $arrSubscriptions = $objSubscription->fetchEach('pid');
     }
     $arrRemove = array_intersect($arrChannels, $arrSubscriptions);
     // Return if there are no subscriptions to remove
     if (!is_array($arrRemove) || empty($arrRemove)) {
         $_SESSION['UNSUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['unsubscribed'];
         $this->reload();
     }
     // Remove the subscriptions
     if (($objRemove = \NewsletterRecipientsModel::findByEmailAndPids($varInput, $arrRemove)) !== null) {
         while ($objRemove->next()) {
             $objRemove->delete();
         }
     }
     // Get the channels
     $objChannels = \NewsletterChannelModel::findByIds($arrRemove);
     $arrChannels = $objChannels->fetchEach('title');
     // Log activity
     $this->log($varInput . ' unsubscribed from ' . implode(', ', $arrChannels), 'ModuleUnsubscribe removeRecipient()', TL_NEWSLETTER);
     // HOOK: post unsubscribe callback
     if (isset($GLOBALS['TL_HOOKS']['removeRecipient']) && is_array($GLOBALS['TL_HOOKS']['removeRecipient'])) {
         foreach ($GLOBALS['TL_HOOKS']['removeRecipient'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($varInput, $arrRemove);
         }
     }
     // Prepare the e-mail text
     $strText = str_replace('##domain##', \Environment::get('host'), $this->nl_unsubscribe);
     $strText = str_replace(array('##channel##', '##channels##'), implode("\n", $arrChannels), $strText);
     // Confirmation e-mail
     $objEmail = new \Email();
     $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
     $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
     $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['nl_subject'], \Environment::get('host'));
     $objEmail->text = $strText;
     $objEmail->sendTo($varInput);
     // Redirect to the jumpTo page
     if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null) {
         $this->redirect($this->generateFrontendUrl($objTarget->row()));
     }
     $_SESSION['UNSUBSCRIBE_CONFIRM'] = $GLOBALS['TL_LANG']['MSC']['nl_removed'];
     $this->reload();
 }
开发者ID:rburch,项目名称:core,代码行数:65,代码来源:ModuleUnsubscribe.php

示例9: setReturnPath

 /**
  * Set the Return-Path property.
  * @param string $address The email address.
  */
 public function setReturnPath($address)
 {
     $this->prepareAddr($address);
     if (!Validator::isEmail($address)) {
         throw new EmailException(array("Email address '%s' is invalid.", $address));
     }
     $this->returnPath = $address;
 }
开发者ID:rolandrajko,项目名称:BREAD,代码行数:12,代码来源:Email.php

示例10: addRecipient

 /**
  * Add a new recipient
  */
 protected function addRecipient()
 {
     if (!\Environment::get('isAjaxRequest')) {
         return parent::addRecipient();
     }
     $arrChannels = \Input::post('channels');
     if (!is_array($arrChannels)) {
         $_SESSION['UNSUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['noChannels'];
         return false;
     }
     $arrChannels = array_intersect($arrChannels, $this->nl_channels);
     // see #3240
     // Check the selection
     if (!is_array($arrChannels) || empty($arrChannels)) {
         $_SESSION['SUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['noChannels'];
         return false;
     }
     $varInput = \Idna::encodeEmail(\Input::post('email', true));
     // Validate the e-mail address
     if (!\Validator::isEmail($varInput)) {
         $_SESSION['SUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['email'];
         return false;
     }
     $arrSubscriptions = array();
     // Get the existing active subscriptions
     if (($objSubscription = \NewsletterRecipientsModel::findBy(array("email=? AND active=1"), $varInput)) !== null) {
         $arrSubscriptions = $objSubscription->fetchEach('pid');
     }
     $arrNew = array_diff($arrChannels, $arrSubscriptions);
     // Return if there are no new subscriptions
     if (!is_array($arrNew) || empty($arrNew)) {
         $_SESSION['SUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['subscribed'];
         return false;
     }
     // Remove old subscriptions that have not been activated yet
     if (($objOld = \NewsletterRecipientsModel::findBy(array("email=? AND active=''"), $varInput)) !== null) {
         while ($objOld->next()) {
             $objOld->delete();
         }
     }
     $time = time();
     $strToken = md5(uniqid(mt_rand(), true));
     // Add the new subscriptions
     foreach ($arrNew as $id) {
         $objRecipient = new \NewsletterRecipientsModel();
         $objRecipient->pid = $id;
         $objRecipient->tstamp = $time;
         $objRecipient->email = $varInput;
         $objRecipient->active = '';
         $objRecipient->addedOn = $time;
         $objRecipient->ip = $this->anonymizeIp(\Environment::get('ip'));
         $objRecipient->token = $strToken;
         $objRecipient->confirmed = '';
         $objRecipient->save();
     }
     // Get the channels
     $objChannel = \NewsletterChannelModel::findByIds($arrChannels);
     // Prepare the e-mail text
     $strText = str_replace('##token##', $strToken, $this->nl_subscribe);
     $strText = str_replace('##domain##', \Idna::decode(\Environment::get('host')), $strText);
     $strText = str_replace('##link##', \Idna::decode(\Environment::get('base')) . \Environment::get('request') . (\Config::get('disableAlias') || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $strToken, $strText);
     $strText = str_replace(array('##channel##', '##channels##'), implode("\n", $objChannel->fetchEach('title')), $strText);
     // Activation e-mail
     $objEmail = new \Email();
     $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
     $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
     $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['nl_subject'], \Idna::decode(\Environment::get('host')));
     $objEmail->text = $strText;
     $objEmail->sendTo($varInput);
     // Redirect to the jumpTo page
     if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null) {
         $this->redirect($this->generateFrontendUrl($objTarget->row()));
     }
     $_SESSION['SUBSCRIBE_CONFIRM'] = $GLOBALS['TL_LANG']['MSC']['nl_confirm'];
     return true;
 }
开发者ID:heimrichhannot,项目名称:contao-bootstrapper,代码行数:79,代码来源:ModuleAjaxSubscribe.php

示例11: isValidEmailAddress

 /**
  * Validate an e-mail address
  * 
  * @param string $strEmail The e-mail address
  * 
  * @return boolean True if it is a valid e-mail address
  * 
  * @deprecated Use Validator::isEmail() instead
  */
 protected function isValidEmailAddress($strEmail)
 {
     return \Validator::isEmail($strEmail);
 }
开发者ID:rburch,项目名称:core,代码行数:13,代码来源:System.php

示例12: validator


//.........这里部分代码省略.........
                     }
                 }
                 break;
                 // Check whether the current value is a valid time format
             // Check whether the current value is a valid time format
             case 'time':
                 if (!\Validator::isTime($varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['time'], \Date::getInputFormat(\Date::getNumericTimeFormat())));
                 }
                 break;
                 // Check whether the current value is a valid date and time format
             // Check whether the current value is a valid date and time format
             case 'datim':
                 if (!\Validator::isDatim($varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['dateTime'], \Date::getInputFormat(\Date::getNumericDatimFormat())));
                 } else {
                     // Validate the date (see #5086)
                     try {
                         new \Date($varInput, \Date::getNumericDatimFormat());
                     } catch (\OutOfBoundsException $e) {
                         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varInput));
                     }
                 }
                 break;
                 // Check whether the current value is a valid friendly name e-mail address
             // Check whether the current value is a valid friendly name e-mail address
             case 'friendly':
                 list($strName, $varInput) = \String::splitFriendlyEmail($varInput);
                 // no break;
                 // Check whether the current value is a valid e-mail address
             // no break;
             // Check whether the current value is a valid e-mail address
             case 'email':
                 if (!\Validator::isEmail($varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['email'], $this->strLabel));
                 }
                 if ($this->rgxp == 'friendly' && $strName != '') {
                     $varInput = $strName . ' [' . $varInput . ']';
                 }
                 break;
                 // Check whether the current value is list of valid e-mail addresses
             // Check whether the current value is list of valid e-mail addresses
             case 'emails':
                 $arrEmails = trimsplit(',', $varInput);
                 foreach ($arrEmails as $strEmail) {
                     $strEmail = \Idna::encodeEmail($strEmail);
                     if (!\Validator::isEmail($strEmail)) {
                         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['emails'], $this->strLabel));
                         break;
                     }
                 }
                 break;
                 // Check whether the current value is a valid URL
             // Check whether the current value is a valid URL
             case 'url':
                 if (!\Validator::isUrl($varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['url'], $this->strLabel));
                 }
                 break;
                 // Check whether the current value is a valid alias
             // Check whether the current value is a valid alias
             case 'alias':
                 if (!\Validator::isAlias($varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['alias'], $this->strLabel));
                 }
                 break;
开发者ID:juergen83,项目名称:contao,代码行数:67,代码来源:Widget.php

示例13: validator


//.........这里部分代码省略.........
                 // Check whether the current value is a valid date format
             // Check whether the current value is a valid date format
             case 'date':
                 $objDate = new \Date();
                 if (!preg_match('~^' . $objDate->getRegexp($GLOBALS['TL_CONFIG']['dateFormat']) . '$~i', $varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['date'], $objDate->getInputFormat($GLOBALS['TL_CONFIG']['dateFormat'])));
                 }
                 break;
                 // Check whether the current value is a valid time format
             // Check whether the current value is a valid time format
             case 'time':
                 $objDate = new \Date();
                 if (!preg_match('~^' . $objDate->getRegexp($GLOBALS['TL_CONFIG']['timeFormat']) . '$~i', $varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['time'], $objDate->getInputFormat($GLOBALS['TL_CONFIG']['timeFormat'])));
                 }
                 break;
                 // Check whether the current value is a valid date and time format
             // Check whether the current value is a valid date and time format
             case 'datim':
                 $objDate = new \Date();
                 if (!preg_match('~^' . $objDate->getRegexp($GLOBALS['TL_CONFIG']['datimFormat']) . '$~i', $varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['dateTime'], $objDate->getInputFormat($GLOBALS['TL_CONFIG']['datimFormat'])));
                 }
                 break;
                 // Check whether the current value is a valid friendly name e-mail address
             // Check whether the current value is a valid friendly name e-mail address
             case 'friendly':
                 list($strName, $varInput) = $this->splitFriendlyName($varInput);
                 // no break;
                 // Check whether the current value is a valid e-mail address
             // no break;
             // Check whether the current value is a valid e-mail address
             case 'email':
                 if (!\Validator::isEmail($varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['email'], $this->strLabel));
                 }
                 if ($this->rgxp == 'friendly' && $strName != '') {
                     $varInput = $strName . ' [' . $varInput . ']';
                 }
                 break;
                 // Check whether the current value is list of valid e-mail addresses
             // Check whether the current value is list of valid e-mail addresses
             case 'emails':
                 $arrEmails = trimsplit(',', $varInput);
                 foreach ($arrEmails as $strEmail) {
                     $strEmail = \Idna::encodeEmail($strEmail);
                     if (!\Validator::isEmail($strEmail)) {
                         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['emails'], $this->strLabel));
                         break;
                     }
                 }
                 break;
                 // Check whether the current value is a valid URL
             // Check whether the current value is a valid URL
             case 'url':
                 if (!\Validator::isUrl($varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['url'], $this->strLabel));
                 }
                 break;
                 // Check whether the current value is a valid alias
             // Check whether the current value is a valid alias
             case 'alias':
                 if (!\Validator::isAlias($varInput)) {
                     $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['alias'], $this->strLabel));
                 }
                 break;
开发者ID:rikaix,项目名称:core,代码行数:67,代码来源:Widget.php

示例14: compileRecipients

 /**
  * Generate CC or BCC recipients from comma separated string
  *
  * @param string $strRecipients
  * @param array  $arrTokens
  *
  * @return array
  */
 public static function compileRecipients($strRecipients, $arrTokens)
 {
     // Replaces tokens first so that tokens can contain a list of recipients.
     $strRecipients = \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($strRecipients, $arrTokens, static::NO_TAGS | static::NO_BREAKS);
     $arrRecipients = array();
     foreach ((array) trimsplit(',', $strRecipients) as $strAddress) {
         if ($strAddress != '') {
             list($strName, $strEmail) = \String::splitFriendlyEmail($strAddress);
             // Address could become empty through invalid insert tag
             if ($strAddress == '' || !\Validator::isEmail($strEmail)) {
                 continue;
             }
             $arrRecipients[] = $strAddress;
         }
     }
     return $arrRecipients;
 }
开发者ID:seaneble,项目名称:contao-notification_center,代码行数:25,代码来源:String.php

示例15: importRecipients

    /**
     * Return a form to choose a CSV file and import it
     *
     * @return string
     */
    public function importRecipients()
    {
        if (\Input::get('key') != 'import') {
            return '';
        }
        $this->import('BackendUser', 'User');
        $class = $this->User->uploader;
        // See #4086 and #7046
        if (!class_exists($class) || $class == 'DropZone') {
            $class = 'FileUpload';
        }
        /** @var \FileUpload $objUploader */
        $objUploader = new $class();
        // Import CSS
        if (\Input::post('FORM_SUBMIT') == 'tl_recipients_import') {
            $arrUploaded = $objUploader->uploadTo('system/tmp');
            if (empty($arrUploaded)) {
                \Message::addError($GLOBALS['TL_LANG']['ERR']['all_fields']);
                $this->reload();
            }
            $time = time();
            $intTotal = 0;
            $intInvalid = 0;
            foreach ($arrUploaded as $strCsvFile) {
                $objFile = new \File($strCsvFile, true);
                if ($objFile->extension != 'csv') {
                    \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filetype'], $objFile->extension));
                    continue;
                }
                // Get separator
                switch (\Input::post('separator')) {
                    case 'semicolon':
                        $strSeparator = ';';
                        break;
                    case 'tabulator':
                        $strSeparator = "\t";
                        break;
                    case 'linebreak':
                        $strSeparator = "\n";
                        break;
                    default:
                        $strSeparator = ',';
                        break;
                }
                $arrRecipients = array();
                $resFile = $objFile->handle;
                while (($arrRow = @fgetcsv($resFile, null, $strSeparator)) !== false) {
                    $arrRecipients = array_merge($arrRecipients, $arrRow);
                }
                $arrRecipients = array_filter(array_unique($arrRecipients));
                foreach ($arrRecipients as $strRecipient) {
                    // Skip invalid entries
                    if (!\Validator::isEmail($strRecipient)) {
                        $this->log('Recipient address "' . $strRecipient . '" seems to be invalid and has been skipped', __METHOD__, TL_ERROR);
                        ++$intInvalid;
                        continue;
                    }
                    // Check whether the e-mail address exists
                    $objRecipient = $this->Database->prepare("SELECT COUNT(*) AS count FROM tl_newsletter_recipients WHERE pid=? AND email=?")->execute(\Input::get('id'), $strRecipient);
                    if ($objRecipient->count < 1) {
                        $this->Database->prepare("INSERT INTO tl_newsletter_recipients SET pid=?, tstamp={$time}, email=?, active=1")->execute(\Input::get('id'), $strRecipient);
                        ++$intTotal;
                    }
                }
            }
            \Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_newsletter_recipients']['confirm'], $intTotal));
            if ($intInvalid > 0) {
                \Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_newsletter_recipients']['invalid'], $intInvalid));
            }
            \System::setCookie('BE_PAGE_OFFSET', 0, 0);
            $this->reload();
        }
        // Return form
        return '
<div id="tl_buttons">
<a href="' . ampersand(str_replace('&key=import', '', \Environment::get('request'))) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>
' . \Message::generate() . '
<form action="' . ampersand(\Environment::get('request'), true) . '" id="tl_recipients_import" class="tl_form" method="post" enctype="multipart/form-data">
<div class="tl_formbody_edit">
<input type="hidden" name="FORM_SUBMIT" value="tl_recipients_import">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">
<input type="hidden" name="MAX_FILE_SIZE" value="' . \Config::get('maxFileSize') . '">

<div class="tl_tbox">
  <h3><label for="separator">' . $GLOBALS['TL_LANG']['MSC']['separator'][0] . '</label></h3>
  <select name="separator" id="separator" class="tl_select" onfocus="Backend.getScrollOffset()">
    <option value="comma">' . $GLOBALS['TL_LANG']['MSC']['comma'] . '</option>
    <option value="semicolon">' . $GLOBALS['TL_LANG']['MSC']['semicolon'] . '</option>
    <option value="tabulator">' . $GLOBALS['TL_LANG']['MSC']['tabulator'] . '</option>
    <option value="linebreak">' . $GLOBALS['TL_LANG']['MSC']['linebreak'] . '</option>
  </select>' . ($GLOBALS['TL_LANG']['MSC']['separator'][1] != '' ? '
  <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['MSC']['separator'][1] . '</p>' : '') . '
  <h3>' . $GLOBALS['TL_LANG']['MSC']['source'][0] . '</h3>' . $objUploader->generateMarkup() . (isset($GLOBALS['TL_LANG']['MSC']['source'][1]) ? '
  <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['MSC']['source'][1] . '</p>' : '') . '
//.........这里部分代码省略.........
开发者ID:juergen83,项目名称:contao,代码行数:101,代码来源:Newsletter.php


注:本文中的Validator::isEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。