/** * Activates DBAL if it is supported. * * @param tx_install $instObj * @return void */ public function execute(tx_install $instObj) { if ($instObj->mode == '123') { switch ($instObj->step) { case 1: if (!t3lib_extMgm::isLoaded('dbal') && $this->isDbalSupported()) { $this->activateDbal(); // Reload page to have Install Tool actually load DBAL $redirectUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'); t3lib_utility_Http::redirect($redirectUrl); } break; case 2: if (!t3lib_extMgm::isLoaded('dbal') && $this->isDbalSupported()) { $this->activateDbal(); } break; case 3: $driver = $instObj->INSTALL['localconf.php']['typo_db_driver']; if ($driver === 'mysql') { $this->deactivateDbal(); } break; } } }
/** * Error handling if no news entry is found * * @param string $configuration configuration what will be done * @throws InvalidArgumentException * @return void */ protected function handleNoNewsFoundError($configuration) { if (empty($configuration)) { return; } $configuration = t3lib_div::trimExplode(',', $configuration, TRUE); switch ($configuration[0]) { case 'redirectToListView': $this->redirect('list'); break; case 'redirectToPage': if (count($configuration) === 1 || count($configuration) > 3) { $msg = sprintf('If error handling "%s" is used, either 2 or 3 arguments, splitted by "," must be used', $configuration[0]); throw new InvalidArgumentException($msg); } /** @var $cObj tslib_cObj */ $cObj = t3lib_div::makeInstance('tslib_cObj'); $url = $cObj->typoLink_URL(array('parameter' => $configuration[1])); if (isset($configuration[2])) { $header = 'HTTP_STATUS_' . $configuration[2]; t3lib_utility_Http::redirect($url, $header); } else { t3lib_utility_Http::redirect($url); } break; case 'pageNotFoundHandler': $GLOBALS['TSFE']->pageNotFoundAndExit('No news entry found.'); break; default: // Do nothing, it might be handled in the view. } }
/** * Processed Backend session creation and redirect to backend.php * * @return void */ public function main() { if ($GLOBALS['BE_USER']->user['uid']) { t3lib_div::cleanOutputBuffers(); $backendURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . 'backend.php'; t3lib_utility_Http::redirect($backendURL); } }
function switchBack($params, $that) { if ($that->session_table == 'be_sessions' && $that->user['uid'] && $that->user['ses_backuserid']) { $updateData = array('ses_userid' => $that->user['ses_backuserid'], 'ses_backuserid' => 0); $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_sessions', 'ses_id=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->id, 'be_sessions') . ' AND ses_name=\'be_typo_user\' AND ses_userid=' . intval($GLOBALS['BE_USER']->user['uid']), $updateData); $redirectUrl = $GLOBALS['BACK_PATH'] . 'index.php' . ($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces'] ? '' : '?commandLI=1'); t3lib_utility_Http::redirect($redirectUrl); } }
/** * Performs the logout processing * * @return void */ function logout() { global $BE_USER; $BE_USER->writelog(255, 2, 0, 1, 'User %s logged out from TYPO3 Backend', array($BE_USER->user['username'])); // Logout written to log $BE_USER->logoff(); $redirectUrl = t3lib_div::_GP('redirect') ? t3lib_div::_GP('redirect') : 'index.php'; t3lib_utility_Http::redirect($redirectUrl); }
/** * Processed Backend session creation and redirect to backend.php * * @return void */ public function main() { if ($GLOBALS['BE_USER']->user['uid']) { while (ob_get_level() > 0) { @ob_end_clean(); } $backendURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . 'backend.php'; t3lib_utility_Http::redirect($backendURL); } }
/** * Processes eID request. * * @return void */ public function main() { // Due to the nature of OpenID (redrections, etc) we need to force user // session fetching if there is no session around. This ensures that // our service is called even if there is no login data in the request. // Inside the service we will process OpenID response and authenticate // the user. $GLOBALS['TYPO3_CONF_VARS']['SVCONF']['auth']['FE_fetchUserIfNoSession'] = true; // Initialize Frontend user tslib_eidtools::connectDB(); tslib_eidtools::initFeUser(); // Redirect to the original location in any case (authenticated or not) @ob_end_clean(); t3lib_utility_Http::redirect(t3lib_div::_GP('tx_openid_location'), t3lib_utility_Http::HTTP_STATUS_303); }
public function kennungenVerwalten() { if (!tx_he_tools_util::userEingeloggt()) { return $this->zeigeLoginLink(); } $username = $GLOBALS['TSFE']->fe_user->user['username']; $get = t3lib_div::_GET(); $post = t3lib_div::_POST(); if (isset($get['antragsId']) && isset($get['csvExport'])) { $uid = $get['antragsId']; if ($this->zugriffErlaubt($username, $uid, 'csvExport')) { return $this->csvExport($username, $uid); } } if (isset($get['antragsId']) && isset($get['angelegt'])) { $uid = $get['antragsId']; if ($this->zugriffErlaubt($username, $uid, 'angelegt')) { if ($get['noEmail'] == 1) { return $this->kennungenAngelegt($uid, false); } elseif ($get['confirm'] == 1) { return $this->kennungenAngelegt($uid); } else { return $this->zeigeFormularKennungenAngelegt($uid); } } } if (isset($get['antragsId']) && $get['loeschen'] == 1) { $antragsId = $get['antragsId']; if ($this->zugriffErlaubt($username, $antragsId, 'loeschen')) { $this->antragLoeschen($antragsId, $username); $page = $GLOBALS['TSFE']->id; $pageUrl = 'https://www.hs-esslingen.de/index.php?id=' . $page; t3lib_utility_Http::redirect($pageUrl); exit; } } $GLOBALS['TSFE']->additionalHeaderData['he_tools_css_1'] .= ' <link href="' . t3lib_extMgm::siteRelPath('he_tools') . 'res/css/cisco_guests_form.css" rel="stylesheet" type="text/css" /> <link href="/typo3/sysext/t3skin/stylesheets/sprites/t3skin.css" rel="stylesheet" type="text/css" /> '; if (!empty($get['antragsId'])) { $out = $this->antragsdatenEinzeln($username, $get['antragsId']); } else { $out = $this->antragsdatenListe($username); } return $out; }
/** * The main method of the plugin * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * @return string The content that is displayed on the website */ public function main($content, $conf) { $content = parent::main($content, $conf); // Process the redirect (without cookie warning) if (($this->logintype === 'login' || $this->logintype === 'logout') && $this->redirectUrl && !$this->noRedirect) { // Add hook for extra processing before redirect if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['beforeRedirect']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['beforeRedirect'])) { $_params = array('loginType' => $this->logintype, 'redirectUrl' => &$this->redirectUrl); foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['beforeRedirect'] as $_funcRef) { if ($_funcRef) { t3lib_div::callUserFunction($_funcRef, $_params, $this); } } } t3lib_utility_Http::redirect($this->redirectUrl); } return $content; }
/** * Import part of module * * @param array Content of POST VAR tx_impexp[].. * @return void Setting content in $this->content */ function importData($inData) { global $TCA, $LANG, $BE_USER; $access = is_array($this->pageinfo) ? 1 : 0; if ($this->id && $access || $BE_USER->user['admin'] && !$this->id) { if ($BE_USER->user['admin'] && !$this->id) { $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0); } if ($inData['new_import']) { unset($inData['import_mode']); } $import = t3lib_div::makeInstance('tx_impexp'); $import->init(0, 'import'); $import->update = $inData['do_update']; $import->import_mode = $inData['import_mode']; $import->enableLogging = $inData['enableLogging']; $import->global_ignore_pid = $inData['global_ignore_pid']; $import->force_all_UIDS = $inData['force_all_UIDS']; $import->showDiff = !$inData['notShowDiff']; $import->allowPHPScripts = $inData['allowPHPScripts']; $import->softrefInputValues = $inData['softrefInputValues']; // OUTPUT creation: $menuItems = array(); // Make input selector: $path = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']; // must have trailing slash. $filesInDir = t3lib_div::getFilesInDir(PATH_site . $path, 't3d,xml', 1, 1); $userPath = $this->userSaveFolder(); //Files from User-Dir $filesInUserDir = t3lib_div::getFilesInDir($userPath, 't3d,xml', 1, 1); $filesInDir = array_merge($filesInUserDir, $filesInDir); if (is_dir(PATH_site . $path . 'export/')) { $filesInDir = array_merge($filesInDir, t3lib_div::getFilesInDir(PATH_site . $path . 'export/', 't3d,xml', 1, 1)); } $tempFolder = $this->userTempFolder(); if ($tempFolder) { $temp_filesInDir = t3lib_div::getFilesInDir($tempFolder, 't3d,xml', 1, 1); $filesInDir = array_merge($filesInDir, $temp_filesInDir); } // Configuration $row = array(); $opt = array(''); foreach ($filesInDir as $file) { $opt[$file] = substr($file, strlen(PATH_site)); } $row[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $LANG->getLL('importdata_selectFileToImport', 1) . '</strong></td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_file', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'importFile', $GLOBALS['BACK_PATH'], '') . '</td> <td>' . $this->renderSelectBox('tx_impexp[file]', $inData['file'], $opt) . '<br />' . sprintf($LANG->getLL('importdata_fromPathS', 1), $path) . (!$import->compress ? '<br /><span class="typo3-red">' . $LANG->getLL('importdata_noteNoDecompressorAvailable', 1) . '</span>' : '') . '</td> </tr>'; $row[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $LANG->getLL('importdata_importOptions', 1) . '</strong></td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_update', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'update', $GLOBALS['BACK_PATH'], '') . '</td> <td> <input type="checkbox" name="tx_impexp[do_update]" id="checkDo_update" value="1"' . ($inData['do_update'] ? ' checked="checked"' : '') . ' /> <label for="checkDo_update">' . $LANG->getLL('importdata_updateRecords', 1) . '</label><br/> <em>(' . $LANG->getLL('importdata_thisOptionRequiresThat', 1) . ')</em>' . ($inData['do_update'] ? ' <hr/> <input type="checkbox" name="tx_impexp[global_ignore_pid]" id="checkGlobal_ignore_pid" value="1"' . ($inData['global_ignore_pid'] ? ' checked="checked"' : '') . ' /> <label for="checkGlobal_ignore_pid">' . $LANG->getLL('importdata_ignorePidDifferencesGlobally', 1) . '</label><br/> <em>(' . $LANG->getLL('importdata_ifYouSetThis', 1) . ')</em> ' : '') . '</td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_options', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'options', $GLOBALS['BACK_PATH'], '') . '</td> <td> <input type="checkbox" name="tx_impexp[notShowDiff]" id="checkNotShowDiff" value="1"' . ($inData['notShowDiff'] ? ' checked="checked"' : '') . ' /> <label for="checkNotShowDiff">' . $LANG->getLL('importdata_doNotShowDifferences', 1) . '</label><br/> <em>(' . $LANG->getLL('importdata_greenValuesAreFrom', 1) . ')</em> <br/><br/> ' . ($GLOBALS['BE_USER']->isAdmin() ? ' <input type="checkbox" name="tx_impexp[allowPHPScripts]" id="checkAllowPHPScripts" value="1"' . ($inData['allowPHPScripts'] ? ' checked="checked"' : '') . ' /> <label for="checkAllowPHPScripts">' . $LANG->getLL('importdata_allowToWriteBanned', 1) . '</label><br/>' : '') . (!$inData['do_update'] && $GLOBALS['BE_USER']->isAdmin() ? ' <br/> <input type="checkbox" name="tx_impexp[force_all_UIDS]" id="checkForce_all_UIDS" value="1"' . ($inData['force_all_UIDS'] ? ' checked="checked"' : '') . ' /> <label for="checkForce_all_UIDS"><span class="typo3-red">' . $LANG->getLL('importdata_force_all_UIDS', 1) . '</span></label><br/> <em>(' . $LANG->getLL('importdata_force_all_UIDS_descr', 1) . ')</em>' : '') . ' </td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_action', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'action', $GLOBALS['BACK_PATH'], '') . '</td> <td>' . (!$inData['import_file'] ? '<input type="submit" value="' . $LANG->getLL('importdata_preview', 1) . '" />' . ($inData['file'] ? ' - <input type="submit" value="' . ($inData['do_update'] ? $LANG->getLL('importdata_update_299e', 1) : $LANG->getLL('importdata_import', 1)) . '" name="tx_impexp[import_file]" onclick="return confirm(\'' . $LANG->getLL('importdata_areYouSure', 1) . '\');" />' : '') : '<input type="submit" name="tx_impexp[new_import]" value="' . $LANG->getLL('importdata_newImport', 1) . '" />') . ' <input type="hidden" name="tx_impexp[action]" value="import" /></td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_enableLogging', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'enableLogging', $GLOBALS['BACK_PATH'], '') . '</td> <td> <input type="checkbox" name="tx_impexp[enableLogging]" id="checkEnableLogging" value="1"' . ($inData['enableLogging'] ? ' checked="checked"' : '') . ' /> <label for="checkEnableLogging">' . $LANG->getLL('importdata_writeIndividualDbActions', 1) . '</label><br/> <em>(' . $LANG->getLL('importdata_thisIsDisabledBy', 1) . ')</em> </td> </tr>'; $menuItems[] = array('label' => $LANG->getLL('importdata_import', 1), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); // Upload file: $tempFolder = $this->userTempFolder(); if ($tempFolder) { $row = array(); $row[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $LANG->getLL('importdata_uploadFileFromLocal', 1) . '</strong></td> </tr>'; $row[] = '<tr class="bgColor4"> <td>' . $LANG->getLL('importdata_browse', 1) . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'upload', $GLOBALS['BACK_PATH'], '') . '</td> <td> <input type="file" name="upload_1"' . $this->doc->formWidth(35) . ' size="40" /> <input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempFolder) . '" /> <input type="hidden" name="file[upload][1][data]" value="1" /><br /> <input type="submit" name="_upload" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit', 1) . '" /> <input type="checkbox" name="overwriteExistingFiles" id="checkOverwriteExistingFiles" value="1" checked="checked" /> <label for="checkOverwriteExistingFiles">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.php:overwriteExistingFiles', 1) . '</label> </td> </tr>'; if (t3lib_div::_POST('_upload')) { $row[] = '<tr class="bgColor4"> <td>' . $LANG->getLL('importdata_uploadStatus', 1) . '</td> <td>' . ($this->fileProcessor->internalUploadMap[1] ? $LANG->getLL('importdata_success', 1) . ' ' . substr($this->fileProcessor->internalUploadMap[1], strlen(PATH_site)) : '<span class="typo3-red">' . $LANG->getLL('importdata_failureNoFileUploaded', 1) . '</span>') . '</td> </tr>'; } $menuItems[] = array('label' => $LANG->getLL('importdata_upload'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); } // Perform import or preview depending: $overviewContent = ''; $extensionInstallationMessage = ''; $emURL = ''; $inFile = t3lib_div::getFileAbsFileName($inData['file']); if ($inFile && @is_file($inFile)) { $trow = array(); if ($import->loadFile($inFile, 1)) { // Check extension dependencies: $extKeysToInstall = array(); if (is_array($import->dat['header']['extensionDependencies'])) { foreach ($import->dat['header']['extensionDependencies'] as $extKey) { if (!t3lib_extMgm::isLoaded($extKey)) { $extKeysToInstall[] = $extKey; } } } if (count($extKeysToInstall)) { $passParams = t3lib_div::_POST('tx_impexp'); unset($passParams['import_mode']); unset($passParams['import_file']); $thisScriptUrl = t3lib_div::getIndpEnv('REQUEST_URI') . '?M=xMOD_tximpexp&id=' . $this->id . t3lib_div::implodeArrayForUrl('tx_impexp', $passParams); $emURL = $this->doc->backPath . 'mod/tools/em/index.php?CMD[requestInstallExtensions]=' . implode(',', $extKeysToInstall) . '&returnUrl=' . rawurlencode($thisScriptUrl); $extensionInstallationMessage = 'Before you can install this T3D file you need to install the extensions "' . implode('", "', $extKeysToInstall) . '". Clicking Import will first take you to the Extension Manager so these dependencies can be resolved.'; } if ($inData['import_file']) { if (!count($extKeysToInstall)) { $import->importData($this->id); t3lib_BEfunc::setUpdateSignal('updatePageTree'); } else { t3lib_utility_Http::redirect($emURL); } } $import->display_import_pid_record = $this->pageinfo; $overviewContent = $import->displayContentOverview(); } // Meta data output: $trow[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $LANG->getLL('importdata_metaData', 1) . '</strong></td> </tr>'; $opt = array(''); foreach ($filesInDir as $file) { $opt[$file] = substr($file, strlen(PATH_site)); } $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_title', 1) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['title'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_description', 1) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['description'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_notes', 1) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['notes'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_packager', 1) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['packager_name'] . ' (' . $import->dat['header']['meta']['packager_username'] . ')')) . '<br/> ' . $LANG->getLL('importdata_email', 1) . ' ' . $import->dat['header']['meta']['packager_email'] . '</td> </tr>'; // Thumbnail icon: if (is_array($import->dat['header']['thumbnail'])) { $pI = pathinfo($import->dat['header']['thumbnail']['filename']); if (t3lib_div::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) { // Construct filename and write it: $fileName = PATH_site . 'typo3temp/importthumb.' . $pI['extension']; t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']); // Check that the image really is an image and not a malicious PHP script... if (getimagesize($fileName)) { // Create icon tag: $iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_icon', 1) . '</strong></td> <td>' . $iconTag . '</td> </tr>'; } else { t3lib_div::unlink_tempfile($fileName); } } } $menuItems[] = array('label' => $LANG->getLL('importdata_metaData_1387'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $trow) . ' </table> '); } // Print errors that might be: $errors = $import->printErrorLog(); $menuItems[] = array('label' => $LANG->getLL('importdata_messages'), 'content' => $errors, 'stateIcon' => $errors ? 2 : 0); // Output tabs: $content = $this->doc->getDynTabMenu($menuItems, 'tx_impexp_import', -1); if ($extensionInstallationMessage) { $content = '<div style="border: 1px black solid; margin: 10px 10px 10px 10px; padding: 10px 10px 10px 10px;">' . $this->doc->icons(1) . htmlspecialchars($extensionInstallationMessage) . '</div>' . $content; } $this->content .= $this->doc->section('', $content, 0, 1); // Print overview: if ($overviewContent) { $this->content .= $this->doc->section($inData['import_file'] ? $LANG->getLL('importdata_structureHasBeenImported', 1) : $LANG->getLL('filterpage_structureToBeImported', 1), $overviewContent, 0, 1); } } }
/** * Main function * Makes a header-location redirect to an edit form IF POSSIBLE from the passed data - otherwise the window will just close. * * @return void */ function main() { global $TCA; if ($this->doClose) { $this->closeWindow(); } else { // Initialize: $table = $this->P['table']; $field = $this->P['field']; t3lib_div::loadTCA($table); $config = $TCA[$table]['columns'][$field]['config']; $fTable = $this->P['currentValue'] < 0 ? $config['neg_foreign_table'] : $config['foreign_table']; // Detecting the various allowed field type setups and acting accordingly. if (is_array($config) && $config['type'] == 'select' && !$config['MM'] && $config['maxitems'] <= 1 && t3lib_div::testInt($this->P['currentValue']) && $this->P['currentValue'] && $fTable) { // SINGLE value: $redirectUrl = 'alt_doc.php?returnUrl=' . rawurlencode('wizard_edit.php?doClose=1') . '&edit[' . $fTable . '][' . $this->P['currentValue'] . ']=edit'; t3lib_utility_Http::redirect($redirectUrl); } elseif (is_array($config) && $this->P['currentSelectedValues'] && ($config['type'] == 'select' && $config['foreign_table'] || $config['type'] == 'group' && $config['internal_type'] == 'db')) { // MULTIPLE VALUES: // Init settings: $allowedTables = $config['type'] == 'group' ? $config['allowed'] : $config['foreign_table'] . ',' . $config['neg_foreign_table']; $prependName = 1; $params = ''; // Selecting selected values into an array: $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup'); $dbAnalysis->start($this->P['currentSelectedValues'], $allowedTables); $value = $dbAnalysis->getValueArray($prependName); // Traverse that array and make parameters for alt_doc.php: foreach ($value as $rec) { $recTableUidParts = t3lib_div::revExplode('_', $rec, 2); $params .= '&edit[' . $recTableUidParts[0] . '][' . $recTableUidParts[1] . ']=edit'; } // Redirect to alt_doc.php: t3lib_utility_Http::redirect('alt_doc.php?returnUrl=' . rawurlencode('wizard_edit.php?doClose=1') . $params); } else { $this->closeWindow(); } } }
/** * Sends a header "Location" to jumpUrl, if jumpurl is set. * Will exit if a location header is sent (for instance if jumpUrl was triggered) * * "jumpUrl" is a concept where external links are redirected from the index_ts.php script, which first logs the URL. * This feature is only interesting if config.sys_stat is used. * * @return void */ function jumpUrl() { if ($this->jumpurl) { if (t3lib_div::_GP('juSecure')) { $hArr = array($this->jumpurl, t3lib_div::_GP('locationData'), $this->TYPO3_CONF_VARS['SYS']['encryptionKey']); $calcJuHash = t3lib_div::shortMD5(serialize($hArr)); $locationData = t3lib_div::_GP('locationData'); $juHash = t3lib_div::_GP('juHash'); if ($juHash == $calcJuHash) { if ($this->locDataCheck($locationData)) { $this->jumpurl = rawurldecode($this->jumpurl); // 211002 - goes with cObj->filelink() rawurlencode() of filenames so spaces can be allowed. // Deny access to files that match TYPO3_CONF_VARS[SYS][fileDenyPattern] and whose parent directory is typo3conf/ (there could be a backup file in typo3conf/ which does not match against the fileDenyPattern) if (t3lib_div::verifyFilenameAgainstDenyPattern($this->jumpurl) && basename(dirname($this->jumpurl)) !== 'typo3conf') { if (@is_file($this->jumpurl)) { $mimeType = t3lib_div::_GP('mimeType'); $mimeType = $mimeType ? $mimeType : 'application/octet-stream'; header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Type: ' . $mimeType); header('Content-Disposition: attachment; filename=' . basename($this->jumpurl)); readfile($this->jumpurl); exit; } else { die('jumpurl Secure: "' . $this->jumpurl . '" was not a valid file!'); } } else { die('jumpurl Secure: The requested file type was not allowed to be accessed through jumpUrl (fileDenyPattern)!'); } } else { die('jumpurl Secure: locationData, ' . $locationData . ', was not accessible.'); } } else { die('jumpurl Secure: Calculated juHash did not match the submitted juHash.'); } } else { $TSConf = $this->getPagesTSconfig(); if ($TSConf['TSFE.']['jumpUrl_transferSession']) { $uParts = parse_url($this->jumpurl); $params = '&FE_SESSION_KEY=' . rawurlencode($this->fe_user->id . '-' . md5($this->fe_user->id . '/' . $this->TYPO3_CONF_VARS['SYS']['encryptionKey'])); $this->jumpurl .= ($uParts['query'] ? '' : '?') . $params; // Add the session parameter ... } if ($TSConf['TSFE.']['jumpURL_HTTPStatusCode']) { switch (intval($TSConf['TSFE.']['jumpURL_HTTPStatusCode'])) { case 301: $statusCode = t3lib_utility_Http::HTTP_STATUS_301; break; case 302: $statusCode = t3lib_utility_Http::HTTP_STATUS_302; break; case 307: $statusCode = t3lib_utility_Http::HTTP_STATUS_307; break; case 303: default: $statusCode = t3lib_utility_Http::HTTP_STATUS_303; break; } } t3lib_utility_Http::redirect($this->jumpurl, $statusCode); } } }
/** * Checks if a submission of username and password is present or use other authentication by auth services * * @return void * @internal */ function checkAuthentication() { // No user for now - will be searched by service below $tempuserArr = array(); $tempuser = FALSE; // User is not authenticated by default $authenticated = FALSE; // User want to login with passed login data (name/password) $activeLogin = FALSE; // Indicates if an active authentication failed (not auto login) $this->loginFailure = FALSE; if ($this->writeDevLog) { t3lib_div::devLog('Login type: ' . $this->loginType, 't3lib_userAuth'); } // The info array provide additional information for auth services $authInfo = $this->getAuthInfoArray(); // Get Login/Logout data submitted by a form or params $loginData = $this->getLoginFormData(); if ($this->writeDevLog) { t3lib_div::devLog('Login data: ' . t3lib_div::arrayToLogString($loginData), 't3lib_userAuth'); } // active logout (eg. with "logout" button) if ($loginData['status'] == 'logout') { if ($this->writeStdLog) { $this->writelog(255, 2, 0, 2, 'User %s logged out', array($this->user['username'])); } // Logout written to log if ($this->writeDevLog) { t3lib_div::devLog('User logged out. Id: ' . $this->id, 't3lib_userAuth', -1); } $this->logoff(); } // active login (eg. with login form) if ($loginData['status'] == 'login') { $activeLogin = TRUE; if ($this->writeDevLog) { t3lib_div::devLog('Active login (eg. with login form)', 't3lib_userAuth'); } // check referer for submitted login values if ($this->formfield_status && $loginData['uident'] && $loginData['uname']) { $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY'); if (!$this->getMethodEnabled && ($httpHost != $authInfo['refInfo']['host'] && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer'])) { throw new RuntimeException('TYPO3 Fatal Error: Error: This host address ("' . $httpHost . '") and the referer host ("' . $authInfo['refInfo']['host'] . '") mismatches!<br /> It\'s possible that the environment variable HTTP_REFERER is not passed to the script because of a proxy.<br /> The site administrator can disable this check in the "All Configuration" section of the Install Tool (flag: TYPO3_CONF_VARS[SYS][doNotCheckReferer]).', 1270853930); } // delete old user session if any $this->logoff(); } // Refuse login for _CLI users, if not processing a CLI request type // (although we shouldn't be here in case of a CLI request type) if (strtoupper(substr($loginData['uname'], 0, 5)) == '_CLI_' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI)) { throw new RuntimeException('TYPO3 Fatal Error: You have tried to login using a CLI user. Access prohibited!', 1270853931); } } // the following code makes auto-login possible (if configured). No submitted data needed // determine whether we need to skip session update. // This is used mainly for checking session timeout without // refreshing the session itself while checking. if (t3lib_div::_GP('skipSessionUpdate')) { $skipSessionUpdate = true; } else { $skipSessionUpdate = false; } // re-read user session $authInfo['userSession'] = $this->fetchUserSession($skipSessionUpdate); $haveSession = is_array($authInfo['userSession']) ? TRUE : FALSE; if ($this->writeDevLog) { if ($haveSession) { t3lib_div::devLog('User session found: ' . t3lib_div::arrayToLogString($authInfo['userSession'], array($this->userid_column, $this->username_column)), 't3lib_userAuth', 0); } if (is_array($this->svConfig['setup'])) { t3lib_div::devLog('SV setup: ' . t3lib_div::arrayToLogString($this->svConfig['setup']), 't3lib_userAuth', 0); } } // fetch user if ... if ($activeLogin || !$haveSession && $this->svConfig['setup'][$this->loginType . '_fetchUserIfNoSession'] || $this->svConfig['setup'][$this->loginType . '_alwaysFetchUser']) { // use 'auth' service to find the user // first found user will be used $serviceChain = ''; $subType = 'getUser' . $this->loginType; while (is_object($serviceObj = t3lib_div::makeInstanceService('auth', $subType, $serviceChain))) { $serviceChain .= ',' . $serviceObj->getServiceKey(); $serviceObj->initAuth($subType, $loginData, $authInfo, $this); if ($row = $serviceObj->getUser()) { $tempuserArr[] = $row; if ($this->writeDevLog) { t3lib_div::devLog('User found: ' . t3lib_div::arrayToLogString($row, array($this->userid_column, $this->username_column)), 't3lib_userAuth', 0); } // user found, just stop to search for more if not configured to go on if (!$this->svConfig['setup'][$this->loginType . '_fetchAllUsers']) { break; } } unset($serviceObj); } unset($serviceObj); if ($this->writeDevLog && $this->svConfig['setup'][$this->loginType . '_alwaysFetchUser']) { t3lib_div::devLog($this->loginType . '_alwaysFetchUser option is enabled', 't3lib_userAuth'); } if ($this->writeDevLog && $serviceChain) { t3lib_div::devLog($subType . ' auth services called: ' . $serviceChain, 't3lib_userAuth'); } if ($this->writeDevLog && !count($tempuserArr)) { t3lib_div::devLog('No user found by services', 't3lib_userAuth'); } if ($this->writeDevLog && count($tempuserArr)) { t3lib_div::devLog(count($tempuserArr) . ' user records found by services', 't3lib_userAuth'); } } // If no new user was set we use the already found user session if (!count($tempuserArr) && $haveSession) { $tempuserArr[] = $authInfo['userSession']; $tempuser = $authInfo['userSession']; // User is authenticated because we found a user session $authenticated = TRUE; if ($this->writeDevLog) { t3lib_div::devLog('User session used: ' . t3lib_div::arrayToLogString($authInfo['userSession'], array($this->userid_column, $this->username_column)), 't3lib_userAuth'); } } // Re-auth user when 'auth'-service option is set if ($this->svConfig['setup'][$this->loginType . '_alwaysAuthUser']) { $authenticated = FALSE; if ($this->writeDevLog) { t3lib_div::devLog('alwaysAuthUser option is enabled', 't3lib_userAuth'); } } // Authenticate the user if needed if (count($tempuserArr) && !$authenticated) { foreach ($tempuserArr as $tempuser) { // use 'auth' service to authenticate the user // if one service returns FALSE then authentication failed // a service might return 100 which means there's no reason to stop but the user can't be authenticated by that service if ($this->writeDevLog) { t3lib_div::devLog('Auth user: '******'t3lib_userAuth'); } $serviceChain = ''; $subType = 'authUser' . $this->loginType; while (is_object($serviceObj = t3lib_div::makeInstanceService('auth', $subType, $serviceChain))) { $serviceChain .= ',' . $serviceObj->getServiceKey(); $serviceObj->initAuth($subType, $loginData, $authInfo, $this); if (($ret = $serviceObj->authUser($tempuser)) > 0) { // if the service returns >=200 then no more checking is needed - useful for IP checking without password if (intval($ret) >= 200) { $authenticated = TRUE; break; } elseif (intval($ret) >= 100) { // Just go on. User is still not authenticated but there's no reason to stop now. } else { $authenticated = TRUE; } } else { $authenticated = FALSE; break; } unset($serviceObj); } unset($serviceObj); if ($this->writeDevLog && $serviceChain) { t3lib_div::devLog($subType . ' auth services called: ' . $serviceChain, 't3lib_userAuth'); } if ($authenticated) { // leave foreach() because a user is authenticated break; } } } // If user is authenticated a valid user is in $tempuser if ($authenticated) { // reset failure flag $this->loginFailure = FALSE; // Insert session record if needed: if (!($haveSession && ($tempuser['ses_id'] == $this->id || $tempuser['uid'] == $authInfo['userSession']['ses_userid']))) { $this->createUserSession($tempuser); // The login session is started. $this->loginSessionStarted = TRUE; } // User logged in - write that to the log! if ($this->writeStdLog && $activeLogin) { $this->writelog(255, 1, 0, 1, 'User %s logged in from %s (%s)', array($tempuser[$this->username_column], t3lib_div::getIndpEnv('REMOTE_ADDR'), t3lib_div::getIndpEnv('REMOTE_HOST')), '', '', '', -1, '', $tempuser['uid']); } if ($this->writeDevLog && $activeLogin) { t3lib_div::devLog('User ' . $tempuser[$this->username_column] . ' logged in from ' . t3lib_div::getIndpEnv('REMOTE_ADDR') . ' (' . t3lib_div::getIndpEnv('REMOTE_HOST') . ')', 't3lib_userAuth', -1); } if ($this->writeDevLog && !$activeLogin) { t3lib_div::devLog('User ' . $tempuser[$this->username_column] . ' authenticated from ' . t3lib_div::getIndpEnv('REMOTE_ADDR') . ' (' . t3lib_div::getIndpEnv('REMOTE_HOST') . ')', 't3lib_userAuth', -1); } if ($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] == 3 && $this->user_table == 'be_users') { $requestStr = substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT'), strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir)); $backendScript = t3lib_BEfunc::getBackendScript(); if ($requestStr == $backendScript && t3lib_div::getIndpEnv('TYPO3_SSL')) { list(, $url) = explode('://', t3lib_div::getIndpEnv('TYPO3_SITE_URL'), 2); list($server, $address) = explode('/', $url, 2); if (intval($TYPO3_CONF_VARS['BE']['lockSSLPort'])) { $sslPortSuffix = ':' . intval($TYPO3_CONF_VARS['BE']['lockSSLPort']); $server = str_replace($sslPortSuffix, '', $server); // strip port from server } t3lib_utility_Http::redirect('http://' . $server . '/' . $address . TYPO3_mainDir . $backendScript); } } } elseif ($activeLogin || count($tempuserArr)) { $this->loginFailure = TRUE; if ($this->writeDevLog && !count($tempuserArr) && $activeLogin) { t3lib_div::devLog('Login failed: ' . t3lib_div::arrayToLogString($loginData), 't3lib_userAuth', 2); } if ($this->writeDevLog && count($tempuserArr)) { t3lib_div::devLog('Login failed: ' . t3lib_div::arrayToLogString($tempuser, array($this->userid_column, $this->username_column)), 't3lib_userAuth', 2); } } // If there were a login failure, check to see if a warning email should be sent: if ($this->loginFailure && $activeLogin) { if ($this->writeDevLog) { t3lib_div::devLog('Call checkLogFailures: ' . t3lib_div::arrayToLogString(array('warningEmail' => $this->warningEmail, 'warningPeriod' => $this->warningPeriod, 'warningMax' => $this->warningMax)), 't3lib_userAuth', -1); } $this->checkLogFailures($this->warningEmail, $this->warningPeriod, $this->warningMax); } }
/** * Redirect URL * * @return void */ function printContent() { t3lib_utility_Http::redirect($this->url); }
public function loginFormular() { $post = t3lib_div::_POST(); //t3lib_div::devlog("HE-Tools: loginFormular","tx_hetools_pi1",0,$post); $username = ''; $minChars = 8; $anmeldungOk = FALSE; if (!empty($post['login']) && !empty($post['benutzer']) && !empty($post['password'])) { $erg = $this->benutzerEinloggen($post['benutzer'], $post['password']); if (!$erg) { $out .= '<h3 class="error">Beim Login gab es einen Fehler.</h3>'; } else { $redirectPid = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_hetools_pi1.']['sb_online.']['redirect_pid']; if (empty($redirectPid)) { $redirectPid = $GLOBALS['TSFE']->id; } $typolink_conf = array('parameter' => $redirectPid, 'returnLast' => 'url'); $redirectUrl = $this->piBase->cObj->typolink('', $typolink_conf); //t3lib_utility_Debug::debugInPopUpWindow('loginOk'); t3lib_utility_Http::redirect($redirectUrl); exit; } } $name = $GLOBALS['TSFE']->fe_user->user['username']; if (strpos($name, self::$kuerzelGastuser) !== FALSE) { $name = substr($name, strlen(self::$kuerzelGastuser)); } if (!$anmeldungOk) { $id = $GLOBALS['TSFE']->id; $typolink_conf = array('parameter' => $id, 'returnLast' => 'url'); $formUrl = $this->piBase->cObj->typolink('', $typolink_conf); $out .= '<h1>Schon hier gewesen?<br />Anonymer Login</h1> <form class="login" action="' . $formUrl . '" method="POST"> <div class="row"> <label for="benutzer">Benutzername:</label> <input type="text" size="40" id="benutzer" name="benutzer" value="' . $username . '"> </div> <div class="row"> <label for="password1">Passwort (mindestens ' . $minChars . ' Zeichen):</label> <input type="password" size="40" id="password" name="password"> </div> <div class="row"> <input type="submit" name="login" value="Einloggen"> </div> </form> '; } return $out; }
public function PM_MainContentAfterHook($content, $piVars, &$pObj) { $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_hetools_pi1.']['powermail.']; if ($conf['pid'] == $GLOBALS['TSFE']->id) { if (is_array($conf['redirect_select_val.'])) { $fieldId = 'uid' . $conf['redirect_select_val.']['condition.']['field_id']; $fieldVal = $conf['redirect_select_val.']['condition.']['field_val']; $op = $conf['redirect_select_val.']['condition.']['compare_op']; switch ($op) { case 'equal': $redirect = $piVars[$fieldId] == $fieldVal; break; case 'unequal': $redirect = $piVars[$fieldId] != $fieldVal; break; default: $redirect = FALSE; } if ($redirect) { $id = $conf['redirect_select_val.']['redirect_page']; if (!empty($id)) { $conf = array('parameter' => $id, 'returnLast' => 'url'); $redirectUrl = $pObj->cObj->typoLink('', $conf); t3lib_utility_Http::redirect($redirectUrl); } } } } if ($piVars['mailID'] > 0 || $piVars['sendNow'] > 0) { return; } if ($conf['pid'] == $GLOBALS['TSFE']->id) { if (is_array($conf['redirect.']['condition.'])) { $redirectConditions = array(); $redirectConfig = $conf['redirect.']['condition.']; $redirectFieldsets = $redirectConfig['fieldsets.']; foreach ($redirectFieldsets as $cssClass => $data) { $cssClass = substr($cssClass, 0, strlen($cssClass) - 1); $conditions[$cssClass] = FALSE; $conditions = array(); foreach ($data as $name => $val) { switch ($name) { case 'count': $maxCount = $val; $conditions['maxCount'] = $val; break; case 'db_field': $conditions['db_field'] = $val; break; case 'conditions.': foreach ($val as $id => $conditionData) { $conditions['tests'][] = array('check_string' => $conditionData['check_string'], 'count' => $conditionData['count']); } break; case 'field_conditions.': foreach ($val as $id => $conditionData) { $conditions['tests'][] = array('check_string' => $conditionData['check_string'], 'count' => $conditionData['count']); } break; } } if (!empty($maxCount) && !empty($conditions)) { $anzahlEintraege = $this->anzahlEintraege($conditions, $conf['pid']); if ($anzahlEintraege >= $maxCount) { $redirectConditions[$cssClass] = TRUE; } } } if (!empty($redirectConditions)) { $boolOp = strtoupper(trim($redirectConfig['bool_op'])); $redirect = FALSE; if ($boolOp == 'AND') { $redirect = TRUE; foreach ($redirectConditions as $field => $val) { if (!$val) { $redirect = FALSE; } } } else { if ($boolOp == 'OR') { $redirect = FALSE; foreach ($redirectConditions as $field => $val) { if ($val) { $redirect = TRUE; } } } } if ($redirect) { $id = $conf['redirect.']['redirect_page']; if (!empty($id)) { $conf = array('parameter' => $id, 'returnLast' => 'url'); $redirectUrl = $pObj->cObj->typoLink('', $conf); t3lib_utility_Http::redirect($redirectUrl); } } } } if (is_array($conf['block_elements.'])) { $blockElementConfig = $conf['block_elements.']; foreach ($blockElementConfig as $cssClass => $data) { $cssClass = substr($cssClass, 0, strlen($cssClass) - 1); $conditions = array(); foreach ($data as $name => $val) { switch ($name) { case 'type': $fieldType = $val; break; case 'count': $maxCount = $val; break; case 'hinweis': $hinweis = $val; break; case 'db_field': $conditions['db_field'] = $val; break; case 'conditions.': foreach ($val as $id => $conditionData) { $conditions['tests'][] = array('check_string' => $conditionData['check_string'], 'count' => $conditionData['count']); } $hinweis = $val; break; } } $anzahlEintraege = $this->anzahlEintraege($conditions, $conf['pid']); if ($anzahlEintraege >= $maxCount) { $this->blockElem($cssClass, $fieldType, $pObj, $hinweis); } } } if (is_array($conf['mandatory_dependencys.'])) { $additionalJs = ' <script type="text/javascript"> $(document).ready(function() { '; foreach ($conf['mandatory_dependencys.'] as $mandatoryData) { $fieldId = $mandatoryData['mandatory_field']; $dependentFieldId = $mandatoryData['dependent_field']; $dependendValue = $mandatoryData['dependent_value']; $dependendValueList = explode(',', $dependendValue); $condition1 = 'dependentVal!="' . implode('" && dependentVal!="', $dependendValueList) . '"'; $condition2 = 'dependentVal=="' . implode('" || dependentVal=="', $dependendValueList) . '"'; $additionalJs .= ' var dependentVal = $("#uid' . $dependentFieldId . '").val(); if (' . $condition1 . ') { $("#uid' . $fieldId . '").removeAttr("required"); } $("#uid' . $dependentFieldId . '").change(function() { var dependentVal = $("#uid' . $dependentFieldId . '").val(); if (' . $condition2 . ') { $("#uid' . $fieldId . '").attr("required","required"); } else { $("#uid' . $fieldId . '").removeAttr("required"); } }) '; } $additionalJs .= ' }); </script> '; $pObj->content = $pObj->content . $additionalJs; } } if (!empty($conf['replace_uid'])) { $uid = $conf['receiverlist']; $where = 'deleted=0 AND uid=' . $uid; $data = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('flexform', ' tx_powermail_fields', $where); $GLOBALS['TYPO3_DB']->sql_free_result($result); // preg_match('>|(.*?)|'.$uid,$data['flexform'], $thementitel); $teile = explode("\n", $data['flexform']); foreach ($teile as $value) { $splitarray = explode("|", $value); if (count($splitarray) == 2) { if (trim($splitarray[1]) == $sessiondata['uid' . $uid]) { $wert = $splitarray[0]; } } } /* $powermail->sessiondata['uid' . $uid] = $wert; $powermail->sessionfields['uid' . $uid] = $wert; $powermail->cObj->data = $powermail->cObj->substituteMarkerInObject( $powermail->cObj->data, array('###THEMA###'=>$wert) ); */ } }
/** * Will find the page carrying the domain record matching the input domain. * Might exit after sending a redirect-header IF a found domain record instructs to do so. * * @param string Domain name to search for. Eg. "www.typo3.com". Typical the HTTP_HOST value. * @param string Path for the current script in domain. Eg. "/somedir/subdir". Typ. supplied by t3lib_div::getIndpEnv('SCRIPT_NAME') * @param string Request URI: Used to get parameters from if they should be appended. Typ. supplied by t3lib_div::getIndpEnv('REQUEST_URI') * @return mixed If found, returns integer with page UID where found. Otherwise blank. Might exit if location-header is sent, see description. * @see tslib_fe::findDomainRecord() */ function getDomainStartPage($domain, $path = '', $request_uri = '') { $domain = explode(':', $domain); $domain = strtolower(preg_replace('/\\.$/', '', $domain[0])); // Removing extra trailing slashes $path = trim(preg_replace('/\\/[^\\/]*$/', '', $path)); // Appending to domain string $domain .= $path; $domain = preg_replace('/\\/*$/', '', $domain); $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pages.uid,sys_domain.redirectTo,sys_domain.redirectHttpStatusCode,sys_domain.prepend_params', 'pages,sys_domain', 'pages.uid=sys_domain.pid AND sys_domain.hidden=0 AND (sys_domain.domainName=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($domain, 'sys_domain') . ' OR sys_domain.domainName=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($domain . '/', 'sys_domain') . ') ' . $this->where_hid_del . $this->where_groupAccess, '', '', 1); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); $GLOBALS['TYPO3_DB']->sql_free_result($res); if ($row) { if ($row['redirectTo']) { $redirectUrl = $row['redirectTo']; if ($row['prepend_params']) { $redirectUrl = rtrim($redirectUrl, '/'); $prependStr = ltrim(substr($request_uri, strlen($path)), '/'); $redirectUrl .= '/' . $prependStr; } $statusCode = intval($row['redirectHttpStatusCode']); if ($statusCode && defined('t3lib_utility_Http::HTTP_STATUS_' . $statusCode)) { t3lib_utility_Http::redirect($redirectUrl, constant('t3lib_utility_Http::HTTP_STATUS_' . $statusCode)); } else { t3lib_utility_Http::redirect($redirectUrl, 't3lib_utility_Http::HTTP_STATUS_301'); } exit; } else { return $row['uid']; } } }
/** * Checking, if we should perform some sort of redirection OR closing of windows. * * @return void */ function checkRedirect() { global $BE_USER, $TBE_TEMPLATE; // Do redirect: // If a user is logged in AND a) if either the login is just done (commandLI) or b) a loginRefresh is done or c) the interface-selector is NOT enabled (If it is on the other hand, it should not just load an interface, because people has to choose then...) if ($BE_USER->user['uid'] && ($this->commandLI || $this->loginRefresh || !$this->interfaceSelector)) { // If no cookie has been set previously we tell people that this is a problem. This assumes that a cookie-setting script (like this one) has been hit at least once prior to this instance. if (!$_COOKIE[$BE_USER->name]) { if ($this->commandLI == 'setCookie') { // we tried it a second time but still no cookie // 26/4 2005: This does not work anymore, because the saving of challenge values in $_SESSION means the system will act as if the password was wrong. t3lib_BEfunc::typo3PrintError('Login-error', "Yeah, that's a classic. No cookies, no TYPO3.<br /><br />Please accept cookies from TYPO3 - otherwise you'll not be able to use the system.", 0); exit; } else { // try it once again - that might be needed for auto login $this->redirectToURL = 'index.php?commandLI=setCookie'; } } if ($redirectToURL = (string) $BE_USER->getTSConfigVal('auth.BE.redirectToURL')) { $this->redirectToURL = $redirectToURL; $this->GPinterface = ''; } // store interface $BE_USER->uc['interfaceSetup'] = $this->GPinterface; $BE_USER->writeUC(); // Based on specific setting of interface we set the redirect script: switch ($this->GPinterface) { case 'backend': case 'backend_old': $this->redirectToURL = 'backend.php'; break; case 'frontend': $this->redirectToURL = '../'; break; } // If there is a redirect URL AND if loginRefresh is not set... if (!$this->loginRefresh) { t3lib_utility_Http::redirect($this->redirectToURL); } else { $TBE_TEMPLATE->JScode .= $TBE_TEMPLATE->wrapScriptTags(' if (parent.opener && (parent.opener.busy || parent.opener.TYPO3.loginRefresh)) { if (parent.opener.TYPO3.loginRefresh) { parent.opener.TYPO3.loginRefresh.startTimer(); } else { parent.opener.busy.loginRefreshed(); } parent.close(); } '); } } elseif (!$BE_USER->user['uid'] && $this->commandLI) { sleep(5); // Wrong password, wait for 5 seconds } }
if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL) { if (!t3lib_extMgm::isLoaded('install')) { die('Install Tool is not loaded as an extension.<br />You must add the key "install" to the list of installed extensions in typo3conf/localconf.php, $TYPO3_CONF_VARS[\'EXT\'][\'extList\'].'); } require_once t3lib_extMgm::extPath('install') . 'mod/class.tx_install.php'; $install_check = t3lib_div::makeInstance('tx_install'); $install_check->allowUpdateLocalConf = 1; $install_check->init(); exit; } // ************************* // Connect to the database // ************************* // Redirect to install tool if database host and database are not defined if (!TYPO3_db_host && !TYPO3_db) { t3lib_utility_Http::redirect('install/index.php?mode=123&step=1&password=joh316'); } elseif ($TYPO3_DB->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { if (!TYPO3_db) { throw new RuntimeException('Database Error: No database selected', time()); } elseif (!$TYPO3_DB->sql_select_db(TYPO3_db)) { throw new RuntimeException('Database Error: Cannot connect to the current database, "' . TYPO3_db . '"', time()); } } else { throw new RuntimeException('Database Error: The current username, password or host was not accepted when the connection to the database was attempted to be established!', time()); } // ******************************* // Checks for proper browser // ******************************* if (!$CLIENT['BROWSER'] && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI)) { throw new RuntimeException('Browser Error: Your browser version looks incompatible with this TYPO3 version!', time()); }
/** * Redirects to the document pointed to by $currentDocFromHandlerMD5 OR $retUrl (depending on some internal calculations). * Most likely you will get a header-location redirect from this function. * * @param string Pointer to the document in the docHandler array * @param string Alternative/Default retUrl * @return void */ function setDocument($currentDocFromHandlerMD5 = '', $retUrl = 'alt_doc_nodoc.php') { if (!t3lib_extMgm::isLoaded('cms') && !strcmp($retUrl, 'alt_doc_nodoc.php')) { return; } if (!$this->modTSconfig['properties']['disableDocSelector'] && is_array($this->docHandler) && count($this->docHandler)) { if (isset($this->docHandler[$currentDocFromHandlerMD5])) { $setupArr = $this->docHandler[$currentDocFromHandlerMD5]; } else { reset($this->docHandler); $setupArr = current($this->docHandler); } if ($setupArr[2]) { $sParts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI')); $retUrl = $sParts['path'] . '?' . $setupArr[2] . '&returnUrl=' . rawurlencode($retUrl); } } t3lib_utility_Http::redirect($retUrl); }
/** * Switches to a given user (SU-mode) and then redirects to the start page of the backend to refresh the navigation etc. * * @param array BE-user record that will be switched to * @return void */ function switchUser($switchUser) { $uRec = t3lib_BEfunc::getRecord('be_users', $switchUser); if (is_array($uRec) && $GLOBALS['BE_USER']->isAdmin()) { $updateData['ses_userid'] = $uRec['uid']; // user switchback if (t3lib_div::_GP('switchBackUser')) { $updateData['ses_backuserid'] = intval($GLOBALS['BE_USER']->user['uid']); } $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_sessions', 'ses_id=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->id, 'be_sessions') . ' AND ses_name=\'be_typo_user\' AND ses_userid=' . intval($GLOBALS['BE_USER']->user['uid']), $updateData); $redirectUrl = $GLOBALS['BACK_PATH'] . 'index.php' . ($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces'] ? '' : '?commandLI=1'); t3lib_utility_Http::redirect($redirectUrl); } }
/** * Check if user is logged in and if so, call ->fetchGroupData() to load group information and access lists of all kind, further check IP, set the ->uc array and send login-notification email if required. * If no user is logged in the default behaviour is to exit with an error message, but this will happen ONLY if the constant TYPO3_PROCEED_IF_NO_USER is set true. * This function is called right after ->start() in fx. init.php * * @return void */ function backendCheckLogin() { if (!$this->user['uid']) { if (!defined('TYPO3_PROCEED_IF_NO_USER') || !TYPO3_PROCEED_IF_NO_USER) { t3lib_utility_Http::redirect($GLOBALS['BACK_PATH']); } } else { // ...and if that's the case, call these functions $this->fetchGroupData(); // The groups are fetched and ready for permission checking in this initialization. Tables.php must be read before this because stuff like the modules has impact in this if ($this->checkLockToIP()) { if ($this->isUserAllowedToLogin()) { $this->backendSetUC(); // Setting the UC array. It's needed with fetchGroupData first, due to default/overriding of values. $this->emailAtLogin(); // email at login - if option set. } else { t3lib_BEfunc::typo3PrintError('Login-error', 'TYPO3 is in maintenance mode at the moment. Only administrators are allowed access.', 0); exit; } } else { t3lib_BEfunc::typo3PrintError('Login-error', 'IP locking prevented you from being authorized. Can\'t proceed, sorry.', 0); exit; } } }
/** * Sends request to the OpenID server to authenticate the user with the * given ID. This function is almost identical to the example from the PHP * OpenID library. Due to the OpenID specification we cannot do a slient login. * Sometimes we have to redirect to the OpenID provider web site so that * user can enter his password there. In this case we will redirect and provide * a return adress to the special script inside this directory, which will * handle the result appropriately. * * This function does not return on success. If it returns, it means something * went totally wrong with OpenID. * * @return void */ protected function sendOpenIDRequest() { $this->includePHPOpenIDLibrary(); $openIDIdentifier = $this->loginData['uname']; // Initialize OpenID client system, get the consumer $openIDConsumer = $this->getOpenIDConsumer(); // Begin the OpenID authentication process $authenticationRequest = $openIDConsumer->begin($openIDIdentifier); if (!$authenticationRequest) { // Not a valid OpenID. Since it can be some other ID, we just return // and let other service handle it. $this->writeLog('Could not create authentication request for OpenID identifier \'%s\'', $openIDIdentifier); return; } // Redirect the user to the OpenID server for authentication. // Store the token for this authentication so we can verify the // response. // For OpenID version 1, we *should* send a redirect. For OpenID version 2, // we should use a Javascript form to send a POST request to the server. $returnURL = $this->getReturnURL(); $trustedRoot = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); if ($authenticationRequest->shouldSendRedirect()) { $redirectURL = $authenticationRequest->redirectURL($trustedRoot, $returnURL); // If the redirect URL can't be built, return. We can only return. if (Auth_OpenID::isFailure($redirectURL)) { $this->writeLog('Authentication request could not create redirect URL for OpenID identifier \'%s\'', $openIDIdentifier); return; } // Send redirect. We use 303 code because it allows to redirect POST // requests without resending the form. This is exactly what we need here. // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4 @ob_end_clean(); t3lib_utility_Http::redirect($redirectURL, t3lib_utility_Http::HTTP_STATUS_303); } else { $formHtml = $authenticationRequest->htmlMarkup($trustedRoot, $returnURL, false, array('id' => 'openid_message')); // Display an error if the form markup couldn't be generated; // otherwise, render the HTML. if (Auth_OpenID::isFailure($formHtml)) { // Form markup cannot be generated $this->writeLog('Could not create form markup for OpenID identifier \'%s\'', $openIDIdentifier); return; } else { @ob_end_clean(); echo $formHtml; } } // If we reached this point, we must not return! exit; }
* http://www.gnu.org/copyleft/gpl.html. * A copy is found in the textfile GPL.txt and important notices to the license * from the author is found in LICENSE.txt distributed with these scripts. * * * This script is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ /** * Apache-trailing-slash workaround * * Meant to solve the trailing slash problem with Apache: * * Make a mod_rewrite rule like this: * RewriteRule ^typo3$ typo3/index_re.php * ... and this document will redirect to the right script. * * $Id$ * * @author Kasper Skaarhoj <*****@*****.**> * @package TYPO3 * @subpackage core */ define('TYPO3_PROCEED_IF_NO_USER', 1); require 'init.php'; t3lib_utility_Http::redirect(t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR') . 'index.php');
/** * The main method of the plugin * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return string The content that is displayed on the website */ public function main($content, $conf) { // Loading TypoScript array into object variable: $this->conf = $conf; $this->uploadDir = 'uploads/tx_felogin/'; // Loading default pivars $this->pi_setPiVarDefaults(); // Loading language-labels $this->pi_loadLL(); // Init FlexForm configuration for plugin: $this->pi_initPIflexForm(); $this->mergeflexFormValuesIntoConf(); // Get storage PIDs: if ($this->conf['storagePid']) { if (intval($this->conf['recursive'])) { $this->spid = $this->pi_getPidList($this->conf['storagePid'], intval($this->conf['recursive'])); } else { $this->spid = $this->conf['storagePid']; } } else { $pids = $GLOBALS['TSFE']->getStorageSiterootPids(); $this->spid = $pids['_STORAGE_PID']; } // GPvars: $this->logintype = t3lib_div::_GP('logintype'); $this->referer = $this->validateRedirectUrl(t3lib_div::_GP('referer')); $this->noRedirect = $this->piVars['noredirect'] || $this->conf['redirectDisable']; // if config.typolinkLinkAccessRestrictedPages is set, the var is return_url $returnUrl = t3lib_div::_GP('return_url'); if ($returnUrl) { $this->redirectUrl = $returnUrl; } else { $this->redirectUrl = t3lib_div::_GP('redirect_url'); } $this->redirectUrl = $this->validateRedirectUrl($this->redirectUrl); // Get Template $templateFile = $this->conf['templateFile'] ? $this->conf['templateFile'] : 'EXT:felogin/template.html'; $this->template = $this->cObj->fileResource($templateFile); // Is user logged in? $this->userIsLoggedIn = $GLOBALS['TSFE']->loginUser; // Redirect if ($this->conf['redirectMode'] && !$this->conf['redirectDisable'] && !$this->noRedirect) { $redirectUrl = $this->processRedirect(); if (count($redirectUrl)) { //$this->redirectUrl = $this->conf['redirectFirstMethod'] ? array_shift($redirectUrl) : array_pop($redirectUrl); $this->redirectUrl = $redirectUrl[0]; } else { $this->redirectUrl = ''; } $tmpredirectUrl = $this->redirectUrl; } // What to display $content = ''; if ($this->piVars['forgot']) { $content .= $this->showForgot(); } elseif ($this->piVars['forgothash']) { $content .= $this->changePassword(); } else { if ($this->userIsLoggedIn && !$this->logintype) { $content .= $this->showLogout(); } else { $content .= $this->showLogin(); } } $this->redirectUrl = $tmpredirectUrl; // Process the redirect if (($this->logintype === 'login' || $this->logintype === 'logout') && $this->redirectUrl && !$this->noRedirect) { if (!$GLOBALS['TSFE']->fe_user->cookieId) { $content .= $this->cObj->stdWrap($this->pi_getLL('cookie_warning', '', 1), $this->conf['cookieWarning_stdWrap.']); } else { t3lib_utility_Http::redirect($this->redirectUrl); } } // Adds hook for processing of extra item markers / special if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['postProcContent']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['postProcContent'])) { $_params = array('content' => $content); foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['postProcContent'] as $_funcRef) { $content = t3lib_div::callUserFunction($_funcRef, $_params, $this); } } return $this->conf['wrapContentInBaseClass'] ? $this->pi_wrapInBaseClass($content) : $content; }
/** * Will get and return the configuration code string * Will also save (and possibly redirect/exit) the content if a save button has been pressed * * @param array Current parent record row (passed by value!) * @return array Configuration Array * @access private */ function getConfigCode(&$row) { // If some data has been submitted, then construct if (isset($this->FORMCFG['c'])) { // Process incoming: $this->changeFunc(); // Convert to string (either line based or XML): if ($this->xmlStorage) { // Convert the input array to XML: $bodyText = t3lib_div::array2xml_cs($this->FORMCFG['c'], 'T3FormWizard'); // Setting cfgArr directly from the input: $cfgArr = $this->FORMCFG['c']; } else { // Convert the input array to a string of configuration code: $bodyText = $this->cfgArray2CfgString($this->FORMCFG['c']); // Create cfgArr from the string based configuration - that way it is cleaned up and any incompatibilities will be removed! $cfgArr = $this->cfgString2CfgArray($bodyText); } // If a save button has been pressed, then save the new field content: if ($_POST['savedok_x'] || $_POST['saveandclosedok_x']) { // Make TCEmain object: $tce = t3lib_div::makeInstance('t3lib_TCEmain'); $tce->stripslashes_values = 0; // Put content into the data array: $data = array(); $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $bodyText; if ($this->special == 'formtype_mail') { $data[$this->P['table']][$this->P['uid']]['subheader'] = $this->FORMCFG['recipient']; } // Perform the update: $tce->start($data, array()); $tce->process_datamap(); // Re-load the record content: $row = t3lib_BEfunc::getRecord($this->P['table'], $this->P['uid']); // If the save/close button was pressed, then redirect the screen: if ($_POST['saveandclosedok_x']) { t3lib_utility_Http::redirect($this->P['returnUrl']); } } } else { // If nothing has been submitted, load the $bodyText variable from the selected database row: if ($this->xmlStorage) { $cfgArr = t3lib_div::xml2array($row[$this->P['field']]); } else { // Regular linebased form configuration: $cfgArr = $this->cfgString2CfgArray($row[$this->P['field']]); } $cfgArr = is_array($cfgArr) ? $cfgArr : array(); } // Return configuration code: return $cfgArr; }
/** * Creates module content. * * @return void */ function main() { global $LANG; // see what we have to do and get parameters (call before processing data!!!) $this->getModuleParameters(); $hasAccess = $GLOBALS['BE_USER']->isAdmin() || 0 != ($GLOBALS['BE_USER']->groupData['workspace_perms'] & 4) || $this->isEditAction && $this->checkWorkspaceAccess(); if (!$hasAccess) { $title = $this->getTitle(); $this->content .= $this->doc->startPage($title); $this->content .= $this->doc->header($title); $this->content .= $this->doc->spacer(5); $this->content .= $LANG->getLL($this->isEditAction ? 'edit_workspace_no_permission' : 'create_workspace_no_permission'); $this->content .= $this->doc->spacer(5); $goBack = $GLOBALS['LANG']->getLL('edit_workspace_go_back'); $this->content .= t3lib_iconWorks::getSpriteIcon('actions-view-go-back') . '<a href="javascript:history.back()" title="' . $goBack . '">' . $goBack . '</a>'; $this->content .= $this->doc->endPage(); return; } // process submission (this may override action and workspace ID!) if (t3lib_div::_GP('workspace_form_submited')) { $this->processData(); // if 'Save&Close' was pressed, redirect to main module script if (t3lib_div::_GP('_saveandclosedok_x')) { // `n` below is to prevent caching t3lib_utility_Http::redirect('index.php?n=' . uniqid('')); } } $this->initTCEForms(); // // start page // $this->content .= $this->doc->header($this->getTitle()); $this->content .= $this->doc->spacer(5); // // page content // $this->content .= $this->tceforms->printNeededJSFunctions_top(); $this->content .= $this->buildForm(); $this->content .= $this->tceforms->printNeededJSFunctions(); // Setting up the buttons and markers for docheader $docHeaderButtons = $this->getButtons(); // $markers['CSH'] = $docHeaderButtons['csh']; $markers['CONTENT'] = $this->content; // Build the <body> for the module $this->content = $this->doc->startPage($this->getTitle()); $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); $this->content .= $this->doc->endPage(); $this->content = $this->doc->insertStylesAndJS($this->content); }
/** * Redirecting the user after the processing has been done. * Might also display error messages directly, if any. * * @return void */ public function finish() { // Prints errors, if there are any $this->fileProcessor->printLogErrorMessages($this->redirect); t3lib_BEfunc::setUpdateSignal('updateFolderTree'); if ($this->redirect) { t3lib_utility_Http::redirect($this->redirect); } }
/** * Displays the "single view" of a news article. Is also used when displaying single news records with the "insert records" content element. * * @return string html-code for the "single view" */ function displaySingle() { $lConf = $this->conf['displaySingle.']; $selectConf = array(); $selectConf['selectFields'] = '*'; $selectConf['fromTable'] = 'tt_news'; $selectConf['where'] = 'tt_news.uid=' . $this->tt_news_uid; $selectConf['where'] .= $this->enableFields; // function Hook for processing the selectConf array if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['sViewSelectConfHook'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['sViewSelectConfHook'] as $_classRef) { $_procObj =& t3lib_div::getUserObj($_classRef); $selectConf = $_procObj->processSViewSelectConfHook($this, $selectConf); } } $res = $this->db->exec_SELECTquery($selectConf['selectFields'], $selectConf['fromTable'], $selectConf['where'], $selectConf['groupBy'], $selectConf['orderBy'], $selectConf['limit']); $row = $this->db->sql_fetch_assoc($res); $this->db->sql_free_result($res); // First get workspace/version overlay and fix workspace pid: if ($this->versioningEnabled) { $this->tsfe->sys_page->versionOL('tt_news', $row); $this->tsfe->sys_page->fixVersioningPid('tt_news', $row); } // Then get localization of record: // (if the content language is not the default language) if ($this->tsfe->sys_language_content) { $OLmode = $this->sys_language_mode == 'strict' ? 'hideNonTranslated' : ''; $row = $this->tsfe->sys_page->getRecordOverlay('tt_news', $row, $this->tsfe->sys_language_content, $OLmode); } // Register displayed news item globally: $GLOBALS['T3_VAR']['displayedNews'][] = $row['uid']; if (is_array($row) && ($row['pid'] > 0 || $this->vPrev)) { // never display versions of a news record (having pid=-1) for normal website users // If type is 1 or 2 (internal/external link), redirect to accordant page: if (is_array($row) && t3lib_div::inList('1,2', $row['type'])) { $redirectUrl = $this->local_cObj->getTypoLink_URL($row['type'] == 1 ? $row['page'] : $row['ext_url']); t3lib_utility_Http::redirect($redirectUrl); } $item = FALSE; // Get the subpart code if ($this->conf['displayCurrentRecord']) { $item = trim($this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_SINGLE_RECORDINSERT###'), $row)); } if (!$item) { $item = $this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_' . $this->theCode . '###'), $row); } $renderMarkers = $this->getMarkers($item); $this->renderMarkers = array_unique($renderMarkers); // reset marker array $wrappedSubpartArray = array(); // build the backToList link if ($this->conf['useHRDates']) { $wrappedSubpartArray['###LINK_ITEM###'] = explode('|', $this->pi_linkTP_keepPIvars('|', array('tt_news' => null, 'backPid' => null, $this->config['singleViewPointerName'] => null, 'pS' => null, 'pL' => null), $this->allowCaching, $this->conf['dontUseBackPid'] ? 1 : 0, $this->config['backPid'])); } else { $wrappedSubpartArray['###LINK_ITEM###'] = explode('|', $this->pi_linkTP_keepPIvars('|', array('tt_news' => null, 'backPid' => null, $this->config['singleViewPointerName'] => null), $this->allowCaching, $this->conf['dontUseBackPid'] ? 1 : 0, $this->config['backPid'])); } // set the title of the single view page to the title of the news record if ($this->conf['substitutePagetitle']) { /** * TODO: 05.05.2009 * pagetitle stdWrap */ $this->tsfe->page['title'] = $row['title']; // set pagetitle for indexed search to news title $this->tsfe->indexedDocTitle = $row['title']; } if ($lConf['catOrderBy']) { $this->config['catOrderBy'] = $lConf['catOrderBy']; } $this->categories = array(); $this->categories[$row['uid']] = $this->getCategories($row['uid']); $markerArray = $this->getItemMarkerArray($row, $lConf, 'displaySingle'); // Substitute $content = $this->cObj->substituteMarkerArrayCached($item, $markerArray, array(), $wrappedSubpartArray); } elseif ($this->sys_language_mode == 'strict' && $this->tt_news_uid && $this->tsfe->sys_language_content) { // not existing translation $noTranslMsg = $this->local_cObj->stdWrap($this->pi_getLL('noTranslMsg'), $this->conf['noNewsIdMsg_stdWrap.']); $content = $noTranslMsg; } elseif ($row['pid'] < 0) { // a non-public version of a record was requested $nonPlublicVersion = $this->local_cObj->stdWrap($this->pi_getLL('nonPlublicVersionMsg'), $this->conf['nonPlublicVersionMsg_stdWrap.']); $content = $nonPlublicVersion; } else { // if singleview is shown with no tt_news uid given from GETvars (&tx_ttnews[tt_news]=) an error message is displayed. $noNewsIdMsg = $this->local_cObj->stdWrap($this->pi_getLL('noNewsIdMsg'), $this->conf['noNewsIdMsg_stdWrap.']); $content = $noNewsIdMsg; } if ($this->debugTimes) { $this->hObj->getParsetime(__METHOD__); } return $content; }
/** * The main processing method if this class * * @return string Information of the template status or the taken actions as HTML string */ function main() { global $SOBE, $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS; global $tmpl, $tplRow, $theConstants; $edit = $this->pObj->edit; $e = $this->pObj->e; t3lib_div::loadTCA('sys_template'); // ************************** // Checking for more than one template an if, set a menu... // ************************** $manyTemplatesMenu = $this->pObj->templateMenu(); $template_uid = 0; if ($manyTemplatesMenu) { $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage']; } // ************************** // Initialize // ************************** $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid); // initialize if ($existTemplate) { $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']; } // ************************** // Create extension template // ************************** $newId = $this->pObj->createTemplate($this->pObj->id, $saveId); if ($newId) { // switch to new template t3lib_utility_Http::redirect('index.php?id=' . $this->pObj->id . '&SET[templatesOnPage]=' . $newId); } if ($existTemplate) { // Update template ? $POST = t3lib_div::_POST(); if ($POST['submit'] || t3lib_div::testInt($POST['submit_x']) && t3lib_div::testInt($POST['submit_y']) || $POST['saveclose'] || t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y'])) { // Set the data to be saved $recData = array(); $alternativeFileName = array(); $resList = $tplRow['resources']; $tmp_upload_name = ''; $tmp_newresource_name = ''; // Set this to blank if (is_array($POST['data'])) { foreach ($POST['data'] as $field => $val) { switch ($field) { case 'constants': case 'config': case 'title': case 'sitetitle': case 'description': $recData['sys_template'][$saveId][$field] = $val; break; case 'resources': $tmp_upload_name = t3lib_div::upload_to_tempfile($_FILES['resources']['tmp_name']); // If there is an uploaded file, move it for the sake of safe_mode. if ($tmp_upload_name) { if ($tmp_upload_name != 'none' && $_FILES['resources']['name']) { $alternativeFileName[$tmp_upload_name] = trim($_FILES['resources']['name']); $resList = $tmp_upload_name . ',' . $resList; } } break; case 'new_resource': $newName = trim(t3lib_div::_GP('new_resource')); if ($newName) { $newName .= '.' . t3lib_div::_GP('new_resource_ext'); $tmp_newresource_name = t3lib_div::tempnam('new_resource_'); $alternativeFileName[$tmp_newresource_name] = $newName; $resList = $tmp_newresource_name . ',' . $resList; } break; case 'makecopy_resource': if (is_array($val)) { $resList = ',' . $resList . ','; foreach ($val as $k => $file) { $tmp_name = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $file; $resList = $tmp_name . ',' . $resList; } } break; case 'remove_resource': if (is_array($val)) { $resList = ',' . $resList . ','; foreach ($val as $k => $file) { $resList = str_replace(',' . $file . ',', ',', $resList); } } break; case 'totop_resource': if (is_array($val)) { $resList = ',' . $resList . ','; foreach ($val as $k => $file) { $resList = str_replace(',' . $file . ',', ',', $resList); $resList = ',' . $file . $resList; } } break; } } } $resList = implode(',', t3lib_div::trimExplode(',', $resList, 1)); if (strcmp($resList, $tplRow['resources'])) { $recData['sys_template'][$saveId]['resources'] = $resList; } if (count($recData)) { // Create new tce-object $tce = t3lib_div::makeInstance('t3lib_TCEmain'); $tce->stripslashes_values = 0; $tce->alternativeFileName = $alternativeFileName; // Initialize $tce->start($recData, array()); // Saved the stuff $tce->process_datamap(); // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php) $tce->clear_cacheCmd('all'); // tce were processed successfully $this->tce_processed = true; // re-read the template ... $this->initialize_editor($this->pObj->id, $template_uid); } // Unlink any uploaded/new temp files there was: t3lib_div::unlink_tempfile($tmp_upload_name); t3lib_div::unlink_tempfile($tmp_newresource_name); // If files has been edited: if (is_array($edit)) { if ($edit['filename'] && $tplRow['resources'] && t3lib_div::inList($tplRow['resources'], $edit['filename'])) { // Check if there are resources, and that the file is in the resourcelist. $path = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $edit['filename']; $fI = t3lib_div::split_fileref($edit['filename']); if (@is_file($path) && t3lib_div::getFileAbsFileName($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) { // checks that have already been done.. Just to make sure // @TODO: Check if the hardcorded value already has a config member, otherwise create one if (filesize($path) < 30720) { // checks that have already been done.. Just to make sure t3lib_div::writeFile($path, $edit['file']); $theOutput .= $this->pObj->doc->spacer(10); $theOutput .= $this->pObj->doc->section('<font color=red>' . $GLOBALS['LANG']->getLL('fileChanged') . '</font>', sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']), 0, 0, 0, 1); // Clear cache - the file has probably affected the template setup // @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible! $tce = t3lib_div::makeInstance('t3lib_TCEmain'); $tce->stripslashes_values = 0; $tce->start(array(), array()); $tce->clear_cacheCmd('all'); } } } } } // hook Post updating template/TCE processing if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) { $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook']; if (is_array($postTCEProcessingHook)) { $hookParameters = array('POST' => $POST, 'tce' => $tce); foreach ($postTCEProcessingHook as $hookFunction) { t3lib_div::callUserFunction($hookFunction, $hookParameters, $this); } } } $theOutput .= $this->pObj->doc->spacer(5); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateInformation'), t3lib_iconWorks::getSpriteIconForRecord('sys_template', $tplRow) . '<strong>' . htmlspecialchars($tplRow['title']) . '</strong>' . htmlspecialchars(trim($tplRow['sitetitle']) ? ' - (' . $tplRow['sitetitle'] . ')' : ''), 0, 1); if ($manyTemplatesMenu) { $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu); $theOutput .= $this->pObj->doc->divider(5); } #$numberOfRows= t3lib_div::intInRange($this->pObj->MOD_SETTINGS["ts_template_editor_TArows"],0,150); #if (!$numberOfRows) $numberOfRows = 35; // If abort pressed, nothing should be edited: if ($POST['abort'] || t3lib_div::testInt($POST['abort_x']) && t3lib_div::testInt($POST['abort_y']) || $POST['saveclose'] || t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y'])) { unset($e); } if ($e['title']) { $outCode = '<input type="Text" name="data[title]" value="' . htmlspecialchars($tplRow['title']) . '"' . $this->pObj->doc->formWidth() . '>'; $outCode .= '<input type="Hidden" name="e[title]" value="1">'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('title'), $outCode); } if ($e['sitetitle']) { $outCode = '<input type="Text" name="data[sitetitle]" value="' . htmlspecialchars($tplRow['sitetitle']) . '"' . $this->pObj->doc->formWidth() . '>'; $outCode .= '<input type="Hidden" name="e[sitetitle]" value="1">'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('sitetitle'), $outCode); } if ($e['description']) { $outCode = '<textarea name="data[description]" rows="5" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, '', '') . '>' . t3lib_div::formatForTextarea($tplRow['description']) . '</textarea>'; $outCode .= '<input type="Hidden" name="e[description]" value="1">'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('description'), $outCode); } if ($e['resources']) { // Upload $outCode = '<input type="File" name="resources"' . $this->pObj->doc->formWidth() . ' size="50">'; $outCode .= '<input type="Hidden" name="data[resources]" value="1">'; $outCode .= '<input type="Hidden" name="e[resources]" value="1">'; $outCode .= '<BR>' . $GLOBALS['LANG']->getLL('allowedExtensions') . ' <strong>' . $TCA['sys_template']['columns']['resources']['config']['allowed'] . '</strong>'; $outCode .= '<BR>' . $GLOBALS['LANG']->getLL('maxFilesize') . ' <strong>' . t3lib_div::formatSize($TCA['sys_template']['columns']['resources']['config']['max_size'] * 1024) . '</strong>'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('uploadResource'), $outCode); // New $opt = explode(',', $this->pObj->textExtensions); $optTags = ''; foreach ($opt as $extVal) { $optTags .= '<option value="' . $extVal . '">.' . $extVal . '</option>'; } $outCode = '<input type="text" name="new_resource"' . $this->pObj->doc->formWidth(20) . '> <select name="new_resource_ext">' . $optTags . '</select>'; $outCode .= '<input type="Hidden" name="data[new_resource]" value="1">'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('newTextResource'), $outCode); // Make copy $rL = $this->resourceListForCopy($this->pObj->id, $template_uid); if ($rL) { $theOutput .= $this->pObj->doc->spacer(20); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('copyResource'), $rL); } // Update resource list $rL = $this->procesResources($tplRow['resources'], 1); if ($rL) { $theOutput .= $this->pObj->doc->spacer(20); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('updateResourceList'), $rL); } } if ($e['constants']) { $outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($tplRow['constants']) . '</textarea>'; $outCode .= '<input type="Hidden" name="e[constants]" value="1">'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants'), ''); $theOutput .= $this->pObj->doc->sectionEnd() . $outCode; } if ($e['file']) { $path = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $e[file]; $fI = t3lib_div::split_fileref($e[file]); if (@is_file($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) { if (filesize($path) < $TCA['sys_template']['columns']['resources']['config']['max_size'] * 1024) { $fileContent = t3lib_div::getUrl($path); $outCode = $GLOBALS['LANG']->getLL('file') . ' <strong>' . $e[file] . '</strong><BR>'; $outCode .= '<textarea name="edit[file]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($fileContent) . '</textarea>'; $outCode .= '<input type="Hidden" name="edit[filename]" value="' . $e[file] . '">'; $outCode .= '<input type="Hidden" name="e[file]" value="' . htmlspecialchars($e[file]) . '">'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editResource'), ''); $theOutput .= $this->pObj->doc->sectionEnd() . $outCode; } else { $theOutput .= $this->pObj->doc->spacer(15); $fileToBig = sprintf($GLOBALS['LANG']->getLL('filesizeExceeded'), $TCA['sys_template']['columns']['resources']['config']['max_size']); $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $TCA['sys_template']['columns']['resources']['config']['max_size']); $theOutput .= $this->pObj->doc->section('<font color=red>' . $fileToBig . '</font>', $filesizeNotAllowed, 0, 0, 0, 1); } } } if ($e['config']) { $outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, "width:98%;height:70%", "off") . ' class="fixed-font">' . t3lib_div::formatForTextarea($tplRow["config"]) . '</textarea>'; if (t3lib_extMgm::isLoaded('tsconfig_help')) { $url = $BACK_PATH . 'wizard_tsconfig.php?mode=tsref'; $params = array('formName' => 'editForm', 'itemName' => 'data[config]'); $outCode .= '<a href="#" onClick="vHWin=window.open(\'' . $url . t3lib_div::implodeArrayForUrl('', array('P' => $params)) . '\',\'popUp' . $md5ID . '\',\'height=500,width=780,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;">' . t3lib_iconWorks::getSpriteIcon('actions-system-typoscript-documentation-open', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:tsRef', true))) . '</a>'; } $outCode .= '<input type="Hidden" name="e[config]" value="1">'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup'), ''); $theOutput .= $this->pObj->doc->sectionEnd() . $outCode; } // Processing: $outCode = ''; $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('title'), htmlspecialchars($tplRow['title']), 'title'); $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('sitetitle'), htmlspecialchars($tplRow['sitetitle']), 'sitetitle'); $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('description'), nl2br(htmlspecialchars($tplRow['description'])), 'description'); $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('resources'), $this->procesResources($tplRow['resources']), 'resources'); $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('constants'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[constants]) ? count(explode(LF, $tplRow[constants])) : 0), 'constants'); $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('setup'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[config]) ? count(explode(LF, $tplRow[config])) : 0), 'config'); $outCode = '<br /><br /><table class="t3-table-info">' . $outCode . '</table>'; // Edit all icon: $outCode .= '<br /><a href="#" onClick="' . t3lib_BEfunc::editOnClick(rawurlencode('&createExtension=0') . '&edit[sys_template][' . $tplRow['uid'] . ']=edit', $BACK_PATH, '') . '"><strong>' . t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title' => $GLOBALS['LANG']->getLL('editTemplateRecord'))) . $GLOBALS['LANG']->getLL('editTemplateRecord') . '</strong></a>'; $theOutput .= $this->pObj->doc->section('', $outCode); // hook after compiling the output if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) { $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook']; if (is_array($postOutputProcessingHook)) { $hookParameters = array('theOutput' => &$theOutput, 'POST' => $POST, 'e' => $e, 'tplRow' => $tplRow, 'numberOfRows' => $numberOfRows); foreach ($postOutputProcessingHook as $hookFunction) { t3lib_div::callUserFunction($hookFunction, $hookParameters, $this); } } } } else { $theOutput .= $this->pObj->noTemplate(1); } return $theOutput; }