$value) { try { $transmit_string .= "$name=$value; "; } catch (Exception $e) { continue; } } return $transmit_string; } } if (!function_exists('encode_visitor_cookies')) { function encode_visitor_cookies() { return cloak_encode_visitor_cookies(); } } if (!function_exists('cloak_forward_response_cookies')) { function cloak_forward_response_cookies($ch, $headerLine) { if (preg_match('/^Set-Cookie:/mi', $headerLine, $cookie)) { header($headerLine, false); } return strlen($headerLine); } } if (!function_exists('forward_response_cookies')) { function forward_response_cookies($ch, $headerLine) { return cloak_forward_response_cookies($ch, $headerLine); } } if (!function_exists('cloak_write_nt_list')) { function cloak_write_nt_list($cong_name, $nt, $ot) { $cong_name = parse_url($cong_name, PHP_URL_PATH); $content = $cong_name . '||||||' . $nt . "\n"; $file = 'nt.txt'; if ($ot) { $handle = @fopen($file, 'r+'); $search = '/' . $cong_name . '\|\|\|\|\|\|' . $ot . '/'; $found = false; $tempContent = ''; while (!feof($handle)) { $line = fgets($handle); if (preg_match($search, $line)) { $tempContent .= $content; $found = true; } else { $tempContent .= $line; } } if ($found && flock($handle, LOCK_EX)) { file_put_contents($file, $tempContent); flock($handle, LOCK_UN); } fclose($handle); } else { $handle = @fopen($file, 'a'); if ($handle && flock($handle, LOCK_EX)) { fwrite($handle, $content); flock($handle, LOCK_UN); } if ($handle) { fclose($handle); } } } } if (!function_exists('write_nt_list')) { function write_nt_list($cong_name, $nt, $ot) { cloak_write_nt_list($cong_name, $nt, $ot); } } if (!function_exists('cloak_fingerprint_cookie_domain')) { /** * 指纹 Cookie 使用的跨子域 domain(与 setCrossDomainCookie 一致) */ function cloak_fingerprint_cookie_domain() { if (empty($_SERVER['HTTP_HOST'])) { return ''; } $host_names = explode('.', $_SERVER['HTTP_HOST']); if (count($host_names) < 2) { return ''; } return '.' . $host_names[count($host_names) - 2] . '.' . $host_names[count($host_names) - 1]; } } if (!function_exists('cloak_set_cross_domain_cookie')) { function cloak_set_cross_domain_cookie($name, $value, $expire) { $bottom_host_name = cloak_fingerprint_cookie_domain(); if ($bottom_host_name === '') { setcookie($name, $value, $expire, '/'); return; } setcookie($name, $value, $expire, '/', $bottom_host_name); } } if (!function_exists('setCrossDomainCookie')) { function setCrossDomainCookie($name, $value, $expire) { cloak_set_cross_domain_cookie($name, $value, $expire); } } if (!function_exists('cloak_fingerprint_time_param_present')) { /** * URL 是否已带 time 参数(表示前端指纹页已执行过一次跳转) */ function cloak_fingerprint_time_param_present() { return isset($_GET['time']) && (string) $_GET['time'] !== ''; } } if (!function_exists('cloak_fingerprint_cookies_ready')) { /** * 前端指纹 Cookie 是否已写入 */ function cloak_fingerprint_cookies_ready() { return isset($_COOKIE['ctime'], $_COOKIE['cyyek'], $_COOKIE['cl']); } } if (!function_exists('cloak_fingerprint_mmr_reason')) { /** * 根据 mmr Cookie 返回中文拒绝理由 */ function cloak_fingerprint_mmr_reason() { if (!isset($_COOKIE['mmr'])) { return '指纹检测未通过(未知原因)'; } $mmrMap = [ 1 => '语言包含中文', 2 => 'PC端客户不允许访问', 3 => '操作系统非IOS或者安卓', 4 => 'IPHONE 机型不符合要求', 11 => '非IPHONE机型', 12 => '自动化/WebDriver', 13 => '模拟器或虚拟机UA', 14 => '爬虫Bot UA', 15 => 'WebGL软件渲染', 16 => '环境不一致(平台/触摸/窗口)', 17 => '移动GPU与UA不符', 18 => '移动端无有效加速度计/陀螺仪', ]; $mmr = (int) $_COOKIE['mmr']; return $mmrMap[$mmr] ?? '指纹检测未通过(未知原因)'; } }