From 3b4c0f8e887db92c7ecc4f7cbf4b6afdc94896a1 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Wed, 13 Jan 2010 00:23:31 +0000 Subject: [PATCH] permissions for /bgp git-svn-id: http://www.observium.org/svn/observer/trunk@674 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/pages/bgp.php | 90 ++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 42 deletions(-) diff --git a/html/pages/bgp.php b/html/pages/bgp.php index b2617e5a13..72b901a772 100644 --- a/html/pages/bgp.php +++ b/html/pages/bgp.php @@ -1,53 +1,59 @@ "); +if ($_SESSION['userlevel'] < '5') +{ + include("includes/error-no-perm.inc.php"); +} +else +{ + echo("
"); - echo ''; + echo ''; - $i = "1"; + $i = "1"; - if($_GET['opta'] == "alerts") { - $where = "AND (B.bgpPeerAdminStatus = 'start' or B.bgpPeerAdminStatus = 'running') AND B.bgpPeerState != 'established'"; - } elseif ($_GET['opta'] == "external") { - $where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs"; - } elseif ($_GET['opta'] == "internal") { - $where = "AND D.bgpLocalAs = B.bgpPeerRemoteAs"; - } + if($_GET['opta'] == "alerts") { + $where = "AND (B.bgpPeerAdminStatus = 'start' or B.bgpPeerAdminStatus = 'running') AND B.bgpPeerState != 'established'"; + } elseif ($_GET['opta'] == "external") { + $where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs"; + } elseif ($_GET['opta'] == "internal") { + $where = "AND D.bgpLocalAs = B.bgpPeerRemoteAs"; + } - $peer_query = mysql_query("select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id $where ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier"); - while($peer = mysql_fetch_array($peer_query)) { + $peer_query = mysql_query("select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id $where ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier"); + while($peer = mysql_fetch_array($peer_query)) { - if(!is_integer($i/2)) { $bg_colour = $list_colour_b; } else { $bg_colour = $list_colour_a; } + if(!is_integer($i/2)) { $bg_colour = $list_colour_b; } else { $bg_colour = $list_colour_a; } - if($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; if ($_GET['opta'] != "alerts") { $bg_colour = "#ffcccc"; } } - if($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } + if($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; if ($_GET['opta'] != "alerts") { $bg_colour = "#ffcccc"; } } + if($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } - if($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; - if($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "Priv eBGP"; } - } + if($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; + if($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "Priv eBGP"; } + } - $peerhost = mysql_fetch_array(mysql_query("SELECT * FROM ipaddr AS A, interfaces AS I, devices AS D WHERE A.addr = '".$peer['bgpPeerIdentifier']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id")); + $peerhost = mysql_fetch_array(mysql_query("SELECT * FROM ipaddr AS A, interfaces AS I, devices AS D WHERE A.addr = '".$peer['bgpPeerIdentifier']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id")); - if($peerhost) { $peername = generatedevicelink($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); } + if($peerhost) { $peername = generatedevicelink($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); } - echo(" + echo(" - + - + - - - "); + + + "); - if($graphs) { - - $graph_type = "bgpupdates"; + if($graphs) { + + $graph_type = "bgpupdates"; - $daily_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=210&height=100"; + $daily_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=210&height=100"; $daily_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150"; $weekly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=210&height=100"; @@ -62,22 +68,22 @@ echo(""); + echo(""); - } - - $i++; - } - echo("
Local addressPeer addressTypeRemote ASStateUptime
Local addressPeer addressTypeRemote ASStateUptime
" . $peer['bgpLocalAddr'] . "
".generatedevicelink($peer, shorthost($peer['hostname']))."
" . $peer['bgpLocalAddr'] . "
".generatedevicelink($peer, shorthost($peer['hostname']))."
->" . $peer['bgpPeerIdentifier'] . "
".$peername."
" . $peer['bgpPeerIdentifier'] . "
".$peername."
$peer_typeAS" . $peer['bgpPeerRemoteAs'] . "
" . $peer['astext'] . "
" . $peer['bgpPeerAdminStatus'] . "
" . $peer['bgpPeerState'] . "
" .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
- Updates " . format_si($peer['bgpPeerInUpdates']) . " - " . format_si($peer['bgpPeerOutUpdates']) . "
AS" . $peer['bgpPeerRemoteAs'] . "
" . $peer['astext'] . "
" . $peer['bgpPeerAdminStatus'] . "
" . $peer['bgpPeerState'] . "
" .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
+ Updates " . format_si($peer['bgpPeerInUpdates']) . " + " . format_si($peer['bgpPeerOutUpdates']) . "
"); echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "); + "); echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "); + "); echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "); + "); echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "); + "); - echo("
"); + } + $i++; + } + echo(""); +} ?>