Changeset 415

Show
Ignore:
Timestamp:
04/07/08 23:41:21 (5 years ago)
Author:
Tatzelwurm
Message:

Downloads, Verarbeitung von relativen Links, Datei Add und Edit verbessert, Vorschaubilder änderbar

Location:
downloadDatabase/files/lib
Files:
3 modified

Legend:

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

    r407 r415  
    9191                        throw new UserInputException('link', 'empty'); 
    9292                } 
    93                 // prÃŒfen ob ein Link UND File angegeben wurden 
     93                if (!$this->mimeType) { 
     94                        // prÃŒfen ob ein relativer Pfad vorliegt und die Datei existiert 
     95                        if (FileUtil::isURL($this->link) == false) { 
     96                                if (@fopen($this->link,'rb') == false) { 
     97                                        throw new UserInputException('link', 'badFile'); 
     98                                } 
     99                        }  
     100                } 
     101 
    94102                if ($this->action == 'add') { 
     103                        // prÃŒfen ob ein Link UND File angegeben wurden 
    95104                        if ($this->link && ($this->upload && $this->upload['error'] != 4)) { 
    96105                                throw new UserInputException('link', 'invalid'); 
     
    117126                                } else { 
    118127                                        throw new UserInputException('upload'); 
     128                                } 
     129                        } else { 
     130                                if (FileUtil::isURL($this->link) == false) { 
     131                                        if (StringUtil::indexOf($this->link, '/') !== false) { 
     132                                                $this->fileName = StringUtil::substring($this->link, StringUtil::lastIndexOf($this->link, '/') + 1); 
     133                                        } 
     134                                        if (StringUtil::indexOf($this->fileName, '.') !== false) { 
     135                                                $this->fileExtension = StringUtil::toLowerCase(StringUtil::substring($this->fileName, StringUtil::lastIndexOf($this->fileName, '.') + 1)); 
     136                                        } 
     137                                        $this->groesse = filesize($this->link); 
    119138                                } 
    120139                        } 
     
    169188                                $dataset = DownloadDBDataEditor::createDataset(intval($this->katID), $this->name, $this->description ,array( 
    170189                                                        'link'                  => StringUtil::encodeHTML($this->link), 
     190                                                        'fileName'              => escapeString($this->fileName), 
     191                                                        'fileExtension' => escapeString($this->fileExtension), 
    171192                                                        'groesse'               => intval($this->groesse), 
    172193                                                        'downloads'             => intval($this->downloads), 
  • downloadDatabase/files/lib/acp/form/DownloadDBDataEditForm.class.php

    r407 r415  
    107107                                } 
    108108                                // neuen File anlegen 
    109                                 $this->previewIMG = DownloadDBDataEditor::createPreview($dataset->dataID, $this->previewArray['tmp_name'],      $this->previewArray['name'], $this->previewArray['type'], 'previewIMG'); 
    110109                                $this->previewFile = $this->previewArray['name']; 
    111                         } 
    112                         // Bei neuem Upload den alten file lschen und den neuen anlegen 
     110                                $this->previewIMG = DownloadDBDataEditor::createPreview($this->previewArray['tmp_name'],        $this->previewArray['name'], $this->previewArray['type'], 'previewIMG'); 
     111                        } 
     112                        // Bei neuem Upload den alten file löschen und den neuen anlegen 
    113113                        if ($this->upload && $this->upload['error'] != 4) { 
    114114                                // auf Fehler beim Upload prfen 
     
    117117                                } 
    118118                                // alten File löschen und neuen anlegen 
    119                                 DownloadDBDataEditor::updateFile($dataset->dataID, $this->fileNameAlt, $this->upload['tmp_name'], $this->upload['name'], $this->upload['type'], 'upload'); 
     119                                DownloadDBDataEditor::updateFile($this->fileNameAlt, $this->upload['tmp_name'], $this->upload['name'], $this->upload['type'], 'upload'); 
    120120                                //Variablen anpassen 
    121121                                $this->fileName = $this->upload['name']; 
     
    126126                                } 
    127127                                $this->link = FileUtil::addTrailingSlash(PAGE_URL).FileUtil::getRealPath('wcf/'.RELATIVE_WCF_DIR.DOWNLOADDB_FILE_DIR.intval($dataset->dataID).'_'.StringUtil::encodeHTML($this->fileName)); 
     128                        } 
     129                        if (!$this->upload && (FileUtil::isURL($this->link) == false)) { 
     130                                        if (StringUtil::indexOf($this->link, '/') !== false) { 
     131                                                $this->fileName = StringUtil::substring($this->link, StringUtil::lastIndexOf($this->link, '/') + 1); 
     132                                        } 
     133                                        if (StringUtil::indexOf($this->fileName, '.') !== false) { 
     134                                                $this->fileExtension = StringUtil::toLowerCase(StringUtil::substring($this->fileName, StringUtil::lastIndexOf($this->fileName, '.') + 1)); 
     135                                        } 
     136                                        $this->groesse = filesize($this->link); 
     137                                 
    128138                        } 
    129139                        // Daten endgltig speichern 
  • downloadDatabase/files/lib/page/DownloadDBFileDownloadPage.class.php

    r407 r415  
    4343                // reset cache 
    4444                WCF::getCache()->clear(WCF_DIR.'cache/', 'cache.dldbData.php'); 
    45                 if (!$this->fileName) { 
     45                if (!$this->fileType) { 
    4646                        if (FileUtil::isURL($this->link)) { 
    4747                                HeaderUtil::redirect($this->link,false); 
    4848                                exit; 
    4949                        } else { 
    50                         $geturl = new downloadDBDataEditor($this->dataID); 
    51                         $link = FileUtil::getRealPath(RELATIVE_WCF_DIR.$geturl->getURL()); 
    52                         $size = filesize($link); 
    53                         $type = 'application/unknown'; 
    54                         $name = StringUtil::toLowerCase(StringUtil::substring($this->link, StringUtil::lastIndexOf($this->link, '/') + 1)); 
     50                                $link = FileUtil::getRealPath(RELATIVE_WCF_DIR.$this->link); 
     51                                $type = 'application/unknown'; 
    5552                        } 
    5653                } else { 
    57                         $geturl = new downloadDBDataEditor($this->dataID); 
    58                         $link = FileUtil::getRealPath(RELATIVE_WCF_DIR.$geturl->getURL()); 
    59                         $size = filesize($link); 
     54                        $dataset = new downloadDBDataEditor($this->dataID); 
     55                        $link = FileUtil::getRealPath(RELATIVE_WCF_DIR.$dataset->getURL()); 
    6056                        $type = $this->fileType; 
    61                         $name = $this->fileName; 
    6257                } 
    6358                // Set Download Infos 
    6459                @ header('Content-Description: File Transfer'); 
    6560                @ header('Content-Type: '. $type); 
    66                 @ header('Content-disposition: attachment; filename="' . $name . '"'); 
    67                 @ header('Content-Length: ' . $size); 
     61                @ header('Content-disposition: attachment; filename="' . $this->fileName . '"'); 
     62                @ header('Content-Length: ' . filesize($link)); 
    6863                @ header('Pragma: no-cache'); 
    6964                @ header('Expires: 0');