added central function and updated

This commit is contained in:
laf
2016-10-18 03:06:03 +00:00
parent 51a1ddf34f
commit 46d2f578e7
4 changed files with 44 additions and 64 deletions

View File

@@ -1736,3 +1736,21 @@ function get_toner_levels($device, $raw_value, $capacity)
return round($raw_value / $capacity * 100);
}
/**
* check if we should skip this device from discovery
* @param $needles
* @param $haystack
* @param $name
* @return bool
*/
function can_skip_discovery($needles, $haystack, $name)
{
foreach ((array)$needles as $needle) {
if (preg_match($needle ."i", $haystack)) {
d_echo("{$name} - regexp '{$needle}' matches '{$haystack}' - skipping device discovery \n");
return true;
}
}
return false;
}