<?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
// 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');

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

// Jetpack Quarantine check
function bps_jetpack_check() {
$filename = WP_CONTENT_DIR . '/bps-backup/quarantine/jetpack.php';
$jetpack = 'jetpack/jetpack.php';
$jetpack_active = in_array( $jetpack, apply_filters('active_plugins', get_option('active_plugins')));

    if ( $jetpack_active == 1 || is_plugin_active_for_network( $jetpack ) ) {

	if ( ! file_exists($filename) ) {
		return;
	}
	
	if ( file_exists($filename) ) {
		echo $bps_topDiv;
		$text = '<font color="#fb0101"><strong>'.__('WARNING!!! Jetpack plugin files have been detected in Quarantine. DO NOT restore Jetpack plugin files from Quarantine. Restoring Jetpack plugin files from Quarantine will crash your website. Delete the Jetpack plugin files from Quarantine and reinstall the Jetpack plugin.', 'bulletproof-security').'</strong></font>';
		echo $text;
		echo $bps_bottomDiv;
	}
	}
}
echo bps_jetpack_check();

$bpsSpacePop = '-------------------------------------------------------------';
// Replace ABSPATH = wp-content/plugins
$bps_plugin_dir = str_replace( ABSPATH, '', WP_PLUGIN_DIR );
// Replace ABSPATH = wp-content
$bps_wpcontent_dir = str_replace( ABSPATH, '', WP_CONTENT_DIR );

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

?>
</div>

<h2 class="bps-tab-title"><?php _e('BulletProof Security Pro ~ Quarantine', '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'); ?>" />
    
<style>
<!--
.bps-spinner {
    visibility:visible;
	position:fixed;
    top:7%;
    left:45%;
 	width:240px;
	background:#fff;
	border:4px solid black;
	padding:2px 0px 4px 8px;   
	z-index:99999;
}
-->
</style> 

    <div id="bps-spinner" class="bps-spinner" style="visibility:hidden;">
    	<img id="bps-img-spinner" src="<?php echo plugins_url('/bulletproof-security/admin/images/bps-spinner.gif'); ?>" style="float:left;margin:0px 20px 0px 0px;" />
        <div id="bps-spinner-text-btn" style="padding:20px 0px 26px 0px;font-size:14px;">Processing...<br><button style="margin:10px 0px 0px 10px;" onclick="javascript:history.go(-1)">Cancel</button>
		</div>
    </div> 
    
<script type="text/javascript">
/* <![CDATA[ */
function QSortSearch() {

    var r = confirm("View File Option: Selecting the View File Checkbox Form option will display the contents of the quarantined file that you have selected to view.\n\n-------------------------------------------------------------\n\nRestore File Option: Selecting the Restore File Checkbox Form option does 3 things: 1. Copies the quarantined file to the autorestore backup folder and overwrites the backed up copy of the file. 2. Moves the file out of quarantine to the original source path where the file was quarantined from and overwrites the file that was autorestored. 3. Deletes the database entry for the quarantined file.\n\n-------------------------------------------------------------\n\nDelete File Option: Selecting the Delete File Checkbox Form option does 2 things: 1. Deletes the file permanently from the Quarantine folder. 2. Deletes the database entry for the quarantined file.\n\n-------------------------------------------------------------\n\nClick OK to proceed or click Cancel.");
	var img = document.getElementById("bps-spinner"); 	
	
	if (r == true) {

		img.style.visibility = "visible";
	
	} else {
	
		history.go(-1);
	}
}
/* ]]> */
</script>     
    
