From 8f5a0ad6f73e7b7757b02c827436384c96069b5a Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 24 Jul 2015 09:20:50 +0200 Subject: [ticket/14039] Revamp updater PHPBB3-14039 --- .../phpbb/install/controller/archive_download.php | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 phpBB/phpbb/install/controller/archive_download.php (limited to 'phpBB/phpbb/install/controller/archive_download.php') diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php new file mode 100644 index 0000000000..711e1f2f0c --- /dev/null +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -0,0 +1,92 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\install\controller; + +use phpbb\install\helper\config; +use Symfony\Component\HttpFoundation\BinaryFileResponse; +use Symfony\Component\HttpFoundation\ResponseHeaderBag; + +class archive_download +{ + /** + * @var config + */ + protected $installer_config; + + /** + * Constructor + * + * @param config $config + */ + public function __construct(config $config) + { + $this->installer_config = $config; + $this->installer_config->load_config(); + } + + /** + * Sends response with the merge conflict archive + * + * Merge conflicts are always have to be resolved manually, + * so we use a different archive for that. + * + * @return BinaryFileResponse + */ + public function conflict_archive() + { + $filename = $this->installer_config->get('update_file_conflict_archive', false); + + if (!$filename) + { + die ('The requested file is not exist.'); + } + + return $this->send_response($filename); + } + + /** + * Sends response with the updated files' archive + * + * @return BinaryFileResponse + */ + public function update_archive() + { + $filename = $this->installer_config->get('update_file_archive', ''); + + if (!$filename) + { + die ('The requested file is not exist.'); + } + + return $this->send_response($filename); + } + + /** + * Generates a download response + * + * @param string $filename Path to the file to download + * + * @return BinaryFileResponse Response object + */ + private function send_response($filename) + { + $response = new BinaryFileResponse($filename); + $response->setContentDisposition( + ResponseHeaderBag::DISPOSITION_ATTACHMENT, + basename($filename) + ); + + return $response; + } +} -- cgit v1.2.1 From 85eb6a0bc0575c687eb43efe61cf206b26b26af8 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 11:21:56 +0200 Subject: [ticket/14039] Fix language constants and comments PHPBB3-14039 --- phpBB/phpbb/install/controller/archive_download.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/controller/archive_download.php') diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php index 711e1f2f0c..e1f7634963 100644 --- a/phpBB/phpbb/install/controller/archive_download.php +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -38,7 +38,7 @@ class archive_download /** * Sends response with the merge conflict archive * - * Merge conflicts are always have to be resolved manually, + * Merge conflicts always have to be resolved manually, * so we use a different archive for that. * * @return BinaryFileResponse -- cgit v1.2.1 From 100bb8f27c52b2faffddf2a6926c5d7b49faa421 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 11:26:41 +0200 Subject: [ticket/14039] Use http_exception instead of die() PHPBB3-14039 --- phpBB/phpbb/install/controller/archive_download.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install/controller/archive_download.php') diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php index e1f7634963..a0f0ba181d 100644 --- a/phpBB/phpbb/install/controller/archive_download.php +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -13,6 +13,7 @@ namespace phpbb\install\controller; +use phpbb\exception\http_exception; use phpbb\install\helper\config; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\ResponseHeaderBag; @@ -49,7 +50,7 @@ class archive_download if (!$filename) { - die ('The requested file is not exist.'); + throw new http_exception(404, 'URL_NOT_FOUND'); } return $this->send_response($filename); @@ -66,7 +67,7 @@ class archive_download if (!$filename) { - die ('The requested file is not exist.'); + throw new http_exception(404, 'URL_NOT_FOUND'); } return $this->send_response($filename); -- cgit v1.2.1 From debd1bb9d655106eb5454ac4687837c9323a99ae Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 2 Feb 2016 17:53:10 +0100 Subject: [ticket/14321] Clean up arcihve controller logic PHPBB3-14321 --- phpBB/phpbb/install/controller/archive_download.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/controller/archive_download.php') diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php index a0f0ba181d..eabc0a9976 100644 --- a/phpBB/phpbb/install/controller/archive_download.php +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -46,9 +46,9 @@ class archive_download */ public function conflict_archive() { - $filename = $this->installer_config->get('update_file_conflict_archive', false); + $filename = $this->installer_config->get('update_file_conflict_archive', ''); - if (!$filename) + if (empty($filename)) { throw new http_exception(404, 'URL_NOT_FOUND'); } @@ -65,7 +65,7 @@ class archive_download { $filename = $this->installer_config->get('update_file_archive', ''); - if (!$filename) + if (empty($filename)) { throw new http_exception(404, 'URL_NOT_FOUND'); } -- cgit v1.2.1