mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
- Added SVN support for rancid. You now see a diff between previous revisions.
git-svn-id: http://www.observium.org/svn/observer/trunk@2396 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@ -4,6 +4,7 @@ include("includes/geshi/geshi.php");
|
||||
|
||||
if ($_SESSION['userlevel'] >= "7")
|
||||
{
|
||||
|
||||
if (!is_array($config['rancid_configs'])) { $config['rancid_configs'] = array($config['rancid_configs']); }
|
||||
|
||||
foreach ($config['rancid_configs'] as $configs)
|
||||
@ -11,10 +12,59 @@ if ($_SESSION['userlevel'] >= "7")
|
||||
if ($configs[strlen($configs)-1] != '/') { $configs .= '/'; }
|
||||
if (is_file($configs . $device['hostname'])) { $file = $configs . $device['hostname']; }
|
||||
}
|
||||
|
||||
echo('<div style="clear: both;">');
|
||||
|
||||
$fh = fopen($file, 'r') or die("Can't open file");
|
||||
$text = fread($fh, filesize($file));
|
||||
fclose($fh);
|
||||
print_optionbar_start('', '');
|
||||
|
||||
echo("<span style='font-weight: bold;'>Config</span> » ");
|
||||
|
||||
if (!$_GET['opta']) {
|
||||
echo('<span class="pagemenu-selected">');
|
||||
echo("<a href='device/".$device['device_id']."/showconfig/'> Latest</a>");
|
||||
echo("</span>");
|
||||
} else {
|
||||
echo("<a href='device/".$device['device_id']."/showconfig/'> Latest</a>");
|
||||
}
|
||||
|
||||
if (function_exists('svn_log')) {
|
||||
|
||||
$sep = " | ";
|
||||
$svnlogs = svn_log($file, SVN_REVISION_HEAD, NULL, 10);
|
||||
$revlist = array();
|
||||
|
||||
foreach ($svnlogs as $svnlog) {
|
||||
|
||||
echo($sep);
|
||||
$revlist[] = $svnlog["rev"];
|
||||
|
||||
if ($_GET['opta'] == $svnlog["rev"]) { echo('<span class="pagemenu-selected">'); }
|
||||
|
||||
echo("<a href='device/".$device['device_id']."/showconfig/" . $svnlog["rev"] . "/'> r" . $svnlog["rev"] ."</a>");
|
||||
if ($_GET['opta'] == $svnlog["rev"]) { echo("</span>"); }
|
||||
|
||||
$sep = " | ";
|
||||
}
|
||||
}
|
||||
|
||||
print_optionbar_end();
|
||||
|
||||
if (function_exists('svn_log') && in_array($_GET['opta'], $revlist)) {
|
||||
list($diff, $errors) = svn_diff($file, $_GET['opta']-1, $file, $_GET['opta']);
|
||||
if (!$diff) {
|
||||
$text = "No Difference";
|
||||
} else {
|
||||
$text = "";
|
||||
while (!feof($diff)) { $text .= fread($diff, 8192); }
|
||||
fclose($diff);
|
||||
fclose($errors);
|
||||
}
|
||||
|
||||
} else {
|
||||
$fh = fopen($file, 'r') or die("Can't open file");
|
||||
$text = fread($fh, filesize($file));
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
if ($config['rancid_ignorecomments'])
|
||||
{
|
||||
@ -33,5 +83,4 @@ if ($_SESSION['userlevel'] >= "7")
|
||||
#$geshi->set_line_style('color: #999999');
|
||||
echo($geshi->parse_code());
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user