-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.php
executable file
·297 lines (260 loc) · 8.52 KB
/
list.php
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
<?php
require(dirname(__FILE__)."/f/global.php");
choose_domain(); //域名判断
//伪静态处理
if(!$fid&&$webdb[Info_htmlType]==2){
$detail=explode("-",$Fid);
$array=array_flip($Fid_db[dir_name]);
$fid=$array[$detail[0]];
if($detail[1]){
for($i=1;$i<count($detail) ;$i++ ){
$_GET[$detail[$i]]=$$detail[$i]=str_replace(array('#@#','#!#'),array('-','/'),$detail[++$i]);
}
}
if($zone_street){
$detail=explode("-",$zone_street);
$array=array_flip($zone_DB['dirname']);
$zone_id=$array[$detail[0]];
if($detail[1]){
$array=array_flip($street_DB['dirname']);
$street_id=$array[$detail[1]];
}
}
}
if($page<1){
$page=1;
}
//缓存
$Cache_FileName=ROOT_PATH."cache/list/$city_id-$fid/$page-".md5($WEBURL).".php";
if(!$jobs&&$webdb[Info_list_cache]&&(time()-filemtime($Cache_FileName))<($webdb[Info_list_cache]*60)){
echo read_file($Cache_FileName);
exit;
}
//导航条
@include(ROOT_PATH."data/guide_fid.php");
//SEO优化
$GuideFid[$fid] = str_replace("'>","'>{$city_DB[name][$city_id]}",$GuideFid[$fid]);
$zone_id && $GuideFid[$fid].=" -> <A href='".str_replace('list.php?fid=','list.php?&fid=',get_info_url('',$fid,$city_id,$zone_id,'',''))."'>{$zone_DB[name][$zone_id]}{$Fid_db[name][$fid]}</A>";
$street_id && $GuideFid[$fid].=" -> <A href='".str_replace('list.php?fid=','list.php?&fid=',get_info_url('',$fid,$city_id,$zone_id,$street_id,''))."'>{$street_DB[name][$street_id]}{$Fid_db[name][$fid]}</A>";
$fidDB=$db->get_one("SELECT A.* FROM {$_pre}sort A WHERE A.fid='$fid'");
if(!$fidDB){
showerr("栏目不存在");
}elseif($fidDB[jumpurl]){
header("location:$fidDB[jumpurl]");
exit;
}
/**
*模型配置文件
**/
$field_db = $module_DB[$fidDB[mid]][field];
//字段筛选
unset($TempSearch_2,$TempSearch_array,$seo_tile);
foreach($field_db AS $key=>$value){
if($value[listfilter]){
if($$key){ //SEO,title
$detail=explode("\r\n",$value[form_set]);
foreach($detail AS $_value){
$detail2=explode("|",$_value);
$detail2[1] || $detail2[1]=$detail2[0];
if($detail2[0]==$$key){
$seo_tile.=" {$value[title]} {$detail2[1]} ";
break;
}
}
}
$TempSearch_2.="$key=>'{$$key}',"; //分页链接使用
$TempSearch_array[$key]=$$key; //其它链接使用
$search_fieldDB[$key][$$key!=''?$$key:0]=" selected class='ck' style='color:red;'";
}
}
/**
*栏目配置参数及栏目用户自定义的变量
*对栏目用户自定义的变量附件路径做处理
*以下用的比较少,可以删除忽略
**/
$fidDB[config]=unserialize($fidDB[config]);
$CV=$fidDB[config][field_value];
$_array=array_flip($fidDB[config][is_html]);
foreach( $fidDB[config][field_db] AS $key=>$rs){
if(in_array($key,$_array)){
$CV[$key]=En_TruePath($CV[$key],0);
}elseif($rs[form_type]=='upfile'){
$CV[$key]=tempdir($CV[$key]);
}
}
//SEO
$titleDB[title] = $fidDB[metatitle]?seo_eval($fidDB[metatitle]):strip_tags("{$city_DB[name][$city_id]} {$zone_DB[name][$zone_id]} {$street_DB[name][$street_id]} $fidDB[name] $seo_tile");
$titleDB[keywords] = seo_eval($fidDB[metakeywords]);
$titleDB[description] = seo_eval($fidDB[metadescription]);
//栏目风格
$fidDB[style] && $STYLE=$fidDB[style];
unset($head_tpl,$foot_tpl);
//城市模板
if($city_DB[tpl][$city_id]){
list($head_tpl,$foot_tpl)=explode("|",$city_DB[tpl][$city_id]);
$head_tpl && $head_tpl=Mpath.$head_tpl;
$foot_tpl && $foot_tpl=Mpath.$foot_tpl;
}
/**
*栏目模板优先于城市模板
**/
if($fidDB[template]){
$FidTpl=unserialize($fidDB[template]);
$FidTpl['head'] && $head_tpl=Mpath.$FidTpl['head'];
$FidTpl['foot'] && $foot_tpl=Mpath.$FidTpl['foot'];
$FidTpl['list'] && $FidTpl['list']=Mpath.$FidTpl['list'];
}
//大分类与小栏目的判断
if($fidDB[type]){
$sortDB=ListOnlySort();
}else{
$_erp=$Fid_db[tableid][$fid];
if($fidDB[maxperpage]){
$rows=$fidDB[maxperpage];
}elseif($webdb[Info_ListNum]){
$rows=$webdb[Info_ListNum];
}else{
$rows=20;
}
$listdb=ListThisSort($rows,70);
if($totalNum){
$showpage=getpage("","","list.php?",$rows,$totalNum);
$showpage=preg_replace("/list\.php\?&page=([0-9]+)/eis","get_info_url('',$fid,$city_id,$zone_id,$street_id,array($TempSearch_2'page'=>'\\1'))",$showpage);
}
}
/**
*为获取标签参数
**/
$chdb[main_tpl]=$fidDB[type]?html("bigsort",$FidTpl['list']):html("list_$fidDB[mid]",$FidTpl['list']);
/**
*标签
**/
$ch_fid = intval($fidDB[config][label_list]); //是否定义了栏目专用标签
$ch_pagetype = 2; //2,为list页,3,为bencandy页
$ch_module = $webdb[module_id]?$webdb[module_id]:99;//系统特定ID参数,每个系统不能雷同
$ch = 0; //不属于任何专题
require(ROOT_PATH."inc/label_module.php");
require(Mpath."inc/head.php");
require($fidDB[type]?html("bigsort",$FidTpl['list']):html("list_$fidDB[mid]",$FidTpl['list']));
require(Mpath."inc/foot.php");
if($jobs=='show'){ //更新标签
@unlink($Cache_FileName);
}elseif($webdb[Info_list_cache]&&(time()-filemtime($Cache_FileName))>($webdb[Info_list_cache]*60)){
if($page<10&&!$otherSelect&&!$zone_id&&!$street_id){
if(!is_dir(dirname($Cache_FileName))){
makepath(dirname($Cache_FileName));
}
//预先清除多余的文件
$handle=opendir(dirname($Cache_FileName));
while($file=readdir($handle)){
if(eregi("^$page-",$file)){
unlink(dirname($Cache_FileName)."/$file");
}
}
write_file($Cache_FileName,$content);
}
}
/**
*针对栏目获取内容信息列表
**/
function ListThisSort($rows,$leng){
global $db,$_pre,$page,$fid,$fidDB,$SQL,$city_id,$zone_id,$street_id,$field_db,$timestamp,$webdb,$timestamp,$Murl,$Fid_db,$_erp,$totalNum,$otherSelect,$Module_db;
$SQL='';
if($street_id>0){
$SQL =" AND A.street_id='$street_id' ";
}elseif($zone_id>0){
$SQL =" AND A.zone_id='$zone_id' ";
}elseif($city_id>0){
$SQL =" AND A.city_id='$city_id' ";
}
//用户自定义筛选字段,过滤数据
foreach($field_db AS $key=>$value){
if($value[listfilter]){
if($_GET[$key]!=''){
$otherSelect++;
$SQL .=" AND B.`$key`='$_GET[$key]' ";
}
}
}
if(!$webdb[Info_ShowNoYz]){
$SQL .=" AND A.yz='1' ";
}
if($page<1){
$page=1;
}
if($fidDB[listorder]==1){
$sql_list="A.posttime";
$sql_order="DESC";
}elseif($fidDB[listorder]==2){
$sql_list="A.posttime";
$sql_order="ASC";
}elseif($fidDB[listorder]==3){
$sql_list="A.hits";
$sql_order="DESC";
}elseif($fidDB[listorder]==4){
$sql_list="A.hits";
$sql_order="ASC";
}elseif($fidDB[listorder]==5){
$sql_list="A.lastview";
$sql_order="DESC";
}else{
$sql_list="A.list";
$sql_order="DESC";
}
$min=($page-1)*$rows;
$query=$db->query("SELECT SQL_CALC_FOUND_ROWS B.*,A.* FROM {$_pre}content$_erp A LEFT JOIN {$_pre}content_{$fidDB[mid]} B ON A.id=B.id WHERE A.fid=$fid $SQL ORDER BY $sql_list $sql_order LIMIT $min,$rows");
$RS=$db->get_one("SELECT FOUND_ROWS()");
$totalNum=$RS['FOUND_ROWS()'];
while( $rs=$db->fetch_array($query) ){
if(del_EndTimeInfo($rs)){ //自动删除过期信息
continue;
}
$rs[content]=@preg_replace('/<([^>]*)>/is',"",$rs[content]); //把HTML代码过滤掉
$rs[content]=get_word($rs[full_content]=$rs[content],100);
$rs[title]=get_word($rs[full_title]=$rs[title],$leng);
if($rs['list']>$timestamp){
$rs[title]=" <font color='$webdb[Info_TopColor]'>$rs[title]</font> <img src='$webdb[www_url]/images/default/icotop.gif' border=0>";
}elseif($rs['list']>$rs[posttime]){
//置顶过期的信息,需要恢复原来发布日期以方便排序,放在后面
$db->query("UPDATE {$_pre}content$_erp SET list='$rs[posttime]' WHERE id='$rs[id]'");
}
$times=$timestamp-$rs[posttime];
if(!$webdb[Info_list_cache]&&$times<3600){
$rs[times]=ceil($times/60).'分钟前';
}elseif(!$webdb[Info_list_cache]&&$times<3600*24){
$rs[times]=ceil($times/3600).'小时前';
}else{
$rs[times]=date("m-d",$rs[posttime]);
}
$rs[posttime]=date("Y-m-d",$rs[full_time]=$rs[posttime]);
if($rs[picurl]){
$rs[picurl]=tempdir($rs[picurl]);
}
$Module_db->showfield($field_db,$rs,'list');
$rs[url]=get_info_url($rs[id],$rs[fid],$rs[city_id]);
$listdb[]=$rs;
}
return $listdb;
}
/**
*大分类
**/
function ListOnlySort(){
global $Fid_db,$module_DB,$fid,$city_id;
foreach($Fid_db[$fid] AS $key=>$value){
unset($rs);
$rs[name]=$value;
$rs[fid]=$key;
$rs[url]=get_info_url('',$rs[fid],$city_id);
$msconfig=$module_DB[$Fid_db[mid][$key]][field][sortid];
$detail=explode("\r\n",$msconfig[form_set]);
foreach( $detail AS $key2=>$value2){
$detail2=explode("|",$value2);
$url=get_info_url('',$rs[fid],$city_id,$zoneid,$streetid,array('sortid'=>"$detail2[0]"));
$rs[sortdb][]="<A HREF='$url'>$detail2[1]</A>";
}
$listdb[]=$rs;
}
return $listdb;
}
?>