Compare commits
51 Commits
Author | SHA1 | Date |
---|---|---|
|
8e218fd4ba | |
|
7e73d8efbc | |
|
05e85db3a7 | |
|
303c22160d | |
|
34112b8c1c | |
|
c76e8fe9d3 | |
|
4266a211e0 | |
|
aabd37bd1a | |
|
20b54f5b27 | |
|
02980bbad5 | |
|
8c61638485 | |
|
bfbdc16036 | |
|
78b97c5094 | |
|
7cfcaeb9d7 | |
|
32bd592098 | |
|
c63b500d77 | |
|
ccdcfb968c | |
|
f0992b4b64 | |
|
6ebaea2d45 | |
|
6a5c483c42 | |
|
6e4c4236aa | |
|
5e605692dd | |
|
1c8021c325 | |
|
42a964c4b8 | |
|
f0d187b4c3 | |
|
0b2da1f00f | |
|
ac074eb944 | |
|
db26ffa611 | |
|
26e9c89405 | |
|
42e327776c | |
|
6c9a169600 | |
|
02b3cfd23f | |
|
0696a16030 | |
|
e74bde2d14 | |
|
b144555e46 | |
|
7d6450706f | |
|
cb7f8ef649 | |
|
08c6d42b3c | |
|
c13c7494bf | |
|
7c300e0a8f | |
|
a4ecd1bff7 | |
|
be9610cd98 | |
|
c500face92 | |
|
37f4bd4185 | |
|
808ae831bf | |
|
6df7a3f6a8 | |
|
ed33c0553d | |
|
23b73a387b | |
|
cf27c1377c | |
|
ee582988e6 | |
|
76ccecca7f |
|
@ -0,0 +1,3 @@
|
|||
*~
|
||||
tpl_c/*.php
|
||||
config.php
|
49
about.php
|
@ -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");
|
||||
|
|
287
asset.php
|
@ -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");
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
if (($i>0) ? $tp->parse("asset") : $tp->hide("asset"));
|
||||
|
||||
// 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');
|
||||
|
|
56
assetadd.php
|
@ -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");
|
||||
?>
|
202
assetclass.php
|
@ -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");
|
||||
|
||||
// set language variables
|
||||
$tp->setvars($lang);
|
||||
|
||||
// get assetclass info
|
||||
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name") or die(mysql_error());
|
||||
for ($i=0;$row=mysql_fetch_object($result);$i++) {
|
||||
$tp->set("assetclass_id", $row->assetclass_id);
|
||||
$tp->set("assetclass_name", $row->assetclass_name);
|
||||
$tp->parse("assetclassrow");
|
||||
$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());
|
||||
}
|
||||
if (($i>0) ? $tp->parse("assetclass") : $tp->hide("assetclass"));
|
||||
$id = $dbh->lastInsertId();
|
||||
$action = ACT_VIEW;
|
||||
break;
|
||||
|
||||
// output
|
||||
$tp->parse();
|
||||
$tp->spit();
|
||||
case 'update':
|
||||
$name = sanitize($_POST['assetclass_name']);
|
||||
$description = sanitize($_POST['assetclass_description']);
|
||||
$group_id = sanitize($_POST['assetclassgroup_id']);
|
||||
|
||||
include("footer.php");
|
||||
?>
|
||||
$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;
|
||||
|
||||
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;
|
||||
|
||||
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');
|
||||
|
|
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
$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());
|
||||
}
|
||||
if (($i>0) ? $tp->parse("assetclassgroup") : $tp->hide("assetclassgroup"));
|
||||
$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');
|
||||
|
|
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
?>
|
61
assetdel.php
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
?>
|
|
@ -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");
|
||||
?>
|
|
@ -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');
|
||||
?>
|
46
comments.php
|
@ -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");
|
||||
?>
|
89
config.php
|
@ -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;
|
||||
?>
|
|
@ -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']
|
||||
];
|
|
@ -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);
|
||||
?>
|
32
footer.php
|
@ -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();
|
||||
?>
|
101
functions.php
|
@ -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;
|
||||
}
|
||||
}
|
||||
?>
|
93
header.php
|
@ -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'];
|
||||
// search box
|
||||
if (isset($_POST['search'])) {
|
||||
$search = sanitize($_POST['search']);
|
||||
$_SESSION['search'] = $search;
|
||||
} else {
|
||||
if(isset($_SESSION['search'])) {
|
||||
} else {
|
||||
if (isset($_SESSION['search'])) {
|
||||
$search = $_SESSION['search'];
|
||||
} else {
|
||||
$search = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set global template vars
|
||||
$tp->set("config_version", $config_version);
|
||||
$tp->set("search", $search);
|
||||
$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();
|
||||
?>
|
47
image.php
|
@ -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);
|
||||
|
|
BIN
images/add.gif
Before Width: | Height: | Size: 141 B |
After Width: | Height: | Size: 739 B |
After Width: | Height: | Size: 748 B |
After Width: | Height: | Size: 388 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 574 B |
After Width: | Height: | Size: 230 B |
After Width: | Height: | Size: 475 B |
After Width: | Height: | Size: 85 B |
After Width: | Height: | Size: 696 B |
After Width: | Height: | Size: 841 B |
After Width: | Height: | Size: 792 B |
After Width: | Height: | Size: 849 B |
After Width: | Height: | Size: 884 B |
After Width: | Height: | Size: 556 B |
After Width: | Height: | Size: 631 B |
After Width: | Height: | Size: 633 B |
After Width: | Height: | Size: 731 B |
After Width: | Height: | Size: 587 B |
BIN
images/check.gif
Before Width: | Height: | Size: 138 B |
After Width: | Height: | Size: 413 B |
Before Width: | Height: | Size: 151 B |
BIN
images/del.gif
Before Width: | Height: | Size: 145 B |
After Width: | Height: | Size: 740 B |
After Width: | Height: | Size: 883 B |
BIN
images/edit.gif
Before Width: | Height: | Size: 197 B |
After Width: | Height: | Size: 807 B |
After Width: | Height: | Size: 666 B |
After Width: | Height: | Size: 701 B |
After Width: | Height: | Size: 736 B |
After Width: | Height: | Size: 778 B |
After Width: | Height: | Size: 703 B |
After Width: | Height: | Size: 70 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 615 B |
After Width: | Height: | Size: 801 B |
After Width: | Height: | Size: 199 B |
After Width: | Height: | Size: 744 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 577 B |
BIN
images/next.gif
Before Width: | Height: | Size: 131 B |
After Width: | Height: | Size: 500 B |
After Width: | Height: | Size: 635 B |
After Width: | Height: | Size: 641 B |
After Width: | Height: | Size: 591 B |
After Width: | Height: | Size: 200 B |
BIN
images/prev.gif
Before Width: | Height: | Size: 131 B |
After Width: | Height: | Size: 649 B |
After Width: | Height: | Size: 745 B |
BIN
images/save.gif
Before Width: | Height: | Size: 242 B |
After Width: | Height: | Size: 774 B |
Before Width: | Height: | Size: 211 B |
After Width: | Height: | Size: 812 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 702 B |
After Width: | Height: | Size: 566 B |
After Width: | Height: | Size: 663 B |
After Width: | Height: | Size: 660 B |
After Width: | Height: | Size: 744 B |
After Width: | Height: | Size: 683 B |
After Width: | Height: | Size: 723 B |
After Width: | Height: | Size: 665 B |
After Width: | Height: | Size: 822 B |
After Width: | Height: | Size: 770 B |
After Width: | Height: | Size: 802 B |
After Width: | Height: | Size: 741 B |
After Width: | Height: | Size: 746 B |
After Width: | Height: | Size: 767 B |
After Width: | Height: | Size: 833 B |
After Width: | Height: | Size: 663 B |