| @@ -23,9 +23,9 @@ | ||
| 23 | 23 | if ( $this->get_option( 'patchstack_license_free', 0 ) == 1 ) { |
| 24 | 24 | return; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - add_action( 'updated_option', array( $this, 'update_option_extras' ), 10, 3 ); | |
| 27 | + add_action( 'updated_option', [ $this, 'update_option_extras' ], 10, 3 ); | |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * If option is updated, write to .htaccess file. |
| @@ -35,9 +35,9 @@ | ||
| 35 | 35 | * @param mixed $value |
| 36 | 36 | * @return void |
| 37 | 37 | */ |
| 38 | 38 | public function update_option_extras( $option_name, $old_value, $value ) { |
| 39 | - if ( in_array( $option_name, array( 'patchstack_prevent_default_file_access', 'patchstack_basic_firewall', 'patchstack_pingback_protection', 'patchstack_block_debug_log_access', 'patchstack_block_fake_bots', 'patchstack_index_views', 'patchstack_trace_and_track', 'patchstack_proxy_comment_posting', 'patchstack_image_hotlinking', 'patchstack_firewall_custom_rules' ) ) ) { | |
| 39 | + if ( in_array( $option_name, [ 'patchstack_prevent_default_file_access', 'patchstack_basic_firewall', 'patchstack_pingback_protection', 'patchstack_block_debug_log_access', 'patchstack_block_fake_bots', 'patchstack_index_views', 'patchstack_trace_and_track', 'patchstack_proxy_comment_posting', 'patchstack_image_hotlinking', 'patchstack_firewall_custom_rules' ] ) ) { | |
| 40 | 40 | $this->plugin->rules->post_firewall_rules(); |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| @@ -46,10 +46,10 @@ | ||
| 46 | 46 | * |
| 47 | 47 | * @return array |
| 48 | 48 | */ |
| 49 | 49 | public function get_firewall_rule_settings() { |
| 50 | - $settings = array(); | |
| 51 | - $options = array( 'patchstack_prevent_default_file_access', 'patchstack_basic_firewall', 'patchstack_block_debug_log_access', 'patchstack_block_fake_bots', 'patchstack_index_views', 'patchstack_proxy_comment_posting', 'patchstack_image_hotlinking', 'patchstack_basicscanblock' ); | |
| 50 | + $settings = []; | |
| 51 | + $options = [ 'patchstack_prevent_default_file_access', 'patchstack_basic_firewall', 'patchstack_block_debug_log_access', 'patchstack_block_fake_bots', 'patchstack_index_views', 'patchstack_proxy_comment_posting', 'patchstack_image_hotlinking', 'patchstack_basicscanblock' ]; | |
| 52 | 52 | foreach ( $options as $option ) { |
| 53 | 53 | if ( get_site_option( $option ) ) { |
| 54 | 54 | $settings[] = ( $option == 'patchstack_basicscanblock' ? 'webarx_wpscan_block' : str_replace( 'patchstack_', 'webarx_', $option ) ); |
| 55 | 55 | } |
| @@ -65,9 +65,9 @@ | ||
| 65 | 65 | */ |
| 66 | 66 | public function firewall() { |
| 67 | 67 | // Get the firewall state. |
| 68 | 68 | $sum_of_firewall = 0; |
| 69 | - foreach ( array( 'patchstack_prevent_default_file_access', 'patchstack_basic_firewall', 'patchstack_pingback_protection', 'patchstack_block_debug_log_access', 'patchstack_block_fake_bots', 'patchstack_index_views', 'patchstack_trace_and_track', 'patchstack_proxy_comment_posting', 'patchstack_image_hotlinking' ) as $option ) { | |
| 69 | + foreach ( [ 'patchstack_prevent_default_file_access', 'patchstack_basic_firewall', 'patchstack_pingback_protection', 'patchstack_block_debug_log_access', 'patchstack_block_fake_bots', 'patchstack_index_views', 'patchstack_trace_and_track', 'patchstack_proxy_comment_posting', 'patchstack_image_hotlinking' ] as $option ) { | |
| 70 | 70 | $value = get_site_option( $option, 0 ); |
| 71 | 71 | $sum_of_firewall += empty( $value ) ? 0 : 1; |
| 72 | 72 | } |
| 73 | 73 | |
| @@ -72,9 +72,9 @@ | ||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Update the options. |
| 75 | 75 | $onoff = $sum_of_firewall > 1 ? 0 : 1; |
| 76 | - foreach ( array( 'patchstack_prevent_default_file_access', 'patchstack_basic_firewall', 'patchstack_block_debug_log_access', 'patchstack_index_views', 'patchstack_proxy_comment_posting' ) as $option ) { | |
| 76 | + foreach ( [ 'patchstack_prevent_default_file_access', 'patchstack_basic_firewall', 'patchstack_block_debug_log_access', 'patchstack_index_views', 'patchstack_proxy_comment_posting' ] as $option ) { | |
| 77 | 77 | update_site_option( $option, $onoff ); |
| 78 | 78 | } |
| 79 | 79 | update_site_option( 'patchstack_block_fake_bots', 0 ); |
| 80 | 80 | update_site_option( 'patchstack_image_hotlinking', 0 ); |
| @@ -162,10 +162,10 @@ | ||
| 162 | 162 | * |
| 163 | 163 | * @return boolean |
| 164 | 164 | */ |
| 165 | 165 | public function is_server_supported() { |
| 166 | - $server = strtolower( filter_var( $_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING ) ); | |
| 167 | - foreach ( array( 'apache', 'nginx', 'litespeed' ) as $webserver ) { | |
| 166 | + $server = strtolower( $_SERVER['SERVER_SOFTWARE'] ); | |
| 167 | + foreach ( [ 'apache', 'nginx', 'litespeed' ] as $webserver ) { | |
| 168 | 168 | if ( strstr( $server, $webserver ) ) { |
| 169 | 169 | return true; |
| 170 | 170 | } |
| 171 | 171 | } |