Slimstat Analytics - Version 4.5.2

Version Description

  • [Note] Would you like to spread the word and tell your friends how much you love Slimstat? Now you have one more reason to do that: win a $50 discount on our online store. Yes, you read that right: write a review highlighting some of the features you love in Slimstat, and we will send you a special code to take $50 off your add-on purchase on our website. The more reviews you write, the more coupons you can get. So, what are you waiting for? Contact our support team with the URL of where the review has been posted, and take advantage of this limited time offer today!
  • [Fix] A fatal error was being experienced by users whose Browscap Library installation was corrupted (missing cache).
  • [Fix] More checks have been added to the source code to prevent Fatal Error issues in case the filesystem permissions are too restrictive for Slimstat. Also, we are now storing the "last modified date" in the database, instead of relying on "touch"-ing files and accessing the mtime there.
  • [Fix] A bug was preventing referrers from being properly recorded when handling external web pages (static tracking code).
  • [Fix] The date widget in the Filter Bar was not working when tracking admin pages (thank you, Colin).
Download this release

Release Info

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

Code changes from version 4.5.1 to 4.5.2

admin/config/index.php CHANGED
@@ -107,7 +107,7 @@ $settings = array(
107
  'enable_outbound_tracking' => array( 'description' => __( 'Track Outbound Clicks', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __('Track when your visitors click on link to external websites. This option required Spy Mode to be enabled.','wp-slimstat') ),
108
  'track_internal_links' => array( 'description' => __( 'Track Internal Clicks', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( "Collect mouse coordinates and other information for clicks on internal links. Recommended if you're using our heatmap add-on. By default, this information is only collected for external links.", 'wp-slimstat' ) ),
109
  'ignore_outbound_classes_rel_href' => array( 'description' => __( 'No Callback', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Track the event but do not invoke the callback function on links marked with one of these class names, <em>rel</em> attribute or whose <em>href</em> attribute contains one of these strings. Useful to prevent conflicts with lightbox and similar libraries.", 'wp-slimstat' ) ),
110
- 'do_not_track_outbound_classes_rel_href' => array( 'description' => __( 'Do Not Track', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Slimstat will ignore links marked with one of these class names, <em>rel</em> attributes or whose <em>href</em> attribute contains one of these strings.", 'wp-slimstat' ) ),
111
  'track_same_domain_referers' => array( 'description' => __( 'Same-Domain Referrers', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( 'By default, when the domain of the referrer for a given page view is the same as the current site, that information is not tracked to save space in the database. However, if you are running a multisite network with subfolders, you might need to track same-domain referrers from one site to another, as they are technically "separate" websites.', 'wp-slimstat' ) ),
112
 
113
  'advanced_tracker_header' => array( 'description' => __( 'Advanced Options', 'wp-slimstat' ), 'type' => 'section_header' ),
@@ -127,10 +127,8 @@ $settings = array(
127
  };
128
  /* ]]&gt; */
129
  &lt;/script&gt;
130
- &lt;script type="text/javascript" src="http://cdn.jsdelivr.net/wp/wp-slimstat/trunk/wp-slimstat.js"&gt;&lt;/script&gt;', 'use_tag_list' => false ),
131
- 'external_domains' => array('description' => __('Allow Domains','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("If you are getting an error saying that no 'Access-Control-Allow-Origin' header is present on the requested resource, when using the external tracking code here above, list the domains (complete with scheme) you would like to allow. For example: <code>http://my.domain.ext</code> (no trailing slash). Please see <a href='http://www.w3.org/TR/cors/#security' target='_blank'>this W3 resource</a> for more information on the security implications of allowing CORS requests.",'wp-slimstat')),
132
- //'advanced_misc_header' => array('description' => __('Miscellaneous','wp-slimstat'), 'type' => 'section_header'),
133
- //'enable_ads_network' => array('description' => __('Enable UAN','wp-slimstat'), 'type' => 'toggle', 'long_description' => __("Send anonymous data about user agents to our server for analysis. This allows us to contribute to the <a href='http://browscap.org/' target='_blank'>BrowsCap opensource project</a>, and improve the accuracy of Slimstat's browser detection functionality. It also enables our transparent ads network. No worries, your site will not be affected in any way.",'wp-slimstat'))
134
  )
135
  ),
136
 
107
  'enable_outbound_tracking' => array( 'description' => __( 'Track Outbound Clicks', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __('Track when your visitors click on link to external websites. This option required Spy Mode to be enabled.','wp-slimstat') ),
108
  'track_internal_links' => array( 'description' => __( 'Track Internal Clicks', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( "Collect mouse coordinates and other information for clicks on internal links. Recommended if you're using our heatmap add-on. By default, this information is only collected for external links.", 'wp-slimstat' ) ),
109
  'ignore_outbound_classes_rel_href' => array( 'description' => __( 'No Callback', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Track the event but do not invoke the callback function on links marked with one of these class names, <em>rel</em> attribute or whose <em>href</em> attribute contains one of these strings. Useful to prevent conflicts with lightbox and similar libraries.", 'wp-slimstat' ) ),
110
+ 'do_not_track_outbound_classes_rel_href' => array( 'description' => __( 'Do Not Track', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Slimstat will ignore links marked with one of these class names, <em>rel</em> attributes or whose <em>href</em> attribute contains one of these strings. Please keep in mind that the class <code>noslimstat</code> is also used to avoid tracking interactive links throughout the reports. If you remove it from this list, some features might not work as expected.", 'wp-slimstat' ) ),
111
  'track_same_domain_referers' => array( 'description' => __( 'Same-Domain Referrers', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( 'By default, when the domain of the referrer for a given page view is the same as the current site, that information is not tracked to save space in the database. However, if you are running a multisite network with subfolders, you might need to track same-domain referrers from one site to another, as they are technically "separate" websites.', 'wp-slimstat' ) ),
112
 
113
  'advanced_tracker_header' => array( 'description' => __( 'Advanced Options', 'wp-slimstat' ), 'type' => 'section_header' ),
127
  };
128
  /* ]]&gt; */
129
  &lt;/script&gt;
130
+ &lt;script type="text/javascript" src="http://cdn.jsdelivr.net/wp/wp-slimstat/trunk/wp-slimstat.min.js"&gt;&lt;/script&gt;', 'use_tag_list' => false ),
131
+ 'external_domains' => array('description' => __('Allow Domains','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("If you are getting an error saying that no 'Access-Control-Allow-Origin' header is present on the requested resource, when using the external tracking code here above, list the domains (complete with scheme) you would like to allow. For example: <code>http://my.domain.ext</code> (no trailing slash). Please see <a href='http://www.w3.org/TR/cors/#security' target='_blank'>this W3 resource</a> for more information on the security implications of allowing CORS requests.",'wp-slimstat'))
 
 
132
  )
133
  ),
134
 
admin/config/maintenance.php CHANGED
@@ -320,7 +320,7 @@ $slim_browsers_exists =wp_slimstat::$wpdb->get_col( "SHOW TABLES LIKE '{$GLOBALS
320
  <td><?php
321
  echo $details_wp_slim_tables[0]['Engine'];
322
  if (!empty($have_innodb) && $have_innodb[0]['Value'] == 'YES' && $details_wp_slim_tables[0]['Engine'] == 'MyISAM'){
323
- echo ' [<a href="'.wp_slimstat_admin::$config_url.$current_tab.'&amp;action=switch-engine">'.__('switch to InnoDB','wp-slimstat').'</a>]';
324
  }
325
  ?></td>
326
  </tr>
320
  <td><?php
321
  echo $details_wp_slim_tables[0]['Engine'];
322
  if (!empty($have_innodb) && $have_innodb[0]['Value'] == 'YES' && $details_wp_slim_tables[0]['Engine'] == 'MyISAM'){
323
+ echo ' [<a class="noslimstat" href="'.wp_slimstat_admin::$config_url.$current_tab.'&amp;action=switch-engine">'.__('switch to InnoDB','wp-slimstat').'</a>]';
324
  }
325
  ?></td>
326
  </tr>
admin/view/addons.php CHANGED
@@ -37,7 +37,7 @@ if ( !is_array( $list_addons ) ) {
37
  <?php
38
  if (empty($_GET['force_refresh'])){
39
  echo ' ';
40
- printf(__('This list is refreshed once daily: <a href="%s&amp;force_refresh=true">click here</a> to clear the cache.','wp-slimstat'), $_SERVER['REQUEST_URI']);
41
  }
42
 
43
  if ( !empty( $error_message ) ) {
37
  <?php
38
  if (empty($_GET['force_refresh'])){
39
  echo ' ';
40
+ printf(__('This list is refreshed once daily: <a href="%s&amp;force_refresh=true" class="noslimstat">click here</a> to clear the cache.','wp-slimstat'), $_SERVER['REQUEST_URI']);
41
  }
42
 
43
  if ( !empty( $error_message ) ) {
admin/view/index.php CHANGED
@@ -32,13 +32,13 @@
32
 
33
  $saved_filters = get_option('slimstat_filters', array());
34
  if (!empty($saved_filters)){
35
- echo '<a href="#" id="slimstat-load-saved-filters" class="button-secondary" title="Saved Filters">'.__('Load','wp-slimstat').'</a>';
36
  }
37
  ?>
38
  </fieldset><!-- slimstat-filters -->
39
 
40
  <fieldset id="slimstat-date-filters" class="wp-ui-highlight">
41
- <a href="#"><?php
42
  if (!empty(wp_slimstat_db::$filters_normalized['date']['hour']) || !empty(wp_slimstat_db::$filters_normalized['date']['interval_hours'])){
43
  echo gmdate( wp_slimstat::$settings[ 'date_format' ] . ' ' . wp_slimstat::$settings[ 'time_format' ], wp_slimstat_db::$filters_normalized['utime']['start']).' - ';
44
  $end_format = (date('Ymd', wp_slimstat_db::$filters_normalized['utime']['start']) != date('Ymd', wp_slimstat_db::$filters_normalized['utime']['end']))?wp_slimstat::$settings[ 'date_format' ] . ' ' . wp_slimstat::$settings[ 'time_format' ] : wp_slimstat::$settings[ 'time_format' ];
@@ -118,15 +118,15 @@
118
  </form>
119
  <?php
120
  if ( !file_exists( wp_slimstat::$maxmind_path ) && ( empty( wp_slimstat::$settings[ 'no_maxmind_warning' ] ) || wp_slimstat::$settings[ 'no_maxmind_warning' ] != 'yes' ) ) {
121
- wp_slimstat_admin::show_alert_message( sprintf( __( "<a href='%s'>Install MaxMind's GeoLite DB</a> to determine your visitors' country of origin.", 'wp-slimstat' ), self::$config_url . '6#wp-slimstat-external-data-files' ) . '<a id="slimstat-hide-geolite-notice" class="slimstat-font-cancel slimstat-float-right" title="Hide this notice" href="#"></a>', 'wp-ui-text-notification below-h2' );
122
  }
123
 
124
  if ( !file_exists( slim_browser::$browscap_autoload_path ) && ( empty( wp_slimstat::$settings[ 'no_browscap_warning' ] ) || wp_slimstat::$settings[ 'no_browscap_warning' ] != 'yes' ) ) {
125
- wp_slimstat_admin::show_alert_message( sprintf( __( "Install the Browscap <a href='%s'>User Agent Database</a> to accurately determine your visitors' browser and operating system.", 'wp-slimstat' ), self::$config_url . '6#wp-slimstat-external-data-files' ) . '<a id="slimstat-hide-browscap-notice" class="slimstat-font-cancel slimstat-float-right" title="Hide this notice" href="#"></a>', 'wp-ui-text-notification below-h2' );
126
  }
127
 
128
  if ( wp_slimstat::$advanced_cache_exists && ( empty( wp_slimstat::$settings[ 'no_caching_warning' ] ) || wp_slimstat::$settings[ 'no_caching_warning' ] != 'yes' ) && ( empty( wp_slimstat::$settings[ 'javascript_mode' ] ) || wp_slimstat::$settings[ 'javascript_mode' ] != 'yes' ) ) {
129
- wp_slimstat_admin::show_alert_message( sprintf( __( "A caching plugin has been detected on your website. Please <a href='%s' target='_blank'>make sure to configure</a> Slimstat Analytics accordingly, to get accurate information.", 'wp-slimstat' ), 'https://slimstat.freshdesk.com/support/solutions/articles/5000528524-i-am-using-w3-total-cache-or-wp-super-cache-hypercache-etc-and-it-looks-like-slimstat-is-not-tra' ) . '<a id="slimstat-hide-caching-notice" class="slimstat-font-cancel slimstat-float-right" title="Hide this notice" href="#"></a>', 'wp-ui-text-notification below-h2' );
130
  }
131
 
132
  $filters_html = wp_slimstat_reports::get_filters_html( wp_slimstat_db::$filters_normalized[ 'columns' ] );
32
 
33
  $saved_filters = get_option('slimstat_filters', array());
34
  if (!empty($saved_filters)){
35
+ echo '<a href="#" id="slimstat-load-saved-filters" class="button-secondary noslimstat" title="Saved Filters">'.__('Load','wp-slimstat').'</a>';
36
  }
37
  ?>
38
  </fieldset><!-- slimstat-filters -->
39
 
40
  <fieldset id="slimstat-date-filters" class="wp-ui-highlight">
41
+ <a href="#" class="noslimstat"><?php
42
  if (!empty(wp_slimstat_db::$filters_normalized['date']['hour']) || !empty(wp_slimstat_db::$filters_normalized['date']['interval_hours'])){
43
  echo gmdate( wp_slimstat::$settings[ 'date_format' ] . ' ' . wp_slimstat::$settings[ 'time_format' ], wp_slimstat_db::$filters_normalized['utime']['start']).' - ';
44
  $end_format = (date('Ymd', wp_slimstat_db::$filters_normalized['utime']['start']) != date('Ymd', wp_slimstat_db::$filters_normalized['utime']['end']))?wp_slimstat::$settings[ 'date_format' ] . ' ' . wp_slimstat::$settings[ 'time_format' ] : wp_slimstat::$settings[ 'time_format' ];
118
  </form>
119
  <?php
120
  if ( !file_exists( wp_slimstat::$maxmind_path ) && ( empty( wp_slimstat::$settings[ 'no_maxmind_warning' ] ) || wp_slimstat::$settings[ 'no_maxmind_warning' ] != 'yes' ) ) {
121
+ wp_slimstat_admin::show_alert_message( sprintf( __( "<a href='%s' class='noslimstat'>Install MaxMind's GeoLite DB</a> to determine your visitors' country of origin.", 'wp-slimstat' ), self::$config_url . '6#wp-slimstat-external-data-files' ) . '<a id="slimstat-hide-geolite-notice" class="slimstat-font-cancel slimstat-float-right noslimstat" title="Hide this notice" href="#"></a>', 'wp-ui-text-notification below-h2' );
122
  }
123
 
124
  if ( !file_exists( slim_browser::$browscap_autoload_path ) && ( empty( wp_slimstat::$settings[ 'no_browscap_warning' ] ) || wp_slimstat::$settings[ 'no_browscap_warning' ] != 'yes' ) ) {
125
+ wp_slimstat_admin::show_alert_message( sprintf( __( "Install the Browscap <a href='%s' class='noslimstat'>User Agent Database</a> to accurately determine your visitors' browser and operating system.", 'wp-slimstat' ), self::$config_url . '6#wp-slimstat-external-data-files' ) . '<a id="slimstat-hide-browscap-notice" class="slimstat-font-cancel slimstat-float-right noslimstat" title="Hide this notice" href="#"></a>', 'wp-ui-text-notification below-h2' );
126
  }
127
 
128
  if ( wp_slimstat::$advanced_cache_exists && ( empty( wp_slimstat::$settings[ 'no_caching_warning' ] ) || wp_slimstat::$settings[ 'no_caching_warning' ] != 'yes' ) && ( empty( wp_slimstat::$settings[ 'javascript_mode' ] ) || wp_slimstat::$settings[ 'javascript_mode' ] != 'yes' ) ) {
129
+ wp_slimstat_admin::show_alert_message( sprintf( __( "A caching plugin has been detected on your website. Please <a href='%s' target='_blank' class='noslimstat'>make sure to configure</a> Slimstat Analytics accordingly, to get accurate information.", 'wp-slimstat' ), 'https://slimstat.freshdesk.com/support/solutions/articles/5000528524-i-am-using-w3-total-cache-or-wp-super-cache-hypercache-etc-and-it-looks-like-slimstat-is-not-tra' ) . '<a id="slimstat-hide-caching-notice" class="slimstat-font-cancel slimstat-float-right" title="Hide this notice" href="#"></a>', 'wp-ui-text-notification below-h2' );
130
  }
131
 
132
  $filters_html = wp_slimstat_reports::get_filters_html( wp_slimstat_db::$filters_normalized[ 'columns' ] );
admin/view/wp-slimstat-reports.php CHANGED
@@ -1907,10 +1907,10 @@ class wp_slimstat_reports {
1907
  }
1908
  }
1909
  if (!empty($filters_html)){
1910
- $filters_html = "<ul class='slimstat-filter-list'>$filters_html</ul><a href='#' id='slimstat-save-filter' class='slimstat-filter-action-button button-secondary' data-filter-array='".htmlentities(serialize($_filters_array), ENT_QUOTES, 'UTF-8')."'>".__('Save','wp-slimstat')."</a>";
1911
  }
1912
  if(count($filters_dropdown) > 1){
1913
- $filters_html .= '<a href="'.self::fs_url().'" id="slimstat-remove-all-filters" class="button-secondary slimstat-filter-action-button">'.__('Reset All','wp-slimstat').'</a>';
1914
  }
1915
  $filters_html .= '';
1916
 
1907
  }
1908
  }
1909
  if (!empty($filters_html)){
1910
+ $filters_html = "<ul class='slimstat-filter-list'>$filters_html</ul><a href='#' id='slimstat-save-filter' class='slimstat-filter-action-button button-secondary noslimstat' data-filter-array='".htmlentities(serialize($_filters_array), ENT_QUOTES, 'UTF-8')."'>".__('Save','wp-slimstat')."</a>";
1911
  }
1912
  if(count($filters_dropdown) > 1){
1913
+ $filters_html .= '<a href="'.self::fs_url().'" id="slimstat-remove-all-filters" class="button-secondary slimstat-filter-action-button noslimstat">'.__('Reset All','wp-slimstat').'</a>';
1914
  }
1915
  $filters_html .= '';
1916
 
admin/wp-slimstat-admin.php CHANGED
@@ -11,7 +11,7 @@ class wp_slimstat_admin {
11
  * Init -- Sets things up.
12
  */
13
  public static function init() {
14
- self::$admin_notice = "Just a quick reminder to take advantage of our current promotion before it ends on January 15: use coupon <code>HAPPY2017</code> to get 17% off any <a href='https://www.wp-slimstat.com/addons/' target='_blank'>add-on purchase on our online store</a>! Prices will go up at the end of this month, so don't wait until the last minute.";
15
  self::$admin_notice .= '<br/><br/><a id="slimstat-hide-admin-notice" href="#" class="button-secondary">Got it, thanks</a>';
16
 
17
  // Load language files
11
  * Init -- Sets things up.
12
  */
13
  public static function init() {
14
+ self::$admin_notice = "Would you like to spread the word and tell your friends how much you love Slimstat? Now you have one more reason to do that: win a $50 discount on our online store. Yes, you read that right: write a review highlighting some of the features you love in Slimstat, and we will send you a special code to take $50 off your add-on purchase on our website. The more reviews you write, the more coupons you can get. So, what are you waiting for? Contact our support team with the URL of where the review has been posted, and take advantage of this limited time offer today!";
15
  self::$admin_notice .= '<br/><br/><a id="slimstat-hide-admin-notice" href="#" class="button-secondary">Got it, thanks</a>';
16
 
17
  // Load language files
browscap/browser.php CHANGED
@@ -51,6 +51,10 @@ class slim_browser {
51
  return array( 1, __( 'This library requires at least PHP 5.5. Please ask your service provider to upgrade your server accordingly.', 'wp-slimstat' ) );
52
  }
53
 
 
 
 
 
54
  // Create the folder, if it doesn't exist
55
  if ( !file_exists( wp_slimstat::$upload_dir ) ) {
56
  @mkdir( wp_slimstat::$upload_dir );
@@ -60,47 +64,79 @@ class slim_browser {
60
  $local_version = 0;
61
  $browscap_zip = wp_slimstat::$upload_dir . '/browscap-db.zip';
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  // Check for updates once a week ( 604800 seconds ), if $_force_download is not true
64
- if ( false === $_force_download && false !== ( $file_stat = @stat( self::$browscap_autoload_path ) ) && ( date( 'U' ) - $file_stat[ 'mtime' ] > 604800 ) && false !== ( $handle = @fopen( self::$browscap_autoload_path, "rb" ) ) ) {
65
 
66
  // Find the version of the local data file
67
- while ( ( $buffer = fgets( $handle, 4096 ) ) !== false ) {
 
 
 
 
 
 
 
68
  if ( strpos( $buffer, 'source_version' ) !== false ) {
69
- $local_version = filter_var( $buffer, FILTER_SANITIZE_NUMBER_INT );
70
  break;
71
  }
72
  }
73
 
 
 
74
  // Now check the version number on the server
75
- $remote_version = wp_remote_retrieve_body( wp_remote_get( 'http://s3.amazonaws.com/browscap/autoload.txt' ) );
76
- if ( intval( $local_version ) != intval( $remote_version ) ) {
77
- $download_remote_file = true;
78
- }
79
- else {
80
- @touch( self::$browscap_autoload_path );
81
  }
82
 
83
- fclose( $handle );
 
84
  }
85
 
86
  // Download the most recent version of our pre-processed Browscap database
87
  if ( $download_remote_file ) {
88
  $response = wp_safe_remote_get( 'http://s3.amazonaws.com/browscap/browscap-db.zip', array( 'timeout' => 300, 'stream' => true, 'filename' => $browscap_zip ) );
89
-
90
  if ( !file_exists( $browscap_zip ) ) {
91
- return array( 2, __( 'There was an error saving the Browscap data file on your server. Please check your folder permissions.', 'wp-slimstat' ) );
 
 
92
  }
93
 
94
  if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
95
  @unlink( $browscap_zip );
96
- return array( 3, __( 'There was an error downloading the Browscap data file from our server. Please try again later.', 'wp-slimstat' ) );
 
 
97
  }
98
 
99
  // Init the filesystem API
100
  require_once( ABSPATH . '/wp-admin/includes/file.php' );
101
  if ( !function_exists( 'wp_filesystem' ) ) {
102
  @unlink( $browscap_zip );
103
- return array( 4, __( 'Could not initialize the WP Filesystem API. Please check your folder permissions and PHP configuration.', 'wp-slimstat' ) );
 
 
104
  }
105
 
106
  wp_filesystem();
@@ -113,7 +149,10 @@ class slim_browser {
113
 
114
  if ( !$unzip_done || !file_exists( self::$browscap_autoload_path ) ) {
115
  @unlink( $browscap_zip );
116
- return array( 5, __( 'There was an error uncompressing the Browscap data file on your server. Please check your folder permissions and PHP configuration.', 'wp-slimstat' ) );
 
 
 
117
  }
118
 
119
  if ( file_exists( $browscap_zip ) ) {
51
  return array( 1, __( 'This library requires at least PHP 5.5. Please ask your service provider to upgrade your server accordingly.', 'wp-slimstat' ) );
52
  }
53
 
54
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
55
+ return array( 2, __( 'No updates are performed during AJAX requests.', 'wp-slimstat' ) );
56
+ }
57
+
58
  // Create the folder, if it doesn't exist
59
  if ( !file_exists( wp_slimstat::$upload_dir ) ) {
60
  @mkdir( wp_slimstat::$upload_dir );
64
  $local_version = 0;
65
  $browscap_zip = wp_slimstat::$upload_dir . '/browscap-db.zip';
66
 
67
+ if ( empty( wp_slimstat::$settings[ 'browscap_last_modified' ] ) ) {
68
+
69
+ if ( file_exists( self::$browscap_autoload_path ) ) {
70
+ $file_stat = @stat( self::$browscap_autoload_path );
71
+ if ( false !== $file_stat ) {
72
+ wp_slimstat::$settings[ 'browscap_last_modified' ] = intval( $file_stat[ 'mtime' ] );
73
+ }
74
+ }
75
+
76
+ // The variable could be still empty if the file does not exist or stat failed to open it
77
+ if ( empty( wp_slimstat::$settings[ 'browscap_last_modified' ] ) ) {
78
+ wp_slimstat::$settings[ 'browscap_last_modified' ] = date( 'U' );
79
+ }
80
+
81
+ wp_slimstat::slimstat_save_options();
82
+ }
83
+
84
  // Check for updates once a week ( 604800 seconds ), if $_force_download is not true
85
+ if ( ( false === $_force_download ) && ( date( 'U' ) - wp_slimstat::$settings[ 'browscap_last_modified' ] > 604800 ) && file_exists( self::$browscap_autoload_path ) ) {
86
 
87
  // Find the version of the local data file
88
+ $handle = @fopen( self::$browscap_autoload_path, "rb" );
89
+ if ( false === $handle ) {
90
+ wp_slimstat::$settings[ 'browscap_last_modified' ] = date( 'U' );
91
+ wp_slimstat::slimstat_save_options();
92
+ return array( 3, __( 'The Browscap Library could not be opened on your filesystem. Please check your server permissions and try again.', 'wp-slimstat' ) );
93
+ }
94
+
95
+ while ( ( $buffer = @fgets( $handle, 4096 ) ) !== false ) {
96
  if ( strpos( $buffer, 'source_version' ) !== false ) {
97
+ $local_version = intval( filter_var( $buffer, FILTER_SANITIZE_NUMBER_INT ) );
98
  break;
99
  }
100
  }
101
 
102
+ fclose( $handle );
103
+
104
  // Now check the version number on the server
105
+ $response = wp_remote_get( 'http://s3.amazonaws.com/browscap/autoload.txt' );
106
+ if ( !is_array( $response ) || is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
107
+ wp_slimstat::$settings[ 'browscap_last_modified' ] = date( 'U' );
108
+ wp_slimstat::slimstat_save_options();
109
+ return array( 4, __( 'There was an error checking the remote library version. Please try again later.', 'wp-slimstat' ) );
 
110
  }
111
 
112
+ $remote_version = intval( wp_remote_retrieve_body( $response ) );
113
+ $download_remote_file = ( $local_version < $remote_version );
114
  }
115
 
116
  // Download the most recent version of our pre-processed Browscap database
117
  if ( $download_remote_file ) {
118
  $response = wp_safe_remote_get( 'http://s3.amazonaws.com/browscap/browscap-db.zip', array( 'timeout' => 300, 'stream' => true, 'filename' => $browscap_zip ) );
119
+
120
  if ( !file_exists( $browscap_zip ) ) {
121
+ wp_slimstat::$settings[ 'browscap_last_modified' ] = date( 'U' );
122
+ wp_slimstat::slimstat_save_options();
123
+ return array( 5, __( 'There was an error saving the Browscap data file on your server. Please check your folder permissions.', 'wp-slimstat' ) );
124
  }
125
 
126
  if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
127
  @unlink( $browscap_zip );
128
+ wp_slimstat::$settings[ 'browscap_last_modified' ] = date( 'U' );
129
+ wp_slimstat::slimstat_save_options();
130
+ return array( 6, __( 'There was an error downloading the Browscap data file from our server. Please try again later.', 'wp-slimstat' ) );
131
  }
132
 
133
  // Init the filesystem API
134
  require_once( ABSPATH . '/wp-admin/includes/file.php' );
135
  if ( !function_exists( 'wp_filesystem' ) ) {
136
  @unlink( $browscap_zip );
137
+ wp_slimstat::$settings[ 'browscap_last_modified' ] = date( 'U' );
138
+ wp_slimstat::slimstat_save_options();
139
+ return array( 7, __( 'Could not initialize the WP Filesystem API. Please check your folder permissions and PHP configuration.', 'wp-slimstat' ) );
140
  }
141
 
142
  wp_filesystem();
149
 
150
  if ( !$unzip_done || !file_exists( self::$browscap_autoload_path ) ) {
151
  @unlink( $browscap_zip );
152
+ $GLOBALS[ 'wp_filesystem' ]->rmdir( dirname( self::$browscap_autoload_path ) . '/', true );
153
+ wp_slimstat::$settings[ 'browscap_last_modified' ] = date( 'U' );
154
+ wp_slimstat::slimstat_save_options();
155
+ return array( 8, __( 'There was an error uncompressing the Browscap data file on your server. Please check your folder permissions and PHP configuration.', 'wp-slimstat' ) );
156
  }
157
 
158
  if ( file_exists( $browscap_zip ) ) {
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: analytics, statistics, counter, tracking, reports, wassup, geolocation, on
5
  Text Domain: wp-slimstat
6
  Requires at least: 3.8
7
  Tested up to: 4.7
8
- Stable tag: 4.5.1
9
 
10
  == Description ==
11
  [youtube https://www.youtube.com/watch?v=zEKP9yC8x6g]
@@ -72,6 +72,13 @@ Our knowledge base is available on our [support center](http://docs.wp-slimstat.
72
 
73
  == Changelog ==
74
 
 
 
 
 
 
 
 
75
  = 4.5.1 =
76
  * [New] Slimstat is now looking for custom HTTP headers like [CF-Connecting-IP](https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-CloudFlare-handle-HTTP-Request-headers-) to determine your visitors' originating IP address when your website is behind reverse proxies like CloudFlare.
77
  * [New] By default, when the domain of the referrer for a given page view is the same as the current site, that information is not tracked to save space in the database. However, if you are running a multisite network with subfolders, you might need to track same-domain referrers from one site to another, as they are technically "separate" websites. A new option under Settings > Tracker was added to handle this situation (thank you, [chenryahts](https://wordpress.org/support/topic/referer-not-recorded-from-other-sites-in-same-multisite/)).
5
  Text Domain: wp-slimstat
6
  Requires at least: 3.8
7
  Tested up to: 4.7
8
+ Stable tag: 4.5.2
9
 
10
  == Description ==
11
  [youtube https://www.youtube.com/watch?v=zEKP9yC8x6g]
72
 
73
  == Changelog ==
74
 
75
+ = 4.5.2 =
76
+ * [Note] Would you like to spread the word and tell your friends how much you love Slimstat? Now you have one more reason to do that: win a $50 discount on our online store. Yes, you read that right: write a review highlighting some of the features you love in Slimstat, and we will send you a special code to take $50 off your add-on purchase on our website. The more reviews you write, the more coupons you can get. So, what are you waiting for? Contact our support team with the URL of where the review has been posted, and take advantage of this limited time offer today!
77
+ * [Fix] A fatal error was being experienced by users whose Browscap Library installation was corrupted (missing cache).
78
+ * [Fix] More checks have been added to the source code to prevent Fatal Error issues in case the filesystem permissions are too restrictive for Slimstat. Also, we are now storing the "last modified date" in the database, instead of relying on "touch"-ing files and accessing the mtime there.
79
+ * [Fix] A bug was preventing referrers from being properly recorded when handling external web pages (static tracking code).
80
+ * [Fix] The date widget in the Filter Bar was not working when tracking admin pages (thank you, Colin).
81
+
82
  = 4.5.1 =
83
  * [New] Slimstat is now looking for custom HTTP headers like [CF-Connecting-IP](https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-CloudFlare-handle-HTTP-Request-headers-) to determine your visitors' originating IP address when your website is behind reverse proxies like CloudFlare.
84
  * [New] By default, when the domain of the referrer for a given page view is the same as the current site, that information is not tracked to save space in the database. However, if you are running a multisite network with subfolders, you might need to track same-domain referrers from one site to another, as they are technically "separate" websites. A new option under Settings > Tracker was added to handle this situation (thank you, [chenryahts](https://wordpress.org/support/topic/referer-not-recorded-from-other-sites-in-same-multisite/)).
wp-slimstat.php CHANGED
@@ -3,7 +3,7 @@
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.5.1
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.5.1';
19
  public static $settings = array();
20
  public static $options = array(); // To be removed, here just for backward compatibility
21
 
@@ -331,12 +331,9 @@ class wp_slimstat {
331
  self::$stat = self::$stat + $content_info;
332
 
333
  // We want to record both hits and searches (performed through the site search form)
334
- if ( self::$stat[ 'content_type' ] == 'external' ) {
335
- self::$stat[ 'resource' ] = $_SERVER[ 'HTTP_REFERER' ];
336
- self::$stat[ 'referer' ] = '';
337
- }
338
- else if ( is_array( self::$data_js ) && isset( self::$data_js[ 'res' ] ) ) {
339
- $parsed_permalink = parse_url( base64_decode( self::$data_js[ 'res' ] ) );
340
  if ( !empty( $referer ) ) {
341
  self::$stat[ 'searchterms' ] = self::_get_search_terms( $referer );
342
  }
@@ -344,10 +341,14 @@ class wp_slimstat {
344
  // Was this an internal search?
345
  if ( empty( self::$stat[ 'searchterms' ] ) ) {
346
  self::$stat[ 'searchterms' ] = self::_get_search_terms( $parsed_permalink );
347
-
348
  }
349
 
350
- self::$stat['resource'] = !is_array( $parsed_permalink ) ? self::$data_js[ 'res' ] : urldecode( $parsed_permalink[ 'path' ] ) . ( !empty( $parsed_permalink[ 'query' ] ) ? '?' . urldecode( $parsed_permalink[ 'query' ] ) : '' );
 
 
 
 
 
351
  }
352
  elseif ( empty( $_REQUEST[ 's' ] ) ) {
353
  if ( !empty( $referer ) ) {
@@ -1037,6 +1038,7 @@ class wp_slimstat {
1037
 
1038
  // Make sure that the control code is valid
1039
  self::$data_js[ 'id' ] = self::_separate_id_from_checksum( self::$data_js[ 'id' ] );
 
1040
  if ( self::$data_js['id'] === false ) {
1041
  do_action( 'slimstat_track_exit_103' );
1042
  self::$stat[ 'id' ] = -101;
@@ -1343,6 +1345,7 @@ class wp_slimstat {
1343
  'version' => self::$version,
1344
  'secret' => wp_hash( uniqid( time(), true ) ),
1345
  'show_admin_notice' => 0,
 
1346
 
1347
  // General
1348
  'is_tracking' => 'yes',
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.5.2
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.5.2';
19
  public static $settings = array();
20
  public static $options = array(); // To be removed, here just for backward compatibility
21
 
331
  self::$stat = self::$stat + $content_info;
332
 
333
  // We want to record both hits and searches (performed through the site search form)
334
+ if ( is_array( self::$data_js ) && isset( self::$data_js[ 'res' ] ) ) {
335
+ $decoded_permalink = base64_decode( self::$data_js[ 'res' ] );
336
+ $parsed_permalink = parse_url( $decoded_permalink );
 
 
 
337
  if ( !empty( $referer ) ) {
338
  self::$stat[ 'searchterms' ] = self::_get_search_terms( $referer );
339
  }
341
  // Was this an internal search?
342
  if ( empty( self::$stat[ 'searchterms' ] ) ) {
343
  self::$stat[ 'searchterms' ] = self::_get_search_terms( $parsed_permalink );
 
344
  }
345
 
346
+ if ( self::$stat[ 'content_type' ] == 'external' ) {
347
+ self::$stat['resource'] = $decoded_permalink;
348
+ }
349
+ else {
350
+ self::$stat['resource'] = !is_array( $parsed_permalink ) ? __( 'Malformed URL', 'wp-slimstat' ) : urldecode( $parsed_permalink[ 'path' ] ) . ( !empty( $parsed_permalink[ 'query' ] ) ? '?' . urldecode( $parsed_permalink[ 'query' ] ) : '' );
351
+ }
352
  }
353
  elseif ( empty( $_REQUEST[ 's' ] ) ) {
354
  if ( !empty( $referer ) ) {
1038
 
1039
  // Make sure that the control code is valid
1040
  self::$data_js[ 'id' ] = self::_separate_id_from_checksum( self::$data_js[ 'id' ] );
1041
+
1042
  if ( self::$data_js['id'] === false ) {
1043
  do_action( 'slimstat_track_exit_103' );
1044
  self::$stat[ 'id' ] = -101;
1345
  'version' => self::$version,
1346
  'secret' => wp_hash( uniqid( time(), true ) ),
1347
  'show_admin_notice' => 0,
1348
+ 'browscap_last_modified' => 0,
1349
 
1350
  // General
1351
  'is_tracking' => 'yes',