403Webshell
Server IP : 38.190.208.107  /  Your IP : 216.73.217.46
Web Server : nginx/1.28.1
System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64
User : root ( 0)
PHP Version : 8.2.28
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /www/wwwroot/wp.4/wp-content/themes/woodmart/inc/admin/modules/import/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/wp.4/wp-content/themes/woodmart/inc/admin/modules/import/class-headers.php
<?php
/**
 * Import headers.
 *
 * @package woodmart
 */

namespace XTS\Admin\Modules\Import;

use Exception;
use XTS\Modules\Header_Builder;

if ( ! defined( 'WOODMART_THEME_DIR' ) ) {
	exit( 'No direct script access allowed' );
}

/**
 * Import headers.
 */
class Headers {
	/**
	 * Version name.
	 *
	 * @var string
	 */
	private $version;
	/**
	 * Helpers.
	 *
	 * @var Helpers
	 */
	private $helpers;

	/**
	 * Constructor.
	 *
	 * @param string $version Version name.
	 */
	public function __construct( $version ) {
		$this->helpers = Helpers::get_instance();
		$this->version = $version;

		$this->import_headers();
	}

	/**
	 * Import headers.
	 */
	private function import_headers() {
		try {
			for ( $i = 1; $i <= 5; $i++ ) {
				$header = $this->helpers->get_file_path( 'header-' . $i . '.json', $this->version );

				if ( 'elementor' === $this->helpers->get_page_builder() && file_exists( $this->helpers->get_version_folder_path( $this->version ) . 'header-' . $i . '-elementor.json' ) ) {
					$header = $this->helpers->get_file_path( 'header-' . $i . '-elementor.json', $this->version );
				} elseif ( 'gutenberg' === $this->helpers->get_page_builder() && file_exists( $this->helpers->get_version_folder_path( $this->version ) . 'header-' . $i . '-gutenberg.json' ) ) {
					$header = $this->helpers->get_file_path( 'header-' . $i . '-gutenberg.json', $this->version );
				}

				if ( $header ) {
					$this->create_new_header( $header, 1 === $i );
				}
			}
		} catch ( Exception $e ) {
			echo esc_html( '[ERROR] Header import<br>' );
		}
	}

	/**
	 * Create new header.
	 *
	 * @param string $file       File.
	 * @param bool   $is_default Default header.
	 */
	private function create_new_header( $file, $is_default = false ) {
		$builder       = Header_Builder::get_instance();
		$imported_data = get_option( 'wd_imported_data_' . $this->version );

		$header_data = $this->helpers->links_replace( $this->helpers->get_local_file_content( $file ), '/' );
		$header_data = $this->update_html_block_id( $header_data );

		$header_data = json_decode( $header_data, true );

		$builder->list->add_header( $header_data['id'], $header_data['name'] );
		$builder->factory->create_new( $header_data['id'], $header_data['name'], $header_data['structure'], $header_data['settings'] );

		$imported_data['headers'][ $header_data['id'] ] = $header_data['id'];

		update_option( 'wd_imported_data_' . $this->version, $imported_data, false );

		if ( $is_default ) {
			update_option( 'whb_main_header', $header_data['id'] );
		}
	}

	/**
	 * Update html block id in header.
	 *
	 * @param string $header_data Header data.
	 *
	 * @return string
	 */
	private function update_html_block_id( $header_data ) {
		$header_data_decoded = json_decode( $header_data, true );
		$imported_data       = $this->helpers->get_imported_data( $this->version );

		foreach ( $header_data_decoded['structure']['content'] as $row ) {
			foreach ( $row['content'] as $column ) {
				foreach ( $column['content'] as $element ) {
					if ( 'HTMLBlock' === $element['type'] ) {
						$current_id = $element['params']['block_id']['value'];
						$new_id     = '';

						if ( isset( $imported_data['all_posts'][ $current_id ]['new'] ) ) {
							$new_id = $imported_data['all_posts'][ $current_id ]['new'];
						}

						if ( $new_id ) {
							$header_data = str_replace( '"value": "' . $current_id . '"', '"value": "' . $new_id . '"', $header_data );
						}
					}

					if ( ( 'logo' === $element['type'] || 'infobox' === $element['type'] ) && ! empty( $element['params']['image']['value'] ) ) {
						$current_id = $element['params']['image']['value']['id'];
						$new_id     = '';

						if ( isset( $imported_data['all_posts'][ $current_id ]['new'] ) ) {
							$new_id = $imported_data['all_posts'][ $current_id ]['new'];
						}

						if ( $new_id ) {
							$header_data = str_replace( '"id": ' . $current_id, '"id": ' . $new_id, $header_data );
						}
					}
				}
			}
		}

		return $header_data;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit