时间:2016-02-16 19:42 来源: 我爱IT技术网 作者:佚名
欢迎您访问我爱IT技术网,今天小编为你分享的电脑教程之dedeCMS系列教程:【dedecms首页调用随机文章及自动更新功能实例】,请阅读以下详细内容!
dedecms首页调用随机文章及自动更新功能实例
<?phpfunction 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( emptyempty($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");
$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\n");
fwrite( $file,"\$last_time=".time().";\n");
fwrite( $file, '?>' );
fclose( $file );
}
?>
关于dedecms首页调用随机文章及自动更新功能实例的用户互动如下:
相关问题:
答: >>详细
相关问题:
答: >>详细
相关问题:
答: >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
