<?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 *****************************************************************************/ // global version string $config_version = 'v0.8'; // available languages $config_lang = array('de', 'en'); include("lib/functions.php"); //require("lib/db.class.php"); //$db = new Db($dblink); //require("lib/user.class.php"); // $user = new User(); require_once('smarty3/Smarty.class.php'); $smarty = new Smarty(); $smarty->template_dir = 'tpl'; $smarty->compile_dir = 'tpl_c'; $smarty->registerPlugin('function', 'treelist', 'print_tree'); $smarty->assign("suser_tooltips", $_SESSION['suser_tooltips'] ?? 'off'); // ========== DATABASE FUCTIONS =============================================== function db_get_options_asset() { global $dbh; $sql = "SELECT asset_id, asset_name FROM asset ORDER BY asset_name"; $sth = $dbh->query($sql); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) { $options[$rec[0]] = $rec[1]; } return $options; } function db_get_options_assetclass() { global $dbh; $sql = "SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name"; $sth = $dbh->query($sql); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) { $options[$rec[0]] = $rec[1]; } return $options; } function db_get_options_assetclassgroup() { global $dbh; $sql = "SELECT assetclassgroup_id, assetclassgroup_name FROM assetclassgroup ORDER BY assetclassgroup_name"; $sth = $dbh->query($sql); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) { $options[$rec[0]] = $rec[1]; } return $options; } function db_get_options_location() { global $dbh; $sql = "SELECT location_id, location_name FROM location ORDER BY location_name"; $sth = $dbh->query($sql); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) { $options[$rec[0]] = $rec[1]; } return $options; } function db_get_options_subnet() { global $dbh; $sql = "SELECT subnet_id, CONCAT_WS('/', subnet_address, subnet_mask) AS subnet_name FROM subnet ORDER BY INET_ATON(subnet_address)"; $sth = $dbh->query($sql); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) { $options[$rec[0]] = $rec[1]; } return $options; } function db_get_options_vlan() { global $dbh; $sql = "SELECT vlan_id, vlan_name FROM vlan ORDER BY vlan_name"; $sth = $dbh->query($sql); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) { $options[$rec[0]] = $rec[1]; } return $options; } ?>