ist_multisort($threadlist, 'tid', FALSE); global $forumlist, $gid; $count_before = count($threadlist); thread_list_access_filter($threadlist, $gid); $count_after = count($threadlist); // 如果过滤超过了一半,则从数据库中加大 $pagesize 再取。 $less_number = $pagesize / 2; if($count_before - $count_after > $less_number){ $pagesize *= 2; $threadlist = search_thread_by_like($keyword_decode, $start, $pagesize); } return $threadlist; } function search_post_by_like($keyword_decode, $start, $pagesize2, &$nextpage, &$page){ global $db, $pagesize; $tablepre = $db->tablepre; // 限制递归调用次数 static $call_count = 0; if($call_count++ > 5){ return array(); } $arrlist = db_sql_find("SELECT * FROM `{$tablepre}post` WHERE $keyword_decode ORDER BY `create_date` DESC LIMIT $start, $pagesize2;"); $nextpage = count($arrlist) == $pagesize2 ? $page + 1 : 0; $pids = arrlist_values($arrlist, 'pid'); $postlist = post_find_by_pids($pids); // 权限过滤 $count_before = count($postlist); global $forumlist, $gid; foreach($postlist as $k=>$post){ $thread = thread__read($post['tid']); if(empty($forumlist[$thread['fid']]['accesson'])){ continue; } if($thread['top'] > 0){ continue; } if(!forum_access_user($thread['fid'], $gid, 'allowread')){ unset($postlist[$k]); } } $count_after = count($postlist); // 如果过滤超过了一半,则从数据库中加大 $pagesize 再取。 $less_number = $pagesize / 2; if($count_before - $count_after > $less_number){ $pagesize2 += $pagesize; $page++; $postlist = search_post_by_like($keyword_decode, $start, $page, $pagesize2, $nextpage, $page); } // 排序 $postlist = arrlist_multisort($postlist, 'pid', FALSE); return $postlist; }?>