Home > CMS Tutorial > DEDECMS > How to automatically update the homepage of DEDECMS

How to automatically update the homepage of DEDECMS

藏色散人
Release: 2019-12-10 09:32:50
Original
2459 people have browsed it

How to automatically update the homepage of DEDECMS

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__).&#39;/&#39;.$stPageName;
$ftime = @filemtime($tureStFile);
if(!file_exists($tureStFile) || ($ftime < time()-$mkTime))
{
$body = file_get_contents($baseCmsUrl.&#39;/&#39;.$dmPageName);
$fp = fopen($tureStFile, &#39;w&#39;);
fwrite($fp, $body);
fclose($fp);
}
?>
Copy after login

Save the above code as task.php

Then introduce the following JS at the end of the static HTML on the homepage

<script language=&#39;javascript&#39; src=&#39;task.php&#39;></script>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template