/** * Get all groups of Device * @param integer $device Device-ID * @return array */ function GetGroupsFromDevice($device) { $ret = array(); foreach (GetDeviceGroups() as $group) { if (dbFetchCell(GenGroupSQL($group['pattern'], 'device_id=?') . ' LIMIT 1', array($device)) == $device) { $ret[] = $group['id']; } } return $ret; }
if (is_numeric($_POST['min_severity'])) { $min_severity_id = $_POST['min_severity']; } else { if (!empty($_POST['min_severity'])) { $min_severity_id = $alert_severities[$_POST['min_severity']]; } } if (isset($min_severity_id)) { $where .= " AND `alert_rules`.`severity` >= " . $min_severity_id; } } if (is_numeric($_POST['group'])) { $group_pattern = dbFetchCell('SELECT `pattern` FROM `device_groups` WHERE id = ' . $_POST['group']); $group_pattern = rtrim($group_pattern, '&&'); $group_pattern = rtrim($group_pattern, '||'); $device_id_sql = GenGroupSQL($group_pattern); if ($device_id_sql) { $where .= " AND devices.device_id IN ({$device_id_sql})"; } } if (!$show_recovered) { $where .= " AND `alerts`.`state`!=" . $alert_states['recovered']; } if (isset($searchPhrase) && !empty($searchPhrase)) { $where .= " AND (`timestamp` LIKE '%{$searchPhrase}%' OR `rule` LIKE '%{$searchPhrase}%' OR `name` LIKE '%{$searchPhrase}%' OR `hostname` LIKE '%{$searchPhrase}%')"; } $sql = ' FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`'; if (is_admin() === false && is_read() === false) { $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id'];
/** * Run the group queries again to get fresh list of groups for this device * @param integer $device_id Device-ID * @param int $extra Return extra info about the groups (name, desc, pattern) * @return array */ function QueryGroupsFromDevice($device_id, $extra = 0) { $ret = array(); foreach (GetDeviceGroups() as $group) { if (dbFetchCell(GenGroupSQL($group['pattern'], 'device_id=?', $extra) . ' LIMIT 1', array($device_id)) == $device_id) { if ($extra === 0) { $ret[] = $group['id']; } else { $ret[] = $group; } } } return $ret; }
/** * Run the group queries again to get fresh list of groups for this device * @param integer $device_id Device-ID * @param int $extra Return extra info about the groups (name, desc, pattern) * @return array */ function QueryGroupsFromDevice($device_id, $extra = 0) { $ret = array(); foreach (GetDeviceGroups() as $group) { $params = (array) json_decode($group['params']); array_unshift($params, $device_id); if (dbFetchCell(GenGroupSQL($group['pattern'], 'device_id=?', $extra) . ' LIMIT 1', $params) == $device_id) { if ($extra === 0) { $ret[] = $group['id']; } else { $ret[] = $group; } } } return $ret; }