= '7') {
if (!is_array($config['rancid_configs'])) {
$config['rancid_configs'] = array($config['rancid_configs']);
}
if (isset($config['rancid_configs'][0])) {
foreach ($config['rancid_configs'] as $configs) {
if ($configs[(strlen($configs) - 1)] != '/') {
$configs .= '/';
}
if (is_file($configs.$device['hostname'])) {
$file = $configs.$device['hostname'];
}
}
echo '
';
print_optionbar_start('', '');
echo "
Config » ";
if (!$vars['rev']) {
echo '';
}
else {
echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'));
}
if (function_exists('svn_log')) {
$sep = ' | ';
$svnlogs = svn_log($file, SVN_REVISION_HEAD, null, 8);
$revlist = array();
foreach ($svnlogs as $svnlog) {
echo $sep;
$revlist[] = $svnlog['rev'];
if ($vars['rev'] == $svnlog['rev']) {
echo '';
}
$sep = ' | ';
}
}//end if
print_optionbar_end();
if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) {
list($diff, $errors) = svn_diff($file, ($vars['rev'] - 1), $file, $vars['rev']);
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']) {
$lines = explode("\n", $text);
for ($i = 0; $i < count($lines); $i++) {
if ($lines[$i][0] == '#') {
unset($lines[$i]);
}
}
$text = join("\n", $lines);
}
}
else if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) {
$node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$device['hostname'].'?format=json'), true);
$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/'.$device['os'].'/'.$device['hostname']);
}
if (is_array($node_info)) {
echo '
Sync status: '.$node_info['last']['status'].'
- Node: '.$node_info['name'].'
- IP: '.$node_info['ip'].'
- Model: '.$node_info['model'].'
- Last Sync: '.$node_info['last']['end'].'
';
}
else {
echo '
';
print_error("We couldn't retrieve the device information from Oxidized");
$text = '';
}
}//end if
if (!empty($text)) {
$language = 'ios';
$geshi = new GeSHi($text, $language);
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
$geshi->set_overall_style('color: black;');
// $geshi->set_line_style('color: #999999');
echo $geshi->parse_code();
}
}//end if
$pagetitle[] = 'Config';