1 | <?php |
||
2 | /** |
||
3 | * |
||
4 | * Advertisement management. An extension for the phpBB Forum Software package. |
||
5 | * |
||
6 | * @copyright (c) 2017 phpBB Limited <https://www.phpbb.com> |
||
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
||
8 | * |
||
9 | */ |
||
10 | |||
11 | namespace phpbb\ads\banner; |
||
12 | |||
13 | class banner |
||
14 | { |
||
15 | /** @var \phpbb\files\upload */ |
||
0 ignored issues
–
show
|
|||
16 | protected $files_upload; |
||
17 | |||
18 | /** @var \phpbb\filesystem\filesystem_interface */ |
||
0 ignored issues
–
show
The type
phpbb\filesystem\filesystem_interface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
19 | protected $filesystem; |
||
20 | |||
21 | /** @var string */ |
||
22 | protected $root_path; |
||
23 | |||
24 | /** @var \phpbb\files\filespec */ |
||
0 ignored issues
–
show
The type
phpbb\files\filespec was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
25 | protected $file; |
||
26 | |||
27 | /** |
||
28 | * Constructor |
||
29 | * |
||
30 | * @param \phpbb\files\upload $files_upload Files upload object |
||
31 | * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem object |
||
32 | * @param string $root_path Root path |
||
33 | */ |
||
34 | 7 | public function __construct(\phpbb\files\upload $files_upload, \phpbb\filesystem\filesystem_interface $filesystem, $root_path) |
|
35 | { |
||
36 | 7 | $this->files_upload = $files_upload; |
|
37 | 7 | $this->filesystem = $filesystem; |
|
38 | 7 | $this->root_path = $root_path; |
|
39 | 7 | } |
|
40 | |||
41 | 3 | public function set_file($file) |
|
42 | { |
||
43 | 3 | $this->file = $file; |
|
44 | 3 | } |
|
45 | |||
46 | /** |
||
47 | * Create storage directory for banners uploaded by Ads Management |
||
48 | * |
||
49 | * @throws \phpbb\filesystem\exception\filesystem_exception |
||
50 | */ |
||
51 | 4 | public function create_storage_dir() |
|
52 | { |
||
53 | 4 | if (!$this->filesystem->exists($this->root_path . 'images/phpbb_ads')) |
|
54 | 4 | { |
|
55 | 2 | $this->filesystem->mkdir($this->root_path . 'images/phpbb_ads'); |
|
56 | 1 | } |
|
57 | 3 | } |
|
58 | |||
59 | /** |
||
60 | * Handle banner upload |
||
61 | * |
||
62 | * @throws \phpbb\exception\runtime_exception |
||
63 | * @return string Filename |
||
64 | */ |
||
65 | 2 | public function upload() |
|
66 | { |
||
67 | // Set file restrictions |
||
68 | 2 | $this->files_upload->reset_vars(); |
|
69 | 2 | $this->files_upload->set_allowed_extensions(array('gif', 'jpg', 'jpeg', 'png')); |
|
70 | |||
71 | // Upload file |
||
72 | 2 | $this->set_file($this->files_upload->handle_upload('files.types.form', 'banner')); |
|
73 | 2 | $this->file->clean_filename('unique_ext'); |
|
74 | |||
75 | // Move file to proper location |
||
76 | 2 | if (!$this->file->move_file('images/phpbb_ads')) |
|
77 | 2 | { |
|
78 | 1 | $this->file->set_error('FILE_MOVE_UNSUCCESSFUL'); |
|
79 | 1 | } |
|
80 | |||
81 | 2 | if (count($this->file->error)) |
|
82 | 2 | { |
|
83 | 1 | throw new \phpbb\exception\runtime_exception($this->file->error[0]); |
|
0 ignored issues
–
show
The type
phpbb\exception\runtime_exception was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
84 | } |
||
85 | |||
86 | 1 | return $this->file->get('realname'); |
|
87 | } |
||
88 | |||
89 | /** |
||
90 | * Remove file from the filesystem |
||
91 | */ |
||
92 | 1 | public function remove() |
|
93 | { |
||
94 | 1 | $this->file->remove(); |
|
95 | 1 | } |
|
96 | } |
||
97 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths