mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-01 20:19:13 +02:00
Centralise common includes and setup
git-svn-id: file:///svn/phpbb/trunk@38 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
4e5538cb78
commit
ddc2cd6ead
108
phpBB/common.php
Normal file
108
phpBB/common.php
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<?php
|
||||||
|
/***************************************************************************
|
||||||
|
* common.php
|
||||||
|
* -------------------
|
||||||
|
* begin : Saturday, Feb 23, 2001
|
||||||
|
* copyright : (C) 2001 The phpBB Group
|
||||||
|
* email : support@phpbb.com
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
include('config.'.$phpEx);
|
||||||
|
|
||||||
|
// Find Users real IP (if possible)
|
||||||
|
$ip = ($HTTP_X_FORWARDED_FOR) ? $HTTP_X_FORWARDED_FOR : $REMOTE_ADDR;
|
||||||
|
define("USER_IP",$ip);
|
||||||
|
unset($ip);
|
||||||
|
|
||||||
|
include('template.inc');
|
||||||
|
// Setup what template to use. Currently just use default
|
||||||
|
$template = new Template("./templates/Default", "keep");
|
||||||
|
|
||||||
|
include('functions/error.'.$phpEx);
|
||||||
|
include('functions/sessions.'.$phpEx);
|
||||||
|
include('functions/auth.'.$phpEx);
|
||||||
|
include('functions/functions.'.$phpEx);
|
||||||
|
include('db.'.$phpEx);
|
||||||
|
|
||||||
|
// Check if user is banned
|
||||||
|
if(!auth("ip ban", $db, "", "", "", "", "", USER_IP, "", "", ""))
|
||||||
|
{
|
||||||
|
error_die($db, BANNED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initalize these variables to keep them safe.
|
||||||
|
$user_logged_in = 0;
|
||||||
|
$logged_in = 0;
|
||||||
|
$userdata = Array();
|
||||||
|
|
||||||
|
// Setup forum wide options.
|
||||||
|
$sql = "SELECT * FROM ".CONFIG_TABLE." WHERE selected = 1";
|
||||||
|
if(!$result = $db->sql_query($sql))
|
||||||
|
{
|
||||||
|
error_die($db, SQL_CONNECT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$config = $db->sql_fetchrowset($result);
|
||||||
|
$sitename = stripslashes($config[0]["sitename"]);
|
||||||
|
$allow_html = $config[0]["allow_html"];
|
||||||
|
$allow_bbcode = $config[0]["allow_bbcode"];
|
||||||
|
$allow_sig = $config[0]["allow_sig"];
|
||||||
|
$allow_namechange = $config[0]["allow_namechange"];
|
||||||
|
$posts_per_page = $config[0]["posts_per_page"];
|
||||||
|
$hot_threshold = $config[0]["hot_threshold"];
|
||||||
|
$topics_per_page = $config[0]["topics_per_page"];
|
||||||
|
$override_user_themes = $config[0]["override_themes"];
|
||||||
|
$email_sig = stripslashes($config[0]["email_sig"]);
|
||||||
|
$email_from = $config[0]["email_from"];
|
||||||
|
$default_lang = $config[0]["default_lang"];
|
||||||
|
$sys_lang = $default_lang;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($HTTP_COOKIE_VARS[$session_cookie]))
|
||||||
|
{
|
||||||
|
$sessid = $HTTP_COOKIE_VARS[$session_cookie];
|
||||||
|
$userid = get_userid_from_session($sessid, $session_cookie_time, USER_IP, $db);
|
||||||
|
|
||||||
|
if ($userid)
|
||||||
|
{
|
||||||
|
$user_logged_in = 1;
|
||||||
|
update_session_time($sessid, $db);
|
||||||
|
|
||||||
|
if(!auth("username ban", $db, $userid, "", "", "", "", "", "", "", ""))
|
||||||
|
{
|
||||||
|
error_die($db, BANNED);
|
||||||
|
}
|
||||||
|
$userdata = get_userdata_from_id($userid, $db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the user isn't logged in check if they have a user ID cookie.
|
||||||
|
if (!$user_logged_in)
|
||||||
|
{
|
||||||
|
if(isset($HTTP_COOKIE_VARS[$cookie_name]))
|
||||||
|
{
|
||||||
|
$userdata = get_userdata_from_id($HTTP_COOKIE_VARS["$cookie_name"], $db);
|
||||||
|
if(!auth("username ban", $db, $userdata["user_id"], "", "", "", "", "", "", "", ""))
|
||||||
|
{
|
||||||
|
error_die($db, BANNED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
71
phpBB/db.php
71
phpBB/db.php
@ -37,81 +37,10 @@ switch($dbms)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Setup what template to use. Currently just use default
|
|
||||||
$template = new Template("./templates/Default", "keep");
|
|
||||||
|
|
||||||
// Make the database connection.
|
// Make the database connection.
|
||||||
$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, false);
|
$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, false);
|
||||||
if(!$db)
|
if(!$db)
|
||||||
{
|
{
|
||||||
error_die($db, SQL_CONNECT);
|
error_die($db, SQL_CONNECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if user is banned
|
|
||||||
if(!auth("ip ban", $db, "", "", "", "", "", $REMOTE_ADDR, "", "", ""))
|
|
||||||
{
|
|
||||||
error_die($db, BANNED);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initalize these variables to keep them safe.
|
|
||||||
$user_logged_in = 0;
|
|
||||||
$logged_in = 0;
|
|
||||||
$userdata = Array();
|
|
||||||
|
|
||||||
// Setup forum wide options.
|
|
||||||
$sql = "SELECT * FROM ".CONFIG_TABLE." WHERE selected = 1";
|
|
||||||
if(!$result = $db->sql_query($sql))
|
|
||||||
{
|
|
||||||
error_die($db, SQL_CONNECT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$config = $db->sql_fetchrowset($result);
|
|
||||||
$sitename = stripslashes($config[0]["sitename"]);
|
|
||||||
$allow_html = $config[0]["allow_html"];
|
|
||||||
$allow_bbcode = $config[0]["allow_bbcode"];
|
|
||||||
$allow_sig = $config[0]["allow_sig"];
|
|
||||||
$allow_namechange = $config[0]["allow_namechange"];
|
|
||||||
$posts_per_page = $config[0]["posts_per_page"];
|
|
||||||
$hot_threshold = $config[0]["hot_threshold"];
|
|
||||||
$topics_per_page = $config[0]["topics_per_page"];
|
|
||||||
$override_user_themes = $config[0]["override_themes"];
|
|
||||||
$email_sig = stripslashes($config[0]["email_sig"]);
|
|
||||||
$email_from = $config[0]["email_from"];
|
|
||||||
$default_lang = $config[0]["default_lang"];
|
|
||||||
$sys_lang = $default_lang;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($HTTP_COOKIE_VARS[$session_cookie]))
|
|
||||||
{
|
|
||||||
$sessid = $HTTP_COOKIE_VARS[$session_cookie];
|
|
||||||
$userid = get_userid_from_session($sessid, $session_cookie_time, $REMOTE_ADDR, $db);
|
|
||||||
|
|
||||||
if ($userid)
|
|
||||||
{
|
|
||||||
$user_logged_in = 1;
|
|
||||||
update_session_time($sessid, $db);
|
|
||||||
|
|
||||||
if(!auth("username ban", $db, $userid, "", "", "", "", "", "", "", ""))
|
|
||||||
{
|
|
||||||
error_die($db, BANNED);
|
|
||||||
}
|
|
||||||
$userdata = get_userdata_from_id($userid, $db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the user isn't logged in check if they have a user ID cookie.
|
|
||||||
if (!$user_logged_in)
|
|
||||||
{
|
|
||||||
if(isset($HTTP_COOKIE_VARS[$cookie_name]))
|
|
||||||
{
|
|
||||||
$userdata = get_userdata_from_id($HTTP_COOKIE_VARS["$cookie_name"], $db);
|
|
||||||
if(!auth("username ban", $db, $userdata["user_id"], "", "", "", "", "", "", "", ""))
|
|
||||||
{
|
|
||||||
error_die($db, BANNED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -22,17 +22,11 @@
|
|||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
include('extension.inc');
|
include('extension.inc');
|
||||||
include('config.'.$phpEx);
|
include('common.'.$phpEx);
|
||||||
include('template.inc');
|
|
||||||
include('functions/sessions.'.$phpEx);
|
|
||||||
include('functions/auth.'.$phpEx);
|
|
||||||
include('functions/functions.'.$phpEx);
|
|
||||||
include('functions/error.'.$phpEx);
|
|
||||||
include('db.'.$phpEx);
|
|
||||||
|
|
||||||
$total_users = get_user_count($db, $users_table);
|
$total_users = get_user_count($db, "");
|
||||||
$total_posts = get_total_posts($db, $forums_table);
|
$total_posts = get_total_posts($db, "");
|
||||||
$newest_userdata = get_newest_user($db, $users_table);
|
$newest_userdata = get_newest_user($db, "");
|
||||||
$newest_user = $newest_userdata["username"];
|
$newest_user = $newest_userdata["username"];
|
||||||
$newest_uid = $newest_userdata["user_id"];
|
$newest_uid = $newest_userdata["user_id"];
|
||||||
$users_browsing = "4 Users";
|
$users_browsing = "4 Users";
|
||||||
@ -63,7 +57,7 @@ if($total_categories)
|
|||||||
|
|
||||||
$total_forums = $db->sql_numrows($q_forums);
|
$total_forums = $db->sql_numrows($q_forums);
|
||||||
$forum_rows = $db->sql_fetchrowset($q_forums);
|
$forum_rows = $db->sql_fetchrowset($q_forums);
|
||||||
|
|
||||||
for($i = 0; $i < $total_categories; $i++)
|
for($i = 0; $i < $total_categories; $i++)
|
||||||
{
|
{
|
||||||
$template->set_var(array("CAT_ID" => $category_rows[$i]["cat_id"],
|
$template->set_var(array("CAT_ID" => $category_rows[$i]["cat_id"],
|
||||||
@ -107,11 +101,13 @@ if($total_categories)
|
|||||||
"TOPICS" => $topics,
|
"TOPICS" => $topics,
|
||||||
"LAST_POST" => $last_post,
|
"LAST_POST" => $last_post,
|
||||||
"MODERATORS" => $moderators));
|
"MODERATORS" => $moderators));
|
||||||
|
|
||||||
$template->parse("forums", "forumrow", true);
|
$template->parse("forums", "forumrow", true);
|
||||||
} // if ... then
|
} // if ... then
|
||||||
} // for total forums
|
} // for total forums
|
||||||
$template->parse("cats", "forums", true);
|
$template->parse("cats", "forums", true);
|
||||||
$template->set_var("forums", "");
|
$template->set_var("forums", "");
|
||||||
|
|
||||||
} // for ... categories
|
} // for ... categories
|
||||||
|
|
||||||
}// if ... total_categories
|
}// if ... total_categories
|
||||||
|
@ -22,13 +22,7 @@
|
|||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
include('extension.inc');
|
include('extension.inc');
|
||||||
include('config.'.$phpEx);
|
include('common.'.$phpEx);
|
||||||
include('template.inc');
|
|
||||||
include('functions/sessions.'.$phpEx);
|
|
||||||
include('functions/auth.'.$phpEx);
|
|
||||||
include('functions/functions.'.$phpEx);
|
|
||||||
include('functions/error.'.$phpEx);
|
|
||||||
include('db.'.$phpEx);
|
|
||||||
|
|
||||||
// Check if the user has acutally sent a forum ID with his/her request
|
// Check if the user has acutally sent a forum ID with his/her request
|
||||||
// If not give them a nice error page.
|
// If not give them a nice error page.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user