mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 16:56:44 +02:00
More changes ... switched away from prefetch for now ...
git-svn-id: file:///svn/phpbb/trunk@2849 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
@@ -1236,7 +1235,7 @@ function generate_smilies($mode, $page_id)
|
||||
$row = 0;
|
||||
$col = 0;
|
||||
|
||||
while ( list($smile_url, $data) = @each($rowset) )
|
||||
foreach( $rowset as $smile_url => $data )
|
||||
{
|
||||
if ( !$col )
|
||||
{
|
||||
@@ -1291,4 +1290,86 @@ function generate_smilies($mode, $page_id)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
define('BBCODE_UID_LEN', 10);
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
class parse_message
|
||||
{
|
||||
var $message;
|
||||
var $bbcode_tpl = null;
|
||||
|
||||
function parse_message($message, $html, $bbcode, $emoticons)
|
||||
{
|
||||
global $board_config;
|
||||
|
||||
$this->message = $message;
|
||||
unset($message);
|
||||
|
||||
$this->html($html);
|
||||
$this->bbcode($bbcode);
|
||||
$this->emoticons($emoticons);
|
||||
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
function html($html)
|
||||
{
|
||||
global $board_config;
|
||||
|
||||
}
|
||||
|
||||
function bbcode($bbcode)
|
||||
{
|
||||
global $board_config;
|
||||
|
||||
}
|
||||
|
||||
function emoticons($emoticons)
|
||||
{
|
||||
global $board_config;
|
||||
|
||||
}
|
||||
|
||||
function attachments()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class parse_poll
|
||||
{
|
||||
|
||||
function parse_poll()
|
||||
{
|
||||
global $board_config;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class parse_search
|
||||
{
|
||||
|
||||
function parse_search()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@@ -29,31 +29,11 @@ define('HEADER_INC', TRUE);
|
||||
//
|
||||
// gzip_compression
|
||||
//
|
||||
$do_gzip_compress = FALSE;
|
||||
if ( $board_config['gzip_compress'] )
|
||||
{
|
||||
$phpver = phpversion();
|
||||
|
||||
if ( $phpver >= '4.0.4pl1' && strstr($HTTP_USER_AGENT,'compatible') )
|
||||
if ( extension_loaded('zlib') && strstr($HTTP_USER_AGENT,'compatible') && !headers_sent() )
|
||||
{
|
||||
if ( extension_loaded('zlib') )
|
||||
{
|
||||
ob_start('ob_gzhandler');
|
||||
}
|
||||
}
|
||||
else if ( $phpver > '4.0' )
|
||||
{
|
||||
if ( strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip') )
|
||||
{
|
||||
if ( extension_loaded('zlib') )
|
||||
{
|
||||
$do_gzip_compress = TRUE;
|
||||
ob_start();
|
||||
ob_implicit_flush(0);
|
||||
|
||||
header("Content-Encoding: gzip");
|
||||
}
|
||||
}
|
||||
ob_start('ob_gzhandler');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +62,7 @@ $sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_colour, s.
|
||||
FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE ." s
|
||||
WHERE u.user_id = s.session_user_id
|
||||
AND s.session_time >= ".( time() - 300 ) . "
|
||||
$user_forum_sql
|
||||
$user_forum_sql
|
||||
ORDER BY u.username ASC, s.session_ip ASC";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
@@ -120,7 +100,7 @@ while( $row = $db->sql_fetchrow($result) )
|
||||
$user_online_link = '<a href="' . "profile.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'] . '"><i>' . $row['username'] . '</i></a>';
|
||||
$logged_hidden_online++;
|
||||
}
|
||||
|
||||
|
||||
if ( $row['user_allow_viewonline'] || $acl->get_admin_acl() )
|
||||
{
|
||||
$online_userlist .= ( $online_userlist != '' ) ? ', ' . $user_online_link : $user_online_link;
|
||||
@@ -145,7 +125,16 @@ if ( empty($online_userlist) )
|
||||
{
|
||||
$online_userlist = $lang['None'];
|
||||
}
|
||||
$online_userlist = ( ( isset($forum_id) ) ? $lang['Browsing_forum'] : $lang['Registered_users'] ) . ' ' . $online_userlist;
|
||||
|
||||
if ( empty($forum_id) )
|
||||
{
|
||||
$online_userlist = $lang['Registered_users'] . ' ' . $online_userlist;
|
||||
}
|
||||
else
|
||||
{
|
||||
$l_online = ( $guests_online == 1 ) ? $lang['Browsing_forum_guest'] : $lang['Browsing_forum_guests'];
|
||||
$online_userlist = sprintf($l_online, $online_userlist, $guests_online);
|
||||
}
|
||||
|
||||
$total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online;
|
||||
|
||||
@@ -218,9 +207,9 @@ else
|
||||
}
|
||||
|
||||
$l_online_users = sprintf($l_t_user_s, $total_online_users);
|
||||
$l_online_users .= sprintf($l_r_user_s, $logged_visible_online);
|
||||
$l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);
|
||||
$l_online_users .= sprintf($l_g_user_s, $guests_online);
|
||||
$l_online_users .= sprintf($l_r_user_s, $logged_visible_online);
|
||||
$l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);
|
||||
$l_online_users .= sprintf($l_g_user_s, $guests_online);
|
||||
|
||||
//
|
||||
// Obtain number of new private messages
|
||||
@@ -230,13 +219,13 @@ if ( $userdata['user_id'] != ANONYMOUS )
|
||||
{
|
||||
if ( $userdata['user_new_privmsg'] )
|
||||
{
|
||||
$l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms'];
|
||||
$l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']);
|
||||
$l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms'];
|
||||
$l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']);
|
||||
|
||||
if ( $userdata['user_last_privmsg'] > $userdata['user_lastvisit'] )
|
||||
{
|
||||
$sql = "UPDATE " . USERS_TABLE . "
|
||||
SET user_last_privmsg = " . $userdata['user_lastvisit'] . "
|
||||
SET user_last_privmsg = " . $userdata['user_lastvisit'] . "
|
||||
WHERE user_id = " . $userdata['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
@@ -259,8 +248,8 @@ if ( $userdata['user_id'] != ANONYMOUS )
|
||||
|
||||
if ( $userdata['user_unread_privmsg'] )
|
||||
{
|
||||
$l_message_unread = ( $userdata['user_unread_privmsg'] == 1 ) ? $lang['Unread_pm'] : $lang['Unread_pms'];
|
||||
$l_privmsgs_text_unread = sprintf($l_message_unread, $userdata['user_unread_privmsg']);
|
||||
$l_message_unread = ( $userdata['user_unread_privmsg'] == 1 ) ? $lang['Unread_pm'] : $lang['Unread_pms'];
|
||||
$l_privmsgs_text_unread = sprintf($l_message_unread, $userdata['user_unread_privmsg']);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -291,49 +280,49 @@ foreach ( $nav_links as $nav_item => $nav_array )
|
||||
{
|
||||
// We have a nested array, used for items like <link rel='chapter'> that can occur more than once.
|
||||
foreach ( $nav_array as $key => $nested_array )
|
||||
{
|
||||
{
|
||||
$nav_links_html .= sprintf($nav_link_proto, $nav_item, $nested_array['url'], $nested_array['title']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
//
|
||||
// The following assigns all _common_ variables that may be used at any point
|
||||
// in a template.
|
||||
//
|
||||
$template->assign_vars(array(
|
||||
'SITENAME' => $board_config['sitename'],
|
||||
'SITE_DESCRIPTION' => $board_config['site_desc'],
|
||||
'SITENAME' => $board_config['sitename'],
|
||||
'SITE_DESCRIPTION' => $board_config['site_desc'],
|
||||
'PAGE_TITLE' => $page_title,
|
||||
'LAST_VISIT_DATE' => sprintf($lang['You_last_visit'], $s_last_visit),
|
||||
'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])),
|
||||
'LAST_VISIT_DATE' => sprintf($lang['You_last_visit'], $s_last_visit),
|
||||
'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])),
|
||||
'TOTAL_USERS_ONLINE' => $l_online_users,
|
||||
'LOGGED_IN_USER_LIST' => $online_userlist,
|
||||
'LOGGED_IN_USER_LIST' => $online_userlist,
|
||||
'RECORD_USERS' => sprintf($lang['Record_online_users'], $board_config['record_online_users'], create_date($board_config['default_dateformat'], $board_config['record_online_date'], $board_config['board_timezone'])),
|
||||
'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text,
|
||||
'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread,
|
||||
'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new,
|
||||
'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new,
|
||||
|
||||
'PRIVMSG_IMG' => $icon_pm,
|
||||
|
||||
'L_USERNAME' => $lang['Username'],
|
||||
'L_PASSWORD' => $lang['Password'],
|
||||
'L_LOGIN_LOGOUT' => $l_login_logout,
|
||||
'L_LOGIN' => $lang['Login'],
|
||||
'L_LOG_ME_IN' => $lang['Log_me_in'],
|
||||
'L_AUTO_LOGIN' => $lang['Log_me_in'],
|
||||
'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']),
|
||||
'L_REGISTER' => $lang['Register'],
|
||||
'L_PROFILE' => $lang['Profile'],
|
||||
'L_SEARCH' => $lang['Search'],
|
||||
'L_PRIVATEMSGS' => $lang['Private_Messages'],
|
||||
'L_WHO_IS_ONLINE' => $lang['Who_is_Online'],
|
||||
'L_MEMBERLIST' => $lang['Memberlist'],
|
||||
'L_FAQ' => $lang['FAQ'],
|
||||
'L_USERGROUPS' => $lang['Usergroups'],
|
||||
'L_SEARCH_NEW' => $lang['Search_new'],
|
||||
'L_SEARCH_UNANSWERED' => $lang['Search_unanswered'],
|
||||
'L_SEARCH_SELF' => $lang['Search_your_posts'],
|
||||
'L_USERNAME' => $lang['Username'],
|
||||
'L_PASSWORD' => $lang['Password'],
|
||||
'L_LOGIN_LOGOUT' => $l_login_logout,
|
||||
'L_LOGIN' => $lang['Login'],
|
||||
'L_LOG_ME_IN' => $lang['Log_me_in'],
|
||||
'L_AUTO_LOGIN' => $lang['Log_me_in'],
|
||||
'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']),
|
||||
'L_REGISTER' => $lang['Register'],
|
||||
'L_PROFILE' => $lang['Profile'],
|
||||
'L_SEARCH' => $lang['Search'],
|
||||
'L_PRIVATEMSGS' => $lang['Private_Messages'],
|
||||
'L_WHO_IS_ONLINE' => $lang['Who_is_Online'],
|
||||
'L_MEMBERLIST' => $lang['Memberlist'],
|
||||
'L_FAQ' => $lang['FAQ'],
|
||||
'L_USERGROUPS' => $lang['Usergroups'],
|
||||
'L_SEARCH_NEW' => $lang['Search_new'],
|
||||
'L_SEARCH_UNANSWERED' => $lang['Search_unanswered'],
|
||||
'L_SEARCH_SELF' => $lang['Search_your_posts'],
|
||||
|
||||
'U_SEARCH_UNANSWERED' => 'search.'.$phpEx.$SID.'&search_id=unanswered',
|
||||
'U_SEARCH_SELF' => 'search.'.$phpEx.$SID.'&search_id=egosearch',
|
||||
@@ -344,26 +333,26 @@ $template->assign_vars(array(
|
||||
'U_PRIVATEMSGS' => 'privmsg.'.$phpEx.$SID.'&folder=inbox',
|
||||
'U_PRIVATEMSGS_POPUP' => 'privmsg.'.$phpEx.$SID.'&mode=newpm',
|
||||
'U_SEARCH' => 'search.'.$phpEx.$SID,
|
||||
'U_MEMBERLIST' => 'memberlist.'.$phpEx.$SID,
|
||||
'U_MODCP' => 'modcp.'.$phpEx.$SID,
|
||||
'U_MEMBERLIST' => 'memberlist.'.$phpEx.$SID,
|
||||
'U_MODCP' => 'modcp.'.$phpEx.$SID,
|
||||
'U_FAQ' => 'faq.'.$phpEx.$SID,
|
||||
'U_VIEWONLINE' => 'viewonline.'.$phpEx.$SID,
|
||||
'U_LOGIN_LOGOUT' => $u_login_logout,
|
||||
'U_MEMBERSLIST' => 'memberlist.'.$phpEx.$SID,
|
||||
'U_GROUP_CP' => 'groupcp.'.$phpEx.$SID,
|
||||
|
||||
'S_USER_LOGGED_IN' => ( $userdata['user_id'] == ANONYMOUS ) ? false : true,
|
||||
'S_USER_LOGGED_IN' => ( $userdata['user_id'] == ANONYMOUS ) ? false : true,
|
||||
'S_USER_PM_POPUP' => ( !empty($userdata['user_popup_pm']) ) ? true : false,
|
||||
'S_USER_BROWSER' => $userdata['session_browser'],
|
||||
'S_CONTENT_DIRECTION' => $lang['DIRECTION'],
|
||||
'S_CONTENT_ENCODING' => $lang['ENCODING'],
|
||||
'S_CONTENT_DIR_LEFT' => $lang['LEFT'],
|
||||
'S_CONTENT_DIR_RIGHT' => $lang['RIGHT'],
|
||||
'S_USER_BROWSER' => $userdata['session_browser'],
|
||||
'S_CONTENT_DIRECTION' => $lang['DIRECTION'],
|
||||
'S_CONTENT_ENCODING' => $lang['ENCODING'],
|
||||
'S_CONTENT_DIR_LEFT' => $lang['LEFT'],
|
||||
'S_CONTENT_DIR_RIGHT' => $lang['RIGHT'],
|
||||
'S_TIMEZONE' => sprintf($lang['All_times'], $lang[$board_config['board_timezone']]),
|
||||
'S_LOGIN_ACTION' => 'login.'.$phpEx.$SID,
|
||||
|
||||
'T_STYLESHEET_DATA' => $theme['css_data'],
|
||||
'T_STYLESHEET_LINK' => 'templates/' . $theme['css_external'],
|
||||
'T_STYLESHEET_DATA' => $theme['css_data'],
|
||||
'T_STYLESHEET_LINK' => 'templates/' . $theme['css_external'],
|
||||
|
||||
'NAV_LINKS' => $nav_links_html)
|
||||
);
|
||||
|
@@ -33,12 +33,12 @@ if ( defined('DEBUG') )
|
||||
$mtime = explode(' ', $mtime);
|
||||
$totaltime = ( $mtime[1] + $mtime[0] ) - $starttime;
|
||||
|
||||
$debug_output = sprintf('<br /><br />[ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $board_config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . (( $session->load ) ? $session->load : 'N/A') . ' ]', $totaltime);
|
||||
$debug_output = sprintf('<br /><br />[ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $board_config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . ( ( $session->load ) ? $session->load : 'N/A') . ' ]', $totaltime);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'PHPBB_VERSION' => $board_config['version'],
|
||||
'ADMIN_LINK' => ( $acl->get_acl_admin() ) ? '<a href="' . "admin/index.$phpEx$SID" . '">' . $lang['Admin_panel'] . '</a><br /><br />' : '',
|
||||
'PHPBB_VERSION' => $board_config['version'],
|
||||
'ADMIN_LINK' => ( $acl->get_acl_admin() ) ? '<a href="' . "admin/index.$phpEx$SID" . '">' . $lang['Admin_panel'] . '</a><br /><br />' : '',
|
||||
'DEBUG_OUTPUT' => ( defined('DEBUG') ) ? $debug_output : '')
|
||||
);
|
||||
|
||||
@@ -49,29 +49,6 @@ $template->display('body');
|
||||
//
|
||||
$db->sql_close();
|
||||
|
||||
//
|
||||
// Compress buffered output if required and send to browser
|
||||
//
|
||||
if ( $do_gzip_compress )
|
||||
{
|
||||
//
|
||||
// Borrowed from php.net!
|
||||
//
|
||||
$gzip_contents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$gzip_size = strlen($gzip_contents);
|
||||
$gzip_crc = crc32($gzip_contents);
|
||||
|
||||
$gzip_contents = gzcompress($gzip_contents, 9);
|
||||
$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);
|
||||
|
||||
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
|
||||
echo $gzip_contents;
|
||||
echo pack("V", $gzip_crc);
|
||||
echo pack("V", $gzip_size);
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
@@ -84,7 +84,7 @@ class session {
|
||||
{
|
||||
//
|
||||
// Do not check IP assuming equivalence, if IPv4 we'll check only first 24
|
||||
// bits ... I've been told (by vHiker) this should alleviate problems with
|
||||
// bits ... I've been told (by vHiker) this should alleviate problems with
|
||||
// load balanced et al proxies while retaining some reliance on IP security.
|
||||
//
|
||||
$ip_check_s = explode('.', $userdata['session_ip']);
|
||||
@@ -97,8 +97,8 @@ class session {
|
||||
//
|
||||
if ( ( $current_time - $userdata['session_time'] > 60 || $userdata['session_page'] != $user_page ) && $update )
|
||||
{
|
||||
$sql = "UPDATE " . SESSIONS_TABLE . "
|
||||
SET session_time = $current_time, session_page = '$user_page'
|
||||
$sql = "UPDATE " . SESSIONS_TABLE . "
|
||||
SET session_time = $current_time, session_page = '$user_page'
|
||||
WHERE session_id = '" . $this->session_id . "'";
|
||||
$db->sql_query($sql);
|
||||
|
||||
@@ -140,8 +140,8 @@ class session {
|
||||
//
|
||||
// Limit sessions in 1 minute period
|
||||
//
|
||||
$sql = "SELECT COUNT(*) AS sessions
|
||||
FROM " . SESSIONS_TABLE . "
|
||||
$sql = "SELECT COUNT(*) AS sessions
|
||||
FROM " . SESSIONS_TABLE . "
|
||||
WHERE session_time >= " . ( $current_time - 60 );
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
@@ -156,8 +156,8 @@ class session {
|
||||
//
|
||||
// Grab user data
|
||||
//
|
||||
$sql = "SELECT *
|
||||
FROM " . USERS_TABLE . "
|
||||
$sql = "SELECT *
|
||||
FROM " . USERS_TABLE . "
|
||||
WHERE user_id = $user_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
@@ -170,12 +170,12 @@ class session {
|
||||
if ( $userdata['user_password'] != $autologin || !$userdata['user_active'] || $user_id == ANONYMOUS )
|
||||
{
|
||||
$autologin = '';
|
||||
$userdata['user_id'] = $user_id = ANONYMOUS;
|
||||
$userdata['user_id'] = $user_id = ANONYMOUS;
|
||||
}
|
||||
|
||||
$sql = "SELECT ban_ip, ban_userid, ban_email
|
||||
FROM " . BANLIST_TABLE . "
|
||||
WHERE ban_end >= $current_time
|
||||
$sql = "SELECT ban_ip, ban_userid, ban_email
|
||||
FROM " . BANLIST_TABLE . "
|
||||
WHERE ban_end >= $current_time
|
||||
OR ban_end = 0";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
@@ -183,9 +183,9 @@ class session {
|
||||
{
|
||||
do
|
||||
{
|
||||
if ( ( $row['user_id'] == $userdata['user_id'] ||
|
||||
if ( ( $row['user_id'] == $userdata['user_id'] ||
|
||||
( $row['ban_ip'] && preg_match('#^' . str_replace('*', '.*?', $row['ban_ip']) . '$#i', $user_ip) ) ||
|
||||
( $row['ban_email'] && preg_match('#^' . str_replace('*', '.*?', $row['ban_email']) . '$#i', $userdata['user_email']) ) )
|
||||
( $row['ban_email'] && preg_match('#^' . str_replace('*', '.*?', $row['ban_email']) . '$#i', $userdata['user_email']) ) )
|
||||
&& !$userdata['user_founder'] )
|
||||
{
|
||||
message_die(MESSAGE, 'You_been_banned');
|
||||
@@ -243,13 +243,13 @@ class session {
|
||||
//
|
||||
// Delete existing session, update last visit info first!
|
||||
//
|
||||
$sql = "UPDATE " . USERS_TABLE . "
|
||||
SET user_lastvisit = " . $userdata['session_time'] . ", user_session_page = '" . $userdata['session_page'] . "'
|
||||
$sql = "UPDATE " . USERS_TABLE . "
|
||||
SET user_lastvisit = " . $userdata['session_time'] . ", user_session_page = '" . $userdata['session_page'] . "'
|
||||
WHERE user_id = " . $userdata['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = "DELETE FROM " . SESSIONS_TABLE . "
|
||||
WHERE session_id = '" . $this->session_id . "'
|
||||
$sql = "DELETE FROM " . SESSIONS_TABLE . "
|
||||
WHERE session_id = '" . $this->session_id . "'
|
||||
AND session_user_id = " . $userdata['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
@@ -266,9 +266,10 @@ class session {
|
||||
{
|
||||
global $db, $board_config, $user_ip;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM " . SESSIONS_TABLE . "
|
||||
WHERE session_time < " . ( $current_time - $board_config['session_length'] );
|
||||
$sql = "SELECT *
|
||||
FROM " . SESSIONS_TABLE . "
|
||||
WHERE session_time < " . ( $current_time - $board_config['session_length'] ) . "
|
||||
LIMIT 10";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$del_session_id = '';
|
||||
@@ -276,8 +277,8 @@ class session {
|
||||
{
|
||||
if ( $row['user_id'] != ANONYMOUS )
|
||||
{
|
||||
$sql = "UPDATE " . USERS_TABLE . "
|
||||
SET user_lastvisit = " . $row['session_time'] . ", user_session_page = '" . $row['session_page'] . "'
|
||||
$sql = "UPDATE " . USERS_TABLE . "
|
||||
SET user_lastvisit = " . $row['session_time'] . ", user_session_page = '" . $row['session_page'] . "'
|
||||
WHERE user_id = " . $row['session_user_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
@@ -290,13 +291,13 @@ class session {
|
||||
//
|
||||
// Delete expired sessions
|
||||
//
|
||||
$sql = "DELETE FROM " . SESSIONS_TABLE . "
|
||||
$sql = "DELETE FROM " . SESSIONS_TABLE . "
|
||||
WHERE session_id IN ($del_session_id)";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
$sql = "UPDATE " . CONFIG_TABLE . "
|
||||
SET config_value = '$current_time'
|
||||
$sql = "UPDATE " . CONFIG_TABLE . "
|
||||
SET config_value = '$current_time'
|
||||
WHERE config_name = 'session_last_gc'";
|
||||
$db->sql_query($sql);
|
||||
|
||||
@@ -341,11 +342,11 @@ class session {
|
||||
//
|
||||
$style = ( !$board_config['override_user_style'] && $userdata['user_id'] != ANONYMOUS ) ? $userdata['user_style'] : $board_config['default_style'];
|
||||
|
||||
$sql = "SELECT t.template_path, t.poll_length, t.pm_box_length, c.css_data, c.css_external, i.*
|
||||
FROM " . STYLES_TABLE . " s, " . STYLES_TPL_TABLE . " t, " . STYLES_CSS_TABLE . " c, " . STYLES_IMAGE_TABLE . " i
|
||||
WHERE s.style_id = $style
|
||||
AND t.template_id = s.template_id
|
||||
AND c.theme_id = s.style_id
|
||||
$sql = "SELECT t.template_path, t.poll_length, t.pm_box_length, c.css_data, c.css_external, i.*
|
||||
FROM " . STYLES_TABLE . " s, " . STYLES_TPL_TABLE . " t, " . STYLES_CSS_TABLE . " c, " . STYLES_IMAGE_TABLE . " i
|
||||
WHERE s.style_id = $style
|
||||
AND t.template_id = s.template_id
|
||||
AND c.theme_id = s.style_id
|
||||
AND i.imageset_id = s.imageset_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
@@ -371,47 +372,57 @@ class session {
|
||||
}
|
||||
|
||||
//
|
||||
// Note this doesn't use the prefetch at present and is very
|
||||
// incomplete ... purely for testing ... will be keeping my
|
||||
// eye of 'other products' to ensure these things don't
|
||||
// Will be keeping my eye of 'other products' to ensure these things don't
|
||||
// mysteriously appear elsewhere, think up your own solutions!
|
||||
//
|
||||
class auth {
|
||||
|
||||
var $acl;
|
||||
var $where_sql = '';
|
||||
|
||||
function auth($mode, $userdata, $forum_id = false)
|
||||
class acl
|
||||
{
|
||||
function acl($mode, $userdata, $forum_id = false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
switch( $mode )
|
||||
{
|
||||
case 'admin':
|
||||
$and_sql = "ao.auth_type LIKE 'admin'";
|
||||
break;
|
||||
case 'list':
|
||||
$and_sql = "AND ( ao.auth_option LIKE 'list' OR ao.auth_type LIKE 'admin' )";
|
||||
$and_sql = "ao.auth_option LIKE 'list' OR ao.auth_type LIKE 'admin'";
|
||||
break;
|
||||
case 'read':
|
||||
$and_sql = "AND ( ao.auth_option LIKE 'read' OR ao.auth_type LIKE 'admin' )";
|
||||
$and_sql = "ao.auth_option LIKE 'read' OR ao.auth_type LIKE 'admin'";
|
||||
break;
|
||||
case 'forum':
|
||||
$and_sql = "AND ( ( au.forum_id = $forum_id ) OR ( au.forum_id <> $forum_id AND ( ao.auth_option LIKE 'list' OR ao.auth_type LIKE 'mod' OR ao.auth_type LIKE 'admin' ) ) )";
|
||||
break;
|
||||
case 'admin':
|
||||
$and_sql = "AND ( ao.auth_type LIKE 'admin' )";
|
||||
$and_sql = "( a.forum_id = $forum_id ) OR ( a.forum_id <> $forum_id AND ( ao.auth_option LIKE 'list' OR ao.auth_type LIKE 'mod' OR ao.auth_type LIKE 'admin' ) )";
|
||||
break;
|
||||
case 'listmod':
|
||||
$and_sql = "AND ( ao.auth_option LIKE 'list' OR ao.auth_type LIKE 'mod' OR ao.auth_type LIKE 'admin' )";
|
||||
break;
|
||||
case 'all':
|
||||
$and_sql = '';
|
||||
$and_sql = "ao.auth_option LIKE 'list' OR ao.auth_type LIKE 'mod' OR ao.auth_type LIKE 'admin'";
|
||||
break;
|
||||
}
|
||||
|
||||
$sql = "SELECT au.forum_id, au.auth_allow_deny, ao.auth_type, ao.auth_option
|
||||
FROM " . ACL_PREFETCH_TABLE . " au, " . ACL_OPTIONS_TABLE . " ao
|
||||
WHERE au.user_id = " . $userdata['user_id'] . "
|
||||
AND ao.auth_option_id = au.auth_option_id
|
||||
$and_sql";
|
||||
$sql = "SELECT a.forum_id, a.auth_allow_deny, ao.auth_type, ao.auth_option
|
||||
FROM " . ACL_GROUPS_TABLE . " a, " . ACL_OPTIONS_TABLE . " ao, " . USER_GROUP_TABLE . " ug
|
||||
WHERE ug.user_id = " . $userdata['user_id'] . "
|
||||
AND a.group_id = ug.group_id
|
||||
AND ao.auth_option_id = a.auth_option_id
|
||||
AND ($and_sql)";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if ( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
do
|
||||
{
|
||||
$this->acl[$row['forum_id']][$row['auth_type']][$row['auth_option']] = $row['auth_allow_deny'];
|
||||
}
|
||||
while ( $row = $db->sql_fetchrow($result) );
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT a.forum_id, a.auth_allow_deny, ao.auth_type, ao.auth_option
|
||||
FROM " . ACL_USERS_TABLE . " a, " . ACL_OPTIONS_TABLE . " ao
|
||||
WHERE a.user_id = " . $userdata['user_id'] . "
|
||||
AND ao.auth_option_id = a.auth_option_id
|
||||
AND ($and_sql)";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if ( $row = $db->sql_fetchrow($result) )
|
||||
@@ -446,14 +457,6 @@ class auth {
|
||||
return $this->get_acl(0, 'admin', $auth_type);
|
||||
}
|
||||
|
||||
function get_acl_user($forum_id, $user_id, $acl = false)
|
||||
{
|
||||
}
|
||||
|
||||
function get_acl_group($forum_id, $group_id, $acl = false)
|
||||
{
|
||||
}
|
||||
|
||||
function set_acl($forum_id, $user_id = false, $group_id = false, $auth = false, $dependencies = array())
|
||||
{
|
||||
global $db;
|
||||
@@ -463,75 +466,6 @@ class auth {
|
||||
return;
|
||||
}
|
||||
|
||||
$dependencies = array_merge_recursive($dependencies, array(
|
||||
'mod' => array(
|
||||
'forum' => array(
|
||||
'list' => 1,
|
||||
'read' => 1,
|
||||
'post' => 1,
|
||||
'reply' => 1,
|
||||
'edit' => 1,
|
||||
'delete' => 1,
|
||||
'poll' => 1,
|
||||
'vote' => 1,
|
||||
'announce' => 1,
|
||||
'sticky' => 1,
|
||||
'attach' => 1,
|
||||
'download' => 1,
|
||||
'html' => 1,
|
||||
'bbcode' => 1,
|
||||
'smilies' => 1,
|
||||
'img' => 1,
|
||||
'flash' => 1,
|
||||
'sigs' => 1,
|
||||
'search' => 1,
|
||||
'email' => 1,
|
||||
'rate' => 1,
|
||||
'print' => 1,
|
||||
'ignoreflood' => 1,
|
||||
'ignorequeue' => 1
|
||||
),
|
||||
),
|
||||
'admin' => array(
|
||||
'forum' => array(
|
||||
'list' => 1,
|
||||
'read' => 1,
|
||||
'post' => 1,
|
||||
'reply' => 1,
|
||||
'edit' => 1,
|
||||
'delete' => 1,
|
||||
'poll' => 1,
|
||||
'vote' => 1,
|
||||
'announce' => 1,
|
||||
'sticky' => 1,
|
||||
'attach' => 1,
|
||||
'download' => 1,
|
||||
'html' => 1,
|
||||
'bbcode' => 1,
|
||||
'smilies' => 1,
|
||||
'img' => 1,
|
||||
'flash' => 1,
|
||||
'sigs' => 1,
|
||||
'search' => 1,
|
||||
'email' => 1,
|
||||
'rate' => 1,
|
||||
'print' => 1,
|
||||
'ignoreflood' => 1,
|
||||
'ignorequeue' => 1
|
||||
),
|
||||
'mod' => array(
|
||||
'edit' => 1,
|
||||
'delete' => 1,
|
||||
'move' => 1,
|
||||
'lock' => 1,
|
||||
'split' => 1,
|
||||
'merge' => 1,
|
||||
'approve' => 1,
|
||||
'unrate' => 1
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
$forum_sql = ( $forum_id ) ? "AND a.forum_id IN ($forum_id, 0)" : '';
|
||||
|
||||
//
|
||||
@@ -540,12 +474,12 @@ class auth {
|
||||
$sql = ( $user_id !== false ) ? "SELECT a.user_id, o.auth_type, o.auth_option_id, o.auth_option, a.auth_allow_deny FROM " . ACL_USERS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o, " . USERS_TABLE . " u WHERE a.auth_option_id = o.auth_option_id $forum_sql AND u.user_id = a.user_id AND a.user_id = $user_id" : "SELECT ug.user_id, o.auth_type, o.auth_option, a.auth_allow_deny FROM " . USER_GROUP_TABLE . " ug, " . ACL_USERS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o, " . USERS_TABLE . " u WHERE a.auth_option_id = o.auth_option_id $forum_sql AND u.user_id = a.user_id AND a.user_id = ug.user_id AND ug.group_id = $group_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$current_user_auth = array();
|
||||
$user_auth = array();
|
||||
if ( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
do
|
||||
{
|
||||
$current_user_auth[$row['user_id']][$row['auth_type']][$row['auth_option_id']] = $row['auth_allow_deny'];
|
||||
$user_auth[$row['user_id']][$row['auth_type']][$row['auth_option_id']] = $row['auth_allow_deny'];
|
||||
}
|
||||
while ( $row = $db->sql_fetchrow($result) );
|
||||
}
|
||||
@@ -554,95 +488,70 @@ class auth {
|
||||
$sql = ( $group_id !== false ) ? "SELECT a.group_id, o.auth_type, o.auth_option_id, o.auth_option, a.auth_allow_deny FROM " . ACL_GROUPS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE a.auth_option_id = o.auth_option_id $forum_sql AND a.group_id = $group_id" : "SELECT ug.group_id, o.auth_type, o.auth_option, a.auth_allow_deny FROM " . USER_GROUP_TABLE . " ug, " . ACL_GROUPS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE a.auth_option_id = o.auth_option_id $forum_sql AND a.group_id = ug.group_id AND ug.user_id = $user_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$current_group_auth = array();
|
||||
$group_auth = array();
|
||||
if ( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
do
|
||||
{
|
||||
$current_group_auth[$row['group_id']][$row['auth_type']][$row['auth_option_id']] = $row['auth_allow_deny'];
|
||||
$group_auth[$row['group_id']][$row['auth_type']][$row['auth_option_id']] = $row['auth_allow_deny'];
|
||||
}
|
||||
while ( $row = $db->sql_fetchrow($result) );
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
print_r($current_user_auth);
|
||||
|
||||
foreach ( $auth as $auth_type => $auth_option_ary )
|
||||
{
|
||||
foreach ( $auth_option_ary as $auth_option => $allow )
|
||||
{
|
||||
if ( $user_id !== false )
|
||||
{
|
||||
if ( !empty($current_user_auth) )
|
||||
if ( !empty($user_auth) )
|
||||
{
|
||||
foreach ( $current_user_auth as $user => $user_auth_ary )
|
||||
foreach ( $user_auth as $user => $user_auth_ary )
|
||||
{
|
||||
$user_auth[$user][$auth_type][$auth_option] = $allow;
|
||||
$sql_ary[] = ( !isset($user_auth_ary[$auth_type][$auth_option]) ) ? "INSERT INTO " . ACL_USERS_TABLE . " (user_id, forum_id, auth_option_id, auth_allow_deny) VALUES ($user_id, $forum_id, $auth_option, $allow)" : ( ( $user_auth_ary[$auth_type][$auth_option] != $allow ) ? "UPDATE " . ACL_USERS_TABLE . " SET auth_allow_deny = $allow WHERE user_id = $user_id AND forum_id = $forum_id and auth_option_id = $auth_option" : '' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_auth[$user_id][$auth_type][$auth_option] = $allow;
|
||||
$sql_ary[] = "INSERT INTO " . ACL_USERS_TABLE . " (user_id, forum_id, auth_option_id, auth_allow_deny) VALUES ($user_id, $forum_id, $auth_option, $allow)";
|
||||
}
|
||||
}
|
||||
|
||||
if ( $group_id !== false )
|
||||
{
|
||||
if ( !empty($current_group_auth) )
|
||||
if ( !empty($group_auth) )
|
||||
{
|
||||
foreach ( $current_group_auth as $group => $group_auth_ary )
|
||||
foreach ( $group_auth as $group => $group_auth_ary )
|
||||
{
|
||||
$group_auth[$group][$auth_type][$auth_option] = $allow;
|
||||
$sql_ary[] = ( !isset($group_auth_ary[$auth_type][$auth_option]) ) ? "INSERT INTO " . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_allow_deny) VALUES ($group_id, $forum_id, $auth_option, $allow)" : ( ( $group_auth_ary[$auth_type][$auth_option] != $allow ) ? "UPDATE " . ACL_GROUPS_TABLE . " SET auth_allow_deny = $allow WHERE group_id = $group_id AND forum_id = $forum_id and auth_option_id = $auth_option" : '' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_auth[$group_id][$auth_type][$auth_option] = $allow;
|
||||
$sql_ary[] = "INSERT INTO " . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_allow_deny) VALUES ($group_id, $forum_id, $auth_option, $allow)";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_r($sql_ary);
|
||||
|
||||
//
|
||||
// Need to update prefetch table ... the fun bit
|
||||
//
|
||||
$sql = ( $user_id !== false ) ? "SELECT a.user_id, o.auth_type, o.auth_option, a.auth_allow_deny FROM " . ACL_PREFETCH_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE a.auth_option_id = o.auth_option_id $forum_sql AND a.user_id = $user_id" : "SELECT ug.user_id, o.auth_type, o.auth_option, a.auth_allow_deny FROM " . USER_GROUP_TABLE . " ug, " . ACL_USERS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE a.auth_option_id = o.auth_option_id $forum_sql AND a.user_id = ug.user_id AND ug.group_id = $group_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$prefetch_auth = array();
|
||||
if ( $row = $db->sql_fetchrow($result) )
|
||||
foreach ( $sql_ary as $sql )
|
||||
{
|
||||
do
|
||||
{
|
||||
$prefetch_auth[$row['user_id']][$row['auth_type']][$row['auth_option']] = $row['auth_allow_deny'];
|
||||
}
|
||||
while ( $row = $db->sql_fetchrow($result) );
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
print_r($prefetch_auth);
|
||||
|
||||
foreach ( $auth as $auth_type => $auth_option_ary )
|
||||
{
|
||||
foreach ( $dependencies[$auth_type] as $dep_sub_type => $dep_sub_type_ary )
|
||||
{
|
||||
foreach ( $dep_sub_type_ary as $dep_sub_option => $dep_sub_allow )
|
||||
{
|
||||
$auth[$dep_sub_type][$dep_sub_option] = $dep_sub_allow;
|
||||
}
|
||||
}
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
unset($current_group_auth);
|
||||
unset($current_user_auth);
|
||||
unset($group_auth);
|
||||
unset($user_auth);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Authentication plug-ins is largely down to
|
||||
// Sergey Kanareykin, our thanks to him.
|
||||
// Sergey Kanareykin, our thanks to him.
|
||||
//
|
||||
class login
|
||||
{
|
||||
|
Reference in New Issue
Block a user