mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	Updates.
git-svn-id: http://www.observium.org/svn/observer/trunk@130 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
		
							
								
								
									
										40
									
								
								html/pages/adduser.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								html/pages/adduser.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
<?
 | 
			
		||||
 | 
			
		||||
echo("<div style='margin: 10px;'>");
 | 
			
		||||
 | 
			
		||||
if($_SESSION['userlevel'] != '10') { echo("<span class=alert>You do not have then necessary permission to view this page!</alert>"); } else {
 | 
			
		||||
 | 
			
		||||
  echo("<h3>Add User</h3>");
 | 
			
		||||
 | 
			
		||||
  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("<span class=info>User " . $_GET['username'] . " added!</span>"); }
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  echo("<form method='post' action='?page=adduser'>
 | 
			
		||||
          <input type='hidden' value='add' name='action'>");
 | 
			
		||||
 | 
			
		||||
  echo("Username <input name='new_username'></input><br />");
 | 
			
		||||
  echo("Password <input name='new_password'></input><br />");
 | 
			
		||||
 | 
			
		||||
  echo("Realname <input name='new_realname'></input><br /><br />");
 | 
			
		||||
 | 
			
		||||
  echo("<select name='new_level'>
 | 
			
		||||
          <option value='1'>Normal User</option>
 | 
			
		||||
          <option value='5'>Global Read</option>
 | 
			
		||||
          <option value='10'>Administrator</option>
 | 
			
		||||
        </select><br /><br />");
 | 
			
		||||
 | 
			
		||||
  echo(" <input type='submit' Value='Add' >");
 | 
			
		||||
 | 
			
		||||
  echo("</form>");
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
echo("</div>");
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										6
									
								
								html/pages/configuration.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								html/pages/configuration.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										41
									
								
								html/pages/deluser.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								html/pages/deluser.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
echo("<div style='margin: 10px;'>");
 | 
			
		||||
 | 
			
		||||
if($_SESSION['userlevel'] != '10') { echo("<span class=alert>You do not have then necessary permission to view this page!</span>"); } else {
 | 
			
		||||
 | 
			
		||||
  echo("<h3>Delete User</h3>");
 | 
			
		||||
 | 
			
		||||
  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("<span class=info>User '$delete_username' deleted!</span>"); }
 | 
			
		||||
 | 
			
		||||
    } else {
 | 
			
		||||
 | 
			
		||||
      echo("<span class=alert>You have requested deletion of the  user '$delete_username'. This action can not be reversed.<br /><a href='?page=deluser&action=del&user_id=" . $_GET['user_id'] . "&confirm=yes'>Click to confirm</a></span>");
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  $userlist = mysql_query("SELECT * FROM `users`");
 | 
			
		||||
 | 
			
		||||
  while($userentry = mysql_fetch_array($userlist)) {
 | 
			
		||||
    $i++;
 | 
			
		||||
    echo($i . ". " . $userentry['username'] . "
 | 
			
		||||
         <a href='?page=deluser&action=del&user_id=" . $userentry['user_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a><br/>");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
echo("</div>");
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										63
									
								
								html/pages/device/dev-entphysical.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								html/pages/device/dev-entphysical.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
function printEntPhysical($ent, $level, $class) {
 | 
			
		||||
 | 
			
		||||
     $query = mysql_query("SELECT * FROM `entPhysical` WHERE device_id = '".$_GET['id']."' AND entPhysicalContainedIn = '".$ent."' ORDER BY entPhysicalContainedIn");
 | 
			
		||||
     while($ent = mysql_fetch_array($query)) {
 | 
			
		||||
       echo("<li class='$class'>");
 | 
			
		||||
 | 
			
		||||
       if($ent['entPhysicalClass'] == "chassis") { echo("<img src='images/16/server.png' style='vertical-align:middle'/> "); }
 | 
			
		||||
       if($ent['entPhysicalClass'] == "module") { echo("<img src='images/16/drive.png' style='vertical-align:middle'/> "); }
 | 
			
		||||
       if($ent['entPhysicalClass'] == "port") { echo("<img src='images/16/connect.png' style='vertical-align:middle'/> "); }
 | 
			
		||||
       if($ent['entPhysicalClass'] == "container") { echo("<img src='images/16/box.png' style='vertical-align:middle'/> "); }
 | 
			
		||||
       if($ent['entPhysicalClass'] == "sensor") { echo("<img src='images/16/contrast.png' style='vertical-align:middle'/> "); }
 | 
			
		||||
       if($ent['entPhysicalClass'] == "backplane") { echo("<img src='images/16/brick.png' style='vertical-align:middle'/> "); }
 | 
			
		||||
 | 
			
		||||
       if($ent['entPhysicalParentRelPos'] > '-1') {echo("<strong>".$ent['entPhysicalParentRelPos'].".</strong> ");}
 | 
			
		||||
 | 
			
		||||
       if($ent['entPhysicalModelName'] && $ent['entPhysicalName']) {
 | 
			
		||||
         echo("<strong>".$ent['entPhysicalModelName']  . "</strong> (".$ent['entPhysicalName'].")");
 | 
			
		||||
       } elseif($ent['entPhysicalModelName']) {
 | 
			
		||||
         echo("<strong>".$ent['entPhysicalModelName']  . "</strong>");
 | 
			
		||||
       } elseif($ent['entPhysicalName']) {
 | 
			
		||||
         echo("<strong>".$ent['entPhysicalName']."</strong>");
 | 
			
		||||
       } elseif($ent['entPhysicalDescr']) {
 | 
			
		||||
         echo("<strong>".$ent['entPhysicalDescr']."</strong>");
 | 
			
		||||
       }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
       echo("<br /><div class='interface-desc' style='margin-left: 20px;'>" . $ent['entPhysicalDescr']);
 | 
			
		||||
 | 
			
		||||
       if($ent['entPhysicalSerialNum']) {
 | 
			
		||||
         echo(" <br /><span style='color: #000099;'>Serial No. ".$ent['entPhysicalSerialNum']."</span> ");
 | 
			
		||||
       }
 | 
			
		||||
 | 
			
		||||
       echo("</div>");
 | 
			
		||||
 | 
			
		||||
       $count = mysql_result(mysql_query("SELECT COUNT(*) FROM `entPhysical` WHERE device_id = '".$_GET['id']."' AND entPhysicalContainedIn = '".$ent['entPhysicalIndex']."'"),0);
 | 
			
		||||
       if($count) {
 | 
			
		||||
         echo("<ul>");
 | 
			
		||||
         printEntPhysical($ent['entPhysicalIndex'], $level+1, '');
 | 
			
		||||
         echo("</ul>");
 | 
			
		||||
       }
 | 
			
		||||
       echo("</li>");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
   echo("<div style='float: left;'><h3>Inventory</h3></div>");
 | 
			
		||||
   echo("<div style='float: right;'>
 | 
			
		||||
           <a href='#' class='button' onClick=\"expandTree('enttree');return false;\"><img src='images/16/bullet_toggle_plus.png'>Expand All Nodes</a>
 | 
			
		||||
           <a href='#' class='button' onClick=\"collapseTree('enttree');return false;\"><img src='images/16/bullet_toggle_minus.png'>Collapse All Nodes</a>
 | 
			
		||||
         </div>");
 | 
			
		||||
 | 
			
		||||
   echo("<div style='clear: both;'><UL CLASS='mktree' id='enttree'>");
 | 
			
		||||
   $level = "0";
 | 
			
		||||
   $ent['entPhysicalIndex'] = "0";
 | 
			
		||||
   printEntPhysical($ent['entPhysicalIndex'], $level, "liOpen");
 | 
			
		||||
   echo("</ul></div>");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										79
									
								
								html/pages/device/dev-storage.inc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								html/pages/device/dev-storage.inc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,79 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
$sql = "SELECT * FROM `storage` WHERE host_id = '" . $_GET[id] . "' ORDER BY hrStorageDescr";
 | 
			
		||||
$query = mysql_query($sql);
 | 
			
		||||
 | 
			
		||||
echo("<table cellspacing=0 cellpadding=5 width=100%>");
 | 
			
		||||
 | 
			
		||||
echo("<tr class=tablehead>
 | 
			
		||||
        <th width=200>Drive</th>
 | 
			
		||||
        <th width=360>Usage</th>
 | 
			
		||||
        <th width=50>Used</th>
 | 
			
		||||
        <th width=50>Total</th>
 | 
			
		||||
        <th width=50>Free</th>
 | 
			
		||||
        <th></th>
 | 
			
		||||
      </tr>");
 | 
			
		||||
 | 
			
		||||
$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('<div class=list-large>".$device['hostname']." - ".$drive['hrStorageDescr'];
 | 
			
		||||
    $fs_popup .= "</div><img src=\'graph.php?id=" . $drive['storage_id'] . "&type=unixfs&from=$month&to=$now&width=400&height=125\'>";
 | 
			
		||||
    $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\"";
 | 
			
		||||
 | 
			
		||||
    $drv_colour = percent_colour($perc);
 | 
			
		||||
 | 
			
		||||
    echo("<tr bgcolor='$row_colour'><th><a href='$fs_url' $fs_popup>" . $drive['hrStorageDescr'] . "</a></td><td>
 | 
			
		||||
          <a href='$fs_url' $fs_popup><img src='percentage.php?per=" . $perc . "&width=350'></a>
 | 
			
		||||
          </td><td style='font-weight: bold; color: $drv_colour'>" . $perc . "%</td><td>" . $total . "</td><td>" . $used . "</td><td></td></tr>");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  $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("<tr bgcolor='$row_colour'><td colspan=6>");
 | 
			
		||||
 | 
			
		||||
  echo("<a onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$drive['hrStorageDescr']."</div><img src=\'$daily_url\'>', LEFT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\">
 | 
			
		||||
        <img src='$daily_temp' border=0></a> ");
 | 
			
		||||
  echo("<a onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$drive['hrStorageDescr']."</div><img src=\'$weekly_url\'>', LEFT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\">
 | 
			
		||||
        <img src='$weekly_temp' border=0></a> ");
 | 
			
		||||
  echo("<a onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$drive['hrStorageDescr']."</div><img src=\'$monthly_url\'>', LEFT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\">
 | 
			
		||||
        <img src='$monthly_temp' border=0></a> ");
 | 
			
		||||
  echo("<a onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$drive['hrStorageDescr']."</div><img src=\'$yearly_url\'>', LEFT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\">
 | 
			
		||||
        <img src='$yearly_temp' border=0></a>");
 | 
			
		||||
 | 
			
		||||
  echo("</td></tr>");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  $row++;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
echo("</table>");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										196
									
								
								html/pages/edituser.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										196
									
								
								html/pages/edituser.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,196 @@
 | 
			
		||||
<script type="text/javascript" src="ajax.js"></script>
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
var ajax = new Array();
 | 
			
		||||
 | 
			
		||||
function getInterfaceList(sel)
 | 
			
		||||
{
 | 
			
		||||
        var deviceId = sel.options[sel.selectedIndex].value;
 | 
			
		||||
        document.getElementById('interface_id').options.length = 0;     // Empty city select box
 | 
			
		||||
        if(deviceId.length>0){
 | 
			
		||||
                var index = ajax.length;
 | 
			
		||||
                ajax[index] = new sack();
 | 
			
		||||
 | 
			
		||||
                ajax[index].requestFile = 'test_interfaces.php?device_id='+deviceId;    // Specifying which file to get
 | 
			
		||||
                ajax[index].onCompletion = function(){ createInterfaces(index) };       // Specify function that will be executed after file has been found
 | 
			
		||||
                ajax[index].runAJAX();          // Execute AJAX function
 | 
			
		||||
        }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function createInterfaces(index)
 | 
			
		||||
{
 | 
			
		||||
        var obj = document.getElementById('interface_id');
 | 
			
		||||
        eval(ajax[index].response);     // Executing the response from Ajax as Javascript code
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<?
 | 
			
		||||
 | 
			
		||||
echo("<div style='margin: 10px;'>");
 | 
			
		||||
 | 
			
		||||
if($_SESSION['userlevel'] != '10') { echo("<div class=error>You do not have then necessary permission to view this page!</div>"); } else {
 | 
			
		||||
 | 
			
		||||
if($_GET['user_id']) {
 | 
			
		||||
  $user_data = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE user_id = '" . $_GET['user_id'] . "'"));
 | 
			
		||||
    echo("<p><h2>" . $user_data['realname'] . "</h2><a href='?page=edituser'>Change...</a></p>");
 | 
			
		||||
  // 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("<table width=100%><tr><td valign=top width=33%>");
 | 
			
		||||
 | 
			
		||||
  // Display devices this users has access to
 | 
			
		||||
  echo("<h3>Device Access</h3>");
 | 
			
		||||
 | 
			
		||||
  $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'] . " <a href='?page=edituser&action=deldevperm&user_id=" . $_GET['user_id'] . "&device_id=" . $device_perm['device_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a><br />");
 | 
			
		||||
    $access_list[] = $device_perm['device_id'];
 | 
			
		||||
    $permdone = "yes";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if(!$permdone) { echo("None Configured"); }
 | 
			
		||||
 | 
			
		||||
  // Display devices this user doesn't have access to
 | 
			
		||||
  echo("<h4>Grant access to new device</h4>");
 | 
			
		||||
  echo("<form method='get' action=''>
 | 
			
		||||
          <input type='hidden' value='" . $_GET['user_id'] . "' name='user_id'>
 | 
			
		||||
          <input type='hidden' value='edituser' name='page'>
 | 
			
		||||
          <input type='hidden' value='adddevperm' name='action'>
 | 
			
		||||
          <select name='device_id' class=selector>");
 | 
			
		||||
 | 
			
		||||
  $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("<option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>");
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  echo("</select> <input type='submit' name='Submit' value='Add'></form>");
 | 
			
		||||
  echo("</td><td valign=top width=33%>");
 | 
			
		||||
  echo("<h3>Interface Access</h3>");
 | 
			
		||||
 | 
			
		||||
  $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("<table><tr><td><strong>".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."</strong><br />".
 | 
			
		||||
                "" . $interface_perm['ifAlias'] . "</td><td width=50>  <a href='?page=edituser&action=delifperm&user_id=" . $_GET['user_id'] .
 | 
			
		||||
     "&interface_id=" . $interface_perm['interface_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a></td></tr></table>");
 | 
			
		||||
    $ipermdone = "yes";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if(!$ipermdone) { echo("None Configured"); }
 | 
			
		||||
 | 
			
		||||
  // Display devices this user doesn't have access to
 | 
			
		||||
  echo("<h4>Grant access to new interface</h4>");
 | 
			
		||||
 | 
			
		||||
  echo("<form action='' method='get'>
 | 
			
		||||
      <input type='hidden' value='" . $_GET['user_id'] . "' name='user_id'>
 | 
			
		||||
      <input type='hidden' value='edituser' name='page'>
 | 
			
		||||
      <input type='hidden' value='addifperm' name='action'>
 | 
			
		||||
      <table><tr><td>Device: </td>
 | 
			
		||||
       <td><select id='device' class='selector' name='device' onchange='getInterfaceList(this)'>
 | 
			
		||||
        <option value=''>Select a device</option>");
 | 
			
		||||
 | 
			
		||||
  $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("<option value='" . $device['device_id']  . "'>" . $device['hostname'] . "</option>"); }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  echo("</select></td></tr><tr>
 | 
			
		||||
     <td>Interface: </td><td><select class=selector id='interface_id' name='interface_id'>
 | 
			
		||||
     </select></td>
 | 
			
		||||
     </tr><tr></table><input type='submit' name='Submit' value='Add'></form>");
 | 
			
		||||
 | 
			
		||||
  echo("</td><td valign=top width=33%>");
 | 
			
		||||
  echo("<h3>Bill Access</h3>");
 | 
			
		||||
 | 
			
		||||
  $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("<table><tr><td><strong>".$bill_perm['bill_name']."</strong></td><td width=50>  <a href='?page=edituser&action=delifperm&user_id=" .
 | 
			
		||||
    $_GET['user_id'] . "&interface_id=" . $bill_perm['interface_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a></td></tr></table>");
 | 
			
		||||
    $bill_access_list[] = $bill_perm['bill_id'];
 | 
			
		||||
 | 
			
		||||
    $bpermdone = "yes";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if(!$bpermdone) { echo("None Configured"); }
 | 
			
		||||
 | 
			
		||||
  // Display devices this user doesn't have access to
 | 
			
		||||
  echo("<h4>Grant access to new bill</h4>");
 | 
			
		||||
  echo("<form method='get' action=''>
 | 
			
		||||
          <input type='hidden' value='" . $_GET['user_id'] . "' name='user_id'>
 | 
			
		||||
          <input type='hidden' value='edituser' name='page'>
 | 
			
		||||
          <input type='hidden' value='addbillperm' name='action'>
 | 
			
		||||
          <select name='bill' class=selector>");
 | 
			
		||||
 | 
			
		||||
  $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("<option value='" . $bill['bill_id'] . "'>" . $bill['bill_name'] . "</option>");
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
echo("</select> <input type='submit' name='Submit' value='Add'></form>");
 | 
			
		||||
 | 
			
		||||
echo("</td></table>");
 | 
			
		||||
 | 
			
		||||
} else {
 | 
			
		||||
 | 
			
		||||
  $user_list = mysql_query("SELECT * FROM `users`");
 | 
			
		||||
 | 
			
		||||
  echo("<h3>Select a user to edit</h3>");
 | 
			
		||||
 | 
			
		||||
  echo("<form method='get' action=''>
 | 
			
		||||
          <input type='hidden' value='edituser' name='page'>
 | 
			
		||||
          <select name='user_id'>");
 | 
			
		||||
  while($user_entry = mysql_fetch_array($user_list)) {
 | 
			
		||||
    echo("<option value='" . $user_entry['user_id']  . "'>" . $user_entry['username'] . "</option>");
 | 
			
		||||
  }
 | 
			
		||||
  echo("</select><input type='submit' name='Submit' value='Select'></form>");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
echo("</div>");
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										55
									
								
								html/pages/preferences.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								html/pages/preferences.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,55 @@
 | 
			
		||||
<?php
 | 
			
		||||
echo("<div style='margin: 10px'>");
 | 
			
		||||
echo("<h3>User Preferences</h3>");
 | 
			
		||||
 | 
			
		||||
include("includes/update-preferences.inc.php");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
echo("<div style='width: 800px; background-color: #fff; padding:5px; margin-bottom:10px; float:left;'>");
 | 
			
		||||
echo("</div>");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
echo("<div style='width: 300px; float: right;'>");
 | 
			
		||||
echo("<div style='background-color: #e5e5e5; border: solid #e5e5e5 10px; margin-bottom:10px;'>");
 | 
			
		||||
echo("<h2>Change Password</h2>");
 | 
			
		||||
 | 
			
		||||
echo($password_message);
 | 
			
		||||
 | 
			
		||||
echo("<form method='post' action='?page=preferences'><input type=hidden name='action' value='changepass'>
 | 
			
		||||
        <table>
 | 
			
		||||
        <tr><td>Old Password</td><td><input type=password name=old_pass></input></td></tr>
 | 
			
		||||
        <tr><td>New Password</td><td><input type=password name=new_pass></input></td></tr>
 | 
			
		||||
        <tr><td>New Password</td><td><input type=password name=new_pass2></input></td></tr>
 | 
			
		||||
        <tr><td></td><td align=right><input type=submit></td></tr></table></form>");
 | 
			
		||||
 | 
			
		||||
echo("</div>");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
echo("<div style='background-color: #e5e5e5; border: solid #e5e5e5 10px;  margin-bottom:10px;'>");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
echo("<h4>Device Permissions</h4>");
 | 
			
		||||
 | 
			
		||||
if($_SESSION['userlevel'] == '10') { echo("<strong>Global Administrative Access</strong>"); }
 | 
			
		||||
if($_SESSION['userlevel'] == '5')  { echo("<strong>Global Viewing Access</strong>"); }
 | 
			
		||||
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("<a href='?page=device&id=" . $perm['device_id'] . "'>" . $perm['hostname'] . "</a><br />");
 | 
			
		||||
    $dev_access = 1;
 | 
			
		||||
  }
 | 
			
		||||
  if(!$dev_access) { echo("No access!"); }
 | 
			
		||||
 | 
			
		||||
 }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
echo("</div>");
 | 
			
		||||
echo("</div>");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
echo("</div>");
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user