Compare commits

...

51 Commits
v0.4 ... master

Author SHA1 Message Date
Thomas Hooge 8e218fd4ba Fixed utf8 encoding for ldap dn 2023-12-22 10:42:58 +01:00
Thomas Hooge 7e73d8efbc Fixed search links 2023-08-29 08:44:13 +02:00
Thomas Hooge 05e85db3a7 Fixed and improved subnet add/edit 2023-03-15 07:43:46 +01:00
Thomas Hooge 303c22160d Fixed some display bugs and improved icons 2023-03-14 18:58:28 +01:00
Thomas Hooge 34112b8c1c Fix some image links 2023-03-13 14:58:22 +01:00
Thomas Hooge c76e8fe9d3 Added administrative password change feature 2023-03-12 17:05:34 +01:00
Thomas Hooge 4266a211e0 Changed language detection code, added some small features 2023-03-12 12:38:43 +01:00
Thomas Hooge aabd37bd1a Improved image-buttons and colored image creation 2023-03-11 17:29:44 +01:00
Thomas Hooge 20b54f5b27 Improved MAC address formatting 2023-03-11 08:59:59 +01:00
Thomas Hooge 02980bbad5 Checks before removing objects 2023-03-10 20:03:21 +01:00
Thomas Hooge 8c61638485 Remove footer.php and some small improvements 2023-03-10 19:31:07 +01:00
Thomas Hooge bfbdc16036 Implement node flags 2023-03-07 14:56:32 +01:00
Thomas Hooge 78b97c5094 Refactored, no more redirects. Improved error messaging system 2023-03-06 19:25:21 +01:00
Thomas Hooge 7cfcaeb9d7 Refactored asset and location 2023-03-04 14:55:07 +01:00
Thomas Hooge 32bd592098 Refactored user, vlan and zone 2023-03-03 19:33:52 +01:00
Thomas Hooge c63b500d77 Refactored assetclassgroup 2023-03-03 18:14:42 +01:00
Thomas Hooge ccdcfb968c Refactored assetclass 2023-03-03 14:36:39 +01:00
Thomas Hooge f0992b4b64 Some more minor GUI improvements 2023-03-03 07:48:35 +01:00
Thomas Hooge 6ebaea2d45 GUI improvements and new assetclass description 2023-03-02 18:58:04 +01:00
Thomas Hooge 6a5c483c42 Improved cable functions 2023-03-02 13:56:07 +01:00
Thomas Hooge 6e4c4236aa Some more bugfixing 2023-03-02 10:53:06 +01:00
Thomas Hooge 5e605692dd Add missing LDAP code to login 2023-03-02 08:40:55 +01:00
Thomas Hooge 1c8021c325 Added counter to assetclass and assetclassgroup views 2023-03-01 17:54:04 +01:00
Thomas Hooge 42a964c4b8 Added symbol for options 2023-03-01 15:52:04 +01:00
Thomas Hooge f0d187b4c3 More restrictions due to authorization system 2023-03-01 15:12:09 +01:00
Thomas Hooge 0b2da1f00f Added missing imagelinks in views 2023-03-01 10:10:36 +01:00
Thomas Hooge ac074eb944 Bumped version to 0.9 2023-03-01 10:02:42 +01:00
Thomas Hooge db26ffa611 Features LDAP, Rights, Cables, Menu improvements and bug fixing 2023-02-28 19:21:42 +01:00
Thomas Hooge 26e9c89405 Assettype field for active/passive network-components 2023-02-24 15:20:25 +01:00
Thomas Hooge 42e327776c Interface count for asset 2023-02-24 14:46:24 +01:00
Thomas Hooge 6c9a169600 Some more small fixes in user admin code 2023-02-24 14:21:28 +01:00
Thomas Hooge 02b3cfd23f Fix bugs in location code 2023-02-24 13:39:05 +01:00
Thomas Hooge 0696a16030 Merge branch 'pdo' 2023-02-24 12:59:23 +01:00
Thomas Hooge e74bde2d14 Subsequent fixes after major changes for PDO 2023-02-24 12:16:25 +01:00
Thomas Hooge b144555e46 Added LDAP auth 2023-02-24 09:29:18 +01:00
Thomas Hooge 7d6450706f Fix password change code 2023-02-23 12:30:11 +01:00
Thomas Hooge cb7f8ef649 Updated databasescript for new hashing algorithm 2023-02-23 10:56:00 +01:00
Thomas Hooge 08c6d42b3c Implemented better password hashing algorithm 2023-02-23 10:50:48 +01:00
Thomas Hooge c13c7494bf Preselect subnet in options if defined 2023-02-22 10:55:49 +01:00
Thomas Hooge 7c300e0a8f Changed database access to PDO using prepared statements 2023-02-22 10:50:24 +01:00
Thomas Hooge a4ecd1bff7 Fix PHP warnings and notices 2023-02-18 08:34:32 +01:00
Thomas Hooge be9610cd98 Fix styles and scripts in header 2023-02-18 07:49:25 +01:00
Thomas Hooge c500face92 Bumped version to 0.8 2023-02-17 19:35:43 +01:00
Thomas Hooge 37f4bd4185 Code formatting improved and some bugfixng 2023-02-17 19:09:10 +01:00
Thomas Hooge 808ae831bf Added some indices to database and more SQL simplification 2023-02-15 14:25:45 +01:00
Thomas Hooge 6df7a3f6a8 SQL Statements simplified and some bugfixing 2023-02-15 12:44:29 +01:00
Thomas Hooge ed33c0553d Example data swapped out for optional import 2023-02-14 14:34:58 +01:00
Thomas Hooge 23b73a387b Added improvements for empty database 2023-02-14 13:48:28 +01:00
Thomas Hooge cf27c1377c Added minor install instructions 2023-02-13 18:04:01 +01:00
Thomas Hooge ee582988e6 Moved towards smarty templates, support php7, switched to mysqli,
finalized language support and fixed some more bugs
2023-02-13 16:41:38 +01:00
Thomas Hooge 76ccecca7f Changes adopted from version 0.5 2023-02-13 10:42:09 +01:00
257 changed files with 11997 additions and 8489 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*~
tpl_c/*.php
config.php

View File

@ -1,44 +1,15 @@
<?php
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2008 Wietse Warendorff
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
Copyright (C) 2011-2023 Thomas Hooge
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
include("includes.php");
include("header.php");
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
$smarty->display("about.tpl");
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");
?>
$smarty->display("footer.tpl");

289
asset.php
View File

@ -1,54 +1,261 @@
<?php
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2008 Wietse Warendorff
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
Copyright (C) 2011-2023 Thomas Hooge
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
include("includes.php");
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
if (isset($_REQUEST['id'])) {
$id = (int) $_REQUEST['id'] or $id = 0;
}
For more information, visit http://sourceforge.net/projects/ipreg,
or contact me at wietsew@users.sourceforge.net
*****************************************************************************/
// ========== ACTIONS START ===================================================
switch ($submit = form_get_action()) {
// includes
include("includes.php");
case NULL: break;
// check authorisation
$auth = auth("asset", $config_auth_assetview, 0);
case 'add': $action = ACT_ADD; break;
case 'view': $action = ACT_VIEW; break;
case 'edit': $action = ACT_EDIT; break;
case 'del': $action = ACT_DELETE; break;
// start output
include("header.php");
case 'insert':
$name = sanitize($_POST['asset_name']);
$hostname = sanitize($_POST['asset_hostname']);
$assetclass_id = sanitize($_POST['assetclass_id']);
$info = sanitize($_POST['asset_info']);
$intf = sanitize($_POST['asset_intf']);
$asset_type = sanitize($_POST['asset_type']);
// set template
$tp = new Template("tpl/asset.tpl");
$sql = "INSERT INTO asset
(asset_name, asset_hostname, assetclass_id, asset_info,
asset_intf, asset_type)
VALUE
(?, ?, ?, ?, ?, ?)";
$sth = $dbh->prepare($sql);
$sth->execute([$name, $hostname, $assetclass_id, $info, $intf, $asset_type]);
$id = $dbh->lastInsertId();
$action = ACT_VIEW;
break;
// set language variables
$tp->setvars($lang);
case 'update':
$asset_name = sanitize($_POST['asset_name']);
$asset_info = sanitize($_POST['asset_info']);
$asset_intf = sanitize($_POST['asset_intf']);
$asset_hostname = sanitize($_POST['asset_hostname']);
$assetclass_id = sanitize($_POST['assetclass_id']);
$asset_type = sanitize($_POST['asset_type']);
// 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"));
$sql = "UPDATE asset SET
asset_name=?, asset_info=?, asset_hostname=?,
assetclass_id=?, asset_intf=?, asset_type=?
WHERE asset_id=?";
$sth = $dbh->prepare($sql);
try {
$sth->execute([$asset_name, $asset_info, $asset_hostname,
$assetclass_id, $asset_intf, $asset_type,
$id]);
} catch (PDOException $e) {
$g_error->Add($e->getMessage());
}
// Ext. links
if ($config_ext['zabbix']['enabled'] and isset($_POST['x_zbx_host'])) {
$zbx_host = sanitize($_POST['x_zbx_host']);
$sql = "SELECT extlink_id FROM extlink WHERE asset_id=? AND extlink_type='zabbix'";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
if ($linkid = $sth->fetchColumn()) {
$sql = "UPDATE extlink SET extlink_refid=? WHERE extlink_id=?";
$sth = $dbh->prepare($sql);
$sth->execute([$zbx_host, $linkid]);
} else {
$sql = "INSERT INTO extlink (asset_id, extlink_type, extlink_refid) VALUES (?, 'zabbix', ?)";
$sth = $dbh->prepare($sql);
$sth->execute([$id, $zbx_host]);
}
}
// output
$tp->parse();
$tp->spit();
$action = ACT_VIEW;
break;
include("footer.php");
?>
case 'delete':
$sth = $dbh->prepare("DELETE FROM asset WHERE asset_id=?");
$sth->execute([$id]);
$sth = $dbh->prepare("DELETE FROM node WHERE asset_id=?");
try {
$sth->execute([$id]);
} catch (PDOException $e) {
$g_error->Add($e->getMessage());
} $action = ACT_DEFAULT;
break;
default:
$g_error->Add(submit_error($submit));
$valid = FALSE;
}
// ========== ACTIONS END =====================================================
include("header.php");
if ($action == ACT_DEFAULT):
// ========== VARIANT: default behavior =======================================
// create letter links
$sql = "SELECT DISTINCT SUBSTRING(UPPER(asset_name),1,1) AS bst
FROM asset
ORDER BY bst";
$sth = $dbh->query($sql);
$alphabet = $sth->fetchAll();
$alphabet[] = ['bst' => '*'];
$smarty->assign("alphabet", $alphabet);
// total asset count
$sth = $dbh->query("SELECT COUNT(*) FROM asset");
$assetcount = $sth->fetchColumn();
$smarty->assign("assetcount", $assetcount);
// assets for current letter
if (isset($_GET['bst'])) {
$bst = sanitize($_GET['bst']);
} else {
$bst = $alphabet[0]['bst'];
}
$sql = "SELECT a.asset_id, IF(LENGTH(a.asset_name)>0, a.asset_name, '...') AS asset_name,
a.asset_info, c.assetclass_id, c.assetclass_name
FROM asset AS a LEFT OUTER JOIN assetclass AS c USING (assetclass_id)";
if ($bst != '*') {
$sql .= " WHERE SUBSTRING(a.asset_name,1,1)=?";
$p = array($bst);
} else {
$p = array();
}
$sql .= " ORDER BY a.asset_name";
$sth = $dbh->prepare($sql);
$sth->execute($p);
$smarty->assign("assets", $sth->fetchAll());
$smarty->display("asset.tpl");
elseif ($action == ACT_ADD):
// ========== VARIANT: add record =============================================
if((isset($_GET['assetclass_id'])) ? $assetclass_id = sanitize($_GET['assetclass_id']) : $assetclass_id = "");
$smarty->assign("assetclass_id", $assetclass_id);
$sql = "SELECT assetclass_id, assetclass_name
FROM assetclass
ORDER BY assetclass_name";
$sth = $dbh->query($sql);
$types = db_load_enum('asset','asset_type');
$smarty->assign("type_ids", $types);
$smarty->assign("type_names", $types);
$smarty->assign("type_selected", $types[0]);
$assetclass_options = array();
foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) {
$assetclass_options[$rec[0]] = $rec[1];
}
$smarty->assign("assetclass_options", $assetclass_options);
$smarty->display("assetadd.tpl");
elseif ($action == ACT_VIEW):
// ========== VARIANT: view single record =====================================
$sql = "SELECT a.asset_id, a.asset_name, a.asset_hostname, a.asset_info,
a.asset_intf, a.asset_type, c.assetclass_id, c.assetclass_name
FROM asset AS a LEFT OUTER JOIN assetclass AS c USING (assetclass_id)
WHERE a.asset_id=?";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$asset = $sth->fetch(PDO::FETCH_OBJ);
$smarty->assign("asset", $asset);
$sql = "SELECT node_id, node_ip, node.node_flags & 0x1 = 1 AS deleted,
CONCAT(LEFT(node_info, 40), IF(CHAR_LENGTH(node_info)>40,'...','')) AS node_info
FROM node
WHERE asset_id=?
ORDER BY INET_ATON(node_ip)";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$smarty->assign("nodes", $sth->fetchAll(PDO::FETCH_ASSOC));
// external systems
// extlink_id
// asset_id
// Type: enum('cdb','zabbix','topdesk', osticket
// ID: extlink_refid int
// extlink_uid string
if ($config_ext['zabbix']['enabled']) {
$smarty->assign("zabbix", true);
$sql = "SELECT extlink_refid FROM extlink WHERE extlink_type='zabbix' AND asset_id=?";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$refid = $sth->fetchColumn();
// TODO fetch ext data here
//$zbx = new PDO('mysql:host='.$config_ext['zabbix']['host'].';dbname='.$config_ext['zabbix']['db'].';', $config_ext['zabbix']['user'], $config_ext['zabbix']['pass']);
//$zbx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//$zbx->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$smarty->assign('refid', $refid);
}
$smarty->display("assetview.tpl");
elseif ($action == ACT_EDIT):
// ========== VARIANT: edit single record =====================================
$sql = "SELECT asset_id, asset_name, asset_hostname, asset_info, asset_intf,
assetclass_id, asset_type
FROM asset
WHERE asset_id=?";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$smarty->assign("asset", $sth->fetch(PDO::FETCH_OBJ));
// Type selection
$smarty->assign("type_ids", ['active', 'passive']);
$smarty->assign("type_names", ['Active', 'Passive']);
$smarty->assign("assetclass_options", db_get_options_assetclass());
$smarty->display("assetedit.tpl");
elseif ($action == ACT_DELETE):
// ========== VARIANT: delete record ==========================================
// asset to delete
$sth = $dbh->prepare("SELECT asset_name FROM asset WHERE asset_id=?");
$sth->execute([$id]);
$smarty->assign("asset_id", $id);
$smarty->assign("asset_name", $sth->fetchColumn());
// nodes to delete
$sql = "SELECT node_id, node_ip FROM node WHERE asset_id=? ORDER BY INET_ATON(node_ip)";
$sth = $dbh->prepare($sql);
$sth->execute([$asset_id]);
$smarty->assign("nodes", $sth->fetchAll(PDO::FETCH_ASSOC));
$smarty->display("assetdel.tpl");
else:
// ========== ERROR UNKNOWN VARIANT ===========================================
echo "<p>Unknown function call: Please report to system development!</p>\n";
endif; // $action == ...
// ========== END OF VARIANTS =================================================
$smarty->display('footer.tpl');

