Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 48 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
| 1 | #!/usr/bin/env php |
| 2 | <?php |
| 3 | /** |
| 4 | * |
| 5 | * This file is part of the phpBB Forum Software package. |
| 6 | * |
| 7 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 8 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 9 | * |
| 10 | * For full copyright and license information, please see |
| 11 | * the docs/CREDITS.txt file. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | use Symfony\Component\Console\Input\ArgvInput; |
| 16 | |
| 17 | if (php_sapi_name() != 'cli') |
| 18 | { |
| 19 | echo 'This program must be run from the command line.' . PHP_EOL; |
| 20 | exit(1); |
| 21 | } |
| 22 | |
| 23 | define('IN_PHPBB', true); |
| 24 | |
| 25 | $phpbb_root_path = __DIR__ . '/../'; |
| 26 | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
| 27 | require($phpbb_root_path . 'includes/startup.' . $phpEx); |
| 28 | require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); |
| 29 | |
| 30 | $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); |
| 31 | $phpbb_class_loader->register(); |
| 32 | |
| 33 | $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); |
| 34 | extract($phpbb_config_php_file->get_all()); |
| 35 | |
| 36 | if (!defined('PHPBB_ENVIRONMENT')) |
| 37 | { |
| 38 | @define('PHPBB_ENVIRONMENT', 'production'); |
| 39 | } |
| 40 | |
| 41 | require($phpbb_root_path . 'includes/constants.' . $phpEx); |
| 42 | require($phpbb_root_path . 'includes/functions.' . $phpEx); |
| 43 | require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); |
| 44 | require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); |
| 45 | require($phpbb_root_path . 'includes/functions_compatibility.' . $phpEx); |
| 46 | |
| 47 | $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); |
| 48 | $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file); |
| 49 | |
| 50 | $input = new ArgvInput(); |
| 51 | |
| 52 | if ($input->hasParameterOption(array('--env'))) |
| 53 | { |
| 54 | $phpbb_container_builder->with_environment($input->getParameterOption('--env')); |
| 55 | } |
| 56 | |
| 57 | if ($input->hasParameterOption(array('--safe-mode'))) |
| 58 | { |
| 59 | $phpbb_container_builder->without_extensions(); |
| 60 | $phpbb_container_builder->without_cache(); |
| 61 | } |
| 62 | else |
| 63 | { |
| 64 | $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); |
| 65 | $phpbb_class_loader_ext->register(); |
| 66 | } |
| 67 | |
| 68 | $phpbb_container = $phpbb_container_builder->get_container(); |
| 69 | $phpbb_container->get('request')->enable_super_globals(); |
| 70 | require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx); |
| 71 | |
| 72 | register_compatibility_globals(); |
| 73 | |
| 74 | if (@is_file($phpbb_root_path . $config['exts_composer_vendor_dir'] . '/autoload.php')) |
| 75 | { |
| 76 | require_once($phpbb_root_path . $config['exts_composer_vendor_dir'] . '/autoload.php'); |
| 77 | } |
| 78 | |
| 79 | /** @var \phpbb\config\config $config */ |
| 80 | $config = $phpbb_container->get('config'); |
| 81 | |
| 82 | /** @var \phpbb\language\language $language */ |
| 83 | $language = $phpbb_container->get('language'); |
| 84 | $language->set_default_language($config['default_lang']); |
| 85 | $language->add_lang(array('common', 'acp/common', 'cli')); |
| 86 | |
| 87 | /* @var $user \phpbb\user */ |
| 88 | $user = $phpbb_container->get('user'); |
| 89 | $user->data['user_id'] = ANONYMOUS; |
| 90 | $user->ip = '127.0.0.1'; |
| 91 | |
| 92 | $application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION, $language, $config); |
| 93 | $application->setDispatcher($phpbb_container->get('event_dispatcher')); |
| 94 | $application->register_container_commands($phpbb_container->get('console.command_collection')); |
| 95 | $application->run($input); |