<?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. 
*/
?>

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

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

<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( $_POST['Submit-PFW-Whitelist'] ) && ! isset( $_POST['Submit-PFW-Allow-From'] ) ) { 

		bpsPro_Browser_UA_scroll_animation();
	}
}
?>

<?php
// S-Monitor HUD - Heads Up Display - Warnings, Error messages, AutoFix Setup & Whitelist - displayed in BPS Only		
bps_HUD_autofix_setup_bps_only();
bps_HUD_autofix_whitelist_bps_only();
bps_HUD_bps_only();

// S-Monitor BPS Security Status for Root and wp-admin (only if problem) - displayed in BPS Only
bps_security_status_bps_only();
bps_security_status_wpadmin_bps_only();

// S-Monitor - AutoRestore Status display - displayed in BPS Only 
bps_ARCM_admin_notice_status_bps();

// S-Monitor - MScan Status display - BPS pages ONLY
bps_MScan_admin_notice_status_bps();

// S-Monitor - DB Monitor Status display - BPS pages ONLY
bps_DBM_admin_notice_status_bps();

// S-Monitor - DB Backup Status display - BPS pages ONLY
bps_DBB_admin_notice_status_bps();

// S-Monitor - Plugin Firewall Status display - BPS pages ONLY
bps_PFWAP_admin_notice_status_bps();

// S-Monitor - Uploads Anti-Exploit Guard Status display - BPS pages ONLY
bps_UAEG_admin_notice_status_bps();

// S-Monitor - Login Security Status display - BPS pages ONLY
bps_Login_Security_admin_notice_status_bps();

// S-Monitor - JTC Anti-Spam Status display - BPS pages ONLY
bps_jtc_antispam_admin_notice_status_bps();

// S-Monitor - Idle Session Status display - BPS pages ONLY
bpsPro_isl_notice_status_bps();

// S-Monitor - Auth Cookie Expiration Status display - BPS pages ONLY
bpsPro_ace_notice_status_bps();

// S-Monitor - Login Security Alerts - BPS pages ONLY
bps_smonitor_LoginSecurityResetModTimeDiff_bps();

// S-Monitor - ARQ Alerts - BPS pages ONLY
bps_smonitor_ARQ_alerts_bps();

// S-Monitor PHP Error Log - New PHP Errors - displayed in BPS Only
bps_smonitor_ELogModTimeDiff_bps();

// S-Monitor Security Log - New Log Entry Has Been Logged - displayed in BPS Only
bps_smonitor_SecurityLogModTimeDiff_bps();

// S-Monitor - PHP Error Log Set & valid path, ini_set Options Checks & auto-update wp-config.php - BPS pages ONLY
bps_smonitor_phpini_bps();

// S-Monitor F-Lock - Check if F-Lock options saved - F-Lock Lock / Unlock File Status & actual file permissions 404 or 400
bps_smonitor_flock_bps();

// Apache IfModule htaccess file code check & creation: run on page load with 15 minute time restriction.
// System Info page: performs check in real-time without a 15 minute time restriction, but does not create htaccess files.
bpsPro_apache_mod_directive_check();
?>

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

<?php
// default.htaccess, secure.htaccess, write content for all WP site types
$bps_get_domain_root = bpsGetDomainRoot();
$bps_get_wp_root_default = bps_wp_get_root_folder();
// Replace ABSPATH = wp-content/plugins
$bps_plugin_dir = str_replace( ABSPATH, '', WP_PLUGIN_DIR );
// Replace ABSPATH = wp-content
$bps_wpcontent_dir = str_replace( ABSPATH, '', WP_CONTENT_DIR );
// Replace ABSPATH = wp-content/uploads
$wp_upload_dir = wp_upload_dir();
$bps_uploads_dir = str_replace( ABSPATH, '', $wp_upload_dir['basedir'] );
// Top div echo & bottom div echo
$bps_topDiv = '<div id="message" class="updated" style="background-color:#dfecf2;border:1px solid #999;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';
$bps_bottomDiv = '</p></div>';
// Nonce for Crypto-js
$bps_nonceValue = 'ghbhnyxu';
$bpsSpacePop = '-------------------------------------------------------------';

require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/core/core-help-text.php' );

// WBM, PFW, HPF, UAEG, MBM, BBM: activate and deactivate and all other form code
if ( isset( $_POST['Submit-WBM-Activate'] ) || isset( $_POST['Submit-WBM-Deactivate'] ) || isset( $_POST['Submit-PFW-Whitelist'] ) || isset( $_POST['Submit-PFW-AutoPilot'] ) || isset( $_POST['Submit-PFW-Allow-From'] ) || isset( $_POST['Submit-PFW-Roles'] ) || isset( $_POST['Submit-PFW-Activate'] ) || isset( $_POST['Submit-PFW-Deactivate'] ) || isset( $_POST['Submit-PFW-Test-Mode'] ) || isset( $_POST['Submit-UAEG-Activate'] ) || isset( $_POST['Submit-UAEG-Deactivate'] ) || isset( $_POST['Submit-UAEG-Reset'] ) || isset( $_POST['Submit-Hidden-Plugins'] ) || isset( $_POST['Hidden-Plugins-Ignore-Submit'] ) || isset( $_POST['Submit-MBM-Activate'] ) || isset( $_POST['Submit-MBM-Deactivate'] ) || isset( $_POST['Submit-BBM-Activate'] ) || isset( $_POST['Submit-BBM-Deactivate'] ) || isset( $_POST['Submit-Backup-htaccess-Files'] ) || isset( $_POST['Submit-Restore-htaccess-Files'] ) ) {
require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/core/core-forms.php' );	
}

// RBM: activate and deactivate form code
if ( isset( $_POST['Submit-RBM-Activate'] ) || isset( $_POST['Submit-RBM-Deactivate'] ) || isset( $_POST['Submit-RBM-Activate-Network'] ) || isset( $_POST['Submit-RBM-Deactivate-Network'] ) ) {
require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/core/core-htaccess-code.php' );
}

// 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>';
	}
}

// Anti-Piracy check - Fallback 10R
$D8 = '42756C6C657450726F6F66';
bpsPro_AP_Check($D8);

// Get Real IP address - USE EXTREME CAUTION!!!
function bpsPro_get_real_ip_address_cc() {
	
	if ( is_admin() && current_user_can('manage_options') ) {
	
		if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
			$ip = esc_html( $_SERVER['HTTP_CLIENT_IP'] );
			
			if ( ! is_array($ip) ) {
				
				if ( preg_match( '/(\d+\.){3}\d+/', $ip, $matches ) ) {

					return $matches[0];	
				
				} elseif ( preg_match( '/([:\d\w]+\.(\d+\.){2}\d+|[:\d\w]+)/', $ip, $matches ) ) {
				
					return $matches[0];	
		
				} else {
					
					return $ip;
				}
			
			} else {
				
				return current($ip);				
			}
		
		} elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
			$ip = esc_html( $_SERVER['HTTP_X_FORWARDED_FOR'] );
			
			if ( ! is_array($ip) ) {
				
				if ( preg_match( '/(\d+\.){3}\d+/', $ip, $matches ) ) {

					return $matches[0];	
				
				} elseif ( preg_match( '/([:\d\w]+\.(\d+\.){2}\d+|[:\d\w]+)/', $ip, $matches ) ) {
				
					return $matches[0];	
		
				} else {
					
					return $ip;
				}
			
			} else {
				
				return current($ip);				
			}
		
		} elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
			$ip = esc_html( $_SERVER['REMOTE_ADDR'] );
			return $ip;
		}
	}
}	

// Create a new Deny All .htaccess file on first page load with users current IP address to allow the cc-master.zip file to be downloaded
// Create a new Deny All .htaccess file if IP address is not current
function bpsPro_Core_CC_deny_all() {

	if ( is_admin() && wp_script_is( 'bps-accordion', $list = 'queue' ) && current_user_can('manage_options') ) {
		
		$HFiles_options = get_option('bulletproof_security_options_htaccess_files');
		$Apache_Mod_options = get_option('bulletproof_security_options_apache_modules');
		$Zip_download_Options = get_option('bulletproof_security_options_zip_fix');
		
		if ( isset( $HFiles_options['bps_htaccess_files'] ) && $HFiles_options['bps_htaccess_files'] == 'disabled' || isset( $Zip_download_Options['bps_zip_download_fix'] ) && $Zip_download_Options['bps_zip_download_fix'] == 'On' ) {
			return;
		}

		if ( $Apache_Mod_options['bps_apache_mod_ifmodule'] == 'Yes' ) {	
	
			$denyall_content = "# BPS mod_authz_core IfModule BC\n<IfModule mod_authz_core.c>\nRequire ip ". bpsPro_get_real_ip_address_cc()."\n</IfModule>\n\n<IfModule !mod_authz_core.c>\n<IfModule mod_access_compat.c>\n<FilesMatch \"(.*)\$\">\nOrder Allow,Deny\nAllow from ". bpsPro_get_real_ip_address_cc()."\n</FilesMatch>\n</IfModule>\n</IfModule>";
	
		} else {
		
			$denyall_content = "# BPS mod_access_compat\n<FilesMatch \"(.*)\$\">\nOrder Allow,Deny\nAllow from ". bpsPro_get_real_ip_address_cc()."\n</FilesMatch>";		
		}		
		
		$create_denyall_htaccess_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/core/.htaccess';
		
		if ( file_exists($create_denyall_htaccess_file) ) {
			$check_string = @file_get_contents($create_denyall_htaccess_file);
		}
		
		if ( ! file_exists($create_denyall_htaccess_file) ) { 

			$handle = fopen( $create_denyall_htaccess_file, 'w+b' );
    		fwrite( $handle, $denyall_content );
    		fclose( $handle );
		}			
		
		if ( file_exists($create_denyall_htaccess_file) && ! strpos( $check_string, bpsPro_get_real_ip_address_cc() ) ) { 
			$handle = fopen( $create_denyall_htaccess_file, 'w+b' );
    		fwrite( $handle, $denyall_content );
    		fclose( $handle );
		}
	}
}
bpsPro_Core_CC_deny_all();

?>
</div>

<!-- Begin inline CSS for WP Filesystem API Errors -->
<style type="text/css">
div.error {margin-left:220px;}
</style>
<!-- End inline CSS for WP Filesystem API Errors -->

<h2 class="bps-tab-title"><?php _e('B-Core ~ Htaccess Core Security', 'bulletproof-security'); ?></h2>

<!-- jQuery UI Tab Menu -->
<div id="bps-tabs" class="bps-menu">
    <div id="bpsHead"><img src="<?php echo plugins_url('/bulletproof-security/admin/images/bps-pro-logo.gif'); ?>" /></div>
		
 	<ul>
		<li><a href="#bps-tabs-1"><?php _e('Security Modes', 'bulletproof-security'); ?></a></li>
		<li><a href="#bps-tabs-6"><?php _e('htaccess File Editor', 'bulletproof-security'); ?></a></li>
		<li><a href="#bps-tabs-7"><?php _e('Custom Code', 'bulletproof-security'); ?></a></li>
		<li><a href="#bps-tabs-8"><?php _e('My Notes', 'bulletproof-security'); ?></a></li>
		<li><a href="#bps-tabs-9"><?php _e('Help & FAQ', 'bulletproof-security'); ?></a></li>
	</ul>
            
<div id="bps-tabs-1" 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('htaccess File Security Modes ~ ', 'bulletproof-security'); ?><span style="font-size:.75em;"><?php _e('RBM, WBM, PFW|AutoPilot Mode, HPF, MBM, BBM & UAEG BulletProof Modes', 'bulletproof-security'); ?></span></h2></td>
  </tr>
  <tr>
    <td class="bps-table_cell_help" style="">