View File

@ -1,56 +0,0 @@
<?php
/*****************************************************************************
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/>.
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
$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");
?>

View File

@ -1,52 +1,174 @@
<?php
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2008 Wietse Warendorff
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
Copyright (C) 2011-2023 Thomas Hooge
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
include("includes.php");
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
if (isset($_REQUEST['id'])) {
$id = (int) $_REQUEST['id'] or $id = 0;
}
For more information, visit http://sourceforge.net/projects/ipreg,
or contact me at wietsew@users.sourceforge.net
*****************************************************************************/
// ========== ACTIONS START ===================================================
switch ($submit = form_get_action()) {
// includes
include("includes.php");
case NULL: break;
// check authorisation
$auth = auth("assetclass", $config_auth_assetclassview, 0);
case 'add': $action = ACT_ADD; break;
case 'view': $action = ACT_VIEW; break;
case 'edit': $action = ACT_EDIT; break;
case 'del': $action = ACT_DELETE; break;
// start output
include("header.php");
case 'insert':
$name = sanitize($_POST['assetclass_name']);
$description = sanitize($_POST['assetclass_description']);
$group_id = sanitize($_POST['assetclassgroup_id']);
// set template
$tp = new Template("tpl/assetclass.tpl");
$sql = "INSERT INTO assetclass
(assetclass_name, assetclass_description, assetclassgroup_id)
VALUE
(?, ?, ?)";
$sth = $dbh->prepare($sql);
try {
$sth->execute([$name, $description, $group_id]);
} catch (PDOException $e) {
$g_error->Add($e->getMessage());
}
$id = $dbh->lastInsertId();
$action = ACT_VIEW;
break;
// set language variables
$tp->setvars($lang);
case 'update':
$name = sanitize($_POST['assetclass_name']);
$description = sanitize($_POST['assetclass_description']);
$group_id = sanitize($_POST['assetclassgroup_id']);
// 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"));
$sql = "UPDATE assetclass SET
assetclass_name=?, assetclass_description=?,
assetclassgroup_id=?
WHERE assetclass_id=?";
$sth = $dbh->prepare($sql);
try {
$sth->execute([$name, $description, $group_id, $id]);
} catch (PDOException $e) {
$g_error->Add($e->getMessage());
} $action = ACT_VIEW;
break;
// output
$tp->parse();
$tp->spit();
case 'delete':
$sth = $dbh->prepare("SELECT COUNT(*) FROM asset WHERE assetclass_id=?");
$sth->execute([$id]);
if ($sth->fetchColumn() > 0) {
$g_warning->Add("Objektklasse kann nicht gelöscht werden, da noch zugeordnete Objekte vorhanden sind.");
$action = ACT_VIEW;
break;
}
$sth = $dbh->prepare("DELETE FROM assetclass WHERE assetclass_id=?");
try {
$sth->execute([$id]);
} catch (PDOException $e) {
$g_error->Add($e->getMessage());
}
$action = ACT_DEFAULT;
break;
include("footer.php");
?>
default:
$g_error->Add(submit_error($submit));
$valid = FALSE;
}
// ========== ACTIONS END =====================================================
include("header.php");
if ($action == ACT_DEFAULT):
// ========== VARIANT: default behavior =======================================
$sql = "SELECT c.assetclass_id AS id, c.assetclass_name AS name, c.assetclassgroup_id AS group_id,
g.assetclassgroup_name AS group_name, g.assetclassgroup_color AS color,
COUNT(a.asset_id) AS count_asset
FROM assetclass AS c
LEFT JOIN assetclassgroup AS g USING (assetclassgroup_id)
LEFT JOIN asset AS a USING (assetclass_id)
GROUP BY id, name, group_id, group_name, color
ORDER BY c.assetclass_name";
$sth = $dbh->query($sql);
$smarty->assign("assetclasses", $sth->fetchAll(PDO::FETCH_ASSOC));
$smarty->display("assetclass.tpl");
elseif ($action == ACT_ADD):
// ========== VARIANT: add record =============================================
if (isset($_GET['assetclassgroup_id'])) {
$group_id = sanitize($_GET['assetclassgroup_id']);
} else {
$group_id = '';
}
$smarty->assign("group_id", $group_id);
$smarty->assign("assetclassgroup_options", db_get_options_assetclassgroup());
$smarty->display("assetclassadd.tpl");
elseif ($action == ACT_VIEW):
// ========== VARIANT: view single record =====================================
$sql = "SELECT a.assetclass_id, a.assetclass_name, g.assetclassgroup_id,
a.assetclass_description,
g.assetclassgroup_name, g.assetclassgroup_color
FROM assetclass AS a LEFT OUTER JOIN assetclassgroup AS g USING (assetclassgroup_id)
WHERE a.assetclass_id=?";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$smarty->assign("assetclass", $sth->fetch(PDO::FETCH_OBJ));
$sql = "SELECT asset_id, asset_name,
CONCAT(LEFT(asset_info, 80), IF(CHAR_LENGTH(asset_info)>80,'...','')) AS asset_info
FROM asset
WHERE assetclass_id=?
ORDER BY asset_name";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$smarty->assign("assets", $sth->fetchAll(PDO::FETCH_ASSOC));
$smarty->display("assetclassview.tpl");
elseif ($action == ACT_EDIT):
// ========== VARIANT: edit single record =====================================
$sql = "SELECT assetclass_id AS id, assetclass_name AS name,
assetclass_description AS description,
assetclassgroup_id AS group_id
FROM assetclass
WHERE assetclass_id=?";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$smarty->assign("assetclass", $sth->fetch(PDO::FETCH_OBJ));
$smarty->assign("assetclassgroup_options", db_get_options_assetclassgroup());
$smarty->display("assetclassedit.tpl");
elseif ($action == ACT_DELETE):
// ========== VARIANT: delete record ==========================================
$sql = "SELECT assetclass_id AS id, assetclass_name AS name
FROM assetclass
WHERE assetclass_id=?";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$smarty->assign("assetclass", $sth->fetch(PDO::FETCH_OBJ));
$smarty->display("assetclassdel.tpl");
else:
// ========== ERROR UNKNOWN VARIANT ===========================================
echo "<p>Unknown function call: Please report to system development!</p>\n";
endif; // $action == ...
// ========== END OF VARIANTS =================================================
$smarty->display('footer.tpl');

