Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.112.1
Your Ip: 216.73.216.223
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : proxy.php
<?php


class Brizy_Admin_Cloud_Proxy {

	const ACTION = 'brizy_cloud_proxy';

	/**
	 * Brizy_Admin_Cloud_Proxy constructor.
	 */
	public function __construct() {
		add_action( 'wp_ajax_' . self::ACTION, array( $this, 'handleRequest' ) );
	}

	/**
	 * @throws Exception
	 */
	public function handleRequest() {

		$vars = $_GET;

		$project = Brizy_Editor_Project::get();

		// redirect the request
		$token          = $project->getMetaValue( 'brizy-cloud-token' );
		$cloudProjectId = $project->getMetaValue( 'brizy-cloud-project' );

		if ( ! isset( $vars['endpoint'] ) ) {
			wp_send_json_error( null, 400 );
			exit;
		}

		if ( ! $token || ! $cloudProjectId || ! isset( $vars['endpoint'] ) ) {
			wp_send_json_error( null, 401 );
			exit;
		}

		$http     = new WP_Http();
		$url      = Brizy_Config::CLOUD_ENDPOINT . "/api/" . $vars['endpoint'];
		$response = $http->request( $url, array(
			'headers' => array(
				'X-AUTH-APP-TOKEN'  => Brizy_Config::CLOUD_APP_KEY,
				'X-AUTH-USER-TOKEN' => $token
			),
			'body'    => $_REQUEST['request'],
			'method'  => $_SERVER['REQUEST_METHOD'],
		) );

		$status = wp_remote_retrieve_response_code( $response );

		if ( $response instanceof WP_Error ) {
			wp_send_json_error( wp_remote_retrieve_response_message( $response ), $status );
			exit;
		}

		wp_send_json_success( wp_remote_retrieve_body( $response ), $status );
		exit;
	}
}
© 2025 XylotrechusZ