To teach you to dream Dede automatically update the home page method

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Everyone good, I am hacklei, I play Dede time is not long, only 2 months, Dede program now use a lot of people. Because it is very easy to use, even if the novice can be used to quickly build Dede station, I would like to tell you to weave the dream of Automatic Updates the first method.

If the homepage of the website uses the CMS that supports the random call article, such as: dedecms, content is collected, and you do not have much time to update the content manually, but want to let Baidu like your website, use this small program will be quite useful and convenient to you.
The code is as follows:

<?php
Set_time_limit (0);
Your site's CMS root URL, end do not add/
$BASECMSURL = "http://www.examx.cn";
The name of the dynamic home page
$dmPageName = "index.php";
The name of the static home page
$stPageName = "index.html";
How often do you want to update the unit in seconds?
$mkTime = 3600;
Here is the code that executes
$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 in the static HTML end of the home page
<script language= ' javascript ' src= ' task.php ' ></script>.

The above code is available in both Dedecms and Phpcms, ECMs may not work, but it seems to have a scheduled task function, but there is no random call to the function to use this is useless.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.