Privacy > * Policy Guide, so a site owner can copy an accurate account of * what this plugin sends where. * * links "Settings" and "Support" next to the plugin on the Plugins page. * * Each section of the report is collected on its own, and one that fails says * so and is skipped. A broken part of the plugin is exactly when this report is * needed, so it must never be the part that stops the report. */ class Sentinel_Support { /** Longest single note or message that goes into the report. */ const NOTE_MAX = 300; const EVENT_ROWS = 15; const PLUGIN_MAX = 60; public static function register(): void { add_filter( 'plugin_action_links_' . WARDPAIR_BASENAME, array( __CLASS__, 'action_links' ) ); add_action( 'admin_init', array( __CLASS__, 'privacy_policy_content' ) ); } // ─── Links ──────────────────────────────────────────────────────────────── /** Is this a customer (paying, or on a trial)? Customers get direct support; everyone else, the forum. */ public static function is_customer(): bool { $fs = function_exists( 'wardpair_fs' ) ? wardpair_fs() : null; return is_object( $fs ) && ( $fs->is_paying() || $fs->is_trial() ); } /** * Where this person should go for help. * customer -> the Freemius "Contact Us" page (reaches the vendor's support email) * otherwise -> the plugin's wordpress.org support forum * Falls back to the same forum if Freemius is not available. Filterable. */ public static function support_url(): string { $url = 'https://wordpress.org/support/plugin/wardpair'; $fs = function_exists( 'wardpair_fs' ) ? wardpair_fs() : null; if ( is_object( $fs ) ) { $url = self::is_customer() ? $fs->contact_url() : $fs->get_support_forum_url(); } return (string) apply_filters( 'wardpair_support_url', $url ); } /** The pricing page, for the contextual "direct support" line. Empty if Freemius is not available. */ public static function upgrade_url(): string { $fs = function_exists( 'wardpair_fs' ) ? wardpair_fs() : null; return is_object( $fs ) ? (string) $fs->get_upgrade_url() : ''; } public static function action_links( array $links ): array { $mine = array( '' . esc_html__( 'Settings', 'wardpair' ) . '', '' . esc_html__( 'Support', 'wardpair' ) . '', ); return array_merge( $mine, $links ); } // ─── Privacy policy text ────────────────────────────────────────────────── public static function privacy_text(): string { $p = array(); $intro = __( 'Wardpair copies your site to a second site that you own, and makes backups. This is what it stores and sends.', 'wardpair' ); $p[] = $intro; $p[] = __( 'On your own server: a log of connection checks and events, a list of backups, and the backup files themselves. A backup contains your whole database, including any personal data your site holds (users, orders, comments, form entries). Treat the backup folder like the database.', 'wardpair' ); $p[] = __( 'To your second site: when two sites are paired, Wardpair copies content, users, settings and files from the primary to the standby over an encrypted, signed connection. The standby is a server you control, so list it as a place your visitors\' data is stored.', 'wardpair' ); $p[] = __( 'To an IP lookup service (api.ipify.org or ipv4.icanhazip.com): only if you tick "Server IP address lookup" in Settings (it is off by default) and the server cannot work out its own public IP address any other way. They receive that server\'s IP address, not your visitors\'.', 'wardpair' ); $alerts = __( 'To the email address you enter for alerts: your site address and a short description of the event, sent through your own site\'s mail setup.', 'wardpair' ); $p[] = $alerts; $p[] = __( 'To Freemius, which handles licensing and updates: account and site details (site address, WordPress, PHP and plugin versions, and your name and email) when you opt in or activate a license. See https://freemius.com/privacy/ .', 'wardpair' ); $p[] = __( 'Wardpair does not send your content, visitor data or backups to the plugin author.', 'wardpair' ); return implode( "\n\n", $p ); } public static function privacy_policy_content(): void { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } wp_add_privacy_policy_content( 'Wardpair', wp_kses_post( wpautop( self::privacy_text(), false ) ) ); } // ═════════════════════════════════════════════════════════════════════════ // Redaction (pure) // ═════════════════════════════════════════════════════════════════════════ /** * Make free text safe to paste somewhere public. Pure. * * Order matters: URLs are cut down to their host first, so a webhook or a * bot token hiding in a path cannot survive, and only then are the * remaining address-like and token-like strings replaced. */ public static function redact( string $text, int $max = self::NOTE_MAX ): string { // Event notes can hold bytes that are not valid UTF-8. json_encode() then // fails and the whole report would be lost, so normalise first. if ( function_exists( 'mb_convert_encoding' ) ) { $text = (string) mb_convert_encoding( $text, 'UTF-8', 'UTF-8' ); } // 1. URLs keep scheme and host; the path and query (where tokens live) go. $text = (string) preg_replace_callback( '~\b(https?)://([^\s/"\'<>?#]+)([^\s"\'<>]*)~i', function ( $m ) { return strtolower( $m[1] ) . '://' . $m[2] . ( '' === $m[3] || '/' === $m[3] ? $m[3] : '/[removed]' ); }, $text ); // 2. Bearer tokens, then "name: value" / "name=value" pairs that look like // secrets. A bare word such as "token" in a sentence is left alone on purpose. $text = (string) preg_replace( '~\bBearer\s+[A-Za-z0-9._\-]+~i', 'Bearer [removed]', $text ); $text = (string) preg_replace( '~\b(secret|token|password|passwd|api[_-]?key|authorization|license[_-]?key)\b\s*[:=]\s*([^\s,;]+)~i', '$1: [removed]', $text ); // 3. Long token-like runs (hex keys, base64, JWT-ish). $text = (string) preg_replace( '~[A-Za-z0-9+/=_\-]{32,}~', '[token]', $text ); // 4. Email addresses. $text = (string) preg_replace( '~[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}~', '[email]', $text ); // 5. IP addresses. IPv6 is matched narrowly (six or more groups, or a "::" // form) so that a time such as 12:30:45 or "Class::method" is left alone. $text = (string) preg_replace( '~\b(?:\d{1,3}\.){3}\d{1,3}\b~', '[ip]', $text ); $text = (string) preg_replace( '~\b(?:[A-Fa-f0-9]{1,4}:){5,7}[A-Fa-f0-9]{1,4}\b~', '[ip]', $text ); $text = (string) preg_replace( '~(? $max ) { $text = mb_substr( $text, 0, max( 0, $max - 3 ) ) . '...'; } return $text; } /** * Lay sections out as plain text. Pure. * * @param array> $sections Title => rows (label => value). */ public static function format_report( array $sections ): string { $out = array(); foreach ( $sections as $title => $rows ) { $out[] = '== ' . $title . ' =='; foreach ( $rows as $label => $value ) { if ( is_bool( $value ) ) { $value = $value ? 'yes' : 'no'; } elseif ( is_array( $value ) ) { $value = $value ? implode( ', ', array_map( 'strval', $value ) ) : '-'; } elseif ( null === $value || '' === $value ) { $value = '-'; } $out[] = $label . ': ' . $value; } $out[] = ''; } return rtrim( implode( "\n", $out ) ) . "\n"; } // ═════════════════════════════════════════════════════════════════════════ // The report // ═════════════════════════════════════════════════════════════════════════ /** * What the display check on the Support tab compares the browser's copy against: the address and * SHA-256 of the plugin's own style and script files. * * @return array{version:string,css:array{url:string,hash:string},js:array{url:string,hash:string}} */ public static function asset_check_data(): array { $files = array( 'css' => 'assets/css/sentinel-admin.css', 'js' => 'assets/js/sentinel-admin.js', ); $out = array( 'version' => WARDPAIR_VERSION ); foreach ( $files as $key => $relative ) { $path = WARDPAIR_DIR . $relative; $hash = is_readable( $path ) ? hash_file( 'sha256', $path ) : false; $out[ $key ] = array( 'url' => WARDPAIR_URL . $relative, 'hash' => is_string( $hash ) ? $hash : '', ); } return $out; } /** Build the whole report as text. */ public static function report(): string { $sections = array( 'Wardpair support report' => self::collect( array( __CLASS__, 'sec_header' ) ), 'Plugin' => self::collect( array( __CLASS__, 'sec_plugin' ) ), 'Server' => self::collect( array( __CLASS__, 'sec_server' ) ), 'Limits and transfer tuning' => self::collect( array( __CLASS__, 'sec_limits' ) ), 'Domain DNS' => self::collect( array( __CLASS__, 'sec_dns' ) ), 'Requirements check' => self::collect( array( __CLASS__, 'sec_requirements' ) ), ); // The paid features' state, in the paid version only. $sections += array( 'Backups' => self::collect( array( __CLASS__, 'sec_backups' ) ), 'Background jobs' => self::collect( array( __CLASS__, 'sec_jobs' ) ), 'Active notices' => self::collect( array( __CLASS__, 'sec_notices' ) ), 'Recent events' => self::collect( array( __CLASS__, 'sec_events' ) ), 'Active plugins' => self::collect( array( __CLASS__, 'sec_plugins' ) ), ); return self::format_report( $sections ); } /** Run one section; a failure becomes one line instead of stopping the report. */ private static function collect( callable $fn ): array { try { return (array) call_user_func( $fn ); } catch ( \Throwable $e ) { return array( 'could not be read' => self::redact( $e->getMessage() ) ); } } private static function sec_header(): array { return array( 'Created' => gmdate( 'Y-m-d H:i:s' ) . ' UTC', 'Note' => 'Contains no keys, tokens, license key, email addresses or full IP addresses. Check it before you post it publicly.', ); } private static function sec_plugin(): array { $mig = Sentinel_Migrate::status(); $err = $mig['error'] ? ( 'step ' . (int) ( $mig['error']['step'] ?? 0 ) . ': ' . self::redact( (string) ( $mig['error']['message'] ?? '' ) ) ) : ''; $peer = Sentinel_Compat::peer_info(); $partner = (string) wp_parse_url( (string) get_option( 'wardpair_partner_url', '' ), PHP_URL_HOST ); return array( 'Wardpair version' => defined( 'WARDPAIR_VERSION' ) ? WARDPAIR_VERSION : '', 'Protocol' => Sentinel_Compat::local_proto(), 'Database schema' => $mig['current'] . ' of ' . $mig['target'], 'Schema error' => $err, 'Role' => (string) get_option( 'wardpair_role', '' ), 'Paired' => (bool) get_option( 'wardpair_is_paired', false ), 'Status' => (string) get_option( 'wardpair_status', '' ), 'Other site' => $partner, 'Other site version' => $peer ? ( (string) ( $peer['version'] ?? '' ) . ' (protocol ' . (int) ( $peer['proto'] ?? 0 ) . ')' ) : 'not reported', ); } private static function sec_server(): array { global $wpdb; $f = Sentinel_Compat::facts(); $ext = array_values( array_filter( array( 'mysqli', 'openssl', 'zlib', 'zip', 'curl', 'mbstring', 'sodium', 'gd', 'xml', 'dom' ), 'extension_loaded' ) ); $sw = isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( (string) $_SERVER['SERVER_SOFTWARE'] ) ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput $theme = wp_get_theme(); return array( 'WordPress' => get_bloginfo( 'version' ), 'PHP' => PHP_VERSION . ' (' . PHP_SAPI . ')', 'Database' => (string) $f['db_info'] . ' [' . (string) $f['db_version'] . ']', 'Web server' => self::redact( $sw, 80 ), 'Memory limit' => size_format( (int) $f['memory'] > 0 ? (int) $f['memory'] : 0 ) ?: 'unlimited', 'Max run time (s)' => (int) $f['exec'], 'PHP extensions' => $ext, 'Functions blocked' => array_values( array_intersect( (array) $f['disabled'], array( 'exec', 'fsockopen', 'stream_socket_client', 'set_time_limit', 'proc_open', 'shell_exec', 'popen' ) ) ), 'Multisite' => (bool) $f['multisite'], 'Object cache' => (bool) wp_using_ext_object_cache(), 'WP cron disabled' => defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON, 'File edits locked' => defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS, 'Outgoing HTTP off' => (bool) $f['http_block'], 'WP_DEBUG' => defined( 'WP_DEBUG' ) && WP_DEBUG, 'Table prefix' => (string) $wpdb->prefix === 'wp_' ? 'default' : 'custom', 'Theme' => $theme->get( 'Name' ) . ' ' . $theme->get( 'Version' ), 'Locale' => get_locale(), 'Timezone' => wp_timezone_string(), ); } /** * The limits that decide whether a large copy survives. PHP's memory_limit is often * higher than what the host really allows, so the container cap and its kill count * are shown next to it. Numbers only: nothing here identifies the site. */ private static function sec_limits(): array { global $wpdb; $read = static function ( array $files ): string { foreach ( $files as $f ) { if ( @is_readable( $f ) ) { return trim( (string) @file_get_contents( $f ) ); } } return ''; }; $size = static function ( $bytes ): string { return ( is_numeric( $bytes ) && (float) $bytes > 0 ) ? size_format( (float) $bytes ) : ''; }; $events = array(); foreach ( explode( "\n", $read( array( '/sys/fs/cgroup/memory.events' ) ) ) as $line ) { $p = explode( ' ', trim( $line ) ); if ( 2 === count( $p ) ) { $events[ $p[0] ] = (int) $p[1]; } } $cap = Sentinel_Utils::container_memory_limit(); $used = $read( array( '/sys/fs/cgroup/memory.current', '/sys/fs/cgroup/memory/memory.usage_in_bytes' ) ); $eff = Sentinel_Utils::effective_memory_limit(); $now = time(); $age = static function ( $ts ) use ( $now ): string { $ts = (int) $ts; return $ts > 0 ? human_time_diff( $ts, $now ) . ' ago' : ''; }; $lock = (int) get_option( 'wardpair_negotiate_lock', 0 ); $dropins = array(); foreach ( array( 'object-cache.php', 'advanced-cache.php', 'db.php' ) as $d ) { if ( file_exists( Sentinel_Utils::content_dir() . '/' . $d ) ) { $dropins[] = $d; } } $curl = function_exists( 'curl_version' ) ? (array) curl_version() : array(); $free_content = function_exists( 'disk_free_space' ) ? @disk_free_space( Sentinel_Utils::content_dir() ) : false; $free_backup = ( function_exists( 'disk_free_space' ) && defined( 'WARDPAIR_BACKUP_DIR' ) && is_dir( WARDPAIR_BACKUP_DIR ) ) ? @disk_free_space( WARDPAIR_BACKUP_DIR ) : false; return array( 'PHP memory_limit' => '-1' === (string) ini_get( 'memory_limit' ) ? '-1 (unlimited)' : (string) ini_get( 'memory_limit' ), 'Host memory cap (container)' => $cap > 0 ? $size( $cap ) : 'none, or not readable from PHP', 'Host memory in use now' => '' !== $used ? $size( $used ) : 'not readable', 'Host memory limit reached (times)' => isset( $events['max'] ) ? $events['max'] : 'not readable', 'Processes ended for memory (oom_kill)' => isset( $events['oom_kill'] ) ? $events['oom_kill'] : 'not readable', 'Memory Wardpair plans with' => $eff > 0 ? $size( $eff ) : 'unlimited', 'WP_MEMORY_LIMIT' => defined( 'WP_MEMORY_LIMIT' ) ? (string) WP_MEMORY_LIMIT : '', 'WP_MAX_MEMORY_LIMIT' => defined( 'WP_MAX_MEMORY_LIMIT' ) ? (string) WP_MAX_MEMORY_LIMIT : '', 'Memory peak of this request' => $size( memory_get_peak_usage( true ) ), 'Max run time (s)' => (int) ini_get( 'max_execution_time' ), 'max_input_time (s)' => (string) ini_get( 'max_input_time' ), 'post_max_size' => (string) ini_get( 'post_max_size' ), 'upload_max_filesize' => (string) ini_get( 'upload_max_filesize' ), 'Database max_allowed_packet' => $size( $wpdb->get_var( 'SELECT @@max_allowed_packet' ) ), 'Free disk (wp-content)' => false !== $free_content ? $size( $free_content ) : 'not readable', 'Free disk (backup folder)' => false !== $free_backup ? $size( $free_backup ) : 'not readable', 'ZIP library' => class_exists( 'ZipArchive' ) ? ( defined( 'ZipArchive::LIBZIP_VERSION' ) ? 'libzip ' . ZipArchive::LIBZIP_VERSION : 'present' ) : 'missing', 'cURL' => $curl ? ( (string) ( $curl['version'] ?? '' ) . ' / ' . (string) ( $curl['ssl_version'] ?? '' ) ) : 'missing', 'OPcache' => (bool) ini_get( 'opcache.enable' ), 'Cache drop-ins present' => $dropins, 'Transfer chunk size in use' => $size( get_option( 'wardpair_chunk_size', 0 ) ), 'Chunk size last negotiated' => $age( get_option( 'wardpair_clone_negotiated_at', 0 ) ), 'Probe ceiling (sizes not tried)' => (int) get_option( 'wardpair_probe_ceiling', 0 ) > 0 ? $size( (int) get_option( 'wardpair_probe_ceiling', 0 ) + 1 ) . ' and above' : 'none', 'Probe ceiling set' => $age( get_option( 'wardpair_probe_ceiling_at', 0 ) ), 'Chunk probe unfinished' => (bool) get_option( 'wardpair_probe_inflight', 0 ), 'Negotiation running now' => $lock > 0 && ( $now - $lock ) < Sentinel_Clone_Primary::NEGOTIATE_ALIVE, ); } /** * What the site's own domain resolves to: counts and families only, never the addresses. * Failover rewrites one record type, so a domain that also publishes the other family, * or sits behind Cloudflare, behaves differently and support needs to see which. */ private static function sec_dns(): array { $host = (string) wp_parse_url( home_url(), PHP_URL_HOST ); if ( '' === $host ) { return array( 'Domain' => 'not readable' ); } $ips = Sentinel_Utils::dns_ips( $host ); $all = array_merge( $ips['v4'], $ips['v6'] ); $edge = $all ? true : false; foreach ( $all as $ip ) { if ( ! Sentinel_Utils::is_cloudflare_edge_ip( (string) $ip ) ) { $edge = false; break; } } $cname = ''; if ( function_exists( 'dns_get_record' ) ) { $c = (array) @dns_get_record( $host, DNS_CNAME ); $cname = ! empty( $c[0]['target'] ) ? (string) $c[0]['target'] : ''; } return array( 'Resolves' => (bool) $all, 'IPv4 (A) records' => count( $ips['v4'] ), 'IPv6 (AAAA) records' => count( $ips['v6'] ), 'CNAME target' => $cname, 'Behind the Cloudflare proxy' => $edge, 'Record type Wardpair manages' => (string) get_option( 'wardpair_cf_record_type', 'A' ), 'IPv6 records present and not proxied' => ! empty( $ips['v6'] ) && ! $edge, ); } private static function sec_requirements(): array { $r = Sentinel_Compat::check(); $out = array(); foreach ( array( 'blockers' => 'BLOCKER', 'warnings' => 'warning', 'notes' => 'note' ) as $k => $tag ) { foreach ( $r[ $k ] as $row ) { $out[ $tag . ' ' . $row['id'] ] = self::redact( $row['label'], 160 ); } } return $out ? $out : array( 'All checks' => 'passed' ); } private static function sec_backups(): array { global $wpdb; $dir = defined( 'WARDPAIR_BACKUP_DIR' ) ? (string) WARDPAIR_BACKUP_DIR : ''; $inside = '' !== $dir && 0 === strpos( wp_normalize_path( $dir ), wp_normalize_path( Sentinel_Utils::content_dir() ) ); $count = (int) $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %i', $wpdb->prefix . 'wardpair_backups' ) ); // phpcs:ignore WordPress.DB.PreparedSQL return array( 'Folder location' => '' === $dir ? 'unknown' : ( $inside ? 'inside wp-content' : 'outside the web root' ), 'Folder writable' => '' !== $dir && is_dir( $dir ) && wp_is_writable( $dir ), 'Backups listed' => $count, 'Schedule' => (string) get_option( 'wardpair_backup_schedule', 'none' ), ); } private static function sec_jobs(): array { if ( ! class_exists( 'ActionScheduler' ) || ! class_exists( 'ActionScheduler_Store' ) ) { return array( 'Action Scheduler' => 'not loaded' ); } $store = ActionScheduler::store(); $out = array(); foreach ( array( 'pending' => ActionScheduler_Store::STATUS_PENDING, 'running' => ActionScheduler_Store::STATUS_RUNNING, 'failed' => ActionScheduler_Store::STATUS_FAILED ) as $label => $status ) { $out[ $label ] = (int) $store->query_actions( array( 'group' => 'wardpair', 'status' => $status ), 'count' ); } return $out; } private static function sec_notices(): array { $out = array(); foreach ( Sentinel_Notices::local() as $n ) { $out[ (string) $n['id'] ] = $n['severity'] . ': ' . self::redact( (string) $n['title'], 160 ); } foreach ( Sentinel_Notices::peer()['items'] as $n ) { $out[ 'other site / ' . (string) $n['id'] ] = $n['severity'] . ': ' . self::redact( (string) $n['title'], 160 ); } return $out ? $out : array( 'None' => '' ); } private static function sec_events(): array { global $wpdb; $rows = $wpdb->get_results( $wpdb->prepare( 'SELECT event_type, triggered_at, notes FROM %i ORDER BY id DESC LIMIT %d', $wpdb->prefix . 'wardpair_events', (int) self::EVENT_ROWS ), ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL $out = array(); foreach ( (array) $rows as $i => $r ) { $out[ ( $i + 1 ) . ' ' . (string) $r['triggered_at'] ] = self::redact( (string) $r['event_type'], 40 ) . ' | ' . self::redact( (string) $r['notes'] ); } return $out ? $out : array( 'None' => '' ); } private static function sec_plugins(): array { if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $all = get_plugins(); $active = (array) get_option( 'active_plugins', array() ); $out = array(); foreach ( $active as $file ) { if ( count( $out ) >= self::PLUGIN_MAX ) { $out['…'] = ( count( $active ) - self::PLUGIN_MAX ) . ' more not listed'; break; } if ( isset( $all[ $file ] ) ) { $out[ self::redact( (string) $all[ $file ]['Name'], 60 ) ] = (string) $all[ $file ]['Version']; } } return $out ? $out : array( 'None' => '' ); } }