diff options
Diffstat (limited to 'phpBB/search.php')
-rw-r--r-- | phpBB/search.php | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/phpBB/search.php b/phpBB/search.php index b621252738..46e811be37 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -115,11 +115,7 @@ else $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0; -// -// Define some globally used data -// $sort_by_types = array($lang['Sort_Time'], $lang['Sort_Post_Subject'], $lang['Sort_Topic_Title'], $lang['Sort_Author'], $lang['Sort_Forum']); -$sort_by_sql = array('p.post_time', 'pt.post_subject', 't.topic_title', 'u.username', 'f.forum_id'); // // Begin core code @@ -161,7 +157,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id ) } else { - header("Location: login.$phpEx?redirect=search&search_id=newposts"); + header("Location: login.$phpEx?redirect=search.$phpEx&search_id=newposts", true); exit; } @@ -179,7 +175,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id ) } else { - header("Location: login.$phpEx?redirect=search&search_id=egosearch"); + header("Location: login.$phpEx?redirect=search.$phpEx&search_id=egosearch", true); exit; } @@ -446,8 +442,8 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id ) } else if ( $search_author != '' || $search_time || $auth_sql != '' ) { - $where_sql = ( $search_author == '' && $auth_sql == '' ) ? "post_id IN (" . implode(', ', $search_ids) . ")" : "p.post_id IN (" . implode(", ", $search_ids) . ")"; - $from_sql = ( $search_author == '' && $auth_sql == '' ) ? POSTS_TABLE : POSTS_TABLE . " p"; + $where_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id IN (' . implode(', ', $search_ids) . ')' : 'p.post_id IN (' . implode(', ', $search_ids) . ')'; + $from_sql = ( $search_author == '' && $auth_sql == '' ) ? POSTS_TABLE : POSTS_TABLE . ' p'; if ( $search_time ) { @@ -640,10 +636,29 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id ) AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id"; } - + $per_page = ( $show_results == 'posts' ) ? $board_config['posts_per_page'] : $board_config['topics_per_page']; - $sql .= " ORDER BY " . $sort_by_sql[$sort_by] . " $sort_dir LIMIT $start, " . $per_page; + $sql .= " ORDER BY "; + switch ( $sort_by ) + { + case 1: + $sql .= ( $show_results == 'posts' ) ? 'pt.post_subject' : 't.topic_title'; + break; + case 2: + $sql .= 't.topic_title'; + break; + case 3: + $sql .= 'u.username'; + break; + case 4: + $sql .= 'f.forum_id'; + break; + default: + $sql .= ( $show_results == 'posts' ) ? 'p.post_time' : 'p2.post_time'; + break; + } + $sql .= " $sort_dir LIMIT $start, " . $per_page; if ( !$result = $db->sql_query($sql) ) { @@ -725,7 +740,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id ) { $forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $searchset[$i]['forum_id']); $topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . "&highlight=$highlight_active"); - $post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&highlight=$highlight_active#" . $searchset[$i]['post_id']); + $post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&highlight=$highlight_active") . '#' . $searchset[$i]['post_id']; $post_date = create_date($board_config['default_dateformat'], $searchset[$i]['post_time'], $board_config['board_timezone']); @@ -1298,4 +1313,4 @@ $template->pparse('body'); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); -?> +?>
\ No newline at end of file |