1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-19 15:17:16 +01:00

Some sql changes

git-svn-id: file:///svn/phpbb/trunk@2866 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-08-17 22:08:34 +00:00
parent ecf33211ec
commit 26190e5c3b
7 changed files with 187 additions and 108 deletions

View File

@ -73,7 +73,7 @@ function get_userdata($user)
global $db;
$sql = "SELECT *
FROM " . USERS_TABLE . "
FROM " . USERS_TABLE . "
WHERE ";
$sql .= ( ( is_integer($user) ) ? "user_id = $user" : "username = '" . str_replace("\'", "''", $user) . "'" ) . " AND user_id <> " . ANONYMOUS;
$result = $db->sql_query($sql);
@ -91,13 +91,13 @@ function get_moderators(&$forum_moderators, $forum_id = false)
$forum_sql = ( $forum_id ) ? 'AND au.forum_id = ' . $forum_id : '';
$sql = "SELECT au.forum_id, u.user_id, u.username
$sql = "SELECT au.forum_id, u.user_id, u.username
FROM " . ACL_USERS_TABLE . " au, " . ACL_OPTIONS_TABLE . " ao, " . USERS_TABLE . " u
WHERE ao.auth_type LIKE 'mod'
AND au.auth_option_id = ao.auth_option_id
$forum_sql
AND u.user_id = au.user_id
GROUP BY au.forum_id
WHERE ao.auth_value LIKE 'mod_%'
$forum_sql
AND au.auth_option_id = ao.auth_option_id
AND u.user_id = au.user_id
GROUP BY au.forum_id, u.user_id, u.username
ORDER BY au.forum_id, u.user_id";
$result = $db->sql_query($sql);
@ -106,13 +106,13 @@ function get_moderators(&$forum_moderators, $forum_id = false)
$forum_moderators[$row['forum_id']][] = '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $row['user_id'] . '">' . $row['username'] . '</a>';
}
$sql = "SELECT au.forum_id, g.group_id, g.group_name
$sql = "SELECT au.forum_id, g.group_id, g.group_name
FROM " . ACL_GROUPS_TABLE . " au, " . ACL_OPTIONS_TABLE . " ao, " . GROUPS_TABLE . " g
WHERE ao.auth_type LIKE 'mod'
AND au.auth_option_id = ao.auth_option_id
$forum_sql
AND g.group_id = au.group_id
GROUP BY au.forum_id
WHERE ao.auth_value LIKE 'mod_%'
$forum_sql
AND au.auth_option_id = ao.auth_option_id
AND g.group_id = au.group_id
GROUP BY au.forum_id, g.group_id, g.group_name
ORDER BY au.forum_id, g.group_id";
$result = $db->sql_query($sql);
@ -149,12 +149,12 @@ function make_jumpbox($action, $match_forum_id = 0)
{
global $SID, $acl, $template, $lang, $db, $nav_links, $phpEx;
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
FROM (( " . FORUMS_TABLE . " f
LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
ORDER BY f.forum_id";
$result = $db->sql_query($sql);
// $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
// FROM (( " . FORUMS_TABLE . " f
// LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
// LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
// ORDER BY f.forum_id";
// $result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
@ -252,14 +252,14 @@ function language_select($default, $select_name = "language", $dirname="language
}
//
// Pick a template/theme combo,
// Pick a template/theme combo,
//
function style_select($default_style, $select_name = "style", $dirname = "templates")
{
global $db;
$sql = "SELECT style_id, style_name
FROM " . STYLES_TABLE . "
FROM " . STYLES_TABLE . "
ORDER BY style_name, style_id";
$result = $db->sql_query($sql);
@ -305,14 +305,14 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat
$u_url = ( $mode == 'forum' ) ? 'f' : 't';
//
// Is user watching this thread?
// Is user watching this thread?
//
if ( $user_id != ANONYMOUS )
if ( $user_id )
{
$can_watch = TRUE;
$sql = "SELECT notify_status
FROM " . $table_sql . "
$sql = "SELECT notify_status
FROM " . $table_sql . "
WHERE $where_sql = $match_id
AND user_id = $user_id";
$result = $db->sql_query($sql);
@ -326,11 +326,11 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat
$is_watching = 0;
$sql = "DELETE FROM " . $table_sql . "
WHERE $where_sql = $match_id
WHERE $where_sql = $match_id
AND user_id = $user_id";
$db->sql_query($sql);
}
$template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="3;url=' . "view$mode.$phpEx$SID&amp;" . $u_url . "=$match_id&amp;start=$start" . '">')
);
@ -562,7 +562,7 @@ function obtain_word_list(&$orig_word, &$replacement_word)
if ( $row = $db->sql_fetchrow($result) )
{
do
do
{
$orig_word[] = '#\b(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')\b#i';
$replacement_word[] = $row['replacement'];

View File

@ -386,21 +386,21 @@ class acl
if ( !($this->founder = $userdata['user_founder']) )
{
$and_sql = "ao.auth_option LIKE 'list'";
$and_sql = "ao.auth_value LIKE 'forum_list'";
if ( $extra_options )
{
$tmp_ary = explode(',', $extra_options);
foreach ( $tmp_ary as $option )
{
$and_sql .= " OR ao.auth_option LIKE '" . trim($option) . "'";
$and_sql .= " OR ao.auth_value LIKE '" . trim($option) . "'";
}
}
$and_sql = ( !$forum_id ) ? $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' ) )";
$and_sql .= " OR ao.auth_type LIKE 'admin'";
$and_sql = ( !$forum_id ) ? $and_sql : "( a.forum_id = $forum_id ) OR ( a.forum_id <> $forum_id AND ( ao.auth_value LIKE 'forum_list' OR ao.auth_value LIKE 'mod_%' ) )";
$and_sql .= " OR ao.auth_value LIKE 'admin_%'";
$sql = "SELECT a.forum_id, a.auth_allow_deny, ao.auth_type, ao.auth_option
$sql = "SELECT a.forum_id, a.auth_allow_deny, ao.auth_value
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
@ -412,21 +412,23 @@ class acl
{
do
{
switch ( $this->acl[$row['forum_id']][$row['auth_type']][$row['auth_option']] )
list($type, $option) = explode('_', $row['auth_value']);
switch ( $this->acl[$row['forum_id']][$type][$option] )
{
case ACL_PERMIT:
case ACL_DENY:
case ACL_PREVENT:
break;
default:
$this->acl[$row['forum_id']][$row['auth_type']][$row['auth_option']] = $row['auth_allow_deny'];
$this->acl[$row['forum_id']][$type][$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
$sql = "SELECT a.forum_id, a.auth_allow_deny, ao.auth_value
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
@ -437,13 +439,15 @@ class acl
{
do
{
switch ( $this->acl[$row['forum_id']][$row['auth_type']][$row['auth_option']] )
list($type, $option) = explode('_', $row['auth_value']);
switch ( $this->acl[$row['forum_id']][$type][$option] )
{
case ACL_PERMIT:
case ACL_PREVENT:
break;
default:
$this->acl[$row['forum_id']][$row['auth_type']][$row['auth_option']] = $row['auth_allow_deny'];
$this->acl[$row['forum_id']][$type][$option] = $row['auth_allow_deny'];
break;
}
}

View File

@ -127,18 +127,16 @@ if ( ( $total_categories = count($category_rows) ) )
switch ( SQL_LAYER )
{
case 'oracle':
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
WHERE p.post_id = f.forum_last_post_id(+)
AND u.user_id = p.poster_id(+)
$sql = "SELECT f.*, u.username, u.user_id
FROM " . FORUMS_TABLE . " f, " . USERS_TABLE . " u
WHERE u.user_id = p.poster_id(+)
ORDER BY f.cat_id, f.forum_order";
break;
default:
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
FROM (( " . FORUMS_TABLE . " f
LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
$sql = "SELECT f.*, u.username, u.user_id
FROM ( " . FORUMS_TABLE . " f
LEFT JOIN " . USERS_TABLE . " u ON u.user_id = f.forum_last_poster_id )
ORDER BY f.cat_id, f.forum_order";
break;
}
@ -184,8 +182,6 @@ if ( ( $total_categories = count($category_rows) ) )
'L_LEGEND' => $lang['Legend'],
'L_NO_FORUMS' => $lang['No_forums'],
'S_LEGEND' => $legend,
'U_MARK_READ' => "index.$phpEx$SID&amp;mark=forums")
);
@ -247,20 +243,12 @@ if ( ( $total_categories = count($category_rows) ) )
foreach ( $new_topic_data[$row_forum_id] as $check_topic_id => $check_post_time )
{
if ( empty($tracking_topics[$check_topic_id]) )
if ( empty($tracking_topics[$check_topic_id]) || $tracking_topics[$check_topic_id] < $check_post_time)
{
$unread_topics = true;
$forum_last_post_time = max($check_post_time, $forum_last_post_time);
}
else
{
if ( $tracking_topics[$check_topic_id] < $check_post_time )
{
$unread_topics = true;
$forum_last_post_time = max($check_post_time, $forum_last_post_time);
}
}
}
if ( !empty($tracking_forums[$row_forum_id]) )
@ -278,7 +266,6 @@ if ( ( $total_categories = count($category_rows) ) )
$unread_topics = false;
}
}
}
}
@ -291,11 +278,11 @@ if ( ( $total_categories = count($category_rows) ) )
if ( $forum_data[$j]['forum_last_post_id'] )
{
$last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']);
$last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['forum_last_post_time'], $board_config['board_timezone']);
$last_post = $last_post_time . '<br />';
$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . "profile.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $forum_data[$j]['user_id'] . '">' . $forum_data[$j]['username'] . '</a> ';
$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['forum_last_poster_name'] != '' ) ? $forum_data[$j]['forum_last_poster_name'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . "profile.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $forum_data[$j]['user_id'] . '">' . $forum_data[$j]['username'] . '</a> ';
$last_post .= '<a href="' . "viewtopic.$phpEx$SID&amp;f=$row_forum_id&amp;p=" . $forum_data[$j]['forum_last_post_id'] . '#' . $forum_data[$j]['forum_last_post_id'] . '">' . create_img($theme['goto_post_latest'], $lang['View_latest_post']) . '</a>';
}

View File

@ -28,7 +28,9 @@ CREATE TABLE phpbb_auth_groups (
group_id mediumint(8) unsigned NOT NULL default '0',
forum_id mediumint(8) unsigned NOT NULL default '0',
auth_option_id smallint(5) unsigned NOT NULL default '0',
auth_allow_deny tinyint(4) NOT NULL default '1'
auth_allow_deny tinyint(4) NOT NULL default '1',
KEY group_id (group_id),
KEY auth_option_id (auth_option_id)
);
@ -37,9 +39,8 @@ CREATE TABLE phpbb_auth_groups (
#
CREATE TABLE phpbb_auth_options (
auth_option_id tinyint(4) NOT NULL auto_increment,
auth_type char(15) NOT NULL default '',
auth_option char(15) NOT NULL default '',
PRIMARY KEY (auth_option_id,auth_option)
auth_value char(20) NOT NULL,
PRIMARY KEY (auth_value, auth_option_id)
);
@ -52,6 +53,8 @@ CREATE TABLE phpbb_auth_prefetch (
forum_id mediumint(8) unsigned NOT NULL default '0',
auth_option_id smallint(5) unsigned NOT NULL default '0',
auth_allow_deny tinyint(4) NOT NULL default '1'
KEY user_id (user_id),
KEY auth_option_id (auth_option_id)
);
@ -64,6 +67,8 @@ CREATE TABLE phpbb_auth_users (
forum_id mediumint(8) unsigned NOT NULL default '0',
auth_option_id smallint(5) unsigned NOT NULL default '0',
auth_allow_deny tinyint(4) NOT NULL default '1'
KEY user_id (user_id),
KEY auth_option_id (auth_option_id)
);
@ -552,7 +557,11 @@ CREATE TABLE phpbb_topics (
topic_status tinyint(3) DEFAULT '0' NOT NULL,
topic_type tinyint(3) DEFAULT '0' NOT NULL,
topic_first_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
topic_first_poster_name varchar(30),
topic_last_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
topic_last_poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
topic_last_poster_name varchar(30),
topic_last_post_time int(11) DEFAULT '0' NOT NULL,
topic_moved_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
post_count_inc tinyint(1) DEFAULT '1' NOT NULL,
poll_title varchar(255) NOT NULL,

View File

@ -1,6 +1,6 @@
<?php
@set_time_limit(600);
@set_time_limit(2400);
ob_end_clean();
//
//
@ -20,7 +20,7 @@ $db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
//
// Updates to this version ...
//
$version = '2.1.0 [20020816]';
$version = '2.1.0 [20020817]';
// ----------------
// BEGIN VARS DEFNS
@ -503,7 +503,8 @@ switch ( $this_version )
$sql_ary = array(
"INSERT INTO " . $table_prefix . "styles (style_id, template_id, theme_id, imageset_id, style_name) VALUES (1, 1, 1, 1, 'subSilver')",
"INSERT INTO " . $table_prefix . "styles_imageset (imageset_id, imageset_name, imageset_path, post_new, post_locked, post_pm, reply_new, reply_pm, reply_locked, icon_quote, icon_edit, icon_search, icon_profile, icon_pm, icon_email, icon_www, icon_icq, icon_aim, icon_yim, icon_msnm, icon_no_email, icon_no_www, icon_no_icq, icon_no_aim, icon_no_yim, icon_no_msnm, icon_delete, icon_ip, goto_post, goto_post_new, goto_post_latest, goto_post_newest, forum, forum_new, forum_locked, folder, folder_new, folder_hot, folder_hot_new, folder_locked, folder_locked_new, folder_sticky, folder_sticky_new, folder_announce, folder_announce_new, topic_watch, topic_unwatch, poll_left, poll_center, poll_right, rating) VALUES (1, 'subSilver &copy; phpBB Group', 'subSilver', '\"imagesets/subSilver/{LANG}/post.gif\" width=\"82\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/{LANG}/reply-locked.gif\" width=\"82\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/{LANG}/post.gif\" width=\"82\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/{LANG}/reply.gif\" width=\"88\" height=\"27\" border=\"0\"', '\"imagesets/subSilver/{LANG}/reply.gif\" width=\"88\" height=\"27\" border=\"0\"', '\"imagesets/subSilver/{LANG}/reply-locked.gif\" width=\"82\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_quote.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_edit.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_search.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_profile.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_pm.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_email.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_www.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_icq_add.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_aim.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_yim.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_msnm.gif\" width=\"59\" height=\"18\" border=\"0\"', '', '', '', '', '', '', '\"imagesets/subSilver/icon_delete.gif\" width=\"16\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_ip.gif\" width=\"16\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/icon_minipost.gif\" width=\"12\" height=\"9\" border=\"0\"', '\"imagesets/subSilver/icon_minipost_new.gif\" width=\"12\" height=\"9\" border=\"0\"', '\"imagesets/subSilver/icon_latest_reply.gif\" width=\"18\" height=\"9\" border=\"0\"', '\"imagesets/subSilver/icon_newest_reply.gif\" width=\"18\" height=\"9\" border=\"0\"', '\"imagesets/subSilver/folder_big.gif\" width=\"46\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/folder_new_big.gif\" width=\"46\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/folder_locked_big.gif\" width=\"46\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/folder.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_new.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_hot.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_new_hot.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_lock.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_lock_new.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_sticky.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_sticky_new.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_announce.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_announce_new.gif\" width=\"19\" height=\"18\" border=\"0\"', '', '', '\"imagesets/subSilver/voting_lcap.gif\" width=\"4\" height=\"12\" border=\"0\"', '\"imagesets/subSilver/voting_rcap.gif\" height=\"12\" border=\"0\"', '\"imagesets/subSilver/voting_bar.gif\" width=\"4\" height=\"12\" border=\"0\"', '\"imagesets/subSilver/ratings/{RATE}.gif\" width=\"45\" height=\"17\" border=\"0\"')",
"INSERT INTO " . $table_prefix . "styles_imageset (imageset_id, imageset_name, imageset_path, post_new, post_locked, post_pm, reply_new, reply_pm, reply_locked, icon_quote, icon_edit, icon_search, icon_profile, icon_pm, icon_email, icon_www, icon_icq, icon_aim, icon_yim, icon_msnm, icon_no_email, icon_no_www, icon_no_icq, icon_no_aim, icon_no_yim, icon_no_msnm, icon_delete, icon_ip, goto_post, goto_post_new, goto_post_latest, goto_post_newest, forum, forum_new, forum_locked, folder, folder_new, folder_hot, folder_hot_new, folder_locked, folder_locked_new, folder_sticky, folder_sticky_new, folder_announce, folder_announce_new, topic_watch, topic_unwatch, poll_left, poll_center, poll_right, rating) VALUES (1, 'subSilver &copy; phpBB Group', 'subSilver', '\"imagesets/subSilver/{LANG}/post.gif\" width=\"82\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/{LANG}/reply-locked.gif\" width=\"82\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/{LANG}/post.gif\" width=\"82\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/{LANG}/reply.gif\" width=\"88\" height=\"27\" border=\"0\"', '\"imagesets/subSilver/{LANG}/reply.gif\" width=\"88\" height=\"27\" border=\"0\"', '\"imagesets/subSilver/{LANG}/reply-locked.gif\" width=\"82\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_quote.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_edit.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_search.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_profile.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_pm.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_email.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_www.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_icq_add.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_aim.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_yim.gif\" width=\"59\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_msnm.gif\" width=\"59\" height=\"18\" border=\"0\"', '', '', '', '', '', '', '\"imagesets/subSilver/icon_delete.gif\" width=\"16\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/{LANG}/icon_ip.gif\" width=\"16\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/icon_minipost.gif\" width=\"12\" height=\"9\" border=\"0\"', '\"imagesets/subSilver/icon_minipost_new.gif\" width=\"12\" height=\"9\" border=\"0\"', '\"imagesets/subSilver/icon_latest_reply.gif\" width=\"18\" height=\"9\" border=\"0\"', '\"imagesets/subSilver/icon_newest_reply.gif\" width=\"18\" height=\"9\" border=\"0\"', '\"imagesets/subSilver/folder_big.gif\" width=\"46\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/folder_new_big.gif\" width=\"46\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/folder_locked_big.gif\" width=\"46\" height=\"25\" border=\"0\"', '\"imagesets/subSilver/folder.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_new.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_hot.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_new_hot.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_lock.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_lock_new.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_sticky.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_sticky_new.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_announce.gif\" width=\"19\" height=\"18\" border=\"0\"', '\"imagesets/subSilver/folder_announce_new.gif\" width=\"19\" height=\"18\" border=\"0\"', '', '', '\"imagesets/subSilver/voting_lcap.gif\" width=\"4\" height=\"12\" border=\"0\"', '\"imagesets/subSilver/voting_rcap.gif\" height=\"12\" border=\"0\"', '\"imagesets/subSilver/voting_bar
.gif\" width=\"4\" height=\"12\" border=\"0\"', '\"imagesets/subSilver/ratings/{RATE}.gif\" width=\"45\" height=\"17\" border=\"0\"')",
"INSERT INTO " . $table_prefix . "styles_template (template_id, template_name, template_path, poll_length, pm_box_length, compile_crc) VALUES (1, 'subSilver &copy; phpBB Group', 'subSilver', 205, 175, '')",
@ -864,13 +865,85 @@ switch ( $this_version )
}
gen_str_ok();
case '2.1.0 [20020816]':
$sql_ary = array();
gen_str_init('* Updating <b>post checksums</b>');
$sql_ary[] = "UPDATE " . $table_prefix . "posts_text
SET post_checksum = MD5(post_text)";
foreach ( $sql_ary as $sql )
{
$db->sql_query($sql);
}
gen_str_ok();
gen_str_init('* Updating <b>forum post info</b>');
switch ( SQL_LAYER )
{
case 'oracle':
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
FROM " . $table_prefix . "forums f, " . $table_prefix . "posts p, " . $table_prefix . "users u
WHERE p.post_id = f.forum_last_post_id(+)
AND u.user_id = p.poster_id(+)";
break;
default:
$sql = "SELECT f.forum_id, p.post_time, p.post_username, u.username, u.user_id
FROM (( " . $table_prefix . "forums f
LEFT JOIN " . $table_prefix . "posts p ON p.post_id = f.forum_last_post_id )
LEFT JOIN " . $table_prefix . "users u ON u.user_id = p.poster_id )";
break;
}
$result = $db->sql_query($sql);
$sql_ary = array();
while ( $row = $db->sql_fetchrow($result) )
{
$forum_id = $row['forum_id'];
$sql_ary[] = "UPDATE " . $table_prefix . "forums
SET forum_last_poster_id = " . $row['user_id'] . ", forum_last_poster_name = '" . $row['post_username'] . "', forum_last_post_time = " . $row['post_time'] . "
WHERE forum_id = $forum_id";
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
FROM " . $table_prefix . "topics t, " . $table_prefix . "users u, " . $table_prefix . "posts p, " . $table_prefix . "posts p2, " . $table_prefix . "users u2
WHERE t.forum_id = $forum_id
AND u.user_id = t.topic_poster
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id";
$result2 = $db->sql_query($sql);
while ( $row2 = $db->sql_fetchrow($result2) )
{
$sql_ary[] = "UPDATE " . $table_prefix . "topics
SET topic_first_poster_name = '" . $row2['post_username'] . "', topic_last_poster_id = " . $row2['id2'] . ", topic_last_post_time = " . $row2['post_time'] . ", topic_last_poster_name = '" . $row2['post_username2'] . "'
WHERE topic_id = " . $row2['topic_id'];
}
$db->sql_freeresult($result2);
unset($row2);
}
$db->sql_freeresult($result);
foreach ( $sql_ary as $sql )
{
$db->sql_query($sql);
}
gen_str_ok();
break;
default;
print "<span class=\"updtext\">* No updates needed</span><br />\n";
}
$sql = "UPDATE " . $table_prefix . "config
SET config_value = '$version'
WHERE config_name = 'version'";

View File

@ -83,7 +83,7 @@ if ( !($forum_data = $db->sql_fetchrow($result)) )
//
// Configure style, language, etc.
//
$userdata['user_style'] = ( $forum_data['forum_style'] ) ? $forum_data['user_style'] : $userdata['user_style'];
$userdata['user_style'] = ( $forum_data['forum_style'] ) ? $forum_data['forum_style'] : $userdata['user_style'];
$session->configure($userdata);
//
@ -91,7 +91,7 @@ $session->configure($userdata);
//
if ( !$acl->get_acl($forum_id, 'forum', 'read') )
{
if ( $userdata['user_id'] == ANONYMOUS )
if ( $userdata['user_id'] )
{
$redirect = "f=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
@ -119,10 +119,10 @@ $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f'
//
if ( $mark_read == 'topics' )
{
if ( $userdata['user_id'] != ANONYMOUS )
if ( $userdata['user_id'] )
{
$sql = "SELECT MAX(post_time) AS last_post
FROM " . POSTS_TABLE . "
$sql = "SELECT MAX(topic_last_post_time) AS last_post
FROM " . TOPICS_TABLE . "
WHERE forum_id = $forum_id";
$result = $db->sql_query($sql);
@ -183,6 +183,9 @@ $orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
//
// Topic ordering options
//
@ -195,18 +198,20 @@ if ( isset($HTTP_POST_VARS['sort']) )
if ( !empty($HTTP_POST_VARS['sort_days']) )
{
$sort_days = ( !empty($HTTP_POST_VARS['sort_days']) ) ? intval($HTTP_POST_VARS['sort_days']) : intval($HTTP_GET_VARS['sort_days']);
$min_topic_time = time() - ($sort_days * 86400);
$min_topic_time = time() - ( $sort_days * 86400 );
$sql = "SELECT COUNT(t.topic_id) AS forum_topics
FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
WHERE t.forum_id = $forum_id
AND p.post_id = t.topic_last_post_id
AND p.post_time >= $min_topic_time";
//
// ref type on as rows as topics ... also not great
//
$sql = "SELECT COUNT(topic_id) AS forum_topics
FROM " . TOPICS_TABLE . "
WHERE forum_id = $forum_id
AND topic_last_post_time >= $min_topic_time";
$result = $db->sql_query($sql);
$start = 0;
$topics_count = ( $row = $db->sql_fetchrow($result) ) ? $row['forum_topics'] : 0;
$limit_topics_time = "AND p.post_time >= $min_topic_time";
$limit_topics_time = "AND t.topic_last_post_time >= $min_topic_time";
}
else
{
@ -248,13 +253,15 @@ $select_sort_dir = '<select name="sort_dir">';
$select_sort_dir .= ( $sort_dir == 'a' ) ? '<option value="a" selected="selected">' . $lang['Ascending'] . '</option><option value="d">' . $lang['Descending'] . '</option>' : '<option value="a">' . $lang['Ascending'] . '</option><option value="d" selected="selected">' . $lang['Descending'] . '</option>';
$select_sort_dir .= '</select>';
$post_alt = ( $forum_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'];
$post_img = '<img src=' . (( $forum_data['forum_status'] == FORUM_LOCKED ) ? $theme['post_locked'] : $theme['post_new'] ) . ' border="0" alt="' . $post_alt . '" title="' . $post_alt . '" />';
$template->assign_vars(array(
'FORUM_ID' => $forum_id,
'FORUM_NAME' => $forum_data['forum_name'],
'POST_IMG' => $post_img,
'POST_IMG' => '<img src=' . (( $forum_data['forum_status'] == FORUM_LOCKED ) ? $theme['post_locked'] : $theme['post_new'] ) . ' border="0" alt="' . $post_alt . '" title="' . $post_alt . '" />',
'PAGINATION' => generate_pagination("viewforum.$phpEx$SID&amp;f=$forum_id&amp;topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start),
'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )),
@ -314,14 +321,13 @@ $topic_rowset = array();
if ( $start )
{
$sql = "SELECT t.*, i.icons_url, i.icons_width, i.icons_height, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username AS post_username2
FROM " . TOPICS_TABLE . " t, " . ICONS_TABLE . " i, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
$sql = "SELECT t.*, i.icons_url, i.icons_width, i.icons_height, u.username, u.user_id, u2.username as user2, u2.user_id as id2
FROM " . TOPICS_TABLE . " t, " . ICONS_TABLE . " i, " . USERS_TABLE . " u, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_type = " . POST_ANNOUNCE . "
AND i.icons_id = t.topic_icon
AND u.user_id = t.topic_poster
AND p.post_id = t.topic_last_post_id
AND u2.user_id = p.poster_id
AND u2.user_id = t.topic_last_poster_id
ORDER BY $sort_order
LIMIT " . $board_config['topics_per_page'];
$result = $db->sql_query($sql);
@ -333,14 +339,15 @@ if ( $start )
}
}
$sql = "SELECT t.*, i.icons_url, i.icons_width, i.icons_height, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
FROM " . TOPICS_TABLE . " t, " . ICONS_TABLE . " i, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
//
// topic icon join requires full table scan ... not good
//
$sql = "SELECT t.*, i.icons_url, i.icons_width, i.icons_height, u.username, u.user_id, u2.username as user2, u2.user_id as id2
FROM " . TOPICS_TABLE . " t, " . ICONS_TABLE . " i, " . USERS_TABLE . " u, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND i.icons_id = t.topic_icon
AND u.user_id = t.topic_poster
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
AND u2.user_id = t.topic_last_poster_id
$limit_topics_time
ORDER BY t.topic_type DESC, $sort_order
LIMIT $start, " . $board_config['topics_per_page'];
@ -520,15 +527,15 @@ if ( $total_topics )
$view_topic_url = 'viewtopic.' . $phpEx . $SID . '&amp;f=' . $forum_id . '&amp;t=' . $topic_id;
$topic_author = ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $topic_rowset[$i]['user_id'] . '">' : '';
$topic_author .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? $topic_rowset[$i]['username'] : ( ( $topic_rowset[$i]['post_username'] != '' ) ? $topic_rowset[$i]['post_username'] : $lang['Guest'] );
$topic_author .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? $topic_rowset[$i]['username'] : ( ( $topic_rowset[$i]['topic_first_poster_name'] != '' ) ? $topic_rowset[$i]['topic_first_poster_name'] : $lang['Guest'] );
$topic_author .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : '';
$first_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['topic_time'], $board_config['board_timezone']);
$last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);
$last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['topic_last_post_time'], $board_config['board_timezone']);
$last_post_author = ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? ( ( $topic_rowset[$i]['post_username2'] != '' ) ? $topic_rowset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $topic_rowset[$i]['id2'] . '">' . $topic_rowset[$i]['user2'] . '</a>';
$last_post_author = ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? ( ( $topic_rowset[$i]['topic_last_poster_name'] != '' ) ? $topic_rowset[$i]['topic_last_poster_name'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $topic_rowset[$i]['topic_last_poster_id'] . '">' . $topic_rowset[$i]['user2'] . '</a>';
$last_post_url = '<a href="viewtopic.' . $phpEx . $SID . '&amp;p=' . $topic_rowset[$i]['topic_last_post_id'] . '#' . $topic_rowset[$i]['topic_last_post_id'] . '">' . create_img($theme['goto_post_latest'], $lang['View_latest_post']) . '</a>';

View File

@ -58,7 +58,7 @@ if ( isset($HTTP_GET_VARS['view']) && empty($post_id) )
WHERE s.session_id = '$session_id'
AND u.user_id = s.session_user_id
AND p.topic_id = $topic_id
AND p.post_approved = " . TRUE . "
AND p.post_approved = 1
AND p.post_time >= u.user_lastvisit
ORDER BY p.post_time ASC
LIMIT 1";
@ -75,7 +75,7 @@ if ( isset($HTTP_GET_VARS['view']) && empty($post_id) )
}
}
header($header_location . 'viewtopic.' . $phpEx . $SID . '&t=' . $topic_id);
header($header_location . 'index.' . $phpEx);
exit;
}
else if ( $HTTP_GET_VARS['view'] == 'next' || $HTTP_GET_VARS['view'] == 'previous' )
@ -84,15 +84,11 @@ if ( isset($HTTP_GET_VARS['view']) && empty($post_id) )
$sql_ordering = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'ASC' : 'DESC';
$sql = "SELECT t.topic_id
FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2
FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2
WHERE t2.topic_id = $topic_id
AND p2.post_id = t2.topic_last_post_id
AND t.forum_id = t2.forum_id
AND p.post_id = t.topic_last_post_id
AND p.post_approved = " . TRUE . "
AND p.post_time $sql_condition p2.post_time
AND p.topic_id = t.topic_id
ORDER BY p.post_time $sql_ordering
AND t.topic_last_post_time $sql_condition t2.topic_last_post_time
ORDER BY t.topic_last_post_time $sql_ordering
LIMIT 1";
$result = $db->sql_query($sql);
@ -272,8 +268,7 @@ for($i = 0; $i < count($previous_days); $i++)
$select_post_days .= '</select>';
$sql = "SELECT *
FROM " . RANKS_TABLE . "
ORDER BY rank_special, rank_min";
FROM " . RANKS_TABLE;
$result = $db->sql_query($sql);
$ranksrow = array();
@ -284,7 +279,7 @@ while ( $row = $db->sql_fetchrow($result) )
$db->sql_freeresult($result);
$rating = '';
if ( $userdata['user_id'] != ANONYMOUS )
if ( $userdata['user_id'] )
{
$rating_text = array(-5 => $lang['Very_poor'], -2 => $lang['Quite_poor'], 0 => $lang['Unrated'], 2 => $lang['Quite_good'], 5 => $lang['Very_good']);
@ -616,12 +611,16 @@ $poster_details = array();
//
// Go ahead and pull all data for this topic
//
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
// FROM phpbb_posts2 p, " . USERS_TABLE . " u
// AND pt.post_id = p.post_id
// pt.post_text, pt.post_subject, pt.bbcode_uid
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.topic_id = $topic_id
AND p.post_approved = " . TRUE . "
$limit_posts_time
AND pt.post_id = p.post_id
$limit_posts_time
AND u.user_id = p.poster_id
ORDER BY $sort_order
LIMIT $start, " . $board_config['posts_per_page'];