How to automatically update the homepage of DEDECMS?
Hello everyone, I have not been playing with DEDECMS for a long time, just over 2 months. Many people are using the DEDECMS program now. Because it is easy to use and convenient, even novices can quickly use DEDECMS to build a website. Now I will tell you how to automatically update the homepage of Dreamweaver regularly.
Recommended learning: 梦Weavercms
If the website homepage uses a CMS that supports random call articles, such as: dedecms, the content is collected, and you don’t have much If you don't have time to manually update the content, but you want Baidu to like your website, using this small program will be quite useful and convenient for you.
The code is as follows:
<?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); } ?>
Save the above code as task.php
Then introduce the following JS at the end of the static HTML on the homepage
<script language='javascript' src='task.php'></script>
The above code It is available in both dedecms and phpcms. Ecms may not work, but it seems to have a scheduled task function, but it is useless without a random call function.
The above is the detailed content of How to automatically update the homepage of DEDECMS. For more information, please follow other related articles on the PHP Chinese website!