Make use of Yapter Template Engine

This commit is contained in:
2023-02-13 09:31:40 +01:00
parent 7322231d3e
commit 8d00ee5e1b
100 changed files with 4804 additions and 2666 deletions

View File

@@ -4,77 +4,47 @@
// get id
$subnet_id = $_GET['subnet_id'];
// get ordering
// set template
$tp = new Template("tpl/nodelist.tpl");
// set language variables
$tp->setvars($lang);
// set variables
$tp->set("subnet_id", $subnet_id);
// set ordering
if (isset($_GET['order'])) {
$order = $_GET['order'];
switch($_GET['order']) {
case ("asset_name") : $order = "a.asset_name"; break;
case ("hostname") : $order = "a.hostname"; break;
case ("mac") : $order = "n.mac"; break;
case ("dns1") : $order = "n.dns1"; break;
case ("dns2") : $order = "n.dns2"; break;
default : $order = "INET_ATON(n.ip)";
}
} 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
// 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") 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->set("hostname", $row->hostname);
$tp->set("node_id", $row->node_id);
$tp->set("ip", $row->ip);
$tp->set("mac", write_mac($row->mac));
$tp->set("dns1", $row->dns1);
$tp->set("dns2", $row->dns2);
$tp->parse("noderow");
}
?>
</table>
<?php
if (($i>0) ? $tp->parse("node") : $tp->hide("node"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>