diff --git a/html/pages/adduser.php b/html/pages/adduser.php new file mode 100644 index 0000000000..ff000c815c --- /dev/null +++ b/html/pages/adduser.php @@ -0,0 +1,40 @@ +"); + +if($_SESSION['userlevel'] != '10') { echo("You do not have then necessary permission to view this page!"); } else { + + echo("

Add User

"); + + if($_POST['action'] == "add") { + + mysql_query("INSERT INTO `users` (`username`, `realname`, `password`, `level`) VALUES ('" . $_POST['new_username'] . "', '" . $_POST['new_realname'] . "', MD5('" . $_POST['new_password'] . "'), '" . $_POST['new_level'] . "')"); + + if(mysql_affected_rows()) { echo("User " . $_GET['username'] . " added!"); } + + } + + echo("
+ "); + + echo("Username
"); + echo("Password
"); + + echo("Realname

"); + + echo("

"); + + echo(" "); + + echo("
"); + +} + +echo(""); + +?> + diff --git a/html/pages/configuration.php b/html/pages/configuration.php new file mode 100644 index 0000000000..5660d667c2 --- /dev/null +++ b/html/pages/configuration.php @@ -0,0 +1,6 @@ + + diff --git a/html/pages/deluser.php b/html/pages/deluser.php new file mode 100644 index 0000000000..6bec8d4743 --- /dev/null +++ b/html/pages/deluser.php @@ -0,0 +1,41 @@ +"); + +if($_SESSION['userlevel'] != '10') { echo("You do not have then necessary permission to view this page!"); } else { + + echo("

Delete User

"); + + if($_GET['action'] == "del") { + + $delete_username = mysql_result(mysql_query("SELECT username FROM users WHERE user_id = '" . $_GET['user_id'] . "'"),0); + + if($_GET['confirm'] == "yes") { + + mysql_query("DELETE FROM `devices_perms` WHERE `user_id` = '" . $_GET['user_id'] . "'"); + mysql_query("DELETE FROM `users` WHERE `user_id` = '" . $_GET['user_id'] . "'"); + + if(mysql_affected_rows()) { echo("User '$delete_username' deleted!"); } + + } else { + + echo("You have requested deletion of the user '$delete_username'. This action can not be reversed.
Click to confirm
"); + + } + + } + + $userlist = mysql_query("SELECT * FROM `users`"); + + while($userentry = mysql_fetch_array($userlist)) { + $i++; + echo($i . ". " . $userentry['username'] . " +
"); + } + +} + +echo(""); + +?> + diff --git a/html/pages/device/dev-entphysical.php b/html/pages/device/dev-entphysical.php new file mode 100644 index 0000000000..c9210c9d42 --- /dev/null +++ b/html/pages/device/dev-entphysical.php @@ -0,0 +1,63 @@ +"); + + if($ent['entPhysicalClass'] == "chassis") { echo(" "); } + if($ent['entPhysicalClass'] == "module") { echo(" "); } + if($ent['entPhysicalClass'] == "port") { echo(" "); } + if($ent['entPhysicalClass'] == "container") { echo(" "); } + if($ent['entPhysicalClass'] == "sensor") { echo(" "); } + if($ent['entPhysicalClass'] == "backplane") { echo(" "); } + + if($ent['entPhysicalParentRelPos'] > '-1') {echo("".$ent['entPhysicalParentRelPos'].". ");} + + if($ent['entPhysicalModelName'] && $ent['entPhysicalName']) { + echo("".$ent['entPhysicalModelName'] . " (".$ent['entPhysicalName'].")"); + } elseif($ent['entPhysicalModelName']) { + echo("".$ent['entPhysicalModelName'] . ""); + } elseif($ent['entPhysicalName']) { + echo("".$ent['entPhysicalName'].""); + } elseif($ent['entPhysicalDescr']) { + echo("".$ent['entPhysicalDescr'].""); + } + + + + echo("
" . $ent['entPhysicalDescr']); + + if($ent['entPhysicalSerialNum']) { + echo("
Serial No. ".$ent['entPhysicalSerialNum']." "); + } + + echo("
"); + + $count = mysql_result(mysql_query("SELECT COUNT(*) FROM `entPhysical` WHERE device_id = '".$_GET['id']."' AND entPhysicalContainedIn = '".$ent['entPhysicalIndex']."'"),0); + if($count) { + echo(""); + } + echo(""); + } +} + + echo("

Inventory

"); + echo("
+ Expand All Nodes + Collapse All Nodes +
"); + + echo("
"); + + +?> + + diff --git a/html/pages/device/dev-storage.inc b/html/pages/device/dev-storage.inc new file mode 100644 index 0000000000..3b2b675987 --- /dev/null +++ b/html/pages/device/dev-storage.inc @@ -0,0 +1,79 @@ +"); + +echo(" + Drive + Usage + Used + Total + Free + + "); + +$row = 1; + +while($drive = mysql_fetch_array($query)) { + + if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + + $total = $drive['hrStorageSize'] * $drive['hrStorageAllocationUnits']; + $used = $drive['hrStorageUsed'] * $drive['hrStorageAllocationUnits']; + $perc = round($drive['storage_perc'], 0); + $total = formatStorage($total); + $used = formatStorage($used); + + $fs_url = "?page=device&id=".$device['device_id']."§ion=dev-storage"; + + $fs_popup = "onmouseover=\"return overlib('
".$device['hostname']." - ".$drive['hrStorageDescr']; + $fs_popup .= "
"; + $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; + + $drv_colour = percent_colour($perc); + + echo("" . $drive['hrStorageDescr'] . " + + " . $perc . "%" . $total . "" . $used . ""); + + + $graph_type = "unixfs"; + +// start temperature graphs + + $daily_temp = "graph.php?id=" . $drive['storage_id'] . "&type=$graph_type&from=$day&to=$now&width=212&height=100"; + $daily_url = "graph.php?id=" . $drive['storage_id'] . "&type=$graph_type&from=$day&to=$now&width=400&height=150"; + + $weekly_temp = "graph.php?id=" . $drive['storage_id'] . "&type=$graph_type&from=$week&to=$now&width=212&height=100"; + $weekly_url = "graph.php?id=" . $drive['storage_id'] . "&type=$graph_type&from=$week&to=$now&width=400&height=150"; + + $monthly_temp = "graph.php?id=" . $drive['storage_id'] . "&type=$graph_type&from=$month&to=$now&width=212&height=100"; + $monthly_url = "graph.php?id=" . $drive['storage_id'] . "&type=$graph_type&from=$month&to=$now&width=400&height=150"; + + $yearly_temp = "graph.php?id=" . $drive['storage_id'] . "&type=$graph_type&from=$year&to=$now&width=212&height=100"; + $yearly_url = "graph.php?id=" . $drive['storage_id'] . "&type=$graph_type&from=$year&to=$now&width=400&height=150"; + + echo(""); + + echo("".$device['hostname']." - ".$drive['hrStorageDescr']."', LEFT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\"> + "); + echo("".$device['hostname']." - ".$drive['hrStorageDescr']."', LEFT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\"> + "); + echo("".$device['hostname']." - ".$drive['hrStorageDescr']."', LEFT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\"> + "); + echo("".$device['hostname']." - ".$drive['hrStorageDescr']."', LEFT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\"> + "); + + echo(""); + + + $row++; + +} + +echo(""); + + +?> diff --git a/html/pages/edituser.php b/html/pages/edituser.php new file mode 100644 index 0000000000..bddeac5ec7 --- /dev/null +++ b/html/pages/edituser.php @@ -0,0 +1,196 @@ + + + +"); + +if($_SESSION['userlevel'] != '10') { echo("
You do not have then necessary permission to view this page!
"); } else { + +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") { + mysql_query("DELETE FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"); + } + if($_GET['action'] == "adddevperm") { + mysql_query("INSERT INTO devices_perms (`device_id`, `user_id`) VALUES ('" . $_GET['device_id'] . "', '" . $_GET['user_id'] . "')"); + } + + if($_GET['action'] == "delifperm") { + mysql_query("DELETE FROM interfaces_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"); + } + if($_GET['action'] == "addifperm") { + mysql_query("INSERT INTO interfaces_perms (`interface_id`, `user_id`) VALUES ('" . $_GET['interface_id'] . "', '" . $_GET['user_id'] . "')"); + } + + if($_GET['action'] == "delbillperm") { + mysql_query("DELETE FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"); + } + if($_GET['action'] == "addbillperm") { + 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

"); + + $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("
+ + + +
"); + echo("
"); + echo("

Interface Access

"); + + $interface_perm_data = mysql_query("SELECT * from interfaces_perms as P, interfaces 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("
".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."
". + "" . $interface_perm['ifAlias'] . "
  
"); + $ipermdone = "yes"; + } + + if(!$ipermdone) { echo("None Configured"); } + + // Display devices this user doesn't have access to + echo("

Grant access to new interface

"); + + echo("
+ + + + + + +
Device:
Interface:
"); + + 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("
+ + + +
"); + +echo("
"); + +} else { + + $user_list = mysql_query("SELECT * FROM `users`"); + + echo("

Select a user to edit

"); + + echo("
+ +
"); + + + +} + +} + +echo(""); + +?> + diff --git a/html/pages/preferences.php b/html/pages/preferences.php new file mode 100644 index 0000000000..2bcd666588 --- /dev/null +++ b/html/pages/preferences.php @@ -0,0 +1,55 @@ +"); +echo("

User Preferences

"); + +include("includes/update-preferences.inc.php"); + + +echo("
"); +echo("
"); + + +echo("
"); +echo("
"); +echo("

Change Password

"); + +echo($password_message); + +echo("
+ + + + +
Old Password
New Password
New Password
"); + +echo("
"); + + +echo("
"); + + +echo("

Device Permissions

"); + +if($_SESSION['userlevel'] == '10') { echo("Global Administrative Access"); } +if($_SESSION['userlevel'] == '5') { echo("Global Viewing Access"); } +if($_SESSION['userlevel'] == '1') { + + $perms = mysql_query("SELECT * FROM `devices_perms` AS P, `devices` AS D WHERE `user_id` = '" . $user_id . "' AND P.device_id = D.device_id"); + + + while($perm = mysql_fetch_array($perms)) { + echo("" . $perm['hostname'] . "
"); + $dev_access = 1; + } + if(!$dev_access) { echo("No access!"); } + + } + + +echo("
"); +echo("
"); + + +echo(""); +?> + diff --git a/scan-snmp.php b/scan-snmp.php index 52c9602cf3..d3e0ec69b0 100755 --- a/scan-snmp.php +++ b/scan-snmp.php @@ -12,8 +12,10 @@ foreach( explode("\n", $data) as $ip) { $snmp = `snmpget -t 0.1 -v2c -c $community $ip sysName.0`; if(strstr($snmp, "STRING")) { $hostname = trim(str_replace("SNMPv2-MIB::sysName.0 = STRING: ","", $snmp)); - if(mysql_result(mysql_query("SELECT COUNT(id) FROM devices WHERE hostname = '$hostname'"),0) == '0') { - `./add-host.php $hostname $community v2c`; + if(mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE hostname = '$hostname'"),0) == '0') { + if(gethostbyname($hostname) == gethostbyname($hostname.".vostron.net")) { $hostname = $hostname . ".vostron.net"; } + if(gethostbyname($hostname) == gethostbyname($hostname.".vostron.net")) { $hostname = $hostname . ".cust.vostron.net"; } + addHost($hostname, $community, 'v2c'); echo("Adding $hostname \n"); } }