手机看片精品高清国产日韩,色先锋资源综合网,国产哺乳奶水91在线播放,乱伦小说亚洲色图欧洲电影

幫助中心 >  技術知識庫 >  云服務器 >  服務器教程 >  織夢dedecms定時自動更新首頁的方法

織夢dedecms定時自動更新首頁的方法

2016-06-15 08:15:23 10356

織夢dedecms定時自動更新首頁的方法如下:

1、在 根目錄/plus 目錄下新建一個php文件,命名為:autoindex.php

2、將以下代碼復制到 autoindex.php 文件

<?php

function sp_input( $text )

{

$text = trim( $text );

$text = htmlspecialchars( $text );

if (!get_magic_quotes_gpc())

return addslashes( $text );

else

return $text;

}

$autotime = 3600;//自動更新時間,單位為秒,這里我設為一小時,大家可以自行更改。

$fpath = "../data/last_time.inc";//記錄更新時間文件,如果不能達到目的,請檢查是否有讀取權限。

include( $fpath );

if( empty($last_time))

$last_time = 0;

if( sp_input($_GET['renew'])=="now")

$last_time = 0;

if((time()-$last_time)>=$autotime )

{

define('DEDEADMIN', ereg_replace("[/\]{1,}",'/',dirname(__FILE__) ) );

require_once(DEDEADMIN."/../include/common.inc.php");

require_once(DEDEINC."/arc.partview.class.php");

/*

$row = $dsql->GetOne("select * from dede_homepageset");

$dsql->Close();

$templet=$row['templet'];

$position=$row['position'];

*/

$templet = “tnbjh/index.htm”;//這里是首頁模板位置,當前是dede默認首面位置。

$position = "../index.html";

$homeFile = dirname(__FILE__)."/".$position;

$homeFile = str_replace("\", "/", $homeFile );

$homeFile = str_replace( "//", "/", $homeFile );

$pv = new PartView();

$pv ->SetTemplet( $cfg_basedir.$cfg_templets_dir."/".$templet );

$pv -> SaveToHtml( $homeFile );

$pv -> Close();

$file = fopen( $fpath, "w");

fwrite( $file, "<?php ");

fwrite( $file,"$last_time=".time()."; ");

fwrite( $file, '?>' );

fclose( $file );

}

?>

3、在首頁模板的<head></head>標簽中加入如下代碼

<script src="/plus/autoindex.php" language="javascript"></script>


提交成功!非常感謝您的反饋,我們會繼續努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務,我們很需要您進一步的反饋信息:

在文檔使用中是否遇到以下問題: