From 76ccecca7fae6a361c26b8ec777637a53aa0be15 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Mon, 13 Feb 2023 10:42:09 +0100 Subject: [PATCH] Changes adopted from version 0.5 --- about.php | 47 +- asset.php | 127 +- assetadd.php | 85 +- assetclass.php | 91 +- assetclassadd.php | 86 +- assetclassdel.php | 69 +- assetclassedit.php | 110 +- assetclassgroup.php | 87 +- assetclassgroupadd.php | 38 +- assetclassgroupdel.php | 69 +- assetclassgroupedit.php | 72 +- assetclassgroupview.php | 122 +- assetclassview.php | 121 +- assetdel.php | 108 +- assetedit.php | 123 +- assetview.php | 138 +- assigniptoasset.php | 76 - assigniptonode.php | 69 +- assignlocationtosubnet.php | 65 - assignnodetoasset.php | 133 ++ assignvlantosubnet.php | 66 - comments.php | 6 +- config.php | 73 +- dbconnect.php | 5 +- footer.php | 20 +- header.php | 117 +- image.php | 112 +- images/add.gif | Bin 141 -> 0 bytes images/background.png | Bin 0 -> 230 bytes images/check.gif | Bin 138 -> 0 bytes images/comment.png | Bin 0 -> 413 bytes images/comments.gif | Bin 151 -> 0 bytes images/control_fastforward_blue.png | Bin 0 -> 736 bytes images/control_rewind_blue.png | Bin 0 -> 745 bytes images/del.gif | Bin 145 -> 0 bytes images/edit.gif | Bin 197 -> 0 bytes images/error.png | Bin 0 -> 666 bytes images/logo.png | Bin 0 -> 1186 bytes images/magnifier.png | Bin 0 -> 615 bytes images/next.gif | Bin 131 -> 0 bytes images/page_add.png | Bin 0 -> 739 bytes images/page_delete.png | Bin 0 -> 740 bytes images/page_edit.png | Bin 0 -> 807 bytes images/page_red.png | Bin 0 -> 641 bytes images/page_save.png | Bin 0 -> 774 bytes images/prev.gif | Bin 131 -> 0 bytes images/save.gif | Bin 242 -> 0 bytes images/search.gif | Bin 211 -> 0 bytes images/shield.ico | Bin 0 -> 1150 bytes images/shield.png | Bin 0 -> 702 bytes includes.php | 80 +- index.php | 117 +- install/install.sql | 142 -- install/install.txt | 24 +- install/mysql.sql | 143 ++ lang/en.php | 116 +- userpassedit.php => lib.php | 40 +- lib/changelink.js | 5 + lib/changetext.js | 3 + userclass.php => lib/db.class.php | 59 +- functions.php => lib/functions.php | 63 +- lib/user.class.php | 115 ++ yapter.php => lib/yapter.php | 0 location.php | 174 ++- locationadd.php | 147 +- locationdel.php | 66 +- locationedit.php | 190 ++- locationsubnetadd.php | 107 ++ locationsubnetdel.php | 102 ++ ...classauthadd.php => locationsubnetedit.php | 66 +- locationview.php | 276 ++-- login.php | 87 +- logout.php | 16 +- natadd.php | 111 ++ natdel.php | 105 ++ userclassdel.php => natedit.php | 65 +- node.php | 108 ++ nodeadd.php | 136 +- nodedel.php | 67 +- nodeedit.php | 186 ++- nodelist.php | 79 - nodeview.php | 190 ++- options.php | 35 +- optionseditdisplay.php | 111 ++ userclassadd.php => optionseditpassword.php | 38 +- search.php | 365 +++-- submit.php | 1305 ++++++++++++----- subnet.php | 92 +- subnetadd.php | 41 +- subnetdel.php | 111 +- subnetedit.php | 85 +- subnetlocationadd.php | 108 ++ subnetlocationdel.php | 102 ++ subnetlocationedit.php | 63 + subnetview.php | 642 +++++--- subnetvlanadd.php | 109 ++ subnetvlandel.php | 104 ++ subnetvlanedit.php | 63 + tpl/about.tpl | 125 +- tpl/asset.tpl | 44 +- tpl/assetadd.tpl | 74 +- tpl/assetclass.tpl | 33 +- tpl/assetclassadd.tpl | 52 +- tpl/assetclassdel.tpl | 28 +- tpl/assetclassedit.tpl | 59 +- tpl/assetclassgroup.tpl | 27 +- tpl/assetclassgroupadd.tpl | 31 +- tpl/assetclassgroupdel.tpl | 28 +- tpl/assetclassgroupedit.tpl | 36 +- tpl/assetclassgroupview.tpl | 69 +- tpl/assetclassview.tpl | 87 +- tpl/assetdel.tpl | 49 +- tpl/assetedit.tpl | 81 +- tpl/assetview.tpl | 125 +- tpl/assigniptoasset.tpl | 93 -- tpl/assigniptonode.tpl | 62 +- tpl/assignlocationtosubnet.tpl | 44 - tpl/assignnodetoasset.tpl | 127 ++ tpl/assignvlantosubnet.tpl | 43 - tpl/comments.tpl | 24 +- tpl/footer.tpl | 10 +- tpl/header.tpl | 61 +- tpl/index.tpl | 57 +- tpl/location.tpl | 25 +- tpl/locationadd.tpl | 68 +- tpl/locationdel.tpl | 25 +- tpl/locationedit.tpl | 70 +- tpl/locationsubnetadd.tpl | 63 + tpl/locationsubnetdel.tpl | 63 + tpl/locationsubnetedit.tpl | 60 + tpl/locationview.tpl | 101 +- tpl/login.tpl | 60 +- tpl/natadd.tpl | 75 + tpl/natdel.tpl | 63 + tpl/natedit.tpl | 58 + tpl/node.tpl | 35 + tpl/nodeadd.tpl | 156 +- tpl/nodedel.tpl | 27 +- tpl/nodeedit.tpl | 127 +- tpl/nodelist.tpl | 46 - tpl/nodeview.tpl | 131 +- tpl/options.tpl | 71 +- tpl/optionseditdisplay.tpl | 92 ++ tpl/optionseditpassword.tpl | 53 + tpl/search.tpl | 30 +- tpl/style.css | 155 +- tpl/subnet.tpl | 31 +- tpl/subnetadd.tpl | 68 +- tpl/subnetdel.tpl | 52 +- tpl/subnetedit.tpl | 53 +- tpl/subnetlocationadd.tpl | 63 + tpl/subnetlocationdel.tpl | 63 + tpl/subnetlocationedit.tpl | 60 + tpl/subnetview.tpl | 239 +-- tpl/subnetvlanadd.tpl | 63 + tpl/subnetvlandel.tpl | 63 + tpl/subnetvlanedit.tpl | 60 + tpl/user.tpl | 35 +- tpl/useradd.tpl | 43 +- tpl/userclass.tpl | 22 - tpl/userclassadd.tpl | 27 - tpl/userclassauth.tpl | 53 - tpl/userclassauthadd.tpl | 33 - tpl/userclassauthadditem.tpl | 42 - tpl/userclassauthaddsubitem.tpl | 63 - tpl/userclassdel.tpl | 28 - tpl/userclassedit.tpl | 48 - tpl/userclassview.tpl | 36 - tpl/userdel.tpl | 28 +- tpl/useredit.tpl | 62 +- tpl/userpassedit.tpl | 39 - tpl/userview.tpl | 62 +- tpl/vlan.tpl | 35 +- tpl/vlanadd.tpl | 36 +- tpl/vlandel.tpl | 25 +- tpl/vlanedit.tpl | 39 +- tpl/vlansubnetadd.tpl | 63 + tpl/vlansubnetdel.tpl | 63 + tpl/vlansubnetedit.tpl | 60 + tpl/vlanview.tpl | 79 +- user.php | 83 +- useradd.php | 44 +- userclassauth.php | 70 - userclassauthadditem.php | 60 - userclassauthaddsubitem.php | 70 - userclassedit.php | 62 - userclassview.php | 61 - userdel.php | 68 +- useredit.php | 81 +- userview.php | 81 +- vlan.php | 86 +- vlanadd.php | 40 +- vlandel.php | 71 +- vlanedit.php | 70 +- vlansubnetadd.php | 109 ++ vlansubnetdel.php | 104 ++ vlansubnetedit.php | 64 + vlanview.php | 122 +- 198 files changed, 10146 insertions(+), 4953 deletions(-) delete mode 100644 assigniptoasset.php delete mode 100644 assignlocationtosubnet.php create mode 100644 assignnodetoasset.php delete mode 100644 assignvlantosubnet.php delete mode 100644 images/add.gif create mode 100644 images/background.png delete mode 100644 images/check.gif create mode 100644 images/comment.png delete mode 100644 images/comments.gif create mode 100644 images/control_fastforward_blue.png create mode 100644 images/control_rewind_blue.png delete mode 100644 images/del.gif delete mode 100644 images/edit.gif create mode 100644 images/error.png create mode 100644 images/logo.png create mode 100644 images/magnifier.png delete mode 100644 images/next.gif create mode 100644 images/page_add.png create mode 100644 images/page_delete.png create mode 100644 images/page_edit.png create mode 100644 images/page_red.png create mode 100644 images/page_save.png delete mode 100644 images/prev.gif delete mode 100644 images/save.gif delete mode 100644 images/search.gif create mode 100644 images/shield.ico create mode 100644 images/shield.png delete mode 100644 install/install.sql create mode 100644 install/mysql.sql rename userpassedit.php => lib.php (69%) create mode 100644 lib/changelink.js create mode 100644 lib/changetext.js rename userclass.php => lib/db.class.php (53%) rename functions.php => lib/functions.php (51%) create mode 100644 lib/user.class.php rename yapter.php => lib/yapter.php (100%) create mode 100644 locationsubnetadd.php create mode 100644 locationsubnetdel.php rename userclassauthadd.php => locationsubnetedit.php (52%) create mode 100644 natadd.php create mode 100644 natdel.php rename userclassdel.php => natedit.php (54%) create mode 100644 node.php delete mode 100644 nodelist.php create mode 100644 optionseditdisplay.php rename userclassadd.php => optionseditpassword.php (68%) create mode 100644 subnetlocationadd.php create mode 100644 subnetlocationdel.php create mode 100644 subnetlocationedit.php create mode 100644 subnetvlanadd.php create mode 100644 subnetvlandel.php create mode 100644 subnetvlanedit.php delete mode 100644 tpl/assigniptoasset.tpl delete mode 100644 tpl/assignlocationtosubnet.tpl create mode 100644 tpl/assignnodetoasset.tpl delete mode 100644 tpl/assignvlantosubnet.tpl create mode 100644 tpl/locationsubnetadd.tpl create mode 100644 tpl/locationsubnetdel.tpl create mode 100644 tpl/locationsubnetedit.tpl create mode 100644 tpl/natadd.tpl create mode 100644 tpl/natdel.tpl create mode 100644 tpl/natedit.tpl create mode 100644 tpl/node.tpl delete mode 100644 tpl/nodelist.tpl create mode 100644 tpl/optionseditdisplay.tpl create mode 100644 tpl/optionseditpassword.tpl create mode 100644 tpl/subnetlocationadd.tpl create mode 100644 tpl/subnetlocationdel.tpl create mode 100644 tpl/subnetlocationedit.tpl create mode 100644 tpl/subnetvlanadd.tpl create mode 100644 tpl/subnetvlandel.tpl create mode 100644 tpl/subnetvlanedit.tpl delete mode 100644 tpl/userclass.tpl delete mode 100644 tpl/userclassadd.tpl delete mode 100644 tpl/userclassauth.tpl delete mode 100644 tpl/userclassauthadd.tpl delete mode 100644 tpl/userclassauthadditem.tpl delete mode 100644 tpl/userclassauthaddsubitem.tpl delete mode 100644 tpl/userclassdel.tpl delete mode 100644 tpl/userclassedit.tpl delete mode 100644 tpl/userclassview.tpl delete mode 100644 tpl/userpassedit.tpl create mode 100644 tpl/vlansubnetadd.tpl create mode 100644 tpl/vlansubnetdel.tpl create mode 100644 tpl/vlansubnetedit.tpl delete mode 100644 userclassauth.php delete mode 100644 userclassauthadditem.php delete mode 100644 userclassauthaddsubitem.php delete mode 100644 userclassedit.php delete mode 100644 userclassview.php create mode 100644 vlansubnetadd.php create mode 100644 vlansubnetdel.php create mode 100644 vlansubnetedit.php diff --git a/about.php b/about.php index 304560a..918338a 100644 --- a/about.php +++ b/about.php @@ -1,7 +1,7 @@ setvars($lang); - - // set vars - $tp->set("config_version", $config_version); - - // output - $tp->parse(); - $tp->spit(); - - // end output - include("footer.php"); + // start page + // includes + include("includes.php"); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/about.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup page + // set vars + $tp->set("config_version", $config_version); + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/asset.php b/asset.php index 5778c80..6845b9c 100644 --- a/asset.php +++ b/asset.php @@ -1,7 +1,7 @@ setvars($lang); - // start output - include("header.php"); + // 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); + + // count results + $alphabet_counter = count($alphabet); - // set template - $tp = new Template("tpl/asset.tpl"); + // any letters? + if ($alphabet_counter>0) { + // get objects + foreach($alphabet AS $alphabet_letter) { + // to tpl + $tp->set("asset_letter", strtoupper($alphabet_letter['asset_letter'])); + + // parse every row + $tp->parse("letter_row"); + } + } + + // parse block + $tp->parse("letter_table"); - // set language variables - $tp->setvars($lang); + // 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 + asset.asset_id AS asset_id, + asset.asset_name AS asset_name, + assetclass.assetclass_id AS assetclass_id, + assetclass.assetclass_name AS assetclass_name + FROM + asset, + assetclass + WHERE + SUBSTRING(asset.asset_name,1,1) = '" . $asset_letter . "' + AND assetclass.assetclass_id=asset.assetclass_id + ORDER BY + asset.asset_name"; + + // run query + $assets = $db->db_select($query); + + // count results + $asset_counter = count($assets); + + // counter to tpl + $tp->set("asset_counter", $asset_counter); - // get asset info - $result = mysql_query("SELECT a.asset_id, a.asset_name, a.assetclass_id, ac.assetclass_name FROM asset a, assetclass ac WHERE ac.assetclass_id=a.assetclass_id ORDER BY a.asset_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("asset_id", $row->asset_id); - $tp->set("asset_name", $row->asset_name); - $tp->set("assetclass_id", $row->assetclass_id); - $tp->set("assetclass_name", $row->assetclass_name); - $tp->parse("assetrow"); - } - if (($i>0) ? $tp->parse("asset") : $tp->hide("asset")); + // any assets? + if ($asset_counter>0) { + // get objects + foreach($assets AS $asset) { + // send to tpl + $tp->set("asset_id", $asset['asset_id']); + $tp->set("asset_name", $asset['asset_name']); + + $tp->set("assetclass_id", $asset['assetclass_id']); + $tp->set("assetclass_name", $asset['assetclass_name']); + + // parse row + $tp->parse("asset_row"); + } + + // parse block + $tp->parse("asset_table"); + } else { + // hide block + $tp->hide("asset_table"); + } - // output - $tp->parse(); - $tp->spit(); + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/assetadd.php b/assetadd.php index 0f9318a..d9e3b1d 100644 --- a/assetadd.php +++ b/assetadd.php @@ -1,7 +1,7 @@ setvars($lang); - // get id - if((isset($_GET['assetclass_id'])) ? $assetclass_id = $_GET['assetclass_id'] : $assetclass_id = ""); + // setup assetclass + // build query + $query = "SELECT + assetclass.assetclass_id AS assetclass_id, + assetclass.assetclass_name AS assetclass_name + FROM + assetclass + ORDER BY + assetclass.assetclass_name"; + + // run query + $assetclasses = $db->db_select($query); + + foreach($assetclasses AS $assetclass) { + // send to tpl + $tp->set("assetclass_id", $assetclass['assetclass_id']); + $tp->set("assetclass_name", $assetclass['assetclass_name']); + + if($assetclass['assetclass_id']==$assetclass_id) { + $tp->set("assetclass_selected", "selected"); + } else { + $tp->set("assetclass_selected", ""); + } + + // parse block + $tp->parse("assetclass_row"); + } + + // parse block + $tp->parse("assetclass_table"); - // check authorisation - $auth = auth("asset", $config_auth_assetadd, 0); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/assetadd.tpl"); - - // set language variables - $tp->setvars($lang); - - // get assetclassgroup information - $result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->assetclass_id==$assetclass_id) ? $tp->set("assetclass_selected", "selected") : $tp->set("assetclass_selected", "")); - $tp->set("assetclass_id", $row->assetclass_id); - $tp->set("assetclass_name", $row->assetclass_name); - $tp->parse("assetclassrow"); - } - if (($i>0) ? $tp->parse("assetclass") : $tp->hide("assetclass")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/assetclass.php b/assetclass.php index f529765..795b204 100644 --- a/assetclass.php +++ b/assetclass.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetclass.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - // get assetclass info - $result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("assetclass_id", $row->assetclass_id); - $tp->set("assetclass_name", $row->assetclass_name); - $tp->parse("assetclassrow"); - } - if (($i>0) ? $tp->parse("assetclass") : $tp->hide("assetclass")); + // setup assetclass + // build query + $query = "SELECT + assetclass.assetclass_id AS assetclass_id, + assetclass.assetclass_name AS assetclass_name, + assetclassgroup.assetclassgroup_id AS assetclassgroup_id, + assetclassgroup.assetclassgroup_name AS assetclassgroup_name + FROM + assetclass, + assetclassgroup + WHERE + assetclassgroup.assetclassgroup_id=assetclass.assetclassgroup_id + ORDER BY + assetclass.assetclass_name"; + + // run query + $assetclasses = $db->db_select($query); + + // count results + $assetclass_counter = count($assetclasses); + + // counter to tpl + $tp->set("assetclass_counter", $assetclass_counter); + + // any assetclasses? + if ($assetclass_counter>0) { + // get objects + foreach($assetclasses AS $assetclass) { + // send to tpl + $tp->set("assetclass_id", $assetclass['assetclass_id']); + $tp->set("assetclass_name", $assetclass['assetclass_name']); + + $tp->set("assetclassgroup_id", $assetclass['assetclassgroup_id']); + $tp->set("assetclassgroup_name", $assetclass['assetclassgroup_name']); + + // parse row + $tp->parse("assetclass_row"); + } + + // parse block + $tp->parse("assetclass_table"); + } else { + // hide block + $tp->hide("assetclass_table"); + } - // output - $tp->parse(); - $tp->spit(); + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/assetclassadd.php b/assetclassadd.php index ee55068..48446b8 100644 --- a/assetclassadd.php +++ b/assetclassadd.php @@ -1,7 +1,7 @@ setvars($lang); - // get id - if((isset($_GET['assetclassgroup_id'])) ? $assetclassgroup_id = $_GET['assetclassgroup_id'] : $assetclassgroup_id = ""); + // setup assetclassgroup + // build query + $query = "SELECT + assetclassgroup.assetclassgroup_id AS assetclassgroup_id, + assetclassgroup.assetclassgroup_name AS assetclassgroup_name + FROM + assetclassgroup + ORDER BY + assetclassgroup.assetclassgroup_name"; + + // run query + $assetclassgroup = $db->db_select($query); + + // get objects + foreach($assetclassgroup AS $assetclassgroup) { + // send to tpl + $tp->set("assetclassgroup_id", $assetclassgroup['assetclassgroup_id']); + $tp->set("assetclassgroup_name", $assetclassgroup['assetclassgroup_name']); + + if($assetclassgroup['assetclassgroup_id']==$assetclassgroup_id) { + $tp->set("assetclassgroup_selected", "selected"); + } else { + $tp->set("assetclassgroup_selected", ""); + } + + // parse block + $tp->parse("assetclassgroup_row"); + } + + // parse block + $tp->parse("assetclassgroup_table"); - // check authorisation - $auth = auth("assetclass", $config_auth_assetclassadd, $assetclass_id); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/assetclassadd.tpl"); - - // set language variables - $tp->setvars($lang); - - // get assetclassgroup information - $result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name FROM assetclassgroup ORDER BY assetclassgroup_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->assetclassgroup_id==$assetclassgroup_id) ? $tp->set("assetclassgroup_selected", "selected") : $tp->set("assetclassgroup_selected", "")); - $tp->set("assetclassgroup_id", $row->assetclassgroup_id); - $tp->set("assetclassgroup_name", $row->assetclassgroup_name); - $tp->parse("assetclassgrouprow"); - } - if (($i>0) ? $tp->parse("assetclassgroup") : $tp->hide("assetclassgroup")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/assetclassdel.php b/assetclassdel.php index b2d9d1b..0894729 100644 --- a/assetclassdel.php +++ b/assetclassdel.php @@ -1,7 +1,7 @@ setvars($lang); - - // get assetclass info - $result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass WHERE assetclass_id='$assetclass_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("assetclass_id", $row->assetclass_id); - $tp->set("assetclass_name", $row->assetclass_name); - - // output - $tp->parse(); - $tp->spit(); + // start page + // includes + include("includes.php"); + + // get id + $assetclass_id = sanitize($_GET['assetclass_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetclassdel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup assetclass + // build query + $query = "SELECT + assetclass.assetclass_id AS assetclass_id, + assetclass.assetclass_name AS assetclass_name + FROM + assetclass + WHERE + assetclass.assetclass_id=" . $assetclass_id; + + // run query + $assetclass = $db->db_select($query); + + // send to tpl + $tp->set("assetclass_id", $assetclass[0]['assetclass_id']); + $tp->set("assetclass_name", $assetclass[0]['assetclass_name']); + + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/assetclassedit.php b/assetclassedit.php index e4659ed..34e4ed7 100644 --- a/assetclassedit.php +++ b/assetclassedit.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); - // get assetclass information - $result = mysql_query("SELECT assetclass_name, assetclassgroup_id FROM assetclass WHERE assetclass_id='$assetclass_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $assetclassgroup_id = $row->assetclassgroup_id; - $tp->set("assetclass_id", $assetclass_id); - $tp->set("assetclass_name", $row->assetclass_name); - $tp->set("assetclassgroup_id", $assetclassgroup_id); - - // get assetclassgroup information - $result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name FROM assetclassgroup ORDER BY assetclassgroup_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->assetclassgroup_id==$assetclassgroup_id) ? $tp->set("selected", "selected") : $tp->set("selected", "")); - $tp->set("assetclassgroup_id", $row->assetclassgroup_id); - $tp->set("assetclassgroup_name", $row->assetclassgroup_name); - $tp->parse("assetclassgrouprow"); - } - if (($i>0) ? $tp->parse("assetclassgroup") : $tp->hide("assetclassgroup")); + // get id + $assetclass_id = sanitize($_GET['assetclass_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetclassedit.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup assetclass + // build query + $query = "SELECT + assetclass.assetclass_id AS assetclass_id, + assetclass.assetclass_name AS assetclass_name, + assetclass.assetclassgroup_id AS assetclassgroup_id + FROM + assetclass + WHERE + assetclass.assetclass_id=" . $assetclass_id; + + // run query + $assetclass = $db->db_select($query); + + // send to tpl + $tp->set("assetclass_id", $assetclass[0]['assetclass_id']); + $tp->set("assetclass_name", $assetclass[0]['assetclass_name']); - // output - $tp->parse(); - $tp->spit(); + // setup assetclassgroup + // build query + $query = "SELECT + assetclassgroup.assetclassgroup_id AS assetclassgroup_id, + assetclassgroup.assetclassgroup_name AS assetclassgroup_name + FROM + assetclassgroup + ORDER BY + assetclassgroup.assetclassgroup_name"; + + // run query + $assetclassgroups = $db->db_select($query); + + // get objects + foreach($assetclassgroups AS $assetclassgroup) { + // send to tpl + $tp->set("assetclassgroup_id", $assetclassgroup['assetclassgroup_id']); + $tp->set("assetclassgroup_name", $assetclassgroup['assetclassgroup_name']); + + if($assetclassgroup['assetclassgroup_id']==$assetclass[0]['assetclassgroup_id']) { + $tp->set("assetclassgroup_selected", "selected"); + } else { + $tp->set("assetclassgroup_selected", ""); + } + + // parse block + $tp->parse("assetclassgroup_row"); + } + + // parse block + $tp->parse("assetclassgroup_table"); - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/assetclassgroup.php b/assetclassgroup.php index 9df6b8f..e0f35aa 100644 --- a/assetclassgroup.php +++ b/assetclassgroup.php @@ -1,7 +1,7 @@ setvars($lang); - - // get asset info - $result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name FROM assetclassgroup ORDER BY assetclassgroup_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("assetclassgroup_id", $row->assetclassgroup_id); - $tp->set("assetclassgroup_name", $row->assetclassgroup_name); - $tp->parse("assetclassgrouprow"); - } - if (($i>0) ? $tp->parse("assetclassgroup") : $tp->hide("assetclassgroup")); + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetclassgroup.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - // output - $tp->parse(); - $tp->spit(); + // setup assetclassgroup + // build query + $query = "SELECT + assetclassgroup.assetclassgroup_id AS assetclassgroup_id, + assetclassgroup.assetclassgroup_name AS assetclassgroup_name + FROM + assetclassgroup + ORDER BY + assetclassgroup.assetclassgroup_name"; + + // run query + $assetclassgroups = $db->db_select($query); + + // count results + $assetclassgroup_counter = count($assetclassgroups); + + // counter to tpl + $tp->set("assetclassgroup_counter", $assetclassgroup_counter); + + // any assetclassgroups? + if ($assetclassgroup_counter>0) { + // get objects + foreach($assetclassgroups AS $assetclassgroup) { + // send to tpl + $tp->set("assetclassgroup_id", $assetclassgroup['assetclassgroup_id']); + $tp->set("assetclassgroup_name", $assetclassgroup['assetclassgroup_name']); + + $tp->set("assetclassgroup_id", $assetclassgroup['assetclassgroup_id']); + $tp->set("assetclassgroup_name", $assetclassgroup['assetclassgroup_name']); + + // parse row + $tp->parse("assetclassgroup_row"); + } + + // parse block + $tp->parse("assetclassgroup_table"); + } else { + // hide block + $tp->hide("assetclassgroup_table"); + } - // end output - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/assetclassgroupadd.php b/assetclassgroupadd.php index 6aa986d..b2fdb2a 100644 --- a/assetclassgroupadd.php +++ b/assetclassgroupadd.php @@ -1,7 +1,7 @@ setvars($lang); - - // output - $tp->parse(); - $tp->spit(); + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetclassgroupadd.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/assetclassgroupdel.php b/assetclassgroupdel.php index 75c3b1b..961a008 100644 --- a/assetclassgroupdel.php +++ b/assetclassgroupdel.php @@ -1,7 +1,7 @@ setvars($lang); - - // get assetclass info - $result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name FROM assetclassgroup WHERE assetclassgroup_id='$assetclassgroup_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("assetclassgroup_id", $row->assetclassgroup_id); - $tp->set("assetclassgroup_name", $row->assetclassgroup_name); - - // output - $tp->parse(); - $tp->spit(); + // start page + // includes + include("includes.php"); + + // get id + $assetclassgroup_id = sanitize($_GET['assetclassgroup_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetclassgroupdel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup assetclassgroup + // build query + $query = "SELECT + assetclassgroup.assetclassgroup_id AS assetclassgroup_id, + assetclassgroup.assetclassgroup_name AS assetclassgroup_name + FROM + assetclassgroup + WHERE + assetclassgroup.assetclassgroup_id=" . $assetclassgroup_id; + + // run query + $assetclassgroup = $db->db_select($query); + + // send to tpl + $tp->set("assetclassgroup_id", $assetclassgroup[0]['assetclassgroup_id']); + $tp->set("assetclassgroup_name", $assetclassgroup[0]['assetclassgroup_name']); + + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/assetclassgroupedit.php b/assetclassgroupedit.php index 8f54a16..0307fc2 100644 --- a/assetclassgroupedit.php +++ b/assetclassgroupedit.php @@ -1,7 +1,7 @@ setvars($lang); - - // get assetclass information - $result = mysql_query("SELECT assetclassgroup_name, color FROM assetclassgroup WHERE assetclassgroup_id='$assetclassgroup_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("assetclassgroup_id", $assetclassgroup_id); - $tp->set("assetclassgroup_name", $row->assetclassgroup_name); - $tp->set("color", $row->color); - - // output - $tp->parse(); - $tp->spit(); + // start page + // includes + include("includes.php"); + + // get id + $assetclassgroup_id = sanitize($_GET['assetclassgroup_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetclassgroupedit.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($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 + $tp->set("assetclassgroup_id", $assetclassgroup[0]['assetclassgroup_id']); + $tp->set("assetclassgroup_name", $assetclassgroup[0]['assetclassgroup_name']); + $tp->set("assetclassgroup_color", $assetclassgroup[0]['assetclassgroup_color']); - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/assetclassgroupview.php b/assetclassgroupview.php index 1d76af6..e836406 100644 --- a/assetclassgroupview.php +++ b/assetclassgroupview.php @@ -1,7 +1,7 @@ setvars($lang); - - // get assetclassgroup info - $result = mysql_query("SELECT assetclassgroup_name, color FROM assetclassgroup WHERE assetclassgroup_id='$assetclassgroup_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("assetclassgroup_id", $assetclassgroup_id); - $tp->set("assetclassgroup_name", $row->assetclassgroup_name); - $tp->set("color", $row->color); - - $result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass WHERE assetclassgroup_id='$assetclassgroup_id' ORDER BY assetclass_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("assetclass_name", $row->assetclass_name); - $tp->set("assetclass_id", $row->assetclass_id); - $tp->parse("assetclassrow"); - } - if (($i>0) ? $tp->parse("assetclass") : $tp->hide("assetclass")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // start page + // includes + include("includes.php"); + + // get id + $assetclassgroup_id = sanitize($_GET['assetclassgroup_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetclassgroupview.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($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 + $tp->set("assetclassgroup_id", $assetclassgroup[0]['assetclassgroup_id']); + $tp->set("assetclassgroup_name", $assetclassgroup[0]['assetclassgroup_name']); + $tp->set("assetclassgroup_color", $assetclassgroup[0]['assetclassgroup_color']); + + // setup assetclass + // build query + $query = "SELECT + assetclass.assetclass_id AS assetclass_id, + assetclass.assetclass_name AS assetclass_name + FROM + assetclass + WHERE + assetclass.assetclassgroup_id=" . $assetclassgroup_id . " + ORDER BY + assetclass.assetclass_name"; + + // run query + $assetclasses = $db->db_select($query); + + // count results + $assetclass_counter = count($assetclasses); + + // counter to tpl + $tp->set("assetclass_counter", $assetclass_counter); + + // any assets? + if ($assetclass_counter>0) { + // get objects + foreach($assetclasses AS $assetclass) { + // send to tpl + $tp->set("assetclass_id", $assetclass['assetclass_id']); + $tp->set("assetclass_name", $assetclass['assetclass_name']); + + // parse row + $tp->parse("assetclass_row"); + } + + // parse block + $tp->parse("assetclass_table"); + } else { + // hide block + $tp->hide("assetclass_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/assetclassview.php b/assetclassview.php index ace8005..340e1b4 100644 --- a/assetclassview.php +++ b/assetclassview.php @@ -1,7 +1,7 @@ setvars($lang); - // set language variables - $tp->setvars($lang); + // setup assetclass + // build query + $query = "SELECT + assetclass.assetclass_id AS assetclass_id, + assetclass.assetclass_name AS assetclass_name, + assetclassgroup.assetclassgroup_id AS assetclassgroup_id, + assetclassgroup.assetclassgroup_name AS assetclassgroup_name + FROM + assetclass, + assetclassgroup + WHERE + assetclass.assetclass_id=" . $assetclass_id . " + AND assetclassgroup.assetclassgroup_id=assetclass.assetclassgroup_id"; + + // run query + $assetclass = $db->db_select($query); + + // send to tpl + $tp->set("assetclass_id", $assetclass[0]['assetclass_id']); + $tp->set("assetclass_name", $assetclass[0]['assetclass_name']); + $tp->set("assetclass_selected", ""); + + $tp->set("assetclassgroup_id", $assetclass[0]['assetclassgroup_id']); + $tp->set("assetclassgroup_name", $assetclass[0]['assetclassgroup_name']); - // get assetclassgroup info - $result = mysql_query("SELECT ac.assetclassgroup_id, ac.assetclass_name, acg.assetclassgroup_name FROM assetclass ac, assetclassgroup acg WHERE ac.assetclass_id='$assetclass_id' AND acg.assetclassgroup_id=ac.assetclassgroup_id") or die(mysql_error()); - $row = mysql_fetch_object($result); - $tp->set("assetclass_id", $assetclass_id); - $tp->set("assetclass_name", $row->assetclass_name); - $tp->set("assetclassgroup_id", $row->assetclassgroup_id); - $tp->set("assetclassgroup_name", $row->assetclassgroup_name); + // setup asset + // build query + $query = "SELECT + asset.asset_id AS asset_id, + asset.asset_name AS asset_name + FROM + asset + WHERE + asset.assetclass_id='" . $assetclass_id . "' + ORDER BY + asset.asset_name"; - // get assets for this assetclassgroup - $result = mysql_query("SELECT asset_id, asset_name FROM asset WHERE assetclass_id='$assetclass_id' ORDER BY asset_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("asset_id", $row->asset_id); - $tp->set("asset_name", $row->asset_name); - $tp->parse("assetrow"); - } - if (($i>0) ? $tp->parse("asset") : $tp->hide("asset")); + // run query + $assets = $db->db_select($query); - // output - $tp->parse(); - $tp->spit(); + // count results + $asset_counter = count($assets); + + // counter to tpl + $tp->set("asset_counter", $asset_counter); + + // any assets? + if ($asset_counter>0) { + // sort using "natural order" + // ksort($assets); + + // get objects + foreach($assets AS $asset) { + // send to tpl + $tp->set("asset_id", $asset['asset_id']); + $tp->set("asset_name", $asset['asset_name']); + + // parse row + $tp->parse("asset_row"); + } + + // parse block + $tp->parse("asset_table"); + } else { + // hide block + $tp->hide("asset_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/assetdel.php b/assetdel.php index 44a8da4..3847389 100644 --- a/assetdel.php +++ b/assetdel.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); + + // get id + $asset_id = sanitize($_GET['asset_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetdel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - // get asset info - $result = mysql_query("SELECT asset_name FROM asset WHERE asset_id='$asset_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("asset_id", $asset_id); - $tp->set("asset_name", $row->asset_name); + // setup asset + // build query + $query = "SELECT + asset.asset_name AS asset_name + FROM + asset + WHERE + asset.asset_id=" . $asset_id; + + // run query + $asset = $db->db_select($query); + + // send to tpl + $tp->set("asset_id", $asset_id); + $tp->set("asset_name", $asset[0]['asset_name']); - // get node info - $result = mysql_query("SELECT n.node_id, n.ip, n.mac, n.dns1, n.dns2, n.node_info, s.subnet_id, s.subnet_address, s.subnet_mask FROM node n, subnet s WHERE asset_id='$asset_id' AND s.subnet_id=n.subnet_id ORDER BY INET_ATON(n.ip)") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("node_id", $row->node_id); - $tp->set("ip", $row->ip); - $tp->parse("noderow"); - } - if (($i>0) ? $tp->parse("node") : $tp->hide("node")); + // setup node + // build query + $query = "SELECT + node.node_id AS node_id, + node.node_ip AS node_ip + FROM + node + WHERE + node.asset_id=" . $asset_id . " + ORDER BY + INET_ATON(node.node_ip)"; + + // run query + $nodes = $db->db_select($query); + + // count results + $node_counter = count($nodes); + + // any nodes? + if ($node_counter>0) { + // get objects + foreach($nodes AS $node) { + // set id + $tp->set("node_id", $node['node_id']); + $tp->set("node_ip", $node['node_ip']); + + // parse row + $tp->parse("node_row"); + } + + // parse block + $tp->parse("node_table"); + } else { + // hide block + $tp->hide("node_table"); + } - // output - $tp->parse(); - $tp->spit(); + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/assetedit.php b/assetedit.php index 0d54efc..aa5a141 100644 --- a/assetedit.php +++ b/assetedit.php @@ -1,7 +1,7 @@ setvars($lang); - // get id - $asset_id = $_GET['asset_id']; + // setup asset + // build query + $query = "SELECT + asset.asset_name AS asset_name, + asset.asset_hostname AS asset_hostname, + asset.asset_info AS asset_info, + asset.assetclass_id AS assetclass_id + FROM + asset + WHERE + asset.asset_id=" . $asset_id; + + // run query + $asset = $db->db_select($query); + + // send to tpl + $tp->set("asset_id", $asset_id); + $tp->set("asset_name", $asset[0]['asset_name']); + $tp->set("asset_hostname", $asset[0]['asset_hostname']); + $tp->set("asset_info", $asset[0]['asset_info']); - // check authorisation - $auth = auth("asset", $config_auth_assetedit, $asset_id); + // setup assetclass + // build query + $query = "SELECT + assetclass.assetclass_id AS assetclass_id, + assetclass.assetclass_name AS assetclass_name + FROM + assetclass + ORDER BY + assetclass.assetclass_name"; + + // run query + $assetclasses = $db->db_select($query); + + // count results + $assetclass_counter = count($assetclasses); + + // any nodes? + if ($assetclass_counter>0) { + // get objects + foreach($assetclasses AS $assetclass) { + // send to tpl + $tp->set("assetclass_id", $assetclass['assetclass_id']); + $tp->set("assetclass_name", $assetclass['assetclass_name']); + + // set select box + if($assetclass['assetclass_id']==$asset[0]['assetclass_id']) { + $tp->set("assetclass_selected", "selected"); + } else { + $tp->set("assetclass_selected", ""); + } + + // parse block + $tp->parse("assetclass_row"); + } + // parse block + $tp->parse("assetclass_table"); + } else { + // parse block + $tp->hide("assetclass_table"); + } - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/assetedit.tpl"); - - // set language variables - $tp->setvars($lang); - - // get asset information - $result = mysql_query("SELECT asset_name, hostname, assetclass_id, asset_info FROM asset WHERE asset_id='$asset_id'") or die(mysql_error()); - $row = mysql_fetch_object($result); - $assetclass_id = $row->assetclass_id; - $tp->set("asset_id", $asset_id); - $tp->set("asset_name", $row->asset_name); - $tp->set("hostname", $row->hostname); - $tp->set("asset_info", $row->asset_info); - - // get assetclass information - $result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->assetclass_id==$assetclass_id) ? $tp->set("selected", "selected") : $tp->set("selected", "")); - $tp->set("assetclass_id", $row->assetclass_id); - $tp->set("assetclass_name", $row->assetclass_name); - $tp->parse("assetclassrow"); - } - if (($i>0) ? $tp->parse("assetclass") : $tp->hide("assetclass")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/assetview.php b/assetview.php index 24cb793..5cf7d50 100644 --- a/assetview.php +++ b/assetview.php @@ -1,7 +1,7 @@ setvars($lang); + + // setup asset + // build query + $query = "SELECT + asset.asset_name AS asset_name, + asset.asset_hostname AS asset_hostname, + asset.asset_info AS asset_info, + assetclass.assetclass_id AS assetclass_id, + assetclass.assetclass_name AS assetclass_name + FROM + asset, + assetclass + WHERE + asset.asset_id=" . $asset_id . " + AND assetclass.assetclass_id=asset.assetclass_id"; + + // run query + $asset = $db->db_select($query); + + // send to tpl + $tp->set("asset_id", $asset_id); + $tp->set("asset_name", $asset[0]['asset_name']); + $tp->set("asset_hostname", $asset[0]['asset_hostname']); + $tp->set("asset_info", nl2br($asset[0]['asset_info'])); + + $tp->set("assetclass_id", $asset[0]['assetclass_id']); + $tp->set("assetclass_name", $asset[0]['assetclass_name']); - // get id - $asset_id = $_GET['asset_id']; + // setup node + // build query + $query = "SELECT + node.node_id AS node_id, + node.node_ip AS node_ip + FROM + node + WHERE + node.asset_id=" . $asset_id . " + ORDER BY + INET_ATON(node.node_ip)"; + + // run query + $nodes = $db->db_select($query); + + // count results + $node_counter = count($nodes); + + // counter to tpl + $tp->set("node_counter", $node_counter); + + // any nodes? + if ($node_counter>0) { + // get objects + foreach($nodes AS $node) { + // send to tpl + $tp->set("node_id", $node['node_id']); + $tp->set("node_ip", $node['node_ip']); + + // parse row + $tp->parse("node_row"); + } + + // parse block + $tp->parse("node_table"); + } else { + // hide block + $tp->hide("node_table"); + } - // check authorisation - auth("asset", $config_auth_assetview, $asset_id); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/assetview.tpl"); - - // set language variables - $tp->setvars($lang); - - // get asset info - $result = mysql_query("SELECT a.asset_name, a.hostname, a.asset_info, ac.assetclass_id, ac.assetclass_name FROM asset a, assetclass ac WHERE a.asset_id='$asset_id' AND ac.assetclass_id=a.assetclass_id") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("asset_id", $asset_id); - $tp->set("asset_name", $row->asset_name); - $tp->set("hostname", $row->hostname); - $tp->set("asset_info", nl2br($row->asset_info)); - $tp->set("assetclass_id", $row->assetclass_id); - $tp->set("assetclass_name", $row->assetclass_name); - - // get node info - $result = mysql_query("SELECT n.node_id, n.ip, n.mac, n.dns1, n.dns2, n.node_info, s.subnet_id, s.subnet_address, s.subnet_mask FROM node n, subnet s WHERE asset_id='$asset_id' AND s.subnet_id=n.subnet_id ORDER BY INET_ATON(n.ip)") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("node_id", $row->node_id); - $tp->set("ip", $row->ip); - $tp->set("mac", write_mac($row->mac)); - $tp->set("dns1", $row->dns1); - $tp->set("dns2", $row->dns2); - $tp->set("node_info", nl2br($row->node_info)); - $tp->set("subnet_id", $row->subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); - $tp->set("nodecount", $i+1); - $tp->parse("noderow"); - } - if (($i>0) ? $tp->parse("node") : $tp->hide("node")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/assigniptoasset.php b/assigniptoasset.php deleted file mode 100644 index 157f3df..0000000 --- a/assigniptoasset.php +++ /dev/null @@ -1,76 +0,0 @@ -. - - For more information, visit http://sourceforge.net/projects/ipreg, - or contact me at wietsew@users.sourceforge.net - *****************************************************************************/ - - // includes - include("includes.php"); - - // get asset_id, ip or subnet_id - if((isset($_GET['asset_id'])) ? $asset_id = $_GET['asset_id'] : $asset_id = ""); - if((isset($_GET['ip'])) ? $ip = $_GET['ip'] : $ip = ""); - if((isset($_GET['subnet_id'])) ? $subnet_id = $_GET['subnet_id'] : $subnet_id = ""); - - // check authorisation - $auth = auth("assigniptoasset", $config_auth_assigniptoasset, 0); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/assigniptoasset.tpl"); - - // set language variables - $tp->setvars($lang); - - // set variables - $tp->set("asset_id", $asset_id); - $tp->set("ip", $ip); - $tp->set("subnet_id", $subnet_id); - $tp->set("config_dns1suffix", $config_dns1suffix); - $tp->set("config_dns2suffix", $config_dns2suffix); - - // get asset info - $result = mysql_query("SELECT asset_id, asset_name FROM asset ORDER BY asset_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->asset_id==$asset_id) ? $tp->set("asset_selected", "selected") : $tp->set("asset_selected", "")); - $tp->set("asset_id", $row->asset_id); - $tp->set("asset_name", $row->asset_name); - $tp->parse("assetrow"); - } - if (($i>0) ? $tp->parse("asset") : $tp->hide("asset")); - - // get subnet info - $result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->subnet_id==$subnet_id) ? $tp->set("subnet_selected", "selected") : $tp->set("subnet_selected", "")); - $tp->set("subnet_id", $row->subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); - $tp->parse("subnetrow"); - } - if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); -?> \ No newline at end of file diff --git a/assigniptonode.php b/assigniptonode.php index 9c3b9d7..1230e5b 100644 --- a/assigniptonode.php +++ b/assigniptonode.php @@ -1,7 +1,7 @@ setvars($lang); - - // set variables - $tp->set("ip", $ip); - $tp->set("subnet_id", $subnet_id); + // 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 template + $tp = new Template("tpl/assigniptonode.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - // get subnet info - $result = mysql_query("SELECT subnet_address, subnet_mask FROM subnet WHERE subnet_id='$subnet_id'") or die(mysql_error()); - $row = mysql_fetch_object($result); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); + // build query + $query = "SELECT + subnet.subnet_address AS subnet_address, + subnet.subnet_mask AS subnet_mask + FROM + subnet + WHERE + subnet.subnet_id=" . $subnet_id; - // output - $tp->parse(); - $tp->spit(); + // run query + $subnet = $db->db_select($query); + + // send to tpl + $tp->set("subnet_id", $subnet_id); + $tp->set("subnet_address", $subnet[0]['subnet_address']); + $tp->set("subnet_mask", $subnet[0]['subnet_mask']); + $tp->set("node_ip", $node_ip); + + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/assignlocationtosubnet.php b/assignlocationtosubnet.php deleted file mode 100644 index 3a7fefd..0000000 --- a/assignlocationtosubnet.php +++ /dev/null @@ -1,65 +0,0 @@ -. - - 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"); - - // get id - if((isset($_GET['location_id'])) ? $location_id = $_GET['location_id'] : $location_id = ""); - if((isset($_GET['subnet_id'])) ? $subnet_id = $_GET['subnet_id'] : $subnet_id = ""); - - // set template - $tp = new Template("tpl/assignlocationtosubnet.tpl"); - - // set language variables - $tp->setvars($lang); - - // get location info - $result = mysql_query("SELECT location_id, location_name FROM location ORDER BY location_name"); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->location_id==$location_id) ? $tp->set("selected", "selected") : $tp->set("selected", "")); - $tp->set("location_id", $row->location_id); - $tp->set("location_name", $row->location_name); - $tp->parse("locationrow"); - } - if (($i>0) ? $tp->parse("location") : $tp->hide("location")); - - // get subnet info - $result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->subnet_id==$subnet_id) ? $tp->set("selected", "selected") : $tp->set("selected", "")); - $tp->set("subnet_id", $row->subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); - $tp->parse("subnetrow"); - } - if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); -?> \ No newline at end of file diff --git a/assignnodetoasset.php b/assignnodetoasset.php new file mode 100644 index 0000000..b426fe8 --- /dev/null +++ b/assignnodetoasset.php @@ -0,0 +1,133 @@ +. + + 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 template + $tp = new Template("tpl/assignnodetoasset.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // to tpl + $tp->set("node_ip", $node_ip); + + // setup asset + // build query + $query = "SELECT + asset.asset_id AS asset_id, + asset.asset_name AS asset_name + FROM + asset + ORDER BY + asset.asset_name"; + + // run query + $assets = $db->db_select($query); + + // count results + $asset_counter = count($assets); + + // any assets? + if ($asset_counter>0) { + // get objects + foreach($assets AS $asset) { + // send to tpl + $tp->set("asset_id", $asset['asset_id']); + $tp->set("asset_name", $asset['asset_name']); + + if($asset['asset_id']==$asset_id) { + $tp->set("asset_selected", "selected"); + } else { + $tp->set("asset_selected", ""); + } + + // parse block + $tp->parse("asset_row"); + } + // parse block + $tp->parse("asset_table"); + } else { + // parse block + $tp->hide("asset_table"); + } + + // 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 + subnet + ORDER BY + INET_ATON(subnet.subnet_address)"; + + // run query + $subnets = $db->db_select($query); + + // count results + $subnet_counter = count($subnets); + + // any subnets? + if ($subnet_counter>0) { + // get objects + foreach($subnets AS $subnet) { + // send to tpl + $tp->set("subnet_id", $subnet['subnet_id']); + $tp->set("subnet_address", $subnet['subnet_address']); + $tp->set("subnet_mask", $subnet['subnet_mask']); + + if($subnet['subnet_id']==$subnet_id) { + $tp->set("subnet_selected", "selected"); + } else { + $tp->set("subnet_selected", ""); + } + + // parse block + $tp->parse("subnet_row"); + } + // parse block + $tp->parse("subnet_table"); + } else { + // parse block + $tp->hide("subnet_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/assignvlantosubnet.php b/assignvlantosubnet.php deleted file mode 100644 index 0ed0650..0000000 --- a/assignvlantosubnet.php +++ /dev/null @@ -1,66 +0,0 @@ -. - - 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 template - $tp = new Template("tpl/assignvlantosubnet.tpl"); - - // set language variables - $tp->setvars($lang); - - // get id - if((isset($_GET['vlan_id'])) ? $vlan_id = $_GET['vlan_id'] : $vlan_id = ""); - if((isset($_GET['subnet_id'])) ? $subnet_id = $_GET['subnet_id'] : $subnet_id = ""); - - // get vlan info - $result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan ORDER BY vlan_number") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->vlan_id==$vlan_id) ? $tp->set("selected", "selected") : $tp->set("selected", "")); - $tp->set("vlan_id", $row->vlan_id); - $tp->set("vlan_name", $row->vlan_name); - $tp->set("vlan_number", $row->vlan_number); - $tp->parse("vlanrow"); - } - if (($i>0) ? $tp->parse("vlan") : $tp->hide("vlan")); - - // get subnet info - $result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->subnet_id==$subnet_id) ? $tp->set("selected", "selected") : $tp->set("selected", "")); - $tp->set("subnet_id", $row->subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); - $tp->parse("subnetrow"); - } - if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); -?> \ No newline at end of file diff --git a/comments.php b/comments.php index 8107c3a..97e523b 100644 --- a/comments.php +++ b/comments.php @@ -1,7 +1,7 @@ setvars($lang); // get error - $comments = $_GET['comments']; + $comments = sanitize($_GET['comments']); // set veriables $tp->set("comments", $lang['lang_comments_' . $comments]); diff --git a/config.php b/config.php index 4c32a17..5f23a2f 100644 --- a/config.php +++ b/config.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/dbconnect.php b/dbconnect.php index 4452c46..55ccaaa 100644 --- a/dbconnect.php +++ b/dbconnect.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/footer.php b/footer.php index 82dc529..bde3c8e 100644 --- a/footer.php +++ b/footer.php @@ -1,7 +1,7 @@ set("config_version", $config_version); + // start page + // set template + $tp = new Template("tpl/footer.tpl", $config_yapter_error); + + // get version for the footer-stamp + $tp->set("config_version", $config_version); - // output - $tp->parse(); - $tp->spit(); + // end page + // output + $tp->parse(); + $tp->spit(); ?> \ No newline at end of file diff --git a/header.php b/header.php index b8f72e8..0bc67a3 100644 --- a/header.php +++ b/header.php @@ -1,7 +1,7 @@ setvars($lang); - - // set search box - if (isset($_POST['search'])) { - $search = $_POST['search']; - $_SESSION['search'] = $search; - } else { - if(isset($_SESSION['search'])) { - $search = $_SESSION['search']; - } else { - $search = ''; - } - } - - // set global template vars - $tp->set("config_version", $config_version); - $tp->set("search", $search); - - // output - $tp->parse(); - $tp->spit(); + // set template + $tp = new Template("tpl/header.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($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 + $tp->set("config_version", $config_version); + $tp->set("suser_name", $_SESSION['suser_displayname']); + $tp->set("search", $search); + + // menu + // assets + if($_SESSION['suser_menu_assets']=='on') { + $tp->parse("menu_assets"); + } else { + $tp->hide("menu_assets"); + } + // assetclasses + if($_SESSION['suser_menu_assetclasses']=='on') { + $tp->parse("menu_assetclasses"); + } else { + $tp->hide("menu_assetclasses"); + } + // assetclassgroups + if($_SESSION['suser_menu_assetclassgroups']=='on') { + $tp->parse("menu_assetclassgroups"); + } else { + $tp->hide("menu_assetclassgroups"); + } + // locations + if($_SESSION['suser_menu_locations']=='on') { + $tp->parse("menu_locations"); + } else { + $tp->hide("menu_locations"); + } + // nodes + if($_SESSION['suser_menu_nodes']=='on') { + $tp->parse("menu_nodes"); + } else { + $tp->hide("menu_nodes"); + } + // subnets + if($_SESSION['suser_menu_subnets']=='on') { + $tp->parse("menu_subnets"); + } else { + $tp->hide("menu_subnets"); + } + // users + if($_SESSION['suser_menu_users']=='on') { + $tp->parse("menu_users"); + } else { + $tp->hide("menu_users"); + } + // vlans + if($_SESSION['suser_menu_vlans']=='on') { + $tp->parse("menu_vlans"); + } else { + $tp->hide("menu_vlans"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); ?> \ No newline at end of file diff --git a/image.php b/image.php index c601429..e3d3039 100644 --- a/image.php +++ b/image.php @@ -1,16 +1,106 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + // start page + // includes + include("includes.php"); + + // 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 ("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); + } + + // 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 diff --git a/images/add.gif b/images/add.gif deleted file mode 100644 index 3d9e239b55c518573ee80e39cccf4ea33640d01f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 141 zcmZ?wbhEHb6krfw*v!K)XGhA8PeoV1EkE?D`sBMAC;m5XdYilUW%}ZWaVwrCAN^am z_gmTj|Nj|aK=CIFBLf2ugAPalWCjC^)r6CttM^tgP0-X}y>8gBs6*C(XT{ds)1S7b nB;2py=Gc=UVau3XW^u--!KJB;Q9-~*yiuSu)IGw7g~1vC+mANV diff --git a/images/background.png b/images/background.png new file mode 100644 index 0000000000000000000000000000000000000000..fb4fde72c0e5fac9b9503d3e92d28262834d2c4b GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^j6fvD!3Jb4-}qM!NUlb%6A^8LW000jFEC2ui01yBW000Cx@X1N5y*O(Mz?Ohvcp5Ma s4T%AY;;2&xA_xP6g3#s54JLtLAmNK02!unCQz$GevX691l|%plJI1I!q5uE@ diff --git a/images/comment.png b/images/comment.png new file mode 100644 index 0000000000000000000000000000000000000000..7bc9233ea63c89d52a99494dd0f0735a29a3ec3b GIT binary patch literal 413 zcmV;O0b>4%P)i2vikyMR~)n*keF9=!Gc_n*K2@qsNT?}H4v4a974 z1ArVJApZ0B-@pGKzWw|E^3%Wn&p!V9|K$C@{}12&`+x7vzyG&i{r!LE6~yrB1;;^# zm?0Y=moxPMSn>r>N00000NkvXX Hu0mjf$^yWL literal 0 HcmV?d00001 diff --git a/images/comments.gif b/images/comments.gif deleted file mode 100644 index 93a2f715aacef19d84470a94f9ededf550e9f0c3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 151 zcmV;I0BHY5Nk%w1VGsZi0J9DNl)Ba4_5IuL`Jc?`qSNi9*zupv>!sN7+U@w+>-O2} z_uTUP-SqsY-u3_g{{R30A^8LW000gEEC2ui01yBW000C;(8)=wy%*@sD+pjH0u&$= zXo?Et1SCT&$4M&zilOhiVmkl?VMrVzekOrZaA+!jK+dAE&|q#12GsJgUR~d?c>Ik3 F06R@_M_T{@ diff --git a/images/control_fastforward_blue.png b/images/control_fastforward_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..4a2f9d4e4a81857f509d85bbe46936c99709cd6f GIT binary patch literal 736 zcmV<60w4W}P)_TF$F*h9sL-j zNpc$weSXQZ6Gag%5kOy9HfA1@g zVA*&|VjFHeVhIV!`DzQM7F-a@NRTNvNlYYp4z%6NAQuJno^MeOJ!7dzy8e(=;etr6 z4q2h83Vb36o=G4!6u79$u)6u4LoN!;_)kItHmh9g5CP1HxVh+sSiS*Mlqx_uVfwL~ z+}p|}Y*;r1{g* z9DE4_W&SW~qUN5hWN@-RUJ#q3Ngxr&iJp;+4aEd;HM{A>I)B?7>yL4`Nc6h^we^ve z3YC6fwXTqAQWr8=Cd?emR={YnNptkhuSFVP{Q?6Lt^ zqF4A?)Arx1JpP&Pyh<4sUhXnam)AJ@xmkE-VuVGbg_|=vm|INb-=FD!zVlDxJ_uiv SXLQ>D0000yhD literal 0 HcmV?d00001 diff --git a/images/control_rewind_blue.png b/images/control_rewind_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..15d1584bdbb2c26a9fc4c8269aa54615a58a4657 GIT binary patch literal 745 zcmV1hlor z)=Ec^h7>5J3?Bj(D6|X+0|UcQj&m*_Qg!D|-c07sd7pF6opXl(U}#WhWg0W$d_xV%ATb~UcS*dC+@kfS*m{?64KBH-eM78JQAu#&2c z7TM!?0X98;&a@msh@1ehFDx4~_smCS0rm@Z$dv@5Y^ec>Jl}_`uDh5!i#cpZh5&_) z{y|~cgJzZ1d%`?CxkdJIg%by0u(~PqB0%Zdj?maMmYO=M!=;B#0>~5_5YO>&?w*4H z@LRbi!eNPrxg`gUUIeK8JG(3%R{o~|7so$K+8_qZe0Iz($pKd%d&oOhA&AGYXkKE` zO8~w=kN^smCS05H!-WT*2mpbXAJK6B{s*`+;U?8|s%XO8{Hs1d`DH6am$(L0coEX9 z)c+Ho)WS9-4?6~g4NrO@c2FaKCYmmR!DQ~YpfIn+s8pr^?KThtmU&}3Kr*7R^y^Rk z5Xsb_*=oc3w-9KI@B4=+yK6a8uQ@#oTkf1PnlL+NjAm=Zh)+xqld|idFEF=^(avw| z4U*w)Kx6;tnV0ZXQD@SHtHr7{`Y12 bpX>Y!%!CO%>C8GV00000NkvXXu0mjfJYGkQ literal 0 HcmV?d00001 diff --git a/images/del.gif b/images/del.gif deleted file mode 100644 index 2ca8b235239f18e02e2518d8258cf21ba3bc5e31..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 145 zcmZ?wbhEHb6krfw*v!kYBPHcWW#yl`x_2{Xyhuy?TwMIWvGH+2!rR>3&kGm+-MsnZ zoH@TYZ215GKLZ#j{$ycfVBlrY0r5a)FtFHdIO(~1uSGnA#{IU7rVbWWT?z%OimH4R u*v~{Wy2jlwf26#Jv%$ebrNi;S!wnB~rr8`wFqjl%zP>;0^xH5c25SJl%shVp diff --git a/images/edit.gif b/images/edit.gif deleted file mode 100644 index 137a6056795970ca9d2af3d3975f2d25bb029f7e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 197 zcmZ?wbhEHb6krfwI3mOlJ7w2~kg#35c0G9TpmNun;`LASm*4*uS<$oe>Fn!2XI}i) zzyDS7x+iyBgQuMM(7*3x{n0OVb#?#$|7Rc$DE?$&WMB|t&;cn2*~!4_v_PdVC39Ye zB#Wk`4Et>+&kH7>IBj@7KT~BmtS*6D`8IT}``VT3 PsnoQk@@(E>CkAT(!V^VA diff --git a/images/error.png b/images/error.png new file mode 100644 index 0000000000000000000000000000000000000000..628cf2dae3d419ae220c8928ac71393b480745a3 GIT binary patch literal 666 zcmV;L0%iS)P)eOSYYtbpBV}~vsBnU!_?2tr-P=|^T zED%wc9ezHgW@NMb!^uT_|SvCpFLJylbx zY%bpaTGI8IYXMN$9w<3j9VkA~NYOKEQXsj?6a9_hcwfU$acAhJhB)zb_w@MVUEy@S zX&I>K-R!bhu3?(6bHWIg$HEl7{9g>>&l_qdd+UYb(1~BCo9LptNq&8>!yoJ3Ui(i5 zRJ|XnYBklL!{@$-7=3mJ>P@1c=7Oc79e-V7yf+%lD2!I;Y&nXBZ>=B!5?CB>LvEx6 znI%n)qqi$#X#wKB(U7XP2P=+4{b@j#r%9-K(8UqtSDk>0UKzf*HM9yqMZ1D!$2MdZ zR=`U>0zhOH1XqN?nY@AQqB7)Fp4{v&dKXvb43hZKvnN8;Po;+jY*}~*Z|W9Q0W%{D z^T}Cc<|r(Su=1K=P5>Z4 zg`et&Va}tdzBS-G-ZcO)zCWpJvGQwrHZ`@wpM420ac@bI5~KkTFfGEM3sPWO8co4^fI6lPnA)Y{ef%@{+SnoUk0+dW+*{8WvF8}}l07*qoM6N<$g7cXs A&j0`b literal 0 HcmV?d00001 diff --git a/images/logo.png b/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..a115a1ae3e425428bab8c6b7773110f345c06fcf GIT binary patch literal 1186 zcmV;T1YP@yP)}BIR5|t?>_@juQ|iN|4Kl%JCL2g zA>|7aWBB%9Jp)i|^Z$SUwgc&7|Nj0v2Bf*)M3zV19dh{34s`UN_g5L1 z*hLvw1oRm=B%Bx+n0bJ*{}}%Ne$VjZll8%y9ZSI?+gwz&jN8e(9W}zcmyDT zSfGw$fO=*R5+Cj{CDFOUYRVfe=g@;EE9SwKf1o7ssZw;M_eK^=Ssh-U(^2{c(MK~v2v zXl$l|6axehG4)6XG}Kl>`4zAj`3DSfCQfB=tbmdb0~3&Dg2c-I{~$52j~V{{{0z)5 z|K6hoN(WLZs6a|Gu$Wkdl%I^z0uz*{_P_!a1ONhv7?13MIv#|Tfd;IG#K^x1pRO-t zVBxo5U}P0yU}RwgVqmgj`NhD*_8;sSZtWh1kGFR*{QUIhibnRmCrD<3%yNY}5}IUC zsw$*>1hX4200dSn4sy*1u5!6iLOun{uBLjZwJGddpj9eg`j(fB~LezV=gqg2_hG>Krtn#C+N2G0X@+8@7JF)-LhxjY0(sc#)=YpWeE^q0N)e*QQlCo+yDRo07*qoM6N<$f?>EH AtpET3 literal 0 HcmV?d00001 diff --git a/images/magnifier.png b/images/magnifier.png new file mode 100644 index 0000000000000000000000000000000000000000..cf3d97f75e9cde9c143980d89272fe61fc2d64ee GIT binary patch literal 615 zcmV-t0+{`YP)gNuvOO$0ks zMIj=HnnBRUR?tKXG11rxCU4&7dG4NbuvR2_mEvc)n?Cow;~Wve|KR^>9@p5l)|QB+ z$jmun3q#x>;ss-PW_mnr2MHVzLAl1RW&0?VkixF*4t!St0YVb2wnKdU(kmOHiL;aW zK8Xte%(k>MVGG$E4no6dcNnb>BhVHHGD&1pv4YZ68kE2V03t5#PCEFm7=ad$6)+3B zTCmn*?A?=u(o~ET7~-7g0)ZB=6|lumi4}B}MLgy~Ysy6)Q5%Al7|05&1z3Jpu>cF8 z3?VXs*3<}%h3`5Wld)N2zJnk%Agw<~3k)sPTLFd=F5;d8-bj-09SkQuynfflNcZLN z!^_37fdZvzrq=9~mp*($%mcDRKC&qvaaZuX+C=AT6O*~tHl>0mcP<_q>-z%$xO(@! zYluq5a8VQI$S@4?r*v;gPo!QQ%pX3A#>xx4t=w-L6COWx?aj&`f+!YePsFtj=hOQR zP3=E2j@9L7s8;T^&s?u(Hdpu?CubjMrGn{t_37>9$|AD)QE08weJlKn8|OyjL~7oP zC8mPT`jzuH*Dh^I0048RGafUIT)4H~*m8m>egI0iH=(LB%b@@O002ovPDHLkV1lw0 B3s diff --git a/images/page_add.png b/images/page_add.png new file mode 100644 index 0000000000000000000000000000000000000000..d5bfa0719bc3a2ce4fc529403f0acd6b6057c956 GIT binary patch literal 739 zcmV<90v!E`P)BG67=JY6c|L1R-#TR>fC$3^Y%QEnYO1xHsf)+GU`3F<{J0kR(;pbF3)zyg$H+idfnl-wl5Wkh!vUH z4Z32YP=l_}1rZd1W_D&^$A($A+&a0e&P?xx0!ctY2}*<#p+qPVN*B(YzvAWXa*%bzq z7Fz41LKILT(GWohi9|LgIzSZBhb*Zf6R6O}WYQ4GOi&71s9lmll0x6;8&ILOl$j(c z0Z1T(6Tg09{?wd{moFHNN6PS?$|e>1MxSJ(0Z7o2)J-Zv|>acY@f`(Y@g7GwsEj5NLQo+q|HsxQ5}XSX_d@*^A9ZT9=A{W~j+$GyI1 zc4oqTHx@1FlRjw4XWyPN5i2~l_F3@aBk!0yu^aoRDvXy}8@HCjUVQUsuSH4$T5|r< zzZOn^?Wfa6y|Q($Hx4{ws+)wX6-HP4zo!S?4KJ@7PG@G3G{CjXs(p*kIrj6rHs7_y z+=<-=Q62s9FuWa^X~WKgJIAAZJR&XBB002ovPDHLkV1jCMPILeO literal 0 HcmV?d00001 diff --git a/images/page_delete.png b/images/page_delete.png new file mode 100644 index 0000000000000000000000000000000000000000..3141467c678d2b53f79deb22086a9cb3a576a08d GIT binary patch literal 740 zcmVP z|1Ep}yDQG09bP~E^Dk?@JiKQJ z6-pO(3~IOP)IYisL6D6;oAEd;E%zR}{U$rMRNuD6nQV7nesKS>)yLo7JuDCrD>Abi zbj3uW23?^GA}9jQ{M^8v?ejL?HaT7AX5WPZNkBmfN`w-jL?{tT7ykZt$%Yln?p_m~ z-?>&d(LD(jAd}h=LPltPQbO$*Wbyl@G-_k5jXbb#qffHY03>M1jfEqoPJQ6Mr=Byp=^jfzePZV1 zLjCmNi31hdIJHa%e;5g=1(`u3BRzfeExY%=VCu{loOr{`%2hUR*x>tL^W_TTaj);0 zpPR6CUD1+0>4TQ6zVfH3TQ;%l6#(_%yspK@3gcmG#Q4!WCPyLU93nMKk7E2pcA=l45({2jNho>sdF*A~bA zxX?-cp~y_z_kFf+yqu3m#QiB}03?Z&9vvR5TNgj<)($Vm)xq5G>|o2sFMag&6aNF+ WAT1?sQBYt20000iHtsh1EzPArg^Q zIZrOk#rNsfjaSbMAL;<4h;Z=jvu8dzyz8N&Nb7=z03ZUw?9z%8KQEa6yM5=kUnka& z3?FJk2}L7q>na=T#;<7U*P91xfF`;`6%pVgWgRy0?1ZryL@%z52=-!fGXWGEn4M351L4<+7eDgwo|moqXT+s1&Kmn>-uQQ8mL7XY)w5Zk*(g+<3Y3tmkR!bL zOUKaUtj_pX26sH+=Iorwu}MGd`_%O-_sS}8VpG#fJA)Fcs#ezwtZf?q?Ac70mDv`rVs{$od?VPKeqf<-kUjNtS6ecB*mq<&M97K^6IVsDO zt2$Ru!b+>2S<}_H>$RcInusU_8PMNdf(W{sNlJ3FkrwMJPeBPO#d}Y^a{9TH(#{Y) l0D?dWAV4eUJX#h`!2gmISk&ZKd4B)^002ovPDHLkV1g&sd|Lnj literal 0 HcmV?d00001 diff --git a/images/page_red.png b/images/page_red.png new file mode 100644 index 0000000000000000000000000000000000000000..0b18247da5850f3c2486373a3e179acd2772e8aa GIT binary patch literal 641 zcmV-{0)G98P);68^@7JE5sw#jpE*579S@TLkU(6yap1yN*Zuy>-hV%Q_v4Ar&!63c8OBr(ZRhFu z_kWs36-AmgZCT>x!RqM;Zu9tqvoHI~k@UmYo_g(*J3c%2{N8}7I+|qKPQzv}7t>%W zsu&9G)UmCzkDYSw{fBnuW4j;1fKV_nicw`$8C6D=F_qu`zUiK$2Oc?5UVY+D(`I@R zW`KlwqLftWHH3Z2_XVNfKn>VgT~k=@- z+N>c>0|@A_HbI9Jn`v0~7cfIF(TS69zaomDS1QtgvaBBfGEPLHccO2~3jc>n^6}^HAEh-2#VxC7YYcDXv!L9X= z-R*SOUvIs;n`8(LxP4~^2|JsiN^hq6cU}5dn4v1~Kl{eT7pm&f$PoY`hyVe%y8G*S bxB&kH@RuR86sIAS00000NkvXXu0mjfZBi!% literal 0 HcmV?d00001 diff --git a/images/page_save.png b/images/page_save.png new file mode 100644 index 0000000000000000000000000000000000000000..caea546af549a0302848f4f478c5bd4aae15bc01 GIT binary patch literal 774 zcmV+h1Nr=kP)SV2@MRD}JQ4(c%G%=dG@_vxH?>gcH#*Ue2HC}9sapf8X?R$Z;XEnm&g zW99mh)5jNw008mK8)r^`_{yH0rNn%u1|SpC(tjf#om=+r#lh+?Kb>DVb9`|C0Bvbv zN3U(>f4-tAC1hosRoA7p(b(hL*V}(j>ug<`&U)|l$6o$)!>PBQ9RQSwn9asj2p*|xhU*R^vq?*Twb0t!lm5}`yW5lRy-U0ZYK?8to!;o!r!XeOE$ z0HB3T+6EEoI4PlR=wonwqJ+TvCoWh&$?CAPVYcU= zD{DS0?AkOtb@-hh^ZLq~FMjxYf19X?pa_YqtgZGvv2TaxcF#KT?O%=_*a-kW_;N|D zakkWsOe!)HsT5WRBiC+p;N-c>0Qwy(1D2MDBC595oXSiR07)sKNk-%9*rDBOO^HUD zZW#;)R&EZpqha<(HK$(tZYU#V29<@0qCXgU{gXeGpc_|pTqQD-WO|}%yKZbeX7k*H z2W~CK$v8NBAq~czrc5A(v51g0Wma7`G8}f=ZcuAiYYxZan@gP(;Ku66M6?bquGiHe z3Q0ya)%Lvk@kLixZfZyU@#UFbv+>pYhcj8TRKSr_sWG8i^X~UA**LvbD3(_Lba3xm ziYcpup*A9qJ$?AA=Og05lndxfwr`!C+O~h|B~4 z01q8H`StcY);%&mId7_+)76ovRpeNWRp&4M?#jx@|E-)x%P*A6t^fc407*qoM6N<$ Ef@ddc(f|Me literal 0 HcmV?d00001 diff --git a/images/prev.gif b/images/prev.gif deleted file mode 100644 index d54638214f2bf060a6cb525e529916e5c8ca5bc9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 131 zcmZ?wbhEHb6krfw*v!okJ7rhFj!)$WzHhnlt@hZT%nfgoR=(JA=jX;NUm8#UUw`S- z|Ns9PkbvS(7DfgJZU!BY7|09;7K4J5o~!p-WHWqW@qEt6a&WG=!kRS-K?elSlzcek b9LV#h;4sJG&dH1#b*@X&Pv%%DGgt!vh1E3m diff --git a/images/save.gif b/images/save.gif deleted file mode 100644 index fb050129db9871a5835291e8c955dd6b96e6578f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 242 zcmZ?wbhEHb6krfwI3mfA+`BTmcm29`>wf(B@%QiFLx&DcIQjka=g(ihd}(N(H0R{U zS;s#tx%hqU-MuWMIutQ0q(4WMWiUvxZ>`<2L~l$G{`P6C9a&4mc_qGMJPtVqj^= zP-^2~V42D3!Ehrd%!${9=RtwRrPPe`J?oeQvYBP>awi0>xUSyd9sZGa@BU0V_F={SKaU?j z{_*3-n>TMRKKpU~?Vnp8|6P3kUBsJXc1#% mWJzjh{=pDnuy6I0@oU-b#={`|>p=q)sm)(_p~^Vq<9CG;c&9 zUxk3uQMhCeSj)R&9IKhgiSLr*rErp5+=R>ZA~A z%}69JL7>4y+OufRh!-jot`4aY)}e%d%RE{shtpKw{RP8b%X$BgQy9~k@nlSgB+^I` z=}<;|G4a=iG>GU{A>_LPZR88BWI_F1QG>wxX|QzGbg>Spq>)DFucFx3N)zHJ{|h}T zgwq+?$#?dh1Rlksp3CTZt~}gD>TO zs8qPk#s@dawuU#$FurJB(io)vRnIJ9iu7c}TXU+LF`!pzL=V+8x?T#pXJIxzq*;zE zff})$3f${c;gwhmDRB$bdnFl5d6csn-0hSj@{<(VJO#YUS=ji{mN{58g1IukQ;o9A zCmUuOu-7}5%8}T3Brn7n`jlqD=)BlWH&Hc|e zl9RNi5P6h-UuU$!;l?I*V-3sY6pe8?p+YWa+=a`Db>(u}8@QZ^crGW#{*j&inF6Oq M2TQV@0H}5T1rS#WN&o-= literal 0 HcmV?d00001 diff --git a/images/shield.png b/images/shield.png new file mode 100644 index 0000000000000000000000000000000000000000..3cb4e257893adf230db7220c06fb9371360312e7 GIT binary patch literal 702 zcmV;v0zv(WP)CSS=grr57X34Zl(zd#$wMb&<%>`t-B(tkBb(psfna0f6_}Do~^xke$ZPQvRr946H zWWosxshhe2GGhTlX^H4l2T{)>lHM28PjBPv)052H^wfm_GUcM~_VUEV$3cdCKWX1R z!rT&^3rTv;k{#1R&D<>@Px1a?%-hNzH)w3T)o)siWm4p$YE@#8C&=cg43(z=rJn}gKmtpUPjP_< zhQXyc#h?f*t`d2Vd9yzWR3(s7PzH#A7!f0%A|E3em_y#OBXS^bn8gJ3v%wOOhaiEV zN+Bg6K!%U|v5J*O8kij|KR-n{eladP2^TtCnBu~OphnPUSs(4yA3V7-gl0O@~?V*x@CTl&E<2=tI5q@L#DQla@S41 zJh{xk+x)uL-5)Og@e9A})romiTU+;hxI5}I{Y{<6W=--* k<)9^%y{&t@hew login - if(empty($_SESSION['suser_id'])) { - header("Location: login.php"); - exit; - } + // session + // start session + session_start(); + + // check for user_id, if unnkown, redirect to login + if(empty($_SESSION['suser_id'])) { + // redirect + header("Location: login.php"); + exit; + } + + // headers + // raw http headers + header("Content-Type: text/html; charset=utf-8"); // includes - include("config.php"); - include("dbconnect.php"); - include("functions.php"); - include("yapter.php"); - - // auth items - $authitems = array( - 'ipreg' => array( - 'name' => 'IP Reg', - ), - 'asset' => array( - 'name' => 'Asset', - 'item_id' => 'asset_id', - 'item_name' => 'asset_name', - ), - 'assetclass' => array( - 'name' => 'Assetclass', - 'item_id' => 'assetclass_id', - 'item_name' => 'assetclass_name', - ), - 'location' => array( - 'name' => 'Location', - 'item_id' => 'location_id', - 'item_name' => 'location_name', - ), - 'node' => array( - 'name' => 'Node', - 'item_id' => 'node_id', - 'item_name' => 'ip', - ), - 'subnet' => array( - 'name' => 'Subnet', - 'item_id' => 'subnet_id', - 'item_name' => 'subnet_address', - ), - 'user' => array( - 'name' => 'User', - 'item_id' => 'user_id', - 'item_name' => 'user_name', - ), - 'userclass' => array( - 'name' => 'Userclass', - 'item_id' => 'userclass_id', - 'item_name' => 'userclass_name', - ), - 'vlan' => array( - 'name' => 'VLAN', - 'item_id' => 'vlan_id', - 'item_name' => 'vlan_name', - ), - ); + // includes + include("config.php"); + include("dbconnect.php"); + + // load lib + include("lib.php"); ?> \ No newline at end of file diff --git a/index.php b/index.php index 1249fab..a758ba4 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ setvars($lang); - // start output - include("header.php"); + // setup asset + // build query + $query = "SELECT + COUNT(asset.asset_id) AS asset_counter + FROM + asset"; + + // run query + $assets = $db->db_select($query); + + // counter to tpl + $tp->set("asset_counter", $assets[0]['asset_counter']); - // set template - $tp = new Template("tpl/index.tpl"); + // setup location + // build query + $query = "SELECT + COUNT(location.location_id) AS location_counter + FROM + location"; + + // run query + $locations = $db->db_select($query); + + // counter to tpl + $tp->set("location_counter", $locations[0]['location_counter']); - // set language variables - $tp->setvars($lang); + // setup node + // build query + $query = "SELECT + COUNT(node.node_id) AS node_counter + FROM + node"; + + // run query + $nodes = $db->db_select($query); + + // counter to tpl + $tp->set("node_counter", $nodes[0]['node_counter']); - // calculate assets - $query = mysql_query("SELECT asset_id FROM asset") or die(mysql_error()); - $assetcount = mysql_num_rows($query); - $tp->set('assetcount', $assetcount); + // setup subnet + // build query + $query = "SELECT + COUNT(subnet.subnet_id) AS subnet_counter + FROM + subnet"; + + // run query + $subnets = $db->db_select($query); + + // counter to tpl + $tp->set("subnet_counter", $subnets[0]['subnet_counter']); - // calculate locations - $query = mysql_query("SELECT location_id FROM location") or die(mysql_error()); - $locationcount = mysql_num_rows($query); - $tp->set('locationcount', $locationcount); + // setup vlan + // build query + $query = "SELECT + COUNT(vlan.vlan_id) AS vlan_counter + FROM + vlan"; + + // run query + $vlans = $db->db_select($query); + + // counter to tpl + $tp->set("vlan_counter", $vlans[0]['vlan_counter']); - // calculate nodes - $query = mysql_query("SELECT node_id FROM node") or die(mysql_error()); - $nodecount = mysql_num_rows($query); - $tp->set('nodecount', $nodecount); - - // calculate subnets - $query = mysql_query("SELECT subnet_id FROM subnet") or die(mysql_error()); - $subnetcount = mysql_num_rows($query); - $tp->set('subnetcount', $subnetcount); - - // calculate vlans - $query = mysql_query("SELECT vlan_id FROM vlan") or die(mysql_error()); - $vlancount = mysql_num_rows($query); - $tp->set('vlancount', $vlancount); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/install/install.sql b/install/install.sql deleted file mode 100644 index 760f43e..0000000 --- a/install/install.sql +++ /dev/null @@ -1,142 +0,0 @@ -SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; - -CREATE TABLE `asset` ( - `asset_id` int(10) NOT NULL auto_increment, - `asset_name` varchar(100) NOT NULL default '', - `hostname` varchar(100) NOT NULL default '', - `assetclass_id` int(10) NOT NULL default '0', - `asset_info` text NOT NULL, - PRIMARY KEY (`asset_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; - -INSERT INTO `asset` (`asset_id`, `asset_name`, `hostname`, `assetclass_id`, `asset_info`) VALUES -(1, 'TestPC', 'TestPC', 1, 'This is just a test PC'); - -CREATE TABLE `assetclass` ( - `assetclass_id` int(10) NOT NULL auto_increment, - `assetclassgroup_id` int(10) NOT NULL default '0', - `assetclass_name` varchar(100) NOT NULL default '', - PRIMARY KEY (`assetclass_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; - -INSERT INTO `assetclass` (`assetclass_id`, `assetclassgroup_id`, `assetclass_name`) VALUES -(1, 1, 'PC'), -(2, 2, 'Switch'); - -CREATE TABLE `assetclassgroup` ( - `assetclassgroup_id` int(10) NOT NULL auto_increment, - `assetclassgroup_name` varchar(100) NOT NULL default '', - `color` varchar(6) NOT NULL, - PRIMARY KEY (`assetclassgroup_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; - -INSERT INTO `assetclassgroup` (`assetclassgroup_id`, `assetclassgroup_name`, `color`) VALUES -(1, 'Workstations', '000000'), -(2, 'Network', 'FF0000'); - -CREATE TABLE `location` ( - `location_id` int(10) NOT NULL auto_increment, - `location_name` varchar(100) NOT NULL default '', - `parent` int(1) NOT NULL default '0', - `location_info` text NOT NULL, - PRIMARY KEY (`location_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; - -INSERT INTO `location` (`location_id`, `location_name`, `parent`, `location_info`) VALUES -(1, 'Main Office', 0, 'Our Main Office Building'); - -CREATE TABLE `node` ( - `node_id` int(10) NOT NULL auto_increment, - `ip` varchar(15) NOT NULL default '', - `mac` varchar(12) NOT NULL default '', - `dns1` varchar(100) NOT NULL default '', - `dns2` varchar(100) NOT NULL default '', - `subnet_id` int(10) NOT NULL default '0', - `asset_id` int(10) NOT NULL default '0', - `node_info` text NOT NULL, - PRIMARY KEY (`node_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; - -INSERT INTO `node` (`node_id`, `ip`, `mac`, `dns1`, `dns2`, `subnet_id`, `asset_id`, `node_info`) VALUES -(1, '192.168.0.1', '', '', '', 1, 1, ''); - -CREATE TABLE `subnet` ( - `subnet_id` int(10) NOT NULL auto_increment, - `subnet_address` varchar(15) NOT NULL default '', - `subnet_mask` int(2) NOT NULL default '0', - `vlan_id` int(10) NOT NULL default '0', - `subnet_info` text NOT NULL, - PRIMARY KEY (`subnet_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; - -INSERT INTO `subnet` (`subnet_id`, `subnet_address`, `subnet_mask`, `vlan_id`, `subnet_info`) VALUES -(1, '192.168.0.1', 24, 1, ''); - -CREATE TABLE `subnetlocation` ( - `subnetlocation_id` int(10) NOT NULL auto_increment, - `subnet_id` int(10) NOT NULL default '0', - `location_id` int(10) NOT NULL default '0', - PRIMARY KEY (`subnetlocation_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; - -INSERT INTO `subnetlocation` (`subnetlocation_id`, `subnet_id`, `location_id`) VALUES -(1, 1, 1); - -CREATE TABLE `user` ( - `user_id` int(10) NOT NULL auto_increment, - `user_name` varchar(100) NOT NULL default '', - `user_pass` varchar(32) NOT NULL default '', - `user_level` int(1) NOT NULL default '0', - `user_displayname` varchar(100) NOT NULL default '', - `user_mac` varchar(25) NOT NULL default 'xxxxxxxxxxxx', - `user_lang` varchar(3) NOT NULL default '', - PRIMARY KEY (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; - -INSERT INTO `user` (`user_id`, `user_name`, `user_pass`, `user_level`, `user_displayname`, `user_mac`, `user_lang`) VALUES -(1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 2, 'admin', 'xxxxxxxxxxxx', 'en'); - -CREATE TABLE `userclass` ( - `userclass_id` int(10) NOT NULL auto_increment, - `userclass_name` varchar(100) collate latin1_general_ci NOT NULL, - PRIMARY KEY (`userclass_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=2 ; - -INSERT INTO `userclass` (`userclass_id`, `userclass_name`) VALUES -(1, 'IP Reg Administrators'); - -CREATE TABLE `userclassauth` ( - `userclassauth_id` int(10) NOT NULL auto_increment, - `ordering` int(3) NOT NULL, - `userclass_id` int(10) NOT NULL, - `item` varchar(100) collate latin1_general_ci NOT NULL, - `id` int(10) NOT NULL, - `auth` int(1) NOT NULL, - PRIMARY KEY (`userclassauth_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=2 ; - - -INSERT INTO `userclassauth` (`userclassauth_id`, `ordering`, `userclass_id`, `item`, `id`, `auth`) VALUES -(1, 1, 1, 'ipreg', 0, 2); - -CREATE TABLE `useruserclass` ( - `useruserclass_id` int(10) NOT NULL auto_increment, - `user_id` int(10) NOT NULL, - `userclass_id` int(10) NOT NULL, - PRIMARY KEY (`useruserclass_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=2 ; - - -INSERT INTO `useruserclass` (`useruserclass_id`, `user_id`, `userclass_id`) VALUES -(1, 1, 1); - -CREATE TABLE `vlan` ( - `vlan_id` int(10) NOT NULL auto_increment, - `vlan_number` int(3) NOT NULL default '0', - `vlan_name` varchar(100) NOT NULL default '', - `vlan_info` text NOT NULL, - PRIMARY KEY (`vlan_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; - -INSERT INTO `vlan` (`vlan_id`, `vlan_number`, `vlan_name`, `vlan_info`) VALUES -(1, 1, 'VLAN', 'Default VLAN'); \ No newline at end of file diff --git a/install/install.txt b/install/install.txt index 1073ce1..a684c1f 100644 --- a/install/install.txt +++ b/install/install.txt @@ -1,18 +1,16 @@ ---- ---- IP Reg 0.4 ---- http://sourceforge.net/projects/ipreg ---- +IP Reg Installation -Installation instructions +1. Create database +Create a database for IP Reg on your web server, as well as a MySQL user who has all privileges for accessing and modifying it. -1) Create your MYSQL-database +2. Run import +Import the mysql.sql file into your database, which will create the tables and some sample data. -2) Use install.sql to create the tables and insert the first data +3. Edit config file +Open config.php in a text editor and fill in your database details. -3) Update config.php with your settings +4. Upload files +Upload all files and directory's (except the install directory) to your webserver. -4) Copy all files to your webserver (exclude install directory) - -5) Start your browser, log in with admin/admin - -6) Please report your comments at http://www.newtree.nl/ipreg \ No newline at end of file +5. Start using IP Reg +Start your browser and login to IP Reg with the default username/password: admin/admin \ No newline at end of file diff --git a/install/mysql.sql b/install/mysql.sql new file mode 100644 index 0000000..a3027dd --- /dev/null +++ b/install/mysql.sql @@ -0,0 +1,143 @@ +CREATE TABLE asset ( + asset_id int(10) NOT NULL auto_increment, + asset_name varchar(100) NOT NULL, + asset_hostname varchar(100) NOT NULL, + assetclass_id int(10) NOT NULL, + asset_info text NOT NULL, + PRIMARY KEY (asset_id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +INSERT INTO asset (asset_name, assetclass_id) VALUES +('My Computer', 1), +('My Server', 2); + + +CREATE TABLE assetclass ( + assetclass_id int(10) NOT NULL auto_increment, + assetclassgroup_id int(10) NOT NULL, + assetclass_name varchar(100) NOT NULL, + PRIMARY KEY (assetclass_id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +INSERT INTO assetclass (assetclassgroup_id, assetclass_name) VALUES +(1, 'PC'), +(2, 'Server'); + + +CREATE TABLE assetclassgroup ( + assetclassgroup_id int(10) NOT NULL auto_increment, + assetclassgroup_name varchar(100) NOT NULL, + assetclassgroup_color varchar(6) NOT NULL, + PRIMARY KEY (assetclassgroup_id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +INSERT INTO assetclassgroup (assetclassgroup_name, assetclassgroup_color) VALUES +('Workstations', 000000); + + +CREATE TABLE location ( + location_id int(10) NOT NULL auto_increment, + location_name varchar(100) NOT NULL, + location_parent int(1) NOT NULL default 0, + location_info text NOT NULL, + PRIMARY KEY (location_id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +INSERT INTO location (location_name, location_parent) VALUES +('Main Office', 0); + + +CREATE TABLE nat ( + nat_id int(10) NOT NULL auto_increment, + nat_type int(1) NOT NULL, + nat_ext int(10) NOT NULL, + nat_int int(10) NOT NULL, + PRIMARY KEY (nat_id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + + +CREATE TABLE node ( + node_id int(10) NOT NULL auto_increment, + node_ip varchar(15) NOT NULL, + node_mac varchar(12) NOT NULL, + node_dns1 varchar(100) NOT NULL, + node_dns2 varchar(100) NOT NULL, + subnet_id int(10) NOT NULL, + asset_id int(10) NOT NULL, + node_info text NOT NULL, + PRIMARY KEY (node_id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +INSERT INTO node (node_ip, node_mac, subnet_id, asset_id) VALUES +('192.168.1.2', '001122334455', 1, 1), +('192.168.1.1', 'aabbccddeeff', 1, 2); + + +CREATE TABLE subnet ( + subnet_id int(10) NOT NULL auto_increment, + subnet_address varchar(15) NOT NULL, + subnet_mask int(2) NOT NULL, + subnet_info text NOT NULL, + PRIMARY KEY (subnet_id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + + +INSERT INTO subnet (subnet_address, subnet_mask) VALUES +('192.168.0.0', 24); + + +CREATE TABLE subnetlocation ( + subnetlocation_id int(10) NOT NULL auto_increment, + subnet_id int(10) NOT NULL, + location_id int(10) NOT NULL, + PRIMARY KEY (subnetlocation_id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +INSERT INTO subnetlocation (subnet_id, location_id) VALUES +(1, 1); + + +CREATE TABLE subnetvlan ( + subnetvlan_id int(10) NOT NULL auto_increment, + subnet_id int(10) NOT NULL, + vlan_id int(10) NOT NULL, + PRIMARY KEY (subnetvlan_id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + + +CREATE TABLE user ( + user_id int(10) NOT NULL auto_increment, + user_name varchar(100) NOT NULL, + user_pass varchar(32) NOT NULL, + user_displayname varchar(100) NOT NULL, + user_imagesize int(3) NOT NULL default 6, + user_imagecount int(3) NOT NULL default 64, + user_mac varchar(25) NOT NULL default 'xxxxxxxxxxxx', + user_dateformat varchar(10) NOT NULL default 'd M Y H:i', + user_dns1suffix varchar(100) NOT NULL, + user_dns2suffix varchar(100) NOT NULL, + user_menu_assets varchar(2) NOT NULL default 'on', + user_menu_assetclasses varchar(2) NOT NULL default 'on', + user_menu_assetclassgroups varchar(2) NOT NULL default 'on', + user_menu_locations varchar(2) NOT NULL default 'on', + user_menu_nodes varchar(2) NOT NULL default 'on', + user_menu_subnets varchar(2) NOT NULL default 'on', + user_menu_users varchar(2) NOT NULL default 'on', + user_menu_vlans varchar(2) NOT NULL default 'on', + PRIMARY KEY (user_id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +INSERT INTO user (user_name, user_pass, user_displayname, user_imagesize, user_imagecount, user_mac, user_dateformat, user_menu_assets, user_menu_assetclasses, user_menu_assetclassgroups, user_menu_locations, user_menu_nodes, user_menu_subnets, user_menu_users, user_menu_vlans) VALUES +('admin', '21232f297a57a5a743894a0e4a801fc3', 'administrator', 6, 64, 'xxxxxxxxxxxx', 'd M Y H:i', 'on', 'on', 'on', 'on', 'on', 'on', 'on', 'on'); + + +CREATE TABLE vlan ( + vlan_id int(10) NOT NULL auto_increment, + vlan_number int(3) NOT NULL, + vlan_name varchar(100) NOT NULL, + vlan_info text NOT NULL, + PRIMARY KEY (vlan_id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +INSERT INTO vlan (vlan_number, vlan_name) VALUES +(1, 'DEFAULT_VLAN'); \ No newline at end of file diff --git a/lang/en.php b/lang/en.php index c0f6c33..b1c8d9f 100644 --- a/lang/en.php +++ b/lang/en.php @@ -1,6 +1,8 @@ 'IP Reg', + 'lang_asset' => 'Asset', 'lang_assets' => 'Assets', 'lang_assetclass' => 'Assetclass', @@ -9,12 +11,11 @@ $lang = array( 'lang_assetclassgroups' => 'Assetclassgroups', 'lang_location' => 'Location', 'lang_locations' => 'Locations', + 'lang_menu' => 'Menu', 'lang_node' => 'Node', 'lang_nodes' => 'Nodes', 'lang_user' => 'User', 'lang_users' => 'Users', - 'lang_userclass' => 'Userclass', - 'lang_userclasses' => 'Userclasses', 'lang_sublocation' => 'Sub-location', 'lang_sublocations' => 'Sub-locations', 'lang_subnet' => 'Subnet', @@ -27,45 +28,52 @@ $lang = array( 'lang_cancel' => 'Cancel', 'lang_color' => 'Color', 'lang_error' => 'Error', - 'lang_header_viewby' => 'View by', 'lang_item' => 'Item', 'lang_language' => 'Language', 'lang_login' => 'Login', 'lang_logout' => 'Logout', 'lang_options' => 'Options', 'lang_reset' => 'Reset', - 'lang_search' => 'Search!', + 'lang_search' => 'Search', 'lang_statistics' => 'Statistics', 'lang_subitem' => 'Sub-Item', 'lang_submit' => 'Submit', 'lang_unassigned' => 'Unassigned', - 'lang_userclassauth' => 'Authorization', + 'lang_warning' => 'Warning', 'lang_asset_add' => 'Add asset', 'lang_asset_del' => 'Delete asset', 'lang_asset_edit' => 'Modify asset', 'lang_asset_info' => 'Asset info', 'lang_asset_name' => 'Asset name', - 'lang_hostname' => 'Hostname', + 'lang_asset_hostname' => 'Hostname', 'lang_assetclass_add' => 'Add assetclass', 'lang_assetclass_del' => 'Delete assetclass', 'lang_assetclass_edit' => 'Mofidy assetclass', 'lang_assetclass_name' => 'Assetclass name', - 'lang_userclassauth_add' => 'Add authorization', - 'lang_userclassauth_del' => 'Delete authorization', - 'lang_userclassauth_edit' => 'Mofidy authorization', - 'lang_assetclassgroup_add' => 'Add assetclassgroup', 'lang_assetclassgroup_del' => 'Delete assetclassgroup', 'lang_assetclassgroup_edit' => 'Modify assetclassgroup', 'lang_assetclassgroup_name' => 'Assetclass Groupname', - 'lang_assigniptoasset' => 'Assign IP to asset', + 'lang_assignnodetoasset' => 'Assign node to asset', + 'lang_assignnodetoasset_existing' => 'Assign node to existing asset', + 'lang_assignnodetoasset_new' => 'Assign node to new asset', + 'lang_assigniptonode' => 'Assign IP to node', + 'lang_assigniptonode_existing' => 'Assign IP to existing node', + 'lang_assigniptonode_new' => 'Assign IP to new node', 'lang_assignlocationtosubnet' => 'Assign location to subnet', + 'lang_assignlocationtosubnet_existing' => 'Assign location to existing subnet', + 'lang_assignlocationtosubnet_new' => 'Assign location to new subnet', + 'lang_assignsubnettovlan' => 'Assign subnet to VLAN', + 'lang_assignsubnettovlan_existing' => 'Assign subnet to existing VLAN', + 'lang_assignsubnettovlan_new' => 'Assign subnet to new VLAN', 'lang_assignvlantosubnet' => 'Assign VLAN to subnet', - + 'lang_assignvlantosubnet_existing' => 'Assign VLAN to existing subnet', + 'lang_assignvlantosubnet_new' => 'Assign VLAN to new subnet', + 'lang_location_add' => 'Add location', 'lang_location_del' => 'Delete location', 'lang_location_edit' => 'Mofidy location', @@ -74,51 +82,66 @@ $lang = array( 'lang_location_parent' => 'Parent', 'lang_sublocation_add' => 'Add Sub-location', + 'lang_locationsubnet' => 'Location/Subnet', + 'lang_locationsubnet_edit' => 'Edit Location/Subnet', + 'lang_node_add' => 'Add node', 'lang_node_del' => 'Delete node', 'lang_node_edit' => 'Modify node', 'lang_node_info' => 'Node info', - 'lang_node_new' => 'Create new node', 'lang_dns1' => 'DNS name', 'lang_dns2' => 'DNS Alias', 'lang_ip' => 'IP Address', 'lang_mac' => 'MAC Address', - 'lang_search_found' => 'found', + 'lang_nat' => 'NAT', + 'lang_nat_add' => 'Add NAT', + 'lang_nat_del' => 'Delete NAT', + 'lang_nat_edit' => 'Modify NAT', + 'lang_nat_rules' => 'NAT Rules', + 'lang_nat_type' => 'Type', + 'lang_nat_type_1' => 'Hide', + 'lang_nat_type_2' => 'Static', + 'lang_nat_type_3' => 'Dynamic', + 'lang_search_results_found' => 'Total results found', 'lang_subnet_add' => 'Add subnet', 'lang_subnet_subnetaddress' => 'Subnet address', + 'lang_subnet_subnetaddress_mask' => 'Subnet address/Mask', 'lang_subnet_broadcastaddress' => 'Broadcast address', + 'lang_subnet_nodesinsubnet' => 'Nodes in subnet', + 'lang_subnet_subnetused' => 'Subnet used', 'lang_subnet_del' => 'Delete subnet', 'lang_subnet_edit' => 'Modify subnet', 'lang_subnet_info' => 'Subnet info', 'lang_subnet_mask' => 'Subnet mask', + 'lang_subnetlocation' => 'Subnet/Location', + 'lang_subnetlocation_edit' => 'Edit Subnet/Location', + 'lang_subnetvlan' => 'Subnet/VLAN', + 'lang_subnetvlan_edit' => 'Edit Subnet/VLAN', + 'lang_user_add' => 'Add user', 'lang_user_del' => 'Delete user', 'lang_user_displayname' => 'Displayname', 'lang_user_edit' => 'Mofidy user', - 'lang_user_level' => 'Userlevel', 'lang_user_name' => 'Username', - 'lang_user_pass' => 'Password', - 'lang_user_passnew1' => 'New password', - 'lang_user_passnew2' => 'Retype new password', - 'lang_user_passold' => 'Current password', - - 'lang_userclass_add' => 'Add userclass', - 'lang_userclass_del' => 'Delete userclass', - 'lang_userclass_edit' => 'Modify userclass', - 'lang_userclass_name' => 'Userclass name', + 'lang_user_password' => 'Password', 'lang_vlan_add' => 'Add VLAN', 'lang_vlan_del' => 'Delete VLAN', 'lang_vlan_edit' => 'Modify VLAN', 'lang_vlan_number' => 'VLAN ID', 'lang_vlan_info' => 'VLAN info', + 'lang_vlan_new' => 'VLAN info', 'lang_vlan_name' => 'VLAN name', + 'lang_vlansubnet' => 'VLAN/Subnet', + 'lang_vlansubnet_edit' => 'Edit VLAN/Subnet', + 'lang_comments' => 'Comments', + 'lang_comments_error' => 'Error', 'lang_comments_asset_del_nodes' => 'These nodes will also be deleted!', 'lang_comments_ipinuse' => 'IP in use', 'lang_comments_notallowed' => 'Not allowed', @@ -126,9 +149,48 @@ $lang = array( 'lang_comments_usernameinuse' => 'Username in use', 'lang_options_ipreg' => 'IP Reg options', - 'lang_options_password_edit' => 'Modify password', - 'lang_options_personal' => 'Personal options', - 'lang_options_settings_edit' => 'Modify settings', + 'lang_options_display' => 'Display options', + 'lang_options_password' => 'Change password', + 'lang_options_imagesize' => 'Imagesize', + 'lang_options_imagesize_help' => 'Size (in pixels) of colored square on subnetview', + 'lang_options_imagecount' => 'Imagecount', + 'lang_options_imagecount_help' => 'Nr of colored squares per row on subnetview', + 'lang_options_mac' => 'MAC Address', + 'lang_options_mac_help' => 'Format in which a MAC address is displayed (e.g. xx-xx-xx-xx-xx-xx)', + 'lang_options_menu_help' => 'Select items to be displayed in menu', + 'lang_options_dateformat' => 'Date format', + 'lang_options_dateformat_help' => 'Format in which dates are displayed using the php-date-format (see http://www.php.net/date for more info)', + 'lang_options_dns1suffix' => 'DNS Name suffix', + 'lang_options_dns1suffix_help' => 'Default DNS Name suffix when creating a new node', + 'lang_options_dns2suffix' => 'DNS Alias suffix', + 'lang_options_dns2suffix_help' => 'Default DNS Alias suffix when creating a new node', + 'lang_options_currentpassword' => 'Current password', + 'lang_options_currentpassword_help' => 'Enter your current password', + 'lang_options_newpassword1' => 'New password', + 'lang_options_newpassword1_help' => 'Enter your new password', + 'lang_options_newpassword2' => 'Retype new password', + 'lang_options_newpassword2_help' => 'Re-type your new password', + + 'lang_about_sfprojectpage' => 'Sourceforge Project Page', + 'lang_about_license' => 'lang_about_license', + 'lang_about_gpl' => 'GNU General Public License (GPL)', + 'lang_about_yapter' => 'Yapter Template Engine', + 'lang_about_iconset' => 'Silk icon set 1.3', + 'lang_about_ipreg_ext' => 'IP Reg, a PHP/MySQL IPAM tool', + 'lang_about_license_ext' => 'Copyright (C) 2007-2009 Wietse Warendorff

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.', + + 'lang_about_changelog' => 'Changelog (major changes only)', + 'lang_about_changelog_v05' => 'v0.5 (dec 2009)', + 'lang_about_changelog_v05_ext' => '- Complete code rewrite
- Input sanitation
- Background image
- Added multiple counters
- HTML is now 100% W3C valid
More user options', + 'lang_about_changelog_v04' => 'v0.4 (jun 2008)', + 'lang_about_changelog_v04_ext' => '- SQL vulnerability fixed
- PHP-generated images in subnet overview', + 'lang_about_changelog_v03' => 'v0.3 (dec 2007)', + 'lang_about_changelog_v03_ext' => '- Class A subnet support
- Multi-language support
- User defined options
- All configuration options in one file (config.php)', + 'lang_about_changelog_v02' => 'v0.2 (dec 2007)', + 'lang_about_changelog_v02_ext' => '- Fixed ordering of IP addresses
- Fixed info fields', + 'lang_about_changelog_v01' => 'v0.1 (dec 2007)', + 'lang_about_changelog_v01_ext' => '- First beta release', + ); ?> \ No newline at end of file diff --git a/userpassedit.php b/lib.php similarity index 69% rename from userpassedit.php rename to lib.php index 487e822..0ac5bbf 100644 --- a/userpassedit.php +++ b/lib.php @@ -1,7 +1,7 @@ setvars($lang); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // functions + include("lib/functions.php"); + + // classes + // db + // load class + require("lib/db.class.php"); + + // create instance + $db = new Db(); + + // user + // load class + require("lib/user.class.php"); + + // create instance + $user = new User(); + + // tpl + // load class + include("lib/yapter.php"); ?> \ No newline at end of file diff --git a/lib/changelink.js b/lib/changelink.js new file mode 100644 index 0000000..7b0455a --- /dev/null +++ b/lib/changelink.js @@ -0,0 +1,5 @@ + function changelink(optVal){ + if(optVal=="") + return false; + window.location='subnetview.php?subnet_id='+optVal; + } \ No newline at end of file diff --git a/lib/changetext.js b/lib/changetext.js new file mode 100644 index 0000000..babe973 --- /dev/null +++ b/lib/changetext.js @@ -0,0 +1,3 @@ + function changetext(id,newtext) { + document.getElementById(id).innerHTML=newtext + } \ No newline at end of file diff --git a/userclass.php b/lib/db.class.php similarity index 53% rename from userclass.php rename to lib/db.class.php index f2c5b37..d6f0e74 100644 --- a/userclass.php +++ b/lib/db.class.php @@ -1,7 +1,7 @@ setvars($lang); - - // get userclass info - $result = mysql_query("SELECT userclass_id, userclass_name FROM userclass ORDER BY userclass_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("userclass_id", $row->userclass_id); - $tp->set("userclass_name", $row->userclass_name); - $tp->parse("userclassrow"); - } - if (($i>0) ? $tp->parse("userclass") : $tp->hide("userclass")); + class Db { + function db_delete($query) { + // run query + $sql = mysql_query($query) or die(mysql_error()); + } - // output - $tp->parse(); - $tp->spit(); + function db_insert($query) { + // run query + $sql = mysql_query($query) or die(mysql_error()); + + // return result + return mysql_insert_id(); + } - include("footer.php"); + function db_select($query) { + // run query + $sql = mysql_query($query) or die(mysql_error()); + + // loop results + while($record = mysql_fetch_assoc($sql)) { + $result[] = $record; + } + + // return array + return $result; + } + + function db_update($query) { + // run query + $sql = mysql_query($query) or die(mysql_error()); + } + } ?> \ No newline at end of file diff --git a/functions.php b/lib/functions.php similarity index 51% rename from functions.php rename to lib/functions.php index 620644c..51a4e13 100644 --- a/functions.php +++ b/lib/functions.php @@ -1,7 +1,7 @@ auth; - } - - // check specific auth for this item - $result = mysql_query("SELECT uc.auth FROM userclassauth uc, useruserclass u WHERE u.user_id='$suser_id' AND uc.userclass_id=u.userclass_id AND uc.item='$item' AND uc.id=0 ORDER BY uc.ordering DESC LIMIT 1") or die(mysql_error()); - while ($row = mysql_fetch_object($result)) { - $auth = $row->auth; + // magic quotes enabled? + if(get_magic_quotes_gpc()) { + // strip slashes + $input = stripslashes($input); } - // and for a specific ID (if set) - if($item_id>0) { - $result = mysql_query("SELECT uc.auth FROM userclassauth uc, useruserclass u WHERE u.user_id='$suser_id' AND uc.userclass_id=u.userclass_id AND uc.item='$item' AND uc.id='$item_id' ORDER BY uc.ordering DESC LIMIT 1") or die(mysql_error()); - while ($row = mysql_fetch_object($result)) { - $auth = $row->auth; - } - } + // convert to utf-8 + iconv("UTF-8", "UTF-8", $input); - if($auth<$min_auth) { - // not allowed -> redirect - header_location("comments.php?comments=notallowed"); - } else { - return $auth; - } + // convert special chars + $input = htmlentities($input,ENT_QUOTES,'UTF-8'); + + // make sql ready + $input = mysql_real_escape_string($input); + + // and return + return $input; } ?> \ No newline at end of file diff --git a/lib/user.class.php b/lib/user.class.php new file mode 100644 index 0000000..eaca764 --- /dev/null +++ b/lib/user.class.php @@ -0,0 +1,115 @@ +. + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + class User { + function check_strlen($string) { + // check length + if(strlen($string)<1) { + return FALSE; + } else { + return TRUE; + } + } + + function user_login($user_name, $user_pass) { + // check user_name length + if($this->check_strlen($user_name)==FALSE) { + return FALSE; + } + + // check user_pass length + if($this->check_strlen($user_pass)==FALSE) { + return FALSE; + } + + // get user data + // initiate class + $db = new Db(); + + // build query + $query = "SELECT + user.user_id, + user.user_pass, + user.user_displayname, + user.user_imagesize, + user.user_imagecount, + user.user_mac, + user.user_dateformat, + user.user_dns1suffix, + user.user_dns2suffix, + user.user_menu_assets, + user.user_menu_assetclasses, + user.user_menu_assetclassgroups, + user.user_menu_locations, + user.user_menu_nodes, + user.user_menu_subnets, + user.user_menu_users, + user.user_menu_vlans + FROM + user + WHERE + user.user_name='" . $user_name . "'"; + + // run query + $users = $db->db_select($query); + + // count results + $user_counter = count($users); + + // any users? + if ($user_counter>0) { + // compare passwords + if(!strcmp(md5($user_pass), $users[0]['user_pass'])) { + // all ok: user is logged in, register session data + $_SESSION['suser_id'] = $users[0]['user_id']; + $_SESSION['suser_displayname'] = $users[0]['user_displayname']; + $_SESSION['suser_imagesize'] = $users[0]['user_imagesize']; + $_SESSION['suser_imagecount'] = $users[0]['user_imagecount']; + $_SESSION['suser_mac'] = $users[0]['user_mac']; + $_SESSION['suser_dateformat'] = $users[0]['user_dateformat']; + $_SESSION['suser_dns1suffix'] = $users[0]['user_dns1suffix']; + $_SESSION['suser_dns2suffix'] = $users[0]['user_dns2suffix']; + $_SESSION['suser_menu_assets'] = $users[0]['user_menu_assets']; + $_SESSION['suser_menu_assetclasses'] = $users[0]['user_menu_assetclasses']; + $_SESSION['suser_menu_assetclassgroups'] = $users[0]['user_menu_assetclassgroups']; + $_SESSION['suser_menu_locations'] = $users[0]['user_menu_locations']; + $_SESSION['suser_menu_nodes'] = $users[0]['user_menu_nodes']; + $_SESSION['suser_menu_subnets'] = $users[0]['user_menu_subnets']; + $_SESSION['suser_menu_users'] = $users[0]['user_menu_users']; + $_SESSION['suser_menu_vlans'] = $users[0]['user_menu_vlans']; + } else { + return FALSE; + } + } else { + return FALSE; + } + + // no errors found, return + return TRUE; + } + + function user_logout() { + // clear and destroy session + $_SESSION = array(); + } + } +?> \ No newline at end of file diff --git a/yapter.php b/lib/yapter.php similarity index 100% rename from yapter.php rename to lib/yapter.php diff --git a/location.php b/location.php index 4cece4a..b9a9be9 100644 --- a/location.php +++ b/location.php @@ -1,7 +1,7 @@ setvars($lang); - - // create array with parent index and location names - $parents = array(); - $location_names = array(); - - // get location information and insert to the arrays - $result = mysql_query("SELECT location_id, location_name, parent FROM location") or die(mysql_error()); - while ($row = mysql_fetch_object($result)) { - $location_names[$row->location_id] = $row->location_name; - $parents[$row->parent][] = $row->location_id; - } - - // look for parents and create a new array for every child - function location($parents, $parent = 0) { - $children = array(); - 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; + // start page + // includes + include("includes.php"); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/location.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // start location + // look for locations + // build query + $query = "SELECT + location.location_id AS location_id, + location.location_name AS location_name, + location.location_parent AS location_parent + FROM + location + ORDER BY + location.location_name"; + + // run query + $locations = $db->db_select($query); + + // count results + $location_counter = count($locations); + + // counter to tpl + $tp->set("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']; + } } - } - return $children; - } - - // recursive children check to template - function checkchildren ($array, $level) { - global $tp; - global $location_names; - foreach ($array as $location_id=>$val) { - if($val != "") { - $tp->set("location_id", $location_id); - $tp->set("location_name", $location_names[$location_id]); - $tp->set("nbsp", str_repeat("-  ",$level)); - $tp->parse("locationrow"); - checkchildren($val, $level+1); - } else { - $tp->set("location_id", $location_id); - $tp->set("location_name", $location_names[$location_id]); - $tp->set("nbsp", str_repeat("-  ",$level)); - $tp->parse("locationrow"); + + // 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; } - } - $tp->parse("location"); - $tp->clear("location"); - } - - // assemble the tree - $tree = location($parents); - - // check for values and build template - checkchildren($tree, 0); - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // to tpl + // recursive children check to template + function checkchildren($locations, $level) { + // include template class + global $tp; + + // import location names + global $location_names; + + // action! + foreach ($locations as $parent=>$child) { + // send vars to template + $tp->set("location_id", $parent); + $tp->set("location_name", $location_names[$parent]); + $tp->set("nbsp", str_repeat("-  ",$level)); + $tp->parse("location_row"); + + // any children? + if($child != "") { + // yes, so do the loop again! + checkchildren($child, $level+1); + } + } + + // parse and clear for the next round + $tp->parse("location_table"); + $tp->clear("location_table"); + } + + // assemble the tree + $tree = location($parents); + + // check for values and build template + checkchildren($tree, 0); + + // end page + // output + $tp->parse(); + $tp->spit(); + + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/locationadd.php b/locationadd.php index c84ad1f..6f85eef 100644 --- a/locationadd.php +++ b/locationadd.php @@ -1,7 +1,7 @@ setvars($lang); - // get id - if((isset($_GET['location_id'])) ? $location_id = $_GET['location_id'] : $location_id = ""); + // start parent + // look for locations + // build query + $query = "SELECT + location.location_id AS location_id, + location.location_name AS location_name, + location.location_parent AS location_parent + FROM + location + ORDER BY + location.location_name"; + + // run query + $locations = $db->db_select($query); + + // count results + $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; + } + + // to tpl + // recursive children check to template + function checkchildren($locations, $level) { + // include template class + global $tp; + + // import location names + global $location_names; + + // import location names + global $location_parent; + + // action! + foreach ($locations as $parent=>$child) { + // send vars to template + $tp->set("location_id", $parent); + $tp->set("location_name", $location_names[$parent]); + $tp->set("nbsp", str_repeat("-  ",$level)); + + // set parent selected + if($parent==$location_parent) { + $tp->set("location_selected", "selected"); + } else { + $tp->set("location_selected", ""); + } + + // parse block + $tp->parse("location_row"); + + // any children? + if($child != "") { + // yes, so do the loop again! + checkchildren($child, $level+1); + } + } + + // parse and clear for the next round + $tp->parse("location_table"); + $tp->clear("location_table"); + } + + // assemble the tree + $tree = location($parents); + + // check for values and build template + checkchildren($tree, 0); - // check authorisation - $auth = auth("location", $config_auth_locationadd, 0); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/locationadd.tpl"); - - // set language variables - $tp->setvars($lang); - - // get location info - $result = mysql_query("SELECT location_id, location_name FROM location ORDER BY location_name"); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->location_id==$location_id) ? $tp->set("location_selected", "selected") : $tp->set("location_selected", "")); - $tp->set("location_id", $row->location_id); - $tp->set("location_name", $row->location_name); - $tp->parse("locationrow"); - } - if (($i>0) ? $tp->parse("location") : $tp->hide("location")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/locationdel.php b/locationdel.php index d33b3c8..630cf6a 100644 --- a/locationdel.php +++ b/locationdel.php @@ -1,7 +1,7 @@ setvars($lang); - - // get location info - $result = mysql_query("SELECT location_name FROM location WHERE location_id='$location_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("location_id", $location_id); - $tp->set("location_name", $row->location_name); + // start page + // includes + include("includes.php"); + + // get id + $location_id = sanitize($_GET['location_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/locationdel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup location + // build query + $query = "SELECT + location.location_name AS location_name + FROM + location + WHERE + location.location_id=" . $location_id; + + // run query + $location = $db->db_select($query); - // output - $tp->parse(); - $tp->spit(); + // send to tpl + $tp->set("location_id", $location_id); + $tp->set("location_name", $location[0]['location_name']); + + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/locationedit.php b/locationedit.php index c1f17dd..2a71f71 100644 --- a/locationedit.php +++ b/locationedit.php @@ -1,7 +1,7 @@ setvars($lang); - - // check for submit - if ($_SERVER['REQUEST_METHOD']=="POST" ) { - $location_id = $_POST['location_id']; - $location_name = $_POST['location_name']; - $parent = $_POST['parent']; - $location_info = $_POST['location_info']; - mysql_query("UPDATE location SET location_name='$location_name', parent='$parent', location_info='$location_info' WHERE location_id='$location_id'") or die(mysql_error()); + // start page + // includes + include("includes.php"); - header_location("locationview.php?location_id=" . $location_id); - } - - // get current information - $result = mysql_query("SELECT location_name, parent, location_info FROM location WHERE location_id='$location_id'") or die(mysql_error()); - $row = mysql_fetch_object($result); - $parent = $row->parent; - $tp->set("location_id", $location_id); - $tp->set("location_name", $row->location_name); - $tp->set("location_info", $row->location_info); + // get id + $location_id = sanitize($_GET['location_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/locationedit.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - // get parent info - $result = mysql_query("SELECT location_id, location_name FROM location ORDER BY location_name"); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->location_id==$parent) ? $tp->set("selected", "selected") : $tp->set("selected", "")); - $tp->set("parent_id", $row->location_id); - $tp->set("parent_name", $row->location_name); - $tp->parse("parentrow"); - } - if (($i>0) ? $tp->parse("parent") : $tp->hide("parent")); + // setup location + // build query + $query = "SELECT + location.location_name AS location_name, + location.location_parent AS location_parent, + location.location_info AS location_info + FROM + location + WHERE + location.location_id=" . $location_id; + + // run query + $location = $db->db_select($query); + + // get parent + $location_parent = $location[0]['location_parent']; - // output - $tp->parse(); - $tp->spit(); + // send to tpl + $tp->set("location_id", $location_id); + $tp->set("location_name", $location[0]['location_name']); + $tp->set("location_info", $location[0]['location_info']); - include("footer.php"); + // setup parent location + // look for locations + // build query + $query = "SELECT + location.location_id AS location_id, + location.location_name AS location_name, + location.location_parent AS location_parent + FROM + location + ORDER BY + location.location_name"; + + // run query + $locations = $db->db_select($query); + + // count results + $location_counter = count($locations); + + // counter to tpl + $tp->set("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; + } + + // to tpl + // recursive children check to template + function checkchildren($locations, $level) { + // include template class + global $tp; + + // import location names + global $location_names; + + // import current id + global $location_id; + + // import parent + global $location_parent; + + // action! + foreach ($locations as $parent=>$child) { + // send vars to template + $tp->set("parentlocation_id", $parent); + $tp->set("parentlocation_name", $location_names[$parent]); + $tp->set("nbsp", str_repeat("-  ",$level)); + + // set parent selected + if($parent==$location_parent) { + $tp->set("parentlocation_selected", "selected"); + } else { + $tp->set("parentlocation_selected", ""); + } + + // parse block + $tp->parse("parentlocation_row"); + + // any children? + if($child != "") { + // yes, so do the loop again! + checkchildren($child, $level+1); + } + } + + // parse and clear for the next round + $tp->parse("parentlocation_table"); + $tp->clear("parentlocation_table"); + } + + // assemble the tree + $tree = location($parents); + + // check for values and build template + checkchildren($tree, 0); + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/locationsubnetadd.php b/locationsubnetadd.php new file mode 100644 index 0000000..be60d27 --- /dev/null +++ b/locationsubnetadd.php @@ -0,0 +1,107 @@ +. + + 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 template + $tp = new Template("tpl/locationsubnetadd.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup location + // build query + $query = "SELECT + location.location_name AS location_name + FROM + location + WHERE + location.location_id=" . $location_id; + + // run query + $location = $db->db_select($query); + + $tp->set("location_id", $location_id); + $tp->set("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 + subnet + WHERE + subnet.subnet_id NOT IN ( + SELECT + subnet_id + FROM + subnetlocation + WHERE + location_id=" . $location_id . " + ) + ORDER BY + INET_ATON(subnet.subnet_address)"; + + // run query + $subnets = $db->db_select($query); + + // count results + $subnet_counter = count($subnets); + + // any locations? + if ($subnet_counter>0) { + // get objects + foreach($subnets AS $subnet) { + // send to tpl + $tp->set("subnet_id", $subnet['subnet_id']); + $tp->set("subnet_address", $subnet['subnet_address']); + $tp->set("subnet_mask", $subnet['subnet_mask']); + + // parse row + $tp->parse("subnet_row"); + } + + // parse block + $tp->parse("subnet_table"); + } else { + // hide block + $tp->hide("subnet_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/locationsubnetdel.php b/locationsubnetdel.php new file mode 100644 index 0000000..dd79eb7 --- /dev/null +++ b/locationsubnetdel.php @@ -0,0 +1,102 @@ +. + + 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 template + $tp = new Template("tpl/locationsubnetdel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup location + // build query + $query = "SELECT + location.location_name AS location_name + FROM + location + WHERE + location.location_id=" . $location_id; + + // run query + $location = $db->db_select($query); + + $tp->set("location_id", $location_id); + $tp->set("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); + + // count results + $subnet_counter = count($subnets); + + // any locations? + if ($subnet_counter>0) { + // get objects + foreach($subnets AS $subnet) { + // send to tpl + $tp->set("subnet_id", $subnet['subnet_id']); + $tp->set("subnet_address", $subnet['subnet_address']); + $tp->set("subnet_mask", $subnet['subnet_mask']); + + // parse row + $tp->parse("subnet_row"); + } + + // parse block + $tp->parse("subnet_table"); + } else { + // hide block + $tp->hide("subnet_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/userclassauthadd.php b/locationsubnetedit.php similarity index 52% rename from userclassauthadd.php rename to locationsubnetedit.php index abfb1d7..e36af08 100644 --- a/userclassauthadd.php +++ b/locationsubnetedit.php @@ -1,7 +1,7 @@ setvars($lang); - - // get userclass info - $result = mysql_query("SELECT userclass_id, userclass_name FROM userclass ORDER BY userclass_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("userclass_id", $row->userclass_id); - $tp->set("userclass_name", $row->userclass_name); - $tp->parse("userclassrow"); - } - if (($i>0) ? $tp->parse("userclass") : $tp->hide("userclass")); + // get ip and id + $location_id = sanitize($_GET['location_id']); - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/locationsubnetedit.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup location + // build query + $query = "SELECT + location.location_name AS location_name + FROM + location + WHERE + location.location_id=" . $location_id; + + // run query + $location = $db->db_select($query); + + // send to tpl + $tp->set("location_id", $location_id); + $tp->set("location_name", $location[0]['location_name']); + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/locationview.php b/locationview.php index b01bd99..8327157 100644 --- a/locationview.php +++ b/locationview.php @@ -1,7 +1,7 @@ setvars($lang); - - // create breadcrumb arrays - $parents = array(); - $location_names = array(); - $crumbs = array(); - - // get location information and insert to the arrays - $result = mysql_query("SELECT location_id, location_name, parent FROM location") or die(mysql_error()); - while ($row = mysql_fetch_object($result)) { - $location_names[$row->location_id] = $row->location_name; - $parents[$row->location_id] = $row->parent; - } - - // function to build array with parents - function parent($location_id) { - // use names index - global $parents; - global $crumbs; - global $location_names; - - // fill array with this value - $crumbs[$location_id] = $location_id; - if (($parents[$location_id])>0) { - // still not on top, so do it again - parent($parents[$location_id]); - } + // start page + // includes + include("includes.php"); - // return the array - return $location_id; - } - - // build parents - parent($location_id); - - // loop array in reverse order and send to template - foreach (array_reverse($crumbs) as $key=>$val) { - $tp->set("location_id", $val); - $tp->set("location_name", $location_names[$val]); - if (($key>0) ? $tp->set("seperator", ". ") : $tp->set("seperator", "")); - $tp->parse("locationcrumbrow"); - } - $tp->parse("locationcrumb"); - - // get location info - $result = mysql_query("SELECT location_name, location_info FROM location WHERE location_id='$location_id'"); - $row=mysql_fetch_object($result); - $tp->set("location_info", nl2br($row->location_info)); + // get id + $location_id = sanitize($_GET['location_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/locationview.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // start locationcrumb + // get locations + // build query + $query = "SELECT + location.location_id AS location_id, + location.location_name AS location_name, + location.location_parent AS location_parent + FROM + location"; + + // run query + $locations = $db->db_select($query); + + // count results + $location_counter = count($locations); + + // counter to tpl + $tp->set("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_id']] = $location['location_parent']; + } + } + + // build parents array + // function to build array with parents for this location + function parent($location_id) { + // use names index + global $parents; + global $crumbs; + global $location_names; + + // fill array with this value + $crumbs[$location_id] = $location_id; + if (($parents[$location_id])>0) { + // still not on top, so do it again + parent($parents[$location_id]); + } + + // return the array + return $location_id; + } + + // build parents + parent($location_id); + + // to tpl + // loop in reverse order + foreach (array_reverse($crumbs) as $key=>$val) { + // send vars to template + $tp->set("location_id", $val); + $tp->set("location_name", $location_names[$val]); + + // include seperator? + if (($key>0) ? $tp->set("seperator", ". ") : $tp->set("seperator", "")); + + // parse block + $tp->parse("locationcrumb_row"); + } + + // parse block + $tp->parse("locationcrumb_table"); + + // setup location + // build query + $query = "SELECT + location.location_info AS location_info + FROM + location + WHERE + location.location_id=" . $location_id; + + // run query + $location = $db->db_select($query); + + // send to tpl + $tp->set("location_id", $location_id); + $tp->set("location_info", nl2br($location[0]['location_info'])); + + // setup sublocations + // build query + $query = "SELECT + location.location_id AS sublocation_id, + location.location_name AS sublocation_name + FROM + location + WHERE + location.location_parent=" . $location_id . " + ORDER BY + location.location_name"; + + // run query + $sublocations = $db->db_select($query); + + // count results + $sublocation_counter = count($sublocations); + + // counter to tpl + $tp->set("sublocation_counter", $sublocation_counter); + + // any nodes? + if ($sublocation_counter>0) { + // get objects + foreach($sublocations AS $sublocation) { + // send to tpl + $tp->set("sublocation_id", $sublocation['sublocation_id']); + $tp->set("sublocation_name", $sublocation['sublocation_name']); + + // parse row + $tp->parse("sublocation_row"); + } + + // parse block + $tp->parse("sublocation_table"); + } else { + // hide block + $tp->hide("sublocation_table"); + } - // search subnets for this location - $result = mysql_query("SELECT s.subnet_id, s.subnet_address, s.subnet_mask FROM subnet s INNER JOIN subnetlocation sl ON s.subnet_id=sl.subnet_id WHERE sl.location_id='$location_id'") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("subnet_id", $row->subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); - $tp->parse("subnetrow"); - } - if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet")); + // setup subnets + // build query + $query = "SELECT + subnet.subnet_id AS subnet_id, + subnet.subnet_address AS subnet_address, + subnet.subnet_mask AS subnet_mask + FROM + subnet, + subnetlocation + WHERE + subnetlocation.location_id=" . $location_id . " + AND subnetlocation.subnet_id=subnet.subnet_id + ORDER BY + INET_ATON(subnet.subnet_address)"; + + // run query + $subnets = $db->db_select($query); + + // count results + $subnet_counter = count($subnets); + + // counter to tpl + $tp->set("subnet_counter", $subnet_counter); + + // any nodes? + if ($subnet_counter>0) { + // get objects + foreach($subnets AS $subnet) { + // send to tpl + $tp->set("subnet_id", $subnet['subnet_id']); + $tp->set("subnet_address", $subnet['subnet_address']); + $tp->set("subnet_mask", $subnet['subnet_mask']); + + // parse row + $tp->parse("subnet_row"); + } + + // parse block + $tp->parse("subnet_table"); + } else { + // hide block + $tp->hide("subnet_table"); + } - // search sub-locations for this location - $result = mysql_query("SELECT location_id, location_name FROM location WHERE parent='$location_id' ORDER BY location_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("sublocation_id", $row->location_id); - $tp->set("sublocation_name", $row->location_name); - $tp->parse("sublocationrow"); - } - if (($i>0) ? $tp->parse("sublocation") : $tp->hide("sublocation")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/login.php b/login.php index 4f0ea6d..1b70f3b 100644 --- a/login.php +++ b/login.php @@ -1,7 +1,7 @@ "" && trim($_POST['user_pass']) <> "") { - $user_name = $_POST['user_name']; - $result = mysql_query("SELECT user_id, user_pass, user_level, user_displayname, user_mac, user_lang FROM user WHERE user_name='$user_name'") or die(mysql_error()); + // 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']); - if(mysql_num_rows($result) > 0) { - if(!strcmp(md5($_POST['user_pass']), mysql_result($result, 0, "user_pass"))) { - // all ok, user logged in - $_SESSION['suser_id'] = mysql_result($result, 0, "user_id"); - $_SESSION['suser_level'] = mysql_result($result, 0, "user_level"); - $_SESSION['suser_displayname'] = mysql_result($result, 0, "user_displayname"); - $_SESSION['suser_mac'] = mysql_result($result, 0, "user_mac"); - $_SESSION['suser_lang'] = mysql_result($result, 0, "user_lang"); - - header_location("index.php"); - } else { + // 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(); - } - // clear mysql-result - mysql_free_result($result); + $_SESSION = array(); + session_destroy(); } } - } // start output - // set template - $tp = new Template("tpl/login.tpl"); - - // set language variables - $tp->setvars($lang); - - // output - $tp->parse(); - $tp->spit(); + // set template + $tp = new Template("tpl/login.tpl", $config_yapter_error); + + // get version for the footer-stamp + $tp->set("config_version", $config_version); + + // set language variables + $tp->setvars($lang); - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/logout.php b/logout.php index a6fcc99..1c1bc64 100644 --- a/logout.php +++ b/logout.php @@ -1,7 +1,7 @@ user_logout(); + // redirect + header("Location: index.php"); ?> \ No newline at end of file diff --git a/natadd.php b/natadd.php new file mode 100644 index 0000000..ecb51a0 --- /dev/null +++ b/natadd.php @@ -0,0 +1,111 @@ +. + + 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 template + $tp = new Template("tpl/natadd.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup node_ext + // build query + $query = "SELECT + node.node_ip AS node_ip_ext + FROM + node + WHERE + node.node_id=" . $node_id; + + // run query + $node = $db->db_select($query); + + $tp->set("node_id_ext", $node_id); + $tp->set("node_ip_ext", $node[0]['node_ip_ext']); + + // setup node_int + // build query + $query = "SELECT + asset.asset_name AS asset_name, + node.node_id AS node_id_int, + node.node_ip AS node_ip_int + FROM + asset, + node + WHERE + node.node_id NOT IN ( + SELECT + nat_int + FROM + nat + WHERE + nat_ext=" . $node_id . " + ) + AND node.node_id!=" . $node_id . " + AND asset.asset_id=node.asset_id + ORDER BY + INET_ATON(node.node_ip)"; + + // run query + $nodes = $db->db_select($query); + + // count results + $node_counter = count($nodes); + + // any nodes? + if ($node_counter>0) { + // get objects + foreach($nodes AS $node) { + // send to tpl + $tp->set("asset_name", $node['asset_name']); + + $tp->set("node_id_int", $node['node_id_int']); + $tp->set("node_ip_int", $node['node_ip_int']); + + // parse row + $tp->parse("node_row"); + } + + // parse block + $tp->parse("node_table"); + } else { + // hide block + $tp->hide("node_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/natdel.php b/natdel.php new file mode 100644 index 0000000..20f8532 --- /dev/null +++ b/natdel.php @@ -0,0 +1,105 @@ +. + + 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 template + $tp = new Template("tpl/natdel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup node_ext + // build query + $query = "SELECT + node.node_ip AS node_ip_ext + FROM + node + WHERE + node.node_id=" . $node_id; + + // run query + $node = $db->db_select($query); + + $tp->set("node_id_ext", $node_id); + $tp->set("node_ip_ext", $node[0]['node_ip_ext']); + + // setup node + // build query + $query = "SELECT + asset.asset_name AS asset_name, + node.node_id AS node_id_int, + node.node_ip AS node_ip_int + FROM + asset, + nat, + node + WHERE + nat.nat_ext=" . $node_id . " + AND node.node_id=nat.nat_int + AND asset.asset_id=node.asset_id + ORDER BY + INET_ATON(node.node_ip)"; + + // run query + $nodes = $db->db_select($query); + + // count results + $node_counter = count($nodes); + + // any nodes? + if ($node_counter>0) { + // get objects + foreach($nodes AS $node) { + // send to tpl + $tp->set("asset_name", $node['asset_name']); + + $tp->set("node_id_int", $node['node_id_int']); + $tp->set("node_ip_int", $node['node_ip_int']); + + // parse row + $tp->parse("node_row"); + } + + // parse block + $tp->parse("node_table"); + } else { + // hide block + $tp->hide("node_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/userclassdel.php b/natedit.php similarity index 54% rename from userclassdel.php rename to natedit.php index 70e7333..fb78402 100644 --- a/userclassdel.php +++ b/natedit.php @@ -1,7 +1,7 @@ setvars($lang); - - // get assetclass info - $result = mysql_query("SELECT userclass_id, userclass_name FROM userclass WHERE userclass_id='$userclass_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("userclass_id", $row->userclass_id); - $tp->set("userclass_name", $row->userclass_name); + // start page + // includes + include("includes.php"); + + // get id + $node_id = sanitize($_GET['node_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/natedit.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($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); + + $tp->set("node_id", $node_id); + $tp->set("node_ip", $node[0]['node_ip']); - // output - $tp->parse(); - $tp->spit(); + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/node.php b/node.php new file mode 100644 index 0000000..3bdd88a --- /dev/null +++ b/node.php @@ -0,0 +1,108 @@ +. + + 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 template + $tp = new Template("tpl/node.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($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 + $tp->set("subnet_id", $subnet_id); + } else { + // to tpl + $tp->set("subnet_id", ""); + } + + // build query + $query = "SELECT + asset.asset_id AS asset_id, + asset.asset_name AS asset_name, + node.node_id AS node_id, + node.node_ip AS node_ip + 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); + + // count results + $node_counter = count($nodes); + + // counter to tpl + $tp->set("node_counter", $node_counter); + + // any nodes? + if ($node_counter>0) { + // get objects + foreach($nodes AS $node) { + // send to tpl + $tp->set("asset_id", $node['asset_id']); + $tp->set("asset_name", $node['asset_name']); + + $tp->set("node_id", $node['node_id']); + $tp->set("node_ip", $node['node_ip']); + + // parse row + $tp->parse("node_row"); + } + + // parse block + $tp->parse("node_table"); + } else { + // hide block + $tp->hide("node_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/nodeadd.php b/nodeadd.php index 7d02cda..8d11841 100644 --- a/nodeadd.php +++ b/nodeadd.php @@ -1,7 +1,7 @@ setvars($lang); - // check authorisation - $auth = auth("node", $config_auth_nodeadd, 0); + // set vars + $tp->set("user_dns1suffix", $_SESSION['suser_dns1suffix']); + $tp->set("user_dns2suffix", $_SESSION['suser_dns2suffix']); + $tp->set("node_ip", $node_ip); - // start output - include("header.php"); + // 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 + subnet + ORDER BY + INET_ATON(subnet.subnet_address)"; + + // run query + $subnets = $db->db_select($query); + + foreach($subnets AS $subnet) { + // send to tpl + $tp->set("subnet_id", $subnet['subnet_id']); + $tp->set("subnet_address", $subnet['subnet_address']); + $tp->set("subnet_mask", $subnet['subnet_mask']); + + // set subnet selected + if($subnet['subnet_id']==$subnet_id) { + $tp->set("subnet_selected", "selected"); + } else { + $tp->set("subnet_selected", ""); + } + + // parse block + $tp->parse("subnet_row"); + } + + // parse block + $tp->parse("subnet_table"); - // set template - $tp = new Template("tpl/nodeadd.tpl"); + // setup assetclass + // build query + $query = "SELECT + assetclass.assetclass_id AS assetclass_id, + assetclass.assetclass_name AS assetclass_name + FROM + assetclass + ORDER BY + assetclass.assetclass_name"; + + // run query + $assetclasses = $db->db_select($query); + + foreach($assetclasses AS $assetclass) { + // send to tpl + $tp->set("assetclass_id", $assetclass['assetclass_id']); + $tp->set("assetclass_name", $assetclass['assetclass_name']); + + if($assetclass['assetclass_id']==$assetclass_id) { + $tp->set("assetclass_selected", "selected"); + } else { + $tp->set("assetclass_selected", ""); + } + + // parse block + $tp->parse("assetclass_row"); + } + + // parse block + $tp->parse("assetclass_table"); - // set language variables - $tp->setvars($lang); - - // check for set ip and/or subnet_id - if ((isset($_GET['ip'])) ? $ip = $tp->set("ip", $_GET['ip']) : $tp->set("ip", "")); - if ((isset($_GET['subnet_id'])) ? $subnet_id = $_GET['subnet_id'] : $subnet_id = ''); - - // set variables - $tp->set("config_dns1suffix", $config_dns1suffix); - $tp->set("config_dns2suffix", $config_dns2suffix); - - // get subnet info - $result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->subnet_id==$subnet_id) ? $tp->set("selected", "selected") : $tp->set("selected", "")); - $tp->set("subnet_id", $row->subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); - $tp->parse("subnetrow"); - } - if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet")); - - // get assetclassgroup information - $result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("assetclass_id", $row->assetclass_id); - $tp->set("assetclass_name", $row->assetclass_name); - $tp->parse("assetclassrow"); - } - if (($i>0) ? $tp->parse("assetclass") : $tp->hide("assetclass")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/nodedel.php b/nodedel.php index b1f317e..fd96f7f 100644 --- a/nodedel.php +++ b/nodedel.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); + + // get id + $node_id = sanitize($_GET['node_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/nodedel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - // get asset info - $result = mysql_query("SELECT ip, asset_id FROM node WHERE node_id='$node_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("node_id", $node_id); - $tp->set("asset_id", $row->asset_id); - $tp->set("ip", $row->ip); + // setup node + // build query + $query = "SELECT + node.asset_id AS asset_id, + node.node_ip AS node_ip + FROM + node + WHERE + node.node_id=" . $node_id; + + // run query + $node = $db->db_select($query); + + // send to tpl + $tp->set("node_id", $node_id); + $tp->set("asset_id", $node[0]['asset_id']); + $tp->set("node_ip", $node[0]['node_ip']); - // output - $tp->parse(); - $tp->spit(); + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/nodeedit.php b/nodeedit.php index d3472f8..747ba7e 100644 --- a/nodeedit.php +++ b/nodeedit.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); - // get node info - $result = mysql_query("SELECT asset_id, ip, mac, dns1, dns2, subnet_id, node_info FROM node WHERE node_id='$node_id'") or die(mysql_error()); - $row = mysql_fetch_object($result); - $asset_id = $row->asset_id; - $subnet_id = $row->subnet_id; - $tp->set("node_id", $node_id); - $tp->set("ip", $row->ip); - $tp->set("mac", $row->mac); - $tp->set("dns1", $row->dns1); - $tp->set("dns2", $row->dns2); - $tp->set("node_info", $row->node_info); - - // get asset info - $result = mysql_query("SELECT asset_id, asset_name FROM asset ORDER BY asset_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->asset_id==$asset_id) ? $tp->set("asset_selected", "selected") : $tp->set("asset_selected", "")); - $tp->set("asset_id", $row->asset_id); - $tp->set("asset_name", $row->asset_name); - $tp->parse("assetrow"); - } - if (($i>0) ? $tp->parse("asset") : $tp->hide("asset")); + // get id + $node_id = sanitize($_GET['node_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/nodeedit.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup node + // build query + $query = "SELECT + asset.asset_id AS asset_id, + node.node_id AS node_id, + node.node_ip AS node_ip, + node.node_mac AS node_mac, + node.node_dns1 AS node_dns1, + node.node_dns2 AS node_dns2, + node.node_info AS node_info, + subnet.subnet_id AS subnet_id + FROM + asset, + node, + subnet + WHERE + asset.asset_id=node.asset_id + AND node.node_id=" . $node_id . " + AND subnet.subnet_id=node.subnet_id"; + + // run query + $node = $db->db_select($query); + + // send to tpl + $tp->set("node_id", $node[0]['node_id']); + $tp->set("node_ip", $node[0]['node_ip']); + $tp->set("node_mac", write_mac($node[0]['node_mac'])); + $tp->set("node_dns1", $node[0]['node_dns1']); + $tp->set("node_dns2", $node[0]['node_dns2']); + $tp->set("node_info", $node[0]['node_info']); - // get subnet info - $result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->subnet_id==$subnet_id) ? $tp->set("subnet_selected", "selected") : $tp->set("subnet_selected", "")); - $tp->set("subnet_id", $row->subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); - $tp->parse("subnetrow"); - } - if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet")); + // setup asset + // build query + $query = "SELECT + asset.asset_id AS asset_id, + asset.asset_name AS asset_name + FROM + asset + ORDER BY + asset.asset_name"; + + // run query + $assets = $db->db_select($query); + + // count results + $asset_counter = count($assets); + + // any assets? + if ($asset_counter>0) { + // get objects + foreach($assets AS $asset) { + // send to tpl + $tp->set("asset_id", $asset['asset_id']); + $tp->set("asset_name", $asset['asset_name']); + + if($asset['asset_id']==$node[0]['asset_id']) { + $tp->set("asset_selected", "selected"); + } else { + $tp->set("asset_selected", ""); + } + + // parse block + $tp->parse("asset_row"); + } + // parse block + $tp->parse("asset_table"); + } else { + // parse block + $tp->hide("asset_table"); + } - // output - $tp->parse(); - $tp->spit(); + // 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 + subnet + ORDER BY + INET_ATON(subnet.subnet_address)"; + + // run query + $subnets = $db->db_select($query); + + // count results + $subnet_counter = count($subnets); + + // any subnets? + if ($subnet_counter>0) { + // get objects + foreach($subnets AS $subnet) { + // send to tpl + $tp->set("subnet_id", $subnet['subnet_id']); + $tp->set("subnet_address", $subnet['subnet_address']); + $tp->set("subnet_mask", $subnet['subnet_mask']); + + if($subnet['subnet_id']==$node[0]['subnet_id']) { + $tp->set("subnet_selected", "selected"); + } else { + $tp->set("subnet_selected", ""); + } + + // parse block + $tp->parse("subnet_row"); + } + // parse block + $tp->parse("subnet_table"); + } else { + // parse block + $tp->hide("subnet_table"); + } - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/nodelist.php b/nodelist.php deleted file mode 100644 index a795dc1..0000000 --- a/nodelist.php +++ /dev/null @@ -1,79 +0,0 @@ -. - - For more information, visit http://sourceforge.net/projects/ipreg, - or contact me at wietsew@users.sourceforge.net - *****************************************************************************/ - - // includes - include("includes.php"); - - // get id - $subnet_id = $_GET['subnet_id']; - - // check authorisation - $auth = auth("node", $config_auth_nodeview, 0); - $auth = auth("subnet", $config_auth_subnetview, $subnet_id); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/nodelist.tpl"); - - // set language variables - $tp->setvars($lang); - - // set variables - $tp->set("subnet_id", $subnet_id); - - // set ordering - if (isset($_GET['order'])) { - switch($_GET['order']) { - case ("asset_name") : $order = "a.asset_name"; break; - case ("hostname") : $order = "a.hostname"; break; - case ("mac") : $order = "n.mac"; break; - case ("dns1") : $order = "n.dns1"; break; - case ("dns2") : $order = "n.dns2"; break; - default : $order = "INET_ATON(n.ip)"; - } - } else { - $order = "INET_ATON(n.ip)"; - } - - // get node info - $result = mysql_query("SELECT a.asset_id, a.asset_name, a.hostname, n.node_id, n.ip, n.mac, n.dns1, n.dns2 FROM asset a, node n WHERE n.subnet_id='$subnet_id' AND a.asset_id=n.asset_id ORDER BY $order") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("asset_id", $row->asset_id); - $tp->set("asset_name", $row->asset_name); - $tp->set("hostname", $row->hostname); - $tp->set("node_id", $row->node_id); - $tp->set("ip", $row->ip); - $tp->set("mac", write_mac($row->mac)); - $tp->set("dns1", $row->dns1); - $tp->set("dns2", $row->dns2); - $tp->parse("noderow"); - } - if (($i>0) ? $tp->parse("node") : $tp->hide("node")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); -?> \ No newline at end of file diff --git a/nodeview.php b/nodeview.php index 08e66fa..88175b1 100644 --- a/nodeview.php +++ b/nodeview.php @@ -1,7 +1,7 @@ setvars($lang); - // set language variables - $tp->setvars($lang); + // setup node + // build query + $query = "SELECT + asset.asset_id AS asset_id, + asset.asset_name AS asset_name, + node.node_id AS node_id, + node.node_ip AS node_ip, + node.node_mac AS node_mac, + node.node_dns1 AS node_dns1, + node.node_dns2 AS node_dns2, + node.node_info AS node_info, + subnet.subnet_id AS subnet_id, + subnet.subnet_address AS subnet_address, + subnet.subnet_mask AS subnet_mask + FROM + asset, + node, + subnet + WHERE + asset.asset_id=node.asset_id + AND node.node_id=" . $node_id . " + AND subnet.subnet_id=node.subnet_id"; + + // run query + $nodes = $db->db_select($query); + + // count results + $node_counter = count($nodes); + + // counter to tpl + $tp->set("node_counter", $node_counter); + + // any nodes? + if ($node_counter>0) { + // get objects + foreach($nodes AS $node) { + // send to tpl + $tp->set("asset_id", $node['asset_id']); + $tp->set("asset_name", $node['asset_name']); + + $tp->set("node_id", $node['node_id']); + $tp->set("node_ip", $node['node_ip']); + $tp->set("node_mac", write_mac($node['node_mac'])); + $tp->set("node_dns1", $node['node_dns1']); + $tp->set("node_dns2", $node['node_dns2']); + $tp->set("node_info", nl2br($node['node_info'])); + + $tp->set("subnet_id", $node['subnet_id']); + $tp->set("subnet_address", $node['subnet_address']); + $tp->set("subnet_mask", $node['subnet_mask']); + + // parse row + $tp->parse("node_row"); + } + + // parse block + $tp->parse("node_table"); + } else { + // hide block + $tp->hide("node_table"); + } - // get node info - $result = mysql_query("SELECT a.asset_name, a.asset_id, n.ip, n.mac, n.dns1, n.dns2, n.node_info, s.subnet_id, s.subnet_address, s.subnet_mask FROM asset a, node n, subnet s WHERE n.node_id='$node_id' AND a.asset_id=n.asset_id AND s.subnet_id=n.subnet_id") or die(mysql_error()); - $row = mysql_fetch_object($result); - $tp->set("node_id", $node_id); - $tp->set("asset_id", $row->asset_id); - $tp->set("asset_name", $row->asset_name); - $tp->set("ip", $row->ip); - $tp->set("mac", write_mac($row->mac)); - $tp->set("dns1", $row->dns1); - $tp->set("dns2", $row->dns2); - $tp->set("node_info", nl2br($row->node_info)); - $tp->set("subnet_id", $row->subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); + // setup nat + // build query + $query = "SELECT + asset_ext.asset_id AS asset_id_ext, + asset_int.asset_id AS asset_id_int, + asset_ext.asset_name AS asset_name_ext, + asset_int.asset_name AS asset_name_int, + nat.nat_id AS nat_id, + nat.nat_type AS nat_type, + nat.nat_ext AS nat_ext, + nat.nat_int AS nat_int, + node_ext.node_ip AS node_ip_ext, + node_int.node_ip AS node_ip_int + FROM + asset asset_ext, + asset asset_int, + nat, + node node_ext, + node node_int + WHERE + (nat.nat_ext=" . $node_id . " + OR nat.nat_int=" . $node_id . ") + AND node_ext.node_id=nat.nat_ext + AND node_int.node_id=nat.nat_int + AND asset_ext.asset_id=node_ext.asset_id + AND asset_int.asset_id=node_int.asset_id + ORDER BY + INET_ATON(node_ext.node_ip), + INET_ATON(node_int.node_ip)"; - // output - $tp->parse(); - $tp->spit(); + // run query + $nats = $db->db_select($query); - include("footer.php"); + // count results + $nat_counter = count($nats); + + // counter to tpl + $tp->set("nat_counter", $nat_counter); + + // any nodes? + if ($nat_counter>0) { + // get objects + foreach($nats AS $nat) { + if($node_id==$nat['nat_ext']) { + // send to tpl + $tp->set("nat_asset_id", $nat['asset_id_int']); + $tp->set("nat_asset_name", $nat['asset_name_int']); + + $tp->set("nat_type", $lang['lang_nat_type_' . $nat['nat_type']]); + + $tp->set("nat_node_id", $nat['nat_int']); + $tp->set("nat_node_ip", $nat['node_ip_int']); + } else if($node_id==$nat['nat_int']) { + // send to tpl + $tp->set("nat_asset_id", $nat['asset_id_ext']); + $tp->set("nat_asset_name", $nat['asset_name_ext']); + + $tp->set("nat_type", $lang['lang_nat_type_' . $nat['nat_type']]); + + $tp->set("nat_node_id", $nat['nat_ext']); + $tp->set("nat_node_ip", $nat['node_ip_ext']); + } + + // parse row + $tp->parse("nat_row"); + } + + // parse block + $tp->parse("nat_table"); + } else { + // hide block + $tp->hide("nat_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + include("footer.php"); ?> \ No newline at end of file diff --git a/options.php b/options.php index 3f551cd..4382ae8 100644 --- a/options.php +++ b/options.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); + + // start output + include("header.php"); - // output - $tp->parse(); - $tp->spit(); + // set template + $tp = new Template("tpl/options.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/optionseditdisplay.php b/optionseditdisplay.php new file mode 100644 index 0000000..fdb78bd --- /dev/null +++ b/optionseditdisplay.php @@ -0,0 +1,111 @@ +. + + 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 template + $tp = new Template("tpl/optionseditdisplay.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // 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 = ''; + } + + // send to tpl + $tp->set("user_id", $_SESSION['suser_id']); + $tp->set("user_imagesize", $_SESSION['suser_imagesize']); + $tp->set("user_imagecount", $_SESSION['suser_imagecount']); + $tp->set("user_mac", $_SESSION['suser_mac']); + $tp->set("user_dateformat", $_SESSION['suser_dateformat']); + $tp->set("user_dns1suffix", $_SESSION['suser_dns1suffix']); + $tp->set("user_dns2suffix", $_SESSION['suser_dns2suffix']); + $tp->set("user_menu_assets_checked", $user_menu_assets_checked); + $tp->set("user_menu_assetclasses_checked", $user_menu_assetclasses_checked); + $tp->set("user_menu_assetclassgroups_checked", $user_menu_assetclassgroups_checked); + $tp->set("user_menu_locations_checked", $user_menu_locations_checked); + $tp->set("user_menu_nodes_checked", $user_menu_nodes_checked); + $tp->set("user_menu_subnets_checked", $user_menu_subnets_checked); + $tp->set("user_menu_users_checked", $user_menu_users_checked); + $tp->set("user_menu_vlans_checked", $user_menu_vlans_checked); + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/userclassadd.php b/optionseditpassword.php similarity index 68% rename from userclassadd.php rename to optionseditpassword.php index d35a3c9..ce6ff7f 100644 --- a/userclassadd.php +++ b/optionseditpassword.php @@ -1,7 +1,7 @@ setvars($lang); - - // output - $tp->parse(); - $tp->spit(); + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/optionseditpassword.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/search.php b/search.php index cc71c72..9f9729d 100644 --- a/search.php +++ b/search.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/search.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - // get string that was searched for + // get string that was searched for ($search is allready set in header.php) if (empty($search)) { + // parse nosearch box $tp->parse("nosearch"); + + // hide others $tp->hide("asset"); $tp->hide("location"); $tp->hide("node"); @@ -42,89 +46,276 @@ $tp->hide("vlan"); $tp->hide("resultcount"); } else { + // hide nosearch box $tp->hide("nosearch"); - // set needle and counter + // set needle $needle = '%' . $search . '%'; + + // set counter $resultcounter = 0; - // search assets - $result = mysql_query("SELECT asset_id, asset_name FROM asset WHERE asset_name LIKE '$needle' OR asset_info LIKE '%$needle%' ORDER BY asset_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("counter", $i+1); - $tp->set("item_name", $lang['lang_assets']); - $tp->set("item", "asset"); - $tp->set("id", $row->asset_id); - $tp->set("name", $row->asset_name); - $resultcounter++; - $tp->parse("row"); - } - if (($i>0) ? $tp->parse("asset") : $tp->hide("asset")); - $tp->clear("row"); - - // search locations - $result = mysql_query("SELECT location_id, location_name FROM location WHERE location_name LIKE '$needle' OR location_info LIKE '%$needle%' ORDER BY location_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("counter", $i+1); - $tp->set("item_name", $lang['lang_locations']); - $tp->set("item", "location"); - $tp->set("id", $row->location_id); - $tp->set("name", $row->location_name); - $resultcounter++; - $tp->parse("row"); - } - if (($i>0) ? $tp->parse("location") : $tp->hide("location")); - $tp->clear("row"); - - // search node - $result = mysql_query("SELECT node_id, ip FROM node WHERE ip LIKE '$needle' OR mac LIKE '$needle' OR dns1 LIKE '$needle' OR dns2 LIKE '$needle' OR node_info LIKE '$needle' ORDER BY ip") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("counter", $i+1); - $tp->set("item_name", $lang['lang_nodes']); - $tp->set("item", "node"); - $tp->set("id", $row->node_id); - $tp->set("name", $row->ip); - $resultcounter++; - $tp->parse("row"); - } - if (($i>0) ? $tp->parse("node") : $tp->hide("node")); - $tp->clear("row"); - - // search subnet - $result = mysql_query("SELECT subnet_id, subnet_address FROM subnet WHERE subnet_address LIKE '$needle' OR subnet_info LIKE '%$needle%' ORDER BY INET_ATON(subnet_address)") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("counter", $i+1); - $tp->set("item_name", $lang['lang_subnets']); - $tp->set("item", "subnet"); - $tp->set("id", $row->subnet_id); - $tp->set("name", $row->subnet_address); - $resultcounter++; - $tp->parse("row"); - } - if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet")); - $tp->clear("row"); - - // search vlan - $result = mysql_query("SELECT vlan_id, vlan_name FROM vlan WHERE vlan_name LIKE '$needle' OR vlan_info LIKE '%$needle%' ORDER BY vlan_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("counter", $i+1); - $tp->set("item_name", $lang['lang_vlans']); - $tp->set("item", "vlan"); - $tp->set("id", $row->vlan_id); - $tp->set("name", $row->vlan_name); - $resultcounter++; - $tp->parse("row"); - } - if (($i>0) ? $tp->parse("vlan") : $tp->hide("vlan")); - $tp->clear("row"); + // setup asset + // build query + $query = "SELECT + asset.asset_id AS asset_id, + asset.asset_name AS asset_name + 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); + + // count results + $counter = count($assets); + + // counter to tpl + $tp->set("counter", $counter); + + // any assets? + if ($counter>0) { + // get objects + foreach($assets AS $asset) { + // send to tpl + $tp->set("item_name", $lang['lang_assets']); + $tp->set("item", "asset"); + $tp->set("id", $asset['asset_id']); + $tp->set("name", $asset['asset_name']); + + // parse block + $tp->parse("row"); + + // update counter + $resultcounter++; + } + + // parse block + $tp->parse("asset"); + } else { + // parse block + $tp->hide("asset"); + } + + // clear row + $tp->clear("row"); + // setup location + // build query + $query = "SELECT + location.location_id AS location_id, + location.location_name AS location_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); + + // count results + $counter = count($locations); + + // counter to tpl + $tp->set("counter", $counter); + + // any locations? + if ($counter>0) { + // get objects + foreach($locations AS $location) { + // send to tpl + $tp->set("item_name", $lang['lang_locations']); + $tp->set("item", "location"); + $tp->set("id", $location['location_id']); + $tp->set("name", $location['location_name']); + + // parse block + $tp->parse("row"); + + // update counter + $resultcounter++; + } + + // parse block + $tp->parse("location"); + } else { + // parse block + $tp->hide("location"); + } + + // clear row + $tp->clear("row"); + + // setup node + // build query + $query = "SELECT + node.node_id AS node_id, + node.node_ip AS node_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); + + // count results + $counter = count($nodes); + + // counter to tpl + $tp->set("counter", $counter); + + // any nodes? + if ($counter>0) { + // get objects + foreach($nodes AS $node) { + // send to tpl + $tp->set("item_name", $lang['lang_nodes']); + $tp->set("item", "node"); + $tp->set("id", $node['node_id']); + $tp->set("name", $node['node_ip']); + + // parse block + $tp->parse("row"); + + // update counter + $resultcounter++; + } + + // parse block + $tp->parse("node"); + } else { + // parse block + $tp->hide("node"); + } + + // clear row + $tp->clear("row"); + + // setup subnet + // build query + $query = "SELECT + subnet.subnet_id AS subnet_id, + subnet.subnet_address AS subnet_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); + + // count results + $counter = count($subnets); + + // counter to tpl + $tp->set("counter", $counter); + + // any subnets? + if ($counter>0) { + // get objects + foreach($subnets AS $subnet) { + // send to tpl + $tp->set("item_name", $lang['lang_subnets']); + $tp->set("item", "subnet"); + $tp->set("id", $subnet['subnet_id']); + $tp->set("name", $subnet['subnet_address']); + + // parse block + $tp->parse("row"); + + // update counter + $resultcounter++; + } + + // parse block + $tp->parse("subnet"); + } else { + // parse block + $tp->hide("subnet"); + } + + // clear row + $tp->clear("row"); + + // setup vlan + // build query + $query = "SELECT + vlan.vlan_id AS vlan_id, + vlan.vlan_name AS vlan_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); + + // count results + $counter = count($vlans); + + // counter to tpl + $tp->set("counter", $counter); + + // any vlans? + if ($counter>0) { + // get objects + foreach($vlans AS $vlan) { + // send to tpl + $tp->set("item_name", $lang['lang_vlans']); + $tp->set("item", "vlan"); + $tp->set("id", $vlan['vlan_id']); + $tp->set("name", $vlan['vlan_name']); + + // parse block + $tp->parse("row"); + + // update counter + $resultcounter++; + } + + // parse block + $tp->parse("vlan"); + } else { + // parse block + $tp->hide("vlan"); + } + + // clear row + $tp->clear("row"); + + // to tpl $tp->set("resultcounter", $resultcounter); + + // parse block $tp->parse("resultcount"); } - // output - $tp->parse(); - $tp->spit(); + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/submit.php b/submit.php index bf52614..662822d 100644 --- a/submit.php +++ b/submit.php @@ -1,7 +1,7 @@ db_insert($query); // redirect header_location("assetview.php?asset_id=" . $asset_id); break; case ("assetclass") : // get variables - $assetclass_name = $_POST['assetclass_name']; - $assetclassgroup_id = $_POST['assetclassgroup_id']; - - // check permission - auth("assetclass", $config_auth_assetclassadd, 0); - - // update db - mysql_query("INSERT INTO assetclass (assetclass_name, assetclassgroup_id) VALUE ('$assetclass_name', '$assetclassgroup_id')") or die(mysql_error()); - $assetclass_id = mysql_insert_id(); + $assetclass_name = sanitize($_POST['assetclass_name']); + $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']); + + // build query + $query = "INSERT + INTO + assetclass( + assetclass.assetclass_name, + assetclass.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 = $_POST['assetclassgroup_name']; - $color = strtoupper($_POST['color']); - $color = preg_replace("|[^a-zA-Z0-9]|", "", $color); - - // check permission - auth("assetclassgroup", $config_auth_assetclassgroupadd, 0); - - // update db - mysql_query("INSERT INTO assetclassgroup (assetclassgroup_name, color) VALUE ('$assetclassgroup_name', '$color')") or die(mysql_error()); - $assetclassgroup_id = mysql_insert_id(); + $assetclassgroup_name = sanitize($_POST['assetclassgroup_name']); + $assetclassgroup_color = preg_replace("|[^A-Z0-9]|", "", strtoupper(sanitize($_POST['assetclassgroup_color']))); + + // build query + $query = "INSERT + INTO + assetclassgroup( + assetclassgroup.assetclassgroup_name, + assetclassgroupassetclassgroup_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 ("assigniptoasset") : - // check permission - if($_SESSION['suser_level'] >= $config_userlevel_assigniptoasset) { - // get variables - $ip = $_POST['ip']; - $subnet_id = $_POST['subnet_id']; - $asset_id = $_POST['asset_id']; - $mac = strip_mac($_POST['mac']); - if ((!empty($_POST['dns1']) && isset($_POST['dns1suffix'])) ? $dns1 = $_POST['dns1'] . $config_dns1suffix : $dns1 = $_POST['dns1']); - if ((!empty($_POST['dns2']) && isset($_POST['dns2suffix'])) ? $dns2 = $_POST['dns2'] . $config_dns2suffix : $dns2 = $_POST['dns2']); - $node_info = $_POST['node_info']; - - // update db - mysql_query("INSERT INTO node (ip, mac, dns1, dns2, subnet_id, asset_id, node_info) VALUE ('$ip', '$mac', '$dns1', '$dns2', '$subnet_id', '$asset_id', '$node_info')") or die(mysql_error()); - - // redirect - header_location("assetview.php?asset_id=" . $asset_id); - } + 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.node_ip, + node.node_mac, + node.node_dns1, + node.node_dns2, + node.subnet_id, + node.asset_id, + node.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") : - // check permission - if($_SESSION['suser_level'] >= $config_userlevel_assignlocationtosubnet) { - // get variables - $location_id = $_POST['location_id']; - $subnet_id = $_POST['subnet_id']; - - // update db - mysql_query("INSERT INTO subnetlocation (location_id, subnet_id) VALUE ('$location_id', '$subnet_id')") or die(mysql_error()); - - // redirect - header_location("Location: location.php"); - } + // get variables + $location_id = sanitize($_POST['location_id']); + $subnet_id = sanitize($_POST['subnet_id']); + + // build query + $query = "INSERT + INTO + subnetlocation( + subnetlocation.location_id, + subnetlocation.subnet_id + ) + VALUE + ( + '$location_id', + '$subnet_id' + )"; + + // run query + $db->db_insert($query); + + // redirect + header_location("Location: location.php"); break; - case ("assignvlantosubnet") : - // check permission - if($_SESSION['suser_level'] >= $config_userlevel_assignvlantosubnet) { - // get variables - $vlan_id = $_POST['vlan_id']; - $subnet_id = $_POST['subnet_id']; - - // update db - mysql_query("UPDATE subnet SET vlan_id='$vlan_id' WHERE subnet_id='$subnet_id'") or die(mysql_error()); - - // redirect - header_location("vlanview.php?vlan_id=" . $vlan_id); - } + case ("assignsubnettovlan") : + // get variables + $subnet_id = sanitize($_POST['subnet_id']); + $vlan_id = sanitize($_POST['vlan_id']); + + // build query + $query = "UPDATE + subnet + SET + subnet.vlan_id='$vlan_id' + WHERE + subnet.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 = $_POST['location_name']; - $parent = $_POST['parent']; - $location_info = $_POST['location_info']; + $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.location_name, + location.location_parent, + location.location_info + ) + VALUE + ( + '$location_name', + '$location_parent', + '$location_info' + )"; + + // run query + $location_id = $db->db_update($query); - // check permission - auth("location", $config_auth_locationadd, 0); - - // update db - mysql_query("INSERT INTO location (location_name, parent, location_info) VALUE ('$location_name', '$parent', '$location_info')") or die(mysql_error()); - $location_id = mysql_insert_id(); + // 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( + subnetlocation.location_id, + subnetlocation.subnet_id + ) + VALUE + ( + '$location_id', + '$subnet_id' + )"; + + // run query + $location_id = $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.nat_ext, + nat.nat_int, + nat.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 = $_POST['asset_name']; - $hostname = $_POST['hostname']; - $assetclass_id = $_POST['assetclass_id']; - $ip = $_POST['ip']; - $mac = strip_mac($_POST['mac']); - if ((!empty($_POST['dns1']) && isset($_POST['dns1suffix'])) ? $dns1 = $_POST['dns1'] . $config_dns1suffix : $dns1 = $_POST['dns1']); - if ((!empty($_POST['dns2']) && isset($_POST['dns2suffix'])) ? $dns2 = $_POST['dns2'] . $config_dns2suffix : $dns2 = $_POST['dns2']); - $subnet_id = $_POST['subnet_id']; - - // check permission - auth("node", $config_auth_nodeadd, 0); - - $result = mysql_query("SELECT * FROM node WHERE ip='$ip'") or die(mysql_error()); - if (mysql_num_rows($result) == 0) { - // update db - mysql_query("INSERT INTO asset (asset_name, hostname, assetclass_id) VALUE ('$asset_name', '$hostname', '$assetclass_id')") or die(mysql_error()); - $asset_id = mysql_insert_id(); - mysql_query("INSERT INTO node (ip, mac, dns1, dns2, subnet_id, asset_id) VALUE ('$ip', '$mac', '$dns1', '$dns2', '$subnet_id', '$asset_id')") or die(mysql_error()); - $node_id = mysql_insert_id(); - - // redirect - header_location("assetview.php?asset_id=" . $asset_id); - } - // display error - $comments = "ipinuse"; + $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.asset_name, + asset.asset_hostname, + asset.assetclass_id + ) + VALUE + ( + '$asset_name', + '$asset_hostname', + '$assetclass_id' + )"; + + // run query + $asset_id = $db->db_insert($query); + + // build query + $query = "INSERT + INTO + node( + node.node_ip, + node.node_mac, + node.node_dns1, + node.node_dns2, + node.node_info, + node.subnet_id, + node.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= $_POST['subnet_address']; - $subnet_mask = $_POST['subnet_mask']; + $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.subnet_address, + subnet.subnet_mask, + subnet.subnet_info + ) + VALUE + ( + '$subnet_address', + '$subnet_mask', + '$subnet_info' + )"; + + // run query + $subnet_id = $db->db_insert($query); - // check permission - auth("subnet", $config_auth_subnetadd, 0); + // 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( + subnetlocation.location_id, + subnetlocation.subnet_id + ) + VALUE + ( + '$location_id', + '$subnet_id' + )"; + + // run query + $db->db_insert($query); - // update db - mysql_query("INSERT INTO subnet (subnet_address, subnet_mask) VALUE ('$subnet_address', '$subnet_mask')") or die(mysql_error()); - $subnet_id = mysql_insert_id(); + // 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( + subnetvlan.subnet_id, + subnetvlan.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 = $_POST['user_name']; - $user_pass = md5($config_user_pass); - $user_level = $_POST['user_level']; - $displayname = $_POST['user_name']; - $user_lang = $config_user_lang; - - // check permission - auth("user", $config_auth_useradd, 0); - - // check for unique username - $result = mysql_query("SELECT user_name FROM user WHERE user_name='$user_name'") or die(mysql_error()); - if(mysql_num_rows($result) == 0) { - // update db - mysql_query("INSERT INTO user (user_name, user_pass, user_level, user_displayname, user_lang) VALUE ('$user_name', '$user_pass', '$user_level', '$displayname', '$user_lang')") or die(mysql_error()); - $user_id = mysql_insert_id(); - + $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.user_name + FROM + user + WHERE + user.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.user_name, + user.user_displayname, + user.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 ("userclass") : + case ("vlan") : // get variables - $userclass_name = $_POST['userclass_name']; + $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.vlan_name, + vlan.vlan_number, + vlan.vlan_info + ) + VALUE + ( + '$vlan_name', + '$vlan_number', + '$vlan_info' + )"; + + // run query + $vlan_id = $db->db_insert($query); - // check permission - auth("userclass", $config_auth_userclassadd, 0); + // 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']); - // update db - mysql_query("INSERT INTO userclass (userclass_name) VALUE ('$userclass_name')") or die(mysql_error()); - $userclass_id = mysql_insert_id(); + // build query + $query = "INSERT + INTO + subnetvlan( + subnetvlan.subnet_id, + subnetvlan.vlan_id + ) + VALUE + ( + '$subnet_id', + '$vlan_id' + )"; + + // run query + $db->db_insert($query); // redirect - header_location("userclassview.php?userclass_id=" . $userclass_id); + header_location("vlanview.php?vlan_id=" . $vlan_id); break; - case ("userclassauth") : + } + } + + if (isset($_POST['del'])) { + switch ($_POST['del']) { + case ("asset") : // get variables - $userclass_id = $_POST['userclass_id']; - $authitem = $_POST['authitem']; - $item_id = $_POST['item_id']; - $auth = $_POST['auth']; - - // check permission - auth("userclassauth", $config_auth_userclassauthadd, 0); + $asset_id = sanitize($_POST['asset_id']); + + // delete asset + // build query + $query = "DELETE + FROM + asset + WHERE + asset.asset_id=" . $asset_id; + + // run query + $db->db_delete($query); + + // delete nodes + $query = "DELETE + FROM + node + WHERE + node.asset_id=" . $asset_id; + + // run query + $db->db_delete($query); - // update db - mysql_query("INSERT INTO userclassauth (userclass_id, item, id, auth) VALUE ('$userclass_id', '$authitem', '$item_id', '$auth')") or die(mysql_error()); - $userclassauth_id = mysql_insert_id(); - // redirect - header_location("userclassauth.php"); + header_location("asset.php"); break; - case ("vlan") : + case ("assetclass") : // get variables - $vlan_name = $_POST['vlan_name']; - $vlan_number= $_POST['vlan_number']; + $assetclass_id = sanitize($_POST['assetclass_id']); - // check permission - auth("vlan", $config_auth_vlanadd, 0); + // build query + $query = "DELETE + FROM + assetclass + WHERE + assetclass.assetclass_id=" . $assetclass_id; - // update db - mysql_query("INSERT INTO vlan (vlan_name, vlan_number) VALUE ('$vlan_name', '$vlan_number')") or die(mysql_error()); - $vlan_id = mysql_insert_id(); + // run query + $db->db_delete($query); // redirect - header_location("vlan.php?vlan_id=" . $vlan_id); + header_location("assetclass.php"); break; - } - } - - if (isset($_POST['edit'])) { - switch ($_POST['edit']) { - case ("asset") : + case ("assetclassgroup") : // get variables - $asset_id = $_POST['asset_id']; - $asset_name = $_POST['asset_name']; - $hostname = $_POST['hostname']; - $assetclass_id = $_POST['assetclass_id']; - $asset_info = $_POST['asset_info']; + $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']); - // check permission - auth("asset", $config_auth_assetedit, $asset_id); + // build query + $query = "DELETE + FROM + assetclassgroup + WHERE + assetclassgroup.assetclassgroup_id=" . $assetclassgroup_id; - // update db - mysql_query("UPDATE asset SET asset_name='$asset_name', hostname='$hostname', assetclass_id='$assetclass_id', asset_info='$asset_info' WHERE asset_id='$asset_id'") or die(mysql_error()) or die(mysql_error()); + // run query + $db->db_delete($query); // redirect - header_location("assetview.php?asset_id=" . $asset_id); + header_location("assetclassgroup.php"); break; - case ("assetclass") : + case ("location") : // get variables - $assetclass_id = $_POST['assetclass_id']; - $assetclass_name = $_POST['assetclass_name']; - $assetclassgroup_id = $_POST['assetclassgroup_id']; + $location_id = sanitize($_POST['location_id']); - // check permission - auth("assetclass", $config_auth_assetclassedit, $assetclass_id); + // build query + $query = "DELETE + FROM + location + WHERE + location.location_id=" . $location_id; - // update db - mysql_query("UPDATE assetclass SET assetclass_name='$assetclass_name', assetclassgroup_id='$assetclassgroup_id' WHERE assetclass_id='$assetclass_id'") or die(mysql_error()); + // run query + $db->db_delete($query); // redirect - header_location("assetclassview.php?assetclass_id=" . $assetclass_id); + header_location("location.php"); break; - case ("assetclassgroup") : + case ("locationsubnet") : // get variables - $assetclassgroup_id = $_POST['assetclassgroup_id']; - $assetclassgroup_name = $_POST['assetclassgroup_name']; - $color = strtoupper($_POST['color']); - $color = preg_replace("|[^a-zA-Z0-9]|", "", $color); + $location_id = sanitize($_POST['location_id']); + $subnet_id = sanitize($_POST['subnet_id']); - // check permission - auth("assetclassgroup", $config_auth_assetclassgroupedit, $assetclassgroup_id); + // build query + $query = "DELETE + FROM + subnetlocation + WHERE + subnetlocation.location_id=" . $location_id . " + AND subnetlocation.subnet_id=" . $subnet_id; - // update db - mysql_query("UPDATE assetclassgroup SET assetclassgroup_name='$assetclassgroup_name', color='$color' WHERE assetclassgroup_id='$assetclassgroup_id'") or die(mysql_error()); + // run query + $db->db_delete($query); // redirect - header_location("assetclassgroupview.php?assetclassgroup_id=" . $assetclassgroup_id); + header_location("locationview.php?location_id=" . $location_id); break; - case ("location") : + case ("nat") : // get variables - $location_id = $_POST['location_id']; - $location_name = $_POST['location_name']; - $parent = $_POST['parent']; - $location_info = $_POST['location_info']; + $node_id_ext = sanitize($_POST['node_id_ext']); + $node_id_int = sanitize($_POST['node_id_int']); - // check permission - auth("location", $config_auth_locationedit, $location_id); + // build query + $query = "DELETE + FROM + nat + WHERE + nat.nat_ext=" . $node_id_ext . " + AND nat.nat_int=" . $node_id_int; - // update db - mysql_query("UPDATE location SET location_name='$location_name', parent='$parent', location_info='$location_info' WHERE location_id='$location_id'") or die(mysql_error()) or die(mysql_error()); + // run query + $db->db_delete($query); // redirect - header_location("locationview.php?location_id=" . $location_id); + header_location("nodeview.php?node_id=" . $node_id_ext); break; case ("node") : // get variables - $node_id = $_POST['node_id']; - $asset_id = $_POST['asset_id']; - $subnet_id = $_POST['subnet_id']; - $mac = strip_mac($_POST['mac']); - $dns1 = $_POST['dns1']; - $dns2 = $_POST['dns2']; - $node_info = $_POST['node_info']; + $node_id = sanitize($_POST['node_id']); + $asset_id = sanitize($_POST['asset_id']); - // check permission - auth("node", $config_auth_nodeedit, $node_id); + // build query + $query = "DELETE + FROM + node + WHERE + node.node_id=" . $node_id; - // update db - mysql_query("UPDATE node SET asset_id='$asset_id', subnet_id='$subnet_id', mac='$mac', dns1='$dns1', dns2='$dns2', node_info='$node_info' WHERE node_id='$node_id'") or die(mysql_error()); + // run query + $db->db_delete($query); // redirect - header_location("nodeview.php?node_id=" . $node_id); + header_location("assetview.php?asset_id=" . $asset_id); break; case ("subnet") : // get variables - $subnet_id = $_POST['subnet_id']; - $subnet_address= $_POST['subnet_address']; - $subnet_mask = $_POST['subnet_mask']; - $vlan_id = $_POST['vlan_id']; - $subnet_info = $_POST['subnet_info']; + $subnet_id = sanitize($_POST['subnet_id']); + + // delete subnet + // build query + $query = "DELETE + FROM + subnet + WHERE + subnet.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); - // check permission - auth("subnet", $config_auth_subnetedit, $subnet_id); + // redirect + header_location("subnet.php"); + break; + case ("subnetlocation") : + // get variables + $location_id = sanitize($_POST['location_id']); + $subnet_id = sanitize($_POST['subnet_id']); - // update db - mysql_query("UPDATE subnet SET subnet_address='$subnet_address', subnet_mask='$subnet_mask', vlan_id='$vlan_id', subnet_info='$subnet_info' WHERE subnet_id='$subnet_id'") or die(mysql_error()); + // build query + $query = "DELETE + FROM + subnetlocation + WHERE + subnetlocation.location_id=" . $location_id . " + AND subnetlocation.subnet_id=" . $subnet_id; + + // run query + $db->db_delete($query); // redirect header_location("subnetview.php?subnet_id=" . $subnet_id); break; - case ("user") : + case ("subnetvlan") : // get variables - $user_id = $_POST['user_id']; - $user_name = $_POST['user_name']; - $user_displayname = $_POST['user_displayname']; - $user_mac = $_POST['user_mac']; - $user_lang = $_POST['user_lang']; + $subnet_id = sanitize($_POST['subnet_id']); + $vlan_id = sanitize($_POST['vlan_id']); - // check permission - auth("user", $config_auth_useredit, $user_id); + // build query + $query = "DELETE + FROM + subnetvlan + WHERE + subnetvlan.subnet_id=" . $subnet_id . " + AND subnetvlan.vlan_id=" . $vlan_id; - // update db - mysql_query("UPDATE user SET user_displayname='$user_displayname', user_mac='$user_mac', user_lang='$user_lang' WHERE user_id='$user_id'") or die(mysql_error()); - - // procedure to update useruserclass table - // 1) delete current users - mysql_query("DELETE FROM useruserclass WHERE user_id='$user_id'") or die(mysql_error()); - - // 2) loop checkbox array for userclass_id - foreach( $_POST['userclass_id'] AS $userclass_id) { - // and insert - mysql_query("INSERT INTO useruserclass (user_id, userclass_id) VALUE ('$user_id', '$userclass_id')") or die(mysql_error()); - } + // run query + $db->db_delete($query); // redirect - header_location("userview.php?user_id=" . $user_id); + header_location("subnetview.php?subnet_id=" . $subnet_id); break; - case ("userclass") : + case ("user") : // get variables - $userclass_id = $_POST['userclass_id']; - $userclass_name = $_POST['userclass_name']; - - // check permission - auth("userclass", $config_auth_userclassedit, $userclass_id); + $user_id = sanitize($_POST['user_id']); - // update db - mysql_query("UPDATE userclass SET userclass_name='$userclass_name' WHERE userclass_id='$userclass_id'") or die(mysql_error()); + // build query + $query = "DELETE + FROM + user + WHERE + user.user_id=" . $user_id; - // procedure to update useruserclass table - // 1) delete current users - mysql_query("DELETE FROM useruserclass WHERE userclass_id='$userclass_id'") or die(mysql_error()); + // run query + $db->db_delete($query); - // 2) loop checkbox array for user_id - foreach($_POST['user_id'] AS $user_id) { - // and insert - mysql_query("INSERT INTO useruserclass (user_id, userclass_id) VALUE ('$user_id', '$userclass_id')") or die(mysql_error()); - } - // redirect - header_location("userclassview.php?userclass_id=" . $userclass_id); + header_location("user.php"); break; - case ("userpass") : - // check variables - if (trim($_POST['user_passold']) <> "" && trim($_POST['user_passnew1']) && trim($_POST['user_passnew2']) && trim($_POST['user_passnew1']) == trim($_POST['user_passnew2'])) { - $suser_id = $_SESSION['suser_id']; - - // get variables - $user_passold = $_POST['user_passold']; - $user_passnew = md5($_POST['user_passnew1']); - - // get current pass - $result = mysql_query("SELECT user_pass FROM user WHERE user_id='$suser_id'") or die(mysql_error()); - // check current pass - if(!strcmp(md5($user_passold), mysql_result($result, 0, "user_pass"))) { - // update db - mysql_query("UPDATE user SET user_pass='$user_passnew' WHERE user_id='$suser_id'") or die(mysql_error()); - - // redirect - header_location("options.php"); - } - } + case ("vlan") : + // get variables + $vlan_id = sanitize($_POST['vlan_id']); - // display error - echo 'Error!'; + // build query + $query = "DELETE + FROM + vlan + WHERE + vlan.vlan_id=" . $vlan_id; + + // run query + $db->db_delete($query); + + // redirect + header_location("vlan.php"); break; - case ("vlan") : + case ("vlansubnet") : // get variables - $vlan_id = $_POST['vlan_id']; - $vlan_name = $_POST['vlan_name']; - $vlan_number = $_POST['vlan_number']; - $vlan_info = $_POST['vlan_info']; + $subnet_id = sanitize($_POST['subnet_id']); + $vlan_id = sanitize($_POST['vlan_id']); - // check permission - auth("vlan", $config_auth_vlanedit, $vlan_id); + // build query + $query = "DELETE + FROM + subnetvlan + WHERE + subnetvlan.subnet_id=" . $subnet_id . " + AND subnetvlan.vlan_id=" . $vlan_id; - // update db - mysql_query("UPDATE vlan SET vlan_name='$vlan_name', vlan_number='$vlan_number', vlan_info='$vlan_info' WHERE vlan_id='$vlan_id'") or die(mysql_error()); + // run query + $db->db_delete($query); // redirect header_location("vlanview.php?vlan_id=" . $vlan_id); break; } } - - if (isset($_POST['del'])) { - switch ($_POST['del']) { + + if (isset($_POST['edit'])) { + switch ($_POST['edit']) { case ("asset") : // get variables - $asset_id = $_POST['asset_id']; - - // check permission - auth("asset", $config_auth_assetdel, $asset_id); - - // update db - mysql_query("DELETE FROM asset WHERE asset_id='$asset_id'") or die(mysql_error()); - mysql_query("DELETE FROM node WHERE asset_id='$asset_id'") or die(mysql_error()); + $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.asset_name='$asset_name', + asset.asset_info='$asset_info', + asset.asset_hostname='$asset_hostname', + asset.assetclass_id='$assetclass_id' + WHERE + asset.asset_id=" . $asset_id; + + // run query + $db->db_update($query); // redirect - header_location("asset.php"); - break; + header_location("assetview.php?asset_id=" . $asset_id); case ("assetclass") : // get variables - $assetclass_id = $_POST['assetclass_id']; - - // check permission - auth("assetclass", $config_auth_assetclassdel, $assetclass_id); - - // update db - mysql_query("DELETE FROM assetclass WHERE assetclass_id='$assetclass_id'") or die(mysql_error()); + $assetclass_id = sanitize($_POST['assetclass_id']); + $assetclass_name = sanitize($_POST['assetclass_name']); + $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']); + + // build query + $query = "UPDATE + assetclass + SET + assetclass.assetclass_name='$assetclass_name', + assetclass.assetclassgroup_id='$assetclassgroup_id' + WHERE + assetclass.assetclass_id=" . $assetclass_id; + + // run query + $db->db_update($query); // redirect - header_location("assetclass.php"); + header_location("assetclassview.php?assetclass_id=" . $assetclass_id); break; case ("assetclassgroup") : // get variables - $assetclassgroup_id = $_POST['assetclassgroup_id']; - - // check permission - auth("assetclassgroup", $config_auth_assetclassgroupdel, $assetclassgroup_id); + $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 - mysql_query("DELETE FROM assetclassgroup WHERE assetclassgroup_id='$assetclassgroup_id'") or die(mysql_error()); + $query = "UPDATE + assetclassgroup + SET + assetclassgroup.assetclassgroup_name='$assetclassgroup_name', + assetclassgroup.assetclassgroup_color='$assetclassgroup_color' + WHERE + assetclassgroup.assetclassgroup_id=" . $assetclassgroup_id; + + // run query + $db->db_update($query); // redirect - header_location("assetclassgroup.php"); + header_location("assetclassgroupview.php?assetclassgroup_id=" . $assetclassgroup_id); break; case ("location") : // get variables - $location_id = $_POST['location_id']; - - // check permission - auth("location", $config_auth_locationdel, $location_id); + $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 - mysql_query("DELETE FROM location WHERE location_id='$location_id'") or die(mysql_error()); + $query = "UPDATE + location + SET + location.location_name='$location_name', + location.location_parent='$parentlocation_id', + location.location_info='$location_info' + WHERE + location.location_id=" . $location_id; + + // run query + $db->db_update($query); // redirect - header_location("location.php"); + header_location("locationview.php?location_id=" . $location_id); break; case ("node") : // get variables - $node_id = $_POST['node_id']; - $asset_id = $_POST['asset_id']; - - // check permission - auth("node", $config_auth_nodedel, $node_id); + $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']); // update db - mysql_query("DELETE FROM node WHERE node_id='$node_id'") or die(mysql_error()); + $query = "UPDATE + node + SET + node.asset_id='$asset_id', + node.node_ip='$node_ip', + node.subnet_id='$subnet_id', + node.node_mac='$node_mac', + node.node_dns1='$node_dns1', + node.node_dns2='$node_dns2', + node.node_info='$node_info' + WHERE + node.node_id=" . $node_id; + + // run query + $db->db_update($query); // redirect - header_location("assetview.php?asset_id=" . $asset_id); + header_location("nodeview.php?node_id=" . $node_id); break; - case ("subnet") : + case ("optionsdisplay") : // get variables - $subnet_id = $_POST['subnet_id']; - - // check permission - auth("subnet", $config_auth_subnetdel, $subnet_id); + $user_id = $_SESSION['suser_id']; + $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']); // update db - mysql_query("DELETE FROM subnet WHERE subnet_id='$subnet_id'") or die(mysql_error()); - mysql_query("DELETE FROM node WHERE subnet_id='$subnet_id'") or die(mysql_error()); + $query = "UPDATE + user + SET + user.user_imagesize='" . $user_imagesize . "', + user.user_imagecount='" . $user_imagecount . "', + user.user_mac='" . $user_mac . "', + user.user_dateformat='" . $user_dateformat . "', + user.user_dns1suffix='" . $user_dns1suffix . "', + user.user_dns2suffix='" . $user_dns2suffix . "', + user.user_menu_assets='" . $user_menu_assets . "', + user.user_menu_assetclasses='" . $user_menu_assetclasses . "', + user.user_menu_assetclassgroups='" . $user_menu_assetclassgroups . "', + user.user_menu_locations='" . $user_menu_locations . "', + user.user_menu_nodes='" . $user_menu_nodes . "', + user.user_menu_subnets='" . $user_menu_subnets . "', + user.user_menu_users='" . $user_menu_users . "', + user.user_menu_vlans='" . $user_menu_vlans . "' + WHERE + user.user_id=" . $user_id; + + // update session + $_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; + + // run query + $db->db_update($query); // redirect - header_location("subnet.php"); + header_location("options.php"); break; - case ("user") : + case ("optionspassword") : // get variables - $user_id = $_POST['user_id']; - - // check permission - auth("user", $config_auth_userdel, $user_id); + $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.user_pass + FROM + user + WHERE + user.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.user_pass='" . md5($user_newpass1) . "' + WHERE + user.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_mask = sanitize($_POST['subnet_mask']); + $subnet_info = sanitize($_POST['subnet_info']); // update db - mysql_query("DELETE FROM user WHERE user_id='$user_id'") or die(mysql_error()); + $query = "UPDATE + subnet + SET + subnet.subnet_address='$subnet_address', + subnet.subnet_mask='$subnet_mask', + subnet.subnet_info='$subnet_info' + WHERE + subnet.subnet_id=" . $subnet_id; + + // run query + $db->db_update($query); // redirect - header_location("user.php"); + header_location("subnetview.php?subnet_id=" . $subnet_id); break; - case ("userclass") : + case ("user") : // get variables - $userclass_id = $_POST['userclass_id']; - - // check permission - auth("userclass", $config_auth_userclassdel, $userclass_id); + $user_id = sanitize($_POST['user_id']); + $user_name = sanitize($_POST['user_name']); + $user_displayname = sanitize($_POST['user_displayname']); // update db - mysql_query("DELETE FROM userclass WHERE userclass_id='$userclass_id'") or die(mysql_error()); + $query = "UPDATE + user + SET + user.user_name='" . $user_name . "', + user.user_displayname='" . $user_displayname . "' + WHERE + user.user_id=" . $user_id; + + // run query + $db->db_update($query); // redirect - header_location("userclass.php"); + header_location("userview.php?user_id=" . $user_id); break; case ("vlan") : // get variables - $vlan_id = $_POST['vlan_id']; - - // check permission - auth("vlan", $config_auth_vlandel, $vlan_id); + $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 - mysql_query("DELETE FROM vlan WHERE vlan_id='$vlan_id'") or die(mysql_error()); + $query = "UPDATE + vlan + SET + vlan.vlan_name='$vlan_name', + vlan.vlan_number='$vlan_number', + vlan.vlan_info='$vlan_info' + WHERE + vlan.vlan_id=" . $vlan_id; + + // run query + $db->db_update($query); // redirect - header_location("vlan.php"); + header_location("vlanview.php?vlan_id=" . $vlan_id); break; } } @@ -579,7 +1150,7 @@ // still not redirected, check for error if(empty($comments)) { - $comments = "notallowed"; + $comments = "error"; } // redirect diff --git a/subnet.php b/subnet.php index 62815ee..84d1b6a 100644 --- a/subnet.php +++ b/subnet.php @@ -1,7 +1,7 @@ setvars($lang); - // set language variables - $tp->setvars($lang); + // setup subnet + // build query + $query = "SELECT + subnet.subnet_id AS subnet_id, + subnet.subnet_address AS subnet_address, + subnet.subnet_mask AS subnet_mask, + COUNT(node.subnet_id) AS node_counter + FROM + subnet + LEFT JOIN + node + ON + node.subnet_id=subnet.subnet_id + GROUP BY + subnet.subnet_id + ORDER BY + INET_ATON(subnet.subnet_address)"; + + // run query + $subnets = $db->db_select($query); + + // count results + $subnet_counter = count($subnets); + + // counter to tpl + $tp->set("subnet_counter", $subnet_counter); - // get subnet info - $result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("subnet_id", $row->subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); - $tp->parse("subnetrow"); - } - if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet")); + // any subnets? + if ($subnet_counter>0) { + // get objects + foreach($subnets AS $subnet) { + // send to tpl + $tp->set("subnet_id", $subnet['subnet_id']); + $tp->set("subnet_address", $subnet['subnet_address']); + $tp->set("subnet_mask", $subnet['subnet_mask']); + $tp->set("node_counter", $subnet['node_counter']); + + // parse row + $tp->parse("subnet_row"); + } + + // parse block + $tp->parse("subnet_table"); + } else { + // hide block + $tp->hide("subnet_table"); + } - // output - $tp->parse(); - $tp->spit(); + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/subnetadd.php b/subnetadd.php index 451385d..ecd5654 100644 --- a/subnetadd.php +++ b/subnetadd.php @@ -1,7 +1,7 @@ setvars($lang); - - // output - $tp->parse(); - $tp->spit(); + // get id + if((isset($_GET['vlan_id'])) ? $vlan_id = sanitize($_GET['vlan_id']) : $vlan_id = ""); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/subnetadd.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/subnetdel.php b/subnetdel.php index 3382da5..00aaba2 100644 --- a/subnetdel.php +++ b/subnetdel.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); + + // get id + $subnet_id = sanitize($_GET['subnet_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/subnetdel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - // get subnet info - $result = mysql_query("SELECT subnet_address, subnet_mask FROM subnet WHERE subnet_id='$subnet_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("subnet_id", $subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); + // 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); + + // send to tpl + $tp->set("subnet_id", $subnet_id); + $tp->set("subnet_address", $subnet[0]['subnet_address']); + $tp->set("subnet_mask", $subnet[0]['subnet_mask']); - // get node info - $result = mysql_query("SELECT node_id, ip, mac, dns1, dns2, node_info FROM node WHERE subnet_id='$subnet_id' ORDER BY INET_ATON(ip)") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("node_id", $row->node_id); - $tp->set("ip", $row->ip); - $tp->parse("noderow"); - } - if (($i>0) ? $tp->parse("node") : $tp->hide("node")); + // setup node + // build query + $query = "SELECT + node.node_id AS node_id, + node.node_ip AS node_ip + FROM + node + WHERE + node.subnet_id=" . $subnet_id . " + ORDER BY + INET_ATON(node.node_ip)"; + + // run query + $nodes = $db->db_select($query); + + // count results + $node_counter = count($nodes); + + // any nodes? + if ($node_counter>0) { + // get objects + foreach($nodes AS $node) { + // set id + $tp->set("node_id", $node['node_id']); + $tp->set("node_ip", $node['node_ip']); + + // parse row + $tp->parse("node_row"); + } + + // parse block + $tp->parse("node_table"); + } else { + // hide block + $tp->hide("node_table"); + } - // output - $tp->parse(); - $tp->spit(); + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/subnetedit.php b/subnetedit.php index 0036f2f..08269c8 100644 --- a/subnetedit.php +++ b/subnetedit.php @@ -1,7 +1,7 @@ setvars($lang); - // get id - $subnet_id = $_GET['subnet_id']; + // setup subnet + // build query + $query = "SELECT + subnet.subnet_address AS subnet_address, + subnet.subnet_mask AS subnet_mask, + subnet.subnet_info AS subnet_info + FROM + subnet + WHERE + subnet.subnet_id=" . $subnet_id; + + // run query + $subnet = $db->db_select($query); + + // send to tpl + $tp->set("subnet_id", $subnet_id); + $tp->set("subnet_address", $subnet[0]['subnet_address']); + $tp->set("subnet_mask", $subnet[0]['subnet_mask']); + $tp->set("subnet_info", $subnet[0]['subnet_info']); - // check authorisation - $auth = auth("subnet", $config_auth_subnetedit, $subnet_id); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/subnetedit.tpl"); - - // set language variables - $tp->setvars($lang); - - // get subnet information - $result = mysql_query("SELECT subnet_address, subnet_mask, vlan_id, subnet_info FROM subnet WHERE subnet_id='$subnet_id'") or die(mysql_error()); - $row = mysql_fetch_object($result); - $vlan_id = $row->vlan_id; - $tp->set("subnet_id", $subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); - $tp->set("vlan_id", $vlan_id); - $tp->set("subnet_info", $row->subnet_info); - - // get vlan info - $result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan ORDER BY vlan_number") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - if (($row->vlan_id==$vlan_id) ? $tp->set("selected", "selected") : $tp->set("selected", "")); - $tp->set("vlan_id", $row->vlan_id); - $tp->set("vlan_name", $row->vlan_name); - $tp->set("vlan_number", $row->vlan_number); - $tp->parse("vlanrow"); - } - if (($i>0) ? $tp->parse("vlan") : $tp->hide("vlan")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/subnetlocationadd.php b/subnetlocationadd.php new file mode 100644 index 0000000..01f7c26 --- /dev/null +++ b/subnetlocationadd.php @@ -0,0 +1,108 @@ +. + + 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 template + $tp = new Template("tpl/subnetlocationadd.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($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); + + $tp->set("subnet_id", $subnet_id); + $tp->set("subnet_address", $subnet[0]['subnet_address']); + $tp->set("subnet_mask", $subnet[0]['subnet_mask']); + + // start parent + // build query + $query = "SELECT + location.location_id AS location_id, + location.location_name AS location_name, + location.location_parent AS location_parent + FROM + location + WHERE + location.location_id NOT IN ( + SELECT + location_id + FROM + subnetlocation + WHERE + subnet_id=" . $subnet_id . " + ) + ORDER BY + location.location_name"; + + // run query + $locations = $db->db_select($query); + + // count results + $location_counter = count($locations); + + // any locations? + if ($location_counter>0) { + // get objects + foreach($locations AS $location) { + // send to tpl + $tp->set("location_id", $location['location_id']); + $tp->set("location_name", $location['location_name']); + + // parse row + $tp->parse("location_row"); + } + + // parse block + $tp->parse("location_table"); + } else { + // hide block + $tp->hide("location_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/subnetlocationdel.php b/subnetlocationdel.php new file mode 100644 index 0000000..d6449cf --- /dev/null +++ b/subnetlocationdel.php @@ -0,0 +1,102 @@ +. + + 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 template + $tp = new Template("tpl/subnetlocationdel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($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); + + $tp->set("subnet_id", $subnet_id); + $tp->set("subnet_address", $subnet[0]['subnet_address']); + $tp->set("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 + $locations = $db->db_select($query); + + // count results + $location_counter = count($locations); + + // any locations? + if ($location_counter>0) { + // get objects + foreach($locations AS $location) { + // send to tpl + $tp->set("location_id", $location['location_id']); + $tp->set("location_name", $location['location_name']); + + // parse row + $tp->parse("location_row"); + } + + // parse block + $tp->parse("location_table"); + } else { + // hide block + $tp->hide("location_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/subnetlocationedit.php b/subnetlocationedit.php new file mode 100644 index 0000000..6ce523b --- /dev/null +++ b/subnetlocationedit.php @@ -0,0 +1,63 @@ +. + + 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 template + $tp = new Template("tpl/subnetlocationedit.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($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); + + $tp->set("subnet_id", $subnet_id); + $tp->set("subnet_address", $subnet[0]['subnet_address']); + $tp->set("subnet_mask", $subnet[0]['subnet_mask']); + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/subnetview.php b/subnetview.php index 9f57b55..2ced9b5 100644 --- a/subnetview.php +++ b/subnetview.php @@ -1,7 +1,7 @@ setvars($lang); - // set template - $tp = new Template("tpl/subnetview.tpl"); + // setup subnet + // build query + $query = "SELECT + subnet.subnet_address AS subnet_address, + subnet.subnet_mask AS subnet_mask, + subnet.subnet_info AS subnet_info, + COUNT(node.subnet_id) AS node_counter + FROM + subnet + LEFT JOIN + node + ON + node.subnet_id=subnet.subnet_id + WHERE + subnet.subnet_id=" . $subnet_id . " + GROUP BY + subnet.subnet_id"; + + // run query + $subnet = $db->db_select($query); + + // set needed variables + $subnet_address = $subnet[0]['subnet_address']; + $subnet_mask = $subnet[0]['subnet_mask']; + + // 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); + + // send to tpl + $tp->set("subnet_id", $subnet_id); + $tp->set("subnet_address", $subnet_address); + $tp->set("subnet_mask", $subnet_mask); + $tp->set("subnet_info", nl2br($subnet[0]['subnet_info'])); + $tp->set("node_counter", $node_counter); + $tp->set("subnet_usedpercentage", $subnet_usedpercentage); + $tp->set("config_color_unused", $config_color_unused); + $tp->set("host_counter", $host_counter-2); + $tp->set("free_counter", (($host_counter-2)-$node_counter)); - // set language variables - $tp->setvars($lang); + // setup 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 + $tp->set("iprange1", $iprange1); + $tp->set("iprange2", $iprange2); + $tp->set("iprange3", $iprange3); + $tp->set("iprange4", $iprange4); + $tp->set("subnetmask1", 255); + $tp->set("subnetmask2", 255); + $tp->set("subnetmask3", 255); + $tp->set("subnetmask4", 256-$host_counter); + + // no pagination needed + $tp->parse("noselect"); + $tp->hide("one_select"); + $tp->hide("two_select"); + + // 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 + $tp->set("iprange1", $iprange1); + $tp->set("iprange2", $iprange2); + + // loop addresses in range3 + for($i=$iprange3;$i<(pow(2,(32-$subnet_mask))/256);$i++) { + // send to tpl + $tp->set("iprange3", $i); + $tp->set("iprange4", 0); + + // set select box + if($i==$page2) { + $tp->set("row_selected", "selected"); + + } else { + $tp->set("row_selected", ""); + } + + // parse block + $tp->parse("one_select_row"); + } + + $tp->set("subnetmask1", 255); + $tp->set("subnetmask2", 255); + $tp->set("subnetmask3", 256-($host_counter/256)); + $tp->set("subnetmask4", 0); + + // one select box + $tp->hide("noselect"); + $tp->parse("one_select"); + $tp->hide("two_select"); + + // set displayed nodes + $nodes_displayed = 256; + } else { + // Class A + // which part do we want to see? + if((empty($page)) ? $page=$subnet_address : $page=$page); + $page = explode('.', $page); + $page2 = $page[1]; + $page3 = $page[2]; + + // fill subnet-array with addresses we want to see + for($i=0;$i<256;$i++) { + // build ip + $ip = $iprange1 . '.' . $page2 . '.' . $page3 . '.' . $i; + + // fill subnet-array + $subnet[$ip] = array(); + } + + // calculate broadcast address + $broadcast_address = $iprange1 . '.' . ($iprange2+$i-1) . '.255.255'; + + // to tpl + $tp->set("iprange1", $iprange1); + $tp->set("iprange2", $iprange2); + + // loop addresses in range 2 + for($i=$iprange2;$i<(pow(2,(24-$subnet_mask))/256);$i++) { + // send to tpl + $tp->set("iprange1", $iprange1); + $tp->set("iprange2", $i); + $tp->set("iprange3", $page3); + $tp->set("iprange4", $iprange4); + + // set select box + if($i==$page2) { + $tp->set("row1_selected", "selected"); + + } else { + $tp->set("row1_selected", ""); + } + + // parse block + $tp->parse("two_select_row1"); + } + + // loop addresses in range 3 + for($i=0;$i<256;$i++) { + // send to tpl + $tp->set("iprange1", $iprange1); + $tp->set("iprange2", $page2); + $tp->set("iprange3", $i); + $tp->set("iprange4", $iprange4); + + // set select box + if($i==$page3) { + $tp->set("row2_selected", "selected"); + + } else { + $tp->set("row2_selected", ""); + } + + // parse block + $tp->parse("two_select_row2"); + } + + $tp->set("subnetmask1", 255); + $tp->set("subnetmask2", 256-($host_counter/65536)); + $tp->set("subnetmask3", 0); + $tp->set("subnetmask4", 0); + + // one select box + $tp->hide("noselect"); + $tp->hide("one_select"); + $tp->parse("two_select"); + + // set displayed nodes + $nodes_displayed = 256; + } - // get subnet info - $result = mysql_query("SELECT subnet_address, subnet_mask, vlan_id, subnet_info FROM subnet WHERE subnet_id='$subnet_id'") or die(mysql_error()); - $row = mysql_fetch_object($result); - $tp->set("subnet_id", $subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); - $tp->set("subnet_info", nl2br($row->subnet_info)); + // get nodes for this subnetview and implement the values into the array + // build query + $query = "SELECT + asset.asset_name AS asset_name, + assetclassgroup.assetclassgroup_color AS assetclassgroup_color, + node.node_id AS node_id, + node.node_ip AS node_ip + FROM + asset, + assetclass, + assetclassgroup, + node + WHERE + node.node_ip IN ('".implode("','",array_keys($subnet))."') + AND node.subnet_id='$subnet_id' + AND asset.asset_id=node.asset_id + AND assetclass.assetclass_id=asset.assetclass_id + AND assetclassgroup.assetclassgroup_id=assetclass.assetclassgroup_id"; + + // run query + $nodes = $db->db_select($query); + + // count results + $node_counter = count($nodes); + + // any nodes? + if ($node_counter>0) { + // get objects + foreach($nodes AS $node) { + // add node-values to ip in subnet-array + $subnet[$node['node_ip']] = $node; + + } + } - // set needed variables - $subnet_address = $row->subnet_address; - $subnet_mask = $row->subnet_mask; - $vlan_id = $row->vlan_id; + // replace ip's in subnet-array (if necessary) + // check for subnet address + if(array_key_exists($subnet_address, $subnet)) { + // replace + $subnet[$subnet_address] = array("subnet_address"); + } + + // check for broadcast address + if(array_key_exists($broadcast_address, $subnet)) { + // replace + $subnet[$broadcast_address] = array("broadcast_address"); + } - // split up the range - $iprange = explode('.', $subnet_address); - $iprange1 = $iprange[0]; - $iprange2 = $iprange[1]; - $iprange3 = $iprange[2]; - $iprange4 = $iprange[3]; + // loop subnet-array and send to template + // start counter + $i=1; + + // loop subnet-array + foreach($subnet AS $node_ip => $node) { + // make new line? + if(($i%$_SESSION['suser_imagecount']==0 && $i!=$nodes_displayed) ? $tr="" : $tr=""); + + // check node + if(empty($node)) { + // empty node to tpl + $tp->set("url", 'assigniptonode.php?subnet_id=' . $subnet_id . '&node_ip='. $node_ip); + $tp->set("remotetext", $node_ip); + $tp->set("assetclassgroup_color", $config_color_unused); + } else if ($node[0]=="subnet_address") { + // subnet address to tpl + $tp->set("url", ""); + $tp->set("remotetext", $node_ip . ' ' . $lang['lang_subnet_subnetaddress']); + $tp->set("assetclassgroup_color", $config_color_blocked); + } else if ($node[0]=="broadcast_address") { + // broadcast address to tpl + $tp->set("url", ""); + $tp->set("remotetext", $node_ip . ' ' . $lang['lang_subnet_broadcastaddress']); + $tp->set("assetclassgroup_color", $config_color_blocked); + } else { + // node to tpl + $tp->set("url", 'nodeview.php?node_id=' . $node['node_id']); + $tp->set("remotetext", $node_ip . ' ' . $node['asset_name']); + $tp->set("assetclassgroup_color", $node['assetclassgroup_color']); + } + + // set other vars + $tp->set("tr", $tr); + + // parse block + $tp->parse("node_row"); + + // update counter + $i++; + } + + // parse block + $tp->parse("node_table"); - // create array for these addresses - $subnet = array(); - if ($subnet_mask>=24) { - // Class C - // calculate hosts - $hostcount = pow(2,(32-$subnet_mask)); - - // fill array with addresses we want to see - for($i=0;$i<$hostcount;$i++) { - $ip = $iprange1 . '.' . $iprange2 . '.' . $iprange3 . '.' . ($iprange4+$i); - $subnet[$ip] = array(); - } + // setup vlan + // build query + $query = "SELECT + vlan.vlan_id AS vlan_id, + vlan.vlan_name AS vlan_name, + vlan.vlan_number AS vlan_number + FROM + subnetvlan, + vlan + WHERE + subnetvlan.subnet_id=" . $subnet_id . " + AND vlan.vlan_id=subnetvlan.vlan_id + ORDER BY + vlan.vlan_name"; - // calculate broadcast address - $broadcast_address = $iprange1 . '.' . $iprange2 . '.' . $iprange3 . '.' . ($iprange4+$i-1); - - // no pagination needed - $tp->set("pagination", ' '); - } 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 array with addresses we want to see - for($i=0;$i<256;$i++) { - $ip = $iprange1 . '.' . $iprange2 . '.' . $page2 . '.' . $i; - $subnet[$ip] = array(); - } + // run query + $vlans = $db->db_select($query); - // calculate broadcast address - $broadcast_address = $iprange1 . '.' . $iprange2 . '.' . ($iprange3+$i-1) . '.255'; + // count results + $vlan_counter = count($vlans); - // create pagination - $pagination = 'Page: ' . $iprange1 . '.' . $iprange2 . '. '; - $pagination .= ''; - $tp->set("pagination", $pagination); - } else { - // Class A - // which part do we want to see? - if((empty($page)) ? $page=$subnet_address : $page=$page); - $page = explode('.', $page); - $page2 = $page[1]; - $page3 = $page[2]; - - // fill array with addresses we want to see - for($i=0;$i<256;$i++) { - $ip = $iprange1 . '.' . $page2 . '.' . $page3 . '.' . $i; - $subnet[$ip] = array(); + // counter to tpl + $tp->set("vlan_counter", $vlan_counter); + + // any nodes? + if ($vlan_counter>0) { + // get objects + foreach($vlans AS $vlan) { + // send to tpl + $tp->set("vlan_id", $vlan['vlan_id']); + $tp->set("vlan_name", $vlan['vlan_name']); + $tp->set("vlan_number", $vlan['vlan_number']); + + // parse block + $tp->parse("vlan_row"); + } + // parse block + $tp->parse("vlan_table"); + } else { + // parse block + $tp->hide("vlan_table"); } + + // setup location + // build query + $query = "SELECT + location.location_id, + location.location_name + FROM + location + LEFT JOIN + subnetlocation + ON + subnetlocation.location_id=location.location_id + WHERE + subnetlocation.subnet_id=". $subnet_id . " + ORDER BY + location.location_name"; - // calculate broadcast address - $broadcast_address = $iprange1 . '.' . ($iprange+$i-1) . '.255.255'; + // run query + $locations = $db->db_select($query); - // create pagination - $pagination = 'Page: '; - // selectbox 1 - $pagination .= ''; - $tp->set("pagination", $pagination); - } - - // get nodes for this subnet and implement the values into the array - $result = mysql_query("SELECT a.asset_name, acg.color, n.node_id, n.ip FROM asset a, assetclass ac, assetclassgroup acg, node n WHERE n.ip IN ('".implode("','",array_keys($subnet))."') AND n.subnet_id='$subnet_id' AND a.asset_id=n.asset_id AND ac.assetclass_id=a.assetclass_id AND acg.assetclassgroup_id=ac.assetclassgroup_id") or die(mysql_error()); - while ($row = mysql_fetch_array($result)) { - $subnet[$row['ip']] = $row; - } - // replace subnet address (if in array) - if(array_key_exists($subnet_address, $subnet)) { - $subnet[$subnet_address]=array("subnet_address"); - } + // setup assetclassgroup + // build query + $query = "SELECT + assetclassgroup.assetclassgroup_id, + assetclassgroup.assetclassgroup_name, + assetclassgroup.assetclassgroup_color, + (SELECT + COUNT(node.node_id) + FROM + asset, + assetclass, + node + WHERE + asset.assetclass_id=assetclass.assetclass_id + AND assetclass.assetclassgroup_id=assetclassgroup.assetclassgroup_id + AND node.asset_id=asset.asset_id + AND node.subnet_id=" . $subnet_id . ") AS node_counter + FROM + assetclassgroup + GROUP BY + assetclassgroup.assetclassgroup_id + ORDER BY + assetclassgroup.assetclassgroup_name"; - // replace broadcast address (if in array) - if(array_key_exists($broadcast_address, $subnet)) { - $subnet[$broadcast_address]=array("broadcast_address"); - } - - // loop array and send to template - $i=1; - foreach($subnet as $ip => $node) { - if(($i%64==0) ? $tr="" : $tr=""); - if(empty($node)) { - $tp->set("url", 'assigniptonode.php?subnet_id=' . $subnet_id . '&ip='. $ip); - $tp->set("remotetext", $ip); - $tp->set("color", $config_color_unused); - } else if ($node[0]=="subnet_address") { - $tp->set("url", ""); - $tp->set("remotetext", $ip . ' ' . $lang['lang_subnet_subnetaddress']); - $tp->set("color", $config_color_blocked); - } else if ($node[0]=="broadcast_address") { - $tp->set("url", ""); - $tp->set("remotetext", $ip . ' ' . $lang['lang_subnet_broadcastaddress']); - $tp->set("color", $config_color_blocked); + // run query + $assetclassgroups = $db->db_select($query); + + // count results + $assetclassgroup_counter = count($assetclassgroups); + + // counter to tpl + $tp->set("assetclassgroup_counter", $assetclassgroup_counter); + + // any nodes? + if ($assetclassgroup_counter>0) { + // get objects + foreach($assetclassgroups AS $assetclassgroup) { + // send to tpl + $tp->set("assetclassgroup_id", $assetclassgroup['assetclassgroup_id']); + $tp->set("assetclassgroup_name", $assetclassgroup['assetclassgroup_name']); + $tp->set("assetclassgroup_color", $assetclassgroup['assetclassgroup_color']); + + $tp->set("assetclassgroup_node_counter", $assetclassgroup['node_counter']); + + // parse block + $tp->parse("assetclassgroup_row"); + } + // parse block + $tp->parse("assetclassgroup_table"); } else { - $tp->set("url", 'nodeview.php?node_id=' . $node['node_id']); - $tp->set("remotetext", $ip . ' ' . $node['asset_name']); - $tp->set("color", $node['color']); + // parse block + $tp->hide("assetclassgroup_table"); } - $tp->set("tr", $tr); - $tp->parse("iprow"); - $i++; - } - $tp->parse("subnet"); - - - // get vlan info - $result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan WHERE vlan_id='$vlan_id'") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("vlan_id", $row->vlan_id); - $tp->set("vlan_name", $row->vlan_name); - $tp->parse("vlanrow"); - } - if (($i>0) ? $tp->parse("vlan") : $tp->hide("vlan")); - - // get location info - $result = mysql_query("SELECT l.location_id, l.location_name FROM location l INNER JOIN subnetlocation sl ON l.location_id=sl.location_id WHERE sl.subnet_id='$subnet_id'") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("location_id", $row->location_id); - $tp->set("location_name", $row->location_name); - $tp->parse("locationrow"); - } - if (($i>0) ? $tp->parse("location") : $tp->hide("location")); - - // get assetclassgroup info - $result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name, color FROM assetclassgroup ORDER BY assetclassgroup_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("assetclassgroup_id", $row->assetclassgroup_id); - $tp->set("assetclassgroup_name", $row->assetclassgroup_name); - $tp->set("color", $row->color); - $tp->parse("assetclassgrouprow"); - } - if (($i>0) ? $tp->parse("assetclassgroup") : $tp->hide("assetclassgroup")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/subnetvlanadd.php b/subnetvlanadd.php new file mode 100644 index 0000000..a7bac61 --- /dev/null +++ b/subnetvlanadd.php @@ -0,0 +1,109 @@ +. + + 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 template + $tp = new Template("tpl/subnetvlanadd.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($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); + + $tp->set("subnet_id", $subnet_id); + $tp->set("subnet_address", $subnet[0]['subnet_address']); + $tp->set("subnet_mask", $subnet[0]['subnet_mask']); + + // setup vlan + // build query + $query = " SELECT + vlan.vlan_id AS vlan_id, + vlan.vlan_number AS vlan_number, + vlan.vlan_name AS vlan_name + FROM + vlan + WHERE + vlan.vlan_id NOT IN ( + SELECT + vlan_id + FROM + subnetvlan + WHERE + subnet_id=" . $subnet_id . " + ) + ORDER BY + vlan.vlan_number"; + + // run query + $vlans = $db->db_select($query); + + // count results + $vlan_counter = count($vlans); + + // any vlans? + if ($vlan_counter>0) { + // get objects + foreach($vlans AS $vlan) { + // send to tpl + $tp->set("vlan_id", $vlan['vlan_id']); + $tp->set("vlan_number", $vlan['vlan_number']); + $tp->set("vlan_name", $vlan['vlan_name']); + + // parse row + $tp->parse("vlan_row"); + } + + // parse block + $tp->parse("vlan_table"); + } else { + // hide block + $tp->hide("vlan_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/subnetvlandel.php b/subnetvlandel.php new file mode 100644 index 0000000..f29f3b4 --- /dev/null +++ b/subnetvlandel.php @@ -0,0 +1,104 @@ +. + + 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 template + $tp = new Template("tpl/subnetvlandel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($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); + + $tp->set("subnet_id", $subnet_id); + $tp->set("subnet_address", $subnet[0]['subnet_address']); + $tp->set("subnet_mask", $subnet[0]['subnet_mask']); + + // setup vlan + // build query + $query = "SELECT + vlan.vlan_id AS vlan_id, + vlan.vlan_number AS vlan_number, + vlan.vlan_name AS vlan_name + FROM + subnetvlan, + vlan + WHERE + subnetvlan.subnet_id=" . $subnet_id . " + AND vlan.vlan_id=subnetvlan.vlan_id + ORDER BY + vlan.vlan_number"; + + // run query + $vlans = $db->db_select($query); + + // count results + $vlan_counter = count($vlans); + + // any vlans? + if ($vlan_counter>0) { + // get objects + foreach($vlans AS $vlan) { + // send to tpl + $tp->set("vlan_id", $vlan['vlan_id']); + $tp->set("vlan_number", $vlan['vlan_number']); + $tp->set("vlan_name", $vlan['vlan_name']); + + // parse row + $tp->parse("vlan_row"); + } + + // parse block + $tp->parse("vlan_table"); + } else { + // hide block + $tp->hide("vlan_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/subnetvlanedit.php b/subnetvlanedit.php new file mode 100644 index 0000000..51cb614 --- /dev/null +++ b/subnetvlanedit.php @@ -0,0 +1,63 @@ +. + + 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 template + $tp = new Template("tpl/subnetvlanedit.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($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); + + $tp->set("subnet_id", $subnet_id); + $tp->set("subnet_address", $subnet[0]['subnet_address']); + $tp->set("subnet_mask", $subnet[0]['subnet_mask']); + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/tpl/about.tpl b/tpl/about.tpl index 157d8ec..5d20f5f 100644 --- a/tpl/about.tpl +++ b/tpl/about.tpl @@ -1,73 +1,118 @@ - +
-
- IP Reg {config_version} + + {lang_about}

- - + +
+ + + + - - - + + + + - + + + +
+ {lang_ipreg} {config_version} + +   +
- Sourceforge Project Page: + + {lang_about_sfprojectpage} + http://sourceforge.net/projects/ipreg
- License: + + {lang_about_license} + + {lang_about_gpl} +
+ {lang_about_yapter} - GNU General Public License (GPL) + + http://yapter.sourceforge.net +
+ {lang_about_iconset} + + http://www.famfamfam.com/lab/icons/silk/

- +
- - - -
- Yapter Template Engine - - http://yapter.sourceforge.net + + {lang_about_ipreg_ext}
- OWeb2 Images - - http://www.oweb2.com/free-web20-icons-pack + + {lang_about_license_ext}

- +
- + + + + + + + + + + + + + + + + + + +
- IP Reg, a PHP/MySQL IPAM tool
- Copyright (C) 2008 Wietse Warendorff

- - This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.

- - This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.

- - You should have received a copy of the GNU General Public License
- along with this program. If not, see http://www.gnu.org/licenses/. +

+ {lang_about_changelog} + +  
+ {lang_about_changelog_v05} + + {lang_about_changelog_v05_ext} +
+ {lang_about_changelog_v04} + + {lang_about_changelog_v04_ext} +
+ {lang_about_changelog_v03} + + {lang_about_changelog_v03_ext} +
+ {lang_about_changelog_v02} + + {lang_about_changelog_v02_ext} +
+ {lang_about_changelog_v01} + + {lang_about_changelog_v01_ext} +
\ No newline at end of file diff --git a/tpl/asset.tpl b/tpl/asset.tpl index 573f96b..5e77752 100644 --- a/tpl/asset.tpl +++ b/tpl/asset.tpl @@ -1,35 +1,49 @@ - +
-
- {lang_assets}: + + {lang_assets} ({asset_counter}) - + {lang_asset_add}

