Slimstat Analytics - Version 4.6.4

Version Description

  • [Update] When the tracker was set to work in "Client mode", the Javascript code was being added to those pages that matched one of the blacklists, even though the subsequent request would have been ignored. By avoiding this, we were able to optimize our code and improve the overall performance.
  • [Fix] A conflict with a Google Maps Javascript API call was causing other scripts to not work as expected (thank you, Fulp2121).
  • [Fix] A bug was preventing the tracker from detecting certain mobile devices as expected in "Client Mode".
  • [Fix] Empty search terms were being counted in the Top/Recent Search Terms reports (thank you, Per).
Download this release

Release Info

Developer coolmann
Plugin Icon 128x128 Slimstat Analytics
Version 4.6.4
Comparing to
See all releases

Code changes from version 4.6.3 to 4.6.4

admin/view/wp-slimstat-reports.php CHANGED
@@ -134,7 +134,7 @@ class wp_slimstat_reports {
134
  'callback_args' => array(
135
  'type' => 'recent',
136
  'columns' => 'searchterms',
137
- 'where' => 'searchterms <> "_"',
138
  'more_columns' => 'referer, resource',
139
  'raw' => array( 'wp_slimstat_db', 'get_recent' )
140
  ),
@@ -187,7 +187,7 @@ class wp_slimstat_reports {
187
  'callback_args' => array(
188
  'type' => 'top',
189
  'columns' => 'searchterms',
190
- 'where' => 'searchterms <> "_"',
191
  'raw' => array( 'wp_slimstat_db', 'get_top' )
192
  ),
193
  'classes' => array( 'normal' ),
@@ -250,7 +250,7 @@ class wp_slimstat_reports {
250
  'chart_data' => array(
251
  'data1' => 'COUNT( searchterms )',
252
  'data2' => 'COUNT( DISTINCT searchterms )',
253
- 'where' => 'searchterms <> "_"'
254
  ),
255
  'chart_labels' => array(
256
  __( 'Search Terms', 'wp-slimstat' ),
@@ -551,7 +551,7 @@ class wp_slimstat_reports {
551
  'columns' => 'REPLACE( SUBSTRING_INDEX( SUBSTRING_INDEX( SUBSTRING_INDEX( referer, "://", -1 ), "/", 1 ), ".", -5 ), "www.", "" )',
552
  'as_column' => 'referer_calculated',
553
  'filter_op' => 'contains',
554
- 'where' => 'searchterms IS NOT NULL AND referer NOT LIKE "%' . str_replace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) ) . '%"',
555
  'raw' => array( 'wp_slimstat_db', 'get_top' )
556
  ),
557
  'classes' => array( 'normal' ),
@@ -642,7 +642,7 @@ class wp_slimstat_reports {
642
  'callback_args' => array(
643
  'type' => 'recent',
644
  'columns' => 'searchterms',
645
- 'where' => 'content_type LIKE "%search%"',
646
  'raw' => array( 'wp_slimstat_db', 'get_recent' )
647
  ),
648
  'classes' => array( 'normal', 'hidden' ),
@@ -718,7 +718,7 @@ class wp_slimstat_reports {
718
  'callback_args' => array(
719
  'type' => 'top',
720
  'columns' => 'searchterms',
721
- 'where' => 'content_type LIKE "%search%"',
722
  'raw' => array( 'wp_slimstat_db', 'get_top' )
723
  ),
724
  'classes' => array( 'normal', 'hidden' ),
@@ -1926,7 +1926,7 @@ class wp_slimstat_reports {
1926
  }
1927
  }
1928
 
1929
- public static function get_search_terms_info($_searchterms = '', $_referer = '', $_serp_only = false){
1930
  $query_details = '';
1931
  $search_terms_info = '';
1932
  parse_str( $_referer, $query_parse_str );
134
  'callback_args' => array(
135
  'type' => 'recent',
136
  'columns' => 'searchterms',
137
+ 'where' => 'searchterms <> "_" AND searchterms <> "" AND searchterms IS NOT NULL',
138
  'more_columns' => 'referer, resource',
139
  'raw' => array( 'wp_slimstat_db', 'get_recent' )
140
  ),
187
  'callback_args' => array(
188
  'type' => 'top',
189
  'columns' => 'searchterms',
190
+ 'where' => 'searchterms <> "_" AND searchterms <> "" AND searchterms IS NOT NULL',
191
  'raw' => array( 'wp_slimstat_db', 'get_top' )
192
  ),
193
  'classes' => array( 'normal' ),
250
  'chart_data' => array(
251
  'data1' => 'COUNT( searchterms )',
252
  'data2' => 'COUNT( DISTINCT searchterms )',
253
+ 'where' => 'searchterms <> "_" AND searchterms IS NOT NULL AND searchterms <> ""'
254
  ),
255
  'chart_labels' => array(
256
  __( 'Search Terms', 'wp-slimstat' ),
551
  'columns' => 'REPLACE( SUBSTRING_INDEX( SUBSTRING_INDEX( SUBSTRING_INDEX( referer, "://", -1 ), "/", 1 ), ".", -5 ), "www.", "" )',
552
  'as_column' => 'referer_calculated',
553
  'filter_op' => 'contains',
554
+ 'where' => 'searchterms IS NOT NULL searchterms <> "" AND searchterms <> "_" AND referer NOT LIKE "%' . str_replace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) ) . '%"',
555
  'raw' => array( 'wp_slimstat_db', 'get_top' )
556
  ),
557
  'classes' => array( 'normal' ),
642
  'callback_args' => array(
643
  'type' => 'recent',
644
  'columns' => 'searchterms',
645
+ 'where' => 'content_type LIKE "%search%" AND searchterms <> "" AND searchterms IS NOT NULL',
646
  'raw' => array( 'wp_slimstat_db', 'get_recent' )
647
  ),
648
  'classes' => array( 'normal', 'hidden' ),
718
  'callback_args' => array(
719
  'type' => 'top',
720
  'columns' => 'searchterms',
721
+ 'where' => 'content_type LIKE "%search%" AND searchterms <> "" AND searchterms IS NOT NULL',
722
  'raw' => array( 'wp_slimstat_db', 'get_top' )
723
  ),
724
  'classes' => array( 'normal', 'hidden' ),
1926
  }
1927
  }
1928
 
