index.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. require('../../class/connect.php');
  3. require('../../class/db_sql.php');
  4. require('../../class/functions.php');
  5. require('../../class/t_functions.php');
  6. require('../../data/dbcache/class.php');
  7. require "../".LoadLang("pub/fun.php");
  8. //require(ECMS_PATH . 'e/extend/cacheadmin/MakeCache.php');
  9. $editor=1;
  10. eCheckCloseMods('search');//关闭模块
  11. $link=db_connect();
  12. $empire=new mysqlquery();
  13. $getvar=$_GET['getvar'];
  14. if(empty($getvar)) {
  15. $getfrom="history.go(-1)";
  16. } else {
  17. $getfrom="../../../search/";
  18. }
  19. //搜索结果
  20. $searchid=(int)$_GET['searchid'];
  21. if(empty($searchid)) {
  22. printerror("SearchNotRecord",$getfrom,1);
  23. }
  24. $search_r=$empire->fetch1("select searchid,keyboard,result_num,orderby,myorder,tbname,tempid,andsql,trueclassid from {$dbtbpre}enewssearch where searchid='$searchid'");
  25. if(empty($search_r['searchid'])||InfoIsInTable($search_r[tbname])) {
  26. printerror("SearchNotRecord",$getfrom,1);
  27. }
  28. $page=(int)$_GET['page'];
  29. $page=RepPIntvar($page);
  30. $start=0;
  31. $page_line=$public_r['search_pagenum'];//每页显示链接数
  32. $line=$public_r['search_num'];//每页显示记录数
  33. $offset=$page*$line;//总偏移量
  34. $search="&searchid=".$searchid;
  35. $myorder=$search_r[orderby];
  36. if(empty($search_r[myorder])) {
  37. $myorder.=" desc";
  38. }
  39. $add=stripSlashes($search_r['andsql']);
  40. $num=$search_r[result_num];
  41. $query="select * from {$dbtbpre}ecms_".$search_r[tbname].($add?' where '.substr($add,5):'');
  42. $query.=" order by ".$myorder." limit $offset,$line";
  43. $sql=$empire->query($query);
  44. $listpage=page1($num,$line,$page_line,$start,$page,$search);
  45. //取得模板
  46. if($search_r['tempid']) {
  47. $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where tempid='".$search_r['tempid']."' limit 1");
  48. } elseif(empty($class_r[$search_r[trueclassid]][searchtempid])) {
  49. $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where isdefault=1 limit 1");
  50. } else {
  51. $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");
  52. }
  53. $have_class=1;//页面支持标签
  54. $tempr[temptext]=DtNewsBq('listsearch'.$search_r['tempid'],$tempr[temptext],0);//替换公共模板变量
  55. $listtemp=$tempr[temptext];
  56. if($public_r['searchtempvar']) { $listtemp=ReplaceTempvar($listtemp);
  57. }
  58. $search_r[keyboard]=ehtmlspecialchars($search_r[keyboard]);
  59. $listtemp=str_replace("[!--show.page--]",$listpage,$listtemp);
  60. $listtemp=str_replace("[!--keyboard--]",$search_r[keyboard],$listtemp);
  61. $listtemp=str_replace("[!--ecms.num--]",$num,$listtemp);
  62. $url="<a href='".ReturnSiteIndexUrl()."'>".$fun_r['index']."</a>&nbsp;>&nbsp;".$fun_r['adsearch'];
  63. $pagetitle=$fun_r['adsearch']." ".$search_r[keyboard];
  64. $listtemp=ReplaceSvars($listtemp,$url,0,$pagetitle,$pagetitle,$pagetitle,$add,0);
  65. $rownum=$tempr[rownum];
  66. if(empty($rownum)) { $rownum=1;
  67. }
  68. $formatdate=$tempr[showdate];
  69. $subnews=$tempr[subnews];
  70. $subtitle=$tempr[subtitle];
  71. $docode=$tempr[docode];
  72. $modid=$tempr[modid];
  73. $listvar=str_replace('[!--news.url--]',$public_r[newsurl],$tempr[listvar]);
  74. //字段
  75. $ret_r=ReturnReplaceListF($tempr[modid]);
  76. //取得列表模板
  77. $list_exp="[!--empirenews.listtemp--]";
  78. $list_r=explode($list_exp,$listtemp);
  79. $listtext=$list_r[1];
  80. $no=$offset+1;
  81. $changerow=1;
  82. while($r=$empire->fetch($sql)) {
  83. //替换列表变量
  84. $repvar=ReplaceListVars($no,$listvar,$subnews,$subtitle,$formatdate,$url,$have_class,$r,$ret_r,$docode);
  85. $listtext=str_replace("<!--list.var".$changerow."-->",$repvar,$listtext);
  86. $listtext=str_replace($search_r[keyboard],"$search_r[keyboard]",$listtext);
  87. $changerow+=1;
  88. //超过行数
  89. if($changerow>$rownum) {
  90. $changerow=1;
  91. $string.=$listtext;
  92. $listtext=$list_r[1];
  93. } $no++;
  94. } db_close();
  95. $empire=null;
  96. //多余数据
  97. if($changerow<=$rownum&&$listtext<>$list_r[1]) {
  98. $string.=$listtext;
  99. }
  100. $string=$list_r[0].$string.$list_r[2];
  101. echo stripSlashes($string);
  102. ?>