index.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <?php
  2. require('../class/connect.php');
  3. require('../class/q_functions.php');
  4. require('../class/db_sql.php');
  5. require('../data/dbcache/class.php');
  6. eCheckCloseMods('rss');//关闭模块
  7. $link=db_connect();
  8. $empire=new mysqlquery();
  9. //参数设置
  10. $pagecode=$ecms_config['sets']['pagechar']?$ecms_config['sets']['pagechar']:'gb2312';
  11. //返回简介字段名
  12. function ReturnTheIntroField($r){
  13. global $public_r,$class_r,$emod_r,$tbname;
  14. $mid=$class_r[$r[classid]]['modid'];
  15. $smalltextf=$emod_r[$mid]['smalltextf'];
  16. $stf=$emod_r[$mid]['savetxtf'];
  17. $field='';
  18. if($smalltextf&&$smalltextf<>',')
  19. {
  20. $smr=explode(',',$smalltextf);
  21. $smcount=count($smr)-1;
  22. for($i=1;$i<$smcount;$i++)
  23. {
  24. $smf=$smr[$i];
  25. if($r[$smf])
  26. {
  27. $field=$smf;
  28. break;
  29. }
  30. }
  31. }
  32. if(empty($field))
  33. {
  34. $field='newstext';
  35. }
  36. //存文本
  37. if($stf==$field)
  38. {
  39. $field='';
  40. }
  41. return $field;
  42. }
  43. //替换
  44. function RepSpeRssStr($str){
  45. $str=stripSlashes($str);
  46. $str=ehtmlspecialchars($str,ENT_QUOTES);
  47. $str=str_replace(array('[!--empirenews.page--]','[/!--empirenews.page--]','[',']'),array('','','',''),$str);
  48. return $str;
  49. }
  50. //地址验证
  51. if(!stristr($public_r['newsurl'],'://'))
  52. {
  53. $public_r['newsurl']=eReturnDomain().$public_r['newsurl'];
  54. }
  55. $sitedomain=eReturnDomain();//网站域名
  56. $pagetitle=$public_r['sitename'];
  57. $pageurl=$public_r['newsurl'];
  58. $pageecms=1;
  59. $pageclassid=0;
  60. $tbname='';
  61. $add='';
  62. $yhid=0;
  63. $yhvar='qlist';
  64. //模型ID
  65. $mid=(int)$_GET['mid'];
  66. if($mid)
  67. {
  68. $tbname=$emod_r[$mid]['tbname'];
  69. if(empty($tbname))
  70. {
  71. exit();
  72. }
  73. $yhid=$etable_r[$tbname][yhid];
  74. }
  75. //栏目
  76. $trueclassid=0;
  77. $classid=$_GET['classid'];
  78. if($classid)
  79. {
  80. $classid=RepPostVar($classid);
  81. if(strstr($classid,','))//多栏目
  82. {
  83. $son_r=sys_ReturnMoreClass($classid,1);
  84. $trueclassid=$son_r[0];
  85. $add.=' and ('.$son_r[1].')';
  86. }
  87. else
  88. {
  89. $trueclassid=intval($classid);
  90. if($class_r[$trueclassid][islast])//终极栏目
  91. {
  92. $add.=" and classid='$trueclassid'";
  93. }
  94. else
  95. {
  96. $add.=' and '.ReturnClass($class_r[$trueclassid][sonclass]);
  97. }
  98. //页面标题
  99. $pagetitle=$class_r[$trueclassid]['classname'];
  100. $this_r['classid']=$trueclassid;
  101. $pageurl=sys_ReturnBqClassname($this_r,9);
  102. $pageecms=0;
  103. $pageclassid=$trueclassid;
  104. }
  105. if(empty($class_r[$trueclassid]['tbname']))
  106. {
  107. exit();
  108. }
  109. if(empty($tbname))
  110. {
  111. $tbname=$class_r[$trueclassid][tbname];
  112. $mid=$class_r[$trueclassid][modid];
  113. $yhid=$class_r[$trueclassid][yhid];
  114. }
  115. }
  116. //标题分类
  117. $truettid=0;
  118. $ttid=$_GET['ttid'];
  119. if($ttid)
  120. {
  121. $ttid=RepPostVar($ttid);
  122. if(strstr($ttid,','))//多标题分类
  123. {
  124. $son_r=sys_ReturnMoreTT($ttid);
  125. $truettid=$son_r[0];
  126. $add.=' and ('.$son_r[1].')';
  127. }
  128. else
  129. {
  130. $truettid=intval($ttid);
  131. $add.=" and ttid='$truettid'";
  132. if($pageecms==1)
  133. {
  134. $pagetitle=$class_tr[$truettid]['tname'];
  135. $pageurl=sys_ReturnBqInfoTypeUrl($truettid);
  136. $pageclassid=$truettid;
  137. }
  138. }
  139. $ttmid=$class_tr[$truettid]['mid'];
  140. if(empty($ttmid))
  141. {
  142. printerror('ErrorUrl','',1);
  143. }
  144. if(empty($tbname))
  145. {
  146. $tbname=$emod_r[$ttmid]['tbname'];
  147. $mid=$ttmid;
  148. $yhid=$class_tr[$truettid][yhid];
  149. }
  150. }
  151. //默认表
  152. if(empty($tbname))
  153. {
  154. $tbname=$public_r['tbname'];
  155. $mid=$etable_r[$tbname][mid];
  156. $yhid=$etable_r[$tbname][yhid];
  157. }
  158. if(empty($tbname)||InfoIsInTable($tbname))
  159. {
  160. printerror('ErrorUrl','',1);
  161. }
  162. //排序
  163. $order=(int)$_GET['order'];
  164. if($order==1)//按ID
  165. {
  166. $myorder="id";
  167. }
  168. elseif($order==2)//评论数
  169. {
  170. $myorder="plnum";
  171. }
  172. elseif($order==3)//点击数
  173. {
  174. $myorder="onclick";
  175. }
  176. elseif($order==4)//下载数
  177. {
  178. $myorder="totaldown";
  179. }
  180. else//发布时间
  181. {
  182. $myorder="newstime";
  183. }
  184. //显示顺序
  185. $orderby=(int)$_GET['orderby'];
  186. if($orderby)
  187. {
  188. $myorderby="ASC";
  189. }
  190. else
  191. {
  192. $myorderby="DESC";
  193. }
  194. //优化
  195. $yhadd='';
  196. if($yhid)
  197. {
  198. $yhadd=ReturnYhSql($yhid,$yhvar);
  199. }
  200. $query="select ".ReturnSqlListF($mid)." from {$dbtbpre}ecms_".$tbname.ReturnYhAndSql($yhadd,$add,1)." order by ".$myorder." ".$myorderby." limit ".$public_r['rssnum'];
  201. $sublen=$public_r['rsssub'];
  202. $sql=$empire->query($query);
  203. //显示文件
  204. $type=$_GET['type'];
  205. if($type=="xml")//xml
  206. {
  207. $webfilename="xml.php";
  208. }
  209. elseif($type=="atom")//atom
  210. {
  211. $webfilename="atom.php";
  212. }
  213. elseif($type=="rss1")//rss1
  214. {
  215. $webfilename="rss10.php";
  216. }
  217. else//rss2
  218. {
  219. $webfilename="rss20.php";
  220. }
  221. require($webfilename);
  222. db_close();
  223. $empire=null;
  224. ?>