Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[疑问] 刷帖置顶好方法

[复制链接]
findallove 发表于 2009-6-21 17:55:25 | 显示全部楼层 |阅读模式
本帖最后由 findallove 于 2010-11-17 23:56 编辑

刷帖置顶好方法
方法:点击过的贴视为新帖,并置顶
如果论坛初哥要耍点人气就用它吧,科学快捷

dx1.5 的刷新方法,演示地址http://www.z8808.cn/bbs
在640行之后,即
$allowblockrecommend = $_G['group']['allowdiy'] || $_G['group']['allowauthorizedblock'];
$allowpostarticle = $_G['group']['allowmanagearticle'] || $_G['group']['allowauthorizedarticle'];
$allowpusharticle = empty($_G['forum_thread']['special']) && empty($_G['forum_thread']['sortid']) && !$_G['forum_thread']['pushedaid'];
if($_G['forum_thread']['displayorder'] != -4) {
$modmenu = array(
  'thread' => $_G['forum']['ismoderator'] || $allowblockrecommend || $allowpusharticle && $allowpostarticle,
  'post' => $_G['forum']['ismoderator'] && ($_G['group']['allowwarnpost'] || $_G['group']['allowbanpost'] || $_G['group']['allowdelpost'] || $_G['group']['allowstickreply']) || $_G['forum_thread']['pushedaid'] && $allowpostarticle
);
} else {
$modmenu = array();
}
之后加入下面代码即可

//点击更新
//cjupdateforum();
//function cjupdateforum()
{   
        
    DB::query("UPDATE ".DB::table('forum_thread')." SET lastpost='".time()."',dateline='".time()."' WHERE tid='$_G[tid]'");
    $queryf = DB::query("SELECT fid FROM ".DB::table('forum_forum')." WHERE type<>'group' and fid='$_G[fid]'");
   
    while($forum=DB::fetch($queryf)) {
               
        $rs = DB::fetch_first("SELECT tid, subject, lastpost, lastposter FROM ".DB::table('forum_thread')." WHERE fid='$forum[fid]' AND displayorder>='0' ORDER BY lastpost DESC LIMIT 1");
        $lastpost = addslashes("$rs[tid]\t$rs[subject]\t$rs[lastpost]\t$rs[lastposter]");
               
        $sql="SELECT COUNT(*) AS threads, SUM(replies)+COUNT(*) AS posts FROM ".DB::table('forum_thread')." WHERE fid='$forum[fid]' AND displayorder>='0'";
   
    $rs=DB::fetch_first($sql);
    $threads=$rs['threads'];
    $posts=$rs['posts'];
    $d1=round((time()-86400)/86400)*86400;
    $d1=$d1+43200;
    $sql="SELECT COUNT(*) AS todayposts FROM ".DB::table('forum_thread')." WHERE fid='$forum[fid]' AND displayorder>='0' and dateline>$d1";
    $rs=DB::fetch_first($sql);
    $todayposts=$rs['todayposts'];
   
    $query=DB::query("UPDATE ".DB::table('forum_forum')." SET threads='$threads', posts='$posts', lastpost='$lastpost',todayposts='$todayposts' WHERE fid='$forum[fid]'");
   
    }
        

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
 楼主| findallove 发表于 2009-6-21 17:58:04 | 显示全部楼层
加入的东西:
一个功能函数,这个函数我很喜欢,用到了很多地方
function getin($s){
        global $db,$tablepre;
        $qr=$db->query($s);
        if($db->num_rows($qr)>0){
                while($pr=$db->fetch_array($qr)){
                        $db->free_result($qr);       
                        return $pr;
                }
        }else{
                $db->free_result($qr);       
                return 0;
        }
}
置顶代码:
加在        require_once DISCUZ_ROOT.'./include/printable.inc.php';

}后面
//点击更新
//cjupdateforum();
//function cjupdateforum()
{
//        global $tablepre,$db;
        $db->query("UPDATE {$tablepre}threads SET lastpost='".time()."',dateline='".time()."' WHERE tid='$tid'");
        $queryf = $db->query("SELECT fid FROM {$tablepre}forums WHERE type<>'group' and fid='$fid'");
        while($forum=$db->fetch_array($queryf)) {
               
                $rs = getin("SELECT tid, subject, lastpost, lastposter FROM {$tablepre}threads WHERE fid='$forum[fid]' AND displayorder>='0' ORDER BY lastpost DESC LIMIT 1");
                $lastpost = addslashes("$rs[tid]\t$rs[subject]\t$rs[lastpost]\t$rs[lastposter]");
               
                $sql="SELECT COUNT(*) AS threads, SUM(replies)+COUNT(*) AS posts FROM {$tablepre}threads WHERE fid='$forum[fid]' AND displayorder>='0'";
    $rs=getin($sql);
    $threads=$rs['threads'];
    $posts=$rs['posts'];
    $d1=round((time()-86400)/86400)*86400;
    $d1=$d1+43200;
                $sql="SELECT COUNT(*) AS todayposts FROM {$tablepre}threads WHERE fid='$forum[fid]' AND displayorder>='0' and dateline>$d1";
    $rs=getin($sql);
    $todayposts=$rs['todayposts'];
   
                $query=$db->query("UPDATE {$tablepre}forums SET threads='$threads', posts='$posts', lastpost='$lastpost',todayposts='$todayposts' WHERE fid='$forum[fid]'");
        }
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-11-15 23:34 , Processed in 0.018601 second(s), 3 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表