2 /***************************************************************
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Gateway for TCE (TYPO3 Core Engine) file-handling through POST forms.
29 * This script serves as the fileadministration part of the TYPO3 Core Engine.
30 * Basically it includes two libraries which are used to manipulate files on the server.
32 * For syntax and API information, see the document 'TYPO3 Core APIs'
35 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
37 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
40 * [CLASS/FUNCTION INDEX of SCRIPT]
44 * 77: class SC_tce_file
46 * 117: function initClipboard()
47 * 138: function main()
48 * 164: function finish()
51 * (This index is automatically created/updated by the extension "extdeveval")
56 require ('template.php');
57 require_once (PATH_t3lib
.'class.t3lib_basicfilefunc.php');
58 require_once (PATH_t3lib
.'class.t3lib_extfilefunc.php');
71 * Script Class, handling the calling of methods in the file admin classes.
73 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
79 // Internal, static: GPvar:
80 var $file; // Array of file-operations.
81 var $redirect; // Redirect URL
82 var $CB; // Clipboard operations array
83 var $overwriteExistingFiles; // If existing files should be overridden.
84 var $vC; // VeriCode - a hash of server specific value and other things which identifies if a submission is OK. (see $BE_USER->veriCode())
87 var $include_once=array(); // Used to set the classes to include after the init() function is called.
88 var $fileProcessor; // File processor object
93 * Registering Incoming data
100 $this->file
= t3lib_div
::_GP('file');
101 $this->redirect
= t3lib_div
::_GP('redirect');
102 $this->CB
= t3lib_div
::_GP('CB');
103 $this->overwriteExistingFiles
= t3lib_div
::_GP('overwriteExistingFiles');
104 $this->vC
= t3lib_div
::_GP('vC');
106 // If clipboard is set, then include the clipboard class:
107 if (is_array($this->CB
)) {
108 $this->include_once[] = PATH_t3lib
.'class.t3lib_clipboard.php';
113 * Initialize the Clipboard. This will fetch the data about files to paste/delete if such an action has been sent.
117 function initClipboard() {
118 if (is_array($this->CB
)) {
119 $clipObj = t3lib_div
::makeInstance('t3lib_clipboard');
120 $clipObj->initializeClipboard();
121 if ($this->CB
['paste']) {
122 $clipObj->setCurrentPad($this->CB
['pad']);
123 $this->file
= $clipObj->makePasteCmdArray_file($this->CB
['paste'],$this->file
);
125 if ($this->CB
['delete']) {
126 $clipObj->setCurrentPad($this->CB
['pad']);
127 $this->file
= $clipObj->makeDeleteCmdArray_file($this->file
);
133 * Performing the file admin action:
134 * Initializes the objects, setting permissions, sending data to object.
139 global $FILEMOUNTS,$TYPO3_CONF_VARS,$BE_USER;
142 $this->fileProcessor
= t3lib_div
::makeInstance('t3lib_extFileFunctions');
143 $this->fileProcessor
->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
144 $this->fileProcessor
->init_actionPerms($BE_USER->user
['fileoper_perms']);
145 $this->fileProcessor
->dontCheckForUnique
= $this->overwriteExistingFiles ?
1 : 0;
147 // Checking referer / executing:
148 $refInfo = parse_url(t3lib_div
::getIndpEnv('HTTP_REFERER'));
149 $httpHost = t3lib_div
::getIndpEnv('TYPO3_HOST_ONLY');
150 if ($httpHost!=$refInfo['host'] && $this->vC
!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) {
151 $this->fileProcessor
->writeLog(0,2,1,'Referer host "%s" and server host "%s" did not match!',array($refInfo['host'],$httpHost));
153 $this->fileProcessor
->start($this->file
);
154 $this->fileProcessor
->processData();
159 * Redirecting the user after the processing has been done.
160 * Might also display error messages directly, if any.
165 // Prints errors, if...
166 $this->fileProcessor
->printLogErrorMessages($this->redirect
);
168 t3lib_BEfunc
::getSetUpdateSignal('updateFolderTree');
169 if ($this->redirect
) {
170 Header('Location: '.t3lib_div
::locationHeaderUrl($this->redirect
));
175 // Include extension?
176 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/tce_file.php']) {
177 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/tce_file.php']);
192 $SOBE = t3lib_div
::makeInstance('SC_tce_file');
196 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
198 $SOBE->initClipboard();