hplfun.php
12.4 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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<?php
//************************************ 評論設置參數 ************************************
function SetPl($add,$userid,$username){
global $empire,$dbtbpre;
//驗證權限
CheckLevel($userid,$username,$classid,"public");
$add['pltime']=(int)$add['pltime'];
$add['plsize']=(int)$add['plsize'];
$add['plincludesize']=(int)$add['plincludesize'];
$add['plkey_ok']=(int)$add['plkey_ok'];
$add['plfacenum']=(int)$add['plfacenum'];
$add['plgroupid']=(int)$add['plgroupid'];
$add['pl_num']=(int)$add['pl_num'];
$add['plmaxfloor']=(int)$add['plmaxfloor'];
$sql=$empire->query("update {$dbtbpre}enewspl_set set pltime='$add[pltime]',plsize='$add[plsize]',plincludesize='$add[plincludesize]',plkey_ok='$add[plkey_ok]',plfacenum='$add[plfacenum]',plgroupid='$add[plgroupid]',plclosewords='".eaddslashes($add[plclosewords])."',pl_num='$add[pl_num]',plurl='$add[plurl]',plmaxfloor='$add[plmaxfloor]',plquotetemp='".eaddslashes2($add[plquotetemp])."' limit 1");
GetConfig();//更新緩存
if($sql)
{
insert_dolog("");//操作日誌
printerror('SetPlSuccess','pl/SetPl.php'.hReturnEcmsHashStrHref2(1));
}
else
{
printerror('DbError','history.go(-1)');
}
}
//************************************ 評論 ************************************
//批量刪除評論
function DelPl_all($plid,$id,$bclassid,$classid,$userid,$username){
global $empire,$class_r,$dbtbpre,$public_r;
//驗證權限
//CheckLevel($userid,$username,$classid,"news");
$restb=(int)$_POST['restb'];
$count=count($plid);
if(empty($count)||!$restb)
{
printerror("NotDelPlid","history.go(-1)");
}
if(!strstr($public_r['pldatatbs'],','.$restb.','))
{
printerror("NotDelPlid","history.go(-1)");
}
for($i=0;$i<$count;$i++)
{
$add.="plid='".intval($plid[$i])."' or ";
}
$add=substr($add,0,strlen($add)-4);
//更新數據表
$fsql=$empire->query("select id,classid,plid,pubid from {$dbtbpre}enewspl_{$restb} where ".$add);
while($r=$empire->fetch($fsql))
{
if($class_r[$r[classid]][tbname]&&$r['pubid']>0)
{
$index_r=$empire->fetch1("select checked from {$dbtbpre}ecms_".$class_r[$r[classid]][tbname]."_index where id='$r[id]' limit 1");
//返回表
$infotb=ReturnInfoMainTbname($class_r[$r[classid]][tbname],$index_r['checked']);
$empire->query("update ".$infotb." set plnum=plnum-1 where id='$r[id]'");
}
}
$sql=$empire->query("delete from {$dbtbpre}enewspl_{$restb} where ".$add);
if($sql)
{
//操作日誌
insert_dolog("classid=".$classid."<br>classname=".$class_r[$classid][classname]);
printerror("DelPlSuccess",$_SERVER['HTTP_REFERER']);
}
else
{printerror("DbError","history.go(-1)");}
}
//批量審核評論
function CheckPl_all($plid,$id,$bclassid,$classid,$userid,$username){
global $empire,$class_r,$dbtbpre,$public_r;
//驗證權限
//CheckLevel($userid,$username,$classid,"news");
$restb=(int)$_POST['restb'];
$count=count($plid);
if(empty($count)||!$restb)
{
printerror("NotCheckPlid","history.go(-1)");
}
if(!strstr($public_r['pldatatbs'],','.$restb.','))
{
printerror("NotCheckPlid","history.go(-1)");
}
for($i=0;$i<$count;$i++)
{
$add.="plid='".intval($plid[$i])."' or ";
}
$add=substr($add,0,strlen($add)-4);
$sql=$empire->query("update {$dbtbpre}enewspl_{$restb} set checked=0 where ".$add);
if($sql)
{
//操作日誌
insert_dolog("classid=".$classid."<br>classname=".$class_r[$classid][classname]);
printerror("CheckPlSuccess",$_SERVER['HTTP_REFERER']);
}
else
{printerror("DbError","history.go(-1)");}
}
//批量推薦/取消評論
function DoGoodPl_all($plid,$id,$bclassid,$classid,$isgood,$userid,$username){
global $empire,$class_r,$dbtbpre,$public_r;
//驗證權限
//CheckLevel($userid,$username,$classid,"news");
$restb=(int)$_POST['restb'];
$count=count($plid);
if(empty($count)||!$restb)
{
printerror("NotGoodPlid","history.go(-1)");
}
if(!strstr($public_r['pldatatbs'],','.$restb.','))
{
printerror("NotGoodPlid","history.go(-1)");
}
$isgood=(int)$isgood;
for($i=0;$i<$count;$i++)
{
$add.="plid='".intval($plid[$i])."' or ";
}
$add=substr($add,0,strlen($add)-4);
$sql=$empire->query("update {$dbtbpre}enewspl_{$restb} set isgood='$isgood' where ".$add);
if($sql)
{
//操作日誌
insert_dolog("isgood=$isgood<br>classid=".$classid."<br>classname=".$class_r[$classid][classname]);
printerror("DoGoodPlSuccess",$_SERVER['HTTP_REFERER']);
}
else
{printerror("DbError","history.go(-1)");}
}
//批量更新信息評論數
function UpdateAllInfoPlnum($add,$userid,$username){
global $empire,$public_r,$class_r,$fun_r,$dbtbpre;
//驗證權限
CheckLevel($userid,$username,$classid,"changedata");
$start=(int)$add['start'];
$tbname=RepPostVar($add['tbname']);
$from=$add['from'];
if(empty($tbname)||!eCheckTbname($tbname))
{
printerror("ErrorUrl","history.go(-1)");
}
//按欄目刷新
$classid=(int)$add['classid'];
if($classid)
{
if(empty($class_r[$classid][islast]))//父欄目
{
$where=ReturnClass($class_r[$classid][sonclass]);
}
else//終極欄目
{
$where="classid='$classid'";
}
$add1=" and (".$where.")";
}
//按ID刷新
$retype=(int)$add['retype'];
if($retype)
{
$startid=(int)$add['startid'];
$endid=(int)$add['endid'];
if($endid)
{
$add1.=" and id>=$startid and id<=$endid";
}
}
else
{
$startday=RepPostVar($add['startday']);
$endday=RepPostVar($add['endday']);
if($startday&&$endday)
{
$add1.=" and truetime>=".to_time($startday." 00:00:00")." and truetime<=".to_time($endday." 23:59:59");
}
}
//指定ID
$doids=trim($add['doids']);
$whereid='';
if($doids)
{
$doidr=explode(',',$doids);
$doidcount=count($doidr);
$wheredh='';
for($doi=0;$doi<$doidcount;$doi++)
{
$whereid.=$wheredh.intval($doidr[$doi]);
$wheredh=',';
}
$add1.=' and id in ('.$whereid.')';
}
$b=0;
$sql=$empire->query("select id,classid,checked from {$dbtbpre}ecms_".$tbname."_index where id>$start".$add1." order by id limit ".$public_r[infolinknum]);
while($r=$empire->fetch($sql))
{
$b=1;
$new_start=$r['id'];
//更信息評論數
UpdateSingleInfoPlnum($r['classid'],$r['id'],$r['checked']);
}
if(empty($b))
{
insert_dolog("");//操作日誌
printerror("UpdateInfoPlnumSuccess",$from);
}
echo $fun_r[OneUpdateInfoPlnumSuccess]."(ID:<font color=red><b>".$new_start."</b></font>)<script>self.location.href='ecmspl.php?enews=UpdateAllInfoPlnum&tbname=$tbname&classid=$classid&start=$new_start&from=".urlencode($from)."&retype=$retype&startday=$startday&endday=$endday&startid=$startid&endid=$endid&doids=$whereid".hReturnEcmsHashStrHref(0)."';</script>";
exit();
}
//************************************ 評論字段管理 ************************************
//驗證字段是否重複
function CheckRePlF($add,$ecms=0){
global $empire,$dbtbpre;
//修改
if($ecms==1&&$add[f]==$add[oldf])
{
return '';
}
//主表
$s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewspl_1");
$b=0;
while($r=$empire->fetch($s))
{
if($r[Field]==$add[f])
{
$b=1;
break;
}
}
if($b)
{
printerror("ReF","history.go(-1)");
}
}
//返回字段類型
function ReturnPlFtype($add){
//字段類型
if($add[ftype]=="TINYINT"||$add[ftype]=="SMALLINT"||$add[ftype]=="INT"||$add[ftype]=="BIGINT"||$add[ftype]=="FLOAT"||$add[ftype]=="DOUBLE")
{
$def=" default '0'";
}
elseif($add[ftype]=="VARCHAR")
{
$def=" default ''";
}
else
{
$def="";
}
$type=$add[ftype];
//VARCHAR
if($add[ftype]=='VARCHAR'&&empty($add[flen]))
{
$add[flen]='255';
}
//字段長度
if($add[flen])
{
if($add[ftype]!="TEXT"&&$add[ftype]!="MEDIUMTEXT"&&$add[ftype]!="LONGTEXT")
{
$type.="(".$add[flen].")";
}
}
$field="`".$add[f]."` ".$type." NOT NULL".$def;
return $field;
}
//增加評論字段
function AddPlF($add,$userid,$username){
global $empire,$dbtbpre;
$add[f]=RepPostVar($add[f]);
if(empty($add[f])||empty($add[fname]))
{
printerror("EmptyF","history.go(-1)");
}
//驗證權限
CheckLevel($userid,$username,$classid,"plf");
//驗證字段重複
CheckRePlF($add,0);
//字段類型
$field=ReturnPlFtype($add);
//新增字段
$tbr=$empire->fetch1("select pldatatbs from {$dbtbpre}enewspl_set limit 1");
if($tbr['pldatatbs'])
{
$dtbr=explode(',',$tbr['pldatatbs']);
$count=count($dtbr);
for($i=1;$i<$count-1;$i++)
{
$empire->query("alter table {$dbtbpre}enewspl_".$dtbr[$i]." add ".$field);
}
}
//處理變量
$add[ismust]=(int)$add[ismust];
$sql=$empire->query("insert into {$dbtbpre}enewsplf(f,fname,fzs,ftype,flen,ismust) values('$add[f]','$add[fname]','".addslashes($add[fzs])."','$add[ftype]','$add[flen]','$add[ismust]');");
$lastid=$empire->lastid();
UpdatePlF();//更新字段
GetConfig();//更新緩存
if($sql)
{
//操作日誌
insert_dolog("fid=".$lastid."<br>f=".$add[f]);
printerror("AddFSuccess","pl/AddPlF.php?enews=AddPlF".hReturnEcmsHashStrHref2(0));
}
else
{
printerror("DbError","history.go(-1)");
}
}
//修改評論字段
function EditPlF($add,$userid,$username){
global $empire,$dbtbpre;
$fid=(int)$add['fid'];
$add[f]=RepPostVar($add[f]);
$add[oldf]=RepPostVar($add[oldf]);
if(empty($add[f])||empty($add[fname])||!$fid)
{
printerror("EmptyF","history.go(-1)");
}
//驗證權限
CheckLevel($userid,$username,$classid,"plf");
//驗證字段重複
CheckRePlF($add,1);
$cr=$empire->fetch1("select * from {$dbtbpre}enewsplf where fid='$fid'");
//改變字段
if($cr[f]<>$add[f]||$cr[ftype]<>$add[ftype]||$cr[flen]<>$add[flen])
{
$field=ReturnPlFtype($add);//字段類型
$tbr=$empire->fetch1("select pldatatbs from {$dbtbpre}enewspl_set limit 1");
if($tbr['pldatatbs'])
{
$dtbr=explode(',',$tbr['pldatatbs']);
$count=count($dtbr);
for($i=1;$i<$count-1;$i++)
{
$empire->query("alter table {$dbtbpre}enewspl_".$dtbr[$i]." change `".$cr[f]."` ".$field);
}
}
}
//處理變量
$add[ismust]=(int)$add[ismust];
$sql=$empire->query("update {$dbtbpre}enewsplf set f='$add[f]',fname='$add[fname]',fzs='".addslashes($add[fzs])."',ftype='$add[ftype]',flen='$add[flen]',ismust='$add[ismust]' where fid=$fid");
UpdatePlF();//更新字段
GetConfig();//更新緩存
if($sql)
{
//操作日誌
insert_dolog("fid=".$fid."<br>f=".$add[f]);
printerror("EditFSuccess","pl/ListPlF.php".hReturnEcmsHashStrHref2(1));
}
else
{printerror("DbError","history.go(-1)");}
}
//刪除評論字段
function DelPlF($add,$userid,$username){
global $empire,$dbtbpre;
$fid=(int)$add['fid'];
if(empty($fid))
{
printerror("EmptyFid","history.go(-1)");
}
//驗證權限
CheckLevel($userid,$username,$classid,"plf");
$r=$empire->fetch1("select f from {$dbtbpre}enewsplf where fid=$fid");
if(!$r[f])
{
printerror("EmptyFid","history.go(-1)");
}
if($r[f]=="saytext")
{
printerror("NotIsAdd","history.go(-1)");
}
//刪除字段
$tbr=$empire->fetch1("select pldatatbs from {$dbtbpre}enewspl_set limit 1");
if($tbr['pldatatbs'])
{
$dtbr=explode(',',$tbr['pldatatbs']);
$count=count($dtbr);
for($i=1;$i<$count-1;$i++)
{
$empire->query("alter table {$dbtbpre}enewspl_".$dtbr[$i]." drop COLUMN `".$r[f]."`");
}
}
$sql=$empire->query("delete from {$dbtbpre}enewsplf where fid=$fid");
UpdatePlF();//更新字段
GetConfig();//更新緩存
if($sql)
{
//操作日誌
insert_dolog("fid=".$fid."<br>f=".$r[f]);
printerror("DelFSuccess","pl/ListPlF.php".hReturnEcmsHashStrHref2(1));
}
else
{printerror("DbError","history.go(-1)");}
}
//更新評論字段
function UpdatePlF(){
global $empire,$dbtbpre;
$plf=',';
$plmustf=',';
$sql=$empire->query("select f,ismust from {$dbtbpre}enewsplf");
while($r=$empire->fetch($sql))
{
$plf.=$r[f].',';
if($r[ismust])
{
$plmustf.=$r[f].',';
}
}
$empire->query("update {$dbtbpre}enewspl_set set plf='$plf',plmustf='$plmustf' limit 1");
}
//************************************ 評論分表管理 ************************************
//增加評論分表
function AddPlDataTable($add,$userid,$username){
echo'This is the Free Version of EmpireCMS.';
exit();
}
//默認評論存放表
function DefPlDataTable($add,$userid,$username){
echo'This is the Free Version of EmpireCMS.';
exit();
}
//刪除評論分表
function DelPlDataTable($add,$userid,$username){
echo'This is the Free Version of EmpireCMS.';
exit();
}
?>