Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 61 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | /** |
| 15 | * Minimum Requirement: PHP 7.2.0 |
| 16 | */ |
| 17 | |
| 18 | if (!defined('IN_PHPBB')) |
| 19 | { |
| 20 | exit; |
| 21 | } |
| 22 | |
| 23 | require($phpbb_root_path . 'includes/startup.' . $phpEx); |
| 24 | require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); |
| 25 | |
| 26 | $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); |
| 27 | $phpbb_class_loader->register(); |
| 28 | |
| 29 | $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); |
| 30 | extract($phpbb_config_php_file->get_all()); |
| 31 | |
| 32 | if (!defined('PHPBB_ENVIRONMENT')) |
| 33 | { |
| 34 | @define('PHPBB_ENVIRONMENT', 'production'); |
| 35 | } |
| 36 | |
| 37 | if (!defined('PHPBB_INSTALLED')) |
| 38 | { |
| 39 | // Redirect the user to the installer |
| 40 | require($phpbb_root_path . 'includes/functions.' . $phpEx); |
| 41 | |
| 42 | // We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information |
| 43 | // available as used by the redirect function |
| 44 | $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); |
| 45 | $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'); |
| 46 | $secure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 1 : 0; |
| 47 | |
| 48 | if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') |
| 49 | { |
| 50 | $secure = 1; |
| 51 | $server_port = 443; |
| 52 | } |
| 53 | |
| 54 | $script_path = phpbb_get_install_redirect($phpbb_root_path, $phpEx); |
| 55 | |
| 56 | // Eliminate . and .. from the path |
| 57 | require($phpbb_root_path . 'phpbb/filesystem/helper.' . $phpEx); |
| 58 | $script_path = \phpbb\filesystem\helper::clean_path($script_path); |
| 59 | |
| 60 | $url = (($secure) ? 'https://' : 'http://') . $server_name; |
| 61 | |
| 62 | if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80))) |
| 63 | { |
| 64 | // HTTP HOST can carry a port number... |
| 65 | if (strpos($server_name, ':') === false) |
| 66 | { |
| 67 | $url .= ':' . $server_port; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | $url .= $script_path; |
| 72 | header('Location: ' . $url); |
| 73 | exit; |
| 74 | } |
| 75 | |
| 76 | // In case $phpbb_adm_relative_path is not set (in case of an update), use the default. |
| 77 | $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/'; |
| 78 | $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; |
| 79 | |
| 80 | // Include files |
| 81 | require($phpbb_root_path . 'includes/functions.' . $phpEx); |
| 82 | require($phpbb_root_path . 'includes/functions_content.' . $phpEx); |
| 83 | include($phpbb_root_path . 'includes/functions_compatibility.' . $phpEx); |
| 84 | |
| 85 | require($phpbb_root_path . 'includes/constants.' . $phpEx); |
| 86 | require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); |
| 87 | |
| 88 | // Registered before building the container so the development environment stay capable of intercepting |
| 89 | // the container builder exceptions. |
| 90 | \phpbb\debug\debug::enable(null, PHPBB_ENVIRONMENT === 'development'); |
| 91 | |
| 92 | $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); |
| 93 | $phpbb_class_loader_ext->register(); |
| 94 | |
| 95 | // Set up container |
| 96 | try |
| 97 | { |
| 98 | $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); |
| 99 | |
| 100 | // Check that cache directory is writable before trying to build container |
| 101 | $cache_dir = $phpbb_container_builder->get_cache_dir(); |
| 102 | if (file_exists($cache_dir) && !is_writable($phpbb_container_builder->get_cache_dir())) |
| 103 | { |
| 104 | die('Unable to write to the cache directory path "' . $cache_dir . '". Ensure that the web server user can write to the cache folder.'); |
| 105 | } |
| 106 | |
| 107 | $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file)->get_container(); |
| 108 | } |
| 109 | catch (InvalidArgumentException $e) |
| 110 | { |
| 111 | if (PHPBB_ENVIRONMENT !== 'development') |
| 112 | { |
| 113 | trigger_error( |
| 114 | 'The requested environment ' . PHPBB_ENVIRONMENT . ' is not available.', |
| 115 | E_USER_ERROR |
| 116 | ); |
| 117 | } |
| 118 | else |
| 119 | { |
| 120 | throw $e; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | if ($phpbb_container->getParameter('debug.error_handler')) |
| 125 | { |
| 126 | \phpbb\debug\debug::enable(); |
| 127 | } |
| 128 | |
| 129 | $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); |
| 130 | $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); |
| 131 | |
| 132 | $phpbb_container->get('dbal.conn')->set_debug_sql_explain($phpbb_container->getParameter('debug.sql_explain')); |
| 133 | $phpbb_container->get('dbal.conn')->set_debug_load_time($phpbb_container->getParameter('debug.load_time')); |
| 134 | |
| 135 | require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx); |
| 136 | |
| 137 | register_compatibility_globals(); |
| 138 | |
| 139 | if (@is_file($phpbb_root_path . $config['exts_composer_vendor_dir'] . '/autoload.php')) |
| 140 | { |
| 141 | require_once($phpbb_root_path . $config['exts_composer_vendor_dir'] . '/autoload.php'); |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Main event which is triggered on every page |
| 146 | * |
| 147 | * You can use this event to load function files and initiate objects |
| 148 | * |
| 149 | * NOTE: At this point the global session ($user) and permissions ($auth) |
| 150 | * do NOT exist yet. If you need to use the user object |
| 151 | * (f.e. to include language files) or need to check permissions, |
| 152 | * please use the core.user_setup event instead! |
| 153 | * |
| 154 | * @event core.common |
| 155 | * @since 3.1.0-a1 |
| 156 | */ |
| 157 | $phpbb_dispatcher->trigger_event('core.common'); |