<?php 
ini_set("display_errors", "0");
error_reporting(0); 

$lldocroot = defined('SITEROOT') ? SITEROOT : $_SERVER['DOCUMENT_ROOT'];
if (file_exists($lldocroot . "/dap/dap-config.php"))
    include_once ($lldocroot . "/dap/dap-config.php");  

$plugin_file = ABSPATH . 'wp-content/plugins/DAP-WP-LiveLinks/DAP-WP-LiveLinks.php';

//$data = get_plugin_data( $plugin_file, $markup = true, $translate = true ) ;


$dapver = floatval(DAP_VERSION);

$data = get_plugin_data( $plugin_file);

$rows = Dap_SecurityScanReport::load();

$scan_type = Dap_SecurityScan::loadByName('scan_type');


/*echo "<pre>"; print_r($rows);*/
?>



<div class="dap_security_scan_wrapper">
	<div class="heading">
		<h4><i class="fa fa-indent" aria-hidden="true"></i> DAP Security Scan</h4>
	</div>
	
	<div class="form-group row pb-5 divider">
		<div class="col-sm-12 align-items-center d-flex">
			<label> Your DAP version is :  <b><?php echo $dapver; ?></b></label>
		</div> 
		<div class="col-sm-12 align-items-center d-flex">
			<label> Your LiveLinks version is : <b><?php echo $data['Version']; ?></b></label>
		</div> 
	</div>
	
	<div class="form-group row pb-5 divider">
		<div class="col-sm-3 align-items-center d-flex">
			  <label> Run a Manual Scan </label>
		  </div> 
		  <div class="col-sm-5">
			  <button class="btn common_btn" id="manual_compare_files" type="button">Click Here To Start Manual Scan</button>
		</div>
	</div>
	
	<div class="heading subheading mt-3">
		<h4><i class="fa fa-indent" aria-hidden="true"></i> Schedule an automated Scan</h4>
	</div>
	
	<div class="form-group row pb-5 divider">
		<div class="col-sm-3 align-items-center d-flex">
			  <label> Select automated scan options </label>
		  </div> 
		  <div class="col-sm-3">
			  <select id="scan_scheduled_automation" class="form-control">
				<option value="daily" <?php if(isset($scan_type[0]) && $scan_type[0]->getValue() == 'daily' ){ echo 'selected'; } ?> >Run Once Daily</option>
				<option value="hourly"  <?php if(isset($scan_type[0]) && $scan_type[0]->getValue() == 'hourly'){ echo 'selected'; } ?>>Run Hourly</option>
				<option value="donot" <?php if(isset($scan_type[0]) && $scan_type[0]->getValue() == 'donot'){ echo 'selected'; } ?>>Do not run automated scan</option>
			  </select>
		</div>
		<div class="col-sm-2 text-right">
			<button class="btn common_btn dap_save_setting" type="button">Save </button>
		</div>
	</div>
	
	<div class="heading subheading mt-3">
		<h4><i class="fa fa-indent" aria-hidden="true"></i> Suspicious files found during the scan</h4>
	</div>
	
	<div class="form-group row mb-0">
		<div class="col-sm-10">
			<div class="table-responsive custom_table">
				<div class="alert alert-danger" id="showDapVersionError" role="alert" style="display:none">
				  
				</div>
				<div class="compareFilesTableOuter">
				<table class="table hover table-striped cell-border" id="dap_security_scan_table">
					<thead>
						<tr>
							<th>id</th>
							<th>File Path</th>
							<th>File Name</th>
							<th>Date</th>
							<th>Action</th>
						</tr>
					</thead>
					<tbody id="security_scan_result_table_body">
						<?php foreach($rows as $row){ ?>
							
						<tr id="pid_<?php echo $row->getId();?>" class="">
							  <td class="table-checkbox-outer">
									<input type="hidden" id="file_full_path_<?php echo $row->getId(); ?>" value="<?php echo $row->getFilePath().'/'.$row->getFileName() ?>" >
									<input type="checkbox" class="template_action" name="template_action" value="<?php echo $row->getId() ?>" id="<?php echo $row->getId(); ?>">
							  </td>
							   <td class="product-name text-left">
									<?php if($row->getFilePath() != ''){  echo $row->getFilePath(); } else{ echo '-';} ?> 
							  </td>					   
							  <td class="product-name text-left">
									<?php if($row->getFileName() != ''){  echo $row->getFileName(); } else{ echo '-';} ?>   
							  </td>	
							  <td class="updated_datel text-center">
								<?php echo $row->getDate();?>
							  </td>
							  <td class="editable-button text-center" >
								<div id="<?php echo $row->getId(); ?>" name="select_action" class="btn-group">								 
								  <a  title="Delete" data-id="<?php echo $row->getId(); ?>" class="del_file_full_path"
								    href="javascript:void(0)" >Delete </a> 
								  </div>
							  </td>
						</tr>
						<?php } ?>
						 
					</tbody>
				</table>
				</div>
			</div>
		</div>
	</div>
</div>


<!--<h1>DAP Security Scan</h1>

<form action="#" method="post">
	<h3>Run a Manual Scan</h3> 
	<input type="submit" name="fileCheck" value="Click here to start manual scan"> 
	
</form>


<h3>Schedule an automated Scan</h3>

<label>Select automated scan options</label>

<select id="scan_scheduled_automation">
	<option value="daily">Run Once Daily</option>
	<option value="hourly">Run Hourly</option>
	<option value="donot">Do not run automated scan</option>
</select>-->


<?php 

foreach($extraFiles as $extra){
	echo "<p>".$extra."</p>";
	echo "<button>Ignore</button>";
	echo "<button>Delete</button>";
}
