xref: /plugin/statistics/dispatch.php (revision 87e0f0b1298c908ddbd85655163d986a03dc53f3)
1*87e0f0b1SAndreas Gohr<?php
2*87e0f0b1SAndreas Gohr
3*87e0f0b1SAndreas Gohr// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
4*87e0f0b1SAndreas Gohr/**
5*87e0f0b1SAndreas Gohr * Statistics plugin - data logger
6*87e0f0b1SAndreas Gohr *
7*87e0f0b1SAndreas Gohr * This logger is called via JavaScript
8*87e0f0b1SAndreas Gohr *
9*87e0f0b1SAndreas Gohr * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
10*87e0f0b1SAndreas Gohr * @author     Andreas Gohr <gohr@cosmocode.de>
11*87e0f0b1SAndreas Gohr */
12*87e0f0b1SAndreas Gohruse dokuwiki\plugin\statistics\IgnoreException;
13*87e0f0b1SAndreas Gohruse dokuwiki\ErrorHandler;
14*87e0f0b1SAndreas Gohr
15*87e0f0b1SAndreas Gohrif (!defined('DOKU_INC')) define('DOKU_INC', realpath(__DIR__ . '/../../../') . '/');
16*87e0f0b1SAndreas Gohrdefine('DOKU_DISABLE_GZIP_OUTPUT', 1);
17*87e0f0b1SAndreas Gohrrequire_once(DOKU_INC . 'inc/init.php');
18*87e0f0b1SAndreas Gohrsession_write_close();
19*87e0f0b1SAndreas Gohr
20*87e0f0b1SAndreas Gohrglobal $INPUT;
21*87e0f0b1SAndreas Gohr
22*87e0f0b1SAndreas Gohrtry {
23*87e0f0b1SAndreas Gohr    /** @var helper_plugin_statistics $plugin */
24*87e0f0b1SAndreas Gohr    $plugin = plugin_load('helper', 'statistics');
25*87e0f0b1SAndreas Gohr    $plugin->sendGIF(); // browser be done
26*87e0f0b1SAndreas Gohr
27*87e0f0b1SAndreas Gohr    $logger = $plugin->getLogger();
28*87e0f0b1SAndreas Gohr    $logger->begin(); // triggers autologging
29*87e0f0b1SAndreas Gohr
30*87e0f0b1SAndreas Gohr    switch ($INPUT->str('do')) {
31*87e0f0b1SAndreas Gohr        case 'v':
32*87e0f0b1SAndreas Gohr            $logger->logPageView();
33*87e0f0b1SAndreas Gohr            break;
34*87e0f0b1SAndreas Gohr        case 'o':
35*87e0f0b1SAndreas Gohr            $logger->logOutgoing();
36*87e0f0b1SAndreas Gohr    }
37*87e0f0b1SAndreas Gohr
38*87e0f0b1SAndreas Gohr    $logger->end();
39*87e0f0b1SAndreas Gohr} catch (\Exception $e) {
40*87e0f0b1SAndreas Gohr    if (!$e instanceof IgnoreException) {
41*87e0f0b1SAndreas Gohr        ErrorHandler::logException($e);
42*87e0f0b1SAndreas Gohr    }
43*87e0f0b1SAndreas Gohr}
44