public function trackHit()
{
// Don't track bot or crawler requests
if (!Grav::instance()['browser']->isHuman()) {
return;
}
/** @var Page $page */
$page = Grav::instance()['page'];
$relative_url = str_replace(Grav::instance()['base_url_relative'], '', $page->url());
// Don't track error pages or pages that have no route
if ($page->template() == 'error' || !$page->route()) {
return;
}
// Make sure no 'widcard-style' ignore matches this url
foreach ((array) $this->config->get('plugins.admin.popularity.ignore') as $ignore) {
if (fnmatch($ignore, $relative_url)) {
return;
}
}
// initial creation if it doesn't exist
if (!file_exists($this->data_path)) {
mkdir($this->data_path);
$this->flushPopularity();
}
// Update the data we want to track
$this->updateDaily();
$this->updateMonthly();
$this->updateTotals($page->route());
$this->updateVisitors(Grav::instance()['uri']->ip());
}