View File

@ -1,56 +0,0 @@
<?php
/*****************************************************************************
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/>.
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
$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");
?>

View File

@ -1,52 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
// set language variables
$tp->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();
include("footer.php");
?>

View File

@ -1,64 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
// set language variables
$tp->setvars($lang);
// 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"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

View File

@ -1,53 +1,163 @@
<?php
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2008 Wietse Warendorff
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
Copyright (C) 2011-2023 Thomas Hooge
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
include("includes.php");
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
if (isset($_REQUEST['id'])) {
$id = (int) $_REQUEST['id'] or $id = 0;
}
For more information, visit http://sourceforge.net/projects/ipreg,
or contact me at wietsew@users.sourceforge.net
*****************************************************************************/
// ========== ACTIONS START ===================================================
switch ($submit = form_get_action()) {
// includes
include("includes.php");
case NULL: break;
// check authorisation
$auth = auth("assetclassgroup", $config_auth_assetclassgroupview, 0);
case 'add': $action = ACT_ADD; break;
case 'view': $action = ACT_VIEW; break;
case 'edit': $action = ACT_EDIT; break;
case 'del': $action = ACT_DELETE; break;
// start output
include("header.php");
case 'insert':
$name = sanitize($_POST['acg_name']);
$color = preg_replace("|[^a-zA-Z0-9]|", "", strtoupper(sanitize($_POST['acg_color'])));
$desc = sanitize($_POST['acg_description']);
// set template
$tp = new Template("tpl/assetclassgroup.tpl");
$sql = "INSERT INTO assetclassgroup
(assetclassgroup_name, assetclassgroup_color, assetclassgroup_description)
VALUE
(?, ?, ?)";
$sth = $dbh->prepare($sql);
try {
$sth->execute([$name, $color, $desc]);
} catch (PDOException $e) {
$g_error->Add($e->getMessage());
} $id = $dbh->lastInsertId();
$action = ACT_VIEW;
break;
// set language variables
$tp->setvars($lang);
case 'update':
$acg_name = sanitize($_POST['acg_name']);
$acg_desc = sanitize($_POST['acg_description']);
$acg_color = preg_replace("|[^a-zA-Z0-9]|", "", strtoupper(sanitize($_POST['acg_color'])));
// 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"));
$sql = "UPDATE assetclassgroup SET
assetclassgroup_name=?, assetclassgroup_color=?, assetclassgroup_description=?
WHERE assetclassgroup_id=?";
$sth = $dbh->prepare($sql);
try {
$sth->execute([$acg_name, $acg_color, $acg_desc, $id]);
} catch (PDOException $e) {
$g_error->Add($e->getMessage());
}
$action = ACT_VIEW;
break;
// output
$tp->parse();
$tp->spit();
case 'delete':
$sth = $dbh->prepare("SELECT COUNT(*) FROM assetclass WHERE assetclassgroup_id=?");
$sth->execute([$id]);
if ($sth->fetchColumn() > 0) {
$g_warning->Add("Objektklassengruppe kann nicht gelöscht werden, da noch zugeordnete Objektklassen vorhanden sind.");
$action = ACT_VIEW;
break;
}
$sth = $dbh->prepare("DELETE FROM assetclassgroup WHERE assetclassgroup_id=?");
try {
$sth->execute([$id]);
} catch (PDOException $e) {
$g_error->Add($e->getMessage());
} $action = ACT_DEFAULT;
break;
// end output
include("footer.php");
?>
default:
$g_error->Add(submit_error($submit));
$valid = FALSE;
}
// ========== ACTIONS END =====================================================
$smarty->assign("scripts", 'jscolor.js');
include("header.php");
if ($action == ACT_DEFAULT):
// ========== VARIANT: default behavior =======================================
$sql = "SELECT g.assetclassgroup_id AS id, g.assetclassgroup_name AS name,
g.assetclassgroup_color AS color, g.assetclassgroup_description AS description,
COUNT(c.assetclass_id) AS count_class
FROM assetclassgroup AS g LEFT JOIN assetclass AS c USING (assetclassgroup_id)
GROUP BY id, name, color, description
ORDER BY g.assetclassgroup_name";
$sth = $dbh->query($sql);
$smarty->assign('assetclassgroups', $sth->fetchAll(PDO::FETCH_ASSOC));
$smarty->display("assetclassgroup.tpl");
elseif ($action == ACT_ADD):
// ========== VARIANT: add record =============================================
$smarty->display("assetclassgroupadd.tpl");
elseif ($action == ACT_VIEW):
// ========== VARIANT: view single record =====================================
$sql = "SELECT assetclassgroup_id AS id,
assetclassgroup_name AS name,
assetclassgroup_color AS color,
assetclassgroup_description AS description
FROM assetclassgroup
WHERE assetclassgroup_id=?";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$smarty->assign("assetclassgroup", $sth->fetch(PDO::FETCH_OBJ));
$sql = "SELECT assetclass_id, assetclass_name
FROM assetclass
WHERE assetclassgroup_id=?
ORDER BY assetclass_name";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$smarty->assign("assetclasses", $sth->fetchAll(PDO::FETCH_ASSOC));
$smarty->display("assetclassgroupview.tpl");
elseif ($action == ACT_EDIT):
// ========== VARIANT: edit single record =====================================
$sql = "SELECT assetclassgroup_id AS id, assetclassgroup_name AS name,
assetclassgroup_color AS color,
assetclassgroup_description AS description
FROM assetclassgroup
WHERE assetclassgroup_id=?";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$smarty->assign("assetclassgroup", $sth->fetch(PDO::FETCH_OBJ));
$smarty->display("assetclassgroupedit.tpl");
elseif ($action == ACT_DELETE):
// ========== VARIANT: delete record ==========================================
$sql = "SELECT assetclassgroup_id AS id, assetclassgroup_name AS name
FROM assetclassgroup
WHERE assetclassgroup_id=?";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$smarty->assign("assetclassgroup", $sth->fetch(PDO::FETCH_OBJ));
$smarty->display("assetclassgroupdel.tpl");
else:
// ========== ERROR UNKNOWN VARIANT ===========================================
echo "<p>Unknown function call: Please report to system development!</p>\n";
endif; // $action == ...
// ========== END OF VARIANTS =================================================
$smarty->display('footer.tpl');

