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` (
`subnetlocation_id` int(10) NOT NULL auto_increment,
`subnet_id` int(10) NOT NULL default '0',
`location_id` int(10) NOT NULL default '0',
PRIMARY KEY (`subnetlocation_id`)
) ;
--
-- Table structure for table `user`
--
CREATE TABLE `user` (
`user_id` int(10) NOT NULL auto_increment,
`user_name` varchar(100) NOT NULL default '',
`user_pass` varchar(32) NOT NULL default '',
`user_level` int(1) NOT NULL default '0',
`displayname` varchar(100) NOT NULL default '',
PRIMARY KEY (`user_id`)
) ;
--
-- Dumping data for table `user`
--
INSERT INTO `user` VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 2, 'admin');
--
-- Table structure for table `vlan`
--
CREATE TABLE `vlan` (
`vlan_id` int(10) NOT NULL auto_increment,
`vlan_number` int(3) NOT NULL default '0',
`vlan_name` varchar(100) NOT NULL default '',
`vlan_info` text NOT NULL,
PRIMARY KEY (`vlan_id`)
) ;

@ -0,0 +1,18 @@
---
--- IP Reg 0.1
--- http://ipreg.sourceforge.net
---
Installation instructions
1) Copy all files to your webserver
2) Create your MYSQL-database
3) Use install.sql to create the tables and insert the first data
4) Update config.php with your settings
5) Start your browser, log in with admin/admin
6) Please report your comments at http://ipreg.sourceforge.net

@ -0,0 +1,48 @@
<?php
include("header.php");
function display_subnet ($location_id) {
$subnet = '';
$result = mysql_query("SELECT s.subnet_id, s.subnet_address, s.subnet_mask FROM subnet s INNER JOIN subnetlocation sl ON s.subnet_id=sl.subnet_id WHERE sl.location_id='$location_id' ORDER BY subnet_address");
while ($row = mysql_fetch_object($result)) {
$subnet .= '<a href="subnetview.php?subnet_id='. $row->subnet_id . '">' . $row->subnet_address . '/' . $row->subnet_mask . '</a><br>';
}
return $subnet;
}
// displaysubnet link (or not)
if (isset($_GET['displaysubnet'])) {
$displaysubnetlink = '<a href="location.php">(hide subnets)</a>';
} else {
$displaysubnetlink = '<a href="location.php?displaysubnet">(display subnets)</a>';
}
// "menu"
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)) {
if (isset($_GET['displaysubnet'])) {
$displaysubnet = display_subnet($row->location_id);
} else {
$displaysubnet = '';
}
echo '<tr><td>' . str_repeat('&nbsp;&nbsp;&nbsp;',$level) . '<a href="locationview.php?location_id=' . $row->location_id . '">' . $row->location_name . '</a></td><td>&nbsp;</td><td>' . $displaysubnet . '</td></tr>';
display_children($row->location_id, $level+1);
}
}
?>
<table border="0">
<tr>
<td>
<b>Location:</b> <?php echo $displaysubnetlink; ?>
</td>
</tr>
<?php display_children('',0); ?>
</table>
<?php
include("footer.php");
?>

@ -0,0 +1,62 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$location_name = $_POST['location_name'];
$parent = $_POST['parent'];
mysql_query("INSERT INTO location (location_name, parent) VALUE ('$location_name', '$parent')") or die(mysql_error());
$location_id = mysql_insert_id();
header_location("locationview.php?location_id=" . $location_id);
}
?>
<form method="POST" action="locationadd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add new location:</b><br>
</td>
</tr>
<tr>
<td>
Location name:
</td>
<td>
<input type="text" name="location_name">
</td>
</tr>
<tr>
<td>
Parent:
</td>
<td>
<select name="parent">
<option value="0">(none)</option>
<?php
$result = mysql_query("SELECT location_name, location_id FROM location ORDER BY location_name");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->location_id . '">' . $row->location_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,87 @@
<?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'];
$location_name = $_POST['location_name'];
$parent = $_POST['parent'];
$location_info = $_POST['location_info'];
mysql_query("UPDATE location SET location_name='$location_name', parent='$parent', location_info='$location_info' WHERE location_id='$location_id'") or die(mysql_error());
header_location("locationview.php?location_id=" . $location_id);
}
$location_id = $_GET['location_id'];
// get current information
$result = mysql_query("SELECT location_name, parent, location_info FROM location WHERE location_id='$location_id'");
while ($row = mysql_fetch_object($result)) {
$location_name = $row->location_name;
$location_info = $row->location_info;
$parent = $row->parent;
}
?>
<form method="POST" action="locationedit.php">
<input type="hidden" name="location_id" value="<?php echo $location_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Edit location:</b><br>
</td>
</tr>
<tr>
<td>
Location name:
</td>
<td>
<input type="text" name="location_name" value="<?php echo $location_name; ?>">
</td>
</tr>
<tr>
<td>
Parent:
</td>
<td>
<select name="parent">
<option value="0">(none)</option>
<?php
$result = mysql_query("SELECT location_name, location_id FROM location ORDER BY location_name");
while ($row = mysql_fetch_object($result)) {
if ($row->location_id==$parent) {
$selected = 'selected';
} else {
$selected = '';
}
echo '<option value="' . $row->location_id . '" ' . $selected . '>' . $row->location_name . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>
Location info:
</td>
<td>
<textarea name="location_info"><?php echo $location_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,90 @@
<?php
include("header.php");
// get id
$location_id = $_GET['location_id'];
// get all info
$result = mysql_query("SELECT location_name, location_info FROM location WHERE location_id='$location_id'");
while ($row = mysql_fetch_object($result)) {
$location_info = $row->location_info;
}
?>
<table border="0">
<tr>
<td>
<b>Location name:</b>
</td>
<td>
<?php echo location_name($location_id, ''); ?>
</td>
</tr>
<tr>
<td>
<b>Location info:</b>
</td>
<td>
<?php echo nl2br($location_info); ?>
</td>
</tr>
<tr>
<td>
<b>Subnet(s):</b>
</td>
<td>
<?php
// search subnets for this location
$result = mysql_query("SELECT s.subnet_id, s.subnet_address, s.subnet_mask FROM subnet s INNER JOIN subnetlocation sl ON s.subnet_id=sl.subnet_id WHERE sl.location_id='$location_id'");
while ($row = mysql_fetch_object($result)) {
echo '<a href="subnetview.php?subnet_id='. $row->subnet_id . '">' . $row->subnet_address . '/' . $row->subnet_mask . '</a><br>';
}
?>
</td>
</tr>
<tr>
<td>
<b>Sub-location(s):</b>
</td>
<td>
<?php
// search sub-locations for this location
$result = mysql_query("SELECT location_id, location_name FROM location WHERE parent='$location_id' ORDER BY location_name");
while ($row = mysql_fetch_object($result)) {
echo '<a href="locationview.php?location_id='. $row->location_id . '">' . $row->location_name . '</a><br>';
}
?>
</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="locationedit.php?location_id=<?php echo $location_id; ?>">Modify location</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assignlocationtosubnet.php?location_id=<?php echo $location_id; ?>">Assign subnet</a>
</td>
</tr>
</table>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,89 @@
<?php
session_start();
ob_start();
// includes
include("config.php");
include("dbconnect.php");
include("functions.php");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
if(isset($_POST['user_name']) && isset($_POST['user_pass']) && trim($_POST['user_name']) <> "" && trim($_POST['user_pass']) <> "") {
$user_name = $_POST['user_name'];
$result = mysql_query("SELECT user_id, user_pass, user_level FROM user WHERE user_name='$user_name'") or die(mysql_error());
if(mysql_num_rows($result) > 0) {
if(!strcmp(md5($_POST['user_pass']), mysql_result($result, 0, "user_pass"))) {
// all ok, user logged in
$_SESSION['suser_id'] = mysql_result($result, 0, "user_id");
$_SESSION['suser_level'] = mysql_result($result, 0, "user_level");
header("Location: index.php");
} else {
// not ok, break session
$_SESSION = array();
session_destroy();
}
// clear mysql-result
mysql_free_result($result);
}
}
echo '<b>Error!</b>';
}
?>
<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>
<br>
<hr>
<form action="login.php" method="post">
<table border="0">
<tr>
<td colspan="2">
<b>IP Reg <?php echo $config_version; ?></b>
</td>
</tr>
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="user_name">
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input type="password" name="user_pass">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<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>

@ -0,0 +1,11 @@
<?php
include("header.php");
// clear and destroy session
$_SESSION = array();
session_destroy();
header("Location: index.php");
include("footer.php");
?>

@ -0,0 +1,191 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$ip = str_replace(' ', '', $_POST['ip']);
// IP in use?
$result = mysql_query("SELECT * FROM node WHERE ip='$ip'");
if (mysql_num_rows($result)!=0) {
echo 'IP in use!';
exit;
} else {
$asset_name = $_POST['asset_name'];
$hostname = $_POST['hostname'];
$assetclass_id = $_POST['assetclass_id'];
mysql_query("INSERT INTO asset (asset_name, hostname, assetclass_id) VALUE ('$asset_name', '$hostname', '$assetclass_id')") or die(mysql_error());
// get asset_id for new node
$asset_id = mysql_insert_id();
$mac = strip_mac($_POST['mac']);
// 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'];
}
$subnet_id = $_POST['subnet_id'];
mysql_query("INSERT INTO node (ip, mac, dns1, dns2, subnet_id, asset_id) VALUE ('$ip', '$mac', '$dns1', '$dns2', '$subnet_id', '$asset_id')") or die(mysql_error());
$node_id = mysql_insert_id();
header_location("assetview.php?asset_id=" . $asset_id);
}
}
// check for ip
if (isset($_GET['ip'])) {
$ip = $_GET['ip'];
} else {
$ip = "";
}
// check for subnet_id
if (isset($_GET['subnet_id'])) {
$subnet_id = $_GET['subnet_id'];
} else {
$subnet_id = '';
}
?>
<form method="POST" action="nodeadd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add new node:</b><br>
</td>
</tr>
<tr>
<td>
Asset name:
</td>
<td>
<input type="text" name="asset_name">
</td>
<td>
*
</td>
</tr>
<tr>
<td>
Hostname:
</td>
<td>
<input type="text" name="hostname">
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>
IP Address:
</td>
<td>
<input type="text" name="ip" value="<?php echo $ip; ?>">
</td>
<td>
*
</td>
</tr>
<tr>
<td>
Subnet:<br>
</td>
<td>
<select name="subnet_id">
<?php
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)");
while ($row = mysql_fetch_object($result)) {
if ($row->subnet_id==$subnet_id) {
$selected = ' selected';
} else {
$selected = '';
}
echo '<option value="' . $row->subnet_id . '" ' . $selected . '>' . $row->subnet_address . '/' . $row->subnet_mask . '</option>';
}
?>
</select>
</td>
<td>
*
</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 . '" ' . $selected . '>' . $row->assetclass_name . '</option>';
}
?>
</select>
</td>
<td>
*
</td>
</tr>
<tr>
<td>
MAC Address:
</td>
<td>
<input type="text" name="mac">
</td>
<td>
&nbsp;
</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 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");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
$node_id = $_GET['node_id'];
// get asset id
$result = mysql_query("SELECT asset_id FROM node WHERE node_id='$node_id'") or die(mysql_error());
$asset_id = mysql_result($result, 0, "asset_id");
// delete node
mysql_query("DELETE FROM node WHERE node_id='$node_id'") or die(mysql_error());
// redirect
header("Location: assetview.php?asset_id=" . $asset_id);
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,129 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$node_id = $_POST['node_id'];
$subnet_id = $_POST['subnet_id'];
$mac = strip_mac($_POST['mac']);
$dns1 = $_POST['dns1'];
$dns2 = $_POST['dns2'];
$node_info = $_POST['node_info'];
mysql_query("UPDATE node SET subnet_id='$subnet_id', mac='$mac', dns1='$dns1', dns2='$dns2', node_info='$node_info' WHERE node_id='$node_id'") or die(mysql_error());
header_location("nodeview.php?node_id=" . $node_id);
}
$node_id = $_GET['node_id'];
// get node info
$result = mysql_query("SELECT a.asset_name, n.ip, n.mac, n.dns1, n.dns2, n.subnet_id, n.node_info FROM asset a, node n WHERE node_id='$node_id' AND a.asset_id=n.asset_id");
while ($row = mysql_fetch_object($result)) {
$ip = $row->ip;
$subnet_id = $row->subnet_id;
$mac = $row->mac;
$dns1 = $row->dns1;
$dns2 = $row->dns2;
$node_info = $row->node_info;
$asset_name = $row->asset_name;
}
?>
<form method="POST" action="nodeedit.php">
<input type="hidden" name="node_id" value="<?php echo $node_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Edit node:</b><br>
</td>
</tr>
<tr>
<td>
Asset:
</td>
<td>
<?php echo $asset_name; ?>
</td>
</tr>
<tr>
<td>
IP Address:
</td>
<td>
<?php echo $ip; ?>
</td>
</tr>
<tr>
<td>
Subnet:<br>
</td>
<td>
<select name="subnet_id">
<?php
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)");
while ($row = mysql_fetch_object($result)) {
if ($row->subnet_id==$subnet_id) {
$selected = ' selected';
} else {
$selected = '';
}
echo '<option value="' . $row->subnet_id . '" ' . $selected . '>' . $row->subnet_address . '/' . $row->subnet_mask . '</option>';
}
?>
</select>
</td>
<td>
*
</td>
</tr>
<tr>
<td>
MAC Address:
</td>
<td>
<input type="text" name="mac" value="<?php echo $mac; ?>">
</td>
</tr>
<tr>
<td>
DNS name:
</td>
<td>
<input type="text" name="dns1" value="<?php echo $dns1; ?>">
</td>
</tr>
<tr>
<td>
DNS alias:
</td>
<td>
<input type="text" name="dns2" value="<?php echo $dns2; ?>">
</td>
</tr>
<tr>
<td>
Node info:
</td>
<td>
<textarea name="node_info"><?php echo $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,80 @@
<?php
include("header.php");
// get id
$subnet_id = $_GET['subnet_id'];
// get ordering
if (isset($_GET['order'])) {
$order = $_GET['order'];
} else {
$order = "INET_ATON(n.ip)";
}
?>
<table border="0">
<tr>
<td width="100">
<a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>&order=INET_ATON(n.ip)"><b>IP Address:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>&order=a.asset_name"><b>Asset name:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>&order=a.hostname"><b>Hostname:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>&order=n.mac"><b>MAC Address:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>&order=n.dns1"><b>DNS name:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>&order=n.dns2"><b>DNS alias:</b></a>
</td>
</tr>
<?php
// get node info
$result = mysql_query("SELECT a.asset_id, a.asset_name, a.hostname, n.node_id, n.ip, n.mac, n.dns1, n.dns2 FROM asset a, node n WHERE n.subnet_id='$subnet_id' AND a.asset_id=n.asset_id ORDER BY $order");
while ($row = mysql_fetch_object($result)) {
$asset_id = $row->asset_id;
$asset_name = $row->asset_name;
$hostname = $row->hostname;
$node_id = $row->node_id;
$ip = $row->ip;
$mac = write_mac($row->mac);
$dns1 = $row->dns1;
$dns2 = $row->dns2;
?>
<tr>
<td>
<a href="nodeview.php?node_id=<?php echo $node_id; ?>"><?php echo $ip; ?></a>
</td>
<td>
<a href="assetview.php?asset_id=<?php echo $asset_id; ?>"><?php echo $asset_name; ?></a>
</td>
<td>
<?php echo $hostname; ?>
</td>
<td>
<?php echo $mac; ?>
</td>
<td>
<?php echo $dns1; ?>
</td>
<td>
<?php echo $dns2; ?>
</td>
</tr>
<?php
}
?>
</table>
<?php
include("footer.php");
?>

@ -0,0 +1,109 @@
<?php
include("header.php");
// get id
$node_id = $_GET['node_id'];
// get node info
$result = mysql_query("SELECT a.asset_name, a.asset_id, n.ip, n.mac, n.dns1, n.dns2, n.node_info, s.subnet_id, s.subnet_address, s.subnet_mask FROM asset a, node n, subnet s WHERE n.node_id='$node_id' AND a.asset_id=n.asset_id AND s.subnet_id=n.subnet_id");
while ($row = mysql_fetch_object($result)) {
$asset_id = $row->asset_id;
$asset_name = $row->asset_name;
$ip = $row->ip;
$mac = write_mac($row->mac);
$dns1 = $row->dns1;
$dns2 = $row->dns2;
$node_info = $row->node_info;
$subnet_id = $row->subnet_id;
$subnet_address = $row->subnet_address;
$subnet_mask = $row->subnet_mask;
}
?>
<table border="0">
<tr>
<td>
<b>IP Address:</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>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<td>
<b>Asset name:</b>
</td>
<td>
<a href="assetview.php?asset_id=<?php echo $asset_id; ?>"><?php echo $asset_name; ?></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="nodeedit.php?node_id=<?php echo $node_id; ?>">Modify node</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="nodedel.php?node_id=<?php echo $node_id; ?>">Delete node</a>
</td>
</tr>
</table>
<?php
// end display only if admin
}
include("footer.php");
?>

@ -0,0 +1,77 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
?>
<table border="0">
<tr>
<td>
<b>IP Reg options</b>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assetadd.php">Add new asset</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assetclassadd.php">Add new assetclass</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="locationadd.php">Add new location</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="nodeadd.php">Add new node</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="useradd.php">Add new user</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="subnetadd.php">Add new subnet</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="vlanadd.php">Add new vlan</a>
</td>
</tr>
</table>
<?php
// end display only if admin
}
?>
<p>
<table border="0">
<tr>
<td>
<b>Personal options</b>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="useredit.php">Modify settings</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="userpassedit.php">Modify password</a>
</td>
</tr>
</table>
<?
include("footer.php");
?>

@ -0,0 +1,103 @@
<?php
include("header.php");
// get string that was searched for
if (empty($search)) {
echo 'Nothing to search for...';
exit;
}
$needle = '%' . $search . '%';
// set resultcounter to zero
$resultcounter = 0;
echo '<table border="0">';
// look for asset
$result = mysql_query("SELECT asset_id, asset_name FROM asset WHERE asset_name LIKE '$needle' OR asset_info LIKE '%$needle%' ORDER BY asset_name");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>Asset(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="assetview.php?asset_id=' . $row->asset_id . '">' . $row->asset_name . '</a></td></tr>';
$resultcounter++;
}
// look for location
$result = mysql_query("SELECT location_id, location_name FROM location WHERE location_name LIKE '$needle' OR location_info LIKE '%$needle%' ORDER BY location_name");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>Location(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="locationview.php?location_id=' . $row->location_id . '">' . $row->location_name . '</a></td></tr>';
$resultcounter++;
}
// look for ip
$result = mysql_query("SELECT node_id, ip FROM node WHERE ip LIKE '$needle' ORDER BY ip");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>Registered IP(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="nodeview.php?node_id=' . $row->node_id . '">' . $row->ip . '</a></td></tr>';
$resultcounter++;
}
// look for mac
$mac = strip_mac($needle);
$result = mysql_query("SELECT node_id, mac FROM node WHERE mac LIKE '$mac' ORDER BY mac");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>MAC(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="nodeview.php?node_id=' . $row->node_id . '">' . write_mac($row->mac) . '</a></td></tr>';
$resultcounter++;
}
// look for dns1
$result = mysql_query("SELECT node_id, dns1 FROM node WHERE dns1 LIKE '$needle' ORDER BY dns1");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>DNS name(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="nodeview.php?node_id=' . $row->node_id . '">' . $row->dns1 . '</a></td></tr>';
$resultcounter++;
}
// look for dns2
$result = mysql_query("SELECT node_id, dns2 FROM node WHERE dns2 LIKE '$needle' ORDER BY dns2");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>DNS alias(es):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="nodeview.php?node_id=' . $row->node_id . '">' . $row->dns2 . '</a></td></tr>';
$resultcounter++;
}
// look for subnet
$result = mysql_query("SELECT subnet_id, subnet_address FROM subnet WHERE subnet_address LIKE '$needle' OR subnet_info LIKE '%$needle%' ORDER BY subnet_address");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>Subnet(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="subnetview.php?subnet_id=' . $row->subnet_id . '">' . $row->subnet_address . '</a></td></tr>';
$resultcounter++;
}
// look for vlan
$result = mysql_query("SELECT vlan_id, vlan_name FROM vlan WHERE vlan_name LIKE '$needle' OR vlan_info LIKE '%$needle%' ORDER BY vlan_name");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>VLAN(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="vlanview.php?vlan_id=' . $row->vlan_id . '">' . $row->vlan_name . '</a></td></tr>';
$resultcounter++;
}
echo '<tr><td>&nbsp;</td></tr>';
echo '<tr><td>Results found: ' . $resultcounter . '</td></tr>';
echo '</table>';
include("footer.php");
?>

@ -0,0 +1,39 @@
body {
background-color: #FFFFFF;
color: #000000;
font-family: Verdana, Arial, Helvetica, Sans-serif;
margin: 12px;
margin-top: 12px;
font-size: 70%;
}
a {
color: #466A8D;
}
a:hover {
color: #E1B100;
}
input {
font-size: 100%;
position: relative;
top: -2px;
font-family: Verdana, Arial, Helvetica, Sans-serif;
}
select {
font-size: 100%;
font-family: Verdana, Sans-serif;
position: relative;
top: -2px;
}
table {
font-size: 100%;
}
td {
vertical-align: top;
height: 18px;
}

@ -0,0 +1,23 @@
<?php
include("header.php");
?>
<table border="0">
<tr>
<td>
<b>Subnet:</b><br>
</td>
</tr>
<?php
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)");
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="subnetview.php?subnet_id=' . $row->subnet_id . '">' . $row->subnet_address . '/' . $row->subnet_mask . '</a></td></tr>';
}
?>
</table>
<?php
include("footer.php");
?>

@ -0,0 +1,54 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$subnet_address= $_POST['subnet_address'];
$subnet_mask = $_POST['subnet_mask'];
mysql_query("INSERT INTO subnet (subnet_address, subnet_mask) VALUE ('$subnet_address', '$subnet_mask')") or die(mysql_error());
$subnet_id = mysql_insert_id();
header_location("subnetview.php?subnet_id=" . $subnet_id);
}
?>
<form method="POST" action="subnetadd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add new subnet:</b><br>
</td>
</tr>
<tr>
<td>
Subnet Address:
</td>
<td>
<input type="text" name="subnet_address">
</td>
</tr>
<tr>
<td>
Subnet Mask:
</td>
<td>
<input type="text" name="subnet_mask" size="2"> (16-30)
</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,100 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$subnet_id = $_POST['subnet_id'];
$subnet_address= $_POST['subnet_address'];
$subnet_mask = $_POST['subnet_mask'];
$vlan_id = $_POST['vlan_id'];
$subnet_info = $_POST['subnet_info'];
mysql_query("UPDATE subnet SET subnet_address='$subnet_address', subnet_mask='$subnet_mask', vlan_id='$vlan_id', subnet_info='$subnet_info' WHERE subnet_id='$subnet_id'") or die(mysql_error());
header_location("subnetview.php?subnet_id=" . $subnet_id);
}
$subnet_id = $_GET['subnet_id'];
// get current information
$result = mysql_query("SELECT subnet_address, subnet_mask, vlan_id, subnet_info FROM subnet WHERE subnet_id='$subnet_id'");
while ($row = mysql_fetch_object($result)) {
$subnet_address = $row->subnet_address;
$subnet_mask = $row->subnet_mask;
$vlan_id = $row->vlan_id;
$subnet_info = $row->subnet_info;
}
?>
<form method="POST" action="subnetedit.php">
<input type="hidden" name="subnet_id" value="<?php echo $subnet_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Edit subnet:</b><br>
</td>
</tr>
<tr>
<td>
Subnet Address:
</td>
<td>
<input type="text" name="subnet_address" value="<?php echo $subnet_address; ?>">
</td>
</tr>
<tr>
<td>
Subnet Mask:
</td>
<td>
<input type="text" name="subnet_mask" size="2" value="<?php echo $subnet_mask; ?>">
</td>
</tr>
<tr>
<td>
VLAN
</td>
<td>
<select name="vlan_number">
<option value="0">(none)</option>
<?php
$result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan ORDER BY vlan_number");
while ($row = mysql_fetch_object($result)) {
if ($row->vlan_id==$vlan_id) {
$selected = 'selected';
} else {
$selected = '';
}
echo '<option value="' . $row->vlan_id . '" ' . $selected . '>' . $row->vlan_name . ' ('. $row->vlan_number . ')</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>
Subnet info:
</td>
<td>
<textarea name="subnet_info"><?php echo $subnet_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,229 @@
<?php
include("header.php");
// get page
if(isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 0;
}
?>
<script language="javascript">
function linkTo(optVal){
if(optVal=="")
return false;
window.location='subnetview.php?subnet_id='+optVal;
}
</script>
<script type="text/javascript">
function change(id,newtext) {
document.getElementById(id).innerHTML=newtext
}
</script>
<?php
// get all info
$result = mysql_query("SELECT subnet_address, subnet_mask, vlan_id, subnet_info FROM subnet WHERE subnet_id='$subnet_id'");
while ($row = mysql_fetch_object($result)) {
$subnet_address = $row->subnet_address;
$subnet_mask = $row->subnet_mask;
$vlan_id = $row->vlan_id;
$subnet_info = $row->subnet_info;
}
// determine current range
$iprange = explode('.', $subnet_address);
$iprange1 = $iprange[0];
$iprange2 = $iprange[1];
$iprange3 = $iprange[2];
$iprange4 = $iprange[3];
// calculate no. of hosts
$hostcount = pow(2,(32-$subnet_mask));
// is there a need for pagination?
if ($hostcount>256) {
$maxdisplayedip = 256;
// calculate broadcast address and create pagination
if ($hostcount>65536) {
// class A subnet
echo 'Class A subnets (>65536 nodes) are not supported';
exit;
} else {
// class B subnet
$broadcast_address = $iprange1 . '.' . $iprange2 . '.' . ($hostcount/256-1) . '.255';
$pagination = 'Page: <select name="pagination" onchange="linkTo(this.options[this.selectedIndex].value);">';
for ($i=0;$i<($hostcount/256);$i++) {
if ($i==$page) {
$selected = ' selected';
} else {
$selected = '';
}
$pagination .= '<option value="' . $subnet_id . '&page=' . $i . '"' . $selected . '>' . $iprange1 . '.' . $iprange2 . '.' . ($i) . '.0</option>';
}
$pagination .= '</select>';
}
} else {
// // class C subnet so no pagination needed, set static variables
$pagination = '&nbsp;';
$page = 0;
$maxdisplayedip = $hostcount;
$broadcast_address = $iprange1 . '.' . $iprange2 . '.' . $iprange3 . '.' . ($iprange4+$hostcount-1);
}
?>
<table border="0">
<tr>
<td colspan="32">
<b>Subnet: </b><?php echo $subnet_address . '/'. $subnet_mask; ?>
</td>
<td colspan="32" align="right">
<?php echo $pagination; ?>
</td>
</tr>
<?php
echo '<tr>';
for ($i=1;$i<=$maxdisplayedip;$i++) {
// build current ip
$ip = $iprange1 . '.' . $iprange2 . '.' . ($iprange3+$page) . '.' . ($i+$iprange4-1);
// disable subnet_address and broadcast_address
if ($ip==$subnet_address) {
echo '<td><img src="images/cross.jpg" onMouseOver="change(\'remotetext\',\'' . $ip . ' (Subnet address)\')" onMouseOut="change(\'remotetext\',\'&nbsp;\')"></td>';
} else if ($ip==$broadcast_address) {
echo '<td><img src="images/cross.jpg" onMouseOver="change(\'remotetext\',\'' . $ip . ' (Broadcast address)\')" onMouseOut="change(\'remotetext\',\'&nbsp;\')"></td>';
} else {
// check for current ip address
$result = mysql_query("SELECT a.asset_name, acg.color, n.node_id FROM asset a, assetclass ac, assetclassgroup acg, node n WHERE n.ip='$ip' AND a.asset_id=n.asset_id AND ac.assetclass_id=a.assetclass_id AND acg.assetclassgroup_id=ac.assetclassgroup_id");
if (mysql_num_rows($result)==0) {
// ip not in use
echo '<td><a href="assigniptonode.php?ip='. $ip . '&subnet_id=' . $subnet_id . '"><img src="images/grey.jpg" border="0" onMouseOver="change(\'remotetext\',\'' . $ip . '\')" onMouseOut="change(\'remotetext\',\'&nbsp;\')"></a></td>';
} else {
// ip in use
while ($row = mysql_fetch_object($result)) {
$node_id = $row->node_id;
echo '<td><a href="nodeview.php?node_id=' . $node_id . '"><img src="images/' . $row->color . '.jpg" border="0" onMouseOver="change(\'remotetext\',\'' . $ip . '&nbsp;' . $row->asset_name . '\')" onMouseOut="change(\'remotetext\',\'&nbsp;\')"></a></td>';
}
}
}
if ($i%64==0) {
echo '</tr><tr>';
}
}
?>
<tr>
<td colspan="64">
<a id="remotetext">&nbsp;</a>
</td>
</tr>
</table>
<table border="0">
<tr>
<td>
<table border="0">
<tr>
<td>
<b>VLAN(s):</b>
</td>
<td>
<?php
// search vlan(s) for this subnet
$result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan WHERE vlan_id='$vlan_id'");
while ($row = mysql_fetch_object($result)) {
echo '<a href="vlanview.php?vlan_id=' . $row->vlan_id . '">' . $row->vlan_name . ' ('. $row->vlan_number . ')</a>';
}
?>
</td>
</tr>
<tr>
<td>
<b>Location(s):</b>
</td>
<td>
<?php
// search location(s) for this subnet
$result = mysql_query("SELECT l.location_id FROM location l INNER JOIN subnetlocation sl ON l.location_id=sl.location_id WHERE sl.subnet_id='$subnet_id'");
while ($row = mysql_fetch_object($result)) {
echo location_name($row->location_id, '') . '<br>';
}
?>
</td>
</tr>
<tr>
<td>
<b>Subnet info:</b>
</td>
<td>
<?php echo nl2br($subnet_info); ?>
</td>
</tr>
</table>
</td>
<td width="100">
&nbsp;
</td>
<td>
<table border="0">
<tr>
<td>
<img src="images/grey.jpg"> Unassigned
</td>
</tr>
</tr>
<?php
// display assetclass(es)
$result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name, color FROM assetclassgroup ORDER BY assetclassgroup_id");
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><img src="images/' . $row->color . '.jpg"> <a href="assetclassgroupview.php?assetclassgroup_id=' . $row->assetclassgroup_id . '">' . $row->assetclassgroup_name . '</a></td></tr>';
}
?>
</table>
</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="subnetedit.php?subnet_id=<?php echo $subnet_id; ?>">Modify subnet</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assignsubnettolocation.php?subnet_id=<?php echo $subnet_id; ?>">Assign location</a>
</td>
</tr>
<?php
// end display only if admin
}
?>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>">View assigned IP addresses in subnet</a>
</td>
</tr>
</table>
<?php
include("footer.php");
?>

@ -0,0 +1,70 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
// check for unique username
$result = mysql_query("SELECT user_name FROM user WHERE user_name='$user_name'") or die(mysql_error());
if(mysql_num_rows($result) == 0) {
$user_name = $_POST['user_name'];
$user_pass = md5($config_user_pass);
$user_level = $_POST['user_level'];
$displayname = $_POST['user_name'];
mysql_query("INSERT INTO user (user_name, user_pass, user_level, displayname) VALUE ('$user_name', '$user_pass', '$user_level', '$displayname')") or die(mysql_error());
header_location("options.php");
}
echo '<b>Error!</b>';
}
?>
<form method="POST" action="useradd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add user:</b><br>
</td>
</tr>
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="user_name">
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<?php echo $config_user_pass; ?>
</td>
</tr>
<tr>
<td>
Level:
</td>
<td>
<select name="user_level">
<option value="1">View all</option>
<option value="2">Edit all</option>
</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,47 @@
<?php
include("header.php");
// get user_id
$suser_id = $_SESSION['suser_id'];
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$displayname = $_POST['displayname'];
mysql_query("UPDATE user SET displayname='$displayname' WHERE user_id='$suser_id'") or die(mysql_error());
header_location("options.php");
}
// get current information
$result = mysql_query("SELECT displayname FROM user WHERE user_id='$suser_id'");
while ($row = mysql_fetch_object($result)) {
$displayname = $row->displayname;
}
?>
<form method="POST" action="useredit.php">
<table border="0">
<tr>
<td colspan="2">
<b>Modify settings:</b><br>
</td>
</tr>
<tr>
<td>
Displayname:
</td>
<td>
<input type="text" name="displayname" value="<?php echo $displayname; ?>">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?
include("footer.php");
?>

@ -0,0 +1,75 @@
<?php
include("header.php");
// get user_id
$suser_id = $_SESSION['suser_id'];
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
if (trim($_POST['user_passold']) <> "" && trim($_POST['user_passnew1']) && trim($_POST['user_passnew2']) && trim($_POST['user_passnew1']) == trim($_POST['user_passnew2'])) {
$user_passold = $_POST['user_passold'];
$user_passnew = md5($_POST['user_passnew1']);
$result = mysql_query("SELECT user_pass FROM user WHERE user_id='$suser_id'") or die(mysql_error());
// check current pass
if(!strcmp(md5($user_passold), mysql_result($result, 0, "user_pass"))) {
// ok, update pass
mysql_query("UPDATE user SET user_pass='$user_passnew' WHERE user_id='$suser_id'") or die(mysql_error());
header_location("options.php");
}
}
// not ok
echo '<b>Error!</b>';
}
// get current information
$result = mysql_query("SELECT displayname FROM user WHERE user_id='$suser_id'");
while ($row = mysql_fetch_object($result)) {
$displayname = $row->displayname;
}
?>
<form method="POST" action="userpassedit.php">
<table border="0">
<tr>
<td colspan="2">
<b>Modify settings:</b><br>
</td>
</tr>
<tr>
<td>
Current password:
</td>
<td>
<input type="password" name="user_passold">
</td>
</tr>
<tr>
<td>
New password:
</td>
<td>
<input type="password" name="user_passnew1">
</td>
</tr>
<tr>
<td>
Retype new password:
</td>
<td>
<input type="password" name="user_passnew2">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?
include("footer.php");
?>

@ -0,0 +1,23 @@
<?php
include("header.php");
?>
<table border="0">
<tr>
<td>
<b>VLAN:</b><br>
</td>
</tr>
<?php
$result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan ORDER BY vlan_number");
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="vlanview.php?vlan_id=' . $row->vlan_id . '">' . $row->vlan_name . ' ('. $row->vlan_number . ')</a></td></tr>';
}
?>
</table>
<?php
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_name = $_POST['vlan_name'];
$vlan_number= $_POST['vlan_number'];
mysql_query("INSERT INTO vlan (vlan_name, vlan_number) VALUE ('$vlan_name', '$vlan_number')") or die(mysql_error());
header("Location: vlan.php");
}
?>
<form method="POST" action="vlanadd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add new VLAN:</b><br>
</td>
</tr>
<tr>
<td>
VLAN name:
</td>
<td>
<input type="text" name="vlan_name">
</td>
</tr>
<tr>
<td>
VLAN ID:
</td>
<td>
<input type="text" name="vlan_number" size="3">
</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,72 @@
<?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'];
$vlan_name = $_POST['vlan_name'];
$vlan_number = $_POST['vlan_number'];
$vlan_info = $_POST['vlan_info'];
mysql_query("UPDATE vlan SET vlan_name='$vlan_name', vlan_number='$vlan_number', vlan_info='$vlan_info' WHERE vlan_id='$vlan_id'") or die(mysql_error());
header_location("vlanview.php?vlan_id=" . $vlan_id);
}
// get current information
$result = mysql_query("SELECT vlan_name, vlan_number, vlan_info FROM vlan WHERE vlan_id='$vlan_id'");
while ($row = mysql_fetch_object($result)) {
$vlan_name = $row->vlan_name;
$vlan_number = $row->vlan_number;
$vlan_info = $row->vlan_info;
}
?>
<form method="POST" action="vlanedit.php">
<input type="hidden" name="vlan_id" value="<?php echo $vlan_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Edit VLAN:</b><br>
</td>
</tr>
<tr>
<td>
VLAN name:
</td>
<td>
<input type="text" name="vlan_name" value="<?php echo $vlan_name; ?>">
</td>
</tr>
<tr>
<td>
VLAN ID:
</td>
<td>
<input type="text" name="vlan_number" size="3" value="<?php echo $vlan_number; ?>">
</td>
</tr>
<tr>
<td>
VLAN info:
</td>
<td>
<textarea name="vlan_info"><?php echo $vlan_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,83 @@
<?php
include("header.php");
// get id
$vlan_id = $_GET['vlan_id'];
// get vlan info
$result = mysql_query("SELECT vlan_name, vlan_number, vlan_info FROM vlan WHERE vlan_id='$vlan_id'");
while ($row = mysql_fetch_object($result)) {
$vlan_name = $row->vlan_name;
$vlan_number = $row->vlan_number;
$vlan_info = $row->vlan_info;
}
?>
<table border="0">
<tr>
<td>
<b>VLAN name:</b>
</td>
<td>
<?php echo $vlan_name; ?>
</td>
</tr>
<tr>
<td>
<b>VLAN ID:</b>
</td>
<td>
<?php echo $vlan_number; ?>
</td>
</tr>
<tr>
<td>
<b>VLAN info:</b>
</td>
<td>
<?php echo nl2br($vlan_info); ?>
</td>
</tr>
<tr>
<td>
<b>Subnet(s):</b>
</td>
<td>
<?php
// get subnet info
$result = mysql_query("SELECT subnet_id, subnet_address FROM subnet WHERE vlan_id='$vlan_id' ORDER BY subnet_address");
while ($row = mysql_fetch_object($result)) {
echo '<a href="subnetview.php?subnet_id=' . $row->subnet_id . '">' . $row->subnet_address . '</a><br>';
}
?>
</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="vlanedit.php?vlan_id=<?php echo $vlan_id; ?>">Modify</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assignvlantosubnet.php?vlan_id=<?php echo $vlan_id; ?>">Assign subnet</a>
</td>
</tr>
</table>
<?php
// end display only if admin
}
include("footer.php");
?>