root / tags / release_2_0_2 / phpBB / common.php
History | View | Annotate | Download (5.1 kB)
| 1 | 38 | psotfx | <?php
|
|---|---|---|---|
| 2 | 200 | thefinn | /***************************************************************************
|
| 3 | 200 | thefinn | * common.php |
| 4 | 200 | thefinn | * ------------------- |
| 5 | 200 | thefinn | * begin : Saturday, Feb 23, 2001 |
| 6 | 200 | thefinn | * copyright : (C) 2001 The phpBB Group |
| 7 | 200 | thefinn | * email : support@phpbb.com |
| 8 | 200 | thefinn | * |
| 9 | 38 | psotfx | * $Id$ |
| 10 | 200 | thefinn | * |
| 11 | 200 | thefinn | * |
| 12 | 200 | thefinn | ***************************************************************************/ |
| 13 | 38 | psotfx | |
| 14 | 943 | thefinn | /***************************************************************************
|
| 15 | 943 | thefinn | * |
| 16 | 943 | thefinn | * This program is free software; you can redistribute it and/or modify |
| 17 | 943 | thefinn | * it under the terms of the GNU General Public License as published by |
| 18 | 943 | thefinn | * the Free Software Foundation; either version 2 of the License, or |
| 19 | 943 | thefinn | * (at your option) any later version. |
| 20 | 943 | thefinn | * |
| 21 | 943 | thefinn | ***************************************************************************/ |
| 22 | 943 | thefinn | |
| 23 | 2327 | psotfx | if ( !defined('IN_PHPBB') ) |
| 24 | 2327 | psotfx | {
|
| 25 | 2327 | psotfx | die("Hacking attempt"); |
| 26 | 2327 | psotfx | } |
| 27 | 2327 | psotfx | |
| 28 | 824 | psotfx | error_reporting (E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables |
| 29 | 824 | psotfx | set_magic_quotes_runtime(0); // Disable magic_quotes_runtime |
| 30 | 824 | psotfx | |
| 31 | 237 | psotfx | //
|
| 32 | 824 | psotfx | // addslashes to vars if magic_quotes_gpc is off
|
| 33 | 824 | psotfx | // this is a security precaution to prevent someone
|
| 34 | 824 | psotfx | // trying to break out of a SQL statement.
|
| 35 | 824 | psotfx | //
|
| 36 | 824 | psotfx | if( !get_magic_quotes_gpc() ) |
| 37 | 824 | psotfx | {
|
| 38 | 1054 | psotfx | if( is_array($HTTP_GET_VARS) ) |
| 39 | 824 | psotfx | {
|
| 40 | 1054 | psotfx | while( list($k, $v) = each($HTTP_GET_VARS) ) |
| 41 | 843 | psotfx | {
|
| 42 | 1054 | psotfx | if( is_array($HTTP_GET_VARS[$k]) ) |
| 43 | 843 | psotfx | {
|
| 44 | 1054 | psotfx | while( list($k2, $v2) = each($HTTP_GET_VARS[$k]) ) |
| 45 | 1054 | psotfx | {
|
| 46 | 1054 | psotfx | $HTTP_GET_VARS[$k][$k2] = addslashes($v2); |
| 47 | 1054 | psotfx | } |
| 48 | 1054 | psotfx | @reset($HTTP_GET_VARS[$k]); |
| 49 | 843 | psotfx | } |
| 50 | 1054 | psotfx | else
|
| 51 | 1054 | psotfx | {
|
| 52 | 1054 | psotfx | $HTTP_GET_VARS[$k] = addslashes($v); |
| 53 | 1054 | psotfx | } |
| 54 | 843 | psotfx | } |
| 55 | 1054 | psotfx | @reset($HTTP_GET_VARS); |
| 56 | 824 | psotfx | } |
| 57 | 824 | psotfx | |
| 58 | 1054 | psotfx | if( is_array($HTTP_POST_VARS) ) |
| 59 | 824 | psotfx | {
|
| 60 | 1054 | psotfx | while( list($k, $v) = each($HTTP_POST_VARS) ) |
| 61 | 843 | psotfx | {
|
| 62 | 1054 | psotfx | if( is_array($HTTP_POST_VARS[$k]) ) |
| 63 | 843 | psotfx | {
|
| 64 | 1054 | psotfx | while( list($k2, $v2) = each($HTTP_POST_VARS[$k]) ) |
| 65 | 1054 | psotfx | {
|
| 66 | 1054 | psotfx | $HTTP_POST_VARS[$k][$k2] = addslashes($v2); |
| 67 | 1054 | psotfx | } |
| 68 | 1054 | psotfx | @reset($HTTP_POST_VARS[$k]); |
| 69 | 843 | psotfx | } |
| 70 | 1054 | psotfx | else
|
| 71 | 1054 | psotfx | {
|
| 72 | 1054 | psotfx | $HTTP_POST_VARS[$k] = addslashes($v); |
| 73 | 1054 | psotfx | } |
| 74 | 843 | psotfx | } |
| 75 | 1054 | psotfx | @reset($HTTP_POST_VARS); |
| 76 | 824 | psotfx | } |
| 77 | 824 | psotfx | |
| 78 | 1054 | psotfx | if( is_array($HTTP_COOKIE_VARS) ) |
| 79 | 824 | psotfx | {
|
| 80 | 1054 | psotfx | while( list($k, $v) = each($HTTP_COOKIE_VARS) ) |
| 81 | 843 | psotfx | {
|
| 82 | 1054 | psotfx | if( is_array($HTTP_COOKIE_VARS[$k]) ) |
| 83 | 843 | psotfx | {
|
| 84 | 1054 | psotfx | while( list($k2, $v2) = each($HTTP_COOKIE_VARS[$k]) ) |
| 85 | 1054 | psotfx | {
|
| 86 | 1054 | psotfx | $HTTP_COOKIE_VARS[$k][$k2] = addslashes($v2); |
| 87 | 1054 | psotfx | } |
| 88 | 1054 | psotfx | @reset($HTTP_COOKIE_VARS[$k]); |
| 89 | 843 | psotfx | } |
| 90 | 1054 | psotfx | else
|
| 91 | 1054 | psotfx | {
|
| 92 | 1054 | psotfx | $HTTP_COOKIE_VARS[$k] = addslashes($v); |
| 93 | 1054 | psotfx | } |
| 94 | 843 | psotfx | } |
| 95 | 1054 | psotfx | @reset($HTTP_COOKIE_VARS); |
| 96 | 824 | psotfx | } |
| 97 | 824 | psotfx | } |
| 98 | 824 | psotfx | |
| 99 | 824 | psotfx | //
|
| 100 | 646 | psotfx | // Define some basic configuration arrays this also prevents
|
| 101 | 661 | psotfx | // malicious rewriting of language and otherarray values via
|
| 102 | 661 | psotfx | // URI params
|
| 103 | 237 | psotfx | //
|
| 104 | 2575 | psotfx | $board_config = array(); |
| 105 | 2575 | psotfx | $userdata = array(); |
| 106 | 2575 | psotfx | $theme = array(); |
| 107 | 2575 | psotfx | $images = array(); |
| 108 | 2575 | psotfx | $lang = array(); |
| 109 | 1220 | psotfx | $gen_simple_header = FALSE; |
| 110 | 237 | psotfx | |
| 111 | 2575 | psotfx | include($phpbb_root_path . 'config.'.$phpEx); |
| 112 | 1144 | psotfx | |
| 113 | 1144 | psotfx | if( !defined("PHPBB_INSTALLED") ) |
| 114 | 1144 | psotfx | {
|
| 115 | 1144 | psotfx | header("Location: install.$phpEx"); |
| 116 | 2575 | psotfx | exit;
|
| 117 | 1144 | psotfx | } |
| 118 | 1144 | psotfx | |
| 119 | 646 | psotfx | include($phpbb_root_path . 'includes/constants.'.$phpEx); |
| 120 | 741 | psotfx | include($phpbb_root_path . 'includes/template.'.$phpEx); |
| 121 | 646 | psotfx | include($phpbb_root_path . 'includes/sessions.'.$phpEx); |
| 122 | 646 | psotfx | include($phpbb_root_path . 'includes/auth.'.$phpEx); |
| 123 | 646 | psotfx | include($phpbb_root_path . 'includes/functions.'.$phpEx); |
| 124 | 646 | psotfx | include($phpbb_root_path . 'includes/db.'.$phpEx); |
| 125 | 38 | psotfx | |
| 126 | 646 | psotfx | //
|
| 127 | 1452 | bartvb | // Mozilla navigation bar
|
| 128 | 1452 | bartvb | // Default items that should be valid on all pages.
|
| 129 | 1452 | bartvb | // Defined here and not in page_header.php so they can be redefined in the code
|
| 130 | 1452 | bartvb | //
|
| 131 | 1452 | bartvb | $nav_links['top'] = array ( |
| 132 | 1452 | bartvb | 'url' => append_sid($phpbb_root_dir."index.".$phpEx), |
| 133 | 1452 | bartvb | 'title' => sprintf($lang['Forum_Index'], $board_config['sitename']) |
| 134 | 1452 | bartvb | ); |
| 135 | 1452 | bartvb | $nav_links['search'] = array ( |
| 136 | 1452 | bartvb | 'url' => append_sid($phpbb_root_dir."search.".$phpEx), |
| 137 | 1452 | bartvb | 'title' => $lang['Search'] |
| 138 | 1452 | bartvb | ); |
| 139 | 1452 | bartvb | $nav_links['help'] = array ( |
| 140 | 1452 | bartvb | 'url' => append_sid($phpbb_root_dir."faq.".$phpEx), |
| 141 | 1452 | bartvb | 'title' => $lang['FAQ'] |
| 142 | 1452 | bartvb | ); |
| 143 | 1452 | bartvb | $nav_links['author'] = array ( |
| 144 | 1452 | bartvb | 'url' => append_sid($phpbb_root_dir."memberlist.".$phpEx), |
| 145 | 1452 | bartvb | 'title' => $lang['Memberlist'] |
| 146 | 1452 | bartvb | ); |
| 147 | 1452 | bartvb | |
| 148 | 1452 | bartvb | //
|
| 149 | 346 | psotfx | // Obtain and encode users IP
|
| 150 | 585 | psotfx | //
|
| 151 | 2314 | psotfx | if( getenv('HTTP_X_FORWARDED_FOR') != '' ) |
| 152 | 585 | psotfx | {
|
| 153 | 2327 | psotfx | $client_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR ); |
| 154 | 2314 | psotfx | |
| 155 | 2327 | psotfx | if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", getenv('HTTP_X_FORWARDED_FOR'), $ip_list) ) |
| 156 | 2314 | psotfx | {
|
| 157 | 2571 | psotfx | $private_ip = array('/^0\./', '/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.16\..*/', '/^10..*/', '/^224..*/', '/^240..*/'); |
| 158 | 2327 | psotfx | $client_ip = preg_replace($private_ip, $client_ip, $ip_list[1]); |
| 159 | 2314 | psotfx | } |
| 160 | 585 | psotfx | } |
| 161 | 585 | psotfx | else
|
| 162 | 585 | psotfx | {
|
| 163 | 2327 | psotfx | $client_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR ); |
| 164 | 585 | psotfx | } |
| 165 | 585 | psotfx | $user_ip = encode_ip($client_ip); |
| 166 | 346 | psotfx | |
| 167 | 237 | psotfx | //
|
| 168 | 2182 | bartvb | // Setup forum wide options, if this fails
|
| 169 | 2182 | bartvb | // then we output a CRITICAL_ERROR since
|
| 170 | 2182 | bartvb | // basic forum information is not available
|
| 171 | 2182 | bartvb | //
|
| 172 | 2182 | bartvb | $sql = "SELECT * |
| 173 | 2182 | bartvb | FROM " . CONFIG_TABLE; |
| 174 | 2564 | psotfx | if( !($result = $db->sql_query($sql)) ) |
| 175 | 2182 | bartvb | {
|
| 176 | 2182 | bartvb | message_die(CRITICAL_ERROR, "Could not query config information", "", __LINE__, __FILE__, $sql); |
| 177 | 2182 | bartvb | } |
| 178 | 2564 | psotfx | |
| 179 | 2564 | psotfx | while ( $row = $db->sql_fetchrow($result) ) |
| 180 | 2182 | bartvb | {
|
| 181 | 2564 | psotfx | $board_config[$row['config_name']] = $row['config_value']; |
| 182 | 2182 | bartvb | } |
| 183 | 2182 | bartvb | |
| 184 | 2182 | bartvb | //
|
| 185 | 2182 | bartvb | // Show 'Board is disabled' message if needed.
|
| 186 | 237 | psotfx | //
|
| 187 | 1511 | psotfx | if( $board_config['board_disable'] && !defined("IN_ADMIN") && !defined("IN_LOGIN") ) |
| 188 | 539 | psotfx | {
|
| 189 | 1083 | psotfx | message_die(GENERAL_MESSAGE, 'Board_disable', 'Information'); |
| 190 | 539 | psotfx | } |
| 191 | 539 | psotfx | |
| 192 | 2183 | psotfx | ?> |

