ListInfo.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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. $link=db_connect();
  9. $empire=new mysqlquery();
  10. eCheckCloseMods('fieldand');//关闭模块
  11. $tbname='';
  12. $add='';
  13. $addorder='newstime desc';
  14. $search='';
  15. $GLOBALS['navclassid']=0;
  16. $yhid=0;
  17. $yhvar='qlist';
  18. //模型ID
  19. $mid=(int)$_GET['mid'];
  20. if($mid)
  21. {
  22. $tbname=$emod_r[$mid]['tbname'];
  23. if(empty($tbname))
  24. {
  25. printerror('ErrorUrl','',1);
  26. }
  27. $search.='&mid='.$mid;
  28. $yhid=$etable_r[$tbname][yhid];
  29. }
  30. $pagetitle=$public_r['sitename'];
  31. $pagekey=$public_r['sitename'];
  32. $pagedes=$public_r['sitename'];
  33. $classimg=$public_r[newsurl].'e/data/images/notimg.gif';
  34. $url="<a href='".ReturnSiteIndexUrl()."'>".$fun_r['index']."</a>&nbsp;>&nbsp;".$fun_r['infolist'];
  35. $pageecms=1;
  36. $pageclassid=0;
  37. $have_class=1;
  38. //栏目
  39. $trueclassid=0;
  40. $classid=$_GET['classid'];
  41. if($classid)
  42. {
  43. $classid=RepPostVar($classid);
  44. if(strstr($classid,','))//多栏目
  45. {
  46. $son_r=sys_ReturnMoreClass($classid,1);
  47. $trueclassid=$son_r[0];
  48. $add.=' and ('.$son_r[1].')';
  49. }
  50. else
  51. {
  52. $trueclassid=intval($classid);
  53. if($class_r[$trueclassid][islast])//终极栏目
  54. {
  55. $add.=" and classid='$trueclassid'";
  56. $have_class=0;
  57. }
  58. else
  59. {
  60. $add.=' and '.ReturnClass($class_r[$trueclassid][sonclass]);
  61. }
  62. $cr=$empire->fetch1("select classpagekey,intro,classimg,cgroupid from {$dbtbpre}enewsclass where classid='$trueclassid'");
  63. //权限
  64. if($cr['cgroupid'])
  65. {
  66. $mgroupid=(int)getcvar('mlgroupid');
  67. if(!strstr($cr[cgroupid],','.$mgroupid.','))
  68. {
  69. printerror('NotLevelToClass','history.go(-1)',1);
  70. }
  71. }
  72. $pagetitle=$class_r[$trueclassid]['classname'];
  73. $pagekey=$cr['classpagekey'];
  74. $pagedes=$cr['intro'];
  75. $classimg=$cr['classimg']?$cr['classimg']:$public_r[newsurl].'e/data/images/notimg.gif';
  76. $url=ReturnClassLink($trueclassid);
  77. $pageecms=0;
  78. $pageclassid=$trueclassid;
  79. $GLOBALS['navclassid']=$trueclassid;
  80. }
  81. if(empty($class_r[$trueclassid][tbname]))
  82. {
  83. printerror('ErrorUrl','',1);
  84. }
  85. if(empty($tbname))
  86. {
  87. $tbname=$class_r[$trueclassid][tbname];
  88. $mid=$class_r[$trueclassid][modid];
  89. $yhid=$class_r[$trueclassid][yhid];
  90. }
  91. if($class_r[$trueclassid][reorder])
  92. {
  93. $addorder=$class_r[$trueclassid][reorder];
  94. }
  95. $search.='&classid='.$classid;
  96. }
  97. //标题分类
  98. $truettid=0;
  99. $ttid=$_GET['ttid'];
  100. if($ttid)
  101. {
  102. $ttid=RepPostVar($ttid);
  103. if(strstr($ttid,','))//多标题分类
  104. {
  105. $son_r=sys_ReturnMoreTT($ttid);
  106. $truettid=$son_r[0];
  107. $add.=' and ('.$son_r[1].')';
  108. }
  109. else
  110. {
  111. $truettid=intval($ttid);
  112. $add.=" and ttid='$truettid'";
  113. if($pageecms==1)
  114. {
  115. $pagetitle=$class_tr[$truettid]['tname'];
  116. $pagekey=$class_tr[$truettid]['tname'];
  117. $pagedes=$class_tr[$truettid]['tname'];
  118. $classimg=$public_r[newsurl].'e/data/images/notimg.gif';
  119. $url="<a href='".ReturnSiteIndexUrl()."'>".$fun_r['index']."</a>&nbsp;>&nbsp;".$class_tr[$truettid]['tname'];
  120. $pageclassid=$truettid;
  121. $GLOBALS['navclassid']=$truettid;
  122. }
  123. }
  124. $ttmid=$class_tr[$truettid]['mid'];
  125. if(empty($ttmid))
  126. {
  127. printerror('ErrorUrl','',1);
  128. }
  129. if(empty($tbname))
  130. {
  131. $tbname=$emod_r[$ttmid]['tbname'];
  132. $mid=$ttmid;
  133. $yhid=$class_tr[$truettid][yhid];
  134. }
  135. $search.='&ttid='.$ttid;
  136. }
  137. if(empty($tbname)||InfoIsInTable($tbname))
  138. {
  139. printerror('ErrorUrl','',1);
  140. }
  141. if($public_r['fieldandclosetb']&&stristr($public_r['fieldandclosetb'],','.$tbname.','))
  142. {
  143. printerror('ErrorUrl','',1);
  144. }
  145. //头条
  146. if($_GET['firsttitle'])
  147. {
  148. $firsttitle=(int)$_GET['firsttitle'];
  149. if($firsttitle==-1)
  150. {
  151. $add.=" and firsttitle>0";
  152. }
  153. else
  154. {
  155. $add.=" and firsttitle='".$firsttitle."'";
  156. }
  157. $search.='&firsttitle='.$firsttitle;
  158. }
  159. //头条
  160. if($_GET['isgood'])
  161. {
  162. $isgood=(int)$_GET['isgood'];
  163. if($isgood==-1)
  164. {
  165. $add.=" and isgood>0";
  166. }
  167. else
  168. {
  169. $add.=" and isgood='".$isgood."'";
  170. }
  171. $search.='&isgood='.$isgood;
  172. }
  173. //时间
  174. if($_GET['endtime'])
  175. {
  176. $starttime=RepPostVar($_GET['starttime']);
  177. if(empty($starttime))
  178. {
  179. $starttime='0000-00-00';
  180. }
  181. $endtime=RepPostVar($_GET['endtime']);
  182. if(empty($endtime))
  183. {
  184. $endtime='0000-00-00';
  185. }
  186. if($endtime!='0000-00-00')
  187. {
  188. $add.=" and (newstime BETWEEN '".to_time($starttime." 00:00:00")."' and '".to_time($endtime." 23:59:59")."')";
  189. $search.='&starttime='.$starttime.'&endtime='.$endtime;
  190. }
  191. }
  192. //每页显示记录数
  193. $line=(int)$_GET['line'];
  194. if($line<10||$line>80)
  195. {
  196. if($class_r[$trueclassid]['lencord'])
  197. {
  198. $line=$class_r[$trueclassid]['lencord'];
  199. }
  200. else
  201. {
  202. $line=intval($public_r['qlistinfonum']);
  203. }
  204. }
  205. if(empty($line))
  206. {
  207. printerror('ErrorUrl','',1);
  208. }
  209. //列表模板
  210. $tempid=(int)$_GET['tempid'];
  211. if(empty($tempid))
  212. {
  213. if($trueclassid)//栏目
  214. {
  215. $tempid=$class_r[$trueclassid]['dtlisttempid']?$class_r[$trueclassid]['dtlisttempid']:$class_r[$trueclassid]['listtempid'];
  216. }
  217. }
  218. else
  219. {
  220. DtTempIsClose($tempid,'listtemp');
  221. }
  222. if(empty($tempid))
  223. {
  224. printerror('ErrorUrl','',1);
  225. }
  226. $tempr=$empire->fetch1("select tempid,temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewslisttemp")." where tempid='$tempid'");
  227. if(empty($tempr[tempid]))
  228. {
  229. printerror('ErrorUrl','',1);
  230. }
  231. $search.='&line='.$line.'&tempid='.$tempid;
  232. if(empty($mid))
  233. {
  234. $mid=$tempr['modid'];
  235. }
  236. //结合项
  237. if(!empty($emod_r[$mid]['listandf'])&&$_GET['ph']==1)
  238. {
  239. $andor=$_GET['andor']=='or'?'or':'and';
  240. $search.='&ph=1&andor='.$andor;
  241. $listandf='';
  242. $andr=explode(',',$emod_r[$mid]['listandf']);
  243. $count=count($andr)-1;
  244. for($i=1;$i<$count;$i++)
  245. {
  246. $andval=$_GET[$andr[$i]];
  247. if(!empty($andval))
  248. {
  249. if(strlen($andval)>$public_r['max_keyboard'])
  250. {
  251. printerror("MinKeyboard","",1);
  252. }
  253. $andval=RepPostVar2($andval);
  254. $doandor=empty($listandf)?'':' '.$andor.' ';
  255. if(strstr($andval,'__'))
  256. {
  257. $andbtr=explode('__',$andval);
  258. $andbtr[0]=(float)$andbtr[0];
  259. $andbtr[1]=(float)$andbtr[1];
  260. if($andbtr[0]&&$andbtr[1])
  261. {
  262. $listandf.=$doandor.$andr[$i]." BETWEEN '".$andbtr[0]."' and '".$andbtr[1]."'";
  263. }
  264. }
  265. elseif(empty($emod_r[$mid]['setandf']))
  266. {
  267. $listandf.=$doandor.$andr[$i]."='".$andval."'";
  268. }
  269. else
  270. {
  271. $listandf.=$doandor.$andr[$i]." like '%".$andval."%'";
  272. }
  273. $search.="&".$andr[$i]."=$andval";
  274. }
  275. }
  276. if($listandf)
  277. {
  278. $add.=' and ('.$listandf.')';
  279. }
  280. }
  281. //排序
  282. $orderby=RepPostVar($_GET['orderby']);
  283. $myorder=(int)$_GET['myorder'];
  284. if($orderby)
  285. {
  286. $orderr=ReturnDoOrderF($mid,$orderby,$myorder);
  287. $addorder=$orderr['returnorder'];
  288. }
  289. $search.='&orderby='.$orderby.'&myorder='.$myorder;
  290. $page=(int)$_GET['page'];
  291. $page=RepPIntvar($page);
  292. $start=0;
  293. $page_line=10;//每页显示链接数
  294. $offset=$page*$line;//总偏移量
  295. //系统模型
  296. $ret_r=ReturnReplaceListF($mid);
  297. //优化
  298. $yhadd='';
  299. if($yhid)
  300. {
  301. $yhadd=ReturnYhSql($yhid,$yhvar);
  302. }
  303. //总数
  304. $totalnum=(int)$_GET['totalnum'];
  305. if(!$public_r['usetotalnum'])
  306. {
  307. $totalnum=0;
  308. }
  309. if($totalnum<1)
  310. {
  311. $totalquery="select count(*) as total from {$dbtbpre}ecms_".$tbname.ReturnYhAndSql($yhadd,$add,1);
  312. $num=$empire->gettotal($totalquery);
  313. }
  314. else
  315. {
  316. $num=$totalnum;
  317. }
  318. if($public_r['usetotalnum'])
  319. {
  320. $search.='&totalnum='.$num;
  321. }
  322. //checkpageno
  323. eCheckListPageNo($page,$line,$num);
  324. //置顶
  325. if($public_r['fieldandtop'])
  326. {
  327. $addorder='istop desc,'.$addorder;
  328. }
  329. $query="select ".ReturnSqlListF($mid)." from {$dbtbpre}ecms_".$tbname.ReturnYhAndSql($yhadd,$add,1);
  330. $query.=" order by ".$addorder." limit $offset,$line";
  331. $sql=$empire->query($query);
  332. //分页
  333. $listpage=page1($num,$line,$page_line,$start,$page,$search);
  334. //页面支持标签
  335. if($public_r['dtcanbq'])
  336. {
  337. $tempr[temptext]=DtNewsBq('list'.$tempid,$tempr[temptext],0);
  338. }
  339. else
  340. {
  341. if($public_r['searchtempvar'])
  342. {
  343. $tempr[temptext]=ReplaceTempvar($tempr[temptext]);
  344. }
  345. }
  346. $listtemp=$tempr[temptext];
  347. $rownum=$tempr[rownum];
  348. if(empty($rownum))
  349. {$rownum=1;}
  350. $formatdate=$tempr[showdate];
  351. $subnews=$tempr[subnews];
  352. $subtitle=$tempr[subtitle];
  353. $docode=$tempr[docode];
  354. $modid=$tempr[modid];
  355. $listvar=str_replace('[!--news.url--]',$public_r[newsurl],$tempr[listvar]);
  356. //公共
  357. $listtemp=str_replace('[!--newsnav--]',$url,$listtemp);//位置导航
  358. $listtemp=Class_ReplaceSvars($listtemp,$url,$pageclassid,$pagetitle,$pagekey,$pagedes,$classimg,$addr,$pageecms);
  359. $listtemp=str_replace('[!--page.stats--]','',$listtemp);
  360. $listtemp=str_replace('[!--show.page--]',$listpage,$listtemp);
  361. $listtemp=str_replace('[!--show.listpage--]',$listpage,$listtemp);
  362. $listtemp=str_replace('[!--list.pageno--]',$page+1,$listtemp);
  363. //取得列表模板
  364. $list_exp="[!--empirenews.listtemp--]";
  365. $list_r=explode($list_exp,$listtemp);
  366. $listtext=$list_r[1];
  367. $no=$offset+1;
  368. $changerow=1;
  369. while($r=$empire->fetch($sql))
  370. {
  371. //替换列表变量
  372. $repvar=ReplaceListVars($no,$listvar,$subnews,$subtitle,$formatdate,$url,$have_class,$r,$ret_r,$docode);
  373. $listtext=str_replace("<!--list.var".$changerow."-->",$repvar,$listtext);
  374. $changerow+=1;
  375. //超过行数
  376. if($changerow>$rownum)
  377. {
  378. $changerow=1;
  379. $string.=$listtext;
  380. $listtext=$list_r[1];
  381. }
  382. $no++;
  383. }
  384. //多余数据
  385. if($changerow<=$rownum&&$listtext<>$list_r[1])
  386. {
  387. $string.=$listtext;
  388. }
  389. $string=$list_r[0].$string.$list_r[2];
  390. echo stripSlashes($string);
  391. db_close();
  392. $empire=null;
  393. ?>