404 to 301 - Version 2.0.4

Version Description

(26/08/2015) =

Bug Fixes - Fixed an issue where error log table is not being created.

Download this release

Release Info

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

Code changes from version 2.0.2 to 2.0.4

404-to-301.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: 404 to 301
4
  * Plugin URI: http://iscode.co/product/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.0.2
7
  * Author: Joel James
8
  * Author URI: http://iscode.co/
9
  * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
@@ -49,10 +49,10 @@ if(!defined('I4T3_LOGS_PAGE')) {
49
  define( 'I4T3_LOGS_PAGE', admin_url( 'admin.php?page=i4t3-logs' ) );
50
  }
51
  if(!defined('I4T3_DB_VERSION')) {
52
- define( 'I4T3_DB_VERSION', '2' );
53
  }
54
  if(!defined('I4T3_VERSION')) {
55
- define( 'I4T3_VERSION', '2.0.2' );
56
  }
57
  // Set who all can access 404 settings. You can change this if you want to give others access.
58
  if(!defined('I4T3_ADMIN_PERMISSION')) {
3
  * Plugin Name: 404 to 301
4
  * Plugin URI: http://iscode.co/product/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.0.4
7
  * Author: Joel James
8
  * Author URI: http://iscode.co/
9
  * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
49
  define( 'I4T3_LOGS_PAGE', admin_url( 'admin.php?page=i4t3-logs' ) );
50
  }
51
  if(!defined('I4T3_DB_VERSION')) {
52
+ define( 'I4T3_DB_VERSION', '3' );
53
  }
54
  if(!defined('I4T3_VERSION')) {
55
+ define( 'I4T3_VERSION', '2.0.4' );
56
  }
57
  // Set who all can access 404 settings. You can change this if you want to give others access.
