PluginProbe
Patchstack – WordPress & Plugins Security / 2.3.1
Patchstack – WordPress & Plugins Security v2.3.1
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
patchstack / includes / mu-plugin-helper.php

mu-plugin-helper.php in Patchstack – WordPress & Plugins Security 2.3.1, at includes/mu-plugin-helper.php

70 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Based on the current path and domain name, determine which option index we should use.
5 *
6 * @param array $options
7 * @return integer
8 */
9 function patchstack_get_active_domain( $options )
10 {
11 // Essential server variables must be set.
12 if ( ! isset( $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'] ) ) {
13 return $options[0];
14 }
15
16 // Give priority to home_url, then site_url.
17 foreach ( [ 'home_url', 'site_url'] as $base ) {
18 // Attempt to match against substring match.
19 foreach ( $options as $option ) {
20 // Only needed if the site is under a different folder path.
21 if ( strpos( $option[$base], '/' ) === false ) {
22 continue;
23 }
24
25 // Make sure there's a substring match.
26 if ( substr( $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 0, strlen( $option[$base] ) ) == $option[$base] ) {
27 return $option;
28 }
29 }
30
31 // Attempt to match against just the hostname.
32 foreach ( $options as $option ) {
33 if ( strpos( $option[$base], '/' ) === false && $_SERVER['HTTP_HOST'] == $option[$base]) {
34 return $option;
35 }
36 }
37 }
38
39 // Return first options set by default.
40 return $options[0];
41 }
42
43 /**
44 * Given the option values, determine if the WAF should run.
45 *
46 * @param array $options
47 * @return boolean
48 */
49 function patchstack_get_should_run( $options )
50 {
51 if ( $options['patchstack_license_activated'] == 0 ) {
52 return false;
53 }
54
55 if ( $options['patchstack_basic_firewall'] != 1 ) {
56 return false;
57 }
58
59 if ( $options['patchstack_license_free'] == 1 ) {
60 return false;
61 }
62
63 $rules = base64_decode( $options['patchstack_firewall_rules_v3_ap'] );
64 if ( $rules == '' || $rules == '[]' ) {
65 return false;
66 }
67
68 return true;
69 }
70