ListLog.php
11.5 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
<?php
define('EmpireCMSAdmin','1');
require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../class/functions.php");
require "../".LoadLang("pub/fun.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,"log");
//刪除日誌
function DelLog($loginid,$userid,$username){
global $empire,$dbtbpre;
//驗證權限
CheckLevel($userid,$username,$classid,"log");
$loginid=(int)$loginid;
if(!$loginid)
{
printerror("NotDelLogid","history.go(-1)");
}
$sql=$empire->query("delete from {$dbtbpre}enewslog where loginid='$loginid'");
if($sql)
{
//操作日誌
insert_dolog("loginid=".$loginid);
printerror("DelLogSuccess","ListLog.php".hReturnEcmsHashStrHref2(1));
}
else
{
printerror("DbError","history.go(-1)");
}
}
//批量刪除日誌
function DelLog_all($loginid,$userid,$username){
global $empire,$dbtbpre;
//驗證權限
CheckLevel($userid,$username,$classid,"log");
$count=count($loginid);
if(!$count)
{
printerror("NotDelLogid","history.go(-1)");
}
for($i=0;$i<$count;$i++)
{
$add.=" loginid='".intval($loginid[$i])."' or";
}
$add=substr($add,0,strlen($add)-3);
$sql=$empire->query("delete from {$dbtbpre}enewslog where".$add);
if($sql)
{
//操作日誌
insert_dolog("");
printerror("DelLogSuccess","ListLog.php".hReturnEcmsHashStrHref2(1));
}
else
{
printerror("DbError","history.go(-1)");
}
}
//日期刪除日誌
function DelLog_date($add,$userid,$username){
global $empire,$dbtbpre;
//驗證權限
CheckLevel($userid,$username,$classid,"log");
$start=RepPostVar($add['startday']);
$end=RepPostVar($add['endday']);
if(!$start||!$end)
{
printerror('EmptyDelLogTime','');
}
$startday=$start.' 00:00:00';
$endday=$end.' 23:59:59';
$sql=$empire->query("delete from {$dbtbpre}enewslog where logintime<='$endday' and logintime>='$startday'");
if($sql)
{
//操作日誌
insert_dolog("time=".$start."~".$end);
printerror("DelLogSuccess","ListLog.php".hReturnEcmsHashStrHref2(1));
}
else
{
printerror("DbError","history.go(-1)");
}
}
//補零
function ToAddDateZero($n){
if($n<10)
{
$n='0'.$n;
}
return $n;
}
//返回日期
function ReturnLogSelectDate($y,$m,$d){
//年
if(empty($y))
{
$y=date("Y");
}
for($i=2003;$i<=$thisyear+1;$i++)
{
$selected='';
if($i==$y)
{
$selected=' selected';
}
$r['year'].="<option value='".$i."'".$selected.">".$i."</option>";
}
//月
if(empty($m))
{
$m=date("m");
}
for($i=1;$i<=12;$i++)
{
$selected='';
$mi=ToAddDateZero($i);
if($mi==$m)
{
$selected=' selected';
}
$r['month'].="<option value='".$mi."'".$selected.">".$mi."</option>";
}
//日
if(empty($d))
{
$d=date("d");
}
for($i=1;$i<=31;$i++)
{
$selected='';
$di=ToAddDateZero($i);
if($di==$d)
{
$selected=' selected';
}
$r['day'].="<option value='".$di."'".$selected.">".$di."</option>";
}
return $r;
}
$enews=$_POST['enews'];
if(empty($enews))
{$enews=$_GET['enews'];}
if($enews)
{
hCheckEcmsRHash();
}
//刪除日誌
if($enews=="DelLog")
{
$loginid=$_GET['loginid'];
DelLog($loginid,$logininid,$loginin);
}
//批量刪除日誌
elseif($enews=="DelLog_all")
{
$loginid=$_POST['loginid'];
DelLog_all($loginid,$logininid,$loginin);
}
elseif($enews=="DelLog_date")
{
DelLog_date($_POST,$logininid,$loginin);
}
$line=20;//每頁顯示條數
$page_line=18;//每頁顯示鏈接數
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$start=0;
$offset=$page*$line;//總偏移量
$query="select loginid,username,loginip,logintime,status,password,loginauth,ipport from {$dbtbpre}enewslog";
$totalquery="select count(*) as total from {$dbtbpre}enewslog";
//搜索
$search='';
$search.=$ecms_hashur['ehref'];
$where='';
if($_GET['sear']==1)
{
$search.="&sear=1";
$a='';
$and='';
//狀態
$status=(int)$_GET['status'];
if($status)
{
if($status==1)
{
$a.="status=1";
}
else
{
$a.="status=0";
}
$search.="&status=$status";
}
//時間
$startday=RepPostVar($_GET['startday']);
$endday=RepPostVar($_GET['endday']);
if($startday&&$endday)
{
$and=$a?' and ':'';
$search.="&startday=$startday&endday=$endday";
$a.=$and."logintime<='".$endday." 23:59:59' and logintime>='".$startday." 00:00:00'";
}
//搜索
$keyboard=RepPostVar($_GET['keyboard']);
if($keyboard)
{
$and=$a?' and ':'';
$show=RepPostStr($_GET['show'],1);
if($show==1)
{
$a.=$and."username like '%$keyboard%'";
}
elseif($show==2)
{
$a.=$and."loginip like '%$keyboard%'";
}
else
{
$a.=$and."(username like '%$keyboard%' or loginip like '%$keyboard%')";
}
$search.="&keyboard=$keyboard&show=$show";
}
if($a)
{
$where.=" where ".$a;
}
$query.=$where;
$totalquery.=$where;
}
$search2=$search;
//排序
$mydesc=(int)$_GET['mydesc'];
$desc=$mydesc?'asc':'desc';
$orderby=(int)$_GET['orderby'];
if($orderby==1)//登陸用戶
{
$order="username ".$desc.",loginid desc";
$usernamedesc=$mydesc?0:1;
}
elseif($orderby==2)//狀態
{
$order="status ".$desc.",loginid desc";
$statusdesc=$mydesc?0:1;
}
elseif($orderby==3)//登陸IP
{
$order="loginip ".$desc.",loginid desc";
$loginipdesc=$mydesc?0:1;
}
elseif($orderby==4)//登陸時間
{
$order="logintime ".$desc.",loginid desc";
$logintimedesc=$mydesc?0:1;
}
else//ID
{
$order="loginid ".$desc;
$loginiddesc=$mydesc?0:1;
}
$search.="&orderby=$orderby&mydesc=$mydesc";
$num=$empire->gettotal($totalquery);//取得總條數
$query=$query." order by ".$order." limit $offset,$line";
$sql=$empire->query($query);
$returnpage=page2($num,$line,$page_line,$start,$page,$search);
?>
<html>
<head>
<link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
<title>管理登陸日誌</title>
<script src="../ecmseditor/fieldfile/setday.js"></script>
<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;
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td>位置:日誌管理 > <a href="ListLog.php<?=$ecms_hashur['whehref']?>">管理登陸日誌</a></td>
<td width="50%"><div align="right" class="emenubutton">
<input type="button" name="Submit5" value="管理操作日誌" onclick="self.location.href='ListDolog.php<?=$ecms_hashur['whehref']?>';">
</div></td>
</tr>
</table>
<br>
<table width="100%" align=center cellpadding=0 cellspacing=0>
<form name=searchlogform method=get action='ListLog.php'>
<?=$ecms_hashur['eform']?>
<tr>
<td height="25"> <div align="center">時間從
<input name="startday" type="text" value="<?=$startday?>" size="12" onclick="setday(this)">
到
<input name="endday" type="text" value="<?=$endday?>" size="12" onclick="setday(this)">
,關鍵字:
<input name="keyboard" type="text" id="keyboard" value="<?=$keyboard?>">
<select name="show" id="show">
<option value="0"<?=$show==0?' selected':''?>>不限</option>
<option value="1"<?=$show==1?' selected':''?>>用戶名</option>
<option value="2"<?=$show==2?' selected':''?>>登陸IP</option>
</select>
<select name="status" id="status">
<option value="0"<?=$status==0?' selected':''?>>所有狀態</option>
<option value="1"<?=$status==1?' selected':''?>>登陸完成日誌</option>
<option value="2"<?=$status==2?' selected':''?>>登陸失敗日誌</option>
</select>
<input name=submit1 type=submit id="submit12" value=搜索>
<input name="sear" type="hidden" id="sear" value="1">
</div></td>
</tr>
</form>
</table>
<form name="form2" method="post" action="ListLog.php" onsubmit="return confirm('確認要刪除?');">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="tableborder">
<?=$ecms_hashur['form']?>
<tr class="header">
<td width="7%"><div align="center"><a href="ListLog.php?orderby=0&mydesc=<?=$loginiddesc.$search2?>">ID</a></div></td>
<td width="28%" height="25"><div align="center"><a href="ListLog.php?orderby=1&mydesc=<?=$usernamedesc.$search2?>">登陸用戶</a></div></td>
<td width="20%"><div align="center"><a href="ListLog.php?orderby=2&mydesc=<?=$statusdesc.$search2?>">狀態</a></div></td>
<td width="17%" height="25"><div align="center"><a href="ListLog.php?orderby=3&mydesc=<?=$loginipdesc.$search2?>">登陸IP</a></div></td>
<td width="17%"><div align="center"><a href="ListLog.php?orderby=4&mydesc=<?=$logintimedesc.$search2?>">登陸時間</a></div></td>
<td width="11%" height="25"><div align="center">刪除</div></td>
</tr>
<?
while($r=$empire->fetch($sql))
{
if($r['status'])
{
$status='登陸完畢';
}
else
{
$status=$r['loginauth']?'<font color="red">認證碼錯</font>':'<font color="red">密碼錯</font>';
}
?>
<tr bgcolor="#FFFFFF" id=log<?=$r[loginid]?>>
<td><div align="center"><?=$r[loginid]?></div></td>
<td height="25"><div align="center">
<?=$r[username]?>
</div></td>
<td><div align="center">
<?=$status?>
</div></td>
<td height="25"><div align="center">
<?=$r[loginip]?>:<?=$r[ipport]?>
</div></td>
<td><div align="center">
<?=$r[logintime]?>
</div></td>
<td height="25"><div align="center">[<a href="ListLog.php?enews=DelLog&loginid=<?=$r[loginid]?><?=$ecms_hashur['href']?>" onclick="return confirm('確認要刪除此日誌?');">刪除</a>
<input name="loginid[]" type="checkbox" id="loginid[]" value="<?=$r[loginid]?>" onclick="if(this.checked){log<?=$r[loginid]?>.style.backgroundColor='#DBEAF5';}else{log<?=$r[loginid]?>.style.backgroundColor='#ffffff';}">
]</div></td>
</tr>
<?
}
?>
<tr bgcolor="#FFFFFF">
<td height="25" colspan="6">
<?=$returnpage?>
<input type="submit" name="Submit" value="批量刪除"> <input name="enews" type="hidden" id="phome" value="DelLog_all">
<input type=checkbox name=chkall value=on onClick=CheckAll(this.form)>
選中全部 </td>
</tr>
</table>
</form>
<form action="ListLog.php" method="post" name="dellogform" id="dellogform" onsubmit="return confirm('確認要刪除?');">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<?=$ecms_hashur['form']?>
<tr>
<td><div align="center">
<input name="enews" type="hidden" id="enews" value="DelLog_date">
刪除從
<input name="startday" type="text" id="startday" onclick="setday(this)" value="<?=$startday?>" size="12">
到
<input name="endday" type="text" id="endday" onclick="setday(this)" value="<?=$endday?>" size="12">
之間的日誌
<input type="submit" name="Submit2" value="提交">
</div></td>
</tr>
</table>
</form>
<?
db_close();
$empire=null;
?>
</body>
</html>