__( 'Public', 'aicom' ), 'discovery' => __( 'Discovery', 'aicom' ), 'read' => __( 'Read', 'aicom' ), 'write' => __( 'Write', 'aicom' ), 'destructive' => __( 'Destructive', 'aicom' ), 'admin_sensitive' => __( 'Admin Sensitive', 'aicom' ), ]; // Collect which classes actually appear in this window for the legend. $classes_present = []; foreach ( $daily as $day ) { foreach ( array_keys( $day['classes'] ) as $cls ) { $classes_present[ $cls ] = true; } } if ( $filter_date ) { $sessions = AICOM_Sessions::get_all( [ 'log_date' => $filter_date ] ); } else { $sessions = AICOM_Sessions::get_all( [ 'date_from' => $graph_from, 'date_to' => $graph_to ] ); } $session_base_url = add_query_arg( [ 'page' => 'aicom-audit-logs', 'tab' => 'sessions' ], admin_url( 'admin.php' ) ); // ── Logs tab data ────────────────────────────────────────────────────── $filter_tool = sanitize_text_field( wp_unslash( $_GET['tool_name'] ?? '' ) ); $filter_status = sanitize_key( wp_unslash( $_GET['status'] ?? '' ) ); $filter_key_id = absint( wp_unslash( $_GET['api_key_id'] ?? 0 ) ); $filter_ip = sanitize_text_field( wp_unslash( $_GET['remote_ip'] ?? '' ) ); $filter_session_id = absint( wp_unslash( $_GET['session_id'] ?? 0 ) ); $filter_period = sanitize_key( wp_unslash( $_GET['period'] ?? 'today' ) ); $filter_from = sanitize_text_field( wp_unslash( $_GET['date_from'] ?? '' ) ); $filter_to = sanitize_text_field( wp_unslash( $_GET['date_to'] ?? '' ) ); $page_num = max( 1, absint( wp_unslash( $_GET['paged'] ?? 1 ) ) ); $per_page = 50; if ( $filter_period !== 'custom' ) { $now = current_time( 'mysql', true ); switch ( $filter_period ) { case 'today': $filter_from = current_time( 'Y-m-d' ) . ' 00:00:00'; $filter_to = $now; break; case '7days': $filter_from = gmdate( 'Y-m-d', strtotime( '-7 days' ) ) . ' 00:00:00'; $filter_to = $now; break; case '30days': $filter_from = gmdate( 'Y-m-d', strtotime( '-30 days' ) ) . ' 00:00:00'; $filter_to = $now; break; case 'year': $filter_from = gmdate( 'Y' ) . '-01-01 00:00:00'; $filter_to = $now; break; default: $filter_from = ''; $filter_to = ''; } } $filters = array_filter( [ 'tool_name' => $filter_tool, 'status' => $filter_status, 'api_key_id' => $filter_key_id ?: null, 'remote_ip' => $filter_ip, 'session_id' => $filter_session_id ?: null, 'date_from' => $filter_from, 'date_to' => $filter_to, ] ); $result = AICOM_Audit_Logger::query( $filters, $per_page, $page_num ); $logs = $result['items']; $total = $result['total']; $num_pages = (int) ceil( $total / $per_page ); $api_keys = $wpdb->get_results( "SELECT id, label, key_prefix FROM {$wpdb->prefix}aicom_api_keys ORDER BY label", ARRAY_A ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery $status_options = [ '', 'success', 'error', 'blocked_soft_lock', 'blocked_hard_lock', 'denied_scope', 'denied_allowlist', 'validation_failed', 'auth_failed', 'dependency_missing' ]; $period_options = [ 'today' => __( 'Today', 'aicom' ), '7days' => __( 'Last 7 Days', 'aicom' ), '30days' => __( 'Last 30 Days', 'aicom' ), 'year' => __( 'This Year', 'aicom' ), 'custom' => __( 'Custom Range', 'aicom' ), 'all' => __( 'All Time', 'aicom' ), ]; $base_url = admin_url( 'admin.php?page=aicom-audit-logs' ); ?>

( )

__( 'Sessions', 'aicom' ), 'logs' => __( 'Logs', 'aicom' ), 'filters' => __( 'Filters', 'aicom' ), ]; foreach ( $tabs as $slug => $label ) : $is_active = $active_tab === $slug; $tab_url = add_query_arg( [ 'page' => 'aicom-audit-logs', 'tab' => $slug ], admin_url( 'admin.php' ) ); ?>

← ← 0 ) : ?> →
$graph_offset, 'session_date' => $day['date'] ], $session_base_url ) ); $clear_url = esc_url( add_query_arg( [ 'graph_offset' => $graph_offset, 'session_date' => '' ], $session_base_url ) ); ?>

· · 0 ) : ?>
▼

—

>

1 ) : ?>
'aicom-audit-logs', 'tab' => 'filters', 'tool_name' => $filter_tool, 'status' => $filter_status, 'api_key_id' => $filter_key_id ?: null, 'remote_ip' => $filter_ip, 'period' => $filter_period, 'date_from' => $filter_from, 'date_to' => $filter_to, ] ); $base = admin_url( 'admin.php' ) . '?' . http_build_query( $pagination_args ); for ( $p = 1; $p <= $num_pages; $p++ ) : $url = $base . '&paged=' . $p; $cls = $p === $page_num ? 'button button-primary button-small' : 'button button-small'; ?>

—

1 ) : ?>
'aicom-audit-logs', 'tab' => 'logs', 'paged' => $p ], admin_url( 'admin.php' ) ); $cls = $p === $page_num ? 'button button-primary button-small' : 'button button-small'; ?>