From f3889bc4a5bd132e724f126c1f7c027ce292ff88 Mon Sep 17 00:00:00 2001 From: Ruben Calvo Date: Wed, 25 Dec 2024 21:01:59 +0100 Subject: [PATCH 1/5] Use storage in ads uploads --- banner/banner.php | 42 ++++++++++----------------------- config/routing.yml | 5 ++++ config/services.yml | 22 ++++++++++++++--- controller/admin_input.php | 3 +-- migrations/v30x/m1_storage.php | 43 ++++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 34 deletions(-) create mode 100644 migrations/v30x/m1_storage.php diff --git a/banner/banner.php b/banner/banner.php index 94e8bbd7..d2fe0818 100644 --- a/banner/banner.php +++ b/banner/banner.php @@ -10,32 +10,29 @@ namespace phpbb\ads\banner; +use phpbb\storage\storage; + class banner { /** @var \phpbb\files\upload */ protected $files_upload; - /** @var \phpbb\filesystem\filesystem_interface */ - protected $filesystem; - - /** @var string */ - protected $root_path; - - /** @var \phpbb\files\filespec */ + /** @var \phpbb\files\filespec_storage */ protected $file; + /** @var storage */ + protected $storage; + /** * Constructor * - * @param \phpbb\files\upload $files_upload Files upload object - * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem object - * @param string $root_path Root path + * @param \phpbb\files\upload $files_upload Files upload object + * @param storage $storage Storage object */ - public function __construct(\phpbb\files\upload $files_upload, \phpbb\filesystem\filesystem_interface $filesystem, $root_path) + public function __construct(\phpbb\files\upload $files_upload, storage $storage) { $this->files_upload = $files_upload; - $this->filesystem = $filesystem; - $this->root_path = $root_path; + $this->storage = $storage; } public function set_file($file) @@ -43,19 +40,6 @@ public function set_file($file) $this->file = $file; } - /** - * Create storage directory for banners uploaded by Ads Management - * - * @throws \phpbb\filesystem\exception\filesystem_exception - */ - public function create_storage_dir() - { - if (!$this->filesystem->exists($this->root_path . 'images/phpbb_ads')) - { - $this->filesystem->mkdir($this->root_path . 'images/phpbb_ads'); - } - } - /** * Handle banner upload * @@ -69,11 +53,11 @@ public function upload() $this->files_upload->set_allowed_extensions(array('gif', 'jpg', 'jpeg', 'png')); // Upload file - $this->set_file($this->files_upload->handle_upload('files.types.form', 'banner')); + $this->set_file($this->files_upload->handle_upload('files.types.form_storage', 'banner')); $this->file->clean_filename('unique_ext'); // Move file to proper location - if (!$this->file->move_file('images/phpbb_ads')) + if (!$this->file->move_file($this->storage)) { $this->file->set_error('FILE_MOVE_UNSUCCESSFUL'); } @@ -91,6 +75,6 @@ public function upload() */ public function remove() { - $this->file->remove(); + $this->file->remove($this->storage); } } diff --git a/config/routing.yml b/config/routing.yml index 47de1f2f..8aaa97a2 100644 --- a/config/routing.yml +++ b/config/routing.yml @@ -15,3 +15,8 @@ phpbb_ads_visual_demo: defaults: { _controller: phpbb.ads.visual_demo.controller:handle } requirements: action: enable|disable + +phpbb_ads_storage_banner: + path: /ads_download/{file} + defaults: + _controller: phpbb.ads.controller.banner:handle diff --git a/config/services.yml b/config/services.yml index 30708d2b..485da45a 100644 --- a/config/services.yml +++ b/config/services.yml @@ -4,6 +4,24 @@ imports: - { resource: location.yml } services: + phpbb.ads.storage: + class: phpbb\storage\storage + arguments: + - '@storage.adapter.factory' + - '@storage.file_tracker' + - 'phpbb_ads' + tags: + - { name: storage } + + phpbb.ads.controller.banner: + class: phpbb\storage\controller\controller + arguments: + - '@cache' + - '@dbal.conn' + - '@mimetype.extension_guesser' + - '@phpbb.ads.storage' + - '@symfony_request' + phpbb.ads.ad.manager: class: phpbb\ads\ad\manager arguments: @@ -17,9 +35,7 @@ services: class: phpbb\ads\banner\banner arguments: - '@files.upload' - - '@filesystem' - - '%core.root_path%' - - '%phpbb.ads.tables.ad_locations%' + - '@phpbb.ads.storage' phpbb.ads.helper: class: phpbb\ads\controller\helper diff --git a/controller/admin_input.php b/controller/admin_input.php index ccda2c3e..a5e65c86 100644 --- a/controller/admin_input.php +++ b/controller/admin_input.php @@ -134,10 +134,9 @@ public function banner_upload($ad_code) { try { - $this->banner->create_storage_dir(); $realname = $this->banner->upload(); - $banner_html = ''; + $banner_html = ''; if ($this->request->is_ajax()) { diff --git a/migrations/v30x/m1_storage.php b/migrations/v30x/m1_storage.php new file mode 100644 index 00000000..e78edf7f --- /dev/null +++ b/migrations/v30x/m1_storage.php @@ -0,0 +1,43 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + */ + +namespace phpbb\ads\migrations\v30x; + +use phpbb\storage\provider\local; + +class m1_storage extends \phpbb\db\migration\container_aware_migration +{ + /** + * {@inheritDoc} + */ + public static function depends_on() + { + return array( + '\phpbb\db\migration\data\v400\dev', + '\phpbb\ads\migrations\v20x\m1_hide_ad_for_group', + ); + } + + public function update_data() + { + return array( + ['config.add', ['storage\\phpbb_ads\\provider', local::class]], + ['config.add', ['storage\\phpbb_ads\\config\\path', 'images/phpbb_ads']], // todo: make sure this exists in migration if is a new installation + ); + } + + public function revert_data() + { + return [ + ['config.remove', ['storage\\phpbb_ads\\provider']], + ['config.remove', ['storage\\phpbb_ads\\config\\path']], + ]; + } +} From 23dd8f1e6c297dd8f5d895656a6405609a4016b6 Mon Sep 17 00:00:00 2001 From: Ruben Calvo Date: Thu, 26 Dec 2024 20:12:55 +0100 Subject: [PATCH 2/5] Use router to generate url, add language keys and improve migration --- config/services.yml | 1 + controller/admin_input.php | 8 +++-- language/en/common.php | 3 ++ migrations/v30x/m1_storage.php | 55 +++++++++++++++++++++++++++++++++- 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/config/services.yml b/config/services.yml index 485da45a..ce75317d 100644 --- a/config/services.yml +++ b/config/services.yml @@ -54,6 +54,7 @@ services: phpbb.ads.admin.input: class: phpbb\ads\controller\admin_input arguments: + - '@controller.helper' - '@user' - '@user_loader' - '@language' diff --git a/controller/admin_input.php b/controller/admin_input.php index a5e65c86..b5b345e6 100644 --- a/controller/admin_input.php +++ b/controller/admin_input.php @@ -17,6 +17,9 @@ */ class admin_input { + /** @var \phpbb\controller\helper */ + protected $controller_helper; + /** @var \phpbb\user */ protected $user; @@ -44,8 +47,9 @@ class admin_input * @param \phpbb\request\request $request Request object * @param \phpbb\ads\banner\banner $banner Banner upload object */ - public function __construct(\phpbb\user $user, \phpbb\user_loader $user_loader, \phpbb\language\language $language, \phpbb\request\request $request, \phpbb\ads\banner\banner $banner) + public function __construct(\phpbb\controller\helper $controller_helper, \phpbb\user $user, \phpbb\user_loader $user_loader, \phpbb\language\language $language, \phpbb\request\request $request, \phpbb\ads\banner\banner $banner) { + $this->controller_helper = $controller_helper; $this->user = $user; $this->user_loader = $user_loader; $this->language = $language; @@ -136,7 +140,7 @@ public function banner_upload($ad_code) { $realname = $this->banner->upload(); - $banner_html = ''; + $banner_html = ''; if ($this->request->is_ajax()) { diff --git a/language/en/common.php b/language/en/common.php index ebe45c83..43dd711c 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -66,4 +66,7 @@ 'AD_SLIDE_UP_DESC' => 'Displays on every page after user scrolls below main content. Slides up from the bottom.', 'AD_SCRIPTS' => 'Scripts', 'AD_SCRIPTS_DESC' => 'This location is for specialty JavaScript code like AdSense Auto ads, tracking codes, etc. The code entered here will be inserted into the page’s HEAD tag and is not intended for ad placement, but only for helper scripts.', + + // Storage + 'STORAGE_PHPBB_ADS_TITLE' => 'phpBB Ads', )); diff --git a/migrations/v30x/m1_storage.php b/migrations/v30x/m1_storage.php index e78edf7f..63c970e9 100644 --- a/migrations/v30x/m1_storage.php +++ b/migrations/v30x/m1_storage.php @@ -10,10 +10,24 @@ namespace phpbb\ads\migrations\v30x; +use phpbb\filesystem\filesystem; use phpbb\storage\provider\local; class m1_storage extends \phpbb\db\migration\container_aware_migration { + /** + * {@inheritdoc} + */ + public function effectively_installed() + { + /** @var filesystem $filesystem_interface */ + $filesystem = $this->container->get('filesystem'); + + return $this->config->offsetExists('storage\\phpbb_ads\\provider') && + $this->config->offsetExists('storage\\phpbb_ads\\config\\path') && + $filesystem->exists($this->phpbb_root_path . 'images/phpbb_ads'); + } + /** * {@inheritDoc} */ @@ -29,15 +43,54 @@ public function update_data() { return array( ['config.add', ['storage\\phpbb_ads\\provider', local::class]], - ['config.add', ['storage\\phpbb_ads\\config\\path', 'images/phpbb_ads']], // todo: make sure this exists in migration if is a new installation + ['config.add', ['storage\\phpbb_ads\\config\\path', 'images/phpbb_ads']], + ['custom', [[$this, 'migrate_ads_storage']]], ); } + public function migrate_ads_storage() + { + /** @var filesystem $filesystem_interface */ + $filesystem = $this->container->get('filesystem'); + + /** @var file_tracker $file_tracker */ + $file_tracker = $this->container->get('storage.file_tracker'); + + if (!$filesystem->exists($this->phpbb_root_path . 'images/phpbb_ads')) + { + $filesystem->mkdir($this->phpbb_root_path . 'images/phpbb_ads'); + } + + $dir = $this->phpbb_root_path . 'images/phpbb_ads'; + $handle = @opendir($dir); + + if ($handle) + { + while (($file = readdir($handle)) !== false) + { + if ($file === '.' || $file === '..') + { + continue; + } + + $file_tracker->track_file('phpbb_ads', $file, filesize($this->phpbb_root_path . 'images/phpbb_ads/' . $file)); + } + + closedir($handle); + } + } + public function revert_data() { return [ ['config.remove', ['storage\\phpbb_ads\\provider']], ['config.remove', ['storage\\phpbb_ads\\config\\path']], + ['custom', [[$this, 'revert_ads_storage']]], ]; } + + public function revert_ads_storage() + { + $this->sql_query('DELETE FROM ' . $this->tables['storage'] . ' WHERE storage = "phpbb_ads"'); + } } From 5dd075897be40f5679f0d1f33416353207e1ae28 Mon Sep 17 00:00:00 2001 From: Ruben Calvo Date: Thu, 26 Dec 2024 20:48:37 +0100 Subject: [PATCH 3/5] Fix tests --- controller/admin_input.php | 11 +++-- migrations/v30x/m1_storage.php | 9 ++-- tests/banner/banner_base.php | 19 +++----- tests/banner/create_storage_dir_test.php | 61 ------------------------ tests/banner/remove_test.php | 5 +- tests/banner/upload_test.php | 6 +-- tests/controller/admin_input_test.php | 29 +++++------ 7 files changed, 38 insertions(+), 102 deletions(-) delete mode 100644 tests/banner/create_storage_dir_test.php diff --git a/controller/admin_input.php b/controller/admin_input.php index b5b345e6..ecaff3d0 100644 --- a/controller/admin_input.php +++ b/controller/admin_input.php @@ -41,11 +41,12 @@ class admin_input /** * Constructor * - * @param \phpbb\user $user User object - * @param \phpbb\user_loader $user_loader User loader object - * @param \phpbb\language\language $language Language object - * @param \phpbb\request\request $request Request object - * @param \phpbb\ads\banner\banner $banner Banner upload object + * @param \phpbb\controller\helper $controller_helper Controller helper object + * @param \phpbb\user $user User object + * @param \phpbb\user_loader $user_loader User loader object + * @param \phpbb\language\language $language Language object + * @param \phpbb\request\request $request Request object + * @param \phpbb\ads\banner\banner $banner Banner upload object */ public function __construct(\phpbb\controller\helper $controller_helper, \phpbb\user $user, \phpbb\user_loader $user_loader, \phpbb\language\language $language, \phpbb\request\request $request, \phpbb\ads\banner\banner $banner) { diff --git a/migrations/v30x/m1_storage.php b/migrations/v30x/m1_storage.php index 63c970e9..414f565b 100644 --- a/migrations/v30x/m1_storage.php +++ b/migrations/v30x/m1_storage.php @@ -56,12 +56,13 @@ public function migrate_ads_storage() /** @var file_tracker $file_tracker */ $file_tracker = $this->container->get('storage.file_tracker'); - if (!$filesystem->exists($this->phpbb_root_path . 'images/phpbb_ads')) + $dir = $this->phpbb_root_path . 'images/phpbb_ads'; + + if (!$filesystem->exists($dir)) { - $filesystem->mkdir($this->phpbb_root_path . 'images/phpbb_ads'); + $filesystem->mkdir($dir); } - $dir = $this->phpbb_root_path . 'images/phpbb_ads'; $handle = @opendir($dir); if ($handle) @@ -73,7 +74,7 @@ public function migrate_ads_storage() continue; } - $file_tracker->track_file('phpbb_ads', $file, filesize($this->phpbb_root_path . 'images/phpbb_ads/' . $file)); + $file_tracker->track_file('phpbb_ads', $file, filesize($dir . '/' . $file)); } closedir($handle); diff --git a/tests/banner/banner_base.php b/tests/banner/banner_base.php index ec60431b..9ced323f 100644 --- a/tests/banner/banner_base.php +++ b/tests/banner/banner_base.php @@ -15,14 +15,12 @@ class banner_base extends \phpbb_test_case /** @var \PHPUnit\Framework\MockObject\MockObject|\phpbb\files\upload */ protected $files_upload; - /** @var \PHPUnit\Framework\MockObject\MockObject|\phpbb\filesystem\filesystem */ - protected $filesystem; + /** @var \PHPUnit\Framework\MockObject\MockObject|\phpbb\files\filespec_storage */ + protected $file; - /** @var string */ - protected $root_path; + /** @var \phpbb\storage\storage */ - /** @var \PHPUnit\Framework\MockObject\MockObject|\phpbb\files\filespec */ - protected $file; + protected $storage; protected static function setup_extensions() { @@ -36,16 +34,12 @@ protected function setUp(): void { parent::setUp(); - global $phpbb_root_path; - $this->files_upload = $this->getMockBuilder('\phpbb\files\upload') ->disableOriginalConstructor() ->getMock(); - $this->filesystem = $this->getMockBuilder('\phpbb\filesystem\filesystem') + $this->storage = $this->getMockBuilder('\phpbb\storage\storage') ->disableOriginalConstructor() ->getMock(); - - $this->root_path = $phpbb_root_path; } /** @@ -57,8 +51,7 @@ public function get_manager() { return new \phpbb\ads\banner\banner( $this->files_upload, - $this->filesystem, - $this->root_path + $this->storage ); } } diff --git a/tests/banner/create_storage_dir_test.php b/tests/banner/create_storage_dir_test.php deleted file mode 100644 index efd790e0..00000000 --- a/tests/banner/create_storage_dir_test.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - */ - -namespace phpbb\ads\tests\banner; - -class create_storage_dir_test extends banner_base -{ - /** - * Test data provider for test_create_storage_dir() - * - * @return array Array of test data - */ - public function create_storage_dir_data() - { - return array( - array(false, false), - array(false, true), - array(true, false), - array(true, true), - ); - } - - /** - * Test create_storage_dir() method - * - * @dataProvider create_storage_dir_data - */ - public function test_create_storage_dir($dir_exists, $success) - { - $manager = $this->get_manager(); - - $this->filesystem->expects(self::once()) - ->method('exists') - ->with($this->root_path . 'images/phpbb_ads') - ->willReturn($dir_exists); - - if (!$dir_exists) - { - $mkdir = $this->filesystem->expects(self::once()) - ->method('mkdir') - ->with($this->root_path . 'images/phpbb_ads'); - - if (!$success) - { - $mkdir->willThrowException(new \phpbb\filesystem\exception\filesystem_exception('CANNOT_CREATE_DIRECTORY')); - - $this->expectException('\phpbb\filesystem\exception\filesystem_exception'); - $this->expectExceptionMessage('CANNOT_CREATE_DIRECTORY'); - } - } - - $manager->create_storage_dir(); - } -} diff --git a/tests/banner/remove_test.php b/tests/banner/remove_test.php index d0d05ed6..14ae56d2 100644 --- a/tests/banner/remove_test.php +++ b/tests/banner/remove_test.php @@ -20,13 +20,14 @@ public function test_remove() $manager = $this->get_manager(); // Mock filespec - $file = $this->getMockBuilder('\phpbb\files\filespec') + $file = $this->getMockBuilder('\phpbb\files\filespec_storage') ->disableOriginalConstructor() ->getMock(); $manager->set_file($file); $file->expects(self::once()) - ->method('remove'); + ->method('remove') + ->with($this->storage); $manager->remove(); } diff --git a/tests/banner/upload_test.php b/tests/banner/upload_test.php index 63e0f368..19bcb933 100644 --- a/tests/banner/upload_test.php +++ b/tests/banner/upload_test.php @@ -42,7 +42,7 @@ public function test_upload($file_move_success) ->with(array('gif', 'jpg', 'jpeg', 'png')); // Mock filespec - $file = $this->getMockBuilder('\phpbb\files\filespec') + $file = $this->getMockBuilder('\phpbb\files\filespec_storage') ->disableOriginalConstructor() ->getMock(); if (!$file_move_success) @@ -52,7 +52,7 @@ public function test_upload($file_move_success) $this->files_upload->expects(self::once()) ->method('handle_upload') - ->with('files.types.form', 'banner') + ->with('files.types.form_storage', 'banner') ->willReturn($file); $file->expects(self::once()) @@ -61,7 +61,7 @@ public function test_upload($file_move_success) $file->expects(self::once()) ->method('move_file') - ->with('images/phpbb_ads') + ->with($this->storage) ->willReturn($file_move_success); if (!$file_move_success) diff --git a/tests/controller/admin_input_test.php b/tests/controller/admin_input_test.php index 07ba124e..55e78a17 100644 --- a/tests/controller/admin_input_test.php +++ b/tests/controller/admin_input_test.php @@ -15,6 +15,9 @@ class admin_input_test extends \phpbb_database_test_case /** @var bool A return value for check_form_key() */ public static $valid_form = true; + /** @var \phpbb\controller\helper */ + protected $controller_helper; + /** @var \phpbb\user */ protected $user; @@ -60,6 +63,9 @@ protected function setUp(): void // Load/Mock classes required by the controller class $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $this->controller_helper = $this->getMockBuilder('\phpbb\controller\helper') + ->disableOriginalConstructor() + ->getMock(); $this->user = $user = new \phpbb\user($this->language, '\phpbb\datetime'); $this->user->timezone = new \DateTimeZone('UTC'); $avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper') @@ -92,6 +98,7 @@ protected function setUp(): void public function get_input_controller() { $input = new \phpbb\ads\controller\admin_input( + $this->controller_helper, $this->user, $this->user_loader, $this->language, @@ -210,24 +217,15 @@ public function test_banner_upload($can_create_directory, $can_move_file, $is_aj { $input_controller = $this->get_input_controller(); - $create_storage_dir = $this->banner->expects(self::once()) - ->method('create_storage_dir'); - if (!$can_create_directory) + $upload = $this->banner->expects(self::once()) + ->method('upload'); + if (!$can_move_file) { - $create_storage_dir->willThrowException(new \phpbb\exception\runtime_exception('CANNOT_CREATE_DIRECTORY')); + $upload->willThrowException(new \phpbb\exception\runtime_exception('FILE_MOVE_UNSUCCESSFUL')); } else { - $upload = $this->banner->expects(self::once()) - ->method('upload'); - if (!$can_move_file) - { - $upload->willThrowException(new \phpbb\exception\runtime_exception('FILE_MOVE_UNSUCCESSFUL')); - } - else - { - $upload->willReturn('abcdef.jpg'); - } + $upload->willReturn('abcdef.jpg'); } if (!$can_create_directory || !$can_move_file) @@ -236,6 +234,9 @@ public function test_banner_upload($can_create_directory, $can_move_file, $is_aj ->method('remove'); } + $this->controller_helper->method('route') + ->willReturn('/images/phpbb_ads/abcdef.jpg'); + $this->request->expects(self::once()) ->method('is_ajax') ->willReturn($is_ajax); From 6913c99a6ea3b0578a13786f184be0f74fe16d08 Mon Sep 17 00:00:00 2001 From: Ruben Calvo Date: Fri, 27 Dec 2024 00:42:56 +0100 Subject: [PATCH 4/5] Fix tests --- tests/controller/admin_input_test.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/controller/admin_input_test.php b/tests/controller/admin_input_test.php index 55e78a17..d28d18d1 100644 --- a/tests/controller/admin_input_test.php +++ b/tests/controller/admin_input_test.php @@ -198,9 +198,6 @@ public function test_get_form_data($valid_form, $data, $ad_owner_expected, $erro public function banner_upload_data() { return array( - array(false, false, false, array('CANNOT_CREATE_DIRECTORY'), '', ''), - array(false, true, false, array('CANNOT_CREATE_DIRECTORY'), '', ''), - array(false, true, true, array('CANNOT_CREATE_DIRECTORY'), '', ''), array(true, false, false, array('FILE_MOVE_UNSUCCESSFUL'), '', ''), array(true, true, false, array(), '', ''), array(true, true, false, array(), 'abc', "abc\n\n"), From 7963b91a64e07b83ab1675ec46e062f55b4366e9 Mon Sep 17 00:00:00 2001 From: Ruben Calvo Date: Sat, 18 Jan 2025 23:15:57 +0100 Subject: [PATCH 5/5] Track files in batches --- migrations/v30x/m1_storage.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/migrations/v30x/m1_storage.php b/migrations/v30x/m1_storage.php index 414f565b..31244fdb 100644 --- a/migrations/v30x/m1_storage.php +++ b/migrations/v30x/m1_storage.php @@ -15,6 +15,8 @@ class m1_storage extends \phpbb\db\migration\container_aware_migration { + private const BATCH_SIZE = 100; + /** * {@inheritdoc} */ @@ -33,19 +35,19 @@ public function effectively_installed() */ public static function depends_on() { - return array( + return [ '\phpbb\db\migration\data\v400\dev', '\phpbb\ads\migrations\v20x\m1_hide_ad_for_group', - ); + ]; } public function update_data() { - return array( + return [ ['config.add', ['storage\\phpbb_ads\\provider', local::class]], ['config.add', ['storage\\phpbb_ads\\config\\path', 'images/phpbb_ads']], ['custom', [[$this, 'migrate_ads_storage']]], - ); + ]; } public function migrate_ads_storage() @@ -67,6 +69,7 @@ public function migrate_ads_storage() if ($handle) { + $files = []; while (($file = readdir($handle)) !== false) { if ($file === '.' || $file === '..') @@ -74,7 +77,21 @@ public function migrate_ads_storage() continue; } - $file_tracker->track_file('phpbb_ads', $file, filesize($dir . '/' . $file)); + $files[] = [ + 'file_path' => $file, + 'filesize' => filesize($dir . '/' . $file), + ]; + + if (count($files) >= self::BATCH_SIZE) + { + $file_tracker->track_files('phpbb_ads', $files); + $files = []; + } + } + + if (!empty($files)) + { + $file_tracker->track_files('phpbb_ads', $files); } closedir($handle);