diff --git a/plugin.php b/plugin.php
index d49235ec..e99a5cfd 100644
--- a/plugin.php
+++ b/plugin.php
@@ -2,14 +2,15 @@
if (!defined('WPINC')) {
exit('Do NOT access this file directly: '.basename(__FILE__));
}
-$GLOBALS['wp_php_rv'] = '5.3.2'; //php-required-version// // Leaving this at v5.3.2 so that we can have more control over Dashboard messages below.
+$GLOBALS['wp_php_rv']['rv'] = '5.3.2'; //php-required-version// // Leaving this at v5.3.2 so that we can have more control over Dashboard messages below.
+$GLOBALS['wp_php_rv']['re'] = array('mbstring');
if (require(dirname(__FILE__).'/src/vendor/websharks/wp-php-rv/src/includes/check.php')) {
if (!empty($_REQUEST['comet_cache_mbstring_deprecated_warning_bypass']) && is_admin()) {
update_site_option('comet_cache_mbstring_deprecated_warning_bypass', time());
}
- ${__FILE__}['apc_enabled'] = (extension_loaded('apc') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.cache_by_default'), FILTER_VALIDATE_BOOLEAN) && stripos((string) ini_get('apc.filters'), 'comet-cache') === false) ? true : false;
+ ${__FILE__}['apc_enabled'] = (extension_loaded('apc') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.cache_by_default'), FILTER_VALIDATE_BOOLEAN) && mb_stripos((string) ini_get('apc.filters'), 'comet-cache') === false) ? true : false;
if ((!version_compare(PHP_VERSION, '5.4', '>=') || ${__FILE__}['apc_enabled'])) { // If PHP <= 5.4 or APC is enabled
diff --git a/src/includes/classes/Actions.php b/src/includes/classes/Actions.php
index a4110acf..c1359c13 100644
--- a/src/includes/classes/Actions.php
+++ b/src/includes/classes/Actions.php
@@ -250,8 +250,8 @@ protected function ajaxClearCacheUrl($args)
}
$is_multisite = is_multisite();
$is_home = rtrim($url, '/') === rtrim($home_url, '/');
- $url_host = strtolower(parse_url($url, PHP_URL_HOST));
- $home_host = strtolower(parse_url($home_url, PHP_URL_HOST));
+ $url_host = mb_strtolower(parse_url($url, PHP_URL_HOST));
+ $home_host = mb_strtolower(parse_url($home_url, PHP_URL_HOST));
$is_offsite_host = !$is_multisite && $url_host !== $home_host;
if (!$this->plugin->currentUserCanClearCache()) {
diff --git a/src/includes/classes/AdvCacheBackCompat.php b/src/includes/classes/AdvCacheBackCompat.php
index 338e5012..7f2e7dda 100644
--- a/src/includes/classes/AdvCacheBackCompat.php
+++ b/src/includes/classes/AdvCacheBackCompat.php
@@ -44,16 +44,16 @@ public static function zcRequestVars()
*/
public static function zenCacheConstants()
{
- $_global_ns = strtoupper(GLOBAL_NS);
+ $_global_ns = mb_strtoupper(GLOBAL_NS);
if (!($constants = get_defined_constants(true)) || empty($constants['user'])) {
return; // Nothing to do; i.e. no user-defined constants.
}
foreach ($constants['user'] as $_constant => $_value) {
- if (stripos($_constant, 'ZENCACHE_') !== 0) {
+ if (mb_stripos($_constant, 'ZENCACHE_') !== 0) {
continue; // Nothing to do here.
}
- if (!($_constant_sub_name = substr($_constant, 9))) {
+ if (!($_constant_sub_name = mb_substr($_constant, 9))) {
continue; // Nothing to do here.
}
if (!defined($_global_ns.'_'.$_constant_sub_name)) {
diff --git a/src/includes/classes/AutoCache.php b/src/includes/classes/AutoCache.php
index 4b063dd0..6c049fc0 100644
--- a/src/includes/classes/AutoCache.php
+++ b/src/includes/classes/AutoCache.php
@@ -140,7 +140,7 @@ protected function autoCacheUrl($url)
if (!($url = trim((string) $url))) {
return; // Nothing to do.
}
- if (!$this->plugin->options['get_requests'] && strpos($url, '?') !== false) {
+ if (!$this->plugin->options['get_requests'] && mb_strpos($url, '?') !== false) {
return; // We're NOT caching URLs with a query string.
}
$cache_path = $this->plugin->buildCachePath($url);
@@ -178,7 +178,7 @@ protected function logAutoCacheUrl($url, $wp_remote_get_response)
{
$cache_dir = $this->plugin->cacheDir();
$cache_lock = $this->plugin->cacheLock();
- $auto_cache_log_file = $cache_dir.'/'.strtolower(SHORT_NAME).'-auto-cache.log';
+ $auto_cache_log_file = $cache_dir.'/'.mb_strtolower(SHORT_NAME).'-auto-cache.log';
if (is_file($auto_cache_log_file) && !is_writable($auto_cache_log_file)) {
throw new \Exception(sprintf(__('Auto-cache log file is NOT writable: `%1$s`. Please set permissions to `644` (or higher). `666` might be needed in some cases.', SLUG_TD), $auto_cache_log_file));
@@ -196,7 +196,7 @@ protected function logAutoCacheUrl($url, $wp_remote_get_response)
file_put_contents($auto_cache_log_file, $log_entry, FILE_APPEND);
if (filesize($auto_cache_log_file) > 2097152) {
- rename($auto_cache_log_file, substr($auto_cache_log_file, 0, -4).'-archived-'.time().'.log');
+ rename($auto_cache_log_file, mb_substr($auto_cache_log_file, 0, -4).'-archived-'.time().'.log');
}
$this->plugin->cacheUnlock($cache_lock); // Release.
}
@@ -215,7 +215,7 @@ protected function logAutoCacheRun($total_urls, $total_time)
{
$cache_dir = $this->plugin->cacheDir();
$cache_lock = $this->plugin->cacheLock();
- $auto_cache_log_file = $cache_dir.'/'.strtolower(SHORT_NAME).'-auto-cache.log';
+ $auto_cache_log_file = $cache_dir.'/'.mb_strtolower(SHORT_NAME).'-auto-cache.log';
if (is_file($auto_cache_log_file) && !is_writable($auto_cache_log_file)) {
throw new \Exception(sprintf(__('Auto-cache log file is NOT writable: `%1$s`. Please set permissions to `644` (or higher). `666` might be needed in some cases.', SLUG_TD), $auto_cache_log_file));
@@ -228,7 +228,7 @@ protected function logAutoCacheRun($total_urls, $total_time)
file_put_contents($auto_cache_log_file, $log_entry, FILE_APPEND);
if (filesize($auto_cache_log_file) > 2097152) {
- rename($auto_cache_log_file, substr($auto_cache_log_file, 0, -4).'-archived-'.time().'.log');
+ rename($auto_cache_log_file, mb_substr($auto_cache_log_file, 0, -4).'-archived-'.time().'.log');
}
$this->plugin->cacheUnlock($cache_lock); // Release.
}
diff --git a/src/includes/classes/CdnFilters.php b/src/includes/classes/CdnFilters.php
index 777097fc..2d25c583 100644
--- a/src/includes/classes/CdnFilters.php
+++ b/src/includes/classes/CdnFilters.php
@@ -138,9 +138,9 @@ public function __construct()
// Host-related properties.
- $this->local_host = strtolower($this->plugin->hostToken());
- $this->cdn_host = strtolower($this->plugin->options['cdn_host']);
- $this->cdn_hosts = strtolower($this->plugin->options['cdn_hosts']);
+ $this->local_host = mb_strtolower($this->plugin->hostToken());
+ $this->cdn_host = mb_strtolower($this->plugin->options['cdn_host']);
+ $this->cdn_hosts = mb_strtolower($this->plugin->options['cdn_hosts']);
$this->parseCdnHosts(); // Convert CDN hosts to an array.
// Configure invalidation-related properties.
@@ -158,7 +158,7 @@ public function __construct()
if (!($cdn_whitelisted_extensions = trim($this->plugin->options['cdn_whitelisted_extensions']))) {
$cdn_whitelisted_extensions = implode('|', static::defaultWhitelistedExtensions());
}
- $this->cdn_whitelisted_extensions = trim(strtolower($cdn_whitelisted_extensions), "\r\n\t\0\x0B".' |;,');
+ $this->cdn_whitelisted_extensions = trim(mb_strtolower($cdn_whitelisted_extensions), "\r\n\t\0\x0B".' |;,');
$this->cdn_whitelisted_extensions = preg_split('/[|;,\s]+/', $this->cdn_whitelisted_extensions, -1, PREG_SPLIT_NO_EMPTY);
$this->cdn_whitelisted_extensions = array_unique($this->cdn_whitelisted_extensions);
@@ -166,7 +166,7 @@ public function __construct()
$cdn_blacklisted_extensions = $this->plugin->options['cdn_blacklisted_extensions'];
- $this->cdn_blacklisted_extensions = trim(strtolower($cdn_blacklisted_extensions), "\r\n\t\0\x0B".' |;,');
+ $this->cdn_blacklisted_extensions = trim(mb_strtolower($cdn_blacklisted_extensions), "\r\n\t\0\x0B".' |;,');
$this->cdn_blacklisted_extensions = preg_split('/[|;,\s]+/', $this->cdn_blacklisted_extensions, -1, PREG_SPLIT_NO_EMPTY);
$this->cdn_blacklisted_extensions[] = 'php'; // Always exclude.
@@ -174,18 +174,18 @@ public function __construct()
// Whitelisted URI patterns; if applicable.
- $cdn_whitelisted_uri_patterns = trim(strtolower($this->plugin->options['cdn_whitelisted_uri_patterns']));
+ $cdn_whitelisted_uri_patterns = trim(mb_strtolower($this->plugin->options['cdn_whitelisted_uri_patterns']));
$cdn_whitelisted_uri_patterns = preg_split('/['."\r\n".']+/', $cdn_whitelisted_uri_patterns, null, PREG_SPLIT_NO_EMPTY);
$cdn_whitelisted_uri_patterns = array_unique($cdn_whitelisted_uri_patterns);
if ($cdn_whitelisted_uri_patterns) {
$this->cdn_whitelisted_uri_patterns = '/(?:'.implode('|', array_map(function ($pattern) {
- return preg_replace(['/\\\\\*/', '/\\\\\^/'], ['.*?', '[^\/]*?'], preg_quote('/'.ltrim($pattern, '/'), '/'));
- }, $cdn_whitelisted_uri_patterns)).')/i'; // CaSe inSensitive.
+ return preg_replace(['/\\\\\*/u', '/\\\\\^/u'], ['.*?', '[^\/]*?'], preg_quote('/'.ltrim($pattern, '/'), '/'));
+ }, $cdn_whitelisted_uri_patterns)).')/ui'; // CaSe inSensitive.
}
// Blacklisted URI patterns; if applicable.
- $cdn_blacklisted_uri_patterns = trim(strtolower($this->plugin->options['cdn_blacklisted_uri_patterns']));
+ $cdn_blacklisted_uri_patterns = trim(mb_strtolower($this->plugin->options['cdn_blacklisted_uri_patterns']));
$cdn_blacklisted_uri_patterns = preg_split('/['."\r\n".']+/', $cdn_blacklisted_uri_patterns, null, PREG_SPLIT_NO_EMPTY);
$cdn_blacklisted_uri_patterns[] = '*/wp-admin/*'; // Always.
@@ -199,8 +199,8 @@ public function __construct()
if ($cdn_blacklisted_uri_patterns) {
$this->cdn_blacklisted_uri_patterns = '/(?:'.implode('|', array_map(function ($pattern) {
- return preg_replace(['/\\\\\*/', '/\\\\\^/'], ['.*?', '[^\/]*?'], preg_quote('/'.ltrim($pattern, '/'), '/'));
- }, $cdn_blacklisted_uri_patterns)).')/i'; // CaSe inSensitive.
+ return preg_replace(['/\\\\\*/u', '/\\\\\^/u'], ['.*?', '[^\/]*?'], preg_quote('/'.ltrim($pattern, '/'), '/'));
+ }, $cdn_blacklisted_uri_patterns)).')/ui'; // CaSe inSensitive.
}
// Maybe attach filters.
@@ -337,7 +337,7 @@ public function contentFilter($string)
if (!($string = (string) $string)) {
return $string; // Nothing to do.
}
- if (strpos($string, '<') === false) {
+ if (mb_strpos($string, '<') === false) {
return $string; // Nothing to do.
}
@@ -357,7 +357,7 @@ public function contentFilter($string)
'(\>)'.// Tag close; group #9.
- '/i'; // End regex pattern; case insensitive.
+ '/ui'; // End regex pattern; case insensitive.
$orig_string = $string; // In case of regex errors.
$string = preg_replace_callback($regex_url_attrs, function ($m) {
@@ -462,16 +462,16 @@ protected function localFile($url_uri_qsl)
if (empty($parsed['host']) && empty($this->cdn_hosts[$this->local_host])) {
return; // Not on this host name.
}
- if (!empty($parsed['host']) && empty($this->cdn_hosts[strtolower($parsed['host'])])) {
+ if (!empty($parsed['host']) && empty($this->cdn_hosts[mb_strtolower($parsed['host'])])) {
return; // Not on this host name.
}
if (!isset($parsed['path'][0]) || $parsed['path'][0] !== '/') {
return; // Missing or unexpected path.
}
- if (substr($parsed['path'], -1) === '/') {
+ if (mb_substr($parsed['path'], -1) === '/') {
return; // Directory, not a file.
}
- if (strpos($parsed['path'], '..') !== false || strpos($parsed['path'], './') !== false) {
+ if (mb_strpos($parsed['path'], '..') !== false || mb_strpos($parsed['path'], './') !== false) {
return; // A relative path that is not absolute.
}
$scheme = null; // Default scheme handling.
@@ -479,10 +479,10 @@ protected function localFile($url_uri_qsl)
$uri = $parsed['path']; // Put URI together.
if (!empty($parsed['scheme'])) {
- $scheme = strtolower($parsed['scheme']);
+ $scheme = mb_strtolower($parsed['scheme']);
}
if (!empty($parsed['host'])) {
- $host = strtolower($parsed['host']);
+ $host = mb_strtolower($parsed['host']);
}
if (!empty($parsed['query'])) {
$uri .= '?'.$parsed['query'];
@@ -512,7 +512,7 @@ protected function extension($path)
return ''; // No path.
}
- return strtolower(ltrim((string) strrchr(basename($path), '.'), '.'));
+ return mb_strtolower(ltrim((string) strrchr(basename($path), '.'), '.'));
}
/**
@@ -526,14 +526,14 @@ protected function parseCdnHosts()
$this->cdn_hosts = []; // Initialize.
$lines = str_replace(["\r\n", "\r"], "\n", $lines);
- $lines = trim(strtolower($lines)); // Force all mappings to lowercase.
+ $lines = trim(mb_strtolower($lines)); // Force all mappings to lowercase.
$lines = preg_split('/['."\r\n".']+/', $lines, null, PREG_SPLIT_NO_EMPTY);
foreach ($lines as $_line) {
if (!($_line = trim($_line))) {
continue; // Invalid line.
}
- if (strpos($_line, '=') !== false) {
+ if (mb_strpos($_line, '=') !== false) {
$_parts = explode('=', $_line, 2);
} else {
$_parts = [$this->local_host, $_line];
@@ -556,7 +556,7 @@ protected function parseCdnHosts()
if (empty($this->cdn_hosts[$this->local_host])) {
if ($this->cdn_host && (!is_multisite() || is_main_site())) {
- $this->cdn_hosts[strtolower((string) $this->plugin->parseUrl(network_home_url(), PHP_URL_HOST))][] = $this->cdn_host;
+ $this->cdn_hosts[mb_strtolower((string) $this->plugin->parseUrl(network_home_url(), PHP_URL_HOST))][] = $this->cdn_host;
}
}
}
@@ -571,13 +571,13 @@ protected function parseCdnHosts()
public static function defaultWhitelistedExtensions()
{
$extensions = array_keys(wp_get_mime_types());
- $extensions = explode('|', strtolower(implode('|', $extensions)));
+ $extensions = explode('|', mb_strtolower(implode('|', $extensions)));
$extensions = array_merge($extensions, ['eot', 'ttf', 'otf', 'woff']);
if (($permalink_structure = get_option('permalink_structure'))) {
- if (strcasecmp(substr($permalink_structure, -5), '.html') === 0) {
+ if (strcasecmp(mb_substr($permalink_structure, -5), '.html') === 0) {
$extensions = array_diff($extensions, ['html']);
- } elseif (strcasecmp(substr($permalink_structure, -4), '.htm') === 0) {
+ } elseif (strcasecmp(mb_substr($permalink_structure, -4), '.htm') === 0) {
$extensions = array_diff($extensions, ['htm']);
}
}
diff --git a/src/includes/classes/Conflicts.php b/src/includes/classes/Conflicts.php
index 742760c1..255f9b4a 100644
--- a/src/includes/classes/Conflicts.php
+++ b/src/includes/classes/Conflicts.php
@@ -77,9 +77,9 @@ protected function maybeEnqueueNotice()
return; // Already did this in one plugin or the other.
}
$construct_name = function ($slug_or_ns) {
- $name = trim(strtolower((string) $slug_or_ns));
- $name = preg_replace('/[_\-]+(?:lite|pro)$/', '', $name);
- $name = preg_replace('/[^a-z0-9]/', ' ', $name);
+ $name = trim(mb_strtolower((string) $slug_or_ns));
+ $name = preg_replace('/[_\-]+(?:lite|pro)$/u', '', $name);
+ $name = preg_replace('/[^a-z0-9]/u', ' ', $name);
$name = str_replace('cache', 'Cache', ucwords($name));
return $name; // e.g., `x-cache` becomes `X Cache`.
diff --git a/src/includes/classes/FeedUtils.php b/src/includes/classes/FeedUtils.php
index 120c12f3..533440db 100644
--- a/src/includes/classes/FeedUtils.php
+++ b/src/includes/classes/FeedUtils.php
@@ -174,14 +174,14 @@ public function postTermFeedLinkVariations(\WP_Post $post, $include_regex_wildca
$_term_feed_link = get_term_feed_link($_post_term->term_id, $_post_term->taxonomy, $_feed_type);
$variations[] = $_term_feed_link; // Add this variation; always.
- if ($include_regex_wildcard_keys && $_term_feed_link && strpos($_term_feed_link, '?') === false) {
+ if ($include_regex_wildcard_keys && $_term_feed_link && mb_strpos($_term_feed_link, '?') === false) {
// Quick example: `(?:123|slug)`; to consider both of these variations.
$_term_id_or_slug = '(?:'.preg_quote($_post_term->term_id, '/').
- '|'.preg_quote(preg_replace('/[^a-z0-9\/.]/i', '-', $_post_term->slug), '/').')';
+ '|'.preg_quote(preg_replace('/[^a-z0-9\/.]/ui', '-', $_post_term->slug), '/').')';
// Quick example: `http://www.example.com/tax/term/feed`;
// with a wildcard this becomes: `http://www.example.com/tax/*/feed`.
- $_term_feed_link_with_wildcard = preg_replace('/\/[^\/]+\/feed([\/?#]|$)/', '/*/feed'.'${1}', $_term_feed_link);
+ $_term_feed_link_with_wildcard = preg_replace('/\/[^\/]+\/feed([\/?#]|$)/u', '/*/feed'.'${1}', $_term_feed_link);
// Quick example: `http://www.example.com/tax/*/feed`;
// becomes: `\/http\/www\.example\.com\/tax\/.*?(?=[\/\-]?(?:123|slug)[\/\-]).*?\/feed`
@@ -250,14 +250,14 @@ public function convertVariationsToHostCachePathRegexFrags(array $variations)
$_host_url = rtrim('http://'.$_url_parts['host'].$_host_base_dir_tokens, '/');
$_host_cache_path = $this->plugin->buildCachePath($_host_url, '', '', $flags);
- if (is_string($_key) && strpos($_key, '::') !== false && strpos($_url, '*') !== false) {
+ if (is_string($_key) && mb_strpos($_key, '::') !== false && mb_strpos($_url, '*') !== false) {
list($_feed_type, $_wildcard_regex) = explode('::', $_key, 2); // This regex replaces wildcards.
$_cache_path = $this->plugin->buildCachePath($_url, '', '', $flags | $this::CACHE_PATH_ALLOW_WILDCARDS);
- $_relative_cache_path = preg_replace('/^'.preg_quote($_host_cache_path, '/').'(?:\/|$)/i', '', $_cache_path);
- $_relative_cache_path_regex = preg_replace('/\\\\\*/', $_wildcard_regex, preg_quote($_relative_cache_path, '/'));
+ $_relative_cache_path = preg_replace('/^'.preg_quote($_host_cache_path, '/').'(?:\/|$)/ui', '', $_cache_path);
+ $_relative_cache_path_regex = preg_replace('/\\\\\*/u', $_wildcard_regex, preg_quote($_relative_cache_path, '/'));
} else {
$_cache_path = $this->plugin->buildCachePath($_url, '', '', $flags); // Default flags.
- $_relative_cache_path = preg_replace('/^'.preg_quote($_host_cache_path, '/').'(?:\/|$)/i', '', $_cache_path);
+ $_relative_cache_path = preg_replace('/^'.preg_quote($_host_cache_path, '/').'(?:\/|$)/ui', '', $_cache_path);
$_relative_cache_path_regex = preg_quote($_relative_cache_path, '/');
}
if ($_relative_cache_path_regex) {
diff --git a/src/includes/classes/MenuPageOptions.php b/src/includes/classes/MenuPageOptions.php
index 0a27d125..c61ed87c 100644
--- a/src/includes/classes/MenuPageOptions.php
+++ b/src/includes/classes/MenuPageOptions.php
@@ -164,7 +164,7 @@ public function __construct()
if (!empty($_REQUEST[GLOBAL_NS.'_advanced_cache_add_failure'])) {
echo '
'."\n";
@@ -574,7 +574,7 @@ public function __construct()
echo ' '."\n";
echo ' '.__('Tip: Setting this to No
is highly recommended when running a membership plugin like s2Member (as one example). In fact, many plugins like s2Member will send nocache_headers() on their own, so your configuration here will likely be overwritten when you run such plugins (which is better anyway). In short, if you run a membership plugin, you should NOT allow a client-side browser cache.', SLUG_TD).'
'."\n";
echo ' '.__('Tip: Setting this to No
will NOT impact static content; e.g., CSS, JS, images, or other media. This setting pertains only to dynamic PHP scripts which produce content generated by WordPress.', SLUG_TD).'
'."\n";
- echo ' '.sprintf(__('Advanced Tip: if you have this set to No
, but you DO want to allow a few special URLs to be cached by the browser; you can add this parameter to your URL ?%2$sABC=1
. This tells %1$s that it\'s OK for the browser to cache that particular URL. In other words, the %2$sABC=1
parameter tells %1$s NOT to send no-cache headers to the browser.', SLUG_TD), esc_html(NAME), esc_html(strtolower(SHORT_NAME))).'
'."\n";
+ echo ' '.sprintf(__('Advanced Tip: if you have this set to No
, but you DO want to allow a few special URLs to be cached by the browser; you can add this parameter to your URL ?%2$sABC=1
. This tells %1$s that it\'s OK for the browser to cache that particular URL. In other words, the %2$sABC=1
parameter tells %1$s NOT to send no-cache headers to the browser.', SLUG_TD), esc_html(NAME), esc_html(mb_strtolower(SHORT_NAME))).'
'."\n";
echo '
'."\n";
echo ' '."\n";
echo ''."\n";
diff --git a/src/includes/classes/VsUpgrades.php b/src/includes/classes/VsUpgrades.php
index bbdaab03..86b56f74 100644
--- a/src/includes/classes/VsUpgrades.php
+++ b/src/includes/classes/VsUpgrades.php
@@ -91,22 +91,22 @@ protected function fromLte151107()
{
if (version_compare($this->prev_version, '151107', '<=')) {
if (is_array($existing_options = get_site_option(GLOBAL_NS.'_options'))) {
- if (!empty($existing_options['cache_clear_xml_sitemap_patterns']) && strpos($existing_options['cache_clear_xml_sitemap_patterns'], '**') === false) {
+ if (!empty($existing_options['cache_clear_xml_sitemap_patterns']) && mb_strpos($existing_options['cache_clear_xml_sitemap_patterns'], '**') === false) {
$this->plugin->options['cache_clear_xml_sitemap_patterns'] = str_replace('*', '**', $existing_options['cache_clear_xml_sitemap_patterns']);
}
- if (!empty($existing_options['exclude_uris']) && strpos($existing_options['exclude_uris'], '**') === false) {
+ if (!empty($existing_options['exclude_uris']) && mb_strpos($existing_options['exclude_uris'], '**') === false) {
$this->plugin->options['exclude_uris'] = str_replace('*', '**', $existing_options['exclude_uris']);
}
- if (!empty($existing_options['exclude_refs']) && strpos($existing_options['exclude_refs'], '**') === false) {
+ if (!empty($existing_options['exclude_refs']) && mb_strpos($existing_options['exclude_refs'], '**') === false) {
$this->plugin->options['exclude_refs'] = str_replace('*', '**', $existing_options['exclude_refs']);
}
- if (!empty($existing_options['exclude_agents']) && strpos($existing_options['exclude_agents'], '**') === false) {
+ if (!empty($existing_options['exclude_agents']) && mb_strpos($existing_options['exclude_agents'], '**') === false) {
$this->plugin->options['exclude_agents'] = str_replace('*', '**', $existing_options['exclude_agents']);
}
- if (!empty($existing_options['htmlc_css_exclusions']) && strpos($existing_options['htmlc_css_exclusions'], '**') === false) {
+ if (!empty($existing_options['htmlc_css_exclusions']) && mb_strpos($existing_options['htmlc_css_exclusions'], '**') === false) {
$this->plugin->options['htmlc_css_exclusions'] = str_replace('*', '**', $existing_options['htmlc_css_exclusions']);
}
- if (!empty($existing_options['htmlc_js_exclusions']) && strpos($existing_options['htmlc_js_exclusions'], '**') === false) {
+ if (!empty($existing_options['htmlc_js_exclusions']) && mb_strpos($existing_options['htmlc_js_exclusions'], '**') === false) {
$this->plugin->options['htmlc_js_exclusions'] = str_replace('*', '**', $existing_options['htmlc_js_exclusions']);
}
if ($existing_options['cdn_blacklisted_extensions'] === 'eot,ttf,otf,woff') {
@@ -186,7 +186,7 @@ protected function fromZenCache()
global $is_apache; // Remove htaccess rules added by ZenCache so that they can be re-added by Comet Cache
if ($is_apache && $this->plugin->findHtaccessMarker('WmVuQ2FjaGU') && ($htaccess = $this->plugin->readHtaccessFile())) {
- $regex = '/#\s*BEGIN\s+ZenCache\s+WmVuQ2FjaGU.*?#\s*END\s+ZenCache\s+WmVuQ2FjaGU\s*/is';
+ $regex = '/#\s*BEGIN\s+ZenCache\s+WmVuQ2FjaGU.*?#\s*END\s+ZenCache\s+WmVuQ2FjaGU\s*/uis';
$htaccess['file_contents'] = preg_replace($regex, '', $htaccess['file_contents']);
$this->plugin->writeHtaccessFile($htaccess, false);
diff --git a/src/includes/stub.php b/src/includes/stub.php
index 56fe3e58..3b0293c0 100644
--- a/src/includes/stub.php
+++ b/src/includes/stub.php
@@ -17,7 +17,7 @@
${__FILE__}['plugin'] = dirname(dirname(__DIR__));
${__FILE__}['plugin'] .= '/'.basename(${__FILE__}['plugin']).'.php';
${__FILE__}['ns_path'] = str_replace('\\', '/', __NAMESPACE__); // To dir/path.
-${__FILE__}['is_pro'] = strtolower(basename(${__FILE__}['ns_path'])) === 'pro';
+${__FILE__}['is_pro'] = mb_strtolower(basename(${__FILE__}['ns_path'])) === 'pro';
define(__NAMESPACE__.'\\SHORT_NAME', 'CC');
define(__NAMESPACE__.'\\NAME', 'Comet Cache');
diff --git a/src/includes/templates/ac-plugin.txt b/src/includes/templates/ac-plugin.txt
index fab100b5..9eaa1b4b 100644
--- a/src/includes/templates/ac-plugin.txt
+++ b/src/includes/templates/ac-plugin.txt
@@ -15,9 +15,9 @@ function my_ac_plugin() // Example plugin.
}
function my_ac_version_salt_shaker($version_salt)
{
- if (stripos($_SERVER['HTTP_USER_AGENT'], 'iphone') !== false) {
+ if (mb_stripos($_SERVER['HTTP_USER_AGENT'], 'iphone') !== false) {
$version_salt .= 'iphones'; // Give iPhones their own variation of the cache.
- } elseif (stripos($_SERVER['HTTP_USER_AGENT'], 'android') !== false) {
+ } elseif (mb_stripos($_SERVER['HTTP_USER_AGENT'], 'android') !== false) {
$version_salt .= 'androids'; // Androic variation.
} else {
$version_salt .= 'other'; // A default group.
diff --git a/src/includes/traits/Ac/BrowserUtils.php b/src/includes/traits/Ac/BrowserUtils.php
index aa64c2e9..d5757457 100644
--- a/src/includes/traits/Ac/BrowserUtils.php
+++ b/src/includes/traits/Ac/BrowserUtils.php
@@ -16,8 +16,8 @@ public function maybeStopBrowserCaching()
case true: // If global config allows, check exclusions.
- if (isset($_GET[strtolower(SHORT_NAME).'ABC'])) {
- if (!filter_var($_GET[strtolower(SHORT_NAME).'ABC'], FILTER_VALIDATE_BOOLEAN)) {
+ if (isset($_GET[mb_strtolower(SHORT_NAME).'ABC'])) {
+ if (!filter_var($_GET[mb_strtolower(SHORT_NAME).'ABC'], FILTER_VALIDATE_BOOLEAN)) {
return $this->sendNoCacheHeaders(); // Disallow.
} // Else, allow client-side caching; because `ABC` is a true-ish value.
// ↑ Note that exclusion patterns are ignored in this case, in favor of `ABC`.
@@ -28,8 +28,8 @@ public function maybeStopBrowserCaching()
case false: // Global config disallows; check inclusions.
- if (isset($_GET[strtolower(SHORT_NAME).'ABC'])) {
- if (filter_var($_GET[strtolower(SHORT_NAME).'ABC'], FILTER_VALIDATE_BOOLEAN)) {
+ if (isset($_GET[mb_strtolower(SHORT_NAME).'ABC'])) {
+ if (filter_var($_GET[mb_strtolower(SHORT_NAME).'ABC'], FILTER_VALIDATE_BOOLEAN)) {
return; // Allow, because `ABC` is a false-ish value.
} // Else, disallow client-side caching; because `ABC` is a true-ish value.
// ↑ Note that inclusion patterns are ignored in this case, in favor of `ABC`.
diff --git a/src/includes/traits/Ac/NcDebugUtils.php b/src/includes/traits/Ac/NcDebugUtils.php
index 592d9a4d..32902747 100644
--- a/src/includes/traits/Ac/NcDebugUtils.php
+++ b/src/includes/traits/Ac/NcDebugUtils.php
@@ -111,7 +111,7 @@ public function maybeGetNcDebugInfo($reason_code = '', $reason = '')
break; // Break switch handler.
case $this::NC_DEBUG_AC_GET_VAR:
- $reason = sprintf(__('because `$_GET[\'%1$sAC\']` is set to a boolean-ish FALSE value.', SLUG_TD), strtolower(SHORT_NAME));
+ $reason = sprintf(__('because `$_GET[\'%1$sAC\']` is set to a boolean-ish FALSE value.', SLUG_TD), mb_strtolower(SHORT_NAME));
break; // Break switch handler.
case $this::NC_DEBUG_UNCACHEABLE_REQUEST:
diff --git a/src/includes/traits/Ac/ObUtils.php b/src/includes/traits/Ac/ObUtils.php
index 042bf077..ac018dac 100644
--- a/src/includes/traits/Ac/ObUtils.php
+++ b/src/includes/traits/Ac/ObUtils.php
@@ -126,7 +126,7 @@ public function maybeStartOutputBuffering()
if (isset($_SERVER['DONOTCACHEPAGE'])) {
return $this->maybeSetDebugInfo($this::NC_DEBUG_DONOTCACHEPAGE_SERVER_VAR);
}
- if (isset($_GET[strtolower(SHORT_NAME).'AC']) && !filter_var($_GET[strtolower(SHORT_NAME).'AC'], FILTER_VALIDATE_BOOLEAN)) {
+ if (isset($_GET[mb_strtolower(SHORT_NAME).'AC']) && !filter_var($_GET[mb_strtolower(SHORT_NAME).'AC'], FILTER_VALIDATE_BOOLEAN)) {
return $this->maybeSetDebugInfo($this::NC_DEBUG_AC_GET_VAR);
}
if ($this->isUncacheableRequestMethod()) {
@@ -140,13 +140,13 @@ public function maybeStartOutputBuffering()
if (!COMET_CACHE_FEEDS_ENABLE && $this->isFeed()) {
return $this->maybeSetDebugInfo($this::NC_DEBUG_FEED_REQUEST);
}
- if (preg_match('/\/(?:wp\-[^\/]+|xmlrpc)\.php(?:[?]|$)/i', $_SERVER['REQUEST_URI'])) {
+ if (preg_match('/\/(?:wp\-[^\/]+|xmlrpc)\.php(?:[?]|$)/ui', $_SERVER['REQUEST_URI'])) {
return $this->maybeSetDebugInfo($this::NC_DEBUG_WP_SYSTEMATICS);
}
- if (is_admin() || preg_match('/\/wp-admin(?:[\/?]|$)/i', $_SERVER['REQUEST_URI'])) {
+ if (is_admin() || preg_match('/\/wp-admin(?:[\/?]|$)/ui', $_SERVER['REQUEST_URI'])) {
return $this->maybeSetDebugInfo($this::NC_DEBUG_WP_ADMIN);
}
- if (is_multisite() && preg_match('/\/files(?:[\/?]|$)/i', $_SERVER['REQUEST_URI'])) {
+ if (is_multisite() && preg_match('/\/files(?:[\/?]|$)/ui', $_SERVER['REQUEST_URI'])) {
return $this->maybeSetDebugInfo($this::NC_DEBUG_MS_FILES);
}
if ((!IS_PRO || !COMET_CACHE_WHEN_LOGGED_IN) && $this->isLikeUserLoggedIn()) {
@@ -208,7 +208,7 @@ public function maybeStartOutputBuffering()
$headers_list = $this->headersList();
foreach (unserialize($headers) as $_header) {
- if (!in_array($_header, $headers_list, true) && stripos($_header, 'Last-Modified:') !== 0) {
+ if (!in_array($_header, $headers_list, true) && mb_stripos($_header, 'Last-Modified:') !== 0) {
header($_header); // Only cacheable/safe headers are stored in the cache.
}
}
@@ -277,7 +277,7 @@ public function outputBufferCallbackHandler($buffer, $phase)
if ((!IS_PRO || !COMET_CACHE_WHEN_LOGGED_IN) && $this->isLikeUserLoggedIn()) {
return (boolean) $this->maybeSetDebugInfo($this::NC_DEBUG_IS_LIKE_LOGGED_IN_USER);
}
- if (!COMET_CACHE_CACHE_NONCE_VALUES && preg_match('/\b(?:_wpnonce|akismet_comment_nonce)\b/', $cache)) {
+ if (!COMET_CACHE_CACHE_NONCE_VALUES && preg_match('/\b(?:_wpnonce|akismet_comment_nonce)\b/u', $cache)) {
if (IS_PRO && COMET_CACHE_WHEN_LOGGED_IN && $this->isLikeUserLoggedIn()) {
if (!COMET_CACHE_CACHE_NONCE_VALUES_WHEN_LOGGED_IN) {
return (boolean) $this->maybeSetDebugInfo($this::NC_DEBUG_IS_LOGGED_IN_USER_NONCE);
@@ -289,7 +289,7 @@ public function outputBufferCallbackHandler($buffer, $phase)
if ($this->is_404 && !COMET_CACHE_CACHE_404_REQUESTS) {
return (boolean) $this->maybeSetDebugInfo($this::NC_DEBUG_404_REQUEST);
}
- if (stripos($cache, '') !== false) {
+ if (mb_stripos($cache, '') !== false) {
return (boolean) $this->maybeSetDebugInfo($this::NC_DEBUG_WP_ERROR_PAGE);
}
if (!$this->hasACacheableContentType()) {
diff --git a/src/includes/traits/Ac/PostloadUtils.php b/src/includes/traits/Ac/PostloadUtils.php
index c2b81908..6542d839 100644
--- a/src/includes/traits/Ac/PostloadUtils.php
+++ b/src/includes/traits/Ac/PostloadUtils.php
@@ -191,7 +191,7 @@ public function maybeStartObWhenLoggedInPostload()
$headers_list = $this->headersList();
foreach (unserialize($headers) as $_header) {
- if (!in_array($_header, $headers_list, true) && stripos($_header, 'Last-Modified:') !== 0) {
+ if (!in_array($_header, $headers_list, true) && mb_stripos($_header, 'Last-Modified:') !== 0) {
header($_header); // Only cacheable/safe headers are stored in the cache.
}
}
diff --git a/src/includes/traits/Plugin/AdminBarUtils.php b/src/includes/traits/Plugin/AdminBarUtils.php
index f228ce95..e1687780 100644
--- a/src/includes/traits/Plugin/AdminBarUtils.php
+++ b/src/includes/traits/Plugin/AdminBarUtils.php
@@ -18,7 +18,7 @@ trait AdminBarUtils
*/
public function adminBarShowing($feature = '')
{
- $feature = trim(strtolower((string) $feature));
+ $feature = trim(mb_strtolower((string) $feature));
if (!is_null($showing = &$this->cacheKey('adminBarShowing', $feature))) {
return $showing; // Already cached this.
}
diff --git a/src/includes/traits/Plugin/AutoCacheUtils.php b/src/includes/traits/Plugin/AutoCacheUtils.php
index 3bb30256..0e089d1e 100644
--- a/src/includes/traits/Plugin/AutoCacheUtils.php
+++ b/src/includes/traits/Plugin/AutoCacheUtils.php
@@ -142,12 +142,12 @@ public function autoCacheCheckXmlSitemap($sitemap, $is_nested_sitemap = false, $
if (is_wp_error($head = wp_remote_head($sitemap, ['redirection' => 5]))) {
$failure = 'WP_Http says: '.$head->get_error_message().'.';
- if (stripos($head->get_error_message(), 'timed out') !== false || stripos($head->get_error_message(), 'timeout') !== false) { // $head->get_error_code() only returns generic `http_request_failed`
+ if (mb_stripos($head->get_error_message(), 'timed out') !== false || mb_stripos($head->get_error_message(), 'timeout') !== false) { // $head->get_error_code() only returns generic `http_request_failed`
$failure .= '
'.__('Note: Most timeout errors are resolved by refreshing the page and trying again. If timeout errors persist, please see this article.', SLUG_TD).'';
}
} elseif (empty($head['response']['code']) || (int) $head['response']['code'] >= 400) {
$failure = sprintf(__('HEAD response code (%1$s
) indicates an error.', SLUG_TD), esc_html((int) @$head['response']['code']));
- } elseif (empty($head['headers']['content-type']) || stripos($head['headers']['content-type'], 'xml') === false) {
+ } elseif (empty($head['headers']['content-type']) || mb_stripos($head['headers']['content-type'], 'xml') === false) {
$failure = sprintf(__('Content-Type (%1$s
) indicates an error.', SLUG_TD), esc_html((string) @$head['headers']['content-type']));
}
if ($failure) { // Failure encountered above?
diff --git a/src/includes/traits/Plugin/DirUtils.php b/src/includes/traits/Plugin/DirUtils.php
index 3c2b223c..353929ea 100644
--- a/src/includes/traits/Plugin/DirUtils.php
+++ b/src/includes/traits/Plugin/DirUtils.php
@@ -75,9 +75,9 @@ public function wpHomePath()
$home = set_url_scheme(get_option('home'), 'http');
$siteurl = set_url_scheme(get_option('siteurl'), 'http');
if (!empty($home) && 0 !== strcasecmp($home, $siteurl) && !empty($_SERVER['SCRIPT_FILENAME'])) {
- $wp_path_rel_to_home = str_ireplace($home, '', $siteurl); /* $siteurl - $home */
+ $wp_path_rel_to_home = preg_replace('/'.preg_quote($home, '/').'/ui', '', $siteurl); /* $siteurl - $home */
$pos = strripos(str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']), trailingslashit($wp_path_rel_to_home));
- $home_path = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos);
+ $home_path = mb_substr($_SERVER['SCRIPT_FILENAME'], 0, $pos);
$home_path = trailingslashit($home_path);
} else {
$home_path = ABSPATH;
diff --git a/src/includes/traits/Plugin/HtaccessUtils.php b/src/includes/traits/Plugin/HtaccessUtils.php
index cf35f0ab..cff69bec 100644
--- a/src/includes/traits/Plugin/HtaccessUtils.php
+++ b/src/includes/traits/Plugin/HtaccessUtils.php
@@ -115,7 +115,7 @@ public function removeWpHtaccess()
return false; // Failure; could not read file, create file, or invalid UTF8 encountered, file may be corrupt.
}
- $regex = '/#\s*BEGIN\s+'.preg_quote(NAME, '/').'\s+'.$this->htaccess_marker.'.*?#\s*END\s+'.preg_quote(NAME, '/').'\s+'.$this->htaccess_marker.'\s*/is';
+ $regex = '/#\s*BEGIN\s+'.preg_quote(NAME, '/').'\s+'.$this->htaccess_marker.'.*?#\s*END\s+'.preg_quote(NAME, '/').'\s+'.$this->htaccess_marker.'\s*/uis';
$htaccess['file_contents'] = preg_replace($regex, '', $htaccess['file_contents']);
if (!$this->writeHtaccessFile($htaccess, false)) {
@@ -187,7 +187,7 @@ public function findHtaccessMarker($htaccess_marker = '')
if (empty($htaccess_marker)) {
$htaccess_marker = $this->htaccess_marker;
}
- if (stripos($htaccess_file_contents, $htaccess_marker) === false) {
+ if (mb_stripos($htaccess_file_contents, $htaccess_marker) === false) {
return false; // Htaccess marker is missing
}
@@ -253,7 +253,7 @@ public function writeHtaccessFile(array $htaccess, $require_marker = true, $htac
}
$htaccess_marker = $htaccess_marker ?: $this->htaccess_marker;
- $_have_marker = stripos($htaccess['file_contents'], $htaccess_marker);
+ $_have_marker = mb_stripos($htaccess['file_contents'], $htaccess_marker);
// Note: rewind() necessary here because we fread() above.
if (($require_marker && $_have_marker === false) || !rewind($htaccess['fp']) || !ftruncate($htaccess['fp'], 0) || !fwrite($htaccess['fp'], $htaccess['file_contents'])) {
diff --git a/src/includes/traits/Plugin/InstallUtils.php b/src/includes/traits/Plugin/InstallUtils.php
index 46597a1f..d2b79213 100644
--- a/src/includes/traits/Plugin/InstallUtils.php
+++ b/src/includes/traits/Plugin/InstallUtils.php
@@ -150,16 +150,16 @@ public function addWpCacheToWpConfig()
if (!($wp_config_file_contents_no_whitespace = php_strip_whitespace($wp_config_file))) {
return ''; // Failure; file empty
}
- if (preg_match('/\bdefine\s*\(\s*([\'"])WP_CACHE\\1\s*,\s*(?:\-?[1-9][0-9\.]*|TRUE|([\'"])(?:[^0\'"]|[^\'"]{2,})\\2)\s*\)\s*;/i', $wp_config_file_contents_no_whitespace)) {
+ if (preg_match('/\bdefine\s*\(\s*([\'"])WP_CACHE\\1\s*,\s*(?:\-?[1-9][0-9\.]*|TRUE|([\'"])(?:[^0\'"]|[^\'"]{2,})\\2)\s*\)\s*;/ui', $wp_config_file_contents_no_whitespace)) {
return $wp_config_file_contents; // It's already in there; no need to modify this file.
}
if (!($wp_config_file_contents = $this->removeWpCacheFromWpConfig())) {
return ''; // Unable to remove previous value.
}
- if (!($wp_config_file_contents = preg_replace('/^\s*(\<\?php|\<\?)\s+/i', '${1}'."\n"."define('WP_CACHE', TRUE);"."\n", $wp_config_file_contents, 1))) {
+ if (!($wp_config_file_contents = preg_replace('/^\s*(\<\?php|\<\?)\s+/ui', '${1}'."\n"."define('WP_CACHE', TRUE);"."\n", $wp_config_file_contents, 1))) {
return ''; // Failure; something went terribly wrong here.
}
- if (strpos($wp_config_file_contents, "define('WP_CACHE', TRUE);") === false) {
+ if (mb_strpos($wp_config_file_contents, "define('WP_CACHE', TRUE);") === false) {
return ''; // Failure; unable to add; unexpected PHP code.
}
if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
@@ -196,16 +196,16 @@ public function removeWpCacheFromWpConfig()
if (!($wp_config_file_contents_no_whitespace = php_strip_whitespace($wp_config_file))) {
return ''; // Failure; file empty
}
- if (!preg_match('/([\'"])WP_CACHE\\1/i', $wp_config_file_contents_no_whitespace)) {
+ if (!preg_match('/([\'"])WP_CACHE\\1/ui', $wp_config_file_contents_no_whitespace)) {
return $wp_config_file_contents; // Already gone.
}
- if (preg_match('/\bdefine\s*\(\s*([\'"])WP_CACHE\\1\s*,\s*(?:0|FALSE|NULL|([\'"])0?\\2)\s*\)\s*;/i', $wp_config_file_contents_no_whitespace) && !is_writable($wp_config_file)) {
+ if (preg_match('/\bdefine\s*\(\s*([\'"])WP_CACHE\\1\s*,\s*(?:0|FALSE|NULL|([\'"])0?\\2)\s*\)\s*;/ui', $wp_config_file_contents_no_whitespace) && !is_writable($wp_config_file)) {
return $wp_config_file_contents; // It's already disabled, and since we can't write to this file let's let this slide.
}
- if (!($wp_config_file_contents = preg_replace('/\bdefine\s*\(\s*([\'"])WP_CACHE\\1\s*,\s*(?:\-?[0-9\.]+|TRUE|FALSE|NULL|([\'"])[^\'"]*\\2)\s*\)\s*;/i', '', $wp_config_file_contents))) {
+ if (!($wp_config_file_contents = preg_replace('/\bdefine\s*\(\s*([\'"])WP_CACHE\\1\s*,\s*(?:\-?[0-9\.]+|TRUE|FALSE|NULL|([\'"])[^\'"]*\\2)\s*\)\s*;/ui', '', $wp_config_file_contents))) {
return ''; // Failure; something went terribly wrong here.
}
- if (preg_match('/([\'"])WP_CACHE\\1/i', $wp_config_file_contents)) {
+ if (preg_match('/([\'"])WP_CACHE\\1/ui', $wp_config_file_contents)) {
return ''; // Failure; perhaps the `/wp-config.php` file contains syntax we cannot remove safely.
}
if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
@@ -247,7 +247,7 @@ public function checkAdvancedCache()
}
$cache_dir = $this->cacheDir();
$advanced_cache_file = WP_CONTENT_DIR.'/advanced-cache.php';
- $advanced_cache_check_file = $cache_dir.'/'.strtolower(SHORT_NAME).'-advanced-cache';
+ $advanced_cache_check_file = $cache_dir.'/'.mb_strtolower(SHORT_NAME).'-advanced-cache';
// Fixes zero-byte advanced-cache.php bug related to migrating from ZenCache
// See:
@@ -277,7 +277,7 @@ public function addAdvancedCache()
}
$cache_dir = $this->cacheDir();
$advanced_cache_file = WP_CONTENT_DIR.'/advanced-cache.php';
- $advanced_cache_check_file = $cache_dir.'/'.strtolower(SHORT_NAME).'-advanced-cache';
+ $advanced_cache_check_file = $cache_dir.'/'.mb_strtolower(SHORT_NAME).'-advanced-cache';
$advanced_cache_template = dirname(dirname(__DIR__)).'/templates/advanced-cache.txt';
if (is_file($advanced_cache_file) && !is_writable($advanced_cache_file)) {
@@ -343,25 +343,24 @@ public function addAdvancedCache()
$_value = "'".$this->escSq($_value)."'";
break; // Break switch handler.
}
- $advanced_cache_contents = // Fill replacement codes.
- str_ireplace(
- [
- "'%%".GLOBAL_NS.'_'.$_option."%%'",
- "'%%".GLOBAL_NS.'_'.preg_replace('/^cache_/i', '', $_option)."%%'",
- ],
- $_value,
- $advanced_cache_contents
- );
+ $advanced_cache_contents = preg_replace(
+ [
+ '/'.preg_quote("'%%".GLOBAL_NS.'_'.$_option."%%'", '/').'/ui',
+ '/'.preg_quote("'%%".GLOBAL_NS.'_'.preg_replace('/^cache_/ui', '', $_option)."%%'", '/').'/ui',
+ ],
+ $_value,
+ $advanced_cache_contents
+ );
}
unset($_option, $_value, $_values, $_response); // Housekeeping.
- if (strpos(PLUGIN_FILE, WP_CONTENT_DIR) === 0) {
+ if (mb_strpos(PLUGIN_FILE, WP_CONTENT_DIR) === 0) {
$plugin_file = "WP_CONTENT_DIR.'".$this->escSq(str_replace(WP_CONTENT_DIR, '', PLUGIN_FILE))."'";
} else {
$plugin_file = "'".$this->escSq(PLUGIN_FILE)."'"; // Full absolute path.
}
// Make it possible for the `advanced-cache.php` handler to find the plugin directory reliably.
- $advanced_cache_contents = str_ireplace("'%%".GLOBAL_NS."_PLUGIN_FILE%%'", $plugin_file, $advanced_cache_contents);
+ $advanced_cache_contents = preg_replace('/'.preg_quote("'%%".GLOBAL_NS."_PLUGIN_FILE%%'", '/').'/ui', $plugin_file, $advanced_cache_contents);
// Ignore; this is created by Comet Cache; and we don't need to obey in this case.
#if(defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS)
@@ -442,7 +441,7 @@ public function deleteAdvancedCache()
{
$cache_dir = $this->cacheDir();
$advanced_cache_file = WP_CONTENT_DIR.'/advanced-cache.php';
- $advanced_cache_check_file = $cache_dir.'/'.strtolower(SHORT_NAME).'-advanced-cache';
+ $advanced_cache_check_file = $cache_dir.'/'.mb_strtolower(SHORT_NAME).'-advanced-cache';
if (is_file($advanced_cache_file)) {
if (!is_writable($advanced_cache_file) || !unlink($advanced_cache_file)) {
@@ -488,7 +487,7 @@ public function checkBlogPaths()
return; // Skip on plugin actions.
}
$cache_dir = $this->cacheDir();
- $blog_paths_file = $cache_dir.'/'.strtolower(SHORT_NAME).'-blog-paths';
+ $blog_paths_file = $cache_dir.'/'.mb_strtolower(SHORT_NAME).'-blog-paths';
if (!is_file($blog_paths_file)) {
$this->updateBlogPaths();
@@ -519,7 +518,7 @@ public function updateBlogPaths($enable_live_network_counts = null)
return $value; // N/A.
}
$cache_dir = $this->cacheDir();
- $blog_paths_file = $cache_dir.'/'.strtolower(SHORT_NAME).'-blog-paths';
+ $blog_paths_file = $cache_dir.'/'.mb_strtolower(SHORT_NAME).'-blog-paths';
$cache_lock = $this->cacheLock();
@@ -538,7 +537,7 @@ public function updateBlogPaths($enable_live_network_counts = null)
foreach ($paths as $_key => &$_path) {
if ($_path && $_path !== '/' && $host_base_token && $host_base_token !== '/') {
// Note that each `path` in the DB looks like: `[/base]/path/` (i.e., it includes base).
- $_path = '/'.ltrim(preg_replace('/^'.preg_quote($host_base_token, '/').'/', '', $_path), '/');
+ $_path = '/'.ltrim(preg_replace('/^'.preg_quote($host_base_token, '/').'/u', '', $_path), '/');
}
if (!$_path || $_path === '/') {
unset($paths[$_key]); // Exclude main site.
diff --git a/src/includes/traits/Plugin/MenuPageUtils.php b/src/includes/traits/Plugin/MenuPageUtils.php
index 0cbf0cb1..92fd407c 100644
--- a/src/includes/traits/Plugin/MenuPageUtils.php
+++ b/src/includes/traits/Plugin/MenuPageUtils.php
@@ -14,7 +14,7 @@ trait MenuPageUtils
*/
public function enqueueAdminStyles()
{
- if (empty($_GET['page']) || strpos($_GET['page'], GLOBAL_NS) !== 0) {
+ if (empty($_GET['page']) || mb_strpos($_GET['page'], GLOBAL_NS) !== 0) {
return; // NOT a plugin page in the administrative area.
}
$deps = []; // Plugin dependencies.
@@ -31,7 +31,7 @@ public function enqueueAdminStyles()
*/
public function enqueueAdminScripts()
{
- if (empty($_GET['page']) || strpos($_GET['page'], GLOBAL_NS) !== 0) {
+ if (empty($_GET['page']) || mb_strpos($_GET['page'], GLOBAL_NS) !== 0) {
return; // NOT a plugin page in the administrative area.
}
$deps = ['jquery', 'chartjs']; // Plugin dependencies.
@@ -170,7 +170,7 @@ public function colorSvgMenuIcon($svg)
$current_pagenow = !empty($GLOBALS['pagenow']) ? $GLOBALS['pagenow'] : '';
$current_page = !empty($_REQUEST['page']) ? $_REQUEST['page'] : '';
- if (strpos($current_pagenow, GLOBAL_NS) === 0 || strpos($current_page, GLOBAL_NS) === 0) {
+ if (mb_strpos($current_pagenow, GLOBAL_NS) === 0 || mb_strpos($current_page, GLOBAL_NS) === 0) {
$use_icon_fill_color = $icon_colors['current'];
}
return str_replace(' fill="currentColor"', ' fill="'.esc_attr($use_icon_fill_color).'"', $svg);
diff --git a/src/includes/traits/Plugin/OptionUtils.php b/src/includes/traits/Plugin/OptionUtils.php
index 881b03a1..5cc24682 100644
--- a/src/includes/traits/Plugin/OptionUtils.php
+++ b/src/includes/traits/Plugin/OptionUtils.php
@@ -35,7 +35,7 @@ public function getOptions()
unset($_key, $_value); // Housekeeping.
$this->options['base_dir'] = trim($this->options['base_dir'], '\\/'." \t\n\r\0\x0B");
- if (!$this->options['base_dir'] || strpos(basename($this->options['base_dir']), 'wp-') === 0) {
+ if (!$this->options['base_dir'] || mb_strpos(basename($this->options['base_dir']), 'wp-') === 0) {
$this->options['base_dir'] = $this->default_options['base_dir'];
}
return $this->options; // Plugin options.
diff --git a/src/includes/traits/Plugin/WcpPostUtils.php b/src/includes/traits/Plugin/WcpPostUtils.php
index 8d0c54d5..8e783162 100644
--- a/src/includes/traits/Plugin/WcpPostUtils.php
+++ b/src/includes/traits/Plugin/WcpPostUtils.php
@@ -71,7 +71,7 @@ public function autoClearPostCache($post_id, $force = false)
}
if ($post_status === 'draft' && isset($GLOBALS['pagenow'], $_POST['publish'])
&& is_admin() && $GLOBALS['pagenow'] === 'post.php' && current_user_can('publish_posts')
- && strpos(wp_get_referer(), '/post-new.php') !== false
+ && mb_strpos(wp_get_referer(), '/post-new.php') !== false
) {
$post_status = 'publish'; // A new post being published now.
}
diff --git a/src/includes/traits/Plugin/WcpTermUtils.php b/src/includes/traits/Plugin/WcpTermUtils.php
index 3d061252..e76418a9 100644
--- a/src/includes/traits/Plugin/WcpTermUtils.php
+++ b/src/includes/traits/Plugin/WcpTermUtils.php
@@ -54,7 +54,7 @@ public function autoClearPostTermsCache($post_id, $force = false)
if ($post_status === 'draft' && isset($GLOBALS['pagenow'], $_POST['publish'])
&& is_admin() && $GLOBALS['pagenow'] === 'post.php' && current_user_can('publish_posts')
- && strpos(wp_get_referer(), '/post-new.php') !== false
+ && mb_strpos(wp_get_referer(), '/post-new.php') !== false
) {
$post_status = 'publish'; // A new post being published now.
}
diff --git a/src/includes/traits/Plugin/WcpUrlUtils.php b/src/includes/traits/Plugin/WcpUrlUtils.php
index 15a088f9..35203bfb 100644
--- a/src/includes/traits/Plugin/WcpUrlUtils.php
+++ b/src/includes/traits/Plugin/WcpUrlUtils.php
@@ -38,7 +38,7 @@ public function autoClearUrlsCache()
return $counter; // Nothing to do.
}
foreach (preg_split('/['."\r\n".']+/', $this->options['cache_clear_urls'], -1, PREG_SPLIT_NO_EMPTY) as $_url) {
- if (stripos($_url, 'http') === 0) {
+ if (mb_stripos($_url, 'http') === 0) {
$_regex = $this->buildCachePathRegexFromWcUrl($_url);
$counter += $this->deleteFilesFromCacheDir($_regex);
}
diff --git a/src/includes/traits/Shared/CacheDirUtils.php b/src/includes/traits/Shared/CacheDirUtils.php
index 8adf4c8b..eb95f6d1 100644
--- a/src/includes/traits/Shared/CacheDirUtils.php
+++ b/src/includes/traits/Shared/CacheDirUtils.php
@@ -142,15 +142,15 @@ public function deleteFilesFromCacheDir($regex, $check_max_age = false)
$cache_dir_tmp_regex = $regex; // Initialize host-specific regex pattern for the tmp directory.
$cache_dir_tmp_regex = '\\/'.ltrim($cache_dir_tmp_regex, '^\\/'); // Make sure it begins with an escaped `/`.
- $cache_dir_tmp_regex = $this->strIreplaceOnce(preg_quote($cache_dir.'/', '/'), '', $cache_dir_tmp_regex);
+ $cache_dir_tmp_regex = preg_replace('/'.preg_quote(preg_quote($cache_dir.'/', '/'), '/').'/ui', '', $cache_dir_tmp_regex, 1);
$cache_dir_tmp_regex = ltrim($cache_dir_tmp_regex, '^\\/');
- if (strpos($cache_dir_tmp_regex, '(?:\/') === 0 || strpos($cache_dir_tmp_regex, '(\/') === 0) {
+ if (mb_strpos($cache_dir_tmp_regex, '(?:\/') === 0 || mb_strpos($cache_dir_tmp_regex, '(\/') === 0) {
$cache_dir_tmp_regex = '/^'.preg_quote($cache_dir_tmp, '/').$cache_dir_tmp_regex;
} else {
$cache_dir_tmp_regex = '/^'.preg_quote($cache_dir_tmp.'/', '/').$cache_dir_tmp_regex;
}
- # if(WP_DEBUG) file_put_contents(WP_CONTENT_DIR.'/'.strtolower(SHORT_NAME).'-debug.log', print_r($regex, TRUE)."\n".print_r($cache_dir_tmp_regex, TRUE)."\n\n", FILE_APPEND);
+ # if(WP_DEBUG) file_put_contents(WP_CONTENT_DIR.'/'.mb_strtolower(SHORT_NAME).'-debug.log', print_r($regex, TRUE)."\n".print_r($cache_dir_tmp_regex, TRUE)."\n\n", FILE_APPEND);
// Uncomment the above line to debug regex pattern matching used by this routine; and others that call upon it.
if (!rename($cache_dir, $cache_dir_tmp)) {
@@ -161,7 +161,7 @@ public function deleteFilesFromCacheDir($regex, $check_max_age = false)
$_sub_path_name = $_resource->getSubpathname();
$_path_name = $_resource->getPathname();
- if ($_resource_type !== 'dir' && strpos($_sub_path_name, '/') === false) {
+ if ($_resource_type !== 'dir' && mb_strpos($_sub_path_name, '/') === false) {
continue; // Don't delete links/files in the immediate directory; e.g. `[SHORT_NAME]-advanced-cache` or `.htaccess`, etc.
// Actual `http|https/...` cache links/files are nested. Links/files in the immediate directory are for other purposes.
}
@@ -307,16 +307,16 @@ public function deleteFilesFromHostCacheDir(
$_host_cache_dir_tmp_regex = $regex; // Initialize host-specific regex pattern for the tmp directory.
$_host_cache_dir_tmp_regex = '\\/'.ltrim($_host_cache_dir_tmp_regex, '^\\/'); // Make sure it begins with an escaped `/`.
- $_host_cache_dir_tmp_regex = $this->strIreplaceOnce(preg_quote($_host_cache_path.'/', '/'), '', $_host_cache_dir_tmp_regex);
- $_host_cache_dir_tmp_regex = $this->strIreplaceOnce(preg_quote($_host_cache_dir.'/', '/'), '', $_host_cache_dir_tmp_regex);
+ $_host_cache_dir_tmp_regex = preg_replace('/'.preg_quote(preg_quote($_host_cache_path.'/', '/'), '/').'/ui', '', $_host_cache_dir_tmp_regex, 1);
+ $_host_cache_dir_tmp_regex = preg_replace('/'.preg_quote(preg_quote($_host_cache_dir.'/', '/'), '/').'/ui', '', $_host_cache_dir_tmp_regex, 1);
$_host_cache_dir_tmp_regex = ltrim($_host_cache_dir_tmp_regex, '^\\/');
- if (strpos($_host_cache_dir_tmp_regex, '(?:\/') === 0 || strpos($_host_cache_dir_tmp_regex, '(\/') === 0) {
+ if (mb_strpos($_host_cache_dir_tmp_regex, '(?:\/') === 0 || mb_strpos($_host_cache_dir_tmp_regex, '(\/') === 0) {
$_host_cache_dir_tmp_regex = '/^'.preg_quote($_host_cache_dir_tmp, '/').$_host_cache_dir_tmp_regex;
} else {
$_host_cache_dir_tmp_regex = '/^'.preg_quote($_host_cache_dir_tmp.'/', '/').$_host_cache_dir_tmp_regex;
}
- #if(WP_DEBUG) file_put_contents(WP_CONTENT_DIR.'/'.strtolower(SHORT_NAME).'-debug.log', print_r($regex, TRUE)."\n".print_r($_host_cache_dir_tmp_regex, TRUE)."\n\n", FILE_APPEND);
+ #if(WP_DEBUG) file_put_contents(WP_CONTENT_DIR.'/'.mb_strtolower(SHORT_NAME).'-debug.log', print_r($regex, TRUE)."\n".print_r($_host_cache_dir_tmp_regex, TRUE)."\n\n", FILE_APPEND);
// Uncomment the above line to debug regex pattern matching used by this routine; and others that call upon it.
if (!rename($_host_cache_dir, $_host_cache_dir_tmp)) {
@@ -327,7 +327,7 @@ public function deleteFilesFromHostCacheDir(
$_sub_path_name = $_resource->getSubpathname();
$_path_name = $_resource->getPathname();
- if ($_host_cache_dir === $cache_dir && $_resource_type !== 'dir' && strpos($_sub_path_name, '/') === false) {
+ if ($_host_cache_dir === $cache_dir && $_resource_type !== 'dir' && mb_strpos($_sub_path_name, '/') === false) {
continue; // Don't delete links/files in the immediate directory; e.g. `[SHORT_NAME]-advanced-cache` or `.htaccess`, etc.
// Actual `http|https/...` cache links/files are nested. Links/files in the immediate directory are for other purposes.
}
@@ -458,10 +458,10 @@ public function deleteAllFilesDirsIn($dir, $delete_dir_too = false)
$wp_content_dir = $this->nDirSeps(WP_CONTENT_DIR);
$wp_content_dir_regex = preg_quote($wp_content_dir, '/');
- if (!preg_match('/^'.$wp_content_dir_regex.'\/[^\/]+/i', $dir)) {
+ if (!preg_match('/^'.$wp_content_dir_regex.'\/[^\/]+/ui', $dir)) {
return $counter; // Security flag; do nothing in this case.
}
- if (preg_match('/^'.$wp_content_dir_regex.'\/(?:mu\-plugins|themes|plugins)(?:\/|$)/i', $dir)) {
+ if (preg_match('/^'.$wp_content_dir_regex.'\/(?:mu\-plugins|themes|plugins)(?:\/|$)/ui', $dir)) {
return $counter; // Security flag; do nothing in this case.
}
/* ------- Begin lock state... ----------- */
@@ -564,10 +564,10 @@ public function eraseAllFilesDirsIn($dir, $erase_dir_too = false)
$wp_content_dir = $this->nDirSeps(WP_CONTENT_DIR);
$wp_content_dir_regex = preg_quote($wp_content_dir, '/');
- if (!preg_match('/^'.$wp_content_dir_regex.'\/[^\/]+/i', $dir)) {
+ if (!preg_match('/^'.$wp_content_dir_regex.'\/[^\/]+/ui', $dir)) {
return $counter; // Security flag; do nothing in this case.
}
- if (preg_match('/^'.$wp_content_dir_regex.'\/(?:mu\-plugins|themes|plugins)(?:\/|$)/i', $dir)) {
+ if (preg_match('/^'.$wp_content_dir_regex.'\/(?:mu\-plugins|themes|plugins)(?:\/|$)/ui', $dir)) {
return $counter; // Security flag; do nothing in this case.
}
clearstatcache(); // Clear stat cache to be sure we have a fresh start below.
diff --git a/src/includes/traits/Shared/CachePathUtils.php b/src/includes/traits/Shared/CachePathUtils.php
index 2cd61449..25b4d4e0 100644
--- a/src/includes/traits/Shared/CachePathUtils.php
+++ b/src/includes/traits/Shared/CachePathUtils.php
@@ -94,7 +94,7 @@ public function buildCachePath($url, $with_user_token = '', $with_version_salt =
$host_base_dir_tokens = $this->hostBaseDirTokens(false, $is_url_domain_mapped, !empty($url_parts['path']) ? $url_parts['path'] : '/');
$is_a_multisite_base_dir = $is_multisite && $host_base_dir_tokens && $host_base_dir_tokens !== '/' // Check?
- && stripos(!empty($url_parts['path']) ? rtrim($url_parts['path'], '/').'/' : '/', $host_base_dir_tokens) === 0;
+ && mb_stripos(!empty($url_parts['path']) ? rtrim($url_parts['path'], '/').'/' : '/', $host_base_dir_tokens) === 0;
$is_a_multisite_base_dir_root = $is_multisite && $is_a_multisite_base_dir // Save time by using the previous check here.
&& strcasecmp(trim($host_base_dir_tokens, '/'), trim(!empty($url_parts['path']) ? $url_parts['path'] : '/', '/')) === 0;
@@ -110,7 +110,7 @@ public function buildCachePath($url, $with_user_token = '', $with_version_salt =
// Put multisite sub-roots into a host directory of their own.
// e.g., `example-com[[-base]-child1]` instead of `example-com`.
if ($is_a_multisite_base_dir && $host_base_dir_tokens && $host_base_dir_tokens !== '/') {
- $host_base_dir_suffix = preg_replace('/[^a-z0-9.]/i', '-', rtrim($host_base_dir_tokens, '/'));
+ $host_base_dir_suffix = preg_replace('/[^a-z0-9.]/ui', '-', rtrim($host_base_dir_tokens, '/'));
$cache_path = rtrim($cache_path, '/').$host_base_dir_suffix.'/';
}
}
@@ -133,7 +133,7 @@ public function buildCachePath($url, $with_user_token = '', $with_version_salt =
$url_parts['path'] = '/lp-'.sha1($url_parts['path']).'/';
}
} // Now add the path and check for a possible root `index/` suffix.
- if (!empty($url_parts['path']) && strlen($url_parts['path'] = trim($url_parts['path'], '\\/'." \t\n\r\0\x0B"))) {
+ if (!empty($url_parts['path']) && mb_strlen($url_parts['path'] = trim($url_parts['path'], '\\/'." \t\n\r\0\x0B"))) {
$cache_path .= $url_parts['path'].'/'; // Add the path as it exists.
if (!($flags & $this::CACHE_PATH_NO_PATH_INDEX) && $is_multisite && $is_a_multisite_base_dir_root) {
@@ -148,7 +148,7 @@ public function buildCachePath($url, $with_user_token = '', $with_version_salt =
if ($this->isExtensionLoaded('mbstring') && mb_check_encoding($cache_path, 'UTF-8')) {
$cache_path = mb_strtolower($cache_path, 'UTF-8');
}
- $cache_path = str_replace('.', '-', strtolower($cache_path));
+ $cache_path = str_replace('.', '-', mb_strtolower($cache_path));
if (!($flags & $this::CACHE_PATH_NO_QUV)) {
if (!($flags & $this::CACHE_PATH_NO_QUERY)) {
@@ -167,14 +167,14 @@ public function buildCachePath($url, $with_user_token = '', $with_version_salt =
}
}
}
- $cache_path = trim(preg_replace(['/\/+/', '/\.+/'], ['/', '.'], $cache_path), '/');
+ $cache_path = trim(preg_replace(['/\/+/u', '/\.+/u'], ['/', '.'], $cache_path), '/');
if ($flags & $this::CACHE_PATH_ALLOW_WD_REGEX) {
- $cache_path = preg_replace('/[^a-z0-9\/.*\^$]/i', '-', $cache_path);
+ $cache_path = preg_replace('/[^a-z0-9\/.*\^$]/ui', '-', $cache_path);
} elseif ($flags & $this::CACHE_PATH_ALLOW_WILDCARDS) {
- $cache_path = preg_replace('/[^a-z0-9\/.*]/i', '-', $cache_path);
+ $cache_path = preg_replace('/[^a-z0-9\/.*]/ui', '-', $cache_path);
} else {
- $cache_path = preg_replace('/[^a-z0-9\/.]/i', '-', $cache_path);
+ $cache_path = preg_replace('/[^a-z0-9\/.]/ui', '-', $cache_path);
}
if (!($flags & $this::CACHE_PATH_NO_EXT)) {
$cache_path .= '.html';
@@ -249,7 +249,7 @@ public function buildHostCachePathRegex($url, $regex_suffix_frag = self::CACHE_P
$host_cache_path = $this->buildCachePath($host_url, '', '', $flags);
$cache_path = $this->buildCachePath($url, '', '', $flags);
- $relative_cache_path = preg_replace('/^'.preg_quote($host_cache_path, '/').'(?:\/|$)/i', '', $cache_path);
+ $relative_cache_path = preg_replace('/^'.preg_quote($host_cache_path, '/').'(?:\/|$)/ui', '', $cache_path);
$abs_relative_cache_path = isset($relative_cache_path[0]) ? '/'.$relative_cache_path : '';
$abs_relative_cache_path_regex = isset($abs_relative_cache_path[0]) ? preg_quote($abs_relative_cache_path, '/') : '';
@@ -321,7 +321,7 @@ public function buildHostCachePathRegexFragsFromWcUris($uris, $regex_suffix_frag
foreach ($uri_patterns as $_key => &$_uri_pattern) {
if (($_uri_pattern = trim($_uri_pattern, '^$'))) {
$_cache_path = $this->buildCachePath($host_url.'/'.trim($_uri_pattern, '/'), '', '', $flags);
- $_relative_cache_path = preg_replace('/^'.preg_quote($host_cache_path, '/').'(?:\/|$)/i', '', $_cache_path);
+ $_relative_cache_path = preg_replace('/^'.preg_quote($host_cache_path, '/').'(?:\/|$)/ui', '', $_cache_path);
$_uri_pattern = $this->wdRegexToActualRegexFrag($_relative_cache_path);
}
if (!$_uri_pattern) {
diff --git a/src/includes/traits/Shared/ConditionalUtils.php b/src/includes/traits/Shared/ConditionalUtils.php
index 3f20c393..c6c37052 100644
--- a/src/includes/traits/Shared/ConditionalUtils.php
+++ b/src/includes/traits/Shared/ConditionalUtils.php
@@ -73,7 +73,7 @@ public function isPostPutDeleteRequest()
return $is = true;
}
if (!empty($_SERVER['REQUEST_METHOD']) && is_string($_SERVER['REQUEST_METHOD'])) {
- if (in_array(strtoupper($_SERVER['REQUEST_METHOD']), ['POST', 'PUT', 'DELETE'], true)) {
+ if (in_array(mb_strtoupper($_SERVER['REQUEST_METHOD']), ['POST', 'PUT', 'DELETE'], true)) {
return $is = true;
}
}
@@ -96,9 +96,9 @@ public function requestContainsUncacheableQueryVars()
}
if (!empty($_GET) || !empty($_SERVER['QUERY_STRING'])) {
$_get_count = !empty($_GET) ? count($_GET) : 0;
- $is_abc_only = $_get_count === 1 && isset($_GET[strtolower(SHORT_NAME).'ABC']);
+ $is_abc_only = $_get_count === 1 && isset($_GET[mb_strtolower(SHORT_NAME).'ABC']);
$is_nginx_q_only = $_get_count === 1 && isset($_GET['q']) && $this->isNginx();
- $is_ac_get_var_true = isset($_GET[strtolower(SHORT_NAME).'AC']) && filter_var($_GET[strtolower(SHORT_NAME).'AC'], FILTER_VALIDATE_BOOLEAN);
+ $is_ac_get_var_true = isset($_GET[mb_strtolower(SHORT_NAME).'AC']) && filter_var($_GET[mb_strtolower(SHORT_NAME).'AC'], FILTER_VALIDATE_BOOLEAN);
if (!$is_abc_only && !$is_nginx_q_only && !$is_ac_get_var_true) {
return $is = true;
@@ -125,7 +125,7 @@ public function isUncacheableRequestMethod()
return $is = true;
}
if (!empty($_SERVER['REQUEST_METHOD']) && is_string($_SERVER['REQUEST_METHOD'])) {
- if (!in_array(strtoupper($_SERVER['REQUEST_METHOD']), ['GET'], true)) {
+ if (!in_array(mb_strtoupper($_SERVER['REQUEST_METHOD']), ['GET'], true)) {
return $is = true;
}
}
@@ -191,7 +191,7 @@ public function isLocalhost()
if (defined('LOCALHOST')) {
return $is = (boolean) LOCALHOST;
}
- if (preg_match('/\b(?:localhost|127\.0\.0\.1)\b/i', $this->hostToken())) {
+ if (preg_match('/\b(?:localhost|127\.0\.0\.1)\b/ui', $this->hostToken())) {
return $is = true;
}
return $is = false;
@@ -213,7 +213,7 @@ public function isAutoCacheEngine()
return $is; // Already cached this.
}
if (!empty($_SERVER['HTTP_USER_AGENT']) && is_string($_SERVER['HTTP_USER_AGENT'])) {
- if (stripos($_SERVER['HTTP_USER_AGENT'], GLOBAL_NS) !== false) {
+ if (mb_stripos($_SERVER['HTTP_USER_AGENT'], GLOBAL_NS) !== false) {
return $is = true;
}
}
@@ -263,10 +263,10 @@ public function isHtmlXmlDoc($doc)
if (!is_null($is = &$this->staticKey('isHtmlXmlDoc', $doc_hash))) {
return $is; // Already cached this.
}
- if (stripos($doc, '') !== false) {
+ if (mb_stripos($doc, '') !== false) {
return $is = true;
}
- if (stripos($doc, 'headersList() as $_key => $_header) {
- if (stripos($_header, 'Content-Type:') === 0) {
+ if (mb_stripos($_header, 'Content-Type:') === 0) {
$content_type = $_header; // Last one.
}
}
unset($_key, $_header); // Housekeeping.
- if (isset($content_type[0]) && stripos($content_type, 'html') === false
- && stripos($content_type, 'xml') === false && stripos($content_type, GLOBAL_NS) === false
+ if (isset($content_type[0]) && mb_stripos($content_type, 'html') === false
+ && mb_stripos($content_type, 'xml') === false && mb_stripos($content_type, GLOBAL_NS) === false
) {
return $is = false; // Do NOT cache data sent by scripts serving other MIME types.
}
@@ -323,7 +323,7 @@ public function hasACacheableStatus()
return $is = false; // A non-2xx & non-404 status code.
}
foreach ($this->headersList() as $_key => $_header) {
- if (preg_match('/^(?:Retry\-After\:\s+(?P.+)|Status\:\s+(?P[0-9]+)|HTTP\/[0-9]+(?:\.[0-9]+)?\s+(?P[0-9]+))/i', $_header, $_m)) {
+ if (preg_match('/^(?:Retry\-After\:\s+(?P.+)|Status\:\s+(?P[0-9]+)|HTTP\/[0-9]+(?:\.[0-9]+)?\s+(?P[0-9]+))/ui', $_header, $_m)) {
if (!empty($_m['retry']) || (!empty($_m['status']) && $_m['status'][0] !== '2' && $_m['status'] !== '404')
|| (!empty($_m['http_status']) && $_m['http_status'][0] !== '2' && $_m['http_status'] !== '404')
) {
@@ -380,10 +380,10 @@ public function functionIsPossible($function)
$disabled_functions = []; // Initialize disabled/blacklisted functions.
if (($disable_functions = trim(ini_get('disable_functions')))) {
- $disabled_functions = array_merge($disabled_functions, preg_split('/[\s;,]+/', strtolower($disable_functions), -1, PREG_SPLIT_NO_EMPTY));
+ $disabled_functions = array_merge($disabled_functions, preg_split('/[\s;,]+/', mb_strtolower($disable_functions), -1, PREG_SPLIT_NO_EMPTY));
}
if (($blacklist_functions = trim(ini_get('suhosin.executor.func.blacklist')))) {
- $disabled_functions = array_merge($disabled_functions, preg_split('/[\s;,]+/', strtolower($blacklist_functions), -1, PREG_SPLIT_NO_EMPTY));
+ $disabled_functions = array_merge($disabled_functions, preg_split('/[\s;,]+/', mb_strtolower($blacklist_functions), -1, PREG_SPLIT_NO_EMPTY));
}
if (filter_var(ini_get('suhosin.executor.disable_eval'), FILTER_VALIDATE_BOOLEAN)) {
$disabled_functions = array_merge($disabled_functions, ['eval']);
@@ -394,7 +394,7 @@ public function functionIsPossible($function)
return $is = false; // Not possible.
}
}
- if ($disabled_functions && in_array(strtolower($function), $disabled_functions, true)) {
+ if ($disabled_functions && in_array(mb_strtolower($function), $disabled_functions, true)) {
return $is = false; // Not possible.
}
return $is = true;
diff --git a/src/includes/traits/Shared/DomainMappingUtils.php b/src/includes/traits/Shared/DomainMappingUtils.php
index e663737c..bf092c9f 100644
--- a/src/includes/traits/Shared/DomainMappingUtils.php
+++ b/src/includes/traits/Shared/DomainMappingUtils.php
@@ -74,7 +74,7 @@ public function domainMappingUrlFilter($url)
if (empty($url_parts['host'])) {
return $original_url; // Not possible.
}
- $blog_domain = strtolower($url_parts['host']); // In the unfiltered URL.
+ $blog_domain = mb_strtolower($url_parts['host']); // In the unfiltered URL.
$blog_path = $this->hostDirToken(false, false, !empty($url_parts['path']) ? $url_parts['path'] : '/');
if (!($blog_id = (integer) get_blog_id_from_url($blog_domain, $blog_path))) {
@@ -86,7 +86,7 @@ public function domainMappingUrlFilter($url)
$url_parts['host'] = $domain; // Filter the URL now.
if (!empty($url_parts['path']) && $url_parts['path'] !== '/') {
if (($host_base_dir_tokens = trim($this->hostBaseDirTokens(false, false, $url_parts['path']), '/'))) {
- $url_parts['path'] = preg_replace('/^\/'.preg_quote($host_base_dir_tokens, '/').'(\/|$)/i', '${1}', $url_parts['path']);
+ $url_parts['path'] = preg_replace('/^\/'.preg_quote($host_base_dir_tokens, '/').'(\/|$)/ui', '${1}', $url_parts['path']);
}
}
return $url = $this->unParseUrl($url_parts);
@@ -159,9 +159,9 @@ public function domainMappingBlogId($url = '', $domain = '')
if (!$url && !$domain && ($blog_details = $this->blogDetails())) {
$domain = $blog_details->domain;
}
- $domain = strtolower(preg_replace('/^www\./i', '', $domain));
+ $domain = mb_strtolower(preg_replace('/^www\./ui', '', $domain));
- if (!$domain || strpos($domain, '.') === false) {
+ if (!$domain || mb_strpos($domain, '.') === false) {
return 0; // Not possible.
}
if (!is_null($blog_id = &$this->staticKey('domainMappingBlogId', $domain))) {
@@ -217,7 +217,7 @@ public function domainMappingBlogDomain($blog_id = 0, $fallback = false)
if (!$enforcing_primary_domain) {
if ($this->isDomainMapping() === $blog_id) {
$domain = $this->hostToken();
- $domain = preg_replace('/^www\./i', '', $domain);
+ $domain = preg_replace('/^www\./ui', '', $domain);
$domain = (string) $wpdb->get_var('SELECT `domain` FROM `'.esc_sql($wpdb->base_prefix.'domain_mapping').'` WHERE `blog_id` = \''.esc_sql($blog_id).'\' AND `domain` IN(\''.esc_sql('www.'.$domain).'\', \''.esc_sql($domain).'\') ORDER BY CHAR_LENGTH(`domain`) DESC LIMIT 1');
} elseif (($domains = $this->domainMappingBlogDomains($blog_id))) {
$domain = $domains[0]; // Use the first of all possible domains.
@@ -230,7 +230,7 @@ public function domainMappingBlogDomain($blog_id = 0, $fallback = false)
}
$wpdb->suppress_errors($suppressing_errors); // Restore.
- return $domain = strtolower((string) $domain);
+ return $domain = mb_strtolower((string) $domain);
}
/**
@@ -272,6 +272,6 @@ public function domainMappingBlogDomains($blog_id = 0)
}
$wpdb->suppress_errors($suppressing_errors); // Restore.
- return $domains = array_unique(array_map('strtolower', (array) $domains));
+ return $domains = array_unique(array_map('mb_strtolower', (array) $domains));
}
}
diff --git a/src/includes/traits/Shared/FsUtils.php b/src/includes/traits/Shared/FsUtils.php
index e8ccf641..26ae9fdf 100644
--- a/src/includes/traits/Shared/FsUtils.php
+++ b/src/includes/traits/Shared/FsUtils.php
@@ -23,21 +23,21 @@ public function nDirSeps($dir_file, $allow_trailing_slash = false)
if (!isset($dir_file[0])) {
return ''; // Catch empty string.
}
- if (strpos($dir_file, '://' !== false)) {
- if (preg_match('/^(?P[a-zA-Z0-9]+)\:\/\//', $dir_file, $stream_wrapper)) {
- $dir_file = preg_replace('/^(?P[a-zA-Z0-9]+)\:\/\//', '', $dir_file);
+ if (mb_strpos($dir_file, '://' !== false)) {
+ if (preg_match('/^(?P[a-zA-Z0-9]+)\:\/\//u', $dir_file, $stream_wrapper)) {
+ $dir_file = preg_replace('/^(?P[a-zA-Z0-9]+)\:\/\//u', '', $dir_file);
}
}
- if (strpos($dir_file, ':' !== false)) {
- if (preg_match('/^(?P[a-zA-Z])\:[\/\\\\]/', $dir_file)) {
- $dir_file = preg_replace_callback('/^(?P[a-zA-Z])\:[\/\\\\]/', create_function('$m', 'return strtoupper($m[0]);'), $dir_file);
+ if (mb_strpos($dir_file, ':' !== false)) {
+ if (preg_match('/^(?P[a-zA-Z])\:[\/\\\\]/u', $dir_file)) {
+ $dir_file = preg_replace_callback('/^(?P[a-zA-Z])\:[\/\\\\]/u', create_function('$m', 'return mb_strtoupper($m[0]);'), $dir_file);
}
}
- $dir_file = preg_replace('/\/+/', '/', str_replace([DIRECTORY_SEPARATOR, '\\', '/'], '/', $dir_file));
+ $dir_file = preg_replace('/\/+/u', '/', str_replace([DIRECTORY_SEPARATOR, '\\', '/'], '/', $dir_file));
$dir_file = ($allow_trailing_slash) ? $dir_file : rtrim($dir_file, '/'); // Strip trailing slashes.
if (!empty($stream_wrapper[0])) {
- $dir_file = strtolower($stream_wrapper[0]).$dir_file;
+ $dir_file = mb_strtolower($stream_wrapper[0]).$dir_file;
}
return $dir_file; // Normalized now.
}
@@ -73,10 +73,10 @@ public function getTmpDir()
if (!empty($_SERVER['TMP'])) {
$possible_dirs[] = (string) $_SERVER['TMP'];
}
- if (stripos(PHP_OS, 'win') === 0) {
+ if (mb_stripos(PHP_OS, 'win') === 0) {
$possible_dirs[] = 'C:/Temp';
}
- if (stripos(PHP_OS, 'win') !== 0) {
+ if (mb_stripos(PHP_OS, 'win') !== 0) {
$possible_dirs[] = '/tmp';
}
if (defined('WP_CONTENT_DIR')) {
@@ -204,7 +204,7 @@ public function abbrBytes($string)
return (float) 0;
}
$value = (float) $_m['value'];
- $modifier = strtolower($_m['modifier']);
+ $modifier = mb_strtolower($_m['modifier']);
unset($_m); // Housekeeping.
switch ($modifier) {
@@ -268,7 +268,7 @@ public function getDirRegexStats($dir, $regex = '', $include_paths = false, $che
if (!$dir || !is_dir($dir)) {
return $stats; // Not possible.
}
- $short_name_lc = strtolower(SHORT_NAME); // Once only.
+ $short_name_lc = mb_strtolower(SHORT_NAME); // Once only.
foreach ($this->dirRegexIteration($dir, $regex) as $_resource) {
$_resource_sub_path = $_resource->getSubpathname();
@@ -280,7 +280,7 @@ public function getDirRegexStats($dir, $regex = '', $include_paths = false, $che
if ($_resource_basename === '.htaccess') {
continue; // Ignore `.htaccess`.
}
- if (stripos($_resource_sub_path, $short_name_lc.'-') === 0) {
+ if (mb_stripos($_resource_sub_path, $short_name_lc.'-') === 0) {
continue; // Ignore [SHORT_NAME] files in base.
}
switch ($_resource->getType()) { // `link`, `file`, `dir`.
diff --git a/src/includes/traits/Shared/HookUtils.php b/src/includes/traits/Shared/HookUtils.php
index 6bc131b9..3c0a1270 100644
--- a/src/includes/traits/Shared/HookUtils.php
+++ b/src/includes/traits/Shared/HookUtils.php
@@ -60,8 +60,8 @@ public function hookId($function)
public function addHook($hook, $function, $priority = 10, $accepted_args = 1)
{
$hook = (string) $hook;
- if (stripos($hook, 'zencache') === 0) {
- $hook = GLOBAL_NS.substr($hook, strlen('zencache'));
+ if (mb_stripos($hook, 'zencache') === 0) {
+ $hook = GLOBAL_NS.mb_substr($hook, mb_strlen('zencache'));
}
$priority = (integer) $priority;
$accepted_args = max(0, (integer) $accepted_args);
@@ -130,8 +130,8 @@ public function add_filter()
public function removeHook($hook, $function, $priority = 10)
{
$hook = (string) $hook;
- if (stripos($hook, 'zencache') === 0) {
- $hook = GLOBAL_NS.substr($hook, strlen('zencache'));
+ if (mb_stripos($hook, 'zencache') === 0) {
+ $hook = GLOBAL_NS.mb_substr($hook, mb_strlen('zencache'));
}
$priority = (integer) $priority;
$hook_id = $this->hookId($function);
@@ -246,8 +246,8 @@ public function doWpAction($hook)
$args = func_get_args();
call_user_func_array('do_action', $args);
- if (stripos($hook, GLOBAL_NS) === 0) {
- $zencache_filter = 'zencache'.substr($hook, strlen(GLOBAL_NS));
+ if (mb_stripos($hook, GLOBAL_NS) === 0) {
+ $zencache_filter = 'zencache'.mb_substr($hook, mb_strlen(GLOBAL_NS));
$zencache_args = $args; // Use a copy of the args.
$zencache_args[0] = $zencache_filter;
call_user_func_array('do_action', $zencache_args);
@@ -269,8 +269,8 @@ public function applyWpFilters($hook)
$args = func_get_args();
$value = call_user_func_array('apply_filters', $args);
- if (stripos($hook, GLOBAL_NS) === 0) {
- $zencache_hook = 'zencache'.substr($hook, strlen(GLOBAL_NS));
+ if (mb_stripos($hook, GLOBAL_NS) === 0) {
+ $zencache_hook = 'zencache'.mb_substr($hook, mb_strlen(GLOBAL_NS));
$zencache_args = $args; // Use a copy of the args.
$zencache_args[0] = $zencache_hook;
$zencache_args[1] = $value; // Filtered value.
diff --git a/src/includes/traits/Shared/HttpUtils.php b/src/includes/traits/Shared/HttpUtils.php
index 56f9fd05..d08b16f6 100644
--- a/src/includes/traits/Shared/HttpUtils.php
+++ b/src/includes/traits/Shared/HttpUtils.php
@@ -18,9 +18,9 @@ public function httpProtocol()
return $protocol; // Already cached this.
}
if (!empty($_SERVER['SERVER_PROTOCOL']) && is_string($_SERVER['SERVER_PROTOCOL'])) {
- $protocol = strtoupper($_SERVER['SERVER_PROTOCOL']);
+ $protocol = mb_strtoupper($_SERVER['SERVER_PROTOCOL']);
}
- if (!$protocol || stripos($protocol, 'HTTP/') !== 0) {
+ if (!$protocol || mb_stripos($protocol, 'HTTP/') !== 0) {
$protocol = 'HTTP/1.0'; // Default value.
}
return $protocol;
@@ -110,10 +110,10 @@ public function cacheableHeadersList()
'X-Powered-By',
'X-UA-Compatible',
];
- $cacheable_headers = array_map('strtolower', $cacheable_headers);
+ $cacheable_headers = array_map('mb_strtolower', $cacheable_headers);
foreach ($headers as $_key => $_header) {
- $_header = strtolower((string) strstr($_header, ':', true));
+ $_header = mb_strtolower((string) strstr($_header, ':', true));
if (!$_header || !in_array($_header, $cacheable_headers, true)) {
unset($headers[$_key]);
}
diff --git a/src/includes/traits/Shared/IpAddrUtils.php b/src/includes/traits/Shared/IpAddrUtils.php
index 2c79a858..26d5da29 100644
--- a/src/includes/traits/Shared/IpAddrUtils.php
+++ b/src/includes/traits/Shared/IpAddrUtils.php
@@ -53,7 +53,7 @@ public function currentIp()
unset($_key, $_source, $_valid_public_ip); // Housekeeping.
}
if (!empty($_SERVER['REMOTE_ADDR'])) {
- return $ip = strtolower((string) $_SERVER['REMOTE_ADDR']);
+ return $ip = mb_strtolower((string) $_SERVER['REMOTE_ADDR']);
}
return $ip = 'unknown'; // Not possible.
}
@@ -79,7 +79,7 @@ public function validPublicIp($list_of_possible_ips)
return ''; // Not possible; i.e., empty string.
}
foreach (preg_split('/[\s;,]+/', $list_of_possible_ips, -1, PREG_SPLIT_NO_EMPTY) as $_key => $_possible_ip) {
- if (($_valid_public_ip = filter_var(strtolower($_possible_ip), FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))) {
+ if (($_valid_public_ip = filter_var(mb_strtolower($_possible_ip), FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))) {
return $_valid_public_ip; // A valid public IPv4 or IPv6 address.
}
}
diff --git a/src/includes/traits/Shared/PatternUtils.php b/src/includes/traits/Shared/PatternUtils.php
index f92677e8..e1436cde 100644
--- a/src/includes/traits/Shared/PatternUtils.php
+++ b/src/includes/traits/Shared/PatternUtils.php
@@ -38,10 +38,10 @@ public function wdRegexToActualRegexFrag($string)
{
return preg_replace(
[
- '/\\\\\^/',
- '/\\\\\*\\\\\*/',
- '/\\\\\*/',
- '/\\\\\$/',
+ '/\\\\\^/u',
+ '/\\\\\*\\\\\*/u',
+ '/\\\\\*/u',
+ '/\\\\\$/u',
],
[
'^', // Beginning of line.
diff --git a/src/includes/traits/Shared/ReplaceUtils.php b/src/includes/traits/Shared/ReplaceUtils.php
index 76c8c417..33bf315c 100644
--- a/src/includes/traits/Shared/ReplaceUtils.php
+++ b/src/includes/traits/Shared/ReplaceUtils.php
@@ -8,6 +8,9 @@ trait ReplaceUtils
/**
* String replace ONE time.
*
+ * @deprecated Deprecated since v16xxxx
+ * @deprecated Replaced with Multibyte String support; see https://github.com/websharks/comet-cache/issues/703
+ *
* @since 150422 Rewrite.
*
* @param string $needle A string to search/replace.
@@ -23,17 +26,20 @@ public function strReplaceOnce($needle, $replace, $haystack, $caSe_insensitive =
$needle = (string) $needle;
$replace = (string) $replace;
$haystack = (string) $haystack;
- $caSe_strpos = $caSe_insensitive ? 'stripos' : 'strpos';
+ $caSe_mb_strpos = $caSe_insensitive ? 'mb_stripos' : 'mb_strpos';
- if (($needle_strpos = $caSe_strpos($haystack, $needle)) === false) {
+ if (($needle_strpos = $caSe_mb_strpos($haystack, $needle)) === false) {
return $haystack; // Nothing to replace.
}
- return (string) substr_replace($haystack, $replace, $needle_strpos, strlen($needle));
+ return (string) substr_replace($haystack, $replace, $needle_strpos, mb_strlen($needle));
}
/**
* String replace ONE time (caSe-insensitive).
*
+ * @deprecated Deprecated since v16xxxx
+ * @deprecated Replaced with Multibyte String support; see https://github.com/websharks/comet-cache/issues/703
+ *
* @since 150422 Rewrite.
*
* @param string $needle A string to search/replace.
diff --git a/src/includes/traits/Shared/ServerUtils.php b/src/includes/traits/Shared/ServerUtils.php
index a011f144..65825af6 100644
--- a/src/includes/traits/Shared/ServerUtils.php
+++ b/src/includes/traits/Shared/ServerUtils.php
@@ -18,10 +18,10 @@ public function isApache()
return $is; // Already cached this.
}
if (!empty($_SERVER['SERVER_SOFTWARE']) && is_string($_SERVER['SERVER_SOFTWARE'])) {
- if (stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false) {
+ if (mb_stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false) {
return $is = true;
}
- if (stripos($_SERVER['SERVER_SOFTWARE'], 'litespeed') !== false) {
+ if (mb_stripos($_SERVER['SERVER_SOFTWARE'], 'litespeed') !== false) {
return $is = true;
}
}
@@ -41,7 +41,7 @@ public function isNginx()
return $is; // Already cached this.
}
if (!empty($_SERVER['SERVER_SOFTWARE']) && is_string($_SERVER['SERVER_SOFTWARE'])) {
- if (stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) {
+ if (mb_stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) {
return $is = true;
}
}
@@ -61,10 +61,10 @@ public function isIis()
return $is; // Already cached this.
}
if (!empty($_SERVER['SERVER_SOFTWARE']) && is_string($_SERVER['SERVER_SOFTWARE'])) {
- if (stripos($_SERVER['SERVER_SOFTWARE'], 'microsoft-iis') !== false) {
+ if (mb_stripos($_SERVER['SERVER_SOFTWARE'], 'microsoft-iis') !== false) {
return $is = true;
}
- if (stripos($_SERVER['SERVER_SOFTWARE'], 'expressiondevserver') !== false) {
+ if (mb_stripos($_SERVER['SERVER_SOFTWARE'], 'expressiondevserver') !== false) {
return $is = true;
}
}
diff --git a/src/includes/traits/Shared/StringUtils.php b/src/includes/traits/Shared/StringUtils.php
index 0fbf80c9..d676ca13 100644
--- a/src/includes/traits/Shared/StringUtils.php
+++ b/src/includes/traits/Shared/StringUtils.php
@@ -32,13 +32,13 @@ public function clip($value, $max_length = 80, $force_ellipsis = false)
$max_length = max(4, $max_length);
$string = strip_tags($string);
- $string = preg_replace('/\s+/', ' ', strip_tags($string));
+ $string = preg_replace('/\s+/u', ' ', strip_tags($string));
$string = trim($string); // Trim it up now.
- if (strlen($string) > $max_length) {
- $string = (string) substr($string, 0, $max_length - 3).'...';
- } elseif ($force_ellipsis && strlen($string) + 3 > $max_length) {
- $string = (string) substr($string, 0, $max_length - 3).'...';
+ if (mb_strlen($string) > $max_length) {
+ $string = (string) mb_substr($string, 0, $max_length - 3).'...';
+ } elseif ($force_ellipsis && mb_strlen($string) + 3 > $max_length) {
+ $string = (string) mb_substr($string, 0, $max_length - 3).'...';
} else {
$string .= $force_ellipsis ? '...' : '';
}
@@ -71,10 +71,10 @@ public function midClip($value, $max_length = 80)
$max_length = max(4, $max_length);
$string = strip_tags($string);
- $string = preg_replace('/\s+/', ' ', strip_tags($string));
+ $string = preg_replace('/\s+/u', ' ', strip_tags($string));
$string = trim($string); // Trim it up now.
- if (strlen($string) <= $max_length) {
+ if (mb_strlen($string) <= $max_length) {
return $string; // Nothing to do.
}
$full_string = $string;
@@ -82,12 +82,12 @@ public function midClip($value, $max_length = 80)
$first_clip = $half_max_length - 3;
$string = $first_clip >= 1 // Something?
- ? substr($full_string, 0, $first_clip).'...'
+ ? mb_substr($full_string, 0, $first_clip).'...'
: '...'; // Ellipsis only.
- $second_clip = strlen($full_string) - ($max_length - strlen($string));
+ $second_clip = mb_strlen($full_string) - ($max_length - mb_strlen($string));
$string .= $second_clip >= 0 && $second_clip >= $first_clip
- ? substr($full_string, $second_clip) : '';
+ ? mb_substr($full_string, $second_clip) : '';
return $string;
}
diff --git a/src/includes/traits/Shared/TokenUtils.php b/src/includes/traits/Shared/TokenUtils.php
index 19fa069d..842b9e9b 100644
--- a/src/includes/traits/Shared/TokenUtils.php
+++ b/src/includes/traits/Shared/TokenUtils.php
@@ -56,9 +56,9 @@ public function hostToken($dashify = false, $consider_domain_mapping = false, $c
$token = (string) parse_url(home_url(), PHP_URL_HOST);
}
if ($token) { // Have token?
- $token = strtolower($token);
+ $token = mb_strtolower($token);
if ($dashify) { // Dashify it?
- $token = preg_replace('/[^a-z0-9]/i', '-', $token);
+ $token = preg_replace('/[^a-z0-9]/ui', '-', $token);
$token = trim($token, '-');
}
}
@@ -98,9 +98,9 @@ public function hostTokenForBlog($dashify = false, $consider_domain_mapping = fa
$token = $blog_details->domain; // Unmapped domain.
}
if ($token) { // Have token?
- $token = strtolower($token);
+ $token = mb_strtolower($token);
if ($dashify) { // Dashify it?
- $token = preg_replace('/[^a-z0-9]/i', '-', $token);
+ $token = preg_replace('/[^a-z0-9]/ui', '-', $token);
$token = trim($token, '-');
}
}
@@ -143,7 +143,7 @@ public function hostBaseToken($dashify = false, $consider_domain_mapping = false
$token = isset($token[0]) ? '/'.$token.'/' : '/';
if ($token !== '/' && $dashify) {
- $token = preg_replace('/[^a-z0-9\/]/i', '-', $token);
+ $token = preg_replace('/[^a-z0-9\/]/ui', '-', $token);
$token = trim($token, '-');
}
return $token;
@@ -185,7 +185,7 @@ public function hostDirToken($dashify = false, $consider_domain_mapping = false,
return $token; // Not applicable.
}
if ($path && $path !== '/' && ($host_base_token = trim($this->hostBaseToken(), '/'))) {
- $path_minus_base = preg_replace('/^\/'.preg_quote($host_base_token, '/').'(\/|$)/i', '${1}', $path);
+ $path_minus_base = preg_replace('/^\/'.preg_quote($host_base_token, '/').'(\/|$)/ui', '${1}', $path);
} else {
$path_minus_base = $path; // Default value.
}
@@ -194,13 +194,13 @@ public function hostDirToken($dashify = false, $consider_domain_mapping = false,
$token = isset($token[0]) ? '/'.$token.'/' : '/';
if ($token !== '/') { // Perhaps NOT the main site?
- $blog_paths_file = $this->cacheDir().'/'.strtolower(SHORT_NAME).'-blog-paths';
+ $blog_paths_file = $this->cacheDir().'/'.mb_strtolower(SHORT_NAME).'-blog-paths';
if (!is_file($blog_paths_file) || !in_array($token, unserialize(file_get_contents($blog_paths_file)), true)) {
$token = '/'; // NOT a real/valid child blog path.
}
}
if ($token !== '/' && $dashify) {
- $token = preg_replace('/[^a-z0-9\/]/i', '-', $token);
+ $token = preg_replace('/[^a-z0-9\/]/ui', '-', $token);
$token = trim($token, '-');
}
return $token;
@@ -236,7 +236,7 @@ public function hostDirTokenForBlog($dashify = false, $consider_domain_mapping =
if (($blog_details = $this->blogDetails($blog_id))) {
$path = $blog_details->path; // e.g., `[/base]/path/` (includes base).
if ($path && $path !== '/' && ($host_base_token = trim($this->hostBaseToken(), '/'))) {
- $path_minus_base = preg_replace('/^\/'.preg_quote($host_base_token, '/').'(\/|$)/i', '${1}', $path);
+ $path_minus_base = preg_replace('/^\/'.preg_quote($host_base_token, '/').'(\/|$)/ui', '${1}', $path);
} else {
$path_minus_base = $path; // Default value.
}
@@ -246,13 +246,13 @@ public function hostDirTokenForBlog($dashify = false, $consider_domain_mapping =
$token = isset($token[0]) ? '/'.$token.'/' : '/';
if ($token !== '/') { // Perhaps NOT the main site?
- $blog_paths_file = $this->cacheDir().'/'.strtolower(SHORT_NAME).'-blog-paths';
+ $blog_paths_file = $this->cacheDir().'/'.mb_strtolower(SHORT_NAME).'-blog-paths';
if (!is_file($blog_paths_file) || !in_array($token, unserialize(file_get_contents($blog_paths_file)), true)) {
$token = '/'; // NOT a real/valid child blog path.
}
}
if ($token !== '/' && $dashify) {
- $token = preg_replace('/[^a-z0-9\/]/i', '-', $token);
+ $token = preg_replace('/[^a-z0-9\/]/ui', '-', $token);
$token = trim($token, '-');
}
return $token;
@@ -280,7 +280,7 @@ public function hostBaseDirTokens($dashify = false, $consider_domain_mapping = f
$tokens = $this->hostBaseToken($dashify, $consider_domain_mapping);
$tokens .= $this->hostDirToken($dashify, $consider_domain_mapping, $path);
- return $tokens = preg_replace('/\/+/', '/', $tokens);
+ return $tokens = preg_replace('/\/+/u', '/', $tokens);
}
/**
@@ -302,7 +302,7 @@ public function hostBaseDirTokensForBlog($dashify = false, $consider_domain_mapp
$tokens = $this->hostBaseToken($dashify, $consider_domain_mapping);
$tokens .= $this->hostDirTokenForBlog($dashify, $consider_domain_mapping, $blog_id);
- return $tokens = preg_replace('/\/+/', '/', $tokens);
+ return $tokens = preg_replace('/\/+/u', '/', $tokens);
}
/*[pro strip-from="lite"]*/
@@ -335,11 +335,11 @@ public function userToken()
}
}
if (!empty($_COOKIE['comment_author_email_'.COOKIEHASH])) {
- return $token = md5(strtolower(stripslashes((string) $_COOKIE['comment_author_email_'.COOKIEHASH])));
+ return $token = md5(mb_strtolower(stripslashes((string) $_COOKIE['comment_author_email_'.COOKIEHASH])));
} elseif (!empty($_COOKIE['wp-postpass_'.COOKIEHASH])) {
return $token = md5(stripslashes((string) $_COOKIE['wp-postpass_'.COOKIEHASH]));
} elseif (defined('SID') && SID) {
- return $token = preg_replace('/[^a-z0-9]/i', '', (string) SID);
+ return $token = preg_replace('/[^a-z0-9]/ui', '', (string) SID);
}
return $token = '';
}
diff --git a/src/includes/traits/Shared/UrlUtils.php b/src/includes/traits/Shared/UrlUtils.php
index 499388a9..5323e9cb 100644
--- a/src/includes/traits/Shared/UrlUtils.php
+++ b/src/includes/traits/Shared/UrlUtils.php
@@ -19,9 +19,9 @@ public function parseUrl($url_uri_qsl, $component = -1)
{
$url_uri_qsl = (string) $url_uri_qsl;
$component = (integer) $component;
- ${'//'} = strpos($url_uri_qsl, '//') === 0;
+ ${'//'} = mb_strpos($url_uri_qsl, '//') === 0;
- if ($url_uri_qsl && strpos($url_uri_qsl, '&') !== false) {
+ if ($url_uri_qsl && mb_strpos($url_uri_qsl, '&') !== false) {
$url_uri_qsl = str_replace('&', '&', $url_uri_qsl);
}
if ($component > -1) {