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