From d76d47b12fdcc9e127d023661e806cf2ca8e7715 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:25:24 +0200 Subject: Adding upstream version 1.1.1. Signed-off-by: Daniel Baumann --- library/Nagvis/RestrictionHelper.php | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 library/Nagvis/RestrictionHelper.php (limited to 'library/Nagvis/RestrictionHelper.php') diff --git a/library/Nagvis/RestrictionHelper.php b/library/Nagvis/RestrictionHelper.php new file mode 100644 index 0000000..a757b9d --- /dev/null +++ b/library/Nagvis/RestrictionHelper.php @@ -0,0 +1,41 @@ +getRestrictions('nagvis/map/filter') as $mapFilter) { + if ($mapFilter !== '') { + $mapFilters = array_merge($mapFilters, array_map('trim', explode(',', $mapFilter))); + } + } + + if (! empty($mapFilters)) { + $mapRegexParts = array(); + foreach (array_unique($mapFilters) as $mapFilter) { + $nonWildcards = array(); + foreach (explode('*', $mapFilter) as $nonWildcard) { + $nonWildcards[] = preg_quote($nonWildcard, '/'); + } + $mapRegexParts[] = implode('.*', $nonWildcards); + } + + return '/^(?:' . implode('|', $mapRegexParts) . ')$/i'; + } + + return null; + } +} -- cgit v1.2.3