100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 帝国cms自动生成html首页 分享一个帝国CMS定时生成首页(自动刷新首页)的方法...

帝国cms自动生成html首页 分享一个帝国CMS定时生成首页(自动刷新首页)的方法...

时间:2019-07-04 09:31:28

相关推荐

帝国cms自动生成html首页 分享一个帝国CMS定时生成首页(自动刷新首页)的方法...

帝国CMS 自动刷新首页对于部份使用帝国程序的网友或许非常有用。刚看到一篇文章, 主要介绍了javascript与php结合的实现前台自动刷新首页的功能。就算一种方法吧。推荐我喜欢的第二种办法.

第一种方法,摘自网上,粗略看了下。

在 /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)

fopen($filepath_s, 'w');

@chmod($filepath_s, 0777);

ReIndex();

}else{

// do nothing

}

db_close();

$empire=null;

?>###网上流传的是这种办法,懂得自然懂,非常不建议使用!

建议使用以下第二种办法,

就参照上边这个php文件,主要就是个ReIndex()自动刷新函数,具体原理见代码!WINdow系统可以使用自动定时工具(恰好,本站有一个/mysoft/21.html),LINUX建议使用面板里的计划任务。相比较上述办法,非常节约网站资源!

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();

ReIndex();

db_close();

$empire=null;

?>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。