public function __construct($strTable, $arrModule = array()) { parent::__construct(); // Check the request token (see #4007) if (isset($_GET['act'])) { if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) { $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request')); $this->redirect('contao/confirm.php'); } } $this->intId = \Input::get('id'); // Check whether the table is defined if (!$strTable || !isset($GLOBALS['TL_DCA'][$strTable])) { $this->log('Could not load the data container configuration for "' . $strTable . '"', 'DC_Table __construct()', TL_ERROR); trigger_error('Could not load the data container configuration', E_USER_ERROR); } $this->strTable = $strTable; $this->arrModule = $arrModule; // Call onload_callback (e.g. to check permissions) if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'])) { foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $this->{$callback[0]}->{$callback[1]}($this); } } } }
protected function compile() { $strAction = \Input::get('act'); // at first check for the correct request token to be set if ($strAction && !\RequestToken::validate(\Input::get('token')) && !$this->deactivateTokens) { StatusMessage::addError(sprintf($GLOBALS['TL_LANG']['frontendedit']['requestTokenExpired'], Environment::getUrl(true, true, false)), $this->id, 'requestTokenExpired'); return; } if ($strAction == FRONTENDEDIT_ACT_DELETE && ($intId = \Input::get('id'))) { if ($this->checkPermission($intId)) { $this->deleteItem($intId); // return to the list \Controller::redirect(Url::removeQueryString(array('act', 'id', 'token'), Environment::getUrl())); } else { StatusMessage::addError($GLOBALS['TL_LANG']['formhybrid_list']['noPermission'], $this->id); return; } } if ($strAction == FRONTENDEDIT_ACT_PUBLISH && ($intId = \Input::get('id'))) { if ($this->checkPermission($intId)) { $this->publishItem($intId); // return to the list \Controller::redirect(Url::removeQueryString(array('act', 'id'), Environment::getUrl())); } else { StatusMessage::addError($GLOBALS['TL_LANG']['formhybrid_list']['noPermission'], $this->id); return; } } parent::compile(); }
/** * Initialize the object * * @param string $strTable * @param array $arrModule */ public function __construct($strTable, $arrModule = array()) { parent::__construct(); // Check the request token (see #4007) if (isset($_GET['act'])) { if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) { $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request')); $this->redirect('contao/confirm.php'); } } $this->intId = \Input::get('id'); // Clear the clipboard if (isset($_GET['clipboard'])) { $this->Session->set('CLIPBOARD', array()); $this->redirect($this->getReferer()); } // Check whether the table is defined if ($strTable == '' || !isset($GLOBALS['TL_DCA'][$strTable])) { $this->log('Could not load the data container configuration for "' . $strTable . '"', __METHOD__, TL_ERROR); trigger_error('Could not load the data container configuration', E_USER_ERROR); } // Set IDs and redirect if (\Input::post('FORM_SUBMIT') == 'tl_select') { $ids = \Input::post('IDS'); if (empty($ids) || !is_array($ids)) { $this->reload(); } $session = $this->Session->getData(); $session['CURRENT']['IDS'] = $ids; $this->Session->setData($session); if (isset($_POST['edit'])) { $this->redirect(str_replace('act=select', 'act=editAll', \Environment::get('request'))); } elseif (isset($_POST['delete'])) { $this->redirect(str_replace('act=select', 'act=deleteAll', \Environment::get('request'))); } elseif (isset($_POST['override'])) { $this->redirect(str_replace('act=select', 'act=overrideAll', \Environment::get('request'))); } elseif (isset($_POST['cut']) || isset($_POST['copy'])) { $arrClipboard = $this->Session->get('CLIPBOARD'); $arrClipboard[$strTable] = array('id' => $ids, 'mode' => isset($_POST['cut']) ? 'cutAll' : 'copyAll'); $this->Session->set('CLIPBOARD', $arrClipboard); // Support copyAll in the list view (see #7499) if (isset($_POST['copy']) && $GLOBALS['TL_DCA'][$strTable]['list']['sorting']['mode'] < 4) { $this->redirect(str_replace('act=select', 'act=copyAll', \Environment::get('request'))); } $this->redirect($this->getReferer()); } } $this->strTable = $strTable; $this->ptable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ptable']; $this->ctable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ctable']; $this->treeView = in_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'], array(5, 6)); $this->root = null; $this->arrModule = $arrModule; // Call onload_callback (e.g. to check permissions) if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'])) { foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $this->{$callback[0]}->{$callback[1]}($this); } elseif (is_callable($callback)) { $callback($this); } } } // Get the IDs of all root records (tree view) if ($this->treeView) { $table = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 6 ? $this->ptable : $this->strTable; // Unless there are any root records specified, use all records with parent ID 0 if (!isset($GLOBALS['TL_DCA'][$table]['list']['sorting']['root']) || $GLOBALS['TL_DCA'][$table]['list']['sorting']['root'] === false) { $objIds = $this->Database->prepare("SELECT id FROM " . $table . " WHERE pid=?" . ($this->Database->fieldExists('sorting', $table) ? ' ORDER BY sorting' : ''))->execute(0); if ($objIds->numRows > 0) { $this->root = $objIds->fetchEach('id'); } } elseif (is_array($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'])) { $this->root = $this->eliminateNestedPages($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'], $table, $this->Database->fieldExists('sorting', $table)); } } elseif (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['root'])) { $this->root = array_unique($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['root']); } // Store the current referer if (!empty($this->ctable) && !\Input::get('act') && !\Input::get('key') && !\Input::get('token') && TL_SCRIPT == 'contao/main.php' && !\Environment::get('isAjaxRequest')) { $session = $this->Session->get('referer'); $session[TL_REFERER_ID][$this->strTable] = substr(\Environment::get('requestUri'), strlen(TL_PATH) + 1); $this->Session->set('referer', $session); } }
} } unset($v); } /** * Include the custom initialization file */ if (file_exists(TL_ROOT . '/system/config/initconfig.php')) { include TL_ROOT . '/system/config/initconfig.php'; } /** * Check the request token upon POST requests */ if ($_POST && !$GLOBALS['TL_CONFIG']['disableRefererCheck'] && !defined('BYPASS_TOKEN_CHECK')) { // Exit if the token cannot be validated if (!RequestToken::validate(Input::post('REQUEST_TOKEN'))) { // Force JavaScript redirect upon Ajax requests (IE requires absolute link) if (Environment::get('isAjaxRequest')) { echo '<script>location.replace("' . Environment::get('base') . 'contao/index.php")</script>'; } else { // Send an error 400 header if it is not an Ajax request header('HTTP/1.1 400 Bad Request'); if (file_exists(TL_ROOT . '/templates/be_referer.html5')) { include TL_ROOT . '/templates/be_referer.html5'; } elseif (file_exists(TL_ROOT . '/system/modules/core/templates/be_referer.html5')) { include TL_ROOT . '/system/modules/core/templates/be_referer.html5'; } else { echo 'Invalid request token. Please <a href="javascript:window.location.href=window.location.href">go back</a> and try again.'; } } exit;
/** * Initialize the object * * @param string $strTable */ public function __construct($strTable) { parent::__construct(); // Check the request token (see #4007) if (isset($_GET['act'])) { if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) { $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request')); $this->redirect('contao/confirm.php'); } } $this->intId = \Input::get('id', true); // Clear the clipboard if (isset($_GET['clipboard'])) { $this->Session->set('CLIPBOARD', array()); $this->redirect($this->getReferer()); } // Check whether the table is defined if ($strTable == '' || !isset($GLOBALS['TL_DCA'][$strTable])) { $this->log('Could not load data container configuration for "' . $strTable . '"', __METHOD__, TL_ERROR); trigger_error('Could not load data container configuration', E_USER_ERROR); } // Check permission to create new folders if (\Input::get('act') == 'paste' && \Input::get('mode') == 'create' && isset($GLOBALS['TL_DCA'][$strTable]['list']['new'])) { $this->log('Attempt to create a new folder although the method has been overwritten in the data container', __METHOD__, TL_ERROR); $this->redirect('contao/main.php?act=error'); } // Set IDs and redirect if (\Input::post('FORM_SUBMIT') == 'tl_select') { $ids = \Input::post('IDS'); if (empty($ids) || !is_array($ids)) { $this->reload(); } // Decode the values (see #5764) $ids = array_map('rawurldecode', $ids); $session = $this->Session->getData(); $session['CURRENT']['IDS'] = $ids; $this->Session->setData($session); if (isset($_POST['edit'])) { $this->redirect(str_replace('act=select', 'act=editAll', \Environment::get('request'))); } elseif (isset($_POST['delete'])) { $this->redirect(str_replace('act=select', 'act=deleteAll', \Environment::get('request'))); } elseif (isset($_POST['cut']) || isset($_POST['copy'])) { $arrClipboard = $this->Session->get('CLIPBOARD'); $arrClipboard[$strTable] = array('id' => $ids, 'mode' => isset($_POST['cut']) ? 'cutAll' : 'copyAll'); $this->Session->set('CLIPBOARD', $arrClipboard); $this->redirect($this->getReferer()); } } $this->strTable = $strTable; $this->blnIsDbAssisted = $GLOBALS['TL_DCA'][$strTable]['config']['databaseAssisted']; // Check for valid file types if ($GLOBALS['TL_DCA'][$this->strTable]['config']['validFileTypes']) { $this->arrValidFileTypes = trimsplit(',', strtolower($GLOBALS['TL_DCA'][$this->strTable]['config']['validFileTypes'])); } // Call onload_callback (e.g. to check permissions) if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'])) { foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $this->{$callback[0]}->{$callback[1]}($this); } elseif (is_callable($callback)) { $callback($this); } } } // Get all filemounts (root folders) if (is_array($GLOBALS['TL_DCA'][$strTable]['list']['sorting']['root'])) { $this->arrFilemounts = $this->eliminateNestedPaths($GLOBALS['TL_DCA'][$strTable]['list']['sorting']['root']); } }
/** * Generate the module * * @return string */ public function run() { if (!\Config::get('enableSearch')) { return ''; } $time = time(); /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_rebuild_index'); $objTemplate->action = ampersand(\Environment::get('request')); $objTemplate->indexHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['searchIndex']; $objTemplate->isActive = $this->isActive(); // Add the error message if ($_SESSION['REBUILD_INDEX_ERROR'] != '') { $objTemplate->indexMessage = $_SESSION['REBUILD_INDEX_ERROR']; $_SESSION['REBUILD_INDEX_ERROR'] = ''; } // Rebuild the index if (\Input::get('act') == 'index') { // Check the request token (see #4007) if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) { $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request')); $this->redirect('contao/confirm.php'); } $arrPages = $this->findSearchablePages(); // HOOK: take additional pages if (isset($GLOBALS['TL_HOOKS']['getSearchablePages']) && is_array($GLOBALS['TL_HOOKS']['getSearchablePages'])) { foreach ($GLOBALS['TL_HOOKS']['getSearchablePages'] as $callback) { $this->import($callback[0]); $arrPages = $this->{$callback[0]}->{$callback[1]}($arrPages); } } // Return if there are no pages if (empty($arrPages)) { $_SESSION['REBUILD_INDEX_ERROR'] = $GLOBALS['TL_LANG']['tl_maintenance']['noSearchable']; $this->redirect($this->getReferer()); } // Truncate the search tables $this->import('Automator'); $this->Automator->purgeSearchTables(); // Hide unpublished elements $this->setCookie('FE_PREVIEW', 0, $time - 86400); // Calculate the hash $strHash = sha1(session_id() . (!\Config::get('disableIpCheck') ? \Environment::get('ip') : '') . 'FE_USER_AUTH'); // Remove old sessions $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute($time - \Config::get('sessionTimeout'), $strHash); // Log in the front end user if (is_numeric(\Input::get('user')) && \Input::get('user') > 0) { // Insert a new session $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute(\Input::get('user'), $time, 'FE_USER_AUTH', session_id(), \Environment::get('ip'), $strHash); // Set the cookie $this->setCookie('FE_USER_AUTH', $strHash, $time + \Config::get('sessionTimeout'), null, null, false, true); } else { // Unset the cookies $this->setCookie('FE_USER_AUTH', $strHash, $time - 86400, null, null, false, true); $this->setCookie('FE_AUTO_LOGIN', \Input::cookie('FE_AUTO_LOGIN'), $time - 86400, null, null, false, true); } $strBuffer = ''; $rand = rand(); // Display the pages for ($i = 0, $c = count($arrPages); $i < $c; $i++) { $strBuffer .= '<span class="page_url" data-url="' . $arrPages[$i] . '#' . $rand . $i . '">' . \StringUtil::substr($arrPages[$i], 100) . '</span><br>'; unset($arrPages[$i]); // see #5681 } $objTemplate->content = $strBuffer; $objTemplate->note = $GLOBALS['TL_LANG']['tl_maintenance']['indexNote']; $objTemplate->loading = $GLOBALS['TL_LANG']['tl_maintenance']['indexLoading']; $objTemplate->complete = $GLOBALS['TL_LANG']['tl_maintenance']['indexComplete']; $objTemplate->indexContinue = $GLOBALS['TL_LANG']['MSC']['continue']; $objTemplate->theme = \Backend::getTheme(); $objTemplate->isRunning = true; return $objTemplate->parse(); } $arrUser = array('' => '-'); // Get active front end users $objUser = $this->Database->execute("SELECT id, username FROM tl_member WHERE disable!='1' AND (start='' OR start<='{$time}') AND (stop='' OR stop>'" . ($time + 60) . "') ORDER BY username"); while ($objUser->next()) { $arrUser[$objUser->id] = $objUser->username . ' (' . $objUser->id . ')'; } // Default variables $objTemplate->user = $arrUser; $objTemplate->indexLabel = $GLOBALS['TL_LANG']['tl_maintenance']['frontendUser'][0]; $objTemplate->indexHelp = \Config::get('showHelp') && strlen($GLOBALS['TL_LANG']['tl_maintenance']['frontendUser'][1]) ? $GLOBALS['TL_LANG']['tl_maintenance']['frontendUser'][1] : ''; $objTemplate->indexSubmit = $GLOBALS['TL_LANG']['tl_maintenance']['indexSubmit']; return $objTemplate->parse(); }
protected function compile() { $this->Template->headline = $this->headline; $this->Template->hl = $this->hl; $this->Template->wrapperClass = $this->strWrapperClass; $this->Template->wrapperId = $this->strWrapperId; $this->strFormId = $this->formHybridDataContainer . '_' . $this->id; $strAction = $this->defaultAction ?: \Input::get('act'); $this->arrEditable = deserialize($this->formHybridEditable, true); $this->strToken = $this->strToken ?: \Input::get('token'); // Do not change this order (see #6191) $this->Template->style = !empty($this->arrStyle) ? implode(' ', $this->arrStyle) : ''; $this->Template->class = trim('mod_' . $this->type . ' ' . $this->cssID[1]); $this->Template->cssID = $this->cssID[0] != '' ? ' id="' . $this->cssID[0] . '"' : ''; $this->Template->inColumn = $this->strColumn; if ($this->Template->headline == '') { $this->Template->headline = $this->headline; } if ($this->Template->hl == '') { $this->Template->hl = $this->hl; } if (!empty($this->classes) && is_array($this->classes)) { $this->Template->class .= ' ' . implode(' ', $this->classes); } $this->addDefaultArchive(); // at first check for the correct request token to be set if (!$this->deactivateTokens && !\RequestToken::validate($this->strToken)) { if (!$this->blnSilentMode) { StatusMessage::addError(sprintf($GLOBALS['TL_LANG']['frontendedit']['requestTokenExpired'], Url::replaceParameterInUri(Url::getUrl(), 'token', \RequestToken::get())), $this->id, 'requestTokenExpired'); } return; } if ($this->formHybridAllowIdAsGetParameter) { $intId = \Input::get($this->formHybridIdGetParameter); if (is_numeric($intId)) { $this->intId = $intId; } } $strItemClass = \Model::getClassFromTable($this->formHybridDataContainer); // get id from share if ($strShare = \Input::get('share')) { if (($objItem = $strItemClass::findByShareToken($strShare)) !== null && !FormHybridList::shareTokenExpiredOrEmpty($objItem, time())) { $this->intId = $objItem->id; } } if (!$this->intId) { if (isset($GLOBALS['TL_HOOKS']['frontendEditAddNoIdBehavior']) && is_array($GLOBALS['TL_HOOKS']['frontendEditAddNoIdBehavior'])) { foreach ($GLOBALS['TL_HOOKS']['frontendEditAddNoIdBehavior'] as $arrCallback) { $this->import($arrCallback[0]); if ($this->{$arrCallback}[0]->{$arrCallback}[1]($this) === false) { return; } } } if ($this->noIdBehavior == 'error') { if (!$this->blnSilentMode) { StatusMessage::addError($GLOBALS['TL_LANG']['frontendedit']['noIdFound'], $this->id, 'noidfound'); } return; } elseif ($this->noIdBehavior == 'redirect' || $this->noIdBehavior == 'create_until') { $arrConditions = deserialize($this->existanceConditions, true); if ($this->existanceConditions && !empty($arrConditions)) { $arrColumns = array(); $arrValues = array(); foreach ($arrConditions as $arrCondition) { if (!$arrCondition['field']) { continue; } $arrColumns[] = $arrCondition['field'] . '=?'; $arrValues[] = $this->replaceInsertTags($arrCondition['value']); } if (!empty($arrColumns) && ($objItem = $strItemClass::findOneBy($arrColumns, $arrValues)) !== null) { $this->intId = $objItem->id; } } } if (!$this->intId) { if ($this->noIdBehavior == 'redirect') { if (!$this->blnSilentMode) { StatusMessage::addError($GLOBALS['TL_LANG']['frontendedit']['noIdFound'], $this->id, 'noidfound'); } return; } else { $strFormId = FormHelper::getFormId($this->formHybridDataContainer, $this->id); // get id from FormSession if ($_POST) { if ($intId = FormSession::getSubmissionId($strFormId)) { $this->intId = $intId; } } if (!$this->intId) { // if no id is given a new instance is initiated $objConfiguration = new FormConfiguration($this->arrData); // ajax handling, required in this manor, as we have no real ajax controller in contao and ajax request not related to this module // might trigger this module beforhand and new submission will be created after the submission was transfered to the user and id wont match any more if (Ajax::isRelated(Form::FORMHYBRID_NAME) !== null) { if ($intId = FormSession::getSubmissionId($strFormId)) { $this->intId = $intId; } else { $objConfiguration->forceCreate = true; } } $this->objForm = new $this->strFormClass($objConfiguration, $this->arrSubmitCallbacks, $this->intId ?: 0, $this); if ($intId = $this->objForm->getId()) { $this->intId = $intId; } } } } } // intId is set at this point! if (!$this->checkEntityExists($this->intId)) { if (!$this->blnSilentMode) { StatusMessage::addError($GLOBALS['TL_LANG']['formhybrid_list']['noPermission'], $this->id, 'nopermission'); } if (Ajax::isRelated(Form::FORMHYBRID_NAME)) { $objResponse = new ResponseError(); $objResponse->setResult(StatusMessage::generate($this->id)); $objResponse->output(); } return; } // page title if ($this->setPageTitle) { global $objPage; if (($objItem = General::getModelInstance($this->formHybridDataContainer, $this->intId)) !== null) { $objPage->pageTitle = $objItem->{$this->pageTitleField}; } } if ($strAction == FRONTENDEDIT_ACT_DELETE) { if ($this->checkDeletePermission($this->intId)) { $blnResult = $this->deleteItem($this->intId); if (\Environment::get('isAjaxRequest')) { die($blnResult); } // return to the list \Controller::redirect(Url::removeQueryString(array('act', 'id', 'token'), Url::getUrl())); } else { if (!$this->blnSilentMode) { StatusMessage::addError($GLOBALS['TL_LANG']['formhybrid_list']['noPermission'], $this->id, 'nopermission'); } return; } } else { if ($this->checkUpdatePermission($this->intId)) { // create a new lock if necessary if (in_array('entity_lock', \ModuleLoader::getActive()) && $this->addEntityLock) { if (\HeimrichHannot\EntityLock\EntityLockModel::isLocked($this->formHybridDataContainer, $this->intId, $this)) { $objLock = \HeimrichHannot\EntityLock\EntityLockModel::findActiveLock($this->formHybridDataContainer, $this->intId, $this); $objItem = General::getModelInstance($this->formHybridDataContainer, $this->intId); if (!$this->blnSilentMode) { $strMessage = \HeimrichHannot\EntityLock\EntityLock::generateErrorMessage($this->formHybridDataContainer, $this->intId, $this); if ($this->allowLockDeletion) { $strUnlockForm = $this->generateUnlockForm($objItem, $objLock); $strMessage .= $strUnlockForm; } StatusMessage::addError($strMessage, $this->id, 'locked'); } if ($this->readOnlyOnLocked) { $this->formHybridViewMode = FORMHYBRID_VIEW_MODE_READONLY; $this->formHybridReadonlyTemplate = 'formhybridreadonly_default'; } else { return; } } else { \HeimrichHannot\EntityLock\EntityLockModel::create($this->formHybridDataContainer, $this->intId, $this); } } if ($this->objForm === null) { $this->objForm = new $this->strFormClass(new FormConfiguration($this->arrData), $this->arrSubmitCallbacks, $this->intId, $this); } $this->Template->form = $this->objForm->generate(); $this->Template->item = $this->objForm->activeRecord; if (\Environment::get('isAjaxRequest') && \Input::get('scope') == 'modal') { $objItem = General::getModelInstance($this->formHybridDataContainer, $this->intId); $objModalWrapper = new \FrontendTemplate($this->modalTpl ?: 'formhybrid_reader_modal_bootstrap'); if ($objItem !== null) { $objModalWrapper->setData($objItem->row()); } $objModalWrapper->module = Arrays::arrayToObject($this->arrData); $objModalWrapper->item = $this->replaceInsertTags($this->Template->parse()); die($objModalWrapper->parse()); } } else { if (!$this->blnSilentMode) { StatusMessage::addError($GLOBALS['TL_LANG']['formhybrid_list']['noPermission'], $this->id, 'nopermission'); } return; } } }
/** * Generate the module * * @return string */ public function run() { $objTemplate = new \BackendTemplate('be_rsce_convert'); $objTemplate->isActive = $this->isActive(); $objTemplate->action = ampersand(\Environment::get('request')); $objTemplate->indexHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['searchIndex']; // Rebuild the index if (\Input::get('act') === 'rsce_convert') { // Check the request token if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) { $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request')); $this->redirect('contao/confirm.php'); } $this->import('Database'); $failedElements = array(); $elementsCount = 0; $contentElements = \ContentModel::findBy(array(\ContentModel::getTable() . '.type LIKE ?'), 'rsce_%'); while ($contentElements && $contentElements->next()) { $html = $this->getHtmlFromElement($contentElements); if (!$html) { $failedElements[] = array('content', $contentElements->id, $contentElements->type); } else { $this->createInitialVersion(\ContentModel::getTable(), $contentElements->id); $this->Database->prepare('UPDATE ' . \ContentModel::getTable() . ' SET tstamp = ?, type = \'html\', html = ? WHERE id = ?')->executeUncached(time(), $html, $contentElements->id); $elementsCount++; $this->createNewVersion(\ContentModel::getTable(), $contentElements->id); $this->log('A new version of record "' . \ContentModel::getTable() . '.id=' . $contentElements->id . '" has been created', __METHOD__, TL_GENERAL); } } $moduleElements = \ModuleModel::findBy(array(\ModuleModel::getTable() . '.type LIKE ?'), 'rsce_%'); while ($moduleElements && $moduleElements->next()) { $html = $this->getHtmlFromElement($moduleElements); if (!$html) { $failedElements[] = array('module', $moduleElements->id, $moduleElements->type); } else { $this->createInitialVersion(\ModuleModel::getTable(), $moduleElements->id); $this->Database->prepare('UPDATE ' . \ModuleModel::getTable() . ' SET tstamp = ?, type = \'html\', html = ? WHERE id = ?')->executeUncached(time(), $html, $moduleElements->id); $elementsCount++; $this->createNewVersion(\ModuleModel::getTable(), $moduleElements->id); $this->log('A new version of record "' . \ModuleModel::getTable() . '.id=' . $moduleElements->id . '" has been created', __METHOD__, TL_GENERAL); } } $formElements = \FormFieldModel::findBy(array(\FormFieldModel::getTable() . '.type LIKE ?'), 'rsce_%'); while ($formElements && $formElements->next()) { $html = $this->getHtmlFromElement($formElements); if (!$html) { $failedElements[] = array('form', $formElements->id, $formElements->type); } else { $this->createInitialVersion(\FormFieldModel::getTable(), $formElements->id); $this->Database->prepare('UPDATE ' . \FormFieldModel::getTable() . ' SET tstamp = ?, type = \'html\', html = ? WHERE id = ?')->executeUncached(time(), $html, $formElements->id); $elementsCount++; $this->createNewVersion(\FormFieldModel::getTable(), $formElements->id); $this->log('A new version of record "' . \FormFieldModel::getTable() . '.id=' . $formElements->id . '" has been created', __METHOD__, TL_GENERAL); } } foreach ($failedElements as $element) { $this->log('Failed to convert ' . $element[0] . ' element ID ' . $element[1] . ' (' . $element[2] . ') to a standard HTML element', __METHOD__, TL_ERROR); } $this->log('Converted ' . $elementsCount . ' RockSolid Custom Elements to standard HTML elements', __METHOD__, TL_GENERAL); $objTemplate->elementsCount = $elementsCount; $objTemplate->failedElements = $failedElements; } $this->loadLanguageFile('rocksolid_custom_elements'); return $objTemplate->parse(); }
/** * Initialize the object * @param string * @param array */ public function __construct($strTable, $arrModule = array()) { parent::__construct(); // Check the request token (see #4007) if (isset($_GET['act'])) { if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) { $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request')); \Controller::redirect('contao/confirm.php'); } } $this->intId = \Input::get('id'); // Clear the clipboard if (isset($_GET['clipboard'])) { $this->Session->set('CLIPBOARD', array()); \Controller::redirect($this->getReferer()); } $this->loadDataContainer('tl_form_field'); $this->import('Formdata'); // in Backend: Check BE User, Admin... if (TL_MODE == 'BE' || BE_USER_LOGGED_IN) { $this->import('BackendUser', 'User'); } // in Frontend: if (TL_MODE == 'FE') { $this->import('FrontendUser', 'Member'); } if (\Input::get('key') == 'export') { $this->strMode = 'export'; } elseif (\Input::get('key') == 'exportxls') { $this->strMode = 'exportxls'; } $this->blnExportUTF8Decode = true; $this->strExportConvertToCharset = 'CP1252'; if (isset($GLOBALS['EFG']['exportUTF8Decode']) && $GLOBALS['EFG']['exportUTF8Decode'] == false) { $this->blnExportUTF8Decode = false; } if (isset($GLOBALS['EFG']['exportConvertToCharset'])) { $this->strExportConvertToCharset = $GLOBALS['EFG']['exportConvertToCharset']; } if (isset($GLOBALS['EFG']['exportIgnoreFields'])) { if (is_string($GLOBALS['EFG']['exportIgnoreFields']) && strlen($GLOBALS['EFG']['exportIgnoreFields'])) { $this->arrExportIgnoreFields = trimsplit(',', $GLOBALS['EFG']['exportIgnoreFields']); } } // all field names of table tl_formdata foreach (\Database::getInstance()->listFields('tl_formdata') as $arrField) { if ($arrField['type'] != 'index') { $this->arrBaseFields[] = $arrField['name']; } } $this->arrBaseFields = array_unique($this->arrBaseFields); $this->arrOwnerFields = array('fd_member', 'fd_user', 'fd_member_group', 'fd_user_group'); $this->arrMembers = $this->Formdata->arrMembers; $this->arrMemberGroups = $this->Formdata->arrMemberGroups; $this->arrUsers = $this->Formdata->arrUsers; $this->arrUserGroups = $this->Formdata->arrUserGroups; // Check whether the table is defined if ($strTable == '' || !isset($GLOBALS['TL_DCA'][$strTable])) { $this->log('Could not load the data container configuration for "' . $strTable . '"', __METHOD__, TL_ERROR); trigger_error('Could not load the data container configuration', E_USER_ERROR); } // Set IDs and redirect if (\Input::post('FORM_SUBMIT') == 'tl_select') { $ids = \Input::post('IDS'); if (!is_array($ids) || empty($ids)) { \Controller::reload(); } $session = $this->Session->getData(); $session['CURRENT']['IDS'] = \Input::post('IDS'); $this->Session->setData($session); if (isset($_POST['edit'])) { \Controller::redirect(str_replace('act=select', 'act=editAll', \Environment::get('request'))); } elseif (isset($_POST['delete'])) { \Controller::redirect(str_replace('act=select', 'act=deleteAll', \Environment::get('request'))); } elseif (isset($_POST['override'])) { \Controller::redirect(str_replace('act=select', 'act=overrideAll', \Environment::get('request'))); } elseif (isset($_POST['cut']) || isset($_POST['copy'])) { $arrClipboard = $this->Session->get('CLIPBOARD'); $arrClipboard[$strTable] = array('id' => $ids, 'mode' => isset($_POST['cut']) ? 'cutAll' : 'copyAll'); $this->Session->set('CLIPBOARD', $arrClipboard); \Controller::redirect($this->getReferer()); } } $this->strTable = $strTable; $this->ptable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ptable']; $this->ctable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ctable']; $this->treeView = false; $this->root = null; $this->arrModule = $arrModule; // Key of a form or '' for no specific form $this->strFormKey = ''; $this->strFormFilterKey = ''; $this->strFormFilterValue = ''; if (\Input::get('do')) { if (\Input::get('do') != 'feedback') { if (array_key_exists(\Input::get('do'), $GLOBALS['BE_MOD']['formdata'])) { $this->strFormKey = \Input::get('do'); $this->strFormFilterKey = 'form'; $this->strFormFilterValue = $this->Formdata->arrStoringForms[substr($this->strFormKey, 3)]['title']; $this->sqlFormFilter = ' AND ' . $this->strFormFilterKey . '=\'' . $this->strFormFilterValue . '\' '; // add sql where condition 'form'=TITLE_OF_FORM if ($this->strTable == 'tl_formdata') { $this->procedure[] = $this->strFormFilterKey . '=?'; $this->values[] = $this->strFormFilterValue; } } } } // Call onload_callback (e.g. to check permissions) if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'])) { foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onload_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($this); } elseif (is_callable($callback)) { $callback($this); } } } // check names of detail fields // .. after call to onload_callback we have the form specific dca in $GLOBALS['TL_DCA'][$this->strTable] if (strlen($this->strFormKey)) { $arrFFNames = array_keys($GLOBALS['TL_DCA'][$this->strTable]['fields']); } else { $objFFNames = \Database::getInstance()->prepare("SELECT DISTINCT ff.name FROM tl_form_field ff, tl_form f WHERE (ff.pid=f.id) AND ff.name != '' AND f.storeFormdata=?")->execute("1"); if ($objFFNames->numRows) { $arrFFNames = $objFFNames->fetchEach('name'); } } if (!empty($arrFFNames)) { $this->arrDetailFields = array_diff($arrFFNames, $this->arrBaseFields, array('import_source')); } // store array of sql-stmts for detail fields if (!empty($this->arrDetailFields)) { $this->arrSqlDetails = array(); foreach ($this->arrDetailFields as $strFName) { $this->arrSqlDetails[$strFName] = '(SELECT value FROM tl_formdata_details WHERE ff_name=\'' . $strFName . '\' AND pid=f.id) AS `' . $strFName . '`'; } } // Store the current referer if (!empty($this->ctable) && !\Input::get('act') && !\Input::get('key') && !\Input::get('token') && \Environment::get('script') == 'contao/main.php' && !\Environment::get('isAjaxRequest')) { $session = $this->Session->get('referer'); $session[TL_REFERER_ID][$this->strTable] = substr(\Environment::get('requestUri'), strlen(TL_PATH) + 1); $this->Session->set('referer', $session); } }
/** * Generate the module * * @return string */ public function run() { $this->import('BackendUser', 'User'); $this->registerEvents(); $time = time(); /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_filecredits_sync'); $objTemplate->action = ampersand(\Environment::get('request')); $objTemplate->syncHeadline = $GLOBALS['TL_LANG']['tl_filecredit']['syncHeadline']; $objTemplate->isActive = $this->isActive(); $objTemplate->pageSelection = $this->generatePageSelection(); if (!\Config::get('headerAddXFrame') || !\Config::get('headerAllowOrigins')) { $objTemplate->originInfo = $GLOBALS['TL_LANG']['tl_filecredit']['originInfo']; } // Add the error message if ($_SESSION['REBUILD_FILECREDIT_ERROR'] != '') { $objTemplate->indexMessage = $_SESSION['REBUILD_FILECREDIT_ERROR']; $_SESSION['REBUILD_FILECREDIT_ERROR'] = ''; } // Rebuild the index if (\Input::get('act') == 'index') { // Check the request token (see #4007) if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) { $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request')); $this->redirect('contao/confirm.php'); } $arrPages = static::findFileCreditPages(); // HOOK: take additional pages (news, events…) if (isset($GLOBALS['TL_HOOKS']['getSearchablePages']) && is_array($GLOBALS['TL_HOOKS']['getSearchablePages'])) { foreach ($GLOBALS['TL_HOOKS']['getSearchablePages'] as $callback) { $this->import($callback[0]); $arrPages = $this->{$callback}[0]->{$callback}[1]($arrPages); } } $blnTruncateTable = true; if (\Input::get('limitfilecreditpages')) { $arrSelectedPages = \Input::get('filecreditpages'); if (is_array($arrSelectedPages) && !empty($arrSelectedPages)) { $arrPages = array_keys(array_intersect(array_flip($arrPages), $arrSelectedPages)); $blnTruncateTable = false; } } // Return if there are no pages if (empty($arrPages)) { $_SESSION['REBUILD_FILECREDIT_ERROR'] = $GLOBALS['TL_LANG']['tl_filecredit']['noSearchable']; \Controller::redirect(\System::getReferer()); } // Truncate the search tables if ($blnTruncateTable) { Automator::purgeFileCreditTables(); } // Hide unpublished elements $this->setCookie('FE_PREVIEW', 0, $time - 86400); // Calculate the hash $strHash = sha1(session_id() . (!\Config::get('disableIpCheck') ? \Environment::get('ip') : '') . 'FE_USER_AUTH'); // Remove old sessions $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute($time - \Config::get('sessionTimeout'), $strHash); // Log in the front end user if (is_numeric(\Input::get('user')) && \Input::get('user') > 0) { // Insert a new session $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute(\Input::get('user'), $time, 'FE_USER_AUTH', session_id(), \Environment::get('ip'), $strHash); // Set the cookie $this->setCookie('FE_USER_AUTH', $strHash, $time + \Config::get('sessionTimeout'), null, null, false, true); } else { // Unset the cookies $this->setCookie('FE_USER_AUTH', $strHash, $time - 86400, null, null, false, true); $this->setCookie('FE_AUTO_LOGIN', \Input::cookie('FE_AUTO_LOGIN'), $time - 86400, null, null, false, true); } $strBuffer = ''; $rand = rand(); // Display the pages for ($i = 0, $c = count($arrPages); $i < $c; $i++) { if (!\Validator::isUrl($arrPages[$i])) { continue; } $strBuffer .= '<span class="page_url" data-url="' . $arrPages[$i] . '#' . $rand . $i . '">' . \StringUtil::substr($arrPages[$i], 100) . '</span><br>'; unset($arrPages[$i]); // see #5681 } $objTemplate->content = $strBuffer; $objTemplate->note = $GLOBALS['TL_LANG']['tl_filecredit']['indexNote']; $objTemplate->loading = $GLOBALS['TL_LANG']['tl_filecredit']['indexLoading']; $objTemplate->complete = $GLOBALS['TL_LANG']['tl_filecredit']['indexComplete']; $objTemplate->indexContinue = $GLOBALS['TL_LANG']['MSC']['continue']; $objTemplate->theme = \Backend::getTheme(); $objTemplate->isRunning = true; } // Default variables $objTemplate->indexSubmit = $GLOBALS['TL_LANG']['tl_filecredit']['syncSubmit']; $objTemplate->backHref = \System::getReferer(true); $objTemplate->backTitle = specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']); $objTemplate->backButton = $GLOBALS['TL_LANG']['MSC']['backBT']; return $objTemplate->parse(); }