From 6bfddb8f6da72b3b0ad3e5ea941c336e99a3599c Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 17 Dec 2014 13:02:37 +0100 Subject: [PATCH] Fixed uploading packages as styles --- .../form/PackageStartInstallForm.class.php | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php index faf2e87a0d..06fafb43ba 100755 --- a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php @@ -98,10 +98,8 @@ class PackageStartInstallForm extends AbstractForm { parent::validate(); if ($this->stylePackageImportLocation) { - $this->archive = new PackageArchive($this->stylePackageImportLocation, $this->package); - try { - $this->validateArchive('uploadPackage'); + $this->validateUploadPackage($this->stylePackageImportLocation); } catch (UserInputException $e) { WCF::getSession()->unregister('stylePackageImportLocation'); @@ -122,22 +120,28 @@ class PackageStartInstallForm extends AbstractForm { /** * Validates the upload package input. + * + * @param string $filename */ - protected function validateUploadPackage() { + protected function validateUploadPackage($filename = '') { $this->activeTabMenuItem = 'upload'; - if (empty($this->uploadPackage['tmp_name'])) { - throw new UserInputException('uploadPackage', 'uploadFailed'); - } - - // get filename - $this->uploadPackage['name'] = FileUtil::getTemporaryFilename('package_', preg_replace('!^.*(?=\.(?:tar\.gz|tgz|tar)$)!i', '', basename($this->uploadPackage['name']))); - - if (!@move_uploaded_file($this->uploadPackage['tmp_name'], $this->uploadPackage['name'])) { - throw new UserInputException('uploadPackage', 'uploadFailed'); + if (empty($filename)) { + if (empty($this->uploadPackage['tmp_name'])) { + throw new UserInputException('uploadPackage', 'uploadFailed'); + } + + // get filename + $this->uploadPackage['name'] = FileUtil::getTemporaryFilename('package_', preg_replace('!^.*(?=\.(?:tar\.gz|tgz|tar)$)!i', '', basename($this->uploadPackage['name']))); + + if (!@move_uploaded_file($this->uploadPackage['tmp_name'], $this->uploadPackage['name'])) { + throw new UserInputException('uploadPackage', 'uploadFailed'); + } + + $filename = $this->uploadPackage['name']; } - if (!PackageValidationManager::getInstance()->validate($this->uploadPackage['name'], false)) { + if (!PackageValidationManager::getInstance()->validate($filename, false)) { $exception = PackageValidationManager::getInstance()->getException(); if ($exception instanceof PackageValidationException) { switch ($exception->getCode()) { -- 2.20.1