File: /var/www/cod67/data/www/cod67.ru/public_html/similar1/panel.php
<?php
$config = require __DIR__ . '/config.php';
if (!isset($_GET['pass']) || $_GET['pass'] !== $config['panel_password']) die("Требуется пароль: ?pass=ВАШ_ПАРОЛЬ");
$daily = json_decode(file_get_contents(__DIR__.'/stats/daily.json'), true);
$monthly = json_decode(file_get_contents(__DIR__.'/stats/monthly.json'), true);
$logDir = __DIR__.'/stats/logs';
$logs = glob($logDir.'/*.log');
// Определяем недоступные сайты по логам
$unavailable = [];
foreach ($logs as $log) {
foreach (explode("\n", file_get_contents($log)) as $line)
if (strpos($line, 'Недоступен:') !== false)
$unavailable[] = trim(explode('Недоступен:', $line)[1]);
}
?>
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Статистика редиректов</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body{font-family:Arial;padding:20px;}
table{border-collapse:collapse;margin-bottom:40px;}
td,th{border:1px solid #ccc;padding:6px 10px;}
.red{background:#ffdddd !important;}
pre{background:#eee;padding:10px;}
</style>
</head>
<body>
<h1>Статистика редиректов</h1>
<h2>Сегодня (<?= $daily['date'] ?>)</h2>
<table>
<tr><th>URL</th><th>Переходов</th></tr>
<?php foreach ($daily['links'] as $url=>$count): ?>
<tr class="<?= in_array($url,$unavailable)?'red':'' ?>">
<td><?= $url ?></td>
<td><?= $count ?></td>
</tr>
<?php endforeach; ?>
</table>
<h2>Месяц (<?= $monthly['month'] ?>)</h2>
<table>
<tr><th>URL</th><th>Переходов</th></tr>
<?php foreach ($monthly['links'] as $url=>$count): ?>
<tr class="<?= in_array($url,$unavailable)?'red':'' ?>">
<td><?= $url ?></td>
<td><?= $count ?></td>
</tr>
<?php endforeach; ?>
</table>
<h2>График переходов за месяц</h2>
<canvas id="chart" width="600" height="200"></canvas>
<script>
const labels = <?= json_encode(array_keys($monthly['links'])) ?>;
const data = <?= json_encode(array_values($monthly['links'])) ?>;
new Chart(document.getElementById('chart'), {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: 'Переходов',
data: data
}]
}
});
</script>
<h2>Логи</h2>
<?php foreach ($logs as $log): ?>
<h3><?= basename($log) ?></h3>
<pre><?= htmlspecialchars(file_get_contents($log)) ?></pre>
<?php endforeach; ?>
</body>
</html>