Make use of Yapter Template Engine
This commit is contained in:
119
subnetedit.php
119
subnetedit.php
@@ -1,100 +1,39 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
// get 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;
|
||||
}
|
||||
?>
|
||||
// set template
|
||||
$tp = new Template("tpl/subnetedit.tpl");
|
||||
|
||||
<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_id">
|
||||
<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
|
||||
// set language variables
|
||||
$tp->setvars($lang);
|
||||
|
||||
// get subnet information
|
||||
$result = mysql_query("SELECT subnet_address, subnet_mask, vlan_id, subnet_info FROM subnet WHERE subnet_id='$subnet_id'") or die(mysql_error());
|
||||
$row = mysql_fetch_object($result);
|
||||
$vlan_id = $row->vlan_id;
|
||||
$tp->set("subnet_id", $subnet_id);
|
||||
$tp->set("subnet_address", $row->subnet_address);
|
||||
$tp->set("subnet_mask", $row->subnet_mask);
|
||||
$tp->set("vlan_id", $vlan_id);
|
||||
$tp->set("subnet_info", $row->subnet_info);
|
||||
|
||||
// get vlan info
|
||||
$result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan ORDER BY vlan_number") or die(mysql_error());
|
||||
for ($i=0;$row=mysql_fetch_object($result);$i++) {
|
||||
if (($row->vlan_id==$vlan_id) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
|
||||
$tp->set("vlan_id", $row->vlan_id);
|
||||
$tp->set("vlan_name", $row->vlan_name);
|
||||
$tp->set("vlan_number", $row->vlan_number);
|
||||
$tp->parse("vlanrow");
|
||||
}
|
||||
if (($i>0) ? $tp->parse("vlan") : $tp->hide("vlan"));
|
||||
|
||||
// output
|
||||
$tp->parse();
|
||||
$tp->spit();
|
||||
|
||||
include("footer.php");
|
||||
?>
|
||||
Reference in New Issue
Block a user