- birthdays/age in user's timezone and not server's local time

- parse bbcode in posts with fewer characters than selected maximum on search results page
- retrieve search word context in posts which are longer than maximum characters (no raw BBCode anymore)
- formatted text is processed in the same order everywhere now: censor_text, replace newlines, bbcode, smileys, attachments, highlighting [including Bug #2048]
- highlighting pattern updated to exclude style and script (e.g custom BBCode) [Bug #3856]
- fixed a style problem in Opera [Bug #3770]
- performance increase for user::img()
- slight adjustments to search


git-svn-id: file:///svn/phpbb/trunk@6321 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Nils Adermann 2006-08-28 17:20:21 +00:00
parent 1d37b69ddd
commit c0a880b665
16 changed files with 293 additions and 71 deletions

View file

@ -258,7 +258,7 @@ span.corners-top span, span.corners-bottom span {
border-top: 1px solid #FFFFFF;
}
#menu li a:hover span, #menu li#activemenu span {
#menu li a:hover span, #menu li#activemenu span, #menu li a:hover {
text-decoration: none;
background-color: #FFA34F;
color: #FFFFFF;

View file

@ -2014,6 +2014,117 @@ function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_po
return $bump_time;
}
/**
* Generates a text with approx. the specified length which contains the specified words and their context
*
* @param string $text The full text from which context shall be extracted
* @param string $words An array of words which should be contained in the result, * is allowed as a wildcard
* @param int $length The desired length of the resulting text, however the result might be shorter or longer than this value
*
* @return string Context of the specified words seperated by "..."
*/
function get_context($text, $words, $length = 400)
{
// first replace all whitespaces with single spaces
$text = preg_replace('/\s+/', ' ', $text);
$word_indizes = array();
if (sizeof($words))
{
$match = '';
// find the starting indizes of all words
foreach ($words as $word)
{
if (preg_match('#(?: |^)(' . str_replace('\*', '\w*?', preg_quote($word, '#')) . ')(?: |$)#i', $text, $match))
{
$pos = strpos($text, $match[1]);
if ($pos !== false)
{
$word_indizes[] = $pos;
}
}
}
unset($match);
if (sizeof($word_indizes))
{
$word_indizes = array_unique($word_indizes);
sort($word_indizes);
$wordnum = sizeof($word_indizes);
// number of characters on the right and left side of each word
$sequence_length = (int) ($length / (2 * $wordnum)) - 2;
$final_text = '';
$word = $j = 0;
$final_text_index = -1;
// cycle through every character in the original text
for ($i = $word_indizes[$word], $n = strlen($text); $i < $n; $i++)
{
// if the current position is the start of one of the words then append $sequence_length characters to the final text
if (isset($word_indizes[$word]) && ($i == $word_indizes[$word]))
{
if ($final_text_index < $i - $sequence_length - 1)
{
$final_text .= '... ' . preg_replace('#^([^ ]*)#', '', substr($text, $i - $sequence_length, $sequence_length));
}
else
{
// if the final text is already nearer to the current word than $sequence_length we only append the text
// from its current index on and distribute the unused length to all other sequenes
$sequence_length += (int) (($final_text_index - $i + $sequence_length + 1) / (2 * $wordnum));
$final_text .= substr($text, $final_text_index + 1, $i - $final_text_index - 1);
}
$final_text_index = $i - 1;
// add the following characters to the final text (see below)
$word++;
$j = 1;
}
if ($j > 0)
{
// add the character to the final text and increment the sequence counter
$final_text .= $text[$i];
$final_text_index++;
$j++;
// if this is a whitespace then check whether we are done with this sequence
if ($text[$i] == ' ')
{
// only check whether we have to exit the context generation completely if we haven't already reached the end anyway
if ($i + 4 < $n)
{
if (($j > $sequence_length && $word >= $wordnum) || strlen($final_text) > $length)
{
$final_text .= ' ...';
break;
}
}
else
{
// make sure the text really reaches the end
$j -= 4;
}
// stop context generation and wait for the next word
if ($j > $sequence_length)
{
$j = 0;
}
}
}
}
return $final_text;
}
}
if (!sizeof($words) || !sizeof($word_indizes))
{
return (strlen($text) >= $length + 3) ? substr($text, 0, $length) . '...' : $text;
}
}
/**
* Decode text whereby text is coming from the db and expected to be pre-parsed content
* We are placing this outside of the message parser because we are often in need of it...
@ -2052,6 +2163,33 @@ function decode_message(&$message, $bbcode_uid = '')
return;
}
/**
* Strips all bbcode from a text and returns the plain content
*/
function strip_bbcode(&$text, $uid = '')
{
if (!$uid)
{
$uid = '[0-9a-z]{5,}';
}
$text = preg_replace("#\[\/?[a-z0-9\*\+\-]+(?:=.*?)?(?::[a-z])?(\:?$uid)\]#", ' ', $text);
$match = array(
'#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#',
'#<!\-\- m \-\-><a href="(.*?)" target="_blank">.*?</a><!\-\- m \-\->#',
'#<!\-\- w \-\-><a href="http:\/\/(.*?)" target="_blank">.*?</a><!\-\- w \-\->#',
'#<!\-\- l \-\-><a href="(.*?)">.*?</a><!\-\- l \-\->#',
'#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/.*? \/><!\-\- s\1 \-\->#',
'#<!\-\- .*? \-\->#s',
'#<.*?>#s'
);
$replace = array('\1', '\1', '\1', '\1', '\1', '', '');
$text = preg_replace($match, $replace, $text);
}
/**
* For display of custom parsed text on user-facing pages
* Expects $text to be the value directly from the database (stored value)
@ -2065,6 +2203,8 @@ function generate_text_for_display($text, $uid, $bitfield, $flags)
return '';
}
$text = str_replace("\n", '<br />', censor_text($text));
// Parse bbcode if bbcode uid stored and bbcode enabled
if ($uid && ($flags & 1))
{
@ -2074,7 +2214,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags)
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
}
if (empty($__bbcode))
if (empty($bbcode))
{
$bbcode = new bbcode($bitfield);
}
@ -2087,7 +2227,6 @@ function generate_text_for_display($text, $uid, $bitfield, $flags)
}
$text = smiley_text($text, !($flags & 2));
$text = str_replace("\n", '<br />', censor_text($text));
return $text;
}

View file

@ -873,6 +873,8 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
$post_subject = $row['post_subject'];
$message = $row['post_text'];
$message = censor_text($message);
$message = str_replace("\n", '<br />', $message);
$decoded_message = false;
if ($show_quote_button && $auth->acl_get('f_reply', $forum_id))
@ -892,14 +894,13 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
$message = smiley_text($message, !$row['enable_smilies']);
$post_subject = censor_text($post_subject);
$message = censor_text($message);
$template->assign_block_vars($mode . '_row', array(
'POSTER_NAME' => $poster,
'POST_SUBJECT' => $post_subject,
'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']),
'POST_DATE' => $user->format_date($row['post_time']),
'MESSAGE' => str_replace("\n", '<br />', $message),
'MESSAGE' => $message,
'DECODED_MESSAGE' => $decoded_message,
'U_POST_ID' => $row['post_id'],

View file

@ -95,6 +95,7 @@ function mcp_post_details($id, $mode, $action)
// Process message, leave it uncensored
$message = $post_info['post_text'];
$message = str_replace("\n", '<br />', $message);
if ($post_info['bbcode_bitfield'])
{
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
@ -102,7 +103,6 @@ function mcp_post_details($id, $mode, $action)
$bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
}
$message = smiley_text($message);
$message = str_replace("\n", '<br />', $message);
$template->assign_vars(array(
'U_MCP_ACTION' => "$url&amp;i=main&amp;quickmod=1", // Use this for mode paramaters

View file

@ -109,6 +109,7 @@ class mcp_queue
// Process message, leave it uncensored
$message = $post_info['post_text'];
$message = str_replace("\n", '<br />', $message);
if ($post_info['bbcode_bitfield'])
{
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);

View file

@ -117,6 +117,7 @@ class mcp_reports
// Process message, leave it uncensored
$message = $post_info['post_text'];
$message = str_replace("\n", '<br />', $message);
if ($post_info['bbcode_bitfield'])
{
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);

View file

@ -110,6 +110,7 @@ function mcp_topic_view($id, $mode, $action)
$message = $row['post_text'];
$post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : $topic_info['topic_title'];
$message = str_replace("\n", '<br />', $message);
if ($row['bbcode_bitfield'])
{
@ -117,7 +118,6 @@ function mcp_topic_view($id, $mode, $action)
}
$message = smiley_text($message);
$message = str_replace("\n", '<br />', $message);
if (!$row['post_approved'])
{

View file

@ -247,6 +247,7 @@ function mcp_warn_post_view($id, $mode, $action)
// We want to make the message available here as a reminder
// Parse the message and subject
$message = $userrow['post_text'];
$message = str_replace("\n", '<br />', censor_text($message));
// Second parse bbcode here
if ($userrow['bbcode_bitfield'])
@ -260,9 +261,6 @@ function mcp_warn_post_view($id, $mode, $action)
// Always process smilies after parsing bbcodes
$message = smiley_text($message);
// Replace naughty words such as farty pants
$message = str_replace("\n", '<br />', censor_text($message));
// Generate the appropriate user information for the user we are looking at
$rank_title = $rank_img = '';
// get_user_rank($userrow['user_rank'], $userrow['user_posts'], $rank_title, $rank_img);

View file

@ -119,6 +119,15 @@ class fulltext_native extends search_backend
// remove some useless bracket combinations which might be created by the previous regexps
$keywords = str_replace(array('()', ')|('), array('', '|'), $keywords);
$keywords = preg_replace_callback(
'#\((?:(?:[^)]*?) )*?[^)]*?\)#',
create_function(
'$matches',
'return str_replace(" ", "|", $matches[0]);'
),
$keywords
);
// $keywords input format: each word seperated by a space, words in a bracket are not seperated
// the user wants to search for any word, convert the search query
@ -187,7 +196,7 @@ class fulltext_native extends search_backend
// a group of which at least one may not be in the resulting posts
if ($word[0] == '(')
{
$word = explode('|', substr($word, 1, -1));
$word = array_unique(explode('|', substr($word, 1, -1)));
$mode = 'must_exclude_one';
}
// one word which should not be in the resulting posts
@ -209,7 +218,7 @@ class fulltext_native extends search_backend
// a group of words of which at least one word should be in every resulting post
if ($word[0] == '(')
{
$word = explode('|', substr($word, 1, -1));
$word = array_unique(explode('|', substr($word, 1, -1)));
}
$ignore_no_id = false;
$mode = 'must_contain';
@ -880,7 +889,7 @@ class fulltext_native extends search_backend
// Do not index code
$match[] = '#\[code(?:=.*?)?(\:?[0-9a-z]{5,})\].*?\[\/code(\:?[0-9a-z]{5,})\]#is';
// BBcode
$match[] = '#\[\/?[a-z\*\+\-]+(?:=.*?)?(\:?[0-9a-z]{5,})\]#';
$match[] = '#\[\/?[a-z0-9\*\+\-]+(?:=.*?)?(?::[a-z])?(\:?[0-9a-z]{5,})\]#';
$min = $config['fulltext_native_min_chars'];
$max = $config['fulltext_native_max_chars'];
@ -890,7 +899,7 @@ class fulltext_native extends search_backend
/**
* Clean up the string, remove HTML tags, remove BBCodes
*/
$word = strtok($this->cleanup(preg_replace($match, ' ', strip_tags($text)), '', $user->lang['ENCODING']), ' ');
$word = strtok($this->cleanup(preg_replace($match, ' ', strip_tags($text)), -1, $user->lang['ENCODING']), ' ');
while (isset($word[0]))
{
@ -1146,14 +1155,14 @@ class fulltext_native extends search_backend
$destroy_cache_words = array();
// Remove common (> 60% of posts ) words
// Remove common (> 20% of posts ) words
if ($config['num_posts'] >= 100)
{
// First, get the IDs of common words
$sql = 'SELECT word_id
FROM ' . SEARCH_WORDMATCH_TABLE . '
GROUP BY word_id
HAVING COUNT(word_id) > ' . floor($config['num_posts'] * 0.6);
HAVING COUNT(word_id) > ' . floor($config['num_posts'] * 0.2);
$result = $db->sql_query($sql);
$sql_in = array();

View file

@ -1340,13 +1340,15 @@ class user extends session
static $imgs;
global $phpbb_root_path;
if (empty($imgs[$img . $suffix]) || $width !== false)
$img_data = $imgs[$img . $suffix];
if (empty($img_data) || $width !== false)
{
if (!isset($this->theme[$img]) || !$this->theme[$img])
{
// Do not fill the image to let designers decide what to do if the image is empty
$imgs[$img . $suffix] = '';
return $imgs[$img . $suffix];
$img_data = '';
return $img_data;
}
// Do not include dimensions?
@ -1372,9 +1374,9 @@ class user extends session
$imgsrc = str_replace('{SUFFIX}', $suffix, $imgsrc);
}
$imgs[$img . $suffix]['src'] = $phpbb_root_path . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . str_replace('{LANG}', $this->img_lang, $imgsrc);
$imgs[$img . $suffix]['width'] = $width;
$imgs[$img . $suffix]['height'] = $height;
$img_data['src'] = $phpbb_root_path . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . str_replace('{LANG}', $this->img_lang, $imgsrc);
$img_data['width'] = $width;
$img_data['height'] = $height;
}
$alt = (!empty($this->lang[$alt])) ? $this->lang[$alt] : $alt;
@ -1382,19 +1384,19 @@ class user extends session
switch ($type)
{
case 'src':
return $imgs[$img . $suffix]['src'];
return $img_data['src'];
break;
case 'width':
return $imgs[$img . $suffix]['width'];
return $img_data['width'];
break;
case 'height':
return $imgs[$img . $suffix]['height'];
return $img_data['height'];
break;
default:
return '<img src="' . $imgs[$img . $suffix]['src'] . '"' . (($imgs[$img . $suffix]['width']) ? ' width="' . $imgs[$img . $suffix]['width'] . '"' : '') . (($imgs[$img . $suffix]['height']) ? ' height="' . $imgs[$img . $suffix]['height'] . '"' : '') . ' alt="' . $alt . '" title="' . $alt . '" />';
return '<img src="' . $img_data['src'] . '"' . (($img_data['width']) ? ' width="' . $img_data['width'] . '"' : '') . (($img_data['height']) ? ' height="' . $img_data['height'] . '"' : '') . ' alt="' . $alt . '" title="' . $alt . '" />';
break;
}
}

View file

@ -54,6 +54,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
// Parse the message and subject
$message = $message_row['message_text'];
$message = str_replace("\n", '<br />', censor_text($message));
// Second parse bbcode here
if ($message_row['bbcode_bitfield'])
@ -66,7 +67,6 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
// Replace naughty words such as farty pants
$message_row['message_subject'] = censor_text($message_row['message_subject']);
$message = str_replace("\n", '<br />', censor_text($message));
// Editing information
if ($message_row['message_edit_count'] && $config['display_last_edited'])
@ -146,6 +146,9 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
// End signature parsing, only if needed
if ($signature)
{
$signature = censor_text($signature);
$signature = str_replace("\n", '<br />', censor_text($signature));
if ($user_info['user_sig_bbcode_bitfield'])
{
if ($bbcode === false)
@ -158,7 +161,6 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
}
$signature = smiley_text($signature);
$signature = str_replace("\n", '<br />', censor_text($signature));
}
$url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm');
@ -318,6 +320,9 @@ function message_history($msg_id, $user_id, $message_row, $folder)
$subject = $row['message_subject'];
$message = $row['message_text'];
$message = censor_text($message);
$message = str_replace("\n", '<br />', $message)
if ($row['bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
@ -326,7 +331,6 @@ function message_history($msg_id, $user_id, $message_row, $folder)
$message = smiley_text($message, !$row['enable_smilies']);
$subject = censor_text($subject);
$message = censor_text($message);
if ($id == $msg_id)
{
@ -339,7 +343,7 @@ function message_history($msg_id, $user_id, $message_row, $folder)
'AUTHOR_NAME' => $author,
'SUBJECT' => $subject,
'SENT_DATE' => $user->format_date($row['message_time']),
'MESSAGE' => str_replace("\n", '<br />', $message),
'MESSAGE' => $message,
'FOLDER' => implode(', ', $row['folder']),
'S_CURRENT_MSG' => ($row['msg_id'] == $msg_id),

View file

@ -54,7 +54,7 @@ $db->sql_freeresult($result);
$birthday_list = '';
if ($config['load_birthdays'])
{
$now = getdate();
$now = getdate(time() + $this->timezone + $this->dst);
$sql = 'SELECT user_id, username, user_colour, user_birthday
FROM ' . USERS_TABLE . "
WHERE user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'

View file

@ -38,7 +38,7 @@ $lang = array_merge($lang, array(
'FOUND_SEARCH_MATCHES' => 'Search found %d matches',
'FOUND_MORE_SEARCH_MATCHES' => 'Search found more than %d matches',
'GLOBAL' => 'Global topic',
'GLOBAL' => 'Global announcement',
'IGNORED_TERMS' => 'ignored',
'IGNORED_TERMS_EXPLAIN' => 'The following words in your search query were ignored: <b>%s</b>',

View file

@ -396,16 +396,20 @@ switch ($mode)
$posts_per_day = $member['user_posts'] / $memberdays;
$percentage = ($config['num_posts']) ? min(100, ($member['user_posts'] / $config['num_posts']) * 100) : 0;
if ($member['user_sig_bbcode_bitfield'] && $member['user_sig'])
{
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
$bbcode = new bbcode();
$bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
}
if ($member['user_sig'])
{
$member['user_sig'] = censor_text(smiley_text($member['user_sig']));
$member['user_sig'] = censor_text($member['user_sig']);
$member['user_sig'] = str_replace("\n", '<br />', $member['user_sig']);
if ($member['user_sig_bbcode_bitfield'])
{
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
$bbcode = new bbcode();
$bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
}
$member['user_sig'] = smiley_text($member['user_sig']);
}
$poster_avatar = '';
@ -459,7 +463,7 @@ switch ($mode)
'OCCUPATION' => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '',
'INTERESTS' => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '',
'SIGNATURE' => (!empty($member['user_sig'])) ? str_replace("\n", '<br />', $member['user_sig']) : '',
'SIGNATURE' => $member['user_sig'],
'AVATAR_IMG' => $poster_avatar,
'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
@ -1329,19 +1333,19 @@ function show_profile($data)
if ($bday_year)
{
$time = time() + $user->timezone + $user->dst;
$now = getdate(time() + $user->timezone + $user->dst);
$diff = date('n', $time) - $bday_month;
$diff = $now['mon'] - $bday_month;
if ($diff == 0)
{
$diff = (date('j', $time) - $bday_day < 0) ? 1 : 0;
$diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
}
else
{
$diff = ($diff < 0) ? 1 : 0;
}
$age = (int) (date('Y', $time) - $bday_year - $diff);
$age = (int) ($now['year'] - $bday_year - $diff);
}
}

View file

@ -47,11 +47,6 @@ $sort_dir = request_var('sd', 'd');
$return_chars = request_var('ch', ($topic_id) ? -1 : 200);
$search_forum = request_var('fid', array(0));
if ($search_forum == array(0))
{
$search_forum = array();
}
// Is user able to search? Has search been disabled?
if (!$auth->acl_get('u_search') || !$auth->acl_getf_global('f_search') || !$config['load_search'])
{
@ -609,11 +604,55 @@ if ($keywords || $author || $author_id || $search_id || $submit)
}
else
{
$bbcode_bitfield = '';
$attach_list = array();
while ($row = $db->sql_fetchrow($result))
{
$rowset[] = $row;
if (($return_chars == -1) || (strlen($row['post_text']) < $return_chars + 3))
{
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
// Does this post have an attachment? If so, add it to the list
if ($row['post_attachment'] && $config['allow_attachments'])
{
$attach_list[] = $row['post_id'];
}
}
}
$db->sql_freeresult($result);
// Instantiate BBCode if needed
if ($bbcode_bitfield !== '')
{
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}
// Pull attachment data
if (sizeof($attach_list))
{
if ($auth->acl_gets('f_download', 'u_download', $forum_id))
{
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '
AND in_message = 0
ORDER BY filetime ' . ((!$config['display_order']) ? 'DESC' : 'ASC') . ', post_msg_id ASC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$attachments[$row['post_msg_id']][] = $row;
}
$db->sql_freeresult($result);
}
else
{
$display_notice = true;
}
}
}
if ($hilit)
@ -727,28 +766,53 @@ if ($keywords || $author || $author_id || $search_id || $submit)
continue;
}
decode_message($row['post_text'], $row['bbcode_uid']);
if ($return_chars != -1)
{
$row['post_text'] = (strlen($row['post_text']) < $return_chars + 3) ? $row['post_text'] : substr($row['post_text'], 0, $return_chars) . '...';
}
// Replace naughty words such as farty pants
$row['post_subject'] = censor_text($row['post_subject']);
$row['post_text'] = str_replace("\n", '<br />', censor_text($row['post_text']));
$message = $row['post_text'];
if (($return_chars != -1) && (strlen($message) >= $return_chars + 3))
{
$message = censor_text($message);
strip_bbcode($message, $row['bbcode_uid']);
// now find context for the searched words
$message = get_context($message, array_filter(explode('|', $hilit), 'strlen'), $return_chars);
$message = str_replace("\n", '<br />', $message);
}
else
{
$message = censor_text($message);
$message = str_replace("\n", '<br />', $message);
// Second parse bbcode here
if ($row['bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
}
if (isset($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]))
{
parse_inline_attachments($message, $attachments[$row['post_id']], $update_count, $forum_id);
// we only display inline attachments
unset($attachments[$row['post_id']]);
}
// Always process smilies after parsing bbcodes
$message = smiley_text($message);
}
// post highlighting
$row['post_text'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*>)#i', '<span class="posthilit">$1</span>', $row['post_text']);
$row['post_text'] = smiley_text($row['post_text']);
$message = preg_replace('#(?!(?:<(?:s(?:cript|tyle))?)[^<]*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $message);
$tpl_ary = array(
'POSTER_NAME' => ($row['poster_id'] == ANONYMOUS) ? ((!empty($row['post_username'])) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'],
'U_PROFILE' => ($row['poster_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u=' . $row['poster_id']) : '',
'POST_SUBJECT' => $row['post_subject'],
'POST_DATE' => (!empty($row['post_time'])) ? $user->format_date($row['post_time']) : '',
'MESSAGE' => $row['post_text']
'MESSAGE' => $message
);
}

View file

@ -717,6 +717,7 @@ if (!empty($topic_data['poll_start']))
for ($i = 0, $size = sizeof($poll_info); $i < $size; $i++)
{
$poll_info[$i]['poll_option_text'] = censor_text($poll_info[$i]['poll_option_text']);
$poll_info[$i]['poll_option_text'] = str_replace("\n", '<br />', $poll_info[$i]['poll_option_text']);
if ($poll_bbcode !== false)
{
@ -724,17 +725,16 @@ if (!empty($topic_data['poll_start']))
}
$poll_info[$i]['poll_option_text'] = smiley_text($poll_info[$i]['poll_option_text']);
$poll_info[$i]['poll_option_text'] = str_replace("\n", '<br />', $poll_info[$i]['poll_option_text']);
}
$topic_data['poll_title'] = censor_text($topic_data['poll_title']);
$topic_data['poll_title'] = str_replace("\n", '<br />', $topic_data['poll_title']);
if ($poll_bbcode !== false)
{
$poll_bbcode->bbcode_second_pass($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield']);
}
$topic_data['poll_title'] = smiley_text($topic_data['poll_title']);
$topic_data['poll_title'] = str_replace("\n", '<br />', $topic_data['poll_title']);
unset($poll_bbcode);
@ -862,8 +862,7 @@ $sql = $db->sql_build_query('SELECT', array(
$result = $db->sql_query($sql);
$today = explode('-', date('j-n-Y', time() + $user->timezone + $user->dst));
$today = array('day' => (int) $today[0], 'month' => (int) $today[1], 'year' => (int) $today[2]);
$now = getdate(time() + $user->timezone + $user->dst);
// Posts are stored in the $rowset array while $attach_list, $user_cache
// and the global bbcode_bitfield are built
@ -1087,17 +1086,17 @@ while ($row = $db->sql_fetchrow($result))
if ($bday_year)
{
$diff = $today['month'] - $bday_month;
$diff = $now['mon'] - $bday_month;
if ($diff == 0)
{
$diff = ($today['day'] - $bday_day < 0) ? 1 : 0;
$diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
}
else
{
$diff = ($diff < 0) ? 1 : 0;
}
$user_cache[$poster_id]['age'] = (int) ($today['year'] - $bday_year - $diff);
$user_cache[$poster_id]['age'] = (int) ($now['year'] - $bday_year - $diff);
}
}
}
@ -1248,6 +1247,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
if ($user_cache[$poster_id]['sig'] && empty($user_cache[$poster_id]['sig_parsed']))
{
$user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']);
$user_cache[$poster_id]['sig'] = str_replace("\n", '<br />', $user_cache[$poster_id]['sig']);
if ($user_cache[$poster_id]['sig_bbcode_bitfield'])
{
@ -1255,12 +1255,12 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
}
$user_cache[$poster_id]['sig'] = smiley_text($user_cache[$poster_id]['sig']);
$user_cache[$poster_id]['sig'] = str_replace("\n", '<br />', $user_cache[$poster_id]['sig']);
$user_cache[$poster_id]['sig_parsed'] = true;
}
// Parse the message and subject
$message = censor_text($row['post_text']);
$message = str_replace("\n", '<br />', $message);
// Second parse bbcode here
if ($row['bbcode_bitfield'])
@ -1285,12 +1285,11 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
// Highlight active words (primarily for search)
if ($highlight_match)
{
$message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*>)#i', '<span class="posthilit">\1</span>', $message);
$message = preg_replace('#(?!(?:<(?:s(?:cript|tyle))?)[^<]*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\1</span>', $message);
}
// Replace naughty words such as farty pants
$row['post_subject'] = censor_text($row['post_subject']);
$message = str_replace("\n", '<br />', $message);
// Editing information
if (($row['post_edit_count'] && $config['display_last_edited']) || $row['post_edit_reason'])