Commit version 24.12.13800
This commit is contained in:
@ -6,21 +6,20 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
foreach ($vars as $var => $value)
|
||||
{
|
||||
if ($value != "")
|
||||
{
|
||||
switch ($var)
|
||||
{
|
||||
case 'name':
|
||||
$where .= generate_query_values_and($value, $var);
|
||||
break;
|
||||
$where = [];
|
||||
|
||||
foreach ($vars as $var => $value) {
|
||||
if ($value != "") {
|
||||
switch ($var) {
|
||||
case 'name':
|
||||
$where[] = generate_query_values($value, $var);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo generate_box_open();
|
||||
@ -34,105 +33,80 @@ echo ' </tr>';
|
||||
echo ' </thead>';
|
||||
echo ' <tbody>';
|
||||
|
||||
// Build array of packages - faster than SQL
|
||||
// foreach (dbFetchRows("SELECT * FROM `packages`", $param) as $entry)
|
||||
// {
|
||||
// }
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", $param) as $package)
|
||||
{
|
||||
echo ' <tr>'.PHP_EOL;
|
||||
echo ' <td><a href="'. generate_url($vars, array('name' => $package['name'])).'" class="entity">'.$package['name'].'</a></td>'.PHP_EOL;
|
||||
echo ' <td>';
|
||||
foreach (dbFetchRows("SELECT * FROM `packages` " . generate_where_clause($where, generate_query_permitted_ng('device'))) as $v) {
|
||||
$packages[$v['name']][$v['version']][$v['build']][] = $v;
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `packages` WHERE `name` = ? ORDER BY version, build", array($package['name'])) as $v)
|
||||
{
|
||||
$package['versions'][$v['version']][$v['build']][] = $v;
|
||||
}
|
||||
//$all[]=$v;
|
||||
}
|
||||
|
||||
//r($package);
|
||||
//r($all);
|
||||
|
||||
if (!empty($vars['name']))
|
||||
{
|
||||
echo '<table class="'.OBS_CLASS_TABLE_STRIPED.'">';
|
||||
echo '<tbody>';
|
||||
}
|
||||
ksort($packages);
|
||||
|
||||
foreach ($package['versions'] as $version => $builds)
|
||||
{
|
||||
|
||||
foreach ($packages as $name => $package) {
|
||||
echo ' <tr>' . PHP_EOL;
|
||||
echo ' <td><a href="' . generate_url($vars, ['name' => $name]) . '" class="entity">' . $name . '</a></td>' . PHP_EOL;
|
||||
echo ' <td>';
|
||||
|
||||
$vers = [];
|
||||
$content = "";
|
||||
foreach ($builds as $build => $device_ids)
|
||||
{
|
||||
if ($build) { $dbuild = '-' . $build; } else { $dbuild = ''; }
|
||||
$content .= $version.$dbuild;
|
||||
$table = '';
|
||||
|
||||
foreach ($device_ids as $entry)
|
||||
{
|
||||
$this_device = device_by_id_cache($entry['device_id']);
|
||||
|
||||
switch($entry['arch'])
|
||||
{
|
||||
case "amd64":
|
||||
$entry['arch_class'] = 'label-success';
|
||||
break;
|
||||
case "i386":
|
||||
$entry['arch_class'] = 'label-info';
|
||||
break;
|
||||
default:
|
||||
$entry['arch_class'] = '';
|
||||
}
|
||||
foreach ($package as $version => $builds) {
|
||||
|
||||
switch($entry['manager'])
|
||||
{
|
||||
case "deb":
|
||||
$entry['manager_class'] = 'label-warning';
|
||||
break;
|
||||
case "rpm":
|
||||
$entry['manager_class'] = 'label-important';
|
||||
break;
|
||||
default:
|
||||
$entry['manager_class'] = '';
|
||||
}
|
||||
foreach ($builds as $build => $devices) {
|
||||
if ($build) {
|
||||
$dbuild = '-' . $build;
|
||||
} else {
|
||||
$dbuild = '';
|
||||
}
|
||||
$content .= $version . $dbuild;
|
||||
|
||||
if ($build != '') { $dbuild = '-'.$entry['build']; } else { $dbuild = ''; }
|
||||
foreach ($devices as $entry) {
|
||||
$this_device = ['device_id' => $entry['device_id'], 'hostname' => $GLOBALS['cache']['devices']['hostname_map'][$entry['device_id']]];
|
||||
|
||||
if (!empty($this_device['hostname'])) {
|
||||
if (!empty($vars['name']))
|
||||
{
|
||||
echo '<tr>';
|
||||
echo '<td>'.$entry['version'].$dbuild.'</td><td><span class="label '.$entry['arch_class'].'">'.$entry['arch'].'</span></td>
|
||||
<td><span class="label '.$entry['manager_class'].'">'.$entry['manager'].'</span></td>
|
||||
<td class="entity">'.generate_device_link($this_device).'</td><td></td><td>'.format_si($entry['size']).'</td>';
|
||||
echo '</tr>';
|
||||
} else {
|
||||
$hosts[] = '<span class="entity">' . $this_device['hostname'].'</span>';
|
||||
}
|
||||
$dbuild = !empty($entry['build']) ? '-' . $entry['build'] : '';
|
||||
|
||||
if (!empty($this_device['hostname'])) {
|
||||
if (!empty($vars['name'])) {
|
||||
|
||||
$table .= '<tr>';
|
||||
$table .= '<td>' . $entry['version'] . $dbuild . '</td><td>' . get_type_class_label($entry['arch'], 'arch') . '</td>
|
||||
<td>' . get_type_class_label($entry['manager'], 'pkg') . '</td>
|
||||
<td class="entity">' . generate_device_link($this_device) . '</td><td></td><td>' . format_si($entry['size']) . '</td>';
|
||||
$table .= '</tr>';
|
||||
} else {
|
||||
$hosts[] = '<span class="entity">' . $this_device['hostname'] . '</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (empty($vars['name'])) {
|
||||
$hosts = implode('<br />', $hosts);
|
||||
$vers[] = generate_tooltip_link('', $version . $dbuild, $hosts);
|
||||
}
|
||||
unset($hosts);
|
||||
}
|
||||
|
||||
if (empty($vars['name']))
|
||||
{
|
||||
#if ($first) { $first = false; $middot = ""; } else { $middot = " · "; }
|
||||
$vers[] = generate_tooltip_link('', $version . $dbuild, implode('<br />', $hosts));
|
||||
if (!empty($vars['name'])) {
|
||||
echo '<table class="' . OBS_CLASS_TABLE_STRIPED . '">';
|
||||
echo '<tbody>';
|
||||
echo $table;
|
||||
echo '</tbody>';
|
||||
echo '</table>';
|
||||
} else {
|
||||
echo implode(' - ', $vers);
|
||||
}
|
||||
unset($hosts);
|
||||
}
|
||||
|
||||
if (!empty($vars['name']))
|
||||
{
|
||||
echo '</tbody>';
|
||||
echo '</table>';
|
||||
} else {
|
||||
echo implode(' - ', $vers);
|
||||
}
|
||||
unset($vers);
|
||||
|
||||
unset($vers);
|
||||
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' </tr>'.PHP_EOL;
|
||||
echo ' </td>' . PHP_EOL;
|
||||
echo ' </tr>' . PHP_EOL;
|
||||
}
|
||||
|
||||
echo ' </tbody>';
|
||||
|
Reference in New Issue
Block a user