mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
- BBCode now only loaded if necessary
- now obtains the whole post rowset before actual processing apply - put all user_cache definitions together - topic_view is only updated once per topic, not at every page git-svn-id: file:///svn/phpbb/trunk@3856 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
afaf95bb13
commit
23efd0bbb4
1 changed files with 628 additions and 598 deletions
|
@ -23,10 +23,6 @@ define('IN_PHPBB', true);
|
||||||
$phpbb_root_path = './';
|
$phpbb_root_path = './';
|
||||||
include($phpbb_root_path . 'extension.inc');
|
include($phpbb_root_path . 'extension.inc');
|
||||||
include($phpbb_root_path . 'common.'.$phpEx);
|
include($phpbb_root_path . 'common.'.$phpEx);
|
||||||
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
|
|
||||||
|
|
||||||
// Instantiate BBCode class
|
|
||||||
$bbcode = new bbcode();
|
|
||||||
|
|
||||||
// Initial var setup
|
// Initial var setup
|
||||||
$forum_id = (isset($_GET['f'])) ? max(intval($_GET['f']), 0) : 0;
|
$forum_id = (isset($_GET['f'])) ? max(intval($_GET['f']), 0) : 0;
|
||||||
|
@ -38,6 +34,9 @@ $start = (isset($_GET['start'])) ? max(intval($_GET['start']), 0) : 0;
|
||||||
// parameters are not directly used in SQL I'm tempted to say
|
// parameters are not directly used in SQL I'm tempted to say
|
||||||
// if someone wishes to screw their view up by entering unknown data
|
// if someone wishes to screw their view up by entering unknown data
|
||||||
// good luck to them :D
|
// good luck to them :D
|
||||||
|
|
||||||
|
// If, for some reason, the SQL query would not fail and $sort vars were
|
||||||
|
// displayed in $pagination_url they could be used for XSS -- Ashe
|
||||||
$sort_days = (!empty($_REQUEST['st'])) ? max(intval($_REQUEST['st']), 0) : 0;
|
$sort_days = (!empty($_REQUEST['st'])) ? max(intval($_REQUEST['st']), 0) : 0;
|
||||||
$sort_key = (!empty($_REQUEST['sk'])) ? htmlspecialchars($_REQUEST['sk']) : 't';
|
$sort_key = (!empty($_REQUEST['sk'])) ? htmlspecialchars($_REQUEST['sk']) : 't';
|
||||||
$sort_dir = (!empty($_REQUEST['sd'])) ? htmlspecialchars($_REQUEST['sd']) : 'a';
|
$sort_dir = (!empty($_REQUEST['sd'])) ? htmlspecialchars($_REQUEST['sd']) : 'a';
|
||||||
|
@ -248,17 +247,44 @@ $sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'AS
|
||||||
|
|
||||||
|
|
||||||
// Cache this? ... it is after all doing a simple data grab
|
// Cache this? ... it is after all doing a simple data grab
|
||||||
$sql = "SELECT *
|
|
||||||
FROM " . RANKS_TABLE . "
|
|
||||||
ORDER BY rank_special, rank_min DESC";
|
|
||||||
$result = $db->sql_query($sql, 120);
|
|
||||||
|
|
||||||
$ranksrow = array();
|
// Only good if there are lots of ranks IMHO (we save the sorting)
|
||||||
while ($row = $db->sql_fetchrow($result))
|
// Moved to global cache but could be simply obtained dynamically if we see
|
||||||
|
// the cache is growing too big -- Ashe
|
||||||
|
if ($cache->exists('ranks'))
|
||||||
{
|
{
|
||||||
$ranksrow[] = $row;
|
$ranks = $cache->get('ranks');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql = 'SELECT *
|
||||||
|
FROM ' . RANKS_TABLE . '
|
||||||
|
ORDER BY rank_min DESC';
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$ranks = array();
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
if ($row['rank_special'])
|
||||||
|
{
|
||||||
|
$ranks['special'][$row['rank_id']] = array(
|
||||||
|
'rank_title' => $row['rank_title'],
|
||||||
|
'rank_image' => $row['rank_image']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ranks['normal'][] = array(
|
||||||
|
'rank_title' => $row['rank_title'],
|
||||||
|
'rank_min' => $row['rank_min'],
|
||||||
|
'rank_image' => $row['rank_image']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
$cache->put('ranks', $ranks);
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
|
|
||||||
// Grab icons
|
// Grab icons
|
||||||
|
@ -473,33 +499,12 @@ if (!empty($poll_start))
|
||||||
|
|
||||||
|
|
||||||
// Container for user details, only process once
|
// Container for user details, only process once
|
||||||
$user_cache = $attachments = $attach_list = array();
|
$user_cache = $attachments = $attach_list = $rowset = array();
|
||||||
|
$has_attachments = FALSE;
|
||||||
$force_encoding = '';
|
$force_encoding = '';
|
||||||
|
$bbcode_bitfield = 0;
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
// Pull attachment data
|
|
||||||
if ( ($config['allow_attachments']) && ($topic_attachment) && ($auth->acl_get('f_download', $forum_id)) )
|
|
||||||
{
|
|
||||||
$sql = "SELECT a.post_id, p.topic_id, d.*
|
|
||||||
FROM " . ATTACHMENTS_TABLE . " a, " . ATTACHMENTS_DESC_TABLE . " d, " . POSTS_TABLE . " p
|
|
||||||
WHERE p.topic_id = " . $topic_id . "
|
|
||||||
AND p.post_id = a.post_id
|
|
||||||
AND a.attach_id = d.attach_id
|
|
||||||
AND p.post_attachment = 1
|
|
||||||
ORDER BY d.filetime " . ((!$config['display_order']) ? "ASC" : "DESC") . ", a.post_id ASC";
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
if ($row = $db->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
$attachments[$row['post_id']][] = $row;
|
|
||||||
}
|
|
||||||
while ($row = $db->sql_fetchrow($result));
|
|
||||||
}
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Go ahead and pull all data for this topic
|
// Go ahead and pull all data for this topic
|
||||||
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_karma, 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_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, p.*
|
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_karma, 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_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, p.*
|
||||||
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
|
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
|
||||||
|
@ -510,14 +515,102 @@ $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_karma, u
|
||||||
ORDER BY $sort_order";
|
ORDER BY $sort_order";
|
||||||
$result = (isset($_GET['view']) && $_GET['view'] == 'print') ? $db->sql_query($sql) : $db->sql_query_limit($sql, intval($config['posts_per_page']), $start);
|
$result = (isset($_GET['view']) && $_GET['view'] == 'print') ? $db->sql_query($sql) : $db->sql_query_limit($sql, intval($config['posts_per_page']), $start);
|
||||||
|
|
||||||
if ($row = $db->sql_fetchrow($result))
|
if (!$row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
do
|
trigger_error($user->lang['NO_TOPIC']);
|
||||||
{
|
}
|
||||||
$poster_id = $row['user_id'];
|
|
||||||
$poster = ($poster_id == ANONYMOUS) ? $user->lang['GUEST'] : $row['username'];
|
|
||||||
|
|
||||||
|
|
||||||
|
// Posts are stored in the $rowset array while $attach_list and the global
|
||||||
|
// bbcode_bitfield are built
|
||||||
|
do
|
||||||
|
{
|
||||||
|
$rowset[] = $row;
|
||||||
|
|
||||||
|
// Does post have an attachment? If so, add it to the list
|
||||||
|
if ($row['post_attachment'] && $config['allow_attachments'] && $auth->acl_get('f_download', $forum_id))
|
||||||
|
{
|
||||||
|
$attach_list[] = $row['post_id'];
|
||||||
|
|
||||||
|
if ($row['post_approved'])
|
||||||
|
{
|
||||||
|
$has_attachments = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define the global bbcode bitfield, will be used to load bbcodes
|
||||||
|
$bbcode_bitfield |= $row['bbcode_bitfield'];
|
||||||
|
}
|
||||||
|
while ($row = $db->sql_fetchrow($result));
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
|
||||||
|
// Pull attachment data
|
||||||
|
if (count($attach_list))
|
||||||
|
{
|
||||||
|
$sql = 'SELECT a.post_id, d.*
|
||||||
|
FROM ' . ATTACHMENTS_TABLE . ' a, ' . ATTACHMENTS_DESC_TABLE . ' d
|
||||||
|
WHERE a.post_id IN (' . implode(', ', $attach_list) . ')
|
||||||
|
AND a.attach_id = d.attach_id
|
||||||
|
ORDER BY d.filetime ' . ((!$config['display_order']) ? 'ASC' : 'DESC') . ', a.post_id ASC';
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$attachments[$row['post_id']][] = $row;
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
// No attachments exist, but post table thinks they do
|
||||||
|
// so go ahead and reset post_attach flags
|
||||||
|
if (!count($attachments))
|
||||||
|
{
|
||||||
|
$sql = 'UPDATE ' . POSTS_TABLE . '
|
||||||
|
SET post_attachment = 0
|
||||||
|
WHERE post_id IN (' . implode(', ', $attach_list) . ')';
|
||||||
|
$db->sql_query($sql);
|
||||||
|
|
||||||
|
// We need to update the topic indicator too if the
|
||||||
|
// complete topic is now without an attachment
|
||||||
|
if (count($rowset) != $total_posts)
|
||||||
|
{
|
||||||
|
// Not all posts are displayed so we query the db to find if there's any attachment for this topic
|
||||||
|
$sql = 'SELECT a.post_id
|
||||||
|
FROM ' . ATTACHMENTS_TABLE . ' a, ' . POSTS_TABLE . " p
|
||||||
|
WHERE p.topic_id = $topic_id
|
||||||
|
AND p.post_approved = 1
|
||||||
|
AND p.post_id = a.post_id";
|
||||||
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
|
||||||
|
if (!$db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$db->sql_query('UPDATE ' . TOPICS_TABLE . " SET topic_attachment = 0 WHERE topic_id = $topic_id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->sql_query('UPDATE ' . TOPICS_TABLE . " SET topic_attachment = 0 WHERE topic_id = $topic_id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($has_attachments && !$topic_data['topic_attachment'])
|
||||||
|
{
|
||||||
|
// Topic has approved attachments but its flag is wrong
|
||||||
|
$db->sql_query('UPDATE ' . TOPICS_TABLE . " SET topic_attachment = 1 WHERE topic_id = $topic_id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($bbcode_bitfield)
|
||||||
|
{
|
||||||
|
// Instantiate BBCode class
|
||||||
|
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
|
||||||
|
$bbcode = new bbcode($bbcode_bitfield);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($rowset as $row)
|
||||||
|
{
|
||||||
|
$poster_id = $row['user_id'];
|
||||||
|
$poster = ($poster_id == ANONYMOUS) ? ((!empty($row['post_username'])) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'];
|
||||||
|
|
||||||
// Three situations can prevent a post being display:
|
// Three situations can prevent a post being display:
|
||||||
// i) The posters karma is below the minimum of the user
|
// i) The posters karma is below the minimum of the user
|
||||||
// ii) The poster is on the users ignore list
|
// ii) The poster is on the users ignore list
|
||||||
|
@ -552,22 +645,88 @@ if ($row = $db->sql_fetchrow($result))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cache various user specific data ... so we don't have to recompute
|
||||||
// Display the post - Cache this
|
// this each time the same user appears on this page
|
||||||
$poster_posts = ($row['user_id'] != ANONYMOUS) ? $user->lang['POSTS'] . ': ' . $row['user_posts'] : '';
|
if (!isset($user_cache[$poster_id]))
|
||||||
|
|
||||||
|
|
||||||
// Cache this
|
|
||||||
$poster_from = ($row['user_from'] && $row['user_id'] != ANONYMOUS) ? $user->lang['LOCATION'] . ': ' . $row['user_from'] : '';
|
|
||||||
|
|
||||||
|
|
||||||
if (!isset($user_cache[$poster_id]['joined']) && $poster_id != ANONYMOUS)
|
|
||||||
{
|
{
|
||||||
$user_cache[$poster_id]['joined'] = ($row['user_id']) ? $user->lang['JOINED'] . ': ' . $user->format_date($row['user_regdate'], $user->lang['DATE_FORMAT']) : '';
|
if ($poster_id == ANONYMOUS)
|
||||||
|
{
|
||||||
|
$user_cache[$poster_id] = array(
|
||||||
|
'joined' => '',
|
||||||
|
'posts' => '',
|
||||||
|
'from' => '',
|
||||||
|
'avatar' => '',
|
||||||
|
'rank_title' => '',
|
||||||
|
'rank_image' => '',
|
||||||
|
'posts' => '',
|
||||||
|
'profile_img' => '',
|
||||||
|
'profile' => '',
|
||||||
|
'pm_img' => '',
|
||||||
|
'pm' => '',
|
||||||
|
'email_img' => '',
|
||||||
|
'email' => '',
|
||||||
|
'www_img' => '',
|
||||||
|
'www' => '',
|
||||||
|
'icq_status_img'=> '',
|
||||||
|
'icq_img' => '',
|
||||||
|
'icq' => '',
|
||||||
|
'aim_img' => '',
|
||||||
|
'aim' => '',
|
||||||
|
'msn_img' => '',
|
||||||
|
'msn' => '',
|
||||||
|
'search_img' => '',
|
||||||
|
'search' => ''
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$user_sig = ($row['user_sig'] && $config['allow_sig']) ? $row['user_sig'] : '';
|
||||||
|
if ($user_sig && $auth->acl_get('f_sigs', $forum_id))
|
||||||
|
{
|
||||||
|
if (!$auth->acl_get('f_html', $forum_id) && $user->data['user_allowhtml'])
|
||||||
|
{
|
||||||
|
$user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($user_cache[$poster_id]['avatar']))
|
$user_sig = (empty($row['user_allowsmile']) || empty($config['enable_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $user_sig) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $user_sig);
|
||||||
|
|
||||||
|
if (count($censors))
|
||||||
{
|
{
|
||||||
|
$user_sig = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $user_sig . '<'), 1, -1));
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_sig = '<br />_________________<br />' . nl2br($user_sig);
|
||||||
|
}
|
||||||
|
|
||||||
|
$profile_url = "memberlist.$phpEx$SID&mode=viewprofile&u=$poster_id";
|
||||||
|
$pm_url = "ucp.$phpEx$SID&mode=message&action=send&u=$poster_id";
|
||||||
|
$aim_url = "memberlist.$phpEx$SID&mode=contact&action=aim&u=$poster_id";
|
||||||
|
$msn_url = "memberlist.$phpEx$SID&mode=contact&action=msnm&u=$poster_id";
|
||||||
|
$yim_url = 'http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg';
|
||||||
|
$search_url = 'search.' . $phpEx . $SID . '&search_author=' . urlencode($row['username']) .'"&showresults=posts';
|
||||||
|
|
||||||
|
$user_cache[$poster_id] = array(
|
||||||
|
'joined' => $user->lang['JOINED'] . ': ' . $user->format_date($row['user_regdate'], $user->lang['DATE_FORMAT']),
|
||||||
|
'posts' => $user->lang['POSTS'] . ': ' . $row['user_posts'],
|
||||||
|
'from' => ($row['user_from']) ? $user->lang['LOCATION'] . ': ' . $row['user_from'] : '',
|
||||||
|
'sig' => $user_sig,
|
||||||
|
'profile_img' => '<a href="' . $profile_url . '">' . $user->img('btn_profile', $user->lang['READ_PROFILE']) . '</a>',
|
||||||
|
'profile' => '<a href="' . $profile_url . '">' . $user->lang['READ_PROFILE'] . '</a>',
|
||||||
|
'pm_img' => '<a href="' . $pm_url . '">' . $user->img('btn_pm', $user->lang['SEND_PRIVATE_MESSAGE']) . '</a>',
|
||||||
|
'pm' => '<a href="' . $pm_url . '">' . $user->lang['SEND_PRIVATE_MESSAGE'] . '</a>',
|
||||||
|
'www_img' => ($row['user_website']) ? '<a href="' . $row['user_website'] . '" target="_userwww">' . $user->img('btn_www', $user->lang['VISIT_WEBSITE']) . '</a>' : '',
|
||||||
|
'www' => ($row['user_website']) ? '<a href="' . $row['user_website'] . '" target="_userwww">' . $user->lang['VISIT_WEBSITE'] . '</a>' : '',
|
||||||
|
'aim_img' => ($row['user_aim']) ? '<a href="' . $aim_url . '">' . $user->img('btn_aim', $user->lang['AIM']) . '</a>' : '',
|
||||||
|
'aim' => ($row['user_aim']) ? '<a href="' . $aim_url . '">' . $user->lang['AIM'] . '</a>' : '',
|
||||||
|
'msn_img' => ($row['user_msnm']) ? '<a href="' . $msn_url . '">' . $user->img('btn_msnm', $user->lang['MSNM']) . '</a>' : '',
|
||||||
|
'msn' => ($row['user_msnm']) ? '<a href="' . $msn_url . '">' . $user->lang['MSNM'] . '</a>' : '',
|
||||||
|
'yim_img' => ($row['user_yim']) ? '<a href="' . $yim_url . '" target="_contact" onclick="im_popup(\'' . $yim_url . '\', 790, 350)">' . $user->img('btn_yim', $user->lang['YIM']) . '</a>' : '',
|
||||||
|
'yim' => ($row['user_yim']) ? '<a href="' . $yim_url . '" target="_contact" onclick="im_popup(\'' . $yim_url . '\', 790, 350)">' . $user->lang['YIM'] . '</a>' : '',
|
||||||
|
'search_img' => ($auth->acl_get('f_search', $forum_id)) ? '<a href="' . $search_url . '">' . $user->img('btn_search', $user->lang['SEARCH_USER_POSTS']) . '</a>' : '',
|
||||||
|
'search' => ($auth->acl_get('f_search', $forum_id)) ? '<a href="' . $search_url . '">' . $user->lang['SEARCH_USER_POSTS'] . '</a>' : ''
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
if ($row['user_avatar_type'] && $auth->acl_get('u_setavatar'))
|
if ($row['user_avatar_type'] && $auth->acl_get('u_setavatar'))
|
||||||
{
|
{
|
||||||
switch ($row['user_avatar_type'])
|
switch ($row['user_avatar_type'])
|
||||||
|
@ -585,62 +744,30 @@ if ($row = $db->sql_fetchrow($result))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($row['user_rank']))
|
||||||
|
{
|
||||||
|
$user_cache[$poster_id]['rank_title'] = $ranks['special'][$row['user_rank']]['rank_title'];
|
||||||
|
$user_cache[$poster_id]['rank_image'] = (!empty($ranks['special'][$row['user_rank']]['rank_image'])) ? '<img src="' . $ranks['special']['rank_image'] . '" border="0" alt="' . $ranks['special'][$row['user_rank']]['rank_title'] . '" title="' . $ranks['special'][$row['user_rank']]['rank_title'] . '" /><br />' : '';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$user_cache[$poster_id]['avatar'] = '';
|
foreach ($ranks['normal'] as $rank)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Set poster rank
|
|
||||||
if (!isset($user_cache[$poster_id]['rank_title']) && $poster_id != ANONYMOUS)
|
|
||||||
{
|
{
|
||||||
foreach ($ranksrow as $rank)
|
if ($row['user_posts'] >= $rank['rank_min'])
|
||||||
{
|
|
||||||
if (empty($row['user_rank']) && $row['user_posts'] >= $rank['rank_min'])
|
|
||||||
{
|
{
|
||||||
$user_cache[$poster_id]['rank_title'] = $rank['rank_title'];
|
$user_cache[$poster_id]['rank_title'] = $rank['rank_title'];
|
||||||
$user_cache[$poster_id]['rank_image'] = (!empty($rank['rank_image'])) ? '<img src="' . $rank['rank_image'] . '" border="0" alt="' . $user_cache[$poster_id]['rank_title'] . '" title="' . $user_cache[$poster_id]['rank_title'] . '" /><br />' : '';
|
$user_cache[$poster_id]['rank_image'] = (!empty($rank['rank_image'])) ? '<img src="' . $rank['rank_image'] . '" border="0" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" /><br />' : '';
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($rank['rank_special']) && $row['user_rank'] == $rank['rank_id'])
|
|
||||||
{
|
|
||||||
$user_cache[$poster_id]['rank_title'] = $rank['rank_title'];
|
|
||||||
$user_cache[$poster_id]['rank_image'] = (!empty($rank['rank_image'])) ? '<img src="' . $rank['rank_image'] . '" border="0" alt="' . $user_cache[$poster_id]['rank_title'] . '" title="' . $user_cache[$poster_id]['rank_title'] . '" /><br />' : '';
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Handle anon users posting with usernames
|
|
||||||
if ($poster_id == ANONYMOUS && $row['post_username'] != '')
|
|
||||||
{
|
|
||||||
$poster = $row['post_username'];
|
|
||||||
$user_cache[$poster_id]['rank_title'] = $user->lang['GUEST'];
|
|
||||||
$user_cache[$poster_id]['rank_image'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Cache various user specific data ... so we don't have to recompute
|
|
||||||
// this each time the same user appears on this page
|
|
||||||
if (!isset($user_cache[$poster_id]['profile']) && $poster_id != ANONYMOUS)
|
|
||||||
{
|
|
||||||
$temp_url = "memberlist.$phpEx$SID&mode=viewprofile&u=$poster_id";
|
|
||||||
$user_cache[$poster_id]['profile_img'] = '<a href="' . $temp_url . '">' . $user->img('btn_profile', $user->lang['READ_PROFILE']) . '</a>';
|
|
||||||
$user_cache[$poster_id]['profile'] = '<a href="' . $temp_url . '">' . $user->lang['READ_PROFILE'] . '</a>';
|
|
||||||
|
|
||||||
$temp_url = "ucp.$phpEx$SID&mode=message&action=send&u=$poster_id";
|
|
||||||
$user_cache[$poster_id]['pm_img'] = '<a href="' . $temp_url . '">' . $user->img('btn_pm', $user->lang['SEND_PRIVATE_MESSAGE']) . '</a>';
|
|
||||||
$user_cache[$poster_id]['pm'] = '<a href="' . $temp_url . '">' . $user->lang['SEND_PRIVATE_MESSAGE'] . '</a>';
|
|
||||||
|
|
||||||
if (!empty($row['user_viewemail']) || $auth->acl_gets('m_', 'a_', $forum_id))
|
if (!empty($row['user_viewemail']) || $auth->acl_gets('m_', 'a_', $forum_id))
|
||||||
{
|
{
|
||||||
$email_uri = ($config['board_email_form'] && $config['email_enable']) ? "ucp.$phpEx$SID&mode=email&u=" . $poster_id : 'mailto:' . $row['user_email'];
|
$email_url = ($config['board_email_form'] && $config['email_enable']) ? "ucp.$phpEx$SID&mode=email&u=" . $poster_id : 'mailto:' . $row['user_email'];
|
||||||
|
$user_cache[$poster_id]['email_img'] = '<a href="' . $email_url . '">' . $user->img('btn_email', $user->lang['SEND_EMAIL']) . '</a>';
|
||||||
$user_cache[$poster_id]['email_img'] = '<a href="' . $email_uri . '">' . $user->img('btn_email', $user->lang['SEND_EMAIL']) . '</a>';
|
$user_cache[$poster_id]['email'] = '<a href="' . $email_url . '">' . $user->lang['SEND_EMAIL'] . '</a>';
|
||||||
$user_cache[$poster_id]['email'] = '<a href="' . $email_uri . '">' . $user->lang['SEND_EMAIL'] . '</a>';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -648,15 +775,12 @@ if ($row = $db->sql_fetchrow($result))
|
||||||
$user_cache[$poster_id]['email'] = '';
|
$user_cache[$poster_id]['email'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_cache[$poster_id]['www_img'] = ($row['user_website']) ? '<a href="' . $row['user_website'] . '" target="_userwww">' . $user->img('btn_www', $user->lang['VISIT_WEBSITE']) . '</a>' : '';
|
|
||||||
$user_cache[$poster_id]['www'] = ($row['user_website']) ? '<a href="' . $row['user_website'] . '" target="_userwww">' . $user->lang['VISIT_WEBSITE'] . '</a>' : '';
|
|
||||||
|
|
||||||
if (!empty($row['user_icq']))
|
if (!empty($row['user_icq']))
|
||||||
{
|
{
|
||||||
$temp_url = "memberlist.$phpEx$SID&mode=contact&action=icq&u=$poster_id";
|
$icq_url = "memberlist.$phpEx$SID&mode=contact&action=icq&u=$poster_id";
|
||||||
$user_cache[$poster_id]['icq_status_img'] = '<a href="' . $temp_url . '"><img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>';
|
$user_cache[$poster_id]['icq_status_img'] = '<a href="' . $icq_url . '"><img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>';
|
||||||
$user_cache[$poster_id]['icq_img'] = '<a href="' . $temp_url . '">' . $user->img('btn_icq', $user->lang['ICQ']) . '</a>';
|
$user_cache[$poster_id]['icq_img'] = '<a href="' . $icq_url . '">' . $user->img('btn_icq', $user->lang['ICQ']) . '</a>';
|
||||||
$user_cache[$poster_id]['icq'] = '<a href="' . $temp_url . '">' . $user->lang['ICQ'] . '</a>';
|
$user_cache[$poster_id]['icq'] = '<a href="' . $icq_url . '">' . $user->lang['ICQ'] . '</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -664,54 +788,9 @@ if ($row = $db->sql_fetchrow($result))
|
||||||
$user_cache[$poster_id]['icq_img'] = '';
|
$user_cache[$poster_id]['icq_img'] = '';
|
||||||
$user_cache[$poster_id]['icq'] = '';
|
$user_cache[$poster_id]['icq'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$temp_url = "memberlist.$phpEx$SID&mode=contact&action=aim&u=$poster_id";
|
|
||||||
$user_cache[$poster_id]['aim_img'] = ($row['user_aim']) ? '<a href="' . $temp_url . '">' . $user->img('btn_aim', $user->lang['AIM']) . '</a>' : '';
|
|
||||||
$user_cache[$poster_id]['aim'] = ($row['user_aim']) ? '<a href="' . $temp_url . '">' . $user->lang['AIM'] . '</a>' : '';
|
|
||||||
|
|
||||||
$temp_url = "memberlist.$phpEx$SID&mode=contact&action=msnm&u=$poster_id";
|
|
||||||
$user_cache[$poster_id]['msn_img'] = ($row['user_msnm']) ? '<a href="' . $temp_url . '">' . $user->img('btn_msnm', $user->lang['MSNM']) . '</a>' : '';
|
|
||||||
$user_cache[$poster_id]['msn'] = ($row['user_msnm']) ? '<a href="' . $temp_url . '">' . $user->lang['MSNM'] . '</a>' : '';
|
|
||||||
|
|
||||||
$temp_url = 'http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg';
|
|
||||||
$user_cache[$poster_id]['yim_img'] = ($row['user_yim']) ? '<a href="' . $temp_url . '" target="_contact" onclick="im_popup(\'' . $temp_url . '\', 790, 350)">' . $user->img('btn_yim', $user->lang['YIM']) . '</a>' : '';
|
|
||||||
$user_cache[$poster_id]['yim'] = ($row['user_yim']) ? '<a href="' . $temp_url . '" target="_contact" onclick="im_popup(\'' . $temp_url . '\', 790, 350)">' . $user->lang['YIM'] . '</a>' : '';
|
|
||||||
|
|
||||||
if ($auth->acl_get('f_search', $forum_id))
|
|
||||||
{
|
|
||||||
$temp_url = 'search.' . $phpEx . $SID . '&search_author=' . urlencode($row['username']) .'"&showresults=posts';
|
|
||||||
$search_img = '<a href="' . $temp_url . '">' . $user->img('btn_search', $user->lang['SEARCH_USER_POSTS']) . '</a>';
|
|
||||||
$search ='<a href="' . $temp_url . '">' . $user->lang['SEARCH_USER_POSTS'] . '</a>';
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$search_img = '';
|
|
||||||
$search = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
else if (!$poster_id)
|
|
||||||
{
|
|
||||||
$user_cache[$poster_id]['profile_img'] = '';
|
|
||||||
$user_cache[$poster_id]['profile'] = '';
|
|
||||||
$user_cache[$poster_id]['pm_img'] = '';
|
|
||||||
$user_cache[$poster_id]['pm'] = '';
|
|
||||||
$user_cache[$poster_id]['email_img'] = '';
|
|
||||||
$user_cache[$poster_id]['email'] = '';
|
|
||||||
$user_cache[$poster_id]['www_img'] = '';
|
|
||||||
$user_cache[$poster_id]['www'] = '';
|
|
||||||
$user_cache[$poster_id]['icq_status_img'] = '';
|
|
||||||
$user_cache[$poster_id]['icq_img'] = '';
|
|
||||||
$user_cache[$poster_id]['icq'] = '';
|
|
||||||
$user_cache[$poster_id]['aim_img'] = '';
|
|
||||||
$user_cache[$poster_id]['aim'] = '';
|
|
||||||
$user_cache[$poster_id]['msn_img'] = '';
|
|
||||||
$user_cache[$poster_id]['msn'] = '';
|
|
||||||
$user_cache[$poster_id]['search_img'] = '';
|
|
||||||
$user_cache[$poster_id]['search'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Non-user specific images/text
|
// Non-user specific images/text
|
||||||
$temp_url = 'posting.' . $phpEx . $SID . '&mode=quote&p=' . $row['post_id'];
|
$temp_url = 'posting.' . $phpEx . $SID . '&mode=quote&p=' . $row['post_id'];
|
||||||
$quote_img = '<a href="' . $temp_url . '">' . $user->img('btn_quote', $user->lang['REPLY_WITH_QUOTE']) . '</a>';
|
$quote_img = '<a href="' . $temp_url . '">' . $user->img('btn_quote', $user->lang['REPLY_WITH_QUOTE']) . '</a>';
|
||||||
|
@ -741,7 +820,7 @@ if ($row = $db->sql_fetchrow($result))
|
||||||
$ip = '';
|
$ip = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($user->data['user_id'] == $poster_id && $auth->acl_get('f_delete', $forum_id) && $forum_topic_data['topic_last_post_id'] == $row['post_id']) || $auth->acl_get('m_delete', $forum_id))
|
if (($user->data['user_id'] == $poster_id && $auth->acl_get('f_delete', $forum_id) && $topic_data['topic_last_post_id'] == $row['post_id']) || $auth->acl_get('m_delete', $forum_id))
|
||||||
{
|
{
|
||||||
$temp_url = "posting.$phpEx$SID&mode=delete&p=" . $row['post_id'];
|
$temp_url = "posting.$phpEx$SID&mode=delete&p=" . $row['post_id'];
|
||||||
$delpost_img = '<a href="' . $temp_url . '">' . $user->img('btn_delete', $user->lang['DELETE_POST']) . '</a>';
|
$delpost_img = '<a href="' . $temp_url . '">' . $user->img('btn_delete', $user->lang['DELETE_POST']) . '</a>';
|
||||||
|
@ -754,18 +833,9 @@ if ($row = $db->sql_fetchrow($result))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Does post have an attachment? If so, add it to the list
|
|
||||||
if ( ($row['post_attachment']) && ($config['allow_attachments']) && ($auth->acl_get('f_download', $forum_id)) )
|
|
||||||
{
|
|
||||||
$attach_list[] = $row['post_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Parse the message and subject
|
// Parse the message and subject
|
||||||
$post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : '';
|
$post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : '';
|
||||||
$message = $row['post_text'];
|
$message = $row['post_text'];
|
||||||
$bbcode_uid = $row['bbcode_uid'];
|
|
||||||
|
|
||||||
|
|
||||||
// If the board has HTML off but the post has HTML
|
// If the board has HTML off but the post has HTML
|
||||||
// on then we process it, else leave it alone
|
// on then we process it, else leave it alone
|
||||||
|
@ -779,7 +849,10 @@ if ($row = $db->sql_fetchrow($result))
|
||||||
|
|
||||||
|
|
||||||
// Second parse bbcode here
|
// Second parse bbcode here
|
||||||
$bbcode->bbcode_second_pass(&$message, $bbcode_uid, $row['bbcode_bitfield']);
|
if ($row['bbcode_bitfield'])
|
||||||
|
{
|
||||||
|
$bbcode->bbcode_second_pass(&$message, $row['bbcode_uid'], $row['bbcode_bitfield']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// If we allow users to disable display of emoticons
|
// If we allow users to disable display of emoticons
|
||||||
|
@ -820,34 +893,6 @@ if ($row = $db->sql_fetchrow($result))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Signature
|
|
||||||
if (!isset($user_cache[$poster_id]['sig']))
|
|
||||||
{
|
|
||||||
$user_sig = ($row['enable_sig'] && $row['user_sig'] != '' && $config['allow_sig']) ? $row['user_sig'] : '';
|
|
||||||
|
|
||||||
if ($user_sig != '' && $auth->acl_get('f_sigs', $forum_id))
|
|
||||||
{
|
|
||||||
if (!$auth->acl_get('f_html', $forum_id) && $user->data['user_allowhtml'])
|
|
||||||
{
|
|
||||||
$user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig);
|
|
||||||
}
|
|
||||||
|
|
||||||
$user_cache[$poster_id]['sig'] = (empty($row['user_allowsmile']) || empty($config['enable_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $user_cache[$poster_id]['sig']) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $user_cache[$poster_id]['sig']);
|
|
||||||
|
|
||||||
if (count($censors))
|
|
||||||
{
|
|
||||||
$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'] = '<br />_________________<br />' . nl2br($user_cache[$poster_id]['sig']);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$user_cache[$poster_id]['sig'] = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Define the little post icon
|
// Define the little post icon
|
||||||
$mini_post_img = ($row['post_time'] > $user->data['user_lastvisit'] && $row['post_time'] > $topic_last_read) ? $user->img('icon_post_new', $user->lang['New_post']) : $user->img('icon_post', $user->lang['Post']);
|
$mini_post_img = ($row['post_time'] > $user->data['user_lastvisit'] && $row['post_time'] > $topic_last_read) ? $user->img('icon_post_new', $user->lang['New_post']) : $user->img('icon_post', $user->lang['Post']);
|
||||||
|
|
||||||
|
@ -862,14 +907,14 @@ if ($row = $db->sql_fetchrow($result))
|
||||||
'POSTER_RANK' => $user_cache[$poster_id]['rank_title'],
|
'POSTER_RANK' => $user_cache[$poster_id]['rank_title'],
|
||||||
'RANK_IMAGE' => $user_cache[$poster_id]['rank_image'],
|
'RANK_IMAGE' => $user_cache[$poster_id]['rank_image'],
|
||||||
'POSTER_JOINED' => $user_cache[$poster_id]['joined'],
|
'POSTER_JOINED' => $user_cache[$poster_id]['joined'],
|
||||||
'POSTER_POSTS' => $poster_posts,
|
'POSTER_POSTS' => $user_cache[$poster_id]['posts'],
|
||||||
'POSTER_FROM' => $poster_from,
|
'POSTER_FROM' => $user_cache[$poster_id]['from'],
|
||||||
'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'],
|
'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'],
|
||||||
'POST_DATE' => $user->format_date($row['post_time']),
|
'POST_DATE' => $user->format_date($row['post_time']),
|
||||||
|
|
||||||
'POST_SUBJECT' => $post_subject,
|
'POST_SUBJECT' => $post_subject,
|
||||||
'MESSAGE' => $message,
|
'MESSAGE' => $message,
|
||||||
'SIGNATURE' => $user_cache[$poster_id]['sig'],
|
'SIGNATURE' => ($row['enable_sig']) ? $user_cache[$poster_id]['sig'] : '',
|
||||||
'EDITED_MESSAGE'=> $l_edited_by,
|
'EDITED_MESSAGE'=> $l_edited_by,
|
||||||
|
|
||||||
'RATING' => $rating,
|
'RATING' => $rating,
|
||||||
|
@ -1027,18 +1072,18 @@ if ($row = $db->sql_fetchrow($result))
|
||||||
// NOTE: If you want to use the download.php everytime an image is displayed inlined, replace the
|
// NOTE: If you want to use the download.php everytime an image is displayed inlined, replace the
|
||||||
// Section between BEGIN and END with (Without the // of course):
|
// Section between BEGIN and END with (Without the // of course):
|
||||||
// $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'];
|
// $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'];
|
||||||
// $linked_image = TRUE;
|
// $download_link = TRUE;
|
||||||
//
|
//
|
||||||
// BEGIN
|
// BEGIN
|
||||||
if ((intval($config['ftp_upload'])) && (trim($config['upload_dir']) == ''))
|
if ((intval($config['ftp_upload'])) && (trim($config['upload_dir']) == ''))
|
||||||
{
|
{
|
||||||
$img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'];
|
$img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'];
|
||||||
$linked_image = TRUE;
|
$download_link = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$img_source = $filename;
|
$img_source = $filename;
|
||||||
$linked_image = FALSE;
|
$download_link = FALSE;
|
||||||
}
|
}
|
||||||
// END
|
// END
|
||||||
|
|
||||||
|
@ -1046,9 +1091,9 @@ if ($row = $db->sql_fetchrow($result))
|
||||||
$download_link = $img_source;
|
$download_link = $img_source;
|
||||||
|
|
||||||
// Directly Viewed Image ... update the download count
|
// Directly Viewed Image ... update the download count
|
||||||
if (!$linked_image)
|
if (!$download_link)
|
||||||
{
|
{
|
||||||
$update_count = TRUE;
|
$update_count = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1132,48 +1177,33 @@ if ($row = $db->sql_fetchrow($result))
|
||||||
$template->assign_block_vars('postrow.attachment', $template_array);
|
$template->assign_block_vars('postrow.attachment', $template_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: rather store attach_id in an array then update all download counts at once, outside of the loop -- Ashe
|
||||||
if ($update_count)
|
if ($update_count)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE " . ATTACHMENTS_DESC_TABLE . "
|
$sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . '
|
||||||
SET download_count = download_count + 1
|
SET download_count = download_count + 1
|
||||||
WHERE attach_id = " . $attachment['attach_id'];
|
WHERE attach_id = ' . $attachment['attach_id'];
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
while ($row = $db->sql_fetchrow($result));
|
|
||||||
|
|
||||||
unset($user_cache);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
trigger_error($user->lang['NO_TOPIC']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// No attachments exist, but post table thinks they do
|
|
||||||
// so go ahead and reset post_attach flags
|
|
||||||
if ( (sizeof($attach_list)) && (count($attachments) == 0) )
|
|
||||||
{
|
|
||||||
$sql = "UPDATE " . POSTS_TABLE . "
|
|
||||||
SET post_attachment = 0
|
|
||||||
WHERE post_id IN (" . implode(', ', $attach_list) . ")";
|
|
||||||
$db->sql_query($sql);
|
|
||||||
|
|
||||||
// We need to update the topic indicator too if the
|
|
||||||
// complete topic is now without an attachment
|
|
||||||
}
|
}
|
||||||
|
unset($rowset);
|
||||||
|
unset($user_cache);
|
||||||
|
|
||||||
// Mark topics read
|
// Mark topics read
|
||||||
markread('topic', $forum_id, $topic_id, $forum_topic_data['topic_last_post_id']);
|
markread('topic', $forum_id, $topic_id, $topic_data['topic_last_post_id']);
|
||||||
|
|
||||||
|
|
||||||
// Update the topic view counter
|
// Update the topic view counter, excepted when the user was already reading it
|
||||||
$sql = "UPDATE " . TOPICS_TABLE . "
|
if (!preg_match("/&t=$topic_id\\b/", $user->data['session_page'] . ' '))
|
||||||
|
{
|
||||||
|
$sql = "UPDATE " . TOPICS_TABLE . "
|
||||||
SET topic_views = topic_views + 1
|
SET topic_views = topic_views + 1
|
||||||
WHERE topic_id = $topic_id";
|
WHERE topic_id = $topic_id";
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Mozilla navigation bar
|
// Mozilla navigation bar
|
||||||
|
|
Loading…
Add table
Reference in a new issue