xref: /plugin/statistics/admin.php (revision 6985b606aaf02e1973f52317ffb8c31daa2f119a)
11878f16fSAndreas Gohr<?php
21878f16fSAndreas Gohr/**
31878f16fSAndreas Gohr * statistics plugin
41878f16fSAndreas Gohr *
51878f16fSAndreas Gohr * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
66b6f8822SAndreas Gohr * @author     Andreas Gohr <gohr@splitbrain.org>
71878f16fSAndreas Gohr */
81878f16fSAndreas Gohr
91878f16fSAndreas Gohr// must be run within Dokuwiki
101878f16fSAndreas Gohrif(!defined('DOKU_INC')) die();
111878f16fSAndreas Gohr
122998b1f6SAndreas Gohr
131878f16fSAndreas Gohr/**
141878f16fSAndreas Gohr * All DokuWiki plugins to extend the admin function
151878f16fSAndreas Gohr * need to inherit from this class
161878f16fSAndreas Gohr */
171878f16fSAndreas Gohrclass admin_plugin_statistics extends DokuWiki_Admin_Plugin {
18a901d721SAndreas Gohr    public    $dblink = null;
19a901d721SAndreas Gohr    protected $opt    = '';
20a901d721SAndreas Gohr    protected $from   = '';
21a901d721SAndreas Gohr    protected $to     = '';
22a901d721SAndreas Gohr    protected $start  = '';
23a901d721SAndreas Gohr    protected $tlimit = '';
24a901d721SAndreas Gohr
25a901d721SAndreas Gohr    /**
26a901d721SAndreas Gohr     * Available statistic pages
27a901d721SAndreas Gohr     */
28a901d721SAndreas Gohr    protected $pages  = array('dashboard','page','referer','newreferer',
295bccfe87SAndreas Gohr                              'outlinks','searchengines','searchphrases',
305bccfe87SAndreas Gohr                              'searchwords', 'internalsearchphrases',
315bccfe87SAndreas Gohr                              'internalsearchwords','browsers','os',
325bccfe87SAndreas Gohr                              'countries','resolution');
331878f16fSAndreas Gohr
341878f16fSAndreas Gohr    /**
356b6f8822SAndreas Gohr     * Initialize the helper
366b6f8822SAndreas Gohr     */
376b6f8822SAndreas Gohr    public function __construct() {
386b6f8822SAndreas Gohr        $this->hlp = plugin_load('helper','statistics');
396b6f8822SAndreas Gohr    }
406b6f8822SAndreas Gohr
416b6f8822SAndreas Gohr    /**
421878f16fSAndreas Gohr     * Access for managers allowed
431878f16fSAndreas Gohr     */
446b6f8822SAndreas Gohr    public function forAdminOnly(){
451878f16fSAndreas Gohr        return false;
461878f16fSAndreas Gohr    }
471878f16fSAndreas Gohr
481878f16fSAndreas Gohr    /**
491878f16fSAndreas Gohr     * return sort order for position in admin menu
501878f16fSAndreas Gohr     */
516b6f8822SAndreas Gohr    public function getMenuSort() {
526b6f8822SAndreas Gohr        return 350;
531878f16fSAndreas Gohr    }
541878f16fSAndreas Gohr
551878f16fSAndreas Gohr    /**
561878f16fSAndreas Gohr     * handle user request
571878f16fSAndreas Gohr     */
586b6f8822SAndreas Gohr    public function handle() {
59264f1744SAndreas Gohr        $this->opt = preg_replace('/[^a-z]+/','',$_REQUEST['opt']);
60a901d721SAndreas Gohr        if(!in_array($this->opt,$this->pages)) $this->opt = 'dashboard';
61a901d721SAndreas Gohr
6295eb68e6SAndreas Gohr        $this->start = (int) $_REQUEST['s'];
63e8699bceSAndreas Gohr        $this->setTimeframe($_REQUEST['f'],$_REQUEST['t']);
64e8699bceSAndreas Gohr    }
6595eb68e6SAndreas Gohr
66e8699bceSAndreas Gohr    /**
67e8699bceSAndreas Gohr     * set limit clause
68e8699bceSAndreas Gohr     */
696b6f8822SAndreas Gohr    public function setTimeframe($from,$to){
70264f1744SAndreas Gohr        // fixme add better sanity checking here:
71e8699bceSAndreas Gohr        $from = preg_replace('/[^\d\-]+/','',$from);
72e8699bceSAndreas Gohr        $to   = preg_replace('/[^\d\-]+/','',$to);
73e8699bceSAndreas Gohr        if(!$from) $from = date('Y-m-d');
74e8699bceSAndreas Gohr        if(!$to)   $to   = date('Y-m-d');
75264f1744SAndreas Gohr
76264f1744SAndreas Gohr        //setup limit clause
772ee939eeSAndreas Gohr        $tlimit = "A.dt >= '$from 00:00:00' AND A.dt <= '$to 23:59:59'";
78e8699bceSAndreas Gohr        $this->tlimit = $tlimit;
79e8699bceSAndreas Gohr        $this->from   = $from;
80e8699bceSAndreas Gohr        $this->to     = $to;
811878f16fSAndreas Gohr    }
821878f16fSAndreas Gohr
831878f16fSAndreas Gohr    /**
8479b4a855SAndreas Gohr     * Output the Statistics
851878f16fSAndreas Gohr     */
861878f16fSAndreas Gohr    function html() {
871d2d78ccSAndreas Gohr        echo '<div id="plugin__statistics">';
88264f1744SAndreas Gohr        echo '<h1>Access Statistics</h1>';
89264f1744SAndreas Gohr        $this->html_timeselect();
90264f1744SAndreas Gohr
9179b4a855SAndreas Gohr        $method = 'html_'.$this->opt;
9279b4a855SAndreas Gohr        if(method_exists($this,$method)){
93a901d721SAndreas Gohr            echo '<div class="plg_stats_'.$this->opt.'">';
94a901d721SAndreas Gohr            echo '<h2>'.$this->getLang($this->opt).'</h2>';
9579b4a855SAndreas Gohr            $this->$method();
96a901d721SAndreas Gohr            echo '</div>';
9714d99ec0SAndreas Gohr        }
981d2d78ccSAndreas Gohr        echo '</div>';
9914d99ec0SAndreas Gohr    }
10014d99ec0SAndreas Gohr
1016b6f8822SAndreas Gohr    /**
1026b6f8822SAndreas Gohr     * Return the TOC
1036b6f8822SAndreas Gohr     *
1046b6f8822SAndreas Gohr     * @return array
1056b6f8822SAndreas Gohr     */
10647ffcf7dSAndreas Gohr    function getTOC(){
10747ffcf7dSAndreas Gohr        $toc = array();
108a901d721SAndreas Gohr        foreach($this->pages as $page){
10947ffcf7dSAndreas Gohr            $toc[] = array(
11047ffcf7dSAndreas Gohr                    'link'  => '?do=admin&amp;page=statistics&amp;opt='.$page.'&amp;f='.$this->from.'&amp;t='.$this->to,
11147ffcf7dSAndreas Gohr                    'title' => $this->getLang($page),
11247ffcf7dSAndreas Gohr                    'level' => 1,
11347ffcf7dSAndreas Gohr                    'type'  => 'ul'
11447ffcf7dSAndreas Gohr            );
11547ffcf7dSAndreas Gohr        }
11647ffcf7dSAndreas Gohr        return $toc;
1179da6395dSAndreas Gohr    }
1189da6395dSAndreas Gohr
1196b6f8822SAndreas Gohr    /**
1206b6f8822SAndreas Gohr     * Outputs pagination links
1216b6f8822SAndreas Gohr     *
1226b6f8822SAndreas Gohr     * @fixme does this still work?
1236b6f8822SAndreas Gohr     *
1246b6f8822SAndreas Gohr     * @param type $limit
1256b6f8822SAndreas Gohr     * @param type $next
1266b6f8822SAndreas Gohr     */
1272507f8e0SAndreas Gohr    function html_pager($limit,$next){
1282507f8e0SAndreas Gohr        echo '<div class="plg_stats_pager">';
1292507f8e0SAndreas Gohr
1302507f8e0SAndreas Gohr        if($this->start > 0){
1312507f8e0SAndreas Gohr            $go = max($this->start - $limit, 0);
1322507f8e0SAndreas Gohr            echo '<a href="?do=admin&amp;page=statistics&amp;opt='.$this->opt.'&amp;f='.$this->from.'&amp;t='.$this->to.'&amp;s='.$go.'" class="prev">previous page</a>';
1332507f8e0SAndreas Gohr        }
1342507f8e0SAndreas Gohr
1352507f8e0SAndreas Gohr        if($next){
1362507f8e0SAndreas Gohr            $go = $this->start + $limit;
1372507f8e0SAndreas Gohr            echo '<a href="?do=admin&amp;page=statistics&amp;opt='.$this->opt.'&amp;f='.$this->from.'&amp;t='.$this->to.'&amp;s='.$go.'" class="next">next page</a>';
1382507f8e0SAndreas Gohr        }
1392507f8e0SAndreas Gohr        echo '</div>';
1402507f8e0SAndreas Gohr    }
1412507f8e0SAndreas Gohr
142264f1744SAndreas Gohr    /**
143264f1744SAndreas Gohr     * Print the time selection menu
144264f1744SAndreas Gohr     */
14514d99ec0SAndreas Gohr    function html_timeselect(){
146*6985b606SAndreas Gohr        $today   = date('Y-m-d');
147*6985b606SAndreas Gohr        $last1   = date('Y-m-d',time()-(60*60*24));
148*6985b606SAndreas Gohr        $last7   = date('Y-m-d',time()-(60*60*24*7));
149*6985b606SAndreas Gohr        $last30  = date('Y-m-d',time()-(60*60*24*30));
15014d99ec0SAndreas Gohr
151264f1744SAndreas Gohr        echo '<div class="plg_stats_timeselect">';
152*6985b606SAndreas Gohr        echo '<span>'.$this->getLang('time_select').'</span> ';
153264f1744SAndreas Gohr
154264f1744SAndreas Gohr        echo '<form action="" method="get">';
155264f1744SAndreas Gohr        echo '<input type="hidden" name="do" value="admin" />';
156264f1744SAndreas Gohr        echo '<input type="hidden" name="page" value="statistics" />';
157264f1744SAndreas Gohr        echo '<input type="hidden" name="opt" value="'.$this->opt.'" />';
158264f1744SAndreas Gohr        echo '<input type="text" name="f" value="'.$this->from.'" class="edit" />';
159264f1744SAndreas Gohr        echo '<input type="text" name="t" value="'.$this->to.'" class="edit" />';
160264f1744SAndreas Gohr        echo '<input type="submit" value="go" class="button" />';
16114d99ec0SAndreas Gohr        echo '</form>';
162264f1744SAndreas Gohr
163*6985b606SAndreas Gohr        echo '<ul>';
164*6985b606SAndreas Gohr        foreach(array('today','last1','last7','last30') as $time){
165*6985b606SAndreas Gohr            echo '<li>';
166*6985b606SAndreas Gohr            echo '<a href="?do=admin&amp;page=statistics&amp;opt='.$this->opt.'&amp;f='.$$time.'&amp;t='.$today.'">';
167*6985b606SAndreas Gohr            echo $this->getLang('time_'.$time);
168*6985b606SAndreas Gohr            echo '</a>';
169*6985b606SAndreas Gohr            echo '</li>';
170*6985b606SAndreas Gohr        }
171*6985b606SAndreas Gohr        echo '</ul>';
172*6985b606SAndreas Gohr
173264f1744SAndreas Gohr        echo '</div>';
17414d99ec0SAndreas Gohr    }
17514d99ec0SAndreas Gohr
17614d99ec0SAndreas Gohr
177f5f32cbfSAndreas Gohr    /**
178f5f32cbfSAndreas Gohr     * Print an introductionary screen
179f5f32cbfSAndreas Gohr     */
18014d99ec0SAndreas Gohr    function html_dashboard(){
1812812a751SAndreas Gohr        echo '<p>This page gives you a quick overview on what is happening in your Wiki. For detailed lists
1822812a751SAndreas Gohr              choose a topic from the list.</p>';
1832812a751SAndreas Gohr
1842812a751SAndreas Gohr        // general info
1852812a751SAndreas Gohr        echo '<div class="plg_stats_top">';
1866b6f8822SAndreas Gohr        $result = $this->hlp->Query()->aggregate($this->tlimit);
1871d2d78ccSAndreas Gohr
1881d2d78ccSAndreas Gohr        echo '<ul class="left">';
1891d2d78ccSAndreas Gohr        foreach(array('pageviews','sessions','visitors','users','logins') as $name){
190eabe0d07SAndreas Gohr            echo '<li><div class="li">'.sprintf($this->getLang('dash_'.$name),$result[$name]).'</div></li>';
191eabe0d07SAndreas Gohr        }
1922812a751SAndreas Gohr        echo '</ul>';
1931d2d78ccSAndreas Gohr
1941d2d78ccSAndreas Gohr        echo '<ul class="left">';
1951d2d78ccSAndreas Gohr        foreach(array('bouncerate','timespent','avgpages','newvisitors','registrations') as $name){
1961d2d78ccSAndreas Gohr            echo '<li><div class="li">'.sprintf($this->getLang('dash_'.$name),$result[$name]).'</div></li>';
1971d2d78ccSAndreas Gohr        }
1981d2d78ccSAndreas Gohr        echo '</ul>';
1991d2d78ccSAndreas Gohr
2001d2d78ccSAndreas Gohr
2012812a751SAndreas Gohr        echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/img.php?img=trend&amp;f='.$this->from.'&amp;t='.$this->to.'" />';
2022812a751SAndreas Gohr        echo '</div>';
2032812a751SAndreas Gohr
20414d99ec0SAndreas Gohr
20587d5e44bSAndreas Gohr        // top pages today
206264f1744SAndreas Gohr        echo '<div>';
207264f1744SAndreas Gohr        echo '<h2>Most popular pages</h2>';
2086b6f8822SAndreas Gohr        $result = $this->hlp->Query()->pages($this->tlimit,$this->start,15);
2092812a751SAndreas Gohr        $this->html_resulttable($result);
2102507f8e0SAndreas Gohr        echo '<a href="?do=admin&amp;page=statistics&amp;opt=page&amp;f='.$this->from.'&amp;t='.$this->to.'" class="more">more</a>';
211264f1744SAndreas Gohr        echo '</div>';
21287d5e44bSAndreas Gohr
21387d5e44bSAndreas Gohr        // top referer today
214264f1744SAndreas Gohr        echo '<div>';
215e7a2f1e0SAndreas Gohr        echo '<h2>Newest incoming links</h2>';
2166b6f8822SAndreas Gohr        $result = $this->hlp->Query()->newreferer($this->tlimit,$this->start,15);
2172812a751SAndreas Gohr        $this->html_resulttable($result);
2182507f8e0SAndreas Gohr        echo '<a href="?do=admin&amp;page=statistics&amp;opt=newreferer&amp;f='.$this->from.'&amp;t='.$this->to.'" class="more">more</a>';
219264f1744SAndreas Gohr        echo '</div>';
22054f6c432SAndreas Gohr
22129dea504SAndreas Gohr        // top searches today
222264f1744SAndreas Gohr        echo '<div>';
22329dea504SAndreas Gohr        echo '<h2>Top search phrases</h2>';
2246b6f8822SAndreas Gohr        $result = $this->hlp->Query()->searchphrases($this->tlimit,$this->start,15);
22529dea504SAndreas Gohr        $this->html_resulttable($result);
22629dea504SAndreas Gohr        echo '<a href="?do=admin&amp;page=statistics&amp;opt=searchphrases&amp;f='.$this->from.'&amp;t='.$this->to.'" class="more">more</a>';
227264f1744SAndreas Gohr        echo '</div>';
22814d99ec0SAndreas Gohr    }
22914d99ec0SAndreas Gohr
230c67866d1SAndreas Gohr    function html_countries(){
231c67866d1SAndreas Gohr        echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/img.php?img=countries&amp;f='.$this->from.'&amp;t='.$this->to.'" />';
2326b6f8822SAndreas Gohr        $result = $this->hlp->Query()->countries($this->tlimit,$this->start,150);
2332507f8e0SAndreas Gohr        $this->html_resulttable($result,'',150);
2349da6395dSAndreas Gohr    }
2359da6395dSAndreas Gohr
2369da6395dSAndreas Gohr    function html_page(){
2376b6f8822SAndreas Gohr        $result = $this->hlp->Query()->pages($this->tlimit,$this->start,150);
2382507f8e0SAndreas Gohr        $this->html_resulttable($result,'',150);
2399da6395dSAndreas Gohr    }
2409da6395dSAndreas Gohr
2414f41a2ccSAndreas Gohr    function html_browsers(){
2424f41a2ccSAndreas Gohr        echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/img.php?img=browsers&amp;f='.$this->from.'&amp;t='.$this->to.'" />';
2436b6f8822SAndreas Gohr        $result = $this->hlp->Query()->browsers($this->tlimit,$this->start,150,true);
2442507f8e0SAndreas Gohr        $this->html_resulttable($result,'',150);
24575fa767dSAndreas Gohr    }
24675fa767dSAndreas Gohr
247bd4217d3SAndreas Gohr    function html_os(){
2486b6f8822SAndreas Gohr        $result = $this->hlp->Query()->os($this->tlimit,$this->start,150,true);
2492507f8e0SAndreas Gohr        $this->html_resulttable($result,'',150);
250bd4217d3SAndreas Gohr    }
251bd4217d3SAndreas Gohr
2529da6395dSAndreas Gohr    function html_referer(){
2536b6f8822SAndreas Gohr        $result = $this->hlp->Query()->aggregate($this->tlimit);
2542812a751SAndreas Gohr
2552812a751SAndreas Gohr        $all    = $result['search']+$result['external']+$result['direct'];
2562812a751SAndreas Gohr
25794023548SAndreas Gohr        if($all){
2582812a751SAndreas Gohr            printf("<p>Of all %d external visits, %d (%.1f%%) were bookmarked (direct) accesses,
2592812a751SAndreas Gohr                    %d (%.1f%%) came from search engines and %d (%.1f%%) were referred through
2602812a751SAndreas Gohr                    links from other pages.</p>",$all,$result['direct'],(100*$result['direct']/$all),
2612812a751SAndreas Gohr                    $result['search'],(100*$result['search']/$all),$result['external'],
2622812a751SAndreas Gohr                    (100*$result['external']/$all));
26394023548SAndreas Gohr        }
2642812a751SAndreas Gohr
2656b6f8822SAndreas Gohr        $result = $this->hlp->Query()->referer($this->tlimit,$this->start,150);
2662507f8e0SAndreas Gohr        $this->html_resulttable($result,'',150);
2679da6395dSAndreas Gohr    }
2689da6395dSAndreas Gohr
269e7a2f1e0SAndreas Gohr    function html_newreferer(){
270e7a2f1e0SAndreas Gohr        echo '<p>The following incoming links where first logged in the selected time frame,
271e7a2f1e0SAndreas Gohr              and have never been seen before.</p>';
272e7a2f1e0SAndreas Gohr
2736b6f8822SAndreas Gohr        $result = $this->hlp->Query()->newreferer($this->tlimit,$this->start,150);
2742507f8e0SAndreas Gohr        $this->html_resulttable($result,'',150);
275e7a2f1e0SAndreas Gohr    }
276e7a2f1e0SAndreas Gohr
277e25286daSAndreas Gohr    function html_outlinks(){
2786b6f8822SAndreas Gohr        $result = $this->hlp->Query()->outlinks($this->tlimit,$this->start,150);
279e25286daSAndreas Gohr        $this->html_resulttable($result,'',150);
280e25286daSAndreas Gohr    }
281e25286daSAndreas Gohr
28212dcdeccSAndreas Gohr    function html_searchphrases(){
2835bccfe87SAndreas Gohr        $result = $this->hlp->Query()->searchphrases(true,$this->tlimit,$this->start,150);
28412dcdeccSAndreas Gohr        $this->html_resulttable($result,'',150);
28512dcdeccSAndreas Gohr    }
28612dcdeccSAndreas Gohr
28712dcdeccSAndreas Gohr    function html_searchwords(){
2885bccfe87SAndreas Gohr        $result = $this->hlp->Query()->searchwords(true,$this->tlimit,$this->start,150);
2895bccfe87SAndreas Gohr        $this->html_resulttable($result,'',150);
2905bccfe87SAndreas Gohr    }
2915bccfe87SAndreas Gohr
2925bccfe87SAndreas Gohr    function html_internalsearchphrases(){
2935bccfe87SAndreas Gohr        $result = $this->hlp->Query()->searchphrases(false,$this->tlimit,$this->start,150);
2945bccfe87SAndreas Gohr        $this->html_resulttable($result,'',150);
2955bccfe87SAndreas Gohr    }
2965bccfe87SAndreas Gohr
2975bccfe87SAndreas Gohr    function html_internalsearchwords(){
2985bccfe87SAndreas Gohr        $result = $this->hlp->Query()->searchwords(false,$this->tlimit,$this->start,150);
29912dcdeccSAndreas Gohr        $this->html_resulttable($result,'',150);
30012dcdeccSAndreas Gohr    }
30112dcdeccSAndreas Gohr
30212dcdeccSAndreas Gohr    function html_searchengines(){
3036b6f8822SAndreas Gohr        $result = $this->hlp->Query()->searchengines($this->tlimit,$this->start,150);
30412dcdeccSAndreas Gohr        $this->html_resulttable($result,'',150);
30512dcdeccSAndreas Gohr    }
30612dcdeccSAndreas Gohr
307e25286daSAndreas Gohr
308c73e16f1SAndreas Gohr    function html_resolution(){
309307baf3fSAndreas Gohr
310307baf3fSAndreas Gohr        echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/img.php?img=resolution&amp;f='.$this->from.'&amp;t='.$this->to.'" />';
311c73e16f1SAndreas Gohr
312c73e16f1SAndreas Gohr        echo '<p>While the data above gives you some info about the resolution your visitors use, it does not tell you
313c73e16f1SAndreas Gohr              much about about the real size of their browser windows. The graphic below shows the size distribution of
314c73e16f1SAndreas Gohr              the view port (document area) of your visitor\'s browsers. Please note that this data can not be logged
315c73e16f1SAndreas Gohr              in all browsers. Because users may resize their browser window while browsing your site the statistics may
316c73e16f1SAndreas Gohr              be flawed. Take it with a grain of salt.</p>';
317c73e16f1SAndreas Gohr
318307baf3fSAndreas Gohr        echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/img.php?img=viewport&amp;f='.$this->from.'&amp;t='.$this->to.'" />';
319307baf3fSAndreas Gohr
320307baf3fSAndreas Gohr        $result = $this->hlp->Query()->resolution($this->tlimit,$this->start,150);
321307baf3fSAndreas Gohr        $this->html_resulttable($result,'',150);
322307baf3fSAndreas Gohr
323307baf3fSAndreas Gohr
324c73e16f1SAndreas Gohr    }
3259da6395dSAndreas Gohr
3269da6395dSAndreas Gohr
32714d99ec0SAndreas Gohr    /**
32814d99ec0SAndreas Gohr     * Display a result in a HTML table
32914d99ec0SAndreas Gohr     */
3302507f8e0SAndreas Gohr    function html_resulttable($result,$header='',$pager=0){
33114d99ec0SAndreas Gohr        echo '<table>';
3322812a751SAndreas Gohr        if(is_array($header)){
33314d99ec0SAndreas Gohr            echo '<tr>';
33414d99ec0SAndreas Gohr            foreach($header as $h){
33514d99ec0SAndreas Gohr                echo '<th>'.hsc($h).'</th>';
33614d99ec0SAndreas Gohr            }
33714d99ec0SAndreas Gohr            echo '</tr>';
3382812a751SAndreas Gohr        }
33914d99ec0SAndreas Gohr
3402507f8e0SAndreas Gohr        $count = 0;
3412ee939eeSAndreas Gohr        if(is_array($result)) foreach($result as $row){
34214d99ec0SAndreas Gohr            echo '<tr>';
34314d99ec0SAndreas Gohr            foreach($row as $k => $v){
3442812a751SAndreas Gohr                echo '<td class="plg_stats_X'.$k.'">';
34514d99ec0SAndreas Gohr                if($k == 'page'){
34614d99ec0SAndreas Gohr                    echo '<a href="'.wl($v).'" class="wikilink1">';
34714d99ec0SAndreas Gohr                    echo hsc($v);
34814d99ec0SAndreas Gohr                    echo '</a>';
34914d99ec0SAndreas Gohr                }elseif($k == 'url'){
35054f6c432SAndreas Gohr                    $url = hsc($v);
35183b63546SAndreas Gohr                    $url = preg_replace('/^https?:\/\/(www\.)?/','',$url);
3522812a751SAndreas Gohr                    if(strlen($url) > 45){
3532812a751SAndreas Gohr                        $url = substr($url,0,30).' &hellip; '.substr($url,-15);
35454f6c432SAndreas Gohr                    }
35514d99ec0SAndreas Gohr                    echo '<a href="'.$v.'" class="urlextern">';
35654f6c432SAndreas Gohr                    echo $url;
35714d99ec0SAndreas Gohr                    echo '</a>';
3585bccfe87SAndreas Gohr                }elseif($k == 'ilookup'){
3595bccfe87SAndreas Gohr                    echo '<a href="'.wl('',array('id'=>$v,'do'=>'search')).'">Search</a>';
36029dea504SAndreas Gohr                }elseif($k == 'lookup'){
36129dea504SAndreas Gohr                    echo '<a href="http://www.google.com/search?q='.rawurlencode($v).'">';
36229dea504SAndreas Gohr                    echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/ico/search/google.png" alt="lookup in Google" border="0" />';
36329dea504SAndreas Gohr                    echo '</a> ';
36429dea504SAndreas Gohr
36529dea504SAndreas Gohr                    echo '<a href="http://search.yahoo.com/search?p='.rawurlencode($v).'">';
36629dea504SAndreas Gohr                    echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/ico/search/yahoo.png" alt="lookup in Yahoo" border="0" />';
36729dea504SAndreas Gohr                    echo '</a> ';
36829dea504SAndreas Gohr
36929dea504SAndreas Gohr                    echo '<a href="http://search.msn.com/results.aspx?q='.rawurlencode($v).'">';
37029dea504SAndreas Gohr                    echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/ico/search/msn.png" alt="lookup in MSN Live" border="0" />';
37129dea504SAndreas Gohr                    echo '</a> ';
37229dea504SAndreas Gohr
37312dcdeccSAndreas Gohr                }elseif($k == 'engine'){
37412dcdeccSAndreas Gohr                    include_once(dirname(__FILE__).'/inc/search_engines.php');
37512dcdeccSAndreas Gohr                    echo $SearchEnginesHashLib[$v];
37675fa767dSAndreas Gohr                }elseif($k == 'bflag'){
3772998b1f6SAndreas Gohr                    echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/ico/browser/'.strtolower(preg_replace('/[^\w]+/','',$v)).'.png" alt="'.hsc($v).'" />';
378bd4217d3SAndreas Gohr                }elseif($k == 'osflag'){
3792998b1f6SAndreas Gohr                    echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/ico/os/'.strtolower(preg_replace('/[^\w]+/','',$v)).'.png" alt="'.hsc($v).'" />';
38075fa767dSAndreas Gohr                }elseif($k == 'cflag'){
38175fa767dSAndreas Gohr                    echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/ico/flags/'.hsc($v).'.png" alt="'.hsc($v).'" width="18" height="12" />';
38214d99ec0SAndreas Gohr                }elseif($k == 'html'){
38314d99ec0SAndreas Gohr                    echo $v;
38414d99ec0SAndreas Gohr                }else{
38514d99ec0SAndreas Gohr                    echo hsc($v);
38614d99ec0SAndreas Gohr                }
38714d99ec0SAndreas Gohr                echo '</td>';
38814d99ec0SAndreas Gohr            }
38914d99ec0SAndreas Gohr            echo '</tr>';
3902507f8e0SAndreas Gohr
3912507f8e0SAndreas Gohr            if($pager && ($count == $pager)) break;
3922507f8e0SAndreas Gohr            $count++;
39314d99ec0SAndreas Gohr        }
39414d99ec0SAndreas Gohr        echo '</table>';
3952507f8e0SAndreas Gohr
3962507f8e0SAndreas Gohr        if($pager) $this->html_pager($pager,count($result) > $pager);
3971878f16fSAndreas Gohr    }
3981878f16fSAndreas Gohr
3991878f16fSAndreas Gohr}
400