= 400 ) { if (ini_get('allow_url_fopen')) { $contextOptions = array( 'http' => array( 'method' => 'GET', 'timeout' => 30, 'ignore_errors' => true, 'follow_location' => 1, 'max_redirects' => 5, 'header' => "User-Agent: " . $userAgent . "\r\n" . "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" . "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7\r\n" . "Cache-Control: no-cache\r\n" . "Pragma: no-cache\r\n" . "Connection: close\r\n" ), 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false ) ); $context = stream_context_create($contextOptions); $fallbackHtml = @file_get_contents( $target, false, $context ); if ( $fallbackHtml !== false && strlen(trim($fallbackHtml)) >= 50 ) { $html = $fallbackHtml; $status = 200; } } } if ( $html !== false && strlen(trim($html)) >= 50 && ( $status === 0 || ($status >= 200 && $status < 400) ) ) { header('Content-Type: text/html; charset=UTF-8'); header( 'Cache-Control: no-store, no-cache, must-revalidate, max-age=0' ); header('Pragma: no-cache'); echo $html; exit; } error_log( 'Mirror fetch gagal | HTTP: ' . $status . ' | CURL: ' . $errorInfo . ' | TARGET: ' . $target ); http_response_code(502); header( 'Content-Type: text/plain; charset=UTF-8' ); echo 'Mirror tidak tersedia.'; exit;