帝国CMS自动刷新生成首页代码和方法
时间:2023年12月13日
/来源:网络
/编辑:佚名
一般来说,我们使用帝国CMS建站系统都是采用静态生成html页面的方式,这样可以大大的节约服务器开销,在某些特殊情况下,我们的需求是让帝国CMS自动刷新生成首页,那么问题来了,我们该如何实现了?下面IT备忘录小编就给大家分享解决方法。
帝国CMS自动刷新生成首页代码和方法
方法步骤:
方法一:
采用:登陆后台->系统设置->“管理计划任务”->“增加计划任务”,但是这种官方提示需要登录后台的情况下才可以。
方法二:
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_s, 0777);
ReIndex();
}elseif(!file_exists($filepath_s) || (filemtime($filepath_s)+600)<time()){
fopen($filepath_s, 'w');
@chmod($filepath_s, 0777);
ReIndex();
}else{
// do nothing
}
db_close();
$empire=null;
?>
2、再将以下代码插入:首页模板 底部即可,当有访客访问网站的时候就会触发机制。
<script language="javascript" type="text/javascript" src="/e/autohtml/index_html.php"></script>
温馨提示:
1、大家可以自行修改文件的存放路径。
2、其实第二段代码也可以不放到网站首页模板,用宝塔面板的用户可以在面板上增加此链接的计划任务,设置好间隔时间即可。
帝国CMS自动刷新生成首页代码和方法
方法步骤:
方法一:
采用:登陆后台->系统设置->“管理计划任务”->“增加计划任务”,但是这种官方提示需要登录后台的情况下才可以。
方法二:
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_s, 0777);
ReIndex();
}elseif(!file_exists($filepath_s) || (filemtime($filepath_s)+600)<time()){
fopen($filepath_s, 'w');
@chmod($filepath_s, 0777);
ReIndex();
}else{
// do nothing
}
db_close();
$empire=null;
?>
2、再将以下代码插入:首页模板 底部即可,当有访客访问网站的时候就会触发机制。
<script language="javascript" type="text/javascript" src="/e/autohtml/index_html.php"></script>
温馨提示:
1、大家可以自行修改文件的存放路径。
2、其实第二段代码也可以不放到网站首页模板,用宝塔面板的用户可以在面板上增加此链接的计划任务,设置好间隔时间即可。
新闻资讯 更多
- 【帝国cms教程】帝国CMS模板变量$GLOBALS[navclassid]用法分析04-03
- 【帝国cms教程】鲜为人知帝国CMS内容页调用上一篇和下一篇的精华方法汇总04-03
- 【帝国cms教程】怎么快速找出帝国CMS数据库配置文件路径及迁移网站后修改技巧!04-03
- 【帝国cms教程】帝国CMS模板$GLOBALS[navclassid]用法详解04-03
- 【帝国cms教程】帝国cms 7.5版列表页分页样式修改笔记04-02
- 【帝国cms教程】解决帝国CMS搜索页面模板不支持灵动标签和万能标签的方法04-02
- 【帝国cms教程】帝国CMS只备份栏目和模板的方法04-02
- 【帝国cms教程】帝国CMS怎样删除清空数据库记录?04-02
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法