/usr/share/zabbix/auditlogs.php is in zabbix-frontend-php 1:2.2.7+dfsg-2+deb8u3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <?php
/*
** Zabbix
** Copyright (C) 2001-2014 Zabbix SIA
**
** 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.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__).'/include/config.inc.php';
require_once dirname(__FILE__).'/include/audit.inc.php';
require_once dirname(__FILE__).'/include/actions.inc.php';
require_once dirname(__FILE__).'/include/users.inc.php';
$page['title'] = _('Audit logs');
$page['file'] = 'auditlogs.php';
$page['hist_arg'] = array();
$page['scripts'] = array('class.calendar.js', 'gtlc.js');
$page['type'] = detect_page_type(PAGE_TYPE_HTML);
require_once dirname(__FILE__).'/include/page_header.php';
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields = array(
'action' => array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(-1, 6), null),
'resourcetype' => array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(-1, 31), null),
'filter_rst' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), null),
'filter_set' => array(T_ZBX_STR, O_OPT, P_SYS, null, null),
'alias' => array(T_ZBX_STR, O_OPT, P_SYS, null, null),
'period' => array(T_ZBX_INT, O_OPT, null, null, null),
'dec' => array(T_ZBX_INT, O_OPT, null, null, null),
'inc' => array(T_ZBX_INT, O_OPT, null, null, null),
'left' => array(T_ZBX_INT, O_OPT, null, null, null),
'right' => array(T_ZBX_INT, O_OPT, null, null, null),
'stime' => array(T_ZBX_STR, O_OPT, null, null, null),
// ajax
'favobj' => array(T_ZBX_STR, O_OPT, P_ACT, null, null),
'favref' => array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})&&"filter"=={favobj}'),
'favstate' => array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})&&"filter"=={favobj}'),
'favid' => array(T_ZBX_INT, O_OPT, P_ACT, null, null)
);
check_fields($fields);
/*
* Ajax
*/
if (isset($_REQUEST['favobj'])) {
if ($_REQUEST['favobj'] == 'filter') {
CProfile::update('web.auditlogs.filter.state', $_REQUEST['favstate'], PROFILE_TYPE_INT);
}
// saving fixed/dynamic setting to profile
if ($_REQUEST['favobj'] == 'timelinefixedperiod') {
if (isset($_REQUEST['favid'])) {
CProfile::update('web.auditlogs.timelinefixed', $_REQUEST['favid'], PROFILE_TYPE_INT);
}
}
}
if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) {
require_once dirname(__FILE__).'/include/page_footer.php';
exit();
}
/*
* Filter
*/
if (isset($_REQUEST['filter_rst'])) {
$_REQUEST['alias'] = '';
$_REQUEST['action'] = -1;
$_REQUEST['resourcetype'] = -1;
}
else {
$_REQUEST['alias'] = get_request('alias', CProfile::get('web.auditlogs.filter.alias', ''));
$_REQUEST['action'] = get_request('action', CProfile::get('web.auditlogs.filter.action', -1));
$_REQUEST['resourcetype'] = get_request('resourcetype', CProfile::get('web.auditlogs.filter.resourcetype', -1));
}
if (isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])) {
CProfile::update('web.auditlogs.filter.alias', $_REQUEST['alias'], PROFILE_TYPE_STR);
CProfile::update('web.auditlogs.filter.action', $_REQUEST['action'], PROFILE_TYPE_INT);
CProfile::update('web.auditlogs.filter.resourcetype', $_REQUEST['resourcetype'], PROFILE_TYPE_INT);
}
/*
* Display
*/
$effectivePeriod = navigation_bar_calc('web.auditlogs.timeline', 0, true);
$data = array(
'stime' => get_request('stime'),
'actions' => array(),
'action' => get_request('action'),
'resourcetype' => get_request('resourcetype'),
'alias' => get_request('alias')
);
$from = zbxDateToTime($data['stime']);
$till = $from + $effectivePeriod;
// get audit
$sqlWhere = array();
if (!empty($data['alias'])) {
$sqlWhere['alias'] = ' AND u.alias='.zbx_dbstr($data['alias']);
}
if ($data['action'] > -1) {
$sqlWhere['action'] = ' AND a.action='.zbx_dbstr($data['action']);
}
if ($data['resourcetype'] > -1) {
$sqlWhere['resourcetype'] = ' AND a.resourcetype='.zbx_dbstr($data['resourcetype']);
}
$sqlWhere['from'] = ' AND a.clock>'.$from;
$sqlWhere['till'] = ' AND a.clock<'.$till;
$sql = 'SELECT a.auditid,a.clock,u.alias,a.ip,a.resourcetype,a.action,a.resourceid,a.resourcename,a.details'.
' FROM auditlog a,users u'.
' WHERE a.userid=u.userid'.
implode('', $sqlWhere).
andDbNode('u.userid', get_current_nodeid(null, PERM_READ)).
' ORDER BY a.clock DESC';
$dbAudit = DBselect($sql, $config['search_limit'] + 1);
while ($audit = DBfetch($dbAudit)) {
switch ($audit['action']) {
case AUDIT_ACTION_ADD:
$action = _('Added');
break;
case AUDIT_ACTION_UPDATE:
$action = _('Updated');
break;
case AUDIT_ACTION_DELETE:
$action = _('Deleted');
break;
case AUDIT_ACTION_LOGIN:
$action = _('Login');
break;
case AUDIT_ACTION_LOGOUT:
$action = _('Logout');
break;
case AUDIT_ACTION_ENABLE:
$action = _('Enabled');
break;
case AUDIT_ACTION_DISABLE:
$action = _('Disabled');
break;
default:
$action = _('Unknown action');
}
$audit['action'] = $action;
$audit['resourcetype'] = audit_resource2str($audit['resourcetype']);
if (empty($audit['details'])) {
$audit['details'] = DBfetchArray(DBselect(
'SELECT ad.table_name,ad.field_name,ad.oldvalue,ad.newvalue'.
' FROM auditlog_details ad'.
' WHERE ad.auditid='.$audit['auditid']
));
}
$data['actions'][$audit['auditid']] = $audit;
}
if (!empty($data['actions'])) {
order_result($data['actions'], 'clock', ZBX_SORT_DOWN);
}
// get paging
$data['paging'] = getPagingLine($data['actions']);
// get timeline
unset($sqlWhere['from'], $sqlWhere['till']);
$sql = 'SELECT MIN(a.clock) AS clock'.
' FROM auditlog a,users u'.
' WHERE a.userid=u.userid'.
implode('', $sqlWhere).
andDbNode('u.userid', get_current_nodeid(null, PERM_READ));
$firstAudit = DBfetch(DBselect($sql, $config['search_limit'] + 1));
$data['timeline'] = array(
'period' => $effectivePeriod,
'starttime' => date(TIMESTAMP_FORMAT, $firstAudit ? $firstAudit['clock'] : null),
'usertime' => isset($_REQUEST['stime']) ? date(TIMESTAMP_FORMAT, zbxDateToTime($data['stime']) + $effectivePeriod) : null
);
// render view
$auditView = new CView('administration.auditlogs.list', $data);
$auditView->render();
$auditView->show();
require_once dirname(__FILE__).'/include/page_footer.php';
|