Changeset 141

Show
Ignore:
Timestamp:
06/12/08 09:04:03 (5 months ago)
Author:
root
Message:

testing major release 1.6

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/main.php

    r129 r141  
    286286        function check_os($useragent) { 
    287287 
    288                         $os = "N/A"; $version = "N/A"; 
     288                        $os = "N/A"; $version = ""; 
    289289 
    290290                        if (preg_match("/Windows NT 5.1/",$useragent,$match)) { 
    291                                 $os = "Windows"; $version = "XP"; 
     291                                $os = "WinXP"; $version = ""; 
    292292                        } elseif (preg_match("/Windows NT 5.2/",$useragent,$match)) { 
    293                                 $os = "Windows"; $version = "Server 2003"; 
     293                                $os = "Win2003"; $version = ""; 
    294294                        } elseif (preg_match("/Windows NT 6.0/",$useragent,$match)) { 
    295                                 $os = "Windows"; $version = "Vista"; 
     295                                $os = "WinVista"; $version = ""; 
    296296                        } elseif (preg_match("/(?:Windows NT 5.0|Windows 2000)/",$useragent,$match)) { 
    297                                 $os = "Windows"; $version = "2000"; 
     297                                $os = "Win2000"; $version = ""; 
    298298                        } elseif (preg_match("/Windows ME/",$useragent,$match)) { 
    299                                 $os = "Windows"; $version = "ME"; 
     299                                $os = "WinME"; $version = ""; 
    300300                        } elseif (preg_match("/(?:WinNT|Windows\s?NT)\s?([0-9\.]+)?/",$useragent,$match)) { 
    301                                 $os = "Windows"; $version = "NT ".$match[1]; 
     301                                $os = "WinNT"; $version = $match[1]; 
    302302                        } elseif (preg_match("/Mac OS X/",$useragent,$match)) { 
    303                                 $os = "Mac OS"; $version = "X"; 
     303                                $os = "MacOSX"; $version = ""; 
    304304                        } elseif (preg_match("/(Mac_PowerPC|Macintosh)/",$useragent,$match)) { 
    305                                 $os = "Mac OS"; $version = ""; 
     305                                $os = "MacPPC"; $version = ""; 
    306306                        } elseif (preg_match("/(?:Windows95|Windows 95|Win95|Win 95)/",$useragent,$match)) { 
    307                                 $os = "Windows"; $version = "95"; 
     307                                $os = "Win95"; $version = ""; 
    308308                        } elseif (preg_match("/(?:Windows98|Windows 98|Win98|Win 98|Win 9x)/",$useragent,$match)) { 
    309                                 $os = "Windows"; $version = "98"; 
     309                                $os = "Win98"; $version = ""; 
    310310                        } elseif (preg_match("/(?:WindowsCE|Windows CE|WinCE|Win CE)/",$useragent,$match)) { 
    311                                 $os = "Windows"; $version = "CE"; 
     311                                $os = "WinCE"; $version = ""; 
    312312                        } elseif (preg_match("/PalmOS/",$useragent,$match)) { 
    313313                                $os = "PalmOS"; 
     
    342342                function check_browser($useragent) { 
    343343 
    344                         $browser = "N/A"; 
     344                        $browser = ""; 
    345345 
    346346                        if (preg_match("/^Mozilla(?:.*)compatible;\sMSIE\s(?:.*)Opera\s([0-9\.]+)/",$useragent,$match)) { 
     
    353353                                $browser = "iCab"; 
    354354                        } elseif (preg_match("/^Mozilla(?:.*)compatible;\sMSIE\s([0-9\.]+)/",$useragent,$match)) { 
    355                                 $browser = "MSIE"; 
     355                                $browser = "IE"; 
    356356                        } elseif (preg_match("/^(?:.*)compatible;\sMSIE\s([0-9\.]+)/",$useragent,$match)) { 
    357                                 $browser = "MSIE"; 
     357                                $browser = "IE"; 
    358358                        } elseif (preg_match("/^Mozilla(?:.*)(?:.*)Safari/",$useragent,$match)) { 
    359359                                $browser = "Safari"; 
     
    366366                        } elseif (preg_match("/^Mozilla(?:.*)\(compatible;\sOmniWeb\/([0-9\.v-]+)/",$useragent,$match)) { 
    367367                                $browser = "Omniweb"; 
     368                        } elseif (preg_match("/^Mozilla(?:.*)Gecko(?:.*?)(?:Camino|Chimera)\/([0-9\.]+)/",$useragent,$match)) { 
     369                                $browser = "Camino"; 
    368370                        } elseif (preg_match("/^Mozilla(?:.*)Gecko(?:.*?)Netscape\/([0-9\.]+)/",$useragent,$match)) { 
    369371                                $browser = "Netscape"; 
    370372                        } elseif (preg_match("/^Mozilla(?:.*)Gecko(?:.*?)(?:Fire(?:fox|bird)|Phoenix)\/([0-9\.]+)/",$useragent,$match)) { 
    371                                 $browser = "Mozilla Firefox"; 
     373                                $browser = "Firefox"; 
    372374                        } elseif (preg_match("/^Mozilla(?:.*)Gecko(?:.*?)Minefield\/([0-9\.]+)/",$useragent,$match)) { 
    373375                                $browser = "Minefield"; 
     
    378380                        } elseif (preg_match("/^Mozilla(?:.*)Gecko(?:.*?)K-Meleon\/([0-9\.]+)/",$useragent,$match)) { 
    379381                                $browser = "K-Meleon"; 
    380                         } elseif (preg_match("/^Mozilla(?:.*)Gecko(?:.*?)(?:Camino|Chimera)\/([0-9\.]+)/",$useragent,$match)) { 
    381                                 $browser = "Camino"; 
    382382                        } elseif (preg_match("/^Mozilla(?:.*)rv:([0-9\.]+)\)\sGecko/",$useragent,$match)) { 
    383383                                $browser = "Mozilla"; 
     
    422422                        } 
    423423 
    424                         $version = $match[1]; 
     424                        //$version = $match[1]; 
     425                        //restrict version to major and minor version #'s 
     426                        preg_match("/^\d+(\.\d+)?/",$match[1],$majorvers); 
     427                        $version = $majorvers[0]; 
    425428 
    426429                        $this->browser = $browser; 
  • trunk/readme.txt

    r139 r141  
    55Requires at least: 2.2 
    66Tested up to: 2.5 - 2.3.2 - 2.3.1 - 2.3 - 2.2 
    7 Stable tag: 1.5.2 
     7Stable tag: 1.6 
    88 
    99Wordpress plugin to analyze your visitors traffic with real time stats, chart and a lot of chronological informations. It has sidebar Widget support to show current online visitors and other statistics. 
  • trunk/wassup.php

    r140 r141  
    44Plugin URI: http://www.wpwp.org 
    55Description: Wordpress plugin to analyze your visitors traffic with real time stats, chart and a lot of chronological informations. It has sidebar Widget support to show current online visitors and other statistics. 
    6 Version: 1.5.2 
     6Version: 1.6 
    77Author: Michele Marcucci 
    88Author URI: http://www.michelem.org/ 
     
    1717        die('Permission Denied! You are not allowed to call this page directly.'); 
    1818} 
    19 $version = "1.5.2"; 
     19$version = "1.6"; 
    2020define('WASSUPFOLDER', dirname(plugin_basename(__FILE__)), TRUE); 
    2121require_once(dirname(__FILE__).'/lib/wassup.class.php'); 
     
    165165//#   -Load jquery AJAX library and dependent javascripts for admin menus 
    166166//#   -Load language/localization files for admin menus and widget 
    167 //#   -Set 'wassup' ## General hooks 
     167//#   -Set 'wassup' cookie for new visitor hits 
    168168function wassup_init() { 
    169169        global $wpurl; 
     
    550550                $to_date = wassup_get_time(); 
    551551                $from_date = strtotime('-3 minutes', $to_date); 
    552                 $currenttot = $wpdb->get_var("SELECT COUNT(DISTINCT wassup_id) as currenttot FROM $table_tmp_name WHERE timestamp BETWEEN $from_date AND $to_date"); 
     552                $currenttot = $wpdb->get_var("SELECT COUNT(DISTINCT wassup_id) as currenttot FROM $table_tmp_name WHERE `timestamp` BETWEEN $from_date AND $to_date"); 
    553553                $currenttot = $currenttot+0;    //set to integer 
    554554                print "<p class='legend'>".__("Visitors online", "wassup").": <strong>".$currenttot."</strong></p><br />"; 
    555555                if ($currenttot > 0) { 
    556                         $qryC = $wpdb->get_results("SELECT id, wassup_id, max(timestamp) as max_timestamp, ip, hostname, searchengine, urlrequested, agent, referrer, spider, username, comment_author FROM $table_tmp_name WHERE timestamp BETWEEN $from_date AND $to_date GROUP BY ip ORDER BY max_timestamp DESC"); 
     556                        $qryC = $wpdb->get_results("SELECT id, wassup_id, max(timestamp) as max_timestamp, ip, hostname, searchengine, urlrequested, agent, referrer, spider, username, comment_author FROM $table_tmp_name WHERE `timestamp` BETWEEN $from_date AND $to_date GROUP BY ip ORDER BY max_timestamp DESC"); 
    557557                foreach ($qryC as $cv) { 
    558558                //$timestamp = $cv->max_timestamp;      //redundant 
    559559                $timed = gmdate("H:i:s", $cv->max_timestamp); 
    560                 $ip = @explode(",", $cv->ip); 
     560                $ip_proxy = strpos($cv->ip,","); 
     561                //if proxy, get 2nd ip... 
     562                if ($ip_proxy !== false) { 
     563                        $ip = substr($cv->ip,(int)$ip_proxy+1); 
     564                } else {  
     565                        $ip = $cv->ip; 
     566                } 
    561567                if ($cv->referrer != '') { 
    562568                        if (!eregi($wpurl, $cv->referrer) OR $cv->searchengine != "") {  
     
    575581        ?> 
    576582                        <div class="sum"> 
    577                         <span class="sum-box"><?php if ($numurl >= 2) { ?><a  href="#" class="showhide" id="<?php echo $cv->id ?>"><?php print $ip[0]; ?></a><?php } else { ?><?php print $ip[0]; ?><?php } ?></span> 
     583                        <span class="sum-box"><?php if ($numurl >= 2) { ?><a  href="#" class="showhide" id="<?php echo $cv->id ?>"><?php print $ip; ?></a><?php } else { ?><?php print $ip; ?><?php } ?></span> 
    578584                        <div class="sum-det"><span class="det1"> 
    579585                        <?php 
     
    604610                        <ul class="url"> 
    605611        <?php  
    606                         $qryCD = $wpdb->get_results("SELECT timestamp, urlrequested FROM $table_tmp_name WHERE wassup_id='".$cv->wassup_id."' ORDER BY timestamp ASC"); 
     612                        $qryCD = $wpdb->get_results("SELECT `timestamp`, urlrequested FROM $table_tmp_name WHERE wassup_id='".$cv->wassup_id."' ORDER BY `timestamp` ASC"); 
    607613                        $i=0; 
    608614                        foreach ($qryCD as $cd) {        
     
    758764                //#   -Helene D. 3/4/08. 
    759765                if (!empty($_GET['deleteMARKED']) && $wassup_options->wmark == "1" ) { 
    760                         $rec_deleted = $wpdb->get_var("SELECT COUNT(ip) as deleted FROM $table_name WHERE ip='".urlencode(attribute_escape($_GET['dip']))."' AND timestamp BETWEEN $from_date AND $to_date"); 
     766                        $rec_deleted = $wpdb->get_var("SELECT COUNT(ip) as deleted FROM $table_name WHERE ip='".urlencode(attribute_escape($_GET['dip']))."' AND `timestamp` BETWEEN $from_date AND $to_date"); 
    761767                        if (method_exists($wpdb,'prepare')) { 
    762                                 $wpdb->query($wpdb->prepare("DELETE FROM $table_name WHERE ip='%s' AND timestamp BETWEEN %s AND %s", urlencode(attribute_escape($_GET['dip'])), $from_date, $to_date)); 
     768                                $wpdb->query($wpdb->prepare("DELETE FROM $table_name WHERE ip='%s' AND `timestamp` BETWEEN %s AND %s", urlencode(attribute_escape($_GET['dip'])), $from_date, $to_date)); 
    763769                        } else { 
    764                                 $wpdb->query("DELETE FROM $table_name WHERE ip='".urlencode(attribute_escape($_GET['dip']))."' AND timestamp BETWEEN $from_date AND $to_date"); 
     770                                $wpdb->query("DELETE FROM $table_name WHERE ip='".urlencode(attribute_escape($_GET['dip']))."' AND `timestamp` BETWEEN $from_date AND $to_date"); 
    765771                        } 
    766772                        echo '<p><strong>'.$rec_deleted.' '.__('records deleted','wassup').'</strong></p>'; 
     
    936942                $timeF = gmdate("H:i:s", $timestampF); 
    937943                $datetimeF = gmdate('Y-m-d H:i:s', $timestampF); 
    938                 $ip = @explode(",", $rk->ip); 
    939  
    940                 // Visitor Record - raw data (hidden) ?> 
    941                 <div id="raw-<?php echo $rk->wassup_id; ?>" style="display:none; padding-top:7px;" > 
     944                //$ip = @explode(",", $rk->ip); 
     945                $ip_proxy = strpos($rk->ip,","); 
     946                //if proxy, get 2nd ip... 
     947                if ($ip_proxy !== false) { 
     948                        $ip = substr($rk->ip,(int)$ip_proxy+1); 
     949                } else {  
     950                        $ip = $rk->ip; 
     951                } 
     952 
     953                // Visitor Record - raw data (hidden) 
     954                $raw_div="raw-".substr($rk->wassup_id,0,25).rand(0,99); 
     955                echo "\n"; ?> 
     956                <div id="<?php echo $raw_div; ?>" style="display:none; padding-top:7px;" > 
    942957                <h2><?php _e("Raw data","wassup"); ?>:</h2> 
    943958                <style type="text/css">.raw { color: #542; padding-left:5px; }</style> 
    944959                <ul style="list-style-type:none;padding:20px 0 0 30px;"> 
     960                <li><?php echo __("Visit type","wassup").': <span class="raw">'; 
     961                if ($rk->username != "") {  
     962                        echo __("Logged-in user","wassup").' - '.$rk->username; 
     963                } elseif ($rk->spam == "1" || $rk->spam == "2" ) {  
     964                        _e("Spammer","wassup"); 
     965                } elseif ($rk->comment_author != "") {  
     966                        echo __("Comment author","wassup").' - '.$rk->comment_author; 
     967                } elseif ($rk->feed != "") {  
     968                        echo __("Feed","wassup").' - '.$rk->feed; 
     969                } elseif ($rk->spider != "") {  
     970                        echo __("Spider","wassup").' - '.$rk->spider; 
     971                } else { 
     972                         _e("Regular visitor","wassup"); 
     973                } 
     974                echo '</span>'; ?></li> 
    945975                <li><?php echo __("IP","wassup").': <span class="raw">'.$rk->ip.'</span>'; ?></li> 
    946976                <li><?php echo __("Hostname","wassup").': <span class="raw">'.$rk->hostname.'</span>'; ?></li> 
     977                <li><?php echo __("Url Requested","wassup").': <span class="raw">'.htmlspecialchars(html_entity_decode(clean_url($rk->urlrequested))).'</span>'; ?></li> 
    947978                <li><?php echo __("User Agent","wassup").': <span class="raw">'.$rk->agent.'</span>'; ?></li> 
    948979                <li><?php echo __("Referrer","wassup").': <span class="raw">'.urldecode($rk->referrer).'</span>'; ?></li> 
    949980                <?php if ($rk->search != "") { ?> 
    950                 <li><?php echo __("Search","wassup").': <span class="raw">'.$rk->search.'</span>'; ?></li> 
     981                <li><?php echo __("Search Engine","wassup").': <span class="raw">'.$rk->searchengine.'</span> &nbsp; &nbsp; '; 
     982                echo __("Search","wassup").': <span class="raw">'.$rk->search.'</span>'; ?></li> 
    951983                <?php } 
    952984                if ($rk->os != "") { ?> 
     
    957989                <?php } 
    958990                if ($rk->language != "") { ?> 
    959                 <li><?php echo __("Language","wassup").': <span class="raw">'.$rk->language.'</span>'; ?></li> 
     991                <li><?php echo __("Locale/Language","wassup").': <span class="raw">'.$rk->language.'</span>'; ?></li> 
    960992                <?php } ?> 
    961                 <li><?php echo __("Url Requested","wassup").': <span class="raw">'.htmlspecialchars(html_entity_decode(clean_url($rk->urlrequested))).'</span>'; ?></li> 
    962                 <li><?php echo __("End Timestamp","wassup").': <span class="raw">'.$datetimeF.' ( '.$rk->max_timestamp.' )</span>'; ?></li> 
     993                <li><?php echo 'Wassup ID'.': <span class="raw">'.$rk->wassup_id.'</span>'; ?></li> 
     994                <li><?php echo __("End timestamp","wassup").': <span class="raw">'.$datetimeF.' ( '.$rk->max_timestamp.' )</span>'; ?></li> 
    963995                </ul> 
    964996                </div> <!-- raw-wassup_id --> 
     
    9831015 
    9841016                <div class="delID<?php echo $rk->wassup_id ?>"> 
    985                 <div class="<?php if ($wassup_options->wmark == 1 AND $wassup_options->wip == $ip[0]) echo "sum-nav-mark"; else echo "sum-nav"; ?>"> 
     1017                <div class="<?php if ($wassup_options->wmark == 1 AND $wassup_options->wip == $ip) echo "sum-nav-mark"; else echo "sum-nav"; ?>"> 
    9861018 
    9871019                <p class="delbut"> 
    9881020                <?php // Mark/Unmark IP 
    989                 if ($wassup_options->wmark == 1 AND $wassup_options->wip ==  $ip[0]) { ?> 
    990                         <a  href="?<?php echo $_SERVER['QUERY_STRING']; ?>&deleteMARKED=1&dip=<?php print $ip[0]; ?>" style="text-decoration:none;"> 
     1021                if ($wassup_options->wmark == 1 AND $wassup_options->wip ==  $ip) { ?> 
     1022                        <a  href="?<?php echo $_SERVER['QUERY_STRING']; ?>&deleteMARKED=1&dip=<?php print $ip; ?>" style="text-decoration:none;"> 
    9911023                        <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/cross.png" alt="'.__('delete','wassup').'" title="'.__('Delete ALL marked records with this IP','wassup'); ?>" /></a> 
    9921024                        <a href="?page=<?php echo WASSUPFOLDER; ?>&wmark=0" style="text-decoration:none;"> 
     
    9951027                        <a  href="#" class="deleteID" id="<?php echo $rk->wassup_id ?>" style="text-decoration:none;"> 
    9961028                        <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/cross.png" alt="'.__('delete','wassup').'" title="'.__('Delete this record','wassup'); ?>" /></a> 
    997                         <a href="?<?php echo $_SERVER['QUERY_STRING']; ?>&wmark=1&wip=<?php print $ip[0]; ?>" style="text-decoration:none;"> 
     1029                        <a href="?<?php echo $_SERVER['QUERY_STRING']; ?>&wmark=1&wip=<?php print $ip; ?>" style="text-decoration:none;"> 
    9981030                        <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/error_add.png" alt="'.__('mark','wassup').'" title="'.__('Mark IP','wassup'); ?>" /></a> 
    9991031                <?php } ?> 
    1000                 <a href="#TB_inline?height=400&width=<?php echo $res.'&inlineId=raw-'.$rk->wassup_id; ?>" class="thickbox"> 
     1032                <a href="#TB_inline?height=400&width=<?php echo $res.'&inlineId='.$raw_div; ?>" class="thickbox"> 
    10011033                <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/database_table.png" alt="'.__('show raw table','wassup').'" title="'.__('Show the items as raw table','wassup'); ?>" /></a> 
    10021034                </p> 
    10031035 
    1004                         <span class="sum-box"><?php if ($numurl >= 2) { ?><a  href="#" class="showhide" id="<?php echo $rk->id ?>"><?php print $ip[0]; ?></a><?php } else { ?><?php print $ip[0]; ?><?php } ?></span> 
     1036                        <span class="sum-box"><?php if ($numurl >= 2) { ?><a  href="#" class="showhide" id="<?php echo $rk->id ?>"><?php print $ip; ?></a><?php } else { ?><?php print $ip; ?><?php } ?></span> 
    10051037                        <span class="sum-date"><?php print $datetimeF; ?></span> 
    10061038                        <div class="sum-det"><span class="det1"> 
     
    10591091                        <ul style="background:#fdeec8;" class="spider"> 
    10601092                                <li class="feed"><span class="indent-li-agent"><?php _e('FEEDREADER','wassup'); ?>: <strong><?php print $rk->spider; ?></strong></span></li> 
    1061                                 <li class="feed"><span class="indent-li-agent"><?php _e('SUBSCRIBER(S)','wassup'); ?>: <strong><?php print $rk->feed; ?></strong></span></li> 
     1093                                <?php if (is_numeric($rk->feed)) { ?> 
     1094                                <li class="feed"><span class="indent-li-agent"><?php _e('SUBSCRIBER(S)','wassup'); ?>: <strong><?php print (int)$rk->feed; ?></strong></span></li> 
     1095                                <?php  } ?> 
    10621096                        </ul> 
    10631097                        <?php  } else { ?> 
     
    10961130                        <ul class="url"> 
    10971131        <?php  
    1098                         $qryCD = $wpdb->get_results("SELECT timestamp, urlrequested FROM $table_name WHERE wassup_id='".$rk->wassup_id."' ORDER BY timestamp ASC"); 
     1132                        $qryCD = $wpdb->get_results("SELECT `timestamp`, urlrequested FROM $table_name WHERE wassup_id='".$rk->wassup_id."' ORDER BY `timestamp` ASC"); 
    10991133                        $i=0; 
    11001134                        foreach ($qryCD as $cd) {        
     
    12421276                $ipAddress = ""; 
    12431277                $hostname = ""; 
    1244                 //#### Get the host/IP details from http header... 
     1278                //#### Get the visitor's details from http header... 
    12451279                if (isset($_SERVER["REMOTE_ADDR"])) { 
    12461280                if ($_SERVER["HTTP_X_FORWARDED_FOR"] != ""){ 
    1247                         $IP = $_SERVER["HTTP_X_FORWARDED_FOR"]; 
     1281                        //in case of multiple forwarding 
     1282                        list($IP) = explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]); 
    12481283                        $proxy = $_SERVER["REMOTE_ADDR"]; 
    1249                         $hostname = @gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]); 
     1284                        $hostname = @gethostbyaddr($IP); 
     1285                        if (empty($hostname) || $hostname == "unknown") { 
     1286                                $hostname = @gethostbyaddr($proxy); 
     1287                        } 
    12501288                        $ipAddress = $proxy.",".$IP; 
    12511289                }else{ 
    1252                         $IP = $_SERVER["REMOTE_ADDR"]; 
    1253                         $hostname = @gethostbyaddr($_SERVER["REMOTE_ADDR"]); 
    1254                         $ipAddress = $IP; 
     1290                        list($IP) = explode(",",$_SERVER["REMOTE_ADDR"]); 
     1291                        $hostname = @gethostbyaddr($IP); 
     1292                        $ipAddress = $_SERVER["REMOTE_ADDR"]; 
    12551293                }  
    12561294                } 
     1295                if (empty($IP)) { $IP = $ipAddress; } 
     1296                if (empty($hostname)) { $hostname = "unknown"; } 
    12571297                $userAgent = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''); 
    12581298                //# Create a new wassup id for this visit from a  
     
    12611301                //#  same ip/userAgent within a 30 minute-period, can be  
    12621302                //#  tracked, even when session/cookies is disabled.  
    1263                 $temp_id = sprintf("%-064.64s", date('YmdH').str_replace(array('','/','.','\'','"',"\\",'$','-','&','+','_',';',',','>','<',':','#','*','%','http',')','(',), '', intval(date('i')/30).$ipAddress.strrev($userAgent).strrev($hostname).intval(date('i')/30)).date('HdmY').rand()); 
     1303                $temp_id = sprintf("%-060.60s", date('YmdH').str_replace(array(' ','http://','www.','/','.','\'','"',"\\",'$','-','&','+','_',';',',','>','<',':','#','*','%','!','@',')','(',), '', intval(date('i')/30).$IP.strrev($userAgent).strrev($hostname).intval(date('i')/30)).date('HdmY').$hostname.rand()); 
    12641304 
    12651305                //Work-around for cookie rejection: 
     
    12931333        if (isset($_SERVER["REMOTE_ADDR"])) { 
    12941334                if ($_SERVER["HTTP_X_FORWARDED_FOR"] != ""){ 
    1295                         $IP = $_SERVER["HTTP_X_FORWARDED_FOR"]; 
     1335                        //in case of multiple forwarding 
     1336                        list($IP) = explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]); 
    12961337                        $proxy = $_SERVER["REMOTE_ADDR"]; 
    1297                         $hostname = @gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]); 
     1338                        $hostname = @gethostbyaddr($IP); 
     1339                        if (empty($hostname) || $hostname == "unknown") { 
     1340                                $hostname = @gethostbyaddr($proxy); 
     1341                        } 
    12981342                        $ipAddress = $proxy.",".$IP; 
    12991343                }else{ 
    1300                         $IP = $_SERVER["REMOTE_ADDR"]; 
    1301                         $hostname = @gethostbyaddr($_SERVER["REMOTE_ADDR"]); 
    1302                         $ipAddress = $IP; 
     1344                        list($IP) = explode(",",$_SERVER["REMOTE_ADDR"]); 
     1345                        $hostname = @gethostbyaddr($IP); 
     1346                        $ipAddress = $_SERVER["REMOTE_ADDR"]; 
    13031347                }  
    13041348        } 
     1349        if (empty($IP)) { $IP = $ipAddress; } 
     1350        if (empty($hostname)) { $hostname = "unknown"; } 
     1351 
    13051352        // Get the visitor's resolution, TODO 
    13061353        /* 
     
    13681415        if ($wassup_options->wassup_loggedin == 1 || !is_user_logged_in() ) { 
    13691416        if ($wassup_options->wassup_attack == 1 || stristr($userAgent,"libwww-perl") === FALSE ) { 
     1417        if (!is_404()) {        //don't record 404 pages... 
    13701418 
    13711419                //##### Extract useful visit information from http header.. 
    1372                 $dip = &new Detector("", $userAgent); 
    1373                 $browser =  $dip->browser." ".$dip->browser_version; 
    1374                 $os = $dip->os." ".$dip->os_version; 
     1420                $browser = ""; 
     1421                $os = ""; 
     1422                list($browser,$os) = wGetBrowser($userAgent); 
    13751423 
    13761424        //#=================================================== 
     
    13831431        //#  such, even when session/cookies is disabled.  
    13841432        //# An md5 encoded version of temp_id is saved as "wassup_id". 
    1385         $temp_id = sprintf("%-064.64s", date('YmdH').str_replace(array('','/','.','\'','"',"\\",'$','-','&','+','_',';',',','>','<',':','#','*','%','http',')','(',), '', intval(date('i')/30).$ipAddress.strrev($userAgent).strrev($hostname).intval(date('i')/30)).date('HdmY').rand()); 
     1433        $temp_id = sprintf("%-060.60s", date('YmdH').str_replace(array(' ','http://','www.','/','.','\'','"',"\\",'$','-','&','+','_',';',',','>','<',':','#','*','%','!','@',')','(',), '', intval(date('i')/30).$IP.strrev($userAgent).strrev($hostname).intval(date('i')/30)).date('HdmY').$hostname.rand()); 
    13861434        $wassup_id = ""; 
    13871435        //Read the cookie for wassup_id 
     
    14941542        if ($dup_urlrequest == 0) { 
    14951543                //##### Extract useful visit information from http header.. 
    1496                 if ($os != "" OR $browser != "") {  
    1497                         $bot=wGetSpider($userAgent); 
    1498                         if (is_array($bot)) { 
    1499                                 $spider = $bot[0]; 
    1500                                 $feed = $bot[1]; 
    1501                         } else { 
    1502                                 $spider = trim($bot); 
    1503                         } 
    1504                 } 
     1544                if (empty($browser) || stristr($browser,"N/A")) { 
     1545                        list($spider,$feed) = wGetSpider($userAgent,$hostname); 
     1546                } 
     1547                 
    15051548                //#I prefer to see os/browser info. for spiders/bots. 
    1506                 //if ($spider != '') { $os=''; $browser=''; } 
    15071549 
    15081550        //spider exclusion control 
     
    15591601        } 
    15601602        if ( $wassup_options->wassup_spam == 1 && $spam == 0 ) { 
    1561                 //# some useragents to exclude from spam checking... 
    1562                 $goodbots = array('Google','Yahoo!','MSN','SummizeFeedReader'); 
     1603                //# some valid spiders to exclude from spam checking 
     1604                $goodbot = false; 
     1605                if ($hostname!="" && !empty($spider)) { 
     1606                        if (preg_match('/^(googlebot|msnbot|yahoo\!\ slurp|technorati)/i',$spider)>0 && preg_match('/(googlebot|live|msn|yahoo|technorati)\.(com|net)$/i',$hostname)>0){ 
     1607                                $goodbot = true; 
     1608                        } 
     1609                } 
    15631610 
    15641611                //# No duplicate spam testing in same session unless there  
     
    15691616                //# No spam check on known bots (google, yahoo,...) unless 
    15701617                //#  there is a comment or forum page request... 
    1571                 } elseif (empty($spider) || array_search($spider,$goodbots) === FALSE || stristr($urlRequested,"comment") !== FALSE || stristr($urlRequested,"forum") !== FALSE  || !empty($comment_user) ) {  
     1618                } elseif (empty($spider) || !$goodbot || stristr($urlRequested,"comment") !== FALSE || stristr($urlRequested,"forum") !== FALSE  || !empty($comment_user) ) {  
    15721619 
    15731620                   // Try to search for previous spammer detected by akismet with same IP 
     
    16541701                $recorded = true; 
    16551702                // Delete records older then 3 minutes 
    1656                 $wpdb->query("DELETE FROM $table_tmp_name WHERE timestamp<'".strtotime("-3 minutes", $timestamp)."'"); 
     1703                $wpdb->query("DELETE FROM $table_tmp_name WHERE `timestamp`<'".strtotime("-3 minutes", $timestamp)."'"); 
    16571704 
    16581705        } //end if $spam == 0 
     
    16611708        } //end if dup_urlrequest == 0 
    16621709 
     1710        } //end if !is_404 
    16631711        } //end if wassup_attack 
    16641712        } //end if wassup_loggedin 
     
    16781726                $from_date = strtotime($wassup_options->delete_auto, $timestamp); 
    16791727                //#check before doing delete as it could lock the table... 
    1680                 if ((int)$wpdb->get_var("SELECT COUNT(id) FROM $table_name WHERE timestamp<'$from_date'") > 0) { 
    1681                         $wpdb->query("DELETE FROM $table_name WHERE timestamp<'$from_date'"); 
     1728                if ((int)$wpdb->get_var("SELECT COUNT(id) FROM $table_name WHERE `timestamp`<'$from_date'") > 0) { 
     1729                        $wpdb->query("DELETE FROM $table_name WHERE `timestamp`<'$from_date'"); 
    16821730                } 
    16831731                // Optimize table once a day 
     
    17261774 
    17271775                if (method_exists($wpdb,'prepare')) { 
    1728                         $insert = $wpdb->query( $wpdb->prepare("INSERT INTO $table_name (wassup_id, timestamp, ip, hostname, urlrequested, agent, referrer, search, searchpage, os, browser, language, screen_res, searchengine, spider, feed, username, comment_author, spam)  
     1776                        $insert = $wpdb->query( $wpdb->prepare("INSERT INTO $table_name (wassup_id, `timestamp`, ip, hostname, urlrequested, agent, referrer, search, searchpage, os, browser, language, screen_res, searchengine, spider, feed, username, comment_author, spam)  
    17291777                           VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )", 
    17301778                           attribute_escape($wassup_id), 
     
    17501798                } else { 
    17511799                        $insert = $wpdb->query("INSERT INTO " . $table_name . 
    1752                            " (wassup_id, timestamp, ip, hostname, urlrequested, agent, referrer, search, searchpage, os, browser, language, screen_res, searchengine, spider, feed, username, comment_author, spam) " . 
     1800                           " (wassup_id, `timestamp`, ip, hostname, urlrequested, agent, referrer, search, searchpage, os, browser, language, screen_res, searchengine, spider, feed, username, comment_author, spam) " . 
    17531801                           "VALUES ( 
    17541802                           '".attribute_escape($wassup_id)."', 
     
    19051953} 
    19061954 
    1907 function wGetSpider($agent = null){ 
     1955//extract browser and platform info from a user agent string and 
     1956// return the values