Started integrating external systems
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
function toggle(source) {
|
||||
checkboxes = document.getElementsByName('rule');
|
||||
for(var i=0, n=checkboxes.length; i<n; i++) {
|
||||
checkboxes[i].checked = source.checked;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
// Computerdatenbank interface
|
||||
// $config_ext['computerdb']
|
||||
|
||||
class Cdb {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
// Loginventory interface
|
||||
// $config_ext['loginventory']
|
||||
|
||||
class Loginventory {
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// Topdesk interface
|
||||
// $config_ext['topdesk']
|
||||
|
||||
class Topdesk {
|
||||
}
|
||||
|
||||
/*
|
||||
Topdesk-Infos / Interessante Tabellen
|
||||
object
|
||||
type
|
||||
asset_typ_id
|
||||
asset_summary
|
||||
asset_status
|
||||
ref_name
|
||||
asset_type
|
||||
unid 16 Byte GUID
|
||||
name
|
||||
am_entity
|
||||
object.asset_id = am_entity.unid
|
||||
|
||||
am_field
|
||||
id
|
||||
displayname
|
||||
properties (JSON)
|
||||
|
||||
am_value
|
||||
entityid
|
||||
fieldname
|
||||
textvalue
|
||||
numvalue
|
||||
valuetype
|
||||
|
||||
am_relation
|
||||
sourceId
|
||||
targetId
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// Zabbix interface
|
||||
// $config_ext['zabbix']
|
||||
|
||||
class Zabbix {
|
||||
}
|
||||
|
||||
// $smarty->assign('zabbix', print_r($config_ext['zabbix']['host'],true));
|
||||
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
|
||||
$zbxconn = false;
|
||||
try {
|
||||
$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);
|
||||
$zbxconn = true;
|
||||
} catch (Exception $e) {
|
||||
$refid = "not_connected:" . $e->getMessage();
|
||||
}
|
||||
|
||||
if ($zbxconn) {
|
||||
$sql = "SELECT host FROM hosts WHERE hostid=?";
|
||||
$sth = $zbx->prepare($sql);
|
||||
$sth->execute([$refid]);
|
||||
$zbx_hostname = $sth->fetchColumn();
|
||||
$smarty->assign('zbx_hostname', $zbx_hostname);
|
||||
$zbx = NULL; // close
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// External data source
|
||||
|
||||
class ExtSys {
|
||||
|
||||
public $name;
|
||||
protected $conn;
|
||||
|
||||
function __construct($xtype, $dbconfig) {
|
||||
if (! $config['enabled']) {
|
||||
throw new Exception('Not allowed to create connection to ' . $xtype);
|
||||
}
|
||||
switch ($config['xtype']) {
|
||||
'cdb':
|
||||
$this->name = 'Computerdatenbank';
|
||||
cdb_init($dbconfig);
|
||||
break;
|
||||
'logi':
|
||||
$this->name = 'Loginventory';
|
||||
logi_init($dbconfig);
|
||||
break;
|
||||
'topdesk':
|
||||
$this->name = 'Topdesk';
|
||||
tdesk_init($dbconfig);
|
||||
break;
|
||||
'zabbix':
|
||||
$this->name = 'Zabbix';
|
||||
zbx_init($dbconfig);
|
||||
break;
|
||||
default:
|
||||
throw new Exception('Invalid xtype');
|
||||
}
|
||||
}
|
||||
|
||||
private function mariadb_connect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private function mssql_connect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private function cdb_init() {
|
||||
mariadb_connect();
|
||||
}
|
||||
|
||||
private function logi_init() {
|
||||
mssql_connect();
|
||||
}
|
||||
|
||||
private function tdesk_init() {
|
||||
mssql_connect();
|
||||
}
|
||||
|
||||
private function zbx_init() {
|
||||
mariadb_connect();
|
||||
}
|
||||
|
||||
}
|
||||
+3
-10
@@ -2,7 +2,7 @@
|
||||
/*****************************************************************************
|
||||
IP Reg, a PHP/MySQL IPAM tool
|
||||
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
|
||||
Copyright (C) 2011-2023 Thomas Hooge
|
||||
Copyright (C) 2011-2026 Thomas Hooge
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*****************************************************************************/
|
||||
@@ -11,22 +11,15 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
function sanitize($input) {
|
||||
global $dblink;
|
||||
|
||||
// trim whitespaces
|
||||
$input = @trim($input);
|
||||
|
||||
// magic quotes enabled?
|
||||
if(get_magic_quotes_gpc()) {
|
||||
// strip slashes
|
||||
$input = stripslashes($input);
|
||||
}
|
||||
$input = stripslashes($input);
|
||||
|
||||
// convert to utf-8
|
||||
iconv("UTF-8", "UTF-8", $input);
|
||||
|
||||
// convert special chars
|
||||
$input = htmlentities($input,ENT_QUOTES,'UTF-8');
|
||||
$input = htmlentities($input, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
// and return
|
||||
return $input;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user