<?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();
}
 
if ( ! current_user_can('manage_options') ) { 
		header('Status: 403 Forbidden');
		header('HTTP/1.1 403 Forbidden');
		exit();
}
?>

<!-- force the vertical scrollbar -->
<style>
#wpwrap{min-height:100.1%};
</style>

<div id="bps-container" class="wrap" style="margin:10px 20px 5px 0px;background:#f1f1f1;">

<?php if ( 'about.php' != $pagenow ) { ?>

<script type="text/javascript">
/* <![CDATA[ */
var bpsActTimeOut = setTimeout(function(){ bpsProActKey() }, 2000);

function bpsProActKey() {
	
	var msg = document.getElementById("bps-act-key");
	msg.style.visibility = "visible";
}
/* ]]> */
</script>

<?php } ?>

<div id="bps-act-key"><img id="bps-act-error-gif" src="<?php echo plugins_url('/bulletproof-security/admin/images/act-error.gif'); ?>" style="float:left;margin:3px 5px 0px 0px;padding:0px 0px 0px 0px;" />
<?php 
echo '<strong><font color="#fb0101">'.__('Error: Invalid|Incorrect BPS Pro Activation Key', 'bulletproof-security').'</font><br>'.__('Go to the BPS Pro Activation page, enter a valid Activation Key and click the Save Activation Key button.<br><font color="blue">Note: If you can see the Pre-Installation Wizard and Setup Wizard buttons then disregard this error message.', 'bulletproof-security').'</font></strong>';
?>
</div>

<noscript><div id="message" class="updated" style="font-weight:600;font-size:13px;padding:5px;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);"><span style="color:blue">BPS Warning: JavaScript is disabled in your Browser</span><br />BPS plugin pages will not display visually correct and all BPS JavaScript functionality will not work correctly.</div></noscript>

<?php 
$ScrollTop_options = get_option('bulletproof_security_options_scrolltop');

if ( isset( $ScrollTop_options['bps_scrolltop'] ) && $ScrollTop_options['bps_scrolltop'] != 'Off' ) {
	
	if ( esc_html($_SERVER['REQUEST_METHOD']) == 'POST' || isset( $_GET['settings-updated'] ) && @$_GET['settings-updated'] == true ) {

		bpsPro_Browser_UA_scroll_animation();
	}
}

## Preloads the w3tc_dashboard page in an iFrame, which writes W3TC htaccess code to the Root htaccess file ONLY if W3TC htaccess code does not already exist.
// The iFrame cannot be loaded in this function: bpsPro_Pwizard_Autofix_W3TC() because things do not happen in time for processing data due to a delay in loading the iFrame.
// Unlock the Root htaccess file if it is locked. Force generate W3TC htaccess code in the Root htaccess file by loading the W3TC Dashboard page in an iFrame.
// Unlock the wp-config.php file if it is locked, writes the WPSC wp-config.php code.
function bpsPro_w3tc_dashboard_iframe_preload() {
	
	if ( isset( $_POST['Submit-Setup-Wizard'] ) || isset( $_POST['Submit-Net-JTC'] ) || isset( $_POST['Submit-Net-LSM'] ) || isset( $_POST['Submit-Wizard-GDMW'] ) || isset( $_POST['Submit-Wizard-cURL-Options'] ) ) {
		return;
	}

	$w3tc_plugin = 'w3-total-cache/w3-total-cache.php';
	$w3tc_plugin_active = in_array( $w3tc_plugin, apply_filters('active_plugins', get_option('active_plugins')));

	if ( $w3tc_plugin_active == 1 || is_plugin_active_for_network( $w3tc_plugin ) ) {	

		$rootHtaccess = ABSPATH . '.htaccess';
		
		if ( file_exists($rootHtaccess) ) {
		
			$wpconfig = ABSPATH . 'wp-config.php';
			$sapi_type = php_sapi_name();
			$perms_wpconfig = @substr(sprintf('%o', fileperms($wpconfig)), -4);
			$permsRootHtaccess = @substr(sprintf('%o', fileperms($rootHtaccess)), -4);
				
			if ( @substr($sapi_type, 0, 6) != 'apache' || @$perms_wpconfig != '0666' || @$perms_wpconfig != '0777' ) {
				@chmod( $wpconfig, 0644 );
			}
	
			if ( @substr($sapi_type, 0, 6) != 'apache' || @$permsRootHtaccess != '0666' || @$permsRootHtaccess != '0777' ) {
				chmod( $rootHtaccess, 0644 );
			}

			if ( is_multisite() ) {
				echo '<iframe src="'.network_admin_url( 'admin.php?page=w3tc_dashboard' ).'" style="width:0;height:0;border:0;border:none;"></iframe>';
			} else {
				echo '<iframe src="'.admin_url( 'admin.php?page=w3tc_dashboard' ).'" style="width:0;height:0;border:0;border:none;"></iframe>';
			}
		}
	}
}

bpsPro_w3tc_dashboard_iframe_preload();

?>

<div id="message" class="updated" style="border:1px solid #999;background-color:#000;">

<?php

$bpsSpacePop = '-------------------------------------------------------------';

if ( isset( $_POST['Submit-Setup-Wizard-Preinstallation'] ) ) {
require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/pwizard-functions.php' );
require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/pwizard-autofix.php' );
require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/pwizard-autofix-setup.php' );
}

if ( isset( $_POST['Submit-Setup-Wizard'] ) ) {
require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/swizard-functions.php' );
require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/swizard-arq-functions.php' );
require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/swizard-folder-lock.php' );
}

// Wizard Prep: Apache Module directive check to get and create the apache modules and htaccess files enabled|disabled DB options/values.
// 11.8: Create|Update htaccess Files Enabled|Disabled DB option values
// mod_access_compat|mod_authz_core forward/backward compatibility: create new htaccess files if needed
// A user can override this check by choosing Enable or Disable htaccess Files Setup Wizard option.
// Enable override: fallback to create mod_access_compat htaccess files. Only in the case where BPS detects fubar. Otherwise normal htaccess file detection/creation is performed.
// Disable override: htaccess files will either be deleted if they exist or not created and all BPS htaccess features will be disabled.
// Important: DO NOT Add: isset( $_POST['Submit-Wizard-HFiles'] ) or isset( $_POST['Submit-Setup-Wizard-Preinstallation'] ) or isset( $_POST['Submit-Setup-Wizard'] ) forms. 
// 15: Bugfix: removed isset( $_POST['Submit-Setup-Wizard'] ) condition. Was causing a timing/page refresh and isset condition problem.
// Important Note: the bpsPro_apache_mod_directive_check() function actually fires AFTER the Pre-Installation Wizard and at the start of Setup Wizard isset. 
// This is a very complex issue that MUST be done this way in order to create accurate htaccess code at the right time.
function bpsPro_pre_installation_prep() {

	if ( isset( $_POST['Submit-Net-JTC'] ) || isset( $_POST['Submit-Net-LSM'] ) || isset( $_POST['Submit-Wizard-GDMW'] ) || isset( $_POST['Submit-Wizard-cURL-Options'] ) ) {
		return;
	}
	
	bpsPro_apache_mod_directive_check();
}

bpsPro_pre_installation_prep();

require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/wizard-backup.php' );

bpsPro_Wizard_deny_all();
bpsPro_root_precheck_download();

// Pre-installation Setup Wizard - Scans up to 50 Page & Posts - includes Home & Login page for Plugin Scripts to Whitelist
// and saves to DB Options. Setup Wizard will later use these DB Options to create the Plugin Firewall .htaccess file
// 11.5: no longer displaying errors for invalid whitelist rules and just not creating them by filtering them out.
// 12.5: added conditions for bbPress & BuddyPress. the cURL scanner will not scan these site types.
// 12.5: Fix for double slashes // in path - create RegEx whitelist rule & "plugins" folder name used in path - preg_match from wp-content folder.
// 12.5: Additional correction: Moved filter conditions and other variables outside of the curl_multi_exec() "for" loop.
// 14.9: Fixed: Plugin Firewall whitelist rules were being removed when the cURL Scan option was set to Off.
function bpsSetupWizardPluginFirewall_DB() {
global $wpdb;

	if ( current_user_can('manage_options') ) {

		$CURLoptions = get_option('bulletproof_security_options_wizard_curl');
		$HFiles_options = get_option('bulletproof_security_options_htaccess_files');	
	
		if ( $CURLoptions['bps_wizard_curl_scan'] == 'Off' || $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			
			echo '<strong><font color="green">'.__('Plugin Firewall cURL Scanning is Turned Off.', 'bulletproof-security').'</font></strong><br>';		
		}	
		
		$bbpress_file = WP_PLUGIN_DIR . '/bbpress/bbpress.php';
		$buddypress_file = WP_PLUGIN_DIR . '/buddypress/bp-loader.php';
	
		if ( $CURLoptions['bps_wizard_curl_scan'] != 'Off' && $HFiles_options['bps_htaccess_files'] != 'disabled' && ! file_exists($bbpress_file) && ! file_exists($buddypress_file) ) {
	
			$posts_table = $wpdb->prefix . "posts";
			$post_type = "p";
			$post_status = "publish";
	
			$getPostsPages = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $posts_table WHERE post_type LIKE %s AND post_status = %s LIMIT 50", "%$post_type%", $post_status) );
	
			$nodes = array();
	
			if ( $getPostsPages ) {
	
				foreach ( $getPostsPages as $PostsPages ) {
					$nodes[] = $PostsPages->guid;
				}
			}
	
			$array1 = array( 1 => get_site_url(), 2 => site_url( '/wp-login.php' ) );
			$merged = array_merge($array1, $nodes);
			$node_count = count($merged);
	
			echo '<strong><font color="green">'.__('Plugin Firewall cURL Scanner Successfully Scanned: ', 'bulletproof-security').'</font><font color="blue">'.$node_count.__(' Pages & Posts', 'bulletproof-security').'</font></strong><br>';
	
			$filterPattern1 = '/\/ga\/inpage_linkid\.js/';	
			$filterPattern2 = '/(\bver=\b|\bpage=\b|\bsrc=\b|\bwww\b|\bhttp\b|\bhttps\b|\bhref\b|\b.com\b|\b.net\b|\b.org\b\b.biz\b|\b.info\b|\b.gov\b|\b.edu\b)/';
			$filterPattern3 = '/[\%\"\'\&\;\<\>]/';
			//$filterPattern4 = '/(\/plugins\/|\/wp-content\/|\/wp-includes\/)/';
			//$filterPattern5 = '/(\/themes\/|\/plugins\/|\/wp-content\/|\/wp-includes\/|\/uploads\/)/';
			$domainName = bpsGetDomainRoot();
			$bps_wpcontent_dir = str_replace( ABSPATH, '', WP_CONTENT_DIR );
	
			$curl_arr = array();
			$master = curl_multi_init();
	
			for( $i = 0; $i < $node_count; $i++ )	{
				$url = $merged[$i];
				$curl_arr[$i] = curl_init($url);
				curl_setopt($curl_arr[$i], CURLOPT_USERAGENT, 'BPS Pro Setup Wizard');    
				curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, 1);
				curl_setopt($curl_arr[$i], CURLOPT_CONNECTTIMEOUT, 15);
				@curl_setopt($curl_arr[$i], CURLOPT_FOLLOWLOCATION, true);	
				curl_multi_add_handle($master, $curl_arr[$i]);
			}
	
			do {
				curl_multi_exec($master, $running);
			} while($running > 0);
	
			for( $i = 0; $i < $node_count; $i++ )	{
		
			$results = curl_multi_getcontent( $curl_arr[$i] ); 
	
			if ( ! is_multisite() ) { 
				preg_match_all("/https?:\/\/(.*)$domainName(.*)\/$bps_wpcontent_dir\/plugins\/(.*)(\.js|\.php|\.swf|\.json)/", $results, $matches);
			}
		
			if ( is_multisite() ) { 
				preg_match_all('/https?:\/\/(.*)\/'.$bps_wpcontent_dir.'\/plugins\/(.*)(\.js|\.php|\.swf|\.json)/', $results, $matches);
			}	
	
			$pathValue = array();		
			
				foreach ( $matches[0] as $Key => $Value ) {
	
					$prep_rule = preg_replace( '/https?:\/\/(.*)\/'.$bps_wpcontent_dir.'\/plugins/', '', $Value );
					
					if ( ! preg_match( $filterPattern1, $prep_rule ) && ! preg_match( $filterPattern2, $prep_rule ) && ! preg_match( $filterPattern3, $prep_rule ) ) {				
					
						$pathValue[] = preg_replace( '/\/\//', '/(.*)', $prep_rule );					
						$comma_separated = implode( ', ', $pathValue );	
						$NoDupes = implode( ', ', array_unique( explode( ', ', $comma_separated ) ) );
					}
				}
			}
		} // end if ( $CURLoptions['bps_wizard_curl_scan'] != 'Off' && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {
	
		// Save Plugin Firewall DB Options
		$successTextBegin = '<font color="green"><strong>';
		$successTextEnd = '</strong></font><br>';
		$successMessage8 = __(' DB Option created or updated Successfully!', 'bulletproof-security');
		$options = get_option('bulletproof_security_options_pfirewall');
		$bps_option_name8 = 'bulletproof_security_options_pfirewall';
		
		if ( isset($options['bps_pfw_paypal']) && $options['bps_pfw_paypal'] == '1') {
			$bps_new_value8 = '1';
		} else {
			$bps_new_value8 = '0';
		}
		
		if ( isset($options['bps_pfw_google']) && $options['bps_pfw_google'] == '1') {
			$bps_new_value8_1 = '1';
		} else {
			$bps_new_value8_1 = '0';
		}
		
		if ( isset($options['bps_pfw_amazon']) && $options['bps_pfw_amazon'] == '1') {
			$bps_new_value8_2 = '1';
		} else {
			$bps_new_value8_2 = '0';
		}
	
		if ( isset($options['bps_pfw_authorizenet']) && $options['bps_pfw_authorizenet'] == '1') {
			$bps_new_value8_3 = '1';
		} else {
			$bps_new_value8_3 = '0';
		}
	
		if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {
	
			$string1 = ! isset($options['bps_pfw_whitelist']) ? '' : $options['bps_pfw_whitelist'];
	
			if ( isset($CURLoptions['bps_wizard_curl_scan']) && $CURLoptions['bps_wizard_curl_scan'] != 'Off' ) {
				$string2 = @$NoDupes;
			} else {
				$string2 = '';
			}
			
			## 13.5: String added and merged for the WordPress Social Login plugin
			$wordpress_social_login = 'wordpress-social-login/wp-social-login.php';
			$wordpress_social_login_active = in_array( $wordpress_social_login, apply_filters('active_plugins', get_option('active_plugins')));
			
			if ( $wordpress_social_login_active == 1 || is_plugin_active_for_network( $wordpress_social_login ) ) {
				$string3 = '/wordpress-social-login/(.*).(js|php)';
			} else {
				$string3 = '';
			}		
			
			//$stringMerge = $string1 . ', ' . $string2 . $string3;
			$stringMerge = $string1 . ', ' . $string2 . ', ' . $string3;
			$stringMergeUnique = implode( ', ', array_unique( explode( ', ', trim( $stringMerge, ", \t\n\r" ) ) ) );
			$bps_new_value8_4 = $stringMergeUnique;
		
		} else {
			$bps_new_value8_4 = '';
		}
	
		$bps_pfw_whitelist_option = ! isset($options['bps_pfw_whitelist']) ? '' : $options['bps_pfw_whitelist'];
		
		$BPS_Options8 = array(
		'bps_pfw_paypal' 		=> $bps_new_value8, 
		'bps_pfw_google' 		=> $bps_new_value8_1, 
		'bps_pfw_amazon' 		=> $bps_new_value8_2, 
		'bps_pfw_authorizenet' 	=> $bps_new_value8_3, 
		'bps_pfw_whitelist' 	=> $bps_new_value8_4
		);
	
		if ( ! get_option( $bps_option_name8 ) ) {	
			
			foreach( $BPS_Options8 as $key => $value ) {
				update_option('bulletproof_security_options_pfirewall', $BPS_Options8);
				echo $successTextBegin.'Plugin Firewall '.$key.$successMessage8.$successTextEnd;
			}
			echo $successTextBegin.'Plugin Firewall Whitelist Rules Created or Updated Successfully: '.$bps_pfw_whitelist_option.$successTextEnd;	
	
		} else {
	
			foreach( $BPS_Options8 as $key => $value ) {
				update_option('bulletproof_security_options_pfirewall', $BPS_Options8);
				echo $successTextBegin.'Plugin Firewall '.$key.$successMessage8.$successTextEnd;	
			}
			echo $successTextBegin.'Plugin Firewall Whitelist Rules Created or Updated Successfully: '.$bps_pfw_whitelist_option.$successTextEnd;
		}	
		
		$Allow_options = get_option('bulletproof_security_options_pfirewall_allow');
		$bps_option_name9 = 'bulletproof_security_options_pfirewall_allow';
		
		if ( ! get_option('bulletproof_security_options_pfirewall_allow') || $Allow_options['bps_pfw_allow_from'] == '' ) {
			$bps_new_value9 = '';
		} else {
			$bps_new_value9 = $Allow_options['bps_pfw_allow_from'];	
		}
		
		$BPS_Options9 = array( 'bps_pfw_allow_from' => $bps_new_value9 );
		
		if ( ! get_option( $bps_option_name9 ) ) {	
			
			foreach( $BPS_Options9 as $key => $value ) {
				update_option('bulletproof_security_options_pfirewall_allow', $BPS_Options9);
				echo $successTextBegin.'Plugin Firewall '.$key.$successMessage8.$successTextEnd;	
			}
		
		} else {
	
			foreach( $BPS_Options9 as $key => $value ) {
				update_option('bulletproof_security_options_pfirewall_allow', $BPS_Options9);
				echo $successTextBegin.'Plugin Firewall '.$key.$successMessage8.$successTextEnd;	
			}
		}
	
		// 15.1: Pre-save the PFW Roles for Administrator, Editor, Author and Contributor	
		$PFW_Roles_Options = get_option('bulletproof_security_options_pfirewall_roles');
		
		$pfw_roles1 = ! isset($PFW_Roles_Options['bps_pfw_administrator']) ? '1' : $PFW_Roles_Options['bps_pfw_administrator'];
		$pfw_roles2 = ! isset($PFW_Roles_Options['bps_pfw_editor']) ? '1' : $PFW_Roles_Options['bps_pfw_editor'];
		$pfw_roles3 = ! isset($PFW_Roles_Options['bps_pfw_author']) ? '1' : $PFW_Roles_Options['bps_pfw_author'];
		$pfw_roles4 = ! isset($PFW_Roles_Options['bps_pfw_contributor']) ? '1' : $PFW_Roles_Options['bps_pfw_contributor'];
		$pfw_roles5 = ! isset($PFW_Roles_Options['bps_pfw_roles_hidden']) ? '14' : $PFW_Roles_Options['bps_pfw_roles_hidden'];	
		$pfw_roles6 = ! isset($PFW_Roles_Options['bps_pfw_custom_roles']) ? array( 'bps', '' ) : $PFW_Roles_Options['bps_pfw_custom_roles'];

		$PFW_Roles = array( 
		'bps_pfw_administrator' => $pfw_roles1, 
		'bps_pfw_editor' 		=> $pfw_roles2, 	
		'bps_pfw_author' 		=> $pfw_roles3, 	
		'bps_pfw_contributor' 	=> $pfw_roles4, 
		'bps_pfw_roles_hidden' 	=> $pfw_roles5, 
		'bps_pfw_custom_roles' 	=> $pfw_roles6  
		);
		
		foreach( $PFW_Roles as $key => $value ) {
			update_option('bulletproof_security_options_pfirewall_roles', $PFW_Roles);
			echo $successTextBegin.'Plugin Firewall '.$key.$successMessage8.$successTextEnd;
		}
	}
}

// General all purpose "Settings Saved." message for forms - /includes/class.php
if ( current_user_can('manage_options') && wp_script_is( 'bps-accordion', $list = 'queue' ) ) {
if ( isset( $_GET['settings-updated'] ) && @$_GET['settings-updated'] == true ) {
	$text = '<p style="font-size:1em;font-weight:bold;padding:2px 0px 2px 5px;margin:0px -11px 0px -11px;background-color:#dfecf2;-webkit-box-shadow: 3px 3px 5px 0px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px 0px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px 0px rgba(153,153,153,0.7);"><font color="green"><strong>'.__('Settings Saved', 'bulletproof-security').'</strong></font></p>';
	echo $text;
	} else {
	echo '<font color="#fb0101"><strong>'.bps_cuser_errors().'</strong></font>';
	}
}

/****************************************/
// BEGIN BPS Pro Pre-Installation Wizard
/****************************************/

