$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/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/Comparator.php
<?php
/**
 * Comparator class.
 *
 * @package HelloPack\Client
 */

declare( strict_types=1 );

namespace HelloPack\Client\Translate;

use WP_Error;

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

/**
 * Compares local and remote translations to determine status.
 */
final class Comparator {

	/**
	 * Locale for translations.
	 */
	private const LOCALE = 'hu_HU';

	/**
	 * Tone for translations.
	 */
	private const TONE = 'formal';

	/**
	 * Cache key for comparison results.
	 */
	private const CACHE_KEY = 'hellopack_translate_compare_hu_HU_formal';

	/**
	 * Compare all installed plugins/themes with remote translations.
	 *
	 * @return array<TranslationItem>|WP_Error
	 */
	public static function compare_all(): array|WP_Error {
		$cached = get_transient( self::CACHE_KEY );

		if ( is_array( $cached ) && ! empty( $cached ) ) {
			return $cached;
		}

		$client = new GitHubClient();
		$tree   = $client->fetch_tree();

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

		$remote_data = TreeParser::parse( $tree, self::TONE, self::LOCALE );
		$plugins     = LocalScanner::get_installed_plugins();
		$themes      = LocalScanner::get_installed_themes();
		$items       = array();

		$items = array_merge(
			$items,
			self::compare_type( $remote_data, $plugins, 'plugin', self::LOCALE )
		);

		$items = array_merge(
			$items,
			self::compare_type( $remote_data, $themes, 'theme', self::LOCALE )
		);

		set_transient( self::CACHE_KEY, $items, 3600 );

		return $items;
	}

	/**
	 * Clear the comparison cache transient.
	 */
	public static function clear_cache(): void {
		delete_transient( self::CACHE_KEY );
	}

	/**
	 * Compare a specific type (plugin or theme).
	 *
	 * @param array<string, array{type: string, files: array<string, string>}> $remote_data Parsed remote data.
	 * @param array<string, string>                                            $installed   Installed items (slug => name).
	 * @param string                                                           $type        Type: 'plugin' or 'theme'.
	 * @param string                                                           $locale      Locale code.
	 * @return array<TranslationItem>
	 */
	private static function compare_type( array $remote_data, array $installed, string $type, string $locale ): array {
		$items = array();

		foreach ( $installed as $slug => $name ) {
			if ( ! isset( $remote_data[ $slug ] ) ) {
				continue;
			}

			$remote = $remote_data[ $slug ];

			if ( $remote['type'] !== $type ) {
				continue;
			}

			$status     = self::determine_status( $slug, $type, $locale, $remote['files'] );
			$local_date = LocalScanner::get_local_date( $slug, $type, $locale );

			$items[] = new TranslationItem(
				slug: $slug,
				name: $name,
				type: $type,
				status: $status,
				file_count: count( $remote['files'] ),
				local_date: $local_date,
				files: $remote['files'],
			);
		}

		return $items;
	}

	/**
	 * Determine translation status by comparing SHA hashes.
	 *
	 * @param string               $slug   Plugin or theme slug.
	 * @param string               $type   Type: 'plugin' or 'theme'.
	 * @param string               $locale Locale code.
	 * @param array<string,string> $files  Remote files with SHA hashes.
	 * @return string Status constant.
	 */
	private static function determine_status( string $slug, string $type, string $locale, array $files ): string {
		$local_sha = LocalScanner::get_local_sha( $slug, $type, $locale );

		if ( null === $local_sha ) {
			return TranslationItem::STATUS_NOT_INSTALLED;
		}

		$mo_filename = $slug . '-' . $locale . '.mo';

		foreach ( $files as $filename => $remote_sha ) {
			if ( $filename === $mo_filename && $local_sha !== $remote_sha ) {
				return TranslationItem::STATUS_UPDATE;
			}
		}

		return TranslationItem::STATUS_UP_TO_DATE;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit