From 89f596fdbb8eca08fa3eb5077f908019eb7f784b Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 5 Feb 2016 14:29:10 -0600 Subject: [PATCH] Fix oxidized versioning + groups Consilidate config fetching rather than having two fetches with the first always failing when the device has a group. --- html/pages/device/showconfig.inc.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index 9e5d0b1a62..ed9219cf23 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -106,19 +106,13 @@ if ($_SESSION['userlevel'] >= '7') { $node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$device['hostname'].'?format=json'), true); if ($config['oxidized']['features']['versioning'] === true && isset($_POST['config'])) { list($oid,$date,$version) = explode('|',mres($_POST['config'])); - $text = file_get_contents($config['oxidized']['url'].'/node/version/view?node='.$device['hostname'].'&group=&oid='.$oid.'&date='.urlencode($date).'&num='.$version.'&format=text'); - if ($text == 'node not found') { - $text = file_get_contents($config['oxidized']['url'].'/node/version/view?node='.$device['hostname'].'&group='.(is_array($node_info) ? $node_info['group'] : $device['os']).'&oid='.$oid.'&date='.urlencode($date).'&num='.$version.'&format=text'); - } + $text = file_get_contents($config['oxidized']['url'].'/node/version/view?node='.$device['hostname'].'&group='.(!empty($node_info['group']) ? $node_info['group'] : '').'&oid='.$oid.'&date='.urlencode($date).'&num='.$version.'&format=text'); } else { - $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['hostname']); - if ($text == 'node not found') { - $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.(is_array($node_info) ? $node_info['group'] : $device['os']).'/'.$device['hostname']); - } + $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.(!empty($node_info['group']) ? $node_info['group'].'/' : '').$device['hostname']); } if ($config['oxidized']['features']['versioning'] === true) { - $config_versions = json_decode(file_get_contents($config['oxidized']['url'].'/node/version?node_full='.$device['hostname'].'&format=json'), true); + $config_versions = json_decode(file_get_contents($config['oxidized']['url'].'/node/version?node_full='.(!empty($node_info['group']) ? $node_info['group'].'/' : '').$device['hostname'].'&format=json'), true); } if (is_array($node_info) || is_array($config_versions)) {