Plugin Directory

Changeset 444137


Ignore:
Timestamp:
09/27/2011 10:23:58 AM (14 years ago)
Author:
michelem
Message:

Release 1.8.3

Location:
wassup/trunk
Files:
8 added
16 edited

Legend:

Unmodified
Added
Removed
  • wassup/trunk/badhosts.txt

    r433606 r444137  
    738738himailer\.com
    739739himsearch\.com
    740 hinet\.net
     740\.sg[0-9]+\.myweb\.hinet\.net
    741741hitprofile\.com
    742742hj68\.com
  • wassup/trunk/css/wassup.css

    r433606 r444137  
    44 */
    55#wassup-wrap {
    6     padding: 1px 5px 3px;
    76    min-height: 500px;
    8     background-color: #efebef;
     7    padding: 1px 7px 3px;
     8    font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;
     9    font-size: 13px;
    910    border:1px solid #d6d7d6;
    10     -moz-border-radius: 10px 10px 0 0;
    11     -webkit-border-top-left-radius: 10px;
    12     -webkit-border-top-right-radius: 10px;
    13     -khtml-border-top-left-radius: 10px;
    14     -khtml-border-top-right-radius: 10px;
    15     border-top-right-radius: 10px;
    16     border-top-left-radius: 10px;
     11    background: #efebef ; */
     12    /* background: #efebef url("images/menu-shadow-rtl.png") left top repeat-y; */
     13    -moz-border-radius: 5px 5px 0 0;
     14    -webkit-border-top-left-radius: 5px;
     15    -webkit-border-top-right-radius: 5px;
     16    -khtml-border-top-left-radius: 5px;
     17    -khtml-border-top-right-radius: 5px;
     18    border-top-right-radius: 5px;
     19    border-top-left-radius: 5px;
    1720}
    1821#wassup-wrap table { border-collapse: collapse; padding: 2px; }
     
    2427#wassup-wrap img {
    2528    display: inline;
    26     vertical-align:bottom;
     29    vertical-align: middle;
    2730    margin: 0 2px 2px 0;
    2831    padding:0;
     
    3538#wassup-wrap td.legend a { border-bottom: 1px solid; }
    3639#wassup-wrap a:visited { color: #229; }
    37 #wassup-wrap a:hover { color: #d11; }
     40#wassup-wrap a:hover { color: #ff6d06; }
     41#wassup-wrap a:active { color: #d11; }
    3842.wassup-icon {}
    3943.wassup-content { min-height:225px; }
     
    4246.wassup-menu-link {
    4347    float: right;
    44     font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
     48    font-family: Arial,"Bitstream Vera Sans",Helvetica,Verdana,sans-serif;
     49    font-size: 12px;
    4550    height: 22px;
    4651    padding: 0;
     
    8691    height: 22px;
    8792    line-height: 22px;
    88     font-size: 10px;
    8993}
    9094#wassup-menu li.current a {
     
    110114}
    111115#wassup-menu li.current, #wassup-menu-link:active {
     116    height: 24px !important;
     117    margin-bottom: -2px !important;
    112118    color: #00284a;
    113119    background: url("images/link.png") no-repeat bottom center;
     
    133139    color: #445;
    134140    background-color: #dedade;
    135     box-shadow: 0 0 5px rgba(24, 24, 64, 0.9); /* 0 0 2px rgba(108,108,168, 0.8); */
    136     -moz-box-shadow: 0 0 5px rgba(24, 24, 64, 0.9);
    137     -webkit-box-shadow: 0 0 5px rgba(24, 24, 64, 0.9);
    138     border: 1px solid #c9d9e9; /* #a5a5bb; #efebef; */
    139     /* border-radius: 3px;
    140     -webkit-border-radius: 3px;
    141     -moz-border-radius: 3px; */
     141    -moz-box-shadow: 0 0 3px rgba(24, 24, 30, 0.9);
     142    -webkit-box-shadow: 0 0 3px rgba(24, 24, 30, 0.9);
     143    box-shadow: 0 0 3px rgba(24, 24, 30, 0.9);
     144    border: 1px solid #e9e9ee;
     145    -moz-border-radius: 3px 3px 0 0;
     146    -webkit-border-top-left-radius: 3px;
     147    -webkit-border-top-right-radius: 3px;
     148    -khtml-border-top-left-radius: 3px;
     149    -khtml-border-top-right-radius: 3px;
     150    border-top-right-radius: 3px;
     151    border-top-left-radius: 3px;
    142152}
    143153.main-tabs a, .main-tabs a:link {
     
    185195    background-color: #778;
    186196    border: 1px solid #fafeee;
    187     box-shadow: 0 0 2px rgba(50, 80, 80, 0.3);
    188197    -moz-box-shadow:0 0 2px rgba(50, 80, 80, 0.3);
    189198    -webkit-box-shadow:0 0 2px rgba(50, 80, 80, 0.3);
     199    box-shadow: 0 0 2px rgba(50, 80, 80, 0.3);
    190200}
    191201.pagination .disabled {
     
    216226    font-size: 11px;
    217227    background-color: #f4f6f6;
    218     border: 1px solid #c7c7cc; /* 89a; */
    219     border-bottom: 3px solid #347;
     228    border: 1px solid #ababca; /* 89a; */
     229    border-top: 1px solid #cdccdc; /* #c7c7cc; */
     230    /* border-bottom: 3px solid #347; */
    220231}
    221232.sum-nav, .sum-nav-mark, .sum-spy {
    222233    position: relative;
    223234    clear: left;
    224     width: 100%;
     235    /* width: 100%; */
    225236    min-height: 50px;
    226237    margin: 0 !important;
     
    228239    font-size: 11px;
    229240    border-top: 1px solid #fffcff;
    230     border-bottom: 1px solid #ddd;
     241    border-left: 1px solid #efefe0;
     242    border-right: 1px solid #efefe0;
     243    border-bottom: 0 none;
    231244        background: url("images/list-bg.png") repeat-x;
    232245}
     
    247260    margin: 12px 0 0 0 !important;
    248261    padding: 1px 1px 0 !important;
    249     border-top: 1px solid #89a;
    250     border-right: 1px solid #789;
    251     border-left: 1px solid #789;
     262    border-top: 1px solid #fefffe;
     263    border-right: 1px solid #779;
     264    border-left: 1px solid #779;
    252265    border-bottom: 3px solid #347;
    253266    min-height: 50px;
    254267        background: #f4f6f6 url("images/list-bg.png") repeat-x;
    255     -webkit-box-shadow: 0 0 5px rgba(80, 100, 100, 0.5);
    256     box-shadow: 0 0 5px rgba(80, 100, 100, 0.5);
    257     -moz-box-shadow:0 0 5px rgba(80, 100, 100, 0.5);
     268    -moz-box-shadow:0 2px 5px #779;
     269    -webkit-box-shadow: 0 2px 5px #779;
     270    box-shadow: 0 2px 5px #779;
    258271}
    259272.delbut {
     
    273286    padding: 0;
    274287    /* width: 100%; */
    275     height: 1px;
     288    height: 3px;
    276289    clear: both;
    277     background-color: #347 /* #899; */
     290    background-color: #77799f;
    278291}
    279292.sum-det, .sum-det-spy {
     
    300313.det1 a { font-weight: bold; border-bottom: 1px solid !important; }
    301314.det2 a, .det2 a:link, .sum-det span.det2 a {
    302     color: #349 !important; /*#00008c  #00284a */
     315    color: #349 !important;
    303316}
    304317.det2 a:hover, .sum-det span.det2 a:hover {
     
    328341    height: 28px;
    329342    padding-top: 5px !important;
    330     border: 1px solid #cacad0;
     343    border: 1px solid #c0cccf;
     344    /* -moz-box-shadow: 0 -2px 10px #BFBFBD inset;
     345    -webkit-box-shadow: 0 -2px 10px #BFBFBD inset;
     346    box-shadow: 0 --2px 10px #BFBFBD inset; */
    331347}
    332348.sum-box-ip {
     
    365381    line-height: 1.1em;
    366382}
    367 #toptenchart a { color: #464646; }
     383#toptenchart { margin:0 auto; padding:0; }
     384#toptenchart table {
     385    margin: 0;
     386    padding: 0;
     387    border-collapse: collapse;
     388    border: 0 none;
     389}
     390#toptenchart a { color: #464646; margin-left: 1px; }
    368391#toptenchart a:hover { color: #d54d22; }
    369392ul.charts    {
     
    371394    margin: 0;
    372395    padding: 0;
     396    font: 8pt sans-serif;
     397    line-height: 1.1em;
    373398    border-bottom: 1px solid #dedede;
     399    border-right: 1px solid #fff;
    374400}
    375401li.charts {
    376     list-style-type: none;
    377     font-size: 11px;
     402    height: 25px !important;
     403    list-style-type: none;
     404    /* font-size: 11px; */
     405    line-height: 22px;
    378406    border-top: 1px #ddd solid;
    379     margin: 0px 0 4px 0;
    380     padding: 2px 4px 4px 4px;
     407    margin: 0;
     408    padding: 0 2px 0 2px;
    381409    background: url("images/list-bg3.png");
    382410}
    383411li.chartsT {
     412    height: 25px !important;
     413    margin: 0;
     414    padding: 2px 2px 0 2px;
    384415    list-style-type: none;
    385416    color: #2683ae;
    386     font-size: 11px;
     417    /* font-size: 11px; */
    387418    border-bottom: 2px solid #bfd0dd;
    388     margin: 2px 0 0 0;
    389     padding: 2px 4px 2px 4px;
     419    vertical-align: bottom;
    390420    background: #cee1ef;
    391421}
     422ul.rownums { background-color: #e6e9ef !important; }
    392423.sum-rec ul { border-top: 1px solid #999; }
    393424.detail-data {
    394425    margin: 0 auto !important;
    395426    clear:both;
    396     border-bottom: 0 none;
     427    border-left: 1px solid #eeeeef;
     428    border-right: 1px solid #eeeeef;
     429    border-top: 0 none;
     430    border-bottom: 1px solid #bcbcbf;
    397431    color: #445;
    398432    font-size: 11px;
     
    402436.detail-data ul {
    403437    list-style-type: none;
    404     width: 100%;
     438    /* width: 100%; */
    405439    margin: 0;
    406440    padding: 3px 0 4px 0;
     
    409443    border-bottom: 1px solid #bbb;
    410444}
     445.detail-data ul li { height: 25px; line-height: 22px; }
    411446ul.searcheng {
    412     background-color: #abdbff; /* #adf; */
     447    background-color: #abdbff;
    413448    border-color: #9cd;
    414449}
     
    425460}
    426461ul.useragent {
    427     padding: 4px 0 2px 0;
     462    padding: 0;
    428463    background-color: #67a;
    429464    border-bottom: 1px #ccc solid;
     
    433468    color: #f5f5f5;
    434469    width: 100%;
    435     padding: 0 6px 0 0;
     470    padding: 4px 6px 0 0;
     471    line-height: 1.5em !important;
    436472    text-align: center;
    437473}
     
    467503    border-right: 1px dotted #8e8e8e;
    468504}
    469 ul.agent { border-color: #ddd; }
     505ul.agent {
     506    border-color: #ddd;
     507    /* -moz-box-shadow: 0 -2px 10px #CDD0EE inset;
     508    -webkit-box-shadow: 0 -2px 10px #CDD0EE inset;
     509    box-shadow: 0 -2px 10px #CDD0EE inset; */
     510}
    470511li.agent {
    471512    list-style-type: none;
     
    495536ul.url {
    496537    list-style-type: none;
    497     width: 100%;
     538    /* width: 100%; */
    498539    margin: 0;
    499540    padding: 0;
    500     border: none;
    501     border-top: 1px #999 solid;
     541    border: 0 none;
    502542    clear: left;
    503543}
    504 li.url {
     544li.url, li.urlodd {
    505545    list-style-type: none;
    506546    width: 100%;
    507547    margin: 0;
    508548    padding: 0;
    509     line-height: 2em;
     549    height: 25px;
     550    line-height: 22px;
    510551    background-image: url("images/list-bg2.png");
    511     border-bottom: 1px #ddd solid;
    512 }
    513 li.urlodd {
    514     list-style-type: none;
    515     width: 100%;
    516     margin: 0;
    517     padding: 4px 0 6px 0;
    518     background-image: url("images/list-bg3.png");
    519     border-bottom: 1px #ddd solid;
     552    border-top: 1px solid #c0cfcf;
     553}
     554ul.url li.url {
     555    background-image: url("images/list-bg3.png") !important;
    520556}
    521557.url a, .url a:link { border-bottom: 1px solid !important; }
     
    553589    padding: 1px 1px 2px !important;
    554590    background-color: #dedade;
    555     box-shadow: 0 0 5px rgba(24, 24, 64, 0.9); /* 0 0 5px rgba(44,44,104, 0.9); */
    556     -moz-box-shadow: 0 0 5px rgba(24, 24, 64, 0.9);
    557     -webkit-box-shadow: 0 0 5px rgba(24, 24, 64, 0.9);
    558     border: 1px solid #c9d9e9; /* #efebef; */
     591    box-shadow: 0 0 4px rgba(24, 24, 30, 0.9);
     592    -moz-box-shadow: 0 0 4px rgba(24, 24, 30, 0.9);
     593    -webkit-box-shadow: 0 0 4px rgba(24, 24, 30, 0.9);
     594    border: 1px solid #ededef;
     595    -moz-border-radius: 3px;
     596    -webkit-border-radius: 3px;
     597    -khtml-border-radius: 3px;
     598    border-radius: 3px;
    559599}
    560600#spyContainer { clear: both; padding: 5px 5px 0 0; }
     
    603643}
    604644.bubble { font-size:11px; }
    605 .top10 { color: #542; }
     645.top10 { color: #542; padding-left: 1px; }
     646.fixed { font-size:11px; font-family: monospace; color: #887; }
    606647
    607648/* wassup-option tabs styles */
    608649#tabcontainer {
    609     list-style:none;
    610650    /* width: 97%;  */
    611651    margin: 10px auto 3px auto;
    612     padding: 2px 5px 1px;
     652    padding: 2px 2px 1px;
     653    font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif !important;
     654    font-size: 14px;
     655    color: #445;
    613656    border: 1px solid #efebef;
    614657    border-radius: 3px;
     
    616659    -moz-border-radius: 3px;
    617660    background-color: #dedade;
    618     color: #445;
    619     box-shadow: 0 0 5px rgba(44,44,104, 0.9);
    620     -moz-box-shadow: 0 0 5px rgba(44,44,104, 0.9);
    621     -webkit-box-shadow: 0 0 5px rgba(44,44,104, 0.9);
     661    list-style:none;
     662    -moz-box-shadow: 0 0 3px rgba(24, 24, 30, 0.9);
     663    -webkit-box-shadow: 0 0 3px rgba(24, 24, 30, 0.9);
     664    box-shadow: 0 0 3px rgba(24, 24, 30, 0.9);
    622665}
    623666#tabcontainer ul.ui-tabs-nav {
     
    658701    border-top-right-radius: 4px;
    659702}
     703.ui-widget-header a {
     704    color: #999 !important;
     705    font-size: 1.1em;
     706    font-weight: bold;
     707    text-shadow: 0 -1px 0 rgba(255,255,221,0.5);
     708}
     709.ui-state-active a, .ui-widget-header a:hover {
     710    color: #212121 !important;
     711}
     712
    660713#wassup_opt_frag-1, #wassup_opt_frag-2, #wassup_opt_frag-3,
    661714#wassup_opt_frag-4 {
     
    697750#spy-pause a, #spy-play a { text-decoration: none; border-bottom: 0 none; }
    698751.wassup-button {
    699 -   width; 160px;
     752    width: 155px !important;
    700753    background: url("images/button.png") top center no-repeat;
    701754    border-color: #999 !important;
     755    border-radius: 10px !important;
     756    -moz-border-radius: 10px;
     757    -webkit-border-radius: 10px;
     758    -khtml-border-radius: 10px;
    702759}
    703760.wassup-hot-button {
    704     width; 160px;
     761    width: 155px;
    705762    background: url("images/button2.png") top center no-repeat;
    706763    border-color: #777 !important;
     764    border-radius: 10px !important;
     765    -moz-border-radius: 10px;
     766    -webkit-border-radius: 10px;
     767    -khtml-border-radius: 10px;
    707768}
    708769.wassup-button:hover {
    709770    background-image: url("images/button2.png");
     771    background-color: transparent !important;
     772    color: #157 !important;
    710773}
    711774.wassup-hot-button:hover {
    712775    background-image: url("images/hot-button.png");
    713776}
     777.button-primary { border-color: #157 !important; }
  • wassup/trunk/lib/action.php

    r318010 r444137  
    107107    }
    108108
    109     $debug_mode=false;  //debug set below
     109    $wdebug_mode=false; //debug set below
    110110    //echo "Debug: Starting action.php from directory ".dirname(__FILE__).".  ABSPATH=".$wpabspath.".<br />\n"; //debug
    111111
     
    127127    // ### Begin actions that have output...
    128128    if (!empty($_GET['debug_mode'])) {
    129         $debug_mode=true;
     129        $wdebug_mode=true;
    130130        $mode_reset=ini_get('display_errors');
    131131        error_reporting(E_ALL); //debug, E_STRICT=php5 only
     
    191191    } elseif ($_GET['action'] == "piechart") {
    192192        // Prepare Pie Chart
    193         $Tot = New MainItems($table_name,$from_date,$to_date);
    194         $items_pie[] = $Tot->calc_tot("count", $search, "AND spam>0", "DISTINCT");
    195         $items_pie[] = $Tot->calc_tot("count", $search, "AND searchengine!='' AND spam=0", "DISTINCT");
    196         $items_pie[] = $Tot->calc_tot("count", $search, "AND searchengine='' AND referrer NOT LIKE '%".$this->WpUrl."%' AND referrer!='' AND spam=0", "DISTINCT");
    197         $items_pie[] = $Tot->calc_tot("count", $search, "AND searchengine='' AND (referrer LIKE '%".$this->WpUrl."%' OR referrer='') AND spam=0", "DISTINCT"); ?>
     193        $wTot = New WassupItems($table_name,$from_date,$to_date);
     194        $items_pie[] = $wTot->calc_tot("count", $search, "AND spam>0", "DISTINCT");
     195        $items_pie[] = $wTot->calc_tot("count", $search, "AND searchengine!='' AND spam=0", "DISTINCT");
     196        $items_pie[] = $wTot->calc_tot("count", $search, "AND searchengine='' AND referrer NOT LIKE '%".$this->WpUrl."%' AND referrer!='' AND spam=0", "DISTINCT");
     197        $items_pie[] = $wTot->calc_tot("count", $search, "AND searchengine='' AND (referrer LIKE '%".$this->WpUrl."%' OR referrer='') AND spam=0", "DISTINCT"); ?>
    198198        <div style="text-align: center"><img src="http://chart.apis.google.com/chart?cht=p3&amp;chco=0000ff&amp;chs=600x300&amp;chl=Spam|Search%20Engine|Referrer|Direct&amp;chd=<?php Gchart_data($items_pie, null, null, null, 'pie'); ?>" /></div>
    199199
     
    201201    // ACTION: LINE CHART - TODO
    202202    //} elseif ($_GET['action'] == "chart") {
    203     //  $chart = mainItems::theChart($from_date,$to_date,$search);
     203    //  $chart = WassupItems::theChart($from_date,$to_date,$search);
    204204
    205205    // ACTION: DISPLAY RAW RECORDS - no longer used (deprecated)
     
    208208    // ACTION: SHOW TOP TEN
    209209    } elseif ($_GET['action'] == "topten") {
    210         $top_limit=10;
    211         if ($debug_mode) {
     210        $top_limit=0;   //use default setting
     211        if ($wdebug_mode) {
    212212            $title='WassUp '.__('Top Stats for Period','wassup');
    213213            $wdformat = get_option("date_format");
     
    225225        echo '<span style="color:red;">Action.php '.__("ERROR: Missing or unknown parameters","wassup").', action='.attribute_escape($_GET["action"]).'</span>';
    226226    } 
    227     if ($debug_mode) {
     227    if ($wdebug_mode) {
    228228        if (function_exists('profiler_endSection')) {
    229229            profiler_endSection('(Tot)Action.php');
  • wassup/trunk/lib/compat_functions.php

    r315060 r444137  
    3232}
    3333
     34//'microtime_float' replicates microtime(true) from PHP5
     35if (!function_exists('microtime_float')) {
     36    function microtime_float() {
     37        list($usec, $sec) = explode(" ", microtime());
     38        return ((float)$usec + (float)$sec);
     39    }
     40}
     41
    3442if (!function_exists('admin_url')) {
    3543    function admin_url($admin_file="") {
  • wassup/trunk/lib/main.php

    r318010 r444137  
    586586} //end function
    587587
    588 //Output wassup records in Digg spy style...
     588//Output wassup records in the old Digg spy style...
    589589function wassup_spiaView ($from_date="",$rows=0,$spytype="",$spy_datasource="") {
    590     global $wpdb, $wp_version, $wassup_options, $debug_mode;
     590    global $wpdb, $wp_version, $wassup_options, $wdebug_mode;
    591591
    592592    if (!class_exists('wassupOptions') && file_exists(dirname(__FILE__). '/wassup.class.php')) {
     
    807807// Geocoding location with Google Maps
    808808function geocodeWassUp($location, $key) {
    809     global $debug_mode;
     809    global $wdebug_mode;
    810810    //Three parts to querystring: q= address, output= format, and key
    811811    $address = urlencode($location);
     
    813813
    814814    /*
    815     $ch = curl_init();
    816     curl_setopt($ch, CURLOPT_URL, $api_url);
    817     curl_setopt($ch, CURLOPT_HEADER,0);
    818     curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    819     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
    820     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    821 
    822     $data = curl_exec($ch);
    823     curl_close($ch);
     815    //$ch = curl_init();
     816    //curl_setopt($ch, CURLOPT_URL, $api_url);
     817    //curl_setopt($ch, CURLOPT_HEADER,0);
     818    //curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
     819    //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
     820    //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     821
     822    //$data = curl_exec($ch);
     823    //curl_close($ch);
    824824    */
    825825    $apidata = wFetchAPIData($api_url);
    826826    $data = explode(',',$apidata);
    827     if ($debug_mode) {
     827    if ($wdebug_mode) {
    828828        echo "\n<!--geocodeWassup data: ";
    829829        print_r($data);
     
    840840 */
    841841function wGeolocateIP($ip) {
    842     global $wpdb, $debug_mode;
     842    global $wpdb, $wdebug_mode;
    843843
    844844    $wassup_settings=get_option('wassup_settings');
     
    922922 */
    923923function wGetStats($stat_type, $stat_limit=10, $stat_condition="") {
    924     global $wpdb, $debug_mode;
     924    global $wpdb, $wdebug_mode;
    925925
    926926    $wassup_settings = get_option('wassup_settings');
     
    928928    $wpurl =  get_bloginfo('wpurl');
    929929    $blogurl =  get_option('home');
    930     $table_name = (!empty($wassup_settings['wassup_table'])?$wassup_settings['wassup_table'] : $wpdb->prefix . "wassup");
    931     $table_tmp_name = $table_name . "_tmp";
     930    $wtable_name = (!empty($wassup_settings['wassup_table'])?$wassup_settings['wassup_table'] : $wpdb->prefix . "wassup");
     931    $wtable_tmp_name = $wtable_name . "_tmp";
    932932
    933933    if (empty($stat_limit) || !(is_numeric($stat_limit))) {
     
    950950    //top search phrases...
    951951    if ($stat_type == "searches") {
    952         $stat_results = $wpdb->get_results("SELECT count(search) AS top_count, search AS top_item, referrer AS top_link FROM $table_name WHERE $stat_condition AND search!='' AND spider='' GROUP BY search ORDER BY top_count DESC LIMIT $stat_limit");
     952        $stat_results = $wpdb->get_results("SELECT count(search) AS top_count, search AS top_item, referrer AS top_link, max(`timestamp`) AS visit_timestamp FROM $wtable_name WHERE $stat_condition AND search!='' AND spider='' GROUP BY search ORDER BY top_count DESC, visit_timestamp DESC LIMIT $stat_limit");
    953953
    954954    //top external referrers...
    955955    } elseif ($stat_type == "referrers") {
    956956        //exclude internal referrals
    957         $url = parse_url($blogurl);
    958         $sitedomain = $url['host'];
     957        $wurl = parse_url($blogurl);
     958        $sitedomain = $wurl['host'];
    959959        $exclude_list = $sitedomain;
    960960        if ($wpurl != $blogurl) {
    961             $url = parse_url($wpurl);
    962             $wpdomain = $url['host'];
     961            $wurl = parse_url($wpurl);
     962            $wpdomain = $wurl['host'];
    963963            $exclude_list .= ",".$wpdomain;
    964964        }
     
    980980            }
    981981        }
    982         $stat_results = $wpdb->get_results("SELECT count(*) AS top_count, LOWER(referrer) AS top_item, referrer AS top_link FROM $table_name WHERE $stat_condition AND referrer!='' AND search='' AND spider='' $exclude_referrers GROUP BY top_item ORDER BY top_count DESC LIMIT $stat_limit");
    983         if ($debug_mode) {
     982        $stat_results = $wpdb->get_results("SELECT count(*) AS top_count, LOWER(referrer) AS top_item, referrer AS top_link, max(`timestamp`) AS visit_timestamp FROM $wtable_name WHERE $stat_condition AND referrer!='' AND search='' AND spider='' $exclude_referrers GROUP BY top_item ORDER BY top_count DESC, visit_timestamp DESC LIMIT $stat_limit");
     983        if ($wdebug_mode) {
    984984            echo "\n<pre>exclude_referrers = $exclude_referrers </pre>\n";
    985985        }
     
    987987    //top url requests...
    988988    } elseif ($stat_type == "urlrequested") {
    989         $stat_results = $wpdb->get_results("SELECT count(*) AS top_count, LOWER(REPLACE(urlrequested, '/', '')) AS top_group, LOWER(urlrequested) AS top_item, urlrequested AS top_link FROM $table_name WHERE $stat_condition GROUP BY top_group ORDER BY top_count DESC LIMIT $stat_limit");
     989        $stat_results = $wpdb->get_results("SELECT count(*) AS top_count, LOWER(REPLACE(urlrequested, '/', '')) AS top_group, LOWER(urlrequested) AS top_item, urlrequested AS top_link, max(`timestamp`) AS visit_timestamp FROM $wtable_name WHERE $stat_condition GROUP BY top_group ORDER BY top_count DESC, visit_timestamp DESC LIMIT $stat_limit");
    990990
    991991    //top browser...
    992992    } elseif ($stat_type == "browser") {
    993         $stat_results = $wpdb->get_results("SELECT count(*) AS top_count, SUBSTRING_INDEX(SUBSTRING_INDEX(browser, ' 0.', 1), '.', 1) AS top_item FROM $table_name WHERE $stat_condition AND `browser`!='' AND `browser` NOT LIKE 'N/A%' AND `spider`='' GROUP BY top_item ORDER BY top_count DESC LIMIT $stat_limit");
     993        $stat_results = $wpdb->get_results("SELECT count(*) AS top_count, SUBSTRING_INDEX(SUBSTRING_INDEX(browser, ' 0.', 1), '.', 1) AS top_item FROM $wtable_name WHERE $stat_condition AND `browser`!='' AND `browser` NOT LIKE 'N/A%' AND `spider`='' GROUP BY top_item ORDER BY top_count DESC LIMIT $stat_limit");
    994994
    995995    //top os...
    996996    } elseif ($stat_type == "os") {
    997         $stat_results = $wpdb->get_results("SELECT count(os) as top_count, `os` AS top_item FROM $table_name WHERE $stat_condition AND `os`!='' AND `os` NOT LIKE 'N/A%' AND spider='' GROUP BY top_item ORDER BY top_count DESC LIMIT $stat_limit");
     997        $stat_results = $wpdb->get_results("SELECT count(os) as top_count, `os` AS top_item FROM $wtable_name WHERE $stat_condition AND `os`!='' AND `os` NOT LIKE 'N/A%' AND spider='' GROUP BY top_item ORDER BY top_count DESC LIMIT $stat_limit");
    998998
    999999    //top language/locale..
    10001000    } elseif ($stat_type == "language" || $stat_type == "locale") {
    1001         $stat_results = $wpdb->get_results("SELECT count(LOWER(language)) as top_count, LOWER(language) as top_item FROM $table_name WHERE $stat_condition AND language!='' AND spider='' GROUP BY top_item ORDER BY top_count DESC LIMIT $stat_limit");
     1001        $stat_results = $wpdb->get_results("SELECT count(LOWER(language)) as top_count, LOWER(language) as top_item FROM $wtable_name WHERE $stat_condition AND language!='' AND spider='' GROUP BY top_item ORDER BY top_count DESC LIMIT $stat_limit");
    10021002
    10031003    //top visitors...
    10041004    } elseif ($stat_type == "visitor" || $stat_type == "visitors") {
    1005         $stat_results = $wpdb->get_results("SELECT count(username) as top_count, username as top_item, '1loggedin_user' as visitor_type, `timestamp` as visit_timestamp FROM $table_name WHERE $stat_condition AND username!='' GROUP BY 2 UNION SELECT count(comment_author) as top_count, comment_author as top_item, '2comment_author' as visitor_type, `timestamp` as visit_timestamp FROM $table_name WHERE $stat_condition AND username='' AND comment_author!='' GROUP BY 2 UNION SELECT count(hostname) as top_count, hostname as top_item, '3hostname' as visitor_type, `timestamp` as visit_timestamp FROM $table_name WHERE $stat_condition AND username='' AND comment_author='' AND spider='' GROUP BY 2 ORDER BY 1 DESC, 3, 2 LIMIT $stat_limit");
     1005        $stat_results = $wpdb->get_results("SELECT count(username) as top_count, username as top_item, '1loggedin_user' as visitor_type, max(`timestamp`) as visit_timestamp FROM $wtable_name WHERE $stat_condition AND username!='' GROUP BY 2 UNION SELECT count(comment_author) as top_count, comment_author as top_item, '2comment_author' as visitor_type, max(`timestamp`) as visit_timestamp FROM $wtable_name WHERE $stat_condition AND username='' AND comment_author!='' GROUP BY 2 UNION SELECT count(hostname) as top_count, hostname as top_item, '3hostname' as visitor_type, max(`timestamp`) as visit_timestamp FROM $wtable_name WHERE $stat_condition AND username='' AND comment_author='' AND spider='' GROUP BY 2 ORDER BY 1 DESC, 3, 2 LIMIT $stat_limit");
     1006
     1007    //top postid (post|page)
     1008    } elseif ($stat_type == "postid" || $stat_type == "article") {
     1009        $stat_results = $wpdb->get_results("SELECT count(*) AS top_count, url_wpid AS top_group, post_title AS top_item, urlrequested AS top_link, max(`timestamp`) as visit_timestamp FROM $wtable_name, {$wpdb->prefix}posts WHERE $stat_condition AND url_wpid!='' AND url_wpid!='0' AND url_wpid = {$wpdb->prefix}posts.ID GROUP BY top_group ORDER BY top_count DESC, visit_timestamp DESC LIMIT $stat_limit");
     1010
    10061011    } else {
    10071012        //TODO: check that wp_wassup.$stat_type column exist and is char
    10081013        if (!empty($stat_type)) {
    1009             $stat_results = $wpdb->get_results("SELECT count($stat_type) AS top_count, `$stat_type` AS top_item FROM $table_name WHERE $stat_condition AND `$stat_type`!='' AND `$stat_type` NOT LIKE 'N/A%' GROUP BY `$stat_type` ORDER BY top_count DESC LIMIT $stat_limit");
     1014            $stat_results = $wpdb->get_results("SELECT count($stat_type) AS top_count, `$stat_type` AS top_item FROM $wtable_name WHERE $stat_condition AND `$stat_type`!='' AND `$stat_type` NOT LIKE 'N/A%' GROUP BY `$stat_type` ORDER BY top_count DESC LIMIT $stat_limit");
    10101015        }
    10111016    }
     
    10241029 * @return none
    10251030 */
    1026 function wassup_top10view ($from_date="",$to_date="",$max_char_len="",$top_limit=10,$title=false) {
     1031function wassup_top10view ($from_date="",$to_date="",$max_char_len="",$top_limit=0,$title=false) {
    10271032    global $wpdb, $wassup_options;
    10281033    if (!class_exists('wassupOptions') && file_exists(dirname(__FILE__). '/wassup.class.php')) {
     
    10311036    $wassup_options = new wassupOptions;
    10321037    $top_ten = unserialize(html_entity_decode($wassup_options->wassup_top10));
    1033     $table_name = (!empty($wassup_options->wassup_table)? $wassup_options->wassup_table: $wpdb->prefix . "wassup");
    1034     $table_tmp_name = $table_name . "_tmp";
     1038    if (!is_array($top_ten)) $top_ten = $wassup_options->defaultSettings("top10");
     1039    //$table_name = (!empty($wassup_options->wassup_table)? $wassup_options->wassup_table: $wpdb->prefix . "wassup");
     1040    //$table_tmp_name = $table_name . "_tmp";
    10351041
    10361042    $blogurl =  get_bloginfo('home');
     
    10531059        }
    10541060    }
    1055     //#add an extra width offset when columns count < 5
     1061    //#add an extra width offset when columns count < 6
    10561062    $col_count = array_sum($top_ten);
    1057     if ($col_count > 0 && $col_count < 5 ) {
    1058         $widthoffset = (($max_char_len*(5 - $col_count))/$col_count)*.4; //just a guess
     1063    if ($col_count > 0 && $col_count < 6 ) {
     1064        $widthoffset = (($max_char_len*(6 - $col_count))/$col_count)*.4; //just a guess
    10591065    } else {
    10601066        $widthoffset = 0;
     
    10621068    //extend page width to make room for more than 5 columns
    10631069    $pagewidth = $wassup_options->wassup_screen_res;
    1064     if ($col_count > 5) {
    1065         $pagewidth = $pagewidth+17*($col_count-5);
     1070    if ($col_count > 6) {
     1071        $pagewidth = $pagewidth+17*($col_count-6);
     1072    }
     1073    //New in v1.8.3: top_limit in top10 array
     1074    if (empty($top_limit) || !is_numeric($top_limit)) {
     1075        if (!empty($top_ten['toplimit'])) {
     1076            $top_limit = (int) $top_ten['toplimit'];
     1077        } else {
     1078            $top_limit = 10;    //default
     1079        }
    10661080    }
    10671081
    10681082    //mysql conditional query...
    10691083    $top_condition = '`timestamp` BETWEEN '.$from_date.' AND '.$to_date;
     1084    if (!empty($top_ten['top_nospider'])) {
     1085        $top_condition .= " AND spider=''";
     1086    }
    10701087    echo "\n"; ?>
    10711088    <div id="toptenchart" style="width:auto;">
    1072     <table width="100%" border="0" style="margin:0; padding:0;">
     1089    <table width="100%">
    10731090    <tr valign="top"><?php
    10741091    if (!empty($title)) { ?>
    10751092        <th colspan="<?php echo $col_count; ?>"><span style="centered"><?php echo $title; ?></span></th></tr><tr><?php
    10761093    }
     1094    //show a line# column for long data columns
     1095    if ($top_limit > 10) wPrintRowNums($top_limit);
     1096
    10771097    //#output top 10 searches
    10781098    if ($top_ten['topsearch'] == 1) {
     
    10831103        <li class="chartsT"><?php echo _e("TOP QUERY", "wassup"); ?></li> <?php
    10841104        $i=0;
     1105        $ndigits=1;
    10851106        if (count($top_results) >0) {
    1086             foreach ($top_results as $top10) {
    1087                 echo "\n"; ?>
    1088         <li class="charts"><?php echo $top10->top_count.': <a href="'.$top10->top_link.'" target="_BLANK" title="'.substr($top10->top_item,0,$wassup_options->wassup_screen_res-100).'">'.stringShortener(preg_replace('/'.preg_quote($blogurl,'/').'/i', '', $top10->top_item),$char_len).'</a>'; ?></li><?php
     1107            $ndigits = strlen("{$top_results[0]->top_count}");
     1108        foreach ($top_results as $top10) {
     1109            echo "\n"; ?>
     1110        <li class="charts"><nobr><?php echo wPadNum($top10->top_count, $ndigits).' <a href="'.$top10->top_link.'" target="_BLANK" title="'.substr($top10->top_item,0,$wassup_options->wassup_screen_res-100).'">'.stringShortener(preg_replace('/'.preg_quote($blogurl,'/').'/i', '', $top10->top_item),$char_len).'</a>'; ?></nobr></li><?php
    10891111                $i++;
    1090             }
     1112        }
    10911113        }
    10921114        //finish list with empty <li> for style consistency
     
    11051127        <ul class="charts">
    11061128        <li class="chartsT"><?php _e("TOP REFERRER", "wassup"); ?></li><?php
    1107          $i=0;
     1129        $i=0;
     1130        $ndigits=1;
    11081131        if (count($top_results) >0) {
     1132            $ndigits = strlen("{$top_results[0]->top_count}");
    11091133        foreach ($top_results as $top10) {
    1110                 echo "\n"; ?>
    1111         <li class="charts"><?php echo $top10->top_count.': ';
    1112             print '<a href="'.clean_url($top10->top_link,'','url').'" title="'.attribute_escape($top10->top_link).'" target="_BLANK">';
     1134            echo "\n"; ?>
     1135        <li class="charts"><nobr><?php echo wPadNum($top10->top_count,$ndigits);
     1136            echo ' <a href="'.clean_url($top10->top_link,'','url').'" title="'.attribute_escape($top10->top_link).'" target="_BLANK">';
    11131137            //#cut http:// from displayed url and truncate
    11141138            //#   instead of using stringShortener
    1115             print substr(str_replace("http://", "", attribute_escape($top10->top_item)),0,$char_len);
     1139            echo substr(str_replace("http://", "", attribute_escape($top10->top_item)),0,$char_len);
    11161140            if (strlen($top10->top_item) > ($char_len + 7)) {
    1117                 print '...';
    1118             }
    1119             print '</a>'; ?></li><?php
     1141                echo '...';
     1142            }
     1143            echo '</a>'; ?></nobr></li><?php
    11201144            $i++;
    11211145        }
     
    11361160        <li class="chartsT"><?php _e("TOP REQUEST", "wassup"); ?></li><?php
    11371161        $i=0;
     1162        $ndigits=1;
    11381163        if (count($top_results) >0) {
    1139             foreach ($top_results as $top10) {
    1140                 echo "\n"; ?>
    1141         <li class="charts"><?php echo $top10->top_count.': ';
     1164            $ndigits = strlen("{$top_results[0]->top_count}");
     1165        foreach ($top_results as $top10) {
     1166            echo "\n"; ?>
     1167        <li class="charts"><nobr><?php echo wPadNum($top10->top_count,$ndigits);
    11421168            if (strstr($top10->top_item,'[404]')) { //no link for 404 pages
    1143                 echo '<span class="top10" title="'.substr($top10->top_item,0,$wassup_options->wassup_screen_res-100).'">'.stringShortener(preg_replace('/'.preg_quote($blogurl,'/').'/i', '', $top10->top_item),$char_len).'</span>';
     1169                echo ' <span class="top10" title="'.substr($top10->top_item,0,$wassup_options->wassup_screen_res-100).'">'.stringShortener(preg_replace('/'.preg_quote($blogurl,'/').'/i', '', $top10->top_item),$char_len).'</span>';
    11441170            } else {
    1145                 echo '<a href="'.wAddSiteurl($top10->top_link).'" target="_BLANK" title="'.substr($top10->top_item,0,$wassup_options->wassup_screen_res-100).'">'.stringShortener(preg_replace('/'.preg_quote($blogurl,'/').'/i', '', $top10->top_item),$char_len).'</a>';
    1146             } ?></li><?php
    1147                 $i++;
    1148             }
     1171                echo ' <a href="'.wAddSiteurl($top10->top_link).'" target="_BLANK" title="'.substr($top10->top_item,0,$wassup_options->wassup_screen_res-100).'">'.stringShortener(preg_replace('/'.preg_quote($blogurl,'/').'/i', '', $top10->top_item),$char_len).'</a>';
     1172            } ?></nobr></li><?php
     1173            $i++;
     1174        }
    11491175        }
    11501176        //finish list with empty <li> for styling consistency
     
    11631189        <li class="chartsT"><?php _e("TOP BROWSER", "wassup") ?></li><?php
    11641190        $i=0;
     1191        $ndigits=1;
    11651192        if (count($top_results) >0) {
    1166             foreach ($top_results as $top10) {
    1167                 echo "\n"; ?>
    1168         <li class="charts"><?php echo $top10->top_count.': ';
    1169                 echo '<span class="top10" title="'.$top10->top_item.'">'.stringShortener($top10->top_item, $char_len).'</span>'; ?></li><?php
    1170                 $i++;
    1171             }
     1193            $ndigits = strlen("{$top_results[0]->top_count}");
     1194        foreach ($top_results as $top10) {
     1195            echo "\n"; ?>
     1196        <li class="charts"><nobr><?php echo wPadNum($top10->top_count,$ndigits);
     1197            echo ' <span class="top10" title="'.$top10->top_item.'">'.stringShortener($top10->top_item, $char_len).'</span>'; ?></nobr></li><?php
     1198            $i++;
     1199        }
    11721200        }
    11731201        //finish list with empty <li> for styling consistency
     
    11861214        <li class="chartsT"><?php _e("TOP OS", "wassup") ?></li><?php
    11871215        $i=0;
     1216        $ndigits=1;
    11881217        if (count($top_results) >0) {
    1189             foreach ($top_results as $top10) {
    1190                 echo "\n"; ?>
    1191         <li class="charts"><?php print $top10->top_count.': '; ?><span class="top10" title="<?php echo $top10->top_item; ?>"><?php echo stringShortener($top10->top_item, $char_len); ?></span></li><?php
    1192                 $i++;
    1193             }
     1218            $ndigits = strlen("{$top_results[0]->top_count}");
     1219        foreach ($top_results as $top10) {
     1220            echo "\n"; ?>
     1221        <li class="charts"><nobr><?php echo wPadNum($top10->top_count,$ndigits); ?> <span class="top10" title="<?php echo $top10->top_item; ?>"><?php echo stringShortener($top10->top_item, $char_len); ?></span></nobr></li><?php
     1222            $i++;
     1223        }
    11941224        }
    11951225        //finish list with empty <li> for styling consistency
     
    12081238        <li class="chartsT"><?php _e("TOP LOCALE", "wassup"); ?></li><?php
    12091239        $i=0;
     1240        $ndigits=1;
    12101241        if (count($top_results) >0) {
    1211             foreach ($top_results as $top10) {
    1212                 echo "\n"; ?>
    1213         <li class="charts"><?php echo $top10->top_count.': ';
    1214             echo '<img src="'.WASSUPURL.'/img/flags/'.strtolower($top10->top_item).'.png" alt="" />'; ?>
    1215             <span class="top10" title="<?php echo $top10->top_item; ?>"><?php echo $top10->top_item; ?></span></li><?php
    1216                 $i++;
    1217             }
     1242            $ndigits = strlen("{$top_results[0]->top_count}");
     1243        foreach ($top_results as $top10) {
     1244            echo "\n"; ?>
     1245        <li class="charts"><nobr><?php echo wPadNum($top10->top_count,$ndigits);
     1246            echo ' <img src="'.WASSUPURL.'/img/flags/'.strtolower($top10->top_item).'.png" alt="" />'; ?>
     1247            <span class="top10" title="<?php echo $top10->top_item; ?>"><?php echo $top10->top_item; ?></span></nobr></li><?php
     1248            $i++;
     1249        }
    12181250        }
    12191251        //finish list with empty <li> for styling consistency
     
    12321264        <li class="chartsT"><?php _e("TOP VISITOR", "wassup"); ?></li><?php
    12331265        $i=0;
     1266        $ndigits=1;
    12341267        if (count($top_results)>0) {
    1235             foreach ($top_results as $top10) {
    1236                 if ($top10->visitor_type == "1loggedin_user")
    1237                     $uclass=" userslogged";
    1238                 elseif ($top10->visitor_type == "2comment_author")
    1239                     $uclass=" users";
    1240                 else
    1241                     $uclass="";
    1242                 echo "\n"; ?>
    1243         <li class="charts"><?php echo $top10->top_count.': <span class="top10'.$uclass.'" title="'.$top10->top_item.'">'.stringShortener($top10->top_item, $char_len).'</span>'; ?></li><?php
    1244                 $i++;
    1245             } //end loop
     1268            $ndigits = strlen("{$top_results[0]->top_count}");
     1269        foreach ($top_results as $top10) {
     1270            if ($top10->visitor_type == "1loggedin_user")
     1271                $uclass=" userslogged";
     1272            elseif ($top10->visitor_type == "2comment_author")
     1273                $uclass=" users";
     1274            else
     1275                $uclass="";
     1276            echo "\n"; ?>
     1277        <li class="charts"><nobr><?php echo wPadNum($top10->top_count,$ndigits).' <span class="top10'.$uclass.'" title="'.$top10->top_item.'">'.stringShortener($top10->top_item, $char_len).'</span>'; ?></nobr></li><?php
     1278            $i++;
     1279        } //end loop
    12461280        }
    12471281        //finish list with empty <li> for styling consistency
     
    12501284        </td>
    12511285<?php   } // end if topvisitor
     1286
     1287    //#output top article (post|page by id)
     1288    if ($top_ten['toppostid'] == 1) {
     1289        echo "\n<!--heartbeat-->";
     1290        $top_results = wGetStats("postid",$top_limit,$top_condition);
     1291        $char_len = round(($max_char_len*.28)+$widthoffset,0); ?>
     1292        <td style="min-width:<?php echo ($char_len-5); ?>px;">
     1293        <ul class="charts">
     1294        <li class="chartsT"><?php _e("TOP ARTICLE", "wassup"); ?></li><?php
     1295        $i=0;
     1296        $ndigits=1;
     1297        if (count($top_results) >0) {
     1298            $ndigits = strlen("{$top_results[0]->top_count}");
     1299        foreach ($top_results as $top10) {
     1300            echo "\n"; ?>
     1301        <li class="charts"><nobr><?php echo wPadNum($top10->top_count,$ndigits);
     1302            echo ' <a href="'.wAddSiteurl($top10->top_link).'" target="_BLANK" title="'.$top10->top_item.'">'.stringShortener($top10->top_item,$char_len).'</a>'; ?> </nobr></li><?php
     1303            $i++;
     1304        }
     1305        }
     1306        //finish list with empty <li> for styling consistency
     1307        wListFiller($i,$top_limit,"charts"); ?>
     1308        </ul>
     1309        </td><?php
     1310    } // end if toppost
     1311    //show a line# column for long data columns
     1312    if ($top_limit > 10 && $col_count > 6) {
     1313        wPrintRowNums($top_limit);
     1314    }
    12521315    ?></tr>
    1253     </table><?php
    1254     if ($wassup_options->wassup_spamcheck == 1) { ?>
    1255     <br/><span style="font-size:6pt;">* <?php _e("This report excludes Spam records","wassup"); ?></span><?php
    1256     } ?>
     1316    </table>
     1317    <span style="font-size:7pt;"> <?php
     1318    if ($wassup_options->wassup_spamcheck == 1 || !empty($top_ten['top_nospider'])) { ?><br/>*<?php
     1319        if ($wassup_options->wassup_spamcheck == 1 && !empty($top_ten['top_nospider'])) {
     1320            _e("This report excludes spam and spider records","wassup");
     1321        } elseif (!empty($top_ten['top_nospider'])) {
     1322            _e("This report excludes spider records","wassup");
     1323        } else {
     1324            _e("This report excludes spam records","wassup");
     1325        }
     1326    } ?> </span>
    12571327    </div> <?php
    12581328} //end wassup_top10view
     
    12671337    }
    12681338} //end wListFiller
    1269 
    1270 // How many digits have an integer
    1271 function digit_count($n, $base=10) {
    1272   if($n == 0) return 1;
    1273   if($base == 10) {
    1274     # using the built-in log10(x)
    1275     # might be more accurate than log(x)/log(10).
    1276     return 1 + floor(log10(abs($n)));
    1277   }else{
    1278     # here  logB(x) = log(x)/log(B) will have to do.
    1279    return 1 + floor(log(abs($n))/ log($base));
    1280   }
     1339/*
     1340 * print a table column with line number rows from 1 to "$top_limit"
     1341 * @param integer
     1342 * @output html
     1343 * @return none
     1344 */
     1345function wPrintRowNums($top_limit=10) {
     1346    $ndigits = strlen("{$top_limit}");
     1347    echo "\n"; ?>
     1348        <td style="min-width:8px;">
     1349        <ul class="charts rownums">
     1350        <li class="chartsT">&nbsp;</li><?php
     1351    for ($i=1; $i<= $top_limit; $i++) {
     1352        echo "\n"; ?>
     1353        <li class="charts"><nobr><?php echo wPadNum($i, $ndigits); ?></nobr></li><?php
     1354    } ?>
     1355        </td><?php
     1356} //end function
     1357
     1358/**
     1359 * return html code to pad an integer ($li_number) with spaces to match a
     1360 * width of $li_width
     1361 * @param integer (2)
     1362 * @return string (html)
     1363 */
     1364function wPadNum($li_number, $li_width=1) {
     1365    $numstr = (int)$li_number;
     1366    $ndigits = strlen("$numstr");
     1367    $padding = '';
     1368    if ($ndigits < $li_width) {
     1369        for ($i=$ndigits; $i < $li_width; $i++) $padding .= '&nbsp;';
     1370    }
     1371    $padhtml = '<span class="fixed">'."$padding{$numstr}</span>";
     1372    return ($padhtml);
    12811373}
     1374
     1375// How many digits have an integer -- quicker to use 'strlen' function
     1376// function digit_count($n, $base=10) {
     1377//  if($n == 0) return 1;
     1378//  if($base == 10) {
     1379//    # using the built-in log10(x)
     1380//    # might be more accurate than log(x)/log(10).
     1381//    return 1 + floor(log10(abs($n)));
     1382//  }else{
     1383//    # here  logB(x) = log(x)/log(B) will have to do.
     1384//   return 1 + floor(log(abs($n))/ log($base));
     1385//  }
     1386//}
    12821387
    12831388//Round the integer to the next near 10
    12841389function roundup($value) {
    1285     $dg = digit_count($value);
     1390    //$dg = digit_count($value);
     1391    $numstr = (int)$value;
     1392    $dg = strlen("$numstr");
    12861393    if ($dg <= 2) {
    12871394        $dg = 1;
     
    12931400
    12941401function Gchart_data($Wvisits, $pages=null, $atime=null, $type, $charttype=null, $axes=null, $chart_loc=null) {
    1295     global $debug_mode;
     1402    global $wdebug_mode;
    12961403    $chartAPIdata = false;
    12971404// Port of JavaScript from http://code.google.com/apis/chart/
     
    13741481
    13751482// Used to show main visitors details query, to count items and to extract data for main chart
    1376 class MainItems {
     1483class WassupItems {
    13771484    // declare variables
    13781485        var $tableName;
     
    13871494
    13881495    /* Constructor */
    1389     function mainitems($table_name,$date_from,$date_to,$whereis=null,$limit=null) {
    1390         global $wpdb, $wassup_options, $debug_mode;
     1496    function wassupitems($table_name,$date_from,$date_to,$whereis=null,$limit=null) {
     1497        global $wpdb, $wassup_options, $wdebug_mode;
    13911498        if (empty($wassup_options->wassup_table)) {
    13921499            $wassup_options = new wassupOptions;
     
    14211528    // Function to show main query and count items
    14221529        function calc_tot($Type, $Search="", $specific_where_clause=null, $distinct_type=null) {
    1423         global $wpdb, $wassup_options, $debug_mode;
     1530        global $wpdb, $wassup_options, $wdebug_mode;
    14241531
    14251532                $this->ItemsType = $Type;
     
    14441551            //  - retrieve one row per wassup_id with timestamp = max(timestamp) (ie. latest record)
    14451552            // "sql_buffer_result" select option helps in cases where it takes a long time to retrieve results.  -Helene D. 2/29/09
    1446             $qry = sprintf("SELECT SQL_BUFFER_RESULT *, max(`timestamp`) as max_timestamp, count(wassup_id) as page_hits FROM %s WHERE `timestamp` >= %s %s %s GROUP BY wassup_id ORDER BY max_timestamp DESC %s",
     1553            $qry = sprintf("SELECT SQL_BUFFER_RESULT *, max(`timestamp`) as max_timestamp, min(`timestamp`) as min_timestamp, count(wassup_id) as page_hits FROM %s WHERE `timestamp` >= %s %s %s GROUP BY wassup_id ORDER BY max_timestamp DESC %s",
    14471554                $this->tableName,
    14481555                $this->from_date,
     
    14521559            $results = $wpdb->get_results($qry);
    14531560            if (empty($results) || !is_array($results)) { //try without buffer
    1454                 $qry = sprintf("SELECT *, max(`timestamp`) as max_timestamp, count(wassup_id) as page_hits FROM %s WHERE `timestamp` >= %s %s %s GROUP BY wassup_id ORDER BY max_timestamp DESC %s",
     1561                $qry = sprintf("SELECT *, max(`timestamp`) as max_timestamp, min(`timestamp`) as min_timestamp, count(wassup_id) as page_hits FROM %s WHERE `timestamp` >= %s %s %s GROUP BY wassup_id ORDER BY max_timestamp DESC %s",
    14551562                    $this->tableName,
    14561563                    $this->from_date,
     
    14761583        case "main-ip":     //TODO
    14771584            // These are the queries to count the hits/pages/spam by ip
    1478             $qry = sprintf("SELECT *, max(`timestamp`) as max_timestamp, count(`ip`) as page_hits FROM %s WHERE `timestamp` >= %s %s %s GROUP BY ip ORDER BY max_timestamp DESC %s",
     1585            $qry = sprintf("SELECT *, max(`timestamp`) as max_timestamp, min(`timestamp`) as min_timestamp, count(`ip`) as page_hits FROM %s WHERE `timestamp` >= %s %s %s GROUP BY ip ORDER BY max_timestamp DESC %s",
    14791586                    $this->tableName,
    14801587                    $this->from_date,
     
    15061613    // $Search = string to add to where clause
    15071614        function TheChart($Ctype, $Res, $chart_height, $Search="", $axes_type, $chart_bg, $chart_loc="page", $chart_group="") {
    1508         global $wpdb, $wassup_options, $debug_mode;
     1615        global $wpdb, $wassup_options, $wdebug_mode;
    15091616
    15101617        $mysqlversion=substr(mysql_get_server_info(),0,3);
     
    15291636                $chart_url = html_entity_decode($wassup_cache[0]->meta_value);
    15301637                $cache_id = $wassup_cache[0]->meta_id;
    1531                 if ($debug_mode) {
     1638                if ($wdebug_mode) {
    15321639                    echo "\n<!-- Cached chart found. cache_id=$cache_id -->\n";
    15331640                }
     
    17051812                }
    17061813            }
    1707             if ($debug_mode) {
     1814            if ($wdebug_mode) {
    17081815                echo "\n<!-- \$x-points= ".implode("|",$tlabel)."\n";
    17091816                echo " \$tgroup=".implode("|",$tgroup)."-->";
     
    17311838            $ss);
    17321839        }
    1733         if ($debug_mode) {
     1840        if ($wdebug_mode) {
    17341841            echo "\n<!-- \$query= $qry-->\n";
    17351842        }
     
    17701877            //if (count($x_label) > 20 && $chart_width < 1000) {
    17711878            //}
    1772             if ($debug_mode) {
     1879            if ($wdebug_mode) {
    17731880                echo "\n<!-- \$x-group= ".implode("|",$x_group);
    17741881                echo "\n \$x-labels= ".implode("|",$x_label)."-->\n";
     
    18441951    } //end function buildSearch
    18451952
    1846 } //end class mainItems
     1953} //end class WassupItems
    18471954
    18481955// Class to check if a previous comment with a specific IP was detected as SPAM by Akismet default plugin
     
    19462053 */
    19472054function wFetchAPIData($api_url) {
    1948     global $debug_mode;
     2055    global $wdebug_mode;
    19492056
    19502057    $wassup_settings=get_option('wassup_settings');
     
    19862093        $api_method='file_get_contents';    //debug
    19872094    }
    1988     if ($debug_mode) {
     2095    if ($wdebug_mode) {
    19892096        echo "\n<!-- <br>API Fetch using $api_method data: "; //debug
    19902097        print_r($apidata);
  • wassup/trunk/lib/settings.php

    r318010 r444137  
    99 */
    1010function wassup_optionsView() {
    11     global $wpdb, $wp_version, $user_level, $wassupversion, $wassup_options, $debug_mode;
     11    global $wpdb, $wp_version, $user_level, $wassupversion, $wassup_options, $wdebug_mode;
    1212
    1313    $GMapsAPI="http://code.google.com/intl/en/apis/maps";
     
    2020    $alertstyle = 'color:red; background-color:#ffd;';
    2121    $wassup_table = (!empty($wassup_options->wassup_table))? $wassup_options->wassup_table: $wpdb->prefix . "wassup";
     22    $wassup_meta_table = $wassup_table . "_meta";
    2223    $table_engine = "";
    2324    $table_collation = "";
     
    7778        <?php $wassup_options->showFormOptions("wassup_screen_res"); ?>
    7879            </select>
    79             </p>
    80         <h3><?php _e('Set minimum users level which can view and manage WassUp plugin (default Administrators)','wassup'); ?></h3>
    81         <p><select name="wassup_userlevel">
     80            </p><br/>
     81        <h3><?php _e('User Permissions'); ?></h3>
     82        <p><strong><?php _e('Set minimum users level which can view and manage WassUp plugin','wassup'); ?></strong>:
     83        <select name="wassup_userlevel">
    8284        <?php $wassup_options->showFormOptions("wassup_userlevel"); ?>
    83         </select></p>
     85        </select>
     86        <?php echo "(".__('default Administrator','wassup').")"; ?>
     87        </p><br/>
    8488
    8589        <h3><?php _e('Dashboard Settings','wassup'); ?></h3>
    8690        <p><input type="checkbox" name="wassup_dashboard_chart" value="1" <?php if($wassup_options->wassup_dashboard_chart == 1) print "CHECKED"; ?> /> <strong><?php _e('Display small chart in the dashboard','wassup'); ?></strong>
    87         </p>
    88 
    89         <h3><?php _e('GEO IP Map (Spy view)','wassup'); ?></h3>
    90         <p><input type="checkbox" name="wassup_geoip_map" value="1" <?php
     91        </p><br/>
     92
     93        <h3><?php _e('Spy Visitors Settings','wassup'); ?></h3>
     94        <p> <input type="checkbox" name="wassup_geoip_map" value="1" <?php
    9195        //if (!function_exists('curl_init')) { print "DISABLED"; }
    9296        if ($wassup_options->wassup_geoip_map == 1) print "CHECKED"; ?> />
     
    105109            }
    106110        } ?>
    107         <p><strong>Google Maps API <?php _e("key","wassup"); ?>:</strong> <input type="text" name="wassup_googlemaps_key" size="40" value="<?php print $wassup_options->wassup_googlemaps_key; ?>" /> - <a href="<?php echo $GMapsAPI.'/signup.html?url='.get_bloginfo('wpurl'); ?>"><?php _e("signup for your key","wassup"); ?></a></p></br /> <?php
     111        <p> <strong>Google Maps API <?php _e("key","wassup"); ?>:</strong> <input type="text" name="wassup_googlemaps_key" size="40" value="<?php print $wassup_options->wassup_googlemaps_key; ?>" /> - <a href="<?php echo $GMapsAPI.'/signup.html?url='.get_bloginfo('wpurl'); ?>"><?php _e("signup for your key","wassup"); ?></a></p> <?php
    108112        //no curl - now works without cUrl using 'wp_remote_get'
    109113        //} else {
    110114        //echo '<p class="small">'.__("Geo IP Map requires","wassup")." PHP <strong>Curl</strong>. ".__("Please install it to be able to activate this feature","wassup").".</p>";
    111         //} ?><br/>
     115        //} ?>
     116        <p> <strong><?php echo _e('Set update speed of Spy data in microseconds','wassup'); ?></strong> :
     117        <input type="text" name="wassup_spy_speed" size="5" value="<?php if (empty($wassup_options->wassup_spy_speed)) echo "5000"; else echo $wassup_options->wassup_spy_speed; ?>" />
     118        <?php echo "<nobr>(".__('default 5000, minimum 1000','wassup').")</nobr>"; ?><br/>
     119        <?php  echo __('Decrease if some visitor records are missing from Spy view. Increase if multiple duplicate records are shown.','wassup'); ?>
     120        </p><br/>
    112121
    113122        <h3><?php _e('Visitor Detail Settings','wassup'); ?></h3>
    114         <p><strong><?php _e('Time format 12/24 Hour','wassup'); ?></strong>:
     123        <p> <strong><?php _e('Time format 12/24 Hour','wassup'); ?></strong>:
    115124        &nbsp; 12h <input type="radio" name="wassup_time_format" value="12" <?php if($wassup_options->wassup_time_format == 12) print "CHECKED"; ?> />
    116125        &nbsp; &nbsp; 24h <input type="radio" name="wassup_time_format" value="24" <?php if($wassup_options->wassup_time_format == 24) print "CHECKED"; ?> />
    117126        </p>
    118 
    119         <p><strong><?php _e('Show chart type - How many axes','wassup'); ?></strong>:
    120         <select name='wassup_chart_type'><?php
    121         $wassup_options->showFormOptions("wassup_chart_type");
    122         ?></select>
    123         </p>
    124 
    125         <p><strong><?php echo __('Set how many minutes wait for automatic page refresh','wassup'); ?></strong>:
     127        <p> <strong><?php _e('Show chart type - How many axes','wassup'); ?></strong>:
     128        <select name='wassup_chart_type'>
     129        <?php $wassup_options->showFormOptions("wassup_chart_type"); ?>
     130        </select>
     131        </p>
     132        <p> <strong><?php echo __('Set how many minutes wait for automatic page refresh','wassup'); ?></strong>:
    126133        <input type="text" name="wassup_refresh" size="2" value="<?php print $wassup_options->wassup_refresh; ?>" /> <?php _e('minutes (default 3)','wassup'); ?>
    127134        </p>
    128 
    129         <p><strong><?php _e('Show visitor details for the last','wassup');
    130         ?></strong>: <select name='wassup_time_period'> <?php
    131         $wassup_options->showFormOptions("wassup_time_period");
    132         ?></select>
    133         </p>
    134         <p><strong><?php _e('Filter visitor details for','wassup');
    135         ?></strong>: <select name='wassup_default_type'> <?php
    136         $wassup_options->showFormOptions("wassup_default_type");
    137         ?></select>
    138         </p>
    139 
    140         <p><strong><?php _e('Number of items per page','wassup'); ?></strong>:
     135        <p> <strong><?php _e('Show visitor details for the last','wassup'); ?></strong>:
     136        <select name='wassup_time_period'>
     137        <?php $wassup_options->showFormOptions("wassup_time_period"); ?>
     138        </select>
     139        </p>
     140        <p> <strong><?php _e('Filter visitor details for','wassup'); ?></strong>:
     141        <select name='wassup_default_type'>
     142        <?php $wassup_options->showFormOptions("wassup_default_type"); ?>
     143        </select>
     144        </p>
     145        <p> <strong><?php _e('Number of items per page','wassup'); ?></strong>:
    141146        <select name='wassup_default_limit'>
    142147        <?php $wassup_options->showFormOptions("wassup_default_limit"); ?>
    143148        </select>
    144149        </p><br />
    145         <?php
    146         //TODO: Make Top 10 Customizable with up to 10 choices
     150
     151        <h3><?php _e('Customize Top Stats Lists','wassup'); ?></h3><?php
     152        //New in 1.8.3:
     153        //  1) toplimit option to customize top stats list size
     154        //  2) toppostid option to list top post-ID items (articles)
     155        //  3) top_nospider option to exclude spider visits from all
     156        //     top stats lists
    147157        $top_ten = unserialize(html_entity_decode($wassup_options->wassup_top10));
    148         ?>
    149         <h3><?php _e('Customize Top Ten List','wassup'); ?></h3>
    150         <p style="margin-top:5px;"> <strong> <?php _e("Choose one or more items for your Top Ten list", "wassup"); ?></strong> (<?php _e("over 5 selections may cause horizontal scrolling","wassup"); ?>):<br />
     158        if (!is_array($top_ten)) {  //in case corrupted
     159            $top_ten = $wassup_options->defaultSettings("top10");
     160        }
     161        if (empty($top_ten["toplimit"])) $top_ten["toplimit"] = 10;
     162        echo "\n"; ?>
     163        <p> <strong> <?php _e("Set the list length size for Top Stats", "wassup"); ?></strong>:
     164        <input type="text" name="toplimit" size="2" value="<?php echo (int)$top_ten['toplimit']; ?>" /> (<?php _e("default 10","wassup"); ?>)
     165        </p>
     166        <p style="margin-top:5px;"> <strong> <?php _e("Choose one or more items to list in Top Stats", "wassup"); ?></strong> (<?php _e("over 5 selections may cause horizontal scrolling","wassup"); ?>):<br />
    151167        <div style="padding-left:25px;padding-top:0;margin-top:0;display:block;clear:left;">
    152168        <div style="display:block; vertical-align:top; float:left; width:225px;">
    153169            <input type="checkbox" name="topsearch" value="1" <?php if($top_ten['topsearch'] == 1) print "CHECKED"; ?> /><?php _e("Top Searches", "wassup"); ?><br />
    154             <input type="checkbox" name="topreferrer" value="1" <?php if($top_ten['topreferrer'] == 1) print "CHECKED"; ?> /><?php _e("Top Referrers", "wassup"); ?><br />
     170            <input type="checkbox" name="topreferrer" value="1" <?php if($top_ten['topreferrer'] == 1) print "CHECKED"; ?> /><?php _e("Top Referrers", "wassup"); ?>*<br />
    155171        <input type="checkbox" name="toprequest" value="1" <?php if($top_ten['toprequest'] == 1) print "CHECKED"; ?> /><?php _e("Top Requests", "wassup"); ?><br />
    156172        </div>
     
    161177        </div>
    162178        <div style="vertical-align:top; float:left; width:225px;">
    163         <input type="checkbox" name="topvisitor" value="1" <?php if($top_ten['topvisitor'] == 1) print "CHECKED"; ?> /><?php _e("Top Visitors", "wassup"); ?><br /><!-- 
     179        <input type="checkbox" name="topvisitor" value="1" <?php if(!empty($top_ten['topvisitor'])) print "CHECKED"; ?> /><?php _e("Top Visitors", "wassup"); ?><br />
     180            <input type="checkbox" name="toppostid" value="1" <?php if(!empty($top_ten['toppostid'])) print "CHECKED"; ?> /><?php _e("Top Articles", "wassup"); ?></span><br /><!-- 
    164181        //TODO
    165182            <input type="checkbox" name="topfeed" value="1" DISABLED /><?php _e("Top Feeds", "wassup"); ?><br />
     
    167184        </div>
    168185        </div>
    169         </p>
    170         <p style="margin-top:10px; clear:left;"> <strong><?php _e("Websites/domains to exclude from top referrers", "wassup"); ?></strong> :<br />
     186        </p><p style="clear:left;"></p>
     187        <p style="margin-top:5px;"> *<strong><?php _e("Exclude the following website domains from Top Referrers", "wassup"); ?></strong> :<br />
    171188        <span style="padding-left:10px;display:block;clear:left;">
    172189        <textarea name="topreferrer_exclude" rows="2" style="width:66%;"><?php echo $top_ten['topreferrer_exclude']; ?></textarea><br />
    173         <?php  echo __("Comma separated value","wassup")."(ex: mydomain2.net, mydomain2.info). ". __("List whole domains only. Wildcards and partial domains will NOT be excluded.","wassup"). " ";
     190        <?php  echo __("Comma separated value","wassup")." (ex: mydomain2.net, mydomain2.info). ". __("List whole domains only. Wildcards and partial domains will be ignored.","wassup"). " ";
    174191        _e("Don't list your website domain defined in WordPress","wassup"); ?>.</span>
    175192        </p>
     193        <p> <input type="checkbox" name="top_nospider" value="1" <?php if($top_ten['top_nospider'] == 1) print "CHECKED"; ?> />
     194        <strong> <?php _e("Exclude all spider records from Top Stats", "wassup"); ?></strong>
     195        </p>
    176196        <br /><br />
    177         <p style="clear:both;padding-left:0;padding-top:15px;"><input type="submit" name="submit-options" class="submit-opt wassup-button" value="<?php _e('Save Settings','wassup'); ?>" />&nbsp;<input type="reset" name="reset" class="reset-opt wassup-button" value="<?php _e('Reset','wassup'); ?>" /> - <input type="submit" name="reset-to-default" class="default-opt wassup-button" value="<?php _e("Reset to Default", "wassup"); ?>" /></p><br />
     197        <p style="clear:both;padding-left:0;padding-top:15px;"><input type="submit" name="submit-options" class="submit-opt wassup-button button-primary" value="<?php _e('Save Settings','wassup'); ?>" />&nbsp;<input type="reset" name="reset" class="reset-opt wassup-button" value="<?php _e('Reset','wassup'); ?>" /> - <input type="submit" name="reset-to-default" class="default-opt wassup-button" value="<?php _e("Reset to Default", "wassup"); ?>" /></p><br />
    178198    </div>
    179199
     
    206226        <br /><span style="padding-left:10px;display:block;clear:left;">
    207227            <textarea name="wassup_exclude_user" rows="2" style="width:60%;"><?php print $wassup_options->wassup_exclude_user; ?></textarea></span> &nbsp; <?php _e("comma separated value, enter a registered user's login name (ex: bobmarley, enyabrennan, etc.)", "wassup") ?></p>
    208         <br /><p><strong><?php echo __("Posts/pages","wassup")."\n<br /> &nbsp; ".__('enter requested URLs to exclude from recording','wassup'); ?></strong>:
     228        <br /><p><strong><?php echo __("Posts/pages","wassup")."\n<br /> &nbsp; ".__('Enter requested URLs to exclude from recording','wassup'); ?></strong>:
    209229        <br /><span style="padding-left:10px;display:block;clear:left;">
    210230            <textarea name="wassup_exclude_url" rows="2" style="width:60%;"><?php print $wassup_options->wassup_exclude_url; ?></textarea></span> &nbsp; <?php _e("comma separated value, don't enter entire url, only the last path or some word to exclude (ex: /category/wordpress, 2007, etc...)", "wassup") ?></p>
    211         <p style="clear:both;padding-left:0;padding-top:15px;"><input type="submit" name="submit-options2" class="submit-opt wassup-button" value="<?php _e('Save Settings','wassup'); ?>" />&nbsp;<input type="reset" name="reset" class="reset-opt wassup-button" value="<?php _e('Reset','wassup'); ?>" /> - <input type="submit" name="reset-to-default" class="default-opt wassup-button" value="<?php _e("Reset to Default", "wassup"); ?>" /></p><br />
     231        <p style="clear:both;padding-left:0;padding-top:15px;"><input type="submit" name="submit-options2" class="submit-opt wassup-button button-primary" value="<?php _e('Save Settings','wassup'); ?>" />&nbsp;<input type="reset" name="reset" class="reset-opt wassup-button" value="<?php _e('Reset','wassup'); ?>" /> - <input type="submit" name="reset-to-default" class="default-opt wassup-button" value="<?php _e("Reset to Default", "wassup"); ?>" /></p><br />
    212232    </div>
    213233   
    214234    <div id="wassup_opt_frag-3" class="optionstab<?php if ($tab == "3") echo ' tabselected'; ?>">
    215        <?php /*
    216     //   <h3>&lt;?php _e('Temporary files location folder','wassup'); ?&rt;</h3>
    217     //  <p>&lt;?php echo '<strong>'.__('Current "Save path" directory for storing temporary files used to track visitor activity','wassup').'</strong>:<br />';
    218     //  $sessionpath = $wassup_options->wassup_savepath;
    219     //  if (empty($sessionpath)) {
    220     //      $sessionpath = getSessionpath();
    221     //  }
    222     //  //$sessionpath = "/fakefolder/temp";    //#debug
    223     //  $sessionstyle = '';
    224     //  //# check that session_save_path exists and is writable...
    225     //  if ($sessionpath == "" || $wassup_options->isWritableFolder($sessionpath) == false) {
    226     //      $sessionwarn = '<span style="font-size:95%; padding-left:5px;'.$alertstyle.'"><span style="text-decoration:blink;">'.__('WARNING','wassup').'!</span> '.__('Directory does not exist or is not writable. Please enter a different path above or change "session.save_path" in "php.ini" to point to a valid, writable folder','wassup').'.</span>';
    227     //      $sessionstyle = $alertstyle;
    228     //  } else {
    229     //      $sessionwarn ='<span style="font-size:95%; color:#555; padding-left:5px;">'.__('Note: To adjust, modify the directory shown in the box above or edit "sessions.save_path" in','wassup').' <i>php.ini</i>.</span>';
    230     //  }
    231     //  <textarea name="wassup_savepath" rows="1" style="width:550px;padding-left:25px;clear:left;&lt;?php echo $sessionstyle; ?&rt;">&lt;?php echo $sessionpath; ?&rt;</textarea>
    232     //  <br />&nbsp;&nbsp;&lt;?php echo __('Use absolute directory paths only. This value is usually','wassup').' "/tmp".'."\n"; ?&rt;
    233     //  <br />&nbsp; <span style="font-size:95%; color:#555;">System default for session.save_path="&lt;?php echo session_save_path(); //debug ?&rt;" from <i>php.ini</i> or from web server configuration.</span>
    234     //  <br />&nbsp;&lt;?php echo $sessionwarn."\n"; ?&rt;
     235<?php /*
     236       //TODO ?
     237       //<!--
     238       //<br /><h3><?php _e('Rescan Old Records','wassup'); ?></h3>
     239    //  <p><?php _e("Statistical records collected by earlier versions of WassUp may not have the latest spider, search engine, and spam data properly identified.  Click the \"Rescan\" button to retroactively scan and update old records","wassup"); ?>.
     240    //  <br /><input type="button" name="rescan" value="<?php _e('Rescan Old Records','wassup'); ?>" />
    235241    //  </p><br />
    236     */ ?>
    237        <?php //TODO ?>
    238        <!--
    239        <br /><h3><?php _e('Rescan Old Records','wassup'); ?></h3>
    240         <p><?php _e("Statistical records collected by earlier versions of WassUp may not have the latest spider, search engine, and spam data properly identified.  Click the \"Rescan\" button to retroactively scan and update old records","wassup"); ?>.
    241         <br /><input type="button" name="rescan" value="<?php _e('Rescan Old Records','wassup'); ?>" />
    242         </p><br />
    243        -->
     242    //   -->
     243*/ ?>
    244244        <h3><?php _e('Select actions for table growth','wassup'); ?></h3>
    245245        <p><?php _e("WassUp table grows very fast, especially if your site is frequently visited. I recommend you delete old records sometimes.","wassup");
    246         echo " ".__("You can select an option below to delete all Wassup records (empty table); or you can delete selected old records on either an automatic schedule (daily), or as manual task now (once). If you haven't database space problems, you can leave the table as is.","wassup"); ?></p>
     246        echo "<br/>".__('You can delete all Wassup records now (Empty Table), you can set an automatic delete option to delete selected old records daily, and you can manually delete selected old records once (Delete NOW).','wassup');
     247        echo " ".__("If you haven't database space problems, you can leave the table as is.","wassup"); ?></p>
    247248        <p><?php _e('Current WassUp table usage is','wassup'); ?>:
    248249        <strong><?php
     
    279280        </p><br/>
    280281        <h3><?php _e('Cache storage option','wassup'); ?></h3>
    281         <p><input type="checkbox" name="wassup_cache" value="1" <?php if($wassup_options->wassup_cache == 1 ) print "CHECKED"; ?> /> <strong><?php echo __('Enable cache for storing some remote API services data locally in WassUp table','wassup'); ?></strong></p>
     282        <p><input type="checkbox" name="wassup_cache" value="1" <?php
     283        if ($wpdb->get_var("SHOW TABLES LIKE '$wassup_meta_table'") != $wassup_meta_table) {
     284            echo "DISABLED"; //meta table required for cache
     285        } elseif ($wassup_options->wassup_cache == 1 ) {
     286            echo "CHECKED";
     287        } ?> /> <strong><?php echo __('Enable cache for storing some remote API data locally in WassUp table','wassup'); ?></strong></p>
    282288        <p style="color:#555; margin-top:0; padding-top:0;"><?php _e('Reduces the number of requests to remote API servers and may improve WassUp admin page load.','wassup'); ?></p><br/>
    283289
     
    485491                }
    486492            }
    487             if ($debug_mode) {
     493            if ($wdebug_mode) {
    488494                print_r($sql_vars); //debug
    489495            }
     
    579585        </ul></p>
    580586        <br /><br />
    581         <p style="clear:both;padding-left:0;padding-top:15px;"><input type="submit" name="submit-options3" class="submit-opt wassup-button" value="<?php _e('Save Settings','wassup'); ?>" />&nbsp;<input type="reset" name="reset" class="reset-opt wassup-button" value="<?php _e('Reset','wassup'); ?>" /> - <input type="submit" name="reset-to-default" class="default-opt wassup-button" value="<?php _e("Reset to Default", "wassup"); ?>" /></p><br />
     587        <p style="clear:both;padding-left:0;padding-top:15px;"><input type="submit" name="submit-options3" class="submit-opt wassup-button button-primary" value="<?php _e('Save Settings','wassup'); ?>" />&nbsp;<input type="reset" name="reset" class="reset-opt wassup-button" value="<?php _e('Reset','wassup'); ?>" /> - <input type="submit" name="reset-to-default" class="default-opt wassup-button" value="<?php _e("Reset to Default", "wassup"); ?>" /></p><br />
    582588    </div>
    583589   
     
    596602        <br /><p><?php _e("To help improve this plugin, we would appreciate your feedback at","wassup"); ?> <a href="http://www.wpwp.org">www.wpwp.org</a>.</p>
    597603        <br /><br />
    598         <p style="clear:both;padding-left:0;padding-top:15px;"><input type="submit" name="submit-options4" class="submit-opt wassup-button" value="<?php _e('Save Settings','wassup'); ?>" />&nbsp;<input type="reset" name="reset" value="<?php _e('Reset','wassup'); ?>" class="reset-opt wassup-button" /> - <input type="submit" name="reset-to-default" class="default-opt wassup-button" value="<?php _e("Reset to Default", "wassup"); ?>" /></p><br />
     604        <p style="clear:both;padding-left:0;padding-top:15px;"><input type="submit" name="submit-options4" class="submit-opt wassup-button button-primary" value="<?php _e('Save Settings','wassup'); ?>" />&nbsp;<input type="reset" name="reset" value="<?php _e('Reset','wassup'); ?>" class="reset-opt wassup-button" /> - <input type="submit" name="reset-to-default" class="default-opt wassup-button" value="<?php _e("Reset to Default", "wassup"); ?>" /></p><br />
    599605    </div>
    600606        </form>
  • wassup/trunk/lib/uadetector.class.php

    r315060 r444137  
    22/**
    33 * UADetector.class.php
    4  * Description: a PHP class for browser and spider identification
    5  * Updated: 2010-09-02
    6  * @version 0.9a3
    7  * @author Helene D. <[email protected]>
    8  * Author URI: http://www.techfromhel.com/
     4 * Description: a PHP4 class for browser and spider identification
     5 * Updated: 2011-07-13
     6 * @version 0.9a5
     7 * @author Helene Duncker <[email protected]>
     8 * Author URI: http://techfromhel.webege.com/
    99 *
    10  * @copyright Copyright (c) 2009,2010 Helene Duncker
     10 * @copyright Copyright (c) 2009-2011 Helene Duncker
    1111 * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License
    1212 */
     
    1616 *
    1717 * Note: UADetector attempts to find the actual browser in use. This may
    18  *    cause the browser "name" to differ from browser "emulation" field
    19  *    when user-agent "spoofing" is detected. This means that:
    20  *    a) "Name" field is best used for information and statistics only.
    21  *    b) "Emulation" field is best used to format web page by browser type.
     18 *    cause the "name" field to differ from "emulation" field when
     19 *    user-agent "spoofing" is detected. Use the appropriate field
     20 *    for your application type:
     21 *      a) "Name" field is best for information and statistics only.
     22 *      b) "Emulation" field is best for UI and customizations by browser type.
    2223 *
    2324 * Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
    2425 */
    2526class UADetector {
    26     var $name = '';     //name of browser or spider, not null
    27     var $version = '';  //version of browser|spider, if available
     27    var $name = '';     //browser or spider name, not null
     28    var $version = '';  //browser or spider version, if available
    2829    var $os = '';       //operating system+version, if available
    29     var $platform = ''; //operating system|device platform
     30    var $platform = ''; //operating system or device platform
    3031    var $emulation = '';    //emulated browser plus major version#
    31     var $language = ''; //language code, if available
    32     var $device = '';   //PC, PDA, Phone, TV, if known
    33     var $model = '';    //Manufacturer model, if known
     32    var $language = ''; //language code (not locale), if available
     33    var $device = '';   //PC, PDA, Phone, TV, if available
     34    var $model = '';    //Device manufacturer model, if available
    3435    var $resolution = '';   //screen size (MMMxNNN), if in user-agent
    35     var $subscribers = '';  //feed subscribers, if in user-agent
     36    var $subscribers = '';  //feed subscriber count, if in user-agent
    3637    var $is_mobile = false;
    3738    var $is_browser = false;
     
    6465     * @access  public
    6566     * @param   string $ua (optional)
    66      * @return  object(12)
     67     * @return  object(16)
    6768     */
    6869    function __construct($ua="") {
    69         global $debug_mode, $do_profile;
     70        global $wdebug_mode, $do_profile;
    7071        $do_profile= false;
    71         if ($debug_mode && function_exists('profiler_beginSection')) {
     72        if ($wdebug_mode && function_exists('profiler_beginSection')) {
    7273            $do_profile = true;
    7374            profiler_beginSection('(Subtot)uaDetector');
     
    139140        //  "WassUp", a web statistics plugin for WordPress 2.2+
    140141        //   available at http://www.wpwp.org
    141         global $debug_mode, $do_profile;
     142        global $wdebug_mode, $do_profile;
    142143
    143144        // User agent parameter or class variable is required.
     
    174175                $top_ua['device'] = $match[3];
    175176            }
    176         // #3 Firefox or other Mozilla browsers on Windows
     177        // #3 Firefox and other Mozilla browsers on Windows
    177178        } elseif (preg_match('#^Mozilla/\d\.\d\s\(Windows;\sU;\s(.+);\s([a-z]{2}(?:\-[A-Za-z]{2})?);\srv\:\d(?:\.\d+)+\)\sGecko/\d+\s([A-Za-z\-0-9]+)/(\d+(?:\.\d+)+)(?:\s\(.*\))?$#',$ua,$match)>0) {
    178179            $top_ua['name'] = $match[3];
     
    193194            }
    194195            $top_ua['agenttype']= 'R';
    195         // #5 MSNBot, MSNbot-media
    196         } elseif (preg_match('#^(?:msnbot(\-media)?)/(\d\.\d)[^a-z0-9]+http\://search\.msn\.com/msnbot\.htm.$#',$ua,$match)>0) {
    197             $top_ua['name'] = 'MSNBot';
     196        // #5 BingBot
     197        } elseif (preg_match('#^Mozilla/\d\.\d\s\(compatible;\sbingbot/(\d\.\d)[^a-z0-9]+http\://www\.bing\.com/bingbot\.htm.$#',$ua,$match)>0) {
     198            $top_ua['name'] = 'BingBot';
    198199            if (!empty($match[1])) {
    199200                $top_ua['name'].=$match[1];
     
    203204            }
    204205            $top_ua['agenttype']= 'R';
    205         // #6 Twiceler
    206         } elseif (preg_match('#^Mozilla/\d\.\d\s\(Twiceler\-(\d\.\d)\shttp://www\.cuill?\.com/twiceler/robot\.html\)$#',$ua,$match)>0) {
    207             $top_ua['name'] = 'Twiceler';
    208             $top_ua['version']=$match[1];
    209             $top_ua['agenttype']= 'R';
    210         // #7 FeedBurner
     206        // #6 FeedBurner
    211207        } elseif (preg_match('#^FeedBurner/(\d\.\d)\s\(http\://www\.FeedBurner\.com\)$#',$ua,$match)>0) {
    212208            $top_ua['name'] = 'FeedBurner';
    213209            $top_ua['version']=$match[1];
    214210            $top_ua['agenttype']= 'F';
    215         // #8 Wordpress
     211        // #7 Wordpress
    216212        } elseif (preg_match('#^WordPress/(?:wordpress(\-mu)\-)?(\d\.\d+)(?:\.\d+)*(?:\-[a-z]+)?(?:\;\shttp\://[a-z0-9_\.\:\/]+)?$#',$ua,$match)>0) {
    217213            $top_ua['name'] = 'Wordpress';
     
    221217            $top_ua['version']=$match[2];
    222218            $top_ua['agenttype']= 'U';
    223         // #9 Firefox and Gecko browsers on Mac|*nix|OS/2 etc...
     219        // #8 Firefox and Gecko browsers on Mac|*nix|OS/2 etc...
    224220        } elseif (preg_match('#^Mozilla/\d\.\d\s\((Macintosh|X11|OS/2);\sU;\s(.+);\s([a-z]{2}(?:\-[A-Za-z]{2})?)(?:-mac)?;\srv\:\d(?:.\d+)+\)\sGecko/\d+\s([A-Za-z\-0-9]+)/(\d+(?:\.[0-9a-z\-\.]+))+(?:(\s\(.*\))(?:\s([A-Za-z\-0-9]+)/(\d+(?:\.\d+)+)))?$#',$ua,$match)>0) {
    225221            $top_ua['name'] = $match[4];
     
    237233            list($top_ua['os']) = $this->OSversion($os,$top_ua['platform'],$ua);
    238234            $top_ua['agenttype']= 'B';
    239         // #10 Safari and Webkit-based browsers on all platforms
     235        // #9 Safari and Webkit-based browsers on all platforms
    240236        } elseif (preg_match('#^Mozilla/\d\.\d\s\(([A-Za-z0-9/\.]+);\sU;?\s?(.*);\s?([a-z]{2}(?:\-[A-Za-z]{2})?)?\)\sAppleWebKit/[0-9\.]+\+?\s\((?:KHTML,\s)?like\sGecko\)(?:\s([a-zA-Z0-9\./]+(?:\sMobile)?)/?[A-Z0-9]*)?\sSafari/([0-9\.]+)$#',$ua,$match)>0) {
    241237            $top_ua['name'] = 'Safari';
     
    260256            $top_ua['language']=$match[3];
    261257            $top_ua['agenttype']= 'B';
     258
     259        // #10 Google Chrome browser on all platforms with or without language string
     260        } elseif (preg_match('#^Mozilla/\d+\.\d+\s(?:[A-Za-z0-9\./]+\s)?\((?:([A-Za-z0-9/\.]+);(?:\sU;)?\s?)?([^;]*)(?:;\s[A-Za-z]{3}64)?;?\s?([a-z]{2}(?:\-[A-Za-z]{2})?)?\)\sAppleWebKit/[0-9\.]+\+?\s\((?:KHTML,\s)?like\sGecko\)(?:\s([A-Za-z0-9_\-]+[^i])/([A-Za-z0-9\.]+)){1,3}(?:\sSafari/[0-9\.]+)?$#',$ua,$match)>0) {
     261            $top_ua['name'] = $match[4];
     262            $top_ua['version'] = $match[5];
     263            if (empty($match[2])) {
     264                $os = $match[1];
     265            } else {
     266                $top_ua['platform'] = $match[1];
     267                $os = $match[2];
     268            }
     269            if ($top_ua['platform'] == 'Windows') {
     270                $top_ua['os'] = $this->winOSversion($os);
     271            } else {
     272                list($top_ua['os']) = $this->OSversion($os,$top_ua['platform'],$ua);
     273            }
     274            if (!empty($match[3])) {
     275                $top_ua['language']=$match[3];
     276            }
     277            $top_ua['agenttype']= 'B';
    262278        }
    263279        //check http header for user agent spoofing and for os and screen resolution
     
    280296            $top_ua=false;
    281297        }
    282         if ($debug_mode) {
     298        if ($wdebug_mode) {
    283299            echo "\n".'<br />uadetector: top_ua->name='.$top_ua['name']."&nbsp; ".'top_ua->os='.$top_ua['os']; //debug
    284300            if ($do_profile) {
     
    296312     */
    297313    function isBrowserAgent($agent="") {
    298         global $debug_mode, $do_profile;
     314        global $wdebug_mode, $do_profile;
    299315        $ua="";
    300316        $is_current_ua = false;
     
    311327
    312328        //spiders are not detected here, so exclude user agents that are likely spiders (ie. contains an email or URL, or spider-like keywords)
    313         if (isset($this->done_spiders) && !$this->done_spiders && preg_match('#(robot|bot[\s\-_\/\)]|bot$|blog|checker|crawl|feed|fetcher|libwww|[^\.e]link\s?|parser|reader|spider|verifier|href|https?\://|.+(?:\@|\s?at\s?)[a-z0-9_\-]+(?:\.|\s?dot\s?)|www[0-9]?\.[a-z0-9_\-]+\..+|\/.+\.(html?|aspx?|php5?|cgi))#i',$ua)>0) {
     329        if (isset($this->done_spiders) && !$this->done_spiders && preg_match('#(robot|bot[\s\-_\/\)]|bot$|blog|checker|crawl|feed|fetcher|libwww|[^\.e]link\s?|parser|reader|spider|verifier|href|https?\://|.+(?:\@|\s?at\s?)[a-z0-9_\-]+(?:\.|\s?dot\s?)|www[0-9]?\.[a-z0-9_\-]+\..+|\/.+\.(s?html?|aspx?|php5?|cgi))#i',$ua)>0) {
    314330            //not spider if embedded browser or is a browser add-on such as spyware or translator
    315331            if (preg_match('#(embedded\s?(WB|Web\sbrowser)|dynaweb|bsalsa\.com|muuk\.co|translat[eo]r?)#i',$ua)==0) {
     
    320336            profiler_beginSection('_____ua::isBrowser');
    321337        }
    322         //Separate check for mobile browsers beforehand
     338        //### Step 1: check for mobile or embedded browsers
    323339        $ismobile = false;
    324         //check for mobile or embedded browser
    325340        $wap = $this->isMobileAgent($ua);
    326341        if (!empty($wap) && is_array($wap)) {
    327342            $ismobile = true;
     343            $browser['name'] = $wap['name'];
     344            $browser['version'] = $wap['version'];
    328345            $browser['device'] = $wap['device'];
    329346            $browser['model'] = $wap['model'];
    330             $browser['platform'] = $wap['platform'];
    331             if (empty($browser['name'])) {
    332                 $browser['name'] = $wap['name'];
    333                 $browser['version'] = $wap['version'];
    334             }
    335             if (!empty($wap['os'])) $browser['os'] = $wap['os'];
     347            $browser['os'] = $wap['os'];
     348            $browser['platform'] = "WAP";
    336349            if (!empty($wap['language'])) $browser['language'] = $wap['language'];
    337350        }
     351        //### Step 2: Check for MSIE-based browsers
    338352        if (!$ismobile || empty($browser['name'])) {
    339             //MSIE browsers
    340353            if (preg_match('/compatible(?:\;|\,|\s)+MSIE\s(\d+)(\.\d+)+(.*)/',$ua,$pcs)>0) {
    341                 if ($debug_mode) {
     354                if ($wdebug_mode) {
    342355                    echo "\nMatch for MSIE-based browser<br/>";
    343356                }
     
    375388                }
    376389
     390        //### Step 3: Check for All Other browsers
    377391            //Opera browsers
    378             } elseif (preg_match('#(Opera\s(?:Mini|Mobile))[/ ]([0-9\.]+)#',$ua,$pcs)>0) {
    379                 $browser['name'] = $pcs[1];
    380                 $browser['version'] = $pcs[2];
    381392            } elseif (preg_match('#Opera[/ ]([0-9\.]+)#',$ua,$pcs)>0) {
    382393                $browser['name'] = 'Opera';
     
    385396            //Firefox-based browsers (Camino, Flock) (find before FF)
    386397            } elseif (preg_match('#[^a-z](Camino|Flock|Galeon|Orca)/(\d+[\.0-9a-z]*)#',$ua,$pcs)>0) {
    387                 if ($debug_mode) {
     398                if ($wdebug_mode) {
    388399                    echo "\nMatch for Firefox-based browser<br/>";
    389400                }
     
    393404            //other Gecko-type browsers (incl. Firefox)
    394405            } elseif (preg_match('#Gecko/\d+\s([a-z0-9_\- ]+)/(\d+[\.0-9a-z]*)(?:$|[^a-z0-9_\-]+([a-z0-9_\- ]+)/(\d+[\.0-9a-z]*)|[^a-z0-9_\-]*\(.*\))#i',$ua,$pcs)>0) {
    395                 if ($debug_mode) {
     406                if ($wdebug_mode) {
    396407                    echo "\nMatch for Gecko-type browser<br/>";
    397408                }
     
    404415            //Firefox browser
    405416            } elseif (preg_match('#[^a-z](Fire(?:fox|bird))/?(\d+[\.0-9a-z]*)?#',$ua,$pcs)>0) {
    406                 if ($debug_mode) {
     417                if ($wdebug_mode) {
    407418                    echo "\nMatch for Firefox browser<br/>";
    408419                }
     
    413424            //Mozilla browser (like FF, but nothing after "rv:" or "Gecko")
    414425            } elseif (preg_match('/^Mozilla\/\d\.\d.+\srv\:(\d[\.0-9a-z]+)[^a-z0-9]+(?:Gecko\/\d+)?$/i',$ua,$pcs)>0) {
    415                 if ($debug_mode) {
     426                if ($wdebug_mode) {
    416427                    echo "\nMatch for Mozilla browser<br/>";
    417428                }
     
    423434            //WebKit-based browsers
    424435            } elseif (preg_match('#^Mozilla/\d\.\d\s\((?:([a-z]{3,}.*\s)?([a-z]{2}(?:\-[A-Za-z]{2})?)?)\)\sAppleWebKit/[0-9\.]+\+?\s\([a-z, ]*like\sGecko[a-z\; ]*\)\s([a-zA-Z0-9\./]+(?:\sMobile)?/?[A-Z0-9]*)?(\sSafari/([0-9\.]+))?$#',$ua,$pcs)>0) {
    425                 if ($debug_mode) {
     436                if ($wdebug_mode) {
    426437                    echo "\nMatch for WebKit-based browser<br/>";
    427438                }
     
    439450            //Text-only browsers Lynx, ELinks...(yep, they still exist)
    440451            } elseif (preg_match("#^(E?Links|Lynx|(?:Emacs\-)?w3m)[^a-z0-9]+([0-9\.]+)?#i",$ua,$pcs)) {
    441                 if ($debug_mode) {
     452                if ($wdebug_mode) {
    442453                    echo "\nMatch for text browser<br/>";
    443454                }
     
    479490            }
    480491            }
    481         } //end if ($ismobile)
     492        } //end if (!$ismobile)
    482493
    483494        //get operating system
     
    522533            $browser['agenttype']= "S";
    523534        }
    524         if ($debug_mode) {
     535        if ($wdebug_mode) {
    525536            echo "\n".'<br />uadetector: browser->name='.$browser['name']."&nbsp; ".'browser->os='.$browser['os']; //debug
    526537        }
     
    550561     */
    551562    function isMobileAgent($agent="") {
    552         global $debug_mode, $do_profile;
     563        global $wdebug_mode, $do_profile;
    553564        $ua="";
    554565        $is_current_ua = false;
     
    565576        }
    566577        $ismobile = false;
    567         $device = $ua;
    568         $wap = array('name'=>"",
    569                 'version'=>"",
    570                 'device'=>"",
    571                 'model'=>"",
    572                 'platform'=>"WAP");
     578        //$device = $ua;
     579        $wap = array('name'=>"", 'version'=>"",
     580            'device'=>"", 'model'=>"",
     581            'os'=>"", 'platform'=>"WAP");
    573582        //detect known mobile browsers
    574583
    575584        //Android-based devices
    576585        if (preg_match("#^(?:([a-z0-9\-\s_]{3,})\s)?Mozilla/\d\.\d\s\([a-z\;\s]+Android\s([0-9\.]+)(?:\;\s([a-z]{2}(?:\-[A-Za-z]{2})?)\;)?.*Gecko\)\s([a-zA-Z0-9\./]+(?:\sMobile)?/?[A-Z0-9]*)?(\sSafari/([0-9\.]+))?#i",$ua,$pcs)) {
    577             $ismobile = true;
    578586            if (!empty($pcs[4])) { $vers = $pcs[4]; }
    579587            else { $vers = $pcs[6]; }
     
    586594            if (!empty($pcs[2])) $wap['os'] .= " ".$this->majorVersion($pcs[2]);
    587595            if (!empty($pcs[3])) $wap['language'] = $pcs[3];
    588             if (!empty($pcs[1])) $device = $pcs[1];
     596            if (!empty($pcs[1])) $wap['device'] = $pcs[1];
     597
     598        //Windows Mobile browsers
     599        } elseif (preg_match('#Windows\sCE;\s?IEMobile\s(\d+)(\.\d+)*\)#i',$ua,$pcs)>0) {
     600            $wap['name'] = 'IEMobile';
     601            $wap['version'] = $pcs[1];
     602            $wap['os'] = 'WinCE';
     603        //Opera Mini/mobile browsers
     604        } elseif (preg_match('#(Opera\s(?:Mini|Mobile))[/ ]([0-9\.]+)#',$ua,$pcs)>0) {
     605            $wap['name'] = $pcs[1];
     606            $wap['version'] = $pcs[2];
    589607
    590608        //NetFront and other mobile/embedded browsers
    591609        } elseif (preg_match("#(NetFront|NF\-Browser)/([0-9\.]+)#i",$ua,$pcs)) {
    592             $ismobile = true;
    593610            $wap['name'] = "NetFront";
    594611            $wap['version'] = $pcs[2];
    595         } elseif (preg_match("#[^a-z0-9](Bolt|Iris|Minimo|Novarra\-Vision|Polaris)/([0-9\.]+)#i",$ua,$pcs)) {
    596             $ismobile = true;
     612        } elseif (preg_match("#[^a-z0-9](Bolt|Iris|Jasmine|Minimo|Novarra\-Vision|Polaris)/([0-9\.]+)#i",$ua,$pcs)) {
    597613            $wap['name'] = $pcs[1];
    598614            $wap['version'] = $pcs[2];
    599615        } elseif (preg_match("#(UP\.browser|SMIT\-Browser)/([0-9\.]+)#i",$ua,$pcs)) {
    600             $ismobile = true;
    601616            $wap['name'] = $pcs[1];
    602617            $wap['version'] = $pcs[2];
    603618        } elseif (preg_match("#\((jig\sbrowser).*\s([0-9\.]+)[^a-z0-9]#i",$ua,$pcs)) {
    604             $ismobile = true;
    605619            $wap['name'] = $pcs[1];
    606620            $wap['version'] = $pcs[2];
    607621        } elseif (preg_match("#[^a-z]Obigo#i",$ua,$pcs)) {
    608             $ismobile = true;
    609622            $wap['name'] = 'Obigo';
    610623        } elseif (preg_match("#openwave(\suntrusted)?/([0-9\.]+)#i",$ua,$pcs)) {
    611             $ismobile = true;
    612624            $wap['name'] = 'OpenWave';
    613625            $wap['version'] = $pcs[2];
     626        }
     627        if (!empty($wap['name'])) {
     628            $ismobile = true;
    614629        }
    615630
     
    649664                }
    650665            }
    651         }
    652         //TODO: check for wireless transcoder service user agents
    653         if (!$ismobile && preg_match('#wireless\stranscoder#i',$ua)>0) {
    654             $ismobile=true;
    655         }
    656         if ($debug_mode) {
     666            //TODO: check for wireless transcoder service user agents
     667            if (!$ismobile && preg_match('#wireless\stranscoder#i',$ua)>0) {
     668                $ismobile=true;
     669            }
     670        }
     671        //set os = device, if missing
     672        if ($ismobile) {
     673            if (!empty($wap['device'])) {
     674                if (empty($wap['name'])) {
     675                    $wap['name'] = $wap['device'];
     676                } elseif (empty($wap['os'])) {
     677                    $wap['os'] = $wap['device'];
     678                }
     679            }
     680        }
     681        if ($wdebug_mode) {
    657682            echo "\n".'<br />uadetector: wap->name='.$wap['name']."&nbsp; ".'wap->device='.$wap['device']; //debug
    658683        }
     
    661686        }
    662687        if ($ismobile) {
     688            if (empty($wap['os'])) $wap['os'] = "WAP";
    663689            return $wap;
    664690        } else {
     
    674700     */
    675701    function isSpiderAgent($agent="") {
    676         global $debug_mode, $do_profile;
     702        global $wdebug_mode, $do_profile;
    677703        $ua="";
    678704        $is_current_ua = false;
     
    692718            $spider['agenttype']= 'F';
    693719       
    694         // #12 FeedFetcher Google
     720        // #12 Twiceler
     721        } elseif (preg_match('#^Mozilla/\d\.\d\s\(Twiceler\-(\d\.\d)\shttp://www\.cuill?\.com/twiceler/robot\.html\)$#',$ua,$match)>0) {
     722            $spider['name'] = 'Twiceler';
     723            $spider['version']=$match[1];
     724            $spider['agenttype']= 'R';
     725
     726        // #13 FeedFetcher Google
    695727        } elseif (preg_match('#^Feedfetcher\-Google[;\s\(\+]+http\://www\.google\.com/feedfetcher\.html[;\)\s]+(?:(\d)\ssubscriber)?#',$ua,$match)>0) {
    696728            $spider['name'] = 'FeedFetcher-Google';
     
    753785                $spider['version']=$match[2];
    754786            }
     787            if (strlen($match[1]) < 5) {
     788                $spider['name'] = $match[1]. " Spider";
     789            }
    755790
    756791        //TODO: Libwww spiders
     
    763798                $spider['version'] = $match[3];
    764799            }
     800        } elseif (preg_match('#^Mozilla\/\d\.\d\s\(compatible;\s([a-z_ ]+)(?:[-/](\d+\.\d+))?;\s.?http://(?:www\.)?[a-z]+(?:[a-z\.]+)\.(?:[a-z]{2,4})/?[a-z/]*(?:\.s?html?|\.php|\.aspx?)?\)$#i',$ua,$match)>0) {
     801            $spider['name'] = $match[1];
     802            if (!empty($match[2])) {
     803                $spider['version'] = $match[2];
     804            }
     805
    765806        // #Assume bot if user-agent 1st word and a contact domain are the same name, ex: Feedburner-feedburner.com, CazoodleBot,
    766807        } elseif (preg_match('/([a-z\_\s\.]+)[\s\/\-_]?(v?[0-9\.]+)?.*(?:http\:\/\/|www\.)(\1)\.[a-z0-9_\-]+/i',$ua,$match)>0) {
     
    790831
    791832        // #Assume bot if user-agent includes contact email
     833        } elseif (preg_match('#^Mozilla\/\d\.\d\s\(compatible;\s([a-z_ ]+)(?:[-/](\d+\.\d+))?;\s[^a-z0-9]?([a-z0-9\.]+@[a-z0-9]+\.[a-z]{2,4})\)$#i',$ua,$match)>0) {
     834            $spider['name'] = $match[1];
     835            if (!empty($match[2])) {
     836                $spider['version'] = $match[2];
     837            }
    792838        } elseif (preg_match('/^(([a-z]+)\s?(bot|crawler|robot|spider|\s[a-z]+)?)[\/\-\s_](v?[0-9\.]+)?.*[^a-z]+(?:\1|\2|\3)(?:\@|\s?at\s?)[a-z\-_]{2,}(?:\.|\s?dot\s)[a-z]{2,4}/i',$ua,$match)>0) {
    793839            $spider['name'] = $match[1];
     
    888934            $spider['agenttype']= "S";
    889935        }
    890         if ($debug_mode) {
     936        if ($wdebug_mode) {
    891937            echo "\n".'<br />uadetector: spider->name='.$spider['name']."&nbsp; "; //debug
    892938        }
     
    916962            }
    917963        }
    918         //distinguish feed readers from other spiders
     964        //separate feed readers from spiders
    919965        if (preg_match("/([0-9]+)\s?subscriber/i",$ua,$subscriber) >0) {
    920966            // It's a feedreader with some subscribers
     
    9681014     */
    9691015    function isWTF($ua="") {
    970         global $debug_mode, $do_profile;
     1016        global $wdebug_mode, $do_profile;
    9711017        //recheck browsers or check PHP's browser capabilities file
    9721018        if (isset($this->done_browsers) && !$this->done_browsers) {
     
    9811027                $this->setClassVars($unknown_agent);
    9821028            }
    983             if ($debug_mode) {
     1029            if ($wdebug_mode) {
    9841030                echo "\n".'<br />uadetector: unknown_agent->name='.$unknown_agent['name']."&nbsp; "; //debug
    9851031            }
     
    9961042     */
    9971043    function OSversion($os="",$platform="",$ua="") {
    998         global $debug_mode, $do_profile;
     1044        global $wdebug_mode, $do_profile;
    9991045        if ($do_profile) {
    10001046            profiler_beginSection('_____ua::OSversion');
     
    12271273     */
    12281274    function linuxOSversion($os="") {
    1229         global $debug_mode, $do_profile;
     1275        global $wdebug_mode, $do_profile;
    12301276        if (empty($os)) { $os = $this->agent; }
    12311277        if (empty($os)) { return false; }
     
    12931339     */
    12941340    function webkitVersion($webkit="",$ua="") {
    1295         global $debug_mode;
     1341        global $wdebug_mode;
    12961342        $browser = "Safari";
    12971343        $vers = "";
    1298         if ($debug_mode) {
     1344        if ($wdebug_mode) {
    12991345            echo "<br />webkit=".$webkit."\n"; //debug
    13001346        }
    13011347        if (empty($webkit)) {
    13021348            return false;
    1303         } elseif (preg_match("#^([a-zA-Z]+)/([0-9](?:[A-Za-z\.0-9]+))(\sMobile)?#",$webkit,$match)>0) {
     1349        } elseif (preg_match("#^([a-zA-Z]+)/([0-9]+(?:[A-Za-z\.0-9]+))(\sMobile)?#",$webkit,$match)>0) {
    13041350            if ($match[1] != "Version") { //Chrome,Iron,Shiira
    13051351                $browser = $match[1];
     
    13961442     */
    13971443    function getBrowscap($ua="") {
    1398         global $debug_mode;
     1444        global $wdebug_mode;
    13991445        if (empty($ua)) $ua = $this->agent;
    14001446        $browsercap = false;
     
    14071453        if (ini_get("browscap")!="") {
    14081454            $browsercap = get_browser($ua,true);
    1409             if ($debug_mode) {
     1455            if ($wdebug_mode) {
    14101456                echo "\n<br/>Browsercap=";
    14111457                print_r($browsercap);
  • wassup/trunk/lib/upgrade.php

    r315060 r444137  
    77 * Contains functions to create and update the tables required for WassUp
    88 *   install and upgrade. These functions are loaded only when plugin is
    9  *   activated via the 'wassup_install' hook function.
     9 *   activated through the 'wassup_install' hook function.
    1010 * @since version 1.8
    1111 * @author Helene D.
     
    1414/**
    1515 * Table install manager function that calls either 'wCreateTable' or
    16  * 'wUpdateTable' depending on whether this is a new install or upgrade.
     16 * 'wUpdateTable' depending on whether this is a new install or an upgrade.
    1717 * @param none
    1818 * @return boolean
     
    2525    $wassup_tmp_table = $wassup_table."_tmp";
    2626    $wassup_meta_table = $wassup_table."_meta";
    27     $charset=true;
    28     $success=false;
    29 
    30     //CREATE new table
    31     if ($wpdb->get_var("SHOW TABLES LIKE '$wassup_table'") != $wassup_table) {
     27    $wcharset=true;
     28    $wsuccess=false;
     29    //$wpdb->show_errors = true;
     30
     31    //CREATE/UPGRADE table
     32    if ($wpdb->get_var("SHOW TABLES LIKE '{$wassup_table}'") == $wassup_table) {
     33        $wcharset=false;
     34        $wsuccess=wUpdateTable(); //<== wassup_tmp is added here, if missing
     35    } else {
    3236        if (wCreateTable()) {   //1st attempt
    33             $charset=true;
     37            $wcharset=true;
    3438        }
    3539        //2nd attempt: no character set in table
    36         if ($wpdb->get_var("SHOW TABLES LIKE '$wassup_table'") != $wassup_table) {
    37             $charset=false;
    38             wCreateTable("",$charset);
    39         }
    40 
    41     } else {
    42         //'wUpdateTable' now uses 'wCreateTable' and Wordpress' 'dbdelta' function to upgrade table structure
    43         $charset=false;
    44         wUpdateTable(); //<== wassup_tmp is added here, if missing
     40        if ($wpdb->get_var("SHOW TABLES LIKE '{$wassup_table}'") != $wassup_table) {
     41            $wcharset=false;
     42            wCreateTable("",$wcharset);
     43        }
     44
    4545    }
    4646
    4747    //check that install was successful, issue warnings, start tracker
    48     if ($wpdb->get_var("SHOW TABLES LIKE '$wassup_table'") == $wassup_table) {
    49         $success=true;
     48    if ($wsuccess || $wpdb->get_var("SHOW TABLES LIKE '{$wassup_table}' ") == $wassup_table) {
     49        $wsuccess=true;
    5050        //double-check that temp and meta were created
    51         if ($wpdb->get_var("SHOW TABLES LIKE '$wassup_tmp_table'") != $wassup_tmp_table) {
    52             wCreateTable($wassup_tmp_table,$charset);
    53         }
    54         if ($wpdb->get_var("SHOW TABLES LIKE '$wassup_meta_table'") != $wassup_meta_table) {
    55             wCreateTable($wassup_meta_table,$charset);
    56         }
    57     }
    58     return $success;   
     51        if ($wpdb->get_var("SHOW TABLES LIKE '{$wassup_tmp_table}' ") != $wassup_tmp_table) {
     52            wCreateTable($wassup_tmp_table,$wcharset);
     53        }
     54        if ($wpdb->get_var("SHOW TABLES LIKE '{$wassup_meta_table}' ") != $wassup_meta_table) {
     55            wCreateTable($wassup_meta_table,$wcharset);
     56        }
     57    }
     58    //$wpdb->show_errors = false;
     59    return($wsuccess);
    5960} //#end function wassup_tableInstaller
    6061
     
    6566 * @return boolean
    6667 */
    67 function wCreateTable($table="",$withcharset=true) {
    68     global $wpdb, $current_user, $wassupversion, $wassup_options;
     68function wCreateTable($wtable="",$withcharset=true) {
     69    global $wpdb, $current_user, $wp_version, $wassupversion, $wassup_options;
    6970
    7071    $wassup_table = (!empty($wassup_options->wassup_table))? $wassup_options->wassup_table: $wpdb->prefix . "wassup";
    7172    $wassup_tmp_table = $wassup_table."_tmp";
    7273    $wassup_meta_table = $wassup_table."_meta";
    73     if (empty($table)) $table_name = $wassup_table;
    74     else $table_name = $table;
     74    if (empty($wtable)) $wtable_name = $wassup_table;
     75    else $wtable_name = $wtable;
    7576    $is_new_table = false;
    7677
     
    8990    $charset_collate = '';
    9091    //Add charset on new table only
    91     if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
     92    if ($wpdb->get_var("SHOW TABLES LIKE '{$wtable_name}'") == $wtable_name) {
    9293        $withcharset = false;
    9394    } else {
     
    106107
    107108    //wassup table structure
    108     if ($table_name == $wassup_table || $table_name == $wassup_tmp_table) {
    109         $sql_createtable = "CREATE TABLE $table_name (
    110   `id` mediumint(9) NOT NULL auto_increment,
     109    if ($wtable_name == $wassup_table || $wtable_name == $wassup_tmp_table) {
     110        $sql_createtable = "CREATE TABLE $wtable_name (
     111  `id` mediumint(9) unsigned NOT NULL auto_increment,
    111112  `wassup_id` varchar(60) NOT NULL,
    112113  `timestamp` varchar(20) NOT NULL,
    113   ip varchar(50) default NULL,
     114  `ip` varchar(50) default NULL,
    114115  `hostname` varchar(150) default NULL,
    115116  `urlrequested` text,
    116117  `agent` varchar(255) default NULL,
    117   `referrer` text default NULL,
     118  `referrer` text,
    118119  `search` varchar(255) default NULL,
    119   `searchpage` int(11) default 0,
     120  `searchpage` int(11) unsigned default '0',
    120121  `os` varchar(15) default NULL,
    121122  `browser` varchar(50) default NULL,
     
    125126  `spider` varchar(50) default NULL,
    126127  `feed` varchar(50) default NULL,
    127   `username`  VARCHAR(50) default NULL,
    128   `comment_author` VARCHAR(50) default NULL,
    129   `spam` VARCHAR(5) default 0,
     128  `username` varchar(50) default NULL,
     129  `comment_author` varchar(50) default NULL,
     130  `spam` varchar(5) default '0',
    130131  `url_wpid` varchar(50) default NULL,
    131   UNIQUE KEY id (`id`),
    132   KEY idx_wassup (wassup_id(32),`timestamp`),
    133   INDEX (os),
    134   INDEX (browser),
    135   INDEX (`timestamp`)) {$charset_collate};";
     132  UNIQUE KEY `id` (`id`),
     133  KEY `idx_wassup` (`wassup_id`(32),`timestamp`),
     134  INDEX (`os`),
     135  INDEX (`browser`),
     136  INDEX `timestamp` (`timestamp`)) {$charset_collate};";
    136137    //Note: index (username,ip) was removed because of problems with
    137138    //  non-romanic language display
    138     //New in v.1.8: increased ip width to 50 for ipv6 support
     139    //Since v1.8: increased ip width to 50 for ipv6 support
    139140
    140141    //...Include a first record if new table (not temp table)
    141142    $sql_firstrecord = '';
    142     if ($table_name == $wassup_table && $is_new_table) {
     143    if ($wtable_name == $wassup_table && $is_new_table) {
    143144        if (!class_exists('UADetector'))
    144145            include_once (dirname(__FILE__) . '/lib/uadetector.class.php');
     
    160161            trim($ua->name.' '.$ua->majorVersion($ua->version)),
    161162            $locale, $screen_res, $logged_user);
    162 }
     163    } // end if wassup && is_new_table
    163164
    164165    //...create/upgrade wassup table
    165     if (!empty($sql_firstrecord)) {
     166
     167    //New in 1.8.3: Don't use Wordpress' "dbdelta" function on
     168    //  pre-existing "wp_wassup" table because "dbDelta" fails to
     169    //  upgrade wp_wassup's large table structure in Wordpress 3.1+
     170    //  (throws MySQL ALTER TABLE error).
     171    if ($wtable_name != $wassup_table) {
     172        $result = dbDelta($sql_createtable);
     173    } elseif (!empty($sql_firstrecord)) {
    166174        $result = dbDelta(array($sql_createtable,$sql_firstrecord));
    167     } else {
    168         $result = dbDelta($sql_createtable);
    169175    }
     176    //$wpdb->print_error(); //debug
    170177
    171178    //...return 'true' if table created successfully, false otherwise
    172179    $retvalue=true;
    173     if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
     180    if ($wpdb->get_var("SHOW TABLES LIKE '{$wtable_name}'") != $wtable_name) {
    174181
    175182        $retvalue=false;
    176183    } else {
    177         if ($table == "" && version_compare(mysql_get_server_info(),'4.1.0','>')) {
     184        if ($wtable == "" && version_compare(mysql_get_server_info(),'4.1.0','>')) {
    178185            //'CREATE TABLE LIKE' syntax not supported in MySQL 4.1 or less
    179             $upgrade = dbDelta("CREATE TABLE $wassup_tmp_table LIKE {$wassup_table}");
     186            $wupgrade = dbDelta("CREATE TABLE $wassup_tmp_table LIKE {$wassup_table}");
     187            //$wpdb->print_error(); //debug
    180188        }
    181189    }
    182190    } //end if wassup_table
    183191   
    184     //New in v1.8: "meta" table to extend wassup. Used as a temporary
     192    //Since v1.8: "meta" table to extend wassup. Used as a temporary
    185193    // data cache and can be used to capture additional visitor data
    186     if ($table == "") $table_name = $wassup_meta_table;
    187     if ($table_name == $wassup_meta_table) {
     194    if ($wtable == "") $wtable_name = $wassup_meta_table;
     195    if ($wtable_name == $wassup_meta_table) {
    188196
    189197    // Wassup Meta Table Structure:
     
    197205    // `meta_expire` is a timestamp that is an expiration date in unix
    198206    //      timestamp format...for temporary/cache-only records.
    199     $sql_createtable_meta = "CREATE TABLE `$wassup_meta_table` (
     207    $sql_create_meta = "CREATE TABLE `$wassup_meta_table` (
    200208  `meta_id` integer(15) unsigned auto_increment,
    201209  `wassup_key` varchar(150) NOT NULL,
     
    203211  `meta_value` longtext,
    204212  `meta_expire` integer(10) unsigned default '0',
    205   UNIQUE KEY (`meta_id`),
     213  UNIQUE KEY meta_id (`meta_id`),
    206214  INDEX (`wassup_key`),
    207   INDEX (`meta_key`)) {$charset_collate};";
     215  INDEX (`meta_key`)) {$charset_collate}; ";
    208216
    209217    //create/upgrade wassup table
    210     $result = dbDelta($sql_createtable_meta);
     218    $result = dbDelta($sql_create_meta);
     219    //$wpdb->print_error(); //debug
    211220
    212221    //...return 'false' if table was not created
    213     if ($table == $wassup_meta_table && $wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
     222    if ($wtable == $wassup_meta_table && $wpdb->get_var("SHOW TABLES LIKE '{$wtable_name}'") != $wtable_name) {
    214223        $retvalue=false;
    215224    }
    216225    } //end if wassup_meta_table
    217226
    218     return $retvalue;
     227    return($retvalue);
    219228    //#TODO:
    220229    // 1. create stored procedure that selects records by timestamp
     
    238247    $wassup_tmp_table = $wassup_table."_tmp";
    239248    $wassup_meta_table = $wassup_table."_meta";
     249    $wsuccess=true;
    240250
    241251    //queue table content upgrades
     
    251261    $wpdb->query("SET wait_timeout = 180");
    252262
    253     //do table content upgrade
    254     if (!empty($upgrade_sql)) {
    255         wassup_scheduled_dbtask($upgrade_sql);
    256     }
    257 
    258     // For all upgrades: Drop and re-create all indices except 'id'
    259     //# get list of all wassup indices
    260     $qryresult = mysql_query("SHOW INDEX FROM {$wassup_table}");
    261     if ($qryresult) {
    262         $row_count = mysql_num_rows($qryresult);
    263     } else {
    264         $row_count = 0;
    265     }
    266     //# get the names of all indices
    267     $idx_names = array();
    268     $prev_key = ""; //names listed multiples times per columns in key
    269     if ($row_count > 1) {
    270         while ($row = mysql_fetch_array($qryresult,MYSQL_ASSOC)) {
    271             if ($row["Column_name"] != "id" && $row["Key_name"] != $prev_key) {
    272                 $idx_names[] = $row["Key_name"];
     263    //do table content upgrade - after table upgrade to avoid lockouts
     264    //if (!empty($upgrade_sql)) {
     265    //  wassup_scheduled_dbtask($upgrade_sql);
     266    //}
     267
     268    // For all upgrades: Drop and re-create all indices except 'id' and
     269    // 'meta_id' on 'wp_wassup' and 'wp_wassup_meta' tables
     270    $wtables = array("$wassup_table", "$wassup_meta_table");
     271    foreach ($wtables AS $wtbl) {
     272        //# get list of all wassup indices
     273        $wqryresult = mysql_query("SHOW INDEX FROM `{$wtbl}`");
     274        if ($wqryresult) {
     275            $wrow_count = mysql_num_rows($wqryresult);
     276        } else {
     277            $wrow_count = 0;
     278        }
     279        //# get the names of all indices
     280        $idx_names = array();
     281        $prev_key = ""; //names listed multiples times per columns in key
     282        if ($wrow_count > 1) {
     283        while ($wrow = mysql_fetch_array($wqryresult,MYSQL_ASSOC)) {
     284            if ($wrow["Column_name"]!= "id" && $wrow["Column_name"]!= "meta_id" && $wrow["Key_name"]!= $prev_key) {
     285                $idx_names[] = $wrow["Key_name"];
    273286            }
    274             $prev_key = $row["Key_name"];
     287            $prev_key = $wrow["Key_name"];
    275288        } //end while
    276     } //end if row_count
    277     mysql_free_result($qryresult);
    278     //# drop all the indices in $idx_names and drop temp table...
    279     //drop indices
    280     foreach ($idx_names AS $idx_drop) {
    281         mysql_query("DROP INDEX $idx_drop ON {$wassup_table}");
     289        } //end if wrow_count
     290        mysql_free_result($wqryresult);
     291        //# drop all the indices in $idx_names and drop temp table...
     292        //drop indices
     293        foreach ($idx_names AS $idx_drop) {
     294            mysql_query("DROP INDEX $idx_drop ON `{$wtbl}`");
     295        }
     296        unset ($wrow, $wrow_count, $prev_key, $idx_names);
    282297    }
    283298
    284299    //NOTE: All column updates replaced by single call to 'wcreateTable' function which uses 'dbDelta' to update table structure
    285300
    286     //## For all upgrades
    287     //# Drop and re-create all indices except 'id'
    288     //Get list of all wp_wassup indices...
    289     //$idx_cols = $wpdb->get_col("SHOW INDEX FROM $wassup_table","Column_name"); //doesn't work
    290     $qryresult = mysql_query("SHOW INDEX FROM {$wassup_table}");
    291     if ($qryresult) {
    292         $row_count = mysql_num_rows($qryresult);
    293     } else {
    294         $row_count = 0;
    295     }
    296     //store names of all indices in an array...
    297     $idx_names = array();
    298     $prev_key = ""; //names listed multiples times per columns in key
    299     if ($row_count > 1) {
    300         while ($row = mysql_fetch_array($qryresult,MYSQL_ASSOC)) {
    301             if ($row["Column_name"] != "id" && $row["Key_name"] != $prev_key) {
    302                 $idx_names[] = $row["Key_name"];
    303             }
    304             $prev_key = $row["Key_name"];
    305         } //end while
    306     } //end if row_count
    307     mysql_free_result($qryresult);
    308     //drop indices in array...
    309     foreach ($idx_names AS $idx_drop) {
    310         mysql_query("DROP INDEX $idx_drop ON {$wassup_table}");
    311     }
     301    ////## For all upgrades - redundant code
     302    ////# Drop and re-create all indices except 'id'
     303    ////Get list of all wp_wassup indices...
     304    ////$idx_cols = $wpdb->get_col("SHOW INDEX FROM $wassup_table","Column_name"); //doesn't work
     305    //$qryresult = mysql_query("SHOW INDEX FROM {$wassup_table}");
     306    //if ($qryresult) {
     307    //  $row_count = mysql_num_rows($qryresult);
     308    //} else {
     309    //  $row_count = 0;
     310    //}
     311    ////store names of all indices in an array...
     312    //$idx_names = array();
     313    //$prev_key = "";   //names listed multiples times per columns in key
     314    //if ($row_count > 1) {
     315    //  while ($row = mysql_fetch_array($qryresult,MYSQL_ASSOC)) {
     316    //      if ($row["Column_name"] != "id" && $row["Key_name"] != $prev_key) {
     317    //          $idx_names[] = $row["Key_name"];
     318    //      }
     319    //      $prev_key = $row["Key_name"];
     320    //  } //end while
     321    //} //end if row_count
     322    //mysql_free_result($qryresult);
     323    ////drop indices in array...
     324    //foreach ($idx_names AS $idx_drop) {
     325    //  mysql_query("DROP INDEX $idx_drop ON {$wassup_table}");
     326    //}
    312327    // drop wp_wassup_tmp table...
    313328    //$wpdb->query("DROP TABLE IF EXISTS $table_tmp_name"); //incorrectly causes an activation error in Wordpress
    314     mysql_query("DROP TABLE IF EXISTS $wassup_tmp_table");
     329    mysql_query("DROP TABLE IF EXISTS `{$wassup_tmp_table}`");
    315330
    316331    //call 'wCreateTable' to update tables structure and rebuild indices using wordpress' 'dbdelta' function...
    317     $success=wCreateTable();
    318 
    319     //build secondary tables, in case failed
    320     if ($wpdb->get_var("SHOW TABLES LIKE '$wassup_tmp_table'") != $wassup_tmp_table) {
     332    //NOTE: 'wcreateTable' no longer upgrades "wp_wassup" table since v.1.8.3
     333    $wsuccess=wCreateTable();
     334
     335    //New in 1.8.3: 'wCreateTable' and 'dbdelta' workaround code
     336    // Since Wordpress 3.1, Wordpress' "dbDelta" function fails to
     337    // upgrade "wp_wassup" table structure (throws MySQL ALTER TABLE
     338    // error). To work around this problem, restored column-by-column
     339    // upgrades from earlier versions of WassUp (pre 1.7) and restored
     340    // manual index rebuilds.
     341
     342    //upgrades for version 1.7 or less
     343    if (empty($wassup_options->wassup_version) OR version_compare($wassup_options->wassup_version,"1.7","<")) {
     344        // Upgrade from version < 1.3.9 - add 'spam' field to wassup table
     345        if ($wpdb->get_var("SHOW COLUMNS FROM $wassup_table LIKE 'spam'") == "") {
     346            $wpdb->query("ALTER TABLE {$wassup_table} ADD COLUMN spam VARCHAR(5) DEFAULT '0'");
     347        }
     348
     349        // Upgrade from version <= 1.5.1 - increase 'wassup_id' size
     350        $wassup_col = $wpdb->get_results("SHOW COLUMNS FROM $wassup_table LIKE 'wassup_id'");
     351        foreach ($wassup_col as $wID) {
     352            if ($wID->Type != "varchar(60)") {
     353                $wpdb->query("ALTER TABLE {$wassup_table} CHANGE COLUMN wassup_id wassup_id varchar(60) DEFAULT NULL");
     354            }
     355        }
     356        // - increase size of 'searchengine' and 'spider' fields
     357        $col_size = $wpdb->get_results("SHOW COLUMNS FROM $wassup_table LIKE 'searchengine'");
     358        foreach ($col_size as $wCol) {
     359            if ($wCol->Type != "varchar(25)") {
     360                $wpdb->query("ALTER TABLE {$wassup_table} CHANGE COLUMN searchengine searchengine varchar(25) DEFAULT NULL");
     361            }
     362        }
     363        $col_size = $wpdb->get_results("SHOW COLUMNS FROM $wassup_table LIKE 'spider'");
     364        foreach ($col_size as $wCol) {
     365            if ($wCol->Type != "varchar(50)") {
     366                $wpdb->query("ALTER TABLE {$wassup_table} CHANGE COLUMN spider spider varchar(50) DEFAULT NULL");
     367            }
     368        }
     369    } //end if wassup_version
     370    //upgrades for versions 1.7 thru 1.8.2
     371    if (empty($wassup_options->wassup_version) OR version_compare($wassup_options->wassup_version,"1.8.3","<")) {
     372        //Since v1.8: add new field 'url_wpid' for post_id tracking
     373        if ($wpdb->get_var("SHOW COLUMNS FROM $wassup_table LIKE 'url_wpid'") == "") {
     374            $wpdb->query("ALTER TABLE {$wassup_table} ADD COLUMN url_wpid varchar(50) DEFAULT NULL");
     375        }
     376        //Since v1.8: increase size of 'ip' field for IPv6 addresses
     377        $wpdb->query("ALTER TABLE {$wassup_table} CHANGE COLUMN ip `ip` varchar(50) DEFAULT NULL");
     378    }
     379    //TODO: show an upgrade warning error when table structure is not updated
     380    //rebuild indices on 'wp_wassup' - this also optimizes
     381    //...could take a long time, so run in background in case of timeout
     382    ignore_user_abort(1);
     383    $wpdb->query("ALTER TABLE {$wassup_table} ADD KEY idx_wassup (wassup_id(32),`timestamp`)");
     384    $wpdb->query("ALTER TABLE {$wassup_table} ADD INDEX (os)");
     385    $wpdb->query("ALTER TABLE {$wassup_table} ADD INDEX (browser)");
     386    $wpdb->query("ALTER TABLE {$wassup_table} ADD INDEX (`timestamp`)");
     387
     388    //build secondary tables, in case upgrade failed in 'wCreateTable'
     389    if ($wpdb->get_var("SHOW TABLES LIKE '{$wassup_tmp_table}'") != $wassup_tmp_table) {
    321390        wCreateTable($wassup_tmp_table,false);
    322391    }
    323     if ($wpdb->get_var("SHOW TABLES LIKE '$wassup_meta_table'") != $wassup_meta_table) {
     392    if ($wpdb->get_var("SHOW TABLES LIKE '{$wassup_meta_table}'") != $wassup_meta_table) {
    324393        wCreateTable($wassup_meta_table,false);
    325394    }
    326395
    327     if ($wpdb->get_var("SHOW TABLES LIKE '$wassup_table'") == $wassup_table) {
    328         //table upgrade warning error
    329         return true;
    330     } else {
    331         //table upgrade fatal error
    332         return false;
    333     }
     396    if ($wsuccess || $wpdb->get_var("SHOW TABLES LIKE '{$wassup_table}'") == $wassup_table) {
     397        $wsuccess=true;
     398    }
     399
     400    //lastly do table content upgrade, if any
     401    if ($wsuccess) {
     402        if (!empty($upgrade_sql)) {
     403            wassup_scheduled_dbtask($upgrade_sql);
     404        }
     405    }
     406    return($wsuccess);
    334407} //end function wUpdateTable
    335408
     
    351424        if (file_exists($footer_file)) {
    352425            $footer = file_get_contents($footer_file);
    353             //Note: Commented out 'wp_footer()' calls will match as true in test below...should be skipped
     426            //Note: if 'wp_footer()' is commented-out in template code, it will still match as true in test below
    354427            if (stristr($footer,'wp_footer(')!==false || stristr($footer,'wp_footer (')!==false) $result=true;
    355428            else $result=false;
  • wassup/trunk/lib/wassup.class.php

    r315060 r444137  
    1111 *   settings in Wordpress' wp_options table and to output those
    1212 *   values for use in forms.
    13  * @author: Helene Duncker. 2/24/08, 6/21/09, 2009-11-15
     13 * @author: Helene Duncker. 2/24/08, 6/21/09, 2009-11-15, 2011-04-17
    1414 */
    1515class wassupOptions {
     
    2222    var $wassup_default_spy_type = "";
    2323    var $wassup_default_limit = "10";
    24     var $wassup_top10 ; //array containg top ten preferences
     24    var $wassup_top10 ; //array containg top stats preferences
    2525    var $wassup_dashboard_chart;   
    2626    var $wassup_geoip_map; 
    2727    var $wassup_googlemaps_key;
     28    var $wassup_spy_speed = "5000"; //New in 1.8.3
    2829    var $wassup_time_format;
    29     var $wassup_time_period; //new in 1.8 - for visitor details default date/time range
     30    var $wassup_time_period;    //since 1.8 - visitor details default range
    3031
    3132    /* recording settings */
     
    4647
    4748    /* table/file management settings */
    48     //var $wassup_savepath; //deprecated
     49    //var $wassup_savepath; //deprecated
    4950    var $delete_auto;
    50     var $delete_filter; //new in 1.8 for deleting select records
     51    var $delete_filter; //since 1.8 - auto delete select records
    5152    var $wassup_remind_mb;
    5253    var $wassup_remind_flag;
     
    5657    var $wassup_table;  //since 1.7.2 - WassUp table name
    5758    var $wassup_dbengine;   //since 1.7.2 - MySQL table engine type
    58     var $wassup_cache;  //new in 1.8 for using wassup_meta table as cache
     59    var $wassup_cache;  //since 1.8 - use wassup_meta table as cache
    5960
    6061    /* chart display settings */
     
    7879
    7980    /* temporary action settings */
    80     var $wassup_alert_message;  //used to display alerts
     81    var $wassup_alert_message;  //to display alerts
    8182    var $wmark;
    8283    var $wip;
     
    102103     * @return array
    103104     */
    104     function defaultSettings() {
     105    function defaultSettings($dsetting="") {
    105106        global $wpdb;
     107        $top10 = array( "toplimit"=>"10",   //new in 1.8.3 - top stats list size
     108                "topsearch"=>"1",
     109                "topreferrer"=>"1",
     110                "toprequest"=>"1",
     111                "topbrowser"=>"1",
     112                "topos"=>"1",
     113                "toplocale"=>"0",
     114                "topvisitor"=>"0",
     115                "toppostid"=>"0",   //new in v1.8.3 - top article by post-id
     116                "topreferrer_exclude"=>"",
     117                "top_nospider"=>"0");   //new in v1.8.3 - exclude spiders from top stats
    106118        $defaults = array(
    107119            'wassup_active'     =>"1",
     
    133145            'wassup_geoip_map'  =>"0",
    134146            'wassup_googlemaps_key' =>"",
     147            'wassup_spy_speed'  =>"5000",
    135148            'wassup_time_format'    =>"24",
    136149            'wassup_time_period'    =>"1",
     
    151164            'wassup_uninstall'  =>"0",
    152165            'wassup_optimize'   =>current_time('timestamp'),
    153             'wassup_top10'  =>attribute_escape(serialize(array(
    154                     "topsearch"=>"1",
    155                     "topreferrer"=>"1",
    156                     "toprequest"=>"1",
    157                     "topbrowser"=>"1",
    158                     "topos"=>"1",
    159                     "toplocale"=>"0",
    160                     "topvisitor"=>"0",
    161                     "topfeed"=>"0",
    162                     "topcrawler"=>"0",
    163                     "topreferrer_exclude"=>""))),
     166            'wassup_top10'  =>attribute_escape(serialize($top10)),
     167//                  "topsearch"=>"1", - moved
     168//                  "topreferrer"=>"1", - moved
     169//                  "toprequest"=>"1", - moved
     170//                  "topbrowser"=>"1", - moved
     171//                  "topos"=>"1", - moved
     172//                  "toplocale"=>"0", - moved
     173//                  "topvisitor"=>"0", - moved
     174//                  "topfeed"=>"0", - moved
     175//                  "topcrawler"=>"0", - moved
     176//                  "topreferrer_exclude"=>""))), - moved
    164177            'whash'     =>$this->get_wp_hash(),
    165178            'wassup_version'=>"",
     
    178191            $defaults['wassup_table']= $this->wassup_table;
    179192        }
    180         return $defaults;
     193        //New in 1.8.3: return a single default value when function argument given
     194        if (!empty($dsetting)) {
     195            if ($dsetting == "top10" || $dsetting == "wassup_top10" || $dsetting == "top_stats") {
     196                return ($top10);
     197            } elseif (!empty($defaults[$dsetting])) {
     198                return ($defaults[$dsetting]);
     199            } else {
     200                return (null);
     201            }
     202        } else {
     203            return($defaults);
     204        };
    181205    } //end defaultSettings
    182206
  • wassup/trunk/readme.txt

    r433606 r444137  
    55Requires at least: 2.2
    66Tested up to: 3.2.1
    7 Stable tag: 1.8.2
     7Stable tag: 1.8.3
    88
    99Analyze your visitors traffic with real-time statistics, a lot of chronological information, charts, a sidebar widget.
     
    7373
    7474= How do I add WassUp's chart to my admin dashboard? =
    75 Go to Wassup >> Options submenu, select [General Setup] tab and check "Display small chart in dashboard", then click [Save Settings] button.
     75Enable the dashboard chart in WassUp's settings. Go to Wassup >> Options >> [General Setup] tab and check "Display small chart in dashboard", then click [Save Settings] button.
    7676
    7777= My Wordpress theme is not widget ready. Is it possible to add WassUp Widget to my site? =
     
    7979
    8080= How do I exclude a visitor from being recorded? =
    81 Go to Wassup >> Options, select [Statistics Recording] tab and enter the IP address or username to be excluded in the appropriate text area.
     81Add a username or IP to WassUp's recording exclusion settings. Go to Wassup >> Options >> [Statistics Recording] tab and enter the IP address or username to be excluded in the appropriate text area.
    8282
    8383= How do I stop (temporarily) WassUp from recording new visits on my site? =
    84 Go to Wassup >> Options, select [Statistics Recording] tab and uncheck "Enable/disable recording", then click [Save Settings] button.
     84Disable recording in WassUp's settings. Go to Wassup >> Options >> [Statistics Recording] tab and uncheck "Enable/disable recording", then click [Save Settings] button.
     85
     86= My popular web site is hosted on a shared server that has database size limits. How do I make sure that WassUp's table size never goes over my allotted quota? =
     87Change WassUp's settings to enable "auto delete" of old records and to set a warning notice to be emailed to you when WassUp's table growth exceeds a preset size limit. Go to Wassup >> Options >> [Manage Files & Database] tab to enable these settings.
    8588
    8689= Can Wassup record visits on a web site that is not Wordpress? =
     
    9396[WP Widget Cache](http://wordpress.org/extend/plugins/wp-widget-cache/) is the only caching plugin verified to work with WassUp. However, some WassUp users have reported success using [DB Cache Reloaded](http://wordpress.org/extend/plugins/db-cache-reloaded/) and [Quick Cache](http://wordpress.org/extend/plugins/quick-cache/) plugins with WassUp.
    9497
    95 = Why does WassUp stats show more page views than actual pages clicked by a user? =
     98= Why does WassUp stats sometimes show more page views than actual pages clicked by a user? =
    9699"Phantom" page views can occur when a user's browser does automatic feed retrieval, link pre-fetching, or a page refresh. WassUp tracks these because they are valid requests from that user's browser and are indistinguishable from user link clicks.
    97100   
    98101= How do I uninstall WassUp? =
    99 To completely remove WassUp's settings and tables from Wordpress, go to Wassup >> Wassup-Options, select [Uninstall] tab, check the "Uninstall" box, click the "[Save Settings]" button, then deactivate WassUp in "Plugins".
     102To completely remove WassUp's settings and tables from Wordpress, go to Wassup >> Options >> [Uninstall] tab, check the "Uninstall" box, click the "[Save Settings]" button, then deactivate WassUp in "Plugins".
    100103
    101104Visit [http://www.wpwp.org](http://trac.wpwp.org/wiki/Documentation) for more FAQs.
     
    142145== Changelog ==
    143146
     147= 1.8.3 =
     148= Urgent bugfix, compatibility, and feature improvement upgrade =
     149* fixed typo that caused a php "foreach" error in v.1.8.2.
     150* fixed table upgrade function to prevent errors that can cause activation failure.
     151* new "Top Stats" settings for improved statistics:
     152* 1. list length - an input field to customize "top stats" list length size
     153* 1. "Top Articles" - a top stats selection to display the most popular articles (posts and pages) by post title, and
     154* 1. "exclude spiders" - a checkbox option to exclude all spiders from top stats.
     155* new option for manual adjust of SPY data speed.
     156* improved tracking of logged-in users.
     157* improved detection of referrer spammers and faked referrer strings.
     158* improved detection of spiders, mobile browsers and google chrome.
     159* improved search engine and search phrase detection.
     160* improved namespace compatibility with other Wordpress plugins.
     161* updated jQuery library to v.1.6.4 and jqueryUI library to v.1.8.16
     162* miscellaneous minor code and style changes.
     163
    144164= 1.8.2 =
    145165= Urgent bugfix, compatibility and feature improvement upgrade =
    146 * fixed regex bug that caused a `preg.match` compilation warning error to display in some configurations.
    147 * fixed a typo in `wassup_install` function and updated code to suppress warning errors when 1st table install attempt fails.
    148 * added a javascript cookie to footer function for better screen resolution tracking in IE.
    149 * added 'Google Web Preview' snapshot bot to list of known spiders.
    150 * added code to detect faked referrer strings.
    151 * added new referrer spammers and removed obsolete domains from spammer lists.
    152 * added validity check to refresh timer to limit user input range to between 0 and 180 minutes (3 hours). An input value of 0 disables the timer.
    153 * improved search engine/search phrase detection.
    154 * improved namespace compatibility with other plugins.
     166* fixed a regex bug that caused a `preg.match` compilation warning in some configurations.
     167* fixed a typo in `wassup_install` function that caused plugin activation to fail in some configurations.
     168* updated refresh timer to have a range limit (0-180 min.) with a value of 0 disabling the timer.
     169* improved spider detection.
     170* improved referrer spam detection.
     171* improved screen resolution detection for IE.
    155172* miscellaneous minor code and style changes.
    156173
     
    158175= Urgent bugfix and code improvement upgrade =
    159176* fixed bug that caused `set_time_limit` and other warning errors to display to visitors.
    160 * improved upgrade instructions in `readme.txt`.
     177* new upgrade instructions in `readme.txt`.
    161178* miscellaneous minor code changes.
    162179 
     
    189206== Upgrade Notice ==
    190207
    191 = 1.8.2 =
    192 * Urgent bug fix and feature improvement upgrade. Required for WassUp 1.8+ users. Read plugin install instructions for important upgrade information.
     208= 1.8.3 =
     209* Urgent bug fix, compatibility, and feature improvement upgrade. Required for WassUp 1.8+ users. Read plugin install instructions for important upgrade information.
    193210
    194211== Infos ==
     
    196213You could find every informations and much more at [http://www.wpwp.org](http://www.wpwp.org) - [http://trac.wpwp.org](http://trac.wpwp.org/wiki/Documentation) - [http://www.wpwp.org/forums](http://www.wpwp.org/forums/)
    197214
    198 Credits to: [Jquery](http://www.jquery.com) for the amazing Ajax framework, [FAMFAMFAM](http://www.famfamfam.com/) for the flags icons and a big thanks to [Helene D.](http://www.techfromhel.com/) for her help to improve WassUp!
    199 
     215Credits to: [Jquery](http://www.jquery.com) for the amazing Ajax framework, [FAMFAMFAM](http://www.famfamfam.com/) for the flags icons and a big thanks to [Helene D.](http://techfromhel.webege.com/) for her help to improve WassUp!
     216
  • wassup/trunk/wassup.php

    r433606 r444137  
    44Plugin URI: http://www.wpwp.org
    55Description: Analyze your visitors traffic with real-time stats, charts, and a lot of chronological information. Includes a sidebar widget of current online visitors and other statistics and an admin dashboard widget with chart. For Wordpress 2.2 or higher. Caution: don't upgrade when your site is busy!
    6 Version: 1.8.2
     6Version: 1.8.3
    77Author: Michele Marcucci, Helene Duncker
    88Author URI: http://www.michelem.org/
    99Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
    1010
    11 Copyright (c) 2007-2010 Michele Marcucci
     11Copyright (c) 2007-2011 Michele Marcucci
    1212Released under the GNU General Public License (GPL)
    1313http://www.gnu.org/licenses/gpl.txt
     
    2424//wassup globals & constants
    2525global $wp_version, $current_user, $user_level, $wassup_options;
    26 $wassupversion="1.8.2";
     26$wassupversion="1.8.3";
    2727$wassup_cookie_value="";
    28 $debug_mode=false;  //turn on debugging (global)...Use cautiously! Will display errors from all plugins, not just WassUp
     28$wdebug_mode=false; //turn on debugging (global)...Use cautiously! Will display errors from all plugins, not just WassUp
    2929define('WASSUPDIR', dirname(__FILE__));     //new constant in v1.8
    3030define('WASSUPFOLDER', plugin_basename(dirname(__FILE__)));
     
    6767    $wassup_options = new wassupOptions; //#settings initialized here
    6868    $wassup_table = (!empty($wassup_options->wassup_table))? $wassup_options->wassup_table : $wpdb->prefix . "wassup";
     69    $wassup_meta_table = $wassup_table . "_meta";
    6970
    7071    //# wassup should not be active during install
     
    108109    } else {
    109110        echo "file: ".WASSUPDIR.'/lib/upgrade.php does not exist!';
    110         exit (1);
    111     }
    112     $success = @wassup_tableInstaller();
     111        exit(1);
     112    }
     113    $wsuccess = wassup_tableInstaller();
    113114    //double-check that main table was installed
    114     $wassup_table = (!empty($wassup_options->wassup_table))? $wassup_options->wassup_table : $wpdb->prefix . "wassup";
    115     if ($wpdb->get_var("SHOW TABLES LIKE '$wassup_table'") == $wassup_table){
     115    if ($wsuccess){
     116        $wassup_options->wassup_alert_message = "Wassup $wassupversion: ".__("Database created/upgraded successfully","wassup"); //debug
     117    } else {
     118        $wassup_options->wassup_alert_message = "Wassup $wassupversion: ".__("An error occured during the upgrade. WassUp table structure may not have been updated properly.","wassup"); //debug
     119    }
     120    if ($wpdb->get_var("SHOW TABLES LIKE '{$wassup_table}'") == $wassup_table) {
    116121        //Reset 'dbengine' MySQL setting with each upgrade...because host server settings can change
    117122        if (!empty($wassup_options->wassup_version)) {  //upgrade only
     
    119124        }
    120125        //turn off wassup_cache if meta table does not exist
    121         $wassup_meta_table = $wassup_table . "_meta";
    122126        if ($wassup_options->wassup_cache == 1) {
    123             if ($wpdb->get_var("SHOW TABLES LIKE '$wassup_meta_table'") != $wassup_meta_table) {
     127            if ($wpdb->get_var("SHOW TABLES LIKE \'$wassup_meta_table\'") != $wassup_meta_table) {
    124128                $wassup_options->wassup_cache = 0;
    125129            }
     
    128132        //show warning when 'WP_CACHE' constant is set
    129133        if (wassup_compatCheck("WP_CACHE") == true) {
    130             $wassup_options->wassup_alert_message = '<strong style="color:#c00;padding:5px;">'.__("Page caching affect WassUp's ability to generate accurate statistics. If your cache plugin does whole page caching, WassUp won't run properly. Please deactivate that plugin and remove \"WP_CACHE\" from \"wp_config.php\".","wassup").'</strong>';
     134            $wassup_options->wassup_alert_message = '<strong style="color:#c00;padding:5px;">'.__("WassUp cannot generate accurate statistics with page caching enabled.","wassup")." ".__("If your cache plugin stores whole Wordpress pages/posts as HTML documents, then WassUp won't run properly. Please deactivate your cache plugin and remove \"WP_CACHE\" from \"wp_config.php\".","wassup").'</strong>';
    131135        }
    132136        //TODO: Show warning when 'wp_footer()' does not exist in active theme template (non-cache setups only)
     
    135139        $wassup_options->wassup_version = $wassupversion;
    136140
    137         if (empty($wassup_options->wassup_alert_message)) {
    138             $wassup_options->wassup_alert_message = "Wassup $wassupversion: ".__("database created/upgraded successfully","wassup"); //debug
    139         }
    140141        $wassup_options->wassup_active = 1;  //start recording
    141142        $wassup_options->saveSettings();
     
    147148            deactivate_plugins(__FILE__);
    148149        }
    149         echo '<strong style="color:#c00;padding:5px;">'.__("Error installing WassUp tables","wassup").'.</strong>';
     150        echo '<strong style="color:#c00;padding:5px;">'.__("An error occured during WassUp table install","wassup").'</strong>'.". <br/>debug: return code: ".(int)$wsuccess." <br/>wassup table: $wassup_table &nbsp; meta table: $wassup_meta_table";
    150151        exit(1);    //exit with error
    151152    }
     
    195196/**
    196197 * Output javascript in page head for wassup tracking
    197  * @param string (optional);
     198 * @param none
    198199 * @return none;
    199200 */
    200 function wassup_head($screen_res="") {
    201     global $wassup_options, $wassupversion, $current_user;
    202 
    203     if ($wassup_options->wassup_active == "1") {
    204         //Since v.1.8: removed meta tag to reduce plugin bloat
    205         //print '<meta name="wassup-version" content="'.$wassupversion.'" />'."\n";
    206         //add screen resolution javascript to blog header
    207         if ($screen_res == "" && isset($_COOKIE['wassup_screen_res'])) {
    208             $screen_res = attribute_escape(trim($_COOKIE['wassup_screen_res']));
    209             if ($screen_res == "x") $screen_res = "";
    210         }
    211         if (empty($screen_res) && isset($_SERVER['HTTP_UA_PIXELS'])) {
    212             //resolution in IE/IEMobile header sometimes
    213             $screen_res = str_replace('X',' x ',$_SERVER['HTTP_UA_PIXELS']);
    214         }
    215         if (empty($screen_res) && isset($_COOKIE['wassup'])) {
    216             $cookie_data = explode('::',attribute_escape(base64_decode(urldecode($_COOKIE['wassup']))));
    217             $screen_res=(!empty($cookie_data[2]))?$cookie_data[2]:"";
    218         }
     201function wassup_head() {
     202    global $wassup_options, $wassupversion, $wscreen_res, $current_user;
     203
     204    //if ($wassup_options->wassup_active == "1") { //redundant, in hook
     205    //Since v.1.8: removed meta tag to reduce plugin bloat
     206    //print '<meta name="wassup-version" content="'.$wassupversion.'" />'."\n";
     207    //add screen resolution javascript to blog header
     208    if ($wscreen_res == "" && isset($_COOKIE['wassup_screen_res'])) {
     209        $wscreen_res = attribute_escape(trim($_COOKIE['wassup_screen_res']));
     210        if ($wscreen_res == "x") $wscreen_res = "";
     211    }
     212    if (empty($wscreen_res) && isset($_SERVER['HTTP_UA_PIXELS'])) {
     213        //resolution in IE/IEMobile header sometimes
     214        $wscreen_res = str_replace('X',' x ',$_SERVER['HTTP_UA_PIXELS']);
     215    }
     216    if (empty($wscreen_res) && isset($_COOKIE['wassup'])) {
     217        $cookie_data = explode('::',attribute_escape(base64_decode(urldecode($_COOKIE['wassup']))));
     218        $wscreen_res=(!empty($cookie_data[2]))?$cookie_data[2]:"";
     219    }
    219220    //Get visitor's screen resolution using javascript and a cookie.
    220221    // - Added here so javascript code is placed in document <head>
     
    223224<script type="text/javascript">
    224225//<![CDATA[
    225     var screen_res = "<?php echo $screen_res; ?>";
    226 <?php   if (empty($screen_res) && !isset($_COOKIE['wassup_screen_res'])) { ?>
     226    var screen_res = "<?php echo $wscreen_res; ?>";
     227<?php
     228    if (empty($wscreen_res) && !isset($_COOKIE['wassup_screen_res'])) { ?>
    227229    function writeCookie(name,value,hours) {
    228230        var the_cookie = name+"="+escape(value)+"; expires=";
     
    256258?>
    257259//]]>
    258 </script>
    259 <?php
    260     } // end if wassup_active == "1"
     260</script><?php
     261    echo "\n";
     262    //} // end if wassup_active == "1"
    261263} //end function wassup_head
    262264
     
    269271
    270272    //block any obvious sql injection attempts involving WassUp -Helene D. 2009-06-16
    271     if (stristr($_SERVER['REQUEST_URI'],'wassup') !==FALSE || (isset($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],'wassup') !==FALSE)) {
    272         if (preg_match('/[&?].+\=(\-(1|9)+|.*(select|update|delete|alter|drop|union|create)[ %&].*(?:from)?.*wp_\w+)/i',str_replace(array('\\','&#92;','"','%22','&#34;','&quot','&#39;','\'','`','&#96;'),'',$_SERVER['REQUEST_URI']))>0) {
     273    $request_uri = $_SERVER['REQUEST_URI'];
     274    if (!$request_uri) $request_uri = $_SERVER['SCRIPT_NAME']; // IIS
     275    if (stristr($request_uri,'wassup')!==FALSE || (isset($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],'wassup')!==FALSE)) {
     276        if (preg_match('/[&?].+\=(\-(1|9)+|.*(select|update|delete|alter|drop|union|create)[ %&].*(?:from)?.*wp_\w+)/i',str_replace(array('\\','&#92;','"','%22','&#34;','&quot','&#39;','\'','`','&#96;'),'',$request_uri))>0) {
    273277            header("HTTP/1.1 403 Forbidden");
    274278            wp_die('Illegal request - Permission Denied!');
     
    291295                }
    292296                // the safe way to load jquery into WP
    293                 wp_register_script('jquery', WASSUPURL.'/js/jquery.js',FALSE,'1.4.2');
     297                wp_register_script('jquery', WASSUPURL.'/js/jquery.min.js',FALSE,'1.6.2');
    294298            }
    295299            if ($_GET['page'] == "wassup-spia") {
     
    298302            } elseif($_GET['page'] == "wassup-options") {
    299303                //if (version_compare($wp_version, '2.7', '<')) {
    300                     wp_enqueue_script('jqueryui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js', array('jquery'), '1.8');
     304                    wp_enqueue_script('jqueryui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js', array('jquery'), '1.8.16');
    301305                //} else {
    302306                //  wp_enqueue_script('ui.core', array('jquery'));
     
    331335//Add the wassup stylesheet and other javascripts...
    332336function add_wassup_css() {
    333     global $wassup_options, $debug_mode;
     337    global $wassup_options, $wdebug_mode;
    334338
    335339    $plugin_page = $_GET['page'];
     
    344348        //preassign "GET" parameters for "action.php" in "action_param"
    345349        $action_param='&whash='.$wassup_options->whash;
    346         if ($debug_mode) {
     350        if ($wdebug_mode) {
    347351            $action_param .= '&debug_mode=true';
    348352        }
     
    367371<script type='text/javascript'>
    368372  //<![CDATA[
    369 //  var selftimerID = 0;
     373  //  var selftimerID = 0;
    370374  function selfRefresh(){
    371375    location.href='?<?php print $_SERVER['QUERY_STRING']; ?>';
    372376  }
    373 //  selftimerID = setTimeout('selfRefresh()', <?php print ($wassup_options->wassup_refresh * 60000)+2000; ?>);
     377  //  selftimerID = setTimeout('selfRefresh()', <?php print ($wassup_options->wassup_refresh * 60000)+2000; ?>);
    374378  //]]>
    375 </script>
    376 <?php           //New in 1.8.2: restrict refresh to range 0-180 minutes (3 hrs)
     379</script><?php
     380            //Since 1.8.2: restrict refresh to range 0-180 minutes (3 hrs)
    377381            $wrefresh = 0;
    378382            if (!is_numeric($wassup_options->wassup_refresh) || $wassup_options->wassup_refresh < 0  || $wassup_options->wassup_refresh > 180) {
     
    451455    //show larger icons on mouse-over
    452456    $("img.delete-icon").mouseover(function() {
    453         $(this).attr("src","<?php echo WASSUPURL.'/img/cross2.png'; ?>");
     457        $(this).attr("src","<?php echo WASSUPURL.'/img/b_delete2.png'; ?>");
    454458    }).mouseout(function() {
    455         $(this).attr("src","<?php echo WASSUPURL.'/img/cross.png'; ?>");
     459        $(this).attr("src","<?php echo WASSUPURL.'/img/b_delete.png'; ?>");
    456460    });
    457461    $("img.table-icon").mouseover(function() {
    458         $(this).attr("src","<?php echo WASSUPURL.'/img/database_table2.png'; ?>");
     462        $(this).attr("src","<?php echo WASSUPURL.'/img/b_select2.png'; ?>");
    459463    }).mouseout(function() {
    460         $(this).attr("src","<?php echo WASSUPURL.'/img/database_table.png'; ?>");
     464        $(this).attr("src","<?php echo WASSUPURL.'/img/b_select.png'; ?>");
    461465    });
    462466
     
    473477                $("div#delID" + id).fadeOut("slow");
    474478            else
    475                 $("div#delID" + id).find('p.delbut').append("<br/><br/><small style='color:#404;font-weight:bold;text-align:right;float:right;'> <nobr>Sorry, delete failed!</nobr> " + html + "</small>");
     479                $("div#delID" + id).find('p.delbut').append("<br/><br/><small style='color:#404;font-weight:bold;text-align:right;float:right;'> <nobr><?php _e('Sorry, delete failed!','wassup'); ?></nobr> " + html + "</small>");
    476480            },
    477481          error: function (XMLHttpReq, txtStatus, errThrown) {
    478               $("div#delID" + id).find('p.delbut').append("<br/><br/><small style='color:#404;font-weight:bold;text-align:right;float:right;'> <nobr>Sorry, delete failed!</nobr> " + txtStatus + ": " + errThrown + "</small>");
     482              $("div#delID" + id).find('p.delbut').append("<br/><br/><small style='color:#404;font-weight:bold;text-align:right;float:right;'> <nobr><?php _e('Sorry, delete failed!','wassup'); ?></nobr> " + txtStatus + ": " + errThrown + "</small>");
    479483            }
    480484        });
     
    486490            echo "\n"; ?>
    487491       $("div.search-ip").slideDown("slow");
    488        $("a.show-search").html("<a href='#' class='show-search'><?php _e("Hide Search", "wassup") ?></a>");
     492       $("a.show-search").html("<?php _e('Hide Search', 'wassup'); ?>");
    489493    },function() {
    490494       $("div.search-ip").slideUp("slow");
    491        $("a.show-search").html("<a href='#' class='show-search'><?php _e("Search", "wassup") ?></a>");
     495       $("a.show-search").html("<?php _e('Search', 'wassup'); ?>");
    492496       return false; <?php 
    493497        } else {
    494498            echo "\n"; ?>
    495499       $("div.search-ip").slideUp("slow");
    496        $("a.show-search").html("<a href='#' class='show-search'><?php _e("Search", "wassup") ?></a>");
     500       $("a.show-search").html("<?php _e('Search', 'wassup'); ?>");
    497501    },function() {
    498502       $("div.search-ip").slideDown("slow");
    499        $("a.show-search").html("<a href='#' class='show-search'><?php _e("Hide Search", "wassup") ?></a>");
     503       $("a.show-search").html("<?php _e('Hide Search', 'wassup'); ?>");
    500504       return false; <?php 
    501505        }
    502506        echo "\n"; ?>
    503507    });
    504     $("a.show-topten").toggle(function(){
    505        $("div.topten").slideDown("slow");
    506        $("a.show-topten").html("<a href='#' class='show-topten'><?php _e("Hide TopTen", "wassup") ?></a>");
    507     },function() {
    508        $("div.topten").slideUp("slow");
    509        $("a.show-topten").html("<a href='#' class='show-topten'><?php _e("Show TopTen", "wassup") ?></a>");
    510        return false;
    511     });
    512 
     508    /*
     509
     510    // Since v1.8.3: deleted hide/show "top stats" javascript because it is not used
     511
     512    */
    513513    $("a.toggle-all").toggle(function() {
    514514       $("div.togglenavi").slideDown("slow");
    515        $("a.toggle-all").html("<a href='#' class='toggle-all boxed'><?php _e("Collapse All", "wassup") ?></a>");
     515       $("a.toggle-all").html("<?php _e('Collapse All', 'wassup'); ?>");
    516516    },function() {
    517517       $("div.togglenavi").slideUp("slow");
    518        $("a.toggle-all").html("<a href='#' class='toggle-all boxed'><?php _e("Expand All", "wassup") ?></a>");
     518       $("a.toggle-all").html("<?php _e('Expand All', 'wassup'); ?>");
    519519       return false;
    520520    });
    521521    $("a.toggle-allcrono").toggle(function() {
    522522       $("div.togglecrono").slideUp("slow");
    523        $("a.toggle-allcrono").html("<a href='#' class='toggle-allcrono boxed'><?php _e("Expand Chronology", "wassup") ?></a>");
     523       $("a.toggle-allcrono").html("<?php _e('Expand Chronology', 'wassup'); ?>");
    524524    },function() {
    525525       $("div.togglecrono").slideDown("slow");
    526        $("a.toggle-allcrono").html("<a href='#' class='toggle-allcrono boxed'><?php _e("Collapse Chronology", "wassup") ?></a>");
     526       $("a.toggle-allcrono").html("<?php _e('Collapse Chronology', 'wassup'); ?>");
    527527       return false;
    528528    });
    529529<?php           
    530     //don't add refresh timer click function if refresh==0
     530    //Since v1.8.2: don't add timer click function when wrefresh==0
    531531    if ($wrefresh > 0) {  ?>
    532532    $("#CountDownPanel").click(function(){  //Pause|Resume countdown
     
    551551<?php } //end if page != wassup-options
    552552
    553 // Since v1.8: go and go2 javascripts deleted because they are not used
    554 
    555553if ($_GET['page'] == "wassup-options") {
    556554        //#Current active tabs are indentified after page reload with
     
    560558//<link rel="stylesheet" href="WASSUPURL.'/css/ui.tabs.css'" type="text/css" />
    561559echo "\n"; ?>
    562 <link href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css' rel='stylesheet' type='text/css'/>
     560<link href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css' rel='stylesheet' type='text/css' />
    563561<script type="text/javascript">
    564562  //<![CDATA[
    565563  jQuery(document).ready(function($) {
    566564      var $tabs = $('#tabcontainer').tabs();
    567       //$('#tabcontainer > ul').tabs({ fx: { opacity: 'toggle' } });
    568565      $('.submit-opt').click(function(){
    569566        $(this).css("background-color", "#d71");
     
    595592        limit: 12,
    596593        fadeLast: 5,
    597         ajax: '<?php echo WASSUPURL."/lib/action.php?action=spia&spiatype=".$spytype.$action_param; ?>',
    598         timeout: 5000,
     594        ajax: <?php echo "'".WASSUPURL."/lib/action.php?action=spia&spiatype=".$spytype.$action_param."',\n";
     595        if (!empty($wassup_options->wassup_spy_speed) && is_numeric($wassup_options->wassup_spy_speed)) {
     596            echo "\t\ttimeout: ".$wassup_options->wassup_spy_speed;
     597        } else {
     598            echo "\t\ttimeout: 5000";
     599        } ?>,
    599600        'timestamp': myTimestamp,
    600601        fadeInSpeed: 1100 });
     
    605606        if (!empty($wassup_options->wassup_geoip_map)) {
    606607            echo "\n"; ?>
    607         $("div#map").css({"opacity": "0.5", "background": "none"}); <?php
     608        $("div#map").css({"opacity": "0.6", "background": "none"}); <?php
    608609        } ?>
    609610    });
     
    683684 */
    684685function WassUp() {
    685     global $wpdb, $wp_version, $current_user, $user_level, $wassupversion, $wassup_options, $debug_mode;
     686    global $wpdb, $wp_version, $current_user, $user_level, $wassupversion, $wassup_options, $wdebug_mode;
    686687   
    687688    // Start getting time of execution to debug SQL query
     
    689690
    690691    //#debug...
    691     if ($debug_mode) {
     692    if ($wdebug_mode) {
    692693        $mode_reset=ini_get('display_errors');
    693694        //error_reporting(E_ALL | E_STRICT);    //debug, E_STRICT=php5 only
     
    708709    //"action_param" are preassigned "GET" parameters used for "action.php" external/ajax calls like "top ten"
    709710    $action_param='&whash='.$wassup_options->whash;
    710     if ($debug_mode) {
     711    if ($wdebug_mode) {
    711712        $action_param .= '&debug_mode=true';
    712713    }
     
    823824        }
    824825        $wassup_options->wassup_screen_res = $_POST['wassup_screen_res'];
    825         //validate wassup_refresh option input
     826        //Since v1.8.2: validate wassup_refresh input value
    826827        if (is_numeric($_POST['wassup_refresh']) && $_POST['wassup_refresh']>=0 && $_POST['wassup_refresh']<=180) {
    827828            $wassup_options->wassup_refresh = (int)$_POST['wassup_refresh'];
     
    834835            $wassup_options->wassup_googlemaps_key = $_POST['wassup_googlemaps_key'];
    835836        }
     837        if (!empty($_POST['wassup_spy_speed']) && is_numeric($_POST['wassup_spy_speed']) && (int)$_POST['wassup_spy_speed'] >1000) {
     838            $wassup_options->wassup_spy_speed = (int)$_POST['wassup_spy_speed'];
     839        }
    836840        $wassup_options->wassup_time_format = $_POST['wassup_time_format'];
    837841        $wassup_options->wassup_time_period = $_POST['wassup_time_period'];
    838842        $wassup_options->wassup_default_type = $_POST['wassup_default_type'];
    839843        $wassup_options->wassup_default_limit = $_POST['wassup_default_limit'];
    840         $top_ten = array("topsearch" => $_POST['topsearch'],
     844        //New in v1.8.3: 1) toplimit input for top stats (top10)
     845        // list size and 2) top_nospider input to exclude spiders
     846        // from all top stats
     847        $top_ten = array("toplimit" => (isset($_POST['toplimit'])? (int)$_POST['toplimit']:"10"),
     848                "topsearch" => $_POST['topsearch'],
    841849                "topreferrer" => $_POST['topreferrer'],
    842850                "toprequest" => $_POST['toprequest'],
     
    845853                "toplocale" => (isset($_POST['toplocale'])?$_POST['toplocale']:"0"),
    846854                "topvisitor" => (isset($_POST['topvisitor'])?$_POST['topvisitor']:"0"),
    847                 "topfeed" => "0",
    848                 "topcrawler" => "0",
    849                 "topreferrer_exclude" => $_POST['topreferrer_exclude']);
     855                "toppostid" => (isset($_POST['toppostid'])?$_POST['toppostid']:"0"),
     856                "topreferrer_exclude" => $_POST['topreferrer_exclude'],
     857                "top_nospider" => (isset($_POST['top_nospider'])?$_POST['top_nospider']:"0"));
    850858        $wassup_options->wassup_top10 = attribute_escape(serialize($top_ten));
    851859        $wassup_options->wassup_cache = (!empty($_POST['wassup_cache'])?"1":"0");
     
    11931201        $to_date = current_time("timestamp");   //wordpress time function
    11941202        if (isset($_GET['last']) && is_numeric($_GET['last'])) {
    1195             $last = $_GET['last'];
    1196             $stickyFilters.='&last='.$last;
     1203            $wlast = $_GET['last'];
     1204            $stickyFilters.='&last='.$wlast;
    11971205        } else {
    1198             $last = $wassup_options->wassup_time_period;
    1199         }
    1200         if ($last == 0) {
     1206            $wlast = $wassup_options->wassup_time_period;
     1207        }
     1208        if ($wlast == 0) {
    12011209            $from_date = "0";   //all time
    12021210        } else {
    1203             $from_date = $to_date - (int)(($last*24)*3600);
     1211            $from_date = $to_date - (int)(($wlast*24)*3600);
    12041212            //extend start date to within a rounded time   
    1205             if ($last < .25) {  //start on 1 minute
     1213            if ($wlast < .25) {     //start on 1 minute
    12061214                $from_date = ((int)($from_date/60))*60;
    1207             } elseif ($last < 7) {
     1215            } elseif ($wlast < 7) {
    12081216                $from_date = ((int)($from_date/300))*300;
    1209             } elseif ($last < 30) {
     1217            } elseif ($wlast < 30) {
    12101218                $from_date = ((int)($from_date/1800))*1800;
    1211             } elseif ($last < 365) {
     1219            } elseif ($wlast < 365) {
    12121220                $from_date = ((int)($from_date/86400))*86400;
    12131221            } else {
     
    12181226        //## Filter detail lists by visitor type...
    12191227        if (isset($_GET['type'])) {
    1220             $type = attribute_escape($_GET['type']);
    1221             $stickyFilters.='&type='.$type;
     1228            $wtype = attribute_escape($_GET['type']);
     1229            $stickyFilters.='&type='.$wtype;
    12221230        } else {
    1223             $type = $wassup_options->wassup_default_type;
    1224         }
    1225         if (!empty($type) && $type != 'everything') {
    1226             $whereis=$wassup_options->getKeyOptions("wassup_default_type","sql",$type);
     1231            $wtype = $wassup_options->wassup_default_type;
     1232        }
     1233        if (!empty($wtype) && $wtype != 'everything') {
     1234            $wwhereis=$wassup_options->getKeyOptions("wassup_default_type","sql",$wtype);
    12271235        } else {
    1228             $type="";
    1229             $whereis="";
     1236            $wtype="";
     1237            $wwhereis="";
    12301238        }
    12311239        //## Filter detail lists by a specific page and number
    12321240        //#  of items per page...
    1233         $items = 10;    //default
     1241        $witems = 10;   //default
    12341242        if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
    1235             //$items = htmlentities(attribute_escape($_GET['limit']));
    1236             $items = (int)$_GET['limit'];
     1243            //$witems = htmlentities(attribute_escape($_GET['limit']));
     1244            $witems = (int)$_GET['limit'];
    12371245        } elseif ($wassup_options->wassup_default_limit != '') {
    1238             $items = $wassup_options->wassup_default_limit;
    1239         }
    1240         if ((int)$items < 1 ) { $items = 10; }
     1246            $witems = $wassup_options->wassup_default_limit;
     1247        }
     1248        if ((int)$witems < 1 ) { $witems = 10; }
    12411249        //# current page selections
    12421250        if (isset($_GET['pages']) && is_numeric($_GET['pages'])) {
    1243             $pages = (int)$_GET['pages'];
     1251            $wpages = (int)$_GET['pages'];
    12441252        } else {
    1245             $pages = 1;
    1246         }
    1247         if ( $pages > 1 ) {
    1248             $limit = " LIMIT ".(($pages-1)*$items).",$items";
     1253            $wpages = 1;
     1254        }
     1255        if ( $wpages > 1 ) {
     1256            $wlimit = " LIMIT ".(($wpages-1)*$witems).",$witems";
    12491257        } else {
    1250             $limit = " LIMIT $items";
     1258            $wlimit = " LIMIT $witems";
    12511259        }
    12521260
    12531261        //## Filter detail lists by a searched item
    12541262                if (!empty($_GET['search'])) {
    1255                         $search = attribute_escape(strip_tags(html_entity_decode($_GET['search'])));
    1256             $stickyFilters.='&search='.$search;
     1263                        $wsearch = attribute_escape(strip_tags(html_entity_decode($_GET['search'])));
     1264            $stickyFilters.='&search='.$wsearch;
    12571265                } else {
    1258                         $search = "";
     1266                        $wsearch = "";
    12591267                }
    12601268
     
    12811289
    12821290        // Instantiate class to count items
    1283         $Tot = New MainItems($wassup_table,$from_date,$to_date,$whereis,$limit);
    1284         $Tot->whereis = $whereis;
    1285         $Tot->Limit = $limit;
    1286         $Tot->WpUrl = $wpurl;
     1291        $wTot = New WassupItems($wassup_table,$from_date,$to_date,$wwhereis,$wlimit);
     1292        $wTot->whereis = $wwhereis;
     1293        $wTot->Limit = $wlimit;
     1294        $wTot->WpUrl = $wpurl;
    12871295        echo "<!--heartbeat-->\n";
    12881296
    12891297        // MAIN QUERY
    1290         $main = $Tot->calc_tot("main", $search);
     1298        $wmain = $wTot->calc_tot("main", $wsearch);
    12911299        echo "<!--heartbeat-->\n";
    1292         $itemstot = $Tot->calc_tot("count", $search, null, "DISTINCT");
     1300        $witemstot = $wTot->calc_tot("count", $wsearch, null, "DISTINCT");
    12931301        echo "<!--heartbeat-->\n";
    1294         $pagestot = $Tot->calc_tot("count", $search);
     1302        $wpagestot = $wTot->calc_tot("count", $wsearch);
    12951303        echo "<!--heartbeat-->\n";
    1296         $spamtot = $Tot->calc_tot("count", $search, "AND spam>0");
     1304        $wspamtot = $wTot->calc_tot("count", $wsearch, "AND spam>0");
    12971305        // Check if some records was marked
    12981306        if ($wassup_options->wmark == "1") {
    1299             $markedtot = $Tot->calc_tot("count", $search, "AND ip = '".$wassup_options->wip."'", "DISTINCT");
     1307            $markedtot = $wTot->calc_tot("count", $wsearch, "AND ip = '".$wassup_options->wip."'", "DISTINCT");
    13001308        }
    13011309        echo "<!--heartbeat-->\n";
    13021310        // Check if some records were searched
    1303         if (!empty($search)) {
    1304             $searchtot = $Tot->calc_tot("count", $search, null, "DISTINCT");
     1311        if (!empty($wsearch)) {
     1312            $searchtot = $wTot->calc_tot("count", $wsearch, null, "DISTINCT");
    13051313        }
    13061314        //#  remove any delete request from $_SERVER['QUERY_STRING']
     
    13441352        <select style="font-size: 11px;" name="last" onChange="window.location.href=this.options[this.selectedIndex].value;"><?php
    13451353        $optionargs="?".attribute_escape($new_last."&last=");
    1346         $wassup_options->showFormOptions("wassup_time_period","$last","$optionargs"); ?>
     1354        $wassup_options->showFormOptions("wassup_time_period","$wlast","$optionargs"); ?>
    13471355        </select></td>
    13481356        <td class="legend" align="right"><?php _e('Items per page','wassup'); ?>: <select name="navi" style="font-size: 11px;" onChange="window.location.href=this.options[this.selectedIndex].value;"><?php
     
    13531361            $new_limit = $URLQuery;
    13541362        }
    1355                 $selected=$items;
     1363                $selected=$witems;
    13561364                $optionargs="?".$new_limit."&limit=";
    13571365        $wassup_options->showFormOptions("wassup_default_limit","$selected","$optionargs"); ?>
     
    13601368                <?php
    13611369                //selectable filter by type of record (wassup_default_type)
    1362                 $selected=$type;
    1363         $filter_args=str_replace("&type=$type","",$stickyFilters);
     1370                $selected=$wtype;
     1371        $filter_args=str_replace("&type=$wtype","",$stickyFilters);
    13641372        $optionargs="?page=".WASSUPFOLDER.$filter_args."&type=";
    13651373                $wassup_options->showFormOptions("wassup_default_type","$selected","$optionargs"); ?>
     
    13711379                <div id='usage'>
    13721380                        <ul>
    1373                         <li><span style="border-bottom:2px solid #0077CC;"><?php echo $itemstot; ?></span> <?php _e('Visits','wassup'); ?></li>
    1374                         <li><span style="border-bottom:2px dashed #FF6D06;"><?php echo $pagestot; ?></span> <?php _e('Pageviews','wassup'); ?></li>
    1375                         <li><span><?php echo @number_format(($pagestot/$itemstot), 2); ?></span> <?php _e('Pages/Visits','wassup'); ?></li><?php
     1381                        <li><span style="border-bottom:2px solid #0077CC;"><?php echo $witemstot; ?></span> <?php _e('Visits','wassup'); ?></li>
     1382                        <li><span style="border-bottom:2px dashed #FF6D06;"><?php echo $wpagestot; ?></span> <?php _e('Pageviews','wassup'); ?></li>
     1383                        <li><span><?php echo @number_format(($wpagestot/$witemstot), 2); ?></span> <?php _e('Pages/Visits','wassup'); ?></li><?php
    13761384        // Print spam usage only if enabled
    13771385        if ($wassup_options->wassup_spamcheck == 1) { ?>
    1378             <li><span> <a href="#TB_inline?width=400&inlineId=hiddenspam" class="thickbox"><?php echo $spamtot; ?><span class="plaintext">(<?php echo @number_format(($spamtot*100/$pagestot), 1); ?>%)</span></a></span> <?php _e('Spams','wassup'); ?></li><?php
     1386            <li><span> <a href="#TB_inline?width=400&inlineId=hiddenspam" class="thickbox"><?php echo $wspamtot; ?><span class="plaintext">(<?php echo @number_format(($wspamtot*100/$wpagestot), 1); ?>%)</span></a></span> <?php _e('Spams','wassup'); ?></li><?php
    13791387        } ?>
    13801388            </ul><br/>
     
    13841392        // Page breakdown
    13851393        // paginate only when total records > items per page
    1386         if ($itemstot > $items) {
     1394        if ($witemstot > $witems) {
    13871395            $p=new wassup_pagination();
    1388             $p->items($itemstot);
    1389             $p->limit($items);
    1390             $p->currentPage($pages);
    1391             $p->target("admin.php?page=".WASSUPFOLDER."&limit=$items&type=$type&last=$last&search=$search");
     1396            $p->items($witemstot);
     1397            $p->limit($witems);
     1398            $p->currentPage($wpages);
     1399            $p->target("admin.php?page=".WASSUPFOLDER."&limit=$witems&type=$wtype&last=$wlast&search=$wsearch");
    13921400            echo "<!--heartbeat-->\n";
    13931401            $p->calculate();
     
    14181426    <td align="right" class="legend">
    14191427        <a href="<?php echo wCleanURL(WASSUPURL.'/lib/action.php?action=topten&from_date='.$from_date.'&to_date='.$to_date.$action_param.'&width='.($res+250).'&height=440','','url');
    1420         if ($debug_mode) echo '" target="_blank';
     1428        if ($wdebug_mode) echo '" target="_blank';
    14211429        else echo '" class="thickbox';
    1422         ?>" title="Wassup <?php _e('Top Stats for Period','wassup');
     1430        ?>" title="Wassup <?php _e('Top Stats for','wassup');
    14231431        $wdformat = get_option("date_format");
    14241432        if (($to_date - $from_date) > 24*60*60) {
     
    14291437        <span class="separator">|</span>
    14301438        <a href="#" class='show-search'><?php
    1431             if (!empty($search)) {
     1439            if (!empty($wsearch)) {
    14321440                _e('Hide Search','wassup');
    14331441            } else {
     
    14361444    </tr>
    14371445    <tr><td align="left" class="legend" colspan="2"><?php
    1438         if (!empty($search)) {
    1439             echo " &nbsp; <strong>".(int)$searchtot."</strong> ".__('Matches found for search','wassup').": <strong>$search</strong>";
     1446        if (!empty($wsearch)) {
     1447            echo " &nbsp; <strong>".(int)$searchtot."</strong> ".__('Matches found for search','wassup').": <strong>$wsearch</strong>";
    14401448        } else {
    14411449            echo "<br/>";
     
    14431451    </td>
    14441452    <td align="right" class="legend">
    1445         <div class="search-ip" <?php if (empty($search)) echo 'style="display: none;"'; ?>>
     1453        <div class="search-ip" <?php if (empty($wsearch)) echo 'style="display: none;"'; ?>>
    14461454        <form action="" method="get">
    14471455        <input type="hidden" name="page" value="<?php echo WASSUPFOLDER; ?>" /><?php
    14481456        if (!empty($stickyFilters)) {
    14491457            $wfilterargs=wGetQueryPairs($stickyFilters);
    1450         if (!empty($wfilterargs)) {
    1451             foreach ($w_filterargs AS $wfilter) {
    1452                 $wfilterval=explode('=',$wfilter);
    1453                 if (!empty($wfilterval[0]) && $wfilterval[0]!= 'type') { ?>
    1454         <input type="hidden" name="<?php echo $wfilterval[0].'" value="'.$wfilterval[1]; ?>" /><?php
    1455                 }
    1456             }
    1457         } } ?>
    1458         <input type="text" size="25" name="search" value="<?php if ($search != "") print attribute_escape($search); ?>" /><input type="submit" name="submit-search" value="search" />
     1458            if (!empty($wfilterargs)) {
     1459                foreach ($wfilterargs AS $wfilter) {
     1460                    $wfilterval=explode('=',$wfilter);
     1461                    if (!empty($wfilterval[0]) && $wfilterval[0]!= 'type') {
     1462                        echo "\n"; ?>
     1463                        <input type="hidden" name="<?php echo $wfilterval[0].'" value="'.$wfilterval[1]; ?>" /><?php
     1464                    }
     1465                }
     1466            }
     1467        }
     1468        echo "\n"; ?>
     1469        <input type="text" size="25" name="search" value="<?php if ($wsearch != "") print attribute_escape($wsearch); ?>" /><input type="submit" name="submit-search" value="search" />
    14591470        </form>
    14601471        </div> <!-- /search-ip -->
     
    14641475    print $expcol;
    14651476        //# Show Page numbers/Links...
    1466     if ($itemstot > $items) {
     1477    if ($witemstot > $witems) {
    14671478        echo '<div id="pag" align="center">'.$p->show()."</div>\n";
    14681479        }
    14691480    //# Detailed List of Wassup Records...
    1470     if ($itemstot >0 && count($main) >0) {
    1471     foreach ($main as $rk) {
     1481    if ($witemstot >0 && count($wmain) >0) {
     1482    foreach ($wmain as $rk) {
    14721483        $timestampF = $rk->max_timestamp;
    14731484        $dateF = gmdate("d M Y", $timestampF);
     
    15601571        } ?>
    15611572        <li><?php echo 'Wassup ID'.': <span class="raw">'.$rk->wassup_id.'</span>'; ?></li>
    1562         <li><?php echo __("End timestamp","wassup").': <span class="raw">'.$datetimeF.' ( '.$rk->max_timestamp.' )</span>'; ?></li>
     1573        <li><?php
     1574        if ($numurl > 1) _e("End timestamp","wassup");
     1575        else _e("Timestamp","wassup");
     1576        echo ': <span class="raw">'.$datetimeF.' ( '.$rk->max_timestamp.' )</span>'; ?></li>
    15631577        </ul>
    15641578        </div> <!-- raw-wassup_id -->
     
    15861600            <a href="?<?php echo attribute_escape($URLQuery.'&wmark=0'); ?>" style="text-decoration:none;"><img class="unmark-icon" src="<?php echo WASSUPURL.'/img/error_delete.png" alt="'.__('unmark','wassup').'" title="'.__('UnMark IP','wassup'); ?>" /></a><?php
    15871601        } else { ?>
    1588             <a href="#" class="deleteID" id="<?php echo $rk->wassup_id ?>" style="text-decoration:none;"><img class="delete-icon" src="<?php echo WASSUPURL.'/img/cross.png" alt="'.__('delete','wassup').'" title="'.__('Delete this record','wassup'); ?>" /></a>
     1602            <a href="#" class="deleteID" id="<?php echo $rk->wassup_id ?>" style="text-decoration:none;"><img class="delete-icon" src="<?php echo WASSUPURL.'/img/b_delete.png" alt="'.__('delete','wassup').'" title="'.__('Delete this record','wassup'); ?>" /></a>
    15891603            <a href="?<?php echo attribute_escape($URLQuery.'&wmark=1&wip='.$ip); ?>" style="text-decoration:none;"><img class="mark-icon" src="<?php echo WASSUPURL.'/img/error_add.png" alt="'.__('mark','wassup').'" title="'.__('Mark IP','wassup'); ?>" /></a><?php
    15901604        } ?>
    1591             <a href="#TB_inline?height=400&width=<?php echo $res.'&inlineId='.$raw_div; ?>" class="thickbox"><img class="table-icon" src="<?php echo WASSUPURL.'/img/database_table.png" alt="'.__('show raw table','wassup').'" title="'.__('Show the items as raw table','wassup'); ?>" /></a>
     1605            <a href="#TB_inline?height=400&width=<?php echo $res.'&inlineId='.$raw_div; ?>" class="thickbox"><img class="table-icon" src="<?php echo WASSUPURL.'/img/b_select.png" alt="'.__('show raw table','wassup').'" title="'.__('Show the items as raw table','wassup'); ?>" /></a>
    15921606            </p>
    15931607            <div class="sum-box">
     
    17461760    } //end foreach qry
    17471761    print $expcol; //moved
    1748     } //end if itemstot > 0
    1749     if ($itemstot > $items) {
     1762    } //end if witemstot > 0
     1763    if ($witemstot > $witems) {
    17501764        print '<div align="center">'.$p->show().'</div><br />'."\n";
    17511765    } ?>
     
    17551769        $chart_type = ($wassup_options->wassup_chart_type >0)? $wassup_options->wassup_chart_type: "2";
    17561770        //show Google!Charts image
    1757         if ($pagestot > 12) {
     1771        if ($wpagestot > 12) {
    17581772            $chartwidth=$res;
    17591773            //let browser resize chart for small screens
     
    17611775                $chartwidth=640;
    17621776            }
    1763             $chart_url = $Tot->TheChart($last, $chartwidth, "180", $search, $chart_type, "bg,s,dedade|c,lg,90,edffff,0,dedade,0.8", "page", $type);
     1777            $chart_url = $wTot->TheChart($wlast, $chartwidth, "180", $wsearch, $chart_type, "bg,s,dedade|c,lg,90,edffff,0,dedade,0.8", "page", $wtype);
    17641778            $html='<img src="'.$chart_url.'" alt="'.__("Graph of visitor hits","wassup").'" class="chart" width="'.$res.'" />';
    17651779        } else {
     
    17841798    <nobr><span class="separator">|</span> <?php echo __('Exec time','wassup').": $totaltime"; ?></nobr></small></p>
    17851799    <?php
    1786     if ($debug_mode) {
     1800    if ($wdebug_mode) {
    17871801        //display MySQL errors/warnings in admin menus - for debug
    17881802        $wpdb->print_error();   //debug
     
    17961810} //end function Wassup
    17971811
    1798 //Since v.1.8: createTable/upgradeTable functions were moved to
    1799 //  'upgrade.php' module where they are loaded only when needed to keep
    1800 //   WassUp fast
     1812//Since v.1.8: createTable/upgradeTable functions moved to 'upgrade.php'
     1813//  module and are loaded during install/upgrade/uninstall only to keep WassUp fast.
    18011814} //end if is_admin
    18021815
     
    18041817//Set Wassup_id and cookie (before headers sent)
    18051818function wassupPrepend() {
    1806     global $wassup_options, $current_user, $user_level, $screen_res, $wassup_cookie_value, $debug_mode;
     1819    global $wassup_options, $current_user, $user_level, $wscreen_res, $wassup_cookie_value, $wdebug_mode;
    18071820
    18081821    //reload wassup_options in case changed elsewhere (by admin)
     
    18151828    $wassup_id = "";
    18161829    $session_timeout = 1;
    1817     $screen_res = "";
     1830    $wscreen_res = "";
    18181831    $cookieIP = "";
    18191832    $cookieHost = "";
     1833    $cookieUser = "";
    18201834    $wassup_cookie_value="";
    18211835    $wassup_dbtask=array();
     
    18311845            $session_timeout = ((int)$wassup_timer - (int)time());
    18321846        }
    1833         if (!empty($cookie_data[2])) $screen_res = $cookie_data[2];
     1847        if (!empty($cookie_data[2])) $wscreen_res = $cookie_data[2];
    18341848        if (!empty($cookie_data[3])) {
    18351849            $cookieIP = $cookie_data[3];
     
    18381852            }
    18391853        }
     1854        //new in v1.8.3: username in wassup cookie
     1855        if (!empty($cookie_data[5])) {
     1856            $cookieUser = $cookie_data[5];
     1857        }
    18401858    }
    18411859    //set screen resolution value from cookie or browser header data, if any
    1842     if (empty($screen_res)) {
     1860    if (empty($wscreen_res)) {
    18431861        if (isset($_COOKIE['wassup_screen_res'])) {
    1844             $screen_res = attribute_escape(trim($_COOKIE['wassup_screen_res']));
    1845             if ($screen_res == "x") $screen_res="";
     1862            $wscreen_res = attribute_escape(trim($_COOKIE['wassup_screen_res']));
     1863            if ($wscreen_res == "x") $wscreen_res="";
    18461864        }
    1847         if (empty($screen_res) && isset($_SERVER['HTTP_UA_PIXELS'])) {
     1865        if (empty($wscreen_res) && isset($_SERVER['HTTP_UA_PIXELS'])) {
    18481866            //resolution in IE/IEMobile header sometimes
    1849             $screen_res = str_replace('X',' x ',$_SERVER['HTTP_UA_PIXELS']);
    1850         }
    1851         //if (empty($screen_res) && isset($_GET['wscr'])) {
    1852         //  $screen_res = $_GET['wscr'];
     1867            $wscreen_res = str_replace('X',' x ',$_SERVER['HTTP_UA_PIXELS']);
     1868        }
     1869        //if (empty($wscreen_res) && isset($_GET['wscr'])) {
     1870        //  $wscreen_res = $_GET['wscr'];
    18531871        //}
    18541872    }
     
    18581876        get_currentuserinfo();  //sets $current_user, $user_xx
    18591877    //}
    1860     $logged_user = (!empty($current_user->user_login)? $current_user->user_login: "");
     1878    //sometimes current_user is empty during wordpress init so use "cookieUser" variable sometimes
     1879    $logged_user = (!empty($current_user->user_login)? $current_user->user_login: $cookieUser);
    18611880    //exclude valid wordpress admin page visits and admin hits
    18621881    if (($wassup_options->wassup_admin == "1" || $user_level < 8) && (!is_admin() || empty($logged_user))) {
    18631882
    18641883        //write wassup cookie for new visits, visit timeout (45 mins) or empty screen_res
    1865         if (empty($wassup_id) || $session_timeout < 1 || (empty($cookie_data[2]) && !empty($screen_res))) {
     1884        if (empty($wassup_id) || $session_timeout < 1 || (empty($cookie_data[2]) && !empty($wscreen_res))) {
    18661885            $ipAddress = "";
    18671886            $proxy = "";
     
    19711990            }
    19721991            $expire = time()+3000;  //expire based on utc timestamp, not on Wordpress time
    1973             $cookie_data = implode('::',array("$wassup_id","$wassup_timer","$screen_res","$IP","$hostname"));
     1992            $cookie_data = implode('::',array("$wassup_id","$wassup_timer","$wscreen_res","$IP","$hostname","$logged_user"));
    19741993            $wassup_cookie_value = urlencode(base64_encode($cookie_data));
    19751994            setcookie("wassup", "$wassup_cookie_value", $expire, $cookiepath, $cookiedomain);
     
    19781997
    19791998        //place wassup tag and javascript in document head
    1980         add_action('wp_head', 'wassup_head', 10, "$screen_res");
     1999        add_action('wp_head', 'wassup_head', 10);
    19812000        //track visitor hits:
    19822001        //  use 'send_headers' hook to track media, downloads, and feed hits
     
    20082027//Track visitors and save record in wassup table, after page is displayed
    20092028function wassupAppend() {
    2010     global $wpdb, $wassup_options, $current_user, $user_level, $wassupversion, $wassup_cookie_value, $debug_mode;
     2029    global $wpdb, $wassup_options, $current_user, $user_level, $wassupversion, $wassup_cookie_value, $wscreen_res, $wdebug_mode;
    20112030
    20122031    if ($wassup_options->wassup_active == 0) {  //do nothing
     
    20152034    @ignore_user_abort(1); // finish script in background if visitor aborts
    20162035
    2017     if ($debug_mode) {  //#debug...
     2036    if ($wdebug_mode) { //#debug...
    20182037        //debug mode must be off for media and non-html requests
    20192038        if (preg_match("/(\.(gif|ico|jpe?g|png|tiff|css|doc|js|jar|rdf|rtf|pdf|ppt|psd|txt|xls|xlt|xml|flv|mov|mpg|mp4|mp3|ogg|swf|wmv|Z|gz|zip)$)|[=\/](feed|atom)/i", $_SERVER['REQUEST_URI'])>0) {
    2020             $debug_mode=false;
     2039            $wdebug_mode=false;
    20212040        } elseif (is_feed()) {
    2022             $debug_mode=false;
     2041            $wdebug_mode=false;
    20232042        } else {
    20242043            $mode_reset=ini_get('display_errors');
    2025             $debug_reset=$debug_mode;
     2044            $debug_reset=$wdebug_mode;
    20262045            error_reporting(E_ALL); //debug, E_STRICT=php5 only
    20272046            ini_set('display_errors','On'); //debug
     
    20372056            @error_reporting(E_ERROR);
    20382057        }
    2039     } //end if $debug_mode
     2058    } //end if $wdebug_mode
    20402059
    20412060    $wpurl = get_bloginfo('wpurl');
     
    20502069    else $post_ID=0;
    20512070    //if (empty($current_user->user_login)) {
    2052         get_currentuserinfo();  //sets $current_user, $user_xx
     2071        get_currentuserinfo();  //gets $current_user, $user_xx
    20532072    //}
    20542073    $logged_user = (!empty($current_user->user_login)? $current_user->user_login: "");
     
    20662085    //# First exclusion control is for admin user
    20672086    if ($wassup_options->wassup_admin == "1" || $user_level < 8) {
     2087
     2088    //# TODO?: Exclude wp-cron utility hits
     2089    //if (stristr($urlRequested,"/wp-cron.php?doing_wp_cron")===FALSE || (!empty($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR'] != $_SERVER['REMOTE_ADDR'])) {
    20682090
    20692091    //# Record non-admin page visits and or hack attempts
     
    21082130    if (!$exclude_visit) {
    21092131        $wassup_id = "";
    2110         $screen_res = "";
    21112132        $cookieIP = "";
    21122133        $cookieHost = "";
     
    21202141            $wassup_id = $wassup_cookie[0];
    21212142            if (!empty($wassup_cookie[2])) {
    2122                 $screen_res = $wassup_cookie[2];
     2143                $wscreen_res = $wassup_cookie[2];
    21232144            }
    21242145            if (!empty($wassup_cookie[3])) {
     
    21302151        }
    21312152        //### set screen resolution value from cookie or browser header data, if any
    2132         if (empty($screen_res)) {
     2153        if (empty($wscreen_res)) {
    21332154            if (isset($_COOKIE['wassup_screen_res'])) {
    2134                 $screen_res = attribute_escape(trim($_COOKIE['wassup_screen_res']));
    2135                 if ($screen_res == "x") $screen_res = "";
     2155                $wscreen_res = attribute_escape(trim($_COOKIE['wassup_screen_res']));
     2156                if ($wscreen_res == "x") $wscreen_res = "";
    21362157            }
    2137             if (empty($screen_res) && isset($_SERVER['HTTP_UA_PIXELS'])) {
     2158            if (empty($wscreen_res) && isset($_SERVER['HTTP_UA_PIXELS'])) {
    21382159                //resolution in IE/IEMobile header sometimes
    2139                 $screen_res = str_replace('X',' x ',attribute_escape($_SERVER['HTTP_UA_PIXELS']));
     2160                $wscreen_res = str_replace('X',' x ',attribute_escape($_SERVER['HTTP_UA_PIXELS']));
    21402161            }
    21412162        }
     
    22462267    // visitor.  Dup==same wassup_id, same URL, and timestamp <180 secs
    22472268    $dup_urlrequest=0;
    2248     $w_pageviews=0;
     2269    $wpageviews=0;
    22492270    $spamresult=0;
    22502271    $wpdb->query("SET wait_timeout = 7"); //don't wait for slow responses
    2251     $recent = $wpdb->get_results("SELECT wassup_id, urlrequested, spam, screen_res, `timestamp`, browser, spider, os, feed, `language`, `agent`, `referrer` FROM ".$table_tmp_name." WHERE wassup_id='".$wassup_id."' AND `timestamp` >".($timestamp-180)." ORDER BY `timestamp` DESC");
    2252     if (!empty($recent)) {
    2253         $w_pageviews=count($recent);
     2272    $recent_hit = $wpdb->get_results("SELECT wassup_id, urlrequested, spam, screen_res, `timestamp`, browser, spider, os, feed, `language`, `agent`, `referrer` FROM ".$table_tmp_name." WHERE wassup_id='".$wassup_id."' AND `timestamp` >".($timestamp-180)." ORDER BY `timestamp` DESC");
     2273    if (!empty($recent_hit)) {
     2274        $wpageviews=count($recent_hit);
    22542275        //check 1st record only
    22552276        //record is dup if same url (with 'wscr' removed) and same user-agent
    2256         if ($recent[0]->urlrequested == $urlRequested || $recent[0]->urlrequested == remove_query_arg('wscr',$urlRequested) || $recent[0]->urlrequested == "[404] $urlRequested") {
    2257             if ($recent[0]->agent == $userAgent || empty($recent[0]->agent)) {
     2277        if ($recent_hit[0]->urlrequested == $urlRequested || $recent_hit[0]->urlrequested == remove_query_arg('wscr',$urlRequested) || $recent_hit[0]->urlrequested == "[404] $urlRequested") {
     2278            if ($recent_hit[0]->agent == $userAgent || empty($recent_hit[0]->agent)) {
    22582279                $dup_urlrequest=1;
    22592280            }
     
    22642285
    22652286        //retrieve previous spam check results
    2266         $spamresult = $recent[0]->spam;
     2287        $spamresult = $recent_hit[0]->spam;
    22672288
    22682289        //check for screen resolution and update, if not previously recorded
    22692290        //...queue the update because of "delayed insert"
    2270         if (empty($recent[0]->screen_res) && !empty($screen_res)) {
    2271             $wassup_dbtask[] = "UPDATE $wassup_table SET `screen_res`='$screen_res' WHERE `wassup_id`='$wassup_id' AND `screen_res`='' ";
     2291        if (empty($recent_hit[0]->screen_res) && !empty($wscreen_res)) {
     2292            $wassup_dbtask[] = "UPDATE $wassup_table SET `screen_res`='$wscreen_res' WHERE `wassup_id`='$wassup_id' AND `screen_res`='' ";
    22722293        }
    22732294
     
    22752296        //  avoid redundant tests
    22762297        if ($dup_urlrequest == 0) {
    2277             if (empty($screen_res) && !empty($recent[0]->screen_res)) {
    2278                 $screen_res = $recent[0]->screen_res;
     2298            if (empty($wscreen_res) && !empty($recent_hit[0]->screen_res)) {
     2299                $wscreen_res = $recent_hit[0]->screen_res;
    22792300            }
    22802301            if ($spam == 0 && (int)$spamresult >0 ) {
    22812302                $spam = $spamresult;
    22822303            }
    2283             if ($recent[0]->agent == $userAgent || empty($userAgent)) {
    2284                 $browser = $recent[0]->browser;
    2285                 $spider = $recent[0]->spider;
    2286                 $os = $recent[0]->os;
     2304            if ($recent_hit[0]->agent == $userAgent || empty($userAgent)) {
     2305                $browser = $recent_hit[0]->browser;
     2306                $spider = $recent_hit[0]->spider;
     2307                $os = $recent_hit[0]->os;
    22872308                if (empty($language)) {
    2288                     $language = $recent[0]->language;
     2309                    $language = $recent_hit[0]->language;
    22892310                }
    22902311                //feed reader only if this page is feed
    2291                 if (!empty($recent[0]->feed) && is_feed()) {
    2292                     $feed = $recent[0]->feed;
     2312                if (!empty($recent_hit[0]->feed) && is_feed()) {
     2313                    $feed = $recent_hit[0]->feed;
    22932314                }
    22942315            }
     
    22962317        // Detect disguised spiders and harvesters by checking for
    22972318        //  excessive pageviews (threshold: 8+ views in < 16 secs)
    2298         if ($w_pageviews >7 && empty($spider)) {
    2299             $visitstart = $recent[7]->timestamp;
    2300             if (($timestamp - $recent[7]->timestamp) < 16) {
     2319        if ($wpageviews >7 && empty($spider)) {
     2320            $pageurls = array();
     2321            $visitstart = $recent_hit[7]->timestamp;
     2322            if (($timestamp - $recent_hit[7]->timestamp) < 16) {
    23012323                $is_spider=true;
    2302                 $pagetest[]="$urlRequested";
     2324                $pageurls[]="$urlRequested";
    23032325                //a spider is unlikely to hit same page 2+ times
    2304                 foreach ($recent AS $w_pgview) {
     2326                foreach ($recent_hit AS $w_pgview) {
    23052327                    if (stristr($w_pgview->urlrequested,"robots.txt")!==false) {
    23062328                        $is_spider = true;
    23072329                        break;
    2308                     } elseif (in_array($w_pgview->urlrequested,$pagetest)) {
     2330                    } elseif (in_array($w_pgview->urlrequested,$pageurls)) {
    23092331                        $is_spider = false;
    23102332                        break;
    23112333                    } else {
    2312                         $pagetest[] = $w_pgview->urlrequested;
     2334                        $pageurls[] = $w_pgview->urlrequested;
    23132335                    }
    23142336                }
     
    23192341            }
    23202342        }
    2321     } //end if recent
    2322     if ($debug_mode) {  //debug
    2323         if (!empty($recent)) {
     2343    } //end if recent_hit
     2344    if ($wdebug_mode) { //debug
     2345        if (!empty($recent_hit)) {
    23242346            echo "<br />\nRecent visit data found in wassup_tmp:\n"; //debug
    2325             print_r($recent); //debug
     2347            print_r($recent_hit); //debug
    23262348            echo "\n";
    2327             $debug_output .="\n\n".date('H:i:s.u').' Recent data lookup results: $recent='.serialize($recent)."\n";
     2349            $debug_output .="\n\n".date('H:i:s.u').' Recent data lookup results: $recent_hit='.serialize($recent_hit)."\n";
    23282350            if ($dup_urlrequest == 1) {
    23292351                echo "\nDuplicate record!\n";
    23302352            }
    2331             if ($recent[0]->agent != $userAgent) {
     2353            if ($recent_hit[0]->agent != $userAgent) {
    23322354                echo "\nUser Agents NOT Identical:";
    23332355                echo "\n\tCurrent user agent: ".$userAgent;
    2334                 echo "\n\tPrevious user agent:".$recent[0]->agent."\n";
     2356                echo "\n\tPrevious user agent:".$recent_hit[0]->agent."\n";
    23352357            }
    23362358        } else {
     
    23412363
    23422364    //don't record 404 unless 1st visit or hack attempt
    2343     if ($req_code == 200 || empty($recent) || ($hackercheck && (stristr($urlRequested,"/wp-")!==FALSE || preg_match('/\.(php|ini|aspx?|dll|cgi)|(\.\.\/\.\.\/|root[^a-z0-9\-_]|[^a-z0-9\-_]passw|\=admin[^a-z0-9\-_]|\=\-\d+|(bin|etc)\/)/i',$urlRequested)>0))) {
     2365    if ($req_code == 200 || empty($recent_hit) || ($hackercheck && (stristr($urlRequested,"/wp-")!==FALSE || preg_match('/\.(php|ini|aspx?|dll|cgi)|(\.\.\/\.\.\/|root[^a-z0-9\-_]|[^a-z0-9\-_]passw|\=admin[^a-z0-9\-_]|\=\-\d+|(bin|etc)\/)/i',$urlRequested)>0))) {
    23442366        //identify hackers
    2345         if ($req_code != 200 && preg_match('#(\.(php|cgi|aspx?)|[\*\,\'"]|\=\-1$)#i',$urlRequested)>0) {
    2346             //visitors trying to run non-existent server-side scripts are up to no good.
    2347             $spam = 3;
     2367        if ($req_code != 200 && preg_match('#(([a-z0-9_\*\-\#\,]+\.php[456]?)|\.(?:cgi|aspx?)|[\*\,\'"]|\=\-1$)#i',$urlRequested,$matches)>0) {
     2368            //visitors requesting non-existent server-side scripts are up to no good
     2369            if (empty($matches[2]) || $matches[2]!= "index.php") {
     2370                $spam = 3;
     2371            }
    23482372        } elseif (preg_match('#\.\./\.\./(etc/passwd|\.\./\.\./)#i',$urlRequested)>0 || preg_match('#[\[&\?/](dir|document_root\]?|id|page|thisdir)\=https?\://#i',$urlRequested)>0) {
    23492373            //anyone trying to access root files, password or ids are up to no good
     
    23532377        }
    23542378        //retroactively update record for hack attempt
    2355         if ($spam == "3" && $spamresult == "0" && !empty($recent)) {
     2379        if ($spam == "3" && $spamresult == "0" && !empty($recent_hit)) {
    23562380            $wassup_dbtask[] = "UPDATE $wassup_table SET `spam`='3' WHERE `wassup_id`='$wassup_id' AND `spam`='0' ";
    23572381        }
    23582382
    2359     //# Exclude duplicates and avoid redundant checks on multi-page visits
     2383    //# Exclude duplicates and avoid redundant checks for multi-page visitors
    23602384    if ($dup_urlrequest == 0) {
    23612385        //##### Extract useful visit information from http header..
     
    23862410                $os = $ua->os;
    23872411                if (!empty($ua->resolution)) {
    2388                 //TODO?: Write 'wassup_screen_res' cookie, if none
    2389                     $screen_res = (preg_match('/^\d+x\d+$/',$ua->resolution)>0)?str_replace('x',' x ',$ua->resolution):$ua->resolution;
     2412                    $wscreen_res = (preg_match('/^\d+x\d+$/',$ua->resolution)>0)?str_replace('x',' x ',$ua->resolution):$ua->resolution;
    23902413                }
    23912414                if (!empty($ua->language) && empty($language)) {
    23922415                    $language=$ua->language;
    23932416                }
    2394                 if ($debug_mode) $debug_output .= "\n".date('H:i:s.u').' UAdetecter results: $ua='.serialize($ua)."\n";
     2417                if ($wdebug_mode) $debug_output .= "\n".date('H:i:s.u').' UAdetecter results: $ua='.serialize($ua)."\n";
    23952418            } //end if $ua->name
    23962419
     
    24012424                list($browser,$os) = wGetBrowser($userAgent);
    24022425                if (!empty($browser)) $agent= $browser;
    2403                 if ($debug_mode) $debug_output .= "\n".date('H:i:s.u').' wGetBrowser results: $browser='.$browser.'  $os='.$os."\n";
     2426                if ($wdebug_mode) $debug_output .= "\n".date('H:i:s.u').' wGetBrowser results: $browser='.$browser.'  $os='.$os."\n";
    24042427            }
    24052428
     
    24122435            if (empty($agent) || stristr($agent,'unknown')!==false || preg_match($spider_hosts,$hostname)>0 ) {
    24132436                list($spider,$spidertype,$feed) = wGetSpider($userAgent,$hostname,$browser);
    2414                 if ($debug_mode) $debug_output .= "\n".date('H:i:s.u').' wGetSpider results: $spider='.$spider.'  $spidertype='.$spidertype.' $feed='.$feed."\n";
     2437                if ($wdebug_mode) $debug_output .= "\n".date('H:i:s.u').' wGetSpider results: $spider='.$spider.'  $spidertype='.$spidertype.' $feed='.$feed."\n";
    24152438                //it's a browser
    24162439                if ($spidertype == "B" && $urlRequested != "/robots.txt") {
     
    24272450            } elseif(!empty($userAgent) && (strlen($agent)<5 || strstr($agent,'N/A') || ($agent == $browser && (empty($os) || preg_match("#\s?([a-z]+(?:bot|crawler|spider|reader|agent))[^a-z]#i",$userAgent)>0 || strstr($urlRequested,"robots.txt")!==FALSE || is_feed())))) {
    24282451                list($spider,$spidertype,$feed) = wGetSpider($userAgent,$hostname,$browser);
    2429                 if ($debug_mode) $debug_output .= "\n".date('H:i:s.u').' wGetSpider results: $spider='.$spider.'  $spidertype='.$spidertype.' $feed='.$feed."\n";
     2452                if ($wdebug_mode) $debug_output .= "\n".date('H:i:s.u').' wGetSpider results: $spider='.$spider.'  $spidertype='.$spidertype.' $feed='.$feed."\n";
    24302453                //it's a browser
    24312454                if ($spidertype == "B" && $urlRequested != "/robots.txt") {
     
    24452468
    24462469        //if 1st request is "robots.txt" then this is a bot
    2447         if (empty($spider) && strstr($urlRequested,"robots.txt")!==FALSE && empty($recent)) {
     2470        if (empty($spider) && strstr($urlRequested,"robots.txt")!==FALSE && empty($recent_hit)) {
    24482471            $spider = __("Unknown Spider","wassup");
    24492472
     
    24592482        //# some valid spiders to exclude from spam check below
    24602483        $goodbot = false;
    2461         if ($hostname!="" && !empty($spider) && preg_match('/^(googlebot|bingbot|msnbot|yahoo\!\ slurp|technorati)/i',$spider)>0 && preg_match('/\.(googlebot|live|msn|yahoo|technorati)\.(com|net)$/i',$hostname)>0){
     2484        if ($hostname!="" && !empty($spider) && preg_match('#^(googlebot|bingbot|msnbot|yahoo\!\sslurp|technorati)#i',$spider)>0 && preg_match('#\.(googlebot|live|msn|yahoo|technorati)\.(com|net)$#i',$hostname)>0){
    24622485            $goodbot = true;
    24632486        }
    24642487
    24652488        //do spam exclusion controls, unless disabled in wassup_spamcheck
    2466     if ($wassup_options->wassup_spamcheck == 1 && $spam == 0) {
     2489    if ($wassup_options->wassup_spamcheck == 1 && $spam == 0 && !$goodbot) {
    24672490        $spamComment = New wassup_checkComment;
    24682491
    24692492        //### 1st Check for referrer spam...faster, if positive
    2470         if ($wassup_options->wassup_refspam == 1 && !empty($referrer) && !$goodbot) {
     2493        if ($wassup_options->wassup_refspam == 1 && !empty($referrer)) {
    24712494            //#...skip if referrer is own blog
    2472             if (stristr($referrer,$wpurl)===FALSE && stristr($referrer,$blogurl)===FALSE && !$debug_mode) {
     2495            if (stristr($referrer,$wpurl)===FALSE && stristr($referrer,$blogurl)===FALSE && !$wdebug_mode) {
    24732496            // Do a control if it is Referrer Spam
    2474             //check if referer is a previous comment spammer
     2497            //check if referrer is a previous comment spammer
    24752498            if ($spamComment->isRefSpam($referrer)>0) {
    24762499                $spam = 2;
    24772500            //check referer against a list of known spammers
    24782501            } else {
    2479                 if ($debug_mode) {
     2502                if ($wdebug_mode) {
    24802503                    $isspam = wGetSpamRef($referrer,$hostname);
    24812504                } else {
     
    24902513        //# No spam check on known bots (google, yahoo,...) unless
    24912514        //#  there is a comment or forum page request...
    2492         if ($spam == 0 && (empty($spider) || !$goodbot || stristr($urlRequested,"comment")!== FALSE || stristr($urlRequested,"forum")!== FALSE  || !empty($comment_user))) {
     2515        if ($spam == 0 && (empty($spider) || stristr($urlRequested,"comment")!== FALSE || stristr($urlRequested,"forum")!== FALSE  || !empty($comment_user))) {
    24932516
    24942517        //if (isset($spamresult) && stristr($urlRequested,"comment") === FALSE && stristr($urlRequested,"forum") === FALSE && empty($comment_user) && empty($_POST['comment'])) {
     
    25052528            }
    25062529            //#lastly check for comment spammers using Akismet API
    2507             //  Note: this may cause "header already sent" errors with "send_headers" hook in some Wordpress configurations
    2508             if ($wassup_options->wassup_spam == 1 && stristr($urlRequested,"comment") !== FALSE && $spam == 0) {
     2530            // Note: Akismet spam test may cause "header already sent" errors with "send_headers" hook in some Wordpress configurations
     2531            if ($spam == 0 && $wassup_options->wassup_spam == 1 && stristr($urlRequested,"comment")!== FALSE && stristr($urlRequested,"/comments/feed/")== FALSE) {
    25092532                $akismet_key = get_option('wordpress_api_key');
    25102533                $akismet_class = dirname(__FILE__).'/lib/akismet.class.php';
     
    25352558
    25362559            //retroactively update visitor's hits as spam, in case late detection
    2537             if (!empty($recent) && !empty($spam) && $spamresult==0) {
     2560            if (!empty($recent_hit) && !empty($spam) && $spamresult==0) {
    25382561                //queue the update...
    25392562                $wassup_dbtask[]="UPDATE $wassup_table SET `spam`='".$spam."' WHERE `wassup_id`='".$wassup_id."' AND `spam`='0' ";
     
    25542577        $search_phrase="";
    25552578        $searchpage="";
     2579        $searchcountry="";
    25562580        //don't check own blog for search engine data
    2557         if (!empty($referrer) && $spam == "0" && stristr($referrer,$blogurl)!=$referrer && !$debug_mode) {
    2558             //if ($debug_mode) {    //debug
     2581        if (!empty($referrer) && $spam == "0" && stristr($referrer,$blogurl)!=$referrer && !$wdebug_mode) {
     2582            //if ($wdebug_mode) {   //debug
    25592583            //  echo '<br />\n$Referrer="'.$referrer.'" is NOT own site: '.$blogurl.'. Checking for search engine data...'."\n"; //debug
    25602584            //}
    25612585            //get GET type search results, ex: search=x
    25622586            if (strpos($referrer,'=')!==false) {
    2563                 list($searchengine,$search_phrase,$searchpage,$searchlang,$searchcountry)=explode("|",wGetSE($referrer));
     2587                list($searchengine,$search_phrase,$searchpage,$searchlang,$searchlocale)=explode("|",wGetSE($referrer));
    25642588                if ($search_phrase != '') {
    25652589                    $sedomain = parse_url($referrer);
     
    25812605            if (!empty($searchengine)) {
    25822606                if (stristr($searchengine,"images")===FALSE && stristr($referrer,'&imgurl=')===FALSE) {
     2607                // 2011-04-18: "page" parameter is now used on referrer string for Google Images et al.
     2608                if (preg_match('#page[=/](\d+)#i',$referrer,$pcs)>0) {
     2609                    if ($searchpage != $pcs[1]) {
     2610                        $searchpage = $pcs[1];
     2611                    }
     2612                } else {
    25832613                // NOTE: Position retrieved in Google Images is
    25842614                // the position number of image NOT page rank position like web search
    25852615                    $searchpage=(int)($searchpage/10)+1;
    25862616                }
    2587                 if (empty($searchcountry) && preg_match('/(\.([a-z]{2})$|^([a-z]{2})\.)/i',$searchdomain,$match)) {
     2617                }
     2618                //append country code to search engine name
     2619                if (preg_match('/(\.([a-z]{2})$|^([a-z]{2})\.)/i',$searchdomain,$match)) {
    25882620                    if (!empty($match[2])) {
    25892621                            $searchcountry = $match[2];
     
    25912623                            $searchcountry = $match[3];
    25922624                    }
    2593                 }
    2594                 if (!empty($searchcountry) && $searchcountry != "us") {
    2595                     $searchengine .= " ".strtoupper($searchcountry);
     2625                    if (!empty($searchcountry) && $searchcountry != "us") {
     2626                        $searchengine .= " ".strtoupper($searchcountry);
     2627                    }
    25962628                }
    25972629            } else {
     
    25992631            }
    26002632            //use search engine country code as locale
    2601             $searchcountry = trim($searchcountry);
    2602             if (!empty($searchcounty) && ($language == "us" || empty($language))) {
     2633            $searchlocale = trim($searchlocale);
     2634            if (!empty($searchlocale)) {
     2635                $language = $searchlocale;
     2636            } elseif (!empty($searchcountry) && ($language == "us" || empty($language))) {
    26032637                $language=$searchcountry;
    26042638            }
     
    26242658                'browser'=>$browser,
    26252659                'language'=>$language,
    2626                 'screen_res'=>$screen_res,
     2660                'screen_res'=>$wscreen_res,
    26272661                'spider'=>$spider,
    26282662                'feed'=>$feed,
     
    26582692    } //end if !exclude_visit
    26592693    } //end if !is_admin
     2694    //} //TODO end if wp-cron.php?doing_wp_cron===FALSE
    26602695    } //end if loggeduser_level
    26612696   
     
    27232758    //perform scheduled database tasks
    27242759    if (count($wassup_dbtask)>0) {
    2725         if ($debug_mode) {
     2760        if ($wdebug_mode) {
    27262761            $debug_output.="\n"."Performing Scheduled tasks:".serialize($wassup_dbtask)."\n";
    27272762        }
    27282763        wassup_scheduled_dbtask($wassup_dbtask);
    27292764    }
    2730     if ($debug_mode) {
     2765    if ($wdebug_mode) {
    27312766        if (!empty($wassup_rec)) {
    27322767            echo "<br />\nWassUp record data:\n";
     
    28472882 */
    28482883function wGetQueryPairs($urlstring){
    2849     $return = array();
     2884    $wreturn = array();
    28502885    if (!empty($urlstring)) {
    2851         $tab=parse_url($urlstring);
    2852         if (key_exists("query",$tab)){
    2853             $query=$tab["query"];
    2854             $return=explode("&",$query);
     2886        $wtab=parse_url($urlstring);
     2887        if (key_exists("query",$wtab)){
     2888            $query=$wtab["query"];
     2889            $wreturn=explode("&",$query);
    28552890        } else {
    2856             $return=explode("&",$urlstring); //partial url
    2857         }
    2858     }
    2859     return $return;
     2891            $wreturn=explode("&",$urlstring); //partial url
     2892        }
     2893    }
     2894    return $wreturn;
    28602895} //end wGetQueryPairs
    28612896
     
    29552990        "Google|www.google.|q|cd|hl||",
    29562991        "Google|www.google.|as_q|start|hl||",   //advanced query
    2957         "Yahoo Images|images.search.yahoo.com|p||||",
    2958         "Yahoo Mobile|m.search.yahoo.|p||||",
    2959         "Yahoo|search.yahoo.|p||||",
    2960         "Yahoo|answers.yahoo.com|p||||",
     2992        "Yahoo! Images|images.search.yahoo.com|p||||",
     2993        "Yahoo! Mobile|m.search.yahoo.|p||||",
     2994        "Yahoo! Mobile|search.yahoo.com/mobile/|p||||",
     2995        "Yahoo!|search.yahoo.|p||||",
     2996        "Yahoo!|answers.yahoo.com|p||||",
    29612997        "Bing Mobile|m.bing.com|q|first|||",
    29622998        "Bing Images|.bing.com/images/|q|first|||",
     
    30373073        "Web|.web.de|su|||de|",
    30383074        "Yahoo! Mobile|m.yahoo.com|p||||",
     3075        "Yahoo! Mobile|m2.yahoo.com|p||||",
     3076        "Yahoo!|.yahoo.com|p||||",
    30393077        "Yandex|yandex.ru|text|||ru|",
    30403078        "Yippy|search.yippy.com|query||||",
     
    30583096            $searchengine = $nome;
    30593097            $search_phrase = "";
    3060             $variables=array();
     3098            $svariables=array();
    30613099            // Google Images or Google Translate needs additional processing of search phrase after 'prev='
    30623100            if ($nome == "Google Images" || $nome == "Google Translate") {
    30633101                //'prev' is an encoded substring containing actual "q" query, so use html_entity_decode to show [&?] in url substring
    3064                 $variables = wGetQueryPairs(html_entity_decode(preg_replace('#/\w+\?#i','', urldecode($match[1]))));
     3102                $svariables = wGetQueryPairs(html_entity_decode(preg_replace('#/\w+\?#i','', urldecode($match[1]))));
    30653103                $key='q';   //q is actual search key
    30663104            } elseif ($nome == "Google Cache") {
     
    30693107                //blogurl in search phrase: cache of own site
    30703108                    $search_phrase = attribute_escape(urldecode(substr($match[1],$n+strlen($blogurl))));
    3071                     $variables = wGetQueryPairs($referrer);
     3109                    $svariables = wGetQueryPairs($referrer);
    30723110                } elseif (strpos($referrer,$blogurl)!==false && preg_match('/\&prev\=([^&]+)/',$referrer,$match)!==false) {
    30733111                    //NOTE: 'prev=' requires html_entity_decode to show [&?] in url substring
    3074                     $variables = wGetQueryPairs(html_entity_decode(preg_replace('#/\w+\?#i','', urldecode($match[1]))));
     3112                    $svariables = wGetQueryPairs(html_entity_decode(preg_replace('#/\w+\?#i','', urldecode($match[1]))));
    30753113                } else {
    30763114                //no blogurl in search phrase: cache of an external site with referrer link
     
    30843122                }
    30853123                $search_phrase = attribute_escape(urldecode($match[1]));
    3086                 $variables = wGetQueryPairs($referrer);
     3124                $svariables = wGetQueryPairs($referrer);
    30873125            }
    30883126            //retrieve search engine parameters
    3089             $i = count($variables);
     3127            $i = count($svariables);
    30903128            while($i--){
    3091                 $tab=explode("=",$variables[$i]);
     3129                $tab=explode("=",$svariables[$i]);
    30923130                if($tab[0] == $key && empty($search_phrase)){
    30933131                    $search_phrase=attribute_escape($tab[1]);
     
    30983136                    if (!empty($lang) && $lang == $tab[0]) {
    30993137                        $searchlang = attribute_escape($tab[1]);
     3138                    }
     3139                    //Indentify locale via Google search's new parameter, 'gl'
     3140                    if (strstr($nome,'Google')!==false && $tab[0] == "gl" && !empty($tab[1])) {
     3141                        $selocale = attribute_escape($tab[1]);
    31003142                    }
    31013143                }
     
    32503292        if (substr($hostname,-16) == ".crawl.yahoo.net" || (substr($hostname,-10)==".yahoo.com" && substr($hostname,0,3)=="ycar")) {
    32513293            if (stristr($ua,"Slurp")) {
    3252                 $crawler = "Yahoo!Slurp";
     3294                $crawler = "Yahoo! Slurp";
    32533295                $crawlertype="R";
    32543296            } elseif (stristr($ua,"mobile")) {
    3255                 $crawler = "Yahoo!Mobile";
     3297                $crawler = "Yahoo! Mobile";
    32563298                $crawlertype="R";
    32573299            } else {
     
    33163358        // array format: "Spider Name|UserAgent keywords (no spaces)| Spider type (R=robot, B=Browser/downloader, F=feedreader, H=hacker, L=Link checker, M=siteMap generator, S=Spammer/email harvester, V=CSS/Html validator)
    33173359        $lines = array("Googlebot|Googlebot/|R|",
    3318             "Yahoo!|Yahoo!Slurp|R|",
     3360            "Yahoo!|Yahoo! Slurp|R|",
    33193361            "FeedBurner|FeedBurner|F|",
    33203362            "AboutUsBot|AboutUsBot/|R|",
     
    36543696//#get the visitor locale/language
    36553697function wGetLocale($language="",$hostname="",$referrer="") {
    3656     global $wpdb, $wassup_options, $debug_mode;
     3698    global $wpdb, $wassup_options, $wdebug_mode;
    36573699    $clocale="";
    36583700    $country="";
     
    37433785 */
    37443786function wGetSpamRef($referrer,$hostname="") {
    3745     global $debug_mode;
     3787    global $wdebug_mode;
    37463788    $referrer=attribute_escape(strip_tags(str_replace(" ","",html_entity_decode($referrer))));
    37473789    $badhost=false;
     
    37593801            //$referrer_path = $rurl['path'];
    37603802            $thissite = parse_url(get_option('home'));
     3803            //exclude current site as referrer
    37613804            if (isset($thissite['host']) && $referrer_host == $thissite['host']) {
    37623805                $referrer_host = "";
     3806            //New in v1.8.3: check the path|query part of url for spammers
     3807            } else {
     3808                //rss.xml|sitemap.txt in referrer is faked
     3809                if (preg_match('#.+/(rss\.xml|sitemap\.txt)$#',$referrer)>0) {
     3810                    $badhost=true;
     3811                //membership|user id in referrer is faked
     3812                } elseif (preg_match('#.+[^a-z0-9]((?:show)?user|u)\=\d+$#',$referrer)>0) {
     3813                    $badhost=true;
     3814                //youtube video in referrer is faked
     3815                } elseif (preg_match('#(\.|/)youtube\.com/watch\?v\=.+#"',$referrer)>0) {
     3816                    $badhost=true;
     3817                //some facebook links in referrer are faked
     3818                } elseif (preg_match('#(\.|/)facebook\.com\/ASeaOfSins$#"',$referrer)>0) {
     3819                    $badhost=true;
     3820                }
    37633821            }
    37643822        } else {    //faked referrer string
     
    37683826        if (!$badhost && !empty($referrer_host)) {
    37693827            $url_shorteners = array('bit.ly', 'cli.gs',
    3770                 'goo.gl', 'is.gd',
    3771                 'shorturl.com', 'snurl.com',
     3828                'goo.gl', 'is.gd', 'ow.ly',
     3829                'shorturl.com', 'snurl.com', 'su.pr',
    37723830                'tinyurl.com','tr.im');
    37733831            if(in_array($referrer_host,$url_shorteners)) {
     
    37783836    if (empty($referrer_host) || $badhost) return $badhost;
    37793837   
    3780     if ($debug_mode) echo "\$referrer_host = $referrer_host.\n";
     3838    if ($wdebug_mode) echo "\$referrer_host = $referrer_host.\n";
    37813839    //compare against a list of recent referer spammers
    37823840    $lines = array( '123666123\.com',
    37833841            '209\.29\.25\.180',
     3842            '[a-z]+19[0-9]{2}\.co\.cc',
    37843843            'aerhaethjsry\.com',
    37853844            'aimtrust\.com',
     
    37883847            'all\-lasik\-centers\.com',
    37893848            'allmymovies\.biz',
     3849            'articlemarketingrobots\.org',
    37903850            'baby\-kleidung\.runashop\.com',
    37913851            'bayanbag\.tk',
     
    37993859            'celebritydietdoctor\.com',
    38003860            'celebrity\-?diets\.(com|org|net|info|biz)',
     3861            '[a-z0-9]+\.cheapchocolatesale\.com',
    38013862            'chocolate\.com',
    38023863            'clients\.your\-server\.de',
    38033864            'couplesresortsonline\.com',
     3865            'creditcardsinformation\.info',
     3866            '.*\.css\-build\.info',
     3867            'h\-1.+\.cssgroup\.lv',
    38043868            '.*dietplan\.com',
     3869            'dogcareinsurancetips\.sosblog\.com',
     3870            'dollhouserugs\.com',
    38053871            'dreamworksdentalcenter\.com',
    38063872            'duunot\.eu',
     
    38113877            'frenchforbeginnerssite\.com',
    38123878            'gameskillinggames\.net',
     3879            'gardenactivities\.webnode\.com',
    38133880            'globalringtones\.net',
     3881            'gossipchips\.com',
    38143882            'gskstudio\.com',
    3815             'h\-13\d\-\d{3}\.cssgroup\.lv',
    38163883            'hearcam\.org',
     3884            'hearthealth\-hpe\.org',
    38173885            'highheelsale\.com',
    38183886            'homebasedaffiliatemarketingbusiness\.com',
     
    38243892            'it\.n\-able\.com',
    38253893            'justanimal\.com',
     3894            'justbazaar\.com',
     3895            'knowledgehubdata\.com',
    38263896            'koreanracinggirls\.com',
     3897            'lacomunidad\.elpais\.com',
    38273898            'lactoseintolerancesymptoms\.net',
    38283899            'liquiddiet[a-z\-]*\.com',
     
    38423913            'pinky\-vs\-cherokee\.com',
    38433914            'pinkyxxx\.org',
     3915            '[a-z]+\.pixnet\.net',
    38443916            'play\-mp3\.com',
    38453917            'poker\-review\.tk',
     
    38563928            'sitetalk\-revolution\.com',
    38573929            'smartforexsignal\.com',
     3930            'socratestheme\.me',
     3931            'stableincomeplan\.blogspot\.com',
    38583932            'staphinfectionpictures\.org',
    38593933            'static\.theplanet\.com',
    38603934            '[a-z]+\-[a-z]+\-symptoms\.com',
     3935            'thebestweddingparty\.com',
    38613936            'thik\-chik\.com',
    38623937            'thisweekendsmovies\.com',
     
    41354210// hook function to put a timestamp in page footer for page caching test
    41364211function wassup_foot() {
    4137     global $wassup_options, $wassupversion, $debug_mode;
    4138     if ($wassup_options->wassup_active == "1") {
    4139         //New in 1.8.2: separate screen resolution cookie for IE
    4140         if (!isset($_COOKIE['wassup_screen_res'])) {
    4141             echo "\n"; ?>
     4212    global $wassup_options, $wassupversion, $wscreen_res, $wdebug_mode;
     4213
     4214    //Since 1.8.2: separate 'wassup_screen_res' cookie in footer for
     4215    // IE users because Internet Explorer does not report screen height
     4216    // or width until after it begins to render the document body.
     4217    if (empty($wscreen_res) && !isset($_COOKIE['wassup_screen_res'])) {
     4218        echo "\n"; ?>
    41424219<!--[if IE]>
    41434220<script language=javascript>
    4144     var sheight = screen.height;
    4145     var swidth = screen.width;
    4146     document.cookie = "wassup_screen_res=" + swidth + " x " + sheight + "; path=/; domain=" + document.domain;
     4221//<![CDATA[
     4222    if (screen_res=="") {
     4223        screen_res = screen.width + " x " + screen.height;
     4224    }
     4225    if (screen_res!=" x ") {
     4226        var cdate = new Date();
     4227        cdate.setTime(cdate.getTime()+(48*60*60*1000));
     4228        var cexpires = cdate.toGMTString();
     4229        //var the_cookie = "wassup_screen_res="+escape(screen_res)+"; expires="+cexpires;
     4230        document.cookie = "wassup_screen_res=" + escape(screen_res)+ "; path=/; domain=" + document.domain;
     4231
     4232    }
     4233//]]>
    41474234</script>
    41484235<![endif]--><?php
    4149         }
    4150         //Output a comment with a current timestamp to verify that page is not cached (i.e. visit is being recorded).
    4151         echo "<!--\n<p class=\"small\"> WassUp $wassupversion ".__("timestamp","wassup").": ".date('Y-m-d h:i:sA T')." (".gmdate('h:iA',time()+(get_option('gmt_offset')*3600)).")<br />\n";
    4152         echo __("If above timestamp is not current time, this page is cached","wassup").".</p> -->\n";
    4153     }
    4154 }
     4236    } //end if !isset('wassup_screen_res')
     4237
     4238    //Output a comment with a current timestamp to verify that page is not cached (i.e. visit is being recorded).
     4239    echo "<!--\n<p class=\"small\"> WassUp $wassupversion ".__("timestamp","wassup").": ".date('Y-m-d h:i:sA T')." (".gmdate('h:iA',time()+(get_option('gmt_offset')*3600)).")<br />\n";
     4240    echo __("If above timestamp is not current time, this page is cached","wassup").".</p> -->\n";
     4241} //end wassup_foot
    41554242
    41564243/**
     
    42704357    }
    42714358
     4359    $wstart = (int)(current_time('timestamp') - 30.4*86400); //1 month in seconds
    42724360    // Widget TOP Browsers
    42734361    if ($wassup_settings['wassup_widget_topbr'] == 1) {
    4274         $top_period = '`timestamp` > 0';    //all time
     4362        $top_period = "'`timestamp` > $wstart'";    //one month
    42754363        $top_limit = attribute_escape($topbrlimit);
    42764364        $top_results =  wGetStats("browser",$top_limit,$top_period);
     
    42874375    // Widget TOP OSes
    42884376    if ($wassup_settings['wassup_widget_topos'] == 1) {
    4289         $top_period = '`timestamp` > 0';    //all time
     4377        $top_period = "'`timestamp` > $wstart'";    //one month
    42904378        $top_limit = attribute_escape($toposlimit);
    42914379        $top_results =  wGetStats("os",$top_limit,$top_period);
     
    43014389
    43024390    // Widget Visitors Online
    4303     $TotWid = New MainItems($table_tmp_name,$from_date,$to_date);
     4391    $TotWid = New WassupItems($table_tmp_name,$from_date,$to_date);
    43044392
    43054393    $currenttot = $TotWid->calc_tot("count", null, null, "DISTINCT");
     
    45214609    }
    45224610
     4611    $wstart = (int)(current_time('timestamp') - 30.4*86400); //1 month in seconds
    45234612    if ($wtopbr == 1) {
    4524         $top_period = '`timestamp` > 0';    //all time
     4613        $top_period = "'`timestamp` > $wstart'";    //one month
    45254614        $top_limit = attribute_escape($topbrlimit);
    45264615        $top_results =  wGetStats("browser",$top_limit,$top_period);
     
    45364625
    45374626    if ($wtopos == 1) {
    4538         $top_period = '`timestamp` > 0';    //all time
     4627        $top_period = "'`timestamp` > $wstart'";    //one month
    45394628        $top_limit = attribute_escape($toposlimit);
    45404629        $top_results =  wGetStats("os",$top_limit,$top_period);
     
    45504639
    45514640    // Visitors Online
    4552     $TotWid = New MainItems($table_tmp_name,$from_date,$to_date);
     4641    $TotWid = New WassupItems($table_tmp_name,$from_date,$to_date);
    45534642
    45544643    $currenttot = $TotWid->calc_tot("count", null, null, "DISTINCT");
     
    45844673        $chart_type = ($wassup_options->wassup_chart_type >0)? $wassup_options->wassup_chart_type: "2";
    45854674        $to_date = current_time("timestamp");
    4586         $Chart = New MainItems($wassup_table,"",$to_date);
     4675        $Chart = New WassupItems($wassup_table,"",$to_date);
    45874676            $chart_url = $Chart->TheChart(1, "400", "125", "", $chart_type, "bg,s,efebef|c,lg,90,edffff,0,efebef,0.8", "dashboard"); ?>
    45884677    <h3>WassUp <?php _e('Stats','wassup'); ?> <cite><a href="admin.php?page=<?php echo WASSUPFOLDER; ?>"><?php _e('More','wassup'); ?> &raquo;</a></cite></h3>
     
    46024691    $chart_type = ($wassup_options->wassup_chart_type >0)? $wassup_options->wassup_chart_type: "2";
    46034692    $res = ((int)$wassup_options->wassup_screen_res-160)/2;
    4604     $Chart = New MainItems($wassup_table,"",$to_date);
     4693    $Chart = New WassupItems($wassup_table,"",$to_date);
    46054694    $chart_url = $Chart->TheChart(1, $res, "180", "", $chart_type, "bg,s,efebef|c,lg,90,edffff,0,eae9e9,0.8", "dashboard");
    46064695    $max_char_len= 40;
     
    46114700        margin:-10px !important;
    46124701        padding:2px 0 5px;
    4613         background: #eae9e9 url("'.WASSUPFOLDER.'/css/images/bg_wrap.png") repeat;
     4702        background: #eae9e9 url("'.WASSUPFOLDER.'/img/bg_wrap.png") repeat;
    46144703        font-size:11px;
    46154704    }
Note: See TracChangeset for help on using the changeset viewer.