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/assigniptoasset.php

115 lines
2.5 KiB

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