Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/litespee.../src
File: htaccess.cls.php
<?php
[0] Fix | Delete
// phpcs:ignoreFile
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* The htaccess rewrite rule operation class
[4] Fix | Delete
*
[5] Fix | Delete
* @since 1.0.0
[6] Fix | Delete
* @package LiteSpeed
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
namespace LiteSpeed;
[10] Fix | Delete
[11] Fix | Delete
defined('WPINC') || exit();
[12] Fix | Delete
[13] Fix | Delete
class Htaccess extends Root {
[14] Fix | Delete
[15] Fix | Delete
private $frontend_htaccess = null;
[16] Fix | Delete
private $_default_frontend_htaccess = null;
[17] Fix | Delete
private $backend_htaccess = null;
[18] Fix | Delete
private $_default_backend_htaccess = null;
[19] Fix | Delete
private $theme_htaccess = null; // Not used yet
[20] Fix | Delete
private $frontend_htaccess_readable = false;
[21] Fix | Delete
private $frontend_htaccess_writable = false;
[22] Fix | Delete
private $backend_htaccess_readable = false;
[23] Fix | Delete
private $backend_htaccess_writable = false;
[24] Fix | Delete
private $theme_htaccess_readable = false;
[25] Fix | Delete
private $theme_htaccess_writable = false;
[26] Fix | Delete
private $__rewrite_on;
[27] Fix | Delete
[28] Fix | Delete
const LS_MODULE_START = '<IfModule LiteSpeed>';
[29] Fix | Delete
const EXPIRES_MODULE_START = '<IfModule mod_expires.c>';
[30] Fix | Delete
const LS_MODULE_END = '</IfModule>';
[31] Fix | Delete
const LS_MODULE_REWRITE_START = '<IfModule mod_rewrite.c>';
[32] Fix | Delete
const REWRITE_ON = 'RewriteEngine on';
[33] Fix | Delete
const LS_MODULE_DONOTEDIT = '## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##';
[34] Fix | Delete
const MARKER = 'LSCACHE';
[35] Fix | Delete
const MARKER_NONLS = 'NON_LSCACHE';
[36] Fix | Delete
const MARKER_LOGIN_COOKIE = '### marker LOGIN COOKIE';
[37] Fix | Delete
const MARKER_ASYNC = '### marker ASYNC';
[38] Fix | Delete
const MARKER_CRAWLER = '### marker CRAWLER';
[39] Fix | Delete
const MARKER_MOBILE = '### marker MOBILE';
[40] Fix | Delete
const MARKER_NOCACHE_COOKIES = '### marker NOCACHE COOKIES';
[41] Fix | Delete
const MARKER_NOCACHE_USER_AGENTS = '### marker NOCACHE USER AGENTS';
[42] Fix | Delete
const MARKER_CACHE_RESOURCE = '### marker CACHE RESOURCE';
[43] Fix | Delete
const MARKER_BROWSER_CACHE = '### marker BROWSER CACHE';
[44] Fix | Delete
const MARKER_MINIFY = '### marker MINIFY';
[45] Fix | Delete
const MARKER_CORS = '### marker CORS';
[46] Fix | Delete
const MARKER_WEBP = '### marker WEBP';
[47] Fix | Delete
const MARKER_DROPQS = '### marker DROPQS';
[48] Fix | Delete
const MARKER_START = ' start ###';
[49] Fix | Delete
const MARKER_END = ' end ###';
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* Initialize the class and set its properties.
[53] Fix | Delete
*
[54] Fix | Delete
* @since 1.0.7
[55] Fix | Delete
*/
[56] Fix | Delete
public function __construct() {
[57] Fix | Delete
$this->_path_set();
[58] Fix | Delete
$this->_default_frontend_htaccess = $this->frontend_htaccess;
[59] Fix | Delete
$this->_default_backend_htaccess = $this->backend_htaccess;
[60] Fix | Delete
[61] Fix | Delete
$frontend_htaccess = defined('LITESPEED_CFG_HTACCESS') ? constant('LITESPEED_CFG_HTACCESS') : false;
[62] Fix | Delete
if ($frontend_htaccess && substr($frontend_htaccess, -10) === '/.htaccess') {
[63] Fix | Delete
$this->frontend_htaccess = $frontend_htaccess;
[64] Fix | Delete
}
[65] Fix | Delete
$backend_htaccess = defined('LITESPEED_CFG_HTACCESS_BACKEND') ? constant('LITESPEED_CFG_HTACCESS_BACKEND') : false;
[66] Fix | Delete
if ($backend_htaccess && substr($backend_htaccess, -10) === '/.htaccess') {
[67] Fix | Delete
$this->backend_htaccess = $backend_htaccess;
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
// Filter for frontend&backend htaccess path
[71] Fix | Delete
$this->frontend_htaccess = apply_filters('litespeed_frontend_htaccess', $this->frontend_htaccess);
[72] Fix | Delete
$this->backend_htaccess = apply_filters('litespeed_backend_htaccess', $this->backend_htaccess);
[73] Fix | Delete
[74] Fix | Delete
clearstatcache();
[75] Fix | Delete
[76] Fix | Delete
// frontend .htaccess privilege
[77] Fix | Delete
$test_permissions = file_exists($this->frontend_htaccess) ? $this->frontend_htaccess : dirname($this->frontend_htaccess);
[78] Fix | Delete
if (is_readable($test_permissions)) {
[79] Fix | Delete
$this->frontend_htaccess_readable = true;
[80] Fix | Delete
}
[81] Fix | Delete
if (is_writable($test_permissions)) {
[82] Fix | Delete
$this->frontend_htaccess_writable = true;
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
$this->__rewrite_on = array(
[86] Fix | Delete
self::REWRITE_ON,
[87] Fix | Delete
'CacheLookup on',
[88] Fix | Delete
'RewriteRule .* - [E=Cache-Control:no-autoflush]',
[89] Fix | Delete
'RewriteRule ' . preg_quote(LITESPEED_DATA_FOLDER) . '/debug/.*\.log$ - [F,L]',
[90] Fix | Delete
'RewriteRule ' . preg_quote(self::CONF_FILE) . ' - [F,L]',
[91] Fix | Delete
);
[92] Fix | Delete
[93] Fix | Delete
// backend .htaccess privilege
[94] Fix | Delete
if ($this->frontend_htaccess === $this->backend_htaccess) {
[95] Fix | Delete
$this->backend_htaccess_readable = $this->frontend_htaccess_readable;
[96] Fix | Delete
$this->backend_htaccess_writable = $this->frontend_htaccess_writable;
[97] Fix | Delete
} else {
[98] Fix | Delete
$test_permissions = file_exists($this->backend_htaccess) ? $this->backend_htaccess : dirname($this->backend_htaccess);
[99] Fix | Delete
if (is_readable($test_permissions)) {
[100] Fix | Delete
$this->backend_htaccess_readable = true;
[101] Fix | Delete
}
[102] Fix | Delete
if (is_writable($test_permissions)) {
[103] Fix | Delete
$this->backend_htaccess_writable = true;
[104] Fix | Delete
}
[105] Fix | Delete
}
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Get if htaccess file is readable
[110] Fix | Delete
*
[111] Fix | Delete
* @since 1.1.0
[112] Fix | Delete
* @return string
[113] Fix | Delete
*/
[114] Fix | Delete
private function _readable( $kind = 'frontend' ) {
[115] Fix | Delete
if ($kind === 'frontend') {
[116] Fix | Delete
return $this->frontend_htaccess_readable;
[117] Fix | Delete
}
[118] Fix | Delete
if ($kind === 'backend') {
[119] Fix | Delete
return $this->backend_htaccess_readable;
[120] Fix | Delete
}
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
/**
[124] Fix | Delete
* Get if htaccess file is writable
[125] Fix | Delete
*
[126] Fix | Delete
* @since 1.1.0
[127] Fix | Delete
* @return string
[128] Fix | Delete
*/
[129] Fix | Delete
public function writable( $kind = 'frontend' ) {
[130] Fix | Delete
if ($kind === 'frontend') {
[131] Fix | Delete
return $this->frontend_htaccess_writable;
[132] Fix | Delete
}
[133] Fix | Delete
if ($kind === 'backend') {
[134] Fix | Delete
return $this->backend_htaccess_writable;
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
/**
[139] Fix | Delete
* Get frontend htaccess path
[140] Fix | Delete
*
[141] Fix | Delete
* @since 1.1.0
[142] Fix | Delete
* @return string
[143] Fix | Delete
*/
[144] Fix | Delete
public static function get_frontend_htaccess( $show_default = false ) {
[145] Fix | Delete
if ($show_default) {
[146] Fix | Delete
return self::cls()->_default_frontend_htaccess;
[147] Fix | Delete
}
[148] Fix | Delete
return self::cls()->frontend_htaccess;
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
/**
[152] Fix | Delete
* Get backend htaccess path
[153] Fix | Delete
*
[154] Fix | Delete
* @since 1.1.0
[155] Fix | Delete
* @return string
[156] Fix | Delete
*/
[157] Fix | Delete
public static function get_backend_htaccess( $show_default = false ) {
[158] Fix | Delete
if ($show_default) {
[159] Fix | Delete
return self::cls()->_default_backend_htaccess;
[160] Fix | Delete
}
[161] Fix | Delete
return self::cls()->backend_htaccess;
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
/**
[165] Fix | Delete
* Check to see if .htaccess exists starting at $start_path and going up directories until it hits DOCUMENT_ROOT.
[166] Fix | Delete
*
[167] Fix | Delete
* As dirname() strips the ending '/', paths passed in must exclude the final '/'
[168] Fix | Delete
*
[169] Fix | Delete
* @since 1.0.11
[170] Fix | Delete
* @access private
[171] Fix | Delete
*/
[172] Fix | Delete
private function _htaccess_search( $start_path ) {
[173] Fix | Delete
while (!file_exists($start_path . '/.htaccess')) {
[174] Fix | Delete
if ($start_path === '/' || !$start_path) {
[175] Fix | Delete
return false;
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
if (!empty($_SERVER['DOCUMENT_ROOT']) && wp_normalize_path($start_path) === wp_normalize_path($_SERVER['DOCUMENT_ROOT'])) {
[179] Fix | Delete
return false;
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
if (dirname($start_path) === $start_path) {
[183] Fix | Delete
return false;
[184] Fix | Delete
}
[185] Fix | Delete
[186] Fix | Delete
$start_path = dirname($start_path);
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
return $start_path;
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
/**
[193] Fix | Delete
* Set the path class variables.
[194] Fix | Delete
*
[195] Fix | Delete
* @since 1.0.11
[196] Fix | Delete
* @access private
[197] Fix | Delete
*/
[198] Fix | Delete
private function _path_set() {
[199] Fix | Delete
$frontend = Router::frontend_path();
[200] Fix | Delete
$frontend_htaccess_search = $this->_htaccess_search($frontend); // The existing .htaccess path to be used for frontend .htaccess
[201] Fix | Delete
$this->frontend_htaccess = ($frontend_htaccess_search ?: $frontend) . '/.htaccess';
[202] Fix | Delete
[203] Fix | Delete
$backend = realpath(ABSPATH); // /home/user/public_html/backend/
[204] Fix | Delete
if ($frontend == $backend) {
[205] Fix | Delete
$this->backend_htaccess = $this->frontend_htaccess;
[206] Fix | Delete
return;
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
// Backend is a different path
[210] Fix | Delete
$backend_htaccess_search = $this->_htaccess_search($backend);
[211] Fix | Delete
// Found affected .htaccess
[212] Fix | Delete
if ($backend_htaccess_search) {
[213] Fix | Delete
$this->backend_htaccess = $backend_htaccess_search . '/.htaccess';
[214] Fix | Delete
return;
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
// Frontend path is the parent of backend path
[218] Fix | Delete
if (stripos($backend, $frontend . '/') === 0) {
[219] Fix | Delete
// backend use frontend htaccess
[220] Fix | Delete
$this->backend_htaccess = $this->frontend_htaccess;
[221] Fix | Delete
return;
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
$this->backend_htaccess = $backend . '/.htaccess';
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
/**
[228] Fix | Delete
* Get corresponding htaccess path
[229] Fix | Delete
*
[230] Fix | Delete
* @since 1.1.0
[231] Fix | Delete
* @param string $kind Frontend or backend
[232] Fix | Delete
* @return string Path
[233] Fix | Delete
*/
[234] Fix | Delete
public function htaccess_path( $kind = 'frontend' ) {
[235] Fix | Delete
switch ($kind) {
[236] Fix | Delete
case 'backend':
[237] Fix | Delete
$path = $this->backend_htaccess;
[238] Fix | Delete
break;
[239] Fix | Delete
[240] Fix | Delete
case 'frontend':
[241] Fix | Delete
default:
[242] Fix | Delete
$path = $this->frontend_htaccess;
[243] Fix | Delete
break;
[244] Fix | Delete
}
[245] Fix | Delete
return $path;
[246] Fix | Delete
}
[247] Fix | Delete
[248] Fix | Delete
/**
[249] Fix | Delete
* Get the content of the rules file.
[250] Fix | Delete
*
[251] Fix | Delete
* NOTE: will throw error if failed
[252] Fix | Delete
*
[253] Fix | Delete
* @since 1.0.4
[254] Fix | Delete
* @since 2.9 Used exception for failed reading
[255] Fix | Delete
* @access public
[256] Fix | Delete
*/
[257] Fix | Delete
public function htaccess_read( $kind = 'frontend' ) {
[258] Fix | Delete
$path = $this->htaccess_path($kind);
[259] Fix | Delete
[260] Fix | Delete
if (!$path || !file_exists($path)) {
[261] Fix | Delete
return "\n";
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
if (!$this->_readable($kind)) {
[265] Fix | Delete
Error::t('HTA_R');
[266] Fix | Delete
}
[267] Fix | Delete
[268] Fix | Delete
$content = File::read($path);
[269] Fix | Delete
if ($content === false) {
[270] Fix | Delete
Error::t('HTA_GET');
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
// Remove ^M characters.
[274] Fix | Delete
$content = str_ireplace("\x0D", '', $content);
[275] Fix | Delete
return $content;
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
/**
[279] Fix | Delete
* Try to backup the .htaccess file if we didn't save one before.
[280] Fix | Delete
*
[281] Fix | Delete
* NOTE: will throw error if failed
[282] Fix | Delete
*
[283] Fix | Delete
* @since 1.0.10
[284] Fix | Delete
* @access private
[285] Fix | Delete
*/
[286] Fix | Delete
private function _htaccess_backup( $kind = 'frontend' ) {
[287] Fix | Delete
$path = $this->htaccess_path($kind);
[288] Fix | Delete
[289] Fix | Delete
if (!file_exists($path)) {
[290] Fix | Delete
return;
[291] Fix | Delete
}
[292] Fix | Delete
[293] Fix | Delete
if (file_exists($path . '.bk')) {
[294] Fix | Delete
return;
[295] Fix | Delete
}
[296] Fix | Delete
[297] Fix | Delete
$res = copy($path, $path . '.bk');
[298] Fix | Delete
[299] Fix | Delete
// Failed to backup, abort
[300] Fix | Delete
if (!$res) {
[301] Fix | Delete
Error::t('HTA_BK');
[302] Fix | Delete
}
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
/**
[306] Fix | Delete
* Get mobile view rule from htaccess file
[307] Fix | Delete
*
[308] Fix | Delete
* NOTE: will throw error if failed
[309] Fix | Delete
*
[310] Fix | Delete
* @since 1.1.0
[311] Fix | Delete
*/
[312] Fix | Delete
public function current_mobile_agents() {
[313] Fix | Delete
$rules = $this->_get_rule_by(self::MARKER_MOBILE);
[314] Fix | Delete
if (!isset($rules[0])) {
[315] Fix | Delete
Error::t('HTA_DNF', self::MARKER_MOBILE);
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
$rule = trim($rules[0]);
[319] Fix | Delete
// 'RewriteCond %{HTTP_USER_AGENT} ' . Utility::arr2regex( $cfg[ $id ], true ) . ' [NC]';
[320] Fix | Delete
$match = substr($rule, strlen('RewriteCond %{HTTP_USER_AGENT} '), -strlen(' [NC]'));
[321] Fix | Delete
[322] Fix | Delete
if (!$match) {
[323] Fix | Delete
Error::t('HTA_DNF', __('Mobile Agent Rules', 'litespeed-cache'));
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
return $match;
[327] Fix | Delete
}
[328] Fix | Delete
[329] Fix | Delete
/**
[330] Fix | Delete
* Parse rewrites rule from the .htaccess file.
[331] Fix | Delete
*
[332] Fix | Delete
* NOTE: will throw error if failed
[333] Fix | Delete
*
[334] Fix | Delete
* @since 1.1.0
[335] Fix | Delete
* @access public
[336] Fix | Delete
*/
[337] Fix | Delete
public function current_login_cookie( $kind = 'frontend' ) {
[338] Fix | Delete
$rule = $this->_get_rule_by(self::MARKER_LOGIN_COOKIE, $kind);
[339] Fix | Delete
[340] Fix | Delete
if (!$rule) {
[341] Fix | Delete
Error::t('HTA_DNF', self::MARKER_LOGIN_COOKIE);
[342] Fix | Delete
}
[343] Fix | Delete
[344] Fix | Delete
if (strpos($rule, 'RewriteRule .? - [E=') !== 0) {
[345] Fix | Delete
Error::t('HTA_LOGIN_COOKIE_INVALID');
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
$rule_cookie = substr($rule, strlen('RewriteRule .? - [E='), -1);
[349] Fix | Delete
[350] Fix | Delete
if (LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS') {
[351] Fix | Delete
$rule_cookie = trim($rule_cookie, '"');
[352] Fix | Delete
}
[353] Fix | Delete
[354] Fix | Delete
// Drop `Cache-Vary:`
[355] Fix | Delete
$rule_cookie = substr($rule_cookie, strlen('Cache-Vary:'));
[356] Fix | Delete
[357] Fix | Delete
return $rule_cookie;
[358] Fix | Delete
}
[359] Fix | Delete
[360] Fix | Delete
/**
[361] Fix | Delete
* Get rewrite rules based on the marker
[362] Fix | Delete
*
[363] Fix | Delete
* @since 2.0
[364] Fix | Delete
* @access private
[365] Fix | Delete
*/
[366] Fix | Delete
private function _get_rule_by( $cond, $kind = 'frontend' ) {
[367] Fix | Delete
clearstatcache();
[368] Fix | Delete
$path = $this->htaccess_path($kind);
[369] Fix | Delete
if (!$this->_readable($kind)) {
[370] Fix | Delete
return false;
[371] Fix | Delete
}
[372] Fix | Delete
[373] Fix | Delete
$rules = File::extract_from_markers($path, self::MARKER);
[374] Fix | Delete
if (!in_array($cond . self::MARKER_START, $rules) || !in_array($cond . self::MARKER_END, $rules)) {
[375] Fix | Delete
return false;
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
$key_start = array_search($cond . self::MARKER_START, $rules);
[379] Fix | Delete
$key_end = array_search($cond . self::MARKER_END, $rules);
[380] Fix | Delete
if ($key_start === false || $key_end === false) {
[381] Fix | Delete
return false;
[382] Fix | Delete
}
[383] Fix | Delete
[384] Fix | Delete
$results = array_slice($rules, $key_start + 1, $key_end - $key_start - 1);
[385] Fix | Delete
if (!$results) {
[386] Fix | Delete
return false;
[387] Fix | Delete
}
[388] Fix | Delete
[389] Fix | Delete
if (count($results) == 1) {
[390] Fix | Delete
return trim($results[0]);
[391] Fix | Delete
}
[392] Fix | Delete
[393] Fix | Delete
return array_filter($results);
[394] Fix | Delete
}
[395] Fix | Delete
[396] Fix | Delete
/**
[397] Fix | Delete
* Generate browser cache rules
[398] Fix | Delete
*
[399] Fix | Delete
* @since 1.3
[400] Fix | Delete
* @access private
[401] Fix | Delete
* @return array Rules set
[402] Fix | Delete
*/
[403] Fix | Delete
private function _browser_cache_rules( $cfg ) {
[404] Fix | Delete
/**
[405] Fix | Delete
* Add ttl setting
[406] Fix | Delete
*
[407] Fix | Delete
* @since 1.6.3
[408] Fix | Delete
*/
[409] Fix | Delete
$id = Base::O_CACHE_TTL_BROWSER;
[410] Fix | Delete
$ttl = $cfg[$id];
[411] Fix | Delete
$rules = array(
[412] Fix | Delete
self::EXPIRES_MODULE_START,
[413] Fix | Delete
// '<FilesMatch "\.(pdf|ico|svg|xml|jpg|jpeg|png|gif|webp|ogg|mp4|webm|js|css|woff|woff2|ttf|eot)(\.gz)?$">',
[414] Fix | Delete
'ExpiresActive on',
[415] Fix | Delete
'ExpiresByType application/pdf A' . $ttl,
[416] Fix | Delete
'ExpiresByType image/x-icon A' . $ttl,
[417] Fix | Delete
'ExpiresByType image/vnd.microsoft.icon A' . $ttl,
[418] Fix | Delete
'ExpiresByType image/svg+xml A' . $ttl,
[419] Fix | Delete
'',
[420] Fix | Delete
'ExpiresByType image/jpg A' . $ttl,
[421] Fix | Delete
'ExpiresByType image/jpeg A' . $ttl,
[422] Fix | Delete
'ExpiresByType image/png A' . $ttl,
[423] Fix | Delete
'ExpiresByType image/gif A' . $ttl,
[424] Fix | Delete
'ExpiresByType image/webp A' . $ttl,
[425] Fix | Delete
'ExpiresByType image/avif A' . $ttl,
[426] Fix | Delete
'',
[427] Fix | Delete
'ExpiresByType video/ogg A' . $ttl,
[428] Fix | Delete
'ExpiresByType audio/ogg A' . $ttl,
[429] Fix | Delete
'ExpiresByType video/mp4 A' . $ttl,
[430] Fix | Delete
'ExpiresByType video/webm A' . $ttl,
[431] Fix | Delete
'',
[432] Fix | Delete
'ExpiresByType text/css A' . $ttl,
[433] Fix | Delete
'ExpiresByType text/javascript A' . $ttl,
[434] Fix | Delete
'ExpiresByType application/javascript A' . $ttl,
[435] Fix | Delete
'ExpiresByType application/x-javascript A' . $ttl,
[436] Fix | Delete
'',
[437] Fix | Delete
'ExpiresByType application/x-font-ttf A' . $ttl,
[438] Fix | Delete
'ExpiresByType application/x-font-woff A' . $ttl,
[439] Fix | Delete
'ExpiresByType application/font-woff A' . $ttl,
[440] Fix | Delete
'ExpiresByType application/font-woff2 A' . $ttl,
[441] Fix | Delete
'ExpiresByType application/vnd.ms-fontobject A' . $ttl,
[442] Fix | Delete
'ExpiresByType font/ttf A' . $ttl,
[443] Fix | Delete
'ExpiresByType font/otf A' . $ttl,
[444] Fix | Delete
'ExpiresByType font/woff A' . $ttl,
[445] Fix | Delete
'ExpiresByType font/woff2 A' . $ttl,
[446] Fix | Delete
'',
[447] Fix | Delete
// '</FilesMatch>',
[448] Fix | Delete
self::LS_MODULE_END,
[449] Fix | Delete
);
[450] Fix | Delete
return $rules;
[451] Fix | Delete
}
[452] Fix | Delete
[453] Fix | Delete
/**
[454] Fix | Delete
* Generate CORS rules for fonts
[455] Fix | Delete
*
[456] Fix | Delete
* @since 1.5
[457] Fix | Delete
* @access private
[458] Fix | Delete
* @return array Rules set
[459] Fix | Delete
*/
[460] Fix | Delete
private function _cors_rules() {
[461] Fix | Delete
return array(
[462] Fix | Delete
'<FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font\.css)$">',
[463] Fix | Delete
'<IfModule mod_headers.c>',
[464] Fix | Delete
'Header set Access-Control-Allow-Origin "*"',
[465] Fix | Delete
'</IfModule>',
[466] Fix | Delete
'</FilesMatch>',
[467] Fix | Delete
);
[468] Fix | Delete
}
[469] Fix | Delete
[470] Fix | Delete
/**
[471] Fix | Delete
* Generate rewrite rules based on settings
[472] Fix | Delete
*
[473] Fix | Delete
* @since 1.3
[474] Fix | Delete
* @access private
[475] Fix | Delete
* @param array $cfg The settings to be used for rewrite rule
[476] Fix | Delete
* @return array Rules array
[477] Fix | Delete
*/
[478] Fix | Delete
private function _generate_rules( $cfg ) {
[479] Fix | Delete
$new_rules = array();
[480] Fix | Delete
$new_rules_nonls = array();
[481] Fix | Delete
$new_rules_backend = array();
[482] Fix | Delete
$new_rules_backend_nonls = array();
[483] Fix | Delete
[484] Fix | Delete
// continual crawler
[485] Fix | Delete
// $id = Base::O_CRAWLER;
[486] Fix | Delete
// if (!empty($cfg[$id])) {
[487] Fix | Delete
$new_rules[] = self::MARKER_ASYNC . self::MARKER_START;
[488] Fix | Delete
$new_rules[] = 'RewriteCond %{REQUEST_URI} /wp-admin/admin-ajax\.php';
[489] Fix | Delete
$new_rules[] = 'RewriteCond %{QUERY_STRING} action=async_litespeed';
[490] Fix | Delete
$new_rules[] = 'RewriteRule .* - [E=noabort:1]';
[491] Fix | Delete
$new_rules[] = self::MARKER_ASYNC . self::MARKER_END;
[492] Fix | Delete
$new_rules[] = '';
[493] Fix | Delete
// }
[494] Fix | Delete
[495] Fix | Delete
// mobile agents
[496] Fix | Delete
$id = Base::O_CACHE_MOBILE_RULES;
[497] Fix | Delete
if ((!empty($cfg[Base::O_CACHE_MOBILE]) || !empty($cfg[Base::O_GUEST])) && !empty($cfg[$id])) {
[498] Fix | Delete
$new_rules[] = self::MARKER_MOBILE . self::MARKER_START;
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function