//根据帖子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("//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 .= '上一页';
if($page > 1){
$s .= ""." $page / $totalpage "."";
}
$totalnum >= $pagesize AND $page != $totalpage AND $s .= '下一页';
return $s; }
-------------------------------------
作者: 迷途
来源: 四叶草 | 问答社区 Life Nerd (bbs.432k.cn)
原文链接: http://bbs.432k.cn/thread-1006.htm
版权声明: 若无额外声明,本帖为作者原创帖,转载请附上帖子链接!