View File

@ -1,43 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
?>

View File

@ -1,52 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
?>

View File

@ -1,53 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
?>

View File

@ -1,61 +0,0 @@
<?php
/*****************************************************************************
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/>.
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);
$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");
?>

View File

@ -1,63 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
// set language variables
$tp->setvars($lang);
// 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);
// 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"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

View File

@ -1,61 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
// 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);
// 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"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

View File

@ -1,65 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
// 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");
?>

View File

@ -1,73 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
// 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");
?>

View File

@ -1,76 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
?>

View File

@ -1,54 +0,0 @@
<?php
/*****************************************************************************
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/>.
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
$ip = $_GET['ip'];
$subnet_id = $_GET['subnet_id'];
// set template
$tp = new Template("tpl/assigniptonode.tpl");
// set language variables
$tp->setvars($lang);
// set variables
$tp->set("ip", $ip);
$tp->set("subnet_id", $subnet_id);
// 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);
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

View File

@ -1,65 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
?>

View File

@ -1,66 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
?>

205
cable.php Normal file
View File

@ -0,0 +1,205 @@
<?php
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
Copyright (C) 2011-2023 Thomas Hooge
SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
include("includes.php");
if ($_SESSION['suser_role_admin'] == 0) {
$g_error->add('Access denied!');
$action = ACT_ERR_DENIED;
}
if (isset($_REQUEST['id'])) {
$id = (int) $_REQUEST['id'] or $id = 0;
}
$ctypes = array('copper' => 'Copper', 'fibre' => 'Fibre',
'laser' => 'Laserlink', 'radio' => 'Radiolink');
// ========== ACTIONS START ===================================================
switch ($submit = form_get_action()) {
case NULL: break;
case 'add': $action = ACT_ADD; break;
case 'view': $action = ACT_VIEW; break;
case 'edit': $action = ACT_EDIT; break;
case 'del': $action = ACT_DELETE; break;
case 'insert':
$description = sanitize($_POST['description']);
$length = sanitize($_POST['length']);
$color = sanitize($_POST['color']);
$type = sanitize($_POST['cable_type']);
$links = sanitize($_POST['links']);
$info = sanitize($_POST['info']);
$sql = "INSERT INTO cable
(cable_description, cable_color, cable_type, cable_links,
cable_length, cable_info)
VALUES
(:description, :color, :type, :links,
:length, :info)";
$sth = $dbh->prepare($sql);
try {
$sth->bindValue(':description', $description, PDO::PARAM_STR);
$sth->bindValue(':length', $length, PDO::PARAM_INT);
$sth->bindValue(':color', $color, PDO::PARAM_STR);
$sth->bindValue(':type', $type, PDO::PARAM_STR);
$sth->bindValue(':links', $info, PDO::PARAM_INT);
$sth->bindValue(':info', $info, PDO::PARAM_STR);
$sth->execute();
$id = $dbh->lastInsertId();
$action = ACT_VIEW;
} catch (PDOException $e) {
$g_error->Add($e->getMessage());
if ($e->getCode() == 23000) {
// duplicate key
$g_warning->Add("Save failed");
$g_warning->Add("Cable description '$description' already in use!");
}
// reassign entered values
$smarty->assign('length', $length);
$smarty->assign('type', $type);
$smarty->assign('links', $links);
$smarty->assign('color', $color);
$smarty->assign('info', $info);
$action = ACT_ADD;
}
break;
case 'update':
$description = sanitize($_POST['description']);
$color = sanitize($_POST['color']);
$length = sanitize($_POST['length']);
$type = sanitize($_POST['cable_type']);
$links = sanitize($_POST['links']);
$info = sanitize($_POST['info']);
$sql = "UPDATE cable
SET cable_description=:desc,
cable_color=:color,
cable_length=:length,
cable_type=:type,
cable_links=:links,
cable_info=:info
WHERE cable_id=:id";
$sth = $dbh->prepare($sql);
$sth->bindValue(':id', $id, PDO::PARAM_INT);
$sth->bindValue(':desc', $description, PDO::PARAM_STR);
$sth->bindValue(':length', $length, PDO::PARAM_INT);
$sth->bindValue(':color', $color, PDO::PARAM_STR);
$sth->bindValue(':type', $type, PDO::PARAM_STR);
$sth->bindValue(':links', $links, PDO::PARAM_INT);
$sth->bindValue(':info', $info, PDO::PARAM_STR);
try {
$sth->execute();
} catch (PDOException $e) {
$g_error->Add($e->getMessage());
}
$action = ACT_VIEW;
break;
case 'delete':
$sth = $dbh->prepare("DELETE FROM cable WHERE cable_id=?");
try {
$sth->execute([$id]);
} catch (PDOException $e) {
$g_error->Add($e->getMessage());
}
$action = ACT_DEFAULT;
break;
default:
$g_error->Add(submit_error($submit));
$valid = FALSE;
}
// ========== ACTIONS END =====================================================
$smarty->assign("scripts", 'jscolor.js');
include("header.php");
// ========== PAGE CONTENT ====================================================
if ($action == ACT_DEFAULT):
// ========== VARIANT: default behavior =======================================
$sql = "SELECT cable_id AS id, cable_description AS description,
cable_from_id, cable_to_id, cable_length, cable_links,
cable_type, cable_color,
CONCAT(LEFT(cable_info, 60), IF(CHAR_LENGTH(cable_info)>60,'...','')) AS info
FROM cable
ORDER BY cable_description";
$sth = $dbh->query($sql);
$smarty->assign("cables", $sth->fetchAll());
$smarty->display("cable.tpl");
elseif ($action == ACT_ADD):
// ========== VARIANT: add record =============================================
$smarty->assign('type_options', $ctypes);
$smarty->display('cableadd.tpl');
elseif ($action == ACT_VIEW):
// ========== VARIANT: view single record =====================================
$sql = "SELECT cable_id AS id, cable_description AS description,
cable_from_id, cable_to_id, cable_length, cable_links,
cable_type, cable_color AS color, cable_info AS info
FROM cable
WHERE cable_id=?";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$smarty->assign('cable', $sth->fetch(PDO::FETCH_OBJ));
$smarty->display('cableview.tpl');
elseif ($action == ACT_EDIT):
// ========== VARIANT: edit single record =====================================
$sql = "SELECT cable_id AS id, cable_description AS description,
cable_from_id, cable_to_id, cable_length, cable_links,
cable_type, cable_color AS color, cable_info AS info
FROM cable
WHERE cable_id=?";
$sth = $dbh->prepare($sql);
$sth->execute([$id]);
$smarty->assign('cable', $sth->fetch(PDO::FETCH_OBJ));
$smarty->assign('type_options', $ctypes);
$smarty->display('cableedit.tpl');
elseif ($action == ACT_DELETE):
// ========== VARIANT: delete record ==========================================
$sth = $dbh->prepare("SELECT cable_description FROM cable WHERE cable_id=?");
$sth->execute([$id]);
$smarty->assign('id', $id);
$smarty->assign('description', $sth->fetchColumn());
$smarty->display('cabledel.tpl');
elseif ($action == ACT_ERR_DENIED):
// ========== ERROR ACCESS TO PAGE DENIED =====================================
if (isset($_SERVER['HTTP_REFERER'])) {
echo '<p"><a href="', $_SERVER['HTTP_REFERER'], '">', "Back to last page</a></p>\n";
}
echo "<p></p>";
else:
// ========== ERROR UNKNOWN VARIANT ===========================================
echo "<p>Unknown function call: Please report to system development!</p>\n";
endif; // $action == ...
// ========== END OF VARIANTS =================================================
$smarty->display('footer.tpl');
?>

View File

@ -1,46 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
?>

View File

@ -1,89 +0,0 @@
<?php
/*****************************************************************************
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/>.
For more information, visit http://sourceforge.net/projects/ipreg,
or contact me at wietsew@users.sourceforge.net
*****************************************************************************/
// version
$config_version = 'v0.4b';
// db connection
$config_mysql_host = "localhost";
$config_mysql_username = '';
$config_mysql_password = '';
$config_mysql_dbname = '';
// default settings for new users
$config_user_lang = 'en';
$config_user_pass = 'welcome';
// domain suffix for dns input fields
$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;
?>

