原文来自:https://liye5.com/

  帝国cms怎么自动刷新网站首页?(帝国CMS自动刷新首页的方法)

  目前国内开源建站程序众多。为什么帝国cms使用的用户会这么多呢,我相信大部分人都是看中了帝国CMS程序的信息承载能力,程序安全性等方面,当然了,帝国CMS模板网也是看中了这一点,随着目前帝国CMS建站的的小伙伴越来越多,大家在建站过程中,遇到的问题也就随之增多,例如经常会有朋友问到帝国mcs怎么自动刷新网站首页呢?针对这个问题,帝国CMS模板网小编就来为大家分享,帝国mcs自动刷新网站首页的方法,下面就跟帝国CMS模板网小编一起来看看如何实现吧:

  本文实例讲述了帝国CMS自动刷新首页的方法。分享给大家供大家参考。具体实现方法如下:

  在首页模板中加入下面代码,尽量放在底部。

<scriptlanguage="javascript"type="text/javascript"src="/e/htmlindex/index_html.php"></script>

  在 /e/ 建立文件夹 htmlindex 并设置 777权限,将下面代码保存在
/e/htmlindex/index_html.php,修改刷新时间,将文件中1200改为你想要的时间,单位为秒。

<?php
require("../class/connect.php");
include("../class/db_sql.php");
include("../class/config.php");
include("../class/functions.php");
include("../class/t_functions.php");
requireLoadLang("pub/fun.php");
require("../data/dbcache/class.php");
require("../data/dbcache/MemberLevel.php");
include("../class/chtmlfun.php");
$link=db_connect();
$empire=newmysqlquery();
$filepath_s="indexhtmlhc.txt";
$time=time();
@$filemtime=(int)filemtime($filepath_s)+1200;
/*
函数解释
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)+1200)<time()){
fopen($filepath_s,'w');
@chmod($filepath_s,0777);
ReIndex();
}else{
//donothing
}
db_close();
$empire=null;
?>

  OK,教程结束,看完大家自行去测试吧,看看效果如何!