Changes adopted from version 0.5
This commit is contained in:
194
nodeview.php
194
nodeview.php
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*****************************************************************************
|
||||
IP Reg, a PHP/MySQL IPAM tool
|
||||
Copyright (C) 2008 Wietse Warendorff
|
||||
Copyright (C) 2007-2009 Wietse Warendorff
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -20,42 +20,162 @@
|
||||
or contact me at wietsew@users.sourceforge.net
|
||||
*****************************************************************************/
|
||||
|
||||
// includes
|
||||
include("includes.php");
|
||||
|
||||
// get id
|
||||
$node_id = $_GET['node_id'];
|
||||
|
||||
// check authorisation
|
||||
$auth = auth("node", $config_auth_nodeview, $node_id);
|
||||
|
||||
// start output
|
||||
include("header.php");
|
||||
|
||||
// set template
|
||||
$tp = new Template("tpl/nodeview.tpl");
|
||||
|
||||
// set language variables
|
||||
$tp->setvars($lang);
|
||||
|
||||
// get node info
|
||||
$result = mysql_query("SELECT a.asset_name, a.asset_id, n.ip, n.mac, n.dns1, n.dns2, n.node_info, s.subnet_id, s.subnet_address, s.subnet_mask FROM asset a, node n, subnet s WHERE n.node_id='$node_id' AND a.asset_id=n.asset_id AND s.subnet_id=n.subnet_id") or die(mysql_error());
|
||||
$row = mysql_fetch_object($result);
|
||||
$tp->set("node_id", $node_id);
|
||||
$tp->set("asset_id", $row->asset_id);
|
||||
$tp->set("asset_name", $row->asset_name);
|
||||
$tp->set("ip", $row->ip);
|
||||
$tp->set("mac", write_mac($row->mac));
|
||||
$tp->set("dns1", $row->dns1);
|
||||
$tp->set("dns2", $row->dns2);
|
||||
$tp->set("node_info", nl2br($row->node_info));
|
||||
$tp->set("subnet_id", $row->subnet_id);
|
||||
$tp->set("subnet_address", $row->subnet_address);
|
||||
$tp->set("subnet_mask", $row->subnet_mask);
|
||||
// start page
|
||||
// includes
|
||||
include("includes.php");
|
||||
|
||||
// output
|
||||
$tp->parse();
|
||||
$tp->spit();
|
||||
// get id
|
||||
$node_id = sanitize($_GET['node_id']);
|
||||
|
||||
include("footer.php");
|
||||
// start output
|
||||
include("header.php");
|
||||
|
||||
// set template
|
||||
$tp = new Template("tpl/nodeview.tpl", $config_yapter_error);
|
||||
|
||||
// set language variables
|
||||
$tp->setvars($lang);
|
||||
|
||||
// setup node
|
||||
// build query
|
||||
$query = "SELECT
|
||||
asset.asset_id AS asset_id,
|
||||
asset.asset_name AS asset_name,
|
||||
node.node_id AS node_id,
|
||||
node.node_ip AS node_ip,
|
||||
node.node_mac AS node_mac,
|
||||
node.node_dns1 AS node_dns1,
|
||||
node.node_dns2 AS node_dns2,
|
||||
node.node_info AS node_info,
|
||||
subnet.subnet_id AS subnet_id,
|
||||
subnet.subnet_address AS subnet_address,
|
||||
subnet.subnet_mask AS subnet_mask
|
||||
FROM
|
||||
asset,
|
||||
node,
|
||||
subnet
|
||||
WHERE
|
||||
asset.asset_id=node.asset_id
|
||||
AND node.node_id=" . $node_id . "
|
||||
AND subnet.subnet_id=node.subnet_id";
|
||||
|
||||
// run query
|
||||
$nodes = $db->db_select($query);
|
||||
|
||||
// count results
|
||||
$node_counter = count($nodes);
|
||||
|
||||
// counter to tpl
|
||||
$tp->set("node_counter", $node_counter);
|
||||
|
||||
// any nodes?
|
||||
if ($node_counter>0) {
|
||||
// get objects
|
||||
foreach($nodes AS $node) {
|
||||
// send to tpl
|
||||
$tp->set("asset_id", $node['asset_id']);
|
||||
$tp->set("asset_name", $node['asset_name']);
|
||||
|
||||
$tp->set("node_id", $node['node_id']);
|
||||
$tp->set("node_ip", $node['node_ip']);
|
||||
$tp->set("node_mac", write_mac($node['node_mac']));
|
||||
$tp->set("node_dns1", $node['node_dns1']);
|
||||
$tp->set("node_dns2", $node['node_dns2']);
|
||||
$tp->set("node_info", nl2br($node['node_info']));
|
||||
|
||||
$tp->set("subnet_id", $node['subnet_id']);
|
||||
$tp->set("subnet_address", $node['subnet_address']);
|
||||
$tp->set("subnet_mask", $node['subnet_mask']);
|
||||
|
||||
// parse row
|
||||
$tp->parse("node_row");
|
||||
}
|
||||
|
||||
// parse block
|
||||
$tp->parse("node_table");
|
||||
} else {
|
||||
// hide block
|
||||
$tp->hide("node_table");
|
||||
}
|
||||
|
||||
// setup nat
|
||||
// build query
|
||||
$query = "SELECT
|
||||
asset_ext.asset_id AS asset_id_ext,
|
||||
asset_int.asset_id AS asset_id_int,
|
||||
asset_ext.asset_name AS asset_name_ext,
|
||||
asset_int.asset_name AS asset_name_int,
|
||||
nat.nat_id AS nat_id,
|
||||
nat.nat_type AS nat_type,
|
||||
nat.nat_ext AS nat_ext,
|
||||
nat.nat_int AS nat_int,
|
||||
node_ext.node_ip AS node_ip_ext,
|
||||
node_int.node_ip AS node_ip_int
|
||||
FROM
|
||||
asset asset_ext,
|
||||
asset asset_int,
|
||||
nat,
|
||||
node node_ext,
|
||||
node node_int
|
||||
WHERE
|
||||
(nat.nat_ext=" . $node_id . "
|
||||
OR nat.nat_int=" . $node_id . ")
|
||||
AND node_ext.node_id=nat.nat_ext
|
||||
AND node_int.node_id=nat.nat_int
|
||||
AND asset_ext.asset_id=node_ext.asset_id
|
||||
AND asset_int.asset_id=node_int.asset_id
|
||||
ORDER BY
|
||||
INET_ATON(node_ext.node_ip),
|
||||
INET_ATON(node_int.node_ip)";
|
||||
|
||||
// run query
|
||||
$nats = $db->db_select($query);
|
||||
|
||||
// count results
|
||||
$nat_counter = count($nats);
|
||||
|
||||
// counter to tpl
|
||||
$tp->set("nat_counter", $nat_counter);
|
||||
|
||||
// any nodes?
|
||||
if ($nat_counter>0) {
|
||||
// get objects
|
||||
foreach($nats AS $nat) {
|
||||
if($node_id==$nat['nat_ext']) {
|
||||
// send to tpl
|
||||
$tp->set("nat_asset_id", $nat['asset_id_int']);
|
||||
$tp->set("nat_asset_name", $nat['asset_name_int']);
|
||||
|
||||
$tp->set("nat_type", $lang['lang_nat_type_' . $nat['nat_type']]);
|
||||
|
||||
$tp->set("nat_node_id", $nat['nat_int']);
|
||||
$tp->set("nat_node_ip", $nat['node_ip_int']);
|
||||
} else if($node_id==$nat['nat_int']) {
|
||||
// send to tpl
|
||||
$tp->set("nat_asset_id", $nat['asset_id_ext']);
|
||||
$tp->set("nat_asset_name", $nat['asset_name_ext']);
|
||||
|
||||
$tp->set("nat_type", $lang['lang_nat_type_' . $nat['nat_type']]);
|
||||
|
||||
$tp->set("nat_node_id", $nat['nat_ext']);
|
||||
$tp->set("nat_node_ip", $nat['node_ip_ext']);
|
||||
}
|
||||
|
||||
// parse row
|
||||
$tp->parse("nat_row");
|
||||
}
|
||||
|
||||
// parse block
|
||||
$tp->parse("nat_table");
|
||||
} else {
|
||||
// hide block
|
||||
$tp->hide("nat_table");
|
||||
}
|
||||
|
||||
// end page
|
||||
// output
|
||||
$tp->parse();
|
||||
$tp->spit();
|
||||
|
||||
include("footer.php");
|
||||
?>
|
||||
Reference in New Issue
Block a user