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 : crop-proxy.php
<?php

class Brizy_Public_CropProxy extends Brizy_Public_AbstractProxy {

	use Brizy_Editor_Trait_Sanitize;

	const ENDPOINT        = '_media';
	const ENDPOINT_FILTER = '_crop';

	/**
	 * @return array
	 */
	protected function get_endpoint_keys() {
		return [
			Brizy_Editor::prefix( self::ENDPOINT ),
			Brizy_Editor::prefix( self::ENDPOINT_FILTER )
		];
	}

	/**
	 * @return void
	 * @throws Exception
	 */
	public function process_query() {
		global $wp_query;

		$vars    = $wp_query->query_vars;
		$uidKey  = Brizy_Editor::prefix( self::ENDPOINT );
		$sizeKey = Brizy_Editor::prefix( self::ENDPOINT_FILTER );

		if ( empty( $vars[ $uidKey ] ) || empty( $vars[ $sizeKey ] ) ) {
			return;
		}

		do_action( 'brizy_before_extract_img' );

		session_write_close();

		try {

			$uid        = $this->sanitizeUid($vars[ $uidKey ]);
			$mediaCache = new Brizy_Editor_CropCacheMedia( Brizy_Editor_Project::get() );

			try {
				if ( substr( $uid, 0, 3 ) !== 'wp-' ) {
					$mediaCache->getAttachmentId( $uid );
				}
			} catch ( Exception $e ) {
				$mediaCache->download_original_image( $uid );
			}

			$croppedPath = $mediaCache->crop_media( $uid, html_entity_decode( $vars[ $sizeKey ] ) );

			do_action( 'brizy_before_send_asset' );

            ob_get_clean();

			$this->send_file( $croppedPath );

		} catch ( Exception $e ) {
			status_header( 404, $e->getMessage() );
			global $wp_query;
			$wp_query->set_404();

			return;
		}
	}
}
© 2025 XylotrechusZ