// Setup Wizard - Pre-Installation Wizard
function bpsSetupWizardPrechecks() {

if ( isset( $_POST['Submit-Setup-Wizard-Preinstallation'] ) && current_user_can('manage_options') ) {
	check_admin_referer( 'bps_setup_wizard_preinstallation' );
	set_time_limit(300);

	global $wp_version;
	
	$time_start = microtime( true );
	
	$successTextBegin = '<font color="green"><strong>';
	$successMessage = __(' DB Table created Successfully!', 'bulletproof-security');
	$successTextEnd = '</strong></font><br>';
	$failTextBegin = '<font color="#fb0101"><strong>';
	$failMessage = __('Error: Unable to create DB Table ', 'bulletproof-security');
	$failTextEnd = '</strong></font><br>';
	$sapi_type = php_sapi_name();
	$gmt_offset = get_option( 'gmt_offset' ) * 3600;
	$wpconfig = ABSPATH . 'wp-config.php';
	$rootHtaccess = ABSPATH . '.htaccess';
	if ( file_exists($rootHtaccess) ) {
		$rootHtaccessContents = file_get_contents($rootHtaccess);
	}
	$rootHtaccessBackup = WP_CONTENT_DIR . '/bps-backup/master-backups/root.htaccess';
	$rootHtaccessBackupTime = WP_CONTENT_DIR . '/bps-backup/master-backups/root.htaccess-'.date( 'Y-m-d-g-i-s-a', time() + $gmt_offset );
	$wpadminHtaccess = ABSPATH . 'wp-admin/.htaccess';
	$wpadminHtaccessBackup = WP_CONTENT_DIR . '/bps-backup/master-backups/wpadmin.htaccess';
	$RootCustomCode = get_option('bulletproof_security_options_customcode');
	$ARQoptions = get_option('bulletproof_security_options_ARCM');
	$HFiles_options = get_option('bulletproof_security_options_htaccess_files');
	$arq_failsafe_file = WP_CONTENT_DIR . '/bps-backup/master-backups/arq-failsafe.txt';
			
	if ( file_exists($arq_failsafe_file) ) {
		unlink($arq_failsafe_file);
	}

	// 15.6: Pre-Save the AutoRestore > Add Files > Root hosting account folder text box option w/blank value.
	if ( ! get_option('bulletproof_security_options_arq_host_root') ) {
		
		$bps_arq_host_root_folder = array( 'bps_arq_host_root_folder' => '' );
		
		foreach( $bps_arq_host_root_folder as $key => $value ) {
			update_option('bulletproof_security_options_arq_host_root', $bps_arq_host_root_folder);
		}
	}

	// 15.4: MScan Rebuild Notice db option value. Set to: new - for new installations of BPS. Set to: upgrade - in the BPS upgrade function for existing BPS installs.
	if ( ! get_option('bulletproof_security_options_new_feature') ) {
		
		$bps_mscan_rebuild = array( 'bps_mscan_rebuild' => 'new' );
		
		foreach( $bps_mscan_rebuild as $key => $value ) {
			update_option('bulletproof_security_options_new_feature', $bps_mscan_rebuild);
		}
	}	

	// New installations of BPS Pro ONLY. PFW Cron: set to 1 minute Cron intervals for 30 minutes and then set to the default 10 minute Cron interval.
	// Note: This DB option is pre-saved on BPS Pro upgrades. The bps_pfw_new_install_completed value is set to: Yes
	$bps_option_pfw_new_install = 'bulletproof_security_options_pfw_new_install';
	
	$bps_pfw_new_install_start = time();
	$bps_pfw_new_install_end = time() + 1800;
	//$bps_pfw_new_install_end = time() + 300; // 5 minutes for testing
	
	$BPS_pfw_new_install = array(
	'bps_pfw_new_install_start' 	=> $bps_pfw_new_install_start, 
	'bps_pfw_new_install_end' 		=> $bps_pfw_new_install_end, 
	'bps_pfw_new_install_completed' => 'No'
	);

		if ( ! get_option( $bps_option_pfw_new_install ) ) {	
		
			foreach( $BPS_pfw_new_install as $key => $value ) {
				update_option('bulletproof_security_options_pfw_new_install', $BPS_pfw_new_install);
			}
		}	

	// Pre-save UI|UX Settings DB option settings
	bpsPro_presave_uiux_settings();
	// Pre-save the Setup Wizard Options DB option settings
	bpsPro_presave_setupwizard_option_settings();
	
	$bps_option_name11 = 'bulletproof_security_options_ARCM';
	
	if ( ! isset($ARQoptions['bps_autorestore_cron_frequency']) ) {
		$bps_new_value11_1 = '2';	
	} else {
		$bps_new_value11_1 = $ARQoptions['bps_autorestore_cron_frequency'];
	}	
	
	$bps_new_value11_2 = 'Off';
	
	if ( ! isset($ARQoptions['bps_autorestore_cron_override']) ) {
		$bps_new_value11_3 = 'Off';	
	} else {
		$bps_new_value11_3 = $ARQoptions['bps_autorestore_cron_override'];
	}		
	
	if ( ! isset($ARQoptions['bps_autorestore_cron_filecheck']) ) {
		$bps_new_value11_3a = 'On';	
	} else {
		$bps_new_value11_3a = $ARQoptions['bps_autorestore_cron_filecheck'];
	}

	if ( ! isset($ARQoptions['bps_autorestore_cron_forced']) ) {
		$bps_new_value11_4 = '1';	
	} else {
		$bps_new_value11_4 = $ARQoptions['bps_autorestore_cron_forced'];
	}	
	
	if ( ! isset($ARQoptions['bps_autorestore_cron_end']) ) {
		$bps_new_value11_5 = '';	
	} else {
		$bps_new_value11_5 = $ARQoptions['bps_autorestore_cron_end'];
	}	

	$BPS_Options11 = array(
	'bps_autorestore_cron_frequency' 	=> $bps_new_value11_1, 
	'bps_autorestore_cron' 				=> $bps_new_value11_2, 
	'bps_autorestore_cron_override' 	=> $bps_new_value11_3, 
	'bps_autorestore_cron_filecheck' 	=> $bps_new_value11_3a, 
	'bps_autorestore_cron_forced' 		=> $bps_new_value11_4, 
	'bps_autorestore_cron_end' 			=> $bps_new_value11_5
	);
	
		if ( ! get_option( $bps_option_name11 ) ) {	
		
			foreach( $BPS_Options11 as $key => $value ) {
				update_option('bulletproof_security_options_ARCM', $BPS_Options11);
			}
	
		} else {

			foreach( $BPS_Options11 as $key => $value ) {
				update_option('bulletproof_security_options_ARCM', $BPS_Options11);
			}	
		}

	$bps_option_preinstall = 'bulletproof_security_options_preinstallation';
	
	$BPS_Options_preinstall = array(
	'bps_wizard_preinstallation' 	=> 'yes', 
	'bps_wizard_preinstallation_61' => 'yes'
		);

		if ( ! get_option( $bps_option_preinstall ) ) {	
		
			foreach( $BPS_Options_preinstall as $key => $value ) {
				update_option('bulletproof_security_options_preinstallation', $BPS_Options_preinstall);
			}
	
		} else {

			foreach( $BPS_Options_preinstall as $key => $value ) {
				update_option('bulletproof_security_options_preinstallation', $BPS_Options_preinstall);
			}	
		}

	// Update BPS DB option - WP version matches the current version of WP & reset the last modified time in DB
	$gmt_offset = get_option( 'gmt_offset' ) * 3600;
	$versionphp = ABSPATH . 'wp-includes/version.php';	
	$last_modified_time_versionphp = date("F d Y H:i", filemtime($versionphp) + $gmt_offset);
	$bps_option_name12 = 'bulletproof_security_options_wp_version';
	$bps_new_value12 = $wp_version;	
	$bps_new_value12_1 = date("F d Y H:i", filemtime($versionphp) + $gmt_offset + 900);	
			
	$BPS_Options12 = array( 'bps_wp_version' => $bps_new_value12, 'bps_wp_version_last_modified_time' => $bps_new_value12_1 );	
	
	if ( ! get_option( $bps_option_name12 ) ) {	
		
		foreach( $BPS_Options12 as $key => $value ) {
			update_option('bulletproof_security_options_wp_version', $BPS_Options12);
		}
			
	} else {

		foreach( $BPS_Options12 as $key => $value ) {
			update_option('bulletproof_security_options_wp_version', $BPS_Options12);
		}	
	}

	echo '<h3>'.__('Pre-Installation Wizard Checks|Scans|Settings have completed:', 'bulletproof-security').'</h3><div style="font-size:12px;margin:-10px 0px 10px 0px;font-weight:bold;">'.__('If you see all green font messages displayed below, scroll down and click the Setup Wizard button.', 'bulletproof-security').'<br>'.__('If you see any red font or blue font messages displayed below, click the Read Me help button above and read the "Notes" help section before clicking the Setup Wizard button.', 'bulletproof-security').'</div>';   
	echo '<div id="Wizard-background" style="max-height:250px;width:85%;overflow:auto;margin:0px;padding:10px;background-color:#dfecf2;border:2px 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);">';
	
	echo '<span class="setup-wizard-checks-text">';
	
	// 13: Setup Wizard AutoFix (AutoWhitelist|AutoSetup|AutoCleanup): Create & Save Custom Code
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:0px;margin-top:10px;">'.__('AutoFix (AutoWhitelist|AutoSetup|AutoCleanup)', 'bulletproof-security').'</div>';
	echo '<div id="pw-autofix" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:0px;"><p>';

	// AutoWhitelist functions
	bpsPro_Pwizard_Autofix_Request_methods();
	bpsPro_Pwizard_Autofix_plugin_skip_bypass_root();
	bpsPro_Pwizard_Autofix_RFI();
	bpsPro_Pwizard_Autofix_BPSQSE_root();
	bpsPro_Pwizard_Autofix_plugin_skip_bypass_wpadmin();
	bpsPro_Pwizard_Autofix_BPSQSE_wpadmin();
	bpsPro_Pwizard_Autofix_UAEG(); // nothing added in this function
	// AutoSetup|AutoCleanup functions
	bpsPro_Pwizard_Autofix_WPSC();
	bpsPro_Pwizard_Autofix_W3TC();
	bpsPro_Pwizard_Autofix_Comet_Cache();
	// 13.7: No longer offering autofix for the EPC plugin.
	//bpsPro_Pwizard_Autofix_Endurance();
	bpsPro_Pwizard_Autofix_WPFC();
	bpsPro_Pwizard_Autofix_WPR();
	bpsPro_Pwizard_Autofix_LSCACHE();
	
	echo '</p></div><br>';

	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:0px;margin-top:10px;">'.__('Compatibility & Basic Checks', 'bulletproof-security').'</div>';
	echo '<div id="pw-compatibility" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:0px;"><p>';

	if ( @substr( $sapi_type, 0, 6) != 'apache' && get_filesystem_method() == 'direct' ) {
		echo $successTextBegin.__('Pass! Compatible Server Configuration: Server API: CGI | WP Filesystem API Method: direct.', 'bulletproof-security').$successTextEnd;
	}
	elseif ( @substr( $sapi_type, 0, 6) == 'apache' && preg_match('#\\\\#', ABSPATH, $matches ) && get_filesystem_method() == 'direct' ) {
		echo $successTextBegin.__('Pass! Compatible Server Configuration: Server Type Apache: XAMPP, WAMP, MAMP or LAMP | WP Filesystem API Method: direct.', 'bulletproof-security').$successTextEnd;	
	}
	elseif ( @substr( $sapi_type, 0, 6) == 'apache' && ! preg_match('#\\\\#', ABSPATH, $matches ) && get_filesystem_method() == 'direct' ) {
		echo $successTextBegin.__('Pass! Compatible Server Configuration: Server API: DSO | WP Filesystem API Method: direct.', 'bulletproof-security').$successTextEnd;		
	}
	elseif ( @substr( $sapi_type, 0, 6) == 'apache' && get_filesystem_method() != 'direct' ) {
		echo $failTextBegin.__('Server API: Apache DSO Server Configuration | WP Filesystem API Method: ', 'bulletproof-security').get_filesystem_method().$failTextEnd.'<br>'.__('Your Server type is DSO and the WP Filesystem API Method is NOT "direct". You can use the Setup Wizard, but you must first make some one-time manual changes to your website before running the Setup Wizard. Please click this Forum Link for instructions: ', 'bulletproof-security').'<a href="https://forum.ait-pro.com/forums/topic/dso-setup-steps/" target="_blank" title="Link opens in a new Browser window"><strong>'.__('DSO Setup Steps', 'bulletproof-security').'</a></strong><br><br>';			
	}
	
	// Parse phpinfo() and return the PHP memory_limit Local Value
	bpsPro_phpinfo_memory_limit_array();

	$bps_php_memory_limit = get_option('bulletproof_security_options_php_memory_limit');

	$memoryLimitM = $bps_php_memory_limit['bps_php_memory_limit'];
	$memoryLimit = str_replace( 'M', '', $memoryLimitM );
	$pos_memory_limit = strpos( $memoryLimitM, 'Unable to get the PHP memory_limit value from the server' );

	if ( $pos_memory_limit !== false ) {
		
		echo '<strong><font color="blue">'.__($bps_php_memory_limit['bps_php_memory_limit'], 'bulletproof-security').'</font></strong><br>';

	} else {

		switch ( $memoryLimit ) {
			case $memoryLimit >= '128':
				echo $successTextBegin.__('Pass! PHP Configuration Memory Limit is set to: ', 'bulletproof-security').$memoryLimitM.$successTextEnd;		
				break;
			case $memoryLimit >= '64' && $memoryLimit < '128':
				echo $successTextBegin.__('Pass! PHP Configuration Memory Limit is set to: ', 'bulletproof-security').$memoryLimitM.'. '.__('It is recommended that you increase your memory limit to at least 128M, 256M is even better.', 'bulletproof-security').$successTextEnd;
				break;
			case $memoryLimit > '0' && $memoryLimit < '64':
				echo '<br>'.$failTextBegin.__('Error: Your PHP Configuration Memory Limit is set to: ', 'bulletproof-security').$memoryLimitM.'. '.__('WordPress needs a bare minimum Memory Limit setting of 128M to perform well. The Setup Wizard may or may not be able to complete the BPS Pro setup successfully until you increase your memory limit to at least 128M. Most Web Host\'s allow your memory limit to be set to at least 128M. Contact your Web Host and ask them to increase your memory limit to the maximum memory limit setting allowed by your Host.', 'bulletproof-security').$failTextEnd.'<br>';	
				break;
		}
	}

	## 11.8: Apache Module Directive Check & htaccess Files Enabled|Disabled Check
	## 15.9: BugFix: Added an additional $HFiles condition. htaccess files were being enabled automatically.
	$HFiles_options = get_option('bulletproof_security_options_htaccess_files');
	$Apache_Mod_options = get_option('bulletproof_security_options_apache_modules');
	$htaccess_files_disabled_enabled = isset($HFiles_options['bps_htaccess_files']) ? $HFiles_options['bps_htaccess_files'] : '';
	
	if ( $Apache_Mod_options['bps_apache_mod_ifmodule'] == 'Yes' && $htaccess_files_disabled_enabled != 'disabled' ) {
				
		echo $successTextBegin.__('mod_authz_core is Loaded|Order, Allow, Deny directives are supported|BC: Yes|IfModule: Yes', 'bulletproof-security').$successTextEnd;

		## 15.3: either temporary or permanent - not sure yet
		$htaccess_files_Options = array(
		'bps_htaccess_files' 	=> 'enabled'
		);

		foreach( $htaccess_files_Options as $key => $value ) {
			update_option('bulletproof_security_options_htaccess_files', $htaccess_files_Options);
		}
			
	} elseif ( $Apache_Mod_options['bps_apache_mod_ifmodule'] == 'No' ) {
				
		if ( $htaccess_files_disabled_enabled == 'enabled' ) {
			echo $successTextBegin.__('Enable|Disable htaccess Files Option set to Enabled.', 'bulletproof-security').$successTextEnd;
		} else {
			echo $successTextBegin.__('mod_access_compat is Loaded|Order, Allow, Deny directives are supported|IfModule: No', 'bulletproof-security').$successTextEnd;
		}
	
	} elseif ( $Apache_Mod_options['bps_apache_mod_ifmodule'] == 'fubar' || $htaccess_files_disabled_enabled == 'disabled' ) {
			echo '<strong><font color="blue">'.__('Enable|Disable htaccess Files Option set to Disabled: All BPS htaccess features will be disabled. ', 'bulletproof-security').'</font></strong>';
	
	} 

	if ( ! file_exists($wpconfig) ) {
		echo '<br>'.$failTextBegin.__('Error: A wp-config.php file was NOT found in your website root folder.', 'bulletproof-security').$failTextEnd.__('If you have moved your wp-config.php file to another folder location then you will need to add the BPS Pro ini_set code to your wp-config.php file manually.', 'bulletproof-security').'<br>'.__('The BPS ini_set code can be found in this file /bulletproof-security/admin/php/php-directives-code-for-wp-config. Setup instructions are included in the file.', 'bulletproof-security').'<br>';
	}
	
	// 11.8: Enable|Disable htaccess Files: set to htaccess Files Disabled - deletes all htaccess files.
	bpsSetupWizard_delete_htaccess_files();
	
	## 15.3: this may be temporary or permanent - not sure yet
	bpsPro_apache_mod_create_htaccess_files();
	
	// 11.8: New htaccess files enabled|disabled condition
	if ( $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
	
	// Create root .htaccess file if it does not exist else Backup existing root htaccess file first and then create new root .htaccess file.
	if ( ! file_exists($rootHtaccess) ) {
		
		bpsSetupWizardCreateRootHtaccess();
	
	} else {
		
		// PHP/php.ini handler root htaccess code - Checks for and creates php/php.ini handler code in BPS Pro Custom Code
		bpsSetupWizardPhpiniHandlerCheck();

		// root htaccess file backup with timestamp: root.htaccess-2017-11-02-3-00-00
		copy($rootHtaccess, $rootHtaccessBackupTime);
		// used for root htaccess file restores
		copy($rootHtaccess, $rootHtaccessBackup);	
		bpsSetupWizardCreateRootHtaccess();
		echo $successTextBegin.__('Pass! Root .htaccess file backup Successful! ', 'bulletproof-security').$rootHtaccessBackupTime.$successTextEnd;
	}

	// Create wp-admin .htaccess file if it does not exist else Backup existing wp-admin htaccess file first and then create new wp-admin .htaccess file.
	if ( ! file_exists($wpadminHtaccess) ) {
		
		bpsSetupWizardCreateWpadminHtaccess();
	
	} else {
		
		copy($wpadminHtaccess, $wpadminHtaccessBackup);
		bpsSetupWizardCreateWpadminHtaccess();		
		echo $successTextBegin.__('Pass! wp-admin .htaccess file backup Successful!', 'bulletproof-security').$successTextEnd;
	}

	// Create the default.htaccess htaccess file
	bpsSetupWizardCreateDefaultHtaccess();
	
	}

		// 14.9: File Lock Override default setting is: Off. The hidden value is: 14
		// This hidden value is only used as a condition to update the File Lock Override options ONCE on new BPS Pro installations.
		$fl_override_options = get_option('bulletproof_security_options_flock_eol');
		
		if ( ! isset($fl_override_options['bps_file_lock_override_hidden']) || isset($fl_override_options['bps_file_lock_override_hidden']) && $fl_override_options['bps_file_lock_override_hidden'] != '14' ) {
		
			$BPS_FLO_Options = array( 
			'bps_file_lock_override' 			=> 'Off', 
			'bps_file_lock_override_hidden' 	=> '14' 
			);	
	
			foreach( $BPS_FLO_Options as $key => $value ) {
				update_option('bulletproof_security_options_flock_eol', $BPS_FLO_Options);
			}		
		}
		
		// 14.9: File Lock override option added
		if ( isset($fl_override_options['bps_file_lock_override']) && $fl_override_options['bps_file_lock_override'] == 'On' ) {
		
			// 11.8: New htaccess files enabled|disabled condition
			if ( $HFiles_options['bps_htaccess_files'] == 'disabled' ) {		
			
				$bps_option_name_pc = 'bulletproof_security_options_setup_wizard_flock';
				
				$BPS_Options_pc = array(
				'bps_wizard_root_htaccess_flock' 	=> 'no', 
				'bps_wizard_wpconfig_flock' 		=> 'no', 
				'bps_wizard_index_flock' 			=> 'no', 
				'bps_wizard_wpblogheader_flock' 	=> 'no' 
				);		
			
				foreach( $BPS_Options_pc as $key => $value ) {
					update_option('bulletproof_security_options_setup_wizard_flock', $BPS_Options_pc);
				}
		
				echo $successTextBegin.__('File Lock: Checking & Alerts Off. htaccess Files Disabled.', 'bulletproof-security').$successTextEnd;
	
			} else {
	
				// F-Lock CGI file permission Check - Save DB values based on existing root htaccess file permissions
				// The actual final F-Lock DB values will be updated in the Setup Wizard
				$sapi_type = @php_sapi_name();	
				$permsRootHtaccess = @substr(sprintf('%o', fileperms($rootHtaccess)), -4); // 0644 / 0404		
			
				if ( @substr($sapi_type, 0, 6) != 'apache' && $permsRootHtaccess != '0404' ) {
			
					$bps_option_name_pc = 'bulletproof_security_options_setup_wizard_flock';
				
					$BPS_Options_pc = array(
					'bps_wizard_root_htaccess_flock' 	=> 'no', 
					'bps_wizard_wpconfig_flock' 		=> 'no', 
					'bps_wizard_index_flock' 			=> 'no', 
					'bps_wizard_wpblogheader_flock' 	=> 'no'
					);
	
					if ( ! get_option( $bps_option_name_pc ) ) {	
				
						foreach( $BPS_Options_pc as $key => $value ) {
							update_option('bulletproof_security_options_setup_wizard_flock', $BPS_Options_pc);
						}
		
					} else {
	
						foreach( $BPS_Options_pc as $key => $value ) {
							update_option('bulletproof_security_options_setup_wizard_flock', $BPS_Options_pc);
						}
					}
					
					echo '<strong><font color="blue">'.__('Your current Root .htaccess file is not locked. It is recommended that you lock your Root .htaccess file on the BPS Pro > B-Core > htaccess File Editor page. Click the Lock htaccess File and Turn On AutoLock buttons on the htaccess File Editor page.', 'bulletproof-security').'</font></strong><br>';		
				}
		
				if ( @substr($sapi_type, 0, 6) != 'apache' && $permsRootHtaccess == '0404' ) {
			
					$bps_option_name_pc = 'bulletproof_security_options_setup_wizard_flock';
				
					$BPS_Options_pc = array(
					'bps_wizard_root_htaccess_flock' 	=> 'yes', 
					'bps_wizard_wpconfig_flock' 		=> 'yes', 
					'bps_wizard_index_flock' 			=> 'yes', 
					'bps_wizard_wpblogheader_flock' 	=> 'yes'
					);
	
					if ( ! get_option( $bps_option_name_pc ) ) {	
				
						foreach( $BPS_Options_pc as $key => $value ) {
							update_option('bulletproof_security_options_setup_wizard_flock', $BPS_Options_pc);
						}
		
					} else {
	
						foreach( $BPS_Options_pc as $key => $value ) {
							update_option('bulletproof_security_options_setup_wizard_flock', $BPS_Options_pc);
						}
					}	
					echo $successTextBegin.__('Pass! File Lock check. The Root .htaccess file can be locked.', 'bulletproof-security').$successTextEnd;
				} 
			}
		}

	// 11.1: Pre-save UI Theme Skin with Blue Theme if DB option does not exist
	// this function is no longer be used. See function: bpsPro_presave_uiux_settings()
	// bpsPro_presave_ui_theme_skin_options();
	// 14: Pre-Save the SLF filter options. The default is now set to On. New option added to use to check against for BPS upgrades: bps_slf_filter_new
	// 14.9: This function is no longer being used. See function: bpsPro_presave_uiux_settings()
	// bpsPro_presave_ui_theme_skin_SLF_options();

	// Plugin Firewall cURL pre-check - Check if cURL is enabled and cURL functions are not disabled
	bpsSetupWizardcURLCheck();
	
	echo '</p></div><br>'; // end Compatibility & Basic Checks visual section divider

	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:0px;margin-top:10px;">'.__('AutoRestore|Quarantine Exclude Rules', 'bulletproof-security').'</div>';
	echo '<div id="pw-arq-exclude" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:0px;"><p>';

	// AutoRestore/Quarantine pre-check - Create /wp-includes/version.php ARQ exclude rule if it does not exist
	// In /includes/functions.php: used in Setup Wizard, Pre-Installation Wizard & wp automatic updating function
	bps_wp_versionphp_exclude_rule();
	
	// Create an ARQ single file Exclude rule for /mu-plugins/bps-pro-mu-tools.php
	// In functions.php: used in Setup Wizard, Pre-Installation Wizard and BPS upgrade functions.
	bpsPro_mu_tools_exclude_rule();
	
	// AutoRestore/Quarantine pre-check - Create ARQ exclude DB options: plugins, mu-plugins & other wp-content folders that should be excluded: backup folders, etc.
	bpsSetupWizardARQExcludeDB();

	// AutoRestore/Quarantine pre-check - Create the ARQ exclude filters in class.php & copy class.php to the /master-backups folder
	bpsSetupWizardARQExcludeFile();
	
	// S-Monitor - pre-save these db values so that the Setup Wizard Spinner and BPS Pro Status Display display on first time installations 
	bpsPro_SetupWizard_smonitor_db_values();

	// BPS free MU plugin cleanup
	bspPro_bps_free_mu_files_cleanup();

	// AutoRestore/Quarantine pre-check - Check for sitemap.xml and sitemap.xml.gz if they exist
	if ( file_exists(ABSPATH . 'sitemap.xml') ) {	
		echo $successTextBegin.__('Pass! ARQ Exclude Rule will be created for sitemap file: ', 'bulletproof-security') . ABSPATH . 'sitemap.xml' . $successTextEnd;	
	}
	if ( file_exists(ABSPATH . 'sitemap.xml.gz') ) {	
		echo $successTextBegin.__('Pass! ARQ Exclude Rule will be created for sitemap file: ', 'bulletproof-security') . ABSPATH . 'sitemap.xml.gz' . $successTextEnd;	
	}	
	
	echo '</p></div><br>'; // end AutoRestore|Quarantine Exclude Rules visual section divider

	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:0px;margin-top:10px;">'.__('Plugin Firewall cURL Scan, DB Options & Whitelist Rules', 'bulletproof-security').'</div>';
	echo '<div id="pw-plugin-firewall" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:0px;"><p>';

	// Plugin Firewall cURL Scan - scan up to 50 Pages & Posts - Save Plugin Firewall whitelist rules to DB
	// 11.8: New htaccess files enabled|disabled conditions added in this function.
	// 15.1: Pre-save PFW Roles options.
	bpsSetupWizardPluginFirewall_DB();
	
	echo '</p></div><br>'; // end AutoRestore|Quarantine Exclude Rules visual section divider

	echo '</span>';
	
	$time_end = microtime( true );
	$wizard_run_time = $time_end - $time_start;
	$wizard_time_display = '<strong>Pre-Installation Wizard Completion Time: </strong>'. round( $wizard_run_time, 2 ) . ' Seconds';
	
		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>';
		$text = '<strong><font color="green">'.__('The Pre-Installation Wizard Checks|Scans|Settings have completed.', 'bulletproof-security').'<br>'.__('Scroll down and click the Setup Wizard button if you do not see any errors or displayed messages for things that need to be corrected first before running the Setup Wizard.', 'bulletproof-security').'<br>'.__('Your existing root htaccess file has been backed up here: /wp-content/bps-backup/master-backups/root.htaccess-[Date-Timestamp]. If you run into a problem or need to restore your old root htaccess file do the steps in this forum topic: ', 'bulletproof-security').'</font><a href="https://forum.ait-pro.com/forums/topic/setup-wizard-root-htaccess-file-backup/" target="_blank" style="text-decoration:underline;">'.__('Setup Wizard Root htaccess File Backup', 'bulletproof-security').'</a></strong><br>';
		echo $text;
		echo '</p></div>';
		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 bpsPro_memory_resource_usage();
		echo $wizard_time_display;
		echo '</p></div>';
	echo '</div>';
	}
}
/****************************************/
// END BPS Pro Pre-Installation Wizard
/****************************************/

/**************************/
// BPS Pro Setup Wizard
/**************************/