<?php if ( ! current_user_can('manage_options') ) { _e('Permission Denied', 'bulletproof-security'); } else { ?>

    <h2 style="border-bottom:1px solid #999999;"><?php _e('Activate|Deactivate Security Modes', 'bulletproof-security'); ?></h2>
    
    <h3><?php _e('Root Folder BulletProof Mode (RBM)', '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('Root Folder BulletProof Mode (RBM)', '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; 
		$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/read-me-first-pro/#bps-pro-general-troubleshooting" title="BPS Pro Troubleshooting Steps" target="_blank"><?php _e('BPS Pro Troubleshooting Steps', 'bulletproof-security'); ?></a></strong><br /><br />

	<?php echo $bps_general_help_info; echo $bps_rbm_content; ?>
    </p>
</div> 

<?php
// RBM Status: real-time status check
// 4 possible RBM Status indicators: Activated, Deactivated, Disabled or Root htaccess File Does Not Exist
function bpsPro_rbm_status() {
global $bpspro_version;
	
	$HFiles_options = get_option('bulletproof_security_options_htaccess_files');	
	$filename = ABSPATH . '.htaccess';
	
	if ( file_exists($filename) ) {
		$check_string = @file_get_contents($filename);
	}
	
	if ( isset ( $_POST['Submit-RBM-Activate'] ) ) {
		$_POST['Submit-RBM-Activate'] = true;
	} else {
		$_POST['Submit-RBM-Activate'] = null;
	}
	
	if ( isset ( $_POST['Submit-RBM-Deactivate'] ) )  {
		$_POST['Submit-RBM-Deactivate'] = true;
	} else {
		$_POST['Submit-RBM-Deactivate'] = null;
	}

	if ( $_POST['Submit-RBM-Activate'] != true && $_POST['Submit-RBM-Deactivate'] != true ) {
	
		if ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<h3><strong>'.__('RBM Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Disabled', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<h3><strong>'.__('RBM Status: ', 'bulletproof-security').'<span class="core-status-error">'.__('Root htaccess File Does Not Exist', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		} elseif ( strpos( $check_string, "BULLETPROOF PRO $bpspro_version SECURE .HTACCESS" ) && strpos( $check_string, "BPSQSE" ) ) {
			$text = '<h3><strong>'.__('RBM Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( strpos( $check_string, "BULLETPROOF PRO DEFAULT .HTACCESS" ) ) {
			$text = '<h3><strong>'.__('RBM Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('Deactivated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;			
		}
	}

	if ( $_POST['Submit-RBM-Activate'] == true || $_POST['Submit-RBM-Deactivate'] == true ) {
		
		if ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<h3><strong>'.__('RBM Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Disabled', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<h3><strong>'.__('RBM Status: ', 'bulletproof-security').'<span class="core-status-error">'.__('Root htaccess File Does Not Exist', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		} elseif ( strpos( $check_string, "BULLETPROOF PRO $bpspro_version SECURE .HTACCESS" ) && strpos( $check_string, "BPSQSE" ) ) {
			$text = '<h3><strong>'.__('RBM Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( strpos( $check_string, "BULLETPROOF PRO DEFAULT .HTACCESS" ) ) {
			$text = '<h3><strong>'.__('RBM Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('Deactivated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;			
		}
	}
}
?>

<div id="RBM-Status"><?php bpsPro_rbm_status(); ?></div>

<div id="root-bulletproof-mode" style="padding-left:10px;border-bottom:1px solid #999999;">

<?php if ( ! is_multisite() ) { ?>

<form name="RBM-Activate" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_rbm_activate'); ?>

	<div id="RBM-buttons" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-RBM-Activate" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Activate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Activate Root Folder BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

<form name="RBM-Deactivate" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_rbm_deactivate'); ?>

	<div id="RBM-buttons" style="">
    <input type="submit" name="Submit-RBM-Deactivate" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Deactivate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Deactivate Root Folder BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

<?php } else { ?>

<form name="RBM-Activate-Network" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_rbm_activate_network'); ?>

	<div id="RBM-buttons" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-RBM-Activate-Network" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Activate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Activate Root Folder BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

<form name="RBM-Deactivate-Network" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_rbm_deactivate_network'); ?>

	<div id="RBM-buttons" style="">
    <input type="submit" name="Submit-RBM-Deactivate-Network" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Deactivate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Deactivate Root Folder BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

<?php } ?>

</div>

<h3><?php _e('wp-admin Folder BulletProof Mode (WBM)', '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('Root Folder BulletProof Mode (RBM)', '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; 
		$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/read-me-first-pro/#bps-pro-general-troubleshooting" title="BPS Pro Troubleshooting Steps" target="_blank"><?php _e('BPS Pro Troubleshooting Steps', 'bulletproof-security'); ?></a></strong><br /><br />

	<?php echo $bps_general_help_info; echo $bps_wbm_content; ?>
    </p>
</div> 

<div id="PFWScan-Menu-Link"></div>

<?php
// WBM Status: real-time status check
// 3 possible WBM Status indicators: Activated, Deactivated or Disabled.
function bpsPro_wbm_status() {
global $bpspro_version;
	
	$BPS_wpadmin_Options = get_option('bulletproof_security_options_htaccess_res');
	$GDMW_options = get_option('bulletproof_security_options_GDMW');	
	$HFiles_options = get_option('bulletproof_security_options_htaccess_files');	
	
	$filename = ABSPATH . 'wp-admin/.htaccess';
	
	if ( file_exists($filename) ) {
		$check_string = @file_get_contents($filename);
	}
	
	if ( isset ( $_POST['Submit-WBM-Activate'] ) ) {
		$_POST['Submit-WBM-Activate'] = true;
	} else {
		$_POST['Submit-WBM-Activate'] = null;
	}
	
	if ( isset ( $_POST['Submit-WBM-Deactivate'] ) )  {
		$_POST['Submit-WBM-Deactivate'] = true;
	} else {
		$_POST['Submit-WBM-Deactivate'] = null;
	}

	if ( $_POST['Submit-WBM-Activate'] != true && $_POST['Submit-WBM-Deactivate'] != true ) {
	
		if ( ! file_exists($filename) && isset( $HFiles_options['bps_htaccess_files'] ) && $HFiles_options['bps_htaccess_files'] == 'disabled' || isset( $BPS_wpadmin_Options['bps_wpadmin_restriction'] ) && $BPS_wpadmin_Options['bps_wpadmin_restriction'] == 'disabled' || isset( $GDMW_options['bps_gdmw_hosting'] ) && $GDMW_options['bps_gdmw_hosting'] == 'yes' ) {
			$text = '<h3><strong>'.__('WBM Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Disabled', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( ! file_exists($filename) ) {	
			$text = '<h3><strong>'.__('WBM Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('Deactivated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		} elseif ( strpos( $check_string, "BULLETPROOF PRO $bpspro_version WP-ADMIN SECURE .HTACCESS" ) && strpos( $check_string, "BPSQSE-check" ) ) {
			$text = '<h3><strong>'.__('WBM Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		}
	}

	if ( $_POST['Submit-WBM-Activate'] == true || $_POST['Submit-WBM-Deactivate'] == true ) {
		
		if ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] == 'disabled' || $BPS_wpadmin_Options['bps_wpadmin_restriction'] == 'disabled' || $GDMW_options['bps_gdmw_hosting'] == 'yes' ) {
			$text = '<h3><strong>'.__('WBM Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Disabled', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( ! file_exists($filename) ) {	
			$text = '<h3><strong>'.__('WBM Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('Deactivated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		} elseif ( strpos( $check_string, "BULLETPROOF PRO $bpspro_version WP-ADMIN SECURE .HTACCESS" ) && strpos( $check_string, "BPSQSE-check" ) ) {
			$text = '<h3><strong>'.__('WBM Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		}
	}
}
?>

<div id="WBM-Status"><?php bpsPro_wbm_status(); ?></div>

<div id="wpadmin-bulletproof-mode" style="padding-left:10px;border-bottom:1px solid #999999;">

<form name="WBM-Activate" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_wbm_activate'); ?>

	<div id="WBM-buttons" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-WBM-Activate" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Activate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Activate wp-admin Folder BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

<form name="WBM-Deactivate" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_wbm_deactivate'); ?>

	<div id="WBM-buttons" style="">
    <input type="submit" name="Submit-WBM-Deactivate" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Deactivate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Deactivate wp-admin Folder BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

</div>

    <h3><?php _e('Plugin Firewall BulletProof Mode (PFW)', '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('Plugin Firewall BulletProof Mode (PFW)', '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 & Video Tutorials: ', 'bulletproof-security').'</font></strong><br>'; 	
		echo $text;	
	?>
	<strong><a href="https://forum.ait-pro.com/video-tutorials/#setup-wizard" title="Setup Wizard Video Tutorial" target="_blank"><?php _e('Setup Wizard Video Tutorial', 'bulletproof-security'); ?></a></strong><br />
	<strong><a href="https://forum.ait-pro.com/video-tutorials/#security-log-firewall" title="Security Log Video Tutorial" target="_blank"><?php _e('Security Log Video Tutorial', 'bulletproof-security'); ?></a></strong><br />
	<strong><a href="https://forum.ait-pro.com/forums/topic/security-log-http-error-log-read-me-first/" title="Security Log Forum Link" target="_blank"><?php _e('Security Log Forum Link', 'bulletproof-security'); ?></a></strong><br />
    <strong><a href="https://forum.ait-pro.com/forums/topic/plugin-firewall-read-me-first-troubleshooting/" title="Plugin Firewall Forum Link" target="_blank"><?php _e('Plugin Firewall Forum Link', 'bulletproof-security'); ?></a></strong><br />
    <strong><a href="https://forum.ait-pro.com/forums/topic/read-me-first-pro/#bps-pro-general-troubleshooting" title="BPS Pro Troubleshooting Steps" target="_blank"><?php _e('BPS Pro Troubleshooting Steps', 'bulletproof-security'); ?></a></strong><br /><br />	    

	<?php echo $bps_pfw_content; ?>
    
    </p>
</div>

<?php
// PFW Status: real-time status check
// 4 possible PFW Status indicators: Activated|AutoPilot On, Activated|AutoPilot Off, Deactivated or Disabled.
function bpsPro_pfw_status() {
global $bpspro_version;
	
	$HFiles_options = get_option('bulletproof_security_options_htaccess_files');
	$PFWAP_options = get_option('bulletproof_security_options_pfw_autopilot');	
	$filename = WP_PLUGIN_DIR . '/.htaccess';
	
	if ( isset ( $_POST['Submit-PFW-Activate'] ) ) {
		$_POST['Submit-PFW-Activate'] = true;
	} else {
		$_POST['Submit-PFW-Activate'] = null;
	}
	
	if ( isset ( $_POST['Submit-PFW-Deactivate'] ) )  {
		$_POST['Submit-PFW-Deactivate'] = true;
	} else {
		$_POST['Submit-PFW-Deactivate'] = null;
	}

	if ( $_POST['Submit-PFW-Activate'] != true && $_POST['Submit-PFW-Deactivate'] != true ) {
	
		if ( ! file_exists($filename) && isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<h3><strong>'.__('PFW Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Disabled', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( ! file_exists($filename) && isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {
			$text = '<h3><strong>'.__('PFW Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('Deactivated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		} elseif ( file_exists($filename) && $PFWAP_options['bps_pfw_autopilot_cron'] == 'On' ) {
			$text = '<h3><strong>'.__('PFW Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated|AutoPilot On', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( file_exists($filename) && $PFWAP_options['bps_pfw_autopilot_cron'] == 'Off' ) {
			$text = '<h3><strong>'.__('PFW Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated|AutoPilot Off', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		}
	}

	if ( $_POST['Submit-PFW-Activate'] == true || $_POST['Submit-PFW-Deactivate'] == true ) {
		
		if ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<h3><strong>'.__('PFW Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Disabled', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {
			$text = '<h3><strong>'.__('PFW Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('Deactivated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		} elseif ( file_exists($filename) && $PFWAP_options['bps_pfw_autopilot_cron'] == 'On' ) {
			$text = '<h3><strong>'.__('PFW Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated|AutoPilot On', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( file_exists($filename) && $PFWAP_options['bps_pfw_autopilot_cron'] == 'Off' ) {
			$text = '<h3><strong>'.__('PFW Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated|AutoPilot Off', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		}
	}
}
?>

<div id="PFW-Status"><?php bpsPro_pfw_status(); ?></div>

<?php bpsPFWWhitelistRulesCheck(); ?>

<div id="PFW-Messages" style="">

<?php 
$scrolltoPFW = isset($_REQUEST['scrolltoPFW']) ? (int) $_REQUEST['scrolltoPFW'] : 0; 
$scrolltoAllowFrom = isset($_REQUEST['scrolltoAllowFrom']) ? (int) $_REQUEST['scrolltoAllowFrom'] : 0;

	echo '<div id="pfw-inpage-messages" style="">';

	if ( isset ( $_POST['Submit-PFW-Whitelist'] ) ) {
		$_POST['Submit-PFW-Whitelist'] = true;
	} else {
		$_POST['Submit-PFW-Whitelist'] = null;
	}
	
	if ( isset ( $_POST['Submit-PFW-Allow-From'] ) )  {
		$_POST['Submit-PFW-Allow-From'] = true;
	} else {
		$_POST['Submit-PFW-Allow-From'] = null;
	}

	if ( $_POST['Submit-PFW-Whitelist'] == true )  { 
		$PluginsHtaccessMaster = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/plugins.htaccess';
		$pluginsHtaccessMasterTXT = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/plugins-htaccess-master.txt';	

		if ( ! is_writable($pluginsHtaccessMasterTXT) || ! is_writable($PluginsHtaccessMaster) ) {
			echo '<div id="pfw-inpage-messages" style="border:2px solid black;padding:5px;margin-bottom:5px;max-width:100%;background-color:#dfecf2;-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);">';
			$text = '<strong><font color="#fb0101" style="font-size:12px;">'.__('Error: Failed to Create the Plugin Firewall Master File.', 'bulletproof-security').'</font><br>'.__('Check the file and folder permissions for these files.', 'bulletproof-security').'</strong><br>'.$pluginsHtaccessMasterTXT.'<br>'.$PluginsHtaccessMaster; 
			echo $text; 
			echo '</div>';
		
		} else { 

			echo '<div id="pfw-inpage-messages" style="border:2px solid black;padding:5px;margin-bottom:5px;max-width:100%;background-color:#dfecf2;-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);">';
			$text = '<font color="blue" style="font-size:12px;"><strong>'.__('Reminder: After clicking Save Whitelist Options button, click the Activate button.', 'bulletproof-security').'</strong></font>';
			echo $text;
			echo '</div>';
		}
	}

	if ( $_POST['Submit-PFW-Allow-From'] == true )  { 
			echo '<div id="pfw-inpage-messages" style="border:2px solid black;padding:5px;margin-bottom:5px;max-width:100%;background-color:#dfecf2;-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);">';
			$text = '<font color="blue" style="font-size:12px;"><strong>'.__('Reminder: After clicking the Save Hostname and IP Address Rules button, click the Activate button', 'bulletproof-security').'</strong></font>';
			echo $text;
			echo '</div>';	
	}

	echo '</div>';

?> 
</div>

<div id="bps-accordion-1" class="bps-accordion-main-3" style="">

<h3><?php _e('Plugin Firewall Whitelist Tools', 'bulletproof-security'); ?></h3>
<div id="mmode-accordion-inner">

<?php echo '<div style="color:#2ea2cc;margin:-15px 0px 10px 0px;font-weight:bold;">'.__('Click the Read Me help button for help information about the Plugin Firewall Whitelist Tools', 'bulletproof-security').'</div>'; ?>

<div id="PFWWhitelistForm" style="position:relative;top:0px;left:0px;float:left;margin:0px 15px 40px 0px;">

<form name="PFW-Whitelist-Form" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#PFWScan-Menu-Link' ); ?>" method="post">
    <?php wp_nonce_field('bulletproof_security_pfw_whitelist'); ?>
	<?php $PFW_whitelist_options = get_option('bulletproof_security_options_pfirewall'); 
		$bps_pfw_whitelist = ! isset($PFW_whitelist_options['bps_pfw_whitelist']) ? '' : trim( $PFW_whitelist_options['bps_pfw_whitelist'], ", \t\n\r");
	?>
    
	<div id="PFW2" style="position:relative;top:0px;left:0px;float:left;margin:0px 15px 0px 0px;">
    <strong><label><?php _e('Plugins Script|File Whitelist Text Area', 'bulletproof-security'); ?></label></strong><br />
    <textarea class="PFW-Whitelist-Text-Area" name="bps_pfw_whitelist" tabindex="1"><?php echo $bps_pfw_whitelist; ?></textarea>
	<input type="hidden" name="scrolltoPFW" id="scrolltoPFW" value="<?php echo esc_html( $scrolltoPFW ); ?>" />
	<input type="hidden" name="PFWSWD" value="PFWSWD" />
	</div>
	
    <div id="PFW3" style="padding:0px 10px 0px 10px;">
    <label><strong><?php _e('Payment Providers', 'bulletproof-security'); ?></strong></label><br />
    <input type="checkbox" name="bps_pfw_paypal" style="margin-top:5px;" value="1" <?php if ( empty( $PFW_whitelist_options['bps_pfw_paypal'] ) ) { echo ''; } else { checked( $PFW_whitelist_options['bps_pfw_paypal'], 1 ); } ?> /><label><?php _e(' PayPal', 'bulletproof-security'); ?></label><br /><br />
	<input type="checkbox" name="bps_pfw_google" value="1" <?php if ( empty( $PFW_whitelist_options['bps_pfw_google'] ) ) { echo ''; } else { checked( $PFW_whitelist_options['bps_pfw_google'], 1 ); } ?> /><label><?php _e(' Google Checkout', 'bulletproof-security'); ?></label><br /><br />    
	<input type="checkbox" name="bps_pfw_amazon" value="1" <?php if ( empty( $PFW_whitelist_options['bps_pfw_amazon'] ) ) { echo ''; } else { checked( $PFW_whitelist_options['bps_pfw_amazon'], 1 ); } ?> /><label><?php _e(' Amazon Checkout', 'bulletproof-security'); ?></label><br /><br />  
	<input type="checkbox" name="bps_pfw_authorizenet" value="1" <?php  if ( empty( $PFW_whitelist_options['bps_pfw_authorizenet'] ) ) { echo ''; } else { checked( $PFW_whitelist_options['bps_pfw_authorizenet'], 1 ); } ?> /><label><?php _e(' Authorize.net', 'bulletproof-security'); ?></label><br />  
	</div>
    
    <div id="PFW7" style="position:absolute;bottom:-50px;left:0px;margin:10px 0px 10px 0px;">
	<input type="submit" name="Submit-PFW-Whitelist" class="button bps-button" value="<?php esc_attr_e('Save Whitelist Options', 'bulletproof-security') ?>" onclick="return confirm('<?php $text = __('Reminder: After clicking Save Whitelist Options button, click the Activate button to activate the Plugin Firewall with your new settings/rules/options.', 'bulletproof-security').'\n\n'.__('Click OK to proceed or click Cancel.', 'bulletproof-security'); echo $text; ?>')"/>
	</div>
</form>

</div>
<br /><br />

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
	$('#PFW-Form').submit(function(){ $('#scrolltoPFW').val( $('#bps_pfw_whitelist').scrollTop() ); });
	$('#bps_pfw_whitelist').scrollTop( $('#scrolltoPFW').val() );
});
/* ]]> */
</script> 

</div>
  
  <h3><?php _e('Plugin Firewall AutoPilot Mode', 'bulletproof-security'); ?></h3>
  <div id="mmode-accordion-inner">

<?php echo '<div style="color:#2ea2cc;margin:-15px 0px 10px 0px;font-weight:bold;">'.__('Click the Read Me help button for help information about Plugin Firewall AutoPilot Mode', 'bulletproof-security').'</div>'; ?>

<div id="PFW13" style="position:relative;top:10px;left:0px;float:left;margin:0px 0px 0px 0px;">
    
<?php
	// Form: Plugin Firewall AutoPilot Form
	echo '<form name="bpsPFWAutoPilot" action="'.admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ).'" method="post">';
	wp_nonce_field('bulletproof_security_pfw_autopilot');

	$AutoPilot_options = get_option('bulletproof_security_options_pfw_autopilot');
	$bps_pfw_autopilot_cron_frequency = ! isset($AutoPilot_options['bps_pfw_autopilot_cron_frequency']) ? '' : $AutoPilot_options['bps_pfw_autopilot_cron_frequency'];
	$bps_pfw_autopilot_cron = ! isset($AutoPilot_options['bps_pfw_autopilot_cron']) ? '' : $AutoPilot_options['bps_pfw_autopilot_cron'];
	
	echo '<label for="bps-autopilot">'.__('AutoPilot Mode Cron Check Frequency:', 'bulletproof-security').'</label><br>';
	echo '<select name="autopilot_cron_frequency" class="form-340">';
	echo '<option value="1"'. selected('1', $bps_pfw_autopilot_cron_frequency).'>'.__('Run AutoPilot Cron Check Every 1 Minute', 'bulletproof-security').'</option>';
	echo '<option value="5"'. selected('5', $bps_pfw_autopilot_cron_frequency).'>'.__('Run AutoPilot Cron Check Every 5 Minutes', 'bulletproof-security').'</option>';
	echo '<option value="10"'. selected('10', $bps_pfw_autopilot_cron_frequency).'>'.__('Run AutoPilot Cron Check Every 10 Minutes', 'bulletproof-security').'</option>';
	echo '<option value="15"'. selected('15', $bps_pfw_autopilot_cron_frequency).'>'.__('Run AutoPilot Cron Check Every 15 Minutes', 'bulletproof-security').'</option>';
	echo '<option value="30"'. selected('30', $bps_pfw_autopilot_cron_frequency).'>'.__('Run AutoPilot Cron Check Every 30 Minutes', 'bulletproof-security').'</option>';
	echo '<option value="60"'. selected('60', $bps_pfw_autopilot_cron_frequency).'>'.__('Run AutoPilot Cron Check Every 60 Minutes', 'bulletproof-security').'</option>';
	echo '</select><br><br>';

	echo '<label for="bps-autopilot">'.__('Turn On|Off AutoPilot Mode:', 'bulletproof-security').'</label><br>';
	echo '<select name="autopilot_on_off" class="form-340">';
	echo '<option value="On"'. selected('On', $bps_pfw_autopilot_cron).'>'.__('AutoPilot Mode On', 'bulletproof-security').'</option>';
	echo '<option value="Off"'. selected('Off', $bps_pfw_autopilot_cron).'>'.__('AutoPilot Mode Off', 'bulletproof-security').'</option>';
	echo '</select>';
	
	echo "<p><input type=\"submit\" name=\"Submit-PFW-AutoPilot\" value=\"".__('Save AutoPilot Options', 'bulletproof-security')."\" class=\"button bps-button\" onclick=\"return confirm('".__('Plugin Firewall AutoPilot Mode will automatically detect and create Plugin Firewall whitelist rules in real-time when AutoPilot Mode is turned On\n\n-------------------------------------------------------------\n\nThe BPS Pro Dashboard Status Display will display: PFW: AutoPilot : 00 Min : 00:00 AM when AutoPilot Mode is turned On\n\n-------------------------------------------------------------\n\nClick OK to proceed or click Cancel', 'bulletproof-security')."')\" /></p></form>";

?>

</div>

</div>

  <h3><?php _e('Plugin Firewall Additional Whitelist Tools', 'bulletproof-security'); ?></h3>
  <div id="mmode-accordion-inner">

<?php echo '<div style="color:#2ea2cc;margin:-15px 0px 10px 0px;font-weight:bold;">'.__('Click the Read Me help button for help information about the Plugin Firewall Additional Whitelist Tools', 'bulletproof-security').'</div>'; ?>

<div id="PFWCustomScan" style="position:relative;top:0px;left:0px;float:left;margin:0px 15px 0px 0px;">

<form name="PFW-Allow-From-Form" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#PFWScan-Menu-Link' ); ?>" method="post">
	<?php wp_nonce_field('bulletproof_security_pfw_allow_from'); ?>
	<?php $PFW_allow_from_options = get_option('bulletproof_security_options_pfirewall_allow'); 
		$bps_pfw_allow_from = ! isset($PFW_allow_from_options['bps_pfw_allow_from']) ? '' : trim( $PFW_allow_from_options['bps_pfw_allow_from'], ", \t\n\r");
	?>

	<div id="PFW8" style="position:relative;top:0px;left:0px;float:left;margin:0px 0px 0px 0px;">
	<strong><label><?php _e('Whitelist by Hostname (domain name) and IP Address:', 'bulletproof-security'); ?></label></strong><br />
    <?php $text = '<div style="allow-from-small-text">'.__('Use a comma and a space between Hostnames and IP Addresses.', 'bulletproof-security').'<br><strong>'.__('Example: example.com, 100.99.88.77, example-2.com', 'bulletproof-security').'</strong><br>'.__('If you want to use backslashes, escape a backslash with another backslash.', 'bulletproof-security').'<br><strong>'.__('Example: example\\\\.com, 100\\\\.99\\\\.88\\\\.77, example-2\\\\.com', 'bulletproof-security').'</strong></div>'; echo $text; ?>
    <textarea class="PFW-Allow-From-Text-Area" name="bps_pfw_allow_from" style="margin-top:5px;" tabindex="1"><?php echo $bps_pfw_allow_from; ?></textarea>
	<input type="hidden" name="scrolltoAllowFrom" id="scrolltoAllowFrom" value="<?php echo esc_html( $scrolltoAllowFrom ); ?>" />

	<div id="PFW7" style="position:relative;top:0px;left:0px;margin:10px 0px 10px 0px;border-bottom:1px solid #999999;">
	<input type="submit" name="Submit-PFW-Allow-From" class="button bps-button" style="margin-bottom:20px;" value="<?php esc_attr_e('Save Hostname and IP Address Rules', 'bulletproof-security') ?>" onclick="return confirm('<?php $text = __('Note: This option is for adding additional whitelist rules to whitelist additional Hostnames (domain names) or IP addresses in your Plugin Firewall .htaccess file.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('After clicking the Save Hostname and IP Address Rules button, click the Activate button to activate the Plugin Firewall.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to proceed or click Cancel.', 'bulletproof-security'); echo $text; ?>')"/>
	</div>
	</div>
</form>

</div>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
	$('#PFW-Allow-From-Form').submit(function(){ $('#scrolltoAllowFrom').val( $('#bps_pfw_allow_from').scrollTop() ); });
	$('#bps_pfw_allow_from').scrollTop( $('#scrolltoAllowFrom').val() );
});
/* ]]> */
</script>

<div id="PFW12" style="position:relative;top:2px;left:0px;float:left;margin:0px 15px 10px 0px;">

<form name="PFW-Roles-Form" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
	<?php wp_nonce_field('bulletproof_security_pfw_roles'); ?>
	<?php $PFW_Roles_options = get_option('bulletproof_security_options_pfirewall_roles'); ?>
    
    <label><strong><?php _e('Additional Roles IP Whitelist', 'bulletproof-security'); ?></strong></label><br />
    <div id="Roles-scroller" style="height:100px;width:250px;overflow:auto;margin:0px;padding-top:1px">
    <input type="checkbox" name="bps_pfw_administrator" value="1" <?php if ( empty( $PFW_Roles_options['bps_pfw_administrator'] ) ) { echo ''; } else { checked( $PFW_Roles_options['bps_pfw_administrator'], 1 ); } ?> /><label style="margin-bottom:5px"><?php _e(' Administrator', 'bulletproof-security'); ?></label><br />
    <input type="checkbox" name="bps_pfw_editor" value="1" <?php if ( empty( $PFW_Roles_options['bps_pfw_editor'] ) ) { echo ''; } else { checked( $PFW_Roles_options['bps_pfw_editor'], 1 ); } ?> /><label><?php _e(' Editor', 'bulletproof-security'); ?></label><br />
	<input type="checkbox" name="bps_pfw_author" value="1" <?php if ( empty( $PFW_Roles_options['bps_pfw_author'] ) ) { echo ''; } else { checked( $PFW_Roles_options['bps_pfw_author'], 1 ); } ?> /><label><?php _e(' Author', 'bulletproof-security'); ?></label><br />
	<input type="checkbox" name="bps_pfw_contributor" value="1" <?php if ( empty( $PFW_Roles_options['bps_pfw_contributor'] ) ) { echo ''; } else { checked( $PFW_Roles_options['bps_pfw_contributor'], 1 ); } ?> /><label><?php _e(' Contributor', 'bulletproof-security'); ?></label><br />
    
	<input type="hidden" name="bps_pfw_roles_hidden" value="14" />

<?php

	foreach ( get_editable_roles() as $role_name => $role_info ) {
	
		if ( $role_name != 'administrator' && $role_name != 'editor' && $role_name != 'author' && $role_name != 'contributor' && $role_name != 'subscriber' ) {
			
			echo "<input type=\"checkbox\" name=\"bps_pfw_custom_roles[$role_name]\" value=\"1\""; 
			if ( ! empty($PFW_Roles_options['bps_pfw_custom_roles'][$role_name]) ) {			
				checked( $PFW_Roles_options['bps_pfw_custom_roles'][$role_name], 1 ); 
			}
			echo " /><label> ". $role_info['name'] ."</label>".'<br>';
		}
	}
?>
</div><br />
	
	<div id="PFW7" style="position:relative;top:0px;left:0px;margin:60px 0px 10px 0px;border-bottom:1px solid #999999;">  
    <input type="submit" name="Submit-PFW-Roles" class="button bps-button" style="margin-bottom:20px;" value="<?php esc_attr_e('Save Additional Roles Options', 'bulletproof-security') ?>" onclick="return confirm('<?php $text = __('Note: This option is for folks who have additional Administrators, Editors, Authors and Contributors who log into the website to create Posts or perform other website tasks.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Clicking the Save Additional Roles Options button will enable automatic Plugin Firewall IP Address Whitelisting for the Additional Roles that you have selected.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('When a person with the Role capabilities that you have selected logs into the website their IP address will be automatically added to the Plugin Firewall Whitelist.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Save your Additional Roles Options or click Cancel.', 'bulletproof-security'); echo $text; ?>')"/>
	</div>
</form>
</div>
</div>
</div>

<div id="UAEG-Menu-Link"></div>

<div id="pfw-bulletproof-mode" style="padding-left:10px;border-bottom:1px solid #999999;">

<form name="PFW-Activate" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_pfw_activate'); ?>

	<div id="PFW-buttons" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-PFW-Activate" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Activate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Note: Plugin Firewall Test Mode is turned Off when you Activate Plugin Firewall BulletProof Mode.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Activate Plugin Firewall BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

<form name="PFW-Deactivate" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_pfw_deactivate'); ?>

	<div id="PFW-buttons" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-PFW-Deactivate" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Deactivate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Note: Plugin Firewall Test Mode is turned Off when you Deactivate Plugin Firewall BulletProof Mode.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Deactivate Plugin Firewall BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

<form name="PFW-Test-Mode" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_pfw_test_mode'); ?>

	<div id="PFW-buttons" style="">
    <input type="submit" name="Submit-PFW-Test-Mode" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Test Mode', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Note: Click the Plugin Firewall BulletProof Mode (PFW) Read Me help button for help information about how to use Test Mode.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to turn On Plugin Firewall Test Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

</div>    
    
<h3><?php _e('Uploads Anti-Exploit Guard BulletProof Mode (UAEG)', 'bulletproof-security'); ?>  <button id="bps-open-modal4" class="button bps-modal-button"><?php _e('Read Me', 'bulletproof-security'); ?></button></h3>

<div id="bps-modal-content4" class="bps-dialog-hide" title="<?php _e('UAEG BulletProof Mode', '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; 
		$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/uploads-anti-exploit-guard-uaeg-read-me-first/" title="UAEG Forum Help Link" target="_blank"><?php _e('UAEG Forum Help Link', 'bulletproof-security'); ?></a></strong><br />
	<strong><a href="https://forum.ait-pro.com/forums/topic/read-me-first-pro/#bps-pro-general-troubleshooting" title="BPS Pro Troubleshooting Steps" target="_blank"><?php _e('BPS Pro Troubleshooting Steps', 'bulletproof-security'); ?></a></strong><br /><br />	
	
	<?php echo $bps_general_help_info; echo $bps_uaeg_content; ?>
    
    </p>
</div>

<?php
// UAEG Status: real-time status check
// 4 possible UAEG Status indicators: Activated, Deactivated, Disabled or Non-BPS UAEG htaccess File Detected.
function bpsPro_uaeg_status() {
	
	$bps_Uploads_Dir = wp_upload_dir();
	$filename = $bps_Uploads_Dir['basedir'] . '/.htaccess';
	$HFiles_options = get_option('bulletproof_security_options_htaccess_files');	
	
	if ( file_exists($filename) ) {
		$check_string = @file_get_contents($filename);
	}

	if ( isset ( $_POST['Submit-UAEG-Activate'] ) ) {
		$_POST['Submit-UAEG-Activate'] = true;
	} else {
		$_POST['Submit-UAEG-Activate'] = null;
	}
	
	if ( isset ( $_POST['Submit-UAEG-Deactivate'] ) )  {
		$_POST['Submit-UAEG-Deactivate'] = true;
	} else {
		$_POST['Submit-UAEG-Deactivate'] = null;
	}

	if ( $_POST['Submit-UAEG-Activate'] != true && $_POST['Submit-UAEG-Deactivate'] != true ) {
	
		if ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<h3><strong>'.__('UAEG Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Disabled', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<h3><strong>'.__('UAEG Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('Deactivated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		} elseif ( ! strpos( $check_string, "BULLETPROOF PRO UPLOADS FOLDER .HTACCESS" ) ) {
			$text = '<h3><strong>'.__('UAEG Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Non-BPS UAEG htaccess File Detected', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( strpos( $check_string, "BULLETPROOF PRO UPLOADS FOLDER .HTACCESS" ) ) {
			$text = '<h3><strong>'.__('UAEG Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		}
	}

	if ( $_POST['Submit-UAEG-Activate'] == true || $_POST['Submit-UAEG-Deactivate'] == true ) {
		
		if ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<h3><strong>'.__('UAEG Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Disabled', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<h3><strong>'.__('UAEG Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('Deactivated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		} elseif ( ! strpos( $check_string, "BULLETPROOF PRO UPLOADS FOLDER .HTACCESS" ) ) {
			$text = '<h3><strong>'.__('UAEG Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Non-BPS UAEG htaccess File Detected', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( strpos( $check_string, "BULLETPROOF PRO UPLOADS FOLDER .HTACCESS" ) ) {
			$text = '<h3><strong>'.__('UAEG Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		}
	}
}
?>

<div id="UAEG-Status"><?php bpsPro_uaeg_status(); ?></div>

<div id="uaeg-bulletproof-mode" style="padding-left:10px;border-bottom:1px solid #999999;">

<form name="UAEG-Activate" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_uaeg_activate'); ?>

	<div id="UAEG-buttons" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-UAEG-Activate" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Activate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Activate UAEG BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

<form name="UAEG-Deactivate" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_uaeg_deactivate'); ?>

	<div id="UAEG-buttons" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-UAEG-Deactivate" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Deactivate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Deactivate UAEG BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

    <div id="uaeg-buttons" style="">
<form name="bps-uaeg-reset" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
	<?php wp_nonce_field('bulletproof_security_uaeg_reset'); ?>
	<input type="submit" name="Submit-UAEG-Reset" style="margin:10px 0px 10px 0px;" value="<?php esc_attr_e('Reset UAEG htaccess File', 'bulletproof-security'); ?>" class="button bps-button" onclick="return confirm('<?php 
$text = __('Reminder: Clicking OK will reset the UAEG htaccess file back to the original default BPS Pro UAEG code/file.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Note: If you have customized your current UAEG htaccess file or added additional whitelist rules in your UAEG htaccess file then save a backup of your UAEG code/file before clicking the Reset button.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Reset the UAEG htaccess file or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
</form>

</div>
</div>

<h3><?php _e('Hidden Plugin Folders|Files Cron (HPF)', 'bulletproof-security'); ?>  <button id="bps-open-modal5" class="button bps-modal-button"><?php _e('Read Me', 'bulletproof-security'); ?></button></h3>

<div id="bps-modal-content5" class="bps-dialog-hide" title="<?php _e('Hidden Plugin Folders|Files Cron (HPF)', '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;
		echo $bps_general_help_info; 
		echo $bps_hpf_content;
	?>
    </p>
</div>

<?php
// HPF Status: real-time status check
// 2 possible HPF Status indicators: HPF Cron On, HPF Cron Off.
function bpsPro_hpf_status() {
	
	$hpf_options = get_option('bulletproof_security_options_hpf_cron');	
	
	if ( isset ( $_POST['Submit-Hidden-Plugins'] ) ) {
		$_POST['Submit-Hidden-Plugins'] = true;
	} else {
		$_POST['Submit-Hidden-Plugins'] = null;
	}
	
	if ( isset ( $_POST['Hidden-Plugins-Ignore-Submit'] ) )  {
		$_POST['Hidden-Plugins-Ignore-Submit'] = true;
	} else {
		$_POST['Hidden-Plugins-Ignore-Submit'] = null;
	}

	if ( $_POST['Submit-Hidden-Plugins'] != true && $_POST['Hidden-Plugins-Ignore-Submit'] != true ) {
	
		if ( isset($hpf_options['bps_hidden_plugins_cron']) && $hpf_options['bps_hidden_plugins_cron'] == 'On' ) {
			$text = '<h3><strong>'.__('HPF Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('HPF Cron On', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( isset($hpf_options['bps_hidden_plugins_cron']) && $hpf_options['bps_hidden_plugins_cron'] == 'Off' ) {
			$text = '<h3><strong>'.__('HPF Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('HPF Cron Off', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		}
	}

	if ( $_POST['Submit-Hidden-Plugins'] == true || $_POST['Hidden-Plugins-Ignore-Submit'] == true ) {
		
		if ( isset($hpf_options['bps_hidden_plugins_cron']) && $hpf_options['bps_hidden_plugins_cron'] == 'On' ) {
			$text = '<h3><strong>'.__('HPF Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('HPF Cron On', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( isset($hpf_options['bps_hidden_plugins_cron']) && $hpf_options['bps_hidden_plugins_cron'] == 'Off' ) {
			$text = '<h3><strong>'.__('HPF Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('HPF Cron Off', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		}
	}
}
?>

<div id="HPF-Status"><?php bpsPro_hpf_status(); ?></div>

<div id="HPF1" style="padding-left:10px;">
<div id="HPF2" style="position:relative;top:10px;left:0px;float:left;margin:0px 15px 0px 0px;">
    
<?php
	// Form: Hidden|Empty Plugin Folders|Files Cron
	echo '<form name="HPFCron" action="'.admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ).'" method="post">';
	wp_nonce_field('bulletproof_security_hpf_cron');

	$hpf_options = get_option('bulletproof_security_options_hpf_cron');
	$bps_hidden_plugins_cron_frequency = ! isset($hpf_options['bps_hidden_plugins_cron_frequency']) ? '' : $hpf_options['bps_hidden_plugins_cron_frequency'];
	$bps_hidden_plugins_cron = ! isset($hpf_options['bps_hidden_plugins_cron']) ? '' : $hpf_options['bps_hidden_plugins_cron'];
	
	echo '<label for="bps-hpf">'.__('HPF Cron Check Frequency:', 'bulletproof-security').'</label><br>';
	echo '<select name="hpf_cron_frequency" class="form-340">';
	echo '<option value="1"'. selected('1', $bps_hidden_plugins_cron_frequency).'>'.__('Run Check Every 1 Minute', 'bulletproof-security').'</option>';
	echo '<option value="5"'. selected('5', $bps_hidden_plugins_cron_frequency).'>'.__('Run Check Every 5 Minutes', 'bulletproof-security').'</option>';
	echo '<option value="10"'. selected('10', $bps_hidden_plugins_cron_frequency).'>'.__('Run Check Every 10 Minutes', 'bulletproof-security').'</option>';
	echo '<option value="15"'. selected('15', $bps_hidden_plugins_cron_frequency).'>'.__('Run Check Every 15 Minutes', 'bulletproof-security').'</option>';
	echo '<option value="30"'. selected('30', $bps_hidden_plugins_cron_frequency).'>'.__('Run Check Every 30 Minutes', 'bulletproof-security').'</option>';
	echo '<option value="60"'. selected('60', $bps_hidden_plugins_cron_frequency).'>'.__('Run Check Every 60 Minutes', 'bulletproof-security').'</option>';
	echo '<option value="daily"'. selected('daily', $bps_hidden_plugins_cron_frequency).'>'.__('Run Check Once Daily', 'bulletproof-security').'</option>';
	echo '</select><br><br>';

	echo '<label for="bps-hpf">'.__('HPF Cron On|Off:', 'bulletproof-security').'</label><br>';
	echo '<select name="hpf_on_off" class="form-340">';
	echo '<option value="On"'. selected('On', $bps_hidden_plugins_cron).'>'.__('HPF Cron On', 'bulletproof-security').'</option>';
	echo '<option value="Off"'. selected('Off', $bps_hidden_plugins_cron).'>'.__('HPF Cron Off', 'bulletproof-security').'</option>';
	echo '</select>';
	
	echo "<p><input type=\"submit\" name=\"Submit-Hidden-Plugins\" value=\"".__('Save HPF Cron Options', 'bulletproof-security')."\" class=\"button bps-button\" onclick=\"return confirm('".__('The default Cron Frequency is: Run Check Every 15 Minutes. This is a lightweight check that uses an insignificant amount of resources/memory so 4 checks per hour will not cause any performance issues whatsoever.\n\n-------------------------------------------------------------\n\nEven choosing Run Check Every 1 Minute would not cause any significant performance issues whatsoever.\n\n-------------------------------------------------------------\n\nClick OK to proceed or click Cancel', 'bulletproof-security')."')\" /></p></form>";

$scrolltoHiddenPlugins = isset($_REQUEST['scrolltoHiddenPlugins']) ? (int) $_REQUEST['scrolltoHiddenPlugins'] : 0; 
?>

</div>

<div id="HPF3" style="position:relative;top:0px;left:0px;float:left;margin:0px 0px 0px 0px;">

<form name="Hidden-Plugins" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
    <?php wp_nonce_field('bulletproof_security_hpf_cron_ignore'); ?>
	<?php $hpfi_options = get_option('bulletproof_security_options_hidden_plugins'); 
		$bps_hidden_plugins_check = ! isset($hpfi_options['bps_hidden_plugins_check']) ? '' : esc_html( trim( $hpfi_options['bps_hidden_plugins_check'], ", \t\n\r") );
	?>

	<div id="HPF4" style="position:relative;top:0px;left:0px;margin:10px 0px 10px 0px;">
	<strong><label><?php _e('Ignore Hidden Plugin Folders & Files:', 'bulletproof-security'); ?></label></strong><br />
    <?php $text = '<div style="allow-from-small-text">'.__('Add Ignore rules using plugin folder names or file names.', 'bulletproof-security').'<br>'.__('Use a comma and a space between folder and/or file names.', 'bulletproof-security').'<br><strong>'.__('Example: plugin-folder-name, example-file-name.php', 'bulletproof-security').'</strong></div>'; echo $text; ?>
    <textarea class="PFW-Allow-From-Text-Area" name="bps_hidden_plugins_check" style="margin-top:5px;" tabindex="1"><?php echo $bps_hidden_plugins_check; ?></textarea>
	<input type="hidden" name="scrolltoHiddenPlugins" id="scrolltoHiddenPlugins" value="<?php echo esc_html( $scrolltoHiddenPlugins ); ?>" />
	</div>

	<div id="HPF5" style="position:relative;top:0px;left:0px;margin:10px 0px 10px 0px;">
    <input type="submit" name="Hidden-Plugins-Ignore-Submit" class="button bps-button" value="<?php esc_attr_e('Save Plugin Folder|Files Ignore Rules', 'bulletproof-security') ?>" onclick="return confirm('<?php $text = __('This option is for adding ignore rules for Hidden or Empty Plugin Folders Detected by BPS or Non-standard WP files detected by BPS in your /plugins/ folder.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('This is an independent option setting that does not require clicking any other buttons.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to proceed or click Cancel.', 'bulletproof-security'); echo $text; ?>')"/>
	</div>

</form>
</div>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
	$('#PFW-Hidden-Plugins').submit(function(){ $('#scrolltoHiddenPlugins').val( $('#bps_hidden_plugins_check').scrollTop() ); });
	$('#bps_hidden_plugins_check').scrollTop( $('#scrolltoHiddenPlugins').val() );
});
/* ]]> */
</script>
</div>

<div id="MC1" style="position:relative;top:0px;left:0px;float:left;margin:0px 0px 0px 0px;width:100%;border-top:1px solid #999999;">

<h3><?php _e('Master htaccess Folder BulletProof Mode (MBM)', 'bulletproof-security'); ?>  <button id="bps-open-modal6" class="button bps-modal-button"><?php _e('Read Me', 'bulletproof-security'); ?></button></h3>

<div id="bps-modal-content6" class="bps-dialog-hide" title="<?php _e('MBM BulletProof Modes', '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;
	echo $bps_general_help_info; 
	echo $bps_mbm_content; 
	?>
    </p>
</div>

<?php
// MBM Status: real-time status check
// 3 possible MBM Status indicators: Activated, Deactivated or Disabled.
function bpsPro_mbm_status() {
	
	$HFiles_options = get_option('bulletproof_security_options_htaccess_files');	
	$filename = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/.htaccess';
	
	if ( isset ( $_POST['Submit-MBM-Activate'] ) ) {
		$_POST['Submit-MBM-Activate'] = true;
	} else {
		$_POST['Submit-MBM-Activate'] = null;
	}
	
	if ( isset ( $_POST['Submit-MBM-Deactivate'] ) )  {
		$_POST['Submit-MBM-Deactivate'] = true;
	} else {
		$_POST['Submit-MBM-Deactivate'] = null;
	}

	if ( $_POST['Submit-MBM-Activate'] != true && $_POST['Submit-MBM-Deactivate'] != true ) {
	
		if ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<h3><strong>'.__('MBM Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Disabled', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<h3><strong>'.__('MBM Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('Deactivated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		} elseif ( file_exists($filename) ) {
			$text = '<h3><strong>'.__('MBM Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		}
	}

	if ( $_POST['Submit-MBM-Activate'] == true || $_POST['Submit-MBM-Deactivate'] == true ) {
		
		if ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<h3><strong>'.__('MBM Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Disabled', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<h3><strong>'.__('MBM Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('Deactivated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		} elseif ( file_exists($filename) ) {
			$text = '<h3><strong>'.__('MBM Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		}
	}
}
?>

<div id="MBM-Status"><?php bpsPro_mbm_status(); ?></div>

<div id="mbm-bulletproof-mode" style="padding-left:10px;">

<form name="MBM-Activate" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_mbm_activate'); ?>

	<div id="MBM-buttons" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-MBM-Activate" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Activate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Activate MBM BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

<form name="MBM-Deactivate" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_mbm_deactivate'); ?>

	<div id="MBM-buttons" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-MBM-Deactivate" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Deactivate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Deactivate MBM BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

</div>
</div>

<div id="MC2" style="position:relative;top:0px;left:0px;float:left;margin:0px 0px 0px 0px;width:100%;border-top:1px solid #999999;">

<h3><?php _e('BPS Backup Folder BulletProof Mode (BBM)', 'bulletproof-security'); ?>  <button id="bps-open-modal7" class="button bps-modal-button"><?php _e('Read Me', 'bulletproof-security'); ?></button></h3>

<div id="bps-modal-content7" class="bps-dialog-hide" title="<?php _e('BBM BulletProof Modes', '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;
	echo $bps_general_help_info; 
	echo $bps_bbm_content; 
	?>
    </p>
</div>

<?php
// BBM Status: real-time status check
// 3 possible BBM Status indicators: Activated, Deactivated or Disabled.
function bpsPro_bbm_status() {
	
	$HFiles_options = get_option('bulletproof_security_options_htaccess_files');	
	$filename = WP_CONTENT_DIR . '/bps-backup/.htaccess';
	
	if ( isset ( $_POST['Submit-BBM-Activate'] ) ) {
		$_POST['Submit-BBM-Activate'] = true;
	} else {
		$_POST['Submit-BBM-Activate'] = null;
	}
	
	if ( isset ( $_POST['Submit-BBM-Deactivate'] ) )  {
		$_POST['Submit-BBM-Deactivate'] = true;
	} else {
		$_POST['Submit-BBM-Deactivate'] = null;
	}

	if ( $_POST['Submit-BBM-Activate'] != true && $_POST['Submit-BBM-Deactivate'] != true ) {
	
		if ( ! file_exists($filename) && isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<h3><strong>'.__('BBM Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Disabled', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( ! file_exists($filename) && isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<h3><strong>'.__('BBM Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('Deactivated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		} elseif ( file_exists($filename) ) {
			$text = '<h3><strong>'.__('BBM Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		}
	}

	if ( $_POST['Submit-BBM-Activate'] == true || $_POST['Submit-BBM-Deactivate'] == true ) {
		
		if ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<h3><strong>'.__('BBM Status: ', 'bulletproof-security').'<span class="core-status-disabled">'.__('Disabled', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		} elseif ( ! file_exists($filename) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<h3><strong>'.__('BBM Status: ', 'bulletproof-security').'<span class="core-status-deactivated">'.__('Deactivated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;	
		} elseif ( file_exists($filename) ) {
			$text = '<h3><strong>'.__('BBM Status: ', 'bulletproof-security').'<span class="core-status-activated">'.__('Activated', 'bulletproof-security').'</span></strong></h3>';
			echo $text;
		}
	}
}
?>

<div id="BBM-Status"><?php bpsPro_bbm_status(); ?></div>

<div id="bbm-bulletproof-mode" style="padding-left:10px;">

<form name="BBM-Activate" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_bbm_activate'); ?>

	<div id="BBM-buttons" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-BBM-Activate" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Activate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Activate BBM BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

<form name="BBM-Deactivate" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_bbm_deactivate'); ?>

	<div id="BBM-buttons" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-BBM-Deactivate" style="margin:10px 0px 10px 0px;width:84px;height:auto;white-space:normal" value="<?php esc_attr_e('Deactivate', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Caution: BPS Backup Folder BulletProof Mode (BBM) should only be deactivated for testing or troubleshooting. Be sure to activate BBM BulletProof Mode after you are done testing or troubleshooting.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Deactivate BBM BulletProof Mode or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

</div>
</div>

<div id="MC3" style="position:relative;top:0px;left:0px;float:left;margin:0px 0px 0px 0px;width:100%;border-top:1px solid #999999;">

<h3><?php _e('Backup & Restore BPS htaccess Files', 'bulletproof-security'); ?> <button id="bps-open-modal8" class="button bps-modal-button"><?php _e('Read Me', 'bulletproof-security'); ?></button></h3>

<div id="bps-modal-content8" class="bps-dialog-hide" title="<?php _e('Backup & Restore BPS htaccess Files', '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;
	echo $bps_backup_restore_content; 
	?>
    </p>
</div>

<div id="backup-restore-mode" style="padding-left:10px;">

<form name="Backup-htaccess-Files" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_backup_active_htaccess_files'); ?>

	<div id="Backup-htaccess-Files" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-Backup-htaccess-Files" style="margin:10px 0px 10px 0px;" value="<?php esc_attr_e('Backup htaccess Files', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Backup BPS htaccess files or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

<form name="Restore-htaccess-Files" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_restore_active_htaccess_files'); ?>

	<div id="Restore-htaccess-Files" style="float:left;padding-right:20px;">
    <input type="submit" name="Submit-Restore-htaccess-Files" style="margin:10px 0px 10px 0px;" value="<?php esc_attr_e('Restore htaccess Files', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Restore BPS htaccess files or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	</div>
</form>

</div>
</div>

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

<?php } ?>

</div>
            
<div id="bps-tabs-6" 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('htaccess File Editor ~ ', 'bulletproof-security'); ?><span style="font-size:.75em;"><?php _e('Check or edit BPS htaccess files/code manually/directly for testing.  Use BPS Custom Code to save htaccess code permanently.', 'bulletproof-security'); ?></span></h2></td>
  </tr>
  <tr>
    <td class="bps-table_cell">    
    
<h3 style="margin:0px 0px 5px 5px;"><?php _e('htaccess File Editing', 'bulletproof-security'); ?>  <button id="bps-open-modal9" class="button bps-modal-button"><?php _e('Read Me', 'bulletproof-security'); ?></button></h3>

<div id="bps-modal-content9" class="bps-dialog-hide" title="<?php _e('htaccess File Editing', 'bulletproof-security'); ?>">  
	<p><?php echo $bps_hfe_content; ?></p>
</div>

<?php if ( ! current_user_can('manage_options') ) { _e('Permission Denied', 'bulletproof-security'); } else { ?>

<table width="100%" border="0">
  <tr>
    <td colspan="2">
    
    <div id="bps_file_editor" class="bps_file_editor_update">

<?php
echo bps_secure_htaccess_file_check();
echo bps_default_htaccess_file_check();
echo bps_wpadmin_htaccess_file_check();

function bpsPro_secure_htaccess_write_check() {
	
	if ( isset ( $_POST['submit1'] ) ) {
		$_POST['submit1'] = true;
	} else {
		$_POST['submit1'] = null;
	}

	if ( $_POST['submit1'] != true ) {

		$secure_htaccess_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/secure.htaccess';
		$HFiles_options = get_option('bulletproof_security_options_htaccess_files');	
		
		if ( isset( $HFiles_options['bps_htaccess_files'] ) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<font color="blue" style="font-size:12px;"><strong>'.__('htaccess Files Disabled: secure.htaccess Master file is disabled.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		
		} elseif ( ! file_exists($secure_htaccess_file) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('ERROR: A secure.htaccess Master file was NOT found.', 'bulletproof-security').'</strong></font><br>';
			echo $text;	
			
		} else {
			
			if ( file_exists($secure_htaccess_file) ) {	
		
				if ( is_writable($secure_htaccess_file) ) {
		
					$text = '<font color="green" style="font-size:12px;"><strong>'.__('File Open and Write test successful! The secure.htaccess Master file is writable.', 'bulletproof-security').'</strong></font><br>';
					echo $text;

				} else {
				
					$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('Cannot write to file: ', 'bulletproof-security').$secure_htaccess_file . '</strong></font><br>';
					echo $text;
				}	
			}
		}
	}
}
	
bpsPro_secure_htaccess_write_check();

	if ( isset( $_POST['submit1'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_save_settings_1' );
	
		if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			echo $bps_topDiv;
			$text = '<font color="blue"><strong>'.__('htaccess Files Disabled: secure.htaccess Master file writing is disabled. ', 'bulletproof-security').'</strong></font>'.__('Click this link for help information: ', 'bulletproof-security').'<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;
    		echo $bps_bottomDiv;
			return;
		}

		$Encryption = new bpsProPHPEncryption();
		$nonceValue = 'ghbhnyxu';
		$secure_htaccess_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/secure.htaccess';
		
		$pos = strpos( $_POST['newcontent1'], 'eyJjaXBoZXJ0ZXh0Ijoi' );

		if ( $pos === false ) {
			$newcontent1 = stripslashes($_POST['newcontent1']);
		} else {
			$newcontent1 = $Encryption->decrypt($_POST['newcontent1'], $nonceValue);
		}

		if ( ! is_writable($secure_htaccess_file) ) {
			echo $bps_topDiv;
			$text = '<font color="#fb0101"><strong>'.__('Error: Unable to write to the secure.htaccess Master file.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
			echo $bps_bottomDiv;
		
		} else {
	
			if ( ! $handle = fopen($secure_htaccess_file, 'w+b') ) {
				exit;
			}
			
			if ( fwrite($handle, $newcontent1) === FALSE ) {
				exit;
			}
	
				echo $bps_topDiv;
				$text = '<font color="green"><strong>'.__('The secure.htaccess Master file has been updated.', 'bulletproof-security').'</strong></font><br>';
				echo $text;
				echo $bps_bottomDiv;
			
			fclose($handle);
		}
		
		$htaccessAR = WP_CONTENT_DIR . '/bps-backup/autorestore/wp-content/plugins/bulletproof-security/admin/htaccess/secure.htaccess';
		@copy($secure_htaccess_file, $htaccessAR);
	}

function bpsPro_default_htaccess_write_check() {
	
	if ( isset ( $_POST['submit2'] ) ) {
		$_POST['submit2'] = true;
	} else {
		$_POST['submit2'] = null;
	}

	if ( $_POST['submit2'] != true ) {

		$default_htaccess_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/default.htaccess';
		$HFiles_options = get_option('bulletproof_security_options_htaccess_files');	
		
		if ( isset( $HFiles_options['bps_htaccess_files'] ) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<font color="blue" style="font-size:12px;"><strong>'.__('htaccess Files Disabled: default.htaccess Master file is disabled.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		
		} elseif ( ! file_exists($default_htaccess_file) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('ERROR: A default.htaccess Master file was NOT found.', 'bulletproof-security').'</strong></font><br>';
			echo $text;	
			
		} else {
			
			if ( file_exists($default_htaccess_file) ) {		
		
				if ( is_writable($default_htaccess_file) ) {
			
					$text = '<font color="green" style="font-size:12px;"><strong>'.__('File Open and Write test successful! The default.htaccess Master file is writable.', 'bulletproof-security').'</strong></font><br>';
					echo $text;

				} else {
				
					$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('Cannot write to file: ', 'bulletproof-security').$default_htaccess_file . '</strong></font><br>';
					echo $text;
				}	
			}
		}
	}
}
	
bpsPro_default_htaccess_write_check();

	if ( isset( $_POST['submit2'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_save_settings_2' );
	
		if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			echo $bps_topDiv;
			$text = '<font color="blue"><strong>'.__('htaccess Files Disabled: default.htaccess Master file writing is disabled. ', 'bulletproof-security').'</strong></font>'.__('Click this link for help information: ', 'bulletproof-security').'<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;
    		echo $bps_bottomDiv;
			return;
		}

		$Encryption = new bpsProPHPEncryption();
		$nonceValue = 'ghbhnyxu';
		$default_htaccess_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/default.htaccess';
		
		$pos = strpos( $_POST['newcontent2'], 'eyJjaXBoZXJ0ZXh0Ijoi' );

		if ( $pos === false ) {
			$newcontent2 = stripslashes($_POST['newcontent2']);
		} else {
			$newcontent2 = $Encryption->decrypt($_POST['newcontent2'], $nonceValue);
		}

		if ( ! is_writable($default_htaccess_file) ) {
			echo $bps_topDiv;
			$text = '<font color="#fb0101"><strong>'.__('Error: Unable to write to the default.htaccess Master file.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
			echo $bps_bottomDiv;
		
		} else {
	
			if ( ! $handle = fopen($default_htaccess_file, 'w+b') ) {
				exit;
			}
			
			if ( fwrite($handle, $newcontent2) === FALSE ) {
				exit;
			}
	
				echo $bps_topDiv;
				$text = '<font color="green"><strong>'.__('The default.htaccess Master file has been updated.', 'bulletproof-security').'</strong></font><br>';
				echo $text;
				echo $bps_bottomDiv;
			
			fclose($handle);
		}

		$htaccessAR = WP_CONTENT_DIR . '/bps-backup/autorestore/wp-content/plugins/bulletproof-security/admin/htaccess/default.htaccess';
		$custom_default_htaccess = WP_CONTENT_DIR . '/bps-backup/master-backups/default.htaccess';
		
		@copy($default_htaccess_file, $htaccessAR);
		
		// 11.9.1: Save the Custom default.htaccess file to /bps-backup/master-backups/default.htaccess
		if ( ! copy($default_htaccess_file, $custom_default_htaccess) ) {
			echo $bps_topDiv;
			$text = '<strong><font color="#fb0101">'.__('Failed to copy your Custom default.htaccess file: ', 'bulletproof-security').'</font>'.$default_htaccess_file.__(' to: ', 'bulletproof-security').$custom_default_htaccess.__(' Check that the /bps-backup/ and /master-backups/ folders exist and the folder permissions or Ownership for these folders.', 'bulletproof-security').'</strong><br>';
			echo $text;
			echo $bps_bottomDiv;
		} else {
			echo $bps_topDiv;
			$text = '<strong><font color="green">'.__('Your Custom default.htaccess Master file has been successfully saved to: ', 'bulletproof-security').'</font>'.$custom_default_htaccess.'</strong><br>';
			echo $text;
			echo $bps_bottomDiv;
		}
	}

function bpsPro_wpadmin_secure_htaccess_write_check() {

	if ( isset ( $_POST['submit4'] ) ) {
		$_POST['submit4'] = true;
	} else {
		$_POST['submit4'] = null;
	}

	if ( $_POST['submit4'] != true ) {

		$wpadmin_htaccess_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/wpadmin-secure.htaccess';
		$HFiles_options = get_option('bulletproof_security_options_htaccess_files');
		$BPS_wpadmin_Options = get_option('bulletproof_security_options_htaccess_res');
		$GDMW_options = get_option('bulletproof_security_options_GDMW');	
		
		if ( isset( $BPS_wpadmin_Options['bps_wpadmin_restriction'] ) && $BPS_wpadmin_Options['bps_wpadmin_restriction'] == 'disabled' || isset( $GDMW_options['bps_gdmw_hosting'] ) && $GDMW_options['bps_gdmw_hosting'] == 'yes' ) {
			$text = '<strong><font color="black">'.__('wpadmin-secure.htaccess file writing is disabled.', 'bulletproof-security').'</font></strong><br>';
			echo $text;
		
		} else {
	
			if ( isset( $HFiles_options['bps_htaccess_files'] ) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
				$text = '<font color="blue" style="font-size:12px;"><strong>'.__('htaccess Files Disabled: wpadmin-secure.htaccess Master file is disabled.', 'bulletproof-security').'</strong></font><br>';
				echo $text;
		
			} elseif ( ! file_exists($wpadmin_htaccess_file) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
				$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('ERROR: A wpadmin-secure.htaccess Master file was NOT found.', 'bulletproof-security').'</strong></font><br>';
				echo $text;	
			
			} else {
			
				if ( file_exists($wpadmin_htaccess_file) ) {	
	
					if ( is_writable($wpadmin_htaccess_file) ) {
	
						$text = '<font color="green" style="font-size:12px;"><strong>'.__('File Open and Write test successful! The wpadmin-secure.htaccess Master file is writable.', 'bulletproof-security').'</strong></font><br>';
						echo $text;
					
					} else {
				
						$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('Cannot write to file: ', 'bulletproof-security').$wpadmin_htaccess_file . '</strong></font><br>';
						echo $text;
					}	
				}
			}
		}
	}
}
	
bpsPro_wpadmin_secure_htaccess_write_check();

	if ( isset( $_POST['submit4'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_save_settings_4' );
	
		if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			echo $bps_topDiv;
			$text = '<font color="blue"><strong>'.__('htaccess Files Disabled: wp-admin-secure.htaccess Master file writing is disabled. ', 'bulletproof-security').'</strong></font>'.__('Click this link for help information: ', 'bulletproof-security').'<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;
    		echo $bps_bottomDiv;
			return;
		}

		$Encryption = new bpsProPHPEncryption();
		$nonceValue = 'ghbhnyxu';
		$wpadmin_htaccess_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/wpadmin-secure.htaccess';
		
		$pos = strpos( $_POST['newcontent4'], 'eyJjaXBoZXJ0ZXh0Ijoi' );

		if ( $pos === false ) {
			$newcontent4 = stripslashes($_POST['newcontent4']);
		} else {
			$newcontent4 = $Encryption->decrypt($_POST['newcontent4'], $nonceValue);
		}

		if ( ! is_writable($wpadmin_htaccess_file) ) {
			echo $bps_topDiv;
			$text = '<font color="#fb0101"><strong>'.__('Error: Unable to write to the wpadmin-secure.htaccess Master file.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
			echo $bps_bottomDiv;
		
		} else {
	
			if ( ! $handle = fopen($wpadmin_htaccess_file, 'w+b') ) {
				exit;
			}
			
			if ( fwrite($handle, $newcontent4) === FALSE ) {
				exit;
			}
	
				echo $bps_topDiv;
				$text = '<font color="green"><strong>'.__('The wpadmin-secure.htaccess Master file has been updated.', 'bulletproof-security').'</strong></font><br>';
				echo $text;
				echo $bps_bottomDiv;
			
			fclose($handle);
		}
		
		$htaccessAR = WP_CONTENT_DIR . '/bps-backup/autorestore/wp-content/plugins/bulletproof-security/admin/htaccess/wpadmin-secure.htaccess';
		@copy($wpadmin_htaccess_file, $htaccessAR);
	}

function bpsPro_plugins_htaccess_write_check() {

	if ( isset ( $_POST['submit-plugins-bps'] ) ) {
		$_POST['submit-plugins-bps'] = true;
	} else {
		$_POST['submit-plugins-bps'] = null;
	}

	if ( $_POST['submit-plugins-bps'] != true ) {

		$plugins_htaccess_file = WP_PLUGIN_DIR . '/.htaccess';
		$HFiles_options = get_option('bulletproof_security_options_htaccess_files');	
		
		if ( ! file_exists($plugins_htaccess_file) && isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<font color="blue" style="font-size:12px;"><strong>'.__('htaccess Files Disabled: plugins folder htaccess file does not exist.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		
		} elseif ( ! file_exists($plugins_htaccess_file) && isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('ERROR: An htaccess file was NOT found in your plugins folder', 'bulletproof-security').'</strong></font><br>';
			echo $text;	
			
		} else {
			
			if ( file_exists($plugins_htaccess_file) ) {	
	
				if ( is_writable($plugins_htaccess_file) ) {
		
					$text = '<font color="green" style="font-size:12px;"><strong>'.__('File Open and Write test successful! Your currently active Plugins htaccess file is writable.', 'bulletproof-security').'</strong></font><br>';
					echo $text;

				} else {
				
					$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('Cannot write to file: ', 'bulletproof-security').$plugins_htaccess_file . '</strong></font><br>';
					echo $text;
				}
			}
		}
	}
}
	
bpsPro_plugins_htaccess_write_check();

	if ( isset( $_POST['submit-plugins-bps'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_save_settings_plugins' );
	
		if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			echo $bps_topDiv;
			$text = '<font color="blue"><strong>'.__('htaccess Files Disabled: plugins htaccess file writing is disabled. ', 'bulletproof-security').'</strong></font>'.__('Click this link for help information: ', 'bulletproof-security').'<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;
    		echo $bps_bottomDiv;
			return;
		}

		$Encryption = new bpsProPHPEncryption();
		$nonceValue = 'ghbhnyxu';
		$plugins_htaccess_file = WP_PLUGIN_DIR . '/.htaccess';
		
		$pos = strpos( $_POST['newcontent5'], 'eyJjaXBoZXJ0ZXh0Ijoi' );

		if ( $pos === false ) {
			$newcontent5 = stripslashes($_POST['newcontent5']);
		} else {
			$newcontent5 = $Encryption->decrypt($_POST['newcontent5'], $nonceValue);
		}

		if ( ! is_writable($plugins_htaccess_file) ) {
			echo $bps_topDiv;
			$text = '<font color="#fb0101"><strong>'.__('Error: Unable to write to the plugins htaccess file.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
			echo $bps_bottomDiv;
		
		} else {
	
			if ( ! $handle = fopen($plugins_htaccess_file, 'w+b') ) {
				exit;
			}
			
			if ( fwrite($handle, $newcontent5) === FALSE ) {
				exit;
			}
	
				echo $bps_topDiv;
				$text = '<font color="green"><strong>'.__('Your currently active plugins folder htaccess file has been updated.', 'bulletproof-security').'</strong></font><br>';
				echo $text;
				echo $bps_bottomDiv;
			
			fclose($handle);
		}
	
		$htaccessAR = WP_CONTENT_DIR . '/bps-backup/autorestore/wp-content/plugins/.htaccess';
		@copy($plugins_htaccess_file, $htaccessAR);
	}

function bpsPro_uploads_htaccess_write_check() {

	if ( isset ( $_POST['submit-uploads-bps'] ) ) {
		$_POST['submit-uploads-bps'] = true;
	} else {
		$_POST['submit-uploads-bps'] = null;
	}

	if ( $_POST['submit-uploads-bps'] != true ) {

		$bps_Uploads_Dir = wp_upload_dir();
		$uploads_htaccess_file = $bps_Uploads_Dir['basedir'] . '/.htaccess'; // for both single and Multisite is the standard /uploads folder
		$HFiles_options = get_option('bulletproof_security_options_htaccess_files');	
		
		if ( ! file_exists($uploads_htaccess_file) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<font color="blue" style="font-size:12px;"><strong>'.__('htaccess Files Disabled: uploads folder htaccess file does not exist.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		
		} elseif ( ! file_exists($uploads_htaccess_file) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('ERROR: An htaccess file was NOT found in your uploads folder', 'bulletproof-security').'</strong></font><br>';
			echo $text;	
			
		} else {
			
			if ( file_exists($uploads_htaccess_file) ) {
					
				if ( is_writable($uploads_htaccess_file) ) {
			
					$text = '<font color="green" style="font-size:12px;"><strong>'.__('File Open and Write test successful! Your currently active Uploads htaccess file is writable.', 'bulletproof-security').'</strong></font><br>';
					echo $text;

				} else {
		
					$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('Cannot write to file: ', 'bulletproof-security').$uploads_htaccess_file . '</strong></font><br>';
					echo $text;
				}
			}
		}
	}
}
	
bpsPro_uploads_htaccess_write_check();

	if ( isset( $_POST['submit-uploads-bps'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_save_settings_uploads' );
	
		if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			echo $bps_topDiv;
			$text = '<font color="blue"><strong>'.__('htaccess Files Disabled: uploads htaccess file writing is disabled. ', 'bulletproof-security').'</strong></font>'.__('Click this link for help information: ', 'bulletproof-security').'<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;
    		echo $bps_bottomDiv;
			return;
		}

		$Encryption = new bpsProPHPEncryption();
		$nonceValue = 'ghbhnyxu';
		$bps_Uploads_Dir = wp_upload_dir();
		$uploads_htaccess_file = $bps_Uploads_Dir['basedir'] . '/.htaccess'; // for both single and Multisite is the standard /uploads folder
		
		$pos = strpos( $_POST['newcontent6'], 'eyJjaXBoZXJ0ZXh0Ijoi' );

		if ( $pos === false ) {
			$newcontent6 = stripslashes($_POST['newcontent6']);
		} else {
			$newcontent6 = $Encryption->decrypt($_POST['newcontent6'], $nonceValue);
		}

		if ( ! is_writable($uploads_htaccess_file) ) {
			echo $bps_topDiv;
			$text = '<font color="#fb0101"><strong>'.__('Error: Unable to write to the uploads htaccess file.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
			echo $bps_bottomDiv;
		
		} else {
	
			if ( ! $handle = fopen($uploads_htaccess_file, 'w+b') ) {
				exit;
			}
			
			if ( fwrite($handle, $newcontent6) === FALSE ) {
				exit;
			}
	
				echo $bps_topDiv;
				$text = '<font color="green"><strong>'.__('Your currently active uploads folder htaccess file has been updated.', 'bulletproof-security').'</strong></font><br>';
				echo $text;
				echo $bps_bottomDiv;
			
			fclose($handle);
		}
	}

function bpsPro_root_htaccess_write_check() {

	if ( isset ( $_POST['submit7'] ) ) {
		$_POST['submit7'] = true;
	} else {
		$_POST['submit7'] = null;
	}

	if ( $_POST['submit7'] != true ) {
	
		$root_htaccess_file = ABSPATH . '.htaccess';
		$HFiles_options = get_option('bulletproof_security_options_htaccess_files');	
		
		if ( ! file_exists($root_htaccess_file) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			$text = '<font color="blue" style="font-size:12px;"><strong>'.__('htaccess Files Disabled: Root htaccess file does not exist.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		
		} elseif ( ! file_exists($root_htaccess_file) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
			$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('ERROR: An htaccess file was NOT found in your root folder', 'bulletproof-security').'</strong></font><br>';
			echo $text;	
			
		} else {
			
			if ( file_exists($root_htaccess_file) ) {
	
				if ( is_writable($root_htaccess_file) ) {
				
					$text = '<font color="green" style="font-size:12px;"><strong>'.__('File Open and Write test successful! Your currently active root htaccess file is writable.', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				
				} else {
				
					$text = '<font color="blue" style="font-size:12px;"><strong>'.__('Your root htaccess file is Locked with Read Only Permissions.', 'bulletproof-security').'<br>'.__('Use the Lock and Unlock buttons below to Lock or Unlock your root htaccess file for editing.', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				}
			}
		}
	}
}

bpsPro_root_htaccess_write_check();

	if ( isset( $_POST['submit7'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_save_settings_7' );
		
		if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			echo $bps_topDiv;
			$text = '<font color="blue"><strong>'.__('htaccess Files Disabled: Root htaccess file writing is disabled. ', 'bulletproof-security').'</strong></font>'.__('Click this link for help information: ', 'bulletproof-security').'<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;
    		echo $bps_bottomDiv;
			return;
		}

		$Encryption = new bpsProPHPEncryption();
		$nonceValue = 'ghbhnyxu';
		$root_htaccess_file = ABSPATH . '.htaccess';
		
		$pos = strpos( $_POST['newcontent7'], 'eyJjaXBoZXJ0ZXh0Ijoi' );

		if ( $pos === false ) {
			$newcontent7 = stripslashes($_POST['newcontent7']);
		} else {
			$newcontent7 = $Encryption->decrypt($_POST['newcontent7'], $nonceValue);
		}
		
		if ( ! is_writable($root_htaccess_file) ) {
			echo $bps_topDiv;
			$text = '<font color="#fb0101"><strong>'.__('Error: Unable to write to the Root htaccess file. If your Root htaccess file is locked you must unlock first.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
			echo $bps_bottomDiv;
		
		} else {	
	
			if ( ! $handle = fopen($root_htaccess_file, 'w+b') ) {
				exit;
			}
			
			if ( fwrite($handle, $newcontent7) === FALSE ) {
				exit;
			}
	
			echo $bps_topDiv;
			$text = '<font color="green"><strong>'.__('Your currently active root htaccess file has been updated.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
			echo $bps_bottomDiv;
			
			fclose($handle);
		}
		
		$htaccessAR = WP_CONTENT_DIR . '/bps-backup/autorestore/root-files/auto_.htaccess';
		@copy($root_htaccess_file, $htaccessAR);
	}

function bpsPro_wpadmin_htaccess_write_check() {

	if ( isset ( $_POST['submit8'] ) ) {
		$_POST['submit8'] = true;
	} else {
		$_POST['submit8'] = null;
	}

	if ( $_POST['submit8'] != true ) {

		$current_wpadmin_htaccess_file = ABSPATH . 'wp-admin/.htaccess';
		$HFiles_options = get_option('bulletproof_security_options_htaccess_files');
		$BPS_wpadmin_Options = get_option('bulletproof_security_options_htaccess_res');
		$GDMW_options = get_option('bulletproof_security_options_GDMW');	
		
		if ( isset( $BPS_wpadmin_Options['bps_wpadmin_restriction'] ) && $BPS_wpadmin_Options['bps_wpadmin_restriction'] == 'disabled' || isset( $GDMW_options['bps_gdmw_hosting'] ) && $GDMW_options['bps_gdmw_hosting'] == 'yes' ) {
			$text = '<font color="blue" style="font-size:12px;"><strong>'.__('wp-admin active htaccess file writing is disabled.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		
		} else {
	
			if ( ! file_exists($current_wpadmin_htaccess_file) && isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
				$text = '<font color="blue" style="font-size:12px;"><strong>'.__('htaccess Files Disabled: wp-admin folder htaccess file does not exist.', 'bulletproof-security').'</strong></font><br>';
				echo $text;
		
			} elseif ( ! file_exists($current_wpadmin_htaccess_file) && isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] != 'disabled' ) {	
				$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('ERROR: An htaccess file was NOT found in your wp-admin folder', 'bulletproof-security').'</strong></font><br>';
				echo $text;	
			
			} else {
			
				if ( file_exists($current_wpadmin_htaccess_file) ) {
	
					if ( is_writable($current_wpadmin_htaccess_file) ) {
			
						$text = '<font color="green" style="font-size:12px;"><strong>'.__('File Open and Write test successful! Your currently active wp-admin htaccess file is writable.', 'bulletproof-security').'</strong></font><br>';
						echo $text;
				
					} else {
		
						$text = '<font color="#fb0101" style="font-size:12px;"><strong>'.__('Cannot write to file: ', 'bulletproof-security').$current_wpadmin_htaccess_file . '</strong></font><br>';
						echo $text;
					}
				}
			}
		}
	}
}
	
bpsPro_wpadmin_htaccess_write_check();

	if ( isset( $_POST['submit8'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_save_settings_8' );
	
		if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
			echo $bps_topDiv;
			$text = '<font color="blue"><strong>'.__('htaccess Files Disabled: wp-admin htaccess file writing is disabled. ', 'bulletproof-security').'</strong></font>'.__('Click this link for help information: ', 'bulletproof-security').'<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;
    		echo $bps_bottomDiv;
			return;
		}

		$Encryption = new bpsProPHPEncryption();
		$nonceValue = 'ghbhnyxu';
		$current_wpadmin_htaccess_file = ABSPATH . 'wp-admin/.htaccess';
		
		$pos = strpos( $_POST['newcontent8'], 'eyJjaXBoZXJ0ZXh0Ijoi' );

		if ( $pos === false ) {
			$newcontent8 = stripslashes($_POST['newcontent8']);
		} else {
			$newcontent8 = $Encryption->decrypt($_POST['newcontent8'], $nonceValue);
		}

		if ( ! is_writable($current_wpadmin_htaccess_file) ) {
			echo $bps_topDiv;
			$text = '<font color="#fb0101"><strong>'.__('Error: Unable to write to the wp-admin htaccess file.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
			echo $bps_bottomDiv;
		
		} else {
	
			if ( ! $handle = fopen($current_wpadmin_htaccess_file, 'w+b') ) {
				exit;
			}
			
			if ( fwrite($handle, $newcontent8) === FALSE ) {
				exit;
			}
	
				echo $bps_topDiv;
				$text = '<font color="green"><strong>'.__('Your currently active wp-admin htaccess file has been updated.', 'bulletproof-security').'</strong></font><br>';
				echo $text;
				echo $bps_bottomDiv;
			
			fclose($handle);
		}
		
		$htaccessAR = WP_CONTENT_DIR . '/bps-backup/autorestore/wp-admin/wpadmin.htaccess';
		@copy($current_wpadmin_htaccess_file, $htaccessAR);	
	}

// Lock and Unlock Root .htaccess file 
if ( isset( $_POST['submit-ProFlockLock'] ) && current_user_can('manage_options') ) {
	check_admin_referer( 'bulletproof_security_flock_lock' );

	$bpsRootHtaccessOL = ABSPATH . '.htaccess';
	
	if ( file_exists($bpsRootHtaccessOL) ) {
		@chmod($bpsRootHtaccessOL, 0404);
		echo $bps_topDiv;
		$text = '<font color="green"><strong><br>'.__('Your Root htaccess file has been Locked.', 'bulletproof-security').'</strong></font><br>';
		echo $text;
		echo $bps_bottomDiv;
	} else {
		echo $bps_topDiv;
		$text = '<font color="#fb0101"><strong><br>'.__('Unable to Lock your Root htaccess file.', 'bulletproof-security').'</strong></font><br>';
		echo $text;
		echo $bps_bottomDiv;
	}
}
	
if ( isset( $_POST['submit-ProFlockUnLock'] ) && current_user_can('manage_options') ) {
	check_admin_referer( 'bulletproof_security_flock_unlock' );
	
	$bpsRootHtaccessOL = ABSPATH . '.htaccess';
		
	if ( file_exists($bpsRootHtaccessOL) ) {
		@chmod($bpsRootHtaccessOL, 0644);
		echo $bps_topDiv;
		$text = '<font color="green"><strong><br>'.__('Your Root htaccess file has been Unlocked.', 'bulletproof-security').'</strong></font><br>';
		echo $text;
		echo $bps_bottomDiv;
	} else {
		echo $bps_topDiv;
		$text = '<font color="#fb0101"><strong><br>'.__('Unable to Unlock your Root htaccess file.', 'bulletproof-security').'</strong></font><br>';
		echo $text;
		echo $bps_bottomDiv;
	}
}

?>
</div>

</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>

<?php // Detect the SAPI - display form submit button only if sapi is cgi
	$sapi_type = php_sapi_name();
	if ( @substr($sapi_type, 0, 6) != 'apache' ) {	
?>    
 
<div id="bpsLockHtaccess">  
<form name="bpsFlockLockForm" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-6' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_flock_lock'); ?>
	<input type="submit" name="submit-ProFlockLock" value="<?php esc_attr_e('Lock htaccess File', 'bulletproof-security'); ?>" class="button bps-button" style="width:138px;height:auto;white-space:normal" onclick="return confirm('<?php $text = __('Click OK to Lock your Root htaccess file or click Cancel.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Note: The File Open and Write Test window will still display the last status of the file as Unlocked. To see the current status refresh your browser.', 'bulletproof-security'); echo $text; ?>')" />
</form>
</div>

<div id="bpsUnLockHtaccess">    
<form name="bpsFlockUnLockForm" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-6' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_flock_unlock'); ?>

	<input type="submit" name="submit-ProFlockUnLock" value="<?php esc_attr_e('Unlock htaccess File', 'bulletproof-security'); ?>" class="button bps-button" style="width:138px;height:auto;white-space:normal" onclick="return confirm('<?php $text = __('Click OK to Unlock your Root htaccess file or click Cancel.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Note: The File Open and Write Test window will still display the last status of the file as Locked. To see the current status refresh your browser.', 'bulletproof-security'); echo $text; ?>')" />
</form>
</div>

<div id="bpsAutoLockOn">
<form name="bpsRootAutoLock-On" action="options.php#bps-tabs-6" method="post">
    <?php settings_fields('bulletproof_security_options_autolock'); ?>
	<?php $options = get_option('bulletproof_security_options_autolock'); ?>
	<input type="hidden" name="bulletproof_security_options_autolock[bps_root_htaccess_autolock]" value="On" />
	<input type="submit" name="submit-RootHtaccessAutoLock-On" value="<?php esc_attr_e('Turn On AutoLock', 'bulletproof-security'); ?>" class="button bps-button" style="width:138px;height:auto;white-space:normal" onclick="return confirm('<?php $text = __('Turning AutoLock On will allow BPS Pro to automatically lock your Root .htaccess file. For some folks this causes a problem because their Web Hosts do not allow the Root .htaccess file to be locked. For most folks allowing BPS Pro to AutoLock the Root .htaccess file works fine.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Turn AutoLock On or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />

<?php if ( $options['bps_root_htaccess_autolock'] == '' || $options['bps_root_htaccess_autolock'] == 'On' ) { echo '<label class="autolock_status" style="font-weight:bold;">'.__('On', 'bulletproof-security').'</label>'; } ?>

</form>
</div>

<div id="bpsAutoLockOff">
<form name="bpsRootAutoLock-Off" action="options.php#bps-tabs-6" method="post">
    <?php settings_fields('bulletproof_security_options_autolock'); ?>
	<?php $options = get_option('bulletproof_security_options_autolock'); ?>
	<input type="hidden" name="bulletproof_security_options_autolock[bps_root_htaccess_autolock]" value="Off" />
	<input type="submit" name="submit-RootHtaccessAutoLock-Off" value="<?php esc_attr_e('Turn Off AutoLock', 'bulletproof-security'); ?>" class="button bps-button" style="width:138px;height:auto;white-space:normal" onclick="return confirm('<?php $text = __('Turning AutoLock Off will prevent BPS Pro from automatically locking your Root .htaccess file. For some folks this is necessary because their Web Hosts do not allow the Root .htaccess file to be locked. For most folks allowing BPS Pro to AutoLock the Root .htaccess file works fine.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Turn AutoLock Off or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />

<?php if ( $options['bps_root_htaccess_autolock'] == 'Off') { echo '<label class="autolock_status" style="font-weight:bold;">'.__('Off', 'bulletproof-security').'</label>'; } ?>

</form>
</div>

<?php } ?>

</td>
  <tr>
    <td colspan="2">
    
    <!-- jQuery UI File Editor Tab Menu -->
<div id="bps-edittabs" class="bps-edittabs-class">
	
    <ul>
		<li><a href="#bps-edittabs-1"><?php _e('secure.htaccess', 'bulletproof-security'); ?></a></li>
		<li><a href="#bps-edittabs-2"><?php _e('default.htaccess', 'bulletproof-security'); ?></a></li>
		<li><a href="#bps-edittabs-4"><?php _e('wpadmin-secure.htaccess', 'bulletproof-security'); ?></a></li>
		<li><a href="#bps-edittabs-5"><?php _e('Your Current Plugins htaccess File', 'bulletproof-security'); ?></a></li>
		<li><a href="#bps-edittabs-6"><?php _e('Your Current Uploads htaccess File', 'bulletproof-security'); ?></a></li>
		<li><a href="#bps-edittabs-7"><?php _e('Your Current Root htaccess File', 'bulletproof-security'); ?></a></li>
		<li><a href="#bps-edittabs-8"><?php _e('Your Current wp-admin htaccess File', 'bulletproof-security'); ?></a></li>
	</ul>
       
<?php 
$scrollto1 = isset($_REQUEST['scrollto1']) ? (int) $_REQUEST['scrollto1'] : 0; 
$scrollto2 = isset($_REQUEST['scrollto2']) ? (int) $_REQUEST['scrollto2'] : 0;
$scrollto4 = isset($_REQUEST['scrollto4']) ? (int) $_REQUEST['scrollto4'] : 0;
$scrollto5 = isset($_REQUEST['scrollto5']) ? (int) $_REQUEST['scrollto5'] : 0;
$scrollto6 = isset($_REQUEST['scrollto6']) ? (int) $_REQUEST['scrollto6'] : 0;
$scrollto7 = isset($_REQUEST['scrollto7']) ? (int) $_REQUEST['scrollto7'] : 0;
$scrollto8 = isset($_REQUEST['scrollto8']) ? (int) $_REQUEST['scrollto8'] : 0;
?>

<div id="bps-edittabs-1" class="bps-edittabs-page-class">
<form name="template1" id="template1" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-6' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_save_settings_1'); 
	$secure_htaccess_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/secure.htaccess';
?>
    <div>
    <textarea id="crypt21" class="bps-text-area-600x700" name="newcontent1" id="newcontent1" tabindex="1"><?php echo bps_get_secure_htaccess(); ?></textarea>
	<input type="hidden" name="action" value="update" />
    <input type="hidden" name="filename" value="<?php echo esc_attr($secure_htaccess_file) ?>" />
	<input type="hidden" name="scrollto1" id="scrollto1" value="<?php echo esc_html( $scrollto1 ); ?>" />
    <p class="submit">

	<?php echo '<div id="bps-edittabs-tooltip" style="margin:-40px 0px 10px 0px"><label for="bps-mscan-label" style="">'.__('If you see an error or are unable to save your editing changes then click the Encrypt htaccess Code button first and then click the Update File button. Mouse over the question mark image to the right for help info.', 'bulletproof-security').'</label><strong><font color="black"><span class="tooltip-350-225"><img src="'.plugins_url('/bulletproof-security/admin/images/question-mark.png').'" style="position:relative;top:3px;left:5px;" /><span>'.__('If your web host currently has ModSecurity installed or installs ModSecurity at a later time then ModSecurity will prevent you from saving your htaccess code unless you encrypt it first by clicking the Encrypt htaccess Code button.', 'bulletproof-security').'<br><br>'.__('If you click the Encrypt htaccess Code button and then want to edit your code again click the Decrypt htaccess Code button. After you are done editing click the Encrypt htaccess Code button before clicking the Update File button.', 'bulletproof-security').'<br><br>'.__('Click the htaccess File Editing Read Me help button for more help info.', 'bulletproof-security').'</span></span></font></strong></div>'; ?>

	<input type="submit" name="submit1" class="button bps-button" value="<?php esc_attr_e('Update File', 'bulletproof-security') ?>" /></p>
</div>
</form>

	<button onclick="bpsSecureFileEncrypt()" class="button bps-button"><?php esc_attr_e('Encrypt htaccess Code', 'bulletproof-security'); ?></button> 
	<button onclick="bpsSecureFileDecrypt()" class="button bps-button"><?php esc_attr_e('Decrypt htaccess Code', 'bulletproof-security'); ?></button>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
	$('#template1').submit(function(){ $('#scrollto1').val( $('#newcontent1').scrollTop() ); });
	$('#newcontent1').scrollTop( $('#scrollto1').val() ); 
});

function bpsSecureFileEncrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt21").value;
  
  // Prevent Double, Triple, etc. encryption
  // The includes() method is not supported in IE 11 (and earlier versions)
  var NoEncrypt1 = CCString1.includes("eyJjaXBoZXJ0ZXh0Ijoi");
  //console.log(NoEncrypt1);

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '' && NoEncrypt1 === false) {
  var encrypted1 = encryption.encrypt(CCString1, nonceValue);
  }
  //console.log(encrypted1); 
  
  if (CCString1 != '' && NoEncrypt1 === false) {
  document.getElementById("crypt21").value = encrypted1;
  }
}

function bpsSecureFileDecrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt21").value;

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '') {
  var decrypted1 = encryption.decrypt(CCString1, nonceValue);
  }
  //console.log(decrypted1);
  
  if (CCString1 != '') {
  document.getElementById("crypt21").value = decrypted1;
  }
}
/* ]]> */
</script>     
</div>

<div id="bps-edittabs-2" class="bps-edittabs-page-class">
<form name="template2" id="template2" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-6' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_save_settings_2'); 
	$default_htaccess_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/default.htaccess';
?>
	<div>
    <textarea id="crypt22" class="bps-text-area-600x700" name="newcontent2" id="newcontent2" tabindex="2"><?php echo bps_get_default_htaccess(); ?></textarea>
	<input type="hidden" name="action" value="update" />
    <input type="hidden" name="filename" value="<?php echo esc_attr($default_htaccess_file) ?>" />
	<input type="hidden" name="scrollto2" id="scrollto2" value="<?php echo esc_html( $scrollto2 ); ?>" />
    <p class="submit">

	<?php echo '<div id="bps-edittabs-tooltip" style="margin:-40px 0px 10px 0px"><label for="bps-mscan-label" style="">'.__('If you see an error or are unable to save your editing changes then click the Encrypt htaccess Code button first and then click the Update File button. Mouse over the question mark image to the right for help info.', 'bulletproof-security').'</label><strong><font color="black"><span class="tooltip-350-225"><img src="'.plugins_url('/bulletproof-security/admin/images/question-mark.png').'" style="position:relative;top:3px;left:5px;" /><span>'.__('If your web host currently has ModSecurity installed or installs ModSecurity at a later time then ModSecurity will prevent you from saving your htaccess code unless you encrypt it first by clicking the Encrypt htaccess Code button.', 'bulletproof-security').'<br><br>'.__('If you click the Encrypt htaccess Code button and then want to edit your code again click the Decrypt htaccess Code button. After you are done editing click the Encrypt htaccess Code button before clicking the Update File button.', 'bulletproof-security').'<br><br>'.__('Click the htaccess File Editing Read Me help button for more help info.', 'bulletproof-security').'</span></span></font></strong></div>'; ?>

	<input type="submit" name="submit2" class="button bps-button" value="<?php esc_attr_e('Update File', 'bulletproof-security') ?>" /></p>
</div>
</form>

	<button onclick="bpsDefaultFileEncrypt()" class="button bps-button"><?php esc_attr_e('Encrypt htaccess Code', 'bulletproof-security'); ?></button> 
	<button onclick="bpsDefaultFileDecrypt()" class="button bps-button"><?php esc_attr_e('Decrypt htaccess Code', 'bulletproof-security'); ?></button>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
	$('#template2').submit(function(){ $('#scrollto2').val( $('#newcontent2').scrollTop() ); });
	$('#newcontent2').scrollTop( $('#scrollto2').val() );
});

function bpsDefaultFileEncrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt22").value;
  
  // Prevent Double, Triple, etc. encryption
  // The includes() method is not supported in IE 11 (and earlier versions)
  var NoEncrypt1 = CCString1.includes("eyJjaXBoZXJ0ZXh0Ijoi");
  //console.log(NoEncrypt1);

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '' && NoEncrypt1 === false) {
  var encrypted1 = encryption.encrypt(CCString1, nonceValue);
  }
  //console.log(encrypted1); 
  
  if (CCString1 != '' && NoEncrypt1 === false) {
  document.getElementById("crypt22").value = encrypted1;
  }
}

function bpsDefaultFileDecrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt22").value;

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '') {
  var decrypted1 = encryption.decrypt(CCString1, nonceValue);
  }
  //console.log(decrypted1);
  
  if (CCString1 != '') {
  document.getElementById("crypt22").value = decrypted1;
  }
}
/* ]]> */
</script>     
</div>

<div id="bps-edittabs-4" class="bps-edittabs-page-class">
<form name="template4" id="template4" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-6' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_save_settings_4'); 
	$wpadmin_htaccess_file = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/wpadmin-secure.htaccess';
?>
	<div>
    <textarea id="crypt23" class="bps-text-area-600x700" name="newcontent4" id="newcontent4" tabindex="4"><?php echo bps_get_wpadmin_htaccess(); ?></textarea>
	<input type="hidden" name="action" value="update" />
    <input type="hidden" name="filename" value="<?php echo esc_attr($wpadmin_htaccess_file) ?>" />
	<input type="hidden" name="scrollto4" id="scrollto4" value="<?php echo esc_html( $scrollto4 ); ?>" />
    <p class="submit">

	<?php echo '<div id="bps-edittabs-tooltip" style="margin:-40px 0px 10px 0px"><label for="bps-mscan-label" style="">'.__('If you see an error or are unable to save your editing changes then click the Encrypt htaccess Code button first and then click the Update File button. Mouse over the question mark image to the right for help info.', 'bulletproof-security').'</label><strong><font color="black"><span class="tooltip-350-225"><img src="'.plugins_url('/bulletproof-security/admin/images/question-mark.png').'" style="position:relative;top:3px;left:5px;" /><span>'.__('If your web host currently has ModSecurity installed or installs ModSecurity at a later time then ModSecurity will prevent you from saving your htaccess code unless you encrypt it first by clicking the Encrypt htaccess Code button.', 'bulletproof-security').'<br><br>'.__('If you click the Encrypt htaccess Code button and then want to edit your code again click the Decrypt htaccess Code button. After you are done editing click the Encrypt htaccess Code button before clicking the Update File button.', 'bulletproof-security').'<br><br>'.__('Click the htaccess File Editing Read Me help button for more help info.', 'bulletproof-security').'</span></span></font></strong></div>'; ?>

	<input type="submit" name="submit4" class="button bps-button" value="<?php esc_attr_e('Update File', 'bulletproof-security') ?>" /></p>
</div>
</form>

	<button onclick="bpsWpadminSecureFileEncrypt()" class="button bps-button"><?php esc_attr_e('Encrypt htaccess Code', 'bulletproof-security'); ?></button> 
	<button onclick="bpsWpadminSecureFileDecrypt()" class="button bps-button"><?php esc_attr_e('Decrypt htaccess Code', 'bulletproof-security'); ?></button>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
	$('#template4').submit(function(){ $('#scrollto4').val( $('#newcontent4').scrollTop() ); });
	$('#newcontent4').scrollTop( $('#scrollto4').val() );
});

function bpsWpadminSecureFileEncrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt23").value;
  
  // Prevent Double, Triple, etc. encryption
  // The includes() method is not supported in IE 11 (and earlier versions)
  var NoEncrypt1 = CCString1.includes("eyJjaXBoZXJ0ZXh0Ijoi");
  //console.log(NoEncrypt1);

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '' && NoEncrypt1 === false) {
  var encrypted1 = encryption.encrypt(CCString1, nonceValue);
  }
  //console.log(encrypted1); 
  
  if (CCString1 != '' && NoEncrypt1 === false) {
  document.getElementById("crypt23").value = encrypted1;
  }
}

function bpsWpadminSecureFileDecrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt23").value;

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '') {
  var decrypted1 = encryption.decrypt(CCString1, nonceValue);
  }
  //console.log(decrypted1);
  
  if (CCString1 != '') {
  document.getElementById("crypt23").value = decrypted1;
  }
}
/* ]]> */
</script>     
</div>

<div id="bps-edittabs-5" class="bps-edittabs-page-class">
<form name="template-plugins-bps" id="template-plugins-bps" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-6' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_save_settings_plugins'); 
	$plugins_htaccess_file = WP_PLUGIN_DIR . '/.htaccess';
?>
	<div>
    <textarea id="crypt24" class="bps-text-area-600x700" name="newcontent5" id="newcontent5" tabindex="5"><?php echo bps_get_plugins_htaccess(); ?></textarea>
	<input type="hidden" name="action" value="update" />
    <input type="hidden" name="filename" value="<?php echo esc_attr($plugins_htaccess_file) ?>" />
	<input type="hidden" name="scrollto5" id="scrollto5" value="<?php echo esc_html( $scrollto5 ); ?>" />
    <p class="submit">

	<?php echo '<div id="bps-edittabs-tooltip" style="margin:-40px 0px 10px 0px"><label for="bps-mscan-label" style="">'.__('If you see an error or are unable to save your editing changes then click the Encrypt htaccess Code button first and then click the Update File button. Mouse over the question mark image to the right for help info.', 'bulletproof-security').'</label><strong><font color="black"><span class="tooltip-350-225"><img src="'.plugins_url('/bulletproof-security/admin/images/question-mark.png').'" style="position:relative;top:3px;left:5px;" /><span>'.__('If your web host currently has ModSecurity installed or installs ModSecurity at a later time then ModSecurity will prevent you from saving your htaccess code unless you encrypt it first by clicking the Encrypt htaccess Code button.', 'bulletproof-security').'<br><br>'.__('If you click the Encrypt htaccess Code button and then want to edit your code again click the Decrypt htaccess Code button. After you are done editing click the Encrypt htaccess Code button before clicking the Update File button.', 'bulletproof-security').'<br><br>'.__('Click the htaccess File Editing Read Me help button for more help info.', 'bulletproof-security').'</span></span></font></strong></div>'; ?>

	<input type="submit" name="submit-plugins-bps" class="button bps-button" value="<?php esc_attr_e('Update File', 'bulletproof-security') ?>" /></p>
</div>
</form>

	<button onclick="bpsPluginsFileEncrypt()" class="button bps-button"><?php esc_attr_e('Encrypt htaccess Code', 'bulletproof-security'); ?></button> 
	<button onclick="bpsPluginsFileDecrypt()" class="button bps-button"><?php esc_attr_e('Decrypt htaccess Code', 'bulletproof-security'); ?></button>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
	$('#template-plugins-bps').submit(function(){ $('#scrollto5').val( $('#newcontent5').scrollTop() ); });
	$('#newcontent5').scrollTop( $('#scrollto5').val() );
});

function bpsPluginsFileEncrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt24").value;
  
  // Prevent Double, Triple, etc. encryption
  // The includes() method is not supported in IE 11 (and earlier versions)
  var NoEncrypt1 = CCString1.includes("eyJjaXBoZXJ0ZXh0Ijoi");
  //console.log(NoEncrypt1);

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '' && NoEncrypt1 === false) {
  var encrypted1 = encryption.encrypt(CCString1, nonceValue);
  }
  //console.log(encrypted1); 
  
  if (CCString1 != '' && NoEncrypt1 === false) {
  document.getElementById("crypt24").value = encrypted1;
  }
}

function bpsPluginsFileDecrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt24").value;

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '') {
  var decrypted1 = encryption.decrypt(CCString1, nonceValue);
  }
  //console.log(decrypted1);
  
  if (CCString1 != '') {
  document.getElementById("crypt24").value = decrypted1;
  }
}
/* ]]> */
</script>     
</div>

<div id="bps-edittabs-6" class="bps-edittabs-page-class">
<form name="template-uploads-bps" id="template-uploads-bps" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-6' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_save_settings_uploads'); 
	$bps_Uploads_Dir = wp_upload_dir();
	$uploads_htaccess_file = $bps_Uploads_Dir['basedir'] . '/.htaccess';
?>
	<div>
    <textarea id="crypt25" class="bps-text-area-600x700" name="newcontent6" id="newcontent6" tabindex="6"><?php echo bps_get_uploads_htaccess(); ?></textarea>
	<input type="hidden" name="action" value="update" />
    <input type="hidden" name="filename" value="<?php echo esc_attr($uploads_htaccess_file) ?>" />
	<input type="hidden" name="scrollto6" id="scrollto6" value="<?php echo esc_html( $scrollto6 ); ?>" />
    <p class="submit">

	<?php echo '<div id="bps-edittabs-tooltip" style="margin:-40px 0px 10px 0px"><label for="bps-mscan-label" style="">'.__('If you see an error or are unable to save your editing changes then click the Encrypt htaccess Code button first and then click the Update File button. Mouse over the question mark image to the right for help info.', 'bulletproof-security').'</label><strong><font color="black"><span class="tooltip-350-225"><img src="'.plugins_url('/bulletproof-security/admin/images/question-mark.png').'" style="position:relative;top:3px;left:5px;" /><span>'.__('If your web host currently has ModSecurity installed or installs ModSecurity at a later time then ModSecurity will prevent you from saving your htaccess code unless you encrypt it first by clicking the Encrypt htaccess Code button.', 'bulletproof-security').'<br><br>'.__('If you click the Encrypt htaccess Code button and then want to edit your code again click the Decrypt htaccess Code button. After you are done editing click the Encrypt htaccess Code button before clicking the Update File button.', 'bulletproof-security').'<br><br>'.__('Click the htaccess File Editing Read Me help button for more help info.', 'bulletproof-security').'</span></span></font></strong></div>'; ?>

	<input type="submit" name="submit-uploads-bps" class="button bps-button" value="<?php esc_attr_e('Update File', 'bulletproof-security') ?>" /></p>
</div>
</form>

	<button onclick="bpsUploadsFileEncrypt()" class="button bps-button"><?php esc_attr_e('Encrypt htaccess Code', 'bulletproof-security'); ?></button> 
	<button onclick="bpsUploadsFileDecrypt()" class="button bps-button"><?php esc_attr_e('Decrypt htaccess Code', 'bulletproof-security'); ?></button>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
	$('#template-uploads-bps').submit(function(){ $('#scrollto6').val( $('#newcontent6').scrollTop() ); });
	$('#newcontent6').scrollTop( $('#scrollto6').val() );
});

function bpsUploadsFileEncrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt25").value;
  
  // Prevent Double, Triple, etc. encryption
  // The includes() method is not supported in IE 11 (and earlier versions)
  var NoEncrypt1 = CCString1.includes("eyJjaXBoZXJ0ZXh0Ijoi");
  //console.log(NoEncrypt1);

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '' && NoEncrypt1 === false) {
  var encrypted1 = encryption.encrypt(CCString1, nonceValue);
  }
  //console.log(encrypted1); 
  
  if (CCString1 != '' && NoEncrypt1 === false) {
  document.getElementById("crypt25").value = encrypted1;
  }
}

function bpsUploadsFileDecrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt25").value;

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '') {
  var decrypted1 = encryption.decrypt(CCString1, nonceValue);
  }
  //console.log(decrypted1);
  
  if (CCString1 != '') {
  document.getElementById("crypt25").value = decrypted1;
  }
}
/* ]]> */
</script>     
</div>

<?php
// File Editor Root .htaccess file Lock check with pop up Confirm message
function bpsStatusRHE() {

	$HFiles_options = get_option('bulletproof_security_options_htaccess_files');

	if ( isset($HFiles_options['bps_htaccess_files']) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {
		$perms = '';
		
		return $perms;
	}
	
	clearstatcache();
	$filename = ABSPATH . '.htaccess';
	$sapi_type = php_sapi_name();
	
	if ( file_exists($filename) && substr($sapi_type, 0, 6) != 'apache') {
		$perms = substr(sprintf('%o', fileperms($filename)), -4);
		
		return $perms;
	}
}
?>

<div id="bps-edittabs-7" class="bps-edittabs-page-class">
<form name="template7" id="template7" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-6' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_save_settings_7'); 
	$root_htaccess_file = ABSPATH . '.htaccess';
	$perms = '';
?>
	<div>
    <textarea id="crypt26" class="bps-text-area-600x700" name="newcontent7" id="newcontent7" tabindex="7"><?php echo bps_get_root_htaccess(); ?></textarea>
	<input type="hidden" name="action" value="update" />
    <input type="hidden" name="filename" value="<?php echo esc_attr($root_htaccess_file) ?>" />
	<input type="hidden" name="scrollto7" id="scrollto7" value="<?php echo esc_html( $scrollto7 ); ?>" />
    <p class="submit">

<?php if ( bpsStatusRHE($perms) == '0404' ) { ?>

	<input type="submit" name="submit7" value="<?php esc_attr_e('Update File', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('YOUR ROOT HTACCESS FILE IS LOCKED.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('YOUR FILE EDITS / CHANGES CANNOT BE SAVED.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click Cancel, copy the file editing changes you made to save them and then click the Unlock htaccess File button to unlock your Root htaccess file. After your Root htaccess file is unlocked paste your file editing changes back into your Root htaccess file and click this Update File button again to save your file edits/changes.', 'bulletproof-security'); echo $text; ?>')" />
	
	<?php } else { ?>

	<?php echo '<div id="bps-edittabs-tooltip" style="margin:-40px 0px 10px 0px"><label for="bps-mscan-label" style="">'.__('If you see an error or are unable to save your editing changes then click the Encrypt htaccess Code button first and then click the Update File button. Mouse over the question mark image to the right for help info.', 'bulletproof-security').'</label><strong><font color="black"><span class="tooltip-350-225"><img src="'.plugins_url('/bulletproof-security/admin/images/question-mark.png').'" style="position:relative;top:3px;left:5px;" /><span>'.__('If your web host currently has ModSecurity installed or installs ModSecurity at a later time then ModSecurity will prevent you from saving your htaccess code unless you encrypt it first by clicking the Encrypt htaccess Code button.', 'bulletproof-security').'<br><br>'.__('If you click the Encrypt htaccess Code button and then want to edit your code again click the Decrypt htaccess Code button. After you are done editing click the Encrypt htaccess Code button before clicking the Update File button.', 'bulletproof-security').'<br><br>'.__('Click the htaccess File Editing Read Me help button for more help info.', 'bulletproof-security').'</span></span></font></strong></div>'; ?>

	<input type="submit" name="submit7" class="button bps-button" value="<?php esc_attr_e('Update File', 'bulletproof-security') ?>" /></p>
<?php } ?>
</div>
</form>

	<button onclick="bpsRootFileEncrypt()" class="button bps-button"><?php esc_attr_e('Encrypt htaccess Code', 'bulletproof-security'); ?></button> 
	<button onclick="bpsRootFileDecrypt()" class="button bps-button"><?php esc_attr_e('Decrypt htaccess Code', 'bulletproof-security'); ?></button>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
	$('#template7').submit(function(){ $('#scrollto7').val( $('#newcontent7').scrollTop() ); });
	$('#newcontent7').scrollTop( $('#scrollto7').val() );
});

function bpsRootFileEncrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt26").value;
  
  // Prevent Double, Triple, etc. encryption
  // The includes() method is not supported in IE 11 (and earlier versions)
  var NoEncrypt1 = CCString1.includes("eyJjaXBoZXJ0ZXh0Ijoi");
  //console.log(NoEncrypt1);

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '' && NoEncrypt1 === false) {
  var encrypted1 = encryption.encrypt(CCString1, nonceValue);
  }
  //console.log(encrypted1); 
  
  if (CCString1 != '' && NoEncrypt1 === false) {
  document.getElementById("crypt26").value = encrypted1;
  }
}

function bpsRootFileDecrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt26").value;

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '') {
  var decrypted1 = encryption.decrypt(CCString1, nonceValue);
  }
  //console.log(decrypted1);
  
  if (CCString1 != '') {
  document.getElementById("crypt26").value = decrypted1;
  }
}
/* ]]> */
</script>     
</div>

<div id="bps-edittabs-8" class="bps-edittabs-page-class">
<form name="template8" id="template8" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-6' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_save_settings_8'); 
	$current_wpadmin_htaccess_file = ABSPATH . 'wp-admin/.htaccess';
?>
	<div>
    <textarea id="crypt27" class="bps-text-area-600x700" name="newcontent8" id="newcontent8" tabindex="8"><?php echo bps_get_current_wpadmin_htaccess_file(); ?></textarea>
	<input type="hidden" name="action" value="update" />
    <input type="hidden" name="filename" value="<?php echo esc_attr($current_wpadmin_htaccess_file) ?>" />
	<input type="hidden" name="scrollto8" id="scrollto8" value="<?php echo esc_html( $scrollto8 ); ?>" />
    <p class="submit">

	<?php echo '<div id="bps-edittabs-tooltip" style="margin:-40px 0px 10px 0px"><label for="bps-mscan-label" style="">'.__('If you see an error or are unable to save your editing changes then click the Encrypt htaccess Code button first and then click the Update File button. Mouse over the question mark image to the right for help info.', 'bulletproof-security').'</label><strong><font color="black"><span class="tooltip-350-225"><img src="'.plugins_url('/bulletproof-security/admin/images/question-mark.png').'" style="position:relative;top:3px;left:5px;" /><span>'.__('If your web host currently has ModSecurity installed or installs ModSecurity at a later time then ModSecurity will prevent you from saving your htaccess code unless you encrypt it first by clicking the Encrypt htaccess Code button.', 'bulletproof-security').'<br><br>'.__('If you click the Encrypt htaccess Code button and then want to edit your code again click the Decrypt htaccess Code button. After you are done editing click the Encrypt htaccess Code button before clicking the Update File button.', 'bulletproof-security').'<br><br>'.__('Click the htaccess File Editing Read Me help button for more help info.', 'bulletproof-security').'</span></span></font></strong></div>'; ?>

	<input type="submit" name="submit8" class="button bps-button" value="<?php esc_attr_e('Update File', 'bulletproof-security') ?>" /></p>
</div>
</form>

	<button onclick="bpsWpadminFileEncrypt()" class="button bps-button"><?php esc_attr_e('Encrypt htaccess Code', 'bulletproof-security'); ?></button> 
	<button onclick="bpsWpadminFileDecrypt()" class="button bps-button"><?php esc_attr_e('Decrypt htaccess Code', 'bulletproof-security'); ?></button>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
	$('#template8').submit(function(){ $('#scrollto8').val( $('#newcontent8').scrollTop() ); });
	$('#newcontent8').scrollTop( $('#scrollto8').val() );
});

function bpsWpadminFileEncrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt27").value;
  
  // Prevent Double, Triple, etc. encryption
  // The includes() method is not supported in IE 11 (and earlier versions)
  var NoEncrypt1 = CCString1.includes("eyJjaXBoZXJ0ZXh0Ijoi");
  //console.log(NoEncrypt1);

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '' && NoEncrypt1 === false) {
  var encrypted1 = encryption.encrypt(CCString1, nonceValue);
  }
  //console.log(encrypted1); 
  
  if (CCString1 != '' && NoEncrypt1 === false) {
  document.getElementById("crypt27").value = encrypted1;
  }
}

function bpsWpadminFileDecrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt27").value;

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '') {
  var decrypted1 = encryption.decrypt(CCString1, nonceValue);
  }
  //console.log(decrypted1);
  
  if (CCString1 != '') {
  document.getElementById("crypt27").value = decrypted1;
  }
}
/* ]]> */
</script>     
</div>
</div>

</td>
  </tr>
</table>
<?php } // if current user can ?>

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

<div id="bps-tabs-7" 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('htaccess File Custom Code ~ ', 'bulletproof-security'); ?><span style="font-size:.75em;"><?php _e('Save custom htaccess code for your Root, wp-admin & UAEG htaccess Files permanently', 'bulletproof-security'); ?> <br /> <span class="cc-read-me-text"><?php _e('* Click the Read Me help button for Custom Code Setup Steps', 'bulletproof-security'); ?></span></span></h2></td>
  </tr>
  <tr>
    <td class="bps-table_cell_help">

<h3 style="margin:0px 0px 5px 0px;"><?php _e('Custom Code', 'bulletproof-security'); ?>  <button id="bps-open-modal10" class="button bps-modal-button"><?php _e('Read Me', 'bulletproof-security'); ?></button></h3>

<div id="bps-modal-content10" class="bps-dialog-hide" title="<?php _e('Custom Code', '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/protect-login-page-from-brute-force-login-attacks/" title="Brute Force Login Page Protection code" target="_blank"><?php _e('Brute Force Login Page Protection code', 'bulletproof-security'); ?></a></strong><br /><br />

	<?php echo $bps_customcode_content; ?>
    
    </p>
</div>

<table width="100%" border="0">
  <tr>
    <td style="width:400px;">
    
<div id="CC-Help-Links">
<h3><?php $text = '<strong><a href="https://forum.ait-pro.com/video-tutorials/" target="_blank" title="Link opens in a new Browser window">'.__('Custom Code Video Tutorial', 'bulletproof-security').'</a></strong>'; echo $text; ?></h3>
<h3><?php $text = '<strong><a href="https://forum.ait-pro.com/read-me-first/" target="_blank" title="Link opens in a new Browser window">'.__('BulletProof Security Pro Forum', 'bulletproof-security').'</a></strong>'; echo $text; ?></h3>
</div>
    
    </td>
    <td>

<?php
if ( ! current_user_can('manage_options') ) { 
	_e('Permission Denied', 'bulletproof-security'); 
	
	} else { 
	
	require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/core/core-export-import.php' );
}
?>

<div id="CC-Import">
<form name="bpsImport" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-7' ); ?>" method="post" enctype="multipart/form-data">
	<?php wp_nonce_field('bulletproof_security_cc_import'); ?>
	<input type="file" name="bps_cc_import" id="bps_cc_import" />
	<input type="submit" name="Submit-CC-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 all of your Root and wp-admin Custom Code from the cc-master.zip file on your computer.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Import Custom Code or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	<?php bpsPro_CC_Import(); ?>
</form>
</div>

<div id="CC-Export">
<form name="bpsExport" id="bpsExport" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-7' ); ?>" method="post">
	<?php wp_nonce_field('bulletproof_security_cc_export'); ?>
    <input type="submit" name="Submit-CC-Export" class="button bps-button" value="<?php esc_attr_e('Export', 'bulletproof-security') ?>" onclick="return confirm('<?php 
$text = __('Clicking OK will Export (copy) all of your Root and wp-admin Custom Code into the cc-master.zip file, which you can then download to your computer by clicking the Download Zip Export button displayed in the Custom Code Export success message.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Export Custom Code or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	<?php bpsPro_CC_Export(); ?>
</form>
</div>

<div id="CC-Delete">
<form name="bpsDeleteCC" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-7' ); ?>" method="post">
	<?php wp_nonce_field('bulletproof_security_cc_delete'); ?>
	<input type="submit" name="Submit-CC-Delete" class="button bps-button" value="<?php esc_attr_e('Delete', 'bulletproof-security') ?>" onclick="return confirm('<?php $text = __('Clicking OK will delete all of your Root and wp-admin Custom Code from all of the Custom Code text boxes.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Delete Custom Code or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	<?php bpsPro_CC_Delete(); ?>
</form>
</div>

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

<?php 
if ( ! current_user_can('manage_options') ) { 
	_e('Permission Denied', 'bulletproof-security'); 
	
	} else { 

	require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/core/core-custom-code.php' );
}
?>

<br />

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

</div>

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

<?php if ( ! current_user_can('manage_options') ) { _e('Permission Denied', 'bulletproof-security'); } else { ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bps-help_faq_table">
  <tr>
    <td class="bps-table_title"><h2><?php _e('My Notes ~ ', 'bulletproof-security'); ?><span style="font-size:.75em;"><?php _e('Save Personal Notes and htaccess Code Notes to your WordPress Database', 'bulletproof-security'); ?></span></h2></td>
  </tr>
  <tr>
    <td class="bps-table_cell_help">
	
<?php 
// My Notes Form
function bpsPro_My_Notes_values_form() {
global $bps_topDiv, $bps_bottomDiv;

	if ( isset( $_POST['myNotes_submit'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_My_Notes' );
		
		$Encryption = new bpsProPHPEncryption();
		$nonceValue = 'ghbhnyxu';
		
		$pos = strpos( $_POST['bps_my_notes'], 'eyJjaXBoZXJ0ZXh0Ijoi' );

		if ( $pos === false ) {
			$bps_my_notes = stripslashes($_POST['bps_my_notes']);
		} else {
			$bps_my_notes = $Encryption->decrypt($_POST['bps_my_notes'], $nonceValue);
		}
		
		$MyNotes_Options = array( 'bps_my_notes' => $bps_my_notes );

		foreach( $MyNotes_Options as $key => $value ) {
			update_option('bulletproof_security_options_mynotes', $MyNotes_Options);
		}		
	
	echo $bps_topDiv;
	$text = '<strong><font color="green">'.__('Your My Notes Personal Notes and/or htaccess Code Notes saved successfully to your WordPress Database.', 'bulletproof-security').'</font></strong>';
	echo $text;		
	echo $bps_bottomDiv;	
	
	}
}	
	
	$scrolltoNotes = isset( $_REQUEST['scrolltoNotes'] ) ? (int) $_REQUEST['scrolltoNotes'] : 0; 
?>

<div id="my-notes-float" style="float:left">

	<button onclick="bpsMyNotesEncrypt()" class="button bps-button"><?php esc_attr_e('Encrypt My Notes', 'bulletproof-security'); ?></button> 
	<button onclick="bpsMyNotesDecrypt()" class="button bps-button" style="margin:0px 0px 10px 0px"><?php esc_attr_e('Decrypt My Notes', 'bulletproof-security'); ?></button>

<form name="myNotes" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/core/core.php#bps-tabs-8' ); ?>" method="post">
<?php 
	wp_nonce_field('bulletproof_security_My_Notes'); 
	bpsPro_My_Notes_values_form();
	$My_Notes_options = get_option('bulletproof_security_options_mynotes'); 
?>

	<textarea id="crypt20" class="bps-text-area-600x700" name="bps_my_notes" tabindex="1"><?php if ( ! empty( $My_Notes_options['bps_my_notes'] ) ) { echo $My_Notes_options['bps_my_notes']; } ?></textarea>
    <input type="hidden" name="scrolltoNotes" value="<?php echo esc_html( $scrolltoNotes ); ?>" />
	
	<?php echo '<div id="bps-my-notes-tooltip"><label for="bps-mscan-label" style="">'.__('If you are unable to save custom htaccess code and/or see an error message when trying to save custom htaccess code, ', 'bulletproof-security').'<br>'.__('click the Encrypt My Notes button first and then click the Save My Notes button.', 'bulletproof-security').'<br>'.__('Mouse over the question mark image to the right for help info.', 'bulletproof-security').'</label><strong><font color="black"><span class="tooltip-350-225"><img src="'.plugins_url('/bulletproof-security/admin/images/question-mark.png').'" style="position:relative;top:3px;left:5px;" /><span>'.__('If your web host currently has ModSecurity installed or installs ModSecurity at a later time then ModSecurity will prevent you from saving your custom htaccess code unless you encrypt it first by clicking the Encrypt My Notes button.', 'bulletproof-security').'<br><br>'.__('If you click the Encrypt My Notes button, but then want to add or edit additional custom code click the Decrypt My Notes button. After you are done adding or editing custom code click the Encrypt My Notes button before clicking the Save My Notes button.', 'bulletproof-security').'<br><br>'.__('Click the Custom Code Read Me help button for more help info.', 'bulletproof-security').'</span></span></font></strong></div>'; ?>

    <input type="submit" name="myNotes_submit" class="button bps-button" style="margin:10px 0px 10px 0px;height:auto;white-space:normal" value="<?php esc_attr_e('Save My Notes', 'bulletproof-security') ?>" />
</form>

	<button onclick="bpsMyNotesEncrypt()" class="button bps-button"><?php esc_attr_e('Encrypt My Notes', 'bulletproof-security'); ?></button> 
	<button onclick="bpsMyNotesDecrypt()" class="button bps-button"><?php esc_attr_e('Decrypt My Notes', 'bulletproof-security'); ?></button>

</div>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
	$('#myNotes').submit(function(){ $('#scrolltoNotes').val( $('#bps_my_notes').scrollTop() ); });
	$('#bps_my_notes').scrollTop( $('#scrolltoNotes').val() ); 
});

function bpsMyNotesEncrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt20").value;
  
  // Prevent Double, Triple, etc. encryption
  // The includes() method is not supported in IE 11 (and earlier versions)
  var NoEncrypt1 = CCString1.includes("eyJjaXBoZXJ0ZXh0Ijoi");
  //console.log(NoEncrypt1);

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '' && NoEncrypt1 === false) {
  var encrypted1 = encryption.encrypt(CCString1, nonceValue);
  }
  //console.log(encrypted); 
  
  if (CCString1 != '' && NoEncrypt1 === false) {
  document.getElementById("crypt20").value = encrypted1;
  }
}

function bpsMyNotesDecrypt() {

  var nonceValue = '<?php echo $bps_nonceValue; ?>';

  var CCString1 = document.getElementById("crypt20").value;

  let encryption = new bpsProJSEncryption();

  if (CCString1 != '') {
  var decrypted1 = encryption.decrypt(CCString1, nonceValue);
  }
  //console.log(decrypted);
  
  if (CCString1 != '') {
  document.getElementById("crypt20").value = decrypted1;
  }
}
/* ]]> */
</script>

</td>
  </tr>
</table>
<?php } ?>
</div>

<div id="bps-tabs-9" 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('Help & FAQ', 'bulletproof-security'); ?></h2></td>
  </tr>
  <tr>
    <td class="bps-table_cell_help_links">
    <a href="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/whatsnew/whatsnew.php' ); ?>" target="_blank"><?php _e('Whats New in ', 'bulletproof-security'); echo BULLETPROOF_VERSION; ?></a><br /><br />
    <a href="https://forum.ait-pro.com/forums/topic/bulletproof-security-pro-version-release-dates/" target="_blank"><?php _e('BPS Pro Features & Version Release Dates', 'bulletproof-security'); ?></a><br /><br />
    <a href="https://forum.ait-pro.com/forums/topic/plugin-conflicts-actively-blocked-plugins-plugin-compatibility/" target="_blank"><?php _e('Forum: Search, Troubleshooting Steps & Post Questions For Assistance', 'bulletproof-security'); ?></a><br /><br />
    <a href="https://forum.ait-pro.com/video-tutorials/" target="_blank"><?php _e('Custom Code Video Tutorial', 'bulletproof-security'); ?></a><br /><br />
    <a href="https://forum.ait-pro.com/video-tutorials/" target="_blank"><?php _e('Video Tutorials', 'bulletproof-security'); ?></a><br /><br />
    <a href="https://www.ait-pro.com/aitpro-blog/2304/wordpress-tips-tricks-fixes/permalinks-wordpress-custom-permalinks-wordpress-best-wordpress-permalinks-structure/" target="_blank"><?php _e('WP Permalinks - Custom Permalink Structure Help Info', 'bulletproof-security'); ?></a><br /><br />
    <a href="https://forum.ait-pro.com/forums/topic/plugin-firewall-read-me-first-troubleshooting/" target="_blank"><?php _e('Plugin Firewall Guide & Troubleshooting', 'bulletproof-security'); ?></a>
    </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>
</div>