aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/search.php
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2006-08-28 17:20:21 +0000
committerNils Adermann <naderman@naderman.de>2006-08-28 17:20:21 +0000
commitc0a880b6652d330b760b7da7cdde8076f854d836 (patch)
treee83ab0835afa5660ff8f582535a25c2a1c1f0f69 /phpBB/search.php
parent1d37b69ddd79d9d6bc1346f3761a899d20305636 (diff)
downloadforums-c0a880b6652d330b760b7da7cdde8076f854d836.tar
forums-c0a880b6652d330b760b7da7cdde8076f854d836.tar.gz
forums-c0a880b6652d330b760b7da7cdde8076f854d836.tar.bz2
forums-c0a880b6652d330b760b7da7cdde8076f854d836.tar.xz
forums-c0a880b6652d330b760b7da7cdde8076f854d836.zip
- 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
Diffstat (limited to 'phpBB/search.php')
-rw-r--r--phpBB/search.php94
1 files changed, 79 insertions, 15 deletions
diff --git a/phpBB/search.php b/phpBB/search.php
index 6fa500d761..e949cf3ce4 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -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']);
+ // Replace naughty words such as farty pants
+ $row['post_subject'] = censor_text($row['post_subject']);
+ $message = $row['post_text'];
+
- if ($return_chars != -1)
+ if (($return_chars != -1) && (strlen($message) >= $return_chars + 3))
{
- $row['post_text'] = (strlen($row['post_text']) < $return_chars + 3) ? $row['post_text'] : substr($row['post_text'], 0, $return_chars) . '...';
+ $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);
- // 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']));
+ // Second parse bbcode here
+ if ($row['bbcode_bitfield'])
+ {
+ $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
+ }
- // post highlighting
- $row['post_text'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*>)#i', '<span class="posthilit">$1</span>', $row['post_text']);
+ 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']]);
+ }
- $row['post_text'] = smiley_text($row['post_text']);
+ // Always process smilies after parsing bbcodes
+ $message = smiley_text($message);
+ }
+
+ // post highlighting
+ $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
);
}