Ejemplo n.º 1
0
$Error = '';
if (!$KeywordNum) {
    AlertMsg('404 Not Found', '404 Not Found', 404);
}
if ($Page < 0 || $Page == 1) {
    header('location: ' . $Config['WebsitePath'] . '/search/' . $Keyword);
    exit;
}
if ($Page == 0) {
    $Page = 1;
}
$limitSize = 30;
//如果定义了搜索服务器,就走搜索服务
if (defined('SearchServer') && SearchServer) {
    try {
        $finds = SearchClient::searchLike($Keyword, 'PostsIndexes', ($Page - 1) * $limitSize, $limitSize, "", 'PostTime desc');
        if (!empty($finds)) {
            $num = $finds[1];
            $postIds = isset($finds[0]['id']) ? $finds[0]['id'] : null;
            if (count($postIds) > 0) {
                $TopicsArray = $DB->query('SELECT t.`ID`, `Topic`, `Tags`, t.`UserID`, t.`UserName`, t.`LastName`, `LastTime`, `Replies` 
					, p.Content, p.ID as pID, p.PostTime 
					FROM ' . $Prefix . 'topics  t, ' . $Prefix . 'posts p 
					WHERE t.ID=p.TopicID and p.ID in (?) and t.IsDel=0 
					ORDER BY p.PostTime DESC', $postIds);
                foreach ($TopicsArray as &$row) {
                    $excerpts = SearchClient::callProxy('buildExcerpts', array(array($row['Topic'], $row['Content']), 'PostsIndexes', $Keyword, array("before_match" => '<span class="search-keyword">', "after_match" => "</span>")));
                    $row['MinContent'] = $excerpts[1];
                }
            }
        }