From 3e88d66ef871fe7c9069a09ecb1ecf29ff4b897f Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Sun, 4 Jan 2015 01:26:10 +0100 Subject: [PATCH] Fixed smiley upload issues --- wcfsetup/install/files/acp/templates/smileyAdd.tpl | 4 ++-- .../files/lib/acp/form/SmileyAddForm.class.php | 11 +++++++---- .../files/lib/acp/form/SmileyEditForm.class.php | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/smileyAdd.tpl b/wcfsetup/install/files/acp/templates/smileyAdd.tpl index 114414c00c..dc8380011c 100644 --- a/wcfsetup/install/files/acp/templates/smileyAdd.tpl +++ b/wcfsetup/install/files/acp/templates/smileyAdd.tpl @@ -119,7 +119,7 @@
{if $uploadedFilename} - + {/if} @@ -140,7 +140,7 @@
- + {if $errorField == 'smileyPath'} diff --git a/wcfsetup/install/files/lib/acp/form/SmileyAddForm.class.php b/wcfsetup/install/files/lib/acp/form/SmileyAddForm.class.php index b4690a84f9..45403db845 100644 --- a/wcfsetup/install/files/lib/acp/form/SmileyAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/SmileyAddForm.class.php @@ -171,7 +171,7 @@ class SmileyAddForm extends AbstractForm { 'categoryID' => $this->categoryID ?: null, 'packageID' => 1 )), - 'fileLocation' => $this->uploadedFilename ? WCF_DIR.'images/smilies/tmp/'.$this->uploadedFilename : '' + 'fileLocation' => $this->uploadedFilename ? WCF_DIR.'images/smilies/'.$this->uploadedFilename : '' )); $this->objectAction->executeAction(); $returnValues = $this->objectAction->getReturnValues(); @@ -210,21 +210,24 @@ class SmileyAddForm extends AbstractForm { parent::validate(); if ($this->uploadedFilename) { - if (!file_exists(WCF_DIR.'images/smilies/tmp/'.$this->uploadedFilename)) { + if (!file_exists(WCF_DIR.'images/smilies/'.$this->uploadedFilename)) { + $this->uploadedFilename = ''; throw new UserInputException('fileUpload', 'uploadFailed'); } } else if (!empty($this->fileUpload['name'])) { if (!getimagesize($this->fileUpload['tmp_name'])) { + $this->uploadedFilename = ''; throw new UserInputException('fileUpload', 'noImage'); } do { $this->uploadedFilename = StringUtil::getRandomID().'.'.mb_strtolower(mb_substr($this->fileUpload['name'], mb_strrpos($this->fileUpload['name'], '.') + 1)); } - while (file_exists(WCF_DIR.'images/smilies/tmp/'.$this->uploadedFilename)); + while (file_exists(WCF_DIR.'images/smilies/'.$this->uploadedFilename)); - if (!@move_uploaded_file($this->fileUpload['tmp_name'], WCF_DIR.'images/smilies/tmp/'.$this->uploadedFilename)) { + if (!@move_uploaded_file($this->fileUpload['tmp_name'], WCF_DIR.'images/smilies/'.$this->uploadedFilename)) { + $this->uploadedFilename = ''; throw new UserInputException('fileUpload', 'uploadFailed'); } } diff --git a/wcfsetup/install/files/lib/acp/form/SmileyEditForm.class.php b/wcfsetup/install/files/lib/acp/form/SmileyEditForm.class.php index b1c5e4fab4..c8081bf3e9 100644 --- a/wcfsetup/install/files/lib/acp/form/SmileyEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/SmileyEditForm.class.php @@ -78,7 +78,7 @@ class SmileyEditForm extends SmileyAddForm { 'showOrder' => $this->showOrder, 'categoryID' => $this->categoryID ?: null )), - 'fileLocation' => $this->uploadedFilename ? WCF_DIR.'images/smilies/tmp/'.$this->uploadedFilename : '' + 'fileLocation' => $this->uploadedFilename ? WCF_DIR.'images/smilies/'.$this->uploadedFilename : '' )); $this->objectAction->executeAction(); -- 2.20.1