= 90 && empty($s['HTTP_SEC_CH_UA']) && !empty($s['HTTPS'])) { $fired[] = 'f4.ua_inconsistent_sec_ch'; } if (self::header_order_anomaly($s, $ua)) { $fired[] = 'f4.header_order_anomaly'; } $remote = (string) ($s['REMOTE_ADDR'] ?? ''); if ($fired && self::is_datacenter($remote)) { $fired[] = 'f4.hosting_hostname'; } $ja3 = (string) ($s['HTTP_CF_JA3_HASH'] ?? ''); if ($ja3 !== '' && in_array($ja3, self::known_bad_ja3(), true)) { $fired[] = 'f4.ja3_known_bad'; } $referrer = (string) ($s['HTTP_REFERER'] ?? ''); $host = (string) ($s['HTTP_HOST'] ?? ''); if ($referrer !== '') { $ref_host = strtolower((string) wp_parse_url($referrer, PHP_URL_HOST)); if ($ref_host !== '' && $host !== '' && $ref_host === strtolower($host)) { $path = (string) wp_parse_url($referrer, PHP_URL_PATH); if ($path !== '' && $path === (string) ($s['REQUEST_URI'] ?? '')) { $fired[] = 'f7.referrer_self_loop'; } } if (preg_match('/(google|bing|yahoo|duckduckgo)\./i', $ref_host) && empty($s['HTTP_ACCEPT_LANGUAGE'])) { $fired[] = 'f7.referrer_spoofed'; } } $query = []; parse_str((string) wp_parse_url((string) ($s['REQUEST_URI'] ?? ''), PHP_URL_QUERY), $query); if (!empty($query['utm_source'])) { $source = strtolower((string) $query['utm_source']); if (in_array($source, ['test', 'bot', 'crawler', 'spider', 'null', 'undefined'], true)) { $fired[] = 'f7.utm_bot_pattern'; } if (in_array($source, ['google', 'googleads', 'adwords', 'bing', 'facebook'], true) && empty($query['gclid']) && empty($query['msclkid']) && empty($query['fbclid'])) { $fired[] = 'f7.paid_source_mismatch'; } } if (in_array('f7.referrer_spoofed', $fired, true)) { $fired = array_values(array_diff($fired, ['f4.missing_accept_language'])); } return array_values(array_unique($fired)); } public static function score($server = null) { return AdGhost_Signal_Registry::score(self::evaluate($server)); } private static function header_order_anomaly(array $s, $ua) { if ($ua === '' || strpos($ua, 'mozilla') === false) { return false; } $order = []; foreach (array_keys($s) as $key) { if (strpos($key, 'HTTP_') === 0) { $order[] = $key; } } if (count($order) < 4) { return true; } foreach (['HTTP_ACCEPT', 'HTTP_ACCEPT_ENCODING', 'HTTP_ACCEPT_LANGUAGE'] as $expected) { if (!in_array($expected, $order, true)) { return true; } } return false; } private static function is_datacenter($ip) { if ($ip === '' || !filter_var($ip, FILTER_VALIDATE_IP)) { return false; } $key = 'adghost_dc_' . md5($ip); $cached = get_transient($key); if ($cached !== false) { return $cached === 'yes'; } if (!self::dns_budget()) { return false; } $host = @gethostbyaddr($ip); $hit = false; if ($host && $host !== $ip) { $host = strtolower($host); foreach (self::DATACENTER_HOSTS as $needle) { if (strpos($host, $needle) !== false) { $hit = true; break; } } } set_transient($key, $hit ? 'yes' : 'no', DAY_IN_SECONDS); return $hit; } private static function dns_budget() { $key = 'adghost_dns_budget_' . gmdate('YmdHi'); $spent = (int) get_transient($key); if ($spent >= self::DNS_LOOKUPS_PER_MINUTE) { return false; } set_transient($key, $spent + 1, 2 * MINUTE_IN_SECONDS); return true; } private static function known_bad_ja3() { return (array) apply_filters('adghost_ivt_known_bad_ja3', []); } }