First commit based on v0.1

master v0.1
Thomas Hooge 2 years ago
commit 2efd4ad0ab
  1. 23
      asset.php
  2. 80
      assetadd.php
  3. 23
      assetclass.php
  4. 63
      assetclassadd.php
  5. 78
      assetclassedit.php
  6. 51
      assetclassgroupview.php
  7. 70
      assetclassview.php
  8. 17
      assetdel.php
  9. 96
      assetedit.php
  10. 158
      assetview.php
  11. 115
      assigniptoasset.php
  12. 59
      assigniptonode.php
  13. 53
      assignlocationtosubnet.php
  14. 58
      assignsubnettolocation.php
  15. 53
      assignvlantosubnet.php
  16. 17
      config.php
  17. 4
      dbconnect.php
  18. 20
      footer.php
  19. 69
      functions.php
  20. 65
      header.php
  21. BIN
      images/arrow.gif
  22. BIN
      images/black.jpg
  23. BIN
      images/blue.jpg
  24. BIN
      images/cross.jpg
  25. BIN
      images/green.jpg
  26. BIN
      images/grey.jpg
  27. BIN
      images/orange.jpg
  28. BIN
      images/red.jpg
  29. 81
      index.php
  30. 136
      install/install.sql
  31. 18
      install/install.txt
  32. 48
      location.php
  33. 62
      locationadd.php
  34. 87
      locationedit.php
  35. 90
      locationview.php
  36. 89
      login.php
  37. 11
      logout.php
  38. 191
      nodeadd.php
  39. 23
      nodedel.php
  40. 129
      nodeedit.php
  41. 80
      nodelist.php
  42. 109
      nodeview.php
  43. 77
      options.php
  44. 103
      search.php
  45. 39
      style.css
  46. 23
      subnet.php
  47. 54
      subnetadd.php
  48. 100
      subnetedit.php
  49. 229
      subnetview.php
  50. 70
      useradd.php
  51. 47
      useredit.php
  52. 75
      userpassedit.php
  53. 23
      vlan.php
  54. 53
      vlanadd.php
  55. 72
      vlanedit.php
  56. 83
      vlanview.php

@ -0,0 +1,23 @@
<?php
include("header.php");
?>
<table border="0">
<tr>
<td>
<b>Asset:</b><br>
</td>
</tr>
<?php
$result = mysql_query("SELECT asset_id, asset_name FROM asset ORDER BY asset_name");
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="assetview.php?asset_id=' . $row->asset_id . '">' . $row->asset_name . '</a></td></tr>';
}
?>
</table>
<?
include("footer.php");
?>

@ -0,0 +1,80 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$asset_name = $_POST['asset_name'];
$hostname = $_POST['hostname'];
$assetclass_id = $_POST['assetclass_id'];
$asset_info = $_POST['asset_info'];
mysql_query("INSERT INTO asset (asset_name, hostname, assetclass_id, asset_info) VALUE ('$asset_name', '$hostname', '$assetclass_id', '$asset_info')") or die(mysql_error());
$asset_id = mysql_insert_id();
header_location("assetview.php?asset_id=" . $asset_id);
}
?>
<form method="POST" action="assetadd.php">
<input type="hidden" name="asset_id" value="<?php echo $asset_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Add asset:</b><br>
</td>
</tr>
<tr>
<td>
Asset name:
</td>
<td>
<input type="text" name="asset_name">
</td>
</tr>
<tr>
<td>
Hostname:
</td>
<td>
<input type="text" name="hostname">
</td>
</tr>
<tr>
<td>
Asset class:
</td>
<td>
<select name="assetclass_id">
<?php
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->assetclass_id . '">' . $row->assetclass_name . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>
Asset info:
</td>
<td>
<textarea name="asset_info"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,23 @@
<?php
include("header.php");
?>
<table border="0">
<tr>
<td>
<b>Assetclass:</b><br>
</td>
</tr>
<?php
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name");
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="assetclassview.php?assetclass_id=' . $row->assetclass_id . '">' . $row->assetclass_name . '</a></td></tr>';
}
?>
</table>
<?php
include("footer.php");
?>

