Added more comments, $Id$ keywords etc for the whole core of TYPO3.
[Packages/TYPO3.CMS.git] / typo3 / file_upload.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 * Web>File: Upload of files
29 *
30 * $Id$
31 *
32 * @author Kasper Skaarhoj <kasper@typo3.com>
33 */
34 /**
35 * [CLASS/FUNCTION INDEX of SCRIPT]
36 *
37 *
38 *
39 * 77: class SC_file_upload
40 * 92: function init()
41 * 149: function main()
42 * 182: function printContent()
43 *
44 * TOTAL FUNCTIONS: 3
45 * (This index is automatically created/updated by the extension "extdeveval")
46 *
47 */
48
49
50
51 $BACK_PATH='';
52 require ('init.php');
53 require ('template.php');
54 include ('sysext/lang/locallang_misc.php');
55 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 /**
71 * Script Class
72 *
73 * @author Kasper Skaarhoj <kasper@typo3.com>
74 * @package TYPO3
75 * @subpackage core
76 */
77 class SC_file_upload {
78 var $content;
79 var $number;
80 var $uploadNumber=10;
81
82 var $basicff;
83 var $shortPath;
84 var $title;
85 var $icon;
86 var $target;
87 var $doc;
88
89 /**
90 * @return [type] ...
91 */
92 function init() {
93 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
94
95 $this->number = t3lib_div::GPvar("number");
96 $this->target = t3lib_div::GPvar("target");
97 $this->basicff = t3lib_div::makeInstance("t3lib_basicFileFunctions");
98 $this->basicff->init($GLOBALS["FILEMOUNTS"],$TYPO3_CONF_VARS["BE"]["fileExtensions"]);
99
100 $this->target=$this->basicff->is_directory($this->target); // Cleaning and checking target
101 $key=$this->basicff->checkPathAgainstMounts($this->target."/");
102 if (!$this->target || !$key) {
103 t3lib_BEfunc::typo3PrintError ("Parameter Error","Target was not a directory!","");
104 exit;
105 }
106 // Finding the icon
107 switch($GLOBALS["FILEMOUNTS"][$key]["type"]) {
108 case "user": $this->icon = "gfx/i/_icon_ftp_user.gif"; break;
109 case "group": $this->icon = "gfx/i/_icon_ftp_group.gif"; break;
110 default: $this->icon = "gfx/i/_icon_ftp.gif"; break;
111 }
112 $this->shortPath = substr($this->target,strlen($GLOBALS["FILEMOUNTS"][$key]["path"]));
113 $this->title = $GLOBALS["FILEMOUNTS"][$key]["name"].": ".$this->shortPath;
114
115
116
117
118 // ***************************
119 // Setting template object
120 // ***************************
121 $this->doc = t3lib_div::makeInstance("smallDoc");
122 $this->doc->backPath = $BACK_PATH;
123
124 $this->doc->JScode='
125 <script language="javascript" type="text/javascript">
126 var path = "'.$this->target.'";
127
128 function reload(a) { //
129 if (!changed || (changed && confirm("'.$LANG->sL("LLL:EXT:lang/locallang_core.php:mess.redraw").'"))) {
130 var params = "&target="+escape(path)+"&number="+a;
131 document.location = "file_upload.php?"+params;
132 }
133 }
134 function backToList() { //
135 top.goToModule("file_list");
136 }
137 var changed = 0;
138
139 </script>
140 ';
141 $this->doc->form='<form action="tce_file.php" method="POST" name="editform" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'">';
142 }
143
144 /**
145 * [Describe function...]
146 *
147 * @return [type] ...
148 */
149 function main() {
150 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
151
152 $this->content="";
153 $this->content.=$this->doc->startPage($LANG->sL("LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle"));
154 $this->content.=$this->doc->header($LANG->sL("LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle"));
155 $this->content.=$this->doc->spacer(5);
156 $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon));
157 $this->content.=$this->doc->divider(5);
158
159
160 // making the selector box
161 $this->number = t3lib_div::intInRange($this->number,1,10);
162 $code='<select name="number" onChange="reload(this.options[this.selectedIndex].value);">';
163 for ($a=1;$a<=$this->uploadNumber;$a++) {
164 $code.='<option value="'.$a.'"'.($this->number==$a?' selected':'').'>'.$a.' '.$LANG->sL("LLL:EXT:lang/locallang_core.php:file_upload.php.files").'</option>';
165 }
166 $code.='</select><BR><BR>';
167
168 $code.='<input type="checkbox" name="overwriteExistingFiles" value="1"> '.$LANG->getLL("overwriteExistingFiles")."<BR>";
169
170 for ($a=0;$a<$this->number;$a++) {
171 $code.='<input type="File" name="upload_'.$a.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(35).' onClick="changed=1;"><input type="Hidden" name="file[upload]['.$a.'][target]" value="'.$this->target.'"><input type="Hidden" name="file[upload]['.$a.'][data]" value="'.$a.'"><BR>';
172 }
173 $code.='<BR><input type="Submit" value="'.$LANG->sL("LLL:EXT:lang/locallang_core.php:file_upload.php.submit").'">&nbsp;&nbsp;<input type="Submit" value="'.$LANG->sL("LLL:EXT:lang/locallang_core.php:labels.cancel").'" onClick="backToList(); return false;">';
174 $this->content.= $this->doc->section("",$code);
175 }
176
177 /**
178 * [Describe function...]
179 *
180 * @return [type] ...
181 */
182 function printContent() {
183 $this->content.= $this->doc->spacer(10);
184 $this->content.= $this->doc->middle();
185 $this->content.= $this->doc->endPage();
186 echo $this->content;
187 }
188 }
189
190 // Include extension?
191 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/file_upload.php"]) {
192 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/file_upload.php"]);
193 }
194
195
196
197
198
199
200
201
202
203
204
205
206 // Make instance:
207 $SOBE = t3lib_div::makeInstance("SC_file_upload");
208 $SOBE->init();
209 $SOBE->main();
210 $SOBE->printContent();
211 ?>