Added more comments, $Id$ keywords etc for the whole core of TYPO3.
[Packages/TYPO3.CMS.git] / typo3 / tce_file.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
6 * All rights reserved
7 *
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.
13 *
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.
18 *
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
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.
31 *
32 * For syntax and API information, see the document 'TYPO3 Core APIs'
33 *
34 * $Id$
35 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
36 *
37 * @author Kasper Skaarhoj <kasper@typo3.com>
38 */
39 /**
40 * [CLASS/FUNCTION INDEX of SCRIPT]
41 *
42 *
43 *
44 * 77: class SC_tce_file
45 * 88: function init()
46 * 103: function initClipboard()
47 * 124: function main()
48 * 157: function finish()
49 *
50 * TOTAL FUNCTIONS: 4
51 * (This index is automatically created/updated by the extension "extdeveval")
52 *
53 */
54
55 require ('init.php');
56 require ('template.php');
57 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
58 require_once (PATH_t3lib.'class.t3lib_extfilefunc.php');
59
60
61
62
63
64
65
66
67
68
69
70 /**
71 * Script Class, handling the calling of methods in the file admin classes.
72 *
73 * @author Kasper Skaarhoj <kasper@typo3.com>
74 * @package TYPO3
75 * @subpackage core
76 */
77 class SC_tce_file {
78 var $include_once=array();
79 var $CB;
80 var $file;
81 var $redirect;
82
83 /**
84 * Registering Incoming data
85 *
86 * @return void
87 */
88 function init() {
89 $this->file = t3lib_div::GPvar('file');
90 $this->redirect = t3lib_div::GPvar('redirect');
91
92 $this->CB = t3lib_div::GPvar('CB');
93 if (is_array($this->CB)) {
94 $this->include_once[]=PATH_t3lib.'class.t3lib_clipboard.php';
95 }
96 }
97
98 /**
99 * Initialize the Clipboard. This will fetch the data about files to paste/delete if such an action has been sent.
100 *
101 * @return void
102 */
103 function initClipboard() {
104 if (is_array($this->CB)) {
105 $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
106 $clipObj->initializeClipboard();
107 if ($this->CB['paste']) {
108 $clipObj->setCurrentPad($this->CB['pad']);
109 $this->file = $clipObj->makePasteCmdArray_file($this->CB['paste'],$this->file);
110 }
111 if ($this->CB['delete']) {
112 $clipObj->setCurrentPad($this->CB['pad']);
113 $this->file = $clipObj->makeDeleteCmdArray_file($this->file);
114 }
115 }
116 }
117
118 /**
119 * Performing the file admin action:
120 * Initializes the objects, setting permissions, sending data to object.
121 *
122 * @return void
123 */
124 function main() {
125 global $FILEMOUNTS,$TYPO3_CONF_VARS,$BE_USER;
126
127 // *********************************
128 // Initializing
129 // *********************************
130 $fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
131 $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
132 $fileProcessor->init_actionPerms($BE_USER->user['fileoper_perms']);
133 $fileProcessor->dontCheckForUnique = t3lib_div::GPvar('overwriteExistingFiles') ? 1 : 0;
134
135 // ***************************
136 // Checking referer / executing
137 // ***************************
138 $refInfo=parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
139 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
140 if ($httpHost!=$refInfo['host'] && t3lib_div::GPvar('vC')!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) {
141 $fileProcessor->writeLog(0,2,1,'Referer host "%s" and server host "%s" did not match!',array($refInfo['host'],$httpHost));
142 } else {
143 $fileProcessor->start($this->file);
144 $fileProcessor->processData();
145 }
146
147 if (!$this->redirect) {
148 $this->redirect = 'status_file.php';
149 }
150 }
151
152 /**
153 * Redirecting to the status script for files.
154 *
155 * @return void
156 */
157 function finish() {
158 Header('Location: '.t3lib_div::locationHeaderUrl($this->redirect));
159
160 echo '
161 <script type="text/javascript">
162 if (confirm(\'System Error:\n\n Some error happend in tce_file.php. Continue?\')) {
163 document.location = \''.$this->redirect.'\';
164 }
165 </script>
166 ';
167 }
168 }
169
170 // Include extension?
171 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/tce_file.php']) {
172 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/tce_file.php']);
173 }
174
175
176
177
178
179
180
181
182
183
184
185
186 // Make instance:
187 $SOBE = t3lib_div::makeInstance('SC_tce_file');
188 $SOBE->init();
189
190 // Include files?
191 reset($SOBE->include_once);
192 while(list(,$INC_FILE)=each($SOBE->include_once)) {include_once($INC_FILE);}
193
194 $SOBE->initClipboard();
195 $SOBE->main();
196 $SOBE->finish();
197 ?>