46
config.php-sample Normal file
View File

@ -0,0 +1,46 @@
<?php
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
Copyright (C) 2011-2023 Thomas Hooge
SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
// application settings
$config_app_session = 'ipreg';
// db connection
$config_mysql_host = 'localhost';
$config_mysql_username = 'ipreg';
$config_mysql_password = 'changeme!';
$config_mysql_dbname = 'ipreg';
// default values for IP blocks
$config_color_blocked = 'dcdcdc';
$config_color_unused = 'ffffff';
$config_color_dynamic = 'e0e0e0';
// language
$config_lang_default = 'en';
// auth
$config_auth_ldap = false;
$config_ldap_host = array('localhost', 'otherhost.example.com');
$config_ldap_port = 389;
$config_ldap_v3 = true;
$config_ldap_base_dn = 'ou=organizationalunit,dc=example,dc=com';
$config_ldap_login_attr = 'uid';
// ldap search user
$config_ldap_bind_dn = 'cn=dummy,ou=organizationalunit,dc=example,dc=com';
$config_ldap_bind_pass = 'secret';
// external systems
$config_ext[] = [
'zabbix' => ['enabled' => false,
'host' => 'localhost',
'db' => 'zabbix',
'user' => 'ipreg',
'pass' => 'topsecret']
];

