hasGlobalRead()) { $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; $where .= ' AND `DP`.`user_id`=?'; $param[] = Auth::id(); } if (!empty($vars['location'])) { $sql .= " LEFT JOIN `devices_attribs` AS `DB` ON `DB`.`device_id`=`devices`.`device_id` AND `DB`.`attrib_type`='override_sysLocation_bool' AND `DB`.`attrib_value`='1' LEFT JOIN `devices_attribs` AS `DA` ON `devices`.`device_id`=`DA`.`device_id`"; } if (!empty($vars['group']) && is_numeric($vars['group'])) { $sql .= " LEFT JOIN `device_group_device` AS `DG` ON `DG`.`device_id`=`devices`.`device_id`"; $where .= " AND `DG`.`device_group_id`=?"; $param[] = $vars['group']; } $sql .= " WHERE $where "; if (!empty($vars['searchquery'])) { $sql .= ' AND (sysName LIKE ? OR hostname LIKE ? OR hardware LIKE ? OR os LIKE ? OR location LIKE ?)'; $param += array_fill(count($param), 5, '%' . $vars['searchquery'] . '%'); } if (!empty($vars['os'])) { $sql .= ' AND os = ?'; $param[] = $vars['os']; } if (!empty($vars['version'])) { $sql .= ' AND version = ?'; $param[] = $vars['version']; } if (!empty($vars['hardware'])) { $sql .= ' AND hardware = ?'; $param[] = $vars['hardware']; } if (!empty($vars['features'])) { $sql .= ' AND features = ?'; $param[] = $vars['features']; } if (!empty($vars['type'])) { if ($vars['type'] == 'generic') { $sql .= " AND ( type = ? OR type = '')"; $param[] = $vars['type']; } else { $sql .= ' AND type = ?'; $param[] = $vars['type']; } } if (!empty($vars['state'])) { $sql .= ' AND status= ?'; if (is_numeric($vars['state'])) { $param[] = $vars['state']; } else { $param[] = str_replace(array('up', 'down'), array(1, 0), $vars['state']); } } if (!empty($vars['disabled'])) { $sql .= ' AND disabled= ?'; $param[] = $vars['disabled']; } if (!empty($vars['ignore'])) { $sql .= ' AND `ignore`= ?'; $param[] = $vars['ignore']; } if (!empty($vars['location']) && $vars['location'] == 'Unset') { $location_filter = ''; } if (!empty($vars['location'])) { $sql .= " AND `location` = ?"; $param[] = $vars['location']; } $count_sql = "SELECT COUNT(`devices`.`device_id`) $sql"; $total = (int)dbFetchCell($count_sql, $param); if (!isset($sort) || empty($sort)) { $sort = '`hostname` DESC'; } $sql .= " ORDER BY $sort"; if (isset($current)) { $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } if ($rowCount != -1) { $sql .= " LIMIT $limit_low,$limit_high"; } $sql = "SELECT DISTINCT(`devices`.`device_id`),`devices`.* $sql"; if (!isset($vars['format'])) { $vars['format'] = 'list_detail'; } list($format, $subformat) = explode('_', $vars['format']); foreach (dbFetchRows($sql, $param) as $device) { if (isset($bg) && $bg == $config['list_colour']['odd']) { $bg = $config['list_colour']['even']; } else { $bg = $config['list_colour']['odd']; } if ($device['status'] == '0') { $extra = 'label-danger'; } else { $extra = 'label-success'; } if ($device['ignore'] == '1') { $extra = 'label-default'; if ($device['status'] == '1') { $extra = 'label-warning'; } } if ($device['disabled'] == '1') { $extra = 'label-default'; } $type = strtolower($device['os']); $image = getIconTag($device); if ($device['os'] == 'ios') { formatCiscoHardware($device, true); } $device['os_text'] = $config['os'][$device['os']]['text']; $port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id'])); $sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id'])); $wireless_count = dbFetchCell('SELECT COUNT(*) FROM `wireless_sensors` WHERE `device_id` = ?', array($device['device_id'])); $actions = '