<?php
#  ________         ____________      _____ ________                       ________      
#  ___  __ )____  _____  /___  /_____ __  /____  __ \______________ ______ ___  __/      
#  __  __  |_  / / /__  / __  / _  _ \_  __/__  /_/ /__  ___/_  __ \_  __ \__  /_        
#  _  /_/ / / /_/ / _  /  _  /  /  __// /_  _  ____/ _  /    / /_/ // /_/ /_  __/        
#  /_____/  \__,_/  /_/   /_/   \___/ \__/  /_/      /_/     \____/ \____/ /_/           
#  ________                             _____ _____              ________                
#  __  ___/_____ ___________  _____________(_)__  /______  __    ___  __ \______________ 
#  _____ \ _  _ \_  ___/_  / / /__  ___/__  / _  __/__  / / /    __  /_/ /__  ___/_  __ \
#  ____/ / /  __// /__  / /_/ / _  /    _  /  / /_  _  /_/ /     _  ____/ _  /    / /_/ /
#  /____/  \___/ \___/  \__,_/  /_/     /_/   \__/  _\__, /      /_/      /_/     \____/ 
#                                                   /____/                               
# 42756C6C657450726F6F66 5365637572697479 50726F 
#
/*	The Copyright, AITpro Software Products License Information must remain
	intact or all BulletProof Security Pro warranties, guarantees, liabilities are void.
	
	Copyright (C) Edward Alexander, AIT-pro.com. All rights reserved.

	AITpro Software Products License Information:
	BY DOWNLOADING, INSTALLING, COPYING, ACCESSING, OR USING BulletProof Security Pro YOU AGREE TO THE TERMS OF THIS AGREEMENT. 
	IF YOU 	ARE ACCEPTING THESE TERMS ON BEHALF OF ANOTHER PERSON OR A COMPANY OR OTHER LEGAL ENTITY, YOU REPRESENT AND WARRANT
	THAT YOU HAVE FULL AUTHORITY TO BIND THAT PERSON, COMPANY, OR LEGAL ENTITY TO THESE TERMS. IF YOU DO NOT AGREE TO THESE TERMS,
	* DO NOT DOWNLOAD, INSTALL, COPY, ACCESS, OR USE BulletProof Security Pro; AND
	* PROMPTLY RETURN BulletProof Security Pro TO THE PARTY FROM WHOM YOU ACQUIRED IT. IF YOU DOWNLOADED BulletProof Security Pro
	FROM THE AITPRO WEBSITE, CONTACT AITPRO FOR A REFUND IF APPLICABLE.
	
	AITpro Software Products License Information continued:
	You agree to keep the AITpro Software Products License for BulletProof Security Pro, unmodified or altered in any way,
	with the original copy of BulletProof Security Pro that you have and any and all copies or partial copies of BulletProof
	Security Pro that You make. 
*/
// Direct calls to this file are Forbidden when core files are not present
if ( ! function_exists ('add_action') ) {
		header('Status: 403 Forbidden');
		header('HTTP/1.1 403 Forbidden');
		exit();
}

// Check Exclude DB Table for the PHP Error Log path
function bps_ExcludePHPELogDB() {
global $wpdb, $bulletproof_security_arq_db_version;
$Etable_name = $wpdb->prefix . "bpspro_arq_exclude";
$options = get_option('bulletproof_security_options2');
$phpELogExclude = ! isset($options['bps_error_log_location']) ? '' : $options['bps_error_log_location'];
	
	if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $Etable_name ) ) == $Etable_name && $phpELogExclude != '' ) {	

		$getExcludeRows = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $Etable_name WHERE arq_exclude_source = %s", $phpELogExclude) );
	
		foreach ($getExcludeRows as $row) {
			if ($row->arq_exclude_source == $phpELogExclude) {
				return $row->arq_exclude_source;
			}
		}
	}
}

function bulletproof_security_admin_init() {
// As of 3.1 the register_activation_hook is not called when a plugin is updated
global $wpdb, $bpspro_version, $wp_version, $blog_id, $bulletproof_security_arq_db_version;

	if ( is_multisite() && $blog_id != 1 ) {

		$Ltable_name = $wpdb->prefix . "bpspro_login_security";
		$wpdb_collate = $wpdb->collate;
	
		if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $Ltable_name ) ) != $Ltable_name ) {	
	
		$sql = "CREATE TABLE $Ltable_name (
		id bigint(20) NOT NULL auto_increment,
		status varchar(60) NOT NULL default '',
		user_id varchar(60) NOT NULL default '',
		username varchar(60) NOT NULL default '',
		public_name varchar(250) NOT NULL default '',
		email varchar(100) NOT NULL default '',
		role varchar(15) NOT NULL default '',
		human_time datetime NOT NULL default '0000-00-00 00:00:00',
		login_time varchar(10) NOT NULL default '',
		lockout_time varchar(10) NOT NULL default '',
		failed_logins varchar(2) NOT NULL default '',
		ip_address varchar(45) NOT NULL default '',
		hostname varchar(60) NOT NULL default '',
		request_uri varchar(255) NOT NULL default '',
		UNIQUE KEY id (id)
		)
		COLLATE {$wpdb_collate};";
	
		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		dbDelta($sql);
		}	

	} else {
		
		$Qtable_name = $wpdb->prefix . "bpspro_arq_quarantine";
		$Etable_name = $wpdb->prefix . "bpspro_arq_exclude";
		$Stable_name = $wpdb->prefix . "bpspro_seclog_ignore";
		$Ltable_name = $wpdb->prefix . "bpspro_login_security";
		$DBBtable_name = $wpdb->prefix . "bpspro_db_backup";
		$DMtable_name = $wpdb->prefix . "bpspro_dbm_monitor";
		$FLtable_name = $wpdb->prefix . "bpspro_folder_lock";
		$MStable_name = $wpdb->prefix . "bpspro_mscan";
		
		$wpdb_collate = $wpdb->collate;
	
		if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $MStable_name ) ) != $MStable_name ) {	
		
		$sql = "CREATE TABLE $MStable_name (
		mscan_id bigint(20) NOT NULL auto_increment,
		mscan_status varchar(8) NOT NULL default '',
		mscan_type varchar(16) NOT NULL default '',
		mscan_path text NOT NULL,
		mscan_pattern text NOT NULL,
		mscan_skipped varchar(7) NOT NULL default '',
		mscan_ignored varchar(6) NOT NULL default '',
		mscan_db_table varchar(64) NOT NULL default '',
		mscan_db_column varchar(64) NOT NULL default '',
		mscan_db_pkid text NOT NULL,
		mscan_time datetime NOT NULL default '0000-00-00 00:00:00',
		PRIMARY KEY (mscan_id),
		UNIQUE KEY id (mscan_id)
		)
		COLLATE {$wpdb_collate};";
	
		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		dbDelta($sql);
		}
	
		if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $Qtable_name ) ) != $Qtable_name ) {	
		
		$sql = "CREATE TABLE $Qtable_name (
		id bigint(20) NOT NULL auto_increment,
		time datetime NOT NULL default '0000-00-00 00:00:00',
		arq_quarantine_source text NOT NULL,
		arq_quarantine_backup text NOT NULL,
		arq_quarantine_qpath text NOT NULL,
		UNIQUE KEY id (id)
		)
		COLLATE {$wpdb_collate};";
	
		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		dbDelta($sql);
		}
	
		if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $Etable_name ) ) != $Etable_name ) {	
		
		$sql = "CREATE TABLE $Etable_name (
		id bigint(20) NOT NULL auto_increment,
		time datetime NOT NULL default '0000-00-00 00:00:00',
		arq_exclude_source text NOT NULL,
		UNIQUE KEY id (id)
		)
		COLLATE {$wpdb_collate};";
	
		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		dbDelta($sql);
		}
	
		if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $Stable_name ) ) != $Stable_name ) {	
		
		$sql = "CREATE TABLE $Stable_name (
		id bigint(20) NOT NULL auto_increment,
		 time datetime NOT NULL default '0000-00-00 00:00:00',
		user_agent_bot text NOT NULL,
		UNIQUE KEY id (id)
		)
		COLLATE {$wpdb_collate};";
	
		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		dbDelta($sql);
		}
	
		if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $Ltable_name ) ) != $Ltable_name ) {	
		
		$sql = "CREATE TABLE $Ltable_name (
		id bigint(20) NOT NULL auto_increment,
		status varchar(60) NOT NULL default '',
		user_id varchar(60) NOT NULL default '',
		username varchar(60) NOT NULL default '',
		public_name varchar(250) NOT NULL default '',
		email varchar(100) NOT NULL default '',
		role varchar(15) NOT NULL default '',
		human_time datetime NOT NULL default '0000-00-00 00:00:00',
		login_time varchar(10) NOT NULL default '',
		lockout_time varchar(10) NOT NULL default '',
		failed_logins varchar(2) NOT NULL default '',
		ip_address varchar(45) NOT NULL default '',
		hostname varchar(60) NOT NULL default '',
		request_uri varchar(255) NOT NULL default '',
		UNIQUE KEY id (id)
		)
		COLLATE {$wpdb_collate};";
	
		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		dbDelta($sql);
		}
		
		// 11.5: new Folder Lock DB Table creation
		if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $FLtable_name ) ) != $FLtable_name ) {	
	
		$sql = "CREATE TABLE $FLtable_name (
		id bigint(20) NOT NULL auto_increment,
		folder_name text NOT NULL,
		status varchar(60) NOT NULL default '',
		curr_perms varchar(4) NOT NULL default '',
		orig_perms varchar(4) NOT NULL default '',
		path text NOT NULL,
		last_mod varchar(10) NOT NULL default '',
		ulock_time varchar(10) NOT NULL default '',
		hlock_time datetime NOT NULL default '0000-00-00 00:00:00',
		UNIQUE KEY id (id)
		)
		COLLATE {$wpdb_collate};";
	
		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		dbDelta($sql);
		}
	
		// last job, next job is updated by the cron - job size is the total size of all tables selected in that job
		if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $DBBtable_name ) ) != $DBBtable_name ) {	
		
		$sql = "CREATE TABLE $DBBtable_name (
		bps_id bigint(20) NOT NULL auto_increment,
		bps_table_name text NOT NULL,
		bps_desc text NOT NULL,
		bps_job_type varchar(9) NOT NULL default '',
		bps_frequency varchar(7) NOT NULL default '',
		bps_last_job varchar(30) NOT NULL default '',
		bps_next_job varchar(30) NOT NULL default '',
		bps_next_job_unix varchar(10) NOT NULL default '',  
		bps_email_zip varchar(10) NOT NULL default '',
		bps_job_created datetime NOT NULL default '0000-00-00 00:00:00',
		UNIQUE KEY bps_id (bps_id)
		)
		COLLATE {$wpdb_collate};";
	
		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		dbDelta($sql);
		}
	
		if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $DMtable_name ) ) != $DMtable_name ) {	
		
		$sql = "CREATE TABLE $DMtable_name (
		bps_id bigint(20) NOT NULL auto_increment,
		bps_table_name varchar(64) NOT NULL default '',
		bps_check varchar(20) NOT NULL default '',
		bps_size varchar(64) NOT NULL default '',  
		bps_update_time datetime NOT NULL default '0000-00-00 00:00:00',
		bps_created datetime NOT NULL default '0000-00-00 00:00:00',
		PRIMARY KEY  (bps_id),
		UNIQUE KEY bps_table_name (bps_table_name)
		)
		COLLATE {$wpdb_collate};";
		
		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		dbDelta($sql);
		add_option("bulletproof_security_arq_db_version", $bulletproof_security_arq_db_version);
		// Delete Old BPS free transient content
		delete_transient( 'bulletproof-security_info' );
		}
	}

	$phpELogOptions = get_option('bulletproof_security_options2');
	$phpELogExclude = ! isset($phpELogOptions['bps_error_log_location']) ? '' : $phpELogOptions['bps_error_log_location'];

	// ONLY Insert PHP Error Log path into Exclude DB Table if php error log path is not /bps-backups/logs
	// Delete php error log row from the arq exclude DB Table if it points to the /bps-backups/logs folder
	$ELogExcludeDB = bps_ExcludePHPELogDB(); // ONLY returns an error log path if the DB Row matches the error log location option and is not blank
	$LogsExcludePath = '/bps-backup\/logs/';
	// if the error log path DOES NOT contain bps-backup/logs in the path and the DB Row does not exist then add the Row in the DB.
	// also checks that the bps_error_log_location DB option is not blank otherwise blank rows would be created.
	if ( ! preg_match( $LogsExcludePath, $phpELogExclude, $matches ) && $ELogExcludeDB == '' && $phpELogExclude != '' ) {
		$QExcludeInsertRows = $wpdb->insert( $Etable_name, array( 'time' => current_time('mysql'), 'arq_exclude_source' => $phpELogExclude ) );
	}
	// if the error log path DOES contain bps-backups/logs in the ARQ Exclude DB Table then delete the DB Row
	if ( preg_match( $LogsExcludePath, $phpELogExclude, $matches ) ) {
		$bps_delete_row = $wpdb->query( $wpdb->prepare( "DELETE FROM $Etable_name WHERE arq_exclude_source = %s", $phpELogExclude));
	}
	
	// Copy & Touch master backup class.php file - overwrite class.php and synchronize last modifed time
	// Prevents wp-content files from being quarantined that have ARQ wp-content folder exclude rules in the class.php file.
	// 13: This code is now only use for these 2 BPS Pro installation/upgrade methods: Upload zip install and manual file copy.
	// 13: For BPS Pro Shiny upgrades the upgrader_post_install Filter executes this function: bpsPro_class_backup_file_copy() in arq-cron.php 
	// 12.8|13: Removed Turn ARQ Off|On & ARQ Status checking code during the preg_replace and copy.
	// The ARQ Cron will not run if the timestamps do not match. Does not need to be GMT time
	// 12.7: update the api http uri to https
	$bpsClassFile = WP_PLUGIN_DIR . '/bulletproof-security/includes/class.php';
	$bpsClassFileARQMB = WP_CONTENT_DIR . '/bps-backup/master-backups/class.php';
	$bpsClassFileARQ = WP_CONTENT_DIR . '/bps-backup/autorestore/wp-content/plugins/bulletproof-security/includes/class.php';
	
	if ( file_exists($bpsClassFileARQMB) && filemtime($bpsClassFileARQMB) != filemtime($bpsClassFile) ) {
		
		$bpsClassFileARQMB_contents = @file_get_contents($bpsClassFileARQMB);
	
		if ( preg_match( '/http:\/\/api.ait-pro.com/', $bpsClassFileARQMB_contents ) ) {
			
			$stringReplace = @file_get_contents($bpsClassFileARQMB);
			$stringReplace = preg_replace('/http:\/\/api.ait-pro.com/', "https://api.ait-pro.com", $stringReplace);
			file_put_contents($bpsClassFileARQMB, $stringReplace);
		}
		
		@copy($bpsClassFileARQMB, $bpsClassFile);
		if ( is_dir( WP_CONTENT_DIR . '/bps-backup/autorestore/wp-content/plugins/bulletproof-security/includes' ) ) {
			@copy($bpsClassFileARQMB, $bpsClassFileARQ);
		}
		@touch($bpsClassFile);
		@touch($bpsClassFileARQMB);
	}

