mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 10:28:13 +00:00
Fix Rancid error messages (#15683)
* Fix Rancid error messages * Fix code style issues.
This commit is contained in:
parent
8e62ad53b4
commit
2ed5afc826
@ -94,7 +94,17 @@ if (Auth::user()->hasGlobalAdmin()) {
|
||||
fclose($errors);
|
||||
}
|
||||
} else {
|
||||
$fh = fopen($rancid_file, 'r') or exit("Can't open file");
|
||||
$fh = fopen($rancid_file, 'r');
|
||||
if ($fh === false) {
|
||||
echo '<div class="alert alert-warning">Error: Cannot open Rancid configuration file for this device.</div>';
|
||||
|
||||
return;
|
||||
}
|
||||
if (filesize($rancid_file) == 0) {
|
||||
echo '<div class="alert alert-warning">Error: Rancid configuration file for this device is empty.</div>';
|
||||
|
||||
return;
|
||||
}
|
||||
$text = fread($fh, filesize($rancid_file));
|
||||
fclose($fh);
|
||||
}
|
||||
@ -110,7 +120,17 @@ if (Auth::user()->hasGlobalAdmin()) {
|
||||
$previous_config = $vars['rev'] . '^';
|
||||
}
|
||||
} else {
|
||||
$fh = fopen($rancid_file, 'r') or exit("Can't open file");
|
||||
$fh = fopen($rancid_file, 'r');
|
||||
if ($fh === false) {
|
||||
echo '<div class="alert alert-warning">Error: Cannot open Rancid configuration file for this device.</div>';
|
||||
|
||||
return;
|
||||
}
|
||||
if (filesize($rancid_file) == 0) {
|
||||
echo '<div class="alert alert-warning">Error: Rancid configuration file for this device is empty.</div>';
|
||||
|
||||
return;
|
||||
}
|
||||
$text = fread($fh, filesize($rancid_file));
|
||||
fclose($fh);
|
||||
}
|
||||
@ -166,7 +186,7 @@ if (Auth::user()->hasGlobalAdmin()) {
|
||||
// populate current_version
|
||||
if (isset($_POST['config'])) {
|
||||
[$oid,$date,$version] = explode('|', htmlspecialchars($_POST['config']));
|
||||
$current_config = ['oid'=>$oid, 'date'=>$date, 'version'=>$version];
|
||||
$current_config = ['oid' => $oid, 'date' => $date, 'version' => $version];
|
||||
} else { // no version selected
|
||||
$current_config = ['oid' => $config_versions[0]['oid'], 'date' => $config_versions[0]['date'], 'version' => $config_total];
|
||||
}
|
||||
@ -175,7 +195,7 @@ if (Auth::user()->hasGlobalAdmin()) {
|
||||
if (isset($_POST['diff'])) { // diff requested
|
||||
[$oid,$date,$version] = explode('|', $_POST['prevconfig']);
|
||||
if (isset($oid) && $oid != $current_config['oid']) {
|
||||
$previous_config = ['oid'=>$oid, 'date'=>$date, 'version'=>$version];
|
||||
$previous_config = ['oid' => $oid, 'date' => $date, 'version' => $version];
|
||||
} elseif ($current_config['version'] != 1) { // assume previous, unless current is first config
|
||||
foreach ($config_versions as $key => $version) {
|
||||
if ($version['oid'] == $current_config['oid']) {
|
||||
|
Loading…
Reference in New Issue
Block a user