代码如下:
<?php
set_time_limit(0);
//你网站的CMS根网址,结束不要加 /
$baseCmsUrl = "http://www.chinaz.com";
//动态主页的名称
$dmPageName = "index.php";
//静态主页的名称
$stPageName = "index.html";
//你希望多长时间更新一次,单位是秒
$mkTime = 3600;
//下面是执行的代码
$tureStFile = dirname(__FILE__).'/'.$stPageName;
$ftime = @filemtime($tureStFile);
if(!file_exists($tureStFile) || ($ftime < time()-$mkTime))
{
$body = file_get_contents($baseCmsUrl.'/'.$dmPageName);
$fp = fopen($tureStFile, 'w');
fwrite($fp, $body);
fclose($fp);
}
?>
ds将上述代码保存为 task.php ,然后在主页的静态HTML结尾引入下面的JS。
<script language="javascript" src="task.php"></script>