aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/startup.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/startup.php')
-rw-r--r--phpBB/includes/startup.php114
1 files changed, 47 insertions, 67 deletions
diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php
index 008651c236..7353b90d99 100644
--- a/phpBB/includes/startup.php
+++ b/phpBB/includes/startup.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -20,21 +24,6 @@ if (!defined('E_DEPRECATED'))
define('E_DEPRECATED', 8192);
}
$level = E_ALL & ~E_NOTICE & ~E_DEPRECATED;
-if (version_compare(PHP_VERSION, '5.4.0-dev', '>='))
-{
- // PHP 5.4 adds E_STRICT to E_ALL.
- // Our utf8 normalizer triggers E_STRICT output on PHP 5.4.
- // Unfortunately it cannot be made E_STRICT-clean while
- // continuing to work on PHP 4.
- // Therefore, in phpBB 3.0.x we disable E_STRICT on PHP 5.4+,
- // while phpBB 3.1 will fix utf8 normalizer.
- // E_STRICT is defined starting with PHP 5
- if (!defined('E_STRICT'))
- {
- define('E_STRICT', 2048);
- }
- $level &= ~E_STRICT;
-}
error_reporting($level);
/*
@@ -95,54 +84,6 @@ function deregister_globals()
unset($input);
}
-/**
- * Check if requested page uses a trailing path
- *
- * @param string $phpEx PHP extension
- *
- * @return bool True if trailing path is used, false if not
- */
-function phpbb_has_trailing_path($phpEx)
-{
- // Check if path_info is being used
- if (!empty($_SERVER['PATH_INFO']) || (!empty($_SERVER['ORIG_PATH_INFO']) && $_SERVER['SCRIPT_NAME'] != $_SERVER['ORIG_PATH_INFO']))
- {
- return true;
- }
-
- // Match any trailing path appended to a php script in the REQUEST_URI.
- // It is assumed that only actual PHP scripts use names like foo.php. Due
- // to this, any phpBB board inside a directory that has the php extension
- // appended to its name will stop working, i.e. if the board is at
- // example.com/phpBB/test.php/ or example.com/test.php/
- if (preg_match('#^[^?]+\.' . preg_quote($phpEx, '#') . '/#', $_SERVER['REQUEST_URI']))
- {
- return true;
- }
-
- return false;
-}
-
-// Check if trailing path is used
-if (phpbb_has_trailing_path($phpEx))
-{
- if (substr(strtolower(@php_sapi_name()), 0, 3) === 'cgi')
- {
- $prefix = 'Status:';
- }
- else if (!empty($_SERVER['SERVER_PROTOCOL']) && is_string($_SERVER['SERVER_PROTOCOL']) && preg_match('#^HTTP/[0-9]\.[0-9]$#', $_SERVER['SERVER_PROTOCOL']))
- {
- $prefix = $_SERVER['SERVER_PROTOCOL'];
- }
- else
- {
- $prefix = 'HTTP/1.0';
- }
- header("$prefix 404 Not Found", true, 404);
- echo 'Trailing paths and PATH_INFO is not supported by phpBB 3.0';
- exit;
-}
-
// Register globals and magic quotes have been dropped in PHP 5.4
if (version_compare(PHP_VERSION, '5.4.0-dev', '>='))
{
@@ -153,7 +94,11 @@ if (version_compare(PHP_VERSION, '5.4.0-dev', '>='))
}
else
{
- @set_magic_quotes_runtime(0);
+ if (get_magic_quotes_runtime())
+ {
+ // Deactivate
+ @set_magic_quotes_runtime(0);
+ }
// Be paranoid with passed vars
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on' || !function_exists('ini_get'))
@@ -192,5 +137,40 @@ if (function_exists('date_default_timezone_set') && function_exists('date_defaul
date_default_timezone_set(@date_default_timezone_get());
}
+// Autoloading of dependencies.
+// Three options are supported:
+// 1. If dependencies are installed with Composer, Composer will create a
+// vendor/autoload.php. If this file exists it will be
+// automatically used by phpBB. This is the default mode that phpBB
+// will use when shipped.
+// 2. To disable composer autoloading, PHPBB_NO_COMPOSER_AUTOLOAD can be specified.
+// Additionally specify PHPBB_AUTOLOAD=/path/to/autoload.php in the
+// environment. This is useful for running CLI scripts and tests.
+// /path/to/autoload.php should define and register class loaders
+// for all of phpBB's dependencies.
+// 3. You can also set PHPBB_NO_COMPOSER_AUTOLOAD without setting PHPBB_AUTOLOAD.
+// In this case autoloading needs to be defined before running any phpBB
+// script. This might be useful in cases when phpBB is integrated into a
+// larger program.
+if (getenv('PHPBB_NO_COMPOSER_AUTOLOAD'))
+{
+ if (getenv('PHPBB_AUTOLOAD'))
+ {
+ require(getenv('PHPBB_AUTOLOAD'));
+ }
+}
+else
+{
+ if (!file_exists($phpbb_root_path . 'vendor/autoload.php'))
+ {
+ trigger_error(
+ 'Composer dependencies have not been set up yet, run ' .
+ "'php ../composer.phar install' from the phpBB directory to do so.",
+ E_USER_ERROR
+ );
+ }
+ require($phpbb_root_path . 'vendor/autoload.php');
+}
+
$starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0];