58
  if(!defined('I4T3_ADMIN_PERMISSION')) {
admin/class-404-to-301-logs.php CHANGED
@@ -90,15 +90,15 @@ class _404_To_301_Logs extends WP_List_Table_404 {
90
  $wpdb->hide_errors();
91
 
92
  // Per page filter
93
- $per_page = apply_filters( 'i4t3_log_list_per_page', 10 );
94
 
95
  $current_page = $this->get_pagenum();
96
- $limit = ( $current_page-1 )* $per_page;
97
-
98
- // If no sort, default to title
99
- $orderby = ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'date';
100
  // If no order, default to asc
101
- $order = ( isset($_GET['order'] ) ) ? $_GET['order'] : 'ASC';
102
 
103
  $log_data = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS id as ID,date,url,ref,ip,ua FROM $this->table ORDER BY $orderby $order LIMIT %d,%d", array( $limit, $per_page) ), ARRAY_A );
104
 
@@ -106,10 +106,36 @@ class _404_To_301_Logs extends WP_List_Table_404 {
106
  foreach ($log_data as $key) {
107
  $error_data[] = $key;
108
  }
109
-
110
  return $error_data;
111
  }
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  /**
114
  * Empty record text.
115
  *
@@ -303,7 +329,7 @@ class _404_To_301_Logs extends WP_List_Table_404 {
303
  $current_page = $this->get_pagenum();
304
 
305
  // Per page filter
306
- $per_page = apply_filters( 'i4t3_log_list_per_page', 10 );
307
 
308
  $total = $wpdb->get_var( "SELECT count(id) as ID FROM $this->table" );
309
 
90
  $wpdb->hide_errors();
91
 
92
  // Per page filter
93
+ $per_page = apply_filters( 'i4t3_log_list_per_page', 2 );
94
 
95
  $current_page = $this->get_pagenum();
96
+ $limit = ( $current_page-1 )* $per_page;
97
+
98
+ // If no sort, default to title
99
+ $orderby = ( isset( $_GET['orderby'] ) ) ? $this->i4t3_get_sort_column_filtered( $_GET['orderby'] ) : 'date';
100
  // If no order, default to asc
101
+ $order = ( isset($_GET['order'] ) && 'desc' == $_GET['order'] ) ? 'DESC' : 'ASC';
102
 
103
  $log_data = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS id as ID,date,url,ref,ip,ua FROM $this->table ORDER BY $orderby $order LIMIT %d,%d", array( $limit, $per_page) ), ARRAY_A );
104
 
106
  foreach ($log_data as $key) {
107
  $error_data[] = $key;
108
  }
109
+
110
  return $error_data;
111
  }
112
 
113
+ /**
114
+ * Filter the sorting parameters.
115
+ *
116
+ * This is used to filter the sorting parameters in order
117
+ * to prevent SQL injection atacks. We will accept only our
118
+ * required values. Else we will assign a default value.
119
+ *
120
+ * @since 2.0.3
121
+ * @author Joel James.
122
+ * @var $column Value from url.
123
+ * @var $filtered_column Value aftet filtering.
124
+ * @return string $filtered_column.
125
+ */
126
+ public function i4t3_get_sort_column_filtered( $column ) {
127
+
128
+ $allowed_columns = array( 'date','url','ref','ip' );
129
+
130
+ if( in_array( $column, $allowed_columns ) ) {
131
+ $filtered_column = esc_sql( $column );
132
+ } else {
133
+ $filtered_column = 'date';
134
+ }
135
+ return $filtered_column;
136
+ }
137
+
138
+
139
  /**
140
  * Empty record text.
141
  *
329
  $current_page = $this->get_pagenum();
330
 
331
  // Per page filter
332
+ $per_page = apply_filters( 'i4t3_log_list_per_page', 2 );
333
 
334
  $total = $wpdb->get_var( "SELECT count(id) as ID FROM $this->table" );
335
 
includes/class-404-to-301-activator.php CHANGED
@@ -63,7 +63,7 @@ class _404_To_301_Activator {
63
  // remember, two spaces after PRIMARY KEY otherwise WP borks
64
  $installed_version = get_option('i4t3_db_version');
65
 
66
- if( I4T3_DB_VERSION != $installed_version ) {
67
 
68
  global $wpdb;
69
  $table = $wpdb->prefix . "404_to_301";
63
  // remember, two spaces after PRIMARY KEY otherwise WP borks
64
  $installed_version = get_option('i4t3_db_version');
65
 
66
+ if( !$installed_version || ( I4T3_DB_VERSION != $installed_version ) ) {
67
 
68
  global $wpdb;
69
  $table = $wpdb->prefix . "404_to_301";
includes/class-404-to-301.php CHANGED
@@ -67,7 +67,7 @@ class _404_To_301 {
67
  public function __construct() {
68
 
69
  $this->plugin_name = '404-to-301';
70
- $this->version = '2.0.2';
71
  $this->table = $GLOBALS['wpdb']->prefix . '404_to_301';
72
  $this->load_dependencies();
73
  $this->define_admin_hooks();
67
  public function __construct() {
68
 
69
  $this->plugin_name = '404-to-301';
70
+ $this->version = '2.0.4';
71
  $this->table = $GLOBALS['wpdb']->prefix . '404_to_301';
72
  $this->load_dependencies();
73
  $this->define_admin_hooks();
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === 404 to 301 ===
2
  Contributors: joelcj91,is_code
3
- Tags: 404, 301, 302, 307, not found, 404 redirect, 404 to 301, 301 redirect, seo redirect, error redirect, 404 seo
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
5
  Requires at least: 3.0
6
- Tested up to: 4.2.4
7
- Stable tag: 2.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -110,6 +110,17 @@ Bug reports for 404 to 301 are always welcome. [Report here](https://iscode.co/s
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
 
 
 
 
 
113
  = 2.0.2 (16/08/2015) =
114
  **Bug Fixes**
115
 
@@ -160,5 +171,5 @@ Bug reports for 404 to 301 are always welcome. [Report here](https://iscode.co/s
160
 
161
  == Upgrade Notice ==
162
 
163
- = 2.0.2 =
164
- * Fixed issues with https.
1
  === 404 to 301 ===
2
  Contributors: joelcj91,is_code
3
+ Tags: 404, 301, 302, 307, not found, 404 redirect, 404 to 301, 301 redirect, seo redirect, error redirect, 404 seo, custom 404 page
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
5
  Requires at least: 3.0
6
+ Tested up to: 4.3
7
+ Stable tag: 2.0.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
110
 
111
  == Changelog ==
112
 
113
+ = 2.0.4 (26/08/2015) =
114
+
115
+ **Bug Fixes**
116
+ - Fixed an issue where error log table is not being created.
117
+
118
+ = 2.0.3 (21/08/2015) =
119
+
120
+ **Bug Fixes**
121
+
122
+ - Fixed a serious issue which may cause SQL injection attack.
123
+
124
  = 2.0.2 (16/08/2015) =
125
  **Bug Fixes**
126
 
171
 
172
  == Upgrade Notice ==
173
 
174
+ = 2.0.4 =
175
+ * Fixed an issue where error log table is not being created.