帝国cms自动刷新网站首页方法.jpg

我相信很多朋友使用帝国cms都是看中了它的信息承载量,但是你在做采集的时候首页栏目你设置成静态他是不刷新的,今天家兴网络方向下这个问题的解决方法!

我们需要在首页底部模板中加入代码:

<script language="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"); 
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)+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{ 
// do nothing 
} 
db_close(); 
$empire=null; 
?>


看了家兴网络分享的帝国cms自动刷新网站首页方法您看了如何还有什么疑问?欢迎给我留言,感觉分享的内容对您有帮助请点赞或者分享给你的站长朋友吧!