本文整理汇总了PHP中StringUtil::splitFriendlyEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::splitFriendlyEmail方法的具体用法?PHP StringUtil::splitFriendlyEmail怎么用?PHP StringUtil::splitFriendlyEmail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::splitFriendlyEmail方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the controller
*/
public function run()
{
global $objPage;
$pageId = $this->getPageIdFromUrl();
$objRootPage = null;
// Load a website root page object if there is no page ID
if ($pageId === null) {
$objRootPage = $this->getRootPageFromUrl();
/** @var \PageRoot $objHandler */
$objHandler = new $GLOBALS['TL_PTY']['root']();
$pageId = $objHandler->generate($objRootPage->id, true, true);
} elseif ($pageId === false) {
$this->User->authenticate();
/** @var \PageError404 $objHandler */
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($pageId);
} elseif (\Config::get('rewriteURL') && strncmp(\Environment::get('request'), 'index.php/', 10) === 0) {
$this->User->authenticate();
/** @var \PageError403 $objHandler */
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($pageId);
}
// Get the current page object(s)
$objPage = \PageModel::findPublishedByIdOrAlias($pageId);
// Check the URL and language of each page if there are multiple results
if ($objPage !== null && $objPage->count() > 1) {
$objNewPage = null;
$arrPages = array();
// Order by domain and language
while ($objPage->next()) {
/** @var \PageModel $objModel */
$objModel = $objPage->current();
$objCurrentPage = $objModel->loadDetails();
$domain = $objCurrentPage->domain ?: '*';
$arrPages[$domain][$objCurrentPage->rootLanguage] = $objCurrentPage;
// Also store the fallback language
if ($objCurrentPage->rootIsFallback) {
$arrPages[$domain]['*'] = $objCurrentPage;
}
}
$strHost = \Environment::get('host');
// Look for a root page whose domain name matches the host name
if (isset($arrPages[$strHost])) {
$arrLangs = $arrPages[$strHost];
} else {
$arrLangs = $arrPages['*'] ?: array();
// empty domain
}
// Use the first result (see #4872)
if (!\Config::get('addLanguageToUrl')) {
$objNewPage = current($arrLangs);
} elseif (($lang = \Input::get('language')) != '' && isset($arrLangs[$lang])) {
$objNewPage = $arrLangs[$lang];
}
// Store the page object
if (is_object($objNewPage)) {
$objPage = $objNewPage;
}
}
// Throw a 404 error if the page could not be found or the result is still ambiguous
if ($objPage === null || $objPage instanceof \Model\Collection && $objPage->count() != 1) {
$this->User->authenticate();
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($pageId);
}
// Make sure $objPage is a Model
if ($objPage instanceof \Model\Collection) {
$objPage = $objPage->current();
}
// If the page has an alias, it can no longer be called via ID (see #7661)
if ($objPage->alias != '' && preg_match('#^' . $objPage->id . '[$/.]#', \Environment::get('relativeRequest'))) {
$this->User->authenticate();
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($pageId);
}
// Load a website root page object (will redirect to the first active regular page)
if ($objPage->type == 'root') {
$objHandler = new $GLOBALS['TL_PTY']['root']();
$objHandler->generate($objPage->id);
}
// Inherit the settings from the parent pages if it has not been done yet
if (!is_bool($objPage->protected)) {
$objPage->loadDetails();
}
// Set the admin e-mail address
if ($objPage->adminEmail != '') {
list($GLOBALS['TL_ADMIN_NAME'], $GLOBALS['TL_ADMIN_EMAIL']) = \StringUtil::splitFriendlyEmail($objPage->adminEmail);
} else {
list($GLOBALS['TL_ADMIN_NAME'], $GLOBALS['TL_ADMIN_EMAIL']) = \StringUtil::splitFriendlyEmail(\Config::get('adminEmail'));
}
// Exit if the root page has not been published (see #2425)
// Do not try to load the 404 page, it can cause an infinite loop!
if (!BE_USER_LOGGED_IN && !$objPage->rootIsPublic) {
header('HTTP/1.1 404 Not Found');
die_nicely('be_no_page', 'Page not found');
}
// Check wether the language matches the root page language
//.........这里部分代码省略.........
示例2: splitFriendlyName
/**
* Split a friendly-name e-address and return name and e-mail as array
*
* @param string $strEmail A friendly-name e-mail address
*
* @return array An array with name and e-mail address
*
* @deprecated Use StringUtil::splitFriendlyEmail() instead
*/
public static function splitFriendlyName($strEmail)
{
return \StringUtil::splitFriendlyEmail($strEmail);
}
示例3: loadPageConfig
/**
* Load system configuration into page object
*
* @param \Database\Result|\PageModel $objPage
*
* @return \Database\Result
*/
public static function loadPageConfig($objPage)
{
// Use the global date format if none is set
if ($objPage->dateFormat == '') {
$objPage->dateFormat = $GLOBALS['TL_CONFIG']['dateFormat'];
}
if ($objPage->timeFormat == '') {
$objPage->timeFormat = $GLOBALS['TL_CONFIG']['timeFormat'];
}
if ($objPage->datimFormat == '') {
$objPage->datimFormat = $GLOBALS['TL_CONFIG']['datimFormat'];
}
// Set the admin e-mail address
if ($objPage->adminEmail != '') {
list($GLOBALS['TL_ADMIN_NAME'], $GLOBALS['TL_ADMIN_EMAIL']) = \StringUtil::splitFriendlyEmail($objPage->adminEmail);
} else {
list($GLOBALS['TL_ADMIN_NAME'], $GLOBALS['TL_ADMIN_EMAIL']) = \StringUtil::splitFriendlyEmail($GLOBALS['TL_CONFIG']['adminEmail']);
}
// Define the static URL constants
define('TL_FILES_URL', $objPage->staticFiles != '' && !$GLOBALS['TL_CONFIG']['debugMode'] ? $objPage->staticFiles . TL_PATH . '/' : '');
define('TL_SCRIPT_URL', $objPage->staticSystem != '' && !$GLOBALS['TL_CONFIG']['debugMode'] ? $objPage->staticSystem . TL_PATH . '/' : '');
define('TL_PLUGINS_URL', $objPage->staticPlugins != '' && !$GLOBALS['TL_CONFIG']['debugMode'] ? $objPage->staticPlugins . TL_PATH . '/' : '');
$objLayout = \Database::getInstance()->prepare("\n SELECT l.*, t.templates\n FROM tl_layout l\n LEFT JOIN tl_theme t ON l.pid=t.id\n WHERE l.id=?\n ORDER BY l.id=? DESC\n ")->limit(1)->execute($objPage->layout, $objPage->layout);
if ($objLayout->numRows) {
// Get the page layout
$objPage->template = strlen($objLayout->template) ? $objLayout->template : 'fe_page';
$objPage->templateGroup = $objLayout->templates;
// Store the output format
list($strFormat, $strVariant) = explode('_', $objLayout->doctype);
$objPage->outputFormat = $strFormat;
$objPage->outputVariant = $strVariant;
}
$GLOBALS['TL_LANGUAGE'] = $objPage->language;
return $objPage;
}
示例4: compileRecipients
/**
* Extract the e-mail addresses from the func_get_args() arguments
*
* @param array $arrRecipients The recipients array
*
* @return array An array of e-mail addresses
*/
protected function compileRecipients($arrRecipients)
{
$arrReturn = array();
foreach ($arrRecipients as $varRecipients) {
if (!is_array($varRecipients)) {
$varRecipients = \StringUtil::splitCsv($varRecipients);
}
// Support friendly name addresses and internationalized domain names
foreach ($varRecipients as $v) {
list($strName, $strEmail) = \StringUtil::splitFriendlyEmail($v);
$strName = trim($strName, ' "');
$strEmail = \Idna::encodeEmail($strEmail);
if ($strName != '') {
$arrReturn[$strEmail] = $strName;
} else {
$arrReturn[] = $strEmail;
}
}
}
return $arrReturn;
}
示例5: 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) = \StringUtil::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);
//.........这里部分代码省略.........
示例6: send
/**
* Renturn a form to choose an existing style sheet and import it
*
* @param \DataContainer $dc
*
* @return string
*/
public function send(\DataContainer $dc)
{
$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($dc->id);
// Return if there is no newsletter
if ($objNewsletter->numRows < 1) {
return '';
}
// Overwrite the SMTP configuration
if ($objNewsletter->useSMTP) {
\Config::set('useSMTP', true);
\Config::set('smtpHost', $objNewsletter->smtpHost);
\Config::set('smtpUser', $objNewsletter->smtpUser);
\Config::set('smtpPass', $objNewsletter->smtpPass);
\Config::set('smtpEnc', $objNewsletter->smtpEnc);
\Config::set('smtpPort', $objNewsletter->smtpPort);
}
// Add default sender address
if ($objNewsletter->sender == '') {
list($objNewsletter->senderName, $objNewsletter->sender) = \StringUtil::splitFriendlyEmail(\Config::get('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;
}
}
}
}
}
// Replace insert tags
$html = $this->replaceInsertTags($objNewsletter->content, false);
$text = $this->replaceInsertTags($objNewsletter->text, false);
// Convert relative URLs
if ($objNewsletter->externalImages) {
$html = $this->convertRelativeUrls($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);
}
$arrRecipient['email'] = urldecode(\Input::get('recipient', true));
// Send
$objEmail = $this->generateEmailObject($objNewsletter, $arrAttachments);
$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);
// Return if there are no recipients
if ($objTotal->count < 1) {
$this->Session->set('tl_newsletter_send', null);
\Message::addError($GLOBALS['TL_LANG']['tl_newsletter']['error']);
$this->redirect($referer);
}
$intTotal = $objTotal->count;
// Get page and timeout
$intTimeout = \Input::get('timeout') > 0 ? \Input::get('timeout') : 1;
$intStart = \Input::get('start') ? \Input::get('start') : 0;
$intPages = \Input::get('mpc') ? \Input::get('mpc') : 10;
// Get recipients
$objRecipients = $this->Database->prepare("SELECT *, r.email FROM tl_newsletter_recipients r LEFT JOIN tl_member m ON(r.email=m.email) WHERE r.pid=? AND r.active=1 GROUP BY r.email ORDER BY r.email")->limit($intPages, $intStart)->execute($objNewsletter->pid);
echo '<div style="font-family:Verdana,sans-serif;font-size:11px;line-height:16px;margin-bottom:12px">';
// Send newsletter
if ($objRecipients->numRows > 0) {
// Update status
if ($intStart == 0) {
$this->Database->prepare("UPDATE tl_newsletter SET sent=1, date=? WHERE id=?")->execute(time(), $objNewsletter->id);
$_SESSION['REJECTED_RECIPIENTS'] = array();
}
while ($objRecipients->next()) {
$objEmail = $this->generateEmailObject($objNewsletter, $arrAttachments);
$this->sendNewsletter($objEmail, $objNewsletter, $objRecipients->row(), $text, $html);
echo 'Sending newsletter to <strong>' . $objRecipients->email . '</strong><br>';
//.........这里部分代码省略.........
示例7: validator
//.........这里部分代码省略.........
} else {
// Validate the date (see #5086)
try {
new \Date($varInput, \Date::getNumericDateFormat());
} catch (\OutOfBoundsException $e) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varInput));
}
}
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) = \StringUtil::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