dedecms自动更新首页和列表页

elseif($ac='automakehtml'){ //自动生成首页、列表页
$time=ceil($_GET['time']);
if($time==0 || $time==''){$time=1800;}
if($_GET['type']=='index'){ //生成首页
  require_once('last_config.php');
  if((time()-$lasttime)>$time){
require_once(DEDEINC."/arc.partview.class.php");
$row  = $dsql->GetOne("Select * From #@__homepageset");
$dsql->Close();
$templet=$row['templet'];
$position=$row['position'];
$homeFile = dirname(__FILE__)."/../".$position;
$homeFile = str_replace("\\","/",$homeFile);
$homeFile = str_replace("//","/",$homeFile);
$templet = str_replace("{style}",$cfg_df_style,$templet);
$pv = new PartView();
$pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet);
echo $homeFile;
$pv->SaveToHtml($homeFile);
$pv->Close();
$file = fopen("last_config.php","w");
fwrite($file,"<?php\n");
fwrite($file,"\$lasttime=".time().";\n");
fwrite($file,'?>');
fclose($file);
  }
}
elseif($_GET['type']=='templist'){ //生成列表页(注意,只生成第一页)
  $id=ceil($_GET['id']);if($id=='' || $id==0){exit;}
  require_once('last_config1.php');
  if((time()-$templist[$id])>$time){
     $thearray=$templist;
$thearray[$id]=time();
$str='Array(';
foreach($thearray as $key=>$values){
  $str.=$key.'=>\''.$values.'\',';
}
$str.=')';
$file = fopen("last_config1.php","w");
fwrite($file,"<?php\n");
fwrite($file,"\$templist=".$str.";\n");
fwrite($file,'?>');
fclose($file);
require_once(DEDEINC."/arc.partview.class.php");
$row = $dsql->GetOne("Select defaultname,templist,typedir From #@__arctype where id=".$id);
$dsql->Close();
$templet=$row['templist'];
$position=$row['typedir'];
$position=str_replace('{cmspath}',DEDEINC.'/..',$position).'/'.$row['defaultname'];
$templet = str_replace("{style}",$cfg_df_style,$templet);
$pv = new PartView();
$pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet);
$pv->SaveToHtml($position);
$pv->Close();
  } 
}
}


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值