403Webshell
Server IP : 209.209.40.120  /  Your IP : 216.73.217.112
Web Server : Microsoft-IIS/10.0
System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586
User : NEWWWW$ ( 0)
PHP Version : 8.3.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/HostingSpaces/admin/pwan.uk/wwwroot - Copy (2)/wp-content/plugins/mihdan-index-now/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/HostingSpaces/admin/pwan.uk/wwwroot - Copy (2)/wp-content/plugins/mihdan-index-now/src/Cron.php
<?php
namespace Mihdan\IndexNow;

use Mihdan\IndexNow\Logger\Logger;
use Mihdan\IndexNow\Views\WPOSA;

class Cron {
	public const EVENT_NAME = 'mihdan-index-now__clear-log';

	/**
	 * Logger instance.
	 *
	 * @var Logger $logger
	 */
	private $logger;

	/**
	 * WPOSA instance.
	 *
	 * @var WPOSA $wposa
	 */
	private $wposa;

	/**
	 * Cron constructor.
	 *
	 * @param Logger $logger Logger instance.
	 * @param WPOSA  $wposa
	 */
	public function __construct( Logger $logger, WPOSA $wposa ) {
		$this->logger = $logger;
		$this->wposa  = $wposa;
	}
	public function setup_hooks() {
		add_action( 'admin_init', [ $this, 'add_task' ] );
		add_action( self::EVENT_NAME, [ $this, 'clear_log' ] );
	}

	public function add_task() {
		if ( ! wp_next_scheduled( self::EVENT_NAME ) ) {
			wp_schedule_event( time(), 'hourly', self::EVENT_NAME );
		}
	}

	/**
	 * Clear log table.
	 *
	 * @return bool
	 */
	public function clear_log(): bool {
		global $wpdb;

		$lifetime   = $this->wposa->get_option( 'lifetime', 'logs', 1 );
		$table_name = $this->logger->get_logger_table_name();

		$wpdb->query(
			$wpdb->prepare( "DELETE FROM {$table_name} WHERE DATEDIFF(NOW(), created_at)>=%d", $lifetime )
		);

		if ( $this->wposa->get_option( 'cron_events', 'logs', 'off' ) === 'on' ) {
			$data = [
				'direction' => 'internal',
			];

			$this->logger->info( 'Old log entries were deleted successfully.', $data );
		}

		return true;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit