| 1 |
<?php |
| 2 |
|
| 3 |
// Do not run if already executed. |
| 4 |
if ( defined( 'PS_FW_MU_RAN' ) ) { |
| 5 |
return; |
| 6 |
} |
| 7 |
|
| 8 |
// Attempt to load config file. |
| 9 |
if ( ! file_exists( __DIR__ . '/../../../pslogs/config.php' ) || ! file_exists ( __DIR__ . '/../lib/patchstack/vendor/autoload.php' ) ) { |
| 10 |
return; |
| 11 |
} |
| 12 |
|
| 13 |
// Define path to pslogs. |
| 14 |
define( 'PS_LOGS', __DIR__ . '/../../../pslogs/' ); |
| 15 |
define( 'PS_PATH', __DIR__ . '/../' ); |
| 16 |
|
| 17 |
// Parse options. |
| 18 |
$ps_options = @include( PS_LOGS . 'config.php' ); |
| 19 |
if ( ! is_array( $ps_options ) || count( $ps_options ) === 0 ) { |
| 20 |
return; |
| 21 |
} |
| 22 |
|
| 23 |
// Include the helper functions. |
| 24 |
require_once __DIR__ . '/mu-plugin-helper.php'; |
| 25 |
|
| 26 |
// Attempt to load the proper config, if on multisite. |
| 27 |
if ( count( $ps_options ) != 1 ) { |
| 28 |
$ps_options = patchstack_get_active_domain( $ps_options ); |
| 29 |
} else { |
| 30 |
$ps_options = $ps_options[0]; |
| 31 |
} |
| 32 |
|
| 33 |
// Do not run if we're not supposed to. |
| 34 |
if ( ! patchstack_get_should_run( $ps_options ) ) { |
| 35 |
return; |
| 36 |
} |
| 37 |
|
| 38 |
// Initialize and launch. |
| 39 |
try { |
| 40 |
// Load the extension. |
| 41 |
require_once __DIR__ . '/../lib/patchstack/vendor/autoload.php'; |
| 42 |
$extension = new Patchstack\Extensions\WordPress\ExtensionAP( $ps_options ); |
| 43 |
|
| 44 |
// Initiate the firewall processor with our settings. |
| 45 |
$firewall = new Patchstack\Processor( |
| 46 |
$extension, |
| 47 |
json_decode( base64_decode( $ps_options['patchstack_firewall_rules_v3_ap'] ), true ), |
| 48 |
[], |
| 49 |
['mustUsePluginCall' => true], |
| 50 |
[], |
| 51 |
[] |
| 52 |
); |
| 53 |
|
| 54 |
// Launch the firewall. |
| 55 |
$firewall->launch(); |
| 56 |
} catch ( \Exception $e ) { |
| 57 |
// |
| 58 |
} |
| 59 |
|