/** * prepare path, resolve relative path and resolve EXT: path * * @param $path absolute or relative path or EXT:foobar/ * @return string/bool false if path is invalid, else the absolute path */ protected function getPath($path) { // getFileAbsFileName can't handle directory path with trailing / correctly if (substr($path, -1) === '/') { $path = substr($path, 0, -1); } // FIXME remove this hacky part // skip path checks for CLI mode if (defined('TYPO3_cliMode')) { return $path; } $path = t3lib_div::getFileAbsFileName($path); if (t3lib_div::isAllowedAbsPath($path)) { return $path; } else { return false; } }
/** * Checks if a given string is a valid frame URL to be loaded in the * backend. * * @param string $url potential URL to check * * @return string either $url if $url is considered to be harmless, or an * empty string otherwise */ private static function internalSanitizeLocalUrl($url = '') { $sanitizedUrl = ''; $decodedUrl = rawurldecode($url); if ($decodedUrl !== t3lib_div::removeXSS($decodedUrl)) { $decodedUrl = ''; } if (!empty($url) && $decodedUrl !== '') { $testAbsoluteUrl = t3lib_div::resolveBackPath($decodedUrl); $testRelativeUrl = t3lib_div::resolveBackPath(t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')) . '/' . $decodedUrl); // That's what's usually carried in TYPO3_SITE_PATH $typo3_site_path = substr(t3lib_div::getIndpEnv('TYPO3_SITE_URL'), strlen(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST'))); // Pass if URL is on the current host: if (self::isValidUrl($decodedUrl)) { if (self::isOnCurrentHost($decodedUrl) && strpos($decodedUrl, t3lib_div::getIndpEnv('TYPO3_SITE_URL')) === 0) { $sanitizedUrl = $url; } // Pass if URL is an absolute file path: } elseif (t3lib_div::isAbsPath($decodedUrl) && t3lib_div::isAllowedAbsPath($decodedUrl)) { $sanitizedUrl = $url; // Pass if URL is absolute and below TYPO3 base directory: } elseif (strpos($testAbsoluteUrl, $typo3_site_path) === 0 && substr($decodedUrl, 0, 1) === '/') { $sanitizedUrl = $url; // Pass if URL is relative and below TYPO3 base directory: } elseif (strpos($testRelativeUrl, $typo3_site_path) === 0 && substr($decodedUrl, 0, 1) !== '/') { $sanitizedUrl = $url; } } if (!empty($url) && empty($sanitizedUrl)) { t3lib_div::sysLog('The URL "' . $url . '" is not considered to be local and was denied.', 'Core', t3lib_div::SYSLOG_SEVERITY_NOTICE); } return $sanitizedUrl; }
/** * If it is an URL, nothing to do, if it is a file, check if path is allowed and prepend current url * * @param string $url * @return string * @throws UnexpectedValueException */ public static function getCorrectUrl($url) { if (empty($url)) { throw new UnexpectedValueException('An empty url is given'); } $url = self::getFalFilename($url); // check URL $urlInfo = parse_url($url); // means: it is no external url if (!isset($urlInfo['scheme'])) { // resolve paths like ../ $url = t3lib_div::resolveBackPath($url); // absolute path is used to check path $absoluteUrl = t3lib_div::getFileAbsFileName($url); if (!t3lib_div::isAllowedAbsPath($absoluteUrl)) { throw new UnexpectedValueException('The path "' . $url . '" is not allowed.'); } // append current domain $url = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $url; } return $url; }
/** * Indexing a regular document given as $file (relative to PATH_site, local file) * * @param string Relative Filename, relative to PATH_site. It can also be an absolute path as long as it is inside the lockRootPath (validated with t3lib_div::isAbsPath()). Finally, if $contentTmpFile is set, this value can be anything, most likely a URL * @param boolean If set, indexing is forced (despite content hashes, mtime etc). * @param string Temporary file with the content to read it from (instead of $file). Used when the $file is a URL. * @param string File extension for temporary file. * @return void */ function indexRegularDocument($file, $force = FALSE, $contentTmpFile = '', $altExtension = '') { // Init $fI = pathinfo($file); $ext = $altExtension ? $altExtension : strtolower($fI['extension']); // Create abs-path: if (!$contentTmpFile) { if (!t3lib_div::isAbsPath($file)) { // Relative, prepend PATH_site: $absFile = t3lib_div::getFileAbsFileName(PATH_site . $file); } else { // Absolute, pass-through: $absFile = $file; } $absFile = t3lib_div::isAllowedAbsPath($absFile) ? $absFile : ''; } else { $absFile = $contentTmpFile; } // Indexing the document: if ($absFile && @is_file($absFile)) { if ($this->external_parsers[$ext]) { $mtime = filemtime($absFile); $cParts = $this->fileContentParts($ext, $absFile); foreach ($cParts as $cPKey) { $this->internal_log = array(); $this->log_push('Index: ' . str_replace('.', '_', basename($file)) . ($cPKey ? '#' . $cPKey : ''), ''); $Pstart = t3lib_div::milliseconds(); $subinfo = array('key' => $cPKey); // Setting page range. This is "0" (zero) when no division is made, otherwise a range like "1-3" $phash_arr = $this->file_phash_arr = $this->setExtHashes($file, $subinfo); $check = $this->checkMtimeTstamp($mtime, $phash_arr['phash']); if ($check > 0 || $force) { if ($check > 0) { $this->log_setTSlogMessage('Indexing needed, reason: ' . $this->reasons[$check], 1); } else { $this->log_setTSlogMessage('Indexing forced by flag', 1); } // Check external file counter: if ($this->externalFileCounter < $this->maxExternalFiles || $force) { // Divide into title,keywords,description and body: $this->log_push('Split content', ''); $contentParts = $this->readFileContent($ext, $absFile, $cPKey); $this->log_pull(); if (is_array($contentParts)) { // Calculating a hash over what is to be the actual content. (see indexTypo3PageContent()) $content_md5h = $this->md5inthash(implode($contentParts, '')); if ($this->checkExternalDocContentHash($phash_arr['phash_grouping'], $content_md5h) || $force) { // Increment counter: $this->externalFileCounter++; // Splitting words $this->log_push('Extract words from content', ''); $splitInWords = $this->processWordsInArrays($contentParts); $this->log_pull(); // Analyse the indexed words. $this->log_push('Analyse the extracted words', ''); $indexArr = $this->indexAnalyze($splitInWords); $this->log_pull(); // Submitting page (phash) record $this->log_push('Submitting page', ''); $size = filesize($absFile); $ctime = filemtime($absFile); // Unfortunately I cannot determine WHEN a file is originally made - so I must return the modification time... $this->submitFilePage($phash_arr, $file, $subinfo, $ext, $mtime, $ctime, $size, $content_md5h, $contentParts); $this->log_pull(); // Check words and submit to word list if not there $this->log_push('Check word list and submit words', ''); $this->checkWordList($indexArr); $this->submitWords($indexArr, $phash_arr['phash']); $this->log_pull(); // Set parsetime $this->updateParsetime($phash_arr['phash'], t3lib_div::milliseconds() - $Pstart); } else { $this->updateTstamp($phash_arr['phash'], $mtime); // Update the timestamp $this->log_setTSlogMessage('Indexing not needed, the contentHash, ' . $content_md5h . ', has not changed. Timestamp updated.'); } } else { $this->log_setTSlogMessage('Could not index file! Unsupported extension.'); } } else { $this->log_setTSlogMessage('The limit of ' . $this->maxExternalFiles . ' has already been exceeded, so no indexing will take place this time.'); } } else { $this->log_setTSlogMessage('Indexing not needed, reason: ' . $this->reasons[$check]); } // Checking and setting sections: # $this->submitFile_grlist($phash_arr['phash']); // Setting a gr_list record if there is none already (set for default fe_group) $this->submitFile_section($phash_arr['phash']); // Setting a section-record for the file. This is done also if the file is not indexed. Notice that section records are deleted when the page is indexed. $this->log_pull(); } } else { $this->log_setTSlogMessage('Indexing not possible; The extension "' . $ext . '" was not supported.'); } } else { $this->log_setTSlogMessage('Indexing not possible; File "' . $absFile . '" not found or valid.'); } }
/** * Export part of module * * @param array Content of POST VAR tx_impexp[].. * @return void Setting content in $this->content */ function exportData($inData) { global $TCA, $LANG; // BUILDING EXPORT DATA: // Processing of InData array values: $inData['pagetree']['maxNumber'] = t3lib_div::intInRange($inData['pagetree']['maxNumber'], 1, 10000, 100); $inData['listCfg']['maxNumber'] = t3lib_div::intInRange($inData['listCfg']['maxNumber'], 1, 10000, 100); $inData['maxFileSize'] = t3lib_div::intInRange($inData['maxFileSize'], 1, 10000, 1000); $inData['filename'] = trim(preg_replace('/[^[:alnum:]._-]*/', '', preg_replace('/\\.(t3d|xml)$/', '', $inData['filename']))); if (strlen($inData['filename'])) { $inData['filename'] .= $inData['filetype'] == 'xml' ? '.xml' : '.t3d'; } // Set exclude fields in export object: if (!is_array($inData['exclude'])) { $inData['exclude'] = array(); } // Saving/Loading/Deleting presets: $this->processPresets($inData); // Create export object and configure it: $this->export = t3lib_div::makeInstance('tx_impexp'); $this->export->init(0, 'export'); $this->export->setCharset($LANG->charSet); $this->export->maxFileSize = $inData['maxFileSize'] * 1024; $this->export->excludeMap = (array) $inData['exclude']; $this->export->softrefCfg = (array) $inData['softrefCfg']; $this->export->extensionDependencies = (array) $inData['extension_dep']; $this->export->showStaticRelations = $inData['showStaticRelations']; $this->export->includeExtFileResources = !$inData['excludeHTMLfileResources']; // Static tables: if (is_array($inData['external_static']['tables'])) { $this->export->relStaticTables = $inData['external_static']['tables']; } // Configure which tables external relations are included for: if (is_array($inData['external_ref']['tables'])) { $this->export->relOnlyTables = $inData['external_ref']['tables']; } $this->export->setHeaderBasics(); // Meta data setting: $this->export->setMetaData($inData['meta']['title'], $inData['meta']['description'], $inData['meta']['notes'], $GLOBALS['BE_USER']->user['username'], $GLOBALS['BE_USER']->user['realName'], $GLOBALS['BE_USER']->user['email']); if ($inData['meta']['thumbnail']) { $tempDir = $this->userTempFolder(); if ($tempDir) { $thumbnails = t3lib_div::getFilesInDir($tempDir, 'png,gif,jpg', 1); $theThumb = $thumbnails[$inData['meta']['thumbnail']]; if ($theThumb) { $this->export->addThumbnail($theThumb); } } } // Configure which records to export if (is_array($inData['record'])) { foreach ($inData['record'] as $ref) { $rParts = explode(':', $ref); $this->export->export_addRecord($rParts[0], t3lib_BEfunc::getRecord($rParts[0], $rParts[1])); } } // Configure which tables to export if (is_array($inData['list'])) { foreach ($inData['list'] as $ref) { $rParts = explode(':', $ref); if ($GLOBALS['BE_USER']->check('tables_select', $rParts[0])) { $res = $this->exec_listQueryPid($rParts[0], $rParts[1], t3lib_div::intInRange($inData['listCfg']['maxNumber'], 1)); while ($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $this->export->export_addRecord($rParts[0], $subTrow); } } } } // Pagetree if (isset($inData['pagetree']['id'])) { if ($inData['pagetree']['levels'] == -1) { // Based on click-expandable tree $pagetree = t3lib_div::makeInstance('localPageTree'); $tree = $pagetree->ext_tree($inData['pagetree']['id'], $this->filterPageIds($this->export->excludeMap)); $this->treeHTML = $pagetree->printTree($tree); $idH = $pagetree->buffer_idH; } elseif ($inData['pagetree']['levels'] == -2) { // Only tables on page $this->addRecordsForPid($inData['pagetree']['id'], $inData['pagetree']['tables'], $inData['pagetree']['maxNumber']); } else { // Based on depth // Drawing tree: // If the ID is zero, export root if (!$inData['pagetree']['id'] && $GLOBALS['BE_USER']->isAdmin()) { $sPage = array('uid' => 0, 'title' => 'ROOT'); } else { $sPage = t3lib_BEfunc::getRecordWSOL('pages', $inData['pagetree']['id'], '*', ' AND ' . $this->perms_clause); } if (is_array($sPage)) { $pid = $inData['pagetree']['id']; $tree = t3lib_div::makeInstance('t3lib_pageTree'); $tree->init('AND ' . $this->perms_clause . $this->filterPageIds($this->export->excludeMap)); $HTML = t3lib_iconWorks::getSpriteIconForRecord('pages', $sPage); $tree->tree[] = array('row' => $sPage, 'HTML' => $HTML); $tree->buffer_idH = array(); if ($inData['pagetree']['levels'] > 0) { $tree->getTree($pid, $inData['pagetree']['levels'], ''); } $idH = array(); $idH[$pid]['uid'] = $pid; if (count($tree->buffer_idH)) { $idH[$pid]['subrow'] = $tree->buffer_idH; } $pagetree = t3lib_div::makeInstance('localPageTree'); $this->treeHTML = $pagetree->printTree($tree->tree); } } // In any case we should have a multi-level array, $idH, with the page structure here (and the HTML-code loaded into memory for nice display...) if (is_array($idH)) { $flatList = $this->export->setPageTree($idH); // Sets the pagetree and gets a 1-dim array in return with the pages (in correct submission order BTW...) foreach ($flatList as $k => $value) { $this->export->export_addRecord('pages', t3lib_BEfunc::getRecord('pages', $k)); $this->addRecordsForPid($k, $inData['pagetree']['tables'], $inData['pagetree']['maxNumber']); } } } // After adding ALL records we set relations: for ($a = 0; $a < 10; $a++) { $addR = $this->export->export_addDBRelations($a); if (!count($addR)) { break; } } // Finally files are added: $this->export->export_addFilesFromRelations(); // MUST be after the DBrelations are set so that files from ALL added records are included! // If the download button is clicked, return file if ($inData['download_export'] || $inData['save_export']) { switch ((string) $inData['filetype']) { case 'xml': $out = $this->export->compileMemoryToFileContent('xml'); $fExt = '.xml'; break; case 't3d': $this->export->dontCompress = 1; default: $out = $this->export->compileMemoryToFileContent(); $fExt = ($this->export->doOutputCompress() ? '-z' : '') . '.t3d'; break; } // Filename: $dlFile = $inData['filename'] ? $inData['filename'] : 'T3D_' . substr(preg_replace('/[^[:alnum:]_]/', '-', $inData['download_export_name']), 0, 20) . '_' . date('d-m-H-i-s') . $fExt; // Export for download: if ($inData['download_export']) { $mimeType = 'application/octet-stream'; Header('Content-Type: ' . $mimeType); Header('Content-Length: ' . strlen($out)); Header('Content-Disposition: attachment; filename=' . basename($dlFile)); echo $out; exit; } // Export by saving: if ($inData['save_export']) { $savePath = $this->userSaveFolder(); $fullName = $savePath . $dlFile; if (t3lib_div::isAllowedAbsPath($savePath) && @is_dir(dirname($fullName)) && t3lib_div::isAllowedAbsPath($fullName)) { t3lib_div::writeFile($fullName, $out); $this->content .= $this->doc->section($LANG->getLL('exportdata_savedFile'), sprintf($LANG->getLL('exportdata_savedInSBytes', 1), substr($savePath . $dlFile, strlen(PATH_site)), t3lib_div::formatSize(strlen($out))), 0, 1); } else { $this->content .= $this->doc->section($LANG->getLL('exportdata_problemsSavingFile'), sprintf($LANG->getLL('exportdata_badPathS', 1), $fullName), 0, 1, 2); } } } // OUTPUT to BROWSER: // Now, if we didn't make download file, show configuration form based on export: $menuItems = array(); // Export configuration $row = array(); $this->makeConfigurationForm($inData, $row); $menuItems[] = array('label' => $LANG->getLL('tableselec_configuration'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); // File options $row = array(); $this->makeSaveForm($inData, $row); $menuItems[] = array('label' => $LANG->getLL('exportdata_filePreset'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); // File options $row = array(); $this->makeAdvancedOptionsForm($inData, $row); $menuItems[] = array('label' => $LANG->getLL('exportdata_advancedOptions'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); // Generate overview: $overViewContent = $this->export->displayContentOverview(); // Print errors that might be: $errors = $this->export->printErrorLog(); $menuItems[] = array('label' => $LANG->getLL('exportdata_messages'), 'content' => $errors, 'stateIcon' => $errors ? 2 : 0); // Add hidden fields and create tabs: $content = $this->doc->getDynTabMenu($menuItems, 'tx_impexp_export', -1); $content .= '<input type="hidden" name="tx_impexp[action]" value="export" />'; $this->content .= $this->doc->section('', $content, 0, 1); // Output Overview: $this->content .= $this->doc->section($LANG->getLL('execlistqu_structureToBeExported'), $overViewContent, 0, 1); }
/** * * @param Tx_ExtensionBuilder_Domain_Model_Extension $extension * @param string $backupDir * * @return void */ static function backupExtension($extension, $backupDir) { if (empty($backupDir)) { throw new Exception('Please define a backup directory in extension configuration!'); } else { if (!t3lib_div::validPathStr($backupDir)) { throw new Exception('Backup directory is not a valid path: ' . $backupDir); } else { if (t3lib_div::isAbsPath($backupDir)) { if (!t3lib_div::isAllowedAbsPath($backupDir)) { throw new Exception('Backup directory is not an allowed absolute path: ' . $backupDir); } } else { $backupDir = PATH_site . $backupDir; } } } if (strrpos($backupDir, '/') < strlen($backupDir) - 1) { $backupDir .= '/'; } if (!is_dir($backupDir)) { throw new Exception('Backup directory does not exist: ' . $backupDir); } else { if (!is_writable($backupDir)) { throw new Exception('Backup directory is not writable: ' . $backupDir); } } $backupDir .= $extension->getExtensionKey(); // create a subdirectory for this extension if (!is_dir($backupDir)) { t3lib_div::mkdir($backupDir); } if (strrpos($backupDir, '/') < strlen($backupDir) - 1) { $backupDir .= '/'; } $backupDir .= date('Y-m-d-') . time(); if (!is_dir($backupDir)) { t3lib_div::mkdir($backupDir); } $extensionDir = substr($extension->getExtensionDir(), 0, strlen($extension->getExtensionDir()) - 1); try { self::recurse_copy($extensionDir, $backupDir); } catch (Exception $e) { throw new Exception('Code generation aborted:' . $e->getMessage()); } t3lib_div::devlog('Backup created in ' . $backupDir, 'extension_builder', 0); }
/** * Indexing files from fileadmin * * @param array Indexing Configuration Record * @param array Session data for the indexing session spread over multiple instances of the script. Passed by reference so changes hereto will be saved for the next call! * @param array Parameters from the log queue. * @param object Parent object (from "crawler" extension!) * @return void */ function crawler_execute_type2($cfgRec, &$session_data, $params, &$pObj) { // Prepare path, making it absolute and checking: $readpath = $params['url']; if (!t3lib_div::isAbsPath($readpath)) { $readpath = t3lib_div::getFileAbsFileName($readpath); } if (t3lib_div::isAllowedAbsPath($readpath)) { if (@is_file($readpath)) { // If file, index it! // Get root line (need to provide this when indexing external files) $rl = $this->getUidRootLineForClosestTemplate($cfgRec['pid']); // Load indexer if not yet. $this->loadIndexerClass(); // (Re)-Indexing file on page. $indexerObj = t3lib_div::makeInstance('tx_indexedsearch_indexer'); $indexerObj->backend_initIndexer($cfgRec['pid'], 0, 0, '', $rl); $indexerObj->backend_setFreeIndexUid($cfgRec['uid'], $cfgRec['set_id']); $indexerObj->hash['phash'] = -1; // EXPERIMENT - but to avoid phash_t3 being written to file sections (otherwise they are removed when page is reindexed!!!) // Index document: $indexerObj->indexRegularDocument(substr($readpath, strlen(PATH_site)), TRUE); } elseif (@is_dir($readpath)) { // If dir, read content and create new pending items for log: // Select files and directories in path: $extList = implode(',', t3lib_div::trimExplode(',', $cfgRec['extensions'], 1)); $fileArr = array(); $files = t3lib_div::getAllFilesAndFoldersInPath($fileArr, $readpath, $extList, 0, 0); $directoryList = t3lib_div::get_dirs($readpath); if (is_array($directoryList) && $params['depth'] < $cfgRec['depth']) { foreach ($directoryList as $subdir) { if ((string) $subdir != '') { $files[] = $readpath . $subdir . '/'; } } } $files = t3lib_div::removePrefixPathFromList($files, PATH_site); // traverse the items and create log entries: foreach ($files as $path) { $this->instanceCounter++; if ($path !== $params['url']) { // Parameters: $nparams = array('indexConfigUid' => $cfgRec['uid'], 'url' => $path, 'procInstructions' => array('[Index Cfg UID#' . $cfgRec['uid'] . ']'), 'depth' => $params['depth'] + 1); $pObj->addQueueEntry_callBack($cfgRec['set_id'], $nparams, $this->callBack, $cfgRec['pid'], $GLOBALS['EXEC_TIME'] + $this->instanceCounter * $this->secondsPerExternalUrl); } } } } }
/** * Initialize; reading parameters with GPvar and checking file path * Results in internal var, $this->input, being set to the absolute path of the file for which to make the thumbnail. * * @return void */ function init() { global $TYPO3_CONF_VARS; // Setting GPvars: $file = t3lib_div::_GP('file'); $size = t3lib_div::_GP('size'); $md5sum = t3lib_div::_GP('md5sum'); // Image extension list is set: $this->imageList = $TYPO3_CONF_VARS['GFX']['imagefile_ext']; // valid extensions. OBS: No spaces in the list, all lowercase... // If the filereference $this->file is relative, we correct the path if (substr($file, 0, 3) == '../') { $file = PATH_site . substr($file, 3); } // Now the path is absolute. // Checking for backpath and double slashes + the thumbnail can be made from files which are in the PATH_site OR the lockRootPath only! if (t3lib_div::isAllowedAbsPath($file)) { $mtime = filemtime($file); } // Do an MD5 check to prevent viewing of images without permission $OK = FALSE; if ($mtime) { // Always use the absolute path for this check! $check = basename($file) . ':' . $mtime . ':' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']; $md5_real = t3lib_div::shortMD5($check); if (!strcmp($md5_real, $md5sum)) { $OK = TRUE; } } if ($OK) { $this->input = $file; $this->size = $size; $this->mtime = $mtime; } else { throw new RuntimeException('TYPO3 Fatal Error: Image does not exist and/or MD5 checksum did not match.', 1270853950); } }
/** * Initialize file-based statistics handling: Check filename and permissions, and create the logfile if it does not exist yet. * This function should be called with care because it might overwrite existing settings otherwise. * * @return boolean True if statistics are enabled (will require some more processing after charset handling is initialized) * @access private */ protected function statistics_init() { $setStatPageName = false; $theLogFile = $this->TYPO3_CONF_VARS['FE']['logfile_dir'] . strftime($this->config['config']['stat_apache_logfile']); // Add PATH_site left to $theLogFile if the path is not absolute yet if (!t3lib_div::isAbsPath($theLogFile)) { $theLogFile = PATH_site . $theLogFile; } if ($this->config['config']['stat_apache'] && $this->config['config']['stat_apache_logfile'] && !strstr($this->config['config']['stat_apache_logfile'], '/')) { if (t3lib_div::isAllowedAbsPath($theLogFile)) { if (!@is_file($theLogFile)) { touch($theLogFile); // Try to create the logfile t3lib_div::fixPermissions($theLogFile); } if (@is_file($theLogFile) && @is_writable($theLogFile)) { $this->config['stat_vars']['logFile'] = $theLogFile; $setStatPageName = true; // Set page name later on } else { $GLOBALS['TT']->setTSlogMessage('Could not set logfile path. Check filepath and permissions.', 3); } } } return $setStatPageName; }
/** * Initialization of the class * Will determine if table/uid GET vars are database record or a file and if the user has access to view information about the item. * * @return void */ function init() { global $BE_USER, $BACK_PATH, $TCA; // Setting input variables. $this->table = t3lib_div::_GET('table'); $this->uid = t3lib_div::_GET('uid'); // Initialize: $this->perms_clause = $BE_USER->getPagePermsClause(1); $this->access = 0; // Set to true if there is access to the record / file. $this->type = ''; // Sets the type, "db" or "file". If blank, nothing can be shown. // Checking if the $table value is really a table and if the user has access to it. if (isset($TCA[$this->table])) { t3lib_div::loadTCA($this->table); $this->type = 'db'; $this->uid = intval($this->uid); // Check permissions and uid value: if ($this->uid && $BE_USER->check('tables_select', $this->table)) { if ((string) $this->table == 'pages') { $this->pageinfo = t3lib_BEfunc::readPageAccess($this->uid, $this->perms_clause); $this->access = is_array($this->pageinfo) ? 1 : 0; $this->row = $this->pageinfo; } else { $this->row = t3lib_BEfunc::getRecordWSOL($this->table, $this->uid); if ($this->row) { $this->pageinfo = t3lib_BEfunc::readPageAccess($this->row['pid'], $this->perms_clause); $this->access = is_array($this->pageinfo) ? 1 : 0; } } $treatData = t3lib_div::makeInstance('t3lib_transferData'); $treatData->renderRecord($this->table, $this->uid, 0, $this->row); $cRow = $treatData->theRecord; } } else { // if the filereference $this->file is relative, we correct the path if (substr($this->table, 0, 3) == '../') { $this->file = PATH_site . preg_replace('/^\\.\\.\\//', '', $this->table); } else { $this->file = $this->table; } if (@is_file($this->file) && t3lib_div::isAllowedAbsPath($this->file)) { $this->type = 'file'; $this->access = 1; } } // Initialize document template object: $this->doc = t3lib_div::makeInstance('template'); $this->doc->backPath = $BACK_PATH; // Starting the page by creating page header stuff: $this->content .= $this->doc->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.viewItem')); $this->content .= '<h3 class="t3-row-header">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.viewItem') . '</h3>'; $this->content .= $this->doc->spacer(5); }
/** * Creates GET parameters for linking to the export module. * * @return string GET parameters for current clipboard content to be exported. */ function exportClipElementParameters() { // Init: $pad = $this->current; $params = array(); $params[] = 'tx_impexp[action]=export'; // Traverse items: if (is_array($this->clipData[$pad]['el'])) { foreach ($this->clipData[$pad]['el'] as $k => $v) { if ($v) { list($table, $uid) = explode('|', $k); if ($table == '_FILE') { // Rendering files/directories on the clipboard: if (file_exists($v) && t3lib_div::isAllowedAbsPath($v)) { $params[] = 'tx_impexp[' . (is_dir($v) ? 'dir' : 'file') . '][]=' . rawurlencode($v); } } else { // Rendering records: $rec = t3lib_BEfunc::getRecord($table, $uid); if (is_array($rec)) { $params[] = 'tx_impexp[record][]=' . rawurlencode($table . ':' . $uid); } } } } } return '?' . implode('&', $params); }
/** * Function to load a HTML template file with markers. * When calling from own extension, use syntax getHtmlTemplate('EXT:extkey/template.html') * * @param string tmpl name, usually in the typo3/template/ directory * @return string HTML of template */ function getHtmlTemplate($filename) { // setting the name of the original HTML template $this->moduleTemplateFilename = $filename; if ($GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]) { $filename = $GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]; } if (t3lib_div::isFirstPartOfStr($filename, 'EXT:')) { $filename = t3lib_div::getFileAbsFileName($filename, TRUE, TRUE); } else { if (!t3lib_div::isAbsPath($filename)) { $filename = t3lib_div::resolveBackPath($this->backPath . $filename); } else { if (!t3lib_div::isAllowedAbsPath($filename)) { $filename = ''; } } } $htmlTemplate = ''; if ($filename !== '') { $htmlTemplate = t3lib_div::getURL($filename); } return $htmlTemplate; }
/** * Creates a new file * * Returns an array with * 0: boolean success * 1: string absolute path of written file/folder * 2: error code * * The error code returns * 0: no error * -1: not writable * -2: not allowed path * -3: already exists * -4: not able to create * * @static * @param $folder * @param $file * @param $isFolder * @return array */ public static function createNewFile($folder, $file, $isFolder) { $success = FALSE; $error = 0; if (substr($folder, -1) !== '/') { $folder .= '/'; } $newFile = t3lib_div::resolveBackPath(PATH_site . $folder . $file); if (!is_writable(dirname($newFile))) { $error = -1; } elseif (!t3lib_div::isAllowedAbsPath($newFile)) { $error = -2; } elseif (file_exists($newFile)) { $error = -3; } else { if ($isFolder) { $success = t3lib_div::mkdir($newFile); } else { $success = t3lib_div::writeFile($newFile, ''); } if (!$success) { $error = -4; } } return array($success, $newFile, $error); }
/** * Make 1st level clickmenu: * * @param string The absolute path * @return string HTML content */ function printFileClickMenu($path) { $menuItems = array(); if (file_exists($path) && t3lib_div::isAllowedAbsPath($path)) { $fI = pathinfo($path); $size = ' (' . t3lib_div::formatSize(filesize($path)) . 'bytes)'; $icon = t3lib_iconWorks::getSpriteIconForFile(is_dir($path) ? 'folder' : strtolower($fI['extension']), array('class' => 'absmiddle', 'title' => htmlspecialchars($fI['basename'] . $size))); // edit if (!in_array('edit', $this->disabledItems) && is_file($path) && t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fI['extension'])) { $menuItems['edit'] = $this->FILE_launch($path, 'file_edit.php', 'edit', 'edit_file.gif'); } // rename if (!in_array('rename', $this->disabledItems)) { $menuItems['rename'] = $this->FILE_launch($path, 'file_rename.php', 'rename', 'rename.gif'); } // upload if (!in_array('upload', $this->disabledItems) && is_dir($path)) { $menuItems['upload'] = $this->FILE_upload($path); } // new if (!in_array('new', $this->disabledItems) && is_dir($path)) { $menuItems['new'] = $this->FILE_launch($path, 'file_newfolder.php', 'new', 'new_file.gif'); } // info if (!in_array('info', $this->disabledItems)) { $menuItems['info'] = $this->DB_info($path, ''); } $menuItems[] = 'spacer'; // copy: if (!in_array('copy', $this->disabledItems)) { $menuItems['copy'] = $this->FILE_copycut($path, 'copy'); } // cut: if (!in_array('cut', $this->disabledItems)) { $menuItems['cut'] = $this->FILE_copycut($path, 'cut'); } // Paste: $elFromAllTables = count($this->clipObj->elFromTable('_FILE')); if (!in_array('paste', $this->disabledItems) && $elFromAllTables && is_dir($path)) { $elArr = $this->clipObj->elFromTable('_FILE'); reset($elArr); $selItem = current($elArr); $elInfo = array(basename($selItem), basename($path), $this->clipObj->currentMode()); $menuItems['pasteinto'] = $this->FILE_paste($path, $selItem, $elInfo); } $menuItems[] = 'spacer'; // delete: if (!in_array('delete', $this->disabledItems)) { $menuItems['delete'] = $this->FILE_delete($path); } } // Adding external elements to the menuItems array $menuItems = $this->processingByExtClassArray($menuItems, $path, 0); // Processing by external functions? $menuItems = $this->externalProcessingOfFileMenuItems($menuItems); // Return the printed elements: return $this->printItems($menuItems, $icon . basename($path)); }
/** * Display extensions details. * * @param string Extension key * @return void Writes content to $this->content */ function showExtDetails($extKey) { global $TYPO3_LOADED_EXT; list($list, ) = $this->extensionList->getInstalledExtensions(); $absPath = tx_em_Tools::getExtPath($extKey, $list[$extKey]['type']); // Check updateModule: if (isset($list[$extKey]) && @is_file($absPath . 'class.ext_update.php')) { require_once $absPath . 'class.ext_update.php'; $updateObj = new ext_update(); if (!$updateObj->access()) { unset($this->MOD_MENU['singleDetails']['updateModule']); } } else { unset($this->MOD_MENU['singleDetails']['updateModule']); } if ($this->CMD['doDelete']) { $this->MOD_MENU['singleDetails'] = array(); } // Function menu here: if (!$this->CMD['standAlone'] && !t3lib_div::_GP('standAlone')) { $content = $GLOBALS['LANG']->getLL('ext_details_ext') . ' <strong>' . $this->extensionTitleIconHeader($extKey, $list[$extKey]) . '</strong> (' . htmlspecialchars($extKey) . ')'; $this->content .= $this->doc->section('', $content); } // Show extension details: if ($list[$extKey]) { // Checking if a command for install/uninstall is executed: if (($this->CMD['remove'] || $this->CMD['load']) && !in_array($extKey, $this->requiredExt)) { // Install / Uninstall extension here: if (t3lib_extMgm::isLocalconfWritable()) { // Check dependencies: $depStatus = $this->install->checkDependencies($extKey, $list[$extKey]['EM_CONF'], $list); if (!$this->CMD['remove'] && !$depStatus['returnCode']) { $this->content .= $depStatus['html']; $newExtList = -1; } elseif ($this->CMD['remove']) { $newExtList = $this->extensionList->removeExtFromList($extKey, $list); } else { $newExtList = $this->extensionList->addExtToList($extKey, $list); } // Successful installation: if ($newExtList != -1) { $updates = ''; if ($this->CMD['load']) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $script = t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[load]' => 1, 'CMD[clrCmd]' => $this->CMD['clrCmd'], 'SET[singleDetails]' => 'info')); } else { $script = ''; } $standaloneUpdates = ''; if ($this->CMD['standAlone']) { $standaloneUpdates .= '<input type="hidden" name="standAlone" value="1" />'; } if ($this->CMD['silendMode']) { $standaloneUpdates .= '<input type="hidden" name="silendMode" value="1" />'; } $depsolver = t3lib_div::_POST('depsolver'); if (is_array($depsolver['ignore'])) { foreach ($depsolver['ignore'] as $depK => $depV) { $dependencyUpdates .= '<input type="hidden" name="depsolver[ignore][' . $depK . ']" value="1" />'; } } $updatesForm = $this->install->updatesForm($extKey, $list[$extKey], 1, $script, $dependencyUpdates . $standaloneUpdates . '<input type="hidden" name="_do_install" value="1" /><input type="hidden" name="_clrCmd" value="' . $this->CMD['clrCmd'] . '" />', TRUE); if ($updatesForm) { $updates = $GLOBALS['LANG']->getLL('ext_details_new_tables_fields') . '<br />' . $GLOBALS['LANG']->getLL('ext_details_new_tables_fields_select') . $updatesForm; $labelDBUpdate = $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $GLOBALS['LANG']->getLL('ext_details_db_needs_update'), 'toUpper'); $this->content .= $this->doc->section(sprintf($GLOBALS['LANG']->getLL('ext_details_installing') . ' ', $this->extensionTitleIconHeader($extKey, $list[$extKey])) . ' ' . $labelDBUpdate, $updates, 1, 1, 1, 1); } } elseif ($this->CMD['remove']) { $updates .= $this->install->checkClearCache($list[$extKey]); if ($updates) { $updates = ' <form action="' . $this->script . '" method="post">' . $updates . ' <br /><input type="submit" name="write" value="' . $GLOBALS['LANG']->getLL('ext_details_remove_ext') . '" /> <input type="hidden" name="_do_install" value="1" /> <input type="hidden" name="_clrCmd" value="' . $this->CMD['clrCmd'] . '" /> <input type="hidden" name="CMD[showExt]" value="' . $this->CMD['showExt'] . '" /> <input type="hidden" name="CMD[remove]" value="' . $this->CMD['remove'] . '" /> <input type="hidden" name="standAlone" value="' . $this->CMD['standAlone'] . '" /> <input type="hidden" name="silentMode" value="' . $this->CMD['silentMode'] . '" /> ' . ($this->noDocHeader ? '<input type="hidden" name="nodoc" value="1" />' : '') . ' </form>'; $labelDBUpdate = $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $GLOBALS['LANG']->getLL('ext_details_db_needs_update'), 'toUpper'); $this->content .= $this->doc->section(sprintf($GLOBALS['LANG']->getLL('ext_details_removing') . ' ', $this->extensionTitleIconHeader($extKey, $list[$extKey])) . ' ' . $labelDBUpdate, $updates, 1, 1, 1, 1); } } if (!$updates || t3lib_div::_GP('_do_install') || $this->noDocHeader && $this->CMD['remove']) { $this->install->writeNewExtensionList($newExtList); $action = $this->CMD['load'] ? 'installed' : 'removed'; $GLOBALS['BE_USER']->writelog(5, 1, 0, 0, 'Extension list has been changed, extension %s has been %s', array($extKey, $action)); if (!t3lib_div::_GP('silentMode') && !$this->CMD['standAlone']) { $messageLabel = 'ext_details_ext_' . $action . '_with_key'; $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL($messageLabel), $extKey), '', t3lib_FlashMessage::OK, TRUE); t3lib_FlashMessageQueue::addMessage($flashMessage); } if ($this->CMD['clrCmd'] || t3lib_div::_GP('_clrCmd')) { if ($this->CMD['load'] && @is_file($absPath . 'ext_conf_template.txt')) { $vA = array('CMD' => array('showExt' => $extKey)); } else { $vA = array('CMD' => ''); } } else { $vA = array('CMD' => array('showExt' => $extKey)); } if ($this->CMD['standAlone'] || t3lib_div::_GP('standAlone')) { $this->content .= sprintf($GLOBALS['LANG']->getLL('ext_details_ext_installed_removed'), $this->CMD['load'] ? $GLOBALS['LANG']->getLL('ext_details_installed') : $GLOBALS['LANG']->getLL('ext_details_removed')) . '<br /><br />' . $this->getSubmitAndOpenerCloseLink(); } else { // Determine if new modules were installed: $techInfo = $this->install->makeDetailedExtensionAnalysis($extKey, $list[$extKey]); if (($this->CMD['load'] || $this->CMD['remove']) && is_array($techInfo['flags']) && in_array('Module', $techInfo['flags'], true)) { $vA['CMD']['refreshMenu'] = 1; } t3lib_utility_Http::redirect(t3lib_div::linkThisScript($vA)); exit; } } } } else { $writeAccessError = $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $GLOBALS['LANG']->getLL('ext_details_write_access_error'), 'toUpper'); $this->content .= $this->doc->section(sprintf($GLOBALS['LANG']->getLL('ext_details_installing') . ' ', $this->extensionTitleIconHeader($extKey, $list[$extKey])) . ' ' . $writeAccessError, $GLOBALS['LANG']->getLL('ext_details_write_error_localconf'), 1, 1, 2, 1); } } elseif ($this->CMD['downloadFile'] && !in_array($extKey, $this->requiredExt)) { // Link for downloading extension has been clicked - deliver content stream: $dlFile = $this->CMD['downloadFile']; if (t3lib_div::isAllowedAbsPath($dlFile) && t3lib_div::isFirstPartOfStr($dlFile, PATH_site) && t3lib_div::isFirstPartOfStr($dlFile, $absPath) && @is_file($dlFile)) { $mimeType = 'application/octet-stream'; Header('Content-Type: ' . $mimeType); Header('Content-Disposition: attachment; filename=' . basename($dlFile)); echo t3lib_div::getUrl($dlFile); exit; } else { throw new RuntimeException('TYPO3 Fatal Error: ' . $GLOBALS['LANG']->getLL('ext_details_error_downloading'), 1270853980); } } elseif ($this->CMD['editFile'] && !in_array($extKey, $this->requiredExt)) { // Editing extension file: $editFile = rawurldecode($this->CMD['editFile']); if (t3lib_div::isAllowedAbsPath($editFile) && t3lib_div::isFirstPartOfStr($editFile, $absPath)) { $fI = t3lib_div::split_fileref($editFile); if (@is_file($editFile) && t3lib_div::inList($this->editTextExtensions, $fI['fileext'] ? $fI['fileext'] : $fI['filebody'])) { if (filesize($editFile) < $this->kbMax * 1024) { $outCode = '<form action="' . $this->script . ' method="post" name="editfileform">'; $info = ''; $submittedContent = t3lib_div::_POST('edit'); $saveFlag = 0; if (isset($submittedContent['file']) && !$GLOBALS['TYPO3_CONF_VARS']['EXT']['noEdit']) { // Check referer here? $oldFileContent = t3lib_div::getUrl($editFile); if ($oldFileContent != $submittedContent['file']) { $oldMD5 = md5(str_replace(CR, '', $oldFileContent)); $info .= sprintf($GLOBALS['LANG']->getLL('ext_details_md5_previous'), '<strong>' . $oldMD5 . '</strong>') . '<br />'; t3lib_div::writeFile($editFile, $submittedContent['file']); $saveFlag = 1; } else { $info .= $GLOBALS['LANG']->getLL('ext_details_no_changes') . '<br />'; } } $fileContent = t3lib_div::getUrl($editFile); $outCode .= sprintf($GLOBALS['LANG']->getLL('ext_details_file'), '<strong>' . substr($editFile, strlen($absPath)) . '</strong> (' . t3lib_div::formatSize(filesize($editFile)) . ')<br />'); $fileMD5 = md5(str_replace(CR, '', $fileContent)); $info .= sprintf($GLOBALS['LANG']->getLL('ext_details_md5_current'), '<strong>' . $fileMD5 . '</strong>') . '<br />'; if ($saveFlag) { $saveMD5 = md5(str_replace(CR, '', $submittedContent['file'])); $info .= sprintf($GLOBALS['LANG']->getLL('ext_details_md5_submitted'), '<strong>' . $saveMD5 . '</strong>') . '<br />'; if ($fileMD5 != $saveMD5) { $info .= tx_em_Tools::rfw('<br /><strong>' . $GLOBALS['LANG']->getLL('ext_details_saving_failed_changes_lost') . '</strong>') . '<br />'; } else { $info .= tx_em_Tools::rfw('<br /><strong>' . $GLOBALS['LANG']->getLL('ext_details_file_saved') . '</strong>') . '<br />'; } } $outCode .= '<textarea name="edit[file]" rows="35" wrap="off"' . $this->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font enable-tab">' . t3lib_div::formatForTextarea($fileContent) . '</textarea>'; $outCode .= '<input type="hidden" name="edit[filename]" value="' . $editFile . '" />'; $outCode .= '<input type="hidden" name="CMD[editFile]" value="' . htmlspecialchars($editFile) . '" />'; $outCode .= '<input type="hidden" name="CMD[showExt]" value="' . $extKey . '" />'; $outCode .= $info; if (!$GLOBALS['TYPO3_CONF_VARS']['EXT']['noEdit']) { $outCode .= '<br /><input type="submit" name="save_file" value="' . $GLOBALS['LANG']->getLL('ext_details_file_save_button') . '" />'; } else { $outCode .= tx_em_Tools::rfw('<br />' . $GLOBALS['LANG']->getLL('ext_details_saving_disabled') . ' '); } $onClick = 'window.location.href="' . t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey)) . '";return false;'; $outCode .= '<input type="submit" name="cancel" value="' . $GLOBALS['LANG']->getLL('ext_details_cancel_button') . '" onclick="' . htmlspecialchars($onClick) . '" /></form>'; $theOutput .= $this->doc->spacer(15); $theOutput .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_edit_file'), '', 0, 1); $theOutput .= $this->doc->sectionEnd() . $outCode; $this->content .= $theOutput; } else { $theOutput .= $this->doc->spacer(15); $theOutput .= $this->doc->section(sprintf($GLOBALS['LANG']->getLL('ext_details_filesize_exceeded_kb'), $this->kbMax), sprintf($GLOBALS['LANG']->getLL('ext_details_file_too_large'), $this->kbMax)); } } } else { die(sprintf($GLOBALS['LANG']->getLL('ext_details_fatal_edit_error'), htmlspecialchars($editFile))); } } else { // MAIN: switch ((string) $this->MOD_SETTINGS['singleDetails']) { case 'info': // Loaded / Not loaded: if (!in_array($extKey, $this->requiredExt)) { if ($TYPO3_LOADED_EXT[$extKey]) { $content = '<strong>' . $GLOBALS['LANG']->getLL('ext_details_loaded_and_running') . '</strong><br />' . '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[remove]' => 1))) . '">' . $GLOBALS['LANG']->getLL('ext_details_remove_button') . ' ' . tx_em_Tools::removeButton() . '</a>'; } else { $content = $GLOBALS['LANG']->getLL('ext_details_not_loaded') . '<br />' . '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[load]' => 1))) . '">' . $GLOBALS['LANG']->getLL('ext_details_install_button') . ' ' . tx_em_Tools::installButton() . '</a>'; } } else { $content = $GLOBALS['LANG']->getLL('ext_details_always_loaded'); } $this->content .= $this->doc->spacer(10); $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_current_status'), $content, 0, 1); if (t3lib_extMgm::isLoaded($extKey)) { $updates = $this->install->updatesForm($extKey, $list[$extKey]); if ($updates) { $this->content .= $this->doc->spacer(10); $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_update_needed'), $updates . '<br /><br />' . $GLOBALS['LANG']->getLL('ext_details_notice_static_data'), 0, 1); } } // Config: if (@is_file($absPath . 'ext_conf_template.txt')) { $this->content .= $this->doc->spacer(10); $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_configuration'), $GLOBALS['LANG']->getLL('ext_details_notice_clear_cache') . '<br /><br />', 0, 1); $this->content .= $this->install->tsStyleConfigForm($extKey, $list[$extKey]); } // Show details: $headline = $GLOBALS['LANG']->getLL('ext_details_details'); $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'info', $headline); $content = $this->extensionDetails->extInformationarray($extKey, $list[$extKey]); $this->content .= $this->doc->spacer(10); $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE); break; case 'upload': $em = t3lib_div::_POST('em'); if ($em['action'] == 'doUpload') { $em['extKey'] = $extKey; $em['extInfo'] = $list[$extKey]; $content = $this->extensionDetails->uploadExtensionToTER($em); $content .= $this->doc->spacer(10); // Must reload this, because EM_CONF information has been updated! list($list, ) = $this->extensionList->getInstalledExtensions(); } else { // headline and CSH $headline = $GLOBALS['LANG']->getLL('ext_details_upload_to_ter'); $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'upload', $headline); // Upload: if (substr($extKey, 0, 5) != 'user_') { $content = $this->getRepositoryUploadForm($extKey, $list[$extKey]); $eC = 0; } else { $content = $GLOBALS['LANG']->getLL('ext_details_no_unique_ext'); $eC = 2; } if (!$this->fe_user['username']) { $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_details_no_username'), '<a href="' . t3lib_div::linkThisScript(array('SET[function]' => 3)) . '">', '</a>'), '', t3lib_FlashMessage::INFO); $content .= '<br />' . $flashMessage->render(); } } $this->content .= $this->doc->section($headline, $content, 0, 1, $eC, TRUE); break; case 'backup': if ($this->CMD['doDelete']) { $content = $this->install->extDelete($extKey, $list[$extKey], $this->CMD); $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_delete'), $GLOBALS['LANG']->getLL('ext_details_delete'), $content, 0, 1); } else { // headline and CSH $headline = $GLOBALS['LANG']->getLL('ext_details_backup'); $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'backup_delete', $headline); $content = $this->extBackup($extKey, $list[$extKey]); $this->content .= $this->doc->section($headline, $content, 0, 1, 0, 1); $content = $this->install->extDelete($extKey, $list[$extKey], $this->CMD); $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_delete'), $content, 0, 1); $content = $this->extUpdateEMCONF($extKey, $list[$extKey]); $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_update_em_conf'), $content, 0, 1); } break; case 'dump': $this->extDumpTables($extKey, $list[$extKey]); break; case 'edit': // headline and CSH $headline = $GLOBALS['LANG']->getLL('ext_details_ext_files'); $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'editfiles', $headline); $content = $this->getFileListOfExtension($extKey, $list[$extKey]); $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE); break; case 'updateModule': $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_update'), is_object($updateObj) ? $updateObj->main() : $GLOBALS['LANG']->getLL('ext_details_no_update_object'), 0, 1); break; default: $this->extObjContent(); break; } } } }
/** * Write content to a file. * * @param string Content to write to the file * @param string File name to write into. If empty a temp file will be created. * @return string File name or FALSE */ function writeFile($content, $absFile = '') { $ret = TRUE; if (!$absFile) { $absFile = $this->tempFile($this->prefixId); } if ($absFile && t3lib_div::isAllowedAbsPath($absFile)) { if ($fd = @fopen($absFile, 'wb')) { @fwrite($fd, $content); @fclose($fd); } else { $this->errorPush(T3_ERR_SV_FILE_WRITE, 'Can not write to file: ' . $absFile); $absFile = FALSE; } } return $absFile; }