@ -0,0 +1,63 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$assetclass_name = $_POST['assetclass_name'];
$assetclassgroup_id = $_POST['assetclassgroup_id'];
mysql_query("INSERT INTO assetclass (assetclass_name, assetclassgroup_id) VALUE ('$assetclass_name', '$assetclassgroup_id')") or die(mysql_error());
$assetclass_id = mysql_insert_id();
header_location("assetclassview.php?assetclass_id=" . $assetclass_id);
}
?>
<form method="POST" action="assetclassadd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add new assetclass:</b><br>
</td>
</tr>
<tr>
<td>
Assetclass name:
</td>
<td>
<input type="text" name="assetclass_name">
</td>
</tr>
<tr>
<td>
Assetclass Group:<br>
</td>
<td>
<select name="assetclassgroup_id">
<?php
$result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name FROM assetclassgroup ORDER BY assetclassgroup_id");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->assetclassgroup_id . '">' . $row->assetclassgroup_name. '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,78 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$assetclass_id = $_POST['assetclass_id'];
$assetclass_name = $_POST['assetclass_name'];
$assetclassgroup_id = $_POST['assetclassgroup_id'];
mysql_query("UPDATE assetclass SET assetclass_name='$assetclass_name', assetclassgroup_id='$assetclassgroup_id' WHERE assetclass_id='$assetclass_id'") or die(mysql_error());
header_location("assetclassview.php?assetclass_id=" . $assetclass_id);
}
$assetclass_id = $_GET['assetclass_id'];
// get current information
$result = mysql_query("SELECT assetclass_name, assetclassgroup_id FROM assetclass WHERE assetclass_id='$assetclass_id'");
while ($row = mysql_fetch_object($result)) {
$assetclass_name = $row->assetclass_name;
$assetclassgroup_id = $row->assetclassgroup_id;
}
?>
<form method="POST" action="assetclassedit.php">
<input type="hidden" name="assetclass_id" value="<?php echo $assetclass_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Edit assetclass:</b><br>
</td>
</tr>
<tr>
<td>
Assetclass name:
</td>
<td>
<input type="text" name="assetclass_name" value="<?php echo $assetclass_name; ?>">
</td>
</tr>
<tr>
<td>
Assetclass Group:<br>
</td>
<td>
<select name="assetclassgroup_id">
<?php
$result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name FROM assetclassgroup ORDER BY assetclassgroup_id");
while ($row = mysql_fetch_object($result)) {
if ($row->assetclassgroup_id==$assetclassgroup_id) {
$selected = "selected";
} else {
$selected = "";
}
echo '<option value="' . $row->assetclassgroup_id . '" ' . $selected . '>' . $row->assetclassgroup_name. '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,51 @@
<?php
include("header.php");
// get id
$assetclassgroup_id = $_GET['assetclassgroup_id'];
// get assetclassgroup info
$result = mysql_query("SELECT assetclassgroup_name, color FROM assetclassgroup WHERE assetclassgroup_id='$assetclassgroup_id'");
while ($row = mysql_fetch_object($result)) {
$assetclassgroup_name = $row->assetclassgroup_name;
$color = $row->color;
}
?>
<table border="0">
<tr>
<td>
<b>Assetclass Groupname:</b>
</td>
<td>
<?php echo $assetclassgroup_name; ?>
</td>
</tr>
<tr>
<td>
<b>Color:</b>
</td>
<td>
<img src="images/<?php echo $color; ?>.jpg">
</td>
</tr>
<tr>
<td>
<b>Assetclass(es):</b>
</td>
<td>
<?php
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass WHERE assetclassgroup_id='$assetclassgroup_id' ORDER BY assetclass_name");
while ($row = mysql_fetch_object($result)) {
echo '<a href="assetclassview.php?assetclass_id=' . $row->assetclass_id . '">' . $row->assetclass_name . '</a><br>';
}
?>
</td>
</tr>
</table>
<?php
include("footer.php");
?>

@ -0,0 +1,70 @@
<?php
include("header.php");
// get id
$assetclass_id = $_GET['assetclass_id'];
// get assetclassgroup info
$result = mysql_query("SELECT ac.assetclassgroup_id, ac.assetclass_name, acg.assetclassgroup_name FROM assetclass ac, assetclassgroup acg WHERE ac.assetclass_id='$assetclass_id' AND acg.assetclassgroup_id=ac.assetclassgroup_id");
while ($row = mysql_fetch_object($result)) {
$assetclass_name = $row->assetclass_name;
$assetclassgroup_id = $row->assetclassgroup_id;
$assetclassgroup_name = $row->assetclassgroup_name;
}
?>
<table border="0">
<tr>
<td>
<b>Assetclass Name:</b>
</td>
<td>
<?php echo $assetclass_name; ?>
</td>
</tr>
<tr>
<td>
<b>Assetclass Groupname:</b>
</td>
<td>
<a href="assetclassgroupview.php?assetclassgroup_id=<?php echo $assetclassgroup_id; ?>"><?php echo $assetclassgroup_name; ?></a>
</td>
</tr>
<tr>
<td>
<b>Asset(s):</b><br>
</td>
<td>
<?php
$result = mysql_query("SELECT asset_id, asset_name FROM asset WHERE assetclass_id='$assetclass_id' ORDER BY asset_name");
while ($row = mysql_fetch_object($result)) {
echo '<a href="assetview.php?asset_id=' . $row->asset_id . '">' . $row->asset_name . '</a><br>';
}
?>
</td>
</tr>
</table>
<p>
<?php
// display only if admin
if($_SESSION['suser_level'] >= 2) {
?>
<table border="0">
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assetclassedit.php?assetclass_id=<?php echo $assetclass_id; ?>">Modify assetclass</a>
</td>
</tr>
</table>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,17 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
$asset_id = $_GET['asset_id'];
mysql_query("DELETE FROM asset WHERE asset_id='$asset_id'") or die(mysql_error());
mysql_query("DELETE FROM node WHERE asset_id='$asset_id'") or die(mysql_error());
header("Location: asset.php");
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,96 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$asset_id = $_POST['asset_id'];
$asset_name = $_POST['asset_name'];
$hostname = $_POST['hostname'];
$assetclass_id = $_POST['assetclass_id'];
$asset_info = $_POST['asset_info'];
mysql_query("UPDATE asset SET asset_name='$asset_name', hostname='$hostname', assetclass_id='$assetclass_id', asset_info='$asset_info' WHERE asset_id='$asset_id'") or die(mysql_error());
header_location("assetview.php?asset_id=" . $asset_id);
}
$asset_id = $_GET['asset_id'];
// get current information
$result = mysql_query("SELECT asset_name, hostname, assetclass_id, asset_info FROM asset WHERE asset_id='$asset_id'");
while ($row = mysql_fetch_object($result)) {
$asset_name = $row->asset_name;
$hostname = $row->hostname;
$assetclass_id = $row->assetclass_id;
$asset_info = $row->asset_info;
}
?>
<form method="POST" action="assetedit.php">
<input type="hidden" name="asset_id" value="<?php echo $asset_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Edit asset:</b><br>
</td>
</tr>
<tr>
<td>
Asset name:
</td>
<td>
<input type="text" name="asset_name" value="<?php echo $asset_name; ?>">
</td>
</tr>
<tr>
<td>
Hostname:
</td>
<td>
<input type="text" name="hostname" value="<?php echo $hostname; ?>">
</td>
</tr>
<tr>
<td>
Asset class:
</td>
<td>
<select name="assetclass_id">
<?php
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name");
while ($row = mysql_fetch_object($result)) {
if ($row->assetclass_id==$assetclass_id) {
$selected = 'selected';
} else {
$selected = '';
}
echo '<option value="' . $row->assetclass_id . '" ' . $selected . '>' . $row->assetclass_name . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>
Asset info:
</td>
<td>
<textarea name="asset_info"><?php echo $asset_info; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,158 @@
<?php
include("header.php");
// get id
$asset_id = $_GET['asset_id'];
// get asset info
$result = mysql_query("SELECT a.asset_name, a.hostname, a.asset_info, ac.assetclass_id, ac.assetclass_name FROM asset a, assetclass ac WHERE a.asset_id='$asset_id' AND ac.assetclass_id=a.assetclass_id");
while ($row = mysql_fetch_object($result)) {
$asset_name = $row->asset_name;
$hostname = $row->hostname;
$asset_info = $row->asset_info;
$assetclass_id = $row->assetclass_id;
$assetclass_name = $row->assetclass_name;
}
?>
<table border="0">
<tr>
<td>
<b>Asset name:</b>
</td>
<td>
<?php echo $asset_name; ?>
</td>
</tr>
<tr>
<td>
<b>Hostname:</b>
</td>
<td>
<?php echo $hostname; ?>
</td>
</tr>
<tr>
<td>
<b>Asset class:</b>
</td>
<td>
<a href="assetclassview.php?assetclass_id=<?php echo $assetclass_id; ?>"><?php echo $assetclass_name; ?></a>
</td>
</tr>
<tr>
<td>
<b>Asset info:</b>
</td>
<td>
<?php echo nl2br($asset_info); ?>
</td>
</tr>
</table>
<?php
// get node info
$nodecount=0;
$result = mysql_query("SELECT n.node_id, n.ip, n.mac, n.dns1, n.dns2, n.node_info, s.subnet_id, s.subnet_address, s.subnet_mask FROM node n, subnet s WHERE asset_id='$asset_id' AND s.subnet_id=n.subnet_id ORDER BY INET_ATON(n.ip)");
while ($row = mysql_fetch_object($result)) {
$node_id = $row->node_id;
$ip = $row->ip;
$mac = write_mac($row->mac);
$dns1 = $row->dns1;
$dns2 = $row->dns2;
$subnet_id = $row->subnet_id;
$node_info = $row->node_info;
$subnet_address = $row->subnet_address;
$subnet_mask = $row->subnet_mask;
$nodecount++;
?>
<p>
<table border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<b>Node #<?php echo $nodecount; ?></b>
</td>
</tr>
<tr>
<td>
<b>IP Address:</b>
</td>
<td>
<a href="nodeview.php?node_id=<?php echo $node_id; ?>"><?php echo $ip; ?></a>
</td>
</tr>
<tr>
<td>
<b>Subnet:</b>
</td>
<td>
<a href="subnetview.php?subnet_id=<?php echo $subnet_id; ?>&page=<?php echo page($ip); ?>"><?php echo $subnet_address; ?>/<?php echo $subnet_mask; ?></a>
</td>
</tr>
<tr>
<td>
<b>MAC Address:</b>
</td>
<td>
<?php echo $mac; ?>
</td>
</tr>
<tr>
<td>
<b>DNS name:</b>
</td>
<td>
<?php echo $dns1; ?>
</td>
</tr>
<tr>
<td>
<b>DNS alias:</b>
</td>
<td>
<?php echo $dns2; ?>
</td>
</tr>
<tr>
<td>
<b>Node info:</b>
</td>
<td>
<?php echo nl2br($node_info); ?>
</td>
</tr>
</table>
<?php
}
// display only if admin
if($_SESSION['suser_level'] >= 2) {
?>
<p>
<table border="0">
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assetedit.php?asset_id=<?php echo $asset_id; ?>">Modify asset</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assetdel.php?asset_id=<?php echo $asset_id; ?>">Delete asset</a>
</td>
</tr>
</table>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,115 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$ip = $_POST['ip'];
$mac = strip_mac($_POST['mac']);
$subnet_id = $_POST['subnet_id'];
$asset_id = $_POST['asset_id'];
$node_info = $_POST['node_info'];
// DNS1
if (!empty($_POST['dns1']) && isset($_POST['dns1suffix'])) {
$dns1 = $_POST['dns1'] . $config_dns1suffix;
} else {
$dns1 = $_POST['dns1'];
}
// DNS2
if (!empty($_POST['dns2']) && isset($_POST['dns2suffix'])) {
$dns2 = $_POST['dns2'] . $config_dns2suffix;
} else {
$dns2 = $_POST['dns2'];
}
mysql_query("INSERT INTO node (ip, mac, dns1, dns2, subnet_id, asset_id, node_info) VALUE ('$ip', '$mac', '$dns1', '$dns2', '$subnet_id', '$asset_id', '$node_info')") or die(mysql_error());
header_location("assetview.php?asset_id=" . $asset_id);
}
$ip = $_GET['ip'];
$subnet_id = $_GET['subnet_id'];
?>
<form method="POST" action="assigniptoasset.php">
<input type="hidden" name="ip" value="<?php echo $ip; ?>">
<input type="hidden" name="subnet_id" value="<?php echo $subnet_id; ?>">
<table border="0">
<tr>
<td>
<b>Assign <?php echo $ip; ?>:</b><br>
</td>
</tr>
<tr>
<td>
Asset:
</td>
<td>
<select name="asset_id">
<?php
$result = mysql_query("SELECT asset_id, asset_name FROM asset ORDER BY asset_name");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->asset_id . '">' . $row->asset_name . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>
MAC address:
</td>
<td>
<input type="text" name="mac">
</td>
</tr>
<tr>
<td>
DNS name:
</td>
<td>
<input type="text" name="dns1">
</td>
<td>
<input type="checkbox" name="dns1suffix" checked><?php echo $config_dns1suffix; ?>
</td>
</tr>
<tr>
<td>
DNS alias:
</td>
<td>
<input type="text" name="dns2">
</td>
<td>
<input type="checkbox" name="dns2suffix" checked><?php echo $config_dns2suffix; ?>
</td>
</tr>
<tr>
<td>
Node info:
</td>
<td>
<textarea name="node_info"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,59 @@
<?php
include("header.php");
$ip = $_GET['ip'];
$subnet_id = $_GET['subnet_id'];
// get node info
$result = mysql_query("SELECT subnet_address, subnet_mask FROM subnet WHERE subnet_id='$subnet_id'");
while ($row = mysql_fetch_object($result)) {
$subnet_address = $row->subnet_address;
$subnet_mask = $row->subnet_mask;
}
?>
<table border="0">
<tr>
<td>
<b>IP:</b>
</td>
<td>
<?php echo $ip; ?>
</td>
</tr>
<tr>
<td>
<b>Subnet:</b>
</td>
<td>
<a href="subnetview.php?subnet_id=<?php echo $subnet_id; ?>&page=<?php echo page($ip); ?>"><?php echo $subnet_address; ?>/<?php echo $subnet_mask; ?></a>
</td>
</tr>
</table>
<?php
// display only if admin
if($_SESSION['suser_level'] >= 2) {
?>
<p>
<table border="0">
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assigniptoasset.php?ip=<?php echo $ip; ?>&subnet_id=<?php echo $subnet_id; ?>">Assign IP to asset</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="nodeadd.php?ip=<?php echo $ip; ?>&subnet_id=<?php echo $subnet_id; ?>">Create new asset</a>
</td>
</tr>
</table>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,53 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$location_id = $_POST['location_id'];
$subnet_id = $_POST['subnet_id'];
mysql_query("INSERT INTO subnetlocation (location_id, subnet_id) VALUE ('$location_id', '$subnet_id')") or die(mysql_error());
header("Location: location.php");
}
$location_id = $_GET['location_id'];
?>
<form method="POST" action="assignlocationtosubnet.php">
<input type="hidden" name="location_id" value="<?php echo $location_id; ?>">
<table border="0">
<tr>
<td>
<b>Assign to:</b><br>
</td>
<td>
<select name="subnet_id">
<?php
$result = mysql_query("SELECT subnet_id, subnet_address FROM subnet ORDER BY INET_ATON(subnet_address)");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->subnet_id . '">' . $row->subnet_address . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,58 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$location_id = $_POST['location_id'];
$subnet_id = $_POST['subnet_id'];
mysql_query("INSERT INTO subnetlocation (location_id, subnet_id) VALUE ('$location_id', '$subnet_id')") or die(mysql_error());
header("Location: subnet.php");
}
$subnet_id = $_GET['subnet_id'];
?>
<form method="POST" action="assignsubnettolocation.php">
<input type="hidden" name="subnet_id" value="<?php echo $subnet_id; ?>">
<table border="0">
<tr>
<td>
<b>Assign to:</b><br>
</td>
<td>
<select name="location_id">
<?php
function display_children($parent, $level) {
$result = mysql_query("SELECT location_id, location_name FROM location WHERE parent='$parent' ORDER BY location_name");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->location_id . '">' . str_repeat('&nbsp;&nbsp;&nbsp;',$level) . $row->location_name . '</option>';
display_children($row->location_id, $level+1);
}
}
display_children('',0);
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,53 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$vlan_id = $_POST['vlan_id'];
$subnet_id = $_POST['subnet_id'];
mysql_query("UPDATE subnet SET vlan_id='$vlan_id' WHERE subnet_id='$subnet_id'") or die(mysql_error());
header("location: vlan.php");
}
$vlan_id = $_GET['vlan_id'];
?>
<form method="POST" action="assignvlantosubnet.php">
<input type="hidden" name="vlan_id" value="<?php echo $vlan_id; ?>">
<table border="0">
<tr>
<td>
<b>Assign to:</b><br>
</td>
<td>
<select name="subnet_id">
<?php
$result = mysql_query("SELECT subnet_id, subnet_address FROM subnet ORDER BY subnet_address");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->subnet_id . '">' . $row->subnet_address . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,17 @@
<?php
// version
$config_version = 'v0.1';
// db connection
$mysql_host = "localhost";
$mysql_username = "dbuser";
$mysql_password = "dbpass";
$mysql_dbname = "dbname";
// standard password for new users
$config_user_pass = "welcome";
// domain suffix for dns input fields
$config_dns1suffix = '.your.domain';
$config_dns2suffix = '.your.domain';
?>

