Пример #1
0
            $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=' . zbx_dbstr($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'], ZBX_SORT_DOWN, new CUrl('auditlogs.php'));
// 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);
$firstAudit = DBfetch(DBselect($sql, $config['search_limit'] + 1));
$data['timeline'] = ['period' => $effectivePeriod, 'starttime' => date(TIMESTAMP_FORMAT, $firstAudit ? $firstAudit['clock'] : null), 'usertime' => isset($_REQUEST['stime']) ? date(TIMESTAMP_FORMAT, zbxDateToTime($data['stime']) + $effectivePeriod) : null];
Пример #2
0
            $action = S_LOGIN;
            break;
        case AUDIT_ACTION_LOGOUT:
            $action = S_LOGOUT;
            break;
        case AUDIT_ACTION_ENABLE:
            $action = S_ENABLED;
            break;
        case AUDIT_ACTION_DISABLE:
            $action = S_DISABLED;
            break;
        default:
            $action = S_UNKNOWN_ACTION;
    }
    $row['action'] = $action;
    $row['resourcetype'] = audit_resource2str($row['resourcetype']);
    $actions[$row['auditid']] = $row;
}
// sorting && paging
order_result($actions, 'clock', ZBX_SORT_DOWN);
$paging = getPagingLine($actions);
//---------
foreach ($actions as $num => $row) {
    if (empty($row['details'])) {
        $details = array();
        $sql = 'SELECT table_name,field_name,oldvalue,newvalue ' . ' FROM auditlog_details ' . ' WHERE auditid=' . $row['auditid'];
        $db_details = DBselect($sql);
        while ($db_detail = DBfetch($db_details)) {
            $details[] = array($db_detail['table_name'] . '.' . $db_detail['field_name'] . ': ' . $db_detail['oldvalue'] . ' => ' . $db_detail['newvalue'], BR());
        }
    } else {
Пример #3
0
            case AUDIT_ACTION_DISABLE:
                $action = S_DISABLED;
                break;
            default:
                $action = S_UNKNOWN_ACTION;
        }
        if ('' == $row['details'] || '0' == $row['details']) {
            $details = array();
            $db_details = DBselect('select table_name,field_name,oldvalue,newvalue from auditlog_details where auditid=' . $row['auditid']);
            while (NULL != ($db_detail = DBfetch($db_details))) {
                array_push($details, array($db_detail['table_name'] . '.' . $db_detail['field_name'] . ': ' . $db_detail['oldvalue'] . ' => ' . $db_detail['newvalue'], BR()));
            }
        } else {
            $details = $row['details'];
        }
        $table->addRow(array(date('Y.M.d H:i:s', $row['clock']), $row['alias'], $row['ip'], audit_resource2str($row['resourcetype']), $action, $row['resourceid'], $row['resourcename'], new CCol($details)));
        $row_count++;
    }
    $numrows = new CSpan(null, 'info');
    $numrows->addOption('name', 'numrows');
    $header = get_table_header(array(S_AUDIT_LOGS, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
    show_table_header($header, $frmForm);
} else {
    if (1 == $config) {
        $table = get_history_of_actions($_REQUEST["start"], PAGE_SIZE, $sql_cond);
        $row_count = $table->GetNumRows();
        $numrows = new CSpan(null, 'info');
        $numrows->addOption('name', 'numrows');
        $header = get_table_header(array(S_AUDIT_ACTIONS, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
        show_table_header($header, $frmForm);
    }
// create filter
$filterForm = new CForm('get');
$filterForm->setAttribute('name', 'zbx_filter');
$filterForm->setAttribute('id', 'zbx_filter');
$filterTable = new CTable('', 'filter');
$actionComboBox = new CComboBox('action', $this->data['action']);
$actionComboBox->addItem(-1, _('All'));
$actionComboBox->addItem(AUDIT_ACTION_LOGIN, _('Login'));
$actionComboBox->addItem(AUDIT_ACTION_LOGOUT, _('Logout'));
$actionComboBox->addItem(AUDIT_ACTION_ADD, _('Add'));
$actionComboBox->addItem(AUDIT_ACTION_UPDATE, _('Update'));
$actionComboBox->addItem(AUDIT_ACTION_DELETE, _('Delete'));
$actionComboBox->addItem(AUDIT_ACTION_ENABLE, _('Enable'));
$actionComboBox->addItem(AUDIT_ACTION_DISABLE, _('Disable'));
$resourceComboBox = new CComboBox('resourcetype', $this->data['resourcetype']);
$resourceComboBox->addItems(array(-1 => _('All')) + audit_resource2str());
$filterTable->addRow(array(array(bold(_('User')), SPACE, new CTextBox('alias', $this->data['alias'], 20), new CButton('btn1', _('Select'), 'return PopUp("popup.php?dstfrm=' . $filterForm->getName() . '&dstfld1=alias&srctbl=users&srcfld1=alias&real_hosts=1");', 'filter-select-button')), array(bold(_('Action')), SPACE, $actionComboBox), array(bold(_('Resource')), SPACE, $resourceComboBox)));
$filterButton = new CButton('filter', _('Filter'), "javascript: create_var('zbx_filter', 'filter_set', '1', true);");
$filterButton->useJQueryStyle('main');
$resetButton = new CButton('filter_rst', _('Reset'), 'javascript: var uri = new Curl(location.href); uri.setArgument("filter_rst", 1); location.href = uri.getUrl();');
$resetButton->useJQueryStyle();
$buttonsDiv = new CDiv(array($filterButton, SPACE, $resetButton));
$buttonsDiv->setAttribute('style', 'padding: 4px 0;');
$filterTable->addRow(new CCol($buttonsDiv, 'controls', 3));
$filterForm->addItem($filterTable);
$auditWidget->addFlicker($filterForm, CProfile::get('web.auditlogs.filter.state', 1));
$auditWidget->addFlicker(new CDiv(null, null, 'scrollbar_cntr'), CProfile::get('web.auditlogs.filter.state', 1));
// create form
$auditForm = new CForm('get');
$auditForm->setName('auditForm');
// create table
** 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.
**/
$auditWidget = (new CWidget())->setTitle(_('Audit log'));
// header
// create filter
$filterForm = new CFilter('web.auditlogs.filter.state');
$filterColumn = new CFormList();
$filterColumn->addRow(_('User'), [(new CTextBox('alias', $this->data['alias']))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), (new CButton('btn1', _('Select')))->addClass(ZBX_STYLE_BTN_GREY)->onClick('return PopUp("popup.php?dstfrm=zbx_filter&dstfld1=alias&srctbl=users&srcfld1=alias");')]);
$filterColumn->addRow(_('Action'), new CComboBox('action', $this->data['action'], null, [-1 => _('All'), AUDIT_ACTION_LOGIN => _('Login'), AUDIT_ACTION_LOGOUT => _('Logout'), AUDIT_ACTION_ADD => _('Add'), AUDIT_ACTION_UPDATE => _('Update'), AUDIT_ACTION_DELETE => _('Delete'), AUDIT_ACTION_ENABLE => _('Enable'), AUDIT_ACTION_DISABLE => _('Disable')]));
$filterColumn->addRow(_('Resource'), new CComboBox('resourcetype', $this->data['resourcetype'], null, [-1 => _('All')] + audit_resource2str()));
$filterForm->addColumn($filterColumn)->addNavigator();
$auditWidget->addItem($filterForm);
// create form
$auditForm = (new CForm('get'))->setName('auditForm');
// create table
$auditTable = (new CTableInfo())->setHeader([_('Time'), _('User'), _('IP'), _('Resource'), _('Action'), _('ID'), _('Description'), _('Details')]);
foreach ($this->data['actions'] as $action) {
    $details = [];
    if (is_array($action['details'])) {
        foreach ($action['details'] as $detail) {
            $details[] = [$detail['table_name'] . '.' . $detail['field_name'] . NAME_DELIMITER . $detail['oldvalue'] . ' => ' . $detail['newvalue'], BR()];
        }
    } else {
        $details = $action['details'];
    }