1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/common.php Wed Mar 07 16:41:10 2012 +0400
1.3 @@ -0,0 +1,125 @@
1.4 +<?php
1.5 +/**
1.6 +*
1.7 +* @package phpBB3
1.8 +* @version $Id$
1.9 +* @copyright (c) 2005 phpBB Group
1.10 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License
1.11 +*
1.12 +* Minimum Requirement: PHP 4.3.3
1.13 +*/
1.14 +
1.15 +/**
1.16 +*/
1.17 +if (!defined('IN_PHPBB'))
1.18 +{
1.19 + exit;
1.20 +}
1.21 +
1.22 +require($phpbb_root_path . 'includes/startup.' . $phpEx);
1.23 +
1.24 +if (file_exists($phpbb_root_path . 'config.' . $phpEx))
1.25 +{
1.26 + require($phpbb_root_path . 'config.' . $phpEx);
1.27 +}
1.28 +
1.29 +if (!defined('PHPBB_INSTALLED'))
1.30 +{
1.31 + // Redirect the user to the installer
1.32 + // We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
1.33 + // available as used by the redirect function
1.34 + $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
1.35 + $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
1.36 + $secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
1.37 +
1.38 + $script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
1.39 + if (!$script_name)
1.40 + {
1.41 + $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
1.42 + }
1.43 +
1.44 + // Replace any number of consecutive backslashes and/or slashes with a single slash
1.45 + // (could happen on some proxy setups and/or Windows servers)
1.46 + $script_path = trim(dirname($script_name)) . '/install/index.' . $phpEx;
1.47 + $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
1.48 +
1.49 + $url = (($secure) ? 'https://' : 'http://') . $server_name;
1.50 +
1.51 + if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
1.52 + {
1.53 + // HTTP HOST can carry a port number...
1.54 + if (strpos($server_name, ':') === false)
1.55 + {
1.56 + $url .= ':' . $server_port;
1.57 + }
1.58 + }
1.59 +
1.60 + $url .= $script_path;
1.61 + header('Location: ' . $url);
1.62 + exit;
1.63 +}
1.64 +
1.65 +if (defined('DEBUG_EXTRA'))
1.66 +{
1.67 + $base_memory_usage = 0;
1.68 + if (function_exists('memory_get_usage'))
1.69 + {
1.70 + $base_memory_usage = memory_get_usage();
1.71 + }
1.72 +}
1.73 +
1.74 +// Load Extensions
1.75 +// dl() is deprecated and disabled by default as of PHP 5.3.
1.76 +if (!empty($load_extensions) && function_exists('dl'))
1.77 +{
1.78 + $load_extensions = explode(',', $load_extensions);
1.79 +
1.80 + foreach ($load_extensions as $extension)
1.81 + {
1.82 + @dl(trim($extension));
1.83 + }
1.84 +}
1.85 +
1.86 +// Include files
1.87 +require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
1.88 +require($phpbb_root_path . 'includes/cache.' . $phpEx);
1.89 +require($phpbb_root_path . 'includes/template.' . $phpEx);
1.90 +require($phpbb_root_path . 'includes/session.' . $phpEx);
1.91 +require($phpbb_root_path . 'includes/auth.' . $phpEx);
1.92 +
1.93 +require($phpbb_root_path . 'includes/functions.' . $phpEx);
1.94 +require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
1.95 +
1.96 +require($phpbb_root_path . 'includes/constants.' . $phpEx);
1.97 +require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
1.98 +require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
1.99 +
1.100 +// Set PHP error handler to ours
1.101 +set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
1.102 +
1.103 +// Instantiate some basic classes
1.104 +$user = new user();
1.105 +$auth = new auth();
1.106 +$template = new template();
1.107 +$cache = new cache();
1.108 +$db = new $sql_db();
1.109 +
1.110 +// Connect to DB
1.111 +$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
1.112 +
1.113 +// We do not need this any longer, unset for safety purposes
1.114 +unset($dbpasswd);
1.115 +
1.116 +// Grab global variables, re-cache if necessary
1.117 +$config = $cache->obtain_config();
1.118 +
1.119 +// Add own hook handler
1.120 +require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
1.121 +$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
1.122 +
1.123 +foreach ($cache->obtain_hooks() as $hook)
1.124 +{
1.125 + @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
1.126 +}
1.127 +
1.128 +?>
1.129 \ No newline at end of file