xref: /plugin/statistics/admin.php (revision 87d5e44b252985d375db6eb3c6ebf1b7df736a84)
11878f16fSAndreas Gohr<?php
21878f16fSAndreas Gohr/**
31878f16fSAndreas Gohr * statistics plugin
41878f16fSAndreas Gohr *
51878f16fSAndreas Gohr * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
61878f16fSAndreas Gohr * @author     Andreas Gohr <gohr@cosmocode.de>
71878f16fSAndreas Gohr */
81878f16fSAndreas Gohr
91878f16fSAndreas Gohr// must be run within Dokuwiki
101878f16fSAndreas Gohrif(!defined('DOKU_INC')) die();
111878f16fSAndreas Gohr
121878f16fSAndreas Gohrif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
131878f16fSAndreas Gohrrequire_once(DOKU_PLUGIN.'admin.php');
141878f16fSAndreas Gohr
151878f16fSAndreas Gohr/**
161878f16fSAndreas Gohr * All DokuWiki plugins to extend the admin function
171878f16fSAndreas Gohr * need to inherit from this class
181878f16fSAndreas Gohr */
191878f16fSAndreas Gohrclass admin_plugin_statistics extends DokuWiki_Admin_Plugin {
201878f16fSAndreas Gohr    var $dblink = null;
211878f16fSAndreas Gohr
221878f16fSAndreas Gohr    /**
231878f16fSAndreas Gohr     * return some info
241878f16fSAndreas Gohr     */
251878f16fSAndreas Gohr    function getInfo(){
261878f16fSAndreas Gohr        return confToHash(dirname(__FILE__).'/info.txt');
271878f16fSAndreas Gohr    }
281878f16fSAndreas Gohr
291878f16fSAndreas Gohr    /**
301878f16fSAndreas Gohr     * Access for managers allowed
311878f16fSAndreas Gohr     */
321878f16fSAndreas Gohr    function forAdminOnly(){
331878f16fSAndreas Gohr        return false;
341878f16fSAndreas Gohr    }
351878f16fSAndreas Gohr
361878f16fSAndreas Gohr    /**
371878f16fSAndreas Gohr     * return sort order for position in admin menu
381878f16fSAndreas Gohr     */
391878f16fSAndreas Gohr    function getMenuSort() {
4014d99ec0SAndreas Gohr        return 150;
411878f16fSAndreas Gohr    }
421878f16fSAndreas Gohr
431878f16fSAndreas Gohr    /**
441878f16fSAndreas Gohr     * handle user request
451878f16fSAndreas Gohr     */
461878f16fSAndreas Gohr    function handle() {
471878f16fSAndreas Gohr    }
481878f16fSAndreas Gohr
491878f16fSAndreas Gohr    /**
5094171ff3SAndreas Gohr     * fixme build statistics here
511878f16fSAndreas Gohr     */
521878f16fSAndreas Gohr    function html() {
5314d99ec0SAndreas Gohr        // fixme build a navigation menu in a TOC here
5414d99ec0SAndreas Gohr
5514d99ec0SAndreas Gohr        switch($_REQUEST['opt']){
5614d99ec0SAndreas Gohr
5714d99ec0SAndreas Gohr            default:
5814d99ec0SAndreas Gohr                echo $this->locale_xhtml('intro');
5914d99ec0SAndreas Gohr                echo $this->html_dashboard();
6014d99ec0SAndreas Gohr        }
6114d99ec0SAndreas Gohr    }
6214d99ec0SAndreas Gohr
6314d99ec0SAndreas Gohr    function html_timeselect(){
6414d99ec0SAndreas Gohr        echo '<form>';
6514d99ec0SAndreas Gohr
6614d99ec0SAndreas Gohr        echo '</form>';
6714d99ec0SAndreas Gohr    }
6814d99ec0SAndreas Gohr
6914d99ec0SAndreas Gohr
7014d99ec0SAndreas Gohr    function html_dashboard(){
7114d99ec0SAndreas Gohr
72*87d5e44bSAndreas Gohr        // top pages today
7314d99ec0SAndreas Gohr        $sql = "SELECT page, COUNT(*) as cnt
7414d99ec0SAndreas Gohr                  FROM ".$this->getConf('db_prefix')."access
7514d99ec0SAndreas Gohr                 WHERE DATE(dt) = CURDATE()
76*87d5e44bSAndreas Gohr                   AND ua_type = 'browser'
7714d99ec0SAndreas Gohr              GROUP BY page
7814d99ec0SAndreas Gohr              ORDER BY cnt DESC, page
7914d99ec0SAndreas Gohr                 LIMIT 20";
8014d99ec0SAndreas Gohr        $result = $this->runSQL($sql);
81*87d5e44bSAndreas Gohr        $this->html_resulttable($result,array('Pages','Count'));
82*87d5e44bSAndreas Gohr
83*87d5e44bSAndreas Gohr        // top referer today
84*87d5e44bSAndreas Gohr        $sql = "SELECT ref as url, COUNT(*) as cnt
85*87d5e44bSAndreas Gohr                  FROM ".$this->getConf('db_prefix')."access
86*87d5e44bSAndreas Gohr                 WHERE DATE(dt) = CURDATE()
87*87d5e44bSAndreas Gohr                   AND ua_type = 'browser'
88*87d5e44bSAndreas Gohr                   AND ref_type = 'external'
89*87d5e44bSAndreas Gohr              GROUP BY ref_md5
90*87d5e44bSAndreas Gohr              ORDER BY cnt DESC, url
91*87d5e44bSAndreas Gohr                 LIMIT 20";
92*87d5e44bSAndreas Gohr        $result = $this->runSQL($sql);
93*87d5e44bSAndreas Gohr        $this->html_resulttable($result,array('Incoming Links','Count'));
9414d99ec0SAndreas Gohr    }
9514d99ec0SAndreas Gohr
9614d99ec0SAndreas Gohr    /**
9714d99ec0SAndreas Gohr     * Display a result in a HTML table
9814d99ec0SAndreas Gohr     */
9914d99ec0SAndreas Gohr    function html_resulttable($result,$header){
10014d99ec0SAndreas Gohr        echo '<table>';
10114d99ec0SAndreas Gohr        echo '<tr>';
10214d99ec0SAndreas Gohr        foreach($header as $h){
10314d99ec0SAndreas Gohr            echo '<th>'.hsc($h).'</th>';
10414d99ec0SAndreas Gohr        }
10514d99ec0SAndreas Gohr        echo '</tr>';
10614d99ec0SAndreas Gohr
10714d99ec0SAndreas Gohr        foreach($result as $row){
10814d99ec0SAndreas Gohr            echo '<tr>';
10914d99ec0SAndreas Gohr            foreach($row as $k => $v){
11014d99ec0SAndreas Gohr                echo '<td class="stats_'.$k.'">';
11114d99ec0SAndreas Gohr                if($k == 'page'){
11214d99ec0SAndreas Gohr                    echo '<a href="'.wl($v).'" class="wikilink1">';
11314d99ec0SAndreas Gohr                    echo hsc($v);
11414d99ec0SAndreas Gohr                    echo '</a>';
11514d99ec0SAndreas Gohr                }elseif($k == 'url'){
11614d99ec0SAndreas Gohr                    echo '<a href="'.$v.'" class="urlextern">';
11714d99ec0SAndreas Gohr                    echo hsc($v);
11814d99ec0SAndreas Gohr                    echo '</a>';
11914d99ec0SAndreas Gohr                }elseif($k == 'html'){
12014d99ec0SAndreas Gohr                    echo $v;
12114d99ec0SAndreas Gohr                }else{
12214d99ec0SAndreas Gohr                    echo hsc($v);
12314d99ec0SAndreas Gohr                }
12414d99ec0SAndreas Gohr                echo '</td>';
12514d99ec0SAndreas Gohr            }
12614d99ec0SAndreas Gohr            echo '</tr>';
12714d99ec0SAndreas Gohr        }
12814d99ec0SAndreas Gohr        echo '</table>';
1291878f16fSAndreas Gohr    }
1301878f16fSAndreas Gohr
1311878f16fSAndreas Gohr
1321878f16fSAndreas Gohr    /**
13314d99ec0SAndreas Gohr     * Return a link to the DB, opening the connection if needed
1341878f16fSAndreas Gohr     */
13514d99ec0SAndreas Gohr    function dbLink(){
1361878f16fSAndreas Gohr        // connect to DB if needed
1371878f16fSAndreas Gohr        if(!$this->dblink){
1381878f16fSAndreas Gohr            $this->dblink = mysql_connect($this->getConf('db_server'),
1391878f16fSAndreas Gohr                                          $this->getConf('db_user'),
1401878f16fSAndreas Gohr                                          $this->getConf('db_password'));
1411878f16fSAndreas Gohr            if(!$this->dblink){
1421878f16fSAndreas Gohr                msg('DB Error: connection failed',-1);
1431878f16fSAndreas Gohr                return null;
1441878f16fSAndreas Gohr            }
1451878f16fSAndreas Gohr            // set utf-8
1461878f16fSAndreas Gohr            if(!mysql_db_query($this->getConf('db_database'),'set names utf8',$this->dblink)){
1471878f16fSAndreas Gohr                msg('DB Error: could not set UTF-8 ('.mysql_error($this->dblink).')',-1);
1481878f16fSAndreas Gohr                return null;
1491878f16fSAndreas Gohr            }
1501878f16fSAndreas Gohr        }
15114d99ec0SAndreas Gohr        return $this->dblink;
15214d99ec0SAndreas Gohr    }
1531878f16fSAndreas Gohr
15414d99ec0SAndreas Gohr    /**
15514d99ec0SAndreas Gohr     * Simple function to run a DB query
15614d99ec0SAndreas Gohr     */
15714d99ec0SAndreas Gohr    function runSQL($sql_string) {
15814d99ec0SAndreas Gohr        $link = $this->dbLink();
15914d99ec0SAndreas Gohr
16014d99ec0SAndreas Gohr        $result = mysql_db_query($this->conf['db_database'],$sql_string,$link);
16194171ff3SAndreas Gohr        if(!$result){
16214d99ec0SAndreas Gohr            msg('DB Error: '.mysql_error($link),-1);
1631878f16fSAndreas Gohr            return null;
1641878f16fSAndreas Gohr        }
1651878f16fSAndreas Gohr
1661878f16fSAndreas Gohr        $resultarray = array();
1671878f16fSAndreas Gohr
1681878f16fSAndreas Gohr        //mysql_db_query returns 1 on a insert statement -> no need to ask for results
1691878f16fSAndreas Gohr        if ($result != 1) {
1701878f16fSAndreas Gohr            for($i=0; $i< mysql_num_rows($result); $i++) {
1711878f16fSAndreas Gohr                $temparray = mysql_fetch_assoc($result);
1721878f16fSAndreas Gohr                $resultarray[]=$temparray;
1731878f16fSAndreas Gohr            }
1741878f16fSAndreas Gohr            mysql_free_result($result);
1751878f16fSAndreas Gohr        }
1761878f16fSAndreas Gohr
17714d99ec0SAndreas Gohr        if (mysql_insert_id($link)) {
17814d99ec0SAndreas Gohr            $resultarray = mysql_insert_id($link); //give back ID on insert
1791878f16fSAndreas Gohr        }
1801878f16fSAndreas Gohr
1811878f16fSAndreas Gohr        return $resultarray;
1821878f16fSAndreas Gohr    }
1831878f16fSAndreas Gohr
1841878f16fSAndreas Gohr    /**
18514d99ec0SAndreas Gohr     * Returns a short name for a User Agent and sets type, version and os info
1861878f16fSAndreas Gohr     */
18714d99ec0SAndreas Gohr    function ua_info($ua,&$type,&$ver,&$os){
18814d99ec0SAndreas Gohr        $ua = strtr($ua,' +','__');
18914d99ec0SAndreas Gohr        $ua = strtolower($ua);
19014d99ec0SAndreas Gohr
19114d99ec0SAndreas Gohr        // common browsers
19214d99ec0SAndreas Gohr        $regvermsie     = '/msie([+_ ]|)([\d\.]*)/i';
19314d99ec0SAndreas Gohr        $regvernetscape = '/netscape.?\/([\d\.]*)/i';
19414d99ec0SAndreas Gohr        $regverfirefox  = '/firefox\/([\d\.]*)/i';
19514d99ec0SAndreas Gohr        $regversvn      = '/svn\/([\d\.]*)/i';
19614d99ec0SAndreas Gohr        $regvermozilla  = '/mozilla(\/|)([\d\.]*)/i';
19714d99ec0SAndreas Gohr        $regnotie       = '/webtv|omniweb|opera/i';
19814d99ec0SAndreas Gohr        $regnotnetscape = '/gecko|compatible|opera|galeon|safari/i';
19914d99ec0SAndreas Gohr
20014d99ec0SAndreas Gohr        $name = '';
20114d99ec0SAndreas Gohr        # IE ?
20214d99ec0SAndreas Gohr        if(preg_match($regvermsie,$ua,$m) && !preg_match($regnotie,$ua)){
20314d99ec0SAndreas Gohr            $type = 'browser';
20414d99ec0SAndreas Gohr            $ver  = $m[2];
20514d99ec0SAndreas Gohr            $name = 'msie';
20614d99ec0SAndreas Gohr        }
20714d99ec0SAndreas Gohr        # Firefox ?
20814d99ec0SAndreas Gohr        elseif (preg_match($regverfirefox,$ua,$m)){
20914d99ec0SAndreas Gohr            $type = 'browser';
21014d99ec0SAndreas Gohr            $ver  = $m[1];
21114d99ec0SAndreas Gohr            $name = 'firefox';
21214d99ec0SAndreas Gohr        }
21314d99ec0SAndreas Gohr        # Subversion ?
21414d99ec0SAndreas Gohr        elseif (preg_match($regversvn,$ua,$m)){
21514d99ec0SAndreas Gohr            $type = 'rcs';
21614d99ec0SAndreas Gohr            $ver  = $m[1];
21714d99ec0SAndreas Gohr            $name = 'svn';
21814d99ec0SAndreas Gohr        }
21914d99ec0SAndreas Gohr        # Netscape 6.x, 7.x ... ?
22014d99ec0SAndreas Gohr        elseif (preg_match($regvernetscape,$ua,$m)){
22114d99ec0SAndreas Gohr            $type = 'browser';
22214d99ec0SAndreas Gohr            $ver  = $m[1];
22314d99ec0SAndreas Gohr            $name = 'netscape';
22414d99ec0SAndreas Gohr        }
22514d99ec0SAndreas Gohr        # Netscape 3.x, 4.x ... ?
22614d99ec0SAndreas Gohr        elseif(preg_match($regvermozilla,$ua,$m) && !preg_match($regnotnetscape,$ua)){
22714d99ec0SAndreas Gohr            $type = 'browser';
22814d99ec0SAndreas Gohr            $ver  = $m[2];
22914d99ec0SAndreas Gohr            $name = 'netscape';
23014d99ec0SAndreas Gohr        }else{
23114d99ec0SAndreas Gohr            include(dirname(__FILE__).'/inc/browsers.php');
23214d99ec0SAndreas Gohr            foreach($BrowsersSearchIDOrder as $regex){
23314d99ec0SAndreas Gohr                if(preg_match('/'.$regex.'/',$ua)){
23414d99ec0SAndreas Gohr                    // it's a browser!
23514d99ec0SAndreas Gohr                    $type = 'browser';
23614d99ec0SAndreas Gohr                    $name = strtolower($regex);
23714d99ec0SAndreas Gohr                    break;
23814d99ec0SAndreas Gohr                }
23914d99ec0SAndreas Gohr            }
24014d99ec0SAndreas Gohr        }
24114d99ec0SAndreas Gohr
24214d99ec0SAndreas Gohr        // check OS for browsers
24314d99ec0SAndreas Gohr        if($type == 'browser'){
24414d99ec0SAndreas Gohr            include(dirname(__FILE__).'/inc/operating_systems.php');
24514d99ec0SAndreas Gohr            foreach($OSSearchIDOrder as $regex){
24614d99ec0SAndreas Gohr                if(preg_match('/'.$regex.'/',$ua)){
24714d99ec0SAndreas Gohr                    $os = $OSHashID[$regex];
24814d99ec0SAndreas Gohr                    break;
24914d99ec0SAndreas Gohr                }
25014d99ec0SAndreas Gohr            }
25114d99ec0SAndreas Gohr
25214d99ec0SAndreas Gohr        }
25314d99ec0SAndreas Gohr
25414d99ec0SAndreas Gohr        // are we done now?
25514d99ec0SAndreas Gohr        if($name) return $name;
25614d99ec0SAndreas Gohr
25714d99ec0SAndreas Gohr        include(dirname(__FILE__).'/inc/robots.php');
25814d99ec0SAndreas Gohr        foreach($RobotsSearchIDOrder as $regex){
25914d99ec0SAndreas Gohr            if(preg_match('/'.$regex.'/',$ua)){
26014d99ec0SAndreas Gohr                    // it's a robot!
26114d99ec0SAndreas Gohr                    $type = 'robot';
26214d99ec0SAndreas Gohr                    return strtolower($regex);
26314d99ec0SAndreas Gohr            }
26414d99ec0SAndreas Gohr        }
26514d99ec0SAndreas Gohr
26614d99ec0SAndreas Gohr        // dunno
2671878f16fSAndreas Gohr        return '';
2681878f16fSAndreas Gohr    }
2691878f16fSAndreas Gohr
2701878f16fSAndreas Gohr    /**
27114d99ec0SAndreas Gohr     *
27214d99ec0SAndreas Gohr     * @fixme: put search engine queries in seperate table here
27314d99ec0SAndreas Gohr     */
27414d99ec0SAndreas Gohr    function log_search($referer,&$type){
27514d99ec0SAndreas Gohr        $referer = strtr($referer,' +','__');
27614d99ec0SAndreas Gohr        $referer = strtolower($referer);
27714d99ec0SAndreas Gohr
27814d99ec0SAndreas Gohr        include(dirname(__FILE__).'/inc/search_engines.php');
27914d99ec0SAndreas Gohr
28014d99ec0SAndreas Gohr        foreach($SearchEnginesSearchIDOrder as $regex){
28114d99ec0SAndreas Gohr            if(preg_match('/'.$regex.'/',$referer)){
28214d99ec0SAndreas Gohr                if(!$NotSearchEnginesKeys[$regex] ||
28314d99ec0SAndreas Gohr                   !preg_match('/'.$NotSearchEnginesKeys[$regex].'/',$referer)){
28414d99ec0SAndreas Gohr                    // it's a search engine!
28514d99ec0SAndreas Gohr                    $type = 'search';
28614d99ec0SAndreas Gohr                    break;
28714d99ec0SAndreas Gohr                }
28814d99ec0SAndreas Gohr            }
28914d99ec0SAndreas Gohr        }
29014d99ec0SAndreas Gohr        if($type != 'search') return; // we're done here
29114d99ec0SAndreas Gohr
29214d99ec0SAndreas Gohr        #fixme now do the keyword magic!
29314d99ec0SAndreas Gohr    }
29414d99ec0SAndreas Gohr
29514d99ec0SAndreas Gohr    /**
29614d99ec0SAndreas Gohr     * Resolve IP to country/city
29714d99ec0SAndreas Gohr     */
29814d99ec0SAndreas Gohr    function log_ip($ip){
29914d99ec0SAndreas Gohr        // check if IP already known and up-to-date
30014d99ec0SAndreas Gohr        $sql = "SELECT ip
30114d99ec0SAndreas Gohr                  FROM ".$this->getConf('db_prefix')."iplocation
30214d99ec0SAndreas Gohr                 WHERE ip ='".addslashes($ip)."'
30314d99ec0SAndreas Gohr                   AND lastupd > DATE_SUB(CURDATE(),INTERVAL 30 DAY)";
30414d99ec0SAndreas Gohr        $result = $this->runSQL($sql);
30514d99ec0SAndreas Gohr        if($result[0]['ip']) return;
30614d99ec0SAndreas Gohr
30714d99ec0SAndreas Gohr        $http = new DokuHTTPClient();
30814d99ec0SAndreas Gohr        $http->timeout = 10;
30914d99ec0SAndreas Gohr        $data = $http->get('http://api.hostip.info/get_html.php?ip='.$ip);
31014d99ec0SAndreas Gohr
31114d99ec0SAndreas Gohr        if(preg_match('/^Country: (.*?) \((.*?)\)\nCity: (.*?)$/s',$data,$match)){
31214d99ec0SAndreas Gohr            $country = addslashes(trim($match[1]));
31314d99ec0SAndreas Gohr            $code    = addslashes(strtolower(trim($match[2])));
31414d99ec0SAndreas Gohr            $city    = addslashes(trim($match[3]));
31514d99ec0SAndreas Gohr            $host    = addslashes(gethostbyaddr($ip));
31614d99ec0SAndreas Gohr            $ip      = addslashes($ip);
31714d99ec0SAndreas Gohr
31814d99ec0SAndreas Gohr            $sql = "REPLACE INTO ".$this->getConf('db_prefix')."iplocation
31914d99ec0SAndreas Gohr                        SET ip = '$ip',
32014d99ec0SAndreas Gohr                            country = '$country',
32114d99ec0SAndreas Gohr                            code    = '$code',
32214d99ec0SAndreas Gohr                            city    = '$city',
32314d99ec0SAndreas Gohr                            host    = '$host'";
32414d99ec0SAndreas Gohr            $this->runSQL($sql);
32514d99ec0SAndreas Gohr        }
32614d99ec0SAndreas Gohr    }
32714d99ec0SAndreas Gohr
32814d99ec0SAndreas Gohr    /**
3291878f16fSAndreas Gohr     * log a page access
3301878f16fSAndreas Gohr     *
3311878f16fSAndreas Gohr     * called from log.php
3321878f16fSAndreas Gohr     */
3331878f16fSAndreas Gohr    function log_access(){
33494171ff3SAndreas Gohr        if(!$_REQUEST['p']) return;
33594171ff3SAndreas Gohr
33614d99ec0SAndreas Gohr        # FIXME check referer against blacklist and drop logging for bad boys
33714d99ec0SAndreas Gohr
33814d99ec0SAndreas Gohr        // handle referer
33914d99ec0SAndreas Gohr        $referer = trim($_REQUEST['r']);
34014d99ec0SAndreas Gohr        if($referer){
34114d99ec0SAndreas Gohr            $ref     = addslashes($referer);
34214d99ec0SAndreas Gohr            $ref_md5 = ($ref) ? md5($referer) : '';
34314d99ec0SAndreas Gohr            if(strpos($referer,DOKU_URL) === 0){
34414d99ec0SAndreas Gohr                $ref_type = 'internal';
34514d99ec0SAndreas Gohr            }else{
34614d99ec0SAndreas Gohr                $ref_type = 'external';
34714d99ec0SAndreas Gohr                $this->log_search($referer,$ref_type);
34814d99ec0SAndreas Gohr            }
34914d99ec0SAndreas Gohr        }else{
35014d99ec0SAndreas Gohr            $ref      = '';
35114d99ec0SAndreas Gohr            $ref_md5  = '';
35214d99ec0SAndreas Gohr            $ref_type = '';
35314d99ec0SAndreas Gohr        }
35414d99ec0SAndreas Gohr
35514d99ec0SAndreas Gohr        // handle user agent
35614d99ec0SAndreas Gohr        $agent   = trim($_SERVER['HTTP_USER_AGENT']);
35714d99ec0SAndreas Gohr
35814d99ec0SAndreas Gohr        $ua      = addslashes($agent);
35914d99ec0SAndreas Gohr        $ua_type = '';
36014d99ec0SAndreas Gohr        $ua_ver  = '';
36114d99ec0SAndreas Gohr        $os      = '';
36214d99ec0SAndreas Gohr        $ua_info = addslashes($this->ua_info($agent,$ua_type,$ua_ver,$os));
36314d99ec0SAndreas Gohr
3641878f16fSAndreas Gohr        $page    = addslashes($_REQUEST['p']);
3651878f16fSAndreas Gohr        $ip      = addslashes($_SERVER['REMOTE_ADDR']);
3661878f16fSAndreas Gohr        $sx      = (int) $_REQUEST['sx'];
3671878f16fSAndreas Gohr        $sy      = (int) $_REQUEST['sy'];
3681878f16fSAndreas Gohr        $vx      = (int) $_REQUEST['vx'];
3691878f16fSAndreas Gohr        $vy      = (int) $_REQUEST['vy'];
3701878f16fSAndreas Gohr        $user    = addslashes($_SERVER['REMOTE_USER']);
3711878f16fSAndreas Gohr        $session = addslashes(session_id());
3721878f16fSAndreas Gohr
37394171ff3SAndreas Gohr        $sql  = "INSERT DELAYED INTO ".$this->getConf('db_prefix')."access
3741878f16fSAndreas Gohr                    SET page     = '$page',
3751878f16fSAndreas Gohr                        ip       = '$ip',
3761878f16fSAndreas Gohr                        ua       = '$ua',
3771878f16fSAndreas Gohr                        ua_info  = '$ua_info',
37814d99ec0SAndreas Gohr                        ua_type  = '$ua_type',
37914d99ec0SAndreas Gohr                        ua_ver   = '$ua_ver',
38014d99ec0SAndreas Gohr                        os       = '$os',
3811878f16fSAndreas Gohr                        ref      = '$ref',
38294171ff3SAndreas Gohr                        ref_md5  = '$ref_md5',
38314d99ec0SAndreas Gohr                        ref_type = '$ref_type',
3841878f16fSAndreas Gohr                        screen_x = '$sx',
3851878f16fSAndreas Gohr                        screen_y = '$sy',
3861878f16fSAndreas Gohr                        view_x   = '$vx',
3871878f16fSAndreas Gohr                        view_y   = '$vy',
3881878f16fSAndreas Gohr                        user     = '$user',
3891878f16fSAndreas Gohr                        session  = '$session'";
3901878f16fSAndreas Gohr        $ok = $this->runSQL($sql);
3911878f16fSAndreas Gohr        if(is_null($ok)){
3921878f16fSAndreas Gohr            global $MSG;
3931878f16fSAndreas Gohr            print_r($MSG);
3941878f16fSAndreas Gohr        }
39514d99ec0SAndreas Gohr
39614d99ec0SAndreas Gohr        // resolve the IP
39714d99ec0SAndreas Gohr        $this->log_ip($_SERVER['REMOTE_ADDR']);
3981878f16fSAndreas Gohr    }
3991878f16fSAndreas Gohr
4001878f16fSAndreas Gohr    /**
4011878f16fSAndreas Gohr     * Just send a 1x1 pixel blank gif to the browser
4021878f16fSAndreas Gohr     *
4031878f16fSAndreas Gohr     * @called from log.php
4041878f16fSAndreas Gohr     *
4051878f16fSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
4061878f16fSAndreas Gohr     * @author Harry Fuecks <fuecks@gmail.com>
4071878f16fSAndreas Gohr     */
4081878f16fSAndreas Gohr    function sendGIF(){
4091878f16fSAndreas Gohr        $img = base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7');
4101878f16fSAndreas Gohr        header('Content-Type: image/gif');
4111878f16fSAndreas Gohr        header('Content-Length: '.strlen($img));
4121878f16fSAndreas Gohr        header('Connection: Close');
4131878f16fSAndreas Gohr        print $img;
4141878f16fSAndreas Gohr        flush();
4151878f16fSAndreas Gohr        // Browser should drop connection after this
4161878f16fSAndreas Gohr        // Thinks it's got the whole image
4171878f16fSAndreas Gohr    }
4181878f16fSAndreas Gohr
4191878f16fSAndreas Gohr}
420