$word) { $search_string.=mysql_escape_string($word)."%"; } $query = "title like '".$search_string."'"; if ($forum!="" && $forum!="all") { $query.=" and forum = ".intval($forum->id); } if ($user!="" && $user!="all") { $query.=" and owner = ".intval($user->id); } if ($time!="" && $user!="all") { $query.=" and timestamp > ".intval($time); } if ($show_hidden == false) { $query .= " AND thread.hidden = 0"; } switch($sort_style) { case MODIFIED_NEW: $query .= ' ORDER BY timestamp DESC'; break; case VIEWS_MOST: $query .= ' ORDER BY views DESC'; break; case REPLIES_MOST: $query .= ' ORDER BY replies DESC'; break; case CREATE_TIME_NEW: $query .= ' ORDER by create_time desc'; break; case CREATE_TIME_OLD: $query .= ' ORDER by create_time asc'; break; case 'score': $query .= ' ORDER by score desc'; break; default: $query .= ' ORDER BY timestamp DESC'; break; } $query.= " limit ".intval($limit); return BoincThread::enum($query); } // Searches for the keywords in the $keyword_list array in post bodies. // optionally filters by forum, time, hidden, or user if specified. // function search_post_content( $keyword_list, $forum="", $user="", $time="", $limit=200, $sort_style=CREATE_TIME_NEW, $show_hidden = false ){ $search_string="%"; foreach ($keyword_list as $key => $word){ $search_string.=mysql_escape_string($word)."%"; } $optional_join = ""; if ($forum!="" && $forum!="all"){ $optional_join = " LEFT JOIN DBNAME.thread ON post.thread = thread.id"; } $query = "select *,post.id as postid from DBNAME.post".$optional_join." where content like '".$search_string."'"; if ($forum!="" && $forum!="all"){ $query.=" and forum = ".intval($forum->id); } if ($user!="" && $user!="all"){ $query.=" and post.user = ".intval($user->id ); } if ($time!="" && $user!="all"){ $query.=" and post.timestamp > ".intval($time); } if ($show_hidden == false) { $query .= " AND post.hidden = 0"; } switch($sort_style) { case VIEWS_MOST: $query.= ' ORDER BY views DESC'; break; case CREATE_TIME_NEW: $query .= ' ORDER by post.timestamp desc'; break; case CREATE_TIME_OLD: $query .= ' ORDER by post.timestamp asc'; break; case POST_SCORE: $query .= ' ORDER by post.score desc'; break; default: $query .= ' ORDER BY post.timestamp DESC'; break; } $query.= " limit ".intval($limit); return BoincPost::enum_general($query); } $logged_in_user = get_logged_in_user(false); BoincForumPrefs::lookup($logged_in_user); if ($logged_in_user && $logged_in_user->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 probably relevant // $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 "
"; 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 ""; page_tail(); exit; $cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit ?>