View File

@ -1,25 +0,0 @@
<?php
/*****************************************************************************
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/>.
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);
?>

View File

@ -1,32 +0,0 @@
<?php
/*****************************************************************************
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/>.
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");
// get version for the footer-stamp
$tp->set("config_version", $config_version);
// output
$tp->parse();
$tp->spit();
?>

View File

@ -1,101 +0,0 @@
<?php
/*****************************************************************************
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/>.
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) {
// 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);
}
// rebuild mac address
function write_mac($mac) {
if (strlen($mac)!=12) {
// if the MAC is empty, or for whatever reason incorrect, just return
return $mac;
} else {
// 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'];
// replace user preference with pieces
for($i=0;$i<12;$i++) {
$user_mac = preg_replace("/x/", ${"mac".$i}, $user_mac, 1);
}
// and return
return $user_mac;
}
}
// redirect page
function header_location($location) {
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;
}
}
?>

View File

@ -1,51 +1,64 @@
<?php
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2008 Wietse Warendorff
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
Copyright (C) 2011-2023 Thomas Hooge
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
include('lang/' . $_SESSION['suser_language'] . '.php');
$smarty->assign($lang);
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
For more information, visit http://sourceforge.net/projects/ipreg,
or contact me at wietsew@users.sourceforge.net
*****************************************************************************/
// include language file
include('lang/' . $_SESSION['suser_lang'] . '.php');
// set template
$tp = new Template("tpl/header.tpl");
// set language variables
$tp->setvars($lang);
// set search box
if (isset($_POST['search'])) {
$search = $_POST['search'];
$_SESSION['search'] = $search;
// search box
if (isset($_POST['search'])) {
$search = sanitize($_POST['search']);
$_SESSION['search'] = $search;
} else {
if (isset($_SESSION['search'])) {
$search = $_SESSION['search'];
} else {
if(isset($_SESSION['search'])) {
$search = $_SESSION['search'];
} else {
$search = '';
}
$search = '';
}
}
// set global template vars
$tp->set("config_version", $config_version);
$tp->set("search", $search);
$smarty->assign("config_version", $config_version);
$smarty->assign("suser_name", $_SESSION['suser_displayname']);
$smarty->assign("search", $search);
// menu
$menu = array();
if ($_SESSION['suser_menu_assets']) {
$menu[] = '<a href="asset.php">' . $lang['lang_assets'] . "</a>\n";
}
if ($_SESSION['suser_menu_assetclasses']) {
$menu[] = '<a href="assetclass.php">' . $lang['lang_assetclasses'] . "</a>\n";
}
if ($_SESSION['suser_menu_assetclassgroups']) {
$menu[] = '<a href="assetclassgroup.php">' . $lang['lang_assetclassgroups'] . "</a>\n";
}
if ($_SESSION['suser_menu_locations']) {
$menu[] = '<a href="location.php">' . $lang['lang_locations'] . "</a>\n";
}
if ($_SESSION['suser_menu_nodes']) {
$menu[] = '<a href="node.php">' . $lang['lang_nodes'] . "</a>\n";
}
if ($_SESSION['suser_menu_nats']) {
$menu[] = '<a href="nat.php">' . $lang['lang_nats'] . "</a>\n";
}
if ($_SESSION['suser_menu_subnets']) {
$menu[] = '<a href="subnet.php">' . $lang['lang_subnets'] . "</a>\n";
}
if ($_SESSION['suser_menu_vlans']) {
$menu[] = '<a href="vlan.php">' . $lang['lang_vlans'] . "</a>\n";
}
if ($_SESSION['suser_menu_cables']) {
$menu[] = '<a href="cable.php">' . $lang['lang_cables'] . "</a>\n";
}
if ($_SESSION['suser_menu_zones']) {
$menu[] = '<a href="zone.php">' . $lang['lang_zones'] . "</a>\n";
}
$smarty->assign("menu", implode(' | ', $menu));
$smarty->display("header.tpl");
// output
$tp->parse();
$tp->spit();
?>

View File

@ -1,16 +1,39 @@
<?php
// get desired color
$color = $_GET['color'];
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
Copyright (C) 2011-2023 Thomas Hooge
// create base image
$image = imagecreatetruecolor(6, 6);
SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
// fill image with color
$color = imagecolorallocate($image, hexdec(substr($color,0,2)), hexdec(substr($color,2,2)), hexdec(substr($color,4,2)));
imagefill($image, 0, 0, $color);
include('config.php');
// display image
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>
session_name($config_app_session);
session_start();
function valid_color($color, $default='888888') {
// safe return a 6 character color string in uppercase
// input can be length of 3 or 6
if (! isset($color) or ! ctype_xdigit($color)) {
return $default;
}
if(strlen($color) == 3) {
// duplicate characters
$col6 = '';
for ($i=1; $i<=3; $i++) {
$col6 .= $color[$i].$color[$i];
}
return strtoupper($col6);
}
return strtoupper($color);
}
$color = valid_color($_GET['color'], '444');
$image = imagecreatetruecolor($_SESSION['suser_imagesize'], $_SESSION['suser_imagesize']);
$color = imagecolorallocate($image, hexdec(substr($color,0,2)), hexdec(substr($color,2,2)), hexdec(substr($color,4,2)));
imagefill($image, 0, 0, $color);
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 B

BIN
images/add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

BIN
images/admin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

BIN
images/arrow_left.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

BIN
images/arrow_right.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

BIN
images/asset.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

BIN
images/background.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

BIN
images/bin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

BIN
images/breadcrumb.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 B

BIN
images/brick.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

BIN
images/brick_add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 841 B

BIN
images/brick_delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 792 B

BIN
images/brick_edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 849 B

BIN
images/bricks.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 884 B

BIN
images/building.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

BIN
images/building_add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

BIN
images/building_delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

BIN
images/building_edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

BIN
images/cancel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 B

BIN
images/comment.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 B

BIN
images/delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

BIN
images/disconnect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B

BIN
images/edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

BIN
images/error.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

BIN
images/exclamation.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

BIN
images/fastforward.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 736 B

BIN
images/information.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

BIN
images/key_add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

BIN
images/link.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B

BIN
images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/magnifier.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

BIN
images/manage.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

BIN
images/minus.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

BIN
images/nat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

BIN
images/network-ethernet.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/network-ethernet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 B

BIN
images/note.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

BIN
images/page.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

BIN
images/page_red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

BIN
images/plugin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

BIN
images/plus.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 B

BIN
images/report.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

BIN
images/rewind.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 B

BIN
images/save.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

BIN
images/settings.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 812 B

BIN
images/shield.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/shield.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

BIN
images/table.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

BIN
images/table_add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

BIN
images/table_delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

BIN
images/table_edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

BIN
images/table_go.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

BIN
images/table_save.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 B

BIN
images/tag.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

BIN
images/tag_add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

BIN
images/tag_delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

BIN
images/tag_edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B

BIN
images/user.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 741 B

BIN
images/user_add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

BIN
images/user_delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 767 B

BIN
images/user_edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 B

BIN
images/user_female.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Some files were not shown because too many files have changed in this diff Show More