- Timestamp:
- 11/13/08 22:03:46 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
downloadDatabase/files/lib/acp/form/DownloadDBDataAddForm.class.php
r668 r715 4 4 require_once(WCF_DIR.'lib/data/downloadDB/DownloadDBDataEditor.class.php'); 5 5 require_once(WCF_DIR.'lib/system/io/Tar.class.php'); 6 require_once(WCF_DIR.'lib/acp/form/ACPForm.class.php'); 6 7 7 8 … … 41 42 public $supportThread = ''; 42 43 public $activ = 0; 44 public $linkType = 0; 43 45 public $isExtern = false; 44 46 public $languageID = '1'; … … 76 78 if (isset($_POST['activ'])) $this->activ = intval($_POST['activ']); 77 79 if (isset($_POST['languageID'])) $this->languageID = intval($_POST['languageID']); 80 if (isset($_POST['linkType'])) $this->linkType = intval($_POST['linkType']); 78 81 // for File Upload 79 82 if (isset($_FILES['upload'])) $this->upload = $_FILES['upload']; … … 96 99 throw new UserInputException('katID', 'invalid'); 97 100 } 98 // prÃŒfen ob ein Linkeingegeben wurde99 if ( empty($this->upload) && empty($this->link)) {100 throw new UserInputException(' link', 'empty');101 // prÃŒfen ob ein Upload eingegeben wurde 102 if ($this->linkType == 0 && empty($this->upload) && $this->action == "add") { 103 throw new UserInputException('upload', 'empty'); 101 104 } 102 105 // prÃŒfen ob ein relativer Pfad eingegeben wurde 103 if ($this->link && (FileUtil::isURL($this->link) == false)) {106 if ($this->linkType == 1 && $this->link && (FileUtil::isURL($this->link) == false)) { 104 107 if ($this->link{0} == "/"){ 105 108 if (@fopen($_SERVER['DOCUMENT_ROOT'].$this->link,'rb') == false) { 106 109 throw new UserInputException('link', 'badFile'); 107 110 } 111 } else { 112 throw new UserInputException('link', 'invalid'); 108 113 } 109 114 } 110 // Only if Action = add 111 if ($this->action == 'add') { 112 // prÃŒfen ob ein Link UND File angegeben wurden 113 if ($this->link && ($this->upload && $this->upload['error'] != 4)) { 115 // prÃŒfen ob ein externer Link eingegeben wurde 116 if ($this->linkType == 2 && $this->link && (FileUtil::isURL($this->link) == false)) { 114 117 throw new UserInputException('link', 'invalid'); 115 } 116 } 118 } 117 119 $this->valid = true; 118 120 } … … 122 124 */ 123 125 public function save() { 126 parent::save(); 124 127 //Create new Dataset with FileUpload 125 128 if ($this->valid && $this->action == 'add'){ 126 129 // upload file if given 127 if ( !$this->link) {130 if ($this->linkType == 0) { 128 131 if ($this->upload && $this->upload['error'] != 4) { 129 132 if ($this->upload['error'] != 0) { … … 136 139 throw new UserInputException('upload'); 137 140 } 138 } else {139 if (FileUtil::isURL($this->link) == false) {140 if ($this->link{0} == "/"){141 if (FileUtil::isURL($_SERVER['DOCUMENT_ROOT'].$this->link) == false) {142 if (StringUtil::indexOf($_SERVER['DOCUMENT_ROOT'].$this->link, '/') !== false) {143 $this->fileName = StringUtil::substring($_SERVER['DOCUMENT_ROOT'].$this->link, StringUtil::lastIndexOf($_SERVER['DOCUMENT_ROOT'].$this->link, '/') + 1);144 }145 if (StringUtil::indexOf($this->fileName, '.') !== false) {146 $this->fileExtension = StringUtil::toLowerCase(StringUtil::substring($this->fileName, StringUtil::lastIndexOf($this->fileName, '.') + 1));147 }148 $this->groesse = @filesize($_SERVER['DOCUMENT_ROOT'].$this->link);141 } 142 if ($this->linkType == 1) { 143 if ($this->link{0} == "/"){ 144 if (FileUtil::isURL($_SERVER['DOCUMENT_ROOT'].$this->link) == false) { 145 if (StringUtil::indexOf($_SERVER['DOCUMENT_ROOT'].$this->link, '/') !== false) { 146 $this->fileName = StringUtil::substring($_SERVER['DOCUMENT_ROOT'].$this->link, StringUtil::lastIndexOf($_SERVER['DOCUMENT_ROOT'].$this->link, '/') + 1); 147 } 148 if (StringUtil::indexOf($this->fileName, '.') !== false) { 149 $this->fileExtension = StringUtil::toLowerCase(StringUtil::substring($this->fileName, StringUtil::lastIndexOf($this->fileName, '.') + 1)); 150 } 151 $this->groesse = @filesize($_SERVER['DOCUMENT_ROOT'].$this->link); 149 152 // Funktioniert nur wenn "fileinfo" in php aktiviert ist!! 150 // $finfo = @finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension151 // $this->mimeType = @finfo_file($finfo, $_SERVER['DOCUMENT_ROOT'].$this->link);152 $this->mimeType = ''; /*#### Entfernen wenn fileinfo aktiv ist ###*/153 // $finfo = @finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension 154 // $this->mimeType = @finfo_file($finfo, $_SERVER['DOCUMENT_ROOT'].$this->link); 155 $this->mimeType = ''; /*#### Entfernen wenn fileinfo aktiv ist ###*/ 153 156 // daher ist $mimeType = ''; 154 157 } 155 } else {156 if (FileUtil::isURL($this->link) == false) {157 if (StringUtil::indexOf($this->link, '/') !== false) {158 $this->fileName = StringUtil::substring($this->link, StringUtil::lastIndexOf($this->link, '/') + 1);159 }160 if (StringUtil::indexOf($this->fileName, '.') !== false) {161 $this->fileExtension = StringUtil::toLowerCase(StringUtil::substring($this->fileName, StringUtil::lastIndexOf($this->fileName, '.') + 1));162 }163 $this->groesse = @filesize($this->link);164 $this->mimeType = '';158 } else { 159 if (FileUtil::isURL($this->link) == false) { 160 if (StringUtil::indexOf($this->link, '/') !== false) { 161 $this->fileName = StringUtil::substring($this->link, StringUtil::lastIndexOf($this->link, '/') + 1); 162 } 163 if (StringUtil::indexOf($this->fileName, '.') !== false) { 164 $this->fileExtension = StringUtil::toLowerCase(StringUtil::substring($this->fileName, StringUtil::lastIndexOf($this->fileName, '.') + 1)); 165 } 166 $this->groesse = @filesize($this->link); 167 $this->mimeType = ''; 165 168 // Funktioniert nur wenn "fileinfo" in php aktiviert ist!! 166 // $finfo = @finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension167 // $this->mimeType = @finfo_file($finfo, $_SERVER['DOCUMENT_ROOT'].$this->link);168 $this->mimeType = ''; /*#### Entfernen wenn fileinfo aktiv ist ###*/169 // $finfo = @finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension 170 // $this->mimeType = @finfo_file($finfo, $_SERVER['DOCUMENT_ROOT'].$this->link); 171 $this->mimeType = ''; /*#### Entfernen wenn fileinfo aktiv ist ###*/ 169 172 // daher ist $mimeType = ''; 170 }171 173 } 172 } else { 173 $this->fileName = $this->fileExtension = NULL; 174 } 175 } 174 } 175 } 176 if ($this->linkType == 2) { 177 $this->fileName = $this->fileExtension = NULL; 178 } 179 176 180 // check for Preview File 177 181 if ($this->previewArray && $this->previewArray['error'] != 4) { … … 218 222 'thread' => $this->supportThread, 219 223 'activ' => true, 224 'linkType' => intval($this->linkType), 220 225 'parseURL' => intval($this->parseURL), 221 226 'enableBBCodes' => intval($this->enableBBCodes), … … 239 244 'thread' => $this->supportThread, 240 245 'activ' => true, 246 'linkType' => intval($this->linkType), 241 247 'parseURL' => intval($this->parseURL), 242 248 'enableBBCodes' => intval($this->enableBBCodes), … … 252 258 } 253 259 } 254 }255 parent::save();256 // reset values257 $this->name = $this->description = $this->link = $this->supportThread= NULL;258 $this->fileName = $this->fileExtension = $this->mimeType = NULL;259 $this->previewFile = $this->previewIMG = NULL;260 $this->groesse = $this->downloads = $this->katID = 0;261 $this->sortOrder = $this->languageID = 1;260 // reset values 261 $this->name = $this->description = $this->link = $this->supportThread = NULL; 262 $this->fileName = $this->fileExtension = $this->mimeType = NULL; 263 $this->previewFile = $this->previewIMG = NULL; 264 $this->groesse = $this->downloads = $this->katID = $this->linkType = 0; 265 $this->sortOrder = $this->languageID = 1; 266 $this->additionalFields = array(); 267 } 262 268 // reset cache 263 269 WCF::getCache()->clear(WCF_DIR.'cache/', 'cache.dldbKat.php'); … … 322 328 'supportThread' => $this->supportThread, 323 329 'activ' => $this->activ, 324 ' action' => 'add',330 'linkType' => $this->linkType, 325 331 'previewExtensions' => DOWNLOADDB_ALLOWED_PREVIEW_EXT, 326 'fileExtensions' => DOWNLOADDB_ALLOWED_FILE_EXT,332 'fileExtensions' => DOWNLOADDB_ALLOWED_FILE_EXT, 327 333 'maxFileSize' => $maxFileSize, 328 334 'isExtern' => $this->isExtern, 329 335 'languageID' => $this->languageID, 330 'language' => $languageArray 336 'language' => $languageArray, 337 'action' => 'add' 331 338 )); 332 339 } … … 338 345 foreach ($this->katCache as $ID => $kategorie) { 339 346 if ($kategorie['topID'] == $katID) { 340 $this->katOptions[$kategorie['katID']] = " ". StringUtil::unescape($kategorie['name']);347 $this->katOptions[$kategorie['katID']] = " ".WCF::getLanguage()->get(StringUtil::encodeHTML($kategorie['name'])); 341 348 // weitere Unterkategorien suchen 342 349 $this->readSubKat($kategorie['katID']); … … 349 356 foreach ($this->katCache as $ID => $kategorie) { 350 357 if ($kategorie['topID'] == NULL) { 351 $this->katOptions[$kategorie['katID']] = " ". StringUtil::unescape($kategorie['name']);358 $this->katOptions[$kategorie['katID']] = " ".WCF::getLanguage()->get(StringUtil::encodeHTML($kategorie['name'])); 352 359 $this->readSubKat($kategorie['katID']); 353 360 }
