帝国cms搜索模板出现乱码怎么解决

我们在使用帝国cms搜索某个关键词的时候,因为帝国cms的模板不支持动态调用所以出现了很多乱码,这个时候我们只需要做一点点修改就可以解决。

找到/e/search/result/index.php这个文件,复制以下代码直接替换就可以搞定。

<?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");
$editor=1;
eCheckCloseMods('search');//关闭模块 
$link=db_connect();
$empire=new mysqlquery();
$getvar=$_GET['getvar'];
if(empty($getvar)) {
         $getfrom="history.go(-1)";
} else {
         $getfrom="../../../search/";
}
//搜索结果 
$searchid=(int)$_GET['searchid'];
if(empty($searchid)) {
         printerror("SearchNotRecord",$getfrom,1);
} 
$search_r=$empire->fetch1("select searchid,keyboard,result_num,orderby,myorder,tbname,tempid,andsql,trueclassid from {$dbtbpre}enewssearch where searchid='$searchid'");
if(empty($search_r['searchid'])||InfoIsInTable($search_r[tbname])) { 
        printerror("SearchNotRecord",$getfrom,1);
}
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$start=0;
$page_line=$public_r['search_pagenum'];//每页显示链接数 
$line=$public_r['search_num'];//每页显示记录数 
$offset=$page*$line;//总偏移量 
$search="&searchid=".$searchid;
$myorder=$search_r[orderby];if(empty($search_r[myorder])) {         
$myorder.=" desc";
} 
$add=stripSlashes($search_r['andsql']);
$num=$search_r[result_num];
$query="select * from {$dbtbpre}ecms_".$search_r[tbname].($add?' where '.substr($add,5):'');$query.=" order by ".$myorder." limit $offset,$line";
$sql=$empire->query($query);$listpage=page1($num,$line,$page_line,$start,$page,$search);//取得模板 
if($search_r['tempid']) {
         $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where tempid='".$search_r['tempid']."' limit 1");
} elseif(empty($class_r[$search_r[trueclassid]][searchtempid])) { 
        $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where isdefault=1 limit 1");
} else {
         $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where tempid='".$class_r[$search_r[trueclassid]][searchtempid]."' limit 1");
} 
$have_class=1;//页面支持标签 
$tempr[temptext]=DtNewsBq('listsearch'.$search_r['tempid'],$tempr[temptext],0);//替换公共模板变量
 $listtemp=$tempr[temptext];
if($public_r['searchtempvar']) { $listtemp=ReplaceTempvar($listtemp);} 
$search_r[keyboard]=ehtmlspecialchars($search_r[keyboard]);
$listtemp=str_replace("[!--show.page--]",$listpage,$listtemp);
$listtemp=str_replace("[!--keyboard--]",$search_r[keyboard],$listtemp);
$listtemp=str_replace("[!--ecms.num--]",$num,$listtemp);
$url="<a href='".ReturnSiteIndexUrl()."'>".$fun_r['index']."</a> > ".$fun_r['adsearch'];$pagetitle=$fun_r['adsearch']." ".$search_r[keyboard];
$listtemp=ReplaceSvars($listtemp,$url,0,$pagetitle,$pagetitle,$pagetitle,$add,0);
$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]);//字段 
$ret_r=ReturnReplaceListF($tempr[modid]);//取得列表模板 
$list_exp="[!--empirenews.listtemp--]";
$list_r=explode($list_exp,$listtemp);
$listtext=$list_r[1];$no=$offset+1;
$changerow=1;while($r=$empire->fetch($sql)) {         //替换列表变量 
$repvar=ReplaceListVars($no,$listvar,$subnews,$subtitle,$formatdate,$url,$have_class,$r,$ret_r,$docode
);
$listtext=str_replace("<!--list.var".$changerow."-->",$repvar,$listtext);
$listtext=str_replace($search_r[keyboard],"<font color='red'>$search_r[keyboard]</font>",$listtext);$changerow+=1;//超过行数 
if($changerow>$rownum) {
$changerow=1;
$string.=$listtext;$listtext=$list_r[1];} $no++;
} 
db_close();
$empire=null;//多余数据 
if($changerow<=$rownum&&$listtext<>$list_r[1]) {
         $string.=$listtext;
} 
$string=$list_r[0].$string.$list_r[2];
echo stripSlashes($string);
?>

只需要复制上面的代码替换/e/search/result/index.php文件就可以解决搜索页面出现乱码问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值