Dmitriev Roman 3 mēneši atpakaļ
vecāks
revīzija
12e0ee0e89
96 mainītis faili ar 1551 papildinājumiem un 1250 dzēšanām
  1. 78 78
      docs/databases/mysql/en/create_db.sql
  2. 121 121
      docs/databases/mysql/en/data.sql
  3. 78 78
      docs/databases/mysql/ru/create_db.sql
  4. 121 121
      docs/databases/mysql/ru/data.sql
  5. 107 108
      docs/databases/postgres/en/create_db.sql
  6. 24 24
      docs/databases/postgres/en/data.sql
  7. 76 76
      docs/databases/postgres/ru/create_db.sql
  8. 26 26
      docs/databases/postgres/ru/data.sql
  9. 1 1
      docs/dhcpd/print-dhcpd.pl
  10. 1 1
      docs/dhcpd/print-dhcpd2.pl
  11. 10 10
      docs/iptables/parse_ulog.pl
  12. 15 15
      docs/iptables/sync_iptables.pl
  13. 4 4
      html/admin/customers/control-subnets-usage.php
  14. 3 3
      html/admin/customers/control.php
  15. 2 2
      html/admin/customers/editcustom.php
  16. 5 5
      html/admin/customers/index.php
  17. 1 1
      html/admin/devices/edit_gw_instances.php
  18. 1 1
      html/admin/devices/edit_gw_subnets.php
  19. 1 1
      html/admin/devices/edit_l3int.php
  20. 2 2
      html/admin/devices/editdevice.php
  21. 1 1
      html/admin/devices/editport.php
  22. 2 2
      html/admin/devices/index-passive.php
  23. 1 1
      html/admin/devices/mactable.php
  24. 4 4
      html/admin/devices/portmactable.php
  25. 1 1
      html/admin/devices/snmpwalk.php
  26. 2 2
      html/admin/devices/switchport-conn.php
  27. 1 1
      html/admin/devices/switchport.php
  28. 1 1
      html/admin/devices/switchstatus.php
  29. 2 2
      html/admin/filters/editfilter.php
  30. 7 7
      html/admin/filters/editgroup.php
  31. 5 5
      html/admin/filters/groups.php
  32. 4 4
      html/admin/filters/index.php
  33. 3 3
      html/admin/filters/instances.php
  34. 2 2
      html/admin/groups/index.php
  35. 1 1
      html/admin/iplist/auto_rules.php
  36. 7 7
      html/admin/iplist/deleted.php
  37. 4 4
      html/admin/iplist/doubles.php
  38. 25 25
      html/admin/iplist/index.php
  39. 10 10
      html/admin/iplist/nagios.php
  40. 2 2
      html/admin/logs/detaillog.php
  41. 2 2
      html/admin/logs/ip.php
  42. 2 2
      html/admin/logs/unknown.php
  43. 3 3
      html/admin/queues/index.php
  44. 3 3
      html/admin/reports/authday.php
  45. 9 9
      html/admin/reports/index-full.php
  46. 9 9
      html/admin/reports/index.php
  47. 12 12
      html/admin/reports/userday.php
  48. 3 3
      html/admin/reports/userdaydetail.php
  49. 3 3
      html/admin/reports/userdaydetaillog.php
  50. 1 1
      html/admin/reports/wan.php
  51. 9 9
      html/admin/users/edit_alias.php
  52. 1 1
      html/admin/users/edit_rules.php
  53. 22 22
      html/admin/users/editauth.php
  54. 21 21
      html/admin/users/edituser.php
  55. 5 5
      html/admin/users/index.php
  56. 8 8
      html/api.php
  57. 2 2
      html/inc/auth.utils.php
  58. 66 66
      html/inc/common.php
  59. 27 27
      html/inc/sql.php
  60. 7 7
      html/public/blocked.php
  61. 8 8
      html/utils/auth_apply.php
  62. 3 3
      html/utils/auth_export.php
  63. 6 6
      html/utils/user_apply.php
  64. 1 1
      scripts/check_dhcp_pool.pl
  65. 10 10
      scripts/dhcp-log.pl
  66. 9 9
      scripts/eye-statd.pl
  67. 65 65
      scripts/eyelib/common.pm
  68. 15 16
      scripts/eyelib/database.pm
  69. 15 15
      scripts/fetch_new_arp.pl
  70. 40 40
      scripts/garbage.pl
  71. 4 4
      scripts/gen_nagios_config.pl
  72. 7 7
      scripts/hmonitor.pl
  73. 3 3
      scripts/print-dnsmasq.pl
  74. 1 1
      scripts/restart_port_snmp.pl
  75. 11 11
      scripts/stat-sync.pl
  76. 19 19
      scripts/sync_mikrotik.pl
  77. 1 1
      scripts/sync_mikrotik_poe_monitor.pl
  78. 2 2
      scripts/updates/2-8-0/after_sql.pl
  79. 2 2
      scripts/updates/2-9-0/config_options.sql
  80. 78 0
      scripts/updates/3-0-1/migration.msql
  81. 70 0
      scripts/updates/3-0-1/migration.psql
  82. 2 0
      scripts/updates/db-patch-mysql-utf8.pl
  83. 14 2
      scripts/updates/upgrade.pl
  84. 3 3
      scripts/utils/bind/print-dns-zones.pl
  85. 9 9
      scripts/utils/import/import_auth.pl
  86. 155 14
      scripts/utils/mac-oids/manuf.csv
  87. 1 1
      scripts/utils/oxidized/print_devices_oxi.pl
  88. 8 8
      scripts/utils/parse_flow.pl
  89. 1 1
      scripts/utils/print-ou-ip.pl
  90. 1 1
      scripts/utils/radius/print_huntgroups.pl
  91. 3 3
      scripts/utils/reaply_rules.pl
  92. 2 2
      scripts/utils/scan_ipcam.pl
  93. 2 2
      scripts/utils/set_port_descr.pl
  94. 1 1
      scripts/utils/trap_restart.pl
  95. 1 1
      scripts/utils/win32/print-dhcpd-netsh.pl
  96. 1 1
      scripts/utils/win32/sync-dhcpd-netsh.pl

+ 78 - 78
docs/databases/mysql/en/create_db.sql

@@ -12,8 +12,8 @@ USE `stat`;
 CREATE TABLE `acl` (
 CREATE TABLE `acl` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `name` varchar(30) NOT NULL,
   `name` varchar(30) NOT NULL,
-  `description.english` varchar(250) NOT NULL,
-  `description.russian` varchar(250) NOT NULL
+  description_english varchar(250) NOT NULL,
+  description_russian varchar(250) NOT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE `ad_comp_cache` (
 CREATE TABLE `ad_comp_cache` (
@@ -46,8 +46,8 @@ CREATE TABLE `config` (
 CREATE TABLE `config_options` (
 CREATE TABLE `config_options` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `option_name` varchar(50) NOT NULL,
   `option_name` varchar(50) NOT NULL,
-  `description.russian` text DEFAULT NULL,
-  `description.english` text DEFAULT NULL,
+  description_russian text DEFAULT NULL,
+  description_english text DEFAULT NULL,
   `draft` tinyint(1) NOT NULL DEFAULT 0,
   `draft` tinyint(1) NOT NULL DEFAULT 0,
   `uniq` tinyint(1) NOT NULL DEFAULT 1,
   `uniq` tinyint(1) NOT NULL DEFAULT 1,
   `type` varchar(100) NOT NULL,
   `type` varchar(100) NOT NULL,
@@ -64,7 +64,7 @@ CREATE TABLE `connections` (
   `last_found` datetime NOT NULL DEFAULT current_timestamp()
   `last_found` datetime NOT NULL DEFAULT current_timestamp()
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Customers` (
+CREATE TABLE `customers` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `Login` varchar(20) DEFAULT 'NULL',
   `Login` varchar(20) DEFAULT 'NULL',
   `comment` varchar(100) DEFAULT NULL,
   `comment` varchar(100) DEFAULT NULL,
@@ -160,8 +160,8 @@ CREATE TABLE `device_ports` (
 
 
 CREATE TABLE `device_types` (
 CREATE TABLE `device_types` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
-  `name.russian` varchar(50) DEFAULT NULL,
-  `name.english` varchar(50) DEFAULT NULL
+  name_russian varchar(50) DEFAULT NULL,
+  name_english varchar(50) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE `dhcp_log` (
 CREATE TABLE `dhcp_log` (
@@ -170,12 +170,12 @@ CREATE TABLE `dhcp_log` (
   `ip_int` bigint(20) UNSIGNED NOT NULL,
   `ip_int` bigint(20) UNSIGNED NOT NULL,
   `ip` varchar(15) NOT NULL,
   `ip` varchar(15) NOT NULL,
   `action` varchar(10) NOT NULL,
   `action` varchar(10) NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
+  `ts` timestamp NOT NULL DEFAULT current_timestamp(),
   `auth_id` bigint(20) UNSIGNED NOT NULL,
   `auth_id` bigint(20) UNSIGNED NOT NULL,
   `dhcp_hostname` varchar(250) DEFAULT NULL,
   `dhcp_hostname` varchar(250) DEFAULT NULL,
-  `circuit-id` varchar(255) DEFAULT NULL,
-  `remote-id` varchar(255) DEFAULT NULL,
-  `client-id` varchar(250) DEFAULT NULL
+  circuit_id varchar(255) DEFAULT NULL,
+  remote_id varchar(255) DEFAULT NULL,
+  client_id varchar(250) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
 
 
 CREATE TABLE `dhcp_queue` (
 CREATE TABLE `dhcp_queue` (
@@ -183,7 +183,7 @@ CREATE TABLE `dhcp_queue` (
   `mac` varchar(17) NOT NULL,
   `mac` varchar(17) NOT NULL,
   `ip` varchar(15) NOT NULL,
   `ip` varchar(15) NOT NULL,
   `action` varchar(10) NOT NULL,
   `action` varchar(10) NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
+  `ts` timestamp NOT NULL DEFAULT current_timestamp(),
   `dhcp_hostname` varchar(250) DEFAULT NULL
   `dhcp_hostname` varchar(250) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
 
 
@@ -191,7 +191,7 @@ CREATE TABLE `dns_cache` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
   `dns` varchar(250) DEFAULT NULL,
   `dns` varchar(250) DEFAULT NULL,
   `ip` bigint(20) UNSIGNED DEFAULT NULL,
   `ip` bigint(20) UNSIGNED DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
+  `ts` timestamp NOT NULL DEFAULT current_timestamp()
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE `dns_queue` (
 CREATE TABLE `dns_queue` (
@@ -209,7 +209,7 @@ CREATE TABLE `filter_instances` (
   `comment` varchar(200) DEFAULT NULL
   `comment` varchar(200) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Filter_list` (
+CREATE TABLE `filter_list` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `name` varchar(50) DEFAULT NULL,
   `name` varchar(50) DEFAULT NULL,
   `comment` varchar(250) DEFAULT NULL,
   `comment` varchar(250) DEFAULT NULL,
@@ -226,7 +226,7 @@ CREATE TABLE `gateway_subnets` (
   `subnet_id` int(11) DEFAULT NULL
   `subnet_id` int(11) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Group_filters` (
+CREATE TABLE `group_filters` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `group_id` int(11) NOT NULL DEFAULT 0,
   `group_id` int(11) NOT NULL DEFAULT 0,
   `filter_id` int(11) NOT NULL DEFAULT 0,
   `filter_id` int(11) NOT NULL DEFAULT 0,
@@ -234,7 +234,7 @@ CREATE TABLE `Group_filters` (
   `action` tinyint(1) NOT NULL DEFAULT 0
   `action` tinyint(1) NOT NULL DEFAULT 0
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Group_list` (
+CREATE TABLE `group_list` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `instance_id` int(11) NOT NULL DEFAULT 1,
   `instance_id` int(11) NOT NULL DEFAULT 1,
   `group_name` varchar(50) DEFAULT NULL,
   `group_name` varchar(50) DEFAULT NULL,
@@ -244,7 +244,7 @@ CREATE TABLE `Group_list` (
 CREATE TABLE `mac_history` (
 CREATE TABLE `mac_history` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
   `mac` varchar(12) DEFAULT NULL,
   `mac` varchar(12) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
+  `ts` timestamp NOT NULL DEFAULT current_timestamp(),
   `device_id` bigint(20) UNSIGNED DEFAULT NULL,
   `device_id` bigint(20) UNSIGNED DEFAULT NULL,
   `port_id` bigint(20) UNSIGNED DEFAULT NULL,
   `port_id` bigint(20) UNSIGNED DEFAULT NULL,
   `ip` varchar(16) NOT NULL DEFAULT '',
   `ip` varchar(16) NOT NULL DEFAULT '',
@@ -277,7 +277,7 @@ CREATE TABLE `OU` (
   `parent_id` int(11) DEFAULT NULL
   `parent_id` int(11) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Queue_list` (
+CREATE TABLE `queue_list` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `queue_name` varchar(20) NOT NULL,
   `queue_name` varchar(20) NOT NULL,
   `Download` int(11) NOT NULL DEFAULT 0,
   `Download` int(11) NOT NULL DEFAULT 0,
@@ -320,11 +320,11 @@ CREATE TABLE `subnets` (
   `comment` varchar(250) DEFAULT NULL
   `comment` varchar(250) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Traffic_detail` (
+CREATE TABLE `traffic_detail` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
   `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
   `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
   `router_id` int(11) NOT NULL DEFAULT 0,
   `router_id` int(11) NOT NULL DEFAULT 0,
-  `timestamp` timestamp NULL DEFAULT NULL,
+  `ts` timestamp NULL DEFAULT NULL,
   `proto` tinyint(3) UNSIGNED DEFAULT NULL,
   `proto` tinyint(3) UNSIGNED DEFAULT NULL,
   `src_ip` int(10) UNSIGNED NOT NULL,
   `src_ip` int(10) UNSIGNED NOT NULL,
   `dst_ip` int(10) UNSIGNED NOT NULL,
   `dst_ip` int(10) UNSIGNED NOT NULL,
@@ -334,15 +334,15 @@ CREATE TABLE `Traffic_detail` (
   `pkt` int(10) UNSIGNED NOT NULL DEFAULT 0
   `pkt` int(10) UNSIGNED NOT NULL DEFAULT 0
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Unknown_mac` (
+CREATE TABLE `unknown_mac` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
   `mac` varchar(12) DEFAULT NULL,
   `mac` varchar(12) DEFAULT NULL,
   `port_id` bigint(20) UNSIGNED DEFAULT NULL,
   `port_id` bigint(20) UNSIGNED DEFAULT NULL,
   `device_id` int(11) DEFAULT NULL,
   `device_id` int(11) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
+  `ts` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `User_auth` (
+CREATE TABLE `user_auth` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `ou_id` int(11) DEFAULT NULL,
   `ou_id` int(11) DEFAULT NULL,
@@ -373,8 +373,8 @@ CREATE TABLE `User_auth` (
   `month_quota` int(11) NOT NULL DEFAULT 0,
   `month_quota` int(11) NOT NULL DEFAULT 0,
   `device_model_id` int(11) DEFAULT 87,
   `device_model_id` int(11) DEFAULT 87,
   `firmware` varchar(100) DEFAULT NULL,
   `firmware` varchar(100) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `client-id` varchar(250) DEFAULT NULL,
+  `ts` timestamp NOT NULL DEFAULT current_timestamp(),
+  client_id varchar(250) DEFAULT NULL,
   `nagios` tinyint(1) NOT NULL DEFAULT 0,
   `nagios` tinyint(1) NOT NULL DEFAULT 0,
   `nagios_status` varchar(10) NOT NULL DEFAULT '',
   `nagios_status` varchar(10) NOT NULL DEFAULT '',
   `nagios_handler` varchar(50) NOT NULL DEFAULT '',
   `nagios_handler` varchar(50) NOT NULL DEFAULT '',
@@ -385,17 +385,17 @@ CREATE TABLE `User_auth` (
   `created_by` varchar(10) DEFAULT NULL
   `created_by` varchar(10) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `User_auth_alias` (
+CREATE TABLE `user_auth_alias` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `auth_id` int(11) NOT NULL,
   `auth_id` int(11) NOT NULL,
   `alias` varchar(100) DEFAULT NULL,
   `alias` varchar(100) DEFAULT NULL,
   `description` varchar(100) DEFAULT NULL,
   `description` varchar(100) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
+  `ts` timestamp NOT NULL DEFAULT current_timestamp()
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `User_list` (
+CREATE TABLE `user_list` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
+  `ts` timestamp NOT NULL DEFAULT current_timestamp(),
   `login` varchar(255) DEFAULT NULL,
   `login` varchar(255) DEFAULT NULL,
   `fio` varchar(255) DEFAULT NULL,
   `fio` varchar(255) DEFAULT NULL,
   `enabled` tinyint(1) NOT NULL DEFAULT 1,
   `enabled` tinyint(1) NOT NULL DEFAULT 1,
@@ -421,20 +421,20 @@ CREATE TABLE `user_sessions` (
   `is_active` tinyint(1) DEFAULT 1
   `is_active` tinyint(1) DEFAULT 1
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `User_stats` (
+CREATE TABLE `user_stats` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
   `router_id` bigint(20) UNSIGNED DEFAULT 0,
   `router_id` bigint(20) UNSIGNED DEFAULT 0,
   `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
+  `ts` datetime NOT NULL DEFAULT current_timestamp(),
   `byte_in` bigint(20) NOT NULL DEFAULT 0,
   `byte_in` bigint(20) NOT NULL DEFAULT 0,
   `byte_out` bigint(20) NOT NULL DEFAULT 0
   `byte_out` bigint(20) NOT NULL DEFAULT 0
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `User_stats_full` (
+CREATE TABLE `user_stats_full` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
   `router_id` bigint(20) UNSIGNED DEFAULT 0,
   `router_id` bigint(20) UNSIGNED DEFAULT 0,
   `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
+  `ts` datetime NOT NULL DEFAULT current_timestamp(),
   `byte_in` bigint(20) NOT NULL DEFAULT 0,
   `byte_in` bigint(20) NOT NULL DEFAULT 0,
   `byte_out` bigint(20) NOT NULL DEFAULT 0,
   `byte_out` bigint(20) NOT NULL DEFAULT 0,
   `pkt_in` int(11) DEFAULT NULL,
   `pkt_in` int(11) DEFAULT NULL,
@@ -460,20 +460,20 @@ CREATE TABLE `version` (
   `version` varchar(10) NOT NULL DEFAULT '2.4.14'
   `version` varchar(10) NOT NULL DEFAULT '2.4.14'
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Wan_stats` (
+CREATE TABLE `wan_stats` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
-  `time` datetime NOT NULL DEFAULT current_timestamp(),
+  `ts` datetime NOT NULL DEFAULT current_timestamp(),
   `router_id` int(11) DEFAULT NULL,
   `router_id` int(11) DEFAULT NULL,
   `interface_id` int(11) DEFAULT NULL,
   `interface_id` int(11) DEFAULT NULL,
-  `in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `out` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
+  `bytes_in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
+  `bytes_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `forward_in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `forward_in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `forward_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0
   `forward_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE `worklog` (
 CREATE TABLE `worklog` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
+  `ts` timestamp NOT NULL DEFAULT current_timestamp(),
   `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `customer` varchar(50) NOT NULL DEFAULT 'system',
   `customer` varchar(50) NOT NULL DEFAULT 'system',
   `ip` varchar(18) NOT NULL DEFAULT '127.0.0.1',
   `ip` varchar(18) NOT NULL DEFAULT '127.0.0.1',
@@ -509,7 +509,7 @@ ALTER TABLE `connections`
   ADD KEY `auth_id` (`auth_id`),
   ADD KEY `auth_id` (`auth_id`),
   ADD KEY `device_id` (`device_id`,`port_id`);
   ADD KEY `device_id` (`device_id`,`port_id`);
 
 
-ALTER TABLE `Customers`
+ALTER TABLE `customers`
   ADD PRIMARY KEY (`id`);
   ADD PRIMARY KEY (`id`);
 
 
 ALTER TABLE `devices`
 ALTER TABLE `devices`
@@ -537,16 +537,16 @@ ALTER TABLE `device_types`
 
 
 ALTER TABLE `dhcp_log`
 ALTER TABLE `dhcp_log`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`action`);
+  ADD KEY `ts` (`ts`,`action`);
 
 
 ALTER TABLE `dhcp_queue`
 ALTER TABLE `dhcp_queue`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`action`);
+  ADD KEY `ts` (`ts`,`action`);
 
 
 ALTER TABLE `dns_cache`
 ALTER TABLE `dns_cache`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD KEY `dns` (`dns`,`ip`),
   ADD KEY `dns` (`dns`,`ip`),
-  ADD KEY `timestamp` (`timestamp`);
+  ADD KEY `ts` (`ts`);
 
 
 ALTER TABLE `dns_queue`
 ALTER TABLE `dns_queue`
   ADD PRIMARY KEY (`id`);
   ADD PRIMARY KEY (`id`);
@@ -555,25 +555,25 @@ ALTER TABLE `filter_instances`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD UNIQUE KEY `name` (`name`);
   ADD UNIQUE KEY `name` (`name`);
 
 
-ALTER TABLE `Filter_list`
+ALTER TABLE `filter_list`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD KEY `Name` (`name`);
   ADD KEY `Name` (`name`);
 
 
 ALTER TABLE `gateway_subnets`
 ALTER TABLE `gateway_subnets`
   ADD PRIMARY KEY (`id`);
   ADD PRIMARY KEY (`id`);
 
 
-ALTER TABLE `Group_filters`
+ALTER TABLE `group_filters`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD KEY `GroupId` (`group_id`,`filter_id`);
   ADD KEY `GroupId` (`group_id`,`filter_id`);
 
 
-ALTER TABLE `Group_list`
+ALTER TABLE `group_list`
   ADD PRIMARY KEY (`id`);
   ADD PRIMARY KEY (`id`);
 
 
 ALTER TABLE `mac_history`
 ALTER TABLE `mac_history`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `mac` (`mac`,`timestamp`),
-  ADD KEY `ip` (`ip`,`timestamp`),
-  ADD KEY `timestamp` (`timestamp`) USING BTREE,
+  ADD KEY `mac` (`mac`,`ts`),
+  ADD KEY `ip` (`ip`,`ts`),
+  ADD KEY `ts` (`ts`) USING BTREE,
   ADD KEY `mac_2` (`mac`),
   ADD KEY `mac_2` (`mac`),
   ADD KEY `ip_2` (`ip`);
   ADD KEY `ip_2` (`ip`);
 
 
@@ -586,7 +586,7 @@ ALTER TABLE `OU`
 ALTER TABLE `OU` ADD FULLTEXT KEY `ou_name` (`ou_name`);
 ALTER TABLE `OU` ADD FULLTEXT KEY `ou_name` (`ou_name`);
 ALTER TABLE `OU` ADD FULLTEXT KEY `ou_name_2` (`ou_name`);
 ALTER TABLE `OU` ADD FULLTEXT KEY `ou_name_2` (`ou_name`);
 
 
-ALTER TABLE `Queue_list`
+ALTER TABLE `queue_list`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD UNIQUE KEY `id` (`id`);
   ADD UNIQUE KEY `id` (`id`);
 
 
@@ -603,26 +603,26 @@ ALTER TABLE `subnets`
   ADD KEY `ip_int_start` (`ip_int_start`,`ip_int_stop`),
   ADD KEY `ip_int_start` (`ip_int_start`,`ip_int_stop`),
   ADD KEY `dhcp` (`dhcp`,`office`,`hotspot`,`static`);
   ADD KEY `dhcp` (`dhcp`,`office`,`hotspot`,`static`);
 
 
-ALTER TABLE `Traffic_detail`
+ALTER TABLE `traffic_detail`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `src` (`auth_id`,`timestamp`,`router_id`,`src_ip`) USING BTREE,
-  ADD KEY `dst` (`auth_id`,`timestamp`,`router_id`,`dst_ip`) USING BTREE;
+  ADD KEY `src` (`auth_id`,`ts`,`router_id`,`src_ip`) USING BTREE,
+  ADD KEY `dst` (`auth_id`,`ts`,`router_id`,`dst_ip`) USING BTREE;
 
 
-ALTER TABLE `Unknown_mac`
+ALTER TABLE `unknown_mac`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`device_id`,`port_id`,`mac`);
+  ADD KEY `ts` (`ts`,`device_id`,`port_id`,`mac`);
 
 
-ALTER TABLE `User_auth`
+ALTER TABLE `user_auth`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD KEY `auth_index` (`id`,`user_id`,`ip_int`,`mac`,`ip`,`deleted`) USING BTREE,
   ADD KEY `auth_index` (`id`,`user_id`,`ip_int`,`mac`,`ip`,`deleted`) USING BTREE,
   ADD KEY `deleted` (`deleted`),
   ADD KEY `deleted` (`deleted`),
   ADD KEY `ou_id` (`ou_id`);
   ADD KEY `ou_id` (`ou_id`);
 
 
-ALTER TABLE `User_auth_alias`
+ALTER TABLE `user_auth_alias`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD KEY `auth_id` (`auth_id`);
   ADD KEY `auth_id` (`auth_id`);
 
 
-ALTER TABLE `User_list`
+ALTER TABLE `user_list`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD KEY `users` (`id`,`ou_id`,`enabled`,`blocked`,`deleted`);
   ADD KEY `users` (`id`,`ou_id`,`enabled`,`blocked`,`deleted`);
 
 
@@ -632,13 +632,13 @@ ALTER TABLE `user_sessions`
   ADD KEY `user_id` (`user_id`),
   ADD KEY `user_id` (`user_id`),
   ADD KEY `is_active` (`is_active`);
   ADD KEY `is_active` (`is_active`);
 
 
-ALTER TABLE `User_stats`
+ALTER TABLE `user_stats`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`auth_id`,`router_id`);
+  ADD KEY `ts` (`ts`,`auth_id`,`router_id`);
 
 
-ALTER TABLE `User_stats_full`
+ALTER TABLE `user_stats_full`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`auth_id`,`router_id`);
+  ADD KEY `ts` (`ts`,`auth_id`,`router_id`);
 
 
 ALTER TABLE `variables`
 ALTER TABLE `variables`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
@@ -651,16 +651,16 @@ ALTER TABLE `vendors`
 ALTER TABLE `version`
 ALTER TABLE `version`
   ADD UNIQUE KEY `id` (`id`);
   ADD UNIQUE KEY `id` (`id`);
 
 
-ALTER TABLE `Wan_stats`
+ALTER TABLE `wan_stats`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD UNIQUE KEY `main` (`time`,`router_id`,`interface_id`),
   ADD UNIQUE KEY `main` (`time`,`router_id`,`interface_id`),
   ADD KEY `times` (`time`);
   ADD KEY `times` (`time`);
 
 
 ALTER TABLE `worklog`
 ALTER TABLE `worklog`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `idx_customer` (`customer`,`level`,`timestamp`),
-  ADD KEY `idx_timestamp` (`level`,`timestamp`),
-  ADD KEY `idx_auth_id` (`auth_id`,`level`,`timestamp`);
+  ADD KEY `idx_customer` (`customer`,`level`,`ts`),
+  ADD KEY `idx_timestamp` (`level`,`ts`),
+  ADD KEY `idx_auth_id` (`auth_id`,`level`,`ts`);
 
 
 
 
 ALTER TABLE `acl`
 ALTER TABLE `acl`
@@ -684,7 +684,7 @@ ALTER TABLE `config_options`
 ALTER TABLE `connections`
 ALTER TABLE `connections`
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Customers`
+ALTER TABLE `customers`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `devices`
 ALTER TABLE `devices`
@@ -720,16 +720,16 @@ ALTER TABLE `dns_queue`
 ALTER TABLE `filter_instances`
 ALTER TABLE `filter_instances`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Filter_list`
+ALTER TABLE `filter_list`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `gateway_subnets`
 ALTER TABLE `gateway_subnets`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Group_filters`
+ALTER TABLE `group_filters`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Group_list`
+ALTER TABLE `group_list`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `mac_history`
 ALTER TABLE `mac_history`
@@ -741,7 +741,7 @@ ALTER TABLE `mac_vendors`
 ALTER TABLE `OU`
 ALTER TABLE `OU`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Queue_list`
+ALTER TABLE `queue_list`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `remote_syslog`
 ALTER TABLE `remote_syslog`
@@ -750,28 +750,28 @@ ALTER TABLE `remote_syslog`
 ALTER TABLE `subnets`
 ALTER TABLE `subnets`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Traffic_detail`
+ALTER TABLE `traffic_detail`
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Unknown_mac`
+ALTER TABLE `unknown_mac`
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `User_auth`
+ALTER TABLE `user_auth`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `User_auth_alias`
+ALTER TABLE `user_auth_alias`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `User_list`
+ALTER TABLE `user_list`
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `user_sessions`
 ALTER TABLE `user_sessions`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `User_stats`
+ALTER TABLE `user_stats`
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `User_stats_full`
+ALTER TABLE `user_stats_full`
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `variables`
 ALTER TABLE `variables`
@@ -780,7 +780,7 @@ ALTER TABLE `variables`
 ALTER TABLE `vendors`
 ALTER TABLE `vendors`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Wan_stats`
+ALTER TABLE `wan_stats`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `worklog`
 ALTER TABLE `worklog`

+ 121 - 121
docs/databases/mysql/en/data.sql

@@ -6,66 +6,66 @@ SET time_zone = "+00:00";
 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 /*!40101 SET NAMES utf8mb4 */;
 /*!40101 SET NAMES utf8mb4 */;
 
 
-INSERT INTO `acl` (`id`, `name`, `description.english`, `description.russian`) VALUES(1, 'Full access', 'Full access', 'Полный доступ');
-INSERT INTO `acl` (`id`, `name`, `description.english`, `description.russian`) VALUES(2, 'Operator', 'Editing parameters that are not related to access rights', 'Редактирование параметров, не связанных с правами доступа');
-INSERT INTO `acl` (`id`, `name`, `description.english`, `description.russian`) VALUES(3, 'View only', 'View only', 'Только просмотр');
+INSERT INTO `acl` (`id`, `name`, description_english, description_russian) VALUES(1, 'Full access', 'Full access', 'Полный доступ');
+INSERT INTO `acl` (`id`, `name`, description_english, description_russian) VALUES(2, 'Operator', 'Editing parameters that are not related to access rights', 'Редактирование параметров, не связанных с правами доступа');
+INSERT INTO `acl` (`id`, `name`, description_english, description_russian) VALUES(3, 'View only', 'View only', 'Только просмотр');
 
 
 INSERT INTO `building` (`id`, `name`, `comment`) VALUES(1, 'Earth', 'Somewhere');
 INSERT INTO `building` (`id`, `name`, `comment`) VALUES(1, 'Earth', 'Somewhere');
 
 
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(1, 'KB', 'Еденица измерения трафика - Килобайт (0) или кибибайт (1,default)', 'Traffic measurement unit - Kilobyte (1000b) or kibibyte (1024b,default)', 0, 1, 'bool', '1024', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(3, 'dns server', 'ip-адрес DNS-сервера', 'DNS server ip address', 0, 1, 'text', '127.0.0.1', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(5, 'dhcp server', 'ip-адрес DHCP-сервера', 'ip address of the DHCP server', 0, 1, 'text', '127.0.0.1', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(9, 'default snmp version', 'Версия snmp по умолчанию. В настоящий момент поддерживаются 1 и 2. Поддержка версии 3 в разработке.', 'The default version of snmp. Currently, 1 and 2 are supported. Support for version 3 is in development.', 0, 1, 'int', '2', 1, 3);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(11, 'default snmp community', 'Read snmp community по умолчанию', 'Read snmp community by default', 0, 1, 'text', 'public', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(21, 'admin email', 'E-mail администратора', 'Administrator e-mail', 0, 1, 'text', 'root', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(22, 'add user from netflow', 'Создавать ли новые записи для неизвестных адресов из анализа трафика netflow. Не включать, если netflow снимает данные с маршрутизатора локальной сети', 'Whether to create new records for unknown addresses from netflow traffic analysis. Do not enable if netflow get data from the local network router', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(23, 'save traffic detail', 'Сохранять ли детализацию трафика из netflow по ip-адресам пользователей', 'Whether to keep the details of traffic from netflow by ip addresses of users', 0, 1, 'bool', '1', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(26, 'history detail traffic', 'Глубина хранения детализации в сутках. Установка значения больше 3-7 дней приведёт к разрастанию базы данных и увеличит время отображения детализации в интерфейсе администратора', 'Depth of detail storage in days. Setting a value greater than 3-7 days will cause the database to grow and increase the time about to display details in the admin interface', 0, 1, 'int', '3', 1, 7);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(27, 'history dhcp lease', 'Глубина хранения аренды dhcp-сервера', 'Storage depth of the dhcp server lease', 0, 1, 'int', '1', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(28, 'router_login', 'Логин для входа на сетевые устройства по умолчанию', 'Default login for network devices', 0, 1, 'text', 'admin', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(29, 'router_password', 'Пароль по умолчанию на сетевые устройства', 'Default password for network devices', 0, 1, 'text', 'admin', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(30, 'router_ssh_port', 'Порт ssh по умолчанию', 'SSH default port', 0, 1, 'int', '22', 22, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(32, 'org name', 'Название организации', 'Organization name', 0, 1, 'text', 'ORG', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(33, 'office domain', 'Домен организации', 'Organization domain', 0, 1, 'text', 'local', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(34, 'debug', 'Включить отладку', 'Enable debugging', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(35, 'connections history, days', 'Время хранения истории мест подключения ip-адресов', 'Storage time of the history of connection locations of ip addresses', 0, 1, 'int', '90', 1, 365);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(37, 'refresh access lists', 'Расположение скрипта управления контролем доступа для роутеров Mikrotik', 'Location of the access control script for Mikrotik routers', 0, 1, 'text', '/opt/Eye/scripts/sync_mikrotik.pl', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(38, 'regenerate dhcp cconfig', 'Расположение скрипта управления конфигурацией dhcp-серверами', 'Location of the dhcp server configuration management script', 0, 1, 'text', '/opt/Eye/scripts/update-dnsmasq', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(39, 'regenerate dns cconfig', 'Расположение скрипта управления dns-сервером', 'Location of the dns server management script', 0, 1, 'text', '/opt/Eye/scripts/update-dns', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(40, 'regenerate nagios cconfig', 'Расположение скрипта конфигурирования Nagios', 'Location of the Nagios configuration script', 0, 1, 'text', '/etc/nagios/restart_nagios', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(41, 'discovery network', 'Расположение скрипта сканирования сети', 'Location of the network scan script', 0, 1, 'text', '/opt/Eye/scripts/fetch_new_arp.pl', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(44, 'Ignore hotspot dhcp log', 'Не писать лог событий dhcp-сервера хотспота. Имеет смысл вклчючать, поскольку время аренды в хот-споте как правило маленькое и в записях хот-спота становятся незаметны логи обычных пользователей', 'Do not write the event log of the hotspot dhcp server. It makes sense to include it, since the rental time in the hotspot is usually small and the logs of ordinary users become invisible in the hotspot records', 0, 1, 'bool', '1', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(45, 'ignore update dhcp event', 'Не писать события обновления ip-адреса dhcp-сервера. ', 'Do not write events for updating the IP address of the dhcp server. ', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(46, 'update hostname from dhcp', 'Обновлять имя хоста в DNS при получении адреса по DHCP', 'Update the hostname in DNS when receiving the address via DHCP', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(47, 'history worklog', 'Глубина хранения VERBOSE логов работы в интерфейсе администратора', 'Depth of work VERBOSE logs storage in the admin interface', 0, 1, 'int', '90', 0, 1095);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(48, 'history syslog', 'Глубина хранения логов работы syslog-сервера', 'Syslog server logs storage depth', 0, 1, 'int', '90', 0, 1095);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(49, 'history traffic stats', 'Глубина хранения статистики трафика юзеров', 'User traffic statistics storage depth', 0, 1, 'int', '365', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(50, 'urgent sync access', 'Немедленное изменение списков доступа на роутере после правки записи пользователя', 'Immediate change of access lists on the router after editing the user record ', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(51, 'Email_alert', 'Отправлять e-mail уведомления', 'Send e-mail notifications', 0, 1, 'bool', '1', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(52, 'Sender email', 'E-mail адрес, с которого рассылается почта', 'E-mail address from which mail is sent', 0, 1, 'text', 'root', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(53, 'log level', 'Каждый уровень включает в себя предыдущий:\r\n0 - ERROR - писать только ошибки\r\n1 - WARNING - писать предупреждения\r\n2 - INFO - писать информационные сообщения\r\n3 - VERBOSE - писать подробную информацию о выполняемых операциях', 'Each level includes the previous one:\r\n0 - ERROR - write only errors\r\n1 - WARNING - write warnings\r\n2 - INFO - write informational\r\n3 - VERBOSE - write detailed information about the operations performed ', 0, 1, 'int', '2', 0, 3);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(54, 'enable_quotes', 'Включить обработку квот по трафику', 'Enable traffic quota processing', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(55, 'netflow_step', 'Интервал сброса данных из коллектора netflow, минуты', 'Data reset interval from netflow collector, minutes', 0, 1, 'int', '1', 1, 10);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(56, 'traffic_ipstat_history', 'Время хранения полной статистики по трафику для каждого ip-адреса в сутках. Таблица в 6 раз больше обычной часовой статистики. Врядли кому-то потребуется глубина хранения более месяца.', 'The storage time of complete traffic statistics for each ip address in days. The table is 6 times larger than the usual hourly statistic Hardly anyone will need a storage depth of more than a month.', 0, 1, 'int', '30', 0, 365);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(57, 'nagios_url', 'Адрес сайта nagios', 'nagios site address', 0, 1, 'text', 'http://127.0.0.1/nagios', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(58, 'cacti_url', 'Адрес сайта cacti', 'cacti site address', 0, 1, 'text', 'http://127.0.0.1/cacti', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(59, 'torrus_url', 'Адрес сайта Torrus', 'Torrus website address', 0, 1, 'text', 'http://127.0.0.1/torrus/CollectorName/', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(60, 'wiki_url', 'Адрес wiki', 'Wiki website address', 0, 1, 'text', 'http://127.0.0.1/wiki', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(61, 'wiki_path', 'Путь к каталогу данных вики', 'Path to wiki data directory', 0, 1, 'text', '/var/www/foswiki/data/', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(62, 'stat_url', 'Адрес этого сайта', 'Address of this site', 0, 1, 'text', 'http://127.0.0.1/stat', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(63, 'wiki_web', 'Web for Wiki. Default - Main. http://example.local/Main/WebHome', 'Web for Wiki. Default - Main. http://example.local/Main/WebHome', 0, 1, 'text', 'Main', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(64, 'auto_mac_rule', 'Создавать автоматическую привязку мак-адреса к юзеру. Т.е. все ip-адреса для найденного мака будут привязываться к одном и тому же юзеру.', 'Create an automatic binding of the mac address to the user. I.e. all ip addresses for the found mac will be bound to the same user.', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(65, 'mikrotik_command_interface', 'Используемый способ конфигурирования (0 - cli для ROS 6, 1 - rest api для ROS 7)', 'Configuration method used (0 - cli for ROS 6, 1 - rest api for ROS 7)', 1, 1, 'int', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(66, 'mikrotik_rest_api_ssl', 'Использовать https для rest api', 'Use HTTPS for rest api', 1, 1, 'bool', '1', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(67, 'mikrotik_rest_api_port', 'Порт вэб-интерфейса для rest api', 'Web interface port for rest API', 1, 1, 'int', '443', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(68, 'config_mode', 'Режим конфигурирования. Скрипт опроса устройств не выполняется.', 'Configuration mode. The device polling script is not running.', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(69, 'clean_empty_user', 'Автоматически удалять записи пользователей, не содержащие ip-адресов или автоматических привязок', 'Automatically delete user records that do not contain IP addresses or automatic bindings', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(70, 'dns_server_type', 'Тип используемого dns-сервера: Windows, Bind. Если используется локальный dnsmasq - параметры dns-сервера указывать не надо.', 'The type of dns server used: Windows, Bind. If you are using a local dnsmasq, you do not need to specify the dns server parameters.', 0, 1, 'list;windows;bind', 'bind', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(71, 'enable_dns_updates', 'Включить обновления DNS имен при изменении dns-имени в ip-записи', 'Enable DNS name updates when dns name changes in an ip record', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(72, 'netflow_path', 'Каталог для хранения данных, полученных по netflow от маршрутизаторов', 'The directory for storing data received via netflow from routers', 0, 1, 'text', '/opt/Eye/netflow', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(73, 'check_computer_exists', 'Проверять существование компьютера в домене перед обновлением DNS по DHCP запросу', 'Verify the existence of a computer in the domain before updating DNS by DHCP request', 0, 1, 'bool', '1', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(1, 'KB', 'Еденица измерения трафика - Килобайт (0) или кибибайт (1,default)', 'Traffic measurement unit - Kilobyte (1000b) or kibibyte (1024b,default)', 0, 1, 'bool', '1024', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(3, 'dns server', 'ip-адрес DNS-сервера', 'DNS server ip address', 0, 1, 'text', '127.0.0.1', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(5, 'dhcp server', 'ip-адрес DHCP-сервера', 'ip address of the DHCP server', 0, 1, 'text', '127.0.0.1', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(9, 'default snmp version', 'Версия snmp по умолчанию. В настоящий момент поддерживаются 1 и 2. Поддержка версии 3 в разработке.', 'The default version of snmp. Currently, 1 and 2 are supported. Support for version 3 is in development.', 0, 1, 'int', '2', 1, 3);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(11, 'default snmp community', 'Read snmp community по умолчанию', 'Read snmp community by default', 0, 1, 'text', 'public', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(21, 'admin email', 'E-mail администратора', 'Administrator e-mail', 0, 1, 'text', 'root', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(22, 'add user from netflow', 'Создавать ли новые записи для неизвестных адресов из анализа трафика netflow. Не включать, если netflow снимает данные с маршрутизатора локальной сети', 'Whether to create new records for unknown addresses from netflow traffic analysis. Do not enable if netflow get data from the local network router', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(23, 'save traffic detail', 'Сохранять ли детализацию трафика из netflow по ip-адресам пользователей', 'Whether to keep the details of traffic from netflow by ip addresses of users', 0, 1, 'bool', '1', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(26, 'history detail traffic', 'Глубина хранения детализации в сутках. Установка значения больше 3-7 дней приведёт к разрастанию базы данных и увеличит время отображения детализации в интерфейсе администратора', 'Depth of detail storage in days. Setting a value greater than 3-7 days will cause the database to grow and increase the time about to display details in the admin interface', 0, 1, 'int', '3', 1, 7);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(27, 'history dhcp lease', 'Глубина хранения аренды dhcp-сервера', 'Storage depth of the dhcp server lease', 0, 1, 'int', '1', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(28, 'router_login', 'Логин для входа на сетевые устройства по умолчанию', 'Default login for network devices', 0, 1, 'text', 'admin', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(29, 'router_password', 'Пароль по умолчанию на сетевые устройства', 'Default password for network devices', 0, 1, 'text', 'admin', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(30, 'router_ssh_port', 'Порт ssh по умолчанию', 'SSH default port', 0, 1, 'int', '22', 22, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(32, 'org name', 'Название организации', 'Organization name', 0, 1, 'text', 'ORG', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(33, 'office domain', 'Домен организации', 'Organization domain', 0, 1, 'text', 'local', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(34, 'debug', 'Включить отладку', 'Enable debugging', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(35, 'connections history, days', 'Время хранения истории мест подключения ip-адресов', 'Storage time of the history of connection locations of ip addresses', 0, 1, 'int', '90', 1, 365);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(37, 'refresh access lists', 'Расположение скрипта управления контролем доступа для роутеров Mikrotik', 'Location of the access control script for Mikrotik routers', 0, 1, 'text', '/opt/Eye/scripts/sync_mikrotik.pl', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(38, 'regenerate dhcp cconfig', 'Расположение скрипта управления конфигурацией dhcp-серверами', 'Location of the dhcp server configuration management script', 0, 1, 'text', '/opt/Eye/scripts/update-dnsmasq', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(39, 'regenerate dns cconfig', 'Расположение скрипта управления dns-сервером', 'Location of the dns server management script', 0, 1, 'text', '/opt/Eye/scripts/update-dns', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(40, 'regenerate nagios cconfig', 'Расположение скрипта конфигурирования Nagios', 'Location of the Nagios configuration script', 0, 1, 'text', '/etc/nagios/restart_nagios', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(41, 'discovery network', 'Расположение скрипта сканирования сети', 'Location of the network scan script', 0, 1, 'text', '/opt/Eye/scripts/fetch_new_arp.pl', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(44, 'Ignore hotspot dhcp log', 'Не писать лог событий dhcp-сервера хотспота. Имеет смысл вклчючать, поскольку время аренды в хот-споте как правило маленькое и в записях хот-спота становятся незаметны логи обычных пользователей', 'Do not write the event log of the hotspot dhcp server. It makes sense to include it, since the rental time in the hotspot is usually small and the logs of ordinary users become invisible in the hotspot records', 0, 1, 'bool', '1', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(45, 'ignore update dhcp event', 'Не писать события обновления ip-адреса dhcp-сервера. ', 'Do not write events for updating the IP address of the dhcp server. ', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(46, 'update hostname from dhcp', 'Обновлять имя хоста в DNS при получении адреса по DHCP', 'Update the hostname in DNS when receiving the address via DHCP', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(47, 'history worklog', 'Глубина хранения VERBOSE логов работы в интерфейсе администратора', 'Depth of work VERBOSE logs storage in the admin interface', 0, 1, 'int', '90', 0, 1095);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(48, 'history syslog', 'Глубина хранения логов работы syslog-сервера', 'Syslog server logs storage depth', 0, 1, 'int', '90', 0, 1095);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(49, 'history traffic stats', 'Глубина хранения статистики трафика юзеров', 'User traffic statistics storage depth', 0, 1, 'int', '365', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(50, 'urgent sync access', 'Немедленное изменение списков доступа на роутере после правки записи пользователя', 'Immediate change of access lists on the router after editing the user record ', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(51, 'Email_alert', 'Отправлять e-mail уведомления', 'Send e-mail notifications', 0, 1, 'bool', '1', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(52, 'Sender email', 'E-mail адрес, с которого рассылается почта', 'E-mail address from which mail is sent', 0, 1, 'text', 'root', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(53, 'log level', 'Каждый уровень включает в себя предыдущий:\r\n0 - ERROR - писать только ошибки\r\n1 - WARNING - писать предупреждения\r\n2 - INFO - писать информационные сообщения\r\n3 - VERBOSE - писать подробную информацию о выполняемых операциях', 'Each level includes the previous one:\r\n0 - ERROR - write only errors\r\n1 - WARNING - write warnings\r\n2 - INFO - write informational\r\n3 - VERBOSE - write detailed information about the operations performed ', 0, 1, 'int', '2', 0, 3);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(54, 'enable_quotes', 'Включить обработку квот по трафику', 'Enable traffic quota processing', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(55, 'netflow_step', 'Интервал сброса данных из коллектора netflow, минуты', 'Data reset interval from netflow collector, minutes', 0, 1, 'int', '1', 1, 10);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(56, 'traffic_ipstat_history', 'Время хранения полной статистики по трафику для каждого ip-адреса в сутках. Таблица в 6 раз больше обычной часовой статистики. Врядли кому-то потребуется глубина хранения более месяца.', 'The storage time of complete traffic statistics for each ip address in days. The table is 6 times larger than the usual hourly statistic Hardly anyone will need a storage depth of more than a month.', 0, 1, 'int', '30', 0, 365);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(57, 'nagios_url', 'Адрес сайта nagios', 'nagios site address', 0, 1, 'text', 'http://127.0.0.1/nagios', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(58, 'cacti_url', 'Адрес сайта cacti', 'cacti site address', 0, 1, 'text', 'http://127.0.0.1/cacti', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(59, 'torrus_url', 'Адрес сайта Torrus', 'Torrus website address', 0, 1, 'text', 'http://127.0.0.1/torrus/CollectorName/', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(60, 'wiki_url', 'Адрес wiki', 'Wiki website address', 0, 1, 'text', 'http://127.0.0.1/wiki', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(61, 'wiki_path', 'Путь к каталогу данных вики', 'Path to wiki data directory', 0, 1, 'text', '/var/www/foswiki/data/', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(62, 'stat_url', 'Адрес этого сайта', 'Address of this site', 0, 1, 'text', 'http://127.0.0.1/stat', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(63, 'wiki_web', 'Web for Wiki. Default - Main. http://example.local/Main/WebHome', 'Web for Wiki. Default - Main. http://example.local/Main/WebHome', 0, 1, 'text', 'Main', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(64, 'auto_mac_rule', 'Создавать автоматическую привязку мак-адреса к юзеру. Т.е. все ip-адреса для найденного мака будут привязываться к одном и тому же юзеру.', 'Create an automatic binding of the mac address to the user. I.e. all ip addresses for the found mac will be bound to the same user.', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(65, 'mikrotik_command_interface', 'Используемый способ конфигурирования (0 - cli для ROS 6, 1 - rest api для ROS 7)', 'Configuration method used (0 - cli for ROS 6, 1 - rest api for ROS 7)', 1, 1, 'int', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(66, 'mikrotik_rest_api_ssl', 'Использовать https для rest api', 'Use HTTPS for rest api', 1, 1, 'bool', '1', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(67, 'mikrotik_rest_api_port', 'Порт вэб-интерфейса для rest api', 'Web interface port for rest API', 1, 1, 'int', '443', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(68, 'config_mode', 'Режим конфигурирования. Скрипт опроса устройств не выполняется.', 'Configuration mode. The device polling script is not running.', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(69, 'clean_empty_user', 'Автоматически удалять записи пользователей, не содержащие ip-адресов или автоматических привязок', 'Automatically delete user records that do not contain IP addresses or automatic bindings', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(70, 'dns_server_type', 'Тип используемого dns-сервера: Windows, Bind. Если используется локальный dnsmasq - параметры dns-сервера указывать не надо.', 'The type of dns server used: Windows, Bind. If you are using a local dnsmasq, you do not need to specify the dns server parameters.', 0, 1, 'list;windows;bind', 'bind', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(71, 'enable_dns_updates', 'Включить обновления DNS имен при изменении dns-имени в ip-записи', 'Enable DNS name updates when dns name changes in an ip record', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(72, 'netflow_path', 'Каталог для хранения данных, полученных по netflow от маршрутизаторов', 'The directory for storing data received via netflow from routers', 0, 1, 'text', '/opt/Eye/netflow', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(73, 'check_computer_exists', 'Проверять существование компьютера в домене перед обновлением DNS по DHCP запросу', 'Verify the existence of a computer in the domain before updating DNS by DHCP request', 0, 1, 'bool', '1', 0, 0);
 
 
-INSERT INTO `Customers` (`id`, `Login`, `comment`, `password`, `api_key`,`rights`) VALUES (1, 'admin', 'Administrator', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31','1') ON DUPLICATE KEY UPDATE `Login`="admin", `password`="$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG", `rights`="1";
+INSERT INTO `customers` (`id`, `Login`, `comment`, `password`, `api_key`,`rights`) VALUES (1, 'admin', 'Administrator', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31','1') ON DUPLICATE KEY UPDATE `Login`="admin", `password`="$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG", `rights`="1";
 
 
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(1, '2011LS', 9, 1, 0, NULL);
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(1, '2011LS', 9, 1, 0, NULL);
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(2, '2011UAS-2HnD', 9, 1, 0, NULL);
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(2, '2011UAS-2HnD', 9, 1, 0, NULL);
@@ -183,18 +183,18 @@ INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(116, 'SNR-S5210X-8F-UPS', 6, 0, 0, NULL);
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(116, 'SNR-S5210X-8F-UPS', 6, 0, 0, NULL);
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(117, 'SNR-S2982G-8T-UPS', 6, 0, 0, NULL);
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(117, 'SNR-S2982G-8T-UPS', 6, 0, 0, NULL);
 
 
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(0, 'Роутер', 'Router');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(1, 'Свич', 'Switch');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(2, 'Шлюз', 'Gateway');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(3, 'Сервер', 'Server');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(4, 'Точка доступа', 'WiFi Access Point');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(5, 'Сетевое устройство', 'Network device');
+INSERT INTO `device_types` (`id`, name_russian, name_english) VALUES(0, 'Роутер', 'Router');
+INSERT INTO `device_types` (`id`, name_russian, name_english) VALUES(1, 'Свич', 'Switch');
+INSERT INTO `device_types` (`id`, name_russian, name_english) VALUES(2, 'Шлюз', 'Gateway');
+INSERT INTO `device_types` (`id`, name_russian, name_english) VALUES(3, 'Сервер', 'Server');
+INSERT INTO `device_types` (`id`, name_russian, name_english) VALUES(4, 'Точка доступа', 'WiFi Access Point');
+INSERT INTO `device_types` (`id`, name_russian, name_english) VALUES(5, 'Сетевое устройство', 'Network device');
 
 
 INSERT INTO `filter_instances` (`id`, `name`, `comment`) VALUES(1, 'default', NULL);
 INSERT INTO `filter_instances` (`id`, `name`, `comment`) VALUES(1, 'default', NULL);
 
 
-INSERT INTO `Group_list` (`id`, `instance_id`, `group_name`, `comment`) VALUES(0, 1, 'default', 'Forbidden all');
-INSERT INTO `Group_list` (`id`, `instance_id`, `group_name`, `comment`) VALUES(1, 1, 'Allow all', 'Allowed all');
-INSERT INTO `Group_list` (`id`, `instance_id`, `group_name`, `comment`) VALUES(2, 1, 'Users','For users');
+INSERT INTO `group_list` (`id`, `instance_id`, `group_name`, `comment`) VALUES(0, 1, 'default', 'Forbidden all');
+INSERT INTO `group_list` (`id`, `instance_id`, `group_name`, `comment`) VALUES(1, 1, 'Allow all', 'Allowed all');
+INSERT INTO `group_list` (`id`, `instance_id`, `group_name`, `comment`) VALUES(2, 1, 'Users','For users');
 
 
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(0, '!Any', NULL, 0, 0, '/etc/nagios/any', 'generic-host', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(0, '!Any', NULL, 0, 0, '/etc/nagios/any', 'generic-host', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(1, 'Servers', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 0, 0, '24.00', NULL);
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(1, 'Servers', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 0, 0, '24.00', NULL);
@@ -211,15 +211,15 @@ INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(12, 'DHCP', NULL, 1, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, '24.00', NULL);
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(12, 'DHCP', NULL, 1, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, '24.00', NULL);
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(13, 'Guests', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4, 1, '24.00', NULL);
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(13, 'Guests', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4, 1, '24.00', NULL);
 
 
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(0, 'unlimited', 0, 0);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(1, '2M/2M', 2048, 2048);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(2, '10M/10M', 10240, 10240);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(3, '100M/100M', 102400, 102400);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(4, '50M/50M', 50000, 50000);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(5, '20M/20M', 20480, 20480);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(6, '200M/200M', 212400, 212400);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(7, '1G/1G', 1024000, 1024000);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(8, '2G/2G', 2048000, 2048000);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(0, 'unlimited', 0, 0);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(1, '2M/2M', 2048, 2048);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(2, '10M/10M', 10240, 10240);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(3, '100M/100M', 102400, 102400);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(4, '50M/50M', 50000, 50000);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(5, '20M/20M', 20480, 20480);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(6, '200M/200M', 212400, 212400);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(7, '1G/1G', 1024000, 1024000);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(8, '2G/2G', 2048000, 2048000);
 
 
 INSERT INTO `subnets` (`id`, `subnet`, `vlan_tag`, `ip_int_start`, `ip_int_stop`, `dhcp_start`, `dhcp_stop`, `dhcp_lease_time`, `gateway`, `office`, `hotspot`, `vpn`, `free`, `dhcp`, `static`, `dhcp_update_hostname`, `discovery`, `notify`, `comment`) VALUES(1, '192.168.2.0/24', 2, 3232236032, 3232236287, 3232236132, 3232236182, 480, 3232236033, 1, 0, 0, 0, 1, 0, 1, 1, 7, 'LAN');
 INSERT INTO `subnets` (`id`, `subnet`, `vlan_tag`, `ip_int_start`, `ip_int_stop`, `dhcp_start`, `dhcp_stop`, `dhcp_lease_time`, `gateway`, `office`, `hotspot`, `vpn`, `free`, `dhcp`, `static`, `dhcp_update_hostname`, `discovery`, `notify`, `comment`) VALUES(1, '192.168.2.0/24', 2, 3232236032, 3232236287, 3232236132, 3232236182, 480, 3232236033, 1, 0, 0, 0, 1, 0, 1, 1, 7, 'LAN');
 
 
@@ -279,54 +279,54 @@ INSERT INTO `vendors` (`id`, `name`) VALUES(67, 'Testo');
 INSERT INTO `vendors` (`id`, `name`) VALUES(68, 'Hw-group');
 INSERT INTO `vendors` (`id`, `name`) VALUES(68, 'Hw-group');
 INSERT INTO `vendors` (`id`, `name`) VALUES(69, 'Tp-link');
 INSERT INTO `vendors` (`id`, `name`) VALUES(69, 'Tp-link');
 
 
-INSERT INTO `Filter_list` VALUES (1,'pop3',NULL,'tcp','0/0','110',NULL,0);
-INSERT INTO `Filter_list` VALUES (3,'http',NULL,'tcp','0/0','80',NULL,0);
-INSERT INTO `Filter_list` VALUES (4,'https',NULL,'tcp','0/0','443',NULL,0);
-INSERT INTO `Filter_list` VALUES (5,'icq',NULL,'tcp','0/0','5190',NULL,0);
-INSERT INTO `Filter_list` VALUES (6,'jabber',NULL,'tcp','0/0','5222',NULL,0);
-INSERT INTO `Filter_list` VALUES (9,'allow_all','any','all','0/0','0','0',0);
-INSERT INTO `Filter_list` VALUES (10,'icmp',NULL,'icmp','0/0','0',NULL,0);
-INSERT INTO `Filter_list` VALUES (11,'ftp',NULL,'tcp','0/0','20-21',NULL,0);
-INSERT INTO `Filter_list` VALUES (15,'telnet',NULL,'tcp','0/0','23',NULL,0);
-INSERT INTO `Filter_list` VALUES (16,'ssh',NULL,'tcp','0/0','22',NULL,0);
-INSERT INTO `Filter_list` VALUES (28,'smtp',NULL,'tcp','0/0','25',NULL,0);
-INSERT INTO `Filter_list` VALUES (32,'rdp',NULL,'tcp','0/0','3389',NULL,0);
-INSERT INTO `Filter_list` VALUES (40,'ntp',NULL,'udp','0/0','123',NULL,0);
-INSERT INTO `Filter_list` VALUES (44,'vnc',NULL,'tcp','0/0','5800-5900',NULL,0);
-INSERT INTO `Filter_list` VALUES (55,'unprivileged tcp',NULL,'tcp','0/0','1024-65500',NULL,0);
-INSERT INTO `Filter_list` VALUES (76,'ipsec',NULL,'udp','0/0','500',NULL,0);
-INSERT INTO `Filter_list` VALUES (77,'isakmp',NULL,'udp','0/0','4500',NULL,0);
-INSERT INTO `Filter_list` VALUES (79,'pop3s',NULL,'tcp','0/0','995',NULL,0);
-INSERT INTO `Filter_list` VALUES (80,'smtps',NULL,'tcp','0/0','465,587',NULL,0);
-INSERT INTO `Filter_list` VALUES (81,'imap',NULL,'tcp','0/0','143',NULL,0);
-INSERT INTO `Filter_list` VALUES (82,'imaps',NULL,'tcp','0/0','993',NULL,0);
-INSERT INTO `Filter_list` VALUES (83,'unprivileged udp',NULL,'udp','0/0','1024-65000',NULL,0);
-INSERT INTO `Filter_list` VALUES (84,'pptp',NULL,'tcp','0/0','1723',NULL,0);
-INSERT INTO `Filter_list` VALUES (85,'openvpn-udp',NULL,'udp','0/0','1194',NULL,0);
-INSERT INTO `Filter_list` VALUES (90,'dns_udp',NULL,'udp','0/0','53',NULL,0);
-INSERT INTO `Filter_list` VALUES (91,'dns_tcp',NULL,'tcp','0/0','53',NULL,0);
-INSERT INTO `Filter_list` VALUES (94,'squid',NULL,'tcp','0/0','3128',NULL,0);
-INSERT INTO `Filter_list` VALUES (101,'snmp',NULL,'udp','0/0','161',NULL,0);
-INSERT INTO `Filter_list` VALUES (105,'http_udp',NULL,'udp','0/0','80',NULL,0);
-INSERT INTO `Filter_list` VALUES (106,'https_udp',NULL,'udp','0/0','443',NULL,0);
-INSERT INTO `Filter_list` VALUES (107,'l2tp-ipsec',NULL,'udp','0/0','1701,4500,500',NULL,0);
-INSERT INTO `Filter_list` VALUES (108,'gre',NULL,'gre','0/0',NULL,NULL,0);
+INSERT INTO `filter_list` VALUES (1,'pop3',NULL,'tcp','0/0','110',NULL,0);
+INSERT INTO `filter_list` VALUES (3,'http',NULL,'tcp','0/0','80',NULL,0);
+INSERT INTO `filter_list` VALUES (4,'https',NULL,'tcp','0/0','443',NULL,0);
+INSERT INTO `filter_list` VALUES (5,'icq',NULL,'tcp','0/0','5190',NULL,0);
+INSERT INTO `filter_list` VALUES (6,'jabber',NULL,'tcp','0/0','5222',NULL,0);
+INSERT INTO `filter_list` VALUES (9,'allow_all','any','all','0/0','0','0',0);
+INSERT INTO `filter_list` VALUES (10,'icmp',NULL,'icmp','0/0','0',NULL,0);
+INSERT INTO `filter_list` VALUES (11,'ftp',NULL,'tcp','0/0','20-21',NULL,0);
+INSERT INTO `filter_list` VALUES (15,'telnet',NULL,'tcp','0/0','23',NULL,0);
+INSERT INTO `filter_list` VALUES (16,'ssh',NULL,'tcp','0/0','22',NULL,0);
+INSERT INTO `filter_list` VALUES (28,'smtp',NULL,'tcp','0/0','25',NULL,0);
+INSERT INTO `filter_list` VALUES (32,'rdp',NULL,'tcp','0/0','3389',NULL,0);
+INSERT INTO `filter_list` VALUES (40,'ntp',NULL,'udp','0/0','123',NULL,0);
+INSERT INTO `filter_list` VALUES (44,'vnc',NULL,'tcp','0/0','5800-5900',NULL,0);
+INSERT INTO `filter_list` VALUES (55,'unprivileged tcp',NULL,'tcp','0/0','1024-65500',NULL,0);
+INSERT INTO `filter_list` VALUES (76,'ipsec',NULL,'udp','0/0','500',NULL,0);
+INSERT INTO `filter_list` VALUES (77,'isakmp',NULL,'udp','0/0','4500',NULL,0);
+INSERT INTO `filter_list` VALUES (79,'pop3s',NULL,'tcp','0/0','995',NULL,0);
+INSERT INTO `filter_list` VALUES (80,'smtps',NULL,'tcp','0/0','465,587',NULL,0);
+INSERT INTO `filter_list` VALUES (81,'imap',NULL,'tcp','0/0','143',NULL,0);
+INSERT INTO `filter_list` VALUES (82,'imaps',NULL,'tcp','0/0','993',NULL,0);
+INSERT INTO `filter_list` VALUES (83,'unprivileged udp',NULL,'udp','0/0','1024-65000',NULL,0);
+INSERT INTO `filter_list` VALUES (84,'pptp',NULL,'tcp','0/0','1723',NULL,0);
+INSERT INTO `filter_list` VALUES (85,'openvpn-udp',NULL,'udp','0/0','1194',NULL,0);
+INSERT INTO `filter_list` VALUES (90,'dns_udp',NULL,'udp','0/0','53',NULL,0);
+INSERT INTO `filter_list` VALUES (91,'dns_tcp',NULL,'tcp','0/0','53',NULL,0);
+INSERT INTO `filter_list` VALUES (94,'squid',NULL,'tcp','0/0','3128',NULL,0);
+INSERT INTO `filter_list` VALUES (101,'snmp',NULL,'udp','0/0','161',NULL,0);
+INSERT INTO `filter_list` VALUES (105,'http_udp',NULL,'udp','0/0','80',NULL,0);
+INSERT INTO `filter_list` VALUES (106,'https_udp',NULL,'udp','0/0','443',NULL,0);
+INSERT INTO `filter_list` VALUES (107,'l2tp-ipsec',NULL,'udp','0/0','1701,4500,500',NULL,0);
+INSERT INTO `filter_list` VALUES (108,'gre',NULL,'gre','0/0',NULL,NULL,0);
 
 
-INSERT INTO `Group_filters` VALUES (1,2,90,1,1);
-INSERT INTO `Group_filters` VALUES (2,2,91,2,1);
-INSERT INTO `Group_filters` VALUES (3,2,11,3,1);
-INSERT INTO `Group_filters` VALUES (5,2,3,4,1);
-INSERT INTO `Group_filters` VALUES (6,2,105,5,1);
-INSERT INTO `Group_filters` VALUES (7,2,4,6,1);
-INSERT INTO `Group_filters` VALUES (8,2,106,7,1);
-INSERT INTO `Group_filters` VALUES (9,2,10,8,1);
-INSERT INTO `Group_filters` VALUES (10,2,81,9,1);
-INSERT INTO `Group_filters` VALUES (11,2,82,10,1);
-INSERT INTO `Group_filters` VALUES (15,2,40,11,1);
-INSERT INTO `Group_filters` VALUES (16,2,1,12,1);
-INSERT INTO `Group_filters` VALUES (17,2,79,13,1);
-INSERT INTO `Group_filters` VALUES (18,2,80,14,1);
-INSERT INTO `Group_filters` VALUES (19,1,9,1,1);
+INSERT INTO `group_filters` VALUES (1,2,90,1,1);
+INSERT INTO `group_filters` VALUES (2,2,91,2,1);
+INSERT INTO `group_filters` VALUES (3,2,11,3,1);
+INSERT INTO `group_filters` VALUES (5,2,3,4,1);
+INSERT INTO `group_filters` VALUES (6,2,105,5,1);
+INSERT INTO `group_filters` VALUES (7,2,4,6,1);
+INSERT INTO `group_filters` VALUES (8,2,106,7,1);
+INSERT INTO `group_filters` VALUES (9,2,10,8,1);
+INSERT INTO `group_filters` VALUES (10,2,81,9,1);
+INSERT INTO `group_filters` VALUES (11,2,82,10,1);
+INSERT INTO `group_filters` VALUES (15,2,40,11,1);
+INSERT INTO `group_filters` VALUES (16,2,1,12,1);
+INSERT INTO `group_filters` VALUES (17,2,79,13,1);
+INSERT INTO `group_filters` VALUES (18,2,80,14,1);
+INSERT INTO `group_filters` VALUES (19,1,9,1,1);
 
 
 INSERT INTO `config` VALUES (1,1,'0');
 INSERT INTO `config` VALUES (1,1,'0');
 INSERT INTO `config` VALUES (2,11,'public');
 INSERT INTO `config` VALUES (2,11,'public');

+ 78 - 78
docs/databases/mysql/ru/create_db.sql

@@ -12,8 +12,8 @@ USE `stat`;
 CREATE TABLE `acl` (
 CREATE TABLE `acl` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `name` varchar(30) NOT NULL,
   `name` varchar(30) NOT NULL,
-  `description.english` varchar(250) NOT NULL,
-  `description.russian` varchar(250) NOT NULL
+  description_english varchar(250) NOT NULL,
+  description_russian varchar(250) NOT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE `ad_comp_cache` (
 CREATE TABLE `ad_comp_cache` (
@@ -46,8 +46,8 @@ CREATE TABLE `config` (
 CREATE TABLE `config_options` (
 CREATE TABLE `config_options` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `option_name` varchar(50) NOT NULL,
   `option_name` varchar(50) NOT NULL,
-  `description.russian` text DEFAULT NULL,
-  `description.english` text DEFAULT NULL,
+  description_russian text DEFAULT NULL,
+  description_english text DEFAULT NULL,
   `draft` tinyint(1) NOT NULL DEFAULT 0,
   `draft` tinyint(1) NOT NULL DEFAULT 0,
   `uniq` tinyint(1) NOT NULL DEFAULT 1,
   `uniq` tinyint(1) NOT NULL DEFAULT 1,
   `type` varchar(100) NOT NULL,
   `type` varchar(100) NOT NULL,
@@ -64,7 +64,7 @@ CREATE TABLE `connections` (
   `last_found` datetime NOT NULL DEFAULT current_timestamp()
   `last_found` datetime NOT NULL DEFAULT current_timestamp()
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Customers` (
+CREATE TABLE `customers` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `Login` varchar(20) DEFAULT 'NULL',
   `Login` varchar(20) DEFAULT 'NULL',
   `comment` varchar(100) DEFAULT NULL,
   `comment` varchar(100) DEFAULT NULL,
@@ -160,8 +160,8 @@ CREATE TABLE `device_ports` (
 
 
 CREATE TABLE `device_types` (
 CREATE TABLE `device_types` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
-  `name.russian` varchar(50) DEFAULT NULL,
-  `name.english` varchar(50) DEFAULT NULL
+  name_russian varchar(50) DEFAULT NULL,
+  name_english varchar(50) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE `dhcp_log` (
 CREATE TABLE `dhcp_log` (
@@ -170,12 +170,12 @@ CREATE TABLE `dhcp_log` (
   `ip_int` bigint(20) UNSIGNED NOT NULL,
   `ip_int` bigint(20) UNSIGNED NOT NULL,
   `ip` varchar(15) NOT NULL,
   `ip` varchar(15) NOT NULL,
   `action` varchar(10) NOT NULL,
   `action` varchar(10) NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
+  `ts` timestamp NOT NULL DEFAULT current_timestamp(),
   `auth_id` bigint(20) UNSIGNED NOT NULL,
   `auth_id` bigint(20) UNSIGNED NOT NULL,
   `dhcp_hostname` varchar(250) DEFAULT NULL,
   `dhcp_hostname` varchar(250) DEFAULT NULL,
-  `circuit-id` varchar(255) DEFAULT NULL,
-  `remote-id` varchar(255) DEFAULT NULL,
-  `client-id` varchar(250) DEFAULT NULL
+  circuit_id varchar(255) DEFAULT NULL,
+  remote_id varchar(255) DEFAULT NULL,
+  client_id varchar(250) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
 
 
 CREATE TABLE `dhcp_queue` (
 CREATE TABLE `dhcp_queue` (
@@ -183,7 +183,7 @@ CREATE TABLE `dhcp_queue` (
   `mac` varchar(17) NOT NULL,
   `mac` varchar(17) NOT NULL,
   `ip` varchar(15) NOT NULL,
   `ip` varchar(15) NOT NULL,
   `action` varchar(10) NOT NULL,
   `action` varchar(10) NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
+  `ts` timestamp NOT NULL DEFAULT current_timestamp(),
   `dhcp_hostname` varchar(250) DEFAULT NULL
   `dhcp_hostname` varchar(250) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
 
 
@@ -191,7 +191,7 @@ CREATE TABLE `dns_cache` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
   `dns` varchar(250) DEFAULT NULL,
   `dns` varchar(250) DEFAULT NULL,
   `ip` bigint(20) UNSIGNED DEFAULT NULL,
   `ip` bigint(20) UNSIGNED DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
+  `ts` timestamp NOT NULL DEFAULT current_timestamp()
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE `dns_queue` (
 CREATE TABLE `dns_queue` (
@@ -209,7 +209,7 @@ CREATE TABLE `filter_instances` (
   `comment` varchar(200) DEFAULT NULL
   `comment` varchar(200) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Filter_list` (
+CREATE TABLE `filter_list` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `name` varchar(50) DEFAULT NULL,
   `name` varchar(50) DEFAULT NULL,
   `comment` varchar(250) DEFAULT NULL,
   `comment` varchar(250) DEFAULT NULL,
@@ -226,7 +226,7 @@ CREATE TABLE `gateway_subnets` (
   `subnet_id` int(11) DEFAULT NULL
   `subnet_id` int(11) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Group_filters` (
+CREATE TABLE `group_filters` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `group_id` int(11) NOT NULL DEFAULT 0,
   `group_id` int(11) NOT NULL DEFAULT 0,
   `filter_id` int(11) NOT NULL DEFAULT 0,
   `filter_id` int(11) NOT NULL DEFAULT 0,
@@ -234,7 +234,7 @@ CREATE TABLE `Group_filters` (
   `action` tinyint(1) NOT NULL DEFAULT 0
   `action` tinyint(1) NOT NULL DEFAULT 0
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Group_list` (
+CREATE TABLE `group_list` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `instance_id` int(11) NOT NULL DEFAULT 1,
   `instance_id` int(11) NOT NULL DEFAULT 1,
   `group_name` varchar(50) DEFAULT NULL,
   `group_name` varchar(50) DEFAULT NULL,
@@ -244,7 +244,7 @@ CREATE TABLE `Group_list` (
 CREATE TABLE `mac_history` (
 CREATE TABLE `mac_history` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
   `mac` varchar(12) DEFAULT NULL,
   `mac` varchar(12) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
+  `ts` timestamp NOT NULL DEFAULT current_timestamp(),
   `device_id` bigint(20) UNSIGNED DEFAULT NULL,
   `device_id` bigint(20) UNSIGNED DEFAULT NULL,
   `port_id` bigint(20) UNSIGNED DEFAULT NULL,
   `port_id` bigint(20) UNSIGNED DEFAULT NULL,
   `ip` varchar(16) NOT NULL DEFAULT '',
   `ip` varchar(16) NOT NULL DEFAULT '',
@@ -277,7 +277,7 @@ CREATE TABLE `OU` (
   `parent_id` int(11) DEFAULT NULL
   `parent_id` int(11) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Queue_list` (
+CREATE TABLE `queue_list` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `queue_name` varchar(20) NOT NULL,
   `queue_name` varchar(20) NOT NULL,
   `Download` int(11) NOT NULL DEFAULT 0,
   `Download` int(11) NOT NULL DEFAULT 0,
@@ -320,11 +320,11 @@ CREATE TABLE `subnets` (
   `comment` varchar(250) DEFAULT NULL
   `comment` varchar(250) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Traffic_detail` (
+CREATE TABLE `traffic_detail` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
   `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
   `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
   `router_id` int(11) NOT NULL DEFAULT 0,
   `router_id` int(11) NOT NULL DEFAULT 0,
-  `timestamp` timestamp NULL DEFAULT NULL,
+  `ts` timestamp NULL DEFAULT NULL,
   `proto` tinyint(3) UNSIGNED DEFAULT NULL,
   `proto` tinyint(3) UNSIGNED DEFAULT NULL,
   `src_ip` int(10) UNSIGNED NOT NULL,
   `src_ip` int(10) UNSIGNED NOT NULL,
   `dst_ip` int(10) UNSIGNED NOT NULL,
   `dst_ip` int(10) UNSIGNED NOT NULL,
@@ -334,15 +334,15 @@ CREATE TABLE `Traffic_detail` (
   `pkt` int(10) UNSIGNED NOT NULL DEFAULT 0
   `pkt` int(10) UNSIGNED NOT NULL DEFAULT 0
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Unknown_mac` (
+CREATE TABLE `unknown_mac` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
   `mac` varchar(12) DEFAULT NULL,
   `mac` varchar(12) DEFAULT NULL,
   `port_id` bigint(20) UNSIGNED DEFAULT NULL,
   `port_id` bigint(20) UNSIGNED DEFAULT NULL,
   `device_id` int(11) DEFAULT NULL,
   `device_id` int(11) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
+  `ts` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `User_auth` (
+CREATE TABLE `user_auth` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `ou_id` int(11) DEFAULT NULL,
   `ou_id` int(11) DEFAULT NULL,
@@ -373,8 +373,8 @@ CREATE TABLE `User_auth` (
   `month_quota` int(11) NOT NULL DEFAULT 0,
   `month_quota` int(11) NOT NULL DEFAULT 0,
   `device_model_id` int(11) DEFAULT 87,
   `device_model_id` int(11) DEFAULT 87,
   `firmware` varchar(100) DEFAULT NULL,
   `firmware` varchar(100) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `client-id` varchar(250) DEFAULT NULL,
+  `ts` timestamp NOT NULL DEFAULT current_timestamp(),
+  client_id varchar(250) DEFAULT NULL,
   `nagios` tinyint(1) NOT NULL DEFAULT 0,
   `nagios` tinyint(1) NOT NULL DEFAULT 0,
   `nagios_status` varchar(10) NOT NULL DEFAULT '',
   `nagios_status` varchar(10) NOT NULL DEFAULT '',
   `nagios_handler` varchar(50) NOT NULL DEFAULT '',
   `nagios_handler` varchar(50) NOT NULL DEFAULT '',
@@ -385,17 +385,17 @@ CREATE TABLE `User_auth` (
   `created_by` varchar(10) DEFAULT NULL
   `created_by` varchar(10) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `User_auth_alias` (
+CREATE TABLE `user_auth_alias` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
   `auth_id` int(11) NOT NULL,
   `auth_id` int(11) NOT NULL,
   `alias` varchar(100) DEFAULT NULL,
   `alias` varchar(100) DEFAULT NULL,
   `description` varchar(100) DEFAULT NULL,
   `description` varchar(100) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
+  `ts` timestamp NOT NULL DEFAULT current_timestamp()
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `User_list` (
+CREATE TABLE `user_list` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
+  `ts` timestamp NOT NULL DEFAULT current_timestamp(),
   `login` varchar(255) DEFAULT NULL,
   `login` varchar(255) DEFAULT NULL,
   `fio` varchar(255) DEFAULT NULL,
   `fio` varchar(255) DEFAULT NULL,
   `enabled` tinyint(1) NOT NULL DEFAULT 1,
   `enabled` tinyint(1) NOT NULL DEFAULT 1,
@@ -421,20 +421,20 @@ CREATE TABLE `user_sessions` (
   `is_active` tinyint(1) DEFAULT 1
   `is_active` tinyint(1) DEFAULT 1
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `User_stats` (
+CREATE TABLE `user_stats` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
   `router_id` bigint(20) UNSIGNED DEFAULT 0,
   `router_id` bigint(20) UNSIGNED DEFAULT 0,
   `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
+  `ts` datetime NOT NULL DEFAULT current_timestamp(),
   `byte_in` bigint(20) NOT NULL DEFAULT 0,
   `byte_in` bigint(20) NOT NULL DEFAULT 0,
   `byte_out` bigint(20) NOT NULL DEFAULT 0
   `byte_out` bigint(20) NOT NULL DEFAULT 0
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `User_stats_full` (
+CREATE TABLE `user_stats_full` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
   `router_id` bigint(20) UNSIGNED DEFAULT 0,
   `router_id` bigint(20) UNSIGNED DEFAULT 0,
   `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
+  `ts` datetime NOT NULL DEFAULT current_timestamp(),
   `byte_in` bigint(20) NOT NULL DEFAULT 0,
   `byte_in` bigint(20) NOT NULL DEFAULT 0,
   `byte_out` bigint(20) NOT NULL DEFAULT 0,
   `byte_out` bigint(20) NOT NULL DEFAULT 0,
   `pkt_in` int(11) DEFAULT NULL,
   `pkt_in` int(11) DEFAULT NULL,
@@ -460,20 +460,20 @@ CREATE TABLE `version` (
   `version` varchar(10) NOT NULL DEFAULT '2.4.14'
   `version` varchar(10) NOT NULL DEFAULT '2.4.14'
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-CREATE TABLE `Wan_stats` (
+CREATE TABLE `wan_stats` (
   `id` int(11) NOT NULL,
   `id` int(11) NOT NULL,
-  `time` datetime NOT NULL DEFAULT current_timestamp(),
+  `ts` datetime NOT NULL DEFAULT current_timestamp(),
   `router_id` int(11) DEFAULT NULL,
   `router_id` int(11) DEFAULT NULL,
   `interface_id` int(11) DEFAULT NULL,
   `interface_id` int(11) DEFAULT NULL,
-  `in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `out` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
+  `bytes_in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
+  `bytes_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `forward_in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `forward_in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `forward_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0
   `forward_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 CREATE TABLE `worklog` (
 CREATE TABLE `worklog` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
+  `ts` timestamp NOT NULL DEFAULT current_timestamp(),
   `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
   `customer` varchar(50) NOT NULL DEFAULT 'system',
   `customer` varchar(50) NOT NULL DEFAULT 'system',
   `ip` varchar(18) NOT NULL DEFAULT '127.0.0.1',
   `ip` varchar(18) NOT NULL DEFAULT '127.0.0.1',
@@ -509,7 +509,7 @@ ALTER TABLE `connections`
   ADD KEY `auth_id` (`auth_id`),
   ADD KEY `auth_id` (`auth_id`),
   ADD KEY `device_id` (`device_id`,`port_id`);
   ADD KEY `device_id` (`device_id`,`port_id`);
 
 
-ALTER TABLE `Customers`
+ALTER TABLE `customers`
   ADD PRIMARY KEY (`id`);
   ADD PRIMARY KEY (`id`);
 
 
 ALTER TABLE `devices`
 ALTER TABLE `devices`
@@ -537,16 +537,16 @@ ALTER TABLE `device_types`
 
 
 ALTER TABLE `dhcp_log`
 ALTER TABLE `dhcp_log`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`action`);
+  ADD KEY `ts` (`ts`,`action`);
 
 
 ALTER TABLE `dhcp_queue`
 ALTER TABLE `dhcp_queue`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`action`);
+  ADD KEY `ts` (`ts`,`action`);
 
 
 ALTER TABLE `dns_cache`
 ALTER TABLE `dns_cache`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD KEY `dns` (`dns`,`ip`),
   ADD KEY `dns` (`dns`,`ip`),
-  ADD KEY `timestamp` (`timestamp`);
+  ADD KEY `ts` (`ts`);
 
 
 ALTER TABLE `dns_queue`
 ALTER TABLE `dns_queue`
   ADD PRIMARY KEY (`id`);
   ADD PRIMARY KEY (`id`);
@@ -555,25 +555,25 @@ ALTER TABLE `filter_instances`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD UNIQUE KEY `name` (`name`);
   ADD UNIQUE KEY `name` (`name`);
 
 
-ALTER TABLE `Filter_list`
+ALTER TABLE `filter_list`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD KEY `Name` (`name`);
   ADD KEY `Name` (`name`);
 
 
 ALTER TABLE `gateway_subnets`
 ALTER TABLE `gateway_subnets`
   ADD PRIMARY KEY (`id`);
   ADD PRIMARY KEY (`id`);
 
 
-ALTER TABLE `Group_filters`
+ALTER TABLE `group_filters`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD KEY `GroupId` (`group_id`,`filter_id`);
   ADD KEY `GroupId` (`group_id`,`filter_id`);
 
 
-ALTER TABLE `Group_list`
+ALTER TABLE `group_list`
   ADD PRIMARY KEY (`id`);
   ADD PRIMARY KEY (`id`);
 
 
 ALTER TABLE `mac_history`
 ALTER TABLE `mac_history`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `mac` (`mac`,`timestamp`),
-  ADD KEY `ip` (`ip`,`timestamp`),
-  ADD KEY `timestamp` (`timestamp`) USING BTREE,
+  ADD KEY `mac` (`mac`,`ts`),
+  ADD KEY `ip` (`ip`,`ts`),
+  ADD KEY `ts` (`ts`) USING BTREE,
   ADD KEY `mac_2` (`mac`),
   ADD KEY `mac_2` (`mac`),
   ADD KEY `ip_2` (`ip`);
   ADD KEY `ip_2` (`ip`);
 
 
@@ -586,7 +586,7 @@ ALTER TABLE `OU`
 ALTER TABLE `OU` ADD FULLTEXT KEY `ou_name` (`ou_name`);
 ALTER TABLE `OU` ADD FULLTEXT KEY `ou_name` (`ou_name`);
 ALTER TABLE `OU` ADD FULLTEXT KEY `ou_name_2` (`ou_name`);
 ALTER TABLE `OU` ADD FULLTEXT KEY `ou_name_2` (`ou_name`);
 
 
-ALTER TABLE `Queue_list`
+ALTER TABLE `queue_list`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD UNIQUE KEY `id` (`id`);
   ADD UNIQUE KEY `id` (`id`);
 
 
@@ -603,26 +603,26 @@ ALTER TABLE `subnets`
   ADD KEY `ip_int_start` (`ip_int_start`,`ip_int_stop`),
   ADD KEY `ip_int_start` (`ip_int_start`,`ip_int_stop`),
   ADD KEY `dhcp` (`dhcp`,`office`,`hotspot`,`static`);
   ADD KEY `dhcp` (`dhcp`,`office`,`hotspot`,`static`);
 
 
-ALTER TABLE `Traffic_detail`
+ALTER TABLE `traffic_detail`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `src` (`auth_id`,`timestamp`,`router_id`,`src_ip`) USING BTREE,
-  ADD KEY `dst` (`auth_id`,`timestamp`,`router_id`,`dst_ip`) USING BTREE;
+  ADD KEY `src` (`auth_id`,`ts`,`router_id`,`src_ip`) USING BTREE,
+  ADD KEY `dst` (`auth_id`,`ts`,`router_id`,`dst_ip`) USING BTREE;
 
 
-ALTER TABLE `Unknown_mac`
+ALTER TABLE `unknown_mac`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`device_id`,`port_id`,`mac`);
+  ADD KEY `ts` (`ts`,`device_id`,`port_id`,`mac`);
 
 
-ALTER TABLE `User_auth`
+ALTER TABLE `user_auth`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD KEY `auth_index` (`id`,`user_id`,`ip_int`,`mac`,`ip`,`deleted`) USING BTREE,
   ADD KEY `auth_index` (`id`,`user_id`,`ip_int`,`mac`,`ip`,`deleted`) USING BTREE,
   ADD KEY `deleted` (`deleted`),
   ADD KEY `deleted` (`deleted`),
   ADD KEY `ou_id` (`ou_id`);
   ADD KEY `ou_id` (`ou_id`);
 
 
-ALTER TABLE `User_auth_alias`
+ALTER TABLE `user_auth_alias`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD KEY `auth_id` (`auth_id`);
   ADD KEY `auth_id` (`auth_id`);
 
 
-ALTER TABLE `User_list`
+ALTER TABLE `user_list`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD KEY `users` (`id`,`ou_id`,`enabled`,`blocked`,`deleted`);
   ADD KEY `users` (`id`,`ou_id`,`enabled`,`blocked`,`deleted`);
 
 
@@ -632,13 +632,13 @@ ALTER TABLE `user_sessions`
   ADD KEY `user_id` (`user_id`),
   ADD KEY `user_id` (`user_id`),
   ADD KEY `is_active` (`is_active`);
   ADD KEY `is_active` (`is_active`);
 
 
-ALTER TABLE `User_stats`
+ALTER TABLE `user_stats`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`auth_id`,`router_id`);
+  ADD KEY `ts` (`ts`,`auth_id`,`router_id`);
 
 
-ALTER TABLE `User_stats_full`
+ALTER TABLE `user_stats_full`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`auth_id`,`router_id`);
+  ADD KEY `ts` (`ts`,`auth_id`,`router_id`);
 
 
 ALTER TABLE `variables`
 ALTER TABLE `variables`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
@@ -651,16 +651,16 @@ ALTER TABLE `vendors`
 ALTER TABLE `version`
 ALTER TABLE `version`
   ADD UNIQUE KEY `id` (`id`);
   ADD UNIQUE KEY `id` (`id`);
 
 
-ALTER TABLE `Wan_stats`
+ALTER TABLE `wan_stats`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
   ADD UNIQUE KEY `main` (`time`,`router_id`,`interface_id`),
   ADD UNIQUE KEY `main` (`time`,`router_id`,`interface_id`),
   ADD KEY `times` (`time`);
   ADD KEY `times` (`time`);
 
 
 ALTER TABLE `worklog`
 ALTER TABLE `worklog`
   ADD PRIMARY KEY (`id`),
   ADD PRIMARY KEY (`id`),
-  ADD KEY `idx_customer` (`customer`,`level`,`timestamp`),
-  ADD KEY `idx_timestamp` (`level`,`timestamp`),
-  ADD KEY `idx_auth_id` (`auth_id`,`level`,`timestamp`);
+  ADD KEY `idx_customer` (`customer`,`level`,`ts`),
+  ADD KEY `idx_timestamp` (`level`,`ts`),
+  ADD KEY `idx_auth_id` (`auth_id`,`level`,`ts`);
 
 
 
 
 ALTER TABLE `acl`
 ALTER TABLE `acl`
@@ -684,7 +684,7 @@ ALTER TABLE `config_options`
 ALTER TABLE `connections`
 ALTER TABLE `connections`
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Customers`
+ALTER TABLE `customers`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `devices`
 ALTER TABLE `devices`
@@ -720,16 +720,16 @@ ALTER TABLE `dns_queue`
 ALTER TABLE `filter_instances`
 ALTER TABLE `filter_instances`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Filter_list`
+ALTER TABLE `filter_list`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `gateway_subnets`
 ALTER TABLE `gateway_subnets`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Group_filters`
+ALTER TABLE `group_filters`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Group_list`
+ALTER TABLE `group_list`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `mac_history`
 ALTER TABLE `mac_history`
@@ -741,7 +741,7 @@ ALTER TABLE `mac_vendors`
 ALTER TABLE `OU`
 ALTER TABLE `OU`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Queue_list`
+ALTER TABLE `queue_list`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `remote_syslog`
 ALTER TABLE `remote_syslog`
@@ -750,28 +750,28 @@ ALTER TABLE `remote_syslog`
 ALTER TABLE `subnets`
 ALTER TABLE `subnets`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Traffic_detail`
+ALTER TABLE `traffic_detail`
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Unknown_mac`
+ALTER TABLE `unknown_mac`
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `User_auth`
+ALTER TABLE `user_auth`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `User_auth_alias`
+ALTER TABLE `user_auth_alias`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `User_list`
+ALTER TABLE `user_list`
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `user_sessions`
 ALTER TABLE `user_sessions`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `User_stats`
+ALTER TABLE `user_stats`
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `User_stats_full`
+ALTER TABLE `user_stats_full`
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
   MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `variables`
 ALTER TABLE `variables`
@@ -780,7 +780,7 @@ ALTER TABLE `variables`
 ALTER TABLE `vendors`
 ALTER TABLE `vendors`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
-ALTER TABLE `Wan_stats`
+ALTER TABLE `wan_stats`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 
 ALTER TABLE `worklog`
 ALTER TABLE `worklog`

+ 121 - 121
docs/databases/mysql/ru/data.sql

@@ -6,66 +6,66 @@ SET time_zone = "+00:00";
 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 /*!40101 SET NAMES utf8mb4 */;
 /*!40101 SET NAMES utf8mb4 */;
 
 
-INSERT INTO `acl` (`id`, `name`, `description.english`, `description.russian`) VALUES(1, 'Full access', 'Full access', 'Полный доступ');
-INSERT INTO `acl` (`id`, `name`, `description.english`, `description.russian`) VALUES(2, 'Operator', 'Editing parameters that are not related to access rights', 'Редактирование параметров, не связанных с правами доступа');
-INSERT INTO `acl` (`id`, `name`, `description.english`, `description.russian`) VALUES(3, 'View only', 'View only', 'Только просмотр');
+INSERT INTO `acl` (`id`, `name`, description_english, description_russian) VALUES(1, 'Full access', 'Full access', 'Полный доступ');
+INSERT INTO `acl` (`id`, `name`, description_english, description_russian) VALUES(2, 'Operator', 'Editing parameters that are not related to access rights', 'Редактирование параметров, не связанных с правами доступа');
+INSERT INTO `acl` (`id`, `name`, description_english, description_russian) VALUES(3, 'View only', 'View only', 'Только просмотр');
 
 
 INSERT INTO `building` (`id`, `name`, `comment`) VALUES(1, 'Earth', 'Somewhere');
 INSERT INTO `building` (`id`, `name`, `comment`) VALUES(1, 'Earth', 'Somewhere');
 
 
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(1, 'KB', 'Еденица измерения трафика - Килобайт (0) или кибибайт (1,default)', 'Traffic measurement unit - Kilobyte (1000b) or kibibyte (1024b,default)', 0, 1, 'bool', '1024', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(3, 'dns server', 'ip-адрес DNS-сервера', 'DNS server ip address', 0, 1, 'text', '127.0.0.1', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(5, 'dhcp server', 'ip-адрес DHCP-сервера', 'ip address of the DHCP server', 0, 1, 'text', '127.0.0.1', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(9, 'default snmp version', 'Версия snmp по умолчанию. В настоящий момент поддерживаются 1 и 2. Поддержка версии 3 в разработке.', 'The default version of snmp. Currently, 1 and 2 are supported. Support for version 3 is in development.', 0, 1, 'int', '2', 1, 3);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(11, 'default snmp community', 'Read snmp community по умолчанию', 'Read snmp community by default', 0, 1, 'text', 'public', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(21, 'admin email', 'E-mail администратора', 'Administrator e-mail', 0, 1, 'text', 'root', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(22, 'add user from netflow', 'Создавать ли новые записи для неизвестных адресов из анализа трафика netflow. Не включать, если netflow снимает данные с маршрутизатора локальной сети', 'Whether to create new records for unknown addresses from netflow traffic analysis. Do not enable if netflow get data from the local network router', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(23, 'save traffic detail', 'Сохранять ли детализацию трафика из netflow по ip-адресам пользователей', 'Whether to keep the details of traffic from netflow by ip addresses of users', 0, 1, 'bool', '1', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(26, 'history detail traffic', 'Глубина хранения детализации в сутках. Установка значения больше 3-7 дней приведёт к разрастанию базы данных и увеличит время отображения детализации в интерфейсе администратора', 'Depth of detail storage in days. Setting a value greater than 3-7 days will cause the database to grow and increase the time about to display details in the admin interface', 0, 1, 'int', '3', 1, 7);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(27, 'history dhcp lease', 'Глубина хранения аренды dhcp-сервера', 'Storage depth of the dhcp server lease', 0, 1, 'int', '1', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(28, 'router_login', 'Логин для входа на сетевые устройства по умолчанию', 'Default login for network devices', 0, 1, 'text', 'admin', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(29, 'router_password', 'Пароль по умолчанию на сетевые устройства', 'Default password for network devices', 0, 1, 'text', 'admin', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(30, 'router_ssh_port', 'Порт ssh по умолчанию', 'SSH default port', 0, 1, 'int', '22', 22, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(32, 'org name', 'Название организации', 'Organization name', 0, 1, 'text', 'ORG', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(33, 'office domain', 'Домен организации', 'Organization domain', 0, 1, 'text', 'local', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(34, 'debug', 'Включить отладку', 'Enable debugging', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(35, 'connections history, days', 'Время хранения истории мест подключения ip-адресов', 'Storage time of the history of connection locations of ip addresses', 0, 1, 'int', '90', 1, 365);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(37, 'refresh access lists', 'Расположение скрипта управления контролем доступа для роутеров Mikrotik', 'Location of the access control script for Mikrotik routers', 0, 1, 'text', '/opt/Eye/scripts/sync_mikrotik.pl', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(38, 'regenerate dhcp cconfig', 'Расположение скрипта управления конфигурацией dhcp-серверами', 'Location of the dhcp server configuration management script', 0, 1, 'text', '/opt/Eye/scripts/update-dnsmasq', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(39, 'regenerate dns cconfig', 'Расположение скрипта управления dns-сервером', 'Location of the dns server management script', 0, 1, 'text', '/opt/Eye/scripts/update-dns', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(40, 'regenerate nagios cconfig', 'Расположение скрипта конфигурирования Nagios', 'Location of the Nagios configuration script', 0, 1, 'text', '/etc/nagios/restart_nagios', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(41, 'discovery network', 'Расположение скрипта сканирования сети', 'Location of the network scan script', 0, 1, 'text', '/opt/Eye/scripts/fetch_new_arp.pl', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(44, 'Ignore hotspot dhcp log', 'Не писать лог событий dhcp-сервера хотспота. Имеет смысл вклчючать, поскольку время аренды в хот-споте как правило маленькое и в записях хот-спота становятся незаметны логи обычных пользователей', 'Do not write the event log of the hotspot dhcp server. It makes sense to include it, since the rental time in the hotspot is usually small and the logs of ordinary users become invisible in the hotspot records', 0, 1, 'bool', '1', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(45, 'ignore update dhcp event', 'Не писать события обновления ip-адреса dhcp-сервера. ', 'Do not write events for updating the IP address of the dhcp server. ', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(46, 'update hostname from dhcp', 'Обновлять имя хоста в DNS при получении адреса по DHCP', 'Update the hostname in DNS when receiving the address via DHCP', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(47, 'history worklog', 'Глубина хранения VERBOSE логов работы в интерфейсе администратора', 'Depth of work VERBOSE logs storage in the admin interface', 0, 1, 'int', '90', 0, 1095);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(48, 'history syslog', 'Глубина хранения логов работы syslog-сервера', 'Syslog server logs storage depth', 0, 1, 'int', '90', 0, 1095);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(49, 'history traffic stats', 'Глубина хранения статистики трафика юзеров', 'User traffic statistics storage depth', 0, 1, 'int', '365', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(50, 'urgent sync access', 'Немедленное изменение списков доступа на роутере после правки записи пользователя', 'Immediate change of access lists on the router after editing the user record ', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(51, 'Email_alert', 'Отправлять e-mail уведомления', 'Send e-mail notifications', 0, 1, 'bool', '1', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(52, 'Sender email', 'E-mail адрес, с которого рассылается почта', 'E-mail address from which mail is sent', 0, 1, 'text', 'root', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(53, 'log level', 'Каждый уровень включает в себя предыдущий:\r\n0 - ERROR - писать только ошибки\r\n1 - WARNING - писать предупреждения\r\n2 - INFO - писать информационные сообщения\r\n3 - VERBOSE - писать подробную информацию о выполняемых операциях', 'Each level includes the previous one:\r\n0 - ERROR - write only errors\r\n1 - WARNING - write warnings\r\n2 - INFO - write informational\r\n3 - VERBOSE - write detailed information about the operations performed ', 0, 1, 'int', '2', 0, 3);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(54, 'enable_quotes', 'Включить обработку квот по трафику', 'Enable traffic quota processing', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(55, 'netflow_step', 'Интервал сброса данных из коллектора netflow, минуты', 'Data reset interval from netflow collector, minutes', 0, 1, 'int', '1', 1, 10);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(56, 'traffic_ipstat_history', 'Время хранения полной статистики по трафику для каждого ip-адреса в сутках. Таблица в 6 раз больше обычной часовой статистики. Врядли кому-то потребуется глубина хранения более месяца.', 'The storage time of complete traffic statistics for each ip address in days. The table is 6 times larger than the usual hourly statistic Hardly anyone will need a storage depth of more than a month.', 0, 1, 'int', '30', 0, 365);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(57, 'nagios_url', 'Адрес сайта nagios', 'nagios site address', 0, 1, 'text', 'http://127.0.0.1/nagios', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(58, 'cacti_url', 'Адрес сайта cacti', 'cacti site address', 0, 1, 'text', 'http://127.0.0.1/cacti', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(59, 'torrus_url', 'Адрес сайта Torrus', 'Torrus website address', 0, 1, 'text', 'http://127.0.0.1/torrus/CollectorName/', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(60, 'wiki_url', 'Адрес wiki', 'Wiki website address', 0, 1, 'text', 'http://127.0.0.1/wiki', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(61, 'wiki_path', 'Путь к каталогу данных вики', 'Path to wiki data directory', 0, 1, 'text', '/var/www/foswiki/data/', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(62, 'stat_url', 'Адрес этого сайта', 'Address of this site', 0, 1, 'text', 'http://127.0.0.1/stat', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(63, 'wiki_web', 'Web for Wiki. Default - Main. http://example.local/Main/WebHome', 'Web for Wiki. Default - Main. http://example.local/Main/WebHome', 0, 1, 'text', 'Main', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(64, 'auto_mac_rule', 'Создавать автоматическую привязку мак-адреса к юзеру. Т.е. все ip-адреса для найденного мака будут привязываться к одном и тому же юзеру.', 'Create an automatic binding of the mac address to the user. I.e. all ip addresses for the found mac will be bound to the same user.', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(65, 'mikrotik_command_interface', 'Используемый способ конфигурирования (0 - cli для ROS 6, 1 - rest api для ROS 7)', 'Configuration method used (0 - cli for ROS 6, 1 - rest api for ROS 7)', 1, 1, 'int', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(66, 'mikrotik_rest_api_ssl', 'Использовать https для rest api', 'Use HTTPS for rest api', 1, 1, 'bool', '1', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(67, 'mikrotik_rest_api_port', 'Порт вэб-интерфейса для rest api', 'Web interface port for rest API', 1, 1, 'int', '443', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(68, 'config_mode', 'Режим конфигурирования. Скрипт опроса устройств не выполняется.', 'Configuration mode. The device polling script is not running.', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(69, 'clean_empty_user', 'Автоматически удалять записи пользователей, не содержащие ip-адресов или автоматических привязок', 'Automatically delete user records that do not contain IP addresses or automatic bindings', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(70, 'dns_server_type', 'Тип используемого dns-сервера: Windows, Bind. Если используется локальный dnsmasq - параметры dns-сервера указывать не надо.', 'The type of dns server used: Windows, Bind. If you are using a local dnsmasq, you do not need to specify the dns server parameters.', 0, 1, 'list;windows;bind', 'bind', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(71, 'enable_dns_updates', 'Включить обновления DNS имен при изменении dns-имени в ip-записи', 'Enable DNS name updates when dns name changes in an ip record', 0, 1, 'bool', '0', 0, 1);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(72, 'netflow_path', 'Каталог для хранения данных, полученных по netflow от маршрутизаторов', 'The directory for storing data received via netflow from routers', 0, 1, 'text', '/opt/Eye/netflow', 0, 0);
-INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(73, 'check_computer_exists', 'Проверять существование компьютера в домене перед обновлением DNS по DHCP запросу', 'Verify the existence of a computer in the domain before updating DNS by DHCP request', 0, 1, 'bool', '1', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(1, 'KB', 'Еденица измерения трафика - Килобайт (0) или кибибайт (1,default)', 'Traffic measurement unit - Kilobyte (1000b) or kibibyte (1024b,default)', 0, 1, 'bool', '1024', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(3, 'dns server', 'ip-адрес DNS-сервера', 'DNS server ip address', 0, 1, 'text', '127.0.0.1', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(5, 'dhcp server', 'ip-адрес DHCP-сервера', 'ip address of the DHCP server', 0, 1, 'text', '127.0.0.1', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(9, 'default snmp version', 'Версия snmp по умолчанию. В настоящий момент поддерживаются 1 и 2. Поддержка версии 3 в разработке.', 'The default version of snmp. Currently, 1 and 2 are supported. Support for version 3 is in development.', 0, 1, 'int', '2', 1, 3);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(11, 'default snmp community', 'Read snmp community по умолчанию', 'Read snmp community by default', 0, 1, 'text', 'public', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(21, 'admin email', 'E-mail администратора', 'Administrator e-mail', 0, 1, 'text', 'root', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(22, 'add user from netflow', 'Создавать ли новые записи для неизвестных адресов из анализа трафика netflow. Не включать, если netflow снимает данные с маршрутизатора локальной сети', 'Whether to create new records for unknown addresses from netflow traffic analysis. Do not enable if netflow get data from the local network router', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(23, 'save traffic detail', 'Сохранять ли детализацию трафика из netflow по ip-адресам пользователей', 'Whether to keep the details of traffic from netflow by ip addresses of users', 0, 1, 'bool', '1', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(26, 'history detail traffic', 'Глубина хранения детализации в сутках. Установка значения больше 3-7 дней приведёт к разрастанию базы данных и увеличит время отображения детализации в интерфейсе администратора', 'Depth of detail storage in days. Setting a value greater than 3-7 days will cause the database to grow and increase the time about to display details in the admin interface', 0, 1, 'int', '3', 1, 7);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(27, 'history dhcp lease', 'Глубина хранения аренды dhcp-сервера', 'Storage depth of the dhcp server lease', 0, 1, 'int', '1', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(28, 'router_login', 'Логин для входа на сетевые устройства по умолчанию', 'Default login for network devices', 0, 1, 'text', 'admin', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(29, 'router_password', 'Пароль по умолчанию на сетевые устройства', 'Default password for network devices', 0, 1, 'text', 'admin', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(30, 'router_ssh_port', 'Порт ssh по умолчанию', 'SSH default port', 0, 1, 'int', '22', 22, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(32, 'org name', 'Название организации', 'Organization name', 0, 1, 'text', 'ORG', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(33, 'office domain', 'Домен организации', 'Organization domain', 0, 1, 'text', 'local', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(34, 'debug', 'Включить отладку', 'Enable debugging', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(35, 'connections history, days', 'Время хранения истории мест подключения ip-адресов', 'Storage time of the history of connection locations of ip addresses', 0, 1, 'int', '90', 1, 365);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(37, 'refresh access lists', 'Расположение скрипта управления контролем доступа для роутеров Mikrotik', 'Location of the access control script for Mikrotik routers', 0, 1, 'text', '/opt/Eye/scripts/sync_mikrotik.pl', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(38, 'regenerate dhcp cconfig', 'Расположение скрипта управления конфигурацией dhcp-серверами', 'Location of the dhcp server configuration management script', 0, 1, 'text', '/opt/Eye/scripts/update-dnsmasq', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(39, 'regenerate dns cconfig', 'Расположение скрипта управления dns-сервером', 'Location of the dns server management script', 0, 1, 'text', '/opt/Eye/scripts/update-dns', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(40, 'regenerate nagios cconfig', 'Расположение скрипта конфигурирования Nagios', 'Location of the Nagios configuration script', 0, 1, 'text', '/etc/nagios/restart_nagios', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(41, 'discovery network', 'Расположение скрипта сканирования сети', 'Location of the network scan script', 0, 1, 'text', '/opt/Eye/scripts/fetch_new_arp.pl', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(44, 'Ignore hotspot dhcp log', 'Не писать лог событий dhcp-сервера хотспота. Имеет смысл вклчючать, поскольку время аренды в хот-споте как правило маленькое и в записях хот-спота становятся незаметны логи обычных пользователей', 'Do not write the event log of the hotspot dhcp server. It makes sense to include it, since the rental time in the hotspot is usually small and the logs of ordinary users become invisible in the hotspot records', 0, 1, 'bool', '1', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(45, 'ignore update dhcp event', 'Не писать события обновления ip-адреса dhcp-сервера. ', 'Do not write events for updating the IP address of the dhcp server. ', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(46, 'update hostname from dhcp', 'Обновлять имя хоста в DNS при получении адреса по DHCP', 'Update the hostname in DNS when receiving the address via DHCP', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(47, 'history worklog', 'Глубина хранения VERBOSE логов работы в интерфейсе администратора', 'Depth of work VERBOSE logs storage in the admin interface', 0, 1, 'int', '90', 0, 1095);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(48, 'history syslog', 'Глубина хранения логов работы syslog-сервера', 'Syslog server logs storage depth', 0, 1, 'int', '90', 0, 1095);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(49, 'history traffic stats', 'Глубина хранения статистики трафика юзеров', 'User traffic statistics storage depth', 0, 1, 'int', '365', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(50, 'urgent sync access', 'Немедленное изменение списков доступа на роутере после правки записи пользователя', 'Immediate change of access lists on the router after editing the user record ', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(51, 'Email_alert', 'Отправлять e-mail уведомления', 'Send e-mail notifications', 0, 1, 'bool', '1', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(52, 'Sender email', 'E-mail адрес, с которого рассылается почта', 'E-mail address from which mail is sent', 0, 1, 'text', 'root', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(53, 'log level', 'Каждый уровень включает в себя предыдущий:\r\n0 - ERROR - писать только ошибки\r\n1 - WARNING - писать предупреждения\r\n2 - INFO - писать информационные сообщения\r\n3 - VERBOSE - писать подробную информацию о выполняемых операциях', 'Each level includes the previous one:\r\n0 - ERROR - write only errors\r\n1 - WARNING - write warnings\r\n2 - INFO - write informational\r\n3 - VERBOSE - write detailed information about the operations performed ', 0, 1, 'int', '2', 0, 3);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(54, 'enable_quotes', 'Включить обработку квот по трафику', 'Enable traffic quota processing', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(55, 'netflow_step', 'Интервал сброса данных из коллектора netflow, минуты', 'Data reset interval from netflow collector, minutes', 0, 1, 'int', '1', 1, 10);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(56, 'traffic_ipstat_history', 'Время хранения полной статистики по трафику для каждого ip-адреса в сутках. Таблица в 6 раз больше обычной часовой статистики. Врядли кому-то потребуется глубина хранения более месяца.', 'The storage time of complete traffic statistics for each ip address in days. The table is 6 times larger than the usual hourly statistic Hardly anyone will need a storage depth of more than a month.', 0, 1, 'int', '30', 0, 365);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(57, 'nagios_url', 'Адрес сайта nagios', 'nagios site address', 0, 1, 'text', 'http://127.0.0.1/nagios', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(58, 'cacti_url', 'Адрес сайта cacti', 'cacti site address', 0, 1, 'text', 'http://127.0.0.1/cacti', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(59, 'torrus_url', 'Адрес сайта Torrus', 'Torrus website address', 0, 1, 'text', 'http://127.0.0.1/torrus/CollectorName/', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(60, 'wiki_url', 'Адрес wiki', 'Wiki website address', 0, 1, 'text', 'http://127.0.0.1/wiki', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(61, 'wiki_path', 'Путь к каталогу данных вики', 'Path to wiki data directory', 0, 1, 'text', '/var/www/foswiki/data/', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(62, 'stat_url', 'Адрес этого сайта', 'Address of this site', 0, 1, 'text', 'http://127.0.0.1/stat', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(63, 'wiki_web', 'Web for Wiki. Default - Main. http://example.local/Main/WebHome', 'Web for Wiki. Default - Main. http://example.local/Main/WebHome', 0, 1, 'text', 'Main', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(64, 'auto_mac_rule', 'Создавать автоматическую привязку мак-адреса к юзеру. Т.е. все ip-адреса для найденного мака будут привязываться к одном и тому же юзеру.', 'Create an automatic binding of the mac address to the user. I.e. all ip addresses for the found mac will be bound to the same user.', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(65, 'mikrotik_command_interface', 'Используемый способ конфигурирования (0 - cli для ROS 6, 1 - rest api для ROS 7)', 'Configuration method used (0 - cli for ROS 6, 1 - rest api for ROS 7)', 1, 1, 'int', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(66, 'mikrotik_rest_api_ssl', 'Использовать https для rest api', 'Use HTTPS for rest api', 1, 1, 'bool', '1', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(67, 'mikrotik_rest_api_port', 'Порт вэб-интерфейса для rest api', 'Web interface port for rest API', 1, 1, 'int', '443', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(68, 'config_mode', 'Режим конфигурирования. Скрипт опроса устройств не выполняется.', 'Configuration mode. The device polling script is not running.', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(69, 'clean_empty_user', 'Автоматически удалять записи пользователей, не содержащие ip-адресов или автоматических привязок', 'Automatically delete user records that do not contain IP addresses or automatic bindings', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(70, 'dns_server_type', 'Тип используемого dns-сервера: Windows, Bind. Если используется локальный dnsmasq - параметры dns-сервера указывать не надо.', 'The type of dns server used: Windows, Bind. If you are using a local dnsmasq, you do not need to specify the dns server parameters.', 0, 1, 'list;windows;bind', 'bind', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(71, 'enable_dns_updates', 'Включить обновления DNS имен при изменении dns-имени в ip-записи', 'Enable DNS name updates when dns name changes in an ip record', 0, 1, 'bool', '0', 0, 1);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(72, 'netflow_path', 'Каталог для хранения данных, полученных по netflow от маршрутизаторов', 'The directory for storing data received via netflow from routers', 0, 1, 'text', '/opt/Eye/netflow', 0, 0);
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES(73, 'check_computer_exists', 'Проверять существование компьютера в домене перед обновлением DNS по DHCP запросу', 'Verify the existence of a computer in the domain before updating DNS by DHCP request', 0, 1, 'bool', '1', 0, 0);
 
 
-INSERT INTO `Customers` (`id`, `Login`, `comment`, `password`, `api_key`,`rights`) VALUES (1, 'admin', 'Administrator', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31','1') ON DUPLICATE KEY UPDATE `Login`="admin", `password`="$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG", `rights`="1";
+INSERT INTO `customers` (`id`, `Login`, `comment`, `password`, `api_key`,`rights`) VALUES (1, 'admin', 'Administrator', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31','1') ON DUPLICATE KEY UPDATE `Login`="admin", `password`="$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG", `rights`="1";
 
 
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(1, '2011LS', 9, 1, 0, NULL);
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(1, '2011LS', 9, 1, 0, NULL);
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(2, '2011UAS-2HnD', 9, 1, 0, NULL);
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(2, '2011UAS-2HnD', 9, 1, 0, NULL);
@@ -183,18 +183,18 @@ INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(116, 'SNR-S5210X-8F-UPS', 6, 0, 0, NULL);
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(116, 'SNR-S5210X-8F-UPS', 6, 0, 0, NULL);
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(117, 'SNR-S2982G-8T-UPS', 6, 0, 0, NULL);
 INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(117, 'SNR-S2982G-8T-UPS', 6, 0, 0, NULL);
 
 
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(0, 'Роутер', 'Router');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(1, 'Свич', 'Switch');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(2, 'Шлюз', 'Gateway');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(3, 'Сервер', 'Server');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(4, 'Точка доступа', 'WiFi Access Point');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(5, 'Сетевое устройство', 'Network device');
+INSERT INTO `device_types` (`id`, name_russian, name_english) VALUES(0, 'Роутер', 'Router');
+INSERT INTO `device_types` (`id`, name_russian, name_english) VALUES(1, 'Свич', 'Switch');
+INSERT INTO `device_types` (`id`, name_russian, name_english) VALUES(2, 'Шлюз', 'Gateway');
+INSERT INTO `device_types` (`id`, name_russian, name_english) VALUES(3, 'Сервер', 'Server');
+INSERT INTO `device_types` (`id`, name_russian, name_english) VALUES(4, 'Точка доступа', 'WiFi Access Point');
+INSERT INTO `device_types` (`id`, name_russian, name_english) VALUES(5, 'Сетевое устройство', 'Network device');
 
 
 INSERT INTO `filter_instances` (`id`, `name`, `comment`) VALUES(1, 'default', NULL);
 INSERT INTO `filter_instances` (`id`, `name`, `comment`) VALUES(1, 'default', NULL);
 
 
-INSERT INTO `Group_list` (`id`, `instance_id`, `group_name`, `comment`) VALUES(0, 1, 'default', 'Всё запрещено');
-INSERT INTO `Group_list` (`id`, `instance_id`, `group_name`, `comment`) VALUES(1, 1, 'Allow all', 'Разрешено всё');
-INSERT INTO `Group_list` (`id`, `instance_id`, `group_name`, `comment`) VALUES(2, 1, 'Users','Для пользователей');
+INSERT INTO `group_list` (`id`, `instance_id`, `group_name`, `comment`) VALUES(0, 1, 'default', 'Всё запрещено');
+INSERT INTO `group_list` (`id`, `instance_id`, `group_name`, `comment`) VALUES(1, 1, 'Allow all', 'Разрешено всё');
+INSERT INTO `group_list` (`id`, `instance_id`, `group_name`, `comment`) VALUES(2, 1, 'Users','Для пользователей');
 
 
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(0, '!Всё', NULL, 0, 0, '/etc/nagios/any', 'generic-host', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(0, '!Всё', NULL, 0, 0, '/etc/nagios/any', 'generic-host', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(1, 'Сервера', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 0, 0, '24.00', NULL);
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(1, 'Сервера', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 0, 0, '24.00', NULL);
@@ -211,15 +211,15 @@ INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(12, 'DHCP', NULL, 1, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, '24.00', NULL);
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(12, 'DHCP', NULL, 1, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, '24.00', NULL);
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(13, 'Гости', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4, 1, '24.00', NULL);
 INSERT INTO `OU` (`id`, `ou_name`, `comment`, `default_users`, `default_hotspot`, `nagios_dir`, `nagios_host_use`, `nagios_ping`, `nagios_default_service`, `enabled`, `filter_group_id`, `queue_id`, `dynamic`, `life_duration`, `parent_id`) VALUES(13, 'Гости', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4, 1, '24.00', NULL);
 
 
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(0, 'unlimited', 0, 0);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(1, '2M/2M', 2048, 2048);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(2, '10M/10M', 10240, 10240);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(3, '100M/100M', 102400, 102400);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(4, '50M/50M', 50000, 50000);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(5, '20M/20M', 20480, 20480);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(6, '200M/200M', 212400, 212400);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(7, '1G/1G', 1024000, 1024000);
-INSERT INTO `Queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(8, '2G/2G', 2048000, 2048000);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(0, 'unlimited', 0, 0);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(1, '2M/2M', 2048, 2048);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(2, '10M/10M', 10240, 10240);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(3, '100M/100M', 102400, 102400);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(4, '50M/50M', 50000, 50000);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(5, '20M/20M', 20480, 20480);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(6, '200M/200M', 212400, 212400);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(7, '1G/1G', 1024000, 1024000);
+INSERT INTO `queue_list` (`id`, `queue_name`, `Download`, `Upload`) VALUES(8, '2G/2G', 2048000, 2048000);
 
 
 INSERT INTO `subnets` (`id`, `subnet`, `vlan_tag`, `ip_int_start`, `ip_int_stop`, `dhcp_start`, `dhcp_stop`, `dhcp_lease_time`, `gateway`, `office`, `hotspot`, `vpn`, `free`, `dhcp`, `static`, `dhcp_update_hostname`, `discovery`, `notify`, `comment`) VALUES(1, '192.168.2.0/24', 2, 3232236032, 3232236287, 3232236132, 3232236182, 480, 3232236033, 1, 0, 0, 0, 1, 0, 1, 1, 7, 'LAN');
 INSERT INTO `subnets` (`id`, `subnet`, `vlan_tag`, `ip_int_start`, `ip_int_stop`, `dhcp_start`, `dhcp_stop`, `dhcp_lease_time`, `gateway`, `office`, `hotspot`, `vpn`, `free`, `dhcp`, `static`, `dhcp_update_hostname`, `discovery`, `notify`, `comment`) VALUES(1, '192.168.2.0/24', 2, 3232236032, 3232236287, 3232236132, 3232236182, 480, 3232236033, 1, 0, 0, 0, 1, 0, 1, 1, 7, 'LAN');
 
 
@@ -279,54 +279,54 @@ INSERT INTO `vendors` (`id`, `name`) VALUES(67, 'Testo');
 INSERT INTO `vendors` (`id`, `name`) VALUES(68, 'Hw-group');
 INSERT INTO `vendors` (`id`, `name`) VALUES(68, 'Hw-group');
 INSERT INTO `vendors` (`id`, `name`) VALUES(69, 'Tp-link');
 INSERT INTO `vendors` (`id`, `name`) VALUES(69, 'Tp-link');
 
 
-INSERT INTO `Filter_list` VALUES (1,'pop3',NULL,'tcp','0/0','110',NULL,0);
-INSERT INTO `Filter_list` VALUES (3,'http',NULL,'tcp','0/0','80',NULL,0);
-INSERT INTO `Filter_list` VALUES (4,'https',NULL,'tcp','0/0','443',NULL,0);
-INSERT INTO `Filter_list` VALUES (5,'icq',NULL,'tcp','0/0','5190',NULL,0);
-INSERT INTO `Filter_list` VALUES (6,'jabber',NULL,'tcp','0/0','5222',NULL,0);
-INSERT INTO `Filter_list` VALUES (9,'allow_all','любой трафик','all','0/0','0','0',0);
-INSERT INTO `Filter_list` VALUES (10,'icmp',NULL,'icmp','0/0','0',NULL,0);
-INSERT INTO `Filter_list` VALUES (11,'ftp',NULL,'tcp','0/0','20-21',NULL,0);
-INSERT INTO `Filter_list` VALUES (15,'telnet',NULL,'tcp','0/0','23',NULL,0);
-INSERT INTO `Filter_list` VALUES (16,'ssh',NULL,'tcp','0/0','22',NULL,0);
-INSERT INTO `Filter_list` VALUES (28,'smtp',NULL,'tcp','0/0','25',NULL,0);
-INSERT INTO `Filter_list` VALUES (32,'rdp',NULL,'tcp','0/0','3389',NULL,0);
-INSERT INTO `Filter_list` VALUES (40,'ntp',NULL,'udp','0/0','123',NULL,0);
-INSERT INTO `Filter_list` VALUES (44,'vnc',NULL,'tcp','0/0','5800-5900',NULL,0);
-INSERT INTO `Filter_list` VALUES (55,'unprivileged tcp',NULL,'tcp','0/0','1024-65500',NULL,0);
-INSERT INTO `Filter_list` VALUES (76,'ipsec',NULL,'udp','0/0','500',NULL,0);
-INSERT INTO `Filter_list` VALUES (77,'isakmp',NULL,'udp','0/0','4500',NULL,0);
-INSERT INTO `Filter_list` VALUES (79,'pop3s',NULL,'tcp','0/0','995',NULL,0);
-INSERT INTO `Filter_list` VALUES (80,'smtps',NULL,'tcp','0/0','465,587',NULL,0);
-INSERT INTO `Filter_list` VALUES (81,'imap',NULL,'tcp','0/0','143',NULL,0);
-INSERT INTO `Filter_list` VALUES (82,'imaps',NULL,'tcp','0/0','993',NULL,0);
-INSERT INTO `Filter_list` VALUES (83,'unprivileged udp',NULL,'udp','0/0','1024-65000',NULL,0);
-INSERT INTO `Filter_list` VALUES (84,'pptp',NULL,'tcp','0/0','1723',NULL,0);
-INSERT INTO `Filter_list` VALUES (85,'openvpn-udp',NULL,'udp','0/0','1194',NULL,0);
-INSERT INTO `Filter_list` VALUES (90,'dns_udp',NULL,'udp','0/0','53',NULL,0);
-INSERT INTO `Filter_list` VALUES (91,'dns_tcp',NULL,'tcp','0/0','53',NULL,0);
-INSERT INTO `Filter_list` VALUES (94,'squid',NULL,'tcp','0/0','3128',NULL,0);
-INSERT INTO `Filter_list` VALUES (101,'snmp',NULL,'udp','0/0','161',NULL,0);
-INSERT INTO `Filter_list` VALUES (105,'http_udp',NULL,'udp','0/0','80',NULL,0);
-INSERT INTO `Filter_list` VALUES (106,'https_udp',NULL,'udp','0/0','443',NULL,0);
-INSERT INTO `Filter_list` VALUES (107,'l2tp-ipsec',NULL,'udp','0/0','1701,4500,500',NULL,0);
-INSERT INTO `Filter_list` VALUES (108,'gre',NULL,'gre','0/0',NULL,NULL,0);
+INSERT INTO `filter_list` VALUES (1,'pop3',NULL,'tcp','0/0','110',NULL,0);
+INSERT INTO `filter_list` VALUES (3,'http',NULL,'tcp','0/0','80',NULL,0);
+INSERT INTO `filter_list` VALUES (4,'https',NULL,'tcp','0/0','443',NULL,0);
+INSERT INTO `filter_list` VALUES (5,'icq',NULL,'tcp','0/0','5190',NULL,0);
+INSERT INTO `filter_list` VALUES (6,'jabber',NULL,'tcp','0/0','5222',NULL,0);
+INSERT INTO `filter_list` VALUES (9,'allow_all','любой трафик','all','0/0','0','0',0);
+INSERT INTO `filter_list` VALUES (10,'icmp',NULL,'icmp','0/0','0',NULL,0);
+INSERT INTO `filter_list` VALUES (11,'ftp',NULL,'tcp','0/0','20-21',NULL,0);
+INSERT INTO `filter_list` VALUES (15,'telnet',NULL,'tcp','0/0','23',NULL,0);
+INSERT INTO `filter_list` VALUES (16,'ssh',NULL,'tcp','0/0','22',NULL,0);
+INSERT INTO `filter_list` VALUES (28,'smtp',NULL,'tcp','0/0','25',NULL,0);
+INSERT INTO `filter_list` VALUES (32,'rdp',NULL,'tcp','0/0','3389',NULL,0);
+INSERT INTO `filter_list` VALUES (40,'ntp',NULL,'udp','0/0','123',NULL,0);
+INSERT INTO `filter_list` VALUES (44,'vnc',NULL,'tcp','0/0','5800-5900',NULL,0);
+INSERT INTO `filter_list` VALUES (55,'unprivileged tcp',NULL,'tcp','0/0','1024-65500',NULL,0);
+INSERT INTO `filter_list` VALUES (76,'ipsec',NULL,'udp','0/0','500',NULL,0);
+INSERT INTO `filter_list` VALUES (77,'isakmp',NULL,'udp','0/0','4500',NULL,0);
+INSERT INTO `filter_list` VALUES (79,'pop3s',NULL,'tcp','0/0','995',NULL,0);
+INSERT INTO `filter_list` VALUES (80,'smtps',NULL,'tcp','0/0','465,587',NULL,0);
+INSERT INTO `filter_list` VALUES (81,'imap',NULL,'tcp','0/0','143',NULL,0);
+INSERT INTO `filter_list` VALUES (82,'imaps',NULL,'tcp','0/0','993',NULL,0);
+INSERT INTO `filter_list` VALUES (83,'unprivileged udp',NULL,'udp','0/0','1024-65000',NULL,0);
+INSERT INTO `filter_list` VALUES (84,'pptp',NULL,'tcp','0/0','1723',NULL,0);
+INSERT INTO `filter_list` VALUES (85,'openvpn-udp',NULL,'udp','0/0','1194',NULL,0);
+INSERT INTO `filter_list` VALUES (90,'dns_udp',NULL,'udp','0/0','53',NULL,0);
+INSERT INTO `filter_list` VALUES (91,'dns_tcp',NULL,'tcp','0/0','53',NULL,0);
+INSERT INTO `filter_list` VALUES (94,'squid',NULL,'tcp','0/0','3128',NULL,0);
+INSERT INTO `filter_list` VALUES (101,'snmp',NULL,'udp','0/0','161',NULL,0);
+INSERT INTO `filter_list` VALUES (105,'http_udp',NULL,'udp','0/0','80',NULL,0);
+INSERT INTO `filter_list` VALUES (106,'https_udp',NULL,'udp','0/0','443',NULL,0);
+INSERT INTO `filter_list` VALUES (107,'l2tp-ipsec',NULL,'udp','0/0','1701,4500,500',NULL,0);
+INSERT INTO `filter_list` VALUES (108,'gre',NULL,'gre','0/0',NULL,NULL,0);
 
 
-INSERT INTO `Group_filters` VALUES (1,2,90,1,1);
-INSERT INTO `Group_filters` VALUES (2,2,91,2,1);
-INSERT INTO `Group_filters` VALUES (3,2,11,3,1);
-INSERT INTO `Group_filters` VALUES (5,2,3,4,1);
-INSERT INTO `Group_filters` VALUES (6,2,105,5,1);
-INSERT INTO `Group_filters` VALUES (7,2,4,6,1);
-INSERT INTO `Group_filters` VALUES (8,2,106,7,1);
-INSERT INTO `Group_filters` VALUES (9,2,10,8,1);
-INSERT INTO `Group_filters` VALUES (10,2,81,9,1);
-INSERT INTO `Group_filters` VALUES (11,2,82,10,1);
-INSERT INTO `Group_filters` VALUES (15,2,40,11,1);
-INSERT INTO `Group_filters` VALUES (16,2,1,12,1);
-INSERT INTO `Group_filters` VALUES (17,2,79,13,1);
-INSERT INTO `Group_filters` VALUES (18,2,80,14,1);
-INSERT INTO `Group_filters` VALUES (19,1,9,1,1);
+INSERT INTO `group_filters` VALUES (1,2,90,1,1);
+INSERT INTO `group_filters` VALUES (2,2,91,2,1);
+INSERT INTO `group_filters` VALUES (3,2,11,3,1);
+INSERT INTO `group_filters` VALUES (5,2,3,4,1);
+INSERT INTO `group_filters` VALUES (6,2,105,5,1);
+INSERT INTO `group_filters` VALUES (7,2,4,6,1);
+INSERT INTO `group_filters` VALUES (8,2,106,7,1);
+INSERT INTO `group_filters` VALUES (9,2,10,8,1);
+INSERT INTO `group_filters` VALUES (10,2,81,9,1);
+INSERT INTO `group_filters` VALUES (11,2,82,10,1);
+INSERT INTO `group_filters` VALUES (15,2,40,11,1);
+INSERT INTO `group_filters` VALUES (16,2,1,12,1);
+INSERT INTO `group_filters` VALUES (17,2,79,13,1);
+INSERT INTO `group_filters` VALUES (18,2,80,14,1);
+INSERT INTO `group_filters` VALUES (19,1,9,1,1);
 
 
 INSERT INTO `config` VALUES (1,1,'0');
 INSERT INTO `config` VALUES (1,1,'0');
 INSERT INTO `config` VALUES (2,11,'public');
 INSERT INTO `config` VALUES (2,11,'public');

+ 107 - 108
docs/databases/postgres/en/create_db.sql

@@ -7,12 +7,12 @@ CREATE EXTENSION IF NOT EXISTS ip4r;
 CREATE TABLE acl (
 CREATE TABLE acl (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 name VARCHAR(30) NOT NULL,
 name VARCHAR(30) NOT NULL,
-"description.english" VARCHAR(250) NOT NULL,
-"description.russian" VARCHAR(250) NOT NULL
+description_english VARCHAR(250) NOT NULL,
+description_russian VARCHAR(250) NOT NULL
 );
 );
 COMMENT ON TABLE acl IS 'Access Control List - roles and permissions';
 COMMENT ON TABLE acl IS 'Access Control List - roles and permissions';
-COMMENT ON COLUMN acl."description.english" IS 'Description in English';
-COMMENT ON COLUMN acl."description.russian" IS 'Description in Russian';
+COMMENT ON COLUMN acl.description_english IS 'Description in English';
+COMMENT ON COLUMN acl.description_russian IS 'Description in Russian';
 
 
 -- Active Directory computer cache
 -- Active Directory computer cache
 CREATE TABLE ad_comp_cache (
 CREATE TABLE ad_comp_cache (
@@ -20,9 +20,9 @@ id SERIAL PRIMARY KEY,
 name VARCHAR(63) NOT NULL UNIQUE,
 name VARCHAR(63) NOT NULL UNIQUE,
 last_found TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
 last_found TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
 );
 );
-COMMENT ON TABLE ad_comp_cache IS 'Cache of computers from Active Directory';
+COMMENT ON TABLE ad_comp_cache IS 'Active Directory computer cache';
 COMMENT ON COLUMN ad_comp_cache.name IS 'Computer name in AD';
 COMMENT ON COLUMN ad_comp_cache.name IS 'Computer name in AD';
-COMMENT ON COLUMN ad_comp_cache.last_found IS 'Last time this computer was found';
+COMMENT ON COLUMN ad_comp_cache.last_found IS 'Last time this computer was detected';
 
 
 -- Authentication rules
 -- Authentication rules
 CREATE TABLE auth_rules (
 CREATE TABLE auth_rules (
@@ -58,8 +58,8 @@ COMMENT ON TABLE config IS 'System configuration values';
 CREATE TABLE config_options (
 CREATE TABLE config_options (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 option_name VARCHAR(50) NOT NULL,
 option_name VARCHAR(50) NOT NULL,
-"description.russian" TEXT,
-"description.english" TEXT,
+description_russian TEXT,
+description_english TEXT,
 draft SMALLINT NOT NULL DEFAULT 0,
 draft SMALLINT NOT NULL DEFAULT 0,
 uniq SMALLINT NOT NULL DEFAULT 1,
 uniq SMALLINT NOT NULL DEFAULT 1,
 type VARCHAR(100) NOT NULL,
 type VARCHAR(100) NOT NULL,
@@ -69,8 +69,8 @@ max_value INTEGER NOT NULL DEFAULT 0
 );
 );
 COMMENT ON TABLE config_options IS 'Available configuration options';
 COMMENT ON TABLE config_options IS 'Available configuration options';
 COMMENT ON COLUMN config_options.option_name IS 'Option name/key';
 COMMENT ON COLUMN config_options.option_name IS 'Option name/key';
-COMMENT ON COLUMN config_options.draft IS 'Is option in draft state';
-COMMENT ON COLUMN config_options.uniq IS 'Is option unique (single value)';
+COMMENT ON COLUMN config_options.draft IS 'Option is in draft state';
+COMMENT ON COLUMN config_options.uniq IS 'Option is unique (single value)';
 
 
 -- Network connections
 -- Network connections
 CREATE TABLE connections (
 CREATE TABLE connections (
@@ -83,11 +83,11 @@ last_found TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
 COMMENT ON TABLE connections IS 'Current network connections (MAC-IP-device-port)';
 COMMENT ON TABLE connections IS 'Current network connections (MAC-IP-device-port)';
 COMMENT ON COLUMN connections.device_id IS 'Network device ID';
 COMMENT ON COLUMN connections.device_id IS 'Network device ID';
 COMMENT ON COLUMN connections.port_id IS 'Device port ID';
 COMMENT ON COLUMN connections.port_id IS 'Device port ID';
-COMMENT ON COLUMN connections.auth_id IS 'User authorization ID';
-COMMENT ON COLUMN connections.last_found IS 'Last time this connection was active';
+COMMENT ON COLUMN connections.auth_id IS 'User authentication ID';
+COMMENT ON COLUMN connections.last_found IS 'Last connection activity time';
 
 
--- System customers/users
-CREATE TABLE Customers (
+-- System users
+CREATE TABLE customers (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 Login VARCHAR(20),
 Login VARCHAR(20),
 comment VARCHAR(100),
 comment VARCHAR(100),
@@ -95,9 +95,9 @@ password VARCHAR(255),
 api_key VARCHAR(255),
 api_key VARCHAR(255),
 rights SMALLINT NOT NULL DEFAULT 3
 rights SMALLINT NOT NULL DEFAULT 3
 );
 );
-COMMENT ON TABLE Customers IS 'System users/administrators';
-COMMENT ON COLUMN Customers.Login IS 'User login name';
-COMMENT ON COLUMN Customers.rights IS 'Access rights level: 0=view, 1=operator, 2=admin, 3=superadmin';
+COMMENT ON TABLE customers IS 'System users/administrators';
+COMMENT ON COLUMN customers.Login IS 'User login';
+COMMENT ON COLUMN customers.rights IS 'Access level: 0=view, 1=operator, 2=admin, 3=superadmin';
 
 
 -- Network devices
 -- Network devices
 CREATE TABLE devices (
 CREATE TABLE devices (
@@ -146,7 +146,7 @@ COMMENT ON COLUMN devices.device_type IS 'Device type ID';
 COMMENT ON COLUMN devices.ip IS 'Device management IP address';
 COMMENT ON COLUMN devices.ip IS 'Device management IP address';
 COMMENT ON COLUMN devices.snmp_version IS 'SNMP version: 0=disabled, 1=v1, 2=v2c, 3=v3';
 COMMENT ON COLUMN devices.snmp_version IS 'SNMP version: 0=disabled, 1=v1, 2=v2c, 3=v3';
 COMMENT ON COLUMN devices.discovery IS 'Enable automatic discovery';
 COMMENT ON COLUMN devices.discovery IS 'Enable automatic discovery';
-COMMENT ON COLUMN devices.active IS 'Is device active and monitored';
+COMMENT ON COLUMN devices.active IS 'Device is active and monitored';
 
 
 -- Device filter instances
 -- Device filter instances
 CREATE TABLE device_filter_instances (
 CREATE TABLE device_filter_instances (
@@ -176,9 +176,9 @@ poe_in SMALLINT NOT NULL DEFAULT 0,
 poe_out SMALLINT NOT NULL DEFAULT 0,
 poe_out SMALLINT NOT NULL DEFAULT 0,
 nagios_template VARCHAR(200)
 nagios_template VARCHAR(200)
 );
 );
-COMMENT ON TABLE device_models IS 'Device models and specifications';
+COMMENT ON TABLE device_models IS 'Device models and their characteristics';
 COMMENT ON COLUMN device_models.poe_in IS 'Supports Power over Ethernet input';
 COMMENT ON COLUMN device_models.poe_in IS 'Supports Power over Ethernet input';
-COMMENT ON COLUMN device_models.poe_out IS 'Provides Power over Ethernet';
+COMMENT ON COLUMN device_models.poe_out IS 'Provides Power over Ethernet output';
 
 
 -- Device ports
 -- Device ports
 CREATE TABLE device_ports (
 CREATE TABLE device_ports (
@@ -200,20 +200,20 @@ tagged_vlan VARCHAR(250),
 untagged_vlan VARCHAR(250),
 untagged_vlan VARCHAR(250),
 forbidden_vlan VARCHAR(250)
 forbidden_vlan VARCHAR(250)
 );
 );
-COMMENT ON TABLE device_ports IS 'Network device ports/interfaces';
+COMMENT ON TABLE device_ports IS 'Ports/interfaces of network devices';
 COMMENT ON COLUMN device_ports.port IS 'Physical port number';
 COMMENT ON COLUMN device_ports.port IS 'Physical port number';
-COMMENT ON COLUMN device_ports.uplink IS 'Is this an uplink port';
-COMMENT ON COLUMN device_ports.vlan IS 'Default/native VLAN ID';
+COMMENT ON COLUMN device_ports.uplink IS 'This is an uplink port';
+COMMENT ON COLUMN device_ports.vlan IS 'Default/native VLAN';
 
 
 -- Device types
 -- Device types
 CREATE TABLE device_types (
 CREATE TABLE device_types (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
-"name.russian" VARCHAR(50),
-"name.english" VARCHAR(50)
+name_russian VARCHAR(50),
+name_english VARCHAR(50)
 );
 );
 COMMENT ON TABLE device_types IS 'Device type classification';
 COMMENT ON TABLE device_types IS 'Device type classification';
-COMMENT ON COLUMN device_types."name.russian" IS 'Device type name in Russian';
-COMMENT ON COLUMN device_types."name.english" IS 'Device type name in English';
+COMMENT ON COLUMN device_types.name_russian IS 'Device type name in Russian';
+COMMENT ON COLUMN device_types.name_english IS 'Device type name in English';
 
 
 -- DHCP logs
 -- DHCP logs
 CREATE TABLE dhcp_log (
 CREATE TABLE dhcp_log (
@@ -225,13 +225,13 @@ action VARCHAR(10) NOT NULL,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 auth_id BIGINT NOT NULL,
 auth_id BIGINT NOT NULL,
 dhcp_hostname VARCHAR(250),
 dhcp_hostname VARCHAR(250),
-"circuit-id" VARCHAR(255),
-"remote-id" VARCHAR(255),
-"client-id" VARCHAR(250)
+circuit_id VARCHAR(255),
+remote_id VARCHAR(255),
+client_id VARCHAR(250)
 );
 );
 COMMENT ON TABLE dhcp_log IS 'DHCP server transaction logs';
 COMMENT ON TABLE dhcp_log IS 'DHCP server transaction logs';
 COMMENT ON COLUMN dhcp_log.action IS 'DHCP action: DISCOVER, REQUEST, ACK, NAK, RELEASE';
 COMMENT ON COLUMN dhcp_log.action IS 'DHCP action: DISCOVER, REQUEST, ACK, NAK, RELEASE';
-COMMENT ON COLUMN dhcp_log."circuit-id" IS 'DHCP option 82 circuit ID';
+COMMENT ON COLUMN dhcp_log.circuit_id IS 'DHCP option 82 circuit ID';
 
 
 -- DHCP queue
 -- DHCP queue
 CREATE TABLE dhcp_queue (
 CREATE TABLE dhcp_queue (
@@ -242,7 +242,7 @@ action VARCHAR(10) NOT NULL,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 dhcp_hostname VARCHAR(250)
 dhcp_hostname VARCHAR(250)
 );
 );
-COMMENT ON TABLE dhcp_queue IS 'Pending DHCP operations queue';
+COMMENT ON TABLE dhcp_queue IS 'Queue of deferred DHCP operations';
 
 
 -- DNS cache
 -- DNS cache
 CREATE TABLE dns_cache (
 CREATE TABLE dns_cache (
@@ -262,7 +262,7 @@ name VARCHAR(200),
 type VARCHAR(10) NOT NULL DEFAULT 'add',
 type VARCHAR(10) NOT NULL DEFAULT 'add',
 value VARCHAR(100)
 value VARCHAR(100)
 );
 );
-COMMENT ON TABLE dns_queue IS 'Pending DNS operations queue';
+COMMENT ON TABLE dns_queue IS 'Queue of deferred DNS operations';
 COMMENT ON COLUMN dns_queue.name_type IS 'DNS record type: A, AAAA, PTR, CNAME';
 COMMENT ON COLUMN dns_queue.name_type IS 'DNS record type: A, AAAA, PTR, CNAME';
 COMMENT ON COLUMN dns_queue.type IS 'Operation type: add, delete, update';
 COMMENT ON COLUMN dns_queue.type IS 'Operation type: add, delete, update';
 
 
@@ -272,10 +272,10 @@ id SERIAL PRIMARY KEY,
 name VARCHAR(50) UNIQUE,
 name VARCHAR(50) UNIQUE,
 comment VARCHAR(200)
 comment VARCHAR(200)
 );
 );
-COMMENT ON TABLE filter_instances IS 'Filter policy instances';
+COMMENT ON TABLE filter_instances IS 'Filtering policy instances';
 
 
--- Filter rules list
-CREATE TABLE Filter_list (
+-- Firewall rule list
+CREATE TABLE filter_list (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 name VARCHAR(50),
 name VARCHAR(50),
 comment VARCHAR(250),
 comment VARCHAR(250),
@@ -285,39 +285,39 @@ dstport VARCHAR(20),
 srcport VARCHAR(20),
 srcport VARCHAR(20),
 type SMALLINT NOT NULL DEFAULT 0
 type SMALLINT NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE Filter_list IS 'Firewall/filter rules';
-COMMENT ON COLUMN Filter_list.proto IS 'Protocol: tcp, udp, icmp, etc.';
-COMMENT ON COLUMN Filter_list.dst IS 'Destination IP/CIDR';
-COMMENT ON COLUMN Filter_list.type IS 'Rule type: 0=allow, 1=deny';
+COMMENT ON TABLE filter_list IS 'Firewall/filtering rules';
+COMMENT ON COLUMN filter_list.proto IS 'Protocol: tcp, udp, icmp, etc.';
+COMMENT ON COLUMN filter_list.dst IS 'Destination IP/CIDR';
+COMMENT ON COLUMN filter_list.type IS 'Rule type: 0=allow, 1=deny';
 
 
--- Gateway subnets
+-- Subnet gateways
 CREATE TABLE gateway_subnets (
 CREATE TABLE gateway_subnets (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 device_id INTEGER,
 device_id INTEGER,
 subnet_id INTEGER
 subnet_id INTEGER
 );
 );
-COMMENT ON TABLE gateway_subnets IS 'Which devices serve as gateways for which subnets';
+COMMENT ON TABLE gateway_subnets IS 'Which devices act as gateways for which subnets';
 
 
--- Filter assignments to groups
-CREATE TABLE Group_filters (
+-- Group filter assignments
+CREATE TABLE group_filters (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 group_id INTEGER NOT NULL DEFAULT 0,
 group_id INTEGER NOT NULL DEFAULT 0,
 filter_id INTEGER NOT NULL DEFAULT 0,
 filter_id INTEGER NOT NULL DEFAULT 0,
-"order" INTEGER NOT NULL DEFAULT 0,
+rule_order INTEGER NOT NULL DEFAULT 0,
 action SMALLINT NOT NULL DEFAULT 0
 action SMALLINT NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE Group_filters IS 'Filter rules assigned to groups';
-COMMENT ON COLUMN Group_filters."order" IS 'Rule processing order';
-COMMENT ON COLUMN Group_filters.action IS 'Action: 1=allow, 0=deny';
+COMMENT ON TABLE group_filters IS 'Filtering rules assigned to groups';
+COMMENT ON COLUMN group_filters.rule_order IS 'Rule processing order';
+COMMENT ON COLUMN group_filters.action IS 'Action: 1=allow, 0=deny';
 
 
 -- Filter groups
 -- Filter groups
-CREATE TABLE Group_list (
+CREATE TABLE group_list (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 instance_id INTEGER NOT NULL DEFAULT 1,
 instance_id INTEGER NOT NULL DEFAULT 1,
 group_name VARCHAR(50),
 group_name VARCHAR(50),
 comment VARCHAR(250)
 comment VARCHAR(250)
 );
 );
-COMMENT ON TABLE Group_list IS 'Filter policy groups';
+COMMENT ON TABLE group_list IS 'Filtering policy groups';
 
 
 -- MAC address history
 -- MAC address history
 CREATE TABLE mac_history (
 CREATE TABLE mac_history (
@@ -330,9 +330,9 @@ ip VARCHAR(16) NOT NULL DEFAULT '',
 auth_id BIGINT,
 auth_id BIGINT,
 dhcp_hostname VARCHAR(250)
 dhcp_hostname VARCHAR(250)
 );
 );
-COMMENT ON TABLE mac_history IS 'Historical MAC address movements';
-COMMENT ON COLUMN mac_history.mac IS 'MAC address (12 hex chars)';
-COMMENT ON COLUMN mac_history.ip IS 'IP address last used';
+COMMENT ON TABLE mac_history IS 'MAC address movement history';
+COMMENT ON COLUMN mac_history.mac IS 'MAC address (12 hexadecimal characters)';
+COMMENT ON COLUMN mac_history.ip IS 'Last used IP address';
 
 
 -- MAC address vendors
 -- MAC address vendors
 CREATE TABLE mac_vendors (
 CREATE TABLE mac_vendors (
@@ -342,7 +342,7 @@ companyName VARCHAR(255),
 companyAddress VARCHAR(255)
 companyAddress VARCHAR(255)
 );
 );
 COMMENT ON TABLE mac_vendors IS 'MAC address vendor database';
 COMMENT ON TABLE mac_vendors IS 'MAC address vendor database';
-COMMENT ON COLUMN mac_vendors.oui IS 'Organizationally Unique Identifier (first 6 chars of MAC)';
+COMMENT ON COLUMN mac_vendors.oui IS 'Organizationally Unique Identifier (first 6 MAC characters)';
 
 
 -- Organizational Units
 -- Organizational Units
 CREATE TABLE OU (
 CREATE TABLE OU (
@@ -364,18 +364,18 @@ parent_id INTEGER
 );
 );
 COMMENT ON TABLE OU IS 'Organizational Units (departments/groups)';
 COMMENT ON TABLE OU IS 'Organizational Units (departments/groups)';
 COMMENT ON COLUMN OU.ou_name IS 'OU name/identifier';
 COMMENT ON COLUMN OU.ou_name IS 'OU name/identifier';
-COMMENT ON COLUMN OU.life_duration IS 'Default lease duration in hours for dynamic OUs';
+COMMENT ON COLUMN OU.life_duration IS 'Default lifetime in hours for dynamic OUs';
 
 
 -- Traffic shaping queues
 -- Traffic shaping queues
-CREATE TABLE Queue_list (
+CREATE TABLE queue_list (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 queue_name VARCHAR(20) NOT NULL,
 queue_name VARCHAR(20) NOT NULL,
 Download INTEGER NOT NULL DEFAULT 0,
 Download INTEGER NOT NULL DEFAULT 0,
 Upload INTEGER NOT NULL DEFAULT 0
 Upload INTEGER NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE Queue_list IS 'Traffic shaping bandwidth profiles';
-COMMENT ON COLUMN Queue_list.Download IS 'Download speed limit in Kbps';
-COMMENT ON COLUMN Queue_list.Upload IS 'Upload speed limit in Kbps';
+COMMENT ON TABLE queue_list IS 'Bandwidth profiles for traffic shaping';
+COMMENT ON COLUMN queue_list.Download IS 'Download speed limit in Kbit/s';
+COMMENT ON COLUMN queue_list.Upload IS 'Upload speed limit in Kbit/s';
 
 
 -- Remote syslog messages
 -- Remote syslog messages
 CREATE TABLE remote_syslog (
 CREATE TABLE remote_syslog (
@@ -417,15 +417,15 @@ discovery SMALLINT NOT NULL DEFAULT 1,
 notify SMALLINT NOT NULL DEFAULT 7,
 notify SMALLINT NOT NULL DEFAULT 7,
 comment VARCHAR(250)
 comment VARCHAR(250)
 );
 );
-COMMENT ON TABLE subnets IS 'Network subnets configuration';
+COMMENT ON TABLE subnets IS 'Network subnet configuration';
 COMMENT ON COLUMN subnets.subnet IS 'Network in CIDR notation';
 COMMENT ON COLUMN subnets.subnet IS 'Network in CIDR notation';
 COMMENT ON COLUMN subnets.vlan_tag IS 'VLAN ID for this subnet';
 COMMENT ON COLUMN subnets.vlan_tag IS 'VLAN ID for this subnet';
-COMMENT ON COLUMN subnets.office IS 'Is this an office subnet';
-COMMENT ON COLUMN subnets.hotspot IS 'Is this a hotspot/public subnet';
-COMMENT ON COLUMN subnets.notify IS 'Bitmask for notifications: 1=email, 2=sms, 4=telegram';
+COMMENT ON COLUMN subnets.office IS 'This is an office subnet';
+COMMENT ON COLUMN subnets.hotspot IS 'This is a public/guest subnet';
+COMMENT ON COLUMN subnets.notify IS 'Notification bitmask: 1=email, 2=sms, 4=telegram';
 
 
 -- Detailed traffic logs
 -- Detailed traffic logs
-CREATE TABLE Traffic_detail (
+CREATE TABLE traffic_detail (
 id BIGSERIAL PRIMARY KEY,
 id BIGSERIAL PRIMARY KEY,
 auth_id BIGINT,
 auth_id BIGINT,
 router_id INTEGER NOT NULL DEFAULT 0,
 router_id INTEGER NOT NULL DEFAULT 0,
@@ -438,23 +438,23 @@ dst_port INTEGER NOT NULL,
 bytes BIGINT NOT NULL,
 bytes BIGINT NOT NULL,
 pkt INTEGER NOT NULL DEFAULT 0
 pkt INTEGER NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE Traffic_detail IS 'Detailed traffic flow records (NetFlow)';
-COMMENT ON COLUMN Traffic_detail.proto IS 'IP protocol number';
-COMMENT ON COLUMN Traffic_detail.src_ip IS 'Source IP as integer';
-COMMENT ON COLUMN Traffic_detail.bytes IS 'Bytes transferred in this flow';
+COMMENT ON TABLE traffic_detail IS 'Detailed traffic flow records (NetFlow)';
+COMMENT ON COLUMN traffic_detail.proto IS 'IP protocol number';
+COMMENT ON COLUMN traffic_detail.src_ip IS 'Source IP as integer';
+COMMENT ON COLUMN traffic_detail.bytes IS 'Bytes transferred in this flow';
 
 
 -- Unknown MAC addresses
 -- Unknown MAC addresses
-CREATE TABLE Unknown_mac (
+CREATE TABLE unknown_mac (
 id BIGSERIAL PRIMARY KEY,
 id BIGSERIAL PRIMARY KEY,
 mac VARCHAR(12),
 mac VARCHAR(12),
 port_id BIGINT,
 port_id BIGINT,
 device_id INTEGER,
 device_id INTEGER,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
 );
 );
-COMMENT ON TABLE Unknown_mac IS 'Recently discovered unknown MAC addresses';
+COMMENT ON TABLE unknown_mac IS 'Recently detected unknown MAC addresses';
 
 
 -- User authorization records
 -- User authorization records
-CREATE TABLE User_auth (
+CREATE TABLE user_auth (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 user_id BIGINT NOT NULL DEFAULT 0,
 user_id BIGINT NOT NULL DEFAULT 0,
 ou_id INTEGER,
 ou_id INTEGER,
@@ -486,7 +486,7 @@ month_quota INTEGER NOT NULL DEFAULT 0,
 device_model_id INTEGER DEFAULT 87,
 device_model_id INTEGER DEFAULT 87,
 firmware VARCHAR(100),
 firmware VARCHAR(100),
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
-"client-id" VARCHAR(250),
+client_id VARCHAR(250),
 nagios SMALLINT NOT NULL DEFAULT 0,
 nagios SMALLINT NOT NULL DEFAULT 0,
 nagios_status VARCHAR(10) NOT NULL DEFAULT '',
 nagios_status VARCHAR(10) NOT NULL DEFAULT '',
 nagios_handler VARCHAR(50) NOT NULL DEFAULT '',
 nagios_handler VARCHAR(50) NOT NULL DEFAULT '',
@@ -496,24 +496,24 @@ dhcp_changed SMALLINT NOT NULL DEFAULT 0,
 changed_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 changed_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 created_by VARCHAR(10)
 created_by VARCHAR(10)
 );
 );
-COMMENT ON TABLE User_auth IS 'Network user/device authorization records';
-COMMENT ON COLUMN User_auth.enabled IS 'Is this authorization active';
-COMMENT ON COLUMN User_auth.dynamic IS 'Is this a dynamically created record';
-COMMENT ON COLUMN User_auth.day_quota IS 'Daily traffic quota in bytes';
-COMMENT ON COLUMN User_auth.nagios IS 'Enable Nagios monitoring for this host';
+COMMENT ON TABLE user_auth IS 'User/device network authorization records';
+COMMENT ON COLUMN user_auth.enabled IS 'This authorization is active';
+COMMENT ON COLUMN user_auth.dynamic IS 'This is a dynamically created record';
+COMMENT ON COLUMN user_auth.day_quota IS 'Daily traffic quota in bytes';
+COMMENT ON COLUMN user_auth.nagios IS 'Enable Nagios monitoring for this host';
 
 
 -- User authorization aliases
 -- User authorization aliases
-CREATE TABLE User_auth_alias (
+CREATE TABLE user_auth_alias (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 auth_id INTEGER NOT NULL,
 auth_id INTEGER NOT NULL,
 alias VARCHAR(100),
 alias VARCHAR(100),
 description VARCHAR(100),
 description VARCHAR(100),
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
 );
 );
-COMMENT ON TABLE User_auth_alias IS 'Aliases/DNS names for authorization records';
+COMMENT ON TABLE user_auth_alias IS 'Aliases/DNS names for authorization records';
 
 
 -- User list
 -- User list
-CREATE TABLE User_list (
+CREATE TABLE user_list (
 id BIGSERIAL PRIMARY KEY,
 id BIGSERIAL PRIMARY KEY,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 login VARCHAR(255),
 login VARCHAR(255),
@@ -529,11 +529,11 @@ day_quota INTEGER NOT NULL DEFAULT 0,
 month_quota INTEGER NOT NULL DEFAULT 0,
 month_quota INTEGER NOT NULL DEFAULT 0,
 permanent SMALLINT NOT NULL DEFAULT 0
 permanent SMALLINT NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE User_list IS 'User accounts in the system';
-COMMENT ON COLUMN User_list.fio IS 'Full name (ФИО)';
-COMMENT ON COLUMN User_list.permanent IS 'Is this a permanent user (not dynamic)';
+COMMENT ON TABLE user_list IS 'User accounts in the system';
+COMMENT ON COLUMN user_list.fio IS 'Full name';
+COMMENT ON COLUMN user_list.permanent IS 'Permanent (non-dynamic) user';
 
 
--- User sessions (web interface)
+-- User web sessions
 CREATE TABLE user_sessions (
 CREATE TABLE user_sessions (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 session_id VARCHAR(128) NOT NULL,
 session_id VARCHAR(128) NOT NULL,
@@ -547,7 +547,7 @@ is_active SMALLINT DEFAULT 1
 COMMENT ON TABLE user_sessions IS 'Web interface user sessions';
 COMMENT ON TABLE user_sessions IS 'Web interface user sessions';
 
 
 -- User traffic statistics
 -- User traffic statistics
-CREATE TABLE User_stats (
+CREATE TABLE user_stats (
 id BIGSERIAL PRIMARY KEY,
 id BIGSERIAL PRIMARY KEY,
 router_id BIGINT DEFAULT 0,
 router_id BIGINT DEFAULT 0,
 auth_id BIGINT NOT NULL DEFAULT 0,
 auth_id BIGINT NOT NULL DEFAULT 0,
@@ -555,10 +555,10 @@ timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 byte_in BIGINT NOT NULL DEFAULT 0,
 byte_in BIGINT NOT NULL DEFAULT 0,
 byte_out BIGINT NOT NULL DEFAULT 0
 byte_out BIGINT NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE User_stats IS 'User traffic statistics (aggregated)';
+COMMENT ON TABLE user_stats IS 'Aggregated user traffic statistics';
 
 
 -- Detailed user statistics
 -- Detailed user statistics
-CREATE TABLE User_stats_full (
+CREATE TABLE user_stats_full (
 id BIGSERIAL PRIMARY KEY,
 id BIGSERIAL PRIMARY KEY,
 router_id BIGINT DEFAULT 0,
 router_id BIGINT DEFAULT 0,
 auth_id BIGINT NOT NULL DEFAULT 0,
 auth_id BIGINT NOT NULL DEFAULT 0,
@@ -569,8 +569,8 @@ pkt_in INTEGER,
 pkt_out INTEGER,
 pkt_out INTEGER,
 step SMALLINT NOT NULL DEFAULT 600
 step SMALLINT NOT NULL DEFAULT 600
 );
 );
-COMMENT ON TABLE User_stats_full IS 'Detailed user traffic statistics';
-COMMENT ON COLUMN User_stats_full.step IS 'Statistics collection interval in seconds';
+COMMENT ON TABLE user_stats_full IS 'Detailed user traffic statistics';
+COMMENT ON COLUMN user_stats_full.step IS 'Statistics collection interval in seconds';
 
 
 -- Temporary variables
 -- Temporary variables
 CREATE TABLE variables (
 CREATE TABLE variables (
@@ -597,19 +597,19 @@ version VARCHAR(10) NOT NULL DEFAULT '2.4.14'
 COMMENT ON TABLE version IS 'System version information';
 COMMENT ON TABLE version IS 'System version information';
 
 
 -- WAN interface statistics
 -- WAN interface statistics
-CREATE TABLE Wan_stats (
+CREATE TABLE wan_stats (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
-time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 router_id INTEGER,
 router_id INTEGER,
 interface_id INTEGER,
 interface_id INTEGER,
-"in" BIGINT NOT NULL DEFAULT 0,
-"out" BIGINT NOT NULL DEFAULT 0,
+bytes_in BIGINT NOT NULL DEFAULT 0,
+bytes_out BIGINT NOT NULL DEFAULT 0,
 forward_in BIGINT NOT NULL DEFAULT 0,
 forward_in BIGINT NOT NULL DEFAULT 0,
 forward_out BIGINT NOT NULL DEFAULT 0
 forward_out BIGINT NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE Wan_stats IS 'WAN interface traffic statistics';
-COMMENT ON COLUMN Wan_stats."in" IS 'Bytes received on WAN interface';
-COMMENT ON COLUMN Wan_stats."out" IS 'Bytes transmitted on WAN interface';
+COMMENT ON TABLE wan_stats IS 'WAN interface traffic statistics';
+COMMENT ON COLUMN wan_stats.bytes_in IS 'Bytes received on WAN interface';
+COMMENT ON COLUMN wan_stats.bytes_out IS 'Bytes sent from WAN interface';
 
 
 -- System activity log
 -- System activity log
 CREATE TABLE worklog (
 CREATE TABLE worklog (
@@ -624,7 +624,7 @@ level SMALLINT NOT NULL DEFAULT 1
 COMMENT ON TABLE worklog IS 'System activity and audit log';
 COMMENT ON TABLE worklog IS 'System activity and audit log';
 COMMENT ON COLUMN worklog.level IS 'Log level: 1=info, 2=warning, 3=error, 4=debug';
 COMMENT ON COLUMN worklog.level IS 'Log level: 1=info, 2=warning, 3=error, 4=debug';
 
 
--- Create indexes (same as original structure)
+-- Indexes (same as in the original schema)
 CREATE INDEX idx_devices_ip ON devices(ip);
 CREATE INDEX idx_devices_ip ON devices(ip);
 CREATE INDEX idx_devices_device_type ON devices(device_type);
 CREATE INDEX idx_devices_device_type ON devices(device_type);
 CREATE INDEX idx_devices_active ON devices(active) WHERE active = 1;
 CREATE INDEX idx_devices_active ON devices(active) WHERE active = 1;
@@ -648,27 +648,26 @@ CREATE INDEX idx_ou_ou_name_gin ON OU USING GIN(ou_name gin_trgm_ops);
 CREATE INDEX idx_subnets_ip_int_start ON subnets(ip_int_start, ip_int_stop);
 CREATE INDEX idx_subnets_ip_int_start ON subnets(ip_int_start, ip_int_stop);
 CREATE INDEX idx_subnets_dhcp ON subnets(dhcp, office, hotspot, static);
 CREATE INDEX idx_subnets_dhcp ON subnets(dhcp, office, hotspot, static);
 
 
-CREATE INDEX idx_traffic_detail_src ON Traffic_detail(auth_id, timestamp, router_id, src_ip);
-CREATE INDEX idx_traffic_detail_dst ON Traffic_detail(auth_id, timestamp, router_id, dst_ip);
+CREATE INDEX idx_traffic_detail_src ON traffic_detail(auth_id, timestamp, router_id, src_ip);
+CREATE INDEX idx_traffic_detail_dst ON traffic_detail(auth_id, timestamp, router_id, dst_ip);
 
 
-CREATE INDEX idx_unknown_mac_timestamp ON Unknown_mac(timestamp, device_id, port_id, mac);
+CREATE INDEX idx_unknown_mac_timestamp ON unknown_mac(timestamp, device_id, port_id, mac);
 
 
-CREATE INDEX idx_user_auth_main ON User_auth(id, user_id, ip_int, mac, ip, deleted);
-CREATE INDEX idx_user_auth_deleted ON User_auth(deleted) WHERE deleted = 0;
-CREATE INDEX idx_user_auth_ou_id ON User_auth(ou_id);
+CREATE INDEX idx_user_auth_main ON user_auth(id, user_id, ip_int, mac, ip, deleted);
+CREATE INDEX idx_user_auth_deleted ON user_auth(deleted) WHERE deleted = 0;
+CREATE INDEX idx_user_auth_ou_id ON user_auth(ou_id);
 
 
-CREATE INDEX idx_user_list_main ON User_list(id, ou_id, enabled, blocked, deleted);
+CREATE INDEX idx_user_list_main ON user_list(id, ou_id, enabled, blocked, deleted);
 
 
 CREATE INDEX idx_user_sessions_session_id ON user_sessions(session_id);
 CREATE INDEX idx_user_sessions_session_id ON user_sessions(session_id);
 CREATE INDEX idx_user_sessions_user_id ON user_sessions(user_id);
 CREATE INDEX idx_user_sessions_user_id ON user_sessions(user_id);
 CREATE INDEX idx_user_sessions_is_active ON user_sessions(is_active) WHERE is_active = 1;
 CREATE INDEX idx_user_sessions_is_active ON user_sessions(is_active) WHERE is_active = 1;
 
 
-CREATE INDEX idx_user_stats_timestamp ON User_stats(timestamp, auth_id, router_id);
-CREATE INDEX idx_user_stats_full_timestamp ON User_stats_full(timestamp, auth_id, router_id);
+CREATE INDEX idx_user_stats_timestamp ON user_stats(timestamp, auth_id, router_id);
+CREATE INDEX idx_user_stats_full_timestamp ON user_stats_full(timestamp, auth_id, router_id);
 
 
-CREATE INDEX idx_wan_stats_time ON Wan_stats(time, router_id, interface_id);
+CREATE INDEX idx_wan_stats_time ON wan_stats(time, router_id, interface_id);
 
 
 CREATE INDEX idx_worklog_customer ON worklog(customer, level, timestamp);
 CREATE INDEX idx_worklog_customer ON worklog(customer, level, timestamp);
 CREATE INDEX idx_worklog_timestamp ON worklog(level, timestamp);
 CREATE INDEX idx_worklog_timestamp ON worklog(level, timestamp);
 CREATE INDEX idx_worklog_auth_id ON worklog(auth_id, level, timestamp);
 CREATE INDEX idx_worklog_auth_id ON worklog(auth_id, level, timestamp);
-

+ 24 - 24
docs/databases/postgres/en/data.sql

@@ -1,15 +1,15 @@
 -- Импорт данных в PostgreSQL (сохранены оригинальные названия)
 -- Импорт данных в PostgreSQL (сохранены оригинальные названия)
 
 
 -- ACL (Access Control List)
 -- ACL (Access Control List)
-INSERT INTO acl (id, name, "description.english", "description.russian") 
+INSERT INTO acl (id, name, description_english, description_russian) 
 VALUES 
 VALUES 
 (1, 'Full access', 'Full access', 'Полный доступ'),
 (1, 'Full access', 'Full access', 'Полный доступ'),
 (2, 'Operator', 'Editing parameters that are not related to access rights', 'Редактирование параметров, не связанных с правами доступа'),
 (2, 'Operator', 'Editing parameters that are not related to access rights', 'Редактирование параметров, не связанных с правами доступа'),
 (3, 'View only', 'View only', 'Только просмотр')
 (3, 'View only', 'View only', 'Только просмотр')
 ON CONFLICT (id) DO UPDATE SET
 ON CONFLICT (id) DO UPDATE SET
     name = EXCLUDED.name,
     name = EXCLUDED.name,
-    "description.english" = EXCLUDED."description.english",
-    "description.russian" = EXCLUDED."description.russian";
+    description_english = EXCLUDED.description_english,
+    description_russian = EXCLUDED.description_russian;
 
 
 -- Buildings
 -- Buildings
 INSERT INTO building (id, name, comment)
 INSERT INTO building (id, name, comment)
@@ -19,7 +19,7 @@ ON CONFLICT (id) DO UPDATE SET
     comment = EXCLUDED.comment;
     comment = EXCLUDED.comment;
 
 
 -- Configuration options
 -- Configuration options
-INSERT INTO config_options (id, option_name, "description.russian", "description.english", draft, uniq, type, default_value, min_value, max_value)
+INSERT INTO config_options (id, option_name, description_russian, description_english, draft, uniq, type, default_value, min_value, max_value)
 VALUES
 VALUES
 (1, 'KB', 'Еденица измерения трафика - Килобайт (0) или кибибайт (1,default)', 'Traffic measurement unit - Kilobyte (1000b) or kibibyte (1024b,default)', 0, 1, 'bool', '1024', 0, 1),
 (1, 'KB', 'Еденица измерения трафика - Килобайт (0) или кибибайт (1,default)', 'Traffic measurement unit - Kilobyte (1000b) or kibibyte (1024b,default)', 0, 1, 'bool', '1024', 0, 1),
 (3, 'dns server', 'ip-адрес DNS-сервера', 'DNS server ip address', 0, 1, 'text', '127.0.0.1', 0, 0),
 (3, 'dns server', 'ip-адрес DNS-сервера', 'DNS server ip address', 0, 1, 'text', '127.0.0.1', 0, 0),
@@ -83,8 +83,8 @@ VALUES
 (73, 'check_computer_exists', 'Проверять существование компьютера в домене перед обновлением DNS по DHCP запросу', 'Verify the existence of a computer in the domain before updating DNS by DHCP request', 0, 1, 'bool', '1', 0, 0)
 (73, 'check_computer_exists', 'Проверять существование компьютера в домене перед обновлением DNS по DHCP запросу', 'Verify the existence of a computer in the domain before updating DNS by DHCP request', 0, 1, 'bool', '1', 0, 0)
 ON CONFLICT (id) DO UPDATE SET
 ON CONFLICT (id) DO UPDATE SET
     option_name = EXCLUDED.option_name,
     option_name = EXCLUDED.option_name,
-    "description.russian" = EXCLUDED."description.russian",
-    "description.english" = EXCLUDED."description.english",
+    description_russian = EXCLUDED.description_russian,
+    description_english = EXCLUDED.description_english,
     draft = EXCLUDED.draft,
     draft = EXCLUDED.draft,
     uniq = EXCLUDED.uniq,
     uniq = EXCLUDED.uniq,
     type = EXCLUDED.type,
     type = EXCLUDED.type,
@@ -122,7 +122,7 @@ ON CONFLICT (id) DO UPDATE SET
     value = EXCLUDED.value;
     value = EXCLUDED.value;
 
 
 -- System users/administrators
 -- System users/administrators
-INSERT INTO Customers (id, Login, comment, password, api_key, rights)
+INSERT INTO customers (id, Login, comment, password, api_key, rights)
 VALUES (1, 'admin', 'Administrator', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31', 1)
 VALUES (1, 'admin', 'Administrator', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31', 1)
 ON CONFLICT (id) DO UPDATE SET
 ON CONFLICT (id) DO UPDATE SET
     Login = EXCLUDED.Login,
     Login = EXCLUDED.Login,
@@ -257,7 +257,7 @@ ON CONFLICT (id) DO UPDATE SET
     nagios_template = EXCLUDED.nagios_template;
     nagios_template = EXCLUDED.nagios_template;
 
 
 -- Device types
 -- Device types
-INSERT INTO device_types (id, "name.russian", "name.english")
+INSERT INTO device_types (id, name_russian, name_english)
 VALUES
 VALUES
 (0, 'Роутер', 'Router'),
 (0, 'Роутер', 'Router'),
 (1, 'Свич', 'Switch'),
 (1, 'Свич', 'Switch'),
@@ -266,8 +266,8 @@ VALUES
 (4, 'Точка доступа', 'WiFi Access Point'),
 (4, 'Точка доступа', 'WiFi Access Point'),
 (5, 'Сетевое устройство', 'Network device')
 (5, 'Сетевое устройство', 'Network device')
 ON CONFLICT (id) DO UPDATE SET
 ON CONFLICT (id) DO UPDATE SET
-    "name.russian" = EXCLUDED."name.russian",
-    "name.english" = EXCLUDED."name.english";
+    name_russian = EXCLUDED.name_russian,
+    name_english = EXCLUDED.name_english;
 
 
 -- Filter instances
 -- Filter instances
 INSERT INTO filter_instances (id, name, comment)
 INSERT INTO filter_instances (id, name, comment)
@@ -277,7 +277,7 @@ ON CONFLICT (id) DO UPDATE SET
     comment = EXCLUDED.comment;
     comment = EXCLUDED.comment;
 
 
 -- Filter groups
 -- Filter groups
-INSERT INTO Group_list (id, instance_id, group_name, comment)
+INSERT INTO group_list (id, instance_id, group_name, comment)
 VALUES
 VALUES
 (0, 1, 'default', 'Forbidden all'),
 (0, 1, 'default', 'Forbidden all'),
 (1, 1, 'Allow all', 'Allowed all'),
 (1, 1, 'Allow all', 'Allowed all'),
@@ -321,7 +321,7 @@ ON CONFLICT (id) DO UPDATE SET
     parent_id = EXCLUDED.parent_id;
     parent_id = EXCLUDED.parent_id;
 
 
 -- Traffic shaping queues
 -- Traffic shaping queues
-INSERT INTO Queue_list (id, queue_name, Download, Upload)
+INSERT INTO queue_list (id, queue_name, Download, Upload)
 VALUES
 VALUES
 (0, 'unlimited', 0, 0),
 (0, 'unlimited', 0, 0),
 (1, '2M/2M', 2048, 2048),
 (1, '2M/2M', 2048, 2048),
@@ -422,7 +422,7 @@ ON CONFLICT (id) DO UPDATE SET
     name = EXCLUDED.name;
     name = EXCLUDED.name;
 
 
 -- Filter rules list
 -- Filter rules list
-INSERT INTO Filter_list (id, name, comment, proto, dst, dstport, srcport, type)
+INSERT INTO filter_list (id, name, comment, proto, dst, dstport, srcport, type)
 VALUES
 VALUES
 (1, 'pop3', NULL, 'tcp', '0/0', '110', NULL, 0),
 (1, 'pop3', NULL, 'tcp', '0/0', '110', NULL, 0),
 (3, 'http', NULL, 'tcp', '0/0', '80', NULL, 0),
 (3, 'http', NULL, 'tcp', '0/0', '80', NULL, 0),
@@ -466,7 +466,7 @@ ON CONFLICT (id) DO UPDATE SET
     type = EXCLUDED.type;
     type = EXCLUDED.type;
 
 
 -- Filter group assignments
 -- Filter group assignments
-INSERT INTO Group_filters (id, group_id, filter_id, "order", action)
+INSERT INTO group_filters (id, group_id, filter_id, "order", action)
 VALUES
 VALUES
 (1, 2, 90, 1, 1),
 (1, 2, 90, 1, 1),
 (2, 2, 91, 2, 1),
 (2, 2, 91, 2, 1),
@@ -500,17 +500,17 @@ SELECT setval(pg_get_serial_sequence('acl', 'id'), COALESCE((SELECT MAX(id) FROM
 SELECT setval(pg_get_serial_sequence('building', 'id'), COALESCE((SELECT MAX(id) FROM building), 0) + 1);
 SELECT setval(pg_get_serial_sequence('building', 'id'), COALESCE((SELECT MAX(id) FROM building), 0) + 1);
 SELECT setval(pg_get_serial_sequence('config_options', 'id'), COALESCE((SELECT MAX(id) FROM config_options), 0) + 1);
 SELECT setval(pg_get_serial_sequence('config_options', 'id'), COALESCE((SELECT MAX(id) FROM config_options), 0) + 1);
 SELECT setval(pg_get_serial_sequence('config', 'id'), COALESCE((SELECT MAX(id) FROM config), 0) + 1);
 SELECT setval(pg_get_serial_sequence('config', 'id'), COALESCE((SELECT MAX(id) FROM config), 0) + 1);
-SELECT setval(pg_get_serial_sequence('Customers', 'id'), COALESCE((SELECT MAX(id) FROM Customers), 0) + 1);
+SELECT setval(pg_get_serial_sequence('customers', 'id'), COALESCE((SELECT MAX(id) FROM customers), 0) + 1);
 SELECT setval(pg_get_serial_sequence('device_models', 'id'), COALESCE((SELECT MAX(id) FROM device_models), 0) + 1);
 SELECT setval(pg_get_serial_sequence('device_models', 'id'), COALESCE((SELECT MAX(id) FROM device_models), 0) + 1);
 SELECT setval(pg_get_serial_sequence('device_types', 'id'), COALESCE((SELECT MAX(id) FROM device_types), 0) + 1);
 SELECT setval(pg_get_serial_sequence('device_types', 'id'), COALESCE((SELECT MAX(id) FROM device_types), 0) + 1);
 SELECT setval(pg_get_serial_sequence('filter_instances', 'id'), COALESCE((SELECT MAX(id) FROM filter_instances), 0) + 1);
 SELECT setval(pg_get_serial_sequence('filter_instances', 'id'), COALESCE((SELECT MAX(id) FROM filter_instances), 0) + 1);
-SELECT setval(pg_get_serial_sequence('Group_list', 'id'), COALESCE((SELECT MAX(id) FROM Group_list), 0) + 1);
+SELECT setval(pg_get_serial_sequence('group_list', 'id'), COALESCE((SELECT MAX(id) FROM group_list), 0) + 1);
 SELECT setval(pg_get_serial_sequence('OU', 'id'), COALESCE((SELECT MAX(id) FROM OU), 0) + 1);
 SELECT setval(pg_get_serial_sequence('OU', 'id'), COALESCE((SELECT MAX(id) FROM OU), 0) + 1);
-SELECT setval(pg_get_serial_sequence('Queue_list', 'id'), COALESCE((SELECT MAX(id) FROM Queue_list), 0) + 1);
+SELECT setval(pg_get_serial_sequence('queue_list', 'id'), COALESCE((SELECT MAX(id) FROM queue_list), 0) + 1);
 SELECT setval(pg_get_serial_sequence('subnets', 'id'), COALESCE((SELECT MAX(id) FROM subnets), 0) + 1);
 SELECT setval(pg_get_serial_sequence('subnets', 'id'), COALESCE((SELECT MAX(id) FROM subnets), 0) + 1);
 SELECT setval(pg_get_serial_sequence('vendors', 'id'), COALESCE((SELECT MAX(id) FROM vendors), 0) + 1);
 SELECT setval(pg_get_serial_sequence('vendors', 'id'), COALESCE((SELECT MAX(id) FROM vendors), 0) + 1);
-SELECT setval(pg_get_serial_sequence('Filter_list', 'id'), COALESCE((SELECT MAX(id) FROM Filter_list), 0) + 1);
-SELECT setval(pg_get_serial_sequence('Group_filters', 'id'), COALESCE((SELECT MAX(id) FROM Group_filters), 0) + 1);
+SELECT setval(pg_get_serial_sequence('filter_list', 'id'), COALESCE((SELECT MAX(id) FROM filter_list), 0) + 1);
+SELECT setval(pg_get_serial_sequence('group_filters', 'id'), COALESCE((SELECT MAX(id) FROM group_filters), 0) + 1);
 
 
 -- Информация о завершении импорта
 -- Информация о завершении импорта
 DO $$
 DO $$
@@ -522,16 +522,16 @@ BEGIN
     RAISE NOTICE '  - building: %', (SELECT COUNT(*) FROM building);
     RAISE NOTICE '  - building: %', (SELECT COUNT(*) FROM building);
     RAISE NOTICE '  - config_options: %', (SELECT COUNT(*) FROM config_options);
     RAISE NOTICE '  - config_options: %', (SELECT COUNT(*) FROM config_options);
     RAISE NOTICE '  - config: %', (SELECT COUNT(*) FROM config);
     RAISE NOTICE '  - config: %', (SELECT COUNT(*) FROM config);
-    RAISE NOTICE '  - Customers: %', (SELECT COUNT(*) FROM Customers);
+    RAISE NOTICE '  - customers: %', (SELECT COUNT(*) FROM customers);
     RAISE NOTICE '  - device_models: %', (SELECT COUNT(*) FROM device_models);
     RAISE NOTICE '  - device_models: %', (SELECT COUNT(*) FROM device_models);
     RAISE NOTICE '  - device_types: %', (SELECT COUNT(*) FROM device_types);
     RAISE NOTICE '  - device_types: %', (SELECT COUNT(*) FROM device_types);
     RAISE NOTICE '  - filter_instances: %', (SELECT COUNT(*) FROM filter_instances);
     RAISE NOTICE '  - filter_instances: %', (SELECT COUNT(*) FROM filter_instances);
-    RAISE NOTICE '  - Group_list: %', (SELECT COUNT(*) FROM Group_list);
+    RAISE NOTICE '  - group_list: %', (SELECT COUNT(*) FROM group_list);
     RAISE NOTICE '  - OU: %', (SELECT COUNT(*) FROM OU);
     RAISE NOTICE '  - OU: %', (SELECT COUNT(*) FROM OU);
-    RAISE NOTICE '  - Queue_list: %', (SELECT COUNT(*) FROM Queue_list);
+    RAISE NOTICE '  - queue_list: %', (SELECT COUNT(*) FROM queue_list);
     RAISE NOTICE '  - subnets: %', (SELECT COUNT(*) FROM subnets);
     RAISE NOTICE '  - subnets: %', (SELECT COUNT(*) FROM subnets);
     RAISE NOTICE '  - vendors: %', (SELECT COUNT(*) FROM vendors);
     RAISE NOTICE '  - vendors: %', (SELECT COUNT(*) FROM vendors);
-    RAISE NOTICE '  - Filter_list: %', (SELECT COUNT(*) FROM Filter_list);
-    RAISE NOTICE '  - Group_filters: %', (SELECT COUNT(*) FROM Group_filters);
+    RAISE NOTICE '  - filter_list: %', (SELECT COUNT(*) FROM filter_list);
+    RAISE NOTICE '  - group_filters: %', (SELECT COUNT(*) FROM group_filters);
     RAISE NOTICE '  - version: %', (SELECT COUNT(*) FROM version);
     RAISE NOTICE '  - version: %', (SELECT COUNT(*) FROM version);
 END $$;
 END $$;

+ 76 - 76
docs/databases/postgres/ru/create_db.sql

@@ -7,12 +7,12 @@ CREATE EXTENSION IF NOT EXISTS ip4r;
 CREATE TABLE acl (
 CREATE TABLE acl (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 name VARCHAR(30) NOT NULL,
 name VARCHAR(30) NOT NULL,
-"description.english" VARCHAR(250) NOT NULL,
-"description.russian" VARCHAR(250) NOT NULL
+description_english VARCHAR(250) NOT NULL,
+description_russian VARCHAR(250) NOT NULL
 );
 );
 COMMENT ON TABLE acl IS 'Список контроля доступа - роли и разрешения';
 COMMENT ON TABLE acl IS 'Список контроля доступа - роли и разрешения';
-COMMENT ON COLUMN acl."description.english" IS 'Описание на английском языке';
-COMMENT ON COLUMN acl."description.russian" IS 'Описание на русском языке';
+COMMENT ON COLUMN acl.description_english IS 'Описание на английском языке';
+COMMENT ON COLUMN acl.description_russian IS 'Описание на русском языке';
 
 
 -- Кэш компьютеров из Active Directory
 -- Кэш компьютеров из Active Directory
 CREATE TABLE ad_comp_cache (
 CREATE TABLE ad_comp_cache (
@@ -58,8 +58,8 @@ COMMENT ON TABLE config IS 'Значения системной конфигур
 CREATE TABLE config_options (
 CREATE TABLE config_options (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 option_name VARCHAR(50) NOT NULL,
 option_name VARCHAR(50) NOT NULL,
-"description.russian" TEXT,
-"description.english" TEXT,
+description_russian TEXT,
+description_english TEXT,
 draft SMALLINT NOT NULL DEFAULT 0,
 draft SMALLINT NOT NULL DEFAULT 0,
 uniq SMALLINT NOT NULL DEFAULT 1,
 uniq SMALLINT NOT NULL DEFAULT 1,
 type VARCHAR(100) NOT NULL,
 type VARCHAR(100) NOT NULL,
@@ -87,7 +87,7 @@ COMMENT ON COLUMN connections.auth_id IS 'ID авторизации пользо
 COMMENT ON COLUMN connections.last_found IS 'Время последней активности соединения';
 COMMENT ON COLUMN connections.last_found IS 'Время последней активности соединения';
 
 
 -- Пользователи системы
 -- Пользователи системы
-CREATE TABLE Customers (
+CREATE TABLE customers (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 Login VARCHAR(20),
 Login VARCHAR(20),
 comment VARCHAR(100),
 comment VARCHAR(100),
@@ -95,9 +95,9 @@ password VARCHAR(255),
 api_key VARCHAR(255),
 api_key VARCHAR(255),
 rights SMALLINT NOT NULL DEFAULT 3
 rights SMALLINT NOT NULL DEFAULT 3
 );
 );
-COMMENT ON TABLE Customers IS 'Пользователи/администраторы системы';
-COMMENT ON COLUMN Customers.Login IS 'Логин пользователя';
-COMMENT ON COLUMN Customers.rights IS 'Уровень прав доступа: 0=просмотр, 1=оператор, 2=админ, 3=суперадмин';
+COMMENT ON TABLE customers IS 'Пользователи/администраторы системы';
+COMMENT ON COLUMN customers.Login IS 'Логин пользователя';
+COMMENT ON COLUMN customers.rights IS 'Уровень прав доступа: 0=просмотр, 1=оператор, 2=админ, 3=суперадмин';
 
 
 -- Сетевые устройства
 -- Сетевые устройства
 CREATE TABLE devices (
 CREATE TABLE devices (
@@ -208,12 +208,12 @@ COMMENT ON COLUMN device_ports.vlan IS 'VLAN по умолчанию/натив
 -- Типы устройств
 -- Типы устройств
 CREATE TABLE device_types (
 CREATE TABLE device_types (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
-"name.russian" VARCHAR(50),
-"name.english" VARCHAR(50)
+name_russian VARCHAR(50),
+name_english VARCHAR(50)
 );
 );
 COMMENT ON TABLE device_types IS 'Классификация типов устройств';
 COMMENT ON TABLE device_types IS 'Классификация типов устройств';
-COMMENT ON COLUMN device_types."name.russian" IS 'Название типа устройства на русском';
-COMMENT ON COLUMN device_types."name.english" IS 'Название типа устройства на английском';
+COMMENT ON COLUMN device_types.name_russian IS 'Название типа устройства на русском';
+COMMENT ON COLUMN device_types.name_english IS 'Название типа устройства на английском';
 
 
 -- Логи DHCP
 -- Логи DHCP
 CREATE TABLE dhcp_log (
 CREATE TABLE dhcp_log (
@@ -225,13 +225,13 @@ action VARCHAR(10) NOT NULL,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 auth_id BIGINT NOT NULL,
 auth_id BIGINT NOT NULL,
 dhcp_hostname VARCHAR(250),
 dhcp_hostname VARCHAR(250),
-"circuit-id" VARCHAR(255),
-"remote-id" VARCHAR(255),
-"client-id" VARCHAR(250)
+circuit_id VARCHAR(255),
+remote_id VARCHAR(255),
+client_id VARCHAR(250)
 );
 );
 COMMENT ON TABLE dhcp_log IS 'Логи транзакций DHCP сервера';
 COMMENT ON TABLE dhcp_log IS 'Логи транзакций DHCP сервера';
 COMMENT ON COLUMN dhcp_log.action IS 'Действие DHCP: DISCOVER, REQUEST, ACK, NAK, RELEASE';
 COMMENT ON COLUMN dhcp_log.action IS 'Действие DHCP: DISCOVER, REQUEST, ACK, NAK, RELEASE';
-COMMENT ON COLUMN dhcp_log."circuit-id" IS 'DHCP опция 82 circuit ID';
+COMMENT ON COLUMN dhcp_log.circuit_id IS 'DHCP опция 82 circuit ID';
 
 
 -- Очередь DHCP
 -- Очередь DHCP
 CREATE TABLE dhcp_queue (
 CREATE TABLE dhcp_queue (
@@ -275,7 +275,7 @@ comment VARCHAR(200)
 COMMENT ON TABLE filter_instances IS 'Экземпляры политик фильтрации';
 COMMENT ON TABLE filter_instances IS 'Экземпляры политик фильтрации';
 
 
 -- Список правил фильтрации
 -- Список правил фильтрации
-CREATE TABLE Filter_list (
+CREATE TABLE filter_list (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 name VARCHAR(50),
 name VARCHAR(50),
 comment VARCHAR(250),
 comment VARCHAR(250),
@@ -285,10 +285,10 @@ dstport VARCHAR(20),
 srcport VARCHAR(20),
 srcport VARCHAR(20),
 type SMALLINT NOT NULL DEFAULT 0
 type SMALLINT NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE Filter_list IS 'Правила firewall/фильтрации';
-COMMENT ON COLUMN Filter_list.proto IS 'Протокол: tcp, udp, icmp и т.д.';
-COMMENT ON COLUMN Filter_list.dst IS 'IP/CIDR назначения';
-COMMENT ON COLUMN Filter_list.type IS 'Тип правила: 0=разрешить, 1=запретить';
+COMMENT ON TABLE filter_list IS 'Правила firewall/фильтрации';
+COMMENT ON COLUMN filter_list.proto IS 'Протокол: tcp, udp, icmp и т.д.';
+COMMENT ON COLUMN filter_list.dst IS 'IP/CIDR назначения';
+COMMENT ON COLUMN filter_list.type IS 'Тип правила: 0=разрешить, 1=запретить';
 
 
 -- Шлюзы подсетей
 -- Шлюзы подсетей
 CREATE TABLE gateway_subnets (
 CREATE TABLE gateway_subnets (
@@ -299,25 +299,25 @@ subnet_id INTEGER
 COMMENT ON TABLE gateway_subnets IS 'Какие устройства являются шлюзами для каких подсетей';
 COMMENT ON TABLE gateway_subnets IS 'Какие устройства являются шлюзами для каких подсетей';
 
 
 -- Назначения фильтров группам
 -- Назначения фильтров группам
-CREATE TABLE Group_filters (
+CREATE TABLE group_filters (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 group_id INTEGER NOT NULL DEFAULT 0,
 group_id INTEGER NOT NULL DEFAULT 0,
 filter_id INTEGER NOT NULL DEFAULT 0,
 filter_id INTEGER NOT NULL DEFAULT 0,
-"order" INTEGER NOT NULL DEFAULT 0,
+rule_order INTEGER NOT NULL DEFAULT 0,
 action SMALLINT NOT NULL DEFAULT 0
 action SMALLINT NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE Group_filters IS 'Правила фильтрации, назначенные группам';
-COMMENT ON COLUMN Group_filters."order" IS 'Порядок обработки правил';
-COMMENT ON COLUMN Group_filters.action IS 'Действие: 1=разрешить, 0=запретить';
+COMMENT ON TABLE group_filters IS 'Правила фильтрации, назначенные группам';
+COMMENT ON COLUMN group_filters.rule_order IS 'Порядок обработки правил';
+COMMENT ON COLUMN group_filters.action IS 'Действие: 1=разрешить, 0=запретить';
 
 
 -- Группы фильтров
 -- Группы фильтров
-CREATE TABLE Group_list (
+CREATE TABLE group_list (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 instance_id INTEGER NOT NULL DEFAULT 1,
 instance_id INTEGER NOT NULL DEFAULT 1,
 group_name VARCHAR(50),
 group_name VARCHAR(50),
 comment VARCHAR(250)
 comment VARCHAR(250)
 );
 );
-COMMENT ON TABLE Group_list IS 'Группы политик фильтрации';
+COMMENT ON TABLE group_list IS 'Группы политик фильтрации';
 
 
 -- История MAC-адресов
 -- История MAC-адресов
 CREATE TABLE mac_history (
 CREATE TABLE mac_history (
@@ -367,15 +367,15 @@ COMMENT ON COLUMN OU.ou_name IS 'Имя/идентификатор OU';
 COMMENT ON COLUMN OU.life_duration IS 'Время жизни по умолчанию в часах для динамических OU';
 COMMENT ON COLUMN OU.life_duration IS 'Время жизни по умолчанию в часах для динамических OU';
 
 
 -- Очереди шейпинга трафика
 -- Очереди шейпинга трафика
-CREATE TABLE Queue_list (
+CREATE TABLE queue_list (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 queue_name VARCHAR(20) NOT NULL,
 queue_name VARCHAR(20) NOT NULL,
 Download INTEGER NOT NULL DEFAULT 0,
 Download INTEGER NOT NULL DEFAULT 0,
 Upload INTEGER NOT NULL DEFAULT 0
 Upload INTEGER NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE Queue_list IS 'Профили полосы пропускания для шейпинга трафика';
-COMMENT ON COLUMN Queue_list.Download IS 'Ограничение скорости скачивания в Кбит/с';
-COMMENT ON COLUMN Queue_list.Upload IS 'Ограничение скорости отдачи в Кбит/с';
+COMMENT ON TABLE queue_list IS 'Профили полосы пропускания для шейпинга трафика';
+COMMENT ON COLUMN queue_list.Download IS 'Ограничение скорости скачивания в Кбит/с';
+COMMENT ON COLUMN queue_list.Upload IS 'Ограничение скорости отдачи в Кбит/с';
 
 
 -- Удаленные syslog сообщения
 -- Удаленные syslog сообщения
 CREATE TABLE remote_syslog (
 CREATE TABLE remote_syslog (
@@ -425,7 +425,7 @@ COMMENT ON COLUMN subnets.hotspot IS 'Это публичная/гостевая
 COMMENT ON COLUMN subnets.notify IS 'Битовая маска для уведомлений: 1=email, 2=sms, 4=telegram';
 COMMENT ON COLUMN subnets.notify IS 'Битовая маска для уведомлений: 1=email, 2=sms, 4=telegram';
 
 
 -- Подробные логи трафика
 -- Подробные логи трафика
-CREATE TABLE Traffic_detail (
+CREATE TABLE traffic_detail (
 id BIGSERIAL PRIMARY KEY,
 id BIGSERIAL PRIMARY KEY,
 auth_id BIGINT,
 auth_id BIGINT,
 router_id INTEGER NOT NULL DEFAULT 0,
 router_id INTEGER NOT NULL DEFAULT 0,
@@ -438,23 +438,23 @@ dst_port INTEGER NOT NULL,
 bytes BIGINT NOT NULL,
 bytes BIGINT NOT NULL,
 pkt INTEGER NOT NULL DEFAULT 0
 pkt INTEGER NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE Traffic_detail IS 'Подробные записи потоков трафика (NetFlow)';
-COMMENT ON COLUMN Traffic_detail.proto IS 'Номер IP протокола';
-COMMENT ON COLUMN Traffic_detail.src_ip IS 'Исходный IP в виде целого числа';
-COMMENT ON COLUMN Traffic_detail.bytes IS 'Байтов переданно в этом потоке';
+COMMENT ON TABLE traffic_detail IS 'Подробные записи потоков трафика (NetFlow)';
+COMMENT ON COLUMN traffic_detail.proto IS 'Номер IP протокола';
+COMMENT ON COLUMN traffic_detail.src_ip IS 'Исходный IP в виде целого числа';
+COMMENT ON COLUMN traffic_detail.bytes IS 'Байтов переданно в этом потоке';
 
 
 -- Неизвестные MAC-адреса
 -- Неизвестные MAC-адреса
-CREATE TABLE Unknown_mac (
+CREATE TABLE unknown_mac (
 id BIGSERIAL PRIMARY KEY,
 id BIGSERIAL PRIMARY KEY,
 mac VARCHAR(12),
 mac VARCHAR(12),
 port_id BIGINT,
 port_id BIGINT,
 device_id INTEGER,
 device_id INTEGER,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
 );
 );
-COMMENT ON TABLE Unknown_mac IS 'Недавно обнаруженные неизвестные MAC-адреса';
+COMMENT ON TABLE unknown_mac IS 'Недавно обнаруженные неизвестные MAC-адреса';
 
 
 -- Записи авторизации пользователей
 -- Записи авторизации пользователей
-CREATE TABLE User_auth (
+CREATE TABLE user_auth (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 user_id BIGINT NOT NULL DEFAULT 0,
 user_id BIGINT NOT NULL DEFAULT 0,
 ou_id INTEGER,
 ou_id INTEGER,
@@ -486,7 +486,7 @@ month_quota INTEGER NOT NULL DEFAULT 0,
 device_model_id INTEGER DEFAULT 87,
 device_model_id INTEGER DEFAULT 87,
 firmware VARCHAR(100),
 firmware VARCHAR(100),
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
-"client-id" VARCHAR(250),
+client_id VARCHAR(250),
 nagios SMALLINT NOT NULL DEFAULT 0,
 nagios SMALLINT NOT NULL DEFAULT 0,
 nagios_status VARCHAR(10) NOT NULL DEFAULT '',
 nagios_status VARCHAR(10) NOT NULL DEFAULT '',
 nagios_handler VARCHAR(50) NOT NULL DEFAULT '',
 nagios_handler VARCHAR(50) NOT NULL DEFAULT '',
@@ -496,24 +496,24 @@ dhcp_changed SMALLINT NOT NULL DEFAULT 0,
 changed_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 changed_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 created_by VARCHAR(10)
 created_by VARCHAR(10)
 );
 );
-COMMENT ON TABLE User_auth IS 'Записи авторизации пользователей/устройств в сети';
-COMMENT ON COLUMN User_auth.enabled IS 'Эта авторизация активна';
-COMMENT ON COLUMN User_auth.dynamic IS 'Это динамически созданная запись';
-COMMENT ON COLUMN User_auth.day_quota IS 'Дневная квота трафика в байтах';
-COMMENT ON COLUMN User_auth.nagios IS 'Включить мониторинг Nagios для этого хоста';
+COMMENT ON TABLE user_auth IS 'Записи авторизации пользователей/устройств в сети';
+COMMENT ON COLUMN user_auth.enabled IS 'Эта авторизация активна';
+COMMENT ON COLUMN user_auth.dynamic IS 'Это динамически созданная запись';
+COMMENT ON COLUMN user_auth.day_quota IS 'Дневная квота трафика в байтах';
+COMMENT ON COLUMN user_auth.nagios IS 'Включить мониторинг Nagios для этого хоста';
 
 
 -- Алиасы авторизации пользователей
 -- Алиасы авторизации пользователей
-CREATE TABLE User_auth_alias (
+CREATE TABLE user_auth_alias (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
 auth_id INTEGER NOT NULL,
 auth_id INTEGER NOT NULL,
 alias VARCHAR(100),
 alias VARCHAR(100),
 description VARCHAR(100),
 description VARCHAR(100),
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
 );
 );
-COMMENT ON TABLE User_auth_alias IS 'Алиасы/DNS имена для записей авторизации';
+COMMENT ON TABLE user_auth_alias IS 'Алиасы/DNS имена для записей авторизации';
 
 
 -- Список пользователей
 -- Список пользователей
-CREATE TABLE User_list (
+CREATE TABLE user_list (
 id BIGSERIAL PRIMARY KEY,
 id BIGSERIAL PRIMARY KEY,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 login VARCHAR(255),
 login VARCHAR(255),
@@ -529,9 +529,9 @@ day_quota INTEGER NOT NULL DEFAULT 0,
 month_quota INTEGER NOT NULL DEFAULT 0,
 month_quota INTEGER NOT NULL DEFAULT 0,
 permanent SMALLINT NOT NULL DEFAULT 0
 permanent SMALLINT NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE User_list IS 'Учетные записи пользователей в системе';
-COMMENT ON COLUMN User_list.fio IS 'Фамилия Имя Отчество';
-COMMENT ON COLUMN User_list.permanent IS 'Это постоянный пользователь (не динамический)';
+COMMENT ON TABLE user_list IS 'Учетные записи пользователей в системе';
+COMMENT ON COLUMN user_list.fio IS 'Фамилия Имя Отчество';
+COMMENT ON COLUMN user_list.permanent IS 'Это постоянный пользователь (не динамический)';
 
 
 -- Сессии пользователей (веб-интерфейс)
 -- Сессии пользователей (веб-интерфейс)
 CREATE TABLE user_sessions (
 CREATE TABLE user_sessions (
@@ -547,7 +547,7 @@ is_active SMALLINT DEFAULT 1
 COMMENT ON TABLE user_sessions IS 'Сессии пользователей веб-интерфейса';
 COMMENT ON TABLE user_sessions IS 'Сессии пользователей веб-интерфейса';
 
 
 -- Статистика трафика пользователей
 -- Статистика трафика пользователей
-CREATE TABLE User_stats (
+CREATE TABLE user_stats (
 id BIGSERIAL PRIMARY KEY,
 id BIGSERIAL PRIMARY KEY,
 router_id BIGINT DEFAULT 0,
 router_id BIGINT DEFAULT 0,
 auth_id BIGINT NOT NULL DEFAULT 0,
 auth_id BIGINT NOT NULL DEFAULT 0,
@@ -555,10 +555,10 @@ timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 byte_in BIGINT NOT NULL DEFAULT 0,
 byte_in BIGINT NOT NULL DEFAULT 0,
 byte_out BIGINT NOT NULL DEFAULT 0
 byte_out BIGINT NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE User_stats IS 'Статистика трафика пользователей (агрегированная)';
+COMMENT ON TABLE user_stats IS 'Статистика трафика пользователей (агрегированная)';
 
 
 -- Подробная статистика пользователей
 -- Подробная статистика пользователей
-CREATE TABLE User_stats_full (
+CREATE TABLE user_stats_full (
 id BIGSERIAL PRIMARY KEY,
 id BIGSERIAL PRIMARY KEY,
 router_id BIGINT DEFAULT 0,
 router_id BIGINT DEFAULT 0,
 auth_id BIGINT NOT NULL DEFAULT 0,
 auth_id BIGINT NOT NULL DEFAULT 0,
@@ -569,8 +569,8 @@ pkt_in INTEGER,
 pkt_out INTEGER,
 pkt_out INTEGER,
 step SMALLINT NOT NULL DEFAULT 600
 step SMALLINT NOT NULL DEFAULT 600
 );
 );
-COMMENT ON TABLE User_stats_full IS 'Подробная статистика трафика пользователей';
-COMMENT ON COLUMN User_stats_full.step IS 'Интервал сбора статистики в секундах';
+COMMENT ON TABLE user_stats_full IS 'Подробная статистика трафика пользователей';
+COMMENT ON COLUMN user_stats_full.step IS 'Интервал сбора статистики в секундах';
 
 
 -- Временные переменные
 -- Временные переменные
 CREATE TABLE variables (
 CREATE TABLE variables (
@@ -597,19 +597,19 @@ version VARCHAR(10) NOT NULL DEFAULT '2.4.14'
 COMMENT ON TABLE version IS 'Информация о версии системы';
 COMMENT ON TABLE version IS 'Информация о версии системы';
 
 
 -- Статистика WAN интерфейсов
 -- Статистика WAN интерфейсов
-CREATE TABLE Wan_stats (
+CREATE TABLE wan_stats (
 id SERIAL PRIMARY KEY,
 id SERIAL PRIMARY KEY,
-time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 router_id INTEGER,
 router_id INTEGER,
 interface_id INTEGER,
 interface_id INTEGER,
-"in" BIGINT NOT NULL DEFAULT 0,
-"out" BIGINT NOT NULL DEFAULT 0,
+bytes_in BIGINT NOT NULL DEFAULT 0,
+bytes_out BIGINT NOT NULL DEFAULT 0,
 forward_in BIGINT NOT NULL DEFAULT 0,
 forward_in BIGINT NOT NULL DEFAULT 0,
 forward_out BIGINT NOT NULL DEFAULT 0
 forward_out BIGINT NOT NULL DEFAULT 0
 );
 );
-COMMENT ON TABLE Wan_stats IS 'Статистика трафика WAN интерфейсов';
-COMMENT ON COLUMN Wan_stats."in" IS 'Байтов получено на WAN интерфейсе';
-COMMENT ON COLUMN Wan_stats."out" IS 'Байтов отправлено с WAN интерфейса';
+COMMENT ON TABLE wan_stats IS 'Статистика трафика WAN интерфейсов';
+COMMENT ON COLUMN wan_stats.bytes_in IS 'Байтов получено на WAN интерфейсе';
+COMMENT ON COLUMN wan_stats.bytes_out IS 'Байтов отправлено с WAN интерфейса';
 
 
 -- Журнал активности системы
 -- Журнал активности системы
 CREATE TABLE worklog (
 CREATE TABLE worklog (
@@ -648,25 +648,25 @@ CREATE INDEX idx_ou_ou_name_gin ON OU USING GIN(ou_name gin_trgm_ops);
 CREATE INDEX idx_subnets_ip_int_start ON subnets(ip_int_start, ip_int_stop);
 CREATE INDEX idx_subnets_ip_int_start ON subnets(ip_int_start, ip_int_stop);
 CREATE INDEX idx_subnets_dhcp ON subnets(dhcp, office, hotspot, static);
 CREATE INDEX idx_subnets_dhcp ON subnets(dhcp, office, hotspot, static);
 
 
-CREATE INDEX idx_traffic_detail_src ON Traffic_detail(auth_id, timestamp, router_id, src_ip);
-CREATE INDEX idx_traffic_detail_dst ON Traffic_detail(auth_id, timestamp, router_id, dst_ip);
+CREATE INDEX idx_traffic_detail_src ON traffic_detail(auth_id, timestamp, router_id, src_ip);
+CREATE INDEX idx_traffic_detail_dst ON traffic_detail(auth_id, timestamp, router_id, dst_ip);
 
 
-CREATE INDEX idx_unknown_mac_timestamp ON Unknown_mac(timestamp, device_id, port_id, mac);
+CREATE INDEX idx_unknown_mac_timestamp ON unknown_mac(timestamp, device_id, port_id, mac);
 
 
-CREATE INDEX idx_user_auth_main ON User_auth(id, user_id, ip_int, mac, ip, deleted);
-CREATE INDEX idx_user_auth_deleted ON User_auth(deleted) WHERE deleted = 0;
-CREATE INDEX idx_user_auth_ou_id ON User_auth(ou_id);
+CREATE INDEX idx_user_auth_main ON user_auth(id, user_id, ip_int, mac, ip, deleted);
+CREATE INDEX idx_user_auth_deleted ON user_auth(deleted) WHERE deleted = 0;
+CREATE INDEX idx_user_auth_ou_id ON user_auth(ou_id);
 
 
-CREATE INDEX idx_user_list_main ON User_list(id, ou_id, enabled, blocked, deleted);
+CREATE INDEX idx_user_list_main ON user_list(id, ou_id, enabled, blocked, deleted);
 
 
 CREATE INDEX idx_user_sessions_session_id ON user_sessions(session_id);
 CREATE INDEX idx_user_sessions_session_id ON user_sessions(session_id);
 CREATE INDEX idx_user_sessions_user_id ON user_sessions(user_id);
 CREATE INDEX idx_user_sessions_user_id ON user_sessions(user_id);
 CREATE INDEX idx_user_sessions_is_active ON user_sessions(is_active) WHERE is_active = 1;
 CREATE INDEX idx_user_sessions_is_active ON user_sessions(is_active) WHERE is_active = 1;
 
 
-CREATE INDEX idx_user_stats_timestamp ON User_stats(timestamp, auth_id, router_id);
-CREATE INDEX idx_user_stats_full_timestamp ON User_stats_full(timestamp, auth_id, router_id);
+CREATE INDEX idx_user_stats_timestamp ON user_stats(timestamp, auth_id, router_id);
+CREATE INDEX idx_user_stats_full_timestamp ON user_stats_full(timestamp, auth_id, router_id);
 
 
-CREATE INDEX idx_wan_stats_time ON Wan_stats(time, router_id, interface_id);
+CREATE INDEX idx_wan_stats_time ON wan_stats(time, router_id, interface_id);
 
 
 CREATE INDEX idx_worklog_customer ON worklog(customer, level, timestamp);
 CREATE INDEX idx_worklog_customer ON worklog(customer, level, timestamp);
 CREATE INDEX idx_worklog_timestamp ON worklog(level, timestamp);
 CREATE INDEX idx_worklog_timestamp ON worklog(level, timestamp);

+ 26 - 26
docs/databases/postgres/ru/data.sql

@@ -1,15 +1,15 @@
 -- Импорт данных в PostgreSQL для русской локали
 -- Импорт данных в PostgreSQL для русской локали
 
 
 -- ACL (Access Control List)
 -- ACL (Access Control List)
-INSERT INTO acl (id, name, "description.english", "description.russian") 
+INSERT INTO acl (id, name, description_english, description_russian) 
 VALUES 
 VALUES 
 (1, 'Full access', 'Full access', 'Полный доступ'),
 (1, 'Full access', 'Full access', 'Полный доступ'),
 (2, 'Operator', 'Editing parameters that are not related to access rights', 'Редактирование параметров, не связанных с правами доступа'),
 (2, 'Operator', 'Editing parameters that are not related to access rights', 'Редактирование параметров, не связанных с правами доступа'),
 (3, 'View only', 'View only', 'Только просмотр')
 (3, 'View only', 'View only', 'Только просмотр')
 ON CONFLICT (id) DO UPDATE SET
 ON CONFLICT (id) DO UPDATE SET
     name = EXCLUDED.name,
     name = EXCLUDED.name,
-    "description.english" = EXCLUDED."description.english",
-    "description.russian" = EXCLUDED."description.russian";
+    description_english = EXCLUDED.description_english,
+    description_russian = EXCLUDED.description_russian;
 
 
 -- Buildings
 -- Buildings
 INSERT INTO building (id, name, comment)
 INSERT INTO building (id, name, comment)
@@ -19,7 +19,7 @@ ON CONFLICT (id) DO UPDATE SET
     comment = EXCLUDED.comment;
     comment = EXCLUDED.comment;
 
 
 -- Configuration options
 -- Configuration options
-INSERT INTO config_options (id, option_name, "description.russian", "description.english", draft, uniq, type, default_value, min_value, max_value)
+INSERT INTO config_options (id, option_name, description_russian, description_english, draft, uniq, type, default_value, min_value, max_value)
 VALUES
 VALUES
 (1, 'KB', 'Еденица измерения трафика - Килобайт (0) или кибибайт (1,default)', 'Traffic measurement unit - Kilobyte (1000b) or kibibyte (1024b,default)', 0, 1, 'bool', '1024', 0, 1),
 (1, 'KB', 'Еденица измерения трафика - Килобайт (0) или кибибайт (1,default)', 'Traffic measurement unit - Kilobyte (1000b) or kibibyte (1024b,default)', 0, 1, 'bool', '1024', 0, 1),
 (3, 'dns server', 'ip-адрес DNS-сервера', 'DNS server ip address', 0, 1, 'text', '127.0.0.1', 0, 0),
 (3, 'dns server', 'ip-адрес DNS-сервера', 'DNS server ip address', 0, 1, 'text', '127.0.0.1', 0, 0),
@@ -75,8 +75,8 @@ VALUES
 (73, 'check_computer_exists', 'Проверять существование компьютера в домене перед обновлением DNS по DHCP запросу', 'Verify the existence of a computer in the domain before updating DNS by DHCP request', 0, 1, 'bool', '1', 0, 0)
 (73, 'check_computer_exists', 'Проверять существование компьютера в домене перед обновлением DNS по DHCP запросу', 'Verify the existence of a computer in the domain before updating DNS by DHCP request', 0, 1, 'bool', '1', 0, 0)
 ON CONFLICT (id) DO UPDATE SET
 ON CONFLICT (id) DO UPDATE SET
     option_name = EXCLUDED.option_name,
     option_name = EXCLUDED.option_name,
-    "description.russian" = EXCLUDED."description.russian",
-    "description.english" = EXCLUDED."description.english",
+    description_russian = EXCLUDED.description_russian,
+    description_english = EXCLUDED.description_english,
     draft = EXCLUDED.draft,
     draft = EXCLUDED.draft,
     uniq = EXCLUDED.uniq,
     uniq = EXCLUDED.uniq,
     type = EXCLUDED.type,
     type = EXCLUDED.type,
@@ -115,7 +115,7 @@ ON CONFLICT (id) DO UPDATE SET
 
 
 -- System users/administrators
 -- System users/administrators
 -- В PostgreSQL нет аналога ON DUPLICATE KEY UPDATE, используем ON CONFLICT
 -- В PostgreSQL нет аналога ON DUPLICATE KEY UPDATE, используем ON CONFLICT
-INSERT INTO Customers (id, Login, comment, password, api_key, rights)
+INSERT INTO customers (id, Login, comment, password, api_key, rights)
 VALUES (1, 'admin', 'Administrator', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31', 1)
 VALUES (1, 'admin', 'Administrator', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31', 1)
 ON CONFLICT (id) DO UPDATE SET
 ON CONFLICT (id) DO UPDATE SET
     Login = EXCLUDED.Login,
     Login = EXCLUDED.Login,
@@ -250,7 +250,7 @@ ON CONFLICT (id) DO UPDATE SET
     nagios_template = EXCLUDED.nagios_template;
     nagios_template = EXCLUDED.nagios_template;
 
 
 -- Device types
 -- Device types
-INSERT INTO device_types (id, "name.russian", "name.english")
+INSERT INTO device_types (id, name_russian, name_english)
 VALUES
 VALUES
 (0, 'Роутер', 'Router'),
 (0, 'Роутер', 'Router'),
 (1, 'Свич', 'Switch'),
 (1, 'Свич', 'Switch'),
@@ -259,8 +259,8 @@ VALUES
 (4, 'Точка доступа', 'WiFi Access Point'),
 (4, 'Точка доступа', 'WiFi Access Point'),
 (5, 'Сетевое устройство', 'Network device')
 (5, 'Сетевое устройство', 'Network device')
 ON CONFLICT (id) DO UPDATE SET
 ON CONFLICT (id) DO UPDATE SET
-    "name.russian" = EXCLUDED."name.russian",
-    "name.english" = EXCLUDED."name.english";
+    name_russian = EXCLUDED.name_russian,
+    name_english = EXCLUDED.name_english;
 
 
 -- Filter instances
 -- Filter instances
 INSERT INTO filter_instances (id, name, comment)
 INSERT INTO filter_instances (id, name, comment)
@@ -270,7 +270,7 @@ ON CONFLICT (id) DO UPDATE SET
     comment = EXCLUDED.comment;
     comment = EXCLUDED.comment;
 
 
 -- Filter groups (русские названия)
 -- Filter groups (русские названия)
-INSERT INTO Group_list (id, instance_id, group_name, comment)
+INSERT INTO group_list (id, instance_id, group_name, comment)
 VALUES
 VALUES
 (0, 1, 'default', 'Всё запрещено'),
 (0, 1, 'default', 'Всё запрещено'),
 (1, 1, 'Allow all', 'Разрешено всё'),
 (1, 1, 'Allow all', 'Разрешено всё'),
@@ -314,7 +314,7 @@ ON CONFLICT (id) DO UPDATE SET
     parent_id = EXCLUDED.parent_id;
     parent_id = EXCLUDED.parent_id;
 
 
 -- Traffic shaping queues
 -- Traffic shaping queues
-INSERT INTO Queue_list (id, queue_name, Download, Upload)
+INSERT INTO queue_list (id, queue_name, Download, Upload)
 VALUES
 VALUES
 (0, 'unlimited', 0, 0),
 (0, 'unlimited', 0, 0),
 (1, '2M/2M', 2048, 2048),
 (1, '2M/2M', 2048, 2048),
@@ -415,7 +415,7 @@ ON CONFLICT (id) DO UPDATE SET
     name = EXCLUDED.name;
     name = EXCLUDED.name;
 
 
 -- Filter rules list
 -- Filter rules list
-INSERT INTO Filter_list (id, name, comment, proto, dst, dstport, srcport, type)
+INSERT INTO filter_list (id, name, comment, proto, dst, dstport, srcport, type)
 VALUES
 VALUES
 (1, 'pop3', NULL, 'tcp', '0/0', '110', NULL, 0),
 (1, 'pop3', NULL, 'tcp', '0/0', '110', NULL, 0),
 (3, 'http', NULL, 'tcp', '0/0', '80', NULL, 0),
 (3, 'http', NULL, 'tcp', '0/0', '80', NULL, 0),
@@ -459,7 +459,7 @@ ON CONFLICT (id) DO UPDATE SET
     type = EXCLUDED.type;
     type = EXCLUDED.type;
 
 
 -- Filter group assignments
 -- Filter group assignments
-INSERT INTO Group_filters (id, group_id, filter_id, "order", action)
+INSERT INTO group_filters (id, group_id, filter_id, rule_order, action)
 VALUES
 VALUES
 (1, 2, 90, 1, 1),
 (1, 2, 90, 1, 1),
 (2, 2, 91, 2, 1),
 (2, 2, 91, 2, 1),
@@ -479,12 +479,12 @@ VALUES
 ON CONFLICT (id) DO UPDATE SET
 ON CONFLICT (id) DO UPDATE SET
     group_id = EXCLUDED.group_id,
     group_id = EXCLUDED.group_id,
     filter_id = EXCLUDED.filter_id,
     filter_id = EXCLUDED.filter_id,
-    "order" = EXCLUDED."order",
+    rule_order = EXCLUDED.rule_order,
     action = EXCLUDED.action;
     action = EXCLUDED.action;
 
 
 -- System version
 -- System version
 INSERT INTO version (id, version)
 INSERT INTO version (id, version)
-VALUES (1, '2.9.1')
+VALUES (1, '3.0.1')
 ON CONFLICT (id) DO UPDATE SET
 ON CONFLICT (id) DO UPDATE SET
     version = EXCLUDED.version;
     version = EXCLUDED.version;
 
 
@@ -493,17 +493,17 @@ SELECT setval(pg_get_serial_sequence('acl', 'id'), COALESCE((SELECT MAX(id) FROM
 SELECT setval(pg_get_serial_sequence('building', 'id'), COALESCE((SELECT MAX(id) FROM building), 0) + 1);
 SELECT setval(pg_get_serial_sequence('building', 'id'), COALESCE((SELECT MAX(id) FROM building), 0) + 1);
 SELECT setval(pg_get_serial_sequence('config_options', 'id'), COALESCE((SELECT MAX(id) FROM config_options), 0) + 1);
 SELECT setval(pg_get_serial_sequence('config_options', 'id'), COALESCE((SELECT MAX(id) FROM config_options), 0) + 1);
 SELECT setval(pg_get_serial_sequence('config', 'id'), COALESCE((SELECT MAX(id) FROM config), 0) + 1);
 SELECT setval(pg_get_serial_sequence('config', 'id'), COALESCE((SELECT MAX(id) FROM config), 0) + 1);
-SELECT setval(pg_get_serial_sequence('Customers', 'id'), COALESCE((SELECT MAX(id) FROM Customers), 0) + 1);
+SELECT setval(pg_get_serial_sequence('customers', 'id'), COALESCE((SELECT MAX(id) FROM customers), 0) + 1);
 SELECT setval(pg_get_serial_sequence('device_models', 'id'), COALESCE((SELECT MAX(id) FROM device_models), 0) + 1);
 SELECT setval(pg_get_serial_sequence('device_models', 'id'), COALESCE((SELECT MAX(id) FROM device_models), 0) + 1);
 SELECT setval(pg_get_serial_sequence('device_types', 'id'), COALESCE((SELECT MAX(id) FROM device_types), 0) + 1);
 SELECT setval(pg_get_serial_sequence('device_types', 'id'), COALESCE((SELECT MAX(id) FROM device_types), 0) + 1);
 SELECT setval(pg_get_serial_sequence('filter_instances', 'id'), COALESCE((SELECT MAX(id) FROM filter_instances), 0) + 1);
 SELECT setval(pg_get_serial_sequence('filter_instances', 'id'), COALESCE((SELECT MAX(id) FROM filter_instances), 0) + 1);
-SELECT setval(pg_get_serial_sequence('Group_list', 'id'), COALESCE((SELECT MAX(id) FROM Group_list), 0) + 1);
+SELECT setval(pg_get_serial_sequence('group_list', 'id'), COALESCE((SELECT MAX(id) FROM group_list), 0) + 1);
 SELECT setval(pg_get_serial_sequence('OU', 'id'), COALESCE((SELECT MAX(id) FROM OU), 0) + 1);
 SELECT setval(pg_get_serial_sequence('OU', 'id'), COALESCE((SELECT MAX(id) FROM OU), 0) + 1);
-SELECT setval(pg_get_serial_sequence('Queue_list', 'id'), COALESCE((SELECT MAX(id) FROM Queue_list), 0) + 1);
+SELECT setval(pg_get_serial_sequence('queue_list', 'id'), COALESCE((SELECT MAX(id) FROM queue_list), 0) + 1);
 SELECT setval(pg_get_serial_sequence('subnets', 'id'), COALESCE((SELECT MAX(id) FROM subnets), 0) + 1);
 SELECT setval(pg_get_serial_sequence('subnets', 'id'), COALESCE((SELECT MAX(id) FROM subnets), 0) + 1);
 SELECT setval(pg_get_serial_sequence('vendors', 'id'), COALESCE((SELECT MAX(id) FROM vendors), 0) + 1);
 SELECT setval(pg_get_serial_sequence('vendors', 'id'), COALESCE((SELECT MAX(id) FROM vendors), 0) + 1);
-SELECT setval(pg_get_serial_sequence('Filter_list', 'id'), COALESCE((SELECT MAX(id) FROM Filter_list), 0) + 1);
-SELECT setval(pg_get_serial_sequence('Group_filters', 'id'), COALESCE((SELECT MAX(id) FROM Group_filters), 0) + 1);
+SELECT setval(pg_get_serial_sequence('filter_list', 'id'), COALESCE((SELECT MAX(id) FROM filter_list), 0) + 1);
+SELECT setval(pg_get_serial_sequence('group_filters', 'id'), COALESCE((SELECT MAX(id) FROM group_filters), 0) + 1);
 
 
 -- Информация о завершении импорта
 -- Информация о завершении импорта
 DO $$
 DO $$
@@ -515,16 +515,16 @@ BEGIN
     RAISE NOTICE '  - building: %', (SELECT COUNT(*) FROM building);
     RAISE NOTICE '  - building: %', (SELECT COUNT(*) FROM building);
     RAISE NOTICE '  - config_options: %', (SELECT COUNT(*) FROM config_options);
     RAISE NOTICE '  - config_options: %', (SELECT COUNT(*) FROM config_options);
     RAISE NOTICE '  - config: %', (SELECT COUNT(*) FROM config);
     RAISE NOTICE '  - config: %', (SELECT COUNT(*) FROM config);
-    RAISE NOTICE '  - Customers: %', (SELECT COUNT(*) FROM Customers);
+    RAISE NOTICE '  - customers: %', (SELECT COUNT(*) FROM customers);
     RAISE NOTICE '  - device_models: %', (SELECT COUNT(*) FROM device_models);
     RAISE NOTICE '  - device_models: %', (SELECT COUNT(*) FROM device_models);
     RAISE NOTICE '  - device_types: %', (SELECT COUNT(*) FROM device_types);
     RAISE NOTICE '  - device_types: %', (SELECT COUNT(*) FROM device_types);
     RAISE NOTICE '  - filter_instances: %', (SELECT COUNT(*) FROM filter_instances);
     RAISE NOTICE '  - filter_instances: %', (SELECT COUNT(*) FROM filter_instances);
-    RAISE NOTICE '  - Group_list: %', (SELECT COUNT(*) FROM Group_list);
+    RAISE NOTICE '  - group_list: %', (SELECT COUNT(*) FROM group_list);
     RAISE NOTICE '  - OU: %', (SELECT COUNT(*) FROM OU);
     RAISE NOTICE '  - OU: %', (SELECT COUNT(*) FROM OU);
-    RAISE NOTICE '  - Queue_list: %', (SELECT COUNT(*) FROM Queue_list);
+    RAISE NOTICE '  - queue_list: %', (SELECT COUNT(*) FROM queue_list);
     RAISE NOTICE '  - subnets: %', (SELECT COUNT(*) FROM subnets);
     RAISE NOTICE '  - subnets: %', (SELECT COUNT(*) FROM subnets);
     RAISE NOTICE '  - vendors: %', (SELECT COUNT(*) FROM vendors);
     RAISE NOTICE '  - vendors: %', (SELECT COUNT(*) FROM vendors);
-    RAISE NOTICE '  - Filter_list: %', (SELECT COUNT(*) FROM Filter_list);
-    RAISE NOTICE '  - Group_filters: %', (SELECT COUNT(*) FROM Group_filters);
+    RAISE NOTICE '  - filter_list: %', (SELECT COUNT(*) FROM filter_list);
+    RAISE NOTICE '  - group_filters: %', (SELECT COUNT(*) FROM group_filters);
     RAISE NOTICE '  - version: %', (SELECT COUNT(*) FROM version);
     RAISE NOTICE '  - version: %', (SELECT COUNT(*) FROM version);
 END $$;
 END $$;

+ 1 - 1
docs/dhcpd/print-dhcpd.pl

@@ -70,7 +70,7 @@ if (! -d "$dir_name" ) { mkpath($dir_name); }
 if (! -d "$new_dir" ) { mkpath($new_dir); }
 if (! -d "$new_dir" ) { mkpath($new_dir); }
 
 
 #get userid list
 #get userid list
-my $sSQL="SELECT id,ip,ip_int,mac,comments,dns_name FROM User_auth where dhcp=1 and deleted=0 and ou_id !=".$default_user_ou_id." and ou_id !=".$default_hotspot_ou_id." ORDER by ip_int";
+my $sSQL="SELECT id,ip,ip_int,mac,comments,dns_name FROM user_auth where dhcp=1 and deleted=0 and ou_id !=".$default_user_ou_id." and ou_id !=".$default_hotspot_ou_id." ORDER by ip_int";
 
 
 my @users = get_records_sql($dbh,$sSQL);
 my @users = get_records_sql($dbh,$sSQL);
 
 

+ 1 - 1
docs/dhcpd/print-dhcpd2.pl

@@ -70,7 +70,7 @@ if (! -d "$dir_name" ) { mkpath($dir_name); }
 if (! -d "$new_dir" ) { mkpath($new_dir); }
 if (! -d "$new_dir" ) { mkpath($new_dir); }
 
 
 #get userid list
 #get userid list
-my $sSQL="SELECT id,ip,ip_int,mac,comments,dns_name FROM User_auth where dhcp=1 and deleted=0 and ou_id !=".$default_user_ou_id." and ou_id !=".$default_hotspot_ou_id." ORDER by ip_int";
+my $sSQL="SELECT id,ip,ip_int,mac,comments,dns_name FROM user_auth where dhcp=1 and deleted=0 and ou_id !=".$default_user_ou_id." and ou_id !=".$default_hotspot_ou_id." ORDER by ip_int";
 
 
 my @users = get_records_sql($dbh,$sSQL);
 my @users = get_records_sql($dbh,$sSQL);
 
 

+ 10 - 10
docs/iptables/parse_ulog.pl

@@ -52,7 +52,7 @@ my $users = new Net::Patricia;
 InitSubnets();
 InitSubnets();
 
 
 #get userid list
 #get userid list
-my $user_auth_list = $dbh->prepare( "SELECT id,ip,user_id,save_traf FROM User_auth where deleted=0 ORDER by user_id,ip" );
+my $user_auth_list = $dbh->prepare( "SELECT id,ip,user_id,save_traf FROM user_auth where deleted=0 ORDER by user_id,ip" );
 if ( !defined $user_auth_list ) { die "Cannot prepare statement: $DBI::errstr\n"; }
 if ( !defined $user_auth_list ) { die "Cannot prepare statement: $DBI::errstr\n"; }
 
 
 $user_auth_list->execute;
 $user_auth_list->execute;
@@ -138,7 +138,7 @@ if ($office_networks->match_string($l_src_ip)) {
         $stats{line}{user}++;
         $stats{line}{user}++;
         $stats{pkt}{user_out}+=$l_packets;
         $stats{pkt}{user_out}+=$l_packets;
         if ($save_detail and $user_stats{$out_user}{save_traf}) {
         if ($save_detail and $user_stats{$out_user}{save_traf}) {
-            my $dSQL="INSERT INTO Traffic_detail (auth_id,router_id,timestamp,proto,src_ip,dst_ip,src_port,dst_port,bytes,pkt) VALUES($out_user,$router_id,$dbtime,'$l_proto',$l_src_ip_aton,$l_dst_ip_aton,'$l_src_port','$l_dst_port','$l_bytes','$l_packets')";
+            my $dSQL="INSERT INTO traffic_detail (auth_id,router_id,timestamp,proto,src_ip,dst_ip,src_port,dst_port,bytes,pkt) VALUES($out_user,$router_id,$dbtime,'$l_proto',$l_src_ip_aton,$l_dst_ip_aton,'$l_src_port','$l_dst_port','$l_bytes','$l_packets')";
             push (@batch_sql_traf,$dSQL);
             push (@batch_sql_traf,$dSQL);
             }
             }
         }
         }
@@ -155,7 +155,7 @@ if ($office_networks->match_string($l_dst_ip)) {
         $stats{pkt}{user_in}+=$l_packets;
         $stats{pkt}{user_in}+=$l_packets;
         $user_found = 1;
         $user_found = 1;
         if ($save_detail and $user_stats{$in_user}{save_traf}) {
         if ($save_detail and $user_stats{$in_user}{save_traf}) {
-            my $dSQL="INSERT INTO Traffic_detail (auth_id,router_id,timestamp,proto,src_ip,dst_ip,src_port,dst_port,bytes,pkt) VALUES($in_user,$router_id,$dbtime,'$l_proto',$l_src_ip_aton,$l_dst_ip_aton,'$l_src_port','$l_dst_port','$l_bytes','$l_packets')";
+            my $dSQL="INSERT INTO traffic_detail (auth_id,router_id,timestamp,proto,src_ip,dst_ip,src_port,dst_port,bytes,pkt) VALUES($in_user,$router_id,$dbtime,'$l_proto',$l_src_ip_aton,$l_dst_ip_aton,'$l_src_port','$l_dst_port','$l_bytes','$l_packets')";
             push (@batch_sql_traf,$dSQL);
             push (@batch_sql_traf,$dSQL);
             }
             }
         }
         }
@@ -195,7 +195,7 @@ $user_ip_aton=StrToIp($user_ip);
 my $auth_id=new_auth($dbh,$user_ip);
 my $auth_id=new_auth($dbh,$user_ip);
 next if (!$auth_id);
 next if (!$auth_id);
 
 
-my $new_user = get_record_sql($dbh,"SELECT * FROM User_auth WHERE id=$auth_id");
+my $new_user = get_record_sql($dbh,"SELECT * FROM user_auth WHERE id=$auth_id");
 
 
 $users->add_string($user_ip,$auth_id);
 $users->add_string($user_ip,$auth_id);
 $user_stats{$auth_id}{net}=$user_ip;
 $user_stats{$auth_id}{net}=$user_ip;
@@ -210,7 +210,7 @@ db_log_info($dbh,"Added user_auth id: $auth_id ip: $user_ip user_id: $new_user->
 
 
 if ($auth_id) {
 if ($auth_id) {
         if ($save_detail) {
         if ($save_detail) {
-            my $dSQL="INSERT INTO Traffic_detail (auth_id,router_id,timestamp,proto,src_ip,dst_ip,src_port,dst_port,bytes) VALUES($auth_id,$router_id,$dbtime,'$l_proto',$l_src_ip_aton,$l_dst_ip_aton,'$l_src_port','$l_dst_port','$l_bytes')";
+            my $dSQL="INSERT INTO traffic_detail (auth_id,router_id,timestamp,proto,src_ip,dst_ip,src_port,dst_port,bytes) VALUES($auth_id,$router_id,$dbtime,'$l_proto',$l_src_ip_aton,$l_dst_ip_aton,'$l_src_port','$l_dst_port','$l_bytes')";
             push (@batch_sql_traf,$dSQL);
             push (@batch_sql_traf,$dSQL);
             }
             }
         if ($l_src_ip eq $user_ip) {
         if ($l_src_ip eq $user_ip) {
@@ -244,17 +244,17 @@ next if (!$user_stats{$row}{htime});
 
 
 #current stats
 #current stats
 
 
-my $tSQL="INSERT INTO User_stats_full (timestamp,auth_id,router_id,byte_in,byte_out,pkt_in,pkt_out,step) VALUES($flow_date,'$user_stats{$row}{id}','$router_id','$user_stats{$row}{in}','$user_stats{$row}{out}','$user_stats{$row}{pkt_in}','$user_stats{$row}{pkt_out}','$timeshift')";
+my $tSQL="INSERT INTO user_stats_full (timestamp,auth_id,router_id,byte_in,byte_out,pkt_in,pkt_out,step) VALUES($flow_date,'$user_stats{$row}{id}','$router_id','$user_stats{$row}{in}','$user_stats{$row}{out}','$user_stats{$row}{pkt_in}','$user_stats{$row}{pkt_out}','$timeshift')";
 push (@batch_sql_traf,$tSQL);
 push (@batch_sql_traf,$tSQL);
 
 
 #hour stats
 #hour stats
 
 
 # get current stats
 # get current stats
-my $sql = "SELECT id, byte_in, byte_out FROM User_stats
-WHERE `timestamp`>=$hour_date1 AND `timestamp`<$hour_date2 AND router_id=$router_id AND auth_id=$user_stats{$row}{id}";
+my $sql = "SELECT id, byte_in, byte_out FROM user_stats
+WHERE ts>=$hour_date1 AND ts<$hour_date2 AND router_id=$router_id AND auth_id=$user_stats{$row}{id}";
 my $hour_stat = get_record_sql($dbh,$sql);
 my $hour_stat = get_record_sql($dbh,$sql);
 if (!$hour_stat) {
 if (!$hour_stat) {
-    my $dSQL="INSERT INTO User_stats (timestamp,auth_id,router_id,byte_in,byte_out,pkt_in,pkt_out) VALUES($user_stats{$row}{htime},'$user_stats{$row}{id}','$router_id','$user_stats{$row}{in}','$user_stats{$row}{out}','$user_stats{$row}{pkt_in}','$user_stats{$row}{pkt_out}')";
+    my $dSQL="INSERT INTO user_stats (timestamp,auth_id,router_id,byte_in,byte_out,pkt_in,pkt_out) VALUES($user_stats{$row}{htime},'$user_stats{$row}{id}','$router_id','$user_stats{$row}{in}','$user_stats{$row}{out}','$user_stats{$row}{pkt_in}','$user_stats{$row}{pkt_out}')";
     push (@batch_sql_traf,$dSQL);
     push (@batch_sql_traf,$dSQL);
     next;
     next;
     }
     }
@@ -262,7 +262,7 @@ if (!$hour_stat->{byte_in}) { $hour_stat->{byte_in}=0; }
 if (!$hour_stat->{byte_out}) { $hour_stat->{byte_out}=0; }
 if (!$hour_stat->{byte_out}) { $hour_stat->{byte_out}=0; }
 $hour_stat->{byte_in} += $user_stats{$row}{in};
 $hour_stat->{byte_in} += $user_stats{$row}{in};
 $hour_stat->{byte_out} += $user_stats{$row}{out};
 $hour_stat->{byte_out} += $user_stats{$row}{out};
-my $ssql="UPDATE User_stats SET byte_in='".$hour_stat->{byte_in}."', byte_out='".$hour_stat->{byte_out}."' WHERE id=".$hour_stat->{id};
+my $ssql="UPDATE user_stats SET byte_in='".$hour_stat->{byte_in}."', byte_out='".$hour_stat->{byte_out}."' WHERE id=".$hour_stat->{id};
 my $res = $dbh->do($ssql);
 my $res = $dbh->do($ssql);
 }
 }
 
 

+ 15 - 15
docs/iptables/sync_iptables.pl

@@ -67,15 +67,15 @@ if ($connected_users_only) {
 db_log_verbose($dbh,"Sync user state at router $router_name started.");
 db_log_verbose($dbh,"Sync user state at router $router_name started.");
 
 
 #get userid list
 #get userid list
-my $user_auth_sql="SELECT User_auth.ip, User_auth.filter_group_id, User_auth.queue_id, User_auth.id
-FROM User_auth, User_list
-WHERE User_auth.user_id = User_list.id
-AND User_auth.deleted =0
-AND User_auth.enabled =1
-AND User_auth.blocked =0
-AND User_list.blocked =0
-AND User_list.enabled =1
-AND User_auth.ou_id <> $default_hotspot_ou_id
+my $user_auth_sql="SELECT user_auth.ip, user_auth.filter_group_id, user_auth.queue_id, user_auth.id
+FROM user_auth, user_list
+WHERE user_auth.user_id = user_list.id
+AND user_auth.deleted =0
+AND user_auth.enabled =1
+AND user_auth.blocked =0
+AND user_list.blocked =0
+AND user_list.enabled =1
+AND user_auth.ou_id <> $default_hotspot_ou_id
 ORDER BY ip_int";
 ORDER BY ip_int";
 
 
 my @authlist_ref = get_records_sql($dbh,$user_auth_sql);
 my @authlist_ref = get_records_sql($dbh,$user_auth_sql);
@@ -102,7 +102,7 @@ log_debug("Users status:".Dumper(\%users));
 $lists{'group_all'}=1;
 $lists{'group_all'}=1;
 
 
 #get queue list
 #get queue list
-my @queuelist_ref = get_records_sql($dbh,"SELECT * FROM Queue_list");
+my @queuelist_ref = get_records_sql($dbh,"SELECT * FROM queue_list");
 
 
 my %queues;
 my %queues;
 foreach my $row (@queuelist_ref) {
 foreach my $row (@queuelist_ref) {
@@ -115,12 +115,12 @@ $queues{'queue_'.$row->{id}}{up}=$row->{Upload};
 
 
 log_debug("Queues status:".Dumper(\%queues));
 log_debug("Queues status:".Dumper(\%queues));
 
 
-my @filterlist_ref = get_records_sql($dbh,"SELECT * FROM Filter_list where type=0");
+my @filterlist_ref = get_records_sql($dbh,"SELECT * FROM filter_list where type=0");
 
 
 my %filters;
 my %filters;
 my %dyn_filters;
 my %dyn_filters;
 
 
-my $max_filter_rec = get_record_sql($dbh,"SELECT MAX(id) FROM Filter_list");
+my $max_filter_rec = get_record_sql($dbh,"SELECT MAX(id) FROM filter_list");
 my $max_filter_id = $max_filter_rec->{id};
 my $max_filter_id = $max_filter_rec->{id};
 
 
 my $dyn_filters_base = $max_filter_id+1000;
 my $dyn_filters_base = $max_filter_id+1000;
@@ -163,10 +163,10 @@ log_debug("Filters status:". Dumper(\%filters));
 log_debug("DNS-filters status:". Dumper(\%dyn_filters));
 log_debug("DNS-filters status:". Dumper(\%dyn_filters));
 
 
 #clean unused filter records
 #clean unused filter records
-do_sql($dbh,"DELETE FROM Group_filters WHERE group_id NOT IN (SELECT id FROM Group_list)");
-do_sql($dbh,"DELETE FROM Group_filters WHERE filter_id NOT IN (SELECT id FROM Filter_list)");
+do_sql($dbh,"DELETE FROM group_filters WHERE group_id NOT IN (SELECT id FROM group_list)");
+do_sql($dbh,"DELETE FROM group_filters WHERE filter_id NOT IN (SELECT id FROM filter_list)");
 
 
-my @grouplist_ref = get_records_sql($dbh,"SELECT `group_id`,`filter_id`,`order`,`action` FROM Group_filters ORDER BY Group_filters.group_id,Group_filters.order");
+my @grouplist_ref = get_records_sql($dbh,"SELECT group_id,filter_id,rule_order,action FROM group_filters ORDER BY group_filters.group_id,group_filters.rule_order");
 
 
 my %group_filters;
 my %group_filters;
 my $index=0;
 my $index=0;

+ 4 - 4
html/admin/customers/control-subnets-usage.php

@@ -34,22 +34,22 @@ foreach ( $t_subnets as $row ) {
     $all_ips = $row['ip_int_stop']-$row['ip_int_start']-3;
     $all_ips = $row['ip_int_stop']-$row['ip_int_start']-3;
     print "<td class=\"$cl\">".$all_ips."</td>\n";
     print "<td class=\"$cl\">".$all_ips."</td>\n";
 #used
 #used
-    $used_all = get_count_records($db_link,'User_auth','deleted=0 and ip_int>='.$row['ip_int_start'].' and ip_int<='.$row['ip_int_stop']);
+    $used_all = get_count_records($db_link,'user_auth','deleted=0 and ip_int>='.$row['ip_int_start'].' and ip_int<='.$row['ip_int_stop']);
     print "<td class=\"$cl\">".$used_all."</td>\n";
     print "<td class=\"$cl\">".$used_all."</td>\n";
     $free_all = $all_ips - $used_all;
     $free_all = $all_ips - $used_all;
     print "<td class=\"$cl\">".$free_all."</td>\n";
     print "<td class=\"$cl\">".$free_all."</td>\n";
     $dhcp_pool = $row['dhcp_stop']-$row['dhcp_start']+1;
     $dhcp_pool = $row['dhcp_stop']-$row['dhcp_start']+1;
     print "<td class=\"$cl\">".$dhcp_pool."</td>\n";
     print "<td class=\"$cl\">".$dhcp_pool."</td>\n";
 #used pool
 #used pool
-    $used_dhcp = get_count_records($db_link,'User_auth','deleted=0 and ip_int>='.$row['dhcp_start'].' and ip_int<='.$row['dhcp_stop']);
+    $used_dhcp = get_count_records($db_link,'user_auth','deleted=0 and ip_int>='.$row['dhcp_start'].' and ip_int<='.$row['dhcp_stop']);
     print "<td class=\"$cl\">".$used_dhcp."</td>\n";
     print "<td class=\"$cl\">".$used_dhcp."</td>\n";
     $free_dhcp = $dhcp_pool - $used_dhcp;
     $free_dhcp = $dhcp_pool - $used_dhcp;
     print "<td class=\"$cl\">".$free_dhcp."</td>\n";
     print "<td class=\"$cl\">".$free_dhcp."</td>\n";
     $free_static = $free_all -  $free_dhcp;
     $free_static = $free_all -  $free_dhcp;
     print "<td class=\"$cl\">".$free_static."</td>\n";
     print "<td class=\"$cl\">".$free_static."</td>\n";
-    $zombi = get_count_records($db_link,'User_auth','deleted=0 and ip_int>='.$row['ip_int_start'].' and ip_int<='.$row['ip_int_stop'].' and last_found<=(NOW() - INTERVAL '.$zombi_days.' DAY)');
+    $zombi = get_count_records($db_link,'user_auth','deleted=0 and ip_int>='.$row['ip_int_start'].' and ip_int<='.$row['ip_int_stop'].' and last_found<=(NOW() - INTERVAL '.$zombi_days.' DAY)');
     print "<td class=\"$cl\">".$zombi."</td>\n";
     print "<td class=\"$cl\">".$zombi."</td>\n";
-    $zombi = get_count_records($db_link,'User_auth','deleted=0 and ip_int>='.$row['dhcp_start'].' and ip_int<='.$row['dhcp_stop'].' and last_found<=(NOW() - INTERVAL '.$zombi_days.' DAY)');
+    $zombi = get_count_records($db_link,'user_auth','deleted=0 and ip_int>='.$row['dhcp_start'].' and ip_int<='.$row['dhcp_stop'].' and last_found<=(NOW() - INTERVAL '.$zombi_days.' DAY)');
     print "<td class=\"$cl\">".$zombi."</td>\n";
     print "<td class=\"$cl\">".$zombi."</td>\n";
     print "</tr>\n";
     print "</tr>\n";
     }
     }

+ 3 - 3
html/admin/customers/control.php

@@ -43,7 +43,7 @@ if (isset($_POST["refresh_nagios"]) and is_option($db_link, 40)) {
 }
 }
 
 
 if (isset($_POST["up_nagios"])) {
 if (isset($_POST["up_nagios"])) {
-    run_sql($db_link,"UPDATE User_auth SET nagios_status='UP'");
+    run_sql($db_link,"UPDATE user_auth SET nagios_status='UP'");
     run_sql($db_link,"UPDATE devices SET nagios_status='UP'");
     run_sql($db_link,"UPDATE devices SET nagios_status='UP'");
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
     exit;
@@ -74,14 +74,14 @@ if (isset($_POST["discovery2"]) and is_option($db_link, 41)) {
 }
 }
 
 
 if (!empty($_POST["save_traf_all"]) and $_POST["save_traf_all"]) {
 if (!empty($_POST["save_traf_all"]) and $_POST["save_traf_all"]) {
-    run_sql($db_link, 'Update User_auth SET save_traf=1');
+    run_sql($db_link, 'Update user_auth SET save_traf=1');
     LOG_INFO($db_link, "Enable save traffic for all!");
     LOG_INFO($db_link, "Enable save traffic for all!");
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
     exit;
 }
 }
 
 
 if (!empty($_POST["not_save_traf_all"]) and $_POST["not_save_traf_all"]) {
 if (!empty($_POST["not_save_traf_all"]) and $_POST["not_save_traf_all"]) {
-    run_sql($db_link, 'Update User_auth SET save_traf=0');
+    run_sql($db_link, 'Update user_auth SET save_traf=0');
     LOG_INFO($db_link, "Disable save traffic for all!");
     LOG_INFO($db_link, "Disable save traffic for all!");
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
     exit;

+ 2 - 2
html/admin/customers/editcustom.php

@@ -16,7 +16,7 @@ if (isset($_POST["edituser"])) {
         $new['api_key'] = $_POST["api_key"];
         $new['api_key'] = $_POST["api_key"];
 	}
 	}
     $new['rights'] = $_POST["f_acl"] * 1;
     $new['rights'] = $_POST["f_acl"] * 1;
-    update_record($db_link, "Customers", "id='$id'", $new);
+    update_record($db_link, "customers", "id='$id'", $new);
     unset($_POST["pass"]);
     unset($_POST["pass"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
     exit;
@@ -27,7 +27,7 @@ unset($_POST);
 print_control_submenu($page_url);
 print_control_submenu($page_url);
 
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
-$customer=get_record($db_link,'Customers',"id=".$id);
+$customer=get_record($db_link,'customers',"id=".$id);
 ?>
 ?>
 
 
 <div id="cont">
 <div id="cont">

+ 5 - 5
html/admin/customers/index.php

@@ -7,7 +7,7 @@ $msg_error = "";
 if (isset($_POST["create"])) {
 if (isset($_POST["create"])) {
     $login = $_POST["newlogin"];
     $login = $_POST["newlogin"];
     if ($login) {
     if ($login) {
-	$customer = get_record_sql($db_link,"Select * from Customers WHERE LCase(Login)=LCase('$login')");
+	$customer = get_record_sql($db_link,"Select * from customers WHERE LCase(Login)=LCase('$login')");
         if (!empty($customer)) {
         if (!empty($customer)) {
             $msg_error = "Login $login already exists!";
             $msg_error = "Login $login already exists!";
             LOG_ERROR($db_link, $msg_error);
             LOG_ERROR($db_link, $msg_error);
@@ -17,7 +17,7 @@ if (isset($_POST["create"])) {
 	    $new['api_key'] = randomPassword(20);
 	    $new['api_key'] = randomPassword(20);
             $new['rights'] = 3;
             $new['rights'] = 3;
             LOG_INFO($db_link, "Create new login: $login");
             LOG_INFO($db_link, "Create new login: $login");
-            $id = insert_record($db_link, "Customers", $new);
+            $id = insert_record($db_link, "customers", $new);
 	    if (!empty($id)) { header("Location: editcustom.php?id=$id"); exit; }
 	    if (!empty($id)) { header("Location: editcustom.php?id=$id"); exit; }
         }
         }
     }
     }
@@ -29,8 +29,8 @@ if (isset($_POST["remove"])) {
     $fid = $_POST["fid"];
     $fid = $_POST["fid"];
     foreach ($fid as $key => $val) {
     foreach ($fid as $key => $val) {
         if ($val) {
         if ($val) {
-            LOG_INFO($db_link, "Remove login with id: $val ". dump_record($db_link,'Customers','id='.$val));
-            delete_record($db_link, "Customers", "id=" . $val);
+            LOG_INFO($db_link, "Remove login with id: $val ". dump_record($db_link,'customers','id='.$val));
+            delete_record($db_link, "customers", "id=" . $val);
         }
         }
     }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
@@ -54,7 +54,7 @@ print_control_submenu($page_url);
 <td><b><?php echo WEB_customer_mode;?></b></td>
 <td><b><?php echo WEB_customer_mode;?></b></td>
 </tr>
 </tr>
 <?php
 <?php
-$users = get_records($db_link,'Customers','True ORDER BY Login');
+$users = get_records($db_link,'customers','True ORDER BY Login');
 foreach ($users as $row) {
 foreach ($users as $row) {
     $cl = "data";
     $cl = "data";
     $acl = get_record_sql($db_link,'SELECT * FROM acl WHERE id='.$row['rights']);
     $acl = get_record_sql($db_link,'SELECT * FROM acl WHERE id='.$row['rights']);

+ 1 - 1
html/admin/devices/edit_gw_instances.php

@@ -5,7 +5,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 
 $device=get_record($db_link,'devices',"id=".$id);
 $device=get_record($db_link,'devices',"id=".$id);
-$user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_id']);
+$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=".$device['user_id']);
 
 
 if (isset($_POST["s_remove"])) {
 if (isset($_POST["s_remove"])) {
     $s_id = $_POST["gs_id"];
     $s_id = $_POST["gs_id"];

+ 1 - 1
html/admin/devices/edit_gw_subnets.php

@@ -5,7 +5,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 
 $device=get_record($db_link,'devices',"id=".$id);
 $device=get_record($db_link,'devices',"id=".$id);
-$user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_id']);
+$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=".$device['user_id']);
 
 
 if (isset($_POST["s_remove"])) {
 if (isset($_POST["s_remove"])) {
     $s_id = $_POST["gs_id"];
     $s_id = $_POST["gs_id"];

+ 1 - 1
html/admin/devices/edit_l3int.php

@@ -6,7 +6,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 
 $device = get_record($db_link,'devices',"id=".$id);
 $device = get_record($db_link,'devices',"id=".$id);
 $snmp=getSnmpAccess($device);
 $snmp=getSnmpAccess($device);
-$user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_id']);
+$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=".$device['user_id']);
 $int_list = getIpAdEntIfIndex($db_link,$device['ip'],$snmp);
 $int_list = getIpAdEntIfIndex($db_link,$device['ip'],$snmp);
 
 
 if (isset($_POST["s_remove"])) {
 if (isset($_POST["s_remove"])) {

+ 2 - 2
html/admin/devices/editdevice.php

@@ -44,7 +44,7 @@ if (isset($_POST["editdevice"]) and isset($id)) {
     $cur_device = get_record_sql($db_link, "SELECT * FROM devices WHERE id=" . $id);
     $cur_device = get_record_sql($db_link, "SELECT * FROM devices WHERE id=" . $id);
     //main device info
     //main device info
     if (!empty($new['ip'])) {
     if (!empty($new['ip'])) {
-        $cur_auth = get_record_sql($db_link, "SELECT * FROM User_auth WHERE deleted=0 AND ip='" . $new['ip'] . "'");
+        $cur_auth = get_record_sql($db_link, "SELECT * FROM user_auth WHERE deleted=0 AND ip='" . $new['ip'] . "'");
     }
     }
     if (isset($_POST["f_device_model_id"])) {
     if (isset($_POST["f_device_model_id"])) {
         $new['device_model_id'] = $_POST["f_device_model_id"] * 1;
         $new['device_model_id'] = $_POST["f_device_model_id"] * 1;
@@ -164,7 +164,7 @@ if (isset($_POST["editdevice"]) and isset($id)) {
 }
 }
 
 
 $device = get_record($db_link, 'devices', "id=" . $id);
 $device = get_record($db_link, 'devices', "id=" . $id);
-$user_info = get_record_sql($db_link, "SELECT * FROM User_list WHERE id=" . $device['user_id']);
+$user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=" . $device['user_id']);
 unset($_POST);
 unset($_POST);
 
 
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");

+ 1 - 1
html/admin/devices/editport.php

@@ -23,7 +23,7 @@ unset($_POST);
 $port = get_record($db_link, 'device_ports', "id=" . $id);
 $port = get_record($db_link, 'device_ports', "id=" . $id);
 $device_id = $port['device_id'];
 $device_id = $port['device_id'];
 $device = get_record($db_link, 'devices', "id=" . $device_id);
 $device = get_record($db_link, 'devices', "id=" . $device_id);
-$user_info = get_record_sql($db_link, "SELECT * FROM User_list WHERE id=" . $device['user_id']);
+$user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=" . $device['user_id']);
 
 
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
 
 

+ 2 - 2
html/admin/devices/index-passive.php

@@ -109,7 +109,7 @@ if ($unknown and $f_vendor_select==0) { $u_filter=' AND V.id<>1 '; } else {
         }
         }
     }
     }
 
 
-$countSQL="SELECT Count(*) FROM User_auth A, User_list L, devices D, device_models M, vendors V
+$countSQL="SELECT Count(*) FROM user_auth A, user_list L, devices D, device_models M, vendors V
 WHERE D.user_id=L.id AND A.ip = D.ip AND D.device_model_id=M.id AND M.vendor_id=V.id AND A.deleted =0
 WHERE D.user_id=L.id AND A.ip = D.ip AND D.device_model_id=M.id AND M.vendor_id=V.id AND A.deleted =0
 $u_filter $ip_list_filter $d_filter";
 $u_filter $ip_list_filter $d_filter";
 $count_records = get_single_field($db_link,$countSQL);
 $count_records = get_single_field($db_link,$countSQL);
@@ -137,7 +137,7 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
 <?php
 <?php
 
 
 $sSQL = "SELECT A.id, D.id as dev_id, D.device_type, A.ip, A.mac, A.user_id, L.login, D.comment, A.last_found, V.name, M.model_name
 $sSQL = "SELECT A.id, D.id as dev_id, D.device_type, A.ip, A.mac, A.user_id, L.login, D.comment, A.last_found, V.name, M.model_name
-FROM User_auth A, User_list L, devices D, device_models M, vendors V
+FROM user_auth A, user_list L, devices D, device_models M, vendors V
 WHERE D.user_id=L.id AND A.ip = D.ip AND D.device_model_id=M.id AND M.vendor_id=V.id AND A.deleted =0
 WHERE D.user_id=L.id AND A.ip = D.ip AND D.device_model_id=M.id AND M.vendor_id=V.id AND A.deleted =0
 $u_filter $ip_list_filter $d_filter
 $u_filter $ip_list_filter $d_filter
 ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
 ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";

+ 1 - 1
html/admin/devices/mactable.php

@@ -5,7 +5,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 
 $device=get_record($db_link,'devices',"id=".$id);
 $device=get_record($db_link,'devices',"id=".$id);
 $snmp = getSnmpAccess($device);
 $snmp = getSnmpAccess($device);
-$user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_id']);
+$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=".$device['user_id']);
 
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
 

+ 4 - 4
html/admin/devices/portmactable.php

@@ -30,7 +30,7 @@ if (empty($device)) {
 }
 }
 
 
 $snmp = getSnmpAccess($device);
 $snmp = getSnmpAccess($device);
-$user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_id']);
+$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=".$device['user_id']);
 if (empty($user_info)) {
 if (empty($user_info)) {
     header("Location: /admin/devices/index.php");
     header("Location: /admin/devices/index.php");
     exit;
     exit;
@@ -57,7 +57,7 @@ print "<b>".$port_info['device_name']." [".$port_info['port']."] </b><br>\n";
 $sw_auth=NULL;
 $sw_auth=NULL;
 $sw_mac=NULL;
 $sw_mac=NULL;
 
 
-$sw_auth = get_record_sql($db_link,"SELECT mac FROM User_auth WHERE deleted=0 and ip='".$port_info['ip']."'");
+$sw_auth = get_record_sql($db_link,"SELECT mac FROM user_auth WHERE deleted=0 and ip='".$port_info['ip']."'");
 if (!empty($sw_auth)) {
 if (!empty($sw_auth)) {
     $sw_mac = mac_simplify($sw_auth['mac']);
     $sw_mac = mac_simplify($sw_auth['mac']);
     $sw_mac = preg_replace("/.{2}$/","",$sw_mac);
     $sw_mac = preg_replace("/.{2}$/","",$sw_mac);
@@ -107,7 +107,7 @@ unset_lock_discovery($db_link,$device_id);
 </tr>
 </tr>
 <?php
 <?php
 print "<b>".WEB_device_port_mac_table_history."</b><br>\n";
 print "<b>".WEB_device_port_mac_table_history."</b><br>\n";
-$d_sql = "select A.ip,A.ip_int,A.mac,A.id,A.dns_name,A.last_found from User_auth as A, connections as C where C.port_id=$port_id and A.id=C.auth_id order by A.ip_int";
+$d_sql = "select A.ip,A.ip_int,A.mac,A.id,A.dns_name,A.last_found from user_auth as A, connections as C where C.port_id=$port_id and A.id=C.auth_id order by A.ip_int";
 $t_device = get_records_sql($db_link, $d_sql);
 $t_device = get_records_sql($db_link, $d_sql);
 if (!empty($t_device)) {
 if (!empty($t_device)) {
     foreach ($t_device as $row) {
     foreach ($t_device as $row) {
@@ -121,7 +121,7 @@ if (!empty($t_device)) {
     }
     }
 }
 }
 
 
-$maclist = get_records_sql($db_link, "SELECT mac,timestamp from Unknown_mac where port_id=$port_id order by timestamp desc");
+$maclist = get_records_sql($db_link, "SELECT mac,timestamp from unknown_mac where port_id=$port_id order by timestamp desc");
 if (!empty($maclist)) {
 if (!empty($maclist)) {
     foreach ($maclist as $row) {
     foreach ($maclist as $row) {
         print "<tr>";
         print "<tr>";

+ 1 - 1
html/admin/devices/snmpwalk.php

@@ -5,7 +5,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 
 $device=get_record($db_link,'devices',"id=".$id);
 $device=get_record($db_link,'devices',"id=".$id);
 $snmp = getSnmpAccess($device);
 $snmp = getSnmpAccess($device);
-$user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_id']);
+$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=".$device['user_id']);
 
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 print_device_submenu($page_url);
 print_device_submenu($page_url);

+ 2 - 2
html/admin/devices/switchport-conn.php

@@ -19,7 +19,7 @@ if (isset($_POST["remove"])) {
 
 
 unset($_POST);
 unset($_POST);
 
 
-$user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_id']);
+$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=".$device['user_id']);
 
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
 
@@ -43,7 +43,7 @@ print_editdevice_submenu($page_url,$id,$device['device_type'],$user_info['login'
 
 
 <?php
 <?php
 
 
-$connections = get_records_sql($db_link,"SELECT C.* FROM `connections` as C,`User_auth` as A WHERE A.id=C.auth_id AND A.deleted=0 AND C.device_id=$id ORDER BY C.port_id ASC");
+$connections = get_records_sql($db_link,"SELECT C.* FROM `connections` as C,`user_auth` as A WHERE A.id=C.auth_id AND A.deleted=0 AND C.device_id=$id ORDER BY C.port_id ASC");
 foreach ($connections as $key => $value) {
 foreach ($connections as $key => $value) {
 print "<tr align=center>\n";
 print "<tr align=center>\n";
 print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='{$value['id']}'></td>\n";
 print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='{$value['id']}'></td>\n";

+ 1 - 1
html/admin/devices/switchport.php

@@ -56,7 +56,7 @@ if (isset($_POST['save'])) {
 unset($_POST);
 unset($_POST);
 
 
 $device=get_record($db_link,'devices',"id=".$id);
 $device=get_record($db_link,'devices',"id=".$id);
-$user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_id']);
+$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=".$device['user_id']);
 
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
 

+ 1 - 1
html/admin/devices/switchstatus.php

@@ -76,7 +76,7 @@ if (!apply_device_lock($db_link, $id)) {
     exit;
     exit;
 }
 }
 
 
-$user_info = get_record_sql($db_link, "SELECT * FROM User_list WHERE id=" . $device['user_id']);
+$user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=" . $device['user_id']);
 
 
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
 
 

+ 2 - 2
html/admin/filters/editfilter.php

@@ -10,7 +10,7 @@ if (isset($_POST["editfilter"])) {
     $new['dstport'] = str_replace(':', '-', $_POST["f_dstport"]);
     $new['dstport'] = str_replace(':', '-', $_POST["f_dstport"]);
     $new['srcport'] = str_replace(':', '-', $_POST["f_srcport"]);
     $new['srcport'] = str_replace(':', '-', $_POST["f_srcport"]);
     $new['comment'] = $_POST["f_comment"];
     $new['comment'] = $_POST["f_comment"];
-    update_record($db_link, "Filter_list", "id='$id'", $new);
+    update_record($db_link, "filter_list", "id='$id'", $new);
     unset($_POST);
     unset($_POST);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
     exit;
@@ -20,7 +20,7 @@ unset($_POST);
 
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
 
-$filter = get_record($db_link, 'Filter_list','id='.$id);
+$filter = get_record($db_link, 'filter_list','id='.$id);
 
 
 print_filters_submenu($page_url);
 print_filters_submenu($page_url);
 
 

+ 7 - 7
html/admin/filters/editgroup.php

@@ -7,14 +7,14 @@ if (isset($_POST["editgroup"])) {
     $new['group_name'] = $_POST["f_group_name"];
     $new['group_name'] = $_POST["f_group_name"];
     $new['instance_id'] = $_POST["f_instance_id"]*1;
     $new['instance_id'] = $_POST["f_instance_id"]*1;
     $new['comment'] = $_POST["f_group_comment"];
     $new['comment'] = $_POST["f_group_comment"];
-    update_record($db_link, "Group_list", "id='$id'", $new);
+    update_record($db_link, "group_list", "id='$id'", $new);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
     exit;
 }
 }
 
 
 if (isset($_POST["addfilter"])) {
 if (isset($_POST["addfilter"])) {
     $filter_id = $_POST["newfilter"] * 1;
     $filter_id = $_POST["newfilter"] * 1;
-    $max_record = get_record_sql($db_link, "SELECT MAX(G.order) as morder FROM Group_filters as G where G.group_id='$id'");
+    $max_record = get_record_sql($db_link, "SELECT MAX(G.order) as morder FROM group_filters as G where G.group_id='$id'");
     if (empty($max_record)) {
     if (empty($max_record)) {
         $forder = 1;
         $forder = 1;
     } else {
     } else {
@@ -24,7 +24,7 @@ if (isset($_POST["addfilter"])) {
     $new['filter_id'] = $filter_id;
     $new['filter_id'] = $filter_id;
     $new['order'] = $forder;
     $new['order'] = $forder;
     $new['action'] = 1;
     $new['action'] = 1;
-    insert_record($db_link, "Group_filters", $new);
+    insert_record($db_link, "group_filters", $new);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
     exit;
 }
 }
@@ -33,7 +33,7 @@ if (isset($_POST["removefilter"])) {
     $f_group_filter = $_POST["f_group_filter"];
     $f_group_filter = $_POST["f_group_filter"];
     foreach ($f_group_filter as $key => $val) {
     foreach ($f_group_filter as $key => $val) {
         if (!empty($val)) {
         if (!empty($val)) {
-            delete_record($db_link, "Group_filters", "id=" . $val * 1);
+            delete_record($db_link, "group_filters", "id=" . $val * 1);
         }
         }
     }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
@@ -57,7 +57,7 @@ if (isset($_POST["updateFilters"])) {
                 $new['action'] = $_POST["f_action"][$group_filter_id] * 1;
                 $new['action'] = $_POST["f_action"][$group_filter_id] * 1;
             }
             }
             if (!empty($new)) {
             if (!empty($new)) {
-                update_record($db_link, "Group_filters", "id=" . $group_filter_id, $new);
+                update_record($db_link, "group_filters", "id=" . $group_filter_id, $new);
             }
             }
         }
         }
     }
     }
@@ -67,7 +67,7 @@ if (isset($_POST["updateFilters"])) {
 
 
 unset($_POST);
 unset($_POST);
 
 
-$group = get_record_sql($db_link, "SELECT * FROM Group_list WHERE id=" . $id);
+$group = get_record_sql($db_link, "SELECT * FROM group_list WHERE id=" . $id);
 
 
 print_filters_submenu($page_url);
 print_filters_submenu($page_url);
 
 
@@ -107,7 +107,7 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
             </tr>
             </tr>
 
 
             <?php
             <?php
-            $sSQL = "SELECT G.id, G.filter_id, F.name, G.order, G.action, F.comment FROM Group_filters G, Filter_list F WHERE F.id=G.filter_id and group_id=$id Order by G.order";
+            $sSQL = "SELECT G.id, G.filter_id, F.name, G.order, G.action, F.comment FROM group_filters G, filter_list F WHERE F.id=G.filter_id and group_id=$id Order by G.order";
             $flist = get_records_sql($db_link, $sSQL);
             $flist = get_records_sql($db_link, $sSQL);
             foreach ($flist as $row) {
             foreach ($flist as $row) {
                 print "<tr align=center>\n";
                 print "<tr align=center>\n";

+ 5 - 5
html/admin/filters/groups.php

@@ -6,7 +6,7 @@ if (isset($_POST["create"])) {
     $fname = $_POST["newgroup"];
     $fname = $_POST["newgroup"];
     if ($fname) {
     if ($fname) {
         $new['group_name'] = $fname;
         $new['group_name'] = $fname;
-        $new_id = insert_record($db_link, "Group_list", $new);
+        $new_id = insert_record($db_link, "group_list", $new);
         header("location: editgroup.php?id=$new_id");
         header("location: editgroup.php?id=$new_id");
         exit;
         exit;
     }
     }
@@ -18,9 +18,9 @@ if (isset($_POST["remove"])) {
     $fgid = $_POST["fid"];
     $fgid = $_POST["fid"];
     foreach ($fgid as $key => $val) {
     foreach ($fgid as $key => $val) {
         if (!empty($val)) {
         if (!empty($val)) {
-            run_sql($db_link, "UPDATE User_auth SET filter_group_id=0, changed = 1 WHERE deleted=0 AND filter_group_id=" . $val * 1);
-            run_sql($db_link, "DELETE FROM Group_filters WHERE group_id=" . $val * 1);
-            delete_record($db_link, "Group_list", "id=" . $val * 1);
+            run_sql($db_link, "UPDATE user_auth SET filter_group_id=0, changed = 1 WHERE deleted=0 AND filter_group_id=" . $val * 1);
+            run_sql($db_link, "DELETE FROM group_filters WHERE group_id=" . $val * 1);
+            delete_record($db_link, "group_list", "id=" . $val * 1);
         }
         }
     }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
@@ -44,7 +44,7 @@ print_filters_submenu($page_url);
                 <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
                 <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
             </tr>
             </tr>
             <?php
             <?php
-            $groups = get_records_sql($db_link, 'SELECT * FROM Group_list ORDER BY id');
+            $groups = get_records_sql($db_link, 'SELECT * FROM group_list ORDER BY id');
             foreach ($groups as $row) {
             foreach ($groups as $row) {
 		$filter_instance = get_record_sql($db_link,'SELECT * FROM filter_instances WHERE id='.$row["instance_id"]);
 		$filter_instance = get_record_sql($db_link,'SELECT * FROM filter_instances WHERE id='.$row["instance_id"]);
                 print "<tr align=center>\n";
                 print "<tr align=center>\n";

+ 4 - 4
html/admin/filters/index.php

@@ -11,7 +11,7 @@ if (isset($_POST["create"])) {
     if (isset($fname)) {
     if (isset($fname)) {
         $new['name'] = $fname;
         $new['name'] = $fname;
         $new['type'] = $ftype;
         $new['type'] = $ftype;
-        $new_id = insert_record($db_link, "Filter_list", $new);
+        $new_id = insert_record($db_link, "filter_list", $new);
         header("Location: editfilter.php?id=$new_id");
         header("Location: editfilter.php?id=$new_id");
         exit;
         exit;
     }
     }
@@ -21,8 +21,8 @@ if (isset($_POST["remove"])) {
     $fid = $_POST["fid"];
     $fid = $_POST["fid"];
     foreach ($fid as $key => $val) {
     foreach ($fid as $key => $val) {
         if ($val) {
         if ($val) {
-            run_sql($db_link, "DELETE FROM Group_filters WHERE filter_id=" . $val);
-            delete_record($db_link, "Filter_list", "id=$val");
+            run_sql($db_link, "DELETE FROM group_filters WHERE filter_id=" . $val);
+            delete_record($db_link, "filter_list", "id=$val");
         }
         }
     }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
@@ -48,7 +48,7 @@ print_filters_submenu($page_url);
                 <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
                 <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
             </tr>
             </tr>
             <?php
             <?php
-            $filters = get_records_sql($db_link, 'SELECT * FROM Filter_list ORDER BY name');
+            $filters = get_records_sql($db_link, 'SELECT * FROM filter_list ORDER BY name');
             foreach ($filters as $row) {
             foreach ($filters as $row) {
                 print "<tr align=center>\n";
                 print "<tr align=center>\n";
                 print "<td class=\"data\" style='padding:0'><input type=checkbox name=fid[] value=" . $row['id'] . "></td>\n";
                 print "<td class=\"data\" style='padding:0'><input type=checkbox name=fid[] value=" . $row['id'] . "></td>\n";

+ 3 - 3
html/admin/filters/instances.php

@@ -34,10 +34,10 @@ if (isset($_POST["remove"])) {
     for ($i = 0; $i < $len; $i ++) {
     for ($i = 0; $i < $len; $i ++) {
         $id = intval($_POST['r_id'][$i]);
         $id = intval($_POST['r_id'][$i]);
         if (!empty($id) and $id>1) {
         if (!empty($id) and $id>1) {
-	    $deleted_groups = get_records_sql($db_link,"SELECT * FROM Group_list WHERE `instance_id`>1 AND `instance_id`=".$id);
+	    $deleted_groups = get_records_sql($db_link,"SELECT * FROM group_list WHERE `instance_id`>1 AND `instance_id`=".$id);
 	    foreach ($deleted_groups as $d_group) {
 	    foreach ($deleted_groups as $d_group) {
-	        run_sql($db_link, "UPDATE User_auth SET filter_group_id=0, changed = 1 WHERE deleted=0 AND filter_group_id=" . $d_group['id']);
-		delete_record($db_link, "Group_list", "id=" . $d_group['id']);
+	        run_sql($db_link, "UPDATE user_auth SET filter_group_id=0, changed = 1 WHERE deleted=0 AND filter_group_id=" . $d_group['id']);
+		delete_record($db_link, "group_list", "id=" . $d_group['id']);
 		}
 		}
             delete_record($db_link, "filter_instances", "id=" . $id * 1);
             delete_record($db_link, "filter_instances", "id=" . $id * 1);
         }
         }

+ 2 - 2
html/admin/groups/index.php

@@ -6,8 +6,8 @@ if (isset($_POST["remove"])) {
     $fid = $_POST["f_id"];
     $fid = $_POST["f_id"];
     foreach ($fid as $key => $val) {
     foreach ($fid as $key => $val) {
         if (isset($val) and $val > 0) {
         if (isset($val) and $val > 0) {
-            run_sql($db_link, "UPDATE User_list SET ou_id=0 WHERE ou_id=$val");
-            run_sql($db_link, "UPDATE User_auth SET ou_id=0 WHERE ou_id=$val");
+            run_sql($db_link, "UPDATE user_list SET ou_id=0 WHERE ou_id=$val");
+            run_sql($db_link, "UPDATE user_auth SET ou_id=0 WHERE ou_id=$val");
             run_sql($db_link, "DELETE FROM auth_rules WHERE ou_id=$val");
             run_sql($db_link, "DELETE FROM auth_rules WHERE ou_id=$val");
             delete_record($db_link, "OU", "id=" . $val);
             delete_record($db_link, "OU", "id=" . $val);
             }
             }

+ 1 - 1
html/admin/iplist/auto_rules.php

@@ -94,7 +94,7 @@ foreach ( $t_auth_rules as $row ) {
     print "<td class=\"data\">".$row['rule']."</td>\n";
     print "<td class=\"data\">".$row['rule']."</td>\n";
     print "<td colspan=2 class=\"data\" align=left>";
     print "<td colspan=2 class=\"data\" align=left>";
     if (!empty($row['user_id'])) {
     if (!empty($row['user_id'])) {
-	$user_info=get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$row['user_id']);
+	$user_info=get_record_sql($db_link,"SELECT * FROM user_list WHERE id=".$row['user_id']);
 	if (!empty($user_info)) { print "User: &nbsp"; print_url($user_info['login'],'/admin/users/edituser.php?id='.$user_info['id']); }
 	if (!empty($user_info)) { print "User: &nbsp"; print_url($user_info['login'],'/admin/users/edituser.php?id='.$user_info['id']); }
 	}
 	}
     if (!empty($row['ou_id'])) {
     if (!empty($row['ou_id'])) {

+ 7 - 7
html/admin/iplist/deleted.php

@@ -17,13 +17,13 @@ if (!isset($f_comment)) { $f_comment=''; }
 
 
 $_SESSION[$page_url]['comment']=$f_comment;
 $_SESSION[$page_url]['comment']=$f_comment;
 
 
-$sort_table = 'User_auth';
+$sort_table = 'user_auth';
 
 
 $sort_url = "<a href=deleted.php?";
 $sort_url = "<a href=deleted.php?";
 
 
 if ($rsubnet == 0) { $subnet_filter = ''; } else {
 if ($rsubnet == 0) { $subnet_filter = ''; } else {
     $subnet_range = get_subnet_range($db_link,$rsubnet);
     $subnet_range = get_subnet_range($db_link,$rsubnet);
-    $subnet_filter = " and User_auth.ip_int>=".$subnet_range['start']." and User_auth.ip_int<=".$subnet_range['stop'];
+    $subnet_filter = " and user_auth.ip_int>=".$subnet_range['start']." and user_auth.ip_int<=".$subnet_range['stop'];
     }
     }
 
 
 $ip_list_filter = $subnet_filter;
 $ip_list_filter = $subnet_filter;
@@ -32,7 +32,7 @@ $ip_where = '';
 if (!empty($f_comment)) {
 if (!empty($f_comment)) {
     if (checkValidIp($f_comment)) { $ip_where = " and ip_int=inet_aton('" . $f_comment . "') "; }
     if (checkValidIp($f_comment)) { $ip_where = " and ip_int=inet_aton('" . $f_comment . "') "; }
     if (checkValidMac($f_comment)) { $ip_where = " and mac='" . mac_dotted($f_comment) . "'  "; }
     if (checkValidMac($f_comment)) { $ip_where = " and mac='" . mac_dotted($f_comment) . "'  "; }
-    if (empty($ip_where)) { $ip_where=" and (User_auth.comments LIKE '$f_comment' OR User_auth.dhcp_hostname LIKE '$f_comment')"; }
+    if (empty($ip_where)) { $ip_where=" and (user_auth.comments LIKE '$f_comment' OR user_auth.dhcp_hostname LIKE '$f_comment')"; }
     $ip_list_filter = $ip_where;
     $ip_list_filter = $ip_where;
     } 
     } 
 
 
@@ -50,7 +50,7 @@ print_ip_submenu($page_url);
 </div>
 </div>
 
 
 <?php
 <?php
-$countSQL="SELECT Count(*) FROM User_auth WHERE User_auth.deleted = 1 $ip_list_filter";
+$countSQL="SELECT Count(*) FROM user_auth WHERE user_auth.deleted = 1 $ip_list_filter";
 $count_records = get_single_field($db_link,$countSQL);
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page>$total) { $page=$total; }
@@ -73,9 +73,9 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
 <?php
 <?php
 
 
 $sSQL = "SELECT 
 $sSQL = "SELECT 
-User_auth.id, User_auth.ip, User_auth.mac, User_auth.comments, User_auth.dns_name, User_auth.dhcp_hostname, 
-User_auth.dhcp_time, User_auth.last_found, User_auth.timestamp, User_auth.changed_time
-FROM User_auth WHERE User_auth.deleted = 1 $ip_list_filter
+user_auth.id, user_auth.ip, user_auth.mac, user_auth.comments, user_auth.dns_name, user_auth.dhcp_hostname, 
+user_auth.dhcp_time, user_auth.last_found, user_auth.timestamp, user_auth.changed_time
+FROM user_auth WHERE user_auth.deleted = 1 $ip_list_filter
 ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
 ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
 $users = get_records_sql($db_link,$sSQL);
 $users = get_records_sql($db_link,$sSQL);
 foreach ($users as $user) {
 foreach ($users as $user) {

+ 4 - 4
html/admin/iplist/doubles.php

@@ -40,7 +40,7 @@ if (empty($rcidr)) { $cidr_filter = ''; } else {
     <td align=right><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="removeauth" value="<?php echo WEB_btn_delete; ?>"></td>
     <td align=right><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="removeauth" value="<?php echo WEB_btn_delete; ?>"></td>
 </tr>
 </tr>
 <?php
 <?php
-$sSQL = "SELECT U.id, U.ip, U.mac, U.arp_found, S.subnet as net FROM User_auth U, subnets S WHERE (U.mac IS NOT NULL AND U.mac<>'') AND (U.ip_int BETWEEN S.ip_int_start AND S.ip_int_stop) $cidr_filter AND S.office=1 AND U.deleted=0 ORDER BY net,mac,arp_found";
+$sSQL = "SELECT U.id, U.ip, U.mac, U.arp_found, S.subnet as net FROM user_auth U, subnets S WHERE (U.mac IS NOT NULL AND U.mac<>'') AND (U.ip_int BETWEEN S.ip_int_start AND S.ip_int_stop) $cidr_filter AND S.office=1 AND U.deleted=0 ORDER BY net,mac,arp_found";
 $users = get_records_sql($db_link,$sSQL);
 $users = get_records_sql($db_link,$sSQL);
 $f_subnet=NULL;
 $f_subnet=NULL;
 $f_mac=NULL;
 $f_mac=NULL;
@@ -63,12 +63,12 @@ foreach ($users as $row) {
         //если первая запись не выводилась - выводим на печать
         //если первая запись не выводилась - выводим на печать
         if (!isset($printed[$f_id])) {
         if (!isset($printed[$f_id])) {
             //считаем сколько у нас дублей
             //считаем сколько у нас дублей
-            $dSQL = "SELECT  U.id, U.ip, U.mac, U.arp_found FROM User_auth U WHERE U.mac='".$f_mac."' $cidr_filter AND U.deleted=0";
+            $dSQL = "SELECT  U.id, U.ip, U.mac, U.arp_found FROM user_auth U WHERE U.mac='".$f_mac."' $cidr_filter AND U.deleted=0";
             $doubles = get_records_sql($db_link,$dSQL);
             $doubles = get_records_sql($db_link,$dSQL);
             $f_count = count($doubles);
             $f_count = count($doubles);
 
 
             $f_index++;
             $f_index++;
-            $user = get_record_sql($db_link,"SELECT * FROM User_auth WHERE id=".$f_id);
+            $user = get_record_sql($db_link,"SELECT * FROM user_auth WHERE id=".$f_id);
             if (empty($user['arp_found']) or $user['arp_found'] === '0000-00-00 00:00:00') { $user['arp_found'] = ''; }
             if (empty($user['arp_found']) or $user['arp_found'] === '0000-00-00 00:00:00') { $user['arp_found'] = ''; }
             if (empty($user['timestamp']) or $user['timestamp'] === '0000-00-00 00:00:00') { $user['timestamp'] = ''; }
             if (empty($user['timestamp']) or $user['timestamp'] === '0000-00-00 00:00:00') { $user['timestamp'] = ''; }
             if (empty($user['changed_time']) or $user['changed_time'] === '0000-00-00 00:00:00') { $user['changed_time'] = ''; }
             if (empty($user['changed_time']) or $user['changed_time'] === '0000-00-00 00:00:00') { $user['changed_time'] = ''; }
@@ -94,7 +94,7 @@ foreach ($users as $row) {
         //проверяем текущую запись
         //проверяем текущую запись
         if (!isset($printed[$row['id']])) {
         if (!isset($printed[$row['id']])) {
             $f_index++;
             $f_index++;
-            $user = get_record_sql($db_link,"SELECT * FROM User_auth WHERE id=".$row['id']);
+            $user = get_record_sql($db_link,"SELECT * FROM user_auth WHERE id=".$row['id']);
             if (empty($user['arp_found']) or $user['arp_found'] === '0000-00-00 00:00:00') { $user['arp_found'] = ''; }
             if (empty($user['arp_found']) or $user['arp_found'] === '0000-00-00 00:00:00') { $user['arp_found'] = ''; }
             if (empty($user['timestamp']) or $user['timestamp'] === '0000-00-00 00:00:00') { $user['timestamp'] = ''; }
             if (empty($user['timestamp']) or $user['timestamp'] === '0000-00-00 00:00:00') { $user['timestamp'] = ''; }
             if (empty($user['changed_time']) or $user['changed_time'] === '0000-00-00 00:00:00') { $user['changed_time'] = ''; }
             if (empty($user['changed_time']) or $user['changed_time'] === '0000-00-00 00:00:00') { $user['changed_time'] = ''; }

+ 25 - 25
html/admin/iplist/index.php

@@ -14,36 +14,36 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/dynfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/dhcpfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/dhcpfilter.php");
 
 
 
 
-$sort_table = 'User_auth';
-if ($sort_field == 'login') { $sort_table = 'User_list'; }
-if ($sort_field == 'fio') { $sort_table = 'User_list'; }
+$sort_table = 'user_auth';
+if ($sort_field == 'login') { $sort_table = 'user_list'; }
+if ($sort_field == 'fio') { $sort_table = 'user_list'; }
 if ($sort_field == 'ou_name') { $sort_table = 'OU'; }
 if ($sort_field == 'ou_name') { $sort_table = 'OU'; }
 
 
 $sort_url = "<a href=index.php?ou=" . $rou;
 $sort_url = "<a href=index.php?ou=" . $rou;
 
 
-if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and User_list.ou_id=$rou "; }
+if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and user_list.ou_id=$rou "; }
 
 
 if (empty($rcidr)) { $cidr_filter = ''; } else {
 if (empty($rcidr)) { $cidr_filter = ''; } else {
     $cidr_range = cidrToRange($rcidr);
     $cidr_range = cidrToRange($rcidr);
-    if (!empty($cidr_range)) { $cidr_filter = " and User_auth.ip_int>=".ip2long($cidr_range[0])." and User_auth.ip_int<=".ip2long($cidr_range[1]); }
+    if (!empty($cidr_range)) { $cidr_filter = " and user_auth.ip_int>=".ip2long($cidr_range[0])." and user_auth.ip_int<=".ip2long($cidr_range[1]); }
     }
     }
 
 
 $enabled_filter='';
 $enabled_filter='';
 if ($enabled>0) {
 if ($enabled>0) {
-    if ($enabled===2) { $enabled_filter = ' and (User_auth.enabled=1 and User_list.enabled=1)'; }
-    if ($enabled===1) { $enabled_filter = ' and (User_auth.enabled=0 or User_list.enabled=0)'; }
+    if ($enabled===2) { $enabled_filter = ' and (user_auth.enabled=1 and user_list.enabled=1)'; }
+    if ($enabled===1) { $enabled_filter = ' and (user_auth.enabled=0 or user_list.enabled=0)'; }
     }
     }
 
 
 $dynamic_filter='';
 $dynamic_filter='';
 if ($dynamic_enabled>0) {
 if ($dynamic_enabled>0) {
-    if ($dynamic_enabled ==1) { $dynamic_filter = ' and User_auth.dynamic=1'; }
-    if ($dynamic_enabled ==2) { $dynamic_filter = ' and User_auth.dynamic=0'; }
+    if ($dynamic_enabled ==1) { $dynamic_filter = ' and user_auth.dynamic=1'; }
+    if ($dynamic_enabled ==2) { $dynamic_filter = ' and user_auth.dynamic=0'; }
     }
     }
 
 
 $dhcp_filter='';
 $dhcp_filter='';
 if ($dhcp_enabled>0) {
 if ($dhcp_enabled>0) {
-    if ($dhcp_enabled ==1) { $dhcp_filter = ' and User_auth.dhcp=1'; }
-    if ($dhcp_enabled ==2) { $dhcp_filter = ' and User_auth.dhcp=0'; }
+    if ($dhcp_enabled ==1) { $dhcp_filter = ' and user_auth.dhcp=1'; }
+    if ($dhcp_enabled ==2) { $dhcp_filter = ' and user_auth.dhcp=0'; }
     }
     }
 
 
 if (isset($_POST['search_str'])) { $f_search_str = trim($_POST['search_str']); }
 if (isset($_POST['search_str'])) { $f_search_str = trim($_POST['search_str']); }
@@ -56,11 +56,11 @@ $f_search=replaceSpecialChars($f_search_str);
 $ip_list_type_filter='';
 $ip_list_type_filter='';
 if ($ip_type>0) {
 if ($ip_type>0) {
     //suspicious - dhcp not found 3 last days
     //suspicious - dhcp not found 3 last days
-    if ($ip_type===3) { $ip_list_type_filter = " and (User_auth.dhcp_action IN ('add', 'old', 'del') and (ABS(User_auth.dhcp_time - User_auth.arp_found)>259200) and (UNIX_TIMESTAMP()-User_auth.arp_found)<259200)"; }
+    if ($ip_type===3) { $ip_list_type_filter = " and (user_auth.dhcp_action IN ('add', 'old', 'del') and (ABS(user_auth.dhcp_time - user_auth.arp_found)>259200) and (UNIX_TIMESTAMP()-user_auth.arp_found)<259200)"; }
     //dhcp
     //dhcp
-    if ($ip_type===2) { $ip_list_type_filter = " and (User_auth.dhcp_action IN ('add', 'old', 'del'))"; }
+    if ($ip_type===2) { $ip_list_type_filter = " and (user_auth.dhcp_action IN ('add', 'old', 'del'))"; }
     //static
     //static
-    if ($ip_type===1) { $ip_list_type_filter = " and (User_auth.dhcp_action NOT IN ('add', 'old', 'del'))"; }
+    if ($ip_type===1) { $ip_list_type_filter = " and (user_auth.dhcp_action NOT IN ('add', 'old', 'del'))"; }
     }
     }
 
 
 $ip_where = '';
 $ip_where = '';
@@ -181,12 +181,12 @@ print_ip_submenu($page_url);
 <form id="def" name="def">
 <form id="def" name="def">
 
 
 <?php
 <?php
-$countSQL="SELECT Count(*) FROM User_auth
-LEFT JOIN User_list
-ON User_auth.user_id = User_list.id
+$countSQL="SELECT Count(*) FROM user_auth
+LEFT JOIN user_list
+ON user_auth.user_id = user_list.id
 LEFT JOIN OU
 LEFT JOIN OU
-ON OU.id=User_list.ou_id
-WHERE User_auth.deleted =0 $ip_list_filter";
+ON OU.id=user_list.ou_id
+WHERE user_auth.deleted =0 $ip_list_filter";
 
 
 $count_records = get_single_field($db_link,$countSQL);
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 $total=ceil($count_records/$displayed);
@@ -216,13 +216,13 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
         </tr>
         </tr>
 <?php
 <?php
 
 
-$sSQL = "SELECT User_auth.*, User_list.login, User_list.enabled as UEnabled, User_list.blocked as UBlocked, OU.ou_name
-FROM User_auth
-LEFT JOIN User_list
-ON User_auth.user_id = User_list.id
+$sSQL = "SELECT user_auth.*, user_list.login, user_list.enabled as UEnabled, user_list.blocked as UBlocked, OU.ou_name
+FROM user_auth
+LEFT JOIN user_list
+ON user_auth.user_id = user_list.id
 LEFT JOIN OU
 LEFT JOIN OU
-ON OU.id=User_list.ou_id
-WHERE User_auth.deleted =0 $ip_list_filter
+ON OU.id=user_list.ou_id
+WHERE user_auth.deleted =0 $ip_list_filter
 ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
 ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
 
 
 $users = get_records_sql($db_link,$sSQL);
 $users = get_records_sql($db_link,$sSQL);

+ 10 - 10
html/admin/iplist/nagios.php

@@ -10,23 +10,23 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/enabledfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/enabledfilter.php");
 
 
-$sort_table = 'User_auth';
-if ($sort_field == 'login') { $sort_table = 'User_list'; }
-if ($sort_field == 'fio') { $sort_table = 'User_list'; }
+$sort_table = 'user_auth';
+if ($sort_field == 'login') { $sort_table = 'user_list'; }
+if ($sort_field == 'fio') { $sort_table = 'user_list'; }
 
 
 $sort_url = "<a href=nagios.php?ou=" . $rou; 
 $sort_url = "<a href=nagios.php?ou=" . $rou; 
 
 
-if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and User_list.ou_id=$rou "; }
+if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and user_list.ou_id=$rou "; }
 
 
 if ($rsubnet == 0) { $subnet_filter = ''; } else {
 if ($rsubnet == 0) { $subnet_filter = ''; } else {
     $subnet_range = get_subnet_range($db_link,$rsubnet);
     $subnet_range = get_subnet_range($db_link,$rsubnet);
-    if (!empty($subnet_range)) { $subnet_filter = " and User_auth.ip_int>=".$subnet_range['start']." and User_auth.ip_int<=".$subnet_range['stop']; }
+    if (!empty($subnet_range)) { $subnet_filter = " and user_auth.ip_int>=".$subnet_range['start']." and user_auth.ip_int<=".$subnet_range['stop']; }
     }
     }
 
 
 $enabled_filter='';
 $enabled_filter='';
 if ($enabled>0) {
 if ($enabled>0) {
-    if ($enabled===2) { $enabled_filter = ' and User_auth.nagios=1'; }
-    if ($enabled===1) { $enabled_filter = ' and User_auth.nagios=0'; }
+    if ($enabled===2) { $enabled_filter = ' and user_auth.nagios=1'; }
+    if ($enabled===1) { $enabled_filter = ' and user_auth.nagios=0'; }
     }
     }
 
 
 $ip_list_filter = $ou_filter.$subnet_filter.$enabled_filter;
 $ip_list_filter = $ou_filter.$subnet_filter.$enabled_filter;
@@ -67,7 +67,7 @@ print_ip_submenu($page_url);
 </div>
 </div>
 
 
 <?php
 <?php
-$countSQL="SELECT Count(*) FROM User_auth, User_list WHERE User_auth.user_id = User_list.id AND User_auth.deleted =0 $ip_list_filter";
+$countSQL="SELECT Count(*) FROM user_auth, user_list WHERE user_auth.user_id = user_list.id AND user_auth.deleted =0 $ip_list_filter";
 $count_records = get_single_field($db_link,$countSQL);
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page>$total) { $page=$total; }
@@ -95,8 +95,8 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
 	</tr>
 	</tr>
 <?php
 <?php
 
 
-$sSQL = "SELECT User_auth.*, User_list.login FROM User_auth, User_list
-WHERE User_auth.user_id = User_list.id AND User_auth.deleted =0 $ip_list_filter
+$sSQL = "SELECT user_auth.*, user_list.login FROM user_auth, user_list
+WHERE user_auth.user_id = user_list.id AND user_auth.deleted =0 $ip_list_filter
 ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
 ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
 
 
 $users = get_records_sql($db_link,$sSQL);
 $users = get_records_sql($db_link,$sSQL);

+ 2 - 2
html/admin/logs/detaillog.php

@@ -59,7 +59,7 @@ if (!empty($f_ip)) { $sort_url .='&f_ip="'.$f_ip.'"'; }
 $gateway_filter='';
 $gateway_filter='';
 if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(router_id=$rgateway) AND"; }
 if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(router_id=$rgateway) AND"; }
 
 
-$countSQL="SELECT Count(*) FROM Traffic_detail as A WHERE $gateway_filter $ip_where `timestamp`>='$date1' AND `timestamp`<'$date2'";
+$countSQL="SELECT Count(*) FROM traffic_detail as A WHERE $gateway_filter $ip_where `timestamp`>='$date1' AND `timestamp`<'$date2'";
 $count_records = get_single_field($db_link,$countSQL);
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page>$total) { $page=$total; }
@@ -87,7 +87,7 @@ $gateway_list = get_gateways($db_link);
 <td class="data" width=80><b><?php $url = $sort_url.'&sort=pkt&order='.$new_order."'>Pkt</a>"; print $url; ?></b></td>
 <td class="data" width=80><b><?php $url = $sort_url.'&sort=pkt&order='.$new_order."'>Pkt</a>"; print $url; ?></b></td>
 </tr>
 </tr>
 <?php
 <?php
-$fsql = "SELECT A.id, A.auth_id, A.`timestamp`, A.router_id, A.proto, A.src_ip, A.src_port, A.dst_ip, A.dst_port, A.bytes, A.pkt FROM Traffic_detail as A JOIN (SELECT id FROM Traffic_detail 
+$fsql = "SELECT A.id, A.auth_id, A.`timestamp`, A.router_id, A.proto, A.src_ip, A.src_port, A.dst_ip, A.dst_port, A.bytes, A.pkt FROM traffic_detail as A JOIN (SELECT id FROM traffic_detail 
         WHERE $gateway_filter $ip_where `timestamp`>='$date1' AND `timestamp`<'$date2'
         WHERE $gateway_filter $ip_where `timestamp`>='$date1' AND `timestamp`<'$date2'
         ORDER BY `timestamp` ASC LIMIT $start,$displayed) as T ON A.id = T.id ORDER BY $sort_table.$sort_field $order";
         ORDER BY `timestamp` ASC LIMIT $start,$displayed) as T ON A.id = T.id ORDER BY $sort_table.$sort_field $order";
 $userdata = get_records_sql($db_link, $fsql);
 $userdata = get_records_sql($db_link, $fsql);

+ 2 - 2
html/admin/logs/ip.php

@@ -31,7 +31,7 @@ if (!empty($f_ip)) {
 </form>
 </form>
 
 
 <?php
 <?php
-$countSQL="SELECT Count(*) FROM User_auth WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $ip_where";
+$countSQL="SELECT Count(*) FROM user_auth WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $ip_where";
 $count_records = get_single_field($db_link,$countSQL);
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page>$total) { $page=$total; }
@@ -53,7 +53,7 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
 
 
 <?php
 <?php
 
 
-$sSQL = "SELECT * FROM User_auth WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $ip_where ORDER BY id DESC LIMIT $start,$displayed";
+$sSQL = "SELECT * FROM user_auth WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $ip_where ORDER BY id DESC LIMIT $start,$displayed";
 
 
 $iplog = get_records_sql($db_link, $sSQL);
 $iplog = get_records_sql($db_link, $sSQL);
 foreach ($iplog as $row) {
 foreach ($iplog as $row) {

+ 2 - 2
html/admin/logs/unknown.php

@@ -25,7 +25,7 @@ if ($f_id > 0) { $where_dev = " and D.id=$f_id "; }
 </form>
 </form>
 
 
 <?php
 <?php
-$countSQL="SELECT Count(*) FROM Unknown_mac AS U, devices AS D, device_ports AS DP  WHERE D.device_type<=2 and U.device_id = D.id  AND U.port_id = DP.id AND U.timestamp>='$date1' AND U.timestamp<'$date2' $where_dev";
+$countSQL="SELECT Count(*) FROM unknown_mac AS U, devices AS D, device_ports AS DP  WHERE D.device_type<=2 and U.device_id = D.id  AND U.port_id = DP.id AND U.timestamp>='$date1' AND U.timestamp<'$date2' $where_dev";
 $count_records = get_single_field($db_link,$countSQL);
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page>$total) { $page=$total; }
@@ -43,7 +43,7 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
 </tr>
 </tr>
 <?php
 <?php
 
 
-$sSQL = "SELECT U.mac, U.timestamp, DP.port, D.device_name FROM Unknown_mac AS U, devices AS D, device_ports AS DP  WHERE D.device_type<=2 and U.device_id = D.id  AND U.port_id = DP.id AND U.timestamp>='$date1' AND U.timestamp<'$date2' $where_dev ORDER BY U.mac LIMIT $start,$displayed";
+$sSQL = "SELECT U.mac, U.timestamp, DP.port, D.device_name FROM unknown_mac AS U, devices AS D, device_ports AS DP  WHERE D.device_type<=2 and U.device_id = D.id  AND U.port_id = DP.id AND U.timestamp>='$date1' AND U.timestamp<'$date2' $where_dev ORDER BY U.mac LIMIT $start,$displayed";
 $maclog = get_records_sql($db_link, $sSQL);
 $maclog = get_records_sql($db_link, $sSQL);
 foreach ($maclog as $row) {
 foreach ($maclog as $row) {
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";

+ 3 - 3
html/admin/queues/index.php

@@ -9,7 +9,7 @@ if (isset($_POST['save'])) {
         $new['queue_name'] = trim($_POST['f_queue_name'][$i]);
         $new['queue_name'] = trim($_POST['f_queue_name'][$i]);
         $new['Download'] = $_POST['f_down'][$i] * 1;
         $new['Download'] = $_POST['f_down'][$i] * 1;
         $new['Upload'] = $_POST['f_up'][$i] * 1;
         $new['Upload'] = $_POST['f_up'][$i] * 1;
-        update_record($db_link, "Queue_list", "id='{$id}'", $new);
+        update_record($db_link, "queue_list", "id='{$id}'", $new);
     }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
     exit;
@@ -19,7 +19,7 @@ if (isset($_POST["create"])) {
     $queue_name = $_POST["new_queue"];
     $queue_name = $_POST["new_queue"];
     if (isset($queue_name)) {
     if (isset($queue_name)) {
         $q['queue_name'] = $queue_name;
         $q['queue_name'] = $queue_name;
-        insert_record($db_link, "Queue_list", $q);
+        insert_record($db_link, "queue_list", $q);
     }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
     exit;
@@ -41,7 +41,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 	<td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
 	<td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
 </tr>
 </tr>
 <?php
 <?php
-$t_queue=get_records($db_link, "Queue_list",'TRUE ORDER BY id');
+$t_queue=get_records($db_link, "queue_list",'TRUE ORDER BY id');
 foreach ($t_queue as $row) {
 foreach ($t_queue as $row) {
     print "<tr align=center>\n";
     print "<tr align=center>\n";
     print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='{$row['id']}'></td>\n";
     print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='{$row['id']}'></td>\n";

+ 3 - 3
html/admin/reports/authday.php

@@ -6,8 +6,8 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
-$auth=get_record_sql($db_link,'SELECT * FROM User_auth WHERE id='.$id);
-$user=get_record_sql($db_link,'SELECT * FROM User_list WHERE id='.$auth['user_id']);
+$auth=get_record_sql($db_link,'SELECT * FROM user_auth WHERE id='.$id);
+$user=get_record_sql($db_link,'SELECT * FROM user_list WHERE id='.$auth['user_id']);
 
 
 ?>
 ?>
 <div id="cont">
 <div id="cont">
@@ -56,7 +56,7 @@ if ($days_shift >730) { $display_date_format='%Y'; }
 $sSQL = "SELECT router_id, DATE_FORMAT(`timestamp`,'$display_date_format') as tHour, 
 $sSQL = "SELECT router_id, DATE_FORMAT(`timestamp`,'$display_date_format') as tHour, 
          SUM(`byte_in`) as byte_in_sum, SUM(`byte_out`) as byte_out_sum,
          SUM(`byte_in`) as byte_in_sum, SUM(`byte_out`) as byte_out_sum,
          MAX(ROUND(`pkt_in`/`step`)) as pkt_in_max, MAX(ROUND(`pkt_out`/`step`)) as pkt_out_max
          MAX(ROUND(`pkt_in`/`step`)) as pkt_in_max, MAX(ROUND(`pkt_out`/`step`)) as pkt_out_max
-         FROM User_stats_full WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' AND auth_id=$id";
+         FROM user_stats_full WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' AND auth_id=$id";
 if ($rgateway == 0) {
 if ($rgateway == 0) {
     $sSQL = $sSQL . " GROUP BY DATE_FORMAT(`timestamp`,'$display_date_format'),router_id ORDER BY tHour,router_id";
     $sSQL = $sSQL . " GROUP BY DATE_FORMAT(`timestamp`,'$display_date_format'),router_id ORDER BY tHour,router_id";
 } else {
 } else {

+ 9 - 9
html/admin/reports/index-full.php

@@ -31,22 +31,22 @@ if (!empty($sort_field) and !empty($order)) { $sort_sql = " ORDER BY $sort_field
 $gateway_list = get_gateways($db_link);
 $gateway_list = get_gateways($db_link);
 
 
 $trafSQL = "SELECT 
 $trafSQL = "SELECT 
-User_list.login,User_list.ou_id,User_auth.user_id, User_auth.ip, User_stats_full.auth_id, 
-User_stats_full.router_id, SUM( byte_in ) AS tin, SUM( byte_out ) AS tout, MAX(ROUND(`pkt_in`/`step`)) as pin, MAX(ROUND(`pkt_out`/`step`)) as pout 
-FROM User_stats_full,User_auth,User_list WHERE User_list.id=User_auth.user_id 
-AND User_stats_full.auth_id = User_auth.id 
-AND User_stats_full.timestamp>='$date1' 
-AND User_stats_full.timestamp<'$date2' 
+user_list.login,user_list.ou_id,user_auth.user_id, user_auth.ip, user_stats_full.auth_id, 
+user_stats_full.router_id, SUM( byte_in ) AS tin, SUM( byte_out ) AS tout, MAX(ROUND(`pkt_in`/`step`)) as pin, MAX(ROUND(`pkt_out`/`step`)) as pout 
+FROM user_stats_full,user_auth,user_list WHERE user_list.id=user_auth.user_id 
+AND user_stats_full.auth_id = user_auth.id 
+AND user_stats_full.timestamp>='$date1' 
+AND user_stats_full.timestamp<'$date2' 
 ";
 ";
 
 
 if ($rou !== 0) {
 if ($rou !== 0) {
-    $trafSQL = $trafSQL . " AND User_list.ou_id=$rou";
+    $trafSQL = $trafSQL . " AND user_list.ou_id=$rou";
 }
 }
 
 
 if ($rgateway == 0) {
 if ($rgateway == 0) {
-    $trafSQL = $trafSQL . " GROUP by User_auth.id,User_stats_full.router_id";
+    $trafSQL = $trafSQL . " GROUP by user_auth.id,user_stats_full.router_id";
 } else {
 } else {
-    $trafSQL = $trafSQL . " AND User_stats_full.router_id=$rgateway GROUP by User_auth.id,User_stats_full.router_id";
+    $trafSQL = $trafSQL . " AND user_stats_full.router_id=$rgateway GROUP by user_auth.id,user_stats_full.router_id";
 }
 }
 
 
 $countSQL = "SELECT Count(*) FROM ($trafSQL) A";
 $countSQL = "SELECT Count(*) FROM ($trafSQL) A";

+ 9 - 9
html/admin/reports/index.php

@@ -39,20 +39,20 @@ if (!empty($sort_field) and !empty($order)) { $sort_sql = " ORDER BY $sort_field
 $gateway_list = get_gateways($db_link);
 $gateway_list = get_gateways($db_link);
 
 
 $trafSQL = "SELECT 
 $trafSQL = "SELECT 
-User_list.login,User_list.ou_id,User_auth.user_id, User_stats.auth_id, 
-User_stats.router_id, SUM( byte_in ) AS tin, SUM( byte_out ) AS tout 
-FROM User_stats,User_auth,User_list WHERE User_list.id=User_auth.user_id 
-AND User_stats.auth_id = User_auth.id 
-AND User_stats.timestamp>='$date1' 
-AND User_stats.timestamp<'$date2' 
+user_list.login,user_list.ou_id,user_auth.user_id, user_stats.auth_id, 
+user_stats.router_id, SUM( byte_in ) AS tin, SUM( byte_out ) AS tout 
+FROM user_stats,user_auth,user_list WHERE user_list.id=user_auth.user_id 
+AND user_stats.auth_id = user_auth.id 
+AND user_stats.timestamp>='$date1' 
+AND user_stats.timestamp<'$date2' 
 ";
 ";
 
 
-if ($rou !== 0) { $trafSQL = $trafSQL . " AND User_list.ou_id=$rou"; }
+if ($rou !== 0) { $trafSQL = $trafSQL . " AND user_list.ou_id=$rou"; }
 
 
 if ($rgateway == 0) {
 if ($rgateway == 0) {
-    $trafSQL = $trafSQL . " GROUP by User_auth.user_id,User_stats.router_id";
+    $trafSQL = $trafSQL . " GROUP by user_auth.user_id,user_stats.router_id";
     } else {
     } else {
-    $trafSQL = $trafSQL . " AND User_stats.router_id=$rgateway GROUP by User_auth.user_id,User_stats.router_id";
+    $trafSQL = $trafSQL . " AND user_stats.router_id=$rgateway GROUP by user_auth.user_id,user_stats.router_id";
     }
     }
 
 
 #set sort
 #set sort

+ 12 - 12
html/admin/reports/userday.php

@@ -7,7 +7,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
 
 
-$user=get_record_sql($db_link,'SELECT * FROM User_list WHERE id='.$id);
+$user=get_record_sql($db_link,'SELECT * FROM user_list WHERE id='.$id);
 
 
 ?>
 ?>
 
 
@@ -35,9 +35,9 @@ $user=get_record_sql($db_link,'SELECT * FROM User_list WHERE id='.$id);
 $gateway_list = get_gateways($db_link);
 $gateway_list = get_gateways($db_link);
 
 
 $gateway_filter='';
 $gateway_filter='';
-if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(User_stats.router_id=$rgateway) AND"; }
+if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(user_stats.router_id=$rgateway) AND"; }
 
 
-$sSQL = "SELECT id,ip,comments FROM User_auth WHERE (User_auth.user_id=$id) Order by IP";
+$sSQL = "SELECT id,ip,comments FROM user_auth WHERE (user_auth.user_id=$id) Order by IP";
 $usersip = get_records_sql($db_link, $sSQL);
 $usersip = get_records_sql($db_link, $sSQL);
 
 
 $ipcount = 0;
 $ipcount = 0;
@@ -49,8 +49,8 @@ foreach ($usersip as $row) {
     $fip = $row["ip"];
     $fip = $row["ip"];
     $fcomm = $row["comments"];
     $fcomm = $row["comments"];
 
 
-    $sSQL = "SELECT SUM(byte_in)+SUM(byte_out) as t_sum FROM User_stats 
-    WHERE $gateway_filter User_stats.timestamp>='$date1' AND User_stats.timestamp<'$date2'AND auth_id=$fid";
+    $sSQL = "SELECT SUM(byte_in)+SUM(byte_out) as t_sum FROM user_stats 
+    WHERE $gateway_filter user_stats.timestamp>='$date1' AND user_stats.timestamp<'$date2'AND auth_id=$fid";
 
 
     $day_summary = get_record_sql($db_link, $sSQL);
     $day_summary = get_record_sql($db_link, $sSQL);
     if (!empty($day_summary)) { $summ = $day_summary['t_sum']; } else { $summ = 0; }
     if (!empty($day_summary)) { $summ = $day_summary['t_sum']; } else { $summ = 0; }
@@ -70,16 +70,16 @@ foreach ($usersip as $row) {
         if ($days_shift >30 and $days_shift <=730) { $display_date_format='%Y-%m'; }
         if ($days_shift >30 and $days_shift <=730) { $display_date_format='%Y-%m'; }
         if ($days_shift >730) { $display_date_format='%Y'; }
         if ($days_shift >730) { $display_date_format='%Y'; }
 
 
-        $sSQL = "SELECT User_stats.router_id, DATE_FORMAT(User_stats.timestamp,'$display_date_format') as tHour,
+        $sSQL = "SELECT user_stats.router_id, DATE_FORMAT(user_stats.timestamp,'$display_date_format') as tHour,
                 SUM(byte_in) as byte_in_sum, SUM(byte_out) as byte_out_sum 
                 SUM(byte_in) as byte_in_sum, SUM(byte_out) as byte_out_sum 
-                FROM User_stats 
-                WHERE User_stats.timestamp>='$date1' AND User_stats.timestamp<'$date2' and auth_id=$fid";
+                FROM user_stats 
+                WHERE user_stats.timestamp>='$date1' AND user_stats.timestamp<'$date2' and auth_id=$fid";
         if ($rgateway == 0) {
         if ($rgateway == 0) {
-            $sSQL = $sSQL . " GROUP BY DATE_FORMAT(User_stats.timestamp,'$display_date_format'),User_stats.router_id 
-            ORDER BY tHour,User_stats.router_id";
+            $sSQL = $sSQL . " GROUP BY DATE_FORMAT(user_stats.timestamp,'$display_date_format'),user_stats.router_id 
+            ORDER BY tHour,user_stats.router_id";
         } else {
         } else {
-            $sSQL = $sSQL . " and User_stats.router_id=$rgateway 
-            GROUP BY DATE_FORMAT(User_stats.timestamp,'$display_date_format'),User_stats.router_id 
+            $sSQL = $sSQL . " and user_stats.router_id=$rgateway 
+            GROUP BY DATE_FORMAT(user_stats.timestamp,'$display_date_format'),user_stats.router_id 
             ORDER BY tHour";
             ORDER BY tHour";
         }
         }
 
 

+ 3 - 3
html/admin/reports/userdaydetail.php

@@ -6,7 +6,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
 
 
-$usersip = get_record_sql($db_link, "SELECT ip,user_id,comments FROM User_auth WHERE User_auth.id=$id");
+$usersip = get_record_sql($db_link, "SELECT ip,user_id,comments FROM user_auth WHERE user_auth.id=$id");
 if (empty($usersip)) {
 if (empty($usersip)) {
     header("location: /admin/reports/index-full.php");
     header("location: /admin/reports/index-full.php");
     exit;
     exit;
@@ -51,7 +51,7 @@ $ip_aton = ip2long($fip);
 $gateway_filter='';
 $gateway_filter='';
 if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(router_id=$rgateway) AND"; }
 if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(router_id=$rgateway) AND"; }
 
 
-$fsql = "SELECT A.proto, A.src_ip, A.src_port, SUM(A.bytes) as tin FROM Traffic_detail A
+$fsql = "SELECT A.proto, A.src_ip, A.src_port, SUM(A.bytes) as tin FROM traffic_detail A
             WHERE $gateway_filter (auth_id='$id') and  `timestamp`>='$date1' and `timestamp`<'$date2' and (A.dst_ip='$ip_aton')
             WHERE $gateway_filter (auth_id='$id') and  `timestamp`>='$date1' and `timestamp`<'$date2' and (A.dst_ip='$ip_aton')
             GROUP BY A.src_ip, A.src_port, A.proto ORDER BY tin DESC LIMIT 0,10";
             GROUP BY A.src_ip, A.src_port, A.proto ORDER BY tin DESC LIMIT 0,10";
 $userdata = get_records_sql($db_link, $fsql);
 $userdata = get_records_sql($db_link, $fsql);
@@ -81,7 +81,7 @@ foreach ($userdata as $row) {
 <td class="data" width=80><b><?php echo WEB_bytes; ?></b></td>
 <td class="data" width=80><b><?php echo WEB_bytes; ?></b></td>
 </tr>
 </tr>
 <?php
 <?php
-$fsql = "SELECT A.proto, A.dst_ip, A.dst_port, SUM(A.bytes) as tout FROM Traffic_detail A
+$fsql = "SELECT A.proto, A.dst_ip, A.dst_port, SUM(A.bytes) as tout FROM traffic_detail A
         WHERE $gateway_filter (auth_id='$id') and  `timestamp`>='$date1' and `timestamp`<'$date2' and (A.src_ip='$ip_aton')
         WHERE $gateway_filter (auth_id='$id') and  `timestamp`>='$date1' and `timestamp`<'$date2' and (A.src_ip='$ip_aton')
         GROUP BY A.dst_ip, A.dst_port, A.proto ORDER BY tout DESC LIMIT 0,10";
         GROUP BY A.dst_ip, A.dst_port, A.proto ORDER BY tout DESC LIMIT 0,10";
 $userdata = get_records_sql($db_link, $fsql);
 $userdata = get_records_sql($db_link, $fsql);

+ 3 - 3
html/admin/reports/userdaydetaillog.php

@@ -17,7 +17,7 @@ if ($rdns) { $dns_checked='checked="checked"'; }
 
 
 $dns_cache=NULL;
 $dns_cache=NULL;
 
 
-$usersip = get_record_sql($db_link, "SELECT ip,user_id,comments FROM User_auth WHERE User_auth.id=$id");
+$usersip = get_record_sql($db_link, "SELECT ip,user_id,comments FROM user_auth WHERE user_auth.id=$id");
 if (empty($usersip)) {
 if (empty($usersip)) {
     header("location: /admin/reports/index-full.php");
     header("location: /admin/reports/index-full.php");
     exit;
     exit;
@@ -51,7 +51,7 @@ $gateway_filter='';
 if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(router_id=$rgateway) AND"; }
 if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(router_id=$rgateway) AND"; }
 if (!empty($search)) { $gateway_filter.=' (src_ip='.ip2long($search).' OR dst_ip='.ip2long($search).') AND'; }
 if (!empty($search)) { $gateway_filter.=' (src_ip='.ip2long($search).' OR dst_ip='.ip2long($search).') AND'; }
 
 
-$countSQL="SELECT Count(*) FROM Traffic_detail as A WHERE $gateway_filter (auth_id='$id') and `timestamp`>='$date1' and `timestamp`<'$date2'";
+$countSQL="SELECT Count(*) FROM traffic_detail as A WHERE $gateway_filter (auth_id='$id') and `timestamp`>='$date1' and `timestamp`<'$date2'";
 $count_records = get_single_field($db_link,$countSQL);
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page>$total) { $page=$total; }
@@ -77,7 +77,7 @@ $gateway_list = get_gateways($db_link);
 <td class="data" width=80><b><?php $url = $sort_url.'&sort=pkt&order='.$new_order."'>".WEB_pkts."</a>"; print $url; ?></b></td>
 <td class="data" width=80><b><?php $url = $sort_url.'&sort=pkt&order='.$new_order."'>".WEB_pkts."</a>"; print $url; ?></b></td>
 </tr>
 </tr>
 <?php
 <?php
-$fsql = "SELECT A.id, A.`timestamp`, A.router_id, A.proto, A.src_ip, A.src_port, A.dst_ip, A.dst_port, A.bytes, A.pkt FROM Traffic_detail as A JOIN (SELECT id FROM Traffic_detail 
+$fsql = "SELECT A.id, A.`timestamp`, A.router_id, A.proto, A.src_ip, A.src_port, A.dst_ip, A.dst_port, A.bytes, A.pkt FROM traffic_detail as A JOIN (SELECT id FROM traffic_detail 
         WHERE $gateway_filter (auth_id='$id') and  `timestamp`>='$date1' and `timestamp`<'$date2'
         WHERE $gateway_filter (auth_id='$id') and  `timestamp`>='$date1' and `timestamp`<'$date2'
         ORDER BY `timestamp` ASC LIMIT $start,$displayed) as T ON A.id = T.id ORDER BY $sort_table.$sort_field $order";
         ORDER BY `timestamp` ASC LIMIT $start,$displayed) as T ON A.id = T.id ORDER BY $sort_table.$sort_field $order";
 $userdata = get_records_sql($db_link, $fsql);
 $userdata = get_records_sql($db_link, $fsql);

+ 1 - 1
html/admin/reports/wan.php

@@ -45,7 +45,7 @@ foreach ($l3_interfaces as $row) {
     print "<td >".WEB_title_forward_output."</td>\n";
     print "<td >".WEB_title_forward_output."</td>\n";
     print "</tr>\n";
     print "</tr>\n";
 
 
-    $trafSQL="SELECT DATE_FORMAT(`time`, '".$dt_template."'  ) AS dt,SUM(`in`) as byte_in,SUM(`out`) as byte_out, SUM(`forward_in`) as byte_f_in,SUM(`forward_out`) as byte_f_out FROM Wan_stats ";
+    $trafSQL="SELECT DATE_FORMAT(`time`, '".$dt_template."'  ) AS dt,SUM(`in`) as byte_in,SUM(`out`) as byte_out, SUM(`forward_in`) as byte_f_in,SUM(`forward_out`) as byte_f_out FROM wan_stats ";
     $trafSQL .=" WHERE router_id='".$device_id."' AND interface_id='".$row['snmpin']."' AND time>='$date1' AND time<'$date2'";
     $trafSQL .=" WHERE router_id='".$device_id."' AND interface_id='".$row['snmpin']."' AND time>='$date1' AND time<'$date2'";
     $trafSQL .=" GROUP BY DATE_FORMAT(`time`, '".$dt_template."' ) ORDER BY dt;";
     $trafSQL .=" GROUP BY DATE_FORMAT(`time`, '".$dt_template."' ) ORDER BY dt;";
 
 

+ 9 - 9
html/admin/users/edit_alias.php

@@ -6,7 +6,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 
 $msg_error = "";
 $msg_error = "";
 
 
-$sSQL = "SELECT * FROM User_auth WHERE id=$id";
+$sSQL = "SELECT * FROM user_auth WHERE id=$id";
 $auth_info = get_record_sql($db_link, $sSQL);
 $auth_info = get_record_sql($db_link, $sSQL);
 
 
 if (empty($auth_info['dns_name']) or $auth_info['deleted']) {
 if (empty($auth_info['dns_name']) or $auth_info['deleted']) {
@@ -14,14 +14,14 @@ if (empty($auth_info['dns_name']) or $auth_info['deleted']) {
     exit;
     exit;
     }
     }
 
 
-run_sql($db_link,"DELETE FROM User_auth_alias WHERE auth_id in (SELECT id FROM User_auth WHERE deleted=1)");
+run_sql($db_link,"DELETE FROM user_auth_alias WHERE auth_id in (SELECT id FROM user_auth WHERE deleted=1)");
 
 
 if (isset($_POST["s_remove"])) {
 if (isset($_POST["s_remove"])) {
     $s_id = $_POST["s_id"];
     $s_id = $_POST["s_id"];
     foreach ($s_id as $key => $val) {
     foreach ($s_id as $key => $val) {
         if (isset($val)) {
         if (isset($val)) {
-            LOG_INFO($db_link, "Remove alias id: $val ".dump_record($db_link,'User_auth_alias','id='.$val));
-            delete_record($db_link, "User_auth_alias", "id=" . $val);
+            LOG_INFO($db_link, "Remove alias id: $val ".dump_record($db_link,'user_auth_alias','id='.$val));
+            delete_record($db_link, "user_auth_alias", "id=" . $val);
         }
         }
     }
     }
     header("Location: " . $page_url);
     header("Location: " . $page_url);
@@ -47,7 +47,7 @@ if (isset($_POST['s_save'])) {
             if (empty($f_dnsname) or !checkValidHostname($f_dnsname) or !checkUniqHostname($db_link,$id,$f_dnsname)) { continue; }
             if (empty($f_dnsname) or !checkValidHostname($f_dnsname) or !checkUniqHostname($db_link,$id,$f_dnsname)) { continue; }
             $new['alias'] = $f_dnsname;
             $new['alias'] = $f_dnsname;
             $new['description'] = trim($_POST['s_comment'][$j]);
             $new['description'] = trim($_POST['s_comment'][$j]);
-            update_record($db_link, "User_auth_alias", "id='{$save_id}'", $new);
+            update_record($db_link, "user_auth_alias", "id='{$save_id}'", $new);
         }
         }
     }
     }
     header("Location: " . $page_url);
     header("Location: " . $page_url);
@@ -80,7 +80,7 @@ if (isset($_POST["s_create"])) {
         $new_rec['alias'] = $f_dnsname;
         $new_rec['alias'] = $f_dnsname;
         $new_rec['auth_id'] = $id;
         $new_rec['auth_id'] = $id;
         LOG_INFO($db_link, "Create new alias $new_alias");
         LOG_INFO($db_link, "Create new alias $new_alias");
-        insert_record($db_link, "User_auth_alias", $new_rec);
+        insert_record($db_link, "user_auth_alias", $new_rec);
     }
     }
     header("Location: " . $page_url);
     header("Location: " . $page_url);
     exit;
     exit;
@@ -111,9 +111,9 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 	<td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="s_remove" value="<?php echo WEB_btn_delete; ?>"></td>
 	<td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="s_remove" value="<?php echo WEB_btn_delete; ?>"></td>
 </tr>
 </tr>
 <?php
 <?php
-$t_User_auth_alias = get_records($db_link,'User_auth_alias',"auth_id=$id ORDER BY alias");
-if (!empty($t_User_auth_alias)) {
-foreach ( $t_User_auth_alias as $row ) {
+$t_user_auth_alias = get_records($db_link,'user_auth_alias',"auth_id=$id ORDER BY alias");
+if (!empty($t_user_auth_alias)) {
+foreach ( $t_user_auth_alias as $row ) {
     print "<tr align=center>\n";
     print "<tr align=center>\n";
     print "<td class=\"data\" style='padding:0'><input type=checkbox name=s_id[] value='{$row['id']}'></td>\n";
     print "<td class=\"data\" style='padding:0'><input type=checkbox name=s_id[] value='{$row['id']}'></td>\n";
     print "<td class=\"data\"><input type=\"hidden\" name='n_id[]' value='{$row['id']}'>{$row['id']}</td>\n";
     print "<td class=\"data\"><input type=\"hidden\" name='n_id[]' value='{$row['id']}'>{$row['id']}</td>\n";

+ 1 - 1
html/admin/users/edit_rules.php

@@ -6,7 +6,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 
 $msg_error = "";
 $msg_error = "";
 
 
-$sSQL = "SELECT * FROM User_list WHERE id=$id";
+$sSQL = "SELECT * FROM user_list WHERE id=$id";
 $auth_info = get_record_sql($db_link, $sSQL);
 $auth_info = get_record_sql($db_link, $sSQL);
 
 
 if (isset($_POST["s_remove"])) {
 if (isset($_POST["s_remove"])) {

+ 22 - 22
html/admin/users/editauth.php

@@ -5,14 +5,14 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/idfilter.php");
 
 
 $msg_error = "";
 $msg_error = "";
 
 
-$old_auth_info = get_record_sql($db_link, "SELECT * FROM User_auth WHERE id=" . $id);
+$old_auth_info = get_record_sql($db_link, "SELECT * FROM user_auth WHERE id=" . $id);
 if (empty($old_auth_info)) {
 if (empty($old_auth_info)) {
     header("Location: /admin/");
     header("Location: /admin/");
     }
     }
 
 
 $parent_id = $old_auth_info['user_id'];
 $parent_id = $old_auth_info['user_id'];
 
 
-$user_info = get_record_sql($db_link, "SELECT * FROM User_list WHERE id=" . $parent_id);
+$user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=" . $parent_id);
 $parent_ou_id = $user_info['ou_id'];
 $parent_ou_id = $user_info['ou_id'];
 $user_enabled = $user_info['enabled'];
 $user_enabled = $user_info['enabled'];
 
 
@@ -24,7 +24,7 @@ if (isset($_POST["editauth"]) and !$old_auth_info['deleted']) {
         //search mac
         //search mac
         $mac_exists = find_mac_in_subnet($db_link, $ip, $mac);
         $mac_exists = find_mac_in_subnet($db_link, $ip, $mac);
         if (isset($mac_exists) and $mac_exists['count'] >= 1 and !in_array($parent_id, $mac_exists['users_id'])) {
         if (isset($mac_exists) and $mac_exists['count'] >= 1 and !in_array($parent_id, $mac_exists['users_id'])) {
-            $dup_sql = "SELECT * FROM User_list WHERE id=" . $mac_exists['users_id']['0'];
+            $dup_sql = "SELECT * FROM user_list WHERE id=" . $mac_exists['users_id']['0'];
             $dup_info = get_record_sql($db_link, $dup_sql);
             $dup_info = get_record_sql($db_link, $dup_sql);
             $msg_error = "Mac already exists at another user in this subnet! Skip creating $ip [$mac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
             $msg_error = "Mac already exists at another user in this subnet! Skip creating $ip [$mac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
             $_SESSION[$page_url]['msg'] = $msg_error;
             $_SESSION[$page_url]['msg'] = $msg_error;
@@ -40,9 +40,9 @@ if (isset($_POST["editauth"]) and !$old_auth_info['deleted']) {
             }
             }
         }
         }
         //search ip
         //search ip
-        $dup_ip_record = get_record_sql($db_link, "SELECT * FROM User_auth WHERE `ip_int`=$ip_aton AND id<>$id AND deleted=0");
+        $dup_ip_record = get_record_sql($db_link, "SELECT * FROM user_auth WHERE `ip_int`=$ip_aton AND id<>$id AND deleted=0");
         if (!empty($dup_ip_record)) {
         if (!empty($dup_ip_record)) {
-            $dup_info = get_record_sql($db_link, "SELECT * FROM User_list WHERE id=" . $dup_ip_record['user_id']);
+            $dup_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=" . $dup_ip_record['user_id']);
             $msg_error = "$ip already exists. Skip creating $ip [$mac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
             $msg_error = "$ip already exists. Skip creating $ip [$mac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
             $_SESSION[$page_url]['msg'] = $msg_error;
             $_SESSION[$page_url]['msg'] = $msg_error;
             LOG_ERROR($db_link, $msg_error);
             LOG_ERROR($db_link, $msg_error);
@@ -68,7 +68,7 @@ if (isset($_POST["editauth"]) and !$old_auth_info['deleted']) {
             update_record($db_link,"devices","id=".$device['id'],$dev);
             update_record($db_link,"devices","id=".$device['id'],$dev);
             }
             }
 
 
-        $dns_alias_count = get_count_records($db_link,'User_auth_alias','auth_id='.$id);
+        $dns_alias_count = get_count_records($db_link,'user_auth_alias','auth_id='.$id);
         if (!empty($f_dnsname) and !$new['dns_ptr_only']) {
         if (!empty($f_dnsname) and !$new['dns_ptr_only']) {
             $domain_zone = get_option($db_link, 33);
             $domain_zone = get_option($db_link, 33);
             $domain_zone = ltrim($domain_zone, '.');
             $domain_zone = ltrim($domain_zone, '.');
@@ -101,11 +101,11 @@ if (isset($_POST["editauth"]) and !$old_auth_info['deleted']) {
         if (empty($f_dnsname) or $new['dns_ptr_only']) {
         if (empty($f_dnsname) or $new['dns_ptr_only']) {
             //remove all dns aliases
             //remove all dns aliases
             $new['dns_name'] = '';
             $new['dns_name'] = '';
-            $t_User_auth_alias = get_records($db_link,'User_auth_alias',"auth_id=$id ORDER BY alias");
-            if (!empty($t_User_auth_alias)) {
-                foreach ( $t_User_auth_alias as $row ) {
-                    LOG_INFO($db_link, "Remove alias id: ".$row['id']." for auth_id: $id :: ".dump_record($db_link,'User_auth_alias','id='.$row['id']));
-                    delete_record($db_link,'User_auth_alias','id='.$row['id']);
+            $t_user_auth_alias = get_records($db_link,'user_auth_alias',"auth_id=$id ORDER BY alias");
+            if (!empty($t_user_auth_alias)) {
+                foreach ( $t_user_auth_alias as $row ) {
+                    LOG_INFO($db_link, "Remove alias id: ".$row['id']." for auth_id: $id :: ".dump_record($db_link,'user_auth_alias','id='.$row['id']));
+                    delete_record($db_link,'user_auth_alias','id='.$row['id']);
                     }
                     }
                 }
                 }
             }
             }
@@ -155,7 +155,7 @@ if (isset($_POST["editauth"]) and !$old_auth_info['deleted']) {
             $new['nagios_status'] = 'UP';
             $new['nagios_status'] = 'UP';
             }
             }
         if (!$user_enabled) { $new['enabled']=0; }
         if (!$user_enabled) { $new['enabled']=0; }
-        $changes = get_diff_rec($db_link, "User_auth", "id='$id'", $new, 0);
+        $changes = get_diff_rec($db_link, "user_auth", "id='$id'", $new, 0);
         if (!empty($changes)) {
         if (!empty($changes)) {
             LOG_WARNING($db_link, "Changed record for $ip! Log: " . $changes, $id);
             LOG_WARNING($db_link, "Changed record for $ip! Log: " . $changes, $id);
             }
             }
@@ -168,7 +168,7 @@ if (isset($_POST["editauth"]) and !$old_auth_info['deleted']) {
                 }
                 }
             exit;
             exit;
             } else {
             } else {
-            update_record($db_link, "User_auth", "id='$id'", $new);
+            update_record($db_link, "user_auth", "id='$id'", $new);
             }
             }
     } else {
     } else {
         $msg_error = "$msg_ip_error xxx.xxx.xxx.xxx";
         $msg_error = "$msg_ip_error xxx.xxx.xxx.xxx";
@@ -180,9 +180,9 @@ if (isset($_POST["editauth"]) and !$old_auth_info['deleted']) {
 
 
 if (isset($_POST["moveauth"]) and !$old_auth_info['deleted']) {
 if (isset($_POST["moveauth"]) and !$old_auth_info['deleted']) {
     $new_parent_id = $_POST["f_new_parent"] * 1;
     $new_parent_id = $_POST["f_new_parent"] * 1;
-    $moved_auth = get_record_sql($db_link,"SELECT comments FROM User_auth WHERE id=".$id);
+    $moved_auth = get_record_sql($db_link,"SELECT comments FROM user_auth WHERE id=".$id);
     $changes = apply_auth_rule($db_link, $moved_auth, $new_parent_id);
     $changes = apply_auth_rule($db_link, $moved_auth, $new_parent_id);
-    update_record($db_link, "User_auth", "id='$id'", $changes);
+    update_record($db_link, "user_auth", "id='$id'", $changes);
     LOG_WARNING($db_link, "IP-address moved to another user! Applyed: " . get_rec_str($changes), $id);
     LOG_WARNING($db_link, "IP-address moved to another user! Applyed: " . get_rec_str($changes), $id);
     run_sql($db_link,"DELETE FROM auth_rules WHERE user_id=".$old_auth_info["user_id"]." AND rule='".$old_auth_info["mac"]."' AND type=2");
     run_sql($db_link,"DELETE FROM auth_rules WHERE user_id=".$old_auth_info["user_id"]." AND rule='".$old_auth_info["mac"]."' AND type=2");
     run_sql($db_link,"DELETE FROM auth_rules WHERE user_id=".$old_auth_info["user_id"]." AND rule='".$old_auth_info["ip"]."' AND type=1");
     run_sql($db_link,"DELETE FROM auth_rules WHERE user_id=".$old_auth_info["user_id"]." AND rule='".$old_auth_info["ip"]."' AND type=1");
@@ -199,7 +199,7 @@ if (isset($_POST["recovery"]) and $old_auth_info['deleted']) {
         //search mac
         //search mac
         $mac_exists = find_mac_in_subnet($db_link, $ip, $mac);
         $mac_exists = find_mac_in_subnet($db_link, $ip, $mac);
         if (isset($mac_exists) and $mac_exists['count'] >= 1 and !in_array($parent_id, $mac_exists['users_id'])) {
         if (isset($mac_exists) and $mac_exists['count'] >= 1 and !in_array($parent_id, $mac_exists['users_id'])) {
-            $dup_sql = "SELECT * FROM User_list WHERE id=" . $mac_exists['users_id']['0'];
+            $dup_sql = "SELECT * FROM user_list WHERE id=" . $mac_exists['users_id']['0'];
             $dup_info = get_record_sql($db_link, $dup_sql);
             $dup_info = get_record_sql($db_link, $dup_sql);
             $msg_error = "Mac already exists at another user in this subnet! Skip creating $ip [$mac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
             $msg_error = "Mac already exists at another user in this subnet! Skip creating $ip [$mac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
             $_SESSION[$page_url]['msg'] = $msg_error;
             $_SESSION[$page_url]['msg'] = $msg_error;
@@ -215,9 +215,9 @@ if (isset($_POST["recovery"]) and $old_auth_info['deleted']) {
             }
             }
         }
         }
         //search ip
         //search ip
-        $dup_ip_record = get_record_sql($db_link, "SELECT * FROM User_auth WHERE `ip_int`=$ip_aton AND id<>$id AND deleted=0");
+        $dup_ip_record = get_record_sql($db_link, "SELECT * FROM user_auth WHERE `ip_int`=$ip_aton AND id<>$id AND deleted=0");
         if (!empty($dup_ip_record)) {
         if (!empty($dup_ip_record)) {
-            $dup_info = get_record_sql($db_link, "SELECT * FROM User_list WHERE id=" . $dup_ip_record['user_id']);
+            $dup_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=" . $dup_ip_record['user_id']);
             $msg_error = "$ip already exists. Skip creating $ip [$mac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
             $msg_error = "$ip already exists. Skip creating $ip [$mac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
             $_SESSION[$page_url]['msg'] = $msg_error;
             $_SESSION[$page_url]['msg'] = $msg_error;
             LOG_ERROR($db_link, $msg_error);
             LOG_ERROR($db_link, $msg_error);
@@ -230,7 +230,7 @@ if (isset($_POST["recovery"]) and $old_auth_info['deleted']) {
 
 
         $parent_id = $old_auth_info['user_id'];
         $parent_id = $old_auth_info['user_id'];
 
 
-        $old_parent = get_record_sql($db_link, "SELECT * FROM User_list WHERE id=".$parent_id);
+        $old_parent = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=".$parent_id);
         if (empty($old_parent)) {
         if (empty($old_parent)) {
             $new_user_info = get_new_user_id($db_link, $ip, $mac, NULL);
             $new_user_info = get_new_user_id($db_link, $ip, $mac, NULL);
             if ($new_user_info['user_id']) { $new_user_id = $new_user_info['user_id']; }
             if ($new_user_info['user_id']) { $new_user_id = $new_user_info['user_id']; }
@@ -263,12 +263,12 @@ if (isset($_POST["recovery"]) and $old_auth_info['deleted']) {
             $new['queue_id'] = get_int($_POST["f_queue_id"]);
             $new['queue_id'] = get_int($_POST["f_queue_id"]);
             $new['filter_group_id'] = get_int($_POST["f_group_id"]);
             $new['filter_group_id'] = get_int($_POST["f_group_id"]);
         }
         }
-        $changes = get_diff_rec($db_link, "User_auth", "id='$id'", $new, 0);
+        $changes = get_diff_rec($db_link, "user_auth", "id='$id'", $new, 0);
         if (!empty($changes)) {
         if (!empty($changes)) {
             LOG_WARNING($db_link, "Recovered ip-address. Applyed: $changes", $id);
             LOG_WARNING($db_link, "Recovered ip-address. Applyed: $changes", $id);
         }
         }
         $new = apply_auth_rule($db_link, $new, $new['user_id']);
         $new = apply_auth_rule($db_link, $new, $new['user_id']);
-        update_record($db_link, "User_auth", "id='$id'", $new);
+        update_record($db_link, "user_auth", "id='$id'", $new);
     } else {
     } else {
         $msg_error = "$msg_ip_error xxx.xxx.xxx.xxx/xx";
         $msg_error = "$msg_ip_error xxx.xxx.xxx.xxx/xx";
         $_SESSION[$page_url]['msg'] = $msg_error;
         $_SESSION[$page_url]['msg'] = $msg_error;
@@ -281,7 +281,7 @@ unset($_POST);
 
 
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
 
 
-$sSQL = "SELECT * FROM User_auth WHERE id=$id";
+$sSQL = "SELECT * FROM user_auth WHERE id=$id";
 $auth_info = get_record_sql($db_link, $sSQL);
 $auth_info = get_record_sql($db_link, $sSQL);
 $device = get_record_sql($db_link, "SELECT * FROM devices WHERE user_id=" . $auth_info['user_id']);
 $device = get_record_sql($db_link, "SELECT * FROM devices WHERE user_id=" . $auth_info['user_id']);
 
 

+ 21 - 21
html/admin/users/edituser.php

@@ -8,7 +8,7 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/sortfilter.php");
 
 
 $msg_error = "";
 $msg_error = "";
 
 
-$sSQL = "SELECT * FROM User_list WHERE id=$id";
+$sSQL = "SELECT * FROM user_list WHERE id=$id";
 $user_info = get_record_sql($db_link, $sSQL);
 $user_info = get_record_sql($db_link, $sSQL);
 
 
 if (empty($user_info)) {
 if (empty($user_info)) {
@@ -36,18 +36,18 @@ if (isset($_POST["edituser"])) {
         $new["month_quota"] = get_int(trim($_POST["f_permonth"]));
         $new["month_quota"] = get_int(trim($_POST["f_permonth"]));
         $new["permanent"] = $_POST["f_permanent"] * 1;
         $new["permanent"] = $_POST["f_permanent"] * 1;
     }
     }
-    $changes = get_diff_rec($db_link, "User_list", "id='$id'", $new, 0);
+    $changes = get_diff_rec($db_link, "user_list", "id='$id'", $new, 0);
     if (!empty($changes)) {
     if (!empty($changes)) {
         LOG_WARNING($db_link, "Changed user id: $id login: " . $new["login"] . ". \r\nApply: $changes");
         LOG_WARNING($db_link, "Changed user id: $id login: " . $new["login"] . ". \r\nApply: $changes");
     }
     }
-    update_record($db_link, "User_list", "id='$id'", $new);
+    update_record($db_link, "user_list", "id='$id'", $new);
     if (!$new["enabled"]) {
     if (!$new["enabled"]) {
-        run_sql($db_link, "UPDATE User_auth SET enabled=0, changed=1 WHERE user_id=" . $id);
+        run_sql($db_link, "UPDATE user_auth SET enabled=0, changed=1 WHERE user_id=" . $id);
     }
     }
     if (!empty($new["fio"])) {
     if (!empty($new["fio"])) {
-        run_sql($db_link, "UPDATE User_auth SET `comments`='" . db_escape($db_link, $new["fio"]) . "' WHERE `user_id`=" . $id . " AND `deleted`=0 AND (`comments` IS NULL or `comments`='' or `comments`='" . $user_info["fio"] . "')");
+        run_sql($db_link, "UPDATE user_auth SET `comments`='" . db_escape($db_link, $new["fio"]) . "' WHERE `user_id`=" . $id . " AND `deleted`=0 AND (`comments` IS NULL or `comments`='' or `comments`='" . $user_info["fio"] . "')");
     }
     }
-    run_sql($db_link, "UPDATE User_auth SET ou_id=" . $new["ou_id"] . " WHERE user_id=" . $id);
+    run_sql($db_link, "UPDATE user_auth SET ou_id=" . $new["ou_id"] . " WHERE user_id=" . $id);
     run_sql($db_link, "UPDATE devices SET device_name='" . $new["login"] . "' WHERE user_id=" . $id);
     run_sql($db_link, "UPDATE devices SET device_name='" . $new["login"] . "' WHERE user_id=" . $id);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
     exit;
@@ -55,7 +55,7 @@ if (isset($_POST["edituser"])) {
 
 
 if (isset($_POST["addMacRule"])) {
 if (isset($_POST["addMacRule"])) {
     unset($new);
     unset($new);
-    $first_auth = get_records_sql($db_link, "SELECT mac FROM User_auth WHERE user_id=" . $id . " AND deleted=0 AND LENGTH(mac)>0 ORDER BY id");
+    $first_auth = get_records_sql($db_link, "SELECT mac FROM user_auth WHERE user_id=" . $id . " AND deleted=0 AND LENGTH(mac)>0 ORDER BY id");
     foreach ($first_auth as $row) {
     foreach ($first_auth as $row) {
         if (!empty($row['mac'])) { add_auth_rule($db_link, $row['mac'], 2, $id); }
         if (!empty($row['mac'])) { add_auth_rule($db_link, $row['mac'], 2, $id); }
         }
         }
@@ -72,7 +72,7 @@ if (isset($_POST["delMacRule"])) {
 
 
 if (isset($_POST["addIPRule"])) {
 if (isset($_POST["addIPRule"])) {
     unset($new);
     unset($new);
-    $first_auth = get_records_sql($db_link, "SELECT ip FROM User_auth WHERE user_id=" . $id . " AND deleted=0 AND LENGTH(ip)>0 ORDER BY id");
+    $first_auth = get_records_sql($db_link, "SELECT ip FROM user_auth WHERE user_id=" . $id . " AND deleted=0 AND LENGTH(ip)>0 ORDER BY id");
     foreach ($first_auth as $row) {
     foreach ($first_auth as $row) {
         if (!empty($row['ip'])) { add_auth_rule($db_link, $row['ip'], 1, $id); }
         if (!empty($row['ip'])) { add_auth_rule($db_link, $row['ip'], 1, $id); }
         }
         }
@@ -89,7 +89,7 @@ if (isset($_POST["delIPRule"])) {
 
 
 if (isset($_POST["showDevice"])) {
 if (isset($_POST["showDevice"])) {
     $device = get_record_sql($db_link, "SELECT * FROM devices WHERE user_id=" . $id);
     $device = get_record_sql($db_link, "SELECT * FROM devices WHERE user_id=" . $id);
-    $auth = get_record_sql($db_link, "SELECT * FROM User_auth WHERE user_id=" . $id);
+    $auth = get_record_sql($db_link, "SELECT * FROM user_auth WHERE user_id=" . $id);
     if (empty($device) and !empty($auth)) {
     if (empty($device) and !empty($auth)) {
         $new['user_id'] = $id;
         $new['user_id'] = $id;
         $new['device_name'] = $user_info['login'];
         $new['device_name'] = $user_info['login'];
@@ -137,7 +137,7 @@ if (isset($_POST["addauth"])) {
             if (!empty($fmac) and !empty($fip)) {
             if (!empty($fmac) and !empty($fip)) {
                 $mac_exists = find_mac_in_subnet($db_link, $fip, $fmac);
                 $mac_exists = find_mac_in_subnet($db_link, $fip, $fmac);
                 if (!empty($mac_exists) and $mac_exists['count'] >= 1 and !in_array($id, $mac_exists['users_id'])) {
                 if (!empty($mac_exists) and $mac_exists['count'] >= 1 and !in_array($id, $mac_exists['users_id'])) {
-                    $dup_sql = "SELECT * FROM User_list WHERE id=" . $mac_exists['users_id']['0'];
+                    $dup_sql = "SELECT * FROM user_list WHERE id=" . $mac_exists['users_id']['0'];
                     $dup_info = get_record_sql($db_link, $dup_sql);
                     $dup_info = get_record_sql($db_link, $dup_sql);
                     $msg_error = "Mac already exists at another user in this subnet! Skip creating $fip [$fmac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
                     $msg_error = "Mac already exists at another user in this subnet! Skip creating $fip [$fmac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
                     $_SESSION[$page_url]['msg'] = $msg_error;
                     $_SESSION[$page_url]['msg'] = $msg_error;
@@ -155,9 +155,9 @@ if (isset($_POST["addauth"])) {
                 }
                 }
             }
             }
             //search ip
             //search ip
-            $dup_ip_record = get_record_sql($db_link, "SELECT * FROM User_auth WHERE `ip_int`=$ip_aton AND user_id<>" . $id . " AND deleted=0");
+            $dup_ip_record = get_record_sql($db_link, "SELECT * FROM user_auth WHERE `ip_int`=$ip_aton AND user_id<>" . $id . " AND deleted=0");
             if (!empty($dup_ip_record)) {
             if (!empty($dup_ip_record)) {
-                $dup_info = get_record_sql($db_link, "SELECT * FROM User_list WHERE id=" . $dup_ip_record['user_id']);
+                $dup_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=" . $dup_ip_record['user_id']);
                 $msg_error = "$fip already exists. Skip creating $fip [$fmac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
                 $msg_error = "$fip already exists. Skip creating $fip [$fmac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
                 $_SESSION[$page_url]['msg'] = $msg_error;
                 $_SESSION[$page_url]['msg'] = $msg_error;
                 LOG_ERROR($db_link, $msg_error);
                 LOG_ERROR($db_link, $msg_error);
@@ -169,7 +169,7 @@ if (isset($_POST["addauth"])) {
                 $new['dhcp'] = $f_dhcp;
                 $new['dhcp'] = $f_dhcp;
                 $new['created_by'] = 'manual';
                 $new['created_by'] = 'manual';
                 if (!empty($fcomment)) { $new['comments'] = $fcomment; }
                 if (!empty($fcomment)) { $new['comments'] = $fcomment; }
-                update_record($db_link, "User_auth", "id=" . $fid, $new);
+                update_record($db_link, "user_auth", "id=" . $fid, $new);
                 LOG_WARNING($db_link, "Add ip for login: " . $user_info["login"] . ": ip => $fip, mac => $fmac", $fid);
                 LOG_WARNING($db_link, "Add ip for login: " . $user_info["login"] . ": ip => $fip, mac => $fmac", $fid);
                 header("Location: /admin/users/editauth.php?id=" . $fid);
                 header("Location: /admin/users/editauth.php?id=" . $fid);
                 exit;
                 exit;
@@ -198,7 +198,7 @@ if (isset($_POST["new_user"])) {
     $save_traf = get_option($db_link, 23) * 1;
     $save_traf = get_option($db_link, 23) * 1;
     foreach ($auth_id as $key => $val) {
     foreach ($auth_id as $key => $val) {
         if ($val) {
         if ($val) {
-            $auth_info = get_record_sql($db_link, "SELECT * FROM User_auth WHERE id=$val");
+            $auth_info = get_record_sql($db_link, "SELECT * FROM user_auth WHERE id=$val");
             $ou_id = $user_info["ou_id"];
             $ou_id = $user_info["ou_id"];
             $login = NULL;
             $login = NULL;
             if (!empty($auth_info["dns_name"])) {
             if (!empty($auth_info["dns_name"])) {
@@ -216,14 +216,14 @@ if (isset($_POST["new_user"])) {
             if (empty($login)) {
             if (empty($login)) {
                 $login = $auth_info["ip"];
                 $login = $auth_info["ip"];
             }
             }
-            $new_user = get_record_sql($db_link, "SELECT * FROM User_list WHERE LCase(login)=LCase('$login') and deleted=0");
+            $new_user = get_record_sql($db_link, "SELECT * FROM user_list WHERE LCase(login)=LCase('$login') and deleted=0");
             if (!empty($new_user)) {
             if (!empty($new_user)) {
                 // move auth
                 // move auth
                 $auth["user_id"] = $new_user["id"];
                 $auth["user_id"] = $new_user["id"];
                 $auth["ou_id"] = $new_user["ou_id"];
                 $auth["ou_id"] = $new_user["ou_id"];
                 $auth["save_traf"] = $save_traf;
                 $auth["save_traf"] = $save_traf;
                 $auth = apply_auth_rule($db_link, $auth, $l_id);
                 $auth = apply_auth_rule($db_link, $auth, $l_id);
-                update_record($db_link, "User_auth", "id='" . $val . "'", $auth);
+                update_record($db_link, "user_auth", "id='" . $val . "'", $auth);
                 LOG_WARNING($db_link, "ip from id: $val moved to another user user_id: " . $new_user["id"], $val);
                 LOG_WARNING($db_link, "ip from id: $val moved to another user user_id: " . $new_user["id"], $val);
             } else {
             } else {
                 $new["login"] = $login;
                 $new["login"] = $login;
@@ -232,10 +232,10 @@ if (isset($_POST["new_user"])) {
                 if (!isset($new["fio"]) and !empty($auth_info["dns_name"])) { $new["fio"] = $auth_info["dns_name"]; }
                 if (!isset($new["fio"]) and !empty($auth_info["dns_name"])) { $new["fio"] = $auth_info["dns_name"]; }
                 if (!isset($new["fio"]) and !empty($auth_info["dhcp_hostname"])) { $new["fio"] = $auth_info["dhcp_hostname"]; }
                 if (!isset($new["fio"]) and !empty($auth_info["dhcp_hostname"])) { $new["fio"] = $auth_info["dhcp_hostname"]; }
                 $new["enabled"] = $auth_info["enabled"];
                 $new["enabled"] = $auth_info["enabled"];
-                $l_id = insert_record($db_link, "User_list", $new);
+                $l_id = insert_record($db_link, "user_list", $new);
                 $auth["user_id"] = $l_id;
                 $auth["user_id"] = $l_id;
                 $auth["save_traf"] = $save_traf;
                 $auth["save_traf"] = $save_traf;
-                update_record($db_link, "User_auth", "id='" . $val . "'", $auth);
+                update_record($db_link, "user_auth", "id='" . $val . "'", $auth);
                 LOG_WARNING($db_link, "Create user from ip: login => $login. ip-record auth_id: $val moved to this user.", $val);
                 LOG_WARNING($db_link, "Create user from ip: login => $login. ip-record auth_id: $val moved to this user.", $val);
             }
             }
         }
         }
@@ -304,7 +304,7 @@ require_once($_SERVER["DOCUMENT_ROOT"] . "/inc/header.php");
                 print "</td>";
                 print "</td>";
                 $rule_count = get_count_records($db_link, "auth_rules", "user_id=" . $id);
                 $rule_count = get_count_records($db_link, "auth_rules", "user_id=" . $id);
                 print "<td > Count: " . $rule_count . "</td>";
                 print "<td > Count: " . $rule_count . "</td>";
-                $first_auth = get_record_sql($db_link, "SELECT id FROM User_auth WHERE user_id=" . $id . " AND deleted=0 ORDER BY id");
+                $first_auth = get_record_sql($db_link, "SELECT id FROM user_auth WHERE user_id=" . $id . " AND deleted=0 ORDER BY id");
                 if (!empty($first_auth)) {
                 if (!empty($first_auth)) {
                     //mac
                     //mac
                     $mac_rule_count = get_count_records($db_link, "auth_rules", "user_id=" . $id . " AND type=2");
                     $mac_rule_count = get_count_records($db_link, "auth_rules", "user_id=" . $id . " AND type=2");
@@ -341,7 +341,7 @@ require_once($_SERVER["DOCUMENT_ROOT"] . "/inc/header.php");
             print "<div id='msg'><b>$msg_error</b></div><br>\n";
             print "<div id='msg'><b>$msg_error</b></div><br>\n";
         }
         }
 
 
-        $sort_table = 'User_auth';
+        $sort_table = 'user_auth';
         $sort_url = "<a href=edituser.php?id=" . $id;
         $sort_url = "<a href=edituser.php?id=" . $id;
         ?>
         ?>
 
 
@@ -373,7 +373,7 @@ require_once($_SERVER["DOCUMENT_ROOT"] . "/inc/header.php");
 
 
             <?php
             <?php
 
 
-            $flist = get_records($db_link, 'User_auth', "user_id=" . $id . " and deleted=0 ORDER BY $sort_table.$sort_field $order");
+            $flist = get_records($db_link, 'user_auth', "user_id=" . $id . " and deleted=0 ORDER BY $sort_table.$sort_field $order");
             if (!empty($flist)) {
             if (!empty($flist)) {
                 foreach ($flist as $row) {
                 foreach ($flist as $row) {
                     $dhcp_str = '';
                     $dhcp_str = '';

+ 5 - 5
html/admin/users/index.php

@@ -12,7 +12,7 @@ $msg_error = "";
 if (isset($_POST["create"])) {
 if (isset($_POST["create"])) {
     $login = trim($_POST["newlogin"]);
     $login = trim($_POST["newlogin"]);
     if (!empty($login)) {
     if (!empty($login)) {
-        $lcount = get_count_records($db_link,"User_list","LCase(login)=LCase('$login')");
+        $lcount = get_count_records($db_link,"user_list","LCase(login)=LCase('$login')");
         if ($lcount > 0) {
         if ($lcount > 0) {
             $msg_error = WEB_cell_login." ".$login." ".$msg_exists."!";
             $msg_error = WEB_cell_login." ".$login." ".$msg_exists."!";
             unset($_POST);
             unset($_POST);
@@ -28,7 +28,7 @@ if (isset($_POST["create"])) {
 	        $new['queue_id'] = $ou_info['queue_id'];
 	        $new['queue_id'] = $ou_info['queue_id'];
 	        $new['filter_group_id'] = $ou_info['filter_group_id'];
 	        $new['filter_group_id'] = $ou_info['filter_group_id'];
 	        }
 	        }
-            $lid=insert_record($db_link, "User_list", $new);
+            $lid=insert_record($db_link, "user_list", $new);
             LOG_WARNING($db_link,"Создан новый пользователь: Login => $login");
             LOG_WARNING($db_link,"Создан новый пользователь: Login => $login");
             header("Location: edituser.php?id=$lid");
             header("Location: edituser.php?id=$lid");
             exit;
             exit;
@@ -105,7 +105,7 @@ $sort_url = "<a href=/admin/users/index.php?";
 
 
 if ($rou == 0) { $filter = "U.ou_id=O.id and U.deleted=0"; } else { $filter = "U.OU_id=O.id and U.deleted=0 and U.ou_id=$rou"; }
 if ($rou == 0) { $filter = "U.ou_id=O.id and U.deleted=0"; } else { $filter = "U.OU_id=O.id and U.deleted=0 and U.ou_id=$rou"; }
 
 
-$countSQL = "SELECT Count(*) FROM User_list U, OU O WHERE $filter";
+$countSQL = "SELECT Count(*) FROM user_list U, OU O WHERE $filter";
 $count_records = get_single_field($db_link,$countSQL);
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page>$total) { $page=$total; }
@@ -113,7 +113,7 @@ if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed;
 $start = ($page * $displayed) - $displayed;
 print_navigation($page_url,$page,$displayed,$count_records,$total);
 print_navigation($page_url,$page,$displayed,$count_records,$total);
 
 
-$sSQL = "SELECT U.id, U.login, U.fio, O.ou_name, U.enabled, U.day_quota, U.month_quota, U.blocked, U.permanent FROM User_list U, OU O WHERE $filter ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
+$sSQL = "SELECT U.id, U.login, U.fio, O.ou_name, U.enabled, U.day_quota, U.month_quota, U.blocked, U.permanent FROM user_list U, OU O WHERE $filter ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
 
 
 ?>
 ?>
 
 
@@ -137,7 +137,7 @@ $sSQL = "SELECT U.id, U.login, U.fio, O.ou_name, U.enabled, U.day_quota, U.month
 $users = get_records_sql($db_link, $sSQL);
 $users = get_records_sql($db_link, $sSQL);
 
 
 foreach ($users as $row) {
 foreach ($users as $row) {
-    $auth_customs = get_count_records($db_link,"User_auth","user_id=".$row['id']." AND deleted=0 AND enabled <>'".$row['enabled']."'");
+    $auth_customs = get_count_records($db_link,"user_auth","user_id=".$row['id']." AND deleted=0 AND enabled <>'".$row['enabled']."'");
     $cl = "data";
     $cl = "data";
     if (! $row['enabled']) {
     if (! $row['enabled']) {
         $cl = "off";
         $cl = "off";

+ 8 - 8
html/api.php

@@ -37,12 +37,12 @@ if (!empty($action)) {
           $sql='';
           $sql='';
           LOG_VERBOSE($db_link,"API: Get User Auth record with ip: $ip mac: $mac id: $rec_id");
           LOG_VERBOSE($db_link,"API: Get User Auth record with ip: $ip mac: $mac id: $rec_id");
           if (!empty($mac) and !empty($ip_aton)) { 
           if (!empty($mac) and !empty($ip_aton)) { 
-                $sql="SELECT * FROM User_auth WHERE `ip_int`=".$ip_aton." AND `mac`='".$mac."' AND deleted=0"; 
+                $sql="SELECT * FROM user_auth WHERE `ip_int`=".$ip_aton." AND `mac`='".$mac."' AND deleted=0"; 
               } else {
               } else {
-              if (!empty($ip_aton)) { $sql = "SELECT * FROM User_auth WHERE `ip_int`=".$ip_aton." AND deleted=0"; }
-              if (!empty($mac)) { $sql="SELECT * FROM User_auth WHERE `mac`='".$mac."' AND deleted=0"; }
+              if (!empty($ip_aton)) { $sql = "SELECT * FROM user_auth WHERE `ip_int`=".$ip_aton." AND deleted=0"; }
+              if (!empty($mac)) { $sql="SELECT * FROM user_auth WHERE `mac`='".$mac."' AND deleted=0"; }
               }
               }
-          if (!empty($rec_id)) { $sql="SELECT * FROM User_auth WHERE id=".$rec_id; }
+          if (!empty($rec_id)) { $sql="SELECT * FROM user_auth WHERE id=".$rec_id; }
           if (!empty($sql)) {
           if (!empty($sql)) {
               $result=get_record_sql($db_link,$sql);
               $result=get_record_sql($db_link,$sql);
               if (!empty($result)) {
               if (!empty($result)) {
@@ -71,11 +71,11 @@ if (!empty($action)) {
           $sql='';
           $sql='';
           LOG_VERBOSE($db_link,"API: Get User record with id: $rec_id");
           LOG_VERBOSE($db_link,"API: Get User record with id: $rec_id");
           if (!empty($rec_id)) {
           if (!empty($rec_id)) {
-                $sql="SELECT * FROM User_list WHERE id=$rec_id";
+                $sql="SELECT * FROM user_list WHERE id=$rec_id";
                 $result=get_record_sql($db_link,$sql);
                 $result=get_record_sql($db_link,$sql);
                 if (!empty($result)) {
                 if (!empty($result)) {
                     LOG_VERBOSE($db_link,"API: User record found.");
                     LOG_VERBOSE($db_link,"API: User record found.");
-                    $sql="SELECT * FROM User_auth WHERE deleted=0 AND user_id=".$rec_id;
+                    $sql="SELECT * FROM user_auth WHERE deleted=0 AND user_id=".$rec_id;
                     $result_auth=get_records_sql($db_link,$sql);
                     $result_auth=get_records_sql($db_link,$sql);
                     try {
                     try {
                         if (!empty($result_auth)) { $result["auth"]=$result_auth; } else { $result["auth"]=''; }
                         if (!empty($result_auth)) { $result["auth"]=$result_auth; } else { $result["auth"]=''; }
@@ -101,7 +101,7 @@ if (!empty($action)) {
             $result=[];
             $result=[];
             LOG_VERBOSE($db_link,"API: Get all dhcp records");
             LOG_VERBOSE($db_link,"API: Get all dhcp records");
             $sql = "SELECT ua.id, ua.ip, ua.ip_int, ua.mac, ua.comments, ua.dns_name, ua.dhcp_option_set, ua.dhcp_acl, ua.ou_id, SUBSTRING_INDEX(s.subnet, '/', 1) AS subnet_base 
             $sql = "SELECT ua.id, ua.ip, ua.ip_int, ua.mac, ua.comments, ua.dns_name, ua.dhcp_option_set, ua.dhcp_acl, ua.ou_id, SUBSTRING_INDEX(s.subnet, '/', 1) AS subnet_base 
-                FROM  User_auth ua JOIN subnets s ON ua.ip_int BETWEEN s.ip_int_start AND s.ip_int_stop
+                FROM  user_auth ua JOIN subnets s ON ua.ip_int BETWEEN s.ip_int_start AND s.ip_int_stop
                 WHERE ua.dhcp = 1 AND ua.deleted = 0 AND s.dhcp = 1 ORDER BY ua.ip_int";
                 WHERE ua.dhcp = 1 AND ua.deleted = 0 AND s.dhcp = 1 ORDER BY ua.ip_int";
             $result = get_records_sql($db_link, $sql);
             $result = get_records_sql($db_link, $sql);
             if (!empty($result)) {
             if (!empty($result)) {
@@ -127,7 +127,7 @@ if (!empty($action)) {
             $f_subnet = trim($f_subnet, "'");
             $f_subnet = trim($f_subnet, "'");
             LOG_VERBOSE($db_link,"API: Get dhcp records for subnet ".$f_subnet);
             LOG_VERBOSE($db_link,"API: Get dhcp records for subnet ".$f_subnet);
             $sql = "SELECT ua.id, ua.ip, ua.ip_int, ua.mac, ua.comments, ua.dns_name, ua.dhcp_option_set, ua.dhcp_acl, ua.ou_id, SUBSTRING_INDEX(s.subnet, '/', 1) AS subnet_base 
             $sql = "SELECT ua.id, ua.ip, ua.ip_int, ua.mac, ua.comments, ua.dns_name, ua.dhcp_option_set, ua.dhcp_acl, ua.ou_id, SUBSTRING_INDEX(s.subnet, '/', 1) AS subnet_base 
-                FROM  User_auth ua JOIN subnets s ON ua.ip_int BETWEEN s.ip_int_start AND s.ip_int_stop
+                FROM  user_auth ua JOIN subnets s ON ua.ip_int BETWEEN s.ip_int_start AND s.ip_int_stop
                 WHERE ua.dhcp = 1 AND ua.deleted = 0 AND s.dhcp = 1 AND SUBSTRING_INDEX(s.subnet, '/', 1) = '".$f_subnet."' ORDER BY ua.ip_int";
                 WHERE ua.dhcp = 1 AND ua.deleted = 0 AND s.dhcp = 1 AND SUBSTRING_INDEX(s.subnet, '/', 1) = '".$f_subnet."' ORDER BY ua.ip_int";
             $result = get_records_sql($db_link, $sql);
             $result = get_records_sql($db_link, $sql);
             if (!empty($result)) {
             if (!empty($result)) {

+ 2 - 2
html/inc/auth.utils.php

@@ -231,7 +231,7 @@ function authenticate_by_credentials($db, $login, $password) {
     log_session_debug($db, "Authenticating by credentials", ['login' => $login]);
     log_session_debug($db, "Authenticating by credentials", ['login' => $login]);
 
 
     $login = trim($login);
     $login = trim($login);
-    $stmt = $db->prepare("SELECT * FROM `Customers` WHERE Login = ?");
+    $stmt = $db->prepare("SELECT * FROM `customers` WHERE Login = ?");
     $stmt->execute([$login]);
     $stmt->execute([$login]);
     $user = $stmt->fetch(PDO::FETCH_ASSOC);
     $user = $stmt->fetch(PDO::FETCH_ASSOC);
 
 
@@ -371,7 +371,7 @@ function IsSilentAuthenticated($db) {
         return false;
         return false;
     }
     }
 
 
-    $stmt = $db->prepare("SELECT id, rights FROM Customers WHERE Login = ? AND api_key = ? LIMIT 1");
+    $stmt = $db->prepare("SELECT id, rights FROM customers WHERE Login = ? AND api_key = ? LIMIT 1");
     $stmt->execute([$login, $api_key]);
     $stmt->execute([$login, $api_key]);
 
 
     if ($stmt->rowCount() === 0) {
     if ($stmt->rowCount() === 0) {

+ 66 - 66
html/inc/common.php

@@ -390,7 +390,7 @@ function searchHostname($db, $id, $hostname)
     $result = '';
     $result = '';
     $domain_zone = get_option($db, 33);
     $domain_zone = get_option($db, 33);
 
 
-    $a_search_filter = 'SELECT * FROM User_auth WHERE deleted=0 and id !="' . $id . '" and (dns_name ="' . db_escape($db, $hostname) . '" or dns_name ="' . db_escape($db, $hostname . '.' . $domain_zone) . '")';
+    $a_search_filter = 'SELECT * FROM user_auth WHERE deleted=0 and id !="' . $id . '" and (dns_name ="' . db_escape($db, $hostname) . '" or dns_name ="' . db_escape($db, $hostname . '.' . $domain_zone) . '")';
 //        LOG_DEBUG($db, "A search-filter: ".$a_search_filter);
 //        LOG_DEBUG($db, "A search-filter: ".$a_search_filter);
     $a_records = get_records_sql($db, $a_search_filter);
     $a_records = get_records_sql($db, $a_search_filter);
     foreach ($a_records as $a_rec) {
     foreach ($a_records as $a_rec) {
@@ -401,7 +401,7 @@ function searchHostname($db, $id, $hostname)
     }
     }
 
 
     $result_cname = '';
     $result_cname = '';
-    $cname_search_filter = 'SELECT * FROM User_auth_alias WHERE auth_id !="' . $id . '" and (alias ="' . db_escape($db, $hostname) . '" or alias ="' . db_escape($db, $hostname . '.' . $domain_zone) . '")';
+    $cname_search_filter = 'SELECT * FROM user_auth_alias WHERE auth_id !="' . $id . '" and (alias ="' . db_escape($db, $hostname) . '" or alias ="' . db_escape($db, $hostname . '.' . $domain_zone) . '")';
 //        LOG_DEBUG($db, "CNAME search-filter: ".$cname_search_filter);
 //        LOG_DEBUG($db, "CNAME search-filter: ".$cname_search_filter);
     $a_records = get_records_sql($db, $cname_search_filter);
     $a_records = get_records_sql($db, $cname_search_filter);
     foreach ($a_records as $a_rec) {
     foreach ($a_records as $a_rec) {
@@ -426,7 +426,7 @@ function checkUniqHostname($db, $id, $hostname)
     $check_A_filter = 'deleted=0 and id !="' . $id . '" and (dns_name ="' . db_escape($db, $hostname) . '" or dns_name ="' . db_escape($db, $hostname . '.' . $domain_zone) . '")';
     $check_A_filter = 'deleted=0 and id !="' . $id . '" and (dns_name ="' . db_escape($db, $hostname) . '" or dns_name ="' . db_escape($db, $hostname . '.' . $domain_zone) . '")';
 //        LOG_DEBUG($db, "CNAME filter: ".$check_A_filter);
 //        LOG_DEBUG($db, "CNAME filter: ".$check_A_filter);
 
 
-    $count = get_count_records($db, 'User_auth', $check_A_filter);
+    $count = get_count_records($db, 'user_auth', $check_A_filter);
     if ($count > 0) {
     if ($count > 0) {
         return FALSE;
         return FALSE;
     }
     }
@@ -435,7 +435,7 @@ function checkUniqHostname($db, $id, $hostname)
 
 
 //        LOG_DEBUG($db, "CNAME filter: ".$check_CNAME_filter);
 //        LOG_DEBUG($db, "CNAME filter: ".$check_CNAME_filter);
 
 
-    $count = get_count_records($db, 'User_auth_alias', $check_CNAME_filter);
+    $count = get_count_records($db, 'user_auth_alias', $check_CNAME_filter);
     if ($count > 0) {
     if ($count > 0) {
         return FALSE;
         return FALSE;
     }
     }
@@ -847,7 +847,7 @@ function print_acl_select($db, $acl_name, $acl_value)
 function print_device_ip_select($db, $ip_name, $ip, $user_id)
 function print_device_ip_select($db, $ip_name, $ip, $user_id)
 {
 {
     print "<select id=\"$ip_name\" name=\"$ip_name\">\n";
     print "<select id=\"$ip_name\" name=\"$ip_name\">\n";
-    $auth_list = get_records_sql($db, "SELECT ip FROM User_auth WHERE user_id=$user_id AND deleted=0 ORDER BY ip_int");
+    $auth_list = get_records_sql($db, "SELECT ip FROM user_auth WHERE user_id=$user_id AND deleted=0 ORDER BY ip_int");
     if (!empty($auth_list)) {
     if (!empty($auth_list)) {
         foreach ($auth_list as $row) {
         foreach ($auth_list as $row) {
             print_select_item($row['ip'], $row['ip'], $ip);
             print_select_item($row['ip'], $row['ip'], $ip);
@@ -1172,7 +1172,7 @@ function print_device_model_select($db, $device_model_name, $device_model_value)
 function print_filter_group_select($db, $group_name, $group_value)
 function print_filter_group_select($db, $group_name, $group_value)
 {
 {
     print "<select id=\"$group_name\" name=\"$group_name\">\n";
     print "<select id=\"$group_name\" name=\"$group_name\">\n";
-    $t_group = get_records_sql($db, "SELECT id,group_name FROM Group_list Order by group_name");
+    $t_group = get_records_sql($db, "SELECT id,group_name FROM group_list Order by group_name");
     foreach ($t_group as $row) {
     foreach ($t_group as $row) {
         print_select_item($row['group_name'], $row['id'], $group_value);
         print_select_item($row['group_name'], $row['id'], $group_value);
     }
     }
@@ -1232,7 +1232,7 @@ function print_devtype_select($db, $devtype_name, $devtype_value)
 
 
 function get_group($db, $group_value)
 function get_group($db, $group_value)
 {
 {
-    $group = get_record_sql($db, "SELECT group_name FROM Group_list WHERE id=$group_value");
+    $group = get_record_sql($db, "SELECT group_name FROM group_list WHERE id=$group_value");
     if (!empty($group) and isset($group['group_name'])) {
     if (!empty($group) and isset($group['group_name'])) {
         return $group['group_name'];
         return $group['group_name'];
     }
     }
@@ -1326,7 +1326,7 @@ function get_gw_subnets($db, $device_id)
 function print_queue_select($db, $queue_name, $queue_value)
 function print_queue_select($db, $queue_name, $queue_value)
 {
 {
     print "<select id=\"$queue_name\" name=\"$queue_name\">\n";
     print "<select id=\"$queue_name\" name=\"$queue_name\">\n";
-    $t_queue = get_records_sql($db, "SELECT id,queue_name FROM Queue_list Order by queue_name");
+    $t_queue = get_records_sql($db, "SELECT id,queue_name FROM queue_list Order by queue_name");
     foreach ($t_queue as $row) {
     foreach ($t_queue as $row) {
         print_select_item($row['queue_name'], $row['id'], $queue_value);
         print_select_item($row['queue_name'], $row['id'], $queue_value);
     }
     }
@@ -1335,7 +1335,7 @@ function print_queue_select($db, $queue_name, $queue_value)
 
 
 function get_queue($db, $queue_value)
 function get_queue($db, $queue_value)
 {
 {
-    $queue=get_record_sql($db, "SELECT queue_name FROM Queue_list WHERE id=$queue_value");
+    $queue=get_record_sql($db, "SELECT queue_name FROM queue_list WHERE id=$queue_value");
     if (!empty($queue) && isset($queue['queue_name'])) {
     if (!empty($queue) && isset($queue['queue_name'])) {
         return $queue['queue_name'];
         return $queue['queue_name'];
     }
     }
@@ -1484,7 +1484,7 @@ function print_dhcp_select($qa_name, $qa_value = 0)
 
 
 function print_nagios_handler_select($db,$qa_name)
 function print_nagios_handler_select($db,$qa_name)
 {
 {
-$nagios_handler = get_records_sql($db,"SELECT DISTINCT `nagios_handler` FROM User_auth WHERE `nagios_handler` IS NOT NULL AND `nagios_handler` != '' AND  `deleted`=0");
+$nagios_handler = get_records_sql($db,"SELECT DISTINCT `nagios_handler` FROM user_auth WHERE `nagios_handler` IS NOT NULL AND `nagios_handler` != '' AND  `deleted`=0");
 if (!empty($nagios_handler) and count($nagios_handler)>0) {
 if (!empty($nagios_handler) and count($nagios_handler)>0) {
     print "<select name=\"$qa_name\">\n";
     print "<select name=\"$qa_name\">\n";
     print_select_simple(WEB_select_item_no, '');
     print_select_simple(WEB_select_item_no, '');
@@ -1499,7 +1499,7 @@ if (!empty($nagios_handler) and count($nagios_handler)>0) {
 
 
 function print_dhcp_acl($db,$qa_name)
 function print_dhcp_acl($db,$qa_name)
 {
 {
-$dhcp_acl = get_records_sql($db,"SELECT DISTINCT `dhcp_acl` FROM User_auth WHERE `dhcp_acl` IS NOT NULL AND `dhcp_acl` != '' AND  `deleted`=0");
+$dhcp_acl = get_records_sql($db,"SELECT DISTINCT `dhcp_acl` FROM user_auth WHERE `dhcp_acl` IS NOT NULL AND `dhcp_acl` != '' AND  `deleted`=0");
 if (!empty($dhcp_acl) and count($dhcp_acl)>0) {
 if (!empty($dhcp_acl) and count($dhcp_acl)>0) {
     print "<select name=\"$qa_name\">\n";
     print "<select name=\"$qa_name\">\n";
     print_select_simple(WEB_select_item_no, '');
     print_select_simple(WEB_select_item_no, '');
@@ -1514,7 +1514,7 @@ if (!empty($dhcp_acl) and count($dhcp_acl)>0) {
 
 
 function print_dhcp_option_set($db,$qa_name)
 function print_dhcp_option_set($db,$qa_name)
 {
 {
-$dhcp_option_sets = get_records_sql($db,"SELECT DISTINCT `dhcp_option_set` FROM User_auth WHERE `dhcp_option_set` IS NOT NULL AND `dhcp_option_set` != '' AND `deleted`=0");
+$dhcp_option_sets = get_records_sql($db,"SELECT DISTINCT `dhcp_option_set` FROM user_auth WHERE `dhcp_option_set` IS NOT NULL AND `dhcp_option_set` != '' AND `deleted`=0");
 if (!empty($dhcp_option_sets) and count($dhcp_option_sets)>0) {
 if (!empty($dhcp_option_sets) and count($dhcp_option_sets)>0) {
     print "<select name=\"$qa_name\">\n";
     print "<select name=\"$qa_name\">\n";
     print_select_simple(WEB_select_item_no, '');
     print_select_simple(WEB_select_item_no, '');
@@ -1529,7 +1529,7 @@ if (!empty($dhcp_option_sets) and count($dhcp_option_sets)>0) {
 
 
 function print_dhcp_acl_list($db,$qa_name,$value='')
 function print_dhcp_acl_list($db,$qa_name,$value='')
 {
 {
-$dhcp_acl = get_records_sql($db,"SELECT DISTINCT `dhcp_acl` FROM User_auth WHERE `dhcp_acl` IS NOT NULL AND `dhcp_acl` != '' AND  `deleted`=0");
+$dhcp_acl = get_records_sql($db,"SELECT DISTINCT `dhcp_acl` FROM user_auth WHERE `dhcp_acl` IS NOT NULL AND `dhcp_acl` != '' AND  `deleted`=0");
 if (!empty($dhcp_acl) and count($dhcp_acl)>0) {
 if (!empty($dhcp_acl) and count($dhcp_acl)>0) {
     print "<input list=\"dhcp_acl\" id=\"$qa_name\" name=\"$qa_name\" value=\"$value\"/>";
     print "<input list=\"dhcp_acl\" id=\"$qa_name\" name=\"$qa_name\" value=\"$value\"/>";
     print "<datalist id=\"dhcp_acl\">";
     print "<datalist id=\"dhcp_acl\">";
@@ -1545,7 +1545,7 @@ if (!empty($dhcp_acl) and count($dhcp_acl)>0) {
 
 
 function print_dhcp_option_set_list($db,$qa_name,$value='')
 function print_dhcp_option_set_list($db,$qa_name,$value='')
 {
 {
-$dhcp_option_sets = get_records_sql($db,"SELECT DISTINCT `dhcp_option_set` FROM User_auth WHERE `dhcp_option_set` IS NOT NULL AND `dhcp_option_set` != '' AND `deleted`=0");
+$dhcp_option_sets = get_records_sql($db,"SELECT DISTINCT `dhcp_option_set` FROM user_auth WHERE `dhcp_option_set` IS NOT NULL AND `dhcp_option_set` != '' AND `deleted`=0");
 if (!empty($dhcp_option_sets) and count($dhcp_option_sets)>0) {
 if (!empty($dhcp_option_sets) and count($dhcp_option_sets)>0) {
     print "<input list=\"dhcp_option_set\" id=\"$qa_name\" name=\"$qa_name\" value=\"$value\"/>";
     print "<input list=\"dhcp_option_set\" id=\"$qa_name\" name=\"$qa_name\" value=\"$value\"/>";
     print "<datalist id=\"dhcp_option_set\">";
     print "<datalist id=\"dhcp_option_set\">";
@@ -1709,9 +1709,9 @@ function print_filter_select($db, $filter_name, $group_id)
 {
 {
     print "<select id=\"$filter_name\" name=\"$filter_name\" class=\"js-select-single\">\n";
     print "<select id=\"$filter_name\" name=\"$filter_name\" class=\"js-select-single\">\n";
     if (isset($group_id)) {
     if (isset($group_id)) {
-        $sSQL = "SELECT id,name FROM Filter_list WHERE Filter_list.id not in (Select filter_id FROM Group_filters WHERE group_id=$group_id)";
+        $sSQL = "SELECT id,name FROM filter_list WHERE filter_list.id not in (Select filter_id FROM group_filters WHERE group_id=$group_id)";
     } else {
     } else {
-        $sSQL = "SELECT id,name FROM Filter_list Order by name";
+        $sSQL = "SELECT id,name FROM filter_list Order by name";
     }
     }
 
 
     $t_filters = get_records_sql($db, $sSQL);
     $t_filters = get_records_sql($db, $sSQL);
@@ -1723,21 +1723,21 @@ function print_filter_select($db, $filter_name, $group_id)
 
 
 function get_filter($db, $filter_value)
 function get_filter($db, $filter_value)
 {
 {
-    $filter = get_record_sql($db, "SELECT name FROM Filter_list WHERE id=" . $filter_value);
+    $filter = get_record_sql($db, "SELECT name FROM filter_list WHERE id=" . $filter_value);
     if (!empty($filter) and isset($filter['name'])) { return $filter['name']; }
     if (!empty($filter) and isset($filter['name'])) { return $filter['name']; }
     return '';
     return '';
 }
 }
 
 
 function get_login($db, $user_id)
 function get_login($db, $user_id)
 {
 {
-    $login = get_record_sql($db, "SELECT login FROM User_list WHERE id=$user_id");
+    $login = get_record_sql($db, "SELECT login FROM user_list WHERE id=$user_id");
     if (!empty($login) and isset($login['login'])) { return $login['login']; }
     if (!empty($login) and isset($login['login'])) { return $login['login']; }
     return '';
     return '';
 }
 }
 
 
 function get_auth_count($db, $user_id)
 function get_auth_count($db, $user_id)
 {
 {
-    $count = get_record_sql($db, "SELECT count(id) as cnt FROM User_auth WHERE user_id=$user_id and deleted=0");
+    $count = get_record_sql($db, "SELECT count(id) as cnt FROM user_auth WHERE user_id=$user_id and deleted=0");
     if (!empty($count) and isset($count['cnt'])) { return $count['cnt']; }
     if (!empty($count) and isset($count['cnt'])) { return $count['cnt']; }
     return 0;
     return 0;
 }
 }
@@ -1745,7 +1745,7 @@ function get_auth_count($db, $user_id)
 function print_login_select($db, $login_name, $current_login)
 function print_login_select($db, $login_name, $current_login)
 {
 {
     print "<select id=\"$login_name\" name=\"$login_name\" class=\"js-select-single\">\n";
     print "<select id=\"$login_name\" name=\"$login_name\" class=\"js-select-single\">\n";
-    $t_login = get_records_sql($db, "SELECT id,login FROM User_list Order by Login");
+    $t_login = get_records_sql($db, "SELECT id,login FROM user_list Order by Login");
     print_select_item('None', 0, $current_login);
     print_select_item('None', 0, $current_login);
     foreach ($t_login as $row) {
     foreach ($t_login as $row) {
         print_select_item($row['login'], $row['id'], $current_login);
         print_select_item($row['login'], $row['id'], $current_login);
@@ -1756,7 +1756,7 @@ function print_login_select($db, $login_name, $current_login)
 function print_auth_select($db, $login_name, $current_auth)
 function print_auth_select($db, $login_name, $current_auth)
 {
 {
     print "<select id=\"$login_name\" name=\"$login_name\" class=\"js-select-single\">\n";
     print "<select id=\"$login_name\" name=\"$login_name\" class=\"js-select-single\">\n";
-    $t_login = get_records_sql($db, "SELECT U.login,U.fio,A.ip,A.id FROM User_list as U, User_auth as A WHERE A.user_id=U.id and A.deleted=0 and (A.id not in (select device_ports.auth_id FROM device_ports) or A.id=$current_auth) order by U.login,U.fio,A.ip");
+    $t_login = get_records_sql($db, "SELECT U.login,U.fio,A.ip,A.id FROM user_list as U, user_auth as A WHERE A.user_id=U.id and A.deleted=0 and (A.id not in (select device_ports.auth_id FROM device_ports) or A.id=$current_auth) order by U.login,U.fio,A.ip");
     print_select_item('Empty', 0, $current_auth);
     print_select_item('Empty', 0, $current_auth);
     foreach ($t_login as $row) {
     foreach ($t_login as $row) {
         print_select_item($row['login'] . "[" . $row['fio'] . "] - " . $row['ip'], $row['id'], $current_auth);
         print_select_item($row['login'] . "[" . $row['fio'] . "] - " . $row['ip'], $row['id'], $current_auth);
@@ -1767,7 +1767,7 @@ function print_auth_select($db, $login_name, $current_auth)
 function print_auth_select_mac($db, $login_name, $current_auth)
 function print_auth_select_mac($db, $login_name, $current_auth)
 {
 {
     print "<select id=\"$login_name\" name=\"$login_name\" class=\"js-select-single\">\n";
     print "<select id=\"$login_name\" name=\"$login_name\" class=\"js-select-single\">\n";
-    $t_login = get_records_sql($db, "SELECT U.login,U.fio,A.ip,A.mac,A.id FROM User_list as U, User_auth as A WHERE A.user_id=U.id and A.deleted=0 and (A.id not in (select device_ports.auth_id FROM device_ports) or A.id=$current_auth) order by U.login,U.fio,A.ip");
+    $t_login = get_records_sql($db, "SELECT U.login,U.fio,A.ip,A.mac,A.id FROM user_list as U, user_auth as A WHERE A.user_id=U.id and A.deleted=0 and (A.id not in (select device_ports.auth_id FROM device_ports) or A.id=$current_auth) order by U.login,U.fio,A.ip");
 
 
     print_select_item('Empty', 0, $current_auth);
     print_select_item('Empty', 0, $current_auth);
     foreach ($t_login as $row) {
     foreach ($t_login as $row) {
@@ -1912,7 +1912,7 @@ function get_device_ips($db, $device_id)
     $switch = get_record($db, 'devices', 'id=' . $device_id);
     $switch = get_record($db, 'devices', 'id=' . $device_id);
     $index = 0;
     $index = 0;
     if (!empty($switch['user_id'])) {
     if (!empty($switch['user_id'])) {
-        $auth_ips = get_records($db, 'User_auth', 'deleted=0 and user_id=' . $switch['user_id']);
+        $auth_ips = get_records($db, 'user_auth', 'deleted=0 and user_id=' . $switch['user_id']);
         foreach ($auth_ips as $key => $value) {
         foreach ($auth_ips as $key => $value) {
             if (isset($value['ip'])) {
             if (isset($value['ip'])) {
                 $result[$index] = $value['ip'];
                 $result[$index] = $value['ip'];
@@ -1950,7 +1950,7 @@ function get_device_name($db, $device_id)
 
 
 function get_auth_by_ip($db, $ip)
 function get_auth_by_ip($db, $ip)
 {
 {
-    $d_sql = "SELECT id FROM User_auth WHERE ip='$ip' and deleted=0";
+    $d_sql = "SELECT id FROM user_auth WHERE ip='$ip' and deleted=0";
     $auth = get_record_sql($db, $d_sql);
     $auth = get_record_sql($db, $d_sql);
     if (empty($auth)) {
     if (empty($auth)) {
         return NULL;
         return NULL;
@@ -1960,7 +1960,7 @@ function get_auth_by_ip($db, $ip)
 
 
 function get_user_by_ip($db, $ip)
 function get_user_by_ip($db, $ip)
 {
 {
-    $d_sql = "SELECT user_id FROM User_auth WHERE ip='$ip' and deleted=0";
+    $d_sql = "SELECT user_id FROM user_auth WHERE ip='$ip' and deleted=0";
     $auth = get_record_sql($db, $d_sql);
     $auth = get_record_sql($db, $d_sql);
     if (empty($auth)) {
     if (empty($auth)) {
         return NULL;
         return NULL;
@@ -1980,7 +1980,7 @@ function get_device_by_auth($db, $id)
 
 
 function print_auth_port($db, $port_id, $new_window = FALSE)
 function print_auth_port($db, $port_id, $new_window = FALSE)
 {
 {
-    $d_sql = "SELECT A.ip, A.ip_int, A.mac, A.id, A.dns_name, A.user_id FROM User_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0 order by A.ip_int";
+    $d_sql = "SELECT A.ip, A.ip_int, A.mac, A.id, A.dns_name, A.user_id FROM user_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0 order by A.ip_int";
     $t_auth = get_records_sql($db, $d_sql);
     $t_auth = get_records_sql($db, $d_sql);
     foreach ($t_auth as $row) {
     foreach ($t_auth as $row) {
         $name = $row['ip'];
         $name = $row['ip'];
@@ -2001,7 +2001,7 @@ function print_auth_port($db, $port_id, $new_window = FALSE)
 
 
 function get_port_comment($db, $port_id, $port_comment = '')
 function get_port_comment($db, $port_id, $port_comment = '')
 {
 {
-    $d_sql = "SELECT A.ip_int, A.comments FROM User_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0 order by A.ip_int";
+    $d_sql = "SELECT A.ip_int, A.comments FROM user_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0 order by A.ip_int";
     $t_auth = get_records_sql($db, $d_sql);
     $t_auth = get_records_sql($db, $d_sql);
     $comment_found = 0;
     $comment_found = 0;
     $result = '';
     $result = '';
@@ -2024,7 +2024,7 @@ function get_port_comment($db, $port_id, $port_comment = '')
 
 
 function print_auth_simple($db, $auth_id)
 function print_auth_simple($db, $auth_id)
 {
 {
-    $auth = get_record($db, "User_auth", "id=$auth_id");
+    $auth = get_record($db, "user_auth", "id=$auth_id");
     $name = $auth['dns_name'];
     $name = $auth['dns_name'];
     if (empty($name)) {
     if (empty($name)) {
         $name = $auth['comments'];
         $name = $auth['comments'];
@@ -2037,7 +2037,7 @@ function print_auth_simple($db, $auth_id)
 
 
 function print_auth($db, $auth_id)
 function print_auth($db, $auth_id)
 {
 {
-    $auth = get_record($db, "User_auth", "id=$auth_id");
+    $auth = get_record($db, "user_auth", "id=$auth_id");
     $name = $auth['dns_name'];
     $name = $auth['dns_name'];
     if (empty($name)) {
     if (empty($name)) {
         $name = $auth['comments'];
         $name = $auth['comments'];
@@ -2054,7 +2054,7 @@ function print_auth($db, $auth_id)
 
 
 function print_auth_detail($db, $auth_id)
 function print_auth_detail($db, $auth_id)
 {
 {
-    $auth = get_record($db, "User_auth", "id=$auth_id");
+    $auth = get_record($db, "user_auth", "id=$auth_id");
     $name = $auth['dns_name'];
     $name = $auth['dns_name'];
     if (empty($name)) {
     if (empty($name)) {
         $name = $auth['comments'];
         $name = $auth['comments'];
@@ -2075,7 +2075,7 @@ function print_auth_detail($db, $auth_id)
 
 
 function get_auth_port_count($db, $port_id)
 function get_auth_port_count($db, $port_id)
 {
 {
-    $d_sql = "SELECT count(A.id) as cnt FROM User_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0";
+    $d_sql = "SELECT count(A.id) as cnt FROM user_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0";
     $t_device = get_record_sql($db, $d_sql);
     $t_device = get_record_sql($db, $d_sql);
     if (empty($t_device)) { return 0; }
     if (empty($t_device)) { return 0; }
     return $t_device['cnt'];
     return $t_device['cnt'];
@@ -2159,7 +2159,7 @@ function clean_dns_cache($db)
 
 
 function clean_unreferensed_rules($db)
 function clean_unreferensed_rules($db)
 {
 {
-    run_sql($db, "DELETE FROM `auth_rules` WHERE user_id NOT IN (SELECT id FROM User_list)");
+    run_sql($db, "DELETE FROM `auth_rules` WHERE user_id NOT IN (SELECT id FROM user_list)");
 }
 }
 
 
 function FormatDateStr($format = 'Y-m-d H:i:s', $date_str)
 function FormatDateStr($format = 'Y-m-d H:i:s', $date_str)
@@ -2249,7 +2249,7 @@ function find_mac_in_subnet($db, $ip, $mac)
     if (empty($ip_subnet)) {
     if (empty($ip_subnet)) {
         return;
         return;
     }
     }
-    $t_auth = get_records_sql($db, "SELECT id,mac,user_id FROM User_auth WHERE ip_int>=" . $ip_subnet['ip_int_start'] . " and ip_int<=" . $ip_subnet['ip_int_stop'] . " and mac='" . $mac . "' and deleted=0 ORDER BY id");
+    $t_auth = get_records_sql($db, "SELECT id,mac,user_id FROM user_auth WHERE ip_int>=" . $ip_subnet['ip_int_start'] . " and ip_int<=" . $ip_subnet['ip_int_stop'] . " and mac='" . $mac . "' and deleted=0 ORDER BY id");
     $auth_count = 0;
     $auth_count = 0;
     $result['count'] = 0;
     $result['count'] = 0;
     $result['users_id'] = [];
     $result['users_id'] = [];
@@ -2273,7 +2273,7 @@ function apply_auth_rule($db, $auth_record, $user_id)
         return $auth_record;
         return $auth_record;
     }
     }
 
 
-    $user_rec = get_record($db, 'User_list', "id=" . $user_id);
+    $user_rec = get_record($db, 'user_list', "id=" . $user_id);
     if (empty($user_rec)) {
     if (empty($user_rec)) {
         return $auth_record;
         return $auth_record;
     }
     }
@@ -2325,7 +2325,7 @@ function new_user($db, $user_info)
         $user['fio'] = $user_info['ip'];
         $user['fio'] = $user_info['ip'];
     }
     }
 
 
-    $login_count = get_count_records($db, "User_list", "(login LIKE '" . $user['login'] . "(%)') OR (login='" . $user['login'] . "')");
+    $login_count = get_count_records($db, "user_list", "(login LIKE '" . $user['login'] . "(%)') OR (login='" . $user['login'] . "')");
     if (!empty($login_count) and $login_count > 0) {
     if (!empty($login_count) and $login_count > 0) {
         $login_count++;
         $login_count++;
         $user['login'] = $user['login'] . "(" . $login_count . ")";
         $user['login'] = $user['login'] . "(" . $login_count . ")";
@@ -2348,7 +2348,7 @@ function new_user($db, $user_info)
         }
         }
     }
     }
 
 
-    $result = insert_record($db, "User_list", $user);
+    $result = insert_record($db, "user_list", $user);
     $auto_mac_rule = get_option($db, 64);
     $auto_mac_rule = get_option($db, 64);
     if (!empty($result) and $auto_mac_rule and $user_info['mac']) {
     if (!empty($result) and $auto_mac_rule and $user_info['mac']) {
         $auth_rule['user_id'] = $result;
         $auth_rule['user_id'] = $result;
@@ -2365,7 +2365,7 @@ function new_auth($db, $ip, $mac, $user_id)
     $msg = '';
     $msg = '';
 
 
     if (!empty($mac)) {
     if (!empty($mac)) {
-        $auth_record = get_record_sql($db, "SELECT * FROM User_auth WHERE ip_int=$ip_aton AND mac='" . mac_dotted($mac) . "' AND deleted=0");
+        $auth_record = get_record_sql($db, "SELECT * FROM user_auth WHERE ip_int=$ip_aton AND mac='" . mac_dotted($mac) . "' AND deleted=0");
         if (!empty($auth_record)) {
         if (!empty($auth_record)) {
             LOG_WARNING($db, "Pair ip-mac already exists! Skip creating $ip [$mac] auth_id: " . $auth_record["id"]);
             LOG_WARNING($db, "Pair ip-mac already exists! Skip creating $ip [$mac] auth_id: " . $auth_record["id"]);
             return $auth_record['id'];
             return $auth_record['id'];
@@ -2377,13 +2377,13 @@ function new_auth($db, $ip, $mac, $user_id)
     $resurrection_id = NULL;
     $resurrection_id = NULL;
 
 
     // seek old auth with same ip and mac
     // seek old auth with same ip and mac
-    $resurrection_id = get_id_record($db, 'User_auth', " deleted=1 AND ip_int=" . $ip_aton . " AND mac='" . $mac . "'");
+    $resurrection_id = get_id_record($db, 'user_auth', " deleted=1 AND ip_int=" . $ip_aton . " AND mac='" . $mac . "'");
     if (!empty($resurrection_id)) {
     if (!empty($resurrection_id)) {
         $msg .= "Recovered auth_id: $resurrection_id with ip: $ip and mac: $mac ";
         $msg .= "Recovered auth_id: $resurrection_id with ip: $ip and mac: $mac ";
         $auth['user_id'] = $user_id;
         $auth['user_id'] = $user_id;
         $auth['deleted'] = 0;
         $auth['deleted'] = 0;
         $auth['save_traf'] = $save_traf * 1;
         $auth['save_traf'] = $save_traf * 1;
-        update_record($db, "User_auth", "id=$resurrection_id", $auth);
+        update_record($db, "user_auth", "id=$resurrection_id", $auth);
     } else {
     } else {
         // not found ->create new record
         // not found ->create new record
         $msg .= "Create new ip record \r\nip: $ip\r\nmac: $mac\r\n";
         $msg .= "Create new ip record \r\nip: $ip\r\nmac: $mac\r\n";
@@ -2393,13 +2393,13 @@ function new_auth($db, $ip, $mac, $user_id)
         $auth['ip_int'] = $ip_aton;
         $auth['ip_int'] = $ip_aton;
         $auth['mac'] = $mac;
         $auth['mac'] = $mac;
         $auth['save_traf'] = $save_traf * 1;
         $auth['save_traf'] = $save_traf * 1;
-        $resurrection_id = insert_record($db, "User_auth", $auth);
+        $resurrection_id = insert_record($db, "user_auth", $auth);
     }
     }
 
 
     //check rules, update filter and state for new record
     //check rules, update filter and state for new record
     if (!empty($resurrection_id)) {
     if (!empty($resurrection_id)) {
         $auth = apply_auth_rule($db, $auth, $user_id);
         $auth = apply_auth_rule($db, $auth, $user_id);
-        update_record($db, "User_auth", "id=$resurrection_id", $auth);
+        update_record($db, "user_auth", "id=$resurrection_id", $auth);
         if (!is_hotspot($db, $ip) and !empty($msg)) {
         if (!is_hotspot($db, $ip) and !empty($msg)) {
             LOG_WARNING($db, $msg);
             LOG_WARNING($db, $msg);
         }
         }
@@ -2420,9 +2420,9 @@ function resurrection_auth($db, $ip_record)
 
 
     $ip_aton = ip2long($ip);
     $ip_aton = ip2long($ip);
 
 
-    $auth_record = get_record_sql($db, "SELECT * FROM User_auth WHERE ip_int=$ip_aton AND mac='" . $mac . "' AND deleted=0");
+    $auth_record = get_record_sql($db, "SELECT * FROM user_auth WHERE ip_int=$ip_aton AND mac='" . $mac . "' AND deleted=0");
     if (!empty($auth_record)) {
     if (!empty($auth_record)) {
-        $user_info = get_record_sql($db, "SELECT * FROM User_list WHERE id=" . $auth_record['user_id']);
+        $user_info = get_record_sql($db, "SELECT * FROM user_list WHERE id=" . $auth_record['user_id']);
         LOG_DEBUG($db, "external dhcp user " . $user_info['login'] . " [" . $ip . "] auth_id: " . $auth_record['id']);
         LOG_DEBUG($db, "external dhcp user " . $user_info['login'] . " [" . $ip . "] auth_id: " . $auth_record['id']);
         if (isset($dhcp_hostname) and !empty($dhcp_hostname)) {
         if (isset($dhcp_hostname) and !empty($dhcp_hostname)) {
             $auth['dhcp_hostname'] = $dhcp_hostname;
             $auth['dhcp_hostname'] = $dhcp_hostname;
@@ -2432,7 +2432,7 @@ function resurrection_auth($db, $ip_record)
         if ($action === 'add') {
         if ($action === 'add') {
             $auth['last_found'] = GetNowTimeString();
             $auth['last_found'] = GetNowTimeString();
         }
         }
-        update_record($db, "User_auth", "id=" . $auth_record['id'], $auth);
+        update_record($db, "user_auth", "id=" . $auth_record['id'], $auth);
         return $auth_record['id'];
         return $auth_record['id'];
     }
     }
 
 
@@ -2444,7 +2444,7 @@ function resurrection_auth($db, $ip_record)
 
 
     $msg = '';
     $msg = '';
     // search changed mac
     // search changed mac
-    $auth_record = get_record_sql($db, "SELECT * FROM User_auth WHERE ip_int=$ip_aton AND deleted=0");
+    $auth_record = get_record_sql($db, "SELECT * FROM user_auth WHERE ip_int=$ip_aton AND deleted=0");
     if (!empty($auth_record)) {
     if (!empty($auth_record)) {
         if (empty($auth_record['mac'])) {
         if (empty($auth_record['mac'])) {
             $auth['mac'] = mac_dotted($mac);
             $auth['mac'] = mac_dotted($mac);
@@ -2457,13 +2457,13 @@ function resurrection_auth($db, $ip_record)
                 $auth['last_found'] = GetNowTimeString();
                 $auth['last_found'] = GetNowTimeString();
             }
             }
             LOG_INFO($db, "for ip: $ip mac not found! Use empty record...");
             LOG_INFO($db, "for ip: $ip mac not found! Use empty record...");
-            update_record($db, "User_auth", "id=" . $auth_record['id'], $auth);
+            update_record($db, "user_auth", "id=" . $auth_record['id'], $auth);
             return $auth_record['id'];
             return $auth_record['id'];
         } else {
         } else {
             if (!$hotspot_found) {
             if (!$hotspot_found) {
                 LOG_WARNING($db, "for ip: $ip mac change detected! Old mac: [" . $auth_record['mac'] . "] New mac: [" . mac_dotted($mac) . "]. Disable old auth_id: " . $auth_record['id']);
                 LOG_WARNING($db, "for ip: $ip mac change detected! Old mac: [" . $auth_record['mac'] . "] New mac: [" . mac_dotted($mac) . "]. Disable old auth_id: " . $auth_record['id']);
             }
             }
-            run_sql($db, "UPDATE User_auth SET changed=1, deleted=1 WHERE id=" . $auth_record['id']);
+            run_sql($db, "UPDATE user_auth SET changed=1, deleted=1 WHERE id=" . $auth_record['id']);
         }
         }
     }
     }
 
 
@@ -2479,7 +2479,7 @@ function resurrection_auth($db, $ip_record)
     $resurrection_id = NULL;
     $resurrection_id = NULL;
     $save_traf = get_option($db, 23);
     $save_traf = get_option($db, 23);
 
 
-    $auth_record = get_record_sql($db, "SELECT * FROM User_auth WHERE ip_int=" . $ip_aton . " and mac='" . $mac . "'");
+    $auth_record = get_record_sql($db, "SELECT * FROM user_auth WHERE ip_int=" . $ip_aton . " and mac='" . $mac . "'");
     // seek old auth with same ip and mac
     // seek old auth with same ip and mac
     if (!empty($auth_record)) {
     if (!empty($auth_record)) {
         // found ->Resurrection old record
         // found ->Resurrection old record
@@ -2496,7 +2496,7 @@ function resurrection_auth($db, $ip_record)
         if ($action === 'add') {
         if ($action === 'add') {
             $auth['last_found'] = GetNowTimeString();
             $auth['last_found'] = GetNowTimeString();
         }
         }
-        update_record($db, "User_auth", "id=$resurrection_id", $auth);
+        update_record($db, "user_auth", "id=$resurrection_id", $auth);
     } else {
     } else {
         // not found ->create new record
         // not found ->create new record
         $msg .= "Создаём новый ip-адрес \r\nip: $ip\r\nmac: $mac\r\n";
         $msg .= "Создаём новый ip-адрес \r\nip: $ip\r\nmac: $mac\r\n";
@@ -2514,12 +2514,12 @@ function resurrection_auth($db, $ip_record)
         if ($action == 'add') {
         if ($action == 'add') {
             $auth['last_found'] = GetNowTimeString();
             $auth['last_found'] = GetNowTimeString();
         }
         }
-        $resurrection_id = insert_record($db, "User_auth", $auth);
+        $resurrection_id = insert_record($db, "user_auth", $auth);
     }
     }
     //check rules, update filter and state for new record
     //check rules, update filter and state for new record
     if (!empty($resurrection_id)) {
     if (!empty($resurrection_id)) {
         $auth = apply_auth_rule($db, $auth, $new_user_id);
         $auth = apply_auth_rule($db, $auth, $new_user_id);
-        update_record($db, "User_auth", "id=$resurrection_id", $auth);
+        update_record($db, "user_auth", "id=$resurrection_id", $auth);
         $msg .= "filter: " . $auth['filter_group_id'] . "\r\n queue_id: " . $auth['queue_id'] . "\r\n enabled: " . $auth['enabled'] . "\r\nid: $resurrection_id";
         $msg .= "filter: " . $auth['filter_group_id'] . "\r\n queue_id: " . $auth['queue_id'] . "\r\n enabled: " . $auth['enabled'] . "\r\nid: $resurrection_id";
         if (!$hotspot_found and !empty($msg)) {
         if (!$hotspot_found and !empty($msg)) {
             LOG_WARNING($db, $msg);
             LOG_WARNING($db, $msg);
@@ -2540,7 +2540,7 @@ function get_auth($db, $current_auth)
     if ($current_auth == 0) {
     if ($current_auth == 0) {
         return;
         return;
     }
     }
-    $t_login = get_record_sql($db, "SELECT U.login,A.ip FROM User_list as U, User_auth as A WHERE A.user_id=U.id and A.id=$current_auth");
+    $t_login = get_record_sql($db, "SELECT U.login,A.ip FROM user_list as U, user_auth as A WHERE A.user_id=U.id and A.id=$current_auth");
     if (!empty($t_login) and isset($t_login['login'])) {
     if (!empty($t_login) and isset($t_login['login'])) {
         return $f_login['login'] . "[" . $t_login['ip'] . "]";
         return $f_login['login'] . "[" . $t_login['ip'] . "]";
     }
     }
@@ -2553,7 +2553,7 @@ function get_auth_by_mac($db, $mac)
         return;
         return;
     }
     }
     $mac = mac_dotted($mac);
     $mac = mac_dotted($mac);
-    $t_login = get_record_sql($db, "SELECT U.id,U.login,A.id as auth_id,A.ip FROM User_list as U, User_auth as A WHERE A.user_id=U.id and A.mac='" . $mac . "' and A.deleted=0 ORDER BY A.last_found DESC");
+    $t_login = get_record_sql($db, "SELECT U.id,U.login,A.id as auth_id,A.ip FROM user_list as U, user_auth as A WHERE A.user_id=U.id and A.mac='" . $mac . "' and A.deleted=0 ORDER BY A.last_found DESC");
     if (!empty($t_login) and isset($t_login['id'])) {
     if (!empty($t_login) and isset($t_login['id'])) {
         $result['auth'] = '<a href=/admin/users/edituser.php?id=' . $t_login['id'] . '>' . $t_login['login'] . '</a> / ip: <a href=/admin/users/editauth.php?id=' . $t_login['auth_id'] . '>' . $t_login['ip'] . '</a>';
         $result['auth'] = '<a href=/admin/users/edituser.php?id=' . $t_login['id'] . '>' . $t_login['login'] . '</a> / ip: <a href=/admin/users/editauth.php?id=' . $t_login['auth_id'] . '>' . $t_login['ip'] . '</a>';
     } else {
     } else {
@@ -2571,7 +2571,7 @@ function get_auth_mac($db, $current_auth)
     if ($current_auth == 0) {
     if ($current_auth == 0) {
         return;
         return;
     }
     }
-    $t_login = get_record_sql($db, "SELECT U.login,A.mac FROM User_list as U, User_auth as A WHERE A.user_id=U.id and A.id=$current_auth");
+    $t_login = get_record_sql($db, "SELECT U.login,A.mac FROM user_list as U, user_auth as A WHERE A.user_id=U.id and A.id=$current_auth");
     if (!empty($t_login) and isset($t_loing['login'])) {
     if (!empty($t_login) and isset($t_loing['login'])) {
         return $t_login['login'] . " [" . $t_login['mac'] . "]";
         return $t_login['login'] . " [" . $t_login['mac'] . "]";
     }
     }
@@ -2879,11 +2879,11 @@ function unset_lock_discovery($db, $device_id)
 function set_port_for_group($db, $group_id, $place_id, $state)
 function set_port_for_group($db, $group_id, $place_id, $state)
 {
 {
 
 
-    $authSQL = 'SELECT User_auth.id, User_auth.dns_name, User_auth.ip 
-                FROM User_auth, User_list 
-                WHERE User_auth.user_id = User_list.id 
-                  AND User_auth.deleted = 0 
-                  AND User_list.ou_id = ' . $group_id;
+    $authSQL = 'SELECT user_auth.id, user_auth.dns_name, user_auth.ip 
+                FROM user_auth, user_list 
+                WHERE user_auth.user_id = user_list.id 
+                  AND user_auth.deleted = 0 
+                  AND user_list.ou_id = ' . $group_id;
     
     
     $auth_list = get_records_sql($db, $authSQL);
     $auth_list = get_records_sql($db, $authSQL);
     LOG_VERBOSE($db, 'Mass port state change started!');
     LOG_VERBOSE($db, 'Mass port state change started!');
@@ -2919,13 +2919,13 @@ function set_port_for_group($db, $group_id, $place_id, $state)
         // Определение режима и обновление nagios_handler
         // Определение режима и обновление nagios_handler
         if ($state == 1) {
         if ($state == 1) {
             $mode = 'enable';
             $mode = 'enable';
-            $runSQL = "UPDATE User_auth 
+            $runSQL = "UPDATE user_auth 
                        SET nagios_handler = 'restart-port' 
                        SET nagios_handler = 'restart-port' 
                        WHERE id = " . (int)$row['id'] . " 
                        WHERE id = " . (int)$row['id'] . " 
                          AND nagios_handler = 'manual-mode'";
                          AND nagios_handler = 'manual-mode'";
         } else {
         } else {
             $mode = 'disable';
             $mode = 'disable';
-            $runSQL = "UPDATE User_auth 
+            $runSQL = "UPDATE user_auth 
                        SET nagios_handler = 'manual-mode' 
                        SET nagios_handler = 'manual-mode' 
                        WHERE id = " . (int)$row['id'] . " 
                        WHERE id = " . (int)$row['id'] . " 
                          AND nagios_handler = 'restart-port'";
                          AND nagios_handler = 'restart-port'";
@@ -3147,7 +3147,7 @@ function expand_log_str($db, $msg)
 
 
 function is_auth_bind_changed($db, $id, $ip, $mac)
 function is_auth_bind_changed($db, $id, $ip, $mac)
 {
 {
-    $old_sql = "SELECT ip,mac FROM User_auth WHERE id=$id";
+    $old_sql = "SELECT ip,mac FROM user_auth WHERE id=$id";
     $old_record = get_record_sql($db, $old_sql);
     $old_record = get_record_sql($db, $old_sql);
     if (empty($old_record["ip"]) or empty($old_record["mac"])) {
     if (empty($old_record["ip"]) or empty($old_record["mac"])) {
         return 0;
         return 0;
@@ -3161,20 +3161,20 @@ function is_auth_bind_changed($db, $id, $ip, $mac)
 
 
 function copy_auth($db, $id, $new_auth)
 function copy_auth($db, $id, $new_auth)
 {
 {
-    $old_record = get_record_sql($db, "SELECT * FROM User_auth WHERE id=$id");
-    delete_record($db, "User_auth", "id=" . $id);
+    $old_record = get_record_sql($db, "SELECT * FROM user_auth WHERE id=$id");
+    delete_record($db, "user_auth", "id=" . $id);
     $new_auth["user_id"] = $old_record["user_id"];
     $new_auth["user_id"] = $old_record["user_id"];
     $new_auth["changed"] = 1;
     $new_auth["changed"] = 1;
     $changed_time = GetNowTimeString();
     $changed_time = GetNowTimeString();
     $new_auth["changed_time"] = $changed_time;
     $new_auth["changed_time"] = $changed_time;
-    $new_id = insert_record($db, "User_auth", $new_auth);
+    $new_id = insert_record($db, "user_auth", $new_auth);
     LOG_VERBOSE($db, "Old record with id: $id deleted. Created new auth record for new ip+mac id: $new_id!");
     LOG_VERBOSE($db, "Old record with id: $id deleted. Created new auth record for new ip+mac id: $new_id!");
     return $new_id;
     return $new_id;
 }
 }
 
 
 function get_dns_name($db, $id)
 function get_dns_name($db, $id)
 {
 {
-    $auth_record = get_record_sql($db, "SELECT dns_name FROM User_auth WHERE id=" . $id);
+    $auth_record = get_record_sql($db, "SELECT dns_name FROM user_auth WHERE id=" . $id);
     if (!empty($auth_record) and !empty($auth_record['dns_name'])) {
     if (!empty($auth_record) and !empty($auth_record['dns_name'])) {
         return $auth_record['dns_name'];
         return $auth_record['dns_name'];
     }
     }

+ 27 - 27
html/inc/sql.php

@@ -481,7 +481,7 @@ function get_id_record($db, $table, $filter) {
 function set_changed($db, $id)
 function set_changed($db, $id)
 {
 {
     $auth['changed'] = 1;
     $auth['changed'] = 1;
-    update_record($db, "User_auth", "id=" . $id, $auth);
+    update_record($db, "user_auth", "id=" . $id, $auth);
 }
 }
 
 
 //action: add,update,del
 //action: add,update,del
@@ -516,13 +516,13 @@ function allow_update($table, $action = 'update', $field = '')
     }
     }
 
 
     //allow tables for Operator
     //allow tables for Operator
-    if (preg_match('/(dns_queue|User_auth_alias)/i', $table)) {
+    if (preg_match('/(dns_queue|user_auth_alias)/i', $table)) {
         return 1;
         return 1;
     }
     }
 
 
     if ($action == 'update') {
     if ($action == 'update') {
         $operator_acl = [
         $operator_acl = [
-            'User_auth' => [
+            'user_auth' => [
                 'comments' => '1',
                 'comments' => '1',
                 'dns_name' => '1',
                 'dns_name' => '1',
                 'dns_ptr_only' => '1',
                 'dns_ptr_only' => '1',
@@ -532,7 +532,7 @@ function allow_update($table, $action = 'update', $field = '')
                 'nagios_handler' => '1',
                 'nagios_handler' => '1',
                 'Wikiname' => '1'
                 'Wikiname' => '1'
             ],
             ],
-            'User_list' => [
+            'user_list' => [
                 'fio' => '1',
                 'fio' => '1',
                 'login' => '1',
                 'login' => '1',
             ],
             ],
@@ -642,7 +642,7 @@ function update_record($db, $table, $filter, $newvalue)
         if (isset($old[$key]) && strcmp($old[$key], $value) == 0) {
         if (isset($old[$key]) && strcmp($old[$key], $value) == 0) {
             continue;
             continue;
         }
         }
-        if ($table === "User_auth") {
+        if ($table === "user_auth") {
             if (!empty($acl_fields["$key"])) {
             if (!empty($acl_fields["$key"])) {
                 $network_changed = 1;
                 $network_changed = 1;
             }
             }
@@ -653,7 +653,7 @@ function update_record($db, $table, $filter, $newvalue)
                 $dns_changed = 1;
                 $dns_changed = 1;
             }
             }
         }
         }
-        if ($table === "User_auth_alias") {
+        if ($table === "user_auth_alias") {
             if (!empty($dns_fields["$key"])) {
             if (!empty($dns_fields["$key"])) {
                 $dns_changed = 1;
                 $dns_changed = 1;
             }
             }
@@ -665,7 +665,7 @@ function update_record($db, $table, $filter, $newvalue)
         $params[] = $value;
         $params[] = $value;
     }
     }
 
 
-    if ($table === "User_auth" and $dns_changed) {
+    if ($table === "user_auth" and $dns_changed) {
         if (!empty($old['dns_name']) and !empty($old['ip']) and !$old['dns_ptr_only'] and !preg_match('/\.$/', $old['dns_name'])) {
         if (!empty($old['dns_name']) and !empty($old['ip']) and !$old['dns_ptr_only'] and !preg_match('/\.$/', $old['dns_name'])) {
             $del_dns['name_type'] = 'A';
             $del_dns['name_type'] = 'A';
             $del_dns['name'] = $old['dns_name'];
             $del_dns['name'] = $old['dns_name'];
@@ -709,7 +709,7 @@ function update_record($db, $table, $filter, $newvalue)
         }
         }
     }
     }
 
 
-    if ($table === "User_auth_alias" and $dns_changed) {
+    if ($table === "user_auth_alias" and $dns_changed) {
         $auth_id = NULL;
         $auth_id = NULL;
         if ($old['auth_id']) {
         if ($old['auth_id']) {
             $auth_id = $old['auth_id'];
             $auth_id = $old['auth_id'];
@@ -751,7 +751,7 @@ function update_record($db, $table, $filter, $newvalue)
     $changed_log = substr_replace($changed_log, "", -1);
     $changed_log = substr_replace($changed_log, "", -1);
     $run_sql = implode(", ", $set_parts);
     $run_sql = implode(", ", $set_parts);
 
 
-    if ($table === 'User_auth') {
+    if ($table === 'user_auth') {
         $changed_time = GetNowTimeString();
         $changed_time = GetNowTimeString();
         $run_sql .= ", `changed_time` = ?";
         $run_sql .= ", `changed_time` = ?";
         $params[] = $changed_time;
         $params[] = $changed_time;
@@ -839,7 +839,7 @@ function delete_record($db, $table, $filter)
     $delete_it = 1;
     $delete_it = 1;
 
 
     //never delete user ip record
     //never delete user ip record
-    if ($table === 'User_auth') {
+    if ($table === 'user_auth') {
         $delete_it = 0;
         $delete_it = 0;
         $changed_time = GetNowTimeString();
         $changed_time = GetNowTimeString();
         $new_sql = "UPDATE $table SET deleted=1, changed=1, `changed_time`='" . $changed_time . "' WHERE $filter";
         $new_sql = "UPDATE $table SET deleted=1, changed=1, `changed_time`='" . $changed_time . "' WHERE $filter";
@@ -881,10 +881,10 @@ function delete_record($db, $table, $filter)
         }
         }
 
 
     //never delete permanent user
     //never delete permanent user
-    if ($table === 'User_list' and $old['permanent']) { return; }
+    if ($table === 'user_list' and $old['permanent']) { return; }
 
 
     //remove aliases
     //remove aliases
-    if ($table === 'User_auth_alias') {
+    if ($table === 'user_auth_alias') {
         //dns
         //dns
         if (!empty($old['alias'])  and !preg_match('/\.$/', $old['alias'])) {
         if (!empty($old['alias'])  and !preg_match('/\.$/', $old['alias'])) {
             $del_dns['name_type'] = 'CNAME';
             $del_dns['name_type'] = 'CNAME';
@@ -973,11 +973,11 @@ function insert_record($db, $table, $newvalue)
         if ($table !== "sessions") {
         if ($table !== "sessions") {
             LOG_VERBOSE($db, "Create record in table $table: $changed_log with id: $last_id");
             LOG_VERBOSE($db, "Create record in table $table: $changed_log with id: $last_id");
         }
         }
-        if ($table === 'User_auth') {
-            run_sql($db, "UPDATE User_auth SET changed=1, dhcp_changed=1 WHERE id=" . $last_id);
+        if ($table === 'user_auth') {
+            run_sql($db, "UPDATE user_auth SET changed=1, dhcp_changed=1 WHERE id=" . $last_id);
         }
         }
 
 
-        if ($table === 'User_auth_alias') {
+        if ($table === 'user_auth_alias') {
             //dns
             //dns
             if (!empty($newvalue['alias'])  and !preg_match('/\.$/', $newvalue['alias'])) {
             if (!empty($newvalue['alias'])  and !preg_match('/\.$/', $newvalue['alias'])) {
                 $add_dns['name_type'] = 'CNAME';
                 $add_dns['name_type'] = 'CNAME';
@@ -989,7 +989,7 @@ function insert_record($db, $table, $newvalue)
             }
             }
         }
         }
 
 
-        if ($table === 'User_auth') {
+        if ($table === 'user_auth') {
             //dns - A-record
             //dns - A-record
             if (!empty($newvalue['dns_name']) and !empty($newvalue['ip']) and !$newvalue['dns_ptr_only']  and !preg_match('/\.$/', $newvalue['dns_name'])) {
             if (!empty($newvalue['dns_name']) and !empty($newvalue['ip']) and !$newvalue['dns_ptr_only']  and !preg_match('/\.$/', $newvalue['dns_name'])) {
                 $add_dns['name_type'] = 'A';
                 $add_dns['name_type'] = 'A';
@@ -1093,14 +1093,14 @@ function get_diff_rec($db, $table, $filter, $newvalue, $only_changed = false)
 
 
 function delete_user_auth($db, $id) {
 function delete_user_auth($db, $id) {
     $msg = '';
     $msg = '';
-    $record = get_record_sql($db, 'SELECT * FROM User_auth WHERE id=' . $id);
+    $record = get_record_sql($db, 'SELECT * FROM user_auth WHERE id=' . $id);
     $txt_record = hash_to_text($record);
     $txt_record = hash_to_text($record);
     // remove aliases
     // remove aliases
-    $t_User_auth_alias = get_records_sql($db, 'SELECT * FROM User_auth_alias WHERE auth_id=' . $id);
-    if (!empty($t_User_auth_alias)) {
-        foreach ($t_User_auth_alias as $row) {
-            $alias_txt = record_to_txt($db, 'User_auth_alias', 'id=' . $row['id']);
-            if (delete_record($db, 'User_auth_alias', 'id=' . $row['id'])) {
+    $t_user_auth_alias = get_records_sql($db, 'SELECT * FROM user_auth_alias WHERE auth_id=' . $id);
+    if (!empty($t_user_auth_alias)) {
+        foreach ($t_user_auth_alias as $row) {
+            $alias_txt = record_to_txt($db, 'user_auth_alias', 'id=' . $row['id']);
+            if (delete_record($db, 'user_auth_alias', 'id=' . $row['id'])) {
                 $msg = "Deleting an alias: " . $alias_txt . "::Success!\n" . $msg;
                 $msg = "Deleting an alias: " . $alias_txt . "::Success!\n" . $msg;
             } else {
             } else {
                 $msg = "Deleting an alias: " . $alias_txt . "::Fail!\n" . $msg;
                 $msg = "Deleting an alias: " . $alias_txt . "::Fail!\n" . $msg;
@@ -1110,7 +1110,7 @@ function delete_user_auth($db, $id) {
     // remove connections
     // remove connections
     run_sql($db, 'DELETE FROM connections WHERE auth_id=' . $id);
     run_sql($db, 'DELETE FROM connections WHERE auth_id=' . $id);
     // remove user auth record
     // remove user auth record
-    $changes = delete_record($db, "User_auth", "id=" . $id);
+    $changes = delete_record($db, "user_auth", "id=" . $id);
     if ($changes) {
     if ($changes) {
         $msg = "Deleting ip-record: " . $txt_record . "::Success!\n" . $msg;
         $msg = "Deleting ip-record: " . $txt_record . "::Success!\n" . $msg;
     } else {
     } else {
@@ -1125,13 +1125,13 @@ function delete_user_auth($db, $id) {
 function delete_user($db,$id)
 function delete_user($db,$id)
 {
 {
 //remove user record
 //remove user record
-$changes = delete_record($db, "User_list", "id=" . $id);
+$changes = delete_record($db, "user_list", "id=" . $id);
 //if fail - exit
 //if fail - exit
 if (!isset($changes) or empty($changes)) { return; }
 if (!isset($changes) or empty($changes)) { return; }
 //remove auth records
 //remove auth records
-$t_User_auth = get_records($db,'User_auth',"user_id=$id");
-if (!empty($t_User_auth)) {
-    foreach ( $t_User_auth as $row ) { delete_user_auth($db,$row['id']); }
+$t_user_auth = get_records($db,'user_auth',"user_id=$id");
+if (!empty($t_user_auth)) {
+    foreach ( $t_user_auth as $row ) { delete_user_auth($db,$row['id']); }
     }
     }
 //remove device
 //remove device
 $device = get_record($db, "devices", "user_id='$id'");
 $device = get_record($db, "devices", "user_id='$id'");

+ 7 - 7
html/public/blocked.php

@@ -31,14 +31,14 @@ $date2 = $pdate_start->format('Y-m-d');
 $ip_aton = ip2long($auth_ip);
 $ip_aton = ip2long($auth_ip);
 if (! $ip_aton) { $ip_aton = 0; }
 if (! $ip_aton) { $ip_aton = 0; }
 
 
-$sSQL = "SELECT * FROM User_auth WHERE ip_int='".$ip_aton."' and deleted = 0";
+$sSQL = "SELECT * FROM user_auth WHERE ip_int='".$ip_aton."' and deleted = 0";
 $auth = get_record_sql($db_link,$sSQL);
 $auth = get_record_sql($db_link,$sSQL);
 if (! isset($auth) or empty($auth)) { print "<font color=red><b>".WEB_cell_ip."&nbsp". $auth_ip ."&nbsp - ".WEB_unknown."!</b><br></font>"; die; }
 if (! isset($auth) or empty($auth)) { print "<font color=red><b>".WEB_cell_ip."&nbsp". $auth_ip ."&nbsp - ".WEB_unknown."!</b><br></font>"; die; }
 
 
 $id = $auth['id'];
 $id = $auth['id'];
 $user_id = $auth['user_id'];
 $user_id = $auth['user_id'];
 
 
-$uSQL = "SELECT * FROM User_list WHERE id='".$user_id."'";
+$uSQL = "SELECT * FROM user_list WHERE id='".$user_id."'";
 $user = get_record_sql($db_link,$uSQL);
 $user = get_record_sql($db_link,$uSQL);
 
 
 if (! isset($user) or empty($user)) { print "<font color=red><b>".WEB_cell_ip."&nbsp". $auth_ip .WEB_user_deleted."</b><br></font>"; die; }
 if (! isset($user) or empty($user)) { print "<font color=red><b>".WEB_cell_ip."&nbsp". $auth_ip .WEB_user_deleted."</b><br></font>"; die; }
@@ -88,7 +88,7 @@ if ($auth['blocked']) { print "<font color=red>".WEB_msg_traffic_blocked."</font
 <?php
 <?php
 
 
 ####### day
 ####### day
-$sSQL = "SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM User_stats WHERE `timestamp`>='".$date1."' AND `timestamp`<'".$date2."' AND auth_id='".$id."'";
+$sSQL = "SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM user_stats WHERE `timestamp`>='".$date1."' AND `timestamp`<'".$date2."' AND auth_id='".$id."'";
 $day_auth_itog = get_record_sql($db_link,$sSQL);
 $day_auth_itog = get_record_sql($db_link,$sSQL);
 
 
 $day_auth_sum_in=0;
 $day_auth_sum_in=0;
@@ -104,11 +104,11 @@ if (!empty($day_auth_itog)) {
 $day_user_sum_in=0;
 $day_user_sum_in=0;
 $day_user_sum_out=0;
 $day_user_sum_out=0;
 
 
-$auth_list = get_records_sql($db_link,"SELECT id FROM User_auth WHERE user_id='".$user_id."' AND deleted=0");
+$auth_list = get_records_sql($db_link,"SELECT id FROM user_auth WHERE user_id='".$user_id."' AND deleted=0");
 
 
 if (!empty($auth_list)) {
 if (!empty($auth_list)) {
     foreach ($auth_list as $row) {
     foreach ($auth_list as $row) {
-        $auth_itog2 = get_record_sql($db_link,"SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM User_stats WHERE `timestamp`>='".$date1."' AND `timestamp`<'".$date2."' AND auth_id='".$row['id']."'");
+        $auth_itog2 = get_record_sql($db_link,"SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM user_stats WHERE `timestamp`>='".$date1."' AND `timestamp`<'".$date2."' AND auth_id='".$row['id']."'");
         if (!empty($auth_itog2)) { 
         if (!empty($auth_itog2)) { 
                 if (empty($auth_itog2['tin'])) { $auth_itog2['tin']=0; }
                 if (empty($auth_itog2['tin'])) { $auth_itog2['tin']=0; }
                 if (empty($auth_itog2['tout'])) { $auth_itog2['tout']=0; }
                 if (empty($auth_itog2['tout'])) { $auth_itog2['tout']=0; }
@@ -119,7 +119,7 @@ if (!empty($auth_list)) {
     }
     }
 
 
 #### month
 #### month
-$sSQL = "SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM User_stats WHERE `timestamp`>='".$date1m."' AND `timestamp`<'".$date2m."' AND auth_id='".$id."'";
+$sSQL = "SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM user_stats WHERE `timestamp`>='".$date1m."' AND `timestamp`<'".$date2m."' AND auth_id='".$id."'";
 $month_auth_itog = get_record_sql($db_link,$sSQL);
 $month_auth_itog = get_record_sql($db_link,$sSQL);
 
 
 $month_auth_sum_in=0;
 $month_auth_sum_in=0;
@@ -137,7 +137,7 @@ $month_user_sum_out=0;
 
 
 if (!empty($auth_list)) {
 if (!empty($auth_list)) {
     foreach ($auth_list as $row) {
     foreach ($auth_list as $row) {
-        $auth_itog2 = get_record_sql($db_link,"SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM User_stats WHERE `timestamp`>='".$date1m."' AND `timestamp`<'".$date2m."' AND auth_id='".$row['id']."'");
+        $auth_itog2 = get_record_sql($db_link,"SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM user_stats WHERE `timestamp`>='".$date1m."' AND `timestamp`<'".$date2m."' AND auth_id='".$row['id']."'");
         if (!empty($auth_itog2)) {
         if (!empty($auth_itog2)) {
                 if (empty($auth_itog2['tin'])) { $auth_itog2['tin']=0; }
                 if (empty($auth_itog2['tin'])) { $auth_itog2['tin']=0; }
                 if (empty($auth_itog2['tout'])) { $auth_itog2['tout']=0; }
                 if (empty($auth_itog2['tout'])) { $auth_itog2['tout']=0; }

+ 8 - 8
html/utils/auth_apply.php

@@ -67,8 +67,8 @@ if (isset($_POST["ApplyForAll"])) {
         if ($val) {
         if ($val) {
             unset($auth);
             unset($auth);
             //check user state
             //check user state
-            $cur_auth = get_record_sql($db_link, "SELECT * FROM User_auth WHERE `id`=" . $val);
-            if (!empty($cur_auth)) { $user_info = get_record_sql($db_link, "SELECT * FROM User_list WHERE `id`=" . $cur_auth["user_id"]); }
+            $cur_auth = get_record_sql($db_link, "SELECT * FROM user_auth WHERE `id`=" . $val);
+            if (!empty($cur_auth)) { $user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE `id`=" . $cur_auth["user_id"]); }
 
 
 
 
             if (isset($_POST["e_enabled"])) {
             if (isset($_POST["e_enabled"])) {
@@ -105,7 +105,7 @@ if (isset($_POST["ApplyForAll"])) {
             }
             }
 
 
             if (!empty($auth)) {
             if (!empty($auth)) {
-                $ret = update_record($db_link, "User_auth", "id='" . $val . "'", $auth);
+                $ret = update_record($db_link, "user_auth", "id='" . $val . "'", $auth);
                 if (!$ret) { $all_ok = 0; }
                 if (!$ret) { $all_ok = 0; }
             }
             }
 
 
@@ -116,14 +116,14 @@ if (isset($_POST["ApplyForAll"])) {
                 //change user group
                 //change user group
                 $msg = " For user id: " . $cur_auth['user_id'] . " login: " . $user_info['login'] . " set: ou_id = ".$a_ou_id;
                 $msg = " For user id: " . $cur_auth['user_id'] . " login: " . $user_info['login'] . " set: ou_id = ".$a_ou_id;
                 LOG_INFO($db_link,$msg);
                 LOG_INFO($db_link,$msg);
-                $ret = update_record($db_link, "User_list", "id='" . $cur_auth['user_id'] . "'", $user);
+                $ret = update_record($db_link, "user_list", "id='" . $cur_auth['user_id'] . "'", $user);
                 if (!$ret) { $all_ok = 0; }
                 if (!$ret) { $all_ok = 0; }
                 //change user ip
                 //change user ip
-                $auth_list = get_records_sql($db_link, "SELECT * FROM User_auth WHERE user_id=" . $cur_auth['user_id']);
+                $auth_list = get_records_sql($db_link, "SELECT * FROM user_auth WHERE user_id=" . $cur_auth['user_id']);
                 if (!empty($auth_list)) {
                 if (!empty($auth_list)) {
                         foreach ($auth_list as $row) {
                         foreach ($auth_list as $row) {
                             if (empty($row)) { continue; }
                             if (empty($row)) { continue; }
-                            $ret = update_record($db_link, "User_auth", "id='" . $row["id"] . "'", $u_auth);
+                            $ret = update_record($db_link, "user_auth", "id='" . $row["id"] . "'", $u_auth);
                             if (!$ret) { $all_ok = 0; }
                             if (!$ret) { $all_ok = 0; }
                             }
                             }
                         }
                         }
@@ -132,7 +132,7 @@ if (isset($_POST["ApplyForAll"])) {
 
 
             //bind mac rule
             //bind mac rule
             if (isset($_POST["e_bind_mac"])) {
             if (isset($_POST["e_bind_mac"])) {
-                $first_auth = get_record_sql($db_link,"SELECT user_id,mac FROM User_auth WHERE id=".$val);
+                $first_auth = get_record_sql($db_link,"SELECT user_id,mac FROM user_auth WHERE id=".$val);
                 if (!empty($first_auth) and !empty($first_auth['mac'])) {
                 if (!empty($first_auth) and !empty($first_auth['mac'])) {
                     if ($a_bind_mac) {
                     if ($a_bind_mac) {
                             $auth_rules_user = get_record_sql($db_link,"SELECT * FROM auth_rules WHERE user_id=".$first_auth['user_id']." AND type=2");
                             $auth_rules_user = get_record_sql($db_link,"SELECT * FROM auth_rules WHERE user_id=".$first_auth['user_id']." AND type=2");
@@ -157,7 +157,7 @@ if (isset($_POST["ApplyForAll"])) {
 
 
             //bind ip rule
             //bind ip rule
             if (isset($_POST["e_bind_ip"])) {
             if (isset($_POST["e_bind_ip"])) {
-                $first_auth = get_record_sql($db_link,"SELECT user_id,ip FROM User_auth WHERE id=".$val);
+                $first_auth = get_record_sql($db_link,"SELECT user_id,ip FROM user_auth WHERE id=".$val);
                 if (!empty($first_auth) and !empty($first_auth['ip'])) {
                 if (!empty($first_auth) and !empty($first_auth['ip'])) {
                     if ($a_bind_ip) {
                     if ($a_bind_ip) {
                             $auth_rules_user = get_record_sql($db_link,"SELECT * FROM auth_rules WHERE user_id=".$first_auth['user_id']." AND type=1");
                             $auth_rules_user = get_record_sql($db_link,"SELECT * FROM auth_rules WHERE user_id=".$first_auth['user_id']." AND type=1");

+ 3 - 3
html/utils/auth_export.php

@@ -11,7 +11,7 @@ if (isset($_POST["ExportAuth"])) {
         $auth_id = $_POST["fid"];
         $auth_id = $_POST["fid"];
         foreach ($auth_id as $key => $val) {
         foreach ($auth_id as $key => $val) {
             if ($val) {
             if ($val) {
-                $sSQL = "SELECT User_list.login, User_auth.ip, User_auth.mac, User_auth.comments, User_auth.dns_name, User_auth.last_found FROM User_auth, User_list WHERE User_auth.user_id = User_list.id AND User_auth.id = " . $val;
+                $sSQL = "SELECT user_list.login, user_auth.ip, user_auth.mac, user_auth.comments, user_auth.dns_name, user_auth.last_found FROM user_auth, user_list WHERE user_auth.user_id = user_list.id AND user_auth.id = " . $val;
                 $record = get_record_sql($db_link, $sSQL);
                 $record = get_record_sql($db_link, $sSQL);
                 print $record['login'] . ';' . $record['ip'] . ';' . $record['mac'] . ';' . $record['comments'] . ';' . $record['dns_name'] . ';' . $record['last_found'] . ';' . get_connection_string($db_link, $val)."\n";
                 print $record['login'] . ';' . $record['ip'] . ';' . $record['mac'] . ';' . $record['comments'] . ';' . $record['dns_name'] . ';' . $record['last_found'] . ';' . get_connection_string($db_link, $val)."\n";
             }
             }
@@ -19,10 +19,10 @@ if (isset($_POST["ExportAuth"])) {
     } else {
     } else {
         //export all
         //export all
         $ip_filter = '';
         $ip_filter = '';
-        $sort = 'User_auth.ip_int';
+        $sort = 'user_auth.ip_int';
         if (!empty($_POST["ip-filter"])) { $ip_filter = $_POST['ip-filter']; }
         if (!empty($_POST["ip-filter"])) { $ip_filter = $_POST['ip-filter']; }
         if (!empty($_POST["ip-sort"])) { $sort = $_POST['ip-sort']; }
         if (!empty($_POST["ip-sort"])) { $sort = $_POST['ip-sort']; }
-        $sSQL = "SELECT User_auth.*, User_list.login, User_list.enabled as UEnabled, User_list.blocked as UBlocked FROM User_auth, User_list WHERE User_auth.user_id = User_list.id AND User_auth.deleted = 0 $ip_filter ORDER BY $sort";
+        $sSQL = "SELECT user_auth.*, user_list.login, user_list.enabled as UEnabled, user_list.blocked as UBlocked FROM user_auth, user_list WHERE user_auth.user_id = user_list.id AND user_auth.deleted = 0 $ip_filter ORDER BY $sort";
         $auth_table = get_records_sql($db_link, $sSQL);
         $auth_table = get_records_sql($db_link, $sSQL);
         foreach ($auth_table as $record) {
         foreach ($auth_table as $record) {
             print $record['login'] . ';' . $record['ip'] . ';' . $record['mac'] . ';' . $record['comments'] . ';' . $record['dns_name'] . ';' . $record['last_found'] .';' . get_connection_string($db_link, $record['id']). "\n";
             print $record['login'] . ';' . $record['ip'] . ';' . $record['mac'] . ';' . $record['comments'] . ';' . $record['dns_name'] . ';' . $record['last_found'] .';' . get_connection_string($db_link, $record['id']). "\n";

+ 6 - 6
html/utils/user_apply.php

@@ -111,16 +111,16 @@ if (isset($_POST["ApplyForAll"])) {
                 $user['permanent'] = $a_permanent;
                 $user['permanent'] = $a_permanent;
             }
             }
 
 
-            $login = get_record($db_link, "User_list", "id='$val'");
+            $login = get_record($db_link, "user_list", "id='$val'");
             $msg .= " For all ip user id: " . $val . " login: " . $login['login'] . " set: ";
             $msg .= " For all ip user id: " . $val . " login: " . $login['login'] . " set: ";
-            $msg .= get_diff_rec($db_link, "User_list", "id='$val'", $user, 1);
+            $msg .= get_diff_rec($db_link, "user_list", "id='$val'", $user, 1);
 
 
             if (!empty($user)) { 
             if (!empty($user)) { 
-                $ret = update_record($db_link, "User_list", "id='" . $val . "'", $user);
+                $ret = update_record($db_link, "user_list", "id='" . $val . "'", $user);
                 if (!$ret) { $all_ok = 0; }
                 if (!$ret) { $all_ok = 0; }
                 }
                 }
 
 
-            $auth_list = get_records_sql($db_link, "SELECT id, mac, ip FROM User_auth WHERE deleted=0 AND user_id=" . $val);
+            $auth_list = get_records_sql($db_link, "SELECT id, mac, ip FROM user_auth WHERE deleted=0 AND user_id=" . $val);
             $b_mac = '';
             $b_mac = '';
             $b_ip = '';
             $b_ip = '';
             if (!empty($auth_list)) {
             if (!empty($auth_list)) {
@@ -129,7 +129,7 @@ if (isset($_POST["ApplyForAll"])) {
                     if (empty($b_mac) and !empty($row["mac"])) { $b_mac = $row["mac"]; }
                     if (empty($b_mac) and !empty($row["mac"])) { $b_mac = $row["mac"]; }
                     if (empty($b_ip) and !empty($row["ip"])) { $b_ip = $row["ip"]; }
                     if (empty($b_ip) and !empty($row["ip"])) { $b_ip = $row["ip"]; }
                     if (!empty($auth)) {
                     if (!empty($auth)) {
-                        $ret = update_record($db_link, "User_auth", "id='" . $row["id"] . "'", $auth);
+                        $ret = update_record($db_link, "user_auth", "id='" . $row["id"] . "'", $auth);
                         if (!$ret) { $all_ok = 0; }
                         if (!$ret) { $all_ok = 0; }
                     }
                     }
                 }
                 }
@@ -184,7 +184,7 @@ if (isset($_POST["ApplyForAll"])) {
                 if ($a_create_netdev) {
                 if ($a_create_netdev) {
                     if (!empty($b_ip)) {
                     if (!empty($b_ip)) {
                         $device = get_record_sql($db_link,"SELECT * FROM devices WHERE user_id=".$val);
                         $device = get_record_sql($db_link,"SELECT * FROM devices WHERE user_id=".$val);
-                        $auth = get_record_sql($db_link,"SELECT * FROM User_auth WHERE user_id=".$val." ORDER BY last_found DESC");
+                        $auth = get_record_sql($db_link,"SELECT * FROM user_auth WHERE user_id=".$val." ORDER BY last_found DESC");
                         if (empty($device) and !empty($auth)) {
                         if (empty($device) and !empty($auth)) {
                             $new['user_id']=$val;
                             $new['user_id']=$val;
                             $new['device_name'] = $login['login'];
                             $new['device_name'] = $login['login'];

+ 1 - 1
scripts/check_dhcp_pool.pl

@@ -58,7 +58,7 @@ $dhcp_conf{$subnet_name}->{dhcp_pool_size}=$subnet->{dhcp_stop}-$subnet->{dhcp_s
 }
 }
 
 
 #get userid list
 #get userid list
-my $sSQL="SELECT id,ip,ip_int,mac,comments,dns_name FROM User_auth where dhcp=1 and deleted=0 and ou_id<>$default_hotspot_ou_id and ou_id<>$default_user_ou_id ORDER by ip_int";
+my $sSQL="SELECT id,ip,ip_int,mac,comments,dns_name FROM user_auth where dhcp=1 and deleted=0 and ou_id<>$default_hotspot_ou_id and ou_id<>$default_user_ou_id ORDER by ip_int";
 my @users = get_records_sql($dbh,$sSQL);
 my @users = get_records_sql($dbh,$sSQL);
 foreach my $row (@users) {
 foreach my $row (@users) {
 next if (!$row);
 next if (!$row);

+ 10 - 10
scripts/dhcp-log.pl

@@ -211,7 +211,7 @@ sub run {
                         $t_remote_id = mac_splitted(isc_mac_simplify($t_remote_id));
                         $t_remote_id = mac_splitted(isc_mac_simplify($t_remote_id));
 
 
                         my $devSQL = "SELECT D.id, D.device_name, D.ip, A.mac " .
                         my $devSQL = "SELECT D.id, D.device_name, D.ip, A.mac " .
-                                     "FROM `devices` AS D, `User_auth` AS A " .
+                                     "FROM devices AS D, user_auth AS A " .
                                      "WHERE D.user_id = A.User_id AND D.ip = A.ip AND A.deleted = 0 " .
                                      "WHERE D.user_id = A.User_id AND D.ip = A.ip AND A.deleted = 0 " .
                                      "AND A.mac = '$t_remote_id'";
                                      "AND A.mac = '$t_remote_id'";
                         log_debug("SQL (по decoded_remote_id): $devSQL");
                         log_debug("SQL (по decoded_remote_id): $devSQL");
@@ -220,8 +220,8 @@ sub run {
                         if ($switch) {
                         if ($switch) {
                             $remote_id = $t_remote_id;
                             $remote_id = $t_remote_id;
                             $circuit_id = $decoded_circuit_id;
                             $circuit_id = $decoded_circuit_id;
-                            $dhcp_record->{'circuit-id'} = $circuit_id;
-                            $dhcp_record->{'remote-id'} = $remote_id;
+                            $dhcp_record->{circuit_id} = $circuit_id;
+                            $dhcp_record->{remote_id} = $remote_id;
                             log_debug("Коммутатор найден по decoded_remote_id: " . $switch->{device_name});
                             log_debug("Коммутатор найден по decoded_remote_id: " . $switch->{device_name});
                         }
                         }
                     }
                     }
@@ -233,7 +233,7 @@ sub run {
                         $t_remote_id = mac_splitted(isc_mac_simplify($t_remote_id));
                         $t_remote_id = mac_splitted(isc_mac_simplify($t_remote_id));
 
 
                         my $devSQL = "SELECT D.id, D.device_name, D.ip, A.mac " .
                         my $devSQL = "SELECT D.id, D.device_name, D.ip, A.mac " .
-                                     "FROM `devices` AS D, `User_auth` AS A " .
+                                     "FROM devices AS D, user_auth AS A " .
                                      "WHERE D.user_id = A.User_id AND D.ip = A.ip AND A.deleted = 0 " .
                                      "WHERE D.user_id = A.User_id AND D.ip = A.ip AND A.deleted = 0 " .
                                      "AND A.mac = '$t_remote_id'";
                                      "AND A.mac = '$t_remote_id'";
                         log_debug("SQL (по remote_id): $devSQL");
                         log_debug("SQL (по remote_id): $devSQL");
@@ -241,8 +241,8 @@ sub run {
 
 
                         if ($switch) {
                         if ($switch) {
                             $remote_id = $t_remote_id;
                             $remote_id = $t_remote_id;
-                            $dhcp_record->{'circuit-id'} = $circuit_id;
-                            $dhcp_record->{'remote-id'} = $remote_id;
+                            $dhcp_record->{circuit_id} = $circuit_id;
+                            $dhcp_record->{remote_id} = $remote_id;
                             log_debug("Коммутатор найден по remote_id: " . $switch->{device_name});
                             log_debug("Коммутатор найден по remote_id: " . $switch->{device_name});
                         }
                         }
                     }
                     }
@@ -252,7 +252,7 @@ sub run {
                         my @id_words = split(/ /, $remote_id);
                         my @id_words = split(/ /, $remote_id);
                         if ($id_words[0]) {
                         if ($id_words[0]) {
                             my $devSQL = "SELECT D.id, D.device_name, D.ip, A.mac " .
                             my $devSQL = "SELECT D.id, D.device_name, D.ip, A.mac " .
-                                         "FROM `devices` AS D, `User_auth` AS A " .
+                                         "FROM devices AS D, user_auth AS A " .
                                          "WHERE D.user_id = A.User_id AND D.ip = A.ip AND A.deleted = 0 " .
                                          "WHERE D.user_id = A.User_id AND D.ip = A.ip AND A.deleted = 0 " .
                                          "AND D.device_name LIKE '$id_words[0]%'";
                                          "AND D.device_name LIKE '$id_words[0]%'";
                             log_debug("SQL (по имени устройства из remote_id): $devSQL");
                             log_debug("SQL (по имени устройства из remote_id): $devSQL");
@@ -268,7 +268,7 @@ sub run {
                         my @id_words = split(/ /, $circuit_id);
                         my @id_words = split(/ /, $circuit_id);
                         if ($id_words[0]) {
                         if ($id_words[0]) {
                             my $devSQL = "SELECT D.id, D.device_name, D.ip, A.mac " .
                             my $devSQL = "SELECT D.id, D.device_name, D.ip, A.mac " .
-                                         "FROM `devices` AS D, `User_auth` AS A " .
+                                         "FROM devices AS D, user_auth AS A " .
                                          "WHERE D.user_id = A.User_id AND D.ip = A.ip AND A.deleted = 0 " .
                                          "WHERE D.user_id = A.User_id AND D.ip = A.ip AND A.deleted = 0 " .
                                          "AND D.device_name LIKE '$id_words[0]%'";
                                          "AND D.device_name LIKE '$id_words[0]%'";
                             log_debug("SQL (по имени из circuit_id — MikroTik?): $devSQL");
                             log_debug("SQL (по имени из circuit_id — MikroTik?): $devSQL");
@@ -276,8 +276,8 @@ sub run {
                             if ($switch) {
                             if ($switch) {
                                 # MikroTik часто путает remote-id и circuit-id — меняем местами
                                 # MikroTik часто путает remote-id и circuit-id — меняем местами
                                 ($circuit_id, $remote_id) = ($remote_id, $t_circuit_id);
                                 ($circuit_id, $remote_id) = ($remote_id, $t_circuit_id);
-                                $dhcp_record->{'circuit-id'} = $circuit_id;
-                                $dhcp_record->{'remote-id'} = $remote_id;
+                                $dhcp_record->{circuit_id} = $circuit_id;
+                                $dhcp_record->{remote_id} = $remote_id;
                                 log_debug("Обнаружен MikroTik — поменяли местами circuit-id и remote-id");
                                 log_debug("Обнаружен MikroTik — поменяли местами circuit-id и remote-id");
                             }
                             }
                         }
                         }

+ 9 - 9
scripts/eye-statd.pl

@@ -115,7 +115,7 @@ $save_path = get_option($dbh,72);
 $timeshift = get_option($hdb,55)*60;
 $timeshift = get_option($hdb,55)*60;
 
 
 @router_ref = get_records_sql($hdb,"SELECT * FROM devices WHERE deleted=0 AND device_type=2 AND snmp_version>0 ORDER by ip" );
 @router_ref = get_records_sql($hdb,"SELECT * FROM devices WHERE deleted=0 AND device_type=2 AND snmp_version>0 ORDER by ip" );
-@interfaces = get_records_sql($hdb,"SELECT * FROM `device_l3_interfaces` ORDER by device_id" );
+@interfaces = get_records_sql($hdb,"SELECT * FROM device_l3_interfaces ORDER by device_id" );
 
 
 #router device_id by known device ip
 #router device_id by known device ip
 foreach my $row (@router_ref) {
 foreach my $row (@router_ref) {
@@ -141,7 +141,7 @@ foreach my $row (@interfaces) {
     }
     }
 
 
 #get userid list
 #get userid list
-my @auth_list_ref = get_records_sql($hdb,"SELECT id,ip,save_traf FROM User_auth where deleted=0 ORDER by id");
+my @auth_list_ref = get_records_sql($hdb,"SELECT id,ip,save_traf FROM user_auth where deleted=0 ORDER by id");
 
 
 foreach my $row (@auth_list_ref) {
 foreach my $row (@auth_list_ref) {
     $user_stats{$row->{ip}}{auth_id}=$row->{id};
     $user_stats{$row->{ip}}{auth_id}=$row->{id};
@@ -779,7 +779,7 @@ foreach my $user_ip (keys %user_stats) {
     my $flow_date = $hdb->quote(sprintf "%04d-%02d-%02d %02d:%02d:%02d",$year+1900,$month+1,$day,$hour,$min,$sec);
     my $flow_date = $hdb->quote(sprintf "%04d-%02d-%02d %02d:%02d:%02d",$year+1900,$month+1,$day,$hour,$min,$sec);
 
 
     #last found timestamp
     #last found timestamp
-    my $tSQL="UPDATE User_auth SET `last_found`=$flow_date WHERE id='$auth_id'";
+    my $tSQL="UPDATE user_auth SET last_found=$flow_date WHERE id='$auth_id'";
     push (@batch_sql_traf,$tSQL);
     push (@batch_sql_traf,$tSQL);
 
 
     #per router stats
     #per router stats
@@ -793,14 +793,14 @@ foreach my $user_ip (keys %user_stats) {
 	if (!exists $user_stats{$user_ip}{$router_id}{pkt_in})  { $user_stats{$user_ip}{$router_id}{pkt_in} = 0; }
 	if (!exists $user_stats{$user_ip}{$router_id}{pkt_in})  { $user_stats{$user_ip}{$router_id}{pkt_in} = 0; }
 	if (!exists $user_stats{$user_ip}{$router_id}{pkt_out}) { $user_stats{$user_ip}{$router_id}{pkt_out} = 0; }
 	if (!exists $user_stats{$user_ip}{$router_id}{pkt_out}) { $user_stats{$user_ip}{$router_id}{pkt_out} = 0; }
 	#current stats
 	#current stats
-	my $tSQL="INSERT INTO User_stats_full (timestamp,auth_id,router_id,byte_in,byte_out,pkt_in,pkt_out,step) VALUES($flow_date,'$auth_id','$router_id','$user_stats{$user_ip}{$router_id}{in}','$user_stats{$user_ip}{$router_id}{out}','$user_stats{$user_ip}{$router_id}{pkt_in}','$user_stats{$user_ip}{$router_id}{pkt_out}','$timeshift')";
+	my $tSQL="INSERT INTO user_stats_full (ts,auth_id,router_id,byte_in,byte_out,pkt_in,pkt_out,step) VALUES($flow_date,'$auth_id','$router_id','$user_stats{$user_ip}{$router_id}{in}','$user_stats{$user_ip}{$router_id}{out}','$user_stats{$user_ip}{$router_id}{pkt_in}','$user_stats{$user_ip}{$router_id}{pkt_out}','$timeshift')";
 	push (@batch_sql_traf,$tSQL);
 	push (@batch_sql_traf,$tSQL);
 	#hour stats
 	#hour stats
 	# get current stats
 	# get current stats
-	my $sql = "SELECT id, byte_in, byte_out FROM User_stats WHERE `timestamp`>=$hour_date1 AND `timestamp`<$hour_date2 AND router_id=$router_id AND auth_id=$auth_id";
+	my $sql = "SELECT id, byte_in, byte_out FROM user_stats WHERE ts>=$hour_date1 AND ts<$hour_date2 AND router_id=$router_id AND auth_id=$auth_id";
 	my $hour_stat = get_record_sql($hdb,$sql);
 	my $hour_stat = get_record_sql($hdb,$sql);
 	if (!$hour_stat) {
 	if (!$hour_stat) {
-	    my $dSQL="INSERT INTO User_stats (timestamp,auth_id,router_id,byte_in,byte_out) VALUES($flow_date,'$auth_id','$router_id','$user_stats{$user_ip}{$router_id}{in}','$user_stats{$user_ip}{$router_id}{out}')";
+	    my $dSQL="INSERT INTO user_stats (ts,auth_id,router_id,byte_in,byte_out) VALUES($flow_date,'$auth_id','$router_id','$user_stats{$user_ip}{$router_id}{in}','$user_stats{$user_ip}{$router_id}{out}')";
 	    push (@batch_sql_traf,$dSQL);
 	    push (@batch_sql_traf,$dSQL);
 	    next;
 	    next;
 	    }
 	    }
@@ -808,7 +808,7 @@ foreach my $user_ip (keys %user_stats) {
 	if (!$hour_stat->{byte_out}) { $hour_stat->{byte_out}=0; }
 	if (!$hour_stat->{byte_out}) { $hour_stat->{byte_out}=0; }
 	$hour_stat->{byte_in} += $user_stats{$user_ip}{$router_id}{in};
 	$hour_stat->{byte_in} += $user_stats{$user_ip}{$router_id}{in};
 	$hour_stat->{byte_out} += $user_stats{$user_ip}{$router_id}{out};
 	$hour_stat->{byte_out} += $user_stats{$user_ip}{$router_id}{out};
-	$tSQL="UPDATE User_stats SET byte_in='".$hour_stat->{byte_in}."', byte_out='".$hour_stat->{byte_out}."' WHERE id='".$auth_id."' AND router_id='".$router_id."'";
+	$tSQL="UPDATE user_stats SET byte_in='".$hour_stat->{byte_in}."', byte_out='".$hour_stat->{byte_out}."' WHERE id='".$auth_id."' AND router_id='".$router_id."'";
 	push (@batch_sql_traf,$tSQL);
 	push (@batch_sql_traf,$tSQL);
 	}
 	}
     }
     }
@@ -830,7 +830,7 @@ foreach my $router_id (keys %wan_stats) {
 	#skip empty stats
 	#skip empty stats
         if ($wan_stats{$router_id}{$int_id}{in} + $wan_stats{$router_id}{$int_id}{out} + $wan_stats{$router_id}{$int_id}{forward_in} + $wan_stats{$router_id}{$int_id}{forward_out} ==0) { next; }
         if ($wan_stats{$router_id}{$int_id}{in} + $wan_stats{$router_id}{$int_id}{out} + $wan_stats{$router_id}{$int_id}{forward_in} + $wan_stats{$router_id}{$int_id}{forward_out} ==0) { next; }
 	#current stats
 	#current stats
-	my $tSQL="INSERT INTO Wan_stats (`time`,`router_id`,`interface_id`,`in`,`out`,`forward_in`,`forward_out`) VALUES($flow_date,'$router_id','$int_id','$wan_stats{$router_id}{$int_id}{in}','$wan_stats{$router_id}{$int_id}{out}','$wan_stats{$router_id}{$int_id}{forward_in}','$wan_stats{$router_id}{$int_id}{forward_out}')";
+	my $tSQL="INSERT INTO wan_stats (ts,router_id,interface_id,bytes_in,bytes_out,forward_in,forward_out) VALUES($flow_date,'$router_id','$int_id','$wan_stats{$router_id}{$int_id}{in}','$wan_stats{$router_id}{$int_id}{out}','$wan_stats{$router_id}{$int_id}{forward_in}','$wan_stats{$router_id}{$int_id}{forward_out}')";
 	push (@batch_sql_traf,$tSQL);
 	push (@batch_sql_traf,$tSQL);
 	}
 	}
     }
     }
@@ -849,7 +849,7 @@ if ($config_ref{enable_quotes}) {
 if (scalar(@detail_traffic)) {
 if (scalar(@detail_traffic)) {
     db_log_debug($hdb,"Start write traffic detail to DB. ".scalar @detail_traffic." lines count") if ($debug);
     db_log_debug($hdb,"Start write traffic detail to DB. ".scalar @detail_traffic." lines count") if ($debug);
     #mysql dont work at parallel table lock
     #mysql dont work at parallel table lock
-    batch_db_sql_csv("Traffic_detail", \@detail_traffic);
+    batch_db_sql_csv("traffic_detail", \@detail_traffic);
     @detail_traffic = ();
     @detail_traffic = ();
     db_log_debug($hdb,"Write traffic detail to DB stopped") if ($debug);
     db_log_debug($hdb,"Write traffic detail to DB stopped") if ($debug);
     }
     }

+ 65 - 65
scripts/eyelib/common.pm

@@ -103,7 +103,7 @@ foreach my $row (@target) {
 sub get_dns_name {
 sub get_dns_name {
 my $db = shift;
 my $db = shift;
 my $id = shift;
 my $id = shift;
-my $auth_record = get_record_sql($db,"SELECT dns_name FROM User_auth WHERE deleted=0 AND id=".$id);
+my $auth_record = get_record_sql($db,"SELECT dns_name FROM user_auth WHERE deleted=0 AND id=".$id);
 if ($auth_record and $auth_record->{'dns_name'}) { return $auth_record->{'dns_name'}; }
 if ($auth_record and $auth_record->{'dns_name'}) { return $auth_record->{'dns_name'}; }
 return;
 return;
 }
 }
@@ -124,18 +124,18 @@ sub delete_user_auth {
 my $db = shift;
 my $db = shift;
 my $id = shift;
 my $id = shift;
 
 
-my $record = get_record_sql($db,'SELECT * FROM User_auth WHERE id='.$id);
+my $record = get_record_sql($db,'SELECT * FROM user_auth WHERE id='.$id);
 my $auth_ident = $record->{ip};
 my $auth_ident = $record->{ip};
 $auth_ident = $auth_ident . '['.$record->{dns_name} .']' if ($record->{dns_name});
 $auth_ident = $auth_ident . '['.$record->{dns_name} .']' if ($record->{dns_name});
 $auth_ident = $auth_ident . ' :: '.$record->{comments} if ($record->{dns_name});
 $auth_ident = $auth_ident . ' :: '.$record->{comments} if ($record->{dns_name});
 my $msg = "";
 my $msg = "";
 my $txt_record = hash_to_text($record);
 my $txt_record = hash_to_text($record);
 #remove aliases
 #remove aliases
-my @t_User_auth_alias = get_records_sql($db,'SELECT * FROM User_auth_alias WHERE auth_id='.$id);
-if (@t_User_auth_alias and scalar @t_User_auth_alias) {
-    foreach my $row ( @t_User_auth_alias) {
-        my $alias_txt = record_to_txt($db,'User_auth_alias','id='.$row->{'id'});
-        if (delete_record($db,'User_auth_alias','id='.$row->{'id'})) {
+my @t_user_auth_alias = get_records_sql($db,'SELECT * FROM user_auth_alias WHERE auth_id='.$id);
+if (@t_user_auth_alias and scalar @t_user_auth_alias) {
+    foreach my $row ( @t_user_auth_alias) {
+        my $alias_txt = record_to_txt($db,'user_auth_alias','id='.$row->{'id'});
+        if (delete_record($db,'user_auth_alias','id='.$row->{'id'})) {
             $msg = "Deleting an alias: ". $alias_txt . "\n::Success!\n" . $msg;
             $msg = "Deleting an alias: ". $alias_txt . "\n::Success!\n" . $msg;
             } else {
             } else {
             $msg = "Deleting an alias: ". $alias_txt . "\n::Fail!\n" . $msg;
             $msg = "Deleting an alias: ". $alias_txt . "\n::Fail!\n" . $msg;
@@ -145,7 +145,7 @@ if (@t_User_auth_alias and scalar @t_User_auth_alias) {
 #remove connections
 #remove connections
 do_sql($db,'DELETE FROM connections WHERE auth_id='.$id);
 do_sql($db,'DELETE FROM connections WHERE auth_id='.$id);
 #remove user auth record
 #remove user auth record
-my $changes = delete_record($db, "User_auth", "id=" . $id);
+my $changes = delete_record($db, "user_auth", "id=" . $id);
 if ($changes) {
 if ($changes) {
     $msg = "Deleting ip-record: ". $txt_record . "\n::Success!\n" . $msg;
     $msg = "Deleting ip-record: ". $txt_record . "\n::Success!\n" . $msg;
     } else {
     } else {
@@ -164,11 +164,11 @@ return $changes;
 sub unblock_user {
 sub unblock_user {
 my $db = shift;
 my $db = shift;
 my $user_id = shift;
 my $user_id = shift;
-my $user_record = get_record_sql($db,'SELECT * FROM User_list WHERE id='.$user_id);
+my $user_record = get_record_sql($db,'SELECT * FROM user_list WHERE id='.$user_id);
 my $user_ident = 'id:'. $user_record->{'id'} . ' '. $user_record->{'login'};
 my $user_ident = 'id:'. $user_record->{'id'} . ' '. $user_record->{'login'};
 $user_ident = $user_ident . '[' . $user_record->{'fio'} . ']' if ($user_record->{'fio'});
 $user_ident = $user_ident . '[' . $user_record->{'fio'} . ']' if ($user_record->{'fio'});
 my $msg = "Amnistuyemo blocked by traffic user $user_ident \nInternet access for the user's IP address has been restored:\n";
 my $msg = "Amnistuyemo blocked by traffic user $user_ident \nInternet access for the user's IP address has been restored:\n";
-my @user_auth = get_records_sql($db,'SELECT * FROM User_auth WHERE deleted=0 AND user_id='.$user_id);
+my @user_auth = get_records_sql($db,'SELECT * FROM user_auth WHERE deleted=0 AND user_id='.$user_id);
 my $send_alert = 0;
 my $send_alert = 0;
 if (@user_auth and scalar @user_auth) {
 if (@user_auth and scalar @user_auth) {
     foreach my $record (@user_auth) {
     foreach my $record (@user_auth) {
@@ -179,7 +179,7 @@ if (@user_auth and scalar @user_auth) {
         my $new;
         my $new;
         $new->{'blocked'}=0;
         $new->{'blocked'}=0;
         $new->{'changed'}=1;
         $new->{'changed'}=1;
-        my $ret_id = update_record($db,'User_auth',$new,'id='.$record->{'id'});
+        my $ret_id = update_record($db,'user_auth',$new,'id='.$record->{'id'});
         if ($ret_id) {
         if ($ret_id) {
             $msg = $msg ."\n".$auth_ident;
             $msg = $msg ."\n".$auth_ident;
             }
             }
@@ -187,7 +187,7 @@ if (@user_auth and scalar @user_auth) {
     }
     }
 my $new;
 my $new;
 $new->{'blocked'}=0;
 $new->{'blocked'}=0;
-my $ret_id = update_record($db,'User_list','id='.$user_id);
+my $ret_id = update_record($db,'user_list','id='.$user_id);
 if ($ret_id) {
 if ($ret_id) {
     db_log_info($db,$msg);
     db_log_info($db,$msg);
     sendEmail("WARN! ".get_first_line($msg),$msg,1) if ($send_alert);
     sendEmail("WARN! ".get_first_line($msg),$msg,1) if ($send_alert);
@@ -201,13 +201,13 @@ sub delete_user {
 my $db = shift;
 my $db = shift;
 my $id = shift;
 my $id = shift;
 #remove user record
 #remove user record
-my $changes = delete_record($db, "User_list", "id=" . $id);
+my $changes = delete_record($db, "user_list", "id=" . $id);
 #if fail - exit
 #if fail - exit
 if (!$changes) { return; }
 if (!$changes) { return; }
 #remove auth records
 #remove auth records
-my @t_User_auth = get_records_sql($db,'SELECT * FROM User_auth WHERE user_id='.$id);
-if (@t_User_auth and scalar @t_User_auth) {
-    foreach my $row ( @t_User_auth ) { delete_user_auth($db,$row->{'id'}); }
+my @t_user_auth = get_records_sql($db,'SELECT * FROM user_auth WHERE user_id='.$id);
+if (@t_user_auth and scalar @t_user_auth) {
+    foreach my $row ( @t_user_auth ) { delete_user_auth($db,$row->{'id'}); }
     }
     }
 #remove device
 #remove device
 my $device = get_record_sql($db, "SELECT * FROM devices WHERE user_id=".$id);
 my $device = get_record_sql($db, "SELECT * FROM devices WHERE user_id=".$id);
@@ -359,7 +359,7 @@ my $id = shift;
 return if (!$db or !$id);
 return if (!$db or !$id);
 my $update_record;
 my $update_record;
 $update_record->{changed}=1;
 $update_record->{changed}=1;
-update_record($db,'User_auth',$update_record,"id=$id");
+update_record($db,'user_auth',$update_record,"id=$id");
 }
 }
 
 
 #---------------------------------------------------------------------------------------------------------------
 #---------------------------------------------------------------------------------------------------------------
@@ -386,7 +386,7 @@ log_debug("Auth id: ".$auth_id);
 log_debug("enable_ad_dns_update: ".$enable_ad_dns_update);
 log_debug("enable_ad_dns_update: ".$enable_ad_dns_update);
 log_debug("DNS update flags - zone: ".$ad_zone.", dns: ".$ad_dns.", enable_ad_dns_update: ".$enable_ad_dns_update);
 log_debug("DNS update flags - zone: ".$ad_zone.", dns: ".$ad_dns.", enable_ad_dns_update: ".$enable_ad_dns_update);
 
 
-my @dns_queue = get_records_sql($hdb,"SELECT * FROM dns_queue WHERE auth_id=".$auth_id." AND `value`>'' AND `value` NOT LIKE '%.'ORDER BY id ASC");
+my @dns_queue = get_records_sql($hdb,"SELECT * FROM dns_queue WHERE auth_id=".$auth_id." AND value>'' AND value NOT LIKE '%.'ORDER BY id ASC");
 
 
 if (!@dns_queue or !scalar @dns_queue) { return; }
 if (!@dns_queue or !scalar @dns_queue) { return; }
 
 
@@ -443,7 +443,7 @@ if ($dns_cmd->{name_type}=~/^a$/i) {
         next;
         next;
         }
         }
     #get aliases
     #get aliases
-    my @aliases = get_records_sql($hdb,"SELECT * FROM User_auth_alias WHERE auth_id=".$auth_id);
+    my @aliases = get_records_sql($hdb,"SELECT * FROM user_auth_alias WHERE auth_id=".$auth_id);
     #remove A & PTR
     #remove A & PTR
     if ($dns_cmd->{type} eq 'del') {
     if ($dns_cmd->{type} eq 'del') {
         #remove aliases
         #remove aliases
@@ -660,7 +660,7 @@ if ($fqdn ne '' and !$dynamic_ok) {
 	    $hostname_filter = $hostname_filter . ' or LOWER(dns_name) REGEXP("^'.lc($auth_record->{dns_name}).'\.*$")';
 	    $hostname_filter = $hostname_filter . ' or LOWER(dns_name) REGEXP("^'.lc($auth_record->{dns_name}).'\.*$")';
 	    }
 	    }
     #check exists another records with some static hostname
     #check exists another records with some static hostname
-    my $filter_sql = 'SELECT * FROM User_auth WHERE id<>'.$auth_record->{id}.' and deleted=0 and ('.$hostname_filter.') ORDER BY last_found DESC';
+    my $filter_sql = 'SELECT * FROM user_auth WHERE id<>'.$auth_record->{id}.' and deleted=0 and ('.$hostname_filter.') ORDER BY last_found DESC';
     db_log_debug($hdb,"Search dhcp hostname by: ".$filter_sql);
     db_log_debug($hdb,"Search dhcp hostname by: ".$filter_sql);
     my $name_record = get_record_sql($hdb,$filter_sql);
     my $name_record = get_record_sql($hdb,$filter_sql);
     if ($name_record->{dns_name} =~/^$fqdn$/i or $name_record->{dns_name} =~/^$dhcp_record->{hostname_utf8}$/i) {
     if ($name_record->{dns_name} =~/^$fqdn$/i or $name_record->{dns_name} =~/^$dhcp_record->{hostname_utf8}$/i) {
@@ -676,7 +676,7 @@ if ($fqdn ne '' and !$dynamic_ok) {
                     } else {
                     } else {
         	    db_log_info($hdb,"Rewrite aliases if exists for $fqdn => $dhcp_record->{ip}");
         	    db_log_info($hdb,"Rewrite aliases if exists for $fqdn => $dhcp_record->{ip}");
                     #get and remove aliases
                     #get and remove aliases
-                    my @aliases = get_records_sql($hdb,"SELECT * FROM User_auth_alias WHERE auth_id=".$auth_record->{id});
+                    my @aliases = get_records_sql($hdb,"SELECT * FROM user_auth_alias WHERE auth_id=".$auth_record->{id});
                     if (@aliases and scalar @aliases) {
                     if (@aliases and scalar @aliases) {
                             foreach my $alias (@aliases) {
                             foreach my $alias (@aliases) {
                                 delete_dns_cname($fqdn_static,$alias->{alias},$ad_zone,$ad_dns,$hdb) if ($alias->{alias});
                                 delete_dns_cname($fqdn_static,$alias->{alias},$ad_zone,$ad_dns,$hdb) if ($alias->{alias});
@@ -705,7 +705,7 @@ sub apply_device_lock {
     my $iteration = shift || 0;
     my $iteration = shift || 0;
     $iteration++;
     $iteration++;
     if ($iteration>2) { return 0; }
     if ($iteration>2) { return 0; }
-    my $dev = get_record_sql($db,"SELECT `discovery_locked`, `locked_timestamp`, UNIX_TIMESTAMP(`locked_timestamp`) as u_locked_timestamp  FROM devices WHERE id=".$device_id);
+    my $dev = get_record_sql($db,"SELECT discovery_locked, locked_timestamp, UNIX_TIMESTAMP(locked_timestamp) as u_locked_timestamp  FROM devices WHERE id=".$device_id);
     if (!$dev) { return 0; }
     if (!$dev) { return 0; }
     if (!$dev->{'discovery_locked'}) { return set_lock_discovery($db,$device_id); }
     if (!$dev->{'discovery_locked'}) { return set_lock_discovery($db,$device_id); }
     #if timestamp undefined, set and return
     #if timestamp undefined, set and return
@@ -1020,7 +1020,7 @@ if ($user_info->{mac}) {
 if ($user_info->{dhcp_hostname}) { $user->{fio}=$user_info->{dhcp_hostname}; } 
 if ($user_info->{dhcp_hostname}) { $user->{fio}=$user_info->{dhcp_hostname}; } 
 if (!$user->{fio}) { $user->{fio}=$user_info->{ip}; }
 if (!$user->{fio}) { $user->{fio}=$user_info->{ip}; }
 
 
-my $login_count = get_count_records($db,"User_list","(login LIKE '".$user->{login}."(%)') OR (login='".$user->{login}."')");
+my $login_count = get_count_records($db,"user_list","(login LIKE '".$user->{login}."(%)') OR (login='".$user->{login}."')");
 if ($login_count) { $login_count++; $user->{login} .="(".$login_count.")"; }
 if ($login_count) { $login_count++; $user->{login} .="(".$login_count.")"; }
 
 
 $user->{ou_id} = $user_info->{ou_id};
 $user->{ou_id} = $user_info->{ou_id};
@@ -1031,7 +1031,7 @@ if ($ou_info) {
     $user->{'filter_group_id'} = $ou_info->{'filter_group_id'};
     $user->{'filter_group_id'} = $ou_info->{'filter_group_id'};
     }
     }
 
 
-my $result = insert_record($db,"User_list",$user);
+my $result = insert_record($db,"user_list",$user);
 if ($result and $config_ref{auto_mac_rule} and $user_info->{mac}) {
 if ($result and $config_ref{auto_mac_rule} and $user_info->{mac}) {
     my $auth_rule;
     my $auth_rule;
     $auth_rule->{user_id} = $result;
     $auth_rule->{user_id} = $result;
@@ -1049,7 +1049,7 @@ sub get_ip_subnet {
     my $ip = shift;
     my $ip = shift;
     if (!$ip) { return; }
     if (!$ip) { return; }
     my $ip_aton = StrToIp($ip);
     my $ip_aton = StrToIp($ip);
-    my $user_subnet = get_record_sql($db, "SELECT * FROM `subnets` WHERE hotspot=1 or office=1 and ( ".$ip_aton." >= ip_int_start and ".$ip_aton." <= ip_int_stop)");
+    my $user_subnet = get_record_sql($db, "SELECT * FROM subnets WHERE hotspot=1 or office=1 and ( ".$ip_aton." >= ip_int_start and ".$ip_aton." <= ip_int_stop)");
     return $user_subnet;
     return $user_subnet;
 }
 }
 
 
@@ -1062,7 +1062,7 @@ sub find_mac_in_subnet {
     if (!$ip or !$mac) { return; }
     if (!$ip or !$mac) { return; }
     my $ip_subnet = get_ip_subnet($db, $ip);
     my $ip_subnet = get_ip_subnet($db, $ip);
     if (!$ip_subnet) { return; }
     if (!$ip_subnet) { return; }
-    my @t_auth = get_records_sql($db, "SELECT * FROM User_auth WHERE ip_int>=" . $ip_subnet->{'ip_int_start'} . " and ip_int<=" . $ip_subnet->{'ip_int_stop'} . " and mac='" . $mac . "' and deleted=0 ORDER BY id");
+    my @t_auth = get_records_sql($db, "SELECT * FROM user_auth WHERE ip_int>=" . $ip_subnet->{'ip_int_start'} . " and ip_int<=" . $ip_subnet->{'ip_int_stop'} . " and mac='" . $mac . "' and deleted=0 ORDER BY id");
     my $auth_count = 0;
     my $auth_count = 0;
     my $result;
     my $result;
     $result->{'count'} = 0;
     $result->{'count'} = 0;
@@ -1085,7 +1085,7 @@ my $ip = $ip_record->{'ip'};
 my $mac = $ip_record->{'mac'};
 my $mac = $ip_record->{'mac'};
 my $action = $ip_record->{'type'};
 my $action = $ip_record->{'type'};
 my $hostname = $ip_record->{'hostname_utf8'};
 my $hostname = $ip_record->{'hostname_utf8'};
-my $client_id = $ip_record->{'client-id'};
+my $client_id = $ip_record->{client_id};
 
 
 if (!exists $ip_record->{ip_aton}) { $ip_record->{ip_aton}=StrToIp($ip); }
 if (!exists $ip_record->{ip_aton}) { $ip_record->{ip_aton}=StrToIp($ip); }
 if (!exists $ip_record->{hotspot}) { $ip_record->{hotspot}=is_hotspot($db,$ip); }
 if (!exists $ip_record->{hotspot}) { $ip_record->{hotspot}=is_hotspot($db,$ip); }
@@ -1098,13 +1098,13 @@ my $ip_aton=$ip_record->{ip_aton};
 
 
 my $timestamp=GetNowTime();
 my $timestamp=GetNowTime();
 
 
-my $record=get_record_sql($db,'SELECT * FROM User_auth WHERE `deleted`=0 AND `ip_int`='.$ip_aton.' AND `mac`="'.$mac.'"');
+my $record=get_record_sql($db,'SELECT * FROM user_auth WHERE deleted=0 AND ip_int='.$ip_aton.' AND mac="'.$mac.'"');
 
 
 my $new_record;
 my $new_record;
 $new_record->{last_found}=$timestamp;
 $new_record->{last_found}=$timestamp;
 $new_record->{arp_found}=$timestamp;
 $new_record->{arp_found}=$timestamp;
 
 
-if ($client_id) { $new_record->{'client-id'} = $client_id; }
+if ($client_id) { $new_record->{client_id} = $client_id; }
 
 
 #auth found?
 #auth found?
 if ($record->{user_id}) {
 if ($record->{user_id}) {
@@ -1115,7 +1115,7 @@ if ($record->{user_id}) {
 	    $new_record->{dhcp_time}=$timestamp;
 	    $new_record->{dhcp_time}=$timestamp;
 	    if ($hostname) { $new_record->{dhcp_hostname} = $hostname; }
 	    if ($hostname) { $new_record->{dhcp_hostname} = $hostname; }
 	    }
 	    }
-    update_record($db,'User_auth',$new_record,"id=$record->{id}");
+    update_record($db,'user_auth',$new_record,"id=$record->{id}");
     return $record->{id};
     return $record->{id};
     }
     }
 
 
@@ -1134,7 +1134,7 @@ my $mac_exists=find_mac_in_subnet($db,$ip,$mac);
 my $msg = '';
 my $msg = '';
 
 
 #search changed mac
 #search changed mac
-$record=get_record_sql($db,'SELECT * FROM User_auth WHERE `ip_int`='.$ip_aton." and deleted=0");
+$record=get_record_sql($db,'SELECT * FROM user_auth WHERE ip_int='.$ip_aton." and deleted=0");
 if ($record->{id}) {
 if ($record->{id}) {
     #if found record with same ip but without mac - update it
     #if found record with same ip but without mac - update it
     if (!$record->{mac}) {
     if (!$record->{mac}) {
@@ -1149,7 +1149,7 @@ if ($record->{id}) {
                 $new_record->{created_by}='dhcp';
                 $new_record->{created_by}='dhcp';
 	        if ($hostname) { $new_record->{dhcp_hostname} = $hostname; }
 	        if ($hostname) { $new_record->{dhcp_hostname} = $hostname; }
                 }
                 }
-        update_record($db,'User_auth',$new_record,"id=$record->{id}");
+        update_record($db,'user_auth',$new_record,"id=$record->{id}");
         sendEmail("WARN! ".get_first_line($msg),$msg,1) if ($send_alert_update);
         sendEmail("WARN! ".get_first_line($msg),$msg,1) if ($send_alert_update);
         return $record->{id};
         return $record->{id};
         }
         }
@@ -1189,7 +1189,7 @@ $mac_exists=find_mac_in_subnet($db,$ip,$mac);
 if ($mac_exists and $mac_exists->{'count'}) { $new_record->{dhcp}=0; }
 if ($mac_exists and $mac_exists->{'count'}) { $new_record->{dhcp}=0; }
 
 
 #seek old auth with same ip and mac
 #seek old auth with same ip and mac
-my $auth_exists=get_count_records($db,'User_auth',"ip_int=".$ip_aton." and mac='".$mac."'");
+my $auth_exists=get_count_records($db,'user_auth',"ip_int=".$ip_aton." and mac='".$mac."'");
 
 
 $new_record->{ip_int}=$ip_aton;
 $new_record->{ip_int}=$ip_aton;
 $new_record->{ip}=$ip;
 $new_record->{ip}=$ip;
@@ -1208,22 +1208,22 @@ if ($action=~/^(add|old|del)$/i) {
 my $cur_auth_id= 0;
 my $cur_auth_id= 0;
 if ($auth_exists) {
 if ($auth_exists) {
     #found ->Resurrection old record
     #found ->Resurrection old record
-    my $resurrection_id = get_id_record($db,'User_auth',"ip_int=".$ip_aton." and mac='".$mac."'");
+    my $resurrection_id = get_id_record($db,'user_auth',"ip_int=".$ip_aton." and mac='".$mac."'");
     $msg = $auth_ident . " Resurrection auth_id: $resurrection_id with ip: $ip and mac: $mac";
     $msg = $auth_ident . " Resurrection auth_id: $resurrection_id with ip: $ip and mac: $mac";
     if (!$ip_record->{hotspot}) { db_log_warning($db,$msg); } else { db_log_info($db,$msg); }
     if (!$ip_record->{hotspot}) { db_log_warning($db,$msg); } else { db_log_info($db,$msg); }
-    if (update_record($db,'User_auth',$new_record,"id=$resurrection_id")) { $cur_auth_id = $resurrection_id; }
+    if (update_record($db,'user_auth',$new_record,"id=$resurrection_id")) { $cur_auth_id = $resurrection_id; }
     } else {
     } else {
     #not found ->create new record
     #not found ->create new record
     $msg = $auth_ident ."\n";
     $msg = $auth_ident ."\n";
-    $cur_auth_id = insert_record($db,'User_auth',$new_record);
+    $cur_auth_id = insert_record($db,'user_auth',$new_record);
     if ($cur_auth_id) {
     if ($cur_auth_id) {
         if (!$ip_record->{hotspot}) { db_log_warning($db,$msg); } else { db_log_info($db,$msg); }
         if (!$ip_record->{hotspot}) { db_log_warning($db,$msg); } else { db_log_info($db,$msg); }
         }
         }
     }
     }
 #filter and status
 #filter and status
-$cur_auth_id=get_id_record($db,'User_auth',"ip='$ip' and mac='$mac' and deleted=0 ORDER BY last_found DESC") if (!$cur_auth_id);
+$cur_auth_id=get_id_record($db,'user_auth',"ip='$ip' and mac='$mac' and deleted=0 ORDER BY last_found DESC") if (!$cur_auth_id);
 if ($cur_auth_id) {
 if ($cur_auth_id) {
-    my $user_record=get_record_sql($db,"SELECT * FROM User_list WHERE id=".$new_user_id);
+    my $user_record=get_record_sql($db,"SELECT * FROM user_list WHERE id=".$new_user_id);
     if ($user_record) {
     if ($user_record) {
 	    my $ou_info = get_record_sql($db,'SELECT * FROM OU WHERE id='.$user_record->{ou_id});
 	    my $ou_info = get_record_sql($db,'SELECT * FROM OU WHERE id='.$user_record->{ou_id});
 	    if ($ou_info and $ou_info->{'dynamic'}) {
 	    if ($ou_info and $ou_info->{'dynamic'}) {
@@ -1246,10 +1246,10 @@ if ($cur_auth_id) {
 	    $new_record->{filter_group_id}=$user_record->{filter_group_id};
 	    $new_record->{filter_group_id}=$user_record->{filter_group_id};
 	    $new_record->{queue_id}=$user_record->{queue_id};
 	    $new_record->{queue_id}=$user_record->{queue_id};
 	    $new_record->{enabled}="$user_record->{enabled}";
 	    $new_record->{enabled}="$user_record->{enabled}";
-            update_record($db,'User_auth',$new_record,"id=$cur_auth_id");
+            update_record($db,'user_auth',$new_record,"id=$cur_auth_id");
 	    }
 	    }
     db_log_warning($db, $msg, $cur_auth_id);
     db_log_warning($db, $msg, $cur_auth_id);
-    sendEmail("WARN! ".get_first_line($msg),$msg."\n".record_to_txt($db,'User_auth',$cur_auth_id),1) if ($send_alert_create);
+    sendEmail("WARN! ".get_first_line($msg),$msg."\n".record_to_txt($db,'user_auth',$cur_auth_id),1) if ($send_alert_create);
     } else { return; }
     } else { return; }
 return $cur_auth_id;
 return $cur_auth_id;
 }
 }
@@ -1260,7 +1260,7 @@ sub new_auth {
 my $db = shift;
 my $db = shift;
 my $ip = shift;
 my $ip = shift;
 my $ip_aton=StrToIp($ip);
 my $ip_aton=StrToIp($ip);
-my $record=get_record_sql($db,'SELECT id FROM User_auth WHERE `deleted`=0 AND `ip_int`='.$ip_aton);
+my $record=get_record_sql($db,'SELECT id FROM user_auth WHERE deleted=0 AND ip_int='.$ip_aton);
 if ($record->{id}) { return $record->{id}; }
 if ($record->{id}) { return $record->{id}; }
 #default user
 #default user
 my $new_user_info=get_new_user_id($db,$ip,undef,undef);
 my $new_user_info=get_new_user_id($db,$ip,undef,undef);
@@ -1274,7 +1274,7 @@ if (is_dynamic_ou($db,$new_user_info->{ou_id})) {
     }
     }
 
 
 my $send_alert = isNotifyCreate(get_notify_subnet($db,$ip));
 my $send_alert = isNotifyCreate(get_notify_subnet($db,$ip));
-my $user_record=get_record_sql($db,"SELECT * FROM User_list WHERE id=".$new_user_id);
+my $user_record=get_record_sql($db,"SELECT * FROM user_list WHERE id=".$new_user_id);
 my $timestamp=GetNowTime();
 my $timestamp=GetNowTime();
 my $new_record;
 my $new_record;
 $new_record->{ip_int}=$ip_aton;
 $new_record->{ip_int}=$ip_aton;
@@ -1289,7 +1289,7 @@ $new_record->{queue_id}=$user_record->{queue_id};
 $new_record->{enabled}="$user_record->{enabled}";
 $new_record->{enabled}="$user_record->{enabled}";
 if ($user_record->{fio}) { $new_record->{comments}=$user_record->{fio}; }
 if ($user_record->{fio}) { $new_record->{comments}=$user_record->{fio}; }
 
 
-my $cur_auth_id=insert_record($db,'User_auth',$new_record);
+my $cur_auth_id=insert_record($db,'user_auth',$new_record);
 if ($cur_auth_id) {
 if ($cur_auth_id) {
     my $msg = "New ip created by netflow! ip: $ip";
     my $msg = "New ip created by netflow! ip: $ip";
     db_log_warning($db,$msg,$cur_auth_id);
     db_log_warning($db,$msg,$cur_auth_id);
@@ -1363,7 +1363,7 @@ my $db = shift;
 my $ip = shift;
 my $ip = shift;
 my $netdev=get_record_sql($db,'SELECT * FROM devices WHERE ip="'.$ip.'"');
 my $netdev=get_record_sql($db,'SELECT * FROM devices WHERE ip="'.$ip.'"');
 if ($netdev and $netdev->{id}>0) { return $netdev; }
 if ($netdev and $netdev->{id}>0) { return $netdev; }
-my $auth_rec=get_record_sql($db,'SELECT user_id FROM User_auth WHERE ip="'.$ip.'" and deleted=0');
+my $auth_rec=get_record_sql($db,'SELECT user_id FROM user_auth WHERE ip="'.$ip.'" and deleted=0');
 if ($auth_rec and $auth_rec->{user_id}>0) {
 if ($auth_rec and $auth_rec->{user_id}>0) {
     $netdev=get_record_sql($db,'SELECT * FROM devices WHERE user_id='.$auth_rec->{user_id});
     $netdev=get_record_sql($db,'SELECT * FROM devices WHERE user_id='.$auth_rec->{user_id});
     return $netdev;
     return $netdev;
@@ -1402,7 +1402,7 @@ $next_month->set(day=>1);
 my $month_stop = $db->quote($next_month->ymd("-")." 00:00:00");
 my $month_stop = $db->quote($next_month->ymd("-")." 00:00:00");
 
 
 #get user limits
 #get user limits
-my $user_auth_list_sql="SELECT A.id as auth_id, U.id, U.day_quota, U.month_quota, A.day_quota as auth_day, A.month_quota as auth_month FROM User_auth as A,User_list as U WHERE A.deleted=0 ORDER by user_id";
+my $user_auth_list_sql="SELECT A.id as auth_id, U.id, U.day_quota, U.month_quota, A.day_quota as auth_day, A.month_quota as auth_month FROM user_auth as A,user_list as U WHERE A.deleted=0 ORDER by user_id";
 my @authlist_ref = get_records_sql($db,$user_auth_list_sql);
 my @authlist_ref = get_records_sql($db,$user_auth_list_sql);
 my %user_stats;
 my %user_stats;
 my %auth_info;
 my %auth_info;
@@ -1420,8 +1420,8 @@ foreach my $row (@authlist_ref) {
 
 
 #recalc quotes - global
 #recalc quotes - global
 #day
 #day
-my $day_sql="SELECT User_stats.auth_id, SUM( byte_in + byte_out ) AS traf_all FROM User_stats
-WHERE User_stats.`timestamp`>= $day_start AND User_stats.`timestamp`< $day_stop GROUP BY User_stats.auth_id";
+my $day_sql="SELECT user_stats.auth_id, SUM( byte_in + byte_out ) AS traf_all FROM user_stats
+WHERE user_stats.ts>= $day_start AND user_stats.ts< $day_stop GROUP BY user_stats.auth_id";
 my @day_stats = get_records_sql($db,$day_sql);
 my @day_stats = get_records_sql($db,$day_sql);
 foreach my $row (@day_stats) {
 foreach my $row (@day_stats) {
     my $user_id=$auth_info{$row->{auth_id}}{user_id};
     my $user_id=$auth_info{$row->{auth_id}}{user_id};
@@ -1430,8 +1430,8 @@ foreach my $row (@day_stats) {
 }
 }
 
 
 #month
 #month
-my $month_sql="SELECT User_stats.auth_id, SUM( byte_in + byte_out ) AS traf_all FROM User_stats
-WHERE User_stats.`timestamp`>= $month_start AND User_stats.`timestamp`< $month_stop GROUP BY User_stats.auth_id";
+my $month_sql="SELECT user_stats.auth_id, SUM( byte_in + byte_out ) AS traf_all FROM user_stats
+WHERE user_stats.ts>= $month_start AND user_stats.ts< $month_stop GROUP BY user_stats.auth_id";
 my @month_stats = get_records_sql($db,$month_sql);
 my @month_stats = get_records_sql($db,$month_sql);
 foreach my $row (@month_stats) {
 foreach my $row (@month_stats) {
     my $user_id=$auth_info{$row->{auth_id}}{user_id};
     my $user_id=$auth_info{$row->{auth_id}}{user_id};
@@ -1450,7 +1450,7 @@ if ($blocked_d or $blocked_m) {
     my $history_msg;
     my $history_msg;
     if ($blocked_d) { $history_msg=printf "Day quota limit found for auth_id: $auth_id - Current: %d Max: %d",$auth_info{$auth_id}{day},$day_limit; }
     if ($blocked_d) { $history_msg=printf "Day quota limit found for auth_id: $auth_id - Current: %d Max: %d",$auth_info{$auth_id}{day},$day_limit; }
     if ($blocked_m) { $history_msg=printf "Month quota limit found for auth_id: $auth_id - Current: %d Max: %d",$auth_info{$auth_id}{month},$month_limit; }
     if ($blocked_m) { $history_msg=printf "Month quota limit found for auth_id: $auth_id - Current: %d Max: %d",$auth_info{$auth_id}{month},$month_limit; }
-    do_sql($db,"UPDATE User_auth set blocked=1, changed=1 where id=$auth_id");
+    do_sql($db,"UPDATE user_auth set blocked=1, changed=1 where id=$auth_id");
     db_log_verbose($db,$history_msg);
     db_log_verbose($db,$history_msg);
     }
     }
 }
 }
@@ -1467,7 +1467,7 @@ if ($blocked_d or $blocked_m) {
     if ($blocked_d) { $history_msg=printf "Day quota limit found for user_id: $user_id - Current: %d Max: %d",$user_stats{$user_id}{day},$day_limit; }
     if ($blocked_d) { $history_msg=printf "Day quota limit found for user_id: $user_id - Current: %d Max: %d",$user_stats{$user_id}{day},$day_limit; }
     if ($blocked_m) { $history_msg=printf "Month quota limit found for user_id: $user_id - Current: %d Max: %d",$user_stats{$user_id}{month},$month_limit; }
     if ($blocked_m) { $history_msg=printf "Month quota limit found for user_id: $user_id - Current: %d Max: %d",$user_stats{$user_id}{month},$month_limit; }
     do_sql($db,"UPDATE User_user set blocked=1 where id=$user_id");
     do_sql($db,"UPDATE User_user set blocked=1 where id=$user_id");
-    do_sql($db,"UPDATE User_auth set blocked=1, changed=1 where user_id=$user_id");
+    do_sql($db,"UPDATE user_auth set blocked=1, changed=1 where user_id=$user_id");
     db_log_verbose($db,$history_msg);
     db_log_verbose($db,$history_msg);
     }
     }
 }
 }
@@ -1513,13 +1513,13 @@ $dhcp_record->{'type'}=$type;
 $dhcp_record->{'hostname_utf8'}=$client_hostname;
 $dhcp_record->{'hostname_utf8'}=$client_hostname;
 $dhcp_record->{'timestamp'} = $timestamp;
 $dhcp_record->{'timestamp'} = $timestamp;
 $dhcp_record->{'last_time'} = time();
 $dhcp_record->{'last_time'} = time();
-$dhcp_record->{'circuit-id'} = $circuit_id;
-$dhcp_record->{'client-id'} = $client_id;
-$dhcp_record->{'remote-id'} = $remote_id;
+$dhcp_record->{circuit_id} = $circuit_id;
+$dhcp_record->{client_id} = $client_id;
+$dhcp_record->{remote_id} = $remote_id;
 $dhcp_record->{'hotspot'}=is_hotspot($dbh,$dhcp_record->{ip});
 $dhcp_record->{'hotspot'}=is_hotspot($dbh,$dhcp_record->{ip});
 
 
 #search actual record
 #search actual record
-my $auth_record = get_record_sql($db,'SELECT * FROM User_auth WHERE ip="'.$dhcp_record->{ip}.'" and mac="'.$mac.'" and deleted=0 ORDER BY last_found DESC');
+my $auth_record = get_record_sql($db,'SELECT * FROM user_auth WHERE ip="'.$dhcp_record->{ip}.'" and mac="'.$mac.'" and deleted=0 ORDER BY last_found DESC');
 
 
 #if record not found and type del => next event
 #if record not found and type del => next event
 if (!$auth_record and $type eq 'del') { return; }
 if (!$auth_record and $type eq 'del') { return; }
@@ -1529,7 +1529,7 @@ if (!$auth_record and $type=~/(add|old)/i) {
 #        db_log_warning($db,"Record for dhcp request type: ".$type." ip=".$dhcp_record->{ip}." and mac=".$mac." does not exists!");
 #        db_log_warning($db,"Record for dhcp request type: ".$type." ip=".$dhcp_record->{ip}." and mac=".$mac." does not exists!");
         my $res_id = resurrection_auth($db,$dhcp_record);
         my $res_id = resurrection_auth($db,$dhcp_record);
         if (!$res_id) {  db_log_error($db,"Error creating an ip address record for ip=".$dhcp_record->{ip}." and mac=".$mac."!");  return; }
         if (!$res_id) {  db_log_error($db,"Error creating an ip address record for ip=".$dhcp_record->{ip}." and mac=".$mac."!");  return; }
-        $auth_record = get_record_sql($db,'SELECT * FROM User_auth WHERE id='.$res_id);
+        $auth_record = get_record_sql($db,'SELECT * FROM user_auth WHERE id='.$res_id);
         db_log_info($db,"Check for new auth. Found id: $res_id",$res_id);
         db_log_info($db,"Check for new auth. Found id: $res_id",$res_id);
         }
         }
 
 
@@ -1542,8 +1542,8 @@ $dhcp_record->{'auth_ou_id'} = $auth_ou_id;
 log_debug(uc($type).">>");
 log_debug(uc($type).">>");
 log_debug("MAC:        ".$dhcp_record->{'mac'});
 log_debug("MAC:        ".$dhcp_record->{'mac'});
 log_debug("IP:         ".$dhcp_record->{'ip'});
 log_debug("IP:         ".$dhcp_record->{'ip'});
-log_debug("CIRCUIT-ID: ".$dhcp_record->{'circuit-id'});
-log_debug("REMOTE-ID:  ".$dhcp_record->{'remote-id'});
+log_debug("CIRCUIT-ID: ".$dhcp_record->{circuit_id});
+log_debug("REMOTE-ID:  ".$dhcp_record->{remote_id});
 log_debug("HOSTNAME:   ".$dhcp_record->{'hostname'});
 log_debug("HOSTNAME:   ".$dhcp_record->{'hostname'});
 log_debug("TYPE:       ".$dhcp_record->{'type'});
 log_debug("TYPE:       ".$dhcp_record->{'type'});
 log_debug("TIME:       ".$dhcp_event_time);
 log_debug("TIME:       ".$dhcp_event_time);
@@ -1559,7 +1559,7 @@ if ($type=~/add/i and $dhcp_record->{hostname_utf8}) {
                 $auth_rec->{arp_found}=$dhcp_event_time;
                 $auth_rec->{arp_found}=$dhcp_event_time;
                 $auth_rec->{created_by}='dhcp';
                 $auth_rec->{created_by}='dhcp';
                 db_log_verbose($db,"Add lease by dhcp event for dynamic clients id: $auth_id ip: $dhcp_record->{ip}",$auth_id);
                 db_log_verbose($db,"Add lease by dhcp event for dynamic clients id: $auth_id ip: $dhcp_record->{ip}",$auth_id);
-                update_record($db,'User_auth',$auth_rec,"id=$auth_id");
+                update_record($db,'user_auth',$auth_rec,"id=$auth_id");
                 }
                 }
 
 
 if ($type=~/old/i) {
 if ($type=~/old/i) {
@@ -1569,7 +1569,7 @@ if ($type=~/old/i) {
                 $auth_rec->{created_by}='dhcp';
                 $auth_rec->{created_by}='dhcp';
                 $auth_rec->{arp_found}=$dhcp_event_time;
                 $auth_rec->{arp_found}=$dhcp_event_time;
                 db_log_verbose($db,"Update lease by dhcp event for dynamic clients id: $auth_id ip: $dhcp_record->{ip}",$auth_id);
                 db_log_verbose($db,"Update lease by dhcp event for dynamic clients id: $auth_id ip: $dhcp_record->{ip}",$auth_id);
-                update_record($db,'User_auth',$auth_rec,"id=$auth_id");
+                update_record($db,'user_auth',$auth_rec,"id=$auth_id");
                 }
                 }
 
 
 if ($type=~/del/i and $auth_id) {
 if ($type=~/del/i and $auth_id) {
@@ -1580,11 +1580,11 @@ if ($type=~/del/i and $auth_id) {
                         my $auth_rec;
                         my $auth_rec;
                         $auth_rec->{dhcp_action}=$type;
                         $auth_rec->{dhcp_action}=$type;
                         $auth_rec->{dhcp_time}=$dhcp_event_time;
                         $auth_rec->{dhcp_time}=$dhcp_event_time;
-                        update_record($db,'User_auth',$auth_rec,"id=$auth_id");
+                        update_record($db,'user_auth',$auth_rec,"id=$auth_id");
                         #remove user auth record if it belongs to the default pool or it is dynamic
                         #remove user auth record if it belongs to the default pool or it is dynamic
                         if (is_default_ou($db,$auth_ou_id) or (is_dynamic_ou($db,$auth_ou_id) and $auth_record->{dynamic})) {
                         if (is_default_ou($db,$auth_ou_id) or (is_dynamic_ou($db,$auth_ou_id) and $auth_record->{dynamic})) {
                                 delete_user_auth($db,$auth_id);
                                 delete_user_auth($db,$auth_id);
-                                my $u_count=get_count_records($db,'User_auth','deleted=0 and user_id='.$auth_record->{'user_id'});
+                                my $u_count=get_count_records($db,'user_auth','deleted=0 and user_id='.$auth_record->{'user_id'});
                                 if (!$u_count) { delete_user($db,$auth_record->{'user_id'}); }
                                 if (!$u_count) { delete_user($db,$auth_record->{'user_id'}); }
                                 }
                                 }
                         }
                         }
@@ -1604,9 +1604,9 @@ $dhcp_log->{'mac'} = $dhcp_record->{'mac'};
 $dhcp_log->{'action'} = $type;
 $dhcp_log->{'action'} = $type;
 $dhcp_log->{'dhcp_hostname'} = $dhcp_record->{'hostname_utf8'};
 $dhcp_log->{'dhcp_hostname'} = $dhcp_record->{'hostname_utf8'};
 $dhcp_log->{'timestamp'} = $dhcp_event_time;
 $dhcp_log->{'timestamp'} = $dhcp_event_time;
-$dhcp_log->{'circuit-id'} = $circuit_id;
-$dhcp_log->{'client-id'} = $client_id;
-$dhcp_log->{'remote-id'} = $remote_id;
+$dhcp_log->{circuit_id} = $circuit_id;
+$dhcp_log->{client_id} = $client_id;
+$dhcp_log->{remote_id} = $remote_id;
 
 
 insert_record($db,'dhcp_log',$dhcp_log);
 insert_record($db,'dhcp_log',$dhcp_log);
 
 

+ 15 - 16
scripts/eyelib/database.pm

@@ -274,7 +274,7 @@ if ($level eq $L_VERBOSE and $log_level >= $L_VERBOSE) { log_verbose($msg); $db_
 if ($level eq $L_DEBUG and $log_level >= $L_DEBUG) { log_debug($msg); return; }
 if ($level eq $L_DEBUG and $log_level >= $L_DEBUG) { log_debug($msg); return; }
 
 
 if ($db_log) {
 if ($db_log) {
-#my $new_id = do_sql($dbh, 'INSERT INTO User_list (login) VALUES (?)', 'Ivan');
+#my $new_id = do_sql($dbh, 'INSERT INTO user_list (login) VALUES (?)', 'Ivan');
 do_sql($db,'INSERT INTO worklog(customer,message,level,auth_id,ip) VALUES( ?, ?, ?, ?, ?)',$MY_NAME,$msg,$level,$auth_id,$config_ref{self_ip});
 do_sql($db,'INSERT INTO worklog(customer,message,level,auth_id,ip) VALUES( ?, ?, ?, ?, ?)',$MY_NAME,$msg,$level,$auth_id,$config_ref{self_ip});
 }
 }
 }
 }
@@ -560,7 +560,6 @@ sub get_option_safe {
     return if (!$option_id);
     return if (!$option_id);
     return if (!$db);
     return if (!$db);
     
     
-    # Один безопасный запрос вместо двух
     my $sql = q{
     my $sql = q{
         SELECT 
         SELECT 
             COALESCE(c.value, co.default_value) as value,
             COALESCE(c.value, co.default_value) as value,
@@ -712,7 +711,7 @@ my $found_changed=0;
 my $rec_id = 0;
 my $rec_id = 0;
 my $dns_changed = 0;
 my $dns_changed = 0;
 
 
-if ($table eq "User_auth") {
+if ($table eq "user_auth") {
 $rec_id = $old_record->{'id'} if ($old_record->{'id'});
 $rec_id = $old_record->{'id'} if ($old_record->{'id'});
 #disable update field 'created_by'
 #disable update field 'created_by'
 if ($old_record->{'created_by'} and exists ($record->{'created_by'})) { delete $record->{'created_by'}; }
 if ($old_record->{'created_by'} and exists ($record->{'created_by'})) { delete $record->{'created_by'}; }
@@ -734,7 +733,7 @@ if ($new_value!~/^$old_value$/) {
 $diff = $diff." $field => $record->{$field} (old: $old_record->{$field}),";
 $diff = $diff." $field => $record->{$field} (old: $old_record->{$field}),";
 # Разные методы экранирования для разных БД
 # Разные методы экранирования для разных БД
 if ($config_ref{DBTYPE} eq 'mysql') {
 if ($config_ref{DBTYPE} eq 'mysql') {
-$change_str = $change_str." `$field`=".$db->quote($record->{$field}).",";
+$change_str = $change_str." $field=".$db->quote($record->{$field}).",";
 } else {
 } else {
 $change_str = $change_str." \"$field\"=".$db->quote($record->{$field}).",";
 $change_str = $change_str." \"$field\"=".$db->quote($record->{$field}).",";
 }
 }
@@ -745,7 +744,7 @@ $found_changed++;
 if ($found_changed) {
 if ($found_changed) {
 $change_str=~s/\,$//;
 $change_str=~s/\,$//;
 $diff=~s/\,$//;
 $diff=~s/\,$//;
-if ($table eq 'User_auth') {
+if ($table eq 'user_auth') {
 $change_str .= ", changed_time='".GetNowTime()."'";
 $change_str .= ", changed_time='".GetNowTime()."'";
 if ($dns_changed) {
 if ($dns_changed) {
 my $del_dns;
 my $del_dns;
@@ -788,7 +787,7 @@ insert_record($db,'dns_queue',$new_dns);
 }
 }
 }
 }
 }
 }
-if ($table eq 'User_auth_alias') {
+if ($table eq 'user_auth_alias') {
 if ($dns_changed) {
 if ($dns_changed) {
 my $del_dns;
 my $del_dns;
 if ($old_record->{'alias'} and $old_record->{'alias'}!~/\.$/) {
 if ($old_record->{'alias'} and $old_record->{'alias'}!~/\.$/) {
@@ -841,7 +840,7 @@ log_error("No database connection available");
 return;
 return;
 }
 }
 
 
-if ($table eq "User_auth") {
+if ($table eq "user_auth") {
 foreach my $field (keys %$record) {
 foreach my $field (keys %$record) {
 if (exists $acl_fields{$field}) { $record->{changed}="1"; }
 if (exists $acl_fields{$field}) { $record->{changed}="1"; }
 if (exists $dhcp_fields{$field}) { $record->{dhcp_changed}="1"; }
 if (exists $dhcp_fields{$field}) { $record->{dhcp_changed}="1"; }
@@ -857,7 +856,7 @@ $new_value=~s/\"//g;
 $record->{$field} = $new_value;
 $record->{$field} = $new_value;
 # Разные методы экранирования имен полей для разных БД
 # Разные методы экранирования имен полей для разных БД
 if ($config_ref{DBTYPE} eq 'mysql') {
 if ($config_ref{DBTYPE} eq 'mysql') {
-$fields = $fields."`$field`,";
+$fields = $fields."$field,";
 } else {
 } else {
 $fields = $fields."\"$field\",";
 $fields = $fields."\"$field\",";
 }
 }
@@ -872,9 +871,9 @@ $new_str=~s/,$//;
 my $sSQL = "INSERT INTO $table($fields) VALUES($values)";
 my $sSQL = "INSERT INTO $table($fields) VALUES($values)";
 my $result = do_sql($db,$sSQL);
 my $result = do_sql($db,$sSQL);
 if ($result) {
 if ($result) {
-$rec_id = $result if ($table eq "User_auth");
+$rec_id = $result if ($table eq "user_auth");
 $new_str='id: '.$result.' '.$new_str;
 $new_str='id: '.$result.' '.$new_str;
-if ($table eq 'User_auth_alias' and $dns_changed) {
+if ($table eq 'user_auth_alias' and $dns_changed) {
 if ($record->{'alias'} and $record->{'alias'}!~/\.$/) {
 if ($record->{'alias'} and $record->{'alias'}!~/\.$/) {
 my $add_dns;
 my $add_dns;
 $add_dns->{'name_type'}='CNAME';
 $add_dns->{'name_type'}='CNAME';
@@ -885,7 +884,7 @@ $add_dns->{'auth_id'}=$record->{'auth_id'};
 insert_record($db,'dns_queue',$add_dns);
 insert_record($db,'dns_queue',$add_dns);
 }
 }
 }
 }
-if ($table eq 'User_auth' and $dns_changed) {
+if ($table eq 'user_auth' and $dns_changed) {
 if ($record->{'dns_name'} and $record->{'ip'} and $dns_changed and !$record->{'dns_ptr_only'} and $record->{'dns_name'}!~/\.$/) {
 if ($record->{'dns_name'} and $record->{'ip'} and $dns_changed and !$record->{'dns_ptr_only'} and $record->{'dns_name'}!~/\.$/) {
 my $add_dns;
 my $add_dns;
 $add_dns->{'name_type'}='A';
 $add_dns->{'name_type'}='A';
@@ -936,14 +935,14 @@ $diff = $diff." $field => $old_record->{$field},";
 }
 }
 $diff=~s/,$//;
 $diff=~s/,$//;
 
 
-if ($table eq 'User_auth') {
+if ($table eq 'user_auth') {
 $rec_id = $old_record->{'id'} if ($old_record->{'id'});
 $rec_id = $old_record->{'id'} if ($old_record->{'id'});
 }
 }
 
 
 db_log_debug($db,'Delete record from table  '.$table.' value: '.$diff, $rec_id);
 db_log_debug($db,'Delete record from table  '.$table.' value: '.$diff, $rec_id);
 #never delete user ip record!
 #never delete user ip record!
-if ($table eq 'User_auth') {
-my $sSQL = "UPDATE User_auth SET changed=1, deleted=1, changed_time='".GetNowTime()."' WHERE ".$filter;
+if ($table eq 'user_auth') {
+my $sSQL = "UPDATE user_auth SET changed=1, deleted=1, changed_time='".GetNowTime()."' WHERE ".$filter;
 my $ret = do_sql($db,$sSQL);
 my $ret = do_sql($db,$sSQL);
 if ($old_record->{'dns_name'} and $old_record->{'ip'} and !$old_record->{'dns_ptr_only'} and $old_record->{'dns_name'}!~/\.$/) {
 if ($old_record->{'dns_name'} and $old_record->{'ip'} and !$old_record->{'dns_ptr_only'} and $old_record->{'dns_name'}!~/\.$/) {
 my $del_dns;
 my $del_dns;
@@ -966,9 +965,9 @@ insert_record($db,'dns_queue',$del_dns);
 return $ret;
 return $ret;
 }
 }
 
 
-if ($table eq 'User_list' and $old_record->{'permanent'}) { return; }
+if ($table eq 'user_list' and $old_record->{'permanent'}) { return; }
 
 
-if ($table eq 'User_auth_alias') {
+if ($table eq 'user_auth_alias') {
 if ($old_record->{'alias'} and $old_record->{'auth_id'} and $old_record->{'alias'}!~/\.$/) {
 if ($old_record->{'alias'} and $old_record->{'auth_id'} and $old_record->{'alias'}!~/\.$/) {
 my $del_dns;
 my $del_dns;
 $del_dns->{'name_type'}='CNAME';
 $del_dns->{'name_type'}='CNAME';

+ 15 - 15
scripts/fetch_new_arp.pl

@@ -46,7 +46,7 @@ if ($config_ref{config_mode}) {
 db_log_verbose($dbh, 'Clearing empty records.');
 db_log_verbose($dbh, 'Clearing empty records.');
 
 
 log_info($dbh, 'Clearing empty user accounts and associated devices for dynamic users and hotspot');
 log_info($dbh, 'Clearing empty user accounts and associated devices for dynamic users and hotspot');
-my $u_sql = "SELECT * FROM User_list AS U WHERE (U.ou_id = " . $default_hotspot_ou_id . " OR U.ou_id = " . $default_user_ou_id . ") AND (SELECT COUNT(*) FROM User_auth WHERE User_auth.deleted = 0 AND User_auth.user_id = U.id) = 0";
+my $u_sql = "SELECT * FROM user_list AS U WHERE (U.ou_id = " . $default_hotspot_ou_id . " OR U.ou_id = " . $default_user_ou_id . ") AND (SELECT COUNT(*) FROM user_auth WHERE user_auth.deleted = 0 AND user_auth.user_id = U.id) = 0";
 my @u_ref = get_records_sql($dbh, $u_sql);
 my @u_ref = get_records_sql($dbh, $u_sql);
 foreach my $row (@u_ref) {
 foreach my $row (@u_ref) {
     db_log_info($dbh, "Remove empty dynamic user with id: $row->{id} login: $row->{login}");
     db_log_info($dbh, "Remove empty dynamic user with id: $row->{id} login: $row->{login}");
@@ -56,7 +56,7 @@ foreach my $row (@u_ref) {
 # Clean up empty non-permanent user accounts that have no authentications or auth rules
 # Clean up empty non-permanent user accounts that have no authentications or auth rules
 #if ($config_ref{clean_empty_user}) {
 #if ($config_ref{clean_empty_user}) {
 #    log_info($dbh, 'Clearing empty non-permanent user accounts and associated devices');
 #    log_info($dbh, 'Clearing empty non-permanent user accounts and associated devices');
-#    my $u_sql = "SELECT * FROM User_list AS U WHERE U.permanent = 0 AND (SELECT COUNT(*) FROM User_auth WHERE User_auth.deleted = 0 AND User_auth.user_id = U.id) = 0 AND (SELECT COUNT(*) FROM auth_rules WHERE auth_rules.user_id = U.id) = 0;";
+#    my $u_sql = "SELECT * FROM user_list AS U WHERE U.permanent = 0 AND (SELECT COUNT(*) FROM user_auth WHERE user_auth.deleted = 0 AND user_auth.user_id = U.id) = 0 AND (SELECT COUNT(*) FROM auth_rules WHERE auth_rules.user_id = U.id) = 0;";
 #    my @u_ref = get_records_sql($dbh, $u_sql);
 #    my @u_ref = get_records_sql($dbh, $u_sql);
 #    foreach my $row (@u_ref) {
 #    foreach my $row (@u_ref) {
 #        db_log_info($dbh, "Remove empty user with id: $row->{id} login: $row->{login}");
 #        db_log_info($dbh, "Remove empty user with id: $row->{id} login: $row->{login}");
@@ -67,13 +67,13 @@ foreach my $row (@u_ref) {
 # Clean temporary (dynamic) user authentication records that have expired
 # Clean temporary (dynamic) user authentication records that have expired
 my $now = DateTime->now(time_zone => 'local');
 my $now = DateTime->now(time_zone => 'local');
 my $clear_time = $dbh->quote($now->strftime('%Y-%m-%d %H:%M:%S'));
 my $clear_time = $dbh->quote($now->strftime('%Y-%m-%d %H:%M:%S'));
-my $users_sql = "SELECT * FROM User_auth WHERE deleted = 0 AND dynamic = 1 AND `eof` <= " . $clear_time;
+my $users_sql = "SELECT * FROM user_auth WHERE deleted = 0 AND dynamic = 1 AND eof <= " . $clear_time;
 my @users_auth = get_records_sql($dbh, $users_sql);
 my @users_auth = get_records_sql($dbh, $users_sql);
 if (@users_auth and scalar @users_auth) {
 if (@users_auth and scalar @users_auth) {
     foreach my $row (@users_auth) {
     foreach my $row (@users_auth) {
         delete_user_auth($dbh, $row->{id});
         delete_user_auth($dbh, $row->{id});
         db_log_info($dbh, "Removed dynamic user auth record for auth_id: $row->{'id'} by eof time: $row->{'eof'}", $row->{'id'});
         db_log_info($dbh, "Removed dynamic user auth record for auth_id: $row->{'id'} by eof time: $row->{'eof'}", $row->{'id'});
-        my $u_count = get_count_records($dbh, 'User_auth', 'deleted = 0 AND user_id = ' . $row->{user_id});
+        my $u_count = get_count_records($dbh, 'user_auth', 'deleted = 0 AND user_id = ' . $row->{user_id});
         if (!$u_count) {
         if (!$u_count) {
             delete_user($dbh, $row->{'user_id'});
             delete_user($dbh, $row->{'user_id'});
         }
         }
@@ -167,7 +167,7 @@ $pm_arp->wait_all_children;
 $dbh = init_db();
 $dbh = init_db();
 
 
 # Load all active user authentications indexed by IP
 # Load all active user authentications indexed by IP
-my @authlist_ref = get_records_sql($dbh, "SELECT * FROM User_auth WHERE deleted = 0 ORDER BY ip_int");
+my @authlist_ref = get_records_sql($dbh, "SELECT * FROM user_auth WHERE deleted = 0 ORDER BY ip_int");
 
 
 my $users = Net::Patricia->new;
 my $users = Net::Patricia->new;
 my %ip_list;
 my %ip_list;
@@ -243,7 +243,7 @@ foreach my $connection (@connections_list) {
 
 
 # Build operational and full MAC-to-auth lookup tables
 # Build operational and full MAC-to-auth lookup tables
 my $auth_filter = " AND last_found >= '" . $now_day . "' ";
 my $auth_filter = " AND last_found >= '" . $now_day . "' ";
-my $auth_sql = "SELECT id, mac FROM User_auth WHERE mac IS NOT NULL AND deleted = 0 $auth_filter ORDER BY id ASC";
+my $auth_sql = "SELECT id, mac FROM user_auth WHERE mac IS NOT NULL AND deleted = 0 $auth_filter ORDER BY id ASC";
 my @auth_list = get_records_sql($dbh, $auth_sql);
 my @auth_list = get_records_sql($dbh, $auth_sql);
 
 
 my %auth_table;
 my %auth_table;
@@ -253,7 +253,7 @@ foreach my $auth (@auth_list) {
     $auth_table{oper_table}{$auth_mac} = $auth->{id};
     $auth_table{oper_table}{$auth_mac} = $auth->{id};
 }
 }
 
 
-$auth_sql = "SELECT id, mac FROM User_auth WHERE mac IS NOT NULL AND deleted = 0 ORDER BY last_found DESC";
+$auth_sql = "SELECT id, mac FROM user_auth WHERE mac IS NOT NULL AND deleted = 0 ORDER BY last_found DESC";
 my @auth_full_list = get_records_sql($dbh, $auth_sql);
 my @auth_full_list = get_records_sql($dbh, $auth_sql);
 foreach my $auth (@auth_full_list) {
 foreach my $auth (@auth_full_list) {
     next if (!$auth);
     next if (!$auth);
@@ -263,7 +263,7 @@ foreach my $auth (@auth_full_list) {
 }
 }
 
 
 # Load unknown MAC addresses from the database
 # Load unknown MAC addresses from the database
-my @unknown_list = get_records_sql($dbh, "SELECT id, mac, port_id, device_id FROM Unknown_mac WHERE mac != '' ORDER BY mac");
+my @unknown_list = get_records_sql($dbh, "SELECT id, mac, port_id, device_id FROM unknown_mac WHERE mac != '' ORDER BY mac");
 my %unknown_table;
 my %unknown_table;
 foreach my $unknown (@unknown_list) {
 foreach my $unknown (@unknown_list) {
     next if (!$unknown);
     next if (!$unknown);
@@ -373,7 +373,7 @@ foreach my $device (@device_list) {
     # Special handling for MikroTik: skip device's own MAC addresses
     # Special handling for MikroTik: skip device's own MAC addresses
     my $sw_mac;
     my $sw_mac;
     if ($device->{vendor_id} eq '9') {
     if ($device->{vendor_id} eq '9') {
-        my $sw_auth = get_record_sql($dbh, "SELECT mac FROM User_auth WHERE deleted = 0 AND ip = '" . $device->{ip} . "'");
+        my $sw_auth = get_record_sql($dbh, "SELECT mac FROM user_auth WHERE deleted = 0 AND ip = '" . $device->{ip} . "'");
         $sw_mac = mac_simplify($sw_auth->{mac});
         $sw_mac = mac_simplify($sw_auth->{mac});
         $sw_mac =~ s/.{2}$//s;  # Strip last two hex chars for prefix match
         $sw_mac =~ s/.{2}$//s;  # Strip last two hex chars for prefix match
     }
     }
@@ -438,7 +438,7 @@ foreach my $device (@device_list) {
                         $auth_rec->{last_found} = $now_str;
                         $auth_rec->{last_found} = $now_str;
                         $auth_rec->{arp_found}  = $now_str;
                         $auth_rec->{arp_found}  = $now_str;
                         $oper_arp_list{$auth_id}{updated} = 1;
                         $oper_arp_list{$auth_id}{updated} = 1;
-                        update_record($dbh, 'User_auth', $auth_rec, "id = $auth_id");
+                        update_record($dbh, 'user_auth', $auth_rec, "id = $auth_id");
                     }
                     }
                     next;
                     next;
                 }
                 }
@@ -453,7 +453,7 @@ foreach my $device (@device_list) {
                 $auth_rec->{last_found} = $now_str;
                 $auth_rec->{last_found} = $now_str;
                 $auth_rec->{arp_found}  = $now_str if exists $auth_table{oper_table}{$simple_mac};
                 $auth_rec->{arp_found}  = $now_str if exists $auth_table{oper_table}{$simple_mac};
                 $oper_arp_list{$auth_id}{updated} = 1;
                 $oper_arp_list{$auth_id}{updated} = 1;
-                update_record($dbh, 'User_auth', $auth_rec, "id = $auth_id");
+                update_record($dbh, 'user_auth', $auth_rec, "id = $auth_id");
 
 
                 my $conn_rec;
                 my $conn_rec;
                 $conn_rec->{port_id}   = $port_id;
                 $conn_rec->{port_id}   = $port_id;
@@ -470,7 +470,7 @@ foreach my $device (@device_list) {
                 $auth_rec->{last_found} = $now_str;
                 $auth_rec->{last_found} = $now_str;
                 $auth_rec->{arp_found}  = $now_str if exists $auth_table{oper_table}{$simple_mac};
                 $auth_rec->{arp_found}  = $now_str if exists $auth_table{oper_table}{$simple_mac};
                 $oper_arp_list{$auth_id}{updated} = 1;
                 $oper_arp_list{$auth_id}{updated} = 1;
-                update_record($dbh, 'User_auth', $auth_rec, "id = $auth_id");
+                update_record($dbh, 'user_auth', $auth_rec, "id = $auth_id");
 
 
                 my $conn_rec;
                 my $conn_rec;
                 $conn_rec->{port_id}   = $port_id;
                 $conn_rec->{port_id}   = $port_id;
@@ -490,7 +490,7 @@ foreach my $device (@device_list) {
                 my $unknown_rec;
                 my $unknown_rec;
                 $unknown_rec->{port_id}   = $port_id;
                 $unknown_rec->{port_id}   = $port_id;
                 $unknown_rec->{device_id} = $dev_id;
                 $unknown_rec->{device_id} = $dev_id;
-                update_record($dbh, 'Unknown_mac', $unknown_rec, "id = $unknown_table{$simple_mac}{unknown_id}");
+                update_record($dbh, 'unknown_mac', $unknown_rec, "id = $unknown_table{$simple_mac}{unknown_id}");
             } else {
             } else {
                 # Brand new unknown MAC
                 # Brand new unknown MAC
                 $mac_history{$simple_mac}{changed} = 1;
                 $mac_history{$simple_mac}{changed} = 1;
@@ -500,7 +500,7 @@ foreach my $device (@device_list) {
                 $unknown_rec->{port_id} = $port_id;
                 $unknown_rec->{port_id} = $port_id;
                 $unknown_rec->{device_id} = $dev_id;
                 $unknown_rec->{device_id} = $dev_id;
                 $unknown_rec->{mac} = $simple_mac;
                 $unknown_rec->{mac} = $simple_mac;
-                insert_record($dbh, 'Unknown_mac', $unknown_rec);
+                insert_record($dbh, 'unknown_mac', $unknown_rec);
             }
             }
         }
         }
     }
     }
@@ -511,7 +511,7 @@ foreach my $auth_id (keys %oper_arp_list) {
     next if ($oper_arp_list{$auth_id}->{updated});
     next if ($oper_arp_list{$auth_id}->{updated});
     my $auth_rec;
     my $auth_rec;
     $auth_rec->{last_found} = $now_str;
     $auth_rec->{last_found} = $now_str;
-    update_record($dbh, 'User_auth', $auth_rec, "id = $auth_id");
+    update_record($dbh, 'user_auth', $auth_rec, "id = $auth_id");
     db_log_debug($dbh, "Update by ARP at unknown connection location for: " . Dumper($oper_arp_list{$auth_id})) if ($debug);
     db_log_debug($dbh, "Update by ARP at unknown connection location for: " . Dumper($oper_arp_list{$auth_id})) if ($debug);
 }
 }
 
 

+ 40 - 40
scripts/garbage.pl

@@ -35,15 +35,15 @@ my $debug_history = 3;
 #    'connections',
 #    'connections',
 #    'device_l3_interfaces',
 #    'device_l3_interfaces',
 #    'device_ports',
 #    'device_ports',
-#    'User_list',
-#    'User_auth',
-#    'Unknown_mac',
-#    'User_stats',
-#    'User_stats_full',
+#    'user_list',
+#    'user_auth',
+#    'unknown_mac',
+#    'user_stats',
+#    'user_stats_full',
 #    'dhcp_log',
 #    'dhcp_log',
 #    'worklog',
 #    'worklog',
 #    'remote_syslog',
 #    'remote_syslog',
-#    'Traffic_detail',
+#    'traffic_detail',
 #);
 #);
 
 
 
 
@@ -113,24 +113,24 @@ foreach my $subnet (@subnets) {
 if ($day == 1) {
 if ($day == 1) {
     log_info($dbh, 'Monthly amnesty started');
     log_info($dbh, 'Monthly amnesty started');
     db_log_info($dbh, "Unblocking all users blocked due to traffic quota");
     db_log_info($dbh, "Unblocking all users blocked due to traffic quota");
-    do_sql($dbh, "UPDATE User_list SET blocked = 0");
-    do_sql($dbh, "UPDATE User_auth SET blocked = 0, changed = 1 WHERE blocked = 1 AND deleted = 0");
+    do_sql($dbh, "UPDATE user_list SET blocked = 0");
+    do_sql($dbh, "UPDATE user_auth SET blocked = 0, changed = 1 WHERE blocked = 1 AND deleted = 0");
     log_info($dbh, 'Monthly amnesty completed');
     log_info($dbh, 'Monthly amnesty completed');
 } else {
 } else {
     # Daily: unblock users whose monthly traffic is now below quota
     # Daily: unblock users whose monthly traffic is now below quota
     log_info($dbh, 'Daily traffic-based unblocking started');
     log_info($dbh, 'Daily traffic-based unblocking started');
 
 
     my $month_sql = "
     my $month_sql = "
-        SELECT User_list.id, User_list.login, SUM(traf_all) AS traf_sum, User_list.month_quota AS uquota
+        SELECT user_list.id, user_list.login, SUM(traf_all) AS traf_sum, user_list.month_quota AS uquota
         FROM (
         FROM (
-            SELECT User_stats.auth_id, SUM(byte_in + byte_out) AS traf_all
-            FROM User_stats
-            WHERE User_stats.`timestamp` >= $month_start AND User_stats.`timestamp` < $month_stop
-            GROUP BY User_stats.auth_id
-        ) AS V, User_auth, User_list
-        WHERE V.auth_id = User_auth.id
-          AND User_auth.user_id = User_list.id
-          AND User_list.blocked = 1
+            SELECT user_stats.auth_id, SUM(byte_in + byte_out) AS traf_all
+            FROM user_stats
+            WHERE user_stats.ts >= $month_start AND user_stats.ts < $month_stop
+            GROUP BY user_stats.auth_id
+        ) AS V, user_auth, user_list
+        WHERE V.auth_id = user_auth.id
+          AND user_auth.user_id = user_list.id
+          AND user_list.blocked = 1
         GROUP BY login
         GROUP BY login
     ";
     ";
 
 
@@ -146,7 +146,7 @@ if ($day == 1) {
 # Clean expired DHCP leases for dynamic users (hotspot and default OU only)
 # Clean expired DHCP leases for dynamic users (hotspot and default OU only)
 log_info($dbh, 'Cleaning DHCP leases with overdue expiration for dynamic hosts');
 log_info($dbh, 'Cleaning DHCP leases with overdue expiration for dynamic hosts');
 
 
-my $users_sql = "SELECT * FROM User_auth WHERE deleted = 0 AND (`ou_id` = " . $default_user_ou_id . " OR `ou_id` = " . $default_hotspot_ou_id . ")";
+my $users_sql = "SELECT * FROM user_auth WHERE deleted = 0 AND (ou_id = " . $default_user_ou_id . " OR ou_id = " . $default_hotspot_ou_id . ")";
 my @users_auth = get_records_sql($dbh, $users_sql);
 my @users_auth = get_records_sql($dbh, $users_sql);
 foreach my $row (@users_auth) {
 foreach my $row (@users_auth) {
     # Skip if IP is not in any DHCP pool
     # Skip if IP is not in any DHCP pool
@@ -163,7 +163,7 @@ foreach my $row (@users_auth) {
             delete_user_auth($dbh, $row->{id});
             delete_user_auth($dbh, $row->{id});
 
 
             # Also delete parent user if no other active sessions remain
             # Also delete parent user if no other active sessions remain
-            my $u_count = get_count_records($dbh, 'User_auth', "deleted = 0 AND user_id = " . $row->{user_id});
+            my $u_count = get_count_records($dbh, 'user_auth', "deleted = 0 AND user_id = " . $row->{user_id});
             if (!$u_count) {
             if (!$u_count) {
                 delete_user($dbh, $row->{'user_id'});
                 delete_user($dbh, $row->{'user_id'});
                 db_log_info($dbh, "Removed dynamic user id: $row->{'user_id'} due to DHCP lease timeout");
                 db_log_info($dbh, "Removed dynamic user id: $row->{'user_id'} due to DHCP lease timeout");
@@ -180,7 +180,7 @@ if ($history_dhcp) {
     my $clean_date = $now - $day_dur;
     my $clean_date = $now - $day_dur;
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     log_info($dbh, 'Clearing outdated DHCP log records');
     log_info($dbh, 'Clearing outdated DHCP log records');
-    do_sql($dbh, "DELETE FROM dhcp_log WHERE `timestamp` < $clean_str");
+    do_sql($dbh, "DELETE FROM dhcp_log WHERE ts < $clean_str");
     log_verbose($dbh, "Removed DHCP log entries older than $clean_str");
     log_verbose($dbh, "Removed DHCP log entries older than $clean_str");
 }
 }
 
 
@@ -190,7 +190,7 @@ if ($connections_history) {
     my $day_dur = DateTime::Duration->new(days => $connections_history);
     my $day_dur = DateTime::Duration->new(days => $connections_history);
     my $clean_date = $now - $day_dur;
     my $clean_date = $now - $day_dur;
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
-    $users_sql = "SELECT id FROM User_auth WHERE `last_found` < $clean_str AND last_found > 0";
+    $users_sql = "SELECT id FROM user_auth WHERE last_found < $clean_str AND last_found > 0";
     log_debug($dbh, $users_sql) if ($debug);
     log_debug($dbh, $users_sql) if ($debug);
     @users_auth = get_records_sql($dbh, $users_sql);
     @users_auth = get_records_sql($dbh, $users_sql);
     foreach my $row (@users_auth) {
     foreach my $row (@users_auth) {
@@ -228,7 +228,7 @@ foreach my $row (@conn_ref) {
 
 
 # Clean empty dynamic/hotspot user accounts (no active authentications)
 # Clean empty dynamic/hotspot user accounts (no active authentications)
 log_info($dbh, 'Clearing empty user accounts and associated devices for dynamic users and hotspot');
 log_info($dbh, 'Clearing empty user accounts and associated devices for dynamic users and hotspot');
-my $u_sql = "SELECT * FROM User_list AS U WHERE (U.ou_id = " . $default_hotspot_ou_id . " OR U.ou_id = " . $default_user_ou_id . ") AND (SELECT COUNT(*) FROM User_auth WHERE User_auth.deleted = 0 AND User_auth.user_id = U.id) = 0";
+my $u_sql = "SELECT * FROM user_list AS U WHERE (U.ou_id = " . $default_hotspot_ou_id . " OR U.ou_id = " . $default_user_ou_id . ") AND (SELECT COUNT(*) FROM user_auth WHERE user_auth.deleted = 0 AND user_auth.user_id = U.id) = 0";
 my @u_ref = get_records_sql($dbh, $u_sql);
 my @u_ref = get_records_sql($dbh, $u_sql);
 foreach my $row (@u_ref) {
 foreach my $row (@u_ref) {
     db_log_info($dbh, "Removing empty dynamic user with id: $row->{id}, login: $row->{login}");
     db_log_info($dbh, "Removing empty dynamic user with id: $row->{id}, login: $row->{login}");
@@ -238,7 +238,7 @@ foreach my $row (@u_ref) {
 # Clean empty non-permanent user accounts (if enabled in config)
 # Clean empty non-permanent user accounts (if enabled in config)
 if ($config_ref{clean_empty_user}) {
 if ($config_ref{clean_empty_user}) {
     log_info($dbh, 'Clearing empty non-permanent user accounts and associated devices');
     log_info($dbh, 'Clearing empty non-permanent user accounts and associated devices');
-    my $u_sql = "SELECT * FROM User_list AS U WHERE U.permanent = 0 AND (SELECT COUNT(*) FROM User_auth WHERE User_auth.deleted = 0 AND User_auth.user_id = U.id) = 0 AND (SELECT COUNT(*) FROM auth_rules WHERE auth_rules.user_id = U.id) = 0;";
+    my $u_sql = "SELECT * FROM user_list AS U WHERE U.permanent = 0 AND (SELECT COUNT(*) FROM user_auth WHERE user_auth.deleted = 0 AND user_auth.user_id = U.id) = 0 AND (SELECT COUNT(*) FROM auth_rules WHERE auth_rules.user_id = U.id) = 0;";
     my @u_ref = get_records_sql($dbh, $u_sql);
     my @u_ref = get_records_sql($dbh, $u_sql);
     foreach my $row (@u_ref) {
     foreach my $row (@u_ref) {
         db_log_info($dbh, "Removing empty user with id: $row->{id}, login: $row->{login}");
         db_log_info($dbh, "Removing empty user with id: $row->{id}, login: $row->{login}");
@@ -247,15 +247,15 @@ if ($config_ref{clean_empty_user}) {
 }
 }
 
 
 # Remove orphaned auth rules (no corresponding user)
 # Remove orphaned auth rules (no corresponding user)
-do_sql($dbh, "DELETE FROM `auth_rules` WHERE user_id NOT IN (SELECT id FROM User_list)");
+do_sql($dbh, "DELETE FROM auth_rules WHERE user_id NOT IN (SELECT id FROM user_list)");
 
 
 # Clean unknown MAC entries that now belong to known users
 # Clean unknown MAC entries that now belong to known users
 log_info($dbh, 'Removing unknown MAC records that are now associated with active users');
 log_info($dbh, 'Removing unknown MAC records that are now associated with active users');
-$users_sql = "SELECT mac FROM User_auth WHERE deleted = 0";
+$users_sql = "SELECT mac FROM user_auth WHERE deleted = 0";
 @users_auth = get_records_sql($dbh, $users_sql);
 @users_auth = get_records_sql($dbh, $users_sql);
 foreach my $row (@users_auth) {
 foreach my $row (@users_auth) {
     next if (!$row->{mac});
     next if (!$row->{mac});
-    do_sql($dbh, "DELETE FROM Unknown_mac WHERE mac = '" . mac_simplify($row->{mac}) . "'");
+    do_sql($dbh, "DELETE FROM unknown_mac WHERE mac = '" . mac_simplify($row->{mac}) . "'");
 }
 }
 
 
 # Clean old detailed traffic records (based on global $history setting)
 # Clean old detailed traffic records (based on global $history setting)
@@ -264,7 +264,7 @@ if ($history) {
     my $clean_date = $now - $day_dur;
     my $clean_date = $now - $day_dur;
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     log_info($dbh, "Cleaning traffic detail records older than $clean_str");
     log_info($dbh, "Cleaning traffic detail records older than $clean_str");
-    do_sql($dbh, "DELETE FROM Traffic_detail WHERE `timestamp` < $clean_str");
+    do_sql($dbh, "DELETE FROM traffic_detail WHERE ts < $clean_str");
 }
 }
 
 
 # Clean verbose (non-info) worklog entries
 # Clean verbose (non-info) worklog entries
@@ -273,7 +273,7 @@ if ($history_log_day) {
     my $clean_date = $now - $day_dur;
     my $clean_date = $now - $day_dur;
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     log_info($dbh, "Cleaning VERBOSE worklog entries older than $clean_str");
     log_info($dbh, "Cleaning VERBOSE worklog entries older than $clean_str");
-    do_sql($dbh, "DELETE FROM worklog WHERE level > $L_INFO AND `timestamp` < $clean_str");
+    do_sql($dbh, "DELETE FROM worklog WHERE level > $L_INFO AND ts < $clean_str");
 }
 }
 
 
 # Clean debug-level worklog entries older than $debug_history days (hardcoded to 3)
 # Clean debug-level worklog entries older than $debug_history days (hardcoded to 3)
@@ -282,7 +282,7 @@ if ($debug_history) {
     my $clean_date = $now - $day_dur;
     my $clean_date = $now - $day_dur;
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     log_info($dbh, "Cleaning debug worklog entries older than $clean_str");
     log_info($dbh, "Cleaning debug worklog entries older than $clean_str");
-    do_sql($dbh, "DELETE FROM worklog WHERE level >= $L_DEBUG AND `timestamp` < $clean_str");
+    do_sql($dbh, "DELETE FROM worklog WHERE level >= $L_DEBUG AND ts < $clean_str");
 }
 }
 
 
 # Clean old remote syslog entries
 # Clean old remote syslog entries
@@ -291,7 +291,7 @@ if ($history_syslog_day) {
     my $clean_date = $now - $day_dur;
     my $clean_date = $now - $day_dur;
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     log_info($dbh, "Cleaning syslog entries older than $clean_str");
     log_info($dbh, "Cleaning syslog entries older than $clean_str");
-    do_sql($dbh, "DELETE FROM remote_syslog WHERE `date` < $clean_str");
+    do_sql($dbh, "DELETE FROM remote_syslog WHERE date < $clean_str");
 }
 }
 
 
 # Clean old aggregated traffic statistics
 # Clean old aggregated traffic statistics
@@ -300,7 +300,7 @@ if ($history_trafstat_day) {
     my $clean_date = $now - $day_dur;
     my $clean_date = $now - $day_dur;
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     log_info($dbh, "Cleaning traffic statistics older than $clean_str");
     log_info($dbh, "Cleaning traffic statistics older than $clean_str");
-    do_sql($dbh, "DELETE FROM User_stats WHERE `timestamp` < $clean_str");
+    do_sql($dbh, "DELETE FROM user_stats WHERE ts < $clean_str");
 }
 }
 
 
 # Clean old per-IP full traffic statistics (if retention is configured)
 # Clean old per-IP full traffic statistics (if retention is configured)
@@ -310,11 +310,11 @@ if ($iptraf_history) {
     my $clean_date = $now - $day_dur;
     my $clean_date = $now - $day_dur;
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     my $clean_str = $dbh->quote($clean_date->ymd("-") . " 00:00:00");
     log_info($dbh, "Cleaning full traffic statistics older than $clean_str");
     log_info($dbh, "Cleaning full traffic statistics older than $clean_str");
-    do_sql($dbh, "DELETE FROM User_stats_full WHERE `timestamp` < $clean_str");
+    do_sql($dbh, "DELETE FROM user_stats_full WHERE ts < $clean_str");
 }
 }
 
 
-# Clean dangling User_auth records (deleted, but with no MAC — likely artifacts)
-do_sql($dbh, "DELETE FROM User_auth WHERE (mac IS NULL OR mac = '') AND deleted = 1");
+# Clean dangling user_auth records (deleted, but with no MAC — likely artifacts)
+do_sql($dbh, "DELETE FROM user_auth WHERE (mac IS NULL OR mac = '') AND deleted = 1");
 
 
 # Ensure current user locations are recorded in mac_history
 # Ensure current user locations are recorded in mac_history
 my %connections;
 my %connections;
@@ -325,7 +325,7 @@ foreach my $connection (@connections_list) {
 }
 }
 
 
 # Build a set of currently active, non-empty MACs with valid connections
 # Build a set of currently active, non-empty MACs with valid connections
-my $auth_sql = "SELECT * FROM User_auth WHERE mac IS NOT NULL AND mac != '' AND deleted = 0 ORDER BY last_found DESC";
+my $auth_sql = "SELECT * FROM user_auth WHERE mac IS NOT NULL AND mac != '' AND deleted = 0 ORDER BY last_found DESC";
 my %auth_table;
 my %auth_table;
 my @auth_full_list = get_records_sql($dbh, $auth_sql);
 my @auth_full_list = get_records_sql($dbh, $auth_sql);
 foreach my $auth (@auth_full_list) {
 foreach my $auth (@auth_full_list) {
@@ -337,7 +337,7 @@ foreach my $auth (@auth_full_list) {
     $auth_table{$auth_mac} = 1;
     $auth_table{$auth_mac} = 1;
 
 
     # Check if location history already exists
     # Check if location history already exists
-    my $h_sql = "SELECT * FROM mac_history WHERE mac = '$auth_mac' ORDER BY `timestamp` DESC LIMIT 1";
+    my $h_sql = "SELECT * FROM mac_history WHERE mac = '$auth_mac' ORDER BY ts DESC LIMIT 1";
     my $history = get_record_sql($dbh, $h_sql);
     my $history = get_record_sql($dbh, $h_sql);
 
 
     my $cur_conn = $connections{$auth->{id}};
     my $cur_conn = $connections{$auth->{id}};
@@ -378,10 +378,10 @@ foreach my $auth (@auth_full_list) {
 #        my $opt_rf = $dbh->prepare($opt_sql) or die "Unable to prepare $opt_sql: " . $dbh->errstr;
 #        my $opt_rf = $dbh->prepare($opt_sql) or die "Unable to prepare $opt_sql: " . $dbh->errstr;
 #        $opt_rf->execute();
 #        $opt_rf->execute();
 #        # Alternative (manual rebuild) is commented out:
 #        # Alternative (manual rebuild) is commented out:
-#        # CREATE TABLE `$table.new` LIKE $table;
-#        # INSERT INTO `$table.new` SELECT * FROM $table;
-#        # RENAME TABLE $table TO `$table.backup`, `$table.new` TO $table;
-#        # DROP TABLE `$table.backup`;
+#        # CREATE TABLE $table.new LIKE $table;
+#        # INSERT INTO $table.new SELECT * FROM $table;
+#        # RENAME TABLE $table TO $table.backup, $table.new TO $table;
+#        # DROP TABLE $table.backup;
 #    }
 #    }
 #    log_info($dbh, 'Table optimization completed.');
 #    log_info($dbh, 'Table optimization completed.');
 #}
 #}

+ 4 - 4
scripts/gen_nagios_config.pl

@@ -88,7 +88,7 @@ if (scalar(@netdev_list)>0) {
             }
             }
 	if ($router->{'user_id'}) {
 	if ($router->{'user_id'}) {
             #get user
             #get user
-	    my $login = get_record_sql($dbh,"SELECT * FROM User_list WHERE id=".$router->{'user_id'});
+	    my $login = get_record_sql($dbh,"SELECT * FROM user_list WHERE id=".$router->{'user_id'});
 	    if ($login and $login->{ou_id} and $ou{$login->{ou_id}}->{nagios_dir}) { $devices{$device_id}{ou_id} = $login->{ou_id}; }
 	    if ($login and $login->{ou_id} and $ou{$login->{ou_id}}->{nagios_dir}) { $devices{$device_id}{ou_id} = $login->{ou_id}; }
             }
             }
         $devices{$device_id}{ou}=$ou{$devices{$device_id}{ou_id}};
         $devices{$device_id}{ou}=$ou{$devices{$device_id}{ou_id}};
@@ -133,7 +133,7 @@ if (scalar(@netdev_list)>0) {
         }
         }
     }
     }
 
 
-my @auth_list=get_records_sql($dbh,'SELECT * FROM User_auth WHERE deleted=0 and nagios=1');
+my @auth_list=get_records_sql($dbh,'SELECT * FROM user_auth WHERE deleted=0 and nagios=1');
 
 
 ##################################### User auth analyze ################################################
 ##################################### User auth analyze ################################################
 
 
@@ -148,7 +148,7 @@ if (scalar(@auth_list)>0) {
         next if ($devices{$device_id});
         next if ($devices{$device_id});
 
 
 	#skip user device with few ip
 	#skip user device with few ip
-        my $auth_count = get_count_records($dbh,"User_auth","user_id=".$auth->{'user_id'}." AND deleted=0");
+        my $auth_count = get_count_records($dbh,"user_auth","user_id=".$auth->{'user_id'}." AND deleted=0");
         next if ($auth_count>1);
         next if ($auth_count>1);
 
 
 	#skip switches and routers
 	#skip switches and routers
@@ -162,7 +162,7 @@ if (scalar(@auth_list)>0) {
         $devices{$device_id}{ip}=$ip;
         $devices{$device_id}{ip}=$ip;
 
 
         #get user
         #get user
-        my $login = get_record_sql($dbh,"SELECT * FROM User_list WHERE id=".$auth->{'user_id'});
+        my $login = get_record_sql($dbh,"SELECT * FROM user_list WHERE id=".$auth->{'user_id'});
     
     
         $devices{$device_id}{user_login} = $login->{login};
         $devices{$device_id}{user_login} = $login->{login};
         $devices{$device_id}{user_fio} = $login->{fio};
         $devices{$device_id}{user_fio} = $login->{fio};

+ 7 - 7
scripts/hmonitor.pl

@@ -121,22 +121,22 @@ my $login;
 my $nagios_handler;
 my $nagios_handler;
 
 
 if (!$hostid or $hostid !~ /^[0-9]/) {
 if (!$hostid or $hostid !~ /^[0-9]/) {
-    $auth = get_record_sql($hdb,'SELECT * FROM User_auth WHERE deleted=0 AND ip="'.$hostip.'"');
+    $auth = get_record_sql($hdb,'SELECT * FROM user_auth WHERE deleted=0 AND ip="'.$hostip.'"');
     next if (!$auth);
     next if (!$auth);
     $hostid = $auth->{id};
     $hostid = $auth->{id};
-    $login = get_record_sql($hdb,'SELECT * FROM User_list WHERE id='.$auth->{user_id});
+    $login = get_record_sql($hdb,'SELECT * FROM user_list WHERE id='.$auth->{user_id});
     $device = get_record_sql($hdb,'SELECT * FROM devices WHERE user_id='.$auth->{user_id});
     $device = get_record_sql($hdb,'SELECT * FROM devices WHERE user_id='.$auth->{user_id});
     if ($auth->{nagios_status}) { $old_state = $auth->{nagios_status}; }
     if ($auth->{nagios_status}) { $old_state = $auth->{nagios_status}; }
     db_log_verbose($hdb,"Manual host: $hostname [$hostip] => $hoststate, old: $old_state");
     db_log_verbose($hdb,"Manual host: $hostname [$hostip] => $hoststate, old: $old_state");
     } else {
     } else {
     if ($hosttype=~/device/i) {
     if ($hosttype=~/device/i) {
         $device = get_record_sql($hdb,'SELECT * FROM devices WHERE id='.$hostid);
         $device = get_record_sql($hdb,'SELECT * FROM devices WHERE id='.$hostid);
-        $login = get_record_sql($hdb,'SELECT * FROM User_list WHERE id='.$device->{user_id});
-        $auth = get_record_sql($hdb,'SELECT * FROM User_auth WHERE user_id='.$device->{user_id}.' AND deleted=0 AND ip="'.$hostip.'"');
+        $login = get_record_sql($hdb,'SELECT * FROM user_list WHERE id='.$device->{user_id});
+        $auth = get_record_sql($hdb,'SELECT * FROM user_auth WHERE user_id='.$device->{user_id}.' AND deleted=0 AND ip="'.$hostip.'"');
         if ($device->{nagios_status}) { $old_state = $device->{nagios_status}; }
         if ($device->{nagios_status}) { $old_state = $device->{nagios_status}; }
         } else {
         } else {
-        $auth = get_record_sql($hdb,'SELECT * FROM User_auth WHERE id='.$hostid);
-        $login = get_record_sql($hdb,'SELECT * FROM User_list WHERE id='.$auth->{user_id});
+        $auth = get_record_sql($hdb,'SELECT * FROM user_auth WHERE id='.$hostid);
+        $login = get_record_sql($hdb,'SELECT * FROM user_list WHERE id='.$auth->{user_id});
         $device = get_record_sql($hdb,'SELECT * FROM devices WHERE user_id='.$auth->{user_id});
         $device = get_record_sql($hdb,'SELECT * FROM devices WHERE user_id='.$auth->{user_id});
         if ($auth->{nagios_status}) { $old_state = $auth->{nagios_status}; }
         if ($auth->{nagios_status}) { $old_state = $auth->{nagios_status}; }
         }
         }
@@ -155,7 +155,7 @@ if ($hoststate ne $old_state) {
     db_log_verbose($hdb,"Host changed! $hostname [$hostip] => $hoststate, old: $old_state");
     db_log_verbose($hdb,"Host changed! $hostname [$hostip] => $hoststate, old: $old_state");
     my $ip_aton=StrToIp($hostip);
     my $ip_aton=StrToIp($hostip);
     if ($device->{id}) { do_sql($hdb,'UPDATE devices SET nagios_status="'.$hoststate.'" WHERE id='.$device->{id}); }
     if ($device->{id}) { do_sql($hdb,'UPDATE devices SET nagios_status="'.$hoststate.'" WHERE id='.$device->{id}); }
-    if ($auth->{id}) { do_sql($hdb,'UPDATE User_auth SET nagios_status="'.$hoststate.'" WHERE id='.$auth->{id}); }
+    if ($auth->{id}) { do_sql($hdb,'UPDATE user_auth SET nagios_status="'.$hoststate.'" WHERE id='.$auth->{id}); }
     if ($hoststate=~/UP/i) {
     if ($hoststate=~/UP/i) {
         nagios_host_svc_enable($hostname,1);
         nagios_host_svc_enable($hostname,1);
         db_log_debug($hdb,"Enable notifications for host $hostname [$hostip] id: $hostid services");
         db_log_debug($hdb,"Enable notifications for host $hostname [$hostip] id: $hostid services");

+ 3 - 3
scripts/print-dnsmasq.pl

@@ -60,7 +60,7 @@ print "dhcp-option=net:net-$subnet_name,option:router,$dhcp_conf{$subnet_name}->
 }
 }
 
 
 #get userid list
 #get userid list
-my $sSQL="SELECT id,ip,ip_int,mac,comments,dns_name,dhcp_option_set,dhcp_acl,ou_id FROM User_auth where dhcp=1 and deleted=0 ORDER by ip_int";
+my $sSQL="SELECT id,ip,ip_int,mac,comments,dns_name,dhcp_option_set,dhcp_acl,ou_id FROM user_auth where dhcp=1 and deleted=0 ORDER by ip_int";
 my @users = get_records_sql($dbh,$sSQL);
 my @users = get_records_sql($dbh,$sSQL);
 foreach my $row (@users) {
 foreach my $row (@users) {
 next if (!$row);
 next if (!$row);
@@ -109,7 +109,7 @@ if (!$static_hole{$ip}{skip}) {
 print "#--- DNS ---#\n";
 print "#--- DNS ---#\n";
 
 
 #get userid list
 #get userid list
-my $sSQL="SELECT id,ou_id,ip,dns_name,dhcp_hostname,dns_ptr_only FROM User_auth WHERE deleted=0 AND ip>'' AND (dns_name>'' OR dhcp_hostname>'') AND dns_name NOT LIKE '%.' ORDER by ip_int;";
+my $sSQL="SELECT id,ou_id,ip,dns_name,dhcp_hostname,dns_ptr_only FROM user_auth WHERE deleted=0 AND ip>'' AND (dns_name>'' OR dhcp_hostname>'') AND dns_name NOT LIKE '%.' ORDER by ip_int;";
 my @users = get_records_sql($dbh,$sSQL);
 my @users = get_records_sql($dbh,$sSQL);
 foreach my $row (@users) {
 foreach my $row (@users) {
 next if (!$row);
 next if (!$row);
@@ -151,7 +151,7 @@ if (!$row->{dns_ptr_only} and $dns_name) {
 #            }
 #            }
     #aliases
     #aliases
     if ($dns_name) {
     if ($dns_name) {
-        my $aSQL="SELECT * FROM `User_auth_alias` WHERE auth_id=$row->{id} AND alias>'' AND alias NOT LIKE '%.';";
+        my $aSQL="SELECT * FROM user_auth_alias WHERE auth_id=$row->{id} AND alias>'' AND alias NOT LIKE '%.';";
         my @aliases = get_records_sql($dbh,$aSQL);
         my @aliases = get_records_sql($dbh,$aSQL);
         print '#DNS aliases for '.$dns_name."\n" if (@aliases and scalar @aliases);
         print '#DNS aliases for '.$dns_name."\n" if (@aliases and scalar @aliases);
         foreach my $alias (@aliases) {
         foreach my $alias (@aliases) {

+ 1 - 1
scripts/restart_port_snmp.pl

@@ -39,7 +39,7 @@ my $HOST_IP = $ARGV[0];
 
 
 my $IP_ATON=StrToIp($HOST_IP);
 my $IP_ATON=StrToIp($HOST_IP);
 
 
-my $auth_rec = get_record_sql($dbh,'SELECT * FROM User_auth WHERE deleted=0 and ip_int='.$IP_ATON);
+my $auth_rec = get_record_sql($dbh,'SELECT * FROM user_auth WHERE deleted=0 and ip_int='.$IP_ATON);
 if (!$auth_rec) { db_log_error("Record with ip $HOST_IP not found! Bye."); exit; }
 if (!$auth_rec) { db_log_error("Record with ip $HOST_IP not found! Bye."); exit; }
 
 
 my $auth_id = $auth_rec->{id};
 my $auth_id = $auth_rec->{id};

+ 11 - 11
scripts/stat-sync.pl

@@ -116,25 +116,25 @@ if (!$pid) {
             $urgent_sync=get_option($hdb,50);
             $urgent_sync=get_option($hdb,50);
             if ($urgent_sync) {
             if ($urgent_sync) {
                     #clean changed for dynamic clients or hotspot
                     #clean changed for dynamic clients or hotspot
-        	    do_sql($hdb,"UPDATE User_auth SET changed=0 WHERE ou_id=".$default_user_ou_id." OR ou_id=".$default_hotspot_ou_id);
-                    do_sql($hdb,"UPDATE User_auth SET dhcp_changed=0 WHERE ou_id=".$default_user_ou_id." OR ou_id=".$default_hotspot_ou_id);
+        	    do_sql($hdb,"UPDATE user_auth SET changed=0 WHERE ou_id=".$default_user_ou_id." OR ou_id=".$default_hotspot_ou_id);
+                    do_sql($hdb,"UPDATE user_auth SET dhcp_changed=0 WHERE ou_id=".$default_user_ou_id." OR ou_id=".$default_hotspot_ou_id);
         	    #clean unmanagment ip changed
         	    #clean unmanagment ip changed
-	            my @all_changed = get_records_sql($hdb,"SELECT id, ip FROM User_auth WHERE changed = 1 OR dhcp_changed = 1");
+	            my @all_changed = get_records_sql($hdb,"SELECT id, ip FROM user_auth WHERE changed = 1 OR dhcp_changed = 1");
         	    foreach my $row(@all_changed) {
         	    foreach my $row(@all_changed) {
 	        	    next if ($office_networks->match_string($row->{ip}));
 	        	    next if ($office_networks->match_string($row->{ip}));
-		            do_sql($hdb,"UPDATE User_auth SET changed = 0, dhcp_changed = 0  WHERE id=".$row->{id});
+		            do_sql($hdb,"UPDATE user_auth SET changed = 0, dhcp_changed = 0  WHERE id=".$row->{id});
 		            }
 		            }
                     #dhcp changed records
                     #dhcp changed records
-                    my $changed = get_record_sql($hdb,"SELECT COUNT(*) as c_count from User_auth WHERE dhcp_changed=1");
+                    my $changed = get_record_sql($hdb,"SELECT COUNT(*) as c_count from user_auth WHERE dhcp_changed=1");
                     if ($changed->{"c_count"}>0) {
                     if ($changed->{"c_count"}>0) {
-                	    do_sql($hdb,"UPDATE User_auth SET dhcp_changed=0");
+                	    do_sql($hdb,"UPDATE user_auth SET dhcp_changed=0");
                             log_info("Found changed dhcp variables in records: ".$changed->{'c_count'});
                             log_info("Found changed dhcp variables in records: ".$changed->{'c_count'});
                             my $dhcp_exec=get_option($hdb,38);
                             my $dhcp_exec=get_option($hdb,38);
 	                    my %result=do_exec_ref('/usr/bin/sudo '.$dhcp_exec);
 	                    my %result=do_exec_ref('/usr/bin/sudo '.$dhcp_exec);
 	                    if ($result{status} ne 0) { log_error("Error sync dhcp config"); }
 	                    if ($result{status} ne 0) { log_error("Error sync dhcp config"); }
                             }
                             }
                     #acl & dhcp changed records 
                     #acl & dhcp changed records 
-                    $changed = get_record_sql($hdb,"SELECT COUNT(*) as c_count from User_auth WHERE changed=1");
+                    $changed = get_record_sql($hdb,"SELECT COUNT(*) as c_count from user_auth WHERE changed=1");
 	            if ($changed->{"c_count"}>0) {
 	            if ($changed->{"c_count"}>0) {
                             log_info("Found changed records: ".$changed->{'c_count'});
                             log_info("Found changed records: ".$changed->{'c_count'});
                             my $acl_exec=get_option($hdb,37);
                             my $acl_exec=get_option($hdb,37);
@@ -143,24 +143,24 @@ if (!$pid) {
 		            }
 		            }
 	            }
 	            }
             #dns changed records
             #dns changed records
-            my @dns_changed = get_records_sql($hdb,"SELECT auth_id FROM `dns_queue` GROUP BY auth_id");
+            my @dns_changed = get_records_sql($hdb,"SELECT auth_id FROM dns_queue GROUP BY auth_id");
             if (@dns_changed and scalar @dns_changed) {
             if (@dns_changed and scalar @dns_changed) {
                     foreach my $auth (@dns_changed) {
                     foreach my $auth (@dns_changed) {
                         update_dns_record($hdb,$auth->{auth_id});
                         update_dns_record($hdb,$auth->{auth_id});
                         log_info("Clear changed dns for auth id: ".$auth->{auth_id});
                         log_info("Clear changed dns for auth id: ".$auth->{auth_id});
-                        do_sql($hdb,"DELETE FROM `dns_queue` WHERE auth_id=".$auth->{auth_id});
+                        do_sql($hdb,"DELETE FROM dns_queue WHERE auth_id=".$auth->{auth_id});
                         }
                         }
 	            }
 	            }
             #clear temporary user auth records
             #clear temporary user auth records
             my $now = DateTime->now(time_zone=>'local');
             my $now = DateTime->now(time_zone=>'local');
             my $clear_time =$dbh->quote($now->strftime('%Y-%m-%d %H:%M:%S'));
             my $clear_time =$dbh->quote($now->strftime('%Y-%m-%d %H:%M:%S'));
-            my $users_sql = "SELECT * FROM User_auth WHERE deleted=0 AND dynamic=1 AND `eof`<=".$clear_time;
+            my $users_sql = "SELECT * FROM user_auth WHERE deleted=0 AND dynamic=1 AND eof<=".$clear_time;
             my @users_auth = get_records_sql($hdb,$users_sql);
             my @users_auth = get_records_sql($hdb,$users_sql);
             if (@users_auth and scalar @users_auth) {
             if (@users_auth and scalar @users_auth) {
                     foreach my $row (@users_auth) {
                     foreach my $row (@users_auth) {
                         delete_user_auth($hdb,$row->{id});
                         delete_user_auth($hdb,$row->{id});
                         db_log_info($hdb,"Removed dynamic user auth record for auth_id: $row->{'id'} by eof time: $row->{'eof'}",$row->{'id'});
                         db_log_info($hdb,"Removed dynamic user auth record for auth_id: $row->{'id'} by eof time: $row->{'eof'}",$row->{'id'});
-                        my $u_count=get_count_records($hdb,'User_auth','deleted=0 and user_id='.$row->{user_id});
+                        my $u_count=get_count_records($hdb,'user_auth','deleted=0 and user_id='.$row->{user_id});
                         if (!$u_count) { delete_user($hdb,$row->{'user_id'}); }
                         if (!$u_count) { delete_user($hdb,$row->{'user_id'}); }
                         }
                         }
                     }
                     }

+ 19 - 19
scripts/sync_mikrotik.pl

@@ -77,7 +77,7 @@ $dhcp_conf{$subnet->{subnet}}->{last_ip_aton}=StrToIp($dhcp_info->{last_ip});
 my $pm = Parallel::ForkManager->new($fork_count);
 my $pm = Parallel::ForkManager->new($fork_count);
 
 
 #save changed records
 #save changed records
-my @changes_found = get_records_sql($dbh,"SELECT id FROM User_auth WHERE changed=1");
+my @changes_found = get_records_sql($dbh,"SELECT id FROM user_auth WHERE changed=1");
 
 
 foreach my $gate (@gateways) {
 foreach my $gate (@gateways) {
 next if (!$gate);
 next if (!$gate);
@@ -231,7 +231,7 @@ my @auth_records=();
 foreach my $dhcp_subnet (@dhcp_subnets) {
 foreach my $dhcp_subnet (@dhcp_subnets) {
     next if (!$dhcp_subnet);
     next if (!$dhcp_subnet);
     next if (!exists $dhcp_conf{$dhcp_subnet});
     next if (!exists $dhcp_conf{$dhcp_subnet});
-    my @tmp1=get_records_sql($dbh,"SELECT * from User_auth WHERE dhcp=1 and `ip_int`>=".$dhcp_conf{$dhcp_subnet}->{first_ip_aton}." and `ip_int`<=".$dhcp_conf{$dhcp_subnet}->{last_ip_aton}." and deleted=0 and ou_id !=".$default_user_ou_id." and ou_id !=".$default_hotspot_ou_id." ORDER BY ip_int");
+    my @tmp1=get_records_sql($dbh,"SELECT * from user_auth WHERE dhcp=1 and ip_int>=".$dhcp_conf{$dhcp_subnet}->{first_ip_aton}." and ip_int<=".$dhcp_conf{$dhcp_subnet}->{last_ip_aton}." and deleted=0 and ou_id !=".$default_user_ou_id." and ou_id !=".$default_hotspot_ou_id." ORDER BY ip_int");
     push(@auth_records,@tmp1);
     push(@auth_records,@tmp1);
     undef @tmp1;
     undef @tmp1;
 }
 }
@@ -455,15 +455,15 @@ if ($gate->{user_acl}) {
 db_log_verbose($dbh,$gate_ident."Sync user state at router $router_name [".$router_ip."] started.");
 db_log_verbose($dbh,$gate_ident."Sync user state at router $router_name [".$router_ip."] started.");
 
 
 #get userid list
 #get userid list
-my $user_auth_sql="SELECT User_auth.ip, User_auth.filter_group_id, User_auth.queue_id, User_auth.id
-FROM User_auth, User_list
-WHERE User_auth.user_id = User_list.id
-AND User_auth.deleted =0
-AND User_auth.enabled =1
-AND User_auth.blocked =0
-AND User_list.blocked =0
-AND User_list.enabled =1
-AND User_auth.ou_id <> $default_hotspot_ou_id
+my $user_auth_sql="SELECT user_auth.ip, user_auth.filter_group_id, user_auth.queue_id, user_auth.id
+FROM user_auth, user_list
+WHERE user_auth.user_id = user_list.id
+AND user_auth.deleted =0
+AND user_auth.enabled =1
+AND user_auth.blocked =0
+AND user_list.blocked =0
+AND user_list.enabled =1
+AND user_auth.ou_id <> $default_hotspot_ou_id
 ORDER BY ip_int";
 ORDER BY ip_int";
 
 
 my @authlist_ref = get_records_sql($dbh,$user_auth_sql);
 my @authlist_ref = get_records_sql($dbh,$user_auth_sql);
@@ -490,7 +490,7 @@ log_debug($gate_ident."Users status:".Dumper(\%users));
 $lists{'group_all'}=1;
 $lists{'group_all'}=1;
 
 
 #get queue list
 #get queue list
-my @queuelist_ref = get_records_sql($dbh,"SELECT * FROM Queue_list");
+my @queuelist_ref = get_records_sql($dbh,"SELECT * FROM queue_list");
 
 
 my %queues;
 my %queues;
 foreach my $row (@queuelist_ref) {
 foreach my $row (@queuelist_ref) {
@@ -505,12 +505,12 @@ log_debug($gate_ident."Queues status:".Dumper(\%queues));
 
 
 my @filter_instances = get_records_sql($dbh,"SELECT * FROM filter_instances");
 my @filter_instances = get_records_sql($dbh,"SELECT * FROM filter_instances");
 
 
-my @filterlist_ref = get_records_sql($dbh,"SELECT * FROM Filter_list where type=0");
+my @filterlist_ref = get_records_sql($dbh,"SELECT * FROM filter_list where type=0");
 
 
 my %filters;
 my %filters;
 my %dyn_filters;
 my %dyn_filters;
 
 
-my $max_filter_rec = get_record_sql($dbh,"SELECT MAX(id) FROM Filter_list");
+my $max_filter_rec = get_record_sql($dbh,"SELECT MAX(id) FROM filter_list");
 my $max_filter_id = $max_filter_rec->{id};
 my $max_filter_id = $max_filter_rec->{id};
 
 
 my $dyn_filters_base = $max_filter_id+1000;
 my $dyn_filters_base = $max_filter_id+1000;
@@ -553,14 +553,14 @@ log_debug($gate_ident."Filters status:". Dumper(\%filters));
 log_debug($gate_ident."DNS-filters status:". Dumper(\%dyn_filters));
 log_debug($gate_ident."DNS-filters status:". Dumper(\%dyn_filters));
 
 
 #clean unused filter records
 #clean unused filter records
-do_sql($dbh,"DELETE FROM Group_filters WHERE group_id NOT IN (SELECT id FROM Group_list)");
-do_sql($dbh,"DELETE FROM Group_filters WHERE filter_id NOT IN (SELECT id FROM Filter_list)");
+do_sql($dbh,"DELETE FROM group_filters WHERE group_id NOT IN (SELECT id FROM group_list)");
+do_sql($dbh,"DELETE FROM group_filters WHERE filter_id NOT IN (SELECT id FROM filter_list)");
 
 
-my @groups_list = get_records_sql($dbh,"SELECT * FROM Group_list");
+my @groups_list = get_records_sql($dbh,"SELECT * FROM group_list");
 my %groups;
 my %groups;
 foreach my $group (@groups_list) { $groups{'group_'.$group->{id}}=$group; }
 foreach my $group (@groups_list) { $groups{'group_'.$group->{id}}=$group; }
 
 
-my @grouplist_ref = get_records_sql($dbh,"SELECT `group_id`,`filter_id`,`order`,`action` FROM Group_filters ORDER BY Group_filters.group_id,Group_filters.order");
+my @grouplist_ref = get_records_sql($dbh,"SELECT group_id,filter_id,rule_order,action FROM group_filters ORDER BY group_filters.group_id,group_filters.rule_order");
 
 
 my %group_filters;
 my %group_filters;
 my $index = 0;
 my $index = 0;
@@ -1041,7 +1041,7 @@ $pm->wait_all_children;
 #clear changed
 #clear changed
 if ($all_ok) {
 if ($all_ok) {
     foreach my $row (@changes_found) {
     foreach my $row (@changes_found) {
-        do_sql($dbh,"UPDATE User_auth SET changed=0 WHERE id=".$row->{id});
+        do_sql($dbh,"UPDATE user_auth SET changed=0 WHERE id=".$row->{id});
         }
         }
     }
     }
 
 

+ 1 - 1
scripts/sync_mikrotik_poe_monitor.pl

@@ -41,7 +41,7 @@ my $switch_ip=$device->{ip};
 
 
 my @cmd_list=();
 my @cmd_list=();
 
 
-my @auth_list = get_records_sql($dbh,"SELECT DP.port,AU.ip,AU.dns_name FROM `device_ports` AS DP, `User_auth` as AU, `connections` as C WHERE DP.id=C.port_id and C.auth_id=AU.id and AU.deleted=0 and AU.nagios=1 and C.device_id=".$device->{id}."");
+my @auth_list = get_records_sql($dbh,"SELECT DP.port,AU.ip,AU.dns_name FROM device_ports AS DP, user_auth as AU, connections as C WHERE DP.id=C.port_id and C.auth_id=AU.id and AU.deleted=0 and AU.nagios=1 and C.device_id=".$device->{id}."");
 
 
 my %work_list;
 my %work_list;
 foreach my $auth (@auth_list) {
 foreach my $auth (@auth_list) {

+ 2 - 2
scripts/updates/2-8-0/after_sql.pl

@@ -40,7 +40,7 @@ if (!$force and $upgrade_from ne $config_ref{version}) { print "Illegal version.
 
 
 print 'Apply patch for version: '.$config_ref{version}.' upgrade to: '.$this_release."\n";
 print 'Apply patch for version: '.$config_ref{version}.' upgrade to: '.$this_release."\n";
 
 
-my @authlist_ref = get_records_sql($dbh,"SELECT * FROM User_auth WHERE dns_name>''" );
+my @authlist_ref = get_records_sql($dbh,"SELECT * FROM user_auth WHERE dns_name>''" );
 
 
 my $total = scalar @authlist_ref;
 my $total = scalar @authlist_ref;
 
 
@@ -85,7 +85,7 @@ foreach my $row (@authlist_ref) {
 
 
     # --- Обновляем, только если имя изменилось
     # --- Обновляем, только если имя изменилось
     if (exists $new->{dns_name} && $new->{dns_name} ne $original_name) {
     if (exists $new->{dns_name} && $new->{dns_name} ne $original_name) {
-        do_sql($dbh, 'UPDATE User_auth SET dns_name = ? WHERE id = ?', $new->{dns_name}, $row->{id});
+        do_sql($dbh, 'UPDATE user_auth SET dns_name = ? WHERE id = ?', $new->{dns_name}, $row->{id});
     }
     }
 }
 }
 
 

+ 2 - 2
scripts/updates/2-9-0/config_options.sql

@@ -1,2 +1,2 @@
-UPDATE `config_options` SET `description.russian` = 'Отправлять e-mail уведомления' WHERE `config_options`.`id` = 51;
-UPDATE `config_options` SET `description.english` = 'Send e-mail notifications' WHERE `config_options`.`id` = 51;
+UPDATE `config_options` SET description_russian = 'Отправлять e-mail уведомления' WHERE `config_options`.`id` = 51;
+UPDATE `config_options` SET description_english = 'Send e-mail notifications' WHERE `config_options`.`id` = 51;

+ 78 - 0
scripts/updates/3-0-1/migration.msql

@@ -0,0 +1,78 @@
+-- Переименование таблиц в нижний регистр
+
+RENAME TABLE
+  Customers TO customers,
+  User_auth TO user_auth,
+  User_list TO user_list,
+  User_stats TO user_stats,
+  User_stats_full TO user_stats_full,
+  User_auth_alias TO user_auth_alias,
+  Wan_stats TO wan_stats,
+  Traffic_detail TO traffic_detail,
+  Unknown_mac TO unknown_mac,
+  Group_filters TO group_filters,
+  Group_list TO group_list,
+  Filter_list TO filter_list,
+  Queue_list TO queue_list;
+
+ALTER TABLE wan_stats
+  CHANGE COLUMN `in` bytes_in BIGINT NOT NULL DEFAULT 0,
+  CHANGE COLUMN `out` bytes_out BIGINT NOT NULL DEFAULT 0;
+
+ALTER TABLE group_filters
+  CHANGE COLUMN `order` rule_order INTEGER NOT NULL DEFAULT 0;
+
+ALTER TABLE user_auth
+  CHANGE COLUMN `client-id` client_id VARCHAR(250);
+
+ALTER TABLE dhcp_log
+  CHANGE COLUMN `client-id` client_id VARCHAR(250),
+  CHANGE COLUMN `circuit-id` circuit_id VARCHAR(255),
+  CHANGE COLUMN `remote-id` remote_id VARCHAR(255);
+
+-- Точки в именах
+ALTER TABLE acl
+  CHANGE COLUMN `description.english` description_english VARCHAR(250) NOT NULL,
+  CHANGE COLUMN `description.russian` description_russian VARCHAR(250) NOT NULL;
+
+ALTER TABLE config_options
+  CHANGE COLUMN `description.english` description_english TEXT,
+  CHANGE COLUMN `description.russian` description_russian TEXT;
+
+ALTER TABLE device_types
+  CHANGE COLUMN `name.russian` name_russian VARCHAR(50),
+  CHANGE COLUMN `name.english` name_english VARCHAR(50);
+
+-- timestamp → ts
+ALTER TABLE dhcp_log        CHANGE COLUMN `timestamp` ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE dhcp_queue      CHANGE COLUMN `timestamp` ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE dns_cache       CHANGE COLUMN `timestamp` ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE mac_history     CHANGE COLUMN `timestamp` ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE user_auth       CHANGE COLUMN `timestamp` ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE user_stats      CHANGE COLUMN `timestamp` ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE user_stats_full CHANGE COLUMN `timestamp` ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE worklog         CHANGE COLUMN `timestamp` ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
+
+-- time/date → ts
+ALTER TABLE wan_stats       CHANGE COLUMN `time` ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE remote_syslog   CHANGE COLUMN `date` ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
+
+-- comment → description
+ALTER TABLE acl             CHANGE COLUMN `comment` description VARCHAR(250);
+ALTER TABLE building        CHANGE COLUMN `comment` description VARCHAR(250);
+ALTER TABLE devices         CHANGE COLUMN `comment` description VARCHAR(255);
+ALTER TABLE filter_instances CHANGE COLUMN `comment` description VARCHAR(200);
+ALTER TABLE filter_list     CHANGE COLUMN `comment` description VARCHAR(250);
+ALTER TABLE group_list      CHANGE COLUMN `comment` description VARCHAR(250);
+ALTER TABLE ou              CHANGE COLUMN `comment` description VARCHAR(250);
+ALTER TABLE subnets         CHANGE COLUMN `comment` description VARCHAR(250);
+ALTER TABLE user_list       CHANGE COLUMN `comment` description VARCHAR(255);
+ALTER TABLE vendors         CHANGE COLUMN `comment` description VARCHAR(255);
+
+-- ⚠️ user_auth.comments → description
+ALTER TABLE user_auth       CHANGE COLUMN `comments` description VARCHAR(250);
+
+-- type → уточнённые имена
+ALTER TABLE config_options  CHANGE COLUMN `type` option_type VARCHAR(100) NOT NULL;
+ALTER TABLE dns_queue       CHANGE COLUMN `type` operation_type VARCHAR(10) NOT NULL DEFAULT 'add';
+ALTER TABLE filter_list     CHANGE COLUMN `type` filter_type SMALLINT NOT NULL DEFAULT 0;

+ 70 - 0
scripts/updates/3-0-1/migration.psql

@@ -0,0 +1,70 @@
+-- Переименование таблиц в нижний регистр (snake_case)
+
+ALTER TABLE "Customers" RENAME TO customers;
+ALTER TABLE "User_auth" RENAME TO user_auth;
+ALTER TABLE "User_list" RENAME TO user_list;
+ALTER TABLE "User_stats" RENAME TO user_stats;
+ALTER TABLE "User_stats_full" RENAME TO user_stats_full;
+ALTER TABLE "User_auth_alias" RENAME TO user_auth_alias;
+ALTER TABLE "Wan_stats" RENAME TO wan_stats;
+ALTER TABLE "Traffic_detail" RENAME TO traffic_detail;
+ALTER TABLE "Unknown_mac" RENAME TO unknown_mac;
+ALTER TABLE "Group_filters" RENAME TO group_filters;
+ALTER TABLE "Group_list" RENAME TO group_list;
+ALTER TABLE "Filter_list" RENAME TO filter_list;
+ALTER TABLE "Queue_list" RENAME TO queue_list;
+
+-- wan_stats: in/out → bytes_in/bytes_out
+ALTER TABLE wan_stats RENAME COLUMN "in" TO bytes_in;
+ALTER TABLE wan_stats RENAME COLUMN "out" TO bytes_out;
+
+-- group_filters: order → rule_order
+ALTER TABLE group_filters RENAME COLUMN "order" TO rule_order;
+
+-- user_auth: client-id → client_id
+ALTER TABLE user_auth RENAME COLUMN "client-id" TO client_id;
+
+-- dhcp_log: дефисы → подчёркивания
+ALTER TABLE dhcp_log RENAME COLUMN "client-id" TO client_id;
+ALTER TABLE dhcp_log RENAME COLUMN "circuit-id" TO circuit_id;
+ALTER TABLE dhcp_log RENAME COLUMN "remote-id" TO remote_id;
+
+-- Точки в именах → подчёркивания
+ALTER TABLE acl RENAME COLUMN "description.english" TO description_english;
+ALTER TABLE acl RENAME COLUMN "description.russian" TO description_russian;
+ALTER TABLE config_options RENAME COLUMN "description.english" TO description_english;
+ALTER TABLE config_options RENAME COLUMN "description.russian" TO description_russian;
+ALTER TABLE device_types RENAME COLUMN "name.russian" TO name_russian;
+ALTER TABLE device_types RENAME COLUMN "name.english" TO name_english;
+
+-- timestamp → ts
+ALTER TABLE dhcp_log RENAME COLUMN timestamp TO ts;
+ALTER TABLE dhcp_queue RENAME COLUMN timestamp TO ts;
+ALTER TABLE dns_cache RENAME COLUMN timestamp TO ts;
+ALTER TABLE mac_history RENAME COLUMN timestamp TO ts;
+ALTER TABLE user_auth RENAME COLUMN timestamp TO ts;
+ALTER TABLE user_stats RENAME COLUMN timestamp TO ts;
+ALTER TABLE user_stats_full RENAME COLUMN timestamp TO ts;
+ALTER TABLE worklog RENAME COLUMN timestamp TO ts;
+
+-- time/date → ts
+ALTER TABLE wan_stats RENAME COLUMN time TO ts;
+ALTER TABLE remote_syslog RENAME COLUMN date TO ts;
+
+-- comment → description (во всех таблицах)
+ALTER TABLE acl RENAME COLUMN comment TO description;
+ALTER TABLE building RENAME COLUMN comment TO description;
+ALTER TABLE devices RENAME COLUMN comment TO description;
+ALTER TABLE filter_instances RENAME COLUMN comment TO description;
+ALTER TABLE filter_list RENAME COLUMN comment TO description;
+ALTER TABLE group_list RENAME COLUMN comment TO description;
+ALTER TABLE ou RENAME COLUMN comment TO description;
+ALTER TABLE subnets RENAME COLUMN comment TO description;
+ALTER TABLE user_auth RENAME COLUMN comments TO description;
+ALTER TABLE user_list RENAME COLUMN comment TO description;
+ALTER TABLE vendors RENAME COLUMN comment TO description;
+
+-- type → уточнённые имена
+ALTER TABLE config_options RENAME COLUMN type TO option_type;
+ALTER TABLE dns_queue RENAME COLUMN type TO operation_type;
+ALTER TABLE filter_list RENAME COLUMN type TO filter_type;

+ 2 - 0
scripts/updates/db-patch-mysql-utf8.pl

@@ -15,6 +15,8 @@ use eyelib::common;
 use strict;
 use strict;
 use warnings;
 use warnings;
 
 
+exit 100 if ($config_ref{DBTYPE} and $config_ref{DBTYPE} ne 'mysql');
+
 my @tables = get_records_sql($dbh,"SHOW TABLES");
 my @tables = get_records_sql($dbh,"SHOW TABLES");
 my @db_tables=();
 my @db_tables=();
 foreach my $table_ref (@tables) {
 foreach my $table_ref (@tables) {

+ 14 - 2
scripts/updates/upgrade.pl

@@ -50,6 +50,10 @@ if ($eye_release eq $config_ref{version}) { print "Already updated!\n"; exit; }
 
 
 print 'Current version: '.$config_ref{version}.' upgrade to: '.$eye_release."\n";
 print 'Current version: '.$config_ref{version}.' upgrade to: '.$eye_release."\n";
 
 
+#1 - mysql
+#0 - pgsql
+my $db_type = ($config_ref{DBTYPE} eq 'mysql');
+
 my $old_version_index = $old_releases_h{$config_ref{version}} + 1;
 my $old_version_index = $old_releases_h{$config_ref{version}} + 1;
 my $stage = 1;
 my $stage = 1;
 
 
@@ -73,7 +77,15 @@ for (my $i=$old_version_index; $i < scalar @old_releases; $i++) {
             }
             }
         }
         }
     #change database schema
     #change database schema
-    my @sql_patches = glob($dir_name.'/*.sql');
+    my @sql_patches;
+    if ($db_type) {
+        my @sql_patches1 = glob($dir_name.'/*.sql');
+        my @sql_patches1 = glob($dir_name.'/*.msql');
+        push(@sql_patches,@sql_patches1);
+        push(@sql_patches,@sql_patches2);
+        } else {
+        @sql_patches = glob($dir_name.'/*.psql');
+        }
     if (@sql_patches and scalar @sql_patches) {
     if (@sql_patches and scalar @sql_patches) {
         foreach my $patch (@sql_patches) {
         foreach my $patch (@sql_patches) {
             next if (!$patch or ! -e $patch);
             next if (!$patch or ! -e $patch);
@@ -102,7 +114,7 @@ for (my $i=$old_version_index; $i < scalar @old_releases; $i++) {
             }
             }
         }
         }
     #change version
     #change version
-    do_sql($dbh,'UPDATE version SET `version`="'.$old_releases[$i].'"');
+    do_sql($dbh,'UPDATE version SET version="'.$old_releases[$i].'"');
 }
 }
 
 
 print "Done!\n";
 print "Done!\n";

+ 3 - 3
scripts/utils/bind/print-dns-zones.pl

@@ -25,7 +25,7 @@ my $named_db_path='/etc/bind/masters';
 my $DNS1=$config_ref{dns_server};
 my $DNS1=$config_ref{dns_server};
 my $DNS1_IP=$config_ref{dns_server};
 my $DNS1_IP=$config_ref{dns_server};
 
 
-my $dns_server_record = get_record_sql($dbh,"SELECT id,ip,dns_name FROM User_auth WHERE deleted=0 AND ip='".$DNS1_IP."'");
+my $dns_server_record = get_record_sql($dbh,"SELECT id,ip,dns_name FROM user_auth WHERE deleted=0 AND ip='".$DNS1_IP."'");
 
 
 if ($dns_server_record and $dns_server_record->{dns_name}) { 
 if ($dns_server_record and $dns_server_record->{dns_name}) { 
     my $ns1=$dns_server_record->{dns_name};
     my $ns1=$dns_server_record->{dns_name};
@@ -45,7 +45,7 @@ my $named_conf=$named_root.'/etc/bind/named.dynamic';
 
 
 my %zones;
 my %zones;
 
 
-my $sSQL="SELECT id,ou_id,ip,dns_name,dhcp_hostname,dns_ptr_only FROM User_auth WHERE deleted=0 AND ip>'' AND (dns_name>'' OR dhcp_hostname>'') AND dns_name NOT LIKE '%.' ORDER by ip_int;";
+my $sSQL="SELECT id,ou_id,ip,dns_name,dhcp_hostname,dns_ptr_only FROM user_auth WHERE deleted=0 AND ip>'' AND (dns_name>'' OR dhcp_hostname>'') AND dns_name NOT LIKE '%.' ORDER by ip_int;";
 my @authlist_ref = get_records_sql($dbh,$sSQL);
 my @authlist_ref = get_records_sql($dbh,$sSQL);
 foreach my $row (@authlist_ref) {
 foreach my $row (@authlist_ref) {
 next if (!$row);
 next if (!$row);
@@ -71,7 +71,7 @@ next if (!$office_networks->match_string($ip));
 my $default_name=$dns_name;
 my $default_name=$dns_name;
 $zones{$domain_name}{A}{$default_name}=$ip;
 $zones{$domain_name}{A}{$default_name}=$ip;
 
 
-my @dns_aliases=get_records_sql($dbh,"SELECT * FROM User_auth_alias WHERE auth_id=$row->{id} AND alias>'' AND alias NOT LIKE '%.' ORDER BY alias");
+my @dns_aliases=get_records_sql($dbh,"SELECT * FROM user_auth_alias WHERE auth_id=$row->{id} AND alias>'' AND alias NOT LIKE '%.' ORDER BY alias");
 foreach my $alias (@dns_aliases) {
 foreach my $alias (@dns_aliases) {
         my $dns_alias = trim($alias->{alias});
         my $dns_alias = trim($alias->{alias});
 #        $dns_alias =~s/$domain_name//i;
 #        $dns_alias =~s/$domain_name//i;

+ 9 - 9
scripts/utils/import/import_auth.pl

@@ -93,13 +93,13 @@ if (!$auth_network) {
     next;
     next;
     }
     }
 
 
-my $search_sql = 'SELECT * FROM User_auth WHERE ip="'.$record->{ip}.'" and deleted=0 ORDER BY last_found DESC';
+my $search_sql = 'SELECT * FROM user_auth WHERE ip="'.$record->{ip}.'" and deleted=0 ORDER BY last_found DESC';
 $record->{ip_int}=StrToIp($record->{ip});
 $record->{ip_int}=StrToIp($record->{ip});
 if (!exists($record->{'mac'})) {
 if (!exists($record->{'mac'})) {
     delete $record->{'mac'};
     delete $record->{'mac'};
     } else {
     } else {
     $record->{mac}=mac_splitted(isc_mac_simplify($record->{mac}));
     $record->{mac}=mac_splitted(isc_mac_simplify($record->{mac}));
-    $search_sql = 'SELECT * FROM User_auth WHERE ip="'.$record->{ip}.'" and mac="'.$record->{mac}.'" and deleted=0 ORDER BY last_found DESC';
+    $search_sql = 'SELECT * FROM user_auth WHERE ip="'.$record->{ip}.'" and mac="'.$record->{mac}.'" and deleted=0 ORDER BY last_found DESC';
     }
     }
 
 
 print "Импортируем:\n";
 print "Импортируем:\n";
@@ -118,12 +118,12 @@ if (exists $record->{dns_name}) {
 #search actual record
 #search actual record
 my $auth_record = get_record_sql($dbh,$search_sql);
 my $auth_record = get_record_sql($dbh,$search_sql);
 if ($auth_record) {
 if ($auth_record) {
-    update_record($dbh,'User_auth',$record,"id=".$auth_record->{id});
+    update_record($dbh,'user_auth',$record,"id=".$auth_record->{id});
     print "URL: <a href='".$config_ref{stat_url}."/admin/users/edituser.php?id=".$auth_record->{user_id}."'>".$auth_record->{user_id}."</a><br>\n";
     print "URL: <a href='".$config_ref{stat_url}."/admin/users/edituser.php?id=".$auth_record->{user_id}."'>".$auth_record->{user_id}."</a><br>\n";
     if (exists $record->{dns_name}) {
     if (exists $record->{dns_name}) {
         my $user_info;
         my $user_info;
         $user_info->{login}=$record->{dns_name};
         $user_info->{login}=$record->{dns_name};
-        update_record($dbh,'User_list',$user_info,"id=".$auth_record->{user_id});
+        update_record($dbh,'user_list',$user_info,"id=".$auth_record->{user_id});
         my $device;
         my $device;
         $device->{device_name}=$record->{dns_name};
         $device->{device_name}=$record->{dns_name};
         update_record($dbh,'devices',$device,"user_id=".$auth_record->{user_id});
         update_record($dbh,'devices',$device,"user_id=".$auth_record->{user_id});
@@ -131,7 +131,7 @@ if ($auth_record) {
     if (exists $record->{comments}) {
     if (exists $record->{comments}) {
         my $user_info;
         my $user_info;
         $user_info->{fio}=$record->{comments};
         $user_info->{fio}=$record->{comments};
-        update_record($dbh,'User_list',$user_info,"id=".$auth_record->{user_id});
+        update_record($dbh,'user_list',$user_info,"id=".$auth_record->{user_id});
         }
         }
     next;
     next;
     }
     }
@@ -144,14 +144,14 @@ if (!$res_id) {
     db_log_error($dbh,"Error creating an ip address record for:\t\t".Dumper($dhcp_record));
     db_log_error($dbh,"Error creating an ip address record for:\t\t".Dumper($dhcp_record));
     next;
     next;
     }
     }
-update_record($dbh,'User_auth',$record,"id=".$res_id);
-$auth_record = get_record_sql($dbh,'SELECT * FROM User_auth where id='.$res_id);
+update_record($dbh,'user_auth',$record,"id=".$res_id);
+$auth_record = get_record_sql($dbh,'SELECT * FROM user_auth where id='.$res_id);
 if ($auth_record) {
 if ($auth_record) {
     print "URL: <a href='".$config_ref{stat_url}."/admin/users/edituser.php?id=".$auth_record->{user_id}."'>".$auth_record->{user_id}."</a><br>\n";
     print "URL: <a href='".$config_ref{stat_url}."/admin/users/edituser.php?id=".$auth_record->{user_id}."'>".$auth_record->{user_id}."</a><br>\n";
     if (exists $record->{dns_name}) {
     if (exists $record->{dns_name}) {
         my $user_info;
         my $user_info;
         $user_info->{login}=$record->{dns_name};
         $user_info->{login}=$record->{dns_name};
-        update_record($dbh,'User_list',$user_info,"id=".$auth_record->{user_id});
+        update_record($dbh,'user_list',$user_info,"id=".$auth_record->{user_id});
         my $device;
         my $device;
         $device->{device_name}=$record->{dns_name};
         $device->{device_name}=$record->{dns_name};
         update_record($dbh,'devices',$device,"user_id=".$auth_record->{user_id});
         update_record($dbh,'devices',$device,"user_id=".$auth_record->{user_id});
@@ -159,7 +159,7 @@ if ($auth_record) {
     if (exists $record->{comments}) {
     if (exists $record->{comments}) {
         my $user_info;
         my $user_info;
         $user_info->{fio}=$record->{comments};
         $user_info->{fio}=$record->{comments};
-        update_record($dbh,'User_list',$user_info,"id=".$auth_record->{user_id});
+        update_record($dbh,'user_list',$user_info,"id=".$auth_record->{user_id});
         }
         }
     }
     }
 }
 }

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 155 - 14
scripts/utils/mac-oids/manuf.csv


+ 1 - 1
scripts/utils/oxidized/print_devices_oxi.pl

@@ -29,7 +29,7 @@ $device = netdev_set_auth($device);
 my $oxi_model = 'dcnos';
 my $oxi_model = 'dcnos';
 my $comware_cmdline = '';
 my $comware_cmdline = '';
 my $vendor = get_record_sql($dbh,"SELECT * FROM vendors WHERE id=".$device->{vendor_id});
 my $vendor = get_record_sql($dbh,"SELECT * FROM vendors WHERE id=".$device->{vendor_id});
-my $model = get_record_sql($dbh,"SELECT * FROM `device_models` WHERE id=".$device->{device_model_id});
+my $model = get_record_sql($dbh,"SELECT * FROM device_models WHERE id=".$device->{device_model_id});
 my $building = get_record_sql($dbh,"SELECT * FROM building WHERE id=".$device->{building_id});
 my $building = get_record_sql($dbh,"SELECT * FROM building WHERE id=".$device->{building_id});
 if ($vendor->{name} =~/zyxel/i) { $oxi_model = 'zynoscli'; }
 if ($vendor->{name} =~/zyxel/i) { $oxi_model = 'zynoscli'; }
 if ($vendor->{name} =~/snr/i) { $oxi_model = 'dcnos'; }
 if ($vendor->{name} =~/snr/i) { $oxi_model = 'dcnos'; }

+ 8 - 8
scripts/utils/parse_flow.pl

@@ -52,7 +52,7 @@ my $users = new Net::Patricia;
 InitSubnets();
 InitSubnets();
 
 
 #get userid list
 #get userid list
-my @auth_list_ref = get_records_sql($dbh,"SELECT id,ip,user_id,save_traf FROM User_auth where deleted=0 ORDER by user_id");
+my @auth_list_ref = get_records_sql($dbh,"SELECT id,ip,user_id,save_traf FROM user_auth where deleted=0 ORDER by user_id");
 
 
 my %user_stats;
 my %user_stats;
 
 
@@ -261,7 +261,7 @@ db_log_debug($f_dbh,"Stopped child $child_count analyze data") if ($debug);
 
 
 if (scalar(@detail_traffic)) {
 if (scalar(@detail_traffic)) {
         db_log_debug($f_dbh,"Start write traffic detail to DB. ".scalar @detail_traffic." lines count") if ($debug);
         db_log_debug($f_dbh,"Start write traffic detail to DB. ".scalar @detail_traffic." lines count") if ($debug);
-	batch_db_sql_cached("INSERT INTO Traffic_detail (auth_id,router_id,timestamp,proto,src_ip,dst_ip,src_port,dst_port,bytes,pkt) VALUES(?,?,?,?,?,?,?,?,?,?)",\@detail_traffic);
+	batch_db_sql_cached("INSERT INTO traffic_detail (auth_id,router_id,ts,proto,src_ip,dst_ip,src_port,dst_port,bytes,pkt) VALUES(?,?,?,?,?,?,?,?,?,?)",\@detail_traffic);
         db_log_debug($f_dbh,"Write traffic detail to DB stopped") if ($debug);
         db_log_debug($f_dbh,"Write traffic detail to DB stopped") if ($debug);
 	}
 	}
 
 
@@ -295,27 +295,27 @@ if (!$auth_id) {
     $auth_id=new_auth($m_dbh,$user_ip);
     $auth_id=new_auth($m_dbh,$user_ip);
     $user_stats{$user_ip}{auth_id}=$auth_id;
     $user_stats{$user_ip}{auth_id}=$auth_id;
     #fix traffic detail for new users
     #fix traffic detail for new users
-    push(@batch_sql_traf,"UPDATE Traffic_detail set auth_id=$auth_id WHERE auth_id=0 AND `timestamp`>=$hour_date1 AND `timestamp`<$hour_date2 AND (src_ip=$user_ip_aton OR dst_ip=$user_ip_aton)");
+    push(@batch_sql_traf,"UPDATE traffic_detail set auth_id=$auth_id WHERE auth_id=0 AND ts>=$hour_date1 AND ts<$hour_date2 AND (src_ip=$user_ip_aton OR dst_ip=$user_ip_aton)");
     }
     }
 
 
 #skip empty stats
 #skip empty stats
 if ($user_stats{$user_ip}{in} + $user_stats{$user_ip}{out} ==0) { next; }
 if ($user_stats{$user_ip}{in} + $user_stats{$user_ip}{out} ==0) { next; }
 
 
 #current stats
 #current stats
-my $tSQL="INSERT INTO User_stats_full (timestamp,auth_id,router_id,byte_in,byte_out,pkt_in,pkt_out,step) VALUES($flow_date,'$auth_id','$router_id','$user_stats{$user_ip}{in}','$user_stats{$user_ip}{out}','$user_stats{$user_ip}{pkt_in}','$user_stats{$user_ip}{pkt_out}','$timeshift')";
+my $tSQL="INSERT INTO user_stats_full (ts,auth_id,router_id,byte_in,byte_out,pkt_in,pkt_out,step) VALUES($flow_date,'$auth_id','$router_id','$user_stats{$user_ip}{in}','$user_stats{$user_ip}{out}','$user_stats{$user_ip}{pkt_in}','$user_stats{$user_ip}{pkt_out}','$timeshift')";
 push (@batch_sql_traf,$tSQL);
 push (@batch_sql_traf,$tSQL);
 
 
 #last found timestamp
 #last found timestamp
-$tSQL="UPDATE User_auth SET `last_found`=$flow_date WHERE id='$auth_id'";
+$tSQL="UPDATE user_auth SET last_found=$flow_date WHERE id='$auth_id'";
 push (@batch_sql_traf,$tSQL);
 push (@batch_sql_traf,$tSQL);
 
 
 #hour stats
 #hour stats
 # get current stats
 # get current stats
-my $sql = "SELECT id, byte_in, byte_out FROM User_stats WHERE `timestamp`>=$hour_date1 AND `timestamp`<$hour_date2 AND router_id=$router_id AND auth_id=$auth_id";
+my $sql = "SELECT id, byte_in, byte_out FROM user_stats WHERE ts>=$hour_date1 AND ts<$hour_date2 AND router_id=$router_id AND auth_id=$auth_id";
 my $hour_stat = get_record_sql($m_dbh,$sql);
 my $hour_stat = get_record_sql($m_dbh,$sql);
 
 
 if (!$hour_stat) {
 if (!$hour_stat) {
-    my $dSQL="INSERT INTO User_stats (timestamp,auth_id,router_id,byte_in,byte_out) VALUES($flow_date,'$auth_id','$router_id','$user_stats{$user_ip}{in}','$user_stats{$user_ip}{out}')";
+    my $dSQL="INSERT INTO user_stats (ts,auth_id,router_id,byte_in,byte_out) VALUES($flow_date,'$auth_id','$router_id','$user_stats{$user_ip}{in}','$user_stats{$user_ip}{out}')";
     push (@batch_sql_traf,$dSQL);
     push (@batch_sql_traf,$dSQL);
     next;
     next;
     }
     }
@@ -324,7 +324,7 @@ if (!$hour_stat->{byte_in}) { $hour_stat->{byte_in}=0; }
 if (!$hour_stat->{byte_out}) { $hour_stat->{byte_out}=0; }
 if (!$hour_stat->{byte_out}) { $hour_stat->{byte_out}=0; }
 $hour_stat->{byte_in} += $user_stats{$user_ip}{in};
 $hour_stat->{byte_in} += $user_stats{$user_ip}{in};
 $hour_stat->{byte_out} += $user_stats{$user_ip}{out};
 $hour_stat->{byte_out} += $user_stats{$user_ip}{out};
-$tSQL="UPDATE User_stats SET byte_in='".$hour_stat->{byte_in}."', byte_out='".$hour_stat->{byte_out}."' WHERE id='".$auth_id."' AND router_id='".$router_id."'";
+$tSQL="UPDATE user_stats SET byte_in='".$hour_stat->{byte_in}."', byte_out='".$hour_stat->{byte_out}."' WHERE id='".$auth_id."' AND router_id='".$router_id."'";
 push (@batch_sql_traf,$tSQL);
 push (@batch_sql_traf,$tSQL);
 }
 }
 
 

+ 1 - 1
scripts/utils/print-ou-ip.pl

@@ -22,7 +22,7 @@ my $ou_filter=" and L.ou_id=$OU_ID ";
 if (!$OU_ID) { $ou_filter=''; }
 if (!$OU_ID) { $ou_filter=''; }
 
 
 #get userid list
 #get userid list
-my $user_auth_list = $dbh->prepare( "SELECT A.ip,A.ip_int,A.dns_name FROM User_auth as A, User_list as L where L.id=A.user_id and A.deleted=0 $ou_filter ORDER by ip_int" );
+my $user_auth_list = $dbh->prepare( "SELECT A.ip,A.ip_int,A.dns_name FROM user_auth as A, user_list as L where L.id=A.user_id and A.deleted=0 $ou_filter ORDER by ip_int" );
 if ( !defined $user_auth_list ) { die "Cannot prepare statement: $DBI::errstr\n"; }
 if ( !defined $user_auth_list ) { die "Cannot prepare statement: $DBI::errstr\n"; }
 
 
 $user_auth_list->execute;
 $user_auth_list->execute;

+ 1 - 1
scripts/utils/radius/print_huntgroups.pl

@@ -34,7 +34,7 @@ my %huntgroups=(
 
 
 my @device_list = get_records_sql($dbh,"SELECT * FROM devices WHERE device_type<=2 ORDER BY device_name" );
 my @device_list = get_records_sql($dbh,"SELECT * FROM devices WHERE device_type<=2 ORDER BY device_name" );
 foreach my $device (sort @device_list) {
 foreach my $device (sort @device_list) {
-my @auth_list = get_records_sql($dbh,"SELECT * FROM User_auth WHERE deleted=0 AND user_id=".$device->{user_id});
+my @auth_list = get_records_sql($dbh,"SELECT * FROM user_auth WHERE deleted=0 AND user_id=".$device->{user_id});
     print "#$device->{device_name}\n";
     print "#$device->{device_name}\n";
     foreach my $auth (sort @auth_list) {
     foreach my $auth (sort @auth_list) {
     if (exists $huntgroups{$device->{vendor_id}}) {
     if (exists $huntgroups{$device->{vendor_id}}) {

+ 3 - 3
scripts/utils/reaply_rules.pl

@@ -37,7 +37,7 @@ my $group = get_record_sql($dbh,"SELECT * FROM OU WHERE id=$group_id");
 print "Analyzed rules for group id: $group_id name: $group->{ou_name}\n";
 print "Analyzed rules for group id: $group_id name: $group->{ou_name}\n";
 
 
 #get userid list
 #get userid list
-my $sSQL="SELECT * FROM User_auth WHERE ip IS NOT NULL and mac IS NOT NULL and deleted=0";
+my $sSQL="SELECT * FROM user_auth WHERE ip IS NOT NULL and mac IS NOT NULL and deleted=0";
 
 
 my @users = get_records_sql($dbh,$sSQL);
 my @users = get_records_sql($dbh,$sSQL);
 foreach my $row (@users) {
 foreach my $row (@users) {
@@ -47,9 +47,9 @@ if ($new_user->{ou_id} ne $group_id) { next; }
 if ($new_user->{ou_id} ne $row->{ou_id}) {
 if ($new_user->{ou_id} ne $row->{ou_id}) {
     print "MOVED: $row->{ip} $row->{mac} $row->{comments} to $new_user->{ou_id}\n";
     print "MOVED: $row->{ip} $row->{mac} $row->{comments} to $new_user->{ou_id}\n";
     my $auth->{ou_id}=$new_user->{ou_id};
     my $auth->{ou_id}=$new_user->{ou_id};
-    update_record($dbh,"User_auth",$auth,"id=".$row->{id});
+    update_record($dbh,"user_auth",$auth,"id=".$row->{id});
     my $user->{ou_id}=$new_user->{ou_id};
     my $user->{ou_id}=$new_user->{ou_id};
-    update_record($dbh,"User_list",$user,"id=".$row->{user_id});
+    update_record($dbh,"user_list",$user,"id=".$row->{user_id});
     }
     }
 }
 }
 
 

+ 2 - 2
scripts/utils/scan_ipcam.pl

@@ -70,7 +70,7 @@ $result->{text} = trim($result->{text});
 return $result;
 return $result;
 }
 }
 
 
-my @auth_list=get_records_sql($dbh,'SELECT * FROM User_auth WHERE deleted=0 and nagios=1');
+my @auth_list=get_records_sql($dbh,'SELECT * FROM user_auth WHERE deleted=0 and nagios=1');
 
 
 ##################################### User auth analyze ################################################
 ##################################### User auth analyze ################################################
 
 
@@ -80,7 +80,7 @@ if (scalar(@auth_list)>0) {
         my $ip = $auth->{'ip'};
         my $ip = $auth->{'ip'};
         $ip =~s/\/\d+$//g;
         $ip =~s/\/\d+$//g;
         #get user
         #get user
-        my $login = get_record_sql($dbh,"SELECT * FROM User_list WHERE id=".$auth->{'user_id'});
+        my $login = get_record_sql($dbh,"SELECT * FROM user_list WHERE id=".$auth->{'user_id'});
         next if ($login->{ou_id} ne 5);
         next if ($login->{ou_id} ne 5);
 
 
         my $cam_dev = get_record_sql($dbh,"SELECT * FROM devices WHERE user_id=".$auth->{'user_id'});
         my $cam_dev = get_record_sql($dbh,"SELECT * FROM devices WHERE user_id=".$auth->{'user_id'});

+ 2 - 2
scripts/utils/set_port_descr.pl

@@ -29,7 +29,7 @@ use Fcntl qw(:flock);
 open(SELF,"<",$0) or die "Cannot open $0 - $!";
 open(SELF,"<",$0) or die "Cannot open $0 - $!";
 flock(SELF, LOCK_EX|LOCK_NB) or exit 1;
 flock(SELF, LOCK_EX|LOCK_NB) or exit 1;
 
 
-my @auth_list = get_records_sql($dbh,"SELECT A.id,A.user_id,A.ip,A.mac,A.dns_name,A.comments,A.dhcp_hostname,A.WikiName,K.login,K.ou_id FROM User_auth as A, User_list as K WHERE K.id=A.user_id AND A.deleted=0 ORDER BY A.id");
+my @auth_list = get_records_sql($dbh,"SELECT A.id,A.user_id,A.ip,A.mac,A.dns_name,A.comments,A.dhcp_hostname,A.WikiName,K.login,K.ou_id FROM user_auth as A, user_list as K WHERE K.id=A.user_id AND A.deleted=0 ORDER BY A.id");
 
 
 my %auth_ref;
 my %auth_ref;
 foreach my $auth (@auth_list) {
 foreach my $auth (@auth_list) {
@@ -77,7 +77,7 @@ $port_info{$port->{id}}{device_type}=$port->{device_type};
 
 
 my %conn_info;
 my %conn_info;
 
 
-$d_sql="SELECT C.id, C.port_id, C.auth_id FROM connections AS C, User_auth as A WHERE A.id=C.auth_id AND A.deleted=0 ORDER BY C.id";
+$d_sql="SELECT C.id, C.port_id, C.auth_id FROM connections AS C, user_auth as A WHERE A.id=C.auth_id AND A.deleted=0 ORDER BY C.id";
 my @conn_list = get_records_sql($dbh,$d_sql);
 my @conn_list = get_records_sql($dbh,$d_sql);
 
 
 foreach my $conn (@conn_list) {
 foreach my $conn (@conn_list) {

+ 1 - 1
scripts/utils/trap_restart.pl

@@ -75,7 +75,7 @@ my $IP_ATON=StrToIp($host_ip);
 print(TRAPFILE "$date [".$$."] search host by ip [$host_ip] aton: $IP_ATON\n");
 print(TRAPFILE "$date [".$$."] search host by ip [$host_ip] aton: $IP_ATON\n");
 
 
 #get device
 #get device
-my $sSQL="SELECT dns_name FROM User_auth where deleted=0 and ip_int='".$IP_ATON."'";
+my $sSQL="SELECT dns_name FROM user_auth where deleted=0 and ip_int='".$IP_ATON."'";
 my $ret=get_custom_record($dbh,$sSQL);
 my $ret=get_custom_record($dbh,$sSQL);
 my $device_name=$ret->{dns_name};
 my $device_name=$ret->{dns_name};
 print(TRAPFILE "$date [".$$."] name: $device_name\n");
 print(TRAPFILE "$date [".$$."] name: $device_name\n");

+ 1 - 1
scripts/utils/win32/print-dhcpd-netsh.pl

@@ -40,7 +40,7 @@ $nets{$scope_name}->add_string($net);
 }
 }
 
 
 #get userid list
 #get userid list
-my $user_auth_list = $dbh->prepare( "SELECT id,ip,ip_int,mac,dns_name FROM User_auth where deleted=0 $time_filter ORDER by ip_int" );
+my $user_auth_list = $dbh->prepare( "SELECT id,ip,ip_int,mac,dns_name FROM user_auth where deleted=0 $time_filter ORDER by ip_int" );
 if ( !defined $user_auth_list ) { die "Cannot prepare statement: $DBI::errstr\n"; }
 if ( !defined $user_auth_list ) { die "Cannot prepare statement: $DBI::errstr\n"; }
 
 
 $user_auth_list->execute;
 $user_auth_list->execute;

+ 1 - 1
scripts/utils/win32/sync-dhcpd-netsh.pl

@@ -106,7 +106,7 @@ if (!$test_only) {
 ######################################### configuration ###############################################
 ######################################### configuration ###############################################
 
 
 #get userid list
 #get userid list
-my $user_auth_list = $dbh->prepare( "SELECT id,ip,ip_int,mac,clientid,dns_name FROM User_auth where deleted=0 ORDER by ip_int" );
+my $user_auth_list = $dbh->prepare( "SELECT id,ip,ip_int,mac,clientid,dns_name FROM user_auth where deleted=0 ORDER by ip_int" );
 if ( !defined $user_auth_list ) { die "Cannot prepare statement: $DBI::errstr\n"; }
 if ( !defined $user_auth_list ) { die "Cannot prepare statement: $DBI::errstr\n"; }
 
 
 $user_auth_list->execute;
 $user_auth_list->execute;

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels