IP Reg is a IPAM tool to keep track of assets, nodes (IP addresses, MAC addresses, DNS aliases) within different subnets, over different locations or even VLAN's. Written in PHP, used with a MySQL-database to have a unique insight in your local network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
ipreg/nodeedit.php

129 lines
2.8 KiB

<?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");
?>