checkRedirects($url); // If there's a redirect and the final URL is different // Se houver redirecionamento e a URL final for diferente if ($redirectInfo['hasRedirect'] && $redirectInfo['finalUrl'] !== $url) { // Redirect to final URL // Redireciona para a URL final header('Location: ' . SITE_URL . '/p/' . urlencode($redirectInfo['finalUrl'])); exit; } // If there's no redirect or if already at final URL // Se não houver redirecionamento ou se já estiver na URL final // Try to analyze and process the URL // Tenta analisar e processar a URL $content = $analyzer->analyze($url); // Display processed content // Exibe o conteúdo processado echo $content; exit; } catch (Exception $e) { $errorMessage = $e->getMessage(); $errorType = 'GENERIC_ERROR'; // Default error type / Tipo padrão de erro // Map error message to specific type // Mapeia a mensagem de erro para um tipo específico if (strpos($errorMessage, 'bloqueado') !== false || strpos($errorMessage, 'blocked') !== false) { $errorType = 'BLOCKED_DOMAIN'; } elseif (strpos($errorMessage, 'DNS') !== false) { $errorType = 'DNS_FAILURE'; } elseif (strpos($errorMessage, 'HTTP: 4') !== false || strpos($errorMessage, 'HTTP: 5') !== false) { $errorType = 'HTTP_ERROR'; } elseif (strpos($errorMessage, 'CURL') !== false) { $errorType = 'CONNECTION_ERROR'; } elseif (strpos($errorMessage, 'obter conteúdo') !== false || strpos($errorMessage, 'get content') !== false) { $errorType = 'CONTENT_ERROR'; } // Redirect to home page with error message // Redireciona para a página inicial com mensagem de erro header('Location: /?message=' . $errorType); exit; } } else { // Invalid URL / URL inválida header('Location: /?message=INVALID_URL'); exit; } } else { // Invalid path / Path inválido header('Location: /?message=NOT_FOUND'); exit; }