HEX
Server: Apache
System: Linux web2213.uni5.net 5.4.282-1.el8.elrepo.x86_64 #1 SMP Mon Aug 19 18:33:22 EDT 2024 x86_64
User: clinicamaciel (596848)
PHP: 7.3.33
Disabled: apache_child_terminate,c99_buff_prepare,c99_sess_put,dl,eval,exec,leak,link,myshellexec,openlog,passthru,pclose,pcntl_exec,php_check_syntax,php_strip_whitespace,popen,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,symlink,system,socket_listen,socket_create_listen,putenv
Upload Files
File: /home/clinicamaciel/www/wp-content/plugins/w3-total-cache/Cdn_Environment_Nginx.php
<?php
namespace W3TC;

/**
 * CDN rules generation for Nginx
 */
class Cdn_Environment_Nginx {
	private $c;



	public function __construct( $config ) {
		$this->c = $config;
	}



	public function generate( $cdnftp ) {
		$rules = '';
		$rule = $this->generate_canonical( $cdnftp );
		if ( !empty( $rule ) ) {
			$rules = $rule . "\n";
		}

		if ( $this->c->get_boolean( 'cdn.cors_header') ) {
			$rules_a = Dispatcher::nginx_rules_for_browsercache_section(
				$this->c, 'other', true );
			$rules_a[] = 'add_header Access-Control-Allow-Origin "*";';

			$rules .=
			"location ~ \\.(ttf|ttc|otf|eot|woff|woff2|font.css)\$ {\n" .
			'    ' . implode( "\n    ", $rules_a ) . "\n" .
			"}\n";
		}

		if ( strlen( $rules ) > 0 ) {
			$rules =
				W3TC_MARKER_BEGIN_CDN . "\n" .
				$rules .
				W3TC_MARKER_END_CDN . "\n";
		}

		return $rules;
	}



	public function generate_canonical( $cdnftp = false ) {
		if ( !$this->c->get_boolean( 'cdn.canonical_header' ) ) {
			return null;
		}

		$home = ( $cdnftp ? Util_Environment::home_url_host() : '$host' );

		return 'add_header Link "<$scheme://' .	$home .
			'$request_uri>; rel=\"canonical\"";';
	}



	public function w3tc_browsercache_rules_section_extensions(
			$extensions, $section ) {
		// CDN adds own rules for those extensions
		if ( $this->c->get_boolean( 'cdn.cors_header') ) {
			unset( $extensions['ttf|ttc'] );
			unset( $extensions['otf'] );
			unset( $extensions['eot'] );
			unset( $extensions['woff'] );
			unset( $extensions['woff2'] );
		}

		return $extensions;
	}
}