HEX
Server: LiteSpeed
System: Linux melbournecleaninggroup 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: www-data (33)
PHP: 7.3.33-1+focal
Disabled: 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_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/html/wp-content/plugins/brizy/public/block-screenshot-proxy.php
<?php


class Brizy_Public_BlockScreenshotProxy extends Brizy_Public_AbstractProxy {

	const ENDPOINT = '_block_screenshot';
	const ENDPOINT_POST = '_post';

	/**
	 * @return string
	 */
	protected function get_endpoint_keys() {
		return array( Brizy_Editor::prefix( self::ENDPOINT), Brizy_Editor::prefix( self::ENDPOINT_POST) );
	}

	public function process_query() {
		global $wp_query;
		$vars = $wp_query->query_vars;

		// Check if user is not querying API
		$endpoint = Brizy_Editor::prefix( self::ENDPOINT );
		$endpointPost = Brizy_Editor::prefix( self::ENDPOINT_POST );
		if ( ! isset( $vars[ $endpoint ] ) || ! is_string( $vars[ $endpoint ] ) ) {
			return;
		}
		$noCacheHeaders = array(
			'Cache-Control' => 'max-age=600'
		);
		session_write_close();

		$screenUID = $vars[ $endpoint ];
		$postID    = isset( $vars[ $endpointPost ] ) ? $vars[ $endpointPost] : null;

		$manager = new Brizy_Editor_Screenshot_Manager( new Brizy_Editor_UrlBuilder( null ) );

		$screenPath = $manager->getScreenshot( $screenUID, $postID );

		if ( $screenPath ) {
			$this->send_file( $screenPath, $noCacheHeaders );
			return;
		}

		// try to get the screenshot from cloud
		$client = new Brizy_Admin_Cloud_Client( Brizy_Editor_Project::get(), new WP_Http() );
		$url    = $client->getScreenshotUrl( $screenUID );

		$image_content = Brizy_Editor_Asset_StaticFile::get_asset_content($url);

		if(!$image_content) {
			Brizy_Logger::instance()->error( 'Unable to obtain screenshot content. Probably the function file_get_contents is disabled or it does not work with external urls' );
			return;
		}

		$result        = $manager->saveScreenshot( $screenUID, 'saved', $image_content, null );

		if ( $result ) {
			$screenPath = $manager->getScreenshot( $screenUID, $postID );
			$this->send_file( $screenPath, $noCacheHeaders );
		}
	}
}