2001-02-24 00:31:58 +00:00
|
|
|
<?php
|
2001-04-20 07:30:45 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* common.php
|
|
|
|
* -------------------
|
|
|
|
* begin : Saturday, Feb 23, 2001
|
|
|
|
* copyright : (C) 2001 The phpBB Group
|
|
|
|
* email : support@phpbb.com
|
|
|
|
*
|
2001-02-24 00:31:58 +00:00
|
|
|
* $Id$
|
2001-04-20 07:30:45 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
2001-02-24 00:31:58 +00:00
|
|
|
|
2001-08-30 22:20:23 +00:00
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2001-08-09 22:21:55 +00:00
|
|
|
error_reporting (E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables
|
|
|
|
set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
|
|
|
|
|
|
|
|
//
|
|
|
|
// addslashes to vars if magic_quotes_gpc is off
|
|
|
|
// this is a security precaution to prevent someone
|
|
|
|
// trying to break out of a SQL statement.
|
|
|
|
//
|
|
|
|
if( !get_magic_quotes_gpc() )
|
|
|
|
{
|
2001-08-13 01:07:14 +00:00
|
|
|
while( list($k, $v) = each($HTTP_GET_VARS) )
|
2001-08-09 22:21:55 +00:00
|
|
|
{
|
2001-08-12 23:22:54 +00:00
|
|
|
if( is_array($HTTP_GET_VARS[$k]) )
|
|
|
|
{
|
|
|
|
while( list($k2, $v2) = each($HTTP_GET_VARS[$k]) )
|
|
|
|
{
|
2001-08-13 01:07:14 +00:00
|
|
|
$HTTP_GET_VARS[$k][$k2] = addslashes($v2);
|
2001-08-12 23:22:54 +00:00
|
|
|
}
|
|
|
|
@reset($HTTP_GET_VARS[$k]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-13 01:07:14 +00:00
|
|
|
$HTTP_GET_VARS[$k] = addslashes($v);
|
2001-08-12 23:22:54 +00:00
|
|
|
}
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
2001-08-13 01:07:14 +00:00
|
|
|
@reset($HTTP_GET_VARS);
|
2001-08-09 22:21:55 +00:00
|
|
|
|
2001-08-13 01:07:14 +00:00
|
|
|
while( list($k, $v) = each($HTTP_POST_VARS) )
|
2001-08-09 22:21:55 +00:00
|
|
|
{
|
2001-08-12 23:22:54 +00:00
|
|
|
if( is_array($HTTP_POST_VARS[$k]) )
|
|
|
|
{
|
|
|
|
while( list($k2, $v2) = each($HTTP_POST_VARS[$k]) )
|
|
|
|
{
|
2001-08-13 01:07:14 +00:00
|
|
|
$HTTP_POST_VARS[$k][$k2] = addslashes($v2);
|
2001-08-12 23:22:54 +00:00
|
|
|
}
|
|
|
|
@reset($HTTP_POST_VARS[$k]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-13 01:07:14 +00:00
|
|
|
$HTTP_POST_VARS[$k] = addslashes($v);
|
2001-08-12 23:22:54 +00:00
|
|
|
}
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
2001-08-13 01:07:14 +00:00
|
|
|
@reset($HTTP_POST_VARS);
|
2001-08-09 22:21:55 +00:00
|
|
|
|
2001-08-13 01:07:14 +00:00
|
|
|
while( list($k, $v) = each($HTTP_COOKIE_VARS) )
|
2001-08-09 22:21:55 +00:00
|
|
|
{
|
2001-08-12 23:22:54 +00:00
|
|
|
if( is_array($HTTP_COOKIE_VARS[$k]) )
|
|
|
|
{
|
|
|
|
while( list($k2, $v2) = each($HTTP_COOKIE_VARS[$k]) )
|
|
|
|
{
|
2001-08-13 01:07:14 +00:00
|
|
|
$HTTP_COOKIE_VARS[$k][$k2] = addslashes($v2);
|
2001-08-12 23:22:54 +00:00
|
|
|
}
|
|
|
|
@reset($HTTP_COOKIE_VARS[$k]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-13 01:07:14 +00:00
|
|
|
$HTTP_COOKIE_VARS[$k] = addslashes($v);
|
2001-08-12 23:22:54 +00:00
|
|
|
}
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
2001-08-13 01:07:14 +00:00
|
|
|
@reset($HTTP_COOKIE_VARS);
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
|
|
|
|
2001-04-19 13:30:47 +00:00
|
|
|
//
|
2001-07-13 16:14:37 +00:00
|
|
|
// Define some basic configuration arrays this also prevents
|
2001-07-14 17:30:21 +00:00
|
|
|
// malicious rewriting of language and otherarray values via
|
|
|
|
// URI params
|
2001-04-19 13:30:47 +00:00
|
|
|
//
|
2001-05-03 22:10:23 +00:00
|
|
|
$board_config = Array();
|
|
|
|
$userdata = Array();
|
|
|
|
$theme = Array();
|
|
|
|
$images = Array();
|
2001-05-27 16:40:25 +00:00
|
|
|
$lang = Array();
|
2001-04-19 13:30:47 +00:00
|
|
|
|
2001-07-13 16:14:37 +00:00
|
|
|
if(empty($phpbb_root_path))
|
|
|
|
{
|
|
|
|
$phpbb_root_path = "./";
|
|
|
|
}
|
|
|
|
include($phpbb_root_path . 'config.'.$phpEx);
|
|
|
|
include($phpbb_root_path . 'includes/constants.'.$phpEx);
|
2001-07-24 11:39:00 +00:00
|
|
|
include($phpbb_root_path . 'includes/template.'.$phpEx);
|
2001-07-13 16:14:37 +00:00
|
|
|
include($phpbb_root_path . 'includes/message.'.$phpEx);
|
|
|
|
include($phpbb_root_path . 'includes/sessions.'.$phpEx);
|
|
|
|
include($phpbb_root_path . 'includes/auth.'.$phpEx);
|
|
|
|
include($phpbb_root_path . 'includes/functions.'.$phpEx);
|
|
|
|
include($phpbb_root_path . 'includes/db.'.$phpEx);
|
2001-08-13 01:07:14 +00:00
|
|
|
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
|
2001-04-19 13:30:47 +00:00
|
|
|
|
2001-07-06 17:47:10 +00:00
|
|
|
//
|
2001-05-27 16:40:25 +00:00
|
|
|
// Obtain and encode users IP
|
2001-07-06 17:47:10 +00:00
|
|
|
//
|
|
|
|
if(!empty($HTTP_CLIENT_IP))
|
|
|
|
{
|
2001-08-13 01:07:14 +00:00
|
|
|
$client_ip = (ereg("[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+", $HTTP_CLIENT_IP)) ? $HTTP_CLIENT_IP : $REMOTE_ADDR;
|
2001-07-06 17:47:10 +00:00
|
|
|
}
|
2001-07-06 22:57:32 +00:00
|
|
|
else if(!empty($HTTP_X_FORWARDED_FOR))
|
2001-07-06 17:47:10 +00:00
|
|
|
{
|
2001-07-07 12:27:30 +00:00
|
|
|
$client_ip = (ereg("([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)", $HTTP_X_FORWARDED_FOR, $ip_list)) ? $ip_list[0] : $REMOTE_ADDR;
|
2001-07-06 17:47:10 +00:00
|
|
|
}
|
|
|
|
else if(!empty($HTTP_PROXY_USER))
|
|
|
|
{
|
2001-07-07 12:26:50 +00:00
|
|
|
$client_ip = (ereg("[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+", $HTTP_PROXY_USER)) ? $HTTP_PROXY_USER : $REMOTE_ADDR;
|
2001-07-06 17:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$client_ip = $REMOTE_ADDR;
|
|
|
|
}
|
|
|
|
$user_ip = encode_ip($client_ip);
|
|
|
|
|
2001-05-03 22:10:23 +00:00
|
|
|
//
|
2001-07-07 00:17:51 +00:00
|
|
|
// Setup forum wide options, if this fails
|
|
|
|
// then we output a CRITICAL_ERROR since
|
|
|
|
// basic forum information is not available
|
2001-05-03 22:10:23 +00:00
|
|
|
//
|
2001-03-21 23:25:03 +00:00
|
|
|
$sql = "SELECT *
|
2001-07-03 00:32:27 +00:00
|
|
|
FROM " . CONFIG_TABLE;
|
2001-02-24 00:31:58 +00:00
|
|
|
if(!$result = $db->sql_query($sql))
|
|
|
|
{
|
2001-07-03 22:50:56 +00:00
|
|
|
message_die(CRITICAL_ERROR, "Could not query config information", "", __LINE__, __FILE__, $sql);
|
2001-02-24 00:31:58 +00:00
|
|
|
}
|
2001-04-20 07:30:45 +00:00
|
|
|
else
|
2001-02-24 00:31:58 +00:00
|
|
|
{
|
2001-07-03 00:32:27 +00:00
|
|
|
/*
|
|
|
|
while($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
|
|
|
$board_config[$row['config_var_name']] = stripslashes($row['config_var_value']);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2001-03-21 23:25:03 +00:00
|
|
|
$config = $db->sql_fetchrow($result);
|
2001-06-30 21:04:37 +00:00
|
|
|
|
2001-07-03 00:32:27 +00:00
|
|
|
$board_config['board_disable'] = $config['board_disable'];
|
2001-07-23 18:59:03 +00:00
|
|
|
$board_config['board_startdate'] = $config['board_startdate'];
|
2001-05-03 22:10:23 +00:00
|
|
|
$board_config['sitename'] = stripslashes($config['sitename']);
|
|
|
|
$board_config['allow_html'] = $config['allow_html'];
|
2001-08-09 22:21:55 +00:00
|
|
|
$board_config['allow_html_tags'] = split(",", $config['allow_html_tags']);
|
2001-05-03 22:10:23 +00:00
|
|
|
$board_config['allow_bbcode'] = $config['allow_bbcode'];
|
2001-05-27 16:40:25 +00:00
|
|
|
$board_config['allow_smilies'] = $config['allow_smilies'];
|
2001-05-03 22:10:23 +00:00
|
|
|
$board_config['allow_sig'] = $config['allow_sig'];
|
|
|
|
$board_config['allow_namechange'] = $config['allow_namechange'];
|
2001-06-12 23:46:24 +00:00
|
|
|
$board_config['allow_avatar_local'] = $config['allow_avatar_local'];
|
2001-07-21 14:35:35 +00:00
|
|
|
$board_config['allow_avatar_remote'] = $config['allow_avatar_remote'];
|
2001-05-27 16:40:25 +00:00
|
|
|
$board_config['allow_avatar_upload'] = $config['allow_avatar_upload'];
|
2001-05-03 22:10:23 +00:00
|
|
|
$board_config['require_activation'] = $config['require_activation'];
|
|
|
|
$board_config['override_user_themes'] = $config['override_themes'];
|
|
|
|
$board_config['posts_per_page'] = $config['posts_per_page'];
|
|
|
|
$board_config['topics_per_page'] = $config['topics_per_page'];
|
2001-07-24 22:11:24 +00:00
|
|
|
$board_config['hot_threshold'] = $config['hot_threshold'];
|
2001-09-06 00:29:07 +00:00
|
|
|
$board_config['max_poll_options'] = $config['max_poll_options'];
|
2001-05-03 22:10:23 +00:00
|
|
|
$board_config['default_theme'] = $config['default_theme'];
|
|
|
|
$board_config['default_dateformat'] = stripslashes($config['default_dateformat']);
|
|
|
|
$board_config['default_template'] = stripslashes($config['sys_template']);
|
|
|
|
$board_config['default_timezone'] = $config['system_timezone'];
|
|
|
|
$board_config['default_lang'] = stripslashes($config['default_lang']);
|
|
|
|
$board_config['board_email'] = stripslashes(str_replace("<br />", "\n", $config['email_sig']));
|
|
|
|
$board_config['board_email_from'] = stripslashes($config['email_from']);
|
2001-05-27 03:11:27 +00:00
|
|
|
$board_config['flood_interval'] = $config['flood_interval'];
|
2001-07-23 15:23:47 +00:00
|
|
|
$board_config['session_length'] = $config['session_length'];
|
2001-07-24 11:39:00 +00:00
|
|
|
// $board_config['session_max'] = $config['session_max'];
|
2001-08-09 22:21:55 +00:00
|
|
|
$board_config['cookie_name'] = stripslashes($config['cookie_name']);
|
|
|
|
$board_config['cookie_path'] = stripslashes($config['cookie_path']);
|
|
|
|
$board_config['cookie_domain'] = stripslashes($config['cookie_domain']);
|
2001-07-23 15:23:47 +00:00
|
|
|
$board_config['cookie_secure'] = $config['cookie_secure'];
|
2001-05-27 16:40:25 +00:00
|
|
|
$board_config['avatar_filesize'] = $config['avatar_filesize'];
|
2001-06-12 23:46:24 +00:00
|
|
|
$board_config['avatar_max_width'] = $config['avatar_max_width'];
|
|
|
|
$board_config['avatar_max_height'] = $config['avatar_max_height'];
|
2001-08-09 22:21:55 +00:00
|
|
|
$board_config['avatar_path'] = stripslashes($config['avatar_path']);
|
|
|
|
$board_config['smilies_path'] = stripslashes($config['smilies_path']);
|
2001-06-19 17:38:00 +00:00
|
|
|
$board_config['prune_enable'] = $config['prune_enable'];
|
2001-06-30 21:04:37 +00:00
|
|
|
$board_config['gzip_compress'] = $config['gzip_compress'];
|
2001-07-04 19:36:32 +00:00
|
|
|
$board_config['smtp_delivery'] = $config['smtp_delivery'];
|
2001-08-09 22:21:55 +00:00
|
|
|
$board_config['smtp_host'] = stripslashes($config['smtp_host']);
|
2001-02-24 00:31:58 +00:00
|
|
|
}
|
2001-06-30 21:04:37 +00:00
|
|
|
|
2001-08-09 22:21:55 +00:00
|
|
|
if($board_config['board_disable'] && !defined("IN_ADMIN"))
|
2001-07-03 00:32:27 +00:00
|
|
|
{
|
2001-07-20 19:22:44 +00:00
|
|
|
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '.'.$phpEx);
|
|
|
|
|
2001-07-03 00:32:27 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $lang['Board_disable'], $lang['Information']);
|
|
|
|
}
|
2001-06-30 21:04:37 +00:00
|
|
|
|
2001-08-13 01:07:14 +00:00
|
|
|
//
|
|
|
|
// Setup the emailer
|
|
|
|
//
|
|
|
|
$emailer = new emailer($board_config['smtp_delivery']);
|
|
|
|
|
2001-07-03 00:32:27 +00:00
|
|
|
?>
|