|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com) 00006 * (c) 2009-2011 Benjamin Mack (benni.typo3.org) 00007 * All rights reserved 00008 * 00009 * This script is part of the TYPO3 project. The TYPO3 project is 00010 * free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * The GNU General Public License can be found at 00016 * http://www.gnu.org/copyleft/gpl.html. 00017 * A copy is found in the textfile GPL.txt and important notices to the license 00018 * from the author is found in LICENSE.txt distributed with these scripts. 00019 * 00020 * 00021 * This script is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU General Public License for more details. 00025 * 00026 * This copyright notice MUST APPEAR in all copies of the script! 00027 ***************************************************************/ 00028 /** 00029 * Gateway for TCE (TYPO3 Core Engine) file-handling through POST forms. 00030 * This script serves as the fileadministration part of the TYPO3 Core Engine. 00031 * Basically it includes two libraries which are used to manipulate files on the server. 00032 * Before TYPO3 4.3, it was located in typo3/tce_file.php and redirected back to a 00033 * $redirectURL. Since 4.3 this class is also used for accessing via AJAX 00034 * 00035 * 00036 * For syntax and API information, see the document 'TYPO3 Core APIs' 00037 * 00038 * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj 00039 * Revised for TYPO3 4.3 Mar/2009 by Benjamin Mack 00040 * 00041 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00042 */ 00043 00044 require_once(PATH_typo3 . 'template.php'); 00045 00046 /** 00047 * Script Class, handling the calling of methods in the file admin classes. 00048 * 00049 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00050 * @package TYPO3 00051 * @subpackage core 00052 */ 00053 class TYPO3_tcefile { 00054 00055 // Internal, static: GPvar: 00056 // Array of file-operations. 00057 protected $file; 00058 // Clipboard operations array 00059 protected $CB; 00060 // If existing files should be overridden. 00061 protected $overwriteExistingFiles; 00062 // VeriCode - a hash of server specific value and other things which 00063 // identifies if a submission is OK. (see $BE_USER->veriCode()) 00064 protected $vC; 00065 // the page where the user should be redirected after everything is done 00066 protected $redirect; 00067 00068 // Internal, dynamic: 00069 // File processor object 00070 protected $fileProcessor; 00071 // the result array from the file processor 00072 protected $fileData; 00073 00074 00075 00076 /** 00077 * Registering incoming data 00078 * 00079 * @return void 00080 */ 00081 public function init() { 00082 // set the GPvars from outside 00083 $this->file = t3lib_div::_GP('file'); 00084 $this->CB = t3lib_div::_GP('CB'); 00085 $this->overwriteExistingFiles = t3lib_div::_GP('overwriteExistingFiles'); 00086 $this->vC = t3lib_div::_GP('vC'); 00087 $this->redirect = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('redirect')); 00088 00089 $this->initClipboard(); 00090 } 00091 00092 /** 00093 * Initialize the Clipboard. This will fetch the data about files to paste/delete if such an action has been sent. 00094 * 00095 * @return void 00096 */ 00097 public function initClipboard() { 00098 if (is_array($this->CB)) { 00099 $clipObj = t3lib_div::makeInstance('t3lib_clipboard'); 00100 $clipObj->initializeClipboard(); 00101 if ($this->CB['paste']) { 00102 $clipObj->setCurrentPad($this->CB['pad']); 00103 $this->file = $clipObj->makePasteCmdArray_file($this->CB['paste'], $this->file); 00104 } 00105 if ($this->CB['delete']) { 00106 $clipObj->setCurrentPad($this->CB['pad']); 00107 $this->file = $clipObj->makeDeleteCmdArray_file($this->file); 00108 } 00109 } 00110 } 00111 00112 /** 00113 * Performing the file admin action: 00114 * Initializes the objects, setting permissions, sending data to object. 00115 * 00116 * @return void 00117 */ 00118 public function main() { 00119 // Initializing: 00120 $this->fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions'); 00121 $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']); 00122 $this->fileProcessor->init_actionPerms($GLOBALS['BE_USER']->getFileoperationPermissions()); 00123 $this->fileProcessor->dontCheckForUnique = ($this->overwriteExistingFiles ? 1 : 0); 00124 00125 // Checking referer / executing: 00126 $refInfo = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER')); 00127 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY'); 00128 if ($httpHost != $refInfo['host'] 00129 && $this->vC != $GLOBALS['BE_USER']->veriCode() 00130 && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer'] 00131 && $GLOBALS['CLIENT']['BROWSER'] != 'flash') { 00132 $this->fileProcessor->writeLog(0, 2, 1, 'Referer host "%s" and server host "%s" did not match!', array($refInfo['host'], $httpHost)); 00133 } else { 00134 $this->fileProcessor->start($this->file); 00135 $this->fileData = $this->fileProcessor->processData(); 00136 } 00137 } 00138 00139 /** 00140 * Redirecting the user after the processing has been done. 00141 * Might also display error messages directly, if any. 00142 * 00143 * @return void 00144 */ 00145 public function finish() { 00146 // Prints errors, if there are any 00147 $this->fileProcessor->printLogErrorMessages($this->redirect); 00148 t3lib_BEfunc::setUpdateSignal('updateFolderTree'); 00149 if ($this->redirect) { 00150 t3lib_utility_Http::redirect($this->redirect); 00151 } 00152 } 00153 00154 /** 00155 * Handles the actual process from within the ajaxExec function 00156 * therefore, it does exactly the same as the real typo3/tce_file.php 00157 * but without calling the "finish" method, thus makes it simpler to deal with the 00158 * actual return value 00159 * 00160 * 00161 * @param string $params always empty. 00162 * @param string $ajaxObj The Ajax object used to return content and set content types 00163 * @return void 00164 */ 00165 public function processAjaxRequest(array $params, TYPO3AJAX $ajaxObj) { 00166 $this->init(); 00167 $this->main(); 00168 $errors = $this->fileProcessor->getErrorMessages(); 00169 if (count($errors)) { 00170 $ajaxObj->setError(implode(',', $errors)); 00171 } else { 00172 $ajaxObj->addContent('result', $this->fileData); 00173 if ($this->redirect) { 00174 $ajaxObj->addContent('redirect', $this->redirect); 00175 } 00176 $ajaxObj->setContentFormat('json'); 00177 } 00178 } 00179 } 00180 00181 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/classes/class.typo3_tcefile.php'])) { 00182 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/classes/class.typo3_tcefile.php']); 00183 } 00184 00185 ?>
1.8.0