diff --git a/about.php b/about.php new file mode 100644 index 0000000..304560a --- /dev/null +++ b/about.php @@ -0,0 +1,44 @@ +. + + 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/about.tpl"); + + // set language variables + $tp->setvars($lang); + + // set vars + $tp->set("config_version", $config_version); + + // 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 a76ceb6..5778c80 100644 --- a/asset.php +++ b/asset.php @@ -1,6 +1,34 @@ . + + 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("asset", $config_auth_assetview, 0); + + // start output + include("header.php"); + // set template $tp = new Template("tpl/asset.tpl"); @@ -8,10 +36,12 @@ $tp->setvars($lang); // get asset info - $result = mysql_query("SELECT asset_id, asset_name FROM asset ORDER BY asset_name") or die(mysql_error()); + $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")); diff --git a/assetadd.php b/assetadd.php index b513161..0f9318a 100644 --- a/assetadd.php +++ b/assetadd.php @@ -1,4 +1,35 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + // includes + include("includes.php"); + + // get id + if((isset($_GET['assetclass_id'])) ? $assetclass_id = $_GET['assetclass_id'] : $assetclass_id = ""); + + // check authorisation + $auth = auth("asset", $config_auth_assetadd, 0); + + // start output include("header.php"); // set template @@ -10,6 +41,7 @@ // 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"); diff --git a/assetclass.php b/assetclass.php index c563576..f529765 100644 --- a/assetclass.php +++ b/assetclass.php @@ -1,4 +1,32 @@ . + + 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("assetclass", $config_auth_assetclassview, 0); + + // start output include("header.php"); // set template diff --git a/assetclassadd.php b/assetclassadd.php index 05dd0ad..ee55068 100644 --- a/assetclassadd.php +++ b/assetclassadd.php @@ -1,4 +1,35 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + // includes + include("includes.php"); + + // get id + if((isset($_GET['assetclassgroup_id'])) ? $assetclassgroup_id = $_GET['assetclassgroup_id'] : $assetclassgroup_id = ""); + + // check authorisation + $auth = auth("assetclass", $config_auth_assetclassadd, $assetclass_id); + + // start output include("header.php"); // set template @@ -10,6 +41,7 @@ // 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"); diff --git a/assetclassdel.php b/assetclassdel.php index 78fb7c4..b2d9d1b 100644 --- a/assetclassdel.php +++ b/assetclassdel.php @@ -1,9 +1,37 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + // includes + include("includes.php"); // get id $assetclass_id = $_GET['assetclass_id']; + // check authorisation + $auth = auth("assetclass", $config_auth_assetclassdel, $assetclass_id); + + // start output + include("header.php"); + // set template $tp = new Template("tpl/assetclassdel.tpl"); diff --git a/assetclassedit.php b/assetclassedit.php index c52165f..e4659ed 100644 --- a/assetclassedit.php +++ b/assetclassedit.php @@ -1,9 +1,37 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + // includes + include("includes.php"); // get id $assetclass_id = $_GET['assetclass_id']; + // check authorisation + $auth = auth("assetclass", $config_auth_assetclassedit, $assetclass_id); + + // start output + include("header.php"); + // set template $tp = new Template("tpl/assetclassedit.tpl"); diff --git a/assetclassgroup.php b/assetclassgroup.php new file mode 100644 index 0000000..9df6b8f --- /dev/null +++ b/assetclassgroup.php @@ -0,0 +1,53 @@ +. + + 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("assetclassgroup", $config_auth_assetclassgroupview, 0); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetclassgroup.tpl"); + + // set language variables + $tp->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")); + + // output + $tp->parse(); + $tp->spit(); + + // end output + include("footer.php"); +?> \ No newline at end of file diff --git a/assetclassgroupadd.php b/assetclassgroupadd.php new file mode 100644 index 0000000..6aa986d --- /dev/null +++ b/assetclassgroupadd.php @@ -0,0 +1,43 @@ +. + + 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("assetclassgroup", $config_auth_assetclassgroupadd, 0); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetclassgroupadd.tpl"); + + // set language variables + $tp->setvars($lang); + + // output + $tp->parse(); + $tp->spit(); + + include("footer.php"); +?> \ No newline at end of file diff --git a/assetclassgroupdel.php b/assetclassgroupdel.php new file mode 100644 index 0000000..75c3b1b --- /dev/null +++ b/assetclassgroupdel.php @@ -0,0 +1,52 @@ +. + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + // includes + include("includes.php"); + + // get id + $assetclassgroup_id = $_GET['assetclassgroup_id']; + + // check authorisation + $auth = auth("assetclassgroup", $config_auth_assetclassgroupdel, $assetclassgroup_id); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetclassgroupdel.tpl"); + + // set language variables + $tp->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(); + + include("footer.php"); +?> \ No newline at end of file diff --git a/assetclassgroupedit.php b/assetclassgroupedit.php new file mode 100644 index 0000000..8f54a16 --- /dev/null +++ b/assetclassgroupedit.php @@ -0,0 +1,53 @@ +. + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + // includes + include("includes.php"); + + // get id + $assetclassgroup_id = $_GET['assetclassgroup_id']; + + // check authorisation + $auth = auth("assetclassgroup", $config_auth_assetclassgroupedit, $assetclassgroup_id); + + // start output + include("header.php"); + + // set template + $tp = new Template("tpl/assetclassgroupedit.tpl"); + + // set language variables + $tp->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(); + + include("footer.php"); +?> \ No newline at end of file diff --git a/assetclassgroupview.php b/assetclassgroupview.php index d31c6bc..1d76af6 100644 --- a/assetclassgroupview.php +++ b/assetclassgroupview.php @@ -1,18 +1,47 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + // includes + include("includes.php"); // get id $assetclassgroup_id = $_GET['assetclassgroup_id']; + // check authorisation + $auth = auth("assetclassgroup", $config_auth_assetclassgroupview, $assetclassgroup_id); + + // start output + include("header.php"); + // set template $tp = new Template("tpl/assetclassgroupview.tpl"); // set language variables $tp->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); @@ -23,21 +52,7 @@ $tp->parse("assetclassrow"); } if (($i>0) ? $tp->parse("assetclass") : $tp->hide("assetclass")); - - // display options - if($_SESSION['suser_level'] >= $config_userlevel_assetclassgroupedit) { - $tp->set("assetclassgroup_id", $assetclassgroup_id); - $tp->parse("assetclassgroupedit"); - } else { - $tp->hide("assetclassgroupedit"); - } - if($_SESSION['suser_level'] >= $config_userlevel_assetclassgroupdel) { - $tp->set("assetclassgroup_id", $assetclassgroup_id); - $tp->parse("assetclassgroupdel"); - } else { - $tp->hide("assetclassgroupdel"); - } - + // output $tp->parse(); $tp->spit(); diff --git a/assetclassview.php b/assetclassview.php index 1491fe6..ace8005 100644 --- a/assetclassview.php +++ b/assetclassview.php @@ -1,8 +1,36 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + // includes + include("includes.php"); // get id $assetclass_id = $_GET['assetclass_id']; + + // check authorisation + $auth = auth("assetclass", $config_auth_assetclassview, $assetclass_id); + + // start output + include("header.php"); // set template $tp = new Template("tpl/assetclassview.tpl"); @@ -13,6 +41,7 @@ // 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); @@ -25,21 +54,7 @@ $tp->parse("assetrow"); } if (($i>0) ? $tp->parse("asset") : $tp->hide("asset")); - - // display options - if($_SESSION['suser_level'] >= $config_userlevel_assetclassedit) { - $tp->set("assetclass_id", $assetclass_id); - $tp->parse("assetclassedit"); - } else { - $tp->hide("assetclassedit"); - } - if($_SESSION['suser_level'] >= $config_userlevel_assetclassdel) { - $tp->set("assetclass_id", $assetclass_id); - $tp->parse("assetclassdel"); - } else { - $tp->hide("assetclassdel"); - } - + // output $tp->parse(); $tp->spit(); diff --git a/assetdel.php b/assetdel.php index b636b28..44a8da4 100644 --- a/assetdel.php +++ b/assetdel.php @@ -1,9 +1,37 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + // includes + include("includes.php"); // get id $asset_id = $_GET['asset_id']; + // check authorisation + $auth = auth("asset", $config_auth_assetdel, $asset_id); + + // start output + include("header.php"); + // set template $tp = new Template("tpl/assetdel.tpl"); diff --git a/assetedit.php b/assetedit.php index 0b952f3..0d54efc 100644 --- a/assetedit.php +++ b/assetedit.php @@ -1,9 +1,37 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + // includes + include("includes.php"); // get id $asset_id = $_GET['asset_id']; + // check authorisation + $auth = auth("asset", $config_auth_assetedit, $asset_id); + + // start output + include("header.php"); + // set template $tp = new Template("tpl/assetedit.tpl"); diff --git a/assetview.php b/assetview.php index 3febf71..24cb793 100644 --- a/assetview.php +++ b/assetview.php @@ -1,9 +1,37 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + // includes + include("includes.php"); // get id $asset_id = $_GET['asset_id']; + // check authorisation + auth("asset", $config_auth_assetview, $asset_id); + + // start output + include("header.php"); + // set template $tp = new Template("tpl/assetview.tpl"); @@ -13,6 +41,7 @@ // 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)); @@ -35,20 +64,6 @@ $tp->parse("noderow"); } if (($i>0) ? $tp->parse("node") : $tp->hide("node")); - - // display options - if($_SESSION['suser_level'] >= $config_userlevel_assetedit) { - $tp->set("asset_id", $asset_id); - $tp->parse("assetedit"); - } else { - $tp->hide("assetedit"); - } - if($_SESSION['suser_level'] >= $config_userlevel_assetdel) { - $tp->set("asset_id", $asset_id); - $tp->parse("assetdel"); - } else { - $tp->hide("assetdel"); - } // output $tp->parse(); diff --git a/assigniptoasset.php b/assigniptoasset.php index 5f29f3e..157f3df 100644 --- a/assigniptoasset.php +++ b/assigniptoasset.php @@ -1,10 +1,39 @@ . + + 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"); @@ -12,31 +41,33 @@ $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 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 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(); diff --git a/assigniptonode.php b/assigniptonode.php index 74816c7..9c3b9d7 100644 --- a/assigniptonode.php +++ b/assigniptonode.php @@ -1,4 +1,29 @@ . + + 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 ip and id @@ -20,19 +45,7 @@ $row = mysql_fetch_object($result); $tp->set("subnet_address", $row->subnet_address); $tp->set("subnet_mask", $row->subnet_mask); - - // display options - if($_SESSION['suser_level'] >= $config_userlevel_assigniptonode) { - $tp->parse("assigniptonode"); - } else { - $tp->hide("assigniptonode"); - } - if($_SESSION['suser_level'] >= $config_userlevel_nodeadd) { - $tp->parse("nodeadd"); - } else { - $tp->hide("nodeadd"); - } - + // output $tp->parse(); $tp->spit(); diff --git a/assignlocationtosubnet.php b/assignlocationtosubnet.php index 2be2a6a..3a7fefd 100644 --- a/assignlocationtosubnet.php +++ b/assignlocationtosubnet.php @@ -1,4 +1,29 @@ . + + 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 diff --git a/assignsubnettolocation.php b/assignsubnettolocation.php deleted file mode 100644 index 1998a21..0000000 --- a/assignsubnettolocation.php +++ /dev/null @@ -1,58 +0,0 @@ -= 2) { - - // check for submit - if ($_SERVER['REQUEST_METHOD']=="POST" ) { - $location_id = $_POST['location_id']; - $subnet_id = $_POST['subnet_id']; - - mysql_query("INSERT INTO subnetlocation (location_id, subnet_id) VALUE ('$location_id', '$subnet_id')") or die(mysql_error()); - - header("Location: subnetview.php?subnet_id=" . $subnet_id); - } - - $subnet_id = $_GET['subnet_id']; -?> - -
- - \ No newline at end of file diff --git a/assignvlantosubnet.php b/assignvlantosubnet.php index c877fb6..0ed0650 100644 --- a/assignvlantosubnet.php +++ b/assignvlantosubnet.php @@ -1,4 +1,29 @@ . + + 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 diff --git a/comments.php b/comments.php new file mode 100644 index 0000000..8107c3a --- /dev/null +++ b/comments.php @@ -0,0 +1,46 @@ +. + + 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/comments.tpl"); + + // set language variables + $tp->setvars($lang); + + // get error + $comments = $_GET['comments']; + + // set veriables + $tp->set("comments", $lang['lang_comments_' . $comments]); + + // output + $tp->parse(); + $tp->spit(); + + include("footer.php"); +?> \ No newline at end of file diff --git a/config.php b/config.php index fb1f1ca..4c32a17 100644 --- a/config.php +++ b/config.php @@ -1,52 +1,89 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + // version - $config_version = 'v0.3'; + $config_version = 'v0.4b'; // db connection - $mysql_host = "localhost"; - $mysql_username = "db_user"; - $mysql_password = "db_pass"; - $mysql_dbname = "db_name"; + $config_mysql_host = "localhost"; + $config_mysql_username = ''; + $config_mysql_password = ''; + $config_mysql_dbname = ''; - // standard password for new users - $config_user_lang = "en"; - $config_user_pass = "welcome"; - - // set userlevels - $config_userlevel_assetadd = 2; - $config_userlevel_assetdel = 2; - $config_userlevel_assetedit = 2; - $config_userlevel_assetview = 1; - $config_userlevel_assetclassadd = 2; - $config_userlevel_assetclassdel = 2; - $config_userlevel_assetclassedit = 2; - $config_userlevel_assetclassview = 1; - $config_userlevel_assetclassgroupadd = 2; - $config_userlevel_assetclassgroupdel = 2; - $config_userlevel_assetclassgroupedit = 2; - $config_userlevel_assetclassgroupview = 1; - $config_userlevel_locationadd = 2; - $config_userlevel_locationdel = 2; - $config_userlevel_locationedit = 2; - $config_userlevel_locationview = 1; - $config_userlevel_nodeadd = 2; - $config_userlevel_nodedel = 2; - $config_userlevel_nodeedit = 2; - $config_userlevel_nodeview = 1; - $config_userlevel_subnetadd = 2; - $config_userlevel_subnetdel = 2; - $config_userlevel_subnetedit = 2; - $config_userlevel_subnetview = 1; - $config_userlevel_useradd = 2; - $config_userlevel_userdel = 2; - $config_userlevel_useredit = 2; - $config_userlevel_userview = 1; - $config_userlevel_vlanadd = 2; - $config_userlevel_vlandel = 2; - $config_userlevel_vlanedit = 2; - $config_userlevel_vlanview = 1; + // default settings for new users + $config_user_lang = 'en'; + $config_user_pass = 'welcome'; // domain suffix for dns input fields - $config_dns1suffix = '.yourdomain.com'; - $config_dns2suffix = '.yourdomain.com'; + $config_dns1suffix = '.domain.com'; + $config_dns2suffix = '.domain.com'; + + // default colors for IP blocks + $config_color_blocked = 'FFFFFF'; + $config_color_unused = 'D3D3D3'; + + // set userlevels + $config_auth_assetadd = 2; + $config_auth_assetdel = 2; + $config_auth_assetedit = 2; + $config_auth_assetview = 1; + $config_auth_assetclassadd = 2; + $config_auth_assetclassdel = 2; + $config_auth_assetclassedit = 2; + $config_auth_assetclassview = 1; + $config_auth_assetclassgroupadd = 2; + $config_auth_assetclassgroupdel = 2; + $config_auth_assetclassgroupedit = 2; + $config_auth_assetclassgroupview = 1; + $config_auth_assigniptoasset = 2; + $config_auth_assigniptonode = 2; + $config_auth_assignlocationtosubnet = 2; + $config_auth_assignvlantosubnet = 2; + $config_auth_locationadd = 2; + $config_auth_locationdel = 2; + $config_auth_locationedit = 2; + $config_auth_locationview = 1; + $config_auth_nodeadd = 2; + $config_auth_nodedel = 2; + $config_auth_nodeedit = 2; + $config_auth_nodeview = 1; + $config_auth_subnetadd = 2; + $config_auth_subnetdel = 2; + $config_auth_subnetedit = 2; + $config_auth_subnetview = 1; + $config_auth_useradd = 2; + $config_auth_userdel = 2; + $config_auth_useredit = 2; + $config_auth_userview = 1; + $config_auth_userclassadd = 2; + $config_auth_userclassdel = 2; + $config_auth_userclassedit = 2; + $config_auth_userclassview = 1; + $config_auth_userclassauthadd = 2; + $config_auth_userclassauthdel = 2; + $config_auth_userclassauthedit = 2; + $config_auth_userclassauthview = 1; + $config_auth_vlanadd = 2; + $config_auth_vlandel = 2; + $config_auth_vlanedit = 2; + $config_auth_vlanview = 1; ?> \ No newline at end of file diff --git a/dbconnect.php b/dbconnect.php index 3b1007c..4452c46 100644 --- a/dbconnect.php +++ b/dbconnect.php @@ -1,4 +1,25 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + + mysql_connect($config_mysql_host,$config_mysql_username,$config_mysql_password); + mysql_select_db($config_mysql_dbname); ?> \ No newline at end of file diff --git a/error.php b/error.php deleted file mode 100644 index f70c603..0000000 --- a/error.php +++ /dev/null @@ -1,21 +0,0 @@ -setvars($lang); - - // get error - $error = $_GET['error']; - - // set veriables - $tp->set("error", $lang['lang_error_' . $error]); - - // output - $tp->parse(); - $tp->spit(); - - include("footer.php"); -?> \ No newline at end of file diff --git a/footer.php b/footer.php index f6f394e..82dc529 100644 --- a/footer.php +++ b/footer.php @@ -1,4 +1,25 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + // set template $tp = new Template("tpl/footer.tpl"); diff --git a/functions.php b/functions.php index 8ab1ecd..620644c 100644 --- a/functions.php +++ b/functions.php @@ -1,13 +1,34 @@ . + + For more information, visit http://sourceforge.net/projects/ipreg, + or contact me at wietsew@users.sourceforge.net + *****************************************************************************/ + // strip mac address to 12 char string function strip_mac($mac) { - $mac = str_replace('-', '', $mac); - $mac = str_replace(':', '', $mac); - $mac = str_replace('.', '', $mac); - $mac = str_replace(',', '', $mac); - $mac = str_replace(' ', '', $mac); + // strip chars we don't need + $mac = preg_replace("|[^a-fA-F0-9]|", "", $mac); + + // capotolize (just because it looks better eh) $mac = strtoupper($mac); + // and return return ($mac); } @@ -17,24 +38,22 @@ // if the MAC is empty, or for whatever reason incorrect, just return return $mac; } else { - // length is good, continue - $mac1 = substr($mac, 0, 2); - $mac2 = substr($mac, 2, 2); - $mac3 = substr($mac, 4, 2); - $mac4 = substr($mac, 6, 2); - $mac5 = substr($mac, 8, 2); - $mac6 = substr($mac, 10, 2); + // length is ok, continue + // strip mac to pieces + for($i=0;$i<12;$i++) { + ${"mac".$i} = $mac{$i}; + } + + // get user preference + $user_mac = $_SESSION['suser_mac']; - // check session for preference (if 0, do nothing), if changed: update useredit.php too! - if ($_SESSION['suser_mac']==1) { - $mac = $mac1 . '-' . $mac2 . '-' . $mac3 . '-' . $mac4 . '-' . $mac5 . '-' . $mac6; - } else if ($_SESSION['suser_mac']==2) { - $mac = $mac1 . ':' . $mac2 . ':' . $mac3 . ':' . $mac4 . ':' . $mac5 . ':' . $mac6; - } else if ($_SESSION['suser_mac']==3) { - $mac = $mac1 . $mac2 . $mac3 . '-' . $mac4 . $mac5 . $mac6; + // replace user preference with pieces + for($i=0;$i<12;$i++) { + $user_mac = preg_replace("/x/", ${"mac".$i}, $user_mac, 1); } - return $mac; + // and return + return $user_mac; } } @@ -43,4 +62,40 @@ header("location: " . $location); exit; } + + // authorisation check + function auth($item, $min_auth, $item_id) { + // get user_id + $suser_id = $_SESSION['suser_id']; + + // set base auth to 0 + $auth = 0; + + // check for global rights + $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='ipreg' AND uc.id=0 ORDER BY uc.ordering DESC LIMIT 1") or die(mysql_error()); + while ($row = mysql_fetch_object($result)) { + $auth = $row->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; + } + + // 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; + } + } + + if($auth<$min_auth) { + // not allowed -> redirect + header_location("comments.php?comments=notallowed"); + } else { + return $auth; + } + } ?> \ No newline at end of file diff --git a/gpl-3.0.txt b/gpl-3.0.txt new file mode 100644 index 0000000..e587591 --- /dev/null +++ b/gpl-3.0.txt @@ -0,0 +1,621 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc.- IP Reg - | -
+ IP Reg {config_version} + | +
+ +
+ Sourceforge Project Page: + | ++ http://sourceforge.net/projects/ipreg + | +
+ License: + | ++ GNU General Public License (GPL) + | +
+ +
+ Yapter Template Engine + | ++ http://yapter.sourceforge.net + | +
+ OWeb2 Images + | ++ http://www.oweb2.com/free-web20-icons-pack + | +
+ +
+ IP Reg, a PHP/MySQL IPAM tool + Copyright (C) 2008 Wietse Warendorff
+
+ This program is free software: you can redistribute it and/or modify
+
+ This program is distributed in the hope that it will be useful,
+
+ You should have received a copy of the GNU General Public License |
+
+ {lang_assets}: + | +
+ ![]() |
+
+ [BLOCK table AS asset]
+ {lang_asset_name} + |
- {lang_asset}: + {lang_assetclass_name} |
{asset_name} | ++ {assetclass_name} + | [END assetrow]