mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Remove global $var access functions (#16345)
* Proxmox remove global access functions * Apply fixes from StyleCI --------- Co-authored-by: Tony Murray <murrant@users.noreply.github.com>
This commit is contained in:
@ -16,40 +16,6 @@ use LibreNMS\Enum\ImageFormat;
|
||||
use LibreNMS\Util\Number;
|
||||
use LibreNMS\Util\Rewrite;
|
||||
|
||||
/**
|
||||
* Compare $t with the value of $vars[$v], if that exists
|
||||
*
|
||||
* @param string $v Name of the var to test
|
||||
* @param string $t Value to compare $vars[$v] to
|
||||
* @return bool true, if values are the same, false if $vars[$v]
|
||||
* is unset or values differ
|
||||
*/
|
||||
function var_eq($v, $t)
|
||||
{
|
||||
global $vars;
|
||||
if (isset($vars[$v]) && $vars[$v] == $t) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of $vars[$v], if it exists
|
||||
*
|
||||
* @param string $v Name of the var to get
|
||||
* @return string|bool The value of $vars[$v] if it exists, false if it does not exist
|
||||
*/
|
||||
function var_get($v)
|
||||
{
|
||||
global $vars;
|
||||
if (isset($vars[$v])) {
|
||||
return $vars[$v];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function toner2colour($descr, $percent)
|
||||
{
|
||||
$colour = \LibreNMS\Util\Color::percentage(100 - $percent, null);
|
||||
|
@ -6,25 +6,25 @@ $graphs['proxmox'] = [
|
||||
];
|
||||
|
||||
$pmxcl = dbFetchRows('SELECT DISTINCT(`app_instance`) FROM `applications` WHERE `app_type` = ?', ['proxmox']);
|
||||
$instance = Request::get('instance', $pmxcl[0]['app_instance'] ?? null);
|
||||
|
||||
print_optionbar_start();
|
||||
|
||||
echo "<span style='font-weight: bold;'>Proxmox Clusters</span> » ";
|
||||
|
||||
unset($sep);
|
||||
$sep = '';
|
||||
|
||||
foreach ($pmxcl as $pmxc) {
|
||||
if (isset($sep)) {
|
||||
echo $sep;
|
||||
}
|
||||
echo $sep;
|
||||
|
||||
if (var_eq('instance', $pmxc['app_instance']) || (! isset($vars['instance']) && ! isset($sep))) {
|
||||
$selected = $pmxc['app_instance'] == $instance || (empty($instance) && empty($sep));
|
||||
if ($selected) {
|
||||
echo "<span class='pagemenu-selected'>";
|
||||
}
|
||||
|
||||
echo generate_link(\LibreNMS\Util\StringHelpers::niceCase($pmxc->app_instance), ['page' => 'apps', 'app' => 'proxmox', 'instance' => $pmxc['app_instance']]);
|
||||
|
||||
if (var_eq('instance', $pmxc['app_instance'])) {
|
||||
if ($selected) {
|
||||
echo '</span>';
|
||||
}
|
||||
|
||||
@ -36,12 +36,6 @@ print_optionbar_end();
|
||||
$pagetitle[] = 'Proxmox';
|
||||
$pagetitle[] = $instance;
|
||||
|
||||
if (! isset($vars['instance'])) {
|
||||
$instance = $pmxcl[0]['app_instance'];
|
||||
} else {
|
||||
$instance = var_get('instance');
|
||||
}
|
||||
|
||||
if (isset($vars['vmid'])) {
|
||||
include 'includes/html/pages/apps/proxmox/vm.inc.php';
|
||||
$pagetitle[] = $vars['vmid'];
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$vm = proxmox_vm_info(var_get('vmid'), var_get('instance'));
|
||||
$vm = proxmox_vm_info(Request::get('vmid'), Request::get('instance'));
|
||||
|
||||
$graphs = [
|
||||
'proxmox_traffic' => 'Traffic',
|
||||
@ -23,7 +23,7 @@ foreach ($vm['ports'] as $port) {
|
||||
|
||||
echo '<h3>' . $text . ' ' . $port['port'] . '@' . $vm['description'] . '</h3>';
|
||||
|
||||
echo "<tr bgcolor='$row_colour'><td colspan=5>";
|
||||
echo '<tr><td colspan=5>';
|
||||
|
||||
include 'includes/html/print-graphrow.inc.php';
|
||||
|
||||
|
@ -25,7 +25,7 @@ if (! \LibreNMS\Config::get('enable_proxmox')) {
|
||||
'proxmox_traffic' => 'Traffic',
|
||||
];
|
||||
|
||||
foreach (proxmox_node_vms(var_get('device')) as $nvm) {
|
||||
foreach (proxmox_node_vms(Request::get('device')) as $nvm) {
|
||||
$vm = proxmox_vm_info($nvm['vmid'], $nvm['cluster']);
|
||||
|
||||
foreach ($vm['ports'] as $port) {
|
||||
@ -45,7 +45,7 @@ if (! \LibreNMS\Config::get('enable_proxmox')) {
|
||||
|
||||
echo '<h3>' . $text . ' ' . $port['port'] . '@' . $vm['description'] . '</h3>';
|
||||
|
||||
echo "<tr bgcolor='$row_colour'><td colspan=5>";
|
||||
echo '<tr><td colspan=5>';
|
||||
|
||||
include 'includes/html/print-graphrow.inc.php';
|
||||
|
||||
|
Reference in New Issue
Block a user