
在你的操作系统,如果是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)
{
$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后台不开能定时刷新的脚本信息内容原创度和真实性等负责。如内容侵犯您的版权或其他权益,请留言并加以说明。站长审查之后若情况属实会及时为您删除。同时遵循 CC 4.0 BY-SA 版权协议,尊重和保护作者的劳动成果,转载请标明出处链接和本声明内容。本文作者:王封安» /dmh/4061.html
很赞哦! (0)