$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/Loader.php
<?php
/**
 * Module loader.
 *
 * @package HelloPack\Client
 */

declare( strict_types=1 );

namespace HelloPack\Client\Module;

use HelloPack\Client\Options;

use HelloPack\Client\Utility\DisabledItems;

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

/**
 * Discovers and loads modules from the modules directory.
 */
class Loader {

	/**
	 * Singleton instance.
	 *
	 * @var self|null
	 */
	private static ?self $instance = null;

	/**
	 * Loaded modules.
	 *
	 * @var array<string, AbstractModule>
	 */
	private array $modules = array();

	/**
	 * Modules directory path.
	 *
	 * @var string
	 */
	private string $module_dir;

	/**
	 * Get singleton instance.
	 *
	 * @return self
	 */
	public static function instance(): self {
		if ( null === self::$instance ) {
			self::$instance = new self();
		}

		return self::$instance;
	}

	/**
	 * Private constructor.
	 */
	private function __construct() {
		$this->module_dir = HELLOPACK_CLIENT_PATH . 'modules/';
		add_action( 'init', array( $this, 'load_modules' ), 5 );
	}

	/**
	 * Load all modules from the modules directory.
	 */
	public function load_modules(): void {
		AbstractModule::set_global_settings(
			Options::get_module_settings()
		);

		$files = glob( $this->module_dir . '*.php' );

		if ( ! empty( $files ) ) {
			foreach ( $files as $file ) {
				$this->load_module( $file );
			}
		}

		/**
		 * Allow other plugins to register modules.
		 *
		 * @param Loader $loader The module loader instance.
		 */
		do_action( 'hellopack_register_modules', $this );
	}

	/**
	 * Load a single module file.
	 *
	 * @param string $file Module file path.
	 */
	private function load_module( string $file ): void {
		if ( ! file_exists( $file ) ) {
			return;
		}

		require_once $file;

		$class_name = $this->resolve_class_name( basename( $file, '.php' ) );

		if ( ! class_exists( $class_name ) || ! is_subclass_of( $class_name, AbstractModule::class ) ) {
			return;
		}

		$module = new $class_name();

		if ( 'system' === $module->get_category() || $this->is_module_registrable( $module ) ) {
			$this->register_module( $module );
		}
	}

	/**
	 * Register a module.
	 *
	 * @param AbstractModule $module Module instance.
	 */
	public function register_module( AbstractModule $module ): void {
		$this->modules[ $module->get_id() ] = $module;

		if ( $module->should_load() ) {
			$module->init();
			$module->register_update_blocks();
		}
	}

	/**
	 * Check if a module can be registered.
	 *
	 * @param AbstractModule $module Module instance.
	 * @return bool
	 */
	private function is_module_registrable( AbstractModule $module ): bool {
		$target   = $module->get_target();
		$category = $module->get_category();

		if ( 'plugin' === $category && ! empty( $target['plugin_dir'] ) && ! empty( $target['plugin_file'] ) ) {
			$plugin_path = $target['plugin_dir'] . '/' . $target['plugin_file'];
			$active      = is_plugin_active( $plugin_path ) || is_plugin_active_for_network( $plugin_path );

			// On a network the plugin may be active on another site only. Register
			// the module whenever the plugin is installed; should_load() still
			// decides per site whether the module actually runs there.
			if ( ! $active && HELLOPACK_CLIENT_NETWORK_ACTIVATED ) {
				$active = file_exists( WP_PLUGIN_DIR . '/' . $plugin_path );
			}

			return $active && ! $this->is_plugin_hard_disabled( $target['plugin_dir'] );
		}

		if ( 'theme' === $category && ! empty( $target['theme_slug'] ) ) {
			return get_option( 'template' ) === $target['theme_slug'] && ! $this->is_theme_hard_disabled( $target['theme_slug'] );
		}

		return false;
	}

	/**
	 * Check if a plugin is hard-disabled via constant.
	 *
	 * @param string $plugin_dir Plugin directory.
	 * @return bool
	 */
	public function is_plugin_hard_disabled( string $plugin_dir ): bool {
		return DisabledItems::is_plugin_disabled( $plugin_dir );
	}

	/**
	 * Check if a theme is hard-disabled via constant.
	 *
	 * @param string $theme_slug Theme slug.
	 * @return bool
	 */
	public function is_theme_hard_disabled( string $theme_slug ): bool {
		return DisabledItems::is_theme_disabled( $theme_slug );
	}

	/**
	 * Resolve class name from filename.
	 *
	 * @param string $filename Filename without extension.
	 * @return string
	 */
	private function resolve_class_name( string $filename ): string {
		$parts = array_map( 'ucfirst', explode( '-', $filename ) );

		$replacements = array(
			'Hellopack' => 'HelloPack',
			'Acf'       => 'ACF',
			'Wp'        => 'WP',
			'Seo'       => 'SEO',
		);

		$parts = array_map(
			static function ( string $part ) use ( $replacements ): string {
				return $replacements[ $part ] ?? $part;
			},
			$parts
		);

		return 'HelloPack\\Modules\\' . implode( '_', $parts );
	}

	/**
	 * Get all registered modules.
	 *
	 * @return array<string, AbstractModule>
	 */
	public function get_modules(): array {
		return $this->modules;
	}

	/**
	 * Flip a module's switch and persist it.
	 *
	 * The single place that knows how to enable or disable a module: the REST
	 * controller and WP-CLI both go through here.
	 *
	 * @param string $module_id Module ID.
	 * @param bool   $enabled   Desired state.
	 * @return AbstractModule|null The module, or null when unknown.
	 */
	public function set_module_enabled( string $module_id, bool $enabled ): ?AbstractModule {
		$module = $this->get_module( $module_id );

		if ( null === $module ) {
			return null;
		}

		$settings    = Options::get_module_settings();
		$was_enabled = ! isset( $settings[ $module_id ] ) || ! empty( $settings[ $module_id ]['enabled'] );

		if ( $was_enabled && ! $enabled ) {
			$module->cleanup();
			$module->cleanup_update_blocks();
		}

		$settings[ $module_id ] = array(
			'enabled' => $enabled,
			'updated' => current_time( 'mysql' ),
		);

		Options::save_module_settings( $settings );

		return $module;
	}

	/**
	 * Get a module by ID.
	 *
	 * @param string $module_id Module ID.
	 * @return AbstractModule|null
	 */
	public function get_module( string $module_id ): ?AbstractModule {
		return $this->modules[ $module_id ] ?? null;
	}

	/**
	 * Get modules by category.
	 *
	 * @param string $category Category name.
	 * @return array<string, AbstractModule>
	 */
	public function get_modules_by_category( string $category ): array {
		return array_filter(
			$this->modules,
			static fn( AbstractModule $m ): bool => $m->get_category() === $category
		);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit