$plugin = <<403WebShell
403Webshell
Server IP : 193.224.177.188  /  Your IP : 216.73.216.209
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/Module/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home2/krtkhu/public_html/wp-content/plugins/hellopack-client/includes/Module/AbstractModule.php
<?php
/**
 * Abstract module base class.
 *
 * @package HelloPack\Client
 */

declare( strict_types=1 );

namespace HelloPack\Client\Module;

use HelloPack\Client\Options;
use HelloPack\Client\Plugin;
use HelloPack\Client\Utility\DisabledItems;

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

/**
 * Base class for all HelloPack modules.
 */
abstract class AbstractModule implements ModuleInterface {

	/**
	 * Module ID.
	 *
	 * @var string
	 */
	protected string $id = '';

	/**
	 * Module name.
	 *
	 * @var string
	 */
	protected string $name = '';

	/**
	 * Module description.
	 *
	 * @var string
	 */
	protected string $description = '';

	/**
	 * Target plugin/theme info.
	 *
	 * @var array<string, string>
	 */
	protected array $target = array();

	/**
	 * Target ID for API access control.
	 *
	 * @var string
	 */
	protected string $target_id = '';

	/**
	 * Module category: plugin, theme, or system.
	 *
	 * @var string
	 */
	protected string $category = 'plugin';

	/**
	 * Module icon URL.
	 *
	 * @var string
	 */
	protected string $icon = '';

	/**
	 * Module version.
	 *
	 * @var string
	 */
	protected string $version = '1.0.0';

	/**
	 * Whether module is enabled.
	 *
	 * @var bool
	 */
	protected bool $enabled = true;

	/**
	 * Whether module is enabled by default.
	 *
	 * @var bool
	 */
	protected bool $enabled_by_default = true;

	/**
	 * Whether module can be disabled.
	 *
	 * @var bool
	 */
	protected bool $can_be_disabled = true;

	/**
	 * Domains/URL patterns to block via pre_http_request filter.
	 *
	 * Format: [ 'url-pattern' => [ 'response' => [...] ] ]
	 *
	 * @var array<string, array<string, mixed>>
	 */
	protected array $blocked_domains = array();

	/**
	 * Transients to pre-populate for blocking update checks.
	 *
	 * Format: [ 'transient_name' => $value ]
	 *
	 * @var array<string, mixed>
	 */
	protected array $update_transients = array();

	/**
	 * Cached module settings (loaded once, shared across all modules).
	 *
	 * @var array<string, array<string, mixed>>|null
	 */
	private static ?array $global_settings = null;

	/**
	 * Pre-load module settings for all modules (call once before instantiation).
	 *
	 * @param array<string, array<string, mixed>> $settings Module settings.
	 */
	public static function set_global_settings( array $settings ): void {
		self::$global_settings = $settings;
	}

	/**
	 * Constructor.
	 */
	public function __construct() {
		$this->setup();
		$this->load_enabled_state();
	}

	/**
	 * Load enabled state from cached settings.
	 */
	private function load_enabled_state(): void {
		if ( null === self::$global_settings ) {
			self::$global_settings = Options::get_module_settings();
		}

		$settings = self::$global_settings;

		if ( isset( $settings[ $this->id ]['enabled'] ) ) {
			$this->enabled = (bool) $settings[ $this->id ]['enabled'];
		} else {
			$this->enabled = $this->enabled_by_default;
		}
	}

	/**
	 * Check if the module has API access based on target_id.
	 *
	 * @return bool
	 */
	public function has_api_access(): bool {
		if ( empty( $this->target_id ) || 'system' === $this->category ) {
			return true;
		}

		$transient_name = 'plugin' === $this->category
			? Options::OPTION_NAME . '_plugins'
			: Options::OPTION_NAME . '_themes';

		$data = get_site_transient( $transient_name );

		// The catalogue cache is cleared whenever a plugin is installed, updated
		// or activated through HelloPack. Without this, every licence module
		// went dormant until the next catalogue refresh — refetch it instead.
		if ( empty( $data ) || ! is_array( $data ) || empty( $data['purchased'] ) ) {
			$data = self::refill_catalogue( $this->category );
		}

		if ( empty( $data ) || ! is_array( $data ) || empty( $data['purchased'] ) ) {
			return false;
		}

		foreach ( $data['purchased'] as $item ) {
			if ( isset( $item['id'] ) && (string) $item['id'] === $this->target_id ) {
				return true;
			}
		}

		return false;
	}

