ListSearchLoadTb.php
10.7 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
<?php
define('EmpireCMSAdmin','1');
require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../class/functions.php");
$link=db_connect();
$empire=new mysqlquery();
$editor=1;
//驗證用戶
$lur=is_login();
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];
//ehash
$ecms_hashur=hReturnEcmsHashStrAll();
//驗證權限
CheckLevel($logininid,$loginin,$classid,"searchall");
//增加搜索數據源
function AddSearchLoadTb($add,$userid,$username){
global $empire,$dbtbpre;
$tbname=RepPostVar($add['tbname']);
$titlefield=RepPostVar($add['titlefield']);
$infotextfield=RepPostVar($add['infotextfield']);
$smalltextfield=RepPostVar($add['smalltextfield']);
$loadnum=(int)$add['loadnum'];
if(!$tbname||!$titlefield||!$infotextfield||!$smalltextfield||!$loadnum)
{
printerror("EmptySearchLoadTb","history.go(-1)");
}
//操作權限
CheckLevel($userid,$username,$classid,"searchall");
//表是否存在
$tbnum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewssearchall_load where tbname='$tbname'");
if($tbnum)
{
printerror("ReSearchLoadTb","history.go(-1)");
}
$lasttime=time();
$sql=$empire->query("insert into {$dbtbpre}enewssearchall_load(tbname,titlefield,infotextfield,smalltextfield,loadnum,lasttime,lastid) values('$tbname','$titlefield','$infotextfield','$smalltextfield',$loadnum,$lasttime,0);");
$lid=$empire->lastid();
GetSearchAllTb();
if($sql)
{
//操作日誌
insert_dolog("lid=".$lid."&tbname=".$tbname);
printerror("AddSearchLoadTbSuccess","AddSearchLoadTb.php?enews=AddSearchLoadTb".hReturnEcmsHashStrHref2(0));
}
else
{printerror("DbError","history.go(-1)");}
}
//修改搜索數據源
function EditSearchLoadTb($add,$userid,$username){
global $empire,$dbtbpre;
$lid=(int)$add['lid'];
$tbname=RepPostVar($add['tbname']);
$titlefield=RepPostVar($add['titlefield']);
$infotextfield=RepPostVar($add['infotextfield']);
$smalltextfield=RepPostVar($add['smalltextfield']);
$loadnum=(int)$add['loadnum'];
if(!$tbname||!$titlefield||!$infotextfield||!$smalltextfield||!$loadnum)
{
printerror("EmptySearchLoadTb","history.go(-1)");
}
//操作權限
CheckLevel($userid,$username,$classid,"searchall");
if($tbname<>$add['oldtbname'])
{
//表是否存在
$tbnum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewssearchall_load where tbname='$tbname' and lid<>$lid limit 1");
if($tbnum)
{
printerror("ReSearchLoadTb","history.go(-1)");
}
}
$sql=$empire->query("update {$dbtbpre}enewssearchall_load set tbname='$tbname',titlefield='$titlefield',infotextfield='$infotextfield',smalltextfield='$smalltextfield',loadnum='$loadnum' where lid='$lid'");
GetSearchAllTb();
if($sql)
{
//操作日誌
insert_dolog("lid=".$lid."&tbname=".$tbname);
printerror("EditSearchLoadTbSuccess","ListSearchLoadTb.php".hReturnEcmsHashStrHref2(1));
}
else
{printerror("DbError","history.go(-1)");}
}
//刪除搜索數據源
function DelSearchLoadTb($lid,$userid,$username){
global $empire,$dbtbpre;
$lid=(int)$lid;
if(!$lid)
{
printerror("NotDelSearchLoadTbid","history.go(-1)");
}
//操作權限
CheckLevel($userid,$username,$classid,"searchall");
$r=$empire->fetch1("select tbname from {$dbtbpre}enewssearchall_load where lid='$lid'");
if(!$r['tbname'])
{
printerror("NotDelSearchLoadTbid","history.go(-1)");
}
$sql=$empire->query("delete from {$dbtbpre}enewssearchall_load where lid='$lid'");
$classids=ReturnTbGetClassids($r['tbname']);
if($classids)
{
$delsql=$empire->query("delete from {$dbtbpre}enewssearchall where classid in (".$classids.")");
}
GetSearchAllTb();
if($sql)
{
//操作日誌
insert_dolog("lid=".$lid."&tbname=".$r['tbname']);
printerror("DelSearchLoadTbSuccess","ListSearchLoadTb.php".hReturnEcmsHashStrHref2(1));
}
else
{printerror("DbError","history.go(-1)");}
}
//刪除數據源數據
function SearchallDelData($add,$userid,$username){
global $empire,$dbtbpre;
//操作權限
CheckLevel($userid,$username,$classid,"searchall");
$lid=$add['lid'];
$count=count($lid);
for($i=0;$i<$count;$i++)
{
$id=(int)$lid[$i];
if(empty($id))
{
continue;
}
$lr=$empire->fetch1("select tbname from {$dbtbpre}enewssearchall_load where lid='$id'");
if(empty($lr['tbname']))
{
continue;
}
$classids=ReturnTbGetClassids($lr['tbname']);
if($classids)
{
$empire->query("delete from {$dbtbpre}enewssearchall where classid in (".$classids.")");
$empire->query("update {$dbtbpre}enewssearchall_load set lastid=0 where lid='$id'");
}
}
//操作日誌
insert_dolog("");
printerror("SearchallDelDataSuccess","ListSearchLoadTb.php".hReturnEcmsHashStrHref2(1));
}
//全站搜索設置
function SetSearchAll($add,$userid,$username){
global $empire,$dbtbpre;
//操作權限
CheckLevel($userid,$username,$classid,"searchall");
$openschall=(int)$add['openschall'];
$schallfield=(int)$add['schallfield'];
$schallminlen=(int)$add['schallminlen'];
$schallmaxlen=(int)$add['schallmaxlen'];
$schallnotcid=','.$add['schallnotcid'].',';
$schallnum=(int)$add['schallnum'];
$schallpagenum=(int)$add['schallpagenum'];
$schalltime=(int)$add['schalltime'];
$sql=$empire->query("update {$dbtbpre}enewspublic set openschall=$openschall,schallfield=$schallfield,schallminlen=$schallminlen,schallmaxlen=$schallmaxlen,schallnotcid='$schallnotcid',schallnum='$schallnum',schallpagenum='$schallpagenum',schalltime='$schalltime' limit 1");
GetConfig();
//操作日誌
insert_dolog("");
printerror("SetSearchAllSuccess","SetSearchAll.php".hReturnEcmsHashStrHref2(1));
}
//返回數據表裡的欄目列表
function ReturnTbGetClassids($tbname){
global $empire,$dbtbpre;
$ids='';
$sql=$empire->query("select classid from {$dbtbpre}enewsclass where tbname='$tbname' and islast=1");
while($r=$empire->fetch($sql))
{
$dh=',';
if($ids=='')
{
$dh='';
}
$ids.=$dh.$r['classid'];
}
return $ids;
}
$enews=$_POST['enews'];
if(empty($enews))
{$enews=$_GET['enews'];}
if($enews)
{
hCheckEcmsRHash();
}
//增加搜索數據源
if($enews=="AddSearchLoadTb")
{
AddSearchLoadTb($_POST,$logininid,$loginin);
}
//修改搜索數據源
elseif($enews=="EditSearchLoadTb")
{
EditSearchLoadTb($_POST,$logininid,$loginin);
}
//刪除搜索數據源
elseif($enews=="DelSearchLoadTb")
{
$lid=$_GET['lid'];
DelSearchLoadTb($lid,$logininid,$loginin);
}
//刪除數據源數據
elseif($enews=="SearchallDelData")
{
SearchallDelData($_GET,$logininid,$loginin);
}
//全站搜索設置
elseif($enews=="SetSearchAll")
{
SetSearchAll($_POST,$logininid,$loginin);
}
$query="select lid,tbname,lasttime,lastid from {$dbtbpre}enewssearchall_load order by lid";
$sql=$empire->query($query);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>管理搜索數據源</title>
<link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
<script>
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.name != 'chkall')
e.checked = form.chkall.checked;
}
}
function CheckSearchAll(obj){
if(!confirm('確認要操作?'))
{
return false;
}
if(obj.enews.value=='SearchallDelData')
{
obj.action="ListSearchLoadTb.php";
}
else
{
obj.action="SearchLoadData.php";
}
}
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td width="50%">位置:<a href="ListSearchLoadTb.php<?=$ecms_hashur['whehref']?>">管理全站搜索數據源</a></td>
<td><div align="right" class="emenubutton">
<input type="button" name="Submit5" value="增加搜索數據源" onclick="self.location.href='AddSearchLoadTb.php?enews=AddSearchLoadTb<?=$ecms_hashur['ehref']?>';">
<input type="button" name="Submit52" value="全站搜索設置" onclick="self.location.href='SetSearchAll.php<?=$ecms_hashur['whehref']?>';">
<input type="button" name="Submit3" value="清理多餘數據" onclick="self.location.href='ClearSearchAll.php<?=$ecms_hashur['whehref']?>';">
</div></td>
</tr>
</table>
<form name="searchform" method="GET" action="SearchLoadData.php" onsubmit="return CheckSearchAll(document.searchform);">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<?=$ecms_hashur['form']?>
<tr class="header">
<td width="5%"><div align="center"> </div></td>
<td width="33%" height="25"><div align="center">導入數據表</div></td>
<td width="18%"><div align="center">最後導入ID</div></td>
<td width="24%"><div align="center">最後導入時間</div></td>
<td width="20%" height="25"><div align="center">操作</div></td>
</tr>
<?
while($r=$empire->fetch($sql))
{
?>
<tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#C3EFFF'">
<td><div align="center">
<input name="lid[]" type="checkbox" id="lid[]" value="<?=$r[lid]?>">
</div></td>
<td height="25"><div align="center">
<?=$r[tbname]?>
</div></td>
<td><div align="center">
<?=$r[lastid]?>
</div></td>
<td><div align="center">
<?=date("Y-m-d H:i:s",$r[lasttime])?>
</div></td>
<td height="25"><div align="center">[<a href="AddSearchLoadTb.php?enews=EditSearchLoadTb&lid=<?=$r[lid]?><?=$ecms_hashur['ehref']?>">修改</a>]
[<a href="SearchLoadData.php?lid[]=<?=$r[lid]?><?=$ecms_hashur['href']?>">導入</a>] [<a href="ListSearchLoadTb.php?enews=DelSearchLoadTb&lid=<?=$r[lid]?><?=$ecms_hashur['href']?>" onclick="return confirm('會同時刪除此數據表的搜索記錄,確認要刪除?');">刪除</a>]
</div></td>
</tr>
<?
}
?>
<tr bgcolor="#FFFFFF">
<td><div align="center">
<input type=checkbox name=chkall value=on onclick="CheckAll(this.form)">
</div></td>
<td height="25" colspan="4"><input type="submit" name="Submit" value="批量導入搜索表" onclick="document.searchform.enews.value='SearchallLoadData';">
<input type="submit" name="Submit2" value="刪除表數據" onclick="document.searchform.enews.value='SearchallDelData';">
<input name="enews" type="hidden" id="enews" value="SearchallLoadData">
</td>
</tr>
</table>
</form>
</body>
</html>
<?
db_close();
$empire=null;
?>