- [BLOCK table AS asset] - + [BLOCK letter_table AS letter_table] +
- + [BLOCK letter_row] + [END letter_row] + + + [END letter_table] + +

+ + [BLOCK asset_table AS asset_table] + + + + - [BLOCK assetrow] + [BLOCK asset_row] - - - [END assetrow] + [END asset_row]
+ {lang_asset_name} + + {lang_assetclass_name}
+ {asset_name} + {assetclass_name}
- [END table] \ No newline at end of file + [END asset_table] \ No newline at end of file diff --git a/tpl/assetadd.tpl b/tpl/assetadd.tpl index 4eb7904..002e786 100644 --- a/tpl/assetadd.tpl +++ b/tpl/assetadd.tpl @@ -1,58 +1,80 @@

- +
-
- {lang_asset_add}: + + {lang_asset_add} - + {lang_cancel} +

- +
- - + + + + - - - [BLOCK table AS assetclass] - - + +
- {lang_asset_name}: + + {lang_asset} + +   +
+ {lang_asset_name} +
- {lang_hostname}: + + {lang_asset_hostname} - + +
- {lang_assetclass}: + + {lang_asset_info} - + + +
+ +

+ + [BLOCK assetclass_table AS assetclass_table] + + + + - [END table] - -
+ {lang_assetclass} + +  
- {lang_asset_info}: + + {lang_assetclass_name} - + +
+ [END assetclass_table]

\ No newline at end of file diff --git a/tpl/assetclass.tpl b/tpl/assetclass.tpl index 9152bd2..a482acb 100644 --- a/tpl/assetclass.tpl +++ b/tpl/assetclass.tpl @@ -1,22 +1,35 @@ - +
-
- {lang_assetclass}:
+
+ {lang_assetclasses} ({assetclass_counter}) - + {lang_assetclass_add}
- [BLOCK table AS assetclass] - - [BLOCK assetclassrow] +

+ + [BLOCK assetclass_table AS assetclass_table] +

+ + + + + [BLOCK assetclass_row] - + - [END assetclassrow] + [END assetclass_row]
+ {lang_assetclass} + + {lang_assetclassgroup_name} +
+ {assetclass_name} + {assetclassgroup_name} +
- [END table] \ No newline at end of file + [END assetclass_table] \ No newline at end of file diff --git a/tpl/assetclassadd.tpl b/tpl/assetclassadd.tpl index b13fa14..a437295 100644 --- a/tpl/assetclassadd.tpl +++ b/tpl/assetclassadd.tpl @@ -1,41 +1,63 @@
- +
-
- {lang_assetclass_add}:
+
+ {lang_assetclass_add} - +

- +
- - + + + + - [BLOCK table AS assetclassgroup] +
- {lang_assetclass_name}: + + {lang_assetclass} + +   +
+ {lang_assetclass_name} +
+ +

+ + [BLOCK assetclassgroup_table AS assetclassgroup_table] + + + + + - - - [END table]
+ {lang_assetclassgroup} + +   +
- {lang_assetclassgroup}:
+
+ {lang_assetclassgroup} +
+ [END assetclassgroup_table] +

\ No newline at end of file diff --git a/tpl/assetclassdel.tpl b/tpl/assetclassdel.tpl index 8bd54ed..695d08e 100644 --- a/tpl/assetclassdel.tpl +++ b/tpl/assetclassdel.tpl @@ -2,27 +2,37 @@ - +
-
- {lang_assetclass_del}:
+
+ {lang_assetclass_del} - + {lang_cancel} +

- +
- - + + + +
- {lang_assetclass_name}: + + {lang_assetclass} - {assetclass_name} + +   +
+ {lang_assetclass_name} + + {assetclass_name}
+ \ No newline at end of file diff --git a/tpl/assetclassedit.tpl b/tpl/assetclassedit.tpl index 8149c85..5dafb45 100644 --- a/tpl/assetclassedit.tpl +++ b/tpl/assetclassedit.tpl @@ -2,41 +2,68 @@ - +
-
- {lang_assetclass_edit}:
+
+ {assetclass_name} - + {lang_cancel} +

- + [BLOCK assetclass_table AS assetclass_table] +
+ [BLOCK assetclass_row] - - + + + + - [BLOCK table AS assetclassgroup] + [END assetclass_row] +
- {lang_assetclass_name}: + + {lang_assetclass} + +   +
+ {lang_assetclass_name} +
+ [END assetclass_table] + +

+ + [BLOCK assetclassgroup_table AS assetclassgroup_table] + + + + + - - - [END table]
+ {lang_assetclassgroup} + +   +
- {lang_assetclassgroup}:
+
+ {lang_assetclassgroup} +
+ [END assetclassgroup_table] + \ No newline at end of file diff --git a/tpl/assetclassgroup.tpl b/tpl/assetclassgroup.tpl index c8d1d25..5d305cb 100644 --- a/tpl/assetclassgroup.tpl +++ b/tpl/assetclassgroup.tpl @@ -1,22 +1,29 @@ - +
-
- {lang_assetclassgroups}: + + {lang_assetclassgroups} ({assetclassgroup_counter}) - + {lang_assetclassgroup_add}
- [BLOCK table AS assetclassgroup] - - [BLOCK assetclassgrouprow] +

+ + [BLOCK assetclassgroup_table AS assetclassgroup_table] +

+ + + + [BLOCK assetclassgroup_row] - - [END assetclassgrouprow] + [END assetclassgroup_row]
+ {lang_assetclassgroup_name} +
+ {assetclassgroup_name}
- [END table] \ No newline at end of file + [END assetclassgroup_table] \ No newline at end of file diff --git a/tpl/assetclassgroupadd.tpl b/tpl/assetclassgroupadd.tpl index 4cad8e4..15eaecc 100644 --- a/tpl/assetclassgroupadd.tpl +++ b/tpl/assetclassgroupadd.tpl @@ -1,33 +1,42 @@

- +
-
- {lang_assetclassgroup_add}:
+
+ {lang_assetclassgroup_add} - + {lang_cancel} +

- +
- - + + + + - - diff --git a/tpl/assetclassgroupdel.tpl b/tpl/assetclassgroupdel.tpl index ac99895..27240cf 100644 --- a/tpl/assetclassgroupdel.tpl +++ b/tpl/assetclassgroupdel.tpl @@ -2,27 +2,37 @@ -
- {lang_assetclassgroup_name}: + + {lang_assetclassgroup} + +   +
+ {lang_assetclassgroup_name} +
- {lang_color}: + + {lang_color} +
+
-
- {lang_assetclassgroup_del}:
+
+ {assetclassgroup_name} - + {lang_cancel} +

- +
- - + + + +
- {lang_assetclassgroup_name}: + + {lang_assetclassgroup_del} - {assetclassgroup_name} + +   +
+ {lang_assetclassgroup_name} + + {assetclassgroup_name}
+

\ No newline at end of file diff --git a/tpl/assetclassgroupedit.tpl b/tpl/assetclassgroupedit.tpl index f43e53c..ae7016d 100644 --- a/tpl/assetclassgroupedit.tpl +++ b/tpl/assetclassgroupedit.tpl @@ -2,35 +2,47 @@ - +
-
- {lang_assetclassgroup_edit}:
+
+ {assetclassgroup_name} - + {lang_cancel} +

- + [BLOCK assetclassgroup_table AS assetclassgroup_table] +
- - + + + + - -
- {lang_assetclassgroup_name}: + + {lang_assetclassgroup} + +   +
+ {lang_assetclassgroup_name} +
- {lang_color}: + + {lang_color} - + +
+ [END assetclassgroup_table] + \ No newline at end of file diff --git a/tpl/assetclassgroupview.tpl b/tpl/assetclassgroupview.tpl index f1d81de..defc79d 100644 --- a/tpl/assetclassgroupview.tpl +++ b/tpl/assetclassgroupview.tpl @@ -1,45 +1,70 @@ - +
-
- {lang_assetclassgroup}:
+
+ {assetclassgroup_name} - - - + {lang_assetclass_add} + {lang_assetclassgroup_edit} + {lang_assetclassgroup_del}

- + [BLOCK assetclassgroup_table AS assetclassgroup_table] +
+ [BLOCK assetclassgroup_row] - - + + + + + + + + + [END assetclassgroup_row] +
- {lang_assetclassgroup_name}: + + {lang_assetclassgroup} - {assetclassgroup_name} + +   +
+ {lang_assetclassgroup_name} + + {assetclassgroup_name} +
+ {lang_color} + + {assetclassgroup_color}
+ [END assetclassgroup_table] + +

+ + - - - - [BLOCK table AS assetclass] - - [END table]
- {lang_color}: + + {lang_assetclass} - + +  
- {lang_assetclasses}: + + {lang_assetclasses} ({assetclass_counter}) - [BLOCK assetclassrow] + + [BLOCK assetclass_table AS assetclass_table] + [BLOCK assetclass_row] {assetclass_name}
- [END assetclassrow] + [END assetclass_row] + [END assetclass_table]
\ No newline at end of file diff --git a/tpl/assetclassview.tpl b/tpl/assetclassview.tpl index 62ea029..2c7cdb0 100644 --- a/tpl/assetclassview.tpl +++ b/tpl/assetclassview.tpl @@ -1,45 +1,86 @@ - +
-
- {lang_assetclass}:
+
+ {assetclass_name} - - - + {lang_asset_add} + {lang_assetclass_edit} + {lang_assetclass_add}

- + [BLOCK assetclass_table AS assetclass_table] +
+ [BLOCK assetclass_row] - - + + + + + [END assetclass_row] +
- {lang_assetclass_name}: + + {lang_assetclass} - {assetclass_name} + +   +
+ {lang_assetclass_name} + + {assetclass_name}
+ [END assetclass_table] + +

+ + [BLOCK assetclassgroup_table AS assetclassgroup_table] + - - - [BLOCK table AS asset] - + - +
- {lang_assetclassgroup_name}: + + {lang_assetclassgroup} - {assetclassgroup_name} + +  
- {lang_assets}:
+
+ {lang_assetclassgroup_name} + + {assetclassgroup_name}
- [BLOCK assetrow] +
+ [END assetclassgroup_table] + +

+ + + + + + + + + - [END table] -
+ {lang_assets} + +   +
+ {lang_assets} ({asset_counter}) + + [BLOCK asset_table AS asset_table] + [BLOCK asset_row] {asset_name}
- [END assetrow] + [END asset_row] + [END asset_table]
\ No newline at end of file + + \ No newline at end of file diff --git a/tpl/assetdel.tpl b/tpl/assetdel.tpl index b334d43..d20a3c6 100644 --- a/tpl/assetdel.tpl +++ b/tpl/assetdel.tpl @@ -2,25 +2,33 @@ - +
-
- {lang_asset_del}: + + {asset_name} - + {lang_cancel} +

- +
- - + + + @@ -28,24 +36,27 @@

- [BLOCK table AS node] -

- {lang_asset_name}: + + {lang_asset} + +   +
+ {lang_asset_name} + {asset_name}
+ [BLOCK node_table AS node_table] +
- + - [BLOCK noderow] + [BLOCK node_row] - - - [END noderow] + [END node_row]
-  {lang_comments_asset_del_nodes} + + {lang_warning} + + {lang_comments_asset_del_nodes}
- {lang_ip}: + + {lang_ip} - {ip} + + {node_ip}
- [END table] + [END node_table] \ No newline at end of file diff --git a/tpl/assetedit.tpl b/tpl/assetedit.tpl index 3bb51e7..eb216d2 100644 --- a/tpl/assetedit.tpl +++ b/tpl/assetedit.tpl @@ -1,59 +1,86 @@

+ - +
-
- {lang_asset_edit}:
+
+ {asset_name} - + {lang_cancel} +

- - + + [BLOCK asset_table AS asset_table] +
+ [BLOCK asset_row] + + + + - - - - - [BLOCK table AS assetclass] - - - [END table] + [END asset_row] +
+ {lang_asset} + +   +
- {lang_asset_name}: + + {lang_asset_name} +
- {lang_hostname}: + + {lang_asset_hostname} - + +
- {lang_assetclass}: + + {lang_asset_info} - + +
+ [END asset_table] + +

+ + [BLOCK assetclass_table AS assetclass_table] + - - + + + +
- {lang_asset_info}: + + {lang_assetclass} - + +   +
+ {lang_assetclass} + +
+ [END assetclass_table]

\ No newline at end of file diff --git a/tpl/assetview.tpl b/tpl/assetview.tpl index 31023fb..096a6a0 100644 --- a/tpl/assetview.tpl +++ b/tpl/assetview.tpl @@ -1,114 +1,101 @@ - +
-
- {lang_asset}: + + {asset_name} - - - + {lang_assignnodetoasset} + {lang_asset_edit} + {lang_asset_edit}

- + [BLOCK asset_table AS asset_table] +
+ [BLOCK asset_row] - - - - - - - + - - + [END asset_row]
- {lang_asset_name}: + + {lang_asset} - {asset_name} + +  
- {lang_hostname}: + + {lang_asset_name} - {hostname} + + {asset_name}
- {lang_assetclass}: + + {lang_asset_hostname} - {assetclass_name} + + {asset_hostname}
- {lang_asset_info}: + + {lang_asset_info} + {asset_info}
+ [END asset_table]

- [BLOCK table AS node] - - [BLOCK noderow] + [BLOCK assetclass_table AS assetclass_table] +
- - - - - - - - - - - - - - - - +
-   - - {lang_node} #{nodecount} + + {lang_assetclass}
- {lang_ip}: - - {ip} -
- {lang_subnet}: - - {subnet_address}/{subnet_mask} -
- {lang_mac}: - - {mac} + +  
- {lang_dns1}: + + {lang_assetclass_name} - {dns1} + + {assetclass_name}
+ [END assetclass_table] + +

+ + - - - - - [END noderow] -
- {lang_dns2}: + + {lang_nodes} - {dns2} + + {lang_assignnodetoasset}
- {lang_node_info}: + + {lang_nodes} ({node_counter}) - {node_info} + + [BLOCK node_table AS node_table] + [BLOCK node_row] + {node_ip}
+ [END node_row] + [END node_table]
- [END table] \ No newline at end of file + \ No newline at end of file diff --git a/tpl/assigniptoasset.tpl b/tpl/assigniptoasset.tpl deleted file mode 100644 index b880439..0000000 --- a/tpl/assigniptoasset.tpl +++ /dev/null @@ -1,93 +0,0 @@ -

- - - - - - - -
- {lang_assigniptoasset}: - - -
- -

- - - - - - - [BLOCK table AS subnet] - - - - - [END table] - [BLOCK table AS asset] - - - - - [END table] - - - - - - - - - - - - - - - - - - -
- {lang_ip}: - - -
- {lang_subnet}: - - -
- {lang_asset_name}: - - -
- {lang_mac}: - - -
- {lang_dns1}: - - - - {config_dns1suffix} -
- {lang_dns2}: - - - - {config_dns2suffix} -
- {lang_node_info}: - - -
-

\ No newline at end of file diff --git a/tpl/assigniptonode.tpl b/tpl/assigniptonode.tpl index 6804da4..daf38f7 100644 --- a/tpl/assigniptonode.tpl +++ b/tpl/assigniptonode.tpl @@ -1,29 +1,67 @@ - + + + + + +
+ + + + +
+ {lang_assigniptonode} + + {lang_cancel} + +
+ +

+ + - - - - + + + +
- {lang_ip}: + + {lang_ip} - {ip} + +  
- {lang_subnet}: + + {lang_ip} - {subnet_address}/{subnet_mask} + + {node_ip} +
+ {lang_subnet} + + {subnet_address}/{subnet_mask}

- +
+ + + + + + - +
+ {lang_options} +
+  {lang_assignnodetoasset_existing} +
- {lang_assigniptoasset} / {lang_node_new} + +  {lang_assignnodetoasset_new}
\ No newline at end of file diff --git a/tpl/assignlocationtosubnet.tpl b/tpl/assignlocationtosubnet.tpl deleted file mode 100644 index b83f908..0000000 --- a/tpl/assignlocationtosubnet.tpl +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - [BLOCK table AS location] - - - - - [END table] - [BLOCK table AS subnet] - - - - - [END table] - - - -
- {lang_assignlocationtosubnet}: -
- {lang_location_name}: - - -
- {lang_subnet}: - - -
- -
- \ No newline at end of file diff --git a/tpl/assignnodetoasset.tpl b/tpl/assignnodetoasset.tpl new file mode 100644 index 0000000..90e9518 --- /dev/null +++ b/tpl/assignnodetoasset.tpl @@ -0,0 +1,127 @@ +

+ + + + + + + +
+ {lang_assignnodetoasset} + + {lang_cancel} + +
+ +

+ + [BLOCK node_table AS node_table] + + [BLOCK node_row] + + + + + + + + + + + + + + + + + + + + + + + + + [END node_row] +
+ {lang_node} + +   +
+ {lang_ip} + + +
+ {lang_mac} + + +
+ {lang_dns1} + + +
+ {lang_dns2} + + +
+ {lang_node_info} + + +
+ [END node_table] + +

+ + [BLOCK asset_table AS asset_table] + + + + + + + + + +
+ {lang_asset} + +   +
+ {lang_asset_name} + + +
+ [END asset_table] + +

+ + [BLOCK subnet_table AS subnet_table] + + + + + + + + + +
+ {lang_subnet} + +   +
+ {lang_subnet_subnetaddress}/{lang_subnet_mask} + + +
+ [END subnet_table] + +

\ No newline at end of file diff --git a/tpl/assignvlantosubnet.tpl b/tpl/assignvlantosubnet.tpl deleted file mode 100644 index 77a3c03..0000000 --- a/tpl/assignvlantosubnet.tpl +++ /dev/null @@ -1,43 +0,0 @@ -
- - - - - - [BLOCK table AS vlan] - - - - - [END table] - [BLOCK table AS subnet] - - - - - [END table] - - - -
- {lang_assignvlantosubnet}:
-
- {lang_vlan}: - - -
- {lang_subnet}: - - -
- -
-
\ No newline at end of file diff --git a/tpl/comments.tpl b/tpl/comments.tpl index 9bbca44..526a334 100644 --- a/tpl/comments.tpl +++ b/tpl/comments.tpl @@ -1,7 +1,25 @@ - +
- + + +
-  {lang_comments}: {comments}
+
+ {lang_comments} + + {lang_cancel} +
+ +

+ + + + + + +
+ {lang_comments} +
+ {comments}
\ No newline at end of file diff --git a/tpl/footer.tpl b/tpl/footer.tpl index 3892a28..1a995c7 100644 --- a/tpl/footer.tpl +++ b/tpl/footer.tpl @@ -1,13 +1,11 @@ - -


- - +

+ +

- \ No newline at end of file diff --git a/tpl/header.tpl b/tpl/header.tpl index f023603..44c5d07 100644 --- a/tpl/header.tpl +++ b/tpl/header.tpl @@ -1,30 +1,63 @@ - + - IP Reg {config_version} - + {lang_ipreg} + + + + +
- +
- -
- + + + + + +
+  {lang_ipreg} +
+ +

\ No newline at end of file diff --git a/tpl/index.tpl b/tpl/index.tpl index c632776..31e111f 100644 --- a/tpl/index.tpl +++ b/tpl/index.tpl @@ -1,57 +1,50 @@ - +
- - -
- IP Reg + + {lang_statistics}
- -

- - - - - - - - - - - - - -
- {lang_statistics}: + +  
- {lang_assets}: + + {lang_assets} - {assetcount} + + {asset_counter}
- {lang_locations}: + + {lang_locations} - {locationcount} + + {location_counter}
- {lang_nodes}: + + {lang_nodes} - {nodecount} + + {node_counter}
- {lang_subnets}: + + {lang_subnets} - {subnetcount} + + {subnet_counter}
- {lang_vlans}: + + {lang_vlans} - {vlancount} + + {vlan_counter}
\ No newline at end of file diff --git a/tpl/location.tpl b/tpl/location.tpl index 8283708..3390df6 100644 --- a/tpl/location.tpl +++ b/tpl/location.tpl @@ -1,24 +1,29 @@ - +
-
- {lang_locations}:
+
+ {lang_locations} ({location_counter}) - + {lang_location_add}

- [BLOCK table AS location] - - [BLOCK locationrow] + [BLOCK location_table AS location_table] +
- + + [BLOCK location_row] + + - [END locationrow] + [END location_row]
+ + {lang_location_name} +
{nbsp}{location_name}
- [END table] \ No newline at end of file + [END location_table] \ No newline at end of file diff --git a/tpl/locationadd.tpl b/tpl/locationadd.tpl index 3b4e3c9..d208e41 100644 --- a/tpl/locationadd.tpl +++ b/tpl/locationadd.tpl @@ -1,51 +1,73 @@

- +
-
- {lang_location_add}:
+
+ {lang_location_add} - + {lang_cancel} +

- +
- - + + + + + + + + - [BLOCK table AS location] +
- {lang_location_name}: + + {lang_location} + +   +
+ {lang_location_name} +
+ {lang_location_info} + + +
+ +

+ + [BLOCK location_table AS location_table] + - - - [END table] - -
- {lang_location_parent}: + + {lang_location_parent} - + +  
- {lang_location_info}: + + {lang_location_name} - + +
+ [END location_table]

\ No newline at end of file diff --git a/tpl/locationdel.tpl b/tpl/locationdel.tpl index 3b63280..220eeb1 100644 --- a/tpl/locationdel.tpl +++ b/tpl/locationdel.tpl @@ -2,25 +2,34 @@ - +
-
- {lang_location_del}:
+
+ {location_name} - + {lang_cancel} +

- +
- - + + + + diff --git a/tpl/locationedit.tpl b/tpl/locationedit.tpl index 5eef1c8..63d0d64 100644 --- a/tpl/locationedit.tpl +++ b/tpl/locationedit.tpl @@ -2,51 +2,75 @@ -
- {lang_location_name}: + + {lang_location} + +   +
+ {lang_location_name} + {location_name}
+
-
- {lang_location_edit}:
+
+ {location_name} - + {lang_cancel} +

- + [BLOCK location_table AS location_table] +
- - + + + + - - + +
- {lang_location_name}: + + {lang_location} + +   +
+ {lang_location_name} +
- {lang_location_parent}: + + {lang_location_info} - [BLOCK table AS parent] - - [END table] + + +
+ [END location_table] + +

+ + [BLOCK parentlocation_table AS parentlocation_table] + + + + - -
+ {lang_location_parent} + +  
- {lang_location_info}: + + {lang_location_parent} - + +
+ [END parentlocation_table] \ No newline at end of file diff --git a/tpl/locationsubnetadd.tpl b/tpl/locationsubnetadd.tpl new file mode 100644 index 0000000..177325c --- /dev/null +++ b/tpl/locationsubnetadd.tpl @@ -0,0 +1,63 @@ +

+ + + + + + + + +
+ {lang_locationsubnet} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_location} + +   +
+ {lang_location_name} + + {location_name} +
+ +

+ + [BLOCK subnet_table AS subnet_table] + + + + + + + + + +
+ {lang_subnet_add} + +   +
+ {lang_subnet} + + +
+ [END subnet_table] \ No newline at end of file diff --git a/tpl/locationsubnetdel.tpl b/tpl/locationsubnetdel.tpl new file mode 100644 index 0000000..266a0e8 --- /dev/null +++ b/tpl/locationsubnetdel.tpl @@ -0,0 +1,63 @@ + + + + + + + + + +
+ {lang_locationsubnet} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_location} + +   +
+ {lang_location_name} + + {location_name} +
+ +

+ + [BLOCK subnet_table AS subnet_table] + + + + + + + + + +
+ {lang_subnet_del} + +   +
+ {lang_subnet} + + +
+ [END subnet_table] \ No newline at end of file diff --git a/tpl/locationsubnetedit.tpl b/tpl/locationsubnetedit.tpl new file mode 100644 index 0000000..fed3e43 --- /dev/null +++ b/tpl/locationsubnetedit.tpl @@ -0,0 +1,60 @@ + + + + + + + + + +
+ {lang_locationsubnet} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_location} + +   +
+ {lang_location_name} + + {location_name} +
+ +

+ + + + + + + + + + + +
+ {lang_subnet} + +   +
+ {lang_options} + +  {lang_subnet_add}
+  {lang_subnet_del} +
+ \ No newline at end of file diff --git a/tpl/locationview.tpl b/tpl/locationview.tpl index 6982260..6a2a34d 100644 --- a/tpl/locationview.tpl +++ b/tpl/locationview.tpl @@ -1,62 +1,99 @@ - +
-
- {lang_location}:
+
+ {location_name} - - - + {lang_sublocation_add} + {lang_location_edit} + {lang_location_del}

- + [BLOCK location_table AS location_table] +
- - + + + + - - +
- {lang_location_name}: + + {lang_location} - [BLOCK table AS locationcrumb] - [BLOCK locationcrumbrow] + +   +
+ {lang_location_name} + + [BLOCK locationcrumb_table AS locationcrumb_table] + [BLOCK locationcrumb_row] {seperator}{location_name} - [END locationcrumbrow] - [END table] + [END locationcrumb_row] + [END locationcrumb_table]
- {lang_location_info}: + + {lang_location_info} + {location_info}
+ [END location_table] + +

+ + - - [BLOCK table AS subnet] - - [END table] - - [BLOCK table AS sublocation] - + + + +
- {lang_subnets}: + + {lang_sublocation} - [BLOCK subnetrow] - {subnet_address}/{subnet_mask}
- [END subnetrow] +
+  
- {lang_sublocations}: + + {lang_sublocations} ({sublocation_counter}) - [BLOCK sublocationrow] + + [BLOCK sublocation_table AS sublocation_table] + [BLOCK sublocation_row] {sublocation_name}
- [END sublocationrow] + [END sublocation_row] + [END sublocation_table] +
+ +

+ + + + - [END table] + + + + +
+ {lang_subnet} + {lang_locationsubnet_edit} +
+ {lang_subnets} ({subnet_counter}) + + [BLOCK subnet_table AS subnet_table] + [BLOCK subnet_row] + {subnet_address}/{subnet_mask}
+ [END subnet_row] + [END subnet_table]
\ No newline at end of file diff --git a/tpl/login.tpl b/tpl/login.tpl index 8e8b81b..fb75bd0 100644 --- a/tpl/login.tpl +++ b/tpl/login.tpl @@ -1,43 +1,71 @@ - IP Reg + {lang_ipreg} + -

+ + + + + -


+ + + + +
+ {lang_ipreg} +
+ +

- + +
- + +
- IP Reg + + {lang_ipreg} {config_version} + +
+ +

+ + - - - - - +
- Username: + + {lang_login} - + +  
- Password: + + {lang_user_name} - + +
- + + {lang_user_password} + +
+

\ No newline at end of file diff --git a/tpl/natadd.tpl b/tpl/natadd.tpl new file mode 100644 index 0000000..e7f7e45 --- /dev/null +++ b/tpl/natadd.tpl @@ -0,0 +1,75 @@ +
+ + + + + + + + +
+ {lang_nat} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_node} + +   +
+ {lang_ip} + + {node_ip_ext} +
+ +

+ + [BLOCK node_table AS node_table] + + + + + + + + + + + + + +
+ {lang_nat_add} + +   +
+ {lang_ip} + + +
+ {lang_nat_type} + + +
+ [END node_table] \ No newline at end of file diff --git a/tpl/natdel.tpl b/tpl/natdel.tpl new file mode 100644 index 0000000..b8d4ee6 --- /dev/null +++ b/tpl/natdel.tpl @@ -0,0 +1,63 @@ + + + + + + + + + +
+ {lang_nat} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_node} + +   +
+ {lang_ip} + + {node_ip_ext} +
+ +

+ + [BLOCK node_table AS node_table] + + + + + + + + + +
+ {lang_nat_del} + +   +
+ {lang_node} + + +
+ [END node_table] \ No newline at end of file diff --git a/tpl/natedit.tpl b/tpl/natedit.tpl new file mode 100644 index 0000000..0d31b25 --- /dev/null +++ b/tpl/natedit.tpl @@ -0,0 +1,58 @@ + + + + + + + + + +
+ {lang_nat} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_node} + +   +
+ {lang_ip} + + {node_ip} +
+ +

+ + + + + + + + + + + + +
+ {lang_options} +
+  {lang_nat_add} +
+  {lang_nat_del} +
+ \ No newline at end of file diff --git a/tpl/node.tpl b/tpl/node.tpl new file mode 100644 index 0000000..e8b5c4a --- /dev/null +++ b/tpl/node.tpl @@ -0,0 +1,35 @@ + + + + + +
+ {lang_nodes} ({node_counter}) + + {lang_node_add} +
+ +

+ + [BLOCK node_table AS node_table] + + + + + + [BLOCK node_row] + + + + + [END node_row] +
+ {lang_ip} + + {lang_asset_name} +
+ {node_ip} + + {asset_name} +
+ [END node_table] \ No newline at end of file diff --git a/tpl/nodeadd.tpl b/tpl/nodeadd.tpl index 907c3b4..835dd69 100644 --- a/tpl/nodeadd.tpl +++ b/tpl/nodeadd.tpl @@ -1,96 +1,154 @@ - +
-
- {lang_node_add}:
+
+ {lang_node_add} - + {lang_cancel} +

- +
- - - - - - - [BLOCK table AS subnet] - - - [END table] - [BLOCK table AS assetclass] - - + + + + + +
- {lang_asset_name}: + + {lang_node} - + +  
- {lang_hostname}: + + {lang_ip} - + +
- {lang_ip}: + + {lang_mac} - + +
- {lang_subnet}: + + {lang_dns1} - + +  {user_dns1suffix}
- {lang_assetclass}: + + {lang_dns2} - + +  {user_dns2suffix} +
+ {lang_node_info} + + +
+ +

+ + [BLOCK asset_table AS asset_table] + + + + + + + + + + + + + +
+ {lang_asset} + +   +
+ {lang_asset_name} + + +
+ {lang_asset_hostname} + + +
+ [END asset_table] + +

+ + [BLOCK assetclass_table AS assetclass_table] + + + + - [END table] - - +
+ {lang_assetclass} + +  
- {lang_mac}: + + {lang_assetclass_name} - + +
+ [END assetclass_table] + +

+ + [BLOCK subnet_table AS subnet_table] + - - - -
- {lang_dns1}: + + {lang_subnet} -  {config_dns1suffix} + +  
- {lang_dns2}: + + {lang_subnet_subnetaddress}/{lang_subnet_mask} -  {config_dns2suffix} + +
+ [END subnet_table]

\ No newline at end of file diff --git a/tpl/nodedel.tpl b/tpl/nodedel.tpl index eab32ce..b6348ee 100644 --- a/tpl/nodedel.tpl +++ b/tpl/nodedel.tpl @@ -3,26 +3,35 @@ - +
-
- {lang_node_del}:
+
+ {node_ip} - + {lang_cancel} +

- +
- - + + + +
- {lang_ip}: + + {lang_node} - {ip} + +   +
+ {lang_ip} + + {node_ip}
diff --git a/tpl/nodeedit.tpl b/tpl/nodeedit.tpl index d5fc3d8..6165be8 100644 --- a/tpl/nodeedit.tpl +++ b/tpl/nodeedit.tpl @@ -2,88 +2,127 @@ - +
-
- {lang_node_edit}:
+
+ {node_ip} - + {lang_cancel} +

- - [BLOCK table AS asset] + [BLOCK node_table AS node_table] +
+ [BLOCK node_row] - - - [END table] - - - [BLOCK table AS subnet] - - - [END table] - - - - - - + [END node_row] +
- {lang_asset}: + + {lang_node} - + +  
+ {lang_ip} - + +
- {lang_subnet}: + + {lang_mac} - + +
- {lang_mac}: + + {lang_dns1} - + +
- {lang_dns1}: + + {lang_dns2} - + +
- {lang_dns2}: + + {lang_node_info} - + +
+ [END node_table] + +

+ + [BLOCK asset_table AS asset_table] + - - + + + + + +
- {lang_node_info}: + + {lang_asset} - + +   +
+ {lang_asset_name} + + +
+ [END asset_table] + +

+ + [BLOCK subnet_table AS subnet_table] + + + + + + + +
+ {lang_subnet} + +   +
+ {lang_subnet_subnetaddress}/{lang_subnet_mask} + +
+ [END subnet_table] \ No newline at end of file diff --git a/tpl/nodelist.tpl b/tpl/nodelist.tpl deleted file mode 100644 index 97723fb..0000000 --- a/tpl/nodelist.tpl +++ /dev/null @@ -1,46 +0,0 @@ - [BLOCK table AS node] - - - - - - - - - - [BLOCK noderow] - - - - - - - - - [END noderow] -
- {lang_ip}: - - {lang_asset_name}: - - {lang_hostname}: - - {lang_mac}: - - {lang_dns1}: - - {lang_dns2}: -
- {ip} - - {asset_name} - - {hostname} - - {mac} - - {dns1} - - {dns2} -
- [END table] \ No newline at end of file diff --git a/tpl/nodeview.tpl b/tpl/nodeview.tpl index 6038a9d..cc7301a 100644 --- a/tpl/nodeview.tpl +++ b/tpl/nodeview.tpl @@ -1,82 +1,139 @@ - +
-
- {lang_node}:
+
+ {node_ip} - - + {lang_node_edit} + {lang_node_del}

- + [BLOCK node_table AS node_table] +
+ [BLOCK node_row] - - - - - + - - + + + + - + + + [END node_row] +
- {lang_ip}: + + {lang_node} - {ip} + +  
- {lang_subnet}: + + {lang_ip} - {subnet_address}/{subnet_mask} + + {node_ip}
-   + + {lang_mac} + + {node_mac}
- {lang_asset_name}: + + {lang_dns1} - {asset_name} + + {node_dns1} +
+ {lang_dns2} + + {node_dns2}
+ + {lang_node_info} + + {node_info} +
+ [END node_table] + +

+ + [BLOCK asset_table AS asset_table] + + + + - - +
+ {lang_asset} +  
- {lang_mac}: + + {lang_asset_name} - {mac} + + {asset_name}
+ [END asset_table] + +

+ + [BLOCK subnet_table AS subnet_table] + - - - - +
- {lang_dns1}: + + {lang_subnet} - {dns1} + +  
- {lang_dns2}: + + {lang_subnet_subnetaddress}/{lang_subnet_mask} - {dns2} + + {subnet_address}/{subnet_mask}
+ [END subnet_table] + +

+ + - - + + + +
- {lang_node_info}: + + {lang_nat} - {node_info} + + {lang_nat_edit} +
+ {lang_nat_rules} ({nat_counter}) + + [BLOCK nat_table AS nat_table] + [BLOCK nat_row] + {nat_node_ip}/{nat_asset_name} ({nat_type})
+ [END nat_row] + [END nat_table]
\ No newline at end of file diff --git a/tpl/options.tpl b/tpl/options.tpl index 599650e..1ca7568 100644 --- a/tpl/options.tpl +++ b/tpl/options.tpl @@ -1,70 +1,35 @@ - + + + +
- + -
- {lang_options_ipreg} + + {lang_options} + +  
+

- - - - - +
- {lang_assetclasses} -
- - - - - - - - - - - - - - - - - - -
- {lang_assetclassgroups} + + {lang_options_ipreg}
- {lang_assigniptoasset} -
- {lang_assignlocationtosubnet} -
- {lang_assignvlantosubnet} -
- {lang_userclassauth} -
- {lang_users} -
- {lang_userclasses} -
- -

- - - - -
- Personal options + + {lang_options_password}
- {lang_options_password_edit} + + {lang_options_display}
-

\ No newline at end of file + \ No newline at end of file diff --git a/tpl/optionseditdisplay.tpl b/tpl/optionseditdisplay.tpl new file mode 100644 index 0000000..93ea829 --- /dev/null +++ b/tpl/optionseditdisplay.tpl @@ -0,0 +1,92 @@ +

+ + + + + + + +
+ {lang_options} + + {lang_cancel} + +
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {lang_options_display} + +   +
+ {lang_options_imagesize} + + +
+ {lang_options_imagecount} + + +
+ {lang_options_mac} + + +
+ {lang_options_dateformat} + + +
+ {lang_options_dns1suffix} + + +
+ {lang_options_dns2suffix} + + +
+ {lang_menu} + + {lang_assets}
+ {lang_assetclasses}
+ {lang_assetclassgroups}
+ {lang_locations}
+ {lang_nodes}
+ {lang_subnets}
+ {lang_users}
+ {lang_vlans}
+
+ +

\ No newline at end of file diff --git a/tpl/optionseditpassword.tpl b/tpl/optionseditpassword.tpl new file mode 100644 index 0000000..d2c1578 --- /dev/null +++ b/tpl/optionseditpassword.tpl @@ -0,0 +1,53 @@ +
+ + + + + + + +
+ {lang_options} + + {lang_cancel} + +
+ +

+ + + + + + + + + + + + + + + + + + +
+ {lang_options_password} + +   +
+ {lang_options_currentpassword} + + +
+ {lang_options_newpassword1} + + +
+ {lang_options_newpassword2} + + +
+ +

\ No newline at end of file diff --git a/tpl/search.tpl b/tpl/search.tpl index c510aa9..49f3245 100644 --- a/tpl/search.tpl +++ b/tpl/search.tpl @@ -1,18 +1,26 @@ + + + + +
+ {lang_search} +
+ [BLOCK nosearch] - +
-
-  {lang_comments_search_nosearch} + + {lang_comments} {lang_comments_search_nosearch}
[END nosearch] [BLOCK resultcount] - +
-
- {lang_search_results_found}: {resultcounter} + + {lang_search_results_found} {resultcounter}
@@ -21,20 +29,22 @@

[BLOCK table AS asset] - +
- [BLOCK row] - [END row]
- {item_name} {lang_search_found} ({counter}): + + {item_name} ({counter})
+ {name}
+ +

[END table] [REUSE table AS location] diff --git a/tpl/style.css b/tpl/style.css index 399be96..2909ba5 100644 --- a/tpl/style.css +++ b/tpl/style.css @@ -1,39 +1,164 @@ body { - background-color: #FFFFFF; - color: #000000; + background-color: #fff; + background-image: url("../images/background.png"); + background-repeat: repeat-x; font-family: Verdana, Arial, Helvetica, Sans-serif; + font-size: 11px; margin: 12px; - margin-top: 12px; - font-size: 70%; + text-align: justify; } a { - color: #466A8D; + color: #000; } a:hover { - color: #E1B100; + color: #666; +} + +img { + border: 0px; } input { - font-size: 100%; - position: relative; - top: -2px; + border: 0px; font-family: Verdana, Arial, Helvetica, Sans-serif; + font-size: 100%; } select { + border: 0px; + font-family: Verdana, Arial, Helvetica, Sans-serif; font-size: 100%; - font-family: Verdana, Sans-serif; - position: relative; - top: -2px; } -table { +textarea { + border: 0px; + font-family: Verdana, Arial, Helvetica, Sans-serif; font-size: 100%; + height: 120px; + width: 350px; +} + +.help { + border-bottom: 1px dotted #333; + cursor: help; +} + +table.footer { + border: 0px; + border-collapse: collapse; + border-spacing: 0px; + width: 100%; +} + +table.footer td { + background-color: #666; + color: #fff; + font-weight: bold; + height: 25px; +} + +table.header { + border: 0px; + border-collapse: collapse; + border-spacing: 0px; + width: 100%; +} + +table.header td { + background-color: #666; + color: #fff; + font-weight: bold; + height: 25px; +} + +table.info { + background-color: #666; + border: 0px; + border-collapse: collapse; + border-spacing: 0px; + width: 800px; +} + +table.info td { + background-color: #dcdcdc; + border: 1px #fff solid; + color: #000; + padding: 4px; +} + +table.info td.header { + background-color: #666; + color: #fff; + font-weight: bold; + height: 25px; +} + +table.info td.header_right { + background-color: #666; + color: #fff; + font-weight: bold; + height: 25px; + text-align: right; } -td { +table.info td.footer { + text-align: right; +} + +table.info td.label { + vertical-align: top; + width: 200px; +} + +table.info td.value { + vertical-align: top; +} + +table.info td.help { vertical-align: top; - height: 18px; + +} + +table.menu { + width: 100%; +} + +table.menu td { + border: 0px; + border-collapse: collapse; + border-spacing: 0px; +} + +table.title { + width: 800px; +} + +table.title td { + border: 0px; + border-collapse: collapse; + border-spacing: 0px; + font-weight: bold; +} + +table.submenu { + +} + +table.submenu td { + border: 0px; + border-collapse: collapse; + border-spacing: 0px; +} + +table.subnetview { + background-color: #dcdcdc; +} + +table.subnetview td { + border: 0px; + border-collapse: collapse; + border-spacing: 0px; + padding: 2px; } \ No newline at end of file diff --git a/tpl/subnet.tpl b/tpl/subnet.tpl index 371a5cc..47a9dae 100644 --- a/tpl/subnet.tpl +++ b/tpl/subnet.tpl @@ -1,24 +1,35 @@ - +
-
- {lang_subnet}:
+
+ {lang_subnets} ({subnet_counter}) - + {lang_asset_add}

- [BLOCK table AS subnet] - - [BLOCK subnetrow] + [BLOCK subnet_table AS subnet_table] +
- + + + [BLOCK subnet_row] + + + - [END subnetrow] + [END subnet_row]
+ + {lang_subnet_subnetaddress_mask} + + {lang_nodes} +
{subnet_address}/{subnet_mask} + {node_counter} +
- [END table] \ No newline at end of file + [END subnet_table] \ No newline at end of file diff --git a/tpl/subnetadd.tpl b/tpl/subnetadd.tpl index 1f891f5..5f19ff6 100644 --- a/tpl/subnetadd.tpl +++ b/tpl/subnetadd.tpl @@ -1,35 +1,81 @@

- +
-
- {lang_subnet_add}:
+
+ {lang_subnet_add} - + {lang_cancel} +

- +
- - + + + + - - + + + +
- {lang_subnet_subnetaddress}: + + {lang_subnet} + +   +
+ {lang_subnet_subnetaddress} +
- {lang_subnet_mask}: + + {lang_subnet_mask} +  (8-30)
+ {lang_subnet_info} + + +
+ +

+ + [BLOCK vlan_table AS vlan_table] + + + + + + + + + +
+ {lang_vlan} + +   +
+ {lang_vlan} + + +
+ [END vlan_table] +

\ No newline at end of file diff --git a/tpl/subnetdel.tpl b/tpl/subnetdel.tpl index 293ebc1..4ecd15e 100644 --- a/tpl/subnetdel.tpl +++ b/tpl/subnetdel.tpl @@ -1,17 +1,32 @@
- + +
+ + + + +
+ {lang_subnet_del} + + {lang_cancel} + +
+ +

+ + - - - @@ -19,24 +34,27 @@

- [BLOCK table AS node] -

- {lang_subnet_del} + + {lang_subnet}
- {lang_subnet}: + + {lang_subnet_subnetaddress}/{lang_subnet_mask} + {subnet_address}/{subnet_mask}
+ [BLOCK node_table AS node_table] +
- + - [BLOCK noderow] + [BLOCK node_row] - - - [END noderow] + [END node_row]
-  {lang_comments_asset_del_nodes} + + {lang_comments} {lang_comments_asset_del_nodes} + +  
- {lang_ip}: + + {lang_ip} - {ip} + + {node_ip}
- [END table] + [END node_table]

\ No newline at end of file diff --git a/tpl/subnetedit.tpl b/tpl/subnetedit.tpl index 0428238..799ec58 100644 --- a/tpl/subnetedit.tpl +++ b/tpl/subnetedit.tpl @@ -2,58 +2,53 @@ - +
-
- {lang_subnet_edit}:
+
+ {lang_subnet_edit} - + {lang_cancel} +

- +
- - - - - - + - -
- {lang_subnet_subnetaddress}: + + {lang_subnet} - + +  
- {lang_subnet_mask}: + + {lang_subnet_subnetaddress} - + +
- {lang_vlan} - - [BLOCK table AS vlan] - + + {lang_subnet_mask} + +
- {lang_subnet_info}: + + {lang_subnet_info} - + +
+ \ No newline at end of file diff --git a/tpl/subnetlocationadd.tpl b/tpl/subnetlocationadd.tpl new file mode 100644 index 0000000..3f44398 --- /dev/null +++ b/tpl/subnetlocationadd.tpl @@ -0,0 +1,63 @@ +

+ + + + + + + + +
+ {lang_subnetlocation} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_subnet} + +   +
+ {lang_subnet_subnetaddress}/{lang_subnet_mask} + + {subnet_address}/{subnet_mask} +
+ +

+ + [BLOCK location_table AS location_table] + + + + + + + + + +
+ {lang_location_add} + +   +
+ {lang_location} + + +
+ [END location_table] \ No newline at end of file diff --git a/tpl/subnetlocationdel.tpl b/tpl/subnetlocationdel.tpl new file mode 100644 index 0000000..41ed438 --- /dev/null +++ b/tpl/subnetlocationdel.tpl @@ -0,0 +1,63 @@ + + + + + + + + + +
+ {lang_subnetlocation} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_subnet} + +   +
+ {lang_subnet_subnetaddress}/{lang_subnet_mask} + + {subnet_address}/{subnet_mask} +
+ +

+ + [BLOCK location_table AS location_table] + + + + + + + + + +
+ {lang_location_del} + +   +
+ {lang_location} + + +
+ [END location_table] \ No newline at end of file diff --git a/tpl/subnetlocationedit.tpl b/tpl/subnetlocationedit.tpl new file mode 100644 index 0000000..d56b2d2 --- /dev/null +++ b/tpl/subnetlocationedit.tpl @@ -0,0 +1,60 @@ + + + + + + + + + +
+ {lang_subnetlocation} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_subnet} + +   +
+ {lang_subnet_subnetaddress}/{lang_subnet_mask} + + {subnet_address}/{subnet_mask} +
+ +

+ + + + + + + + + + + +
+ {lang_location} + +   +
+ {lang_options} + +  {lang_location_add}
+  {lang_location_del} +
+ \ No newline at end of file diff --git a/tpl/subnetview.tpl b/tpl/subnetview.tpl index 39a3db1..3d55b8a 100644 --- a/tpl/subnetview.tpl +++ b/tpl/subnetview.tpl @@ -1,125 +1,180 @@ - - - - +
-
- {lang_subnet}: + + {subnet_address}/{subnet_mask} - - + {lang_subnet_edit} + {lang_subnet_del}

- - + [BLOCK subnet_table AS subnet_table] +
- +
- + + + + + - + - + + + + + + + + +
+ {lang_subnet} + + [BLOCK noselect] + {iprange1}.{iprange2}.{iprange3}.{iprange4} + [END noselect] + [BLOCK one_select] + {iprange1}.{iprange2}. + + [END one_select] + [BLOCK two_select] + + + [END two_select] +
+ [BLOCK node_table AS node_table] + + [BLOCK node_row] - + {tr} + [END node_row]
- {lang_subnet_subnetaddress}: {subnet_address}/{subnet_mask} - - {pagination} + {remotetext}
+   + [END node_table]
- [BLOCK table AS subnet] - - - [BLOCK iprow] - {tr} - [END iprow] - -
- [END table] +
+ {lang_subnet_subnetaddress} + + {subnet_address}
- - - - -
-   -
+
+ {lang_subnet_mask} + + {subnetmask1}.{subnetmask2}.{subnetmask3}.{subnetmask4} +
+ {lang_subnet_nodesinsubnet} + + {node_counter} / {host_counter} ({subnet_usedpercentage}%) +
+ {lang_subnet_info} + + {subnet_info}
+ [END subnet_table] + +

- +
- - + + + + + [BLOCK assetclassgroup_table AS assetclassgroup_table] + [BLOCK assetclassgroup_row] + + + + + [END assetclassgroup_row] + [END assetclassgroup_table] +
- - - - - - - - - - - - - -
- {lang_vlans}: - - [BLOCK table AS vlan] - [BLOCK vlanrow] - {vlan_name}
- [END vlanrow] - [END table] -
- {lang_locations}: - - [BLOCK table AS location] - [BLOCK locationrow] - {location_name}
- [END locationrow] - [END table] -
- {lang_subnet_info}: - - {subnet_info} -
+
+ {lang_assetclasses} +  
+ {lang_unassigned} {lang_unassigned} + - [BLOCK table AS assetclassgroup] - - [BLOCK assetclassgrouprow] - - - - [END assetclassgrouprow] -
-  {assetclassgroup_name} -
- [END table] + {free_counter} +
+ {assetclassgroup_name} {assetclassgroup_name} + + {assetclassgroup_node_counter} +
+ +

+ + + + + + + + + + +
+ {lang_vlans} + + {lang_subnetvlan_edit} +
+ {lang_vlans} ({vlan_counter}) + + [BLOCK vlan_table AS vlan_table] + [BLOCK vlan_row] + {vlan_name} ({vlan_number})
+ [END vlan_row] + [END vlan_table] +
+ +

+ + + + + + + + +
+ {lang_locations} + + {lang_location_edit} +
+ {lang_locations} ({location_counter}) + + [BLOCK location_table AS location_table] + [BLOCK location_row] + {location_name}
+ [END location_row] + [END location_table]
\ No newline at end of file diff --git a/tpl/subnetvlanadd.tpl b/tpl/subnetvlanadd.tpl new file mode 100644 index 0000000..b59a8f8 --- /dev/null +++ b/tpl/subnetvlanadd.tpl @@ -0,0 +1,63 @@ + + + + + + + + + +
+ {lang_subnetvlan} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_subnet} + +   +
+ {lang_subnet_subnetaddress}/{lang_subnet_mask} + + {subnet_address}/{subnet_mask} +
+ +

+ + [BLOCK vlan_table AS vlan_table] + + + + + + + + + +
+ {lang_vlan_add} + +   +
+ {lang_vlan} + + +
+ [END vlan_table] \ No newline at end of file diff --git a/tpl/subnetvlandel.tpl b/tpl/subnetvlandel.tpl new file mode 100644 index 0000000..283b87d --- /dev/null +++ b/tpl/subnetvlandel.tpl @@ -0,0 +1,63 @@ + + + + + + + + + +
+ {lang_subnetvlan} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_subnet} + +   +
+ {lang_subnet_subnetaddress}/{lang_subnet_mask} + + {subnet_address}/{subnet_mask} +
+ +

+ + [BLOCK vlan_table AS vlan_table] + + + + + + + + + +
+ {lang_vlan_del} + +   +
+ {lang_vlan} + + +
+ [END vlan_table] \ No newline at end of file diff --git a/tpl/subnetvlanedit.tpl b/tpl/subnetvlanedit.tpl new file mode 100644 index 0000000..55cbd88 --- /dev/null +++ b/tpl/subnetvlanedit.tpl @@ -0,0 +1,60 @@ + + + + + + + + + +
+ {lang_subnetvlan} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_subnet} + +   +
+ {lang_subnet_subnetaddress}/{lang_subnet_mask} + + {subnet_address}/{subnet_mask} +
+ +

+ + + + + + + + + + + +
+ {lang_vlan} + +   +
+ {lang_options} + +  {lang_vlan_add}
+  {lang_vlan_del} +
+ \ No newline at end of file diff --git a/tpl/user.tpl b/tpl/user.tpl index f2d7663..deacf63 100644 --- a/tpl/user.tpl +++ b/tpl/user.tpl @@ -1,22 +1,35 @@ - +
-
- {lang_user}:
+
+ {lang_users} ({user_counter}) - + {lang_user_add}
- [BLOCK table AS user] - - [BLOCK userrow] +

