帝國CMS的前台定時執行刷新任務插件,可替代需要開着后台才會執行刷新任務。
帝國cms官方插件下載地址:http://bbs.phome.net/showthread-31-196160-0.html
******************** 安裝插件 ********************
1、將“upload”目錄下的文件上傳至帝國CMS系統目錄,即把DoTimeRepage目錄,放到/e/extend/中,安裝后路徑是:/e/extend/DoTimeRepage/;
2、插件安裝完畢。
******************** 卸載插件 ********************
1、刪除 /e/extend/DoTimeRepage/ 目錄;
2、插件卸載完畢。
******************** 插件使用 ********************
1、在經常被訪問到的頁面(比如:首頁)最底部加上如下代碼即可:(兩種方式選其一)
(1)、JS調用方式:
<script src="[!--news.url--]e/extend/DoTimeRepage/"></script>
(2)、框架調用方式:
<IFRAME frameBorder="0" width="0" height="0" marginWidth="0" marginHeight="0" id="dorepage" name="dorepage" scrolling="no" src="[!--news.url--]e/extend/DoTimeRepage/"></IFRAME>
2、生成相應頁面。
(刷新任務增加:后台>“系統”>“計划任務”>“管理刷新任務”。信息定時上下線:增加信息時選項設置里可以設置定時發布。)
******************** 插件目錄說明 ********************
/e/extend/DoTimeRepage/ 前台定時執行刷新任務插件目錄
└index.php 執行刷新任務程序文件
注意事項:上傳插件,在頁面中調用插件,生成前台頁面,這樣當訪客訪問前台頁面時,會觸發頁面中的插件代碼,從而啟動刷新計划任務。
例如:你設置了一個計划任務,5分鍾后執行。那么訪客在5分鍾內訪問頁面,是不會觸發計划任務的,必須是5分鍾后,訪問頁面才會觸發插件。這一點需要注意一下。
e/extend/DoTimeRepage/index.php源碼如下:
<?php require("../../class/connect.php"); require("../../class/db_sql.php"); require("../../class/functions.php"); require "../".LoadLang("pub/fun.php"); require("../../class/delpath.php"); require("../../class/copypath.php"); require("../../class/t_functions.php"); require("../../data/dbcache/class.php"); require("../../data/dbcache/MemberLevel.php"); $link=db_connect(); $empire=new mysqlquery(); $editor=1; @set_time_limit(0); //加載 $incftp=0; if($public_r['phpmode']) { include("../../class/ftp.php"); $incftp=1; } //防采集 if($public_r['opennotcj']) { @include("../../data/dbcache/notcj.php"); } //定時刷新任務 function user_DoTimeRepage(){ global $empire,$dbtbpre; user_DoAutoUpAndDownInfo();//自動上/下線 $todaytime=time(); $b=0; $sql=$empire->query("select doing,classid,doid from {$dbtbpre}enewsdo where isopen=1 and lasttime+dotime*60<$todaytime"); 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],$ret_r[0],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],$ret_r,5); } } else//生成首頁 { $indextemp=GetIndextemp(); NewsBq($classid,$indextemp,1,0); } $empire->query("update {$dbtbpre}enewsdo set lasttime=$todaytime where doid='$r[doid]'"); } if($b) { //echo "最后執行時間:".date("Y-m-d H:i:s",$todaytime)."<br><br>"; } } //定時上線/下線 function user_DoAutoUpAndDownInfo(){ global $empire,$dbtbpre,$class_r,$emod_r,$public_r; $todaytime=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']<=$todaytime) { $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']<=$todaytime) { $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); } } } user_DoTimeRepage();//自動刷新頁面 db_close(); $empire=null; ?>