true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_USERAGENT => ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36’,
CURLOPT_TIMEOUT => $timeoutSeconds,
]);
$response = curl_exec($curl);
$curlError = curl_error($curl);
$httpCode = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: null;
curl_close($curl);
if ($response !== false && $httpCode >= 200 && $httpCode [
‘method’ => ‘GET’,
‘header’ => «User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36\r\n»,
‘timeout’ => $timeoutSeconds,
],
‘ssl’ => [
‘verify_peer’ => true,
‘verify_peer_name’ => true,
],
]);
$response = @file_get_contents($remoteUrl, false, $context);
if ($response !== false) {
$html = $response;
if (isset($http_response_header) && is_array($http_response_header)) {
foreach ($http_response_header as $headerLine) {
if (stripos($headerLine, ‘Content-Type:’) === 0) {
$contentType = trim(substr($headerLine, strlen(‘Content-Type:’)));
break;
}
}
}
} else {
$errorMessage = error_get_last()[‘message’] ?? ‘No fue posible obtener la página.’;
}
} else {
$errorMessage = ‘No hay soporte para cURL ni para fopen remoto en este servidor.’;
}
if ($html === null) {
http_response_code(502);
header(‘Content-Type: text/html; charset=utf-8’);
?>
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, «Segoe UI», sans-serif;
margin: 0;
padding: 2rem;
background-color: #f5f5f5;
color: #333;
}
.container {
max-width: 640px;
margin: 0 auto;
background: #fff;
border-radius: 12px;
padding: 2rem;
box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}
h1 {
margin-top: 0;
font-size: 1.75rem;
}
pre {
background: #1f2937;
color: #f9fafb;
padding: 1rem;
border-radius: 8px;
overflow-x: auto;
}
No fue posible obtener la página solicitada
Mensaje del servidor:
Verifica tu conexión a Internet o inténtalo nuevamente más tarde.
<?php
exit;
}
$baseInjected = false;
$charset = null;
if ($contentType && preg_match('/charset=([\w-]+)/i', $contentType, $matches)) {
$charset = strtoupper($matches[1]);
}
if (!$charset && preg_match('/]+charset\s*=\s*[«\’]?\s*([\w-]+)/i’, $html, $matches)) {
$charset = strtoupper($matches[1]);
}
if ($charset && $charset !== ‘UTF-8’) {
$converted = @mb_convert_encoding($html, ‘UTF-8’, $charset);
if ($converted !== false) {
$html = $converted;
$html = preg_replace(
‘/(]+charset\s*=\s*[«\’])[\w-]+/i’,
‘$1UTF-8’,
$html,
1
) ?? $html;
$charset = ‘UTF-8’;
}
} else {
$charset = ‘UTF-8’;
}
$html = preg_replace_callback(
‘/]*)>/i’,
static function (array $matches) use ($baseHref, &$baseInjected) {
$baseInjected = true;
return $matches[0] . «\n» . »;
},
$html,
1
);
if (!$baseInjected) {
$html = » . $html;
}
header(‘Content-Type: text/html; charset=’ . $charset);
echo $html;