// Whitelist BPS DB options: Total: 91 
register_setting('bulletproof_security_options', 'bulletproof_security_options', 'bulletproof_security_options_validate');
register_setting('bulletproof_security_options2', 'bulletproof_security_options2', 'bulletproof_security_options_validate2');
register_setting('bulletproof_security_options_pfw', 'bulletproof_security_options_pfw', 'bulletproof_security_options_validate_pfw');
register_setting('bulletproof_security_options_GMT', 'bulletproof_security_options_GMT', 'bulletproof_security_options_validate_GMT');
register_setting('bulletproof_security_options_ARCM', 'bulletproof_security_options_ARCM', 'bulletproof_security_options_validate_ARCM');
register_setting('bulletproof_security_options_debug', 'bulletproof_security_options_debug', 'bulletproof_security_options_validate_debug');
register_setting('bulletproof_security_options_MScan', 'bulletproof_security_options_MScan', 'bulletproof_security_options_validate_MScan');
register_setting('bulletproof_security_options_vcheck', 'bulletproof_security_options_vcheck', 'bulletproof_security_options_validate_vcheck');
register_setting('bulletproof_security_options_DBM_log', 'bulletproof_security_options_DBM_log', 'bulletproof_security_options_validate_DBM_log');
register_setting('bulletproof_security_options_DBB_log', 'bulletproof_security_options_DBB_log', 'bulletproof_security_options_validate_DBB_log');
register_setting('bulletproof_security_options_ARCM_log', 'bulletproof_security_options_ARCM_log', 'bulletproof_security_options_validate_ARCM_log');
register_setting('bulletproof_security_options_autolock', 'bulletproof_security_options_autolock', 'bulletproof_security_options_validate_autolock');
register_setting('bulletproof_security_options_MU_tools', 'bulletproof_security_options_MU_tools', 'bulletproof_security_options_validate_MU_tools');
register_setting('bulletproof_security_options_b64_tools', 'bulletproof_security_options_b64_tools', 'bulletproof_security_options_validate_b64_tools');
register_setting('bulletproof_security_options_MScan_log', 'bulletproof_security_options_MScan_log', 'bulletproof_security_options_validate_MScan_log');
register_setting('bulletproof_security_options_pfirewall', 'bulletproof_security_options_pfirewall', 'bulletproof_security_options_validate_pfirewall');
register_setting('bulletproof_security_options_flock_eol', 'bulletproof_security_options_flock_eol', 'bulletproof_security_options_validate_flock_eol');
register_setting('bulletproof_security_options_customcode', 'bulletproof_security_options_customcode', 'bulletproof_security_options_validate_customcode');
register_setting('bulletproof_security_options_mu_sysinfo', 'bulletproof_security_options_mu_sysinfo', 'bulletproof_security_options_validate_mu_sysinfo');
register_setting('bulletproof_security_options_wizard_curl', 'bulletproof_security_options_wizard_curl', 'bulletproof_security_options_validate_wizard_curl');
register_setting('bulletproof_security_options_auth_cookie', 'bulletproof_security_options_auth_cookie', 'bulletproof_security_options_validate_auth_cookie');
register_setting('bulletproof_security_options_new_feature', 'bulletproof_security_options_new_feature', 'bulletproof_security_options_validate_new_feature');
register_setting('bulletproof_security_options_Security_log', 'bulletproof_security_options_Security_log', 'bulletproof_security_options_validate_Security_log');
register_setting('bulletproof_security_options_MScan_status', 'bulletproof_security_options_MScan_status', 'bulletproof_security_options_validate_MScan_status');
register_setting('bulletproof_security_options_mscan_report', 'bulletproof_security_options_mscan_report', 'bulletproof_security_options_validate_mscan_report');
register_setting('bulletproof_security_options_mod_security', 'bulletproof_security_options_mod_security', 'bulletproof_security_options_validate_mod_security');
register_setting('bulletproof_security_options_uaeg_version', 'bulletproof_security_options_uaeg_version', 'bulletproof_security_options_validate_uaeg_version');
register_setting('bulletproof_security_options_pfw_autopilot', 'bulletproof_security_options_pfw_autopilot', 'bulletproof_security_options_validate_pfw_autopilot');
register_setting('bulletproof_security_options_upgrade_email', 'bulletproof_security_options_upgrade_email', 'bulletproof_security_options_validate_upgrade_email');
register_setting('bulletproof_security_options_mscan_patterns', 'bulletproof_security_options_mscan_patterns', 'bulletproof_security_options_validate_mscan_patterns');
register_setting('bulletproof_security_options_exclude_folder', 'bulletproof_security_options_exclude_folder', 'bulletproof_security_options_validate_exclude_folder');
register_setting('bulletproof_security_options_login_security', 'bulletproof_security_options_login_security', 'bulletproof_security_options_validate_login_security');
register_setting('bulletproof_security_options_htaccess_files', 'bulletproof_security_options_htaccess_files', 'bulletproof_security_options_validate_htaccess_files');
register_setting('bulletproof_security_options_hidden_plugins', 'bulletproof_security_options_hidden_plugins', 'bulletproof_security_options_validate_hidden_plugins');
register_setting('bulletproof_security_options_pfirewall_roles', 'bulletproof_security_options_pfirewall_roles', 'bulletproof_security_options_validate_pfirewall_roles');
register_setting('bulletproof_security_options_preinstallation', 'bulletproof_security_options_preinstallation', 'bulletproof_security_options_validate_preinstallation');
register_setting('bulletproof_security_options_flock_FL_alerts', 'bulletproof_security_options_flock_FL_alerts', 'bulletproof_security_options_validate_flock_FL_alerts');
register_setting('bulletproof_security_options_pfw_new_install', 'bulletproof_security_options_pfw_new_install', 'bulletproof_security_options_validate_pfw_new_install');
register_setting('bulletproof_security_options_php_memory_limit', 'bulletproof_security_options_php_memory_limit', 'bulletproof_security_options_validate_php_memory_limit');
register_setting('bulletproof_security_options_setup_wizard_woo', 'bulletproof_security_options_setup_wizard_woo', 'bulletproof_security_options_validate_setup_wizard_woo');
register_setting('bulletproof_security_options_mscan_t_hash_new', 'bulletproof_security_options_mscan_t_hash_new', 'bulletproof_security_options_validate_mscan_t_hash_new');
register_setting('bulletproof_security_options_mscan_nodownload', 'bulletproof_security_options_mscan_nodownload', 'bulletproof_security_options_validate_mscan_nodownload');
register_setting('bulletproof_security_options_mscan_zip_upload', 'bulletproof_security_options_mscan_zip_upload', 'bulletproof_security_options_validate_mscan_zip_upload');
register_setting('bulletproof_security_options_mscan_theme_hash', 'bulletproof_security_options_mscan_theme_hash', 'bulletproof_security_options_validate_mscan_theme_hash');
register_setting('bulletproof_security_options_mscan_p_hash_new', 'bulletproof_security_options_mscan_p_hash_new', 'bulletproof_security_options_validate_mscan_p_hash_new');
register_setting('bulletproof_security_options_mscan_plugin_hash', 'bulletproof_security_options_mscan_plugin_hash', 'bulletproof_security_options_validate_mscan_plugin_hash');
register_setting('bulletproof_security_options_sec_log_post_limit', 'bulletproof_security_options_sec_log_post_limit', 'bulletproof_security_options_validate_sec_log_post_limit');
register_setting('bulletproof_security_options_login_security_jtc', 'bulletproof_security_options_login_security_jtc', 'bulletproof_security_options_validate_login_security_jtc');
register_setting('bulletproof_security_options_setup_wizard_flock', 'bulletproof_security_options_setup_wizard_flock', 'bulletproof_security_options_validate_setup_wizard_flock');	
register_setting('bulletproof_security_options_mu_wp_autoupdate', 'bulletproof_security_options_mu_wp_autoupdate', 'bulletproof_security_options_validate_mu_wp_autoupdate');
register_setting('bulletproof_security_options_pfirewall_allow', 'bulletproof_security_options_pfirewall_allow', 'bulletproof_security_options_validate_pfirewall_allow');
register_setting('bulletproof_security_options_customcode_UAEG', 'bulletproof_security_options_customcode_UAEG', 'bulletproof_security_options_validate_customcode_UAEG');
register_setting('bulletproof_security_options_wizard_autofix', 'bulletproof_security_options_wizard_autofix', 'bulletproof_security_options_validate_wizard_autofix');
register_setting('bulletproof_security_options_upgrade_notice', 'bulletproof_security_options_upgrade_notice', 'bulletproof_security_options_validate_upgrade_notice');
register_setting('bulletproof_security_options_customcode_WPA', 'bulletproof_security_options_customcode_WPA', 'bulletproof_security_options_validate_customcode_WPA');
register_setting('bulletproof_security_options_apache_modules', 'bulletproof_security_options_apache_modules', 'bulletproof_security_options_validate_apache_modules');
register_setting('bulletproof_security_options_arq_add_delete', 'bulletproof_security_options_arq_add_delete', 'bulletproof_security_options_validate_arq_add_delete');
register_setting('bulletproof_security_options_arq_add_hidden', 'bulletproof_security_options_arq_add_hidden', 'bulletproof_security_options_validate_arq_add_hidden');
register_setting('bulletproof_security_options_arq_host_root', 'bulletproof_security_options_arq_host_root', 'bulletproof_security_options_validate_arq_host_root');
register_setting('bulletproof_security_options_pfw_test_mode', 'bulletproof_security_options_pfw_test_mode', 'bulletproof_security_options_validate_pfw_test_mode');
register_setting('bulletproof_security_options_wp_autoupdate', 'bulletproof_security_options_wp_autoupdate', 'bulletproof_security_options_validate_wp_autoupdate'); // delete
register_setting('bulletproof_security_options_xternal_tools', 'bulletproof_security_options_xternal_tools', 'bulletproof_security_options_validate_xternal_tools');
register_setting('bulletproof_security_options_idle_session', 'bulletproof_security_options_idle_session', 'bulletproof_security_options_validate_idle_session');
register_setting('bulletproof_security_options_login_alerts', 'bulletproof_security_options_login_alerts', 'bulletproof_security_options_validate_login_alerts');
register_setting('bulletproof_security_options_htaccess_res', 'bulletproof_security_options_htaccess_res', 'bulletproof_security_options_validate_htaccess_res');
register_setting('bulletproof_security_options_zip_filename', 'bulletproof_security_options_zip_filename', 'bulletproof_security_options_validate_zip_filename');
register_setting('bulletproof_security_options_ARQ_upgrade', 'bulletproof_security_options_ARQ_upgrade', 'bulletproof_security_options_validate_ARQ_upgrade');
register_setting('bulletproof_security_options_ARQ_status', 'bulletproof_security_options_ARQ_status', 'bulletproof_security_options_validate_ARQ_status');
register_setting('bulletproof_security_options_db_monitor', 'bulletproof_security_options_db_monitor', 'bulletproof_security_options_validate_db_monitor');
register_setting('bulletproof_security_options_maint_mode', 'bulletproof_security_options_maint_mode', 'bulletproof_security_options_validate_maint_mode');
register_setting('bulletproof_security_options_theme_skin', 'bulletproof_security_options_theme_skin', 'bulletproof_security_options_validate_theme_skin');
register_setting('bulletproof_security_options_activation', 'bulletproof_security_options_activation', 'bulletproof_security_options_validate_activation');
register_setting('bulletproof_security_options_wp_version', 'bulletproof_security_options_wp_version', 'bulletproof_security_options_validate_wp_version');
register_setting('bulletproof_security_options_db_backup', 'bulletproof_security_options_db_backup', 'bulletproof_security_options_validate_db_backup');
register_setting('bulletproof_security_options_wpt_nodes', 'bulletproof_security_options_wpt_nodes', 'bulletproof_security_options_validate_wpt_nodes');
register_setting('bulletproof_security_options_scrolltop', 'bulletproof_security_options_scrolltop', 'bulletproof_security_options_validate_scrolltop');
register_setting('bulletproof_security_options_hpf_cron', 'bulletproof_security_options_hpf_cron', 'bulletproof_security_options_validate_hpf_cron');
register_setting('bulletproof_security_options_flock_FL', 'bulletproof_security_options_flock_FL', 'bulletproof_security_options_validate_flock_FL');
register_setting('bulletproof_security_options_rate_pro', 'bulletproof_security_options_rate_pro', 'bulletproof_security_options_validate_rate_pro');
register_setting('bulletproof_security_options_spinner', 'bulletproof_security_options_spinner', 'bulletproof_security_options_validate_spinner');
register_setting('bulletproof_security_options_monitor', 'bulletproof_security_options_monitor', 'bulletproof_security_options_validate_monitor');
register_setting('bulletproof_security_options_mynotes', 'bulletproof_security_options_mynotes', 'bulletproof_security_options_validate_mynotes');
register_setting('bulletproof_security_options_zip_fix', 'bulletproof_security_options_zip_fix', 'bulletproof_security_options_validate_zip_fix');
register_setting('bulletproof_security_options_iniSet', 'bulletproof_security_options_iniSet', 'bulletproof_security_options_validate_iniSet');
register_setting('bulletproof_security_options_flock', 'bulletproof_security_options_flock', 'bulletproof_security_options_validate_flock');
register_setting('bulletproof_security_options_email', 'bulletproof_security_options_email', 'bulletproof_security_options_validate_email');
register_setting('bulletproof_security_options_gdpr', 'bulletproof_security_options_gdpr', 'bulletproof_security_options_validate_gdpr');
register_setting('bulletproof_security_options_elog', 'bulletproof_security_options_elog', 'bulletproof_security_options_validate_elog');
register_setting('bulletproof_security_options_GDMW', 'bulletproof_security_options_GDMW', 'bulletproof_security_options_validate_GDMW');
register_setting('bulletproof_security_options_SLF', 'bulletproof_security_options_SLF', 'bulletproof_security_options_validate_SLF');
register_setting('bulletproof_security_options_fsp', 'bulletproof_security_options_fsp', 'bulletproof_security_options_validate_fsp');

	// Create BPS Backup Folder
	if ( ! is_dir( WP_CONTENT_DIR . '/bps-backup' ) ) {
		@mkdir( WP_CONTENT_DIR . '/bps-backup', 0755, true );
		@chmod( WP_CONTENT_DIR . '/bps-backup/', 0755 );
	}
	
	// Create master backups folder
	if ( ! is_dir( WP_CONTENT_DIR . '/bps-backup/master-backups' ) ) {
		@mkdir( WP_CONTENT_DIR . '/bps-backup/master-backups', 0755, true );
		@chmod( WP_CONTENT_DIR . '/bps-backup/master-backups/', 0755 );
	}

	// Create autorestore folder
	if ( ! is_dir( WP_CONTENT_DIR . '/bps-backup/autorestore' ) ) {
		@mkdir( WP_CONTENT_DIR . '/bps-backup/autorestore', 0755, true );
		@chmod( WP_CONTENT_DIR . '/bps-backup/autorestore/', 0755 );
	}
	
	// Create quarantine folder
	if ( ! is_dir( WP_CONTENT_DIR . '/bps-backup/quarantine' ) ) {
		@mkdir( WP_CONTENT_DIR . '/bps-backup/quarantine', 0755, true );
		@chmod( WP_CONTENT_DIR . '/bps-backup/quarantine/', 0755 );
	}
	
	// Create logs folder
	if ( ! is_dir( WP_CONTENT_DIR . '/bps-backup/logs' ) ) {
		@mkdir( WP_CONTENT_DIR . '/bps-backup/logs', 0755, true );
		@chmod( WP_CONTENT_DIR . '/bps-backup/logs/', 0755 );
	}

	// Create the wp-hashes folder
	if ( ! is_dir( WP_CONTENT_DIR . '/bps-backup/wp-hashes' ) ) {
		@mkdir( WP_CONTENT_DIR . '/bps-backup/wp-hashes', 0755, true );
		@chmod( WP_CONTENT_DIR . '/bps-backup/wp-hashes/', 0755 );
	}

	// Create the mscan folder for mscan pattern matching file/code
	if ( ! is_dir( WP_CONTENT_DIR . '/bps-backup/mscan' ) ) {
		@mkdir( WP_CONTENT_DIR . '/bps-backup/mscan', 0755, true );
		@chmod( WP_CONTENT_DIR . '/bps-backup/mscan/', 0755 );
	}

	// Copy the blank wp-hashes.php file to the /wp-hashes/ folder
	$wp_hashes_file_master = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/wp-hashes.php';
	$wp_hashes_file = WP_CONTENT_DIR . '/bps-backup/wp-hashes/wp-hashes.php';
	
	if ( ! file_exists($wp_hashes_file) ) {
		copy($wp_hashes_file_master, $wp_hashes_file);
	}	

	if ( ! is_dir( WP_CONTENT_DIR . '/bps-backup/plugin-hashes' ) ) {
		@mkdir( WP_CONTENT_DIR . '/bps-backup/plugin-hashes', 0755, true );
		@chmod( WP_CONTENT_DIR . '/bps-backup/plugin-hashes/', 0755 );
	}

	$plugin_hash_file = WP_CONTENT_DIR . '/bps-backup/plugin-hashes/plugin-hashes.php';
	$blank_hash_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/wp-hashes.php';

	if ( ! file_exists($plugin_hash_file) ) {
		copy($blank_hash_file, $plugin_hash_file);
	}

	if ( ! is_dir( WP_CONTENT_DIR . '/bps-backup/theme-hashes' ) ) {
		@mkdir( WP_CONTENT_DIR . '/bps-backup/theme-hashes', 0755, true );
		@chmod( WP_CONTENT_DIR . '/bps-backup/theme-hashes/', 0755 );
	}

	$theme_hash_file = WP_CONTENT_DIR . '/bps-backup/theme-hashes/theme-hashes.php';
	$blank_hash_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/wp-hashes.php';

	if ( ! file_exists($theme_hash_file) ) {
		copy($blank_hash_file, $theme_hash_file);
	}

	// Create the MScan log file in /logs
	$bpsProMScanLog = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/mscan_log.txt';
	$bpsProMScanLogARQ = WP_CONTENT_DIR . '/bps-backup/logs/mscan_log.txt';
	
	if ( ! file_exists($bpsProMScanLogARQ) ) {
		@copy($bpsProMScanLog, $bpsProMScanLogARQ);
	}

	// Previously the mscan-pattern-match.php file was copied to the /mscan/ folder and then deleted from the /htaccess/ folder
	// 15.3: Create new MScan pattern match DB options and then delete the mscan-pattern-match.php file from the /htaccess/ folder 
	// and the old mscan-pattern-match.php file in the /bps-backup/mscan/ folder.
	$mscan_pattern_match_master = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/mscan-pattern-match.php';
	$mscan_pattern_match_file = WP_CONTENT_DIR . '/bps-backup/mscan/mscan-pattern-match.php';

	if ( file_exists($mscan_pattern_match_master) ) {		

		require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/mscan-pattern-match.php' );
	
		$mscan_pattern_match_files = array( 
				'mscan_pattern_match_files' => 
					array( 
					'js_patterns' 		=> $js_pattern,
					'htaccess_patterns' => $htaccess_pattern,
					'php_patterns' 		=> $php_pattern,
					'image_patterns' 	=> $image_pattern 
					)
		);
	
		$mscan_pattern_match_db = array( 
				'mscan_pattern_match_db' => 
					array( 
					'search1' 			=> $search1,
					'search2' 			=> $search2,
					'search3' 			=> $search3,
					'search4' 			=> $search4, 
					'search5' 			=> $search5,
					'search6' 			=> $search6,
					'search7' 			=> $search7,
					'search8' 			=> $search8, 
					'search9' 			=> $search9, 
					'eval_match' 		=> $eval_match,
					'b64_decode_match'	=> $base64_decode_match,
					'eval_text' 		=> $eval_text,
					'b64_decode_text' 	=> $base64_decode_text 
					)
		);
		
		$mscan_pattern_match_options = array(
		'mscan_pattern_match_files' 		=> $mscan_pattern_match_files, 
		'mscan_pattern_match_db' 			=> $mscan_pattern_match_db 
		);
	
		foreach( $mscan_pattern_match_options as $key => $value ) {
			update_option('bulletproof_security_options_mscan_patterns', $mscan_pattern_match_options);
		}
			
		unlink($mscan_pattern_match_master);
	}

	if ( file_exists($mscan_pattern_match_file) ) {
		unlink($mscan_pattern_match_file);
	}

	// Create backups folder with randomly generated folder name, create the db-diff folder & save the backups folder name to the DB
	bpsPro_create_db_backup_folder();

	// Create AutoRestore/Quarantine - ARQ Log
	$bps_AutoRestore_Log = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/autorestore_log.txt';
	$bps_AutoRestore_LogARQ = WP_CONTENT_DIR . '/bps-backup/logs/autorestore_log.txt';
	
	if ( ! file_exists($bps_AutoRestore_LogARQ) ) {
		@copy($bps_AutoRestore_Log, $bps_AutoRestore_LogARQ);
	}	
	
	// Create Pro-Tools B64.zip and bps_b64_decode.txt in /logs
	$bpsB64TXT = WP_PLUGIN_DIR . '/bulletproof-security/admin/tools/bps_b64_decode.txt';
	$bpsB64Zip = WP_PLUGIN_DIR . '/bulletproof-security/admin/tools/B64.zip';	
	$bpsB64TXTARQ = WP_CONTENT_DIR . '/bps-backup/logs/bps_b64_decode.txt';
	$bpsB64ZipARQ = WP_CONTENT_DIR . '/bps-backup/logs/B64.zip';	
	
	if ( ! file_exists($bpsB64TXTARQ) ) {
		@copy($bpsB64TXT, $bpsB64TXTARQ);
	}
	if ( ! file_exists($bpsB64ZipARQ) ) {
		@copy($bpsB64Zip, $bpsB64ZipARQ);
	}	

	// Automatically delete the Pro-Tools B64 Decoder/Encoder files
	bpsPro_delete_b64_tools();

	// Create the String Replacer log file in /logs
	$bpsStringReplaceLog = WP_PLUGIN_DIR . '/bulletproof-security/admin/tools/string_replacer_log.txt';
	$bpsStringReplaceLogARQ = WP_CONTENT_DIR . '/bps-backup/logs/string_replacer_log.txt';	
	
	if ( ! file_exists($bpsStringReplaceLogARQ) ) {
		@copy($bpsStringReplaceLog, $bpsStringReplaceLogARQ);
	}	
	
	// Create the Security / HTTP error log in /logs
	$bpsProLog = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/http_error_log.txt';
	$bpsProLogARQ = WP_CONTENT_DIR . '/bps-backup/logs/http_error_log.txt';
	
	if ( ! file_exists($bpsProLogARQ) ) {
		@copy($bpsProLog, $bpsProLogARQ);
	}		

	// Create the PHP error log in /logs - the PHP Error Log file location can be changed by users, but create this file by default
	$bpsProPHPELog = WP_PLUGIN_DIR . '/bulletproof-security/admin/php/bps_php_error_master.log';
	$bpsProPHPELogARQ = WP_CONTENT_DIR . '/bps-backup/logs/bps_php_error.log';
	
	if ( ! file_exists($bpsProPHPELogARQ) ) {
		@copy($bpsProPHPELog, $bpsProPHPELogARQ);
	}		

	// Create the DB Monitor log in /logs
	$bpsProDBMLog = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/db_monitor_log.txt';
	$bpsProDBMLogARQ = WP_CONTENT_DIR . '/bps-backup/logs/db_monitor_log.txt';
	
	if ( ! file_exists($bpsProDBMLogARQ) ) {
		@copy($bpsProDBMLog, $bpsProDBMLogARQ);
	}

	// Create the DB Backup log in /logs
	$bpsProDBBLog = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/db_backup_log.txt';
	$bpsProDBBLogARQ = WP_CONTENT_DIR . '/bps-backup/logs/db_backup_log.txt';
	
	if ( ! file_exists($bpsProDBBLogARQ) ) {
		@copy($bpsProDBBLog, $bpsProDBBLogARQ);
	}

	// Copy and rename the blank.txt file to /master-backups - used for resetting the Login Security alert/timestamp
	$BPSblank = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/blank.txt';
	$SecurityLogReset = WP_CONTENT_DIR . '/bps-backup/master-backups/Login-Security-Alert-Reset.txt';
	
	if ( ! file_exists($SecurityLogReset) ) {
		@copy($BPSblank, $SecurityLogReset);
	}

	// Copy and rename the blank.txt file to /master-backups - used for resetting the Folder Lock alert/timestamp
	$FolderLockReset = WP_CONTENT_DIR . '/bps-backup/master-backups/Folder-Lock-Alert-Reset.txt';
	
	if ( ! file_exists($FolderLockReset) ) {
		@copy($BPSblank, $FolderLockReset);
	}

	// 13.3: Copy and rename the blank.txt file to /master-backups - used for MScan Stop Scan
	$MScanStop = WP_CONTENT_DIR . '/bps-backup/master-backups/mscan-stop.txt';
	
	if ( ! file_exists($MScanStop) ) {
		@copy($BPSblank, $MScanStop);
	}

	// Create the ARQ /mu-plugins/ Folder
	if ( ! is_dir( WP_CONTENT_DIR . '/bps-backup/autorestore/wp-content/mu-plugins' ) ) {
		@mkdir( WP_CONTENT_DIR . '/bps-backup/autorestore/wp-content/mu-plugins', 0755, true );
		@chmod( WP_CONTENT_DIR . '/bps-backup/autorestore/wp-content/mu-plugins/', 0755 );
	}

	// Create the /mu-plugins/ Folder
	if ( ! is_dir( WP_CONTENT_DIR . '/mu-plugins' ) ) {
		@mkdir( WP_CONTENT_DIR . '/mu-plugins', 0755, true );
		@chmod( WP_CONTENT_DIR . '/mu-plugins/', 0755 );
	}

	// Copy the bps-pro-mu-tools.php file to /mu-plugins/ & ARQ backup.
	// Note: An ARQ single file exclude rule is created for this file during BPS Pro upgrades and when running the Setup Wizard.
	// bpsPro_mu_tools_exclude_rule() in functions.php
	$BPS_MU_tools = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/bps-pro-mu-tools.php';
	$BPS_MU_tools_copy = WP_CONTENT_DIR . '/mu-plugins/bps-pro-mu-tools.php';
	$BPS_MU_tools_ARQ = WP_CONTENT_DIR . '/bps-backup/autorestore/wp-content/mu-plugins/bps-pro-mu-tools.php';	

	if ( is_dir( WP_CONTENT_DIR . '/mu-plugins' ) && ! file_exists($BPS_MU_tools_copy) ) {
		@copy($BPS_MU_tools, $BPS_MU_tools_ARQ);
		@copy($BPS_MU_tools, $BPS_MU_tools_copy);
	}

	$bps_autofix_options = 'bulletproof_security_options_wizard_autofix';			

	$AutoFix_Option_settings = array( 'bps_wizard_autofix' => 'On' );
	
	if ( ! get_option( $bps_autofix_options ) ) {			
		
		foreach( $AutoFix_Option_settings as $key => $value ) {
			update_option('bulletproof_security_options_wizard_autofix', $AutoFix_Option_settings);
		}
	}

	$mu_tools_options = 'bulletproof_security_options_MU_tools';			

	$MUTools_Option_settings = array( 
	'bps_mu_tools_timestamp' 		=> time() + 300, 
	'bps_mu_tools_enable_disable' 	=> 'enable' 
	);
	
	if ( ! get_option( $mu_tools_options ) ) {			
		
		foreach( $MUTools_Option_settings as $key => $value ) {
			update_option('bulletproof_security_options_MU_tools', $MUTools_Option_settings);
		}
	}
} // end admin_init

