Exemplo n.º 1
0
/**
 * Print a HTML code with the content of the logs audited by the remote Sucuri
 * API service, this page is part of the monitoring tool.
 *
 * @return void
 */
function sucuriscan_auditreport()
{
    $audit_report = false;
    $logs4report = SucuriScanOption::get_option(':logs4report');
    if (SucuriScanOption::is_enabled(':audit_report')) {
        $audit_report = SucuriScanAPI::get_audit_report($logs4report);
    }
    $template_variables = array('PageTitle' => 'Audit Reports', 'AuditReport.EventColors' => '', 'AuditReport.EventsPerType' => '', 'AuditReport.EventsPerLogin' => '', 'AuditReport.EventsPerUserCategories' => '', 'AuditReport.EventsPerUserSeries' => '', 'AuditReport.EventsPerIPAddressCategories' => '', 'AuditReport.EventsPerIPAddressSeries' => '', 'AuditReport.Logs4Report' => $logs4report);
    if ($audit_report) {
        $template_variables['AuditReport.EventColors'] = @implode(',', $audit_report['event_colors']);
        // Generate report chart data for the events per type.
        foreach ($audit_report['events_per_type'] as $event => $times) {
            $template_variables['AuditReport.EventsPerType'] .= sprintf("[ '%s', %d ],\n", ucwords($event . " events"), $times);
        }
        // Generate report chart data for the events per login.
        foreach ($audit_report['events_per_login'] as $event => $times) {
            $template_variables['AuditReport.EventsPerLogin'] .= sprintf("[ '%s', %d ],\n", ucwords($event . " logins"), $times);
        }
        // Generate report chart data for the events per user.
        foreach ($audit_report['events_per_user'] as $event => $times) {
            $template_variables['AuditReport.EventsPerUserCategories'] .= sprintf('"%s",', $event);
            $template_variables['AuditReport.EventsPerUserSeries'] .= sprintf('%d,', $times);
        }
        // Generate report chart data for the events per remote address.
        foreach ($audit_report['events_per_ipaddress'] as $event => $times) {
            $template_variables['AuditReport.EventsPerIPAddressCategories'] .= sprintf('"%s",', $event);
            $template_variables['AuditReport.EventsPerIPAddressSeries'] .= sprintf('%d,', $times);
        }
        return SucuriScanTemplate::get_section('integrity-auditreport', $template_variables);
    }
    return '';
}