[code]//根据帖子ID 获取文章详情
function ax_message($tid{
$r = db_find_one(‘post’, array(‘tid’=>$tid));
//return xn_substr(strip_tags($r[‘message_fmt’]), 0, 48).”…”; 备用截取显示文字数目
return $r[‘message_fmt’];
}
//根据帖子ID 获取文章中的图片
function ax_cover($tid){
$r = db_find_one(‘post’, array(‘tid’=>$tid));
$content = $r[‘message_fmt’]; //文章内容
preg_match_all(“/<img.*src=[\’|\”](.*)[\’|\”]\s*.*>/iU”, $content, $img);
$imgArr = $img[1];
if(isset($imgArr[0])){
return $imgArr[0];
}else{
return “”;
}
}
//最新发表 + 缓存
function ax_new_thread() {
$cachename = “ax_new_thread”;
$threadlist = cache_get($cachename);
if($threadlist === NULL) {
$threadlist = thread_find(array(),array(‘tid’=>-1),2,10);
cache_set($cachename, $threadlist, 200);
}
return $threadlist;
}
//显示同板块下 相关文章
function ax_Relevant($fid)
$r = thread_find(array(“fid”=>$fid),array(‘tid’=>-1),1,6);
return $r;
}
//根据板块id和当前帖子id 实现 上一篇,下一篇
function ax_prev($tid,$fid) {
$r = db_sql_find_one(“select * from bbs_thread where fid = {$fid} and tid > {$tid} order by tid asc limit 0,1”);
return $r;
}
function ax_next($tid,$fid) {
$r = db_sql_find_one(“select * from bbs_thread where fid = {$fid} and tid < {$tid} order by tid desc limit 0,1″);
return $r;
}
// 更改翻页方式 不再是1,2,3,4 …形式 改为 上一页下一页,形式
function axpager($url, $totalnum, $page, $pagesize = 20) {
$totalpage = ceil($totalnum / $pagesize);
if($totalpage < 2) return ”;
$page = min($totalpage, $page);
$s = ”;
$page > 1 AND $s .= ‘<li class=”previous”><a href=”‘.str_replace(‘{page}’, $page-1, $url).'”>上一页</a></li>’;
if($page > 1){
$s .= “<span class=’now-page’>”.” $page / $totalpage “.”</span>”;
}
$totalnum >= $pagesize AND $page != $totalpage AND $s .= ‘<a href=”‘.str_replace(‘{page}’, $page+1, $url).'” class=”page-link”>下一页</a>’;
return $s;
}[/code]