您现在的位置是:首页 > cms教程 > 帝国CMS教程帝国CMS教程
帝国CMS后台不开能定时刷新的脚本
王封安2023-05-17帝国CMS教程已有人查阅
导读在你的操作系统,如果是Linux的话,添加以下计划任务。 * * * * * /usr/bin/php /webrootpath/e/tasks/backend_cronjob.php。

在你的操作系统,如果是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;
本文标签:
很赞哦! ()
相关教程
图文教程
帝国CMS灵动标签怎么调用友情链接的方法
帝国CMS默认的友情链接标签内置的格式太坑了,无法满足个性化需求。可使用灵动标签来调用:调用文字链接:
帝国CMS8.0新增支持PostgreSQL和国产数据库
帝国CMS8.0版在原来版本支持MySQL、MariaDB、其它MySQL内核的数据库基础上,还新增支持postgreSQL、国产华为高斯(openGauss)、国产金仓数据库(kingbase)
帝国CMS安装和下载教程
1、进入帝国CMS官方网站2、进入帝国CMS官方网站下载专区,下载对应版本帝国CMS,不懂的朋友可以问客服3、下载完成后解压帝国CMS安装文件压缩包4、点击进
帝国CMS上传文件随机生成的名前面怎么加自定义前缀的方法
帝国CMS默认上传文件后生成一个32位的随机名称。通过本教程可以在这个32位的随机名称前增加固定名称。
相关源码
-
(自适应)中英双语配线器材扎带线卡网站pbootcms模板免费下载为线缆管理、电气配线领域打造的响应式网站模板,采用PbootCMS内核开发,可快速搭建企业级产品展示平台,数据实时同步管理。查看源码 -
(PC+WAP)货运物流快递仓储货架pbootcms网站模板下载本模板基于PbootCMS开发,为货运物流、快递配送、仓储货架等行业设计,支持PC+WAP自适应,确保在电脑、手机、平板等设备上均能流畅访问。适用于物流公司、仓储企业查看源码 -
(自适应)黑色摄影作品工作室pbootcms模板网站源码下载为风景摄影、个人工作室打造的高端网站模板,基于PbootCMS开源内核开发,采用HTML5自适应架构,PC与移动端实时数据同步,适配各类拍摄作品展示需求。查看源码 -
(自适应html5)重工业钢铁机械设备网站pbootcms响应式模板下载为重工业领域打造的响应式网站模板,助力企业高效展示产品与服务,基于PbootCMS开发的工业级网站模板,特别适合钢铁制造、机械设备生产等重工业企业使用。查看源码 -
pbootcms模板PC+WAP娱乐新闻资讯类博客网站源码该模板基于PbootCMS内核开发,专为娱乐新闻、健康生活类资讯网站设计,同时支持快速适配其他行业(如企业官网、博客门户等),仅需替换图文内容即可完成转型。查看源码 -
(自适应)响应式文章博客互联网新闻pbootcms模板下载本模板基于PbootCMS开发,专为科技新闻、互联网资讯和文章博客类网站设计。采用响应式布局技术,确保在电脑、平板和手机上都能获得最佳浏览体验。适用于科技媒体、行业博客查看源码
| 分享笔记 (共有 篇笔记) |

