Changeset 444137
- Timestamp:
- 09/27/2011 10:23:58 AM (14 years ago)
- Location:
- wassup/trunk
- Files:
-
- 8 added
- 16 edited
-
badhosts.txt (modified) (1 diff)
-
css/images/Thumbs.db (added)
-
css/images/list-bg.png (modified) (previous)
-
css/images/list-bg2.png (modified) (previous)
-
css/images/list-bg3.png (modified) (previous)
-
css/wassup.css (modified) (27 diffs)
-
img/Thumbs.db (added)
-
img/b_delete.png (added)
-
img/b_delete2.png (added)
-
img/b_select.png (added)
-
img/b_select2.png (added)
-
img/error_add.png (modified) (previous)
-
img/error_delete.png (modified) (previous)
-
img/flags/Thumbs.db (added)
-
js/jquery.min.js (added)
-
lib/action.php (modified) (6 diffs)
-
lib/compat_functions.php (modified) (1 diff)
-
lib/main.php (modified) (37 diffs)
-
lib/settings.php (modified) (11 diffs)
-
lib/uadetector.class.php (modified) (42 diffs)
-
lib/upgrade.php (modified) (13 diffs)
-
lib/wassup.class.php (modified) (9 diffs)
-
readme.txt (modified) (8 diffs)
-
wassup.php (modified) (118 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wassup/trunk/badhosts.txt
r433606 r444137 738 738 himailer\.com 739 739 himsearch\.com 740 hinet\.net740 \.sg[0-9]+\.myweb\.hinet\.net 741 741 hitprofile\.com 742 742 hj68\.com -
wassup/trunk/css/wassup.css
r433606 r444137 4 4 */ 5 5 #wassup-wrap { 6 padding: 1px 5px 3px;7 6 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; 9 10 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; 17 20 } 18 21 #wassup-wrap table { border-collapse: collapse; padding: 2px; } … … 24 27 #wassup-wrap img { 25 28 display: inline; 26 vertical-align: bottom;29 vertical-align: middle; 27 30 margin: 0 2px 2px 0; 28 31 padding:0; … … 35 38 #wassup-wrap td.legend a { border-bottom: 1px solid; } 36 39 #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; } 38 42 .wassup-icon {} 39 43 .wassup-content { min-height:225px; } … … 42 46 .wassup-menu-link { 43 47 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; 45 50 height: 22px; 46 51 padding: 0; … … 86 91 height: 22px; 87 92 line-height: 22px; 88 font-size: 10px;89 93 } 90 94 #wassup-menu li.current a { … … 110 114 } 111 115 #wassup-menu li.current, #wassup-menu-link:active { 116 height: 24px !important; 117 margin-bottom: -2px !important; 112 118 color: #00284a; 113 119 background: url("images/link.png") no-repeat bottom center; … … 133 139 color: #445; 134 140 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; 142 152 } 143 153 .main-tabs a, .main-tabs a:link { … … 185 195 background-color: #778; 186 196 border: 1px solid #fafeee; 187 box-shadow: 0 0 2px rgba(50, 80, 80, 0.3);188 197 -moz-box-shadow:0 0 2px rgba(50, 80, 80, 0.3); 189 198 -webkit-box-shadow:0 0 2px rgba(50, 80, 80, 0.3); 199 box-shadow: 0 0 2px rgba(50, 80, 80, 0.3); 190 200 } 191 201 .pagination .disabled { … … 216 226 font-size: 11px; 217 227 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; */ 220 231 } 221 232 .sum-nav, .sum-nav-mark, .sum-spy { 222 233 position: relative; 223 234 clear: left; 224 width: 100%;235 /* width: 100%; */ 225 236 min-height: 50px; 226 237 margin: 0 !important; … … 228 239 font-size: 11px; 229 240 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; 231 244 background: url("images/list-bg.png") repeat-x; 232 245 } … … 247 260 margin: 12px 0 0 0 !important; 248 261 padding: 1px 1px 0 !important; 249 border-top: 1px solid # 89a;250 border-right: 1px solid #7 89;251 border-left: 1px solid #7 89;262 border-top: 1px solid #fefffe; 263 border-right: 1px solid #779; 264 border-left: 1px solid #779; 252 265 border-bottom: 3px solid #347; 253 266 min-height: 50px; 254 267 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; 258 271 } 259 272 .delbut { … … 273 286 padding: 0; 274 287 /* width: 100%; */ 275 height: 1px;288 height: 3px; 276 289 clear: both; 277 background-color: # 347 /* #899; */290 background-color: #77799f; 278 291 } 279 292 .sum-det, .sum-det-spy { … … 300 313 .det1 a { font-weight: bold; border-bottom: 1px solid !important; } 301 314 .det2 a, .det2 a:link, .sum-det span.det2 a { 302 color: #349 !important; /*#00008c #00284a */315 color: #349 !important; 303 316 } 304 317 .det2 a:hover, .sum-det span.det2 a:hover { … … 328 341 height: 28px; 329 342 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; */ 331 347 } 332 348 .sum-box-ip { … … 365 381 line-height: 1.1em; 366 382 } 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; } 368 391 #toptenchart a:hover { color: #d54d22; } 369 392 ul.charts { … … 371 394 margin: 0; 372 395 padding: 0; 396 font: 8pt sans-serif; 397 line-height: 1.1em; 373 398 border-bottom: 1px solid #dedede; 399 border-right: 1px solid #fff; 374 400 } 375 401 li.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; 378 406 border-top: 1px #ddd solid; 379 margin: 0 px 0 4px 0;380 padding: 2px 4px 4px 4px;407 margin: 0; 408 padding: 0 2px 0 2px; 381 409 background: url("images/list-bg3.png"); 382 410 } 383 411 li.chartsT { 412 height: 25px !important; 413 margin: 0; 414 padding: 2px 2px 0 2px; 384 415 list-style-type: none; 385 416 color: #2683ae; 386 font-size: 11px;417 /* font-size: 11px; */ 387 418 border-bottom: 2px solid #bfd0dd; 388 margin: 2px 0 0 0; 389 padding: 2px 4px 2px 4px; 419 vertical-align: bottom; 390 420 background: #cee1ef; 391 421 } 422 ul.rownums { background-color: #e6e9ef !important; } 392 423 .sum-rec ul { border-top: 1px solid #999; } 393 424 .detail-data { 394 425 margin: 0 auto !important; 395 426 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; 397 431 color: #445; 398 432 font-size: 11px; … … 402 436 .detail-data ul { 403 437 list-style-type: none; 404 width: 100%;438 /* width: 100%; */ 405 439 margin: 0; 406 440 padding: 3px 0 4px 0; … … 409 443 border-bottom: 1px solid #bbb; 410 444 } 445 .detail-data ul li { height: 25px; line-height: 22px; } 411 446 ul.searcheng { 412 background-color: #abdbff; /* #adf; */447 background-color: #abdbff; 413 448 border-color: #9cd; 414 449 } … … 425 460 } 426 461 ul.useragent { 427 padding: 4px 0 2px0;462 padding: 0; 428 463 background-color: #67a; 429 464 border-bottom: 1px #ccc solid; … … 433 468 color: #f5f5f5; 434 469 width: 100%; 435 padding: 0 6px 0 0; 470 padding: 4px 6px 0 0; 471 line-height: 1.5em !important; 436 472 text-align: center; 437 473 } … … 467 503 border-right: 1px dotted #8e8e8e; 468 504 } 469 ul.agent { border-color: #ddd; } 505 ul.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 } 470 511 li.agent { 471 512 list-style-type: none; … … 495 536 ul.url { 496 537 list-style-type: none; 497 width: 100%;538 /* width: 100%; */ 498 539 margin: 0; 499 540 padding: 0; 500 border: none; 501 border-top: 1px #999 solid; 541 border: 0 none; 502 542 clear: left; 503 543 } 504 li.url {544 li.url, li.urlodd { 505 545 list-style-type: none; 506 546 width: 100%; 507 547 margin: 0; 508 548 padding: 0; 509 line-height: 2em; 549 height: 25px; 550 line-height: 22px; 510 551 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 } 554 ul.url li.url { 555 background-image: url("images/list-bg3.png") !important; 520 556 } 521 557 .url a, .url a:link { border-bottom: 1px solid !important; } … … 553 589 padding: 1px 1px 2px !important; 554 590 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; 559 599 } 560 600 #spyContainer { clear: both; padding: 5px 5px 0 0; } … … 603 643 } 604 644 .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; } 606 647 607 648 /* wassup-option tabs styles */ 608 649 #tabcontainer { 609 list-style:none;610 650 /* width: 97%; */ 611 651 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; 613 656 border: 1px solid #efebef; 614 657 border-radius: 3px; … … 616 659 -moz-border-radius: 3px; 617 660 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); 622 665 } 623 666 #tabcontainer ul.ui-tabs-nav { … … 658 701 border-top-right-radius: 4px; 659 702 } 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 660 713 #wassup_opt_frag-1, #wassup_opt_frag-2, #wassup_opt_frag-3, 661 714 #wassup_opt_frag-4 { … … 697 750 #spy-pause a, #spy-play a { text-decoration: none; border-bottom: 0 none; } 698 751 .wassup-button { 699 - width; 160px;752 width: 155px !important; 700 753 background: url("images/button.png") top center no-repeat; 701 754 border-color: #999 !important; 755 border-radius: 10px !important; 756 -moz-border-radius: 10px; 757 -webkit-border-radius: 10px; 758 -khtml-border-radius: 10px; 702 759 } 703 760 .wassup-hot-button { 704 width ; 160px;761 width: 155px; 705 762 background: url("images/button2.png") top center no-repeat; 706 763 border-color: #777 !important; 764 border-radius: 10px !important; 765 -moz-border-radius: 10px; 766 -webkit-border-radius: 10px; 767 -khtml-border-radius: 10px; 707 768 } 708 769 .wassup-button:hover { 709 770 background-image: url("images/button2.png"); 771 background-color: transparent !important; 772 color: #157 !important; 710 773 } 711 774 .wassup-hot-button:hover { 712 775 background-image: url("images/hot-button.png"); 713 776 } 777 .button-primary { border-color: #157 !important; } -
wassup/trunk/lib/action.php
r318010 r444137 107 107 } 108 108 109 $ debug_mode=false; //debug set below109 $wdebug_mode=false; //debug set below 110 110 //echo "Debug: Starting action.php from directory ".dirname(__FILE__).". ABSPATH=".$wpabspath.".<br />\n"; //debug 111 111 … … 127 127 // ### Begin actions that have output... 128 128 if (!empty($_GET['debug_mode'])) { 129 $ debug_mode=true;129 $wdebug_mode=true; 130 130 $mode_reset=ini_get('display_errors'); 131 131 error_reporting(E_ALL); //debug, E_STRICT=php5 only … … 191 191 } elseif ($_GET['action'] == "piechart") { 192 192 // 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"); ?> 198 198 <div style="text-align: center"><img src="http://chart.apis.google.com/chart?cht=p3&chco=0000ff&chs=600x300&chl=Spam|Search%20Engine|Referrer|Direct&chd=<?php Gchart_data($items_pie, null, null, null, 'pie'); ?>" /></div> 199 199 … … 201 201 // ACTION: LINE CHART - TODO 202 202 //} elseif ($_GET['action'] == "chart") { 203 // $chart = mainItems::theChart($from_date,$to_date,$search);203 // $chart = WassupItems::theChart($from_date,$to_date,$search); 204 204 205 205 // ACTION: DISPLAY RAW RECORDS - no longer used (deprecated) … … 208 208 // ACTION: SHOW TOP TEN 209 209 } elseif ($_GET['action'] == "topten") { 210 $top_limit= 10;211 if ($ debug_mode) {210 $top_limit=0; //use default setting 211 if ($wdebug_mode) { 212 212 $title='WassUp '.__('Top Stats for Period','wassup'); 213 213 $wdformat = get_option("date_format"); … … 225 225 echo '<span style="color:red;">Action.php '.__("ERROR: Missing or unknown parameters","wassup").', action='.attribute_escape($_GET["action"]).'</span>'; 226 226 } 227 if ($ debug_mode) {227 if ($wdebug_mode) { 228 228 if (function_exists('profiler_endSection')) { 229 229 profiler_endSection('(Tot)Action.php'); -
wassup/trunk/lib/compat_functions.php
r315060 r444137 32 32 } 33 33 34 //'microtime_float' replicates microtime(true) from PHP5 35 if (!function_exists('microtime_float')) { 36 function microtime_float() { 37 list($usec, $sec) = explode(" ", microtime()); 38 return ((float)$usec + (float)$sec); 39 } 40 } 41 34 42 if (!function_exists('admin_url')) { 35 43 function admin_url($admin_file="") { -
wassup/trunk/lib/main.php
r318010 r444137 586 586 } //end function 587 587 588 //Output wassup records in Digg spy style...588 //Output wassup records in the old Digg spy style... 589 589 function 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; 591 591 592 592 if (!class_exists('wassupOptions') && file_exists(dirname(__FILE__). '/wassup.class.php')) { … … 807 807 // Geocoding location with Google Maps 808 808 function geocodeWassUp($location, $key) { 809 global $ debug_mode;809 global $wdebug_mode; 810 810 //Three parts to querystring: q= address, output= format, and key 811 811 $address = urlencode($location); … … 813 813 814 814 /* 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); 824 824 */ 825 825 $apidata = wFetchAPIData($api_url); 826 826 $data = explode(',',$apidata); 827 if ($ debug_mode) {827 if ($wdebug_mode) { 828 828 echo "\n<!--geocodeWassup data: "; 829 829 print_r($data); … … 840 840 */ 841 841 function wGeolocateIP($ip) { 842 global $wpdb, $ debug_mode;842 global $wpdb, $wdebug_mode; 843 843 844 844 $wassup_settings=get_option('wassup_settings'); … … 922 922 */ 923 923 function wGetStats($stat_type, $stat_limit=10, $stat_condition="") { 924 global $wpdb, $ debug_mode;924 global $wpdb, $wdebug_mode; 925 925 926 926 $wassup_settings = get_option('wassup_settings'); … … 928 928 $wpurl = get_bloginfo('wpurl'); 929 929 $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"; 932 932 933 933 if (empty($stat_limit) || !(is_numeric($stat_limit))) { … … 950 950 //top search phrases... 951 951 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_countDESC 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"); 953 953 954 954 //top external referrers... 955 955 } elseif ($stat_type == "referrers") { 956 956 //exclude internal referrals 957 $ url = parse_url($blogurl);958 $sitedomain = $ url['host'];957 $wurl = parse_url($blogurl); 958 $sitedomain = $wurl['host']; 959 959 $exclude_list = $sitedomain; 960 960 if ($wpurl != $blogurl) { 961 $ url = parse_url($wpurl);962 $wpdomain = $ url['host'];961 $wurl = parse_url($wpurl); 962 $wpdomain = $wurl['host']; 963 963 $exclude_list .= ",".$wpdomain; 964 964 } … … 980 980 } 981 981 } 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_countDESC 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) { 984 984 echo "\n<pre>exclude_referrers = $exclude_referrers </pre>\n"; 985 985 } … … 987 987 //top url requests... 988 988 } 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_countDESC 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"); 990 990 991 991 //top browser... 992 992 } 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"); 994 994 995 995 //top os... 996 996 } 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"); 998 998 999 999 //top language/locale.. 1000 1000 } 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"); 1002 1002 1003 1003 //top visitors... 1004 1004 } 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 1006 1011 } else { 1007 1012 //TODO: check that wp_wassup.$stat_type column exist and is char 1008 1013 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"); 1010 1015 } 1011 1016 } … … 1024 1029 * @return none 1025 1030 */ 1026 function wassup_top10view ($from_date="",$to_date="",$max_char_len="",$top_limit= 10,$title=false) {1031 function wassup_top10view ($from_date="",$to_date="",$max_char_len="",$top_limit=0,$title=false) { 1027 1032 global $wpdb, $wassup_options; 1028 1033 if (!class_exists('wassupOptions') && file_exists(dirname(__FILE__). '/wassup.class.php')) { … … 1031 1036 $wassup_options = new wassupOptions; 1032 1037 $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"; 1035 1041 1036 1042 $blogurl = get_bloginfo('home'); … … 1053 1059 } 1054 1060 } 1055 //#add an extra width offset when columns count < 51061 //#add an extra width offset when columns count < 6 1056 1062 $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 guess1063 if ($col_count > 0 && $col_count < 6 ) { 1064 $widthoffset = (($max_char_len*(6 - $col_count))/$col_count)*.4; //just a guess 1059 1065 } else { 1060 1066 $widthoffset = 0; … … 1062 1068 //extend page width to make room for more than 5 columns 1063 1069 $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 } 1066 1080 } 1067 1081 1068 1082 //mysql conditional query... 1069 1083 $top_condition = '`timestamp` BETWEEN '.$from_date.' AND '.$to_date; 1084 if (!empty($top_ten['top_nospider'])) { 1085 $top_condition .= " AND spider=''"; 1086 } 1070 1087 echo "\n"; ?> 1071 1088 <div id="toptenchart" style="width:auto;"> 1072 <table width="100%" border="0" style="margin:0; padding:0;">1089 <table width="100%"> 1073 1090 <tr valign="top"><?php 1074 1091 if (!empty($title)) { ?> 1075 1092 <th colspan="<?php echo $col_count; ?>"><span style="centered"><?php echo $title; ?></span></th></tr><tr><?php 1076 1093 } 1094 //show a line# column for long data columns 1095 if ($top_limit > 10) wPrintRowNums($top_limit); 1096 1077 1097 //#output top 10 searches 1078 1098 if ($top_ten['topsearch'] == 1) { … … 1083 1103 <li class="chartsT"><?php echo _e("TOP QUERY", "wassup"); ?></li> <?php 1084 1104 $i=0; 1105 $ndigits=1; 1085 1106 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 1089 1111 $i++; 1090 }1112 } 1091 1113 } 1092 1114 //finish list with empty <li> for style consistency … … 1105 1127 <ul class="charts"> 1106 1128 <li class="chartsT"><?php _e("TOP REFERRER", "wassup"); ?></li><?php 1107 $i=0; 1129 $i=0; 1130 $ndigits=1; 1108 1131 if (count($top_results) >0) { 1132 $ndigits = strlen("{$top_results[0]->top_count}"); 1109 1133 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">'; 1113 1137 //#cut http:// from displayed url and truncate 1114 1138 //# instead of using stringShortener 1115 printsubstr(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); 1116 1140 if (strlen($top10->top_item) > ($char_len + 7)) { 1117 print'...';1118 } 1119 print '</a>'; ?></li><?php1141 echo '...'; 1142 } 1143 echo '</a>'; ?></nobr></li><?php 1120 1144 $i++; 1121 1145 } … … 1136 1160 <li class="chartsT"><?php _e("TOP REQUEST", "wassup"); ?></li><?php 1137 1161 $i=0; 1162 $ndigits=1; 1138 1163 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); 1142 1168 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>'; 1144 1170 } 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><?php1147 $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 } 1149 1175 } 1150 1176 //finish list with empty <li> for styling consistency … … 1163 1189 <li class="chartsT"><?php _e("TOP BROWSER", "wassup") ?></li><?php 1164 1190 $i=0; 1191 $ndigits=1; 1165 1192 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 } 1172 1200 } 1173 1201 //finish list with empty <li> for styling consistency … … 1186 1214 <li class="chartsT"><?php _e("TOP OS", "wassup") ?></li><?php 1187 1215 $i=0; 1216 $ndigits=1; 1188 1217 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 } 1194 1224 } 1195 1225 //finish list with empty <li> for styling consistency … … 1208 1238 <li class="chartsT"><?php _e("TOP LOCALE", "wassup"); ?></li><?php 1209 1239 $i=0; 1240 $ndigits=1; 1210 1241 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 } 1218 1250 } 1219 1251 //finish list with empty <li> for styling consistency … … 1232 1264 <li class="chartsT"><?php _e("TOP VISITOR", "wassup"); ?></li><?php 1233 1265 $i=0; 1266 $ndigits=1; 1234 1267 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 1246 1280 } 1247 1281 //finish list with empty <li> for styling consistency … … 1250 1284 </td> 1251 1285 <?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 } 1252 1315 ?></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> 1257 1327 </div> <?php 1258 1328 } //end wassup_top10view … … 1267 1337 } 1268 1338 } //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 */ 1345 function 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"> </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 */ 1364 function 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 .= ' '; 1370 } 1371 $padhtml = '<span class="fixed">'."$padding{$numstr}</span>"; 1372 return ($padhtml); 1281 1373 } 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 //} 1282 1387 1283 1388 //Round the integer to the next near 10 1284 1389 function roundup($value) { 1285 $dg = digit_count($value); 1390 //$dg = digit_count($value); 1391 $numstr = (int)$value; 1392 $dg = strlen("$numstr"); 1286 1393 if ($dg <= 2) { 1287 1394 $dg = 1; … … 1293 1400 1294 1401 function Gchart_data($Wvisits, $pages=null, $atime=null, $type, $charttype=null, $axes=null, $chart_loc=null) { 1295 global $ debug_mode;1402 global $wdebug_mode; 1296 1403 $chartAPIdata = false; 1297 1404 // Port of JavaScript from http://code.google.com/apis/chart/ … … 1374 1481 1375 1482 // Used to show main visitors details query, to count items and to extract data for main chart 1376 class MainItems {1483 class WassupItems { 1377 1484 // declare variables 1378 1485 var $tableName; … … 1387 1494 1388 1495 /* 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; 1391 1498 if (empty($wassup_options->wassup_table)) { 1392 1499 $wassup_options = new wassupOptions; … … 1421 1528 // Function to show main query and count items 1422 1529 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; 1424 1531 1425 1532 $this->ItemsType = $Type; … … 1444 1551 // - retrieve one row per wassup_id with timestamp = max(timestamp) (ie. latest record) 1445 1552 // "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", 1447 1554 $this->tableName, 1448 1555 $this->from_date, … … 1452 1559 $results = $wpdb->get_results($qry); 1453 1560 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", 1455 1562 $this->tableName, 1456 1563 $this->from_date, … … 1476 1583 case "main-ip": //TODO 1477 1584 // 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", 1479 1586 $this->tableName, 1480 1587 $this->from_date, … … 1506 1613 // $Search = string to add to where clause 1507 1614 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; 1509 1616 1510 1617 $mysqlversion=substr(mysql_get_server_info(),0,3); … … 1529 1636 $chart_url = html_entity_decode($wassup_cache[0]->meta_value); 1530 1637 $cache_id = $wassup_cache[0]->meta_id; 1531 if ($ debug_mode) {1638 if ($wdebug_mode) { 1532 1639 echo "\n<!-- Cached chart found. cache_id=$cache_id -->\n"; 1533 1640 } … … 1705 1812 } 1706 1813 } 1707 if ($ debug_mode) {1814 if ($wdebug_mode) { 1708 1815 echo "\n<!-- \$x-points= ".implode("|",$tlabel)."\n"; 1709 1816 echo " \$tgroup=".implode("|",$tgroup)."-->"; … … 1731 1838 $ss); 1732 1839 } 1733 if ($ debug_mode) {1840 if ($wdebug_mode) { 1734 1841 echo "\n<!-- \$query= $qry-->\n"; 1735 1842 } … … 1770 1877 //if (count($x_label) > 20 && $chart_width < 1000) { 1771 1878 //} 1772 if ($ debug_mode) {1879 if ($wdebug_mode) { 1773 1880 echo "\n<!-- \$x-group= ".implode("|",$x_group); 1774 1881 echo "\n \$x-labels= ".implode("|",$x_label)."-->\n"; … … 1844 1951 } //end function buildSearch 1845 1952 1846 } //end class mainItems1953 } //end class WassupItems 1847 1954 1848 1955 // Class to check if a previous comment with a specific IP was detected as SPAM by Akismet default plugin … … 1946 2053 */ 1947 2054 function wFetchAPIData($api_url) { 1948 global $ debug_mode;2055 global $wdebug_mode; 1949 2056 1950 2057 $wassup_settings=get_option('wassup_settings'); … … 1986 2093 $api_method='file_get_contents'; //debug 1987 2094 } 1988 if ($ debug_mode) {2095 if ($wdebug_mode) { 1989 2096 echo "\n<!-- <br>API Fetch using $api_method data: "; //debug 1990 2097 print_r($apidata); -
wassup/trunk/lib/settings.php
r318010 r444137 9 9 */ 10 10 function 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; 12 12 13 13 $GMapsAPI="http://code.google.com/intl/en/apis/maps"; … … 20 20 $alertstyle = 'color:red; background-color:#ffd;'; 21 21 $wassup_table = (!empty($wassup_options->wassup_table))? $wassup_options->wassup_table: $wpdb->prefix . "wassup"; 22 $wassup_meta_table = $wassup_table . "_meta"; 22 23 $table_engine = ""; 23 24 $table_collation = ""; … … 77 78 <?php $wassup_options->showFormOptions("wassup_screen_res"); ?> 78 79 </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"> 82 84 <?php $wassup_options->showFormOptions("wassup_userlevel"); ?> 83 </select></p> 85 </select> 86 <?php echo "(".__('default Administrator','wassup').")"; ?> 87 </p><br/> 84 88 85 89 <h3><?php _e('Dashboard Settings','wassup'); ?></h3> 86 90 <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" <?php91 </p><br/> 92 93 <h3><?php _e('Spy Visitors Settings','wassup'); ?></h3> 94 <p> <input type="checkbox" name="wassup_geoip_map" value="1" <?php 91 95 //if (!function_exists('curl_init')) { print "DISABLED"; } 92 96 if ($wassup_options->wassup_geoip_map == 1) print "CHECKED"; ?> /> … … 105 109 } 106 110 } ?> 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 /> <?php111 <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 108 112 //no curl - now works without cUrl using 'wp_remote_get' 109 113 //} else { 110 114 //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/> 112 121 113 122 <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>: 115 124 12h <input type="radio" name="wassup_time_format" value="12" <?php if($wassup_options->wassup_time_format == 12) print "CHECKED"; ?> /> 116 125 24h <input type="radio" name="wassup_time_format" value="24" <?php if($wassup_options->wassup_time_format == 24) print "CHECKED"; ?> /> 117 126 </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>: 126 133 <input type="text" name="wassup_refresh" size="2" value="<?php print $wassup_options->wassup_refresh; ?>" /> <?php _e('minutes (default 3)','wassup'); ?> 127 134 </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>: 141 146 <select name='wassup_default_limit'> 142 147 <?php $wassup_options->showFormOptions("wassup_default_limit"); ?> 143 148 </select> 144 149 </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 147 157 $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 /> 151 167 <div style="padding-left:25px;padding-top:0;margin-top:0;display:block;clear:left;"> 152 168 <div style="display:block; vertical-align:top; float:left; width:225px;"> 153 169 <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 /> 155 171 <input type="checkbox" name="toprequest" value="1" <?php if($top_ten['toprequest'] == 1) print "CHECKED"; ?> /><?php _e("Top Requests", "wassup"); ?><br /> 156 172 </div> … … 161 177 </div> 162 178 <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 /><!-- 164 181 //TODO 165 182 <input type="checkbox" name="topfeed" value="1" DISABLED /><?php _e("Top Feeds", "wassup"); ?><br /> … … 167 184 </div> 168 185 </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 /> 171 188 <span style="padding-left:10px;display:block;clear:left;"> 172 189 <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"). " "; 174 191 _e("Don't list your website domain defined in WordPress","wassup"); ?>.</span> 175 192 </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> 176 196 <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'); ?>" /> <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'); ?>" /> <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 /> 178 198 </div> 179 199 … … 206 226 <br /><span style="padding-left:10px;display:block;clear:left;"> 207 227 <textarea name="wassup_exclude_user" rows="2" style="width:60%;"><?php print $wassup_options->wassup_exclude_user; ?></textarea></span> <?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 /> ".__(' enter requested URLs to exclude from recording','wassup'); ?></strong>:228 <br /><p><strong><?php echo __("Posts/pages","wassup")."\n<br /> ".__('Enter requested URLs to exclude from recording','wassup'); ?></strong>: 209 229 <br /><span style="padding-left:10px;display:block;clear:left;"> 210 230 <textarea name="wassup_exclude_url" rows="2" style="width:60%;"><?php print $wassup_options->wassup_exclude_url; ?></textarea></span> <?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'); ?>" /> <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'); ?>" /> <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 /> 212 232 </div> 213 233 214 234 <div id="wassup_opt_frag-3" class="optionstab<?php if ($tab == "3") echo ' tabselected'; ?>"> 215 <?php /* 216 // <h3><?php _e('Temporary files location folder','wassup'); ?&rt;</h3> 217 // <p><?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;<?php echo $sessionstyle; ?&rt;"><?php echo $sessionpath; ?&rt;</textarea> 232 // <br /> <?php echo __('Use absolute directory paths only. This value is usually','wassup').' "/tmp".'."\n"; ?&rt; 233 // <br /> <span style="font-size:95%; color:#555;">System default for session.save_path="<?php echo session_save_path(); //debug ?&rt;" from <i>php.ini</i> or from web server configuration.</span> 234 // <br /> <?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'); ?>" /> 235 241 // </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 */ ?> 244 244 <h3><?php _e('Select actions for table growth','wassup'); ?></h3> 245 245 <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> 247 248 <p><?php _e('Current WassUp table usage is','wassup'); ?>: 248 249 <strong><?php … … 279 280 </p><br/> 280 281 <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> 282 288 <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/> 283 289 … … 485 491 } 486 492 } 487 if ($ debug_mode) {493 if ($wdebug_mode) { 488 494 print_r($sql_vars); //debug 489 495 } … … 579 585 </ul></p> 580 586 <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'); ?>" /> <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'); ?>" /> <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 /> 582 588 </div> 583 589 … … 596 602 <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> 597 603 <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'); ?>" /> <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'); ?>" /> <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 /> 599 605 </div> 600 606 </form> -
wassup/trunk/lib/uadetector.class.php
r315060 r444137 2 2 /** 3 3 * UADetector.class.php 4 * Description: a PHP class for browser and spider identification5 * Updated: 201 0-09-026 * @version 0.9a 37 * @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/ 9 9 * 10 * @copyright Copyright (c) 2009 ,2010Helene Duncker10 * @copyright Copyright (c) 2009-2011 Helene Duncker 11 11 * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License 12 12 */ … … 16 16 * 17 17 * 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. 22 23 * 23 24 * Disclaimer: Use at your own risk. No warranty expressed or implied is provided. 24 25 */ 25 26 class UADetector { 26 var $name = ''; // name of browser or spider, not null27 var $version = ''; // version of browser|spider, if available27 var $name = ''; //browser or spider name, not null 28 var $version = ''; //browser or spider version, if available 28 29 var $os = ''; //operating system+version, if available 29 var $platform = ''; //operating system |device platform30 var $platform = ''; //operating system or device platform 30 31 var $emulation = ''; //emulated browser plus major version# 31 var $language = ''; //language code , if available32 var $device = ''; //PC, PDA, Phone, TV, if known33 var $model = ''; // Manufacturer model, if known32 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 34 35 var $resolution = ''; //screen size (MMMxNNN), if in user-agent 35 var $subscribers = ''; //feed subscriber s, if in user-agent36 var $subscribers = ''; //feed subscriber count, if in user-agent 36 37 var $is_mobile = false; 37 38 var $is_browser = false; … … 64 65 * @access public 65 66 * @param string $ua (optional) 66 * @return object(1 2)67 * @return object(16) 67 68 */ 68 69 function __construct($ua="") { 69 global $ debug_mode, $do_profile;70 global $wdebug_mode, $do_profile; 70 71 $do_profile= false; 71 if ($ debug_mode && function_exists('profiler_beginSection')) {72 if ($wdebug_mode && function_exists('profiler_beginSection')) { 72 73 $do_profile = true; 73 74 profiler_beginSection('(Subtot)uaDetector'); … … 139 140 // "WassUp", a web statistics plugin for WordPress 2.2+ 140 141 // available at http://www.wpwp.org 141 global $ debug_mode, $do_profile;142 global $wdebug_mode, $do_profile; 142 143 143 144 // User agent parameter or class variable is required. … … 174 175 $top_ua['device'] = $match[3]; 175 176 } 176 // #3 Firefox orother Mozilla browsers on Windows177 // #3 Firefox and other Mozilla browsers on Windows 177 178 } 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) { 178 179 $top_ua['name'] = $match[3]; … … 193 194 } 194 195 $top_ua['agenttype']= 'R'; 195 // #5 MSNBot, MSNbot-media196 } 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'; 198 199 if (!empty($match[1])) { 199 200 $top_ua['name'].=$match[1]; … … 203 204 } 204 205 $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 211 207 } elseif (preg_match('#^FeedBurner/(\d\.\d)\s\(http\://www\.FeedBurner\.com\)$#',$ua,$match)>0) { 212 208 $top_ua['name'] = 'FeedBurner'; 213 209 $top_ua['version']=$match[1]; 214 210 $top_ua['agenttype']= 'F'; 215 // # 8Wordpress211 // #7 Wordpress 216 212 } elseif (preg_match('#^WordPress/(?:wordpress(\-mu)\-)?(\d\.\d+)(?:\.\d+)*(?:\-[a-z]+)?(?:\;\shttp\://[a-z0-9_\.\:\/]+)?$#',$ua,$match)>0) { 217 213 $top_ua['name'] = 'Wordpress'; … … 221 217 $top_ua['version']=$match[2]; 222 218 $top_ua['agenttype']= 'U'; 223 // # 9Firefox and Gecko browsers on Mac|*nix|OS/2 etc...219 // #8 Firefox and Gecko browsers on Mac|*nix|OS/2 etc... 224 220 } 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) { 225 221 $top_ua['name'] = $match[4]; … … 237 233 list($top_ua['os']) = $this->OSversion($os,$top_ua['platform'],$ua); 238 234 $top_ua['agenttype']= 'B'; 239 // # 10Safari and Webkit-based browsers on all platforms235 // #9 Safari and Webkit-based browsers on all platforms 240 236 } 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) { 241 237 $top_ua['name'] = 'Safari'; … … 260 256 $top_ua['language']=$match[3]; 261 257 $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'; 262 278 } 263 279 //check http header for user agent spoofing and for os and screen resolution … … 280 296 $top_ua=false; 281 297 } 282 if ($ debug_mode) {298 if ($wdebug_mode) { 283 299 echo "\n".'<br />uadetector: top_ua->name='.$top_ua['name']." ".'top_ua->os='.$top_ua['os']; //debug 284 300 if ($do_profile) { … … 296 312 */ 297 313 function isBrowserAgent($agent="") { 298 global $ debug_mode, $do_profile;314 global $wdebug_mode, $do_profile; 299 315 $ua=""; 300 316 $is_current_ua = false; … … 311 327 312 328 //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) { 314 330 //not spider if embedded browser or is a browser add-on such as spyware or translator 315 331 if (preg_match('#(embedded\s?(WB|Web\sbrowser)|dynaweb|bsalsa\.com|muuk\.co|translat[eo]r?)#i',$ua)==0) { … … 320 336 profiler_beginSection('_____ua::isBrowser'); 321 337 } 322 // Separate check for mobile browsers beforehand338 //### Step 1: check for mobile or embedded browsers 323 339 $ismobile = false; 324 //check for mobile or embedded browser325 340 $wap = $this->isMobileAgent($ua); 326 341 if (!empty($wap) && is_array($wap)) { 327 342 $ismobile = true; 343 $browser['name'] = $wap['name']; 344 $browser['version'] = $wap['version']; 328 345 $browser['device'] = $wap['device']; 329 346 $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"; 336 349 if (!empty($wap['language'])) $browser['language'] = $wap['language']; 337 350 } 351 //### Step 2: Check for MSIE-based browsers 338 352 if (!$ismobile || empty($browser['name'])) { 339 //MSIE browsers340 353 if (preg_match('/compatible(?:\;|\,|\s)+MSIE\s(\d+)(\.\d+)+(.*)/',$ua,$pcs)>0) { 341 if ($ debug_mode) {354 if ($wdebug_mode) { 342 355 echo "\nMatch for MSIE-based browser<br/>"; 343 356 } … … 375 388 } 376 389 390 //### Step 3: Check for All Other browsers 377 391 //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];381 392 } elseif (preg_match('#Opera[/ ]([0-9\.]+)#',$ua,$pcs)>0) { 382 393 $browser['name'] = 'Opera'; … … 385 396 //Firefox-based browsers (Camino, Flock) (find before FF) 386 397 } elseif (preg_match('#[^a-z](Camino|Flock|Galeon|Orca)/(\d+[\.0-9a-z]*)#',$ua,$pcs)>0) { 387 if ($ debug_mode) {398 if ($wdebug_mode) { 388 399 echo "\nMatch for Firefox-based browser<br/>"; 389 400 } … … 393 404 //other Gecko-type browsers (incl. Firefox) 394 405 } 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) { 396 407 echo "\nMatch for Gecko-type browser<br/>"; 397 408 } … … 404 415 //Firefox browser 405 416 } elseif (preg_match('#[^a-z](Fire(?:fox|bird))/?(\d+[\.0-9a-z]*)?#',$ua,$pcs)>0) { 406 if ($ debug_mode) {417 if ($wdebug_mode) { 407 418 echo "\nMatch for Firefox browser<br/>"; 408 419 } … … 413 424 //Mozilla browser (like FF, but nothing after "rv:" or "Gecko") 414 425 } 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) { 416 427 echo "\nMatch for Mozilla browser<br/>"; 417 428 } … … 423 434 //WebKit-based browsers 424 435 } 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) { 426 437 echo "\nMatch for WebKit-based browser<br/>"; 427 438 } … … 439 450 //Text-only browsers Lynx, ELinks...(yep, they still exist) 440 451 } elseif (preg_match("#^(E?Links|Lynx|(?:Emacs\-)?w3m)[^a-z0-9]+([0-9\.]+)?#i",$ua,$pcs)) { 441 if ($ debug_mode) {452 if ($wdebug_mode) { 442 453 echo "\nMatch for text browser<br/>"; 443 454 } … … 479 490 } 480 491 } 481 } //end if ( $ismobile)492 } //end if (!$ismobile) 482 493 483 494 //get operating system … … 522 533 $browser['agenttype']= "S"; 523 534 } 524 if ($ debug_mode) {535 if ($wdebug_mode) { 525 536 echo "\n".'<br />uadetector: browser->name='.$browser['name']." ".'browser->os='.$browser['os']; //debug 526 537 } … … 550 561 */ 551 562 function isMobileAgent($agent="") { 552 global $ debug_mode, $do_profile;563 global $wdebug_mode, $do_profile; 553 564 $ua=""; 554 565 $is_current_ua = false; … … 565 576 } 566 577 $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"); 573 582 //detect known mobile browsers 574 583 575 584 //Android-based devices 576 585 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;578 586 if (!empty($pcs[4])) { $vers = $pcs[4]; } 579 587 else { $vers = $pcs[6]; } … … 586 594 if (!empty($pcs[2])) $wap['os'] .= " ".$this->majorVersion($pcs[2]); 587 595 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]; 589 607 590 608 //NetFront and other mobile/embedded browsers 591 609 } elseif (preg_match("#(NetFront|NF\-Browser)/([0-9\.]+)#i",$ua,$pcs)) { 592 $ismobile = true;593 610 $wap['name'] = "NetFront"; 594 611 $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)) { 597 613 $wap['name'] = $pcs[1]; 598 614 $wap['version'] = $pcs[2]; 599 615 } elseif (preg_match("#(UP\.browser|SMIT\-Browser)/([0-9\.]+)#i",$ua,$pcs)) { 600 $ismobile = true;601 616 $wap['name'] = $pcs[1]; 602 617 $wap['version'] = $pcs[2]; 603 618 } elseif (preg_match("#\((jig\sbrowser).*\s([0-9\.]+)[^a-z0-9]#i",$ua,$pcs)) { 604 $ismobile = true;605 619 $wap['name'] = $pcs[1]; 606 620 $wap['version'] = $pcs[2]; 607 621 } elseif (preg_match("#[^a-z]Obigo#i",$ua,$pcs)) { 608 $ismobile = true;609 622 $wap['name'] = 'Obigo'; 610 623 } elseif (preg_match("#openwave(\suntrusted)?/([0-9\.]+)#i",$ua,$pcs)) { 611 $ismobile = true;612 624 $wap['name'] = 'OpenWave'; 613 625 $wap['version'] = $pcs[2]; 626 } 627 if (!empty($wap['name'])) { 628 $ismobile = true; 614 629 } 615 630 … … 649 664 } 650 665 } 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) { 657 682 echo "\n".'<br />uadetector: wap->name='.$wap['name']." ".'wap->device='.$wap['device']; //debug 658 683 } … … 661 686 } 662 687 if ($ismobile) { 688 if (empty($wap['os'])) $wap['os'] = "WAP"; 663 689 return $wap; 664 690 } else { … … 674 700 */ 675 701 function isSpiderAgent($agent="") { 676 global $ debug_mode, $do_profile;702 global $wdebug_mode, $do_profile; 677 703 $ua=""; 678 704 $is_current_ua = false; … … 692 718 $spider['agenttype']= 'F'; 693 719 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 695 727 } elseif (preg_match('#^Feedfetcher\-Google[;\s\(\+]+http\://www\.google\.com/feedfetcher\.html[;\)\s]+(?:(\d)\ssubscriber)?#',$ua,$match)>0) { 696 728 $spider['name'] = 'FeedFetcher-Google'; … … 753 785 $spider['version']=$match[2]; 754 786 } 787 if (strlen($match[1]) < 5) { 788 $spider['name'] = $match[1]. " Spider"; 789 } 755 790 756 791 //TODO: Libwww spiders … … 763 798 $spider['version'] = $match[3]; 764 799 } 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 765 806 // #Assume bot if user-agent 1st word and a contact domain are the same name, ex: Feedburner-feedburner.com, CazoodleBot, 766 807 } elseif (preg_match('/([a-z\_\s\.]+)[\s\/\-_]?(v?[0-9\.]+)?.*(?:http\:\/\/|www\.)(\1)\.[a-z0-9_\-]+/i',$ua,$match)>0) { … … 790 831 791 832 // #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 } 792 838 } 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) { 793 839 $spider['name'] = $match[1]; … … 888 934 $spider['agenttype']= "S"; 889 935 } 890 if ($ debug_mode) {936 if ($wdebug_mode) { 891 937 echo "\n".'<br />uadetector: spider->name='.$spider['name']." "; //debug 892 938 } … … 916 962 } 917 963 } 918 // distinguish feed readers from otherspiders964 //separate feed readers from spiders 919 965 if (preg_match("/([0-9]+)\s?subscriber/i",$ua,$subscriber) >0) { 920 966 // It's a feedreader with some subscribers … … 968 1014 */ 969 1015 function isWTF($ua="") { 970 global $ debug_mode, $do_profile;1016 global $wdebug_mode, $do_profile; 971 1017 //recheck browsers or check PHP's browser capabilities file 972 1018 if (isset($this->done_browsers) && !$this->done_browsers) { … … 981 1027 $this->setClassVars($unknown_agent); 982 1028 } 983 if ($ debug_mode) {1029 if ($wdebug_mode) { 984 1030 echo "\n".'<br />uadetector: unknown_agent->name='.$unknown_agent['name']." "; //debug 985 1031 } … … 996 1042 */ 997 1043 function OSversion($os="",$platform="",$ua="") { 998 global $ debug_mode, $do_profile;1044 global $wdebug_mode, $do_profile; 999 1045 if ($do_profile) { 1000 1046 profiler_beginSection('_____ua::OSversion'); … … 1227 1273 */ 1228 1274 function linuxOSversion($os="") { 1229 global $ debug_mode, $do_profile;1275 global $wdebug_mode, $do_profile; 1230 1276 if (empty($os)) { $os = $this->agent; } 1231 1277 if (empty($os)) { return false; } … … 1293 1339 */ 1294 1340 function webkitVersion($webkit="",$ua="") { 1295 global $ debug_mode;1341 global $wdebug_mode; 1296 1342 $browser = "Safari"; 1297 1343 $vers = ""; 1298 if ($ debug_mode) {1344 if ($wdebug_mode) { 1299 1345 echo "<br />webkit=".$webkit."\n"; //debug 1300 1346 } 1301 1347 if (empty($webkit)) { 1302 1348 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) { 1304 1350 if ($match[1] != "Version") { //Chrome,Iron,Shiira 1305 1351 $browser = $match[1]; … … 1396 1442 */ 1397 1443 function getBrowscap($ua="") { 1398 global $ debug_mode;1444 global $wdebug_mode; 1399 1445 if (empty($ua)) $ua = $this->agent; 1400 1446 $browsercap = false; … … 1407 1453 if (ini_get("browscap")!="") { 1408 1454 $browsercap = get_browser($ua,true); 1409 if ($ debug_mode) {1455 if ($wdebug_mode) { 1410 1456 echo "\n<br/>Browsercap="; 1411 1457 print_r($browsercap); -
wassup/trunk/lib/upgrade.php
r315060 r444137 7 7 * Contains functions to create and update the tables required for WassUp 8 8 * install and upgrade. These functions are loaded only when plugin is 9 * activated viathe 'wassup_install' hook function.9 * activated through the 'wassup_install' hook function. 10 10 * @since version 1.8 11 11 * @author Helene D. … … 14 14 /** 15 15 * 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. 17 17 * @param none 18 18 * @return boolean … … 25 25 $wassup_tmp_table = $wassup_table."_tmp"; 26 26 $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 { 32 36 if (wCreateTable()) { //1st attempt 33 $ charset=true;37 $wcharset=true; 34 38 } 35 39 //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 45 45 } 46 46 47 47 //check that install was successful, issue warnings, start tracker 48 if ($w pdb->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; 50 50 //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); 59 60 } //#end function wassup_tableInstaller 60 61 … … 65 66 * @return boolean 66 67 */ 67 function wCreateTable($ table="",$withcharset=true) {68 global $wpdb, $current_user, $w assupversion, $wassup_options;68 function wCreateTable($wtable="",$withcharset=true) { 69 global $wpdb, $current_user, $wp_version, $wassupversion, $wassup_options; 69 70 70 71 $wassup_table = (!empty($wassup_options->wassup_table))? $wassup_options->wassup_table: $wpdb->prefix . "wassup"; 71 72 $wassup_tmp_table = $wassup_table."_tmp"; 72 73 $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; 75 76 $is_new_table = false; 76 77 … … 89 90 $charset_collate = ''; 90 91 //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) { 92 93 $withcharset = false; 93 94 } else { … … 106 107 107 108 //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, 111 112 `wassup_id` varchar(60) NOT NULL, 112 113 `timestamp` varchar(20) NOT NULL, 113 ipvarchar(50) default NULL,114 `ip` varchar(50) default NULL, 114 115 `hostname` varchar(150) default NULL, 115 116 `urlrequested` text, 116 117 `agent` varchar(255) default NULL, 117 `referrer` text default NULL,118 `referrer` text, 118 119 `search` varchar(255) default NULL, 119 `searchpage` int(11) default 0,120 `searchpage` int(11) unsigned default '0', 120 121 `os` varchar(15) default NULL, 121 122 `browser` varchar(50) default NULL, … … 125 126 `spider` varchar(50) default NULL, 126 127 `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', 130 131 `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};"; 136 137 //Note: index (username,ip) was removed because of problems with 137 138 // non-romanic language display 138 // New in v.1.8: increased ip width to 50 for ipv6 support139 //Since v1.8: increased ip width to 50 for ipv6 support 139 140 140 141 //...Include a first record if new table (not temp table) 141 142 $sql_firstrecord = ''; 142 if ($ table_name == $wassup_table && $is_new_table) {143 if ($wtable_name == $wassup_table && $is_new_table) { 143 144 if (!class_exists('UADetector')) 144 145 include_once (dirname(__FILE__) . '/lib/uadetector.class.php'); … … 160 161 trim($ua->name.' '.$ua->majorVersion($ua->version)), 161 162 $locale, $screen_res, $logged_user); 162 } 163 } // end if wassup && is_new_table 163 164 164 165 //...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)) { 166 174 $result = dbDelta(array($sql_createtable,$sql_firstrecord)); 167 } else {168 $result = dbDelta($sql_createtable);169 175 } 176 //$wpdb->print_error(); //debug 170 177 171 178 //...return 'true' if table created successfully, false otherwise 172 179 $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) { 174 181 175 182 $retvalue=false; 176 183 } 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','>')) { 178 185 //'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 180 188 } 181 189 } 182 190 } //end if wassup_table 183 191 184 // New inv1.8: "meta" table to extend wassup. Used as a temporary192 //Since v1.8: "meta" table to extend wassup. Used as a temporary 185 193 // 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) { 188 196 189 197 // Wassup Meta Table Structure: … … 197 205 // `meta_expire` is a timestamp that is an expiration date in unix 198 206 // timestamp format...for temporary/cache-only records. 199 $sql_create table_meta = "CREATE TABLE `$wassup_meta_table` (207 $sql_create_meta = "CREATE TABLE `$wassup_meta_table` ( 200 208 `meta_id` integer(15) unsigned auto_increment, 201 209 `wassup_key` varchar(150) NOT NULL, … … 203 211 `meta_value` longtext, 204 212 `meta_expire` integer(10) unsigned default '0', 205 UNIQUE KEY (`meta_id`),213 UNIQUE KEY meta_id (`meta_id`), 206 214 INDEX (`wassup_key`), 207 INDEX (`meta_key`)) {$charset_collate}; ";215 INDEX (`meta_key`)) {$charset_collate}; "; 208 216 209 217 //create/upgrade wassup table 210 $result = dbDelta($sql_createtable_meta); 218 $result = dbDelta($sql_create_meta); 219 //$wpdb->print_error(); //debug 211 220 212 221 //...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) { 214 223 $retvalue=false; 215 224 } 216 225 } //end if wassup_meta_table 217 226 218 return $retvalue;227 return($retvalue); 219 228 //#TODO: 220 229 // 1. create stored procedure that selects records by timestamp … … 238 247 $wassup_tmp_table = $wassup_table."_tmp"; 239 248 $wassup_meta_table = $wassup_table."_meta"; 249 $wsuccess=true; 240 250 241 251 //queue table content upgrades … … 251 261 $wpdb->query("SET wait_timeout = 180"); 252 262 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"]; 273 286 } 274 $prev_key = $ row["Key_name"];287 $prev_key = $wrow["Key_name"]; 275 288 } //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); 282 297 } 283 298 284 299 //NOTE: All column updates replaced by single call to 'wcreateTable' function which uses 'dbDelta' to update table structure 285 300 286 // ## For all upgrades287 // # 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 work290 $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 key299 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 while306 } //end if row_count307 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 //} 312 327 // drop wp_wassup_tmp table... 313 328 //$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}`"); 315 330 316 331 //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) { 321 390 wCreateTable($wassup_tmp_table,false); 322 391 } 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) { 324 393 wCreateTable($wassup_meta_table,false); 325 394 } 326 395 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); 334 407 } //end function wUpdateTable 335 408 … … 351 424 if (file_exists($footer_file)) { 352 425 $footer = file_get_contents($footer_file); 353 //Note: Commented out 'wp_footer()' calls will match as true in test below...should be skipped426 //Note: if 'wp_footer()' is commented-out in template code, it will still match as true in test below 354 427 if (stristr($footer,'wp_footer(')!==false || stristr($footer,'wp_footer (')!==false) $result=true; 355 428 else $result=false; -
wassup/trunk/lib/wassup.class.php
r315060 r444137 11 11 * settings in Wordpress' wp_options table and to output those 12 12 * 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 14 14 */ 15 15 class wassupOptions { … … 22 22 var $wassup_default_spy_type = ""; 23 23 var $wassup_default_limit = "10"; 24 var $wassup_top10 ; //array containg top tenpreferences24 var $wassup_top10 ; //array containg top stats preferences 25 25 var $wassup_dashboard_chart; 26 26 var $wassup_geoip_map; 27 27 var $wassup_googlemaps_key; 28 var $wassup_spy_speed = "5000"; //New in 1.8.3 28 29 var $wassup_time_format; 29 var $wassup_time_period; //new in 1.8 - for visitor details default date/timerange30 var $wassup_time_period; //since 1.8 - visitor details default range 30 31 31 32 /* recording settings */ … … 46 47 47 48 /* table/file management settings */ 48 //var $wassup_savepath; //deprecated49 //var $wassup_savepath; //deprecated 49 50 var $delete_auto; 50 var $delete_filter; // new in 1.8 for deletingselect records51 var $delete_filter; //since 1.8 - auto delete select records 51 52 var $wassup_remind_mb; 52 53 var $wassup_remind_flag; … … 56 57 var $wassup_table; //since 1.7.2 - WassUp table name 57 58 var $wassup_dbengine; //since 1.7.2 - MySQL table engine type 58 var $wassup_cache; // new in 1.8 for usingwassup_meta table as cache59 var $wassup_cache; //since 1.8 - use wassup_meta table as cache 59 60 60 61 /* chart display settings */ … … 78 79 79 80 /* temporary action settings */ 80 var $wassup_alert_message; // usedto display alerts81 var $wassup_alert_message; //to display alerts 81 82 var $wmark; 82 83 var $wip; … … 102 103 * @return array 103 104 */ 104 function defaultSettings( ) {105 function defaultSettings($dsetting="") { 105 106 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 106 118 $defaults = array( 107 119 'wassup_active' =>"1", … … 133 145 'wassup_geoip_map' =>"0", 134 146 'wassup_googlemaps_key' =>"", 147 'wassup_spy_speed' =>"5000", 135 148 'wassup_time_format' =>"24", 136 149 'wassup_time_period' =>"1", … … 151 164 'wassup_uninstall' =>"0", 152 165 '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 164 177 'whash' =>$this->get_wp_hash(), 165 178 'wassup_version'=>"", … … 178 191 $defaults['wassup_table']= $this->wassup_table; 179 192 } 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 }; 181 205 } //end defaultSettings 182 206 -
wassup/trunk/readme.txt
r433606 r444137 5 5 Requires at least: 2.2 6 6 Tested up to: 3.2.1 7 Stable tag: 1.8. 27 Stable tag: 1.8.3 8 8 9 9 Analyze your visitors traffic with real-time statistics, a lot of chronological information, charts, a sidebar widget. … … 73 73 74 74 = 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.75 Enable 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. 76 76 77 77 = My Wordpress theme is not widget ready. Is it possible to add WassUp Widget to my site? = … … 79 79 80 80 = 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.81 Add 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. 82 82 83 83 = 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. 84 Disable 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? = 87 Change 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. 85 88 86 89 = Can Wassup record visits on a web site that is not Wordpress? = … … 93 96 [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. 94 97 95 = Why does WassUp stats s how 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? = 96 99 "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. 97 100 98 101 = 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".102 To 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". 100 103 101 104 Visit [http://www.wpwp.org](http://trac.wpwp.org/wiki/Documentation) for more FAQs. … … 142 145 == Changelog == 143 146 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 144 164 = 1.8.2 = 145 165 = 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. 155 172 * miscellaneous minor code and style changes. 156 173 … … 158 175 = Urgent bugfix and code improvement upgrade = 159 176 * fixed bug that caused `set_time_limit` and other warning errors to display to visitors. 160 * improvedupgrade instructions in `readme.txt`.177 * new upgrade instructions in `readme.txt`. 161 178 * miscellaneous minor code changes. 162 179 … … 189 206 == Upgrade Notice == 190 207 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. 193 210 194 211 == Infos == … … 196 213 You 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/) 197 214 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 215 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://techfromhel.webege.com/) for her help to improve WassUp! 216 -
wassup/trunk/wassup.php
r433606 r444137 4 4 Plugin URI: http://www.wpwp.org 5 5 Description: 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. 26 Version: 1.8.3 7 7 Author: Michele Marcucci, Helene Duncker 8 8 Author URI: http://www.michelem.org/ 9 9 Disclaimer: Use at your own risk. No warranty expressed or implied is provided. 10 10 11 Copyright (c) 2007-201 0Michele Marcucci11 Copyright (c) 2007-2011 Michele Marcucci 12 12 Released under the GNU General Public License (GPL) 13 13 http://www.gnu.org/licenses/gpl.txt … … 24 24 //wassup globals & constants 25 25 global $wp_version, $current_user, $user_level, $wassup_options; 26 $wassupversion="1.8. 2";26 $wassupversion="1.8.3"; 27 27 $wassup_cookie_value=""; 28 $ debug_mode=false; //turn on debugging (global)...Use cautiously! Will display errors from all plugins, not just WassUp28 $wdebug_mode=false; //turn on debugging (global)...Use cautiously! Will display errors from all plugins, not just WassUp 29 29 define('WASSUPDIR', dirname(__FILE__)); //new constant in v1.8 30 30 define('WASSUPFOLDER', plugin_basename(dirname(__FILE__))); … … 67 67 $wassup_options = new wassupOptions; //#settings initialized here 68 68 $wassup_table = (!empty($wassup_options->wassup_table))? $wassup_options->wassup_table : $wpdb->prefix . "wassup"; 69 $wassup_meta_table = $wassup_table . "_meta"; 69 70 70 71 //# wassup should not be active during install … … 108 109 } else { 109 110 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(); 113 114 //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) { 116 121 //Reset 'dbengine' MySQL setting with each upgrade...because host server settings can change 117 122 if (!empty($wassup_options->wassup_version)) { //upgrade only … … 119 124 } 120 125 //turn off wassup_cache if meta table does not exist 121 $wassup_meta_table = $wassup_table . "_meta";122 126 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) { 124 128 $wassup_options->wassup_cache = 0; 125 129 } … … 128 132 //show warning when 'WP_CACHE' constant is set 129 133 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 thatplugin 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>'; 131 135 } 132 136 //TODO: Show warning when 'wp_footer()' does not exist in active theme template (non-cache setups only) … … 135 139 $wassup_options->wassup_version = $wassupversion; 136 140 137 if (empty($wassup_options->wassup_alert_message)) {138 $wassup_options->wassup_alert_message = "Wassup $wassupversion: ".__("database created/upgraded successfully","wassup"); //debug139 }140 141 $wassup_options->wassup_active = 1; //start recording 141 142 $wassup_options->saveSettings(); … … 147 148 deactivate_plugins(__FILE__); 148 149 } 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 meta table: $wassup_meta_table"; 150 151 exit(1); //exit with error 151 152 } … … 195 196 /** 196 197 * Output javascript in page head for wassup tracking 197 * @param string (optional);198 * @param none 198 199 * @return none; 199 200 */ 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 bloat205 //print '<meta name="wassup-version" content="'.$wassupversion.'" />'."\n";206 //add screen resolution javascript to blog header207 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 sometimes213 $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 }201 function 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 } 219 220 //Get visitor's screen resolution using javascript and a cookie. 220 221 // - Added here so javascript code is placed in document <head> … … 223 224 <script type="text/javascript"> 224 225 //<![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'])) { ?> 227 229 function writeCookie(name,value,hours) { 228 230 var the_cookie = name+"="+escape(value)+"; expires="; … … 256 258 ?> 257 259 //]]> 258 </script> 259 <?php 260 } // end if wassup_active == "1"260 </script><?php 261 echo "\n"; 262 //} // end if wassup_active == "1" 261 263 } //end function wassup_head 262 264 … … 269 271 270 272 //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('\\','\','"','%22','"','"',''','\'','`','`'),'',$_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('\\','\','"','%22','"','"',''','\'','`','`'),'',$request_uri))>0) { 273 277 header("HTTP/1.1 403 Forbidden"); 274 278 wp_die('Illegal request - Permission Denied!'); … … 291 295 } 292 296 // 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'); 294 298 } 295 299 if ($_GET['page'] == "wassup-spia") { … … 298 302 } elseif($_GET['page'] == "wassup-options") { 299 303 //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'); 301 305 //} else { 302 306 // wp_enqueue_script('ui.core', array('jquery')); … … 331 335 //Add the wassup stylesheet and other javascripts... 332 336 function add_wassup_css() { 333 global $wassup_options, $ debug_mode;337 global $wassup_options, $wdebug_mode; 334 338 335 339 $plugin_page = $_GET['page']; … … 344 348 //preassign "GET" parameters for "action.php" in "action_param" 345 349 $action_param='&whash='.$wassup_options->whash; 346 if ($ debug_mode) {350 if ($wdebug_mode) { 347 351 $action_param .= '&debug_mode=true'; 348 352 } … … 367 371 <script type='text/javascript'> 368 372 //<![CDATA[ 369 // var selftimerID = 0;373 // var selftimerID = 0; 370 374 function selfRefresh(){ 371 375 location.href='?<?php print $_SERVER['QUERY_STRING']; ?>'; 372 376 } 373 // selftimerID = setTimeout('selfRefresh()', <?php print ($wassup_options->wassup_refresh * 60000)+2000; ?>);377 // selftimerID = setTimeout('selfRefresh()', <?php print ($wassup_options->wassup_refresh * 60000)+2000; ?>); 374 378 //]]> 375 </script> 376 <?php //New in1.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) 377 381 $wrefresh = 0; 378 382 if (!is_numeric($wassup_options->wassup_refresh) || $wassup_options->wassup_refresh < 0 || $wassup_options->wassup_refresh > 180) { … … 451 455 //show larger icons on mouse-over 452 456 $("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'; ?>"); 454 458 }).mouseout(function() { 455 $(this).attr("src","<?php echo WASSUPURL.'/img/ cross.png'; ?>");459 $(this).attr("src","<?php echo WASSUPURL.'/img/b_delete.png'; ?>"); 456 460 }); 457 461 $("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'; ?>"); 459 463 }).mouseout(function() { 460 $(this).attr("src","<?php echo WASSUPURL.'/img/ database_table.png'; ?>");464 $(this).attr("src","<?php echo WASSUPURL.'/img/b_select.png'; ?>"); 461 465 }); 462 466 … … 473 477 $("div#delID" + id).fadeOut("slow"); 474 478 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>"); 476 480 }, 477 481 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>"); 479 483 } 480 484 }); … … 486 490 echo "\n"; ?> 487 491 $("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'); ?>"); 489 493 },function() { 490 494 $("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'); ?>"); 492 496 return false; <?php 493 497 } else { 494 498 echo "\n"; ?> 495 499 $("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'); ?>"); 497 501 },function() { 498 502 $("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'); ?>"); 500 504 return false; <?php 501 505 } 502 506 echo "\n"; ?> 503 507 }); 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 */ 513 513 $("a.toggle-all").toggle(function() { 514 514 $("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'); ?>"); 516 516 },function() { 517 517 $("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'); ?>"); 519 519 return false; 520 520 }); 521 521 $("a.toggle-allcrono").toggle(function() { 522 522 $("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'); ?>"); 524 524 },function() { 525 525 $("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'); ?>"); 527 527 return false; 528 528 }); 529 529 <?php 530 // don't add refresh timer click function ifrefresh==0530 //Since v1.8.2: don't add timer click function when wrefresh==0 531 531 if ($wrefresh > 0) { ?> 532 532 $("#CountDownPanel").click(function(){ //Pause|Resume countdown … … 551 551 <?php } //end if page != wassup-options 552 552 553 // Since v1.8: go and go2 javascripts deleted because they are not used554 555 553 if ($_GET['page'] == "wassup-options") { 556 554 //#Current active tabs are indentified after page reload with … … 560 558 //<link rel="stylesheet" href="WASSUPURL.'/css/ui.tabs.css'" type="text/css" /> 561 559 echo "\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' /> 563 561 <script type="text/javascript"> 564 562 //<![CDATA[ 565 563 jQuery(document).ready(function($) { 566 564 var $tabs = $('#tabcontainer').tabs(); 567 //$('#tabcontainer > ul').tabs({ fx: { opacity: 'toggle' } });568 565 $('.submit-opt').click(function(){ 569 566 $(this).css("background-color", "#d71"); … … 595 592 limit: 12, 596 593 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 } ?>, 599 600 'timestamp': myTimestamp, 600 601 fadeInSpeed: 1100 }); … … 605 606 if (!empty($wassup_options->wassup_geoip_map)) { 606 607 echo "\n"; ?> 607 $("div#map").css({"opacity": "0. 5", "background": "none"}); <?php608 $("div#map").css({"opacity": "0.6", "background": "none"}); <?php 608 609 } ?> 609 610 }); … … 683 684 */ 684 685 function 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; 686 687 687 688 // Start getting time of execution to debug SQL query … … 689 690 690 691 //#debug... 691 if ($ debug_mode) {692 if ($wdebug_mode) { 692 693 $mode_reset=ini_get('display_errors'); 693 694 //error_reporting(E_ALL | E_STRICT); //debug, E_STRICT=php5 only … … 708 709 //"action_param" are preassigned "GET" parameters used for "action.php" external/ajax calls like "top ten" 709 710 $action_param='&whash='.$wassup_options->whash; 710 if ($ debug_mode) {711 if ($wdebug_mode) { 711 712 $action_param .= '&debug_mode=true'; 712 713 } … … 823 824 } 824 825 $wassup_options->wassup_screen_res = $_POST['wassup_screen_res']; 825 // validate wassup_refresh option input826 //Since v1.8.2: validate wassup_refresh input value 826 827 if (is_numeric($_POST['wassup_refresh']) && $_POST['wassup_refresh']>=0 && $_POST['wassup_refresh']<=180) { 827 828 $wassup_options->wassup_refresh = (int)$_POST['wassup_refresh']; … … 834 835 $wassup_options->wassup_googlemaps_key = $_POST['wassup_googlemaps_key']; 835 836 } 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 } 836 840 $wassup_options->wassup_time_format = $_POST['wassup_time_format']; 837 841 $wassup_options->wassup_time_period = $_POST['wassup_time_period']; 838 842 $wassup_options->wassup_default_type = $_POST['wassup_default_type']; 839 843 $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'], 841 849 "topreferrer" => $_POST['topreferrer'], 842 850 "toprequest" => $_POST['toprequest'], … … 845 853 "toplocale" => (isset($_POST['toplocale'])?$_POST['toplocale']:"0"), 846 854 "topvisitor" => (isset($_POST['topvisitor'])?$_POST['topvisitor']:"0"), 847 "top feed" => "0",848 "top crawler" => "0",849 "top referrer_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")); 850 858 $wassup_options->wassup_top10 = attribute_escape(serialize($top_ten)); 851 859 $wassup_options->wassup_cache = (!empty($_POST['wassup_cache'])?"1":"0"); … … 1193 1201 $to_date = current_time("timestamp"); //wordpress time function 1194 1202 if (isset($_GET['last']) && is_numeric($_GET['last'])) { 1195 $ last = $_GET['last'];1196 $stickyFilters.='&last='.$ last;1203 $wlast = $_GET['last']; 1204 $stickyFilters.='&last='.$wlast; 1197 1205 } 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) { 1201 1209 $from_date = "0"; //all time 1202 1210 } else { 1203 $from_date = $to_date - (int)(($ last*24)*3600);1211 $from_date = $to_date - (int)(($wlast*24)*3600); 1204 1212 //extend start date to within a rounded time 1205 if ($ last < .25) { //start on 1 minute1213 if ($wlast < .25) { //start on 1 minute 1206 1214 $from_date = ((int)($from_date/60))*60; 1207 } elseif ($ last < 7) {1215 } elseif ($wlast < 7) { 1208 1216 $from_date = ((int)($from_date/300))*300; 1209 } elseif ($ last < 30) {1217 } elseif ($wlast < 30) { 1210 1218 $from_date = ((int)($from_date/1800))*1800; 1211 } elseif ($ last < 365) {1219 } elseif ($wlast < 365) { 1212 1220 $from_date = ((int)($from_date/86400))*86400; 1213 1221 } else { … … 1218 1226 //## Filter detail lists by visitor type... 1219 1227 if (isset($_GET['type'])) { 1220 $ type = attribute_escape($_GET['type']);1221 $stickyFilters.='&type='.$ type;1228 $wtype = attribute_escape($_GET['type']); 1229 $stickyFilters.='&type='.$wtype; 1222 1230 } else { 1223 $ type = $wassup_options->wassup_default_type;1224 } 1225 if (!empty($ type) && $type != 'everything') {1226 $w hereis=$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); 1227 1235 } else { 1228 $ type="";1229 $w hereis="";1236 $wtype=""; 1237 $wwhereis=""; 1230 1238 } 1231 1239 //## Filter detail lists by a specific page and number 1232 1240 //# of items per page... 1233 $ items = 10; //default1241 $witems = 10; //default 1234 1242 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']; 1237 1245 } 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; } 1241 1249 //# current page selections 1242 1250 if (isset($_GET['pages']) && is_numeric($_GET['pages'])) { 1243 $ pages = (int)$_GET['pages'];1251 $wpages = (int)$_GET['pages']; 1244 1252 } 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"; 1249 1257 } else { 1250 $ limit = " LIMIT $items";1258 $wlimit = " LIMIT $witems"; 1251 1259 } 1252 1260 1253 1261 //## Filter detail lists by a searched item 1254 1262 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; 1257 1265 } else { 1258 $ search = "";1266 $wsearch = ""; 1259 1267 } 1260 1268 … … 1281 1289 1282 1290 // 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; 1287 1295 echo "<!--heartbeat-->\n"; 1288 1296 1289 1297 // MAIN QUERY 1290 $ main = $Tot->calc_tot("main", $search);1298 $wmain = $wTot->calc_tot("main", $wsearch); 1291 1299 echo "<!--heartbeat-->\n"; 1292 $ itemstot = $Tot->calc_tot("count", $search, null, "DISTINCT");1300 $witemstot = $wTot->calc_tot("count", $wsearch, null, "DISTINCT"); 1293 1301 echo "<!--heartbeat-->\n"; 1294 $ pagestot = $Tot->calc_tot("count", $search);1302 $wpagestot = $wTot->calc_tot("count", $wsearch); 1295 1303 echo "<!--heartbeat-->\n"; 1296 $ spamtot = $Tot->calc_tot("count", $search, "AND spam>0");1304 $wspamtot = $wTot->calc_tot("count", $wsearch, "AND spam>0"); 1297 1305 // Check if some records was marked 1298 1306 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"); 1300 1308 } 1301 1309 echo "<!--heartbeat-->\n"; 1302 1310 // 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"); 1305 1313 } 1306 1314 //# remove any delete request from $_SERVER['QUERY_STRING'] … … 1344 1352 <select style="font-size: 11px;" name="last" onChange="window.location.href=this.options[this.selectedIndex].value;"><?php 1345 1353 $optionargs="?".attribute_escape($new_last."&last="); 1346 $wassup_options->showFormOptions("wassup_time_period","$ last","$optionargs"); ?>1354 $wassup_options->showFormOptions("wassup_time_period","$wlast","$optionargs"); ?> 1347 1355 </select></td> 1348 1356 <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 … … 1353 1361 $new_limit = $URLQuery; 1354 1362 } 1355 $selected=$ items;1363 $selected=$witems; 1356 1364 $optionargs="?".$new_limit."&limit="; 1357 1365 $wassup_options->showFormOptions("wassup_default_limit","$selected","$optionargs"); ?> … … 1360 1368 <?php 1361 1369 //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); 1364 1372 $optionargs="?page=".WASSUPFOLDER.$filter_args."&type="; 1365 1373 $wassup_options->showFormOptions("wassup_default_type","$selected","$optionargs"); ?> … … 1371 1379 <div id='usage'> 1372 1380 <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><?php1381 <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 1376 1384 // Print spam usage only if enabled 1377 1385 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><?php1386 <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 1379 1387 } ?> 1380 1388 </ul><br/> … … 1384 1392 // Page breakdown 1385 1393 // paginate only when total records > items per page 1386 if ($ itemstot > $items) {1394 if ($witemstot > $witems) { 1387 1395 $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"); 1392 1400 echo "<!--heartbeat-->\n"; 1393 1401 $p->calculate(); … … 1418 1426 <td align="right" class="legend"> 1419 1427 <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'; 1421 1429 else echo '" class="thickbox'; 1422 ?>" title="Wassup <?php _e('Top Stats for Period','wassup');1430 ?>" title="Wassup <?php _e('Top Stats for','wassup'); 1423 1431 $wdformat = get_option("date_format"); 1424 1432 if (($to_date - $from_date) > 24*60*60) { … … 1429 1437 <span class="separator">|</span> 1430 1438 <a href="#" class='show-search'><?php 1431 if (!empty($ search)) {1439 if (!empty($wsearch)) { 1432 1440 _e('Hide Search','wassup'); 1433 1441 } else { … … 1436 1444 </tr> 1437 1445 <tr><td align="left" class="legend" colspan="2"><?php 1438 if (!empty($ search)) {1439 echo " <strong>".(int)$searchtot."</strong> ".__('Matches found for search','wassup').": <strong>$ search</strong>";1446 if (!empty($wsearch)) { 1447 echo " <strong>".(int)$searchtot."</strong> ".__('Matches found for search','wassup').": <strong>$wsearch</strong>"; 1440 1448 } else { 1441 1449 echo "<br/>"; … … 1443 1451 </td> 1444 1452 <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;"'; ?>> 1446 1454 <form action="" method="get"> 1447 1455 <input type="hidden" name="page" value="<?php echo WASSUPFOLDER; ?>" /><?php 1448 1456 if (!empty($stickyFilters)) { 1449 1457 $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" /> 1459 1470 </form> 1460 1471 </div> <!-- /search-ip --> … … 1464 1475 print $expcol; 1465 1476 //# Show Page numbers/Links... 1466 if ($ itemstot > $items) {1477 if ($witemstot > $witems) { 1467 1478 echo '<div id="pag" align="center">'.$p->show()."</div>\n"; 1468 1479 } 1469 1480 //# 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) { 1472 1483 $timestampF = $rk->max_timestamp; 1473 1484 $dateF = gmdate("d M Y", $timestampF); … … 1560 1571 } ?> 1561 1572 <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> 1563 1577 </ul> 1564 1578 </div> <!-- raw-wassup_id --> … … 1586 1600 <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 1587 1601 } 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> 1589 1603 <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 1590 1604 } ?> 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> 1592 1606 </p> 1593 1607 <div class="sum-box"> … … 1746 1760 } //end foreach qry 1747 1761 print $expcol; //moved 1748 } //end if itemstot > 01749 if ($ itemstot > $items) {1762 } //end if witemstot > 0 1763 if ($witemstot > $witems) { 1750 1764 print '<div align="center">'.$p->show().'</div><br />'."\n"; 1751 1765 } ?> … … 1755 1769 $chart_type = ($wassup_options->wassup_chart_type >0)? $wassup_options->wassup_chart_type: "2"; 1756 1770 //show Google!Charts image 1757 if ($ pagestot > 12) {1771 if ($wpagestot > 12) { 1758 1772 $chartwidth=$res; 1759 1773 //let browser resize chart for small screens … … 1761 1775 $chartwidth=640; 1762 1776 } 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); 1764 1778 $html='<img src="'.$chart_url.'" alt="'.__("Graph of visitor hits","wassup").'" class="chart" width="'.$res.'" />'; 1765 1779 } else { … … 1784 1798 <nobr><span class="separator">|</span> <?php echo __('Exec time','wassup').": $totaltime"; ?></nobr></small></p> 1785 1799 <?php 1786 if ($ debug_mode) {1800 if ($wdebug_mode) { 1787 1801 //display MySQL errors/warnings in admin menus - for debug 1788 1802 $wpdb->print_error(); //debug … … 1796 1810 } //end function Wassup 1797 1811 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. 1801 1814 } //end if is_admin 1802 1815 … … 1804 1817 //Set Wassup_id and cookie (before headers sent) 1805 1818 function 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; 1807 1820 1808 1821 //reload wassup_options in case changed elsewhere (by admin) … … 1815 1828 $wassup_id = ""; 1816 1829 $session_timeout = 1; 1817 $ screen_res = "";1830 $wscreen_res = ""; 1818 1831 $cookieIP = ""; 1819 1832 $cookieHost = ""; 1833 $cookieUser = ""; 1820 1834 $wassup_cookie_value=""; 1821 1835 $wassup_dbtask=array(); … … 1831 1845 $session_timeout = ((int)$wassup_timer - (int)time()); 1832 1846 } 1833 if (!empty($cookie_data[2])) $ screen_res = $cookie_data[2];1847 if (!empty($cookie_data[2])) $wscreen_res = $cookie_data[2]; 1834 1848 if (!empty($cookie_data[3])) { 1835 1849 $cookieIP = $cookie_data[3]; … … 1838 1852 } 1839 1853 } 1854 //new in v1.8.3: username in wassup cookie 1855 if (!empty($cookie_data[5])) { 1856 $cookieUser = $cookie_data[5]; 1857 } 1840 1858 } 1841 1859 //set screen resolution value from cookie or browser header data, if any 1842 if (empty($ screen_res)) {1860 if (empty($wscreen_res)) { 1843 1861 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=""; 1846 1864 } 1847 if (empty($ screen_res) && isset($_SERVER['HTTP_UA_PIXELS'])) {1865 if (empty($wscreen_res) && isset($_SERVER['HTTP_UA_PIXELS'])) { 1848 1866 //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']; 1853 1871 //} 1854 1872 } … … 1858 1876 get_currentuserinfo(); //sets $current_user, $user_xx 1859 1877 //} 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); 1861 1880 //exclude valid wordpress admin page visits and admin hits 1862 1881 if (($wassup_options->wassup_admin == "1" || $user_level < 8) && (!is_admin() || empty($logged_user))) { 1863 1882 1864 1883 //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))) { 1866 1885 $ipAddress = ""; 1867 1886 $proxy = ""; … … 1971 1990 } 1972 1991 $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")); 1974 1993 $wassup_cookie_value = urlencode(base64_encode($cookie_data)); 1975 1994 setcookie("wassup", "$wassup_cookie_value", $expire, $cookiepath, $cookiedomain); … … 1978 1997 1979 1998 //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); 1981 2000 //track visitor hits: 1982 2001 // use 'send_headers' hook to track media, downloads, and feed hits … … 2008 2027 //Track visitors and save record in wassup table, after page is displayed 2009 2028 function 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; 2011 2030 2012 2031 if ($wassup_options->wassup_active == 0) { //do nothing … … 2015 2034 @ignore_user_abort(1); // finish script in background if visitor aborts 2016 2035 2017 if ($ debug_mode) { //#debug...2036 if ($wdebug_mode) { //#debug... 2018 2037 //debug mode must be off for media and non-html requests 2019 2038 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; 2021 2040 } elseif (is_feed()) { 2022 $ debug_mode=false;2041 $wdebug_mode=false; 2023 2042 } else { 2024 2043 $mode_reset=ini_get('display_errors'); 2025 $debug_reset=$ debug_mode;2044 $debug_reset=$wdebug_mode; 2026 2045 error_reporting(E_ALL); //debug, E_STRICT=php5 only 2027 2046 ini_set('display_errors','On'); //debug … … 2037 2056 @error_reporting(E_ERROR); 2038 2057 } 2039 } //end if $ debug_mode2058 } //end if $wdebug_mode 2040 2059 2041 2060 $wpurl = get_bloginfo('wpurl'); … … 2050 2069 else $post_ID=0; 2051 2070 //if (empty($current_user->user_login)) { 2052 get_currentuserinfo(); // sets $current_user, $user_xx2071 get_currentuserinfo(); //gets $current_user, $user_xx 2053 2072 //} 2054 2073 $logged_user = (!empty($current_user->user_login)? $current_user->user_login: ""); … … 2066 2085 //# First exclusion control is for admin user 2067 2086 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'])) { 2068 2090 2069 2091 //# Record non-admin page visits and or hack attempts … … 2108 2130 if (!$exclude_visit) { 2109 2131 $wassup_id = ""; 2110 $screen_res = "";2111 2132 $cookieIP = ""; 2112 2133 $cookieHost = ""; … … 2120 2141 $wassup_id = $wassup_cookie[0]; 2121 2142 if (!empty($wassup_cookie[2])) { 2122 $ screen_res = $wassup_cookie[2];2143 $wscreen_res = $wassup_cookie[2]; 2123 2144 } 2124 2145 if (!empty($wassup_cookie[3])) { … … 2130 2151 } 2131 2152 //### set screen resolution value from cookie or browser header data, if any 2132 if (empty($ screen_res)) {2153 if (empty($wscreen_res)) { 2133 2154 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 = ""; 2136 2157 } 2137 if (empty($ screen_res) && isset($_SERVER['HTTP_UA_PIXELS'])) {2158 if (empty($wscreen_res) && isset($_SERVER['HTTP_UA_PIXELS'])) { 2138 2159 //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'])); 2140 2161 } 2141 2162 } … … 2246 2267 // visitor. Dup==same wassup_id, same URL, and timestamp <180 secs 2247 2268 $dup_urlrequest=0; 2248 $w _pageviews=0;2269 $wpageviews=0; 2249 2270 $spamresult=0; 2250 2271 $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); 2254 2275 //check 1st record only 2255 2276 //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)) { 2258 2279 $dup_urlrequest=1; 2259 2280 } … … 2264 2285 2265 2286 //retrieve previous spam check results 2266 $spamresult = $recent [0]->spam;2287 $spamresult = $recent_hit[0]->spam; 2267 2288 2268 2289 //check for screen resolution and update, if not previously recorded 2269 2290 //...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`='' "; 2272 2293 } 2273 2294 … … 2275 2296 // avoid redundant tests 2276 2297 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; 2279 2300 } 2280 2301 if ($spam == 0 && (int)$spamresult >0 ) { 2281 2302 $spam = $spamresult; 2282 2303 } 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; 2287 2308 if (empty($language)) { 2288 $language = $recent [0]->language;2309 $language = $recent_hit[0]->language; 2289 2310 } 2290 2311 //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; 2293 2314 } 2294 2315 } … … 2296 2317 // Detect disguised spiders and harvesters by checking for 2297 2318 // 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) { 2301 2323 $is_spider=true; 2302 $page test[]="$urlRequested";2324 $pageurls[]="$urlRequested"; 2303 2325 //a spider is unlikely to hit same page 2+ times 2304 foreach ($recent AS $w_pgview) {2326 foreach ($recent_hit AS $w_pgview) { 2305 2327 if (stristr($w_pgview->urlrequested,"robots.txt")!==false) { 2306 2328 $is_spider = true; 2307 2329 break; 2308 } elseif (in_array($w_pgview->urlrequested,$page test)) {2330 } elseif (in_array($w_pgview->urlrequested,$pageurls)) { 2309 2331 $is_spider = false; 2310 2332 break; 2311 2333 } else { 2312 $page test[] = $w_pgview->urlrequested;2334 $pageurls[] = $w_pgview->urlrequested; 2313 2335 } 2314 2336 } … … 2319 2341 } 2320 2342 } 2321 } //end if recent 2322 if ($ debug_mode) { //debug2323 if (!empty($recent )) {2343 } //end if recent_hit 2344 if ($wdebug_mode) { //debug 2345 if (!empty($recent_hit)) { 2324 2346 echo "<br />\nRecent visit data found in wassup_tmp:\n"; //debug 2325 print_r($recent ); //debug2347 print_r($recent_hit); //debug 2326 2348 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"; 2328 2350 if ($dup_urlrequest == 1) { 2329 2351 echo "\nDuplicate record!\n"; 2330 2352 } 2331 if ($recent [0]->agent != $userAgent) {2353 if ($recent_hit[0]->agent != $userAgent) { 2332 2354 echo "\nUser Agents NOT Identical:"; 2333 2355 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"; 2335 2357 } 2336 2358 } else { … … 2341 2363 2342 2364 //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))) { 2344 2366 //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 } 2348 2372 } elseif (preg_match('#\.\./\.\./(etc/passwd|\.\./\.\./)#i',$urlRequested)>0 || preg_match('#[\[&\?/](dir|document_root\]?|id|page|thisdir)\=https?\://#i',$urlRequested)>0) { 2349 2373 //anyone trying to access root files, password or ids are up to no good … … 2353 2377 } 2354 2378 //retroactively update record for hack attempt 2355 if ($spam == "3" && $spamresult == "0" && !empty($recent )) {2379 if ($spam == "3" && $spamresult == "0" && !empty($recent_hit)) { 2356 2380 $wassup_dbtask[] = "UPDATE $wassup_table SET `spam`='3' WHERE `wassup_id`='$wassup_id' AND `spam`='0' "; 2357 2381 } 2358 2382 2359 //# Exclude duplicates and avoid redundant checks on multi-page visits2383 //# Exclude duplicates and avoid redundant checks for multi-page visitors 2360 2384 if ($dup_urlrequest == 0) { 2361 2385 //##### Extract useful visit information from http header.. … … 2386 2410 $os = $ua->os; 2387 2411 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; 2390 2413 } 2391 2414 if (!empty($ua->language) && empty($language)) { 2392 2415 $language=$ua->language; 2393 2416 } 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"; 2395 2418 } //end if $ua->name 2396 2419 … … 2401 2424 list($browser,$os) = wGetBrowser($userAgent); 2402 2425 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"; 2404 2427 } 2405 2428 … … 2412 2435 if (empty($agent) || stristr($agent,'unknown')!==false || preg_match($spider_hosts,$hostname)>0 ) { 2413 2436 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"; 2415 2438 //it's a browser 2416 2439 if ($spidertype == "B" && $urlRequested != "/robots.txt") { … … 2427 2450 } 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())))) { 2428 2451 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"; 2430 2453 //it's a browser 2431 2454 if ($spidertype == "B" && $urlRequested != "/robots.txt") { … … 2445 2468 2446 2469 //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)) { 2448 2471 $spider = __("Unknown Spider","wassup"); 2449 2472 … … 2459 2482 //# some valid spiders to exclude from spam check below 2460 2483 $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){ 2462 2485 $goodbot = true; 2463 2486 } 2464 2487 2465 2488 //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) { 2467 2490 $spamComment = New wassup_checkComment; 2468 2491 2469 2492 //### 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)) { 2471 2494 //#...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) { 2473 2496 // Do a control if it is Referrer Spam 2474 //check if refer er is a previous comment spammer2497 //check if referrer is a previous comment spammer 2475 2498 if ($spamComment->isRefSpam($referrer)>0) { 2476 2499 $spam = 2; 2477 2500 //check referer against a list of known spammers 2478 2501 } else { 2479 if ($ debug_mode) {2502 if ($wdebug_mode) { 2480 2503 $isspam = wGetSpamRef($referrer,$hostname); 2481 2504 } else { … … 2490 2513 //# No spam check on known bots (google, yahoo,...) unless 2491 2514 //# 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))) { 2493 2516 2494 2517 //if (isset($spamresult) && stristr($urlRequested,"comment") === FALSE && stristr($urlRequested,"forum") === FALSE && empty($comment_user) && empty($_POST['comment'])) { … … 2505 2528 } 2506 2529 //#lastly check for comment spammers using Akismet API 2507 // Note: thismay cause "header already sent" errors with "send_headers" hook in some Wordpress configurations2508 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) { 2509 2532 $akismet_key = get_option('wordpress_api_key'); 2510 2533 $akismet_class = dirname(__FILE__).'/lib/akismet.class.php'; … … 2535 2558 2536 2559 //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) { 2538 2561 //queue the update... 2539 2562 $wassup_dbtask[]="UPDATE $wassup_table SET `spam`='".$spam."' WHERE `wassup_id`='".$wassup_id."' AND `spam`='0' "; … … 2554 2577 $search_phrase=""; 2555 2578 $searchpage=""; 2579 $searchcountry=""; 2556 2580 //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) { //debug2581 if (!empty($referrer) && $spam == "0" && stristr($referrer,$blogurl)!=$referrer && !$wdebug_mode) { 2582 //if ($wdebug_mode) { //debug 2559 2583 // echo '<br />\n$Referrer="'.$referrer.'" is NOT own site: '.$blogurl.'. Checking for search engine data...'."\n"; //debug 2560 2584 //} 2561 2585 //get GET type search results, ex: search=x 2562 2586 if (strpos($referrer,'=')!==false) { 2563 list($searchengine,$search_phrase,$searchpage,$searchlang,$search country)=explode("|",wGetSE($referrer));2587 list($searchengine,$search_phrase,$searchpage,$searchlang,$searchlocale)=explode("|",wGetSE($referrer)); 2564 2588 if ($search_phrase != '') { 2565 2589 $sedomain = parse_url($referrer); … … 2581 2605 if (!empty($searchengine)) { 2582 2606 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 { 2583 2613 // NOTE: Position retrieved in Google Images is 2584 2614 // the position number of image NOT page rank position like web search 2585 2615 $searchpage=(int)($searchpage/10)+1; 2586 2616 } 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)) { 2588 2620 if (!empty($match[2])) { 2589 2621 $searchcountry = $match[2]; … … 2591 2623 $searchcountry = $match[3]; 2592 2624 } 2593 }2594 if (!empty($searchcountry) && $searchcountry != "us") {2595 $searchengine .= " ".strtoupper($searchcountry);2625 if (!empty($searchcountry) && $searchcountry != "us") { 2626 $searchengine .= " ".strtoupper($searchcountry); 2627 } 2596 2628 } 2597 2629 } else { … … 2599 2631 } 2600 2632 //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))) { 2603 2637 $language=$searchcountry; 2604 2638 } … … 2624 2658 'browser'=>$browser, 2625 2659 'language'=>$language, 2626 'screen_res'=>$ screen_res,2660 'screen_res'=>$wscreen_res, 2627 2661 'spider'=>$spider, 2628 2662 'feed'=>$feed, … … 2658 2692 } //end if !exclude_visit 2659 2693 } //end if !is_admin 2694 //} //TODO end if wp-cron.php?doing_wp_cron===FALSE 2660 2695 } //end if loggeduser_level 2661 2696 … … 2723 2758 //perform scheduled database tasks 2724 2759 if (count($wassup_dbtask)>0) { 2725 if ($ debug_mode) {2760 if ($wdebug_mode) { 2726 2761 $debug_output.="\n"."Performing Scheduled tasks:".serialize($wassup_dbtask)."\n"; 2727 2762 } 2728 2763 wassup_scheduled_dbtask($wassup_dbtask); 2729 2764 } 2730 if ($ debug_mode) {2765 if ($wdebug_mode) { 2731 2766 if (!empty($wassup_rec)) { 2732 2767 echo "<br />\nWassUp record data:\n"; … … 2847 2882 */ 2848 2883 function wGetQueryPairs($urlstring){ 2849 $ return = array();2884 $wreturn = array(); 2850 2885 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); 2855 2890 } else { 2856 $ return=explode("&",$urlstring); //partial url2857 } 2858 } 2859 return $ return;2891 $wreturn=explode("&",$urlstring); //partial url 2892 } 2893 } 2894 return $wreturn; 2860 2895 } //end wGetQueryPairs 2861 2896 … … 2955 2990 "Google|www.google.|q|cd|hl||", 2956 2991 "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||||", 2961 2997 "Bing Mobile|m.bing.com|q|first|||", 2962 2998 "Bing Images|.bing.com/images/|q|first|||", … … 3037 3073 "Web|.web.de|su|||de|", 3038 3074 "Yahoo! Mobile|m.yahoo.com|p||||", 3075 "Yahoo! Mobile|m2.yahoo.com|p||||", 3076 "Yahoo!|.yahoo.com|p||||", 3039 3077 "Yandex|yandex.ru|text|||ru|", 3040 3078 "Yippy|search.yippy.com|query||||", … … 3058 3096 $searchengine = $nome; 3059 3097 $search_phrase = ""; 3060 $ variables=array();3098 $svariables=array(); 3061 3099 // Google Images or Google Translate needs additional processing of search phrase after 'prev=' 3062 3100 if ($nome == "Google Images" || $nome == "Google Translate") { 3063 3101 //'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])))); 3065 3103 $key='q'; //q is actual search key 3066 3104 } elseif ($nome == "Google Cache") { … … 3069 3107 //blogurl in search phrase: cache of own site 3070 3108 $search_phrase = attribute_escape(urldecode(substr($match[1],$n+strlen($blogurl)))); 3071 $ variables = wGetQueryPairs($referrer);3109 $svariables = wGetQueryPairs($referrer); 3072 3110 } elseif (strpos($referrer,$blogurl)!==false && preg_match('/\&prev\=([^&]+)/',$referrer,$match)!==false) { 3073 3111 //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])))); 3075 3113 } else { 3076 3114 //no blogurl in search phrase: cache of an external site with referrer link … … 3084 3122 } 3085 3123 $search_phrase = attribute_escape(urldecode($match[1])); 3086 $ variables = wGetQueryPairs($referrer);3124 $svariables = wGetQueryPairs($referrer); 3087 3125 } 3088 3126 //retrieve search engine parameters 3089 $i = count($ variables);3127 $i = count($svariables); 3090 3128 while($i--){ 3091 $tab=explode("=",$ variables[$i]);3129 $tab=explode("=",$svariables[$i]); 3092 3130 if($tab[0] == $key && empty($search_phrase)){ 3093 3131 $search_phrase=attribute_escape($tab[1]); … … 3098 3136 if (!empty($lang) && $lang == $tab[0]) { 3099 3137 $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]); 3100 3142 } 3101 3143 } … … 3250 3292 if (substr($hostname,-16) == ".crawl.yahoo.net" || (substr($hostname,-10)==".yahoo.com" && substr($hostname,0,3)=="ycar")) { 3251 3293 if (stristr($ua,"Slurp")) { 3252 $crawler = "Yahoo! Slurp";3294 $crawler = "Yahoo! Slurp"; 3253 3295 $crawlertype="R"; 3254 3296 } elseif (stristr($ua,"mobile")) { 3255 $crawler = "Yahoo! Mobile";3297 $crawler = "Yahoo! Mobile"; 3256 3298 $crawlertype="R"; 3257 3299 } else { … … 3316 3358 // 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) 3317 3359 $lines = array("Googlebot|Googlebot/|R|", 3318 "Yahoo!|Yahoo! Slurp|R|",3360 "Yahoo!|Yahoo! Slurp|R|", 3319 3361 "FeedBurner|FeedBurner|F|", 3320 3362 "AboutUsBot|AboutUsBot/|R|", … … 3654 3696 //#get the visitor locale/language 3655 3697 function wGetLocale($language="",$hostname="",$referrer="") { 3656 global $wpdb, $wassup_options, $ debug_mode;3698 global $wpdb, $wassup_options, $wdebug_mode; 3657 3699 $clocale=""; 3658 3700 $country=""; … … 3743 3785 */ 3744 3786 function wGetSpamRef($referrer,$hostname="") { 3745 global $ debug_mode;3787 global $wdebug_mode; 3746 3788 $referrer=attribute_escape(strip_tags(str_replace(" ","",html_entity_decode($referrer)))); 3747 3789 $badhost=false; … … 3759 3801 //$referrer_path = $rurl['path']; 3760 3802 $thissite = parse_url(get_option('home')); 3803 //exclude current site as referrer 3761 3804 if (isset($thissite['host']) && $referrer_host == $thissite['host']) { 3762 3805 $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 } 3763 3821 } 3764 3822 } else { //faked referrer string … … 3768 3826 if (!$badhost && !empty($referrer_host)) { 3769 3827 $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', 3772 3830 'tinyurl.com','tr.im'); 3773 3831 if(in_array($referrer_host,$url_shorteners)) { … … 3778 3836 if (empty($referrer_host) || $badhost) return $badhost; 3779 3837 3780 if ($ debug_mode) echo "\$referrer_host = $referrer_host.\n";3838 if ($wdebug_mode) echo "\$referrer_host = $referrer_host.\n"; 3781 3839 //compare against a list of recent referer spammers 3782 3840 $lines = array( '123666123\.com', 3783 3841 '209\.29\.25\.180', 3842 '[a-z]+19[0-9]{2}\.co\.cc', 3784 3843 'aerhaethjsry\.com', 3785 3844 'aimtrust\.com', … … 3788 3847 'all\-lasik\-centers\.com', 3789 3848 'allmymovies\.biz', 3849 'articlemarketingrobots\.org', 3790 3850 'baby\-kleidung\.runashop\.com', 3791 3851 'bayanbag\.tk', … … 3799 3859 'celebritydietdoctor\.com', 3800 3860 'celebrity\-?diets\.(com|org|net|info|biz)', 3861 '[a-z0-9]+\.cheapchocolatesale\.com', 3801 3862 'chocolate\.com', 3802 3863 'clients\.your\-server\.de', 3803 3864 'couplesresortsonline\.com', 3865 'creditcardsinformation\.info', 3866 '.*\.css\-build\.info', 3867 'h\-1.+\.cssgroup\.lv', 3804 3868 '.*dietplan\.com', 3869 'dogcareinsurancetips\.sosblog\.com', 3870 'dollhouserugs\.com', 3805 3871 'dreamworksdentalcenter\.com', 3806 3872 'duunot\.eu', … … 3811 3877 'frenchforbeginnerssite\.com', 3812 3878 'gameskillinggames\.net', 3879 'gardenactivities\.webnode\.com', 3813 3880 'globalringtones\.net', 3881 'gossipchips\.com', 3814 3882 'gskstudio\.com', 3815 'h\-13\d\-\d{3}\.cssgroup\.lv',3816 3883 'hearcam\.org', 3884 'hearthealth\-hpe\.org', 3817 3885 'highheelsale\.com', 3818 3886 'homebasedaffiliatemarketingbusiness\.com', … … 3824 3892 'it\.n\-able\.com', 3825 3893 'justanimal\.com', 3894 'justbazaar\.com', 3895 'knowledgehubdata\.com', 3826 3896 'koreanracinggirls\.com', 3897 'lacomunidad\.elpais\.com', 3827 3898 'lactoseintolerancesymptoms\.net', 3828 3899 'liquiddiet[a-z\-]*\.com', … … 3842 3913 'pinky\-vs\-cherokee\.com', 3843 3914 'pinkyxxx\.org', 3915 '[a-z]+\.pixnet\.net', 3844 3916 'play\-mp3\.com', 3845 3917 'poker\-review\.tk', … … 3856 3928 'sitetalk\-revolution\.com', 3857 3929 'smartforexsignal\.com', 3930 'socratestheme\.me', 3931 'stableincomeplan\.blogspot\.com', 3858 3932 'staphinfectionpictures\.org', 3859 3933 'static\.theplanet\.com', 3860 3934 '[a-z]+\-[a-z]+\-symptoms\.com', 3935 'thebestweddingparty\.com', 3861 3936 'thik\-chik\.com', 3862 3937 'thisweekendsmovies\.com', … … 4135 4210 // hook function to put a timestamp in page footer for page caching test 4136 4211 function 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"; ?> 4142 4219 <!--[if IE]> 4143 4220 <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 //]]> 4147 4234 </script> 4148 4235 <![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 4155 4242 4156 4243 /** … … 4270 4357 } 4271 4358 4359 $wstart = (int)(current_time('timestamp') - 30.4*86400); //1 month in seconds 4272 4360 // Widget TOP Browsers 4273 4361 if ($wassup_settings['wassup_widget_topbr'] == 1) { 4274 $top_period = '`timestamp` > 0'; //all time4362 $top_period = "'`timestamp` > $wstart'"; //one month 4275 4363 $top_limit = attribute_escape($topbrlimit); 4276 4364 $top_results = wGetStats("browser",$top_limit,$top_period); … … 4287 4375 // Widget TOP OSes 4288 4376 if ($wassup_settings['wassup_widget_topos'] == 1) { 4289 $top_period = '`timestamp` > 0'; //all time4377 $top_period = "'`timestamp` > $wstart'"; //one month 4290 4378 $top_limit = attribute_escape($toposlimit); 4291 4379 $top_results = wGetStats("os",$top_limit,$top_period); … … 4301 4389 4302 4390 // 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); 4304 4392 4305 4393 $currenttot = $TotWid->calc_tot("count", null, null, "DISTINCT"); … … 4521 4609 } 4522 4610 4611 $wstart = (int)(current_time('timestamp') - 30.4*86400); //1 month in seconds 4523 4612 if ($wtopbr == 1) { 4524 $top_period = '`timestamp` > 0'; //all time4613 $top_period = "'`timestamp` > $wstart'"; //one month 4525 4614 $top_limit = attribute_escape($topbrlimit); 4526 4615 $top_results = wGetStats("browser",$top_limit,$top_period); … … 4536 4625 4537 4626 if ($wtopos == 1) { 4538 $top_period = '`timestamp` > 0'; //all time4627 $top_period = "'`timestamp` > $wstart'"; //one month 4539 4628 $top_limit = attribute_escape($toposlimit); 4540 4629 $top_results = wGetStats("os",$top_limit,$top_period); … … 4550 4639 4551 4640 // Visitors Online 4552 $TotWid = New MainItems($table_tmp_name,$from_date,$to_date);4641 $TotWid = New WassupItems($table_tmp_name,$from_date,$to_date); 4553 4642 4554 4643 $currenttot = $TotWid->calc_tot("count", null, null, "DISTINCT"); … … 4584 4673 $chart_type = ($wassup_options->wassup_chart_type >0)? $wassup_options->wassup_chart_type: "2"; 4585 4674 $to_date = current_time("timestamp"); 4586 $Chart = New MainItems($wassup_table,"",$to_date);4675 $Chart = New WassupItems($wassup_table,"",$to_date); 4587 4676 $chart_url = $Chart->TheChart(1, "400", "125", "", $chart_type, "bg,s,efebef|c,lg,90,edffff,0,efebef,0.8", "dashboard"); ?> 4588 4677 <h3>WassUp <?php _e('Stats','wassup'); ?> <cite><a href="admin.php?page=<?php echo WASSUPFOLDER; ?>"><?php _e('More','wassup'); ?> »</a></cite></h3> … … 4602 4691 $chart_type = ($wassup_options->wassup_chart_type >0)? $wassup_options->wassup_chart_type: "2"; 4603 4692 $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); 4605 4694 $chart_url = $Chart->TheChart(1, $res, "180", "", $chart_type, "bg,s,efebef|c,lg,90,edffff,0,eae9e9,0.8", "dashboard"); 4606 4695 $max_char_len= 40; … … 4611 4700 margin:-10px !important; 4612 4701 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; 4614 4703 font-size:11px; 4615 4704 }
Note: See TracChangeset
for help on using the changeset viewer.