时间:2021-07-21人气:-
<?phpset_time_limit(0);//你网站的CMS根网址,结束不要加 /$baseCmsUrl = "http://www.examx.cn";//动态主页的名称$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);}?>
将上述代码保存为 task.php
然后在主页的静态HTML结尾引入下面的JS
<script language='javascript' src='task.php'></script>。
以上代码在dedecms和phpcms中均可用,ecms可能是不行的,不过它似乎有计划任务功能,但没有随机调用的功能用这个也没用。