prefs->privilege(S_MODERATOR)){
$show_hidden_posts = true;
} else {
$show_hidden_posts = false;
}
page_head(tra("Forum search"));
$search_keywords = post_str("search_keywords", true);
$search_author = post_str("search_author", true);
$search_max_time = post_int("search_max_time");
$search_forum = post_int("search_forum");
$search_sort = post_int("search_sort");
$search_list = explode(" ",$search_keywords);
$min_timestamp = time() - ($search_max_time*3600*24);
$limit = 100;
if ($search_forum==-1){
$forum = "";
} else if ($search_forum) {
$forum = BoincForum::lookup_id($search_forum);
}
$user = null;
if ($search_author) {
$user = BoincUser::lookup_id($search_author);
}
// First search thread titles, if we get a hit there it's probablyrelevant
//
$threads = search_thread_titles($search_list, $forum, $user, $min_timestamp, round($limit/7), $search_sort, $show_hidden_posts);
// Display the threads while we search for posts
if (count($threads)){
echo "
Perform another search
";
echo "Threads found matching your search query:
";
start_forum_table(array(tra("Topic"), tra("Threads"), tra("Posts"), tra("Author"), tra("Views"), "".tra("Last post").""));
foreach ($threads as $thread){
if ($thread->hidden) continue;
$thread_forum = BoincForum::lookup_id($thread->forum);
$owner = BoincUser::lookup_id($thread->owner);
echo '
'.cleanup_title($thread_forum->title).' |
'.cleanup_title($thread->title).' | ';
echo '
'.($thread->replies+1).' |
'.user_links($owner).' |
'.$thread->views.' |
'.time_diff_str($thread->timestamp, time()).' |
';
}
end_table();
echo "
";
}
// Let's see if we can match anything in a post body as well:
//
$posts = search_post_titles(
$search_list, $forum, $user, $min_timestamp, $limit, $search_sort,
$show_hidden_posts
);
if (count($posts)){
echo "Posts found matching your search query:
";
start_forum_table(array(tra("Topic"), tra("Threads"), tra("Author"),"".tra("Last post").""));
if ($logged_in_user){
$options = get_output_options($logged_in_user);
} else {
$options = new output_options();
}
foreach ($posts as $post){
$thread = BoincThread::lookup_id($post->thread);
if (($show_hidden_posts == false) && ($thread->hidden)) continue;
if (($show_hidden_posts == false) && ($post->hidden)) continue;
$options->setHighlightTerms($search_list);
$contents = output_transform($post->content, $options);
$thread_forum = BoincForum::lookup_id($thread->forum);
$owner = BoincUser::lookup_id($post->user);
echo '
'.cleanup_title($thread_forum->title).' |
'.cleanup_title($thread->title).' |
'.user_links($owner).' |
'.time_diff_str($post->timestamp, time()).' |
'.substr($contents,0,200).'...
|
|
';
}
end_table();
}
if (!count($thread) && !count($posts)){
echo "Sorry, couldn't find anything matching your search query. You
can try to broaden your search by using less words (or less specific words).
You can also
try the same search on Google.
";
}
echo "Perform another search
";
page_tail();
exit;
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
?>