Make use of Yapter Template Engine
This commit is contained in:
@@ -1,115 +1,45 @@
|
||||
<?php
|
||||
include("header.php");
|
||||
|
||||
// display only if admin
|
||||
if($_SESSION['suser_level'] >= 2) {
|
||||
// get ip and id
|
||||
if((isset($_GET['subnet_id'])) ? $subnet_id = $_GET['subnet_id'] : $subnet_id = "");
|
||||
if((isset($_GET['ip'])) ? $ip = $_GET['ip'] : $ip = "");
|
||||
|
||||
// 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);
|
||||
// set template
|
||||
$tp = new Template("tpl/assigniptoasset.tpl");
|
||||
|
||||
// set language variables
|
||||
$tp->setvars($lang);
|
||||
|
||||
// set variables
|
||||
$tp->set("ip", $ip);
|
||||
$tp->set("subnet_id", $subnet_id);
|
||||
$tp->set("config_dns1suffix", $config_dns1suffix);
|
||||
$tp->set("config_dns2suffix", $config_dns2suffix);
|
||||
|
||||
// get subnet info
|
||||
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error());
|
||||
for ($i=0;$row=mysql_fetch_object($result);$i++) {
|
||||
if (($row->subnet_id==$subnet_id) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
|
||||
$tp->set("subnet_id", $row->subnet_id);
|
||||
$tp->set("subnet_address", $row->subnet_address);
|
||||
$tp->set("subnet_mask", $row->subnet_mask);
|
||||
$tp->parse("subnetrow");
|
||||
}
|
||||
if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet"));
|
||||
|
||||
$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
|
||||
// get asset info
|
||||
$result = mysql_query("SELECT asset_id, asset_name FROM asset ORDER BY asset_name") or die(mysql_error());
|
||||
for ($i=0;$row=mysql_fetch_object($result);$i++) {
|
||||
$tp->set("asset_id", $row->asset_id);
|
||||
$tp->set("asset_name", $row->asset_name);
|
||||
$tp->parse("assetrow");
|
||||
}
|
||||
if (($i>0) ? $tp->parse("asset") : $tp->hide("asset"));
|
||||
|
||||
// output
|
||||
$tp->parse();
|
||||
$tp->spit();
|
||||
|
||||
include("footer.php");
|
||||
?>
|
||||
Reference in New Issue
Block a user