Skip to content
Permalink
Browse files

Enable inline output filtering

  • Loading branch information...
fstolba authored and respawner committed Jul 4, 2019
1 parent f0251fd commit 501860829268d5ffb4624aaa47edf3fef488644c
Showing with 13 additions and 7 deletions.
  1. +3 −0 config.php.example
  2. +10 −7 routers/router.php
@@ -24,6 +24,9 @@ $config['frontpage']['disclaimer'] = 'This is a disclaimer!';
// Things to remove from the output (PHP compatible regex)
$config['filters']['output'][] = '/(client1|client2)/';
$config['filters']['output'][] = '/^NotToShow/';
// Matched patterns can also replaced inline
$config['filters']['output'][] = ['/replacethis/', 'withthis'];

// If telnet is used in combination with extreme_netiron, uncomment the following filter
//$config['filters']['output'][] = '/([^\x20-\x7E]|User|Please|Disable|telnet|^\s*$)/';

@@ -73,15 +73,18 @@ private function sanitize_output($output) {
$valid = true;
foreach ($this->global_config['filters']['output'] as $filter) {
// Line has been marked as invalid
// Or filtered based on the configuration
if (!$valid || (preg_match($filter, $line) === 1)) {
$valid = false;
break;
if (gettype($filter) == gettype(array())) {
$line = preg_replace($filter[0], $filter[1], $line);
} else {
// Line has been marked as invalid
// Or filtered based on the configuration
if (!$valid || (preg_match($filter, $line) === 1)) {
$valid = false;
break;
}
}
}
if ($valid) {
if ($valid) {
// The line is valid, print it
$filtered .= $line."\n";
}

0 comments on commit 5018608

Please sign in to comment.
You can’t perform that action at this time.