// BPS Pro Setup Wizard - Fail message
function bpsSetupWizardFail() {
	
	if ( isset( $_POST['Submit-Setup-Wizard'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bps_setup_wizard' );
	
		$PreInstallOptions = get_option('bulletproof_security_options_preinstallation');  

		if ( ! isset($PreInstallOptions['bps_wizard_preinstallation']) || isset($PreInstallOptions['bps_wizard_preinstallation']) && $PreInstallOptions['bps_wizard_preinstallation'] != 'yes' || isset($PreInstallOptions['bps_wizard_preinstallation_61']) && $PreInstallOptions['bps_wizard_preinstallation_61'] != 'yes') {
			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>';
			$text = '<strong><font color="#fb0101">'.__('The Pre-Installation Wizard button must be clicked first before you can click the Setup Wizard button.', 'bulletproof-security').'</font></strong><br>';
			echo $text;
			echo '</p></div>';
		}
	}
}

// BPS Pro Setup Wizard
function bpsSetupWizard() {

if ( isset( $_POST['Submit-Setup-Wizard'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bps_setup_wizard' );
		set_time_limit(300);

global $wpdb, $wp_version, $bpspro_version;
//global $bulletproof_security_arq_db_version;

$time_start = microtime( true );

$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";
$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";

$successTextBegin = '<font color="green"><strong>';
$successMessage = __(' DB Table created Successfully!', 'bulletproof-security');
$successTextEnd = '</strong></font><br>';
$failTextBegin = '<font color="#fb0101"><strong>';
$failMessage = __('Error: Unable to create DB Table ', 'bulletproof-security');
$failTextEnd = '</strong></font><br>';
$HFiles_options = get_option('bulletproof_security_options_htaccess_files');

	// 13.4.1: BPS Pro plugin 30 day review/rating request Dismiss Notice
	$bps_rate_options = 'bulletproof_security_options_rate_pro';
	$gmt_offset = get_option( 'gmt_offset' ) * 3600;
	$bps_pro_rate_review = mktime(0, 0, 0, date("m")+1, date("d")+1, date("Y"));

	$BPS_Rate_Option = array( 'bps_pro_rate_review' => $bps_pro_rate_review + $gmt_offset );

	if ( ! get_option( $bps_rate_options ) ) {	
	
		foreach( $BPS_Rate_Option as $key => $value ) {
			update_option('bulletproof_security_options_rate_pro', $BPS_Rate_Option);
		}
	}

	// Delete the BPS free plugin 30 day review/rating request DB option
	delete_option('bulletproof_security_options_rate_free');
	
	$PreInstallOptions = get_option('bulletproof_security_options_preinstallation');  

	if ( ! isset($PreInstallOptions['bps_wizard_preinstallation']) || isset($PreInstallOptions['bps_wizard_preinstallation']) && $PreInstallOptions['bps_wizard_preinstallation'] != 'yes' || isset($PreInstallOptions['bps_wizard_preinstallation_61']) && $PreInstallOptions['bps_wizard_preinstallation_61'] != 'yes') {
	
	} else {
	
		// Delete the BPS free Setup Wizard DB option
		delete_option('bulletproof_security_options_wizard_free');
	
	echo '<h3>'.__('BPS Pro Setup Verification & Error Checks', 'bulletproof-security').'</h3>';
	echo '<div style="font-size:12px;margin:-10px 0px 10px 0px;font-weight:bold;">'.__('If you see all green font messages displayed below, the Setup Wizard setup completed successfully.', 'bulletproof-security').'<br>'.__('If you see any red font or blue font messages displayed below, click the Read Me help button above and read the "Notes" help section.', 'bulletproof-security').'</div>';
	echo '<div id="Wizard-background" style="max-height:250px;width:85%;overflow:auto;margin-bottom:20px;padding:10px;background-color:#dfecf2;border:2px 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);">';
	
	echo '<span class="setup-wizard-checks-text">';
	
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;">'.__('BulletProof Security Pro Synchronize WordPress Version', 'bulletproof-security').'</div>';
	echo '<div id="SWWPVersion" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';

	// Update BPS DB option - WP version matches the current version of WP & reset the last modified time in DB
	$successMessageWPV = __(' DB Option created or updated Successfully!', 'bulletproof-security');
	$gmt_offset = get_option( 'gmt_offset' ) * 3600;
	$versionphp = ABSPATH . 'wp-includes/version.php';	
	$last_modified_time_versionphp = date("F d Y H:i", filemtime($versionphp) + $gmt_offset);
	$bps_option_name_wpv = 'bulletproof_security_options_wp_version';
	$bps_new_value_wpv = $wp_version;	
	$bps_new_value_wpv1 = date("F d Y H:i", filemtime($versionphp) + $gmt_offset + 900);		
	
	$BPS_Options_wpv = array( 'bps_wp_version' => $bps_new_value_wpv, 'bps_wp_version_last_modified_time' => $bps_new_value_wpv1 );	
	
	if ( ! get_option( $bps_option_name_wpv ) ) {	
		
		foreach( $BPS_Options_wpv as $key => $value ) {
			update_option('bulletproof_security_options_wp_version', $BPS_Options_wpv);
			echo $successTextBegin.$key.$successMessageWPV.$successTextEnd;
		}
	
	} else {

		foreach( $BPS_Options_wpv as $key => $value ) {
			update_option('bulletproof_security_options_wp_version', $BPS_Options_wpv);
			echo $successTextBegin.$key.$successMessageWPV.$successTextEnd;
		}	
	}
	
	echo '</p></div>';
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro Database Tables Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWDBTables" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';
	
	if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $Qtable_name ) ) == $Qtable_name ) {
		echo $successTextBegin.$Qtable_name.$successMessage.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage.$Qtable_name.$failTextEnd;	
	}
	
	if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $Etable_name ) ) == $Etable_name ) {
		echo $successTextBegin.$Etable_name.$successMessage.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage.$Etable_name.$failTextEnd;	
	}
	
	if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $Stable_name ) ) == $Stable_name ) {
		echo $successTextBegin.$Stable_name.$successMessage.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage.$Stable_name.$failTextEnd;	
	}

	if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $Ltable_name ) ) == $Ltable_name ) {
		echo $successTextBegin.$Ltable_name.$successMessage.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage.$Ltable_name.$failTextEnd;	
	}

	if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $DMtable_name ) ) == $DMtable_name ) {
		echo $successTextBegin.$DMtable_name.$successMessage.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage.$DMtable_name.$failTextEnd;	
	}

	if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $DBBtable_name ) ) == $DBBtable_name ) {
		echo $successTextBegin.$DBBtable_name.$successMessage.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage.$DBBtable_name.$failTextEnd;	
	}

	if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $FLtable_name ) ) == $FLtable_name ) {
		echo $successTextBegin.$FLtable_name.$successMessage.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage.$FLtable_name.$failTextEnd;	
	}

	if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $MStable_name ) ) == $MStable_name ) {
		echo $successTextBegin.$MStable_name.$successMessage.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage.$MStable_name.$failTextEnd;	
	}

	echo '</p></div>';	
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro Core Folders Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWFolders" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';
	
	$successMessage2 = __(' Folder created Successfully!', 'bulletproof-security');
	$failMessage2 = __('Error: Unable to create Folder ', 'bulletproof-security');

	if ( is_dir( WP_CONTENT_DIR . '/bps-backup' ) ) {	
		echo $successTextBegin.WP_CONTENT_DIR . '/bps-backup'.$successMessage2.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage2.WP_CONTENT_DIR . '/bps-backup'.$failTextEnd;	
	}	

	if ( is_dir( WP_CONTENT_DIR . '/bps-backup' ) ) {	
		echo $successTextBegin.WP_CONTENT_DIR . '/bps-backup/master-backups'.$successMessage2.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage2.WP_CONTENT_DIR . '/bps-backup/master-backups'.$failTextEnd;	
	}
	
	if ( is_dir( WP_CONTENT_DIR . '/bps-backup/autorestore' ) ) {	
		echo $successTextBegin.WP_CONTENT_DIR . '/bps-backup/autorestore'.$successMessage2.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage2.WP_CONTENT_DIR . '/bps-backup/autorestore'.$failTextEnd;	
	}

	if ( is_dir( WP_CONTENT_DIR . '/bps-backup/quarantine' ) ) {	
		echo $successTextBegin.WP_CONTENT_DIR . '/bps-backup/quarantine'.$successMessage2.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage2.WP_CONTENT_DIR . '/bps-backup/quarantine'.$failTextEnd;	
	}

	if ( is_dir( WP_CONTENT_DIR . '/bps-backup/logs' ) ) {	
		echo $successTextBegin.WP_CONTENT_DIR . '/bps-backup/logs'.$successMessage2.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage2.WP_CONTENT_DIR . '/bps-backup/logs'.$failTextEnd;	
	}

	if ( is_dir( WP_CONTENT_DIR . '/bps-backup/wp-hashes' ) ) {	
		echo $successTextBegin.WP_CONTENT_DIR . '/bps-backup/wp-hashes'.$successMessage2.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage2.WP_CONTENT_DIR . '/bps-backup/wp-hashes'.$failTextEnd;	
	}

	echo '</p></div>';
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro Core Files Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWFiles" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';

	$successMessage3 = __(' File created or updated Successfully!', 'bulletproof-security');
	$failMessage3 = __('Error: Unable to create or update File ', 'bulletproof-security');	
	
	$bps_ARHtaccess = WP_CONTENT_DIR . '/bps-backup/.htaccess';	
	$bps_ARHtaccessM = WP_CONTENT_DIR . '/bps-backup/master-backups/.htaccess';	
	$bps_AutoRestore_LogARQ = WP_CONTENT_DIR . '/bps-backup/logs/autorestore_log.txt';	
	$bpsStringReplaceLogARQ = WP_CONTENT_DIR . '/bps-backup/logs/string_replacer_log.txt';
	$bpsProSecLogARQ = WP_CONTENT_DIR . '/bps-backup/logs/http_error_log.txt';
	$bpsProPHPELogARQ = WP_CONTENT_DIR . '/bps-backup/logs/bps_php_error.log';
	$bpsProDBMLog = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/db_monitor_log.txt';
	$SecurityLogReset = WP_CONTENT_DIR . '/bps-backup/master-backups/Login-Security-Alert-Reset.txt';
	$mscan_log = WP_CONTENT_DIR . '/bps-backup/logs/mscan_log.txt';
	// NOTE: class.php is a special case handle it later

	if ( $HFiles_options['bps_htaccess_files'] != 'disabled' ) {
	
		if ( file_exists($bps_ARHtaccess) ) {
			echo $successTextBegin.$bps_ARHtaccess.$successMessage3.$successTextEnd;
		} else {
			echo $failTextBegin.$failMessage3.$bps_ARHtaccess.$failTextEnd;	
		}
			
		if ( file_exists($bps_ARHtaccessM) ) {
			echo $successTextBegin.$bps_ARHtaccessM.$successMessage3.$successTextEnd;
		} else {
			echo $failTextBegin.$failMessage3.$bps_ARHtaccessM.$failTextEnd;	
		}
	}
	
	if ( file_exists($bps_AutoRestore_LogARQ) ) {
		echo $successTextBegin.$bps_AutoRestore_LogARQ.$successMessage3.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage3.$bps_AutoRestore_LogARQ.$failTextEnd;	
	}	

	if ( file_exists($mscan_log) ) {
		echo $successTextBegin.$mscan_log.$successMessage3.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage3.$mscan_log.$failTextEnd;	
	}

	if ( file_exists($bpsStringReplaceLogARQ) ) {
		echo $successTextBegin.$bpsStringReplaceLogARQ.$successMessage3.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage3.$bpsStringReplaceLogARQ.$failTextEnd;	
	}	

	if ( file_exists($bpsProSecLogARQ) ) {
		echo $successTextBegin.$bpsProSecLogARQ.$successMessage3.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage3.$bpsProSecLogARQ.$failTextEnd;	
	}

	if ( file_exists($bpsProPHPELogARQ) ) {
		echo $successTextBegin.$bpsProPHPELogARQ.$successMessage3.$successTextEnd;
	} else {
		//echo $failTextBegin.$failMessage3.$bpsProPHPELogARQ.$failTextEnd;	
	}

	if ( file_exists($SecurityLogReset) ) {
		echo $successTextBegin.$SecurityLogReset.$successMessage3.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage3.$SecurityLogReset.$failTextEnd;	
	}	
	
	if ( file_exists($bpsProDBMLog) ) {
		echo $successTextBegin.$bpsProDBMLog.$successMessage3.$successTextEnd;
	} else {
		echo $failTextBegin.$failMessage3.$bpsProDBMLog.$failTextEnd;	
	}

	echo '</p></div>';
	
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security MScan Malware Scanner Setup', 'bulletproof-security').'</div>';
	echo '<div id="MScanWizard" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';

	bpsPro_presave_mscan_options();

	echo '</p></div>';

	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security DB Monitor Setup', 'bulletproof-security').'</div>';
	echo '<div id="DBMonitor" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';

	$DBMoptions = get_option('bulletproof_security_options_wizard_curl');
	
	if ( $DBMoptions['bps_wizard_dbm_settings'] == 'Off' ) {
		echo '<strong><font color="blue">'.__('Keep Existing DB Monitor Settings option is selected. DB Monitor settings were not changed.', 'bulletproof-security').'</font></strong><br>';
	} else {
	
		$dbm_successMessage = __(' DB Option created or updated Successfully!', 'bulletproof-security');	
		$bps_dbm_options = 'bulletproof_security_options_db_monitor';
	
		$DBM_Options = array( 
		'bps_db_monitor_cron' 						=> 'On', 
		'bps_db_monitor_cron_frequency' 			=> '15', 
		'bps_db_monitor_cron_table_created_check' 	=> 'On', 
		'bps_db_monitor_cron_end' 					=> time() + 900
		);
	
		if ( ! get_option( $bps_dbm_options ) ) {	
		
			foreach( $DBM_Options as $key => $value ) {
				update_option('bulletproof_security_options_db_monitor', $DBM_Options);
				echo $successTextBegin.$key.$dbm_successMessage.$successTextEnd;	
			}
	
		} else {

			$BPS_DBM_options = get_option('bulletproof_security_options_db_monitor');
		
			$DBM_Options = array( 
			'bps_db_monitor_cron' 						=> $BPS_DBM_options['bps_db_monitor_cron'], 
			'bps_db_monitor_cron_frequency' 			=> $BPS_DBM_options['bps_db_monitor_cron_frequency'], 
			'bps_db_monitor_cron_table_created_check' 	=> $BPS_DBM_options['bps_db_monitor_cron_table_created_check'], 
			'bps_db_monitor_cron_end' 					=> $BPS_DBM_options['bps_db_monitor_cron_end']
			);

			foreach( $DBM_Options as $key => $value ) {
				update_option('bulletproof_security_options_db_monitor', $DBM_Options);
				echo $successTextBegin.$key.$dbm_successMessage.$successTextEnd;	
			}
		}	
		echo $successTextBegin.__('DB Monitor DB Options created or updated Successfully!', 'bulletproof-security').$successTextEnd;
	}
	echo '</p></div>';	

	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security DB Backup Setup', 'bulletproof-security').'</div>';
	echo '<div id="DBBackup" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';

	bpsSetupWizard_dbbackup_folder_check();
	
	echo '</p></div>';
	
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro Uploads Anti-Exploit Guard (UAEG) Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWUAEG" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';

	if ( $HFiles_options['bps_htaccess_files'] == 'disabled' ) {

		$text = '<font color="blue"><strong>'.__('htaccess Files Disabled: Uploads Anti-Exploit Guard (UAEG) htaccess file was not created.', 'bulletproof-security').' '.__('Click this link for help information: ', 'bulletproof-security').'</strong></font><a href="https://forum.ait-pro.com/forums/topic/htaccess-files-disabled-setup-wizard-enable-disable-htaccess-files/" target="_blank" title="htaccess Files Disabled Forum Topic">'.__('htaccess Files Disabled Forum Topic', 'bulletproof-security').'</a><br>';
		echo $text;
	
	} else {

	$bps_Uploads_Dir = wp_upload_dir();
	$UploadsHtaccess = $bps_Uploads_Dir['basedir'] . '/.htaccess';
	$successMessageU = __(' File created or updated Successfully!', 'bulletproof-security');
	$failMessageU = __('Error: Unable to create or update File ', 'bulletproof-security');	

	$GDMW_options = get_option('bulletproof_security_options_GDMW');	
	
	if ( $GDMW_options['bps_gdmw_hosting'] == 'yes' ) {

		$text = '<font color="blue"><strong>'.__('Go Daddy Managed WordPress Hosting requires that you manually activate the BPS Pro Uploads Anti-Exploit Guard (UAEG) on the B-Core Security Modes page.', 'bulletproof-security').'</strong></font>';
		echo $text;
	
	} else {

		if ( is_dir( $bps_Uploads_Dir['basedir'] ) && file_exists($UploadsHtaccess) ) {
			echo $successTextBegin.$UploadsHtaccess.$successMessageU.$successTextEnd;
		} else {
			echo $failTextBegin.$failMessageU.$UploadsHtaccess.$failTextEnd;	
		}	
	}
	}
	
	echo '</p></div>';
	
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro Hidden Plugin Folders|Files (HPF) Setup', 'bulletproof-security').'</div>';
	echo '<div id="HPFoptions" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';
	
	$hpf_successMessage = __(' DB Option created or updated Successfully!', 'bulletproof-security');
	$hpf_cron = get_option('bulletproof_security_options_hpf_cron');

	$hpf_cron1 = ! isset($hpf_cron['bps_hidden_plugins_cron']) ? 'On' : $hpf_cron['bps_hidden_plugins_cron'];
	$hpf_cron2 = ! isset($hpf_cron['bps_hidden_plugins_cron_frequency']) ? '15' : $hpf_cron['bps_hidden_plugins_cron_frequency'];
	$hpf_cron3 = ! isset($hpf_cron['bps_hidden_plugins_cron_email']) ? '' : $hpf_cron['bps_hidden_plugins_cron_email'];
	$hpf_cron4 = ! isset($hpf_cron['bps_hidden_plugins_cron_alert']) ? '' : $hpf_cron['bps_hidden_plugins_cron_alert'];	
		
	$hpf_cron_options = array(
	'bps_hidden_plugins_cron' 			=> $hpf_cron1, 
	'bps_hidden_plugins_cron_frequency' => $hpf_cron2, 
	'bps_hidden_plugins_cron_email' 	=> $hpf_cron3, 
	'bps_hidden_plugins_cron_alert' 	=> $hpf_cron4 
	);

	foreach( $hpf_cron_options as $key => $value ) {
		update_option('bulletproof_security_options_hpf_cron', $hpf_cron_options);
		echo $successTextBegin.$key.$hpf_successMessage.$successTextEnd;
	}	
	
	$hpf_check = get_option('bulletproof_security_options_hidden_plugins');
	$hpf_check1 = ! isset($hpf_check['bps_hidden_plugins_check']) ? '' : $hpf_check['bps_hidden_plugins_check'];
		
	$hpf_check_options = array( 'bps_hidden_plugins_check' => $hpf_check1 );

	foreach( $hpf_check_options as $key => $value ) {
		update_option('bulletproof_security_options_hidden_plugins', $hpf_check_options);
		echo $successTextBegin.$key.$hpf_successMessage.$successTextEnd;
	}	
	
	echo $successTextBegin.__('Hidden Plugin Folders|Files (HPF) DB Options created or updated Successfully!', 'bulletproof-security').$successTextEnd;
	echo '</p></div>';	

	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro Security Log User Agent Filter Setup', 'bulletproof-security').'</div>';
	echo '<div id="SLuserAgentFilter" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';
	bpsSetupWizard_autoupdate_useragent_filters();
	
	// 13|13.2 BugFix: Changed the default option setting to: Do Not Log POST Request Body Data on new BPS installations & upgrades.
	// 11.2: Set Security Log Limit POST Request Body Data option to checked/limited by default
	if ( ! get_option('bulletproof_security_options_sec_log_post_limit') ) {	

		$SecLog_post_limit_settings = array( 
		'bps_security_log_post_limit' 	=> '', 
		'bps_security_log_post_none' 	=> '1', 
		'bps_security_log_post_max' 	=> '' 
		);
			
		foreach( $SecLog_post_limit_settings as $key => $value ) {
			update_option('bulletproof_security_options_sec_log_post_limit', $SecLog_post_limit_settings);
		}
	}

	echo '</p></div>';
	
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro Log Files Database Options Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWDBOptions" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';
	// NOTE: The update_option incorporates add_option and will add the DB option if it does not already exist
	// $failMessage4 = __('Error: Unable to create or update DB Option ', 'bulletproof-security');	
	
	$successMessage4 = __(' DB Option created or updated Successfully!', 'bulletproof-security');

	$bps_option_name1 = 'bulletproof_security_options_ARCM_log';
	$bps_new_value1 = bps_getARCMLogLastMod_wp_secs();
	$BPS_Options1 = array( 'bps_arcm_log_date_mod' => $bps_new_value1 );

	if ( ! get_option( $bps_option_name1 ) ) {	
		update_option('bulletproof_security_options_ARCM_log', $BPS_Options1);
		echo $successTextBegin.$bps_option_name1.$successMessage4.$successTextEnd;
	} else {
		update_option('bulletproof_security_options_ARCM_log', $BPS_Options1);
		echo $successTextBegin.$bps_option_name1.$successMessage4.$successTextEnd;
	}	

	$bps_option_name2 = 'bulletproof_security_options_Security_log';
	$bps_new_value2 = bps_getSecurityLogLastMod_secs();
	$BPS_Options2 = array('bps_security_log_date_mod' => $bps_new_value2);

	if ( ! get_option( $bps_option_name2 ) ) {	
		update_option('bulletproof_security_options_Security_log', $BPS_Options2);
		echo $successTextBegin.$bps_option_name2.$successMessage4.$successTextEnd;
	} else {
		update_option('bulletproof_security_options_Security_log', $BPS_Options2);
		echo $successTextBegin.$bps_option_name2.$successMessage4.$successTextEnd;
	}

	$bps_option_name3 = 'bulletproof_security_options2';
	$bps_new_value3 = addslashes(WP_CONTENT_DIR . '/bps-backup/logs/bps_php_error.log');
	$BPS_Options3 = array('bps_error_log_location' => $bps_new_value3);

	if ( ! get_option( $bps_option_name3 ) ) {	
		update_option('bulletproof_security_options2', $BPS_Options3);
		echo $successTextBegin.$bps_option_name3.$successMessage4.$successTextEnd;
	} else {
		
		$BPS_PHP_Error_Log_Options = get_option('bulletproof_security_options2');
		
		$BPS_Options_php_error_log = array(
		'bps_error_log_location' => $BPS_PHP_Error_Log_Options['bps_error_log_location']
		);

		foreach( $BPS_Options_php_error_log as $key => $value ) {
			update_option('bulletproof_security_options2', $BPS_Options_php_error_log);
			echo $successTextBegin.$bps_option_name3.$successMessage4.$successTextEnd;	
		}		
	}
	
	$bps_option_name4 = 'bulletproof_security_options_elog';
	$bps_new_value4 = bps_getPhpELogLastMod_smonitor();
	$BPS_Options4 = array('bps_error_log_date_mod' => $bps_new_value4);

	if ( ! get_option( $bps_option_name4 ) ) {	
		update_option('bulletproof_security_options_elog', $BPS_Options4);
		echo $successTextBegin.$bps_option_name4.$successMessage4.$successTextEnd;
	} else {
		update_option('bulletproof_security_options_elog', $BPS_Options4);
		echo $successTextBegin.$bps_option_name4.$successMessage4.$successTextEnd;
	}
	
	$bps_option_name_dbm = 'bulletproof_security_options_DBM_log';
	$bps_new_value_dbm = bpsPro_DBM_LogLastMod_wp_secs();
	$BPS_Options_dbm = array( 'bps_dbm_log_date_mod' => $bps_new_value_dbm );

	if ( ! get_option( $bps_option_name_dbm ) ) {	
		update_option('bulletproof_security_options_DBM_log', $BPS_Options_dbm);
		echo $successTextBegin.$bps_option_name_dbm.$successMessage4.$successTextEnd;
	} else {
		update_option('bulletproof_security_options_DBM_log', $BPS_Options_dbm);
		echo $successTextBegin.$bps_option_name_dbm.$successMessage4.$successTextEnd;
	}

	$bps_option_name_dbb = 'bulletproof_security_options_DBB_log';
	$bps_new_value_dbb = bpsPro_DBB_LogLastMod_wp_secs();
	$BPS_Options_dbb = array( 'bps_dbb_log_date_mod' => $bps_new_value_dbb );

	if ( ! get_option( $bps_option_name_dbb ) ) {	
		update_option('bulletproof_security_options_DBB_log', $BPS_Options_dbb);
		echo $successTextBegin.$bps_option_name_dbb.$successMessage4.$successTextEnd;
	} else {
		update_option('bulletproof_security_options_DBB_log', $BPS_Options_dbb);
		echo $successTextBegin.$bps_option_name_dbb.$successMessage4.$successTextEnd;
	}

	$bps_option_name_mscan = 'bulletproof_security_options_MScan_log';
	$bps_new_value_mscan = bpsPro_MScan_LogLastMod_wp_secs();
	$BPS_Options_mscan = array( 'bps_mscan_log_date_mod' => $bps_new_value_mscan );

	if ( ! get_option( $bps_option_name_mscan ) ) {	
		update_option('bulletproof_security_options_MScan_log', $BPS_Options_mscan);
		echo $successTextBegin.$bps_option_name_mscan.$successMessage4.$successTextEnd;
	} else {
		update_option('bulletproof_security_options_MScan_log', $BPS_Options_mscan);
		echo $successTextBegin.$bps_option_name_mscan.$successMessage4.$successTextEnd;
	}

	echo '</p></div>';	
	
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro ini_set Options Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWiniSetOptions" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';	
	
	$successMessage5 = __(' DB Option created or updated Successfully!', 'bulletproof-security');
	
	$bps_option_name5 = 'bulletproof_security_options_iniSet';
	
	$bps_new_value5_2 = addslashes( WP_CONTENT_DIR . '/bps-backup/logs/bps_php_error.log' );
	
	// Parse phpinfo() and return the PHP memory_limit Local Value
	bpsPro_phpinfo_memory_limit_array();

	$bps_php_memory_limit = get_option('bulletproof_security_options_php_memory_limit');

	$pos_memory_limit = strpos( $bps_php_memory_limit['bps_php_memory_limit'], 'Unable to get the PHP memory_limit value from the server' );

	if ( $pos_memory_limit !== false ) {
		$bps_new_value5_4 = '256M';
	} else {
		$bps_new_value5_4 = $bps_php_memory_limit['bps_php_memory_limit'];
	}
	
	$BPS_Options5 = array(
	'bps_iniSet_ErrorReporting' 			=> 'E_ALL|E_STRICT', 
	'bps_iniSet_LogErrors' 					=> 'On', 
	'bps_iniSet_ErrorLog' 					=> $bps_new_value5_2, 
	'bps_iniSet_LogErrorsMaxLen' 			=> '1024', 
	'bps_iniSet_MemoryLimit' 				=> $bps_new_value5_4, 
	'bps_iniSet_session_cookie_httponly' 	=> 'On', 
	'bps_iniSet_session_use_only_cookies' 	=> 'On', 
	'bps_iniSet_session_cookie_secure' 		=> 'Off', 
	'bps_iniSet_IgnoreRepeatedErrors' 		=> 'On', 
	'bps_iniSet_IgnoreRepeatedSource' 		=> 'Off', 
	'bps_iniSet_AllowUrlInclude' 			=> 'Off', 
	'bps_iniSet_DefineSyslogVar' 			=> 'Off', 
	'bps_iniSet_DisplayErrors' 				=> 'Off', 
	'bps_iniSet_DisplayStartupErrors' 		=> 'Off', 
	'bps_iniSet_ImplicitFlush' 				=> 'Off', 
	'bps_iniSet_MagicQuotesRuntime' 		=> 'Off', 
	'bps_iniSet_MaxExecutionTime' 			=> '120', 
	'bps_iniSet_MysqlConnectTimeout' 		=> '30', 
	'bps_iniSet_MysqlTraceMode' 			=> 'Off', 
	'bps_iniSet_ReportMemleaks' 			=> 'On' 
	);

	if ( ! get_option( $bps_option_name5 ) ) {	
		
		foreach( $BPS_Options5 as $key => $value ) {
			update_option('bulletproof_security_options_iniSet', $BPS_Options5);
			echo $successTextBegin.$key.$successMessage5.$successTextEnd;	
		}
	
	} else {

		$BPS_iniset_Options = get_option('bulletproof_security_options_iniSet');

		$BPS_Options_iniset = array(
		'bps_iniSet_ErrorReporting' 			=> $BPS_iniset_Options['bps_iniSet_ErrorReporting'], 
		'bps_iniSet_LogErrors' 					=> $BPS_iniset_Options['bps_iniSet_LogErrors'], 
		'bps_iniSet_ErrorLog' 					=> $BPS_iniset_Options['bps_iniSet_ErrorLog'], 
		'bps_iniSet_LogErrorsMaxLen' 			=> $BPS_iniset_Options['bps_iniSet_LogErrorsMaxLen'], 
		'bps_iniSet_MemoryLimit' 				=> $bps_new_value5_4, 
		'bps_iniSet_session_cookie_httponly' 	=> $BPS_iniset_Options['bps_iniSet_session_cookie_httponly'], 
		'bps_iniSet_session_use_only_cookies' 	=> $BPS_iniset_Options['bps_iniSet_session_use_only_cookies'], 
		'bps_iniSet_session_cookie_secure' 		=> $BPS_iniset_Options['bps_iniSet_session_cookie_secure'], 
		'bps_iniSet_IgnoreRepeatedErrors' 		=> $BPS_iniset_Options['bps_iniSet_IgnoreRepeatedErrors'], 
		'bps_iniSet_IgnoreRepeatedSource' 		=> $BPS_iniset_Options['bps_iniSet_IgnoreRepeatedSource'], 
		'bps_iniSet_AllowUrlInclude' 			=> $BPS_iniset_Options['bps_iniSet_AllowUrlInclude'], 
		'bps_iniSet_DefineSyslogVar' 			=> $BPS_iniset_Options['bps_iniSet_ErrorReporting'], 
		'bps_iniSet_DisplayErrors' 				=> $BPS_iniset_Options['bps_iniSet_DefineSyslogVar'], 
		'bps_iniSet_DisplayStartupErrors' 		=> $BPS_iniset_Options['bps_iniSet_DisplayStartupErrors'], 
		'bps_iniSet_ImplicitFlush' 				=> $BPS_iniset_Options['bps_iniSet_ImplicitFlush'], 
		'bps_iniSet_MagicQuotesRuntime' 		=> $BPS_iniset_Options['bps_iniSet_MagicQuotesRuntime'], 
		'bps_iniSet_MaxExecutionTime' 			=> $BPS_iniset_Options['bps_iniSet_MaxExecutionTime'], 
		'bps_iniSet_MysqlConnectTimeout' 		=> $BPS_iniset_Options['bps_iniSet_MysqlConnectTimeout'], 
		'bps_iniSet_MysqlTraceMode' 			=> $BPS_iniset_Options['bps_iniSet_MysqlTraceMode'], 
		'bps_iniSet_ReportMemleaks' 			=> $BPS_iniset_Options['bps_iniSet_ReportMemleaks'] 
		);

		foreach( $BPS_Options_iniset as $key => $value ) {
			update_option('bulletproof_security_options_iniSet', $BPS_Options_iniset);
			echo $successTextBegin.$key.$successMessage5.$successTextEnd;	
		}
	}	

	$wpconfig = ABSPATH . 'wp-config.php';
	
	if ( ! file_exists($wpconfig) ) {
		echo '<br>'.$failTextBegin.__('A wp-config.php file was NOT found in your website root folder.', 'bulletproof-security').$failTextEnd.__('If you have moved your wp-config.php file to another folder location then you will need to add the BPS Pro ini_set code to your wp-config.php file manually.', 'bulletproof-security').'<br>'.__('The BPS ini_set code can be found in this file /bulletproof-security/admin/php/php-directives-code-for-wp-config. Setup instructions are included in the file.', 'bulletproof-security').'<br>';
	} else {
		bpsSetupWizardIniSetOptions();
	}

	echo '</p></div>';	
	
	// See pwizard-functions.php - bpsPro_SetupWizard_smonitor_db_values() for why PW db values are updated
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro S-Monitor Monitoring and Alerting Options Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWSmonitor" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';	
	
	$successMessage6 = __(' DB Option created or updated Successfully!', 'bulletproof-security');
	
	$bps_option_name6 = 'bulletproof_security_options_monitor';

	$BPS_Options6 = array(
	'bps_first_launch' 				=> 'Off', 
	'bps_security_status' 			=> 'wpOn', 
	'bps_SecLog_entry' 				=> 'Off', 
	'bps_autorestore_status' 		=> 'wpOn', 
	'bps_autorestore_alerts' 		=> 'wpOn', 
	'bps_plugin_firewall_status' 	=> 'wpOn', 
	'bps_UAEG_status' 				=> 'wpOn', 
	'bps_login_security_status' 	=> 'wpOn', 
	'bps_flock_status' 				=> 'wpOn', 
	'bps_HUD_alerts' 				=> 'wpOn', 
	'bps_PHP_ELogLoc_set' 			=> 'wpOn', 
	'bps_PHP_ELog_error' 			=> 'wpOn', 
	'bps_phpini_created' 			=> 'wpOn', 
	'bps_login_security_alerts' 	=> 'wpOn', 
	'bps_jtc_antispam_status' 		=> 'wpOn', 
	'bps_dbm_status' 				=> 'wpOn', 
	'bps_dbm_alerts' 				=> 'Off', 
	'bps_dbb_status' 				=> 'wpOn', 
	'bps_flock_FL_alerts' 			=> 'wpOn', 
	'bps_isl_status' 				=> 'Off', 		
	'bps_ace_status' 				=> 'Off', 
	'bps_mscan_status_display' 		=> 'wpOn' 
	);

	if ( ! get_option( $bps_option_name6 ) ) {	
		
		foreach( $BPS_Options6 as $key => $value ) {
			update_option('bulletproof_security_options_monitor', $BPS_Options6);
			echo $successTextBegin.$key.$successMessage6.$successTextEnd;	
		}
	
	} else {

		$BPS_SM_Options = get_option('bulletproof_security_options_monitor');

		if ( $BPS_SM_Options['bps_SecLog_entry'] == 'PW' && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {
			$bps_sm_value_1 = 'Off';
		} elseif ( $BPS_SM_Options['bps_SecLog_entry'] == 'PW' && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$bps_sm_value_1 = 'Off';
		} else {
			$bps_sm_value_1 = $BPS_SM_Options['bps_SecLog_entry'];
		}			
		
		if ( $BPS_SM_Options['bps_autorestore_status'] == 'PW' ) {
			$bps_sm_value_2 = 'wpOn';	
		} else {
			$bps_sm_value_2 = $BPS_SM_Options['bps_autorestore_status'];
		}

		if ( $BPS_SM_Options['bps_autorestore_alerts'] == 'PW' ) {
			$bps_sm_value_2b = 'wpOn';	
		} else {
			$bps_sm_value_2b = $BPS_SM_Options['bps_autorestore_alerts'];
		}

		if ( $BPS_SM_Options['bps_plugin_firewall_status'] == 'PW' && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {
			$bps_sm_value_3 = 'wpOn';	
		} elseif ( $BPS_SM_Options['bps_plugin_firewall_status'] == 'PW' && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$bps_sm_value_3 = 'Off';
		} else {
			$bps_sm_value_3 = $BPS_SM_Options['bps_plugin_firewall_status'];
		}

		if ( $BPS_SM_Options['bps_UAEG_status'] == 'PW' && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {
			$bps_sm_value_4 = 'wpOn';	
		} elseif ( $BPS_SM_Options['bps_UAEG_status'] == 'PW' && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$bps_sm_value_4 = 'Off';
		} else {
			$bps_sm_value_4 = $BPS_SM_Options['bps_UAEG_status'];
		}

		if ( $BPS_SM_Options['bps_login_security_status'] == 'PW' ) {
			$bps_sm_value_5 = 'wpOn';	
		} else {
			$bps_sm_value_5 = $BPS_SM_Options['bps_login_security_status'];
		}

		if ( $BPS_SM_Options['bps_flock_status'] == 'PW' ) {
			$bps_sm_value_6 = 'wpOn';	
		} else {
			$bps_sm_value_6 = $BPS_SM_Options['bps_flock_status'];
		}

		if ( $BPS_SM_Options['bps_HUD_alerts'] == 'PW' ) {
			$bps_sm_value_7 = 'wpOn';	
		} else {
			$bps_sm_value_7 = $BPS_SM_Options['bps_HUD_alerts'];
		}

		if ( $BPS_SM_Options['bps_PHP_ELogLoc_set'] == 'PW' ) {
			$bps_sm_value_8 = 'wpOn';	
		} else {
			$bps_sm_value_8 = $BPS_SM_Options['bps_PHP_ELogLoc_set'];
		}

		if ( $BPS_SM_Options['bps_PHP_ELog_error'] == 'PW' ) {
			$bps_sm_value_9 = 'wpOn';	
		} else {
			$bps_sm_value_9 = $BPS_SM_Options['bps_PHP_ELog_error'];
		}

		if ( $BPS_SM_Options['bps_phpini_created'] == 'PW' ) {
			$bps_sm_value_10 = 'wpOn';	
		} else {
			$bps_sm_value_10 = $BPS_SM_Options['bps_phpini_created'];
		}

		if ( $BPS_SM_Options['bps_login_security_alerts'] == 'PW' ) {
			$bps_sm_value_11 = 'wpOn';	
		} else {
			$bps_sm_value_11 = $BPS_SM_Options['bps_login_security_alerts'];
		}

		if ( $BPS_SM_Options['bps_jtc_antispam_status'] == 'PW' ) {
			$bps_sm_value_12 = 'wpOn';	
		} else {
			$bps_sm_value_12 = $BPS_SM_Options['bps_jtc_antispam_status'];
		}

		if ( $BPS_SM_Options['bps_dbm_status'] == 'PW' ) {
			$bps_sm_value_13 = 'wpOn';	
		} else {
			$bps_sm_value_13 = $BPS_SM_Options['bps_dbm_status'];
		}

		if ( $BPS_SM_Options['bps_dbb_status'] == 'PW' ) {
			$bps_sm_value_14 = 'wpOn';	
		} else {
			$bps_sm_value_14 = $BPS_SM_Options['bps_dbb_status'];
		}

		if ( $BPS_SM_Options['bps_flock_FL_alerts'] == 'PW' ) {
			$bps_sm_value_15 = 'wpOn';	
		} else {
			$bps_sm_value_15 = $BPS_SM_Options['bps_flock_FL_alerts'];
		}

		if ( $BPS_SM_Options['bps_mscan_status_display'] == 'PW' ) {
			$bps_sm_value_16 = 'wpOn';	
		} else {
			$bps_sm_value_16 = $BPS_SM_Options['bps_mscan_status_display'];
		}

		$BPS_Options_SM = array(
		'bps_first_launch' 				=> 'Off', 
		'bps_security_status' 			=> $BPS_SM_Options['bps_security_status'], 
		'bps_SecLog_entry' 				=> $bps_sm_value_1, 
		'bps_autorestore_status' 		=> $bps_sm_value_2, 
		'bps_autorestore_alerts' 		=> $bps_sm_value_2b, 
		'bps_plugin_firewall_status' 	=> $bps_sm_value_3, 
		'bps_UAEG_status' 				=> $bps_sm_value_4, 
		'bps_login_security_status' 	=> $bps_sm_value_5, 
		'bps_flock_status' 				=> $bps_sm_value_6, 
		'bps_HUD_alerts' 				=> $bps_sm_value_7, 
		'bps_PHP_ELogLoc_set' 			=> $bps_sm_value_8, 
		'bps_PHP_ELog_error' 			=> $bps_sm_value_9, 
		'bps_phpini_created' 			=> $bps_sm_value_10, 
		'bps_login_security_alerts' 	=> $bps_sm_value_11, 
		'bps_jtc_antispam_status' 		=> $bps_sm_value_12, 
		'bps_dbm_status' 				=> $bps_sm_value_13, 
		'bps_dbm_alerts' 				=> $BPS_SM_Options['bps_dbm_alerts'], 
		'bps_dbb_status' 				=> $bps_sm_value_14,  
		'bps_flock_FL_alerts' 			=> $bps_sm_value_15, 	
		'bps_isl_status' 				=> $BPS_SM_Options['bps_isl_status'], 		
		'bps_ace_status' 				=> $BPS_SM_Options['bps_ace_status'], 
		'bps_mscan_status_display' 		=> $bps_sm_value_16 
		);

		foreach( $BPS_Options_SM as $key => $value ) {
			update_option('bulletproof_security_options_monitor', $BPS_Options_SM);
			echo $successTextBegin.$key.$successMessage6.$successTextEnd;	
		}
	}

	echo '</p></div>';	
	
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro S-Monitor Email Alerting & Log File Options Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWSmonitor" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';	
	
	$admin_email = get_option('admin_email');
	$successMessage7 = __(' DB Option created or updated Successfully!', 'bulletproof-security');
	
	$bps_option_name7 = 'bulletproof_security_options_email';

	$BPS_Options7 = array(
	'bps_send_email_to' 			=> $admin_email, 
	'bps_send_email_from' 			=> $admin_email, 
	'bps_send_email_cc' 			=> '', 
	'bps_send_email_bcc' 			=> '', 
	'bps_login_security_email' 		=> 'lockoutOnly', 
	'bps_autorestore_email' 		=> 'yes', 
	'bps_arq_log_size' 				=> '500KB', 
	'bps_arq_log_email' 			=> 'email', 
	'bps_security_log_email' 		=> 'no', 
	'bps_security_log_size' 		=> '500KB', 
	'bps_security_log_emailL' 		=> 'email', 
	'bps_error_log_email' 			=> 'no',  
	'bps_php_log_size' 				=> '500KB', 
	'bps_php_log_email' 			=> 'email',  
	'bps_upgrade_email' 			=> 'yes',  
	'bps_dbm_email' 				=> 'no', 
	'bps_dbm_log_email' 			=> 'email', 
	'bps_dbm_log_size' 				=> '500KB',  
	'bps_dbb_log_email' 			=> 'email', 
	'bps_dbb_log_size' 				=> '500KB', 
	'bps_flock_email' 				=> 'yes', 
	'bps_arq_cron_frequency_email' 	=> '15', 
	'bps_arq_cron_next_email' 		=> '0', 
	'bps_hpf_email' 				=> 'yes', 
	'bps_mscan_email' 				=> 'yes', 
	'bps_mscan_log_size' 			=> '500KB', 
	'bps_mscan_log_email' 			=> 'email', 
	'bps_plugin_updates_frequency' 	=> '1Hour', 
	'bps_plugin_updates_email' 		=> 'no',
	'bps_theme_updates_frequency' 	=> '1Hour',
	'bps_theme_updates_email' 		=> 'no' 
	);

	if ( ! get_option( $bps_option_name7 ) ) {	
		
		foreach( $BPS_Options7 as $key => $value ) {
			update_option('bulletproof_security_options_email', $BPS_Options7);
			echo $successTextBegin.$key.$successMessage7.$successTextEnd;	
		}
	
	} else {

		$BPS_SMEmail_Options = get_option('bulletproof_security_options_email');
		
		## Note: Figure out why these vars are blank after Setup Wizard first run.
		$bps_hpf_email = isset($BPS_SMEmail_Options['bps_hpf_email']) ? $BPS_SMEmail_Options['bps_hpf_email'] : '';
		$bps_mscan_email = isset($BPS_SMEmail_Options['bps_mscan_email']) ? $BPS_SMEmail_Options['bps_mscan_email'] : '';		
		$bps_mscan_log_size = isset($BPS_SMEmail_Options['bps_mscan_log_size']) ? $BPS_SMEmail_Options['bps_mscan_log_size'] : '';
		$bps_mscan_log_email = isset($BPS_SMEmail_Options['bps_mscan_log_email']) ? $BPS_SMEmail_Options['bps_mscan_log_email'] : '';

		$BPS_Options_smemail = array(
		'bps_send_email_to' 			=> $BPS_SMEmail_Options['bps_send_email_to'], 
		'bps_send_email_from' 			=> $BPS_SMEmail_Options['bps_send_email_from'], 
		'bps_send_email_cc' 			=> $BPS_SMEmail_Options['bps_send_email_cc'], 
		'bps_send_email_bcc' 			=> $BPS_SMEmail_Options['bps_send_email_bcc'], 
		'bps_login_security_email' 		=> $BPS_SMEmail_Options['bps_login_security_email'], 
		'bps_autorestore_email' 		=> $BPS_SMEmail_Options['bps_autorestore_email'], 
		'bps_arq_log_size' 				=> $BPS_SMEmail_Options['bps_arq_log_size'], 
		'bps_arq_log_email' 			=> $BPS_SMEmail_Options['bps_arq_log_email'], 
		'bps_security_log_email' 		=> $BPS_SMEmail_Options['bps_security_log_email'], 
		'bps_security_log_size' 		=> $BPS_SMEmail_Options['bps_security_log_size'], 
		'bps_security_log_emailL' 		=> $BPS_SMEmail_Options['bps_security_log_emailL'], 
		'bps_error_log_email' 			=> $BPS_SMEmail_Options['bps_error_log_email'],  
		'bps_php_log_size' 				=> $BPS_SMEmail_Options['bps_php_log_size'], 
		'bps_php_log_email' 			=> $BPS_SMEmail_Options['bps_php_log_email'],  
		'bps_upgrade_email' 			=> $BPS_SMEmail_Options['bps_upgrade_email'],  
		'bps_dbm_email' 				=> $BPS_SMEmail_Options['bps_dbm_email'], 
		'bps_dbm_log_email' 			=> $BPS_SMEmail_Options['bps_dbm_log_email'], 
		'bps_dbm_log_size' 				=> $BPS_SMEmail_Options['bps_dbm_log_size'],  
		'bps_dbb_log_email' 			=> $BPS_SMEmail_Options['bps_dbb_log_email'], 
		'bps_dbb_log_size' 				=> $BPS_SMEmail_Options['bps_dbb_log_size'], 
		'bps_flock_email' 				=> $BPS_SMEmail_Options['bps_flock_email'], 
		'bps_arq_cron_frequency_email' 	=> $BPS_SMEmail_Options['bps_arq_cron_frequency_email'], 
		'bps_arq_cron_next_email' 		=> $BPS_SMEmail_Options['bps_arq_cron_next_email'], 
		'bps_hpf_email' 				=> $bps_hpf_email, 
		'bps_mscan_email' 				=> $bps_mscan_email, 
		'bps_mscan_log_size' 			=> $bps_mscan_log_size, 
		'bps_mscan_log_email' 			=> $bps_mscan_log_email, 
		'bps_plugin_updates_frequency' 	=> $BPS_SMEmail_Options['bps_plugin_updates_frequency'], 
		'bps_plugin_updates_email' 		=> $BPS_SMEmail_Options['bps_plugin_updates_email'],
		'bps_theme_updates_frequency' 	=> $BPS_SMEmail_Options['bps_theme_updates_frequency'],
		'bps_theme_updates_email' 		=> $BPS_SMEmail_Options['bps_theme_updates_email'] 
		);

		foreach( $BPS_Options_smemail as $key => $value ) {
			update_option('bulletproof_security_options_email', $BPS_Options_smemail);
			echo $successTextBegin.$key.$successMessage7.$successTextEnd;	
		}
	}

	echo '</p></div>';	
	
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro Login Security & Monitoring Options Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWLoginSecurity" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';	
	
	$successMessage8 = __(' DB Option created or updated Successfully!', 'bulletproof-security');

	$bps_option_name8 = 'bulletproof_security_options_login_security';
	$BPS_LSM_Options = get_option('bulletproof_security_options_login_security');
	$woo_plugin = 'woocommerce/woocommerce.php';
	$woo_plugin_active = in_array( $woo_plugin, apply_filters('active_plugins', get_option('active_plugins')));
	
	// 13.2: BugFix: Enable Login Security for WooCommerce option being reset on rerun. Only enable once if the option does not exist.
	if ( $woo_plugin_active == 1 || is_plugin_active_for_network( $woo_plugin ) ) {
		// 12.6: New installations of BPS Pro should not display the WooCommerce Enable LSM & JTC options Dismiss Notice if WooCommerce is already installed.
		$bps_woo_lsm_jtc_options = array( 'bps_wizard_woo' => '1' );

		if ( $BPS_LSM_Options['bps_enable_lsm_woocommerce'] == '' || $BPS_LSM_Options['bps_enable_lsm_woocommerce'] == '1' ) {
			$bps_enable_lsm_woocommerce = $BPS_LSM_Options['bps_enable_lsm_woocommerce'];
		} elseif ( ! $BPS_LSM_Options['bps_enable_lsm_woocommerce'] ) {
			$bps_enable_lsm_woocommerce = '1';
		}

	} else {
		$bps_enable_lsm_woocommerce = '';
		$bps_woo_lsm_jtc_options = array( 'bps_wizard_woo' => '' );
	}

	foreach( $bps_woo_lsm_jtc_options as $key => $value ) {
		update_option('bulletproof_security_options_setup_wizard_woo', $bps_woo_lsm_jtc_options);
	}		

	$BPS_Options8 = array(
	'bps_max_logins' 				=> '3', 
	'bps_lockout_duration' 			=> '15', 
	'bps_manual_lockout_duration' 	=> '60', 
	'bps_max_db_rows_display' 		=> '', 
	'bps_login_security_OnOff' 		=> 'On', 
	'bps_login_security_logging' 	=> 'logLockouts', 
	'bps_login_security_errors' 	=> 'wpErrors', 
	'bps_login_security_remaining' 	=> 'On', 
	'bps_login_security_pw_reset' 	=> 'enable',  
	'bps_login_security_sort' 		=> 'ascending', 
	'bps_enable_lsm_woocommerce' 	=> $bps_enable_lsm_woocommerce 
	);

	if ( ! get_option( $bps_option_name8 ) ) {	
		
		foreach( $BPS_Options8 as $key => $value ) {
			update_option('bulletproof_security_options_login_security', $BPS_Options8);
			echo $successTextBegin.$key.$successMessage8.$successTextEnd;	
		}
	
	} else {

		$BPS_Options_lsm = array(
		'bps_max_logins' 				=> $BPS_LSM_Options['bps_max_logins'], 
		'bps_lockout_duration' 			=> $BPS_LSM_Options['bps_lockout_duration'], 
		'bps_manual_lockout_duration' 	=> $BPS_LSM_Options['bps_manual_lockout_duration'], 
		'bps_max_db_rows_display' 		=> $BPS_LSM_Options['bps_max_db_rows_display'], 
		'bps_login_security_OnOff' 		=> $BPS_LSM_Options['bps_login_security_OnOff'], 
		'bps_login_security_logging' 	=> $BPS_LSM_Options['bps_login_security_logging'], 
		'bps_login_security_errors' 	=> $BPS_LSM_Options['bps_login_security_errors'], 
		'bps_login_security_remaining' 	=> $BPS_LSM_Options['bps_login_security_remaining'], 
		'bps_login_security_pw_reset' 	=> $BPS_LSM_Options['bps_login_security_pw_reset'],  
		'bps_login_security_sort' 		=> $BPS_LSM_Options['bps_login_security_sort'], 
		'bps_enable_lsm_woocommerce' 	=> $bps_enable_lsm_woocommerce 
		);

		foreach( $BPS_Options_lsm as $key => $value ) {
			update_option('bulletproof_security_options_login_security', $BPS_Options_lsm);
			echo $successTextBegin.$key.$successMessage8.$successTextEnd;	
		}
	}	
	
	$bps_option_name9 = 'bulletproof_security_options_login_alerts';
	$bps_new_value9 = bps_SWLoginSecurityResetFileLastMod();
	$BPS_Options9 = array('bps_login_security_db_mod_time' => $bps_new_value9);

	if ( ! get_option( $bps_option_name9 ) ) {	
		update_option('bulletproof_security_options_login_alerts', $BPS_Options9);
		echo $successTextBegin.$bps_option_name9.$successMessage8.$successTextEnd;
	} else {
		update_option('bulletproof_security_options_login_alerts', $BPS_Options9);
		echo $successTextBegin.$bps_option_name9.$successMessage8.$successTextEnd;
	}	
	
	// 15.1: Network subsites create|update all subsite LSM DB options
	if ( is_multisite() ) {
		bpsPro_network_subsites_lsm_settings();
	}

	echo '</p></div>';	
	
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro JTC Anti-Spam|Anti-Hacker Options Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWJTC-Anti-Spam" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';

	$bps_option_name9b = 'bulletproof_security_options_login_security_jtc';
	$successMessage9b = __(' DB Option created or updated Successfully!', 'bulletproof-security');
	$jtc_options = get_option('bulletproof_security_options_login_security_jtc'); 
	
	if ( has_action('bp_after_signup_profile_fields') && has_action('bp_signup_validate') && has_action('bp_sidebar_login_form') ) {
		$bps_jtc_buddypress_register_form = '1';
		$bps_jtc_buddypress_sidebar_form = '1';
	} else {
		$bps_jtc_buddypress_register_form = '0';
		$bps_jtc_buddypress_sidebar_form = '0';
	}

	if ( ! isset($jtc_options['bps_jtc_custom_roles']) ) {
			$bps_jtc_custom_roles = array( 'bps', '' );
		
	} else {

		foreach ( $jtc_options as $key => $value ) {
		
			if ( $key == 'bps_jtc_custom_roles' ) {
					
				if ( ! is_array($value) ) {
					$bps_jtc_custom_roles = array( 'bps', '' );
				} else { 
					$bps_jtc_custom_roles = $jtc_options['bps_jtc_custom_roles'];
				}
			}
		}
	}
	
	// 13.5: Added new JTC option: bps_jtc_mu_register_form. Default for standard site is: 0 and MU is: 1 on new installations.
	// 13.4.1: Added new JTC option: bps_jtc_custom_form_error. Defaults to standard JTC CAPTCHA error message.
	// 13.2: BugFix: Enable JTC for WooCommerce option being reset on rerun. Only enable once if the option does not exist.
	// 13.3: BugFix: JTC options being reset on Setup Wizard rerun - ternary should not be used here - reverted to WP standard ! get_option.
	if ( $woo_plugin_active == 1 || is_plugin_active_for_network( $woo_plugin ) ) {
		if ( $jtc_options['bps_enable_jtc_woocommerce'] == '' || $jtc_options['bps_enable_jtc_woocommerce'] == '1' ) {
			$bps_enable_jtc_woocommerce = $jtc_options['bps_enable_jtc_woocommerce'];
		} elseif ( ! $jtc_options['bps_enable_jtc_woocommerce'] ) {
			$bps_enable_jtc_woocommerce = '1';
		}
	} else {
		$bps_enable_jtc_woocommerce = '';
	}

	$bps_jtc_custom_form_error = ! isset($jtc_options['bps_jtc_custom_form_error']) ? '' : $jtc_options['bps_jtc_custom_form_error'];
	
	if ( is_multisite() ) {
		$bps_jtc_mu_register_form = '1';
	} else {
		$bps_jtc_mu_register_form = '0';
	}

	$jtc_db_options_new = array(
	'bps_tooltip_captcha_key' 			=> 'jtc', 
	'bps_tooltip_captcha_hover_text' 	=> 'Type/Enter:  jtc', 
	'bps_tooltip_captcha_title' 		=> 'Hover or click the text box below', 
	'bps_tooltip_captcha_logging' 		=> 'On', 
	'bps_jtc_login_form' 				=> '1', 
	'bps_jtc_register_form' 			=> '1', 
	'bps_jtc_lostpassword_form' 		=> '1', 
	'bps_jtc_comment_form' 				=> '0', 
	'bps_jtc_mu_register_form' 			=> $bps_jtc_mu_register_form, 
	'bps_jtc_buddypress_register_form' 	=> $bps_jtc_buddypress_register_form, 
	'bps_jtc_buddypress_sidebar_form' 	=> $bps_jtc_buddypress_sidebar_form, 
	'bps_jtc_administrator' 			=> '0', 
	'bps_jtc_editor' 					=> '0', 
	'bps_jtc_author' 					=> '0', 
	'bps_jtc_contributor' 				=> '0', 
	'bps_jtc_subscriber' 				=> '0', 
	'bps_jtc_comment_form_error' 		=> '', 
	'bps_jtc_comment_form_label' 		=> '', 
	'bps_jtc_comment_form_input' 		=> '', 
	'bps_jtc_custom_roles' 				=> $bps_jtc_custom_roles, 
	'bps_enable_jtc_woocommerce' 		=> $bps_enable_jtc_woocommerce, 
	'bps_jtc_custom_form_error' 		=> $bps_jtc_custom_form_error 
	);

	if ( ! get_option( $bps_option_name9b ) ) {	
		
		foreach( $jtc_db_options_new as $key => $value ) {
			update_option('bulletproof_security_options_login_security_jtc', $jtc_db_options_new);
			echo $successTextBegin.$key.$successMessage9b.$successTextEnd;	
		}
	
	} else {

		$jtc_db_options = array(
		'bps_tooltip_captcha_key' 			=> $jtc_options['bps_tooltip_captcha_key'], 
		'bps_tooltip_captcha_hover_text' 	=> $jtc_options['bps_tooltip_captcha_hover_text'], 
		'bps_tooltip_captcha_title' 		=> $jtc_options['bps_tooltip_captcha_title'], 
		'bps_tooltip_captcha_logging' 		=> $jtc_options['bps_tooltip_captcha_logging'], 
		'bps_jtc_login_form' 				=> $jtc_options['bps_jtc_login_form'], 
		'bps_jtc_register_form' 			=> $jtc_options['bps_jtc_register_form'], 
		'bps_jtc_lostpassword_form' 		=> $jtc_options['bps_jtc_lostpassword_form'], 
		'bps_jtc_comment_form' 				=> $jtc_options['bps_jtc_comment_form'], 
		'bps_jtc_mu_register_form' 			=> $jtc_options['bps_jtc_mu_register_form'], 
		'bps_jtc_buddypress_register_form' 	=> $jtc_options['bps_jtc_buddypress_register_form'], 
		'bps_jtc_buddypress_sidebar_form' 	=> $jtc_options['bps_jtc_buddypress_sidebar_form'], 
		'bps_jtc_administrator' 			=> $jtc_options['bps_jtc_administrator'], 
		'bps_jtc_editor' 					=> $jtc_options['bps_jtc_editor'], 
		'bps_jtc_author' 					=> $jtc_options['bps_jtc_author'], 
		'bps_jtc_contributor' 				=> $jtc_options['bps_jtc_contributor'], 
		'bps_jtc_subscriber' 				=> $jtc_options['bps_jtc_subscriber'], 
		'bps_jtc_comment_form_error' 		=> $jtc_options['bps_jtc_comment_form_error'], 
		'bps_jtc_comment_form_label' 		=> $jtc_options['bps_jtc_comment_form_label'], 
		'bps_jtc_comment_form_input' 		=> $jtc_options['bps_jtc_comment_form_input'], 
		'bps_jtc_custom_roles' 				=> $bps_jtc_custom_roles, 
		'bps_enable_jtc_woocommerce' 		=> $bps_enable_jtc_woocommerce, 
		'bps_jtc_custom_form_error' 		=> $bps_jtc_custom_form_error 
		);
	
		foreach( $jtc_db_options as $key => $value ) {
			update_option('bulletproof_security_options_login_security_jtc', $jtc_db_options);
			echo $successTextBegin.$key.$successMessage9b.$successTextEnd;
		}
	}
	
	// 15.1: Network subsites create|update all subsite JTC DB options
	if ( is_multisite() ) {
		bpsPro_network_subsites_jtc_settings();
	}

	echo '</p></div>';	
	
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro Force Strong Passwords Options Setup', 'bulletproof-security').'</div>';
	echo '<div id="SW-FSP" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';	
	
	$successMessage_fsp = __(' DB Option created or updated Successfully!', 'bulletproof-security');

	$bps_option_name_fsp = 'bulletproof_security_options_fsp';
	$FSP_Message = 'Password must contain 1 lowercase letter, 1 uppercase letter, 1 number, 1 special character and be a minimum of 12 characters long.';

	$BPS_FSP_Options = array(
	'bps_fsp_on_off' 		=> 'Off', 
	'bps_fsp_char_length' 	=> '12', 
	'bps_fsp_lower_case' 	=> '1', 
	'bps_fsp_upper_case' 	=> '1', 
	'bps_fsp_number' 		=> '1', 
	'bps_fsp_special_char' 	=> '1', 
	'bps_fsp_message' 		=> $FSP_Message  
	);

	if ( ! get_option( $bps_option_name_fsp ) ) {	
		
		foreach( $BPS_FSP_Options as $key => $value ) {
			update_option('bulletproof_security_options_fsp', $BPS_FSP_Options);
			echo $successTextBegin.$key.$successMessage_fsp.$successTextEnd;	
		}
	
	} else {

		$BPS_FSP_Options = get_option('bulletproof_security_options_fsp');

		$BPS_Options_fsp = array(
		'bps_fsp_on_off' 		=> $BPS_FSP_Options['bps_fsp_on_off'], 
		'bps_fsp_char_length' 	=> $BPS_FSP_Options['bps_fsp_char_length'], 
		'bps_fsp_lower_case' 	=> $BPS_FSP_Options['bps_fsp_lower_case'], 
		'bps_fsp_upper_case' 	=> $BPS_FSP_Options['bps_fsp_upper_case'], 
		'bps_fsp_number' 		=> $BPS_FSP_Options['bps_fsp_number'], 
		'bps_fsp_special_char' 	=> $BPS_FSP_Options['bps_fsp_special_char'], 
		'bps_fsp_message' 		=> $BPS_FSP_Options['bps_fsp_message'] 
		);

		foreach( $BPS_Options_fsp as $key => $value ) {
			update_option('bulletproof_security_options_fsp', $BPS_Options_fsp);
			echo $successTextBegin.$key.$successMessage_fsp.$successTextEnd;	
		}
	}	
	
	if ( is_multisite() ) {
		bpsPro_network_subsites_fsp_settings();
	}

	echo '</p></div>';

	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro F-Lock Options Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWFlock" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';	
	
	$successMessage10 = __(' DB Option created or updated Successfully!', 'bulletproof-security');
	$sapi_type = php_sapi_name();	
	$bps_option_name10 = 'bulletproof_security_options_flock';
	$bps_option_name10A = 'bulletproof_security_options_autolock';
	
	$SWflockPreCheck = get_option('bulletproof_security_options_setup_wizard_flock');
	$fl_override_options = get_option('bulletproof_security_options_flock_eol');

	// 14.9: New File Override condition added
	if ( @substr($sapi_type, 0, 6) == 'apache' || $SWflockPreCheck['bps_wizard_root_htaccess_flock'] == 'no' || $HFiles_options['bps_htaccess_files'] == 'disabled' || $fl_override_options['bps_file_lock_override'] == 'Off' ) {

		$BPS_Options10 = array(
		'bps_lock_root_htaccess' 		=> 'off', 
		'bps_lock_wpconfig' 			=> 'off', 
		'bps_lock_index_php' 			=> 'off', 
		'bps_lock_wpblog_header' 		=> 'off', 
		'bps_lock_root_htaccess_dr' 	=> 'off', 
		'bps_lock_index_php_dr' 		=> 'off', 
		'bps_lock_root_htaccess_gwiod' 	=> 'off', 
		'bps_lock_index_php_gwiod' 		=> 'off' 
		);
	
		foreach( $BPS_Options10 as $key => $value ) {
			update_option('bulletproof_security_options_flock', $BPS_Options10);
			echo $successTextBegin.$key.$successMessage10.$successTextEnd;	
		}

		// AutoLock turned Off
		$BPS_Options10A = array( 'bps_root_htaccess_autolock' => 'Off' );
	
		if ( ! get_option( $bps_option_name10A ) ) {	
			
			foreach( $BPS_Options10A as $key => $value ) {
				update_option('bulletproof_security_options_autolock', $BPS_Options10A);
				echo $successTextBegin.$key.$successMessage10.$successTextEnd;	
			}
		
		} else {
			
			$AutoLock_options = get_option('bulletproof_security_options_autolock');
			$BPS_AutoLock_Options = array('bps_root_htaccess_autolock' => $AutoLock_options['bps_root_htaccess_autolock']); 
	
			foreach( $BPS_AutoLock_Options as $key => $value ) {
				update_option('bulletproof_security_options_autolock', $BPS_AutoLock_Options);
				echo $successTextBegin.$key.$successMessage10.$successTextEnd;	
			}
		}	
	} // end if ( @substr($sapi_type, 0, 6) == 'apache'...

	if ( @substr($sapi_type, 0, 6) != 'apache' && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {

		// 14.9: New File Lock Override condition added
		if ( $fl_override_options['bps_file_lock_override'] == 'On' && $SWflockPreCheck['bps_wizard_root_htaccess_flock'] == 'yes' ) {
			
			$BPS_Options10 = array(
			'bps_lock_root_htaccess' 		=> 'yes', 
			'bps_lock_wpconfig' 			=> 'yes', 
			'bps_lock_index_php' 			=> 'yes', 
			'bps_lock_wpblog_header' 		=> 'yes', 
			'bps_lock_root_htaccess_dr' 	=> 'off', 
			'bps_lock_index_php_dr' 		=> 'off', 
			'bps_lock_root_htaccess_gwiod' 	=> 'off', 
			'bps_lock_index_php_gwiod' 		=> 'off' 
			);
		
			if ( ! get_option( $bps_option_name10 ) ) {	
				
				foreach( $BPS_Options10 as $key => $value ) {
					update_option('bulletproof_security_options_flock', $BPS_Options10);
					echo $successTextBegin.$key.$successMessage10.$successTextEnd;	
				}
			
			} else {
		
				$Flock_options = get_option('bulletproof_security_options_flock');
		
				$BPS_flock_Options = array(
				'bps_lock_root_htaccess' 		=> $Flock_options['bps_lock_root_htaccess'], 
				'bps_lock_wpconfig' 			=> $Flock_options['bps_lock_wpconfig'], 
				'bps_lock_index_php' 			=> $Flock_options['bps_lock_index_php'], 
				'bps_lock_wpblog_header' 		=> $Flock_options['bps_lock_wpblog_header'], 
				'bps_lock_root_htaccess_dr' 	=> $Flock_options['bps_lock_root_htaccess_dr'], 
				'bps_lock_index_php_dr' 		=> $Flock_options['bps_lock_index_php_dr'], 
				'bps_lock_root_htaccess_gwiod' 	=> $Flock_options['bps_lock_root_htaccess_gwiod'], 
				'bps_lock_index_php_gwiod' 		=> $Flock_options['bps_lock_index_php_gwiod'] 
				);
		
				foreach( $BPS_flock_Options as $key => $value ) {
					update_option('bulletproof_security_options_flock', $BPS_flock_Options);
					echo $successTextBegin.$key.$successMessage10.$successTextEnd;	
				}
			}	
		}
		
		// AutoLock option
		$BPS_Options10A = array( 'bps_root_htaccess_autolock' => 'On' );
	
		if ( ! get_option( $bps_option_name10A ) ) {	
			
			foreach( $BPS_Options10A as $key => $value ) {
				update_option('bulletproof_security_options_autolock', $BPS_Options10A);
				echo $successTextBegin.$key.$successMessage10.$successTextEnd;	
			}
		
		} else {
	
			$AutoLock_options = get_option('bulletproof_security_options_autolock');
			$BPS_AutoLock_Options = array('bps_root_htaccess_autolock' => $AutoLock_options['bps_root_htaccess_autolock']); 
	
			foreach( $BPS_AutoLock_Options as $key => $value ) {
				update_option('bulletproof_security_options_autolock', $BPS_AutoLock_Options);
				echo $successTextBegin.$key.$successMessage10.$successTextEnd;	
			}
		}	
	} // end if ( @substr($sapi_type, 0, 6) != 'apache'...

	$bps_option_name10FL = 'bulletproof_security_options_flock_FL';
	
	$BPS_Options10FL = array(
	'bps_folder_lock_cron' 				=> 'Off', 
	'bps_folder_lock_cron_frequency' 	=> '2', 
	'bps_folder_lock_cron_end' 			=> time() + 120 
	);

	if ( ! get_option( $bps_option_name10FL ) ) {	
		
		foreach( $BPS_Options10FL as $key => $value ) {
			update_option('bulletproof_security_options_flock_FL', $BPS_Options10FL);
			echo $successTextBegin.$key.$successMessage10.$successTextEnd;	
		}
	
	} else {

		$BPS_FLock_Options = get_option('bulletproof_security_options_flock_FL');
		
		$BPS_Options_flock = array(
		'bps_folder_lock_cron' 				=> $BPS_FLock_Options['bps_folder_lock_cron'], 
		'bps_folder_lock_cron_frequency' 	=> $BPS_FLock_Options['bps_folder_lock_cron_frequency'], 
		'bps_folder_lock_cron_end' 			=> $BPS_FLock_Options['bps_folder_lock_cron_end'] 
		);

		foreach( $BPS_Options_flock as $key => $value ) {
			update_option('bulletproof_security_options_flock_FL', $BPS_Options_flock);
			echo $successTextBegin.$key.$successMessage10.$successTextEnd;	
		}
	}	

	$bps_option_name10AF = 'bulletproof_security_options_flock_FL_alerts';
	$bps_new_value10AF = bps_SWFolderLockResetFileLastMod();
	$BPS_Options10AF = array('bps_folderlock_db_mod_time' => $bps_new_value10AF);

	if ( ! get_option( $bps_option_name10AF ) ) {	
		update_option('bulletproof_security_options_flock_FL_alerts', $BPS_Options10AF);
		echo $successTextBegin.$bps_option_name10AF.$successMessage10.$successTextEnd;
	} else {
		update_option('bulletproof_security_options_flock_FL_alerts', $BPS_Options10AF);
		echo $successTextBegin.$bps_option_name10AF.$successMessage10.$successTextEnd;
	}

	bpsPro_SWizard_flock_folder_scan();
	echo $successTextBegin.__(' F-Lock Folder Lock Hosting Account Root Folder Scan Run', 'bulletproof-security').$successTextEnd;

	echo '</p></div>';	
	
	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro Plugin Firewall Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWPluginFirewall" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';	

	$successMessage10B = __(' DB Option created or updated Successfully!', 'bulletproof-security');
	$pfwap_options = 'bulletproof_security_options_pfw_autopilot';
	
	if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
	
		$BPS_PFW_OnOff = array( 'bps_pfw_on_off' => 'Off' );		
			
		foreach( $BPS_PFW_OnOff as $key => $value ) {
			update_option('bulletproof_security_options_pfw', $BPS_PFW_OnOff);
		}
		
		$BPS_PFWAP_Options = array( 
		'bps_pfw_autopilot_cron' 			=> 'On', 
		'bps_pfw_autopilot_cron_frequency' 	=> '10',  	
		'bps_pfw_autopilot_cron_end' 		=> time() + 900 
		);		
	
		foreach( $BPS_PFWAP_Options as $key => $value ) {
			update_option('bulletproof_security_options_pfw_autopilot', $BPS_PFWAP_Options);
		}

		$text = '<font color="blue"><strong>'.__('htaccess Files Disabled: Plugin Firewall htaccess file was not created.', 'bulletproof-security').' '.__('Click this link for help information: ', 'bulletproof-security').'</strong></font><a href="https://forum.ait-pro.com/forums/topic/htaccess-files-disabled-setup-wizard-enable-disable-htaccess-files/" target="_blank" title="htaccess Files Disabled Forum Topic">'.__('htaccess Files Disabled Forum Topic', 'bulletproof-security').'</a><br>';
		echo $text;		
	}

	if ( ! get_option( $pfwap_options ) ) {	
		
		$BPS_PFWAP_Options = array( 
		'bps_pfw_autopilot_cron' 			=> 'On',  
		'bps_pfw_autopilot_cron_frequency' 	=> '10',  	
		'bps_pfw_autopilot_cron_end' 		=> time() + 900 
		);
		
		foreach( $BPS_PFWAP_Options as $key => $value ) {
			update_option('bulletproof_security_options_pfw_autopilot', $BPS_PFWAP_Options);
			
			if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {
				echo $successTextBegin.$key.$successMessage10B.$successTextEnd;
			}
		}
	
	} else {

		// If htaccess files are disabled then the db option values have already been updated above
		$PFWAP_options = get_option('bulletproof_security_options_pfw_autopilot');
		
		$BPS_PFWAP_Options = array( 
		'bps_pfw_autopilot_cron' 			=> $PFWAP_options['bps_pfw_autopilot_cron'],  
		'bps_pfw_autopilot_cron_frequency' 	=> $PFWAP_options['bps_pfw_autopilot_cron_frequency'],  	
		'bps_pfw_autopilot_cron_end' 		=> $PFWAP_options['bps_pfw_autopilot_cron_end'] 
		);

		foreach( $BPS_PFWAP_Options as $key => $value ) {
			update_option('bulletproof_security_options_pfw_autopilot', $BPS_PFWAP_Options);
			
			if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {			
				echo $successTextBegin.$key.$successMessage10B.$successTextEnd;
			}
		}
	}	
	
	if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {
		echo $successTextBegin.__('Plugin Firewall AutoPilot Mode DB Options created or updated Successfully!', 'bulletproof-security').$successTextEnd;
	}
	
	bpsSetupWizardPluginFirewall_File();
	
	// Custom Code - no echo/output: pre-save CC DB options for Custom Code Export|Import features ONLY if DB options do not exist
	bpsSetupWizardCustomCodePresave();

	echo '</p></div>';	

	echo '<div style="color:black;font-size:1.13em;font-weight:bold;margin-bottom:15px;padding-top:2px;">'.__('BulletProof Security Pro AutoRestore|Quarantine Final Setup', 'bulletproof-security').'</div>';
	echo '<div id="SWAutoRestore" style="border-top:3px solid #999999;border-bottom:3px solid #999999;margin-top:-10px;"><p>';		

	echo $successTextBegin.__('AutoRestore|Quarantine DB Options created or updated Successfully!', 'bulletproof-security').$successTextEnd;
	
	$source = '';
	$dest = '';
	$count = '';
	
	bpsSetupWizardExcludeSitemap();	
	bpsSetupWizardExcludeWPEnginesql();
	bpsSetupWizardExcludeAdvancedCacheFile();
	bpsSetupWizardExcludeWpCacheConfigFile();
	bpsSetupWizardExcludeObjectCacheFile();
	bpsSetupWizardExcludeDBCacheFile();
	bps_wp_versionphp_exclude_rule();
	bpsPro_mu_tools_exclude_rule();	
	bpsSetupWizard_ARQ_root_backup($source, $dest);
	bpsSetupWizard_ARQ_wpadmin_backup($source, $dest);
	bpsSetupWizard_ARQ_wpincludes_backup($source, $dest);
	bpsSetupWizard_ARQ_wpcontent_backup($source, $dest);	

	if ( bpsSetupWizardFileCounterRootARQ($source, $count) == bpsSetupWizardFileCounterRoot($source, $count) && bpsSetupWizardFileCounterWpadminARQ($source, $count) == bpsSetupWizardFileCounterWpadmin($source, $count) && bpsSetupWizardFileCounterWpincludesARQ($source, $count) == bpsSetupWizardFileCounterWpincludes($source, $count) && bpsSetupWizardFileCounterWpcontentARQ($source, $count) == bpsSetupWizardFileCounterWpcontent($source, $count) ) {
	
	// IMPORTANT!!! The ARQ Status needs to be cleared here - this SHOULD be '' - NEVER CHANGE THIS value
	$ARQ_status_Options = array( 
	'bps_arq_status' 			=> '', 
	'bps_arq_status_timestamp' 	=> time() 
	);
	
	foreach( $ARQ_status_Options as $key => $value ) {
		update_option('bulletproof_security_options_ARQ_status', $ARQ_status_Options);
	}

	$arq_failsafe_file = WP_CONTENT_DIR . '/bps-backup/master-backups/arq-failsafe.txt';
			
	if ( file_exists($arq_failsafe_file) ) {
		unlink($arq_failsafe_file);
	}

	$successMessage11 = __(' DB Option created or updated Successfully!', 'bulletproof-security');
	$ARQoptions = get_option('bulletproof_security_options_ARCM');
	$bps_option_name11 = 'bulletproof_security_options_ARCM';
	
	if ( ! $ARQoptions['bps_autorestore_cron_frequency'] ) {
		$bps_new_value11_1 = '2';	
	} else {
		$bps_new_value11_1 = $ARQoptions['bps_autorestore_cron_frequency'];
	}	
	
	$bps_new_value11_2 = 'On';

	if ( ! $ARQoptions['bps_autorestore_cron_override'] ) {
		$bps_new_value11_3 = 'Off';	
	} else {
		$bps_new_value11_3 = $ARQoptions['bps_autorestore_cron_override'];
	}	
	
	if ( ! $ARQoptions['bps_autorestore_cron_filecheck'] ) {
		$bps_new_value11_3a = 'On';	
	} else {
		$bps_new_value11_3a = $ARQoptions['bps_autorestore_cron_filecheck'];
	}

	if ( ! $ARQoptions['bps_autorestore_cron_forced'] ) {
		$bps_new_value11_4 = '1';	
	} else {
		$bps_new_value11_4 = $ARQoptions['bps_autorestore_cron_forced'];
	}	
	
	if ( ! $ARQoptions['bps_autorestore_cron_end'] ) {
		$bps_new_value11_5 = '';	
	} else {
		$bps_new_value11_5 = $ARQoptions['bps_autorestore_cron_end'];
	}	
	
		$BPS_Options11 = array(
		'bps_autorestore_cron_frequency' 	=> $bps_new_value11_1, 
		'bps_autorestore_cron' 				=> $bps_new_value11_2, 
		'bps_autorestore_cron_override' 	=> $bps_new_value11_3, 
		'bps_autorestore_cron_filecheck' 	=> $bps_new_value11_3a, 
		'bps_autorestore_cron_forced' 		=> $bps_new_value11_4, 
		'bps_autorestore_cron_end' 			=> $bps_new_value11_5
		);
	
		if ( ! get_option( $bps_option_name11 ) ) {	
		
			foreach( $BPS_Options11 as $key => $value ) {
				update_option('bulletproof_security_options_ARCM', $BPS_Options11);
				echo $successTextBegin.$key.$successMessage11.$successTextEnd;	
			}
	
		} else {

			foreach( $BPS_Options11 as $key => $value ) {
				update_option('bulletproof_security_options_ARCM', $BPS_Options11);
				echo $successTextBegin.$key.$successMessage11.$successTextEnd;	
			}	
		}

		echo $successTextBegin.__('ARQ Root File Backup Verified', 'bulletproof-security').$successTextEnd;
		echo $successTextBegin.__('ARQ wp-admin File Backup Verified', 'bulletproof-security').$successTextEnd;
		echo $successTextBegin.__('ARQ wp-includes File Backup Verified', 'bulletproof-security').$successTextEnd;
		echo $successTextBegin.__('ARQ wp-content File Backup Verified', 'bulletproof-security').$successTextEnd;
		echo $successTextBegin.__('The AutoRestore Cron has been turned On', 'bulletproof-security').$successTextEnd;
		
		echo '</span>';

		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>';
		$text = '<strong><font color="green">'.__('The Setup Wizard has completed BPS Pro Setup.', 'bulletproof-security').'<br>'.__('Check the "BPS Pro Setup Verification & Error Checks" section below for any errors in Red Font. If you see any errors send an email to info@ait-pro.com and copy and paste the entire "BPS Pro Setup Verification & Error Checks" section below in your email.', 'bulletproof-security').'</font><br><br><font color="blue">'.__('Important Recommendation: ', 'bulletproof-security').'</font>'.__('Please take a few minutes to read the top 4 paragraphs (General Help Info) on the <a href="https://forum.ait-pro.com/forums/topic/autorestore-quarantine-guide-read-me-first/" target="_blank" title="AutoRestore|Quarantine Guide (ARQ IDPS) Forum Topic" style="text-decoration:underline;">'.__('AutoRestore|Quarantine Guide (ARQ IDPS) Forum Topic', 'bulletproof-security').'</a> to get a general idea about how ARQ IDPS works. ARQ IDPS is a very unique security feature and nothing like it exists in any other WordPress security plugins.', 'bulletproof-security').'<br><br><a href="https://forum.ait-pro.com/forums/topic/pre-installation-wizard-and-setup-wizard-read-me-first/" target="_blank" title="Setup Wizard Optional|Additional Features" style="text-decoration:underline;">'.__('Click to view Optional|Additional BPS Pro Features', 'bulletproof-security').'</a></strong><br>';
		echo $text;
		echo '</p></div>';

	} else {

		echo $failTextBegin.__('Error: ARQ File Backup Failed', 'bulletproof-security').$failTextEnd;	
		echo $failTextBegin.__('The AutoRestore Cron has NOT been turned On', 'bulletproof-security').$failTextEnd;	

		echo '</span>';

		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>';
		$text = '<strong><font color="green">'.__('The Setup Wizard has completed BPS Pro Setup.', 'bulletproof-security').'<br>'.__('Check the "BPS Pro Setup Verification & Error Checks" section below for any errors in Red Font. If you see any errors send an email to info@ait-pro.com and copy and paste the entire "BPS Pro Setup Verification & Error Checks" section below in your email.', 'bulletproof-security').'</font></strong><br>';
		echo $text;
		echo '</p></div>';
	} // end if ( bpsSetupWizardFileCounterRootARQ($source, $count)...
	
	echo '</p></div>';	
	} // end if ( !$PreInstallOptions['bps_wizard_preinstallation'] || $PreInstallOptions['bps_wizard_preinstallation'] != 'yes') {

// 15: Process any BPS plugin updates if someone has disabled htaccess files. This needs to happen last and be outside of the ARQ file backup condition.
function bpsPro_plugin_updates_htaccess_files_disabled() {
	
	$HFiles_options = get_option('bulletproof_security_options_htaccess_files');
       
	if ( isset( $HFiles_options['bps_htaccess_files'] ) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
		
		require_once ( WP_PLUGIN_DIR . '/bulletproof-security/includes/general-functions.php' );
		bpsPro_new_version_db_options_files_autoupdate();
	}
}

bpsPro_plugin_updates_htaccess_files_disabled();

	$time_end = microtime( true );
	$wizard_run_time = $time_end - $time_start;
	$wizard_time_display = '<strong>'.__('Setup Wizard Completion Time: ', 'bulletproof-security').'</strong>'. round( $wizard_run_time, 2 ) . ' Seconds';	
	
	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 bpsPro_memory_resource_usage();
	echo $wizard_time_display;
	echo '</p></div>';

	echo '</div>';
	} // end if (isset($_POST['Submit-Setup-Wizard'])
}