@ -0,0 +1,4 @@
<?php
mysql_connect($mysql_host,$mysql_username,$mysql_password);
mysql_select_db($mysql_dbname);
?>

@ -0,0 +1,20 @@
<?php
// start footer output
?>
<hr>
<table border="0" width="100%">
<tr>
<td align="center">
<a href="index.php" class="label">IP Reg <?php echo $config_version; ?></a>
</td>
</tr>
</table>
</body>
</html>
<?php
ob_end_flush();
?>

@ -0,0 +1,69 @@
<?php
// strip mac address to 12 char string
function strip_mac($mac) {
$mac = str_replace('-', '', $mac);
$mac = str_replace(':', '', $mac);
$mac = str_replace('.', '', $mac);
$mac = str_replace(',', '', $mac);
$mac = str_replace(' ', '', $mac);
$mac = strtoupper($mac);
return ($mac);
}
// rebuild mac address
function write_mac($mac) {
// check for invalid mac
if (strlen($mac)!=12) {
return $mac;
} else {
$mac1 = substr($mac, 0, 2);
$mac2 = substr($mac, 2, 2);
$mac3 = substr($mac, 4, 2);
$mac4 = substr($mac, 6, 2);
$mac5 = substr($mac, 8, 2);
$mac6 = substr($mac, 10, 2);
$mac = $mac1 . '-' . $mac2 . '-' . $mac3 . '-' . $mac4 . '-' . $mac5 . '-' . $mac6;
return $mac;
}
}
// redirect page
function header_location($location) {
return header("location: " . $location);
exit;
}
// get location name and that of its parents and return with links to the locations
function location_name($location_id, $seperator) {
// create an array
$location_name = array();
// get location name(s)
$result = mysql_query("SELECT location_name, parent FROM location WHERE location_id='$location_id'");
while ($row = mysql_fetch_object($result)) {
// put this parent before any children
array_unshift($location_name, $row->location_name);
// repeat
location_name($row->parent, '.');
}
// count total no. of found locations
$location_count = count($location_name);
// display location for every array value
for ($i = 0; $i < $location_count; $i++ ) {
echo '<a href="locationview.php?location_id=' . $location_id . '">' . $location_name[$i] . '</a>' . $seperator;
}
}
// calculate page for pagination (pagination is used in subnetview.php)
function page($ip) {
$iprange = explode('.', $ip);
$iprange3 = $iprange[2];
return $iprange3;
}
?>

