| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) exit; |
| 4 |
if (!class_exists('WPRWPAction')) : |
| 5 |
class WPRWPAction { |
| 6 |
public $settings; |
| 7 |
public $siteinfo; |
| 8 |
public $bvinfo; |
| 9 |
public $bvapi; |
| 10 |
|
| 11 |
public function __construct($settings, $siteinfo, $bvapi) { |
| 12 |
$this->settings = $settings; |
| 13 |
$this->siteinfo = $siteinfo; |
| 14 |
$this->bvapi = $bvapi; |
| 15 |
$this->bvinfo = new WPRInfo($settings); |
| 16 |
} |
| 17 |
|
| 18 |
public function activate() { |
| 19 |
if (!isset($_REQUEST['blogvaultkey'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 20 |
##BVKEYSLOCATE## |
| 21 |
} |
| 22 |
if (WPRAccount::isConfigured($this->settings)) { |
| 23 |
/* This informs the server about the activation */ |
| 24 |
$info = array(); |
| 25 |
$this->siteinfo->basic($info); |
| 26 |
$this->bvapi->pingbv('/bvapi/activate', $info); |
| 27 |
} else { |
| 28 |
WPRAccount::setup($this->settings); |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
public function deactivate() { |
| 33 |
$info = array(); |
| 34 |
$this->siteinfo->basic($info); |
| 35 |
##DISABLECACHE## |
| 36 |
$this->process_deactivation_feedback($info); |
| 37 |
|
| 38 |
$this->bvapi->pingbv('/bvapi/deactivate', $info); |
| 39 |
} |
| 40 |
|
| 41 |
public static function uninstall() { |
| 42 |
do_action('wpr_clear_pt_config'); |
| 43 |
do_action('wpr_clear_dynsync_config'); |
| 44 |
##CLEARCACHECONFIG## |
| 45 |
do_action('wpr_clear_bv_services_config'); |
| 46 |
do_action('wpr_clear_wp_2fa_config'); |
| 47 |
do_action('wpr_remove_bv_preload_include'); |
| 48 |
do_action('wpr_clear_php_error_config'); |
| 49 |
} |
| 50 |
|
| 51 |
public function clear_bv_services_config() { |
| 52 |
$this->settings->deleteOption($this->bvinfo->services_option_name); |
| 53 |
} |
| 54 |
|
| 55 |
public function clear_wp_2fa_config() { |
| 56 |
$meta_keys = array('wpr_2fa_enabled', 'wpr_2fa_secret', 'wpr_2fa_method', 'wpr_2fa_email_challenge', 'wpr_2fa_email_rate', 'wpr_2fa_attempts'); |
| 57 |
foreach ($meta_keys as $meta_key) { |
| 58 |
$this->settings->deleteMetaData('user', null, $meta_key, '', true); |
| 59 |
} |
| 60 |
|
| 61 |
$this->settings->deleteOption(WPRWP2FA::$wp_2fa_option); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
##SOUNINSTALLFUNCTION## |
| 66 |
|
| 67 |
public function footerHandler() { |
| 68 |
$bvfooter = $this->settings->getOption($this->bvinfo->badgeinfo); |
| 69 |
if ($bvfooter) { |
| 70 |
echo '<div style="max-width:150px;min-height:70px;margin:0 auto;text-align:center;position:relative;"> |
| 71 |
<a href='.esc_url($bvfooter['badgeurl']).' target="_blank" ><img src="'.esc_url(plugins_url($bvfooter['badgeimg'], __FILE__)).'" alt="'.esc_attr($bvfooter['badgealt']).'" /></a></div>'; |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
private function process_deactivation_feedback(&$info) { |
| 76 |
//phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 77 |
if (!isset($_GET['bv_deactivation_assets']) || !is_string($_GET['bv_deactivation_assets'])) { |
| 78 |
return; |
| 79 |
} |
| 80 |
|
| 81 |
$deactivation_assets = wp_unslash($_GET['bv_deactivation_assets']); |
| 82 |
$info['deactivation_feedback'] = base64_encode($deactivation_assets); |
| 83 |
//phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 84 |
} |
| 85 |
|
| 86 |
public function removeBVPreload() { |
| 87 |
$pattern = "@include '" . rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/bv-preload.php" . "';"; |
| 88 |
WPRHelper::removePatternFromWpConfig($pattern); |
| 89 |
} |
| 90 |
|
| 91 |
} |
| 92 |
endif; |