dataID = intval($_REQUEST['dataID']); if (!$this->dataID){ require_once(WCF_DIR.'lib/system/exception/NamedUserException.class.php'); throw new NamedUserException(WCF::getLanguage()->get('wcf.dldb.wrongid')); exit; } } /** * @see Form::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); if (isset($_POST['UserIDAkt'])) $this->userIDAkt = intval($_POST['UserIDAkt']); if (isset($_POST['datumAkt'])) $this->datumAkt = intval($_POST['datumAkt']); if (isset($_POST['downloadsAkt'])) $this->downloadsAkt = intval($_POST['downloadsAkt']); if (isset($_POST['delPreview'])) $this->delPreview = intval($_POST['delPreview']); if (isset($_POST['fileName'])) $this->fileName = $_POST['fileName']; if (isset($_POST['fileNameAlt'])) $this->fileNameAlt = $_POST['fileNameAlt']; if (isset($_POST['fileExtension'])) $this->fileExtension = escapeString($_POST['fileExtension']); if (isset($_POST['mimeType'])) $this->mimeType = escapeString($_POST['mimeType']); } /** * @see Page::readData() */ public function readData() { parent::readData(); // Daten einlesen if (!count($_POST)) { $this->readDaten(); } } /** * @see Page::assignVariables() */ public function assignVariables() { parent::assignVariables(); WCF::getTPL()->assign(array( 'action' => 'edit', 'dataID' => $this->dataID, 'fileNameAlt' => $this->fileNameAlt, 'downloadsAkt' => $this->downloadsAkt, 'datumAkt' => $this->datumAkt, 'UserIDAkt' => $this->userIDAkt, 'delPreview' => $this->delPreview, 'dldbUserName' => $this->dldbUserName, )); } /** * @see Form::validate() */ public function validate() { parent::validate(); $this->valid = true; } /** * Updates the data of an existing File/Link. */ public function save() { if ($this->valid && $this->dataID) { $dataset = new DownloadDBDataEditor($this->dataID); if ($this->downloadsAkt) $this->downloads = 0; else $this->downloads = $dataset->downloads; if ($this->datumAkt) $this->datum = TIME_NOW; else $this->datum = $dataset->datum; if ($this->userIDAkt) $this->dldbUserID = WCF::getUser()->userID; // Bei neuem Prewiew Upload den alten file löschen und den neuen anlegen if ($this->previewArray && $this->previewArray['error'] != 4) { // auf Fehler beim Upload prüfen if ($this->previewArray['error'] != 0) { throw new UserInputException('previewIMG', 'uploadFailed'); } if ($this->previewFile != $this->previewArray['name']) { // alten File löschen wenn neuer angegeben wurde $dataset->deletePreview($this->previewFile); } // neuen File anlegen $this->previewFile = $this->previewArray['name']; $this->previewIMG = DownloadDBDataEditor::createPreview($this->previewArray['tmp_name'], $this->previewArray['name'], $this->previewArray['type'], 'previewIMG'); } else { $this->previewFile = $dataset->previewFile; $this->previewIMG = $dataset->previewIMG; } // Delete preview? if ($this->delPreview) { $dataset->deletePreview($this->previewFile); $this->previewFile = $this->previewIMG = NULL; } // Bei neuem Upload den alten file löschen und den neuen anlegen $upld = false; if ($this->upload && $this->upload['error'] != 4) { $upld = true; // auf Fehler beim Upload prüfen if ($this->upload['error'] != 0) { throw new UserInputException('upload', 'uploadFailed'); } // alten File löschen und neuen anlegen DownloadDBDataEditor::updateFile($this->fileNameAlt, $this->upload['tmp_name'], $this->upload['name'], $this->upload['type'], 'upload'); //Variablen anpassen $this->fileName = $this->upload['name']; $this->mimeType = $this->upload['type']; $this->groesse = $this->upload['size']; if (StringUtil::indexOf($this->fileName, '.') !== false) { $this->fileExtension = StringUtil::toLowerCase(StringUtil::substring($this->fileName, StringUtil::lastIndexOf($this->fileName, '.') + 1)); } $this->link = FileUtil::getRealPath(RELATIVE_WCF_DIR.DOWNLOADDB_FILE_DIR.intval($dataset->dataID).'_'.StringUtil::encodeHTML($this->fileName)); } if (!$upld && $this->link && ($this->link != escapeString($dataset->link))) { if (FileUtil::isURL($this->link) == false) { if ($this->link{0} == "/"){ if (StringUtil::indexOf($_SERVER['DOCUMENT_ROOT'].$this->link, '/') !== false) { $this->fileName = StringUtil::substring($_SERVER['DOCUMENT_ROOT'].$this->link, StringUtil::lastIndexOf($_SERVER['DOCUMENT_ROOT'].$this->link, '/') + 1); } if (StringUtil::indexOf($this->fileName, '.') !== false) { $this->fileExtension = StringUtil::toLowerCase(StringUtil::substring($this->fileName, StringUtil::lastIndexOf($this->fileName, '.') + 1)); } $this->groesse = @filesize($_SERVER['DOCUMENT_ROOT'].$this->link); $this->mimeType = ''; // Funktioniert nur wenn "fileinfo" in php aktiviert ist!! // $finfo = @finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension // $this->mimeType = finfo_file($finfo, $_SERVER['DOCUMENT_ROOT'].$this->link); // daher ist $mimeType = ''; } else { if (StringUtil::indexOf($this->link, '/') !== false) { $this->fileName = StringUtil::substring($this->link, StringUtil::lastIndexOf($this->link, '/') + 1); } if (StringUtil::indexOf($this->fileName, '.') !== false) { $this->fileExtension = StringUtil::toLowerCase(StringUtil::substring($this->fileName, StringUtil::lastIndexOf($this->fileName, '.') + 1)); } $this->groesse = @filesize($this->link); $this->mimeType = ''; // Funktioniert nur wenn "fileinfo" in php aktiviert ist!! // $finfo = @finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension // $this->mimeType = finfo_file($finfo, $this->link); // daher ist $mimeType = ''; } } else { $this->fileName = $this->fileExtension = $this->mimeType = NULL; } } else { $this->link = $dataset->link; $this->fileName = $dataset->fileName; $this->fileExtension = $dataset->fileExtension; $this->mimeType = $dataset->mimeType; } // Daten endgltig speichern $dataset->updateDataset(array_merge($this->additionalFields, array( 'katID' => intval($this->katID), 'name' => escapeString($this->name), 'description' => escapeString($this->description), 'previewIMG' => escapeString($this->previewIMG), 'previewFile' => StringUtil::encodeHTML($this->previewFile), 'fileName' => escapeString($this->fileName), 'fileExtension' => escapeString($this->fileExtension), 'mimeType' => escapeString($this->mimeType), 'link' => $this->link, 'groesse' => intval($this->groesse), 'downloads' => intval($this->downloads), 'userID' => intval($this->dldbUserID), 'datum' => $this->datum, 'sortOrder' => intval($this->sortOrder), 'thread' => $this->supportThread, 'activ' => true, 'parseURL' => intval($this->parseURL), 'enableBBCodes' => intval($this->enableBBCodes), 'enableHtml' => intval($this->enableHtml), 'enableSmilies' => intval($this->enableSmilies), 'languageID' => intval($this->languageID) ))); } // show success message WCF::getTPL()->assign('success', true); // delete category cache WCF::getCache()->clear(WCF_DIR.'cache', 'cache.dldbKat.php'); $this->saved(); // forward to list page header('Location: index.php?page=DownloadDBDataList&packageID='.PACKAGE_ID.SID_ARG_2ND_NOT_ENCODED); exit; } protected function readDaten() { WCF::getCache()->addResource('dldbData', WCF_DIR.'cache/cache.dldbData.php', WCF_DIR.'lib/system/cache/CacheBuilderDLDBData.class.php'); $this->dataCache = WCF::getCache()->get('dldbData'); // get data foreach ($this->dataCache as $ID => $data) { if ($data['dataID'] == $this->dataID) { $this->katID = $data['katID']; $this->name = $data['name']; $this->description = $data['description']; $this->previewFile = $data['previewFile']; if ($this->previewFile) { $ext = StringUtil::toLowerCase(StringUtil::substring($data['previewFile'], StringUtil::lastIndexOf($data['previewFile'], '.') + 1)); if (@fopen(FileUtil::getRealPath(RELATIVE_WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'thumbnail-'.$this->dataID.'.'.$ext),'rb') == false) { $this->previewIMG = FileUtil::getRealPath(RELATIVE_WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'Preview-'.$this->dataID.'.'.$ext); } else { $this->previewIMG = FileUtil::getRealPath(RELATIVE_WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'thumbnail-'.$this->dataID.'.'.$ext); } } else { $this->previewIMG = ''; } $this->fileName = $this->fileNameAlt = $data['fileName']; $this->fileExtension = $data['fileExtension']; $this->mimeType = $data['mimeType']; $this->link = StringUtil::decodeHTML($data['link']); if (FileUtil::isURL($this->link) == true || $this->link{0} == "/") $this->isExtern = true; $this->groesse = $data['groesse']; $this->downloads = $data['downloads']; $this->dldbUserID = $data['dldbUserID']; $this->dldbUserName = $data['dldbUsername']; $this->datum = $data['datum']; $this->sortOrder = $data['sortOrder']; $this->supportThread = StringUtil::decodeHTML($data['thread']); $this->activ = $data['activ']; $this->parseURL = $data['parseURL']; $this->enableSmilies = $data['enableSmilies']; $this->enableHtml = $data['enableHtml']; $this->enableBBCodes = $data['enableBBCodes']; $this->languageID = $data['languageID']; } WCF::getCache()->clearResource('dldbData'); } } } ?>