PluginProbe
Patchstack – WordPress & Plugins Security / 2.2.6
Patchstack – WordPress & Plugins Security v2.2.6
2.3.7 trunk 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.2 2.1.20 2.1.21 2.1.22 2.1.23 2.1.24 2.1.25 2.1.3 2.1.4 2.1.5 2.1.6 All 49 releases
← All changes | includes/admin/general.php +15 -18 2.1.142.2.6 View file →
@@ -20,15 +20,15 @@
20 20 public function __construct( $core ) {
21 21 parent::__construct( $core );
22 22
23 23 // Add admin and network notices.
24 - add_action( 'admin_notices', array( $this, 'file_error_notice' ) );
25 - add_action( 'network_admin_notices', array( $this, 'file_error_notice' ) );
24 + add_action( 'admin_notices', [ $this, 'file_error_notice' ] );
25 + add_action( 'network_admin_notices', [ $this, 'file_error_notice' ] );
26 26
27 - add_action( 'wp_loaded', array( $this, 'update_rules' ) );
28 - add_action( 'update_option_siteurl', array( $this, 'update_option_url' ), 10, 2 );
29 - add_action( 'admin_init', array( $this, 'alter_ips' ) );
30 - add_action( 'admin_init', array( $this, 'enable_settings' ) );
27 + add_action( 'wp_loaded', [ $this, 'update_rules' ] );
28 + add_action( 'update_option_siteurl', [ $this, 'update_option_url' ], 10, 2 );
29 + add_action( 'admin_init', [ $this, 'alter_ips' ] );
30 + add_action( 'admin_init', [ $this, 'enable_settings' ] );
31 31
32 32 // If the firewall or whitelist rules do not exist, attempt to pull fresh.
33 33 $token = get_option( 'patchstack_api_token', false );
34 34 if ( ! empty( $token ) && ( get_option( 'patchstack_firewall_rules', '' ) == '' || get_option( 'patchstack_whitelist_keys_rules' ) == '' ) && get_option( 'patchstack_license_free', 0 ) != 1 ) {
@@ -47,9 +47,9 @@
47 47 return;
48 48 }
49 49
50 50 // Check root .htaccess file and data folder writability.
51 - $files = array();
51 + $files = [];
52 52 if ( file_exists( ABSPATH . '.htaccess' ) && ! wp_is_writable( ABSPATH . '.htaccess' ) ) {
53 53 array_push( $files, ABSPATH . '.htaccess' );
54 54 }
55 55
@@ -85,13 +85,10 @@
85 85 $token = $this->plugin->api->get_access_token();
86 86
87 87 // Update the firewall status.
88 88 if ( ! empty( $token ) ) {
89 - $this->plugin->api->update_firewall_status( array( 'status' => $this->get_option( 'patchstack_basic_firewall' ) == 1 ) );
89 + $this->plugin->api->update_firewall_status( [ 'status' => $this->get_option( 'patchstack_basic_firewall' ) == 1 ] );
90 90 }
91 -
92 - // Update the custom whitelist.
93 - update_option( 'patchstack_custom_whitelist_rules', $this->get_option( 'patchstack_whitelist' ) );
94 91 }
95 92 }
96 93
97 94 /**
@@ -103,9 +100,9 @@
103 100 * @return void
104 101 */
105 102 public function update_option_url( $old_value, $new_value ) {
106 103 if ( $old_value != $new_value ) {
107 - $this->plugin->api->update_url( array( 'plugin_url' => $new_value ) );
104 + $this->plugin->api->update_url( [ 'plugin_url' => $new_value ] );
108 105 }
109 106 }
110 107
111 108 /**
@@ -114,9 +111,9 @@
114 111 *
115 112 * @return void
116 113 */
117 114 public function alter_ips() {
118 - if ( ! isset( $_GET['action'], $_GET['PatchstackNonce'] ) || ! wp_verify_nonce( $_GET['PatchstackNonce'], 'patchstack-nonce-alter-ips' ) || ! current_user_can( 'administrator' ) || ! in_array( $_GET['action'], array( 'patchstack_unblock', 'patchstack_unblock_whitelist', 'patchstack_whitelist' ) ) ) {
115 + if ( ! isset( $_GET['action'], $_GET['PatchstackNonce'] ) || ! wp_verify_nonce( $_GET['PatchstackNonce'], 'patchstack-nonce-alter-ips' ) || ! current_user_can( 'administrator' ) || ! in_array( $_GET['action'], [ 'patchstack_unblock', 'patchstack_unblock_whitelist', 'patchstack_whitelist' ] ) ) {
119 116 return;
120 117 }
121 118
122 119 global $wpdb;
@@ -124,15 +121,15 @@
124 121 // Unblock the IP; delete the logs of the IP.
125 122 if ( $_GET['action'] == 'patchstack_unblock' && isset( $_GET['id'] ) && ctype_digit( $_GET['id'] ) ) {
126 123 // First get the IP address to unblock.
127 124 $result = $wpdb->get_results(
128 - $wpdb->prepare( 'SELECT ip FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE id = %d', array( (int) $_GET['id'] ) )
125 + $wpdb->prepare( 'SELECT ip FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE id = %d', [ (int) $_GET['id'] ] )
129 126 );
130 127
131 128 // Unblock the IP address.
132 129 if ( isset( $result[0], $result[0]->ip ) ) {
133 130 $wpdb->query(
134 - $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE ip = %s', array( $result[0]->ip ) )
131 + $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE ip = %s', [ $result[0]->ip ] )
135 132 );
136 133 }
137 134 }
138 135
@@ -139,9 +136,9 @@
139 136 // Unblock and whitelist the IP.
140 137 if ( $_GET['action'] == 'patchstack_unblock_whitelist' && isset( $_GET['id'] ) && ctype_digit( $_GET['id'] ) ) {
141 138 // First get the IP address to whitelist.
142 139 $result = $wpdb->get_results(
143 - $wpdb->prepare( 'SELECT ip FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE id = %d', array( (int) $_GET['id'] ) )
140 + $wpdb->prepare( 'SELECT ip FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE id = %d', [ (int) $_GET['id'] ] )
144 141 );
145 142
146 143 // Whitelist and unblock the IP address.
147 144 if ( isset( $result[0], $result[0]->ip ) && filter_var( $result[0]->ip, FILTER_VALIDATE_IP ) ) {
@@ -146,9 +143,9 @@
146 143 // Whitelist and unblock the IP address.
147 144 if ( isset( $result[0], $result[0]->ip ) && filter_var( $result[0]->ip, FILTER_VALIDATE_IP ) ) {
148 145 update_option( 'patchstack_login_whitelist', $this->get_option( 'patchstack_login_whitelist', '' ) . "\n" . $result[0]->ip );
149 146 $wpdb->query(
150 - $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE ip = %s', array( $result[0]->ip ) )
147 + $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE ip = %s', [ $result[0]->ip ] )
151 148 );
152 149 }
153 150 }
154 151
@@ -175,8 +172,8 @@
175 172 // Turn it on.
176 173 update_option( 'patchstack_show_settings', 1 );
177 174
178 175 // Redirect the user back to the license page.
179 - wp_safe_redirect( admin_url( 'admin.php?page=' . $this->plugin->name . '&tab=license' ) );
176 + wp_safe_redirect( admin_url( 'admin.php?page=' . $this->plugin->name ) );
180 177 exit;
181 178 }
182 179 }