	/**
	 * Refetch the purchased catalogue once per request when its cache is empty.
	 *
	 * @param string $category 'plugin' or 'theme'.
	 * @return array<string, mixed>
	 */
	private static function refill_catalogue( string $category ): array {
		static $attempted = array();

		if ( isset( $attempted[ $category ] ) || 'active' !== Options::get_status() ) {
			return array();
		}

		$attempted[ $category ] = true;

		$manager = Plugin::instance()->update_manager();

		if ( null === $manager ) {
			return array();
		}

		return 'plugin' === $category
			? $manager->items_cache()->get_plugins()
			: $manager->items_cache()->get_themes();
	}

	/**
	 * Check if this module should load.
	 *
	 * @return bool
	 */
	public function should_load(): bool {
		if ( ! $this->has_api_access() || ! $this->enabled ) {
			return false;
		}

		if ( $this->can_be_disabled && DisabledItems::is_module_disabled( $this->id ) ) {
			return false;
		}

		if ( 'system' === $this->category ) {
			return true;
		}

		return $this->is_target_active();
	}

	/**
	 * Check if the target plugin/theme is active.
	 *
	 * @return bool
	 */
	private function is_target_active(): bool {
		if ( 'plugin' === $this->category ) {
			if ( ! empty( $this->target['plugin_dir'] ) && ! empty( $this->target['plugin_file'] ) ) {
				$plugin_path = $this->target['plugin_dir'] . '/' . $this->target['plugin_file'];
				return is_plugin_active( $plugin_path );
			}
		} elseif ( 'theme' === $this->category ) {
			if ( ! empty( $this->target['theme_slug'] ) ) {
				return get_option( 'template' ) === $this->target['theme_slug'];
			}
		}

		return false;
	}

	/**
	 * Cleanup on disable.
	 */
	public function cleanup(): void {
		// Override in child classes.
	}

	/**
	 * Register update blocks: set transients and add blocked domains to the filter.
	 *
	 * Called by the Loader after init() for active modules.
	 */
	public function register_update_blocks(): void {
		foreach ( $this->update_transients as $name => $value ) {
			if ( false === get_transient( $name ) ) {
				set_transient( $name, $value, YEAR_IN_SECONDS );
			}
		}

		if ( ! empty( $this->blocked_domains ) ) {
			$domains   = $this->blocked_domains;
			$module_id = $this->id;

			add_filter(
				'hellopack_blocked_license_domains',
				static function ( array $existing ) use ( $domains, $module_id ): array {
					foreach ( $domains as $pattern => $config ) {
						$config['module_id']  = $module_id;
						$existing[ $pattern ] = $config;
					}
					return $existing;
				}
			);
		}
	}

	/**
	 * Remove update-block transients when the module is disabled.
	 *
	 * Called by the ModuleController alongside cleanup().
	 */
	public function cleanup_update_blocks(): void {
		foreach ( $this->update_transients as $name => $value ) {
			delete_transient( $name );
		}
	}

	// -----------------------------------------------------------------
	// Blocked domain response helpers.
	// -----------------------------------------------------------------

	/**
	 * Generic success response.
	 *
	 * @return array<string, mixed>
	 */
	protected static function generic_block(): array {
		return array( 'response' => array( 'success' => true ) );
	}

	/**
	 * EDD Software Licensing response.
	 *
	 * @return array<string, mixed>
	 */
	protected static function edd_sl_block(): array {
		return array(
			'response' => array(
				'success'  => true,
				'license'  => 'valid',
				'expires'  => '2099-01-01 23:59:59',
				'price_id' => 3,
			),
		);
	}

