00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00052 $BACK_PATH = '';
00053 require('init.php');
00054 require('template.php');
00055 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
00056 require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00077 class SC_file_upload {
00078
00079
00080 var $uploadNumber=10;
00081
00082
00083 var $doc;
00084 var $basicff;
00085 var $icon;
00086 var $shortPath;
00087 var $title;
00088
00089
00090 var $number;
00091 var $target;
00092 var $returnUrl;
00093
00094
00095 var $content;
00096
00097
00103 function init() {
00104 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
00105
00106
00107 $this->number = t3lib_div::_GP('number');
00108 $this->target = t3lib_div::_GP('target');
00109 $this->returnUrl = t3lib_div::_GP('returnUrl');
00110
00111 if (empty($this->number)) {
00112 $defaultFileUploads = $GLOBALS['BE_USER']->getTSConfigVal('options.defaultFileUploads');
00113 if ($defaultFileUploads) {
00114 $this->number = t3lib_div::intInRange($defaultFileUploads,1,$this->uploadNumber);
00115 }
00116 }
00117
00118 $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00119 $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
00120
00121
00122 $this->target=$this->basicff->is_directory($this->target);
00123 $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
00124 if (!$this->target || !$key) {
00125 t3lib_BEfunc::typo3PrintError ('Parameter Error','Target was not a directory!','');
00126 exit;
00127 }
00128
00129
00130 switch($GLOBALS['FILEMOUNTS'][$key]['type']) {
00131 case 'user': $this->icon = 'gfx/i/_icon_ftp_user.gif'; break;
00132 case 'group': $this->icon = 'gfx/i/_icon_ftp_group.gif'; break;
00133 default: $this->icon = 'gfx/i/_icon_ftp.gif'; break;
00134 }
00135
00136
00137 $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
00138
00139
00140 $this->title = $GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath;
00141
00142
00143 $this->doc = t3lib_div::makeInstance('smallDoc');
00144 $this->doc->docType = 'xhtml_trans';
00145 $this->doc->backPath = $BACK_PATH;
00146 $this->doc->form='<form action="tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">';
00147
00148 if($GLOBALS['BE_USER']->jsConfirmation(1)) {
00149 $confirm = ' && confirm('.$LANG->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')).')';
00150 } else {
00151 $confirm = '';
00152 }
00153 $this->doc->JScode=$this->doc->wrapScriptTags('
00154 var path = "'.$this->target.'";
00155
00156 function reload(a) {
00157 if (!changed || (changed '.$confirm.')) {
00158 var params = "&target="+escape(path)+"&number="+a+"&returnUrl='.htmlspecialchars($this->returnUrl).'";
00159 window.location.href = "file_upload.php?"+params;
00160 }
00161 }
00162 function backToList() {
00163 top.goToModule("file_list");
00164 }
00165 var changed = 0;
00166 ');
00167 }
00168
00174 function main() {
00175 global $LANG;
00176
00177
00178 $this->content='';
00179 $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle'));
00180 $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle'));
00181 $this->content.=$this->doc->spacer(5);
00182 $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon));
00183 $this->content.=$this->doc->divider(5);
00184
00185
00186
00187 $this->number = t3lib_div::intInRange($this->number,1,10);
00188 $code='
00189 <div id="c-select">
00190 <select name="number" onchange="reload(this.options[this.selectedIndex].value);">';
00191 for ($a=1;$a<=$this->uploadNumber;$a++) {
00192 $code.='
00193 <option value="'.$a.'"'.($this->number==$a?' selected="selected"':'').'>'.$a.' '.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.files',1).'</option>';
00194 }
00195 $code.='
00196 </select>
00197 </div>
00198 ';
00199
00200
00201 $code.='
00202 <div id="c-override">
00203 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$LANG->getLL('overwriteExistingFiles',1).'</label>
00204 </div>
00205 ';
00206
00207
00208 $code.='
00209 <div id="c-upload">
00210 ';
00211 for ($a=0;$a<$this->number;$a++) {
00212
00213 $code.='
00214 <input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" onclick="changed=1;" />
00215 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($this->target).'" />
00216 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />
00217 ';
00218 }
00219 $code.='
00220 </div>
00221 ';
00222
00223
00224 $code.='
00225 <div id="c-submit">
00226 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />
00227 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
00228 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
00229 </div>
00230 ';
00231
00232
00233 $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_upload', $GLOBALS['BACK_PATH'],'<br/>');
00234
00235
00236 $this->content.= $this->doc->section('',$code);
00237 }
00238
00244 function printContent() {
00245 $this->content.= $this->doc->endPage();
00246 $this->content = $this->doc->insertStylesAndJS($this->content);
00247 echo $this->content;
00248 }
00249 }
00250
00251
00252 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_upload.php']) {
00253 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_upload.php']);
00254 }
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 $SOBE = t3lib_div::makeInstance('SC_file_upload');
00269 $SOBE->init();
00270 $SOBE->main();
00271 $SOBE->printContent();
00272 ?>