Changeset 3813747
- Timestamp:
- 11/20/2026 01:23:58 PM (6 hours ago)
- Location:
- blogvault-real-time-backup
- Files:
-
- 34 added
- 46 edited
- 34 copied
-
tags/6.85 (copied) (copied from blogvault-real-time-backup/trunk )
-
tags/6.85/blogvault.php (copied) (copied from blogvault-real-time-backup/trunk/blogvault.php ) (2 diffs)
-
tags/6.85/broken_link_checker (copied) (copied from blogvault-real-time-backup/trunk/broken_link_checker )
-
tags/6.85/callback/base.php (copied) (copied from blogvault-real-time-backup/trunk/callback/base.php ) (2 diffs)
-
tags/6.85/callback/handler.php (copied) (copied from blogvault-real-time-backup/trunk/callback/handler.php ) (1 diff)
-
tags/6.85/callback/wings/form_testing.php (added)
-
tags/6.85/callback/wings/info.php (copied) (copied from blogvault-real-time-backup/trunk/callback/wings/info.php ) (2 diffs)
-
tags/6.85/callback/wings/ipstore.php (copied) (copied from blogvault-real-time-backup/trunk/callback/wings/ipstore.php ) (2 diffs)
-
tags/6.85/callback/wings/links.php (copied) (copied from blogvault-real-time-backup/trunk/callback/wings/links.php )
-
tags/6.85/callback/wings/misc.php (modified) (1 diff)
-
tags/6.85/callback/wings/protect.php (copied) (copied from blogvault-real-time-backup/trunk/callback/wings/protect.php ) (1 diff)
-
tags/6.85/callback/wings/watch.php (copied) (copied from blogvault-real-time-backup/trunk/callback/wings/watch.php ) (2 diffs)
-
tags/6.85/form_testing/entries.php (added)
-
tags/6.85/form_testing/form_testing.php (modified) (5 diffs)
-
tags/6.85/form_testing/handlers/avada_form.php (added)
-
tags/6.85/form_testing/handlers/beaver_builder_form.php (added)
-
tags/6.85/form_testing/handlers/contact_form7.php (modified) (1 diff)
-
tags/6.85/form_testing/handlers/divi_form.php (added)
-
tags/6.85/form_testing/handlers/elementor_pro_form.php (added)
-
tags/6.85/form_testing/handlers/fluent_form.php (added)
-
tags/6.85/form_testing/handlers/formidable_form.php (modified) (2 diffs)
-
tags/6.85/form_testing/handlers/forminator_form.php (modified) (3 diffs)
-
tags/6.85/form_testing/handlers/gravity_form.php (modified) (2 diffs)
-
tags/6.85/form_testing/handlers/jet_engine_form.php (added)
-
tags/6.85/form_testing/handlers/jet_form_builder_form.php (added)
-
tags/6.85/form_testing/handlers/jetpack_form.php (added)
-
tags/6.85/form_testing/handlers/kadence_form.php (added)
-
tags/6.85/form_testing/handlers/mail_poet_form.php (added)
-
tags/6.85/form_testing/handlers/mc4wp_form.php (added)
-
tags/6.85/form_testing/handlers/met_form.php (added)
-
tags/6.85/form_testing/handlers/ninja_form.php (modified) (2 diffs)
-
tags/6.85/form_testing/handlers/spectra_form.php (added)
-
tags/6.85/form_testing/handlers/sure_form.php (added)
-
tags/6.85/form_testing/handlers/wp_form.php (modified) (3 diffs)
-
tags/6.85/form_testing/recorder.php (added)
-
tags/6.85/info.php (copied) (copied from blogvault-real-time-backup/trunk/info.php ) (1 diff)
-
tags/6.85/protect/fw.php (copied) (copied from blogvault-real-time-backup/trunk/protect/fw.php ) (31 diffs)
-
tags/6.85/protect/fw/rule.php (copied) (copied from blogvault-real-time-backup/trunk/protect/fw/rule.php ) (5 diffs)
-
tags/6.85/protect/fw/rule/engine.php (copied) (copied from blogvault-real-time-backup/trunk/protect/fw/rule/engine.php ) (26 diffs)
-
tags/6.85/protect/fw/rule/errors.php (copied) (copied from blogvault-real-time-backup/trunk/protect/fw/rule/errors.php ) (1 diff)
-
tags/6.85/protect/fw/rule/functions/array.php (copied) (copied from blogvault-real-time-backup/trunk/protect/fw/rule/functions/array.php ) (22 diffs)
-
tags/6.85/protect/fw/rule/functions/misc.php (copied) (copied from blogvault-real-time-backup/trunk/protect/fw/rule/functions/misc.php ) (5 diffs)
-
tags/6.85/protect/fw/rule/functions/request.php (copied) (copied from blogvault-real-time-backup/trunk/protect/fw/rule/functions/request.php ) (2 diffs)
-
tags/6.85/protect/fw/rule/functions/string.php (copied) (copied from blogvault-real-time-backup/trunk/protect/fw/rule/functions/string.php ) (11 diffs)
-
tags/6.85/protect/fw/rule/functions/wp.php (copied) (copied from blogvault-real-time-backup/trunk/protect/fw/rule/functions/wp.php ) (17 diffs)
-
tags/6.85/protect/ipstore.php (copied) (copied from blogvault-real-time-backup/trunk/protect/ipstore.php ) (3 diffs)
-
tags/6.85/protect/ipstore/db.php (copied) (copied from blogvault-real-time-backup/trunk/protect/ipstore/db.php ) (4 diffs)
-
tags/6.85/protect/ipstore/fs.php (copied) (copied from blogvault-real-time-backup/trunk/protect/ipstore/fs.php ) (4 diffs)
-
tags/6.85/protect/lib/utils.php (copied) (copied from blogvault-real-time-backup/trunk/protect/lib/utils.php ) (2 diffs)
-
tags/6.85/protect/logger.php (copied) (copied from blogvault-real-time-backup/trunk/protect/logger.php ) (2 diffs)
-
tags/6.85/protect/logger/db.php (copied) (copied from blogvault-real-time-backup/trunk/protect/logger/db.php ) (2 diffs)
-
tags/6.85/protect/logger/fs.php (copied) (copied from blogvault-real-time-backup/trunk/protect/logger/fs.php ) (1 diff)
-
tags/6.85/protect/lp.php (copied) (copied from blogvault-real-time-backup/trunk/protect/lp.php ) (14 diffs)
-
tags/6.85/protect/prepend/ignitor.php (copied) (copied from blogvault-real-time-backup/trunk/protect/prepend/ignitor.php ) (1 diff)
-
tags/6.85/protect/protect.php (copied) (copied from blogvault-real-time-backup/trunk/protect/protect.php ) (10 diffs)
-
tags/6.85/protect/request.php (copied) (copied from blogvault-real-time-backup/trunk/protect/request.php ) (5 diffs)
-
tags/6.85/protect/wp_user.php (copied) (copied from blogvault-real-time-backup/trunk/protect/wp_user.php ) (3 diffs)
-
tags/6.85/readme.txt (copied) (copied from blogvault-real-time-backup/trunk/readme.txt ) (2 diffs)
-
tags/6.85/wp_actions.php (copied) (copied from blogvault-real-time-backup/trunk/wp_actions.php )
-
trunk/blogvault.php (modified) (2 diffs)
-
trunk/callback/base.php (modified) (2 diffs)
-
trunk/callback/handler.php (modified) (1 diff)
-
trunk/callback/wings/form_testing.php (added)
-
trunk/callback/wings/info.php (modified) (2 diffs)
-
trunk/callback/wings/ipstore.php (modified) (2 diffs)
-
trunk/callback/wings/misc.php (modified) (1 diff)
-
trunk/callback/wings/protect.php (modified) (1 diff)
-
trunk/callback/wings/watch.php (modified) (2 diffs)
-
trunk/form_testing/entries.php (added)
-
trunk/form_testing/form_testing.php (modified) (5 diffs)
-
trunk/form_testing/handlers/avada_form.php (added)
-
trunk/form_testing/handlers/beaver_builder_form.php (added)
-
trunk/form_testing/handlers/contact_form7.php (modified) (1 diff)
-
trunk/form_testing/handlers/divi_form.php (added)
-
trunk/form_testing/handlers/elementor_pro_form.php (added)
-
trunk/form_testing/handlers/fluent_form.php (added)
-
trunk/form_testing/handlers/formidable_form.php (modified) (2 diffs)
-
trunk/form_testing/handlers/forminator_form.php (modified) (3 diffs)
-
trunk/form_testing/handlers/gravity_form.php (modified) (2 diffs)
-
trunk/form_testing/handlers/jet_engine_form.php (added)
-
trunk/form_testing/handlers/jet_form_builder_form.php (added)
-
trunk/form_testing/handlers/jetpack_form.php (added)
-
trunk/form_testing/handlers/kadence_form.php (added)
-
trunk/form_testing/handlers/mail_poet_form.php (added)
-
trunk/form_testing/handlers/mc4wp_form.php (added)
-
trunk/form_testing/handlers/met_form.php (added)
-
trunk/form_testing/handlers/ninja_form.php (modified) (2 diffs)
-
trunk/form_testing/handlers/spectra_form.php (added)
-
trunk/form_testing/handlers/sure_form.php (added)
-
trunk/form_testing/handlers/wp_form.php (modified) (3 diffs)
-
trunk/form_testing/recorder.php (added)
-
trunk/info.php (modified) (1 diff)
-
trunk/protect/fw.php (modified) (31 diffs)
-
trunk/protect/fw/rule.php (modified) (5 diffs)
-
trunk/protect/fw/rule/engine.php (modified) (26 diffs)
-
trunk/protect/fw/rule/errors.php (modified) (1 diff)
-
trunk/protect/fw/rule/functions/array.php (modified) (22 diffs)
-
trunk/protect/fw/rule/functions/misc.php (modified) (5 diffs)
-
trunk/protect/fw/rule/functions/request.php (modified) (2 diffs)
-
trunk/protect/fw/rule/functions/string.php (modified) (11 diffs)
-
trunk/protect/fw/rule/functions/wp.php (modified) (17 diffs)
-
trunk/protect/ipstore.php (modified) (3 diffs)
-
trunk/protect/ipstore/db.php (modified) (4 diffs)
-
trunk/protect/ipstore/fs.php (modified) (4 diffs)
-
trunk/protect/lib/utils.php (modified) (2 diffs)
-
trunk/protect/logger.php (modified) (2 diffs)
-
trunk/protect/logger/db.php (modified) (2 diffs)
-
trunk/protect/logger/fs.php (modified) (1 diff)
-
trunk/protect/lp.php (modified) (14 diffs)
-
trunk/protect/prepend/ignitor.php (modified) (1 diff)
-
trunk/protect/protect.php (modified) (10 diffs)
-
trunk/protect/request.php (modified) (5 diffs)
-
trunk/protect/wp_user.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
blogvault-real-time-backup/tags/6.85/blogvault.php
r3795700 r3813747 6 6 Author: Backup by BlogVault 7 7 Author URI: https://blogvault.net 8 Version: 6.8 38 Version: 6.85 9 9 Network: True 10 10 License: GPLv2 or later … … 187 187 require_once dirname( __FILE__ ) . '/protect/protect.php'; 188 188 //For backward compatibility. 189 BVProtect_V68 3::$settings = new BVWPSettings();190 BVProtect_V68 3::$db = new BVWPDb();191 BVProtect_V68 3::$info = new BVInfo(BVProtect_V683::$settings);192 193 add_action('bv_clear_pt_config', array('BVProtect_V68 3', 'uninstall'));189 BVProtect_V685::$settings = new BVWPSettings(); 190 BVProtect_V685::$db = new BVWPDb(); 191 BVProtect_V685::$info = new BVInfo(BVProtect_V685::$settings); 192 193 add_action('bv_clear_pt_config', array('BVProtect_V685', 'uninstall')); 194 194 195 195 if ($bvinfo->isActivePlugin()) { 196 BVProtect_V68 3::init(BVProtect_V683::MODE_WP);196 BVProtect_V685::init(BVProtect_V685::MODE_WP); 197 197 } 198 198 } -
blogvault-real-time-backup/tags/6.85/callback/base.php
r3795700 r3813747 13 13 "DB_WING_VERSION" => '1.5', 14 14 "ACCOUNT_WING_VERSION" => '1.2', 15 "MISC_WING_VERSION" => '1. 4',15 "MISC_WING_VERSION" => '1.6', 16 16 "FS_WING_VERSION" => '1.4', 17 "INFO_WING_VERSION" => ' 2.9',17 "INFO_WING_VERSION" => '3.0', 18 18 "WATCH_WING_VERSION" => '1.7', 19 19 "FS_WRITE_WING_VERSION" => '1.2', … … 23 23 "SECURITY_WING_VERSION" => '1.4', 24 24 "LINKS_WING_VERSION" => '1.0', 25 "FORM_TESTING_WING_VERSION" => '1.0', 25 26 "SECURITY_HARDENING_SETTINGS_VERSION" => '1.0', 26 27 ); -
blogvault-real-time-backup/tags/6.85/callback/handler.php
r3795700 r3813747 180 180 $module = new BVLinksCallback($this); 181 181 break; 182 case 'frmtst': 183 // Only the BlogVault, MalCare and WP Remote plugins carry this wing; the rest answer Bad Command. 184 $form_testing_wing = dirname( __FILE__ ) . '/wings/form_testing.php'; 185 if (!file_exists($form_testing_wing)) { 186 $module = null; 187 break; 188 } 189 require_once $form_testing_wing; 190 $module = new BVFormTestingCallback($this); 191 break; 182 192 default: 183 193 require_once dirname( __FILE__ ) . '/wings/misc.php'; -
blogvault-real-time-backup/tags/6.85/callback/wings/info.php
r3795700 r3813747 11 11 public $bvapi; 12 12 13 const INFO_WING_VERSION = 2.9;13 const INFO_WING_VERSION = 3.0; 14 14 15 15 public function __construct($callback_handler) { … … 221 221 'templatedir' => get_template_directory(), 222 222 'dbcharset' => defined('DB_CHARSET') ? DB_CHARSET : null, 223 'mysql_client_flags' => defined('MYSQL_CLIENT_FLAGS') ? MYSQL_CLIENT_FLAGS : null, 223 224 'disallow_file_edit' => defined('DISALLOW_FILE_EDIT'), 224 225 'disallow_file_mods' => defined('DISALLOW_FILE_MODS'), -
blogvault-real-time-backup/tags/6.85/callback/wings/ipstore.php
r3795700 r3813747 51 51 public function getIPs($table, $auto_increment_offset, $type, $category) { 52 52 $query = "SELECT `start_ip_range` FROM $table WHERE id < $auto_increment_offset AND `type` in (" . implode(',', $type) . ") AND "; 53 $query .= ($category == BVProtectIpstoreDB_V68 3::CATEGORY_FW) ? "`is_fw` = true;" : "`is_lp` = true;";53 $query .= ($category == BVProtectIpstoreDB_V685::CATEGORY_FW) ? "`is_fw` = true;" : "`is_lp` = true;"; 54 54 return $this->db->getCol($query); 55 55 } … … 65 65 66 66 $info['fw_blacklisted_ips'] = $this->getIPs($table, $auto_increment_offset, 67 BVProtectIpstoreDB_V68 3::blacklistedTypes(), BVProtectIpstoreDB_V683::CATEGORY_FW);67 BVProtectIpstoreDB_V685::blacklistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_FW); 68 68 $info['lp_blacklisted_ips'] = $this->getIPs($table, $auto_increment_offset, 69 BVProtectIpstoreDB_V68 3::blacklistedTypes(), BVProtectIpstoreDB_V683::CATEGORY_LP);69 BVProtectIpstoreDB_V685::blacklistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_LP); 70 70 $info['fw_whitelisted_ips'] = $this->getIPs($table, $auto_increment_offset, 71 BVProtectIpstoreDB_V68 3::whitelistedTypes(), BVProtectIpstoreDB_V683::CATEGORY_FW);71 BVProtectIpstoreDB_V685::whitelistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_FW); 72 72 $info['lp_whitelisted_ips'] = $this->getIPs($table, $auto_increment_offset, 73 BVProtectIpstoreDB_V68 3::whitelistedTypes(), BVProtectIpstoreDB_V683::CATEGORY_LP);73 BVProtectIpstoreDB_V685::whitelistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_LP); 74 74 $info['ip_store_offset'] = $this->getIPStoreOffset($table, $auto_increment_offset); 75 75 $info['country_ips_size'] = intval($db->getVar("SELECT COUNT(id) FROM $table WHERE id >= $auto_increment_offset")); -
blogvault-real-time-backup/tags/6.85/callback/wings/misc.php
r3158138 r3813747 12 12 public $db; 13 13 14 const MISC_WING_VERSION = 1. 4;14 const MISC_WING_VERSION = 1.6; 15 15 16 16 public function __construct($callback_handler) { -
blogvault-real-time-backup/tags/6.85/callback/wings/protect.php
r3795700 r3813747 41 41 42 42 public function unBlockIP($ip, $attempts, $time) { 43 $transient_name = BVProtectLP_V68 3::UNBLOCK_IP_TRANSIENT_PREFIX . $ip;43 $transient_name = BVProtectLP_V685::UNBLOCK_IP_TRANSIENT_PREFIX . $ip; 44 44 $this->settings->setTransient($transient_name, $attempts, $time); 45 45 return $this->settings->getTransient($transient_name); -
blogvault-real-time-backup/tags/6.85/callback/wings/watch.php
r3795700 r3813747 145 145 require_once dirname( __FILE__ ) . '/../../protect/lp.php'; 146 146 $lp_params = $params['lp']; 147 if (!isset($lp_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVProtectLP_V68 3::TABLE_NAME))) {147 if (!isset($lp_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVProtectLP_V685::TABLE_NAME))) { 148 148 $limit = intval($lp_params['limit']); 149 149 $filter = $lp_params['filter']; 150 150 $offset = isset($lp_params['offset']) ? intval($lp_params['offset']) : 0; 151 $table = $db->getBVTable(BVProtectLP_V68 3::TABLE_NAME);151 $table = $db->getBVTable(BVProtectLP_V685::TABLE_NAME); 152 152 $resp["lplogs"] = $this->getOffsetResetInfo($lp_params, $offset, $table); 153 153 if (empty($resp["lplogs"])) { 154 $db->deleteBVTableContent(BVProtectLP_V68 3::TABLE_NAME, $lp_params['rmfilter']);154 $db->deleteBVTableContent(BVProtectLP_V685::TABLE_NAME, $lp_params['rmfilter']); 155 155 $resp["lplogs"] = $this->getData($table, $limit, $filter); 156 156 } … … 168 168 require_once dirname( __FILE__ ) . '/../../protect/fw.php'; 169 169 $fw_params = $params['fw']; 170 if (!isset($fw_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVProtectFW_V68 3::TABLE_NAME))) {170 if (!isset($fw_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVProtectFW_V685::TABLE_NAME))) { 171 171 $limit = intval($fw_params['limit']); 172 172 $filter = $fw_params['filter']; 173 173 $offset = isset($fw_params['offset']) ? intval($fw_params['offset']) : 0; 174 $table = $db->getBVTable(BVProtectFW_V68 3::TABLE_NAME);174 $table = $db->getBVTable(BVProtectFW_V685::TABLE_NAME); 175 175 $resp["fwlogs"] = $this->getOffsetResetInfo($fw_params, $offset, $table); 176 176 if (empty($resp["fwlogs"])){ 177 $db->deleteBVTableContent(BVProtectFW_V68 3::TABLE_NAME, $fw_params['rmfilter']);177 $db->deleteBVTableContent(BVProtectFW_V685::TABLE_NAME, $fw_params['rmfilter']); 178 178 $resp["fwlogs"] = $this->getData($table, $limit, $filter); 179 179 } -
blogvault-real-time-backup/tags/6.85/form_testing/form_testing.php
r3220024 r3813747 2 2 3 3 if (!defined('ABSPATH')) exit; 4 5 require_once dirname(__FILE__) . '/recorder.php'; 6 require_once dirname(__FILE__) . '/entries.php'; 7 4 8 if (!class_exists('BVFormTesting')) : 5 9 10 // Form test mode for one signed test submission: the tested form's CAPTCHA, email and anti-spam bypasses, and the recorder. 6 11 class BVFormTesting { 7 12 private $form_type; … … 9 14 private $spam_bypass; 10 15 private $bypass_params = array(); 16 private $run_id; 17 private $capture_mail; 18 private $block_http; 19 private $captcha_live; 11 20 12 21 public function __construct($params) { … … 15 24 $this->spam_bypass = isset($params['bv_ignr_spm_plgns']); 16 25 17 if (isset($params['bv_ignr_frm_cptch'])) { 26 $this->captcha_live = isset($params['bv_frm_cptch_live']); 27 // A live-captcha run tests that the form rejects a wrong token: never bypass the captcha then. 28 if (isset($params['bv_ignr_frm_cptch']) && !$this->captcha_live) { 18 29 $this->bypass_params['should_bypass_captcha'] = true; 19 30 } … … 22 33 $this->bypass_params['should_bypass_email'] = true; 23 34 } 35 36 $run_id = isset($params['bv_frm_run']) && is_string($params['bv_frm_run']) ? sanitize_text_field(wp_unslash($params['bv_frm_run'])) : null; 37 $this->run_id = BVFormTestRecorder::isValidRunId($run_id) ? $run_id : null; 38 $this->capture_mail = isset($params['bv_frm_cptr_ml']); 39 $this->block_http = isset($params['bv_frm_blk_http']); 40 } 41 42 /** 43 * Request fields that only a login, registration, checkout or comment sends: exact names, never a pattern (form fields 44 * such as "mf-password" must not match). WordPress's login sends "log" and "pwd" together. 45 */ 46 private static $refused_fields = array('woocommerce-login-nonce', 'woocommerce-register-nonce', 'woocommerce-process-checkout-nonce', 47 'woocommerce-lost-password-nonce', 'woocommerce-reset-password-nonce', 'woocommerce-edit-account-nonce', 'wc-ajax', 'comment_post_ID'); 48 49 /** 50 * Whether this is a request a form test never makes (see the class comment): login, registration, comments, 51 * XML-RPC, cron, an admin screen other than admin-ajax.php, a WooCommerce login, checkout or account form. 52 */ 53 public function isRefusedRequest($request) { 54 $request = (array) $request; 55 if (defined('XMLRPC_REQUEST') || defined('DOING_CRON') || defined('WP_INSTALLING')) { 56 return true; 57 } 58 $script = isset($_SERVER['SCRIPT_NAME']) && is_string($_SERVER['SCRIPT_NAME']) ? basename($_SERVER['SCRIPT_NAME']) : ''; 59 if (defined('DOING_AJAX') && DOING_AJAX) { 60 if ($script !== 'admin-ajax.php') { 61 return true; 62 } 63 } elseif (is_admin() || $script !== 'index.php') { 64 return true; 65 } 66 if (isset($request['log'], $request['pwd'])) { 67 return true; 68 } 69 foreach (self::$refused_fields as $field) { 70 if (isset($request[$field])) { 71 return true; 72 } 73 } 74 return false; 24 75 } 25 76 26 77 public function init() { 78 // Refused, not handled as a normal request: a test submission carried on without test mode would be a real one. 79 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 80 if ($this->isRefusedRequest($_REQUEST)) { 81 wp_die(esc_html('Form test refused for this request.'), '', array('response' => 403)); 82 } 83 27 84 if ($this->spam_bypass === true) { 28 85 $this->bypassSpamPlugins(); 29 86 } 30 87 88 $recorder = null; 89 if ($this->run_id !== null) { 90 $recorder = new BVFormTestRecorder($this->run_id, $this->capture_mail, $this->block_http, $this->captcha_live, 91 array_key_exists('should_bypass_captcha', $this->bypass_params), $this->form_id); 92 $recorder->start(); 93 BVFormTestEntries::watch($recorder); 94 $this->watchSubmissionEvents($recorder); 95 } 96 97 // Mail capture can only be decided once wp_mail() exists (after all plugins load), and the 98 // plugin's own email suppression depends on it, so with capture requested both wait for 99 // plugins_loaded. That is still before any form plugin handles the submission. 100 if ($recorder !== null && $this->capture_mail) { 101 $this->whenPluginsLoaded(function () use ($recorder) { 102 $this->applyBypass($recorder); 103 }); 104 } else { 105 $this->applyBypass($recorder); 106 } 107 } 108 109 private function applyBypass($recorder) { 110 if ($recorder !== null) { 111 $recorder->setupMailCapture(); 112 // Captured mail never leaves the site, so let the plugin send it to wp_mail() and record it. 113 if ($recorder->captureMailEnabled()) { 114 unset($this->bypass_params['should_bypass_email']); 115 } 116 } 117 118 // Always, even with nothing to bypass: besides the CAPTCHA and email bypasses, each handler keeps the test's 119 // side effects in check (integrations, created posts and users, asynchronous work), which a submission must 120 // never skip. The wrong-CAPTCHA run (bv_frm_cptch_live) with mail capture has no bypass at all, and is exactly 121 // the run that goes through as a real submission when the form accepts the wrong token. 31 122 $handler = $this->getHandler($this->form_type); 32 if ($handler === null) { 33 return; 34 } 35 36 if (empty($this->bypass_params) === false) { 123 if ($handler !== null) { 37 124 $handler->bypass(); 125 } 126 } 127 128 /** Form plugins that store no entry id, or whose handler reports what it did: record the submission's events. */ 129 private function watchSubmissionEvents($recorder) { 130 switch ($this->form_type) { 131 case 'ElementorProForm': 132 require_once dirname(__FILE__) . '/handlers/elementor_pro_form.php'; 133 BVElementorProFormHandler::watch($recorder); 134 break; 135 case 'DiviForm': 136 require_once dirname(__FILE__) . '/handlers/divi_form.php'; 137 BVDiviFormHandler::watch($recorder); 138 break; 139 case 'SpectraForm': 140 require_once dirname(__FILE__) . '/handlers/spectra_form.php'; 141 BVSpectraFormHandler::watch($recorder); 142 break; 143 case 'KadenceForm': 144 require_once dirname(__FILE__) . '/handlers/kadence_form.php'; 145 BVKadenceFormHandler::watch($recorder); 146 break; 147 case 'BeaverBuilderForm': 148 require_once dirname(__FILE__) . '/handlers/beaver_builder_form.php'; 149 BVBeaverBuilderFormHandler::watch($recorder); 150 break; 151 case 'Mc4wpForm': 152 require_once dirname(__FILE__) . '/handlers/mc4wp_form.php'; 153 BVMc4wpFormHandler::watch($recorder); 154 break; 155 case 'JetEngineForm': 156 require_once dirname(__FILE__) . '/handlers/jet_engine_form.php'; 157 BVJetEngineFormHandler::watch($recorder); 158 break; 159 case 'FluentForm': 160 require_once dirname(__FILE__) . '/handlers/fluent_form.php'; 161 BVFluentFormHandler::watch($recorder); 162 break; 163 } 164 } 165 166 private function whenPluginsLoaded($callback) { 167 if (did_action('plugins_loaded')) { 168 call_user_func($callback); 169 } else { 170 add_action('plugins_loaded', $callback, PHP_INT_MIN); 38 171 } 39 172 } … … 59 192 require_once dirname(__FILE__) . '/handlers/formidable_form.php'; 60 193 return new BVFormidableFormHandler($this->form_id, $this->bypass_params); 194 case 'FluentForm': 195 require_once dirname(__FILE__) . '/handlers/fluent_form.php'; 196 return new BVFluentFormHandler($this->form_id, $this->bypass_params); 197 case 'ElementorProForm': 198 require_once dirname(__FILE__) . '/handlers/elementor_pro_form.php'; 199 return new BVElementorProFormHandler($this->form_id, $this->bypass_params); 200 case 'DiviForm': 201 require_once dirname(__FILE__) . '/handlers/divi_form.php'; 202 return new BVDiviFormHandler($this->form_id, $this->bypass_params); 203 case 'MetForm': 204 require_once dirname(__FILE__) . '/handlers/met_form.php'; 205 return new BVMetFormHandler($this->form_id, $this->bypass_params); 206 case 'JetFormBuilderForm': 207 require_once dirname(__FILE__) . '/handlers/jet_form_builder_form.php'; 208 return new BVJetFormBuilderFormHandler($this->form_id, $this->bypass_params); 209 case 'SureForm': 210 require_once dirname(__FILE__) . '/handlers/sure_form.php'; 211 return new BVSureFormHandler($this->form_id, $this->bypass_params); 212 case 'JetpackForm': 213 require_once dirname(__FILE__) . '/handlers/jetpack_form.php'; 214 return new BVJetpackFormHandler($this->form_id, $this->bypass_params); 215 case 'SpectraForm': 216 require_once dirname(__FILE__) . '/handlers/spectra_form.php'; 217 return new BVSpectraFormHandler($this->form_id, $this->bypass_params); 218 case 'KadenceForm': 219 require_once dirname(__FILE__) . '/handlers/kadence_form.php'; 220 return new BVKadenceFormHandler($this->form_id, $this->bypass_params); 221 case 'BeaverBuilderForm': 222 require_once dirname(__FILE__) . '/handlers/beaver_builder_form.php'; 223 return new BVBeaverBuilderFormHandler($this->form_id, $this->bypass_params); 224 case 'AvadaForm': 225 require_once dirname(__FILE__) . '/handlers/avada_form.php'; 226 return new BVAvadaFormHandler($this->form_id, $this->bypass_params); 227 case 'MailPoetForm': 228 require_once dirname(__FILE__) . '/handlers/mail_poet_form.php'; 229 return new BVMailPoetFormHandler($this->form_id, $this->bypass_params); 230 case 'Mc4wpForm': 231 require_once dirname(__FILE__) . '/handlers/mc4wp_form.php'; 232 return new BVMc4wpFormHandler($this->form_id, $this->bypass_params); 233 case 'JetEngineForm': 234 require_once dirname(__FILE__) . '/handlers/jet_engine_form.php'; 235 return new BVJetEngineFormHandler($this->form_id, $this->bypass_params); 61 236 default: 62 237 return null; -
blogvault-real-time-backup/tags/6.85/form_testing/handlers/contact_form7.php
r3220024 r3813747 24 24 25 25 private function bypassCaptcha() { 26 // Spam check: reCAPTCHA v3, Turnstile, Akismet, disallowed list. 26 27 add_filter('wpcf7_skip_spam_check', '__return_true', PHP_INT_MAX); 28 29 // Quiz and Really Simple CAPTCHA are validated per field instead. Their answers are tied to a 30 // random question or a single-use image, so unhook their validators just before they run. 31 add_filter('wpcf7_validate_quiz', array($this, 'skipQuizValidation'), 9, 1); 32 add_filter('wpcf7_validate_captchar', array($this, 'skipCaptchaValidation'), 9, 1); 33 } 34 35 public function skipQuizValidation($result) { 36 remove_filter('wpcf7_validate_quiz', 'wpcf7_quiz_validation_filter', 10); 37 return $result; 38 } 39 40 public function skipCaptchaValidation($result) { 41 remove_filter('wpcf7_validate_captchar', 'wpcf7_captcha_validation_filter', 10); 42 return $result; 27 43 } 28 44 -
blogvault-real-time-backup/tags/6.85/form_testing/handlers/formidable_form.php
r3220024 r3813747 14 14 15 15 public function bypass() { 16 // Report spam as an error instead of silently saving a spam entry behind a success message. 17 add_filter('frm_save_spam_entry', '__return_false', PHP_INT_MAX); 18 16 19 if (array_key_exists('should_bypass_captcha', $this->bypass_params)) { 17 20 $this->bypassCaptcha(); … … 24 27 25 28 public function bypassCaptcha() { 26 add_filter('frm_is_field_hidden', '__return_true', PHP_INT_MAX); 29 // Only the captcha field: Formidable Pro also uses this filter for conditional logic on every field. 30 add_filter('frm_is_field_hidden', array($this, 'hideCaptchaField'), PHP_INT_MAX, 2); 31 // Anti-spam a direct test POST can't pass: the JavaScript token and the honeypot. 32 add_filter('frm_run_antispam', '__return_false', PHP_INT_MAX); 33 add_filter('frm_run_honeypot', '__return_false', PHP_INT_MAX); 34 } 35 36 public function hideCaptchaField($is_hidden, $field) { 37 $type = is_array($field) ? (isset($field['type']) ? $field['type'] : '') : (isset($field->type) ? $field->type : ''); 38 return ($type === 'captcha') ? true : $is_hidden; 27 39 } 28 40 -
blogvault-real-time-backup/tags/6.85/form_testing/handlers/forminator_form.php
r3220024 r3813747 7 7 private $form_id; 8 8 private $bypass_params = array(); 9 private $captcha_endpoints = array(); 10 private $created_posts = array(); 11 private $created_attachments = array(); 9 12 10 13 public function __construct($form_id, $bypass_params) { … … 21 24 $this->bypassEmail(); 22 25 } 26 27 $this->allowPollTestVotes(); 28 $this->discardPostDataPosts(); 23 29 } 24 30 31 private function isTestedModule($module_id) { 32 return (string) $module_id === (string) $this->form_id; 33 } 34 35 /** 36 * Forminator verifies reCAPTCHA (v2 checkbox, v2 invisible, v3), hCaptcha and Turnstile tokens with 37 * Forminator_Captcha_Verification::verify(), a wp_remote_request() to the provider's siteverify URL that 38 * it passes through the forminator_<provider>_verify_endpoint filter. We note that URL and answer the 39 * request ourselves with a passing verdict, so only Forminator's own verification is affected. 40 */ 25 41 public function bypassCaptcha() { 42 foreach (array('recaptcha', 'hcaptcha', 'turnstile') as $provider) { 43 add_filter("forminator_{$provider}_verify_endpoint", function ($endpoint) use ($provider) { 44 if (is_string($endpoint) && $endpoint !== '') { 45 $this->captcha_endpoints[$endpoint] = $provider; 46 } 47 return $endpoint; 48 }, PHP_INT_MAX); 49 } 50 add_filter('pre_http_request', array($this, 'stubCaptchaVerification'), PHP_INT_MAX - 1, 3); 51 52 // Forminator before 1.58 skipped its captcha check while a Stripe field was hidden. 53 // From 1.58 a hidden Stripe field means "verify the payment token", which needs a token we don't have. 54 $this->whenForminatorLoaded(function () { 55 if (defined('FORMINATOR_VERSION') && version_compare(FORMINATOR_VERSION, '1.58.0', '<')) { 56 $this->markStripeHidden(); 57 } 58 }); 59 } 60 61 public function stubCaptchaVerification($preempt, $args, $url) { 62 if ($preempt !== false || !is_string($url) || !isset($this->captcha_endpoints[$url])) { 63 return $preempt; 64 } 65 66 $verdict = array('success' => true, 'hostname' => BVFormTestRecorder::parseUrl(home_url(), PHP_URL_HOST)); 67 // Only reCAPTCHA v3 checks a score, and it wants a high one. 68 if ($this->captcha_endpoints[$url] === 'recaptcha') { 69 $verdict['score'] = 1.0; 70 } 71 72 return array( 73 'headers' => array(), 74 'body' => BVFormTestRecorder::jsonEncode($verdict), 75 'response' => array('code' => 200, 'message' => 'OK'), 76 'cookies' => array(), 77 'filename' => null 78 ); 79 } 80 81 private function markStripeHidden() { 26 82 if (defined('WP_PLUGIN_DIR')) { 27 83 $abstract_front_action_file_path = WP_PLUGIN_DIR . '/forminator/library/abstracts/abstract-class-front-action.php'; … … 45 101 } 46 102 } 103 104 /** 105 * Polls accept one vote per IP (or browser cookie). A test vote must neither be refused because an 106 * earlier test voted, nor lock the poll for the monitoring server's IP: we let the test vote through 107 * and don't store the voter IP with it. 108 */ 109 private function allowPollTestVotes() { 110 add_filter('forminator_poll_handle_form_user_can_vote', function ($can_vote, $poll_id) { 111 return $this->isTestedModule($poll_id) ? true : $can_vote; 112 }, PHP_INT_MAX, 2); 113 114 // Forminator also blocks the voter's IP for a few seconds after a vote; lift that block for a test vote. 115 add_action('forminator_polls_submit_before_set_fields', function ($entry, $poll_id) { 116 if ($this->isTestedModule($poll_id)) { 117 add_action('shutdown', function () use ($poll_id) { 118 $this->clearPollVoteLock($poll_id); 119 }, 0); 120 } 121 }, PHP_INT_MAX, 2); 122 123 add_filter('forminator_polls_submit_field_data', function ($field_data, $poll_id) { 124 if (!$this->isTestedModule($poll_id) || !is_array($field_data)) { 125 return $field_data; 126 } 127 return array_values(array_filter($field_data, function ($item) { 128 return !(is_array($item) && isset($item['name']) && $item['name'] === '_forminator_user_ip'); 129 })); 130 }, PHP_INT_MAX, 2); 131 } 132 133 private function clearPollVoteLock($poll_id) { 134 if (!class_exists('Forminator_Geo') || !method_exists('Forminator_Geo', 'get_user_ip')) { 135 return; 136 } 137 $user_ip = Forminator_Geo::get_user_ip(); 138 delete_transient('forminator_request_from_ip_' . $poll_id . '_' . $user_ip); 139 delete_option('forminator_poll_ip_lock_' . $poll_id . '_' . md5($user_ip)); 140 } 141 142 /** 143 * A Post Data field creates a post. For a test submission it is created as a draft (never published, 144 * so no publish notifications or auto-sharing) and deleted, with any featured image uploaded by the 145 * submission, once the request ends. 146 */ 147 private function discardPostDataPosts() { 148 add_filter('forminator_post_data_post_info', function ($post) { 149 if ($this->isCurrentForm() && is_array($post)) { 150 $post['post_status'] = 'draft'; 151 } 152 return $post; 153 }, PHP_INT_MAX); 154 155 add_action('forminator_post_data_field_post_saved', function ($post_id) { 156 if ($this->isCurrentForm()) { 157 $this->created_posts[] = absint($post_id); 158 } 159 }, PHP_INT_MAX); 160 161 add_action('add_attachment', function ($attachment_id) { 162 if ($this->isCurrentForm()) { 163 $this->created_attachments[] = absint($attachment_id); 164 } 165 }, PHP_INT_MAX); 166 167 add_action('shutdown', array($this, 'deleteCreatedPosts'), 0); 168 } 169 170 private function isCurrentForm() { 171 return class_exists('Forminator_CForm_Front_Action') && isset(Forminator_CForm_Front_Action::$module_id) && 172 $this->isTestedModule(Forminator_CForm_Front_Action::$module_id); 173 } 174 175 public function deleteCreatedPosts() { 176 foreach ($this->created_posts as $post_id) { 177 $post = get_post($post_id); 178 if ($post_id === 0 || !$post || $post->post_status !== 'draft') { 179 continue; 180 } 181 $thumbnail_id = (int) get_post_thumbnail_id($post_id); 182 if ($thumbnail_id > 0 && in_array($thumbnail_id, $this->created_attachments, true)) { 183 wp_delete_attachment($thumbnail_id, true); 184 } 185 wp_delete_post($post_id, true); 186 } 187 $this->created_posts = array(); 188 } 189 190 private function whenForminatorLoaded($callback) { 191 if (did_action('plugins_loaded')) { 192 call_user_func($callback); 193 } else { 194 add_action('plugins_loaded', $callback, PHP_INT_MIN); 195 } 196 } 47 197 } 48 198 -
blogvault-real-time-backup/tags/6.85/form_testing/handlers/gravity_form.php
r3220024 r3813747 21 21 $this->bypassEmail(); 22 22 } 23 24 $this->bypassContentCreation(); 25 $this->keepSideEffectsInRequest(); 26 $this->bypassTotalValidation(); 27 } 28 29 /** 30 * Gravity Forms 2.10+ sends notifications from a background request by default (and add-ons may 31 * process feeds in one), where the test's email suppression, mail capture and HTTP blocking are not 32 * active. Process them within the test request instead. 33 */ 34 public function keepSideEffectsInRequest() { 35 if ($this->form_id === null) { 36 return; 37 } 38 39 $form_id = absint($this->form_id); 40 add_filter('gform_is_asynchronous_notifications_enabled_' . $form_id, '__return_false', PHP_INT_MAX); 41 add_filter('gform_is_feed_asynchronous_' . $form_id, '__return_false', PHP_INT_MAX); 42 } 43 44 /** 45 * The Total field is filled by the browser from the pricing fields; Gravity Forms recalculates the 46 * total when it saves the entry, so the submitted value is not compared for a test submission. 47 */ 48 public function bypassTotalValidation() { 49 if ($this->form_id === null) { 50 return; 51 } 52 53 add_filter('gform_pre_validation_' . absint($this->form_id), function($form) { 54 foreach ($form['fields'] as &$field) { 55 if ($field->type === 'total') { 56 $field->validateTotal = false; 57 } 58 } 59 return $form; 60 }, PHP_INT_MAX); 61 } 62 63 /** 64 * A test submission must not create posts (Post fields) or WordPress users (User Registration add-on) 65 * on the site. Advanced Post Creation feeds are skipped for the same reason. 66 */ 67 public function bypassContentCreation() { 68 if ($this->form_id === null) { 69 return; 70 } 71 72 $form_id = absint($this->form_id); 73 add_filter('gform_disable_post_creation_' . $form_id, '__return_true', PHP_INT_MAX); 74 add_filter('gform_gravityformsuserregistration_pre_process_feeds_' . $form_id, '__return_empty_array', PHP_INT_MAX); 75 add_filter('gform_gravityformsadvancedpostcreation_pre_process_feeds_' . $form_id, '__return_empty_array', PHP_INT_MAX); 23 76 } 24 77 … … 36 89 return $form; 37 90 }, PHP_INT_MAX); 91 92 // Honeypot and the submission speed check (2.9.21+) mark a scripted submission as spam or abort it. 93 add_filter('gform_pre_process_' . absint($this->form_id), function($form) { 94 if (is_array($form)) { 95 $form['enableHoneypot'] = false; 96 $form['enableSubmitSpeedCheck'] = false; 97 } 98 return $form; 99 }, PHP_INT_MAX); 100 101 // Akismet (Gravity Forms' own integration) would mark the test entry as spam. 102 add_filter('gform_akismet_enabled_' . absint($this->form_id), '__return_false', PHP_INT_MAX); 38 103 } 39 104 -
blogvault-real-time-backup/tags/6.85/form_testing/handlers/ninja_form.php
r3220024 r3813747 24 24 25 25 public function bypassCaptcha() { 26 // Field captchas (reCAPTCHA v2, hCaptcha, Turnstile, the spam question): a null type skips the field's validation. 26 27 add_filter('ninja_forms_pre_validate_field_settings', function ($field_settings) { 27 if (isset($field_settings['type']) && in_array($field_settings['type'], ['recaptcha', 'spam'], true)) { 28 $captcha_types = array('recaptcha', 'recaptcha_v3', 'hcaptcha', 'turnstile', 'spam'); 29 if (isset($field_settings['type']) && in_array($field_settings['type'], $captcha_types, true)) { 28 30 $field_settings['type'] = null; 29 31 } … … 31 33 }, PHP_INT_MAX); 32 34 35 // reCAPTCHA v3 is a form action (type "recaptcha") that verifies the injected token. 33 36 add_filter('ninja_forms_run_action_type_recaptcha', '__return_false', PHP_INT_MAX); 34 37 } -
blogvault-real-time-backup/tags/6.85/form_testing/handlers/wp_form.php
r3220024 r3813747 4 4 if (!class_exists('BVWPFormHandler')) : 5 5 6 // WPForms (Lite and Pro): CAPTCHA, anti-spam, email and upload handling for the tested form in a signed test request. 6 7 class BVWPFormHandler { 7 8 private $form_id; … … 21 22 $this->bypassEmail(); 22 23 } 24 25 $this->sendEmailsInRequest(); 26 $this->acceptModernUploads(); 27 $this->skipMediaLibrary(); 23 28 } 24 29 25 30 public function bypassCaptcha() { 26 31 add_filter('wpforms_process_bypass_captcha', '__return_true', PHP_INT_MAX); 32 add_filter('wpforms_process_antispam', '__return_true', PHP_INT_MAX); 33 add_filter('wpforms_process_honeypot', '__return_false', PHP_INT_MAX); 34 add_filter('wpforms_process_anti_spam_honeypot_bypass', '__return_true', PHP_INT_MAX); 35 add_filter('wpforms_process_anti_spam_direct_post_bypass', '__return_true', PHP_INT_MAX); 36 $form_id = (string) $this->form_id; 37 // Custom Captcha addon: validated as field type "captcha" (wpforms_process_validate_captcha). 38 add_action('wpforms_process_validate_captcha', function ($field_id, $field_submit, $form_data) use ($form_id) { 39 if (!is_array($form_data) || !isset($form_data['id']) || (string) $form_data['id'] !== $form_id || !function_exists('wpforms')) { 40 return; 41 } 42 $process = wpforms()->get('process'); 43 if (is_object($process) && isset($process->errors[$form_data['id']][$field_id])) { 44 unset($process->errors[$form_data['id']][$field_id]); 45 } 46 }, PHP_INT_MAX, 3); 27 47 } 28 48 … … 30 50 add_filter('wpforms_entry_email', '__return_false', PHP_INT_MAX); 31 51 } 52 53 /** 54 * With "Optimize Email Sending" (setting email-async), WPForms 1.8.5+ queues each notification as an Action 55 * Scheduler task that a later request sends, outside test mode: a real email that mail capture never sees. Send 56 * the tested form's notifications in this request instead. 57 */ 58 public function sendEmailsInRequest() { 59 $form_id = (string) $this->form_id; 60 add_filter('wpforms_tasks_entry_emails_trigger_send_same_process', function ($same_process, $fields = array(), $entry = array(), $form_data = array()) use ($form_id) { 61 if ($form_id === '' || (is_array($form_data) && isset($form_data['id']) && (string) $form_data['id'] === $form_id)) { 62 return true; 63 } 64 return $same_process; 65 }, PHP_INT_MAX, 4); 66 } 67 68 public function skipMediaLibrary() { 69 $form_id = (string) $this->form_id; 70 add_filter('wpforms_process_before_form_data', function ($form_data) use ($form_id) { 71 if (!is_array($form_data) || !isset($form_data['id'], $form_data['fields']) || (string) $form_data['id'] !== $form_id || !is_array($form_data['fields'])) { 72 return $form_data; 73 } 74 foreach ($form_data['fields'] as $key => $field) { 75 if (is_array($field) && isset($field['type']) && in_array($field['type'], array('file-upload', 'camera'), true) && !empty($field['media_library'])) { 76 $form_data['fields'][$key]['media_library'] = '0'; 77 } 78 } 79 return $form_data; 80 }, PHP_INT_MAX, 1); 81 } 82 83 public function acceptModernUploads() { 84 $form_id = (string) $this->form_id; 85 add_action('wpforms_process_before', function ($entry, $form_data) use ($form_id) { 86 if (!is_array($form_data) || !isset($form_data['id'], $form_data['fields']) || (string) $form_data['id'] !== $form_id || 87 empty($_FILES) || !function_exists('wpforms_upload_dir')) { 88 return; 89 } 90 foreach ((array) $form_data['fields'] as $field) { 91 if (is_array($field) && isset($field['type'], $field['id'], $field['style']) && $field['type'] === 'file-upload' && $field['style'] === 'modern') { 92 BVWPFormHandler::storeModernUpload(sprintf('wpforms_%d_%d', absint($form_data['id']), absint($field['id'])), $field); 93 } 94 } 95 }, 1, 2); 96 } 97 98 /** 99 * Extensions WPForms refuses whatever the site allows (WPForms FileMethodsTrait::$denylist, plus the other PHP 100 * extensions servers may run). 101 */ 102 private static $denied_extensions = array( 103 'ade', 'adp', 'app', 'asp', 'bas', 'bat', 'cer', 'cgi', 'chm', 'cmd', 'com', 'cpl', 'crt', 'csh', 'csr', 'dfxp', 104 'dll', 'drv', 'exe', 'flv', 'fxp', 'hlp', 'hta', 'htaccess', 'htm', 'html', 'htpasswd', 'inf', 'ins', 'isp', 105 'jar', 'js', 'jse', 'jsp', 'ksh', 'lnk', 'mdb', 'mde', 'mdt', 'mdw', 'msc', 'msi', 'msp', 'mst', 'onetmp', 'ops', 106 'pcd', 'phar', 'php', 'php3', 'php4', 'php5', 'php7', 'php8', 'pht', 'phtml', 'pif', 'pl', 'prg', 'ps1', 'ps2', 107 'py', 'rb', 'reg', 'scr', 'sct', 'sh', 'shb', 'shs', 'swf', 'sys', 'tmp', 'torrent', 'url', 'vb', 'vbe', 'vbs', 108 'vbscript', 'wsc', 'wsf', 'wsh' 109 ); 110 111 /** 112 * The extensions a file upload field accepts, as WPForms works them out: the field's list (all when empty), 113 * limited to the file types WordPress allows, without the denied extensions. 114 */ 115 public static function allowedExtensions($field) { 116 $allowed = array(); 117 foreach (array_keys(get_allowed_mime_types()) as $extensions) { 118 foreach (explode('|', $extensions) as $extension) { 119 $allowed[] = strtolower($extension); 120 } 121 } 122 $allowed = array_diff($allowed, self::$denied_extensions); 123 if (is_array($field) && !empty($field['extensions']) && is_string($field['extensions'])) { 124 $listed = array(); 125 foreach (explode(',', $field['extensions']) as $extension) { 126 $listed[] = strtolower(preg_replace('/[^A-Za-z0-9_-]/', '', $extension)); 127 } 128 $allowed = array_intersect($allowed, $listed); 129 } 130 return array_values(array_unique($allowed)); 131 } 132 133 /** 134 * Moves one posted file of a modern upload field into the WPForms tmp folder and posts its JSON description. 135 * A file whose extension or type the field doesn't accept is left out, and stays in PHP's upload folder (deleted 136 * when the request ends), so WPForms reports the field as empty or required. A file moved into the tmp folder that 137 * WPForms doesn't take into the form's folder is deleted when the request ends. 138 */ 139 public static function storeModernUpload($input_name, $field) { 140 // phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput 141 if (!empty($_POST[$input_name]) || !isset($_FILES[$input_name]['tmp_name'], $_FILES[$input_name]['name'], $_FILES[$input_name]['error']) || 142 !is_string($_FILES[$input_name]['tmp_name']) || !is_string($_FILES[$input_name]['name']) || 143 (int) $_FILES[$input_name]['error'] !== UPLOAD_ERR_OK || !is_uploaded_file($_FILES[$input_name]['tmp_name'])) { 144 return; 145 } 146 $file = $_FILES[$input_name]; 147 unset($_FILES[$input_name]); 148 // phpcs:enable 149 150 $name = sanitize_file_name(wp_unslash($file['name'])); 151 $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION)); 152 if ($name === '' || $extension === '' || !in_array($extension, self::allowedExtensions($field), true)) { 153 return; 154 } 155 // WordPress's own check of the name against the content (images are sniffed): refused when it finds no 156 // allowed type, or when it would rename the file. 157 $filetype = wp_check_filetype_and_ext($file['tmp_name'], $name); 158 if (empty($filetype['ext']) || empty($filetype['type']) || !empty($filetype['proper_filename']) || 159 strtolower($filetype['ext']) !== $extension) { 160 return; 161 } 162 163 $upload_dir = wpforms_upload_dir(); 164 if (!is_array($upload_dir) || empty($upload_dir['path']) || empty($upload_dir['url'])) { 165 return; 166 } 167 $tmp_dir = $upload_dir['path'] . '/tmp'; 168 if (!wp_mkdir_p($tmp_dir)) { 169 return; 170 } 171 $tmp_name = wp_hash(wp_rand() . microtime() . $input_name) . '.' . $extension; 172 $tmp_path = $tmp_dir . '/' . $tmp_name; 173 if (!move_uploaded_file($file['tmp_name'], $tmp_path)) { 174 return; 175 } 176 // WPForms moves the file out of the tmp folder when the entry is saved; anything left is a failed submission. 177 add_action('shutdown', function () use ($tmp_path) { 178 if (is_file($tmp_path)) { 179 BVFormTestRecorder::deleteFile($tmp_path); 180 } 181 }); 182 if (function_exists('wpforms_sanitize_svg_file') && !wpforms_sanitize_svg_file($tmp_path)) { 183 BVFormTestRecorder::deleteFile($tmp_path); 184 return; 185 } 186 187 $_POST[$input_name] = wp_slash(BVFormTestRecorder::jsonEncode(array(array( 188 'name' => $name, 189 'file' => $tmp_name, 190 'url' => $upload_dir['url'] . '/tmp/' . $tmp_name, 191 'size' => filesize($tmp_path), 192 'type' => $filetype['type'], 193 'file_user_name' => $name 194 )))); 195 } 32 196 } 33 197 -
blogvault-real-time-backup/tags/6.85/info.php
r3795700 r3813747 12 12 public $brand_option = 'bv_whitelabel_infos'; 13 13 public $wp_lp_whitelabel_option = 'bvLpWhitelabelConf'; 14 public $version = '6.8 3';14 public $version = '6.85'; 15 15 public $webpage = 'https://blogvault.net'; 16 16 public $appurl = 'https://app.blogvault.net'; -
blogvault-real-time-backup/tags/6.85/protect/fw.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectFW_V68 3')) :4 if (!class_exists('BVProtectFW_V685')) : 5 5 require_once dirname( __FILE__ ) . '/fw/rule/errors.php'; 6 6 require_once dirname( __FILE__ ) . '/fw/rule/engine.php'; 7 7 require_once dirname( __FILE__ ) . '/fw/rule.php'; 8 8 9 class BVProtectFW_V68 3{9 class BVProtectFW_V685 { 10 10 private $brand_name; 11 11 private $protect_mode; … … 24 24 private $has_valid_bypass_cookie; 25 25 26 private $mode = BVProtectFW_V68 3::MODE_DISABLED;27 private $ip_cookie_mode = BVProtectFW_V68 3::IP_COOKIE_MODE_DISABLED;28 private $admin_cookie_mode = BVProtectFW_V68 3::ADMIN_COOKIE_MODE_DISABLED;29 private $bypass_level = BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_CONTRIBUTOR;30 private $wpf_rule_init_mode = BVProtectFW_V68 3::WPF_RULE_INIT_MODE_WP;26 private $mode = BVProtectFW_V685::MODE_DISABLED; 27 private $ip_cookie_mode = BVProtectFW_V685::IP_COOKIE_MODE_DISABLED; 28 private $admin_cookie_mode = BVProtectFW_V685::ADMIN_COOKIE_MODE_DISABLED; 29 private $bypass_level = BVProtectFW_V685::WP_USER_ROLE_LEVEL_CONTRIBUTOR; 30 private $wpf_rule_init_mode = BVProtectFW_V685::WPF_RULE_INIT_MODE_WP; 31 31 private $custom_roles = array(); 32 32 private $cookie_key = ""; … … 35 35 private $cookie_validity = 2592000; 36 36 private $can_set_cache_prevention_cookie = false; 37 private $rules_mode = BVProtectFW_V68 3::RULES_MODE_DISABLED;37 private $rules_mode = BVProtectFW_V685::RULES_MODE_DISABLED; 38 38 private $is_geo_blocking = false; 39 39 private $is_wp_user_cookie_enabled = false; 40 40 private $log_config = array(); 41 private $request_profiling_mode = BVProtectFW_V68 3::REQ_PROFILING_MODE_DISABLED;42 private $logging_mode = BVProtectFW_V68 3::LOGGING_MODE_VISITOR;41 private $request_profiling_mode = BVProtectFW_V685::REQ_PROFILING_MODE_DISABLED; 42 private $logging_mode = BVProtectFW_V685::LOGGING_MODE_VISITOR; 43 43 private $skip_log_config = array(); 44 44 private $skip_log_cookies = array(); … … 55 55 private $break_rule_matching = false; 56 56 private $can_log_raw_body = false; 57 private $log_slice_size = BVProtectFW_V68 3::LOG_SLICE_SIZE;57 private $log_slice_size = BVProtectFW_V685::LOG_SLICE_SIZE; 58 58 59 59 private static $instance = null; … … 101 101 102 102 const DEFAULT_WP_USER_ROLE_LEVELS = array( 103 'administrator' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_ADMIN,104 'editor' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_EDITOR,105 'author' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_AUTHOR,106 'contributor' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_CONTRIBUTOR,107 'subscriber' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_SUBSCRIBER103 'administrator' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_ADMIN, 104 'editor' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_EDITOR, 105 'author' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_AUTHOR, 106 'contributor' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_CONTRIBUTOR, 107 'subscriber' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_SUBSCRIBER 108 108 ); 109 109 110 110 const EXTRA_WP_USER_ROLE_LEVELS = array( 111 'custom' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_CUSTOM,112 'unknown' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_UNKNOWN111 'custom' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_CUSTOM, 112 'unknown' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_UNKNOWN 113 113 ); 114 114 … … 249 249 if ($this->isPrependMode()) { 250 250 $log_file = MCDATAPATH . MCCONFKEY . '-mc.log'; 251 $this->ipstore = new BVProtectIpstore_V68 3(BVProtectIpstore_V683::STORAGE_TYPE_FS);252 $this->logger = new BVProtectLogger_V68 3($log_file, BVProtectLogger_V683::TYPE_FS);251 $this->ipstore = new BVProtectIpstore_V685(BVProtectIpstore_V685::STORAGE_TYPE_FS); 252 $this->logger = new BVProtectLogger_V685($log_file, BVProtectLogger_V685::TYPE_FS); 253 253 } else { 254 $this->ipstore = new BVProtectIpstore_V68 3(BVProtectIpstore_V683::STORAGE_TYPE_DB);255 $this->logger = new BVProtectLogger_V68 3(BVProtectFW_V683::TABLE_NAME, BVProtectLogger_V683::TYPE_DB);254 $this->ipstore = new BVProtectIpstore_V685(BVProtectIpstore_V685::STORAGE_TYPE_DB); 255 $this->logger = new BVProtectLogger_V685(BVProtectFW_V685::TABLE_NAME, BVProtectLogger_V685::TYPE_DB); 256 256 } 257 257 … … 266 266 if (!isset(self::$instance)) { 267 267 self::$instance = new self($protect_mode, $request, $config, $brand_name); 268 } elseif (self::$instance->protect_mode != $protect_mode && $protect_mode == BVProtect_V68 3::MODE_WP) {268 } elseif (self::$instance->protect_mode != $protect_mode && $protect_mode == BVProtect_V685::MODE_WP) { 269 269 self::$instance->protect_mode = $protect_mode; 270 270 self::$instance->brand_name = $brand_name; 271 self::$instance->ipstore = new BVProtectIpstore_V68 3(BVProtectIpstore_V683::STORAGE_TYPE_DB);271 self::$instance->ipstore = new BVProtectIpstore_V685(BVProtectIpstore_V685::STORAGE_TYPE_DB); 272 272 self::$instance->initRules(); 273 273 } … … 277 277 278 278 public static function uninstall() { 279 BVProtect_V68 3::$db->dropBVTable(BVProtectFW_V683::TABLE_NAME);279 BVProtect_V685::$db->dropBVTable(BVProtectFW_V685::TABLE_NAME); 280 280 } 281 281 … … 297 297 298 298 private function isPrependMode() { 299 return ($this->protect_mode === BVProtect_V68 3::MODE_PREPEND);299 return ($this->protect_mode === BVProtect_V685::MODE_PREPEND); 300 300 } 301 301 302 302 private function isWPMode() { 303 return ($this->protect_mode === BVProtect_V68 3::MODE_WP);303 return ($this->protect_mode === BVProtect_V685::MODE_WP); 304 304 } 305 305 306 306 private function isModeDisabled() { 307 return ($this->mode === BVProtectFW_V68 3::MODE_DISABLED);307 return ($this->mode === BVProtectFW_V685::MODE_DISABLED); 308 308 } 309 309 310 310 private function isModeProtect() { 311 return ($this->mode === BVProtectFW_V68 3::MODE_PROTECT);311 return ($this->mode === BVProtectFW_V685::MODE_PROTECT); 312 312 } 313 313 314 314 private function isAdminCookieEnabled() { 315 return ($this->admin_cookie_mode === BVProtectFW_V68 3::ADMIN_COOKIE_MODE_ENABLED);315 return ($this->admin_cookie_mode === BVProtectFW_V685::ADMIN_COOKIE_MODE_ENABLED); 316 316 } 317 317 318 318 private function isIPCookieEnabled() { 319 return ($this->ip_cookie_mode === BVProtectFW_V68 3::IP_COOKIE_MODE_ENABLED);319 return ($this->ip_cookie_mode === BVProtectFW_V685::IP_COOKIE_MODE_ENABLED); 320 320 } 321 321 322 322 private function isRequestProfilingDisabled() { 323 return ($this->request_profiling_mode === BVProtectFW_V68 3::REQ_PROFILING_MODE_DISABLED);323 return ($this->request_profiling_mode === BVProtectFW_V685::REQ_PROFILING_MODE_DISABLED); 324 324 } 325 325 326 326 private function isRequestProfilingModeDebug() { 327 return ($this->request_profiling_mode === BVProtectFW_V68 3::REQ_PROFILING_MODE_DEBUG);327 return ($this->request_profiling_mode === BVProtectFW_V685::REQ_PROFILING_MODE_DEBUG); 328 328 } 329 329 330 330 private function isRequestHasValidBypassCookie() { 331 331 if (!isset($this->has_valid_bypass_cookie)) { 332 $cookie = (string) $this->request->getCookies(BVProtectFW_V68 3::BYPASS_COOKIE_NAME);332 $cookie = (string) $this->request->getCookies(BVProtectFW_V685::BYPASS_COOKIE_NAME); 333 333 $new_cookie = $this->generateBypassCookie(); 334 334 $is_valid = ($this->isAdminCookieEnabled() && $new_cookie && ($cookie === $new_cookie)); … … 340 340 341 341 private function isRulesModeProtect() { 342 return ($this->rules_mode === BVProtectFW_V68 3::RULES_MODE_PROTECT);342 return ($this->rules_mode === BVProtectFW_V685::RULES_MODE_PROTECT); 343 343 } 344 344 345 345 public function isLoggingModeComplete() { 346 return ($this->logging_mode === BVProtectFW_V68 3::LOGGING_MODE_COMPLETE);346 return ($this->logging_mode === BVProtectFW_V685::LOGGING_MODE_COMPLETE); 347 347 } 348 348 349 349 public function isLoggingModeVisitor() { 350 return ($this->logging_mode === BVProtectFW_V68 3::LOGGING_MODE_VISITOR);350 return ($this->logging_mode === BVProtectFW_V685::LOGGING_MODE_VISITOR); 351 351 } 352 352 … … 356 356 357 357 private function isWPFRuleInitModePrepend() { 358 return ($this->wpf_rule_init_mode === BVProtectFW_V68 3::WPF_RULE_INIT_MODE_PREPEND);358 return ($this->wpf_rule_init_mode === BVProtectFW_V685::WPF_RULE_INIT_MODE_PREPEND); 359 359 } 360 360 361 361 private function isWPFRuleInitModeWP() { 362 return ($this->wpf_rule_init_mode === BVProtectFW_V68 3::WPF_RULE_INIT_MODE_WP);362 return ($this->wpf_rule_init_mode === BVProtectFW_V685::WPF_RULE_INIT_MODE_WP); 363 363 } 364 364 … … 389 389 390 390 if (!$current_wp_user->isIdentical($this->request->wp_user)) { 391 $serialized_wp_user = BVProtectWPUser_V68 3::_serialize($current_wp_user);391 $serialized_wp_user = BVProtectWPUser_V685::_serialize($current_wp_user); 392 392 $cookie_val = $serialized_wp_user . '_' . 393 BVProtectUtils_V68 3::signMessage($serialized_wp_user, $this->cookie_key);393 BVProtectUtils_V685::signMessage($serialized_wp_user, $this->cookie_key); 394 394 $cookie_val = base64_encode($cookie_val); 395 395 396 $this->setCookie(BVProtectWPUser_V68 3::COOKIE_NAME, $cookie_val);396 $this->setCookie(BVProtectWPUser_V685::COOKIE_NAME, $cookie_val); 397 397 } 398 398 } elseif ($this->request->wp_user->isLoggedIn()) { 399 $this->request->wp_user = BVProtectWPUser_V68 3::defaultUser();400 $this->unsetCookie(BVProtectWPUser_V68 3::COOKIE_NAME);399 $this->request->wp_user = BVProtectWPUser_V685::defaultUser(); 400 $this->unsetCookie(BVProtectWPUser_V685::COOKIE_NAME); 401 401 } 402 402 } … … 415 415 } 416 416 417 return (new BVProtectWPUser_V68 3($id, $role_level, $capabilities, $time));417 return (new BVProtectWPUser_V685($id, $role_level, $capabilities, $time)); 418 418 } 419 419 … … 434 434 435 435 private function loadWPUser() { 436 $this->request->wp_user = BVProtectWPUser_V68 3::defaultUser();437 438 $cookie_val = $this->request->getCookies(BVProtectWPUser_V68 3::COOKIE_NAME);436 $this->request->wp_user = BVProtectWPUser_V685::defaultUser(); 437 438 $cookie_val = $this->request->getCookies(BVProtectWPUser_V685::COOKIE_NAME); 439 439 if (!is_string($cookie_val)) { 440 440 return; … … 452 452 list($serialized_user, $signature) = $cookie_val_array; 453 453 454 if (BVProtectUtils_V68 3::verifyMessage($serialized_user, $signature, $this->cookie_key) === true) {455 $wp_user = BVProtectWPUser_V68 3::_unserialize($serialized_user);454 if (BVProtectUtils_V685::verifyMessage($serialized_user, $signature, $this->cookie_key) === true) { 455 $wp_user = BVProtectWPUser_V685::_unserialize($serialized_user); 456 456 457 457 if (!isset($wp_user) || $wp_user->time !== (int) floor(time() / $this->cookie_validity)) { … … 468 468 } 469 469 470 $role_by_level = array_flip(array_merge(BVProtectFW_V68 3::DEFAULT_WP_USER_ROLE_LEVELS,471 BVProtectFW_V68 3::EXTRA_WP_USER_ROLE_LEVELS));470 $role_by_level = array_flip(array_merge(BVProtectFW_V685::DEFAULT_WP_USER_ROLE_LEVELS, 471 BVProtectFW_V685::EXTRA_WP_USER_ROLE_LEVELS)); 472 472 $this->request->wp_user->role = $role_by_level[$this->request->wp_user->role_level]; 473 473 } … … 493 493 if ($this->isPrependMode()) { 494 494 $rules_file = MCDATAPATH . MCCONFKEY . '-' . 'mc_rules.json'; 495 $rule_arrays = BVProtectUtils_V68 3::parseFile($rules_file);495 $rule_arrays = BVProtectUtils_V685::parseFile($rules_file); 496 496 } else { 497 $rule_arrays = BVProtect_V68 3::$settings->getOption('bvruleset');497 $rule_arrays = BVProtect_V685::$settings->getOption('bvruleset'); 498 498 if(!is_array($rule_arrays)) { 499 499 $rule_arrays = array(); … … 507 507 508 508 foreach($rule_arrays as $rule_array) { 509 $rule = BVProtectFWRule_V68 3::init($rule_array);509 $rule = BVProtectFWRule_V685::init($rule_array); 510 510 511 511 if ($rule) { … … 532 532 private function initWPFRule($rule) { 533 533 switch ($rule->execute_on) { 534 case BVProtectFWRule_V68 3::EXE_ON_PRE_UPDATE_OPTION:534 case BVProtectFWRule_V685::EXE_ON_PRE_UPDATE_OPTION: 535 535 $this->addWPHook($rule, 'pre_update_option', 'handleRequestOnPreUpdateOption', 3); 536 536 break; 537 case BVProtectFWRule_V68 3::EXE_ON_PRE_DELETE_POST:537 case BVProtectFWRule_V685::EXE_ON_PRE_DELETE_POST: 538 538 $this->addWPHook($rule, 'pre_delete_post', 'handleRequestOnPreDeletePost', 3); 539 539 break; 540 case BVProtectFWRule_V68 3::EXE_ON_WP_INSERT_POST_EMPTY_CONTENT:540 case BVProtectFWRule_V685::EXE_ON_WP_INSERT_POST_EMPTY_CONTENT: 541 541 $this->addWPHook($rule, 'wp_insert_post_empty_content', 542 542 'handleRequestOnWPInsertPostEmptyContent', 2); 543 543 break; 544 case BVProtectFWRule_V68 3::EXE_ON_INSERT_USER_META:544 case BVProtectFWRule_V685::EXE_ON_INSERT_USER_META: 545 545 $this->addWPHook($rule, 'insert_user_meta', 'handleRequestOnInsertUserMeta', 4); 546 546 break; 547 case BVProtectFWRule_V68 3::EXE_ON_DELETE_OPTION:547 case BVProtectFWRule_V685::EXE_ON_DELETE_OPTION: 548 548 $this->addWPHook($rule, 'delete_option', 'handleRequestOnDeleteOption', 1, 'action'); 549 549 break; 550 case BVProtectFWRule_V68 3::EXE_ON_DELETE_USER:550 case BVProtectFWRule_V685::EXE_ON_DELETE_USER: 551 551 $this->addWPHook($rule, 'delete_user', 'handleRequestOnDeleteUser', 3, 'action'); 552 552 break; 553 case BVProtectFWRule_V68 3::EXE_ON_PASSWORD_RESET:553 case BVProtectFWRule_V685::EXE_ON_PASSWORD_RESET: 554 554 $this->addWPHook($rule, 'password_reset', 'handleRequestOnPasswordReset', 2, 'action'); 555 555 break; 556 case BVProtectFWRule_V68 3::EXE_ON_SEND_AUTH_COOKIES:556 case BVProtectFWRule_V685::EXE_ON_SEND_AUTH_COOKIES: 557 557 $this->addWPHook($rule, 'send_auth_cookies', 'handleRequestOnSendAuthCookies', 6); 558 558 break; 559 case BVProtectFWRule_V68 3::EXE_ON_SET_AUTH_COOKIE:559 case BVProtectFWRule_V685::EXE_ON_SET_AUTH_COOKIE: 560 560 $this->addWPHook($rule, 'set_auth_cookie', 'handleRequestOnSetAuthCookie', 6, 'action'); 561 561 break; 562 case BVProtectFWRule_V68 3::EXE_ON_INIT:562 case BVProtectFWRule_V685::EXE_ON_INIT: 563 563 $this->addWPHook($rule, 'init', 'handleRequestOnInit', 0, 'action'); 564 564 break; 565 case BVProtectFWRule_V68 3::EXE_ON_USER_REGISTER:565 case BVProtectFWRule_V685::EXE_ON_USER_REGISTER: 566 566 $this->addWPHook($rule, 'user_register', 'handleRequestOnUserRegister', 2, 'action'); 567 567 break; 568 case BVProtectFWRule_V68 3::EXE_ON_ADD_USER_META:568 case BVProtectFWRule_V685::EXE_ON_ADD_USER_META: 569 569 $this->addWPHook($rule, 'add_user_meta', 'handleRequestOnAddUserMeta', 3, 'action'); 570 570 break; 571 case BVProtectFWRule_V68 3::EXE_ON_UPDATE_USER_METADATA:571 case BVProtectFWRule_V685::EXE_ON_UPDATE_USER_METADATA: 572 572 $this->addWPHook($rule, 'update_user_metadata', 'handleRequestOnUpdateUserMetadata', 5); 573 573 break; 574 case BVProtectFWRule_V68 3::EXE_ON_UPDATE_USER_META:574 case BVProtectFWRule_V685::EXE_ON_UPDATE_USER_META: 575 575 $this->addWPHook($rule, 'update_user_meta', 'handleRequestOnUpdateUserMeta', 4, 'action'); 576 576 break; 577 case BVProtectFWRule_V68 3::EXE_ON_ADD_OPTION:577 case BVProtectFWRule_V685::EXE_ON_ADD_OPTION: 578 578 $this->addWPHook($rule, 'add_option', 'handleRequestOnAddOption', 2, 'action'); 579 579 break; 580 case BVProtectFWRule_V68 3::EXE_ON_WP_PRE_INSERT_USER_DATA:580 case BVProtectFWRule_V685::EXE_ON_WP_PRE_INSERT_USER_DATA: 581 581 $this->addWPHook($rule, 'wp_pre_insert_user_data', 'handleRequestOnWPPreInsertUserData', 4); 582 582 break; 583 case BVProtectFWRule_V68 3::EXE_ON_REST_REQUEST_BEFORE_CALLBACKS:583 case BVProtectFWRule_V685::EXE_ON_REST_REQUEST_BEFORE_CALLBACKS: 584 584 $this->addWPHook($rule, 'rest_request_before_callbacks', 585 585 'handleRequestOnRestRequestBeforeCallbacks', 3); 586 586 break; 587 case BVProtectFWRule_V68 3::EXE_ON_ADMIN_INIT:587 case BVProtectFWRule_V685::EXE_ON_ADMIN_INIT: 588 588 $this->addWPHook($rule, 'admin_init', 'handleRequestOnAdminInit', 0, 'action'); 589 589 break; 590 case BVProtectFWRule_V68 3::EXE_ON_WP_HANDLE_UPLOAD_PREFILTER:590 case BVProtectFWRule_V685::EXE_ON_WP_HANDLE_UPLOAD_PREFILTER: 591 591 $this->addWPHook($rule, 'wp_handle_upload_prefilter', 592 592 'handleRequestOnWPHandleUploadPrefilter', 1); 593 593 break; 594 case BVProtectFWRule_V68 3::EXE_ON_TEMPLATE_REDIRECT:594 case BVProtectFWRule_V685::EXE_ON_TEMPLATE_REDIRECT: 595 595 $this->addWPHook($rule, 'template_redirect', 'handleRequestOnTemplateRedirect', 0, 'action'); 596 596 break; 597 case BVProtectFWRule_V68 3::EXE_ON_WP_LOADED:597 case BVProtectFWRule_V685::EXE_ON_WP_LOADED: 598 598 $this->addWPHook($rule, 'wp_loaded', 'handleRequestOnWPLoaded', 0, 'action'); 599 599 break; 600 case BVProtectFWRule_V68 3::EXE_ON_ADD_POST_METADATA:600 case BVProtectFWRule_V685::EXE_ON_ADD_POST_METADATA: 601 601 $this->addWPHook($rule, 'add_post_metadata', 'handleRequestOnAddPostMetadata', 5); 602 602 break; 603 case BVProtectFWRule_V68 3::EXE_ON_UPDATE_POST_METADATA:603 case BVProtectFWRule_V685::EXE_ON_UPDATE_POST_METADATA: 604 604 $this->addWPHook($rule, 'update_post_metadata', 'handleRequestOnUpdatePostMetadata', 5); 605 605 break; 606 case BVProtectFWRule_V68 3::EXE_ON_DELETE_POST_METADATA:606 case BVProtectFWRule_V685::EXE_ON_DELETE_POST_METADATA: 607 607 $this->addWPHook($rule, 'delete_post_metadata', 'handleRequestOnDeletePostMetadata', 5); 608 608 break; 609 case BVProtectFWRule_V68 3::EXE_ON_ADD_TERM_METADATA:609 case BVProtectFWRule_V685::EXE_ON_ADD_TERM_METADATA: 610 610 $this->addWPHook($rule, 'add_term_metadata', 'handleRequestOnAddTermMetadata', 5); 611 611 break; 612 case BVProtectFWRule_V68 3::EXE_ON_UPDATE_TERM_METADATA:612 case BVProtectFWRule_V685::EXE_ON_UPDATE_TERM_METADATA: 613 613 $this->addWPHook($rule, 'update_term_metadata', 'handleRequestOnUpdateTermMetadata', 5); 614 614 break; 615 case BVProtectFWRule_V68 3::EXE_ON_DELETE_TERM_METADATA:615 case BVProtectFWRule_V685::EXE_ON_DELETE_TERM_METADATA: 616 616 $this->addWPHook($rule, 'delete_term_metadata', 'handleRequestOnDeleteTermMetadata', 5); 617 617 break; 618 case BVProtectFWRule_V68 3::EXE_ON_ADD_COMMENT_METADATA:618 case BVProtectFWRule_V685::EXE_ON_ADD_COMMENT_METADATA: 619 619 $this->addWPHook($rule, 'add_comment_metadata', 'handleRequestOnAddCommentMetadata', 5); 620 620 break; 621 case BVProtectFWRule_V68 3::EXE_ON_UPDATE_COMMENT_METADATA:621 case BVProtectFWRule_V685::EXE_ON_UPDATE_COMMENT_METADATA: 622 622 $this->addWPHook($rule, 'update_comment_metadata', 'handleRequestOnUpdateCommentMetadata', 5); 623 623 break; 624 case BVProtectFWRule_V68 3::EXE_ON_DELETE_COMMENT_METADATA:624 case BVProtectFWRule_V685::EXE_ON_DELETE_COMMENT_METADATA: 625 625 $this->addWPHook($rule, 'delete_comment_metadata', 'handleRequestOnDeleteCommentMetadata', 5); 626 626 break; 627 case BVProtectFWRule_V68 3::EXE_ON_ADD_USER_METADATA:627 case BVProtectFWRule_V685::EXE_ON_ADD_USER_METADATA: 628 628 $this->addWPHook($rule, 'add_user_metadata', 'handleRequestOnAddUserMetadata', 5); 629 629 break; 630 case BVProtectFWRule_V68 3::EXE_ON_DELETE_USER_METADATA:630 case BVProtectFWRule_V685::EXE_ON_DELETE_USER_METADATA: 631 631 $this->addWPHook($rule, 'delete_user_metadata', 'handleRequestOnDeleteUserMetadata', 5); 632 632 break; … … 646 646 } 647 647 } else { 648 BVProtectUtils_V68 3::preInitWPHook($hook_name, $callback, -9999999, $accepted_args);648 BVProtectUtils_V685::preInitWPHook($hook_name, $callback, -9999999, $accepted_args); 649 649 } 650 650 } … … 1204 1204 private function setIPCookie() { 1205 1205 if (!$this->is_ip_cookie_set && $this->isIPCookieEnabled() && 1206 !$this->request->getCookies(BVProtectFW_V68 3::IP_COOKIE_NAME)) {1206 !$this->request->getCookies(BVProtectFW_V685::IP_COOKIE_NAME)) { 1207 1207 1208 1208 $time = floor(time() / 86400); 1209 1209 $cookie = hash('sha256', $this->request->ip . $time . $this->cookie_key); 1210 1210 if ($cookie) { 1211 $this->setCookie(BVProtectFW_V68 3::IP_COOKIE_NAME, $cookie, time() + 86400);1211 $this->setCookie(BVProtectFW_V685::IP_COOKIE_NAME, $cookie, time() + 86400); 1212 1212 } 1213 1213 } … … 1217 1217 if (function_exists('current_user_can')) { 1218 1218 if (function_exists('is_super_admin') && is_super_admin()) { 1219 return BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_ADMIN;1219 return BVProtectFW_V685::WP_USER_ROLE_LEVEL_ADMIN; 1220 1220 } 1221 1221 1222 1222 foreach ($this->custom_roles as $role) { 1223 1223 if (current_user_can($role)) { 1224 return BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_CUSTOM;1224 return BVProtectFW_V685::WP_USER_ROLE_LEVEL_CUSTOM; 1225 1225 } 1226 1226 } 1227 1227 1228 foreach (BVProtectFW_V68 3::DEFAULT_WP_USER_ROLE_LEVELS as $role => $level) {1228 foreach (BVProtectFW_V685::DEFAULT_WP_USER_ROLE_LEVELS as $role => $level) { 1229 1229 if (current_user_can($role)) { 1230 1230 return $level; … … 1334 1334 $cookies = array(); 1335 1335 1336 if ($this->request->getCookies(BVProtectFW_V68 3::IP_COOKIE_NAME) !== NULL) {1337 $cookie_val = (string) $this->request->getCookies(BVProtectFW_V68 3::IP_COOKIE_NAME);1338 $cookies[BVProtectFW_V68 3::IP_COOKIE_NAME] = $cookie_val;1336 if ($this->request->getCookies(BVProtectFW_V685::IP_COOKIE_NAME) !== NULL) { 1337 $cookie_val = (string) $this->request->getCookies(BVProtectFW_V685::IP_COOKIE_NAME); 1338 $cookies[BVProtectFW_V685::IP_COOKIE_NAME] = $cookie_val; 1339 1339 } 1340 1340 … … 1500 1500 1501 1501 private function getUserBy($attribute, $value) { 1502 if (isset($value) && function_exists('get_user_by') && BVProtectUtils_V68 3::havePluginsLoaded()) {1502 if (isset($value) && function_exists('get_user_by') && BVProtectUtils_V685::havePluginsLoaded()) { 1503 1503 return get_user_by($attribute, $value); 1504 1504 } … … 1604 1604 } 1605 1605 1606 if ($this->matchCount(BVProtectFWRule_V68 3::SQLIREGEX, $value) > 2) {1606 if ($this->matchCount(BVProtectFWRule_V685::SQLIREGEX, $value) > 2) { 1607 1607 $profiled_data[$key]["sql"] = true; 1608 1608 } … … 1693 1693 private function canRequestBypassFirewall() { 1694 1694 if ($this->isRequestIPWhitelisted() || $this->isRequestHasValidBypassCookie()) { 1695 $this->request->category = BVProtectRequest_V68 3::CATEGORY_WHITELISTED;1696 $this->request->status = BVProtectRequest_V68 3::STATUS_BYPASSED;1695 $this->request->category = BVProtectRequest_V685::CATEGORY_WHITELISTED; 1696 $this->request->status = BVProtectRequest_V685::STATUS_BYPASSED; 1697 1697 1698 1698 return true; 1699 } elseif (BVProtectUtils_V68 3::isPrivateIP($this->request->ip)) {1700 $this->request->category = BVProtectRequest_V68 3::CATEGORY_PRIVATEIP;1701 $this->request->status = BVProtectRequest_V68 3::STATUS_BYPASSED;1699 } elseif (BVProtectUtils_V685::isPrivateIP($this->request->ip)) { 1700 $this->request->category = BVProtectRequest_V685::CATEGORY_PRIVATEIP; 1701 $this->request->status = BVProtectRequest_V685::STATUS_BYPASSED; 1702 1702 1703 1703 return true; … … 1723 1723 1724 1724 private function handleRequestOnRuleMatch($rules, $engine_vars = array(), $log_data = array()) { 1725 $normalized_engine_vars = BVProtectFWRuleEngine_V68 3::normalizeVariables($engine_vars);1725 $normalized_engine_vars = BVProtectFWRuleEngine_V685::normalizeVariables($engine_vars); 1726 1726 1727 1727 foreach ($rules as $rule) { … … 1733 1733 if (array_key_exists('variables', $rule->opts)) { 1734 1734 $_engine_vars = array_merge($_engine_vars, 1735 BVProtectFWRuleEngine_V68 3::normalizeVariables($rule->opts['variables']));1736 } 1737 1738 $rule_engine = new BVProtectFWRuleEngine_V68 3($this->request, $_engine_vars);1735 BVProtectFWRuleEngine_V685::normalizeVariables($rule->opts['variables'])); 1736 } 1737 1738 $rule_engine = new BVProtectFWRuleEngine_V685($this->request, $_engine_vars); 1739 1739 1740 1740 if ($rule_engine->evaluate($rule) && !$rule_engine->hasError()) { … … 1749 1749 case "ALLOW": 1750 1750 $this->break_rule_matching = true; 1751 $this->request->category = BVProtectRequest_V68 3::CATEGORY_RULE_ALLOWED;1751 $this->request->category = BVProtectRequest_V685::CATEGORY_RULE_ALLOWED; 1752 1752 return; 1753 1753 case "BLOCK": 1754 1754 if ($this->isModeProtect()) { 1755 $this->terminateRequest(BVProtectRequest_V68 3::CATEGORY_RULE_BLOCKED);1755 $this->terminateRequest(BVProtectRequest_V685::CATEGORY_RULE_BLOCKED); 1756 1756 } 1757 1757 return; … … 1769 1769 private function terminateRequest($category) { 1770 1770 $this->request->category = $category; 1771 $this->request->status = BVProtectRequest_V68 3::STATUS_BLOCKED;1771 $this->request->status = BVProtectRequest_V685::STATUS_BLOCKED; 1772 1772 $this->request->setRespCode(403); 1773 1773 1774 1774 if ($this->can_set_cache_prevention_cookie && 1775 !$this->request->getCookies(BVProtectFW_V68 3::PREVENT_CACHE_COOKIE_NAME)) {1775 !$this->request->getCookies(BVProtectFW_V685::PREVENT_CACHE_COOKIE_NAME)) { 1776 1776 $value = "Prevent Caching Response."; 1777 $this->setCookie(BVProtectFW_V68 3::PREVENT_CACHE_COOKIE_NAME, $value, time() + 43200);1777 $this->setCookie(BVProtectFW_V685::PREVENT_CACHE_COOKIE_NAME, $value, time() + 43200); 1778 1778 } 1779 1779 … … 1803 1803 $cookie = $this->generateBypassCookie(); 1804 1804 if ($cookie) { 1805 $this->setCookie(BVProtectFW_V68 3::BYPASS_COOKIE_NAME, $cookie);1805 $this->setCookie(BVProtectFW_V685::BYPASS_COOKIE_NAME, $cookie); 1806 1806 } 1807 1807 } -
blogvault-real-time-backup/tags/6.85/protect/fw/rule.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectFWRule_V68 3')) :5 class BVProtectFWRule_V68 3{4 if (!class_exists('BVProtectFWRule_V685')) : 5 class BVProtectFWRule_V685 { 6 6 public $id; 7 7 public $logic; … … 105 105 106 106 if (!array_key_exists('min_rule_engine_ver', $attributes) || !is_float($attributes['min_rule_engine_ver']) || 107 $attributes['min_rule_engine_ver'] > BVProtectFWRuleEngine_V68 3::VERSION) {107 $attributes['min_rule_engine_ver'] > BVProtectFWRuleEngine_V685::VERSION) { 108 108 109 109 return false; … … 111 111 112 112 if (array_key_exists('max_rule_engine_ver', $attributes) && (!is_float($attributes['max_rule_engine_ver']) || 113 $attributes['max_rule_engine_ver'] < BVProtectFWRuleEngine_V68 3::VERSION)) {113 $attributes['max_rule_engine_ver'] < BVProtectFWRuleEngine_V685::VERSION)) { 114 114 115 115 return false; … … 130 130 if (!array_key_exists('execute_on', $attributes)) { 131 131 if (array_key_exists('level', $attributes) && $attributes['level'] === 1) { 132 $attributes['execute_on'] = BVProtectFWRule_V68 3::EXE_ON_BOOT;132 $attributes['execute_on'] = BVProtectFWRule_V685::EXE_ON_BOOT; 133 133 } else { 134 134 return false; … … 136 136 } 137 137 138 return new BVProtectFWRule_V68 3($attributes);138 return new BVProtectFWRule_V685($attributes); 139 139 } 140 140 141 141 public function isExeOnBoot() { 142 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_BOOT);142 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_BOOT); 143 143 } 144 144 145 145 public function isExeOnPreUpdateOption() { 146 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_PRE_UPDATE_OPTION);146 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_PRE_UPDATE_OPTION); 147 147 } 148 148 149 149 public function isExeOnPreDeletePost() { 150 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_PRE_DELETE_POST);150 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_PRE_DELETE_POST); 151 151 } 152 152 153 153 public function isExeOnWPInsertPostEmptyContent() { 154 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_WP_INSERT_POST_EMPTY_CONTENT);154 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_WP_INSERT_POST_EMPTY_CONTENT); 155 155 } 156 156 157 157 public function isExeOnInsertUserMeta() { 158 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_INSERT_USER_META);158 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_INSERT_USER_META); 159 159 } 160 160 161 161 public function isExeOnDeleteOption() { 162 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_DELETE_OPTION);162 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_DELETE_OPTION); 163 163 } 164 164 165 165 public function isExeOnDeleteUser() { 166 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_DELETE_USER);166 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_DELETE_USER); 167 167 } 168 168 169 169 public function isExeOnPasswordReset() { 170 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_PASSWORD_RESET);170 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_PASSWORD_RESET); 171 171 } 172 172 173 173 public function isExeOnSendAuthCookies() { 174 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_SEND_AUTH_COOKIES);174 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_SEND_AUTH_COOKIES); 175 175 } 176 176 177 177 public function isExeOnSetAuthCookie() { 178 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_SET_AUTH_COOKIE);178 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_SET_AUTH_COOKIE); 179 179 } 180 180 181 181 public function isExeOnInit() { 182 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_INIT);182 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_INIT); 183 183 } 184 184 185 185 public function isExeOnUserRegister() { 186 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_USER_REGISTER);186 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_USER_REGISTER); 187 187 } 188 188 189 189 public function isExeOnAddUserMeta() { 190 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_ADD_USER_META);190 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_ADD_USER_META); 191 191 } 192 192 193 193 public function isExeOnUpdateUserMetadata() { 194 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_UPDATE_USER_METADATA);194 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_UPDATE_USER_METADATA); 195 195 } 196 196 197 197 public function isExeOnUpdateUserMeta() { 198 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_UPDATE_USER_META);198 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_UPDATE_USER_META); 199 199 } 200 200 201 201 public function isExeOnAddOption() { 202 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_ADD_OPTION);202 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_ADD_OPTION); 203 203 } 204 204 205 205 public function isExeOnWpPreInsertUserData() { 206 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_WP_PRE_INSERT_USER_DATA);206 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_WP_PRE_INSERT_USER_DATA); 207 207 } 208 208 } -
blogvault-real-time-backup/tags/6.85/protect/fw/rule/engine.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!class_exists('BVProtectFWRuleEngine_V68 3')) :5 if (!class_exists('BVProtectFWRuleEngine_V685')) : 6 6 require_once dirname( __FILE__ ) . '/functions.php'; 7 7 8 class BVProtectFWRuleEngine_V68 3{9 use BVProtectFWRuleStringFunc_V68 3;10 use BVProtectFWRuleArrayFunc_V68 3;11 use BVProtectFWRuleMiscFunc_V68 3;12 use BVProtectFWRuleRequestFunc_V68 3;13 use BVProtectFWRuleWPFunc_V68 3;8 class BVProtectFWRuleEngine_V685 { 9 use BVProtectFWRuleStringFunc_V685; 10 use BVProtectFWRuleArrayFunc_V685; 11 use BVProtectFWRuleMiscFunc_V685; 12 use BVProtectFWRuleRequestFunc_V685; 13 use BVProtectFWRuleWPFunc_V685; 14 14 15 15 private $request; … … 26 26 const WILDCARD_KEY = '*'; 27 27 const FUNC_NAME_PREFIX = '_rf_'; 28 const CONST_NAME_PREFIX = 'BVProtectFWRule_V68 3::';28 const CONST_NAME_PREFIX = 'BVProtectFWRule_V685::'; 29 29 const ALLOWED_EXT_CONSTANTS = [ 30 30 'DOING_CRON' … … 53 53 try { 54 54 return $this->executeStmt($rule->logic); 55 } catch (BVProtectRuleError_V68 3$e) {55 } catch (BVProtectRuleError_V685 $e) { 56 56 $this->error = $e; 57 57 } … … 124 124 private function getValue($stmt) { 125 125 if (!is_array($stmt) || empty($stmt["type"])) { 126 throw new BVProtectRuleError_V68 3(126 throw new BVProtectRuleError_V685( 127 127 $this->addExState("InvalidStatementError: Malformed value statement")); 128 128 } … … 133 133 case "NUMBER": 134 134 if (!isset($stmt["value"]) || !is_int($stmt["value"])) { 135 throw new BVProtectRuleError_V68 3(135 throw new BVProtectRuleError_V685( 136 136 $this->addExState("TypeError: Value is not a number") 137 137 ); … … 141 141 case "STRING": 142 142 if (!isset($stmt["value"]) || !is_string($stmt["value"])) { 143 throw new BVProtectRuleError_V68 3(143 throw new BVProtectRuleError_V685( 144 144 $this->addExState("TypeError: Value is not a string") 145 145 ); … … 149 149 case "BOOL": 150 150 if (!isset($stmt["value"]) || !is_bool($stmt["value"])) { 151 throw new BVProtectRuleError_V68 3(151 throw new BVProtectRuleError_V685( 152 152 $this->addExState("TypeError: Value is not a boolean") 153 153 ); … … 157 157 case "CONST": 158 158 if (!isset($stmt["value"]) || !is_string($stmt["value"])) { 159 throw new BVProtectRuleError_V68 3(159 throw new BVProtectRuleError_V685( 160 160 $this->addExState("TypeError: Invalid constant name") 161 161 ); … … 169 169 170 170 if (!defined($name)) { 171 throw new BVProtectRuleError_V68 3(171 throw new BVProtectRuleError_V685( 172 172 $this->addExState("TypeError: Undefined constant" . $stmt["value"]) 173 173 ); … … 177 177 case "ARRAY": 178 178 if (!isset($stmt["value"]) || !is_array($stmt["value"])) { 179 throw new BVProtectRuleError_V68 3(179 throw new BVProtectRuleError_V685( 180 180 $this->addExState("TypeError: Value is not a array") 181 181 ); … … 208 208 private function executeStmt($stmt) { 209 209 if (!is_array($stmt) || empty($stmt["type"])) { 210 throw new BVProtectRuleError_V68 3(210 throw new BVProtectRuleError_V685( 211 211 $this->addExState("InvalidStatementError: Malformed logic statement") 212 212 ); … … 220 220 case "AND": 221 221 if (empty($stmt["left_operand"]) || empty($stmt["right_operand"])) { 222 throw new BVProtectRuleError_V68 3(222 throw new BVProtectRuleError_V685( 223 223 $this->addExState("InvalidOperandError: Malformed operand(s)") 224 224 ); … … 229 229 case "OR": 230 230 if (empty($stmt["left_operand"]) || empty($stmt["right_operand"])) { 231 throw new BVProtectRuleError_V68 3(231 throw new BVProtectRuleError_V685( 232 232 $this->addExState("InvalidOperandError: Malformed operand(s)") 233 233 ); … … 238 238 case "NOT": 239 239 if (empty($stmt["value"])) { 240 throw new BVProtectRuleError_V68 3(240 throw new BVProtectRuleError_V685( 241 241 $this->addExState("InvalidOperandError: Malformed operand") 242 242 ); … … 247 247 case "FUNCTION": 248 248 if (empty($stmt["name"]) || !is_string($stmt["name"])) { 249 throw new BVProtectRuleError_V68 3(249 throw new BVProtectRuleError_V685( 250 250 $this->addExState("InvalidFunctionName: Malformed name") 251 251 ); … … 256 256 257 257 if (!is_callable($handler)) { 258 throw new BVProtectRuleError_V68 3(258 throw new BVProtectRuleError_V685( 259 259 $this->addExState("UndefinedFunctionCall: " . $stmt["name"]) 260 260 ); … … 262 262 263 263 if (!array_key_exists('args', $stmt) || !is_array($stmt['args'])) { 264 throw new BVProtectRuleError_V68 3(264 throw new BVProtectRuleError_V685( 265 265 $this->addExState("InvalidArguments: Malformed args") 266 266 ); … … 275 275 break; 276 276 default: 277 throw new BVProtectRuleError_V68 3(277 throw new BVProtectRuleError_V685( 278 278 $this->addExState("UnknownOperation: -") 279 279 ); … … 286 286 private function processRuleFunctionParams($func_name, $args_cnt, $args, $required_params = 0, $param_types = array()) { 287 287 if (($args_cnt < $required_params)) { 288 throw new BVProtectRuleError_V68 3(288 throw new BVProtectRuleError_V685( 289 289 $this->addExState("ArgumentCountError: Too few arguments for " . $func_name) 290 290 ); … … 293 293 foreach ($param_types as $pos => $type) { 294 294 if (!is_int($pos)) { 295 throw new BVProtectRuleError_V68 3(295 throw new BVProtectRuleError_V685( 296 296 $this->addExState("InvalidParamType: " . $pos) 297 297 ); … … 301 301 case "string": 302 302 if (!isset($args[$pos]) || !is_string($args[$pos])) { 303 throw new BVProtectRuleError_V68 3(303 throw new BVProtectRuleError_V685( 304 304 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not a string.") 305 305 ); … … 308 308 case 'integer': 309 309 if (!isset($args[$pos]) || !is_int($args[$pos])) { 310 throw new BVProtectRuleError_V68 3(310 throw new BVProtectRuleError_V685( 311 311 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not a integer.") 312 312 ); … … 315 315 case 'double': 316 316 if (!isset($args[$pos]) || !is_double($args[$pos])) { 317 throw new BVProtectRuleError_V68 3(317 throw new BVProtectRuleError_V685( 318 318 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not a double.") 319 319 ); … … 322 322 case 'boolean': 323 323 if (!isset($args[$pos]) || !is_bool($args[$pos])) { 324 throw new BVProtectRuleError_V68 3(324 throw new BVProtectRuleError_V685( 325 325 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not a boolean.") 326 326 ); … … 329 329 case 'array': 330 330 if (!isset($args[$pos]) || !is_array($args[$pos])) { 331 throw new BVProtectRuleError_V68 3(331 throw new BVProtectRuleError_V685( 332 332 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not an array.") 333 333 ); … … 337 337 break; 338 338 default: 339 throw new BVProtectRuleError_V68 3(339 throw new BVProtectRuleError_V685( 340 340 $this->addExState("InvalidParamTypeError: Invalid type at " . $pos . " for " . $func_name) 341 341 ); -
blogvault-real-time-backup/tags/6.85/protect/fw/rule/errors.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectRuleError_V68 3')) :5 class BVProtectRuleError_V68 3extends Exception {4 if (!class_exists('BVProtectRuleError_V685')) : 5 class BVProtectRuleError_V685 extends Exception { 6 6 //Root rule error class. 7 7 } -
blogvault-real-time-backup/tags/6.85/protect/fw/rule/functions/array.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!trait_exists('BVProtectFWRuleArrayFunc_V68 3')) :6 trait BVProtectFWRuleArrayFunc_V68 3{5 if (!trait_exists('BVProtectFWRuleArrayFunc_V685')) : 6 trait BVProtectFWRuleArrayFunc_V685 { 7 7 private function _rf_inArray() { 8 8 $args = $this->processRuleFunctionParams( … … 17 17 18 18 if (!is_array($array)) { 19 throw new BVProtectRuleError_V68 3(19 throw new BVProtectRuleError_V685( 20 20 $this->addExState("inArray: 2nd param is not an array") 21 21 ); … … 23 23 24 24 if (!is_bool($strict)) { 25 throw new BVProtectRuleError_V68 3(25 throw new BVProtectRuleError_V685( 26 26 $this->addExState("inArray: 3rd param is not a boolean") 27 27 ); … … 54 54 } 55 55 } else { 56 throw new BVProtectRuleError_V68 3(56 throw new BVProtectRuleError_V685( 57 57 $this->addExState("recInArray: Expects an array") 58 58 ); … … 73 73 74 74 if (!is_array($array)) { 75 throw new BVProtectRuleError_V68 3(75 throw new BVProtectRuleError_V685( 76 76 $this->addExState("arrayKeyExists: Array must be of type array") 77 77 ); 78 78 } elseif (!is_string($key) && !is_int($key)) { 79 throw new BVProtectRuleError_V68 3(79 throw new BVProtectRuleError_V685( 80 80 $this->addExState("arrayKeyExists: Key must be of type string or int") 81 81 ); … … 110 110 111 111 if (!is_bool($recursive)) { 112 throw new BVProtectRuleError_V68 3(112 throw new BVProtectRuleError_V685( 113 113 $this->addExState("getArrayKeys: 2nd param must be a boolean") 114 114 ); … … 140 140 141 141 if (!is_bool($recursive)) { 142 throw new BVProtectRuleError_V68 3(142 throw new BVProtectRuleError_V685( 143 143 $this->addExState("hasAnyArrayKey: 3rd param must be a boolean") 144 144 ); … … 148 148 foreach ($keys as $key) { 149 149 if (!is_int($key) && !is_string($key)) { 150 throw new BVProtectRuleError_V68 3(150 throw new BVProtectRuleError_V685( 151 151 $this->addExState("hasAnyArrayKey: Key must be of type string or int") 152 152 ); … … 189 189 190 190 if (!is_bool($recursive)) { 191 throw new BVProtectRuleError_V68 3(191 throw new BVProtectRuleError_V685( 192 192 $this->addExState("keyMatches: 3rd param must be a boolean") 193 193 ); … … 224 224 225 225 if ($resp === false) { 226 throw new BVProtectRuleError_V68 3(226 throw new BVProtectRuleError_V685( 227 227 $this->addExState("keyMatches: Invalid regular expression") 228 228 ); … … 233 233 $resp = BVHelper::safePregMatch($pattern, (string) $key); 234 234 if ($resp === false) { 235 throw new BVProtectRuleError_V68 3(235 throw new BVProtectRuleError_V685( 236 236 $this->addExState("keyMatches: Regex match failed") 237 237 ); … … 242 242 243 243 private function keyMatchesRecursive($array, $pattern, &$traversed_keys, $depth = 1) { 244 if ($depth > BVProtectFWRuleEngine_V68 3::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) {244 if ($depth > BVProtectFWRuleEngine_V685::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { 245 245 return false; 246 246 } … … 262 262 263 263 private function getArrayKeysRecursive($array, &$keys, &$traversed_keys, $depth = 1) { 264 if ($depth > BVProtectFWRuleEngine_V68 3::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) {264 if ($depth > BVProtectFWRuleEngine_V685::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { 265 265 return; 266 266 } … … 277 277 278 278 private function hasAnyArrayKeyRecursive($array, $key_lookup, &$traversed_keys, $depth = 1) { 279 if ($depth > BVProtectFWRuleEngine_V68 3::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) {279 if ($depth > BVProtectFWRuleEngine_V685::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { 280 280 return false; 281 281 } … … 297 297 298 298 private function enforceArrayTraversalLimit($func_name, $traversed_keys) { 299 if ($traversed_keys > BVProtectFWRuleEngine_V68 3::MAX_ARRAY_KEYS_TO_TRAVERSE) {300 throw new BVProtectRuleError_V68 3(299 if ($traversed_keys > BVProtectFWRuleEngine_V685::MAX_ARRAY_KEYS_TO_TRAVERSE) { 300 throw new BVProtectRuleError_V685( 301 301 $this->addExState( 302 302 "TraversalLimitError: " . $func_name . " exceeded " . 303 BVProtectFWRuleEngine_V68 3::MAX_ARRAY_KEYS_TO_TRAVERSE .303 BVProtectFWRuleEngine_V685::MAX_ARRAY_KEYS_TO_TRAVERSE . 304 304 " array keys" 305 305 ) … … 321 321 foreach ($keys as $key) { 322 322 if (!is_int($key) && !is_string($key)) { 323 throw new BVProtectRuleError_V68 3(323 throw new BVProtectRuleError_V685( 324 324 $this->addExState("digArray: Keys must be a valid array of string, or integer type") 325 325 ); … … 342 342 343 343 if (empty($keys)) { 344 throw new BVProtectRuleError_V68 3(344 throw new BVProtectRuleError_V685( 345 345 $this->addExState("digArrayValues: Keys must not be empty") 346 346 ); 347 347 } 348 348 349 if (count($keys) > BVProtectFWRuleEngine_V68 3::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) {350 throw new BVProtectRuleError_V68 3(349 if (count($keys) > BVProtectFWRuleEngine_V685::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { 350 throw new BVProtectRuleError_V685( 351 351 $this->addExState( 352 352 "digArrayValues: Keys exceeded " . 353 BVProtectFWRuleEngine_V68 3::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC .353 BVProtectFWRuleEngine_V685::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC . 354 354 " levels of traversal" 355 355 ) … … 359 359 foreach ($keys as $key) { 360 360 if (!is_int($key) && !is_string($key)) { 361 throw new BVProtectRuleError_V68 3(361 throw new BVProtectRuleError_V685( 362 362 $this->addExState("digArrayValues: Keys must be a valid array of string, or integer type") 363 363 ); … … 376 376 } 377 377 378 if ($key === BVProtectFWRuleEngine_V68 3::WILDCARD_KEY) {378 if ($key === BVProtectFWRuleEngine_V685::WILDCARD_KEY) { 379 379 foreach ($node as $value) { 380 380 $traversed_keys += 1; … … 417 417 foreach ($keys as $key) { 418 418 if (!is_int($key) && !is_string($key)) { 419 throw new BVProtectRuleError_V68 3(419 throw new BVProtectRuleError_V685( 420 420 $this->addExState("filterArray: Keys must be a valid array of string, or integer type") 421 421 ); … … 438 438 439 439 if (!is_string($key) && !is_int($key)) { 440 throw new BVProtectRuleError_V68 3(440 throw new BVProtectRuleError_V685( 441 441 $this->addExState("getArrayVal: Key must be a valid string or integer") 442 442 ); … … 519 519 foreach ($array as $element) { 520 520 if (!is_scalar($element)) { 521 throw new BVProtectRuleError_V68 3(521 throw new BVProtectRuleError_V685( 522 522 $this->addExState("arrayJoin: Array element must be of scalar type") 523 523 ); -
blogvault-real-time-backup/tags/6.85/protect/fw/rule/functions/misc.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!trait_exists('BVProtectFWRuleMiscFunc_V68 3')) :6 trait BVProtectFWRuleMiscFunc_V68 3{5 if (!trait_exists('BVProtectFWRuleMiscFunc_V685')) : 6 trait BVProtectFWRuleMiscFunc_V685 { 7 7 private function _rf_isTrue() { 8 8 $args = $this->processRuleFunctionParams( … … 73 73 74 74 if (!array_key_exists($name, $this->variables)) { 75 throw new BVProtectRuleError_V68 3(75 throw new BVProtectRuleError_V685( 76 76 $this->addExState("UndefinedVariableError: " . $name . " is not defined.") 77 77 ); … … 134 134 $resp = BVHelper::safePregMatch((string) $pattern, (string) $subject); 135 135 if ($resp === false) { 136 throw new BVProtectRuleError_V68 3(136 throw new BVProtectRuleError_V685( 137 137 $this->addExState('BVHelper::safePregMatch' . serialize($subject)) 138 138 ); … … 175 175 $count = preg_match_all((string) $pattern, (string) $subject, $matches); 176 176 if ($count === false) { 177 throw new BVProtectRuleError_V68 3(177 throw new BVProtectRuleError_V685( 178 178 $this->addExState("preg_match_all: " . serialize($subject)) 179 179 ); … … 201 201 $count = preg_match_all((string) $pattern, (string) $subject, $matches); 202 202 if ($count === false) { 203 throw new BVProtectRuleError_V68 3(203 throw new BVProtectRuleError_V685( 204 204 $this->addExState("preg_match_all: " . serialize($subject)) 205 205 ); -
blogvault-real-time-backup/tags/6.85/protect/fw/rule/functions/request.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!trait_exists('BVProtectFWRuleRequestFunc_V68 3')) :6 trait BVProtectFWRuleRequestFunc_V68 3{5 if (!trait_exists('BVProtectFWRuleRequestFunc_V685')) : 6 trait BVProtectFWRuleRequestFunc_V685 { 7 7 private function _rf_getAction() { 8 8 $args = $this->processRuleFunctionParams( … … 496 496 497 497 if (!array_key_exists('ID', $user)) { 498 throw new BVProtectRuleError_V68 3(498 throw new BVProtectRuleError_V685( 499 499 $this->addExState("wpUserId: user's id doesn't exist") 500 500 ); -
blogvault-real-time-backup/tags/6.85/protect/fw/rule/functions/string.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!trait_exists('BVProtectFWRuleStringFunc_V68 3')) :6 trait BVProtectFWRuleStringFunc_V68 3{5 if (!trait_exists('BVProtectFWRuleStringFunc_V685')) : 6 trait BVProtectFWRuleStringFunc_V685 { 7 7 private function _rf_isNumeric() { 8 8 $args = $this->processRuleFunctionParams( … … 239 239 } 240 240 } else { 241 throw new BVProtectRuleError_V68 3(241 throw new BVProtectRuleError_V685( 242 242 $this->addExState("containsAnySubstring: Expects an array of substrings.") 243 243 ); … … 274 274 275 275 if (!is_int($offset)) { 276 throw new BVProtectRuleError_V68 3(276 throw new BVProtectRuleError_V685( 277 277 $this->addExState("strPos: Offset should be an integer") 278 278 ); … … 319 319 320 320 if (empty($separator)) { 321 throw new BVProtectRuleError_V68 3(321 throw new BVProtectRuleError_V685( 322 322 $this->addExState("splitString: Separator cannot be empty") 323 323 ); … … 325 325 326 326 if (!is_int($limit)) { 327 throw new BVProtectRuleError_V68 3(327 throw new BVProtectRuleError_V685( 328 328 $this->addExState("splitString: Limit should be an integer") 329 329 ); … … 344 344 345 345 if (!is_bool($recursive)) { 346 throw new BVProtectRuleError_V68 3(346 throw new BVProtectRuleError_V685( 347 347 $this->addExState("urlDecode: Recursive flag should be a boolean") 348 348 ); … … 363 363 364 364 if (!is_bool($recursive)) { 365 throw new BVProtectRuleError_V68 3(365 throw new BVProtectRuleError_V685( 366 366 $this->addExState("rawUrlDecode: Recursive flag should be a boolean") 367 367 ); … … 382 382 383 383 if (!is_bool($recursive)) { 384 throw new BVProtectRuleError_V68 3(384 throw new BVProtectRuleError_V685( 385 385 $this->addExState("htmlEntityDecode: Recursive flag should be a boolean") 386 386 ); … … 401 401 402 402 if (!is_bool($recursive)) { 403 throw new BVProtectRuleError_V68 3(403 throw new BVProtectRuleError_V685( 404 404 $this->addExState("stripSlashes: Recursive flag should be a boolean") 405 405 ); … … 410 410 411 411 private function normalizeStringValue($value, $operation, $recursive, $depth = 1) { 412 if ($depth > BVProtectFWRuleEngine_V68 3::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) {412 if ($depth > BVProtectFWRuleEngine_V685::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { 413 413 return null; 414 414 } … … 442 442 } 443 443 444 throw new BVProtectRuleError_V68 3(444 throw new BVProtectRuleError_V685( 445 445 $this->addExState("normalizeStringValue: Invalid normalization operation") 446 446 ); -
blogvault-real-time-backup/tags/6.85/protect/fw/rule/functions/wp.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!trait_exists('BVProtectFWRuleWPFunc_V68 3')) :6 trait BVProtectFWRuleWPFunc_V68 3{5 if (!trait_exists('BVProtectFWRuleWPFunc_V685')) : 6 trait BVProtectFWRuleWPFunc_V685 { 7 7 private function _rf_sanitizeUser() { 8 8 $args = $this->processRuleFunctionParams( … … 16 16 $strict = $args[1]; 17 17 18 if (!function_exists('sanitize_user') || !BVProtectUtils_V68 3::haveMupluginsLoaded()) {19 throw new BVProtectRuleError_V68 3(18 if (!function_exists('sanitize_user') || !BVProtectUtils_V685::haveMupluginsLoaded()) { 19 throw new BVProtectRuleError_V685( 20 20 $this->addExState("sanitizeUser: Func sanitize_user doesn't exist.") 21 21 ); … … 34 34 $data = $args[0]; 35 35 36 if (!function_exists('maybe_serialize') || !BVProtectUtils_V68 3::haveMupluginsLoaded()) {37 throw new BVProtectRuleError_V68 3(36 if (!function_exists('maybe_serialize') || !BVProtectUtils_V685::haveMupluginsLoaded()) { 37 throw new BVProtectRuleError_V685( 38 38 $this->addExState("maybeSerialize: Func maybe_serialize doesn't exist.") 39 39 ); … … 50 50 ); 51 51 52 if (!function_exists('is_user_logged_in') || !BVProtectUtils_V68 3::havePluginsLoaded()) {53 throw new BVProtectRuleError_V68 3(52 if (!function_exists('is_user_logged_in') || !BVProtectUtils_V685::havePluginsLoaded()) { 53 throw new BVProtectRuleError_V685( 54 54 $this->addExState("isUserLoggedIn: Func is_user_logged_in doesn't exist.") 55 55 ); … … 66 66 ); 67 67 68 if (!function_exists('wp_get_current_user') || !BVProtectUtils_V68 3::havePluginsLoaded()) {69 throw new BVProtectRuleError_V68 3(68 if (!function_exists('wp_get_current_user') || !BVProtectUtils_V685::havePluginsLoaded()) { 69 throw new BVProtectRuleError_V685( 70 70 $this->addExState("getCurrentWPUser: Func wp_get_current_user doesn't exist.") 71 71 ); 72 72 } 73 73 74 return BVProtectFWRuleEngine_V68 3::toAllowedType(wp_get_current_user());74 return BVProtectFWRuleEngine_V685::toAllowedType(wp_get_current_user()); 75 75 } 76 76 … … 87 87 $arg2 = isset($args[2]) ? $args[2] : null; 88 88 89 if (!function_exists('current_user_can') || !BVProtectUtils_V68 3::havePluginsLoaded()) {90 throw new BVProtectRuleError_V68 3(89 if (!function_exists('current_user_can') || !BVProtectUtils_V685::havePluginsLoaded()) { 90 throw new BVProtectRuleError_V685( 91 91 $this->addExState("currentUserCan: Required funcs doesn't exist.") 92 92 ); … … 115 115 $value = $args[1]; 116 116 117 if (!function_exists('get_user_by') || !BVProtectUtils_V68 3::havePluginsLoaded()) {118 throw new BVProtectRuleError_V68 3(117 if (!function_exists('get_user_by') || !BVProtectUtils_V685::havePluginsLoaded()) { 118 throw new BVProtectRuleError_V685( 119 119 $this->addExState("getUserBy: Func get_user_by doesn't exist") 120 120 ); … … 123 123 if ($field === 'ID' || $field === 'id') { 124 124 if (!is_string($value) && !is_int($value)) { 125 throw new BVProtectRuleError_V68 3(125 throw new BVProtectRuleError_V685( 126 126 $this->addExState("getUserBy: Value must be a valid string or an integer") 127 127 ); 128 128 } 129 129 } elseif (!is_string($value)) { 130 throw new BVProtectRuleError_V68 3(130 throw new BVProtectRuleError_V685( 131 131 $this->addExState("getUserBy: Value must be a valid string") 132 132 ); … … 138 138 } 139 139 140 return BVProtectFWRuleEngine_V68 3::toAllowedType($user);140 return BVProtectFWRuleEngine_V685::toAllowedType($user); 141 141 } 142 142 … … 151 151 152 152 if (!array_key_exists("allcaps", $user)) { 153 throw new BVProtectRuleError_V68 3(153 throw new BVProtectRuleError_V685( 154 154 $this->addExState("getCurrentWPUserCapabilities: allcaps doesn't exist in user.") 155 155 ); 156 156 } 157 157 158 return BVProtectFWRuleEngine_V68 3::toAllowedType($user["allcaps"]);158 return BVProtectFWRuleEngine_V685::toAllowedType($user["allcaps"]); 159 159 } 160 160 … … 174 174 175 175 if (!array_key_exists("allcaps", $user)) { 176 throw new BVProtectRuleError_V68 3(176 throw new BVProtectRuleError_V685( 177 177 $this->addExState("getUserCapabilities: allcaps doesn't exist in user.") 178 178 ); 179 179 } 180 180 181 return BVProtectFWRuleEngine_V68 3::toAllowedType($user["allcaps"]);181 return BVProtectFWRuleEngine_V685::toAllowedType($user["allcaps"]); 182 182 } 183 183 … … 203 203 $default_value = isset($args[1]) ? $args[1] : false; 204 204 205 if (!function_exists('get_option') || !BVProtectUtils_V68 3::haveMupluginsLoaded()) {206 throw new BVProtectRuleError_V68 3(205 if (!function_exists('get_option') || !BVProtectUtils_V685::haveMupluginsLoaded()) { 206 throw new BVProtectRuleError_V685( 207 207 $this->addExState("getOption: Func get_option doesn't exist.") 208 208 ); 209 209 } 210 210 211 return BVProtectFWRuleEngine_V68 3::toAllowedType(get_option($option, $default_value));211 return BVProtectFWRuleEngine_V685::toAllowedType(get_option($option, $default_value)); 212 212 } 213 213 … … 223 223 $login = $args[1]; 224 224 225 if (!function_exists('check_password_reset_key') || !BVProtectUtils_V68 3::havePluginsLoaded()) {226 throw new BVProtectRuleError_V68 3(225 if (!function_exists('check_password_reset_key') || !BVProtectUtils_V685::havePluginsLoaded()) { 226 throw new BVProtectRuleError_V685( 227 227 $this->addExState("checkPasswordResetKey: Func check_password_reset_key doesn't exist.") 228 228 ); … … 232 232 233 233 if (is_a($user, "WP_User")) { 234 return BVProtectFWRuleEngine_V68 3::toAllowedType($user);234 return BVProtectFWRuleEngine_V685::toAllowedType($user); 235 235 } 236 236 … … 287 287 $value = $args[0]; 288 288 289 if (!function_exists('wp_unslash') || !BVProtectUtils_V68 3::haveMuPluginsLoaded()) {290 throw new BVProtectRuleError_V68 3(289 if (!function_exists('wp_unslash') || !BVProtectUtils_V685::haveMuPluginsLoaded()) { 290 throw new BVProtectRuleError_V685( 291 291 $this->addExState("wpUnslash: Func wp_unslash doesn't exist.") 292 292 ); … … 294 294 295 295 if (!is_string($value) && !is_array($value)) { 296 throw new BVProtectRuleError_V68 3(296 throw new BVProtectRuleError_V685( 297 297 $this->addExState("wpUnslash: Value must be a valid string or an array") 298 298 ); … … 310 310 311 311 if (!defined('COOKIEHASH')) { 312 throw new BVProtectRuleError_V68 3(312 throw new BVProtectRuleError_V685( 313 313 $this->addExState("parseResetPassCookie: COOKIEHASH is not defined.") 314 314 ); -
blogvault-real-time-backup/tags/6.85/protect/ipstore.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectIpstore_V68 3')) :4 if (!class_exists('BVProtectIpstore_V685')) : 5 5 require_once dirname( __FILE__ ) . '/request.php'; 6 6 require_once dirname( __FILE__ ) . '/ipstore/fs.php'; 7 7 require_once dirname( __FILE__ ) . '/ipstore/db.php'; 8 8 9 class BVProtectIpstore_V68 3{9 class BVProtectIpstore_V685 { 10 10 private $storage; 11 11 private $storage_type; … … 14 14 const STORAGE_TYPE_DB = 1; 15 15 16 function __construct($storage_type = BVProtectIpstore_V68 3::STORAGE_TYPE_DB) {16 function __construct($storage_type = BVProtectIpstore_V685::STORAGE_TYPE_DB) { 17 17 $this->storage_type = $storage_type; 18 if ($this->storage_type == BVProtectIpstore_V68 3::STORAGE_TYPE_FS) {19 $this->storage = new BVProtectIpstoreFS_V68 3();18 if ($this->storage_type == BVProtectIpstore_V685::STORAGE_TYPE_FS) { 19 $this->storage = new BVProtectIpstoreFS_V685(); 20 20 } else { 21 $this->storage = new BVProtectIpstoreDB_V68 3();21 $this->storage = new BVProtectIpstoreDB_V685(); 22 22 } 23 23 } 24 24 25 25 public static function uninstall() { 26 BVProtectIpstoreDB_V68 3::uninstall();26 BVProtectIpstoreDB_V685::uninstall(); 27 27 } 28 28 29 29 public function isLPIPBlacklisted($ip) { 30 if ($this->storage_type == BVProtectIpstore_V68 3::STORAGE_TYPE_DB) {30 if ($this->storage_type == BVProtectIpstore_V685::STORAGE_TYPE_DB) { 31 31 return $this->storage->isLPIPBlacklisted($ip); 32 32 } … … 34 34 35 35 public function isLPIPWhitelisted($ip) { 36 if ($this->storage_type == BVProtectIpstore_V68 3::STORAGE_TYPE_DB) {36 if ($this->storage_type == BVProtectIpstore_V685::STORAGE_TYPE_DB) { 37 37 return $this->storage->isLPIPWhitelisted($ip); 38 38 } -
blogvault-real-time-backup/tags/6.85/protect/ipstore/db.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectIpstoreDB_V68 3')) :5 class BVProtectIpstoreDB_V68 3{4 if (!class_exists('BVProtectIpstoreDB_V685')) : 5 class BVProtectIpstoreDB_V685 { 6 6 const TABLE_NAME = 'ip_store'; 7 7 … … 11 11 #XNOTE: check this. 12 12 public static function blacklistedTypes() { 13 return BVProtectRequest_V68 3::blacklistedCategories();13 return BVProtectRequest_V685::blacklistedCategories(); 14 14 } 15 15 16 16 public static function whitelistedTypes() { 17 return BVProtectRequest_V68 3::whitelistedCategories();17 return BVProtectRequest_V685::whitelistedCategories(); 18 18 } 19 19 20 20 public static function uninstall() { 21 BVProtect_V68 3::$db->dropBVTable(BVProtectIpstoreDB_V683::TABLE_NAME);21 BVProtect_V685::$db->dropBVTable(BVProtectIpstoreDB_V685::TABLE_NAME); 22 22 } 23 23 24 24 public function isLPIPBlacklisted($ip) { 25 return $this->checkIPPresent($ip, self::blacklistedTypes(), BVProtectIpstoreDB_V68 3::CATEGORY_LP);25 return $this->checkIPPresent($ip, self::blacklistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_LP); 26 26 } 27 27 28 28 public function isLPIPWhitelisted($ip) { 29 return $this->checkIPPresent($ip, self::whitelistedTypes(), BVProtectIpstoreDB_V68 3::CATEGORY_LP);29 return $this->checkIPPresent($ip, self::whitelistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_LP); 30 30 } 31 31 32 32 public function getTypeIfBlacklistedIP($ip) { 33 return $this->getIPType($ip, self::blacklistedTypes(), BVProtectIpstoreDB_V68 3::CATEGORY_FW);33 return $this->getIPType($ip, self::blacklistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_FW); 34 34 } 35 35 36 36 public function isFWIPBlacklisted($ip) { 37 return $this->checkIPPresent($ip, self::blacklistedTypes(), BVProtectIpstoreDB_V68 3::CATEGORY_FW);37 return $this->checkIPPresent($ip, self::blacklistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_FW); 38 38 } 39 39 40 40 public function isFWIPWhitelisted($ip) { 41 return $this->checkIPPresent($ip, self::whitelistedTypes(), BVProtectIpstoreDB_V68 3::CATEGORY_FW);41 return $this->checkIPPresent($ip, self::whitelistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_FW); 42 42 } 43 43 … … 50 50 #XNOTE: getIPCategory or getIPType? 51 51 private function getIPType($ip, $types, $category) { 52 $table = BVProtect_V68 3::$db->getBVTable(BVProtectIpstoreDB_V683::TABLE_NAME);52 $table = BVProtect_V685::$db->getBVTable(BVProtectIpstoreDB_V685::TABLE_NAME); 53 53 54 if (BVProtect_V68 3::$db->isTablePresent($table)) {55 $binIP = BVProtectUtils_V68 3::bvInetPton($ip);56 $is_v6 = BVProtectUtils_V68 3::isIPv6($ip);54 if (BVProtect_V685::$db->isTablePresent($table)) { 55 $binIP = BVProtectUtils_V685::bvInetPton($ip); 56 $is_v6 = BVProtectUtils_V685::isIPv6($ip); 57 57 58 58 if ($binIP !== false) { 59 59 $query_str = "SELECT * FROM $table WHERE %s >= `start_ip_range` && %s <= `end_ip_range` && "; 60 if ($category == BVProtectIpstoreDB_V68 3::CATEGORY_FW) {60 if ($category == BVProtectIpstoreDB_V685::CATEGORY_FW) { 61 61 $query_str .= "`is_fw` = true"; 62 62 } else { … … 65 65 $query_str .= " && `type` in (" . implode(',', $types) . ") && `is_v6` = %d LIMIT 1;"; 66 66 67 $query = BVProtect_V68 3::$db->prepare($query_str, array($binIP, $binIP, $is_v6));67 $query = BVProtect_V685::$db->prepare($query_str, array($binIP, $binIP, $is_v6)); 68 68 69 return BVProtect_V68 3::$db->getVar($query, 5);69 return BVProtect_V685::$db->getVar($query, 5); 70 70 } 71 71 } -
blogvault-real-time-backup/tags/6.85/protect/ipstore/fs.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectIpstoreFS_V68 3')) :5 class BVProtectIpstoreFS_V68 3{4 if (!class_exists('BVProtectIpstoreFS_V685')) : 5 class BVProtectIpstoreFS_V685 { 6 6 private $whitelisted_ips; 7 7 private $blacklisted_ips; … … 12 12 function __construct() { 13 13 $ip_store_file = MCDATAPATH . MCCONFKEY . '-' . 'mc_ips.conf'; 14 $ips = BVProtectUtils_V68 3::parseFile($ip_store_file);14 $ips = BVProtectUtils_V685::parseFile($ip_store_file); 15 15 $this->whitelisted_ips = array_key_exists('whitelisted', $ips) ? $ips['whitelisted'] : array(); 16 16 $this->blacklisted_ips = array_key_exists('blacklisted', $ips) ? $ips['blacklisted'] : array(); … … 18 18 19 19 public function getTypeIfBlacklistedIP($ip) { 20 return $this->getIPType($ip, BVProtectIpstoreFS_V68 3::IP_TYPE_BLACKLISTED);20 return $this->getIPType($ip, BVProtectIpstoreFS_V685::IP_TYPE_BLACKLISTED); 21 21 } 22 22 23 23 public function isFWIPBlacklisted($ip) { 24 return $this->checkIPPresent($ip, BVProtectIpstoreFS_V68 3::IP_TYPE_BLACKLISTED);24 return $this->checkIPPresent($ip, BVProtectIpstoreFS_V685::IP_TYPE_BLACKLISTED); 25 25 } 26 26 27 27 public function isFWIPWhitelisted($ip) { 28 return $this->checkIPPresent($ip, BVProtectIpstoreFS_V68 3::IP_TYPE_WHITELISTED);28 return $this->checkIPPresent($ip, BVProtectIpstoreFS_V685::IP_TYPE_WHITELISTED); 29 29 } 30 30 … … 37 37 private function getIPType($ip, $type) { 38 38 switch ($type) { 39 case BVProtectIpstoreFS_V68 3::IP_TYPE_BLACKLISTED:39 case BVProtectIpstoreFS_V685::IP_TYPE_BLACKLISTED: 40 40 return isset($this->blacklisted_ips[$ip]) ? $this->blacklisted_ips[$ip] : null; 41 case BVProtectIpstoreFS_V68 3::IP_TYPE_WHITELISTED:41 case BVProtectIpstoreFS_V685::IP_TYPE_WHITELISTED: 42 42 return isset($this->whitelisted_ips[$ip]) ? $this->whitelisted_ips[$ip] : null; 43 43 } -
blogvault-real-time-backup/tags/6.85/protect/lib/utils.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectUtils_V68 3')) :5 class BVProtectUtils_V68 3{4 if (!class_exists('BVProtectUtils_V685')) : 5 class BVProtectUtils_V685 { 6 6 public static function getIP($ip_header) { 7 7 $ip = null; … … 131 131 if (is_array($val)) { 132 132 foreach ($val as $e) { 133 $length += BVProtectUtils_V68 3::getLength($e);133 $length += BVProtectUtils_V685::getLength($e); 134 134 } 135 135 -
blogvault-real-time-backup/tags/6.85/protect/logger.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectLogger_V68 3')) :4 if (!class_exists('BVProtectLogger_V685')) : 5 5 require_once dirname( __FILE__ ) . '/logger/fs.php'; 6 6 require_once dirname( __FILE__ ) . '/logger/db.php'; 7 7 8 class BVProtectLogger_V68 3{8 class BVProtectLogger_V685 { 9 9 private $log_destination; 10 10 … … 12 12 const TYPE_DB = 1; 13 13 14 function __construct($name, $type = BVProtectLogger_V68 3::TYPE_DB) {15 if ($type == BVProtectLogger_V68 3::TYPE_FS) {16 $this->log_destination = new BVProtectLoggerFS_V68 3($name);14 function __construct($name, $type = BVProtectLogger_V685::TYPE_DB) { 15 if ($type == BVProtectLogger_V685::TYPE_FS) { 16 $this->log_destination = new BVProtectLoggerFS_V685($name); 17 17 } else { 18 $this->log_destination = new BVProtectLoggerDB_V68 3($name);18 $this->log_destination = new BVProtectLoggerDB_V685($name); 19 19 } 20 20 } -
blogvault-real-time-backup/tags/6.85/protect/logger/db.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectLoggerDB_V68 3')) :5 class BVProtectLoggerDB_V68 3{4 if (!class_exists('BVProtectLoggerDB_V685')) : 5 class BVProtectLoggerDB_V685 { 6 6 private $tablename; 7 7 private $bv_tablename; … … 11 11 function __construct($tablename) { 12 12 $this->tablename = $tablename; 13 $this->bv_tablename = BVProtect_V68 3::$db->getBVTable($tablename);13 $this->bv_tablename = BVProtect_V685::$db->getBVTable($tablename); 14 14 } 15 15 16 16 public function log($data) { 17 17 if (is_array($data)) { 18 if (BVProtect_V68 3::$db->rowsCount($this->bv_tablename) > BVProtectLoggerDB_V683::MAXROWCOUNT) {19 BVProtect_V68 3::$db->deleteRowsFromtable($this->tablename, 1);18 if (BVProtect_V685::$db->rowsCount($this->bv_tablename) > BVProtectLoggerDB_V685::MAXROWCOUNT) { 19 BVProtect_V685::$db->deleteRowsFromtable($this->tablename, 1); 20 20 } 21 21 22 BVProtect_V68 3::$db->replaceIntoBVTable($this->tablename, $data);22 BVProtect_V685::$db->replaceIntoBVTable($this->tablename, $data); 23 23 } 24 24 } -
blogvault-real-time-backup/tags/6.85/protect/logger/fs.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectLoggerFS_V68 3')) :5 class BVProtectLoggerFS_V68 3{4 if (!class_exists('BVProtectLoggerFS_V685')) : 5 class BVProtectLoggerFS_V685 { 6 6 public $logFile; 7 7 -
blogvault-real-time-backup/tags/6.85/protect/lp.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectLP_V68 3')) :5 class BVProtectLP_V68 3{4 if (!class_exists('BVProtectLP_V685')) : 5 class BVProtectLP_V685 { 6 6 private $ip; 7 7 private $time; … … 10 10 private $brand_name; 11 11 12 private $mode = BVProtectLP_V68 3::MODE_DISABLED;12 private $mode = BVProtectLP_V685::MODE_DISABLED; 13 13 private $captcha_limit = 3; 14 14 private $temp_block_limit = 10; … … 18 18 private $all_blocked_gap = 1800; 19 19 20 private $category = BVProtectLP_V68 3::CATEGORY_ALLOWED;20 private $category = BVProtectLP_V685::CATEGORY_ALLOWED; 21 21 private $username = ''; 22 22 private $message = ''; … … 47 47 $this->ip = $request->getIP(); 48 48 $this->brand_name = $brand_name; 49 $this->ipstore = new BVProtectIpstore_V68 3();50 $this->logger = new BVProtectLogger_V68 3(BVProtectLP_V683::TABLE_NAME);49 $this->ipstore = new BVProtectIpstore_V685(); 50 $this->logger = new BVProtectLogger_V685(BVProtectLP_V685::TABLE_NAME); 51 51 $this->time = strtotime(gmdate("Y-m-d H:i:s")); 52 52 … … 91 91 92 92 public static function uninstall() { 93 BVProtect_V68 3::$db->dropBVTable(BVProtectLP_V683::TABLE_NAME);93 BVProtect_V685::$db->dropBVTable(BVProtectLP_V685::TABLE_NAME); 94 94 } 95 95 … … 103 103 104 104 private function getCaptchaLink() { 105 $account = BVAccount::apiPublicAccount(BVProtect_V68 3::$settings);105 $account = BVAccount::apiPublicAccount(BVProtect_V685::$settings); 106 106 107 107 $url = $account->authenticatedUrl('/captcha/solve'); … … 112 112 113 113 private function getAllowLoginsTransient() { 114 return BVProtect_V68 3::$settings->getTransient('bvlp_allow_logins');114 return BVProtect_V685::$settings->getTransient('bvlp_allow_logins'); 115 115 } 116 116 117 117 private function getBlockLoginsTransient() { 118 return BVProtect_V68 3::$settings->getTransient('bvlp_block_logins');118 return BVProtect_V685::$settings->getTransient('bvlp_block_logins'); 119 119 } 120 120 … … 142 142 143 143 private function isProtecting() { 144 return $this->mode === BVProtectLP_V68 3::MODE_PROTECT;144 return $this->mode === BVProtectLP_V685::MODE_PROTECT; 145 145 } 146 146 147 147 private function isActive() { 148 return $this->mode !== BVProtectLP_V68 3::MODE_DISABLED;148 return $this->mode !== BVProtectLP_V685::MODE_DISABLED; 149 149 } 150 150 … … 158 158 159 159 private function isUnBlockedIP() { 160 $transient_name = BVProtectLP_V68 3::UNBLOCK_IP_TRANSIENT_PREFIX . $this->ip;161 $attempts = BVProtect_V68 3::$settings->getTransient($transient_name);160 $transient_name = BVProtectLP_V685::UNBLOCK_IP_TRANSIENT_PREFIX . $this->ip; 161 $attempts = BVProtect_V685::$settings->getTransient($transient_name); 162 162 163 163 if ($attempts && $attempts > 0) { 164 BVProtect_V68 3::$settings->setTransient($transient_name, $attempts - 1, 600 * $attempts);164 BVProtect_V685::$settings->setTransient($transient_name, $attempts - 1, 600 * $attempts); 165 165 return true; 166 166 } … … 171 171 private function isLoginBlocked() { 172 172 if ($this->getAllowLoginsTransient() || 173 ($this->getLoginCount(BVProtectLP_V68 3::LOGIN_STATUS_FAILURE, null, $this->all_blocked_gap) < $this->block_all_limit)) {173 ($this->getLoginCount(BVProtectLP_V685::LOGIN_STATUS_FAILURE, null, $this->all_blocked_gap) < $this->block_all_limit)) { 174 174 return false; 175 175 } … … 194 194 private function terminateLogin() { 195 195 $this->message = 'Login Blocked'; 196 $this->log(BVProtectLP_V68 3::LOGIN_STATUS_BLOCKED);196 $this->log(BVProtectLP_V685::LOGIN_STATUS_BLOCKED); 197 197 if ($this->isProtecting()) { 198 198 header("Cache-Control: no-cache, no-store, must-revalidate"); … … 208 208 public function loginInit($user, $username = '', $password = '') { 209 209 if ($this->isUnBlockedIP()) { 210 $this->category = BVProtectLP_V68 3::CATEGORY_UNBLOCKED;210 $this->category = BVProtectLP_V685::CATEGORY_UNBLOCKED; 211 211 } else { 212 $failed_attempts = $this->getLoginCount(BVProtectLP_V68 3::LOGIN_STATUS_FAILURE,212 $failed_attempts = $this->getLoginCount(BVProtectLP_V685::LOGIN_STATUS_FAILURE, 213 213 $this->ip, $this->failed_login_gap); 214 214 215 215 if ($this->isWhitelistedIP()) { 216 $this->category = BVProtectLP_V68 3::CATEGORY_BYPASSED;217 } elseif (BVProtectUtils_V68 3::isPrivateIP($this->ip)) {218 $this->category = BVProtectLP_V68 3::CATEGORY_PRIVATEIP;216 $this->category = BVProtectLP_V685::CATEGORY_BYPASSED; 217 } elseif (BVProtectUtils_V685::isPrivateIP($this->ip)) { 218 $this->category = BVProtectLP_V685::CATEGORY_PRIVATEIP; 219 219 } elseif ($this->isBlacklistedIP()) { 220 $this->category = BVProtectLP_V68 3::CATEGORY_BLACKLISTED;220 $this->category = BVProtectLP_V685::CATEGORY_BLACKLISTED; 221 221 $this->terminateLogin(); 222 222 } elseif ($this->isKnownLogin()) { 223 $this->category = BVProtectLP_V68 3::CATEGORY_BYPASSED;223 $this->category = BVProtectLP_V685::CATEGORY_BYPASSED; 224 224 } elseif ($this->isLoginBlocked()) { 225 $this->category = BVProtectLP_V68 3::CATEGORY_ALL_BLOCKED;225 $this->category = BVProtectLP_V685::CATEGORY_ALL_BLOCKED; 226 226 $this->terminateLogin(); 227 227 } elseif ($failed_attempts >= $this->temp_block_limit) { 228 $this->category = BVProtectLP_V68 3::CATEGORY_TEMP_BLOCK;228 $this->category = BVProtectLP_V685::CATEGORY_TEMP_BLOCK; 229 229 $this->terminateLogin(); 230 230 } elseif ($failed_attempts >= $this->captcha_limit) { 231 $this->category = BVProtectLP_V68 3::CATEGORY_CAPTCHA_BLOCK;231 $this->category = BVProtectLP_V685::CATEGORY_CAPTCHA_BLOCK; 232 232 $this->terminateLogin(); 233 233 } … … 243 243 public function loginFailed($username) { 244 244 $this->username = $username; 245 $this->log(BVProtectLP_V68 3::LOGIN_STATUS_FAILURE);245 $this->log(BVProtectLP_V685::LOGIN_STATUS_FAILURE); 246 246 } 247 247 … … 249 249 $this->username = $username; 250 250 $this->message = 'Login Success'; 251 $this->log(BVProtectLP_V68 3::LOGIN_STATUS_SUCCESS);251 $this->log(BVProtectLP_V685::LOGIN_STATUS_SUCCESS); 252 252 } 253 253 254 254 private function isKnownLogin() { 255 return $this->getLoginCount(BVProtectLP_V68 3::LOGIN_STATUS_SUCCESS,255 return $this->getLoginCount(BVProtectLP_V685::LOGIN_STATUS_SUCCESS, 256 256 $this->ip, $this->success_login_gap) > 0; 257 257 } 258 258 259 259 private function getLoginCount($status, $ip, $gap) { 260 $table = BVProtect_V68 3::$db->getBVTable(BVProtectLP_V683::TABLE_NAME);260 $table = BVProtect_V685::$db->getBVTable(BVProtectLP_V685::TABLE_NAME); 261 261 $query_str = "SELECT COUNT(*) as count from `$table` WHERE status=%d && time > %d"; 262 262 $query_args = array($status, ($this->time - $gap)); 263 263 264 $query = BVProtect_V68 3::$db->prepare($query_str, $query_args);264 $query = BVProtect_V685::$db->prepare($query_str, $query_args); 265 265 if ($ip) { 266 $query .= BVProtect_V68 3::$db->prepare(" && ip=%s", $ip);267 } 268 269 $rows = BVProtect_V68 3::$db->getResult($query);266 $query .= BVProtect_V685::$db->prepare(" && ip=%s", $ip); 267 } 268 269 $rows = BVProtect_V685::$db->getResult($query); 270 270 if (!$rows) { 271 271 return 0; -
blogvault-real-time-backup/tags/6.85/protect/prepend/ignitor.php
r3795700 r3813747 5 5 require_once dirname( __FILE__ ) . '/../protect.php'; 6 6 7 BVProtect_V68 3::init(BVProtect_V683::MODE_PREPEND);7 BVProtect_V685::init(BVProtect_V685::MODE_PREPEND); 8 8 } -
blogvault-real-time-backup/tags/6.85/protect/protect.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtect_V68 3')) :4 if (!class_exists('BVProtect_V685')) : 5 5 require_once dirname( __FILE__ ) . '/logger.php'; 6 6 require_once dirname( __FILE__ ) . '/ipstore.php'; … … 12 12 require_once dirname( __FILE__ ) . '/../helper.php'; 13 13 14 class BVProtect_V68 3{14 class BVProtect_V685 { 15 15 public static $settings; 16 16 public static $db; … … 27 27 } 28 28 29 if ($mode == BVProtect_V68 3::MODE_PREPEND) {29 if ($mode == BVProtect_V685::MODE_PREPEND) { 30 30 $config_file = MCDATAPATH . MCCONFKEY . '-' . 'mc.conf'; 31 $config = BVProtectUtils_V68 3::parseFile($config_file);31 $config = BVProtectUtils_V685::parseFile($config_file); 32 32 33 33 if (empty($config['time']) || !($config['time'] > time() - (48*3600)) || 34 34 !isset($config['mc_conf_version']) || 35 (BVProtect_V68 3::CONF_VERSION !== $config['mc_conf_version'])) {35 (BVProtect_V685::CONF_VERSION !== $config['mc_conf_version'])) { 36 36 return false; 37 37 … … 41 41 $request_ip_header = array_key_exists('ipheader', $config) ? $config['ipheader'] : null; 42 42 $req_config = array_key_exists('reqconfig', $config) ? $config['reqconfig'] : array(); 43 $request = new BVProtectRequest_V68 3($request_ip_header, $req_config);43 $request = new BVProtectRequest_V685($request_ip_header, $req_config); 44 44 $fw_config = array_key_exists('fw', $config) ? $config['fw'] : array(); 45 45 46 BVProtectFW_V68 3::getInstance($mode, $request, $fw_config, $brand_name)->init();46 BVProtectFW_V685::getInstance($mode, $request, $fw_config, $brand_name)->init(); 47 47 } else { 48 48 $plug_config = self::$settings->getOption(self::$info->services_option_name); 49 49 $config = array_key_exists('protect', $plug_config) ? $plug_config['protect'] : array(); 50 50 if (!is_array($config) || !array_key_exists('mc_conf_version', $config) || 51 (BVProtect_V68 3::CONF_VERSION !== $config['mc_conf_version'])) {51 (BVProtect_V685::CONF_VERSION !== $config['mc_conf_version'])) { 52 52 53 53 return false; … … 57 57 $request_ip_header = array_key_exists('ipheader', $config) ? $config['ipheader'] : null; 58 58 $req_config = array_key_exists('reqconfig', $config) ? $config['reqconfig'] : array(); 59 $request = new BVProtectRequest_V68 3($request_ip_header, $req_config);59 $request = new BVProtectRequest_V685($request_ip_header, $req_config); 60 60 $fw_config = array_key_exists('fw', $config) ? $config['fw'] : array(); 61 61 $lp_config = array_key_exists('lp', $config) ? $config['lp'] : array(); 62 62 63 BVProtectFW_V68 3::getInstance($mode, $request, $fw_config, $brand_name)->init();64 BVProtectLP_V68 3::getInstance($request, $lp_config, $brand_name)->init();63 BVProtectFW_V685::getInstance($mode, $request, $fw_config, $brand_name)->init(); 64 BVProtectLP_V685::getInstance($request, $lp_config, $brand_name)->init(); 65 65 } 66 66 } … … 69 69 self::$settings->deleteOption('bvptconf'); 70 70 self::$settings->deleteOption('bvptplug'); 71 BVProtectIpstore_V68 3::uninstall();72 BVProtectFW_V68 3::uninstall();73 BVProtectLP_V68 3::uninstall();71 BVProtectIpstore_V685::uninstall(); 72 BVProtectFW_V685::uninstall(); 73 BVProtectLP_V685::uninstall(); 74 74 75 BVProtect_V68 3::removeWPPrepend();76 BVProtect_V68 3::removePHPPrepend();77 BVProtect_V68 3::removeMCData();75 BVProtect_V685::removeWPPrepend(); 76 BVProtect_V685::removePHPPrepend(); 77 BVProtect_V685::removeMCData(); 78 78 79 79 return true; … … 96 96 $pattern = "@include '" . rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/malcare-waf.php" . "';"; 97 97 98 BVProtectUtils_V68 3::fileRemovePattern($fname, $pattern);98 BVProtectUtils_V685::fileRemovePattern($fname, $pattern); 99 99 } 100 100 101 101 private static function removePHPPrepend() { 102 BVProtect_V68 3::removeHtaccessPrepend();103 BVProtect_V68 3::removeUseriniPrepend();102 BVProtect_V685::removeHtaccessPrepend(); 103 BVProtect_V685::removeUseriniPrepend(); 104 104 } 105 105 … … 107 107 $pattern = "/# MalCare WAF(.|\n)*# END MalCare WAF/i"; 108 108 109 BVProtectUtils_V68 3::fileRemovePattern(rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/.htaccess", $pattern, true);109 BVProtectUtils_V685::fileRemovePattern(rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/.htaccess", $pattern, true); 110 110 } 111 111 … … 113 113 $pattern = "/; MalCare WAF(.|\n)*; END MalCare WAF/i"; 114 114 115 BVProtectUtils_V68 3::fileRemovePattern(rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/.user.ini", $pattern, true);115 BVProtectUtils_V685::fileRemovePattern(rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/.user.ini", $pattern, true); 116 116 } 117 117 … … 120 120 $mc_data_dir = $content_dir . "/mc_data"; 121 121 122 BVProtectUtils_V68 3::rrmdir($mc_data_dir);122 BVProtectUtils_V685::rrmdir($mc_data_dir); 123 123 } 124 124 } -
blogvault-real-time-backup/tags/6.85/protect/request.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!class_exists('BVProtectRequest_V68 3')) :6 class BVProtectRequest_V68 3{5 if (!class_exists('BVProtectRequest_V685')) : 6 class BVProtectRequest_V685 { 7 7 public $ip; 8 8 public $host = ''; … … 20 20 public $files; 21 21 public $respcode; 22 public $status = BVProtectRequest_V68 3::STATUS_ALLOWED;23 public $category = BVProtectRequest_V68 3::CATEGORY_NORMAL;22 public $status = BVProtectRequest_V685::STATUS_ALLOWED; 23 public $category = BVProtectRequest_V685::CATEGORY_NORMAL; 24 24 25 25 public $wp_user; … … 60 60 61 61 public function __construct($ip_header, $config) { 62 $this->ip = BVProtectUtils_V68 3::getIP($ip_header);62 $this->ip = BVProtectUtils_V685::getIP($ip_header); 63 63 $this->timestamp = time(); 64 64 $this->get_params = $_GET; // phpcs:ignore WordPress.Security.NonceVerification.Recommended … … 142 142 public static function blacklistedCategories() { 143 143 return array( 144 BVProtectRequest_V68 3::CATEGORY_BOT_BLOCKED,145 BVProtectRequest_V68 3::CATEGORY_COUNTRY_BLOCKED,146 BVProtectRequest_V68 3::CATEGORY_USER_BLACKLISTED,147 BVProtectRequest_V68 3::CATEGORY_GLOBAL_BOT_BLOCKED144 BVProtectRequest_V685::CATEGORY_BOT_BLOCKED, 145 BVProtectRequest_V685::CATEGORY_COUNTRY_BLOCKED, 146 BVProtectRequest_V685::CATEGORY_USER_BLACKLISTED, 147 BVProtectRequest_V685::CATEGORY_GLOBAL_BOT_BLOCKED 148 148 ); 149 149 } 150 150 151 151 public static function whitelistedCategories() { 152 return array(BVProtectRequest_V68 3::CATEGORY_WHITELISTED);152 return array(BVProtectRequest_V685::CATEGORY_WHITELISTED); 153 153 } 154 154 … … 488 488 } 489 489 490 $_json_params = BVProtectUtils_V68 3::safeDecodeJSON(490 $_json_params = BVProtectUtils_V685::safeDecodeJSON( 491 491 $this->raw_body, 492 492 true, -
blogvault-real-time-backup/tags/6.85/protect/wp_user.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectWPUser_V68 3')) :5 class BVProtectWPUser_V68 3{4 if (!class_exists('BVProtectWPUser_V685')) : 5 class BVProtectWPUser_V685 { 6 6 public $id; 7 7 public $role; … … 22 22 public static function defaultUser() { 23 23 $time = (int) floor(time() / 43200); 24 return (new BVProtectWPUser_V68 3(0, 0, array(), $time));24 return (new BVProtectWPUser_V685(0, 0, array(), $time)); 25 25 } 26 26 … … 42 42 $capabilities = array_map('intval', explode(',', $capabilities)); 43 43 44 return (new BVProtectWPUser_V68 3((int) $id, (int) $role_level, $capabilities, (int) $time));44 return (new BVProtectWPUser_V685((int) $id, (int) $role_level, $capabilities, (int) $time)); 45 45 } 46 46 -
blogvault-real-time-backup/tags/6.85/readme.txt
r3795700 r3813747 7 7 Tested up to: 7.1 8 8 Requires PHP: 7.0 9 Stable tag: 6.8 39 Stable tag: 6.85 10 10 License: GPLv2 or later 11 11 License URI: [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html) … … 271 271 272 272 == CHANGELOG == 273 = 6.85 = 274 * Improvement: Form test cleanup now also removes uploaded files, and checks each item against the test's record before deleting it. 275 * Improvement: Form tests now confirm what a test submission did (entry saved, notification email, integrations) without delivering the email, and remove the test entry afterwards. 276 * Improvement: Form tests support more form plugins, including their CAPTCHA and anti-spam checks. 277 * Improvement: Hardened the handling of form test requests. 278 273 279 = 6.83 = 274 280 * New: Broken Link Checker: checks your links from your own site, and highlights the broken ones on the page when you open it from the dashboard. -
blogvault-real-time-backup/trunk/blogvault.php
r3795700 r3813747 6 6 Author: Backup by BlogVault 7 7 Author URI: https://blogvault.net 8 Version: 6.8 38 Version: 6.85 9 9 Network: True 10 10 License: GPLv2 or later … … 187 187 require_once dirname( __FILE__ ) . '/protect/protect.php'; 188 188 //For backward compatibility. 189 BVProtect_V68 3::$settings = new BVWPSettings();190 BVProtect_V68 3::$db = new BVWPDb();191 BVProtect_V68 3::$info = new BVInfo(BVProtect_V683::$settings);192 193 add_action('bv_clear_pt_config', array('BVProtect_V68 3', 'uninstall'));189 BVProtect_V685::$settings = new BVWPSettings(); 190 BVProtect_V685::$db = new BVWPDb(); 191 BVProtect_V685::$info = new BVInfo(BVProtect_V685::$settings); 192 193 add_action('bv_clear_pt_config', array('BVProtect_V685', 'uninstall')); 194 194 195 195 if ($bvinfo->isActivePlugin()) { 196 BVProtect_V68 3::init(BVProtect_V683::MODE_WP);196 BVProtect_V685::init(BVProtect_V685::MODE_WP); 197 197 } 198 198 } -
blogvault-real-time-backup/trunk/callback/base.php
r3795700 r3813747 13 13 "DB_WING_VERSION" => '1.5', 14 14 "ACCOUNT_WING_VERSION" => '1.2', 15 "MISC_WING_VERSION" => '1. 4',15 "MISC_WING_VERSION" => '1.6', 16 16 "FS_WING_VERSION" => '1.4', 17 "INFO_WING_VERSION" => ' 2.9',17 "INFO_WING_VERSION" => '3.0', 18 18 "WATCH_WING_VERSION" => '1.7', 19 19 "FS_WRITE_WING_VERSION" => '1.2', … … 23 23 "SECURITY_WING_VERSION" => '1.4', 24 24 "LINKS_WING_VERSION" => '1.0', 25 "FORM_TESTING_WING_VERSION" => '1.0', 25 26 "SECURITY_HARDENING_SETTINGS_VERSION" => '1.0', 26 27 ); -
blogvault-real-time-backup/trunk/callback/handler.php
r3795700 r3813747 180 180 $module = new BVLinksCallback($this); 181 181 break; 182 case 'frmtst': 183 // Only the BlogVault, MalCare and WP Remote plugins carry this wing; the rest answer Bad Command. 184 $form_testing_wing = dirname( __FILE__ ) . '/wings/form_testing.php'; 185 if (!file_exists($form_testing_wing)) { 186 $module = null; 187 break; 188 } 189 require_once $form_testing_wing; 190 $module = new BVFormTestingCallback($this); 191 break; 182 192 default: 183 193 require_once dirname( __FILE__ ) . '/wings/misc.php'; -
blogvault-real-time-backup/trunk/callback/wings/info.php
r3795700 r3813747 11 11 public $bvapi; 12 12 13 const INFO_WING_VERSION = 2.9;13 const INFO_WING_VERSION = 3.0; 14 14 15 15 public function __construct($callback_handler) { … … 221 221 'templatedir' => get_template_directory(), 222 222 'dbcharset' => defined('DB_CHARSET') ? DB_CHARSET : null, 223 'mysql_client_flags' => defined('MYSQL_CLIENT_FLAGS') ? MYSQL_CLIENT_FLAGS : null, 223 224 'disallow_file_edit' => defined('DISALLOW_FILE_EDIT'), 224 225 'disallow_file_mods' => defined('DISALLOW_FILE_MODS'), -
blogvault-real-time-backup/trunk/callback/wings/ipstore.php
r3795700 r3813747 51 51 public function getIPs($table, $auto_increment_offset, $type, $category) { 52 52 $query = "SELECT `start_ip_range` FROM $table WHERE id < $auto_increment_offset AND `type` in (" . implode(',', $type) . ") AND "; 53 $query .= ($category == BVProtectIpstoreDB_V68 3::CATEGORY_FW) ? "`is_fw` = true;" : "`is_lp` = true;";53 $query .= ($category == BVProtectIpstoreDB_V685::CATEGORY_FW) ? "`is_fw` = true;" : "`is_lp` = true;"; 54 54 return $this->db->getCol($query); 55 55 } … … 65 65 66 66 $info['fw_blacklisted_ips'] = $this->getIPs($table, $auto_increment_offset, 67 BVProtectIpstoreDB_V68 3::blacklistedTypes(), BVProtectIpstoreDB_V683::CATEGORY_FW);67 BVProtectIpstoreDB_V685::blacklistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_FW); 68 68 $info['lp_blacklisted_ips'] = $this->getIPs($table, $auto_increment_offset, 69 BVProtectIpstoreDB_V68 3::blacklistedTypes(), BVProtectIpstoreDB_V683::CATEGORY_LP);69 BVProtectIpstoreDB_V685::blacklistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_LP); 70 70 $info['fw_whitelisted_ips'] = $this->getIPs($table, $auto_increment_offset, 71 BVProtectIpstoreDB_V68 3::whitelistedTypes(), BVProtectIpstoreDB_V683::CATEGORY_FW);71 BVProtectIpstoreDB_V685::whitelistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_FW); 72 72 $info['lp_whitelisted_ips'] = $this->getIPs($table, $auto_increment_offset, 73 BVProtectIpstoreDB_V68 3::whitelistedTypes(), BVProtectIpstoreDB_V683::CATEGORY_LP);73 BVProtectIpstoreDB_V685::whitelistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_LP); 74 74 $info['ip_store_offset'] = $this->getIPStoreOffset($table, $auto_increment_offset); 75 75 $info['country_ips_size'] = intval($db->getVar("SELECT COUNT(id) FROM $table WHERE id >= $auto_increment_offset")); -
blogvault-real-time-backup/trunk/callback/wings/misc.php
r3158138 r3813747 12 12 public $db; 13 13 14 const MISC_WING_VERSION = 1. 4;14 const MISC_WING_VERSION = 1.6; 15 15 16 16 public function __construct($callback_handler) { -
blogvault-real-time-backup/trunk/callback/wings/protect.php
r3795700 r3813747 41 41 42 42 public function unBlockIP($ip, $attempts, $time) { 43 $transient_name = BVProtectLP_V68 3::UNBLOCK_IP_TRANSIENT_PREFIX . $ip;43 $transient_name = BVProtectLP_V685::UNBLOCK_IP_TRANSIENT_PREFIX . $ip; 44 44 $this->settings->setTransient($transient_name, $attempts, $time); 45 45 return $this->settings->getTransient($transient_name); -
blogvault-real-time-backup/trunk/callback/wings/watch.php
r3795700 r3813747 145 145 require_once dirname( __FILE__ ) . '/../../protect/lp.php'; 146 146 $lp_params = $params['lp']; 147 if (!isset($lp_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVProtectLP_V68 3::TABLE_NAME))) {147 if (!isset($lp_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVProtectLP_V685::TABLE_NAME))) { 148 148 $limit = intval($lp_params['limit']); 149 149 $filter = $lp_params['filter']; 150 150 $offset = isset($lp_params['offset']) ? intval($lp_params['offset']) : 0; 151 $table = $db->getBVTable(BVProtectLP_V68 3::TABLE_NAME);151 $table = $db->getBVTable(BVProtectLP_V685::TABLE_NAME); 152 152 $resp["lplogs"] = $this->getOffsetResetInfo($lp_params, $offset, $table); 153 153 if (empty($resp["lplogs"])) { 154 $db->deleteBVTableContent(BVProtectLP_V68 3::TABLE_NAME, $lp_params['rmfilter']);154 $db->deleteBVTableContent(BVProtectLP_V685::TABLE_NAME, $lp_params['rmfilter']); 155 155 $resp["lplogs"] = $this->getData($table, $limit, $filter); 156 156 } … … 168 168 require_once dirname( __FILE__ ) . '/../../protect/fw.php'; 169 169 $fw_params = $params['fw']; 170 if (!isset($fw_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVProtectFW_V68 3::TABLE_NAME))) {170 if (!isset($fw_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVProtectFW_V685::TABLE_NAME))) { 171 171 $limit = intval($fw_params['limit']); 172 172 $filter = $fw_params['filter']; 173 173 $offset = isset($fw_params['offset']) ? intval($fw_params['offset']) : 0; 174 $table = $db->getBVTable(BVProtectFW_V68 3::TABLE_NAME);174 $table = $db->getBVTable(BVProtectFW_V685::TABLE_NAME); 175 175 $resp["fwlogs"] = $this->getOffsetResetInfo($fw_params, $offset, $table); 176 176 if (empty($resp["fwlogs"])){ 177 $db->deleteBVTableContent(BVProtectFW_V68 3::TABLE_NAME, $fw_params['rmfilter']);177 $db->deleteBVTableContent(BVProtectFW_V685::TABLE_NAME, $fw_params['rmfilter']); 178 178 $resp["fwlogs"] = $this->getData($table, $limit, $filter); 179 179 } -
blogvault-real-time-backup/trunk/form_testing/form_testing.php
r3220024 r3813747 2 2 3 3 if (!defined('ABSPATH')) exit; 4 5 require_once dirname(__FILE__) . '/recorder.php'; 6 require_once dirname(__FILE__) . '/entries.php'; 7 4 8 if (!class_exists('BVFormTesting')) : 5 9 10 // Form test mode for one signed test submission: the tested form's CAPTCHA, email and anti-spam bypasses, and the recorder. 6 11 class BVFormTesting { 7 12 private $form_type; … … 9 14 private $spam_bypass; 10 15 private $bypass_params = array(); 16 private $run_id; 17 private $capture_mail; 18 private $block_http; 19 private $captcha_live; 11 20 12 21 public function __construct($params) { … … 15 24 $this->spam_bypass = isset($params['bv_ignr_spm_plgns']); 16 25 17 if (isset($params['bv_ignr_frm_cptch'])) { 26 $this->captcha_live = isset($params['bv_frm_cptch_live']); 27 // A live-captcha run tests that the form rejects a wrong token: never bypass the captcha then. 28 if (isset($params['bv_ignr_frm_cptch']) && !$this->captcha_live) { 18 29 $this->bypass_params['should_bypass_captcha'] = true; 19 30 } … … 22 33 $this->bypass_params['should_bypass_email'] = true; 23 34 } 35 36 $run_id = isset($params['bv_frm_run']) && is_string($params['bv_frm_run']) ? sanitize_text_field(wp_unslash($params['bv_frm_run'])) : null; 37 $this->run_id = BVFormTestRecorder::isValidRunId($run_id) ? $run_id : null; 38 $this->capture_mail = isset($params['bv_frm_cptr_ml']); 39 $this->block_http = isset($params['bv_frm_blk_http']); 40 } 41 42 /** 43 * Request fields that only a login, registration, checkout or comment sends: exact names, never a pattern (form fields 44 * such as "mf-password" must not match). WordPress's login sends "log" and "pwd" together. 45 */ 46 private static $refused_fields = array('woocommerce-login-nonce', 'woocommerce-register-nonce', 'woocommerce-process-checkout-nonce', 47 'woocommerce-lost-password-nonce', 'woocommerce-reset-password-nonce', 'woocommerce-edit-account-nonce', 'wc-ajax', 'comment_post_ID'); 48 49 /** 50 * Whether this is a request a form test never makes (see the class comment): login, registration, comments, 51 * XML-RPC, cron, an admin screen other than admin-ajax.php, a WooCommerce login, checkout or account form. 52 */ 53 public function isRefusedRequest($request) { 54 $request = (array) $request; 55 if (defined('XMLRPC_REQUEST') || defined('DOING_CRON') || defined('WP_INSTALLING')) { 56 return true; 57 } 58 $script = isset($_SERVER['SCRIPT_NAME']) && is_string($_SERVER['SCRIPT_NAME']) ? basename($_SERVER['SCRIPT_NAME']) : ''; 59 if (defined('DOING_AJAX') && DOING_AJAX) { 60 if ($script !== 'admin-ajax.php') { 61 return true; 62 } 63 } elseif (is_admin() || $script !== 'index.php') { 64 return true; 65 } 66 if (isset($request['log'], $request['pwd'])) { 67 return true; 68 } 69 foreach (self::$refused_fields as $field) { 70 if (isset($request[$field])) { 71 return true; 72 } 73 } 74 return false; 24 75 } 25 76 26 77 public function init() { 78 // Refused, not handled as a normal request: a test submission carried on without test mode would be a real one. 79 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 80 if ($this->isRefusedRequest($_REQUEST)) { 81 wp_die(esc_html('Form test refused for this request.'), '', array('response' => 403)); 82 } 83 27 84 if ($this->spam_bypass === true) { 28 85 $this->bypassSpamPlugins(); 29 86 } 30 87 88 $recorder = null; 89 if ($this->run_id !== null) { 90 $recorder = new BVFormTestRecorder($this->run_id, $this->capture_mail, $this->block_http, $this->captcha_live, 91 array_key_exists('should_bypass_captcha', $this->bypass_params), $this->form_id); 92 $recorder->start(); 93 BVFormTestEntries::watch($recorder); 94 $this->watchSubmissionEvents($recorder); 95 } 96 97 // Mail capture can only be decided once wp_mail() exists (after all plugins load), and the 98 // plugin's own email suppression depends on it, so with capture requested both wait for 99 // plugins_loaded. That is still before any form plugin handles the submission. 100 if ($recorder !== null && $this->capture_mail) { 101 $this->whenPluginsLoaded(function () use ($recorder) { 102 $this->applyBypass($recorder); 103 }); 104 } else { 105 $this->applyBypass($recorder); 106 } 107 } 108 109 private function applyBypass($recorder) { 110 if ($recorder !== null) { 111 $recorder->setupMailCapture(); 112 // Captured mail never leaves the site, so let the plugin send it to wp_mail() and record it. 113 if ($recorder->captureMailEnabled()) { 114 unset($this->bypass_params['should_bypass_email']); 115 } 116 } 117 118 // Always, even with nothing to bypass: besides the CAPTCHA and email bypasses, each handler keeps the test's 119 // side effects in check (integrations, created posts and users, asynchronous work), which a submission must 120 // never skip. The wrong-CAPTCHA run (bv_frm_cptch_live) with mail capture has no bypass at all, and is exactly 121 // the run that goes through as a real submission when the form accepts the wrong token. 31 122 $handler = $this->getHandler($this->form_type); 32 if ($handler === null) { 33 return; 34 } 35 36 if (empty($this->bypass_params) === false) { 123 if ($handler !== null) { 37 124 $handler->bypass(); 125 } 126 } 127 128 /** Form plugins that store no entry id, or whose handler reports what it did: record the submission's events. */ 129 private function watchSubmissionEvents($recorder) { 130 switch ($this->form_type) { 131 case 'ElementorProForm': 132 require_once dirname(__FILE__) . '/handlers/elementor_pro_form.php'; 133 BVElementorProFormHandler::watch($recorder); 134 break; 135 case 'DiviForm': 136 require_once dirname(__FILE__) . '/handlers/divi_form.php'; 137 BVDiviFormHandler::watch($recorder); 138 break; 139 case 'SpectraForm': 140 require_once dirname(__FILE__) . '/handlers/spectra_form.php'; 141 BVSpectraFormHandler::watch($recorder); 142 break; 143 case 'KadenceForm': 144 require_once dirname(__FILE__) . '/handlers/kadence_form.php'; 145 BVKadenceFormHandler::watch($recorder); 146 break; 147 case 'BeaverBuilderForm': 148 require_once dirname(__FILE__) . '/handlers/beaver_builder_form.php'; 149 BVBeaverBuilderFormHandler::watch($recorder); 150 break; 151 case 'Mc4wpForm': 152 require_once dirname(__FILE__) . '/handlers/mc4wp_form.php'; 153 BVMc4wpFormHandler::watch($recorder); 154 break; 155 case 'JetEngineForm': 156 require_once dirname(__FILE__) . '/handlers/jet_engine_form.php'; 157 BVJetEngineFormHandler::watch($recorder); 158 break; 159 case 'FluentForm': 160 require_once dirname(__FILE__) . '/handlers/fluent_form.php'; 161 BVFluentFormHandler::watch($recorder); 162 break; 163 } 164 } 165 166 private function whenPluginsLoaded($callback) { 167 if (did_action('plugins_loaded')) { 168 call_user_func($callback); 169 } else { 170 add_action('plugins_loaded', $callback, PHP_INT_MIN); 38 171 } 39 172 } … … 59 192 require_once dirname(__FILE__) . '/handlers/formidable_form.php'; 60 193 return new BVFormidableFormHandler($this->form_id, $this->bypass_params); 194 case 'FluentForm': 195 require_once dirname(__FILE__) . '/handlers/fluent_form.php'; 196 return new BVFluentFormHandler($this->form_id, $this->bypass_params); 197 case 'ElementorProForm': 198 require_once dirname(__FILE__) . '/handlers/elementor_pro_form.php'; 199 return new BVElementorProFormHandler($this->form_id, $this->bypass_params); 200 case 'DiviForm': 201 require_once dirname(__FILE__) . '/handlers/divi_form.php'; 202 return new BVDiviFormHandler($this->form_id, $this->bypass_params); 203 case 'MetForm': 204 require_once dirname(__FILE__) . '/handlers/met_form.php'; 205 return new BVMetFormHandler($this->form_id, $this->bypass_params); 206 case 'JetFormBuilderForm': 207 require_once dirname(__FILE__) . '/handlers/jet_form_builder_form.php'; 208 return new BVJetFormBuilderFormHandler($this->form_id, $this->bypass_params); 209 case 'SureForm': 210 require_once dirname(__FILE__) . '/handlers/sure_form.php'; 211 return new BVSureFormHandler($this->form_id, $this->bypass_params); 212 case 'JetpackForm': 213 require_once dirname(__FILE__) . '/handlers/jetpack_form.php'; 214 return new BVJetpackFormHandler($this->form_id, $this->bypass_params); 215 case 'SpectraForm': 216 require_once dirname(__FILE__) . '/handlers/spectra_form.php'; 217 return new BVSpectraFormHandler($this->form_id, $this->bypass_params); 218 case 'KadenceForm': 219 require_once dirname(__FILE__) . '/handlers/kadence_form.php'; 220 return new BVKadenceFormHandler($this->form_id, $this->bypass_params); 221 case 'BeaverBuilderForm': 222 require_once dirname(__FILE__) . '/handlers/beaver_builder_form.php'; 223 return new BVBeaverBuilderFormHandler($this->form_id, $this->bypass_params); 224 case 'AvadaForm': 225 require_once dirname(__FILE__) . '/handlers/avada_form.php'; 226 return new BVAvadaFormHandler($this->form_id, $this->bypass_params); 227 case 'MailPoetForm': 228 require_once dirname(__FILE__) . '/handlers/mail_poet_form.php'; 229 return new BVMailPoetFormHandler($this->form_id, $this->bypass_params); 230 case 'Mc4wpForm': 231 require_once dirname(__FILE__) . '/handlers/mc4wp_form.php'; 232 return new BVMc4wpFormHandler($this->form_id, $this->bypass_params); 233 case 'JetEngineForm': 234 require_once dirname(__FILE__) . '/handlers/jet_engine_form.php'; 235 return new BVJetEngineFormHandler($this->form_id, $this->bypass_params); 61 236 default: 62 237 return null; -
blogvault-real-time-backup/trunk/form_testing/handlers/contact_form7.php
r3220024 r3813747 24 24 25 25 private function bypassCaptcha() { 26 // Spam check: reCAPTCHA v3, Turnstile, Akismet, disallowed list. 26 27 add_filter('wpcf7_skip_spam_check', '__return_true', PHP_INT_MAX); 28 29 // Quiz and Really Simple CAPTCHA are validated per field instead. Their answers are tied to a 30 // random question or a single-use image, so unhook their validators just before they run. 31 add_filter('wpcf7_validate_quiz', array($this, 'skipQuizValidation'), 9, 1); 32 add_filter('wpcf7_validate_captchar', array($this, 'skipCaptchaValidation'), 9, 1); 33 } 34 35 public function skipQuizValidation($result) { 36 remove_filter('wpcf7_validate_quiz', 'wpcf7_quiz_validation_filter', 10); 37 return $result; 38 } 39 40 public function skipCaptchaValidation($result) { 41 remove_filter('wpcf7_validate_captchar', 'wpcf7_captcha_validation_filter', 10); 42 return $result; 27 43 } 28 44 -
blogvault-real-time-backup/trunk/form_testing/handlers/formidable_form.php
r3220024 r3813747 14 14 15 15 public function bypass() { 16 // Report spam as an error instead of silently saving a spam entry behind a success message. 17 add_filter('frm_save_spam_entry', '__return_false', PHP_INT_MAX); 18 16 19 if (array_key_exists('should_bypass_captcha', $this->bypass_params)) { 17 20 $this->bypassCaptcha(); … … 24 27 25 28 public function bypassCaptcha() { 26 add_filter('frm_is_field_hidden', '__return_true', PHP_INT_MAX); 29 // Only the captcha field: Formidable Pro also uses this filter for conditional logic on every field. 30 add_filter('frm_is_field_hidden', array($this, 'hideCaptchaField'), PHP_INT_MAX, 2); 31 // Anti-spam a direct test POST can't pass: the JavaScript token and the honeypot. 32 add_filter('frm_run_antispam', '__return_false', PHP_INT_MAX); 33 add_filter('frm_run_honeypot', '__return_false', PHP_INT_MAX); 34 } 35 36 public function hideCaptchaField($is_hidden, $field) { 37 $type = is_array($field) ? (isset($field['type']) ? $field['type'] : '') : (isset($field->type) ? $field->type : ''); 38 return ($type === 'captcha') ? true : $is_hidden; 27 39 } 28 40 -
blogvault-real-time-backup/trunk/form_testing/handlers/forminator_form.php
r3220024 r3813747 7 7 private $form_id; 8 8 private $bypass_params = array(); 9 private $captcha_endpoints = array(); 10 private $created_posts = array(); 11 private $created_attachments = array(); 9 12 10 13 public function __construct($form_id, $bypass_params) { … … 21 24 $this->bypassEmail(); 22 25 } 26 27 $this->allowPollTestVotes(); 28 $this->discardPostDataPosts(); 23 29 } 24 30 31 private function isTestedModule($module_id) { 32 return (string) $module_id === (string) $this->form_id; 33 } 34 35 /** 36 * Forminator verifies reCAPTCHA (v2 checkbox, v2 invisible, v3), hCaptcha and Turnstile tokens with 37 * Forminator_Captcha_Verification::verify(), a wp_remote_request() to the provider's siteverify URL that 38 * it passes through the forminator_<provider>_verify_endpoint filter. We note that URL and answer the 39 * request ourselves with a passing verdict, so only Forminator's own verification is affected. 40 */ 25 41 public function bypassCaptcha() { 42 foreach (array('recaptcha', 'hcaptcha', 'turnstile') as $provider) { 43 add_filter("forminator_{$provider}_verify_endpoint", function ($endpoint) use ($provider) { 44 if (is_string($endpoint) && $endpoint !== '') { 45 $this->captcha_endpoints[$endpoint] = $provider; 46 } 47 return $endpoint; 48 }, PHP_INT_MAX); 49 } 50 add_filter('pre_http_request', array($this, 'stubCaptchaVerification'), PHP_INT_MAX - 1, 3); 51 52 // Forminator before 1.58 skipped its captcha check while a Stripe field was hidden. 53 // From 1.58 a hidden Stripe field means "verify the payment token", which needs a token we don't have. 54 $this->whenForminatorLoaded(function () { 55 if (defined('FORMINATOR_VERSION') && version_compare(FORMINATOR_VERSION, '1.58.0', '<')) { 56 $this->markStripeHidden(); 57 } 58 }); 59 } 60 61 public function stubCaptchaVerification($preempt, $args, $url) { 62 if ($preempt !== false || !is_string($url) || !isset($this->captcha_endpoints[$url])) { 63 return $preempt; 64 } 65 66 $verdict = array('success' => true, 'hostname' => BVFormTestRecorder::parseUrl(home_url(), PHP_URL_HOST)); 67 // Only reCAPTCHA v3 checks a score, and it wants a high one. 68 if ($this->captcha_endpoints[$url] === 'recaptcha') { 69 $verdict['score'] = 1.0; 70 } 71 72 return array( 73 'headers' => array(), 74 'body' => BVFormTestRecorder::jsonEncode($verdict), 75 'response' => array('code' => 200, 'message' => 'OK'), 76 'cookies' => array(), 77 'filename' => null 78 ); 79 } 80 81 private function markStripeHidden() { 26 82 if (defined('WP_PLUGIN_DIR')) { 27 83 $abstract_front_action_file_path = WP_PLUGIN_DIR . '/forminator/library/abstracts/abstract-class-front-action.php'; … … 45 101 } 46 102 } 103 104 /** 105 * Polls accept one vote per IP (or browser cookie). A test vote must neither be refused because an 106 * earlier test voted, nor lock the poll for the monitoring server's IP: we let the test vote through 107 * and don't store the voter IP with it. 108 */ 109 private function allowPollTestVotes() { 110 add_filter('forminator_poll_handle_form_user_can_vote', function ($can_vote, $poll_id) { 111 return $this->isTestedModule($poll_id) ? true : $can_vote; 112 }, PHP_INT_MAX, 2); 113 114 // Forminator also blocks the voter's IP for a few seconds after a vote; lift that block for a test vote. 115 add_action('forminator_polls_submit_before_set_fields', function ($entry, $poll_id) { 116 if ($this->isTestedModule($poll_id)) { 117 add_action('shutdown', function () use ($poll_id) { 118 $this->clearPollVoteLock($poll_id); 119 }, 0); 120 } 121 }, PHP_INT_MAX, 2); 122 123 add_filter('forminator_polls_submit_field_data', function ($field_data, $poll_id) { 124 if (!$this->isTestedModule($poll_id) || !is_array($field_data)) { 125 return $field_data; 126 } 127 return array_values(array_filter($field_data, function ($item) { 128 return !(is_array($item) && isset($item['name']) && $item['name'] === '_forminator_user_ip'); 129 })); 130 }, PHP_INT_MAX, 2); 131 } 132 133 private function clearPollVoteLock($poll_id) { 134 if (!class_exists('Forminator_Geo') || !method_exists('Forminator_Geo', 'get_user_ip')) { 135 return; 136 } 137 $user_ip = Forminator_Geo::get_user_ip(); 138 delete_transient('forminator_request_from_ip_' . $poll_id . '_' . $user_ip); 139 delete_option('forminator_poll_ip_lock_' . $poll_id . '_' . md5($user_ip)); 140 } 141 142 /** 143 * A Post Data field creates a post. For a test submission it is created as a draft (never published, 144 * so no publish notifications or auto-sharing) and deleted, with any featured image uploaded by the 145 * submission, once the request ends. 146 */ 147 private function discardPostDataPosts() { 148 add_filter('forminator_post_data_post_info', function ($post) { 149 if ($this->isCurrentForm() && is_array($post)) { 150 $post['post_status'] = 'draft'; 151 } 152 return $post; 153 }, PHP_INT_MAX); 154 155 add_action('forminator_post_data_field_post_saved', function ($post_id) { 156 if ($this->isCurrentForm()) { 157 $this->created_posts[] = absint($post_id); 158 } 159 }, PHP_INT_MAX); 160 161 add_action('add_attachment', function ($attachment_id) { 162 if ($this->isCurrentForm()) { 163 $this->created_attachments[] = absint($attachment_id); 164 } 165 }, PHP_INT_MAX); 166 167 add_action('shutdown', array($this, 'deleteCreatedPosts'), 0); 168 } 169 170 private function isCurrentForm() { 171 return class_exists('Forminator_CForm_Front_Action') && isset(Forminator_CForm_Front_Action::$module_id) && 172 $this->isTestedModule(Forminator_CForm_Front_Action::$module_id); 173 } 174 175 public function deleteCreatedPosts() { 176 foreach ($this->created_posts as $post_id) { 177 $post = get_post($post_id); 178 if ($post_id === 0 || !$post || $post->post_status !== 'draft') { 179 continue; 180 } 181 $thumbnail_id = (int) get_post_thumbnail_id($post_id); 182 if ($thumbnail_id > 0 && in_array($thumbnail_id, $this->created_attachments, true)) { 183 wp_delete_attachment($thumbnail_id, true); 184 } 185 wp_delete_post($post_id, true); 186 } 187 $this->created_posts = array(); 188 } 189 190 private function whenForminatorLoaded($callback) { 191 if (did_action('plugins_loaded')) { 192 call_user_func($callback); 193 } else { 194 add_action('plugins_loaded', $callback, PHP_INT_MIN); 195 } 196 } 47 197 } 48 198 -
blogvault-real-time-backup/trunk/form_testing/handlers/gravity_form.php
r3220024 r3813747 21 21 $this->bypassEmail(); 22 22 } 23 24 $this->bypassContentCreation(); 25 $this->keepSideEffectsInRequest(); 26 $this->bypassTotalValidation(); 27 } 28 29 /** 30 * Gravity Forms 2.10+ sends notifications from a background request by default (and add-ons may 31 * process feeds in one), where the test's email suppression, mail capture and HTTP blocking are not 32 * active. Process them within the test request instead. 33 */ 34 public function keepSideEffectsInRequest() { 35 if ($this->form_id === null) { 36 return; 37 } 38 39 $form_id = absint($this->form_id); 40 add_filter('gform_is_asynchronous_notifications_enabled_' . $form_id, '__return_false', PHP_INT_MAX); 41 add_filter('gform_is_feed_asynchronous_' . $form_id, '__return_false', PHP_INT_MAX); 42 } 43 44 /** 45 * The Total field is filled by the browser from the pricing fields; Gravity Forms recalculates the 46 * total when it saves the entry, so the submitted value is not compared for a test submission. 47 */ 48 public function bypassTotalValidation() { 49 if ($this->form_id === null) { 50 return; 51 } 52 53 add_filter('gform_pre_validation_' . absint($this->form_id), function($form) { 54 foreach ($form['fields'] as &$field) { 55 if ($field->type === 'total') { 56 $field->validateTotal = false; 57 } 58 } 59 return $form; 60 }, PHP_INT_MAX); 61 } 62 63 /** 64 * A test submission must not create posts (Post fields) or WordPress users (User Registration add-on) 65 * on the site. Advanced Post Creation feeds are skipped for the same reason. 66 */ 67 public function bypassContentCreation() { 68 if ($this->form_id === null) { 69 return; 70 } 71 72 $form_id = absint($this->form_id); 73 add_filter('gform_disable_post_creation_' . $form_id, '__return_true', PHP_INT_MAX); 74 add_filter('gform_gravityformsuserregistration_pre_process_feeds_' . $form_id, '__return_empty_array', PHP_INT_MAX); 75 add_filter('gform_gravityformsadvancedpostcreation_pre_process_feeds_' . $form_id, '__return_empty_array', PHP_INT_MAX); 23 76 } 24 77 … … 36 89 return $form; 37 90 }, PHP_INT_MAX); 91 92 // Honeypot and the submission speed check (2.9.21+) mark a scripted submission as spam or abort it. 93 add_filter('gform_pre_process_' . absint($this->form_id), function($form) { 94 if (is_array($form)) { 95 $form['enableHoneypot'] = false; 96 $form['enableSubmitSpeedCheck'] = false; 97 } 98 return $form; 99 }, PHP_INT_MAX); 100 101 // Akismet (Gravity Forms' own integration) would mark the test entry as spam. 102 add_filter('gform_akismet_enabled_' . absint($this->form_id), '__return_false', PHP_INT_MAX); 38 103 } 39 104 -
blogvault-real-time-backup/trunk/form_testing/handlers/ninja_form.php
r3220024 r3813747 24 24 25 25 public function bypassCaptcha() { 26 // Field captchas (reCAPTCHA v2, hCaptcha, Turnstile, the spam question): a null type skips the field's validation. 26 27 add_filter('ninja_forms_pre_validate_field_settings', function ($field_settings) { 27 if (isset($field_settings['type']) && in_array($field_settings['type'], ['recaptcha', 'spam'], true)) { 28 $captcha_types = array('recaptcha', 'recaptcha_v3', 'hcaptcha', 'turnstile', 'spam'); 29 if (isset($field_settings['type']) && in_array($field_settings['type'], $captcha_types, true)) { 28 30 $field_settings['type'] = null; 29 31 } … … 31 33 }, PHP_INT_MAX); 32 34 35 // reCAPTCHA v3 is a form action (type "recaptcha") that verifies the injected token. 33 36 add_filter('ninja_forms_run_action_type_recaptcha', '__return_false', PHP_INT_MAX); 34 37 } -
blogvault-real-time-backup/trunk/form_testing/handlers/wp_form.php
r3220024 r3813747 4 4 if (!class_exists('BVWPFormHandler')) : 5 5 6 // WPForms (Lite and Pro): CAPTCHA, anti-spam, email and upload handling for the tested form in a signed test request. 6 7 class BVWPFormHandler { 7 8 private $form_id; … … 21 22 $this->bypassEmail(); 22 23 } 24 25 $this->sendEmailsInRequest(); 26 $this->acceptModernUploads(); 27 $this->skipMediaLibrary(); 23 28 } 24 29 25 30 public function bypassCaptcha() { 26 31 add_filter('wpforms_process_bypass_captcha', '__return_true', PHP_INT_MAX); 32 add_filter('wpforms_process_antispam', '__return_true', PHP_INT_MAX); 33 add_filter('wpforms_process_honeypot', '__return_false', PHP_INT_MAX); 34 add_filter('wpforms_process_anti_spam_honeypot_bypass', '__return_true', PHP_INT_MAX); 35 add_filter('wpforms_process_anti_spam_direct_post_bypass', '__return_true', PHP_INT_MAX); 36 $form_id = (string) $this->form_id; 37 // Custom Captcha addon: validated as field type "captcha" (wpforms_process_validate_captcha). 38 add_action('wpforms_process_validate_captcha', function ($field_id, $field_submit, $form_data) use ($form_id) { 39 if (!is_array($form_data) || !isset($form_data['id']) || (string) $form_data['id'] !== $form_id || !function_exists('wpforms')) { 40 return; 41 } 42 $process = wpforms()->get('process'); 43 if (is_object($process) && isset($process->errors[$form_data['id']][$field_id])) { 44 unset($process->errors[$form_data['id']][$field_id]); 45 } 46 }, PHP_INT_MAX, 3); 27 47 } 28 48 … … 30 50 add_filter('wpforms_entry_email', '__return_false', PHP_INT_MAX); 31 51 } 52 53 /** 54 * With "Optimize Email Sending" (setting email-async), WPForms 1.8.5+ queues each notification as an Action 55 * Scheduler task that a later request sends, outside test mode: a real email that mail capture never sees. Send 56 * the tested form's notifications in this request instead. 57 */ 58 public function sendEmailsInRequest() { 59 $form_id = (string) $this->form_id; 60 add_filter('wpforms_tasks_entry_emails_trigger_send_same_process', function ($same_process, $fields = array(), $entry = array(), $form_data = array()) use ($form_id) { 61 if ($form_id === '' || (is_array($form_data) && isset($form_data['id']) && (string) $form_data['id'] === $form_id)) { 62 return true; 63 } 64 return $same_process; 65 }, PHP_INT_MAX, 4); 66 } 67 68 public function skipMediaLibrary() { 69 $form_id = (string) $this->form_id; 70 add_filter('wpforms_process_before_form_data', function ($form_data) use ($form_id) { 71 if (!is_array($form_data) || !isset($form_data['id'], $form_data['fields']) || (string) $form_data['id'] !== $form_id || !is_array($form_data['fields'])) { 72 return $form_data; 73 } 74 foreach ($form_data['fields'] as $key => $field) { 75 if (is_array($field) && isset($field['type']) && in_array($field['type'], array('file-upload', 'camera'), true) && !empty($field['media_library'])) { 76 $form_data['fields'][$key]['media_library'] = '0'; 77 } 78 } 79 return $form_data; 80 }, PHP_INT_MAX, 1); 81 } 82 83 public function acceptModernUploads() { 84 $form_id = (string) $this->form_id; 85 add_action('wpforms_process_before', function ($entry, $form_data) use ($form_id) { 86 if (!is_array($form_data) || !isset($form_data['id'], $form_data['fields']) || (string) $form_data['id'] !== $form_id || 87 empty($_FILES) || !function_exists('wpforms_upload_dir')) { 88 return; 89 } 90 foreach ((array) $form_data['fields'] as $field) { 91 if (is_array($field) && isset($field['type'], $field['id'], $field['style']) && $field['type'] === 'file-upload' && $field['style'] === 'modern') { 92 BVWPFormHandler::storeModernUpload(sprintf('wpforms_%d_%d', absint($form_data['id']), absint($field['id'])), $field); 93 } 94 } 95 }, 1, 2); 96 } 97 98 /** 99 * Extensions WPForms refuses whatever the site allows (WPForms FileMethodsTrait::$denylist, plus the other PHP 100 * extensions servers may run). 101 */ 102 private static $denied_extensions = array( 103 'ade', 'adp', 'app', 'asp', 'bas', 'bat', 'cer', 'cgi', 'chm', 'cmd', 'com', 'cpl', 'crt', 'csh', 'csr', 'dfxp', 104 'dll', 'drv', 'exe', 'flv', 'fxp', 'hlp', 'hta', 'htaccess', 'htm', 'html', 'htpasswd', 'inf', 'ins', 'isp', 105 'jar', 'js', 'jse', 'jsp', 'ksh', 'lnk', 'mdb', 'mde', 'mdt', 'mdw', 'msc', 'msi', 'msp', 'mst', 'onetmp', 'ops', 106 'pcd', 'phar', 'php', 'php3', 'php4', 'php5', 'php7', 'php8', 'pht', 'phtml', 'pif', 'pl', 'prg', 'ps1', 'ps2', 107 'py', 'rb', 'reg', 'scr', 'sct', 'sh', 'shb', 'shs', 'swf', 'sys', 'tmp', 'torrent', 'url', 'vb', 'vbe', 'vbs', 108 'vbscript', 'wsc', 'wsf', 'wsh' 109 ); 110 111 /** 112 * The extensions a file upload field accepts, as WPForms works them out: the field's list (all when empty), 113 * limited to the file types WordPress allows, without the denied extensions. 114 */ 115 public static function allowedExtensions($field) { 116 $allowed = array(); 117 foreach (array_keys(get_allowed_mime_types()) as $extensions) { 118 foreach (explode('|', $extensions) as $extension) { 119 $allowed[] = strtolower($extension); 120 } 121 } 122 $allowed = array_diff($allowed, self::$denied_extensions); 123 if (is_array($field) && !empty($field['extensions']) && is_string($field['extensions'])) { 124 $listed = array(); 125 foreach (explode(',', $field['extensions']) as $extension) { 126 $listed[] = strtolower(preg_replace('/[^A-Za-z0-9_-]/', '', $extension)); 127 } 128 $allowed = array_intersect($allowed, $listed); 129 } 130 return array_values(array_unique($allowed)); 131 } 132 133 /** 134 * Moves one posted file of a modern upload field into the WPForms tmp folder and posts its JSON description. 135 * A file whose extension or type the field doesn't accept is left out, and stays in PHP's upload folder (deleted 136 * when the request ends), so WPForms reports the field as empty or required. A file moved into the tmp folder that 137 * WPForms doesn't take into the form's folder is deleted when the request ends. 138 */ 139 public static function storeModernUpload($input_name, $field) { 140 // phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput 141 if (!empty($_POST[$input_name]) || !isset($_FILES[$input_name]['tmp_name'], $_FILES[$input_name]['name'], $_FILES[$input_name]['error']) || 142 !is_string($_FILES[$input_name]['tmp_name']) || !is_string($_FILES[$input_name]['name']) || 143 (int) $_FILES[$input_name]['error'] !== UPLOAD_ERR_OK || !is_uploaded_file($_FILES[$input_name]['tmp_name'])) { 144 return; 145 } 146 $file = $_FILES[$input_name]; 147 unset($_FILES[$input_name]); 148 // phpcs:enable 149 150 $name = sanitize_file_name(wp_unslash($file['name'])); 151 $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION)); 152 if ($name === '' || $extension === '' || !in_array($extension, self::allowedExtensions($field), true)) { 153 return; 154 } 155 // WordPress's own check of the name against the content (images are sniffed): refused when it finds no 156 // allowed type, or when it would rename the file. 157 $filetype = wp_check_filetype_and_ext($file['tmp_name'], $name); 158 if (empty($filetype['ext']) || empty($filetype['type']) || !empty($filetype['proper_filename']) || 159 strtolower($filetype['ext']) !== $extension) { 160 return; 161 } 162 163 $upload_dir = wpforms_upload_dir(); 164 if (!is_array($upload_dir) || empty($upload_dir['path']) || empty($upload_dir['url'])) { 165 return; 166 } 167 $tmp_dir = $upload_dir['path'] . '/tmp'; 168 if (!wp_mkdir_p($tmp_dir)) { 169 return; 170 } 171 $tmp_name = wp_hash(wp_rand() . microtime() . $input_name) . '.' . $extension; 172 $tmp_path = $tmp_dir . '/' . $tmp_name; 173 if (!move_uploaded_file($file['tmp_name'], $tmp_path)) { 174 return; 175 } 176 // WPForms moves the file out of the tmp folder when the entry is saved; anything left is a failed submission. 177 add_action('shutdown', function () use ($tmp_path) { 178 if (is_file($tmp_path)) { 179 BVFormTestRecorder::deleteFile($tmp_path); 180 } 181 }); 182 if (function_exists('wpforms_sanitize_svg_file') && !wpforms_sanitize_svg_file($tmp_path)) { 183 BVFormTestRecorder::deleteFile($tmp_path); 184 return; 185 } 186 187 $_POST[$input_name] = wp_slash(BVFormTestRecorder::jsonEncode(array(array( 188 'name' => $name, 189 'file' => $tmp_name, 190 'url' => $upload_dir['url'] . '/tmp/' . $tmp_name, 191 'size' => filesize($tmp_path), 192 'type' => $filetype['type'], 193 'file_user_name' => $name 194 )))); 195 } 32 196 } 33 197 -
blogvault-real-time-backup/trunk/info.php
r3795700 r3813747 12 12 public $brand_option = 'bv_whitelabel_infos'; 13 13 public $wp_lp_whitelabel_option = 'bvLpWhitelabelConf'; 14 public $version = '6.8 3';14 public $version = '6.85'; 15 15 public $webpage = 'https://blogvault.net'; 16 16 public $appurl = 'https://app.blogvault.net'; -
blogvault-real-time-backup/trunk/protect/fw.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectFW_V68 3')) :4 if (!class_exists('BVProtectFW_V685')) : 5 5 require_once dirname( __FILE__ ) . '/fw/rule/errors.php'; 6 6 require_once dirname( __FILE__ ) . '/fw/rule/engine.php'; 7 7 require_once dirname( __FILE__ ) . '/fw/rule.php'; 8 8 9 class BVProtectFW_V68 3{9 class BVProtectFW_V685 { 10 10 private $brand_name; 11 11 private $protect_mode; … … 24 24 private $has_valid_bypass_cookie; 25 25 26 private $mode = BVProtectFW_V68 3::MODE_DISABLED;27 private $ip_cookie_mode = BVProtectFW_V68 3::IP_COOKIE_MODE_DISABLED;28 private $admin_cookie_mode = BVProtectFW_V68 3::ADMIN_COOKIE_MODE_DISABLED;29 private $bypass_level = BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_CONTRIBUTOR;30 private $wpf_rule_init_mode = BVProtectFW_V68 3::WPF_RULE_INIT_MODE_WP;26 private $mode = BVProtectFW_V685::MODE_DISABLED; 27 private $ip_cookie_mode = BVProtectFW_V685::IP_COOKIE_MODE_DISABLED; 28 private $admin_cookie_mode = BVProtectFW_V685::ADMIN_COOKIE_MODE_DISABLED; 29 private $bypass_level = BVProtectFW_V685::WP_USER_ROLE_LEVEL_CONTRIBUTOR; 30 private $wpf_rule_init_mode = BVProtectFW_V685::WPF_RULE_INIT_MODE_WP; 31 31 private $custom_roles = array(); 32 32 private $cookie_key = ""; … … 35 35 private $cookie_validity = 2592000; 36 36 private $can_set_cache_prevention_cookie = false; 37 private $rules_mode = BVProtectFW_V68 3::RULES_MODE_DISABLED;37 private $rules_mode = BVProtectFW_V685::RULES_MODE_DISABLED; 38 38 private $is_geo_blocking = false; 39 39 private $is_wp_user_cookie_enabled = false; 40 40 private $log_config = array(); 41 private $request_profiling_mode = BVProtectFW_V68 3::REQ_PROFILING_MODE_DISABLED;42 private $logging_mode = BVProtectFW_V68 3::LOGGING_MODE_VISITOR;41 private $request_profiling_mode = BVProtectFW_V685::REQ_PROFILING_MODE_DISABLED; 42 private $logging_mode = BVProtectFW_V685::LOGGING_MODE_VISITOR; 43 43 private $skip_log_config = array(); 44 44 private $skip_log_cookies = array(); … … 55 55 private $break_rule_matching = false; 56 56 private $can_log_raw_body = false; 57 private $log_slice_size = BVProtectFW_V68 3::LOG_SLICE_SIZE;57 private $log_slice_size = BVProtectFW_V685::LOG_SLICE_SIZE; 58 58 59 59 private static $instance = null; … … 101 101 102 102 const DEFAULT_WP_USER_ROLE_LEVELS = array( 103 'administrator' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_ADMIN,104 'editor' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_EDITOR,105 'author' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_AUTHOR,106 'contributor' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_CONTRIBUTOR,107 'subscriber' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_SUBSCRIBER103 'administrator' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_ADMIN, 104 'editor' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_EDITOR, 105 'author' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_AUTHOR, 106 'contributor' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_CONTRIBUTOR, 107 'subscriber' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_SUBSCRIBER 108 108 ); 109 109 110 110 const EXTRA_WP_USER_ROLE_LEVELS = array( 111 'custom' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_CUSTOM,112 'unknown' => BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_UNKNOWN111 'custom' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_CUSTOM, 112 'unknown' => BVProtectFW_V685::WP_USER_ROLE_LEVEL_UNKNOWN 113 113 ); 114 114 … … 249 249 if ($this->isPrependMode()) { 250 250 $log_file = MCDATAPATH . MCCONFKEY . '-mc.log'; 251 $this->ipstore = new BVProtectIpstore_V68 3(BVProtectIpstore_V683::STORAGE_TYPE_FS);252 $this->logger = new BVProtectLogger_V68 3($log_file, BVProtectLogger_V683::TYPE_FS);251 $this->ipstore = new BVProtectIpstore_V685(BVProtectIpstore_V685::STORAGE_TYPE_FS); 252 $this->logger = new BVProtectLogger_V685($log_file, BVProtectLogger_V685::TYPE_FS); 253 253 } else { 254 $this->ipstore = new BVProtectIpstore_V68 3(BVProtectIpstore_V683::STORAGE_TYPE_DB);255 $this->logger = new BVProtectLogger_V68 3(BVProtectFW_V683::TABLE_NAME, BVProtectLogger_V683::TYPE_DB);254 $this->ipstore = new BVProtectIpstore_V685(BVProtectIpstore_V685::STORAGE_TYPE_DB); 255 $this->logger = new BVProtectLogger_V685(BVProtectFW_V685::TABLE_NAME, BVProtectLogger_V685::TYPE_DB); 256 256 } 257 257 … … 266 266 if (!isset(self::$instance)) { 267 267 self::$instance = new self($protect_mode, $request, $config, $brand_name); 268 } elseif (self::$instance->protect_mode != $protect_mode && $protect_mode == BVProtect_V68 3::MODE_WP) {268 } elseif (self::$instance->protect_mode != $protect_mode && $protect_mode == BVProtect_V685::MODE_WP) { 269 269 self::$instance->protect_mode = $protect_mode; 270 270 self::$instance->brand_name = $brand_name; 271 self::$instance->ipstore = new BVProtectIpstore_V68 3(BVProtectIpstore_V683::STORAGE_TYPE_DB);271 self::$instance->ipstore = new BVProtectIpstore_V685(BVProtectIpstore_V685::STORAGE_TYPE_DB); 272 272 self::$instance->initRules(); 273 273 } … … 277 277 278 278 public static function uninstall() { 279 BVProtect_V68 3::$db->dropBVTable(BVProtectFW_V683::TABLE_NAME);279 BVProtect_V685::$db->dropBVTable(BVProtectFW_V685::TABLE_NAME); 280 280 } 281 281 … … 297 297 298 298 private function isPrependMode() { 299 return ($this->protect_mode === BVProtect_V68 3::MODE_PREPEND);299 return ($this->protect_mode === BVProtect_V685::MODE_PREPEND); 300 300 } 301 301 302 302 private function isWPMode() { 303 return ($this->protect_mode === BVProtect_V68 3::MODE_WP);303 return ($this->protect_mode === BVProtect_V685::MODE_WP); 304 304 } 305 305 306 306 private function isModeDisabled() { 307 return ($this->mode === BVProtectFW_V68 3::MODE_DISABLED);307 return ($this->mode === BVProtectFW_V685::MODE_DISABLED); 308 308 } 309 309 310 310 private function isModeProtect() { 311 return ($this->mode === BVProtectFW_V68 3::MODE_PROTECT);311 return ($this->mode === BVProtectFW_V685::MODE_PROTECT); 312 312 } 313 313 314 314 private function isAdminCookieEnabled() { 315 return ($this->admin_cookie_mode === BVProtectFW_V68 3::ADMIN_COOKIE_MODE_ENABLED);315 return ($this->admin_cookie_mode === BVProtectFW_V685::ADMIN_COOKIE_MODE_ENABLED); 316 316 } 317 317 318 318 private function isIPCookieEnabled() { 319 return ($this->ip_cookie_mode === BVProtectFW_V68 3::IP_COOKIE_MODE_ENABLED);319 return ($this->ip_cookie_mode === BVProtectFW_V685::IP_COOKIE_MODE_ENABLED); 320 320 } 321 321 322 322 private function isRequestProfilingDisabled() { 323 return ($this->request_profiling_mode === BVProtectFW_V68 3::REQ_PROFILING_MODE_DISABLED);323 return ($this->request_profiling_mode === BVProtectFW_V685::REQ_PROFILING_MODE_DISABLED); 324 324 } 325 325 326 326 private function isRequestProfilingModeDebug() { 327 return ($this->request_profiling_mode === BVProtectFW_V68 3::REQ_PROFILING_MODE_DEBUG);327 return ($this->request_profiling_mode === BVProtectFW_V685::REQ_PROFILING_MODE_DEBUG); 328 328 } 329 329 330 330 private function isRequestHasValidBypassCookie() { 331 331 if (!isset($this->has_valid_bypass_cookie)) { 332 $cookie = (string) $this->request->getCookies(BVProtectFW_V68 3::BYPASS_COOKIE_NAME);332 $cookie = (string) $this->request->getCookies(BVProtectFW_V685::BYPASS_COOKIE_NAME); 333 333 $new_cookie = $this->generateBypassCookie(); 334 334 $is_valid = ($this->isAdminCookieEnabled() && $new_cookie && ($cookie === $new_cookie)); … … 340 340 341 341 private function isRulesModeProtect() { 342 return ($this->rules_mode === BVProtectFW_V68 3::RULES_MODE_PROTECT);342 return ($this->rules_mode === BVProtectFW_V685::RULES_MODE_PROTECT); 343 343 } 344 344 345 345 public function isLoggingModeComplete() { 346 return ($this->logging_mode === BVProtectFW_V68 3::LOGGING_MODE_COMPLETE);346 return ($this->logging_mode === BVProtectFW_V685::LOGGING_MODE_COMPLETE); 347 347 } 348 348 349 349 public function isLoggingModeVisitor() { 350 return ($this->logging_mode === BVProtectFW_V68 3::LOGGING_MODE_VISITOR);350 return ($this->logging_mode === BVProtectFW_V685::LOGGING_MODE_VISITOR); 351 351 } 352 352 … … 356 356 357 357 private function isWPFRuleInitModePrepend() { 358 return ($this->wpf_rule_init_mode === BVProtectFW_V68 3::WPF_RULE_INIT_MODE_PREPEND);358 return ($this->wpf_rule_init_mode === BVProtectFW_V685::WPF_RULE_INIT_MODE_PREPEND); 359 359 } 360 360 361 361 private function isWPFRuleInitModeWP() { 362 return ($this->wpf_rule_init_mode === BVProtectFW_V68 3::WPF_RULE_INIT_MODE_WP);362 return ($this->wpf_rule_init_mode === BVProtectFW_V685::WPF_RULE_INIT_MODE_WP); 363 363 } 364 364 … … 389 389 390 390 if (!$current_wp_user->isIdentical($this->request->wp_user)) { 391 $serialized_wp_user = BVProtectWPUser_V68 3::_serialize($current_wp_user);391 $serialized_wp_user = BVProtectWPUser_V685::_serialize($current_wp_user); 392 392 $cookie_val = $serialized_wp_user . '_' . 393 BVProtectUtils_V68 3::signMessage($serialized_wp_user, $this->cookie_key);393 BVProtectUtils_V685::signMessage($serialized_wp_user, $this->cookie_key); 394 394 $cookie_val = base64_encode($cookie_val); 395 395 396 $this->setCookie(BVProtectWPUser_V68 3::COOKIE_NAME, $cookie_val);396 $this->setCookie(BVProtectWPUser_V685::COOKIE_NAME, $cookie_val); 397 397 } 398 398 } elseif ($this->request->wp_user->isLoggedIn()) { 399 $this->request->wp_user = BVProtectWPUser_V68 3::defaultUser();400 $this->unsetCookie(BVProtectWPUser_V68 3::COOKIE_NAME);399 $this->request->wp_user = BVProtectWPUser_V685::defaultUser(); 400 $this->unsetCookie(BVProtectWPUser_V685::COOKIE_NAME); 401 401 } 402 402 } … … 415 415 } 416 416 417 return (new BVProtectWPUser_V68 3($id, $role_level, $capabilities, $time));417 return (new BVProtectWPUser_V685($id, $role_level, $capabilities, $time)); 418 418 } 419 419 … … 434 434 435 435 private function loadWPUser() { 436 $this->request->wp_user = BVProtectWPUser_V68 3::defaultUser();437 438 $cookie_val = $this->request->getCookies(BVProtectWPUser_V68 3::COOKIE_NAME);436 $this->request->wp_user = BVProtectWPUser_V685::defaultUser(); 437 438 $cookie_val = $this->request->getCookies(BVProtectWPUser_V685::COOKIE_NAME); 439 439 if (!is_string($cookie_val)) { 440 440 return; … … 452 452 list($serialized_user, $signature) = $cookie_val_array; 453 453 454 if (BVProtectUtils_V68 3::verifyMessage($serialized_user, $signature, $this->cookie_key) === true) {455 $wp_user = BVProtectWPUser_V68 3::_unserialize($serialized_user);454 if (BVProtectUtils_V685::verifyMessage($serialized_user, $signature, $this->cookie_key) === true) { 455 $wp_user = BVProtectWPUser_V685::_unserialize($serialized_user); 456 456 457 457 if (!isset($wp_user) || $wp_user->time !== (int) floor(time() / $this->cookie_validity)) { … … 468 468 } 469 469 470 $role_by_level = array_flip(array_merge(BVProtectFW_V68 3::DEFAULT_WP_USER_ROLE_LEVELS,471 BVProtectFW_V68 3::EXTRA_WP_USER_ROLE_LEVELS));470 $role_by_level = array_flip(array_merge(BVProtectFW_V685::DEFAULT_WP_USER_ROLE_LEVELS, 471 BVProtectFW_V685::EXTRA_WP_USER_ROLE_LEVELS)); 472 472 $this->request->wp_user->role = $role_by_level[$this->request->wp_user->role_level]; 473 473 } … … 493 493 if ($this->isPrependMode()) { 494 494 $rules_file = MCDATAPATH . MCCONFKEY . '-' . 'mc_rules.json'; 495 $rule_arrays = BVProtectUtils_V68 3::parseFile($rules_file);495 $rule_arrays = BVProtectUtils_V685::parseFile($rules_file); 496 496 } else { 497 $rule_arrays = BVProtect_V68 3::$settings->getOption('bvruleset');497 $rule_arrays = BVProtect_V685::$settings->getOption('bvruleset'); 498 498 if(!is_array($rule_arrays)) { 499 499 $rule_arrays = array(); … … 507 507 508 508 foreach($rule_arrays as $rule_array) { 509 $rule = BVProtectFWRule_V68 3::init($rule_array);509 $rule = BVProtectFWRule_V685::init($rule_array); 510 510 511 511 if ($rule) { … … 532 532 private function initWPFRule($rule) { 533 533 switch ($rule->execute_on) { 534 case BVProtectFWRule_V68 3::EXE_ON_PRE_UPDATE_OPTION:534 case BVProtectFWRule_V685::EXE_ON_PRE_UPDATE_OPTION: 535 535 $this->addWPHook($rule, 'pre_update_option', 'handleRequestOnPreUpdateOption', 3); 536 536 break; 537 case BVProtectFWRule_V68 3::EXE_ON_PRE_DELETE_POST:537 case BVProtectFWRule_V685::EXE_ON_PRE_DELETE_POST: 538 538 $this->addWPHook($rule, 'pre_delete_post', 'handleRequestOnPreDeletePost', 3); 539 539 break; 540 case BVProtectFWRule_V68 3::EXE_ON_WP_INSERT_POST_EMPTY_CONTENT:540 case BVProtectFWRule_V685::EXE_ON_WP_INSERT_POST_EMPTY_CONTENT: 541 541 $this->addWPHook($rule, 'wp_insert_post_empty_content', 542 542 'handleRequestOnWPInsertPostEmptyContent', 2); 543 543 break; 544 case BVProtectFWRule_V68 3::EXE_ON_INSERT_USER_META:544 case BVProtectFWRule_V685::EXE_ON_INSERT_USER_META: 545 545 $this->addWPHook($rule, 'insert_user_meta', 'handleRequestOnInsertUserMeta', 4); 546 546 break; 547 case BVProtectFWRule_V68 3::EXE_ON_DELETE_OPTION:547 case BVProtectFWRule_V685::EXE_ON_DELETE_OPTION: 548 548 $this->addWPHook($rule, 'delete_option', 'handleRequestOnDeleteOption', 1, 'action'); 549 549 break; 550 case BVProtectFWRule_V68 3::EXE_ON_DELETE_USER:550 case BVProtectFWRule_V685::EXE_ON_DELETE_USER: 551 551 $this->addWPHook($rule, 'delete_user', 'handleRequestOnDeleteUser', 3, 'action'); 552 552 break; 553 case BVProtectFWRule_V68 3::EXE_ON_PASSWORD_RESET:553 case BVProtectFWRule_V685::EXE_ON_PASSWORD_RESET: 554 554 $this->addWPHook($rule, 'password_reset', 'handleRequestOnPasswordReset', 2, 'action'); 555 555 break; 556 case BVProtectFWRule_V68 3::EXE_ON_SEND_AUTH_COOKIES:556 case BVProtectFWRule_V685::EXE_ON_SEND_AUTH_COOKIES: 557 557 $this->addWPHook($rule, 'send_auth_cookies', 'handleRequestOnSendAuthCookies', 6); 558 558 break; 559 case BVProtectFWRule_V68 3::EXE_ON_SET_AUTH_COOKIE:559 case BVProtectFWRule_V685::EXE_ON_SET_AUTH_COOKIE: 560 560 $this->addWPHook($rule, 'set_auth_cookie', 'handleRequestOnSetAuthCookie', 6, 'action'); 561 561 break; 562 case BVProtectFWRule_V68 3::EXE_ON_INIT:562 case BVProtectFWRule_V685::EXE_ON_INIT: 563 563 $this->addWPHook($rule, 'init', 'handleRequestOnInit', 0, 'action'); 564 564 break; 565 case BVProtectFWRule_V68 3::EXE_ON_USER_REGISTER:565 case BVProtectFWRule_V685::EXE_ON_USER_REGISTER: 566 566 $this->addWPHook($rule, 'user_register', 'handleRequestOnUserRegister', 2, 'action'); 567 567 break; 568 case BVProtectFWRule_V68 3::EXE_ON_ADD_USER_META:568 case BVProtectFWRule_V685::EXE_ON_ADD_USER_META: 569 569 $this->addWPHook($rule, 'add_user_meta', 'handleRequestOnAddUserMeta', 3, 'action'); 570 570 break; 571 case BVProtectFWRule_V68 3::EXE_ON_UPDATE_USER_METADATA:571 case BVProtectFWRule_V685::EXE_ON_UPDATE_USER_METADATA: 572 572 $this->addWPHook($rule, 'update_user_metadata', 'handleRequestOnUpdateUserMetadata', 5); 573 573 break; 574 case BVProtectFWRule_V68 3::EXE_ON_UPDATE_USER_META:574 case BVProtectFWRule_V685::EXE_ON_UPDATE_USER_META: 575 575 $this->addWPHook($rule, 'update_user_meta', 'handleRequestOnUpdateUserMeta', 4, 'action'); 576 576 break; 577 case BVProtectFWRule_V68 3::EXE_ON_ADD_OPTION:577 case BVProtectFWRule_V685::EXE_ON_ADD_OPTION: 578 578 $this->addWPHook($rule, 'add_option', 'handleRequestOnAddOption', 2, 'action'); 579 579 break; 580 case BVProtectFWRule_V68 3::EXE_ON_WP_PRE_INSERT_USER_DATA:580 case BVProtectFWRule_V685::EXE_ON_WP_PRE_INSERT_USER_DATA: 581 581 $this->addWPHook($rule, 'wp_pre_insert_user_data', 'handleRequestOnWPPreInsertUserData', 4); 582 582 break; 583 case BVProtectFWRule_V68 3::EXE_ON_REST_REQUEST_BEFORE_CALLBACKS:583 case BVProtectFWRule_V685::EXE_ON_REST_REQUEST_BEFORE_CALLBACKS: 584 584 $this->addWPHook($rule, 'rest_request_before_callbacks', 585 585 'handleRequestOnRestRequestBeforeCallbacks', 3); 586 586 break; 587 case BVProtectFWRule_V68 3::EXE_ON_ADMIN_INIT:587 case BVProtectFWRule_V685::EXE_ON_ADMIN_INIT: 588 588 $this->addWPHook($rule, 'admin_init', 'handleRequestOnAdminInit', 0, 'action'); 589 589 break; 590 case BVProtectFWRule_V68 3::EXE_ON_WP_HANDLE_UPLOAD_PREFILTER:590 case BVProtectFWRule_V685::EXE_ON_WP_HANDLE_UPLOAD_PREFILTER: 591 591 $this->addWPHook($rule, 'wp_handle_upload_prefilter', 592 592 'handleRequestOnWPHandleUploadPrefilter', 1); 593 593 break; 594 case BVProtectFWRule_V68 3::EXE_ON_TEMPLATE_REDIRECT:594 case BVProtectFWRule_V685::EXE_ON_TEMPLATE_REDIRECT: 595 595 $this->addWPHook($rule, 'template_redirect', 'handleRequestOnTemplateRedirect', 0, 'action'); 596 596 break; 597 case BVProtectFWRule_V68 3::EXE_ON_WP_LOADED:597 case BVProtectFWRule_V685::EXE_ON_WP_LOADED: 598 598 $this->addWPHook($rule, 'wp_loaded', 'handleRequestOnWPLoaded', 0, 'action'); 599 599 break; 600 case BVProtectFWRule_V68 3::EXE_ON_ADD_POST_METADATA:600 case BVProtectFWRule_V685::EXE_ON_ADD_POST_METADATA: 601 601 $this->addWPHook($rule, 'add_post_metadata', 'handleRequestOnAddPostMetadata', 5); 602 602 break; 603 case BVProtectFWRule_V68 3::EXE_ON_UPDATE_POST_METADATA:603 case BVProtectFWRule_V685::EXE_ON_UPDATE_POST_METADATA: 604 604 $this->addWPHook($rule, 'update_post_metadata', 'handleRequestOnUpdatePostMetadata', 5); 605 605 break; 606 case BVProtectFWRule_V68 3::EXE_ON_DELETE_POST_METADATA:606 case BVProtectFWRule_V685::EXE_ON_DELETE_POST_METADATA: 607 607 $this->addWPHook($rule, 'delete_post_metadata', 'handleRequestOnDeletePostMetadata', 5); 608 608 break; 609 case BVProtectFWRule_V68 3::EXE_ON_ADD_TERM_METADATA:609 case BVProtectFWRule_V685::EXE_ON_ADD_TERM_METADATA: 610 610 $this->addWPHook($rule, 'add_term_metadata', 'handleRequestOnAddTermMetadata', 5); 611 611 break; 612 case BVProtectFWRule_V68 3::EXE_ON_UPDATE_TERM_METADATA:612 case BVProtectFWRule_V685::EXE_ON_UPDATE_TERM_METADATA: 613 613 $this->addWPHook($rule, 'update_term_metadata', 'handleRequestOnUpdateTermMetadata', 5); 614 614 break; 615 case BVProtectFWRule_V68 3::EXE_ON_DELETE_TERM_METADATA:615 case BVProtectFWRule_V685::EXE_ON_DELETE_TERM_METADATA: 616 616 $this->addWPHook($rule, 'delete_term_metadata', 'handleRequestOnDeleteTermMetadata', 5); 617 617 break; 618 case BVProtectFWRule_V68 3::EXE_ON_ADD_COMMENT_METADATA:618 case BVProtectFWRule_V685::EXE_ON_ADD_COMMENT_METADATA: 619 619 $this->addWPHook($rule, 'add_comment_metadata', 'handleRequestOnAddCommentMetadata', 5); 620 620 break; 621 case BVProtectFWRule_V68 3::EXE_ON_UPDATE_COMMENT_METADATA:621 case BVProtectFWRule_V685::EXE_ON_UPDATE_COMMENT_METADATA: 622 622 $this->addWPHook($rule, 'update_comment_metadata', 'handleRequestOnUpdateCommentMetadata', 5); 623 623 break; 624 case BVProtectFWRule_V68 3::EXE_ON_DELETE_COMMENT_METADATA:624 case BVProtectFWRule_V685::EXE_ON_DELETE_COMMENT_METADATA: 625 625 $this->addWPHook($rule, 'delete_comment_metadata', 'handleRequestOnDeleteCommentMetadata', 5); 626 626 break; 627 case BVProtectFWRule_V68 3::EXE_ON_ADD_USER_METADATA:627 case BVProtectFWRule_V685::EXE_ON_ADD_USER_METADATA: 628 628 $this->addWPHook($rule, 'add_user_metadata', 'handleRequestOnAddUserMetadata', 5); 629 629 break; 630 case BVProtectFWRule_V68 3::EXE_ON_DELETE_USER_METADATA:630 case BVProtectFWRule_V685::EXE_ON_DELETE_USER_METADATA: 631 631 $this->addWPHook($rule, 'delete_user_metadata', 'handleRequestOnDeleteUserMetadata', 5); 632 632 break; … … 646 646 } 647 647 } else { 648 BVProtectUtils_V68 3::preInitWPHook($hook_name, $callback, -9999999, $accepted_args);648 BVProtectUtils_V685::preInitWPHook($hook_name, $callback, -9999999, $accepted_args); 649 649 } 650 650 } … … 1204 1204 private function setIPCookie() { 1205 1205 if (!$this->is_ip_cookie_set && $this->isIPCookieEnabled() && 1206 !$this->request->getCookies(BVProtectFW_V68 3::IP_COOKIE_NAME)) {1206 !$this->request->getCookies(BVProtectFW_V685::IP_COOKIE_NAME)) { 1207 1207 1208 1208 $time = floor(time() / 86400); 1209 1209 $cookie = hash('sha256', $this->request->ip . $time . $this->cookie_key); 1210 1210 if ($cookie) { 1211 $this->setCookie(BVProtectFW_V68 3::IP_COOKIE_NAME, $cookie, time() + 86400);1211 $this->setCookie(BVProtectFW_V685::IP_COOKIE_NAME, $cookie, time() + 86400); 1212 1212 } 1213 1213 } … … 1217 1217 if (function_exists('current_user_can')) { 1218 1218 if (function_exists('is_super_admin') && is_super_admin()) { 1219 return BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_ADMIN;1219 return BVProtectFW_V685::WP_USER_ROLE_LEVEL_ADMIN; 1220 1220 } 1221 1221 1222 1222 foreach ($this->custom_roles as $role) { 1223 1223 if (current_user_can($role)) { 1224 return BVProtectFW_V68 3::WP_USER_ROLE_LEVEL_CUSTOM;1224 return BVProtectFW_V685::WP_USER_ROLE_LEVEL_CUSTOM; 1225 1225 } 1226 1226 } 1227 1227 1228 foreach (BVProtectFW_V68 3::DEFAULT_WP_USER_ROLE_LEVELS as $role => $level) {1228 foreach (BVProtectFW_V685::DEFAULT_WP_USER_ROLE_LEVELS as $role => $level) { 1229 1229 if (current_user_can($role)) { 1230 1230 return $level; … … 1334 1334 $cookies = array(); 1335 1335 1336 if ($this->request->getCookies(BVProtectFW_V68 3::IP_COOKIE_NAME) !== NULL) {1337 $cookie_val = (string) $this->request->getCookies(BVProtectFW_V68 3::IP_COOKIE_NAME);1338 $cookies[BVProtectFW_V68 3::IP_COOKIE_NAME] = $cookie_val;1336 if ($this->request->getCookies(BVProtectFW_V685::IP_COOKIE_NAME) !== NULL) { 1337 $cookie_val = (string) $this->request->getCookies(BVProtectFW_V685::IP_COOKIE_NAME); 1338 $cookies[BVProtectFW_V685::IP_COOKIE_NAME] = $cookie_val; 1339 1339 } 1340 1340 … … 1500 1500 1501 1501 private function getUserBy($attribute, $value) { 1502 if (isset($value) && function_exists('get_user_by') && BVProtectUtils_V68 3::havePluginsLoaded()) {1502 if (isset($value) && function_exists('get_user_by') && BVProtectUtils_V685::havePluginsLoaded()) { 1503 1503 return get_user_by($attribute, $value); 1504 1504 } … … 1604 1604 } 1605 1605 1606 if ($this->matchCount(BVProtectFWRule_V68 3::SQLIREGEX, $value) > 2) {1606 if ($this->matchCount(BVProtectFWRule_V685::SQLIREGEX, $value) > 2) { 1607 1607 $profiled_data[$key]["sql"] = true; 1608 1608 } … … 1693 1693 private function canRequestBypassFirewall() { 1694 1694 if ($this->isRequestIPWhitelisted() || $this->isRequestHasValidBypassCookie()) { 1695 $this->request->category = BVProtectRequest_V68 3::CATEGORY_WHITELISTED;1696 $this->request->status = BVProtectRequest_V68 3::STATUS_BYPASSED;1695 $this->request->category = BVProtectRequest_V685::CATEGORY_WHITELISTED; 1696 $this->request->status = BVProtectRequest_V685::STATUS_BYPASSED; 1697 1697 1698 1698 return true; 1699 } elseif (BVProtectUtils_V68 3::isPrivateIP($this->request->ip)) {1700 $this->request->category = BVProtectRequest_V68 3::CATEGORY_PRIVATEIP;1701 $this->request->status = BVProtectRequest_V68 3::STATUS_BYPASSED;1699 } elseif (BVProtectUtils_V685::isPrivateIP($this->request->ip)) { 1700 $this->request->category = BVProtectRequest_V685::CATEGORY_PRIVATEIP; 1701 $this->request->status = BVProtectRequest_V685::STATUS_BYPASSED; 1702 1702 1703 1703 return true; … … 1723 1723 1724 1724 private function handleRequestOnRuleMatch($rules, $engine_vars = array(), $log_data = array()) { 1725 $normalized_engine_vars = BVProtectFWRuleEngine_V68 3::normalizeVariables($engine_vars);1725 $normalized_engine_vars = BVProtectFWRuleEngine_V685::normalizeVariables($engine_vars); 1726 1726 1727 1727 foreach ($rules as $rule) { … … 1733 1733 if (array_key_exists('variables', $rule->opts)) { 1734 1734 $_engine_vars = array_merge($_engine_vars, 1735 BVProtectFWRuleEngine_V68 3::normalizeVariables($rule->opts['variables']));1736 } 1737 1738 $rule_engine = new BVProtectFWRuleEngine_V68 3($this->request, $_engine_vars);1735 BVProtectFWRuleEngine_V685::normalizeVariables($rule->opts['variables'])); 1736 } 1737 1738 $rule_engine = new BVProtectFWRuleEngine_V685($this->request, $_engine_vars); 1739 1739 1740 1740 if ($rule_engine->evaluate($rule) && !$rule_engine->hasError()) { … … 1749 1749 case "ALLOW": 1750 1750 $this->break_rule_matching = true; 1751 $this->request->category = BVProtectRequest_V68 3::CATEGORY_RULE_ALLOWED;1751 $this->request->category = BVProtectRequest_V685::CATEGORY_RULE_ALLOWED; 1752 1752 return; 1753 1753 case "BLOCK": 1754 1754 if ($this->isModeProtect()) { 1755 $this->terminateRequest(BVProtectRequest_V68 3::CATEGORY_RULE_BLOCKED);1755 $this->terminateRequest(BVProtectRequest_V685::CATEGORY_RULE_BLOCKED); 1756 1756 } 1757 1757 return; … … 1769 1769 private function terminateRequest($category) { 1770 1770 $this->request->category = $category; 1771 $this->request->status = BVProtectRequest_V68 3::STATUS_BLOCKED;1771 $this->request->status = BVProtectRequest_V685::STATUS_BLOCKED; 1772 1772 $this->request->setRespCode(403); 1773 1773 1774 1774 if ($this->can_set_cache_prevention_cookie && 1775 !$this->request->getCookies(BVProtectFW_V68 3::PREVENT_CACHE_COOKIE_NAME)) {1775 !$this->request->getCookies(BVProtectFW_V685::PREVENT_CACHE_COOKIE_NAME)) { 1776 1776 $value = "Prevent Caching Response."; 1777 $this->setCookie(BVProtectFW_V68 3::PREVENT_CACHE_COOKIE_NAME, $value, time() + 43200);1777 $this->setCookie(BVProtectFW_V685::PREVENT_CACHE_COOKIE_NAME, $value, time() + 43200); 1778 1778 } 1779 1779 … … 1803 1803 $cookie = $this->generateBypassCookie(); 1804 1804 if ($cookie) { 1805 $this->setCookie(BVProtectFW_V68 3::BYPASS_COOKIE_NAME, $cookie);1805 $this->setCookie(BVProtectFW_V685::BYPASS_COOKIE_NAME, $cookie); 1806 1806 } 1807 1807 } -
blogvault-real-time-backup/trunk/protect/fw/rule.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectFWRule_V68 3')) :5 class BVProtectFWRule_V68 3{4 if (!class_exists('BVProtectFWRule_V685')) : 5 class BVProtectFWRule_V685 { 6 6 public $id; 7 7 public $logic; … … 105 105 106 106 if (!array_key_exists('min_rule_engine_ver', $attributes) || !is_float($attributes['min_rule_engine_ver']) || 107 $attributes['min_rule_engine_ver'] > BVProtectFWRuleEngine_V68 3::VERSION) {107 $attributes['min_rule_engine_ver'] > BVProtectFWRuleEngine_V685::VERSION) { 108 108 109 109 return false; … … 111 111 112 112 if (array_key_exists('max_rule_engine_ver', $attributes) && (!is_float($attributes['max_rule_engine_ver']) || 113 $attributes['max_rule_engine_ver'] < BVProtectFWRuleEngine_V68 3::VERSION)) {113 $attributes['max_rule_engine_ver'] < BVProtectFWRuleEngine_V685::VERSION)) { 114 114 115 115 return false; … … 130 130 if (!array_key_exists('execute_on', $attributes)) { 131 131 if (array_key_exists('level', $attributes) && $attributes['level'] === 1) { 132 $attributes['execute_on'] = BVProtectFWRule_V68 3::EXE_ON_BOOT;132 $attributes['execute_on'] = BVProtectFWRule_V685::EXE_ON_BOOT; 133 133 } else { 134 134 return false; … … 136 136 } 137 137 138 return new BVProtectFWRule_V68 3($attributes);138 return new BVProtectFWRule_V685($attributes); 139 139 } 140 140 141 141 public function isExeOnBoot() { 142 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_BOOT);142 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_BOOT); 143 143 } 144 144 145 145 public function isExeOnPreUpdateOption() { 146 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_PRE_UPDATE_OPTION);146 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_PRE_UPDATE_OPTION); 147 147 } 148 148 149 149 public function isExeOnPreDeletePost() { 150 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_PRE_DELETE_POST);150 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_PRE_DELETE_POST); 151 151 } 152 152 153 153 public function isExeOnWPInsertPostEmptyContent() { 154 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_WP_INSERT_POST_EMPTY_CONTENT);154 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_WP_INSERT_POST_EMPTY_CONTENT); 155 155 } 156 156 157 157 public function isExeOnInsertUserMeta() { 158 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_INSERT_USER_META);158 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_INSERT_USER_META); 159 159 } 160 160 161 161 public function isExeOnDeleteOption() { 162 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_DELETE_OPTION);162 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_DELETE_OPTION); 163 163 } 164 164 165 165 public function isExeOnDeleteUser() { 166 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_DELETE_USER);166 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_DELETE_USER); 167 167 } 168 168 169 169 public function isExeOnPasswordReset() { 170 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_PASSWORD_RESET);170 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_PASSWORD_RESET); 171 171 } 172 172 173 173 public function isExeOnSendAuthCookies() { 174 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_SEND_AUTH_COOKIES);174 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_SEND_AUTH_COOKIES); 175 175 } 176 176 177 177 public function isExeOnSetAuthCookie() { 178 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_SET_AUTH_COOKIE);178 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_SET_AUTH_COOKIE); 179 179 } 180 180 181 181 public function isExeOnInit() { 182 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_INIT);182 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_INIT); 183 183 } 184 184 185 185 public function isExeOnUserRegister() { 186 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_USER_REGISTER);186 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_USER_REGISTER); 187 187 } 188 188 189 189 public function isExeOnAddUserMeta() { 190 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_ADD_USER_META);190 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_ADD_USER_META); 191 191 } 192 192 193 193 public function isExeOnUpdateUserMetadata() { 194 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_UPDATE_USER_METADATA);194 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_UPDATE_USER_METADATA); 195 195 } 196 196 197 197 public function isExeOnUpdateUserMeta() { 198 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_UPDATE_USER_META);198 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_UPDATE_USER_META); 199 199 } 200 200 201 201 public function isExeOnAddOption() { 202 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_ADD_OPTION);202 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_ADD_OPTION); 203 203 } 204 204 205 205 public function isExeOnWpPreInsertUserData() { 206 return ($this->execute_on === BVProtectFWRule_V68 3::EXE_ON_WP_PRE_INSERT_USER_DATA);206 return ($this->execute_on === BVProtectFWRule_V685::EXE_ON_WP_PRE_INSERT_USER_DATA); 207 207 } 208 208 } -
blogvault-real-time-backup/trunk/protect/fw/rule/engine.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!class_exists('BVProtectFWRuleEngine_V68 3')) :5 if (!class_exists('BVProtectFWRuleEngine_V685')) : 6 6 require_once dirname( __FILE__ ) . '/functions.php'; 7 7 8 class BVProtectFWRuleEngine_V68 3{9 use BVProtectFWRuleStringFunc_V68 3;10 use BVProtectFWRuleArrayFunc_V68 3;11 use BVProtectFWRuleMiscFunc_V68 3;12 use BVProtectFWRuleRequestFunc_V68 3;13 use BVProtectFWRuleWPFunc_V68 3;8 class BVProtectFWRuleEngine_V685 { 9 use BVProtectFWRuleStringFunc_V685; 10 use BVProtectFWRuleArrayFunc_V685; 11 use BVProtectFWRuleMiscFunc_V685; 12 use BVProtectFWRuleRequestFunc_V685; 13 use BVProtectFWRuleWPFunc_V685; 14 14 15 15 private $request; … … 26 26 const WILDCARD_KEY = '*'; 27 27 const FUNC_NAME_PREFIX = '_rf_'; 28 const CONST_NAME_PREFIX = 'BVProtectFWRule_V68 3::';28 const CONST_NAME_PREFIX = 'BVProtectFWRule_V685::'; 29 29 const ALLOWED_EXT_CONSTANTS = [ 30 30 'DOING_CRON' … … 53 53 try { 54 54 return $this->executeStmt($rule->logic); 55 } catch (BVProtectRuleError_V68 3$e) {55 } catch (BVProtectRuleError_V685 $e) { 56 56 $this->error = $e; 57 57 } … … 124 124 private function getValue($stmt) { 125 125 if (!is_array($stmt) || empty($stmt["type"])) { 126 throw new BVProtectRuleError_V68 3(126 throw new BVProtectRuleError_V685( 127 127 $this->addExState("InvalidStatementError: Malformed value statement")); 128 128 } … … 133 133 case "NUMBER": 134 134 if (!isset($stmt["value"]) || !is_int($stmt["value"])) { 135 throw new BVProtectRuleError_V68 3(135 throw new BVProtectRuleError_V685( 136 136 $this->addExState("TypeError: Value is not a number") 137 137 ); … … 141 141 case "STRING": 142 142 if (!isset($stmt["value"]) || !is_string($stmt["value"])) { 143 throw new BVProtectRuleError_V68 3(143 throw new BVProtectRuleError_V685( 144 144 $this->addExState("TypeError: Value is not a string") 145 145 ); … … 149 149 case "BOOL": 150 150 if (!isset($stmt["value"]) || !is_bool($stmt["value"])) { 151 throw new BVProtectRuleError_V68 3(151 throw new BVProtectRuleError_V685( 152 152 $this->addExState("TypeError: Value is not a boolean") 153 153 ); … … 157 157 case "CONST": 158 158 if (!isset($stmt["value"]) || !is_string($stmt["value"])) { 159 throw new BVProtectRuleError_V68 3(159 throw new BVProtectRuleError_V685( 160 160 $this->addExState("TypeError: Invalid constant name") 161 161 ); … … 169 169 170 170 if (!defined($name)) { 171 throw new BVProtectRuleError_V68 3(171 throw new BVProtectRuleError_V685( 172 172 $this->addExState("TypeError: Undefined constant" . $stmt["value"]) 173 173 ); … … 177 177 case "ARRAY": 178 178 if (!isset($stmt["value"]) || !is_array($stmt["value"])) { 179 throw new BVProtectRuleError_V68 3(179 throw new BVProtectRuleError_V685( 180 180 $this->addExState("TypeError: Value is not a array") 181 181 ); … … 208 208 private function executeStmt($stmt) { 209 209 if (!is_array($stmt) || empty($stmt["type"])) { 210 throw new BVProtectRuleError_V68 3(210 throw new BVProtectRuleError_V685( 211 211 $this->addExState("InvalidStatementError: Malformed logic statement") 212 212 ); … … 220 220 case "AND": 221 221 if (empty($stmt["left_operand"]) || empty($stmt["right_operand"])) { 222 throw new BVProtectRuleError_V68 3(222 throw new BVProtectRuleError_V685( 223 223 $this->addExState("InvalidOperandError: Malformed operand(s)") 224 224 ); … … 229 229 case "OR": 230 230 if (empty($stmt["left_operand"]) || empty($stmt["right_operand"])) { 231 throw new BVProtectRuleError_V68 3(231 throw new BVProtectRuleError_V685( 232 232 $this->addExState("InvalidOperandError: Malformed operand(s)") 233 233 ); … … 238 238 case "NOT": 239 239 if (empty($stmt["value"])) { 240 throw new BVProtectRuleError_V68 3(240 throw new BVProtectRuleError_V685( 241 241 $this->addExState("InvalidOperandError: Malformed operand") 242 242 ); … … 247 247 case "FUNCTION": 248 248 if (empty($stmt["name"]) || !is_string($stmt["name"])) { 249 throw new BVProtectRuleError_V68 3(249 throw new BVProtectRuleError_V685( 250 250 $this->addExState("InvalidFunctionName: Malformed name") 251 251 ); … … 256 256 257 257 if (!is_callable($handler)) { 258 throw new BVProtectRuleError_V68 3(258 throw new BVProtectRuleError_V685( 259 259 $this->addExState("UndefinedFunctionCall: " . $stmt["name"]) 260 260 ); … … 262 262 263 263 if (!array_key_exists('args', $stmt) || !is_array($stmt['args'])) { 264 throw new BVProtectRuleError_V68 3(264 throw new BVProtectRuleError_V685( 265 265 $this->addExState("InvalidArguments: Malformed args") 266 266 ); … … 275 275 break; 276 276 default: 277 throw new BVProtectRuleError_V68 3(277 throw new BVProtectRuleError_V685( 278 278 $this->addExState("UnknownOperation: -") 279 279 ); … … 286 286 private function processRuleFunctionParams($func_name, $args_cnt, $args, $required_params = 0, $param_types = array()) { 287 287 if (($args_cnt < $required_params)) { 288 throw new BVProtectRuleError_V68 3(288 throw new BVProtectRuleError_V685( 289 289 $this->addExState("ArgumentCountError: Too few arguments for " . $func_name) 290 290 ); … … 293 293 foreach ($param_types as $pos => $type) { 294 294 if (!is_int($pos)) { 295 throw new BVProtectRuleError_V68 3(295 throw new BVProtectRuleError_V685( 296 296 $this->addExState("InvalidParamType: " . $pos) 297 297 ); … … 301 301 case "string": 302 302 if (!isset($args[$pos]) || !is_string($args[$pos])) { 303 throw new BVProtectRuleError_V68 3(303 throw new BVProtectRuleError_V685( 304 304 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not a string.") 305 305 ); … … 308 308 case 'integer': 309 309 if (!isset($args[$pos]) || !is_int($args[$pos])) { 310 throw new BVProtectRuleError_V68 3(310 throw new BVProtectRuleError_V685( 311 311 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not a integer.") 312 312 ); … … 315 315 case 'double': 316 316 if (!isset($args[$pos]) || !is_double($args[$pos])) { 317 throw new BVProtectRuleError_V68 3(317 throw new BVProtectRuleError_V685( 318 318 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not a double.") 319 319 ); … … 322 322 case 'boolean': 323 323 if (!isset($args[$pos]) || !is_bool($args[$pos])) { 324 throw new BVProtectRuleError_V68 3(324 throw new BVProtectRuleError_V685( 325 325 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not a boolean.") 326 326 ); … … 329 329 case 'array': 330 330 if (!isset($args[$pos]) || !is_array($args[$pos])) { 331 throw new BVProtectRuleError_V68 3(331 throw new BVProtectRuleError_V685( 332 332 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not an array.") 333 333 ); … … 337 337 break; 338 338 default: 339 throw new BVProtectRuleError_V68 3(339 throw new BVProtectRuleError_V685( 340 340 $this->addExState("InvalidParamTypeError: Invalid type at " . $pos . " for " . $func_name) 341 341 ); -
blogvault-real-time-backup/trunk/protect/fw/rule/errors.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectRuleError_V68 3')) :5 class BVProtectRuleError_V68 3extends Exception {4 if (!class_exists('BVProtectRuleError_V685')) : 5 class BVProtectRuleError_V685 extends Exception { 6 6 //Root rule error class. 7 7 } -
blogvault-real-time-backup/trunk/protect/fw/rule/functions/array.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!trait_exists('BVProtectFWRuleArrayFunc_V68 3')) :6 trait BVProtectFWRuleArrayFunc_V68 3{5 if (!trait_exists('BVProtectFWRuleArrayFunc_V685')) : 6 trait BVProtectFWRuleArrayFunc_V685 { 7 7 private function _rf_inArray() { 8 8 $args = $this->processRuleFunctionParams( … … 17 17 18 18 if (!is_array($array)) { 19 throw new BVProtectRuleError_V68 3(19 throw new BVProtectRuleError_V685( 20 20 $this->addExState("inArray: 2nd param is not an array") 21 21 ); … … 23 23 24 24 if (!is_bool($strict)) { 25 throw new BVProtectRuleError_V68 3(25 throw new BVProtectRuleError_V685( 26 26 $this->addExState("inArray: 3rd param is not a boolean") 27 27 ); … … 54 54 } 55 55 } else { 56 throw new BVProtectRuleError_V68 3(56 throw new BVProtectRuleError_V685( 57 57 $this->addExState("recInArray: Expects an array") 58 58 ); … … 73 73 74 74 if (!is_array($array)) { 75 throw new BVProtectRuleError_V68 3(75 throw new BVProtectRuleError_V685( 76 76 $this->addExState("arrayKeyExists: Array must be of type array") 77 77 ); 78 78 } elseif (!is_string($key) && !is_int($key)) { 79 throw new BVProtectRuleError_V68 3(79 throw new BVProtectRuleError_V685( 80 80 $this->addExState("arrayKeyExists: Key must be of type string or int") 81 81 ); … … 110 110 111 111 if (!is_bool($recursive)) { 112 throw new BVProtectRuleError_V68 3(112 throw new BVProtectRuleError_V685( 113 113 $this->addExState("getArrayKeys: 2nd param must be a boolean") 114 114 ); … … 140 140 141 141 if (!is_bool($recursive)) { 142 throw new BVProtectRuleError_V68 3(142 throw new BVProtectRuleError_V685( 143 143 $this->addExState("hasAnyArrayKey: 3rd param must be a boolean") 144 144 ); … … 148 148 foreach ($keys as $key) { 149 149 if (!is_int($key) && !is_string($key)) { 150 throw new BVProtectRuleError_V68 3(150 throw new BVProtectRuleError_V685( 151 151 $this->addExState("hasAnyArrayKey: Key must be of type string or int") 152 152 ); … … 189 189 190 190 if (!is_bool($recursive)) { 191 throw new BVProtectRuleError_V68 3(191 throw new BVProtectRuleError_V685( 192 192 $this->addExState("keyMatches: 3rd param must be a boolean") 193 193 ); … … 224 224 225 225 if ($resp === false) { 226 throw new BVProtectRuleError_V68 3(226 throw new BVProtectRuleError_V685( 227 227 $this->addExState("keyMatches: Invalid regular expression") 228 228 ); … … 233 233 $resp = BVHelper::safePregMatch($pattern, (string) $key); 234 234 if ($resp === false) { 235 throw new BVProtectRuleError_V68 3(235 throw new BVProtectRuleError_V685( 236 236 $this->addExState("keyMatches: Regex match failed") 237 237 ); … … 242 242 243 243 private function keyMatchesRecursive($array, $pattern, &$traversed_keys, $depth = 1) { 244 if ($depth > BVProtectFWRuleEngine_V68 3::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) {244 if ($depth > BVProtectFWRuleEngine_V685::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { 245 245 return false; 246 246 } … … 262 262 263 263 private function getArrayKeysRecursive($array, &$keys, &$traversed_keys, $depth = 1) { 264 if ($depth > BVProtectFWRuleEngine_V68 3::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) {264 if ($depth > BVProtectFWRuleEngine_V685::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { 265 265 return; 266 266 } … … 277 277 278 278 private function hasAnyArrayKeyRecursive($array, $key_lookup, &$traversed_keys, $depth = 1) { 279 if ($depth > BVProtectFWRuleEngine_V68 3::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) {279 if ($depth > BVProtectFWRuleEngine_V685::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { 280 280 return false; 281 281 } … … 297 297 298 298 private function enforceArrayTraversalLimit($func_name, $traversed_keys) { 299 if ($traversed_keys > BVProtectFWRuleEngine_V68 3::MAX_ARRAY_KEYS_TO_TRAVERSE) {300 throw new BVProtectRuleError_V68 3(299 if ($traversed_keys > BVProtectFWRuleEngine_V685::MAX_ARRAY_KEYS_TO_TRAVERSE) { 300 throw new BVProtectRuleError_V685( 301 301 $this->addExState( 302 302 "TraversalLimitError: " . $func_name . " exceeded " . 303 BVProtectFWRuleEngine_V68 3::MAX_ARRAY_KEYS_TO_TRAVERSE .303 BVProtectFWRuleEngine_V685::MAX_ARRAY_KEYS_TO_TRAVERSE . 304 304 " array keys" 305 305 ) … … 321 321 foreach ($keys as $key) { 322 322 if (!is_int($key) && !is_string($key)) { 323 throw new BVProtectRuleError_V68 3(323 throw new BVProtectRuleError_V685( 324 324 $this->addExState("digArray: Keys must be a valid array of string, or integer type") 325 325 ); … … 342 342 343 343 if (empty($keys)) { 344 throw new BVProtectRuleError_V68 3(344 throw new BVProtectRuleError_V685( 345 345 $this->addExState("digArrayValues: Keys must not be empty") 346 346 ); 347 347 } 348 348 349 if (count($keys) > BVProtectFWRuleEngine_V68 3::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) {350 throw new BVProtectRuleError_V68 3(349 if (count($keys) > BVProtectFWRuleEngine_V685::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { 350 throw new BVProtectRuleError_V685( 351 351 $this->addExState( 352 352 "digArrayValues: Keys exceeded " . 353 BVProtectFWRuleEngine_V68 3::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC .353 BVProtectFWRuleEngine_V685::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC . 354 354 " levels of traversal" 355 355 ) … … 359 359 foreach ($keys as $key) { 360 360 if (!is_int($key) && !is_string($key)) { 361 throw new BVProtectRuleError_V68 3(361 throw new BVProtectRuleError_V685( 362 362 $this->addExState("digArrayValues: Keys must be a valid array of string, or integer type") 363 363 ); … … 376 376 } 377 377 378 if ($key === BVProtectFWRuleEngine_V68 3::WILDCARD_KEY) {378 if ($key === BVProtectFWRuleEngine_V685::WILDCARD_KEY) { 379 379 foreach ($node as $value) { 380 380 $traversed_keys += 1; … … 417 417 foreach ($keys as $key) { 418 418 if (!is_int($key) && !is_string($key)) { 419 throw new BVProtectRuleError_V68 3(419 throw new BVProtectRuleError_V685( 420 420 $this->addExState("filterArray: Keys must be a valid array of string, or integer type") 421 421 ); … … 438 438 439 439 if (!is_string($key) && !is_int($key)) { 440 throw new BVProtectRuleError_V68 3(440 throw new BVProtectRuleError_V685( 441 441 $this->addExState("getArrayVal: Key must be a valid string or integer") 442 442 ); … … 519 519 foreach ($array as $element) { 520 520 if (!is_scalar($element)) { 521 throw new BVProtectRuleError_V68 3(521 throw new BVProtectRuleError_V685( 522 522 $this->addExState("arrayJoin: Array element must be of scalar type") 523 523 ); -
blogvault-real-time-backup/trunk/protect/fw/rule/functions/misc.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!trait_exists('BVProtectFWRuleMiscFunc_V68 3')) :6 trait BVProtectFWRuleMiscFunc_V68 3{5 if (!trait_exists('BVProtectFWRuleMiscFunc_V685')) : 6 trait BVProtectFWRuleMiscFunc_V685 { 7 7 private function _rf_isTrue() { 8 8 $args = $this->processRuleFunctionParams( … … 73 73 74 74 if (!array_key_exists($name, $this->variables)) { 75 throw new BVProtectRuleError_V68 3(75 throw new BVProtectRuleError_V685( 76 76 $this->addExState("UndefinedVariableError: " . $name . " is not defined.") 77 77 ); … … 134 134 $resp = BVHelper::safePregMatch((string) $pattern, (string) $subject); 135 135 if ($resp === false) { 136 throw new BVProtectRuleError_V68 3(136 throw new BVProtectRuleError_V685( 137 137 $this->addExState('BVHelper::safePregMatch' . serialize($subject)) 138 138 ); … … 175 175 $count = preg_match_all((string) $pattern, (string) $subject, $matches); 176 176 if ($count === false) { 177 throw new BVProtectRuleError_V68 3(177 throw new BVProtectRuleError_V685( 178 178 $this->addExState("preg_match_all: " . serialize($subject)) 179 179 ); … … 201 201 $count = preg_match_all((string) $pattern, (string) $subject, $matches); 202 202 if ($count === false) { 203 throw new BVProtectRuleError_V68 3(203 throw new BVProtectRuleError_V685( 204 204 $this->addExState("preg_match_all: " . serialize($subject)) 205 205 ); -
blogvault-real-time-backup/trunk/protect/fw/rule/functions/request.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!trait_exists('BVProtectFWRuleRequestFunc_V68 3')) :6 trait BVProtectFWRuleRequestFunc_V68 3{5 if (!trait_exists('BVProtectFWRuleRequestFunc_V685')) : 6 trait BVProtectFWRuleRequestFunc_V685 { 7 7 private function _rf_getAction() { 8 8 $args = $this->processRuleFunctionParams( … … 496 496 497 497 if (!array_key_exists('ID', $user)) { 498 throw new BVProtectRuleError_V68 3(498 throw new BVProtectRuleError_V685( 499 499 $this->addExState("wpUserId: user's id doesn't exist") 500 500 ); -
blogvault-real-time-backup/trunk/protect/fw/rule/functions/string.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!trait_exists('BVProtectFWRuleStringFunc_V68 3')) :6 trait BVProtectFWRuleStringFunc_V68 3{5 if (!trait_exists('BVProtectFWRuleStringFunc_V685')) : 6 trait BVProtectFWRuleStringFunc_V685 { 7 7 private function _rf_isNumeric() { 8 8 $args = $this->processRuleFunctionParams( … … 239 239 } 240 240 } else { 241 throw new BVProtectRuleError_V68 3(241 throw new BVProtectRuleError_V685( 242 242 $this->addExState("containsAnySubstring: Expects an array of substrings.") 243 243 ); … … 274 274 275 275 if (!is_int($offset)) { 276 throw new BVProtectRuleError_V68 3(276 throw new BVProtectRuleError_V685( 277 277 $this->addExState("strPos: Offset should be an integer") 278 278 ); … … 319 319 320 320 if (empty($separator)) { 321 throw new BVProtectRuleError_V68 3(321 throw new BVProtectRuleError_V685( 322 322 $this->addExState("splitString: Separator cannot be empty") 323 323 ); … … 325 325 326 326 if (!is_int($limit)) { 327 throw new BVProtectRuleError_V68 3(327 throw new BVProtectRuleError_V685( 328 328 $this->addExState("splitString: Limit should be an integer") 329 329 ); … … 344 344 345 345 if (!is_bool($recursive)) { 346 throw new BVProtectRuleError_V68 3(346 throw new BVProtectRuleError_V685( 347 347 $this->addExState("urlDecode: Recursive flag should be a boolean") 348 348 ); … … 363 363 364 364 if (!is_bool($recursive)) { 365 throw new BVProtectRuleError_V68 3(365 throw new BVProtectRuleError_V685( 366 366 $this->addExState("rawUrlDecode: Recursive flag should be a boolean") 367 367 ); … … 382 382 383 383 if (!is_bool($recursive)) { 384 throw new BVProtectRuleError_V68 3(384 throw new BVProtectRuleError_V685( 385 385 $this->addExState("htmlEntityDecode: Recursive flag should be a boolean") 386 386 ); … … 401 401 402 402 if (!is_bool($recursive)) { 403 throw new BVProtectRuleError_V68 3(403 throw new BVProtectRuleError_V685( 404 404 $this->addExState("stripSlashes: Recursive flag should be a boolean") 405 405 ); … … 410 410 411 411 private function normalizeStringValue($value, $operation, $recursive, $depth = 1) { 412 if ($depth > BVProtectFWRuleEngine_V68 3::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) {412 if ($depth > BVProtectFWRuleEngine_V685::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { 413 413 return null; 414 414 } … … 442 442 } 443 443 444 throw new BVProtectRuleError_V68 3(444 throw new BVProtectRuleError_V685( 445 445 $this->addExState("normalizeStringValue: Invalid normalization operation") 446 446 ); -
blogvault-real-time-backup/trunk/protect/fw/rule/functions/wp.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!trait_exists('BVProtectFWRuleWPFunc_V68 3')) :6 trait BVProtectFWRuleWPFunc_V68 3{5 if (!trait_exists('BVProtectFWRuleWPFunc_V685')) : 6 trait BVProtectFWRuleWPFunc_V685 { 7 7 private function _rf_sanitizeUser() { 8 8 $args = $this->processRuleFunctionParams( … … 16 16 $strict = $args[1]; 17 17 18 if (!function_exists('sanitize_user') || !BVProtectUtils_V68 3::haveMupluginsLoaded()) {19 throw new BVProtectRuleError_V68 3(18 if (!function_exists('sanitize_user') || !BVProtectUtils_V685::haveMupluginsLoaded()) { 19 throw new BVProtectRuleError_V685( 20 20 $this->addExState("sanitizeUser: Func sanitize_user doesn't exist.") 21 21 ); … … 34 34 $data = $args[0]; 35 35 36 if (!function_exists('maybe_serialize') || !BVProtectUtils_V68 3::haveMupluginsLoaded()) {37 throw new BVProtectRuleError_V68 3(36 if (!function_exists('maybe_serialize') || !BVProtectUtils_V685::haveMupluginsLoaded()) { 37 throw new BVProtectRuleError_V685( 38 38 $this->addExState("maybeSerialize: Func maybe_serialize doesn't exist.") 39 39 ); … … 50 50 ); 51 51 52 if (!function_exists('is_user_logged_in') || !BVProtectUtils_V68 3::havePluginsLoaded()) {53 throw new BVProtectRuleError_V68 3(52 if (!function_exists('is_user_logged_in') || !BVProtectUtils_V685::havePluginsLoaded()) { 53 throw new BVProtectRuleError_V685( 54 54 $this->addExState("isUserLoggedIn: Func is_user_logged_in doesn't exist.") 55 55 ); … … 66 66 ); 67 67 68 if (!function_exists('wp_get_current_user') || !BVProtectUtils_V68 3::havePluginsLoaded()) {69 throw new BVProtectRuleError_V68 3(68 if (!function_exists('wp_get_current_user') || !BVProtectUtils_V685::havePluginsLoaded()) { 69 throw new BVProtectRuleError_V685( 70 70 $this->addExState("getCurrentWPUser: Func wp_get_current_user doesn't exist.") 71 71 ); 72 72 } 73 73 74 return BVProtectFWRuleEngine_V68 3::toAllowedType(wp_get_current_user());74 return BVProtectFWRuleEngine_V685::toAllowedType(wp_get_current_user()); 75 75 } 76 76 … … 87 87 $arg2 = isset($args[2]) ? $args[2] : null; 88 88 89 if (!function_exists('current_user_can') || !BVProtectUtils_V68 3::havePluginsLoaded()) {90 throw new BVProtectRuleError_V68 3(89 if (!function_exists('current_user_can') || !BVProtectUtils_V685::havePluginsLoaded()) { 90 throw new BVProtectRuleError_V685( 91 91 $this->addExState("currentUserCan: Required funcs doesn't exist.") 92 92 ); … … 115 115 $value = $args[1]; 116 116 117 if (!function_exists('get_user_by') || !BVProtectUtils_V68 3::havePluginsLoaded()) {118 throw new BVProtectRuleError_V68 3(117 if (!function_exists('get_user_by') || !BVProtectUtils_V685::havePluginsLoaded()) { 118 throw new BVProtectRuleError_V685( 119 119 $this->addExState("getUserBy: Func get_user_by doesn't exist") 120 120 ); … … 123 123 if ($field === 'ID' || $field === 'id') { 124 124 if (!is_string($value) && !is_int($value)) { 125 throw new BVProtectRuleError_V68 3(125 throw new BVProtectRuleError_V685( 126 126 $this->addExState("getUserBy: Value must be a valid string or an integer") 127 127 ); 128 128 } 129 129 } elseif (!is_string($value)) { 130 throw new BVProtectRuleError_V68 3(130 throw new BVProtectRuleError_V685( 131 131 $this->addExState("getUserBy: Value must be a valid string") 132 132 ); … … 138 138 } 139 139 140 return BVProtectFWRuleEngine_V68 3::toAllowedType($user);140 return BVProtectFWRuleEngine_V685::toAllowedType($user); 141 141 } 142 142 … … 151 151 152 152 if (!array_key_exists("allcaps", $user)) { 153 throw new BVProtectRuleError_V68 3(153 throw new BVProtectRuleError_V685( 154 154 $this->addExState("getCurrentWPUserCapabilities: allcaps doesn't exist in user.") 155 155 ); 156 156 } 157 157 158 return BVProtectFWRuleEngine_V68 3::toAllowedType($user["allcaps"]);158 return BVProtectFWRuleEngine_V685::toAllowedType($user["allcaps"]); 159 159 } 160 160 … … 174 174 175 175 if (!array_key_exists("allcaps", $user)) { 176 throw new BVProtectRuleError_V68 3(176 throw new BVProtectRuleError_V685( 177 177 $this->addExState("getUserCapabilities: allcaps doesn't exist in user.") 178 178 ); 179 179 } 180 180 181 return BVProtectFWRuleEngine_V68 3::toAllowedType($user["allcaps"]);181 return BVProtectFWRuleEngine_V685::toAllowedType($user["allcaps"]); 182 182 } 183 183 … … 203 203 $default_value = isset($args[1]) ? $args[1] : false; 204 204 205 if (!function_exists('get_option') || !BVProtectUtils_V68 3::haveMupluginsLoaded()) {206 throw new BVProtectRuleError_V68 3(205 if (!function_exists('get_option') || !BVProtectUtils_V685::haveMupluginsLoaded()) { 206 throw new BVProtectRuleError_V685( 207 207 $this->addExState("getOption: Func get_option doesn't exist.") 208 208 ); 209 209 } 210 210 211 return BVProtectFWRuleEngine_V68 3::toAllowedType(get_option($option, $default_value));211 return BVProtectFWRuleEngine_V685::toAllowedType(get_option($option, $default_value)); 212 212 } 213 213 … … 223 223 $login = $args[1]; 224 224 225 if (!function_exists('check_password_reset_key') || !BVProtectUtils_V68 3::havePluginsLoaded()) {226 throw new BVProtectRuleError_V68 3(225 if (!function_exists('check_password_reset_key') || !BVProtectUtils_V685::havePluginsLoaded()) { 226 throw new BVProtectRuleError_V685( 227 227 $this->addExState("checkPasswordResetKey: Func check_password_reset_key doesn't exist.") 228 228 ); … … 232 232 233 233 if (is_a($user, "WP_User")) { 234 return BVProtectFWRuleEngine_V68 3::toAllowedType($user);234 return BVProtectFWRuleEngine_V685::toAllowedType($user); 235 235 } 236 236 … … 287 287 $value = $args[0]; 288 288 289 if (!function_exists('wp_unslash') || !BVProtectUtils_V68 3::haveMuPluginsLoaded()) {290 throw new BVProtectRuleError_V68 3(289 if (!function_exists('wp_unslash') || !BVProtectUtils_V685::haveMuPluginsLoaded()) { 290 throw new BVProtectRuleError_V685( 291 291 $this->addExState("wpUnslash: Func wp_unslash doesn't exist.") 292 292 ); … … 294 294 295 295 if (!is_string($value) && !is_array($value)) { 296 throw new BVProtectRuleError_V68 3(296 throw new BVProtectRuleError_V685( 297 297 $this->addExState("wpUnslash: Value must be a valid string or an array") 298 298 ); … … 310 310 311 311 if (!defined('COOKIEHASH')) { 312 throw new BVProtectRuleError_V68 3(312 throw new BVProtectRuleError_V685( 313 313 $this->addExState("parseResetPassCookie: COOKIEHASH is not defined.") 314 314 ); -
blogvault-real-time-backup/trunk/protect/ipstore.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectIpstore_V68 3')) :4 if (!class_exists('BVProtectIpstore_V685')) : 5 5 require_once dirname( __FILE__ ) . '/request.php'; 6 6 require_once dirname( __FILE__ ) . '/ipstore/fs.php'; 7 7 require_once dirname( __FILE__ ) . '/ipstore/db.php'; 8 8 9 class BVProtectIpstore_V68 3{9 class BVProtectIpstore_V685 { 10 10 private $storage; 11 11 private $storage_type; … … 14 14 const STORAGE_TYPE_DB = 1; 15 15 16 function __construct($storage_type = BVProtectIpstore_V68 3::STORAGE_TYPE_DB) {16 function __construct($storage_type = BVProtectIpstore_V685::STORAGE_TYPE_DB) { 17 17 $this->storage_type = $storage_type; 18 if ($this->storage_type == BVProtectIpstore_V68 3::STORAGE_TYPE_FS) {19 $this->storage = new BVProtectIpstoreFS_V68 3();18 if ($this->storage_type == BVProtectIpstore_V685::STORAGE_TYPE_FS) { 19 $this->storage = new BVProtectIpstoreFS_V685(); 20 20 } else { 21 $this->storage = new BVProtectIpstoreDB_V68 3();21 $this->storage = new BVProtectIpstoreDB_V685(); 22 22 } 23 23 } 24 24 25 25 public static function uninstall() { 26 BVProtectIpstoreDB_V68 3::uninstall();26 BVProtectIpstoreDB_V685::uninstall(); 27 27 } 28 28 29 29 public function isLPIPBlacklisted($ip) { 30 if ($this->storage_type == BVProtectIpstore_V68 3::STORAGE_TYPE_DB) {30 if ($this->storage_type == BVProtectIpstore_V685::STORAGE_TYPE_DB) { 31 31 return $this->storage->isLPIPBlacklisted($ip); 32 32 } … … 34 34 35 35 public function isLPIPWhitelisted($ip) { 36 if ($this->storage_type == BVProtectIpstore_V68 3::STORAGE_TYPE_DB) {36 if ($this->storage_type == BVProtectIpstore_V685::STORAGE_TYPE_DB) { 37 37 return $this->storage->isLPIPWhitelisted($ip); 38 38 } -
blogvault-real-time-backup/trunk/protect/ipstore/db.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectIpstoreDB_V68 3')) :5 class BVProtectIpstoreDB_V68 3{4 if (!class_exists('BVProtectIpstoreDB_V685')) : 5 class BVProtectIpstoreDB_V685 { 6 6 const TABLE_NAME = 'ip_store'; 7 7 … … 11 11 #XNOTE: check this. 12 12 public static function blacklistedTypes() { 13 return BVProtectRequest_V68 3::blacklistedCategories();13 return BVProtectRequest_V685::blacklistedCategories(); 14 14 } 15 15 16 16 public static function whitelistedTypes() { 17 return BVProtectRequest_V68 3::whitelistedCategories();17 return BVProtectRequest_V685::whitelistedCategories(); 18 18 } 19 19 20 20 public static function uninstall() { 21 BVProtect_V68 3::$db->dropBVTable(BVProtectIpstoreDB_V683::TABLE_NAME);21 BVProtect_V685::$db->dropBVTable(BVProtectIpstoreDB_V685::TABLE_NAME); 22 22 } 23 23 24 24 public function isLPIPBlacklisted($ip) { 25 return $this->checkIPPresent($ip, self::blacklistedTypes(), BVProtectIpstoreDB_V68 3::CATEGORY_LP);25 return $this->checkIPPresent($ip, self::blacklistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_LP); 26 26 } 27 27 28 28 public function isLPIPWhitelisted($ip) { 29 return $this->checkIPPresent($ip, self::whitelistedTypes(), BVProtectIpstoreDB_V68 3::CATEGORY_LP);29 return $this->checkIPPresent($ip, self::whitelistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_LP); 30 30 } 31 31 32 32 public function getTypeIfBlacklistedIP($ip) { 33 return $this->getIPType($ip, self::blacklistedTypes(), BVProtectIpstoreDB_V68 3::CATEGORY_FW);33 return $this->getIPType($ip, self::blacklistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_FW); 34 34 } 35 35 36 36 public function isFWIPBlacklisted($ip) { 37 return $this->checkIPPresent($ip, self::blacklistedTypes(), BVProtectIpstoreDB_V68 3::CATEGORY_FW);37 return $this->checkIPPresent($ip, self::blacklistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_FW); 38 38 } 39 39 40 40 public function isFWIPWhitelisted($ip) { 41 return $this->checkIPPresent($ip, self::whitelistedTypes(), BVProtectIpstoreDB_V68 3::CATEGORY_FW);41 return $this->checkIPPresent($ip, self::whitelistedTypes(), BVProtectIpstoreDB_V685::CATEGORY_FW); 42 42 } 43 43 … … 50 50 #XNOTE: getIPCategory or getIPType? 51 51 private function getIPType($ip, $types, $category) { 52 $table = BVProtect_V68 3::$db->getBVTable(BVProtectIpstoreDB_V683::TABLE_NAME);52 $table = BVProtect_V685::$db->getBVTable(BVProtectIpstoreDB_V685::TABLE_NAME); 53 53 54 if (BVProtect_V68 3::$db->isTablePresent($table)) {55 $binIP = BVProtectUtils_V68 3::bvInetPton($ip);56 $is_v6 = BVProtectUtils_V68 3::isIPv6($ip);54 if (BVProtect_V685::$db->isTablePresent($table)) { 55 $binIP = BVProtectUtils_V685::bvInetPton($ip); 56 $is_v6 = BVProtectUtils_V685::isIPv6($ip); 57 57 58 58 if ($binIP !== false) { 59 59 $query_str = "SELECT * FROM $table WHERE %s >= `start_ip_range` && %s <= `end_ip_range` && "; 60 if ($category == BVProtectIpstoreDB_V68 3::CATEGORY_FW) {60 if ($category == BVProtectIpstoreDB_V685::CATEGORY_FW) { 61 61 $query_str .= "`is_fw` = true"; 62 62 } else { … … 65 65 $query_str .= " && `type` in (" . implode(',', $types) . ") && `is_v6` = %d LIMIT 1;"; 66 66 67 $query = BVProtect_V68 3::$db->prepare($query_str, array($binIP, $binIP, $is_v6));67 $query = BVProtect_V685::$db->prepare($query_str, array($binIP, $binIP, $is_v6)); 68 68 69 return BVProtect_V68 3::$db->getVar($query, 5);69 return BVProtect_V685::$db->getVar($query, 5); 70 70 } 71 71 } -
blogvault-real-time-backup/trunk/protect/ipstore/fs.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectIpstoreFS_V68 3')) :5 class BVProtectIpstoreFS_V68 3{4 if (!class_exists('BVProtectIpstoreFS_V685')) : 5 class BVProtectIpstoreFS_V685 { 6 6 private $whitelisted_ips; 7 7 private $blacklisted_ips; … … 12 12 function __construct() { 13 13 $ip_store_file = MCDATAPATH . MCCONFKEY . '-' . 'mc_ips.conf'; 14 $ips = BVProtectUtils_V68 3::parseFile($ip_store_file);14 $ips = BVProtectUtils_V685::parseFile($ip_store_file); 15 15 $this->whitelisted_ips = array_key_exists('whitelisted', $ips) ? $ips['whitelisted'] : array(); 16 16 $this->blacklisted_ips = array_key_exists('blacklisted', $ips) ? $ips['blacklisted'] : array(); … … 18 18 19 19 public function getTypeIfBlacklistedIP($ip) { 20 return $this->getIPType($ip, BVProtectIpstoreFS_V68 3::IP_TYPE_BLACKLISTED);20 return $this->getIPType($ip, BVProtectIpstoreFS_V685::IP_TYPE_BLACKLISTED); 21 21 } 22 22 23 23 public function isFWIPBlacklisted($ip) { 24 return $this->checkIPPresent($ip, BVProtectIpstoreFS_V68 3::IP_TYPE_BLACKLISTED);24 return $this->checkIPPresent($ip, BVProtectIpstoreFS_V685::IP_TYPE_BLACKLISTED); 25 25 } 26 26 27 27 public function isFWIPWhitelisted($ip) { 28 return $this->checkIPPresent($ip, BVProtectIpstoreFS_V68 3::IP_TYPE_WHITELISTED);28 return $this->checkIPPresent($ip, BVProtectIpstoreFS_V685::IP_TYPE_WHITELISTED); 29 29 } 30 30 … … 37 37 private function getIPType($ip, $type) { 38 38 switch ($type) { 39 case BVProtectIpstoreFS_V68 3::IP_TYPE_BLACKLISTED:39 case BVProtectIpstoreFS_V685::IP_TYPE_BLACKLISTED: 40 40 return isset($this->blacklisted_ips[$ip]) ? $this->blacklisted_ips[$ip] : null; 41 case BVProtectIpstoreFS_V68 3::IP_TYPE_WHITELISTED:41 case BVProtectIpstoreFS_V685::IP_TYPE_WHITELISTED: 42 42 return isset($this->whitelisted_ips[$ip]) ? $this->whitelisted_ips[$ip] : null; 43 43 } -
blogvault-real-time-backup/trunk/protect/lib/utils.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectUtils_V68 3')) :5 class BVProtectUtils_V68 3{4 if (!class_exists('BVProtectUtils_V685')) : 5 class BVProtectUtils_V685 { 6 6 public static function getIP($ip_header) { 7 7 $ip = null; … … 131 131 if (is_array($val)) { 132 132 foreach ($val as $e) { 133 $length += BVProtectUtils_V68 3::getLength($e);133 $length += BVProtectUtils_V685::getLength($e); 134 134 } 135 135 -
blogvault-real-time-backup/trunk/protect/logger.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectLogger_V68 3')) :4 if (!class_exists('BVProtectLogger_V685')) : 5 5 require_once dirname( __FILE__ ) . '/logger/fs.php'; 6 6 require_once dirname( __FILE__ ) . '/logger/db.php'; 7 7 8 class BVProtectLogger_V68 3{8 class BVProtectLogger_V685 { 9 9 private $log_destination; 10 10 … … 12 12 const TYPE_DB = 1; 13 13 14 function __construct($name, $type = BVProtectLogger_V68 3::TYPE_DB) {15 if ($type == BVProtectLogger_V68 3::TYPE_FS) {16 $this->log_destination = new BVProtectLoggerFS_V68 3($name);14 function __construct($name, $type = BVProtectLogger_V685::TYPE_DB) { 15 if ($type == BVProtectLogger_V685::TYPE_FS) { 16 $this->log_destination = new BVProtectLoggerFS_V685($name); 17 17 } else { 18 $this->log_destination = new BVProtectLoggerDB_V68 3($name);18 $this->log_destination = new BVProtectLoggerDB_V685($name); 19 19 } 20 20 } -
blogvault-real-time-backup/trunk/protect/logger/db.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectLoggerDB_V68 3')) :5 class BVProtectLoggerDB_V68 3{4 if (!class_exists('BVProtectLoggerDB_V685')) : 5 class BVProtectLoggerDB_V685 { 6 6 private $tablename; 7 7 private $bv_tablename; … … 11 11 function __construct($tablename) { 12 12 $this->tablename = $tablename; 13 $this->bv_tablename = BVProtect_V68 3::$db->getBVTable($tablename);13 $this->bv_tablename = BVProtect_V685::$db->getBVTable($tablename); 14 14 } 15 15 16 16 public function log($data) { 17 17 if (is_array($data)) { 18 if (BVProtect_V68 3::$db->rowsCount($this->bv_tablename) > BVProtectLoggerDB_V683::MAXROWCOUNT) {19 BVProtect_V68 3::$db->deleteRowsFromtable($this->tablename, 1);18 if (BVProtect_V685::$db->rowsCount($this->bv_tablename) > BVProtectLoggerDB_V685::MAXROWCOUNT) { 19 BVProtect_V685::$db->deleteRowsFromtable($this->tablename, 1); 20 20 } 21 21 22 BVProtect_V68 3::$db->replaceIntoBVTable($this->tablename, $data);22 BVProtect_V685::$db->replaceIntoBVTable($this->tablename, $data); 23 23 } 24 24 } -
blogvault-real-time-backup/trunk/protect/logger/fs.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectLoggerFS_V68 3')) :5 class BVProtectLoggerFS_V68 3{4 if (!class_exists('BVProtectLoggerFS_V685')) : 5 class BVProtectLoggerFS_V685 { 6 6 public $logFile; 7 7 -
blogvault-real-time-backup/trunk/protect/lp.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectLP_V68 3')) :5 class BVProtectLP_V68 3{4 if (!class_exists('BVProtectLP_V685')) : 5 class BVProtectLP_V685 { 6 6 private $ip; 7 7 private $time; … … 10 10 private $brand_name; 11 11 12 private $mode = BVProtectLP_V68 3::MODE_DISABLED;12 private $mode = BVProtectLP_V685::MODE_DISABLED; 13 13 private $captcha_limit = 3; 14 14 private $temp_block_limit = 10; … … 18 18 private $all_blocked_gap = 1800; 19 19 20 private $category = BVProtectLP_V68 3::CATEGORY_ALLOWED;20 private $category = BVProtectLP_V685::CATEGORY_ALLOWED; 21 21 private $username = ''; 22 22 private $message = ''; … … 47 47 $this->ip = $request->getIP(); 48 48 $this->brand_name = $brand_name; 49 $this->ipstore = new BVProtectIpstore_V68 3();50 $this->logger = new BVProtectLogger_V68 3(BVProtectLP_V683::TABLE_NAME);49 $this->ipstore = new BVProtectIpstore_V685(); 50 $this->logger = new BVProtectLogger_V685(BVProtectLP_V685::TABLE_NAME); 51 51 $this->time = strtotime(gmdate("Y-m-d H:i:s")); 52 52 … … 91 91 92 92 public static function uninstall() { 93 BVProtect_V68 3::$db->dropBVTable(BVProtectLP_V683::TABLE_NAME);93 BVProtect_V685::$db->dropBVTable(BVProtectLP_V685::TABLE_NAME); 94 94 } 95 95 … … 103 103 104 104 private function getCaptchaLink() { 105 $account = BVAccount::apiPublicAccount(BVProtect_V68 3::$settings);105 $account = BVAccount::apiPublicAccount(BVProtect_V685::$settings); 106 106 107 107 $url = $account->authenticatedUrl('/captcha/solve'); … … 112 112 113 113 private function getAllowLoginsTransient() { 114 return BVProtect_V68 3::$settings->getTransient('bvlp_allow_logins');114 return BVProtect_V685::$settings->getTransient('bvlp_allow_logins'); 115 115 } 116 116 117 117 private function getBlockLoginsTransient() { 118 return BVProtect_V68 3::$settings->getTransient('bvlp_block_logins');118 return BVProtect_V685::$settings->getTransient('bvlp_block_logins'); 119 119 } 120 120 … … 142 142 143 143 private function isProtecting() { 144 return $this->mode === BVProtectLP_V68 3::MODE_PROTECT;144 return $this->mode === BVProtectLP_V685::MODE_PROTECT; 145 145 } 146 146 147 147 private function isActive() { 148 return $this->mode !== BVProtectLP_V68 3::MODE_DISABLED;148 return $this->mode !== BVProtectLP_V685::MODE_DISABLED; 149 149 } 150 150 … … 158 158 159 159 private function isUnBlockedIP() { 160 $transient_name = BVProtectLP_V68 3::UNBLOCK_IP_TRANSIENT_PREFIX . $this->ip;161 $attempts = BVProtect_V68 3::$settings->getTransient($transient_name);160 $transient_name = BVProtectLP_V685::UNBLOCK_IP_TRANSIENT_PREFIX . $this->ip; 161 $attempts = BVProtect_V685::$settings->getTransient($transient_name); 162 162 163 163 if ($attempts && $attempts > 0) { 164 BVProtect_V68 3::$settings->setTransient($transient_name, $attempts - 1, 600 * $attempts);164 BVProtect_V685::$settings->setTransient($transient_name, $attempts - 1, 600 * $attempts); 165 165 return true; 166 166 } … … 171 171 private function isLoginBlocked() { 172 172 if ($this->getAllowLoginsTransient() || 173 ($this->getLoginCount(BVProtectLP_V68 3::LOGIN_STATUS_FAILURE, null, $this->all_blocked_gap) < $this->block_all_limit)) {173 ($this->getLoginCount(BVProtectLP_V685::LOGIN_STATUS_FAILURE, null, $this->all_blocked_gap) < $this->block_all_limit)) { 174 174 return false; 175 175 } … … 194 194 private function terminateLogin() { 195 195 $this->message = 'Login Blocked'; 196 $this->log(BVProtectLP_V68 3::LOGIN_STATUS_BLOCKED);196 $this->log(BVProtectLP_V685::LOGIN_STATUS_BLOCKED); 197 197 if ($this->isProtecting()) { 198 198 header("Cache-Control: no-cache, no-store, must-revalidate"); … … 208 208 public function loginInit($user, $username = '', $password = '') { 209 209 if ($this->isUnBlockedIP()) { 210 $this->category = BVProtectLP_V68 3::CATEGORY_UNBLOCKED;210 $this->category = BVProtectLP_V685::CATEGORY_UNBLOCKED; 211 211 } else { 212 $failed_attempts = $this->getLoginCount(BVProtectLP_V68 3::LOGIN_STATUS_FAILURE,212 $failed_attempts = $this->getLoginCount(BVProtectLP_V685::LOGIN_STATUS_FAILURE, 213 213 $this->ip, $this->failed_login_gap); 214 214 215 215 if ($this->isWhitelistedIP()) { 216 $this->category = BVProtectLP_V68 3::CATEGORY_BYPASSED;217 } elseif (BVProtectUtils_V68 3::isPrivateIP($this->ip)) {218 $this->category = BVProtectLP_V68 3::CATEGORY_PRIVATEIP;216 $this->category = BVProtectLP_V685::CATEGORY_BYPASSED; 217 } elseif (BVProtectUtils_V685::isPrivateIP($this->ip)) { 218 $this->category = BVProtectLP_V685::CATEGORY_PRIVATEIP; 219 219 } elseif ($this->isBlacklistedIP()) { 220 $this->category = BVProtectLP_V68 3::CATEGORY_BLACKLISTED;220 $this->category = BVProtectLP_V685::CATEGORY_BLACKLISTED; 221 221 $this->terminateLogin(); 222 222 } elseif ($this->isKnownLogin()) { 223 $this->category = BVProtectLP_V68 3::CATEGORY_BYPASSED;223 $this->category = BVProtectLP_V685::CATEGORY_BYPASSED; 224 224 } elseif ($this->isLoginBlocked()) { 225 $this->category = BVProtectLP_V68 3::CATEGORY_ALL_BLOCKED;225 $this->category = BVProtectLP_V685::CATEGORY_ALL_BLOCKED; 226 226 $this->terminateLogin(); 227 227 } elseif ($failed_attempts >= $this->temp_block_limit) { 228 $this->category = BVProtectLP_V68 3::CATEGORY_TEMP_BLOCK;228 $this->category = BVProtectLP_V685::CATEGORY_TEMP_BLOCK; 229 229 $this->terminateLogin(); 230 230 } elseif ($failed_attempts >= $this->captcha_limit) { 231 $this->category = BVProtectLP_V68 3::CATEGORY_CAPTCHA_BLOCK;231 $this->category = BVProtectLP_V685::CATEGORY_CAPTCHA_BLOCK; 232 232 $this->terminateLogin(); 233 233 } … … 243 243 public function loginFailed($username) { 244 244 $this->username = $username; 245 $this->log(BVProtectLP_V68 3::LOGIN_STATUS_FAILURE);245 $this->log(BVProtectLP_V685::LOGIN_STATUS_FAILURE); 246 246 } 247 247 … … 249 249 $this->username = $username; 250 250 $this->message = 'Login Success'; 251 $this->log(BVProtectLP_V68 3::LOGIN_STATUS_SUCCESS);251 $this->log(BVProtectLP_V685::LOGIN_STATUS_SUCCESS); 252 252 } 253 253 254 254 private function isKnownLogin() { 255 return $this->getLoginCount(BVProtectLP_V68 3::LOGIN_STATUS_SUCCESS,255 return $this->getLoginCount(BVProtectLP_V685::LOGIN_STATUS_SUCCESS, 256 256 $this->ip, $this->success_login_gap) > 0; 257 257 } 258 258 259 259 private function getLoginCount($status, $ip, $gap) { 260 $table = BVProtect_V68 3::$db->getBVTable(BVProtectLP_V683::TABLE_NAME);260 $table = BVProtect_V685::$db->getBVTable(BVProtectLP_V685::TABLE_NAME); 261 261 $query_str = "SELECT COUNT(*) as count from `$table` WHERE status=%d && time > %d"; 262 262 $query_args = array($status, ($this->time - $gap)); 263 263 264 $query = BVProtect_V68 3::$db->prepare($query_str, $query_args);264 $query = BVProtect_V685::$db->prepare($query_str, $query_args); 265 265 if ($ip) { 266 $query .= BVProtect_V68 3::$db->prepare(" && ip=%s", $ip);267 } 268 269 $rows = BVProtect_V68 3::$db->getResult($query);266 $query .= BVProtect_V685::$db->prepare(" && ip=%s", $ip); 267 } 268 269 $rows = BVProtect_V685::$db->getResult($query); 270 270 if (!$rows) { 271 271 return 0; -
blogvault-real-time-backup/trunk/protect/prepend/ignitor.php
r3795700 r3813747 5 5 require_once dirname( __FILE__ ) . '/../protect.php'; 6 6 7 BVProtect_V68 3::init(BVProtect_V683::MODE_PREPEND);7 BVProtect_V685::init(BVProtect_V685::MODE_PREPEND); 8 8 } -
blogvault-real-time-backup/trunk/protect/protect.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtect_V68 3')) :4 if (!class_exists('BVProtect_V685')) : 5 5 require_once dirname( __FILE__ ) . '/logger.php'; 6 6 require_once dirname( __FILE__ ) . '/ipstore.php'; … … 12 12 require_once dirname( __FILE__ ) . '/../helper.php'; 13 13 14 class BVProtect_V68 3{14 class BVProtect_V685 { 15 15 public static $settings; 16 16 public static $db; … … 27 27 } 28 28 29 if ($mode == BVProtect_V68 3::MODE_PREPEND) {29 if ($mode == BVProtect_V685::MODE_PREPEND) { 30 30 $config_file = MCDATAPATH . MCCONFKEY . '-' . 'mc.conf'; 31 $config = BVProtectUtils_V68 3::parseFile($config_file);31 $config = BVProtectUtils_V685::parseFile($config_file); 32 32 33 33 if (empty($config['time']) || !($config['time'] > time() - (48*3600)) || 34 34 !isset($config['mc_conf_version']) || 35 (BVProtect_V68 3::CONF_VERSION !== $config['mc_conf_version'])) {35 (BVProtect_V685::CONF_VERSION !== $config['mc_conf_version'])) { 36 36 return false; 37 37 … … 41 41 $request_ip_header = array_key_exists('ipheader', $config) ? $config['ipheader'] : null; 42 42 $req_config = array_key_exists('reqconfig', $config) ? $config['reqconfig'] : array(); 43 $request = new BVProtectRequest_V68 3($request_ip_header, $req_config);43 $request = new BVProtectRequest_V685($request_ip_header, $req_config); 44 44 $fw_config = array_key_exists('fw', $config) ? $config['fw'] : array(); 45 45 46 BVProtectFW_V68 3::getInstance($mode, $request, $fw_config, $brand_name)->init();46 BVProtectFW_V685::getInstance($mode, $request, $fw_config, $brand_name)->init(); 47 47 } else { 48 48 $plug_config = self::$settings->getOption(self::$info->services_option_name); 49 49 $config = array_key_exists('protect', $plug_config) ? $plug_config['protect'] : array(); 50 50 if (!is_array($config) || !array_key_exists('mc_conf_version', $config) || 51 (BVProtect_V68 3::CONF_VERSION !== $config['mc_conf_version'])) {51 (BVProtect_V685::CONF_VERSION !== $config['mc_conf_version'])) { 52 52 53 53 return false; … … 57 57 $request_ip_header = array_key_exists('ipheader', $config) ? $config['ipheader'] : null; 58 58 $req_config = array_key_exists('reqconfig', $config) ? $config['reqconfig'] : array(); 59 $request = new BVProtectRequest_V68 3($request_ip_header, $req_config);59 $request = new BVProtectRequest_V685($request_ip_header, $req_config); 60 60 $fw_config = array_key_exists('fw', $config) ? $config['fw'] : array(); 61 61 $lp_config = array_key_exists('lp', $config) ? $config['lp'] : array(); 62 62 63 BVProtectFW_V68 3::getInstance($mode, $request, $fw_config, $brand_name)->init();64 BVProtectLP_V68 3::getInstance($request, $lp_config, $brand_name)->init();63 BVProtectFW_V685::getInstance($mode, $request, $fw_config, $brand_name)->init(); 64 BVProtectLP_V685::getInstance($request, $lp_config, $brand_name)->init(); 65 65 } 66 66 } … … 69 69 self::$settings->deleteOption('bvptconf'); 70 70 self::$settings->deleteOption('bvptplug'); 71 BVProtectIpstore_V68 3::uninstall();72 BVProtectFW_V68 3::uninstall();73 BVProtectLP_V68 3::uninstall();71 BVProtectIpstore_V685::uninstall(); 72 BVProtectFW_V685::uninstall(); 73 BVProtectLP_V685::uninstall(); 74 74 75 BVProtect_V68 3::removeWPPrepend();76 BVProtect_V68 3::removePHPPrepend();77 BVProtect_V68 3::removeMCData();75 BVProtect_V685::removeWPPrepend(); 76 BVProtect_V685::removePHPPrepend(); 77 BVProtect_V685::removeMCData(); 78 78 79 79 return true; … … 96 96 $pattern = "@include '" . rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/malcare-waf.php" . "';"; 97 97 98 BVProtectUtils_V68 3::fileRemovePattern($fname, $pattern);98 BVProtectUtils_V685::fileRemovePattern($fname, $pattern); 99 99 } 100 100 101 101 private static function removePHPPrepend() { 102 BVProtect_V68 3::removeHtaccessPrepend();103 BVProtect_V68 3::removeUseriniPrepend();102 BVProtect_V685::removeHtaccessPrepend(); 103 BVProtect_V685::removeUseriniPrepend(); 104 104 } 105 105 … … 107 107 $pattern = "/# MalCare WAF(.|\n)*# END MalCare WAF/i"; 108 108 109 BVProtectUtils_V68 3::fileRemovePattern(rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/.htaccess", $pattern, true);109 BVProtectUtils_V685::fileRemovePattern(rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/.htaccess", $pattern, true); 110 110 } 111 111 … … 113 113 $pattern = "/; MalCare WAF(.|\n)*; END MalCare WAF/i"; 114 114 115 BVProtectUtils_V68 3::fileRemovePattern(rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/.user.ini", $pattern, true);115 BVProtectUtils_V685::fileRemovePattern(rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/.user.ini", $pattern, true); 116 116 } 117 117 … … 120 120 $mc_data_dir = $content_dir . "/mc_data"; 121 121 122 BVProtectUtils_V68 3::rrmdir($mc_data_dir);122 BVProtectUtils_V685::rrmdir($mc_data_dir); 123 123 } 124 124 } -
blogvault-real-time-backup/trunk/protect/request.php
r3795700 r3813747 3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 4 4 5 if (!class_exists('BVProtectRequest_V68 3')) :6 class BVProtectRequest_V68 3{5 if (!class_exists('BVProtectRequest_V685')) : 6 class BVProtectRequest_V685 { 7 7 public $ip; 8 8 public $host = ''; … … 20 20 public $files; 21 21 public $respcode; 22 public $status = BVProtectRequest_V68 3::STATUS_ALLOWED;23 public $category = BVProtectRequest_V68 3::CATEGORY_NORMAL;22 public $status = BVProtectRequest_V685::STATUS_ALLOWED; 23 public $category = BVProtectRequest_V685::CATEGORY_NORMAL; 24 24 25 25 public $wp_user; … … 60 60 61 61 public function __construct($ip_header, $config) { 62 $this->ip = BVProtectUtils_V68 3::getIP($ip_header);62 $this->ip = BVProtectUtils_V685::getIP($ip_header); 63 63 $this->timestamp = time(); 64 64 $this->get_params = $_GET; // phpcs:ignore WordPress.Security.NonceVerification.Recommended … … 142 142 public static function blacklistedCategories() { 143 143 return array( 144 BVProtectRequest_V68 3::CATEGORY_BOT_BLOCKED,145 BVProtectRequest_V68 3::CATEGORY_COUNTRY_BLOCKED,146 BVProtectRequest_V68 3::CATEGORY_USER_BLACKLISTED,147 BVProtectRequest_V68 3::CATEGORY_GLOBAL_BOT_BLOCKED144 BVProtectRequest_V685::CATEGORY_BOT_BLOCKED, 145 BVProtectRequest_V685::CATEGORY_COUNTRY_BLOCKED, 146 BVProtectRequest_V685::CATEGORY_USER_BLACKLISTED, 147 BVProtectRequest_V685::CATEGORY_GLOBAL_BOT_BLOCKED 148 148 ); 149 149 } 150 150 151 151 public static function whitelistedCategories() { 152 return array(BVProtectRequest_V68 3::CATEGORY_WHITELISTED);152 return array(BVProtectRequest_V685::CATEGORY_WHITELISTED); 153 153 } 154 154 … … 488 488 } 489 489 490 $_json_params = BVProtectUtils_V68 3::safeDecodeJSON(490 $_json_params = BVProtectUtils_V685::safeDecodeJSON( 491 491 $this->raw_body, 492 492 true, -
blogvault-real-time-backup/trunk/protect/wp_user.php
r3795700 r3813747 2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; 3 3 4 if (!class_exists('BVProtectWPUser_V68 3')) :5 class BVProtectWPUser_V68 3{4 if (!class_exists('BVProtectWPUser_V685')) : 5 class BVProtectWPUser_V685 { 6 6 public $id; 7 7 public $role; … … 22 22 public static function defaultUser() { 23 23 $time = (int) floor(time() / 43200); 24 return (new BVProtectWPUser_V68 3(0, 0, array(), $time));24 return (new BVProtectWPUser_V685(0, 0, array(), $time)); 25 25 } 26 26 … … 42 42 $capabilities = array_map('intval', explode(',', $capabilities)); 43 43 44 return (new BVProtectWPUser_V68 3((int) $id, (int) $role_level, $capabilities, (int) $time));44 return (new BVProtectWPUser_V685((int) $id, (int) $role_level, $capabilities, (int) $time)); 45 45 } 46 46 -
blogvault-real-time-backup/trunk/readme.txt
r3795700 r3813747 7 7 Tested up to: 7.1 8 8 Requires PHP: 7.0 9 Stable tag: 6.8 39 Stable tag: 6.85 10 10 License: GPLv2 or later 11 11 License URI: [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html) … … 271 271 272 272 == CHANGELOG == 273 = 6.85 = 274 * Improvement: Form test cleanup now also removes uploaded files, and checks each item against the test's record before deleting it. 275 * Improvement: Form tests now confirm what a test submission did (entry saved, notification email, integrations) without delivering the email, and remove the test entry afterwards. 276 * Improvement: Form tests support more form plugins, including their CAPTCHA and anti-spam checks. 277 * Improvement: Hardened the handling of form test requests. 278 273 279 = 6.83 = 274 280 * New: Broken Link Checker: checks your links from your own site, and highlights the broken ones on the page when you open it from the dashboard.
Note:
See TracChangeset
for help on using the changeset viewer.