diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..018dd33
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+htdocs/lg_config.php
diff --git a/htdocs/.gitignore b/htdocs/.gitignore
deleted file mode 100644
index ed222e1..0000000
--- a/htdocs/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-lg_config.php
diff --git a/htdocs/favicon.ico b/htdocs/favicon.ico
old mode 100644
new mode 100755
diff --git a/htdocs/index.php b/htdocs/index.php
old mode 100644
new mode 100755
index 3392394..0ef73b2
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -1,5 +1,7 @@
+
* HSDN PHP Looking Glass version 1.2.22b
*
* General Features:
@@ -63,13 +65,15 @@
'sshprivatekeypath' => '',
'sshpwdcommand' => 'plink',
'plink' => '/usr/local/bin/plink',
- 'sshpass' => '/usr/bin/sshpass',
+ 'sshpass' => '/usr/bin/sshpass',
'ssh' => '/usr/bin/ssh',
- 'ipwhois' => 'http://noc.hsdn.org/whois/',
- 'aswhois' => 'http://noc.hsdn.org/aswhois/',
+ 'ipwhois' => 'https://stat.ripe.net/',
+ 'aswhois' => 'https://stat.ripe.net/',
'routers' => array(),
);
+$anunciadas;
+
@ob_end_flush();
if (file_exists('lg_config.php') AND is_readable('lg_config.php'))
@@ -80,7 +84,17 @@
$router = isset($_REQUEST['router']) ? trim($_REQUEST['router']) : FALSE;
$protocol = isset($_REQUEST['protocol']) ? trim($_REQUEST['protocol']) : FALSE;
$command = isset($_REQUEST['command']) ? trim($_REQUEST['command']) : FALSE;
-$query = isset($_REQUEST['query']) ? trim($_REQUEST['query']) : FALSE;
+$query = isset($_REQUEST['query']) ? $_REQUEST['query'] : array(); // Inicializa como um array vazio se não houver 'query'
+
+// Verifica se 'query' é um array e trata cada elemento
+if (is_array($query)) {
+ foreach ($query as $key => $value) {
+ $query[$key] = trim($value); // Remove espaços em branco de cada elemento do array
+ }
+} else {
+ $query = trim($_REQUEST['query']); // Transforma em array único se não for array
+}
+
if ($command != 'graph' OR !isset($_REQUEST['render']) OR !isset($_CONFIG['routers'][$router]))
{
@@ -117,18 +131,8 @@
.legend { font-size: 12px; margin: auto; }
//-->
-
-
+
@@ -190,13 +194,13 @@ function load() {
(
'ipv4' => array
(
- 'bgp' => '/ip route print detail where bgp dst-address=%s',
- 'bgp-within' => '/ip route print detail where bgp dst-address in %s',
+ 'bgp' => '/ip route print detail where bgp dst-address in %s',
+ 'bgp-within' => '/ip route print detail where bgp dst-address=%s',
'advertised-routes' => '/routing bgp advertisements print peer=%s',
'routes' => '/ip route print where gateway=%s',
'summary' => '/routing bgp peer print status where address-families=ip',
'ping' => '/ping count=5 size=56 %s',
- 'trace' => '/tool traceroute %s size=60 count=1',
+ 'trace' => '/tool traceroute %s size=60 count=1',
),
'ipv6' => array
(
@@ -257,21 +261,25 @@ function load() {
(
'ipv4' => array
(
- 'bgp' => 'display bgp routing-table %s',
- 'advertised-routes' => 'display bgp routing-table peer %s advertised-routes',
- 'bgp-within' => 'display bgp routing-table community | include %s',
- 'received-routes' => 'display bgp routing-table peer %s received-routes',
- 'routes' => 'display bgp routing-table peer %s received-routes active',
- 'summary' => 'display bgp peer',
+ 'bgp' => 'display bgp routing-table %s | no-more',
+ 'advertised-routes' => 'display bgp routing-table peer %s advertised-routes | no-more',
+ 'advertised-communities' => 'display bgp routing-table peer %s advertised-routes %s community-list | no-more',
+ 'graph' => 'display bgp routing-table %s as-path | no-more',
+ 'bgp-within' => 'display bgp routing-table %s as-path | no-more',
+ 'received-routes' => 'display bgp routing-table peer %s received-routes | no-more',
+ 'routes' => 'display bgp routing-table peer %s received-routes active | no-more',
+ 'summary' => 'display bgp peer | no-more',
'ping' => 'ping %s',
'trace' => 'tracert %s',
),
'ipv6' => array
(
'bgp' => 'display bgp ipv6 routing-table %s',
- 'advertised-routes' => 'display bgp ipv6 routing-table peer %s advertised-routes',
- 'received-routes' => 'display bgp ipv6 routing-table peer %s received-routes',
- 'routes' => 'display bgp ipv6 routing-table peer %s received-routes active',
+ 'graph' => 'display bgp ipv6 routing-table %s as-path | no-more',
+ 'advertised-routes' => 'display bgp ipv6 routing-table peer %s advertised-routes | no-more',
+ 'advertised-communities' => 'display bgp ipv6 routing-table peer %s advertised-routes %s community-list | no-more',
+ 'received-routes' => 'display bgp ipv6 routing-table peer %s received-routes | no-more',
+ 'routes' => 'display bgp ipv6 routing-table peer %s received-routes active | no-more',
'summary' => 'display bgp ipv6 peer',
'ping' => 'ping ipv6 %s',
'trace' => 'tracert ipv6 %s',
@@ -307,13 +315,13 @@ function load() {
$os = $_CONFIG['routers'][$router]['os'];
- if ($command == 'graph' AND isset($queries[$os][$protocol]['bgp']))
- {
+ if ($command == 'graph' AND isset($queries[$os][$protocol]['graph'])){
+ $exec = $queries[$os][$protocol]['graph'];
+ }else if ($command == 'graph' AND isset($queries[$os][$protocol]['bgp'])){
$exec = $queries[$os][$protocol]['bgp'];
- }
- else
- {
+ }else{
$exec = $queries[$os][$protocol][$command];
+ // var_dump($query);
}
if (strpos($exec, '%s') !== FALSE)
@@ -325,6 +333,16 @@ function load() {
$query = get_host($query);
}
}
+
+ $num_placeholders = substr_count($exec, '%s');
+ if ($num_placeholders > 1 && is_array($query)) {
+ if ($num_placeholders != count($query)) {
+ // Handle error: the number of placeholders and parameters do not match
+ echo "Número de parâmetros não corresponde ao número de placeholders.";
+ } else {
+ $exec = vsprintf(str_replace('%s', '%s', $exec), array_map('escapeshellcmd', $query));
+ }
+ }
if ($query AND ($command == 'bgp' OR $command == 'bgp-within' OR $command == 'graph') AND ($os == 'mikrotik' OR ($protocol == 'ipv6' AND $os == 'ios')))
{
@@ -352,6 +370,14 @@ function load() {
}
}
}
+
+ if ($query AND ($command == 'bgp' OR $command == 'bgp-within' OR $command == 'graph') AND $os == 'huawei')
+ {
+ if (buscabarra($query,"/",1))
+ {
+ $query = str_replace("/"," ",$query);
+ }
+ }
$exec = sprintf($exec, escapeshellcmd($query));
@@ -513,12 +539,8 @@ function load() {
-
-
-
-
+
+
";
+ $titles = "
+ Network |
+ NextHop |
+ MED |
+ LocPrf |
+ Path |
+ Comunidades |
+
";
+ echo $titles;
+
+ foreach($t as $linha){
+ if(strlen($linha) < 20) continue;
+ if(preg_match("/^Info: The max number of VTY /i",$linha)) continue;
+
+ $linha = preg_replace('/\\s\\s+/', ' ', $linha);
+ $linha = explode(' ', $linha);
+
+ $Network = $linha[2];
+ $NextHop = $linha[3];
+ $MED = $linha[4];
+ $LocPrf = $linha[5];
+ $Path = $linha[6];
+
+ $Network = preg_replace(['/\s\s+/', '/\//'], ' ', $Network);
+
+ $trupa = "
+ $Network |
+ $NextHop |
+ $MED |
+ $LocPrf |
+ $Path |
+ ".link_command2("advertised-communities", array($query, $Network ), $name = 'Comunidades', $return_uri = FALSE)." |
+
";
+ echo $trupa;
+ // var_dump($linha);
+ }
+
+ echo "";
+
+ }
+ }else if($os == "huawei" and $command == "advertised-routes" and $protocol == "ipv6"){
+ // echo "Pulei";
+ $fp = @popen('echo n | '.$ssh_path.' '.implode(' ', $params).' '.$exec, 'r');
+ if ($fp) {
+ $output = '';
+ while (!feof($fp)) {
+ $output .= fgets($fp, 1024);
+ }
+ pclose($fp);
+
+ // Remove tabulações, quebras de linha e excessos de espaços
+ $output = preg_replace('/[\t\r\n]+/', ' ', $output);
+ $output = preg_replace('/\s{2,}/', ' ', $output);
+
+
+
+ // Padrões de regex para capturar os campos relevantes
+ $patterns = [
+ 'Network' => '/Network\s*:\s*(.*?)\s*PrefixLen\s*:\s*(\d+)/',
+ 'NextHop' => '/NextHop\s*:\s*(.*?)\s*LocPrf\s*:\s*(\d*)/',
+ 'MED' => '/MED\s*:\s*(\d+)/',
+ 'PathOgn' => '/Ogn\s*:\s*(\d+[a-zA-Z]?)\b/'
+ ];
+
+ // Inicializa a tabela HTML
+ echo "";
+ echo "
+ Network |
+ NextHop |
+ MED |
+ LocPrf |
+ Path |
+ Comunidades |
+
";
+
+ // Encontra todas as correspondências usando os padrões de regex
+ foreach ($patterns as $key => $pattern) {
+ preg_match_all($pattern, $output, $matches[$key]);
+
+ }
+ // var_dump($matches);
+ // Itera sobre as correspondências encontradas
+ $numEntries = count($matches['Network'][1]); // Número de entradas de rota
+
+ for ($i = 0; $i < $numEntries; $i++) {
+ // Extrai os campos relevantes de cada entrada
+ $PrefixLen = isset($matches['Network'][2][$i]) ? $matches['Network'][2][$i] : '';
+ $Network = isset($matches['Network'][1][$i]) ? $matches['Network'][1][$i] . ' ' . $PrefixLen : '';
+ $NextHop = isset($matches['NextHop'][1][$i]) ? $matches['NextHop'][1][$i] : '';
+ $LocPrf = isset($matches['NextHop'][2][$i]) ? $matches['NextHop'][2][$i] : '';
+ $MED = isset($matches['MED'][1][$i]) ? $matches['MED'][1][$i] : '';
+ $Path = isset($matches['PathOgn'][1][$i]) ? $matches['PathOgn'][1][$i] : '';
+
+ // Ajusta o formato do Network (removendo espaços duplos e substituindo '/' por espaço)
+ $Network = preg_replace('/\s\s+/', ' ', $Network);
+ $Network = str_replace('/', ' ', $Network);
+
+ // Cria a linha da tabela HTML
+ $row = "
+ $Network |
+ $NextHop |
+ $MED |
+ $LocPrf |
+ $Path |
+ " . link_command2("advertised-communities", array($query, $Network), 'Comunidades', FALSE) . " |
+
";
+
+ // Exibe a linha na tabela
+ echo $row;
+ }
+ // Fecha a tabela HTML
+ echo "
";
+ }
+ }else
if ($fp = @popen('echo n | '.$ssh_path.' '.implode(' ', $params).' '.$exec, 'r'))
{
+ // echo 'echo n | '.$ssh_path.' '.implode(' ', $params).' '.$exec;
+ // var_dump(shell_exec($ssh_path.' '.implode(' ', $params).' '.$exec));
while (!feof($fp))
{
if (!$output = fgets($fp, 1024))
{
continue;
}
-
- $line = !$return_buffer ? parse_out($output, TRUE) : $output;
+
+ // não quebra as linhas no sumário huawei
+ if (!($os == 'huawei' and (preg_match('/^display bgp peer/i', $exec) or preg_match('/^display bgp ipv6 peer/i', $exec)))){
+
+ $line = !$return_buffer ? parse_out($output, TRUE) : $output;
+
+ }
if ($line === TRUE)
{
@@ -773,7 +940,6 @@ function process($url, $exec, $return_buffer = FALSE)
$line = $output;
}
}
-
pclose($fp);
}
@@ -975,9 +1141,168 @@ function process($url, $exec, $return_buffer = FALSE)
*/
function parse_out($output, $check = FALSE)
{
- global $_CONFIG, $router, $protocol, $os, $command, $exec, $query, $index, $lastip, $best, $count, $str_in, $ros;
-
+ global $anunciadas, $_CONFIG, $router, $protocol, $os, $command, $exec, $query, $index, $lastip, $best, $count, $str_in, $ros;
+
+ // Huawei
+// if(preg_match('/advertised-routes/i', $exec)){
+// $output = str_replace("\r\n", "", $output);
+// if (strlen($output) < 20) return;
+// if (preg_match("/^Info: The max number of VTY /i",$output)) return;
+// $output = preg_replace('/\\s\\s+/', ' ', $output);
+// if (preg_match("/^ The current login time /i",$output)) return;
+// if (preg_match("/^ Status codes: /i",$output)) return;
+// if (preg_match("/^ h - history, /i",$output)) return;
+// if (preg_match("/^ Network NextHop MED LocPrf PrefVal /i",$output)) return;
+// if (preg_match("/^ BGP Local router ID is /i",$output)) return;
+// if (preg_match("/^ Origin /i",$output)) return;
+// if (preg_match("/RPKI/i",$output)) return;
+// if (preg_match("/^ Total Number of Routes: /i",$output)) return;
+//
+// $item = explode(" ",$output);
+//
+// $titles = "
+// Network |
+// NextHop |
+// Path |
+// Comunidades |
+//
";
+// // echo $titles;
+//
+// $Network = $item[2];
+// $NextHop = $item[3];
+// $Path = $item[6];
+// $Comunidades = "";
+//
+// $trupa .= "
+// $Network |
+// $NextHop |
+// $Path |
+// $Comunidades |
+//
";
+// // echo $trupa;
+//
+// $tabela .= "";
+// // $tabela .= $titles;
+// $tabela .= $trupa;
+// $tabela .= "
";
+// return $tabela;
+// }
+
+
+ if (preg_match('/^display bgp peer/i', $exec) or preg_match('/^display bgp ipv6 peer/i', $exec))
+ {
+ $output = str_replace("\r", "", $output);
+ if(sizeof(explode("through SSH.",$output)) > 1){
+ $output = explode("through SSH.",$output)[1];
+ }
+ $ooo = explode("\n",$output);
+ foreach($ooo as $v){
+ if (strlen($v) < 20) continue;
+ if (preg_match("/^Info: The max number of VTY /i",$v)) continue;
+ $v = preg_replace('/\\s\\s+/', ' ', $v);
+ if (preg_match("/^ The current login time /i",$v)) continue;
+
+ // var_dump($v);
+ if (preg_match("/^ BGP local router /i",$v)){
+ $head['ID'] = explode(": ",$v)[1];
+ continue;
+ }
+ if (preg_match("/^ Local AS /i",$v)){
+ $head['ASN'] = explode(": ",$v)[1];
+ continue;
+ }
+ if (preg_match("/^ Total number/i",$v)){
+ $head['peers'] = explode(" ",$v)[6];
+ $head['up'] = explode(" ",$v)[12];
+ continue;
+ }
+ if (preg_match("/Peer/i",$v)){
+ continue;
+ }
+
+ $resumo = "Router ID: $head[ID] from ASN: $head[ASN]
Peering: $head[up] up of $head[peers] total";
+
+ // A partir daqui todos os itens avaliados serão um peer a compor a tabela
+ $v = explode(" ",$v);
+ $peer = $v[1];
+ $asn = $v[3];
+ $recebido = $v[4];
+ $enviado = $v[5];
+ $uptime = $v[7];
+ $status = $v[8];
+ $prefixos = $v[9];
+ $OutQ = $v[6];
+ $asinfo = get_asinfo("AS".$asn);
+ $estilo = $status == "Established" ? 'style="background-color: bisque;"' : "";
+ $pesquisar = $status == "Established" ? link_command("advertised-routes", $peer, $name = 'Anuncios', $return_uri = FALSE) : "";
+ $pesquisar_recebidas = $prefixos > 0 ? link_command("received-routes", $peer, $name = $prefixos, $return_uri = FALSE) : "$prefixos";
+
+ if(sizeof(explode("h",$uptime))>1){
+ $horasb = explode("h",$uptime)[0];
+ $dias = intval($horasb/24);
+ $horas = ($horasb/24-$dias)*24;
+ $horas = $horasb%24;
+ $minutos = str_replace("m",":",explode("h",$uptime)[1]);
+ $segundos = '00';
+
+ $uptime = $dias."d ".$horas.":".$minutos.$segundos;
+ }else{
+ $dias = 0;
+ $horas = explode(":",$uptime)[0];
+ $minutos = explode(":",$uptime)[1]."m";
+ $segundos = explode(":",$uptime)[2];
+
+ $uptime = $dias."d ".$uptime;
+ }
+
+
+ $trupa .= "
+ $peer |
+ ".link_as($asn)." |
+ ".$asinfo['asname']." ".$asinfo['description']." |
+ $pesquisar |
+ $recebido |
+ $enviado |
+ $status |
+ $uptime |
+ $pesquisar_recebidas |
+ $OutQ |
+
";
+
+ // $newout[] = $v;
+ }
+ $output = null;
+ $output['head'] = $head;
+ $output['tail'] = $newout;
+ $titles = "
+ Peer |
+ ASN |
+ Nome |
+ Anuncios |
+ Msg Recebidas |
+ Msg Enviadas |
+ Status |
+ Uptime |
+ Rotas |
+ OutQ |
+
";
+
+ $tabela .= $resumo;
+ $tabela .= "";
+ $tabela .= $titles;
+ $tabela .= $trupa;
+ $tabela .= "
";
+ return $tabela;
+ }
+
$output = str_replace("\r\n", "\n", $output);
+ if ($os == 'huawei'){
+
+ if (preg_match("/^Info: The max number of VTY /i",$output)) return;
+ if (preg_match("/The current login time is /i",$output)) return;
+ if (preg_match("/The last login time is /i",$output)) return;
+ if (strlen($output) < 5) return;
+ }
// MikroTik
if (preg_match("/^\/(ip|ipv6) route print detail/i", $exec) AND $os == 'mikrotik')
@@ -2095,7 +2420,7 @@ function ($matches) {
return $output;
}
-
+
return $output;
}
@@ -2104,13 +2429,13 @@ function ($matches) {
*/
function parse_bgp_path($output)
{
- global $os, $exec, $query, $count;
+ global $os, $exec, $query, $count, $_CONFIG;
$best = FALSE;
$pathes = array();
$output = str_replace("\r\n", "\n", $output);
-
+
// MikroTik
if (preg_match("/^\/(ip|ipv6) route print detail/i", $exec) AND $os == 'mikrotik')
{
@@ -2123,24 +2448,111 @@ function parse_bgp_path($output)
$summary_parts = explode("\n\n" , $output_parts[3]);
+
foreach ($summary_parts as $i => $summary_part)
{
$data_exp = explode(' ', trim($summary_part), 3);
-
+
if (strpos($data_exp[1], 'A') !== FALSE)
{
$best = $i;
+
}
if (preg_match("/bgp-as-path=\"([^\"]+)\"/", $summary_part, $exp))
{
+
if ($path = parse_as_path($exp[1]))
{
$pathes[] = $path;
}
}
}
+
+ return array
+ (
+ 'best' => $best,
+ 'pathes' => $pathes
+ );
+ }
+
+ // Huawei
+ if ($os == 'huawei')
+ {
+ if(preg_match("/as-path/i", $exec)){
+
+
+ $output_parts = explode("BGP routing table entry information of " , trim($output));
+ // Aqui eu finalmente tenho os blocos de informações separados por path
+ if (!isset($output_parts[0]))
+ {
+ return FALSE;
+ }
+
+
+ $summary_parts = $output_parts;
+
+
+ foreach ($summary_parts as $i => $summary_part)
+ {
+
+ $summary_part = explode("AS-path " , trim($summary_part))[1];
+ // $summary_part = explode("Info: The max number of VTY users");
+
+
+ if(preg_match("/best/i", $summary_part)){
+ // Se esta for a melhor rota, sinaliza ela
+ $best = $i;
+ }
+
+ $summary_part = explode("\n" , trim($summary_part))[0];
+ $data_exp = str_replace(' ', ',',trim($summary_part));
+ if($data_exp == "") continue;
+ if($data_exp == "Nil") $data_exp = $_CONFIG['asn'];
+
+ if ($path = parse_as_path($data_exp))
+ {
+ $pathes[] = $path;
+ }
+ }
+ $best = getBestHuawei();
+ }else
+ {
+ $output_parts = explode("BGP local router ID :" , trim($output), 4);
+ $output_parts = explode("Paths:" , trim($output_parts[1]), 2);
+ $output_parts = explode("BGP routing table entry information of " , trim($output_parts[1]),2);
+ // Aqui eu finalmente tenho os blocos de informações separados por path
+ $output_parts = explode("\n\n" , trim($output_parts[1]));
+ if (!isset($output_parts[0]))
+ {
+ return FALSE;
+ }
+
+
+ $summary_parts = $output_parts;
+
+ foreach ($summary_parts as $i => $summary_part)
+ {
+
+ $summary_part = explode("AS-path " , trim($summary_part));
+
+ if(preg_match("/best/i", $summary_part[1])){
+ // Se esta for a melhor rota, sinaliza ela
+ $best = $i;
+ }
+
+ $summary_part = explode("," , trim($summary_part[1]))[0];
+ $data_exp = str_replace(' ', ',',trim($summary_part));
+
+
+ if ($path = parse_as_path($data_exp))
+ {
+ $pathes[] = $path;
+ }
+ }
+ }
+
return array
(
'best' => $best,
@@ -2148,6 +2560,7 @@ function parse_bgp_path($output)
);
}
+
// JunOS
if (preg_match("/^show route protocol bgp .* terse/i", $exec))
{
@@ -2307,7 +2720,9 @@ function parse_as_path($line)
$return[] = 'AS'.$asn;
}
}
-
+
+ return $return;
+ # Se remover as duplicatas os prepends não serão sinalizados no mapa
return array_unique($return);
}
@@ -2384,6 +2799,28 @@ function link_command($command, $query, $name = '', $return_uri = FALSE)
return ''.$name.'';
}
+function link_command2($command, $queries, $name = '', $return_uri = FALSE)
+{
+ global $router, $protocol;
+
+ if ($name == '') {
+ $name = implode(' ', $queries);
+ }
+
+ $queryString = implode('&query[]=', $queries);
+ $uri = '?router='.$router.
+ '&protocol='.$protocol.
+ '&command='.$command.
+ '&query[]='.$queryString;
+
+ if ($return_uri) {
+ return $uri;
+ }
+
+ return ''.$name.'';
+}
+
+
/**
* Link to AS community
*/
@@ -2482,7 +2919,6 @@ function get_path_graph($router, $query, $as_pathes, $as_best_path, $format = 's
$font_size = 9; // default font size
$graph = new Image_GraphViz();
-
$graph->addNode($router, array
(
'label' => $_CONFIG['routers'][$router]['description'],
@@ -2567,7 +3003,7 @@ function get_path_graph($router, $query, $as_pathes, $as_best_path, $format = 's
foreach ($as_list as $as_id)
{
- $color = isset($as_peer_list[$as_id]) ? ($as_peer_list[$as_id] ? '#CCFFCC' : '#CCCCFF') : 'white';
+ $color = isset($as_peer_list[$as_id]) ? ($as_peer_list[$as_id] ? '#CCFFCC' : '#CCCCFF') : '#D3D3D3';
$asinfo = get_asinfo($as_id);
@@ -2575,7 +3011,8 @@ function get_path_graph($router, $query, $as_pathes, $as_best_path, $format = 's
(
'URL' => $_CONFIG['aswhois'].$as_id,
'target' => '_blank',
- 'label' => isset($asinfo['description']) ? $as_id."\n".$asinfo['description'] : $as_id,
+ 'shape' => 'rect',
+ 'label' => isset($asinfo['description']) ? $as_id."\n".$asinfo['asname']."\n".$asinfo['description'] : $as_id,
'style' => 'filled',
'fillcolor' => $color,
'fontsize' => $font_size
@@ -2642,6 +3079,7 @@ function get_path_graph($router, $query, $as_pathes, $as_best_path, $format = 's
*/
function get_blank_graph($string, $format = 'svg')
{
+
$graph = new Image_GraphViz();
$graph->addNode('error', array
@@ -2843,6 +3281,42 @@ function get_ptr($ip)
return reset($ptr);
}
+function buscabarra($haystack, $needle, $nth) {
+ $count = 0;
+ $pos = -1;
+ do {
+ $pos = strpos($haystack, $needle, $pos + 1);
+ $count++;
+ } while ($pos !== false && $count < $nth);
+ return $pos;
+}
+
+function getBestHuawei() {
+ global $url,$os,$protocol, $queries,$query;
+ $exe = str_replace("%s",$query,$queries[$os][$protocol]['bgp']);
+ $test = process($url, $exe, TRUE);
+
+ $ddd = explode("BGP local router ID :" , trim($test), 4);
+ $ddd = explode("Paths:" , trim($ddd[1]), 2);
+ $ddd = explode("BGP routing table entry information of " , trim($ddd[1]),2);
+ // Aqui eu finalmente tenho os blocos de informações separados por path
+ $ddd = explode("\n\n" , trim($ddd[1]));
+
+ $eee = $ddd;
+ foreach ($eee as $i => $sp)
+ {
+
+ $sp = explode("AS-path " , trim($sp));
+
+ if(preg_match("/best/i", $sp[1])){
+ // Se esta for a melhor rota, sinaliza ela
+ $best = $i;
+ }
+ }
+ return $best;
+}
+
+
/**
* Group router list
*/
@@ -3276,4 +3750,4 @@ public function waitPrompt()
} // class Telnet
-/* End of file */
+/* End of file */
\ No newline at end of file
diff --git a/htdocs/lg_config.php.example b/htdocs/lg_config.php.example
old mode 100644
new mode 100755
index 40afe22..c7aa6d3
--- a/htdocs/lg_config.php.example
+++ b/htdocs/lg_config.php.example
@@ -1,5 +1,4 @@
- array
- (
- 'url' => 'telnet://route-views.optus.net.au:23',
- 'pingtraceurl' => FALSE,
- 'description' => 'Example Router 1',
- 'group' => 'AS12345',
- 'ipv6' => TRUE,
- 'os' => 'ios',
- ),
-
- 'example2' => array
- (
- 'url' => 'ssh://route-server.eastlink.ca:23',
- 'pingtraceurl' => FALSE,
- 'description' => 'Example Router 2',
- 'group' => 'AS12345',
- 'ipv6' => TRUE,
- 'os' => 'ios',
- ),
-
- 'example3' => array
- (
- 'url' => 'ssh://user@device.local',
- 'pingtraceurl' => FALSE,
- 'description' => 'Example Router 3',
- 'group' => 'AS12345',
- 'ipv6' => TRUE,
- 'os' => 'mikrotik',
- ),
-
- 'example4' => array
- (
- 'url' => 'ssh://user@device.local',
- 'sshauthtype' => 'privatekey',
- 'pingtraceurl' => FALSE,
- 'description' => 'Example Router 4',
- 'group' => 'AS12345',
- 'ipv6' => TRUE,
- 'os' => 'mikrotik',
- ),
+ 'ne40' => array
+ (
+ 'url' => 'ssh://"user":"senha"@10.61.61.2:22',
+ 'pingtraceurl' => FALSE,
+ 'description' => 'R1',
+ 'group' => 'Grupo',
+ 'ipv6' => TRUE,
+ 'os' => 'huawei',
+ ),
+
+ 'chr' => array
+ (
+ 'url' => 'ssh://user:senha@10.2.60.2:22',
+ 'pingtraceurl' => FALSE,
+ 'description' => 'R2',
+ 'group' => 'Grupo',
+ 'ipv6' => TRUE,
+ 'os' => 'mikrotik',
+ )
);
-/* End of file */
\ No newline at end of file
+/* End of file */
+?>
\ No newline at end of file
diff --git a/htdocs/lg_logo.gif b/htdocs/lg_logo.gif
old mode 100644
new mode 100755
diff --git a/htdocs/logo.png b/htdocs/logo.png
new file mode 100644
index 0000000..cadfbe0
Binary files /dev/null and b/htdocs/logo.png differ
diff --git a/htdocs/showgraph.js b/htdocs/showgraph.js
new file mode 100644
index 0000000..fc92a3c
--- /dev/null
+++ b/htdocs/showgraph.js
@@ -0,0 +1,11 @@
+$(document).ready(function(){
+ var url = "index.php"+$("#mapa").attr("url");
+
+ $.post(url, "", function(data){
+
+ $("#mapa").html(data);
+ $("#loading").hide();
+
+ });
+
+});
\ No newline at end of file