	/**
	 * WooCommerce API Manager response.
	 *
	 * @return array<string, mixed>
	 */
	protected static function wc_am_block(): array {
		return array(
			'response' => array(
				'success' => true,
				'data'    => array(
					'package' => array(
						'id'             => 0,
						'slug'           => '',
						'plugin'         => '',
						'new_version'    => '0.0.0',
						'url'            => '',
						'tested'         => '',
						'package'        => '',
						'upgrade_notice' => '',
					),
				),
			),
		);
	}

	/**
	 * Woo Software Licensing response.
	 *
	 * @return array<string, mixed>
	 */
	protected static function woo_sl_block(): array {
		return array(
			'response' => array(
				array(
					'status'         => 'success',
					'status_code'    => 's205',
					'message'        => 'License is active',
					'license_status' => 'active',
				),
			),
		);
	}

	/**
	 * Remove all hooks registered by a specific class.
	 *
	 * Useful for disabling a plugin's native update/license hooks
	 * so HelloPack can handle updates instead.
	 *
	 * @param string $hook_name  WordPress hook name.
	 * @param string $class_name Fully qualified class name.
	 */
	protected function remove_class_hooks( string $hook_name, string $class_name ): void {
		global $wp_filter;

		if ( ! isset( $wp_filter[ $hook_name ] ) ) {
			return;
		}

		foreach ( $wp_filter[ $hook_name ]->callbacks as $priority => $callbacks ) {
			foreach ( $callbacks as $callback ) {
				$function = $callback['function'];

				// Array callback: instance method or static method.
				if (
					is_array( $function ) &&
					(
						( is_object( $function[0] ) && get_class( $function[0] ) === $class_name ) ||
						( is_string( $function[0] ) && $function[0] === $class_name )
					)
				) {
					remove_filter( $hook_name, $function, $priority );
					continue;
				}

				// Closure bound to an instance of the target class.
				if ( $function instanceof \Closure ) {
					$bound = ( new \ReflectionFunction( $function ) )->getClosureThis();
					if ( null !== $bound && get_class( $bound ) === $class_name ) {
						remove_filter( $hook_name, $function, $priority );
					}
				}
			}
		}
	}

	/**
	 * Get module ID.
	 *
	 * @return string
	 */
	public function get_id(): string {
		return $this->id;
	}

	/**
	 * Get module name.
	 *
	 * @return string
	 */
	public function get_name(): string {
		return $this->name;
	}

	/**
	 * Get module description.
	 *
	 * @return string
	 */
	public function get_description(): string {
		return $this->description;
	}

	/**
	 * Get module category.
	 *
	 * @return string
	 */
	public function get_category(): string {
		return $this->category;
	}

	/**
	 * Get target info.
	 *
	 * @return array<string, string>
	 */
	public function get_target(): array {
		return $this->target;
	}

	/**
	 * Get target ID.
	 *
	 * @return string
	 */
	public function get_target_id(): string {
		return $this->target_id;
	}

	/**
	 * Check if module is enabled.
	 *
	 * @return bool
	 */
	public function is_enabled(): bool {
		return $this->enabled;
	}

	/**
	 * Check if module can be disabled.
	 *
	 * @return bool
	 */
	public function can_be_disabled(): bool {
		return $this->can_be_disabled;
	}

	/**
	 * Check if module is hard-disabled via HP_DISABLE_MODULES constant.
	 *
	 * @return bool
	 */
	public function is_hard_disabled(): bool {
		return DisabledItems::is_module_disabled( $this->id );
	}

	/**
	 * Get module info as array.
	 *
	 * @return array<string, mixed>
	 */
	public function get_info(): array {
		return array(
			'id'                 => $this->id,
			'name'               => $this->name,
			'description'        => $this->description,
			'icon'               => $this->icon,
			'category'           => $this->category,
			'version'            => $this->version,
			'target'             => $this->target,
			'target_id'          => $this->target_id,
			'enabled'            => $this->enabled,
			'enabled_by_default' => $this->enabled_by_default,
			'can_be_disabled'    => $this->can_be_disabled,
			'active'             => $this->should_load(),
		);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit