Statify - Version 1.6.3

Version Description

Download this release

Release Info

Developer Bueltge
Plugin Icon 128x128 Statify
Version 1.6.3
Comparing to
See all releases

Code changes from version 1.6.2 to 1.6.3

Files changed (3) hide show
  1. inc/class-statify-frontend.php +25 -16
  2. readme.txt +13 -1
  3. statify.php +1 -1
inc/class-statify-frontend.php CHANGED
@@ -37,14 +37,20 @@ class Statify_Frontend extends Statify {
37
  $target = urldecode( get_query_var( 'statify_target' ) );
38
  $referrer = urldecode( get_query_var( 'statify_referrer' ) );
39
  } elseif ( ! $use_snippet ) {
40
- $target = filter_input( INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL );
 
 
 
41
  if ( is_null( $target ) || false === $target ) {
42
  $target = '/';
43
  } else {
44
  $target = wp_unslash( $target );
45
  }
46
 
47
- $referrer = filter_input( INPUT_SERVER, 'HTTP_REFERER', FILTER_SANITIZE_URL );
 
 
 
48
  if ( is_null( $referrer ) || false === $referrer ) {
49
  $referrer = '';
50
  }
@@ -59,7 +65,7 @@ class Statify_Frontend extends Statify {
59
 
60
  /* Check whether tracking should be skipped for this view. */
61
  if ( self::_skip_tracking() ) {
62
- return false;
63
  }
64
 
65
  /* Global vars */
@@ -134,7 +140,7 @@ class Statify_Frontend extends Statify {
134
  * Rules to skip the tracking
135
  *
136
  * @since 1.2.6
137
- * @version 2016-12-21
138
  *
139
  * @hook boolean statify__skip_tracking
140
  * @see https://wordpress.org/plugins/statify/
@@ -153,7 +159,10 @@ class Statify_Frontend extends Statify {
153
  }
154
 
155
  // Skip tracking via User Agent.
156
- $user_agent = filter_input( INPUT_SERVER, 'HTTP_USER_AGENT', FILTER_SANITIZE_STRING );
 
 
 
157
  if ( is_null( $user_agent )
158
  || false === $user_agent
159
  || ! preg_match( '/(?:Windows|Macintosh|Linux|iPhone|iPad)/', $user_agent ) ) {
@@ -169,7 +178,7 @@ class Statify_Frontend extends Statify {
169
  /**
170
  * Rules to detect internal calls to skip tracking and not print code snippet.
171
  *
172
- * @since 1.7.0
173
  *
174
  * @return boolean $skip_hook TRUE if NO tracking is desired
175
  */
@@ -181,10 +190,10 @@ class Statify_Frontend extends Statify {
181
  * Compare the referrer url to the blacklist data.
182
  * De/activate this feature via settings in the Dashboard widget.
183
  *
184
- * @since 2016-12-21
185
- * @version 2017-01-10
186
  *
187
- * @return bool
188
  */
189
  private static function check_referrer() {
190
 
@@ -193,25 +202,25 @@ class Statify_Frontend extends Statify {
193
  return false;
194
  }
195
 
196
- $referrer = filter_input( INPUT_SERVER, 'HTTP_REFERER', FILTER_SANITIZE_URL );
 
 
 
197
  if ( ! is_null( $referrer ) && false !== $referrer ) {
198
  $referrer = wp_parse_url( $referrer, PHP_URL_HOST );
199
- } else {
200
- $referrer = '';
201
- }
202
-
203
- if ( empty( $referrer ) ) {
204
- return true;
205
  }
206
 
 
207
  if ( is_array( $referrer ) && isset( $referrer['host'] ) ) {
208
  $referrer = $referrer['host'];
209
  }
210
 
 
211
  if ( ! is_string( $referrer ) ) {
212
  return false;
213
  }
214
 
 
215
  $blacklist = self::get_blacklist_keys();
216
  foreach ( $blacklist as $item ) {
217
  if ( strpos( $referrer, $item ) !== false ) {
37
  $target = urldecode( get_query_var( 'statify_target' ) );
38
  $referrer = urldecode( get_query_var( 'statify_referrer' ) );
39
  } elseif ( ! $use_snippet ) {
40
+ $target = filter_var(
41
+ ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '/' ),
42
+ FILTER_SANITIZE_URL
43
+ );
44
  if ( is_null( $target ) || false === $target ) {
45
  $target = '/';
46
  } else {
47
  $target = wp_unslash( $target );
48
  }
49
 
50
+ $referrer = filter_var(
51
+ ( isset( $_SERVER['HTTP_REFERER'] ) ? wp_unslash( $_SERVER['HTTP_REFERER'] ) : '' ),
52
+ FILTER_SANITIZE_URL
53
+ );
54
  if ( is_null( $referrer ) || false === $referrer ) {
55
  $referrer = '';
56
  }
65
 
66
  /* Check whether tracking should be skipped for this view. */
67
  if ( self::_skip_tracking() ) {
68
+ return self::_jump_out( $is_snippet );
69
  }
70
 
71
  /* Global vars */
140
  * Rules to skip the tracking
141
  *
142
  * @since 1.2.6
143
+ * @version 1.6.3
144
  *
145
  * @hook boolean statify__skip_tracking
146
  * @see https://wordpress.org/plugins/statify/
159
  }
160
 
161
  // Skip tracking via User Agent.
162
+ $user_agent = filter_var(
163
+ ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) : '' ),
164
+ FILTER_SANITIZE_STRING
165
+ );
166
  if ( is_null( $user_agent )
167
  || false === $user_agent
168
  || ! preg_match( '/(?:Windows|Macintosh|Linux|iPhone|iPad)/', $user_agent ) ) {
178
  /**
179
  * Rules to detect internal calls to skip tracking and not print code snippet.
180
  *
181
+ * @since 1.6.1
182
  *
183
  * @return boolean $skip_hook TRUE if NO tracking is desired
184
  */
190
  * Compare the referrer url to the blacklist data.
191
  * De/activate this feature via settings in the Dashboard widget.
192
  *
193
+ * @since 1.5.0
194
+ * @version 1.6.3
195
  *
196
+ * @return boolean TRUE of referrer matches blacklist entry and should thus be excluded.
197
  */
198
  private static function check_referrer() {
199
 
202
  return false;
203
  }
204
 
205
+ $referrer = filter_var(
206
+ ( isset( $_SERVER['HTTP_REFERER'] ) ? wp_unslash( $_SERVER['HTTP_REFERER'] ) : '' ),
207
+ FILTER_SANITIZE_URL
208
+ );
209
  if ( ! is_null( $referrer ) && false !== $referrer ) {
210
  $referrer = wp_parse_url( $referrer, PHP_URL_HOST );
 
 
 
 
 
 
211
  }
212
 
213
+ // Fallback for wp_parse_url() returning array instead of host only.
214
  if ( is_array( $referrer ) && isset( $referrer['host'] ) ) {
215
  $referrer = $referrer['host'];
216
  }
217
 
218
+ // Return false if there still is no referrer to checj.
219
  if ( ! is_string( $referrer ) ) {
220
  return false;
221
  }
222
 
223
+ // Finally compare referrer against the blacklist.
224
  $blacklist = self::get_blacklist_keys();
225
  foreach ( $blacklist as $item ) {
226
  if ( strpos( $referrer, $item ) !== false ) {
readme.txt CHANGED
@@ -5,7 +5,7 @@
5
  * Requires at least: 4.7
6
  * Tested up to: 4.9
7
  * Requires PHP: 5.6
8
- * Stable tag: 1.6.2
9
  * License: GPLv3 or later
10
  * License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -115,6 +115,11 @@ has to be added to the theme's `functions.php`. The condition has modified such
115
  ## Changelog ##
116
  You can find the full changelog in [our GitHub repository](https://github.com/pluginkollektiv/statify/blob/master/CHANGELOG.md).
117
 
 
 
 
 
 
118
  ### 1.6.2
119
  * Fix compatibility issues with JavaScript optimization plugins
120
  * Fix tracking issue if JavaScript tracking is disabled
@@ -138,6 +143,13 @@ For the complete changelog, check out our [GitHub repository](https://github.com
138
 
139
  ## Upgrade Notice ##
140
 
 
 
 
 
 
 
 
141
  ### 1.6.1 ###
142
  This bugfix release is recommended for all users.
143
 
5
  * Requires at least: 4.7
6
  * Tested up to: 4.9
7
  * Requires PHP: 5.6
8
+ * Stable tag: 1.6.3
9
  * License: GPLv3 or later
10
  * License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
115
  ## Changelog ##
116
  You can find the full changelog in [our GitHub repository](https://github.com/pluginkollektiv/statify/blob/master/CHANGELOG.md).
117
 
118
+ ### 1.6.3
119
+ * Fix compatibility issue with some PHP implementations not populating `INPUT_SERVER`
120
+ * Fix failing blacklist check for empty referrers
121
+ * JS snippet call properly breaks page generation when tracking is skipped
122
+
123
  ### 1.6.2
124
  * Fix compatibility issues with JavaScript optimization plugins
125
  * Fix tracking issue if JavaScript tracking is disabled
143
 
144
  ## Upgrade Notice ##
145
 
146
+ ### 1.6.3 ###
147
+ This bugfix release is recommended for all users.
148
+ It fixes completely broken tracking with some PHP implementations. Sorry for that, we might owe you a couple of visitors.
149
+
150
+ ### 1.6.2 ###
151
+ This bugfix release is recommended for all users.
152
+
153
  ### 1.6.1 ###
154
  This bugfix release is recommended for all users.
155
 
statify.php CHANGED
@@ -7,7 +7,7 @@
7
  * Author URI: https://pluginkollektiv.org
8
  * Plugin URI: https://wordpress.org/plugins/statify/
9
  * License: GPLv3 or later
10
- * Version: 1.6.2
11
  *
12
  * @package WordPress
13
  */
7
  * Author URI: https://pluginkollektiv.org
8
  * Plugin URI: https://wordpress.org/plugins/statify/
9
  * License: GPLv3 or later
10
+ * Version: 1.6.3
11
  *
12
  * @package WordPress
13
  */