* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * Package Search * @author Daniel Preussker * @copyright 2014 f0o, LibreNMS * @license GPL */ print_optionbar_start(28); ?>
0) { $results = $_POST['results']; } else { $results = 50; } ?>
hasGlobalRead()) { $device_ids = Permissions::devicesForUser()->toArray() ?: [0]; $where .= ' AND `D`.`device_id` IN ' . dbGenPlaceholders(count($device_ids)); $param = array_merge($param, $device_ids); } $query .= " WHERE packages.device_id = devices.device_id AND packages.name LIKE '%" . mres($_POST['package']) . "%' $sql_where GROUP BY packages.name"; $where = ''; $ver = ''; $opt = ''; if (! empty($_POST['arch'])) { $where .= ' AND packages.arch = ?'; $param[] = mres($_POST['arch']); } if (is_numeric($_REQUEST['device_id'])) { $where .= ' AND packages.device_id = ?'; $param[] = $_REQUEST['device_id']; } $count_query .= $query . ' ) sub'; $query .= $where . ' ORDER BY packages.name, packages.arch, packages.version'; $count = dbFetchCell($count_query, $param); if (! isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; } else { $page_number = $_POST['page_number']; } $start = ($page_number - 1) * $results; $full_query = $full_query . $query . " LIMIT $start,$results"; ?> $entry) { $vers = []; $arch = []; $devs = []; foreach ($entry as $variation) { $variation['version'] = str_replace(':', '.', $variation['version']); if (! in_array($variation['version'], $vers) && (empty($ver) || version_compare($variation['version'], $ver, $opt))) { $vers[] = $variation['version']; } if (! in_array($variation['arch'], $arch)) { $arch[] = $variation['arch']; } if (! in_array($variation['hostname'], $devs)) { unset($variation['version']); $devs[] = generate_device_link($variation); } } if (sizeof($arch) > 0 && sizeof($vers) > 0) { ?> 0 && $count != $results) { ?>
Packages
Package Version Arch Device
', $vers); ?> ', $arch); ?> ', $devs); ?>