$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/TreeParser.php
<?php
/**
 * GitHub Tree Parser.
 *
 * @package HelloPack\Client
 */

declare( strict_types=1 );

namespace HelloPack\Client\Translate;

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

/**
 * Parses the GitHub tree into structured translation data.
 */
final class TreeParser {

	/**
	 * Supported file extensions for translation files.
	 */
	private const EXTENSIONS = array( '.mo', '.po', '.l10n.php', '.json' );

	/**
	 * Parse tree entries for a given tone and locale.
	 *
	 * Returns an array keyed by slug, containing type and file entries.
	 *
	 * @param array<int, array<string, string>> $tree   Raw tree from GitHub API.
	 * @param string                            $tone   Translation tone (formal/informal).
	 * @param string                            $locale Target locale (e.g. hu_HU).
	 * @return array<string, array{type: string, files: array<string, string>}>
	 */
	public static function parse( array $tree, string $tone, string $locale ): array {
		$results = array();

		foreach ( array( 'plugins', 'themes' ) as $type ) {
			$prefix = $tone . '/' . $type . '/' . $locale . '/';

			foreach ( $tree as $entry ) {
				if ( 'blob' !== ( $entry['type'] ?? '' ) ) {
					continue;
				}

				$path = $entry['path'] ?? '';

				if ( ! str_starts_with( $path, $prefix ) ) {
					continue;
				}

				$relative = substr( $path, strlen( $prefix ) );
				$parts    = explode( '/', $relative, 2 );

				if ( 2 !== count( $parts ) ) {
					continue;
				}

				$slug     = $parts[0];
				$filename = $parts[1];

				if ( ! self::is_translation_file( $filename ) ) {
					continue;
				}

				if ( ! isset( $results[ $slug ] ) ) {
					$results[ $slug ] = array(
						'type'  => 'themes' === $type ? 'theme' : 'plugin',
						'files' => array(),
					);
				}

				$results[ $slug ]['files'][ $filename ] = $entry['sha'] ?? '';
			}
		}

		return $results;
	}

	/**
	 * Extract available locales from the tree.
	 *
	 * @param array<int, array<string, string>> $tree Raw tree from GitHub API.
	 * @param string                            $tone Translation tone.
	 * @return array<string>
	 */
	public static function get_available_locales( array $tree, string $tone ): array {
		$locales = array();

		foreach ( $tree as $entry ) {
			if ( 'tree' !== ( $entry['type'] ?? '' ) ) {
				continue;
			}

			$path = $entry['path'] ?? '';

			if ( ! str_starts_with( $path, $tone . '/plugins/' ) && ! str_starts_with( $path, $tone . '/themes/' ) ) {
				continue;
			}

			$parts = explode( '/', $path );

			if ( 3 === count( $parts ) ) {
				$locales[ $parts[2] ] = true;
			}
		}

		$result = array_keys( $locales );
		sort( $result );

		return $result;
	}

	/**
	 * Check if a filename is a supported translation file.
	 *
	 * @param string $filename File name to check.
	 * @return bool
	 */
	private static function is_translation_file( string $filename ): bool {
		foreach ( self::EXTENSIONS as $ext ) {
			if ( str_ends_with( $filename, $ext ) ) {
				return true;
			}
		}

		return false;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit