phpbb-extensions /
ad-management
| 1 | <?php |
||||||
| 2 | /** |
||||||
| 3 | * |
||||||
| 4 | * Advertisement management. An extension for the phpBB Forum Software package. |
||||||
| 5 | * |
||||||
| 6 | * @copyright (c) 2018 phpBB Limited <https://www.phpbb.com> |
||||||
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
||||||
| 8 | * |
||||||
| 9 | */ |
||||||
| 10 | |||||||
| 11 | namespace phpbb\ads\controller; |
||||||
| 12 | |||||||
| 13 | /** |
||||||
| 14 | * Visual demo controller |
||||||
| 15 | */ |
||||||
| 16 | class visual_demo_controller |
||||||
| 17 | { |
||||||
| 18 | /** @var \phpbb\auth\auth */ |
||||||
|
0 ignored issues
–
show
|
|||||||
| 19 | protected $auth; |
||||||
| 20 | |||||||
| 21 | /** @var \phpbb\config\config */ |
||||||
|
0 ignored issues
–
show
The type
phpbb\config\config 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 Loading history...
|
|||||||
| 22 | protected $config; |
||||||
| 23 | |||||||
| 24 | /** @var \phpbb\request\request */ |
||||||
|
0 ignored issues
–
show
The type
phpbb\request\request 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 Loading history...
|
|||||||
| 25 | protected $request; |
||||||
| 26 | |||||||
| 27 | /** @var \phpbb\user */ |
||||||
|
0 ignored issues
–
show
The type
phpbb\user 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 Loading history...
|
|||||||
| 28 | protected $user; |
||||||
| 29 | |||||||
| 30 | /** @var string */ |
||||||
| 31 | protected $root_path; |
||||||
| 32 | |||||||
| 33 | /** @var string */ |
||||||
| 34 | protected $php_ext; |
||||||
| 35 | |||||||
| 36 | /** |
||||||
| 37 | * Constructor |
||||||
| 38 | * |
||||||
| 39 | * @param \phpbb\auth\auth $auth |
||||||
| 40 | * @param \phpbb\config\config $config |
||||||
| 41 | * @param \phpbb\request\request $request |
||||||
| 42 | * @param \phpbb\user $user |
||||||
| 43 | * @param string $root_path |
||||||
| 44 | * @param string $php_ext |
||||||
| 45 | */ |
||||||
| 46 | 6 | public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\request\request $request, \phpbb\user $user, $root_path, $php_ext) |
|||||
| 47 | { |
||||||
| 48 | 6 | $this->auth = $auth; |
|||||
| 49 | 6 | $this->config = $config; |
|||||
| 50 | 6 | $this->request = $request; |
|||||
| 51 | 6 | $this->user = $user; |
|||||
| 52 | 6 | $this->root_path = $root_path; |
|||||
| 53 | 6 | $this->php_ext = $php_ext; |
|||||
| 54 | 6 | } |
|||||
| 55 | |||||||
| 56 | /** |
||||||
| 57 | * Visual demo handler |
||||||
| 58 | * |
||||||
| 59 | * When called by an admin, add or remove the visual demo cookie |
||||||
| 60 | * and direct them to an appropriate forum page to view. |
||||||
| 61 | * |
||||||
| 62 | * @param string $action enable|disable |
||||||
| 63 | * @return \Symfony\Component\HttpFoundation\JsonResponse |
||||||
| 64 | * @throws \phpbb\exception\http_exception http exception |
||||||
| 65 | */ |
||||||
| 66 | 6 | public function handle($action) |
|||||
| 67 | { |
||||||
| 68 | // Protect against unauthorised access |
||||||
| 69 | 6 | if (!$this->auth->acl_get('a_')) |
|||||
| 70 | 6 | { |
|||||
| 71 | 2 | throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION'); |
|||||
|
0 ignored issues
–
show
The type
phpbb\exception\http_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 Loading history...
|
|||||||
| 72 | } |
||||||
| 73 | |||||||
| 74 | 4 | if ($action === 'disable') |
|||||
| 75 | 4 | { |
|||||
| 76 | // Destroy our cookie and redirect user to previous page viewed. |
||||||
| 77 | 2 | $this->user->set_cookie('phpbb_ads_visual_demo', '', 1); |
|||||
| 78 | 2 | $redirect = $this->request->variable('redirect', $this->user->data['session_page']); |
|||||
| 79 | 2 | } |
|||||
| 80 | else |
||||||
| 81 | { |
||||||
| 82 | // Create our cookie and send user to the index page. |
||||||
| 83 | 2 | $this->user->set_cookie('phpbb_ads_visual_demo', time(), 0); |
|||||
| 84 | 2 | $redirect = "{$this->root_path}index.$this->php_ext"; |
|||||
| 85 | } |
||||||
| 86 | |||||||
| 87 | // Send a JSON response if an AJAX request was used |
||||||
| 88 | 4 | if ($this->request->is_ajax()) |
|||||
| 89 | 4 | { |
|||||
| 90 | 2 | return new \Symfony\Component\HttpFoundation\JsonResponse(array( |
|||||
|
0 ignored issues
–
show
The type
Symfony\Component\HttpFoundation\JsonResponse 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 Loading history...
|
|||||||
| 91 | 2 | 'success' => true, |
|||||
| 92 | 2 | )); |
|||||
| 93 | } |
||||||
| 94 | |||||||
| 95 | // Redirect user to a page |
||||||
| 96 | 2 | $redirect = reapply_sid($redirect); |
|||||
|
0 ignored issues
–
show
The function
reapply_sid was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 97 | 2 | redirect($redirect); |
|||||
|
0 ignored issues
–
show
The function
redirect was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 98 | |||||||
| 99 | // We shouldn't get here, but throw http exception just in case |
||||||
| 100 | throw new \phpbb\exception\http_exception(500, 'GENERAL_ERROR'); |
||||||
| 101 | } |
||||||
| 102 | } |
||||||
| 103 |
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