@ -0,0 +1,65 @@
<?php
session_start();
ob_start();
// includes
include("config.php");
include("dbconnect.php");
include("functions.php");
// check for session
if(empty($_SESSION['suser_id'])) {
header("Location: login.php");
exit;
}
// fill search box
if (isset($_POST['search'])) {
$search = $_POST['search'];
$_SESSION['search'] = $search;
} else {
if(isset($_SESSION['search'])) {
$search = $_SESSION['search'];
} else {
$search = '';
}
}
// start header output
?>
<html>
<header>
<title>IP Reg</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
</header>
<body>
<form method="POST" action="search.php">
<table border="0" width="100%">
<tr>
<td>
View by: <a href="asset.php">Asset</a> -
<a href="assetclass.php">Assetclass</a> -
<a href="location.php">Location</a> -
<a href="subnet.php">Subnet</a> -
<a href="vlan.php">VLAN</a>&nbsp;
.:<input type="text" name="search" value="<?php echo $search; ?>"><input type="submit" value="Search!">
</td>
<td align="right">
<?php
$suser_id = $_SESSION['suser_id'];
$result = mysql_query("SELECT displayname FROM user WHERE user_id='$suser_id'");
while ($row = mysql_fetch_object($result)) {
echo $displayname = $row->displayname . ' - ';
}
?>
<a href="options.php">Options</a> -
<a href="logout.php">Log out</a>
</td>
</tr>
</table>
</form>
<hr>

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

