/** * Get a list of denial types using the reason of the blocking of a request from * the from the audit logs. Examples of denial types can be: "Bad bot access * denied", "Access to restricted folder", "Blocked by IDS", etc. * * @param array $access_logs A list of objects with the detailed version of each request blocked by our service. * @param boolean $in_html Whether the list should be converted to a HTML select options or not. * @return array Either a list of unique blocking types, or a HTML code. */ function sucuriscan_monitoring_denial_types($access_logs = array(), $in_html = true) { $types = array(); if ($access_logs && !empty($access_logs)) { foreach ($access_logs as $access_log) { if (!array_key_exists($access_log->sucuri_block_reason, $types)) { $denial_type_k = SucuriScan::human2var($access_log->sucuri_block_reason); $denial_type_v = $access_log->sucuri_block_reason; if (empty($denial_type_v)) { $denial_type_v = 'Unknown'; } $types[$denial_type_k] = $denial_type_v; } } } if ($in_html) { $html_types = '<option value="">Filter</option>'; $selected = SucuriScanRequest::post(':monitoring_denial_type', '.+'); foreach ($types as $type_key => $type_value) { $selected_tag = $type_key === $selected ? 'selected="selected"' : ''; $html_types .= sprintf('<option value="%s" %s>%s</option>', SucuriScan::escape($type_key), $selected_tag, SucuriScan::escape($type_value)); } return $html_types; } return $types; }