1929
+ public static function get_search_terms_info( $_searchterms = '', $_referer = '', $_serp_only = false ) {
1930
  $query_details = '';
1931
  $search_terms_info = '';
1932
  parse_str( $_referer, $query_parse_str );
admin/wp-slimstat-admin.php CHANGED
@@ -122,7 +122,7 @@ class wp_slimstat_admin {
122
  }
123
 
124
  if ( function_exists( 'is_network_admin' ) && !is_network_admin() ) {
125
- // Add the appropriate entries to the admin menu, if this user can view/admin WP SlimStats
126
  add_action( 'admin_menu', array( __CLASS__, 'wp_slimstat_add_view_menu' ) );
127
  add_action( 'admin_menu', array( __CLASS__, 'wp_slimstat_add_config_menu' ) );
128
 
@@ -142,7 +142,7 @@ class wp_slimstat_admin {
142
  }
143
  }
144
 
145
- // Add some inline CSS to customize the icon associated to SlimStat in the sidebar
146
  add_action( 'admin_enqueue_scripts', array( __CLASS__, 'wp_slimstat_stylesheet_icon' ) );
147
 
148
  // Update the table structure and options, if needed
@@ -775,7 +775,7 @@ class wp_slimstat_admin {
775
  if ( wp_slimstat::$settings[ 'use_separate_menu' ] == 'yes' || is_network_admin() ) {
776
  $parent = 'slimview1';
777
  $page_location = 'slimstat';
778
- $new_entry[] = add_menu_page(__('SlimStat','wp-slimstat'), __('SlimStat','wp-slimstat'), $minimum_capability, $parent, array( __CLASS__, 'wp_slimstat_include_view' ) );
779
  }
780
  else {
781
  $parent = 'admin.php';
@@ -860,7 +860,7 @@ class wp_slimstat_admin {
860
  }
861
 
862
  /**
863
- * Adds a new entry in the admin menu, to manage SlimStat options
864
  */
865
  public static function wp_slimstat_add_config_menu($_s){
866
  wp_slimstat::$settings[ 'capability_can_admin' ] = empty( wp_slimstat::$settings[ 'capability_can_admin' ] ) ? 'activate_plugins' : wp_slimstat::$settings[ 'capability_can_admin' ];
122
  }
123
 
124
  if ( function_exists( 'is_network_admin' ) && !is_network_admin() ) {
125
+ // Add the appropriate entries to the admin menu, if this user can view/admin Slimstat
126
  add_action( 'admin_menu', array( __CLASS__, 'wp_slimstat_add_view_menu' ) );
127
  add_action( 'admin_menu', array( __CLASS__, 'wp_slimstat_add_config_menu' ) );
128
 
142
  }
143
  }
144
 
145
+ // Add some inline CSS to customize the icon associated to Slimstat in the sidebar
146
  add_action( 'admin_enqueue_scripts', array( __CLASS__, 'wp_slimstat_stylesheet_icon' ) );
147
 
148
  // Update the table structure and options, if needed
775
  if ( wp_slimstat::$settings[ 'use_separate_menu' ] == 'yes' || is_network_admin() ) {
776
  $parent = 'slimview1';
777
  $page_location = 'slimstat';
778
+ $new_entry[] = add_menu_page(__('Slimstat','wp-slimstat'), __('Slimstat','wp-slimstat'), $minimum_capability, $parent, array( __CLASS__, 'wp_slimstat_include_view' ) );
779
  }
780
  else {
781
  $parent = 'admin.php';
860
  }
861
 
862
  /**
863
+ * Adds a new entry in the admin menu, to manage Slimstat options
864
  */
865
  public static function wp_slimstat_add_config_menu($_s){
866
  wp_slimstat::$settings[ 'capability_can_admin' ] = empty( wp_slimstat::$settings[ 'capability_can_admin' ] ) ? 'activate_plugins' : wp_slimstat::$settings[ 'capability_can_admin' ];
browscap/browser.php CHANGED
@@ -17,15 +17,13 @@ class slim_browser {
17
  self::$browscap_autoload_path = wp_slimstat::$upload_dir . '/browscap-db/autoload.php';
18
 
19
  if ( file_exists( self::$browscap_autoload_path ) && version_compare( PHP_VERSION, '5.5', '>=' ) ) {
20
- $return_code = self::update_browscap_database( false );
 
21
 
22
- if ( is_array( $return_code ) && $return_code[ 0 ] === 0 ) {
23
- require_once( self::$browscap_autoload_path );
24
-
25
- if ( method_exists( 'slimBrowscapConnector', 'get_browser_from_browscap' ) ) {
26
- self::$browser = slimBrowscapConnector::get_browser_from_browscap( self::$browser );
27
- }
28
  }
 
29
  }
30
  }
31
 
17
  self::$browscap_autoload_path = wp_slimstat::$upload_dir . '/browscap-db/autoload.php';
18
 
19
  if ( file_exists( self::$browscap_autoload_path ) && version_compare( PHP_VERSION, '5.5', '>=' ) ) {
20
+ self::update_browscap_database( false );
21
+ require_once( self::$browscap_autoload_path );
22
 
23
+ if ( method_exists( 'slimBrowscapConnector', 'get_browser_from_browscap' ) ) {
24
+ self::$browser = slimBrowscapConnector::get_browser_from_browscap( self::$browser );
 
 
 
 
25
  }
26
+
27
  }
28
  }
29
 
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
- === Slim Stat Analytics ===
2
  Contributors: coolmann
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BNJR5EZNY3W38
4
  Tags: analytics, statistics, counter, tracking, reports, wassup, geolocation, online users, spider, tracker, pageviews, stats, maxmind, statistics, statpress, power stats, hit
5
  Text Domain: wp-slimstat
6
  Requires at least: 3.8
7
  Tested up to: 4.8
8
- Stable tag: 4.6.3
9
 
10
  == Description ==
11
  [youtube https://www.youtube.com/watch?v=zEKP9yC8x6g]
@@ -68,6 +68,12 @@ Our knowledge base is available on our [support center](http://docs.wp-slimstat.
68
  5. **Responsive layout** - Keep an eye on your reports on the go
69
 
70
  == Changelog ==
 
 
 
 
 
 
71
  = 4.6.3 =
72
  * [Note] We would like to thank all the people who stepped forward to offer their help and test this new version before it was officially released. We worked with our users to identify the many different scenarios related to lightbox libraries, jQuery animations and so forth. It was a great team effort! You guys are terrific!
73
  * [Update] Say goodbye to incompatibility issues with lightbox libraries, jQuery drop down menus, fancy animations and the like. We worked on the tracking algorithm to make it less intrusive, and to FINALLY play nice with any other event handlers attached to your DOM elements. As an added bonus, the new tracker is performing from 10 to 30 percent faster in our tests. Not bad, huh?
1
+ === Slimstat Analytics ===
2
  Contributors: coolmann
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BNJR5EZNY3W38
4
  Tags: analytics, statistics, counter, tracking, reports, wassup, geolocation, online users, spider, tracker, pageviews, stats, maxmind, statistics, statpress, power stats, hit
5
  Text Domain: wp-slimstat
6
  Requires at least: 3.8
7
  Tested up to: 4.8
8
+ Stable tag: 4.6.4
9
 
10
  == Description ==
11
  [youtube https://www.youtube.com/watch?v=zEKP9yC8x6g]
68
  5. **Responsive layout** - Keep an eye on your reports on the go
69
 
70
  == Changelog ==
71
+ = 4.6.4 =
72
+ * [Update] When the tracker was set to work in "Client mode", the Javascript code was being added to those pages that matched one of the blacklists, even though the subsequent request would have been ignored. By avoiding this, we were able to optimize our code and improve the overall performance.
73
+ * [Fix] A conflict with a Google Maps Javascript API call was causing other scripts to not work as expected (thank you, Fulp2121).
74
+ * [Fix] A bug was preventing the tracker from detecting certain mobile devices as expected in "Client Mode".
75
+ * [Fix] Empty search terms were being counted in the Top/Recent Search Terms reports (thank you, Per).
76
+
77
  = 4.6.3 =
78
  * [Note] We would like to thank all the people who stepped forward to offer their help and test this new version before it was officially released. We worked with our users to identify the many different scenarios related to lightbox libraries, jQuery animations and so forth. It was a great team effort! You guys are terrific!
79
  * [Update] Say goodbye to incompatibility issues with lightbox libraries, jQuery drop down menus, fancy animations and the like. We worked on the tracking algorithm to make it less intrusive, and to FINALLY play nice with any other event handlers attached to your DOM elements. As an added bonus, the new tracker is performing from 10 to 30 percent faster in our tests. Not bad, huh?
wp-slimstat.js CHANGED
@@ -221,6 +221,7 @@ var SlimStat = {
221
  if ( request ) {
222
  request.open( "POST", SlimStatParams.ajaxurl, true );
223
  request.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
 
224
  request.send( slimstat_data_with_client_info );
225
 
226
  request.onreadystatechange = function() {
@@ -375,20 +376,18 @@ SlimStat.add_event( window, "load", function() {
375
  var to_not_track = ( "undefined" != typeof SlimStatParams.outbound_classes_rel_href_to_not_track && SlimStatParams.outbound_classes_rel_href_to_not_track ) ? SlimStatParams.outbound_classes_rel_href_to_not_track.split( ',' ) : [];
376
 
377
  for (var i = 0; i < all_links.length; i++) {
378
- var cur_link = all_links[i];
379
-
380
  // Types
381
  // 0: external
382
  // 1: download
383
  // 2: internal (track coordinates only)
384
 
385
- type = ( cur_link.href && ( cur_link.hostname == location.hostname || cur_link.href.indexOf('://') == -1 ) ) ? 2 : 0;
386
  tracking = 1;
387
 
388
  // Do not track links with given class names...
389
  if ( to_not_track.length > 0 ) {
390
  if ( 1 == tracking ) {
391
- classes_current_link = ( "undefined" != typeof cur_link.className && cur_link.className ) ? cur_link.className.split( " " ) : [];
392
 
393
  for ( var cl = 0; cl < classes_current_link.length; cl++ ) {
394
  if ( SlimStat.in_array_substring( classes_current_link[ cl ], to_not_track ) ) {
@@ -399,36 +398,36 @@ SlimStat.add_event( window, "load", function() {
399
  }
400
 
401
  // ... or rel attribute
402
- if ( 1 == tracking && "undefined" != typeof cur_link.attributes.rel && cur_link.attributes.rel.value ) {
403
- if ( SlimStat.in_array_substring( cur_link.attributes.rel.value, to_not_track ) ) {
404
  tracking = 0;
405
  }
406
  }
407
 
408
  // ... or HREF attribute
409
- if ( 1 == tracking && "undefined" != typeof cur_link.href && cur_link.href ) {
410
- if ( SlimStat.in_array_substring( cur_link.href, to_not_track ) ) {
411
  tracking = 0;
412
  }
413
  }
414
  }
415
 
416
  // Downloads
417
- extension_current_link = cur_link.pathname.split( /[?#]/ )[ 0 ].split( '.' ).pop().replace( /[\/\-]/g, '' );
418
- if ( 2 == type && extensions_to_track.length > 0 && SlimStat.in_array( extension_current_link, extensions_to_track ) ) {
419
  tracking = 1;
420
- type = 1;
421
  }
422
 
423
- cur_link.setAttribute( "data-slimstat", ( type << 1 ) + tracking );
424
 
425
- SlimStat.add_event( cur_link, "click", function( e ) {
426
  link_info = parseInt( this.getAttribute( "data-slimstat" ) );
427
  if ( isNaN ( link_info ) ) {
428
  link_info = 0;
429
  }
430
 
431
- // tracking: link_info & 1 --- type: link_info >> 1;
432
  if ( link_info & 1 == 1 ) {
433
  SlimStat.ss_track( e, link_info >> 1, "" );
434
  }
221
  if ( request ) {
222
  request.open( "POST", SlimStatParams.ajaxurl, true );
223
  request.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
224
+ request.setRequestHeader( "X-Requested-With", "XMLHttpRequest" );
225
  request.send( slimstat_data_with_client_info );
226
 
227
  request.onreadystatechange = function() {
376
  var to_not_track = ( "undefined" != typeof SlimStatParams.outbound_classes_rel_href_to_not_track && SlimStatParams.outbound_classes_rel_href_to_not_track ) ? SlimStatParams.outbound_classes_rel_href_to_not_track.split( ',' ) : [];
377
 
378
  for (var i = 0; i < all_links.length; i++) {
 
 
379
  // Types
380
  // 0: external
381
  // 1: download
382
  // 2: internal (track coordinates only)
383
 
384
+ linktype = ( all_links[ i ].href && ( all_links[ i ].hostname == location.hostname || all_links[ i ].href.indexOf( '://' ) == -1 ) ) ? 2 : 0;
385
  tracking = 1;
386
 
387
  // Do not track links with given class names...
388
  if ( to_not_track.length > 0 ) {
389
  if ( 1 == tracking ) {
390
+ classes_current_link = ( "undefined" != typeof all_links[ i ].className && all_links[ i ].className ) ? all_links[ i ].className.split( " " ) : [];
391
 
392
  for ( var cl = 0; cl < classes_current_link.length; cl++ ) {
393
  if ( SlimStat.in_array_substring( classes_current_link[ cl ], to_not_track ) ) {
398
  }
399
 
400
  // ... or rel attribute
401
+ if ( 1 == tracking && "undefined" != typeof all_links[ i ].attributes.rel && all_links[ i ].attributes.rel.value ) {
402
+ if ( SlimStat.in_array_substring( all_links[ i ].attributes.rel.value, to_not_track ) ) {
403
  tracking = 0;
404
  }
405
  }
406
 
407
  // ... or HREF attribute
408
+ if ( 1 == tracking && "undefined" != typeof all_links[ i ].href && all_links[ i ].href ) {
409
+ if ( SlimStat.in_array_substring( all_links[ i ].href, to_not_track ) ) {
410
  tracking = 0;
411
  }
412
  }
413
  }
414
 
415
  // Downloads
416
+ extension_current_link = all_links[ i ].pathname.split( /[?#]/ )[ 0 ].split( '.' ).pop().replace( /[\/\-]/g, '' );
417
+ if ( 2 == linktype && extensions_to_track.length > 0 && SlimStat.in_array( extension_current_link, extensions_to_track ) ) {
418
  tracking = 1;
419
+ linktype = 1;
420
  }
421
 
422
+ all_links[ i ].setAttribute( "data-slimstat", ( linktype << 1 ) + tracking );
423
 
424
+ SlimStat.add_event( all_links[ i ], "click", function( e ) {
425
  link_info = parseInt( this.getAttribute( "data-slimstat" ) );
426
  if ( isNaN ( link_info ) ) {
427
  link_info = 0;
428
  }
429
 
430
+ // tracking: link_info & 1 --- linktype: link_info >> 1;
431
  if ( link_info & 1 == 1 ) {
432
  SlimStat.ss_track( e, link_info >> 1, "" );
433
  }
wp-slimstat.min.js CHANGED
@@ -1 +1 @@
1
- var SlimStat={_id:"undefined"!=typeof SlimStatParams.id?SlimStatParams.id:"-1.0",_base64_key_str:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_plugins:{acrobat:{substrings:["Adobe","Acrobat"],active_x_strings:["AcroPDF.PDF","PDF.PDFCtrl.5"]},pdfviewer:{substrings:["PDF"],active_x_strings:["AcroPDF.PDF"]},flash:{substrings:["Shockwave","Flash"],active_x_strings:["ShockwaveFlash.ShockwaveFlash"]},mediaplayer:{substrings:["Windows Media"],active_x_strings:["WMPlayer.OCX"]},quicktime:{substrings:["QuickTime"],active_x_strings:["QuickTime.QuickTime"]},silverlight:{substrings:["Silverlight"],active_x_strings:["AgControl.AgControl"]}},_utf8_encode:function(a){var b,c,d="";for(a=a.replace(/\r\n/g,"\n"),b=0;b<a.length;b++)c=a.charCodeAt(b),c<128?d+=String.fromCharCode(c):c>127&&c<2048?(d+=String.fromCharCode(c>>6|192),d+=String.fromCharCode(63&c|128)):(d+=String.fromCharCode(c>>12|224),d+=String.fromCharCode(c>>6&63|128),d+=String.fromCharCode(63&c|128));return d},_base64_encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=SlimStat._utf8_encode(a);j<a.length;)b=a.charCodeAt(j++),c=a.charCodeAt(j++),d=a.charCodeAt(j++),e=b>>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)?g=h=64:isNaN(d)&&(h=64),i=i+SlimStat._base64_key_str.charAt(e)+SlimStat._base64_key_str.charAt(f)+SlimStat._base64_key_str.charAt(g)+SlimStat._base64_key_str.charAt(h);return i},_detect_single_plugin_not_ie:function(a){var c,d,e,f;for(e in navigator.plugins){c=""+navigator.plugins[e].name+navigator.plugins[e].description,d=0;for(f in SlimStat._plugins[a].substrings)c.indexOf(SlimStat._plugins[a].substrings[f])!=-1&&d++;if(d==SlimStat._plugins[a].substrings.length)return!0}return!1},_detect_single_plugin_ie:function(a){var b="",c=!1;for(b in SlimStat._plugins[a].active_x_strings)try{new ActiveXObject(SlimStat._plugins[a].active_x_strings[b]),c=!0}catch(a){}return c},_detect_single_plugin:function(a){return navigator.plugins.length?this.detect=SlimStat._detect_single_plugin_not_ie:this.detect=SlimStat._detect_single_plugin_ie,this.detect(a)},detect_plugins:function(){var a,b=[];for(a in SlimStat._plugins)SlimStat._detect_single_plugin(a)&&b.push(a);return"function"==typeof navigator.javaEnabled&&navigator.javaEnabled()&&b.push("java"),b.join(",")},get_page_performance:function(){return slim_performance=window.performance||window.mozPerformance||window.msPerformance||window.webkitPerformance||{},"undefined"==typeof slim_performance.timing?0:slim_performance.timing.loadEventEnd-slim_performance.timing.responseEnd},get_server_latency:function(){return slim_performance=window.performance||window.mozPerformance||window.msPerformance||window.webkitPerformance||{},"undefined"==typeof slim_performance.timing?0:slim_performance.timing.responseEnd-slim_performance.timing.connectEnd},add_event:function(a,b,c){a&&a.addEventListener?a.addEventListener(b,c,!1):a&&a.attachEvent?(a["e"+b+c]=c,a[b+c]=function(){a["e"+b+c](window.event)},a.attachEvent("on"+b,a[b+c])):a["on"+b]=a["e"+b+c]},in_array:function(a,b){for(var c=0;c<b.length;c++)if(b[c].trim()==a)return!0;return!1},in_array_substring:function(a,b){for(var c=0;c<b.length;c++)if(a.indexOf(b[c].trim())!=-1)return!0;return!1},send_to_server:function(a,b){if("undefined"==typeof SlimStatParams.ajaxurl||"undefined"==typeof a)return!1;if("undefined"==typeof b&&(b=!0),slimstat_data_with_client_info=a+"&sw="+screen.width+"&sh="+screen.height+"&bw="+window.innerWidth+"&bh="+window.innerHeight+"&sl="+SlimStat.get_server_latency()+"&pp="+SlimStat.get_page_performance()+"&pl="+SlimStat.detect_plugins(),b&&navigator.sendBeacon)navigator.sendBeacon(SlimStatParams.ajaxurl,slimstat_data_with_client_info);else{try{window.XMLHttpRequest?request=new XMLHttpRequest:window.ActiveXObject&&(request=new ActiveXObject("Microsoft.XMLHTTP"))}catch(a){return!1}if(request)return request.open("POST",SlimStatParams.ajaxurl,!0),request.setRequestHeader("Content-type","application/x-www-form-urlencoded"),request.send(slimstat_data_with_client_info),request.onreadystatechange=function(){4==request.readyState&&(parsed_id=parseInt(request.responseText),!isNaN(parsed_id)&&parsed_id>0&&(SlimStat._id=request.responseText))},!0}return!1},ss_track:function(a,b,c,d){if(a=a?a:window.event,b="undefined"==typeof b?0:parseInt(b),note_array=[],"undefined"==typeof d&&(d=!0),parsed_id=parseInt(SlimStat._id),isNaN(parsed_id)||parsed_id<=0)return!1;if(node="undefined"!=typeof a.target?a.target:"undefined"!=typeof a.srcElement&&a.srcElement,!node)return!1;switch(3==node.nodeType&&(node=node.parentNode),parent_node=node.parentNode,resource_url="",node.nodeName){case"FORM":"undefined"!=typeof node.action&&node.action&&(resource_url=node.action);break;case"INPUT":for(;"undefined"!=typeof parent_node&&"FORM"!=parent_node.nodeName&&"BODY"!=parent_node.nodeName;)parent_node=parent_node.parentNode;if("undefined"!=typeof parent_node.action&&parent_node.action){resource_url=parent_node.action;break}default:if("A"!=node.nodeName)for(;"undefined"!=typeof node.parentNode&&null!=node.parentNode&&"A"!=node.nodeName&&"BODY"!=node.nodeName;)node=node.parentNode;"undefined"!=typeof node.hash&&node.hash&&node.hostname==location.hostname?resource_url=node.hash:"undefined"!=typeof node.href&&(resource_url=node.href),"function"==typeof node.getAttribute&&("undefined"!=typeof node.getAttribute("title")&&node.getAttribute("title")&&note_array.push("Title:"+node.getAttribute("title")),"undefined"!=typeof node.getAttribute("id")&&node.getAttribute("id")&&note_array.push("ID:"+node.getAttribute("id")))}return pos_x=-1,pos_y=-1,position="","undefined"!=typeof a.pageX&&"undefined"!=typeof a.pageY?(pos_x=a.pageX,pos_y=a.pageY):"undefined"!=typeof a.clientX&&"undefined"!=typeof a.clientY&&"undefined"!=typeof document.body.scrollLeft&&"undefined"!=typeof document.documentElement.scrollLeft&&"undefined"!=typeof document.body.scrollTop&&"undefined"!=typeof document.documentElement.scrollTop&&(pos_x=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,pos_y=a.clientY+document.body.scrollTop+document.documentElement.scrollTop),pos_x>0&&pos_y>0&&(position=pos_x+","+pos_y),event_description=a.type,"keypress"==a.type?event_description+="; keypress:"+String.fromCharCode(parseInt(a.which)):"click"==a.type&&(event_description+="; which:"+a.which),"undefined"!=typeof c&&c&&note_array.push(c),note_string=SlimStat._base64_encode(note_array.join(", ")),requested_op="add",1==b?resource_url=resource_url.substring(resource_url.indexOf(location.hostname)+location.hostname.length):0!=b&&2!=b||(requested_op="update"),SlimStat.send_to_server("action=slimtrack&op="+requested_op+"&id="+SlimStat._id+"&ty="+b+"&ref="+SlimStat._base64_encode(document.referrer)+"&res="+SlimStat._base64_encode(resource_url)+"&pos="+position+"&des="+SlimStat._base64_encode(event_description)+"&no="+note_string,d),!0}};"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),SlimStat.add_event(window,"load",function(){all_links=document.getElementsByTagName("a");for(var a="undefined"!=typeof SlimStatParams.extensions_to_track&&SlimStatParams.extensions_to_track?SlimStatParams.extensions_to_track.split(","):[],b="undefined"!=typeof SlimStatParams.outbound_classes_rel_href_to_not_track&&SlimStatParams.outbound_classes_rel_href_to_not_track?SlimStatParams.outbound_classes_rel_href_to_not_track.split(","):[],c=0;c<all_links.length;c++){var d=all_links[c];if(type=!d.href||d.hostname!=location.hostname&&d.href.indexOf("://")!=-1?0:2,tracking=1,b.length>0){if(1==tracking){classes_current_link="undefined"!=typeof d.className&&d.className?d.className.split(" "):[];for(var e=0;e<classes_current_link.length;e++)if(SlimStat.in_array_substring(classes_current_link[e],b)){tracking=0;break}}1==tracking&&"undefined"!=typeof d.attributes.rel&&d.attributes.rel.value&&SlimStat.in_array_substring(d.attributes.rel.value,b)&&(tracking=0),1==tracking&&"undefined"!=typeof d.href&&d.href&&SlimStat.in_array_substring(d.href,b)&&(tracking=0)}extension_current_link=d.pathname.split(/[?#]/)[0].split(".").pop().replace(/[\/\-]/g,""),2==type&&a.length>0&&SlimStat.in_array(extension_current_link,a)&&(tracking=1,type=1),d.setAttribute("data-slimstat",(type<<1)+tracking),SlimStat.add_event(d,"click",function(a){link_info=parseInt(this.getAttribute("data-slimstat")),isNaN(link_info)&&(link_info=0),link_info&!0&&SlimStat.ss_track(a,link_info>>1,"")})}});var slimstat_data="",use_beacon=!0;"undefined"!=typeof SlimStatParams.id&&parseInt(SlimStatParams.id)>0?slimstat_data="action=slimtrack&op=update&id="+SlimStatParams.id:"undefined"!=typeof SlimStatParams.ci&&(slimstat_data="action=slimtrack&op=add&id="+SlimStatParams.ci+"&ref="+SlimStat._base64_encode(document.referrer)+"&res="+SlimStat._base64_encode(window.location.href),use_beacon=!1),slimstat_data.length>0&&SlimStat.add_event(window,"load",function(){setTimeout(function(){SlimStat.send_to_server(slimstat_data,"")},0)});
1
+ var SlimStat={_id:"undefined"!=typeof SlimStatParams.id?SlimStatParams.id:"-1.0",_base64_key_str:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_plugins:{acrobat:{substrings:["Adobe","Acrobat"],active_x_strings:["AcroPDF.PDF","PDF.PDFCtrl.5"]},pdfviewer:{substrings:["PDF"],active_x_strings:["AcroPDF.PDF"]},flash:{substrings:["Shockwave","Flash"],active_x_strings:["ShockwaveFlash.ShockwaveFlash"]},mediaplayer:{substrings:["Windows Media"],active_x_strings:["WMPlayer.OCX"]},quicktime:{substrings:["QuickTime"],active_x_strings:["QuickTime.QuickTime"]},silverlight:{substrings:["Silverlight"],active_x_strings:["AgControl.AgControl"]}},_utf8_encode:function(a){var b,c,d="";for(a=a.replace(/\r\n/g,"\n"),b=0;b<a.length;b++)c=a.charCodeAt(b),c<128?d+=String.fromCharCode(c):c>127&&c<2048?(d+=String.fromCharCode(c>>6|192),d+=String.fromCharCode(63&c|128)):(d+=String.fromCharCode(c>>12|224),d+=String.fromCharCode(c>>6&63|128),d+=String.fromCharCode(63&c|128));return d},_base64_encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=SlimStat._utf8_encode(a);j<a.length;)b=a.charCodeAt(j++),c=a.charCodeAt(j++),d=a.charCodeAt(j++),e=b>>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)?g=h=64:isNaN(d)&&(h=64),i=i+SlimStat._base64_key_str.charAt(e)+SlimStat._base64_key_str.charAt(f)+SlimStat._base64_key_str.charAt(g)+SlimStat._base64_key_str.charAt(h);return i},_detect_single_plugin_not_ie:function(a){var c,d,e,f;for(e in navigator.plugins){c=""+navigator.plugins[e].name+navigator.plugins[e].description,d=0;for(f in SlimStat._plugins[a].substrings)c.indexOf(SlimStat._plugins[a].substrings[f])!=-1&&d++;if(d==SlimStat._plugins[a].substrings.length)return!0}return!1},_detect_single_plugin_ie:function(a){var b="",c=!1;for(b in SlimStat._plugins[a].active_x_strings)try{new ActiveXObject(SlimStat._plugins[a].active_x_strings[b]),c=!0}catch(a){}return c},_detect_single_plugin:function(a){return navigator.plugins.length?this.detect=SlimStat._detect_single_plugin_not_ie:this.detect=SlimStat._detect_single_plugin_ie,this.detect(a)},detect_plugins:function(){var a,b=[];for(a in SlimStat._plugins)SlimStat._detect_single_plugin(a)&&b.push(a);return"function"==typeof navigator.javaEnabled&&navigator.javaEnabled()&&b.push("java"),b.join(",")},get_page_performance:function(){return slim_performance=window.performance||window.mozPerformance||window.msPerformance||window.webkitPerformance||{},"undefined"==typeof slim_performance.timing?0:slim_performance.timing.loadEventEnd-slim_performance.timing.responseEnd},get_server_latency:function(){return slim_performance=window.performance||window.mozPerformance||window.msPerformance||window.webkitPerformance||{},"undefined"==typeof slim_performance.timing?0:slim_performance.timing.responseEnd-slim_performance.timing.connectEnd},add_event:function(a,b,c){a&&a.addEventListener?a.addEventListener(b,c,!1):a&&a.attachEvent?(a["e"+b+c]=c,a[b+c]=function(){a["e"+b+c](window.event)},a.attachEvent("on"+b,a[b+c])):a["on"+b]=a["e"+b+c]},in_array:function(a,b){for(var c=0;c<b.length;c++)if(b[c].trim()==a)return!0;return!1},in_array_substring:function(a,b){for(var c=0;c<b.length;c++)if(a.indexOf(b[c].trim())!=-1)return!0;return!1},send_to_server:function(a,b){if("undefined"==typeof SlimStatParams.ajaxurl||"undefined"==typeof a)return!1;if("undefined"==typeof b&&(b=!0),slimstat_data_with_client_info=a+"&sw="+screen.width+"&sh="+screen.height+"&bw="+window.innerWidth+"&bh="+window.innerHeight+"&sl="+SlimStat.get_server_latency()+"&pp="+SlimStat.get_page_performance()+"&pl="+SlimStat.detect_plugins(),b&&navigator.sendBeacon)navigator.sendBeacon(SlimStatParams.ajaxurl,slimstat_data_with_client_info);else{try{window.XMLHttpRequest?request=new XMLHttpRequest:window.ActiveXObject&&(request=new ActiveXObject("Microsoft.XMLHTTP"))}catch(a){return!1}if(request)return request.open("POST",SlimStatParams.ajaxurl,!0),request.setRequestHeader("Content-type","application/x-www-form-urlencoded"),request.setRequestHeader("X-Requested-With","XMLHttpRequest"),request.send(slimstat_data_with_client_info),request.onreadystatechange=function(){4==request.readyState&&(parsed_id=parseInt(request.responseText),!isNaN(parsed_id)&&parsed_id>0&&(SlimStat._id=request.responseText))},!0}return!1},ss_track:function(a,b,c,d){if(a=a?a:window.event,b="undefined"==typeof b?0:parseInt(b),note_array=[],"undefined"==typeof d&&(d=!0),parsed_id=parseInt(SlimStat._id),isNaN(parsed_id)||parsed_id<=0)return!1;if(node="undefined"!=typeof a.target?a.target:"undefined"!=typeof a.srcElement&&a.srcElement,!node)return!1;switch(3==node.nodeType&&(node=node.parentNode),parent_node=node.parentNode,resource_url="",node.nodeName){case"FORM":"undefined"!=typeof node.action&&node.action&&(resource_url=node.action);break;case"INPUT":for(;"undefined"!=typeof parent_node&&"FORM"!=parent_node.nodeName&&"BODY"!=parent_node.nodeName;)parent_node=parent_node.parentNode;if("undefined"!=typeof parent_node.action&&parent_node.action){resource_url=parent_node.action;break}default:if("A"!=node.nodeName)for(;"undefined"!=typeof node.parentNode&&null!=node.parentNode&&"A"!=node.nodeName&&"BODY"!=node.nodeName;)node=node.parentNode;"undefined"!=typeof node.hash&&node.hash&&node.hostname==location.hostname?resource_url=node.hash:"undefined"!=typeof node.href&&(resource_url=node.href),"function"==typeof node.getAttribute&&("undefined"!=typeof node.getAttribute("title")&&node.getAttribute("title")&&note_array.push("Title:"+node.getAttribute("title")),"undefined"!=typeof node.getAttribute("id")&&node.getAttribute("id")&&note_array.push("ID:"+node.getAttribute("id")))}return pos_x=-1,pos_y=-1,position="","undefined"!=typeof a.pageX&&"undefined"!=typeof a.pageY?(pos_x=a.pageX,pos_y=a.pageY):"undefined"!=typeof a.clientX&&"undefined"!=typeof a.clientY&&"undefined"!=typeof document.body.scrollLeft&&"undefined"!=typeof document.documentElement.scrollLeft&&"undefined"!=typeof document.body.scrollTop&&"undefined"!=typeof document.documentElement.scrollTop&&(pos_x=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,pos_y=a.clientY+document.body.scrollTop+document.documentElement.scrollTop),pos_x>0&&pos_y>0&&(position=pos_x+","+pos_y),event_description=a.type,"keypress"==a.type?event_description+="; keypress:"+String.fromCharCode(parseInt(a.which)):"click"==a.type&&(event_description+="; which:"+a.which),"undefined"!=typeof c&&c&&note_array.push(c),note_string=SlimStat._base64_encode(note_array.join(", ")),requested_op="add",1==b?resource_url=resource_url.substring(resource_url.indexOf(location.hostname)+location.hostname.length):0!=b&&2!=b||(requested_op="update"),SlimStat.send_to_server("action=slimtrack&op="+requested_op+"&id="+SlimStat._id+"&ty="+b+"&ref="+SlimStat._base64_encode(document.referrer)+"&res="+SlimStat._base64_encode(resource_url)+"&pos="+position+"&des="+SlimStat._base64_encode(event_description)+"&no="+note_string,d),!0}};"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),SlimStat.add_event(window,"load",function(){all_links=document.getElementsByTagName("a");for(var a="undefined"!=typeof SlimStatParams.extensions_to_track&&SlimStatParams.extensions_to_track?SlimStatParams.extensions_to_track.split(","):[],b="undefined"!=typeof SlimStatParams.outbound_classes_rel_href_to_not_track&&SlimStatParams.outbound_classes_rel_href_to_not_track?SlimStatParams.outbound_classes_rel_href_to_not_track.split(","):[],c=0;c<all_links.length;c++){if(linktype=!all_links[c].href||all_links[c].hostname!=location.hostname&&all_links[c].href.indexOf("://")!=-1?0:2,tracking=1,b.length>0){if(1==tracking){classes_current_link="undefined"!=typeof all_links[c].className&&all_links[c].className?all_links[c].className.split(" "):[];for(var d=0;d<classes_current_link.length;d++)if(SlimStat.in_array_substring(classes_current_link[d],b)){tracking=0;break}}1==tracking&&"undefined"!=typeof all_links[c].attributes.rel&&all_links[c].attributes.rel.value&&SlimStat.in_array_substring(all_links[c].attributes.rel.value,b)&&(tracking=0),1==tracking&&"undefined"!=typeof all_links[c].href&&all_links[c].href&&SlimStat.in_array_substring(all_links[c].href,b)&&(tracking=0)}extension_current_link=all_links[c].pathname.split(/[?#]/)[0].split(".").pop().replace(/[\/\-]/g,""),2==linktype&&a.length>0&&SlimStat.in_array(extension_current_link,a)&&(tracking=1,linktype=1),all_links[c].setAttribute("data-slimstat",(linktype<<1)+tracking),SlimStat.add_event(all_links[c],"click",function(a){link_info=parseInt(this.getAttribute("data-slimstat")),isNaN(link_info)&&(link_info=0),link_info&!0&&SlimStat.ss_track(a,link_info>>1,"")})}});var slimstat_data="",use_beacon=!0;"undefined"!=typeof SlimStatParams.id&&parseInt(SlimStatParams.id)>0?slimstat_data="action=slimtrack&op=update&id="+SlimStatParams.id:"undefined"!=typeof SlimStatParams.ci&&(slimstat_data="action=slimtrack&op=add&id="+SlimStatParams.ci+"&ref="+SlimStat._base64_encode(document.referrer)+"&res="+SlimStat._base64_encode(window.location.href),use_beacon=!1),slimstat_data.length>0&&SlimStat.add_event(window,"load",function(){setTimeout(function(){SlimStat.send_to_server(slimstat_data,"")},0)});
wp-slimstat.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /*
3
- Plugin Name: Slim Stat Analytics
4
  Plugin URI: http://wordpress.org/plugins/wp-slimstat/
5
  Description: The leading web analytics plugin for WordPress
6
- Version: 4.6.3
7
  Author: Jason Crouse
8
  Author URI: http://www.wp-slimstat.com/
9
  Text Domain: wp-slimstat
@@ -15,7 +15,7 @@ if ( !empty( wp_slimstat::$settings ) ) {
15
  }
16
 
17
  class wp_slimstat {
18
- public static $version = '4.6.3';
19
  public static $settings = array();
20
  public static $options = array(); // To be removed, here just for backward compatibility
21
 
@@ -133,7 +133,6 @@ class wp_slimstat {
133
  * Ajax Tracking
134
  */
135
  public static function slimtrack_ajax() {
136
-
137
  // This function also initializes self::$data_js and removes the checksum from self::$data_js['id']
138
  self::_check_data_integrity( self::$raw_post_array );
139
 
@@ -251,7 +250,7 @@ class wp_slimstat {
251
  self::toggle_date_i18n_filters( true );
252
 
253
  // Allow third-party tools to initialize the stat array
254
- self::$stat = apply_filters('slimstat_filter_pageview_stat_init', self::$stat);
255
 
256
  // Third-party tools can decide that this pageview should not be tracked, by setting its datestamp to zero
257
  if ( empty( self::$stat ) || empty( self::$stat[ 'dt' ] ) ) {
@@ -310,11 +309,13 @@ class wp_slimstat {
310
  }
311
 
312
  // Is this referer blacklisted?
313
- foreach ( self::string_to_array( self::$settings[ 'ignore_referers' ] ) as $a_filter ) {
314
- $pattern = str_replace( array( '\*', '\!' ) , array( '(.*)', '.' ), preg_quote( $a_filter, '/' ) );
315
- if ( preg_match( "@^$pattern$@i", self::$stat[ 'referer' ] ) ) {
316
- self::$stat[ 'id' ] = -301;
317
- self::_set_error_array( sprintf( __( 'Referrer %s is blacklisted', 'wp-slimstat' ), self::$stat[ 'referer' ] ), true );
 
 
318
  return $_argument;
319
  }
320
  }
@@ -375,7 +376,8 @@ class wp_slimstat {
375
  }
376
  self::$stat[ 'resource' ] = self::get_request_uri();
377
  }
378
- else{
 
379
  self::$stat[ 'searchterms' ] = str_replace( '\\', '', $_REQUEST[ 's' ] );
380
  self::$stat[ 'referer' ] = self::get_request_uri();
381
  if ( isset( $GLOBALS['wp_query']->found_posts ) ) {
@@ -395,14 +397,14 @@ class wp_slimstat {
395
  }
396
 
397
  // Is this resource blacklisted?
398
- if ( !empty( self::$stat[ 'resource' ] ) ) {
399
- foreach ( self::string_to_array( self::$settings[ 'ignore_resources' ] ) as $a_filter ) {
400
- $pattern = str_replace( array('\*', '\!') , array('(.*)', '.'), preg_quote($a_filter, '/'));
401
- if ( preg_match( "@^$pattern$@i", self::$stat[ 'resource' ] ) ) {
402
- self::$stat['id'] = -302;
403
- self::_set_error_array( sprintf( __( 'Permalink %s is blacklisted', 'wp-slimstat' ), self::$stat[ 'resource' ] ), true );
404
- return $_argument;
405
- }
406
  }
407
  }
408
 
@@ -425,11 +427,13 @@ class wp_slimstat {
425
  }
426
 
427
  // Is this user blacklisted?
428
- foreach ( self::string_to_array( self::$settings[ 'ignore_users' ] ) as $a_filter ) {
429
- $pattern = str_replace( array( '\*', '\!' ) , array( '(.*)', '.' ), preg_quote( $a_filter, '/' ) );
430
- if ( preg_match( "~^$pattern$~i", $GLOBALS[ 'current_user' ]->data->user_login ) ) {
431
- self::$stat['id'] = -305;
432
- self::_set_error_array( sprintf( __( 'User %s is blacklisted', 'wp-slimstat' ), $GLOBALS[ 'current_user' ]->data->user_login ), true );
 
 
433
  return $_argument;
434
  }
435
  }
@@ -538,17 +542,25 @@ class wp_slimstat {
538
  }
539
 
540
  // Is this browser blacklisted?
541
- foreach ( self::string_to_array( self::$settings[ 'ignore_browsers' ] ) as $a_filter ) {
542
- $pattern = str_replace( array( '\*', '\!' ) , array( '(.*)', '.' ), preg_quote( $a_filter, '/' ) );
543
- if ( preg_match( "~^$pattern$~i", self::$browser[ 'browser' ] . '/' . self::$browser[ 'version' ] ) || preg_match( "~^$pattern$~i", self::$browser[ 'browser' ] ) || preg_match( "~^$pattern$~i", self::$browser[ 'user_agent' ] ) ) {
544
- self::$stat[ 'id' ] = -311;
545
- self::_set_error_array( sprintf( __( 'Browser %s is blacklisted', 'wp-slimstat' ), self::$browser[ 'browser' ] ), true );
 
 
546
  return $_argument;
547
  }
548
  }
549
 
550
  self::$stat = self::$stat + self::$browser;
551
 
 
 
 
 
 
 
552
  // Do we need to assign a visit_id to this user?
553
  $cookie_has_been_set = self::_set_visit_id( false );
554
 
@@ -1093,6 +1105,27 @@ class wp_slimstat {
1093
  return false;
1094
  }
1095
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1096
  public static function dtr_pton( $ip ){
1097
  if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {
1098
  $unpacked = unpack( 'A4', inet_pton( $ip ) );
@@ -1480,14 +1513,6 @@ class wp_slimstat {
1480
  * Enqueue a javascript to track users' screen resolution and other browser-based information
1481
  */
1482
  public static function wp_slimstat_enqueue_tracking_script() {
1483
- if ( self::$settings[ 'enable_cdn' ] == 'yes' ) {
1484
- $schema = is_ssl() ? 'https' : 'http';
1485
- wp_register_script( 'wp_slimstat', $schema . '://cdn.jsdelivr.net/wp/wp-slimstat/tags/' . self::$version . '/wp-slimstat.min.js', array(), null, true );
1486
- }
1487
- else{
1488
- wp_register_script('wp_slimstat', plugins_url('/wp-slimstat.min.js', __FILE__), array(), null, true);
1489
- }
1490
-
1491
  // Pass some information to Javascript
1492
  $params = array(
1493
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
@@ -1501,6 +1526,11 @@ class wp_slimstat {
1501
  }
1502
 
1503
  if ( self::$settings[ 'javascript_mode' ] != 'yes' ) {
 
 
 
 
 
1504
  if ( !empty( self::$stat[ 'id' ] ) ) {
1505
  $params[ 'id' ] = self::_get_id_with_checksum( self::$stat[ 'id' ] );
1506
  }
@@ -1509,12 +1539,26 @@ class wp_slimstat {
1509
  }
1510
  }
1511
  else {
 
 
 
 
 
 
1512
  $encoded_ci = base64_encode( serialize( self::_get_content_info() ) );
1513
  $params[ 'ci' ] = self::_get_id_with_checksum( $encoded_ci );
1514
  }
1515
 
1516
  $params = apply_filters( 'slimstat_js_params', $params );
1517
 
 
 
 
 
 
 
 
 
1518
  wp_enqueue_script( 'wp_slimstat' );
1519
  wp_localize_script( 'wp_slimstat', 'SlimStatParams', $params );
1520
  }
1
  <?php
2
  /*
3
+ Plugin Name: Slimstat Analytics
4
  Plugin URI: http://wordpress.org/plugins/wp-slimstat/
5
  Description: The leading web analytics plugin for WordPress
6
+ Version: 4.6.4
7
  Author: Jason Crouse
8
  Author URI: http://www.wp-slimstat.com/
9
  Text Domain: wp-slimstat
15
  }
16
 
17
  class wp_slimstat {
18
+ public static $version = '4.6.4';
19
  public static $settings = array();
20
  public static $options = array(); // To be removed, here just for backward compatibility
21
 
133
  * Ajax Tracking
134
  */
135
  public static function slimtrack_ajax() {
 
136
  // This function also initializes self::$data_js and removes the checksum from self::$data_js['id']
137
  self::_check_data_integrity( self::$raw_post_array );
138
 
250
  self::toggle_date_i18n_filters( true );
251
 
252
  // Allow third-party tools to initialize the stat array
253
+ self::$stat = apply_filters( 'slimstat_filter_pageview_stat_init', self::$stat );
254
 
255
  // Third-party tools can decide that this pageview should not be tracked, by setting its datestamp to zero
256
  if ( empty( self::$stat ) || empty( self::$stat[ 'dt' ] ) ) {
309
  }
310
 
311
  // Is this referer blacklisted?
312
+ if ( !empty( self::$settings[ 'ignore_referers' ] ) ) {
313
+ $return_error_code = array(
314
+ -301,
315
+ sprintf( __( 'Referrer %s is blacklisted', 'wp-slimstat' ), self::$stat[ 'referer' ] ),
316
+ true
317
+ );
318
+ if ( self::_is_blacklisted( self::$stat[ 'referer' ], self::$settings[ 'ignore_referers' ], $return_error_code ) ) {
319
  return $_argument;
320
  }
321
  }
376
  }
377
  self::$stat[ 'resource' ] = self::get_request_uri();
378
  }
379
+ else {
380
+ self::$stat[ 'resource' ] = parse_url( self::get_request_uri(), PHP_URL_PATH );
381
  self::$stat[ 'searchterms' ] = str_replace( '\\', '', $_REQUEST[ 's' ] );
382
  self::$stat[ 'referer' ] = self::get_request_uri();
383
  if ( isset( $GLOBALS['wp_query']->found_posts ) ) {
397
  }
398
 
399
  // Is this resource blacklisted?
400
+ if ( !empty( self::$settings[ 'ignore_resources' ] ) ) {
401
+ $return_error_code = array(
402
+ -302,
403
+ sprintf( __( 'Permalink %s is blacklisted', 'wp-slimstat' ), self::$stat[ 'resource' ] ),
404
+ true
405
+ );
406
+ if ( self::_is_blacklisted( self::$stat[ 'resource' ], self::$settings[ 'ignore_resources' ], $return_error_code ) ) {
407
+ return $_argument;
408
  }
409
  }
410
 
427
  }
428
 
429
  // Is this user blacklisted?
430
+ if ( !empty( self::$settings[ 'ignore_users' ] ) ) {
431
+ $return_error_code = array(
432
+ -305,
433
+ sprintf( __( 'User %s is blacklisted', 'wp-slimstat' ), $GLOBALS[ 'current_user' ]->data->user_login ),
434
+ true
435
+ );
436
+ if ( self::_is_blacklisted( $GLOBALS[ 'current_user' ]->data->user_login, self::$settings[ 'ignore_users' ], $return_error_code ) ) {
437
  return $_argument;
438
  }
439
  }
542
  }
543
 
544
  // Is this browser blacklisted?
545
+ if ( !empty( self::$settings[ 'ignore_browsers' ] ) ) {
546
+ $return_error_code = array(
547
+ -311,
548
+ sprintf( __( 'Browser %s is blacklisted', 'wp-slimstat' ), self::$browser[ 'browser' ] ),
549
+ true
550
+ );
551
+ if ( self::_is_blacklisted( array( self::$browser[ 'browser' ], self::$browser[ 'user_agent' ] ), self::$settings[ 'ignore_browsers' ], $return_error_code ) ) {
552
  return $_argument;
553
  }
554
  }
555
 
556
  self::$stat = self::$stat + self::$browser;
557
 
558
+ // This function can be called in "simulate" mode: no data will be actually saved in the database
559
+ if ( is_array( $_argument ) && isset( $_argument[ 'slimtrack_simulate' ] ) ) {
560
+ $_argument[ 'slimtrack_would_track' ] = true;
561
+ return ( $_argument );
562
+ }
563
+
564
  // Do we need to assign a visit_id to this user?
565
  $cookie_has_been_set = self::_set_visit_id( false );
566
 
1105
  return false;
1106
  }
1107
 
1108
+ protected static function _is_blacklisted( $_needles = array(), $_haystack_string = '', $_return_error_code = array( 0, '', false ) ) {
1109
+ foreach ( self::string_to_array( $_haystack_string ) as $a_item ) {
1110
+ $pattern = str_replace( array( '\*', '\!' ) , array( '(.*)', '.' ), preg_quote( $a_item, '/' ) );
1111
+
1112
+ if ( !is_array( $_needles ) ) {
1113
+ $_needles = array( $_needles );
1114
+ }
1115
+
1116
+ foreach ( $_needles as $a_needle ) {
1117
+ if ( preg_match( "@^$pattern$@i", $a_needle ) ) {
1118
+
1119
+ self::$stat[ 'id' ] = $_return_error_code[ 0 ];
1120
+ self::_set_error_array( $_return_error_code[ 1 ], $_return_error_code[ 2 ] );
1121
+ return true;
1122
+ }
1123
+ }
1124
+ }
1125
+
1126
+ return false;
1127
+ }
1128
+
1129
  public static function dtr_pton( $ip ){
1130
  if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {
1131
  $unpacked = unpack( 'A4', inet_pton( $ip ) );
1513
  * Enqueue a javascript to track users' screen resolution and other browser-based information
1514
  */
1515
  public static function wp_slimstat_enqueue_tracking_script() {
 
 
 
 
 
 
 
 
1516
  // Pass some information to Javascript
1517
  $params = array(
1518
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
1526
  }
1527
 
1528
  if ( self::$settings[ 'javascript_mode' ] != 'yes' ) {
1529
+ // Do not enqueue the tracker if this page view was not tracked for some reason
1530
+ if ( intval( self::$stat[ 'id' ] ) < 0 ) {
1531
+ return false;
1532
+ }
1533
+
1534
  if ( !empty( self::$stat[ 'id' ] ) ) {
1535
  $params[ 'id' ] = self::_get_id_with_checksum( self::$stat[ 'id' ] );
1536
  }
1539
  }
1540
  }
1541
  else {
1542
+ // Check filters and blacklists to see if this page should be tracked
1543
+ $simulate = self::slimtrack( array( 'slimtrack_simulate' => true ) );
1544
+ if ( empty( $simulate[ 'slimtrack_would_track' ] ) ) {
1545
+ return false;
1546
+ }
1547
+
1548
  $encoded_ci = base64_encode( serialize( self::_get_content_info() ) );
1549
  $params[ 'ci' ] = self::_get_id_with_checksum( $encoded_ci );
1550
  }
1551
 
1552
  $params = apply_filters( 'slimstat_js_params', $params );
1553
 
1554
+ if ( self::$settings[ 'enable_cdn' ] == 'yes' ) {
1555
+ $schema = is_ssl() ? 'https' : 'http';
1556
+ wp_register_script( 'wp_slimstat', $schema . '://cdn.jsdelivr.net/wp/wp-slimstat/tags/' . self::$version . '/wp-slimstat.min.js', array(), null, true );
1557
+ }
1558
+ else{
1559
+ wp_register_script('wp_slimstat', plugins_url('/wp-slimstat.min.js', __FILE__), array(), null, true);
1560
+ }
1561
+
1562
  wp_enqueue_script( 'wp_slimstat' );
1563
  wp_localize_script( 'wp_slimstat', 'SlimStatParams', $params );
1564
  }