diff options
Diffstat (limited to 'modules-available/eventlog/inc/filterruleprocessor.inc.php')
-rw-r--r-- | modules-available/eventlog/inc/filterruleprocessor.inc.php | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/modules-available/eventlog/inc/filterruleprocessor.inc.php b/modules-available/eventlog/inc/filterruleprocessor.inc.php index bd829b26..2eb0c252 100644 --- a/modules-available/eventlog/inc/filterruleprocessor.inc.php +++ b/modules-available/eventlog/inc/filterruleprocessor.inc.php @@ -181,8 +181,6 @@ class FilterRuleProcessor $pathElement = array_shift($path); // Get everything on this level if ($pathElement === '*') { - if (!is_array($data)) - return []; $return = []; if (empty($path)) { // End, everything needs to be primitive types @@ -201,11 +199,13 @@ class FilterRuleProcessor } return $return; } + if (!array_key_exists($pathElement, $data) && (isset($data['clientip']) || isset($data['machineuuid']))) { // An unknown key was requested, but we have clientip or machineuuid.... - if (in_array($pathElement, self::MACHINE_COLUMNS)) { - // Key matches a column from machine table, try to fetch it + if (in_array($pathElement, self::MACHINE_COLUMNS) || !isset($data['machineuuid'])) { + // Key matches a column from machine table, OR we don't have machineuuid but clientip + // try to fetch it. Second condition is in case we have a HW_QUERIES virtual column. if ($pathElement !== 'machineuuid' && isset($data['machineuuid'])) { $row = Database::queryFirst("SELECT " . implode(',', self::MACHINE_COLUMNS) . " FROM machine WHERE machineuuid = :uuid", ['uuid' => $data['machineuuid']]); @@ -216,27 +216,29 @@ class FilterRuleProcessor $row = false; } if ($row !== false) { - error_log('Additional client data fetched on the fly'); $data += $row; } - } elseif (isset($data['machineuuid']) + } + if (isset($data['machineuuid']) && isset(self::HW_QUERIES[$pathElement]) && Module::isAvailable('statistics')) { // Key matches a predefined hwinfo property, resolve.... $q = new HardwareQuery(self::HW_QUERIES[$pathElement][0], $data['machineuuid']); $q->addColumn(self::HW_QUERIES[$pathElement][2], self::HW_QUERIES[$pathElement][1]); $res = $q->query(); if ($res !== false) { - $row = $res->fetch(); - if ($row !== false) { - $data[$pathElement] = $row[self::HW_QUERIES[$pathElement][1]]; + foreach ($res as $row) { + $data[$pathElement][] = $row[self::HW_QUERIES[$pathElement][1]]; } } } } + if (!array_key_exists($pathElement, $data)) return []; if (empty($path) && !is_array($data[$pathElement])) return [$data[$pathElement]]; + if (empty($path) && ArrayUtil::isOnlyPrimitiveTypes($data[$pathElement])) + return $data[$pathElement]; if (is_array($data[$pathElement])) return self::get($path, $data[$pathElement]); return []; // No match |