HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.30
System: Linux iZj6c1151k3ad370bosnmsZ 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64
User: root (0)
PHP: 7.4.30
Disabled: NONE
Upload Files
File: /var/www/html/breadsecret.com/wp-content/plugins/wp-security-audit-log/classes/AbstractLogger.php
<?php
/**
 * Abstract logger class.
 *
 * @package    wsal
 * @subpackage loggers
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Abstract class used in the Logger.
 *
 * @see Loggers/Database.php
 * @package wsal
 */
abstract class WSAL_AbstractLogger {

	/**
	 * Instance of WpSecurityAuditLog.
	 *
	 * @var WpSecurityAuditLog
	 */
	protected $plugin;

	/**
	 * Method: Constructor.
	 *
	 * @param WpSecurityAuditLog $plugin - Instance of WpSecurityAuditLog.
	 *
	 * @since  1.0.0
	 */
	public function __construct( WpSecurityAuditLog $plugin ) {
		$this->plugin = $plugin;
	}

	/**
	 * Log alert abstract.
	 *
	 * @param integer $type    - Alert code.
	 * @param array   $data    - Metadata.
	 * @param integer $date    (Optional) - Created on.
	 * @param integer $site_id (Optional) - Site id.
	 */
	abstract public function log( $type, $data = array(), $date = null, $site_id = null );

	/**
	 * Determines what is the correct timestamp for the event.
	 *
	 * It uses the timestamp from metadata if available. This is needed because we introduced a possible delay by using
	 * action scheduler in 4.3.0. The $legacy_date attribute is only used for migration of legacy data. This should be
	 * removed in future releases.
	 *
	 * @param array $metadata    Event metadata.
	 * @param int   $legacy_date Legacy date only used when migrating old db event format to the new one.
	 *
	 * @return float GMT timestamp including microseconds.
	 * @since 4.3.0
	 */
	protected function get_correct_timestamp( $metadata, $legacy_date ) {

		if ( is_null( $legacy_date ) ) {
			$timestamp = current_time( 'U.u', true );

			$timestamp = \apply_filters( 'wsal_database_timestamp_value', $timestamp, $metadata );

			return array_key_exists( 'Timestamp', $metadata ) ? $metadata['Timestamp'] : current_time( 'U.u', true );
		}

		return floatval( $legacy_date );
	}
}