本文整理汇总了PHP中Idna::decode方法的典型用法代码示例。如果您正苦于以下问题:PHP Idna::decode方法的具体用法?PHP Idna::decode怎么用?PHP Idna::decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Idna
的用法示例。
在下文中一共展示了Idna::decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendPasswordLink
/**
* Send a lost password e-mail
* @param object
*/
protected function sendPasswordLink($objMember)
{
$objNotification = \NotificationCenter\Model\Notification::findByPk($this->nc_notification);
if ($objNotification === null) {
$this->log('The notification was not found ID ' . $this->nc_notification, __METHOD__, TL_ERROR);
return;
}
$confirmationId = md5(uniqid(mt_rand(), true));
// Store the confirmation ID
$objMember = \MemberModel::findByPk($objMember->id);
$objMember->activation = $confirmationId;
$objMember->save();
$arrTokens = array();
// Add member tokens
foreach ($objMember->row() as $k => $v) {
$arrTokens['member_' . $k] = $v;
}
$arrTokens['recipient_email'] = $objMember->email;
$arrTokens['domain'] = \Idna::decode(\Environment::get('host'));
$arrTokens['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $confirmationId;
$objNotification->send($arrTokens);
$this->log('A new password has been requested for user ID ' . $objMember->id . ' (' . $objMember->email . ')', __METHOD__, TL_ACCESS);
// Check whether there is a jumpTo page
if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) {
$this->jumpToOrReload($objJumpTo->row());
}
$this->reload();
}
示例2: test_decode
public function test_decode()
{
$arrIdnaToStr = array_flip($this->arrIdnaTests);
foreach ($arrIdnaToStr as $strEncodedDomain => $strDecodedDomain) {
$this->assertEquals(Idna::decode($strEncodedDomain), $strDecodedDomain);
}
}
示例3: generate
/**
* Generate the widget and return it as string
* @return string
*/
public function generate()
{
// Hide the Punycode format (see #2750)
if ($this->rgxp == 'email' || $this->rgxp == 'url') {
$this->varValue = \Idna::decode($this->varValue);
}
return sprintf('<input type="%s" name="%s" id="ctrl_%s" class="text%s%s" value="%s"%s%s', $this->hideInput ? 'password' : 'text', $this->strName, $this->strId, $this->hideInput ? ' password' : '', strlen($this->strClass) ? ' ' . $this->strClass : '', specialchars($this->varValue), $this->getAttributes(), $this->strTagEnding) . $this->addSubmit();
}
示例4: __construct
/**
* @param $strType
* @param null $strForceLanguage
*/
public function __construct($strType, $strForceLanguage = null)
{
if (in_array($strType, $GLOBALS['TL_EMAIL'])) {
$this->strType = $strType;
}
$this->strForceLanguage = $strForceLanguage;
// Set default parameters
$this->addParameter('host', \Idna::decode(\Environment::get('host')));
$this->addParameter('admin_name', \BackendUser::getInstance()->name);
}
示例5: sendPasswordLink
/**
* Send a lost password e-mail
*
* @param \MemberModel $objMember
*/
protected function sendPasswordLink($objMember)
{
$objNotification = \NotificationCenter\Model\Notification::findByPk($this->nc_notification);
if ($objNotification === null) {
$this->log('The notification was not found ID ' . $this->nc_notification, __METHOD__, TL_ERROR);
return;
}
$confirmationId = md5(uniqid(mt_rand(), true));
// Store the confirmation ID
$objMember = \MemberModel::findByPk($objMember->id);
$objMember->activation = $confirmationId;
$objMember->save();
$arrTokens = array();
// Add member tokens
foreach ($objMember->row() as $k => $v) {
if (\Validator::isBinaryUuid($v)) {
$v = \StringUtil::binToUuid($v);
}
$arrTokens['member_' . $k] = specialchars($v);
}
// FIX: Add salutation token
$arrTokens['salutation_user'] = NotificationCenterPlus::createSalutation($GLOBALS['TL_LANGUAGE'], $objMember);
// ENDFIX
$arrTokens['recipient_email'] = $objMember->email;
$arrTokens['domain'] = \Idna::decode(\Environment::get('host'));
$arrTokens['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $confirmationId;
// FIX: Add custom change password jump to
if (($objJumpTo = $this->objModel->getRelated('changePasswordJumpTo')) !== null) {
$arrTokens['link'] = \Idna::decode(\Environment::get('base')) . \Controller::generateFrontendUrl($objJumpTo->row(), '?token=' . $confirmationId);
}
// ENDFIX
$objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']);
$this->log('A new password has been requested for user ID ' . $objMember->id . ' (' . $objMember->email . ')', __METHOD__, TL_ACCESS);
// Check whether there is a jumpTo page
if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) {
$this->jumpToOrReload($objJumpTo->row());
}
StatusMessage::addSuccess(sprintf($GLOBALS['TL_LANG']['notification_center_plus']['sendPasswordLink']['messageSuccess'], $arrTokens['recipient_email']), $this->objModel->id);
$this->reload();
}
开发者ID:heimrichhannot,项目名称:contao-notification_center_plus,代码行数:45,代码来源:ModulePasswordNotificationCenterPlus.php
示例6: parse
/**
* Parse the template file and return it as string
* @param array
* @return string
*/
public function parse($arrAttributes = null)
{
if ($this->formcontrol_template) {
$this->strTemplate = $this->formcontrol_template;
// Hide the Punycode format (see #2750)
if ($this->rgxp == 'email' || $this->rgxp == 'friendly' || $this->rgxp == 'url') {
$this->varValue = \Idna::decode($this->varValue);
}
if ($this->hideInput) {
$strType = 'password';
} elseif ($this->strFormat != 'xhtml') {
// Use the HTML5 types (see #4138)
// but not the date, time and datetime types (see #5918)
switch ($this->rgxp) {
case 'digit':
$strType = 'number';
break;
case 'phone':
$strType = 'tel';
break;
case 'email':
$strType = 'email';
break;
case 'url':
$strType = 'url';
break;
default:
$strType = 'text';
break;
}
} else {
$strType = 'text';
}
$this->type = $strType;
}
return parent::parse($arrAttributes);
}
示例7: getFileInfo
/**
* @param string $filePk
* @param bool $isImage
* @return array
*/
protected function getFileInfo($filePk, $isImage = false)
{
$fileInfo = array();
$objFile = \FilesModel::findByPk($filePk);
$ogImage = $objFile ? (string) $objFile->path : '';
if ($ogImage != '') {
$baseUrl = \Idna::decode(\Environment::get('base'));
if ($baseUrl == '') {
$baseUrl = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['PHP_SELF'], 0, -9);
}
$fileInfo['url'] = $baseUrl . $ogImage;
if (file_exists(TL_ROOT . TL_FILES_URL . '/' . $ogImage)) {
$image = TL_ROOT . TL_FILES_URL . '/' . $ogImage;
} elseif (file_exists(TL_ROOT . '/' . $ogImage)) {
$image = TL_ROOT . '/' . $ogImage;
} else {
$image = dirname(__FILE__) . '/../../../../../' . $ogImage;
}
$mimeType = @mime_content_type($image);
if ($mimeType) {
$fileInfo['mime_type'] = $mimeType;
}
if ($isImage) {
$imagesize = @getimagesize($image);
if ($imagesize) {
$fileInfo['width'] = $imagesize[0];
$fileInfo['height'] = $imagesize[1];
}
}
}
return $fileInfo;
}
示例8: idnaDecode
/**
* Decode an internationalized domain name
*
* @param string $strDomain The domain name
*
* @return string The decoded domain name
*
* @deprecated Use Idna::decode() instead
*/
protected function idnaDecode($strDomain)
{
return \Idna::decode($strDomain);
}
示例9: notifyCommentsSubscribers
/**
* Notify the subscribers of new comments
*
* @param \CommentsModel $objComment
*/
public static function notifyCommentsSubscribers(\CommentsModel $objComment)
{
// Notified already
if ($objComment->notified) {
return;
}
$objNotify = \CommentsNotifyModel::findActiveBySourceAndParent($objComment->source, $objComment->parent);
// No subscriptions
if ($objNotify === null) {
return;
}
while ($objNotify->next()) {
// Don't notify the commentor about his own comment
if ($objNotify->email == $objComment->email) {
continue;
}
// Prepare the URL
$strUrl = \Idna::decode(\Environment::get('base')) . $objNotify->url;
$objEmail = new \Email();
$objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
$objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
$objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['com_notifySubject'], \Idna::decode(\Environment::get('host')));
$objEmail->text = sprintf($GLOBALS['TL_LANG']['MSC']['com_notifyMessage'], $objNotify->name, $strUrl, $strUrl . '?token=' . $objNotify->tokenRemove);
$objEmail->sendTo($objNotify->email);
}
$objComment->notified = 1;
$objComment->save();
}
示例10: createNewUser
protected function createNewUser($arrData)
{
$arrData['tstamp'] = time();
$arrData['login'] = $this->reg_allowLogin;
$arrData['activation'] = md5(uniqid(mt_rand(), true));
$arrData['dateAdded'] = $arrData['tstamp'];
$pw = $this->getRandomPassword(6);
$arrData['password'] = \Encryption::hash($pw["clear"]);
$arrData['username'] = strtolower($arrData['email']);
$arrData['email'] = strtolower($arrData['email']);
// Set default groups
if (!array_key_exists('groups', $arrData)) {
$arrData['groups'] = $this->reg_groups;
}
// // Disable account
// $arrData['disable'] = 1;
// Send activation e-mail
if ($this->reg_activate) {
$arrChunks = array();
$strConfirmation = $this->reg_text;
preg_match_all('/##[^#]+##/', $strConfirmation, $arrChunks);
foreach ($arrChunks[0] as $strChunk) {
$strKey = substr($strChunk, 2, -2);
switch ($strKey) {
case 'domain':
$strConfirmation = str_replace($strChunk, \Idna::decode(\Environment::get('host')), $strConfirmation);
break;
case 'gen_pw':
$strConfirmation = str_replace($strChunk, $pw["clear"], $strConfirmation);
break;
case 'link':
$strConfirmation = str_replace($strChunk, \Idna::decode(\Environment::get('base')) . \Environment::get('request') . (\Config::get('disableAlias') || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $arrData['activation'], $strConfirmation);
break;
// HOOK: support newsletter subscriptions
// HOOK: support newsletter subscriptions
case 'channel':
case 'channels':
if (!in_array('newsletter', \ModuleLoader::getActive())) {
break;
}
// Make sure newsletter is an array
if (!is_array($arrData['newsletter'])) {
if ($arrData['newsletter'] != '') {
$arrData['newsletter'] = array($arrData['newsletter']);
} else {
$arrData['newsletter'] = array();
}
}
// Replace the wildcard
if (!empty($arrData['newsletter'])) {
$objChannels = \NewsletterChannelModel::findByIds($arrData['newsletter']);
if ($objChannels !== null) {
$strConfirmation = str_replace($strChunk, implode("\n", $objChannels->fetchEach('title')), $strConfirmation);
}
} else {
$strConfirmation = str_replace($strChunk, '', $strConfirmation);
}
break;
default:
$strConfirmation = str_replace($strChunk, $arrData[$strKey], $strConfirmation);
break;
}
}
$objEmail = new \Email();
$objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
$objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
$objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['emailSubject'], \Idna::decode(\Environment::get('host')));
$objEmail->text = $strConfirmation;
$objEmail->sendTo($arrData['email']);
}
// Make sure newsletter is an array
if (isset($arrData['newsletter']) && !is_array($arrData['newsletter'])) {
$arrData['newsletter'] = array($arrData['newsletter']);
}
// Create the user
$objNewUser = new \MemberModel();
$objNewUser->setRow($arrData);
$objNewUser->save();
$insertId = $objNewUser->id;
// Assign home directory
if ($this->reg_assignDir) {
$objHomeDir = \FilesModel::findByUuid($this->reg_homeDir);
if ($objHomeDir !== null) {
$this->import('Files');
$strUserDir = standardize($arrData['username']) ?: 'user_' . $insertId;
// Add the user ID if the directory exists
while (is_dir(TL_ROOT . '/' . $objHomeDir->path . '/' . $strUserDir)) {
$strUserDir .= '_' . $insertId;
}
// Create the user folder
new \Folder($objHomeDir->path . '/' . $strUserDir);
$objUserDir = \FilesModel::findByPath($objHomeDir->path . '/' . $strUserDir);
// Save the folder ID
$objNewUser->assignDir = 1;
$objNewUser->homeDir = $objUserDir->uuid;
$objNewUser->save();
}
}
// HOOK: send insert ID and user data
if (isset($GLOBALS['TL_HOOKS']['createNewUser']) && is_array($GLOBALS['TL_HOOKS']['createNewUser'])) {
//.........这里部分代码省略.........
示例11: doReplace
//.........这里部分代码省略.........
break;
// Conditional tags (if)
// Conditional tags (if)
case 'iflng':
if ($elements[1] != '' && $elements[1] != $objPage->language) {
for (; $_rit < $_cnt; $_rit += 2) {
if ($tags[$_rit + 1] == 'iflng' || $tags[$_rit + 1] == 'iflng::' . $objPage->language) {
break;
}
}
}
unset($arrCache[$strTag]);
break;
// Conditional tags (if not)
// Conditional tags (if not)
case 'ifnlng':
if ($elements[1] != '') {
$langs = \StringUtil::trimsplit(',', $elements[1]);
if (in_array($objPage->language, $langs)) {
for (; $_rit < $_cnt; $_rit += 2) {
if ($tags[$_rit + 1] == 'ifnlng') {
break;
}
}
}
}
unset($arrCache[$strTag]);
break;
// Environment
// Environment
case 'env':
switch ($elements[1]) {
case 'host':
$arrCache[$strTag] = \Idna::decode(\Environment::get('host'));
break;
case 'http_host':
$arrCache[$strTag] = \Idna::decode(\Environment::get('httpHost'));
break;
case 'url':
$arrCache[$strTag] = \Idna::decode(\Environment::get('url'));
break;
case 'path':
$arrCache[$strTag] = \Idna::decode(\Environment::get('base'));
break;
case 'request':
$arrCache[$strTag] = \Environment::get('indexFreeRequest');
break;
case 'ip':
$arrCache[$strTag] = \Environment::get('ip');
break;
case 'referer':
$arrCache[$strTag] = $this->getReferer(true);
break;
case 'files_url':
$arrCache[$strTag] = TL_FILES_URL;
break;
case 'assets_url':
case 'plugins_url':
case 'script_url':
$arrCache[$strTag] = TL_ASSETS_URL;
break;
case 'base_url':
$arrCache[$strTag] = \System::getContainer()->get('request_stack')->getCurrentRequest()->getBaseUrl();
break;
}
break;
示例12: sendPasswordLink
/**
* Create a new user and redirect
*
* @param \MemberModel $objMember
*/
protected function sendPasswordLink($objMember)
{
$confirmationId = md5(uniqid(mt_rand(), true));
// Store the confirmation ID
$objMember = \MemberModel::findByPk($objMember->id);
$objMember->activation = $confirmationId;
$objMember->save();
// Prepare the simple token data
$arrData = $objMember->row();
$arrData['domain'] = \Idna::decode(\Environment::get('host'));
$arrData['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . (\Config::get('disableAlias') || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $confirmationId;
// Send e-mail
$objEmail = new \Email();
$objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
$objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
$objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['passwordSubject'], \Idna::decode(\Environment::get('host')));
$objEmail->text = \String::parseSimpleTokens($this->reg_password, $arrData);
$objEmail->sendTo($objMember->email);
$this->log('A new password has been requested for user ID ' . $objMember->id . ' (' . $objMember->email . ')', __METHOD__, TL_ACCESS);
// Check whether there is a jumpTo page
if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) {
$this->jumpToOrReload($objJumpTo->row());
}
$this->reload();
}
示例13: commentsController
protected function commentsController()
{
$returnarray['error'] = $this->errorcode(0);
$returnarray['changes'] = 1;
$getTs = \Input::get($this->request['ts']);
$getId = \Input::get($this->request['id']);
$returnarray['ts'] = isset($getTs) ? $getTs : 0;
if (isset($getId)) {
if (\Input::get($this->request['action']) == 'add') {
$comment = $_REQUEST[$this->request['comment']];
$name = $_REQUEST[$this->request['name']];
$email = $_REQUEST[$this->request['email']];
$key = $_REQUEST[$this->request['key']];
if (!$comment || $comment == "" || !$name || !$email) {
$returnarray['error'] = $this->errorcode(30);
} elseif (!\Validator::isEmail($email)) {
$returnarray['error'] = $this->errorcode(31);
} else {
$ts = time();
$arrInsert = array('tstamp' => $ts, 'source' => 'tl_news', 'parent' => $getId, 'date' => $ts, 'name' => $name, 'email' => $email, 'comment' => trim($comment), 'published' => $this->settings['news_moderate'] == 1 ? 0 : 1, 'ip' => \Environment::get('remote_addr'));
$objComment = new \CommentsModel();
$objComment->setRow($arrInsert)->save();
if ($objComment->id) {
$strComment = $_REQUEST[$this->request['comment']];
$strComment = strip_tags($strComment);
$strComment = \String::decodeEntities($strComment);
$strComment = str_replace(array('[&]', '[lt]', '[gt]'), array('&', '<', '>'), $strComment);
$objTemplate = new \FrontendTemplate('kommentar_email');
$objTemplate->name = $arrInsert['name'] . ' (' . $arrInsert['email'] . ')';
$objTemplate->comment = $strComment;
$objTemplate->edit = \Idna::decode(\Environment::get('base')) . 'contao/main.php?do=comments&act=edit&id=' . $objComment->id;
$objEmail = new \Email();
$objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
$objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
$objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['com_subject'], \Idna::decode(\Environment::get('host')));
$objEmail->text = $objTemplate->parse();
if ($GLOBALS['TL_ADMIN_EMAIL'] != '') {
$objEmail->sendTo($GLOBALS['TL_ADMIN_EMAIL']);
}
$returnarray['error'] = $this->errorcode(0);
$returnarray['ts'] = $ts;
$returnarray['comment_id'] = $objComment->id;
$returnarray['changes'] = 1;
$returnarray['status'] = $this->settings['news_moderate'] == 1 ? 'Kommentar wird geprüft.' : "Kommentar veröffentlicht.";
} else {
$returnarray['error'] = $this->errorcode(31);
}
}
} else {
$post = $this->getComment($getId);
if ($post['commentStatus'] == 'open') {
$returnarray['comment_status'] = $post['commentStatus'];
$returnarray['comments_count'] = $post['commentsCount'];
$returnarray['REQUEST_TOKEN'] = REQUEST_TOKEN;
if ($post['commentsCount'] > 0) {
$pos = 0;
foreach ($post['items'] as $comment) {
$tempArray = array();
$tempArray['pos'] = ++$pos;
$tempArray['id'] = $comment->id;
$tempArray['text'] = strip_tags($comment->comment);
$tempArray['timestamp'] = (int) $comment->date;
if ($tempArray['timestamp'] > $returnarray['ts']) {
$returnarray['ts'] = $tempArray['timestamp'];
$returnarray['changes'] = 1;
}
$tempArray['datum'] = date('d.m.Y, H:i', $tempArray['timestamp']);
$tempArray['author']['name'] = $comment->name;
$tempArray['author']['id'] = "0";
$tempArray['author']['email'] = $comment->email;
$tempArray['author']['img'] = "";
if ($comment->addReply) {
$objUser = \UserModel::findByPk($comment->author);
$tempArray['subitems'] = array(array('pos' => 1, 'id' => 1, 'parent_id' => $comment->id, 'text' => strip_tags($comment->reply), 'timestamp' => (int) $comment->tstamp, 'datum' => date('d.m.Y, H:i', $comment->tstamp), 'author' => array('name' => $objUser->name, 'id' => $objUser->id, 'email' => $objUser->email, 'img' => "")));
}
$returnarray['items'][] = $tempArray;
}
if ($returnarray['changes'] != 1) {
unset($returnarray['items']);
}
}
} else {
$returnarray['error'] = $this->errorcode(29);
}
}
} else {
$returnarray['error'] = $this->errorcode(15);
}
return array('comments' => $returnarray);
}
示例14: renderCommentForm
/**
* removes $this->reload(); call (last line) of core method \Comments::renderCommentForm()
*/
protected function renderCommentForm(\FrontendTemplate $objTemplate, \stdClass $objConfig, $strSource, $intParent, $varNotifies)
{
$this->import('FrontendUser', 'User');
// Access control
if ($objConfig->requireLogin && !BE_USER_LOGGED_IN && !FE_USER_LOGGED_IN) {
$objTemplate->requireLogin = true;
$objTemplate->login = $GLOBALS['TL_LANG']['MSC']['com_login'];
return;
}
// Confirm or remove a subscription
if (\Input::get('token')) {
static::changeSubscriptionStatus($objTemplate);
return;
}
// Form fields
$arrFields = array('name' => array('name' => 'name', 'label' => $GLOBALS['TL_LANG']['MSC']['com_name'], 'value' => trim($this->User->firstname . ' ' . $this->User->lastname), 'inputType' => 'text', 'eval' => array('mandatory' => true, 'maxlength' => 64)), 'email' => array('name' => 'email', 'label' => $GLOBALS['TL_LANG']['MSC']['com_email'], 'value' => $this->User->email, 'inputType' => 'text', 'eval' => array('rgxp' => 'email', 'mandatory' => true, 'maxlength' => 128, 'decodeEntities' => true)), 'website' => array('name' => 'website', 'label' => $GLOBALS['TL_LANG']['MSC']['com_website'], 'inputType' => 'text', 'eval' => array('rgxp' => 'url', 'maxlength' => 128, 'decodeEntities' => true)));
// Captcha
if (!$objConfig->disableCaptcha) {
$arrFields['captcha'] = array('name' => 'captcha', 'inputType' => 'captcha', 'eval' => array('mandatory' => true));
}
// Comment field
$arrFields['comment'] = array('name' => 'comment', 'label' => $GLOBALS['TL_LANG']['MSC']['com_comment'], 'inputType' => 'textarea', 'eval' => array('mandatory' => true, 'rows' => 4, 'cols' => 40, 'preserveTags' => true));
// Notify me of new comments
$arrFields['notify'] = array('name' => 'notify', 'label' => '', 'inputType' => 'checkbox', 'options' => array(1 => $GLOBALS['TL_LANG']['MSC']['com_notify']));
$doNotSubmit = false;
$arrWidgets = array();
$strFormId = 'com_' . $strSource . '_' . $intParent;
// Initialize the widgets
foreach ($arrFields as $arrField) {
/** @var \Widget $strClass */
$strClass = $GLOBALS['TL_FFL'][$arrField['inputType']];
// Continue if the class is not defined
if (!class_exists($strClass)) {
continue;
}
$arrField['eval']['required'] = $arrField['eval']['mandatory'];
/** @var \Widget $objWidget */
$objWidget = new $strClass($strClass::getAttributesFromDca($arrField, $arrField['name'], $arrField['value']));
// Validate the widget
if (\Input::post('FORM_SUBMIT') == $strFormId) {
$objWidget->validate();
if ($objWidget->hasErrors()) {
$doNotSubmit = true;
}
}
$arrWidgets[$arrField['name']] = $objWidget;
}
$objTemplate->fields = $arrWidgets;
$objTemplate->submit = $GLOBALS['TL_LANG']['MSC']['com_submit'];
$objTemplate->action = ampersand(\Environment::get('request'));
$objTemplate->messages = '';
// Backwards compatibility
$objTemplate->formId = $strFormId;
$objTemplate->hasError = $doNotSubmit;
// Do not index or cache the page with the confirmation message
if ($_SESSION['TL_COMMENT_ADDED']) {
/** @var \PageModel $objPage */
global $objPage;
$objPage->noSearch = 1;
$objPage->cache = 0;
$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['com_confirm'];
$_SESSION['TL_COMMENT_ADDED'] = false;
}
// Store the comment
if (!$doNotSubmit && \Input::post('FORM_SUBMIT') == $strFormId) {
$strWebsite = $arrWidgets['website']->value;
// Add http:// to the website
if ($strWebsite != '' && !preg_match('@^(https?://|ftp://|mailto:|#)@i', $strWebsite)) {
$strWebsite = 'http://' . $strWebsite;
}
// Do not parse any tags in the comment
$strComment = specialchars(trim($arrWidgets['comment']->value));
$strComment = str_replace(array('&', '<', '>'), array('[&]', '[lt]', '[gt]'), $strComment);
// Remove multiple line feeds
$strComment = preg_replace('@\\n\\n+@', "\n\n", $strComment);
// Parse BBCode
if ($objConfig->bbcode) {
$strComment = $this->parseBbCode($strComment);
}
// Prevent cross-site request forgeries
$strComment = preg_replace('/(href|src|on[a-z]+)="[^"]*(contao\\/main\\.php|typolight\\/main\\.php|javascript|vbscri?pt|script|alert|document|cookie|window)[^"]*"+/i', '$1="#"', $strComment);
$time = time();
// Prepare the record
$arrSet = array('tstamp' => $time, 'source' => $strSource, 'parent' => $intParent, 'name' => $arrWidgets['name']->value, 'email' => $arrWidgets['email']->value, 'website' => $strWebsite, 'comment' => $this->convertLineFeeds($strComment), 'ip' => $this->anonymizeIp(\Environment::get('ip')), 'date' => $time, 'published' => $objConfig->moderate ? '' : 1);
// Store the comment
$objComment = new \CommentsModel();
$objComment->setRow($arrSet)->save();
// Store the subscription
if ($arrWidgets['notify']->value) {
static::addCommentsSubscription($objComment);
}
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['addComment']) && is_array($GLOBALS['TL_HOOKS']['addComment'])) {
foreach ($GLOBALS['TL_HOOKS']['addComment'] as $callback) {
$this->import($callback[0]);
$this->{$callback[0]}->{$callback[1]}($objComment->id, $arrSet, $this);
}
//.........这里部分代码省略.........
示例15: replaceInsertTags
//.........这里部分代码省略.........
break;
// Conditional tags (if)
// Conditional tags (if)
case 'iflng':
if ($elements[1] != '' && $elements[1] != $objPage->language) {
for (; $_rit < $_cnt; $_rit += 3) {
if ($tags[$_rit + 1] == 'iflng' || $tags[$_rit + 1] == 'iflng::' . $objPage->language) {
break;
}
}
}
unset($arrCache[$strTag]);
break;
// Conditional tags (if not)
// Conditional tags (if not)
case 'ifnlng':
if ($elements[1] != '') {
$langs = trimsplit(',', $elements[1]);
if (in_array($objPage->language, $langs)) {
for (; $_rit < $_cnt; $_rit += 3) {
if ($tags[$_rit + 1] == 'ifnlng') {
break;
}
}
}
}
unset($arrCache[$strTag]);
break;
// Environment
// Environment
case 'env':
switch ($elements[1]) {
case 'host':
$arrCache[$strTag] = \Idna::decode(\Environment::get('host'));
break;
case 'http_host':
$arrCache[$strTag] = \Idna::decode(\Environment::get('httpHost'));
break;
case 'url':
$arrCache[$strTag] = \Idna::decode(\Environment::get('url'));
break;
case 'path':
$arrCache[$strTag] = \Idna::decode(\Environment::get('base'));
break;
case 'request':
$arrCache[$strTag] = \Environment::get('indexFreeRequest');
break;
case 'ip':
$arrCache[$strTag] = \Environment::get('ip');
break;
case 'referer':
$arrCache[$strTag] = $this->getReferer(true);
break;
case 'files_url':
$arrCache[$strTag] = TL_FILES_URL;
break;
case 'assets_url':
case 'plugins_url':
case 'script_url':
$arrCache[$strTag] = TL_ASSETS_URL;
break;
}
break;
// Page
// Page
case 'page':