@ -0,0 +1,81 @@
<?php
include("header.php");
// calculate stats
$query = mysql_query("SELECT asset_id FROM asset") or die(mysql_error());
$assetcount = mysql_num_rows($query);
$query = mysql_query("SELECT location_id FROM location") or die(mysql_error());
$locationcount = mysql_num_rows($query);
$query = mysql_query("SELECT node_id FROM node") or die(mysql_error());
$nodecount = mysql_num_rows($query);
$query = mysql_query("SELECT subnet_id FROM subnet") or die(mysql_error());
$subnetcount = mysql_num_rows($query);
$query = mysql_query("SELECT vlan_id FROM vlan") or die(mysql_error());
$vlancount = mysql_num_rows($query);
?>
<table border="0">
<tr>
<td>
<b>IP Reg <?php echo $config_version; ?></b>
</td>
</tr>
</table>
<p>
<table border="0">
<tr>
<td colspan="2">
<b>Statistics:</b>
</td>
</tr>
<tr>
<td width="100">
Assets:
</td>
<td align="right">
<?php echo $assetcount; ?>
</td>
</tr>
<tr>
<td>
Locations:
</td>
<td align="right">
<?php echo $locationcount; ?>
</td>
</tr>
<tr>
<td>
Nodes:
</td>
<td align="right">
<?php echo $nodecount; ?>
</td>
</tr>
<tr>
<td>
Subnets:
</td>
<td align="right">
<?php echo $subnetcount; ?>
</td>
</tr>
<tr>
<td>
VLANs:
</td>
<td align="right">
<?php echo $vlancount; ?>
</td>
</tr>
</table>
<?php
include("footer.php");
?>

