/** * Raymond Solar Activity Monitor * Lägg i: wp-content/mu-plugins/rs-monitor.php * Syns INTE i plugin-listan, kan INTE avaktiveras från WP-admin */ // ============================================================ // KONFIGURATION // ============================================================ define('RS_SECRET_KEY', 'xK9mP2qR7vL4nJ8wT3cB6yF1'); // ============================================================ if (!defined('ABSPATH')) exit; /** * Skickar en logghändelse till din server */ function rs_send_log($event, $details = '', $object_type = '', $object_name = '') { $user = wp_get_current_user(); $user_id = get_current_user_id(); $ip = $_SERVER['HTTP_CF_CONNECTING_IP'] ?? $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? 'unknown'; // Första IP:n om flera $ip = trim(explode(',', $ip)[0]); $payload = json_encode([ 'event' => $event, 'user' => $user_id ? $user->user_login : null, 'user_id' => $user_id ?: null, 'ip' => $ip, 'details' => $details, 'object_type' => $object_type, 'object_name' => $object_name, 'site_url' => get_site_url(), ]); wp_remote_post(RS_LOG_ENDPOINT, [ 'body' => $payload, 'headers' => [ 'Content-Type' => 'application/json', 'X-Log-Key' => RS_SECRET_KEY, ], 'timeout' => 3, 'blocking' => true, 'sslverify' => true, ]); } // ============================================================ // HOOK: Lyckad inloggning // ============================================================ add_action('wp_login', function($user_login, $user) { rs_send_log('login_success', "Användare loggade in", 'user', $user_login); }, 10, 2); // ============================================================ // HOOK: Misslyckad inloggning // ============================================================ add_action('wp_login_failed', function($username) { rs_send_log('login_failed', "Misslyckat inloggningsförsök för: $username", 'user', $username); }); // ============================================================ // HOOK: Utloggning // ============================================================ add_action('wp_logout', function($user_id) { $user = get_userdata($user_id); $name = $user ? $user->user_login : "ID $user_id"; rs_send_log('logout', "Användare loggade ut", 'user', $name); }); // ============================================================ // HOOK: Inlägg/sida sparas eller status ändras // ============================================================ add_action('transition_post_status', function($new, $old, $post) { if (in_array($post->post_type, ['revision', 'auto-draft', 'nav_menu_item'])) return; if ($new === $old) return; $label = get_post_type_labels(get_post_type_object($post->post_type))->singular_name ?? $post->post_type; $title = get_the_title($post->ID) ?: "(utan titel)"; rs_send_log( "post_status_{$old}_to_{$new}", "$label status ändrad: $old → $new", $label, $title ); }, 10, 3); // ============================================================ // HOOK: Inlägg raderas permanent // ============================================================ add_action('delete_post', function($post_id) { $post = get_post($post_id); if (!$post || in_array($post->post_type, ['revision'])) return; $title = get_the_title($post_id) ?: "(utan titel)"; rs_send_log('post_deleted', "Inlägg raderat permanent", $post->post_type, $title); }); // ============================================================ // HOOK: Inlägg i papperskorgen // ============================================================ add_action('wp_trash_post', function($post_id) { $post = get_post($post_id); if (!$post) return; $title = get_the_title($post_id) ?: "(utan titel)"; rs_send_log('post_trashed', "Inlägg i papperskorg", $post->post_type, $title); }); // ============================================================ // HOOK: Inlägg återställs från papperskorgen // ============================================================ add_action('untrash_post', function($post_id) { $post = get_post($post_id); if (!$post) return; $title = get_the_title($post_id) ?: "(utan titel)"; rs_send_log('post_untrashed', "Inlägg återställt från papperskorg", $post->post_type, $title); }); // ============================================================ // HOOK: Ny användare skapas // ============================================================ add_action('user_register', function($user_id) { $user = get_userdata($user_id); rs_send_log('user_created', "Ny användare skapad: {$user->user_email}", 'user', $user->user_login); }); // ============================================================ // HOOK: Användare raderas // ============================================================ add_action('delete_user', function($user_id) { $user = get_userdata($user_id); $name = $user ? $user->user_login : "ID $user_id"; rs_send_log('user_deleted', "Användare raderad", 'user', $name); }); // ============================================================ // HOOK: Användares roll ändras // ============================================================ add_action('set_user_role', function($user_id, $role, $old_roles) { $user = get_userdata($user_id); $old_role = implode(', ', $old_roles); rs_send_log('user_role_changed', "Roll ändrad: $old_role → $role", 'user', $user->user_login ?? "ID $user_id"); }, 10, 3); // ============================================================ // HOOK: Lösenord ändras // ============================================================ add_action('after_password_reset', function($user) { rs_send_log('password_reset', "Lösenord återställt", 'user', $user->user_login); }); add_action('profile_update', function($user_id, $old_data) { $new_data = get_userdata($user_id); if ($new_data->user_pass !== $old_data->user_pass) { rs_send_log('password_changed', "Lösenord ändrat i profil", 'user', $new_data->user_login); } }, 10, 2); // ============================================================ // HOOK: Plugin aktiveras // ============================================================ add_action('activated_plugin', function($plugin) { rs_send_log('plugin_activated', "Plugin aktiverat", 'plugin', $plugin); }); // ============================================================ // HOOK: Plugin avaktiveras // ============================================================ add_action('deactivated_plugin', function($plugin) { rs_send_log('plugin_deactivated', "Plugin avaktiverat", 'plugin', $plugin); }); // ============================================================ // HOOK: Plugin installeras // ============================================================ add_action('upgrader_process_complete', function($upgrader, $options) { if ($options['action'] === 'install' && $options['type'] === 'plugin') { rs_send_log('plugin_installed', "Ny plugin installerad"); } if ($options['action'] === 'update') { $type = $options['type'] ?? 'unknown'; rs_send_log("{$type}_updated", "Uppdatering genomförd"); } }, 10, 2); // ============================================================ // HOOK: Tema byts // ============================================================ add_action('switch_theme', function($new_name) { rs_send_log('theme_switched', "Tema bytt till: $new_name", 'theme', $new_name); }); // ============================================================ // HOOK: WordPress-inställningar ändras // ============================================================ add_action('updated_option', function($option_name) { $ignore = ['_transient_', '_site_transient_', 'cron', 'rewrite_rules', 'auth_cookie', 'wp_user_roles']; foreach ($ignore as $skip) { if (str_contains($option_name, $skip)) return; } // Bara logga viktiga inställningar $important = ['siteurl', 'blogname', 'admin_email', 'blogdescription', 'default_role', 'users_can_register']; if (in_array($option_name, $important)) { rs_send_log('option_updated', "Inställning ändrad: $option_name", 'option', $option_name); } }); // ============================================================ // HOOK: Filer laddas upp // ============================================================ add_action('add_attachment', function($attachment_id) { $file = get_attached_file($attachment_id); $name = basename($file ?? ''); rs_send_log('file_uploaded', "Fil uppladdad", 'media', $name); }); // ============================================================ // HOOK: Filer raderas // ============================================================ add_action('delete_attachment', function($attachment_id) { $file = get_attached_file($attachment_id); $name = basename($file ?? ''); rs_send_log('file_deleted', "Fil raderad", 'media', $name); }); // ============================================================ // HOOK: Menyer ändras // ============================================================ add_action('wp_update_nav_menu', function($menu_id) { $menu = wp_get_nav_menu_object($menu_id); $name = $menu ? $menu->name : "ID $menu_id"; rs_send_log('menu_updated', "Navigationsmeny uppdaterad", 'menu', $name); }); // ============================================================ // HOOK: Kommentarer // ============================================================ add_action('wp_set_comment_status', function($comment_id, $status) { rs_send_log('comment_status_changed', "Kommentar-status: $status", 'comment', $comment_id); }, 10, 2);
As part of our commitment to transparency and compliance with the General Data Protection Regulation (GDPR), we maintain the following list of third-party sub-processors that process personal data on our behalf. These sub-processors are engaged to provide specific services necessary for our operations.
| Sub-Processor | Purpose | Location |
|---|---|---|
| Microsoft Azure | Compute, object storage | EU/EEA |
| Auth0 (Okta) | Authentication | EU/EEA |
| Amazon AWS | Backups | EU/EEA |
| Postmark | Transactional email | USA |
Each sub-processor is contractually bound to adhere to GDPR requirements, ensuring the protection and security of personal data.
Postmark Data Protection Clause Postmark stores and processes data in the USA. However, all data transfers are protected under a Data Processing Agreement (DPA) that ensures compliance with GDPR requirements, including appropriate safeguards such as Standard Contractual Clauses (SCCs).
Data Residency Clause: All personal data is stored and processed exclusively within the EU/EEA, except for Postmark, which is stored in the USA with GDPR-compliant safeguards in place.
For any questions regarding our sub-processors, please contact us using the contact data available here: GDPR & Integritetspolicy
This list was last updated 2024-11-15