POST TIME:2020-04-10 18:53
<?php
set_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可能是不行的,不過它似乎有計劃任務功能,但沒有隨機調用的功能用這個也沒用。