<?php
#  ________         ____________      _____ ________                       ________      
#  ___  __ )____  _____  /___  /_____ __  /____  __ \______________ ______ ___  __/      
#  __  __  |_  / / /__  / __  / _  _ \_  __/__  /_/ /__  ___/_  __ \_  __ \__  /_        
#  _  /_/ / / /_/ / _  /  _  /  /  __// /_  _  ____/ _  /    / /_/ // /_/ /_  __/        
#  /_____/  \__,_/  /_/   /_/   \___/ \__/  /_/      /_/     \____/ \____/ /_/           
#  ________                             _____ _____              ________                
#  __  ___/_____ ___________  _____________(_)__  /______  __    ___  __ \______________ 
#  _____ \ _  _ \_  ___/_  / / /__  ___/__  / _  __/__  / / /    __  /_/ /__  ___/_  __ \
#  ____/ / /  __// /__  / /_/ / _  /    _  /  / /_  _  /_/ /     _  ____/ _  /    / /_/ /
#  /____/  \___/ \___/  \__,_/  /_/     /_/   \__/  _\__, /      /_/      /_/     \____/ 
#                                                   /____/                               
# 42756C6C657450726F6F66 5365637572697479 50726F 
#
if ( file_exists( dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/wp-load.php' ) ) {
require_once( '../../../../../wp-load.php' );
} elseif ( file_exists( dirname(__FILE__) . '/wp-load.php' ) ) {
require_once( dirname(__FILE__) . '/wp-load.php' );
} else {
echo '<strong><font color="#fb0101">ERROR: Unable to load the wp-load.php file</strong></font>';
}

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

// Get Real IP address - USE EXTREME CAUTION!!!
function bpsPro_get_real_ip_address_xtf() {
	
	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;
	}
}

?>

