2 /***************************************************************
5 * (c) 1999-2003 Kasper Skaarhoj (kasper@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 * Web>File: Upload of files
32 * @author Kasper Skaarhoj <kasper@typo3.com>
35 * [CLASS/FUNCTION INDEX of SCRIPT]
39 * 77: class SC_file_upload
41 * 149: function main()
42 * 182: function printContent()
45 * (This index is automatically created/updated by the extension "extdeveval")
53 require ('template.php');
54 include ('sysext/lang/locallang_misc.php');
55 require_once (PATH_t3lib
.'class.t3lib_basicfilefunc.php');
73 * @author Kasper Skaarhoj <kasper@typo3.com>
77 class SC_file_upload
{
93 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
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"]);
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!","");
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;
112 $this->shortPath
= substr($this->target
,strlen($GLOBALS["FILEMOUNTS"][$key]["path"]));
113 $this->title
= $GLOBALS["FILEMOUNTS"][$key]["name"].": ".$this->shortPath
;
118 // ***************************
119 // Setting template object
120 // ***************************
121 $this->doc
= t3lib_div
::makeInstance("smallDoc");
122 $this->doc
->backPath
= $BACK_PATH;
125 <script language="javascript" type="text/javascript">
126 var path = "'.$this->target
.'";
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;
134 function backToList() { //
135 top.goToModule("file_list");
141 $this->doc
->form
='<form action="tce_file.php" method="POST" name="editform" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'">';
145 * [Describe function...]
150 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
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);
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>';
166 $code.='</select><BR><BR>';
168 $code.='<input type="checkbox" name="overwriteExistingFiles" value="1"> '.$LANG->getLL("overwriteExistingFiles")."<BR>";
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>';
173 $code.='<BR><input type="Submit" value="'.$LANG->sL("LLL:EXT:lang/locallang_core.php:file_upload.php.submit").'"> <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);
178 * [Describe function...]
182 function printContent() {
183 $this->content
.= $this->doc
->spacer(10);
184 $this->content
.= $this->doc
->middle();
185 $this->content
.= $this->doc
->endPage();
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"]);
207 $SOBE = t3lib_div
::makeInstance("SC_file_upload");
210 $SOBE->printContent();