89 lines
4.4 KiB
PHP
89 lines
4.4 KiB
PHP
<?php
|
|
// Prepare required objects and data for VM log display
|
|
$settings = new OCVMSettings();
|
|
$ocvm_notifications_obj = new OCVMNotifications();
|
|
$history_log_obj = new OCVMHistoryLog();
|
|
$history_log_obj->collectVulnerabilities();
|
|
$empty_class = ( $history_log_obj->history_log_data === null ) ? 'vm-empty-table' : '';
|
|
$mwp_class = ( $settings->isPremium() ) ? 'mwp-package' : 'non-mwp-package';
|
|
?>
|
|
|
|
<div class="back_to_vm">
|
|
<a href="javascript:void(0);" title="<?php echo __( 'Back', 'onecom-wp' ); ?>"><img
|
|
src="<?php echo OCVM_PLUGIN_DIR_URL; ?>/assets/images/back.svg"
|
|
alt="Back" /><span><?php echo __( 'Back', 'onecom-wp' ); ?></span></a>
|
|
</div>
|
|
<div class="cardwrap vmLogCard vm-log-container <?php echo $empty_class . ' ' . $mwp_class; ?>">
|
|
<div class="vm-log-header">
|
|
<?php echo __( 'Vulnerability log', 'onecom-wp' ); ?>
|
|
</div>
|
|
<div class="vm-log-desc">
|
|
<?php echo __( 'Your overview of all resolved vulnerabilities of core files, plugins and themes.', 'onecom-wp' ); ?>
|
|
</div>
|
|
<div>
|
|
<table id="vm-log-table" class="display nowrap" style="width:100%">
|
|
<thead>
|
|
<tr>
|
|
<th><?php _e( 'Date', 'onecom-wp' ); ?> <span class="vm-sort-icon"></span></th>
|
|
<th><?php _e( 'Issue', 'onecom-wp' ); ?></th>
|
|
<th><?php _e( 'Severity', 'onecom-wp' ); ?> <span class="vm-sort-icon"></span></th>
|
|
<th><?php _e( 'Type', 'onecom-wp' ); ?> <span class="vm-sort-icon"></span></th>
|
|
<th><?php _e( 'Name', 'onecom-wp' ); ?> <span class="vm-sort-icon"></span></th>
|
|
<th><?php _e( 'Version', 'onecom-wp' ); ?></th>
|
|
<th><?php _e( 'Result', 'onecom-wp' ); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
// checks if a log variable is set and is not null
|
|
if ( $history_log_obj->history_log_data ) {
|
|
// Loop through the data and populate table rows
|
|
foreach ( $history_log_obj->history_log_data as $item ) {
|
|
// Prepare vulnerabilities
|
|
$vul_url = $item['url'];
|
|
// Prepare the date and time format from WordPress settings
|
|
$date_format = get_option( 'date_format' );
|
|
$time_format = get_option( 'time_format' );
|
|
$unix_timestamp = strtotime( $item['timestamp'] . ' UTC' );
|
|
$wp_timezone_string = ! empty( wp_timezone_string() ) ? wp_timezone_string() : 'UTC';
|
|
$wp_timezone = new DateTimeZone( $wp_timezone_string );
|
|
$datetime = new DateTime( '@' . $unix_timestamp );
|
|
$datetime->setTimezone( $wp_timezone );
|
|
$formatted_date = $datetime->format( $date_format . ' ' . $time_format );
|
|
$severity_info = $ocvm_notifications_obj->get_vul_severity( $item['cvss_score'] );
|
|
$fix_version_with_arrow = "<i class='vm-fix-arrow'> </i>" . $item['fix_version'];
|
|
$fix_version = $item['fix_version'] ? $fix_version_with_arrow : '';
|
|
$item_type = $item['item_type'];
|
|
|
|
echo '<tr>';
|
|
echo '<td data-sort="' . $item['timestamp'] . '">' . $formatted_date . '</td>';
|
|
echo '<td class="oc-vul-url"><a href="' . $vul_url . '" target="_blank">' . __( $item['vuln_type'], 'onecom-wp' ) . '</a></td>';
|
|
echo '<td> <div class="' . $severity_info['class'] . '"> <span class="onecom_tag">' . __( $severity_info['label'], 'onecom-wp' ) . '</span></div></td>';
|
|
echo '<td>' . __( $item_type, 'onecom-wp' ) . '</td>';
|
|
echo '<td>' . __( $item['item_name'], 'onecom-wp' ) . '</td>';
|
|
echo '<td><span class="vm_version_box">' . $item['installed_version'] . $fix_version . '</span></td>';
|
|
echo '<td>' . __( $item['status'], 'onecom-wp' ) . '</td>';
|
|
echo '</tr>';
|
|
}
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
<?php
|
|
// Show message for empty vulnerability or non-mWP upsell (only if any vul exist)
|
|
if ( ! $history_log_obj->history_log_data || $history_log_obj->history_log_data === null ) {
|
|
?>
|
|
<div class="vm-empty-vul-message">
|
|
<?php _e( 'Once the first vulnerability on your site has been resolved, it will show up here.', 'onecom-wp' ); ?>
|
|
</div>
|
|
<?php
|
|
}
|
|
if ( ! $settings->isPremium() ) {
|
|
?>
|
|
<div class="upsell_vm_notification">
|
|
<p><?php echo sprintf( __( 'The full vulnerability log is a Managed WordPress feature. Upgrade to unlock it. %sLearn more.%s', 'onecom-wp' ), '<a href="javascript:void(0);" class="upsell-mwp-banner-show oc-show-modal ocwp_ocp_vm_log_mwp_upgrade_initiated_event" data-upsell-btn-event="ocwp_ocp_vm_log_mwp_upgrade_confirmed_event">', '</a>' ); ?> </p>
|
|
</div>
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|