?>
</div>

<h2 class="bps-tab-title"><?php _e('BulletProof Security Pro ~ Setup Wizard', 'bulletproof-security'); ?></h2>

<!-- jQuery UI Tab Menu -->
<div id="bps-tabs-wizard" class="bps-menu">
    <div id="bpsHead"><img src="<?php echo plugins_url('/bulletproof-security/admin/images/bps-pro-logo.gif'); ?>" />
    
<style>
<!--
.bps-spinner {
    visibility:visible;
	position:fixed;
    top:7%;
    left:45%;
 	width:240px;
	background:#fff;
	border:4px solid black;
	padding:2px 0px 4px 8px;   
	z-index:99999;
}
-->
</style> 

<script type="text/javascript">
/* <![CDATA[ */
function bpsSpinnerPWizard() {
	
	var r = confirm("Reminder: The Pre-Installation Wizard button MUST ALWAYS be clicked first before you click the Setup Wizard button.\n\n-------------------------------------------------------------\n\nThe Pre-Installation Wizard checks for pre-existing website issues or problems and will automatically fix those pre-existing issues or problems if possible.\n\n-------------------------------------------------------------\n\nIf the Pre-Installation Wizard cannot automatically fix an issue or problem then an error message will be displayed with what needs to be done to fix the issue or problem before clicking/running the Setup Wizard button.\n\n-------------------------------------------------------------\n\nThe Pre-Installation Wizard also scans your website for plugin scripts that need to be whitelisted in the Plugin Firewall. It will take longer for the Pre-Installation Wizard to finish scanning on larger websites that have more Pages and Posts.\n\n-------------------------------------------------------------\n\nClick OK to Run the Pre-Installation Wizard or click Cancel.");
	
	var img = document.getElementById("bps-spinner");

	if (r == true) {

		img.style.visibility = "visible";
	
	} else {
	
		history.go(-1);
	}
}
/* ]]> */
</script>     
    
