HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux vgpudjuxex 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User: cod67 (1010)
PHP: 8.2.29
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Upload Files
File: /var/www/cod67/data/www/cod67.ru/public_html/similar1/redirect.php
<?php
global $logDir, $config;
foreach (glob($logDir.'/*.log') as $f)
if (filemtime($f) < time() - 86400 * $config['log_keep_days']) unlink($f);
}
cleanup_logs();


/* ---------- ЗАГРУЗКА СТАТИСТИКИ ---------- */
$dailyStats = load_json($dailyFile);
$monthlyStats = load_json($monthlyFile);
$today = date('Y-m-d');
$month = date('Y-m');


if (($dailyStats['date'] ?? null) !== $today)
$dailyStats = ['date' => $today, 'links' => []];
if (($monthlyStats['month'] ?? null) !== $month)
$monthlyStats = ['month' => $month, 'links' => []];


/* ---------- СПИСОК ССЫЛОК ---------- */
$links_raw = file_get_contents($config['links_source']);
if ($links_raw === false) die("Не могу загрузить links.txt: " . $config['links_source']);
$links = array_values(array_filter(array_map('trim', explode("
", $links_raw))));


$is_https =
(isset($_SERVER['HTTP_CF_VISITOR']) && json_decode($_SERVER['HTTP_CF_VISITOR'], true)['scheme'] === 'https') ||
(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https') ||
(isset($_SERVER['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) die("URL не найден в списке");


/* ---------- ПОИСК РАБОЧЕЙ ССЫЛКИ ---------- */
$total = count($links);
$checked = 0;


while ($checked < $total) {
$current_index = ($current_index + 1) % $total;
$url = $links[$current_index];


$daily = $dailyStats['links'][$url] ?? 0;
$monthly = $monthlyStats['links'][$url] ?? 0;


if ($daily >= $config['daily_limit'] || $monthly >= $config['monthly_limit']){
write_log("Лимит превышен: $url (day=$daily, month=$monthly)");
$checked++;
continue;
}


if (!url_alive($url)){
write_log("Недоступен: $url");
telegram_notify("⚠️ Недоступен сайт: $url");
echo "<p>Сайт недоступен: $url</p>";
sleep($config['sleep_unavailable']);
$checked++;
continue;
}


$dailyStats['links'][$url] = $daily + 1;
$monthlyStats['links'][$url] = $monthly + 1;
save_json($dailyFile,$dailyStats);
save_json($monthlyFile,$monthlyStats);


write_log("Редирект → $url");


echo "<meta http-equiv='refresh' content='<?php echo $config['redirect_delay']; ?>;url=" . htmlspecialchars($url) . "'>";
exit;
}


tel egram_notify("❌ Все ссылки недоступны или превысили лимиты!");
die("Нет доступных ссылок.");