// BPS Menus
function bulletproof_security_admin_menu() {
global $blog_id;

	if ( current_user_can('manage_options') ) {
	
	// Network / Multisite display partial BPS Pro menus
	if ( is_multisite() && $blog_id != 1 ) {

	add_menu_page(__('BulletProof Pro Security Settings', 'bulletproof-security'), __('BPS Pro', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/login/login.php', '', plugins_url('bulletproof-security/admin/images/bps-icon-small.png') );
	add_submenu_page('bulletproof-security/admin/login/login.php', __('Login Security ~ JTC', 'bulletproof-security'), __('Login Security', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/login/login.php' );
	add_submenu_page('bulletproof-security/admin/login/login.php', __('Login Security ~ JTC', 'bulletproof-security'), __('JTC Anti-Spam<br>Anti-Hacker', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/login/login.php#bps-tabs-2' );
	
	// Do not display the Maintenance Mode menu for GDMW hosted sites
	$GDMW_options = get_option('bulletproof_security_options_GDMW');
	if ( isset($GDMW_options['bps_gdmw_hosting']) && $GDMW_options['bps_gdmw_hosting'] != 'yes' ) {	
	add_submenu_page('bulletproof-security/admin/login/login.php', __('Maintenance Mode', 'bulletproof-security'), __('Maintenance Mode', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/maintenance/maintenance.php' );
	}
	
	// 13.7: Setup Wizard Option: Multisite Hide|Display System Info Page for Subsites
	$Mu_Sysinfo_page_options = get_option('bulletproof_security_options_mu_sysinfo');
	if ( isset($Mu_Sysinfo_page_options['bps_sysinfo_hide_display']) && $Mu_Sysinfo_page_options['bps_sysinfo_hide_display'] != 'hide' ) {	
	add_submenu_page('bulletproof-security/admin/login/login.php', __('System Info', 'bulletproof-security'), __('System Info', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/system-info/system-info.php' );
	}
	
	add_submenu_page('bulletproof-security/admin/login/login.php', __('UI|UX Settings', 'bulletproof-security'), __('UI|UX Settings', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/theme-skin/theme-skin.php' );
	add_submenu_page('bulletproof-security/admin/login/login.php', __('Whats New ~ New Features in BPS Pro and General Help Info', 'bulletproof-security'), __('Whats New', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/whatsnew/whatsnew.php' );
	
		} else {

	add_menu_page(__('BulletProof Pro Security Settings', 'bulletproof-security'), __('BPS Pro', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/core/core.php', '', plugins_url('bulletproof-security/admin/images/bps-icon-small.png'));
	add_submenu_page('bulletproof-security/admin/core/core.php', __('B-Core ~ BPS Pro htaccess Core', 'bulletproof-security'), __('B-Core', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/core/core.php' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('P-Security ~ BPS Pro php.ini Security and Performance', 'bulletproof-security'), __('P-Security', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/php/php-options.php' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('S-Monitor ~ BPS Pro Security Monitor and Alerting', 'bulletproof-security'), __('S-Monitor', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/monitor/monitor.php' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('Pro-Tools ~ BPS Pro Tools', 'bulletproof-security'), __('Pro-Tools', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/tools/tools.php' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('AutoRestore ~ BPS Pro Automatic File Restore', 'bulletproof-security'), __('AutoRestore', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/autorestore/autorestore.php' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('Quarantine ~ BPS Pro Automatic File Quarantine', 'bulletproof-security'), __('Quarantine', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/quarantine/quarantine.php' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('MScan ~ Malware Scanner', 'bulletproof-security'), __('MScan', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/mscan/mscan.php' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('B-Core ~ BPS Pro htaccess Core', 'bulletproof-security'), __('Plugin Firewall', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/core/core.php#PFWScan-Menu-Link' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('B-Core ~ BPS Pro htaccess Core', 'bulletproof-security'), __('Uploads Anti-Exploit Guard (UAEG)', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/core/core.php#UAEG-Menu-Link' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('Login Security ~ JTC ~ ISL ~ ACE', 'bulletproof-security'), __('Login Security', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/login/login.php' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('Login Security ~ JTC ~ ISL ~ ACE', 'bulletproof-security'), __('JTC Anti-Spam<br>Anti-Hacker', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/login/login.php#bps-tabs-2' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('Login Security ~ JTC ~ ISL ~ ACE', 'bulletproof-security'), __('Idle Session Logout<br>Cookie Expiration', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/login/login.php#bps-tabs-3' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('DB Backup', 'bulletproof-security'), __('DB Backup', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/db-backup-security/db-backup-security.php' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('DB Monitor', 'bulletproof-security'), __('DB Monitor', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/db-monitor/db-monitor.php' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('B-Core ~ BPS Pro htaccess Core', 'bulletproof-security'), __('htaccess File Editor', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-6' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('B-Core ~ BPS Pro htaccess Core', 'bulletproof-security'), __('Custom Code', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-7' );
	add_submenu_page('bulletproof-security/admin/core/core.php', __('F-Lock ~ File ~ Folder ~ Lock', 'bulletproof-security'), __('F-Lock', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/lock/flock.php' );

	// Do not display the Maintenance Mode menu for GDMW hosted sites
	$GDMW_options = get_option('bulletproof_security_options_GDMW');
	if ( isset( $GDMW_options['bps_gdmw_hosting'] ) && $GDMW_options['bps_gdmw_hosting'] != 'yes' ) {
	add_submenu_page('bulletproof-security/admin/core/core.php', __('Maintenance Mode', 'bulletproof-security'), __('Maintenance Mode', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/maintenance/maintenance.php' );
	}

	add_menu_page(__('Logs & Info', 'bulletproof-security'), __('Logs & Info', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/security-log/security-log.php', '', plugins_url('bulletproof-security/admin/images/bps-icon-small.png'));	
	add_submenu_page('bulletproof-security/admin/security-log/security-log.php', __('Security Log', 'bulletproof-security'), __('Security Log', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/security-log/security-log.php' );
	add_submenu_page('bulletproof-security/admin/security-log/security-log.php', __('P-Security ~ BPS Pro php.ini Security and Performance', 'bulletproof-security'), __('PHP Error Log', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/php/php-options.php#bps-tabs-5' );
	add_submenu_page('bulletproof-security/admin/security-log/security-log.php', __('Quarantine ~ BPS Pro Automatic File Quarantine', 'bulletproof-security'), __('Quarantine Log', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/quarantine/quarantine.php#bps-tabs-2' );	
	add_submenu_page('bulletproof-security/admin/security-log/security-log.php', __('MScan Log', 'bulletproof-security'), __('MScan Log', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/mscan/mscan.php#bps-tabs-2' );	
	add_submenu_page('bulletproof-security/admin/security-log/security-log.php', __('DB Backup', 'bulletproof-security'), __('DB Backup Log', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/db-backup-security/db-backup-security.php#bps-tabs-2' );
	add_submenu_page('bulletproof-security/admin/security-log/security-log.php', __('DB Monitor', 'bulletproof-security'), __('DB Monitor Log', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/db-monitor/db-monitor.php#bps-tabs-2' );	
	add_submenu_page('bulletproof-security/admin/security-log/security-log.php', __('System Info', 'bulletproof-security'), __('System Info', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/system-info/system-info.php' );
	add_submenu_page('bulletproof-security/admin/security-log/security-log.php', __('P-Security ~ BPS Pro php.ini Security and Performance', 'bulletproof-security'), __('PHP Info', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/php/php-options.php#bps-tabs-6' );
	add_submenu_page('bulletproof-security/admin/security-log/security-log.php', __('DB Monitor', 'bulletproof-security'), __('DB Status & Info', 'bulletproof-security'), 'manage_options', 'admin.php?page=bulletproof-security/admin/db-monitor/db-monitor.php#bps-tabs-4' );		
	add_submenu_page('bulletproof-security/admin/security-log/security-log.php', __('Whats New ~ New Features in BPS Pro and General Help Info', 'bulletproof-security'), __('Whats New', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/whatsnew/whatsnew.php' );
	
	// Setup Menu
	add_menu_page(__('Setup', 'bulletproof-security'), __('Setup', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/wizard/wizard.php', '', plugins_url('bulletproof-security/admin/images/bps-icon-small.png'));
	add_submenu_page('bulletproof-security/admin/wizard/wizard.php', __('Setup Wizard', 'bulletproof-security'), __('Setup Wizard', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/wizard/wizard.php' );
	add_submenu_page('bulletproof-security/admin/wizard/wizard.php', __('Activation', 'bulletproof-security'), __('Activation', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/activation/activation.php' );
	add_submenu_page('bulletproof-security/admin/wizard/wizard.php', __('Upload Zip Install', 'bulletproof-security'), __('Upload Zip Install', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/install/installation.php' );
	add_submenu_page('bulletproof-security/admin/wizard/wizard.php', __('UI|UX Settings', 'bulletproof-security'), __('UI|UX Settings', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/theme-skin/theme-skin.php' );	
	// MScan Scan Status Page: hidden submenu. Necessary to avoid the "you don't have permission to view this page" error message.
	add_submenu_page( null, __('MScan Scan Status', 'bulletproof-security'), __('', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/mscan/mscan-scan-status.php' );
	
	// Dev Testing page
	//add_submenu_page('bulletproof-security/admin/wizard/wizard.php', __('Dev Testing', 'bulletproof-security'), __('Dev Testing', 'bulletproof-security'), 'manage_options', 'bulletproof-security/admin/test/ux.php' );	
	}
	}
}

$bpsPro_SLF_options = get_option('bulletproof_security_options_SLF');

if ( isset($bpsPro_SLF_options['bps_slf_filter']) && $bpsPro_SLF_options['bps_slf_filter'] == 'On' ) {

	if ( is_admin() && preg_match( '/page=bulletproof-security/', esc_html($_SERVER['REQUEST_URI']), $matches ) ) {

	add_filter( 'style_loader_tag', 'bpsPro_style_loader_filter' );
	add_filter( 'script_loader_tag', 'bpsPro_script_loader_filter' );
	
	}
}

// Prevents other plugin and theme Styles from loading in BPS plugin pages
// Notes: $tag is a string and not an array. This is a quick and dirty way to strip out all rogue styles/scripts + optimum performance.
// 11.9: Added Debug option
// 14: Modified SLF filter code.
// 14.7: Whitelist the Query Monitor plugin js and CSS scripts in BPS plugin pages. script & style name: query-monitor.
function bpsPro_style_loader_filter($tag) {

	if ( preg_match( '/page=bulletproof-security/', esc_html($_SERVER['REQUEST_URI']), $matches) ) {

		$topDiv = '<div id="message" class="updated" style="background-color:#dfecf2;border:1px solid #999;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';

		$Debug_options = get_option('bulletproof_security_options_debug');
		$matches = '';

		if ( ! strpos( $tag, 'bulletproof-security' ) && ! strpos( $tag, 'wp-admin' ) && ! strpos( $tag, 'wp-includes' ) && ! strpos( $tag, 'query-monitor' ) )

			unset($tag);
			$tag = ! isset($tag) ? '' : $tag;			
			
			if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' ) {
			
				if ( preg_match( '/\/(plugins|themes)\/.*\.css/', $tag, $matches ) ) {
			
					echo $topDiv;
					echo '<font color="blue"><strong>'.__('BPS Pro UI|UX Debug: SLF: CSS Script Loaded', 'bulletproof-security').'</strong></font><br>';
					print_r($matches[0]);
					echo '</p></div>';
				}
			}	
		return $tag;
	}
}

// Prevents other plugin and theme Scripts from loading in BPS plugin pages
// Notes: $tag is a string and not an array. This is a quick and dirty way to strip out all rogue scripts.
// 11.9: Added Debug option
// 14: Modified SLF filter code.
// 14.7: Whitelist the Query Monitor plugin js and CSS scripts in BPS plugin pages. script & style name: query-monitor.
function bpsPro_script_loader_filter($tag) {

	if ( preg_match( '/page=bulletproof-security/', esc_html($_SERVER['REQUEST_URI']), $matches) ) {
		
		$topDiv = '<div id="message" class="updated" style="background-color:#dfecf2;border:1px solid #999;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';
		
		$Debug_options = get_option('bulletproof_security_options_debug');
		$matches = '';
		
		if ( ! strpos( $tag, 'bulletproof-security' ) && ! strpos( $tag, 'wp-admin' ) && ! strpos( $tag, 'wp-includes' ) && ! strpos( $tag, 'query-monitor' ) )

			unset($tag);
			$tag = ! isset($tag) ? '' : $tag;
			
			if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' ) {
			
				if ( preg_match( '/\/(plugins|themes)\/.*\.js/', $tag, $matches ) ) {
					
					echo $topDiv;
					echo '<font color="blue"><strong>'.__('BPS Pro UI|UX Debug: SLF: js Script Loaded', 'bulletproof-security').'</strong></font><br>';
					print_r($matches[0]);
					echo '</p></div>';
				}
			}	
		return $tag;
	}
}

add_action( 'admin_enqueue_scripts', 'bpsPro_register_enqueue_scripts_styles' );

// Register scripts and styles, Enqueue scripts and styles, Dequeue any plugin or theme scripts and styles loading in BPS plugin pages
// 11.9: BugFix: script handles & dependencies code was fubar. Added: ver Query Strings * load scripts in footer * Debug option
// 13.2: Remove all version compare conditions for >= 3.8. Minimum WP version required is now WP 3.8.
// 14: Encryption/Decryption added to evade/bypass the Mod Security CRS ruleset, which breaks numerous Forms throughout BPS Pro.
// 14.7: Whitelist the Query Monitor plugin js and CSS scripts in BPS plugin pages. script & style name: query-monitor.
function bpsPro_register_enqueue_scripts_styles() {
global $wp_scripts, $wp_styles, $bulletproof_security, $wp_version, $bpspro_version;

	// Register and Load the BPS ARQ Automation Ajax script sitewide
	wp_register_script( 'bps-arq-ajax', plugins_url( '/bulletproof-security/admin/js/bps-arq-ajax.js' ), array( 'jquery' ), $bpspro_version, true );
	wp_enqueue_script( 'bps-arq-ajax' );
	wp_localize_script( 'bps-arq-ajax', 'bps_arq_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );

	// Register & Load BPS scripts and styles on BPS plugin pages ONLY
	if ( preg_match( '/page=bulletproof-security/', esc_html($_SERVER['REQUEST_URI']), $matches) ) {

		$UIoptions = get_option('bulletproof_security_options_theme_skin');
		$Debug_options = get_option('bulletproof_security_options_debug');

		// Register BPS Scripts
		wp_register_script('bps-tabs', plugins_url( '/bulletproof-security/admin/js/bps-ui-tabs.js' ), array( 'jquery', 'jquery-ui-tabs' ), $bpspro_version, true );
		wp_register_script('bps-dialog', plugins_url( '/bulletproof-security/admin/js/bps-ui-dialog.js' ), array( 'jquery', 'jquery-ui-dialog', 'jquery-effects-core', 'jquery-effects-blind', 'jquery-effects-explode' ), $bpspro_version, true );	
		wp_register_script('bps-accordion', plugins_url( '/bulletproof-security/admin/js/bps-ui-accordion.js' ), array( 'jquery', 'jquery-ui-accordion' ), $bpspro_version, true );
		## 14: Encryption js scripts added
		wp_register_script('bps-encryption', plugins_url( '/bulletproof-security/admin/js/bps-encryption.js' ), '', $bpspro_version, true );
		wp_register_script('bps-crypto-js', plugins_url( '/bulletproof-security/admin/js/crypto-js/crypto-js.js' ), '', $bpspro_version, true );	

		// Register BPS Styles
		switch ( isset($UIoptions['bps_ui_theme_skin']) && $UIoptions['bps_ui_theme_skin'] ) {
    		case 'blue':
				wp_register_style('bps-css-38', plugins_url('/bulletproof-security/admin/css/bps-blue-ui-theme.css'), array(), $bpspro_version, 'all' );
			break;
    		case 'grey':
				wp_register_style('bps-css-38', plugins_url('/bulletproof-security/admin/css/bps-grey-ui-theme.css'), array(), $bpspro_version, 'all' );
			break;
    		case 'black':
				wp_register_style('bps-css-38', plugins_url('/bulletproof-security/admin/css/bps-black-ui-theme.css'), array(), $bpspro_version, 'all' );
			break;
			default: 		
				wp_register_style('bps-css-38', plugins_url('/bulletproof-security/admin/css/bps-blue-ui-theme.css'), array(), $bpspro_version, 'all' );		
		}

		// Enqueue BPS scripts & script dependencies
		wp_enqueue_script( 'bps-tabs' );
		wp_enqueue_script( 'bps-dialog' );
		wp_enqueue_script( 'bps-accordion' );
		wp_enqueue_script( 'bps-encryption' );
		wp_enqueue_script( 'bps-crypto-js' );

		// Enqueue BPS stylesheets
		switch ( isset($UIoptions['bps_ui_theme_skin']) && $UIoptions['bps_ui_theme_skin'] ) {
    		case 'blue':
				wp_enqueue_style('bps-css-38');
			break;
    		case 'grey':
				wp_enqueue_style('bps-css-38');
			break;
    		case 'black':
				wp_enqueue_style('bps-css-38');
			break;
			default: 		
				wp_enqueue_style('bps-css-38');	
		}

		// Dequeue any other plugin or theme scripts that should not be loading on BPS plugin pages
		$script_handles = array( 'bps-arq-ajax', 'bps-mscan-ajax', 'bps-tabs', 'bps-dialog', 'bps-accordion', 'bps-encryption', 'bps-crypto-js', 'admin-bar', 'jquery', 'jquery-ui-core', 'jquery-ui-tabs', 'jquery-ui-dialog', 'jquery-ui-widget', 'jquery-ui-mouse', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position', 'jquery-ui-accordion', 'jquery-effects-core', 'jquery-effects-blind', 'jquery-effects-explode', 'common', 'utils', 'svg-painter', 'wp-auth-check', 'heartbeat', 'debug-bar', 'wp-polyfill', 'wp-i18n', 'hoverintent-js', 'wp-hooks', 'query-monitor' );
		
		$style_handles = array( 'bps-css', 'bps-css-38', 'admin-bar', 'colors', 'ie', 'wp-auth-check', 'debug-bar', 'query-monitor' );
		
		if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' ) {
			echo '<div id="message" class="updated" style="background-color:#dfecf2;border:1px solid #999;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';
			echo '<font color="blue"><strong>'.__('BPS Pro UI|UX Debug: RESS: Scripts|Styles Dequeued', 'bulletproof-security').'</strong></font><br>';
		}

			$NSCD = 0;
			
			foreach( $wp_scripts->queue as $handle ) {
				
				if ( ! in_array( $handle, $script_handles ) ) {
					wp_dequeue_script( $handle );
				
					if ( $Debug_options['bps_debug'] == 'On' ) {
						$NSCD = 1;
						echo '<strong>'.__('Script Dequeued: ', 'bulletproof-security') . '</strong>' . $handle . '<br>';
					}
				}
			}
		
			if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' && 0 == $NSCD ) {
				echo '<strong>'.__('No additional plugin or theme Scripts were found that needed to be Dequeued.', 'bulletproof-security') . '</strong><br>';
			}
			
			$NSTD = 0;

			foreach( $wp_styles->queue as $handle ) {
        	
				if ( ! in_array( $handle, $style_handles ) ) {
					wp_dequeue_style( $handle );
				
					if ( $Debug_options['bps_debug'] == 'On' ) {
						$NSTD = 1;
						echo '<strong>'.__('Style Dequeued: ', 'bulletproof-security') . '</strong>' . $handle . '<br>';
					}					
				}
			}	
			
			if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' && 0 == $NSTD ) {			
				echo '<strong>'.__('No additional plugin or theme Styles were found that needed to be Dequeued.', 'bulletproof-security') . '</strong><br>';
			}
		
		if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' ) {
			echo '</p></div>';
		}	
	}
}

$bpspro_url = 'https://api.ait-pro.com/';

add_action( 'wp_before_admin_bar_render', 'bpsPro_remove_non_wp_nodes_from_toolbar' );

// Removes any/all additional WP Toolbar nodes / menu items added by other plugins and themes
// in BPS plugin pages ONLY. Does NOT remove any of the default WP Toolbar nodes.
// Note: This file is loaded in the WP Dashboard. This function is ONLY processed in BPS plugin pages.
// 11.9: Added Debug option
function bpsPro_remove_non_wp_nodes_from_toolbar() {
	
	if ( preg_match( '/page=bulletproof-security/', esc_html($_SERVER['REQUEST_URI']), $matches ) ) {
	
		$UIWPToptions = get_option('bulletproof_security_options_wpt_nodes');
	
		if ( isset($UIWPToptions['bps_wpt_nodes']) && $UIWPToptions['bps_wpt_nodes'] != 'allnodes' ) {
			
			global $wp_admin_bar;
			$all_toolbar_nodes = $wp_admin_bar->get_nodes();
			$Debug_options = get_option('bulletproof_security_options_debug');
			$WPTB = 0;

			$topDiv = '<div id="message" class="updated" style="background-color:#dfecf2;border:1px solid #999;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';

			if ( $all_toolbar_nodes ) {
		
				if ( ! is_multisite() ) {
				
					$wp_default_nodes = array( 'user-actions', 'user-info', 'edit-profile', 'logout', 'menu-toggle', 'my-account', 'wp-logo', 'about', 'wporg', 'documentation', 'support-forums', 'feedback', 'site-name', 'view-site', 'updates', 'comments', 'new-content', 'new-post', 'new-media', 'new-page', 'new-user', 'top-secondary', 'wp-logo-external' );
				
					if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' ) {
						echo $topDiv;
						echo '<font color="blue"><strong>'.__('BPS Pro UI|UX Debug: WP Toolbar nodes|menu items Removed', 'bulletproof-security').'</strong></font><br>';
					}

					foreach ( $all_toolbar_nodes as $node ) {
						// For Testing: echo '<br>'; print_r($node->id); 
					
						if ( ! in_array( $node->id, $wp_default_nodes ) ) {
							$wp_admin_bar->remove_node( $node->id );
								
							if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' ) {
								
								$WPTB = 1;
								echo '<strong>'.__('WP Toolbar node|menu item Removed: ', 'bulletproof-security') . '</strong>';
								print_r($node->id);
								echo '<br>';
							}
						}
					}				
					
					if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' && 0 == $WPTB ) {
						echo '<strong>'.__('No WP Toolbar nodes|menu items were Removed in BPS plugin pages', 'bulletproof-security') . '</strong><br>';
					}
			
					if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' ) {
						echo '</p></div>';
					}

				} else {
				
					$wp_default_nodes = array( 'user-actions', 'user-info', 'edit-profile', 'logout', 'menu-toggle', 'my-account', 'wp-logo', 'about', 'wporg', 'documentation', 'support-forums', 'feedback', 'site-name', 'view-site', 'updates', 'comments', 'new-content', 'new-post', 'new-media', 'new-page', 'new-user', 'top-secondary', 'wp-logo-external', 'my-sites', 'my-sites-super-admin', 'network-admin', 'network-admin-d', 'network-admin-s', 'network-admin-u', 'network-admin-t', 'network-admin-p', 'my-sites-list', 'edit-site' );
				
					if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' ) {
						echo $topDiv;
						echo '<font color="blue"><strong>'.__('BPS Pro UI|UX Debug: WP Toolbar nodes|menu items Removed', 'bulletproof-security').'</strong></font><br>';
					}

					foreach ( $all_toolbar_nodes as $node ) {
						// For Testing: echo '<br>'; print_r($node->id); 
					
						if ( ! in_array( $node->id, $wp_default_nodes ) && ! preg_match( '/blog-[0-9]/', $node->id, $matches ) ) {
							$wp_admin_bar->remove_node( $node->id );	
						
							if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' ) {
								
								$WPTB = 1;
								echo '<strong>'.__('WP Toolbar node|menu item Removed: ', 'bulletproof-security') . '</strong>';
								print_r($node->id);
								echo '<br>';
							}						
						}
					}
					
					if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' && 0 == $WPTB ) {
						echo '<strong>'.__('No WP Toolbar nodes|menu items were Removed in BPS plugin pages', 'bulletproof-security') . '</strong><br>';
					}
			
					if ( isset($Debug_options['bps_debug']) && $Debug_options['bps_debug'] == 'On' ) {
						echo '</p></div>';
					}				
				}
			}
		}
	}
}

// Create Backup folder with randomly generated folder name and update DB with folder name
function bpsPro_create_db_backup_folder() {
$options = get_option('bulletproof_security_options_db_backup');

	if ( isset($options['bps_db_backup_folder']) && $options['bps_db_backup_folder'] != '' && is_dir( $options['bps_db_backup_folder'] ) || isset($_POST['Submit-DBB-Reset']) && @$_POST['Submit-DBB-Reset'] == true ) {
		return;	
	}
	
	$source = WP_CONTENT_DIR . '/bps-backup';

	if ( is_dir($source) ) {
		
		$iterator = new DirectoryIterator($source);
			
		foreach ( $iterator as $folder ) {
			if ( $folder->isDir() && !$folder->isDot() && preg_match( '/backups_[a-zA-Z0-9]/', $folder ) ) {
				return;
			}
		}
				
		$str = '1234567890abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
		$folder_obs = substr( str_shuffle($str), 0, 15 );
		@mkdir( WP_CONTENT_DIR . '/bps-backup/backups_' . $folder_obs, 0755, true );
		@chmod( WP_CONTENT_DIR . '/bps-backup/backups_' . $folder_obs . '/', 0755 );
				
		@mkdir( WP_CONTENT_DIR . '/bps-backup/backups_' . $folder_obs . '/db-diff', 0755, true );
		@chmod( WP_CONTENT_DIR . '/bps-backup/backups_' . $folder_obs . '/db-diff/', 0755 );

		$dbb_options = 'bulletproof_security_options_db_backup';
		$bps_db_backup_folder = addslashes( WP_CONTENT_DIR . '/bps-backup/backups_' . $folder_obs );
		//$bps_db_backup_download_link = ( WP_CONTENT_DIR . '/bps-backup/backups_' . $folder_obs );
		$bps_db_backup_download_link = content_url( '/bps-backup/backups_' ) . $folder_obs . '/';
		
		$DBB_Options = array(
		'bps_db_backup' 						=> 'On', 
		'bps_db_backup_description' 			=> '', 
		'bps_db_backup_folder' 					=> $bps_db_backup_folder, 
		'bps_db_backup_download_link' 			=> $bps_db_backup_download_link, 
		'bps_db_backup_job_type' 				=> '', 
		'bps_db_backup_frequency' 				=> '', 		 
		'bps_db_backup_start_time_hour' 		=> '', 
		'bps_db_backup_start_time_weekday' 		=> '', 
		'bps_db_backup_start_time_month_date' 	=> '', 
		'bps_db_backup_email_zip' 				=> '', 
		'bps_db_backup_delete' 					=> '', 
		'bps_db_backup_status_display' 			=> 'No DB Backups' 
		);	
	
		if ( ! get_option( $dbb_options ) ) {	
		
			foreach( $DBB_Options as $key => $value ) {
				update_option('bulletproof_security_options_db_backup', $DBB_Options);
			}
			
		} else {

			foreach( $DBB_Options as $key => $value ) {
				update_option('bulletproof_security_options_db_backup', $DBB_Options);
			}	
		}			
	}
}

// Automatically delete the Pro-Tools B64 Decoder/Encoder files
function bpsPro_delete_b64_tools() {
$options = get_option('bulletproof_security_options_b64_tools');  
$bps_b64_online_decoder = WP_PLUGIN_DIR . '/bulletproof-security/admin/tools/b64-online-decoder.php';	
$bps_b64_offline_decoder = WP_PLUGIN_DIR . '/bulletproof-security/admin/tools/b64-offline-decoder.php';	

	if ( isset( $options['bps_b64_offline_decoder'] ) && $options['bps_b64_offline_decoder'] == 'delete' && file_exists($bps_b64_offline_decoder) ) {
		unlink($bps_b64_offline_decoder);	
	}
	
	if ( isset( $options['bps_b64_online_decoder'] ) && $options['bps_b64_online_decoder'] == 'delete' && file_exists($bps_b64_online_decoder) ) {
		unlink($bps_b64_online_decoder);	
	}
}

function bulletproof_security_install() {
global $bulletproof_security, $bpspro_version;
$previous_install = get_option('bulletproof_security_options');
	
	if ( $previous_install ) {
	if ( version_compare($previous_install['version'], $bpspro_version, '<') )
		delete_transient( 'bulletproof-security_info' );
	}
}

// On BPS Plugin Deactivation: remove/unschedule all scheduled Cron jobs: 14 total
// note: add new crons to scheduled crons pro-tool
function bulletproof_security_deactivation() {
	wp_clear_scheduled_hook('bpsPro_DBB_check');	
	wp_clear_scheduled_hook('bpsPro_php_elog_check');
	wp_clear_scheduled_hook('bpsPro_update_check');
	wp_clear_scheduled_hook('bpsPro_email_log_files');	
	wp_clear_scheduled_hook('bpsPro_PFWAP_check');	
	wp_clear_scheduled_hook('bpsPro_DBM_check');
	wp_clear_scheduled_hook('bpsPro_security_log_check');	
	wp_clear_scheduled_hook('bpsPro_AutoRestore_check');
	wp_clear_scheduled_hook('bpsPro_ARQ_OBFD');
	wp_clear_scheduled_hook('bpsPro_FolderLock_check');
	wp_clear_scheduled_hook('bpsPro_ARQ_Off_check');
	wp_clear_scheduled_hook('bpsPro_HPF_check');
	wp_clear_scheduled_hook('bpsPro_AFS_check');
	wp_clear_scheduled_hook('bpsPro_MScan_check');
	wp_clear_scheduled_hook('bpsPro_plugin_updates_cron');
	wp_clear_scheduled_hook('bpsPro_theme_updates_cron');

	$ARQoptions = get_option('bulletproof_security_options_ARCM');

	$BPS_Options = array(
	'bps_autorestore_cron_frequency' 	=> $ARQoptions['bps_autorestore_cron_frequency'], 
	'bps_autorestore_cron' 				=> 'Off', 
	'bps_autorestore_cron_override' 	=> $ARQoptions['bps_autorestore_cron_override'], 
	'bps_autorestore_cron_filecheck' 	=> $ARQoptions['bps_autorestore_cron_filecheck'], 
	'bps_autorestore_cron_forced' 		=> $ARQoptions['bps_autorestore_cron_forced'], 
	'bps_autorestore_cron_end' 			=> $ARQoptions['bps_autorestore_cron_end']
	);	

	foreach( $BPS_Options as $key => $value ) {
		update_option('bulletproof_security_options_ARCM', $BPS_Options);
	}
	
	// Reset MScan Status to: 4. ie a page reload looping problem.
	$MScan_status = get_option('bulletproof_security_options_MScan_status');

	$MScan_status_db = array( 
	'bps_mscan_time_start' 					=> $MScan_status['bps_mscan_time_start'], 
	'bps_mscan_time_stop' 					=> $MScan_status['bps_mscan_time_stop'], 
	'bps_mscan_time_end' 					=> $MScan_status['bps_mscan_time_end'], 
	'bps_mscan_time_remaining' 				=> $MScan_status['bps_mscan_time_remaining'], 
	'bps_mscan_status' 						=> '4', 
	'bps_mscan_last_scan_timestamp' 		=> $MScan_status['bps_mscan_last_scan_timestamp'], 
	'bps_mscan_total_time' 					=> $MScan_status['bps_mscan_total_time'], 
	'bps_mscan_total_website_files' 		=> '', 
	'bps_mscan_total_wp_core_files' 		=> $MScan_status['bps_mscan_total_wp_core_files'], 
	'bps_mscan_total_non_image_files' 		=> $MScan_status['bps_mscan_total_non_image_files'], 
	'bps_mscan_total_image_files' 			=> '', 
	'bps_mscan_total_all_scannable_files' 	=> $MScan_status['bps_mscan_total_all_scannable_files'], 
	'bps_mscan_total_skipped_files' 		=> $MScan_status['bps_mscan_total_skipped_files'], 
	'bps_mscan_total_suspect_files' 		=> $MScan_status['bps_mscan_total_suspect_files'], 
	'bps_mscan_suspect_skipped_files' 		=> $MScan_status['bps_mscan_suspect_skipped_files'], 
	'bps_mscan_total_suspect_db' 			=> $MScan_status['bps_mscan_total_suspect_db'], 
	'bps_mscan_total_ignored_files' 		=> $MScan_status['bps_mscan_total_ignored_files'],
	'bps_mscan_total_plugin_files' 			=> $MScan_status['bps_mscan_total_plugin_files'], 			 
	'bps_mscan_total_theme_files' 			=> $MScan_status['bps_mscan_total_theme_files'] 
	);		
		
	foreach( $MScan_status_db as $key => $value ) {
		update_option('bulletproof_security_options_MScan_status', $MScan_status_db);
	}	
}

// BPS Pro Uninstall Multisite: Get domain
function bpsPro_network_domain_check_uninstall() {
	global $wpdb;
	if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) )
		return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
	return false;
}

// BPS Pro Uninstall Multisite: Get basedomain
function bpsPro_get_clean_basedomain_uninstall() {
	if ( $existing_domain = bpsPro_network_domain_check_uninstall() )
		return $existing_domain;
	$domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
	if ( $slash = strpos( $domain, '/' ) )
		$domain = substr( $domain, 0, $slash );
	return $domain;
}

// BPS Pro Uninstall Multisite: Get root folder
function bps_wp_get_root_folder_uninstall() {
	if ( is_admin() && current_user_can('manage_options') ) {
		$site_root = parse_url(get_option('siteurl'));
	if ( isset( $site_root['path'] ) )
		$site_root = trailingslashit($site_root['path']);
	else
		$site_root = '/';
	return $site_root;
	}
}

// BPS Pro Uninstall Multisite: Create the default WP htaccess file for Multisite
function bpsPro_default_wp_htaccess_file_multisite() {
global $bpspro_version;

	if ( is_multisite() ) {
		
	$bps_get_wp_root_default = bps_wp_get_root_folder_uninstall();	
	
	$hostname          = bpsPro_get_clean_basedomain_uninstall();
	$slashed_home      = trailingslashit( get_option( 'home' ) );
	$base              = parse_url( $slashed_home, PHP_URL_PATH );
	$document_root_fix = str_replace( '\\', '/', realpath( $_SERVER['DOCUMENT_ROOT'] ) );
	$abspath_fix       = str_replace( '\\', '/', ABSPATH );
	$home_path         = 0 === strpos( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
	$wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix );
	$rewrite_base      = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
	$subdomain_install = is_subdomain_install();
	$subdir_match          = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?';
	$subdir_replacement_01 = $subdomain_install ? '' : '$1';
	$subdir_replacement_12 = $subdomain_install ? '$1' : '$2';
		
	$ms_files_rewriting = '';
	if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
		$ms_files_rewriting = "\n# uploaded files\nRewriteRule ^";
		$ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}wp-includes/ms-files.php?file={$subdir_replacement_12} [L]" . "\n";
	}

$bps_default_content_top = "# BEGIN WordPress
# The directives (lines) between \"BEGIN WordPress\" and \"END WordPress\" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.\n";

$bpsMUSDirTop = "<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase $bps_get_wp_root_default
RewriteRule ^index\.php$ - [L]\n
{$ms_files_rewriting}
# add a trailing slash to /wp-admin
RewriteRule ^{$subdir_match}wp-admin$ {$subdir_replacement_01}wp-admin/ [R=301,L]\n\n";

$bpsMUSDirBottom = "RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^{$subdir_match}(wp-(content|admin|includes).*) {$rewrite_base}{$subdir_replacement_12} [L]
RewriteRule ^{$subdir_match}(.*\.php)$ {$rewrite_base}$subdir_replacement_12 [L]
RewriteRule . index.php [L]
</IfModule>\n
# END WordPress\n";

		$bps_auto_write_default_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/default.htaccess';
		$bps_root_htaccess_file = ABSPATH . '.htaccess';
		
		if ( file_exists( $bps_auto_write_default_file ) ) {
			copy($bps_auto_write_default_file, $bps_root_htaccess_file);
			$stringReplace = file_get_contents($bps_root_htaccess_file);
			$stringReplace = $bps_default_content_top.$bpsMUSDirTop.$bpsMUSDirBottom;
		
			if ( file_put_contents( $bps_root_htaccess_file, $stringReplace ) ) {

			}
		}
	}
}

// Root and wp-admin .htaccess files are backed up to the /bps-backup folder before deleting them.
// The only thing that is left behind is the /bps-backup folder, which requires manual deletion.
function bulletproof_security_uninstall() {
global $wpdb, $current_user;
$user_id = $current_user->ID;

require_once ABSPATH . 'wp-admin/includes/plugin.php';

$Atable_name = $wpdb->prefix . "bpspro_arq_add";
$Qtable_name = $wpdb->prefix . "bpspro_arq_quarantine";
$Etable_name = $wpdb->prefix . "bpspro_arq_exclude";
$Ptable_name = $wpdb->prefix . "bpspro_pfw_override";
$Stable_name = $wpdb->prefix . "bpspro_seclog_ignore";
$Ltable_name = $wpdb->prefix . "bpspro_login_security";
$DMtable_name = $wpdb->prefix . "bpspro_dbm_monitor";
$DBBtable_name = $wpdb->prefix . "bpspro_db_backup";
$FLtable_name = $wpdb->prefix . "bpspro_folder_lock";
$MStable_name = $wpdb->prefix . "bpspro_mscan";
$bps_Uploads_Dir = wp_upload_dir();
$UploadsHtaccess = $bps_Uploads_Dir['basedir'] . '/.htaccess'; // for both single and Multisite is the standard /uploads folder
$PluginsHtaccess = WP_PLUGIN_DIR . '/.htaccess';
$RootHtaccess = ABSPATH . '.htaccess';
$RootHtaccessBackup = WP_CONTENT_DIR . '/bps-backup/master-backups/root.htaccess';
$wpadminHtaccess = ABSPATH . 'wp-admin/.htaccess';
$wpadminHtaccessBackup = WP_CONTENT_DIR . '/bps-backup/master-backups/wpadmin.htaccess';
$BPS_MU_tools = WP_CONTENT_DIR . '/mu-plugins/bps-pro-mu-tools.php';
//$options = get_option('bulletproof_security_options');

	if ( file_exists($RootHtaccess) ) {
		copy($RootHtaccess, $RootHtaccessBackup);
	}
	if ( file_exists($wpadminHtaccess) ) {
		copy($wpadminHtaccess, $wpadminHtaccessBackup);
	}

	delete_option('bulletproof_security_options');
	delete_option('bulletproof_security_options2');
	delete_option('bulletproof_security_options_elog');
	delete_option('bulletproof_security_options_iniSet');
	delete_option('bulletproof_security_options_ARCM_log');
	delete_option('bulletproof_security_options_ARCM');
	delete_option('bulletproof_security_options_flock');
	delete_option('bulletproof_security_options_exclude_folder');	
	delete_option('bulletproof_security_options_customcode');
	delete_option('bulletproof_security_options_customcode_WPA');
	delete_option('bulletproof_security_options_maint');
	delete_option('bulletproof_security_options_maint_mode');
	delete_option('bulletproof_security_options_mynotes');
	delete_option('bulletproof_security_options_activation');
	delete_option('bulletproof_security_options_monitor');
	delete_option('bulletproof_security_options_email');
	delete_option('bulletproof_security_options_autolock');
	delete_option('bulletproof_security_options_pfw');
	delete_option('bulletproof_security_options_pfirewall');
	delete_option('bulletproof_security_options_pfirewall_roles');
	delete_option('bulletproof_security_options_pfirewall_allow');
	delete_option('bulletproof_security_options_pfirewall_TMode');
	delete_option('bulletproof_security_options_Security_log');
	delete_option('bulletproof_security_options_login_security');
	delete_option('bulletproof_security_options_login_alerts');
	delete_option('bulletproof_security_options_preinstallation');
	delete_option('bulletproof_security_options_setup_wizard_flock');
	delete_option('bulletproof_security_options_upgrade_notice');	
	delete_option('bulletproof_security_arq_db_version');
	delete_option('bulletproof_security_options_login_security_jtc'); 
	delete_option('bulletproof_security_options_wp_version');  
	delete_option('bulletproof_security_options_wp_autoupdate');
	delete_option('bulletproof_security_options_upgrade_email');
	delete_option('bulletproof_security_options_theme_skin');
	delete_option('bulletproof_security_options_db_backup');
	delete_option('bulletproof_security_options_db_monitor');
	delete_option('bulletproof_security_options_DBM_log');
	delete_option('bulletproof_security_options_DBB_log');
	delete_option('bulletproof_security_options_wizard_curl');
	delete_option('bulletproof_security_options_pfirewall_plugins');  
	delete_option('bulletproof_security_options_GMT');
	delete_option('bulletproof_security_options_htaccess_res'); 
	delete_option('bulletproof_security_options_net_correction');
	delete_option('bulletproof_security_options_GDMW');
	delete_option('bulletproof_security_options_b64_tools');
	delete_option('bulletproof_security_options_pfw_autopilot');
	delete_option('bulletproof_security_options_spinner');
	delete_option('bulletproof_security_options_wpt_nodes');
	delete_option('bulletproof_security_options_ARQ_upgrade');
	delete_option('bulletproof_security_options_xternal_tools');
	delete_option('bulletproof_security_options_wizard_free');
	delete_option('bulletproof_security_options_idle_session'); 	
	delete_option('bulletproof_security_options_auth_cookie'); 
	delete_option('bulletproof_security_options_SLF'); 
	delete_option('bulletproof_security_options_scrolltop');
	delete_option('bulletproof_security_options_apache_modules');  
	delete_option('bulletproof_security_options_sec_log_post_limit'); 
	delete_option('bulletproof_security_options_customcode_UAEG');
	delete_option('bulletproof_security_options_flock_FL_alerts');
	delete_option('bulletproof_security_options_flock_FL');
	delete_option('bulletproof_security_options_htaccess_files');
	delete_option('bulletproof_security_options_debug');	
	delete_option('bulletproof_security_options_hidden_plugins');
	delete_option('bulletproof_security_options_hpf_cron');
	delete_option('bulletproof_security_options_zip_fix');
	delete_option('bulletproof_security_options_ARQ_status');
	delete_option('bulletproof_security_options_setup_wizard_woo');
	delete_option('bulletproof_security_options_MU_tools');
	delete_option('bulletproof_security_options_pfw_test_mode');
	delete_option('bulletproof_security_options_wizard_autofix');
	delete_option('bulletproof_security_options_MScan_log');
	delete_option('bulletproof_security_options_MScan_status');
	delete_option('bulletproof_security_options_MScan');
	delete_option('bulletproof_security_options_rate_pro');
	delete_option('bulletproof_security_options_mod_security');
	delete_option('bulletproof_security_options_vcheck');
	delete_option('bulletproof_security_options_gdpr'); 
	delete_option('bulletproof_security_options_mu_sysinfo');
	delete_option('bulletproof_security_options_uaeg_version');
	delete_option('bulletproof_security_options_mu_wp_autoupdate');
	delete_option('bulletproof_security_options_pfw_new_install');
	delete_option('bulletproof_security_options_flock_eol');
	delete_option('bulletproof_security_options_php_memory_limit');
	delete_option('bulletproof_security_options_fsp');
	delete_option('bulletproof_security_options_mscan_plugin_hash');
	delete_option('bulletproof_security_options_mscan_p_hash_new');
	delete_option('bulletproof_security_options_mscan_theme_hash');
	delete_option('bulletproof_security_options_mscan_t_hash_new');
	delete_option('bulletproof_security_options_mscan_patterns');
	delete_option('bulletproof_security_options_pop_uninstall');
	delete_option('bulletproof_security_options_mscan_nodownload');
	delete_option('bulletproof_security_options_new_feature'); 	
	delete_option('bulletproof_security_options_mscan_zip_upload'); 	
	delete_option('bulletproof_security_options_mscan_report');
	delete_option('bulletproof_security_options_arq_host_root'); 
	delete_option('bulletproof_security_options_arq_add_delete');
	delete_option('bulletproof_security_options_arq_add_hidden'); 
	delete_option('bulletproof_security_options_zip_filename'); 

	$wpdb->query("DROP TABLE IF EXISTS $Atable_name");
	$wpdb->query("DROP TABLE IF EXISTS $Qtable_name");
	$wpdb->query("DROP TABLE IF EXISTS $Etable_name");
	$wpdb->query("DROP TABLE IF EXISTS $Ptable_name");
	$wpdb->query("DROP TABLE IF EXISTS $Stable_name");
	$wpdb->query("DROP TABLE IF EXISTS $Ltable_name");
	$wpdb->query("DROP TABLE IF EXISTS $DMtable_name");
	$wpdb->query("DROP TABLE IF EXISTS $DBBtable_name");
	$wpdb->query("DROP TABLE IF EXISTS $FLtable_name");
	$wpdb->query("DROP TABLE IF EXISTS $MStable_name");	

	delete_user_meta($user_id, 'bps_ignore_new_feature_notice');
	delete_user_meta($user_id, 'bps_ignore_iis_notice');
	delete_user_meta($user_id, 'bps_ignore_public_username_notice');
	delete_user_meta($user_id, 'bps_ignore_PFW_roles_notice');
	delete_user_meta($user_id, 'bps_ignore_sucuri_notice');
	delete_user_meta($user_id, 'bps_ignore_BLC_notice');
	delete_user_meta($user_id, 'bps_ignore_PhpiniHandler_notice');
	delete_user_meta($user_id, 'bps_ignore_Permalinks_notice');
	delete_user_meta($user_id, 'bps_ignore_JTC_notice');
	delete_user_meta($user_id, 'bps_brute_force_login_protection_notice');
	delete_user_meta($user_id, 'bps_speed_boost_cache_notice');
	delete_user_meta($user_id, 'bps_xmlrpc_ddos_notice');
	delete_user_meta($user_id, 'bps_author_enumeration_notice');
	delete_user_meta($user_id, 'bps_hud_NetworkActivationAlert_notice');
	delete_user_meta($user_id, 'bps_ignore_wpfirewall2_notice');
	delete_user_meta($user_id, 'bpsPro_pfw_new_plugins_notice');
	delete_user_meta($user_id, 'bps_ignore_PFW_litespeed_notice');
	delete_user_meta($user_id, 'bps_referer_spam_notice');
	delete_user_meta($user_id, 'bps_sniff_driveby_notice');
	delete_user_meta($user_id, 'bps_iframe_clickjack_notice');
	delete_user_meta($user_id, 'bps_bonus_code_dismiss_all_notice');
	delete_user_meta($user_id, 'bps_post_request_attack_notice');
	delete_user_meta($user_id, 'bps_ignore_folder_lock_notice');	
	delete_user_meta($user_id, 'bps_ignore_jetpack_notice');
	delete_user_meta($user_id, 'bps_ignore_woocommerce_notice');
	delete_user_meta($user_id, 'bps_ignore_woocommerce_lsm_jtc_notice');
	delete_user_meta($user_id, 'bps_ignore_mscan_notice');
	delete_user_meta($user_id, 'bps_ignore_rate_notice');
	delete_user_meta($user_id, 'bpsPro_ignore_mod_security_notice');
	delete_user_meta($user_id, 'bpsPro_ignore_gdpr_compliance_notice');
	delete_user_meta($user_id, 'bps_ignore_root_version_check_notice');
	delete_user_meta($user_id, 'bpsPro_ignore_mu_wp_automatic_updates_notice');
	delete_user_meta($user_id, 'bpsPro_hud_EUM_plugin_check_notice');
	delete_user_meta($user_id, 'bpsPro_hud_new_feature_notice');

	@unlink($PluginsHtaccess);
	@unlink($UploadsHtaccess);
	@unlink($wpadminHtaccess);
	@unlink($BPS_MU_tools);
	
	if ( @unlink($RootHtaccess) || ! file_exists($RootHtaccess) ) {
		
		if ( is_multisite() ) {
			bpsPro_default_wp_htaccess_file_multisite();			
		} else {
			flush_rewrite_rules();
		}
	}
}

// P-Security File Manager 
function bulletproof_security_options_validate($input) {  
	$options = get_option('bulletproof_security_options');  
	$options['bpsinifiles_input_1'] = trim(wp_filter_nohtml_kses($input['bpsinifiles_input_1']));
	$options['bpsinifiles_input_2'] = trim(wp_filter_nohtml_kses($input['bpsinifiles_input_2']));
	$options['bpsinifiles_input_3'] = trim(wp_filter_nohtml_kses($input['bpsinifiles_input_3']));
	$options['bpsinifiles_input_4'] = trim(wp_filter_nohtml_kses($input['bpsinifiles_input_4']));
	$options['bpsinifiles_input_5'] = trim(wp_filter_nohtml_kses($input['bpsinifiles_input_5']));
	$options['bpsinifiles_input_6'] = trim(wp_filter_nohtml_kses($input['bpsinifiles_input_6']));
	$options['bpsinifiles_input_7'] = trim(wp_filter_nohtml_kses($input['bpsinifiles_input_7']));
	$options['bpsinifiles_input_8'] = trim(wp_filter_nohtml_kses($input['bpsinifiles_input_8']));
	$options['bpsinifiles_input_9'] = trim(wp_filter_nohtml_kses($input['bpsinifiles_input_9']));
	$options['bpsinifiles_input_10'] = trim(wp_filter_nohtml_kses($input['bpsinifiles_input_10']));
	$options['bpsinifiles_input_1_label'] = wp_filter_nohtml_kses($input['bpsinifiles_input_1_label']);
	$options['bpsinifiles_input_2_label'] = wp_filter_nohtml_kses($input['bpsinifiles_input_2_label']); 
	$options['bpsinifiles_input_3_label'] = wp_filter_nohtml_kses($input['bpsinifiles_input_3_label']); 
	$options['bpsinifiles_input_4_label'] = wp_filter_nohtml_kses($input['bpsinifiles_input_4_label']);
	$options['bpsinifiles_input_5_label'] = wp_filter_nohtml_kses($input['bpsinifiles_input_5_label']);
	$options['bpsinifiles_input_6_label'] = wp_filter_nohtml_kses($input['bpsinifiles_input_6_label']); 
	$options['bpsinifiles_input_7_label'] = wp_filter_nohtml_kses($input['bpsinifiles_input_7_label']); 
	$options['bpsinifiles_input_8_label'] = wp_filter_nohtml_kses($input['bpsinifiles_input_8_label']);
	$options['bpsinifiles_input_9_label'] = wp_filter_nohtml_kses($input['bpsinifiles_input_9_label']);
	$options['bpsinifiles_input_10_label'] = wp_filter_nohtml_kses($input['bpsinifiles_input_10_label']);
		
	return $options;  
}

// PHP Error Log Folder Location 
function bulletproof_security_options_validate2($input) {  
	$options = get_option('bulletproof_security_options2');  
	$options['bps_error_log_location'] = trim(wp_filter_nohtml_kses($input['bps_error_log_location']));
		
	return $options;  
}

// PHP Error Log Last Modified Time 
function bulletproof_security_options_validate_elog($input) {  
	$options = get_option('bulletproof_security_options_elog');  
	$options['bps_error_log_date_mod'] = wp_filter_nohtml_kses($input['bps_error_log_date_mod']);
		
	return $options;  
}

// Plugin Firewall: On|Off
function bulletproof_security_options_validate_pfw($input) {  
	$options = get_option('bulletproof_security_options_pfw');  
	$options['bps_pfw_on_off'] = wp_filter_nohtml_kses($input['bps_pfw_on_off']);
	
	return $options;  
}

// Plugin Firewall: core.php, wizard.php
function bulletproof_security_options_validate_pfirewall($input) {  
	$options = get_option('bulletproof_security_options_pfirewall');  
	$options['bps_pfw_paypal'] = wp_filter_nohtml_kses($input['bps_pfw_paypal']);
	$options['bps_pfw_google'] = wp_filter_nohtml_kses($input['bps_pfw_google']);		
	$options['bps_pfw_amazon'] = wp_filter_nohtml_kses($input['bps_pfw_amazon']);
	$options['bps_pfw_authorizenet'] = wp_filter_nohtml_kses($input['bps_pfw_authorizenet']);
	$options['bps_pfw_whitelist'] = wp_filter_nohtml_kses($input['bps_pfw_whitelist']);	
	
	return $options;  
}

// Plugin Firewall AutoPilot Mode: core.php, wizard.php
function bulletproof_security_options_validate_pfw_autopilot($input) {  
	$options = get_option('bulletproof_security_options_pfw_autopilot');  
	$options['bps_pfw_autopilot_cron'] = wp_filter_nohtml_kses($input['bps_pfw_autopilot_cron']);
	$options['bps_pfw_autopilot_cron_frequency'] = wp_filter_nohtml_kses($input['bps_pfw_autopilot_cron_frequency']);
	$options['bps_pfw_autopilot_cron_end'] = wp_filter_nohtml_kses($input['bps_pfw_autopilot_cron_end']);		
	
	return $options;  
}

// Plugin Firewall Test Mode: core.php
function bulletproof_security_options_validate_pfw_test_mode($input) {  
	$options = get_option('bulletproof_security_options_pfw_test_mode');  
	$options['bps_pfw_test_mode'] = wp_filter_nohtml_kses($input['bps_pfw_test_mode']);
	
	return $options;  
}

// Plugin Firewall Additional Roles IP Whitelist option
function bulletproof_security_options_validate_pfirewall_roles($input) {  
	$options = get_option('bulletproof_security_options_pfirewall_roles');  
	$options['bps_pfw_administrator'] = wp_filter_nohtml_kses($input['bps_pfw_administrator']);
	$options['bps_pfw_editor'] = wp_filter_nohtml_kses($input['bps_pfw_editor']);
	$options['bps_pfw_author'] = wp_filter_nohtml_kses($input['bps_pfw_author']);		
	$options['bps_pfw_contributor'] = wp_filter_nohtml_kses($input['bps_pfw_contributor']);
	$options['bps_pfw_roles_hidden'] = wp_filter_nohtml_kses($input['bps_pfw_roles_hidden']);
	@$options['bps_pfw_custom_roles'] = $input['bps_pfw_custom_roles'];

	return $options;  
}

// Plugin Firewall Whitelist by Hostname (domain name) and IP Address option
function bulletproof_security_options_validate_pfirewall_allow($input) {  
	$options = get_option('bulletproof_security_options_pfirewall_allow');  
	$options['bps_pfw_allow_from'] = wp_filter_nohtml_kses($input['bps_pfw_allow_from']);
	
	return $options;  
}

// Security Log Last Modified Time DB
function bulletproof_security_options_validate_Security_log($input) {  
	$options = get_option('bulletproof_security_options_Security_log');  
	$options['bps_security_log_date_mod'] = wp_filter_nohtml_kses($input['bps_security_log_date_mod']);
		
	return $options;  
}

// Security Log Limit POST Request Body Data
function bulletproof_security_options_validate_sec_log_post_limit($input) {  
	$options = get_option('bulletproof_security_options_sec_log_post_limit');  
	@$options['bps_security_log_post_limit'] = wp_filter_nohtml_kses($input['bps_security_log_post_limit']);
	@$options['bps_security_log_post_none'] = wp_filter_nohtml_kses($input['bps_security_log_post_none']);	
	@$options['bps_security_log_post_max'] = wp_filter_nohtml_kses($input['bps_security_log_post_max']);		

	return $options;  
}

// Root .htaccess file AutoLock 
function bulletproof_security_options_validate_autolock($input) {  
	$options = get_option('bulletproof_security_options_autolock');  
	$options['bps_root_htaccess_autolock'] = wp_filter_nohtml_kses($input['bps_root_htaccess_autolock']);
		
	return $options;  
}

// P-Security ini_set Options 
function bulletproof_security_options_validate_iniSet($input) {  
	$options = get_option('bulletproof_security_options_iniSet');  
	$options['bps_iniSet_ErrorReporting'] = wp_filter_nohtml_kses($input['bps_iniSet_ErrorReporting']);
	$options['bps_iniSet_LogErrors'] = wp_filter_nohtml_kses($input['bps_iniSet_LogErrors']);
	$options['bps_iniSet_ErrorLog'] = trim(wp_filter_nohtml_kses($input['bps_iniSet_ErrorLog']));
	$options['bps_iniSet_LogErrorsMaxLen'] = trim(wp_filter_nohtml_kses($input['bps_iniSet_LogErrorsMaxLen']));
	$options['bps_iniSet_MemoryLimit'] = trim(wp_filter_nohtml_kses($input['bps_iniSet_MemoryLimit']));
	$options['bps_iniSet_session_cookie_httponly'] = wp_filter_nohtml_kses($input['bps_iniSet_session_cookie_httponly']);	
	$options['bps_iniSet_session_use_only_cookies'] = wp_filter_nohtml_kses($input['bps_iniSet_session_use_only_cookies']);
	$options['bps_iniSet_session_cookie_secure'] = wp_filter_nohtml_kses($input['bps_iniSet_session_cookie_secure']);
	$options['bps_iniSet_IgnoreRepeatedErrors'] = wp_filter_nohtml_kses($input['bps_iniSet_IgnoreRepeatedErrors']);
	$options['bps_iniSet_IgnoreRepeatedSource'] = wp_filter_nohtml_kses($input['bps_iniSet_IgnoreRepeatedSource']);
	$options['bps_iniSet_AllowUrlInclude'] = wp_filter_nohtml_kses($input['bps_iniSet_AllowUrlInclude']);
	$options['bps_iniSet_DefineSyslogVar'] = wp_filter_nohtml_kses($input['bps_iniSet_DefineSyslogVar']);
	$options['bps_iniSet_DisplayErrors'] = wp_filter_nohtml_kses($input['bps_iniSet_DisplayErrors']);		
	$options['bps_iniSet_DisplayStartupErrors'] = wp_filter_nohtml_kses($input['bps_iniSet_DisplayStartupErrors']);	
	$options['bps_iniSet_ImplicitFlush'] = wp_filter_nohtml_kses($input['bps_iniSet_ImplicitFlush']);
	$options['bps_iniSet_MagicQuotesRuntime'] = wp_filter_nohtml_kses($input['bps_iniSet_MagicQuotesRuntime']);	
	$options['bps_iniSet_MaxExecutionTime'] = trim(wp_filter_nohtml_kses($input['bps_iniSet_MaxExecutionTime']));	
	$options['bps_iniSet_MysqlConnectTimeout'] = trim(wp_filter_nohtml_kses($input['bps_iniSet_MysqlConnectTimeout']));
	$options['bps_iniSet_MysqlTraceMode'] = wp_filter_nohtml_kses($input['bps_iniSet_MysqlTraceMode']);
	$options['bps_iniSet_ReportMemleaks'] = wp_filter_nohtml_kses($input['bps_iniSet_ReportMemleaks']);
		
	return $options;  
}

// AutoRestore Cron settings 
function bulletproof_security_options_validate_ARCM($input) {  
	$options = get_option('bulletproof_security_options_ARCM');  
	$options['bps_autorestore_cron'] = wp_filter_nohtml_kses($input['bps_autorestore_cron']);
	$options['bps_autorestore_cron_frequency'] = wp_filter_nohtml_kses($input['bps_autorestore_cron_frequency']);
	$options['bps_autorestore_cron_forced'] = wp_filter_nohtml_kses($input['bps_autorestore_cron_forced']);
	$options['bps_autorestore_cron_override'] = wp_filter_nohtml_kses($input['bps_autorestore_cron_override']);
	$options['bps_autorestore_cron_filecheck'] = wp_filter_nohtml_kses($input['bps_autorestore_cron_filecheck']);	
	$options['bps_autorestore_cron_end'] = wp_filter_nohtml_kses($input['bps_autorestore_cron_end']);
	
	return $options;
}

// ARQ Quarantine Log Last Modified Time DB
function bulletproof_security_options_validate_ARCM_log($input) {  
	$options = get_option('bulletproof_security_options_ARCM_log');  
	$options['bps_arcm_log_date_mod'] = wp_filter_nohtml_kses($input['bps_arcm_log_date_mod']);
		
	return $options;  
}

// ARQ various conditions for: AJAX, Shiny Updates, Manual & Bulk Updates & Automatic Updates
function bulletproof_security_options_validate_ARQ_upgrade($input) {  
	$options = get_option('bulletproof_security_options_ARQ_upgrade');  
	$options['bps_arq_upgrade'] = wp_filter_nohtml_kses($input['bps_arq_upgrade']);
	
	return $options;  
}

// ARQ Automation: upgrader_pre_install and upgrader_post_install filters check if ARQ is On or Off before update.
function bulletproof_security_options_validate_ARQ_status($input) {  
	$options = get_option('bulletproof_security_options_ARQ_status');  
	$options['bps_arq_status'] = wp_filter_nohtml_kses($input['bps_arq_status']);
	$options['bps_arq_status_timestamp'] = wp_filter_nohtml_kses($input['bps_arq_status_timestamp']);	

	return $options;  
}

// ARQ Exclude wp-content Folders 
function bulletproof_security_options_validate_exclude_folder($input) {  
	$options = get_option('bulletproof_security_options_exclude_folder');  
	$options['bpsexclude_input_1'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_1']));
	$options['bpsexclude_input_2'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_2']));
	$options['bpsexclude_input_3'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_3']));
	$options['bpsexclude_input_4'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_4']));
	$options['bpsexclude_input_5'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_5']));
	$options['bpsexclude_input_6'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_6']));
	$options['bpsexclude_input_7'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_7']));
	$options['bpsexclude_input_8'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_8']));
	$options['bpsexclude_input_9'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_9']));
	$options['bpsexclude_input_10'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_10']));
	$options['bpsexclude_input_11'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_11']));
	$options['bpsexclude_input_12'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_12']));
	$options['bpsexclude_input_13'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_13']));
	$options['bpsexclude_input_14'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_14']));
	$options['bpsexclude_input_15'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_15']));
	$options['bpsexclude_input_16'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_16']));
	$options['bpsexclude_input_17'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_17']));
	$options['bpsexclude_input_18'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_18']));
	$options['bpsexclude_input_19'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_19']));
	$options['bpsexclude_input_20'] = trim(wp_filter_nohtml_kses($input['bpsexclude_input_20']));
	$options['bpsexclude_input_1_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_1_label']);
	$options['bpsexclude_input_2_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_2_label']); 
	$options['bpsexclude_input_3_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_3_label']); 
	$options['bpsexclude_input_4_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_4_label']);
	$options['bpsexclude_input_5_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_5_label']);
	$options['bpsexclude_input_6_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_6_label']); 
	$options['bpsexclude_input_7_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_7_label']); 
	$options['bpsexclude_input_8_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_8_label']);
	$options['bpsexclude_input_9_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_9_label']);
	$options['bpsexclude_input_10_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_10_label']);
	$options['bpsexclude_input_11_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_11_label']);
	$options['bpsexclude_input_12_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_12_label']); 
	$options['bpsexclude_input_13_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_13_label']); 
	$options['bpsexclude_input_14_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_14_label']);
	$options['bpsexclude_input_15_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_15_label']);
	$options['bpsexclude_input_16_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_16_label']); 
	$options['bpsexclude_input_17_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_17_label']); 
	$options['bpsexclude_input_18_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_18_label']);
	$options['bpsexclude_input_19_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_19_label']);
	$options['bpsexclude_input_20_label'] = wp_filter_nohtml_kses($input['bpsexclude_input_20_label']);
		
	return $options;  
}

// 15.6: AutoRestore Add Folders & Files: Text box option to save the full path to the hosting account root folder.
function bulletproof_security_options_validate_arq_host_root($input) {  
	$options = get_option('bulletproof_security_options_arq_host_root');  
	$options['bps_arq_host_root_folder'] = esc_html($input['bps_arq_host_root_folder']);
	
	return $options;  
}

// 15.6: AutoRestore Add Folders & Files: Delete all Added Folders & Files and the AutoRestore Add DB table with 1 click.
function bulletproof_security_options_validate_arq_add_delete($input) {  
	$options = get_option('bulletproof_security_options_arq_add_delete');  
	$options['bps_arq_add_delete'] = esc_html($input['bps_arq_add_delete']);
	
	return $options;  
}

// 15.6: AutoRestore Add Folders & Files: Hidden DB option value. Used to check against in the ARQ Hud Dismiss Notice
// in cases where someone has previously Added Folders & Files. Also used in the arq-cron.php > bps_ARQ_addedFiles() function.
// The bps_ARQ_addedFiles() will exit the script if someone has not deleted and/or resaved Added Folders & Files.
// This DB option is saved/updated in these Forms: ARQ Add Folders & Files and Delete All Added Folders & Files.
function bulletproof_security_options_validate_arq_add_hidden($input) {  
	$options = get_option('bulletproof_security_options_arq_add_hidden');  
	$options['bps_arq_add_hidden'] = esc_html($input['bps_arq_add_hidden']);
	
	return $options;  
}

// Root Custom Code
function bulletproof_security_options_validate_customcode($input) {  
	$options = get_option('bulletproof_security_options_customcode');  
	// TOP PHP/PHP.INI HANDLER/CACHE CODE
	$options['bps_customcode_one'] = esc_html($input['bps_customcode_one']);
	$options['bps_customcode_server_signature'] = esc_html($input['bps_customcode_server_signature']);
	$options['bps_customcode_directory_index'] = esc_html($input['bps_customcode_directory_index']);
	// BRUTE FORCE LOGIN PAGE PROTECTION
	$options['bps_customcode_server_protocol'] = esc_html($input['bps_customcode_server_protocol']);	
	$options['bps_customcode_error_logging'] = esc_html($input['bps_customcode_error_logging']);
	$options['bps_customcode_deny_dot_folders'] = esc_html($input['bps_customcode_deny_dot_folders']);	
	$options['bps_customcode_admin_includes'] = esc_html($input['bps_customcode_admin_includes']);
	$options['bps_customcode_wp_rewrite_start'] = esc_html($input['bps_customcode_wp_rewrite_start']);
	$options['bps_customcode_request_methods'] = esc_html($input['bps_customcode_request_methods']);
	// PLUGIN/THEME SKIP/BYPASS RULES
	$options['bps_customcode_two'] = esc_html($input['bps_customcode_two']);
	$options['bps_customcode_timthumb_misc'] = esc_html($input['bps_customcode_timthumb_misc']);
	$options['bps_customcode_bpsqse'] = esc_html($input['bps_customcode_bpsqse']);
	if ( is_multisite() ) {
	$options['bps_customcode_wp_rewrite_end'] = esc_html($input['bps_customcode_wp_rewrite_end']);
	}
	$options['bps_customcode_deny_files'] = esc_html($input['bps_customcode_deny_files']);
	// BOTTOM HOTLINKING/FORBID COMMENT SPAMMERS/BLOCK BOTS/BLOCK IP/REDIRECT CODE
	$options['bps_customcode_three'] = esc_html($input['bps_customcode_three']);

	return $options;  
}

// wp-admin Custom Code
function bulletproof_security_options_validate_customcode_WPA($input) {  
	$options = get_option('bulletproof_security_options_customcode_WPA');  
	$options['bps_customcode_deny_files_wpa'] = esc_html($input['bps_customcode_deny_files_wpa']);
	$options['bps_customcode_one_wpa'] = esc_html($input['bps_customcode_one_wpa']);
	$options['bps_customcode_two_wpa'] = esc_html($input['bps_customcode_two_wpa']);
	$options['bps_customcode_bpsqse_wpa'] = esc_html($input['bps_customcode_bpsqse_wpa']);		
	
	return $options;  
}

// UAEG Custom Code
function bulletproof_security_options_validate_customcode_UAEG($input) {  
	$options = get_option('bulletproof_security_options_customcode_UAEG');  
	$options['bps_customcode_uaeg'] = esc_html($input['bps_customcode_uaeg']);
	
	return $options;  
}

// Maintenance Mode Form options
function bulletproof_security_options_validate_maint_mode($input) {  
	$options = get_option('bulletproof_security_options_maint_mode');  
	$options['bps_maint_on_off'] = wp_filter_nohtml_kses($input['bps_maint_on_off']);
	$options['bps_maint_countdown_timer'] = wp_filter_nohtml_kses($input['bps_maint_countdown_timer']);
	$options['bps_maint_countdown_timer_color'] = wp_filter_nohtml_kses($input['bps_maint_countdown_timer_color']);
	$options['bps_maint_time'] = wp_filter_nohtml_kses($input['bps_maint_time']);
	$options['bps_maint_retry_after'] = wp_filter_nohtml_kses($input['bps_maint_retry_after']);
	$options['bps_maint_frontend'] = wp_filter_nohtml_kses($input['bps_maint_frontend']);
	$options['bps_maint_backend'] = wp_filter_nohtml_kses($input['bps_maint_backend']);
	$options['bps_maint_ip_allowed'] = wp_filter_nohtml_kses($input['bps_maint_ip_allowed']);
	$options['bps_maint_text'] = esc_html($input['bps_maint_text']);
	$options['bps_maint_background_images'] = wp_filter_nohtml_kses($input['bps_maint_background_images']);
	$options['bps_maint_center_images'] = wp_filter_nohtml_kses($input['bps_maint_center_images']);
	$options['bps_maint_background_color'] = wp_filter_nohtml_kses($input['bps_maint_background_color']);
	$options['bps_maint_show_visitor_ip'] = wp_filter_nohtml_kses($input['bps_maint_show_visitor_ip']);
	$options['bps_maint_show_login_link'] = wp_filter_nohtml_kses($input['bps_maint_show_login_link']);
	$options['bps_maint_dashboard_reminder'] = wp_filter_nohtml_kses($input['bps_maint_dashboard_reminder']);	
	$options['bps_maint_log_visitors'] = wp_filter_nohtml_kses($input['bps_maint_log_visitors']);
	$options['bps_maint_countdown_email'] = wp_filter_nohtml_kses($input['bps_maint_countdown_email']);
	$options['bps_maint_email_to'] = trim(wp_filter_nohtml_kses($input['bps_maint_email_to']));
	$options['bps_maint_email_from'] = trim(wp_filter_nohtml_kses($input['bps_maint_email_from']));
	$options['bps_maint_email_cc'] = trim(wp_filter_nohtml_kses($input['bps_maint_email_cc']));
	$options['bps_maint_email_bcc'] = trim(wp_filter_nohtml_kses($input['bps_maint_email_bcc']));	
	$options['bps_maint_mu_entire_site'] = wp_filter_nohtml_kses($input['bps_maint_mu_entire_site']);
	$options['bps_maint_mu_subsites_only'] = wp_filter_nohtml_kses($input['bps_maint_mu_subsites_only']);
	
	return $options;  
}

// B-Core "My Notes" settings 
function bulletproof_security_options_validate_mynotes($input) {  
	$options = get_option('bulletproof_security_options_mynotes');  
	$options['bps_my_notes'] = esc_html($input['bps_my_notes']);
		
	return $options;  
}

// F-Lock File Lock settings 
function bulletproof_security_options_validate_flock($input) {  
	$options = get_option('bulletproof_security_options_flock');  
	$options['bps_lock_root_htaccess'] = wp_filter_nohtml_kses($input['bps_lock_root_htaccess']);
	$options['bps_lock_wpconfig'] = wp_filter_nohtml_kses($input['bps_lock_wpconfig']);
	$options['bps_lock_index_php'] = wp_filter_nohtml_kses($input['bps_lock_index_php']);
	$options['bps_lock_wpblog_header'] = wp_filter_nohtml_kses($input['bps_lock_wpblog_header']);
	$options['bps_lock_root_htaccess_dr'] = wp_filter_nohtml_kses($input['bps_lock_root_htaccess_dr']);
	$options['bps_lock_index_php_dr'] = wp_filter_nohtml_kses($input['bps_lock_index_php_dr']);
	$options['bps_lock_root_htaccess_gwiod'] = wp_filter_nohtml_kses($input['bps_lock_root_htaccess_gwiod']);
	$options['bps_lock_index_php_gwiod'] = wp_filter_nohtml_kses($input['bps_lock_index_php_gwiod']);
		
	return $options;  
}

// F-Lock File Lock - EOL|Retired. Allows someone to override all File Lock conditions to continue using File Lock.
function bulletproof_security_options_validate_flock_eol($input) {  
	$options = get_option('bulletproof_security_options_flock_eol');  
	$options['bps_file_lock_override'] = wp_filter_nohtml_kses($input['bps_file_lock_override']);
	$options['bps_file_lock_override_hidden'] = wp_filter_nohtml_kses($input['bps_file_lock_override_hidden']);	

	return $options;
}

// F-Lock Folder Lock Cron settings 
function bulletproof_security_options_validate_flock_FL($input) {  
	$options = get_option('bulletproof_security_options_flock_FL');  
	$options['bps_folder_lock_cron'] = wp_filter_nohtml_kses($input['bps_folder_lock_cron']);
	$options['bps_folder_lock_cron_frequency'] = wp_filter_nohtml_kses($input['bps_folder_lock_cron_frequency']);
	$options['bps_folder_lock_cron_end'] = wp_filter_nohtml_kses($input['bps_folder_lock_cron_end']);
	
	return $options;
}

// F-Lock Folder Lock Last Modified Time DB - Reset/Clear alerts
function bulletproof_security_options_validate_flock_FL_alerts($input) {  
	$options = get_option('bulletproof_security_options_flock_FL_alerts');  
	$options['bps_folderlock_db_mod_time'] = wp_filter_nohtml_kses($input['bps_folderlock_db_mod_time']);
		
	return $options;  
}

// Login Security & Monitoring
function bulletproof_security_options_validate_login_security($input) {  
	$BPSoptions = get_option('bulletproof_security_options_login_security');  
	$BPSoptions['bps_max_logins'] = trim(wp_filter_nohtml_kses($input['bps_max_logins']));
	$BPSoptions['bps_lockout_duration'] = trim(wp_filter_nohtml_kses($input['bps_lockout_duration']));
	$BPSoptions['bps_manual_lockout_duration'] = trim(wp_filter_nohtml_kses($input['bps_manual_lockout_duration']));
	$BPSoptions['bps_max_db_rows_display'] = trim(wp_filter_nohtml_kses($input['bps_max_db_rows_display']));
	$BPSoptions['bps_login_security_OnOff'] = wp_filter_nohtml_kses($input['bps_login_security_OnOff']);
	$BPSoptions['bps_login_security_logging'] = wp_filter_nohtml_kses($input['bps_login_security_logging']);
	$BPSoptions['bps_login_security_errors'] = wp_filter_nohtml_kses($input['bps_login_security_errors']);
	$BPSoptions['bps_login_security_remaining'] = wp_filter_nohtml_kses($input['bps_login_security_remaining']);
	$BPSoptions['bps_login_security_pw_reset'] = wp_filter_nohtml_kses($input['bps_login_security_pw_reset']);
	$BPSoptions['bps_login_security_sort'] = wp_filter_nohtml_kses($input['bps_login_security_sort']);
	@$BPSoptions['bps_enable_lsm_woocommerce'] = wp_filter_nohtml_kses($input['bps_enable_lsm_woocommerce']);

	return $BPSoptions;  
}

// Login Security Last Modified Time DB - Reset/Clear alerts
function bulletproof_security_options_validate_login_alerts($input) {  
	$LSAlertsoptions = get_option('bulletproof_security_options_login_alerts');  
	$LSAlertsoptions['bps_login_security_db_mod_time'] = wp_filter_nohtml_kses($input['bps_login_security_db_mod_time']);
		
	return $LSAlertsoptions;  
}

// JTC Anti-Spam|Anti-Hacker
function bulletproof_security_options_validate_login_security_jtc($input) {  
	$BPSoptionsJTC = get_option('bulletproof_security_options_login_security_jtc');  
	$BPSoptionsJTC['bps_tooltip_captcha_key'] = trim(wp_filter_nohtml_kses($input['bps_tooltip_captcha_key']));	
	$BPSoptionsJTC['bps_tooltip_captcha_hover_text'] = wp_filter_nohtml_kses($input['bps_tooltip_captcha_hover_text']);
	$BPSoptionsJTC['bps_tooltip_captcha_title'] = wp_filter_nohtml_kses($input['bps_tooltip_captcha_title']);	
	$BPSoptionsJTC['bps_tooltip_captcha_logging'] = wp_filter_nohtml_kses($input['bps_tooltip_captcha_logging']);		
	$BPSoptionsJTC['bps_jtc_login_form'] = wp_filter_nohtml_kses($input['bps_jtc_login_form']);
	$BPSoptionsJTC['bps_jtc_register_form'] = wp_filter_nohtml_kses($input['bps_jtc_register_form']);
	$BPSoptionsJTC['bps_jtc_lostpassword_form'] = wp_filter_nohtml_kses($input['bps_jtc_lostpassword_form']);
	$BPSoptionsJTC['bps_jtc_comment_form'] = wp_filter_nohtml_kses($input['bps_jtc_comment_form']);
	$BPSoptionsJTC['bps_jtc_mu_register_form'] = wp_filter_nohtml_kses($input['bps_jtc_mu_register_form']);
	$BPSoptionsJTC['bps_jtc_buddypress_register_form'] = wp_filter_nohtml_kses($input['bps_jtc_buddypress_register_form']);
	$BPSoptionsJTC['bps_jtc_buddypress_sidebar_form'] = wp_filter_nohtml_kses($input['bps_jtc_buddypress_sidebar_form']);
	$BPSoptionsJTC['bps_jtc_administrator'] = wp_filter_nohtml_kses($input['bps_jtc_administrator']);
	$BPSoptionsJTC['bps_jtc_editor'] = wp_filter_nohtml_kses($input['bps_jtc_editor']);
	$BPSoptionsJTC['bps_jtc_author'] = wp_filter_nohtml_kses($input['bps_jtc_author']);
	$BPSoptionsJTC['bps_jtc_contributor'] = wp_filter_nohtml_kses($input['bps_jtc_contributor']);
	$BPSoptionsJTC['bps_jtc_subscriber'] = wp_filter_nohtml_kses($input['bps_jtc_subscriber']);
	$BPSoptionsJTC['bps_jtc_comment_form_error'] = $input['bps_jtc_comment_form_error'];
	$BPSoptionsJTC['bps_jtc_comment_form_label'] = $input['bps_jtc_comment_form_label'];		
	$BPSoptionsJTC['bps_jtc_comment_form_input'] = $input['bps_jtc_comment_form_input'];	
	//$BPSoptionsJTC['bps_jtc_hide_ghost_text'] = wp_filter_nohtml_kses($input['bps_jtc_hide_ghost_text']);	
	// Note: You cannot use: wp_filter_nohtml_kses for multidimensional arrays - it will strip out the inner array code.
	@$BPSoptionsJTC['bps_jtc_custom_roles'] = $input['bps_jtc_custom_roles'];	
	$BPSoptionsJTC['bps_enable_jtc_woocommerce'] = wp_filter_nohtml_kses($input['bps_enable_jtc_woocommerce']);
	$BPSoptionsJTC['bps_jtc_custom_form_error'] = $input['bps_jtc_custom_form_error'];	

	return $BPSoptionsJTC;  
}

// Idle Session Logout (ISL): Do not automatically set ISL up. This should be left up to users to choose whether to use this or not.
function bulletproof_security_options_validate_idle_session($input) {  
	$options = get_option('bulletproof_security_options_idle_session');  
	$options['bps_isl'] = wp_filter_nohtml_kses($input['bps_isl']);
	$options['bps_isl_timeout'] = trim(wp_filter_nohtml_kses($input['bps_isl_timeout']));
	$options['bps_isl_logout_url'] = trim(wp_filter_nohtml_kses($input['bps_isl_logout_url']));	
	$options['bps_isl_login_url'] = trim(wp_filter_nohtml_kses($input['bps_isl_login_url']));
	@$options['bps_isl_custom_message'] = wp_filter_nohtml_kses($input['bps_isl_custom_message']);
	$options['bps_isl_custom_css_1'] = wp_filter_nohtml_kses($input['bps_isl_custom_css_1']);
	$options['bps_isl_custom_css_2'] = wp_filter_nohtml_kses($input['bps_isl_custom_css_2']);
	$options['bps_isl_custom_css_3'] = wp_filter_nohtml_kses($input['bps_isl_custom_css_3']);
	$options['bps_isl_custom_css_4'] = wp_filter_nohtml_kses($input['bps_isl_custom_css_4']);
	@$options['bps_isl_user_account_exceptions'] = wp_filter_nohtml_kses($input['bps_isl_user_account_exceptions']);
	@$options['bps_isl_administrator'] = wp_filter_nohtml_kses($input['bps_isl_administrator']);
	@$options['bps_isl_editor'] = wp_filter_nohtml_kses($input['bps_isl_editor']);
	@$options['bps_isl_author'] = wp_filter_nohtml_kses($input['bps_isl_author']);
	@$options['bps_isl_contributor'] = wp_filter_nohtml_kses($input['bps_isl_contributor']);
	@$options['bps_isl_subscriber'] = wp_filter_nohtml_kses($input['bps_isl_subscriber']);
	@$options['bps_isl_tinymce'] = wp_filter_nohtml_kses($input['bps_isl_tinymce']);
	@$options['bps_isl_uri_exclusions'] = wp_filter_nohtml_kses($input['bps_isl_uri_exclusions']);
	// Note: You cannot use: wp_filter_nohtml_kses for multidimensional arrays - it will strip out the inner array code.
	@$options['bps_isl_custom_roles'] = $input['bps_isl_custom_roles'];
	
	return $options;  
}

// Authentication Cookie Expiration (ACE): Do not automatically set ACE up. This should be left up to users to choose whether to use this or not.
function bulletproof_security_options_validate_auth_cookie($input) {  
	$options = get_option('bulletproof_security_options_auth_cookie');  
	$options['bps_ace'] = wp_filter_nohtml_kses($input['bps_ace']);
	$options['bps_ace_expiration'] = trim(wp_filter_nohtml_kses($input['bps_ace_expiration']));
	$options['bps_ace_rememberme_expiration'] = trim(wp_filter_nohtml_kses($input['bps_ace_rememberme_expiration']));
	@$options['bps_ace_user_account_exceptions'] = wp_filter_nohtml_kses($input['bps_ace_user_account_exceptions']);
	@$options['bps_ace_administrator'] = wp_filter_nohtml_kses($input['bps_ace_administrator']);
	@$options['bps_ace_editor'] = wp_filter_nohtml_kses($input['bps_ace_editor']);
	@$options['bps_ace_author'] = wp_filter_nohtml_kses($input['bps_ace_author']);
	@$options['bps_ace_contributor'] = wp_filter_nohtml_kses($input['bps_ace_contributor']);
	@$options['bps_ace_subscriber'] = wp_filter_nohtml_kses($input['bps_ace_subscriber']);
	@$options['bps_ace_rememberme_disable'] = wp_filter_nohtml_kses($input['bps_ace_rememberme_disable']);
	// Note: You cannot use: wp_filter_nohtml_kses for multidimensional arrays - it will strip out the inner array code.
	@$options['bps_ace_custom_roles'] = $input['bps_ace_custom_roles'];

	return $options;  
}

// BPS Pro Activation 
function bulletproof_security_options_validate_activation($input) {  
	$options = get_option('bulletproof_security_options_activation');  
	$options['bps_pro_activation'] = trim(wp_filter_nohtml_kses($input['bps_pro_activation']));
	$options['delete_paypal_email'] = trim(wp_filter_nohtml_kses($input['delete_paypal_email']));
	$options['bps_pro_key'] = trim(wp_filter_nohtml_kses($input['bps_pro_key']));
	$options['bps_api_key'] = trim(wp_filter_nohtml_kses($input['bps_api_key']));
	$options['bps_domain_url'] = wp_filter_nohtml_kses($input['bps_domain_url']);			

	return $options;  
}

// S-Monitor: Monitoring and Alerting Options & Dashboard Status Display
function bulletproof_security_options_validate_monitor($input) {  
	$options = get_option('bulletproof_security_options_monitor');  
	$options['bps_first_launch'] = wp_filter_nohtml_kses($input['bps_first_launch']);
	//$options['bps_upgrade_notice'] = wp_filter_nohtml_kses($input['bps_upgrade_notice']); // not used anymore
	$options['bps_security_status'] = wp_filter_nohtml_kses($input['bps_security_status']);
	$options['bps_HUD_alerts'] = wp_filter_nohtml_kses($input['bps_HUD_alerts']);
	$options['bps_PHP_ELogLoc_set'] = wp_filter_nohtml_kses($input['bps_PHP_ELogLoc_set']);
	$options['bps_PHP_ELog_error'] = wp_filter_nohtml_kses($input['bps_PHP_ELog_error']);
	$options['bps_phpini_created'] = wp_filter_nohtml_kses($input['bps_phpini_created']);
	$options['bps_flock_status'] = wp_filter_nohtml_kses($input['bps_flock_status']);
	$options['bps_autorestore_status'] = wp_filter_nohtml_kses($input['bps_autorestore_status']);
	$options['bps_autorestore_alerts'] = wp_filter_nohtml_kses($input['bps_autorestore_alerts']);
	$options['bps_plugin_firewall_status'] = wp_filter_nohtml_kses($input['bps_plugin_firewall_status']);
	$options['bps_UAEG_status'] = wp_filter_nohtml_kses($input['bps_UAEG_status']);
	$options['bps_SecLog_entry'] = wp_filter_nohtml_kses($input['bps_SecLog_entry']);
	$options['bps_login_security_status'] = wp_filter_nohtml_kses($input['bps_login_security_status']);
	$options['bps_login_security_alerts'] = wp_filter_nohtml_kses($input['bps_login_security_alerts']);			
	$options['bps_jtc_antispam_status'] = wp_filter_nohtml_kses($input['bps_jtc_antispam_status']);	
	$options['bps_dbm_status'] = wp_filter_nohtml_kses($input['bps_dbm_status']);
	$options['bps_dbm_alerts'] = wp_filter_nohtml_kses($input['bps_dbm_alerts']);
	$options['bps_dbb_status'] = wp_filter_nohtml_kses($input['bps_dbb_status']);
	$options['bps_flock_FL_alerts'] = wp_filter_nohtml_kses($input['bps_flock_FL_alerts']);
	$options['bps_isl_status'] = wp_filter_nohtml_kses($input['bps_isl_status']);
	$options['bps_ace_status'] = wp_filter_nohtml_kses($input['bps_ace_status']);
	$options['bps_mscan_status_display'] = wp_filter_nohtml_kses($input['bps_mscan_status_display']);

	return $options;  
}

// BPS Pro Upgrade Check email - maybe combine this into S-Monitor Email Alerts later or not
function bulletproof_security_options_validate_upgrade_email($input) {  
	$options = get_option('bulletproof_security_options_upgrade_email');  
	$options['bps_upgrade_check_email'] = wp_filter_nohtml_kses($input['bps_upgrade_check_email']);
			
	return $options;  
}

// S-Monitor Email Alerts / Email Log Files
function bulletproof_security_options_validate_email($input) {  
	$options = get_option('bulletproof_security_options_email');  
	//$options['bps_quarantine_email'] = wp_filter_nohtml_kses($input['bps_quarantine_email']);
	$options['bps_error_log_email'] = wp_filter_nohtml_kses($input['bps_error_log_email']);
	$options['bps_upgrade_email'] = wp_filter_nohtml_kses($input['bps_upgrade_email']);
	$options['bps_autorestore_email'] = wp_filter_nohtml_kses($input['bps_autorestore_email']);
	$options['bps_security_log_email'] = wp_filter_nohtml_kses($input['bps_security_log_email']);
	$options['bps_send_email_to'] = trim(wp_filter_nohtml_kses($input['bps_send_email_to']));
	$options['bps_send_email_from'] = trim(wp_filter_nohtml_kses($input['bps_send_email_from']));
	$options['bps_send_email_cc'] = trim(wp_filter_nohtml_kses($input['bps_send_email_cc']));
	$options['bps_send_email_bcc'] = trim(wp_filter_nohtml_kses($input['bps_send_email_bcc']));
	$options['bps_arq_log_size'] = wp_filter_nohtml_kses($input['bps_arq_log_size']);
	$options['bps_security_log_size'] = wp_filter_nohtml_kses($input['bps_security_log_size']);
	$options['bps_php_log_size'] = wp_filter_nohtml_kses($input['bps_php_log_size']);
	$options['bps_arq_log_email'] = wp_filter_nohtml_kses($input['bps_arq_log_email']);
	$options['bps_security_log_emailL'] = wp_filter_nohtml_kses($input['bps_security_log_emailL']);
	$options['bps_php_log_email'] = wp_filter_nohtml_kses($input['bps_php_log_email']);
	$options['bps_login_security_email'] = wp_filter_nohtml_kses($input['bps_login_security_email']);
	$options['bps_dbm_email'] = wp_filter_nohtml_kses($input['bps_dbm_email']);
	$options['bps_dbm_log_email'] = wp_filter_nohtml_kses($input['bps_dbm_log_email']);	
	$options['bps_dbm_log_size'] = wp_filter_nohtml_kses($input['bps_dbm_log_size']);
	//$options['bps_dbb_email'] = wp_filter_nohtml_kses($input['bps_dbb_email']); // unnecessary - handled in DB Backup itself
	$options['bps_dbb_log_email'] = wp_filter_nohtml_kses($input['bps_dbb_log_email']);	
	$options['bps_dbb_log_size'] = wp_filter_nohtml_kses($input['bps_dbb_log_size']);	
	$options['bps_flock_email'] = wp_filter_nohtml_kses($input['bps_flock_email']);	
	$options['bps_arq_cron_frequency_email'] = wp_filter_nohtml_kses($input['bps_arq_cron_frequency_email']);
	$options['bps_arq_cron_next_email'] = wp_filter_nohtml_kses($input['bps_arq_cron_next_email']);	
	$options['bps_hpf_email'] = wp_filter_nohtml_kses($input['bps_hpf_email']);	
	$options['bps_mscan_email'] = wp_filter_nohtml_kses($input['bps_mscan_email']);	
	$options['bps_mscan_log_size'] = wp_filter_nohtml_kses($input['bps_mscan_log_size']);
	$options['bps_mscan_log_email'] = wp_filter_nohtml_kses($input['bps_mscan_log_email']);	
	$options['bps_plugin_updates_frequency'] = wp_filter_nohtml_kses($input['bps_plugin_updates_frequency']);
	$options['bps_plugin_updates_email'] = wp_filter_nohtml_kses($input['bps_plugin_updates_email']);
	$options['bps_theme_updates_frequency'] = wp_filter_nohtml_kses($input['bps_theme_updates_frequency']);
	$options['bps_theme_updates_email'] = wp_filter_nohtml_kses($input['bps_theme_updates_email']);	

	return $options;  
}

// Setup Wizard Flock Checks 
function bulletproof_security_options_validate_setup_wizard_flock($input) {  
	$options = get_option('bulletproof_security_options_setup_wizard_flock');  
	$options['bps_wizard_root_htaccess_flock'] = wp_filter_nohtml_kses($input['bps_wizard_root_htaccess_flock']);
	$options['bps_wizard_wpconfig_flock'] = wp_filter_nohtml_kses($input['bps_wizard_wpconfig_flock']);
	$options['bps_wizard_index_flock'] = wp_filter_nohtml_kses($input['bps_wizard_index_flock']);
	$options['bps_wizard_wpblogheader_flock'] = wp_filter_nohtml_kses($input['bps_wizard_wpblogheader_flock']);
			
	return $options;  
}

// Setup Wizard Pre-Installation check 
function bulletproof_security_options_validate_preinstallation($input) {  
	$options = get_option('bulletproof_security_options_preinstallation');  
	$options['bps_wizard_preinstallation'] = wp_filter_nohtml_kses($input['bps_wizard_preinstallation']);
	$options['bps_wizard_preinstallation_61'] = wp_filter_nohtml_kses($input['bps_wizard_preinstallation_61']);			
	
	return $options;  
}

// Setup Wizard New BPS Pro Installations: Used in WooCommerce Dismiss Notice.
// New installations of BPS Pro should not display the WooCommerce Enable LSM & JTC options Dismiss Notice.
function bulletproof_security_options_validate_setup_wizard_woo($input) {  
	$options = get_option('bulletproof_security_options_setup_wizard_woo');  
	$options['bps_wizard_woo'] = wp_filter_nohtml_kses($input['bps_wizard_woo']);
	
	return $options;  
}

// Setup Wizard AutoFix On/Off: Automatically creates fixes/setups or whitelist rules for any known issues with other plugins.
function bulletproof_security_options_validate_wizard_autofix($input) {  
	$options = get_option('bulletproof_security_options_wizard_autofix');  
	$options['bps_wizard_autofix'] = wp_filter_nohtml_kses($input['bps_wizard_autofix']);
	
	return $options;  
}

// Setup Wizard cURL On/Off or home page scan ONLY & DB Monitor keep settings
function bulletproof_security_options_validate_wizard_curl($input) {  
	$options = get_option('bulletproof_security_options_wizard_curl');  
	$options['bps_wizard_curl_scan'] = wp_filter_nohtml_kses($input['bps_wizard_curl_scan']);
	$options['bps_wizard_dbm_settings'] = wp_filter_nohtml_kses($input['bps_wizard_dbm_settings']);	
	
	return $options;  
}

// Upgrade Notifications - New Features & Options - static
function bulletproof_security_options_validate_upgrade_notice($input) {  
	$options = get_option('bulletproof_security_options_upgrade_notice');  
	$options['bps_upgrade_notification_wizard'] = wp_filter_nohtml_kses($input['bps_upgrade_notification_wizard']);
			
	return $options;  
}

// New feature Dismiss Notice: Value is set on BPS upgrades and in the Wizard - This is ONLY used rarely for very important new features or options.
// If someone has upgraded BPS the value is: upgrade. If is a new BPS installation value is: new
// The Dismiss Notice is ONLY displayed to people who have upgraded BPS.
// I can add additional options later if needed.
function bulletproof_security_options_validate_new_feature($input) {  
	$options = get_option('bulletproof_security_options_new_feature');  
	$options['bps_mscan_rebuild'] = wp_filter_nohtml_kses($input['bps_mscan_rebuild']);
			
	return $options;  
}

// WP Automatic Update & manual update WordPress version Check
function bulletproof_security_options_validate_wp_version($input) {  
	$options = get_option('bulletproof_security_options_wp_version');  
	$options['bps_wp_version'] = wp_filter_nohtml_kses($input['bps_wp_version']);
	$options['bps_wp_version_last_modified_time'] = wp_filter_nohtml_kses($input['bps_wp_version_last_modified_time']);			
	
	return $options;  
}

// Pro-Tools WP Automatic Update - Pending Deletion
// The Automatic Update Pro-Tool has been removed. Automatic Update control is now in the BPS Pro MU Tools plugin.
// Delete this DB options at some point. Leave them for now.
function bulletproof_security_options_validate_wp_autoupdate($input) {  
	$options = get_option('bulletproof_security_options_wp_autoupdate');  
	$options['bps_WP_AUTO_UPDATE_CORE_false'] = wp_filter_nohtml_kses($input['bps_WP_AUTO_UPDATE_CORE_false']);
	$options['bps_WP_AUTO_UPDATE_CORE_true'] = wp_filter_nohtml_kses($input['bps_WP_AUTO_UPDATE_CORE_true']);
	$options['bps_WP_AUTO_UPDATE_CORE_minor'] = wp_filter_nohtml_kses($input['bps_WP_AUTO_UPDATE_CORE_minor']);
	$options['bps_AUTOMATIC_UPDATER_DISABLED_true'] = wp_filter_nohtml_kses($input['bps_AUTOMATIC_UPDATER_DISABLED_true']);
	$options['bps_AUTOMATIC_UPDATER_DISABLED_false'] = wp_filter_nohtml_kses($input['bps_AUTOMATIC_UPDATER_DISABLED_false']);
				
	return $options;  
}
// MU Tools: must-use file/plugin: bps-pro-mu-tools.php
// Enable|Disable WordPress Automatic Updates. Note: add_filter( 'automatic_updater_disabled', '__return_true' ); Disables all Automatic Updates: Core, Plugins and Themes.
function bulletproof_security_options_validate_mu_wp_autoupdate($input) {  
	$options = get_option('bulletproof_security_options_mu_wp_autoupdate');  
	$options['bps_automatic_updater_disabled'] = wp_filter_nohtml_kses($input['bps_automatic_updater_disabled']);
	$options['bps_auto_update_core_updates_disabled'] = wp_filter_nohtml_kses($input['bps_auto_update_core_updates_disabled']);
	$options['bps_auto_update_core'] = wp_filter_nohtml_kses($input['bps_auto_update_core']);
	$options['bps_allow_dev_auto_core_updates'] = wp_filter_nohtml_kses($input['bps_allow_dev_auto_core_updates']);
	$options['bps_allow_minor_auto_core_updates'] = wp_filter_nohtml_kses($input['bps_allow_minor_auto_core_updates']);
	$options['bps_allow_major_auto_core_updates'] = wp_filter_nohtml_kses($input['bps_allow_major_auto_core_updates']);
				
	return $options;  
}

// UI Theme Skin 
function bulletproof_security_options_validate_theme_skin($input) {  
	$options = get_option('bulletproof_security_options_theme_skin');  
	$options['bps_ui_theme_skin'] = wp_filter_nohtml_kses($input['bps_ui_theme_skin']);
			
	return $options;  
}

// DB Backup
function bulletproof_security_options_validate_db_backup($input) {  
	$options = get_option('bulletproof_security_options_db_backup');  
	$options['bps_db_backup'] = wp_filter_nohtml_kses($input['bps_db_backup']);
	$options['bps_db_backup_description'] = trim(wp_filter_nohtml_kses($input['bps_db_backup_description']));		
	$options['bps_db_backup_folder'] = trim(wp_filter_nohtml_kses($input['bps_db_backup_folder']));
	$options['bps_db_backup_download_link'] = trim(wp_filter_nohtml_kses($input['bps_db_backup_download_link']));				
	$options['bps_db_backup_job_type'] = wp_filter_nohtml_kses($input['bps_db_backup_job_type']);	
	$options['bps_db_backup_frequency'] = wp_filter_nohtml_kses($input['bps_db_backup_frequency']);	
	$options['bps_db_backup_start_time_hour'] = wp_filter_nohtml_kses($input['bps_db_backup_start_time_hour']);
	$options['bps_db_backup_start_time_weekday'] = wp_filter_nohtml_kses($input['bps_db_backup_start_time_weekday']);
	$options['bps_db_backup_start_time_month_date'] = wp_filter_nohtml_kses($input['bps_db_backup_start_time_month_date']);
	$options['bps_db_backup_email_zip'] = wp_filter_nohtml_kses($input['bps_db_backup_email_zip']);		
	$options['bps_db_backup_delete'] = wp_filter_nohtml_kses($input['bps_db_backup_delete']);		
	$options['bps_db_backup_status_display'] = wp_filter_nohtml_kses($input['bps_db_backup_status_display']); // hidden form option
	
	return $options;  
}

// DB Monitor Cron
function bulletproof_security_options_validate_db_monitor($input) {  
	$options = get_option('bulletproof_security_options_db_monitor');  
	$options['bps_db_monitor_cron'] = wp_filter_nohtml_kses($input['bps_db_monitor_cron']);
	$options['bps_db_monitor_cron_frequency'] = wp_filter_nohtml_kses($input['bps_db_monitor_cron_frequency']);
	$options['bps_db_monitor_cron_table_created_check'] = wp_filter_nohtml_kses($input['bps_db_monitor_cron_table_created_check']);	
	$options['bps_db_monitor_cron_end'] = wp_filter_nohtml_kses($input['bps_db_monitor_cron_end']);
	
	return $options;  
}

// DB Monitor Log Last Modified Time DB
function bulletproof_security_options_validate_DBM_log($input) {  
	$options = get_option('bulletproof_security_options_DBM_log');  
	$options['bps_dbm_log_date_mod'] = wp_filter_nohtml_kses($input['bps_dbm_log_date_mod']);
		
	return $options;  
}

// DB Backup Log Last Modified Time DB
function bulletproof_security_options_validate_DBB_log($input) {  
	$options = get_option('bulletproof_security_options_DBB_log');  
	$options['bps_dbb_log_date_mod'] = wp_filter_nohtml_kses($input['bps_dbb_log_date_mod']);
		
	return $options;  
}

// GMT timestamp option for synch function on upgrades
function bulletproof_security_options_validate_GMT($input) {  
	$options = get_option('bulletproof_security_options_GMT');  
	$options['bps_gmt_timestamp'] = wp_filter_nohtml_kses($input['bps_gmt_timestamp']);
		
	return $options;  
}

// Hosting that does not allow wp-admin .htaccess files - Go Daddy Managed WordPress hosting
function bulletproof_security_options_validate_htaccess_res($input) {  
	$options = get_option('bulletproof_security_options_htaccess_res');  
	$options['bps_wpadmin_restriction'] = wp_filter_nohtml_kses($input['bps_wpadmin_restriction']);
		
	return $options;  
}

// Setup Wizard Options: Go Daddy Managed WordPress hosting
function bulletproof_security_options_validate_GDMW($input) {  
	$options = get_option('bulletproof_security_options_GDMW');  
	$options['bps_gdmw_hosting'] = wp_filter_nohtml_kses($input['bps_gdmw_hosting']);
	
	return $options;  
}

// Pro-Tools Base64 Decoder/Encoder file/tools install and removal
function bulletproof_security_options_validate_b64_tools($input) {  
	$options = get_option('bulletproof_security_options_b64_tools');  
	$options['bps_b64_offline_decoder'] = wp_filter_nohtml_kses($input['bps_b64_offline_decoder']);
	$options['bps_b64_online_decoder'] = wp_filter_nohtml_kses($input['bps_b64_online_decoder']);	
	
	return $options;  
}

// Loading/Processing Spinner On/Off
function bulletproof_security_options_validate_spinner($input) {  
	$options = get_option('bulletproof_security_options_spinner');  
	$options['bps_spinner'] = wp_filter_nohtml_kses($input['bps_spinner']);
	
	return $options;  
}

// jQuery ScrollTop Animation On/Off
function bulletproof_security_options_validate_scrolltop($input) {  
	$options = get_option('bulletproof_security_options_scrolltop');  
	$options['bps_scrolltop'] = wp_filter_nohtml_kses($input['bps_scrolltop']);
	
	return $options;  
}

// WP Toolbar remove or allow all nodes
function bulletproof_security_options_validate_wpt_nodes($input) {  
	$options = get_option('bulletproof_security_options_wpt_nodes');  
	$options['bps_wpt_nodes'] = wp_filter_nohtml_kses($input['bps_wpt_nodes']);
	
	return $options;  
}

// Xternal Tools Page|Form: locked or unlocked
// 11.8: bps_xternal_tools_pfw is obsolete/not used
function bulletproof_security_options_validate_xternal_tools($input) {  
	$options = get_option('bulletproof_security_options_xternal_tools');  
	$options['bps_xternal_tools_form'] = wp_filter_nohtml_kses($input['bps_xternal_tools_form']);
	$options['bps_xternal_tools_pfw'] = wp_filter_nohtml_kses($input['bps_xternal_tools_pfw']);

	return $options;  
}

// Style|Script Loader Filter (SLF)
function bulletproof_security_options_validate_SLF($input) {  
	$options = get_option('bulletproof_security_options_SLF');  
	$options['bps_slf_filter'] = wp_filter_nohtml_kses($input['bps_slf_filter']);
	$options['bps_slf_filter_new'] = wp_filter_nohtml_kses($input['bps_slf_filter_new']);

	return $options;  
}

// Apache Modules IfModule condition: create IfModule conditions or just Order, Deny, Allow htaccess code
function bulletproof_security_options_validate_apache_modules($input) {  
	$options = get_option('bulletproof_security_options_apache_modules');  
	$options['bps_apache_mod_ifmodule'] = wp_filter_nohtml_kses($input['bps_apache_mod_ifmodule']);
	$options['bps_apache_mod_time'] = wp_filter_nohtml_kses($input['bps_apache_mod_time']);

	return $options;  
}

// Setup Wizard: Enable|Disable htaccess Files
// Based on Apache Module test results or manual setting: Servers that do no have either mod_access_compat and mod_authz_core or mod_rewrite Loaded
function bulletproof_security_options_validate_htaccess_files($input) {  
	$options = get_option('bulletproof_security_options_htaccess_files');  
	$options['bps_htaccess_files'] = wp_filter_nohtml_kses($input['bps_htaccess_files']);
		
	return $options;  
}

// UI|UX Debug: Displays scripts and styles dequeued|SLF scripts and styles nulled|WP Toolbar nodes|menu items that were Removed
function bulletproof_security_options_validate_debug($input) {  
	$options = get_option('bulletproof_security_options_debug');  
	$options['bps_debug'] = wp_filter_nohtml_kses($input['bps_debug']);
		
	return $options;  
}


// Hidden|Empty Plugin Folders|Files Cron: core.php, wizard.php
function bulletproof_security_options_validate_hpf_cron($input) {  
	$options = get_option('bulletproof_security_options_hpf_cron');  
	$options['bps_hidden_plugins_cron'] = wp_filter_nohtml_kses($input['bps_hidden_plugins_cron']);
	$options['bps_hidden_plugins_cron_frequency'] = wp_filter_nohtml_kses($input['bps_hidden_plugins_cron_frequency']);
	$options['bps_hidden_plugins_cron_email'] = wp_filter_nohtml_kses($input['bps_hidden_plugins_cron_email']);		
	$options['bps_hidden_plugins_cron_alert'] = wp_filter_nohtml_kses($input['bps_hidden_plugins_cron_alert']);		
	
	return $options;  
}

// Hidden|Empty Plugin Folders|Files: Check /plugins/ folder Hidden or Empty Plugin Folders & non-standard WP Files Check
// Textarea box to check against ignored folders and/or files.
function bulletproof_security_options_validate_hidden_plugins($input) {  
	$options = get_option('bulletproof_security_options_hidden_plugins');  
	$options['bps_hidden_plugins_check'] = wp_filter_nohtml_kses($input['bps_hidden_plugins_check']);
	
	return $options;  
}

// Setup Wizard Options: Zip File Download Fix (Incapsula, Proxy, Other Cause)
function bulletproof_security_options_validate_zip_fix($input) {  
	$options = get_option('bulletproof_security_options_zip_fix');  
	$options['bps_zip_download_fix'] = wp_filter_nohtml_kses($input['bps_zip_download_fix']);
	
	return $options;  
}

// MU Tools: must-use file: bps-pro-mu-tools.php
// timestamp to limit log writing and email alerts when the BPS plugin folder is renamed or deleted.
function bulletproof_security_options_validate_MU_tools($input) {  
	$options = get_option('bulletproof_security_options_MU_tools');  
	$options['bps_mu_tools_timestamp'] = wp_filter_nohtml_kses($input['bps_mu_tools_timestamp']);
	$options['bps_mu_tools_enable_disable'] = wp_filter_nohtml_kses($input['bps_mu_tools_enable_disable']);	
	
	return $options;  
}

// MScan Log Last Modified Time DB
function bulletproof_security_options_validate_MScan_log($input) {  
	$options = get_option('bulletproof_security_options_MScan_log');  
	$options['bps_mscan_log_date_mod'] = wp_filter_nohtml_kses($input['bps_mscan_log_date_mod']);
		
	return $options;  
}

// MScan Scan: time, file counts & other stats
// Note: Infected, Suspicious, skipped & ignored files can be outputted via a DB Query, but save these values statically as well
function bulletproof_security_options_validate_MScan_status($input) {  
	$options = get_option('bulletproof_security_options_MScan_status');  
	$options['bps_mscan_time_start'] = wp_filter_nohtml_kses($input['bps_mscan_time_start']);
	$options['bps_mscan_time_stop'] = wp_filter_nohtml_kses($input['bps_mscan_time_stop']);
	$options['bps_mscan_time_end'] = wp_filter_nohtml_kses($input['bps_mscan_time_end']);
	$options['bps_mscan_time_remaining'] = wp_filter_nohtml_kses($input['bps_mscan_time_remaining']);
	$options['bps_mscan_status'] = wp_filter_nohtml_kses($input['bps_mscan_status']);
	$options['bps_mscan_last_scan_timestamp'] = wp_filter_nohtml_kses($input['bps_mscan_last_scan_timestamp']);
	$options['bps_mscan_total_time'] = wp_filter_nohtml_kses($input['bps_mscan_total_time']);
	$options['bps_mscan_total_website_files'] = wp_filter_nohtml_kses($input['bps_mscan_total_website_files']);	
	$options['bps_mscan_total_wp_core_files'] = wp_filter_nohtml_kses($input['bps_mscan_total_wp_core_files']);
	$options['bps_mscan_total_non_image_files'] = wp_filter_nohtml_kses($input['bps_mscan_total_non_image_files']);
	$options['bps_mscan_total_image_files'] = wp_filter_nohtml_kses($input['bps_mscan_total_image_files']);
	$options['bps_mscan_total_all_scannable_files'] = wp_filter_nohtml_kses($input['bps_mscan_total_all_scannable_files']);
	$options['bps_mscan_total_skipped_files'] = wp_filter_nohtml_kses($input['bps_mscan_total_skipped_files']);
	$options['bps_mscan_total_suspect_files'] = wp_filter_nohtml_kses($input['bps_mscan_total_suspect_files']);
	@$options['bps_mscan_suspect_skipped_files'] = wp_filter_nohtml_kses($input['bps_mscan_suspect_skipped_files']);
	@$options['bps_mscan_total_suspect_db'] = wp_filter_nohtml_kses($input['bps_mscan_total_suspect_db']);	
	$options['bps_mscan_total_ignored_files'] = wp_filter_nohtml_kses($input['bps_mscan_total_ignored_files']);
	// 15.4: 2 new options added
	$options['bps_mscan_total_plugin_files'] = wp_filter_nohtml_kses($input['bps_mscan_total_plugin_files']);
	$options['bps_mscan_total_theme_files'] = wp_filter_nohtml_kses($input['bps_mscan_total_theme_files']);

	return $options;  
}

// MScan Scan Options: folders to scan, cron schedules, etc.
function bulletproof_security_options_validate_MScan($input) {  
	$options = get_option('bulletproof_security_options_MScan');  
	// Note: You cannot use: wp_filter_nohtml_kses for multidimensional arrays - it will strip out the inner array code.
	$options['bps_mscan_dirs'] = $input['bps_mscan_dirs'];
	$options['mscan_max_file_size'] = wp_filter_nohtml_kses($input['mscan_max_file_size']);		
	$options['mscan_max_time_limit'] = wp_filter_nohtml_kses($input['mscan_max_time_limit']);	
	$options['mscan_scan_database'] = wp_filter_nohtml_kses($input['mscan_scan_database']);
	$options['mscan_scan_images'] = wp_filter_nohtml_kses($input['mscan_scan_images']);
	$options['mscan_scan_skipped_files'] = wp_filter_nohtml_kses($input['mscan_scan_skipped_files']);
	$options['mscan_scan_delete_tmp_files'] = wp_filter_nohtml_kses($input['mscan_scan_delete_tmp_files']);
	$options['mscan_scan_frequency'] = wp_filter_nohtml_kses($input['mscan_scan_frequency']);	
	@$options['mscan_exclude_dirs'] = wp_filter_nohtml_kses($input['mscan_exclude_dirs']);
	@$options['mscan_exclude_tmp_files'] = wp_filter_nohtml_kses($input['mscan_exclude_tmp_files']);
	$options['mscan_file_size_limit_hidden'] = wp_filter_nohtml_kses($input['mscan_file_size_limit_hidden']);	
	
	return $options;  
}

// MScan Scan plugin hashes options: 2-D arrays: 
// Note: You cannot use: wp_filter_nohtml_kses for multidimensional arrays - it will strip out the inner array code.
function bulletproof_security_options_validate_mscan_plugin_hash($input) {  
	$options = get_option('bulletproof_security_options_mscan_plugin_hash');  
	$options['bps_mscan_plugin_hash_version_check'] = $input['bps_mscan_plugin_hash_version_check'];
	$options['bps_mscan_plugin_hash_paths'] = $input['bps_mscan_plugin_hash_paths'];
	$options['bps_mscan_plugin_hash_zip_file'] = $input['bps_mscan_plugin_hash_zip_file'];
	
	return $options;  
}

// MScan Scan plugin hashes options: 2-D arrays: 
// Notes: You cannot use: wp_filter_nohtml_kses for multidimensional arrays - it will strip out the inner array code.
// The WP delete_option() function only deletes strings due to trim(). So I need a separate DB option for the new arrays
// in order to delete this option so that new arrays for comparison are created/updated each time. Simpler is always better anyways.
function bulletproof_security_options_validate_mscan_p_hash_new($input) {  
	$options = get_option('bulletproof_security_options_mscan_p_hash_new');  
	$options['bps_mscan_plugin_hash_version_check_new'] = $input['bps_mscan_plugin_hash_version_check_new'];
	$options['bps_mscan_plugin_hash_paths_new'] = $input['bps_mscan_plugin_hash_paths_new'];
	$options['bps_mscan_plugin_hash_zip_file_new'] = $input['bps_mscan_plugin_hash_zip_file_new'];	
	
	return $options;  
}

// MScan Scan Theme hashes options: 2-D arrays: 
function bulletproof_security_options_validate_mscan_theme_hash($input) {  
	$options = get_option('bulletproof_security_options_mscan_theme_hash');  
	$options['bps_mscan_theme_hash_version_check'] = $input['bps_mscan_theme_hash_version_check'];
	$options['bps_mscan_theme_hash_paths'] = $input['bps_mscan_theme_hash_paths'];
	$options['bps_mscan_theme_hash_zip_file'] = $input['bps_mscan_theme_hash_zip_file'];
	
	return $options;  
}

// MScan Scan Theme hashes options: 2-D arrays: 
function bulletproof_security_options_validate_mscan_t_hash_new($input) {  
	$options = get_option('bulletproof_security_options_mscan_t_hash_new');  
	$options['bps_mscan_theme_hash_version_check_new'] = $input['bps_mscan_theme_hash_version_check_new'];
	$options['bps_mscan_theme_hash_paths_new'] = $input['bps_mscan_theme_hash_paths_new'];
	$options['bps_mscan_theme_hash_zip_file_new'] = $input['bps_mscan_theme_hash_zip_file_new'];	
	
	return $options;  
}

// MScan Scan file and db pattern matching options: 2-D arrays: 
function bulletproof_security_options_validate_mscan_patterns($input) {  
	$options = get_option('bulletproof_security_options_mscan_patterns');  
	$options['mscan_pattern_match_files'] = $input['mscan_pattern_match_files'];
	$options['mscan_pattern_match_db'] = $input['mscan_pattern_match_db'];
	
	return $options;  
}

// MScan: Plugins and Themes that are not downloadable from WP. ie premium/paid, custom plugins or no zip file version number.
function bulletproof_security_options_validate_mscan_nodownload($input) {  
	$options = get_option('bulletproof_security_options_mscan_nodownload');  
	$options['bps_plugin_nodownload'] = $input['bps_plugin_nodownload'];		
	$options['bps_theme_nodownload'] = $input['bps_theme_nodownload'];	

	return $options;  
}

// MScan Zip Upload Forms: Plugins and Themes that are not downloadable from WP. ie premium/paid, custom plugins or no zip file version number.
// Used in the MScan Report to check if these plugins and themes have file hashes or not.
function bulletproof_security_options_validate_mscan_zip_upload($input) {  
	$options = get_option('bulletproof_security_options_mscan_zip_upload');  
	$options['bps_mscan_plugin_zip_upload'] = $input['bps_mscan_plugin_zip_upload'];		
	$options['bps_mscan_theme_zip_upload'] = $input['bps_mscan_theme_zip_upload'];	

	return $options;  
}

// MScan Report: Multidimensional arrays for saving each MScan Report
// 20 saved scan reports max. Each report array needs to be a separate option so that it can be deleted easily.
function bulletproof_security_options_validate_mscan_report($input) {  
	$options = get_option('bulletproof_security_options_mscan_report');  
	$options['bps_mscan_report_data_1'] = $input['bps_mscan_report_data_1'];		
	$options['bps_mscan_report_data_2'] = $input['bps_mscan_report_data_2'];
	$options['bps_mscan_report_data_3'] = $input['bps_mscan_report_data_3'];		
	$options['bps_mscan_report_data_4'] = $input['bps_mscan_report_data_4'];
	$options['bps_mscan_report_data_5'] = $input['bps_mscan_report_data_5'];		
	$options['bps_mscan_report_data_6'] = $input['bps_mscan_report_data_6'];
	$options['bps_mscan_report_data_7'] = $input['bps_mscan_report_data_7'];		
	$options['bps_mscan_report_data_8'] = $input['bps_mscan_report_data_8'];
	$options['bps_mscan_report_data_9'] = $input['bps_mscan_report_data_9'];		
	$options['bps_mscan_report_data_10'] = $input['bps_mscan_report_data_10'];
	$options['bps_mscan_report_data_11'] = $input['bps_mscan_report_data_11'];		
	$options['bps_mscan_report_data_12'] = $input['bps_mscan_report_data_12'];
	$options['bps_mscan_report_data_13'] = $input['bps_mscan_report_data_13'];		
	$options['bps_mscan_report_data_14'] = $input['bps_mscan_report_data_14'];
	$options['bps_mscan_report_data_15'] = $input['bps_mscan_report_data_15'];		
	$options['bps_mscan_report_data_16'] = $input['bps_mscan_report_data_16'];
	$options['bps_mscan_report_data_17'] = $input['bps_mscan_report_data_17'];		
	$options['bps_mscan_report_data_18'] = $input['bps_mscan_report_data_18'];
	$options['bps_mscan_report_data_19'] = $input['bps_mscan_report_data_19'];		
	$options['bps_mscan_report_data_20'] = $input['bps_mscan_report_data_20'];
	
	return $options;  
}

// BPS Pro plugin 30 day review/rating request Dismiss Notice
function bulletproof_security_options_validate_rate_pro($input) {  
	$options = get_option('bulletproof_security_options_rate_pro');  
	$options['bps_pro_rate_review'] = wp_filter_nohtml_kses($input['bps_pro_rate_review']);		
	
	return $options;  
}

// Mod Security Check: function: bpsPro_apache_mod_directive_check() used in Mod Security Dismiss Notice
function bulletproof_security_options_validate_mod_security($input) {  
	$options = get_option('bulletproof_security_options_mod_security');  
	$options['bps_mod_security_check'] = wp_filter_nohtml_kses($input['bps_mod_security_check']);
	//$options['bps_mod_security2_check'] = wp_filter_nohtml_kses($input['bps_mod_security2_check']);
		
	return $options;  
}

// VCheck testing
function bulletproof_security_options_validate_vcheck($input) {  
	$options = get_option('bulletproof_security_options_vcheck');  
	$options['bps_vcheck'] = $input['bps_vcheck'];		
	
	return $options;  
}

// Setup Wizard Options: GDPR On|Off Setup Wizard Option
function bulletproof_security_options_validate_gdpr($input) {  
	$options = get_option('bulletproof_security_options_gdpr');  
	$options['bps_gdpr_on_off'] = $input['bps_gdpr_on_off'];		
	
	return $options;  
}

// Setup Wizard Options: Network|Multisite Hide|Display System Info page for Subsites
function bulletproof_security_options_validate_mu_sysinfo($input) {  
	$options = get_option('bulletproof_security_options_mu_sysinfo');  
	$options['bps_sysinfo_hide_display'] = $input['bps_sysinfo_hide_display'];		
	
	return $options;  
}

// UAEG version check displayed on the Security Modes page
function bulletproof_security_options_validate_uaeg_version($input) {  
	$options = get_option('bulletproof_security_options_uaeg_version');  
	$options['bps_pro_uaeg_version'] = wp_filter_nohtml_kses($input['bps_pro_uaeg_version']);		
	
	return $options;  
}

// Plugin Firewall: 1 minute Cron interval for 30 minutes on new BPS Pro installations
// This option is set in the Pre-Installation Wizard and on BPS Pro upgrades.
function bulletproof_security_options_validate_pfw_new_install($input) {  
	$options = get_option('bulletproof_security_options_pfw_new_install');  
	$options['bps_pfw_new_install_start'] = wp_filter_nohtml_kses($input['bps_pfw_new_install_start']);		
	$options['bps_pfw_new_install_end'] = wp_filter_nohtml_kses($input['bps_pfw_new_install_end']);	
	$options['bps_pfw_new_install_completed'] = wp_filter_nohtml_kses($input['bps_pfw_new_install_completed']);	
	
	return $options;  
}

// Setup Wizard: Parse phpinfo() to get the PHP memory_limit Local Value
function bulletproof_security_options_validate_php_memory_limit($input) {  
	$options = get_option('bulletproof_security_options_php_memory_limit');  
	$options['bps_php_memory_limit'] = wp_filter_nohtml_kses($input['bps_php_memory_limit']);		
	
	return $options;  
}

// Force Strong Passwords: Login Security page
function bulletproof_security_options_validate_fsp($input) {
	$options = get_option('bulletproof_security_options_fsp');
	$options['bps_fsp_on_off'] = wp_filter_nohtml_kses($input['bps_fsp_on_off']);
	$options['bps_fsp_char_length'] = wp_filter_nohtml_kses($input['bps_fsp_char_length']);	
	$options['bps_fsp_lower_case'] = wp_filter_nohtml_kses($input['bps_fsp_lower_case']);
	$options['bps_fsp_upper_case'] = wp_filter_nohtml_kses($input['bps_fsp_upper_case']);
	$options['bps_fsp_number'] = wp_filter_nohtml_kses($input['bps_fsp_number']);
	$options['bps_fsp_special_char'] = wp_filter_nohtml_kses($input['bps_fsp_special_char']);				
	$options['bps_fsp_message'] = wp_filter_nohtml_kses($input['bps_fsp_message']);
		
	return $options;  
}

// Zipped Log Files: Saves the renamed zip file names with timestamp to DB to use in the email send/attachment function.
function bulletproof_security_options_validate_zip_filename($input) {  
	$options = get_option('bulletproof_security_options_zip_filename');  
	$options['bps_security_log_zip_file'] = wp_filter_nohtml_kses($input['bps_security_log_zip_file']);		
	$options['bps_db_backup_log_zip_file'] = wp_filter_nohtml_kses($input['bps_db_backup_log_zip_file']);		
	$options['bps_mscan_log_zip_file'] = wp_filter_nohtml_kses($input['bps_mscan_log_zip_file']);	
	$options['bps_db_monitor_log_zip_file'] = wp_filter_nohtml_kses($input['bps_db_monitor_log_zip_file']);		
	$options['bps_quarantine_log_zip_file'] = wp_filter_nohtml_kses($input['bps_quarantine_log_zip_file']);		
	$options['bps_php_error_log_zip_file'] = wp_filter_nohtml_kses($input['bps_php_error_log_zip_file']);	

	return $options;  
}
?>