This repository has been archived by the owner on Feb 13, 2019. It is now read-only.
/
admin_logger.php
175 lines (156 loc) · 4.28 KB
/
admin_logger.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
<?php
/**
* System-Logger - Admin
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @license http://www.gnu.org/licenses/gpl.txt
* @package Panel
* @version CVS: $Id$
* @link http://www.nutime.de/
* @since File available since Release 1.2.20
*/
define('AREA', 'admin');
/**
* Include our init.php, which manages Sessions, Language etc.
*/
require ("./lib/init.php");
if($page == 'log'
&& $userinfo['change_serversettings'] == '1')
{
if($action == '')
{
$fields = array(
'action' => $lng['logger']['action'],
'date' => $lng['logger']['date'],
'type' => $lng['logger']['type'],
'user' => $lng['logger']['user']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_LOG, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$paging->sortfield = 'date';
$paging->sortorder = 'desc';
$result = $db->query('SELECT * FROM `' . TABLE_PANEL_LOG . '` ' . $paging->getSqlWhere(false) . ' ' . $paging->getSqlOrderBy() . ' ' . $paging->getSqlLimit());
$paging->setEntries($db->num_rows($result));
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$clog = array();
while($row = $db->fetch_array($result))
{
if(!isset($clog[$row['action']])
|| !is_array($clog[$row['action']]))
{
$clog[$row['action']] = array();
}
$clog[$row['action']][$row['logid']] = $row;
}
if($paging->sortfield == 'date'
&& $paging->sortorder == 'desc')
{
krsort($clog);
}
else
{
ksort($clog);
}
$i = 0;
$count = 0;
$log_count = 0;
$log = '';
foreach($clog as $action => $logrows)
{
$_action = 0;
foreach($logrows as $row)
{
if($paging->checkDisplay($i))
{
$row = htmlentities_array($row);
$row['date'] = date("d.m.y H:i:s", $row['date']);
if($_action != $action)
{
switch($action)
{
case USR_ACTION:
$_action = $lng['admin']['customer'];
break;
case RES_ACTION:
$_action = 'Reseller';
break;
case ADM_ACTION:
$_action = 'Administrator';
break;
case CRON_ACTION:
$_action = 'Cronjob';
break;
case LOG_ERROR:
$_action = 'Internal';
break;
default:
$_action = 'Unknown';
break;
}
$row['action'] = $_action;
eval("\$log.=\"" . getTemplate("logger/logger_action") . "\";");
}
$log_count++;
$type = $row['type'];
$_type = 'unknown';
switch($type)
{
case LOG_INFO:
$_type = 'Information';
break;
case LOG_NOTICE:
$_type = 'Notice';
break;
case LOG_WARNING:
$_type = 'Warning';
break;
case LOG_ERR:
$_type = 'Error';
break;
case LOG_CRIT:
$_type = 'Critical';
break;
default:
$_type = 'Unknown';
break;
}
$row['type'] = $_type;
eval("\$log.=\"" . getTemplate("logger/logger_log") . "\";");
$count++;
$_action = $action;
}
}
$i++;
}
eval("echo \"" . getTemplate("logger/logger") . "\";");
}
elseif($action == 'truncate')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$yesterday = time() - (60 * 10);
/* (60*60*24); */
$db->query("DELETE FROM `" . TABLE_PANEL_LOG . "` WHERE `date` < '" . $yesterday . "'");
$log->logAction(ADM_ACTION, LOG_WARNING, "truncated the system-log (mysql)");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
ask_yesno('logger_reallytruncate', $filename, array('page' => $page, 'action' => $action), TABLE_PANEL_LOG);
}
}
}
?>