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

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

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

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

<noscript><div id="message" class="updated" style="font-weight:600;font-size:13px;padding:5px;background-color:#dfecf2;border:1px solid #999;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><span style="color:blue">BPS Warning: JavaScript is disabled in your Browser</span><br />BPS plugin pages will not display visually correct and all BPS JavaScript functionality will not work correctly.</div></noscript>

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

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

		bpsPro_Browser_UA_scroll_animation();
	}
}
?>

<?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 (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();
?>

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

<?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>';
	}
}
$bpsSpacePop = '-------------------------------------------------------------';

// 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>';
$UIoptions = get_option('bulletproof_security_options_theme_skin');
// Replace ABSPATH = wp-content
$bps_wpcontent_dir = str_replace( ABSPATH, '', WP_CONTENT_DIR );

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

?>
</div>

<h2 class="bps-tab-title"><?php _e('BulletProof Security Pro ~ File Lock ~ Folder Lock', '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('File Lock', 'bulletproof-security'); ?></a></li>
			<li><a href="#bps-tabs-2"><?php _e('Folder Lock', 'bulletproof-security'); ?></a></li>
			<li><a href="#bps-tabs-3"><?php _e('Help &amp; FAQ', 'bulletproof-security'); ?></a></li>
		</ul>
            
<div id="bps-tabs-1" class="bps-tab-page">

<?php

// CGI Permissions and Status Table functions - Get file permissions and display status only if SAPI is CGI
function bps_flock_pro_statusRH() {
	clearstatcache();
	$file = ABSPATH . '.htaccess';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');	

	if ( $options['bps_lock_root_htaccess'] == 'off' ) { 	
		$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
		echo $text;
	} elseif ( $options['bps_lock_root_htaccess'] == 'yes' || $options['bps_lock_root_htaccess'] == 'no' || $options['bps_lock_root_htaccess'] == '' ) { 	
		
		if ( ! file_exists($file) ) {
			$text = '<font color="black"><strong>'.__('Site Root htaccess file does not exist.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} else {
			if ( $perms == '0404' ) {
				$text = '<font color="green"><strong>'.$perms.' - '.__('Locked - Read Only', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			} else {
				$text = '<font color="#fb0101"><strong>'.$perms.' - '.__('Unlocked or Not Locked', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			}
		}
	}
}

function bps_flock_pro_statusWPC() {
	clearstatcache();
	$file = ABSPATH . 'wp-config.php';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');	

	if ( $options['bps_lock_wpconfig'] == 'off' ) { 	
		$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
		echo $text;
	} elseif ( $options['bps_lock_wpconfig'] == 'yes' || $options['bps_lock_wpconfig'] == 'no' || $options['bps_lock_wpconfig'] == '' ) { 	
		
		if ( ! file_exists($file) ) {
			$text = '<font color="black"><strong>'.__('The wp-config.php file does not exist.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} else {	
			if ( $perms == '0400' ) {
				$text = '<font color="green"><strong>'.$perms.' - '.__('Locked - Read Only', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			} else {
				$text = '<font color="#fb0101"><strong>'.$perms.' - '.__('Unlocked or Not Locked', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			}
		}
	}
}

function bps_flock_pro_statusWPI() {
	clearstatcache();
	$file = ABSPATH . 'index.php';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');	

	if ( $options['bps_lock_index_php'] == 'off' ) { 	
		$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
		echo $text;
	} elseif ( $options['bps_lock_index_php'] == 'yes' || $options['bps_lock_index_php'] == 'no' ||$options['bps_lock_index_php'] == '' ) { 	
		
		if ( ! file_exists($file ) ) {
			$text = '<font color="black"><strong>'.__('The WP Site Root index.php file does not exist.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} else {		
			if ( $perms == '0400' ) { // had a value of 400. ?
				$text = '<font color="green"><strong>'.$perms.' - '.__('Locked - Read Only', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			} else {
				$text = '<font color="#fb0101"><strong>'.$perms.' - '.__('Unlocked or Not Locked', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			}
		}
	}
}

function bps_flock_pro_statusWPBH() {
	clearstatcache();
	$file = ABSPATH . 'wp-blog-header.php';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');	

	if ( $options['bps_lock_wpblog_header'] == 'off' ) { 	
		$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
		echo $text;
	} elseif ( $options['bps_lock_wpblog_header'] == 'yes' || $options['bps_lock_wpblog_header'] == 'no' || $options['bps_lock_wpblog_header'] == '' ) { 	
		
		if ( ! file_exists($file) ) {
			$text = '<font color="black"><strong>'.__('The wp-blog-header.php file does not exist.', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} else {
			if ( $perms == '0400' ) {
				$text = '<font color="green"><strong>'.$perms.' - '.__('Locked - Read Only', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			} else {
				$text = '<font color="#fb0101"><strong>'.$perms.' - '.__('Unlocked or Not Locked', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			}
		}
	}
}

function bps_flock_pro_statusRH_DR() {
	clearstatcache();
	$file = $_SERVER['DOCUMENT_ROOT'] . '/.htaccess';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');
	
	if ( $options['bps_lock_root_htaccess_dr'] == 'off' ) { 	
		$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
		echo $text;
	} elseif ( $options['bps_lock_root_htaccess_dr'] == 'yes' || $options['bps_lock_root_htaccess_dr'] == 'no' || $options['bps_lock_root_htaccess_dr'] == '' ) { 	
		
		if ( ! file_exists($file) ) {
			$text = '<font color="black"><strong>'.__('DR - Root htaccess file does not exist.', 'bulletproof-security').'</strong></font><br>';
			echo $text;	
		} else {
			if ( $perms == '0404' ) {
				$text = '<font color="green"><strong>'.$perms.' - '.__('Locked - Read Only', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			} else {
				$text = '<font color="#fb0101"><strong>'.$perms.' - '.__('Unlocked or Not Locked', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			}
		}
	}
}

function bps_flock_pro_statusWPI_DR() {
	clearstatcache();
	$file = $_SERVER['DOCUMENT_ROOT'] . '/index.php';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');	

	if ( $options['bps_lock_index_php_dr'] == 'off ') { 	
		$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
		echo $text;
	} elseif ( $options['bps_lock_index_php_dr'] == 'yes' || $options['bps_lock_index_php_dr'] == 'no' || $options['bps_lock_index_php_dr'] == '' ) { 	
		
		if ( ! file_exists($file) ) {
			$text = '<font color="black"><strong>'.__('DR - Root index.php file does not exist.', 'bulletproof-security').'</strong></font><br>';
			echo $text;	
		} else {
			if ( $perms == '0400' ) {
				$text = '<font color="green"><strong>'.$perms.' - '.__('Locked - Read Only', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			} else {
				$text = '<font color="#fb0101"><strong>'.$perms.' - '.__('Unlocked or Not Locked', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			}
		}
	}
}

function bps_flock_pro_statusRH_GWIOD() {
	clearstatcache();
	$file = dirname(ABSPATH) . '/.htaccess';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');
	
	if ( isset($options['bps_lock_root_htaccess_gwiod']) ) { 
	
		if ( $options['bps_lock_root_htaccess_gwiod'] == 'off' ) { 	
			$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} elseif ( $options['bps_lock_root_htaccess_gwiod'] == 'yes' || $options['bps_lock_root_htaccess_gwiod'] == 'no' || $options['bps_lock_root_htaccess_gwiod'] == '' ) { 	
			
			if ( ! file_exists($file) ) {
				$text = '<font color="black"><strong>'.__('GWIOD - Root htaccess file does not exist.', 'bulletproof-security').'</strong></font><br>';
				echo $text;	
			} else {
				if ( $perms == '0404' ) {
					$text = '<font color="green"><strong>'.$perms.' - '.__('Locked - Read Only', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				} else {
					$text = '<font color="#fb0101"><strong>'.$perms.' - '.__('Unlocked or Not Locked', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				}
			}
		}
	}
}

function bps_flock_pro_statusWPI_GWIOD() {
	clearstatcache();
	$file = dirname(ABSPATH) . '/index.php';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');
	
	if ( isset($options['bps_lock_index_php_gwiod']) ) { 

		if ( $options['bps_lock_index_php_gwiod'] == 'off' ) { 	
			$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} elseif ( $options['bps_lock_index_php_gwiod'] == 'yes' || $options['bps_lock_index_php_gwiod'] == 'no' || $options['bps_lock_index_php_gwiod'] == '' ) { 	
			
			if ( ! file_exists($file) ) {
				$text = '<font color="black"><strong>'.__('GWIOD - Root index.php file does not exist.', 'bulletproof-security').'</strong></font><br>';
				echo $text;		
			} else {
				if ( $perms == '0400' ) {
					$text = '<font color="green"><strong>'.$perms.' - '.__('Locked - Read Only', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				} else {
					$text = '<font color="#fb0101"><strong>'.$perms.' - '.__('Unlocked or Not Locked', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				}
			}
		}
	}
}

// DSO Permissions and Status Table functions - displays only if DSO SAPI is detected
function bps_flock_pro_statusRH_DSO() {
	clearstatcache();
	$file = ABSPATH . '.htaccess';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');	

	if ( isset($options['bps_lock_root_htaccess']) ) { 

		if ( $options['bps_lock_root_htaccess'] == 'off' ) { 	
			$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} elseif ( $options['bps_lock_root_htaccess'] == 'yes' || $options['bps_lock_root_htaccess'] == 'no' || $options['bps_lock_root_htaccess'] == '' ) { 	
			
			if ( ! file_exists($file) ) {
				$text = '<font color="black"><strong>'.__('Site Root htaccess file does not exist.', 'bulletproof-security').'</strong></font><br>';
				echo $text;			
			} else {
				if ( $perms == '0644' ) {
					$text = '<font color="green"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				} else {
					$text = '<font color="#fb0101"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;	
				}
			}
		}
	}
}

function bps_flock_pro_statusWPC_DSO() {
	clearstatcache();
	$file = ABSPATH . 'wp-config.php';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');	

	if ( isset($options['bps_lock_wpconfig']) ) { 

		if ( $options['bps_lock_wpconfig'] == 'off' ) { 	
			$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} elseif ( $options['bps_lock_wpconfig'] == 'yes' || $options['bps_lock_wpconfig'] == 'no' || $options['bps_lock_wpconfig'] == '' ) { 	
			
			if ( ! file_exists($file) ) {
				$text = '<font color="black"><strong>'.__('The wp-config.php file does not exist.', 'bulletproof-security').'</strong></font><br>';
				echo $text;	
			} else {		
				if ( $perms == '0644' ) {
					$text = '<font color="green"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				} else {
					$text = '<font color="#fb0101"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;	
				}
			}
		}
	}
}

function bps_flock_pro_statusWPI_DSO() {
	clearstatcache();
	$file = ABSPATH . 'index.php';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');	

	if ( isset($options['bps_lock_index_php']) ) { 

		if ( $options['bps_lock_index_php'] == 'off' ) { 	
			$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} elseif ( $options['bps_lock_index_php'] == 'yes' || $options['bps_lock_index_php'] == 'no' || $options['bps_lock_index_php'] == '' ) { 	
			
			if ( ! file_exists($file) ) {
				$text = '<font color="black"><strong>'.__('The WP Site Root index.php file does not exist.', 'bulletproof-security').'</strong></font><br>';
				echo $text;	
			} else {	
				if ( $perms == '0644' ) {
					$text = '<font color="green"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				} else {
					$text = '<font color="#fb0101"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;	
				}
			}
		}
	}
}

function bps_flock_pro_statusWPBH_DSO() {
	clearstatcache();
	$file = ABSPATH . 'wp-blog-header.php';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');	

	if ( isset($options['bps_lock_wpblog_header']) ) { 

		if ( $options['bps_lock_wpblog_header'] == 'off' ) { 	
			$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} elseif ( $options['bps_lock_wpblog_header'] == 'yes' || $options['bps_lock_wpblog_header'] == 'no' || $options['bps_lock_wpblog_header'] == '' ) { 	
			
			if ( ! file_exists($file) ) {
				$text = '<font color="black"><strong>'.__('The wp-blog-header.php file does not exist.', 'bulletproof-security').'</strong></font><br>';
				echo $text;		
			} else {
				if ( $perms == '0644' ) {
					$text = '<font color="green"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				} else {
					$text = '<font color="#fb0101"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;	
				}
			}
		}
	}
}

function bps_flock_pro_statusRH_DR_DSO() {
	clearstatcache();
	$file = $_SERVER['DOCUMENT_ROOT'] . '/.htaccess';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');
	
	if ( isset($options['bps_lock_root_htaccess_dr']) ) { 

		if ( $options['bps_lock_root_htaccess_dr'] == 'off' ) { 	
			$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} elseif ( $options['bps_lock_root_htaccess_dr'] == 'yes' || $options['bps_lock_root_htaccess_dr'] == 'no' || $options['bps_lock_root_htaccess_dr'] == '' ) { 	
			
			if ( ! file_exists($file) ) {
				$text = '<font color="black"><strong>'.__('DR - Root htaccess file does not exist.', 'bulletproof-security').'</strong></font><br>';
				echo $text;			
			} else {
				if ( $perms == '0644' ) {
					$text = '<font color="green"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				} else {
					$text = '<font color="#fb0101"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;	
				}
			}
		}
	}
}

function bps_flock_pro_statusWPI_DR_DSO() {
	clearstatcache();
	$file = $_SERVER['DOCUMENT_ROOT'] . '/index.php';
	$perms = @substr(sprintf('%o', fileperms($file)), -4);
	$options = get_option('bulletproof_security_options_flock');	

	if ( isset($options['bps_lock_index_php_dr']) ) { 

		if ( $options['bps_lock_index_php_dr'] == 'off' ) { 	
			$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} elseif ( $options['bps_lock_index_php_dr'] == 'yes' || $options['bps_lock_index_php_dr'] == 'no' || $options['bps_lock_index_php_dr'] == '' ) { 	
			
			if ( ! file_exists($file) ) {
				$text = '<font color="black"><strong>'.__('DR - Root index.php file does not exist.', 'bulletproof-security').'</strong></font><br>';
				echo $text;
			} else {
				if ( $perms == '0644' ) {
					$text = '<font color="green"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				} else {
					$text = '<font color="#fb0101"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				}
			}
		}
	}
}

function bps_flock_pro_statusRH_GWIOD_DSO() {
	clearstatcache();
	$file = dirname(ABSPATH) . '/.htaccess';

	if ( file_exists($file) ) {
		$perms = substr(sprintf('%o', fileperms($file)), -4);
	} else {
		$perms = '';
	}

	$options = get_option('bulletproof_security_options_flock');
	
	if ( isset($options['bps_lock_root_htaccess_gwiod']) ) { 

		if ( $options['bps_lock_root_htaccess_gwiod'] == 'off' ) { 	
			$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} elseif ( $options['bps_lock_root_htaccess_gwiod'] == 'yes' || $options['bps_lock_root_htaccess_gwiod'] == 'no' || $options['bps_lock_root_htaccess_gwiod'] == '' ) { 	
			
			if ( ! file_exists($file) ) {
				$text = '<font color="black"><strong>'.__('GWIOD - Root htaccess file does not exist.', 'bulletproof-security').'</strong></font><br>';
				echo $text;	
			} else {
				if ( $perms == '0644' ) {
					$text = '<font color="green"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				} else {
					$text = '<font color="#fb0101"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text; 
				}
			}
		}
	}
}

function bps_flock_pro_statusWPI_GWIOD_DSO() {
	clearstatcache();
	$file = dirname(ABSPATH) . '/index.php';

	if ( file_exists($file) ) {
		$perms = substr(sprintf('%o', fileperms($file)), -4);
	} else {
		$perms = '';
	}

	$options = get_option('bulletproof_security_options_flock');
	
	if ( isset($options['bps_lock_index_php_gwiod']) ) {

		if ( $options['bps_lock_index_php_gwiod'] == 'off' ) { 	
			$text = '<font color="black"><strong>'.__('Turned Off', 'bulletproof-security').'</strong></font><br>';
			echo $text;
		} elseif ( $options['bps_lock_index_php_gwiod'] == 'yes' || $options['bps_lock_index_php_gwiod'] == 'no' || $options['bps_lock_index_php_gwiod'] == '' ) { 	
			
			if ( ! file_exists($file) ) {
				$text = '<font color="black"><strong>'.__('GWIOD - Root index.php file does not exist.', 'bulletproof-security').'</strong></font><br>';
				echo $text;	
			} else {
				if ( $perms == '0644' ) {
					$text = '<font color="green"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				} else {
					$text = '<font color="#fb0101"><strong>'.__('DSO - ', 'bulletproof-security').$perms.__(' File Permissions', 'bulletproof-security').'</strong></font><br>';
					echo $text;
				}
			}
		}
	}
}

// CGI and DSO File Permissions and Status Tables - File Last Modified Time
function bps_flock_modTimeRH() {
$gmt_offset = get_option( 'gmt_offset' ) * 3600;
$file = ABSPATH . '.htaccess';
	
	if ( file_exists($file) ) {
		$last_modified = date_i18n( get_option('date_format'), filemtime($file) + $gmt_offset) . ' ' . date_i18n(get_option('time_format'), filemtime($file) + $gmt_offset);	
	return $last_modified;
	}
}
function bps_flock_modTimeWPC() {
$gmt_offset = get_option( 'gmt_offset' ) * 3600;
$file = ABSPATH . 'wp-config.php';
	
	if ( file_exists($file) ) {
		$last_modified = date_i18n( get_option('date_format'), filemtime($file) + $gmt_offset) . ' ' . date_i18n(get_option('time_format'), filemtime($file) + $gmt_offset);
	return $last_modified;
	}
}
function bps_flock_modTimeWPI() {
$gmt_offset = get_option( 'gmt_offset' ) * 3600;
$file = ABSPATH . 'index.php';
	
	if ( file_exists($file) ) {
		$last_modified = date_i18n( get_option('date_format'), filemtime($file) + $gmt_offset) . ' ' . date_i18n(get_option('time_format'), filemtime($file) + $gmt_offset);
	return $last_modified;
	}
}
function bps_flock_modTimeWPBH() {
$gmt_offset = get_option( 'gmt_offset' ) * 3600;
$file = ABSPATH . 'wp-blog-header.php';
	
	if ( file_exists($file) ) {
		$last_modified = date_i18n( get_option('date_format'), filemtime($file) + $gmt_offset) . ' ' . date_i18n(get_option('time_format'), filemtime($file) + $gmt_offset);
	return $last_modified;
	}
}
function bps_flock_modTimeRH_DR() {
$gmt_offset = get_option( 'gmt_offset' ) * 3600;
$file = $_SERVER['DOCUMENT_ROOT'] . '/.htaccess';
	
	if ( file_exists($file) ) {
		$last_modified = date_i18n( get_option('date_format'), filemtime($file) + $gmt_offset) . ' ' . date_i18n(get_option('time_format'), filemtime($file) + $gmt_offset);
	return $last_modified;
	}
}
function bps_flock_modTimeWPI_DR() {
$gmt_offset = get_option( 'gmt_offset' ) * 3600;
$file = $_SERVER['DOCUMENT_ROOT'] . '/index.php';
	
	if ( file_exists($file) ) {
		$last_modified = date_i18n( get_option('date_format'), filemtime($file) + $gmt_offset) . ' ' . date_i18n(get_option('time_format'), filemtime($file) + $gmt_offset);
	return $last_modified;
	}
}
function bps_flock_modTimeRH_GWIOD() {
$gmt_offset = get_option( 'gmt_offset' ) * 3600;
$file = dirname(ABSPATH) . '/.htaccess';
$open_basedir = ini_get('open_basedir');
	
	# Quick Fix: do more with this later
	if ( $open_basedir == '' ) {

		if ( file_exists($file) ) {
			$last_modified = date_i18n( get_option('date_format'), filemtime($file) + $gmt_offset) . ' ' . date_i18n(get_option('time_format'), filemtime($file) + $gmt_offset);
		return $last_modified;
		}
	}
}

function bps_flock_modTimeWPI_GWIOD() {
$gmt_offset = get_option( 'gmt_offset' ) * 3600;
$file = dirname(ABSPATH) . '/index.php';
$open_basedir = ini_get('open_basedir');	

	# Quick Fix: do more with this later
	if ( $open_basedir == '' ) {

		if ( file_exists($file) ) {
			$last_modified = date_i18n( get_option('date_format'), filemtime($file) + $gmt_offset) . ' ' . date_i18n(get_option('time_format'), filemtime($file) + $gmt_offset);
		return $last_modified;
		}
	}
}

function bpsPro_flock_sapi_gdmw_hfiles_check() {
	
	$GDMW_options = get_option('bulletproof_security_options_GDMW');
	
	if ( isset( $GDMW_options['bps_gdmw_hosting'] ) && $GDMW_options['bps_gdmw_hosting'] == 'yes' ) {
		$text = '<div style="width:95%;background-color:#dfecf2;border:1px solid #999;font-weight:bold;padding:0px 5px;margin:0px 0px 10px 0px;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><font color="blue">'.__('GDMW Notice: ', 'bulletproof-security').'</font></span>'.__('The Setup Wizard Go Daddy "Managed WordPress Hosting" option is set to Yes.', 'bulletproof-security').'<br>'.__('If you have Go Daddy "Managed WordPress Hosting" click this link: ', 'bulletproof-security').'<a href="https://forum.ait-pro.com/forums/topic/gdmw/" target="_blank" title="Link opens in a new Browser window">'.__('Go Daddy Managed WordPress Hosting', 'bulletproof-security').'</a>.<br>'.__('If you do not have Go Daddy "Managed WordPress Hosting" then change the Go Daddy "Managed WordPress Hosting" Setup Wizard option to No.', 'bulletproof-security').'</strong></div>';
		echo $text;
	}

	$HFiles_options = get_option('bulletproof_security_options_htaccess_files');

	if ( isset( $HFiles_options['bps_htaccess_files'] ) && $HFiles_options['bps_htaccess_files'] == 'disabled' ) {	   
	    $text = '<div style="width:95%;background-color:#dfecf2;border:1px solid #999;font-weight:bold;padding:0px 5px;margin:0px 0px 10px 0px;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><font color="blue">'.__('htaccess Files Disabled Notice: ', 'bulletproof-security').'</font><br><font color="black">'.__('Click this link for help information: ', 'bulletproof-security').'</font><a href="https://forum.ait-pro.com/forums/topic/htaccess-files-disabled-setup-wizard-enable-disable-htaccess-files/" target="_blank" title="htaccess Files Disabled Forum Topic">'.__('htaccess Files Disabled Forum Topic', 'bulletproof-security').'</a></div>';
		echo $text;
	}

	// Detect the SAPI - php_sapi_name returns lower case string by default
	$sapi_type = php_sapi_name();
	
	if ( @substr($sapi_type, 0, 6) != 'apache') {		
		$text = '<div style="width:95%;background-color:#dfecf2;border:1px solid #999;font-weight:bold;padding:0px 5px;margin:0px 0px 10px 0px;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><strong><font color="blue">'.__('Server API: ', 'bulletproof-security').$sapi_type.' - </font><font color="black">'.__('Your Host Server is using CGI. Use the CGI File Lock and Unlock options.', 'bulletproof-security').'</strong></font></div>';
		echo $text;
	} else {
    	$text = '<div style="width:95%;background-color:#dfecf2;border:1px solid #999;font-weight:bold;padding:0px 5px;margin:0px 0px 10px 0px;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><strong><font color="blue">'.__('Server API: ', 'bulletproof-security').$sapi_type.' - </font><font color="black">'.__('Your Server Configuration is DSO. Files cannot be locked on a DSO Server. Choose/Select - Checking & Alerts Off - for all F-Lock option settings.', 'bulletproof-security').'</strong></font></div>';
		echo $text;
	}
}

?>

<div id="FLock-Inner-Table">

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bps-help_faq_table">
  <tr>
    <td colspan="2" class="bps-table_title"><h2><?php _e('File Lock ~ ', 'bulletproof-security'); ?><span style="font-size:.75em;"><?php _e('Lock Mission Critical WordPress Files', 'bulletproof-security'); ?></span></h2>
	
	<?php 
		$text = '<div style="font-size:1.2em;width:95%;background-color:#dfecf2;border:1px solid #999;font-weight:bold;padding:0px 5px;margin:0px 0px 10px 0px;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><strong><font color="blue">'.__('Notice: The File Lock feature has been retired and is turned Off by default. Click the File Lock Read Me help button for more information.', 'bulletproof-security').'</font></div>';
		echo $text; 
	
		bpsPro_flock_sapi_gdmw_hfiles_check(); 
	
	?>
    
    </td>
  </tr>
  <tr>
    <td width="50%" class="bps-table_cell_help">
    
<h3 style="margin:0px 0px 10px 0px;"><?php _e('File Lock Help Info', '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('File Lock', 'bulletproof-security'); ?>">
	<p><?php $text = '<strong>'.__('This Read Me Help window is draggable (top) and resizable (bottom right corner)', 'bulletproof-security').'</strong><br><br><strong><font color="blue">'.__('The File Lock feature has been retired', 'bulletproof-security').'</font></strong><br>'.__('Things have changed since the File Lock feature was originally created in 2011. Web hosts now protect against exploiting Group Permissions on files located in a web host server root folder. If you would still like to continue to use the File Lock feature anyway then set the File Lock Override option setting to > File Lock Override On.', 'bulletproof-security').'<br><br><strong>'.__('IMPORTANT - Web Host Server API Info - CGI or DSO Info', 'bulletproof-security').'</strong><br>'.__('BPS Pro checks your Web Hosts Server API and your Web Hosts Server API is displayed in green font right below this Read Me Help button. Most people will have a CGI Server configuration on their Web Hosts and you should see that your Server API is CGI. If your Web Host is using DSO instead of CGI then file locking and unlocking does not pertain to you. Set your file permissions to DSO - 644 File Permissions and then turn off the S-Monitor', 'bulletproof-security').' <strong>'.__('F-Lock: Check File Lock/Unlock Status', 'bulletproof-security').'</strong> '.__('checking option. DSO file ownership permissions are handled in a completely different way then CGI file permissions. The majority of Web Hosts will be using CGI so the rest of this help file pertains to a CGI Server API.', 'bulletproof-security').'<br><br><strong>'.__('Why Lock Mission Critical Files?', 'bulletproof-security').'</strong><br><strong><font color="blue">'.__('No Longer Relevant - things have changed since File Lock was originally created: ', 'bulletproof-security' ).'</font></strong>'.__('Hackers specifically target the index.php, wp-config.php, wp-blog-header.php and root htaccess files. This is done by exploiting the Group Permissions on files located in Root folders for hosts that use CGI. By locking these files with Read Only 400 and 404 permissions the Group Permissions are removed and these files are protected against attacks. For hosts using DSO - 644 file permissions are secure because of the different file permission methods used by DSO.', 'bulletproof-security').'<br><br><strong>'.__('Will Locking Files With Read Only Permissions Break WordPress?', 'bulletproof-security').'</strong><br>'.__('No. 400 and 404 files permissions have been tested on several different web hosts using CGI and WordPress performs normally. DSO file permissions should be the standard 644 file permissions. BPS is checking and displaying your Server API. If you see CGI displayed as your Server API then you can use the regular File Lock and Unlock options. If you see something other than CGI or DSO displayed as your Server API then check with your web host to find out what the most restrictive file permissions that you can use are or you can just experiment. If you are experimenting be prepared to FTP to your website and manually change the file permission back to what it was if you see 500 errors. Incorrect file permissions could cause you website to display 500 errors and be down. It is possible but not likely that the Server API could display another interface name such as continuity, embed, isapi, litespeed or other SAPI names instead of DSO or CGI.', 'bulletproof-security').'<br><br><strong>'.__('Will Locking Files With Read Only Permissions Break Plugins?', 'bulletproof-security').'</strong><br>'.__('Locking the files will not interfere with a plugins normal operation but if a plugin needs to write to any of these locked files then the file will temporarily need to be unlocked so that a plugin can write to it. If you are using the B-Core File Editor to edit your root htaccess file you will need to unlock the root htaccess file so that BPS can write to it. A Lock/Unlock button has been added to the BPS htaccess File Editor page. F-Lock allows you to quickly Lock and Unlock files on the fly without having to use FTP or your Control Panel.', 'bulletproof-security').'<br><br><strong>'.__('What is GWIOD - Lock/Unlock?', 'bulletproof-security').'</strong><br>'.__('GWIOD is short for Giving WordPress Its Own Directory. People who are using this type of WordPress site set up will have an additional htaccess file and index.php file in their Site Root folder. This will allow them to lock both their Site Root htaccess file and index.php file as well as the htaccess file and index.php files that exist in their actual WordPress installation folder. If you are not using this type of WordPress set up then these files will either show up as duplicates of your already locked or unlocked files or could generate error messages. If you are not using this type of WordPress set up and you are seeing error messages then turn this check off by selecting the', 'bulletproof-security').' <strong>'.__('Checking &amp; Alerts Off', 'bulletproof-security').'</strong> '.__('dropdown list option. If the file does not really exist then you will see', 'bulletproof-security').' <strong>...'.__('file does not exist', 'bulletproof-security').'</strong> '.__('under Permissions &amp; Status for that file.', 'bulletproof-security').'<br><br><strong>'.__('What is DR - Lock/Unlock?', 'bulletproof-security').'</strong><br>'.__('DR is short for Document Root. This allows you to lock and unlock an htaccess file or index.php file in your Document Root folder. If your WordPress installation is already in your Document Root folder then the DR Permissions & Status information will just be duplicated permissions and status information about your already locked or unlocked files. If you have multiple WordPress sites installed and some are subfolder installations and one is a WordPress Document Root installation then you will be able to lock and unlock the Document Root files from any of your WordPress subfolder websites. If you have a single WordPress installation installed in your Document Root folder then these files will show up as duplicates of your already locked or unlocked files. If you are seeing error messages about these files not being locked because they do not really exist then turn this check off by selecting the', 'bulletproof-security').' <strong>'.__('Checking &amp; Alerts Off', 'bulletproof-security').'</strong> '.__('dropdown list option. If the file does not really exist then you will see', 'bulletproof-security').' <strong>'.__('...file does not exist', 'bulletproof-security').'</strong> '.__('under Permissions &amp; Status for that file. Another possible scenario is that if you have an HTML site in your Document Root folder then you could lock the htaccess file for that HTML site.', 'bulletproof-security').'<br><br><strong>'.__('The Wrong Permissions and Status Table Is Displayed', 'bulletproof-security').'</strong><br>'.__('If BPS detects CGI then you will see the', 'bulletproof-security').' <strong>'.__('CGI Permissions & Status Table', 'bulletproof-security').'</strong> '.__('displayed and you should be able to set permissions to 400 and 404. If BPS detects DSO then you will see the', 'bulletproof-security').' <strong>'.__('DSO Permissions & Status Table', 'bulletproof-security').'</strong> '.__('and should only be able to set permissions to 644. BPS looks at the Server API name that your host has configured to display. If your host is using CGI but they are using another interface name then BPS will not be able to detect that your Server is using CGI and will display the DSO Permissions and Status Table. Please let us know about this by sending us an email. We can then add additional coding to BPS to create an exception for your particular host.', 'bulletproof-security').'<br><br><strong>'.__('Help links are provided on the Help & FAQ page.', 'bulletproof-security').'</strong>'; echo $text; ?></p>
</div>    

<?php

if ( isset( $_POST['bpsFlockSubmit'] ) && current_user_can('manage_options') ) {
	check_admin_referer( 'bulletproof_security_options_flock' );
	
	$fl_override_options = get_option('bulletproof_security_options_flock_eol');
		
	if ( $fl_override_options['bps_file_lock_override'] == 'On' ) {

		$Flock_Options = array(
		'bps_lock_root_htaccess' 		=> $_POST['bps_lock_root_htaccess'], 
		'bps_lock_wpconfig' 			=> $_POST['bps_lock_wpconfig'], 
		'bps_lock_index_php' 			=> $_POST['bps_lock_index_php'], 
		'bps_lock_wpblog_header' 		=> $_POST['bps_lock_wpblog_header'], 
		'bps_lock_root_htaccess_dr' 	=> $_POST['bps_lock_root_htaccess_dr'], 
		'bps_lock_index_php_dr' 		=> $_POST['bps_lock_index_php_dr'], 
		'bps_lock_root_htaccess_gwiod' 	=> $_POST['bps_lock_root_htaccess_gwiod'], 
		'bps_lock_index_php_gwiod' 		=> $_POST['bps_lock_index_php_gwiod'] 
		);	
		
		foreach( $Flock_Options as $key => $value ) {
			update_option('bulletproof_security_options_flock', $Flock_Options);
		}	
	
		echo $bps_topDiv;
		$text = '<font color="green"><strong>'.__('F-Lock File Lock Option settings saved!', 'bulletproof-security').'</strong></font>';
		echo $text;		
		echo $bps_bottomDiv;	
		
		$options = get_option('bulletproof_security_options_flock');
		$bpsRootHtaccess = ABSPATH . '.htaccess';
		$bpsWpConfig = ABSPATH . 'wp-config.php';
		$bpsIndexPhp = ABSPATH . 'index.php';
		$bpsWpBlogHeader = ABSPATH . 'wp-blog-header.php';
		$bpsRootHtaccessDR = $_SERVER['DOCUMENT_ROOT'] . '/.htaccess';
		$bpsIndexPhpDR = $_SERVER['DOCUMENT_ROOT'] . '/index.php';
		$bpsRootHtaccessGWIOD = dirname(ABSPATH) . '/.htaccess';
		$bpsIndexPhpGWIOD = dirname(ABSPATH) . '/index.php';
		
		if ( $options['bps_lock_root_htaccess'] == 'yes' ) { 	
			if ( file_exists($bpsRootHtaccess) ) {
				@chmod($bpsRootHtaccess, 0404);
			}
		}
	
		if ( $options['bps_lock_root_htaccess'] == 'no' ) { 	
			if ( file_exists($bpsRootHtaccess) ) {
				@chmod($bpsRootHtaccess, 0644);
			}
		}
		
		if ( $options['bps_lock_root_htaccess'] == 'dso' ) { 	
			if ( file_exists($bpsRootHtaccess) ) {
				@chmod($bpsRootHtaccess, 0644);
			}
		}
	
		if ( $options['bps_lock_wpconfig'] == 'yes' ) { 	
			if ( file_exists($bpsWpConfig) ) {
				@chmod($bpsWpConfig, 0400);
			}
		}
	
		if ( $options['bps_lock_wpconfig'] == 'no' ) { 	
			if ( file_exists($bpsWpConfig) ) {
				@chmod($bpsWpConfig, 0644);
			}
		}
	
		if ( $options['bps_lock_wpconfig'] == 'dso' ) { 	
			if ( file_exists($bpsWpConfig) ) {
				@chmod($bpsWpConfig, 0644);
			}
		}
		
		if ( $options['bps_lock_index_php'] == 'yes' ) { 	
			if ( file_exists($bpsIndexPhp) ) {
				@chmod($bpsIndexPhp, 0400);
			}
		}
	
		if ( $options['bps_lock_index_php'] == 'no' ) { 	
			if ( file_exists($bpsIndexPhp) ) {
				@chmod($bpsIndexPhp, 0644);
			}
		}
	
		if ( $options['bps_lock_index_php'] == 'dso' ) { 	
			if ( file_exists($bpsIndexPhp) ) {
				@chmod($bpsIndexPhp, 0644);
			}
		}
		
		if ( $options['bps_lock_wpblog_header'] == 'yes' ) { 	
			if ( file_exists($bpsWpBlogHeader) ) {
				@chmod($bpsWpBlogHeader, 0400);
			}
		}
	
		if ( $options['bps_lock_wpblog_header'] == 'no' ) { 	
			if ( file_exists($bpsWpBlogHeader) ) {
				@chmod($bpsWpBlogHeader, 0644);
			}
		}
	
		if ( $options['bps_lock_wpblog_header'] == 'dso' ) { 	
			if ( file_exists($bpsWpBlogHeader) ) {
				@chmod($bpsWpBlogHeader, 0644);
			}
		}	
	
		if ( $options['bps_lock_root_htaccess_dr'] == 'yes' ) { 	
			if ( file_exists($bpsRootHtaccessDR) ) {
				@chmod($bpsRootHtaccessDR, 0404);
			}
		}
	
		if ( $options['bps_lock_root_htaccess_dr'] == 'no' ) { 	
			if ( file_exists($bpsRootHtaccessDR) ) {
				@chmod($bpsRootHtaccessDR, 0644);
			}
		}
	
		if ( $options['bps_lock_root_htaccess_dr'] == 'dso' ) { 	
			if ( file_exists($bpsRootHtaccessDR) ) {
				@chmod($bpsRootHtaccessDR, 0644);
			}
		}
	
		if ( $options['bps_lock_index_php_dr'] == 'yes' ) { 	
			if ( file_exists($bpsIndexPhpDR) ) {
				@chmod($bpsIndexPhpDR, 0400);
			}
		}
	
		if ( $options['bps_lock_index_php_dr'] == 'no' ) { 	
			if ( file_exists($bpsIndexPhpDR) ) {
				@chmod($bpsIndexPhpDR, 0644);
			}
		}
	
		if ( $options['bps_lock_index_php_dr'] == 'dso' ) { 	
			if ( file_exists($bpsIndexPhpDR )) {
				@chmod($bpsIndexPhpDR, 0644);
			}
		}
	
		if ( $options['bps_lock_root_htaccess_gwiod'] == 'yes' ) { 	
			if ( file_exists($bpsRootHtaccessGWIOD) ) {
				@chmod($bpsRootHtaccessGWIOD, 0404);
			}
		}
	
		if ( $options['bps_lock_root_htaccess_gwiod'] == 'no' ) { 	
			if ( file_exists($bpsRootHtaccessGWIOD) ) {
				@chmod($bpsRootHtaccessGWIOD, 0644);
			}
		}
	
		if ( $options['bps_lock_root_htaccess_gwiod'] == 'dso' ) { 	
			if ( file_exists($bpsRootHtaccessGWIOD) ) {
				@chmod($bpsRootHtaccessGWIOD, 0644);
			}
		}
	
	
		if ( $options['bps_lock_index_php_gwiod'] == 'yes' ) { 	
			if ( file_exists($bpsIndexPhpGWIOD) ) {
				@chmod($bpsIndexPhpGWIOD, 0400);
			}
		}
	
		if ( $options['bps_lock_index_php_gwiod'] == 'no' ) { 	
			if ( file_exists($bpsIndexPhpGWIOD )) {
				@chmod($bpsIndexPhpGWIOD, 0644);
			}
		}
		
		if ( $options['bps_lock_index_php_gwiod'] == 'dso' ) { 	
			if ( file_exists($bpsIndexPhpGWIOD )) {
				@chmod($bpsIndexPhpGWIOD, 0644);
			}
		}

	} else {
		
		echo $bps_topDiv;
		$text = '<font color="#fb0101"><strong>'.__('The File Lock Override option setting is set to Off. If you would like to use the File Lock feature change the File Override option setting to On.', 'bulletproof-security').'</strong></font>';
		echo $text;		
		echo $bps_bottomDiv;
		
	}

}

function bpsPro_file_lock_override() {
global $bps_topDiv, $bps_bottomDiv;

	if ( isset( $_POST['Submit-FL-Override'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_fl_override' );
	
		$BPS_FLO_Options = array( 
		'bps_file_lock_override' 			=> $_POST['bps_file_lock_override'], 
		'bps_file_lock_override_hidden' 	=> $_POST['bps_file_lock_override_hidden'] 
		);	

		foreach( $BPS_FLO_Options as $key => $value ) {
			update_option('bulletproof_security_options_flock_eol', $BPS_FLO_Options);
		}	

		echo $bps_topDiv;
		$text = '<font color="green"><strong>'.__('File Lock Override Option setting saved', 'bulletproof-security').'</strong></font>';
		echo $text;		
		echo $bps_bottomDiv;
	}
}

?>

<div id="FLock-options-form">

<form name="bpsFLOverride" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/lock/flock.php' ); ?>" method="post">
	<?php wp_nonce_field('bulletproof_security_fl_override'); 
	bpsPro_file_lock_override();
	$fl_override_options = get_option('bulletproof_security_options_flock_eol');
	$bps_file_lock_override = ! isset($fl_override_options['bps_file_lock_override']) ? '' : $fl_override_options['bps_file_lock_override'];
	?>
<strong><label for="bps-flock"><?php _e('File Lock Override', 'bulletproof-security'); ?></label></strong><br />
<select name="bps_file_lock_override" class="form-340">
<option value="Off"<?php selected('Off', $bps_file_lock_override); ?>><?php _e('File Lock Override Off', 'bulletproof-security'); ?></option>
<option value="On"<?php selected('On', $bps_file_lock_override); ?>><?php _e('File Lock Override On', 'bulletproof-security'); ?></option>
</select><br /><br />
	<input type="hidden" name="bps_file_lock_override_hidden" value="14" />
	<input type="submit" name="Submit-FL-Override" class="button bps-button" style="margin:0px 0px 10px 10px;" value="<?php esc_attr_e('Save Override Option', 'bulletproof-security') ?>" />
</form>

<form name="bpsFlock" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/lock/flock.php' ); ?>" method="post">
    <?php wp_nonce_field('bulletproof_security_options_flock'); ?>
	<?php $options = get_option('bulletproof_security_options_flock'); 
	$bps_lock_root_htaccess = ! isset($options['bps_lock_root_htaccess']) ? '' : $options['bps_lock_root_htaccess'];
	$bps_lock_wpconfig = ! isset($options['bps_lock_wpconfig']) ? '' : $options['bps_lock_wpconfig'];	
	$bps_lock_index_php = ! isset($options['bps_lock_index_php']) ? '' : $options['bps_lock_index_php'];
	$bps_lock_wpblog_header = ! isset($options['bps_lock_wpblog_header']) ? '' : $options['bps_lock_wpblog_header'];	
	$bps_lock_root_htaccess_dr = ! isset($options['bps_lock_root_htaccess_dr']) ? '' : $options['bps_lock_root_htaccess_dr'];
	$bps_lock_index_php_dr = ! isset($options['bps_lock_index_php_dr']) ? '' : $options['bps_lock_index_php_dr'];	
	$bps_lock_root_htaccess_gwiod = ! isset($options['bps_lock_root_htaccess_gwiod']) ? '' : $options['bps_lock_root_htaccess_gwiod'];
	$bps_lock_index_php_gwiod = ! isset($options['bps_lock_index_php_gwiod']) ? '' : $options['bps_lock_index_php_gwiod'];
	?>

<strong><label for="bps-flock"><?php _e('Lock|Unlock Root htaccess File', 'bulletproof-security'); ?></label></strong><br />
<select name="bps_lock_root_htaccess" class="form-340">
<option value="yes"<?php selected('yes', $bps_lock_root_htaccess); ?>><?php _e('CGI|Lock Root htaccess File', 'bulletproof-security'); ?></option>
<option value="no"<?php selected('no', $bps_lock_root_htaccess); ?>><?php _e('CGI|Unlock Root htaccess File', 'bulletproof-security'); ?></option>
<option value="dso"<?php selected('dso', $bps_lock_root_htaccess); ?>><?php _e('DSO|644 File Permission', 'bulletproof-security'); ?></option>
<option value="off"<?php selected('off', $bps_lock_root_htaccess); ?>><?php _e('Checking &amp; Alerts Off', 'bulletproof-security'); ?></option>
</select><br /><br />
<strong><label for="bps-flock"><?php _e('Lock|Unlock wp-config.php File', 'bulletproof-security'); ?></label></strong><br />
<select name="bps_lock_wpconfig" class="form-340">
<option value="yes"<?php selected('yes', $bps_lock_wpconfig); ?>><?php _e('CGI|Lock wp-config.php File', 'bulletproof-security'); ?></option>
<option value="no"<?php selected('no', $bps_lock_wpconfig); ?>><?php _e('CGI|Unlock wp-config.php File', 'bulletproof-security'); ?></option>
<option value="dso"<?php selected('dso', $bps_lock_wpconfig); ?>><?php _e('DSO|644 File Permission', 'bulletproof-security'); ?></option>
<option value="off"<?php selected('off', $bps_lock_wpconfig); ?>><?php _e('Checking &amp; Alerts Off', 'bulletproof-security'); ?></option>
</select><br /><br />
<strong><label for="bps-flock"><?php _e('Lock|Unlock WP Root index.php File', 'bulletproof-security'); ?></label></strong><br />
<select name="bps_lock_index_php" class="form-340">
<option value="yes"<?php selected('yes', $bps_lock_index_php); ?>><?php _e('CGI|Lock WP Root index.php File', 'bulletproof-security'); ?></option>
<option value="no"<?php selected('no', $bps_lock_index_php); ?>><?php _e('CGI|Unlock WP Root index.php File', 'bulletproof-security'); ?></option>
<option value="dso"<?php selected('dso', $bps_lock_index_php); ?>><?php _e('DSO|644 File Permission', 'bulletproof-security'); ?></option>
<option value="off"<?php selected('off', $bps_lock_index_php); ?>><?php _e('Checking &amp; Alerts Off', 'bulletproof-security'); ?></option>
</select><br /><br />
<strong><label for="bps-flock"><?php _e('Lock|Unlock wp-blog-header.php File', 'bulletproof-security'); ?></label></strong><br />
<select name="bps_lock_wpblog_header" class="form-340">
<option value="yes"<?php selected('yes', $bps_lock_wpblog_header); ?>><?php _e('CGI|Lock wp-blog-header.php File', 'bulletproof-security'); ?></option>
<option value="no"<?php selected('no', $bps_lock_wpblog_header); ?>><?php _e('CGI|Unlock wp-blog-header.php File', 'bulletproof-security'); ?></option>
<option value="dso"<?php selected('dso', $bps_lock_wpblog_header); ?>><?php _e('DSO|644 File Permission', 'bulletproof-security'); ?></option>
<option value="off"<?php selected('off', $bps_lock_wpblog_header); ?>><?php _e('Checking &amp; Alerts Off', 'bulletproof-security'); ?></option>
</select><br /><br />
<strong><label for="bps-flock"><?php _e('DR: Lock|Unlock DR htaccess File', 'bulletproof-security'); ?></label></strong><br />
<select name="bps_lock_root_htaccess_dr" class="form-340">
<option value="off"<?php selected('off', $bps_lock_root_htaccess_dr); ?>><?php _e('Checking &amp; Alerts Off', 'bulletproof-security'); ?></option>
<option value="yes"<?php selected('yes', $bps_lock_root_htaccess_dr); ?>><?php _e('CGI|Lock DR Root htaccess File', 'bulletproof-security'); ?></option>
<option value="no"<?php selected('no', $bps_lock_root_htaccess_dr); ?>><?php _e('CGI|Unlock DR Root htaccess File', 'bulletproof-security'); ?></option>
<option value="dso"<?php selected('dso', $bps_lock_root_htaccess_dr); ?>><?php _e('DSO|644 File Permission', 'bulletproof-security'); ?></option>
</select><br /><br />
<strong><label for="bps-flock"><?php _e('DR: Lock|Unlock WP DR index.php File', 'bulletproof-security'); ?></label></strong><br />
<select name="bps_lock_index_php_dr" class="form-340">
<option value="off"<?php selected('off', $bps_lock_index_php_dr); ?>><?php _e('Checking &amp; Alerts Off', 'bulletproof-security'); ?></option>
<option value="yes"<?php selected('yes', $bps_lock_index_php_dr); ?>><?php _e('CGI|Lock DR WP index.php File', 'bulletproof-security'); ?></option>
<option value="no"<?php selected('no', $bps_lock_index_php_dr); ?>><?php _e('CGI|Unlock DR WP index.php File', 'bulletproof-security'); ?></option>
<option value="dso"<?php selected('dso', $bps_lock_index_php_dr); ?>><?php _e('DSO|644 File Permission', 'bulletproof-security'); ?></option>
</select><br /><br />
<strong><label for="bps-flock"><?php _e('GWIOD: Lock|Unlock Root htaccess File', 'bulletproof-security'); ?></label></strong><br />
<select name="bps_lock_root_htaccess_gwiod" class="form-340">
<option value="off"<?php selected('off', $bps_lock_root_htaccess_gwiod); ?>><?php _e('Checking &amp; Alerts Off', 'bulletproof-security'); ?></option>
<option value="yes"<?php selected('yes', $bps_lock_root_htaccess_gwiod); ?>><?php _e('CGI|Lock GWIOD Root htaccess File', 'bulletproof-security'); ?></option>
<option value="no"<?php selected('no', $bps_lock_root_htaccess_gwiod); ?>><?php _e('CGI|Unlock GWIOD Root htaccess File', 'bulletproof-security'); ?></option>
<option value="dso"<?php selected('dso', $bps_lock_root_htaccess_gwiod); ?>><?php _e('DSO|644 File Permission', 'bulletproof-security'); ?></option>
</select><br /><br />
<strong><label for="bps-flock"><?php _e('GWIOD: Lock|Unlock WP Root index.php File', 'bulletproof-security'); ?></label></strong><br />
<select name="bps_lock_index_php_gwiod" class="form-340">
<option value="off"<?php selected('off', $bps_lock_index_php_gwiod); ?>><?php _e('Checking &amp; Alerts Off', 'bulletproof-security'); ?></option>
<option value="yes"<?php selected('yes', $bps_lock_index_php_gwiod); ?>><?php _e('CGI|Lock GWIOD WP index.php File', 'bulletproof-security'); ?></option>
<option value="no"<?php selected('no', $bps_lock_index_php_gwiod); ?>><?php _e('CGI|Unlock GWIOD WP index.php File', 'bulletproof-security'); ?></option>
<option value="dso"<?php selected('dso', $bps_lock_index_php_gwiod); ?>><?php _e('DSO|644 File Permission', 'bulletproof-security'); ?></option>
</select><br /><br />
<input type="hidden" name="bpsFL" value="bps-FL" />

<input type="submit" name="bpsFlockSubmit" class="button bps-button" style="margin:0px 0px 10px 10px;" value="<?php esc_attr_e('Save Options', 'bulletproof-security') ?>"   onclick="return confirm('<?php $text = __('Hint: Most websites will not need to use the DR and GWIOD F-Lock options and these can be set to Checking and Alerts Off. Please read the Read Me help button for more information about what types of WordPress websites use the DR and GWIOD options.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Save your options or click Cancel.', 'bulletproof-security'); echo $text; ?>')"/>
</form>	

</div>
    </td>
    <td width="50%" valign="top" class="bps-table_cell_help">
    
    <?php 
	$bpsRootHtaccess = ABSPATH . '.htaccess';
	$bpsWpConfig = ABSPATH . 'wp-config.php';
	$bpsIndexPhp = ABSPATH . 'index.php';
	$bpsWpBlogHeader = ABSPATH . 'wp-blog-header.php';
	$bpsRootHtaccessDR = $_SERVER['DOCUMENT_ROOT'] . '/.htaccess';
	$bpsIndexPhpDR = $_SERVER['DOCUMENT_ROOT'] . '/index.php';
	$bpsRootHtaccessGWIOD = dirname(ABSPATH) . '/.htaccess';
	$bpsIndexPhpGWIOD = dirname(ABSPATH) . '/index.php';
	$sapi_type = php_sapi_name();
	
	if ( @substr($sapi_type, 0, 6) != 'apache') {	
	?>

    <h3 style="margin:0px 0px 5px 0px;"><?php _e('CGI Permissions &amp; Status Table', 'bulletproof-security'); ?></h3>
    
    <div id="FlockFilesTable">
    <table class="widefat" style="margin-bottom:20px;">
	<thead>
	<tr>
	<th scope="col"><strong><?php _e('Filename', 'bulletproof-security')?></strong></th>
	<th scope="col"><strong><?php _e('Permissions &amp; Status', 'bulletproof-security')?></strong></th>
    <th scope="col"><strong><?php _e('Last Modified', 'bulletproof-security')?></strong></th>
	</tr>
	</thead>

	<tbody>
	<tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('Root .htaccess', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusRH(); ?></td>
    <td><?php echo bps_flock_modTimeRH(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsRootHtaccess; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('wp-config.php', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusWPC(); ?></td>
    <td><?php echo bps_flock_modTimeWPC(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsWpConfig; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('WP index.php', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusWPI(); ?></td>
    <td><?php echo bps_flock_modTimeWPI(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsIndexPhp; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('wp-blog-header.php', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusWPBH(); ?></td>
    <td><?php echo bps_flock_modTimeWPBH(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsWpBlogHeader; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('DR - Root .htaccess', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusRH_DR(); ?></td>
    <td><?php echo bps_flock_modTimeRH_DR(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsRootHtaccessDR; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('DR - WP index.php', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusWPI_DR(); ?></td>
    <td><?php echo bps_flock_modTimeWPI_DR(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsIndexPhpDR; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('GWIOD - Root .htaccess', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusRH_GWIOD(); ?></td>
    <td><?php echo bps_flock_modTimeRH_GWIOD(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsRootHtaccessGWIOD; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('GWIOD - WP index.php', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusWPI_GWIOD(); ?></td>
    <td><?php echo bps_flock_modTimeWPI_GWIOD(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsIndexPhpGWIOD; ?></td>
    </tr>
</tbody>
</table>
</div>

<?php } else { ?>

<h3 style="margin:0px 0px 5px 0px;"><?php _e('DSO Permissions &amp; Status Table', 'bulletproof-security'); ?></h3>
    
    <div id="FlockFilesTable">
    <table class="widefat" style="margin-bottom:20px;">
	<thead>
	<tr>
	<th scope="col"><strong><?php _e('Filename', 'bulletproof-security')?></strong></th>
	<th scope="col"><strong><?php _e('Permissions &amp; Status', 'bulletproof-security')?></strong></th>
    <th scope="col"><strong><?php _e('Last Modified', 'bulletproof-security')?></strong></th>
	</tr>
	</thead>
	
    <tbody>
	<tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('Root .htaccess', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusRH_DSO(); ?></td>
    <td><?php echo bps_flock_modTimeRH(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsRootHtaccess; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('wp-config.php', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusWPC_DSO(); ?></td>
    <td><?php echo bps_flock_modTimeWPC(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsWpConfig; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('WP index.php', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusWPI_DSO(); ?></td>
    <td><?php echo bps_flock_modTimeWPI(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsIndexPhp; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('wp-blog-header.php', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusWPBH_DSO(); ?></td>
    <td><?php echo bps_flock_modTimeWPBH(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsWpBlogHeader; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('DR - Root .htaccess', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusRH_DR_DSO(); ?></td>
    <td><?php echo bps_flock_modTimeRH_DR(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsRootHtaccessDR; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('DR - WP index.php', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusWPI_DR_DSO(); ?></td>
    <td><?php echo bps_flock_modTimeWPI_DR(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsIndexPhpDR; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('GWIOD - Root .htaccess', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusRH_GWIOD_DSO(); ?></td>
    <td><?php echo bps_flock_modTimeRH_GWIOD(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff;padding:0px 0px 0px 6px;">
	<?php echo $bpsRootHtaccessGWIOD; ?></td>
    </tr>
    <tr>
	<th scope="row" style="border-bottom:none;">
	<?php _e('GWIOD - WP index.php', 'bulletproof-security')?></th>
	<td><?php echo bps_flock_pro_statusWPI_GWIOD_DSO(); ?></td>
    <td><?php echo bps_flock_modTimeWPI_GWIOD(); ?></td>
	</tr>
    <tr>
	<th scope="row" style="padding:0px;"></th>
    <td colspan="2" style="color:black;background-color:#fff; padding:0px 0px 0px 6px;">
	<?php echo $bpsIndexPhpGWIOD; ?></td>
    </tr>
</tbody>
</table>
</div>
<?php } ?>
	</td>
  </tr>
</table>
</div>

<?php if ( isset($UIoptions['bps_ui_theme_skin']) && $UIoptions['bps_ui_theme_skin'] == 'blue' ) { ?>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($) {
	$( "#FlockFilesTable tr:odd" ).css( "background-color", "#f9f9f9" );
});
/* ]]> */
</script>

<?php } ?>

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

<?php

/* May need to be used later - wait and see what happens with DSO Server types.
	if ( @substr($sapi_type, 0, 6) != 'apache') {		
		$text = '<font color="green"><strong>'.__('Server API: ', 'bulletproof-security').$sapi_type.' - '.__('Your Host Server is using CGI. Use the CGI Folder Lock and Unlock options.', 'bulletproof-security').'</strong></font>';
		echo $text;
	} else {
    	$text = '<font color="black"><strong>'.__('Server API: ', 'bulletproof-security').$sapi_type.' - '.__('Your Server Configuration is DSO. Folders cannot be locked on a DSO Server. Choose/Select - Turn Off Checking & Alerts - for all F-Lock option settings.', 'bulletproof-security').'</strong></font>';
		echo $text;
}
*/

?>

<?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 colspan="2" class="bps-table_title"><h2><?php _e('Folder Lock ~ ', 'bulletproof-security'); ?><span style="font-size:.75em;"><?php _e('Monitors your Hosting Account Root folder for new folders that are created & automatically locks them', 'bulletproof-security'); ?> <br /> <span class="cc-read-me-text"><?php _e('* Click the Read Me help button before using Folder Lock', 'bulletproof-security'); ?></span></span></h2></td>
  </tr>
  <tr>
    <td width="50%" class="bps-table_cell_help">
    
<h3 style="margin:0px 0px 10px 0px;"><?php _e('Folder Lock Help Info', '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('Folder Lock', 'bulletproof-security'); ?>">
	<p><?php $text = '<strong>'.__('This Read Me Help window is draggable (top) and resizable (bottom right corner)', 'bulletproof-security').'</strong><br><br><strong>'.__('What Folder Lock Does & How it Works', 'bulletproof-security').'</strong><br>'.__('Folder Lock monitors your Hosting Account Root folder and checks for any new folders that are created. If a new folder is found in your Hosting Account Root folder that is not listed in the Folder Lock Table it is automatically locked with 400 folder permissions, which means that the folder will be literally locked and will not be accessible to anyone including you. Folder Lock is not intended to be used to secure/protect your existing Hosting Account Root folders since locking a folder literally means lock that folder and make it unusable/inaccessible to anyone including you. Folder Lock should ONLY be turned On, on 1 of your websites under your Hosting Account. You only want 1 of your websites under a Hosting Account to monitor the Hosting Account Root folder for all of your websites/your entire Hosting Account Root folder.', 'bulletproof-security').'<br><br><strong>'.__('Example Usage Scenario:', 'bulletproof-security').'</strong><br>'.__('A hacker creates a folder in your Hosting Account Root folder. Folder Lock will automatically lock that folder with 400 folder permissions, send you an email alert that a folder was locked and will display a Dashboard alert that a folder has been locked. If the folder is unlocked via FTP the folder will be automatically relocked again by Folder Lock until it is unlocked using the Folder Lock Unlock Form.', 'bulletproof-security').'<br><br><strong>'.__('IMPORTANT NOTES:', 'bulletproof-security').'</strong><br>'.__('1. Locking a folder literally means lock the folder and make the folder inaccessible and unusable. Locking a folder does not mean making the folder secure or adding security to a folder.', 'bulletproof-security').'<br>'.__('2. The WP Core Folders: wp-admin, wp-content and wp-includes cannot be locked since that would cause your WordPress website to stop working.', 'bulletproof-security').'<br>'.__('3. A Delete Folder option has intentionally not been added. If a hacker creates a folder in your Hosting Account Root folder then you should download a copy of that folder to your computer before deleting the folder from your Hosting Account Root folder using FTP. You probably want to take a look at what is in that hacker folder for any clues to what the hacker was attempting to do.', 'bulletproof-security').'<br>'.__('4. AutoRestore|Quarantine monitors all files in your Hosting Account Root folder, but does check for new folders being created in the Hosting Account Root folder so Folder Lock covers this very low probability attack vector just in case. It is very unlikely that a hacker will ever create a folder in your Hosting Account Root folder.', 'bulletproof-security').'<br><br><strong>'.__('Folder Lock Cron Check Frequency:', 'bulletproof-security').'</strong><br>'.__('Choose how often the Folder Lock Cron Check should be performed. Every 1, 2, 3, 4, 5, 10, 15, 30 or 60 minutes. The Default Cron Frequency Check is set to 2 minutes by the Setup Wizard. You can of course change this to any other Cron frequency checking time that you want to use.', 'bulletproof-security').'<br><br><strong>'.__('Folder Lock On|Off (Folder Lock Cron Check):', 'bulletproof-security').'</strong><br>'.__('The Folder Lock Cron Check should ONLY be turned On, on 1 of your websites under your Hosting Account. You only want 1 of your websites in a Hosting Account monitoring your Hosting Account Root folder.', 'bulletproof-security').'<br><br><strong>'.__('Reset|Clear Folder Lock Alerts', 'bulletproof-security').'</strong><br>'.__('To reset/clear Folder Lock Dashboard Alerts click the Reset|Clear Folder Lock Alerts button.', 'bulletproof-security').'<br><br><strong>'.__('Rescan|Add Hosting Account Root Folders', 'bulletproof-security').'</strong><br>'.__('Clicking the Rescan|Add Hosting Account Root Folders button deletes all existing DB rows displayed in the Folder Lock Table and creates new DB Rows that will be displayed in the Folder Lock Table.', 'bulletproof-security').'<br><br><strong>'.__('Lock', 'bulletproof-security').'</strong><br>'.__('Locking a folder literally means lock the folder and make the folder inaccessible and unusable. Locking a folder does not mean making the folder secure or adding security to a folder. Lock uses 400 folder permissions, which means that no one including yourself can access the folder or add any files in that locked folder.', 'bulletproof-security').'<br><br><strong>'.__('Unlock', 'bulletproof-security').'</strong><br>'.__('Unlocking a folder uses the folder permissions that you see for the DB: value. If the DB: value is blank then 755 folder permissions will be used for the unlock folder permissions.', 'bulletproof-security').'<br><br><strong>'.__('Procedural Steps When Adding New Hosting Account Root Folders', 'bulletproof-security').'</strong><br>'.__('1. Login to the website that has Folder Lock turned On and turn Folder Lock Off.', 'bulletproof-security').'<br>'.__('2. Upload/Add/Create your folders in your Hosting Account Root folder.', 'bulletproof-security').'<br>'.__('3. Click the Rescan|Add Hosting Account Root Folders button.', 'bulletproof-security').'<br>'.__('4. Turn Folder Lock On.', 'bulletproof-security').'<br><br><strong>'.__('Email and Dashboard Alert Settings', 'bulletproof-security').'</strong><br>'.__('Email and Dashboard Alerting option settings for Folder Lock are on the BPS Pro S-Monitor page.', 'bulletproof-security').'<br><br><strong>'.__('Troubleshooting', 'bulletproof-security').'</strong><br>'.__('If you upload/add or create a new folder in your Hosting Account Root folder and it is locked by Folder Lock do these steps below to unlock the folder and rescan your Hosting Account Root folder.', 'bulletproof-security').'<br>'.__('1. Login to the website that has Folder Lock turned On.', 'bulletproof-security').'<br>'.__('2. Check the Unlock checkbox for the folder you want to unlock and click the Submit button.', 'bulletproof-security').'<br>'.__('3. Click the Rescan|Add Hosting Account Root Folders button.', 'bulletproof-security').'<br><br><strong>'.__('Additional Notes:', 'bulletproof-security').'</strong><br>'.__('1. On XAMPP when doing a CHMOD 0400 the Windows permissions show 0555 permissions, which basically does not mean anything since Windows permissions are different than Linux permissions. You cannot lock a file using CHMOD on Windows.', 'bulletproof-security').'<br>'.__('2. If a new file is created in a folder then the Last Modified date of the folder will change to the time when that new file was created in that folder.', 'bulletproof-security').'<br><br><strong>'.__('Help links are provided on the Help & FAQ page.', 'bulletproof-security').'</strong>'; echo $text; ?></p>
</div> 

<table width="100%" border="0">
  <tr>
    <td style="width:400px;vertical-align:top;">

<?php
// Folder Lock DB Values Form
function bpsPro_folder_lock_values_form() {
global $bps_topDiv, $bps_bottomDiv;

	if ( isset( $_POST['bpsFolderLockSubmit'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bpsFolderLockValues' );
		
	if ( $_POST['flock_cron'] == 'Off' ) {
		wp_clear_scheduled_hook('bpsPro_FolderLock_check');
	}
	
	$flock_cron_frequency = $_POST['flock_cron_frequency'];
	
	if ( $flock_cron_frequency == '1' ) {
		$flock_cron_end = time() + 60;	
	}
	if ( $flock_cron_frequency == '2' ) {
		$flock_cron_end = time() + 120;	
	}
	if ( $flock_cron_frequency == '3' ) {
		$flock_cron_end = time() + 180;	
	}
	if ( $flock_cron_frequency == '4' ) {
		$flock_cron_end = time() + 240;	
	}
	if ( $flock_cron_frequency == '5' ) {
		$flock_cron_end = time() + 300;	
	}	
	if ( $flock_cron_frequency == '10' ) {
		$flock_cron_end = time() + 600;	
	}	
	if ( $flock_cron_frequency == '15' ) {
		$flock_cron_end = time() + 900;	
	}	
	if ( $flock_cron_frequency == '30' ) {
		$flock_cron_end = time() + 1800;	
	}	
	if ( $flock_cron_frequency == '60' ) {
		$flock_cron_end = time() + 3600;	
	}	

	$BPS_Options = array(
	'bps_folder_lock_cron' 				=> $_POST['flock_cron'], 
	'bps_folder_lock_cron_frequency' 	=> $flock_cron_frequency, 
	'bps_folder_lock_cron_end' 			=> $flock_cron_end
	);	
	
		foreach( $BPS_Options as $key => $value ) {
			update_option('bulletproof_security_options_flock_FL', $BPS_Options);
		}	

	echo $bps_topDiv;
	$text = '<font color="green"><strong>'.__('Folder Lock Option settings saved!', 'bulletproof-security').'</strong></font>';
	echo $text;		
	echo $bps_bottomDiv;
	}
}
?>

<div id="bps-Folder-Lock-Cron" style="margin:10px 0px 20px 0px;">
    <form name="bpsFolderLockCron" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/lock/flock.php#bps-tabs-2' ); ?>" method="post">
<?php 
	wp_nonce_field('bpsFolderLockValues'); 
	bpsPro_folder_lock_values_form(); 
	$FLoptions = get_option('bulletproof_security_options_flock_FL');
	$bps_folder_lock_cron_frequency = ! isset($FLoptions['bps_folder_lock_cron_frequency']) ? '' : $FLoptions['bps_folder_lock_cron_frequency'];
	$bps_folder_lock_cron = ! isset($FLoptions['bps_folder_lock_cron']) ? '' : $FLoptions['bps_folder_lock_cron'];
?>

<div style="margin-top:0px;"><strong>
<label for="bps-flock"><?php _e('Folder Lock Cron Check Frequency:', 'bulletproof-security'); ?></label></strong>
</div>
<select name="flock_cron_frequency" class="form-340">
<option value="1"<?php selected('1', $bps_folder_lock_cron_frequency); ?>><?php _e('Run Folder Lock Cron Check Every 1 Minute', 'bulletproof-security'); ?></option>
<option value="2"<?php selected('2', $bps_folder_lock_cron_frequency); ?>><?php _e('Run Folder Lock Cron Check Every 2 Minutes', 'bulletproof-security'); ?></option>
<option value="3"<?php selected('3', $bps_folder_lock_cron_frequency); ?>><?php _e('Run Folder Lock Cron Check Every 3 Minutes', 'bulletproof-security'); ?></option>
<option value="4"<?php selected('4', $bps_folder_lock_cron_frequency); ?>><?php _e('Run Folder Lock Cron Check Every 4 Minutes', 'bulletproof-security'); ?></option>
<option value="5"<?php selected('5', $bps_folder_lock_cron_frequency); ?>><?php _e('Run Folder Lock Cron Check Every 5 Minutes', 'bulletproof-security'); ?></option>
<option value="10"<?php selected('10', $bps_folder_lock_cron_frequency); ?>><?php _e('Run Folder Lock Cron Check Every 10 Minutes', 'bulletproof-security'); ?></option>
<option value="15"<?php selected('15', $bps_folder_lock_cron_frequency); ?>><?php _e('Run Folder Lock Cron Check Every 15 Minutes', 'bulletproof-security'); ?></option>
<option value="30"<?php selected('30', $bps_folder_lock_cron_frequency); ?>><?php _e('Run Folder Lock Cron Check Every 30 Minutes', 'bulletproof-security'); ?></option>
<option value="60"<?php selected('60', $bps_folder_lock_cron_frequency); ?>><?php _e('Run Folder Lock Cron Check Every 60 Minutes', 'bulletproof-security'); ?></option>
</select><br /><br />

<div id="FLock-on-off-form">
<strong><label for="bps-flock"><?php _e('Folder Lock On|Off (Folder Lock Cron Check):', 'bulletproof-security'); ?></label></strong><br />
<select name="flock_cron" class="form-340">
<option value="On"<?php selected('On', $bps_folder_lock_cron); ?>><?php _e('Folder Lock On', 'bulletproof-security'); ?></option>
<option value="Off"<?php selected('Off', $bps_folder_lock_cron); ?>><?php _e('Folder Lock Off', 'bulletproof-security'); ?></option>
</select><br /><br />
</div>

<input type="hidden" name="flock_cron_end" value="<?php echo esc_html( $bps_folder_lock_cron_frequency ); ?>" />

<input type="submit" name="bpsFolderLockSubmit" value="<?php esc_attr_e('Save Folder Lock Cron Options', 'bulletproof-security'); ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Click OK to proceed or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
</form>

</div>

    </td>
    <td style="vertical-align:top;">

<?php
// Get the Current / Last Modifed Date of the Login Security Reset File
function bps_getFolderLockResetFileLastMod() {
$filename = WP_CONTENT_DIR . '/bps-backup/master-backups/Folder-Lock-Alert-Reset.txt';
$gmt_offset = get_option( 'gmt_offset' ) * 3600;

if ( file_exists($filename) ) {
	$last_modified = date("F d Y H:i:s", filemtime($filename) + $gmt_offset );
	return $last_modified;
	}
}

// Drop the existing Folder Lock DB Table, Create a new DB Table, insert new DB Rows.
// Include wp-admin, wp-content and wp-includes folders if they are in the Hosting Root folder.
// Not using the orig_perms db column at this point, maybe later on. See DW file code.
function bpsPro_flock_folder_scan() {

	if ( isset( $_POST['Submit-Flock-Folder-Scan'] ) && current_user_can('manage_options') ) {
		check_admin_referer('bulletproof_security_flock_FL_scan');

		global $wpdb, $bps_wpcontent_dir, $bps_topDiv, $bps_bottomDiv;	
	
		$source = $_SERVER['DOCUMENT_ROOT'];
		$FLtable_name = $wpdb->prefix . "bpspro_folder_lock";
		$wpdb_collate = $wpdb->collate;
	
		if ( $wpdb->query("DROP TABLE IF EXISTS $FLtable_name") ) {	
	
			if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $FLtable_name ) ) != $FLtable_name ) {	
	
			$sql = "CREATE TABLE $FLtable_name (
			id bigint(20) NOT NULL auto_increment,
			folder_name text NOT NULL,
			status varchar(60) NOT NULL default '',
			curr_perms varchar(4) NOT NULL default '',
			orig_perms varchar(4) NOT NULL default '',
			path text NOT NULL,
			last_mod varchar(10) NOT NULL default '',
			ulock_time varchar(10) NOT NULL default '',
			hlock_time datetime NOT NULL default '0000-00-00 00:00:00',
			UNIQUE KEY id (id)
			)
			COLLATE {$wpdb_collate};";
	
			require_once ABSPATH . 'wp-admin/includes/upgrade.php';
			dbDelta($sql);
			}
		}
	
		if ( is_dir($source) ) {
			
			$iterator = new DirectoryIterator($source);	
	
			echo $bps_topDiv;
			$text = '<strong><font color="green">'.__('Hosting Account Root Folders Added:', 'bulletproof-security').'</font></strong><br>';
			echo $text;
			
			foreach ( $iterator as $files ) {
				
				if ( $files->isDir() && ! $files->isDot() ) {
	
					if ( empty( $files ) ) {
					
						$text = '<strong><font color="green">'.__('No Hosting Account Root Folders were Found or Added. This is ok. Folder Lock checks if any new folders are created in your Hosting Account Root folder, locks those new folders and alerts you about them.', 'bulletproof-security').'</font></strong>';
						echo $text;
	
					} else {
	
						// maybe filter these later if there is a problem: if ( $files != $bps_wpcontent_dir && $files != 'wp-admin' && $files != 'wp-includes' ) {
						if ( $insert_rows = $wpdb->insert( $FLtable_name, array( 'folder_name' => $files->getFilename(), 'status' => 'Not Locked', 'curr_perms' => substr(sprintf('%o', $files->getPerms()), -4), 'path' => $files->getPathname(), 'last_mod' => $files->getMTime(), 'ulock_time' => time(), 'hlock_time' => current_time('mysql') ) ) ) {
					
							echo '<strong><font color="green">' . $files->getFilename() . ', ' . '</font></strong>';
						}
					}
				}
			}
			echo $bps_bottomDiv;	
		}
	}
}

?>

<div id="Folder-Lock-Reset-Button">
<form name="FolderLockAlertReset" action="options.php#bps-tabs-2" method="post">
<?php settings_fields('bulletproof_security_options_flock_FL_alerts'); ?> 
<?php $FLAlertsoptions = get_option('bulletproof_security_options_flock_FL_alerts'); ?>
    <input type="hidden" name="bulletproof_security_options_flock_FL_alerts[bps_folderlock_db_mod_time]" value="<?php echo bps_getFolderLockResetFileLastMod(); ?>" /><br />
    <input type="submit" name="Submit-Reset-Folder-Lock-Alerts" class="button bps-button" style="margin:22px 0px 20px 0px;width:266px;height:auto;white-space:normal" value="<?php esc_attr_e('Reset|Clear Folder Lock Alerts', 'bulletproof-security') ?>" /><!-- top margin was 22 -->
</form>
</div>

<div id="Folder-Lock-Scan">
<form name="FolderLockScan" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/lock/flock.php#bps-tabs-2' ); ?>" method="post">
	<?php wp_nonce_field('bulletproof_security_flock_FL_scan'); ?>
	<input type="submit" name="Submit-Flock-Folder-Scan" class="button bps-button" style="margin:0px 0px 0px 0px;width:266px;height:auto;white-space:normal" value="<?php esc_attr_e('Rescan|Add Hosting Account Root Folders', 'bulletproof-security') ?>" onclick="return confirm('<?php 
$text = __('Clicking OK will rescan your Hosting Account Root folder and add/create all folders with their current folder permissions in the Folder Lock Table.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to proceed or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
	<?php bpsPro_flock_folder_scan(); ?>
</form>
</div>

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

<?php

// Folder Lock Form proccessing - Lock or Unlock Folders
// curr_perms – gets the actual current folder permissions and resaves them each time the Rescan button is clicked.
// This is the value that is used for Unlock in Folder Lock Form processing.
// Note: Wierd bug in XAMPP that requires using the literal 0777 or 0666 permissions with CHMOD or the permissions will be changed to 0555?
if ( isset( $_POST['Submit-Folder-Lock'] ) && current_user_can('manage_options') ) {
	check_admin_referer('bulletproof_security_folder_lock');
	
	$FLFN = $_POST['FLFN'];
	$FLtable_name = $wpdb->prefix . "bpspro_folder_lock";
	$gmt_offset = get_option( 'gmt_offset' ) * 3600;
	
	switch( $_POST['Submit-Folder-Lock'] ) {
		case __('Submit', 'bulletproof-security'):
		
		$unlock_folders = array();
		$lock_folders = array();		
		
		if ( ! empty($FLFN) ) {
			
			echo $checked;
			
			foreach ( $FLFN as $key => $value ) {
				
				if ( $value == 'unlockfolder' ) {
					$unlock_folders[] = $key;
				
				} elseif ( $value == 'lockfolder' ) {
					$lock_folders[] = $key;
				}
			}
		}
			
		if ( ! empty($unlock_folders) ) {
			
			echo '<div id="message" class="updated" style="background-color:#dfecf2;border:1px solid #999;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';
			
			foreach ( $unlock_folders as $unlock_folder ) {
				
				$FolderLockRows = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $FLtable_name WHERE folder_name = %s", $unlock_folder ) );

				foreach ( $FolderLockRows as $row ) {

					// Added literal CHMOD permissions to compensate for a wierd bug in XAMPP
					if ( $row->curr_perms == '' ) {
						chmod( $row->path, 0755 );
						$update_rows = $wpdb->update( $FLtable_name, array( 'status' => 'Not Locked',  'curr_perms' => '0755' ), array( 'folder_name' => $row->folder_name ) );	
					} elseif ( $row->curr_perms == '0666' ) {
						chmod( $row->path, 0666 );
						$update_rows = $wpdb->update( $FLtable_name, array( 'status' => 'Not Locked' ), array( 'folder_name' => $row->folder_name ) );							
					} elseif ( $row->curr_perms == '0777' ) {
						chmod( $row->path, 0777 );
						$update_rows = $wpdb->update( $FLtable_name, array( 'status' => 'Not Locked' ), array( 'folder_name' => $row->folder_name ) );	
					} elseif ( $row->curr_perms == '0600' ) {
						chmod( $row->path, 0600 );
						$update_rows = $wpdb->update( $FLtable_name, array( 'status' => 'Not Locked' ), array( 'folder_name' => $row->folder_name ) );	
					} elseif ( $row->curr_perms == '0700' ) {
						chmod( $row->path, 0700 );
						$update_rows = $wpdb->update( $FLtable_name, array( 'status' => 'Not Locked' ), array( 'folder_name' => $row->folder_name ) );	
					} elseif ( $row->curr_perms == '0705' ) {
						chmod( $row->path, 0705 );
						$update_rows = $wpdb->update( $FLtable_name, array( 'status' => 'Not Locked' ), array( 'folder_name' => $row->folder_name ) );	
					} elseif ( $row->curr_perms == '0750' ) {
						chmod( $row->path, 0750 );								
						$update_rows = $wpdb->update( $FLtable_name, array( 'status' => 'Not Locked' ), array( 'folder_name' => $row->folder_name ) );
					} elseif ( $row->curr_perms == '0755' ) {
						chmod( $row->path, 0755 );								
						$update_rows = $wpdb->update( $FLtable_name, array( 'status' => 'Not Locked' ), array( 'folder_name' => $row->folder_name ) );

					} else {

						chmod( $row->path, $row->curr_perms );
						$update_rows = $wpdb->update( $FLtable_name, array( 'status' => 'Not Locked' ), array( 'folder_name' => $row->folder_name ) );
					}
					$textUnlock = '<font color="green">'.__('Folder: ', 'bulletproof-security').$row->folder_name.__(' has been Unlocked.', 'bulletproof-security').'</font><br>';
					echo $textUnlock;
				}			
			}
			echo '</p></div>';	
		}

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

			foreach ( $lock_folders as $lock_folder ) {
				
				$FolderLockRows = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $FLtable_name WHERE folder_name = %s", $lock_folder ) );			
				
				foreach ( $FolderLockRows as $row ) {

					chmod( $row->path, 0400 );

					$update_rows = $wpdb->update( $FLtable_name, array( 'status' => 'Locked', 'ulock_time' => time(), 'hlock_time' => current_time('mysql') ), array( 'folder_name' => $row->folder_name ) );
			
					$textLock = '<font color="green">'.__('Folder: ', 'bulletproof-security').$row->folder_name.__(' has been Locked.', 'bulletproof-security').'</font><br>';
					echo $textLock;
				}			
			}
			echo '<strong>'.__('IMPORTANT: When a folder is locked it is no longer usable or accessible to anyone including you. Click the Folder Lock Read Me help button for help information.', 'bulletproof-security').'</strong>';
			echo '</p></div>';
		}
		break;
	} // end Switch
}

	// Folder Lock Form: 12.5: Removed checkboxes for: wp-admin, wp-content and wp-includes so these folders cannot be locked by mistake.
	// Notes: Folder Lock can still be used on a DSO Server API type to lock a folder for protection, but the Lock value for a DSO server should be 755 instead of 400.
	if ( is_admin() && current_user_can('manage_options') ) {
	
		echo '<form name="bpsFolderLockForm" action="'.admin_url( 'admin.php?page=bulletproof-security/admin/lock/flock.php#bps-tabs-2' ).'" method="post">';
		wp_nonce_field('bulletproof_security_folder_lock');

		$FLtable_name = $wpdb->prefix . "bpspro_folder_lock";
		$searchAll = ''; // return all rows
		$getFolderLockTable = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $FLtable_name WHERE folder_name != %s ORDER BY folder_name ASC", "%$searchAll%" ) );
		$source = $_SERVER['DOCUMENT_ROOT'];	
		$gmt_offset = get_option( 'gmt_offset' ) * 3600;

		echo '<div id="FolderLockCheckall" style="max-height:600px;width:100%;overflow:auto;margin:0px 0px 20px 0px;">';
		echo '<table class="widefat" style="margin-bottom:20px;">';
		echo '<thead>';
		echo '<tr>';
		echo '<th scope="col" style="width:15%;font-size:16px;"><strong>'.__('Folder Name', 'bulletproof-security').'</strong></th>';
		echo '<th scope="col" style="width:8%;font-size:16px;"><strong>'.__('Status', 'bulletproof-security').'</strong></th>';
		echo '<th scope="col" style="width:4%;font-size:12px;"><input type="checkbox" class="checkallLock" style="text-align:left;margin-left:2px;" /><br><strong>'.__('Lock', 'bulletproof-security').'</strong></th>';
		echo '<th scope="col" style="width:4%;font-size:12px;"><input type="checkbox" class="checkallUnlock" style="text-align:left;margin-left:2px;" /><br><strong>'.__('Unlock', 'bulletproof-security').'</strong></th>';
		echo '<th scope="col" style="width:8%;font-size:12px;"><strong>'.__('Permissions', 'bulletproof-security').'</strong></th>';
		echo '<th scope="col" style="width:43%;font-size:12px;"><strong>'.__('Hosting Account Root Folder Path', 'bulletproof-security').'</strong></th>';
		echo '<th scope="col" style="width:18%;font-size:12px;"><strong>'.__('Last Modified', 'bulletproof-security').'</strong></th>';
		echo '</tr>';
		echo '</thead>';
		echo '<tbody>';
		echo '<tr>';
		
		if ( is_dir($source) ) {
			$iterator = new DirectoryIterator($source);
			
			$folder_name = array();
			$folder_perms = array();
			$folder_mod = array();									
			$folder_path = array();				
			
			foreach ( $iterator as $files ) {
			
				try {
					if ( $files->isDir() && ! $files->isDot() ) {

						$folder_name[] = $files->getFilename();
						$folder_perms[$files->getFilename()] = substr(sprintf('%o', $files->getPerms()), -4);					
						$folder_path[$files->getFilename()] = $files->getPathname();
						$folder_mod[$files->getFilename()] = date_i18n(get_option('date_format').' '.get_option('time_format'), $files->getMTime() + $gmt_offset);
					}
				} catch (RuntimeException $e) {}
			}			
		}
		
		if ( $wpdb->num_rows != 0 ) {

			foreach ( $getFolderLockTable as $row ) {

				if ( in_array( $row->folder_name, $folder_name ) ) {
					echo '<th scope="row" style="border-bottom:none;">'.$row->folder_name.'</th>';						
				} else {
					echo '<th scope="row" style="border-bottom:none;color:red;font-weight:bold;">'.$row->folder_name.'</th>';					
				}

				if ( $row->status == 'Locked' ) {
					echo '<td style="border-bottom:none;color:red;font-weight:bold;">'.$row->status.'<br><span style="font-size:10px;">'.$row->hlock_time.'</span></td>';
				} else {
					echo '<td style="border-bottom:none;color:green;font-weight:bold;">'.$row->status.'</td>';
				}
		
				if ( $row->folder_name == $bps_wpcontent_dir || $row->folder_name == 'wp-admin' || $row->folder_name == 'wp-includes' ) {
					echo '<td> ----- </td>';
					echo '<td> ----- </td>';
				}
				
				if ( $row->folder_name != $bps_wpcontent_dir && $row->folder_name != 'wp-admin' && $row->folder_name != 'wp-includes' ) {
				
					echo "<td><input type=\"checkbox\" id=\"lockfolder\" name=\"FLFN[$row->folder_name]\" value=\"lockfolder\" class=\"lockfolderALL\" /><br><span style=\"font-size:10px;\">".__('Lock', 'bulletproof-security')."</span></td>";
					echo "<td><input type=\"checkbox\" id=\"unlockfolder\" name=\"FLFN[$row->folder_name]\" value=\"unlockfolder\" class=\"unlockfolderALL\" /><br><span style=\"font-size:10px;\">".__('Unlock', 'bulletproof-security')."</span></td>";
				}
				
				echo '<td style="font-size:11px;"><strong>DB:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>'.$row->curr_perms.'<br>';				
				
				foreach ( $folder_perms as $key => $value ) {
				
					if ( $key == $row->folder_name ) {
						echo '<strong>Actual:&nbsp;</strong>'.$value;
					}
				}
				echo '</td>';					
				
				echo '<td style="font-size:11px;"><strong>DB:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>'.$row->path.'<br>';				
				
					if ( ! is_dir( $row->path ) ) {
						echo '<span style="color:red;font-weight:bold;">Folder Not Found or Deleted</span>';
					}

				foreach ( $folder_path as $key => $value ) {
				
					if ( $key == $row->folder_name ) {
						echo '<strong>Actual:&nbsp;</strong>'.$value;
					}
				}
				echo '</td>';
	
				echo '<td style="font-size:11px;"><strong>DB:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>'.date_i18n(get_option('date_format').' '.get_option('time_format'), $row->last_mod + $gmt_offset).'<br>';		
				
				foreach ( $folder_mod as $key => $value ) {
				
					if ( $key == $row->folder_name ) {
						echo '<strong>Actual:&nbsp;</strong>'.$value;
					}
				}
				echo '</td>';	
				echo '</tr>';		
			}
		}
		
		if ( $wpdb->num_rows == 0 ) {		
			echo '<th scope="row" style="border-bottom:none;">'.__('No Hosting Account Root Folders', 'bulletproof-security').'</th>';
			echo "<td></td>";
			echo "<td></td>";
			echo "<td></td>";
			echo '<td></td>';		
			echo '<td></td>'; 
			echo '<td></td>';		
			echo '</tr>';		
		}
		echo '</tbody>';
		echo '</table>';
		echo '</div>';

		// maybe do a SAPI check and display different confirm messages based on CGI or DSO - would be an entirely duplicated/different submit code.
		echo "<input type=\"submit\" name=\"Submit-Folder-Lock\" value=\"".__('Submit', 'bulletproof-security')."\" class=\"button bps-button\" onclick=\"return confirm('".__('WARNING: Do Not Lock your wp-admin, wp-content or wp-includes folders unless you know exactly what you are doing. Click the Folder Lock Read Me help button for help information.\n\n-------------------------------------------------------------\n\nLocking a folder will set 400 folder permissions for that folder, which means the folder cannot be opened and files cannot be accessed or saved in that folder.\n\nUnlocking a folder will set the folder permissions back to the original folder permissions that were saved in your Folder Lock Database Table for that folder.\n\n-------------------------------------------------------------\n\nClick OK to proceed or click Cancel', 'bulletproof-security')."')\" />&nbsp;&nbsp;<input type=\"button\" name=\"cancel\" value=\"".__('Clear|Refresh', 'bulletproof-security')."\" class=\"button bps-button\" onclick=\"javascript:history.go(0)\" /></form>";
	}

$UIoptions = get_option('bulletproof_security_options_theme_skin');

if ( isset($UIoptions['bps_ui_theme_skin']) && $UIoptions['bps_ui_theme_skin'] == 'blue' ) {
?>
<br />

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($) {
	$( "#FolderLockCheckall tr:odd" ).css( "background-color", "#f9f9f9" );
});
/* ]]> */
</script>

<?php } ?>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($) {
//jQuery(function() {
    $('.checkallLock').click(function() {
        $(this).parents('#FolderLockCheckall:eq(0)').find('.lockfolderALL:checkbox').attr('checked', this.checked);
    });
});
/* ]]> */
</script>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
//jQuery(function() {
    $('.checkallUnlock').click(function() {
        $(this).parents('#FolderLockCheckall:eq(0)').find('.unlockfolderALL:checkbox').attr('checked', this.checked);
    });
});
/* ]]> */
</script>

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

<?php 
} 
?>

</div>

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

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bps-help_faq_table">
  <tr>
    <td class="bps-table_title"><h2><?php _e('Help &amp; 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/video-tutorials/" target="_blank"><?php _e('Video Tutorials', '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>
    </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>