<style type="text/css">
<!--
body {font-family:"Open Sans", sans-serif;border:1px solid #000;font-size:13px;line-height:1.4em;background-color:#333333;}
#bps-xtf-container {background-color:#fafafa;}
h1 {padding:15px 0px 0px 10px;}
p {font-weight:bold;padding:0px 0px 0px 10px;}
label[for=xtf] {position:relative;top:-2px;left:0px;}
#xternal-background-top {background-image:url(../images/rescue.png);background-repeat:repeat-x;height:156px;border-bottom:1px solid #000;background-color:#fff;}
#xternal-authentication-form {font-weight:bold;padding:0px 0px 0px 10px;margin:-5px 0px 0px 0px;}
#xternal-lock-form {font-weight:bold;padding:0px 0px 0px 10px;margin:-5px 0px 0px 0px;}
#xternal-form-1 {font-weight:bold;padding:0px 0px 31px 10px;}
#xternal-form-2 {font-weight:bold;padding:0px 0px 0px 10px;}
.Xternal-Tools-Authentication-Table {font-size:13px;line-height:1.4em;text-align:left;}
.Xternal-Tools-Form-Table {font-size:13px;line-height:1.4em;text-align:left;}
#bpsMessage {text-align:center;background-color:#F7F8F9;border:5px solid #000000;padding:10px;}
-->
</style>

<div id="xternal-background-top">
<h1>BPS Pro Xternal Tools (XTF)</h1>
<p style="margin-top:0px;">
&bull; The Xternal Tools page has 2 layers of protection: Password Protection and the BPS Pro Plugin Firewall.<br />
&bull; The Xternal Tools Form can only be viewed/accessed/unlocked by entering your Database username and password.<br />
&bull; Email alerts are sent to you when the Unlock Xternal Tools Form and the Xternal Tools Form are submitted.<br />
&bull; After you are done using the BPS Pro Xternal Tools Form, click the Lock Xternal Tools Form button.<br />
&bull; Only your current IP address: <span style="background-color:#fafafa;color:green;border:1px solid #999;padding:0px 3px 0px 3px">
<?php echo bpsPro_get_real_ip_address_xtf(); ?></span> is allowed to view/access the Xternal Tools page.
</p>
</div>

<div id="bps-xtf-container">

<?php
## Automated Email Variables
$Email_Options = get_option('bulletproof_security_options_email');
$timeNow = time();
$gmt_offset = get_option( 'gmt_offset' ) * 3600;	
$timestamp = date_i18n(get_option('date_format'), strtotime("11/15-1976")) . ' - ' . date_i18n(get_option('time_format'), $timeNow + $gmt_offset);	
$justUrl = get_site_url();
$ip_address = esc_html( $_SERVER['REMOTE_ADDR'] );
$hostname = esc_html( @gethostbyaddr($_SERVER['REMOTE_ADDR'] ) );
$request_uri = esc_html( $_SERVER['REQUEST_URI'] );

$bps_email_to = $Email_Options['bps_send_email_to'];
$bps_email_from = $Email_Options['bps_send_email_from'];
$bps_email_cc = $Email_Options['bps_send_email_cc'];
$bps_email_bcc = $Email_Options['bps_send_email_bcc'];

$headers = array( 'Content-Type: text/html; charset=UTF-8', 'From: ' . $bps_email_from, 'Cc: ' . $bps_email_cc, 'Bcc: ' . $bps_email_bcc );

// Unlock the XTF Form
if ( isset( $_POST['Submit-Xternal-Tools-Authentication'] ) ) {
	
	$DBUser = $_POST['dbuser'];
	$DBPass = $_POST['dbpassword'];
	
	if ( $DBUser != DB_USER ) {
		$db_username_check = '<strong><font color="#fb0101">The Database Username is not valid/correct</font></strong>';
	}
	if ( $DBPass != DB_PASSWORD ) {
		$db_password_check = '<strong><font color="#fb0101">The Database Password is not valid/correct</font></strong>';		
	}

	if ( $DBUser == DB_USER && $DBPass == DB_PASSWORD ) {
		
		$db_username_check = '';
		$db_password_check = '';
		
		$XTF_Options = array( 'bps_xternal_tools_form' => 'unlocked', 'bps_xternal_tools_pfw' => '' );

		foreach( $XTF_Options as $key => $value ) {
			update_option('bulletproof_security_options_xternal_tools', $XTF_Options);
		}		
	}
	
	$subject = " BPS Pro Xternal Tools Alert: The Unlock Xternal Tools Form Was Submitted - $timestamp ";

	$message = '<p><font color="blue"><strong>The BPS Pro Unlock Xternal Tools Form has been submitted.</strong></font></p>';
	$message .=  '<p>This automated email is just a procedural safety alert and not a problem. This automated email is sent to you when the BPS Pro Unlock Xternal Tools Form is submitted whether or not the Xternal Tools Form was successfully unlocked or not.</p>';
	$message .= '<p><strong>IP Address:</strong> '.$ip_address.'</p>'; 
	$message .= '<p><strong>Hostname:</strong> '.$hostname.'</p>'; 
	$message .= '<p><strong>Request URI:</strong> '.$request_uri.'</p>'; 
	$message .= '<p><strong>Site:</strong> '.$justUrl.'</p>';

	wp_mail($bps_email_to, $subject, $message, $headers);
}

// Lock the XTF Form: 
if ( isset( $_POST['Submit-Xternal-Tools-Lock'] ) ) {
	
	$XTF_Options = array( 'bps_xternal_tools_form' => 'locked', 'bps_xternal_tools_pfw' => '' );

	foreach( $XTF_Options as $key => $value ) {
		update_option('bulletproof_security_options_xternal_tools', $XTF_Options);
	}		
}


$XTFoptions = get_option('bulletproof_security_options_xternal_tools');
	
// Display either the XTF Unlock or the XTF Lock Form
if ( ! $XTFoptions['bps_xternal_tools_form'] || $XTFoptions['bps_xternal_tools_form'] != 'unlocked' || $XTFoptions['bps_xternal_tools_form'] == '' ) {

?>

<div id="xternal-authentication-form">

<p style="margin-left:-10px;padding-top:10px;color:blue;">Enter your DB Username and Password from your wp-config.php file to view/access/unlock the BPS Pro Xternal Tools Form</p>

<form name="Xternal-Tools-Authentication-Form" action="xternal.php" method="post">

<table class="Xternal-Tools-Authentication-Table" width="40%" border="0">
<thead>
	<tr>
	<th scope="col" style="width:5%;"></th>
	<th scope="col" style="width:3%;"></th>
	<th scope="col" style="width:20%;"></th>
	</tr>
</thead>

<tbody>
	<tr>
	<th scope="row"><label for="XTF"><strong>DB Username: </strong></label></th>
	<td><input type="text" name="dbuser" value="" /></td>
    <td><?php echo $db_username_check; ?></td>
	</tr>
	<tr>
	<th scope="row"><label for="XTF"><strong>DB Password: </strong></label></th>
    <td><input type="password" name="dbpassword" value="" /></td>
    <td><?php echo $db_password_check; ?></td>
	</tr>
</tbody>
</table>

<input type="submit" name="Submit-Xternal-Tools-Authentication" style="margin:10px 0px 10px 0px;" value="<?php esc_attr_e('Unlock Xternal Tools Form', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Unlock the Xternal Tools Form or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
</form>

</div>

<?php } else { ?>

<div id="xternal-lock-form">

<p style="margin-left:-10px;color:blue;padding-top:10px;">After you are done using the BPS Pro Xternal Tools Form, click the Lock Xternal Tools Form button.</p>

<form action="xternal.php" method="post">   
	<input type="submit" name="Submit-Xternal-Tools-Lock" style="margin:0px 0px 0px 0px;" value="<?php esc_attr_e('Lock Xternal Tools Form', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Lock the Xternal Tools Form or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />  
</form>

</div>

<?php } ?>

<?php 
## Xternal Tools Form Start: do all form processing and XTF code below this point

$XTFoptions = get_option('bulletproof_security_options_xternal_tools');
	
if ( ! $XTFoptions['bps_xternal_tools_form'] || $XTFoptions['bps_xternal_tools_form'] == 'locked' || $XTFoptions['bps_xternal_tools_form'] == '' ) {
		return;
		
	} else {
	

		if ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) {

			// Turn Off|Deactivate utoRestore|Quarantine (ARQ)
			if ( $_POST['deactivate_arq'] == '1' ) {

				$xtf_form_options = 'Turn Off|Deactivate utoRestore|Quarantine (ARQ)<br>';
			
				$ARQoptions = get_option('bulletproof_security_options_ARCM');
		
				$BPS_ARQ_Options = array(
				'bps_autorestore_cron_frequency' 	=> $ARQoptions['bps_autorestore_cron_frequency'], 
				'bps_autorestore_cron' 				=> 'Off', 
				'bps_autorestore_cron_override' 	=> $ARQoptions['bps_autorestore_cron_override'], 
				'bps_autorestore_cron_forced' 		=> $ARQoptions['bps_autorestore_cron_forced'], 
				'bps_autorestore_cron_filecheck' 	=> $ARQoptions['bps_autorestore_cron_filecheck'], 
				'bps_autorestore_cron_end' 			=> $ARQoptions['bps_autorestore_cron_end']
				);	
						
				foreach( $BPS_ARQ_Options as $key => $value ) {
					update_option('bulletproof_security_options_ARCM', $BPS_ARQ_Options);
				}	
			}
	
			// Turn Off|Deactivate Login Security (LSM)
			if ( $_POST['deactivate_lsm'] == '1' ) {

				$xtf_form_options .= 'Turn Off|Deactivate Login Security (LSM)<br>';
			
				$LSMoptions = get_option('bulletproof_security_options_login_security');
		
				$BPS_LSM_Options = array(
				'bps_max_logins' 				=> $LSMoptions['bps_max_logins'], 
				'bps_lockout_duration' 			=> $LSMoptions['bps_lockout_duration'], 
				'bps_manual_lockout_duration' 	=> $LSMoptions['bps_manual_lockout_duration'], 
				'bps_max_db_rows_display' 		=> $LSMoptions['bps_max_db_rows_display'], 
				'bps_login_security_OnOff' 		=> 'Off', 
				'bps_login_security_logging' 	=> $LSMoptions['bps_login_security_logging'], 
				'bps_login_security_errors' 	=> $LSMoptions['bps_login_security_errors'], 
				'bps_login_security_remaining' 	=> $LSMoptions['bps_login_security_remaining'], 
				'bps_login_security_pw_reset' 	=> $LSMoptions['bps_login_security_pw_reset'],  
				'bps_login_security_sort' 		=> $LSMoptions['bps_login_security_sort'], 
				'bps_enable_lsm_woocommerce' 	=> $LSMoptions['bps_enable_lsm_woocommerce'] 
				);

				foreach( $BPS_LSM_Options as $key => $value ) {
					update_option('bulletproof_security_options_login_security', $BPS_LSM_Options);
				}
			}
	
			// Turn Off|Deactivate JTC Anti-Spam|Anti-Hacker (JTC)
			if ( $_POST['deactivate_jtc'] == '1' ) {

				$xtf_form_options .= 'Turn Off|Deactivate JTC Anti-Spam|Anti-Hacker (JTC)<br>';
				
				$JTCoptions = get_option('bulletproof_security_options_login_security_jtc');
		
				$BPS_JTC_Options = array(
				'bps_tooltip_captcha_key' 			=> $JTCoptions['bps_tooltip_captcha_key'], 
				'bps_tooltip_captcha_hover_text' 	=> $JTCoptions['bps_tooltip_captcha_hover_text'], 
				'bps_tooltip_captcha_title' 		=> $JTCoptions['bps_tooltip_captcha_title'], 
				'bps_tooltip_captcha_logging' 		=> $JTCoptions['bps_tooltip_captcha_logging'], 
				'bps_jtc_login_form' 				=> '', 
				'bps_jtc_register_form' 			=> '', 
				'bps_jtc_lostpassword_form' 		=> '', 
				'bps_jtc_comment_form' 				=> '', 
				'bps_jtc_mu_register_form' 			=> '', 
				'bps_jtc_buddypress_register_form' 	=> '', 
				'bps_jtc_buddypress_sidebar_form' 	=> '', 
				'bps_jtc_administrator' 			=> $JTCoptions['bps_jtc_administrator'], 
				'bps_jtc_editor' 					=> $JTCoptions['bps_jtc_editor'], 
				'bps_jtc_author' 					=> $JTCoptions['bps_jtc_author'], 
				'bps_jtc_contributor' 				=> $JTCoptions['bps_jtc_contributor'], 
				'bps_jtc_subscriber' 				=> $JTCoptions['bps_jtc_subscriber'], 
				'bps_jtc_comment_form_error' 		=> $JTCoptions['bps_jtc_comment_form_error'], 
				'bps_jtc_comment_form_label' 		=> $JTCoptions['bps_jtc_comment_form_label'], 
				'bps_jtc_comment_form_input' 		=> $JTCoptions['bps_jtc_comment_form_input'], 
				'bps_jtc_custom_roles' 				=> $JTCoptions['bps_jtc_custom_roles'], 
				'bps_enable_jtc_woocommerce' 		=> $JTCoptions['bps_enable_jtc_woocommerce'], 
				'bps_jtc_custom_form_error' 		=> $JTCoptions['bps_jtc_custom_form_error'] 
				);

				foreach( $BPS_JTC_Options as $key => $value ) {
					update_option('bulletproof_security_options_login_security_jtc', $BPS_JTC_Options);
				}				
			}

			// Turn Off|Deactivate Idle Session Logout (ISL)
			if ( $_POST['deactivate_isl'] == '1' ) {

				$xtf_form_options .= 'Turn Off|Deactivate Idle Session Logout (ISL)<br>';
				
				$ISLoptions = get_option('bulletproof_security_options_idle_session');
		
				$BPS_ISL_Options = array(
				'bps_isl' 							=> 'Off', 
				'bps_isl_timeout' 					=> $ISLoptions['bps_isl_timeout'], 
				'bps_isl_logout_url' 				=> $ISLoptions['bps_isl_logout_url'], 
				'bps_isl_login_url' 				=> $ISLoptions['bps_isl_login_url'], 
				'bps_isl_custom_message' 			=> $ISLoptions['bps_isl_custom_message'], 
				'bps_isl_custom_css_1' 				=> $ISLoptions['bps_isl_custom_css_1'], 
				'bps_isl_custom_css_2' 				=> $ISLoptions['bps_isl_custom_css_2'], 
				'bps_isl_custom_css_3' 				=> $ISLoptions['bps_isl_custom_css_3'], 
				'bps_isl_custom_css_4' 				=> $ISLoptions['bps_isl_custom_css_4'], 
				'bps_isl_user_account_exceptions'	=> $ISLoptions['bps_isl_user_account_exceptions'], 
				'bps_isl_administrator' 			=> $ISLoptions['bps_isl_administrator'], 
				'bps_isl_editor' 					=> $ISLoptions['bps_isl_editor'], 
				'bps_isl_author' 					=> $ISLoptions['bps_isl_author'], 
				'bps_isl_contributor' 				=> $ISLoptions['bps_isl_contributor'], 
				'bps_isl_subscriber' 				=> $ISLoptions['bps_isl_subscriber'], 
				'bps_isl_tinymce' 					=> $ISLoptions['bps_isl_tinymce'], 
				'bps_isl_uri_exclusions' 			=> $ISLoptions['bps_isl_uri_exclusions'], 
				'bps_isl_custom_roles' 				=> $ISLoptions['bps_isl_custom_roles'] 
				);

				foreach( $BPS_ISL_Options as $key => $value ) {
					update_option('bulletproof_security_options_idle_session', $BPS_ISL_Options);
				}				
			}

			// Turn Off|Deactivate Auth Cookie Expiration (ACE)
			if ( $_POST['deactivate_ace'] == '1' ) {

				$xtf_form_options .= 'Turn Off|Deactivate Auth Cookie Expiration (ACE)<br>';
				
				$ACEoptions = get_option('bulletproof_security_options_auth_cookie');
		
				$BPS_ACE_Options = array(
				'bps_ace' 							=> 'Off', 
				'bps_ace_expiration' 				=> $ACEoptions['bps_ace_expiration'], 
				'bps_ace_rememberme_expiration' 	=> $ACEoptions['bps_ace_rememberme_expiration'], 
				'bps_ace_user_account_exceptions'	=> $ACEoptions['bps_ace_user_account_exceptions'], 
				'bps_ace_administrator' 			=> $ACEoptions['bps_ace_administrator'], 
				'bps_ace_editor' 					=> $ACEoptions['bps_ace_editor'], 
				'bps_ace_author' 					=> $ACEoptions['bps_ace_author'], 
				'bps_ace_contributor' 				=> $ACEoptions['bps_ace_contributor'], 
				'bps_ace_subscriber' 				=> $ACEoptions['bps_ace_subscriber'], 
				'bps_ace_rememberme_disable' 		=> $ACEoptions['bps_ace_rememberme_disable'], 
				'bps_ace_custom_roles' 				=> $ACEoptions['bps_ace_custom_roles'] 	
				);

				foreach( $BPS_ACE_Options as $key => $value ) {
					update_option('bulletproof_security_options_auth_cookie', $BPS_ACE_Options);
				}				
			}

			// Turn Off|Deactivate the Plugin Firewall (PFW) & AutoPilot Mode
			if ( $_POST['deactivate_pfw'] == '1' ) {

				$xtf_form_options .= 'Turn Off|Deactivate the Plugin Firewall (PFW)<br>';
				
				$PluginsHtaccess = WP_PLUGIN_DIR . '/.htaccess';
				$PFWAP_options = get_option('bulletproof_security_options_pfw_autopilot');				

				if ( file_exists($PluginsHtaccess) ) {
					unlink($PluginsHtaccess);
				}
			
				if ( ! file_exists($PluginsHtaccess) ) {
					
					$XTF_Options = array( 
					'bps_xternal_tools_form' 	=> $XTFoptions['bps_xternal_tools_form'], 
					'bps_xternal_tools_pfw' 	=> '' 
					);	

					foreach( $XTF_Options as $key => $value ) {
						update_option('bulletproof_security_options_xternal_tools', $XTF_Options);
					}			
				
					wp_clear_scheduled_hook('bpsPro_PFWAP_check');

					$BPS_PFWAP_Options = array( 
					'bps_pfw_autopilot_cron' 			=> 'Off',  
					'bps_pfw_autopilot_cron_frequency' 	=> $PFWAP_options['bps_pfw_autopilot_cron_frequency'],  	
					'bps_pfw_autopilot_cron_end' 		=> $PFWAP_options['bps_pfw_autopilot_cron_end'] 
					);		
			
					foreach( $BPS_PFWAP_Options as $key => $value ) {
						update_option('bulletproof_security_options_pfw_autopilot', $BPS_PFWAP_Options);
					}				
				}
			}

			// Turn Off|Deactivate BackEnd Maintenance Mode (MMode)
			if ( $_POST['deactivate_mmode'] == '1' ) {

				$xtf_form_options .= 'Turn Off|Deactivate BackEnd Maintenance Mode (MMode)<br>';
				
				$wpadminHtaccess = ABSPATH . 'wp-admin/.htaccess';
				
				if ( file_exists($wpadminHtaccess) ) {
					unlink($wpadminHtaccess);
				}
			}

			// Turn Off|Unschedule All Cron Jobs
			if ( $_POST['unschedule_crons'] == '1' ) {

				$xtf_form_options .= 'Turn Off|Unschedule All Cron Jobs<br>';
				
				wp_clear_scheduled_hook('bpsPro_DBB_check');	
				wp_clear_scheduled_hook('bpsPro_php_elog_check');
				wp_clear_scheduled_hook('bpsPro_update_check');
				wp_clear_scheduled_hook('bpsPro_email_log_files');	
				wp_clear_scheduled_hook('bpsPro_PFWAP_check');	
				wp_clear_scheduled_hook('bpsPro_DBM_check');
				wp_clear_scheduled_hook('bpsPro_security_log_check');	
				wp_clear_scheduled_hook('bpsPro_AutoRestore_check');
				wp_clear_scheduled_hook('bpsPro_ARQ_OBFD');
				wp_clear_scheduled_hook('bpsPro_FolderLock_check');
				wp_clear_scheduled_hook('bpsPro_ARQ_Off_check');
				wp_clear_scheduled_hook('bpsPro_HPF_check');
				wp_clear_scheduled_hook('bpsPro_AFS_check');
				wp_clear_scheduled_hook('bpsPro_MScan_check');
				wp_clear_scheduled_hook('bpsPro_plugin_updates_cron');
				wp_clear_scheduled_hook('bpsPro_theme_updates_cron');
			}

			// Unlock All Locked Files
			if ( $_POST['flock_unlock'] == '1' ) {

				$xtf_form_options .= 'Unlock All Locked Files<br>';
				$Flockoptions = get_option('bulletproof_security_options_flock');
	
				$flock_RootHtaccess = ABSPATH . '.htaccess';
				$flock_wpconfig = ABSPATH . 'wp-config.php';
				$flock_index = ABSPATH . 'index.php';
				$flock_wpblogheader = ABSPATH . 'wp-blog-header.php';
				$flock_RootHtaccess_DR = $_SERVER['DOCUMENT_ROOT'] . '/.htaccess';
				$flock_index_DR = $_SERVER['DOCUMENT_ROOT'] . '/index.php';
				$flock_RootHtaccess_GWIOD = dirname(ABSPATH) . '/.htaccess';
				$flock_index_GWIOD = dirname(ABSPATH) . '/index.php';
				
				if ( $Flockoptions['bps_lock_root_htaccess'] == 'yes' ) { 	
					if ( file_exists($flock_RootHtaccess) ) {
						@chmod($flock_RootHtaccess, 0644);
					}
				}				
				
				if ( $Flockoptions['bps_lock_wpconfig'] == 'yes' ) { 	
					if ( file_exists($flock_wpconfig) ) {
						@chmod($flock_wpconfig, 0644);
					}
				}			
				
				if ( $Flockoptions['bps_lock_index_php'] == 'yes' ) { 	
					if ( file_exists($flock_index) ) {
						@chmod($flock_index, 0644);
					}
				}
				
				if ( $Flockoptions['bps_lock_wpblog_header'] == 'yes' ) { 	
					if ( file_exists($flock_wpblogheader) ) {
						@chmod($flock_wpblogheader, 0644);
					}
				}			
				
				if ( $Flockoptions['bps_lock_root_htaccess_dr'] == 'yes' ) { 	
					if ( file_exists($flock_RootHtaccess_DR) ) {
						@chmod($flock_RootHtaccess_DR, 0644);
					}
				}

				if ( $Flockoptions['bps_lock_index_php_dr'] == 'yes' ) { 	
					if ( file_exists($flock_index_DR) ) {
						@chmod($flock_index_DR, 0644);
					}
				}

				if ( $Flockoptions['bps_lock_root_htaccess_gwiod'] == 'yes' ) { 	
					if ( file_exists($flock_RootHtaccess_GWIOD) ) {
						@chmod($flock_RootHtaccess_GWIOD, 0644);
					}
				}			
				
				if ( $Flockoptions['bps_lock_index_php_gwiod'] == 'yes' ) { 	
					if ( file_exists($flock_index_GWIOD) ) {
						@chmod($flock_index_GWIOD, 0644);
					}
				}				
			}
			
			// Restore All Files in Quarantine
			if ( $_POST['quarantine_restore'] == '1' ) {
				
				$xtf_form_options .= 'Restore All Files in Quarantine<br>';
				$Quarantine = $wpdb->prefix . "bpspro_arq_quarantine";	

				$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

				/* check connection */
				if ( mysqli_connect_errno() ) {
    				printf("Connect failed: %s\n", mysqli_connect_error());
				}

				$query = "SELECT * FROM $Quarantine WHERE arq_quarantine_qpath LIKE '%/quarantine/%'";	
	
				if ( $result = $mysqli->query($query) ) {

					/* fetch associative array, restore files & delete Quarantine DB Rows */
    				while ( $row = $result->fetch_assoc() ) {
					
						$delete_row = "DELETE FROM $Quarantine WHERE arq_quarantine_qpath LIKE '%/quarantine/%'";
						
						// copy files from quarantine folder to autorestore backup folder
						if ( copy($row["arq_quarantine_qpath"], $row["arq_quarantine_backup"]) ) {				
						
							// copy files from quarantine back to the orginal source path/location
							if ( rename($row["arq_quarantine_qpath"], $row["arq_quarantine_source"]) ) {	
						
								if ( $mysqli->query($delete_row) ) {       
									echo '<div style="padding-left:10px;"><strong><font color="green">File: ';
									printf ("%s", $row["arq_quarantine_source"]);
    								echo '</font><font color="green"> Restored Successfully.</font></strong><br></div>';
								}
							}
						}
					}
				$result->free();
				}
			$mysqli->close();				
			}
			
			// Delete All Files in Quarantine
			if ( $_POST['quarantine_delete'] == '1' ) {
				
				$xtf_form_options .= 'Delete All Files in Quarantine<br>';				
				$Quarantine = $wpdb->prefix . "bpspro_arq_quarantine";	

				$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

				/* check connection */
				if ( mysqli_connect_errno() ) {
    				printf("Connect failed: %s\n", mysqli_connect_error());
 				}

				$query = "SELECT * FROM $Quarantine WHERE arq_quarantine_qpath LIKE '%/quarantine/%'";	
	
				if ( $result = $mysqli->query($query) ) {

					/* fetch associative array, delete files in quarantine & delete Quarantine DB Rows */
    				while ( $row = $result->fetch_assoc() ) {
					
						$delete_query = "DELETE FROM $Quarantine WHERE arq_quarantine_qpath LIKE '%/quarantine/%'";
		
						// delete all files in the quarantine folder
						if ( unlink($row["arq_quarantine_qpath"]) ) {
		
							if ( $mysqli->query($delete_query) ) {       
								echo '<div style="padding-left:10px;"><strong><font color="green">File: ';
								printf ("%s", $row["arq_quarantine_qpath"]);
    							echo '</font><font color="green"> Deleted Successfully.</font></strong><br></div>';
							}
						}
					}
				$result->free();
				}
			$mysqli->close();				
			}

			// Turn Off|Deactivate Root BulletProof Mode (RBM)
			// 10.9/11: delete the auto_.htaccess file
			if ( $_POST['deactivate_rbm'] == '1' ) {

				$xtf_form_options .= 'Turn Off|Deactivate Root BulletProof Mode (RBM)<br>';
				$RootHtaccess = ABSPATH . '.htaccess';
				$RootHtaccessARQ = WP_CONTENT_DIR . '/bps-backup/autorestore/root-files/auto_.htaccess';				

				if ( file_exists($RootHtaccessARQ) ) {
					unlink($RootHtaccessARQ);
				}
				if ( file_exists($RootHtaccess) ) {
					unlink($RootHtaccess);
				}				
			}

			// Turn Off|Deactivate wp-admin BulletProof Mode (WBM)
			if ( $_POST['deactivate_wbm'] == '1' ) {

				$xtf_form_options .= 'Turn Off|Deactivate wp-admin BulletProof Mode (WBM)<br>';
				$wpadminHtaccess = ABSPATH . 'wp-admin/.htaccess';
				
				if ( file_exists($wpadminHtaccess) ) {
					unlink($wpadminHtaccess);
				}
			}

		$subject = " BPS Pro Xternal Tools Alert: The Xternal Tools Form Was Submitted - $timestamp ";

		$message = '<p><font color="blue"><strong>The BPS Pro Xternal Tools Form has been submitted.</strong></font></p>';
		$message .=  '<p>This automated email is just a procedural safety alert and not a problem. This automated email is sent to you when the BPS Pro Xternal Tools Form is submitted.</p>';
		$message .= '<p><strong>IP Address:</strong> '.$ip_address.'</p>'; 
		$message .= '<p><strong>Hostname:</strong> '.$hostname.'</p>'; 
		$message .= '<p><strong>Request URI:</strong> '.$request_uri.'</p>'; 
		$message .= '<p><strong>Site:</strong> '.$justUrl.'</p>';
		$message .= '<p><strong>XTF Form Options Submitted:</strong><br>'.$xtf_form_options.'</p>';

		wp_mail($bps_email_to, $subject, $message, $headers);		
		
		}

$deactivate_arq = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : ''; 
$deactivate_lsm = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : ''; 
$deactivate_jtc = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : '';
$deactivate_isl = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : '';
$deactivate_ace = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : '';
$deactivate_pfw = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : '';
$deactivate_mmode = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : '';
$unschedule_crons = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : '';
$flock_unlock = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : '';
$quarantine_restore = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : '';
$quarantine_delete = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : '';
$deactivate_rbm = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : '';
$deactivate_wbm = ( isset( $_POST['Submit-Xternal-Tools-Form'] ) ) ? $_POST['Submit-Xternal-Tools-Form'] : '';

$ARQoptions = get_option('bulletproof_security_options_ARCM');

	if ( $ARQoptions['bps_autorestore_cron'] == 'On' ) {
		$arq_status = 'On|Activated';
	} else {
		$arq_status = 'Off|Deactivated';		
	}

$LSMoptions = get_option('bulletproof_security_options_login_security'); 

	if ( $LSMoptions['bps_login_security_OnOff'] == 'On' ) {
		$lsm_status = 'On|Activated';
	} else {
		$lsm_status = 'Off|Deactivated';		
	}		
		

$JTCoptions = get_option('bulletproof_security_options_login_security_jtc'); 
		
	if ( $JTCoptions['bps_jtc_login_form'] == '1' || $JTCoptions['bps_jtc_register_form'] == '1' || $JTCoptions['bps_jtc_lostpassword_form'] == '1' || $JTCoptions['bps_jtc_comment_form'] == '1' || $BPSoptionsJTC['bps_jtc_mu_register_form'] == '1' || $JTCoptions['bps_jtc_buddypress_register_form'] == '1' || $JTCoptions['bps_jtc_buddypress_sidebar_form'] == '1' ) {
		$jtc_status = 'On|Activated';
	}
	if ( $JTCoptions['bps_jtc_login_form'] != '1' && $JTCoptions['bps_jtc_register_form'] != '1' && $JTCoptions['bps_jtc_lostpassword_form'] != '1' && $JTCoptions['bps_jtc_comment_form'] != '1' && $BPSoptionsJTC['bps_jtc_mu_register_form'] != '1' && $JTCoptions['bps_jtc_buddypress_register_form'] != '1' && $JTCoptions['bps_jtc_buddypress_sidebar_form'] != '1' ) {
		$jtc_status = 'Off|Deactivated';
	}

$ISLoptions = get_option('bulletproof_security_options_idle_session'); 

	if ( $ISLoptions['bps_isl'] == 'On' ) {
		$isl_status = 'On|Activated';
	} else {
		$isl_status = 'Off|Deactivated';		
	}

$ACEoptions = get_option('bulletproof_security_options_auth_cookie'); 

	if ( $ACEoptions['bps_ace'] == 'On' ) {
		$ace_status = 'On|Activated';
	} else {
		$ace_status = 'Off|Deactivated';		
	}

	$PluginsHtaccess = WP_PLUGIN_DIR . '/.htaccess';
	if ( file_exists($PluginsHtaccess) ) {
		$pfw_status = 'On|Activated';		
	} else {
		$pfw_status = 'Off|Deactivated';
	}
	
	$wpadminHtaccess = ABSPATH . 'wp-admin/.htaccess';
	if ( file_exists($wpadminHtaccess) ) {
		$mmode_status = 'On|Activated';		
	} else {
		$mmode_status = 'Off|Deactivated';
	}

	if ( ! wp_next_scheduled( 'bpsPro_DBB_check' ) && ! wp_next_scheduled( 'bpsPro_php_elog_check' ) && ! wp_next_scheduled( 'bpsPro_update_check' ) && ! wp_next_scheduled( 'bpsPro_email_log_files' ) && ! wp_next_scheduled( 'bpsPro_PFWAP_check' ) && ! wp_next_scheduled( 'bpsPro_DBM_check' ) && ! wp_next_scheduled( 'bpsPro_security_log_check' ) && ! wp_next_scheduled( 'bpsPro_AutoRestore_check' ) ) {
		$cron_status = 'Off|Unscheduled';
	} else {
		$cron_status = 'On|Scheduled';		
	}

	// for Flock do not bother checking file permissions - just check db values
	$Flockoptions = get_option('bulletproof_security_options_flock');
	
	if ( $Flockoptions['bps_lock_root_htaccess'] == 'yes' || $Flockoptions['bps_lock_wpconfig'] == 'yes' || $Flockoptions['bps_lock_index_php'] == 'yes' || $Flockoptions['bps_lock_wpblog_header'] == 'yes' || $Flockoptions['bps_lock_root_htaccess_dr'] == 'yes' || $Flockoptions['bps_lock_index_php_dr'] == 'yes' || $Flockoptions['bps_lock_root_htaccess_gwiod'] == 'yes' || $Flockoptions['bps_lock_index_php_gwiod'] == 'yes' ) { 
		
		$flock_unlock_status = 'Locked';
	} else {
		$flock_unlock_status = 'Unlocked';		
	}

// for Quarantine both restore and delete status get the total number of files from the db option or zero
function bpsQDBRowCount_xternal() {
global $wpdb;
	$bpspro_Qtable = $wpdb->prefix . "bpspro_arq_quarantine";
	$id = '0';
	$DB_row_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $bpspro_Qtable WHERE id != %d", $id ) );
	$text = '<font color="blue"><strong>Total Files: ' . "{$DB_row_count}" . '</strong></font>';
	echo $text;	
}

	// for delete root htaccess file just check if it exists or not for the status
	// for wp-admin use the mmode status variable - same thing
	$RootHtaccess = ABSPATH . '.htaccess';
	if ( file_exists($RootHtaccess) ) {
		$root_htaccess_status = 'On|Activated';		
	} else {
		$root_htaccess_status = 'Off|Deactivated';
	}

	if ( ! function_exists('mysqli_connect') ) {
		$mysqli_check = '<font color="#fb0101"><strong>'.__('ERROR: The MySQLi Extension is NOT Installed|Enabled: ', 'bulletproof-security').'</strong></font>'.__('You cannot use the Restore and Delete All Files in Quarantine Form options.', 'bulletproof-security').'<br><br>';		
	} else {
		$mysqli_check = '';
	}

// Upload Zip Install Form: will only accept filename = bulletproof-security.zip
if ( isset( $_POST['Submit-XTF-bps-zip-install'] ) ) {
	
	$ARQoptions = get_option('bulletproof_security_options_ARCM');
	$bpsClassFile = WP_PLUGIN_DIR . '/bulletproof-security/includes/class.php';
	$bpsClassFile_contents = @file_get_contents($bpsClassFile);
	
	if ( file_exists($bpsClassFile) && ! preg_match( '/\s\'plugins\',\s/', $bpsClassFile_contents, $matches ) ) {
		
		$BPS_Options = array(
		'bps_autorestore_cron_frequency' 	=> $ARQoptions['bps_autorestore_cron_frequency'], 
		'bps_autorestore_cron' 				=> 'Off', 
		'bps_autorestore_cron_override' 	=> $ARQoptions['bps_autorestore_cron_override'], 
		'bps_autorestore_cron_filecheck' 	=> $ARQoptions['bps_autorestore_cron_filecheck'], 
		'bps_autorestore_cron_forced' 		=> $ARQoptions['bps_autorestore_cron_forced'], 
		'bps_autorestore_cron_end' 			=> $ARQoptions['bps_autorestore_cron_end']
		);	

		foreach( $BPS_Options as $key => $value ) {
			update_option('bulletproof_security_options_ARCM', $BPS_Options);
		}	
		
		$text = '<div style="padding:0px 0px 0px 10px;"><strong><font color="blue">'.__('AutoRestore has been turned Off', 'bulletproof-security').'</font><br>'.__(' After you log back into your website go to AutoRestore, click the wp-content Backup Files button before turning AutoRestore back On.', 'bulletproof-security').'</strong></div>';
		echo $text;	
	}

	$bpsZipFilename = 'bulletproof-security.zip';
	$bps_tmp_file = $_FILES['bps_file_zip']['tmp_name'];
	$zip_folder_path = WP_PLUGIN_DIR . '/';
	$bps_uploaded_zip = str_replace( '//', '/', $zip_folder_path) . $_FILES['bps_file_zip']['name'];
	$bpsZipzUploadFail = $_FILES['bps_file_zip']['name'];
		
	if ( ! empty($_FILES) ) {
	if ( $_FILES['bps_file_zip']['name'] == $bpsZipFilename ) {
		
		if ( move_uploaded_file($bps_tmp_file, $bps_uploaded_zip) ) {
		
			$text = '<div style="padding:0px 0px 0px 10px;"><strong><font color="green">'.__('Zip File Upload Successful.', 'bulletproof-security').'</font></strong></div>';
			echo $text;
		
			if ( class_exists('ZipArchive') ) {	

				$bpsZip = new ZipArchive;
	
				if ( $bpsZip->open( WP_PLUGIN_DIR . '/bulletproof-security.zip' ) === TRUE ) {
    				$bpsZip->extractTo( WP_PLUGIN_DIR . '/bulletproof-security/' );
    				$bpsZip->close();
    	
					$text = '<div style="padding:0px 0px 0px 10px;"><strong><font color="green">'.__('Zip File Installation Successful. Method: ZipArchive class.', 'bulletproof-security').'</font></strong></div>';
					echo $text;
	
					unlink( WP_PLUGIN_DIR . '/bulletproof-security.zip' );
	
					bpsPro_update_checks(); // installing an older BPS version zip file will send an upgrade email alert if option is selected/saved
	
				} else {
	
					$text = '<div style="padding:0px 0px 0px 10px;"><strong><font color="#fb0101">'.__('ERROR: Zip File Installation Failed. Method: ZipArchive class.', 'bulletproof-security').'</font></strong></div>';
					echo $text;
					
					unlink( WP_PLUGIN_DIR . '/bulletproof-security.zip' );  				
				}	
		
			} else { // Use PclZip if ZipArchive class is not installed
		
				// IMPORTANT: last modified date of files is not changed with PclZip
				define( 'PCLZIP_TEMPORARY_DIR', WP_PLUGIN_DIR . '/' );
				require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php');
	
				if ( ini_get( 'mbstring.func_overload' ) && function_exists( 'mb_internal_encoding' ) ) {
					$previous_encoding = mb_internal_encoding();
					mb_internal_encoding( 'ISO-8859-1' );
				}	

				$archive = new PclZip( WP_PLUGIN_DIR . '/bulletproof-security.zip' );
  		
				if ( $archive->extract( PCLZIP_OPT_PATH, WP_PLUGIN_DIR . '/bulletproof-security', PCLZIP_OPT_REMOVE_PATH, WP_PLUGIN_DIR . '/bulletproof-security' ) ) {
					
					$text = '<div style="padding:0px 0px 0px 10px;"><strong><font color="green">'.__('Zip File Installation Successful. Method: PclZip.', 'bulletproof-security').'</font></strong></div>';
					echo $text;
 				
					unlink( WP_PLUGIN_DIR . '/bulletproof-security.zip' );
					
					bpsPro_update_checks(); // installing an older BPS version zip file will send an upgrade email alert if option is selected/saved			
				
				} else {
					
					$text = '<div style="padding:0px 0px 0px 10px;"><strong><font color="#fb0101">'.__('ERROR: Zip File Installation Failed. Method: PclZip.', 'bulletproof-security').'</font></strong></div>';
					echo $text;
				
					unlink( WP_PLUGIN_DIR . '/bulletproof-security.zip' );
				}
			} // end if ( class_exists('ZipArchive') ) {		
		
		} else {
		
			$text = '<div style="padding:0px 0px 0px 10px;"><strong><font color="#fb0101">'.__('ERROR: Zip File Upload Failed.', 'bulletproof-security').'</font><br><font color="black">'.__('Either a bulletproof-security.zip file has not been selected yet for upload or the file ', 'bulletproof-security').$bpsZipzUploadFail.__(' is not a valid bulletproof-security.zip file or file name. The BPS Pro Upload Zip Installer only allows the bulletproof-security.zip file to be uploaded and installed.', 'bulletproof-security').'</font></strong></div>';
		echo $text;
		}
	}
	}
		
	$subject = " BPS Pro Xternal Tools Alert: The Reinstall BPS Pro plugin files Form Was Submitted - $timestamp ";

	$message = '<p><font color="blue"><strong>The BPS Pro Xternal Tools Reinstall BPS Pro plugin files Form has been submitted.</strong></font></p>';
	$message .=  '<p>This automated email is just a procedural safety alert and not a problem. This automated email is sent to you when the BPS Pro Xternal Tools Form is submitted.</p>';
	$message .= '<p><strong>IP Address:</strong> '.$ip_address.'</p>'; 
	$message .= '<p><strong>Hostname:</strong> '.$hostname.'</p>'; 
	$message .= '<p><strong>Request URI:</strong> '.$request_uri.'</p>'; 
	$message .= '<p><strong>Site:</strong> '.$justUrl.'</p>';
	//$message .= '<p><strong>XTF Form Options Submitted:</strong><br>'.$xtf_form_options.'</p>';

	wp_mail($bps_email_to, $subject, $message, $headers);	
}
?>

<div id="xternal-form-1">

<p style="margin-left:-10px"><span style="color:blue;">Intended Usage:</span> The BPS Pro Xternal Tools are intended to be used when you are unable to login to your website to fix an<br />issue/problem. Click this link: <a href="https://forum.ait-pro.com/forums/topic/xternal-tools-xtf-guide/" title="Link opens in a new Browser window" target="_blank" style="color:blue;">BPS Pro Xternal Tools Help</a> for additional help, troubleshooting and usage information.</p>

<?php echo $mysqli_check; ?>

<form name="Xternal-Tools-Form" action="xternal.php" method="post">

<table class="Xternal-Tools-Form-Table" width="40%" border="0">
<thead>
	<tr>
	<th scope="col">Xternal Tools Form Options</th>
	<th scope="col">Current Status</th>
	</tr>
</thead>

<tbody>
	<tr>
	<th scope="row"><input type="checkbox" name="deactivate_arq" value="1" <?php checked( $deactivate_arq, 1 ); ?> /><label for="xtf"><?php _e(' Turn Off|Deactivate AutoRestore|Quarantine (ARQ)', 'bulletproof-security'); ?></label></th>
	<td><?php echo '<font color="blue"><strong>'. $arq_status . '</strong></font>'; ?></td>
	</tr>
	<tr>
	<th scope="row"><input type="checkbox" name="deactivate_lsm" value="1" <?php checked( $deactivate_lsm, 1 ); ?> /><label for="xtf"><?php _e(' Turn Off|Deactivate Login Security (LSM)', 'bulletproof-security'); ?></label></th>
    <td><?php echo '<font color="blue"><strong>'. $lsm_status . '</strong></font>'; ?></td>
	</tr>
	<tr>
	<th scope="row"><input type="checkbox" name="deactivate_jtc" value="1" <?php checked( $deactivate_jtc, 1 ); ?> /><label for="xtf"><?php _e(' Turn Off|Deactivate JTC Anti-Spam|Anti-Hacker (JTC)', 'bulletproof-security');?></label></th>
	<td><?php echo '<font color="blue"><strong>'. $jtc_status . '</strong></font>'; ?></td>
	</tr>
	<tr>
	<th scope="row"><input type="checkbox" name="deactivate_isl" value="1" <?php checked( $deactivate_isl, 1 ); ?> /><label for="xtf"><?php _e(' Turn Off|Deactivate Idle Session Logout (ISL)', 'bulletproof-security'); ?></label></th>
    <td><?php echo '<font color="blue"><strong>'. $isl_status . '</strong></font>'; ?></td>
	</tr>
	<tr>
	<th scope="row"><input type="checkbox" name="deactivate_ace" value="1" <?php checked( $deactivate_ace, 1 ); ?> /><label for="xtf"><?php _e(' Turn Off|Deactivate Auth Cookie Expiration (ACE)', 'bulletproof-security');?></label></th>
	<td><?php echo '<font color="blue"><strong>'. $ace_status . '</strong></font>'; ?></td>
	</tr>
	<tr>
	<th scope="row"><input type="checkbox" name="deactivate_pfw" value="1" <?php checked( $deactivate_pfw, 1 ); ?> /><label for="xtf"><?php _e(' Turn Off|Deactivate the Plugin Firewall (PFW)', 'bulletproof-security'); ?></label></th>
    <td><?php echo '<font color="blue"><strong>'. $pfw_status . '</strong></font>'; ?></td>
	</tr>
	<tr>
	<th scope="row"><input type="checkbox" name="deactivate_mmode" value="1" <?php checked( $deactivate_mmode, 1 ); ?> /><label for="xtf"><?php _e(' Turn Off|Deactivate BackEnd Maintenance Mode (MMode)', 'bulletproof-security'); ?></label></th>
    <td><?php echo '<font color="blue"><strong>'. $mmode_status . '</strong></font>'; ?></td>
	</tr>
	<tr>
	<th scope="row"><input type="checkbox" name="unschedule_crons" value="1" <?php checked( $unschedule_crons, 1 ); ?> /><label for="xtf"><?php _e(' Turn Off|Unschedule All Cron Jobs', 'bulletproof-security'); ?></label></th>
    <td><?php echo '<font color="blue"><strong>'. $cron_status . '</strong></font>'; ?></td>
	</tr>
	<tr>
	<th scope="row"><input type="checkbox" name="flock_unlock" value="1" <?php checked( $flock_unlock, 1 ); ?> /><label for="xtf"><?php _e(' Unlock All Locked Files', 'bulletproof-security'); ?></label></th>
    <td><?php echo '<font color="blue"><strong>'. $flock_unlock_status . '</strong></font>'; ?></td>
	</tr>
	<tr>
	<th scope="row"><input type="checkbox" name="quarantine_restore" value="1" <?php checked( $quarantine_restore, 1 ); ?> /><label for="xtf"><?php _e(' Restore All Files in Quarantine', 'bulletproof-security'); ?></label></th>
    <td><div id="QCount" style="position:relative;top:12px;left:0px;"><?php echo bpsQDBRowCount_xternal(); ?></div></td>
	</tr>
	<tr>
	<th scope="row"><input type="checkbox" name="quarantine_delete" value="1" <?php checked( $quarantine_delete, 1 ); ?> /><label for="xtf"><?php _e(' Delete All Files in Quarantine', 'bulletproof-security'); ?></label></th>
    <td>&nbsp;</td>
	</tr>
	<tr>
	<th scope="row"><input type="checkbox" name="deactivate_rbm" value="1" <?php checked( $deactivate_rbm, 1 ); ?> /><label for="xtf"><?php _e(' Turn Off|Deactivate Root BulletProof Mode (RBM)', 'bulletproof-security'); ?></label></th>
    <td><?php echo '<font color="blue"><strong>'. $root_htaccess_status . '</strong></font>'; ?></td>
	</tr>
	<tr>
	<th scope="row"><input type="checkbox" name="deactivate_wbm" value="1" <?php checked( $deactivate_wbm, 1 ); ?> /><label for="xtf"><?php _e(' Turn Off|Deactivate wp-admin BulletProof Mode (WBM)', 'bulletproof-security'); ?></label></th>
    <td><?php echo '<font color="blue"><strong>'. $mmode_status . '</strong></font>'; ?></td>
	</tr>
</tbody>
</table>

<input type="submit" name="Submit-Xternal-Tools-Form" style="margin:10px 0px 0px 7px;" value="<?php esc_attr_e('Submit Xternal Tools Form', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to Submit the Xternal Tools Form or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
</form>

</div>

<div id="xternal-form-2" style="position:absolute;top:50%;left:45%;">

<p style="margin-left:-10px;margin-bottom:5px;"><span style="color:blue;">Reinstall BPS Pro plugin files:</span><br />&bull; ONLY installs the bulletproof-security.zip file.<br />&bull; The zip file MUST be named bulletproof-security.zip.<br />&bull; Installation Method: ZipArchive or PclZip.<br />&bull; Overwrites existing BPS Pro plugin files.<br />&bull; Does NOT change BPS Pro database settings.</p>

<form name="BPS-XTF-Zip-Installer" action="xternal.php" method="post" enctype="multipart/form-data">
	<input type="file" name="bps_file_zip" id="bps_file_zip"  />
	<input type="submit" name="Submit-XTF-bps-zip-install" style="margin:10px 0px 0px 0px;" value="<?php esc_attr_e('Install Zip Now', 'bulletproof-security'); ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Clicking OK to install the bulletproof-security.zip file or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
</form>

</div>

<?php } ## Xternal Tools Form End ?>
</div>
