$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/Api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home2/krtkhu/public_html/wp-content/plugins/hellopack-client/includes/Api/Client.php
<?php
/**
 * API HTTP client.
 *
 * @package HelloPack\Client
 */

declare( strict_types=1 );

namespace HelloPack\Client\Api;

use HelloPack\Client\Options;
use WP_Error;

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

/**
 * HTTP communication with the HelloPack API.
 */
class Client {

	/**
	 * API token.
	 *
	 * @var string
	 */
	private string $token;

	/**
	 * Normalizer instance.
	 *
	 * @var Normalizer
	 */
	private Normalizer $normalizer;

	/**
	 * Constructor.
	 */
	public function __construct() {
		$this->token      = (string) Options::get( 'token' );
		$this->normalizer = new Normalizer();
	}

	/**
	 * Make an API request.
	 *
	 * @param string               $url  Request URL.
	 * @param array<string, mixed> $args Optional wp_remote_get args.
	 * @return array<string, mixed>|WP_Error
	 */
	public function request( string $url, array $args = array() ): array|WP_Error {
		if ( ! defined( 'HELLOPACK_LOCAL_DEVELOPMENT' ) && strpos( $url, 'https://' ) !== 0 ) {
			return new WP_Error(
				'insecure_connection',
				__( 'API requests must use HTTPS.', 'hellopack-client' )
			);
		}

		$defaults = array(
			'sslverify' => ! defined( 'HELLOPACK_LOCAL_DEVELOPMENT' ),
			'headers'   => $this->get_headers(),
			'timeout'   => 15,
		);

		$args  = wp_parse_args( $args, $defaults );
		$token = trim( str_replace( 'Bearer', '', $args['headers']['Authorization'] ?? '' ) );

		if ( ! defined( 'HELLOPACK_LOCAL_DEVELOPMENT' ) && empty( $token ) ) {
			return new WP_Error( 'api_token_error', __( 'An API token is required.', 'hellopack-client' ) );
		}

		$response      = wp_remote_get( esc_url_raw( $url ), $args );
		$response_code = wp_remote_retrieve_response_code( $response );

		if ( is_wp_error( $response ) ) {
			return $response;
		}

		if ( 200 !== $response_code ) {
			$body_raw = json_decode( wp_remote_retrieve_body( $response ), true );
			$message  = $body_raw['error'] ?? $body_raw['message'] ?? '';

			if ( empty( $message ) ) {
				$message = wp_remote_retrieve_response_message( $response );
			}

			return new WP_Error(
				(string) $response_code,
				! empty( $message ) ? $message : __( 'An unknown API error occurred.', 'hellopack-client' )
			);
		}

		$body = json_decode( wp_remote_retrieve_body( $response ), true );

		if ( null === $body ) {
			return new WP_Error( 'json_decode_error', __( 'Invalid JSON response.', 'hellopack-client' ) );
		}

		return $body;
	}

	/**
	 * Get purchased plugins from the API.
	 *
	 * @return array<int, array<string, mixed>>
	 */
	public function plugins(): array {
		$url      = Endpoints::SERVER . Endpoints::path( 'list-purchases' ) . 'wordpress-plugins';
		$response = $this->request( $url );

		return $this->process_list_response( $response, 'plugin' );
	}

	/**
	 * Get purchased themes from the API.
	 *
	 * @return array<int, array<string, mixed>>
	 */
	public function themes(): array {
		$url      = Endpoints::SERVER . Endpoints::path( 'list-purchases' ) . 'wordpress-themes';
		$response = $this->request( $url );

		return $this->process_list_response( $response, 'theme' );
	}

	/**
	 * Get a deferred download URL for an item.
	 *
	 * @param int $id Item ID.
	 * @return string
	 */
	public function deferred_downloads( int $id ): string {
		if ( $id <= 0 ) {
			return '';
		}

		$page_url = HELLOPACK_CLIENT_NETWORK_ACTIVATED
			? network_admin_url( 'admin.php?page=hellopack-client' )
			: admin_url( 'admin.php?page=hellopack-client' );

		return add_query_arg(
			array(
				'deferred_downloads' => true,
				'hp_item_id'         => $id,
			),
			$page_url
		);
	}

	/**
	 * Download an item by ID.
	 *
	 * @param int                  $id   Item ID.
	 * @param array<string, mixed> $args Optional request args.
	 * @return string|false Download URL or false.
	 */
	public function download( int $id, array $args = array() ): string|false {
		if ( $id <= 0 ) {
			return false;
		}

		$url      = Endpoints::SERVER . Endpoints::path( 'download' ) . '?hp_item_id=' . $id . '&shorten_urls=true';
		$response = $this->request( $url, $args );

		if ( is_wp_error( $response ) || empty( $response ) ) {
			return false;
		}

		return $response['wordpress_plugin'] ?? $response['wordpress_theme'] ?? false;
	}

	/**
	 * Get request headers.
	 *
	 * @return array<string, string>
	 */
	private function get_headers(): array {
		return array(
			'Authorization' => 'Bearer ' . $this->token,
			// A network identifies itself by its main URL, not the current site's.
			'User-Agent'    => HELLOPACK_CLIENT_NETWORK_ACTIVATED ? network_site_url() : get_site_url(),
		);
	}

	/**
	 * Process a list API response.
	 *
	 * @param array<string, mixed>|WP_Error $response API response.
	 * @param string                        $type     'plugin' or 'theme'.
	 * @return array<int, array<string, mixed>>
	 */
	private function process_list_response( array|WP_Error $response, string $type ): array {
		$current_status = Options::get_status();

		if ( is_wp_error( $response ) || empty( $response ) ) {
			if ( is_wp_error( $response ) && '403' === $response->get_error_code() && 'inactive' !== $current_status ) {
				Options::set_status( 'inactive' );
			}
			return array();
		}

		if ( 'active' !== $current_status ) {
			Options::set_status( 'active' );
		}

		if ( empty( $response['results'] ) ) {
			return array();
		}

		$items = array();
		foreach ( $response['results'] as $item ) {
			$items[] = 'plugin' === $type
				? $this->normalizer->normalize_plugin( $item['item'] )
				: $this->normalizer->normalize_theme( $item['item'] );
		}

		return $items;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit