diff --git a/.gitignore b/.gitignore
index 3c50d5e..33ad9cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*~
tpl_c/*.php
+config.php
diff --git a/asset.php b/asset.php
index a8ebe28..350e723 100644
--- a/asset.php
+++ b/asset.php
@@ -1,82 +1,55 @@
.
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+include("header.php");
- // start page
- // includes
- include("includes.php");
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // create letter links
- // build query
- $query = "SELECT
- SUBSTRING(UPPER(asset.asset_name),1,1) AS asset_letter
- FROM
- asset
- GROUP BY
- asset_letter
- ORDER BY
- asset_letter";
-
- // run query
- $alphabet = $db->db_select($query);
- $smarty->assign("alphabet", $alphabet);
- // setup asset
- // setup current letter
- if(isset($_GET['asset_letter'])) {
- $asset_letter = sanitize($_GET['asset_letter']);
- } else {
- $asset_letter = $alphabet[0]['asset_letter'];
- }
-
- // build query
- $query = "SELECT
- a.asset_id,
- IF(LENGTH(a.asset_name)>0, a.asset_name, '...') AS asset_name,
- a.asset_info,
- c.assetclass_id,
- c.assetclass_name
- FROM
- asset AS a LEFT OUTER JOIN assetclass AS c USING (assetclass_id)
- WHERE
- SUBSTRING(a.asset_name,1,1) = '" . $asset_letter . "'
- ORDER BY
- a.asset_name";
+// create letter links
+$query = "SELECT
+ SUBSTRING(UPPER(asset.asset_name),1,1) AS asset_letter
+ FROM
+ asset
+ GROUP BY
+ asset_letter
+ ORDER BY
+ asset_letter";
- // run query
- $assets = $db->db_select($query);
+$alphabet = $db->db_select($query);
+$smarty->assign("alphabet", $alphabet);
+
+// setup current letter
+if(isset($_GET['asset_letter'])) {
+ $asset_letter = sanitize($_GET['asset_letter']);
+} else {
+ $asset_letter = $alphabet[0]['asset_letter'];
+}
- // counter to tpl
- $smarty->assign("assets", $assets);
+$query = "SELECT
+ a.asset_id,
+ IF(LENGTH(a.asset_name)>0, a.asset_name, '...') AS asset_name,
+ a.asset_info,
+ c.assetclass_id,
+ c.assetclass_name
+ FROM
+ asset AS a LEFT OUTER JOIN assetclass AS c USING (assetclass_id)
+ WHERE
+ SUBSTRING(a.asset_name,1,1) = '" . $asset_letter . "'
+ ORDER BY
+ a.asset_name";
+
+$assets = $db->db_select($query);
+
+$smarty->assign("assets", $assets);
- // end page
- // output
- $smarty->display("asset.tpl");
+$smarty->display("asset.tpl");
- // end output
- include("footer.php");
+include("footer.php");
?>
diff --git a/assetadd.php b/assetadd.php
index 3d3af06..ce6bdaa 100644
--- a/assetadd.php
+++ b/assetadd.php
@@ -1,59 +1,33 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get id
- if((isset($_GET['assetclass_id'])) ? $assetclass_id = sanitize($_GET['assetclass_id']) : $assetclass_id = "");
-
- // start output
- include("header.php");
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+
+if((isset($_GET['assetclass_id'])) ? $assetclass_id = sanitize($_GET['assetclass_id']) : $assetclass_id = "");
+
+include("header.php");
- // set language variables
- $smarty->assign($lang);
-
- // setup assetclass
- // build query
- $query = "SELECT
- assetclass_id,
- assetclass_name
- FROM
- assetclass
- ORDER BY
- assetclass_name";
+$query = "SELECT
+ assetclass_id,
+ assetclass_name
+FROM
+ assetclass
+ORDER BY
+ assetclass_name";
- // run query
- $assetclasses = $db->db_select($query);
- foreach ($assetclasses as $assetclass) {
- $assetclass_options[$assetclass['assetclass_id']] = $assetclass['assetclass_name'];
- }
- $smarty->assign("assetclass_options", $assetclass_options);
+$assetclasses = $db->db_select($query);
+foreach ($assetclasses as $assetclass) {
+ $assetclass_options[$assetclass['assetclass_id']] = $assetclass['assetclass_name'];
+}
- // end page
- // output
- $smarty->display("assetadd.tpl");
-
- // end output
- include("footer.php");
+$smarty->assign("assetclass_options", $assetclass_options);
+$smarty->display("assetadd.tpl");
+
+include("footer.php");
?>
\ No newline at end of file
diff --git a/assetclass.php b/assetclass.php
index 7e3ed41..318e96e 100644
--- a/assetclass.php
+++ b/assetclass.php
@@ -1,59 +1,30 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
-
- // start output
- include("header.php");
+include("includes.php");
+include("header.php");
- // set language variables
- $smarty->assign($lang);
-
- // setup assetclass
- // build query
- $query = "SELECT
- a.assetclass_id,
- a.assetclass_name,
- g.assetclassgroup_id,
- g.assetclassgroup_name,
- g.assetclassgroup_color
- FROM
- assetclass AS a LEFT OUTER JOIN assetclassgroup AS g USING (assetclassgroup_id)
- ORDER BY
- a.assetclass_name";
+$query = "SELECT
+ a.assetclass_id,
+ a.assetclass_name,
+ g.assetclassgroup_id,
+ g.assetclassgroup_name,
+ g.assetclassgroup_color
+ FROM
+ assetclass AS a LEFT OUTER JOIN assetclassgroup AS g USING (assetclassgroup_id)
+ ORDER BY
+ a.assetclass_name";
- // run query
- $assetclasses = $db->db_select($query);
-
- // counter to tpl
- $smarty->assign("assetclasses", $assetclasses);
-
+$assetclasses = $db->db_select($query);
- // end page
- // output
- $smarty->display("assetclass.tpl");
-
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+$smarty->assign("assetclasses", $assetclasses);
+$smarty->display("assetclass.tpl");
+
+include("footer.php");
+?>
diff --git a/assetclassadd.php b/assetclassadd.php
index 4ea4ad9..7199997 100644
--- a/assetclassadd.php
+++ b/assetclassadd.php
@@ -1,45 +1,20 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+
+if((isset($_GET['assetclassgroup_id'])) ? $assetclassgroup_id = sanitize($_GET['assetclassgroup_id']) : $assetclassgroup_id = "");
+
+include("header.php");
+
+$smarty->assign("assetclassgroup_options", $db->options_assetclassgroup());
+$smarty->display("assetclassadd.tpl");
- // get id
- if((isset($_GET['assetclassgroup_id'])) ? $assetclassgroup_id = sanitize($_GET['assetclassgroup_id']) : $assetclassgroup_id = "");
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup assetclassgroup
- $smarty->assign("assetclassgroup_options", $db->options_assetclassgroup());
-
- // end page
- // output
- $smarty->display("assetclassadd.tpl");
-
- // end output
- include("footer.php");
+include("footer.php");
?>
\ No newline at end of file
diff --git a/assetclassdel.php b/assetclassdel.php
index d870a34..8c17b89 100644
--- a/assetclassdel.php
+++ b/assetclassdel.php
@@ -1,59 +1,32 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get id
- $assetclass_id = sanitize($_GET['assetclass_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup assetclass
- // build query
- $query = "SELECT
- assetclass_id,
- assetclass_name
- FROM
- assetclass
- WHERE
- assetclass_id=" . $assetclass_id;
-
- // run query
- $assetclass = $db->db_select($query);
-
- // send to tpl
- $smarty->assign("assetclass_id", $assetclass[0]['assetclass_id']);
- $smarty->assign("assetclass_name", $assetclass[0]['assetclass_name']);
-
- // end page
- // output
- $smarty->display("assetclassdel.tpl");
-
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+
+$assetclass_id = sanitize($_GET['assetclass_id']);
+
+include("header.php");
+
+$query = "SELECT
+ assetclass_id,
+ assetclass_name
+ FROM
+ assetclass
+ WHERE
+ assetclass_id=" . $assetclass_id;
+
+$assetclass = $db->db_select($query);
+
+$smarty->assign("assetclass_id", $assetclass[0]['assetclass_id']);
+$smarty->assign("assetclass_name", $assetclass[0]['assetclass_name']);
+
+$smarty->display("assetclassdel.tpl");
+
+include("footer.php");
+?>
diff --git a/assetclassedit.php b/assetclassedit.php
index ac12eec..d0ac629 100644
--- a/assetclassedit.php
+++ b/assetclassedit.php
@@ -1,65 +1,35 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get id
- $assetclass_id = sanitize($_GET['assetclass_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // setup assetclass
- // build query
- $query = "SELECT
- assetclass_id,
- assetclass_name,
- assetclassgroup_id
- FROM
- assetclass
- WHERE
- assetclass_id=" . $assetclass_id;
+include("includes.php");
+
+$assetclass_id = sanitize($_GET['assetclass_id']);
+include("header.php");
- // run query
- $assetclass = $db->db_select($query);
+$query = "SELECT
+ assetclass_id,
+ assetclass_name,
+ assetclassgroup_id
+ FROM
+ assetclass
+ WHERE
+ assetclass_id=" . $assetclass_id;
- // send to tpl
- $smarty->assign("assetclass_id", $assetclass[0]['assetclass_id']);
- $smarty->assign("assetclass_name", $assetclass[0]['assetclass_name']);
- $smarty->assign("assetclassgroup_id", $assetclass[0]['assetclassgroup_id']);
+$assetclass = $db->db_select($query);
- // setup assetclassgroup
- // build query
- $smarty->assign("assetclassgroup_options", $db->options_assetclassgroup());
+$smarty->assign("assetclass_id", $assetclass[0]['assetclass_id']);
+$smarty->assign("assetclass_name", $assetclass[0]['assetclass_name']);
+$smarty->assign("assetclassgroup_id", $assetclass[0]['assetclassgroup_id']);
- // end page
- // output
- $smarty->display("assetclassedit.tpl");
-
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+$smarty->assign("assetclassgroup_options", $db->options_assetclassgroup());
+
+$smarty->display("assetclassedit.tpl");
+
+include("footer.php");
+?>
diff --git a/assetclassgroup.php b/assetclassgroup.php
index 79ecd11..a77e26c 100644
--- a/assetclassgroup.php
+++ b/assetclassgroup.php
@@ -1,54 +1,29 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+
+include("header.php");
- // setup assetclassgroup
- // build query
- $query = "SELECT
- assetclassgroup_id,
- assetclassgroup_name,
- assetclassgroup_color
- FROM
- assetclassgroup
- ORDER BY
- assetclassgroup_name";
+$query = "SELECT
+ assetclassgroup_id,
+ assetclassgroup_name,
+ assetclassgroup_color
+FROM
+ assetclassgroup
+ORDER BY
+ assetclassgroup_name";
- // run query
- $assetclassgroups = $db->db_select($query);
- $smarty->assign("assetclassgroups", $assetclassgroups);
+$assetclassgroups = $db->db_select($query);
- // end page
- // output
- $smarty->display("assetclassgroup.tpl");
+$smarty->assign("assetclassgroups", $assetclassgroups);
+$smarty->display("assetclassgroup.tpl");
- // end output
- include("footer.php");
+include("footer.php");
?>
\ No newline at end of file
diff --git a/assetclassgroupadd.php b/assetclassgroupadd.php
index 13e5a51..33d8f60 100644
--- a/assetclassgroupadd.php
+++ b/assetclassgroupadd.php
@@ -1,39 +1,16 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // start output
- include("header.php");
+include("includes.php");
+include("header.php");
- // set language variables
- $smarty->assign($lang);
-
- // end page
- // output
- $smarty->display("assetclassgroupadd.tpl");
+$smarty->display("assetclassgroupadd.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/assetclassgroupdel.php b/assetclassgroupdel.php
index 281b345..dd34439 100644
--- a/assetclassgroupdel.php
+++ b/assetclassgroupdel.php
@@ -1,59 +1,34 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get id
- $assetclassgroup_id = sanitize($_GET['assetclassgroup_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup assetclassgroup
- // build query
- $query = "SELECT
- assetclassgroup_id,
- assetclassgroup_name
- FROM
- assetclassgroup
- WHERE
- assetclassgroup_id=" . $assetclassgroup_id;
-
- // run query
- $assetclassgroup = $db->db_select($query);
-
- // send to tpl
- $smarty->assign("assetclassgroup_id", $assetclassgroup[0]['assetclassgroup_id']);
- $smarty->assign("assetclassgroup_name", $assetclassgroup[0]['assetclassgroup_name']);
-
- // end page
- // output
- $smarty->display("assetclassgroupdel.tpl");
-
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+
+$assetclassgroup_id = sanitize($_GET['assetclassgroup_id']);
+
+include("header.php");
+
+$smarty->assign($lang);
+
+$query = "SELECT
+ assetclassgroup_id,
+ assetclassgroup_name
+ FROM
+ assetclassgroup
+ WHERE
+ assetclassgroup_id=" . $assetclassgroup_id;
+
+$assetclassgroup = $db->db_select($query);
+
+$smarty->assign("assetclassgroup_id", $assetclassgroup[0]['assetclassgroup_id']);
+$smarty->assign("assetclassgroup_name", $assetclassgroup[0]['assetclassgroup_name']);
+
+$smarty->display("assetclassgroupdel.tpl");
+
+include("footer.php");
+?>
diff --git a/assetclassgroupedit.php b/assetclassgroupedit.php
index 27557ee..cac83b4 100644
--- a/assetclassgroupedit.php
+++ b/assetclassgroupedit.php
@@ -1,62 +1,37 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get id
- $assetclassgroup_id = sanitize($_GET['assetclassgroup_id']);
-
- // start output
- $smarty->assign("scripts", 'jscolor.js');
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup assetclassgroup
- // build query
- $query = "SELECT
- assetclassgroup.assetclassgroup_id AS assetclassgroup_id,
- assetclassgroup.assetclassgroup_name AS assetclassgroup_name,
- assetclassgroup.assetclassgroup_color AS assetclassgroup_color
- FROM
- assetclassgroup
- WHERE
- assetclassgroup.assetclassgroup_id=" . $assetclassgroup_id;
-
- // run query
- $assetclassgroup = $db->db_select($query);
-
- // send to tpl
- $smarty->assign("assetclassgroup_id", $assetclassgroup[0]['assetclassgroup_id']);
- $smarty->assign("assetclassgroup_name", $assetclassgroup[0]['assetclassgroup_name']);
- $smarty->assign("assetclassgroup_color", $assetclassgroup[0]['assetclassgroup_color']);
-
- // end page
- // output
- $smarty->display("assetclassgroupedit.tpl");
-
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+
+$assetclassgroup_id = sanitize($_GET['assetclassgroup_id']);
+
+$smarty->assign("scripts", 'jscolor.js');
+include("header.php");
+
+$smarty->assign($lang);
+
+$query = "SELECT
+ assetclassgroup_id,
+ assetclassgroup_name,
+ assetclassgroup_color
+ FROM
+ assetclassgroup
+ WHERE
+ assetclassgroup_id=" . $assetclassgroup_id;
+
+$assetclassgroup = $db->db_select($query);
+
+$smarty->assign("assetclassgroup_id", $assetclassgroup[0]['assetclassgroup_id']);
+$smarty->assign("assetclassgroup_name", $assetclassgroup[0]['assetclassgroup_name']);
+$smarty->assign("assetclassgroup_color", $assetclassgroup[0]['assetclassgroup_color']);
+
+$smarty->display("assetclassgroupedit.tpl");
+
+include("footer.php");
+?>
diff --git a/assetclassgroupview.php b/assetclassgroupview.php
index 30d5b70..50eb233 100644
--- a/assetclassgroupview.php
+++ b/assetclassgroupview.php
@@ -1,77 +1,47 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get id
- $assetclassgroup_id = sanitize($_GET['assetclassgroup_id']);
-
- // start output
- include("header.php");
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
- // set language variables
- $smarty->assign($lang);
-
- // setup assetclassgroup
- // build query
- $query = "SELECT
- assetclassgroup_id,
- assetclassgroup_name,
- assetclassgroup_color
- FROM
- assetclassgroup
- WHERE
- assetclassgroup_id=" . $assetclassgroup_id;
-
- // run query
- $assetclassgroup = $db->db_select($query);
-
- // send to tpl
- $smarty->assign("assetclassgroup_id", $assetclassgroup[0]['assetclassgroup_id']);
- $smarty->assign("assetclassgroup_name", $assetclassgroup[0]['assetclassgroup_name']);
- $smarty->assign("assetclassgroup_color", $assetclassgroup[0]['assetclassgroup_color']);
-
- // setup assetclass
- // build query
- $query = "SELECT
- assetclass_id,
- assetclass_name
- FROM
- assetclass
- WHERE
- assetclassgroup_id=" . $assetclassgroup_id . "
- ORDER BY
- assetclass_name";
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // run query
- $assetclasses = $db->db_select($query);
- $smarty->assign("assetclasses", $assetclasses);
-
- // end page
- // output
- $smarty->display("assetclassgroupview.tpl");
-
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("includes.php");
+
+$assetclassgroup_id = sanitize($_GET['assetclassgroup_id']);
+
+include("header.php");
+
+$query = "SELECT
+ assetclassgroup_id,
+ assetclassgroup_name,
+ assetclassgroup_color
+ FROM
+ assetclassgroup
+ WHERE
+ assetclassgroup_id=" . $assetclassgroup_id;
+
+$assetclassgroup = $db->db_select($query);
+
+$smarty->assign("assetclassgroup_id", $assetclassgroup[0]['assetclassgroup_id']);
+$smarty->assign("assetclassgroup_name", $assetclassgroup[0]['assetclassgroup_name']);
+$smarty->assign("assetclassgroup_color", $assetclassgroup[0]['assetclassgroup_color']);
+
+$query = "SELECT
+ assetclass_id,
+ assetclass_name
+ FROM
+ assetclass
+ WHERE
+ assetclassgroup_id=" . $assetclassgroup_id . "
+ ORDER BY
+ assetclass_name";
+
+$assetclasses = $db->db_select($query);
+$smarty->assign("assetclasses", $assetclasses);
+
+$smarty->display("assetclassgroupview.tpl");
+
+include("footer.php");
+?>
diff --git a/assetclassview.php b/assetclassview.php
index bcd3122..861d0fd 100644
--- a/assetclassview.php
+++ b/assetclassview.php
@@ -1,82 +1,51 @@
.
+$assetclass_id = sanitize($_GET['assetclass_id']);
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+include("header.php");
- // start page
- // includes
- include("includes.php");
+ $query = "SELECT
+ a.assetclass_id, a.assetclass_name,
+ g.assetclassgroup_id, g.assetclassgroup_name, g.assetclassgroup_color
+ FROM
+ assetclass AS a LEFT OUTER JOIN assetclassgroup AS g USING (assetclassgroup_id)
+ WHERE
+ a.assetclass_id=" . $assetclass_id;
- // get id
- $assetclass_id = sanitize($_GET['assetclass_id']);
+$assetclass = $db->db_select($query);
- // start output
- include("header.php");
+$smarty->assign("assetclass_id", $assetclass[0]['assetclass_id']);
+$smarty->assign("assetclass_name", $assetclass[0]['assetclass_name']);
+$smarty->assign("assetclass_selected", "");
- // set language variables
- $smarty->assign($lang);
+$smarty->assign("assetclassgroup_id", $assetclass[0]['assetclassgroup_id']);
+$smarty->assign("assetclassgroup_name", $assetclass[0]['assetclassgroup_name']);
+$smarty->assign("assetclassgroup_color", $assetclass[0]['assetclassgroup_color']);
- // setup assetclass
- // build query
- $query = "SELECT
- a.assetclass_id, a.assetclass_name,
- g.assetclassgroup_id, g.assetclassgroup_name, g.assetclassgroup_color
- FROM
- assetclass AS a LEFT OUTER JOIN assetclassgroup AS g USING (assetclassgroup_id)
- WHERE
- a.assetclass_id=" . $assetclass_id;
+$query = "SELECT
+ asset_id,
+ asset_name,
+ CONCAT(LEFT(asset_info, 80), IF(CHAR_LENGTH(asset_info)>80,'...','')) AS asset_info
+ FROM
+ asset
+ WHERE
+ assetclass_id='" . $assetclass_id . "'
+ ORDER BY
+ asset_name";
- // run query
- $assetclass = $db->db_select($query);
+$assets = $db->db_select($query);
+$smarty->assign("assets", $assets);
- // send to tpl
- $smarty->assign("assetclass_id", $assetclass[0]['assetclass_id']);
- $smarty->assign("assetclass_name", $assetclass[0]['assetclass_name']);
- $smarty->assign("assetclass_selected", "");
+$smarty->display("assetclassview.tpl");
- $smarty->assign("assetclassgroup_id", $assetclass[0]['assetclassgroup_id']);
- $smarty->assign("assetclassgroup_name", $assetclass[0]['assetclassgroup_name']);
- $smarty->assign("assetclassgroup_color", $assetclass[0]['assetclassgroup_color']);
-
- // send to tpl
- // setup asset
- // build query
- $query = "SELECT
- asset_id,
- asset_name,
- CONCAT(LEFT(asset_info, 80), IF(CHAR_LENGTH(asset_info)>80,'...','')) AS asset_info
- FROM
- asset
- WHERE
- assetclass_id='" . $assetclass_id . "'
- ORDER BY
- asset_name";
-
- // run query
- $assets = $db->db_select($query);
- $smarty->assign("assets", $assets);
-
- // end page
- // output
- $smarty->display("assetclassview.tpl");
-
- // footer
- include("footer.php");
+include("footer.php");
?>
diff --git a/assetdel.php b/assetdel.php
index af79672..4e99ff4 100644
--- a/assetdel.php
+++ b/assetdel.php
@@ -1,74 +1,44 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get id
- $asset_id = sanitize($_GET['asset_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
- // setup asset
- // build query
- $query = "SELECT
- asset_name
- FROM
- asset
- WHERE
- asset_id=" . $asset_id;
-
- // run query
- $asset = $db->db_select($query);
-
- // send to tpl
- $smarty->assign("asset_id", $asset_id);
- $smarty->assign("asset_name", $asset[0]['asset_name']);
-
- // setup node
- // build query
- $query = "SELECT
- node_id,
- node_ip
- FROM
- node
- WHERE
- asset_id=" . $asset_id . "
- ORDER BY
- INET_ATON(node_ip)";
-
- // run query
- $nodes = $db->db_select($query);
- $smarty->assign("nodes", $nodes);
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+
+$asset_id = sanitize($_GET['asset_id']);
+
+include("header.php");
- // end page
- // output
- $smarty->display("assetdel.tpl");
+$query = "SELECT
+ asset_name
+ FROM
+ asset
+ WHERE
+ asset_id=" . $asset_id;
+
+$asset = $db->db_select($query);
+
+$smarty->assign("asset_id", $asset_id);
+$smarty->assign("asset_name", $asset[0]['asset_name']);
+
+$query = "SELECT
+ node_id,
+ node_ip
+ FROM
+ node
+ WHERE
+ asset_id=" . $asset_id . "
+ ORDER BY
+ INET_ATON(node_ip)";
+
+$nodes = $db->db_select($query);
+$smarty->assign("nodes", $nodes);
+
+$smarty->display("assetdel.tpl");
- // footer
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/assetedit.php b/assetedit.php
index 0a31cc8..307ce62 100644
--- a/assetedit.php
+++ b/assetedit.php
@@ -1,62 +1,35 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
-
- // get id
- $asset_id = sanitize($_GET['asset_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
+include("includes.php");
+
+$asset_id = sanitize($_GET['asset_id']);
+
+include("header.php");
- // setup asset
- // build query
- $query = "SELECT
- asset_id,
- asset_name,
- asset_hostname,
- asset_info,
- assetclass_id
- FROM
- asset
- WHERE
- asset_id=" . $asset_id;
+$query = "SELECT
+ asset_id,
+ asset_name,
+ asset_hostname,
+ asset_info,
+ assetclass_id
+ FROM
+ asset
+ WHERE
+ asset_id=" . $asset_id;
+
+$asset = $db->db_select($query);
+$smarty->assign("asset", $asset[0]);
- // run query
- $asset = $db->db_select($query);
- $smarty->assign("asset", $asset[0]);
+$smarty->assign("assetclass_options", $db->options_assetclass());
- // setup assetclass
- $smarty->assign("assetclass_options", $db->options_assetclass());
+$smarty->display("assetedit.tpl");
- // end page
- // output
- $smarty->display("assetedit.tpl");
-
- // footer
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/assetview.php b/assetview.php
index be2d18a..10554a8 100644
--- a/assetview.php
+++ b/assetview.php
@@ -1,84 +1,54 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get id
- $asset_id = sanitize($_GET['asset_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup asset
- // build query
- $query = "SELECT
- a.asset_name,
- a.asset_hostname,
- a.asset_info,
- c.assetclass_id,
- c.assetclass_name
- FROM
- asset AS a LEFT OUTER JOIN assetclass AS c USING (assetclass_id)
- WHERE
- a.asset_id=" . $asset_id;
-
- // run query
- $asset = $db->db_select($query);
-
- // send to tpl
- $smarty->assign("asset_id", $asset_id);
- $smarty->assign("asset_name", $asset[0]['asset_name']);
- $smarty->assign("asset_hostname", $asset[0]['asset_hostname']);
- $smarty->assign("asset_info", nl2br($asset[0]['asset_info']));
-
- $smarty->assign("assetclass_id", $asset[0]['assetclass_id']);
- $smarty->assign("assetclass_name", $asset[0]['assetclass_name']);
-
- // setup node
- // build query
- $query = "SELECT
- node_id,
- node_ip,
- LEFT(node_info, 40) as node_info
- FROM
- node
- WHERE
- asset_id=" . $asset_id . "
- ORDER BY
- INET_ATON(node_ip)";
-
- // run query
- $nodes = $db->db_select($query);
- $smarty->assign("nodes", $nodes);
-
- // end page
- // output
- $smarty->display("assetview.tpl");
-
- // footer
- include("footer.php");
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+
+$asset_id = sanitize($_GET['asset_id']);
+
+include("header.php");
+
+$query = "SELECT
+ a.asset_name,
+ a.asset_hostname,
+ a.asset_info,
+ c.assetclass_id,
+ c.assetclass_name
+ FROM
+ asset AS a LEFT OUTER JOIN assetclass AS c USING (assetclass_id)
+ WHERE
+ a.asset_id=" . $asset_id;
+
+$asset = $db->db_select($query);
+
+$smarty->assign("asset_id", $asset_id);
+$smarty->assign("asset_name", $asset[0]['asset_name']);
+$smarty->assign("asset_hostname", $asset[0]['asset_hostname']);
+$smarty->assign("asset_info", nl2br($asset[0]['asset_info']));
+
+$smarty->assign("assetclass_id", $asset[0]['assetclass_id']);
+$smarty->assign("assetclass_name", $asset[0]['assetclass_name']);
+
+$query = "SELECT
+ node_id,
+ node_ip,
+ LEFT(node_info, 40) as node_info
+ FROM
+ node
+ WHERE
+ asset_id=" . $asset_id . "
+ ORDER BY
+ INET_ATON(node_ip)";
+
+$nodes = $db->db_select($query);
+$smarty->assign("nodes", $nodes);
+
+$smarty->display("assetview.tpl");
+
+include("footer.php");
?>
diff --git a/assigniptonode.php b/assigniptonode.php
index d183771..4d333a3 100644
--- a/assigniptonode.php
+++ b/assigniptonode.php
@@ -1,61 +1,35 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get ip and id
- $node_ip = sanitize($_GET['node_ip']);
- $subnet_id = sanitize($_GET['subnet_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // build query
- $query = "SELECT
- subnet_address,
- subnet_mask
- FROM
- subnet
- WHERE
- subnet_id=" . $subnet_id;
-
- // run query
- $subnet = $db->db_select($query);
-
- // send to tpl
- $smarty->assign("subnet_id", $subnet_id);
- $smarty->assign("subnet_address", $subnet[0]['subnet_address']);
- $smarty->assign("subnet_mask", $subnet[0]['subnet_mask']);
- $smarty->assign("node_ip", $node_ip);
-
- // end page
- // output
- $smarty->display("assigniptonode.tpl");
-
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+
+$node_ip = sanitize($_GET['node_ip']);
+$subnet_id = sanitize($_GET['subnet_id']);
+
+include("header.php");
+
+$query = "SELECT
+ subnet_address,
+ subnet_mask
+ FROM
+ subnet
+ WHERE
+ subnet_id=" . $subnet_id;
+
+$subnet = $db->db_select($query);
+
+$smarty->assign("subnet_id", $subnet_id);
+$smarty->assign("subnet_address", $subnet[0]['subnet_address']);
+$smarty->assign("subnet_mask", $subnet[0]['subnet_mask']);
+$smarty->assign("node_ip", $node_ip);
+
+$smarty->display("assigniptonode.tpl");
+
+include("footer.php");
+?>
diff --git a/assignnodetoasset.php b/assignnodetoasset.php
index 3c83d9e..337210d 100644
--- a/assignnodetoasset.php
+++ b/assignnodetoasset.php
@@ -1,79 +1,49 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get id
- $asset_id = sanitize($_GET['asset_id']);
- $node_ip = sanitize($_GET['node_ip']);
- $subnet_id = sanitize($_GET['subnet_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // to tpl
- $smarty->assign("node_ip", $node_ip);
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
- // setup asset
- $smarty->assign("asset_id", $asset_id);
- // build query
- $query = "SELECT
- asset_id,
- asset_name
- FROM
- asset
- ORDER BY
- asset_name";
-
- // run query
- $assets = $db->db_select($query);
- foreach ($assets as $asset) {
- $asset_options[$asset['asset_id']] = $asset['asset_name'];
- }
- $smarty->assign("asset_options", $asset_options);
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // setup subnet
- // build query
- $query = "SELECT subnet_id,
- CONCAT_WS('/', subnet_address, subnet_mask) AS subnet_name
- FROM subnet
- ORDER BY INET_ATON(subnet_address)";
+include("includes.php");
+
+$asset_id = sanitize($_GET['asset_id']);
+$node_ip = sanitize($_GET['node_ip']);
+$subnet_id = sanitize($_GET['subnet_id']);
+
+include("header.php");
+
+$smarty->assign("node_ip", $node_ip);
+$smarty->assign("asset_id", $asset_id);
+
+$query = "SELECT
+ asset_id,
+ asset_name
+ FROM
+ asset
+ ORDER BY
+ asset_name";
+
+$assets = $db->db_select($query);
+foreach ($assets as $asset) {
+ $asset_options[$asset['asset_id']] = $asset['asset_name'];
+}
+$smarty->assign("asset_options", $asset_options);
+
+$query = "SELECT subnet_id,
+ CONCAT_WS('/', subnet_address, subnet_mask) AS subnet_name
+ FROM subnet
+ ORDER BY INET_ATON(subnet_address)";
- // run query
- $subnets = $db->db_select($query);
- foreach ($subnets as $subnet) {
- $subnet_options[$subnet['subnet_id']] = $subnet['subnet_name'];
- }
- $smarty->assign("subnet_options", $subnet_options);
+$subnets = $db->db_select($query);
+foreach ($subnets as $subnet) {
+ $subnet_options[$subnet['subnet_id']] = $subnet['subnet_name'];
+}
+$smarty->assign("subnet_options", $subnet_options);
- // end page
- // output
- $smarty->display("assignnodetoasset.tpl");
+$smarty->display("assignnodetoasset.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/comments.php b/comments.php
index a7850c6..f450c38 100644
--- a/comments.php
+++ b/comments.php
@@ -1,42 +1,22 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // includes
- include("includes.php");
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // get error
- $comments = sanitize($_GET['comments']);
-
- // set veriables
- $smarty->assign("comments", $lang['lang_comments_' . $comments]);
-
- // output
- $smarty->display("comments.tpl");
-
- include("footer.php");
-?>
\ No newline at end of file
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+
+include("header.php");
+
+
+$comments = sanitize($_GET['comments']);
+
+$smarty->assign("comments", $lang['lang_comments_' . $comments]);
+
+$smarty->display("comments.tpl");
+
+include("footer.php");
+?>
diff --git a/config.php b/config.php
deleted file mode 100644
index 7108104..0000000
--- a/config.php
+++ /dev/null
@@ -1,41 +0,0 @@
-.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // version
- $config_version = 'v0.7';
-
- // db connection
- $config_mysql_host = 'localhost';
- $config_mysql_username = 'ipreg';
- $config_mysql_password = 'changeme!';
- $config_mysql_dbname = 'ipreg';
-
- // default values for IP blocks
- $config_color_blocked = 'dcdcdc';
- $config_color_unused = 'ffffff';
- $config_color_dynamic = 'e0e0e0';
-
- // language
- $config_lang = array('de', 'en');
- $config_lang_default = 'en';
-
-?>
\ No newline at end of file
diff --git a/config.php-sample b/config.php-sample
new file mode 100644
index 0000000..0193a0b
--- /dev/null
+++ b/config.php-sample
@@ -0,0 +1,28 @@
+
diff --git a/dbconnect.php b/dbconnect.php
index d03236d..c81d5c9 100644
--- a/dbconnect.php
+++ b/dbconnect.php
@@ -1,28 +1,13 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // build connection
- $dblink = mysqli_connect($config_mysql_host,$config_mysql_username,$config_mysql_password);
-
- // select db
- mysqli_select_db($dblink, $config_mysql_dbname);
?>
diff --git a/footer.php b/footer.php
index dc460f3..d4de289 100644
--- a/footer.php
+++ b/footer.php
@@ -1,31 +1,13 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
-
- // get version for the footer-stamp
- $smarty->assign("config_version", $config_version);
-
- // end page
- // output
- $smarty->display("footer.tpl");
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+$smarty->assign("config_version", $config_version);
+
+$smarty->display("footer.tpl");
?>
\ No newline at end of file
diff --git a/header.php b/header.php
index 2d25135..6455ede 100644
--- a/header.php
+++ b/header.php
@@ -1,69 +1,41 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // include language file
- include('lang/' . $_SESSION['suser_language'] . '.php');
-
- // set language variables
- $smarty->assign($lang);
-
- // search box
- // new search?
- if (isset($_POST['search'])) {
- // set var
- $search = sanitize($_POST['search']);
-
- // store var
- $_SESSION['search'] = $search;
- } else {
- // check for stored var
- if(isset($_SESSION['search'])) {
- // set var
- $search = $_SESSION['search'];
- } else {
- // empty var
- $search = '';
- }
- }
-
- // to tpl
- // set global template vars
- $smarty->assign("config_version", $config_version);
- $smarty->assign("suser_name", $_SESSION['suser_displayname']);
- $smarty->assign("search", $search);
-
- // menu
- $smarty->assign("menu_assets", $_SESSION['suser_menu_assets']=='on');
- $smarty->assign("menu_assetclasses", $_SESSION['suser_menu_assetclasses']=='on');
- $smarty->assign("menu_assetclassgroups", $_SESSION['suser_menu_assetclassgroups']=='on');
- $smarty->assign("menu_locations", $_SESSION['suser_menu_locations']=='on');
- $smarty->assign("menu_nodes", $_SESSION['suser_menu_nodes']=='on');
- $smarty->assign("menu_subnets", $_SESSION['suser_menu_subnets']=='on');
- $smarty->assign("menu_users", $_SESSION['suser_menu_users']=='on');
- $smarty->assign("menu_vlans", $_SESSION['suser_menu_vlans']=='on');
- $smarty->assign("menu_zones", $_SESSION['suser_menu_zones']=='on');
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include('lang/' . $_SESSION['suser_language'] . '.php');
+$smarty->assign($lang);
+
+// search box
+if (isset($_POST['search'])) {
+ $search = sanitize($_POST['search']);
+ $_SESSION['search'] = $search;
+} else {
+ if (isset($_SESSION['search'])) {
+ $search = $_SESSION['search'];
+ } else {
+ $search = '';
+ }
+}
+
+$smarty->assign("config_version", $config_version);
+$smarty->assign("suser_name", $_SESSION['suser_displayname']);
+$smarty->assign("search", $search);
+
+// menu
+$smarty->assign("menu_assets", $_SESSION['suser_menu_assets']=='on');
+$smarty->assign("menu_assetclasses", $_SESSION['suser_menu_assetclasses']=='on');
+$smarty->assign("menu_assetclassgroups", $_SESSION['suser_menu_assetclassgroups']=='on');
+$smarty->assign("menu_locations", $_SESSION['suser_menu_locations']=='on');
+$smarty->assign("menu_nodes", $_SESSION['suser_menu_nodes']=='on');
+$smarty->assign("menu_subnets", $_SESSION['suser_menu_subnets']=='on');
+$smarty->assign("menu_users", $_SESSION['suser_menu_users']=='on');
+$smarty->assign("menu_vlans", $_SESSION['suser_menu_vlans']=='on');
+$smarty->assign("menu_zones", $_SESSION['suser_menu_zones']=='on');
- // end page
- // output
- $smarty->display("header.tpl");
-?>
\ No newline at end of file
+$smarty->display("header.tpl");
+?>
diff --git a/image.php b/image.php
index 163be86..cd92df5 100644
--- a/image.php
+++ b/image.php
@@ -1,109 +1,81 @@
.
+ imagealphablending($image, true);
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+ imagesavealpha($image, true);
- // start page
- // includes
- include("includes.php");
+ header('Content-type: image/png');
+ imagepng($image);
+ imagedestroy($image);
+}
+
+if(isset($_GET['color'])) {
+ $color = sanitize($_GET['color']);
- // icon image
- if(isset($_GET['icon'])) {
- // get desired image
- $icon = sanitize($_GET['icon']);
-
- // switch selected
- switch($icon) {
- case ("add") :
- $png = 'page_add';
- break;
- case ("back") :
- $png = 'control_rewind_blue';
- break;
- case ("cancel") :
- $png = 'control_rewind_blue';
- break;
- case ("comment") :
- $png = 'comment';
- break;
- case ("delete") :
- $png = 'page_delete';
- break;
- case ("shred") :
- $png = 'bin';
- break;
- case ("edit") :
- $png = 'page_edit';
- break;
- case ("error") :
- $png = 'error';
- break;
- case ("help") :
- $png = 'help';
- break;
- case ("logo") :
- $png = 'logo';
- break;
- case ("next") :
- $png = 'control_fastforward_blue';
- break;
- case ("save") :
- $png = 'page_save';
- break;
- case ("search") :
- $png = 'magnifier';
- break;
- }
-
- // get image
- $image = imagecreatefrompng("images/" . $png . ".png");
-
- // alpha blending
- imagealphablending($image, true);
-
- // save alphablending setting
- imagesavealpha($image, true);
-
- // display image
- header('Content-type: image/png');
- imagepng($image);
- imagedestroy($image);
- }
+ $image = imagecreatetruecolor($_SESSION['suser_imagesize'], $_SESSION['suser_imagesize']);
- // colored block
- if(isset($_GET['color'])) {
- // get desired color
- $color = sanitize($_GET['color']);
-
- // create base image
- $image = imagecreatetruecolor($_SESSION['suser_imagesize'], $_SESSION['suser_imagesize']);
-
- // build color
- $color = imagecolorallocate($image, hexdec(substr($color,0,2)), hexdec(substr($color,2,2)), hexdec(substr($color,4,2)));
-
- // fill image with color
- imagefill($image, 0, 0, $color);
-
- // display image
- header('Content-type: image/png');
- imagepng($image);
- imagedestroy($image);
- }
-?>
\ No newline at end of file
+ $color = imagecolorallocate($image, hexdec(substr($color,0,2)), hexdec(substr($color,2,2)), hexdec(substr($color,4,2)));
+
+ imagefill($image, 0, 0, $color);
+
+ header('Content-type: image/png');
+ imagepng($image);
+ imagedestroy($image);
+}
+?>
diff --git a/includes.php b/includes.php
index 856b5e3..5e02318 100644
--- a/includes.php
+++ b/includes.php
@@ -1,50 +1,26 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // session
- // start session
- session_name('ipreg');
- session_start();
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
- // check for user_id, if unnkown, redirect to login
- if(empty($_SESSION['suser_id'])) {
- // redirect
- header("Location: login.php");
- exit;
- }
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // headers
- // raw http headers
- header("Content-Type: text/html; charset=utf-8");
+session_name('ipreg');
+session_start();
+
+// check for user_id, if unnkown, redirect to login
+if(empty($_SESSION['suser_id'])) {
+ header("Location: login.php");
+ exit;
+}
- // includes
- // includes
- include("config.php");
- include("dbconnect.php");
+include("config.php");
+include("dbconnect.php");
- // load lib
- include("lib.php");
+include("lib.php");
- // set language
- $language = lang_getfrombrowser($config_lang, $config_lang_default, null, false);
+$language = lang_getfrombrowser($config_lang, $config_lang_default, null, false);
?>
\ No newline at end of file
diff --git a/index.php b/index.php
index 6e4f122..4e56d7c 100644
--- a/index.php
+++ b/index.php
@@ -1,118 +1,69 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
- // setup asset
- // build query
- $query = "SELECT
- COUNT(asset_id) AS asset_counter
- FROM
- asset";
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // run query
- $assets = $db->db_select($query);
-
- // counter to tpl
- $smarty->assign("asset_counter", $assets[0]['asset_counter']);
-
- // setup location
- // build query
- $query = "SELECT
- COUNT(location_id) AS location_counter
- FROM
- location";
-
- // run query
- $locations = $db->db_select($query);
-
- // counter to tpl
- $smarty->assign("location_counter", $locations[0]['location_counter']);
-
- // setup node
- // build query
- $query = "SELECT
- COUNT(node_id) AS node_counter
- FROM
- node";
-
- // run query
- $nodes = $db->db_select($query);
-
- // counter to tpl
- $smarty->assign("node_counter", $nodes[0]['node_counter']);
-
- // setup subnet
- // build query
- $query = "SELECT
- COUNT(subnet_id) AS subnet_counter
- FROM
- subnet";
-
- // run query
- $subnets = $db->db_select($query);
-
- // counter to tpl
- $smarty->assign("subnet_counter", $subnets[0]['subnet_counter']);
-
- // setup vlan
- // build query
- $query = "SELECT
- COUNT(vlan_id) AS vlan_counter
- FROM
- vlan";
-
- // run query
- $vlans = $db->db_select($query);
-
- // counter to tpl
- $smarty->assign("vlan_counter", $vlans[0]['vlan_counter']);
+include("includes.php");
- // setup zone
- // build query
- $query = "SELECT
- COUNT(zone_id) AS zone_counter
- FROM
- zone";
-
- // run query
- $zones = $db->db_select($query);
-
- // counter to tpl
- $smarty->assign("zone_counter", $zones[0]['zone_counter']);
+include("header.php");
+// asset
+$query = "SELECT
+ COUNT(asset_id) AS asset_counter
+ FROM
+ asset";
- // end page
- // output
- $smarty->display("index.tpl");
+$assets = $db->db_select($query);
+$smarty->assign("asset_counter", $assets[0]['asset_counter']);
- // footer
- include("footer.php");
-?>
\ No newline at end of file
+// location
+$query = "SELECT
+ COUNT(location_id) AS location_counter
+ FROM
+ location";
+
+$locations = $db->db_select($query);
+$smarty->assign("location_counter", $locations[0]['location_counter']);
+
+// node
+$query = "SELECT
+ COUNT(node_id) AS node_counter
+ FROM
+ node";
+
+$nodes = $db->db_select($query);
+$smarty->assign("node_counter", $nodes[0]['node_counter']);
+
+// subnet
+$query = "SELECT
+ COUNT(subnet_id) AS subnet_counter
+ FROM
+ subnet";
+$subnets = $db->db_select($query);
+$smarty->assign("subnet_counter", $subnets[0]['subnet_counter']);
+
+// vlan
+$query = "SELECT
+ COUNT(vlan_id) AS vlan_counter
+ FROM
+ vlan";
+
+$vlans = $db->db_select($query);
+$smarty->assign("vlan_counter", $vlans[0]['vlan_counter']);
+
+// zone
+$query = "SELECT
+ COUNT(zone_id) AS zone_counter
+ FROM
+ zone";
+$zones = $db->db_select($query);
+$smarty->assign("zone_counter", $zones[0]['zone_counter']);
+
+$smarty->display("index.tpl");
+
+include("footer.php");
+?>
diff --git a/lib.php b/lib.php
index d050091..9fbe207 100644
--- a/lib.php
+++ b/lib.php
@@ -1,48 +1,25 @@
.
+require("lib/db.class.php");
+$db = new Db($dblink);
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+require("lib/user.class.php");
+$user = new User();
- // functions
- include("lib/functions.php");
+require_once('smarty3/Smarty.class.php');
+$smarty = new Smarty();
+$smarty->template_dir = 'tpl';
+$smarty->compile_dir = 'tpl_c';
+$smarty->registerPlugin('function', 'treelist', 'print_tree');
+$smarty->assign("suser_tooltips", $_SESSION['suser_tooltips']);
- // classes
- // db
- // load class
- require("lib/db.class.php");
-
- // create instance
- $db = new Db($dblink);
-
- // user
- // load class
- require("lib/user.class.php");
-
- // create instance
- $user = new User();
-
- // tpl
- require_once('smarty3/Smarty.class.php');
- $smarty = new Smarty();
- $smarty->template_dir = 'tpl';
- $smarty->compile_dir = 'tpl_c';
- $smarty->registerPlugin('function', 'treelist', 'print_tree');
- $smarty->assign("suser_tooltips", $_SESSION['suser_tooltips']);
?>
diff --git a/location.php b/location.php
index 495281c..5506bd4 100644
--- a/location.php
+++ b/location.php
@@ -1,70 +1,46 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
- // start page
- // includes
- include("includes.php");
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
- // start output
- include("header.php");
+include("header.php");
- // set language variables
- $smarty->assign($lang);
+$query = "SELECT
+ location_id AS id,
+ location_name AS value,
+ location_parent AS parent_id
+FROM
+ location
+ORDER BY location_parent, location_sort, location_name";
- // start location
- // look for locations
- // build query
- $query = "SELECT
- location_id AS id,
- location_name AS value,
- location_parent AS parent_id
- FROM
- location
- ORDER BY location_parent, location_sort, location_name";
+$locations = $db->db_select($query);
- // run query
- $locations = $db->db_select($query);
+// function for recursion
+function build_tree($parent_id, $level) {
+ global $locations;
+ $children = array();
+ foreach ($locations as $key => $location) {
+ if ($location['parent_id'] == $parent_id) {
+ unset($location['parent_id']);
+ $location['children'] = build_tree($location['id'], $level+1);
+ $location['level'] = $level;
+ $location['href'] = 'locationview.php?location_id=' . $location['id'];
+ $children[] = $location;
+ }
+ }
+ return $children;
+}
- function build_tree($parent_id, $level) {
- global $locations;
- $children = array();
- foreach ($locations as $key => $location) {
- if ($location['parent_id'] == $parent_id) {
- unset($location['parent_id']);
- $location['children'] = build_tree($location['id'], $level+1);
- $location['level'] = $level;
- $location['href'] = 'locationview.php?location_id=' . $location['id'];
- $children[] = $location;
- }
- }
- return $children;
- }
- $tree = build_tree(0, 0);
- $smarty->assign("locations", $tree);
+$tree = build_tree(0, 0);
+$smarty->assign("locations", $tree);
- // end page
- // output
- $smarty->display("location.tpl");
+$smarty->display("location.tpl");
- // footer
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/locationadd.php b/locationadd.php
index 168ebaf..4c75102 100644
--- a/locationadd.php
+++ b/locationadd.php
@@ -1,109 +1,78 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
+include("includes.php");
- // get id
- $location_parent = sanitize($_GET['location_parent']);
+$location_parent = sanitize($_GET['location_parent']);
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
+include("header.php");
// *************
+$query = "SELECT location_id, location_name, location_parent, location_sort
+ FROM location
+ ORDER BY location_parent, location_sort, location_name";
- // start parent
- // look for locations
- // build query
- $query = "SELECT location_id, location_name, location_parent, location_sort
- FROM location
- ORDER BY location_parent, location_sort, location_name";
-
- // run query
- $locations = $db->db_select($query);
+$locations = $db->db_select($query);
- // count results
- $location_counter = count($locations);
+$location_counter = count($locations);
- // any loactions?
- if ($location_counter>0) {
- // get objects
- foreach($locations AS $location) {
- // create arrays
- $location_names[$location['location_id']] = $location['location_name'];
- $parents[$location['location_parent']][] = $location['location_id'];
- }
- }
-
- // look for parents
- // function to look for parents and create a new array for every child
- function location($parents, $parent = 0) {
- // loop array to check
- foreach($parents[$parent] as $child) {
- if(isset($parents[$child])) {
- // element has children
- $children[$child] = location($parents, $child);
- } else {
- // no children, set NULL
- $children[$child] = NULL;
- }
- }
-
- // and again...
- return $children;
- }
+if ($location_counter>0) {
+ // get objects
+ foreach ($locations AS $location) {
+ // create arrays
+ $location_names[$location['location_id']] = $location['location_name'];
+ $parents[$location['location_parent']][] = $location['location_id'];
+ }
+}
+
+// look for parents
+// function to look for parents and create a new array for every child
+function location($parents, $parent = 0) {
+ // loop array to check
+ foreach ($parents[$parent] as $child) {
+ if (isset($parents[$child])) {
+ // element has children
+ $children[$child] = location($parents, $child);
+ } else {
+ // no children, set NULL
+ $children[$child] = NULL;
+ }
+ }
+
+ // and again...
+ return $children;
+}
- // recursive children check to template
- function checkchildren($locations, $level) {
- global $location_options;
- global $location_names;
- global $location_parent;
+// recursive children check to template
+function checkchildren($locations, $level) {
+ global $location_options;
+ global $location_names;
+ global $location_parent;
- foreach ($locations as $parent=>$child) {
- $row = str_repeat("- ", $level) . $location_names[$parent];
- $location_options[$parent] = $row;
- if(isset($child)) {
- checkchildren($child, $level+1);
- }
- }
-
- }
+ foreach ($locations as $parent=>$child) {
+ $row = str_repeat("- ", $level) . $location_names[$parent];
+ $location_options[$parent] = $row;
+ if (isset($child)) {
+ checkchildren($child, $level+1);
+ }
+ }
+}
- $tree = location($parents);
- $location_options = array(0 => '-');
- checkchildren($tree, 0);
- $smarty->assign("location_options", $location_options);
- $smarty->assign("location_parent", $location_parent);
+$tree = location($parents);
+$location_options = array(0 => '-');
+checkchildren($tree, 0);
+$smarty->assign("location_options", $location_options);
+$smarty->assign("location_parent", $location_parent);
- // end page
- // output
- $smarty->display("locationadd.tpl");
+$smarty->display("locationadd.tpl");
- // footer
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/locationdel.php b/locationdel.php
index 615537e..91ef975 100644
--- a/locationdel.php
+++ b/locationdel.php
@@ -1,58 +1,31 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
+include("includes.php");
- // get id
- $location_id = sanitize($_GET['location_id']);
+$location_id = sanitize($_GET['location_id']);
- // start output
- include("header.php");
+include("header.php");
- // set language variables
- $smarty->assign($lang);
-
- // setup location
- // build query
- $query = "SELECT
- location_name
- FROM
- location
- WHERE
- location_id=" . $location_id;
+$query = "SELECT
+ location_name
+FROM
+ location
+WHERE
+ location_id=" . $location_id;
- // run query
- $location = $db->db_select($query);
+$location = $db->db_select($query);
- // send to tpl
- $smarty->assign("location_id", $location_id);
- $smarty->assign("location_name", $location[0]['location_name']);
+$smarty->assign("location_id", $location_id);
+$smarty->assign("location_name", $location[0]['location_name']);
- // end page
- // output
- $smarty->display("locationdel.tpl");
+$smarty->display("locationdel.tpl");
- // footer
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/locationedit.php b/locationedit.php
index 8bffd91..6ecfb34 100644
--- a/locationedit.php
+++ b/locationedit.php
@@ -1,139 +1,104 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
+include("includes.php");
- // get id
- $location_id = sanitize($_GET['location_id']);
+$location_id = sanitize($_GET['location_id']);
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup location
- // build query
- $query = "SELECT
- location_name,
- location_parent,
- location_info,
- location_sort
- FROM
- location
- WHERE
- location.location_id=" . $location_id;
+include("header.php");
+
+// location
+$query = "SELECT
+ location_name,
+ location_parent,
+ location_info,
+ location_sort
+FROM
+ location
+WHERE
+ location_id=" . $location_id;
- // run query
- $location = $db->db_select($query);
+$location = $db->db_select($query);
- // get parent
- $location_parent = $location[0]['location_parent'];
+$location_parent = $location[0]['location_parent'];
- // send to tpl
- $smarty->assign("location_id", $location_id);
- $smarty->assign("location_name", $location[0]['location_name']);
- $smarty->assign("location_info", $location[0]['location_info']);
- $smarty->assign("location_sort", $location[0]['location_sort']);
+$smarty->assign("location_id", $location_id);
+$smarty->assign("location_name", $location[0]['location_name']);
+$smarty->assign("location_info", $location[0]['location_info']);
+$smarty->assign("location_sort", $location[0]['location_sort']);
- // setup parent location
- // look for locations
- // build query
- $query = "SELECT
- location_id,
- location_name,
- location_parent
- FROM
- location
- WHERE
- location_id != " . $location_id . "
- ORDER BY
- location.location_name";
+// parent location
+$query = "SELECT
+ location_id,
+ location_name,
+ location_parent
+FROM
+ location
+WHERE
+ location_id != " . $location_id . "
+ORDER BY
+ location_name";
- // run query
- $locations = $db->db_select($query);
+$locations = $db->db_select($query);
- // count results
- $location_counter = count($locations);
+$location_counter = count($locations);
- // counter to tpl
- $smarty->assign("location_counter", $location_counter);
+$smarty->assign("location_counter", $location_counter);
- // any loactions?
- if ($location_counter>0) {
- // get objects
- foreach($locations AS $location) {
- // create arrays
- $location_names[$location['location_id']] = $location['location_name'];
- $parents[$location['location_parent']][] = $location['location_id'];
- }
- }
-
- // look for parents
- // function to look for parents and create a new array for every child
- function location($parents, $parent = 0) {
- // loop array to check
- foreach($parents[$parent] as $child) {
- if(isset($parents[$child])) {
- // element has children
- $children[$child] = location($parents, $child);
- } else {
- // no children, set NULL
- $children[$child] = NULL;
- }
- }
-
- // and again...
- return $children;
- }
-
- // recursive children check to template
- function checkchildren($locations, $level) {
- global $location_options;
- global $location_names;
- global $location_parent;
-
- foreach ($locations as $parent=>$child) {
- $row = str_repeat("- ", $level) . $location_names[$parent];
- $location_options[$parent] = $row;
- if(isset($child)) {
- checkchildren($child, $level+1);
- }
- }
- }
+// any loactions?
+if ($location_counter>0) {
+ foreach($locations AS $location) {
+ $location_names[$location['location_id']] = $location['location_name'];
+ $parents[$location['location_parent']][] = $location['location_id'];
+ }
+}
- $tree = location($parents);
- $location_options = array(0 => '-');
- checkchildren($tree, 0);
- $smarty->assign("location_options", $location_options);
- $smarty->assign("location_parent", $location_parent);
+// look for parents
+// function to look for parents and create a new array for every child
+function location($parents, $parent = 0) {
+ // loop array to check
+ foreach($parents[$parent] as $child) {
+ if(isset($parents[$child])) {
+ // element has children
+ $children[$child] = location($parents, $child);
+ } else {
+ // no children, set NULL
+ $children[$child] = NULL;
+ }
+ }
+
+ // and again...
+ return $children;
+}
+// recursive children check to template
+function checkchildren($locations, $level) {
+ global $location_options;
+ global $location_names;
+ global $location_parent;
+
+ foreach ($locations as $parent=>$child) {
+ $row = str_repeat("- ", $level) . $location_names[$parent];
+ $location_options[$parent] = $row;
+ if(isset($child)) {
+ checkchildren($child, $level+1);
+ }
+ }
+}
- // end page
- // output
- $smarty->display("locationedit.tpl");
+$tree = location($parents);
+$location_options = array(0 => '-');
+checkchildren($tree, 0);
+$smarty->assign("location_options", $location_options);
+$smarty->assign("location_parent", $location_parent);
+
+$smarty->display("locationedit.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/locationsubnetadd.php b/locationsubnetadd.php
index c01f319..1f11e63 100644
--- a/locationsubnetadd.php
+++ b/locationsubnetadd.php
@@ -1,60 +1,31 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
+include("includes.php");
- // get ip and id
- $location_id = sanitize($_GET['location_id']);
+$location_id = sanitize($_GET['location_id']);
- // start output
- include("header.php");
+include("header.php");
- // set language variables
- $smarty->assign($lang);
-
- // setup location
- // build query
- $query = "SELECT
- location_name
- FROM
- location
- WHERE
- location_id=" . $location_id;
-
- // run query
- $location = $db->db_select($query);
-
- $smarty->assign("location_id", $location_id);
- $smarty->assign("location_name", $location[0]['location_name']);
+$query = "SELECT
+ location_name
+ FROM
+ location
+ WHERE
+ location_id=" . $location_id;
- // setup subnet
- $smarty->assign("subnet_options", $db->options_subnet());
-
- // end page
- // output
- $smarty->display("locationsubnetadd.tpl");
+$location = $db->db_select($query);
+
+$smarty->assign("location_id", $location_id);
+$smarty->assign("location_name", $location[0]['location_name']);
+$smarty->assign("subnet_options", $db->options_subnet());
+$smarty->display("locationsubnetadd.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/locationsubnetdel.php b/locationsubnetdel.php
index 36d74d6..b5f4e8e 100644
--- a/locationsubnetdel.php
+++ b/locationsubnetdel.php
@@ -1,76 +1,47 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
+include("includes.php");
- // get ip and id
- $location_id = sanitize($_GET['location_id']);
+$location_id = sanitize($_GET['location_id']);
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup location
- // build query
- $query = "SELECT
- location.location_name AS location_name
- FROM
- location
- WHERE
- location.location_id=" . $location_id;
+include("header.php");
+
+// location
+$query = "SELECT
+ location_name
+FROM
+ location
+WHERE
+ location_id=" . $location_id;
- // run query
- $location = $db->db_select($query);
+$location = $db->db_select($query);
- $smarty->assign("location_id", $location_id);
- $smarty->assign("location_name", $location[0]['location_name']);
+$smarty->assign("location_id", $location_id);
+$smarty->assign("location_name", $location[0]['location_name']);
- // setup subnet
- // build query
- $query = "SELECT
- subnet.subnet_id AS subnet_id,
- subnet.subnet_address AS subnet_address,
- subnet.subnet_mask AS subnet_mask
- FROM
- subnetlocation,
- subnet
- WHERE
- subnetlocation.location_id=" . $location_id . "
- AND subnet.subnet_id=subnetlocation.subnet_id
- ORDER BY
- INET_ATON(subnet.subnet_address)";
-
- // run query
- $subnets = $db->db_select($query);
- $smarty->assign($subnets);
+// subnet
+$query = "SELECT
+ s.subnet_id,
+ s.subnet_address,
+ s.subnet_mask
+ FROM
+ subnetlocation AS l LEFT JOIN subnet AS s USING (subnet_id)
+ WHERE
+ l.location_id=" . $location_id . "
+ ORDER BY
+ INET_ATON(s.subnet_address)";
+
+$subnets = $db->db_select($query);
+$smarty->assign($subnets);
- // end page
- // output
- $smarty->display("locationsubnetdel.tpl");
+$smarty->display("locationsubnetdel.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/locationsubnetedit.php b/locationsubnetedit.php
index 6dd1381..905a0d0 100644
--- a/locationsubnetedit.php
+++ b/locationsubnetedit.php
@@ -1,58 +1,31 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get ip and id
- $location_id = sanitize($_GET['location_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // setup location
- // build query
- $query = "SELECT
- location_name
- FROM
- location
- WHERE
- location_id=" . $location_id;
+include("includes.php");
- // run query
- $location = $db->db_select($query);
+$location_id = sanitize($_GET['location_id']);
- // send to tpl
- $smarty->assign("location_id", $location_id);
- $smarty->assign("location_name", $location[0]['location_name']);
+include("header.php");
+// location
+$query = "SELECT
+ location_name
+ FROM
+ location
+ WHERE
+ location_id=" . $location_id;
+
+$location = $db->db_select($query);
+
+$smarty->assign("location_id", $location_id);
+$smarty->assign("location_name", $location[0]['location_name']);
- // end page
- // output
- $smarty->display("locationsubnetedit.tpl");
+$smarty->display("locationsubnetedit.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/locationview.php b/locationview.php
index badebd4..95ccf78 100644
--- a/locationview.php
+++ b/locationview.php
@@ -1,108 +1,80 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
+include("includes.php");
- // get id
- $location_id = sanitize($_GET['location_id']);
+$location_id = sanitize($_GET['location_id']);
- // start output
- include("header.php");
+include("header.php");
- // set language variables
- $smarty->assign($lang);
- // start locationcrumb
- // get location crumbs
+// locationcrumb
- $query = "SELECT location_id AS id,
- location_name AS name,
- location_parent AS parent_id,
- location_info
- FROM location
- WHERE location_id=" . $location_id;
- $location = $db->db_select($query);
- $location[0]['url'] = 'locationview.php?location_id=' . $location[0]['id'];
- $crumbs[] = $location[0];
- $level = 1;
- while ($crumbs[0]['parent_id'] != 0) {
- $query = "SELECT location_id AS id,
- location_name AS name,
- location_parent AS parent_id
- FROM location
- WHERE location_id=" . $crumbs[0]['parent_id'];
- $result = $db->db_select($query);
- $result[0]['url'] = 'locationview.php?location_id=' . $result[0]['id'];
- array_unshift($crumbs, $result[0]);
- $level++;
- }
+$query = "SELECT location_id AS id,
+ location_name AS name,
+ location_parent AS parent_id,
+ location_info
+ FROM location
+ WHERE location_id=" . $location_id;
+$location = $db->db_select($query);
+$location[0]['url'] = 'locationview.php?location_id=' . $location[0]['id'];
+$crumbs[] = $location[0];
+$level = 1;
+while ($crumbs[0]['parent_id'] != 0) {
+ $query = "SELECT location_id AS id,
+ location_name AS name,
+ location_parent AS parent_id
+ FROM location
+ WHERE location_id=" . $crumbs[0]['parent_id'];
+ $result = $db->db_select($query);
+ $result[0]['url'] = 'locationview.php?location_id=' . $result[0]['id'];
+ array_unshift($crumbs, $result[0]);
+ $level++;
+}
- // send to tpl
- $smarty->assign("location_id", $location_id);
- $smarty->assign("location_info", nl2br($location[0]['location_info']));
- $smarty->assign("crumbs", $crumbs);
+$smarty->assign("location_id", $location_id);
+$smarty->assign("location_info", nl2br($location[0]['location_info']));
+$smarty->assign("crumbs", $crumbs);
- // setup sublocations
- // build query
- $query = "SELECT
- location_id AS sublocation_id,
- location_name AS sublocation_name,
- LEFT(location_info, 40) AS info_short,
- CHAR_LENGTH(location_info) AS info_length
- FROM
- location
- WHERE
- location_parent=" . $location_id . "
- ORDER BY
- location_name";
+// sublocations
+$query = "SELECT
+ location_id AS sublocation_id,
+ location_name AS sublocation_name,
+ LEFT(location_info, 40) AS info_short,
+ CHAR_LENGTH(location_info) AS info_length
+ FROM
+ location
+ WHERE
+ location_parent=" . $location_id . "
+ ORDER BY
+ location_name";
- // run query
- $sublocations = $db->db_select($query);
- $smarty->assign("sublocations", $sublocations);
+$sublocations = $db->db_select($query);
+$smarty->assign("sublocations", $sublocations);
- // setup subnets
- // build query
- $query = "SELECT
- s.subnet_id,
- s.subnet_address,
- s.subnet_mask
- FROM
- subnet AS s LEFT JOIN subnetlocation USING (subnet_id)
- WHERE
- subnetlocation.location_id=" . $location_id . "
- ORDER BY
- INET_ATON(s.subnet_address)";
+// subnets
+$query = "SELECT
+ s.subnet_id,
+ s.subnet_address,
+ s.subnet_mask
+ FROM
+ subnet AS s LEFT JOIN subnetlocation USING (subnet_id)
+ WHERE
+ subnetlocation.location_id=" . $location_id . "
+ ORDER BY
+ INET_ATON(s.subnet_address)";
- // run query
- $subnets = $db->db_select($query);
- $smarty->assign("subnets", $subnets);
+$subnets = $db->db_select($query);
+$smarty->assign("subnets", $subnets);
- // end page
- // output
- $smarty->display("locationview.tpl");
+$smarty->display("locationview.tpl");
- // footer
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/login.php b/login.php
index 5a1eee3..b355d10 100644
--- a/login.php
+++ b/login.php
@@ -1,77 +1,47 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // session
- // start session
- session_name('ipreg');
- session_start();
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+session_name('ipreg');
+session_start();
- // headers
- // raw http headers
- header("Content-Type: text/html; charset=utf-8");
+include("config.php");
+include("dbconnect.php");
- // includes
- // includes
- include("config.php");
- include("dbconnect.php");
+include("lib.php");
- // load lib
- include("lib.php");
-
- // include language file
- $language = lang_getfrombrowser($config_lang, $config_lang_default, null, false);
- include('lang/' . $language . '.php');
+// include language file
+$language = lang_getfrombrowser($config_lang, $config_lang_default, null, false);
+include('lang/' . $language . '.php');
- // try login?
- // check for submit
- if ($_SERVER['REQUEST_METHOD']=="POST" ) {
- /// get post info
- $user_name = sanitize($_POST['user_name']);
- $user_pass = sanitize($_POST['user_pass']);
-
- // login
- $login = $user->user_login($user_name, $user_pass);
-
- if($login==TRUE) {
- // redirect
- header_location("index.php");
- } else {
- // not ok, break session
- $_SESSION = array();
- session_destroy();
- }
- }
-
- // start output
- // get version for the footer-stamp
- $smarty->assign("config_version", $config_version);
-
- // set language variables
- $smarty->assign($lang);
+// check for submit
+if ($_SERVER['REQUEST_METHOD']=="POST" ) {
+ /// get post info
+ $user_name = sanitize($_POST['user_name']);
+ $user_pass = sanitize($_POST['user_pass']);
- // end page
- // output
- $smarty->display("login.tpl");
+ // login
+ $login = $user->user_login($user_name, $user_pass);
+
+ if($login==TRUE) {
+ // redirect
+ header_location("index.php");
+ } else {
+ // not ok, break session
+ $_SESSION = array();
+ session_destroy();
+ }
+}
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+$smarty->assign("config_version", $config_version);
+$smarty->assign($lang);
+
+$smarty->display("login.tpl");
+
+include("footer.php");
+?>
diff --git a/logout.php b/logout.php
index 34518e2..6047e76 100644
--- a/logout.php
+++ b/logout.php
@@ -1,33 +1,17 @@
.
+// user logout: clear session
+$_SESSION = array();
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // logout
- // user logout
- $user->user_logout();
-
- // redirect
- header("Location: index.php");
+// redirect to start page
+header("Location: index.php");
?>
\ No newline at end of file
diff --git a/natadd.php b/natadd.php
index b94e5f4..395bcf0 100644
--- a/natadd.php
+++ b/natadd.php
@@ -1,90 +1,63 @@
.
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+include("includes.php");
- // start page
- // includes
- include("includes.php");
-
- // get ip and id
- $node_id = sanitize($_GET['node_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
+$node_id = sanitize($_GET['node_id']);
- // setup node_ext
- // build query
- $query = "SELECT
- node_ip AS node_ip_ext
- FROM
- node
- WHERE
- node_id=" . $node_id;
+include("header.php");
+
+// node_ext
+$query = "SELECT
+ node_ip AS node_ip_ext
+ FROM
+ node
+ WHERE
+ node_id=" . $node_id;
- // run query
- $node = $db->db_select($query);
+$node = $db->db_select($query);
- $smarty->assign("node_id_ext", $node_id);
- $smarty->assign("node_ip_ext", $node[0]['node_ip_ext']);
+$smarty->assign("node_id_ext", $node_id);
+$smarty->assign("node_ip_ext", $node[0]['node_ip_ext']);
- // setup node_int
- // build query
- $query = "SELECT
- a.asset_name,
- n.node_id AS node_id_int,
- n.node_ip AS node_ip_int
+// node_int
+$query = "SELECT
+ a.asset_name,
+ n.node_id AS node_id_int,
+ n.node_ip AS node_ip_int
+ FROM
+ asset AS a LEFT JOIN node AS n USING (asset_id)
+ WHERE
+ n.node_id NOT IN (
+ SELECT
+ nat_int
FROM
- asset AS a LEFT JOIN node AS n USING (asset_id)
+ nat
WHERE
- n.node_id NOT IN (
- SELECT
- nat_int
- FROM
- nat
- WHERE
- nat_ext=" . $node_id . "
- )
- AND n.node_id!=" . $node_id . "
- ORDER BY
- INET_ATON(n.node_ip)";
-
- // run query
- $nodes = $db->db_select($query);
- foreach ($nodes as $rec) {
- $node_options[$rec['node_id_int']] = $rec['node_ip_int'] . '/' . $rec['asset_name'];
- }
- $smarty->assign("node_options", $node_options);
+ nat_ext=" . $node_id . "
+ )
+ AND n.node_id!=" . $node_id . "
+ ORDER BY
+ INET_ATON(n.node_ip)";
+
+$nodes = $db->db_select($query);
+foreach ($nodes as $rec) {
+ $node_options[$rec['node_id_int']] = $rec['node_ip_int'] . '/' . $rec['asset_name'];
+}
+$smarty->assign("node_options", $node_options);
- $nat_type_options[1] = $lang['lang_nat_type_1'];
- $nat_type_options[2] = $lang['lang_nat_type_2'];
- $nat_type_options[3] = $lang['lang_nat_type_3'];
- $smarty->assign("nat_type_options", $nat_type_options);
+$nat_type_options[1] = $lang['lang_nat_type_1'];
+$nat_type_options[2] = $lang['lang_nat_type_2'];
+$nat_type_options[3] = $lang['lang_nat_type_3'];
+$smarty->assign("nat_type_options", $nat_type_options);
- // end page
- // output
- $smarty->display("natadd.tpl");
+$smarty->display("natadd.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/natdel.php b/natdel.php
index b0e4eba..94f44d8 100644
--- a/natdel.php
+++ b/natdel.php
@@ -1,83 +1,55 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get ip and id
- $node_id = sanitize($_GET['node_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup node_ext
- // build query
- $query = "SELECT
- node_ip AS node_ip_ext
- FROM
- node
- WHERE
- node_id=" . $node_id;
-
- // run query
- $node = $db->db_select($query);
-
- $smarty->assign("node_id_ext", $node_id);
- $smarty->assign("node_ip_ext", $node[0]['node_ip_ext']);
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // setup options
- // build query
- $query = "SELECT
- a.asset_name,
- n.node_ip,
- x.nat_ext
- FROM
- asset AS a,
- nat AS x,
- node AS n
- WHERE
- x.nat_ext=" . $node_id . "
- AND n.node_id=x.nat_int
- AND a.asset_id=n.asset_id
- ORDER BY
- INET_ATON(n.node_ip)";
+include("includes.php");
+
+$node_id = sanitize($_GET['node_id']);
+
+include("header.php");
+
+// node_ext
+$query = "SELECT
+ node_ip AS node_ip_ext
+ FROM
+ node
+ WHERE
+ node_id=" . $node_id;
+
+$node = $db->db_select($query);
+
+$smarty->assign("node_id_ext", $node_id);
+$smarty->assign("node_ip_ext", $node[0]['node_ip_ext']);
- // run query
- $nodes = $db->db_select($query);
+// options
+$query = "SELECT
+ a.asset_name,
+ n.node_ip,
+ x.nat_ext
+ FROM
+ asset AS a,
+ nat AS x,
+ node AS n
+ WHERE
+ x.nat_ext=" . $node_id . "
+ AND n.node_id=x.nat_int
+ AND a.asset_id=n.asset_id
+ ORDER BY
+ INET_ATON(n.node_ip)";
- $options = array();
- foreach ($nodes as $rec) {
- $options[$rec['nat_ext']] = $rec['node_ip'] . '/' . $rec['asset_name'];
- }
- $smarty->assign("nat_options", $options);
+$nodes = $db->db_select($query);
- // end page
- // output
- $smarty->display("natdel.tpl");
+$options = array();
+foreach ($nodes as $rec) {
+ $options[$rec['nat_ext']] = $rec['node_ip'] . '/' . $rec['asset_name'];
+}
+$smarty->assign("nat_options", $options);
+$smarty->display("natdel.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/natedit.php b/natedit.php
index 9ff71bf..dd4408c 100644
--- a/natedit.php
+++ b/natedit.php
@@ -1,57 +1,31 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
+include("includes.php");
- // get id
- $node_id = sanitize($_GET['node_id']);
+$node_id = sanitize($_GET['node_id']);
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup node
- // build query
- $query = "SELECT
- node.node_ip AS node_ip
- FROM
- node
- WHERE
- node.node_id=" . $node_id;
-
- // run query
- $node = $db->db_select($query);
+include("header.php");
+
+$query = "SELECT
+ node_ip
+FROM
+ node
+WHERE
+ node.node_id=" . $node_id;
+
+$node = $db->db_select($query);
- $smarty->assign("node_id", $node_id);
- $smarty->assign("node_ip", $node[0]['node_ip']);
+$smarty->assign("node_id", $node_id);
+$smarty->assign("node_ip", $node[0]['node_ip']);
- // end page
- // output
- $smarty->display("natedit.tpl");
+$smarty->display("natedit.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/node.php b/node.php
index a2d648c..c03a421 100644
--- a/node.php
+++ b/node.php
@@ -1,78 +1,40 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // start node
- // setup view
- // subnet
- if(isset($_GET['subnet_id'])) {
- // get id
- $subnet_id = sanitize($_GET['subnet_id']);
-
- // build query part
- $subnet_view = "AND node.subnet_id=" . $subnet_id;
-
- // to tpl
- $smarty->assign("subnet_id", $subnet_id);
- } else {
- // to tpl
- $smarty->assign("subnet_id", "");
- }
-
- // build query
- $query = "SELECT
- asset.asset_id,
- REPLACE(asset.asset_name, ' ', ' ') AS asset_name,
- asset.asset_info,
- node.node_id,
- node.node_ip
- FROM
- asset,
- node
- WHERE
- asset.asset_id=node.asset_id
- " . $subnet_view . "
- GROUP BY
- node.node_id
- ORDER BY
- INET_ATON(node.node_ip)";
-
- // run query
- $nodes = $db->db_select($query);
- $smarty->assign("nodes", $nodes);
-
- // end page
- // output
- $smarty->display("node.tpl");
-
- // end output
- include("footer.php");
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+include("header.php");
+
+if(isset($_GET['subnet_id'])) {
+ $subnet_id = sanitize($_GET['subnet_id']);
+ $subnet_view = "WHERE node.subnet_id=" . $subnet_id;
+ $smarty->assign("subnet_id", $subnet_id);
+} else {
+ $smarty->assign("subnet_id", "");
+}
+
+$query = "SELECT
+ asset.asset_id,
+ REPLACE(asset.asset_name, ' ', ' ') AS asset_name,
+ asset.asset_info,
+ node.node_id,
+ node.node_ip
+ FROM
+ asset LEFT JOIN node USING (asset_id)
+ " . $subnet_view . "
+ GROUP BY
+ node.node_id
+ ORDER BY
+ INET_ATON(node.node_ip)";
+
+$nodes = $db->db_select($query);
+$smarty->assign("nodes", $nodes);
+$smarty->display("node.tpl");
+
+include("footer.php");
?>
diff --git a/nodeadd.php b/nodeadd.php
index d96f9d1..31791ad 100644
--- a/nodeadd.php
+++ b/nodeadd.php
@@ -1,54 +1,26 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
+include("includes.php");
- // check for set ip and/or subnet_id
- if ((isset($_GET['node_ip'])) ? $node_ip = sanitize($_GET['node_ip']) : $node_ip = '');
- if ((isset($_GET['subnet_id'])) ? $subnet_id = sanitize($_GET['subnet_id']) : $subnet_id = '');
+if ((isset($_GET['node_ip'])) ? $node_ip = sanitize($_GET['node_ip']) : $node_ip = '');
+if ((isset($_GET['subnet_id'])) ? $subnet_id = sanitize($_GET['subnet_id']) : $subnet_id = '');
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
+include("header.php");
- // set vars
- $smarty->assign("user_dns1suffix", $_SESSION['suser_dns1suffix']);
- $smarty->assign("user_dns2suffix", $_SESSION['suser_dns2suffix']);
- $smarty->assign("node_ip", $node_ip);
+$smarty->assign("user_dns1suffix", $_SESSION['suser_dns1suffix']);
+$smarty->assign("user_dns2suffix", $_SESSION['suser_dns2suffix']);
+$smarty->assign("node_ip", $node_ip);
- // setup subnet
- $smarty->assign("subnet_options", $db->options_subnet());
-
- // setup assetclass
- $smarty->assign("assetclass_options", $db->options_assetclass());
-
- // end page
- // output
- $smarty->display("nodeadd.tpl");
+$smarty->assign("subnet_options", $db->options_subnet());
+$smarty->assign("assetclass_options", $db->options_assetclass());
+$smarty->display("nodeadd.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/nodedel.php b/nodedel.php
index e47775b..46ce123 100644
--- a/nodedel.php
+++ b/nodedel.php
@@ -1,60 +1,35 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get id
- $node_id = sanitize($_GET['node_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup node
- // build query
- $query = "SELECT
- asset_id,
- node_ip
- FROM
- node
- WHERE
- node_id=" . $node_id;
+include("includes.php");
- // run query
- $node = $db->db_select($query);
+$node_id = sanitize($_GET['node_id']);
- // send to tpl
- $smarty->assign("node_id", $node_id);
- $smarty->assign("asset_id", $node[0]['asset_id']);
- $smarty->assign("node_ip", $node[0]['node_ip']);
+include("header.php");
+
+$query = "SELECT
+ asset_id,
+ node_ip
+ FROM
+ node
+ WHERE
+ node_id=" . $node_id;
+
+// run query
+$node = $db->db_select($query);
+
+// send to tpl
+$smarty->assign("node_id", $node_id);
+$smarty->assign("asset_id", $node[0]['asset_id']);
+$smarty->assign("node_ip", $node[0]['node_ip']);
- // end page
- // output
- $smarty->display("nodedel.tpl");
+$smarty->display("nodedel.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/nodeedit.php b/nodeedit.php
index 54080d9..dd0e7f6 100644
--- a/nodeedit.php
+++ b/nodeedit.php
@@ -1,86 +1,54 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
-
- // get id
- $node_id = sanitize($_GET['node_id']);
+include("includes.php");
- // start output
- include("header.php");
+$node_id = sanitize($_GET['node_id']);
- // set language variables
- $smarty->assign($lang);
+include("header.php");
- // setup node
- // build query
- $query = "SELECT
- a.asset_id,
- n.node_id,
- n.node_ip,
- n.node_mac,
- n.node_dns1,
- n.node_dns2,
- n.node_info,
- s.subnet_id,
- n.zone_id
- FROM
- asset AS a,
- node AS n,
- subnet AS s
- WHERE
- a.asset_id=n.asset_id
- AND n.node_id=" . $node_id . "
- AND s.subnet_id=n.subnet_id";
-
- // run query
- $node = $db->db_select($query);
-
-// send to tpl
- $smarty->assign("node_id", $node[0]['node_id']);
- $smarty->assign("node_ip", $node[0]['node_ip']);
- $smarty->assign("node_mac", write_mac($node[0]['node_mac']));
- $smarty->assign("node_dns1", $node[0]['node_dns1']);
- $smarty->assign("node_dns2", $node[0]['node_dns2']);
- $smarty->assign("node_info", $node[0]['node_info']);
- $smarty->assign("asset_id", $node[0]['asset_id']);
- $smarty->assign("subnet_id", $node[0]['subnet_id']);
- $smarty->assign("zone_id", $node[0]['zone_id']);
+$query = "SELECT
+ a.asset_id,
+ n.node_id,
+ n.node_ip,
+ n.node_mac,
+ n.node_dns1,
+ n.node_dns2,
+ n.node_info,
+ s.subnet_id,
+ n.zone_id
+ FROM
+ asset AS a,
+ node AS n,
+ subnet AS s
+ WHERE
+ a.asset_id=n.asset_id
+ AND n.node_id=" . $node_id . "
+ AND s.subnet_id=n.subnet_id";
- // setup asset
- $smarty->assign("asset_options", $db->options_asset());
+$node = $db->db_select($query);
- // setup subnet
- $smarty->assign("subnet_options", $db->options_subnet());
+$smarty->assign("node_id", $node[0]['node_id']);
+$smarty->assign("node_ip", $node[0]['node_ip']);
+$smarty->assign("node_mac", write_mac($node[0]['node_mac']));
+$smarty->assign("node_dns1", $node[0]['node_dns1']);
+$smarty->assign("node_dns2", $node[0]['node_dns2']);
+$smarty->assign("node_info", $node[0]['node_info']);
+$smarty->assign("asset_id", $node[0]['asset_id']);
+$smarty->assign("subnet_id", $node[0]['subnet_id']);
+$smarty->assign("zone_id", $node[0]['zone_id']);
- // setup zone
- $smarty->assign("zone_options", $db->options_zone("(keine)"));
+$smarty->assign("asset_options", $db->options_asset());
+$smarty->assign("subnet_options", $db->options_subnet());
+$smarty->assign("zone_options", $db->options_zone("(keine)"));
- // end page
- // output
- $smarty->display("nodeedit.tpl");
+$smarty->display("nodeedit.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/nodeview.php b/nodeview.php
index 5ce37a6..6c82193 100644
--- a/nodeview.php
+++ b/nodeview.php
@@ -1,107 +1,85 @@
.
+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");
?>
diff --git a/options.php b/options.php
index 047e4f1..93af530 100644
--- a/options.php
+++ b/options.php
@@ -1,39 +1,16 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
- // start page
- // includes
- include("includes.php");
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start output
- include("header.php");
+include("includes.php");
+include("header.php");
- // set language variables
- $smarty->assign($lang);
+$smarty->display("options.tpl");
- // end page
- // output
- $smarty->display("options.tpl");
-
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/optionseditdisplay.php b/optionseditdisplay.php
index ad3e088..14235d9 100644
--- a/optionseditdisplay.php
+++ b/optionseditdisplay.php
@@ -1,123 +1,99 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
- // start output
- include("header.php");
+include("header.php");
- // set language variables
- $smarty->assign($lang);
- $smarty->assign("language", $language);
+$smarty->assign("language", $language);
+
- // setup options
- // set menu checkboxes
- // assets
- if($_SESSION['suser_menu_assets']=='on') {
- $user_menu_assets_checked = 'checked';
- } else {
- $user_menu_assets_checked = '';
- }
- // assetclasses
- if($_SESSION['suser_menu_assetclasses']=='on') {
- $user_menu_assetclasses_checked = 'checked';
- } else {
- $user_menu_assetclasses_checked = '';
- }
- // assetclassgroups
- if($_SESSION['suser_menu_assetclassgroups']=='on') {
- $user_menu_assetclassgroups_checked = 'checked';
- } else {
- $user_menu_assetclassgroups_checked = '';
- }
- // locations
- if($_SESSION['suser_menu_locations']=='on') {
- $user_menu_locations_checked = 'checked';
- } else {
- $user_menu_locations_checked = '';
- }
- // nodes
- if($_SESSION['suser_menu_nodes']=='on') {
- $user_menu_nodes_checked = 'checked';
- } else {
- $user_menu_nodes_checked = '';
- }
- // subnets
- if($_SESSION['suser_menu_subnets']=='on') {
- $user_menu_subnets_checked = 'checked';
- } else {
- $user_menu_subnets_checked = '';
- }
- // users
- if($_SESSION['suser_menu_users']=='on') {
- $user_menu_users_checked = 'checked';
- } else {
- $user_menu_users_checked = '';
- }
- // vlans
- if($_SESSION['suser_menu_vlans']=='on') {
- $user_menu_vlans_checked = 'checked';
- } else {
- $user_menu_vlans_checked = '';
- }
- // zones
- if($_SESSION['suser_menu_zones']=='on') {
- $user_menu_zones_checked = 'checked';
- } else {
- $user_menu_zones_checked = '';
- }
- // tooltips
- if($_SESSION['suser_tooltips']=='on') {
- $user_tooltips_checked = 'checked';
- } else {
- $user_tooltips_checked = '';
- }
-
- // send to tpl
- $smarty->assign("user_id", $_SESSION['suser_id']);
- $smarty->assign("user_imagesize", $_SESSION['suser_imagesize']);
- $smarty->assign("user_imagecount", $_SESSION['suser_imagecount']);
- $smarty->assign("user_mac", $_SESSION['suser_mac']);
- $smarty->assign("user_dateformat", $_SESSION['suser_dateformat']);
- $smarty->assign("user_dns1suffix", $_SESSION['suser_dns1suffix']);
- $smarty->assign("user_dns2suffix", $_SESSION['suser_dns2suffix']);
- $smarty->assign("user_language", $_SESSION['suser_language']);
- $smarty->assign("user_menu_assets_checked", $user_menu_assets_checked);
- $smarty->assign("user_menu_assetclasses_checked", $user_menu_assetclasses_checked);
- $smarty->assign("user_menu_assetclassgroups_checked", $user_menu_assetclassgroups_checked);
- $smarty->assign("user_menu_locations_checked", $user_menu_locations_checked);
- $smarty->assign("user_menu_nodes_checked", $user_menu_nodes_checked);
- $smarty->assign("user_menu_subnets_checked", $user_menu_subnets_checked);
- $smarty->assign("user_menu_users_checked", $user_menu_users_checked);
- $smarty->assign("user_menu_vlans_checked", $user_menu_vlans_checked);
- $smarty->assign("user_menu_zones_checked", $user_menu_zones_checked);
- $smarty->assign("user_tooltips_checked", $user_tooltips_checked);
+if($_SESSION['suser_menu_assets']=='on') {
+ $user_menu_assets_checked = 'checked';
+} else {
+ $user_menu_assets_checked = '';
+}
+// assetclasses
+if($_SESSION['suser_menu_assetclasses']=='on') {
+ $user_menu_assetclasses_checked = 'checked';
+} else {
+ $user_menu_assetclasses_checked = '';
+}
+// assetclassgroups
+if($_SESSION['suser_menu_assetclassgroups']=='on') {
+ $user_menu_assetclassgroups_checked = 'checked';
+} else {
+ $user_menu_assetclassgroups_checked = '';
+}
+// locations
+if($_SESSION['suser_menu_locations']=='on') {
+ $user_menu_locations_checked = 'checked';
+} else {
+ $user_menu_locations_checked = '';
+}
+// nodes
+if($_SESSION['suser_menu_nodes']=='on') {
+ $user_menu_nodes_checked = 'checked';
+} else {
+ $user_menu_nodes_checked = '';
+}
+// subnets
+if($_SESSION['suser_menu_subnets']=='on') {
+ $user_menu_subnets_checked = 'checked';
+} else {
+ $user_menu_subnets_checked = '';
+}
+// users
+if($_SESSION['suser_menu_users']=='on') {
+ $user_menu_users_checked = 'checked';
+} else {
+ $user_menu_users_checked = '';
+}
+// vlans
+if($_SESSION['suser_menu_vlans']=='on') {
+ $user_menu_vlans_checked = 'checked';
+} else {
+ $user_menu_vlans_checked = '';
+}
+// zones
+if($_SESSION['suser_menu_zones']=='on') {
+ $user_menu_zones_checked = 'checked';
+} else {
+ $user_menu_zones_checked = '';
+}
+// tooltips
+if($_SESSION['suser_tooltips']=='on') {
+ $user_tooltips_checked = 'checked';
+} else {
+ $user_tooltips_checked = '';
+}
+
+$smarty->assign("user_id", $_SESSION['suser_id']);
+$smarty->assign("user_imagesize", $_SESSION['suser_imagesize']);
+$smarty->assign("user_imagecount", $_SESSION['suser_imagecount']);
+$smarty->assign("user_mac", $_SESSION['suser_mac']);
+$smarty->assign("user_dateformat", $_SESSION['suser_dateformat']);
+$smarty->assign("user_dns1suffix", $_SESSION['suser_dns1suffix']);
+$smarty->assign("user_dns2suffix", $_SESSION['suser_dns2suffix']);
+$smarty->assign("user_language", $_SESSION['suser_language']);
+$smarty->assign("user_menu_assets_checked", $user_menu_assets_checked);
+$smarty->assign("user_menu_assetclasses_checked", $user_menu_assetclasses_checked);
+$smarty->assign("user_menu_assetclassgroups_checked", $user_menu_assetclassgroups_checked);
+$smarty->assign("user_menu_locations_checked", $user_menu_locations_checked);
+$smarty->assign("user_menu_nodes_checked", $user_menu_nodes_checked);
+$smarty->assign("user_menu_subnets_checked", $user_menu_subnets_checked);
+$smarty->assign("user_menu_users_checked", $user_menu_users_checked);
+$smarty->assign("user_menu_vlans_checked", $user_menu_vlans_checked);
+$smarty->assign("user_menu_zones_checked", $user_menu_zones_checked);
+$smarty->assign("user_tooltips_checked", $user_tooltips_checked);
- // end page
- // output
- $smarty->display("optionseditdisplay.tpl");
+$smarty->display("optionseditdisplay.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/optionseditpassword.php b/optionseditpassword.php
index cfdfccc..a949347 100644
--- a/optionseditpassword.php
+++ b/optionseditpassword.php
@@ -1,39 +1,16 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
-
- // start output
- include("header.php");
+include("includes.php");
+include("header.php");
- // set language variables
- $smarty->assign($lang);
-
- // end page
- // output
- $smarty->display("optionseditpassword.tpl");
+$smarty->display("optionseditpassword.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/search.php b/search.php
index c7097a1..d51c130 100644
--- a/search.php
+++ b/search.php
@@ -1,178 +1,145 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // get string that was searched for ($search is already set in header.php)
- if (empty($search)) {
- // parse nosearch box
- $smarty->assign("nosearch", TRUE);
- } else {
- // hide nosearch box
- $smarty->assign("nosearch", FALSE);
- $smarty->assign("search", $search);
-
- // set needle
- $needle = '%' . $search . '%';
-
- // set counter
- $resultcounter = 0;
-
- // setup asset
- // build query
- $query = "SELECT
- asset.asset_id AS id,
- asset.asset_name AS name,
- asset.asset_info AS description
- FROM
- asset
- WHERE
- asset.asset_name LIKE '" . $needle . "'
- OR asset.asset_hostname LIKE '" . $needle . "'
- OR asset.asset_info LIKE '" . $needle . "'
- ORDER BY
- asset.asset_name";
-
- // run query
- $assets = $db->db_select($query);
- $resultcounter += count($assets);
- $smarty->assign("assets", $assets);
-
- // setup location
- // build query
- $query = "SELECT
- location.location_id AS id,
- location.location_name AS name
- FROM
- location
- WHERE
- location.location_name LIKE '" . $needle . "'
- OR location.location_info LIKE '" . $needle . "'
- ORDER BY
- location.location_name";
-
- // run query
- $locations = $db->db_select($query);
- $resultcounter += count($locations);
- $smarty->assign("locations", $locations);
-
- // setup node
- // build query
- $query = "SELECT
- node.node_id AS id,
- node.node_ip AS ip
- FROM
- node
- WHERE
- node.node_ip LIKE '" . $needle . "'
- OR node.node_mac LIKE '" . $needle . "'
- OR node.node_dns1 LIKE '" . $needle . "'
- OR node.node_dns2 LIKE '" . $needle . "'
- OR node.node_info LIKE '" . $needle . "'
- ORDER BY
- node.node_ip";
-
- // run query
- $nodes = $db->db_select($query);
- $resultcounter += count($nodes);
- $smarty->assign("nodes", $nodes);
-
- // setup subnet
- // build query
- $query = "SELECT
- subnet.subnet_id AS id,
- subnet.subnet_address AS address
- FROM
- subnet
- WHERE
- subnet.subnet_address LIKE '" . $needle . "'
- OR subnet.subnet_info LIKE '" . $needle . "'
- ORDER BY
- subnet.subnet_address";
-
- // run query
- $subnets = $db->db_select($query);
- $resultcounter += count($subnets);
- $smarty->assign("subnets", $subnets);
-
- // setup vlan
- // build query
- $query = "SELECT
- vlan.vlan_id AS id,
- vlan.vlan_name AS name
- FROM
- vlan
- WHERE
- vlan.vlan_name LIKE '" . $needle . "'
- OR vlan.vlan_info LIKE '" . $needle . "'
- ORDER BY
- vlan.vlan_name";
-
- // run query
- $vlans = $db->db_select($query);
- $resultcounter += count($vlans);
- $smarty->assign("vlans", $vlans);
-
- // setup zone
- // build query
- $query = "SELECT
- zone_id AS id,
- zone_origin AS origin
- FROM
- zone
- WHERE
- zone_origin LIKE '" . $needle . "'
- OR zone_soa LIKE '" . $needle . "'
- OR zone_hostmaster LIKE '" . $needle . "'
- OR zone_ns1 LIKE '" . $needle . "'
- OR zone_ns2 LIKE '" . $needle . "'
- OR zone_ns3 LIKE '" . $needle . "'
- OR zone_mx1 LIKE '" . $needle . "'
- OR zone_mx2 LIKE '" . $needle . "'
- OR zone_info LIKE '" . $needle . "'
- ORDER BY
- zone_origin";
-
- // run query
- $zones = $db->db_select($query);
- $resultcounter += count($zones);
- $smarty->assign("zones", $zones);
-
- // grand totals
- $smarty->assign("resultcounter", $resultcounter);
- }
-
- // end page
- // output
- $smarty->display("search.tpl");
-
- // end output
- include("footer.php");
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+include("header.php");
+
+
+// get string that was searched for ($search is already set in header.php)
+if (empty($search)) {
+ // parse nosearch box
+ $smarty->assign("nosearch", TRUE);
+} else {
+ // hide nosearch box
+ $smarty->assign("nosearch", FALSE);
+ $smarty->assign("search", $search);
+
+ // set needle
+ $needle = '%' . $search . '%';
+
+ // set counter
+ $resultcounter = 0;
+
+ // asset
+ $query = "SELECT
+ asset_id AS id,
+ asset_name AS name,
+ asset_info AS description
+ FROM
+ asset
+ WHERE
+ asset_name LIKE '" . $needle . "'
+ OR asset_hostname LIKE '" . $needle . "'
+ OR asset_info LIKE '" . $needle . "'
+ ORDER BY
+ asset_name";
+
+ $assets = $db->db_select($query);
+ $resultcounter += count($assets);
+ $smarty->assign("assets", $assets);
+
+ // location
+ $query = "SELECT
+ location_id AS id,
+ location_name AS name
+ FROM
+ location
+ WHERE
+ location_name LIKE '" . $needle . "'
+ OR location_info LIKE '" . $needle . "'
+ ORDER BY
+ location_name";
+
+ $locations = $db->db_select($query);
+ $resultcounter += count($locations);
+ $smarty->assign("locations", $locations);
+
+ // node
+ $query = "SELECT
+ node_id AS id,
+ node_ip AS ip
+ FROM
+ node
+ WHERE
+ node_ip LIKE '" . $needle . "'
+ OR node_mac LIKE '" . $needle . "'
+ OR node_dns1 LIKE '" . $needle . "'
+ OR node_dns2 LIKE '" . $needle . "'
+ OR node_info LIKE '" . $needle . "'
+ ORDER BY
+ node_ip";
+
+ $nodes = $db->db_select($query);
+ $resultcounter += count($nodes);
+ $smarty->assign("nodes", $nodes);
+
+ // subnet
+ $query = "SELECT
+ subnet_id AS id,
+ subnet_address AS address
+ FROM
+ subnet
+ WHERE
+ subnet_address LIKE '" . $needle . "'
+ OR subnet_info LIKE '" . $needle . "'
+ ORDER BY
+ subnet_address";
+
+ // run query
+ $subnets = $db->db_select($query);
+ $resultcounter += count($subnets);
+ $smarty->assign("subnets", $subnets);
+
+ // vlan
+ $query = "SELECT
+ vlan_id AS id,
+ vlan_name AS name
+ FROM
+ vlan
+ WHERE
+ vlan_name LIKE '" . $needle . "'
+ OR vlan_info LIKE '" . $needle . "'
+ ORDER BY
+ vlan_name";
+
+ $vlans = $db->db_select($query);
+ $resultcounter += count($vlans);
+ $smarty->assign("vlans", $vlans);
+
+ // setup zone
+ $query = "SELECT
+ zone_id AS id,
+ zone_origin AS origin
+ FROM
+ zone
+ WHERE
+ zone_origin LIKE '" . $needle . "'
+ OR zone_soa LIKE '" . $needle . "'
+ OR zone_hostmaster LIKE '" . $needle . "'
+ OR zone_ns1 LIKE '" . $needle . "'
+ OR zone_ns2 LIKE '" . $needle . "'
+ OR zone_ns3 LIKE '" . $needle . "'
+ OR zone_mx1 LIKE '" . $needle . "'
+ OR zone_mx2 LIKE '" . $needle . "'
+ OR zone_info LIKE '" . $needle . "'
+ ORDER BY
+ zone_origin";
+
+ $zones = $db->db_select($query);
+ $resultcounter += count($zones);
+ $smarty->assign("zones", $zones);
+
+ // grand totals
+ $smarty->assign("resultcounter", $resultcounter);
+}
+
+$smarty->display("search.tpl");
+
+include("footer.php");
?>
diff --git a/submit.php b/submit.php
index 4dfdf93..e944ba6 100644
--- a/submit.php
+++ b/submit.php
@@ -1,1303 +1,1084 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // includes
- include("includes.php");
-
- // check for submit
- if ($_SERVER['REQUEST_METHOD']=="POST") {
- // what to do?
- if (isset($_POST['redirect'])) {
- switch ($_POST['redirect']) {
- case ("assigniptonode") :
- // get variables
- $node_ip = sanitize($_POST['node_ip']);
- $subnet_id = sanitize($_POST['subnet_id']);
-
- switch ($_POST['action']) {
- case ("assignnodetoasset") :
- // redirect
- header_location("assignnodetoasset.php?subnet_id=" . $subnet_id . "&node_ip=" . $node_ip);
- break;
- case ("nodeadd") :
- // redirect
- header_location("nodeadd.php?subnet_id=" . $subnet_id . "&node_ip=" . $node_ip);
- break;
- }
- break;
- case ("locationsubnet") :
- // get variables
- $location_id = sanitize($_POST['location_id']);
-
- switch ($_POST['action']) {
- case ("locationsubnetadd") :
- // redirect
- header_location("locationsubnetadd.php?location_id=" . $location_id);
- break;
- case ("locationsubnetdel") :
- // redirect
- header_location("locationsubnetdel.php?location_id=" . $location_id);
- break;
- }
- break;
- case ("nat") :
- // get variables
- $node_id = sanitize($_POST['node_id']);
-
- switch ($_POST['action']) {
- case ("natadd") :
- // redirect
- header_location("natadd.php?node_id=" . $node_id);
- break;
- case ("natdel") :
- // redirect
- header_location("natdel.php?node_id=" . $node_id);
- break;
- }
- break;
- case ("subnetlocation") :
- // get variables
- $subnet_id = sanitize($_POST['subnet_id']);
-
- switch ($_POST['action']) {
- case ("subnetlocationadd") :
- // redirect
- header_location("subnetlocationadd.php?subnet_id=" . $subnet_id);
- break;
- case ("subnetlocationdel") :
- // redirect
- header_location("subnetlocationdel.php?subnet_id=" . $subnet_id);
- break;
- }
- break;
- case ("subnetvlan") :
- // get variables
- $subnet_id = sanitize($_POST['subnet_id']);
-
- switch ($_POST['action']) {
- case ("subnetvlanadd") :
- // redirect
- header_location("subnetvlanadd.php?subnet_id=" . $subnet_id);
- break;
- case ("subnetvlandel") :
- // redirect
- header_location("subnetvlandel.php?subnet_id=" . $subnet_id);
- break;
- }
- break;
- case ("vlansubnet") :
- // get variables
- $vlan_id = sanitize($_POST['vlan_id']);
-
- switch ($_POST['action']) {
- case ("vlansubnetadd") :
- // redirect
- header_location("vlansubnetadd.php?vlan_id=" . $vlan_id);
- break;
- case ("vlansubnetdel") :
- // redirect
- header_location("vlansubnetdel.php?vlan_id=" . $vlan_id);
- break;
- }
- break;
- }
- }
-
- if (isset($_POST['add'])) {
- switch ($_POST['add']) {
- case ("asset") :
- // get variables
- $asset_name = sanitize($_POST['asset_name']);
- $asset_hostname = sanitize($_POST['asset_hostname']);
- $assetclass_id = sanitize($_POST['assetclass_id']);
- $asset_info = sanitize($_POST['asset_info']);
-
- // build query
- $query = "INSERT
- INTO
- asset(
- asset_name,
- asset_hostname,
- assetclass_id,
- asset_info
- )
- VALUE
- (
- '$asset_name',
- '$asset_hostname',
- '$assetclass_id',
- '$asset_info'
- )";
-
- // run query
- $asset_id = $db->db_insert($query);
-
- // redirect
- header_location("assetview.php?asset_id=" . $asset_id);
- break;
- case ("assetclass") :
- // get variables
- $assetclass_name = sanitize($_POST['assetclass_name']);
- $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']);
-
- // build query
- $query = "INSERT
- INTO
- assetclass(
- assetclass_name,
- assetclassgroup_id
- )
- VALUE
- (
- '$assetclass_name',
- '$assetclassgroup_id'
- )";
-
- // run query
- $assetclass_id = $db->db_insert($query);
-
- // redirect
- header_location("assetclassview.php?assetclass_id=" . $assetclass_id);
- break;
- case ("assetclassgroup") :
- // get variables
- $assetclassgroup_name = sanitize($_POST['assetclassgroup_name']);
- $assetclassgroup_color = preg_replace("|[^a-zA-Z0-9]|", "", strtoupper(sanitize($_POST['assetclassgroup_color'])));
-
- // build query
- $query = "INSERT
- INTO
- assetclassgroup(
- assetclassgroup_name,
- assetclassgroup_color
- )
- VALUE
- (
- '$assetclassgroup_name',
- '$assetclassgroup_color'
- )";
-
- // run query
- $assetclassgroup_id = $db->db_insert($query);
-
- // redirect
- header_location("assetclassgroupview.php?assetclassgroup_id=" . $assetclassgroup_id);
- break;
- case ("assignnodetoasset") :
- // get variables
- $node_ip = sanitize($_POST['node_ip']);
- $subnet_id = sanitize($_POST['subnet_id']);
- $asset_id = sanitize($_POST['asset_id']);
- $node_mac = strip_mac(sanitize($_POST['node_mac']));
- if ((!empty($_POST['node_dns1']) && isset($_POST['node_dns1suffix'])) ? $node_dns1 = sanitize($_POST['node_dns1']) . $config_dns1suffix : $node_dns1 = sanitize($_POST['node_dns1']));
- if ((!empty($_POST['node_dns2']) && isset($_POST['node_dns2suffix'])) ? $node_dns2 = sanitize($_POST['node_dns2']) . $config_dns2suffix : $node_dns2 = sanitize($_POST['node_dns2']));
- $node_info = $_POST['node_info'];
-
- // build query
- $query = "INSERT
- INTO
- node(
- node_ip,
- node_mac,
- node_dns1,
- node_dns2,
- subnet_id,
- asset_id,
- node_info
- )
- VALUE
- (
- '$node_ip',
- '$node_mac',
- '$node_dns1',
- '$node_dns2',
- '$subnet_id',
- '$asset_id',
- '$node_info'
- )";
-
- // run query
- $node_id = $db->db_insert($query);
-
- // redirect
- header_location("nodeview.php?node_id=" . $node_id);
- break;
- case ("assignlocationtosubnet") :
- // get variables
- $location_id = sanitize($_POST['location_id']);
- $subnet_id = sanitize($_POST['subnet_id']);
-
- // build query
- $query = "INSERT
- INTO
- subnetlocation(
- location_id,
- subnet_id
- )
- VALUE
- (
- '$location_id',
- '$subnet_id'
- )";
-
- // run query
- $db->db_insert($query);
-
- // redirect
- header_location("Location: location.php");
- break;
- case ("assignsubnettovlan") :
- // get variables
- $subnet_id = sanitize($_POST['subnet_id']);
- $vlan_id = sanitize($_POST['vlan_id']);
-
- // build query
- $query = "UPDATE
- subnet
- SET
- vlan_id='$vlan_id'
- WHERE
- subnet_id='$subnet_id'";
-
- // run query
- $db->db_update($query);
-
- // redirect
- header_location("subnetview.php?subnet_id=" . $subnet_id);
- break;
- case ("location") :
- // get variables
- $location_name = sanitize($_POST['location_name']);
- $location_parent = sanitize($_POST['location_parent']);
- $location_info = sanitize($_POST['location_info']);
-
- // build query
- $query = "INSERT
- INTO
- location(
- location_name,
- location_parent,
- location_info
- )
- VALUE
- (
- '$location_name',
- '$location_parent',
- '$location_info'
- )";
-
- // run query
- $location_id = $db->db_insert($query);
-
- // redirect
- header_location("locationview.php?location_id=" . $location_id);
- break;
- case ("locationsubnet") :
- // get variables
- $location_id = sanitize($_POST['location_id']);
- $subnet_id = sanitize($_POST['subnet_id']);
-
- // build query
- $query = "INSERT
- INTO
- subnetlocation(
- location_id,
- subnet_id
- )
- VALUE
- (
- '$location_id',
- '$subnet_id'
- )";
-
- // run query
- $newid = $db->db_insert($query);
-
- // redirect
- header_location("locationview.php?location_id=" . $location_id);
- break;
- case ("nat") :
- // get variables
- $node_id_ext = sanitize($_POST['node_id_ext']);
- $node_id_int = sanitize($_POST['node_id_int']);
- $nat_type = sanitize($_POST['nat_type']);
-
- // build query
- $query = "INSERT
- INTO
- nat(
- nat_ext,
- nat_int,
- nat_type
- )
- VALUE
- (
- '$node_id_ext',
- '$node_id_int',
- '$nat_type'
- )";
-
- // run query
- $db->db_insert($query);
-
- // redirect
- header_location("nodeview.php?node_id=" . $node_id_ext);
- break;
- case ("node") :
- // get variables
- $asset_name = sanitize($_POST['asset_name']);
- $asset_hostname = sanitize($_POST['asset_hostname']);
- $assetclass_id = sanitize($_POST['assetclass_id']);
- $ip = sanitize($_POST['node_ip']);
- $mac = strip_mac(sanitize($_POST['node_mac']));
- if ((!empty($_POST['node_dns1']) && isset($_POST['dns1suffix'])) ? $dns1 = sanitize($_POST['node_dns1']) . $config_dns1suffix : $dns1 = sanitize($_POST['node_dns1']));
- if ((!empty($_POST['node_dns2']) && isset($_POST['dns2suffix'])) ? $dns2 = sanitize($_POST['node_dns2']) . $config_dns2suffix : $dns2 = sanitize($_POST['node_dns2']));
- $node_info = sanitize($_POST['node_info']);
- $subnet_id = $_POST['subnet_id'];
-
- // build query
- $query = "INSERT
- INTO
- asset(
- asset_name,
- asset_hostname,
- assetclass_id
- )
- VALUE
- (
- '$asset_name',
- '$asset_hostname',
- '$assetclass_id'
- )";
-
- // run query
- $asset_id = $db->db_insert($query);
-
- // build query
- $query = "INSERT
- INTO
- node(
- node_ip,
- node_mac,
- node_dns1,
- node_dns2,
- node_info,
- subnet_id,
- asset_id
- )
- VALUE
- (
- '$ip',
- '$mac',
- '$dns1',
- '$dns2',
- '$node_info',
- '$subnet_id',
- '$asset_id'
- )";
-
- // run query
- $node_id = $db->db_insert($query);
-
- // redirect
- header_location("nodeview.php?node_id=" . $node_id);
- break;
- case ("subnet") :
- // get variables
- $subnet_address= sanitize($_POST['subnet_address']);
- $subnet_mask = sanitize($_POST['subnet_mask']);
- $subnet_info = sanitize($_POST['subnet_info']);
-
- // build query
- $query = "INSERT
- INTO
- subnet(
- subnet_address,
- subnet_mask,
- subnet_info
- )
- VALUE
- (
- '$subnet_address',
- '$subnet_mask',
- '$subnet_info'
- )";
-
- // run query
- $subnet_id = $db->db_insert($query);
-
- // redirect
- header_location("subnetview.php?subnet_id=" . $subnet_id);
- break;
- case ("subnetlocation") :
- // get variables
- $location_id = sanitize($_POST['location_id']);
- $subnet_id = sanitize($_POST['subnet_id']);
-
- // build query
- $query = "INSERT
- INTO
- subnetlocation(
- location_id,
- subnet_id
- )
- VALUE
- (
- '$location_id',
- '$subnet_id'
- )";
-
- // run query
- $db->db_insert($query);
-
- // redirect
- header_location("subnetview.php?subnet_id=" . $subnet_id);
- break;
- case ("subnetvlan") :
- // get variables
- $subnet_id = sanitize($_POST['subnet_id']);
- $vlan_id = sanitize($_POST['vlan_id']);
-
- // build query
- $query = "INSERT
- INTO
- subnetvlan(
- subnet_id,
- vlan_id
- )
- VALUE
- (
- '$subnet_id',
- '$vlan_id'
- )";
-
- // run query
- $db->db_insert($query);
-
- // redirect
- header_location("subnetview.php?subnet_id=" . $subnet_id);
- break;
- case ("user") :
- // get variables
- $user_name = strtolower(sanitize($_POST['user_name']));
- $user_displayname = sanitize($_POST['user_displayname']);
- $user_password = md5(sanitize($_POST['user_password']));
-
- // build query
- $query = "SELECT
- user_name
- FROM
- user
- WHERE
- user_name='$user_name'";
-
- // run query
- $users = $db->db_select($query);
-
- // count results
- $user_counter = count($users);
-
- // user exists?
- if ($user_counter==0) {
- // build query
- $query = "INSERT
- INTO
- user(
- user_name,
- user_displayname,
- user_pass
- )
- VALUE
- (
- '$user_name',
- '$user_displayname',
- '$user_password'
- )";
-
- // run query
- $user_id = $db->db_insert($query);
-
- // redirect
- header_location("userview.php?user_id=" . $user_id);
- }
-
- // display error
- $comments = "usernameinuse";
- break;
- case ("vlan") :
- // get variables
- $vlan_name = sanitize($_POST['vlan_name']);
- $vlan_number = sanitize($_POST['vlan_number']);
- $vlan_info = sanitize($_POST['vlan_info']);
-
- // build query
- $query = "INSERT
- INTO
- vlan(
- vlan_name,
- vlan_number,
- vlan_info
- )
- VALUE
- (
- '$vlan_name',
- '$vlan_number',
- '$vlan_info'
- )";
-
- // run query
- $vlan_id = $db->db_insert($query);
-
- // redirect
- header_location("vlanview.php?vlan_id=" . $vlan_id);
- break;
- case ("vlansubnet") :
- // get variables
- $subnet_id = sanitize($_POST['subnet_id']);
- $vlan_id = sanitize($_POST['vlan_id']);
-
- // build query
- $query = "INSERT
- INTO
- subnetvlan(
- subnet_id,
- vlan_id
- )
- VALUE
- (
- '$subnet_id',
- '$vlan_id'
- )";
-
- // run query
- $db->db_insert($query);
-
- // redirect
- header_location("vlanview.php?vlan_id=" . $vlan_id);
- break;
- case ("zone") :
- // get variables
- $zone_origin = sanitize($_POST['zone_origin']);
- $zone_ttl_default = sanitize($_POST['zone_ttl_default']);
- $zone_soa = sanitize($_POST['zone_soa']);
- $zone_hostmaster = sanitize($_POST['zone_hostmaster']);
- $zone_refresh = sanitize($_POST['zone_refresh']);
- $zone_retry = sanitize($_POST['zone_retry']);
- $zone_expire = sanitize($_POST['zone_expire']);
- $zone_ttl = sanitize($_POST['zone_ttl']);
- $zone_serial = sanitize($_POST['zone_serial']);
- $zone_ns1 = sanitize($_POST['zone_ns1']);
- $zone_ns2 = sanitize($_POST['zone_ns2']);
- $zone_ns3 = sanitize($_POST['zone_ns3']);
- $zone_mx1 = sanitize($_POST['zone_mx1']);
- $zone_mx2 = sanitize($_POST['zone_mx2']);
- $zone_info = sanitize($_POST['zone_info']);
-
- // build query
- $query = "INSERT
- INTO
- zone(
- zone_origin,
- zone_ttl_default,
- zone_soa,
- zone_hostmaster,
- zone_refresh,
- zone_retry,
- zone_expire,
- zone_ttl,
- zone_serial,
- zone_ns1,
- zone_ns2,
- zone_ns3,
- zone_mx1,
- zone_mx2,
- zone_info
- )
- VALUE
- (
- '$zone_origin',
- '$zone_ttl_default',
- '$zone_soa',
- '$zone_hostmaster',
- '$zone_refresh',
- '$zone_retry',
- '$zone_expire',
- '$zone_ttl',
- '$zone_serial',
- '$zone_ns1',
- '$zone_ns2',
- '$zone_ns3',
- '$zone_mx1',
- '$zone_mx2',
- '$zone_info'
- )";
-
- // run query
- $zoneid = $db->db_insert($query);
-
- // redirect
- header_location("zoneview.php?zone_id=" . $zoneid);
- break;
- }
- }
-
- if (isset($_POST['del'])) {
- switch ($_POST['del']) {
- case ("asset") :
- // get variables
- $asset_id = sanitize($_POST['asset_id']);
-
- // delete asset
- // build query
- $query = "DELETE
- FROM
- asset
- WHERE
- asset_id=" . $asset_id;
-
- // run query
- $db->db_delete($query);
-
- // delete nodes
- $query = "DELETE
- FROM
- node
- WHERE
- asset_id=" . $asset_id;
-
- // run query
- $db->db_delete($query);
-
- // redirect
- header_location("asset.php");
- break;
- case ("assetclass") :
- // get variables
- $assetclass_id = sanitize($_POST['assetclass_id']);
-
- // build query
- $query = "DELETE
- FROM
- assetclass
- WHERE
- assetclass_id=" . $assetclass_id;
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
- // run query
- $db->db_delete($query);
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // redirect
- header_location("assetclass.php");
- break;
- case ("assetclassgroup") :
- // get variables
- $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']);
-
- // build query
- $query = "DELETE
- FROM
- assetclassgroup
- WHERE
- assetclassgroup_id=" . $assetclassgroup_id;
-
- // run query
- $db->db_delete($query);
-
- // redirect
- header_location("assetclassgroup.php");
- break;
- case ("location") :
- // get variables
- $location_id = sanitize($_POST['location_id']);
-
- // build query
- $query = "DELETE
- FROM
- location
- WHERE
- location_id=" . $location_id;
-
- // run query
- $db->db_delete($query);
+include("includes.php");
- // redirect
- header_location("location.php");
- break;
- case ("locationsubnet") :
- // get variables
- $location_id = sanitize($_POST['location_id']);
- $subnet_id = sanitize($_POST['subnet_id']);
-
- // build query
- $query = "DELETE
- FROM
- subnetlocation
- WHERE
- location_id=" . $location_id . "
- AND subnet_id=" . $subnet_id;
+if ($_SERVER['REQUEST_METHOD'] != "POST") {
+ header_location("comments.php?comments=" . $comments);
+ exit;
+}
- // run query
- $db->db_delete($query);
+if (isset($_POST['redirect'])) {
+ switch ($_POST['redirect']) {
+ case ("assigniptonode") :
+ $node_ip = sanitize($_POST['node_ip']);
+ $subnet_id = sanitize($_POST['subnet_id']);
- // redirect
- header_location("locationview.php?location_id=" . $location_id);
+ switch ($_POST['action']) {
+ case ("assignnodetoasset") :
+ header_location("assignnodetoasset.php?subnet_id=" . $subnet_id . "&node_ip=" . $node_ip);
break;
- case ("nat") :
- // get variables
- $node_id_ext = sanitize($_POST['node_id_ext']);
- $node_id_int = sanitize($_POST['node_id_int']);
-
- // build query
- $query = "DELETE
- FROM
- nat
- WHERE
- nat_ext=" . $node_id_ext . "
- AND nat_int=" . $node_id_int;
-
- // run query
- $db->db_delete($query);
-
- // redirect
- header_location("nodeview.php?node_id=" . $node_id_ext);
+ case ("nodeadd") :
+ header_location("nodeadd.php?subnet_id=" . $subnet_id . "&node_ip=" . $node_ip);
break;
- case ("node") :
- // get variables
- $node_id = sanitize($_POST['node_id']);
- $asset_id = sanitize($_POST['asset_id']);
-
- // build query
- $query = "DELETE
- FROM
- node
- WHERE
- node_id=" . $node_id;
-
- // run query
- $db->db_delete($query);
+ }
+ break;
+ case ("locationsubnet") :
+ $location_id = sanitize($_POST['location_id']);
- // redirect
- header_location("assetview.php?asset_id=" . $asset_id);
+ switch ($_POST['action']) {
+ case ("locationsubnetadd") :
+ header_location("locationsubnetadd.php?location_id=" . $location_id);
break;
- case ("subnet") :
- // get variables
- $subnet_id = sanitize($_POST['subnet_id']);
-
- // delete subnet
- // build query
- $query = "DELETE
- FROM
- subnet
- WHERE
- subnet_id=" . $subnet_id;
-
- // run query
- $db->db_delete($query);
-
- // delete nodes
- // build query
- $query = "DELETE
- FROM
- node
- WHERE
- subnet_id=" . $subnet_id;
-
- // run query
- $db->db_delete($query);
-
- // redirect
- header_location("subnet.php");
+ case ("locationsubnetdel") :
+ header_location("locationsubnetdel.php?location_id=" . $location_id);
break;
- case ("subnetlocation") :
- // get variables
- $location_id = sanitize($_POST['location_id']);
- $subnet_id = sanitize($_POST['subnet_id']);
-
- // build query
- $query = "DELETE
- FROM
- subnetlocation
- WHERE
- location_id=" . $location_id . "
- AND subnet_id=" . $subnet_id;
-
- // run query
- $db->db_delete($query);
+ }
+ break;
+ case ("nat") :
+ $node_id = sanitize($_POST['node_id']);
- // redirect
- header_location("subnetview.php?subnet_id=" . $subnet_id);
+ switch ($_POST['action']) {
+ case ("natadd") :
+ header_location("natadd.php?node_id=" . $node_id);
break;
- case ("subnetvlan") :
- // get variables
- $subnet_id = sanitize($_POST['subnet_id']);
- $vlan_id = sanitize($_POST['vlan_id']);
-
- // build query
- $query = "DELETE
- FROM
- subnetvlan
- WHERE
- subnet_id=" . $subnet_id . "
- AND vlan_id=" . $vlan_id;
-
- // run query
- $db->db_delete($query);
-
- // redirect
- header_location("subnetview.php?subnet_id=" . $subnet_id);
+ case ("natdel") :
+ header_location("natdel.php?node_id=" . $node_id);
break;
- case ("user") :
- // get variables
- $user_id = sanitize($_POST['user_id']);
-
- // build query
- $query = "DELETE
- FROM
- user
- WHERE
- user_id=" . $user_id;
-
- // run query
- $db->db_delete($query);
+ }
+ break;
+ case ("subnetlocation") :
+ $subnet_id = sanitize($_POST['subnet_id']);
- // redirect
- header_location("user.php");
+ switch ($_POST['action']) {
+ case ("subnetlocationadd") :
+ header_location("subnetlocationadd.php?subnet_id=" . $subnet_id);
break;
- case ("vlan") :
- // get variables
- $vlan_id = sanitize($_POST['vlan_id']);
-
- // build query
- $query = "DELETE
- FROM
- vlan
- WHERE
- vlan_id=" . $vlan_id;
-
- // run query
- $db->db_delete($query);
-
- // redirect
- header_location("vlan.php");
+ case ("subnetlocationdel") :
+ header_location("subnetlocationdel.php?subnet_id=" . $subnet_id);
break;
- case ("vlansubnet") :
- // get variables
- $subnet_id = sanitize($_POST['subnet_id']);
- $vlan_id = sanitize($_POST['vlan_id']);
-
- // build query
- $query = "DELETE
- FROM
- subnetvlan
- WHERE
- subnet_id=" . $subnet_id . "
- AND vlan_id=" . $vlan_id;
-
- // run query
- $db->db_delete($query);
+ }
+ break;
+ case ("subnetvlan") :
+ $subnet_id = sanitize($_POST['subnet_id']);
- // redirect
- header_location("vlanview.php?vlan_id=" . $vlan_id);
+ switch ($_POST['action']) {
+ case ("subnetvlanadd") :
+ header_location("subnetvlanadd.php?subnet_id=" . $subnet_id);
break;
- case ("zone") :
- // get variables
- $zone_id = sanitize($_POST['zone_id']);
-
- // build query
- $query = "DELETE
- FROM
- zone
- WHERE
- zone_id=" . $zone_id;
-
- // run query
- $db->db_delete($query);
-
- // redirect
- header_location("zone.php");
+ case ("subnetvlandel") :
+ header_location("subnetvlandel.php?subnet_id=" . $subnet_id);
break;
}
- }
-
- if (isset($_POST['edit'])) {
- switch ($_POST['edit']) {
- case ("asset") :
- // get variables
- $asset_id = sanitize($_POST['asset_id']);
- $asset_name = sanitize($_POST['asset_name']);
- $asset_info = sanitize($_POST['asset_info']);
- $asset_hostname = sanitize($_POST['asset_hostname']);
- $assetclass_id = sanitize($_POST['assetclass_id']);
-
- // build query
- $query = "UPDATE
- asset
- SET
- asset_name='$asset_name',
- asset_info='$asset_info',
- asset_hostname='$asset_hostname',
- assetclass_id='$assetclass_id'
- WHERE
- asset_id=" . $asset_id;
-
- // run query
- $db->db_update($query);
-
- // redirect
- header_location("assetview.php?asset_id=" . $asset_id);
- case ("assetclass") :
- // get variables
- $assetclass_id = sanitize($_POST['assetclass_id']);
- $assetclass_name = sanitize($_POST['assetclass_name']);
- $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']);
+ break;
+ case ("vlansubnet") :
+ $vlan_id = sanitize($_POST['vlan_id']);
- // build query
- $query = "UPDATE
- assetclass
- SET
- assetclass_name='$assetclass_name',
- assetclassgroup_id='$assetclassgroup_id'
- WHERE
- assetclass_id=" . $assetclass_id;
-
- // run query
- $db->db_update($query);
-
- // redirect
- header_location("assetclassview.php?assetclass_id=" . $assetclass_id);
+ switch ($_POST['action']) {
+ case ("vlansubnetadd") :
+ header_location("vlansubnetadd.php?vlan_id=" . $vlan_id);
break;
- case ("assetclassgroup") :
- // get variables
- $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']);
- $assetclassgroup_name = sanitize($_POST['assetclassgroup_name']);
- $assetclassgroup_color = preg_replace("|[^a-zA-Z0-9]|", "", strtoupper(sanitize($_POST['assetclassgroup_color'])));
-
- // update db
- $query = "UPDATE
- assetclassgroup
- SET
- assetclassgroup_name='$assetclassgroup_name',
- assetclassgroup_color='$assetclassgroup_color'
- WHERE
- assetclassgroup_id=" . $assetclassgroup_id;
-
- // run query
- $db->db_update($query);
-
- // redirect
- header_location("assetclassgroupview.php?assetclassgroup_id=" . $assetclassgroup_id);
+ case ("vlansubnetdel") :
+ header_location("vlansubnetdel.php?vlan_id=" . $vlan_id);
break;
- case ("location") :
- // get variables
- $location_id = sanitize($_POST['location_id']);
- $location_name = sanitize($_POST['location_name']);
- $location_info = sanitize($_POST['location_info']);
- $parentlocation_id = sanitize($_POST['parentlocation_id']);
-
- // update db
- $query = "UPDATE
- location
- SET
- location_name='$location_name',
- location_parent='$parentlocation_id',
- location_info='$location_info'
- WHERE
- location_id=" . $location_id;
-
- // run query
- $db->db_update($query);
-
- // redirect
- header_location("locationview.php?location_id=" . $location_id);
- break;
- case ("node") :
- // get variables
- $node_id = sanitize($_POST['node_id']);
- $asset_id = sanitize($_POST['asset_id']);
- $node_ip = sanitize($_POST['node_ip']);
- $subnet_id = sanitize($_POST['subnet_id']);
- $node_mac = strip_mac(sanitize($_POST['node_mac']));
- $node_dns1 = sanitize($_POST['node_dns1']);
- $node_dns2 = sanitize($_POST['node_dns2']);
- $node_info = sanitize($_POST['node_info']);
- $zone_id = sanitize($_POST['zone_id']);
-
- // update db
- $query = "UPDATE
- node
- SET
- asset_id='$asset_id',
- node_ip='$node_ip',
- subnet_id='$subnet_id',
- node_mac='$node_mac',
- node_dns1='$node_dns1',
- node_dns2='$node_dns2',
- node_info='$node_info',
- zone_id='$zone_id'
- WHERE
- node_id=" . $node_id;
-
- // run query
- $db->db_update($query);
+ }
+ break;
+ }
+}
+
+if (isset($_POST['add'])) {
+ switch ($_POST['add']) {
+ case ("asset") :
+ $asset_name = sanitize($_POST['asset_name']);
+ $asset_hostname = sanitize($_POST['asset_hostname']);
+ $assetclass_id = sanitize($_POST['assetclass_id']);
+ $asset_info = sanitize($_POST['asset_info']);
+
+ $query = "INSERT
+ INTO
+ asset(
+ asset_name,
+ asset_hostname,
+ assetclass_id,
+ asset_info
+ )
+ VALUE
+ (
+ '$asset_name',
+ '$asset_hostname',
+ '$assetclass_id',
+ '$asset_info'
+ )";
+
+ $asset_id = $db->db_insert($query);
+
+ header_location("assetview.php?asset_id=" . $asset_id);
+ break;
+ case ("assetclass") :
+ $assetclass_name = sanitize($_POST['assetclass_name']);
+ $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']);
+
+ $query = "INSERT
+ INTO
+ assetclass(
+ assetclass_name,
+ assetclassgroup_id
+ )
+ VALUE
+ (
+ '$assetclass_name',
+ '$assetclassgroup_id'
+ )";
+
+ $assetclass_id = $db->db_insert($query);
+
+ header_location("assetclassview.php?assetclass_id=" . $assetclass_id);
+ break;
+ case ("assetclassgroup") :
+ $assetclassgroup_name = sanitize($_POST['assetclassgroup_name']);
+ $assetclassgroup_color = preg_replace("|[^a-zA-Z0-9]|", "", strtoupper(sanitize($_POST['assetclassgroup_color'])));
+
+ $query = "INSERT
+ INTO
+ assetclassgroup(
+ assetclassgroup_name,
+ assetclassgroup_color
+ )
+ VALUE
+ (
+ '$assetclassgroup_name',
+ '$assetclassgroup_color'
+ )";
+
+ $assetclassgroup_id = $db->db_insert($query);
+
+ header_location("assetclassgroupview.php?assetclassgroup_id=" . $assetclassgroup_id);
+ break;
+ case ("assignnodetoasset") :
+ $node_ip = sanitize($_POST['node_ip']);
+ $subnet_id = sanitize($_POST['subnet_id']);
+ $asset_id = sanitize($_POST['asset_id']);
+ $node_mac = strip_mac(sanitize($_POST['node_mac']));
+ if ((!empty($_POST['node_dns1']) && isset($_POST['node_dns1suffix'])) ? $node_dns1 = sanitize($_POST['node_dns1']) . $config_dns1suffix : $node_dns1 = sanitize($_POST['node_dns1']));
+ if ((!empty($_POST['node_dns2']) && isset($_POST['node_dns2suffix'])) ? $node_dns2 = sanitize($_POST['node_dns2']) . $config_dns2suffix : $node_dns2 = sanitize($_POST['node_dns2']));
+ $node_info = $_POST['node_info'];
+
+ $query = "INSERT
+ INTO
+ node(
+ node_ip,
+ node_mac,
+ node_dns1,
+ node_dns2,
+ subnet_id,
+ asset_id,
+ node_info
+ )
+ VALUE
+ (
+ '$node_ip',
+ '$node_mac',
+ '$node_dns1',
+ '$node_dns2',
+ '$subnet_id',
+ '$asset_id',
+ '$node_info'
+ )";
+
+ $node_id = $db->db_insert($query);
+
+ header_location("nodeview.php?node_id=" . $node_id);
+ break;
+ case ("assignlocationtosubnet") :
+ $location_id = sanitize($_POST['location_id']);
+ $subnet_id = sanitize($_POST['subnet_id']);
+
+ $query = "INSERT
+ INTO
+ subnetlocation(
+ location_id,
+ subnet_id
+ )
+ VALUE
+ (
+ '$location_id',
+ '$subnet_id'
+ )";
+
+ $db->db_insert($query);
+
+ header_location("Location: location.php");
+ break;
+ case ("assignsubnettovlan") :
+ $subnet_id = sanitize($_POST['subnet_id']);
+ $vlan_id = sanitize($_POST['vlan_id']);
+
+ $query = "UPDATE
+ subnet
+ SET
+ vlan_id='$vlan_id'
+ WHERE
+ subnet_id='$subnet_id'";
+
+ $db->db_update($query);
+
+ header_location("subnetview.php?subnet_id=" . $subnet_id);
+ break;
+ case ("location") :
+ $location_name = sanitize($_POST['location_name']);
+ $location_parent = sanitize($_POST['location_parent']);
+ $location_info = sanitize($_POST['location_info']);
+
+ $query = "INSERT
+ INTO
+ location(
+ location_name,
+ location_parent,
+ location_info
+ )
+ VALUE
+ (
+ '$location_name',
+ '$location_parent',
+ '$location_info'
+ )";
+
+ $location_id = $db->db_insert($query);
+
+ header_location("locationview.php?location_id=" . $location_id);
+ break;
+ case ("locationsubnet") :
+ $location_id = sanitize($_POST['location_id']);
+ $subnet_id = sanitize($_POST['subnet_id']);
+
+ $query = "INSERT
+ INTO
+ subnetlocation(
+ location_id,
+ subnet_id
+ )
+ VALUE
+ (
+ '$location_id',
+ '$subnet_id'
+ )";
+
+ $newid = $db->db_insert($query);
+
+ header_location("locationview.php?location_id=" . $location_id);
+ break;
+ case ("nat") :
+ $node_id_ext = sanitize($_POST['node_id_ext']);
+ $node_id_int = sanitize($_POST['node_id_int']);
+ $nat_type = sanitize($_POST['nat_type']);
+
+ $query = "INSERT
+ INTO
+ nat(
+ nat_ext,
+ nat_int,
+ nat_type
+ )
+ VALUE
+ (
+ '$node_id_ext',
+ '$node_id_int',
+ '$nat_type'
+ )";
+
+ $db->db_insert($query);
+
+ header_location("nodeview.php?node_id=" . $node_id_ext);
+ break;
+ case ("node") :
+ $asset_name = sanitize($_POST['asset_name']);
+ $asset_hostname = sanitize($_POST['asset_hostname']);
+ $assetclass_id = sanitize($_POST['assetclass_id']);
+ $ip = sanitize($_POST['node_ip']);
+ $mac = strip_mac(sanitize($_POST['node_mac']));
+ if ((!empty($_POST['node_dns1']) && isset($_POST['dns1suffix'])) ? $dns1 = sanitize($_POST['node_dns1']) . $config_dns1suffix : $dns1 = sanitize($_POST['node_dns1']));
+ if ((!empty($_POST['node_dns2']) && isset($_POST['dns2suffix'])) ? $dns2 = sanitize($_POST['node_dns2']) . $config_dns2suffix : $dns2 = sanitize($_POST['node_dns2']));
+ $node_info = sanitize($_POST['node_info']);
+ $subnet_id = $_POST['subnet_id'];
+
+ $query = "INSERT
+ INTO
+ asset(
+ asset_name,
+ asset_hostname,
+ assetclass_id
+ )
+ VALUE
+ (
+ '$asset_name',
+ '$asset_hostname',
+ '$assetclass_id'
+ )";
+
+ $asset_id = $db->db_insert($query);
+
+ $query = "INSERT
+ INTO
+ node(
+ node_ip,
+ node_mac,
+ node_dns1,
+ node_dns2,
+ node_info,
+ subnet_id,
+ asset_id
+ )
+ VALUE
+ (
+ '$ip',
+ '$mac',
+ '$dns1',
+ '$dns2',
+ '$node_info',
+ '$subnet_id',
+ '$asset_id'
+ )";
+
+ $node_id = $db->db_insert($query);
+
+ header_location("nodeview.php?node_id=" . $node_id);
+ break;
+ case ("subnet") :
+ $subnet_address= sanitize($_POST['subnet_address']);
+ $subnet_mask = sanitize($_POST['subnet_mask']);
+ $subnet_info = sanitize($_POST['subnet_info']);
+
+ $query = "INSERT
+ INTO
+ subnet(
+ subnet_address,
+ subnet_mask,
+ subnet_info
+ )
+ VALUE
+ (
+ '$subnet_address',
+ '$subnet_mask',
+ '$subnet_info'
+ )";
+
+ $subnet_id = $db->db_insert($query);
+
+ header_location("subnetview.php?subnet_id=" . $subnet_id);
+ break;
+ case ("subnetlocation") :
+ $location_id = sanitize($_POST['location_id']);
+ $subnet_id = sanitize($_POST['subnet_id']);
+
+ $query = "INSERT
+ INTO
+ subnetlocation(
+ location_id,
+ subnet_id
+ )
+ VALUE
+ (
+ '$location_id',
+ '$subnet_id'
+ )";
+
+ $db->db_insert($query);
+
+ header_location("subnetview.php?subnet_id=" . $subnet_id);
+ break;
+ case ("subnetvlan") :
+ $subnet_id = sanitize($_POST['subnet_id']);
+ $vlan_id = sanitize($_POST['vlan_id']);
+
+ $query = "INSERT
+ INTO
+ subnetvlan(
+ subnet_id,
+ vlan_id
+ )
+ VALUE
+ (
+ '$subnet_id',
+ '$vlan_id'
+ )";
+
+ $db->db_insert($query);
+
+ header_location("subnetview.php?subnet_id=" . $subnet_id);
+ break;
+ case ("user") :
+ $user_name = strtolower(sanitize($_POST['user_name']));
+ $user_displayname = sanitize($_POST['user_displayname']);
+ $user_password = md5(sanitize($_POST['user_password']));
+
+ $query = "SELECT
+ user_name
+ FROM
+ user
+ WHERE
+ user_name='$user_name'";
+
+ $users = $db->db_select($query);
+
+ $user_counter = count($users);
+
+ if ($user_counter==0) {
+ $query = "INSERT
+ INTO
+ user(
+ user_name,
+ user_displayname,
+ user_pass
+ )
+ VALUE
+ (
+ '$user_name',
+ '$user_displayname',
+ '$user_password'
+ )";
+
+ $user_id = $db->db_insert($query);
+
+ header_location("userview.php?user_id=" . $user_id);
+ }
- // redirect
- header_location("nodeview.php?node_id=" . $node_id);
- break;
- case ("optionsdisplay") :
- // get variables
- $user_id = $_SESSION['suser_id'];
- $user_language = $_POST['user_language'];
- $user_imagesize = sanitize($_POST['user_imagesize']);
- $user_imagecount = sanitize($_POST['user_imagecount']);
- $user_mac = sanitize($_POST['user_mac']);
- $user_dateformat = sanitize($_POST['user_dateformat']);
- $user_dns1suffix = sanitize($_POST['user_dns1suffix']);
- $user_dns2suffix = sanitize($_POST['user_dns2suffix']);
- $user_menu_assets = sanitize($_POST['user_menu_assets']);
- $user_menu_assetclasses = sanitize($_POST['user_menu_assetclasses']);
- $user_menu_assetclassgroups = sanitize($_POST['user_menu_assetclassgroups']);
- $user_menu_locations = sanitize($_POST['user_menu_locations']);
- $user_menu_nodes = sanitize($_POST['user_menu_nodes']);
- $user_menu_subnets = sanitize($_POST['user_menu_subnets']);
- $user_menu_users = sanitize($_POST['user_menu_users']);
- $user_menu_vlans = sanitize($_POST['user_menu_vlans']);
- $user_menu_zones = sanitize($_POST['user_menu_zones']);
- $user_tooltips = sanitize($_POST['user_tooltips']);
-
- // update db
+ $comments = "usernameinuse";
+ break;
+ case ("vlan") :
+ $vlan_name = sanitize($_POST['vlan_name']);
+ $vlan_number = sanitize($_POST['vlan_number']);
+ $vlan_info = sanitize($_POST['vlan_info']);
+
+ $query = "INSERT
+ INTO
+ vlan(
+ vlan_name,
+ vlan_number,
+ vlan_info
+ )
+ VALUE
+ (
+ '$vlan_name',
+ '$vlan_number',
+ '$vlan_info'
+ )";
+
+ $vlan_id = $db->db_insert($query);
+
+ header_location("vlanview.php?vlan_id=" . $vlan_id);
+ break;
+ case ("vlansubnet") :
+ $subnet_id = sanitize($_POST['subnet_id']);
+ $vlan_id = sanitize($_POST['vlan_id']);
+
+ $query = "INSERT
+ INTO
+ subnetvlan(
+ subnet_id,
+ vlan_id
+ )
+ VALUE
+ (
+ '$subnet_id',
+ '$vlan_id'
+ )";
+
+ $db->db_insert($query);
+
+ header_location("vlanview.php?vlan_id=" . $vlan_id);
+ break;
+ case ("zone") :
+ $zone_origin = sanitize($_POST['zone_origin']);
+ $zone_ttl_default = sanitize($_POST['zone_ttl_default']);
+ $zone_soa = sanitize($_POST['zone_soa']);
+ $zone_hostmaster = sanitize($_POST['zone_hostmaster']);
+ $zone_refresh = sanitize($_POST['zone_refresh']);
+ $zone_retry = sanitize($_POST['zone_retry']);
+ $zone_expire = sanitize($_POST['zone_expire']);
+ $zone_ttl = sanitize($_POST['zone_ttl']);
+ $zone_serial = sanitize($_POST['zone_serial']);
+ $zone_ns1 = sanitize($_POST['zone_ns1']);
+ $zone_ns2 = sanitize($_POST['zone_ns2']);
+ $zone_ns3 = sanitize($_POST['zone_ns3']);
+ $zone_mx1 = sanitize($_POST['zone_mx1']);
+ $zone_mx2 = sanitize($_POST['zone_mx2']);
+ $zone_info = sanitize($_POST['zone_info']);
+
+ $query = "INSERT
+ INTO
+ zone(
+ zone_origin,
+ zone_ttl_default,
+ zone_soa,
+ zone_hostmaster,
+ zone_refresh,
+ zone_retry,
+ zone_expire,
+ zone_ttl,
+ zone_serial,
+ zone_ns1,
+ zone_ns2,
+ zone_ns3,
+ zone_mx1,
+ zone_mx2,
+ zone_info
+ )
+ VALUE
+ (
+ '$zone_origin',
+ '$zone_ttl_default',
+ '$zone_soa',
+ '$zone_hostmaster',
+ '$zone_refresh',
+ '$zone_retry',
+ '$zone_expire',
+ '$zone_ttl',
+ '$zone_serial',
+ '$zone_ns1',
+ '$zone_ns2',
+ '$zone_ns3',
+ '$zone_mx1',
+ '$zone_mx2',
+ '$zone_info'
+ )";
+
+ $zoneid = $db->db_insert($query);
+
+ header_location("zoneview.php?zone_id=" . $zoneid);
+ break;
+ }
+}
+
+if (isset($_POST['del'])) {
+ switch ($_POST['del']) {
+ case ("asset") :
+ $asset_id = sanitize($_POST['asset_id']);
+
+ $query = "DELETE
+ FROM
+ asset
+ WHERE
+ asset_id=" . $asset_id;
+
+ $db->db_delete($query);
+
+ $query = "DELETE
+ FROM
+ node
+ WHERE
+ asset_id=" . $asset_id;
+
+ $db->db_delete($query);
+
+ header_location("asset.php");
+ break;
+ case ("assetclass") :
+ $assetclass_id = sanitize($_POST['assetclass_id']);
+
+ $query = "DELETE
+ FROM
+ assetclass
+ WHERE
+ assetclass_id=" . $assetclass_id;
+
+ $db->db_delete($query);
+
+ header_location("assetclass.php");
+ break;
+ case ("assetclassgroup") :
+ $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']);
+
+ $query = "DELETE
+ FROM
+ assetclassgroup
+ WHERE
+ assetclassgroup_id=" . $assetclassgroup_id;
+
+ $db->db_delete($query);
+
+ header_location("assetclassgroup.php");
+ break;
+ case ("location") :
+ $location_id = sanitize($_POST['location_id']);
+
+ $query = "DELETE
+ FROM
+ location
+ WHERE
+ location_id=" . $location_id;
+
+ $db->db_delete($query);
+
+ header_location("location.php");
+ break;
+ case ("locationsubnet") :
+ $location_id = sanitize($_POST['location_id']);
+ $subnet_id = sanitize($_POST['subnet_id']);
+
+ $query = "DELETE
+ FROM
+ subnetlocation
+ WHERE
+ location_id=" . $location_id . "
+ AND subnet_id=" . $subnet_id;
+
+ $db->db_delete($query);
+
+ header_location("locationview.php?location_id=" . $location_id);
+ break;
+ case ("nat") :
+ $node_id_ext = sanitize($_POST['node_id_ext']);
+ $node_id_int = sanitize($_POST['node_id_int']);
+
+ $query = "DELETE
+ FROM
+ nat
+ WHERE
+ nat_ext=" . $node_id_ext . "
+ AND nat_int=" . $node_id_int;
+
+ $db->db_delete($query);
+
+ header_location("nodeview.php?node_id=" . $node_id_ext);
+ break;
+ case ("node") :
+ $node_id = sanitize($_POST['node_id']);
+ $asset_id = sanitize($_POST['asset_id']);
+
+ $query = "DELETE
+ FROM
+ node
+ WHERE
+ node_id=" . $node_id;
+
+ $db->db_delete($query);
+
+ header_location("assetview.php?asset_id=" . $asset_id);
+ break;
+ case ("subnet") :
+ $subnet_id = sanitize($_POST['subnet_id']);
+
+ $query = "DELETE
+ FROM
+ subnet
+ WHERE
+ subnet_id=" . $subnet_id;
+
+ $db->db_delete($query);
+
+ $query = "DELETE
+ FROM
+ node
+ WHERE
+ subnet_id=" . $subnet_id;
+
+ $db->db_delete($query);
+
+ header_location("subnet.php");
+ break;
+ case ("subnetlocation") :
+ $location_id = sanitize($_POST['location_id']);
+ $subnet_id = sanitize($_POST['subnet_id']);
+
+ $query = "DELETE
+ FROM
+ subnetlocation
+ WHERE
+ location_id=" . $location_id . "
+ AND subnet_id=" . $subnet_id;
+
+ $db->db_delete($query);
+
+ header_location("subnetview.php?subnet_id=" . $subnet_id);
+ break;
+ case ("subnetvlan") :
+ $subnet_id = sanitize($_POST['subnet_id']);
+ $vlan_id = sanitize($_POST['vlan_id']);
+
+ $query = "DELETE
+ FROM
+ subnetvlan
+ WHERE
+ subnet_id=" . $subnet_id . "
+ AND vlan_id=" . $vlan_id;
+
+ $db->db_delete($query);
+
+ header_location("subnetview.php?subnet_id=" . $subnet_id);
+ break;
+ case ("user") :
+ $user_id = sanitize($_POST['user_id']);
+
+ $query = "DELETE
+ FROM
+ user
+ WHERE
+ user_id=" . $user_id;
+
+ $db->db_delete($query);
+
+ header_location("user.php");
+ break;
+ case ("vlan") :
+ $vlan_id = sanitize($_POST['vlan_id']);
+
+ $query = "DELETE
+ FROM
+ vlan
+ WHERE
+ vlan_id=" . $vlan_id;
+
+ $db->db_delete($query);
+
+ header_location("vlan.php");
+ break;
+ case ("vlansubnet") :
+ $subnet_id = sanitize($_POST['subnet_id']);
+ $vlan_id = sanitize($_POST['vlan_id']);
+
+ $query = "DELETE
+ FROM
+ subnetvlan
+ WHERE
+ subnet_id=" . $subnet_id . "
+ AND vlan_id=" . $vlan_id;
+
+ $db->db_delete($query);
+
+ header_location("vlanview.php?vlan_id=" . $vlan_id);
+ break;
+ case ("zone") :
+ $zone_id = sanitize($_POST['zone_id']);
+
+ $query = "DELETE
+ FROM
+ zone
+ WHERE
+ zone_id=" . $zone_id;
+
+ $db->db_delete($query);
+
+ header_location("zone.php");
+ break;
+ }
+}
+
+if (isset($_POST['edit'])) {
+ switch ($_POST['edit']) {
+ case ("asset") :
+ $asset_id = sanitize($_POST['asset_id']);
+ $asset_name = sanitize($_POST['asset_name']);
+ $asset_info = sanitize($_POST['asset_info']);
+ $asset_hostname = sanitize($_POST['asset_hostname']);
+ $assetclass_id = sanitize($_POST['assetclass_id']);
+
+ $query = "UPDATE
+ asset
+ SET
+ asset_name='$asset_name',
+ asset_info='$asset_info',
+ asset_hostname='$asset_hostname',
+ assetclass_id='$assetclass_id'
+ WHERE
+ asset_id=" . $asset_id;
+
+ $db->db_update($query);
+
+ header_location("assetview.php?asset_id=" . $asset_id);
+ case ("assetclass") :
+ $assetclass_id = sanitize($_POST['assetclass_id']);
+ $assetclass_name = sanitize($_POST['assetclass_name']);
+ $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']);
+
+ $query = "UPDATE
+ assetclass
+ SET
+ assetclass_name='$assetclass_name',
+ assetclassgroup_id='$assetclassgroup_id'
+ WHERE
+ assetclass_id=" . $assetclass_id;
+
+ $db->db_update($query);
+
+ header_location("assetclassview.php?assetclass_id=" . $assetclass_id);
+ break;
+ case ("assetclassgroup") :
+ $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']);
+ $assetclassgroup_name = sanitize($_POST['assetclassgroup_name']);
+ $assetclassgroup_color = preg_replace("|[^a-zA-Z0-9]|", "", strtoupper(sanitize($_POST['assetclassgroup_color'])));
+
+ $query = "UPDATE
+ assetclassgroup
+ SET
+ assetclassgroup_name='$assetclassgroup_name',
+ assetclassgroup_color='$assetclassgroup_color'
+ WHERE
+ assetclassgroup_id=" . $assetclassgroup_id;
+
+ $db->db_update($query);
+
+ header_location("assetclassgroupview.php?assetclassgroup_id=" . $assetclassgroup_id);
+ break;
+ case ("location") :
+ $location_id = sanitize($_POST['location_id']);
+ $location_name = sanitize($_POST['location_name']);
+ $location_info = sanitize($_POST['location_info']);
+ $parentlocation_id = sanitize($_POST['parentlocation_id']);
+
+ $query = "UPDATE
+ location
+ SET
+ location_name='$location_name',
+ location_parent='$parentlocation_id',
+ location_info='$location_info'
+ WHERE
+ location_id=" . $location_id;
+
+ $db->db_update($query);
+
+ header_location("locationview.php?location_id=" . $location_id);
+ break;
+ case ("node") :
+ $node_id = sanitize($_POST['node_id']);
+ $asset_id = sanitize($_POST['asset_id']);
+ $node_ip = sanitize($_POST['node_ip']);
+ $subnet_id = sanitize($_POST['subnet_id']);
+ $node_mac = strip_mac(sanitize($_POST['node_mac']));
+ $node_dns1 = sanitize($_POST['node_dns1']);
+ $node_dns2 = sanitize($_POST['node_dns2']);
+ $node_info = sanitize($_POST['node_info']);
+ $zone_id = sanitize($_POST['zone_id']);
+
+ $query = "UPDATE
+ node
+ SET
+ asset_id='$asset_id',
+ node_ip='$node_ip',
+ subnet_id='$subnet_id',
+ node_mac='$node_mac',
+ node_dns1='$node_dns1',
+ node_dns2='$node_dns2',
+ node_info='$node_info',
+ zone_id='$zone_id'
+ WHERE
+ node_id=" . $node_id;
+
+ $db->db_update($query);
+
+ header_location("nodeview.php?node_id=" . $node_id);
+ break;
+ case ("optionsdisplay") :
+ $user_id = $_SESSION['suser_id'];
+ $user_language = $_POST['user_language'];
+ $user_imagesize = sanitize($_POST['user_imagesize']);
+ $user_imagecount = sanitize($_POST['user_imagecount']);
+ $user_mac = sanitize($_POST['user_mac']);
+ $user_dateformat = sanitize($_POST['user_dateformat']);
+ $user_dns1suffix = sanitize($_POST['user_dns1suffix']);
+ $user_dns2suffix = sanitize($_POST['user_dns2suffix']);
+ $user_menu_assets = sanitize($_POST['user_menu_assets']);
+ $user_menu_assetclasses = sanitize($_POST['user_menu_assetclasses']);
+ $user_menu_assetclassgroups = sanitize($_POST['user_menu_assetclassgroups']);
+ $user_menu_locations = sanitize($_POST['user_menu_locations']);
+ $user_menu_nodes = sanitize($_POST['user_menu_nodes']);
+ $user_menu_subnets = sanitize($_POST['user_menu_subnets']);
+ $user_menu_users = sanitize($_POST['user_menu_users']);
+ $user_menu_vlans = sanitize($_POST['user_menu_vlans']);
+ $user_menu_zones = sanitize($_POST['user_menu_zones']);
+ $user_tooltips = sanitize($_POST['user_tooltips']);
+
+ $query = "UPDATE
+ user
+ SET
+ user_language='" . $user_language . "',
+ user_imagesize='" . $user_imagesize . "',
+ user_imagecount='" . $user_imagecount . "',
+ user_mac='" . $user_mac . "',
+ user_dateformat='" . $user_dateformat . "',
+ user_dns1suffix='" . $user_dns1suffix . "',
+ user_dns2suffix='" . $user_dns2suffix . "',
+ user_menu_assets='" . $user_menu_assets . "',
+ user_menu_assetclasses='" . $user_menu_assetclasses . "',
+ user_menu_assetclassgroups='" . $user_menu_assetclassgroups . "',
+ user_menu_locations='" . $user_menu_locations . "',
+ user_menu_nodes='" . $user_menu_nodes . "',
+ user_menu_subnets='" . $user_menu_subnets . "',
+ user_menu_users='" . $user_menu_users . "',
+ user_menu_vlans='" . $user_menu_vlans . "',
+ user_menu_zones='" . $user_menu_zones . "',
+ user_tooltips='" . $user_tooltips . "'
+ WHERE
+ user_id=" . $user_id;
+
+ $_SESSION['suser_language'] = $user_language;
+ $_SESSION['suser_imagesize'] = $user_imagesize;
+ $_SESSION['suser_imagecount'] = $user_imagecount;
+ $_SESSION['suser_mac'] = $user_mac;
+ $_SESSION['suser_dateformat'] = $user_dateformat;
+ $_SESSION['suser_dns1suffix'] = $user_dns1suffix;
+ $_SESSION['suser_dns2suffix'] = $user_dns2suffix;
+ $_SESSION['suser_menu_assets'] = $user_menu_assets;
+ $_SESSION['suser_menu_assetclasses'] = $user_menu_assetclasses;
+ $_SESSION['suser_menu_assetclassgroups'] = $user_menu_assetclassgroups;
+ $_SESSION['suser_menu_locations'] = $user_menu_locations;
+ $_SESSION['suser_menu_nodes'] = $user_menu_nodes;
+ $_SESSION['suser_menu_subnets'] = $user_menu_subnets;
+ $_SESSION['suser_menu_users'] = $user_menu_users;
+ $_SESSION['suser_menu_vlans'] = $user_menu_vlans;
+ $_SESSION['suser_menu_zones'] = $user_menu_zones;
+ $_SESSION['suser_tooltips'] = $user_tooltips;
+
+ $db->db_update($query);
+
+ header_location("options.php");
+ break;
+ case ("optionspassword") :
+ $user_id = $_SESSION['suser_id'];
+ $user_currentpass = sanitize($_POST['user_currentpass']);
+ $user_newpass1 = sanitize($_POST['user_newpass1']);
+ $user_newpass2 = sanitize($_POST['user_newpass2']);
+
+ $query = "SELECT
+ user_pass
+ FROM
+ user
+ WHERE
+ user_id='" . $user_id . "'";
+
+ $user = $db->db_select($query);
+
+ if(!strcmp(md5($user_currentpass), $user[0]['user_pass'])) {
+ if(!strcmp($user_newpass1, $user_newpass2)) {
$query = "UPDATE
user
SET
- user_language='" . $user_language . "',
- user_imagesize='" . $user_imagesize . "',
- user_imagecount='" . $user_imagecount . "',
- user_mac='" . $user_mac . "',
- user_dateformat='" . $user_dateformat . "',
- user_dns1suffix='" . $user_dns1suffix . "',
- user_dns2suffix='" . $user_dns2suffix . "',
- user_menu_assets='" . $user_menu_assets . "',
- user_menu_assetclasses='" . $user_menu_assetclasses . "',
- user_menu_assetclassgroups='" . $user_menu_assetclassgroups . "',
- user_menu_locations='" . $user_menu_locations . "',
- user_menu_nodes='" . $user_menu_nodes . "',
- user_menu_subnets='" . $user_menu_subnets . "',
- user_menu_users='" . $user_menu_users . "',
- user_menu_vlans='" . $user_menu_vlans . "',
- user_menu_zones='" . $user_menu_zones . "',
- user_tooltips='" . $user_tooltips . "'
+ user_pass='" . md5($user_newpass1) . "'
WHERE
user_id=" . $user_id;
- // update session
- $_SESSION['suser_language'] = $user_language;
- $_SESSION['suser_imagesize'] = $user_imagesize;
- $_SESSION['suser_imagecount'] = $user_imagecount;
- $_SESSION['suser_mac'] = $user_mac;
- $_SESSION['suser_dateformat'] = $user_dateformat;
- $_SESSION['suser_dns1suffix'] = $user_dns1suffix;
- $_SESSION['suser_dns2suffix'] = $user_dns2suffix;
- $_SESSION['suser_menu_assets'] = $user_menu_assets;
- $_SESSION['suser_menu_assetclasses'] = $user_menu_assetclasses;
- $_SESSION['suser_menu_assetclassgroups'] = $user_menu_assetclassgroups;
- $_SESSION['suser_menu_locations'] = $user_menu_locations;
- $_SESSION['suser_menu_nodes'] = $user_menu_nodes;
- $_SESSION['suser_menu_subnets'] = $user_menu_subnets;
- $_SESSION['suser_menu_users'] = $user_menu_users;
- $_SESSION['suser_menu_vlans'] = $user_menu_vlans;
- $_SESSION['suser_menu_zones'] = $user_menu_zones;
- $_SESSION['suser_tooltips'] = $user_tooltips;
-
- // run query
$db->db_update($query);
- // redirect
header_location("options.php");
- break;
- case ("optionspassword") :
- // get variables
- $user_id = $_SESSION['suser_id'];
- $user_currentpass = sanitize($_POST['user_currentpass']);
- $user_newpass1 = sanitize($_POST['user_newpass1']);
- $user_newpass2 = sanitize($_POST['user_newpass2']);
-
- // get current pass from db
- $query = "SELECT
- user_pass
- FROM
- user
- WHERE
- user_id='" . $user_id . "'";
-
- // run query
- $user = $db->db_select($query);
-
- // check current pass
- if(!strcmp(md5($user_currentpass), $user[0]['user_pass'])) {
- if(!strcmp($user_newpass1, $user_newpass2)) {
- // update db
- $query = "UPDATE
- user
- SET
- user_pass='" . md5($user_newpass1) . "'
- WHERE
- user_id=" . $user_id;
-
- // run query
- $db->db_update($query);
-
- // redirect
- header_location("options.php");
- }
- }
- break;
- case ("subnet") :
- // get variables
- $subnet_id = sanitize($_POST['subnet_id']);
- $subnet_address= sanitize($_POST['subnet_address']);
- $subnet_proto_vers = sanitize($_POST['subnet_proto_vers']);
- $subnet_mask = sanitize($_POST['subnet_mask']);
- $subnet_dhcpstart = sanitize($_POST['subnet_dhcpstart']);
- $subnet_dhcpend = sanitize($_POST['subnet_dhcpend']);
- $subnet_ntp_server = sanitize($_POST['subnet_ntp_server']);
- $subnet_info = sanitize($_POST['subnet_info']);
-
- // update db
- $query = "UPDATE
- subnet
- SET
- subnet_address='$subnet_address',
- subnet_mask='$subnet_mask',
- subnet_dhcp_start='$subnet_dhcpstart',
- subnet_dhcp_end='$subnet_dhcpend',
- subnet_info='$subnet_info',
- protocol_version=$subnet_proto_vers,
- ntp_server='$subnet_ntp_server'
- WHERE
- subnet_id=" . $subnet_id;
-
- // run query
- $db->db_update($query);
-
- // redirect
- header_location("subnetview.php?subnet_id=" . $subnet_id);
- break;
- case ("user") :
- // get variables
- $user_id = sanitize($_POST['user_id']);
- $user_name = sanitize($_POST['user_name']);
- $user_displayname = sanitize($_POST['user_displayname']);
-
- // update db
- $query = "UPDATE
- user
- SET
- user_name='" . $user_name . "',
- user_displayname='" . $user_displayname . "'
- WHERE
- user_id=" . $user_id;
-
- // run query
- $db->db_update($query);
-
- // redirect
- header_location("userview.php?user_id=" . $user_id);
- break;
- case ("vlan") :
- // get variables
- $vlan_id = sanitize($_POST['vlan_id']);
- $vlan_name = sanitize($_POST['vlan_name']);
- $vlan_number = sanitize($_POST['vlan_number']);
- $vlan_info = sanitize($_POST['vlan_info']);
-
- // update db
- $query = "UPDATE
- vlan
- SET
- vlan_name='$vlan_name',
- vlan_number='$vlan_number',
- vlan_info='$vlan_info'
- WHERE
- vlan_id=" . $vlan_id;
-
- // run query
- $db->db_update($query);
-
- // redirect
- header_location("vlanview.php?vlan_id=" . $vlan_id);
- break;
- case ("zone") :
- // get variables
- $zone_id = sanitize($_POST['zone_id']);
- $zone_origin = sanitize($_POST['zone_origin']);
- $zone_ttl_default = sanitize($_POST['zone_ttl_default']);
- $zone_soa = sanitize($_POST['zone_soa']);
- $zone_hostmaster = sanitize($_POST['zone_hostmaster']);
- $zone_refresh = sanitize($_POST['zone_refresh']);
- $zone_retry = sanitize($_POST['zone_retry']);
- $zone_expire = sanitize($_POST['zone_expire']);
- $zone_ttl = sanitize($_POST['zone_ttl']);
- $zone_serial = sanitize($_POST['zone_serial']);
- $zone_ns1 = sanitize($_POST['zone_ns1']);
- $zone_ns2 = sanitize($_POST['zone_ns2']);
- $zone_ns3 = sanitize($_POST['zone_ns3']);
- $zone_mx1 = sanitize($_POST['zone_mx1']);
- $zone_mx2 = sanitize($_POST['zone_mx2']);
- $zone_info = sanitize($_POST['zone_info']);
- // update db
- $query = "UPDATE
- zone
- SET
- zone_origin='$zone_origin',
- zone_ttl_default='$zone_ttl_default',
- zone_soa='$zone_soa',
- zone_hostmaster='$zone_hostmaster',
- zone_refresh='$zone_refresh',
- zone_retry='$zone_retry',
- zone_expire='$zone_expire',
- zone_ttl='$zone_ttl',
- zone_serial='$zone_serial',
- zone_ns1='$zone_ns1',
- zone_ns2='$zone_ns2',
- zone_ns3='$zone_ns3',
- zone_mx1='$zone_mx1',
- zone_mx2='$zone_mx2',
- zone_info='$zone_info'
- WHERE
- zone_id=" . $zone_id;
-
- // run query
- $db->db_update($query);
-
- // redirect
- header_location("zoneview.php?zone_id=" . $zone_id);
- break;
+ }
}
- }
- }
-
- // still not redirected, check for error
- if(empty($comments)) {
- $comments = "error";
+ break;
+ case ("subnet") :
+ $subnet_id = sanitize($_POST['subnet_id']);
+ $subnet_address= sanitize($_POST['subnet_address']);
+ $subnet_proto_vers = sanitize($_POST['subnet_proto_vers']);
+ $subnet_mask = sanitize($_POST['subnet_mask']);
+ $subnet_dhcpstart = sanitize($_POST['subnet_dhcpstart']);
+ $subnet_dhcpend = sanitize($_POST['subnet_dhcpend']);
+ $subnet_ntp_server = sanitize($_POST['subnet_ntp_server']);
+ $subnet_info = sanitize($_POST['subnet_info']);
+
+ $query = "UPDATE
+ subnet
+ SET
+ subnet_address='$subnet_address',
+ subnet_mask='$subnet_mask',
+ subnet_dhcp_start='$subnet_dhcpstart',
+ subnet_dhcp_end='$subnet_dhcpend',
+ subnet_info='$subnet_info',
+ protocol_version=$subnet_proto_vers,
+ ntp_server='$subnet_ntp_server'
+ WHERE
+ subnet_id=" . $subnet_id;
+
+ $db->db_update($query);
+
+ header_location("subnetview.php?subnet_id=" . $subnet_id);
+ break;
+ case ("user") :
+ $user_id = sanitize($_POST['user_id']);
+ $user_name = sanitize($_POST['user_name']);
+ $user_displayname = sanitize($_POST['user_displayname']);
+
+ $query = "UPDATE
+ user
+ SET
+ user_name='" . $user_name . "',
+ user_displayname='" . $user_displayname . "'
+ WHERE
+ user_id=" . $user_id;
+
+ $db->db_update($query);
+
+ header_location("userview.php?user_id=" . $user_id);
+ break;
+ case ("vlan") :
+ $vlan_id = sanitize($_POST['vlan_id']);
+ $vlan_name = sanitize($_POST['vlan_name']);
+ $vlan_number = sanitize($_POST['vlan_number']);
+ $vlan_info = sanitize($_POST['vlan_info']);
+
+ $query = "UPDATE
+ vlan
+ SET
+ vlan_name='$vlan_name',
+ vlan_number='$vlan_number',
+ vlan_info='$vlan_info'
+ WHERE
+ vlan_id=" . $vlan_id;
+
+ $db->db_update($query);
+
+ header_location("vlanview.php?vlan_id=" . $vlan_id);
+ break;
+ case ("zone") :
+ $zone_id = sanitize($_POST['zone_id']);
+ $zone_origin = sanitize($_POST['zone_origin']);
+ $zone_ttl_default = sanitize($_POST['zone_ttl_default']);
+ $zone_soa = sanitize($_POST['zone_soa']);
+ $zone_hostmaster = sanitize($_POST['zone_hostmaster']);
+ $zone_refresh = sanitize($_POST['zone_refresh']);
+ $zone_retry = sanitize($_POST['zone_retry']);
+ $zone_expire = sanitize($_POST['zone_expire']);
+ $zone_ttl = sanitize($_POST['zone_ttl']);
+ $zone_serial = sanitize($_POST['zone_serial']);
+ $zone_ns1 = sanitize($_POST['zone_ns1']);
+ $zone_ns2 = sanitize($_POST['zone_ns2']);
+ $zone_ns3 = sanitize($_POST['zone_ns3']);
+ $zone_mx1 = sanitize($_POST['zone_mx1']);
+ $zone_mx2 = sanitize($_POST['zone_mx2']);
+ $zone_info = sanitize($_POST['zone_info']);
+ $query = "UPDATE
+ zone
+ SET
+ zone_origin='$zone_origin',
+ zone_ttl_default='$zone_ttl_default',
+ zone_soa='$zone_soa',
+ zone_hostmaster='$zone_hostmaster',
+ zone_refresh='$zone_refresh',
+ zone_retry='$zone_retry',
+ zone_expire='$zone_expire',
+ zone_ttl='$zone_ttl',
+ zone_serial='$zone_serial',
+ zone_ns1='$zone_ns1',
+ zone_ns2='$zone_ns2',
+ zone_ns3='$zone_ns3',
+ zone_mx1='$zone_mx1',
+ zone_mx2='$zone_mx2',
+ zone_info='$zone_info'
+ WHERE
+ zone_id=" . $zone_id;
+
+ $db->db_update($query);
+
+ header_location("zoneview.php?zone_id=" . $zone_id);
+ break;
}
+}
- // redirect
- header_location("comments.php?comments=" . $comments);
+// still not redirected, check for error
+if(empty($comments)) {
+ $comments = "error";
+}
+header_location("comments.php?comments=" . $comments);
?>
diff --git a/subnet.php b/subnet.php
index a09412e..0981402 100644
--- a/subnet.php
+++ b/subnet.php
@@ -1,60 +1,34 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup subnet
- // build query
- $query = "SELECT
- s.subnet_id,
- s.subnet_address,
- s.subnet_mask,
- s.ntp_server,
- LEFT(s.subnet_info, 40) AS subnet_info,
- CHAR_LENGTH(s.subnet_info) AS subnet_length,
- COUNT(node.subnet_id) AS node_counter
- FROM
- subnet AS s LEFT JOIN node USING (subnet_id)
- GROUP BY
- s.subnet_id
- ORDER BY
- INET_ATON(s.subnet_address)";
-
- // run query
- $subnets = $db->db_select($query);
- $smarty->assign("subnets", $subnets);
-
- // end page
- // output
- $smarty->display("subnet.tpl");
-
- // end output
- include("footer.php");
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+include("header.php");
+
+$query = "SELECT
+ s.subnet_id,
+ s.subnet_address,
+ s.subnet_mask,
+ s.ntp_server,
+ LEFT(s.subnet_info, 40) AS subnet_info,
+ CHAR_LENGTH(s.subnet_info) AS subnet_length,
+ COUNT(node.subnet_id) AS node_counter
+ FROM
+ subnet AS s LEFT JOIN node USING (subnet_id)
+ GROUP BY
+ s.subnet_id
+ ORDER BY
+ INET_ATON(s.subnet_address)";
+
+$subnets = $db->db_select($query);
+
+$smarty->assign("subnets", $subnets);
+$smarty->display("subnet.tpl");
+
+include("footer.php");
?>
diff --git a/subnetadd.php b/subnetadd.php
index 538975d..20f90ae 100644
--- a/subnetadd.php
+++ b/subnetadd.php
@@ -1,61 +1,35 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
- // get id
- if((isset($_GET['vlan_id'])) ? $vlan_id = sanitize($_GET['vlan_id']) : $vlan_id = "");
+if((isset($_GET['vlan_id'])) ? $vlan_id = sanitize($_GET['vlan_id']) : $vlan_id = "");
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
+include("header.php");
- // setup vlan
- // build query
- $query = "SELECT
- vlan_id,
- vlan_number,
- vlan_name
- FROM
- vlan
- ORDER BY
- vlan_name";
+$query = "SELECT
+ vlan_id,
+ vlan_number,
+ vlan_name
+ FROM
+ vlan
+ ORDER BY
+ vlan_name";
- // run query
- $vlans = $db->db_select($query);
- $vlan_options[0] = $lang['lang_option_none'];
- foreach ($vlans as $vlan) {
- $vlan_options[$vlan['vlan_id']] = $vlan['vlan_name'];
- }
- $smarty->assign("vlan_options", $vlan_options);
+$vlans = $db->db_select($query);
+$vlan_options[0] = $lang['lang_option_none'];
+foreach ($vlans as $vlan) {
+ $vlan_options[$vlan['vlan_id']] = $vlan['vlan_name'];
+}
+$smarty->assign("vlan_options", $vlan_options);
- // end page
- // output
- $smarty->display("subnetadd.tpl");
+$smarty->display("subnetadd.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/subnetdel.php b/subnetdel.php
index 9d1bc34..6ed440f 100644
--- a/subnetdel.php
+++ b/subnetdel.php
@@ -1,76 +1,48 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get id
- $subnet_id = sanitize($_GET['subnet_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // setup subnet
- // build query
- $query = "SELECT
- subnet_address,
- subnet_mask
- FROM
- subnet
- WHERE
- subnet_id=" . $subnet_id;
+include("includes.php");
- // run query
- $subnet = $db->db_select($query);
+$subnet_id = sanitize($_GET['subnet_id']);
- // send to tpl
- $smarty->assign("subnet_id", $subnet_id);
- $smarty->assign("subnet_address", $subnet[0]['subnet_address']);
- $smarty->assign("subnet_mask", $subnet[0]['subnet_mask']);
-
- // setup node
- // build query
- $query = "SELECT
- node_id,
- node_ip
- FROM
- node
- WHERE
- subnet_id=" . $subnet_id . "
- ORDER BY
- INET_ATON(node_ip)";
+include("header.php");
+
+// subnet
+$query = "SELECT
+ subnet_address,
+ subnet_mask
+ FROM
+ subnet
+ WHERE
+ subnet_id=" . $subnet_id;
- // run query
- $nodes = $db->db_select($query);
- $smarty->assign("nodes", $nodes);
-
- // end page
- // output
- $smarty->display("subnetdel.tpl");
+$subnet = $db->db_select($query);
+
+$smarty->assign("subnet_id", $subnet_id);
+$smarty->assign("subnet_address", $subnet[0]['subnet_address']);
+$smarty->assign("subnet_mask", $subnet[0]['subnet_mask']);
+
+// node
+$query = "SELECT
+ node_id,
+ node_ip
+ FROM
+ node
+ WHERE
+ subnet_id=" . $subnet_id . "
+ ORDER BY
+ INET_ATON(node_ip)";
+
+$nodes = $db->db_select($query);
+
+$smarty->assign("nodes", $nodes);
+$smarty->display("subnetdel.tpl");
- // footer
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/subnetedit.php b/subnetedit.php
index 91cda9b..ab2344a 100644
--- a/subnetedit.php
+++ b/subnetedit.php
@@ -1,70 +1,43 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get id
- $subnet_id = sanitize($_GET['subnet_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup subnet
- // build query
- $query = "SELECT
- subnet_address,
- subnet_mask,
- protocol_version,
- subnet_dhcp_start,
- subnet_dhcp_end,
- ntp_server,
- subnet_info AS subnet_info
- FROM
- subnet
- WHERE
- subnet_id=" . $subnet_id;
-
- // run query
- $subnet = $db->db_select($query);
-
- // send to tpl
- $smarty->assign("subnet_id", $subnet_id);
- $smarty->assign("subnet_address", $subnet[0]['subnet_address']);
- $smarty->assign("subnet_mask", $subnet[0]['subnet_mask']);
- $smarty->assign("subnet_proto_vers", $subnet[0]['protocol_version']);
- $smarty->assign("subnet_dhcpstart", $subnet[0]['subnet_dhcp_start']);
- $smarty->assign("subnet_dhcpend", $subnet[0]['subnet_dhcp_end']);
- $smarty->assign("subnet_ntp_server", $subnet[0]['ntp_server']);
- $smarty->assign("subnet_info", $subnet[0]['subnet_info']);
-
- // end page
- // output
- $smarty->display("subnetedit.tpl");
-
- // end output
- include("footer.php");
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+
+$subnet_id = sanitize($_GET['subnet_id']);
+
+include("header.php");
+
+$query = "SELECT
+ subnet_address,
+ subnet_mask,
+ protocol_version,
+ subnet_dhcp_start,
+ subnet_dhcp_end,
+ ntp_server,
+ subnet_info AS subnet_info
+ FROM
+ subnet
+ WHERE
+ subnet_id=" . $subnet_id;
+
+$subnet = $db->db_select($query);
+
+$smarty->assign("subnet_id", $subnet_id);
+$smarty->assign("subnet_address", $subnet[0]['subnet_address']);
+$smarty->assign("subnet_mask", $subnet[0]['subnet_mask']);
+$smarty->assign("subnet_proto_vers", $subnet[0]['protocol_version']);
+$smarty->assign("subnet_dhcpstart", $subnet[0]['subnet_dhcp_start']);
+$smarty->assign("subnet_dhcpend", $subnet[0]['subnet_dhcp_end']);
+$smarty->assign("subnet_ntp_server", $subnet[0]['ntp_server']);
+$smarty->assign("subnet_info", $subnet[0]['subnet_info']);
+
+$smarty->display("subnetedit.tpl");
+
+include("footer.php");
?>
diff --git a/subnetlocationadd.php b/subnetlocationadd.php
index 466519f..12f3008 100644
--- a/subnetlocationadd.php
+++ b/subnetlocationadd.php
@@ -1,63 +1,34 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
+include("includes.php");
- // get ip and id
- $subnet_id = sanitize($_GET['subnet_id']);
+$subnet_id = sanitize($_GET['subnet_id']);
- // start output
- include("header.php");
+include("header.php");
- // set language variables
- $smarty->assign($lang);
-
- // setup subnet
- // build query
- $query = "SELECT
- subnet.subnet_address AS subnet_address,
- subnet.subnet_mask AS subnet_mask
- FROM
- subnet
- WHERE
- subnet.subnet_id=" . $subnet_id;
-
- // run query
- $subnet = $db->db_select($query);
-
- $smarty->assign("subnet_id", $subnet_id);
- $smarty->assign("subnet_address", $subnet[0]['subnet_address']);
- $smarty->assign("subnet_mask", $subnet[0]['subnet_mask']);
-
- // start parent
- // build query
- $smarty->assign("location_options", $db->options_location());
+$query = "SELECT
+ subnet_address,
+ subnet_mask
+ FROM
+ subnet
+ WHERE
+ subnet_id=" . $subnet_id;
- // end page
- // output
- $smarty->display("subnetlocationadd.tpl");
+$subnet = $db->db_select($query);
+
+$smarty->assign("subnet_id", $subnet_id);
+$smarty->assign("subnet_address", $subnet[0]['subnet_address']);
+$smarty->assign("subnet_mask", $subnet[0]['subnet_mask']);
+
+$smarty->assign("location_options", $db->options_location());
+$smarty->display("subnetlocationadd.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/subnetlocationdel.php b/subnetlocationdel.php
index a5e39f5..06cb992 100644
--- a/subnetlocationdel.php
+++ b/subnetlocationdel.php
@@ -1,82 +1,54 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
-
- // start page
- // includes
- include("includes.php");
-
- // get ip and id
- $subnet_id = sanitize($_GET['subnet_id']);
-
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
-
- // setup subnet
- // build query
- $query = "SELECT
- subnet.subnet_address AS subnet_address,
- subnet.subnet_mask AS subnet_mask
- FROM
- subnet
- WHERE
- subnet.subnet_id=" . $subnet_id;
-
- // run query
- $subnet = $db->db_select($query);
-
- $smarty->assign("subnet_id", $subnet_id);
- $smarty->assign("subnet_address", $subnet[0]['subnet_address']);
- $smarty->assign("subnet_mask", $subnet[0]['subnet_mask']);
-
- // setup location
- // build query
- $query = "SELECT
- location.location_id AS location_id,
- location.location_name AS location_name
- FROM
- subnetlocation,
- location
- WHERE
- subnetlocation.subnet_id=" . $subnet_id . "
- AND location.location_id=subnetlocation.location_id
- ORDER BY
- location.location_name";
-
- // run query
- $records = $db->db_select($query);
- $locations = array();
- foreach ($records as $rec) {
- $locations[$rec['location_id']] = $rec['location_name'];
- }
- $smarty->assign("location_options", $locations);
-
-
- // end page
- // output
- $smarty->display("subnetlocationdel.tpl");
-
- // end output
- include("footer.php");
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
+
+include("includes.php");
+
+$subnet_id = sanitize($_GET['subnet_id']);
+
+include("header.php");
+
+// subnet
+$query = "SELECT
+ subnet_address,
+ subnet_mask
+ FROM
+ subnet
+ WHERE
+ subnet_id=" . $subnet_id;
+
+// run query
+$subnet = $db->db_select($query);
+
+$smarty->assign("subnet_id", $subnet_id);
+$smarty->assign("subnet_address", $subnet[0]['subnet_address']);
+$smarty->assign("subnet_mask", $subnet[0]['subnet_mask']);
+
+// location
+$query = "SELECT
+ l.location_id,
+ l.location_name
+ FROM
+ subnetlocation AS s LEFT JOIN location USING (location_id)
+ WHERE
+ s.subnet_id=" . $subnet_id . "
+ ORDER BY
+ l.location_name";
+
+// run query
+$records = $db->db_select($query);
+$locations = array();
+foreach ($records as $rec) {
+ $locations[$rec['location_id']] = $rec['location_name'];
+}
+$smarty->assign("location_options", $locations);
+
+$smarty->display("subnetlocationdel.tpl");
+
+include("footer.php");
?>
diff --git a/subnetlocationedit.php b/subnetlocationedit.php
index b071711..ac6e75d 100644
--- a/subnetlocationedit.php
+++ b/subnetlocationedit.php
@@ -1,59 +1,34 @@
.
-
- For more information, visit http://sourceforge.net/projects/ipreg,
- or contact me at wietsew@users.sourceforge.net
- *****************************************************************************/
+/*****************************************************************************
+IP Reg, a PHP/MySQL IPAM tool
+Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
+Copyright (C) 2011-2023 Thomas Hooge
+
+SPDX-License-Identifier: GPL-3.0-or-later
+*****************************************************************************/
- // start page
- // includes
- include("includes.php");
+include("includes.php");
- // get ip and id
- $subnet_id = sanitize($_GET['subnet_id']);
+$subnet_id = sanitize($_GET['subnet_id']);
- // start output
- include("header.php");
-
- // set language variables
- $smarty->assign($lang);
+include("header.php");
- // setup subnet
- // build query
- $query = "SELECT
- subnet.subnet_address AS subnet_address,
- subnet.subnet_mask AS subnet_mask
- FROM
- subnet
- WHERE
- subnet.subnet_id=" . $subnet_id;
-
- // run query
- $subnet = $db->db_select($query);
-
- $smarty->assign("subnet_id", $subnet_id);
- $smarty->assign("subnet_address", $subnet[0]['subnet_address']);
- $smarty->assign("subnet_mask", $subnet[0]['subnet_mask']);
+$query = "SELECT
+ subnet_address,
+ subnet_mask
+ FROM
+ subnet
+ WHERE
+ subnet_id=" . $subnet_id;
+
+// run query
+$subnet = $db->db_select($query);
+
+$smarty->assign("subnet_id", $subnet_id);
+$smarty->assign("subnet_address", $subnet[0]['subnet_address']);
+$smarty->assign("subnet_mask", $subnet[0]['subnet_mask']);
- // end page
- // output
- $smarty->display("subnetlocationedit.tpl");
+$smarty->display("subnetlocationedit.tpl");
- // end output
- include("footer.php");
-?>
\ No newline at end of file
+include("footer.php");
+?>
diff --git a/subnetview.php b/subnetview.php
index 59ab994..75b8e71 100644
--- a/subnetview.php
+++ b/subnetview.php
@@ -1,432 +1,395 @@
assign("scripts",'changetext.js');
+include("header.php");
+
+// subnet
+$query = "SELECT
+ s.subnet_address,
+ s.subnet_mask,
+ s.subnet_dhcp_start,
+ s.subnet_dhcp_end,
+ s.subnet_info,
+ s.protocol_version,
+ s.ntp_server,
+ COUNT(node.subnet_id) AS node_counter
+ FROM
+ subnet AS s LEFT JOIN node USING (subnet_id)
+ WHERE
+ s.subnet_id=" . $subnet_id . "
+ GROUP BY
+ s.subnet_id";
+
+$subnet = $db->db_select($query);
+
+// set needed variables
+$subnet_address = $subnet[0]['subnet_address'];
+$subnet_mask = $subnet[0]['subnet_mask'];
+$subnet_dhcpstart = $subnet[0]['subnet_dhcp_start'];
+$subnet_dhcpend = $subnet[0]['subnet_dhcp_end'];
+$subnet_proto_vers = $subnet[0]['protocol_version'];
+$subnet_ntp_server = $subnet[0]['ntp_server'];
+
+// set counters
+$host_counter = pow(2,(32-$subnet_mask));
+$node_counter = $subnet[0]['node_counter'];
+$subnet_usedpercentage = round((($node_counter/($host_counter-2))*100), 1);
+
+$smarty->assign("subnet_id", $subnet_id);
+$smarty->assign("subnet_address", $subnet_address);
+$smarty->assign("subnet_mask", $subnet_mask);
+$smarty->assign("subnet_dhcpstart", $subnet_dhcpstart);
+$smarty->assign("subnet_dhcpend", $subnet_dhcpend);
+$smarty->assign("subnet_info", nl2br($subnet[0]['subnet_info']));
+$smarty->assign("subnet_proto_vers", $subnet_proto_vers);
+$smarty->assign("subnet_ntp_server", $subnet_ntp_server);
+$smarty->assign("node_counter", $node_counter);
+$smarty->assign("subnet_usedpercentage", $subnet_usedpercentage);
+$smarty->assign("config_color_unused", $config_color_unused);
+$smarty->assign("host_counter", $host_counter-2);
+$smarty->assign("free_counter", (($host_counter-2)-$node_counter));
+
+// subnet
+
+// split up the range
+$iprange = explode('.', $subnet_address);
+$iprange1 = $iprange[0];
+$iprange2 = $iprange[1];
+$iprange3 = $iprange[2];
+$iprange4 = $iprange[3];
+
+// create empty subnet-array
+$subnet = array();
+
+// determine range (Class A/B/C)
+if ($subnet_mask>=24) {
+ // Class C
+ // fill subnet-array with addresses we want to see
+ for($i=0;$i<$host_counter;$i++) {
+ // build ip
+ $ip = $iprange1 . '.' . $iprange2 . '.' . $iprange3 . '.' . ($iprange4+$i);
+
+ // fill subnet-array
+ $subnet[$ip] = array();
+ }
+
+ // calculate broadcast address
+ $broadcast_address = $iprange1 . '.' . $iprange2 . '.' . $iprange3 . '.' . ($iprange4+$i-1);
+
+ // to tpl
+ $smarty->assign("iprange1", $iprange1);
+ $smarty->assign("iprange2", $iprange2);
+ $smarty->assign("iprange3", $iprange3);
+ $smarty->assign("iprange4", $iprange4);
+ $smarty->assign("subnetmask1", 255);
+ $smarty->assign("subnetmask2", 255);
+ $smarty->assign("subnetmask3", 255);
+ $smarty->assign("subnetmask4", 256-$host_counter);
+
+ // no pagination needed
+ $smarty->assign("noselect", TRUE);
+ $smarty->assign("one_select", FALSE);
+ $smarty->assign("two_select", FALSE);
+
+ // set displayed nodes
+ $nodes_displayed = $host_counter;
+} else if ($subnet_mask>=16) {
+ // Class B
+ // which part do we want to see?
+ if((empty($page)) ? $page=$subnet_address : $page=$page);
+ $page = explode('.', $page);
+ $page2 = $page[2];
+
+ // fill subnet-array with addresses we want to see
+ for($i=0;$i<256;$i++) {
+ // build ip
+ $ip = $iprange1 . '.' . $iprange2 . '.' . $page2 . '.' . $i;
+
+ // fill subnet-array
+ $subnet[$ip] = array();
+ }
+
+ // calculate broadcast address
+ $broadcast_address = $iprange1 . '.' . $iprange2 . '.' . ($iprange3+$i-1) . '.255';
+
+ // to tpl
+ $smarty->assign("iprange1", $iprange1);
+ $smarty->assign("iprange2", $iprange2);
+
+ // loop addresses in range3
+ for($i=$iprange3;$i<(pow(2,(32-$subnet_mask))/256);$i++) {
+ // send to tpl
+ $smarty->assign("iprange3", $i);
+ $smarty->assign("iprange4", 0);
- You should have received a copy of the GNU General Public License
- along with this program. If not, see