Your IP : 216.73.217.78


Current Path : /home/seto/testhive.pm/admin/
Upload File :
Current File : /home/seto/testhive.pm/admin/pages.php

<?php
require_once __DIR__ . '/../includes/auth.php';
require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/_layout.php';

$page   = max(1, (int)($_GET['page'] ?? 1));
$offset = ($page - 1) * ROWS_PER_PAGE;
$total  = (int)db()->query("SELECT COUNT(*) FROM pages")->fetchColumn();

$rows = db()->prepare(
    "SELECT p.url, p.hits, p.last_seen_at, d.domain,
            (SELECT COUNT(*) FROM impressions_daily id WHERE id.page_id=p.id AND id.date=date('now')) as today_imp
     FROM pages p JOIN donors d ON d.id=p.donor_id
     ORDER BY p.last_seen_at DESC LIMIT ? OFFSET ?"
);
$rows->execute([ROWS_PER_PAGE, $offset]);
$rows = $rows->fetchAll();

layout_head('Страницы');
?>
<div class="card shadow-sm">
<table class="table table-hover mb-0 small">
<thead class="table-light">
  <tr>
    <th>Domain</th>
    <th>URL</th>
    <th class="text-end">Хитов</th>
    <th class="text-end">Показов сегодня</th>
    <th>Последний визит</th>
  </tr>
</thead>
<tbody>
<?php foreach ($rows as $r): ?>
<tr>
  <td><?= htmlspecialchars($r['domain']) ?></td>
  <td class="text-truncate" style="max-width:300px">
    <?= htmlspecialchars($r['url']) ?>
    <a href="<?= 'http://' . htmlspecialchars($r['domain']) . htmlspecialchars($r['url']) ?>" target="_blank" rel="noopener" class="ms-1 text-muted" title="Открыть страницу" style="opacity:.5;vertical-align:middle"><svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a>
  </td>
  <td class="text-end"><?= number_format((int)$r['hits']) ?></td>
  <td class="text-end"><?= (int)$r['today_imp'] ?></td>
  <td><?= $r['last_seen_at'] ? date('d.m.Y H:i', $r['last_seen_at']) : '—' ?></td>
</tr>
<?php endforeach ?>
<?php if (empty($rows)): ?>
<tr><td colspan="5" class="text-center text-muted py-3">Страниц пока нет</td></tr>
<?php endif ?>
</tbody>
</table>
</div>
<?php if ($total > ROWS_PER_PAGE): ?>
<div class="mt-3"><?= paginate($total, $page, ROWS_PER_PAGE, '/admin/pages.php') ?></div>
<?php endif ?>
<?php layout_foot() ?>