使用織夢(mèng)的朋友都知道首頁(yè)添加完隨機(jī)文章板塊后不會(huì)實(shí)現(xiàn)自動(dòng)更新,那怎樣才能實(shí)現(xiàn)隨機(jī)文章自動(dòng)更新呢?
第一步、復(fù)制下面紅色部分內(nèi)容到記事本,完成后,另存為名稱為autoindex.php的文件,并將其上傳到織夢(mèng)plus文件夾<?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”;
$position = "../index.html";
$homeFile = dirname(__FILE__)."/".$position;
$homeFile = str_replace("\\", "/", $homeFile );
$homeFile = str_replace( "http://", "/", $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 );
}
?>
第二步、登錄織夢(mèng)后臺(tái),在head.htm文件中加入下面代碼,我加在了<!-- //header -->前面
<script src="/plus/autoindex.php" language="javascript"></script>溫馨提示:千萬(wàn)不要上傳到錯(cuò)誤位置,否則會(huì)調(diào)用不成功!
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源:
創(chuàng)新互聯(lián)