HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/mu-plugins/plugin-install-audit-log.php
<?php
/**
 * Plugin install/update audit logger.
 */

if (!defined('ABSPATH')) {
    exit;
}

add_action('upgrader_process_complete', function ($upgrader, $options) {
    if (!is_array($options) || (($options['type'] ?? '') !== 'plugin')) {
        return;
    }

    $ip = $_SERVER['REMOTE_ADDR'] ?? '';
    $forwarded_for = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? '';
    $user_id = function_exists('get_current_user_id') ? get_current_user_id() : 0;
    $user = $user_id ? get_userdata($user_id) : null;

    error_log('PLUGIN INSTALL/UPDATE AUDIT: ' . wp_json_encode([
        'options' => $options,
        'remote_addr' => $ip,
        'x_forwarded_for' => $forwarded_for,
        'user_id' => $user_id,
        'user_login' => $user ? $user->user_login : null,
        'request_uri' => $_SERVER['REQUEST_URI'] ?? '',
        'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
        'time' => gmdate('c'),
    ]));
}, 10, 2);