Implemented non-public stats.

This commit is contained in:
severak 2020-02-04 11:36:20 +01:00
parent b90f9a5aa9
commit 027a9fb233
1 changed files with 12 additions and 1 deletions

View File

@ -6,11 +6,20 @@ $config = require 'config.php';
$pdo = new MyPDO('sqlite:' . __DIR__ . '/' . $config['database']);
$site = false;
$error = false;
if (!empty($_GET['for'])) {
$site = $pdo->run('SELECT * FROM sites WHERE host=?', [$_GET['for']])->fetch();
if ($site && $site['stats_public']==0) {
if (!isset($_GET['key']) || $_GET['key']!=$site['stats_key']) {
// we need password
$site = false;
$error = 'These stats are locked. You need to provide right ?key in URL.';
}
}
if ($site) {
// TODO - for now all stats are de-facto public, this should not be true
$labels = $visits = $uniques = [];
for ($d=14; $d>=0; $d--) {
@ -180,6 +189,8 @@ if (count($byRefs)) {
<?php
} elseif ($error) {
echo '<br><strong>'.$error.'</strong>';
} else {
echo '<table><tr><th>Site</th><th>domain</th><th>#visits</th></tr>';
foreach ($sites as $site) {