114d99ec0SAndreas Gohr<?php 214d99ec0SAndreas Gohr/** 314d99ec0SAndreas Gohr * 414d99ec0SAndreas Gohr * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 514d99ec0SAndreas Gohr * @author Andreas Gohr <gohr@cosmocode.de> 614d99ec0SAndreas Gohr */ 714d99ec0SAndreas Gohr 814d99ec0SAndreas Gohr// must be run within Dokuwiki 914d99ec0SAndreas Gohrif(!defined('DOKU_INC')) die(); 1014d99ec0SAndreas Gohr 1114d99ec0SAndreas Gohrif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 1214d99ec0SAndreas Gohrrequire_once(DOKU_PLUGIN.'action.php'); 1314d99ec0SAndreas Gohr 1414d99ec0SAndreas Gohrclass action_plugin_statistics extends DokuWiki_Action_Plugin { 1514d99ec0SAndreas Gohr 1614d99ec0SAndreas Gohr /** 1714d99ec0SAndreas Gohr * return some info 1814d99ec0SAndreas Gohr */ 1914d99ec0SAndreas Gohr function getInfo(){ 2014d99ec0SAndreas Gohr return confToHash(dirname(__FILE__).'/info.txt'); 2114d99ec0SAndreas Gohr } 2214d99ec0SAndreas Gohr 2314d99ec0SAndreas Gohr /** 2414d99ec0SAndreas Gohr * register the eventhandlers and initialize some options 2514d99ec0SAndreas Gohr */ 2614d99ec0SAndreas Gohr function register(&$controller){ 2714d99ec0SAndreas Gohr 2814d99ec0SAndreas Gohr $controller->register_hook('TPL_METAHEADER_OUTPUT', 2914d99ec0SAndreas Gohr 'BEFORE', 3014d99ec0SAndreas Gohr $this, 3114d99ec0SAndreas Gohr 'handle_metaheaders', 3214d99ec0SAndreas Gohr array()); 3314d99ec0SAndreas Gohr } 3414d99ec0SAndreas Gohr 3514d99ec0SAndreas Gohr /** 3614d99ec0SAndreas Gohr * Extend the meta headers 3714d99ec0SAndreas Gohr */ 3814d99ec0SAndreas Gohr function handle_metaheaders(&$event, $param){ 3914d99ec0SAndreas Gohr global $ACT; 4014d99ec0SAndreas Gohr global $ID; 4114d99ec0SAndreas Gohr if($ACT != 'show') return; //only log page views for now 4214d99ec0SAndreas Gohr 43*73051aefSAndreas Gohr $page = rawurlencode($ID); 44*73051aefSAndreas Gohr $data = "plugin_statistics.init('$page');"; 4514d99ec0SAndreas Gohr $event->data['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', '_data'=>$data); 4614d99ec0SAndreas Gohr } 4714d99ec0SAndreas Gohr 4814d99ec0SAndreas Gohr /** 4914d99ec0SAndreas Gohr * @fixme call this in the webbug call 5014d99ec0SAndreas Gohr */ 5114d99ec0SAndreas Gohr function putpixel(){ 5214d99ec0SAndreas Gohr global $ID; 5314d99ec0SAndreas Gohr $url = DOKU_BASE.'lib/plugins/statistics/log.php?p='.rawurlencode($ID). 5414d99ec0SAndreas Gohr '&r='.rawurlencode($_SERVER['HTTP_REFERER']).'&rnd='.time(); 5514d99ec0SAndreas Gohr 5614d99ec0SAndreas Gohr echo '<noscript><img src="'.$url.'" width="1" height="1" /></noscript>'; 5714d99ec0SAndreas Gohr } 5814d99ec0SAndreas Gohr} 5914d99ec0SAndreas Gohr 60