Skip to content

Instantly share code, notes, and snippets.

@robot00f
Last active November 30, 2024 01:01
Show Gist options
  • Save robot00f/9b1b2444b0ea8e814683c7ceebf92f6c to your computer and use it in GitHub Desktop.
Save robot00f/9b1b2444b0ea8e814683c7ceebf92f6c to your computer and use it in GitHub Desktop.
<?php
// Lista de dominios para verificar
$domains = [
"http://flow-live.dlt.qwilted-cds.cqloud.com",
"https://chromecast.cvattv.com.ar",
"https://lb-02-slo.cvattv.com.ar",
"https://cdn.cvattv.com.ar"
];
// Obtener la ruta que se pasa como parámetro 'path' en la URL
if (empty($_GET['path'])) {
echo "La ruta no ha sido especificada.";
exit;
}
$path = $_GET['path']; // Obtener la ruta dinámica desde la URL
// Iterar sobre los dominios y verificar cuál responde correctamente
foreach ($domains as $domain) {
// Componer la URL completa con el dominio y la ruta proporcionada
$full_url = $domain . $path;
// Inicializar cURL para verificar el estado de la URL
$ch = curl_init($full_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Obtener respuesta completa
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); // NO seguir automáticamente las redirecciones
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'); // Simular navegador
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Deshabilitar validación de SSL
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Deshabilitar verificación de peer SSL
// Ejecutar la solicitud cURL
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); // Obtener código de estado HTTP
// Verificar si hay errores en la conexión
if (curl_errno($ch)) {
echo "Error al conectar con: " . $domain . " - " . curl_error($ch) . "<br>";
curl_close($ch);
continue;
}
curl_close($ch);
// Si el estado es 200 o 302, redirigir a la URL completa
if ($http_code == 200 || $http_code == 302) {
// Si el dominio está activo, redirigir directamente a la URL completa
echo "Dominio disponible: " . $domain . "<br>";
echo "Redirigiendo a: " . $full_url . "<br>";
header("Location: " . $full_url); // Redirigir a la URL completa
exit; // Detener la ejecución después de la redirección
} else {
echo "Error al acceder a: " . $full_url . " con estado: " . $http_code . "<br>";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment