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.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2002-03-18 23:45:24 +00:00
|
|
|
if ( !defined('IN_PHPBB') )
|
|
|
|
{
|
2002-07-14 14:45:26 +00:00
|
|
|
die('Hacking attempt');
|
2002-03-18 23:45:24 +00:00
|
|
|
}
|
|
|
|
|
2002-10-17 02:50:50 +00:00
|
|
|
error_reporting(E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables
|
|
|
|
//error_reporting(E_ALL);
|
2002-10-04 13:09:10 +00:00
|
|
|
set_magic_quotes_runtime(0);
|
2001-08-09 22:21:55 +00:00
|
|
|
|
2002-10-20 19:19:07 +00:00
|
|
|
// If magic quotes is off, addslashes
|
|
|
|
if ( !get_magic_quotes_gpc() )
|
|
|
|
{
|
|
|
|
$_GET = slash_input_data($_GET);
|
|
|
|
$_POST = slash_input_data($_POST);
|
|
|
|
$_COOKIE = slash_input_data($_COOKIE);
|
|
|
|
}
|
|
|
|
|
2002-07-14 14:45:26 +00:00
|
|
|
require($phpbb_root_path . 'config.'.$phpEx);
|
2002-10-26 12:36:38 +00:00
|
|
|
require($phpbb_root_path . 'config_cache.'.$phpEx);
|
2001-08-09 22:21:55 +00:00
|
|
|
|
2002-07-14 14:45:26 +00:00
|
|
|
if ( !defined('PHPBB_INSTALLED') )
|
2002-04-20 00:22:29 +00:00
|
|
|
{
|
2002-07-14 14:45:26 +00:00
|
|
|
header('Location: install/install.'.$phpEx);
|
|
|
|
exit;
|
2001-08-09 22:21:55 +00:00
|
|
|
}
|
|
|
|
|
2002-10-26 12:36:38 +00:00
|
|
|
// Include files
|
|
|
|
require($phpbb_root_path . 'includes/template.'.$phpEx);
|
|
|
|
require($phpbb_root_path . 'includes/session.'.$phpEx);
|
|
|
|
require($phpbb_root_path . 'includes/functions.'.$phpEx);
|
|
|
|
require($phpbb_root_path . 'db/' . $dbms . '.'.$phpEx);
|
2002-04-20 00:22:29 +00:00
|
|
|
|
|
|
|
// User related
|
2002-10-20 19:19:07 +00:00
|
|
|
define('ANONYMOUS', 0);
|
|
|
|
|
2002-04-20 00:22:29 +00:00
|
|
|
define('USER_ACTIVATION_NONE', 0);
|
|
|
|
define('USER_ACTIVATION_SELF', 1);
|
|
|
|
define('USER_ACTIVATION_ADMIN', 2);
|
2002-07-28 19:41:21 +00:00
|
|
|
define('USER_ACTIVATION_DISABLE', 3);
|
2002-04-20 00:22:29 +00:00
|
|
|
|
|
|
|
define('USER_AVATAR_NONE', 0);
|
|
|
|
define('USER_AVATAR_UPLOAD', 1);
|
|
|
|
define('USER_AVATAR_REMOTE', 2);
|
|
|
|
define('USER_AVATAR_GALLERY', 3);
|
|
|
|
|
2002-08-13 16:34:17 +00:00
|
|
|
// ACL
|
2002-10-20 19:19:07 +00:00
|
|
|
define('ACL_DENY', 0);
|
|
|
|
define('ACL_ALLOW', 1);
|
|
|
|
define('ACL_INHERIT', 2);
|
2002-08-13 16:34:17 +00:00
|
|
|
|
2002-04-20 00:22:29 +00:00
|
|
|
// Group settings
|
|
|
|
define('GROUP_OPEN', 0);
|
|
|
|
define('GROUP_CLOSED', 1);
|
|
|
|
define('GROUP_HIDDEN', 2);
|
2002-11-09 00:45:34 +00:00
|
|
|
define('GROUP_SPECIAL', 3);
|
2002-04-20 00:22:29 +00:00
|
|
|
|
2002-08-13 16:34:17 +00:00
|
|
|
// Forum/Topic states
|
|
|
|
define('ITEM_UNLOCKED', 0);
|
|
|
|
define('ITEM_LOCKED', 1);
|
|
|
|
define('ITEM_MOVED', 2);
|
2002-09-15 17:21:08 +00:00
|
|
|
define('ITEM_CATEGORY', 3);
|
2002-04-20 00:22:29 +00:00
|
|
|
|
|
|
|
// Topic types
|
|
|
|
define('POST_NORMAL', 0);
|
|
|
|
define('POST_STICKY', 1);
|
|
|
|
define('POST_ANNOUNCE', 2);
|
|
|
|
|
|
|
|
// Error codes
|
2002-07-14 14:45:26 +00:00
|
|
|
define('MESSAGE', 200);
|
|
|
|
define('ERROR', 201);
|
2002-04-20 00:22:29 +00:00
|
|
|
|
|
|
|
// Private messaging
|
|
|
|
define('PRIVMSGS_READ_MAIL', 0);
|
|
|
|
define('PRIVMSGS_NEW_MAIL', 1);
|
|
|
|
define('PRIVMSGS_UNREAD_MAIL', 5);
|
|
|
|
|
|
|
|
// Table names
|
2002-07-14 14:45:26 +00:00
|
|
|
define('ACL_GROUPS_TABLE', $table_prefix.'auth_groups');
|
|
|
|
define('ACL_OPTIONS_TABLE', $table_prefix.'auth_options');
|
|
|
|
define('ACL_PREFETCH_TABLE', $table_prefix.'auth_prefetch');
|
|
|
|
define('ACL_USERS_TABLE', $table_prefix.'auth_users');
|
2002-04-20 00:22:29 +00:00
|
|
|
define('BANLIST_TABLE', $table_prefix.'banlist');
|
2002-08-13 16:34:17 +00:00
|
|
|
define('CATEGORIES_TABLE', $table_prefix.'categories'); //
|
2002-04-20 00:22:29 +00:00
|
|
|
define('CONFIG_TABLE', $table_prefix.'config');
|
2002-07-28 19:41:21 +00:00
|
|
|
define('CONFIG_USER_TABLE', $table_prefix.'config_defaults');
|
2002-07-14 14:45:26 +00:00
|
|
|
define('DISALLOW_TABLE', $table_prefix.'disallow'); //
|
2002-04-20 00:22:29 +00:00
|
|
|
define('FORUMS_TABLE', $table_prefix.'forums');
|
2002-04-20 22:56:09 +00:00
|
|
|
define('FORUMS_WATCH_TABLE', $table_prefix.'forums_watch');
|
2002-04-20 00:22:29 +00:00
|
|
|
define('GROUPS_TABLE', $table_prefix.'groups');
|
2002-07-14 14:45:26 +00:00
|
|
|
define('ICONS_TABLE', $table_prefix.'icons');
|
|
|
|
define('LOG_ADMIN_TABLE', $table_prefix.'log_admin');
|
2002-08-03 23:52:33 +00:00
|
|
|
define('LOG_MOD_TABLE', $table_prefix.'log_moderator');
|
2002-04-20 00:22:29 +00:00
|
|
|
define('POSTS_TABLE', $table_prefix.'posts');
|
|
|
|
define('POSTS_TEXT_TABLE', $table_prefix.'posts_text');
|
|
|
|
define('PRIVMSGS_TABLE', $table_prefix.'privmsgs');
|
|
|
|
define('PRIVMSGS_TEXT_TABLE', $table_prefix.'privmsgs_text');
|
|
|
|
define('RANKS_TABLE', $table_prefix.'ranks');
|
|
|
|
define('SEARCH_TABLE', $table_prefix.'search_results');
|
|
|
|
define('SEARCH_WORD_TABLE', $table_prefix.'search_wordlist');
|
|
|
|
define('SEARCH_MATCH_TABLE', $table_prefix.'search_wordmatch');
|
|
|
|
define('SESSIONS_TABLE', $table_prefix.'sessions');
|
|
|
|
define('SMILIES_TABLE', $table_prefix.'smilies');
|
2002-07-14 14:45:26 +00:00
|
|
|
define('STYLES_TABLE', $table_prefix.'styles');
|
|
|
|
define('STYLES_TPL_TABLE', $table_prefix.'styles_template');
|
|
|
|
define('STYLES_CSS_TABLE', $table_prefix.'styles_theme');
|
|
|
|
define('STYLES_IMAGE_TABLE', $table_prefix.'styles_imageset');
|
2002-04-20 00:22:29 +00:00
|
|
|
define('TOPICS_TABLE', $table_prefix.'topics');
|
2002-11-08 03:33:58 +00:00
|
|
|
define('TOPICS_PREFETCH_TABLE', $table_prefix.'topics_prefetch');
|
2002-07-14 14:45:26 +00:00
|
|
|
define('TOPICS_RATINGS_TABLE', $table_prefix.'topics_rating');
|
2002-04-20 00:22:29 +00:00
|
|
|
define('TOPICS_WATCH_TABLE', $table_prefix.'topics_watch');
|
|
|
|
define('USER_GROUP_TABLE', $table_prefix.'user_group');
|
|
|
|
define('USERS_TABLE', $table_prefix.'users');
|
|
|
|
define('WORDS_TABLE', $table_prefix.'words');
|
2002-10-30 00:57:27 +00:00
|
|
|
define('POLL_OPTIONS_TABLE', $table_prefix.'poll_results');
|
|
|
|
define('POLL_VOTES_TABLE', $table_prefix.'poll_voters');
|
|
|
|
|
2002-04-20 00:22:29 +00:00
|
|
|
define('VOTE_DESC_TABLE', $table_prefix.'vote_desc');
|
|
|
|
define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results');
|
|
|
|
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');
|
|
|
|
|
2002-10-26 12:36:38 +00:00
|
|
|
// Set PHP error handler to ours
|
|
|
|
set_error_handler('msg_handler');
|
2002-07-14 14:45:26 +00:00
|
|
|
|
2002-10-26 12:36:38 +00:00
|
|
|
// Need these here so instantiate them now
|
2002-08-22 21:40:51 +00:00
|
|
|
$template = new Template();
|
2002-07-14 14:45:26 +00:00
|
|
|
$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
|
2001-11-26 12:09:37 +00:00
|
|
|
|
2002-10-26 12:36:38 +00:00
|
|
|
// Obtain boardwide default config (rebuilding cache if reqd)
|
2002-10-30 00:57:27 +00:00
|
|
|
if ( empty($config) )
|
2002-10-26 12:36:38 +00:00
|
|
|
{
|
|
|
|
require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
|
2002-10-30 00:57:27 +00:00
|
|
|
$config = config_config();
|
2002-10-26 12:36:38 +00:00
|
|
|
}
|
|
|
|
|
2002-02-18 08:57:28 +00:00
|
|
|
$sql = "SELECT *
|
2002-10-26 12:36:38 +00:00
|
|
|
FROM " . CONFIG_TABLE . "
|
|
|
|
WHERE is_dynamic = 1";
|
2002-10-04 13:09:10 +00:00
|
|
|
$result = $db->sql_query($sql, false);
|
2002-04-20 00:22:29 +00:00
|
|
|
|
2002-07-14 14:45:26 +00:00
|
|
|
while ( $row = $db->sql_fetchrow($result) )
|
2002-02-18 08:57:28 +00:00
|
|
|
{
|
2002-10-30 00:57:27 +00:00
|
|
|
$config[$row['config_name']] = $row['config_value'];
|
2002-02-18 08:57:28 +00:00
|
|
|
}
|
|
|
|
|
2002-10-26 12:36:38 +00:00
|
|
|
// Re-cache acl options if reqd
|
|
|
|
if ( empty($acl_options) )
|
|
|
|
{
|
|
|
|
require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
|
|
|
|
$auth_admin = new auth_admin();
|
|
|
|
$acl_options = $auth_admin->acl_cache_options();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Instantiate some basic classes
|
|
|
|
$user = new user();
|
|
|
|
$auth = new auth();
|
|
|
|
|
2002-10-04 13:09:10 +00:00
|
|
|
// Show 'Board is disabled' message
|
2002-10-30 00:57:27 +00:00
|
|
|
if ( $config['board_disable'] && !defined('IN_ADMIN') && !defined('IN_LOGIN') )
|
2001-07-03 00:32:27 +00:00
|
|
|
{
|
2002-10-30 00:57:27 +00:00
|
|
|
$message = ( !empty($config['board_disable_msg']) ) ? $config['board_disable_msg'] : 'Board_disable';
|
2002-10-26 12:36:38 +00:00
|
|
|
trigger_error($message);
|
2002-07-14 14:45:26 +00:00
|
|
|
}
|
|
|
|
|
2002-10-04 13:09:10 +00:00
|
|
|
// addslashes to vars if magic_quotes_gpc is off
|
2002-07-14 14:45:26 +00:00
|
|
|
function slash_input_data(&$data)
|
|
|
|
{
|
|
|
|
if ( is_array($data) )
|
|
|
|
{
|
2002-08-15 15:45:22 +00:00
|
|
|
foreach ( $data as $k => $v )
|
2002-07-14 14:45:26 +00:00
|
|
|
{
|
|
|
|
$data[$k] = ( is_array($v) ) ? slash_input_data($v) : addslashes($v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $data;
|
2001-07-03 00:32:27 +00:00
|
|
|
}
|
2001-06-30 21:04:37 +00:00
|
|
|
|
2002-02-18 12:34:38 +00:00
|
|
|
?>
|