<script type="text/javascript">
/* <![CDATA[ */
function QStandard() {
	
    var r = confirm("View File Option: Selecting the View File Checkbox Form option will display the contents of the quarantined file that you have selected to view.\n\n-------------------------------------------------------------\n\nRestore File Option: Selecting the Restore File Checkbox Form option does 3 things: 1. Copies the quarantined file to the autorestore backup folder and overwrites the backed up copy of the file. 2. Moves the file out of quarantine to the original source path where the file was quarantined from and overwrites the file that was autorestored. 3. Deletes the database entry for the quarantined file.\n\n-------------------------------------------------------------\n\nDelete File Option: Selecting the Delete File Checkbox Form option does 2 things: 1. Deletes the file permanently from the Quarantine folder. 2. Deletes the database entry for the quarantined file.\n\n-------------------------------------------------------------\n\nClick OK to proceed or click Cancel.");
	var img = document.getElementById("bps-spinner"); 	
	
	if (r == true) {

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

    </div>
		<ul>
			<li><a href="#bps-tabs-1"><?php _e('Quarantine', 'bulletproof-security'); ?></a></li>
            <li><a href="#bps-tabs-2"><?php _e('Quarantine Log', '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">

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bps-help_faq_table">
  <tr>
    <td class="bps-table_title"><h2><?php _e('Quarantine', 'bulletproof-security'); ?></h2></td>
  </tr>
  <tr>
    <td class="bps-table_cell_help">

<h3 style="margin:0px 0px 5px 0px;"><?php _e('Quarantine', '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('Quarantine', 'bulletproof-security'); ?>">
	<p>
	<?php
        $text = '<strong>'.__('This Read Me Help window is draggable (top) and resizable (bottom right corner)', 'bulletproof-security').'</strong><br><br>';
		echo $text; 
		// Forum Help Links or of course both
		$text = '<strong><font color="blue">'.__('Forum Help Links: ', 'bulletproof-security').'</font></strong><br>'; 	
		echo $text;	
	?>
	<strong><a href="https://forum.ait-pro.com/forums/topic/autorestore-quarantine-guide-read-me-first/#quarantine-sort" title="Quarantine Sort|Search & Troubleshooting" target="_blank"><?php _e('Quarantine Sort|Search & Troubleshooting', 'bulletproof-security'); ?></a></strong><br />
	<strong><a href="https://forum.ait-pro.com/forums/topic/xternal-tools-xtf-guide/" title="Xternal Tools (XTF) Guide" target="_blank"><?php _e('Xternal Tools (XTF) Guide', 'bulletproof-security'); ?></a></strong><br /><br />
	
	<?php $text = '<strong>'.__('Quarantine General Concept', 'bulletproof-security').'</strong><br>'.__('The Quarantine folder is located in an isolated .htaccess protected directory that cannot be accessed by anyone other than you. When a file has been autorestored by the ARQ Cron, a copy of that modified file that was autorestored is sent to Quarantine before it was autorestored. This allows you to restore the modified file that is in quarantine and overwrite the autorestored file. Or in other words restoring a file from Quarantine is an Undo.', 'bulletproof-security').'<br><br><font color="#fb0101"><strong>'.__('A file has been sent to Quarantine: ', 'bulletproof-security').'</strong></font><br>'.__('If you received a BPS Pro Quarantine email Alert and have confirmed that a hacker\'s file was quarantined then you need to change all of your passwords as quickly as possible. See the help section below: Steps To Take When a Hacker\'s File Has Been Quarantined. If you do not know whether or not a file in Quarantine is a hacker file or not then select the Quarantine View File Checkbox Form option for that file and click the Submit button. Copy the contents of the file you are viewing into an email and send it to info@ait-pro.com with "Quarantine Help - is this hacker code?" in the Subject line of the email.', 'bulletproof-security').'<br><br><font color="blue"><strong>'.__('Important Note: ', 'bulletproof-security').'</strong></font><br>'.__('If you use a Select All checkbox for any table column (either Restore File or Delete File) then all files in Quarantine will use that Select All checkbox setting.  If you want to restore and delete files at the same time DO NOT use the Select All checkbox for either of the table columns and instead check individual checkboxes. Example scenario: you have 1 file in Quarantine that you want to restore and you want to delete all the other files in Quarantine. The best way to do this would be to restore the file you want to restore first and then after that file is restored you can click the Select All checkbox for the Delete Files table column. You can of course restore and delete files at the same time as long as a Select All checkbox is not checked for either table column.', 'bulletproof-security').'<br><br><font color="blue"><strong>'.__('Steps To Take When a Hacker\'s File Has Been Quarantined: ', 'bulletproof-security').'</strong></font><br>'.__('Change your WordPress password first, next change your FTP password, next change your WordPress Database password. To change your WordPress database password you will need to change the DB password in 2 places: your web host control panel using phpMyAdmin and also in your wp-config.php file. For good measure it is also recommended that you change your web host control panel login password.', 'bulletproof-security').'<br><br><strong>'.__('NOTES: ', 'bulletproof-security').'</strong>'.__('If a new file is uploaded to your website and a copy of that uploaded file does not exist in backup then that file is sent to Quarantine. If there are no files in Quarantine the Quarantine Checkbox Form will display an empty table with this displayed message - No Files in Quarantine. If there are files in Quarantine the Quarantine Checkbox Form will display the file name, the time the file was quarantined, the source path where the file was quarantined from and Checkbox Form options: 1. View File, 2. Restore File or 3. Delete File. The Restore File option allows you to quickly and easily restore a file if it needs to be restored. Restore File and Delete File have Select All Checkboxes located above the Restore File and Delete File Column text.', 'bulletproof-security').'<br><br><strong>'.__('NOTE: ', 'bulletproof-security').'</strong>'.__('The Quarantine Log logs the specific details about the action that was taken when a file is sent to Quarantine. View the Quarantine Log Read Me button for specific details about the Quarantine Log.', 'bulletproof-security').'<br><br><strong>'.__('NOTE: ', 'bulletproof-security').'</strong>'.__('It is recommended that you first use the View File Checkbox Form option before choosing to restore or delete a file in Quarantine.', 'bulletproof-security').'<br><br><strong>'.__('Quarantine Sort|Search and Troubleshooting: ', 'bulletproof-security').'<br>'.__('See the Forum Help Links at the top of this Read Me help window for examples of how to use the Sort|Search feature: ', 'bulletproof-security').'</strong><br>'.__('The Quarantine Sort|Search feature allows you to sort files by plugin folder name or theme folder name or other folder name and either restore or delete all of these files. If the total number of files in Quarantine exceeds 200, an error message will be displayed with a link to forum help information. If 200 files have been sent to Quarantine this usually means that an error or problem occurred and excessive files have been quarantined. Try restoring all files in Quarantine first. If all files cannot be restored at the same time, click the Quarantine Sort|Search and Troubleshooting link at the top of this Read Me help window for step by step instructions on how to fix this using the Quarantine Sort|Search feature or BPS Pro Xternal Tools (XTF) Form or manually copying folders and files from the Quarantine folder back to where the folders and files were quarantined from.', 'bulletproof-security').'<br><br><strong>'.__('View File Option: ', 'bulletproof-security').'</strong><br>'.__('Selecting the View File Checkbox Form option will display the contents of the quarantined file that you have selected to view.', 'bulletproof-security').'<br><br><strong>'.__('Restore File Option: ', 'bulletproof-security').'</strong><br>'.__('Selecting the Restore File Checkbox Form option does 3 things: 1. Copies the quarantined file to the autorestore backup folder and overwrites the backed up copy of the file. 2. Moves the file out of quarantine to the original source path where the file was quarantined from and overwrites the file that was autorestored. 3. Deletes the database entry for the quarantined file.', 'bulletproof-security').'<br><br><strong>'.__('NOTE: ', 'bulletproof-security').'</strong>'.__('If you create a new folder with new files or upload a new folder with files in it to your website then using the Restore File option will NOT create that new folder in your autorestore backup folder for security reasons. You can restore the file, but the file or files in that new folder will continue to be quarantined because they will be seen as illegitimate website files based on the fact that the folder name does not exist in autorestore backup. To correct this issue turn Off the ARQ Cron, add your new folder and upload your new files and then click the appropriate Backup Files button on the AutoRestore|Quarantine Settings page if this new folder and files are WordPress files. Or if this new folder and files are non-WordPress files then use Add Folders & Files form on the AutoRestore Add|Exclude Files page to add this new folder and files to backup, then turn the ARQ Cron back On.', 'bulletproof-security').'<br><br><strong>'.__('Delete File Option: ', 'bulletproof-security').'</strong><br>'.__('Selecting the Delete File Checkbox Form option does 2 things: 1. Deletes the file permanently from the Quarantine folder. 2. Deletes the database entry for the quarantined file.', 'bulletproof-security').'<br><br><strong>'.__('Exclude Folders|Files from being checked by AutoRestore', 'bulletproof-security').'</strong><br>'.__('You can exclude folders and files from being checked by AutoRestore and quarantined using this tool. This tool and other folder and file tools are available on the AutoRestore Add|Exclude Other Folders & Files tab page. You can remove folder and file exclusions on the AutoRestore Add|Exclude Other Folders & Files tab page. You cannot exclude folders or files that you have added using the AutoRestore Add Folders & Files tool. Added folders and files is an independent AutoRestore feature. See the AutoRestore Add|Exclude Other Folders & Files Read Me help button for more information.', 'bulletproof-security').'<br><br><strong>'.__('Important Notes:', 'bulletproof-security').'</strong><br>'. 
__('1. This tool is for excluding folder and files that you do not want AutoRestore to check permanently. If you were manually editing or uploading a file and it was quarantined then just restore the file in Quarantine instead of excluding the file. Example: If you were manually editing a theme file and this is a rare event then just restore the theme file. If you will be working on the theme file on an ongoing basis then exclude the theme file. The same logic applies to folders. If you are going to be working on files in a particular folder on an ongoing basis then exclude the folder, otherwise just restore any files that were quarantined if this is not going to be a regular ongoing event.', 'bulletproof-security').'<br><br>'.__('2. Files MUST be restored from Quarantine FIRST before excluding folders or files.', 'bulletproof-security').'<br><br>'.__('3. If you are excluding a wp-content root folder it is better to use the AutoRestore Exclude wp-content Folders tool. Example wp-content root folder:  /wp-content/some-folder.  The AutoRestore Exclude wp-content Folders tool is located on the BPS Pro AutoRestore page.', 'bulletproof-security').'<br><br><strong>'.__('Exclude Folders|Files Options & Examples', 'bulletproof-security').'</strong><br><br><strong>'.__('Exclude An Individual File option', 'bulletproof-security').'</strong><br>'.__('Select the Exclude An Individual File option to exclude individual files from being checked by AutoRestore. Example Use: Your host server updates a default server php error log file called: error_log and the error_log file is being repeatedly quarantined. /', 'bulletproof-security').$bps_wpcontent_dir.__('/error_log. Because the error_log log file is being updated regularly the ARQ Cron will autorestore and quarantine that log file each time the file changes. To exclude that log file from being checked by the ARQ Cron you would select the Exclude An Individual File option and enter the path to the file that you want excluded in the Enter a folder or file path to exclude text box and click the Exclude Folder|File button.', 'bulletproof-security').'<br><br><strong>'.__('Exclude A Specific Folder option - creates exclude rules for all files in a specific folder', 'bulletproof-security').'</strong><br>'.__('Excluding a specific folder can be used for excluding all files in a specific folder ONLY - no files in any subfolders of that specific folder will be excluded from being checked by AutoRestore. Example: You have a subfolder named /', 'bulletproof-security').$bps_wpcontent_dir.__('/example-folder/example-subfolder and you want to exclude all files in the /example-subfolder folder from being checked by the ARQ Cron. You would select the Exclude A Specific Folder option and enter this path in the Enter an Exclude Folder or File Path text box - /xxxxx/xxxxx/', 'bulletproof-security').$bps_wpcontent_dir.__('/example-folder/example-subfolder. By excluding only the specific /example-subfolder folder ONLY files in that folder will be excluded from being checked by the ARQ Cron. Any files in the parent folder /xxxxx/xxxxx/', 'bulletproof-security').$bps_wpcontent_dir.__('/example-folder will NOT be excluded from being checked by the ARQ Cron.', 'bulletproof-security').'<br><br><strong>'.__('Exclude Top Level Folder option - creates exclude rules for all files in all folders (top level and subfolders)', 'bulletproof-security').'</strong><br>'.__('Excluding a Top Level Folder means that all files in the folder that you exclude and all files in the subfolders of that folder will be excluded from being checked by the ARQ Cron. Typically you should only need to exclude individual files that are repeatedly quarantined by the ARQ Cron, but if you are modifying several files in a folder then you could use this option to exclude the entire folder while you are modifying files in that folder and then use the AutoRestore Remove Excluded Folders|Files Search tool to remove the files from being excluded by the ARQ Cron check. Example: You are modifying several of your Theme files. You have a Top Level Theme Folder named /xxxxx/xxxxx/', 'bulletproof-security').$bps_wpcontent_dir.__('/themes/my-theme and you want to exclude all subfolders and files from being checked by the ARQ Cron while you are modifying your Theme files. You would select the Exclude Top Level Folder option and then enter the folder path to this folder /xxxxx/xxxxx/', 'bulletproof-security').$bps_wpcontent_dir.__('/themes/my-theme in the Enter an Exclude Folder or File Path text box and click the Exclude Folder|File button. After you are done modifying your Theme files you would FIRST backup your files by going to the AutoRestore|Quarantine Settings page and clicking the Backup Files button for the wp-content folder and then use the AutoRestore Remove Excluded Folders|Files Search tool to find and remove these files from being excluded from the ARQ Cron check.', 'bulletproof-security'); 
echo $text; ?></p>

</div>

<?php
// Form Quarantine Exclude Folders & Files - Add Excluded WordPress file paths to DB - DB row entry is source path, not backup path
if ( ! isset( $_POST['Submit-Quarantine-Exclude'] ) )
    $chosenQuarantineExclude = array(0);
	
	else
    
	if ( isset( $_POST['Submit-Quarantine-Exclude'] ) && current_user_can('manage_options') ) {
		check_admin_referer( 'bulletproof_security_quarantine_exclude' );   
	    $chosenQuarantineExclude = $_POST['QuarantineExclude'];
		global $wpdb;

		$source = trim( stripslashes( $_POST['quarantine-source-path-exclude'] ) );
		$table_name = $wpdb->prefix . "bpspro_arq_exclude";
		
	if ( $_POST['QuarantineExclude'] == array(0) ) {
		
		echo '<div id="message" class="updated" style="background-color:#dfecf2;border:1px solid #999;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';
		$text = '<font color="#fb0101"><strong>'.__('Error: You did not select a Folder or File Exclude Option.', 'bulletproof-security').'</strong></font>';
		echo $text;
		echo '</p></div>';
	}

	if ( $_POST['QuarantineExclude'] == array(1) ) {
		
		if ( is_dir($source) ) {
		$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
		
		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 ( $iterator as $file ) {
			if ( $file->isDir() ) {
				// no need to add directory paths ONLY file paths are needed
			} else {
				$rows_affected = $wpdb->insert( $table_name, array( 'time' => current_time('mysql'), 'arq_exclude_source' => $file ) );
			}
		}
		$text = '<font color="green">'.$source.__(' folder and all subfolders and files have been Excluded successfully.', 'bulletproof-security').'</font>';
		echo $text;
		echo '</p></div>';
		
		} else {
			
			echo '<div id="message" class="updated" style="background-color:#dfecf2;border:1px solid #999;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';
			$text = '<font color="#fb0101"><strong>'.$source.__(' is not a valid folder path.', 'bulletproof-security').'</strong></font>';
		echo $text;
		echo '</p></div>';
		}	
	}
		
		if ( $_POST['QuarantineExclude'] == array(2) ) {
		
		if ( is_dir($source) ) {
		$iterator = new DirectoryIterator($source);

		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 ( $iterator as $file ) {
			if ( $file->isFile() ) {
				$rows_affected = $wpdb->insert( $table_name, array( 'time' => current_time('mysql'), 'arq_exclude_source' => $source.DIRECTORY_SEPARATOR.$file ) );
			}
			
		}
		$text = '<font color="green">'.$source.__(' folder and all files in this folder have been Excluded successfully.', 'bulletproof-security').'</font>';
		echo $text;
		echo '</p></div>';
		
		} else {
			
			echo '<div id="message" class="updated" style="background-color:#dfecf2;border:1px solid #999;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';
			$text = '<font color="#fb0101"><strong>'.$source.__(' is not a valid folder path.', 'bulletproof-security').'</strong></font>';
		echo $text;
		echo '</p></div>';
		}	
	}
		
		if ( $_POST['QuarantineExclude'] == array(3) ) {
		
		if ( file_exists($source) ) {
			$rows_affected = $wpdb->insert( $table_name, array( 'time' => current_time('mysql'), 'arq_exclude_source' => $source ) );
			echo '<div id="message" class="updated" style="background-color:#dfecf2;border:1px solid #999;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';
			$text = '<font color="green">'.$source.__(' has been Excluded successfully and will NOT be checked by AutoRestore.', 'bulletproof-security').'</font>';
		echo $text;
		echo '</p></div>';
		
		} else {
			
			echo '<div id="message" class="updated" style="background-color:#dfecf2;border:1px solid #999;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';
			$text = '<font color="#fb0101"><strong>'.$source.__(' is not a valid file path.', 'bulletproof-security').'</strong></font>';
		echo $text;
		echo '</p></div>';
		}
		} // end array 3
} // end if isset

// Dropdown list array for Quarantine Folder|File Exclude Form		
function bpsPro_exclude_folder_form_options($array, $active, $echo=true) {
	$string = '';
	foreach ( $array as $k => $v ) {
	if ( is_array($active) )
	$s = ( in_array($k, $active) ) ? ' selected="selected"' : '';
	else
	$s = ( $active == $k ) ? ' selected="selected"' : '';
	$string .= '<option value="'.$k.'"'.$s.'>'.$v.'</option>'."\n";
	}
	if ($echo)   echo $string;
	else        return $string;
}

$QuarantineExclude = array(' Select Folder or File Exclude Option:', 'Exclude Top Level Folder - All Subfolders & All Files Are Excluded', 'Exclude A Specific Folder - All Files In A Specific Folder Are Excluded', 'Exclude An Individual File - A Single File Is Excluded');

$file_folder_path = ( isset( $_POST['quarantine-source-path-exclude'] ) ) ? $_POST['quarantine-source-path-exclude'] : 'Enter a folder or file path to exclude';

?>

<div id="bpsARQCronExclude" style="margin:10px 0px 0px 0px;">
<style>
<!--
select#QuarantineExclude.form-340{vertical-align:top;}
-->
</style>

<form name="Quarantine-Exclude" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/quarantine/quarantine.php' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_quarantine_exclude'); ?>
	
    <strong><label for="arq-add"><?php _e('Exclude Folders|Files from being checked by AutoRestore', 'bulletproof-security'); ?> </label></strong><br />
    <select name="QuarantineExclude[]" id="QuarantineExclude" class="form-340" >
	<?php echo bpsPro_exclude_folder_form_options($QuarantineExclude, $chosenQuarantineExclude, true); ?>
	</select>
    
    <input type="text" name="quarantine-source-path-exclude" class="regular-text-340" style="background-color:#FFFFFF;font-size:14px;" placeholder="Enter a folder or file path to exclude" value="<?php echo trim( $file_folder_path, ", \t\n\r\/" ); ?>" onfocus="this.value=''" />
    
    <input type="submit" name="Submit-Quarantine-Exclude" value="<?php esc_attr_e('Exclude Folder|File', 'bulletproof-security') ?>" class="button bps-button" onclick="return confirm('<?php $text = __('Clicking OK will exclude folders and files from being checked by AutoRestore for whatever path you entered in the "Enter a folder or file path to exclude" text box.', 'bulletproof-security').'\n\n'.__('To remove folders and files from being excluded from the AutoRestore Cron check, use the Remove Excluded Folders|Files Search tool on the AutoRestore - Add|Exclude Other Folders & Files page.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Exclude the folder or file or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
    </div>
</form>

</div>

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

// Quarantine Standard/Default Form Proccessing - View, Restore or Delete Files
if ( isset( $_POST['Submit-ARQ-Quarantine-Radio'] ) && current_user_can('manage_options') ) {
	check_admin_referer('bulletproof_security_arq_quarantine');
	
	$qradio = $_POST['qradio'];
	$bpspro_arq_quarantine_table = $wpdb->prefix . "bpspro_arq_quarantine";
	
	switch( $_POST['Submit-ARQ-Quarantine-Radio'] ) {
		case __('Submit', 'bulletproof-security'):
		
		$delete_files = array();
		$restore_files = array();
		$view_files = array();		
		
		if ( ! empty($qradio) ) {
			
			foreach ( $qradio as $key => $value ) {
				
				if ( $value == 'deletefile' ) {
					$delete_files[] = $key;
				
				} elseif ( $value == 'restorefile' ) {
					$restore_files[] = $key;
				
				} elseif ( $value == 'viewfile' ) {
					$view_files[] = $key;
				}
			}
		}
			
		if ( ! empty($delete_files) ) {
			
			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 ( $delete_files as $delete_file ) {
				
				$QuarantineRows = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $bpspro_arq_quarantine_table WHERE arq_quarantine_qpath = %s", $delete_file) );
			
				foreach ( $QuarantineRows as $row ) {
					$path_parts = pathinfo($row->arq_quarantine_qpath);
					$filename = $path_parts['basename'];
					
					if ( file_exists($row->arq_quarantine_qpath) ) {
						@unlink($row->arq_quarantine_qpath);
						
						$delete_row = $wpdb->query( $wpdb->prepare( "DELETE FROM $bpspro_arq_quarantine_table WHERE arq_quarantine_qpath = %s", $delete_file));
					
						$textDelete = '<font color="green">'.$filename.__(' has been deleted from Quarantine.', 'bulletproof-security').'</font><br>';
						echo $textDelete;
					}
				}
			}
			echo '</p></div>';	
		}
		
		if ( ! empty($restore_files) ) {
			
			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 ( $restore_files as $restore_file ) {
				
				$QuarantineRows = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $bpspro_arq_quarantine_table WHERE arq_quarantine_source = %s", $restore_file) );
			
				foreach ( $QuarantineRows as $row ) {
					$path_parts = pathinfo($row->arq_quarantine_qpath);
					$filename = $path_parts['basename'];
					
					if ( file_exists($row->arq_quarantine_qpath) ) {
						@copy($row->arq_quarantine_qpath, $row->arq_quarantine_backup);				
						@rename($row->arq_quarantine_qpath, $row->arq_quarantine_source);
						
						if ( preg_match( '/(.*)\/autorestore\/added-files\/(.*)/', $row->arq_quarantine_backup ) ) {
							
							$arq_add_table = $wpdb->prefix . "bpspro_arq_add";
	
							$AddFilesRows = '';
							$AddFilesTableRows = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $arq_add_table WHERE arq_add_source != %s", $AddFilesRows ) );
					
							$arq_add_source_array = array();
							
							foreach ( $AddFilesTableRows as $arq_add_row ) {
								
								$arq_add_source_array[] = $arq_add_row->arq_add_source;
							}
								
							if ( ! in_array( $row->arq_quarantine_source, $arq_add_source_array ) ) {
								
								$rows_affected = $wpdb->insert( $arq_add_table, array( 'arq_add_type' => 'q-restore', 'arq_add_time' => current_time('mysql'), 'arq_add_dir' => dirname($row->arq_quarantine_source), 'arq_add_source' => $row->arq_quarantine_source, 'arq_add_backup' => str_replace( array( '\\\\', '\\'), '/', $row->arq_quarantine_backup ) ) );
							}							
						}						
						
						$delete_row = $wpdb->query( $wpdb->prepare( "DELETE FROM $bpspro_arq_quarantine_table WHERE arq_quarantine_source = %s", $restore_file));
					
						$textRestore = '<font color="green">'.$filename.__(' has been restored to ', 'bulletproof-security').$row->arq_quarantine_source.'</font><br>';
						echo $textRestore;					
					}
				}			
			}
			echo '</p></div>';	
		}

		if ( ! empty($view_files) ) {
			
			echo '<div id="message" style="margin:25px 0px 15px 0px;padding:0px 10px 0px 10px;background-color:#dfecf2;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';

			foreach ( $view_files as $view_file ) {
				
				$QuarantineRows = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $bpspro_arq_quarantine_table WHERE arq_quarantine_qpath = %s", $view_file) );
			
				foreach ( $QuarantineRows as $row ) {
					$path_parts = pathinfo($row->arq_quarantine_qpath);
					$filename = $path_parts['basename'];
					$Qcontents = file_get_contents($row->arq_quarantine_qpath);

					$textViewClose = '<font color="green"><strong>'.__('Viewing File: ', 'bulletproof-security').$filename.'</strong></font><br><div style="width:60px;margin:-12px 0px 5px 0px;padding:2px 6px 2px 6px;background-color:#e8e8e8;border:1px solid gray;"><a href="'.admin_url( 'admin.php?page=bulletproof-security/admin/quarantine/quarantine.php' ).'" style="font-size:1.13em;text-decoration:none;">'.__('Close File', 'bulletproof-security').'</a></div><pre>'.htmlspecialchars($Qcontents).'</pre>';
					echo $textViewClose;
				}			
			}
			echo '</p></div>';			
		}
		break;
	} // end Switch
}

// Quarantine Sort/Search Form Processing - View, Restore or Delete Files
if ( isset( $_POST['Submit-Quarantine-Search-Radio'] ) && current_user_can('manage_options') ) {
	check_admin_referer('bulletproof_security_quarantine_search');
	
	$qradio = $_POST['qradio'];
	$bpspro_arq_quarantine_table = $wpdb->prefix . "bpspro_arq_quarantine";
	
	switch( $_POST['Submit-Quarantine-Search-Radio'] ) {
		case __('Submit', 'bulletproof-security'):
		
		$delete_files = array();
		$restore_files = array();
		$view_files = array();		
		
		if ( ! empty($qradio) ) {
			
			foreach ( $qradio as $key => $value ) {
				
				if ( $value == 'deletefile' ) {
					$delete_files[] = $key;
				
				} elseif ( $value == 'restorefile' ) {
					$restore_files[] = $key;
				
				} elseif ( $value == 'viewfile' ) {
					$view_files[] = $key;
				}
			}
		}
			
		if ( ! empty($delete_files) ) {
			
			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 ( $delete_files as $delete_file ) {
				
				$QuarantineRows = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $bpspro_arq_quarantine_table WHERE arq_quarantine_qpath = %s", $delete_file) );
			
				foreach ( $QuarantineRows as $row ) {
					$path_parts = pathinfo($row->arq_quarantine_qpath);
					$filename = $path_parts['basename'];
					
					if ( file_exists($row->arq_quarantine_qpath) ) {
						@unlink($row->arq_quarantine_qpath);
						
						$delete_row = $wpdb->query( $wpdb->prepare( "DELETE FROM $bpspro_arq_quarantine_table WHERE arq_quarantine_qpath = %s", $delete_file) );

						$textDelete = '<font color="green">'.$filename.__(' has been deleted from Quarantine.', 'bulletproof-security').'</font><br>';
						echo $textDelete;
					}
				}
			}
			echo '</p></div>';	
		}
		
		if ( ! empty($restore_files) ) {

			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 ($restore_files as $restore_file) {
				
				$QuarantineRows = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $bpspro_arq_quarantine_table WHERE arq_quarantine_source = %s", $restore_file) );
			
				foreach ( $QuarantineRows as $row ) {
					$path_parts = pathinfo($row->arq_quarantine_qpath);
					$filename = $path_parts['basename'];

					if ( file_exists($row->arq_quarantine_qpath) ) {
						@copy($row->arq_quarantine_qpath, $row->arq_quarantine_backup);				
						@rename($row->arq_quarantine_qpath, $row->arq_quarantine_source);
					
						if ( preg_match( '/(.*)\/autorestore\/added-files\/(.*)/', $row->arq_quarantine_backup ) ) {
							
							$arq_add_table = $wpdb->prefix . "bpspro_arq_add";
	
							$AddFilesRows = '';
							$AddFilesTableRows = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $arq_add_table WHERE arq_add_source != %s", $AddFilesRows ) );
					
							$arq_add_source_array = array();
							
							foreach ( $AddFilesTableRows as $arq_add_row ) {
								
								$arq_add_source_array[] = $arq_add_row->arq_add_source;
							}
								
							if ( ! in_array( $row->arq_quarantine_source, $arq_add_source_array ) ) {
								
								$rows_affected = $wpdb->insert( $arq_add_table, array( 'arq_add_type' => 'q-restore', 'arq_add_time' => current_time('mysql'), 'arq_add_dir' => dirname($row->arq_quarantine_source), 'arq_add_source' => $row->arq_quarantine_source, 'arq_add_backup' => str_replace( array( '\\\\', '\\'), '/', $row->arq_quarantine_backup ) ) );
							}							
						}						
						
						$delete_row = $wpdb->query( $wpdb->prepare( "DELETE FROM $bpspro_arq_quarantine_table WHERE arq_quarantine_source = %s", $restore_file));
						
						$textRestore = '<font color="green">'.$filename.__(' has been restored to ', 'bulletproof-security').$row->arq_quarantine_source.'</font><br>';
						echo $textRestore;					
					}
				}			
			}
			echo '</p></div>';	
		}

		if ( ! empty($view_files) ) {
			
			echo '<div id="message" style="margin:25px 0px 15px 0px;padding:0px 10px 0px 10px;background-color:#dfecf2;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);-moz-box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);box-shadow: 3px 3px 5px -1px rgba(153,153,153,0.7);"><p>';

			foreach ($view_files as $view_file) {
				
				$QuarantineRows = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $bpspro_arq_quarantine_table WHERE arq_quarantine_qpath = %s", $view_file) );
			
				foreach ( $QuarantineRows as $row ) {
					$path_parts = pathinfo($row->arq_quarantine_qpath);
					$filename = $path_parts['basename'];
					$Qcontents = file_get_contents($row->arq_quarantine_qpath);
				
					$textViewClose = '<font color="green"><strong>'.__('Viewing File: ', 'bulletproof-security').$filename.'</strong></font><br><div style="width:60px;margin:-12px 0px 5px 0px;padding:2px 6px 2px 6px;background-color:#e8e8e8;border:1px solid gray;"><a href="'.admin_url( 'admin.php?page=bulletproof-security/admin/quarantine/quarantine.php' ).'" style="font-size:1.13em;text-decoration:none;">'.__('Close File', 'bulletproof-security').'</a></div><pre>'.htmlspecialchars($Qcontents).'</pre>';					
					echo $textViewClose;
				}			
			}
			echo '</p></div>';	
		}
		break;
	} // end Switch
}

function bpsQDBRowCount() {
global $wpdb;
	$bpspro_Qtable = $wpdb->prefix . "bpspro_arq_quarantine";
	$id = '0';

	$DB_row_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $bpspro_Qtable WHERE id != %d", $id ) );

	echo '<div id="QuarantineDBRowCount" style="position:relative;left:0px;top:25px;color:#2ea2cc;font-weight:bold;font-size:13px;width:70%;">';

	if ( isset( $_POST['Submit-Quarantine-Search'] ) ) {
		
		$search_string = $_POST['QSearch'];
		$DB_row_count_search = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $bpspro_Qtable WHERE arq_quarantine_source LIKE %s", "%$search_string%" ) );
		$text = "{$DB_row_count_search}".__(' out of ', 'bulletproof-security')."{$DB_row_count}".__(' Quarantined files are currently being displayed', 'bulletproof-security');
		echo $text;
	
	} else {
	
		if ( ! isset( $_POST['Submit-Quarantine-Search-Radio'] ) ) {
		
			if ( $DB_row_count > 200 ) {

				$text = '<font color="#fb0101" style="font-size:14px;">'.__('Total number of Quarantined Files: ', 'bulletproof-security')."{$DB_row_count}".'</font><br>'.__('If 200+ files have been sent to Quarantine this usually means that an error or problem occurred and excessive files have been quarantined. Try restoring all files in Quarantine first. If all files cannot be restored at the same time, click the link below for step by step instructions on how to restore files using the Quarantine Sort|Search feature or Xternal Tools or manually copying folders and files from the Quarantine folder back to where the folders and files were quarantined from.', 'bulletproof-security').'<br><a href="https://forum.ait-pro.com/forums/topic/autorestore-quarantine-guide-read-me-first/#quarantine-sort" target="_blank" title="Link opens in a new Browser window" style="color:#2ea2cc;">'.__('Quarantine Sort|Search feature, Xternal Tools, Manually Copy Files', 'bulletproof-security').'</a>';
				echo $text;				

			} else {
		
				$text = __('Total number of Quarantined Files: ', 'bulletproof-security')."{$DB_row_count}";
				echo $text;	
			}
		}
	}
	echo '</div>';
}
bpsQDBRowCount();

	// DB Quarantine Sort/Search Form - search all DB values/fields - top was 240px
	// 11.3: late Firefox CSS/div bugfix
	echo '<div id="QSortSearch" style="">';
	echo '<form name="QuarantineSearchForm" action="'.admin_url( 'admin.php?page=bulletproof-security/admin/quarantine/quarantine.php' ).'" method="post">';
	wp_nonce_field('bulletproof_security_quarantine_search');
	echo '<input type="text" name="QSearch" class="regular-text-short-fixed" style="margin:0px 5px 0px 0px; "value="" />';
	echo '<input type="submit" name="Submit-Quarantine-Search" value="'.esc_attr__('Sort|Search', 'bulletproof-security').'" class="button bps-button" />';
	echo '</form>';
	echo '</div>';
	echo '<div style="clear:both;"></div>';

// Quarantine Sort/Search Form
if ( isset( $_POST['Submit-Quarantine-Search'] ) && current_user_can('manage_options') ) {
	check_admin_referer('bulletproof_security_quarantine_search');
	
	$filename = '';
	$bpspro_arq_quarantine_table = $wpdb->prefix . "bpspro_arq_quarantine";
	$search_string = $_POST['QSearch'];
	$getQuarantineTable = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $bpspro_arq_quarantine_table WHERE arq_quarantine_source LIKE %s", "%$search_string%") );
	
	echo '<form name="bpsQuarantineDBRadioSearch" action="'.admin_url( 'admin.php?page=bulletproof-security/admin/quarantine/quarantine.php' ).'" method="post">';
	wp_nonce_field('bulletproof_security_quarantine_search');

		echo '<div id="ARQcheckall" style="">';
		echo '<table class="widefat" style="margin-bottom:20px;">';
		echo '<thead>';
		echo '<tr>';
		echo '<th scope="col" style="width:20%;"><strong>'.__('Filename', 'bulletproof-security').'</strong></th>';
		echo '<th scope="col" style="width:7%;"><br><strong>'.__('View<br>File', 'bulletproof-security').'</strong></th>';
		echo '<th scope="col" style="width:7%;"><input type="checkbox" class="checkallRestore" style="text-align:left; margin-left:2px;" /><br><strong>'.__('Restore<br>File', 'bulletproof-security').'</strong></th>';
		echo '<th scope="col" style="width:7%;"><input type="checkbox" class="checkallDelete" style="text-align:left; margin-left:2px;" /><br><strong>'.__('Delete<br>File', 'bulletproof-security').'</strong></th>';
		echo '<th scope="col" style="width:49%;"><strong>'.__('Source Path - File was Quarantined from this location', 'bulletproof-security').'</strong><br>'.__('The file will be restored to this location if Restore File is selected').'</th>';
		echo '<th scope="col" style="width:10%;"><strong>'.__('Quarantine<br>Time', 'bulletproof-security').'</strong></th>';
		echo '</tr>';
		echo '</thead>';
		echo '<tbody>';
		echo '<tr>';
		
		foreach ( $getQuarantineTable as $row ) {
			$path_parts = pathinfo($row->arq_quarantine_qpath);
			$filename = $path_parts['basename'];
		
			if ( $filename != '' ) {
			
				echo '<th scope="row" style="border-bottom:none;">'.$filename.'</th>';
				echo "<td><input type=\"checkbox\" id=\"viewfile\" name=\"qradio[$row->arq_quarantine_qpath]\" value=\"viewfile\" /><br><span style=\"font-size:10px;\">".__('View', 'bulletproof-security')."</span></td>";
				echo "<td><input type=\"checkbox\" id=\"restorefile\" name=\"qradio[$row->arq_quarantine_source]\" value=\"restorefile\" class=\"restorefileALL\" /><br><span style=\"font-size:10px;\">".__('Restore', 'bulletproof-security')."</span></td>";
				echo "<td><input type=\"checkbox\" id=\"deletefile\" name=\"qradio[$row->arq_quarantine_qpath]\" value=\"deletefile\" class=\"deletefileALL\" /><br><span style=\"font-size:10px;\">".__('Delete', 'bulletproof-security')."</span></td>";
				echo '<td>'.$row->arq_quarantine_source.'</td>';		
				echo '<td>'.$row->time.'</td>'; 
				echo '</tr>';			
			}
		} 
		
		if ( $filename == '' ) {		
			echo '<th scope="row" style="border-bottom:none;">No Files in Quarantine</th>';
			echo "<td></td>";
			echo "<td></td>";
			echo "<td></td>";
			echo '<td></td>';		
			echo '<td></td>'; 
			echo '</tr>';		
		}
		echo '</tbody>';
		echo '</table>';
		echo '</div>';	

		echo "<input type=\"submit\" name=\"Submit-Quarantine-Search-Radio\" value=\"".__('Submit', 'bulletproof-security')."\" class=\"button bps-button\" onclick=\"QSortSearch()\" />&nbsp;&nbsp;<input type=\"button\" name=\"cancel\" value=\"".__('Clear|Refresh', 'bulletproof-security')."\" class=\"button bps-button\" onclick=\"javascript:history.go(0)\" /></form>";
	
	} else {

		// Quarantine Static Form
		//if ( ! isset( $_POST['Submit-Quarantine-Search-Radio'] ) && ! isset( $_POST['Submit-ARQ-Quarantine-Radio'] ) ) {
			
			echo '<form name="bpsQuarantineDBRadio" action="'.admin_url( 'admin.php?page=bulletproof-security/admin/quarantine/quarantine.php' ).'" method="post">';
			wp_nonce_field('bulletproof_security_arq_quarantine');
			
			$bpspro_arq_quarantine_table = $wpdb->prefix . "bpspro_arq_quarantine";
			$forward_slash = '/'; // return all rows with a forward slash in them or in other words all rows
			$filename = '';
			$getQuarantineTable = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $bpspro_arq_quarantine_table WHERE arq_quarantine_source LIKE %s", "%$forward_slash%") );
		
			echo '<div id="ARQcheckall" style="">';
			echo '<table class="widefat" style="margin-bottom:20px;">';
			echo '<thead>';
			echo '<tr>';
			echo '<th scope="col" style="width:20%;"><strong>'.__('Filename', 'bulletproof-security').'</strong></th>';
			echo '<th scope="col" style="width:7%;"><br><strong>'.__('View<br>File', 'bulletproof-security').'</strong></th>';
			echo '<th scope="col" style="width:7%;"><input type="checkbox" class="checkallRestore" style="text-align:left; margin-left:2px;" /><br><strong>'.__('Restore<br>File', 'bulletproof-security').'</strong></th>';
			echo '<th scope="col" style="width:7%;"><input type="checkbox" class="checkallDelete" style="text-align:left; margin-left:2px;" /><br><strong>'.__('Delete<br>File', 'bulletproof-security').'</strong></th>';
			echo '<th scope="col" style="width:49%;"><strong>'.__('Source Path - File was Quarantined from this location', 'bulletproof-security').'</strong><br>'.__('The file will be restored to this location if Restore File is selected').'</th>';
			echo '<th scope="col" style="width:10%;"><strong>'.__('Quarantine<br>Time', 'bulletproof-security').'</strong></th>';
			echo '</tr>';
			echo '</thead>';
			echo '<tbody>';
			echo '<tr>';
			
			foreach ( $getQuarantineTable as $row ) {
				$path_parts = pathinfo($row->arq_quarantine_qpath);
				$filename = $path_parts['basename'];
			
				if ( $filename != '' ) {
					
					echo '<th scope="row" style="border-bottom:none;">'.$filename.'</th>';
					echo "<td><input type=\"checkbox\" id=\"viewfile\" name=\"qradio[$row->arq_quarantine_qpath]\" value=\"viewfile\" /><br><span style=\"font-size:10px;\">".__('View', 'bulletproof-security')."</span></td>";
					echo "<td><input type=\"checkbox\" id=\"restorefile\" name=\"qradio[$row->arq_quarantine_source]\" value=\"restorefile\" class=\"restorefileALL\" /><br><span style=\"font-size:10px;\">".__('Restore', 'bulletproof-security')."</span></td>";
					echo "<td><input type=\"checkbox\" id=\"deletefile\" name=\"qradio[$row->arq_quarantine_qpath]\" value=\"deletefile\" class=\"deletefileALL\" /><br><span style=\"font-size:10px;\">".__('Delete', 'bulletproof-security')."</span></td>";
					echo '<td>'.$row->arq_quarantine_source.'</td>';		
					echo '<td>'.$row->time.'</td>'; 
					echo '</tr>';			
				}
			} 
			
			if ( $filename == '' ) {		
				echo '<th scope="row" style="border-bottom:none;">No Files in Quarantine</th>';
				echo "<td></td>";
				echo "<td></td>";
				echo "<td></td>";
				echo '<td></td>';		
				echo '<td></td>'; 
				echo '</tr>';		
			}
			echo '</tbody>';
			echo '</table>';
			echo '</div>';	
	
			echo "<input type=\"submit\" name=\"Submit-ARQ-Quarantine-Radio\" value=\"".__('Submit', 'bulletproof-security')."\" class=\"button bps-button\" onclick=\"QStandard()\" />&nbsp;&nbsp;<input type=\"button\" name=\"cancel\" value=\"".__('Clear|Refresh', 'bulletproof-security')."\" class=\"button bps-button\" onclick=\"javascript:history.go(0)\" /></form>";
		//}
	}
?>
<br />

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

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

<?php } ?>

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

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

<?php 
} // end if ( ! current_user_can('manage_options') )
?>

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

</div>

<div id="bps-tabs-2" 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('Quarantine Log', 'bulletproof-security'); ?></h2></td>
  </tr>
  <tr>
    <td class="bps-table_cell_help">

<h3 style="margin:0px 0px 10px 0px;"><?php _e('Quarantine Log', '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('Quarantine Log', '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>'.__('Quarantine Log General Information', 'bulletproof-security').'</strong><br>'.__('The Quarantine Log logs specific information about what action was taken so that you can quickly visually identify exactly what action occurred. See the Example Quarantine Log Entries help section below.', 'bulletproof-security').'<br><br>'.__('When a file has been quarantined you will see an AutoRestore|Quarantine Alert. To remove that alert from being displayed click the Reset Last Modified Time in DB button. This synchronizes the last modified time of the actual Quarantine Log file with the timestamp stored in your WordPress database for the last time the Quarantine Log file was modified. Every time a new log entry is made in the Quarantine Log the last modified time of the Quarantine Log file will change.', 'bulletproof-security').'<br><br>'.__('Your ARQ Log file is a plain text static file and not a dynamic file or dynamic display to keep your website resource usage at a bare minimum and keep your website performance at a maximum. Log entries are logged in descending order by Date and Time. You can copy, edit and delete this plain text file. S-Monitor Email Alerting & Log File Options will automatically email your ARQ Log file to you and delete it when it reaches a certain size (256KB, 500KB or 1MB). NOTE: The S-Monitor Email Alerting & Log File Options will only send log files up to 2MB in size. 500KB is the recommended maximum size setting that you should use for when to automatically email your ARQ Log File to you.', 'bulletproof-security').'<br><br><strong>'.__('Example Quarantine Log Entries', 'bulletproof-security').'<br>'.__('Example Demo Site: WordPress is installed in a folder named "demo-site"', 'bulletproof-security').'</strong><br><br><strong>'.__('Root File AutoRestore Logged: ', 'bulletproof-security').'</strong>'.__('The index.php file was intentionally altered/modified and it was autorestored with a good backup copy of the index.php file. A copy of the altered/modified index.php was sent to Quarantine. AutoRestore Log entries log the filename, the path where the file has been sent to in the Quarantine folder and the restore path where the file was quarantined from.', 'bulletproof-security').'<br><br>[Root File AutoRestore Logged: October 3, 2015 1:32 pm]<br>Quarantined Filename: index.php<br>Quarantine Path: /xxxxx/xxxxx/demo-site/'.$bps_wpcontent_dir.'/bps-backup/quarantine/root-files/index.php<br>Restore Path: /xxxxx/xxxxx/demo-site/index.php<br><br><strong>'.__('Root File Quarantine Logged: ', 'bulletproof-security').'</strong>'.__('The example-hacker-file.php was uploaded to the "demo-site" folder and the file was sent to Quarantine. Quarantine Log entries log the filename, the path where the file has been sent to in the Quarantine folder and the restore path where the file was quarantined from.', 'bulletproof-security').'<br><br>[Root File Quarantine Logged: October 3, 2015 1:32 pm]<br>Quarantined Filename: example-hacker-file.php<br>Quarantine Path: /xxxxx/xxxxx/demo-site/'.$bps_wpcontent_dir.'/bps-backup/quarantine/root-files/example-hacker-file.php<br>Restore Path: /xxxxx/xxxxx/demo-site/example-hacker-file.php'; echo $text; ?></p>
</div>

<?php

// Get the Current / Last Modifed Date of the ARQ Log File
function bps_getARCMLogLastMod() {
$filename = WP_CONTENT_DIR . '/bps-backup/logs/autorestore_log.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;
	}
}

// String comparison of ARQ DB Last Modified Time and Actual File Last Modified Time
function bps_ARCMModTimeDiff() {
$options = get_option('bulletproof_security_options_ARCM_log');
$last_modified_time = bps_getARCMLogLastMod();
$last_modified_time_db = ! isset($options['bps_arcm_log_date_mod']) ? '' : $options['bps_arcm_log_date_mod'];
	
	if ( isset($options['bps_arcm_log_date_mod']) && $options['bps_arcm_log_date_mod'] == '' ) {
		$text = '<font color="#fb0101" style="padding-right:5px;"><strong>'.__('Click the Reset Last Modified Time in DB button', 'bulletproof-security').'<br>'.__('to set the', 'bulletproof-security').'</strong></font>';
		echo $text;
	}
	if ( strcmp($last_modified_time, $last_modified_time_db) == 0 ) { // 0 is equal
		$text = '<font color="green" style="padding-right:8px;"><strong>'.__('Last Modified Time in DB:', 'bulletproof-security').' </strong></font>';
		echo $text;
	} else {
		$text = '<font color="#fb0101" style="padding-right:8px;"><strong>'.__('Last Modified Time in DB:', 'bulletproof-security').' </strong></font>';
		echo $text;
	}
}

// Get File Size of the Quarantine Log File
function bps_getARQLogSize() {
$filename = WP_CONTENT_DIR . '/bps-backup/logs/autorestore_log.txt';

if ( file_exists($filename) ) {
	$logSize = filesize($filename);
	if ($logSize < 2097152) {
 		$text = '<span style="font-size:13px;"><strong>'. __('ARQ Log File Size: ', 'bulletproof-security').'<font color="#2ea2cc">'. round($logSize / 1024, 2) .' KB</font></strong></span><br><br>';
		echo $text;
	} else {
 		$text = '<span style="font-size:13px;"><strong>'. __('ARQ Log File Size: ', 'bulletproof-security').'<font color="#fb0101">'. round($logSize / 1024, 2) .' KB<br>'.__('The S-Monitor Email Logging options will only send log files up to 2MB in size.', 'bulletproof-security').'</font></strong><br>'.__('Copy and paste the ARQ Log file contents into a Notepad text file on your computer and save it.', 'bulletproof-security').'<br>'.__('Then click the Delete Log button to delete the contents of this Log file.', 'bulletproof-security').'</span><br><br>';		
		echo $text;
	}
	}
}
bps_getARQLogSize();

?>

<form name="QLogModDate" action="options.php#bps-tabs-2" method="post">
	<?php settings_fields('bulletproof_security_options_ARCM_log'); ?> 
	<?php $options = get_option('bulletproof_security_options_ARCM_log'); 
	$bps_arcm_log_date_mod = ! isset($options['bps_arcm_log_date_mod']) ? '' : $options['bps_arcm_log_date_mod'];
	?>
    <label for="QLog"><strong><?php _e('Quarantine Log Last Modified Time:', 'bulletproof-security'); ?></strong></label><br />
	<label for="QLog"><strong><?php echo bps_ARCMModTimeDiff(); ?></strong><?php echo $bps_arcm_log_date_mod; ?></label><br />
	<label for="QLog" style="vertical-align:top;"><strong><?php _e('Last Modified Time in File:', 'bulletproof-security'); ?></strong></label>
    <input type="text" name="bulletproof_security_options_ARCM_log[bps_arcm_log_date_mod]" class="QLog-last-mod-file" style="color:#2ea2cc;font-size:13px;width:200px;margin-top:-6px;padding-left:4px;font-weight:600;border:none;background:none;outline:none;-webkit-box-shadow:none;box-shadow:none;-webkit-transition:none;transition:none;" value="<?php echo bps_getARCMLogLastMod(); ?>" /><br />
	<input type="submit" name="Submit-ARCM-Mod" class="button bps-button" style="margin:10px 0px 0px 0px;" value="<?php esc_attr_e('Reset Last Modified Time in DB', 'bulletproof-security') ?>" />
</form>

<?php
if ( isset( $_POST['Submit-Delete-ARQ-Log'] ) && current_user_can('manage_options') ) {
	check_admin_referer( 'bps-delete-arq-log' );

$options = get_option('bulletproof_security_options_ARCM_log');
$last_modified_time_db = $options['bps_arcm_log_date_mod'];
$time = strtotime($last_modified_time_db); 
$ARQLog = WP_CONTENT_DIR . '/bps-backup/logs/autorestore_log.txt';
$ARQLogMaster = WP_PLUGIN_DIR . '/bulletproof-security/admin/htaccess/autorestore_log.txt';
	
	if ( copy($ARQLogMaster, $ARQLog) ) {
		touch($ARQLog, $time);	
		
		echo $bps_topDiv;		
		$text = '<font color="green"><strong>'.__('Success! Your Quarantine Log file has been deleted and replaced with a new blank Quarantine Log file.', 'bulletproof-security').'</strong></font>';
		echo $text;	
		echo $bps_bottomDiv;
	}
}
?>

<form name="DeleteLogForm" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/quarantine/quarantine.php#bps-tabs-2' ); ?>" method="post">
<?php wp_nonce_field('bps-delete-arq-log'); ?>

<input type="submit" name="Submit-Delete-ARQ-Log" value="<?php esc_attr_e('Delete Log', 'bulletproof-security') ?>" class="button bps-button" style="margin:15px 0px 15px 0px" onclick="return confirm('<?php $text = __('Clicking OK will delete the contents of your ARQ Log file.', 'bulletproof-security').'\n\n'.$bpsSpacePop.'\n\n'.__('Click OK to Delete the Log file contents or click Cancel.', 'bulletproof-security'); echo $text; ?>')" />
</form>

<div id="messageinner" class="updatedinner">
<?php

// Get BPS ARCM log file contents 
function bps_get_arcm_log() {
if ( current_user_can('manage_options') ) {
	
$bps_arcm_log = WP_CONTENT_DIR . '/bps-backup/logs/autorestore_log.txt';
$bps_wpcontent_dir = str_replace( ABSPATH, '', WP_CONTENT_DIR );

	if ( file_exists($bps_arcm_log) ) {
		$bps_arcm_log = file_get_contents($bps_arcm_log);
		return htmlspecialchars($bps_arcm_log);
	
	} else {
	
	_e('The AutoRestore Log File Was Not Found! Check that the file really exists here - /', 'bulletproof-security').$bps_wpcontent_dir.__('/bps-backup/logs/autorestore_log.txt and is named correctly.', 'bulletproof-security');
	}
	}
}

// Form - ARCM Error Log - Perform File Open and Write test - If append write test is successful write to file
if ( current_user_can('manage_options') ) {
$bps_arcm_log = WP_CONTENT_DIR . '/bps-backup/logs/autorestore_log.txt';
$write_test = "";
	
	if ( is_writable($bps_arcm_log) ) {
    if ( !$handle = fopen($bps_arcm_log, 'a+b') ) {
    exit;
    }
    if ( fwrite($handle, $write_test) === FALSE ) {
	exit;
    }
	$text = '<font color="green" style="font-size:12px;"><strong>'.__('File Open and Write test successful! Your AutoRestore|Quarantine Log file is writable.', 'bulletproof-security').'</strong></font><br>';
	echo $text;
	}
	}
	
	if ( isset( $_POST['submit-arcm-log'] ) && current_user_can('manage_options') ) {
	check_admin_referer( 'bulletproof_security_save_arcm_log' );
	$newcontentarcm = stripslashes($_POST['newcontentarcm']);
	if ( is_writable($bps_arcm_log) ) {
		$handle = fopen($bps_arcm_log, 'w+b');
		fwrite($handle, $newcontentarcm);
	$text = '<font color="green" style="font-size:12px;"><strong>'.__('Success! Your AutoRestore|Quarantine Log file has been updated.', 'bulletproof-security').'</strong></font><br>';
	echo $text;	
	
	echo $bps_topDiv;
	$text = '<font color="green"><strong>'.__('Success! Your Quarantine Log file has been updated.', 'bulletproof-security').'</strong></font>';
	echo $text;	
	echo $bps_bottomDiv;

    fclose($handle);

	$gmt_offset = get_option( 'gmt_offset' ) * 3600;
	$time_now = date("F d Y H:i:s", time() + $gmt_offset );
	$BPS_QLog = array( 'bps_arcm_log_date_mod' => $time_now );	

		foreach( $BPS_QLog as $key => $value ) {
			update_option('bulletproof_security_options_ARCM_log', $BPS_QLog);
		}
	}
}
$scrolltoarcmlog = isset($_REQUEST['scrolltoarcmlog']) ? (int) $_REQUEST['scrolltoarcmlog'] : 0;
?>
</div>

<div id="QLogEditor">
<form name="bpsARCMLog" id="bpsARCMLog" action="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/quarantine/quarantine.php#bps-tabs-2' ); ?>" method="post">
<?php wp_nonce_field('bulletproof_security_save_arcm_log'); ?>
<div id="bpsARCMLog">
    <textarea class="bps-text-area-600x700" name="newcontentarcm" id="newcontentarcm" tabindex="1"><?php echo bps_get_arcm_log(); ?></textarea>
	<input type="hidden" name="scrolltoarcmlog" id="scrolltoarcmlog" value="<?php echo esc_html( $scrolltoarcmlog ); ?>" />
    <p class="submit">
	<input type="submit" name="submit-arcm-log" class="button bps-button" value="<?php esc_attr_e('Update File', 'bulletproof-security') ?>" /></p>
</div>
</form>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
	$('#bpsARCMLog').submit(function(){ $('#scrolltoarcmlog').val( $('#newcontentarcm').scrollTop() ); });
	$('#newcontentarcm').scrollTop( $('#scrolltoarcmlog').val() ); 
});
/* ]]> */
</script>
</div>

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

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

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bps-help_faq_table">
  <tr>
    <td class="bps-table_title"><h2><?php _e('Help & FAQ', 'bulletproof-security'); ?></h2></td>
  </tr>
  <tr>
    <td class="bps-table_cell_help_links">
    <a href="<?php echo admin_url( 'admin.php?page=bulletproof-security/admin/whatsnew/whatsnew.php' ); ?>" target="_blank"><?php _e('Whats New in ', 'bulletproof-security'); echo BULLETPROOF_VERSION; ?></a><br /><br />
    <a href="https://forum.ait-pro.com/forums/topic/bulletproof-security-pro-version-release-dates/" target="_blank"><?php _e('BPS Pro Features & Version Release Dates', 'bulletproof-security'); ?></a><br /><br />
    <a href="https://forum.ait-pro.com/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><br /><br />
    <a href="https://forum.ait-pro.com/forums/topic/autorestore-quarantine-guide-read-me-first/" target="_blank"><?php _e('AutoRestore|Quarantine Guide & Troubleshooting', 'bulletproof-security'); ?></a>
    </td>
  </tr>
</table>
</div>
         
<div id="AITpro-link">BulletProof Security Pro <?php echo BULLETPROOF_VERSION; ?> Plugin by <a href="https://forum.ait-pro.com/" target="_blank" title="AITpro Website Security">AITpro Website Security</a>
</div>
</div>
<style>
<!--
.bps-spinner {visibility:hidden;}
-->
</style>
</div>