PageRenderTime 26ms CodeModel.GetById 46ms RepoModel.GetById 0ms app.codeStats 0ms

/phpBB/bin/phpbbcli.php

https://github.com/michaelcullum/phpbb3
PHP | 92 lines | 67 code | 11 blank | 14 comment | 3 complexity | ac81e3ee7c2de12cca3170145592e208 MD5 | raw file
  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. use Symfony\Component\Console\Input\ArgvInput;
  15. if (php_sapi_name() != 'cli')
  16. {
  17. echo 'This program must be run from the command line.' . PHP_EOL;
  18. exit(1);
  19. }
  20. define('IN_PHPBB', true);
  21. $phpbb_root_path = __DIR__ . '/../';
  22. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  23. require($phpbb_root_path . 'includes/startup.' . $phpEx);
  24. require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx);
  25. $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
  26. $phpbb_class_loader->register();
  27. $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx);
  28. extract($phpbb_config_php_file->get_all());
  29. if (!defined('PHPBB_ENVIRONMENT'))
  30. {
  31. @define('PHPBB_ENVIRONMENT', 'production');
  32. }
  33. require($phpbb_root_path . 'includes/constants.' . $phpEx);
  34. require($phpbb_root_path . 'includes/functions.' . $phpEx);
  35. require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
  36. require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
  37. require($phpbb_root_path . 'includes/functions_compatibility.' . $phpEx);
  38. $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx);
  39. $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file);
  40. $input = new ArgvInput();
  41. if ($input->hasParameterOption(array('--env')))
  42. {
  43. $phpbb_container_builder->with_environment($input->getParameterOption('--env'));
  44. }
  45. if ($input->hasParameterOption(array('--safe-mode')))
  46. {
  47. $phpbb_container_builder->without_extensions();
  48. $phpbb_container_builder->without_cache();
  49. }
  50. else
  51. {
  52. $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
  53. $phpbb_class_loader_ext->register();
  54. }
  55. $phpbb_container = $phpbb_container_builder->get_container();
  56. $phpbb_container->get('request')->enable_super_globals();
  57. require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx);
  58. register_compatibility_globals();
  59. if (@is_file($phpbb_root_path . $config['exts_composer_vendor_dir'] . '/autoload.php'))
  60. {
  61. require_once($phpbb_root_path . $config['exts_composer_vendor_dir'] . '/autoload.php');
  62. }
  63. /** @var \phpbb\language\language $language */
  64. $language = $phpbb_container->get('language');
  65. $language->set_default_language($phpbb_container->get('config')['default_lang']);
  66. $language->add_lang(array('common', 'acp/common', 'cli'));
  67. /* @var $user \phpbb\user */
  68. $user = $phpbb_container->get('user');
  69. $user->data['user_id'] = ANONYMOUS;
  70. $user->ip = '127.0.0.1';
  71. $application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION, $language);
  72. $application->setDispatcher($phpbb_container->get('dispatcher'));
  73. $application->register_container_commands($phpbb_container->get('console.command_collection'));
  74. $application->run($input);