1*14d99ec0SAndreas Gohr<?php 2*14d99ec0SAndreas Gohr/** 3*14d99ec0SAndreas Gohr * 4*14d99ec0SAndreas Gohr * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 5*14d99ec0SAndreas Gohr * @author Andreas Gohr <gohr@cosmocode.de> 6*14d99ec0SAndreas Gohr */ 7*14d99ec0SAndreas Gohr 8*14d99ec0SAndreas Gohr// must be run within Dokuwiki 9*14d99ec0SAndreas Gohrif(!defined('DOKU_INC')) die(); 10*14d99ec0SAndreas Gohr 11*14d99ec0SAndreas Gohrif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 12*14d99ec0SAndreas Gohrrequire_once(DOKU_PLUGIN.'action.php'); 13*14d99ec0SAndreas Gohr 14*14d99ec0SAndreas Gohrclass action_plugin_statistics extends DokuWiki_Action_Plugin { 15*14d99ec0SAndreas Gohr 16*14d99ec0SAndreas Gohr /** 17*14d99ec0SAndreas Gohr * return some info 18*14d99ec0SAndreas Gohr */ 19*14d99ec0SAndreas Gohr function getInfo(){ 20*14d99ec0SAndreas Gohr return confToHash(dirname(__FILE__).'/info.txt'); 21*14d99ec0SAndreas Gohr } 22*14d99ec0SAndreas Gohr 23*14d99ec0SAndreas Gohr /** 24*14d99ec0SAndreas Gohr * register the eventhandlers and initialize some options 25*14d99ec0SAndreas Gohr */ 26*14d99ec0SAndreas Gohr function register(&$controller){ 27*14d99ec0SAndreas Gohr 28*14d99ec0SAndreas Gohr $controller->register_hook('TPL_METAHEADER_OUTPUT', 29*14d99ec0SAndreas Gohr 'BEFORE', 30*14d99ec0SAndreas Gohr $this, 31*14d99ec0SAndreas Gohr 'handle_metaheaders', 32*14d99ec0SAndreas Gohr array()); 33*14d99ec0SAndreas Gohr } 34*14d99ec0SAndreas Gohr 35*14d99ec0SAndreas Gohr /** 36*14d99ec0SAndreas Gohr * Extend the meta headers 37*14d99ec0SAndreas Gohr */ 38*14d99ec0SAndreas Gohr function handle_metaheaders(&$event, $param){ 39*14d99ec0SAndreas Gohr global $ACT; 40*14d99ec0SAndreas Gohr global $ID; 41*14d99ec0SAndreas Gohr if($ACT != 'show') return; //only log page views for now 42*14d99ec0SAndreas Gohr 43*14d99ec0SAndreas Gohr $url = DOKU_BASE.'lib/plugins/statistics/log.php?p='.rawurlencode($ID).'&rnd='.time(); 44*14d99ec0SAndreas Gohr 45*14d99ec0SAndreas Gohr // we create an image object and load the logger here 46*14d99ec0SAndreas Gohr $data = "var plugin_statistics_image = new Image(); 47*14d99ec0SAndreas Gohr plugin_statistics_image.src = '$url&r='+encodeURIComponent(document.referrer)+ 48*14d99ec0SAndreas Gohr '&sx='+screen.width+ 49*14d99ec0SAndreas Gohr '&sy='+screen.height+ 50*14d99ec0SAndreas Gohr '&vx='+window.innerWidth+ 51*14d99ec0SAndreas Gohr '&vy='+window.innerHeight;"; 52*14d99ec0SAndreas Gohr 53*14d99ec0SAndreas Gohr $event->data['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', '_data'=>$data); 54*14d99ec0SAndreas Gohr } 55*14d99ec0SAndreas Gohr 56*14d99ec0SAndreas Gohr /** 57*14d99ec0SAndreas Gohr * @fixme call this in the webbug call 58*14d99ec0SAndreas Gohr */ 59*14d99ec0SAndreas Gohr function putpixel(){ 60*14d99ec0SAndreas Gohr global $ID; 61*14d99ec0SAndreas Gohr $url = DOKU_BASE.'lib/plugins/statistics/log.php?p='.rawurlencode($ID). 62*14d99ec0SAndreas Gohr '&r='.rawurlencode($_SERVER['HTTP_REFERER']).'&rnd='.time(); 63*14d99ec0SAndreas Gohr 64*14d99ec0SAndreas Gohr echo '<noscript><img src="'.$url.'" width="1" height="1" /></noscript>'; 65*14d99ec0SAndreas Gohr } 66*14d99ec0SAndreas Gohr} 67*14d99ec0SAndreas Gohr 68