diff options
author | Phil Davis <phil.davis@inf.org> | 2017-03-12 13:06:47 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2017-03-12 13:06:47 +0545 |
commit | bea1884125fdd9d8ef58afd97f53516b61adaf29 (patch) | |
tree | def8d8e8e9f363ee9942f8d6083fd9d793c16892 /src/etc/inc/util.inc | |
parent | 2b359eda6d4d6712888a59cb5b01aeee245e34be (diff) | |
download | pfsense-bea1884125fdd9d8ef58afd97f53516b61adaf29.zip pfsense-bea1884125fdd9d8ef58afd97f53516b61adaf29.tar.gz |
Fix #7372 Cannot filter ICMP Type SKIP
Diffstat (limited to 'src/etc/inc/util.inc')
-rw-r--r-- | src/etc/inc/util.inc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index 604c557..cdf67b9 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -2368,6 +2368,23 @@ function explode_assoc($delimiter, $string) { return $result; } +/* + * Given a string of text with some delimiter, look for occurrences + * of some string and replace all of those. + * $text - the text string (e.g. "abc,defg,x123,ipv4,xyz") + * $delimiter - the delimiter (e.g. ",") + * $element - the element to match (e.g. "defg") + * $replacement - the string to replace it with (e.g. "42") + * Returns the resulting delimited string (e.g. "abc,42,x123,ipv4,xyz") + */ +function replace_element_in_list($text, $delimiter, $element, $replacement) { + $textArray = explode($delimiter, $text); + while (($entry = array_search($element, $textArray)) !== false) { + $textArray[$entry] = $replacement; + } + return implode(',', $textArray); +} + /* Try to change a static route, if it doesn't exist, add it */ function route_add_or_change($args) { global $config; |