一个新鲜、有趣、有料的网络营销个人博客

帝国cms 专题伪静态

<?php
require(‘../class/connect.php’);
require(‘../class/db_sql.php’);
require(‘../class/functions.php’);
require(‘../class/t_functions.php’);
require(‘../data/dbcache/class.php’);
require LoadLang(‘pub/fun.php’);
$link=db_connect();
$empire=new mysqlquery();
$editor=1;
$classid=RepPostStr($_GET[‘classid’]);//修改过滤方式–yognlan
//获取真实专题ID–kun588.com
$ztr=$empire->fetch1(“select * from {$dbtbpre}enewszt where ztpath=’$classid'”);
$listtempid=$ztr[‘listtempid’];
$ztid=$ztr[‘ztid’];
$intro=$ztr[‘intro’];
//获取真实classid–yognlan
if(!is_numeric($classid)){
foreach ($class_r as $val){
foreach ($val as $val2){
if($classid==$val[‘classpath’]){
$classid=$val[‘classid’];
break;
}
}
}
}
if(!$ztid){
if(empty($classid))
{
printerror(“ErrorUrl”,”history.go(-1)”,1);
}
$search=’&classid=’.$classid;
$tbname=$class_r[$classid][tbname];
$mid=$class_r[$classid][modid];
if(empty($tbname)||empty($mid)||InfoIsInTable($tbname))
{
printerror(“ErrorUrl”,”history.go(-1)”,1);
}
$cr=$empire->fetch1(“select classid,classpagekey,intro,classimg,cgroupid,islist,classtempid,listdt,bdinfoid,repagenum,islast,infos from {$dbtbpre}enewsclass where classid=’$classid'”);
if(empty($cr[‘classid’]))
{
printerror(“ErrorUrl”,”history.go(-1)”,1);
}
if($class_r[$classid][islast]&&$cr[‘bdinfoid’])
{
printerror(“ErrorUrl”,”history.go(-1)”,1);
}
}
//是否支持动态页
/*伪静态不需要
if(empty($class_r[$classid][‘listdt’])&&!$cr[‘repagenum’])
{
$classurl=sys_ReturnBqClassname($cr,9);
Header(“Location:$classurl”);
exit();
}
*/
//权限
if($cr[‘cgroupid’])
{
$mgroupid=(int)getcvar(‘mlgroupid’);
if(!strstr($cr[cgroupid],’,’.$mgroupid.’,’))
{
printerror(‘NotLevelToClass’,’history.go(-1)’,1);
}
}
$GLOBALS[‘navclassid’]=$classid;
if($ztid){
$url=ReturnZtLink($ztid);
}else{
$url=ReturnClassLink($classid);
}
$pagetitle=$class_r[$classid][‘classname’];
$pagekey=$cr[‘classpagekey’];
$pagedes=$cr[‘intro’];
$classimg=$cr[‘classimg’]?$cr[‘classimg’]:$public_r[newsurl].’e/data/images/notimg.gif’;
//—封面式—
if(!$ztid){
if(!$class_r[$classid][islast]&&$cr[‘islist’]!=1)
{
/*伪静态不需要 —yonglan
if(empty($cr[‘listdt’])||$cr[‘islist’]==3)
{
printerror(“ErrorUrl”,”history.go(-1)”,1);
}
*/
if($cr[islist]==2)
{
$classtemp=GetClassText($classid);
$dttempname=’classpage’.$classid;
}
else
{
if(empty($cr[‘classtempid’]))
{
printerror(‘ErrorUrl’,”,1);
}
$classtemp=GetClassTemp($cr[‘classtempid’]);
$dttempname=’classtemp’.$cr[‘classtempid’];
}
$string=DtNewsBq($dttempname,$classtemp,0);
$string=str_replace(‘[!–newsnav–]’,$url,$string);//位置导航
$string=Class_ReplaceSvars($string,$url,$classid,$pagetitle,$pagekey,$pagedes,$classimg,$addr,0);
$string=str_replace(‘[!–page.stats–]’,”,$string);
echo stripSlashes($string);
exit();
}
}
//—列表式—
$add=”;
//栏目
if($class_r[$classid][islast])//终极栏目
{
$add.=”classid=’$classid'”;
$have_class=0;
}
else
{
$add.=ReturnClass($class_r[$classid][sonclass]);
$have_class=1;
}
//排序
if(empty($class_r[$classid][reorder]))
{
$addorder=”newstime desc”;
}
else
{
$addorder=$class_r[$classid][reorder];
}
//列表模板
if($ztid){
$tempid=$listtempid;
}else{
$tempid=$class_r[$classid][‘dtlisttempid’]?$class_r[$classid][‘dtlisttempid’]:$class_r[$classid][‘listtempid’];
}
if(empty($tempid))
{
printerror(‘ErrorUrl’,”,1);
}
$tempr=$empire->fetch1(“select tempid,temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from “.GetTemptb(“enewslisttemp”).” where tempid=’$tempid'”);
if(empty($tempr[tempid]))
{
printerror(‘ErrorUrl’,”,1);
}
$page=(int)substr($_GET[‘page’],6);//page是带index-所以去掉—-yonglan
$page=RepPIntvar($page)?RepPIntvar($page):1;
$start=0;
$line=$class_r[$classid][‘lencord’];//每页显示记录数
$page_line=10;//每页显示链接数

$offset=$page*$line-$line;//总偏移量
//系统模型
$ret_r=ReturnReplaceListF($mid);
//优化
$yhadd=”;
$yhid=$class_r[$classid][yhid];
$yhvar=’qlist’;
if($yhid)
{
$yhadd=ReturnYhSql($yhid,$yhvar,1);
}
//总数
$totalnum=(int)$_GET[‘totalnum’];

$addd=”;
$search=’&ztid=’.$ztid.$ecms_hashur[‘ehref’];
//专题子类
$cid=(int)$_GET[‘cid’];
if($cid)
{
$addd.=” and cid=’$cid'”;
$search.=’&cid=’.$cid;
}
//系统模型
$mid=(int)$_GET[‘mid’];
if($mid)
{
$addd.=” and mid=’$mid'”;
$search.=’&mid=’.$mid;
}
//栏目
$classid=(int)$_GET[‘classid’];
if($classid)
{
$addd.=’ and ‘.($class_r[$classid][islast]?”classid=’$classid'”:”(“.ReturnClass($class_r[$classid][sonclass]).”)”);
}
if($totalnum<1)
{
if($ztid){
//当前专题信息数–kun588.com
$totalquery=”select count(*) as total from {$dbtbpre}enewsztinfo where ztid=’$ztid'”.$addd;
$num=$empire->gettotal($totalquery);
}else{
if($yhadd)
{
$totalquery=”select count(*) as total from {$dbtbpre}ecms_”.$tbname.” where “.$yhadd.$add;
$num=$empire->gettotal($totalquery);
}
else
{
$num=ReturnClassInfoNum($cr,0);
}
}
}
else
{
$num=$totalnum;
}

$myorder=(int)$_GET[‘myorder’];
if($myorder==1)
{
$doorder=’newstime desc’;
}
elseif($myorder==2)
{
$doorder=’newstime asc’;
}
elseif($myorder==3)
{
$doorder=’newstime desc’;
}
elseif($myorder==4)
{
$doorder=’newstime asc’;
}
else
{
$doorder=’newstime desc’;
}
//专题数据–kun588.com
if($ztid){
//取专题所在表–kun588.com
$rr=$empire->fetch1(“select * from {$dbtbpre}enewsztinfo where ztid=”.$ztid.””.$addd);
$tbname=$class_r[$rr[classid]][‘tbname’];
$query=”select a.* from {$dbtbpre}ecms_”.$tbname.” a,{$dbtbpre}enewsztinfo b where a.id=b.id  and (b.ztid=”.$ztid.” or b.ztid=”.$ztid.”) “;
$query.=”order by “.$doorder.” limit $offset,$line”;
$sql=$empire->query($query);
}else{
$query=”select “.ReturnSqlListF($mid).” from {$dbtbpre}ecms_”.$tbname.” where “.$yhadd.$add;
$query.=” order by “.ReturnSetTopSql(‘list’).$addorder.” limit $offset,$line”;
$sql=$empire->query($query);
}
//伪静态
$pagefunr=eReturnRewriteClassUrl($classid,0);
$pagefunr[‘repagenum’]=$cr[‘repagenum’];
$pagefunr[‘dolink’]=empty($class_r[$classid][‘classurl’])?$public_r[‘newsurl’].$class_r[$classid][‘classpath’].’/’:$class_r[$classid][‘classurl’].’/’;
$pagefunr[‘dofile’]=’index’;
$pagefunr[‘dotype’]=$class_r[$classid][‘classtype’];
//分页
/*不用默认分页了—yonglan
if($pagefunr[‘rewrite’]==1||$pagefunr[‘repagenum’])
{
$listpage=InfoUsePage($num,$line,$page_line,$start,$page,$search,$pagefunr);
}
else
{
$listpage=page1($num,$line,$page_line,$start,$page,$search);
}
*/
$listpage=yl_pagelist($num,$line,$page_line,$start,$page);//自己加的分页—yonglan
function yl_pagelist($num,$line,$page_line,$start,$page){//自己加的分页函数—yonglan
global $fun_r;
if($num<=$line)
{
return ”;
}
$f=’_’;//伪静态分页分割符号
$url=preg_replace(‘/_[0-9]+/’, ”, $_SERVER[‘HTTP_X_REWRITE_URL’]?$_SERVER[‘HTTP_X_REWRITE_URL’]:$_SERVER[‘REQUEST_URI’]);
if(!strripos($url,’.’)){
$url=$url.’index.html’;
}
$urlarr=explode(‘.’, $url);
$snum=3;//最小页数
$totalpage=ceil($num/$line);//取得总页数
$firststr='<a title=”‘.$fun_r[‘trecord’].'”>&nbsp;<b>’.$num.'</b> </a>&nbsp;&nbsp;’;
//上一页
if($page<>0)
{
$toppage='<a href=”‘.substr($urlarr[0],0,-5).'”>’.$fun_r[‘startpage’].'</a>&nbsp;’;
$pagepr=$page-1;
if($pagepr==1){
$prepage='<a href=”‘.substr($urlarr[0],0,-5).'”>’.$fun_r[‘pripage’].'</a>&nbsp;’;
}else{
$prepage='<a href=”‘.$urlarr[0].$f.$pagepr.’.’.$urlarr[1].'”>’.$fun_r[‘pripage’].'</a>’;
}

}
//下一页
if($page!=$totalpage)
{
$pagenex=$page+1;
$nextpage=’&nbsp;<a href=”‘.$urlarr[0].$f.$pagenex.’.’.$urlarr[1].'”>’.$fun_r[‘nextpage’].'</a>’;
$lastpage=’&nbsp;<a href=”‘.$urlarr[0].$f.$totalpage.’.’.$urlarr[1].'”>’.$fun_r[‘lastpage’].'</a>’;
}
$starti=$page-$snum<0?0:$page-$snum;
$no=0;
for($i=$starti+1;$i<$totalpage+1&&$no<$page_line;$i++)
{
$no++;
if($page==$i)
{
$is_1=”<b>”;
$is_2=”</b>”;
}
else
{
if($i==1){//第一页不加page0
$is_1='<a href=”‘.substr($urlarr[0],0,-5).'”>’;
$is_2=”</a>”;
}else{
$is_1='<a href=”‘.$urlarr[0].$f.$i.’.’.$urlarr[1].'”>’;
$is_2=”</a>”;
}

}

$pagenum=$i;
$returnstr.=”&nbsp;”.$is_1.$pagenum.$is_2;
}
$returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage;
return $returnstr;
}//自己写的分页函数结束—–yonglannet
//页面支持标签
if($public_r[‘dtcanbq’])
{
$tempr[temptext]=DtNewsBq(‘list’.$tempid,$tempr[temptext],0);
}
else
{
if($public_r[‘searchtempvar’])
{
$tempr[temptext]=ReplaceTempvar($tempr[temptext]);
}
}
$listtemp=$tempr[temptext];
$rownum=$tempr[rownum];
if(empty($rownum))
{$rownum=1;}
$formatdate=$tempr[showdate];
$subnews=$tempr[subnews];
$subtitle=$tempr[subtitle];
$docode=$tempr[docode];
$modid=$tempr[modid];
$listvar=str_replace(‘[!–news.url–]’,$public_r[newsurl],$tempr[listvar]);
//公共
$listtemp=str_replace(‘[!–newsnav–]’,$url,$listtemp);//位置导航
$listtemp=Class_ReplaceSvars($listtemp,$url,$classid,$pagetitle,$pagekey,$pagedes,$classimg,$addr,0);
$listtemp=str_replace(‘[!–page.stats–]’,”,$listtemp);
$listtemp=str_replace(‘[!–show.page–]’,$listpage,$listtemp);
$listtemp=str_replace(‘[!–show.listpage–]’,$listpage,$listtemp);
$listtemp=str_replace(‘[!–list.pageno–]’,$page+1,$listtemp);
$listtemp=str_replace(‘[!–intro–]’,$intro,$listtemp);
$listtemp=str_replace(‘[!–ztname–]’,$ztname,$listtemp);

//取得列表模板
$list_exp=”[!–empirenews.listtemp–]”;
$list_r=explode($list_exp,$listtemp);
$listtext=$list_r[1];
$no=$offset+1;
$changerow=1;

while($r=$empire->fetch($sql))
{
//替换列表变量
if($ztid){
$repvar=ReplaceListVars($no,$listvar,$subnews,$subtitle,$formatdate,$url,$have_class,$r,$ret_r);
}else{
$repvar=ReplaceListVars($no,$listvar,$subnews,$subtitle,$formatdate,$url,$have_class,$r,$ret_r,$docode);
}
$listtext=str_replace(“<!–list.var”.$changerow.”–>”,$repvar,$listtext);
$changerow+=1;
//超过行数
if($changerow>$rownum)
{
$changerow=1;
$string.=$listtext;
$listtext=$list_r[1];
}
$no++;
}

//多余数据
if($changerow<=$rownum&&$listtext<>$list_r[1])
{
$string.=$listtext;
}
$string=$list_r[0].$string.$list_r[2];
echo stripSlashes($string);
db_close();
$empire=null;
?>

 

[!–intro–]为专题简介
[!–ztname–]专题名称
[!–show.listpage–]分页
列表调用
[!–id–]信息ID
[!–oldtitle–]信息标题
[!–titleurl–]信息链接
以下需要修改connect.php文件
打开connect.php文件查找“//替换列表模板/标签模板/搜索模板”—-→在找到 $listtemp=str_replace(‘[!–totaldown–]’,$r[totaldown],$listtemp);在这句后面添加
$listtemp=str_replace(‘[!–titlepic–]’,$r[titlepic],$listtemp);
$listtemp=str_replace(‘[!–smalltext–]’,$r[smalltext],$listtemp);

在列表使用[!–titlepic–]调用信息标题图片
在列表使用[!–smalltext–]调用信息简介

.htaccess 修改(d/|e/|html/|images/|search/|skin/|t/)这里面为伪静态禁止访问目录,要把专题所在目录去除,不去除会404

RewriteEngine On
#栏目
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(d/|e/|html/|images/|search/|skin/|t/)
RewriteRule ^([0-9a-zA-Z/]+)/(|index\.html|index_[0-9]+\.html)$ /e/action/list\.php\?classid=$1&page=$2
#内容

RewriteCond %{QUERY_STRING} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(d/|e/|html/|images/|s/|search/|skin/|t/)
RewriteRule ^([0-9a-zA-Z/]+)/([0-9a-zA-Z]+)([_0-9]*)\.html$ /e/action/show\.php\?classid=$1&id=$2&page=$3

nginx伪静态规则

rewrite ^/([0-9a-zA-Z/]+)/(|index\.html|index_[0-9]+\.html)$ /e/action/list.php?classid=$1&page=$2;
rewrite ^/([0-9a-zA-Z/]+)/([0-9a-zA-Z]+)([_0-9]*)\.html$ /e/action/show.php?classid=$1&id=$2&page=$3;

未经允许,不得转载本站任何文章:王振东 » 帝国cms 专题伪静态

分享到

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址