2 /***************************************************************
5 * (c) 1999-2003 Kasper Skårhøj (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
30 * @author Kasper Skårhøj <kasper@typo3.com>
39 require ("template.php");
40 include ("sysext/lang/locallang_misc.php");
41 require_once (PATH_t3lib
."class.t3lib_basicfilefunc.php");
44 // ***************************
46 // ***************************
47 class SC_file_upload
{
60 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
62 $this->number
= t3lib_div
::GPvar("number");
63 $this->target
= t3lib_div
::GPvar("target");
64 $this->basicff
= t3lib_div
::makeInstance("t3lib_basicFileFunctions");
65 $this->basicff
->init($GLOBALS["FILEMOUNTS"],$TYPO3_CONF_VARS["BE"]["fileExtensions"]);
67 $this->target
=$this->basicff
->is_directory($this->target
); // Cleaning and checking target
68 $key=$this->basicff
->checkPathAgainstMounts($this->target
."/");
69 if (!$this->target ||
!$key) {
70 t3lib_BEfunc
::typo3PrintError ("Parameter Error","Target was not a directory!","");
74 switch($GLOBALS["FILEMOUNTS"][$key]["type"]) {
75 case "user": $this->icon
= "gfx/i/_icon_ftp_user.gif"; break;
76 case "group": $this->icon
= "gfx/i/_icon_ftp_group.gif"; break;
77 default: $this->icon
= "gfx/i/_icon_ftp.gif"; break;
79 $this->shortPath
= substr($this->target
,strlen($GLOBALS["FILEMOUNTS"][$key]["path"]));
80 $this->title
= $GLOBALS["FILEMOUNTS"][$key]["name"].": ".$this->shortPath
;
85 // ***************************
86 // Setting template object
87 // ***************************
88 $this->doc
= t3lib_div
::makeInstance("smallDoc");
89 $this->doc
->backPath
= $BACK_PATH;
92 <script language="javascript" type="text/javascript">
93 var path = "'.$this->target
.'";
96 if (!changed || (changed && confirm("'.$LANG->sL("LLL:EXT:lang/locallang_core.php:mess.redraw").'"))) {
97 var params = "&target="+escape(path)+"&number="+a;
98 document.location = "file_upload.php?"+params;
101 function backToList() {
102 top.goToModule("file_list");
108 $this->doc
->form
='<form action="tce_file.php" method="POST" name="editform" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'">';
111 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
114 $this->content
.=$this->doc
->startPage($LANG->sL("LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle"));
115 $this->content
.=$this->doc
->header($LANG->sL("LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle"));
116 $this->content
.=$this->doc
->spacer(5);
117 $this->content
.=$this->doc
->section('',$this->doc
->getFileheader($this->title
,$this->shortPath
,$this->icon
));
118 $this->content
.=$this->doc
->divider(5);
121 // making the selector box
122 $this->number
= t3lib_div
::intInRange($this->number
,1,10);
123 $code='<select name="number" onChange="reload(this.options[this.selectedIndex].value);">';
124 for ($a=1;$a<=$this->uploadNumber
;$a++
) {
125 $code.='<option value="'.$a.'"'.($this->number
==$a?
' selected':'').'>'.$a.' '.$LANG->sL("LLL:EXT:lang/locallang_core.php:file_upload.php.files").'</option>';
127 $code.='</select><BR><BR>';
129 $code.='<input type="checkbox" name="overwriteExistingFiles" value="1"> '.$LANG->getLL("overwriteExistingFiles")."<BR>";
131 for ($a=0;$a<$this->number
;$a++
) {
132 $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>';
134 $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;">';
135 $this->content
.= $this->doc
->section("",$code);
137 function printContent() {
140 $this->content
.= $this->doc
->spacer(10);
141 $this->content
.= $this->doc
->middle();
142 $this->content
.= $this->doc
->endPage();
146 // ***************************
148 // ***************************
151 // Include extension?
152 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE
]["XCLASS"]["typo3/file_upload.php"]) {
153 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]["XCLASS"]["typo3/file_upload.php"]);
168 $SOBE = t3lib_div
::makeInstance("SC_file_upload");
171 $SOBE->printContent();