@ -0,0 +1,136 @@
--
-- Table structure for table `asset`
--
CREATE TABLE `asset` (
`asset_id` int(10) NOT NULL auto_increment,
`asset_name` varchar(100) NOT NULL default '',
`hostname` varchar(100) NOT NULL default '',
`assetclass_id` int(10) NOT NULL default '0',
`asset_info` text NOT NULL,
PRIMARY KEY (`asset_id`)
) ;
--
-- Table structure for table `assetclass`
--
CREATE TABLE `assetclass` (
`assetclass_id` int(10) NOT NULL auto_increment,
`assetclassgroup_id` int(10) NOT NULL default '0',
`assetclass_name` varchar(100) NOT NULL default '',
PRIMARY KEY (`assetclass_id`)
) ;
INSERT INTO `assetclass` VALUES ('', 1, 'Access device');
INSERT INTO `assetclass` VALUES ('', 1, 'Firewall');
INSERT INTO `assetclass` VALUES ('', 1, 'HUB');
INSERT INTO `assetclass` VALUES ('', 1, 'Router');
INSERT INTO `assetclass` VALUES ('', 1, 'Switch');
INSERT INTO `assetclass` VALUES ('', 2, 'Server');
INSERT INTO `assetclass` VALUES ('', 2, 'NAS');
INSERT INTO `assetclass` VALUES ('', 3, 'IP Phone');
INSERT INTO `assetclass` VALUES ('', 4, 'Laptop');
INSERT INTO `assetclass` VALUES ('', 4, 'PC');
INSERT INTO `assetclass` VALUES ('', 4, 'Printer');
INSERT INTO `assetclass` VALUES ('', 4, 'Thin Client');
--
-- Table structure for table `assetclassgroup`
--
CREATE TABLE `assetclassgroup` (
`assetclassgroup_id` int(10) NOT NULL auto_increment,
`assetclassgroup_name` varchar(100) NOT NULL default '',
`color` varchar(10) NOT NULL default '',
PRIMARY KEY (`assetclassgroup_id`)
) ;
INSERT INTO `assetclassgroup` VALUES ('', 'Network', 'green');
INSERT INTO `assetclassgroup` VALUES ('', 'Servers', 'red');
INSERT INTO `assetclassgroup` VALUES ('', 'VOIP', 'orange');
INSERT INTO `assetclassgroup` VALUES ('', 'Workstations', 'blue');
INSERT INTO `assetclassgroup` VALUES ('', 'Other', 'black');
--
-- Table structure for table `location`
--
CREATE TABLE `location` (
`location_id` int(10) NOT NULL auto_increment,
`location_name` varchar(100) NOT NULL default '',
`parent` int(1) NOT NULL default '0',
`location_info` text NOT NULL,
PRIMARY KEY (`location_id`)
) ;
--
-- Table structure for table `node`
--
CREATE TABLE `node` (
`node_id` int(10) NOT NULL auto_increment,
`ip` varchar(15) NOT NULL default '',
`mac` varchar(12) NOT NULL default '',
`dns1` varchar(100) NOT NULL default '',
`dns2` varchar(100) NOT NULL default '',
`subnet_id` int(10) NOT NULL default '0',
`asset_id` int(10) NOT NULL default '0',
`node_info` text NOT NULL,
PRIMARY KEY (`node_id`)
) ;
--
-- Table structure for table `subnet`
--
CREATE TABLE `subnet` (
`subnet_id` int(10) NOT NULL auto_increment,
`subnet_address` varchar(15) NOT NULL default '',
`subnet_mask` int(2) NOT NULL default '0',
`vlan_id` int(10) NOT NULL default '0',
`subnet_info` text NOT NULL,
PRIMARY KEY (`subnet_id`)
) ;
--
-- Table structure for table `subnetlocation`
--
CREATE TABLE `subnetlocation` (