+ + [BLOCK user_table AS user_table] +

+ + + + + [BLOCK user_row] - + - [END userrow] + [END user_row]
+ {lang_user_name} + + {lang_user_displayname} +
- {user_displayname} + + {user_name} + + {user_displayname}
- [END table] \ No newline at end of file + [END user_table] \ No newline at end of file diff --git a/tpl/useradd.tpl b/tpl/useradd.tpl index 29cc2ac..b644c41 100644 --- a/tpl/useradd.tpl +++ b/tpl/useradd.tpl @@ -1,44 +1,51 @@ - +
-
- {lang_user_add}: + + {lang_user_add} - + {lang_cancel} +

- +
- - + + + + - - - -
- {lang_user_name}: + + {lang_user} + +   +
+ {lang_user_name} +
- {lang_user_pass}: + + {lang_user_displayname} - {user_pass} + +
- {lang_user_level}: + + {lang_user_password} - +
diff --git a/tpl/userclass.tpl b/tpl/userclass.tpl deleted file mode 100644 index c5c2530..0000000 --- a/tpl/userclass.tpl +++ /dev/null @@ -1,22 +0,0 @@ - - - - - -
- {lang_userclass}: - - -
- - [BLOCK table AS userclass] - - [BLOCK userclassrow] - - - - [END userclassrow] -
- {userclass_name} -
- [END table] \ No newline at end of file diff --git a/tpl/userclassadd.tpl b/tpl/userclassadd.tpl deleted file mode 100644 index 9490889..0000000 --- a/tpl/userclassadd.tpl +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - -
- {lang_userclass_add}:
-
- -
- -

- - - - - - -
- {lang_userclass_name}: - - -
- \ No newline at end of file diff --git a/tpl/userclassauth.tpl b/tpl/userclassauth.tpl deleted file mode 100644 index 3297b66..0000000 --- a/tpl/userclassauth.tpl +++ /dev/null @@ -1,53 +0,0 @@ - - - - - -
- {lang_userclassauth}: - - -
- -

- - [BLOCK table AS uca] - - - - - - - - - [BLOCK ucarow] - - - - - - - - [END ucarow] -
- # - - {lang_userclass}: - - {lang_item}: - - {lang_subitem}: - - {lang_userclassauth}: -
- {count} - - {userclass_name} - - {item_name} - - {subitem_name} - - {auth} -
- [END table] \ No newline at end of file diff --git a/tpl/userclassauthadd.tpl b/tpl/userclassauthadd.tpl deleted file mode 100644 index 3cea0af..0000000 --- a/tpl/userclassauthadd.tpl +++ /dev/null @@ -1,33 +0,0 @@ -

- - - - - - -
- {lang_userclassauth_add}: - - -
- -

- - - [BLOCK table AS userclass] - - - - - [END table] -
- {lang_userclass_name}: - - -
- -

\ No newline at end of file diff --git a/tpl/userclassauthadditem.tpl b/tpl/userclassauthadditem.tpl deleted file mode 100644 index 3f80573..0000000 --- a/tpl/userclassauthadditem.tpl +++ /dev/null @@ -1,42 +0,0 @@ -
- - - - - - - -
- {lang_userclassauth_add}: - - -
- -

- - - - - - - [BLOCK table AS item] - - - - - [END table] -
- {lang_userclass_name}: - - {userclass_name} -
- {lang_item}: - - -
- -

\ No newline at end of file diff --git a/tpl/userclassauthaddsubitem.tpl b/tpl/userclassauthaddsubitem.tpl deleted file mode 100644 index f0b3aac..0000000 --- a/tpl/userclassauthaddsubitem.tpl +++ /dev/null @@ -1,63 +0,0 @@ -
- - - - - - - - - -
- {lang_userclassauth_add}: - - -
- -

- - - - - - - [BLOCK table AS item] - - - - - [END table] - [BLOCK table AS items] - - - - - [END table] - - - - -
- {lang_userclass_name}: - - {userclass_name} -
- {lang_item}: - - {authitem_name} -
- {lang_subitem}: - - -
- {lang_userclassauth}: - - -
- -

\ No newline at end of file diff --git a/tpl/userclassdel.tpl b/tpl/userclassdel.tpl deleted file mode 100644 index 3d42a1c..0000000 --- a/tpl/userclassdel.tpl +++ /dev/null @@ -1,28 +0,0 @@ -
- - - - - - - - -
- {lang_userclass_del}:
-
- -
- -

- - - - - - -
- {lang_userclass_name}: - - {userclass_name} -
-

\ No newline at end of file diff --git a/tpl/userclassedit.tpl b/tpl/userclassedit.tpl deleted file mode 100644 index f6e8867..0000000 --- a/tpl/userclassedit.tpl +++ /dev/null @@ -1,48 +0,0 @@ -
- - - - - - - - -
- {lang_userclass_edit}:
-
- -
- -

- - - - - - -
- {lang_userclass_name}: - - -
- -

- - - [BLOCK table AS user] - - - - [BLOCK userrow] - - - - [END userrow] - [END table] -
- {lang_users}: -
- {user_displayname} -
- -

\ No newline at end of file diff --git a/tpl/userclassview.tpl b/tpl/userclassview.tpl deleted file mode 100644 index 5376289..0000000 --- a/tpl/userclassview.tpl +++ /dev/null @@ -1,36 +0,0 @@ - - - - - -
- {lang_userclass}: - - - -
- -

- - - - - - - [BLOCK table AS user] - - - - - [END table] -
- {lang_userclass_name}: - - {userclass_name} -
- {lang_users}: - - [BLOCK userrow] - {user_displayname}
- [END userrow] -
\ No newline at end of file diff --git a/tpl/userdel.tpl b/tpl/userdel.tpl index 349e3f1..c6cdf16 100644 --- a/tpl/userdel.tpl +++ b/tpl/userdel.tpl @@ -2,27 +2,37 @@ - +
-
- {lang_user_del}:
+
+ {lang_user_del} - + {lang_cancel} +

- +
- - + + + +
- {lang_user_name}: + + {lang_user} - {user_name} + +   +
+ {lang_user_name} + + {user_name}
+ \ No newline at end of file diff --git a/tpl/useredit.tpl b/tpl/useredit.tpl index 732e6a1..812cb35 100644 --- a/tpl/useredit.tpl +++ b/tpl/useredit.tpl @@ -2,71 +2,45 @@ - +
-
- {lang_user_edit}:
+
+ {user_name} - + {lang_cancel} +

- +
- - - - - - - - - - - - -
- {lang_user_name}: + + {lang_user} - -
- {lang_user_displayname}: - - -
- {lang_mac}: - - + +  
- {lang_language}: + + {lang_user_name} - + +
- -

- - - [BLOCK table AS userclass] - - - [BLOCK userclassrow] - - - [END userclassrow] - [END table]
- {lang_userclasses}: + + {lang_user_displayname}
- {userclass_name} + +
\ No newline at end of file diff --git a/tpl/userpassedit.tpl b/tpl/userpassedit.tpl deleted file mode 100644 index e36fba8..0000000 --- a/tpl/userpassedit.tpl +++ /dev/null @@ -1,39 +0,0 @@ -

- - - - - - - - - - - - - - - - - - - - -
- {lang_options_password_edit}:
-
- {lang_user_passold}: - - -
- {lang_user_passnew1}: - - -
- {lang_user_passnew2}: - - -
- -
-
\ No newline at end of file diff --git a/tpl/userview.tpl b/tpl/userview.tpl index 614a4b8..38b9be0 100644 --- a/tpl/userview.tpl +++ b/tpl/userview.tpl @@ -1,60 +1,42 @@ - +
-
- {lang_user}: + + {user_name} - - + {lang_user_edit} + {lang_user_del}

- + [BLOCK user_table AS user_table] +
- - - - - - - - - - - - - [BLOCK table AS userclass] - - - - [END table] -
- {lang_user_name}: + + {lang_user} - {user_name} + +  
- {lang_user_displayname}: - - {user_displayname} -
- {lang_mac}: + + {lang_user_name} - {user_mac} + + {user_name}
- {lang_language}: - - {user_lang} -
- {lang_userclasses}: + + {lang_user_displayname} - [BLOCK userclassrow] - {userclass_name}
- [END userclassrow] +
+ {user_displayname}
\ No newline at end of file +

+ [END user_table] \ No newline at end of file diff --git a/tpl/vlan.tpl b/tpl/vlan.tpl index fcbb4bb..2912f71 100644 --- a/tpl/vlan.tpl +++ b/tpl/vlan.tpl @@ -1,22 +1,35 @@ - +
-
- {lang_vlan}: + + {lang_vlans} ({vlan_counter}) - + {lang_vlan_add}
- [BLOCK table AS vlan] - - [BLOCK vlanrow] +

+ + [BLOCK vlan_table AS vlan_table] +

+ + + + + [BLOCK vlan_row] - + - [END vlanrow] + [END vlan_row]
+ {lang_vlan_number} + + {lang_vlan_name} +
- {vlan_name} ({vlan_number}) + + {vlan_number} + + {vlan_name}
- [END table] \ No newline at end of file + [END vlan_table] \ No newline at end of file diff --git a/tpl/vlanadd.tpl b/tpl/vlanadd.tpl index d094a0e..f69d458 100644 --- a/tpl/vlanadd.tpl +++ b/tpl/vlanadd.tpl @@ -1,36 +1,50 @@

- +
-
- {lang_vlan_add}: + + {lang_vlan_add} - + {lang_cancel} +

- +
- - + + + - - + + + +
- {lang_vlan_name}: + + {lang_vlan} +
+ {lang_vlan_name} +
- {lang_vlan_number}: + + {lang_vlan_number} +
+ {lang_vlan_info} + + +

\ No newline at end of file diff --git a/tpl/vlandel.tpl b/tpl/vlandel.tpl index fb1b625..b830755 100644 --- a/tpl/vlandel.tpl +++ b/tpl/vlandel.tpl @@ -2,25 +2,34 @@ - +
-
- {lang_vlan_del}: + + {vlan_name} - + {lang_cancel} +

- +
- - + + + + diff --git a/tpl/vlanedit.tpl b/tpl/vlanedit.tpl index ad644b2..cf386ee 100644 --- a/tpl/vlanedit.tpl +++ b/tpl/vlanedit.tpl @@ -2,42 +2,51 @@ -
- {lang_vlan_name}: + + {lang_vlan} + +   +
+ {lang_vlan_name} + {vlan_name} ({vlan_number})
+
-
- {lang_vlan_edit}:
+
+ {vlan_name} - + {lang_cancel} +

- +
- - + + + + - - - -
- {lang_vlan_name}: + + {lang_vlan} + +   +
+ {lang_vlan_name} +
- {lang_vlan_number}: + + {lang_vlan_number} +
- {lang_vlan_info}: + + {lang_vlan_info} - + +
diff --git a/tpl/vlansubnetadd.tpl b/tpl/vlansubnetadd.tpl new file mode 100644 index 0000000..7a32d84 --- /dev/null +++ b/tpl/vlansubnetadd.tpl @@ -0,0 +1,63 @@ +

+ + + + + + + + +
+ {lang_vlansubnet} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_vlan} + +   +
+ {lang_vlan_name} ({lang_vlan_number}) + + {vlan_name} ({vlan_number}) +
+ +

+ + [BLOCK subnet_table AS subnet_table] + + + + + + + + + +
+ {lang_subnet_add} + +   +
+ {lang_subnet} + + +
+ [END subnet_table] \ No newline at end of file diff --git a/tpl/vlansubnetdel.tpl b/tpl/vlansubnetdel.tpl new file mode 100644 index 0000000..3302a9f --- /dev/null +++ b/tpl/vlansubnetdel.tpl @@ -0,0 +1,63 @@ + + + + + + + + + +
+ {lang_vlansubnet} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_vlan} + +   +
+ {lang_vlan_name} ({lang_vlan_number}) + + {vlan_name} ({vlan_number}) +
+ +

+ + [BLOCK subnet_table AS subnet_table] + + + + + + + + + +
+ {lang_subnet_del} + +   +
+ {lang_subnet} + + +
+ [END subnet_table] \ No newline at end of file diff --git a/tpl/vlansubnetedit.tpl b/tpl/vlansubnetedit.tpl new file mode 100644 index 0000000..6e48388 --- /dev/null +++ b/tpl/vlansubnetedit.tpl @@ -0,0 +1,60 @@ + + + + + + + + + +
+ {lang_vlansubnet} + + {lang_cancel} + +
+ +

+ + + + + + + + + + +
+ {lang_vlan} + +   +
+ {lang_vlan_name} ({lang_vlan_number}) + + {vlan_name} ({vlan_number}) +
+ +

+ + + + + + + + + + + +
+ {lang_subnet} + +   +
+ {lang_options} + +  {lang_subnet_add}
+  {lang_subnet_del} +
+ \ No newline at end of file diff --git a/tpl/vlanview.tpl b/tpl/vlanview.tpl index 07b110a..8fe8823 100644 --- a/tpl/vlanview.tpl +++ b/tpl/vlanview.tpl @@ -1,52 +1,79 @@ - +
-
- {lang_vlan}: + + {vlan_name} - - + {lang_assignvlantosubnet} + {lang_vlan_edit} + {lang_vlan_del}

- + [BLOCK vlan_table AS vlan_table] +
+ [BLOCK vlan_row] - - - - - - [BLOCK table AS subnet] - - [END table] - - - + + [END vlan_row] +
- {lang_vlan_name}: + + {lang_vlan} - {vlan_name} + +  
- {lang_vlan_number}: + + {lang_vlan_name} - {vlan_number} + + {vlan_name}
- {lang_subnets}: + + {lang_vlan_number} - [BLOCK subnetrow] - {subnet_address}/{subnet_mask}
- [END subnetrow] +
+ {vlan_number}
- {lang_vlan_info}: + + {lang_vlan_info} + {vlan_info}
+ [END vlan_table] + +

+ + + + + + + + + + +
+ {lang_subnet} + + {lang_subnetvlan_edit} +
+ {lang_subnets} ({subnet_counter}) + + [BLOCK subnet_table AS subnet_table] + [BLOCK subnet_row] + {subnet_address}/{subnet_mask}
+ [END subnet_row] + [END subnet_table] +
\ No newline at end of file diff --git a/user.php b/user.php index 1574262..c56fec0 100644 --- a/user.php +++ b/user.php @@ -1,7 +1,7 @@ setvars($lang); - // set template - $tp = new Template("tpl/user.tpl"); + // setup user + // build query + $query = "SELECT + user.user_id AS user_id, + user.user_name AS user_name, + user.user_displayname AS user_displayname + FROM + user + ORDER BY + user.user_name"; + + // run query + $users = $db->db_select($query); + + // count results + $user_counter = count($users); + + // counter to tpl + $tp->set("user_counter", $user_counter); - // set language variables - $tp->setvars($lang); + // any users? + if ($user_counter>0) { + // get objects + foreach($users AS $user) { + // send to tpl + $tp->set("user_id", $user['user_id']); + $tp->set("user_name", $user['user_name']); + $tp->set("user_displayname", $user['user_displayname']); + + // parse row + $tp->parse("user_row"); + } + + // parse block + $tp->parse("user_table"); + } else { + // hide block + $tp->hide("user_table"); + } - // get user info - $result = mysql_query("SELECT user_id, user_displayname FROM user ORDER BY user_displayname") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("user_id", $row->user_id); - $tp->set("user_displayname", $row->user_displayname); - $tp->parse("userrow"); - } - if (($i>0) ? $tp->parse("user") : $tp->hide("user")); - - // output - $tp->parse(); - $tp->spit(); + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/useradd.php b/useradd.php index 95713c1..37f9446 100644 --- a/useradd.php +++ b/useradd.php @@ -1,7 +1,7 @@ setvars($lang); - - $tp->set("user_pass", $config_user_pass); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // start page + // includes + include("includes.php"); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/useradd.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/userclassauth.php b/userclassauth.php deleted file mode 100644 index e0edadd..0000000 --- a/userclassauth.php +++ /dev/null @@ -1,70 +0,0 @@ -. - - For more information, visit http://sourceforge.net/projects/ipreg, - or contact me at wietsew@users.sourceforge.net - *****************************************************************************/ - - // includes - include("includes.php"); - - // check authorisation - $auth = auth("userclassauth", $config_auth_userclassauthview, 0); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/userclassauth.tpl"); - - // set language variables - $tp->setvars($lang); - - // get userclassauth info - $result = mysql_query("SELECT uc.userclass_id, uc.userclass_name, uca.userclassauth_id, uca.item, uca.id, uca.auth FROM userclass uc, userclassauth uca WHERE uc.userclass_id=uca.userclass_id ORDER BY uc.userclass_name, item, id, auth") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("count", $i+1); - $tp->set("userclass_id", $row->userclass_id); - $tp->set("userclass_name", $row->userclass_name); - $tp->set("item_name", $authitems[$row->item]['name']); - $tp->set("auth", $row->auth); - - // check for set id - if($row->id>0) { - // id set - $item = $row->item; - $txt_item_id = $authitems[$row->item]['item_id']; - $txt_item_name = $authitems[$row->item]['item_name']; - $subresult = mysql_query("SELECT $txt_item_id AS item_id, $txt_item_name AS item_name FROM $item") or die(mysql_error()); - $subrow=mysql_fetch_object($subresult); - $tp->set("subitem_name", $subrow->item_name); - } else { - // no id, so make output empty - $tp->set("subitem_name", ""); - } - - $tp->parse("ucarow"); - } - if (($i>0) ? $tp->parse("uca") : $tp->hide("uca")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); -?> \ No newline at end of file diff --git a/userclassauthadditem.php b/userclassauthadditem.php deleted file mode 100644 index cb38883..0000000 --- a/userclassauthadditem.php +++ /dev/null @@ -1,60 +0,0 @@ -. - - For more information, visit http://sourceforge.net/projects/ipreg, - or contact me at wietsew@users.sourceforge.net - *****************************************************************************/ - - // includes - include("includes.php"); - - // get vars - $userclass_id = $_POST['userclass_id']; - - // check authorisation - $auth = auth("userclassauthadd", $config_auth_userclassauthadd, 0); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/userclassauthadditem.tpl"); - - // set language variables - $tp->setvars($lang); - - // get userclass info - $result = mysql_query("SELECT userclass_name FROM userclass WHERE userclass_id='$userclass_id'") or die(mysql_error()); - $row = mysql_fetch_object($result); - $tp->set("userclass_id", $userclass_id); - $tp->set("userclass_name", $row->userclass_name); - - // loop authitem array to display items - foreach($authitems AS $authitem => $authitem_name) { - $tp->set("authitem", $authitem); - $tp->set("authitem_name", $authitem_name['name']); - $tp->parse("itemrow"); - } - $tp->parse("item"); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); -?> \ No newline at end of file diff --git a/userclassauthaddsubitem.php b/userclassauthaddsubitem.php deleted file mode 100644 index 4c750fd..0000000 --- a/userclassauthaddsubitem.php +++ /dev/null @@ -1,70 +0,0 @@ -. - - For more information, visit http://sourceforge.net/projects/ipreg, - or contact me at wietsew@users.sourceforge.net - *****************************************************************************/ - - // includes - include("includes.php"); - - // get vars - $userclass_id = $_POST['userclass_id']; - $item = $_POST['item']; - - // check authorisation - $auth = auth("userclassauthadd", $config_auth_userclassauthadd, 0); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/userclassauthaddsubitem.tpl"); - - // set language variables - $tp->setvars($lang); - - // get userclass info - $result = mysql_query("SELECT userclass_name FROM userclass WHERE userclass_id='$userclass_id'") or die(mysql_error()); - $row = mysql_fetch_object($result); - $tp->set("userclass_id", $userclass_id); - $tp->set("userclass_name", $row->userclass_name); - $tp->set("authitem", $item); - $tp->set("authitem_name", $authitems[$item]['name']); - - // get subitem info - if($item=="ipreg") { - $tp->hide("items"); - } else { - $txt_item_id = $authitems[$item]['item_id']; - $txt_item_name = $authitems[$item]['item_name']; - $result = mysql_query("SELECT $txt_item_id AS item_id, $txt_item_name AS item_name FROM $item ORDER BY $txt_item_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("item_id", $row->item_id); - $tp->set("item_name", $row->item_name); - $tp->parse("itemrow"); - } - if (($i>0) ? $tp->parse("items") : $tp->hide("items")); - } - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); -?> \ No newline at end of file diff --git a/userclassedit.php b/userclassedit.php deleted file mode 100644 index b365557..0000000 --- a/userclassedit.php +++ /dev/null @@ -1,62 +0,0 @@ -. - - For more information, visit http://sourceforge.net/projects/ipreg, - or contact me at wietsew@users.sourceforge.net - *****************************************************************************/ - - // includes - include("includes.php"); - - // get user_id - $userclass_id = $_GET['userclass_id']; - - // check authorisation - $auth = auth("userclass", $config_auth_userclass, $userclass_id); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/userclassedit.tpl"); - - // set language variables - $tp->setvars($lang); - - // get userclass info - $result = mysql_query("SELECT userclass_name FROM userclass WHERE userclass_id='$userclass_id'") or die(mysql_error()); - $row = mysql_fetch_object($result); - $tp->set("userclass_id", $userclass_id); - $tp->set("userclass_name", $row->userclass_name); - - // get user info - $result = mysql_query("SELECT u.user_id, u.user_displayname, (SELECT uuc.user_id FROM useruserclass uuc WHERE uuc.userclass_id='$userclass_id' AND uuc.user_id=u.user_id) AS member FROM user u ORDER BY u.user_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("user_id", $row->user_id); - $tp->set("user_displayname", $row->user_displayname); - if((is_null($row->member)) ? $tp->set("checked", "") : $tp->set("checked", "checked")); - $tp->parse("userrow"); - } - if (($i>0) ? $tp->parse("user") : $tp->hide("user")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); -?> \ No newline at end of file diff --git a/userclassview.php b/userclassview.php deleted file mode 100644 index 78a078c..0000000 --- a/userclassview.php +++ /dev/null @@ -1,61 +0,0 @@ -. - - For more information, visit http://sourceforge.net/projects/ipreg, - or contact me at wietsew@users.sourceforge.net - *****************************************************************************/ - - // includes - include("includes.php"); - - // get id - $userclass_id = $_GET['userclass_id']; - - // check authorisation - $auth = auth("userclass", $config_auth_userclassview, $userclass_id); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/userclassview.tpl"); - - // set language variables - $tp->setvars($lang); - - // get userclass info - $result = mysql_query("SELECT userclass_name FROM userclass WHERE userclass_id='$userclass_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("userclass_id", $userclass_id); - $tp->set("userclass_name", $row->userclass_name); - - // get user info - $result = mysql_query("SELECT u.user_id, u.user_displayname FROM user u, useruserclass uuc WHERE uuc.userclass_id='$userclass_id' AND u.user_id=uuc.user_id ORDER BY u.user_displayname") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("user_id", $row->user_id); - $tp->set("user_displayname", $row->user_displayname); - $tp->parse("userrow"); - } - if (($i>0) ? $tp->parse("user") : $tp->hide("user")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); -?> \ No newline at end of file diff --git a/userdel.php b/userdel.php index 177f23a..3bfa4af 100644 --- a/userdel.php +++ b/userdel.php @@ -1,7 +1,7 @@ setvars($lang); - - // get assetclass info - $result = mysql_query("SELECT user_id, user_name FROM user WHERE user_id='$user_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("user_id", $row->user_id); - $tp->set("user_name", $row->user_name); - - // output - $tp->parse(); - $tp->spit(); + // start page + // includes + include("includes.php"); + + // get id + $user_id = sanitize($_GET['user_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/userdel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup user + // build query + $query = "SELECT + user.user_name AS user_name + FROM + user + WHERE + user.user_id=" . $user_id; + + // run query + $user = $db->db_select($query); + + // send to tpl + $tp->set("user_id", $user_id); + $tp->set("user_name", $user[0]['user_name']); + + // end page + // output + $tp->parse(); + $tp->spit(); - include("footer.php"); + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/useredit.php b/useredit.php index b7f7806..118a3ae 100644 --- a/useredit.php +++ b/useredit.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); - // get user info - $result = mysql_query("SELECT user_name, user_displayname, user_mac, user_lang FROM user WHERE user_id='$user_id'") or die(mysql_error()); - $row = mysql_fetch_object($result); - $tp->set("user_id", $user_id); - $tp->set("user_name", $row->user_name); - $tp->set("user_displayname", $row->user_displayname); - $tp->set("user_mac", $row->user_mac); - $tp->set("user_lang", $row->user_lang); - - // get userclass info - $result = mysql_query("SELECT uc.userclass_id, uc.userclass_name, (SELECT uuc.userclass_id FROM useruserclass uuc WHERE uuc.user_id='$user_id' AND uuc.userclass_id=uc.userclass_id) AS member FROM userclass uc") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("userclass_id", $row->userclass_id); - $tp->set("userclass_name", $row->userclass_name); - if((is_null($row->member)) ? $tp->set("checked", "") : $tp->set("checked", "checked")); - $tp->parse("userclassrow"); - } - if (($i>0) ? $tp->parse("userclass") : $tp->hide("userclass")); - - // output - $tp->parse(); - $tp->spit(); + // get id + $user_id = sanitize($_GET['user_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/useredit.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup user + // build query + $query = "SELECT + user.user_name AS user_name, + user.user_displayname AS user_displayname + FROM + user + WHERE + user.user_id=" . $user_id; + + // run query + $user = $db->db_select($query); + + // send to tpl + $tp->set("user_id", $user_id); + $tp->set("user_name", $user[0]['user_name']); + $tp->set("user_displayname", $user[0]['user_displayname']); - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/userview.php b/userview.php index 77fd349..af5f8de 100644 --- a/userview.php +++ b/userview.php @@ -1,7 +1,7 @@ setvars($lang); - // get id - $user_id = $_GET['user_id']; + // setup user + // build query + $query = "SELECT + user.user_name AS user_name, + user.user_displayname AS user_displayname + FROM + user + WHERE + user.user_id=" . $user_id; + + // run query + $user = $db->db_select($query); + + // send to tpl + $tp->set("user_id", $user_id); + $tp->set("user_name", $user[0]['user_name']); + $tp->set("user_displayname", $user[0]['user_displayname']); - // check authorisation - $auth = auth("user", $config_auth_userview, $user_id); - - // start output - include("header.php"); - - // set template - $tp = new Template("tpl/userview.tpl"); - - // set language variables - $tp->setvars($lang); - - // get user info - $result = mysql_query("SELECT user_name, user_displayname, user_mac, user_lang FROM user WHERE user_id='$user_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("user_id", $user_id); - $tp->set("user_name", $row->user_name); - $tp->set("user_displayname", $row->user_displayname); - $tp->set("user_mac", $row->user_mac); - $tp->set("user_lang", $row->user_lang); - - // get userclass info - $result = mysql_query("SELECT uc.userclass_id, uc.userclass_name FROM userclass uc, useruserclass uuc WHERE uuc.user_id='$user_id' AND uuc.userclass_id=uc.userclass_id ORDER BY uc.userclass_name") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("userclass_id", $row->userclass_id); - $tp->set("userclass_name", $row->userclass_name); - $tp->set("userclasscount", $i+1); - $tp->parse("userclassrow"); - } - if (($i>0) ? $tp->parse("userclass") : $tp->hide("userclass")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/vlan.php b/vlan.php index 311a335..3cef085 100644 --- a/vlan.php +++ b/vlan.php @@ -1,7 +1,7 @@ setvars($lang); - // check authorisation - $auth = auth("vlan", $config_auth_vlanview, 0); + // setup vlan + // build query + $query = "SELECT + vlan.vlan_id AS vlan_id, + vlan.vlan_number AS vlan_number, + vlan.vlan_name AS vlan_name + FROM + vlan + ORDER BY + vlan.vlan_number"; + + // run query + $vlans = $db->db_select($query); + + // count results + $vlan_counter = count($vlans); + + // counter to tpl + $tp->set("vlan_counter", $vlan_counter); - // start output - include("header.php"); + // any vlans? + if ($vlan_counter>0) { + // get objects + foreach($vlans AS $vlan) { + // send to tpl + $tp->set("vlan_id", $vlan['vlan_id']); + $tp->set("vlan_number", $vlan['vlan_number']); + $tp->set("vlan_name", $vlan['vlan_name']); + + // parse row + $tp->parse("vlan_row"); + } + + // parse block + $tp->parse("vlan_table"); + } else { + // hide block + $tp->hide("vlan_table"); + } - // set template - $tp = new Template("tpl/vlan.tpl"); - - // set language variables - $tp->setvars($lang); - - // get vlan info - $result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan ORDER BY vlan_number") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("vlan_id", $row->vlan_id); - $tp->set("vlan_name", $row->vlan_name); - $tp->set("vlan_number", $row->vlan_number); - $tp->parse("vlanrow"); - } - if (($i>0) ? $tp->parse("vlan") : $tp->hide("vlan")); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/vlanadd.php b/vlanadd.php index 68cfda9..ed208c4 100644 --- a/vlanadd.php +++ b/vlanadd.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/vlanadd.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file diff --git a/vlandel.php b/vlandel.php index c740a71..7e3de9e 100644 --- a/vlandel.php +++ b/vlandel.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); + + // get id + $vlan_id = sanitize($_GET['vlan_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/vlandel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - // get vlanclass info - $result = mysql_query("SELECT vlan_id, vlan_name, vlan_number FROM vlan WHERE vlan_id='$vlan_id'") or die(mysql_error()); - $row=mysql_fetch_object($result); - $tp->set("vlan_id", $row->vlan_id); - $tp->set("vlan_name", $row->vlan_name); - $tp->set("vlan_number", $row->vlan_number); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); + // setup vlan + // build query + $query = "SELECT + vlan.vlan_name AS vlan_name, + vlan.vlan_number AS vlan_number + FROM + vlan + WHERE + vlan.vlan_id=" . $vlan_id; + + // run query + $vlan = $db->db_select($query); + + // send to tpl + $tp->set("vlan_id", $vlan_id); + $tp->set("vlan_name", $vlan[0]['vlan_name']); + $tp->set("vlan_number", $vlan[0]['vlan_number']); + + // end page + // output + $tp->parse(); + $tp->spit(); + + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/vlanedit.php b/vlanedit.php index ed6c8f5..2916239 100644 --- a/vlanedit.php +++ b/vlanedit.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); + + // get id + $vlan_id = sanitize($_GET['vlan_id']); - // get vlan information - $result = mysql_query("SELECT vlan_name, vlan_number, vlan_info FROM vlan WHERE vlan_id='$vlan_id'") or die(mysql_error()); - $row = mysql_fetch_object($result); - $tp->set("vlan_id", $vlan_id); - $tp->set("vlan_name", $row->vlan_name); - $tp->set("vlan_number", $row->vlan_number); - $tp->set("vlan_info", $row->vlan_info); + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/vlanedit.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - // output - $tp->parse(); - $tp->spit(); + // setup vlan + // build query + $query = "SELECT + vlan.vlan_name AS vlan_name, + vlan.vlan_number AS vlan_number, + vlan.vlan_info AS vlan_info + FROM + vlan + WHERE + vlan.vlan_id=" . $vlan_id; + + // run query + $vlan = $db->db_select($query); + + // send to tpl + $tp->set("vlan_id", $vlan_id); + $tp->set("vlan_name", $vlan[0]['vlan_name']); + $tp->set("vlan_number", $vlan[0]['vlan_number']); + $tp->set("vlan_info", $vlan[0]['vlan_info']); - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // footer + include("footer.php"); ?> \ No newline at end of file diff --git a/vlansubnetadd.php b/vlansubnetadd.php new file mode 100644 index 0000000..fe767d9 --- /dev/null +++ b/vlansubnetadd.php @@ -0,0 +1,109 @@ +. + + 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 + $vlan_id = sanitize($_GET['vlan_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/vlansubnetadd.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup vlan + // build query + $query = "SELECT + vlan.vlan_name AS vlan_name, + vlan.vlan_number AS vlan_number + FROM + vlan + WHERE + vlan.vlan_id=" . $vlan_id; + + // run query + $vlan = $db->db_select($query); + + $tp->set("vlan_id", $vlan_id); + $tp->set("vlan_name", $vlan[0]['vlan_name']); + $tp->set("vlan_number", $vlan[0]['vlan_number']); + + // 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 + subnet + WHERE + subnet.subnet_id NOT IN ( + SELECT + subnet_id + FROM + subnetvlan + WHERE + vlan_id=" . $vlan_id . " + ) + ORDER BY + INET_ATON(subnet.subnet_address)"; + + // run query + $subnets = $db->db_select($query); + + // count results + $subnet_counter = count($subnets); + + // any vlans? + if ($subnet_counter>0) { + // get objects + foreach($subnets AS $subnet) { + // send to tpl + $tp->set("subnet_id", $subnet['subnet_id']); + $tp->set("subnet_address", $subnet['subnet_address']); + $tp->set("subnet_mask", $subnet['subnet_mask']); + + // parse row + $tp->parse("subnet_row"); + } + + // parse block + $tp->parse("subnet_table"); + } else { + // hide block + $tp->hide("subnet_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/vlansubnetdel.php b/vlansubnetdel.php new file mode 100644 index 0000000..c06c93b --- /dev/null +++ b/vlansubnetdel.php @@ -0,0 +1,104 @@ +. + + 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 + $vlan_id = sanitize($_GET['vlan_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/vlansubnetdel.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup vlan + // build query + $query = "SELECT + vlan.vlan_name AS vlan_name, + vlan.vlan_number AS vlan_number + FROM + vlan + WHERE + vlan.vlan_id=" . $vlan_id; + + // run query + $vlan = $db->db_select($query); + + $tp->set("vlan_id", $vlan_id); + $tp->set("vlan_name", $vlan[0]['vlan_name']); + $tp->set("vlan_number", $vlan[0]['vlan_number']); + + // 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 + subnetvlan, + subnet + WHERE + subnetvlan.vlan_id=" . $vlan_id . " + AND subnet.subnet_id=subnetvlan.subnet_id + ORDER BY + INET_ATON(subnet.subnet_address)"; + + // run query + $subnets = $db->db_select($query); + + // count results + $subnet_counter = count($subnets); + + // any vlans? + if ($subnet_counter>0) { + // get objects + foreach($subnets AS $subnet) { + // send to tpl + $tp->set("subnet_id", $subnet['subnet_id']); + $tp->set("subnet_address", $subnet['subnet_address']); + $tp->set("subnet_mask", $subnet['subnet_mask']); + + // parse row + $tp->parse("subnet_row"); + } + + // parse block + $tp->parse("subnet_table"); + } else { + // hide block + $tp->hide("subnet_table"); + } + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/vlansubnetedit.php b/vlansubnetedit.php new file mode 100644 index 0000000..09ee29f --- /dev/null +++ b/vlansubnetedit.php @@ -0,0 +1,64 @@ +. + + 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 + $vlan_id = sanitize($_GET['vlan_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/vlansubnetedit.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); + + // setup vlan + // build query + $query = "SELECT + vlan.vlan_name AS vlan_name, + vlan.vlan_number AS vlan_number + FROM + vlan + WHERE + vlan.vlan_id=" . $vlan_id; + + // run query + $vlan = $db->db_select($query); + + // send to tpl + $tp->set("vlan_id", $vlan_id); + $tp->set("vlan_name", $vlan[0]['vlan_name']); + $tp->set("vlan_number", $vlan[0]['vlan_number']); + + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/vlanview.php b/vlanview.php index 70b3898..785e018 100644 --- a/vlanview.php +++ b/vlanview.php @@ -1,7 +1,7 @@ setvars($lang); + // start page + // includes + include("includes.php"); + + // get id + $vlan_id = sanitize($_GET['vlan_id']); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/vlanview.tpl", $config_yapter_error); + + // set language variables + $tp->setvars($lang); - // get vlan info - $result = mysql_query("SELECT vlan_name, vlan_number, vlan_info FROM vlan WHERE vlan_id='$vlan_id'") or die(mysql_error()); - $row = mysql_fetch_object($result); - $tp->set("vlan_id", $vlan_id); - $tp->set("vlan_name", $row->vlan_name); - $tp->set("vlan_number", $row->vlan_number); - $tp->set("vlan_info", $row->vlan_info); + // setup vlan + // build query + $query = "SELECT + vlan.vlan_name AS vlan_name, + vlan.vlan_number AS vlan_number, + vlan.vlan_info AS vlan_info + FROM + vlan + WHERE + vlan.vlan_id=" . $vlan_id; + + // run query + $vlan = $db->db_select($query); + + // send to tpl + $tp->set("vlan_id", $vlan_id); + $tp->set("vlan_name", $vlan[0]['vlan_name']); + $tp->set("vlan_number", $vlan[0]['vlan_number']); + $tp->set("vlan_info", nl2br($vlan[0]['vlan_info'])); - // get subnet info - $result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet WHERE vlan_id='$vlan_id' ORDER BY INET_ATON(subnet_address)") or die(mysql_error()); - for ($i=0;$row=mysql_fetch_object($result);$i++) { - $tp->set("subnet_id", $row->subnet_id); - $tp->set("subnet_address", $row->subnet_address); - $tp->set("subnet_mask", $row->subnet_mask); - $tp->parse("subnetrow"); - } - if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet")); + // setup subnets + // build query + $query = "SELECT + subnet.subnet_id AS subnet_id, + subnet.subnet_address AS subnet_address, + subnet.subnet_mask AS subnet_mask + FROM + subnet, + subnetvlan + WHERE + subnetvlan.vlan_id=" . $vlan_id . " + AND subnet.subnet_id=subnetvlan.subnet_id + ORDER BY + INET_ATON(subnet.subnet_address)"; + + // run query + $subnets = $db->db_select($query); - // output - $tp->parse(); - $tp->spit(); + // count results + $subnet_counter = count($subnets); + + // counter to tpl + $tp->set("subnet_counter", $subnet_counter); + + // any nodes? + if ($subnet_counter>0) { + // get objects + foreach($subnets AS $subnet) { + // send to tpl + $tp->set("subnet_id", $subnet['subnet_id']); + $tp->set("subnet_address", $subnet['subnet_address']); + $tp->set("subnet_mask", $subnet['subnet_mask']); + + // parse row + $tp->parse("subnet_row"); + } + + // parse block + $tp->parse("subnet_table"); + } else { + // hide block + $tp->hide("subnet_table"); + } - include("footer.php"); + // end page + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); ?> \ No newline at end of file