mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
PSR2 Cleanup: /html edition
Travis tests for code conformance. Ignore warnings for now. Fixed all errors, left most warnings.
This commit is contained in:
@@ -16,11 +16,9 @@ if (is_admin()) {
|
||||
|
||||
if (is_file($configs.$device['hostname'])) {
|
||||
$file = $configs.$device['hostname'];
|
||||
}
|
||||
elseif (is_file($configs.strtok($device['hostname'], '.'))) { // Strip domain
|
||||
} elseif (is_file($configs.strtok($device['hostname'], '.'))) { // Strip domain
|
||||
$file = $configs.strtok($device['hostname'], '.');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!empty($config['mydomain'])) { // Try with domain name if set
|
||||
if (is_file($configs.$device['hostname'].'.'.$config['mydomain'])) {
|
||||
$file = $configs.$device['hostname'].'.'.$config['mydomain'];
|
||||
@@ -39,8 +37,7 @@ if (is_admin()) {
|
||||
echo '<span class="pagemenu-selected">';
|
||||
echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'));
|
||||
echo '</span>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'));
|
||||
}
|
||||
|
||||
@@ -74,8 +71,7 @@ if (is_admin()) {
|
||||
list($diff, $errors) = svn_diff($file, ($vars['rev'] - 1), $file, $vars['rev']);
|
||||
if (!$diff) {
|
||||
$text = 'No Difference';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$text = '';
|
||||
while (!feof($diff)) {
|
||||
$text .= fread($diff, 8192);
|
||||
@@ -84,8 +80,7 @@ if (is_admin()) {
|
||||
fclose($diff);
|
||||
fclose($errors);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$fh = fopen($file, 'r') or die("Can't open file");
|
||||
$text = fread($fh, filesize($file));
|
||||
fclose($fh);
|
||||
@@ -101,8 +96,7 @@ if (is_admin()) {
|
||||
|
||||
$text = join("\n", $lines);
|
||||
}
|
||||
}
|
||||
else if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) {
|
||||
} elseif ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) {
|
||||
// Try with hostname as set in librenms first
|
||||
$oxidized_hostname = $device['hostname'];
|
||||
// fetch info about the node and then a list of versions for that node
|
||||
@@ -114,8 +108,7 @@ if (is_admin()) {
|
||||
if (strpos($oxidized_hostname, '.') !== false) {
|
||||
// Use short name
|
||||
$oxidized_hostname = strtok($device['hostname'], '.');
|
||||
}
|
||||
elseif($config['mydomain']) {
|
||||
} elseif ($config['mydomain']) {
|
||||
$oxidized_hostname = $device['hostname'].'.'.$config['mydomain'];
|
||||
}
|
||||
|
||||
@@ -137,20 +130,18 @@ if (is_admin()) {
|
||||
if ($config_total > 1) {
|
||||
// populate current_version
|
||||
if (isset($_POST['config'])) {
|
||||
list($oid,$date,$version) = explode('|',mres($_POST['config']));
|
||||
list($oid,$date,$version) = explode('|', mres($_POST['config']));
|
||||
$current_config = array('oid'=>$oid, 'date'=>$date, 'version'=>$version);
|
||||
}
|
||||
else { // no version selected
|
||||
} else { // no version selected
|
||||
$current_config = array('oid'=>$config_versions[0]['oid'], 'date'=>$current_config[0]['date'], 'version'=>$config_total);
|
||||
}
|
||||
|
||||
// populate previous_version
|
||||
if (isset($_POST['diff'])) { // diff requested
|
||||
list($oid,$date,$version) = explode('|',mres($_POST['prevconfig']));
|
||||
list($oid,$date,$version) = explode('|', mres($_POST['prevconfig']));
|
||||
if (isset($oid) && $oid != $current_config['oid']) {
|
||||
$previous_config = array('oid'=>$oid, 'date'=>$date, 'version'=>$version);
|
||||
}
|
||||
else if ($current_config['version'] != 1) { // assume previous, unless current is first config
|
||||
} elseif ($current_config['version'] != 1) { // assume previous, unless current is first config
|
||||
foreach ($config_versions as $key => $version) {
|
||||
if ($version['oid'] == $current_config['oid']) {
|
||||
$prev_key = $key + 1;
|
||||
@@ -160,8 +151,7 @@ if (is_admin()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
print_error('No previous version, please select a different version.');
|
||||
}
|
||||
}
|
||||
@@ -178,10 +168,8 @@ if (is_admin()) {
|
||||
// fetch current_version
|
||||
$text = file_get_contents($config['oxidized']['url'].'/node/version/view?node='.$oxidized_hostname.'&group='.(!empty($node_info['group']) ? $node_info['group'] : '').'&oid='.$current_config['oid'].'&date='.urlencode($current_config['date']).'&num='.$current_config['version'].'&format=text');
|
||||
}
|
||||
}
|
||||
else { // just fetch the only version
|
||||
} else { // just fetch the only version
|
||||
$text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.(!empty($node_info['group']) ? $node_info['group'].'/' : '').$oxidized_hostname);
|
||||
|
||||
}
|
||||
|
||||
if (is_array($node_info) || $config_total > 1) {
|
||||
@@ -221,15 +209,12 @@ if (is_admin()) {
|
||||
if ($current_config['oid'] == $version['oid']) {
|
||||
if (isset($previous_config)) {
|
||||
echo 'selected>+';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo 'selected>*';
|
||||
}
|
||||
}
|
||||
else if ($previous_config['oid'] == $version['oid']) {
|
||||
} elseif ($previous_config['oid'] == $version['oid']) {
|
||||
echo '> -';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo '> ';
|
||||
}
|
||||
echo $i.' :: '.$version['date'].'</option>';
|
||||
@@ -243,7 +228,7 @@ if (is_admin()) {
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-6">
|
||||
<input type="hidden" name="prevconfig" value="';
|
||||
echo implode('|',$current_config);
|
||||
echo implode('|', $current_config);
|
||||
echo '">
|
||||
<button type="submit" class="btn btn-primary btn-sm" name="show">Show version</button>
|
||||
<button type="submit" class="btn btn-primary btn-sm" name="diff">Show diff</button>
|
||||
@@ -255,8 +240,7 @@ if (is_admin()) {
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo '<br />';
|
||||
print_error("We couldn't retrieve the device information from Oxidized");
|
||||
$text = '';
|
||||
|
Reference in New Issue
Block a user