aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/search.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2009-07-02 10:28:32 +0000
committerJoas Schilling <nickvergessen@gmx.de>2009-07-02 10:28:32 +0000
commit2854705096a5029295ab99fa9fcf063661fc2cbc (patch)
tree5cc8549b1aaf4574b9a4cb4b05e829aae6077832 /phpBB/search.php
parent89d87a21823494069bf7d34f450985e0e705abeb (diff)
downloadforums-2854705096a5029295ab99fa9fcf063661fc2cbc.tar
forums-2854705096a5029295ab99fa9fcf063661fc2cbc.tar.gz
forums-2854705096a5029295ab99fa9fcf063661fc2cbc.tar.bz2
forums-2854705096a5029295ab99fa9fcf063661fc2cbc.tar.xz
forums-2854705096a5029295ab99fa9fcf063661fc2cbc.zip
Fix bug #36565 - Search by authorname does not display posts of guests and deleted users
Authorised by: naderman git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9713 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/search.php')
-rw-r--r--phpBB/search.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/phpBB/search.php b/phpBB/search.php
index 5e2a7c2836..c7c1d47257 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -97,6 +97,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
// If we are looking for authors get their ids
$author_id_ary = array();
+ $sql_author_match = '';
if ($author_id)
{
$author_id_ary[] = $author_id;
@@ -122,6 +123,22 @@ if ($keywords || $author || $author_id || $search_id || $submit)
}
$db->sql_freeresult($result);
+ $sql_where = (strpos($author, '*') !== false) ? ' post_username ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " post_username = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
+
+ $sql = 'SELECT 1 as guest_post
+ FROM ' . POSTS_TABLE . "
+ WHERE $sql_where
+ AND poster_id = " . ANONYMOUS;
+ $result = $db->sql_query_limit($sql, 1);
+ $found_guest_post = $db->sql_fetchfield('guest_post');
+ $db->sql_freeresult($result);
+
+ if ($found_guest_post)
+ {
+ $author_id_ary[] = ANONYMOUS;
+ $sql_author_match = (strpos($author, '*') !== false) ? ' ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
+ }
+
if (!sizeof($author_id_ary))
{
trigger_error('NO_SEARCH_RESULTS');
@@ -435,12 +452,12 @@ if ($keywords || $author || $author_id || $search_id || $submit)
if (!empty($search->search_query))
{
- $total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $id_ary, $start, $per_page);
+ $total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);
}
else if (sizeof($author_id_ary))
{
$firstpost_only = ($search_fields === 'firstpost' || $search_fields == 'titleonly') ? true : false;
- $total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $id_ary, $start, $per_page);
+ $total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);
}
// For some searches we need to print out the "no results" page directly to allow re-sorting/refining the search options.