Added some indices to database and more SQL simplification

master
Thomas Hooge 2 years ago
parent 6df7a3f6a8
commit 808ae831bf
  1. 47
      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 <?php
/***************************************************************************** /*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool 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 SPDX-License-Identifier: GPL-3.0-or-later
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, include("includes.php");
but WITHOUT ANY WARRANTY; without even the implied warranty of include("header.php");
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 $smarty->display("about.tpl");
along with this program. If not, see <http://www.gnu.org/licenses/>.
For more information, visit http://sourceforge.net/projects/ipreg, include("footer.php");
or contact me at wietsew@users.sourceforge.net
*****************************************************************************/
// 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 // setup assetclassgroup
// build query // build query
$query = "SELECT $query = "SELECT
assetclassgroup.assetclassgroup_id AS assetclassgroup_id, assetclassgroup_id,
assetclassgroup.assetclassgroup_name AS assetclassgroup_name, assetclassgroup_name,
assetclassgroup.assetclassgroup_color AS assetclassgroup_color assetclassgroup_color
FROM FROM
assetclassgroup assetclassgroup
WHERE WHERE
assetclassgroup.assetclassgroup_id=" . $assetclassgroup_id; assetclassgroup_id=" . $assetclassgroup_id;
// run query // run query
$assetclassgroup = $db->db_select($query); $assetclassgroup = $db->db_select($query);
@ -55,14 +55,14 @@
// setup assetclass // setup assetclass
// build query // build query
$query = "SELECT $query = "SELECT
assetclass.assetclass_id AS assetclass_id, assetclass_id,
assetclass.assetclass_name AS assetclass_name assetclass_name
FROM FROM
assetclass assetclass
WHERE WHERE
assetclass.assetclassgroup_id=" . $assetclassgroup_id . " assetclassgroup_id=" . $assetclassgroup_id . "
ORDER BY ORDER BY
assetclass.assetclass_name"; assetclass_name";
// run query // run query
$assetclasses = $db->db_select($query); $assetclasses = $db->db_select($query);

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

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

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

@ -4,21 +4,24 @@ CREATE TABLE asset (
asset_hostname varchar(100) DEFAULT NULL, asset_hostname varchar(100) DEFAULT NULL,
assetclass_id int(10) NOT NULL, assetclass_id int(10) NOT NULL,
asset_info text DEFAULT 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; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE assetclass ( CREATE TABLE assetclass (
assetclass_id int(10) NOT NULL AUTO_INCREMENT, assetclass_id int(10) NOT NULL AUTO_INCREMENT,
assetclassgroup_id int(10) NOT NULL, assetclassgroup_id int(10) NOT NULL,
assetclass_name varchar(100) 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; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE assetclassgroup ( CREATE TABLE assetclassgroup (
assetclassgroup_id int(10) NOT NULL AUTO_INCREMENT, assetclassgroup_id int(10) NOT NULL AUTO_INCREMENT,
assetclassgroup_name varchar(100) NOT NULL, assetclassgroup_name varchar(100) NOT NULL,
assetclassgroup_color varchar(6) NOT NULL DEFAULT '000000', 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; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE location ( CREATE TABLE location (
@ -28,7 +31,8 @@ CREATE TABLE location (
location_info text DEFAULT NULL, location_info text DEFAULT NULL,
location_sort int(11) NOT NULL DEFAULT 0, location_sort int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (location_id), 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; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE nat ( CREATE TABLE nat (
@ -101,7 +105,8 @@ CREATE TABLE user (
user_menu_vlans varchar(2) NOT NULL DEFAULT 'on', user_menu_vlans varchar(2) NOT NULL DEFAULT 'on',
user_menu_zones varchar(2) NOT NULL DEFAULT 'on', user_menu_zones varchar(2) NOT NULL DEFAULT 'on',
user_tooltips 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; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO user (user_name, user_pass, user_displayname) VALUES 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 INSERT INTO subnetvlan (subnet_id, vlan_id) VALUES
(1, 1); (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 INSERT INTO vlan (vlan_number, vlan_name) VALUES
(1, 'DEFAULT_VLAN'); (1, 'DEFAULT_VLAN');