Added $Id$ keywords, cleaned up comment tags
[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 * @author Kasper Skaarhoj <kasper@typo3.com>
31 * @package TYPO3
32 * @subpackage core
33 *
34 */
35
36
37 $BACK_PATH="";
38 require ("init.php");
39 require ("template.php");
40 include ("sysext/lang/locallang_misc.php");
41 require_once (PATH_t3lib."class.t3lib_basicfilefunc.php");
42
43
44 // ***************************
45 // Script Classes
46 // ***************************
47 class SC_file_upload {
48 var $content;
49 var $number;
50 var $uploadNumber=10;
51
52 var $basicff;
53 var $shortPath;
54 var $title;
55 var $icon;
56 var $target;
57 var $doc;
58
59 function init() {
60 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
61
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"]);
66
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!","");
71 exit;
72 }
73 // Finding the icon
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;
78 }
79 $this->shortPath = substr($this->target,strlen($GLOBALS["FILEMOUNTS"][$key]["path"]));
80 $this->title = $GLOBALS["FILEMOUNTS"][$key]["name"].": ".$this->shortPath;
81
82
83
84
85 // ***************************
86 // Setting template object
87 // ***************************
88 $this->doc = t3lib_div::makeInstance("smallDoc");
89 $this->doc->backPath = $BACK_PATH;
90
91 $this->doc->JScode='
92 <script language="javascript" type="text/javascript">
93 var path = "'.$this->target.'";
94
95 function reload(a) {
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;
99 }
100 }
101 function backToList() {
102 top.goToModule("file_list");
103 }
104 var changed = 0;
105
106 </script>
107 ';
108 $this->doc->form='<form action="tce_file.php" method="POST" name="editform" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'">';
109 }
110 function main() {
111 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
112
113 $this->content="";
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);
119
120
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>';
126 }
127 $code.='</select><BR><BR>';
128
129 $code.='<input type="checkbox" name="overwriteExistingFiles" value="1"> '.$LANG->getLL("overwriteExistingFiles")."<BR>";
130
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>';
133 }
134 $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;">';
135 $this->content.= $this->doc->section("",$code);
136 }
137 function printContent() {
138 global $SOBE;
139
140 $this->content.= $this->doc->spacer(10);
141 $this->content.= $this->doc->middle();
142 $this->content.= $this->doc->endPage();
143 echo $this->content;
144 }
145
146 // ***************************
147 // OTHER FUNCTIONS:
148 // ***************************
149 }
150
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"]);
154 }
155
156
157
158
159
160
161
162
163
164
165
166
167 // Make instance:
168 $SOBE = t3lib_div::makeInstance("SC_file_upload");
169 $SOBE->init();
170 $SOBE->main();
171 $SOBE->printContent();
172 ?>