diff --git a/html/pages/addhost.inc.php b/html/pages/addhost.inc.php
index f08eb5a298..dfee96cf44 100644
--- a/html/pages/addhost.inc.php
+++ b/html/pages/addhost.inc.php
@@ -1,31 +1,33 @@
You are not permitted to perform this function");
-exit;
-
+if ($_SESSION['userlevel'] < 10)
+{
+ # FIXME generic box?
+ echo("You are not permitted to perform this function");
+ exit;
}
echo("
Change...");
+ // Perform actions if requested
-if($_GET['user_id']) {
- $user_data = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE user_id = '" . $_GET['user_id'] . "'"));
- echo("
" . $user_data['realname'] . "
Change...");
- // Perform actions if requested
-
- if($_GET['action'] == "deldevperm") {
- if(mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
- mysql_query("DELETE FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
+ if ($_GET['action'] == "deldevperm")
+ {
+ if (mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
+ mysql_query("DELETE FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
+ }
}
- }
- if($_GET['action'] == "adddevperm") {
- if(!mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
- mysql_query("INSERT INTO devices_perms (`device_id`, `user_id`) VALUES ('" . $_GET['device_id'] . "', '" . $_GET['user_id'] . "')");
+ if ($_GET['action'] == "adddevperm")
+ {
+ if (!mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
+ mysql_query("INSERT INTO devices_perms (`device_id`, `user_id`) VALUES ('" . $_GET['device_id'] . "', '" . $_GET['user_id'] . "')");
+ }
}
- }
-
- if($_GET['action'] == "delifperm") {
- if(mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
- mysql_query("DELETE FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
+ if ($_GET['action'] == "delifperm")
+ {
+ if (mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
+ mysql_query("DELETE FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
+ }
}
- }
- if($_GET['action'] == "addifperm") {
- if(!mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
- mysql_query("INSERT INTO ports_perms (`interface_id`, `user_id`) VALUES ('" . $_GET['interface_id'] . "', '" . $_GET['user_id'] . "')");
+ if ($_GET['action'] == "addifperm")
+ {
+ if (!mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
+ mysql_query("INSERT INTO ports_perms (`interface_id`, `user_id`) VALUES ('" . $_GET['interface_id'] . "', '" . $_GET['user_id'] . "')");
+ }
}
- }
-
- if($_GET['action'] == "delbillperm") {
- if(mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
- mysql_query("DELETE FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
+ if ($_GET['action'] == "delbillperm")
+ {
+ if (mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
+ mysql_query("DELETE FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
+ }
}
- }
- if($_GET['action'] == "addbillperm") {
- if(!mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
- mysql_query("INSERT INTO bill_perms (`bill_id`, `user_id`) VALUES ('" . $_GET['bill_id'] . "', '" . $_GET['user_id'] . "')");
+ if ($_GET['action'] == "addbillperm")
+ {
+ if (!mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
+ mysql_query("INSERT INTO bill_perms (`bill_id`, `user_id`) VALUES ('" . $_GET['bill_id'] . "', '" . $_GET['user_id'] . "')");
+ }
}
- }
+ echo("
");
+ // Display devices this users has access to
+ echo("
Device Access
");
-
-echo("
");
-
- // Display devices this users has access to
- echo("
Device Access
");
-
- $device_perm_data = mysql_query("SELECT * from devices_perms as P, devices as D WHERE `user_id` = '" . $_GET['user_id'] . "' AND D.device_id = P.device_id");
- while($device_perm = mysql_fetch_array($device_perm_data)) {
- echo("" . $device_perm['hostname'] . " ");
- $access_list[] = $device_perm['device_id'];
- $permdone = "yes";
- }
-
- if(!$permdone) { echo("None Configured"); }
-
-
- // Display devices this user doesn't have access to
- echo("
Grant access to new device
");
- echo("
-
-
-
-
");
+ if (!$permdone) { echo("None Configured"); }
- echo("
");
- echo("
Interface Access
");
+ // Display devices this user doesn't have access to
+ echo("
Grant access to new device
");
+ echo("
+
+
+
+
");
- echo("
Bill Access
");
-
- $bill_perm_data = mysql_query("SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = '" . $_GET['user_id'] .
- "' AND P.bill_id = B.bill_id");
-
- while($bill_perm = mysql_fetch_array($bill_perm_data)) {
- echo("
".$bill_perm['bill_name']."
");
- $bill_access_list[] = $bill_perm['bill_id'];
-
- $bpermdone = "yes";
- }
-
- if(!$bpermdone) { echo("None Configured"); }
-
- // Display devices this user doesn't have access to
- echo("
Grant access to new bill
");
- echo("
-
-
-
- ");
-
- $bills = mysql_query("SELECT * FROM `bills` ORDER BY `bill_name`");
- while($bill = mysql_fetch_array($bills)) {
- unset($done);
- foreach($bill_access_list as $ac) { if($ac == $bill['bill_id']) { $done = 1; } }
- if(!$done) {
- echo("");
+ $device_list = mysql_query("SELECT * FROM `devices` ORDER BY hostname");
+ while ($device = mysql_fetch_array($device_list))
+ {
+ unset($done);
+ foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } }
+ if (!$done)
+ {
+ echo("");
+ }
}
+
+ echo("
");
+
+ echo("
");
+ echo("
Interface Access
");
+
+ $interface_perm_data = mysql_query("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = '" . $_GET['user_id'] .
+ "' AND I.interface_id = P.interface_id AND D.device_id = I.device_id");
+
+ while ($interface_perm = mysql_fetch_array($interface_perm_data))
+ {
+ echo("
");
-?>
+?>
\ No newline at end of file
diff --git a/html/pages/front/default.php b/html/pages/front/default.php
index ec61ee073c..b8a01fe8be 100644
--- a/html/pages/front/default.php
+++ b/html/pages/front/default.php
@@ -1,6 +1,7 @@
$content
");
@@ -8,12 +9,13 @@ echo("
");
-if($_SESSION['userlevel'] == '10') {
+if ($_SESSION['userlevel'] == '10')
+{
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
} else {
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0'");
}
-while($device = mysql_fetch_array($sql)){
+while ($device = mysql_fetch_array($sql)){
generate_front_box("#ffaaaa", "
".generate_device_link($device, shorthost($device['hostname']))." Device Down
@@ -22,7 +24,8 @@ while($device = mysql_fetch_array($sql)){
}
-if($_SESSION['userlevel'] == '10') {
+if ($_SESSION['userlevel'] == '10')
+{
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
} else {
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
@@ -30,52 +33,56 @@ $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS
### These things need to become more generic, and more manageable across different frontpages... rewrite inc :>
-while($interface = mysql_fetch_array($sql)){
- if(!$interface['deleted']){
- $interface = ifNameDescr($interface);
- generate_front_box("#ffdd99", "
".generate_device_link($interface, shorthost($interface['hostname']))." Port Down ".generate_port_link($interface, truncate(makeshortif($interface['label']),13,''))."
" . ($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '') . "
");
-
}
}
/* FIXME service permissions? seem nonexisting now.. */
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
-while($service = mysql_fetch_array($sql)){
- generate_front_box("#ffaaaa", "
".generate_device_link($service, shorthost($service['hostname']))."
- Service Down
- ".$service['service_type']."
- ".truncate($interface['ifAlias'], 20)."
-
".generate_device_link($service, shorthost($service['hostname']))."
+ Service Down
+ ".$service['service_type']."
+ ".truncate($interface['ifAlias'], 20)."
+
");
}
if (isset($config['enable_bgp']) && $config['enable_bgp'])
{
- if($_SESSION['userlevel'] == '10') {
+ if ($_SESSION['userlevel'] == '10')
+ {
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0");
} else {
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0");
}
- while($peer = mysql_fetch_array($sql))
+ while ($peer = mysql_fetch_array($sql))
{
generate_front_box("#ffaaaa", "
");
-?>
+?>
\ No newline at end of file
diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php
index 087a5e1178..ea09176dbd 100644
--- a/html/pages/front/demo.php
+++ b/html/pages/front/demo.php
@@ -8,7 +8,7 @@ $nodes = array();
$sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'");
-while($device = mysql_fetch_array($sql)){
+while ($device = mysql_fetch_array($sql)){
unset($already);
$i = 0;
while ($i <= count($nodes)) {
@@ -18,13 +18,13 @@ while($device = mysql_fetch_array($sql)){
}
$i++;
}
- if(!$already) { $nodes[] = $device['device_id']; }
+ if (!$already) { $nodes[] = $device['device_id']; }
}
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
-while($device = mysql_fetch_array($sql)){
- if(device_permitted($device['device_id'])) {
+while ($device = mysql_fetch_array($sql)){
+ if (device_permitted($device['device_id'])) {
echo("
".generate_device_link($device, shorthost($device['hostname']))." Device Down
@@ -33,11 +33,11 @@ while($device = mysql_fetch_array($sql)){
}
}
-if($config['warn']['ifdown']) {
+if ($config['warn']['ifdown']) {
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
-while($interface = mysql_fetch_array($sql)){
- if(port_permitted($interface['interface_id'])) {
+while ($interface = mysql_fetch_array($sql)){
+ if (port_permitted($interface['interface_id'])) {
echo("
".generate_device_link($interface, shorthost($interface['hostname']))." Port Down
@@ -50,8 +50,8 @@ while($interface = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
-while($service = mysql_fetch_array($sql)){
- if(device_permitted($service['device_id'])) {
+while ($service = mysql_fetch_array($sql)){
+ if (device_permitted($service['device_id'])) {
echo("
".generate_device_link($service, shorthost($service['hostname']))." Service Down
@@ -62,11 +62,11 @@ while($service = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id");
-while($peer = mysql_fetch_array($sql)){
- if(device_permitted($peer['device_id'])) {
+while ($peer = mysql_fetch_array($sql)){
+ if (device_permitted($peer['device_id'])) {
echo("
".generate_device_link($peer, shorthost($peer['hostname']))."
- BGP Down
+ BGP Down ".$peer['bgpPeerIdentifier']." AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)."
");
@@ -74,8 +74,8 @@ while($peer = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '84600' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'");
-while($device = mysql_fetch_array($sql)){
- if(device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) {
+while ($device = mysql_fetch_array($sql)){
+ if (device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) {
echo("
");
- if($ports['fileserver']) {
+ if ($ports['fileserver']) {
echo("
");
echo("
Central Fileserver
");
diff --git a/html/pages/front/example2.php b/html/pages/front/example2.php
index 306516d395..669e5931da 100644
--- a/html/pages/front/example2.php
+++ b/html/pages/front/example2.php
@@ -11,37 +11,39 @@ $nodes = array();
$sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'");
-while($device = mysql_fetch_array($sql)){
+while ($device = mysql_fetch_array($sql))
+{
unset($already);
$i = 0;
- while ($i <= count($nodes)) {
+ while ($i <= count($nodes))
+ {
$thisnode = $device['device_id'];
- if ($nodes[$i] == $thisnode) {
+ if ($nodes[$i] == $thisnode)
+ {
$already = "yes";
}
$i++;
}
- if(!$already) { $nodes[] = $device['device_id']; }
+ if (!$already) { $nodes[] = $device['device_id']; }
}
-
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
-while($device = mysql_fetch_array($sql)){
+while ($device = mysql_fetch_array($sql)){
echo("
".generate_device_link($device, shorthost($device['hostname']))."
- Device Down
+ Device Down".truncate($device['location'], 20)."
");
}
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
-while($interface = mysql_fetch_array($sql)){
+while ($interface = mysql_fetch_array($sql)){
echo("
".generate_device_link($interface, shorthost($interface['hostname']))."
- Port Down
+ Port Down".generate_port_link($interface, makeshortif($interface['ifDescr']))." ".truncate($interface['ifAlias'], 20)."
");
@@ -49,11 +51,11 @@ while($interface = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
-while($service = mysql_fetch_array($sql)){
+while ($service = mysql_fetch_array($sql)){
echo("
".generate_device_link($service, shorthost($service['hostname']))."
- Service Down
+ Service Down".$service['service_type']." ".truncate($interface['ifAlias'], 20)."
");
@@ -61,11 +63,11 @@ while($service = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id");
-while($peer = mysql_fetch_array($sql)){
+while ($peer = mysql_fetch_array($sql)){
echo("
');
@@ -69,4 +81,4 @@ switch ($_GET['opta'])
break;
}
-?>
+?>
\ No newline at end of file
diff --git a/html/pages/health/current.inc.php b/html/pages/health/current.inc.php
index 6c0f76734c..27bb5862a1 100644
--- a/html/pages/health/current.inc.php
+++ b/html/pages/health/current.inc.php
@@ -3,7 +3,8 @@
$graph_type = "sensor_current";
$unit = "A";
-if($_SESSION['userlevel'] >= '5') {
+if ($_SESSION['userlevel'] >= '5')
+{
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='current' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr";
} else {
$sql = "SELECT * FROM `current` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='current' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_descr";
@@ -26,16 +27,16 @@ echo('
");
-
-?>
+?>
\ No newline at end of file
diff --git a/html/pages/health/fanspeeds.inc.php b/html/pages/health/fanspeeds.inc.php
index d928d5b018..75cd350af0 100644
--- a/html/pages/health/fanspeeds.inc.php
+++ b/html/pages/health/fanspeeds.inc.php
@@ -3,7 +3,8 @@
$graph_type = "sensor_fanspeed";
$unit = "rpm";
-if($_SESSION['userlevel'] >= '5') {
+if ($_SESSION['userlevel'] >= '5')
+{
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='fanspeed' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr";
} else {
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='fanspeed' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_descr";
@@ -25,16 +26,16 @@ echo('
\ No newline at end of file
+
\ No newline at end of file
diff --git a/html/pages/inventory.inc.php b/html/pages/inventory.inc.php
index ee25aa1140..3356281b55 100644
--- a/html/pages/inventory.inc.php
+++ b/html/pages/inventory.inc.php
@@ -11,16 +11,17 @@
".$data['entPhysicalModelName']."");
}
?>