帝国CMS二次开发不开后台定时刷新脚本

在你的操作系统,如果是Linux的话,添加以下计划任务。 

* * * * *  /usr/bin/php /webrootpath/e/tasks/backend_cronjob.php。

把代码传到 /e/tasks/ 下。 

这个脚本将替代后台的定时刷新,你不用在开着后台了,它帮你定时刷新。

适用场景:全战静态化,需要定时刷新。(比如首页有点计量,排行榜这样的数据)

同时适用于,需要在多台服务器上生成内容的情况。

<?php
if (substr(php_sapi_name(), 0, 3) !== 'cli') {
    die(forbidden);
}
define('DOC_ROOT', strtr(__FILE__,'','/'));
define('ROOT_PATH',dirname(dirname(dirname(DOC_ROOT))));
require(ROOT_PATH.'/e/class/connect.php');
require(ROOT_PATH.'/e/class/functions.php');
require(ROOT_PATH.'/e/data/dbcache/class.php'); //引入栏目缓存文件
require(ROOT_PATH.'/e/class/db_sql.php');
require(ROOT_PATH.'/e/class/t_functions.php');
require(ROOT_PATH.'/e/data/dbcache/class.php');
require(ROOT_PATH.'/e/data/dbcache/MemberLevel.php');
$link = db_connect();
$empire = new mysqlquery();
//定时刷新任务
function DoTimeRepage(){
    global $empire,$dbtbpre;
    DoAutoUpAndDownInfo();//自动上/下线
    $dotime=time();
    $b=0;
    $sql=$empire->query(select doing,classid,doid from {$dbtbpre}enewsdo where isopen = 1 and lasttime + dotime * 60 < $dotime);
    while($r=$empire->fetch($sql))
    {
        $b=1;
        if($r['doing']==1)//生成栏目
        {
            $cr=explode(',',$r['classid']);
            $count=count($cr)-1;
            for($i=1;$i<$count;$i++)
            {
                if(empty($cr[$i]))
                {
                    continue;
                }
                $cr[$i]=(int)$cr[$i];
                ReListHtml($cr[$i],1);
            }
        }
        elseif($r['doing']==2)//生成专题
        {
            $cr=explode(',',$r['classid']);
            $count=count($cr)-1;
            for($i=1;$i<$count;$i++)
            {
                if(empty($cr[$i]))
                {
                    continue;
                }
                $cr[$i]=(int)$cr[$i];
                ListHtmlIndex($cr[$i],null,0);
            }
        }
        elseif($r['doing']==3)//生成自定义列表
        {
            $cr=explode(',',$r['classid']);
            $count=count($cr)-1;
            for($i=1;$i<$count;$i++)
            {
                if(empty($cr[$i]))
                {
                    continue;
                }
                $cr[$i]=(int)$cr[$i];
                $ur=$empire->fetch1(select listid,pagetitle,filepath,filetype,totalsql,listsql,maxnum,lencord,listtempid,pagekeywords,pagedescription from {$dbtbpre}enewsuserlist where listid='.$cr[$i].');
                ReUserlist($ur,);
            }
        }
        elseif($r['doing']==4)//生成自定义页面
        {
            $cr=explode(',',$r['classid']);
            $count=count($cr)-1;
            for($i=1;$i<$count;$i++)
            {
                if(empty($cr[$i]))
                {
                    continue;
                }
                $cr[$i]=(int)$cr[$i];
                $ur=$empire->fetch1(select id,path,pagetext,title,pagetitle,pagekeywords,pagedescription,tempid from {$dbtbpre}enewspage where id='.$cr[$i].');
                ReUserpage($ur['id'],$ur[pagetext],$ur[path],$ur[title],$ur[pagetitle],$ur[pagekeywords],$ur[pagedescription],$ur[tempid]);
            }
        }
        elseif($r['doing']==5)//生成自定义JS
        {
            $cr=explode(',',$r['classid']);
            $count=count($cr)-1;
            for($i=1;$i<$count;$i++)
            {
                if(empty($cr[$i]))
                {
                    continue;
                }
                $cr[$i]=(int)$cr[$i];
                $ur=$empire->fetch1(select jsid,jsname,jssql,jstempid,jsfilename from {$dbtbpre}enewsuserjs where jsid='.$cr[$i].');
                ReUserjs($ur,'');
            }
        }
        elseif($r['doing']==6)//生成标题分类页面
        {
            $cr=explode(',',$r['classid']);
            $count=count($cr)-1;
            for($i=1;$i<$count;$i++)
            {
                if(empty($cr[$i]))
                {
                    continue;
                }
                $cr[$i]=(int)$cr[$i];
                ListHtml($cr[$i],null,5);
            }
        }
        else//生成首页
        {
            $indextemp=GetIndextemp();
            NewsBq(null,$indextemp,1,0);
        }
        $empire->query(update {$dbtbpre}enewsdo set lasttime = $dotime where doid= '$r[doid] ');
    }
    if($b)
    {
        echo 最后执行时间:.date(Y-m-d H:i:s, $dotime);
    }
}
//定时上线/下线
function DoAutoUpAndDownInfo(){
    global $empire,$dbtbpre,$class_r,$emod_r,$public_r;
    $dotime=time();
    $sql=$empire->query(select id,classid,infouptime,infodowntime from {$dbtbpre}enewsinfovote where infouptime>0 or infodowntime>0);
    while($r=$empire->fetch($sql))
    {
        if(!$class_r[$r[classid]]['tbname'])
        {
            continue;
        }
        //上线
        if($r['infouptime']&&$r['infouptime']<=$dotime)
        {
            $infor=$empire->fetch1(select * from {$dbtbpre}ecms_.$class_r[$r[classid]][tbname]._check where id='$r[id]' limit 1);
            if(!$infor['id'])
            {
                continue;
            }
            //签发
            if($infor['isqf'])
            {
                $qfr=$empire->fetch1(select checktno from {$dbtbpre}enewswfinfo where id='$r[id]' and classid='$r[classid]' limit 1);
                if($qfr['checktno']!='100')
                {
                    continue;
                }
            }
            $empire->query(update {$dbtbpre}ecms_.$class_r[$r[classid]][tbname]._index set checked=1 where id='$r[id]' limit 1);
            $pubid=ReturnInfoPubid($r['classid'],$r['id']);
            $empire->query(update {$dbtbpre}enewsinfovote set infouptime=0 where pubid='$pubid' limit 1);
            //互转
            MoveCheckInfoData($class_r[$r[classid]][tbname],0,$infor['stb'],id='$r[id]');
            AddClassInfos($r['classid'],'','+1');
            //刷新信息
            GetHtml($infor['classid'],$infor['id'],$infor,1);
            //刷新列表
            ReListHtml($r[classid],1);
        }
        //下线
        if($r['infodowntime']&&$r['infodowntime']<=$dotime)
        {
            $mid=$class_r[$r[classid]][modid];
            $tbname=$class_r[$r[classid]][tbname];
            $pf=$emod_r[$mid]['pagef'];
            $stf=$emod_r[$mid]['savetxtf'];
            //主表
            $infor=$empire->fetch1(select * from {$dbtbpre}ecms_.$class_r[$r[classid]][tbname]. where id='.$r[id].' limit 1);
            if(!$infor['id'])
            {
                continue;
            }
            //签发
            if($infor['isqf'])
            {
                $qfr=$empire->fetch1(select checktno from {$dbtbpre}enewswfinfo where id='$r[id]' and classid='$r[classid]' limit 1);
                if($qfr['checktno']!='100')
                {
                    continue;
                }
            }
            //分页字段
            if($pf)
            {
                if(strstr($emod_r[$mid]['tbdataf'],','.$pf.','))
                {
                    $finfor=$empire->fetch1(select .$pf. from {$dbtbpre}ecms_.$tbname._data_.$infor[stb]. where id='$r[id]' limit 1);
                    $infor[$pf]=$finfor[$pf];
                }
                if($stf&&$stf==$pf)//存放文本
                {
                    $infor[$pf]=GetTxtFieldText($infor[$pf]);
                }
            }
            DelNewsFile($infor[filename],$infor[newspath],$infor[classid],$infor[$pf],$infor[groupid]);
            $empire->query(update {$dbtbpre}ecms_.$class_r[$r[classid]][tbname]._index set checked=0,havehtml=0 where id='$r[id]' limit 1);
            $pubid=ReturnInfoPubid($r['classid'],$r['id']);
            $empire->query(update {$dbtbpre}enewsinfovote set infodowntime=0 where pubid='$pubid' limit 1);
            //互转
            MoveCheckInfoData($class_r[$r[classid]][tbname],1,$infor['stb'],id='$r[id]');
            AddClassInfos($r['classid'],'','-1');
            //刷新列表
            ReListHtml($r[classid],1);
        }
    }
}
DoTimeRepage();
db_close();
$empire=null;
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
8. 精力有限,不少源码未能详细测试(解密),不能分辨部分源码是病毒还是误报,所以没有进行任何修改,大家使用前请进行甄别
9.本站默认解压密码为:www.sudo1.com
本站提供的一切软件、教程和内容信息仅限用于学习和研究目的。
不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
本站信息来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。
如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。
我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解!

云资源网 » 帝国CMS二次开发不开后台定时刷新脚本

常见问题FAQ

免费下载或者VIP会员专享资源能否直接商用?
本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
提示下载完但解压或打开不了?
最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用百度网盘软件或迅雷下载。 若排除这种情况,可在对应资源底部留言,或 联络我们.。
你们有qq群吗怎么加入?
当然有的,如果你是帝国cms、易优cms、和pbootcms系统的爱好者你可以加入我们的QQ千人交流群https://sudo1.com/page-qun.html。
  • 会员数(个)
  • 12275资源数(个)
  •        
  • 资源(G)
  •        
  • 今日下载
  • 1365稳定运行(天)

提供最优质的资源集合

立即查看 了解详情