xref: /plugin/statistics/admin.php (revision 6b6f8822aea95e0fbdfc3340464d791e6676d91e)
11878f16fSAndreas Gohr<?php
21878f16fSAndreas Gohr/**
31878f16fSAndreas Gohr * statistics plugin
41878f16fSAndreas Gohr *
51878f16fSAndreas Gohr * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6*6b6f8822SAndreas 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',
29a901d721SAndreas Gohr                              'outlinks','searchphrases','searchwords',
30a901d721SAndreas Gohr                              'searchengines','browser','os','country',
31a901d721SAndreas Gohr                              'resolution');
321878f16fSAndreas Gohr
331878f16fSAndreas Gohr    /**
34*6b6f8822SAndreas Gohr     * Initialize the helper
35*6b6f8822SAndreas Gohr     */
36*6b6f8822SAndreas Gohr    public function __construct() {
37*6b6f8822SAndreas Gohr        $this->hlp = plugin_load('helper','statistics');
38*6b6f8822SAndreas Gohr    }
39*6b6f8822SAndreas Gohr
40*6b6f8822SAndreas Gohr    /**
411878f16fSAndreas Gohr     * Access for managers allowed
421878f16fSAndreas Gohr     */
43*6b6f8822SAndreas Gohr    public function forAdminOnly(){
441878f16fSAndreas Gohr        return false;
451878f16fSAndreas Gohr    }
461878f16fSAndreas Gohr
471878f16fSAndreas Gohr    /**
481878f16fSAndreas Gohr     * return sort order for position in admin menu
491878f16fSAndreas Gohr     */
50*6b6f8822SAndreas Gohr    public function getMenuSort() {
51*6b6f8822SAndreas Gohr        return 350;
521878f16fSAndreas Gohr    }
531878f16fSAndreas Gohr
541878f16fSAndreas Gohr    /**
551878f16fSAndreas Gohr     * handle user request
561878f16fSAndreas Gohr     */
57*6b6f8822SAndreas Gohr    public function handle() {
58264f1744SAndreas Gohr        $this->opt = preg_replace('/[^a-z]+/','',$_REQUEST['opt']);
59a901d721SAndreas Gohr        if(!in_array($this->opt,$this->pages)) $this->opt = 'dashboard';
60a901d721SAndreas Gohr
6195eb68e6SAndreas Gohr        $this->start = (int) $_REQUEST['s'];
62e8699bceSAndreas Gohr        $this->setTimeframe($_REQUEST['f'],$_REQUEST['t']);
63e8699bceSAndreas Gohr    }
6495eb68e6SAndreas Gohr
65e8699bceSAndreas Gohr    /**
66e8699bceSAndreas Gohr     * set limit clause
67e8699bceSAndreas Gohr     */
68*6b6f8822SAndreas Gohr    public function setTimeframe($from,$to){
69264f1744SAndreas Gohr        // fixme add better sanity checking here:
70e8699bceSAndreas Gohr        $from = preg_replace('/[^\d\-]+/','',$from);
71e8699bceSAndreas Gohr        $to   = preg_replace('/[^\d\-]+/','',$to);
72e8699bceSAndreas Gohr        if(!$from) $from = date('Y-m-d');
73e8699bceSAndreas Gohr        if(!$to)   $to   = date('Y-m-d');
74264f1744SAndreas Gohr
75264f1744SAndreas Gohr        //setup limit clause
762ee939eeSAndreas Gohr        $tlimit = "A.dt >= '$from 00:00:00' AND A.dt <= '$to 23:59:59'";
77e8699bceSAndreas Gohr        $this->tlimit = $tlimit;
78e8699bceSAndreas Gohr        $this->from   = $from;
79e8699bceSAndreas Gohr        $this->to     = $to;
801878f16fSAndreas Gohr    }
811878f16fSAndreas Gohr
821878f16fSAndreas Gohr    /**
8379b4a855SAndreas Gohr     * Output the Statistics
841878f16fSAndreas Gohr     */
851878f16fSAndreas Gohr    function html() {
86264f1744SAndreas Gohr        echo '<h1>Access Statistics</h1>';
87264f1744SAndreas Gohr        $this->html_timeselect();
88264f1744SAndreas Gohr
8979b4a855SAndreas Gohr        $method = 'html_'.$this->opt;
9079b4a855SAndreas Gohr        if(method_exists($this,$method)){
91a901d721SAndreas Gohr            echo '<div class="plg_stats_'.$this->opt.'">';
92a901d721SAndreas Gohr            echo '<h2>'.$this->getLang($this->opt).'</h2>';
9379b4a855SAndreas Gohr            $this->$method();
94a901d721SAndreas Gohr            echo '</div>';
9514d99ec0SAndreas Gohr        }
9614d99ec0SAndreas Gohr    }
9714d99ec0SAndreas Gohr
98*6b6f8822SAndreas Gohr    /**
99*6b6f8822SAndreas Gohr     * Return the TOC
100*6b6f8822SAndreas Gohr     *
101*6b6f8822SAndreas Gohr     * @return array
102*6b6f8822SAndreas Gohr     */
10347ffcf7dSAndreas Gohr    function getTOC(){
10447ffcf7dSAndreas Gohr        $toc = array();
105a901d721SAndreas Gohr        foreach($this->pages as $page){
10647ffcf7dSAndreas Gohr            $toc[] = array(
10747ffcf7dSAndreas Gohr                    'link'  => '?do=admin&amp;page=statistics&amp;opt='.$page.'&amp;f='.$this->from.'&amp;t='.$this->to,
10847ffcf7dSAndreas Gohr                    'title' => $this->getLang($page),
10947ffcf7dSAndreas Gohr                    'level' => 1,
11047ffcf7dSAndreas Gohr                    'type'  => 'ul'
11147ffcf7dSAndreas Gohr            );
11247ffcf7dSAndreas Gohr        }
11347ffcf7dSAndreas Gohr        return $toc;
1149da6395dSAndreas Gohr    }
1159da6395dSAndreas Gohr
116*6b6f8822SAndreas Gohr    /**
117*6b6f8822SAndreas Gohr     * Outputs pagination links
118*6b6f8822SAndreas Gohr     *
119*6b6f8822SAndreas Gohr     * @fixme does this still work?
120*6b6f8822SAndreas Gohr     *
121*6b6f8822SAndreas Gohr     * @param type $limit
122*6b6f8822SAndreas Gohr     * @param type $next
123*6b6f8822SAndreas Gohr     */
1242507f8e0SAndreas Gohr    function html_pager($limit,$next){
1252507f8e0SAndreas Gohr        echo '<div class="plg_stats_pager">';
1262507f8e0SAndreas Gohr
1272507f8e0SAndreas Gohr        if($this->start > 0){
1282507f8e0SAndreas Gohr            $go = max($this->start - $limit, 0);
1292507f8e0SAndreas 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>';
1302507f8e0SAndreas Gohr        }
1312507f8e0SAndreas Gohr
1322507f8e0SAndreas Gohr        if($next){
1332507f8e0SAndreas Gohr            $go = $this->start + $limit;
1342507f8e0SAndreas 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>';
1352507f8e0SAndreas Gohr        }
1362507f8e0SAndreas Gohr        echo '</div>';
1372507f8e0SAndreas Gohr    }
1382507f8e0SAndreas Gohr
139264f1744SAndreas Gohr    /**
140264f1744SAndreas Gohr     * Print the time selection menu
141264f1744SAndreas Gohr     */
14214d99ec0SAndreas Gohr    function html_timeselect(){
143264f1744SAndreas Gohr        $now   = date('Y-m-d');
144264f1744SAndreas Gohr        $yday  = date('Y-m-d',time()-(60*60*24));
145264f1744SAndreas Gohr        $week  = date('Y-m-d',time()-(60*60*24*7));
146264f1744SAndreas Gohr        $month = date('Y-m-d',time()-(60*60*24*30));
14714d99ec0SAndreas Gohr
148264f1744SAndreas Gohr        echo '<div class="plg_stats_timeselect">';
149264f1744SAndreas Gohr        echo '<span>Select the timeframe:</span>';
150264f1744SAndreas Gohr        echo '<ul>';
151264f1744SAndreas Gohr
152264f1744SAndreas Gohr        echo '<li>';
1532507f8e0SAndreas Gohr        echo '<a href="?do=admin&amp;page=statistics&amp;opt='.$this->opt.'&amp;f='.$now.'&amp;t='.$now.'">';
154264f1744SAndreas Gohr        echo 'today';
155264f1744SAndreas Gohr        echo '</a>';
156264f1744SAndreas Gohr        echo '</li>';
157264f1744SAndreas Gohr
158264f1744SAndreas Gohr        echo '<li>';
1592507f8e0SAndreas Gohr        echo '<a href="?do=admin&amp;page=statistics&amp;opt='.$this->opt.'&amp;f='.$yday.'&amp;t='.$yday.'">';
160264f1744SAndreas Gohr        echo 'yesterday';
161264f1744SAndreas Gohr        echo '</a>';
162264f1744SAndreas Gohr        echo '</li>';
163264f1744SAndreas Gohr
164264f1744SAndreas Gohr        echo '<li>';
1652507f8e0SAndreas Gohr        echo '<a href="?do=admin&amp;page=statistics&amp;opt='.$this->opt.'&amp;f='.$week.'&amp;t='.$now.'">';
166264f1744SAndreas Gohr        echo 'last 7 days';
167264f1744SAndreas Gohr        echo '</a>';
168264f1744SAndreas Gohr        echo '</li>';
169264f1744SAndreas Gohr
170264f1744SAndreas Gohr        echo '<li>';
1712507f8e0SAndreas Gohr        echo '<a href="?do=admin&amp;page=statistics&amp;opt='.$this->opt.'&amp;f='.$month.'&amp;t='.$now.'">';
172264f1744SAndreas Gohr        echo 'last 30 days';
173264f1744SAndreas Gohr        echo '</a>';
174264f1744SAndreas Gohr        echo '</li>';
175264f1744SAndreas Gohr
176264f1744SAndreas Gohr        echo '</ul>';
177264f1744SAndreas Gohr
178264f1744SAndreas Gohr
179264f1744SAndreas Gohr        echo '<form action="" method="get">';
180264f1744SAndreas Gohr        echo '<input type="hidden" name="do" value="admin" />';
181264f1744SAndreas Gohr        echo '<input type="hidden" name="page" value="statistics" />';
182264f1744SAndreas Gohr        echo '<input type="hidden" name="opt" value="'.$this->opt.'" />';
183264f1744SAndreas Gohr        echo '<input type="text" name="f" value="'.$this->from.'" class="edit" />';
184264f1744SAndreas Gohr        echo '<input type="text" name="t" value="'.$this->to.'" class="edit" />';
185264f1744SAndreas Gohr        echo '<input type="submit" value="go" class="button" />';
18614d99ec0SAndreas Gohr        echo '</form>';
187264f1744SAndreas Gohr
188264f1744SAndreas Gohr        echo '</div>';
18914d99ec0SAndreas Gohr    }
19014d99ec0SAndreas Gohr
19114d99ec0SAndreas Gohr
192f5f32cbfSAndreas Gohr    /**
193f5f32cbfSAndreas Gohr     * Print an introductionary screen
194f5f32cbfSAndreas Gohr     */
19514d99ec0SAndreas Gohr    function html_dashboard(){
1962812a751SAndreas Gohr        echo '<p>This page gives you a quick overview on what is happening in your Wiki. For detailed lists
1972812a751SAndreas Gohr              choose a topic from the list.</p>';
1982812a751SAndreas Gohr
1992812a751SAndreas Gohr        // general info
2002812a751SAndreas Gohr        echo '<div class="plg_stats_top">';
201*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->aggregate($this->tlimit);
2022812a751SAndreas Gohr        echo '<ul>';
2032812a751SAndreas Gohr        echo '<li><span>'.$result['pageviews'].'</span> page views </li>';
2043c0acc14SAndreas Gohr        echo '<li><span>'.$result['sessions'].'</span> visits (sessions) </li>';
2053c0acc14SAndreas Gohr        echo '<li><span>'.$result['visitors'].'</span> unique visitors </li>';
2062812a751SAndreas Gohr        echo '<li><span>'.$result['users'].'</span> logged in users</li>';
2072812a751SAndreas Gohr
2082812a751SAndreas Gohr        echo '</ul>';
2092812a751SAndreas Gohr        echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/img.php?img=trend&amp;f='.$this->from.'&amp;t='.$this->to.'" />';
2102812a751SAndreas Gohr        echo '</div>';
2112812a751SAndreas Gohr
21214d99ec0SAndreas Gohr
21387d5e44bSAndreas Gohr        // top pages today
214264f1744SAndreas Gohr        echo '<div>';
215264f1744SAndreas Gohr        echo '<h2>Most popular pages</h2>';
216*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->pages($this->tlimit,$this->start,15);
2172812a751SAndreas Gohr        $this->html_resulttable($result);
2182507f8e0SAndreas Gohr        echo '<a href="?do=admin&amp;page=statistics&amp;opt=page&amp;f='.$this->from.'&amp;t='.$this->to.'" class="more">more</a>';
219264f1744SAndreas Gohr        echo '</div>';
22087d5e44bSAndreas Gohr
22187d5e44bSAndreas Gohr        // top referer today
222264f1744SAndreas Gohr        echo '<div>';
223e7a2f1e0SAndreas Gohr        echo '<h2>Newest incoming links</h2>';
224*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->newreferer($this->tlimit,$this->start,15);
2252812a751SAndreas Gohr        $this->html_resulttable($result);
2262507f8e0SAndreas Gohr        echo '<a href="?do=admin&amp;page=statistics&amp;opt=newreferer&amp;f='.$this->from.'&amp;t='.$this->to.'" class="more">more</a>';
227264f1744SAndreas Gohr        echo '</div>';
22854f6c432SAndreas Gohr
22929dea504SAndreas Gohr        // top searches today
230264f1744SAndreas Gohr        echo '<div>';
23129dea504SAndreas Gohr        echo '<h2>Top search phrases</h2>';
232*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->searchphrases($this->tlimit,$this->start,15);
23329dea504SAndreas Gohr        $this->html_resulttable($result);
23429dea504SAndreas Gohr        echo '<a href="?do=admin&amp;page=statistics&amp;opt=searchphrases&amp;f='.$this->from.'&amp;t='.$this->to.'" class="more">more</a>';
235264f1744SAndreas Gohr        echo '</div>';
23614d99ec0SAndreas Gohr    }
23714d99ec0SAndreas Gohr
2389da6395dSAndreas Gohr    function html_country(){
239bd4217d3SAndreas Gohr        echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/img.php?img=country&amp;f='.$this->from.'&amp;t='.$this->to.'" />';
240*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->countries($this->tlimit,$this->start,150);
2412507f8e0SAndreas Gohr        $this->html_resulttable($result,'',150);
2429da6395dSAndreas Gohr    }
2439da6395dSAndreas Gohr
2449da6395dSAndreas Gohr    function html_page(){
245*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->pages($this->tlimit,$this->start,150);
2462507f8e0SAndreas Gohr        $this->html_resulttable($result,'',150);
2479da6395dSAndreas Gohr    }
2489da6395dSAndreas Gohr
24975fa767dSAndreas Gohr    function html_browser(){
25075fa767dSAndreas Gohr        echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/img.php?img=browser&amp;f='.$this->from.'&amp;t='.$this->to.'" />';
251*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->browsers($this->tlimit,$this->start,150,true);
2522507f8e0SAndreas Gohr        $this->html_resulttable($result,'',150);
25375fa767dSAndreas Gohr    }
25475fa767dSAndreas Gohr
255bd4217d3SAndreas Gohr    function html_os(){
256*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->os($this->tlimit,$this->start,150,true);
2572507f8e0SAndreas Gohr        $this->html_resulttable($result,'',150);
258bd4217d3SAndreas Gohr    }
259bd4217d3SAndreas Gohr
2609da6395dSAndreas Gohr    function html_referer(){
261*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->aggregate($this->tlimit);
2622812a751SAndreas Gohr
2632812a751SAndreas Gohr        $all    = $result['search']+$result['external']+$result['direct'];
2642812a751SAndreas Gohr
26594023548SAndreas Gohr        if($all){
2662812a751SAndreas Gohr            printf("<p>Of all %d external visits, %d (%.1f%%) were bookmarked (direct) accesses,
2672812a751SAndreas Gohr                    %d (%.1f%%) came from search engines and %d (%.1f%%) were referred through
2682812a751SAndreas Gohr                    links from other pages.</p>",$all,$result['direct'],(100*$result['direct']/$all),
2692812a751SAndreas Gohr                    $result['search'],(100*$result['search']/$all),$result['external'],
2702812a751SAndreas Gohr                    (100*$result['external']/$all));
27194023548SAndreas Gohr        }
2722812a751SAndreas Gohr
273*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->referer($this->tlimit,$this->start,150);
2742507f8e0SAndreas Gohr        $this->html_resulttable($result,'',150);
2759da6395dSAndreas Gohr    }
2769da6395dSAndreas Gohr
277e7a2f1e0SAndreas Gohr    function html_newreferer(){
278e7a2f1e0SAndreas Gohr        echo '<p>The following incoming links where first logged in the selected time frame,
279e7a2f1e0SAndreas Gohr              and have never been seen before.</p>';
280e7a2f1e0SAndreas Gohr
281*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->newreferer($this->tlimit,$this->start,150);
2822507f8e0SAndreas Gohr        $this->html_resulttable($result,'',150);
283e7a2f1e0SAndreas Gohr    }
284e7a2f1e0SAndreas Gohr
285e25286daSAndreas Gohr    function html_outlinks(){
286*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->outlinks($this->tlimit,$this->start,150);
287e25286daSAndreas Gohr        $this->html_resulttable($result,'',150);
288e25286daSAndreas Gohr    }
289e25286daSAndreas Gohr
29012dcdeccSAndreas Gohr    function html_searchphrases(){
291*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->searchphrases($this->tlimit,$this->start,150);
29212dcdeccSAndreas Gohr        $this->html_resulttable($result,'',150);
29312dcdeccSAndreas Gohr    }
29412dcdeccSAndreas Gohr
29512dcdeccSAndreas Gohr    function html_searchwords(){
296*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->searchwords($this->tlimit,$this->start,150);
29712dcdeccSAndreas Gohr        $this->html_resulttable($result,'',150);
29812dcdeccSAndreas Gohr    }
29912dcdeccSAndreas Gohr
30012dcdeccSAndreas Gohr    function html_searchengines(){
301*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->searchengines($this->tlimit,$this->start,150);
30212dcdeccSAndreas Gohr        $this->html_resulttable($result,'',150);
30312dcdeccSAndreas Gohr    }
30412dcdeccSAndreas Gohr
305e25286daSAndreas Gohr
306c73e16f1SAndreas Gohr    function html_resolution(){
307*6b6f8822SAndreas Gohr        $result = $this->hlp->Query()->resolution($this->tlimit,$this->start,150);
308c73e16f1SAndreas Gohr        $this->html_resulttable($result,'',150);
309c73e16f1SAndreas Gohr
310c73e16f1SAndreas Gohr        echo '<p>While the data above gives you some info about the resolution your visitors use, it does not tell you
311c73e16f1SAndreas Gohr              much about about the real size of their browser windows. The graphic below shows the size distribution of
312c73e16f1SAndreas Gohr              the view port (document area) of your visitor\'s browsers. Please note that this data can not be logged
313c73e16f1SAndreas Gohr              in all browsers. Because users may resize their browser window while browsing your site the statistics may
314c73e16f1SAndreas Gohr              be flawed. Take it with a grain of salt.</p>';
315c73e16f1SAndreas Gohr
316c73e16f1SAndreas Gohr        echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/img.php?img=view&amp;f='.$this->from.'&amp;t='.$this->to.'" />';
317c73e16f1SAndreas Gohr    }
3189da6395dSAndreas Gohr
3199da6395dSAndreas Gohr
32014d99ec0SAndreas Gohr    /**
32114d99ec0SAndreas Gohr     * Display a result in a HTML table
32214d99ec0SAndreas Gohr     */
3232507f8e0SAndreas Gohr    function html_resulttable($result,$header='',$pager=0){
32414d99ec0SAndreas Gohr        echo '<table>';
3252812a751SAndreas Gohr        if(is_array($header)){
32614d99ec0SAndreas Gohr            echo '<tr>';
32714d99ec0SAndreas Gohr            foreach($header as $h){
32814d99ec0SAndreas Gohr                echo '<th>'.hsc($h).'</th>';
32914d99ec0SAndreas Gohr            }
33014d99ec0SAndreas Gohr            echo '</tr>';
3312812a751SAndreas Gohr        }
33214d99ec0SAndreas Gohr
3332507f8e0SAndreas Gohr        $count = 0;
3342ee939eeSAndreas Gohr        if(is_array($result)) foreach($result as $row){
33514d99ec0SAndreas Gohr            echo '<tr>';
33614d99ec0SAndreas Gohr            foreach($row as $k => $v){
3372812a751SAndreas Gohr                echo '<td class="plg_stats_X'.$k.'">';
33814d99ec0SAndreas Gohr                if($k == 'page'){
33914d99ec0SAndreas Gohr                    echo '<a href="'.wl($v).'" class="wikilink1">';
34014d99ec0SAndreas Gohr                    echo hsc($v);
34114d99ec0SAndreas Gohr                    echo '</a>';
34214d99ec0SAndreas Gohr                }elseif($k == 'url'){
34354f6c432SAndreas Gohr                    $url = hsc($v);
34483b63546SAndreas Gohr                    $url = preg_replace('/^https?:\/\/(www\.)?/','',$url);
3452812a751SAndreas Gohr                    if(strlen($url) > 45){
3462812a751SAndreas Gohr                        $url = substr($url,0,30).' &hellip; '.substr($url,-15);
34754f6c432SAndreas Gohr                    }
34814d99ec0SAndreas Gohr                    echo '<a href="'.$v.'" class="urlextern">';
34954f6c432SAndreas Gohr                    echo $url;
35014d99ec0SAndreas Gohr                    echo '</a>';
35129dea504SAndreas Gohr                }elseif($k == 'lookup'){
35229dea504SAndreas Gohr                    echo '<a href="http://www.google.com/search?q='.rawurlencode($v).'">';
35329dea504SAndreas Gohr                    echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/ico/search/google.png" alt="lookup in Google" border="0" />';
35429dea504SAndreas Gohr                    echo '</a> ';
35529dea504SAndreas Gohr
35629dea504SAndreas Gohr                    echo '<a href="http://search.yahoo.com/search?p='.rawurlencode($v).'">';
35729dea504SAndreas Gohr                    echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/ico/search/yahoo.png" alt="lookup in Yahoo" border="0" />';
35829dea504SAndreas Gohr                    echo '</a> ';
35929dea504SAndreas Gohr
36029dea504SAndreas Gohr                    echo '<a href="http://search.msn.com/results.aspx?q='.rawurlencode($v).'">';
36129dea504SAndreas Gohr                    echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/ico/search/msn.png" alt="lookup in MSN Live" border="0" />';
36229dea504SAndreas Gohr                    echo '</a> ';
36329dea504SAndreas Gohr
36412dcdeccSAndreas Gohr                }elseif($k == 'engine'){
36512dcdeccSAndreas Gohr                    include_once(dirname(__FILE__).'/inc/search_engines.php');
36612dcdeccSAndreas Gohr                    echo $SearchEnginesHashLib[$v];
36775fa767dSAndreas Gohr                }elseif($k == 'bflag'){
3682998b1f6SAndreas Gohr                    echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/ico/browser/'.strtolower(preg_replace('/[^\w]+/','',$v)).'.png" alt="'.hsc($v).'" />';
369bd4217d3SAndreas Gohr                }elseif($k == 'osflag'){
3702998b1f6SAndreas Gohr                    echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/ico/os/'.strtolower(preg_replace('/[^\w]+/','',$v)).'.png" alt="'.hsc($v).'" />';
37175fa767dSAndreas Gohr                }elseif($k == 'cflag'){
37275fa767dSAndreas Gohr                    echo '<img src="'.DOKU_BASE.'lib/plugins/statistics/ico/flags/'.hsc($v).'.png" alt="'.hsc($v).'" width="18" height="12" />';
37314d99ec0SAndreas Gohr                }elseif($k == 'html'){
37414d99ec0SAndreas Gohr                    echo $v;
37514d99ec0SAndreas Gohr                }else{
37614d99ec0SAndreas Gohr                    echo hsc($v);
37714d99ec0SAndreas Gohr                }
37814d99ec0SAndreas Gohr                echo '</td>';
37914d99ec0SAndreas Gohr            }
38014d99ec0SAndreas Gohr            echo '</tr>';
3812507f8e0SAndreas Gohr
3822507f8e0SAndreas Gohr            if($pager && ($count == $pager)) break;
3832507f8e0SAndreas Gohr            $count++;
38414d99ec0SAndreas Gohr        }
38514d99ec0SAndreas Gohr        echo '</table>';
3862507f8e0SAndreas Gohr
3872507f8e0SAndreas Gohr        if($pager) $this->html_pager($pager,count($result) > $pager);
3881878f16fSAndreas Gohr    }
3891878f16fSAndreas Gohr
39095eb68e6SAndreas Gohr    /**
39195eb68e6SAndreas Gohr     * Create an image
39295eb68e6SAndreas Gohr     */
39395eb68e6SAndreas Gohr    function img_build($img){
39495eb68e6SAndreas Gohr        include(dirname(__FILE__).'/inc/AGC.class.php');
39595eb68e6SAndreas Gohr
39695eb68e6SAndreas Gohr        switch($img){
39795eb68e6SAndreas Gohr            default:
39895eb68e6SAndreas Gohr                $this->sendGIF();
39995eb68e6SAndreas Gohr        }
40095eb68e6SAndreas Gohr    }
40195eb68e6SAndreas Gohr
4021878f16fSAndreas Gohr    /**
4031878f16fSAndreas Gohr     * Just send a 1x1 pixel blank gif to the browser
4041878f16fSAndreas Gohr     *
4051878f16fSAndreas Gohr     * @called from log.php
4061878f16fSAndreas Gohr     *
4071878f16fSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
4081878f16fSAndreas Gohr     * @author Harry Fuecks <fuecks@gmail.com>
4091878f16fSAndreas Gohr     */
4101878f16fSAndreas Gohr    function sendGIF(){
4111878f16fSAndreas Gohr        $img = base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7');
4121878f16fSAndreas Gohr        header('Content-Type: image/gif');
4131878f16fSAndreas Gohr        header('Content-Length: '.strlen($img));
4141878f16fSAndreas Gohr        header('Connection: Close');
4151878f16fSAndreas Gohr        print $img;
4161878f16fSAndreas Gohr        flush();
4171878f16fSAndreas Gohr        // Browser should drop connection after this
4181878f16fSAndreas Gohr        // Thinks it's got the whole image
4191878f16fSAndreas Gohr    }
4201878f16fSAndreas Gohr
4211878f16fSAndreas Gohr}
422