diff --git a/modules/blockstore/blockstore.php b/modules/blockstore/blockstore.php index a559ab73b..4b82ecf1a 100644 --- a/modules/blockstore/blockstore.php +++ b/modules/blockstore/blockstore.php @@ -92,13 +92,15 @@ class BlockStore extends Module return $this->displayError($this->l('Invalid image')); else { - if (!move_uploaded_file($_FILES['store_img']['tmp_name'], dirname(__FILE__).'/'.$_FILES['store_img']['name'])) + $ext = substr($_FILES['store_img']['name'], strrpos($_FILES['store_img']['name'], '.') + 1); + $file_name = md5($_FILES['store_img']['name']).'.'.$ext; + if (!move_uploaded_file($_FILES['store_img']['tmp_name'], dirname(__FILE__).'/'.$file_name)) return $this->displayError($this->l('An error occurred while attempting to upload the file.')); else { - if (Configuration::hasContext('BLOCKSTORE_IMG', null, Shop::getContext()) && Configuration::get('BLOCKSTORE_IMG') != $_FILES['store_img']['name']) + if (Configuration::hasContext('BLOCKSTORE_IMG', null, Shop::getContext()) && Configuration::get('BLOCKSTORE_IMG') != $file_name) @unlink(dirname(__FILE__).'/'.Configuration::get('BLOCKSTORE_IMG')); - Configuration::updateValue('BLOCKSTORE_IMG', $_FILES['store_img']['name']); + Configuration::updateValue('BLOCKSTORE_IMG', $file_name); $this->_clearCache('blockstore.tpl'); return $this->displayConfirmation($this->l('The settings have been updated.')); }