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