<script type="text/javascript">
/* <![CDATA[ */
function bpsSpinnerSWizard() {
	
    var r = confirm("Reminder: The Pre-Installation Wizard button MUST ALWAYS be clicked first before clicking the Setup Wizard button.\n\n-------------------------------------------------------------\n\nPlease allow the Setup Wizard to complete the BPS Pro Setup before leaving the Setup Wizard page.\n\n-------------------------------------------------------------\n\nWhen the Setup Wizard has completed successfully you will see this Success message - The Setup Wizard has completed BPS Pro Setup.\n\n-------------------------------------------------------------\n\nYou can re-run the Pre-Installation Wizard and Setup Wizard again at any time. Your existing settings will NOT be overwritten and will be re-saved. Any new or additional settings that the Pre-Installation and Setup Wizards find on your website will be saved/setup.\n\n-------------------------------------------------------------\n\nClick OK to Run the Setup Wizard or click Cancel.");
	
	var img = document.getElementById("bps-spinner"); 

	if (r == true) {
 	
		img.style.visibility = "visible";
	
	} else {
	
		history.go(-1);
	}
}
/* ]]> */
</script> 

    <div id="bps-spinner" class="bps-spinner" style="visibility:hidden;">
    	<img id="bps-img-spinner" src="<?php echo plugins_url('/bulletproof-security/admin/images/bps-spinner.gif'); ?>" style="float:left;margin:0px 20px 0px 0px;" />
        <div id="bps-spinner-text-btn" style="padding:20px 0px 26px 0px;font-size:14px;">Processing...<br><button style="margin:10px 0px 0px 10px;" onclick="javascript:history.go(-1)">Cancel</button>
		</div>
    </div> 
    
    </div>
		<ul>
            <li><a href="#bps-tabs-1"><?php _e('Setup Wizard', 'bulletproof-security'); ?></a></li>
            <li><a href="#bps-tabs-2"><?php _e('Setup Wizard Options', 'bulletproof-security'); ?></a></li>
            <li><a href="#bps-tabs-3"><?php _e('Setup Wizard Export|Import', 'bulletproof-security'); ?></a></li>
		</ul>
            
<div id="bps-tabs-1" class="bps-tab-page">

