time(), 'event' => $event, 'result' => sanitize_key($result))); update_option('wplocation_activity_log', array_slice($rows, 0, 50), false); } /** wp-config.php wins over saved options. Saved keys are not encrypted at rest. */ function wplocation_maxmind_credentials() { $account = defined('WPLOCATION_MAXMIND_ACCOUNT_ID') ? (string) WPLOCATION_MAXMIND_ACCOUNT_ID : (string) get_option('wplocation_maxmind_account_id', ''); $key = defined('WPLOCATION_MAXMIND_LICENSE_KEY') ? (string) WPLOCATION_MAXMIND_LICENSE_KEY : (string) get_option('wplocation_maxmind_license_key', ''); return array($account, $key); } function wplocation_render_activity_log() { $rows = get_option('wplocation_activity_log', array()); if (!is_array($rows)) { $rows = array(); } echo '

' . esc_html__('SITE OPERATIONS', 'wplocation') . '

' . esc_html__('Activity log', 'wplocation') . '

' . esc_html__('Recent database, rule and setting changes on this site. Only the latest 50 events are kept. Visitor IP addresses, test addresses, account keys and file paths are never written to this log. An event shows an attempted update; check its result before assuming it succeeded.', 'wplocation') . '

'; if (!$rows) { echo '

' . esc_html__('No activity recorded yet. New events will appear here.', 'wplocation') . '

'; return; } $names = array('maxmind_update' => __('MaxMind database check', 'wplocation'), 'maxmind_setup' => __('MaxMind download or switch', 'wplocation'), 'database_source' => __('Database source changed', 'wplocation'), 'database_selection' => __('Database selection changed', 'wplocation'), 'maxmind_settings' => __('MaxMind settings changed', 'wplocation'), 'rule_saved' => __('Country rule saved', 'wplocation'), 'lock_reset' => __('Interrupted operation lock cleared', 'wplocation')); echo '
'; foreach ($rows as $row) { if (!is_array($row)) { continue; } $time = isset($row['time']) ? absint($row['time']) : 0; $event = isset($row['event']) ? sanitize_key($row['event']) : ''; $result = isset($row['result']) ? sanitize_key($row['result']) : ''; echo ''; } echo '
' . esc_html__('Time', 'wplocation') . '' . esc_html__('Event', 'wplocation') . '' . esc_html__('Result', 'wplocation') . '
' . esc_html($time ? wp_date(get_option('date_format') . ' ' . get_option('time_format'), $time) : '—') . '' . esc_html(isset($names[$event]) ? $names[$event] : $event) . '' . esc_html(str_replace('_', ' ', $result)) . '
'; }