= 0) message(sprintf($lang_search['Search flood'], $pun_user['g_search_flood'])); // First of all lets find out if we need to cache the results, we only need to do this for detailed queries, not quicksearches or for mysql(i) if ($db_type != 'mysql' && $db_type != 'mysqli' && (isset($keywords) || isset($author))) { // We need to grab results, insert them into the cache and reload with a search id before showing them $keyword_results = $author_results = array(); // If it's a search for keywords if ($keywords) { $stopwords = (array)@file(PUN_ROOT.'lang/'.$pun_user['language'].'/stopwords.txt'); $stopwords = array_map('trim', $stopwords); // Filter out non-alphabetical chars $noise_match = array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!', 'ยค'); $noise_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '' , ' ', ' ', ' ', ' ', ' ', ' ', ' '); $keywords = str_replace($noise_match, $noise_replace, $keywords); // Strip out excessive whitespace $keywords = trim(preg_replace('#\s+#', ' ', $keywords)); // Fill an array with all the words $keywords_array = explode(' ', $keywords); if (empty($keywords_array)) message($lang_search['No hits']); while (list($i, $word) = @each($keywords_array)) { $num_chars = pun_strlen($word); if ($word !== 'or' && ($num_chars < 3 || $num_chars > 20 || in_array($word, $stopwords))) unset($keywords_array[$i]); } $word_count = 0; $match_type = 'and'; $result_list = array(); @reset($keywords_array); while (list(, $cur_word) = @each($keywords_array)) { switch ($cur_word) { case 'and': case 'or': case 'not': $match_type = $cur_word; break; default: { $cur_word = $pun_db->escape(str_replace('*', '%', $cur_word)); $query = array( 'SELECT' => 'm.post_id', 'FROM' => 'search_words AS w', 'JOINS' => array( array( 'INNER JOIN' => 'search_matches AS m', 'ON' => 'm.word_id=w.id' ) ), 'WHERE' => 'w.word LIKE \''.$cur_word.'\'' ); // Search in what? if ($search_in) $query['WHERE'] .= ($search_in > 0 ? ' AND m.subject_match=0' : ' AND m.subject_match=1'); ($hook = get_hook('se_qr_get_keyword_hits')) ? eval($hook) : null; $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); $row = array(); while ($temp = $pun_db->fetch_row($result)) { $row[$temp[0]] = 1; if (!$word_count) $result_list[$temp[0]] = 1; else if ($match_type == 'or') $result_list[$temp[0]] = 1; else if ($match_type == 'not') $result_list[$temp[0]] = 0; } if ($match_type == 'and' && $word_count) { @reset($result_list); while (list($post_id,) = @each($result_list)) { if (!isset($row[$post_id])) $result_list[$post_id] = 0; } } ++$word_count; $pun_db->free_result($result); break; } } } @reset($result_list); while (list($post_id, $matches) = @each($result_list)) { if ($matches) $keyword_results[] = $post_id; } unset($result_list); } // If it's a search for author name (and that author name isn't Guest) if ($author && strtolower($author) != 'guest' && strtolower($author) != strtolower($lang_common['Guest'])) { $query = array( 'SELECT' => 'u.id', 'FROM' => 'users AS u', 'WHERE' => 'u.username '.($db_type == 'pgsql' ? 'ILIKE' : 'LIKE').' \''.$pun_db->escape(str_replace('*', '%', $author)).'\'' ); ($hook = get_hook('se_qr_get_author')) ? eval($hook) : null; $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); if ($pun_db->num_rows($result)) { $user_ids = ''; while ($row = $pun_db->fetch_row($result)) $user_ids .= (($user_ids != '') ? ',' : '').$row[0]; $query = array( 'SELECT' => 'p.id', 'FROM' => 'posts AS p', 'WHERE' => 'p.poster_id IN('.$user_ids.')' ); ($hook = get_hook('se_qr_get_author_hits')) ? eval($hook) : null; $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); $search_ids = array(); while ($row = $pun_db->fetch_row($result)) $author_results[] = $row[0]; $pun_db->free_result($result); } } if ($author && $keywords) { // If we searched for both keywords and author name we want the intersection between the results $search_ids = array_intersect($keyword_results, $author_results); unset($keyword_results, $author_results); } else if ($keywords) $search_ids = $keyword_results; else $search_ids = $author_results; if (count($search_ids) == 0) message($lang_search['No hits']); // Setup the default show_as topics search $query = array( 'SELECT' => 't.id', 'FROM' => 'posts AS p', 'JOINS' => array( array( 'INNER JOIN' => 'topics AS t', 'ON' => 't.id=p.topic_id' ), array( 'LEFT JOIN' => 'forum_perms AS fp', 'ON' => '(fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].')' ) ), 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND p.id IN('.implode(',', $search_ids).')', 'GROUP BY' => 't.id' ); // Search a specific forum? if ($forum != -1 || ($forum == -1 && $pun_config['o_search_all_forums'] == '0' && !$pun_user['is_admmod'])) $query['WHERE'] .= ' AND t.forum_id = '.$forum; // Adjust the query if show_as posts if ($show_as == 'posts') { $query['SELECT'] = 'p.id'; unset($query['GROUP BY']); } ($hook = get_hook('se_qr_get_hits')) ? eval($hook) : null; $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); $search_ids = array(); while ($row = $pun_db->fetch_row($result)) $search_ids[] = $row[0]; // Prune "old" search results $query = array( 'SELECT' => 'o.ident', 'FROM' => 'online AS o' ); ($hook = get_hook('se_qr_get_online_idents')) ? eval($hook) : null; $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); if ($pun_db->num_rows($result)) { $online_idents = array(); while ($row = $pun_db->fetch_row($result)) $online_idents[] = '\''.$pun_db->escape($row[0]).'\''; $query = array( 'DELETE' => 'search_cache', 'WHERE' => 'ident NOT IN('.implode(',', $online_idents).')' ); ($hook = get_hook('se_qr_delete_old_cached_searches')) ? eval($hook) : null; $pun_db->query_build($query) or error(__FILE__, __LINE__); } // Final search results $search_results = implode(',', $search_ids); // Fill an array with our results and search properties $temp['search_results'] = $search_results; $temp['sort_by'] = $sort_by; $temp['sort_dir'] = $sort_dir; $temp['show_as'] = $show_as; $temp = serialize($temp); $search_id = mt_rand(1, 2147483647); $ident = ($pun_user['is_guest']) ? get_remote_address() : $pun_user['username']; $query = array( 'INSERT' => 'id, ident, search_data', 'INTO' => 'search_cache', 'VALUES' => $search_id.', \''.$pun_db->escape($ident).'\', \''.$pun_db->escape($temp).'\'' ); ($hook = get_hook('se_qr_cache_search')) ? eval($hook) : null; $pun_db->query_build($query) or error(__FILE__, __LINE__); $pun_db->end_transaction(); $pun_db->close(); // Redirect the user to the cached result page header('Location: '.str_replace('&', '&', pun_link($pun_url['search_results'], $search_id))); exit; } // If we're still running we don't need to cache results but we still need to get them, either from the cache or from their respective sources. // We're doing a fulltext search! else if (($db_type == 'mysql' || $db_type == 'mysqli') && (isset($keywords) || isset($author))) { // Are we limiting the results to a specific forum? if ($forum != -1 || ($forum == -1 && $pun_config['o_search_all_forums'] == '0' && !$pun_user['is_admmod'])) $forum_where = ' AND f.id = '.$forum; else $forum_where = ''; // Sort out how to order the results switch ($sort_by) { case 1: $sort_by_sql = ($show_as == 'topics') ? 'poster' : 'p.poster'; break; case 2: $sort_by_sql = 'subject'; break; case 3: $sort_by_sql = 'forum_id'; break; case 4: if ($show_as == 'posts') $sort_by_sql = 'MATCH(p.message) AGAINST(\''.$pun_db->escape($keywords).'\')'; else $sort_by_sql = 'total_relevance'; break; default: $sort_by_sql = ($show_as == 'topics') ? 'posted' : 'p.posted'; break; } // Generate the query to give us our results if ($show_as == 'posts') $query = ' SELECT p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, SUBSTRING(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.first_post_id, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id, f.forum_name FROM '.$pun_db->prefix.'posts AS p LEFT JOIN '.$pun_db->prefix.'topics AS t ON t.id=p.topic_id LEFT JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) '.($author ? 'AND p.poster LIKE \''.$pun_db->escape(str_replace('*', '%', $author)).'\'' : '').' '.($keywords ? 'AND MATCH(p.message) AGAINST(\''.$pun_db->escape($keywords).'\' IN BOOLEAN MODE)' : '').' '.$forum_where.' ORDER BY '.$sort_by_sql.' '.$sort_dir; else { $query = ' SELECT *, SUM(relevance) AS total_relevance FROM ( SELECT t.id AS tid, t.poster, t.subject, t.first_post_id, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, t.posted, f.forum_name, MATCH(t.subject) AGAINST(\''.$pun_db->escape($keywords).'\') AS relevance FROM '.$pun_db->prefix.'topics AS t LEFT JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) '.($author ? 'AND t.poster LIKE \''.$pun_db->escape(str_replace('*', '%', $author)).'\'' : '').' '.($keywords ? 'AND MATCH(t.subject) AGAINST(\''.$pun_db->escape($keywords).'\' IN BOOLEAN MODE)' : '').' '.$forum_where.' UNION SELECT t.id AS tid, t.poster, t.subject, t.first_post_id, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, t.posted, f.forum_name, MATCH(p.message) AGAINST(\''.$pun_db->escape($keywords).'\') AS relevance FROM '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'topics AS t ON p.topic_id = t.id LEFT JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) '.($author ? 'AND p.poster LIKE \''.$pun_db->escape(str_replace('*', '%', $author)).'\'' : '').' '.($keywords ? 'AND MATCH(p.message) AGAINST(\''.$pun_db->escape($keywords).'\' IN BOOLEAN MODE)' : '').' '.$forum_where.' ) AS tmp GROUP BY tid ORDER BY '.$sort_by_sql.' '.$sort_dir; } $url_type = $pun_url['search_resultft']; $search_id = array(rawurlencode($keywords), $forum, rawurlencode($author), ($search_in == 0 ) ? 'all' : (($search_in == 1) ? 'message' : 'subject'), $sort_by, $sort_dir, $show_as); } // We aren't doing a fulltext but we are getting results, if a valid search_id was supplied we attempt to fetch the search results from the cache else if (isset($search_id)) { $ident = ($pun_user['is_guest']) ? get_remote_address() : $pun_user['username']; $query = array( 'SELECT' => 'sc.search_data', 'FROM' => 'search_cache AS sc', 'WHERE' => 'sc.id='.$search_id.' AND sc.ident=\''.$pun_db->escape($ident).'\'' ); ($hook = get_hook('se_qr_get_cached_search_data')) ? eval($hook) : null; $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); if ($row = $pun_db->fetch_assoc($result)) { $temp = unserialize($row['search_data']); $search_results = $temp['search_results']; $sort_by = $temp['sort_by']; $sort_dir = $temp['sort_dir']; $show_as = $temp['show_as']; unset($temp); } else message($lang_search['No hits']); switch ($sort_by) { case 1: $sort_by_sql = ($show_as == 'topics') ? 't.poster' : 'p.poster'; break; case 2: $sort_by_sql = 't.subject'; break; case 3: $sort_by_sql = 't.forum_id'; break; default: $sort_by_sql = ($show_as == 'topics') ? 't.posted' : 'p.posted'; break; } if ($show_as == 'posts') { $query = array( 'SELECT' => 'p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, '.(($db_type != 'sqlite') ? 'SUBSTRING' : 'SUBSTR').'(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.first_post_id, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id, f.forum_name', 'FROM' => 'posts AS p', 'JOINS' => array( array( 'INNER JOIN' => 'topics AS t', 'ON' => 't.id=p.topic_id' ), array( 'INNER JOIN' => 'forums AS f', 'ON' => 'f.id=t.forum_id' ) ), 'WHERE' => 'p.id IN('.$search_results.')', 'ORDER BY' => $sort_by_sql ); ($hook = get_hook('se_qr_get_cached_hits_as_posts')) ? eval($hook) : null; } else { $query = array( 'SELECT' => 't.id AS tid, t.poster, t.subject, t.first_post_id, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, f.forum_name', 'FROM' => 'topics AS t', 'JOINS' => array( array( 'INNER JOIN' => 'forums AS f', 'ON' => 'f.id=t.forum_id' ) ), 'WHERE' => 't.id IN('.$search_results.')', 'ORDER BY' => $sort_by_sql ); ($hook = get_hook('se_qr_get_cached_hits_as_topics')) ? eval($hook) : null; } $url_type = $pun_url['search_results']; } else if (in_array($action, $valid_actions)) { $search_id = ''; $show_as = 'topics'; switch ($action) { case 'show_new': if ($pun_user['is_guest']) message($lang_common['No permission']); $query = array( 'SELECT' => 't.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, f.forum_name', 'FROM' => 'topics AS t', 'JOINS' => array( array( 'INNER JOIN' => 'forums AS f', 'ON' => 'f.id=t.forum_id' ), array( 'LEFT JOIN' => 'forum_perms AS fp', 'ON' => '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')' ) ), 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.last_post>'.$pun_user['last_visit'].' AND t.moved_to IS NULL', 'ORDER BY' => 't.last_post DESC' ); ($hook = get_hook('se_qr_get_new')) ? eval($hook) : null; $url_type = $pun_url['search_new']; break; case 'show_recent': $query = array( 'SELECT' => 't.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, f.forum_name', 'FROM' => 'topics AS t', 'JOINS' => array( array( 'INNER JOIN' => 'forums AS f', 'ON' => 'f.id=t.forum_id' ), array( 'LEFT JOIN' => 'forum_perms AS fp', 'ON' => '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')' ) ), 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.last_post>'.(time() - $value).' AND t.moved_to IS NULL', 'GROUP BY' => 't.id', 'ORDER BY' => 't.last_post DESC' ); ($hook = get_hook('se_qr_get_recent')) ? eval($hook) : null; $url_type = $pun_url['search_24h']; break; case 'show_user_posts': $query = array( 'SELECT' => 'p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, '.(($db_type != 'sqlite') ? 'SUBSTRING' : 'SUBSTR').'(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.first_post_id, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id, f.forum_name', 'FROM' => 'posts AS p', 'JOINS' => array( array( 'INNER JOIN' => 'topics AS t', 'ON' => 't.id=p.topic_id' ), array( 'INNER JOIN' => 'forums AS f', 'ON' => 'f.id=t.forum_id' ), array( 'LEFT JOIN' => 'forum_perms AS fp', 'ON' => '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')' ) ), 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND p.poster_id='.$user_id, 'ORDER BY' => 'pposted DESC' ); ($hook = get_hook('se_qr_get_user_posts')) ? eval($hook) : null; $url_type = $pun_url['search_user_posts']; $search_id = $user_id; $show_as = 'posts'; break; case 'show_user_topics': $query = array( 'SELECT' => 't.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, f.forum_name', 'FROM' => 'topics AS t', 'JOINS' => array( array( 'INNER JOIN' => 'posts AS p', 'ON' => 't.first_post_id=p.id' ), array( 'INNER JOIN' => 'forums AS f', 'ON' => 'f.id=t.forum_id' ), array( 'LEFT JOIN' => 'forum_perms AS fp', 'ON' => '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')' ) ), 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND p.poster_id='.$user_id, 'ORDER BY' => 't.last_post DESC' ); ($hook = get_hook('se_qr_get_user_topics')) ? eval($hook) : null; $url_type = $pun_url['search_user_topics']; $search_id = $user_id; break; case 'show_subscriptions': if ($pun_user['is_guest']) message($lang_common['Bad request']); $query = array( 'SELECT' => 't.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, f.forum_name', 'FROM' => 'topics AS t', 'JOINS' => array( array( 'INNER JOIN' => 'subscriptions AS s', 'ON' => '(t.id=s.topic_id AND s.user_id='.$pun_user['id'].')' ), array( 'INNER JOIN' => 'forums AS f', 'ON' => 'f.id=t.forum_id' ), array( 'LEFT JOIN' => 'forum_perms AS fp', 'ON' => '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')' ) ), 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1)', 'ORDER BY' => 't.last_post DESC' ); ($hook = get_hook('se_qr_get_subscriptions')) ? eval($hook) : null; $url_type = $pun_url['search_subscriptions']; break; case 'show_unanswered': $query = array( 'SELECT' => 't.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, f.forum_name', 'FROM' => 'topics AS t', 'JOINS' => array( array( 'INNER JOIN' => 'forums AS f', 'ON' => 'f.id=t.forum_id' ), array( 'LEFT JOIN' => 'forum_perms AS fp', 'ON' => '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')' ) ), 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.num_replies=0 AND t.moved_to IS NULL', 'GROUP BY' => 't.id', 'ORDER BY' => 't.last_post DESC' ); ($hook = get_hook('se_qr_get_unanswered')) ? eval($hook) : null; $url_type = $pun_url['search_unanswered']; break; default: // A good place for an extension to add a new search type (action must be added to $valid_actions first) ($hook = get_hook('se_new_action')) ? eval($hook) : null; break; } } else message($lang_common['Bad request']); // We now have a query that will give us our results in $query, lets get the data! if (is_array($query)) $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); else $result = $pun_db->query($query) or error(__FILE__, __LINE__); if (!$pun_user['is_guest']) { // Set the user's last_search time $query = array( 'UPDATE' => 'users', 'SET' => 'last_search='.time(), 'WHERE' => 'id='.$pun_user['id'], 'PARAMS' => array( 'LOW_PRIORITY' => 1 // MySQL only ) ); ($hook = get_hook('se_qr_update_last_search_time')) ? eval($hook) : null; $pun_db->query_build($query) or error(__FILE__, __LINE__); } // Make sure we actually have some results $num_hits = $pun_db->num_rows($result); if ($num_hits == 0) { $pun_page['search_again'] = ''.$lang_search['Perform new search'].''; switch ($action) { case 'show_new': message($lang_search['No new posts'], $pun_page['search_again']); case 'show_recent': message($lang_search['No recent posts'], $pun_page['search_again']); case 'show_user_posts': message($lang_search['No user posts'], $pun_page['search_again']); case 'show_user_topics': message($lang_search['No user topics'], $pun_page['search_again']); case 'show_subscriptions': message($lang_search['No subscriptions'], $pun_page['search_again']); case 'show_unanswered': message($lang_search['No unanswered'], $pun_page['search_again']); default: ($hook = get_hook('se_new_action_no_hits')) ? eval($hook) : null; message($lang_search['No hits'], $pun_page['search_again']); } } // Get topic/forum tracking data if (!$pun_user['is_guest']) $tracked_topics = get_tracked_topics(); // Determine the topic or post offset (based on $_GET['p']) $pun_page['per_page'] = ($show_as == 'posts') ? $pun_user['disp_posts'] : $pun_user['disp_topics']; $pun_page['num_pages'] = ceil($num_hits / $pun_page['per_page']); $pun_page['page'] = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $pun_page['num_pages']) ? 1 : $_GET['p']; $pun_page['start_from'] = $pun_page['per_page'] * ($pun_page['page'] - 1); $pun_page['finish_at'] = min(($pun_page['start_from'] + $pun_page['per_page']), $num_hits); // Generate paging links $pun_page['page_post'] = '
'.$lang_common['Pages'].' '.paginate($pun_page['num_pages'], $pun_page['page'], $url_type, $lang_common['Paging separator'], $search_id).'
'; // Fill $search_set with out search hits $search_set = array(); $row_num = 0; while ($row = $pun_db->fetch_assoc($result)) { if ($pun_page['start_from'] <= $row_num && $pun_page['finish_at'] > $row_num) $search_set[] = $row; ++$row_num; } $pun_db->free_result($result); ($hook = get_hook('se_post_results_fetched')) ? eval($hook) : null; // Navigation links for header and page numbering for title/meta description if ($pun_page['page'] < $pun_page['num_pages']) { $pun_page['nav'][] = ''; $pun_page['nav'][] = ''; } if ($pun_page['page'] > 1) { $pun_page['nav'][] = ''; $pun_page['nav'][] = ''; } // Setup breadcrumbs and results header and footer $pun_page['main_foot_options'][] = ''.$lang_search['Perform new search'].''; $pun_page['crumbs'][] = array($pun_config['o_board_title'], pun_link($pun_url['index'])); switch ($action) { case 'show_new': $pun_page['crumbs'][] = $lang_common['New posts']; $pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], $lang_search['Topics with new'], $num_hits) : ''.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' '.sprintf($lang_common['Paged info'], $lang_search['Topics with new'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits)); $pun_page['main_foot_options'][] = ''.$lang_common['Mark all as read'].''; break; case 'show_recent': $pun_page['crumbs'][] = $lang_common['Recent posts']; $pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], $lang_search['Topics with recent'], $num_hits) : ''.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' '.sprintf($lang_common['Paged info'], $lang_search['Topics with recent'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits)); break; case 'show_unanswered': $pun_page['crumbs'][] = $lang_common['Unanswered topics']; $pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], $lang_common['Unanswered topics'], $num_hits) : ''.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' '.sprintf($lang_common['Paged info'], $lang_common['Unanswered topics'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits)); break; case 'show_user_posts': $pun_page['crumbs'][] = sprintf($lang_search['Posts by'], $search_set[0]['pposter']); $pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], sprintf($lang_search['Posts by'], $search_set[0]['pposter']), $num_hits) : ''.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' '.sprintf($lang_common['Paged info'], sprintf($lang_search['Posts by'], $search_set[0]['pposter']), $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits)); $pun_page['main_foot_options'][] = ''.sprintf($lang_search['Topics by'], $search_set[0]['pposter']).''; break; case 'show_user_topics': $pun_page['crumbs'][] = sprintf($lang_search['Topics by'], $search_set[0]['poster']); $pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], sprintf($lang_search['Topics by'], $search_set[0]['poster']), $num_hits) : ''.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' '.sprintf($lang_common['Paged info'], sprintf($lang_search['Topics by'], $search_set[0]['poster']), $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits)); $pun_page['main_foot_options'][] = ''.sprintf($lang_search['Posts by'], $search_set[0]['poster']).''; break; case 'show_subscriptions': $pun_page['crumbs'][] = $lang_common['Your subscriptions']; $pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], $lang_common['Your subscriptions'], $num_hits) : ''.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' '.sprintf($lang_common['Paged info'], $lang_common['Your subscriptions'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits)); break; default: $pun_page['crumbs'][] = $lang_search['Search results']; $pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], (($show_as=='topics') ? $lang_common['Topics'] : $lang_common['Posts']), $num_hits) : ''.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' '.sprintf($lang_common['Paged info'], (($show_as=='topics') ? $lang_common['Topics'] : $lang_common['Posts']), $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits)); break; } ($hook = get_hook('se_results_pre_header_load')) ? eval($hook) : null; define('PUN_PAGE', $show_as == 'topics' ? 'searchtopics' : 'searchposts'); require PUN_ROOT.'header.php'; if ($show_as == 'topics') { // Load the forum.php language file require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php'; ?>