Uname:Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64

403WebShell
403Webshell
Server IP : 188.114.97.2  /  Your IP : 104.23.243.200
Web Server : Apache/2.4.59 (Debian)
System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64
User : edlftp ( 1002)
PHP Version : 7.4.33
Disable Function : 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,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/nicolasj/www/propulseasbl.be/wp-content/plugins/wp-optimize/webp/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/nicolasj/www/propulseasbl.be/wp-content/plugins/wp-optimize/webp/class-wpo-webp-self-test.php
<?php

if (!defined('ABSPATH')) die('No direct access allowed');

if (!class_exists('WPO_WebP_Self_Test')) :

class WPO_WebP_Self_Test {

	/**
	 * Relative path to the test image used for WebP serving verification.
	 *
	 * @var string
	 */
	const TEST_IMAGE_PATH = '/wpo/images/wpo_logo_small.png';

	/**
	 * The MIME type for WebP images, used as the Accept header value
	 * and for content-type verification.
	 *
	 * @var string
	 */
	const WEBP_MIME_TYPE = 'image/webp';

	/**
	 * Determines whether the content-type header indicates a WebP image.
	 *
	 * @param array<string, string> $headers An array of response headers
	 *
	 * @return bool
	 */
	private function has_webp_mime($headers): bool {
		return isset($headers['content-type']) && 0 === strcasecmp(self::WEBP_MIME_TYPE, $headers['content-type']);
	}

	/**
	 * Determines whether the Vary header includes Accept.
	 *
	 * @param array<string, string> $headers An array of response headers
	 *
	 * @return bool
	 */
	private function has_vary($headers): bool {
		return isset($headers['vary']) && preg_match('/accept/i', $headers['vary']);
	}

	/**
	 * Determines whether a WebP version is served when requested with
	 * an appropriate Accept header.
	 *
	 * @return bool
	 */
	public function is_webp_served(): bool {
		$args = array(
			'headers' => array(
				'accept' => self::WEBP_MIME_TYPE
			)
		);

		$upload_dir = wp_upload_dir();
		$url = $upload_dir['baseurl'] . self::TEST_IMAGE_PATH;

		$response = wp_remote_head($url, $args);

		if (is_wp_error($response) || 200 !== $response['response']['code']) {
			return false;
		}

		$headers = wp_remote_retrieve_headers($response);
		if (is_object($headers) && method_exists($headers, 'getAll')) {
			$headers = $headers->getAll();
			return $this->has_webp_mime($headers) && $this->has_vary($headers);
		}
		return false;
	}

	/**
	 * Returns singleton instance
	 *
	 * @return WPO_WebP_Self_Test
	 */
	public static function get_instance(): self {
		static $_instance = null;
		if (null === $_instance) {
			$_instance = new self();
		}
		return $_instance;
	}
}

endif;

Youez - 2016 - github.com/yon3zu
LinuXploit