帝国CMS自动刷新生成首页代码和方法

admin4个月前未分类61

一般来说,我们使用帝国CMS建站系统都是采用静态生成html页面的方式,这样可以大大的节约服务器开销,在某些特殊情况下,我们的需求是让帝国CMS自动刷新生成首页,那么问题来了,我们该如何实现了?下面IT备忘录小编就给大家分享解决方法。方法步骤:

方法一:

采用:登陆后台->系统设置->“管理计划任务”->“增加计划任务”,但是这种官方提示需要登录后台的情况下才可以。

方法二:

1、在 /e/ 建立文件夹 autohtml 并设置 777权限(可读写),将下面代码保存在 /e/autohtml/index_html.php,修改刷新时间,将文件中:600,改为你想要的时间,单位为:


  • <?php

  • require("../class/connect.php");

  • include("../class/db_sql.php");

  • include("../class/config.php");

  • include("../class/functions.php");

  • include("../class/t_functions.php");

  • require LoadLang("pub/fun.php");

  • require("../data/dbcache/class.php");

  • require("../data/dbcache/MemberLevel.php");

  • include("../class/chtmlfun.php");

  • $link=db_connect();

  • $empire=new mysqlquery();

  • $filepath_s="indexhtmlhc.txt";

  • $time=time();

  • @$filemtime=(int)filemtime($filepath_s)+600;

  • /*

  • 函数解释

  • file_exists() 函数检查文件或目录是否存在。

  • mkdir() 函数创建目录。

  • time() 函数返回当前时间的 Unix 时间戳。

  • filemtime() 函数返回文件内容上次的修改时间。

  • */

  • if (!file_exists($filepath_s)){

  • fopen($filepath_s'w');

  • @chmod($filepath_s0777);

  • ReIndex();

  • }elseif(!file_exists($filepath_s) || (filemtime($filepath_s)+600)<time()){

  • fopen($filepath_s'w');

  • @chmod($filepath_s0777);

  • ReIndex();

  • }else{

  • // do nothing

  • }

  • db_close();

  • $empire=null;

  • ?>

2、再将以下代码插入:首页模板 底部即可,当有访客访问网站的时候就会触发机制。


  • <script language="javascript" type="text/javascript" src="/e/autohtml/index_html.php"></script>

温馨提示

1、大家可以自行修改文件的存放路径。

2、其实第二段代码也可以不放到网站首页模板,用宝塔面板的用户可以在面板上增加此链接的计划任务,设置好间隔时间即可。


相关文章

宝塔计划任务定时删除系统日志(脚本):

find /www/backup/database -name "*.gz" -exec rm -rf {} \;find /www/backup/site -name "...

discuz关于出现“对不起,您安装的不是正版应用..”的解决办法

最近很多会员朋友反映一个问题:有些插件和风格在安装时出现不能安装的现象,出现以下提示:对不起,您安装的不是正版应用,安装程序无法继续执行点击这里安装正版应用点击这里返回上一页针对这一情况,本人从网络上...

未命名

AB1包站价格8万/月 不议价 【267个站点,均为独立站点】欢迎老板咨询2域名信息标题3https://baipiaowang.org白嫖网社区-白嫖网4https://www.bcwangzhan...

帝国

 3:修改 phome_enewsuser 表中的如下四个字段的值username:adminpassword:28faed7bf0c97624ad3b8737b6947e41salt1:f...

小工具

GIZ压缩检测https://www.giftofspeed.com/gzip-test/https://tool.chinaz.com/gzips    ...

discuz 删除安装应用安全密码

common_setting 表的siteuniqueid 删除...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。