Changeset 141 for trunk/wassup.php
- Timestamp:
- 06/12/08 09:04:03 (7 months ago)
- Files:
-
- 1 modified
-
trunk/wassup.php (modified) (35 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wassup.php
r140 r141 4 4 Plugin URI: http://www.wpwp.org 5 5 Description: Wordpress plugin to analyze your visitors traffic with real time stats, chart and a lot of chronological informations. It has sidebar Widget support to show current online visitors and other statistics. 6 Version: 1. 5.26 Version: 1.6 7 7 Author: Michele Marcucci 8 8 Author URI: http://www.michelem.org/ … … 17 17 die('Permission Denied! You are not allowed to call this page directly.'); 18 18 } 19 $version = "1. 5.2";19 $version = "1.6"; 20 20 define('WASSUPFOLDER', dirname(plugin_basename(__FILE__)), TRUE); 21 21 require_once(dirname(__FILE__).'/lib/wassup.class.php'); … … 165 165 //# -Load jquery AJAX library and dependent javascripts for admin menus 166 166 //# -Load language/localization files for admin menus and widget 167 //# -Set 'wassup' ## General hooks167 //# -Set 'wassup' cookie for new visitor hits 168 168 function wassup_init() { 169 169 global $wpurl; … … 550 550 $to_date = wassup_get_time(); 551 551 $from_date = strtotime('-3 minutes', $to_date); 552 $currenttot = $wpdb->get_var("SELECT COUNT(DISTINCT wassup_id) as currenttot FROM $table_tmp_name WHERE timestampBETWEEN $from_date AND $to_date");552 $currenttot = $wpdb->get_var("SELECT COUNT(DISTINCT wassup_id) as currenttot FROM $table_tmp_name WHERE `timestamp` BETWEEN $from_date AND $to_date"); 553 553 $currenttot = $currenttot+0; //set to integer 554 554 print "<p class='legend'>".__("Visitors online", "wassup").": <strong>".$currenttot."</strong></p><br />"; 555 555 if ($currenttot > 0) { 556 $qryC = $wpdb->get_results("SELECT id, wassup_id, max(timestamp) as max_timestamp, ip, hostname, searchengine, urlrequested, agent, referrer, spider, username, comment_author FROM $table_tmp_name WHERE timestampBETWEEN $from_date AND $to_date GROUP BY ip ORDER BY max_timestamp DESC");556 $qryC = $wpdb->get_results("SELECT id, wassup_id, max(timestamp) as max_timestamp, ip, hostname, searchengine, urlrequested, agent, referrer, spider, username, comment_author FROM $table_tmp_name WHERE `timestamp` BETWEEN $from_date AND $to_date GROUP BY ip ORDER BY max_timestamp DESC"); 557 557 foreach ($qryC as $cv) { 558 558 //$timestamp = $cv->max_timestamp; //redundant 559 559 $timed = gmdate("H:i:s", $cv->max_timestamp); 560 $ip = @explode(",", $cv->ip); 560 $ip_proxy = strpos($cv->ip,","); 561 //if proxy, get 2nd ip... 562 if ($ip_proxy !== false) { 563 $ip = substr($cv->ip,(int)$ip_proxy+1); 564 } else { 565 $ip = $cv->ip; 566 } 561 567 if ($cv->referrer != '') { 562 568 if (!eregi($wpurl, $cv->referrer) OR $cv->searchengine != "") { … … 575 581 ?> 576 582 <div class="sum"> 577 <span class="sum-box"><?php if ($numurl >= 2) { ?><a href="#" class="showhide" id="<?php echo $cv->id ?>"><?php print $ip [0]; ?></a><?php } else { ?><?php print $ip[0]; ?><?php } ?></span>583 <span class="sum-box"><?php if ($numurl >= 2) { ?><a href="#" class="showhide" id="<?php echo $cv->id ?>"><?php print $ip; ?></a><?php } else { ?><?php print $ip; ?><?php } ?></span> 578 584 <div class="sum-det"><span class="det1"> 579 585 <?php … … 604 610 <ul class="url"> 605 611 <?php 606 $qryCD = $wpdb->get_results("SELECT timestamp, urlrequested FROM $table_tmp_name WHERE wassup_id='".$cv->wassup_id."' ORDER BY timestampASC");612 $qryCD = $wpdb->get_results("SELECT `timestamp`, urlrequested FROM $table_tmp_name WHERE wassup_id='".$cv->wassup_id."' ORDER BY `timestamp` ASC"); 607 613 $i=0; 608 614 foreach ($qryCD as $cd) { … … 758 764 //# -Helene D. 3/4/08. 759 765 if (!empty($_GET['deleteMARKED']) && $wassup_options->wmark == "1" ) { 760 $rec_deleted = $wpdb->get_var("SELECT COUNT(ip) as deleted FROM $table_name WHERE ip='".urlencode(attribute_escape($_GET['dip']))."' AND timestampBETWEEN $from_date AND $to_date");766 $rec_deleted = $wpdb->get_var("SELECT COUNT(ip) as deleted FROM $table_name WHERE ip='".urlencode(attribute_escape($_GET['dip']))."' AND `timestamp` BETWEEN $from_date AND $to_date"); 761 767 if (method_exists($wpdb,'prepare')) { 762 $wpdb->query($wpdb->prepare("DELETE FROM $table_name WHERE ip='%s' AND timestampBETWEEN %s AND %s", urlencode(attribute_escape($_GET['dip'])), $from_date, $to_date));768 $wpdb->query($wpdb->prepare("DELETE FROM $table_name WHERE ip='%s' AND `timestamp` BETWEEN %s AND %s", urlencode(attribute_escape($_GET['dip'])), $from_date, $to_date)); 763 769 } else { 764 $wpdb->query("DELETE FROM $table_name WHERE ip='".urlencode(attribute_escape($_GET['dip']))."' AND timestampBETWEEN $from_date AND $to_date");770 $wpdb->query("DELETE FROM $table_name WHERE ip='".urlencode(attribute_escape($_GET['dip']))."' AND `timestamp` BETWEEN $from_date AND $to_date"); 765 771 } 766 772 echo '<p><strong>'.$rec_deleted.' '.__('records deleted','wassup').'</strong></p>'; … … 936 942 $timeF = gmdate("H:i:s", $timestampF); 937 943 $datetimeF = gmdate('Y-m-d H:i:s', $timestampF); 938 $ip = @explode(",", $rk->ip); 939 940 // Visitor Record - raw data (hidden) ?> 941 <div id="raw-<?php echo $rk->wassup_id; ?>" style="display:none; padding-top:7px;" > 944 //$ip = @explode(",", $rk->ip); 945 $ip_proxy = strpos($rk->ip,","); 946 //if proxy, get 2nd ip... 947 if ($ip_proxy !== false) { 948 $ip = substr($rk->ip,(int)$ip_proxy+1); 949 } else { 950 $ip = $rk->ip; 951 } 952 953 // Visitor Record - raw data (hidden) 954 $raw_div="raw-".substr($rk->wassup_id,0,25).rand(0,99); 955 echo "\n"; ?> 956 <div id="<?php echo $raw_div; ?>" style="display:none; padding-top:7px;" > 942 957 <h2><?php _e("Raw data","wassup"); ?>:</h2> 943 958 <style type="text/css">.raw { color: #542; padding-left:5px; }</style> 944 959 <ul style="list-style-type:none;padding:20px 0 0 30px;"> 960 <li><?php echo __("Visit type","wassup").': <span class="raw">'; 961 if ($rk->username != "") { 962 echo __("Logged-in user","wassup").' - '.$rk->username; 963 } elseif ($rk->spam == "1" || $rk->spam == "2" ) { 964 _e("Spammer","wassup"); 965 } elseif ($rk->comment_author != "") { 966 echo __("Comment author","wassup").' - '.$rk->comment_author; 967 } elseif ($rk->feed != "") { 968 echo __("Feed","wassup").' - '.$rk->feed; 969 } elseif ($rk->spider != "") { 970 echo __("Spider","wassup").' - '.$rk->spider; 971 } else { 972 _e("Regular visitor","wassup"); 973 } 974 echo '</span>'; ?></li> 945 975 <li><?php echo __("IP","wassup").': <span class="raw">'.$rk->ip.'</span>'; ?></li> 946 976 <li><?php echo __("Hostname","wassup").': <span class="raw">'.$rk->hostname.'</span>'; ?></li> 977 <li><?php echo __("Url Requested","wassup").': <span class="raw">'.htmlspecialchars(html_entity_decode(clean_url($rk->urlrequested))).'</span>'; ?></li> 947 978 <li><?php echo __("User Agent","wassup").': <span class="raw">'.$rk->agent.'</span>'; ?></li> 948 979 <li><?php echo __("Referrer","wassup").': <span class="raw">'.urldecode($rk->referrer).'</span>'; ?></li> 949 980 <?php if ($rk->search != "") { ?> 950 <li><?php echo __("Search","wassup").': <span class="raw">'.$rk->search.'</span>'; ?></li> 981 <li><?php echo __("Search Engine","wassup").': <span class="raw">'.$rk->searchengine.'</span> '; 982 echo __("Search","wassup").': <span class="raw">'.$rk->search.'</span>'; ?></li> 951 983 <?php } 952 984 if ($rk->os != "") { ?> … … 957 989 <?php } 958 990 if ($rk->language != "") { ?> 959 <li><?php echo __("L anguage","wassup").': <span class="raw">'.$rk->language.'</span>'; ?></li>991 <li><?php echo __("Locale/Language","wassup").': <span class="raw">'.$rk->language.'</span>'; ?></li> 960 992 <?php } ?> 961 <li><?php echo __("Url Requested","wassup").': <span class="raw">'.htmlspecialchars(html_entity_decode(clean_url($rk->urlrequested))).'</span>'; ?></li>962 <li><?php echo __("End Timestamp","wassup").': <span class="raw">'.$datetimeF.' ( '.$rk->max_timestamp.' )</span>'; ?></li>993 <li><?php echo 'Wassup ID'.': <span class="raw">'.$rk->wassup_id.'</span>'; ?></li> 994 <li><?php echo __("End timestamp","wassup").': <span class="raw">'.$datetimeF.' ( '.$rk->max_timestamp.' )</span>'; ?></li> 963 995 </ul> 964 996 </div> <!-- raw-wassup_id --> … … 983 1015 984 1016 <div class="delID<?php echo $rk->wassup_id ?>"> 985 <div class="<?php if ($wassup_options->wmark == 1 AND $wassup_options->wip == $ip [0]) echo "sum-nav-mark"; else echo "sum-nav"; ?>">1017 <div class="<?php if ($wassup_options->wmark == 1 AND $wassup_options->wip == $ip) echo "sum-nav-mark"; else echo "sum-nav"; ?>"> 986 1018 987 1019 <p class="delbut"> 988 1020 <?php // Mark/Unmark IP 989 if ($wassup_options->wmark == 1 AND $wassup_options->wip == $ip [0]) { ?>990 <a href="?<?php echo $_SERVER['QUERY_STRING']; ?>&deleteMARKED=1&dip=<?php print $ip [0]; ?>" style="text-decoration:none;">1021 if ($wassup_options->wmark == 1 AND $wassup_options->wip == $ip) { ?> 1022 <a href="?<?php echo $_SERVER['QUERY_STRING']; ?>&deleteMARKED=1&dip=<?php print $ip; ?>" style="text-decoration:none;"> 991 1023 <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/cross.png" alt="'.__('delete','wassup').'" title="'.__('Delete ALL marked records with this IP','wassup'); ?>" /></a> 992 1024 <a href="?page=<?php echo WASSUPFOLDER; ?>&wmark=0" style="text-decoration:none;"> … … 995 1027 <a href="#" class="deleteID" id="<?php echo $rk->wassup_id ?>" style="text-decoration:none;"> 996 1028 <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/cross.png" alt="'.__('delete','wassup').'" title="'.__('Delete this record','wassup'); ?>" /></a> 997 <a href="?<?php echo $_SERVER['QUERY_STRING']; ?>&wmark=1&wip=<?php print $ip [0]; ?>" style="text-decoration:none;">1029 <a href="?<?php echo $_SERVER['QUERY_STRING']; ?>&wmark=1&wip=<?php print $ip; ?>" style="text-decoration:none;"> 998 1030 <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/error_add.png" alt="'.__('mark','wassup').'" title="'.__('Mark IP','wassup'); ?>" /></a> 999 1031 <?php } ?> 1000 <a href="#TB_inline?height=400&width=<?php echo $res.'&inlineId= raw-'.$rk->wassup_id; ?>" class="thickbox">1032 <a href="#TB_inline?height=400&width=<?php echo $res.'&inlineId='.$raw_div; ?>" class="thickbox"> 1001 1033 <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/database_table.png" alt="'.__('show raw table','wassup').'" title="'.__('Show the items as raw table','wassup'); ?>" /></a> 1002 1034 </p> 1003 1035 1004 <span class="sum-box"><?php if ($numurl >= 2) { ?><a href="#" class="showhide" id="<?php echo $rk->id ?>"><?php print $ip [0]; ?></a><?php } else { ?><?php print $ip[0]; ?><?php } ?></span>1036 <span class="sum-box"><?php if ($numurl >= 2) { ?><a href="#" class="showhide" id="<?php echo $rk->id ?>"><?php print $ip; ?></a><?php } else { ?><?php print $ip; ?><?php } ?></span> 1005 1037 <span class="sum-date"><?php print $datetimeF; ?></span> 1006 1038 <div class="sum-det"><span class="det1"> … … 1059 1091 <ul style="background:#fdeec8;" class="spider"> 1060 1092 <li class="feed"><span class="indent-li-agent"><?php _e('FEEDREADER','wassup'); ?>: <strong><?php print $rk->spider; ?></strong></span></li> 1061 <li class="feed"><span class="indent-li-agent"><?php _e('SUBSCRIBER(S)','wassup'); ?>: <strong><?php print $rk->feed; ?></strong></span></li> 1093 <?php if (is_numeric($rk->feed)) { ?> 1094 <li class="feed"><span class="indent-li-agent"><?php _e('SUBSCRIBER(S)','wassup'); ?>: <strong><?php print (int)$rk->feed; ?></strong></span></li> 1095 <?php } ?> 1062 1096 </ul> 1063 1097 <?php } else { ?> … … 1096 1130 <ul class="url"> 1097 1131 <?php 1098 $qryCD = $wpdb->get_results("SELECT timestamp, urlrequested FROM $table_name WHERE wassup_id='".$rk->wassup_id."' ORDER BY timestampASC");1132 $qryCD = $wpdb->get_results("SELECT `timestamp`, urlrequested FROM $table_name WHERE wassup_id='".$rk->wassup_id."' ORDER BY `timestamp` ASC"); 1099 1133 $i=0; 1100 1134 foreach ($qryCD as $cd) { … … 1242 1276 $ipAddress = ""; 1243 1277 $hostname = ""; 1244 //#### Get the host/IPdetails from http header...1278 //#### Get the visitor's details from http header... 1245 1279 if (isset($_SERVER["REMOTE_ADDR"])) { 1246 1280 if ($_SERVER["HTTP_X_FORWARDED_FOR"] != ""){ 1247 $IP = $_SERVER["HTTP_X_FORWARDED_FOR"]; 1281 //in case of multiple forwarding 1282 list($IP) = explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]); 1248 1283 $proxy = $_SERVER["REMOTE_ADDR"]; 1249 $hostname = @gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]); 1284 $hostname = @gethostbyaddr($IP); 1285 if (empty($hostname) || $hostname == "unknown") { 1286 $hostname = @gethostbyaddr($proxy); 1287 } 1250 1288 $ipAddress = $proxy.",".$IP; 1251 1289 }else{ 1252 $IP = $_SERVER["REMOTE_ADDR"];1253 $hostname = @gethostbyaddr($ _SERVER["REMOTE_ADDR"]);1254 $ipAddress = $ IP;1290 list($IP) = explode(",",$_SERVER["REMOTE_ADDR"]); 1291 $hostname = @gethostbyaddr($IP); 1292 $ipAddress = $_SERVER["REMOTE_ADDR"]; 1255 1293 } 1256 1294 } 1295 if (empty($IP)) { $IP = $ipAddress; } 1296 if (empty($hostname)) { $hostname = "unknown"; } 1257 1297 $userAgent = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''); 1258 1298 //# Create a new wassup id for this visit from a … … 1261 1301 //# same ip/userAgent within a 30 minute-period, can be 1262 1302 //# tracked, even when session/cookies is disabled. 1263 $temp_id = sprintf("%-06 4.64s", date('YmdH').str_replace(array('','/','.','\'','"',"\\",'$','-','&','+','_',';',',','>','<',':','#','*','%','http',')','(',), '', intval(date('i')/30).$ipAddress.strrev($userAgent).strrev($hostname).intval(date('i')/30)).date('HdmY').rand());1303 $temp_id = sprintf("%-060.60s", date('YmdH').str_replace(array(' ','http://','www.','/','.','\'','"',"\\",'$','-','&','+','_',';',',','>','<',':','#','*','%','!','@',')','(',), '', intval(date('i')/30).$IP.strrev($userAgent).strrev($hostname).intval(date('i')/30)).date('HdmY').$hostname.rand()); 1264 1304 1265 1305 //Work-around for cookie rejection: … … 1293 1333 if (isset($_SERVER["REMOTE_ADDR"])) { 1294 1334 if ($_SERVER["HTTP_X_FORWARDED_FOR"] != ""){ 1295 $IP = $_SERVER["HTTP_X_FORWARDED_FOR"]; 1335 //in case of multiple forwarding 1336 list($IP) = explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]); 1296 1337 $proxy = $_SERVER["REMOTE_ADDR"]; 1297 $hostname = @gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]); 1338 $hostname = @gethostbyaddr($IP); 1339 if (empty($hostname) || $hostname == "unknown") { 1340 $hostname = @gethostbyaddr($proxy); 1341 } 1298 1342 $ipAddress = $proxy.",".$IP; 1299 1343 }else{ 1300 $IP = $_SERVER["REMOTE_ADDR"];1301 $hostname = @gethostbyaddr($ _SERVER["REMOTE_ADDR"]);1302 $ipAddress = $ IP;1344 list($IP) = explode(",",$_SERVER["REMOTE_ADDR"]); 1345 $hostname = @gethostbyaddr($IP); 1346 $ipAddress = $_SERVER["REMOTE_ADDR"]; 1303 1347 } 1304 1348 } 1349 if (empty($IP)) { $IP = $ipAddress; } 1350 if (empty($hostname)) { $hostname = "unknown"; } 1351 1305 1352 // Get the visitor's resolution, TODO 1306 1353 /* … … 1368 1415 if ($wassup_options->wassup_loggedin == 1 || !is_user_logged_in() ) { 1369 1416 if ($wassup_options->wassup_attack == 1 || stristr($userAgent,"libwww-perl") === FALSE ) { 1417 if (!is_404()) { //don't record 404 pages... 1370 1418 1371 1419 //##### Extract useful visit information from http header.. 1372 $ dip = &new Detector("", $userAgent);1373 $ browser = $dip->browser." ".$dip->browser_version;1374 $os = $dip->os." ".$dip->os_version;1420 $browser = ""; 1421 $os = ""; 1422 list($browser,$os) = wGetBrowser($userAgent); 1375 1423 1376 1424 //#=================================================== … … 1383 1431 //# such, even when session/cookies is disabled. 1384 1432 //# An md5 encoded version of temp_id is saved as "wassup_id". 1385 $temp_id = sprintf("%-06 4.64s", date('YmdH').str_replace(array('','/','.','\'','"',"\\",'$','-','&','+','_',';',',','>','<',':','#','*','%','http',')','(',), '', intval(date('i')/30).$ipAddress.strrev($userAgent).strrev($hostname).intval(date('i')/30)).date('HdmY').rand());1433 $temp_id = sprintf("%-060.60s", date('YmdH').str_replace(array(' ','http://','www.','/','.','\'','"',"\\",'$','-','&','+','_',';',',','>','<',':','#','*','%','!','@',')','(',), '', intval(date('i')/30).$IP.strrev($userAgent).strrev($hostname).intval(date('i')/30)).date('HdmY').$hostname.rand()); 1386 1434 $wassup_id = ""; 1387 1435 //Read the cookie for wassup_id … … 1494 1542 if ($dup_urlrequest == 0) { 1495 1543 //##### Extract useful visit information from http header.. 1496 if ($os != "" OR $browser != "") { 1497 $bot=wGetSpider($userAgent); 1498 if (is_array($bot)) { 1499 $spider = $bot[0]; 1500 $feed = $bot[1]; 1501 } else { 1502 $spider = trim($bot); 1503 } 1504 } 1544 if (empty($browser) || stristr($browser,"N/A")) { 1545 list($spider,$feed) = wGetSpider($userAgent,$hostname); 1546 } 1547 1505 1548 //#I prefer to see os/browser info. for spiders/bots. 1506 //if ($spider != '') { $os=''; $browser=''; }1507 1549 1508 1550 //spider exclusion control … … 1559 1601 } 1560 1602 if ( $wassup_options->wassup_spam == 1 && $spam == 0 ) { 1561 //# some useragents to exclude from spam checking... 1562 $goodbots = array('Google','Yahoo!','MSN','SummizeFeedReader'); 1603 //# some valid spiders to exclude from spam checking 1604 $goodbot = false; 1605 if ($hostname!="" && !empty($spider)) { 1606 if (preg_match('/^(googlebot|msnbot|yahoo\!\ slurp|technorati)/i',$spider)>0 && preg_match('/(googlebot|live|msn|yahoo|technorati)\.(com|net)$/i',$hostname)>0){ 1607 $goodbot = true; 1608 } 1609 } 1563 1610 1564 1611 //# No duplicate spam testing in same session unless there … … 1569 1616 //# No spam check on known bots (google, yahoo,...) unless 1570 1617 //# there is a comment or forum page request... 1571 } elseif (empty($spider) || array_search($spider,$goodbots) === FALSE|| stristr($urlRequested,"comment") !== FALSE || stristr($urlRequested,"forum") !== FALSE || !empty($comment_user) ) {1618 } elseif (empty($spider) || !$goodbot || stristr($urlRequested,"comment") !== FALSE || stristr($urlRequested,"forum") !== FALSE || !empty($comment_user) ) { 1572 1619 1573 1620 // Try to search for previous spammer detected by akismet with same IP … … 1654 1701 $recorded = true; 1655 1702 // Delete records older then 3 minutes 1656 $wpdb->query("DELETE FROM $table_tmp_name WHERE timestamp<'".strtotime("-3 minutes", $timestamp)."'");1703 $wpdb->query("DELETE FROM $table_tmp_name WHERE `timestamp`<'".strtotime("-3 minutes", $timestamp)."'"); 1657 1704 1658 1705 } //end if $spam == 0 … … 1661 1708 } //end if dup_urlrequest == 0 1662 1709 1710 } //end if !is_404 1663 1711 } //end if wassup_attack 1664 1712 } //end if wassup_loggedin … … 1678 1726 $from_date = strtotime($wassup_options->delete_auto, $timestamp); 1679 1727 //#check before doing delete as it could lock the table... 1680 if ((int)$wpdb->get_var("SELECT COUNT(id) FROM $table_name WHERE timestamp<'$from_date'") > 0) {1681 $wpdb->query("DELETE FROM $table_name WHERE timestamp<'$from_date'");1728 if ((int)$wpdb->get_var("SELECT COUNT(id) FROM $table_name WHERE `timestamp`<'$from_date'") > 0) { 1729 $wpdb->query("DELETE FROM $table_name WHERE `timestamp`<'$from_date'"); 1682 1730 } 1683 1731 // Optimize table once a day … … 1726 1774 1727 1775 if (method_exists($wpdb,'prepare')) { 1728 $insert = $wpdb->query( $wpdb->prepare("INSERT INTO $table_name (wassup_id, timestamp, ip, hostname, urlrequested, agent, referrer, search, searchpage, os, browser, language, screen_res, searchengine, spider, feed, username, comment_author, spam)1776 $insert = $wpdb->query( $wpdb->prepare("INSERT INTO $table_name (wassup_id, `timestamp`, ip, hostname, urlrequested, agent, referrer, search, searchpage, os, browser, language, screen_res, searchengine, spider, feed, username, comment_author, spam) 1729 1777 VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )", 1730 1778 attribute_escape($wassup_id), … … 1750 1798 } else { 1751 1799 $insert = $wpdb->query("INSERT INTO " . $table_name . 1752 " (wassup_id, timestamp, ip, hostname, urlrequested, agent, referrer, search, searchpage, os, browser, language, screen_res, searchengine, spider, feed, username, comment_author, spam) " .1800 " (wassup_id, `timestamp`, ip, hostname, urlrequested, agent, referrer, search, searchpage, os, browser, language, screen_res, searchengine, spider, feed, username, comment_author, spam) " . 1753 1801 "VALUES ( 1754 1802 '".attribute_escape($wassup_id)."', … … 1905 1953 } 1906 1954 1907 function wGetSpider($agent = null){ 1955 //extract browser and platform info from a user agent string and 1956 // return the values in an array: 0->browser 1->os. -Helene D. 6/7/08. 1957 function wGetBrowser($agent="") { 1958 if (empty($agent)) { $agent = $_SERVER['HTTP_USER_AGENT']; } 1959 $browsercap = array(); 1960 $browser = ""; 1961 $os = ""; 1962 //check PHP browscap data for browser and platform, when available 1963 if (ini_get("browscap") != "" ) { 1964 $browsercap = get_browser($agent,true); 1965 if (!empty($browsercap['platform'])) { 1966 if (stristr($browsercap['platform'],"unknown") === false) { 1967 $os = $browsercap['platform']; 1968 if (!empty($browsercap['browser'])) { 1969 $browser = $browsercap['browser']; 1970 } else { 1971 $browser = $browsercap['parent']; 1972 } 1973 if (!empty($browsercap['version'])) { 1974 $browser = $browser." ".$browsercap['version']; 1975 } 1976 } } 1977 //reject generic browscap browsers (ex: mozilla, default) 1978 if (preg_match('/^(mozilla|default|unknown)/i',$browser) > 0) { 1979 $browser = ""; 1980 } 1981 } 1982 $os = trim($os); 1983 $browser = trim($browser); 1984 1985 //use Detector class when browscap is missing or browser is unknown 1986 if ( $os == "" || $browser == "") { 1987 $dip = &new Detector("", $agent); 1988 $browser = $dip->browser." ".$dip->browser_version; 1989 $os = $dip->os." ".$dip->os_version; 1990 } 1991 return array(trim($browser),trim($os)); 1992 } //end function wGetBrowser 1993 1994 //extract spider and feed info from a user agent string and 1995 // return the values in an array: 0->spider 1->feed 1996 function wGetSpider($agent="",$hostname=""){ 1997 if (empty($agent)) { $agent = $_SERVER['HTTP_USER_AGENT']; } 1998 $crawler = ""; 1999 $feed = ""; 2000 $os = ""; 2001 //check browscap data for crawler info., when available 2002 if (ini_get("browscap") != "" ) { 2003 $browsercap = get_browser($agent,true); 2004 //if no platform(os), assume crawler... 2005 if (!empty($browsercap['platform'])) { 2006 if ( $browsercap['platform'] != "unknown") { 2007 $os = $browsercap['platform']; 2008 } 2009 } 2010 if (!empty($browsercap['crawler']) || !empty($browsercap['stripper']) || $os == "") { 2011 if (!empty($browsercap['browser'])) { 2012 $crawler = $browsercap['browser']; 2013 } else { 2014 $crawler = $browsercap['parent']; 2015 } 2016 if (!empty($browsercap['version'])) { 2017 $crawler = $crawler." ".$browsercap['version']; 2018 } 2019 } 2020 //reject unknown browscap crawlers (ex: default) 2021 if (preg_match('/^(default|unknown)/i',$crawler) > 0) { 2022 $crawler = ""; 2023 } 2024 } 2025 2026 //get crawler info. from a known list 2027 $crawler = trim($crawler); 1908 2028 $agent=str_replace(" ","",$agent); 1909 $key = null; 2029 if (empty($crawler)) { 2030 $key = null; 1910 2031 $lines = array("Wordpress Pingback/Trackback|Wordpress|", "Alexa|ia_archiver|","Ask.com/Teoma|AskJeeves/Teoma)|","Biz360|Biz360|","Naver|NaverBot|","Naver|Cowbot|","cURL|curl/|","Google|Googlebot/|", 1911 2032 "Google|googlebot/|","Google Images|Googlebot-Image|","LookSmart|grub-client|","Yahoo!|slurp@inktomi|","Yahoo!|Yahoo!Slurp|", … … 1968 2089 "GurujiBot|GurujiBot|", "Missigua Locator|Missigua Locator|", "ISC Systems iRc Search|ISC Systems iRc Search|", "whiteiexpres/Nutch|whiteiexpres/Nutch|", 1969 2090 "kalooga/kalooga|kalooga/kalooga|", "Bookdog|Bookdog|", "webLyzard|webLyzard|", "EnaBot|EnaBot|", "AboutUsBot|AboutUsBot|"); 1970 foreach($lines as $line_num => $spider) { 1971 list($nome,$key)=explode("|",$spider); 1972 if(@strpos(strtolower($agent),strtolower($key))===FALSE) continue; 1973 if (@strpos(strtolower($agent), "subscriber")!== FALSE) { 1974 preg_match("/([0-9]{1,10})(subscriber)/i", $agent, $subscriber); 1975 $feed[] = $nome; 1976 $feed[] = $subscriber[1]; 1977 // It's a feedreader with some subscribers 1978 return $feed; 2091 foreach($lines as $line_num => $spider) { 2092 list($nome,$key)=explode("|",$spider); 2093 if(stristr($agent,$key)===FALSE) { continue; } 2094 else { $crawler = trim($nome); } 2095 } 2096 } // end if crawler 2097 2098 //determine if this is a feed reader... 2099 if (preg_match("/([0-9]{1,10})(subscriber)/i",$agent,$subscriber) > 0) { 2100 // It's a feedreader with some subscribers 2101 $feed = $subscriber[1]; 2102 if (empty($crawler)) { 2103 $crawler = "Feed Reader"; 2104 } 2105 } elseif (@strpos(strtolower($agent),"feed")!== FALSE) { 2106 if (empty($crawler)) { 2107 $crawler = "Feed Reader"; 2108 $feed = "feed reader"; 1979 2109 } else { 1980 // find it! 1981 return $nome; 1982 } 1983 } 1984 return null; 2110 $feed = $crawler; 2111 } 2112 } //end if preg_match subscriber 2113 2114 //check for spoofers of Google/Msn/Yahoo crawlers... 2115 if ($hostname!="") { 2116 if (preg_match('/^(googlebot|msnbot|yahoo\!\ slurp)/i',$crawler)>0 && preg_match('/(googlebot|live|msn|yahoo)\./i',$hostname)==0){ 2117 $crawler = "Spoofer bot"; 2118 } 2119 } //end if hostname 2120 2121 return array($crawler,trim($feed)); 1985 2122 } 1986 2123 … … 1993 2130 $badhostfile= dirname(__FILE__).'/badhosts.txt'; 1994 2131 $key = null; 1995 1996 2132 if (empty($referrer)) { return null; } //nothing to check... 1997 2133 … … 2004 2140 } 2005 2141 } 2006 2007 2142 $lines = array("1clickholdem.com", "1ps.biz", "24h.to", "4all-credit.com", "4all-prescription.com", "4u-money.com", "6q.org", "88.to", "always-casino.com", 2008 2143 "always-credit.com", "andipink.com", "antiquemarketplace.net", "artmedia.com.ru", "asstraffic.com", "at.cx", "available-casino.com", "available-credit.com",
