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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home2/krtkhu/public_html/wp-content/plugins/hellopack-client/includes/Translate/FileInstaller.php
<?php
/**
 * File Installer class.
 *
 * @package HelloPack\Client
 */

declare( strict_types=1 );

namespace HelloPack\Client\Translate;

use WP_Error;
use WP_Filesystem_Base;

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

/**
 * Downloads and installs translation files to the WordPress language directory.
 */
final class FileInstaller {

	/**
	 * GitHub client.
	 *
	 * @var GitHubClient
	 */
	private GitHubClient $client;

	/**
	 * Constructor.
	 */
	public function __construct() {
		$this->client = new GitHubClient();
	}

	/**
	 * Install translation files for a slug.
	 *
	 * @param string $slug Plugin or theme slug.
	 * @param string $type Type: 'plugin' or 'theme'.
	 * @return true|WP_Error
	 */
	public function install( string $slug, string $type ): bool|WP_Error {
		$tree = $this->client->fetch_tree();

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

		$remote_paths = FileMatcher::get_remote_paths_from_tree( $slug, $type, $tree );

		if ( empty( $remote_paths ) ) {
			return new WP_Error(
				'no_files',
				__( 'No translation files found for this item.', 'hellopack-client' )
			);
		}

		$filesystem = $this->get_filesystem();

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

		$this->ensure_directories( $filesystem, $type );

		foreach ( $remote_paths as $remote_path ) {
			$result = $this->download_and_save( $remote_path, $filesystem );

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

		return true;
	}

	/**
	 * Delete translation files for a slug.
	 *
	 * @param string $slug Plugin or theme slug.
	 * @param string $type Type: 'plugin' or 'theme'.
	 * @return void
	 */
	public function delete( string $slug, string $type ): void {
		$tree = $this->client->fetch_tree();

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

		$remote_paths = FileMatcher::get_remote_paths_from_tree( $slug, $type, $tree );

		foreach ( $remote_paths as $remote_path ) {
			$local_path = FileMatcher::remote_to_local( $remote_path );

			if ( ! empty( $local_path ) && file_exists( $local_path ) ) {
				wp_delete_file( $local_path );
			}
		}
	}

	/**
	 * Download a remote file and save it locally.
	 *
	 * @param string             $remote_path Remote file path.
	 * @param WP_Filesystem_Base $filesystem  WordPress filesystem instance.
	 * @return true|WP_Error
	 */
	private function download_and_save( string $remote_path, WP_Filesystem_Base $filesystem ): bool|WP_Error {
		$content = $this->client->download_file( $remote_path );

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

		$local_path = FileMatcher::remote_to_local( $remote_path );

		if ( empty( $local_path ) ) {
			return new WP_Error( 'invalid_path', __( 'Could not determine local path.', 'hellopack-client' ) );
		}

		// $remote_path / $content come from the first-party, HelloPack-controlled
		// translation repo (see GitHubClient trust-model note) — full control over
		// what ships, nothing arbitrary gets in. remote_to_local() also clamps the
		// write to WP_LANG_DIR/{plugins,themes}. Keep this guarantee: if the source
		// ever accepts third-party content, validate the basename + realpath here
		// before writing (the file lands in a web-served directory).
		$written = $filesystem->put_contents( $local_path, $content, FS_CHMOD_FILE );

		if ( ! $written ) {
			return new WP_Error(
				'write_error',
				/* translators: %s: local file path */
				sprintf( __( 'Could not write file: %s', 'hellopack-client' ), $local_path )
			);
		}

		return true;
	}

	/**
	 * Ensure language directories exist.
	 *
	 * @param WP_Filesystem_Base $filesystem WordPress filesystem instance.
	 * @param string             $type       Type: 'plugin' or 'theme'.
	 * @return void
	 */
	private function ensure_directories( WP_Filesystem_Base $filesystem, string $type ): void {
		$dir = 'theme' === $type ? 'themes' : 'plugins';

		$target = WP_LANG_DIR . '/' . $dir;

		if ( ! $filesystem->is_dir( $target ) ) {
			$filesystem->mkdir( $target, FS_CHMOD_DIR );
		}
	}

	/**
	 * Get WordPress filesystem instance.
	 *
	 * @return WP_Filesystem_Base|WP_Error
	 */
	private function get_filesystem(): WP_Filesystem_Base|WP_Error {
		global $wp_filesystem;

		if ( ! function_exists( 'WP_Filesystem' ) ) {
			require_once ABSPATH . 'wp-admin/includes/file.php';
		}

		if ( ! WP_Filesystem() ) {
			return new WP_Error( 'filesystem_error', __( 'Could not initialize filesystem.', 'hellopack-client' ) );
		}

		return $wp_filesystem;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit