NewsBq |
e/class/functions.php |
//标签替换
function NewsBq($classid,$indextext,$enews=0,$doing=0){
global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$class_zr,$fun_r,$navclassid,$navinfor,$class_tr,$level_r,$etable_r;
$indextext=stripSlashes($indextext);
$indextext=ReplaceTempvar($indextext);//替换全局模板变量
$classlevel='';
if($enews==0)//生成大栏目
{
if($class_r[$classid]['listdt']||$class_r[$classid]['wburl']||strstr($public_r['nreclass'],','.$classid.',')||InfoIsInTable($class_r[$classid]['tbname']))//不生成栏目
{
return '';
}
$GLOBALS['navclassid']=$classid;
$url=ReturnClassLink($classid);//导航
$cf=$doing==1?',classpath,classtype,classname':'';
$cr=$empire->fetch1("select classpagekey,intro,classimg,cgroupid".$cf." from {$dbtbpre}enewsclass where classid='$classid'");
if(!empty($cf))
{
$class_r[$classid][classpath]=$cr[classpath];
$class_r[$classid][classtype]=$cr[classtype];
$class_r[$classid][classname]=$cr[classname];
}
//权限
if($cr['cgroupid'])
{
$classlevel=AddCheckClassLevel($classid,$cr['cgroupid'],'');
}
//页面
$pagetitle=ehtmlspecialchars($class_r[$classid][classname]);
$pagekey=ehtmlspecialchars($cr['classpagekey']);
$pagedes=ehtmlspecialchars($cr['intro']);
$classimg=$cr['classimg'];
$onclick="<script src=".$public_r[newsurl]."e/public/onclick/?enews=doclass&classid=$classid></script>";
$truefile=eReturnTrueEcmsPath().ReturnSaveClassPath($classid,1);//moreport
$file=ECMS_PATH.'e/data/tmp/class'.$classid.'.php';
$indextext=str_replace("[!--newsnav--]",$url,$indextext);//位置导航
$indextext=Class_ReplaceSvars($indextext,$url,$classid,$pagetitle,$pagekey,$pagedes,$classimg,$add,0);
}
elseif($enews==3)//专题
{
$GLOBALS['navclassid']=$classid;
$url=ReturnZtLink($classid);//导航
$cf=$doing==1?',ztpath,zttype,ztname':'';
$cr=$empire->fetch1("select ztpagekey,intro,ztimg".$cf." from {$dbtbpre}enewszt where ztid='$classid'");
if(!empty($cf))
{
$class_zr[$classid][ztpath]=$cr[ztpath];
$class_zr[$classid][zttype]=$cr[zttype];
$class_zr[$classid][ztname]=$cr[ztname];
}
$pagetitle=ehtmlspecialchars($class_zr[$classid][ztname]);
$pagekey=ehtmlspecialchars($cr['ztpagekey']);
$pagedes=ehtmlspecialchars($cr['intro']);
$classimg=$cr['ztimg'];
$onclick="<script src=".$public_r[newsurl]."e/public/onclick/?enews=dozt&ztid=$classid></script>";
$truefile=ECMS_PATH.ReturnSaveZtPath($classid,1);
$file=ECMS_PATH.'e/data/tmp/zt'.$classid.'.php';
$indextext=str_replace("[!--newsnav--]",$url,$indextext);//位置导航
$indextext=Class_ReplaceSvars($indextext,$url,$classid,$pagetitle,$pagekey,$pagedes,$classimg,$add,1);
}
elseif($enews==4)//专题子类
{
$cr=$empire->fetch1("select ztid,cname,ttype from {$dbtbpre}enewszttype where cid='$classid'");
$GLOBALS['navclassid']=$classid;
$GLOBALS['navinfor']['ecmsbid']=$cr['ztid'];
$url=ReturnZtLink($cr['ztid']);//导航
$pagetitle=ehtmlspecialchars($cr['cname']);
$pagekey=ehtmlspecialchars($cr['cname']);
$pagedes=ehtmlspecialchars($cr['cname']);
$onclick="<script src=".$public_r[newsurl]."e/public/onclick/?enews=dozt&ztid=$cr[ztid]></script>";
$truefile=ECMS_PATH.ReturnSaveZtPath($cr['ztid'],0).'/type'.$classid.$cr['ttype'];
$file=ECMS_PATH.'e/data/tmp/ztc'.$classid.'.php';
$indextext=str_replace("[!--newsnav--]",$url,$indextext);//位置导航
$indextext=Class_ReplaceSvars($indextext,$url,$classid,$pagetitle,$pagekey,$pagedes,$classimg,$add,1);
}
elseif($enews==1)//生成首页文件
{
$pr=$empire->fetch1("select sitekey,siteintro,indexpagedt from {$dbtbpre}enewspublic limit 1");
if($pr['indexpagedt']||(Moreport_ReturnMustDt()&&!defined('ECMS_SELFPATH')))//moreport
{
return '';
}
//页面
$pagetitle=ehtmlspecialchars($public_r['sitename']);
$pagekey=ehtmlspecialchars($pr['sitekey']);
$pagedes=ehtmlspecialchars($pr['siteintro']);
$url="<a href="".ReturnSiteIndexUrl()."">".$fun_r['index']."</a>";//栏目导航
$onclick='';
$truefile=eReturnTrueEcmsPath().ReturnSaveIndexFile();//moreport
$file=ECMS_PATH.'e/data/tmp/index.php';
$indextext=ReplaceSvars($indextext,$url,0,$pagetitle,$pagekey,$pagedes,$add,0);
}
$indextext=str_replace("[!--page.stats--]",$onclick,$indextext);
//替换标签
$indextext=DoRepEcmsLoopBq($indextext);
$indextext=RepBq($indextext);
//写文件
WriteFiletext($file,AddCheckViewTempCode().$indextext);
//读取文件内容
ob_start();
include($file);
$string=ob_get_contents();
ob_end_clean();
$string=RepExeCode($string);//解析代码
WriteFiletext($truefile,$classlevel.$string);
return $string;
} |