diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index af94d2b692..cf091624b9 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -535,7 +535,7 @@ if ($forum_data['forum_postable'])
'VIEWS' => $topic_rowset[$i]['topic_views'],
'TOPIC_TITLE' => $topic_title,
'TOPIC_TYPE' => $topic_type,
- 'TOPIC_ICON' => (!empty($topic_rowset[$i]['topic_icon']) ) ? '
' : '',
+ 'TOPIC_ICON' => (!empty($topic_rowset[$i]['icon_id']) ) ? '
' : '',
'S_ROW_COUNT' => $i,
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 9b52490d1f..053be02816 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -39,6 +39,8 @@ if (empty($topic_id) && empty($post_id))
$user->start();
// End session management
+
+
// Find topic id if user requested a newer or older topic
if (isset($_GET['view']) && empty($post_id))
{
@@ -53,9 +55,8 @@ if (isset($_GET['view']) && empty($post_id))
AND p.topic_id = $topic_id
AND p.post_approved = 1
AND p.post_time >= u.user_lastvisit
- ORDER BY p.post_time ASC
- LIMIT 1";
- $result = $db->sql_query($sql);
+ ORDER BY p.post_time ASC";
+ $result = $db->sql_query_limit($sql, 1);
if (!($row = $db->sql_fetchrow($result)))
{
@@ -79,9 +80,8 @@ if (isset($_GET['view']) && empty($post_id))
WHERE t2.topic_id = $topic_id
AND t.forum_id = t2.forum_id
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);
+ ORDER BY t.topic_last_post_time $sql_ordering";
+ $result = $db->sql_query_limit($sql, 1);
if (!($row = $db->sql_fetchrow($result)))
{
@@ -95,6 +95,8 @@ if (isset($_GET['view']) && empty($post_id))
}
}
+
+
// Look at this query ... perhaps a re-think? Perhaps store topic ids rather
// than last/first post ids and have a redirect at the top of this page
// for latest post, newest post for a given topic_id?
@@ -170,7 +172,6 @@ watch_topic_forum('topic', $s_watching_topic, $s_watching_topic_img, $user->data
-
// Post ordering options
$previous_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
@@ -244,9 +245,6 @@ $select_post_days .= '';
-
-
-
$sql = "SELECT *
FROM " . RANKS_TABLE;
$result = $db->sql_query($sql);
@@ -260,6 +258,10 @@ $db->sql_freeresult($result);
+// Grab icons
+$icons = array();
+obtain_icons($icons);
+
// Was a highlight request part of the URI?
@@ -281,6 +283,8 @@ if (isset($_GET['highlight']))
$highlight = urlencode($_GET['highlight']);
}
+
+
// Quick mod tools
$s_forum_rules = '';
get_forum_rules('topic', $s_forum_rules, $forum_id);
@@ -306,6 +310,8 @@ $view_next_topic_url = 'viewtopic.' . $phpEx . $SID . '&f=' . $forum_id . '&
$reply_img = ($forum_status == ITEM_LOCKED || $topic_status == ITEM_LOCKED) ? $user->img('reply_locked', $user->lang['Topic_locked']) : $user->img('reply_new', $user->lang['Reply_to_topic']);
$post_img = ($forum_status == ITEM_LOCKED) ? $user->img('post_locked', $user->lang['Forum_locked']) : $user->img('post_new', $user->lang['Post_new_topic']);
+
+
// Set a cookie for this topic
if ($user->data['user_id'] != ANONYMOUS)
{
@@ -360,6 +366,8 @@ if ($parent_id > 0)
}
}
+
+
// Build navigation links
foreach ($forum_parents as $parent_forum_id => $parent_name)
{
@@ -373,6 +381,8 @@ $template->assign_block_vars('navlinks', array(
'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id
));
+
+
// Moderators
$forum_moderators = array();
get_moderators($forum_moderators, $forum_id);
@@ -533,9 +543,8 @@ $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_karma, u
AND pt.post_id = p.post_id
$limit_posts_time
AND u.user_id = p.poster_id
- ORDER BY $sort_order
- LIMIT $start, " . $config['posts_per_page'];
-$result = $db->sql_query($sql);
+ ORDER BY $sort_order";
+$result = $db->sql_query_limit($sql, $start, $config['posts_per_page']);
if ($row = $db->sql_fetchrow($result))
{
@@ -789,10 +798,13 @@ if ($row = $db->sql_fetchrow($result))
// Second parse bbcode here
+
// If we allow users to disable display of emoticons
// we'll need an appropriate check and preg_replace here
$message = (empty($row['enable_smilies']) || empty($config['enable_smilies'])) ? preg_replace('#
(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '\\\\1', '\\0')", '>' . $message . '<'), 1, -1));
}
+
+
// Replace naughty words such as farty pants
if (sizeof($censors))
{
@@ -808,8 +822,10 @@ if ($row = $db->sql_fetchrow($result))
$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $message . '<'), 1, -1));
}
+
$message = nl2br($message);
+
// Editing information
if (intval($row['post_edit_count']))
{
@@ -822,6 +838,8 @@ if ($row = $db->sql_fetchrow($result))
$l_edited_by = '';
}
+
+
// Signature
if (!isset($user_cache[$poster_id]['sig']))
{
@@ -836,9 +854,9 @@ if ($row = $db->sql_fetchrow($result))
$user_cache[$poster_id]['sig'] = (empty($row['user_allowsmile']) || empty($config['enable_smilies'])) ? preg_replace('#
(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1));
+ $user_sig = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $user_sig . '<'), 1, -1));
}
$user_cache[$poster_id]['sig'] = '
_________________
' . nl2br($user_cache[$poster_id]['sig']);
@@ -849,6 +867,8 @@ if ($row = $db->sql_fetchrow($result))
}
}
+
+
// Define the little post icon
$mini_post_img = ($row['post_time'] > $user->data['user_lastvisit'] && $row['post_time'] > $topic_last_read) ? $user->img('goto_post_new', $user->lang['New_post']) : $user->img('goto_post', $user->lang['Post']);
@@ -856,6 +876,8 @@ if ($row = $db->sql_fetchrow($result))
$mini_post_url = 'viewtopic.' . $phpEx . $SID . '&p=' . $row['post_id'] . '#' . $row['post_id'];
$u_post_id = (!empty($newest_post_id) && $newest_post_id == $row['post_id']) ? 'newest' : $row['post_id'];
+
+
// Dump vars into template
$template->assign_block_vars('postrow', array(
'POSTER_NAME' => $poster,
@@ -872,7 +894,7 @@ if ($row = $db->sql_fetchrow($result))
'SIGNATURE' => $user_cache[$poster_id]['sig'],
'EDITED_MESSAGE'=> $l_edited_by,
- 'RATING' => $rating,
+ 'RATING' => $rating,
'MINI_POST_IMG' => $mini_post_img,
'EDIT_IMG' => $edit_img,
@@ -904,9 +926,11 @@ if ($row = $db->sql_fetchrow($result))
'YIM_IMG' => $user_cache[$poster_id]['yim_img'],
'YIM' => $user_cache[$poster_id]['yim'],
- 'L_MINI_POST_ALT' => $mini_post_alt,
+ 'POST_ICON' => (!empty($row['icon_id']) ) ? '
' : '',
- 'S_ROW_COUNT' => $i++,
+ 'L_MINI_POST_ALT' => $mini_post_alt,
+
+ 'S_ROW_COUNT' => $i++,
'U_MINI_POST' => $mini_post_url,
'U_POST_ID' => $u_post_id