['val' => runcache_get_server_var('REQUEST_URI'), 'key' => 'exclude_url'], 'browser' => ['val' => runcache_get_server_var('HTTP_USER_AGENT'), 'key' => 'exclude_browser'], 'visitorip' => ['val' => runcache_get_server_var('REMOTE_ADDR'), 'key' => 'exclude_visitorip'], ]; foreach ($checks as $check) { $onn = $runcache_config["{$check['key']}_onn"] ?? false; $mch = $runcache_config["{$check['key']}_mch"] ?? []; // Split string lists on newlines. if (is_string($mch)) { $mch = array_filter(array_map('trim', preg_split('/\r?\n/', $mch) ?: [])); } if ($onn && is_array($mch) && $matches_any($check['val'], $mch)) { return false; } } // Auth and session cookies are always excluded. foreach ($_COOKIE as $name => $_) { if ($matches_any((string) $name, $hardcoded_cookies)) { return false; } } // Check every cookie name against the configured patterns. if (($runcache_config['exclude_cookie_onn'] ?? false)) { $patterns = $runcache_config['exclude_cookie_mch'] ?? []; if (is_string($patterns)) { $patterns = array_filter(array_map('trim', preg_split('/\r?\n/', $patterns) ?: [])); } if (is_array($patterns)) { foreach ($_COOKIE as $name => $_) { if ($matches_any((string) $name, $patterns)) { return false; } } } } // Check query parameters after the ignore list removes its keys. if ($get_params !== []) { $query_params = $get_params; if (!empty($runcache_config['exclude_query_onn'])) { $excluded = runcache_normalize_list($runcache_config['exclude_query_mch'] ?? []); if ($excluded !== [] && array_intersect(array_keys($query_params), $excluded) !== []) { return false; } } if (!empty($runcache_config['ignore_query_onn'])) { $ignored = runcache_normalize_list($runcache_config['ignore_query_mch'] ?? []); if ($ignored !== []) { $query_params = array_diff_key($query_params, array_flip($ignored)); } } if ($query_params !== []) { if (empty($runcache_config['allow_query_onn'])) { // Query strings are not cacheable by default. return false; } $allowed = runcache_normalize_list($runcache_config['allow_query_mch'] ?? []); if (array_diff(array_keys($query_params), $allowed) !== []) { return false; } } } return true; } }