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 * register the eventhandlers and initialize some options 1814d99ec0SAndreas Gohr */ 1914d99ec0SAndreas Gohr function register(&$controller){ 20*eabe0d07SAndreas Gohr global $JSINFO; 21*eabe0d07SAndreas Gohr global $ACT; 22*eabe0d07SAndreas Gohr $JSINFO['act'] = $ACT; 2314d99ec0SAndreas Gohr 24*eabe0d07SAndreas Gohr 2558511ae8SAndreas Gohr $controller->register_hook('IO_WIKIPAGE_WRITE', 2658511ae8SAndreas Gohr 'BEFORE', 2758511ae8SAndreas Gohr $this, 2858511ae8SAndreas Gohr 'logedits', 2958511ae8SAndreas Gohr array()); 305bccfe87SAndreas Gohr $controller->register_hook('SEARCH_QUERY_FULLPAGE', 315bccfe87SAndreas Gohr 'AFTER', 325bccfe87SAndreas Gohr $this, 335bccfe87SAndreas Gohr 'logsearch', 345bccfe87SAndreas Gohr array()); 3514d99ec0SAndreas Gohr } 3614d99ec0SAndreas Gohr 3714d99ec0SAndreas Gohr 3814d99ec0SAndreas Gohr /** 3914d99ec0SAndreas Gohr * @fixme call this in the webbug call 4014d99ec0SAndreas Gohr */ 4114d99ec0SAndreas Gohr function putpixel(){ 4214d99ec0SAndreas Gohr global $ID; 4314d99ec0SAndreas Gohr $url = DOKU_BASE.'lib/plugins/statistics/log.php?p='.rawurlencode($ID). 4414d99ec0SAndreas Gohr '&r='.rawurlencode($_SERVER['HTTP_REFERER']).'&rnd='.time(); 4514d99ec0SAndreas Gohr 4614d99ec0SAndreas Gohr echo '<noscript><img src="'.$url.'" width="1" height="1" /></noscript>'; 4714d99ec0SAndreas Gohr } 4858511ae8SAndreas Gohr 4958511ae8SAndreas Gohr 5058511ae8SAndreas Gohr /** 515bccfe87SAndreas Gohr * Log page edits actions 5258511ae8SAndreas Gohr */ 5358511ae8SAndreas Gohr function logedits(&$event, $param){ 5458511ae8SAndreas Gohr if($event->data[3]) return; // no revision 5558511ae8SAndreas Gohr 5658511ae8SAndreas Gohr if(file_exists($event->data[0][0])){ 5758511ae8SAndreas Gohr if($event->data[0][1] == ''){ 5858511ae8SAndreas Gohr $type = 'D'; 5958511ae8SAndreas Gohr }else{ 6058511ae8SAndreas Gohr $type = 'E'; 6158511ae8SAndreas Gohr } 6258511ae8SAndreas Gohr }else{ 6358511ae8SAndreas Gohr $type = 'C'; 6458511ae8SAndreas Gohr } 6558511ae8SAndreas Gohr $hlp = plugin_load('helper','statistics'); 6658511ae8SAndreas Gohr $hlp->Logger()->log_edit(cleanID($event->data[1].':'.$event->data[2]), $type); 6758511ae8SAndreas Gohr } 685bccfe87SAndreas Gohr 695bccfe87SAndreas Gohr /** 705bccfe87SAndreas Gohr * Log internal search 715bccfe87SAndreas Gohr */ 725bccfe87SAndreas Gohr function logsearch(&$event, $param){ 735bccfe87SAndreas Gohr $hlp = plugin_load('helper','statistics'); 745bccfe87SAndreas Gohr $hlp->Logger()->log_search('',$event->data['query'],$event->data['highlight'],'dokuwiki'); 755bccfe87SAndreas Gohr } 7614d99ec0SAndreas Gohr} 7714d99ec0SAndreas Gohr 78