|
|
|
@ -98,157 +98,151 @@ $records = $database->select("analytics", [
|
|
|
|
|
<?php
|
|
|
|
|
if (count($records) > 0) {
|
|
|
|
|
?>
|
|
|
|
|
<div class="row mt-3">
|
|
|
|
|
<div class="col-12 col-sm-6 col-md-6 col-lg-4 mb-4">
|
|
|
|
|
<!-- Overview -->
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h4 class="card-title"><?php lang("overview"); ?></h4>
|
|
|
|
|
<?php
|
|
|
|
|
$uuids = [];
|
|
|
|
|
foreach ($records as $r) {
|
|
|
|
|
if (!in_array($r["uuid"], $uuids)) {
|
|
|
|
|
$uuids[] = $r["uuid"];
|
|
|
|
|
}
|
|
|
|
|
<div class="card-columns mt-4">
|
|
|
|
|
<!-- Overview -->
|
|
|
|
|
<div class="card mb-4">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h4 class="card-title"><?php lang("overview"); ?></h4>
|
|
|
|
|
<?php
|
|
|
|
|
$uuids = [];
|
|
|
|
|
foreach ($records as $r) {
|
|
|
|
|
if (!in_array($r["uuid"], $uuids)) {
|
|
|
|
|
$uuids[] = $r["uuid"];
|
|
|
|
|
}
|
|
|
|
|
$visits = count($uuids);
|
|
|
|
|
$views = count($records);
|
|
|
|
|
$ratio = round($views / $visits, 1);
|
|
|
|
|
?>
|
|
|
|
|
<h5>
|
|
|
|
|
<i class="fas fa-users fa-fw"></i> <?php echo $visits; ?> <?php lang("visits") ?> <br />
|
|
|
|
|
<i class="fas fa-eye fa-fw"></i> <?php echo $views; ?> <?php lang("page views") ?> <br />
|
|
|
|
|
<i class="fas fa-percent fa-fw"></i> <?php echo $ratio; ?> <?php lang("views per visit") ?>
|
|
|
|
|
</h5>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
$visits = count($uuids);
|
|
|
|
|
$views = count($records);
|
|
|
|
|
$ratio = round($views / $visits, 1);
|
|
|
|
|
?>
|
|
|
|
|
<h5>
|
|
|
|
|
<i class="fas fa-users fa-fw"></i> <?php echo $visits; ?> <?php lang("visits") ?> <br />
|
|
|
|
|
<i class="fas fa-eye fa-fw"></i> <?php echo $views; ?> <?php lang("page views") ?> <br />
|
|
|
|
|
<i class="fas fa-percent fa-fw"></i> <?php echo $ratio; ?> <?php lang("views per visit") ?>
|
|
|
|
|
</h5>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Visits Over Time -->
|
|
|
|
|
<div class="card mt-4">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h4 class="card-title"><?php lang("visits over time"); ?></h4>
|
|
|
|
|
<?php
|
|
|
|
|
$format = "Y-m-00 00:00:00";
|
|
|
|
|
$max = $records[0];
|
|
|
|
|
$min = $records[count($records) - 1];
|
|
|
|
|
$diff = strtotime($max['time']) - strtotime($min['time']);
|
|
|
|
|
if ($diff < 60 * 60) { // 1 hour
|
|
|
|
|
$format = "Y-m-d H:i:00";
|
|
|
|
|
} else if ($diff < 60 * 60 * 24 * 3) { // 3 days
|
|
|
|
|
$format = "Y-m-d H:00:00";
|
|
|
|
|
} else if ($diff < 60 * 60 * 24 * 60) { // 30 days
|
|
|
|
|
$format = "Y-m-d 00:00:00";
|
|
|
|
|
}
|
|
|
|
|
<!-- Visits Over Time -->
|
|
|
|
|
<div class="card mb-4">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h4 class="card-title"><?php lang("visits over time"); ?></h4>
|
|
|
|
|
<?php
|
|
|
|
|
$format = "Y-m-00 00:00:00";
|
|
|
|
|
$max = $records[0];
|
|
|
|
|
$min = $records[count($records) - 1];
|
|
|
|
|
$diff = strtotime($max['time']) - strtotime($min['time']);
|
|
|
|
|
if ($diff < 60 * 60) { // 1 hour
|
|
|
|
|
$format = "Y-m-d H:i:00";
|
|
|
|
|
} else if ($diff < 60 * 60 * 24 * 3) { // 3 days
|
|
|
|
|
$format = "Y-m-d H:00:00";
|
|
|
|
|
} else if ($diff < 60 * 60 * 24 * 60) { // 30 days
|
|
|
|
|
$format = "Y-m-d 00:00:00";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$counted = [];
|
|
|
|
|
foreach ($records as $r) {
|
|
|
|
|
$rf = date($format, strtotime($r['time']));
|
|
|
|
|
if (array_key_exists($rf, $counted)) {
|
|
|
|
|
$counted[$rf] ++;
|
|
|
|
|
} else {
|
|
|
|
|
$counted[$rf] = 1;
|
|
|
|
|
}
|
|
|
|
|
$counted = [];
|
|
|
|
|
foreach ($records as $r) {
|
|
|
|
|
$rf = date($format, strtotime($r['time']));
|
|
|
|
|
if (array_key_exists($rf, $counted)) {
|
|
|
|
|
$counted[$rf] ++;
|
|
|
|
|
} else {
|
|
|
|
|
$counted[$rf] = 1;
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
<script nonce="<?php echo $SECURE_NONCE; ?>">
|
|
|
|
|
var visitsOverTimeData = [
|
|
|
|
|
<script nonce="<?php echo $SECURE_NONCE; ?>">
|
|
|
|
|
var visitsOverTimeData = [
|
|
|
|
|
<?php foreach ($counted as $d => $c) { ?>
|
|
|
|
|
{
|
|
|
|
|
x: "<?php echo $d; ?>",
|
|
|
|
|
y: <?php echo $c; ?>
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
x: "<?php echo $d; ?>",
|
|
|
|
|
y: <?php echo $c; ?>
|
|
|
|
|
},
|
|
|
|
|
<?php } ?>
|
|
|
|
|
];
|
|
|
|
|
</script>
|
|
|
|
|
<div class="w-100 position-relative">
|
|
|
|
|
<canvas id="visitsOverTime"></canvas>
|
|
|
|
|
</div>
|
|
|
|
|
];
|
|
|
|
|
</script>
|
|
|
|
|
<div class="w-100 position-relative">
|
|
|
|
|
<canvas id="visitsOverTime"></canvas>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Recent Actions -->
|
|
|
|
|
<div class="col-12 col-sm-6 col-md-6 col-lg-4">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h4 class="card-title"><?php lang("recent actions"); ?></h4>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="list-group">
|
|
|
|
|
<?php
|
|
|
|
|
$max = 10;
|
|
|
|
|
$i = 0;
|
|
|
|
|
foreach ($records as $r) {
|
|
|
|
|
$i++;
|
|
|
|
|
if ($i > $max) {
|
|
|
|
|
break;
|
|
|
|
|
<!-- Visitor Map -->
|
|
|
|
|
<div class="card mb-4">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h4 class="card-title"><?php lang("visitor map"); ?></h4>
|
|
|
|
|
<?php
|
|
|
|
|
require_once __DIR__ . "/../lib/countries_2_3.php";
|
|
|
|
|
$countries = [];
|
|
|
|
|
$states = [];
|
|
|
|
|
foreach ($records as $r) {
|
|
|
|
|
if (array_key_exists($COUNTRY_CODES[$r['countrycode']], $countries)) {
|
|
|
|
|
$countries[$COUNTRY_CODES[$r['countrycode']]] ++;
|
|
|
|
|
} else {
|
|
|
|
|
$countries[$COUNTRY_CODES[$r['countrycode']]] = 1;
|
|
|
|
|
}
|
|
|
|
|
if ($r['countrycode'] === "US") {
|
|
|
|
|
if (array_key_exists($r['regioncode'], $states)) {
|
|
|
|
|
$states[$r['regioncode']] ++;
|
|
|
|
|
} else {
|
|
|
|
|
$states[$r['regioncode']] = 1;
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<div class="list-group-item">
|
|
|
|
|
<div>
|
|
|
|
|
<div><i class="fas fa-user fa-fw"></i> <?php echo substr($r["uuid"], 0, 8); ?></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="row justify-content-between">
|
|
|
|
|
<div class="col-12 col-sm-6 d-flex flex-column">
|
|
|
|
|
<span><i class="fas fa-clock fa-fw"></i> <?php echo date("g:i A", strtotime($r["time"])); ?></span>
|
|
|
|
|
<span><i class="fas fa-file fa-fw"></i> <?php echo $r["pagetitle"]; ?></span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-12 col-sm-6 d-flex flex-column">
|
|
|
|
|
<span><i class="fas fa-calendar fa-fw"></i> <?php echo date("M j Y", strtotime($r["time"])); ?></span>
|
|
|
|
|
<span><i class="fas fa-sitemap fa-fw"></i> <?php echo $r["sitename"]; ?></span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div><i class="fas fa-globe fa-fw"></i> <?php echo $r["country"]; ?></div>
|
|
|
|
|
<div><i class="fas fa-map-marker fa-fw"></i> <?php echo $r["city"] . ", " . $r["region"]; ?></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
$countrymapdata = [];
|
|
|
|
|
foreach ($countries as $id => $count) {
|
|
|
|
|
$countrymapdata[] = [$id, $count];
|
|
|
|
|
}
|
|
|
|
|
$statemapdata = [];
|
|
|
|
|
foreach ($states as $id => $count) {
|
|
|
|
|
$statemapdata[] = [$id, $count];
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<script nonce="<?php echo $SECURE_NONCE; ?>">
|
|
|
|
|
visitorMap_Countries = <?php echo json_encode($countrymapdata); ?>;
|
|
|
|
|
visitorMap_States = <?php echo json_encode($statemapdata); ?>;
|
|
|
|
|
</script>
|
|
|
|
|
<div class="w-100" id="visitorMapWorld"></div>
|
|
|
|
|
<div class="w-100" id="visitorMapUSA"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Visitor Map -->
|
|
|
|
|
<div class="col-12 col-sm-6 col-md-6 col-lg-4">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h4 class="card-title"><?php lang("visitor map"); ?></h4>
|
|
|
|
|
<?php
|
|
|
|
|
require_once __DIR__ . "/../lib/countries_2_3.php";
|
|
|
|
|
$countries = [];
|
|
|
|
|
$states = [];
|
|
|
|
|
foreach ($records as $r) {
|
|
|
|
|
if (array_key_exists($COUNTRY_CODES[$r['countrycode']], $countries)) {
|
|
|
|
|
$countries[$COUNTRY_CODES[$r['countrycode']]] ++;
|
|
|
|
|
} else {
|
|
|
|
|
$countries[$COUNTRY_CODES[$r['countrycode']]] = 1;
|
|
|
|
|
}
|
|
|
|
|
if ($r['countrycode'] === "US") {
|
|
|
|
|
if (array_key_exists($r['regioncode'], $states)) {
|
|
|
|
|
$states[$r['regioncode']] ++;
|
|
|
|
|
} else {
|
|
|
|
|
$states[$r['regioncode']] = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$countrymapdata = [];
|
|
|
|
|
foreach ($countries as $id => $count) {
|
|
|
|
|
$countrymapdata[] = [$id, $count];
|
|
|
|
|
}
|
|
|
|
|
$statemapdata = [];
|
|
|
|
|
foreach ($states as $id => $count) {
|
|
|
|
|
$statemapdata[] = [$id, $count];
|
|
|
|
|
<!-- Recent Actions -->
|
|
|
|
|
<div class="card mb-4">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h4 class="card-title"><?php lang("recent actions"); ?></h4>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="list-group list-group-scrolly">
|
|
|
|
|
<?php
|
|
|
|
|
$max = 20;
|
|
|
|
|
$i = 0;
|
|
|
|
|
foreach ($records as $r) {
|
|
|
|
|
$i++;
|
|
|
|
|
if ($i > $max) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<script nonce="<?php echo $SECURE_NONCE; ?>">
|
|
|
|
|
visitorMap_Countries = <?php echo json_encode($countrymapdata); ?>;
|
|
|
|
|
visitorMap_States = <?php echo json_encode($statemapdata); ?>;
|
|
|
|
|
</script>
|
|
|
|
|
<div class="w-100" id="visitorMapWorld"></div>
|
|
|
|
|
<div class="w-100" id="visitorMapUSA"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="list-group-item">
|
|
|
|
|
<div>
|
|
|
|
|
<div><i class="fas fa-user fa-fw"></i> <?php echo substr($r["uuid"], 0, 8); ?></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="row justify-content-between">
|
|
|
|
|
<div class="col-12 col-sm-6 d-flex flex-column">
|
|
|
|
|
<span><i class="fas fa-clock fa-fw"></i> <?php echo date("g:i A", strtotime($r["time"])); ?></span>
|
|
|
|
|
<span><i class="fas fa-file fa-fw"></i> <?php echo $r["pagetitle"]; ?></span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-12 col-sm-6 d-flex flex-column">
|
|
|
|
|
<span><i class="fas fa-calendar fa-fw"></i> <?php echo date("M j Y", strtotime($r["time"])); ?></span>
|
|
|
|
|
<span><i class="fas fa-sitemap fa-fw"></i> <?php echo $r["sitename"]; ?></span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div><i class="fas fa-globe fa-fw"></i> <?php echo $r["country"]; ?></div>
|
|
|
|
|
<div><i class="fas fa-map-marker fa-fw"></i> <?php echo $r["city"] . ", " . $r["region"]; ?></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|