Code formatting improved and some bugfixng
This commit is contained in:
170
nodeview.php
170
nodeview.php
@@ -1,107 +1,85 @@
|
||||
<?php
|
||||
/*****************************************************************************
|
||||
IP Reg, a PHP/MySQL IPAM tool
|
||||
Copyright (C) 2007-2009 Wietse Warendorff
|
||||
/*****************************************************************************
|
||||
IP Reg, a PHP/MySQL IPAM tool
|
||||
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
|
||||
Copyright (C) 2011-2023 Thomas Hooge
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*****************************************************************************/
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
include("includes.php");
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
if (isset($_GET['node_id']) && (!empty($_GET['node_id']))) {
|
||||
$node_id = sanitize($_GET['node_id']);
|
||||
} else {
|
||||
// redirect to error page
|
||||
header_location("comments.php?comments=error");
|
||||
exit;
|
||||
}
|
||||
|
||||
For more information, visit http://sourceforge.net/projects/ipreg,
|
||||
or contact me at wietsew@users.sourceforge.net
|
||||
*****************************************************************************/
|
||||
include("header.php");
|
||||
// node
|
||||
$query = "SELECT
|
||||
asset.asset_id,
|
||||
asset.asset_name,
|
||||
node.node_id,
|
||||
node.node_ip,
|
||||
node.node_mac,
|
||||
node.node_dns1,
|
||||
node.node_dns2,
|
||||
node.node_info,
|
||||
node.node_type,
|
||||
subnet.subnet_id,
|
||||
subnet.subnet_address,
|
||||
subnet.subnet_mask,
|
||||
zone.zone_origin
|
||||
FROM
|
||||
node
|
||||
JOIN asset USING (asset_id)
|
||||
JOIN subnet USING (subnet_id)
|
||||
LEFT JOIN zone USING (zone_id)
|
||||
WHERE
|
||||
node.node_id=" . $node_id;
|
||||
|
||||
// start page
|
||||
// includes
|
||||
include("includes.php");
|
||||
$node = $db->db_select($query);
|
||||
$node[0]['node_mac'] = write_mac($node[0]['node_mac']);
|
||||
$smarty->assign("node", $node[0]);
|
||||
|
||||
// get id
|
||||
$node_id = sanitize($_GET['node_id']);
|
||||
// nat
|
||||
$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,
|
||||
node_int.node_id AS node_id_int,
|
||||
node_ext.node_id AS node_id_ext
|
||||
FROM
|
||||
asset AS asset_ext,
|
||||
asset AS asset_int,
|
||||
nat,
|
||||
node AS node_ext,
|
||||
node AS 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)";
|
||||
|
||||
// start output
|
||||
include("header.php");
|
||||
$natrules = $db->db_select($query);
|
||||
$smarty->assign("natrules", $natrules);
|
||||
|
||||
// set language variables
|
||||
$smarty->assign($lang);
|
||||
$smarty->display("nodeview.tpl");
|
||||
|
||||
// setup node
|
||||
// build query
|
||||
$query = "SELECT
|
||||
asset.asset_id,
|
||||
asset.asset_name,
|
||||
node.node_id,
|
||||
node.node_ip,
|
||||
node.node_mac,
|
||||
node.node_dns1,
|
||||
node.node_dns2,
|
||||
node.node_info,
|
||||
node.node_type,
|
||||
subnet.subnet_id,
|
||||
subnet.subnet_address,
|
||||
subnet.subnet_mask,
|
||||
zone.zone_origin
|
||||
FROM
|
||||
node
|
||||
JOIN asset USING (asset_id)
|
||||
JOIN subnet USING (subnet_id)
|
||||
LEFT JOIN zone USING (zone_id)
|
||||
WHERE
|
||||
node.node_id=" . $node_id;
|
||||
|
||||
// run query
|
||||
$node = $db->db_select($query);
|
||||
$node[0]['node_mac'] = write_mac($node[0]['node_mac']);
|
||||
$smarty->assign("node", $node[0]);
|
||||
|
||||
// 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,
|
||||
node_int.node_id AS node_id_int,
|
||||
node_ext.node_id AS node_id_ext
|
||||
FROM
|
||||
asset AS asset_ext,
|
||||
asset AS asset_int,
|
||||
nat,
|
||||
node AS node_ext,
|
||||
node AS 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
|
||||
$natrules = $db->db_select($query);
|
||||
// counter to tpl
|
||||
$smarty->assign("natrules", $natrules);
|
||||
|
||||
// end page
|
||||
// output
|
||||
$smarty->display("nodeview.tpl");
|
||||
|
||||
include("footer.php");
|
||||
include("footer.php");
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user