diff --git a/phpBB/install/schemas/mysql_schema.sql b/phpBB/install/schemas/mysql_schema.sql index eb60923afc..169fc71ad4 100644 --- a/phpBB/install/schemas/mysql_schema.sql +++ b/phpBB/install/schemas/mysql_schema.sql @@ -564,7 +564,7 @@ CREATE TABLE phpbb_reports ( ); # Table: 'phpbb_search_results' -CREATE TABLE new_search_results ( +CREATE TABLE phpbb_search_results ( search_key varchar(32) DEFAULT '' NOT NULL, search_time int(11) DEFAULT '0' NOT NULL, search_keywords mediumtext NOT NULL, diff --git a/phpBB/search.php b/phpBB/search.php index fceab40459..2b2151ba10 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -84,12 +84,12 @@ if ($keywords || $author || $search_id) // Which forums should not be searched? $ex_fid_ary = array_keys($auth->acl_getf('!f_read', true)); + $not_in_fid = (sizeof($ex_fid_ary)) ? 'f.forum_id NOT IN (' . implode(', ', $ex_fid_ary) . ') OR ' : ''; $sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, fa.user_id FROM ' . FORUMS_TABLE . ' f LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->data['session_id']) . "') - WHERE f.forum_id NOT IN (" . implode(', ', $ex_fid_ary) . ") - OR (f.forum_password <> '' AND fa.user_id <> " . (int) $user->data['user_id'] . ') + WHERE $not_in_fid(f.forum_password <> '' AND fa.user_id <> " . (int) $user->data['user_id'] . ') ORDER BY f.left_id'; $result = $db->sql_query($sql);