Added some indices to database and more SQL simplification

master
Thomas Hooge 2 years ago
parent 6df7a3f6a8
commit 808ae831bf
  1. 33
      about.php
  2. 16
      assetclassgroupview.php
  3. 12
      assetdel.php
  4. 6
      assignnodetoasset.php
  5. 10
      index.php
  6. 15
      install/mysql.sql
  7. 3
      install/mysql_sample.sql

@ -1,43 +1,16 @@
<?php
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2007-2009 Wietse Warendorff
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.
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
SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
// start page
// includes
include("includes.php");
// start output
include("header.php");
// set language variables
$smarty->assign($lang);
// setup page
// set vars
$smarty->assign("config_version", $config_version);
// end page
// output
$smarty->display("about.tpl");
// end output
include("footer.php");
?>

@ -36,13 +36,13 @@
// setup assetclassgroup
// build query
$query = "SELECT
assetclassgroup.assetclassgroup_id AS assetclassgroup_id,
assetclassgroup.assetclassgroup_name AS assetclassgroup_name,
assetclassgroup.assetclassgroup_color AS assetclassgroup_color
assetclassgroup_id,
assetclassgroup_name,
assetclassgroup_color
FROM
assetclassgroup
WHERE
assetclassgroup.assetclassgroup_id=" . $assetclassgroup_id;
assetclassgroup_id=" . $assetclassgroup_id;
// run query
$assetclassgroup = $db->db_select($query);
@ -55,14 +55,14 @@
// setup assetclass
// build query
$query = "SELECT
assetclass.assetclass_id AS assetclass_id,
assetclass.assetclass_name AS assetclass_name
assetclass_id,
assetclass_name
FROM
assetclass
WHERE
assetclass.assetclassgroup_id=" . $assetclassgroup_id . "
assetclassgroup_id=" . $assetclassgroup_id . "
ORDER BY
assetclass.assetclass_name";
assetclass_name";
// run query
$assetclasses = $db->db_select($query);

@ -36,11 +36,11 @@
// setup asset
// build query
$query = "SELECT
asset.asset_name AS asset_name
asset_name
FROM
asset
WHERE
asset.asset_id=" . $asset_id;
asset_id=" . $asset_id;
// run query
$asset = $db->db_select($query);
@ -52,14 +52,14 @@
// setup node
// build query
$query = "SELECT
node.node_id AS node_id,
node.node_ip AS node_ip
node_id,
node_ip
FROM
node
WHERE
node.asset_id=" . $asset_id . "
asset_id=" . $asset_id . "
ORDER BY
INET_ATON(node.node_ip)";
INET_ATON(node_ip)";
// run query
$nodes = $db->db_select($query);

@ -42,12 +42,12 @@
$smarty->assign("asset_id", $asset_id);
// build query
$query = "SELECT
asset.asset_id AS asset_id,
asset.asset_name AS asset_name
asset_id,
asset_name
FROM
asset
ORDER BY
asset.asset_name";
asset_name";
// run query
$assets = $db->db_select($query);

@ -33,7 +33,7 @@
// setup asset
// build query
$query = "SELECT
COUNT(asset.asset_id) AS asset_counter
COUNT(asset_id) AS asset_counter
FROM
asset";
@ -46,7 +46,7 @@
// setup location
// build query
$query = "SELECT
COUNT(location.location_id) AS location_counter
COUNT(location_id) AS location_counter
FROM
location";
@ -59,7 +59,7 @@
// setup node
// build query
$query = "SELECT
COUNT(node.node_id) AS node_counter
COUNT(node_id) AS node_counter
FROM
node";
@ -72,7 +72,7 @@
// setup subnet
// build query
$query = "SELECT
COUNT(subnet.subnet_id) AS subnet_counter
COUNT(subnet_id) AS subnet_counter
FROM
subnet";
@ -85,7 +85,7 @@
// setup vlan
// build query
$query = "SELECT
COUNT(vlan.vlan_id) AS vlan_counter
COUNT(vlan_id) AS vlan_counter
FROM
vlan";

@ -4,21 +4,24 @@ CREATE TABLE asset (
asset_hostname varchar(100) DEFAULT NULL,
assetclass_id int(10) NOT NULL,
asset_info text DEFAULT NULL,
PRIMARY KEY (asset_id)
PRIMARY KEY (asset_id),
INDEX ix_asset_name (asset_name)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE assetclass (
assetclass_id int(10) NOT NULL AUTO_INCREMENT,
assetclassgroup_id int(10) NOT NULL,
assetclass_name varchar(100) NOT NULL,
PRIMARY KEY (assetclass_id)
PRIMARY KEY (assetclass_id),
INDEX ix_assetclass_name (assetclass_name)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE assetclassgroup (
assetclassgroup_id int(10) NOT NULL AUTO_INCREMENT,
assetclassgroup_name varchar(100) NOT NULL,
assetclassgroup_color varchar(6) NOT NULL DEFAULT '000000',
PRIMARY KEY (assetclassgroup_id)
PRIMARY KEY (assetclassgroup_id),
INDEX ix_assetclassgroup_name (assetclassgroup_name)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE location (
@ -28,7 +31,8 @@ CREATE TABLE location (
location_info text DEFAULT NULL,
location_sort int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (location_id),
KEY location_sort (location_sort)
INDEX ix_location_sort (location_sort),
INDEX ix_location_name (location_name)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE nat (
@ -101,7 +105,8 @@ CREATE TABLE user (
user_menu_vlans varchar(2) NOT NULL DEFAULT 'on',
user_menu_zones varchar(2) NOT NULL DEFAULT 'on',
user_tooltips varchar(2) NOT NULL DEFAULT 'on',
PRIMARY KEY (user_id)
PRIMARY KEY (user_id),
UNIQUE INDEX ix_username (user_name)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO user (user_name, user_pass, user_displayname) VALUES

@ -49,9 +49,6 @@ INSERT INTO subnetlocation (subnet_id, location_id) VALUES
INSERT INTO subnetvlan (subnet_id, vlan_id) VALUES
(1, 1);
INSERT INTO user (user_name, user_pass, user_displayname, user_imagesize, user_imagecount, user_mac, user_dateformat) VALUES
('admin', '21232f297a57a5a743894a0e4a801fc3', 'administrator', 6, 64, 'xxxxxxxxxxxx', 'd M Y H:i');
INSERT INTO vlan (vlan_number, vlan_name) VALUES
(1, 'DEFAULT_VLAN');