<?php
function bpsPro_hfiles_inpage_message() {       

$HFiles_options = get_option('bulletproof_security_options_htaccess_files');
       
	if ( isset( $HFiles_options['bps_htaccess_files'] ) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {	   
	    $text = '<div id="bps-inpage-message" style="background-color:#dfecf2;border:1px solid #999;font-weight:bold;padding:0px 5px;margin:0px 0px 10px 0px;-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);"><font color="blue">'.__('htaccess Files Disabled Notice: ', 'bulletproof-security').'</font><br><font color="black">'.__('BPS has detected that htaccess files cannot be used on your website/server. Click this ', 'bulletproof-security').'</font><a href="https://forum.ait-pro.com/forums/topic/htaccess-files-disabled-setup-wizard-enable-disable-htaccess-files/" target="_blank" title="htaccess Files Disabled Forum Topic">'.__('htaccess Files Disabled Forum Topic', 'bulletproof-security').'</a><font color="black">'.__(' link for more information before running the Wizards.', 'bulletproof-security').'<br>'.__('If you intentionally disabled htaccess files then disregard this Notice. The Pre-Installation and Setup Wizard need to be run again after disabling or enabling htaccess files.', 'bulletproof-security').'</font></div>';
		echo $text;
	}
}

bpsPro_hfiles_inpage_message();

?>

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bps-help_faq_table">
  <tr>
    <td class="bps-table_title"><h2><?php _e('Setup Wizards ~ ', 'bulletproof-security'); ?><span style="font-size:.75em;"><?php _e('Pre-Installation Wizard & Setup Wizard', 'bulletproof-security'); ?></span></h2></td>
  </tr>
  <tr>
    <td class="bps-table_cell_help">
    
<h3 style="margin:0px 0px 5px 0px;"><?php _e('Pre-Installation Wizard & Setup Wizard', 'bulletproof-security'); ?>  <button id="bps-open-modal1" class="button bps-modal-button"><?php _e('Read Me', 'bulletproof-security'); ?></button></h3>
		
<div id="bps-modal-content1" class="bps-dialog-hide" title="<?php _e('Pre-Installation Wizard & Setup Wizard', 'bulletproof-security'); ?>">
    <p>
	<?php
        $text = '<strong>'.__('This Read Me Help window is draggable (top) and resizable (bottom right corner)', 'bulletproof-security').'</strong><br><br>';
		echo $text; 
		// Forum Help Links or of course both
		$text = '<strong><font color="blue">'.__('Forum Help Links: ', 'bulletproof-security').'</font></strong><br>'; 	
		echo $text;	
	?>
	<strong><a href="https://forum.ait-pro.com/forums/topic/pre-installation-wizard-and-setup-wizard-read-me-first/" title="Setup Wizard Optional|Additional Features" target="_blank"><?php _e('Setup Wizard Optional|Additional Features', 'bulletproof-security'); ?></a></strong><br /><br />		
	
	<?php $dialog_text = '<strong>'.__('Setup Wizard Steps: ', 'bulletproof-security').'</strong><br>'.__('1. Click the Pre-Installation Wizard button.', 'bulletproof-security').'<br>'.__('2. Click the Setup Wizard button.', 'bulletproof-security').'<br><br><strong>'.__('Notes: ', 'bulletproof-security').'</strong><br>&bull; '.__('If you see any Red font error messages after running the Pre-Installation Wizard, correct those issues before clicking the Setup Wizard button. Red font messages are displayed with an exact description of the issue and how to correct it. Blue font messages are just Notices that do not require anything to be corrected. Example Blue font Notice: Plugin Firewall cURL Scanning is Turned Off.','bulletproof-security' ).'<br><br>&bull; '.__('If the Pre-installation Wizard hangs or does not complete successfully: click on the Setup Wizard Options tab page, select and save the Turn Off cURL Scan option and run the Pre-Installation Wizard again.', 'bulletproof-security').'<br><br>&bull; '.__('Each time you run/re-run the Wizards the Pre-Installation Wizard button MUST ALWAYS be clicked first before clicking the Setup Wizard button.', 'bulletproof-security').'<br><br>&bull; '.__('You can re-run the Pre-Installation Wizard and Setup Wizard again at any time. Your existing settings will NOT be overwritten and will be re-saved (see the DB Monitor: Use Default or Keep Existing Settings help section in the Setup Wizard Options Read Me help button). Any new or additional settings that the Pre-Installation and Setup Wizards find on your website will be saved/setup.', 'bulletproof-security').'<br><br>&bull; '.__('Please allow the Pre-Installation Wizard to finish running before clicking the Setup Wizard button.','bulletproof-security' ).'<br><br>&bull; '.__('When the Pre-Installation Wizard has finished running you will see "The Pre-Installation Wizard Checks|Scans|Settings have completed."','bulletproof-security' ).'<br><br>&bull; '.__('Please allow the Setup Wizard to complete the BPS Pro Setup before leaving the Setup Wizard page.','bulletproof-security' ).'<br><br>&bull; '.__('Estimated Setup Wizard Completion Time: 10 seconds to 1 minute.','bulletproof-security' ).'<br><br>&bull; '.__('When the Setup Wizard has completed you will see "The Setup Wizard has completed BPS Pro Setup."','bulletproof-security' ).'<br><br>&bull; '.__('View the "Setup Wizard Optional|Additional Features" Forum Help Link at the top of this Read Me help window after running the Setup Wizard. There a few additional optional features and setup steps for some features in BPS Pro if you choose to use those features.','bulletproof-security').'<br><br>&bull; '.__('For new installations of BPS the Setup Wizard creates a new root htaccess file and backs up the existing root htaccess file if the website already has a root htaccess file. For existing BPS installations the Setup Wizard backs up the existing root htaccess file and updates the current root htaccess file each time the Setup Wizard is run. Backed up htaccess files can be found in this folder:  /wp-content/bps-backup/master-backups/root.htaccess-[Date-Timestamp]','bulletproof-security'); echo $dialog_text; ?></p>
</div>

<?php
$text = '<span class="setup-wizard-inpage-text"><div class="setup-wizard-video-link" style="margin:0px 0px -10px 0px;"><a href="https://forum.ait-pro.com/video-tutorials/#setup-wizard" target="_blank" title="Setup Wizard Video Tutorial">'.__('Setup Wizard Video Tutorial', 'bulletproof-security').'</a></div><br><div style="margin:0px 0px 5px 0px;">'.__('1. Click the Pre-Installation Wizard button.', 'bulletproof-security').'<br>'.__('2. Click the Setup Wizard button.', 'bulletproof-security').'</div></span>';
echo $text;
?>

<h3 style="border-bottom:1px solid #999999;"><?php _e('Pre-Installation Wizard', 'bulletproof-security'); ?></h3>

<?php echo '<span class="setup-wizard-blue-small-text"><strong><font color="#2ea2cc">'.__('If the Pre-Installation Wizards hangs or does not complete successfully click the Read Me help button above.', 'bulletproof-security').'</font></strong></span><br>'; ?>

<form name="bpsSetupWizardPreinstallation" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/wizard/wizard.php' ); ?>" method="post">
<?php wp_nonce_field('bps_setup_wizard_preinstallation'); ?>

	<input type="submit" name="Submit-Setup-Wizard-Preinstallation" style="margin:10px 0px 10px 0px;width:154px;height:auto;white-space:normal" value="<?php esc_attr_e('Pre-Installation Wizard', 'bulletproof-security') ?>" class="button bps-button" onclick="bpsSpinnerPWizard()" />

<?php bpsSetupWizardPrechecks(); ?>
</form>

<h3 style="border-bottom:1px solid #999999;"><?php _e('Setup Wizard', 'bulletproof-security'); ?></h3>

<form name="bpsSetupWizard" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/wizard/wizard.php' ); ?>" method="post">
<?php wp_nonce_field('bps_setup_wizard'); $PreInstallOptions = get_option('bulletproof_security_options_preinstallation'); ?>
<?php if ( ! isset($PreInstallOptions['bps_wizard_preinstallation']) || isset($PreInstallOptions['bps_wizard_preinstallation']) && $PreInstallOptions['bps_wizard_preinstallation'] != 'yes' || isset($PreInstallOptions['bps_wizard_preinstallation_61']) && $PreInstallOptions['bps_wizard_preinstallation_61'] != 'yes') { ?>

    <input type="submit" name="Submit-Setup-Wizard" style="margin:10px 0px 10px 0px;width:154px;height:auto;white-space:normal" value="<?php esc_attr_e('Setup Wizard', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('The Pre-Installation Wizard button MUST ALWAYS be clicked first before you click the Setup Wizard button.', 'bulletproof-security').__('Click the Cancel button.', 'bulletproof-security'); echo $text; ?>')" />

<?php bpsSetupWizardFail(); ?>

<?php } else { ?>

<input type="submit" name="Submit-Setup-Wizard" style="margin:10px 0px 20px 0px;width:154px" value="<?php esc_attr_e('Setup Wizard', 'bulletproof-security') ?>" class="button bps-button" onclick="bpsSpinnerSWizard()" />

<?php bpsSetupWizard(); ?>
<?php } ?>
</form>

</td>
  </tr>
</table>

</div>
        
<div id="bps-tabs-2" class="bps-tab-page">

<?php bpsPro_hfiles_inpage_message(); ?>

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bps-help_faq_table">
  <tr>
    <td class="bps-table_title"><h2><?php _e('Setup Wizard Options ~ ', 'bulletproof-security'); ?><span style="font-size:.75em;"><?php _e('Click the Setup Wizard Options Read Me help button for help info about each option setting', 'bulletproof-security'); ?></span></h2></td>
  </tr>
  <tr>
    <td class="bps-table_cell_help">
    
<h3 style="margin:0px 0px 5px 0px;"><?php _e('Setup Wizard Options', 'bulletproof-security'); ?>  <button id="bps-open-modal2" class="button bps-modal-button"><?php _e('Read Me', 'bulletproof-security'); ?></button></h3>

<div id="bps-modal-content2" class="bps-dialog-hide" title="<?php _e('Setup Wizard Options', 'bulletproof-security'); ?>">
    <p>
	<?php
        $text = '<strong>'.__('This Read Me Help window is draggable (top) and resizable (bottom right corner)', 'bulletproof-security').'</strong><br><br>';
		echo $text; 
		// Forum Help Links or of course both
		$text = '<strong><font color="blue">'.__('Forum Help Links: ', 'bulletproof-security').'</font></strong><br>'; 	
		echo $text;	
	?>
	<strong><a href="https://forum.ait-pro.com/forums/topic/gdmw/" title="GDMW Hosting" target="_blank"><?php _e('GDMW Hosting', 'bulletproof-security'); ?></a></strong><br />	
	<strong><a href="https://forum.ait-pro.com/forums/topic/htaccess-files-disabled-setup-wizard-enable-disable-htaccess-files/" title="Enable|Disable htaccess Files" target="_blank"><?php _e('Enable|Disable htaccess Files', 'bulletproof-security'); ?></a></strong><br />
 	<strong><a href="https://forum.ait-pro.com/forums/topic/setup-wizard-autofix/" title="AutoFix" target="_blank"><?php _e('AutoFix Forum Topic', 'bulletproof-security'); ?></a></strong><br />
 	<strong><a href="https://forum.ait-pro.com/forums/topic/bps-gdpr-compliance/" title="GDPR Compliance" target="_blank"><?php _e('GDPR Compliance Forum Topic', 'bulletproof-security'); ?></a></strong><br /><br />
	
	<?php $dialog_text = '<strong>'.__('Setup Wizard Option Settings', 'bulletproof-security').'</strong><br><br><strong>'.__('AutoFix (AutoWhitelist|AutoSetup|AutoCleanup)', 'bulletproof-security').'</strong><br>'.__('Setup Wizard AutoFix is turned On by default. When AutoFix is turned On the Setup Wizard will automatically create htaccess whitelist rules in BPS Custom Code and your Live htaccess files for other plugins and themes that you have installed that require htaccess code whitelist rules. Setup Wizard AutoFix will also automatically setup or cleanup htaccess code in BPS Custom Code for these caching plugins: WP Super Cache, W3 Total Cache, Comet Cache Plugin (free & Pro), WP Fastest Cache Plugin (free & Premium), LiteSpeed Cache and WP Rocket. If a problem occurs with AutoFix you can turn On the AutoFix Debugger on the BPS UI|UX Settings page > BPS UI|UX|AutoFix Debug option to check the plugin or theme name and the BPS Custom Code text box where the problem is occurring. You can also turn Off AutoFix and AutoFix will not try to detect or create Custom Code whitelist rules or setup or cleanup caching plugins htaccess code. If a problem does occur with AutoFix turn On the BPS UI|UX|AutoFix Debug option, copy the AutoFix Debug information that is displayed to you and then click the AutoFix Forum Topic link at the top of this Read Me help window and post a forum Reply with your AutoFix Debug information so that we can figure out what the problem is.', 'bulletproof-security').'<br><br><strong>'.__('GDPR Compliance (IP Address Logging On|Off)', 'bulletproof-security').'</strong><br>'.__('The GDPR Compliance option setting is set to Off by default. Choosing the GDPR Compliance On option setting will disable IP address logging in all BPS Pro features that log IP addresses. This plain text will be logged instead of IP addresses: GDPR Compliance On. List of BPS Pro features that log IP addresses: Security Log, Login Security, JTC Anti-Spam|Anti-Hacker and Maintenance Mode. Note: For simplicity and ease of use this GDPR Compliance Setup Wizard Options setting is the only option setting that needs to be set instead of creating individual option settings in all BPS Pro features that perform IP address logging. For more information about GDPR Compliance click the GDPR Compliance Forum Topic link at the top of this Read Me help window.', 'bulletproof-security').'<br><br><strong>'.__('cURL Scan Option: Turn On|Off cURL Scan', 'bulletproof-security').'</strong><br>'.__('The cURL Scan Option is set to On by default. If the Pre-Installation Wizard is crashing/hanging/not completing then select and save the "cURL Scan Off" option and run the Pre-Installation Wizard again. If you have a VPS or Dedicated Server you may need to reboot your server if the Pre-Installation Wizard cURL Scanner causes your website/server to crash. Plugin Firewall AutoPilot Mode will automatically create any Plugin Firewall whitelist rules in real-time that are needed for your website so cURL scanning is not necessary during Setup Wizard setup.', 'bulletproof-security').'<br><br><strong>'.__('DB Monitor: Use Default or Keep Existing Settings', 'bulletproof-security').'</strong><br>'.__('If you are re-running the Pre-Installation Wizard and Setup Wizard and you have setup the DB Monitor to monitor additional DB Tables then choose the "Keep Existing DB Monitor Settings" option.', 'bulletproof-security').'<br><br><strong>'.__('Go Daddy Managed WordPress Hosting (GDMW):', 'bulletproof-security').'</strong><br>'.__('This option is ONLY for a special type of Go Daddy Hosting account called "Managed WordPress Hosting" and is NOT for regular/standard Go Daddy Hosting account types. Leave the default setting set to No, unless you have a Go Daddy Managed WordPress Hosting account. See the GDMW Hosting Forum Help Link at the top of this Read Me help window for more information.', 'bulletproof-security').'<br><br><strong>'.__('Enable|Disable htaccess Files:', 'bulletproof-security').'</strong><br>'.__('Before changing this option setting, click the ', 'bulletproof-security').'<strong><font color="blue">'.__('Enable|Disable htaccess Files', 'bulletproof-security').'</font></strong>'.__(' Forum Help Link at the top of this Read Me help window to find out exactly what this option setting does and when it should or should not be used. htaccess Files Disabled: Will disable all BPS htaccess features and files. htaccess Files Enabled: Will enable all BPS htaccess freatures and files.', 'bulletproof-security').'<br><br><strong>'.__('Enable|Disable wp-admin BulletProof Mode', 'bulletproof-security').'</strong><br>'.__('The default setting is already set to: wp-admin BulletProof Mode Enabled. If you would like to disable wp-admin BulletProof Mode select wp-admin BulletProof Mode Disabled.', 'bulletproof-security').'<br><br><strong>'.__('Zip File Download Fix (Incapsula, Proxy, Other Cause):', 'bulletproof-security').'</strong><br>'.__('This option should only be set to On if you are seeing a 403 error and/or unable to download these Zip files: Custom Code Export Zip file, Login Security Table Export Zip file or the Setup Wizard Root htaccess file backup Zip file. The Setup Wizard Root htaccess file backup Zip file link is only displayed if BPS detects that your current Root htaccess file is not a BPS Root htaccess file. If you are still unable to download zip files after setting this option to On then you will need to whitelist your Proxy IP address in the Plugin Firewall Whitelist by Hostname (domain name) and IP Address tool under the Plugin Firewall Additional Whitelist Tools accordion tab. If that does not work then you will need to deactivate the Plugin Firewall temporarily, download the zip file and then activate the Plugin Firewall again.', 'bulletproof-security').'<br><br><strong>'.__('Multisite Hide|Display System Info Page for Subsites:', 'bulletproof-security').'</strong><br>'.__('This option is for Network|Multisite sites only. Choosing Hide System Info Page will hide the System Info menu link under the BPS navigational menus. Choosing Display System Info page will display the System Info menu link under the BPS navigational mensus.', 'bulletproof-security').'<br><br><strong>'.__('Network|Multisite Sitewide Login Security Settings', 'bulletproof-security').'</strong><br>'.__('This option is for Network|Multisite sites ONLY. This is an independent option Form that creates and saves Login Security DB option settings for all Network sites when you click the Save Network LSM Options Sitewide button. If Login Security option settings have already been setup and saved for any Network site then those Login Security option settings will NOT be changed. If Login Security options settings have NOT already been setup and saved for any Network site then those Login Security option settings will be created and saved with these default settings: Max Login Attempts: 3, Automatic Lockout Time: 60, Manual Lockout Time: 60, Max DB Rows To Show: blank show all rows, Turn On|Turn Off: Turn On Login Security, Logging Options: Log Only Account Lockouts, Error Messages: Standard WP Login Errors, Attempts Remaining: Show Login Attempts Remaining, Password Reset: Enable Password Reset, Sort DB Rows: Ascending - Show Oldest Login First.', 'bulletproof-security').'<br><br><strong>'.__('Network|Multisite Sitewide JTC Anti-Spam|Anti-Hacker Settings', 'bulletproof-security').'</strong><br>'.__('This option is for Network|Multisite sites ONLY. This is an independent option Form that creates and saves JTC Anti-Spam|Anti-Hacker DB option settings for all Network sites when you click the Save Network JTC Options Sitewide button. If JTC option settings have already been setup and saved for any Network site then those JTC option settings will NOT be changed. If JTC options settings have NOT already been setup and saved for any Network site then those JTC option settings will be created and saved with these default settings: JTC CAPTCHA: jtc, JTC ToolTip: Type/Enter: jtc, JTC Title|Text: Hover or click the text box below, Enable|Disable JTC Anti-Spam For These Forms: Login Form, Register Form and Lost Password Form checkboxes are checked and will display the JTC CAPTCHA text box on those Forms.', 'bulletproof-security').'<br><br><strong>'.__('Network|Multisite Sitewide Force Strong Passwords Settings', 'bulletproof-security').'</strong><br>'.__('This option is for Network|Multisite sites ONLY. This is an independent option Form that creates and saves FSP DB option settings for all Network sites when you click the Save Network FSP Options Sitewide button. If FSP option settings have already been setup and saved for any Network site then those FSP option settings will NOT be changed. If FSP options settings have NOT already been setup and saved for any Network site then those FSP option settings will be created and saved with these default settings: FSP: Off, Password Character Length: 12, Password Criteria Requirements checkboxes: all checked and Displayed Message/Error Message: default FSP message.', 'bulletproof-security'); echo $dialog_text; ?></p>
</div>

<form name="AutoFix" action="options.php#bps-tabs-2" method="post">
	<?php settings_fields('bulletproof_security_options_wizard_autofix'); ?>
	<?php $AutoFix_Options = get_option('bulletproof_security_options_wizard_autofix'); 
		$bps_wizard_autofix = ! isset($AutoFix_Options['bps_wizard_autofix']) ? '' : $AutoFix_Options['bps_wizard_autofix'];
	?>
	
    <strong><label for="auto-fix"><?php _e('AutoFix (AutoWhitelist|AutoSetup|AutoCleanup):', 'bulletproof-security'); ?></label></strong><br />
<select name="bulletproof_security_options_wizard_autofix[bps_wizard_autofix]" class="form-300" style="margin-top:5px;">
<option value="On" <?php selected('On', $bps_wizard_autofix); ?>><?php _e('AutoFix On', 'bulletproof-security'); ?></option>
<option value="Off" <?php selected('Off', $bps_wizard_autofix); ?>><?php _e('AutoFix Off', 'bulletproof-security'); ?></option>
</select><br />
<input type="submit" name="Submit-AutoFix" class="button bps-button" style="margin:10px 0px 20px 0px;width:202px;height:auto;white-space:normal" value="<?php esc_attr_e('Save AutoFix Option', 'bulletproof-security') ?>" />
</form>

<form name="GDPR" action="options.php#bps-tabs-2" method="post">
	<?php settings_fields('bulletproof_security_options_gdpr'); ?>
	<?php $GDPR_Options = get_option('bulletproof_security_options_gdpr'); 
		$bps_gdpr_on_off = ! isset($GDPR_Options['bps_gdpr_on_off']) ? '' : $GDPR_Options['bps_gdpr_on_off'];
	?>
	
    <strong><label for="gdpr"><?php _e('GDPR Compliance (IP Address Logging On|Off):', 'bulletproof-security'); ?></label></strong><br />
<select name="bulletproof_security_options_gdpr[bps_gdpr_on_off]" class="form-300" style="margin-top:5px;">
<option value="Off" <?php selected('Off', $bps_gdpr_on_off); ?>><?php _e('GDPR Compliance Off', 'bulletproof-security'); ?></option>
<option value="On" <?php selected('On', $bps_gdpr_on_off); ?>><?php _e('GDPR Compliance On', 'bulletproof-security'); ?></option>
</select><br />
<input type="submit" name="Submit-GDPR" class="button bps-button" style="margin:10px 0px 20px 0px;width:202px;height:auto;white-space:normal" value="<?php esc_attr_e('Save GDPR Option', 'bulletproof-security') ?>" />
</form>

<form name="SetupWizardcURLOptions" action="options.php#bps-tabs-2" method="post">
	<?php settings_fields('bulletproof_security_options_wizard_curl'); ?> 
	<?php $CURLoptions = get_option('bulletproof_security_options_wizard_curl'); 
		$bps_wizard_curl_scan = ! isset($CURLoptions['bps_wizard_curl_scan']) ? '' : $CURLoptions['bps_wizard_curl_scan'];	
		$bps_wizard_dbm_settings = ! isset($CURLoptions['bps_wizard_dbm_settings']) ? '' : $CURLoptions['bps_wizard_dbm_settings'];	
	?>
    
	<label for="wizard-curl"><?php _e('cURL Scan Option: Turn On|Off cURL Scan', 'bulletproof-security'); ?></label><br />
<select name="bulletproof_security_options_wizard_curl[bps_wizard_curl_scan]" class="form-300" style="margin-bottom:10px;">
<option value="On" <?php selected('On', $bps_wizard_curl_scan); ?>><?php _e('cURL Scan On', 'bulletproof-security'); ?></option>
<option value="Off" <?php selected('Off', $bps_wizard_curl_scan); ?>><?php _e('cURL Scan Off', 'bulletproof-security'); ?></option>
</select><br />
	<label for="wizard-curl"><?php _e('DB Monitor: Use Default or Keep Existing Settings', 'bulletproof-security'); ?></label><br />
<select name="bulletproof_security_options_wizard_curl[bps_wizard_dbm_settings]" class="form-300">
<option value="On" <?php selected('On', $bps_wizard_dbm_settings); ?>><?php _e('Use Default DB Monitor Settings', 'bulletproof-security'); ?></option>
<option value="Off" <?php selected('Off', $bps_wizard_dbm_settings); ?>><?php _e('Keep Existing DB Monitor Settings', 'bulletproof-security'); ?></option>
</select><br />
<input type="submit" name="Submit-Wizard-cURL-Options" class="button bps-button" style="margin:10px 0px 20px 0px;width:202px;height:auto;white-space:normal" value="<?php esc_attr_e('Save cURL|DB Monitor Options', 'bulletproof-security') ?>" />
</form>

<form name="SetupWizardGDMW" action="options.php#bps-tabs-2" method="post">
	<?php settings_fields('bulletproof_security_options_GDMW'); ?> 
	<?php $GDMWoptions = get_option('bulletproof_security_options_GDMW'); 
		$bps_gdmw_hosting = ! isset($GDMWoptions['bps_gdmw_hosting']) ? '' : $GDMWoptions['bps_gdmw_hosting'];	
	?>
    
	<label for="wizard-curl"><?php _e('Go Daddy Managed WordPress Hosting (GDMW):', 'bulletproof-security'); ?></label><br />
<select name="bulletproof_security_options_GDMW[bps_gdmw_hosting]" class="form-300">
<option value="no" <?php selected('no', $bps_gdmw_hosting); ?>><?php _e('No (default setting)', 'bulletproof-security'); ?></option>
<option value="yes" <?php selected('yes', $bps_gdmw_hosting); ?>><?php _e('Yes (ONLY if you have Managed WordPress Hosting)', 'bulletproof-security'); ?></option>
</select><br />
<input type="submit" name="Submit-Wizard-GDMW" class="button bps-button" style="margin:10px 0px 20px 0px;width:202px;height:auto;white-space:normal" value="<?php esc_attr_e('Save GDMW Option', 'bulletproof-security') ?>" />
</form> 

 <form name="SetupWizardHFiles" action="options.php#bps-tabs-2" method="post">
	<?php settings_fields('bulletproof_security_options_htaccess_files'); ?> 
	<?php $HFiles_options = get_option('bulletproof_security_options_htaccess_files'); 
		$bps_htaccess_files = ! isset($HFiles_options['bps_htaccess_files']) ? '' : $HFiles_options['bps_htaccess_files'];	
	?>
    
	<label for="wizard-curl"><?php _e('Enable|Disable htaccess Files:', 'bulletproof-security'); ?></label><br />
	<label for="wizard-curl" class="setup-wizard-blue-small-text" style="color:#2ea2cc;"><?php _e('CAUTION: Click the Read Me help button before changing this option setting', 'bulletproof-security'); ?></label><br />
<select name="bulletproof_security_options_htaccess_files[bps_htaccess_files]" class="form-300">
<option value="enabled" <?php selected('enabled', $bps_htaccess_files); ?>><?php _e('htaccess Files Enabled', 'bulletproof-security'); ?></option>
<option value="disabled" <?php selected('disabled', $bps_htaccess_files); ?>><?php _e('htaccess Files Disabled', 'bulletproof-security'); ?></option>
</select><br />
<input type="submit" name="Submit-Wizard-HFiles" class="button bps-button" style="margin:10px 0px 20px 0px;width:202px;height:auto;white-space:normal" value="<?php esc_attr_e('Enable|Disable', 'bulletproof-security') ?>" />
</form>

<form name="wpadminEnableDisable" action="options.php#bps-tabs-2" method="post">
	<?php settings_fields('bulletproof_security_options_htaccess_res'); ?> 
	<?php $BPS_wpadmin_Options = get_option('bulletproof_security_options_htaccess_res'); 
		$bps_wpadmin_restriction = ! isset($BPS_wpadmin_Options['bps_wpadmin_restriction']) ? '' : $BPS_wpadmin_Options['bps_wpadmin_restriction'];	
	?>
	
    <strong><label for="wpadmin-res"><?php _e('Enable|Disable wp-admin BulletProof Mode:', 'bulletproof-security'); ?></label></strong><br />
<select name="bulletproof_security_options_htaccess_res[bps_wpadmin_restriction]" class="form-300" style="margin-top:5px;">
<option value="enabled" <?php selected('enabled', $bps_wpadmin_restriction); ?>><?php _e('wp-admin BulletProof Mode Enabled', 'bulletproof-security'); ?></option>
<option value="disabled" <?php selected('disabled', $bps_wpadmin_restriction); ?>><?php _e('wp-admin BulletProof Mode Disabled', 'bulletproof-security'); ?></option>
</select><br />
<input type="submit" name="Submit-Enable-Disable-wpadmin" class="button bps-button" style="margin:10px 0px 20px 0px;width:202px;height:auto;white-space:normal" value="<?php esc_attr_e('Enable|Disable', 'bulletproof-security') ?>" />
</form>

<form name="ZipDownloadFix" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/wizard/wizard.php#bps-tabs-2' ); ?>" method="post">
	<?php wp_nonce_field('bulletproof_security_zip_download_fix'); ?>
	<?php $Zip_download_Options = get_option('bulletproof_security_options_zip_fix'); 
		$bps_zip_download_fix = ! isset($Zip_download_Options['bps_zip_download_fix']) ? '' : $Zip_download_Options['bps_zip_download_fix'];		
	?>
	
    <strong><label for="zip-fix"><?php _e('Zip File Download Fix (Incapsula, Proxy, Other Cause):', 'bulletproof-security'); ?></label></strong><br />
<select name="bulletproof_security_options_zip_fix" class="form-300" style="margin-top:5px;">
<option value="Off" <?php selected('Off', $bps_zip_download_fix); ?>><?php _e('Zip File Download Fix Off', 'bulletproof-security'); ?></option>
<option value="On" <?php selected('On', $bps_zip_download_fix); ?>><?php _e('Zip File Download Fix On', 'bulletproof-security'); ?></option>
</select><br />
<input type="submit" name="Submit-Zip-Download-Fix" class="button bps-button" style="margin:10px 0px 20px 0px;width:232px;height:auto;white-space:normal" value="<?php esc_attr_e('Save Zip File Download Fix Option', 'bulletproof-security') ?>" />
</form>

<form name="muSysinfo" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/wizard/wizard.php#bps-tabs-2' ); ?>" method="post">
	<?php wp_nonce_field('bulletproof_security_options_mu_sysinfo'); ?>
	<?php $Mu_Sysinfo_page_options = get_option('bulletproof_security_options_mu_sysinfo'); 
		$bps_sysinfo_hide_display = ! isset($Mu_Sysinfo_page_options['bps_sysinfo_hide_display']) ? '' : $Mu_Sysinfo_page_options['bps_sysinfo_hide_display'];	
	?>
	
    <strong><label for="mu-sysinfo"><?php _e('Multisite Hide|Display System Info Page for Subsites:', 'bulletproof-security'); ?></label></strong><br />
<select name="bulletproof_security_options_mu_sysinfo_select" class="form-300" style="margin-top:5px;">
<option value="display" <?php selected('display', $bps_sysinfo_hide_display); ?>><?php _e('Display System Info Page', 'bulletproof-security'); ?></option>
<option value="hide" <?php selected('hide', $bps_sysinfo_hide_display); ?>><?php _e('Hide System Info Page', 'bulletproof-security'); ?></option>
</select><br />
<input type="submit" name="Submit-MU-Sysinfo-Display" class="button bps-button" style="margin:10px 0px 20px 0px;width:232px;height:auto;white-space:normal" value="<?php esc_attr_e('Save Multisite Hide|Display Option', 'bulletproof-security') ?>" />
</form>

<form name="bpsNetLSM" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/wizard/wizard.php#bps-tabs-2' ); ?>" method="post">
<?php wp_nonce_field('bps_setup_wizard'); ?>
<div>
<strong><label for="NetLSM"><?php _e('Network|Multisite Sitewide Login Security Settings', 'bulletproof-security'); ?></label></strong><br />  
<input type="submit" name="Submit-Net-LSM" class="button bps-button" style="margin:10px 0px 20px 0px;width:232px;height:auto;white-space:normal" value="<?php esc_attr_e('Save Network LSM Options Sitewide', 'bulletproof-security') ?>" />
</div>
<?php bpsPro_network_subsites_lsm_settings(); ?>
</form>

<form name="bpsNetJTC" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/wizard/wizard.php#bps-tabs-2' ); ?>" method="post">
<?php wp_nonce_field('bps_setup_wizard'); ?>
<div>
<strong><label for="NetLSM"><?php _e('Network|Multisite Sitewide JTC Anti-Spam|Anti-Hacker Settings', 'bulletproof-security'); ?></label></strong><br />  
<input type="submit" name="Submit-Net-JTC" class="button bps-button" style="margin:10px 0px 20px 0px;width:232px;height:auto;white-space:normal" value="<?php esc_attr_e('Save Network JTC Options Sitewide', 'bulletproof-security') ?>" />
</div>
<?php bpsPro_network_subsites_jtc_settings(); ?>
</form>

<form name="bpsNetFSP" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/wizard/wizard.php#bps-tabs-2' ); ?>" method="post">
<?php wp_nonce_field('bps_setup_wizard'); ?>
<div>
<strong><label for="NetLSM"><?php _e('Network|Multisite Sitewide Force Strong Passwords Settings', 'bulletproof-security'); ?></label></strong><br />  
<input type="submit" name="Submit-Net-FSP" class="button bps-button" style="margin:10px 0px 20px 0px;width:232px;height:auto;white-space:normal" value="<?php esc_attr_e('Save Network FSP Options Sitewide', 'bulletproof-security') ?>" />
</div>
<?php bpsPro_network_subsites_fsp_settings(); ?>
</form>

<?php
// Zip File Download Fix
if ( isset( $_POST['Submit-Zip-Download-Fix'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_zip_download_fix' );
		
	if ( esc_html($_POST['bulletproof_security_options_zip_fix']) == 'On' ) {		
	
		$core_htaccess = WP_PLUGIN_DIR . '/bulletproof-security/admin/core/.htaccess';
		$login_htaccess = WP_PLUGIN_DIR . '/bulletproof-security/admin/login/.htaccess';
		$wizard_htaccess = WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/.htaccess';
	
		$files = array( $core_htaccess, $login_htaccess, $wizard_htaccess );
	
		foreach ( $files as $file ) {
			if ( file_exists($file) ) {
				unlink($file);
			}
		}
	
		$zip_fix_options = array( 'bps_zip_download_fix' => 'On' );

		foreach( $zip_fix_options as $key => $value ) {
			update_option('bulletproof_security_options_zip_fix', $zip_fix_options);
		}

		echo $bps_topDiv;
		$text = '<font color="green"><strong>'.__('The Zip File Download Fix option is set to On. This option should only be set to On if you are unable to download these Zip files: Custom Code Export Zip file, Login Security Table Export Zip file or the Setup Wizard Root htaccess file backup Zip file.', 'bulletproof-security').'</strong></font>';
		echo $text;
		echo $bps_bottomDiv;		

	} elseif ( esc_html($_POST['bulletproof_security_options_zip_fix']) == 'Off' ) {	
		
		$zip_fix_options = array( 'bps_zip_download_fix' => 'Off' );

		foreach( $zip_fix_options as $key => $value ) {
			update_option('bulletproof_security_options_zip_fix', $zip_fix_options);
		}

		echo $bps_topDiv;
		$text = '<font color="green"><strong>'.__('The Zip File Download Fix option is set to Off.', 'bulletproof-security').'</strong></font>';
		echo $text;
		echo $bps_bottomDiv;
	}
}

// Network|Multisite: Multisite Hide|Display System Info Page for Subsites
if ( isset( $_POST['Submit-MU-Sysinfo-Display'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_options_mu_sysinfo' );
		
	$network_ids = wp_get_sites();

	foreach ( $network_ids as $key => $value ) {
			
		$net_id = $value['blog_id'];

		$MU_Sysinfo_Options = array( 'bps_sysinfo_hide_display' => esc_html($_POST['bulletproof_security_options_mu_sysinfo_select']) );	
	
		foreach( $MU_Sysinfo_Options as $key => $value ) {
			update_blog_option( $net_id, 'bulletproof_security_options_mu_sysinfo', $MU_Sysinfo_Options);
		}		
	}

	echo $bps_topDiv;
	$text = '<font color="green"><strong>'.__('Multisite Hide|Display System Info Page for Subsites option saved.', 'bulletproof-security').'</strong></font>';
	echo $text;
	echo $bps_bottomDiv;
}

// Network|Multisite: update/save Login Security DB option settings for all sites
function bpsPro_network_subsites_lsm_settings() {
	
	if ( isset( $_POST['Submit-Net-LSM'] ) && current_user_can('manage_options') || isset( $_POST['Submit-Setup-Wizard'] ) && current_user_can('manage_options') ) {
			check_admin_referer( 'bps_setup_wizard' );
	
		if ( is_multisite() ) {
		
			if ( wp_is_large_network() ) {
				echo $bps_topDiv;
				$text = '<font color="#fb0101"><strong>'.__('Error: Your Network site exceeds the default WP criteria for a large network site. Either you have more than 10,000 users or more than 10,000 sites. Please send an email to info@ait-pro.com for help. Use this email Subject line: Setup Wizard Options Large Network Site Help.', 'bulletproof-security').'</strong></font>';
				echo $text;
				echo $bps_bottomDiv;
			
			return;
			}
	
			$successMessage = __(' LSM DB Options created or updated Successfully!', 'bulletproof-security');
			$successTextBegin = '<font color="green"><strong>';
			$successTextEnd = '</strong></font><br>';
	
			$BPS_LSM_Options = get_option('bulletproof_security_options_login_security');
			$woo_plugin = 'woocommerce/woocommerce.php';
			$woo_plugin_active = in_array( $woo_plugin, apply_filters('active_plugins', get_option('active_plugins')));
			
			// 13.2: BugFix: Enable Login Security for WooCommerce option being reset on rerun. Only enable once if the option does not exist.
			if ( $woo_plugin_active == 1 || is_plugin_active_for_network( $woo_plugin ) ) {
				// 12.6: New installations of BPS Pro should not display the WooCommerce Enable LSM & JTC options Dismiss Notice if WooCommerce is already installed.
				$bps_woo_lsm_jtc_options = array( 'bps_wizard_woo' => '1' );
		
				if ( $BPS_LSM_Options['bps_enable_lsm_woocommerce'] == '' || $BPS_LSM_Options['bps_enable_lsm_woocommerce'] == '1' ) {
					$bps_enable_lsm_woocommerce = $BPS_LSM_Options['bps_enable_lsm_woocommerce'];
				} elseif ( ! $BPS_LSM_Options['bps_enable_lsm_woocommerce'] ) {
					$bps_enable_lsm_woocommerce = '1';
				}
		
			} else {
				$bps_enable_lsm_woocommerce = '';
				$bps_woo_lsm_jtc_options = array( 'bps_wizard_woo' => '' );
			}
		
			foreach( $bps_woo_lsm_jtc_options as $key => $value ) {
				update_option('bulletproof_security_options_setup_wizard_woo', $bps_woo_lsm_jtc_options);
			}

			$network_ids = wp_get_sites();
	
			foreach ( $network_ids as $key => $value ) {
				
				$net_id = $value['blog_id'];
			
				$bps_Net_lsm = 'bulletproof_security_options_login_security';
		
				$BPS_Net_LSM_Options = array(
				'bps_max_logins' 				=> '3', 
				'bps_lockout_duration' 			=> '15', 
				'bps_manual_lockout_duration' 	=> '60', 
				'bps_max_db_rows_display' 		=> '', 
				'bps_login_security_OnOff' 		=> 'On', 
				'bps_login_security_logging' 	=> 'logLockouts', 
				'bps_login_security_errors' 	=> 'wpErrors', 
				'bps_login_security_remaining' 	=> 'On', 
				'bps_login_security_pw_reset' 	=> 'enable',  
				'bps_login_security_sort' 		=> 'ascending', 
				'bps_enable_lsm_woocommerce' 	=> $bps_enable_lsm_woocommerce 
				);
	
				if ( ! get_blog_option( $net_id, $bps_Net_lsm ) ) {	
			
					foreach( $BPS_Net_LSM_Options as $key => $value ) {
						update_blog_option( $net_id, 'bulletproof_security_options_login_security', $BPS_Net_LSM_Options );
					}
		
					echo $successTextBegin.'Site: '.$net_id.$successMessage.$successTextEnd;
				
				} else {
	
					$BPS_LSM_Options_Net = get_blog_option( $net_id, 'bulletproof_security_options_login_security' );
			
					$BPS_Net_Options_lsm = array(
					'bps_max_logins' 				=> $BPS_LSM_Options_Net['bps_max_logins'], 
					'bps_lockout_duration' 			=> $BPS_LSM_Options_Net['bps_lockout_duration'], 
					'bps_manual_lockout_duration' 	=> $BPS_LSM_Options_Net['bps_manual_lockout_duration'], 
					'bps_max_db_rows_display' 		=> $BPS_LSM_Options_Net['bps_max_db_rows_display'], 
					'bps_login_security_OnOff' 		=> $BPS_LSM_Options_Net['bps_login_security_OnOff'], 
					'bps_login_security_logging' 	=> $BPS_LSM_Options_Net['bps_login_security_logging'], 
					'bps_login_security_errors' 	=> $BPS_LSM_Options_Net['bps_login_security_errors'], 
					'bps_login_security_remaining' 	=> $BPS_LSM_Options_Net['bps_login_security_remaining'], 
					'bps_login_security_pw_reset' 	=> $BPS_LSM_Options_Net['bps_login_security_pw_reset'],  
					'bps_login_security_sort' 		=> $BPS_LSM_Options_Net['bps_login_security_sort'], 
					'bps_enable_lsm_woocommerce' 	=> $bps_enable_lsm_woocommerce 
					);
	
					foreach( $BPS_Net_Options_lsm as $key => $value ) {
						update_blog_option( $net_id, 'bulletproof_security_options_login_security', $BPS_Net_Options_lsm );
					}
						echo $successTextBegin.'Site: '.$net_id.$successMessage.$successTextEnd;
				}
			}
		}
	}
}

// Network|Multisite: update/save JTC Anti-Spam|Anti-Hacker DB option settings for all sites
function bpsPro_network_subsites_jtc_settings() {
	
	if ( isset( $_POST['Submit-Net-JTC'] ) && current_user_can('manage_options') || isset( $_POST['Submit-Setup-Wizard'] ) && current_user_can('manage_options') ) {
			check_admin_referer( 'bps_setup_wizard' );
	
		if ( is_multisite() ) {
		
			if ( wp_is_large_network() ) {
				echo $bps_topDiv;
				$text = '<font color="#fb0101"><strong>'.__('Error: Your Network site exceeds the default WP criteria for a large network site. Either you have more than 10,000 users or more than 10,000 sites. Please send an email to info@ait-pro.com for help. Use this email Subject line: Setup Wizard Options Large Network Site Help.', 'bulletproof-security').'</strong></font>';
				echo $text;
				echo $bps_bottomDiv;
			
			return;
			}
	
			$successMessage = __(' JTC DB Options created or updated Successfully!', 'bulletproof-security');
			$successTextBegin = '<font color="green"><strong>';
			$successTextEnd = '</strong></font><br>';
	
			$jtc_options = get_option('bulletproof_security_options_login_security_jtc'); 
			
			if ( has_action('bp_after_signup_profile_fields') && has_action('bp_signup_validate') && has_action('bp_sidebar_login_form') ) {
				$bps_jtc_buddypress_register_form = '1';
				$bps_jtc_buddypress_sidebar_form = '1';
			} else {
				$bps_jtc_buddypress_register_form = '0';
				$bps_jtc_buddypress_sidebar_form = '0';
			}
		
			if ( ! $jtc_options['bps_jtc_custom_roles'] ) {
					$bps_jtc_custom_roles = array( 'bps', '' );
				
			} else {
		
				foreach ( $jtc_options as $key => $value ) {
				
					if ( $key == 'bps_jtc_custom_roles' ) {
							
						if ( ! is_array($value) ) {
							$bps_jtc_custom_roles = array( 'bps', '' );
						} else { 
							$bps_jtc_custom_roles = $jtc_options['bps_jtc_custom_roles'];
						}
					}
				}
			}
			
			// 13.5: Added new JTC option: bps_jtc_mu_register_form. Default for standard site is: 0 and MU is: 1 on new installations.
			// 13.4.1: Added new JTC option: bps_jtc_custom_form_error. Defaults to standard JTC CAPTCHA error message.
			// 13.2: BugFix: Enable JTC for WooCommerce option being reset on rerun. Only enable once if the option does not exist.
			// 13.3: BugFix: JTC options being reset on Setup Wizard rerun - ternary should not be used here - reverted to WP standard ! get_option.
			if ( $woo_plugin_active == 1 || is_plugin_active_for_network( $woo_plugin ) ) {
				if ( $jtc_options['bps_enable_jtc_woocommerce'] == '' || $jtc_options['bps_enable_jtc_woocommerce'] == '1' ) {
					$bps_enable_jtc_woocommerce = $jtc_options['bps_enable_jtc_woocommerce'];
				} elseif ( ! $jtc_options['bps_enable_jtc_woocommerce'] ) {
					$bps_enable_jtc_woocommerce = '1';
				}
			} else {
				$bps_enable_jtc_woocommerce = '';
			}
		
			$bps_jtc_custom_form_error = ! $jtc_options['bps_jtc_custom_form_error'] ? '' : $jtc_options['bps_jtc_custom_form_error'];
			
			if ( is_multisite() ) {
				$bps_jtc_mu_register_form = '1';
			} else {
				$bps_jtc_mu_register_form = '0';
			}

			$network_ids = wp_get_sites();
	
			foreach ( $network_ids as $key => $value ) {
				
				$net_id = $value['blog_id'];
			
				$bps_Net_jtc = 'bulletproof_security_options_login_security_jtc';
		
				$BPS_Net_JTC_Options = array(
				'bps_tooltip_captcha_key' 			=> 'jtc', 
				'bps_tooltip_captcha_hover_text' 	=> 'Type/Enter:  jtc', 
				'bps_tooltip_captcha_title' 		=> 'Hover or click the text box below', 
				'bps_tooltip_captcha_logging' 		=> 'Off', 
				'bps_jtc_login_form' 				=> '1', 
				'bps_jtc_register_form' 			=> '1', 
				'bps_jtc_lostpassword_form' 		=> '1', 
				'bps_jtc_comment_form' 				=> '0', 
				'bps_jtc_mu_register_form' 			=> $bps_jtc_mu_register_form, 
				'bps_jtc_buddypress_register_form' 	=> $bps_jtc_buddypress_register_form, 
				'bps_jtc_buddypress_sidebar_form' 	=> $bps_jtc_buddypress_sidebar_form, 
				'bps_jtc_administrator' 			=> '0', 
				'bps_jtc_editor' 					=> '0', 
				'bps_jtc_author' 					=> '0', 
				'bps_jtc_contributor' 				=> '0', 
				'bps_jtc_subscriber' 				=> '0', 
				'bps_jtc_comment_form_error' 		=> '', 
				'bps_jtc_comment_form_label' 		=> '', 
				'bps_jtc_comment_form_input' 		=> '', 
				'bps_jtc_custom_roles' 				=> $bps_jtc_custom_roles, 
				'bps_enable_jtc_woocommerce' 		=> $bps_enable_jtc_woocommerce, 
				'bps_jtc_custom_form_error' 		=> $bps_jtc_custom_form_error 
				);
	
				if ( ! get_blog_option( $net_id, $bps_Net_jtc ) ) {	
			
					foreach( $BPS_Net_JTC_Options as $key => $value ) {
						update_blog_option( $net_id, 'bulletproof_security_options_login_security_jtc', $BPS_Net_JTC_Options );
					}
		
					echo $successTextBegin.'Site: '.$net_id.$successMessage.$successTextEnd;
	
				} else {
	
					$BPS_JTC_Options_Net = get_blog_option( $net_id, 'bulletproof_security_options_login_security_jtc' );
			
					$BPS_Net_Options_jtc = array(
					'bps_tooltip_captcha_key' 			=> $BPS_JTC_Options_Net['bps_tooltip_captcha_key'], 
					'bps_tooltip_captcha_hover_text' 	=> $BPS_JTC_Options_Net['bps_tooltip_captcha_hover_text'], 
					'bps_tooltip_captcha_title' 		=> $BPS_JTC_Options_Net['bps_tooltip_captcha_title'], 
					'bps_tooltip_captcha_logging' 		=> $BPS_JTC_Options_Net['bps_tooltip_captcha_logging'], 
					'bps_jtc_login_form' 				=> $BPS_JTC_Options_Net['bps_jtc_login_form'], 
					'bps_jtc_register_form' 			=> $BPS_JTC_Options_Net['bps_jtc_register_form'], 
					'bps_jtc_lostpassword_form' 		=> $BPS_JTC_Options_Net['bps_jtc_lostpassword_form'], 
					'bps_jtc_comment_form' 				=> $BPS_JTC_Options_Net['bps_jtc_comment_form'], 
					'bps_jtc_mu_register_form' 			=> $BPS_JTC_Options_Net['bps_jtc_mu_register_form'], 
					'bps_jtc_buddypress_register_form' 	=> $BPS_JTC_Options_Net['bps_jtc_buddypress_register_form'], 
					'bps_jtc_buddypress_sidebar_form' 	=> $BPS_JTC_Options_Net['bps_jtc_buddypress_sidebar_form'], 
					'bps_jtc_administrator' 			=> $BPS_JTC_Options_Net['bps_jtc_administrator'], 
					'bps_jtc_editor' 					=> $BPS_JTC_Options_Net['bps_jtc_editor'], 
					'bps_jtc_author' 					=> $BPS_JTC_Options_Net['bps_jtc_author'], 
					'bps_jtc_contributor' 				=> $BPS_JTC_Options_Net['bps_jtc_contributor'], 
					'bps_jtc_subscriber' 				=> $BPS_JTC_Options_Net['bps_jtc_subscriber'], 
					'bps_jtc_comment_form_error' 		=> $BPS_JTC_Options_Net['bps_jtc_comment_form_error'], 
					'bps_jtc_comment_form_label' 		=> $BPS_JTC_Options_Net['bps_jtc_comment_form_label'], 
					'bps_jtc_comment_form_input' 		=> $BPS_JTC_Options_Net['bps_jtc_comment_form_input'], 
					'bps_jtc_custom_roles' 				=> $bps_jtc_custom_roles, 
					'bps_enable_jtc_woocommerce' 		=> $bps_enable_jtc_woocommerce, 
					'bps_jtc_custom_form_error' 		=> $bps_jtc_custom_form_error 
					);
	
					foreach( $BPS_Net_Options_jtc as $key => $value ) {
						update_blog_option( $net_id, 'bulletproof_security_options_login_security_jtc', $BPS_Net_Options_jtc );
					}
						echo $successTextBegin.'Site: '.$net_id.$successMessage.$successTextEnd;
				}
			}
		}
	}
}

// Network|Multisite: update/save Force Strong Passwords DB option settings for all sites
function bpsPro_network_subsites_fsp_settings() {
	
	if ( isset( $_POST['Submit-Net-FSP'] ) && current_user_can('manage_options') || isset( $_POST['Submit-Setup-Wizard'] ) && current_user_can('manage_options') ) {
			check_admin_referer( 'bps_setup_wizard' );
	
		if ( is_multisite() ) {
		
			if ( wp_is_large_network() ) {
				echo $bps_topDiv;
				$text = '<font color="#fb0101"><strong>'.__('Error: Your Network site exceeds the default WP criteria for a large network site. Either you have more than 10,000 users or more than 10,000 sites. Please send an email to info@ait-pro.com for help. Use this email Subject line: Setup Wizard Options Large Network Site Help.', 'bulletproof-security').'</strong></font>';
				echo $text;
				echo $bps_bottomDiv;
			
			return;
			}
	
			$successMessage = __(' FSP DB Options created or updated Successfully!', 'bulletproof-security');
			$successTextBegin = '<font color="green"><strong>';
			$successTextEnd = '</strong></font><br>';
	
			$BPS_FSP_Options = get_option('bulletproof_security_options_fsp');
			$network_ids = wp_get_sites();
	
			foreach ( $network_ids as $key => $value ) {
				
				$net_id = $value['blog_id'];
			
				$bps_Net_fsp = 'bulletproof_security_options_fsp';
				$FSP_Message = 'Password must contain 1 lowercase letter, 1 uppercase letter, 1 number, 1 special character and be a minimum of 12 characters long.';
		
				$BPS_Net_FSP_Options = array(
				'bps_fsp_on_off' 		=> 'Off', 
				'bps_fsp_char_length' 	=> '12', 
				'bps_fsp_lower_case' 	=> '1', 
				'bps_fsp_upper_case' 	=> '1', 
				'bps_fsp_number' 		=> '1', 
				'bps_fsp_special_char' 	=> '1', 
				'bps_fsp_message' 		=> $FSP_Message  
				);
	
				if ( ! get_blog_option( $net_id, $bps_Net_fsp ) ) {	
			
					foreach( $BPS_Net_FSP_Options as $key => $value ) {
						update_blog_option( $net_id, 'bulletproof_security_options_fsp', $BPS_Net_FSP_Options );
					}
		
					echo $successTextBegin.'Site: '.$net_id.$successMessage.$successTextEnd;
				
				} else {
	
					$BPS_FSP_Options_Net = get_blog_option( $net_id, 'bulletproof_security_options_fsp' );
			
					$BPS_Net_Options_fsp = array(
					'bps_fsp_on_off' 		=> $BPS_FSP_Options_Net['bps_fsp_on_off'], 
					'bps_fsp_char_length' 	=> $BPS_FSP_Options_Net['bps_fsp_char_length'], 
					'bps_fsp_lower_case' 	=> $BPS_FSP_Options_Net['bps_fsp_lower_case'], 
					'bps_fsp_upper_case' 	=> $BPS_FSP_Options_Net['bps_fsp_upper_case'], 
					'bps_fsp_number' 		=> $BPS_FSP_Options_Net['bps_fsp_number'], 
					'bps_fsp_special_char' 	=> $BPS_FSP_Options_Net['bps_fsp_special_char'], 
					'bps_fsp_message' 		=> $BPS_FSP_Options_Net['bps_fsp_message'] 
					);
	
					foreach( $BPS_Net_Options_fsp as $key => $value ) {
						update_blog_option( $net_id, 'bulletproof_security_options_fsp', $BPS_Net_Options_fsp );
					}
						echo $successTextBegin.'Site: '.$net_id.$successMessage.$successTextEnd;
				}
			}
		}
	}
}
?>

	</td>
  </tr>
</table>

</div>    

<div id="bps-tabs-3" class="bps-tab-page">

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bps-help_faq_table">
  <tr>
    <td class="bps-table_title"><h2><?php _e('Setup Wizard Export|Import ~ ', 'bulletproof-security'); ?><span style="font-size:.75em;"><?php _e('Export or Import BPS Pro plugin option settings.', 'bulletproof-security'); ?></span></h2></td>
  </tr>
  <tr>
    <td class="bps-table_cell_help">
    
<h3 style="margin:0px 0px 5px 0px;"><?php _e('Setup Wizard Export|Import', 'bulletproof-security'); ?>  <button id="bps-open-modal3" class="button bps-modal-button"><?php _e('Read Me', 'bulletproof-security'); ?></button></h3>

<div id="bps-modal-content3" class="bps-dialog-hide" title="<?php _e('Setup Wizard Export|Import', 'bulletproof-security'); ?>">
    <p>
	<?php
        $text = '<strong>'.__('This Read Me Help window is draggable (top) and resizable (bottom right corner)', 'bulletproof-security').'</strong><br><br>';
		echo $text; 
		// Forum Help Links or of course both
		//$text = '<strong><font color="blue">'.__('Forum Help Links: ', 'bulletproof-security').'</font></strong><br>'; 	
		//echo $text;	
	?>
	<!--<strong><a href="https://forum.ait-pro.com/forums/topic/gdmw/" title="GDMW Hosting" target="_blank">
	<?php _e('GDMW Hosting', 'bulletproof-security'); ?></a></strong><br />-->
	
	<?php $dialog_text = '<font color="blue"><strong>'.__('AutoRestore is set to Off automatically in the zip export file so that when you import BPS Pro plugin option settings into a new website AutoRestore will be turned Off on the new website to prevent any possible problems.', 'bulletproof-security').'</strong></font><br><br><strong>'.__('Setup Wizard Export', 'bulletproof-security').'</strong><br>'.__('The Setup Wizard Export feature exports all BPS Pro plugin option settings except for website specific settings that need to be setup by running the Pre-Installation Wizard and Setup Wizard after you have imported the BPS Pro plugin option settings into a new website. The name of the exported zip file is: bps-pro-settings-export.zip', 'bulletproof-security').'<br><br><strong>'.__('Setup Wizard Import', 'bulletproof-security').'</strong><br>'.__('To import BPS Pro plugin option settings click the Choose File button, navigate to where you downloaded/saved the bps-pro-settings-export.zip file on your computer, select the zip file and click the Open button. Then click the Import button. IMPORTANT: Run the BPS Pro Pre-Installation Wizard and Setup Wizard after the import completes. After running the Wizards go to the BPS Pro > B-Core > Custom Code tab page and check all of your custom htaccess code for any website specific custom htaccess code. Example: If you find any custom htaccess code that has a website URL for your other website that you exported BPS Pro plugin settings from, then either edit that custom htaccess code or remove it from BPS Custom Code.', 'bulletproof-security').'<br><br><strong>'.__('Network|Multisite Help Info', 'bulletproof-security').'</strong><br>'.__('Setup Wizard Export|Import works for Network|Multisite site types, but only the Primary site\'s BPS Pro plugin option settings are exported and imported. BPS Pro plugin option settings are not exported or imported for Subsites. Note: These Setup Wizard Options > Network|Multisite Sitewide Login Security Settings, Network|Multisite Sitewide JTC Anti-Spam|Anti-Hacker Settings and Network|Multisite Sitewide Force Strong Passwords Settings can be run after importing BPS Pro plugin option settings to apply BPS Pro LSM, JTC and FSP plugin option settings from the Primary site to all Subsites.', 'bulletproof-security'); echo $dialog_text; ?></p>
</div>

<div id="CC-Import" style="margin:20px 0px 20px 0px">
<form name="bpsSWImport" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/wizard/wizard.php#bps-tabs-3' ); ?>" method="post" enctype="multipart/form-data">
	<?php wp_nonce_field('bulletproof_security_sw_import'); ?>
	<input type="file" name="bps_sw_import" id="bps_sw_import" />
	<input type="submit" name="Submit-SW-Import" class="button bps-button" style="margin-top:1px;" value="<?php esc_attr_e('Import', 'bulletproof-security') ?>" onclick="return confirm('<?php $text = __('Clicking OK will Import BPS Pro plugin settings from the bps-pro-settings-export.zip file on your computer.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Import BPS Pro plugin settings or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	<?php bpsPro_setup_wizard_import(); ?>
</form>
</div>

<div id="CC-Export" style="margin-bottom:10px">
<form name="bpsSWExport" id="bpsExport" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/wizard/wizard.php#bps-tabs-3' ); ?>" method="post">
	<?php wp_nonce_field('bulletproof_security_sw_export'); ?>
    <input type="submit" name="Submit-SW-Export" class="button bps-button" value="<?php esc_attr_e('Export', 'bulletproof-security') ?>" onclick="return confirm('<?php 
$text = __('Clicking OK will Export your BPS Pro plugin settings into the bps-pro-settings-export.zip file, which you can then download to your computer by clicking the Download Zip Export button displayed in the Setup Wizard Export success message.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Export BPS Pro plugin settings or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	<?php bpsPro_setup_wizard_export(); ?>
</form>
</div>


<?php

// Zip the Setup Wizard Export file: setup-wizard-export.php - If ZipArchive Class is not available use PclZip
function bpsPro_zip_setup_wizard_export_file() {

	$filename = WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/bps-pro-settings-export.zip';
	
	if ( file_exists($filename) ) {
		unlink($filename);
	}

	// Use ZipArchive
	if ( class_exists('ZipArchive') ) {

		$zip = new ZipArchive();

		if ( $zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE ) {
    		exit("Error: Cannot Open $filename\n");
		}

		$zip->addFile(WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/setup-wizard-export.php', "setup-wizard-export.php");
		$zip->close();

	return true;

	} else {

		// Use PclZip
		define( 'PCLZIP_TEMPORARY_DIR', WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/' );
		require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php');
	
		if ( ini_get( 'mbstring.func_overload' ) && function_exists( 'mb_internal_encoding' ) ) {
			$previous_encoding = mb_internal_encoding();
			mb_internal_encoding( 'ISO-8859-1' );
		}
  		
		$archive = new PclZip(WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/bps-pro-settings-export.zip');
  		$v_list = $archive->create(WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/setup-wizard-export.php', PCLZIP_OPT_REMOVE_PATH, WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/');
  	
	return true;

		if ( $v_list == 0 ) {
			die("Error : ".$archive->errorInfo(true) );
		return false;	
		}
	}
}

// Setup Wizard Export: Creates BPS Pro plugin option settings in a file that is called by an include/require on Import.
// Network|Multisite: Only the Primary site's BPS Pro plugin option settings can be exported and imported.
// Don't do an automatic download. There are issues with some Browsers.
function bpsPro_setup_wizard_export() {
global $wpdb, $blog_id, $bps_topDiv, $bps_bottomDiv;
		
	if ( isset( $_POST['Submit-SW-Export'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_sw_export' );

		if ( is_multisite() && $blog_id != 1 ) {
			return;
		
		} else {
	
			$timeNow = time();
			$gmt_offset = get_option( 'gmt_offset' ) * 3600;
			$timestamp = date_i18n(get_option('date_format'), strtotime("11/15-1976")) . ' ' . date_i18n(get_option('time_format'), $timeNow + $gmt_offset);
			$wizard_export = WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/setup-wizard-export.php';
			
			$handle = fopen( $wizard_export, 'wb' );
		
		if ( $handle )
	
			fwrite( $handle, "<?php\n" );
			fwrite( $handle, "## ---------------------------------------------\n" );
			fwrite( $handle, "## BulletProof Security Pro Setup Wizard Export\n" );
			fwrite( $handle, "## Support: https://forum.ait-pro.com/\n" );
			fwrite( $handle, "## Export Time: ". $timestamp . "\n" );
			fwrite( $handle, "## Website: " . get_bloginfo( 'url' ) . "\n" );
			fwrite( $handle, "## WP ABSPATH: ". ABSPATH . "\n" );
			fwrite( $handle, "## ---------------------------------------------\n\n" );
			fwrite( $handle, "## BPS Pro Plugin Options\n\n" );	
		
			$bps_plugin_options = 'bulletproof_security_options';	
			$BPSPluginOptionRows = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->options WHERE option_name LIKE %s", "$bps_plugin_options%" ) );
			
			foreach ( $BPSPluginOptionRows as $data ) {
				
				// Exclude these BPS Pro option settings
				if ( $data->option_name != 'bulletproof_security_options_activation' && $data->option_name != 'bulletproof_security_options_apache_modules' && $data->option_name != 'bulletproof_security_options2' && $data->option_name != 'bulletproof_security_options_iniSet' && $data->option_name != 'bulletproof_security_options_MScan_status' && $data->option_name != 'bulletproof_security_options_Security_log' && $data->option_name != 'bulletproof_security_options_elog' && $data->option_name != 'bulletproof_security_options_ARCM_log' && $data->option_name != 'bulletproof_security_options_MScan_log' && $data->option_name != 'bulletproof_security_options_DBB_log' && $data->option_name != 'bulletproof_security_options_DBM_log' && $data->option_name != 'bulletproof_security_options_login_alerts' && $data->option_name != 'bulletproof_security_options_db_backup' && $data->option_name != 'bulletproof_security_options_db_monitor' && $data->option_name != 'bulletproof_security_options_flock_FL_alerts' && $data->option_name != 'bulletproof_security_options_mod_security' && $data->option_name != 'bulletproof_security_options_pfw_new_install' && $data->option_name != 'bulletproof_security_options_preinstallation' && $data->option_name != 'bulletproof_security_options_rate_pro' && $data->option_name != 'bulletproof_security_options_wp_version' && $data->option_name != 'bulletproof_security_options_mscan_plugin_hash' && $data->option_name != 'bulletproof_security_options_mscan_p_hash_new' && $data->option_name != 'bulletproof_security_options_mscan_theme_hash' && $data->option_name != 'bulletproof_security_options_mscan_t_hash_new' && $data->option_name != 'bulletproof_security_options_mscan_nodownload' && $data->option_name != 'bulletproof_security_options_mscan_zip_upload' && $data->option_name != 'bulletproof_security_options_arq_add_hidden' && $data->option_name != 'bulletproof_security_options_arq_host_root' ) {
				
					fwrite( $handle, "$".$data->option_name." = '".$data->option_name."';\n" );
					fwrite( $handle, "$".$data->option_name."_array = array(\n" );
		
					$options_array = maybe_unserialize($data->option_value);
					
					foreach ( $options_array as $key => $value ) {
						
						if ( ! is_array($value) ) {
						
							// Remove or change option keys or values
							if ( $key == 'bps_autorestore_cron' ) {
								$value = 'Off';
							}
			
							fwrite( $handle, "'".$key."'"." => '".$value."', \n" );
						}
					}
				
					fwrite( $handle, ");\n\n" );
					fwrite( $handle, "if ( ! get_option( $".$data->option_name." ) ) {\n" );
					fwrite( $handle, "foreach( $".$data->option_name."_array as \$key => \$value ) {\n" );
					fwrite( $handle, "update_option('".$data->option_name."', $".$data->option_name."_array);\n" );
					fwrite( $handle, "}\n\n" );
					fwrite( $handle, "} else {\n\n" );
					fwrite( $handle, "foreach( $".$data->option_name."_array as \$key => \$value ) {\n" );
					fwrite( $handle, "update_option('".$data->option_name."', $".$data->option_name."_array);\n" );
					fwrite( $handle, "}\n" );
					fwrite( $handle, "}\n\n" );
				}
			}
				
			fwrite( $handle, "?>\n" );
			
			$wizard_zip_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/bps-pro-settings-export.zip';
			
			if ( file_exists($wizard_export) ) {
			
				if ( bpsPro_zip_setup_wizard_export_file() == true ) {
	
					echo $bps_topDiv;
					$text = '<font color="green"><strong>'.__('BPS Pro plugin option settings exported successfully. Click the Download Zip Export button to download the Setup Wizard Export zip file: bps-pro-settings-export.zip.', 'bulletproof-security').'<br>'.__('If you see a 403 error and/or are unable to download the zip file then click here: ', 'bulletproof-security').'<a href="'.admin_url( 'admin.php?page=bulletproof-security/admin/wizard/wizard.php#bps-tabs-2' ).'" target="_blank">'.__('Setup Wizard Options', 'bulletproof-security').'</a>'.__(' and select the Zip File Download Fix On setting for the Zile File Download Fix option. You should now be able to download the bps-pro-settings-export.zip file.', 'bulletproof-security').'</strong></font><br><div style="width:140px;font-size:1em;text-align:center;margin:10px 0px 0px 0px;padding:4px 6px 4px 6px;background-color:#e8e8e8;border:1px solid gray;"><a href="'.plugins_url( '/bulletproof-security/admin/wizard/bps-pro-settings-export.zip' ).'" style="font-size:1em;font-weight:bold;text-decoration:none;">'.__('Download Zip Export', 'bulletproof-security').'</a></div>';
					echo $text;
					echo $bps_bottomDiv;
				}		
			}		
		}
	}
}

// Update the BPS Pro plugin option settings by processing the setup-wizard-export.php file once.
function bpsPro_SW_DB_Update() {
	
	$SW_export = WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/setup-wizard-export.php';
	
	if ( file_exists($SW_export) ) {
		
		require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/setup-wizard-export.php' );		
		
		// Update the Admin email address option settings in S-Monitor and MMode to the current site's Admin email address
		$admin_email = get_option('admin_email');

		$BPS_SMEmail_Options = get_option('bulletproof_security_options_email');
		
		$BPS_Options_smemail = array(
		'bps_send_email_to' 			=> $admin_email, 
		'bps_send_email_from' 			=> $admin_email, 
		'bps_send_email_cc' 			=> $BPS_SMEmail_Options['bps_send_email_cc'], 
		'bps_send_email_bcc' 			=> $BPS_SMEmail_Options['bps_send_email_bcc'], 
		'bps_login_security_email' 		=> $BPS_SMEmail_Options['bps_login_security_email'], 
		'bps_autorestore_email' 		=> $BPS_SMEmail_Options['bps_autorestore_email'], 
		'bps_arq_log_size' 				=> $BPS_SMEmail_Options['bps_arq_log_size'], 
		'bps_arq_log_email' 			=> $BPS_SMEmail_Options['bps_arq_log_email'], 
		'bps_security_log_email' 		=> $BPS_SMEmail_Options['bps_security_log_email'], 
		'bps_security_log_size' 		=> $BPS_SMEmail_Options['bps_security_log_size'], 
		'bps_security_log_emailL' 		=> $BPS_SMEmail_Options['bps_security_log_emailL'], 
		'bps_error_log_email' 			=> $BPS_SMEmail_Options['bps_error_log_email'],  
		'bps_php_log_size' 				=> $BPS_SMEmail_Options['bps_php_log_size'], 
		'bps_php_log_email' 			=> $BPS_SMEmail_Options['bps_php_log_email'],  
		'bps_upgrade_email' 			=> $BPS_SMEmail_Options['bps_upgrade_email'],  
		'bps_dbm_email' 				=> $BPS_SMEmail_Options['bps_dbm_email'], 
		'bps_dbm_log_email' 			=> $BPS_SMEmail_Options['bps_dbm_log_email'], 
		'bps_dbm_log_size' 				=> $BPS_SMEmail_Options['bps_dbm_log_size'],  
		'bps_dbb_log_email' 			=> $BPS_SMEmail_Options['bps_dbb_log_email'], 
		'bps_dbb_log_size' 				=> $BPS_SMEmail_Options['bps_dbb_log_size'], 
		'bps_flock_email' 				=> $BPS_SMEmail_Options['bps_flock_email'], 
		'bps_arq_cron_frequency_email' 	=> $BPS_SMEmail_Options['bps_arq_cron_frequency_email'], 
		'bps_arq_cron_next_email' 		=> $BPS_SMEmail_Options['bps_arq_cron_next_email'], 
		'bps_hpf_email' 				=> $BPS_SMEmail_Options['bps_hpf_email'], 
		'bps_mscan_email' 				=> $BPS_SMEmail_Options['bps_mscan_email'], 
		'bps_mscan_log_size' 			=> $BPS_SMEmail_Options['bps_mscan_log_size'], 
		'bps_mscan_log_email' 			=> $BPS_SMEmail_Options['bps_mscan_log_email'], 
		'bps_plugin_updates_frequency' 	=> $BPS_SMEmail_Options['bps_plugin_updates_frequency'], 
		'bps_plugin_updates_email' 		=> $BPS_SMEmail_Options['bps_plugin_updates_email'],
		'bps_theme_updates_frequency' 	=> $BPS_SMEmail_Options['bps_theme_updates_frequency'],
		'bps_theme_updates_email' 		=> $BPS_SMEmail_Options['bps_theme_updates_email'] 
		);

		foreach( $BPS_Options_smemail as $key => $value ) {
			update_option('bulletproof_security_options_email', $BPS_Options_smemail);
		}
		
		$BPS_MMode = get_option('bulletproof_security_options_maint_mode');
		
		$BPS_Options_MMode = array(
		'bps_maint_on_off' 					=> $BPS_MMode['bps_maint_on_off'], 
		'bps_maint_countdown_timer' 		=> $BPS_MMode['bps_maint_countdown_timer'], 
		'bps_maint_countdown_timer_color' 	=> $BPS_MMode['bps_maint_countdown_timer_color'], 
		'bps_maint_time' 					=> $BPS_MMode['bps_maint_time'], 
		'bps_maint_retry_after' 			=> $BPS_MMode['bps_maint_retry_after'], 
		'bps_maint_frontend' 				=> $BPS_MMode['bps_maint_frontend'], 
		'bps_maint_backend' 				=> $BPS_MMode['bps_maint_backend'], 
		'bps_maint_ip_allowed' 				=> $BPS_MMode['bps_maint_ip_allowed'], 
		'bps_maint_text' 					=> $BPS_MMode['bps_maint_text'],
		'bps_maint_background_images' 		=> $BPS_MMode['bps_maint_background_images'], 
		'bps_maint_center_images' 			=> $BPS_MMode['bps_maint_center_images'], 
		'bps_maint_background_color' 		=> $BPS_MMode['bps_maint_background_color'], 
		'bps_maint_show_visitor_ip' 		=> $BPS_MMode['bps_maint_show_visitor_ip'], 
		'bps_maint_show_login_link' 		=> $BPS_MMode['bps_maint_show_login_link'], 
		'bps_maint_dashboard_reminder' 		=> $BPS_MMode['bps_maint_dashboard_reminder'], 
		'bps_maint_log_visitors' 			=> $BPS_MMode['bps_maint_log_visitors'], 
		'bps_maint_countdown_email' 		=> $BPS_MMode['bps_maint_countdown_email'], 
		'bps_maint_email_to' 				=> $admin_email, 
		'bps_maint_email_from' 				=> $admin_email, 
		'bps_maint_email_cc' 				=> $BPS_MMode['bps_maint_email_cc'], 
		'bps_maint_email_bcc' 				=> $BPS_MMode['bps_maint_email_bcc'], 
		'bps_maint_mu_entire_site' 			=> $BPS_MMode['bps_maint_mu_entire_site'], 
		'bps_maint_mu_subsites_only' 		=> $BPS_MMode['bps_maint_mu_subsites_only']
		);	
	
		foreach( $BPS_Options_MMode as $key => $value ) {
			update_option('bulletproof_security_options_maint_mode', $BPS_Options_MMode);
		}

		// Update ISL logout and login URL's ONLY if the ISL options have already been saved before.
		$BPS_ISL = get_option('bulletproof_security_options_idle_session');

		$ISL_logout_url = plugins_url('/bulletproof-security/isl-logout.php');
		$ISL_login_url = site_url('/wp-login.php');
		$Custom_Roles = $BPS_ISL['bps_isl_custom_roles'];

		if ( ! empty($Custom_Roles) ) {
			
			$Custom_Roles_array = array();
			
			foreach ( $Custom_Roles as $key => $value ) {
				
				if ( $value == '1' ) {
					$Custom_Roles_array[$key] = $value;
				} 
			}
		
		} else {
			
			$Custom_Roles_array = array( 'bps', '' );
		}

		$ISL_Options = array(
		'bps_isl' 							=> $BPS_ISL['bps_isl'], 
		'bps_isl_timeout' 					=> $BPS_ISL['bps_isl_timeout'], 
		'bps_isl_logout_url' 				=> $ISL_logout_url, 
		'bps_isl_login_url' 				=> $ISL_login_url,
		'bps_isl_custom_message' 			=> $BPS_ISL['bps_isl_custom_message'],
		'bps_isl_custom_css_1' 				=> $BPS_ISL['bps_isl_custom_css_1'],
		'bps_isl_custom_css_2' 				=> $BPS_ISL['bps_isl_custom_css_2'],
		'bps_isl_custom_css_3' 				=> $BPS_ISL['bps_isl_custom_css_3'],
		'bps_isl_custom_css_4' 				=> $BPS_ISL['bps_isl_custom_css_4'],	
		'bps_isl_user_account_exceptions' 	=> $BPS_ISL['bps_isl_user_account_exceptions'], 
		'bps_isl_administrator' 			=> $BPS_ISL['bps_isl_administrator'], 
		'bps_isl_editor' 					=> $BPS_ISL['bps_isl_editor'], 
		'bps_isl_author' 					=> $BPS_ISL['bps_isl_author'], 
		'bps_isl_contributor' 				=> $BPS_ISL['bps_isl_contributor'], 
		'bps_isl_subscriber' 				=> $BPS_ISL['bps_isl_subscriber'], 
		'bps_isl_tinymce' 					=> $BPS_ISL['bps_isl_tinymce'], 
		'bps_isl_uri_exclusions' 			=> $BPS_ISL['bps_isl_uri_exclusions'], 
		'bps_isl_custom_roles' 				=> $Custom_Roles_array  
		);	
	
		if ( ! get_option('bulletproof_security_options_idle_session') ) {
			// do nothing
			
		} else {
		
			foreach( $ISL_Options as $key => $value ) {
				update_option('bulletproof_security_options_idle_session', $ISL_Options);
			}
		}

		return true;
	
	} else {
		
		return false;
	}
}

// Setup Wizard Import: Import the Setup Wizard Export zip file: bps-pro-settings-export.zip
// Notes: Don't use the WP wp_handle_upload() function. I need more flexibility.
function bpsPro_setup_wizard_import() {
global $bps_topDiv, $bps_bottomDiv;	
	
	if ( isset( $_POST['Submit-SW-Import'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_sw_import' );
	
		$bpsZipFilename = 'bps-pro-settings-export.zip';
		$bps_tmp_file = $_FILES['bps_sw_import']['tmp_name'];
		$zip_folder_path = WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/';
		$bps_uploaded_zip = str_replace( '//', '/', $zip_folder_path) . $_FILES['bps_sw_import']['name'];
		$bpsZipzUploadFail = $_FILES['bps_sw_import']['name'];
		$SW_export = WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/setup-wizard-export.php';
		
		if ( file_exists($SW_export) ) {
			unlink($SW_export);
		}
		
		echo $bps_topDiv;

		if ( ! empty($_FILES) ) {
		if ( $_FILES['bps_sw_import']['name'] == $bpsZipFilename ) {
		
			if ( move_uploaded_file($bps_tmp_file, $bps_uploaded_zip) ) {

				$text = '<strong><font color="green">'.__('Zip File Upload Successful.', 'bulletproof-security').'</font></strong><br>';
				echo $text;
				
				if ( class_exists('ZipArchive') ) {	

					$bpsZip = new ZipArchive;
	
					if ( $bpsZip->open( WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/bps-pro-settings-export.zip' ) === TRUE ) {
						$bpsZip->extractTo( WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/' );
    					$bpsZip->close();
    	
						$text = '<strong><font color="green">'.__('Zip File Exraction Successful. Method: ZipArchive class.', 'bulletproof-security').'</font></strong><br>';
						echo $text;

						// Update BPS Pro plugin option settings from the extracted setup-wizard-export.php file.
						if ( bpsPro_SW_DB_Update() == true ) {
							$text = '<strong><font color="green">'.__('BPS Pro plugin settings imported successfully.', 'bulletproof-security').'</font><br><br><font color="blue">'.__('IMPORTANT: Run the BPS Pro Pre-Installation Wizard and Setup Wizard now.', 'bulletproof-security').'</font><br><br>'.__('After running the Wizards go to the BPS Pro > B-Core > Custom Code tab page and check all of your custom htaccess code for any website specific custom htaccess code. Example: If you find any custom htaccess code that has a website URL for your other website that you exported BPS Pro plugin settings from, then either edit that custom htaccess code or remove it from BPS Custom Code.', 'bulletproof-security').'</strong>';
							echo $text;
						}

					} else {
	
						$text = '<strong><font color="#fb0101">'.__('ERROR: Zip File Extraction Failed. Method: ZipArchive class.', 'bulletproof-security').'</font></strong>';
						echo $text;
								
					}	
		
				} else { // Use PclZip if ZipArchive class is not installed
		
					// NOTE: last modified date of files is not changed with PclZip
					define( 'PCLZIP_TEMPORARY_DIR', WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/' );
					require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php');
	
					if ( ini_get( 'mbstring.func_overload' ) && function_exists( 'mb_internal_encoding' ) ) {
						$previous_encoding = mb_internal_encoding();
						mb_internal_encoding( 'ISO-8859-1' );
					}	

					$archive = new PclZip( WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard/bps-pro-settings-export.zip' );
  		
					if ( $archive->extract( PCLZIP_OPT_PATH, WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard', PCLZIP_OPT_REMOVE_PATH, WP_PLUGIN_DIR . '/bulletproof-security/admin/wizard' ) ) {
					
						$text = '<strong><font color="green">'.__('Zip File Extraction Successful. Method: PclZip.', 'bulletproof-security').'</font></strong><br>';
						echo $text;
				
						// Update BPS Pro plugin option settings from the extracted setup-wizard-export.php file.
						if ( bpsPro_SW_DB_Update() == true ) {

							$text = '<strong><font color="green">'.__('BPS Pro plugin settings imported successfully.', 'bulletproof-security').'</font><br><br><font color="blue">'.__('IMPORTANT: Run the BPS Pro Pre-Installation Wizard and Setup Wizard now.', 'bulletproof-security').'</font><br><br>'.__('After running the Wizards go to the BPS Pro > B-Core > Custom Code tab page and check all of your custom htaccess code for any website specific custom htaccess code. Example: If you find any custom htaccess code that has a website URL for your other website that you exported BPS Pro plugin settings from, then either edit that custom htaccess code or remove it from BPS Custom Code.', 'bulletproof-security').'</strong>';
							echo $text;
						}

					} else {
					
						$text = '<strong><font color="#fb0101">'.__('ERROR: Zip File Extraction Failed. Method: PclZip.', 'bulletproof-security').'</font></strong>';
						echo $text;

					}
				} // end if ( class_exists('ZipArchive') ) {		
		
			} else { // end if ( move_uploaded_file($bps_tmp_file, $bps_uploaded_zip) ) {
		
				$text = '<strong><font color="#fb0101">'.__('ERROR: Zip File Upload Failed.', 'bulletproof-security').'</font><br><font color="black">'.__('Either the bps-pro-settings-export.zip file has not been selected yet for Import or the file ', 'bulletproof-security').$bpsZipzUploadFail.__(' is not a valid Setup Wizard Export file or file name. The BPS Pro Setup Wizard Import feature only allows the bps-pro-settings-export.zip file to be Uploaded/Imported. The filename MUST be named: bps-pro-settings-export.zip.', 'bulletproof-security').'</font></strong>';
				echo $text;
			}
		}
		}
		echo $bps_bottomDiv;
	}	
}

?>

	</td>
  </tr>
</table>

</div>

<div id="AITpro-link">BulletProof Security Pro <?php echo BULLETPROOF_VERSION; ?> Plugin by <a href="https://forum.ait-pro.com/" target="_blank" title="AITpro Website Security">AITpro Website Security</a>
</div>
</div>
<style>
<!--
.bps-spinner {visibility:hidden;}
-->
</style>
</div>