"TYPO3 4.0.1: typo3_src-4.0.1/typo3/tce_file.php Source File", "datetime" => "Sat Dec 2 19:22:35 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

tce_file.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00055 require ('init.php');
00056 require ('template.php');
00057 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
00058 require_once (PATH_t3lib.'class.t3lib_extfilefunc.php');
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00077 class SC_tce_file {
00078 
00079                 // Internal, static: GPvar:
00080         var $file;                                              // Array of file-operations.
00081         var $redirect;                                  // Redirect URL
00082         var $CB;                                                // Clipboard operations array
00083         var $overwriteExistingFiles;    // If existing files should be overridden.
00084         var $vC;                                                // VeriCode - a hash of server specific value and other things which identifies if a submission is OK. (see $BE_USER->veriCode())
00085 
00086                 // Internal, dynamic:
00087         var $include_once=array();              // Used to set the classes to include after the init() function is called.
00088         var $fileProcessor;                             // File processor object
00089 
00090 
00091 
00097         function init() {
00098 
00099                         // GPvars:
00100                 $this->file = t3lib_div::_GP('file');
00101                 $this->redirect = t3lib_div::_GP('redirect');
00102                 $this->CB = t3lib_div::_GP('CB');
00103                 $this->overwriteExistingFiles = t3lib_div::_GP('overwriteExistingFiles');
00104                 $this->vC = t3lib_div::_GP('vC');
00105 
00106                         // If clipboard is set, then include the clipboard class:
00107                 if (is_array($this->CB))        {
00108                         $this->include_once[] = PATH_t3lib.'class.t3lib_clipboard.php';
00109                 }
00110         }
00111 
00117         function initClipboard()        {
00118                 if (is_array($this->CB))        {
00119                         $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
00120                         $clipObj->initializeClipboard();
00121                         if ($this->CB['paste']) {
00122                                 $clipObj->setCurrentPad($this->CB['pad']);
00123                                 $this->file = $clipObj->makePasteCmdArray_file($this->CB['paste'],$this->file);
00124                         }
00125                         if ($this->CB['delete'])        {
00126                                 $clipObj->setCurrentPad($this->CB['pad']);
00127                                 $this->file = $clipObj->makeDeleteCmdArray_file($this->file);
00128                         }
00129                 }
00130         }
00131 
00138         function main() {
00139                 global $FILEMOUNTS,$TYPO3_CONF_VARS,$BE_USER;
00140 
00141                         // Initializing:
00142                 $this->fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
00143                 $this->fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
00144                 $this->fileProcessor->init_actionPerms($BE_USER->user['fileoper_perms']);
00145                 $this->fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0;
00146 
00147                         // Checking referer / executing:
00148                 $refInfo = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
00149                 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
00150                 if ($httpHost!=$refInfo['host'] && $this->vC!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer'])    {
00151                         $this->fileProcessor->writeLog(0,2,1,'Referer host "%s" and server host "%s" did not match!',array($refInfo['host'],$httpHost));
00152                 } else {
00153                         $this->fileProcessor->start($this->file);
00154                         $this->fileProcessor->processData();
00155                 }
00156         }
00157 
00164         function finish()       {
00165                         // Prints errors, if...
00166                 $this->fileProcessor->printLogErrorMessages($this->redirect);
00167 
00168                 t3lib_BEfunc::getSetUpdateSignal('updateFolderTree');
00169                 if ($this->redirect) {
00170                         Header('Location: '.t3lib_div::locationHeaderUrl($this->redirect));
00171                 }
00172         }
00173 }
00174 
00175 // Include extension?
00176 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/tce_file.php'])      {
00177         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/tce_file.php']);
00178 }
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 // Make instance:
00192 $SOBE = t3lib_div::makeInstance('SC_tce_file');
00193 $SOBE->init();
00194 
00195 // Include files?
00196 foreach($SOBE->include_once as $INC_FILE)       include_once($INC_FILE);
00197 
00198 $SOBE->initClipboard();
00199 $SOBE->main();
00200 $SOBE->finish();
00201 ?>