Show
Ignore:
Timestamp:
11/13/08 22:03:46 (5 years ago)
Author:
Tatzelwurm
Message:

Last version (1.1.0 pl 1)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • downloadDatabase/files/lib/acp/form/DownloadDBDataAddForm.class.php

    r668 r715  
    44require_once(WCF_DIR.'lib/data/downloadDB/DownloadDBDataEditor.class.php'); 
    55require_once(WCF_DIR.'lib/system/io/Tar.class.php'); 
     6require_once(WCF_DIR.'lib/acp/form/ACPForm.class.php'); 
    67 
    78 
     
    4142        public $supportThread = ''; 
    4243        public $activ = 0; 
     44        public $linkType = 0; 
    4345        public $isExtern = false; 
    4446        public $languageID = '1'; 
     
    7678                if (isset($_POST['activ']))                     $this->activ            = intval($_POST['activ']); 
    7779                if (isset($_POST['languageID']))        $this->languageID       = intval($_POST['languageID']); 
     80                if (isset($_POST['linkType']))          $this->linkType         = intval($_POST['linkType']); 
    7881                // for File Upload 
    7982                if (isset($_FILES['upload']))           $this->upload           = $_FILES['upload']; 
     
    9699                        throw new UserInputException('katID', 'invalid'); 
    97100                } 
    98                 // prÃŒfen ob ein Link eingegeben wurde 
    99                 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'); 
    101104                } 
    102105                // 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)) { 
    104107                        if ($this->link{0} == "/"){ 
    105108                                if (@fopen($_SERVER['DOCUMENT_ROOT'].$this->link,'rb') == false) { 
    106109                                        throw new UserInputException('link', 'badFile'); 
    107110                                } 
     111                        } else { 
     112                                throw new UserInputException('link', 'invalid'); 
    108113                        } 
    109114                }  
    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)) { 
    114117                                throw new UserInputException('link', 'invalid'); 
    115                         } 
    116                 } 
     118                }  
    117119                $this->valid = true; 
    118120        } 
     
    122124         */ 
    123125        public function save() { 
     126                parent::save(); 
    124127                //Create new Dataset with FileUpload  
    125128                if ($this->valid && $this->action == 'add'){ 
    126129                        // upload file if given 
    127                         if (!$this->link) { 
     130                        if ($this->linkType == 0) { 
    128131                                if ($this->upload && $this->upload['error'] != 4) { 
    129132                                        if ($this->upload['error'] != 0) { 
     
    136139                                        throw new UserInputException('upload'); 
    137140                                } 
    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); 
    149152// Funktioniert nur wenn "fileinfo" in php aktiviert ist!!  
    150 //                                                      $finfo = @finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension 
    151 //                                                      $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 ###*/ 
    153156// daher ist $mimeType = ''; 
    154157                                                } 
    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 = ''; 
    165168// Funktioniert nur wenn "fileinfo" in php aktiviert ist!!  
    166 //                                                      $finfo = @finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension 
    167 //                                                      $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 ###*/ 
    169172// daher ist $mimeType = ''; 
    170                                                 } 
    171173                                        } 
    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 
    176180                        // check for Preview File 
    177181                        if ($this->previewArray && $this->previewArray['error'] != 4) { 
     
    218222                                                        'thread'                => $this->supportThread, 
    219223                                                        'activ'                 => true, 
     224                                                        'linkType'              => intval($this->linkType), 
    220225                                                        'parseURL'              => intval($this->parseURL), 
    221226                                                        'enableBBCodes' => intval($this->enableBBCodes), 
     
    239244                                                        'thread'                => $this->supportThread, 
    240245                                                        'activ'                 => true, 
     246                                                        'linkType'              => intval($this->linkType), 
    241247                                                        'parseURL'              => intval($this->parseURL), 
    242248                                                        'enableBBCodes' => intval($this->enableBBCodes), 
     
    252258                                } 
    253259                        } 
    254                 } 
    255                 parent::save(); 
    256                 // reset values 
    257                 $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                } 
    262268                // reset cache 
    263269                WCF::getCache()->clear(WCF_DIR.'cache/', 'cache.dldbKat.php'); 
     
    322328                        'supportThread' => $this->supportThread, 
    323329                        'activ'                 => $this->activ, 
    324                         'action'                => 'add', 
     330                        'linkType'              => $this->linkType, 
    325331                        'previewExtensions' => DOWNLOADDB_ALLOWED_PREVIEW_EXT, 
    326                         'fileExtensions' => DOWNLOADDB_ALLOWED_FILE_EXT, 
     332                        'fileExtensions'        => DOWNLOADDB_ALLOWED_FILE_EXT, 
    327333                        'maxFileSize'   => $maxFileSize, 
    328334                        'isExtern'              => $this->isExtern, 
    329335                        'languageID'    => $this->languageID, 
    330                         'language'              => $languageArray 
     336                        'language'              => $languageArray, 
     337                        'action'                => 'add' 
    331338                )); 
    332339        } 
     
    338345                foreach ($this->katCache as $ID => $kategorie) { 
    339346                        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'])); 
    341348                                // weitere Unterkategorien suchen 
    342349                                $this->readSubKat($kategorie['katID']); 
     
    349356                foreach ($this->katCache as $ID => $kategorie) { 
    350357                        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'])); 
    352359                                $this->readSubKat($kategorie['katID']); 
    353360                        }