ソースを参照

Merge pull request #1 from rajven/release/3.0.0

Release/3.0.0
Roman Dmitriev 3 ヶ月 前
コミット
c9a8ca7f56
100 ファイル変更9078 行追加7040 行削除
  1. 0 1
      .gitignore
  2. 29 0
      CHANGELOG.md
  3. 423 8
      README.md
  4. 0 229
      Readme.en.md
  5. 0 225
      Readme.ru.md
  6. 3 11
      docs/addons/dnsmasq.conf
  7. 16 48
      docs/apache/000-default.conf
  8. 3 3
      docs/cron/stat
  9. 205 0
      docs/databases/checkDBschema.pl
  10. 493 0
      docs/databases/checkDBschema.sh
  11. 360 0
      docs/databases/migrate2psql.pl
  12. 583 0
      docs/databases/migrate2psql.sh
  13. 792 0
      docs/databases/mysql/en/create_db.sql
  14. 360 0
      docs/databases/mysql/en/data.sql
  15. 0 0
      docs/databases/mysql/nagios.sql
  16. 1 1
      docs/databases/mysql/reset_admin.sql
  17. 792 0
      docs/databases/mysql/ru/create_db.sql
  18. 359 0
      docs/databases/mysql/ru/data.sql
  19. 677 0
      docs/databases/postgres/en/create_db.sql
  20. 538 0
      docs/databases/postgres/en/data.sql
  21. 7 0
      docs/databases/postgres/reset_admin.sql
  22. 678 0
      docs/databases/postgres/ru/create_db.sql
  23. 531 0
      docs/databases/postgres/ru/data.sql
  24. 1 1
      docs/dhcpd/print-dhcpd.pl
  25. 1 1
      docs/dhcpd/print-dhcpd2.pl
  26. 10 10
      docs/iptables/parse_ulog.pl
  27. 15 15
      docs/iptables/sync_iptables.pl
  28. BIN
      docs/legacy/mysql/2-6-3.tar.gz
  29. BIN
      docs/legacy/mysql/2-7-0.tar.gz
  30. BIN
      docs/legacy/mysql/2-7-1.tar.gz
  31. BIN
      docs/legacy/mysql/2-7-2.tar.gz
  32. BIN
      docs/legacy/mysql/2-7-3.tar.gz
  33. BIN
      docs/legacy/mysql/2-7-4.tar.gz
  34. BIN
      docs/legacy/mysql/2-7-5.tar.gz
  35. BIN
      docs/legacy/mysql/2-7-6.tar.gz
  36. BIN
      docs/legacy/mysql/2-7-7.tar.gz
  37. BIN
      docs/legacy/mysql/2-7-8.tar.gz
  38. BIN
      docs/legacy/mysql/2-7-9.tar.gz
  39. BIN
      docs/legacy/updates/2-6-3.tar.gz
  40. BIN
      docs/legacy/updates/2-7-0.tar.gz
  41. BIN
      docs/legacy/updates/2-7-1.tar.gz
  42. BIN
      docs/legacy/updates/2-7-2.tar.gz
  43. BIN
      docs/legacy/updates/2-7-3.tar.gz
  44. BIN
      docs/legacy/updates/2-7-4.tar.gz
  45. BIN
      docs/legacy/updates/2-7-5.tar.gz
  46. BIN
      docs/legacy/updates/2-7-6.tar.gz
  47. BIN
      docs/legacy/updates/2-7-7.tar.gz
  48. BIN
      docs/legacy/updates/2-7-8.tar.gz
  49. BIN
      docs/legacy/updates/2-7-9.tar.gz
  50. 0 1688
      docs/mysql/2-8-0/mysql.sql
  51. 0 1688
      docs/mysql/2-8-1/mysql.sql
  52. 0 1690
      docs/mysql/2-9-0/mysql.sql
  53. 0 1
      docs/mysql/create_db.sql
  54. 0 1
      docs/mysql/latest-mysql.sql
  55. 73 0
      docs/patches/patch_seq.pl
  56. 215 0
      docs/patches/sha512.alt.patch
  57. 1 1
      docs/php-fpm/eye.conf
  58. 0 5
      docs/sudoers.d/eye
  59. 0 58
      docs/update-named
  60. 38 35
      html/admin/customers/building.php
  61. 56 35
      html/admin/customers/control-options.php
  62. 103 27
      html/admin/customers/control-subnets-usage.php
  63. 3 15
      html/admin/customers/control.php
  64. 70 94
      html/admin/customers/devmodels.php
  65. 47 47
      html/admin/customers/devvendors.php
  66. 81 41
      html/admin/customers/editcustom.php
  67. 89 76
      html/admin/customers/editsubnet.php
  68. 52 29
      html/admin/customers/index-subnets.php
  69. 34 23
      html/admin/customers/index.php
  70. 25 11
      html/admin/customers/ipcam.php
  71. 20 14
      html/admin/devices/edit_gw_instances.php
  72. 25 14
      html/admin/devices/edit_gw_subnets.php
  73. 119 90
      html/admin/devices/edit_l3int.php
  74. 114 127
      html/admin/devices/editdevice.php
  75. 19 17
      html/admin/devices/editport.php
  76. 30 21
      html/admin/devices/index-passive.php
  77. 4 4
      html/admin/devices/index-tree-simple.php
  78. 4 4
      html/admin/devices/index-tree.php
  79. 36 15
      html/admin/devices/index.php
  80. 6 6
      html/admin/devices/mactable.php
  81. 66 39
      html/admin/devices/portmactable.php
  82. 10 11
      html/admin/devices/portsbyvlan.php
  83. 2 2
      html/admin/devices/snmpwalk.php
  84. 15 13
      html/admin/devices/switchport-conn.php
  85. 39 47
      html/admin/devices/switchport.php
  86. 88 62
      html/admin/devices/switchstatus.php
  87. 19 15
      html/admin/filters/editfilter.php
  88. 69 47
      html/admin/filters/editgroup.php
  89. 37 18
      html/admin/filters/groups.php
  90. 41 25
      html/admin/filters/index.php
  91. 68 29
      html/admin/filters/instances.php
  92. 120 55
      html/admin/groups/edit_group.php
  93. 26 18
      html/admin/groups/index.php
  94. 28 20
      html/admin/iplist/auto_rules.php
  95. 51 37
      html/admin/iplist/deleted.php
  96. 49 30
      html/admin/iplist/doubles.php
  97. 90 56
      html/admin/iplist/index.php
  98. 30 26
      html/admin/iplist/nagios.php
  99. 46 19
      html/admin/logs/authlog.php
  100. 43 41
      html/admin/logs/detaillog.php

+ 0 - 1
.gitignore

@@ -6,4 +6,3 @@
 /html/js/select2/
 /.vscode/
 /html/log/*.log
-/html/sessions/sess_*

+ 29 - 0
CHANGELOG.md

@@ -1,4 +1,32 @@
+# Changelog 2.9.1 - release
+
+- Added PostgreSQL support (EXPERIMENTAL — DO NOT USE IN PRODUCTION!)
+- html: switched to use PDO
+- added perl-Net-SNMP module patch to support sha512 in AltLinux
+- The installer has been added 
+- Old versions of the database dump have been removed 
+- The installation now uses php-fpm by default. 
+- Revised English translation 
+- Redesigned the import of vendor mac address data
+- bugfix: fixed clearing of lease records when changing dnsmasq configuration html: added support for php 8.4
+- The name of the dynamic address elimination field is now written in red font for temporary recording
+- Added a check on the database connection activity in the backend, since the automatic reconnect is no longer in use.
+- The debug log is not written to the database.
+- The CNAME output method in dnsmasq has been changed. Now the alias is given as an A record, since dnsmasq does not resolve the parent record, and the secondary one does not send the IP address to the CNAME.
+- improved the function of checking the availability of the host in the web interface
+- double encoding of the redirect url has been removed
+- bugfix: when the subnet was changed, the default gateway was not recalculated. bugfix: the multiplication of the redirect address with an invalid login has been removed.
+- bugfix: removed the artifacts of working with snmp for mikrotik candles updated to the current version of oxidized 0.34.3 pack for a list with support for custom ssh|telnet ports
+- bugfix: duplication of styles has been removed
+- bugfix: Fixed the handling of possible looping in the switch connection scheme
+- bugfix: fixed sorting the list of devices by name and location
+- bugfix: fixed an ancient bug with permanent deletion of the ip address record from the backend
+- In the search string, * (asterisk) can work anywhere except at the end of the string.
+- bugfix: authorization has been fixed. Authorization is no longer reset when opening a direct link. 
+- bugfix: The address import script now handles dns name changes correctly.
+
 # Changelog 2.8.2 - release
+
 - html: The default interval is 1 hour for displaying logs and reports.
 - html: The search in the list of all addresses now takes into account the filters set
 - html: The IP address can be written using the russain letter Ю instead of a dot.
@@ -14,6 +42,7 @@
 - always remove dynamic user ip record by dhcp release request
 
 # Changelog 2.8.0 - draft
+
 - fixed upgrade script name
 - The rule of the only mac in the subnet has been implemented for dynamic records.
 - The ability to set a group has been added to mass editing from the address list.

+ 423 - 8
README.md

@@ -2,11 +2,426 @@
 
 Обычный быдло-кодинг, разросшийся за последние 13 лет. Выкладываю сюда - может кого-то сподвигнет сделать что-то своё нормально).
 
-Предназначен для контроля доступа юзеров в интернет на оборудовании микротик или linux-сервере.
-Возможности:
-- Управляет выходом в интернет для ip-адресов. Настраивается фильтрация, объём трафика в сутки, месяц.
-- Ограничивать скорость (только на микротике, функционал на линухе был, но давно вырезан)
-- генерит конфиги для dhcp-серверов (dnsmasq, mikrotik)
-- генерит конфиг для named
-- опрашивает свичи и роутеры по snmp после чего анализирует и находит порты подключения ip-адресов
-- ну и ещё по мелочи...
+## 📋 Обзор
+
+Eye — это комплексная система сетевого мониторинга и управления, обеспечивающая:
+
+- Управление выходом в интернет для IP-адресов через маршрутизаторы MikroTik/Linux (настраивается фильтрация, лимиты трафика в сутки и за месяц).
+- Ограничение скорости доступа (реализовано на MikroTik; функциональность для Linux ранее существовала, но была удалена).
+- Генерация конфигураций для DHCP-серверов  (dnsmasq, MikroTik).
+- Генерация конфигураций для DNS-сервера (BIND).
+- Опрос коммутаторов и маршрутизаторов по SNMP с последующим анализом и определением портов подключения IP-адресов.
+- Мониторинг и управление сетевыми устройствами.
+- Анализ трафика и контроль пропускной способности.
+- Сбор и анализ Syslog-сообщений.
+- Статистика и отчёты в реальном времени.
+
+---
+
+# Eye Monitoring System — Руководство по установке
+
+### Системные требования
+
+#### Поддерживаемые дистрибутивы:
+
+* ALT Linux 11.1+
+* Debian 11+
+* Ubuntu 20.04+
+
+---
+
+## 🚀 Быстрая установка с помощью скрипта
+
+Для автоматизированной установки используйте установочный скрипт:
+
+```bash
+# Сделать скрипт исполняемым
+chmod +x install-eye.sh
+
+# Запуск установки
+sudo ./install-eye.sh
+
+# Автоматический режим (минимальное вмешательство)
+sudo ./install-eye.sh --auto
+````
+
+### Возможности скрипта
+
+* Поддержка ALT Linux, Debian и Ubuntu
+* Поддержка двух СУБД: MySQL/MariaDB или PostgreSQL (экспериментально, не для production!)
+* Многоязычный интерфейс: английский или русский
+* Автоматическая установка зависимостей
+* Настройка конфигурационных файлов
+* Инициализация базы данных
+
+---
+
+## 🔧 Ручная установка
+
+
+### Установка требуемых пакетов
+
+#### Для ALT Linux:
+
+```bash
+# Обновление репозиториев
+apt-get update
+
+# Установка пакетов Eye
+apt-get install git xxd wget fping hwdata
+
+# База данных (выберите одну)
+apt-get install mariadb-server mariadb-client    # Для MySQL
+# ИЛИ
+apt-get install postgresql postgresql-client     # Для PostgreSQL
+
+# Веб-сервер и PHP
+apt-get install apache2 php8.2 php8.2-mysqlnd php8.2-pgsql \
+php8.2-intl php8.2-mbstring php8.2-fpm-fcgi apache2-mod_fcgid
+
+# Perl-модули
+apt-get install perl-Net-Patricia perl-NetAddr-IP perl-Config-Tiny \
+perl-Net-DNS perl-DateTime perl-Net-Ping \
+perl-Net-Netmask perl-Text-Iconv perl-Net-SNMP \
+perl-Net-Telnet perl-DBI \
+perl-Parallel-ForkManager perl-Proc-Daemon \
+perl-DateTime-Format-DateParse perl-DateTime-Format-Strptime \
+perl-Net-OpenSSH perl-File-Tail perl-Tie-File \
+perl-Crypt-Rijndael perl-Crypt-CBC perl-CryptX perl-Crypt-DES \
+perl-File-Path-Tiny perl-Expect perl-Proc-ProcessTable \
+perl-Text-CSV \
+perl-DBD-Pg perl-DBD-mysql
+
+# Дополнительные сервисы
+apt-get install dnsmasq syslog-ng syslog-ng-journal pwgen
+```
+
+#### Для Debian / Ubuntu:
+
+```bash
+# Обновление репозиториев
+apt-get update
+
+# Установка пакетов Eye
+apt-get install git xxd bsdmainutils pwgen wget fping ieee-data
+
+# База данных (выберите одну)
+apt-get install mariadb-server mariadb-client    # Для MySQL
+# ИЛИ
+apt-get install postgresql postgresql-client     # Для PostgreSQL
+
+# Веб-сервер и PHP
+apt-get install apache2 php php-mysql php-pgsql php-bcmath \
+php-intl php-mbstring php-date php-mail php-snmp php-zip \
+php-db php-fpm libapache2-mod-fcgid
+
+# Perl-модули
+apt-get install -y perl \
+libnet-patricia-perl libnetaddr-ip-perl libconfig-tiny-perl \
+libnet-dns-perl libdatetime-perl libnet-netmask-perl \
+libtext-iconv-perl libnet-snmp-perl libnet-telnet-perl \
+libdbi-perl libparallel-forkmanager-perl libproc-daemon-perl \
+libdatetime-format-dateparse-perl libnetwork-ipv4addr-perl \
+libnet-openssh-perl libfile-tail-perl libdatetime-format-strptime-perl \
+libcrypt-rijndael-perl libcrypt-cbc-perl libcryptx-perl \
+libcrypt-des-perl libfile-path-tiny-perl libexpect-perl \
+libtext-csv-perl \
+libdbd-pg-perl libdbd-mysql-perl
+
+# Дополнительные сервисы
+apt-get install dnsmasq syslog-ng
+```
+
+---
+
+### Создание пользователя и группы
+
+```bash
+# Создание группы
+groupadd --system eye
+
+# Создание пользователя
+adduser --system --disabled-password --disabled-login \
+--ingroup eye --home=/opt/Eye eye
+
+# Создание каталога
+mkdir -p /opt/Eye
+chown eye:eye /opt/Eye
+chmod 770 /opt/Eye
+
+# Опционально: добавить nagios в группу eye
+usermod -a -G eye nagios
+```
+
+---
+
+### Загрузка и установка исходного кода
+
+```bash
+# Клонирование репозитория
+git clone https://github.com/rajven/Eye
+
+# Создание структуры каталогов
+mkdir -p /opt/Eye/scripts/cfg
+mkdir -p /opt/Eye/scripts/log
+mkdir -p /opt/Eye/html/cfg
+mkdir -p /opt/Eye/html/js
+mkdir -p /opt/Eye/docs
+
+# Установка прав
+chmod 750 /opt/Eye
+chmod 770 /opt/Eye/scripts/log
+chmod 750 /opt/Eye/scripts
+
+# Копирование файлов
+cp -R scripts/ /opt/Eye/
+cp -R html/ /opt/Eye/
+cp -R docs/ /opt/Eye/
+
+# Установка прав
+chown -R eye:eye /opt/Eye
+```
+
+---
+
+### Применение патча SNMP SHA512 (опционально)
+
+```bash
+# Патч для поддержки SNMPv3 SHA512
+# Файл: /opt/Eye/docs/patches/sha512.patch
+# Для ALT Linux: /opt/Eye/docs/patches/sha512.alt.patch
+
+# Применение патча при необходимости
+cp /opt/Eye/docs/patches/USM.pm /usr/share/perl5/Net/SNMP/Security/USM.pm
+```
+
+---
+
+### Загрузка дополнительных JavaScript-библиотек
+
+```bash
+# Создание каталогов
+mkdir -p /opt/Eye/html/js/jq
+mkdir -p /opt/Eye/html/js/select2
+mkdir -p /opt/Eye/html/js/jstree
+
+# Загрузка jQuery
+wget https://code.jquery.com/jquery-3.7.0.min.js \
+-O /opt/Eye/html/js/jq/jquery.min.js
+
+# Загрузка Select2
+wget https://github.com/select2/select2/archive/4.0.12.tar.gz -O 4.0.12.tar.gz
+tar -xzf 4.0.12.tar.gz -C /opt/Eye/html/js/select2/ \
+--strip-components=2 select2-4.0.12/dist
+rm -f 4.0.12.tar.gz
+
+# Загрузка jsTree
+wget https://github.com/vakata/jstree/archive/3.3.12.tar.gz -O jstree.tar.gz
+tar -xzf jstree.tar.gz -C /opt/Eye/html/js/
+mv /opt/Eye/html/js/jstree-3.3.12/dist/* /opt/Eye/html/js/jstree
+rm -rf /opt/Eye/html/js/jstree-3.3.12
+rm -f jstree.tar.gz
+```
+
+---
+
+### Настройка базы данных
+
+#### MySQL / MariaDB:
+
+```bash
+systemctl enable mariadb
+systemctl start mariadb
+
+mysql_secure_installation
+
+mysql -u root -p < /opt/Eye/docs/databases/mysql/en/create_db.sql
+mysql -u root -p stat < /opt/Eye/docs/databases/mysql/en/data.sql
+
+mysql -u root -p <<EOF
+CREATE USER 'stat'@'localhost' IDENTIFIED BY 'your_password';
+GRANT ALL PRIVILEGES ON stat.* TO 'stat'@'localhost';
+FLUSH PRIVILEGES;
+EOF
+```
+
+#### PostgreSQL:
+
+```bash
+systemctl enable postgresql
+systemctl start postgresql
+
+sudo -u postgres psql -f /opt/Eye/docs/databases/postgres/en/create_db.sql
+sudo -u postgres psql -d stat -f /opt/Eye/docs/databases/postgres/en/data.sql
+sudo -u postgres psql -c "ALTER USER stat WITH PASSWORD 'your_password';"
+
+# В pg_hba.conf добавить строку:
+# local   stat            stat                                    md5
+```
+
+---
+
+### Конфигурационные файлы
+
+```bash
+cp /opt/Eye/html/cfg/config.sample.php /opt/Eye/html/cfg/config.php
+cp /opt/Eye/scripts/cfg/config.sample /opt/Eye/scripts/cfg/config
+
+ENCRYPTION_KEY=$(pwgen 16 1)
+ENCRYPTION_IV=$(tr -dc 0-9 </dev/urandom | head -c 16)
+
+chown -R eye:eye /opt/Eye/html/cfg /opt/Eye/scripts/cfg
+chmod 660 /opt/Eye/html/cfg/config.php /opt/Eye/scripts/cfg/config
+```
+
+---
+
+### Настройка Apache и PHP
+
+```bash
+cp /opt/Eye/docs/apache/000-default.conf /etc/apache2/sites-available/
+a2enmod setenvif proxy proxy_fcgi
+cp /opt/Eye/docs/php-fpm/eye.conf /etc/php/8.2/fpm/pool.d/
+
+cp /opt/Eye/docs/sudoers.d/www-data /etc/sudoers.d/eye
+sed -i 's/www-data/eye/g' /etc/sudoers.d/eye
+chmod 440 /etc/sudoers.d/eye
+
+systemctl restart apache2
+systemctl restart php8.2-fpm
+```
+
+---
+
+### Cron и Logrotate
+
+```bash
+cp /opt/Eye/docs/cron/stat /etc/cron.d/eye
+chmod 644 /etc/cron.d/eye
+
+cp /opt/Eye/docs/logrotate/dnsmasq /etc/logrotate.d/dnsmasq-eye
+cp /opt/Eye/docs/logrotate/scripts /etc/logrotate.d/eye-scripts
+```
+
+---
+
+### Дополнительные сервисы (опционально)
+
+#### DHCP (dnsmasq):
+
+```bash
+cp /etc/dnsmasq.conf /etc/dnsmasq.conf.backup
+cat /opt/Eye/docs/addons/dnsmasq.conf > /etc/dnsmasq.conf
+
+cp /opt/Eye/docs/systemd/dhcp-log.service /etc/systemd/system/
+cp /opt/Eye/docs/systemd/dhcp-log-truncate.service /etc/systemd/system/
+
+systemctl enable dnsmasq dhcp-log dhcp-log-truncate
+systemctl start dnsmasq
+```
+
+#### Syslog-ng:
+
+```bash
+cp /etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf.backup
+mkdir -p /etc/syslog-ng/conf.d
+cp /opt/Eye/docs/syslog-ng/eye.conf /etc/syslog-ng/conf.d/
+
+cp /opt/Eye/docs/systemd/syslog-stat.service /etc/systemd/system/
+
+systemctl enable syslog-ng syslog-stat
+systemctl restart syslog-ng
+systemctl start syslog-stat
+```
+
+#### NetFlow:
+
+```bash
+cp /opt/Eye/docs/systemd/eye-statd.service /etc/systemd/system/
+systemctl enable eye-statd
+```
+
+#### Stat-sync:
+
+```bash
+cp /opt/Eye/docs/systemd/stat-sync.service /etc/systemd/system/
+systemctl enable stat-sync.service
+```
+
+---
+
+### Импорт базы MAC-адресов
+
+```bash
+cd /opt/Eye/scripts/utils/mac-oids/
+bash download-macs.sh
+perl update-mac-vendors.pl
+```
+
+---
+
+## 🌐 Доступ к веб-интерфейсу
+
+* URL: `http://your-server-ip/`
+* Админ-панель: `http://your-server-ip/admin/`
+* Логин: `admin`
+* Пароль: `admin`
+
+---
+
+## 🔐 Рекомендации по безопасности
+
+* **НЕМЕДЛЕННО смените пароль администратора**
+* Сгенерируйте новый API-ключ
+* Ограничьте доступ с помощью firewall
+* Используйте HTTPS (без принудительного редиректа!)
+* Делайте регулярные обновления и резервные копии
+
+---
+
+## 📊 Интеграция с MikroTik
+
+### Firewall:
+
+```routeros
+/ip firewall filter
+add action=jump chain=forward comment="users set" in-interface-list=WAN jump-target=Users
+add action=jump chain=forward jump-target=Users out-interface-list=WAN
+```
+
+### Управление трафиком:
+
+```routeros
+/queue tree
+add max-limit=100M name=upload_root_ether1 parent=ether1 queue=pcq-upload-default
+add name=download_root_bridge parent=bridge queue=pcq-download-default
+```
+
+### DHCP-скрипт (RouterOS 6):
+
+```routeros
+/tool fetch mode=http keep-result=no url="http://<EYE_IP>/api.php?login=<LOGIN>&api_key=<API_KEY>&send=dhcp&mac=\$leaseActMAC&ip=\$leaseActIP&action=\$leaseBound&hostname=\$lease-hostname"
+```
+
+### DHCP-скрипт (RouterOS 7):
+
+```routeros
+/tool fetch url="http://<EYE_IP>/api.php?login=<LOGIN>&api_key=<API_KEY>&send=dhcp&mac=$leaseActMAC&ip=$leaseActIP&action=$leaseBound&hostname=$"lease-hostname"" mode=http keep-result=no
+```
+
+### NetFlow:
+
+```routeros
+# RouterOS 6
+/ip traffic-flow
+set enabled=yes
+
+# RouterOS 7
+/ip traffic-flow
+set enabled=yes interfaces=WAN
+
+/ip traffic-flow target
+add dst-address=<NETFLOW_SERVER_IP> port=2055
+```
+
+---

+ 0 - 229
Readme.en.md

@@ -1,229 +0,0 @@
-Installation
-
-1. Install the packages
-
-#common
-apt install git xxd bsdmainutils
-
-#for database server
-apt install mariadb-server
-
-#for web
-apt install apache2 libapache2-mod-fcgid \
-php php-mysql php-bcmath php-intl php-mbstring php-date php-mail php-snmp php-zip php-fpm php-db php-pgsql
-
-#for backend
-apt install perl libnet-patricia-perl libnetaddr-ip-perl libconfig-tiny-perl libnet-dns-perl libdatetime-perl \
-libnet-netmask-perl libtext-iconv-perl libnet-snmp-perl libnet-telnet-perl libdbi-perl \
-libdbd-mysql-perl libparallel-forkmanager-perl libproc-daemon-perl libdatetime-format-dateparse-perl \
-libnetwork-ipv4addr-perl libnet-openssh-perl libfile-tail-perl libcrypt-rijndael-perl \
-libcrypt-cbc-perl libcryptx-perl libdbd-pg-perl libfile-path-tiny-perl libexpect-perl libcrypt-des-perl
-
-#additional packages 
-apt install dnsmasq syslog-ng 
-apt install bind9 bind9-utils bind9-host
-
-2. Create user and group
-
-addgroup --system eye
-adduser --system  --disabled-password --disabled-login --ingroup eye --home=/opt/Eye eye
-chmod 770 /opt/Eye
-
-2.1 For nagios
-usermod -a -G eye nagios
-
-3. Download the source code and spread it in catalogs:
-
-git clone https://github.com/rajven/Eye
-mkdir -p /opt/Eye/scripts
-mkdir -p /opt/Eye/scripts/cfg
-mkdir -p /opt/Eye/scripts/log
-cd Eye/
-cp -R scripts/ /opt/Eye/
-cp -R html/ /opt/Eye/
-
-patch perl snmp for support SHA512
-
-#cp -f docs/patches/USM.pm /usr/share/perl5/Net/SNMP/Security/USM.pm
-
-4. You can download additional scripts (prettiness)
-
-mkdir -p /opt/Eye/html/js/jq
-mkdir -p /opt/Eye/html/js/select2
-
-download from https://jquery.com/download/ production jQuery to /opt/Eye/html/js/jq
-#wget https://code.jquery.com/jquery-1.12.4.min.js -O /opt/Eye/html/js/jq/jquery.min.js
-or
-#wget https://code.jquery.com/jquery-3.7.0.min.js -O /opt/Eye/html/js/jq/jquery.min.js
-
-download from https://github.com/select2/select2 release
-#wget https://github.com/select2/select2/archive/4.0.12.tar.gz
-#tar -xzf 4.0.12.tar.gz -C /opt/Eye/html/js/select2/ --strip-components=2 select2-4.0.12/dist
-#rm -f 4.0.12.tar.gz
-
-download jstree from  https://github.com/vakata/jstree/
-#wget https://github.com/vakata/jstree/zipball/3.3.12 -O js.zip
-#unzip js.zip "vakata-jstree-7a03954/dist/*" -d "/opt/Eye/html/"
-#mv /opt/Eye/html/vakata-jstree-7a03954/dist/ /opt/Eye/html/js/jstree
-#rm -d /opt/Eye/html/vakata-jstree-7a03954
-#rm -f js.zip
-
-5. Setting up mysql 
-
-systemctl enable mariadb
-systemctl start mariadb
-
-set password for root
-#mysql_secure_installation
-
-Create database
-#cat docs/mysql/create_db.sql | mysql -u root -p
-
-Import default tables
-#cat docs/mysql/latest-mysql.sql | mysql -u root -p stat
-
-Create user and database
-
-#mysql -u root -p
-
-MariaDB [(none)]>
-grant all privileges to stat.* stat@localhost, identified with a "password";
-flush privileges;
-exit
-
-6. Edit configs for web and scripts:
-
-cp html/cfg/config.sample.php /opt/Eye/html/cfg/
-mv /opt/Eye/html/cfg/config.sample.php /opt/Eye/html/cfg/config.php
-
-edit: /opt/Eye/html/cfg/config.php
-
-cp scripts/cfg/config.sample /opt/Eye/scripts/cfg/config
-
-edit: /opt/Eye/scripts/cfg/config
-
-You need to specify the password in mysql and the database!
-
-Symmetric AES-128-CBC encryption is used to encrypt passwords to devices. It is necessary to generate a password and an initialization vector, enter in both configs:
-Password: pwgen 16
-Vector: tr -dc 0-9 </dev/urandom | head -c 16 ; echo ''
-
-7. Configuring apache and php:
-
-sed -i 's/short_open_tag = Off/short_open_tag = On/' /etc/php/7.4/apache2/php.ini
-sed -i 's/;date.time zone =/date.time zone = Europe\/Moscow/' /etc/php/7.4/apache2/php.ini
-sed -i -E 's/DocumentRoot\s+\/var\/www\/html/DocumentRoot \/opt\/Eye\/html/' /etc/apache2/sites-available/000-default.conf
-
-systemctl enable apache2
-systemctl start apache2
-
-cp docs/sudoers.d/www-data /etc/sudoers.d/www-data
-
-8. Cron and logrotate
-
-cp docs/cron/stat /etc/cron.d/stat
-cp docs/logrotate/dnsmasq /etc/logrotate.d/dnsmasq
-cp docs/logrotate/scripts/etc/logrotate.d/scripts
-
-Do not forget to uncomment the necessary scripts in the crown
-
-9. Minimal setup is ready! Log in: http://[ip]/admin/ user: admin password: admin, configure the user interface, user networks, etc.
-
-10. Change the administrator password and api key!!!
-
-######################################### DHCP server on Linux ###############################################################
-
-You can use a dhcp server both on mirkotik and on a server with Linux. Imho, dnsmasq is preferable.
-
-apt install dnsmasq -y
-
-cp docs/systemd/dhcp-log.service /etc/systemd/system
-cp docs/systemd/dhcp-log-truncate.service /etc/systemd/system
-cp /etc/dnsmasq.conf /etc/dnsmasq.conf.default
-cat docs/addons/dnsmasq.conf >/etc/dnsmasq.conf
-
-#edit /etc/dnsmasq.conf for you network
-
-systemctl enable dnsmasq dhcp-log dhcp-log-truncate --now
-
-######################################### Additional ##################################################################
-
-1. To determine the vendor of equipment by mac, you need to import a database of macs:
-
-scripts/utils/mac-oids/download-macs.sh
-scripts/utils/mac-oids/update-mac-vendors.pl
-
-2. enable stat-sync service
-
-cp docs/systemd/stat-sync.service /etc/systemd/system
-
-systemctl enable stat-sync.service
-
-######################################### Network flow #####################################################################
-
-Enable netflow at mikrotik:
-/ip traffic-flow
-#for ROS 6
-set enabled=yes
-#for ROS 7
-set enabled=yes  interfaces=WAN
-/ip traffic-flow target
-add dst-address=[IP-NETFLOW-SERVER] port=2055
-
-#cp docs/systemd/eye-statd.service /etc/systemd/system
-#systemctl enable eye-statd
-
-######################################### Remote System Log ###############################################################
-
-If you need to write logs from devices:
-
-apt install syslog-ng -y
-
-cp /etc/syslog-ng/syslog-ng.conf  /etc/syslog-ng/syslog-ng.conf.default
-cat docs/syslog-ng/syslog-ng.conf >/etc/syslog-ng/syslog-ng.conf
-
-systemctl enable syslog-ng
-systemctl start syslog-ng
-
-cp docs/systemd/syslog-stat.service /etc/systemd/system/syslog-stat.service
-
-systemctl enable syslog-stat
-systemctl start syslog-stat
-
-######################################### Mikrotik Management ##########################################################
-
-configure ssh access parameters to the router in the admin panel (login | password | port) http://[IP]/admin/customers/control-options.php
-
-we register in the router (http:// [IP]/admin/devices/), enter and disable servers, enable the use of servers, a dhcp server (not necessary if we use dnsmasq)
-
-Adding rules to the firewall:
-
-/ip firewall filter
-
-add action=jump chain=forward comment="users set" in-interface-list=WAN jump-target=Users
-add action=jump chain=forward jump-target=Users out-interface-list=WAN
-
-#the above rules should be put above these default ones:
-#add action=drop chain=forward comment="drop forward invalid" connection-state=invalid
-#add action=accept chain=forward comment=related,established connection-state=established,related
-
-#And these rules should be lower than the default ones
-add action=reject chain=forward comment="deny default wan" in-interface-list=WAN log=yes log-prefix=unk_wan: reject-with=icmp-network-unreachable 
-add action=drop chain=forward out-interface-list=WAN
-
-shaper:
-/queue tree
-add max-limit=[YOU BANDWIDTH] name=upload_root_[WAN_INTERFACE_NAME] parent=[WAN_INTERFACE_NAME] queue=pcq-upload-default
-add name=download_root_[LAN_INTERFACE_NAME] parent=[LAN_INTERFACE_NAME] queue=pcq-download-default
-
-launching /opt/Eye/scripts/sync_mikrotik.pl
-The script will create filtering and shaper rules
-
-#dhcp script sampling
-#ROS6
-/tool fetch mode=http keep-result=no url="http://<STAT_IP_OR_HOSTNAME>/api.php\?login=<LOGIN>&api_key=<API_CUSTOMER_KEY>&send=dhcp&mac=$leaseActMAC&ip=$leaseActIP&action=$leaseBound&hostname=$"lease-hostname""
-#ROS7
-/tool fetch mode=http keep-result=no url="http://<STAT_IP_OR_HOSTNAME>/api.php?login=<LOGIN>&api_key=<API_CUSTOMER_KEY>&send=dhcp&mac=$leaseActMAC&ip=$leaseActIP&action=$leaseBound&hostname=$"lease-hostname""
-
-
-#########################################################################################################################

+ 0 - 225
Readme.ru.md

@@ -1,225 +0,0 @@
-Установка
-
-1. Ставим пакеты
-
-#общая часть
-apt install git xxd bsdmainutils
-
-#для сервера с БД
-apt install mariadb-server
-
-#для сервера с вэбом
-apt install apache2 libapache2-mod-fcgid \
-php php-mysql php-bcmath php-intl php-mbstring php-date php-mail php-snmp php-zip php-fpm php-db php-pgsql
-
-#для ядра
-apt install perl libnet-patricia-perl libnetaddr-ip-perl libconfig-tiny-perl libnet-dns-perl libdatetime-perl \
-libnet-netmask-perl libtext-iconv-perl libnet-snmp-perl libnet-telnet-perl libdbi-perl \
-libdbd-mysql-perl libparallel-forkmanager-perl libproc-daemon-perl libdatetime-format-dateparse-perl \
-libnetwork-ipv4addr-perl libnet-openssh-perl libfile-tail-perl libcrypt-rijndael-perl \
-libcrypt-cbc-perl libcryptx-perl libdbd-pg-perl libfile-path-tiny-perl libexpect-perl libcrypt-des-perl
-
-#дополнительно
-apt install dnsmasq syslog-ng 
-apt install bind9 bind9-utils bind9-host
-
-2. Create user and group
-
-addgroup --system eye
-adduser --system  --disabled-password --disabled-login --ingroup eye --home=/opt/Eye eye
-chmod 770 /opt/Eye
-
-2.1 Если нужна работа с nagios
-usermod -a -G eye nagios
-
-3. Качаем исходники и раскидываем по каталогам:
-
-git clone https://github.com/rajven/Eye
-mkdir -p /opt/Eye/scripts
-mkdir -p /opt/Eye/scripts/cfg
-mkdir -p /opt/Eye/scripts/log
-cd Eye/
-cp -R scripts/ /opt/Eye/
-cp -R html/ /opt/Eye/
-
-patch perl snmp for support SHA512
-
-#cp -f docs/patches/USM.pm /usr/share/perl5/Net/SNMP/Security/USM.pm
-
-4. Можно скачать дополнительные скрипты (красивости)
-
-mkdir -p /opt/Eye/html/js/jq
-mkdir -p /opt/Eye/html/js/select2
-
-download from https://jquery.com/download/ production jQuery to /opt/Eye/html/js/jq
-#wget https://code.jquery.com/jquery-1.12.4.min.js -O /opt/Eye/html/js/jq/jquery.min.js
-or
-#wget https://code.jquery.com/jquery-3.7.0.min.js -O /opt/Eye/html/js/jq/jquery.min.js
-
-download from https://github.com/select2/select2 release
-#wget https://github.com/select2/select2/archive/4.0.12.tar.gz
-#tar -xzf 4.0.12.tar.gz -C /opt/Eye/html/js/select2/ --strip-components=2 select2-4.0.12/dist
-#rm -f 4.0.12.tar.gz
-
-download jstree from  https://github.com/vakata/jstree/
-#wget https://github.com/vakata/jstree/zipball/3.3.12 -O js.zip
-#unzip js.zip "vakata-jstree-7a03954/dist/*" -d "/opt/Eye/html/"
-#mv /opt/Eye/html/vakata-jstree-7a03954/dist/ /opt/Eye/html/js/jstree
-#rm -d /opt/Eye/html/vakata-jstree-7a03954
-#rm -f js.zip
-
-5. Настраиваем mysql 
-
-set password for root
-#mysql_secure_installation
-
-Создаём базу данных
-#cat docs/mysql/create_db.sql | mysql -u root -p
-
-Импортируем таблицы
-#cat docs/mysql/latest-mysql.sql | mysql -u root -p stat
-
-Create user and database
-
-#mysql -u root -p
-
-MariaDB [(none)]>
-grant all privileges to stat.* stat@localhost, identified with a "password";
-flush privileges;
-exit
-
-6. Настраиваем конфиги для вэба и скриптов:
-
-cp html/inc/config.sample.php /opt/Eye/html/cfg/
-mv /opt/Eye/html/cfg/config.sample.php /opt/Eye/html/cfg/config.php
-
-edit: /opt/Eye/html/cfg/config.php
-
-cp scripts/cfg/config.sample /opt/Eye/scripts/cfg/config
-
-edit: /opt/Eye/scripts/cfg/config
-
-Надо указать пароль в  mysql и базу данных!
-
-Для шифрования паролей на устройства используется симметричное ишфрование AES-128-CBC. Необходимо сгенерировать пароль и вектор инициализации, внести в оба конфига:
-Пароль: pwgen 16
-Вектор: tr -dc 0-9 </dev/urandom | head -c 16 ; echo ''
-
-7. Настраиваем апач и php:
-
-sed -i 's/short_open_tag = Off/short_open_tag = On/' /etc/php/7.4/apache2/php.ini
-sed -i 's/;date.timezone =/date.timezone = Europe\/Moscow/' /etc/php/7.4/apache2/php.ini
-sed -i -E 's/DocumentRoot\s+\/var\/www\/html/DocumentRoot \/opt\/Eye\/html/' /etc/apache2/sites-available/000-default.conf
-
-systemctl enable apache2
-systemctl start apache2
-
-cp docs/sudoers.d/www-data /etc/sudoers.d/www-data
-
-8. Cron & logrotate
-
-cp docs/cron/stat /etc/cron.d/stat
-cp docs/logrotate/dnsmasq /etc/logrotate.d/dnsmasq
-cp docs/logrotate/scripts /etc/logrotate.d/scripts
-
-Не забудьте раскомментировать в кроне неоходимые скрипты
-
-9. Минимальная настройка готова! Заходим: http://[ip]/admin/ user: admin password: admin, настраиваем список устройств, используемые сети и т.д.
-
-10. Change admin password and api key!!!
-
-######################################### DHCP Server at Linux ###############################################################
-
-Можно использовать dhcp-сервер как на миркотике, так и на сервере с Linux. Имхо, dnsmasq - предпочтительнее.
-
-apt install dnsmasq -y
-
-cp docs/systemd/dhcp-log.service /etc/systemd/system
-cp docs/systemd/dhcp-log-truncate.service /etc/systemd/system
-cp /etc/dnsmasq.conf /etc/dnsmasq.conf.default
-cat docs/addons/dnsmasq.conf >/etc/dnsmasq.conf
-
-#edit /etc/dnsmasq.conf for you network
-
-systemctl enable dnsmasq dhcp-log dhcp-log-truncate --now
-
-######################################### Additional ##################################################################
-
-1. Для определения вендора оборудования по маку, необходимо импортировать базу маков:
-
-scripts/utils/mac-oids/download-macs.sh
-scripts/utils/mac-oids/update-mac-vendors.pl
-
-2. Для изменения списков доступа на маршрутизаторе сразу после внесения изменений в вэб-интерфейсе необходимо включить сервис stat-sync
-
-cp docs/systemd/stat-sync.service /etc/systemd/system
-
-systemctl enable stat-sync.service
-
-######################################### Network flow #####################################################################
-
-Включаем netflow на роутере микротик:
-#for ROS 6
-set enabled=yes
-#for ROS 7
-set enabled=yes  interfaces=WAN
-
-/ip traffic-flow target
-add dst-address=[IP-SERVER] port=2055
-
-#cp docs/systemd/eye-statd.service /etc/systemd/system
-#systemctl enable eye-statd
-
-######################################### Remote syslog ###############################################################
-
-Если нужно писать логи с устройств:
-
-apt install syslog-ng -y
-
-cp /etc/syslog-ng/syslog-ng.conf  /etc/syslog-ng/syslog-ng.conf.default
-cat docs/syslog-ng/syslog-ng.conf >/etc/syslog-ng/syslog-ng.conf
-
-systemctl enable syslog-ng
-systemctl start syslog-ng
-
-cp docs/systemd/syslog-stat.service /etc/systemd/system/syslog-stat.service
-
-systemctl enable syslog-stat
-systemctl start syslog-stat
-
-######################################### Mikrotik managment ##########################################################
-
-настраиваем параметры доступа по ssh к роутеру в админке (login|password|port)  http://[IP]/admin/customers/control-options.php
-
-указываем в роутере (http://[IP]/admin/devices/) внешние и внутренние интерфейсы, включаем использование шейперов, dhcp-сервера (не нужно, если исопльзуем dnsmasq)
-
-Добавляем правила в фаервол:
-
-/ip firewall filter
-
-add action=jump chain=forward comment="users set" in-interface-list=WAN jump-target=Users
-add action=jump chain=forward jump-target=Users out-interface-list=WAN
-
-#указанные выше правила надо поставить выше этих дефалтных:
-#add action=drop chain=forward comment="drop forward invalid" connection-state=invalid
-#add action=accept chain=forward comment=related,established connection-state=established,related
-
-#А эти правила должны быть ниже дефолтных
-add action=reject chain=forward comment="deny default wan" in-interface-list=WAN log=yes log-prefix=unk_wan: reject-with=icmp-network-unreachable 
-add action=drop chain=forward out-interface-list=WAN
-
-шейпер:
-/queue tree
-add max-limit=[YOU BANDWIDTH] name=upload_root_[WAN_INTERFACE_NAME] parent=[WAN_INTERFACE_NAME] queue=pcq-upload-default
-add name=download_root_[LAN_INTERFACE_NAME] parent=[LAN_INTERFACE_NAME] queue=pcq-download-default
-
-запускаем /opt/Eye/scripts/sync_mikrotik.pl
-Скрипт создаст правила фильтрации и шейпера
-
-#dhcp script
-#ROS6
-/tool fetch mode=http keep-result=no url="http://<STAT_IP_OR_HOSTNAME>/api.php\?login=<LOGIN>&api_key=<API_CUSTOMER_KEY>&send=dhcp&mac=$leaseActMAC&ip=$leaseActIP&action=$leaseBound&hostname=$"lease-hostname""
-#ROS7
-/tool fetch mode=http keep-result=no url="http://<STAT_IP_OR_HOSTNAME>/api.php?login=<LOGIN>&api_key=<API_CUSTOMER_KEY>&send=dhcp&mac=$leaseActMAC&ip=$leaseActIP&action=$leaseBound&hostname=$"lease-hostname""
-
-#########################################################################################################################

+ 3 - 11
docs/addons/dnsmasq.conf

@@ -1,11 +1,11 @@
 bogus-priv
 
-user=nobody
-group=nobody
+#user=nobody
+#group=nobody
 
 no-resolv
 
-port=0
+port=53
 
 log-facility=/var/log/dnsmasq.log
 log-dhcp
@@ -27,13 +27,6 @@ dhcp-option=6,192.168.1.100
 dhcp-option=option:domain-name,"lan"
 dhcp-option=119,"lan"
 
-#wins
-#dhcp-option=44,192.168.1.100
-#dhcp-option=46,8
-
-dhcp-range=office,192.168.1.10,192.168.1.200,255.255.255.0,4h
-dhcp-option=net:office,option:router,192.168.1.1
-
 dhcp-script=/opt/Eye/scripts/dnsmasq-hook.sh
 
 dhcp-lease-max=4000
@@ -44,4 +37,3 @@ dhcp-option=vendor:MSFT,2,1i
 
 #log option82 fields
 dhcp-match=set:full,option:agent-id,*
-

+ 16 - 48
docs/apache/000-default.conf

@@ -1,72 +1,40 @@
 <VirtualHost *:80>
 
-#ServerName www.example.com
-
-ServerAdmin webmaster@localhost
-
-ErrorLog ${APACHE_LOG_DIR}/stat-error_log
-TransferLog ${APACHE_LOG_DIR}/stat-access_log
-
-#don't enable redirect to HTTPS!!!
-RewriteEngine Off
+#ServerName you_server_fqdn
+#ServerAdmin webmaster@localhost
 
 DocumentRoot /opt/Eye/html
 
 <Directory "/opt/Eye/html">
-    Options -Indexes -FollowSymLinks
-    AllowOverride All
-    Require all granted
-
-    AddType application/x-httpd-php .php
-
-# Redirect to local php-fpm if mod_php is not available
-<IfModule !mod_php8.c>
-<IfModule proxy_fcgi_module>
-    # Enable http authorization headers
-    <IfModule setenvif_module>
-    SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
+Options -Indexes +FollowSymLinks
+AllowOverride All
+Require all granted
+
+# Если mod_php НЕ загружен — используем PHP-FPM
+<IfModule !php_module>
+    <IfModule proxy_fcgi_module>
+        <FilesMatch "\.ph(ar|p|tml)$">
+            SetHandler "proxy:fcgi://127.0.0.1:9002"
+        </FilesMatch>
+        <FilesMatch "\.phps$">
+            Require all denied
+        </FilesMatch>
     </IfModule>
-
-    <FilesMatch ".+\.ph(ar|p|tml)$">
-#    SetHandler "proxy:unix:/run/php/php8.2-fpm-eye.sock|fcgi://127.0.0.1:9002"
-    SetHandler "proxy:fcgi://127.0.0.1:9002"
-    </FilesMatch>
-
-    <FilesMatch ".+\.phps$">
-        # Deny access to raw php sources by default
-        # To re-enable it's recommended to enable access to the files
-        # only in specific virtual host or directory
-        Require all denied
-    </FilesMatch>
-    # Deny access to files without filename (e.g. '.php')
-    <FilesMatch "^\.ph(ar|p|ps|tml)$">
-        Require all denied
-    </FilesMatch>
 </IfModule>
-</IfModule>
-
 </Directory>
 
 <Directory /opt/Eye/html/log>
-    <IfModule mod_authz_core.c>
     Require all denied
-    </IfModule>
 </Directory>
 
 <Directory /opt/Eye/html/tmp>
-    <IfModule mod_authz_core.c>
     Require all denied
-    </IfModule>
 </Directory>
 
 <Directory /opt/Eye/html/session>
-    <IfModule mod_authz_core.c>
     Require all denied
-    </IfModule>
 </Directory>
 
-AddDefaultCharset UTF-8
+    AddDefaultCharset UTF-8
 
 </VirtualHost>
-
-# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

+ 3 - 3
docs/cron/stat

@@ -6,7 +6,7 @@
 #refresh dnsmasq dhcp server config's
 02 * * * * root /opt/Eye/scripts/update-dnsmasq
 
-#maybe any user
+#maybe user
 
 #garbage trash
 01 0 * * * eye /opt/Eye/scripts/garbage.pl
@@ -15,7 +15,7 @@
 #03 * * * * eye /opt/Eye/scripts/sync_mikrotik.pl
 
 #passive scan network => 2 * arp_timeout (default min: 2 * 5m)
-*/25 * * * * eye /opt/Eye/scripts/fetch_new_arp.pl
+*/11 * * * * eye /opt/Eye/scripts/fetch_new_arp.pl
 
 #active scan network (with fping subnets before analyze)
-20 10,13,19 * * * eye /opt/Eye/scripts/fetch_new_arp.pl 1
+20 10,13,16,19 * * * eye /opt/Eye/scripts/fetch_new_arp.pl 1

+ 205 - 0
docs/databases/checkDBschema.pl

@@ -0,0 +1,205 @@
+#!/usr/bin/perl
+
+#
+# Copyright (C) Roman Dmitriev, rnd@rajven.ru
+#
+
+use utf8;
+use open ":encoding(utf8)";
+use open ':std', ':encoding(UTF-8)';
+use Encode;
+no warnings 'utf8';
+use English;
+use FindBin '$Bin';
+use lib "/opt/Eye/scripts";
+use Getopt::Long qw(GetOptions);
+use Data::Dumper;
+use eyelib::config;
+use eyelib::main;
+use eyelib::database;
+use eyelib::common;
+use eyelib::net_utils;
+use strict;
+use warnings;
+
+# === Получаем имя чистой БД ===
+my $clear_db_name = $DBNAME . "_test";
+
+# === Подключаемся к рабочей БД ===
+my $work_db = init_db();
+
+# === Подключаемся к чистой БД ===
+my $clear_db;
+if ($config_ref{DBTYPE} eq 'mysql') {
+    my $dsn = "dbi:mysql:database=$clear_db_name;host=$DBHOST;port=3306;mysql_local_infile=1";
+    $clear_db = DBI->connect($dsn, $DBUSER, $DBPASS, {
+        RaiseError => 0,
+        AutoCommit => 1,
+        mysql_enable_utf8 => 1
+    });
+    if (!defined $clear_db) {
+        die "Cannot connect to MySQL database '$clear_db_name': $DBI::errstr\n";
+    }
+    $clear_db->do('SET NAMES utf8mb4');
+} else {
+    my $dsn = "dbi:Pg:dbname=$clear_db_name;host=$DBHOST;port=5432;";
+    $clear_db = DBI->connect($dsn, $DBUSER, $DBPASS, {
+        RaiseError => 0,
+        AutoCommit => 1,
+        pg_enable_utf8 => 1,
+        pg_server_prepare => 0
+    });
+    if (!defined $clear_db) {
+        die "Cannot connect to PostgreSQL database '$clear_db_name': $DBI::errstr\n";
+    }
+}
+
+# === Функция нормализации значения по умолчанию ===
+sub normalize_default {
+    my ($default, $db_type) = @_;
+    return undef unless defined $default;
+
+    if ($db_type eq 'mysql') {
+        # Убираем кавычки, если строка
+        $default =~ s/^'(.*)'$/$1/;
+        # NULL → undef
+        return undef if lc($default) eq 'null';
+    } else {
+        # PostgreSQL: уже в нормальном виде
+        return undef if lc($default) eq 'null';
+    }
+    return $default;
+}
+
+# === Сбор схемы для БД ===
+sub get_schema {
+    my ($db, $db_type, $db_name) = @_;
+    my %schema;
+
+    my @tables;
+    if ($db_type eq 'mysql') {
+        my @rows = get_records_sql($db, 'SHOW TABLES');
+        my $idx = 'Tables_in_' . $db_name;
+        @tables = map { $_->{$idx} } grep { $_ && exists $_->{$idx} } @rows;
+    } else {
+        my @rows = get_records_sql($db, "SELECT tablename FROM pg_tables WHERE schemaname = 'public'");
+        @tables = map { $_->{tablename} } @rows;
+    }
+
+    for my $table (@tables) {
+        my %cols = get_table_columns($db, $table);
+        # get_table_columns уже возвращает lowercase имена
+        for my $col (keys %cols) {
+            my $info = $cols{$col};
+            $schema{$table}{$col} = {
+                name     => $info->{name} // '',
+                type     => $info->{type}     // '',
+                nullable => $info->{nullable} // 1,
+                default  => normalize_default($info->{default}, $db_type),
+            };
+        }
+    }
+    return %schema;
+}
+
+# === Сбор схем ===
+print "Fetching schema from working database '$DBNAME'...\n";
+my %work_schema = get_schema($work_db, $config_ref{DBTYPE}, $DBNAME);
+
+print "Fetching schema from clean database '$clear_db_name'...\n";
+my %clear_schema = get_schema($clear_db, $config_ref{DBTYPE}, $clear_db_name);
+
+print "\n=== Comparing DB schemas ===\n\n";
+
+my $has_critical_error = 0;
+
+# === 1. Проверка: всё ли из чистой БД есть в рабочей? ===
+for my $table (keys %clear_schema) {
+    if (!exists $work_schema{$table}) {
+        print "❗ ERROR: Table '$table' exists in clean DB but not in working DB!\n";
+        $has_critical_error = 1;
+        next;
+    }
+
+    for my $col (keys %{ $clear_schema{$table} }) {
+        if (!exists $work_schema{$table}{$col}) {
+            print "❗ ERROR: Column '$col' in table '$table' exists in clean DB but not in working DB!\n";
+            $has_critical_error = 1;
+            next;
+        }
+        my $clean_name = $clear_schema{$table}{$col}{name} // '';
+        my $work_name  = $work_schema{$table}{$col}{name} // '';
+        if ($clean_name ne $work_name) {
+            print "❗ ERROR: Column '$col' in table '$table' has different name case:\n";
+            print "      Clean: '$clean_name', Working: '$work_name'\n";
+            $has_critical_error = 1;
+        }
+
+        # === Сравнение типов ===
+        my $clean_type = $clear_schema{$table}{$col}{type} // '';
+        my $work_type  = $work_schema{$table}{$col}{type} // '';
+
+        # Нормализуем типы для сравнения (MySQL vs PG)
+#        if ($config_ref{DBTYPE} eq 'mysql') {
+            # Пример: TINYINT(1) → boolean-like, но у нас SMALLINT
+            # Для простоты сравниваем как строки
+#        }
+
+        if ($clean_type ne $work_type) {
+            print "❗ ERROR: Column '$col' in table '$table' has different type:\n";
+            print "      Clean: '$clean_type', Working: '$work_type'\n";
+            $has_critical_error = 1;
+        }
+
+        # === Сравнение NULL ===
+        my $clean_null = $clear_schema{$table}{$col}{nullable} // 1;
+        my $work_null  = $work_schema{$table}{$col}{nullable} // 1;
+
+        if ($clean_null != $work_null) {
+            my $clean_str = $clean_null ? "NULL" : "NOT NULL";
+            my $work_str  = $work_null  ? "NULL" : "NOT NULL";
+            print "❗ ERROR: Column '$col' in table '$table' has different NULL setting:\n";
+            print "      Clean: $clean_str, Working: $work_str\n";
+            $has_critical_error = 1;
+        }
+
+        # === Сравнение DEFAULT ===
+        my $clean_def = $clear_schema{$table}{$col}{default};
+        my $work_def  = $work_schema{$table}{$col}{default};
+
+        if (!defined $clean_def && !defined $work_def) {
+            # ok
+        } elsif (!defined $clean_def || !defined $work_def) {
+            print "❗ ERROR: Column '$col' in table '$table' has different DEFAULT (one is NULL):\n";
+            print "      Clean: ", defined $clean_def ? "'$clean_def'" : "NULL", "\n";
+            print "      Working: ", defined $work_def ? "'$work_def'" : "NULL", "\n";
+            $has_critical_error = 1;
+        } elsif ($clean_def ne $work_def) {
+            print "❗ ERROR: Column '$col' in table '$table' has different DEFAULT:\n";
+            print "      Clean: '$clean_def', Working: '$work_def'\n";
+            $has_critical_error = 1;
+        }
+    }
+}
+
+# === 2. Проверка: есть ли лишнее в рабочей БД? ===
+for my $table (keys %work_schema) {
+    if (!exists $clear_schema{$table}) {
+        print "⚠  WARNING: Table '$table' exists in working DB but not in clean DB — will be skipped.\n";
+        next;
+    }
+
+    for my $col (keys %{ $work_schema{$table} }) {
+        if (!exists $clear_schema{$table}{$col}) {
+            print "⚠  WARNING: Column '$col' in table '$table' exists in working DB but not in clean DB — will be ignored.\n";
+        }
+    }
+}
+
+if ($has_critical_error) {
+    print "\nSchema validation failed: structural differences found.\n";
+    exit 103;
+}
+
+print "✅ Schema validation passed.\n\n";
+exit 0;

+ 493 - 0
docs/databases/checkDBschema.sh

@@ -0,0 +1,493 @@
+#!/bin/bash
+# Eye Script validating current DB schema for ALT Linux/Debian/Ubuntu with PostgreSQL support
+# Version: 1.0
+
+# set -e
+
+# Colors for output
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+BLUE='\033[0;34m'
+NC='\033[0m' # No Color
+
+# Output functions
+print_info() {
+    echo -e "${GREEN}[INFO]${NC} $1"
+}
+
+print_warn() {
+    echo -e "${YELLOW}[WARN]${NC} $1"
+}
+
+print_error() {
+    echo -e "${RED}[ERROR]${NC} $1"
+}
+
+print_step() {
+    echo -e "${BLUE}=== $1 ===${NC}"
+}
+
+# Check for root privileges
+check_root() {
+    if [[ $EUID -ne 0 ]]; then
+        print_error "This script must be run as root"
+        print_error "Use: sudo $0"
+        exit 1
+    fi
+}
+
+# Detect distribution and package manager
+detect_distro() {
+    if [[ -f /etc/os-release ]]; then
+        . /etc/os-release
+        OS_ID=$ID
+        OS_VERSION=$VERSION_ID
+        OS_NAME=$NAME
+
+        case $OS_ID in
+            altlinux)
+                PACKAGE_MANAGER="apt-get"
+                SERVICE_MANAGER="systemctl"
+                OS_FAMILY="alt"
+                print_info "Detected ALT Linux $OS_VERSION"
+                ;;
+            debian)
+                PACKAGE_MANAGER="apt"
+                SERVICE_MANAGER="systemctl"
+                OS_FAMILY="debian"
+                print_info "Detected Debian $OS_VERSION"
+                ;;
+            ubuntu)
+                PACKAGE_MANAGER="apt"
+                SERVICE_MANAGER="systemctl"
+                OS_FAMILY="debian"
+                print_info "Detected Ubuntu $OS_VERSION"
+                ;;
+            *)
+                print_error "Unsupported distribution: $OS_ID"
+                print_error "Supported: ALT Linux, Debian, Ubuntu"
+                exit 1
+                ;;
+        esac
+    else
+        print_error "Failed to detect distribution"
+        exit 1
+    fi
+}
+
+select_language() {
+    print_step "Select Installation Language"
+
+    if [ -n "${EYE_LANG}" ]; then
+	return
+	fi
+
+    echo "Available languages:"
+    echo "1) English"
+    echo "2) Russian (default)"
+    echo ""
+
+    while true; do
+        read -p "Select language (1 or 2) [2]: " lang_choice
+        
+        # Если пустой ввод - по умолчанию английский
+        if [[ -z "$lang_choice" ]]; then
+            lang_choice="2"
+        fi
+        
+        # Обработка ввода (приводим к нижнему регистру)
+        lang_choice_lower=$(echo "$lang_choice" | tr '[:upper:]' '[:lower:]')
+        
+        case $lang_choice_lower in
+            1|english|en|eng|анг|английский)
+                EYE_LANG="english"
+                EYE_LANG_SHORT="en"
+                print_info "Selected English language"
+                break
+                ;;
+            2|russian|ru|rus|ру|русский)
+                EYE_LANG="russian"
+                EYE_LANG_SHORT="ru"
+                print_info "Selected Russian language (Русский)"
+                break
+                ;;
+            *)
+                print_error "Invalid choice: '$lang_choice'"
+                print_warn "Available options: 1 (English), 2 (Russian)"
+                print_warn "You can also type: english, en, russian, ru"
+                ;;
+        esac
+    done
+}
+
+# Настройка параметров подключения к БД (общая для local и remote)
+configure_database_connection() {
+    echo ""
+    echo "Local Database Configuration"
+    echo "============================"
+    if [[ "$DB_TYPE" == "postgresql" ]]; then
+        DB_PORT="5432"
+    else
+        DB_PORT="3306"
+    fi
+}
+
+# Configure MySQL
+setup_mysql() {
+    print_step "Configuring MySQL"
+
+    # Check MySQL access
+    if ! command -v mysql &> /dev/null; then
+        print_error "MySQL client not installed"
+        return 1
+    fi
+
+    MYSQL_OPT="-u root"
+
+    # Check access without password
+    if mysql -u root -e "SELECT 1;" 2>/dev/null; then
+        print_info "MySQL accessible with empty password"
+        echo ""
+        print_warn "IMPORTANT: Need to set root password for MySQL!"
+        print_warn "After installation run: mysql_secure_installation"
+        echo ""
+    else
+        # Ask for password and create config file
+        read -p "Enter MySQL root user password: " DB_ROOT_PASSWORD
+        echo ""
+
+        # Create temporary config file
+        MYSQL_CNF_FILE="/tmp/mysql_root_eye.cnf"
+        echo "[client]" > "$MYSQL_CNF_FILE"
+        echo "user=root" >> "$MYSQL_CNF_FILE"
+        echo "password=$DB_ROOT_PASSWORD" >> "$MYSQL_CNF_FILE"
+        chmod 600 "$MYSQL_CNF_FILE"
+
+        # Check connection
+        if mysql --defaults-extra-file="$MYSQL_CNF_FILE" -e "SELECT 1;" &>/dev/null; then
+            print_info "Successfully connected to MySQL"
+            MYSQL_OPT="--defaults-extra-file=$MYSQL_CNF_FILE"
+        else
+            print_error "Incorrect MySQL root password"
+            rm -f "$MYSQL_CNF_FILE"
+            return 1
+        fi
+    fi
+
+    # === Проверка: существует ли база данных? ===
+    if mysql $MYSQL_OPT -sN -e "SHOW DATABASES;" | grep -q "^${DB_TEST}$"; then
+        print_error "Database '$DB_TEST' already exists. The script has been stopped."
+        exit 120
+        fi
+
+    print_info "Creating database..."
+
+    # Import main SQL file
+    mysql $MYSQL_OPT <<EOF
+CREATE DATABASE IF NOT EXISTS ${DB_TEST} DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+EOF
+
+    print_info "Importing database structure..."
+
+    mysql $MYSQL_OPT ${DB_TEST} < ${SQL_CREATE_FILE}
+
+    if [[ $? -ne 0 ]]; then
+        print_error "Error importing create_db.sql"
+        if [[ -f "$MYSQL_CNF_FILE" ]]; then
+            rm -f "$MYSQL_CNF_FILE"
+        fi
+        return 1
+    fi
+
+    print_info "Database structure imported"
+
+    # Create db user
+    print_info "Creating user ${DB_USER}.."
+    mysql $MYSQL_OPT <<EOF
+GRANT ALL PRIVILEGES ON $DB_TEST.* TO '$DB_USER'@'localhost';
+FLUSH PRIVILEGES;
+EOF
+
+    if [[ $? -ne 0 ]]; then
+        print_error "Error update user $DB_USER"
+        if [[ -f "$MYSQL_CNF_FILE" ]]; then
+            rm -f "$MYSQL_CNF_FILE"
+        fi
+        return 1
+    fi
+
+    # Clean up temporary file if created
+    if [[ -f "$MYSQL_CNF_FILE" ]]; then
+        rm -f "$MYSQL_CNF_FILE"
+    fi
+
+    return 0
+}
+
+# Configure PostgreSQL
+setup_postgresql() {
+    print_step "Configuring PostgreSQL"
+
+    # Определяем локаль на основе языка
+    if [[ "$EYE_LANG" == "russian" ]]; then
+        LC_TYPE="ru_RU.UTF-8"
+    else
+        LC_TYPE="en_US.UTF-8"
+    fi
+
+    # === Проверка: существует ли БД? ===
+    if sudo -u postgres psql -lqt | cut -d \| -f 1 | grep -qw "^\s*${DB_TEST}\s*$"; then
+        print_error "Database '$DB_TEST' already exists. The script has been stopped."
+        exit 120
+        fi
+
+    print_info "Creating database '$DB_TEST' with locale '$LC_TYPE'..."
+
+    sudo -u postgres createdb \
+      --encoding=UTF8 \
+      --lc-collate="$LC_TYPE" \
+      --lc-ctype="$LC_TYPE" \
+      --template=template0 \
+      --owner="$DB_USER" \
+      "$DB_TEST"
+
+    if [[ $? -ne 0 ]]; then
+        print_error "Failed to create database"
+        return 1
+    fi
+
+    print_info "Database created successfully with owner '$DB_USER'"
+
+    sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_TEST TO $DB_USER;"
+
+    # Теперь подключаемся как новый владелец для импорта
+    print_info "Importing database structure as '$DB_USER'..."
+
+    # Вариант 1: Используя sudo и переключение пользователя в psql
+    sudo -u postgres psql -d "$DB_TEST" <<EOF
+SET ROLE "$DB_USER";
+\i $SQL_CREATE_FILE
+EOF
+
+    if [[ $? -ne 0 ]]; then
+        print_error "Error importing create_db.sql"
+        exit 102
+    fi
+
+    print_info "Database structure imported successfully"
+
+    # Дополнительные привилегии 
+    print_info "Setting up additional privileges..."
+
+    # Дать доступ пользователю postgres к БД
+    sudo -u postgres psql -c "GRANT CONNECT ON DATABASE $DB_TEST TO postgres;"
+
+    # Дать полные права пользователю postgres на все объекты
+    sudo -u postgres psql -d "$DB_TEST" <<EOF
+GRANT ALL ON SCHEMA public TO postgres;
+ALTER DEFAULT PRIVILEGES FOR USER "$DB_USER" IN SCHEMA public GRANT ALL ON TABLES TO postgres;
+ALTER DEFAULT PRIVILEGES FOR USER "$DB_USER" IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres;
+ALTER DEFAULT PRIVILEGES FOR USER "$DB_USER" IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres;
+EOF
+
+    print_info "Database setup completed successfully"
+
+    return 0
+}
+
+# Configure database based on selected type
+setup_database() {
+    # Пропускаем настройку, если БД — удалённая
+    if [[ "$DB_INSTALL" != "local" ]]; then
+        print_info "Database is configured remotely — skipping local setup"
+        return 0
+    fi
+
+    print_step "Setting up local database"
+
+    # Определяем пути к SQL-файлам в зависимости от типа БД и языка
+    if [[ "$DB_TYPE" == "mysql" ]]; then
+        if [[ "$EYE_LANG" == "russian" && -d "/opt/Eye/docs/databases/mysql/ru" ]]; then
+            SQL_CREATE_FILE="/opt/Eye/docs/databases/mysql/ru/create_db.sql"
+        else
+            SQL_CREATE_FILE="/opt/Eye/docs/databases/mysql/en/create_db.sql"
+        fi
+    elif [[ "$DB_TYPE" == "postgresql" ]]; then
+        if [[ "$EYE_LANG" == "russian" && -d "/opt/Eye/docs/databases/postgres/ru" ]]; then
+            SQL_CREATE_FILE="/opt/Eye/docs/databases/postgres/ru/create_db.sql"
+        else
+            SQL_CREATE_FILE="/opt/Eye/docs/databases/postgres/en/create_db.sql"
+        fi
+    else
+        print_error "Unsupported database type: $DB_TYPE"
+        return 1
+    fi
+
+    # Проверка существования файлов
+    if [[ ! -f "$SQL_CREATE_FILE" ]]; then
+        print_error "SQL files not found for DB_TYPE=$DB_TYPE and EYE_LANG=$EYE_LANG"
+        return 1
+    fi
+
+    print_info "Using SQL files for $EYE_LANG language"
+
+    # Выполняем настройку в зависимости от СУБД
+    if [[ "$DB_TYPE" == "postgresql" ]]; then
+        setup_postgresql
+    else
+        setup_mysql
+    fi
+}
+
+# Install function
+install_clear_db() {
+    clear
+    echo -e "${GREEN}================++++++++===========================${NC}"
+    echo -e "${GREEN}   CheckDB Schema for Eye Monitoring System        ${NC}"
+    echo -e "${GREEN}           for ALT Linux/Debian/Ubuntu             ${NC}"
+    echo -e "${GREEN}===================================================${NC}"
+    echo ""
+
+    # Обязательные шаги (всегда)
+    check_root
+    detect_distro
+    select_language
+
+    # Настройка БД
+    configure_database_connection
+    setup_database
+
+    #data migration
+    /opt/Eye/docs/databases/checkDBschema.pl
+
+    echo "The $DB_TEST database can be deleted"
+}
+
+# Function to display help
+show_help() {
+    echo "Usage: $0"
+    echo "\tThe script checks the correctness of the working database structure."
+    echo "\tTo do this, it creates a new empty database with a reference structure,"
+    echo "\tand then compares the two databases. "
+    echo "\tThe name of the test database is formed from the name of the working database with _test appended to it."
+    echo ""
+    echo "Options:"
+    echo "  --help, -h     Show this help"
+    echo ""
+    echo "Supported distributions:"
+    echo "  - ALT Linux 11.1+"
+    echo "  - Debian 11+"
+    echo "  - Ubuntu 20.04+"
+    echo ""
+}
+
+# Function to check directory existence
+check_directory() {
+    [ -d "/opt/Eye" ]
+    return $?
+}
+
+# Инициализация глобальных переменных
+DB_NAME=""
+DB_USER=""
+DB_HOST=""
+DB_PASS=""
+DB_TYPE="mysql"
+EYE_LANG="russian"
+SQL_CREATE_FILE=""
+
+PHP_CONFIG="/opt/Eye/html/cfg/config.php"
+PERL_CONFIG="/opt/Eye/scripts/cfg/config"
+
+# Проверяем наличие хотя бы одного конфига Eye
+if [[ -f "${PHP_CONFIG}" ]] || [[ -f "${PERL_CONFIG}" ]]; then
+        echo "✓ Eye configuration detected"
+    else
+	echo "Eye installation not found! Bye."
+	exit 101
+    fi
+
+if [[ -f "${PHP_CONFIG}" ]]; then
+            # Извлекаем DB_HOST из PHP-конфига
+            DB_HOST=$(grep -oP 'define\s*\(\s*"DB_HOST"\s*,\s*"\K[^"]+' ${PHP_CONFIG} 2>/dev/null)
+    fi
+if [[ -z "$DB_HOST" && -f "${PERL_CONFIG}" ]]; then
+            # Извлекаем из Perl-конфига
+            DB_HOST=$(grep -oP '^DBHOST=\K.*' ${PERL_CONFIG} 2>/dev/null)
+    fi
+
+if [[ "$DB_HOST" == "127.0.0.1" || "$DB_HOST" == "localhost" || "$DB_HOST" == "::1" ]]; then
+            DB_INSTALL="local"
+        else
+            echo "Remote database detected. Abort installation!"
+            exit 100
+        fi
+
+# === Восстанавливаем DB_TYPE ===
+if [[ -f "${PHP_CONFIG}" ]]; then
+            DB_TYPE=$(grep -oP 'define\s*\(\s*"DB_TYPE"\s*,\s*"\K[^"]+' ${PHP_CONFIG} 2>/dev/null)
+            # В PHP может быть 'pgsql' вместо 'postgresql'
+            if [[ "$DB_TYPE" == "pgsql" ]]; then
+                DB_TYPE="postgresql"
+            elif [[ "$DB_TYPE" == "mysql" ]]; then
+                DB_TYPE="mysql"
+            fi
+        elif [[ -f "${PERL_CONFIG}" ]]; then
+            DB_TYPE=$(grep -oP '^DBTYPE=\K.*' ${PERL_CONFIG} 2>/dev/null)
+        fi
+
+if [[ -f "$PHP_CONFIG" ]]; then
+    # Извлекаем язык
+    if HTML_LANG=$(grep -oP 'define\s*\(\s*"HTML_LANG"\s*,\s*"\K[^"]+' "$PHP_CONFIG" 2>/dev/null); then
+        case "$HTML_LANG" in
+            russian|ru) EYE_LANG="russian" ;;
+            english|en) EYE_LANG="english" ;;
+        esac
+    fi
+
+    # Извлекаем БД параметры
+    DB_NAME=$(grep -oP 'define\s*\(\s*"DB_NAME"\s*,\s*"\K[^"]+' "$PHP_CONFIG" 2>/dev/null)
+    DB_USER=$(grep -oP 'define\s*\(\s*"DB_USER"\s*,\s*"\K[^"]+' "$PHP_CONFIG" 2>/dev/null)
+    DB_HOST=$(grep -oP 'define\s*\(\s*"DB_HOST"\s*,\s*"\K[^"]+' "$PHP_CONFIG" 2>/dev/null)
+    DB_PASS=$(grep -oP 'define\s*\(\s*"DB_PASS"\s*,\s*"\K[^"]+' "$PHP_CONFIG" 2>/dev/null)
+fi
+
+# читаем из Perl-конфига ===
+
+if [[ -z "$DB_NAME" || -z "$DB_USER" || -z "$DB_PASS" ]] && [[ -f "$PERL_CONFIG" ]]; then
+    while IFS='=' read -r key value; do
+        # Пропускаем комментарии и пустые строки
+        [[ $key =~ ^#.*$ || -z $key ]] && continue
+        case "$key" in
+            DBNAME)  DB_NAME="$value" ;;
+            DBUSER)  DB_USER="$value" ;;
+            DBSERVER) DB_HOST="$value" ;;
+            DBPASS) DB_PASS="$value" ;;
+        esac
+    done < "$PERL_CONFIG"
+    fi
+
+if [ -z "${DB_TYPE}" ]; then
+    DB_TYPE='mysql'
+    fi
+
+# === Вывод результатов (для отладки или использования в других скриптах) ===
+echo "EYE_LANG=$EYE_LANG"
+echo "DB_NAME=$DB_NAME"
+echo "DB_USER=$DB_USER"
+echo "DB_HOST=$DB_HOST"
+echo "DB_TYPE=$DB_TYPE"
+
+DB_TEST="${DB_NAME}_test"
+
+# Убедимся, что все необходимые параметры получены
+if [[ -z "$DB_NAME" || -z "$DB_USER" || -z "$DB_PASS" ]]; then
+    print_error "Failed to extract database credentials from config files"
+    exit 1
+fi
+
+install_clear_db
+
+# Exit with success code
+exit 0

+ 360 - 0
docs/databases/migrate2psql.pl

@@ -0,0 +1,360 @@
+#!/usr/bin/perl
+
+#
+# Copyright (C) Roman Dmitriev, rnd@rajven.ru
+#
+
+use utf8;
+use open ":encoding(utf8)";
+use open ':std', ':encoding(UTF-8)';
+use Encode;
+no warnings 'utf8';
+use English;
+use FindBin '$Bin';
+use lib "/opt/Eye/scripts";
+use Getopt::Long qw(GetOptions);
+use Data::Dumper;
+use eyelib::config;
+use eyelib::main;
+use eyelib::database;
+use eyelib::common;
+use eyelib::net_utils;
+use strict;
+use warnings;
+
+my $chunk_count = 1000;
+
+sub batch_sql_cached {
+    my ($db, $sql, $data) = @_;
+    # Запоминаем исходное состояние AutoCommit
+    my $original_autocommit = $db->{AutoCommit};
+    eval {
+        # Выключаем AutoCommit для транзакции
+        $db->{AutoCommit} = 0;
+        my $sth = $db->prepare_cached($sql)  or die "Unable to prepare SQL: " . $db->errstr;
+        for my $params (@$data) {
+            next unless @$params;
+            $sth->execute(@$params) or die "Unable to execute with params [" . join(',', @$params) . "]: " . $sth->errstr;
+        }
+        $db->commit();
+        1;
+    } or do {
+        my $err = $@ || 'Unknown error';
+        eval { $db->rollback() };
+        warn "batch_sql_cached failed: $err";
+        # Восстанавливаем AutoCommit даже при ошибке
+        $db->{AutoCommit} = $original_autocommit;
+        return 0;
+    };
+    # Восстанавливаем исходный режим AutoCommit
+    $db->{AutoCommit} = $original_autocommit;
+    return 1;
+}
+
+# debug disable force
+$debug = 0;
+
+# === Разбор аргументов командной строки ===
+my $opt_clear = 0;
+my $opt_batch = 0;
+GetOptions(
+    'clear' => \$opt_clear,
+    'batch' => \$opt_batch,
+) or die "Usage: $0 [--clear] [--batch]\n";
+
+# === Явное указание портов ===
+my $MYSQL_PORT = 3306;
+my $PG_PORT    = 5432;
+
+# === Подключение к MySQL (источник) ===
+my $mysql_dsn = "dbi:mysql:database=$DBNAME;host=$DBHOST;port=$MYSQL_PORT;mysql_local_infile=1";
+my $mysql_db = DBI->connect($mysql_dsn, $DBUSER, $DBPASS, {
+    RaiseError => 0,
+    AutoCommit => 1,
+    mysql_enable_utf8 => 1
+});
+if (!defined $mysql_db) {
+    die "Cannot connect to MySQL server: $DBI::errstr\n";
+}
+$mysql_db->do('SET NAMES utf8mb4');
+
+# === Подключение к PostgreSQL (цель) ===
+my $pg_dsn = "dbi:Pg:dbname=$DBNAME;host=$DBHOST;port=$PG_PORT;";
+my $pg_db = DBI->connect($pg_dsn, $DBUSER, $DBPASS, {
+    RaiseError => 0,
+    AutoCommit => 1,
+    pg_enable_utf8 => 1,
+    pg_server_prepare => 0
+});
+if (!defined $pg_db) {
+    print "Cannot connect to PostgreSQL server: $DBI::errstr\n";
+    print "For install/configure PostgreSQL server please run migrate2psql.sh!\n";
+    exit 100;
+}
+
+# === Получение списка таблиц ===
+print "Fetching table list from MySQL...\n";
+my @migration_tables = get_records_sql($mysql_db, 'SHOW TABLES');
+my %tables;
+my $table_index = 'Tables_in_' . $DBNAME;
+
+foreach my $row (@migration_tables) {
+    next unless $row && exists $row->{$table_index};
+    my $table_name = $row->{$table_index};
+    # Пропускаем traffic_detail (слишком большая)
+    $tables{$table_name} = ($table_name !~ /(traffic_detail|sessions)/) ? 1 : 0;
+}
+
+# Фильтруем только те, что будем мигрировать
+my @tables_to_migrate = sort grep { $tables{$_} } keys %tables;
+my $total_tables = scalar @tables_to_migrate;
+
+if ($total_tables == 0) {
+    print "No tables to migrate!\n";
+    exit 0;
+}
+
+# === Опционально: очистка всех таблиц перед импортом ===
+if ($opt_clear) {
+    print "\n⚠️  --clear mode: Truncating all target tables before import...\n";
+    for my $table (@tables_to_migrate) {
+        eval {
+            $pg_db->do("TRUNCATE TABLE \"$table\" RESTART IDENTITY");
+        };
+        if ($@) {
+            chomp $@;
+            print "  ⚠️  Failed to truncate table '$table': $@\n";
+        } else {
+            print "  → Truncated: $table\n";
+        }
+    }
+    print "\n";
+}
+
+print "\n=== Check DB schema ===\n\n";
+
+# === Сбор полной схемы из обеих БД ===
+print "Fetching schema from MySQL and PostgreSQL...\n";
+
+# === Сбор схем ===
+my %schema;
+for my $table (@tables_to_migrate) {
+    next if $table =~ /(traffic_detail|sessions)/i;
+    $schema{mysql}{$table} = { get_table_columns($mysql_db, $table) };
+}
+
+my @pg_tables = map { $_->{tablename} } get_records_sql($pg_db, "SELECT tablename FROM pg_tables WHERE schemaname = 'public'");
+for my $table (@pg_tables) {
+    next if $table =~ /(traffic_detail|sessions)/i;
+    $schema{pg}{$table} = { get_table_columns($pg_db, $table) };
+}
+
+# === Флаг ошибки ===
+my $has_critical_error = 0;
+
+# === 1. Проверка: всё ли из PostgreSQL есть в MySQL? ===
+for my $table (keys %{ $schema{pg} }) {
+    if (!exists $schema{mysql}{$table}) {
+        print "❗ ERROR: Table '$table' exists in PostgreSQL but not in MySQL!\n";
+        $has_critical_error = 1;
+        next;
+    }
+
+    for my $col (keys %{ $schema{pg}{$table} }) {
+        if (!exists $schema{mysql}{$table}{$col}) {
+            print "❗ ERROR: Column '$col' in table '$table' exists in PostgreSQL but not in MySQL!\n";
+            $has_critical_error = 1;
+        }
+    }
+}
+
+# === 2. Проверка: есть ли лишнее в MySQL? ===
+for my $table (keys %{ $schema{mysql} }) {
+    if (!exists $schema{pg}{$table}) {
+        print "⚠️  WARNING: Table '$table' exists in MySQL but not in PostgreSQL — will be skipped.\n";
+        next;
+    }
+
+    for my $col (keys %{ $schema{mysql}{$table} }) {
+        if (!exists $schema{pg}{$table}{$col}) {
+            print "⚠️  WARNING: Column '$col' in table '$table' exists in MySQL but not in PostgreSQL — will be ignored.\n";
+        }
+    }
+}
+
+if ($has_critical_error) {
+    print "\nSchema validation failed: missing required tables/columns in source MySQL database.\n";
+    exit 103;
+}
+
+print "✅ Schema validation passed.\n\n";
+
+print "\n=== Starting migration of $total_tables tables ===\n\n";
+
+# === Миграция по таблицам с прогрессом ===
+for my $idx (0 .. $#tables_to_migrate) {
+    my $table = $tables_to_migrate[$idx];
+    my $table_num = $idx + 1;
+
+    if (!exists $schema{pg}->{$table}) { next; }
+
+    print "[$table_num/$total_tables] Processing table: $table\n";
+
+    my $rec_count = get_count_records($mysql_db, $table);
+    print "  → Expected records: $rec_count\n";
+
+    if ($rec_count == 0) {
+        print "  → Empty table. Skipping.\n\n";
+        next;
+    }
+
+
+    my $inserted = 0;
+    my $errors   = 0;
+
+    # === Построчное чтение ===
+    my $select_sth = $mysql_db->prepare("SELECT * FROM `$table`");
+    $select_sth->execute();
+
+# === Режим вставки: построчный или пакетный ===
+if ($opt_batch) {
+    print "  → Using BATCH mode ($chunk_count records per chunk)\n";
+
+    # Берём колонки напрямую из PostgreSQL-схемы — они все есть в MySQL
+    my @valid_columns = sort keys %{ $schema{pg}{$table} };
+
+    my $quoted_columns = '"' . join('", "', @valid_columns) . '"';
+    my $placeholders   = join(', ', ('?') x @valid_columns);
+    my $insert_sql     = "INSERT INTO \"$table\" ($quoted_columns) VALUES ($placeholders)";
+
+    my @batch_buffer;
+    my $chunk_size = $chunk_count;
+
+    my $processed = 0;
+    my $report_every = 10_000;
+
+
+    while (my $row = $select_sth->fetchrow_hashref) {
+        my @values;
+        for my $col (@valid_columns) {
+            my $raw_value = $row->{$col};
+            my $norm_value = normalize_value($raw_value, $schema{pg}{$table}{$col});
+            push @values, $norm_value;
+        }
+        push @batch_buffer, \@values;
+        $processed++;
+
+        if (@batch_buffer >= $chunk_count) {
+            my $insert_status = batch_sql_cached($pg_db, $insert_sql, \@batch_buffer);
+            if ($insert_status) {
+                $inserted += @batch_buffer;
+            } else {
+                $errors += @batch_buffer;
+            }
+            @batch_buffer = ();
+
+            # Прогресс
+            if ($processed % $report_every == 0) {
+                my $pct = int($processed * 100 / $rec_count);
+                printf "  → Processed: %d / %d (%d%%)\r", $processed, $rec_count, $pct;
+                $| = 1;  # flush STDOUT
+            }
+        }
+    }
+
+    # Остаток
+    if (@batch_buffer) {
+        my $insert_status = batch_sql_cached($pg_db, $insert_sql, \@batch_buffer);
+        if ($insert_status) {
+            $inserted += @batch_buffer;
+        } else {
+            $errors += @batch_buffer;
+        }
+        $processed += @batch_buffer;
+    }
+
+    # Финальная строка
+    printf "  → Processed: %d / %d (100%%)\n", $processed, $rec_count;
+
+    } else {
+
+    # === Построчный режим ===
+    my $processed = 0;
+    my $report_every = 10_000;
+
+    while (my $row = $select_sth->fetchrow_hashref) {
+        my %row_normalized;
+        for my $col (keys %{ $schema{pg}{$table} }) {
+            my $raw_value = $row->{$col};
+            my $norm_value = normalize_value($raw_value, $schema{pg}{$table}{$col});
+            $row_normalized{$col} = $norm_value;
+        }
+
+        my $ret_id = insert_record($pg_db, $table, \%row_normalized);
+        if ($ret_id > 0) {
+            $inserted++;
+        } else {
+            $errors++;
+            print Dumper(\%row_normalized) if ($debug);
+        }
+
+        $processed++;
+
+        # Прогресс каждые N строк
+        if ($rec_count > 0 && $processed % $report_every == 0) {
+            my $pct = int($processed * 100 / $rec_count);
+            printf "  → Processed: %d / %d (%d%%)\r", $processed, $rec_count, $pct;
+            $| = 1;  # flush
+        }
+    }
+    $select_sth->finish();
+
+    # Финальная строка
+    if ($rec_count > 0) {
+        printf "  → Processed: %d / %d (100%%)\n", $processed, $rec_count;
+        } else {
+        print "  → Processed: $processed records\n";
+        }
+    }
+
+    # === Итог по таблице ===
+    my $status = ($errors == 0) ? "✅ SUCCESS" : "⚠️  COMPLETED WITH ERRORS";
+    print "  → Result: $status\n";
+    print "     Inserted: $inserted | Errors: $errors | Expected: $rec_count\n";
+    
+    if ($inserted + $errors != $rec_count) {
+        print "    ❗ WARNING: Record count mismatch! (source: $rec_count, processed: " . ($inserted + $errors) . ")\n";
+    }
+    
+    print "\n";
+}
+
+print "\n=== Resetting all table sequences ===\n";
+
+# Получаем список всех таблиц из целевой схемы (PostgreSQL)
+my $tables_sql = "SELECT tablename FROM pg_tables WHERE schemaname = 'public'";
+my $sth = $pg_db->prepare($tables_sql);
+$sth->execute();
+
+while (my ($table) = $sth->fetchrow_array) {
+    # Формируем имя последовательности
+    my $seq_name = "${table}_id_seq";
+    # Проверяем, существует ли такая последовательность
+    my ($exists) = $pg_db->selectrow_array(
+        "SELECT 1 FROM pg_class WHERE relname = ? AND relkind = 'S'",
+        undef, $seq_name
+    );
+    if ($exists) {
+        # Получаем MAX(id)
+        my ($max_id) = $pg_db->selectrow_array("SELECT MAX(id) FROM \"$table\"");
+        $max_id //= 1;
+        # Сбрасываем последовательность
+        $pg_db->do("SELECT setval('$seq_name', $max_id)");
+        print "  → $table: sequence reset to $max_id\n";
+    }
+}
+
+print "✅ All sequences updated.\n";
+
+print "🎉 Migration completed! Processed $total_tables tables.\n";
+exit 0;

+ 583 - 0
docs/databases/migrate2psql.sh

@@ -0,0 +1,583 @@
+#!/bin/bash
+# Eye Migration Script for ALT Linux/Debian/Ubuntu with PostgreSQL support
+# Version: 1.0
+
+# set -e
+
+# Colors for output
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+BLUE='\033[0;34m'
+NC='\033[0m' # No Color
+
+# Output functions
+print_info() {
+    echo -e "${GREEN}[INFO]${NC} $1"
+}
+
+print_warn() {
+    echo -e "${YELLOW}[WARN]${NC} $1"
+}
+
+print_error() {
+    echo -e "${RED}[ERROR]${NC} $1"
+}
+
+print_step() {
+    echo -e "${BLUE}=== $1 ===${NC}"
+}
+
+# Check for root privileges
+check_root() {
+    if [[ $EUID -ne 0 ]]; then
+        print_error "This script must be run as root"
+        print_error "Use: sudo $0"
+        exit 1
+    fi
+}
+
+service_exists() {
+    systemctl cat "$1.service" >/dev/null 2>&1
+}
+
+safe_start_service() {
+    local svc="$1"
+    if service_exists "$svc"; then
+        if systemctl start "$svc"; then
+            print_info "Service ${svc} has been successfully started"
+        else
+            print_error "Failed to start ${svc}"
+        fi
+    fi
+}
+
+safe_stop_service() {
+    local svc="$1"
+    if service_exists "$svc"; then
+        if systemctl stop "$svc"; then
+            print_info "Service ${svc} has been successfully stopped"
+        else
+            print_error "Failed to stop ${svc}"
+        fi
+    fi
+}
+
+stop_eye() {
+    print_step "Stopping services"
+    local PHP_VERSION
+    PHP_VERSION=$(php -v 2>/dev/null | head -n1 | grep -oP '\d+\.\d+' || echo "")
+    if [ -n "${PHP_VERSION}" ]; then
+        safe_stop_service "php${PHP_VERSION}-fpm"
+    fi
+
+    for svc in cron eye-statd dhcp-log stat-sync syslog-stat; do
+        safe_stop_service "$svc"
+    done
+}
+
+start_eye() {
+    local PHP_VERSION
+    PHP_VERSION=$(php -v 2>/dev/null | head -n1 | grep -oP '\d+\.\d+' || echo "")
+    if [ -n "${PHP_VERSION}" ]; then
+        safe_start_service "php${PHP_VERSION}-fpm"
+    fi
+
+    for svc in cron eye-statd dhcp-log stat-sync syslog-stat; do
+        safe_start_service "$svc"
+    done
+}
+
+# Detect distribution and package manager
+detect_distro() {
+    if [[ -f /etc/os-release ]]; then
+        . /etc/os-release
+        OS_ID=$ID
+        OS_VERSION=$VERSION_ID
+        OS_NAME=$NAME
+
+        case $OS_ID in
+            altlinux)
+                PACKAGE_MANAGER="apt-get"
+                SERVICE_MANAGER="systemctl"
+                OS_FAMILY="alt"
+                print_info "Detected ALT Linux $OS_VERSION"
+                ;;
+            debian)
+                PACKAGE_MANAGER="apt"
+                SERVICE_MANAGER="systemctl"
+                OS_FAMILY="debian"
+                print_info "Detected Debian $OS_VERSION"
+                ;;
+            ubuntu)
+                PACKAGE_MANAGER="apt"
+                SERVICE_MANAGER="systemctl"
+                OS_FAMILY="debian"
+                print_info "Detected Ubuntu $OS_VERSION"
+                ;;
+            *)
+                print_error "Unsupported distribution: $OS_ID"
+                print_error "Supported: ALT Linux, Debian, Ubuntu"
+                exit 1
+                ;;
+        esac
+    else
+        print_error "Failed to detect distribution"
+        exit 1
+    fi
+}
+
+select_language() {
+    print_step "Select Installation Language"
+
+    if [ -n "${EYE_LANG}" ]; then
+	return
+	fi
+
+    echo "Available languages:"
+    echo "1) English"
+    echo "2) Russian (default)"
+    echo ""
+
+    while true; do
+        read -p "Select language (1 or 2) [2]: " lang_choice
+        
+        # Если пустой ввод - по умолчанию английский
+        if [[ -z "$lang_choice" ]]; then
+            lang_choice="2"
+        fi
+        
+        # Обработка ввода (приводим к нижнему регистру)
+        lang_choice_lower=$(echo "$lang_choice" | tr '[:upper:]' '[:lower:]')
+        
+        case $lang_choice_lower in
+            1|english|en|eng|анг|английский)
+                EYE_LANG="english"
+                EYE_LANG_SHORT="en"
+                print_info "Selected English language"
+                break
+                ;;
+            2|russian|ru|rus|ру|русский)
+                EYE_LANG="russian"
+                EYE_LANG_SHORT="ru"
+                print_info "Selected Russian language (Русский)"
+                break
+                ;;
+            *)
+                print_error "Invalid choice: '$lang_choice'"
+                print_warn "Available options: 1 (English), 2 (Russian)"
+                print_warn "You can also type: english, en, russian, ru"
+                ;;
+        esac
+    done
+}
+
+# Настройка параметров подключения к БД (общая для local и remote)
+configure_database_connection() {
+    echo ""
+    echo "Local Database Configuration"
+    echo "============================"
+    DB_HOST="127.0.0.1"
+    DB_PORT="5432"
+    echo "Database server: $DB_HOST:$DB_PORT (local)"
+}
+
+# Install dependencies for ALT Linux
+install_deps_altlinux() {
+    print_step "Installing dependencies for ALT Linux"
+    apt-get update
+    # === Локальная база данных
+    apt-get install -y postgresql17 postgresql17-server postgresql17-contrib postgresql17-perl
+}
+
+# Install dependencies for Debian/Ubuntu
+install_deps_debian() {
+    print_step "Installing dependencies for Debian/Ubuntu"
+    apt-get update
+    # === Локальная база данных
+    apt-get install -y postgresql postgresql-contrib postgresql-server-dev-all
+}
+
+# System update
+update_system() {
+    print_step "Updating apt cache"
+    $PACKAGE_MANAGER update -y
+}
+
+# Install packages
+install_packages() {
+    print_step "Installing packages"
+
+    case $OS_FAMILY in
+        alt)
+            install_deps_altlinux
+            ;;
+        debian)
+            install_deps_debian
+            ;;
+    esac
+}
+
+# Configure PostgreSQL
+setup_postgresql() {
+    print_step "Configuring PostgreSQL"
+
+    PGDATA="/var/lib/pgsql/data"
+
+    # Для ALT Linux
+    if [[ "$OS_FAMILY" == "alt" ]]; then
+        echo "root ALL=(ALL:ALL) NOPASSWD: ALL" >/etc/sudoers.d/root
+        PGDATA="/var/lib/pgsql/data"
+
+        if [ -z "$(ls -A $PGDATA 2>/dev/null)" ]; then
+            /etc/init.d/postgresql initdb
+
+            # === ВАЖНО: настраиваем pg_hba.conf для безпарольного доступа ===
+            local pg_hba_file="$PGDATA/pg_hba.conf"
+            if [[ -f "$pg_hba_file" ]]; then
+                # Делаем резервную копию
+                cp "$pg_hba_file" "${pg_hba_file}.backup"
+
+                # Вставляем правило для пользователя 'postgres' в начало файла
+                # Это разрешит подключение без пароля через Unix-сокет
+                sed -i '1i\
+# Allow local postgres user without password\
+local   all             postgres                                peer\
+' "$pg_hba_file"
+
+                print_info "Configured pg_hba.conf to allow peer authentication for 'postgres'"
+            fi
+        fi
+
+        # Start and enable service
+        $SERVICE_MANAGER enable postgresql
+        $SERVICE_MANAGER restart postgresql
+    else
+        # Start and enable service
+        $SERVICE_MANAGER enable postgresql
+        $SERVICE_MANAGER start postgresql
+    fi
+
+    # Check PostgreSQL access
+    if ! command -v psql &> /dev/null; then
+        print_error "PostgreSQL client not installed"
+        return 1
+    fi
+
+    # Определяем локаль на основе языка
+    if [[ "$EYE_LANG" == "russian" ]]; then
+        LC_TYPE="ru_RU.UTF-8"
+    else
+        LC_TYPE="en_US.UTF-8"
+    fi
+
+    # === Проверка: существует ли БД? ===
+    if sudo -u postgres psql -lqt | cut -d \| -f 1 | grep -qw "^\s*${DB_NAME}\s*$"; then
+        print_error "Database '$DB_NAME' already exists. The script has been stopped."
+        exit 120
+        fi
+
+    print_info "Creating database '$DB_NAME' with locale '$LC_TYPE'..."
+
+    # Set password for stat user
+    print_info "Setting password for user $DB_USER ..."
+    sudo -u postgres psql -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';"
+
+    sudo -u postgres createdb \
+      --encoding=UTF8 \
+      --lc-collate="$LC_TYPE" \
+      --lc-ctype="$LC_TYPE" \
+      --template=template0 \
+      --owner="$DB_USER" \
+      "$DB_NAME"
+
+    if [[ $? -ne 0 ]]; then
+        print_error "Failed to create database"
+        return 1
+    fi
+
+    print_info "Database created successfully with owner '$DB_USER'"
+
+    sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;"
+
+    # Теперь подключаемся как новый владелец для импорта
+    print_info "Importing database structure as '$DB_USER'..."
+
+    # Вариант 1: Используя sudo и переключение пользователя в psql
+    sudo -u postgres psql -d "$DB_NAME" <<EOF
+SET ROLE "$DB_USER";
+\i $SQL_CREATE_FILE
+EOF
+
+    if [[ $? -ne 0 ]]; then
+        print_error "Error importing create_db.sql"
+        exit 102
+    fi
+
+    print_info "Database structure imported successfully"
+
+    # Дополнительные привилегии 
+    print_info "Setting up additional privileges..."
+
+    # Дать доступ пользователю postgres к БД
+    sudo -u postgres psql -c "GRANT CONNECT ON DATABASE $DB_NAME TO postgres;"
+
+    # Дать полные права пользователю postgres на все объекты
+    sudo -u postgres psql -d "$DB_NAME" <<EOF
+GRANT ALL ON SCHEMA public TO postgres;
+ALTER DEFAULT PRIVILEGES FOR USER "$DB_USER" IN SCHEMA public GRANT ALL ON TABLES TO postgres;
+ALTER DEFAULT PRIVILEGES FOR USER "$DB_USER" IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres;
+ALTER DEFAULT PRIVILEGES FOR USER "$DB_USER" IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres;
+EOF
+
+    print_info "Database setup completed successfully"
+
+    # Configure PostgreSQL for MD5 authentication
+    if [[ "$OS_FAMILY" == "alt" ]]; then
+        local pg_hba_file="/var/lib/pgsql/data/pg_hba.conf"
+        if [[ -f "$pg_hba_file" ]]; then
+            # Backup original
+            cp "$pg_hba_file" "${pg_hba_file}.backup"
+            # Add local md5 authentication if not present
+            if ! grep -q "local.*$DB_NAME.*md5" "$pg_hba_file"; then
+                echo "local   $DB_NAME            $DB_USER                                    scram-sha-256" >> "$pg_hba_file"
+                print_info "Added MD5 authentication for $DB_USER user in pg_hba.conf"
+                fi
+            fi
+        else
+        local pg_hba_file="/etc/postgresql/$(ls /etc/postgresql/ | head -1)/main/pg_hba.conf"
+        if [[ -f "$pg_hba_file" ]]; then
+            # Backup original
+            cp "$pg_hba_file" "${pg_hba_file}.backup"
+            # Add local md5 authentication if not present
+            if ! grep -q "local.*$DB_NAME.*md5" "$pg_hba_file"; then
+                echo "local   $DB_NAME            $DB_USER                                    scram-sha-256" >> "$pg_hba_file"
+                print_info "Added MD5 authentication for $DB_USER user in pg_hba.conf"
+                fi
+            fi
+        fi
+
+    # Restart PostgreSQL to apply changes
+    $SERVICE_MANAGER restart postgresql
+
+    print_info "User $DB_USER password: $DB_PASS"
+
+    return 0
+}
+
+# Configure database based on selected type
+setup_database() {
+    print_step "Setting up local database"
+
+    # Определяем пути к SQL-файлам в зависимости от типа БД и языка
+    if [[ "$DB_TYPE" == "postgresql" ]]; then
+        if [[ "$EYE_LANG" == "russian" && -d "/opt/Eye/docs/databases/postgres/ru" ]]; then
+            SQL_CREATE_FILE="/opt/Eye/docs/databases/postgres/ru/create_db.sql"
+        else
+            SQL_CREATE_FILE="/opt/Eye/docs/databases/postgres/en/create_db.sql"
+        fi
+    else
+        print_error "Unsupported database type: $DB_TYPE"
+        return 1
+    fi
+
+    # Проверка существования файлов
+    if [[ ! -f "$SQL_CREATE_FILE" ]]; then
+        print_error "SQL files not found for DB_TYPE=$DB_TYPE and EYE_LANG=$EYE_LANG"
+        return 1
+    fi
+    print_info "Using SQL files for $EYE_LANG language"
+    setup_postgresql
+}
+
+# Install function
+eye_migrate2pgsql() {
+    clear
+    echo -e "${GREEN}================++++++++===========================${NC}"
+    echo -e "${GREEN}   Migration Eye Monitoring System to PostgreSQL   ${NC}"
+    echo -e "${GREEN}           for ALT Linux/Debian/Ubuntu             ${NC}"
+    echo -e "${GREEN}===================================================${NC}"
+    echo ""
+
+    # Обязательные шаги (всегда)
+    check_root
+    detect_distro
+    select_language
+
+    # Обновление системы и установка пакетов (зависит от типа установки и ОС)
+    update_system
+    install_packages
+
+    # Настройка БД
+    configure_database_connection
+    setup_database
+    
+    #data migration
+    /opt/Eye/docs/databases/migrate2psql.pl --clear --batch
+    
+    if [ $? -eq 0 ]; then
+	setup_configs
+	fi
+}
+
+# Function to display help
+show_help() {
+    echo "Usage: $0 [options]"
+    echo ""
+    echo "Options:"
+    echo "  --help, -h     Show this help"
+    echo ""
+    echo "Supported distributions:"
+    echo "  - ALT Linux 11.1+"
+    echo "  - Debian 11+"
+    echo "  - Ubuntu 20.04+"
+    echo ""
+}
+
+# Function to check directory existence
+check_directory() {
+    [ -d "/opt/Eye" ]
+    return $?
+}
+
+# Configure configuration files
+setup_configs() {
+    print_step "Configuring configuration files"
+
+    # === Настройка веб-конфигурации (только если нужен веб) ===
+    if [[ -f "/opt/Eye/html/cfg/config.php" ]]; then
+            cp /opt/Eye/html/cfg/config.php /opt/Eye/html/cfg/config.migration.php
+            PHP_DB_TYPE="pgsql"
+            # Подстановка реальных значений
+            sed -i "s/define(\"DB_TYPE\",\"[^\"]*\");/define(\"DB_TYPE\",\"$PHP_DB_TYPE\");/" /opt/Eye/html/cfg/config.php
+            sed -i "s/define(\"DB_PORT\",\"[^\"]*\");/define(\"DB_PORT\",\"$DB_PORT\");/" /opt/Eye/html/cfg/config.php
+            print_info "Web configuration file config.php created"
+        else
+            print_warn "Web config template not found, skipping PHP config"
+        fi
+        
+    # === Настройка конфигурации бэкенда (только если нужен бэкенд) ===
+    if [[ -f "/opt/Eye/scripts/cfg/config.sample" ]]; then
+            cp /opt/Eye/scripts/cfg/config /opt/Eye/scripts/cfg/config.migration
+            # Подстановка значений
+            sed -i "s/^DBTYPE=.*/DBTYPE=$DB_TYPE/" /opt/Eye/scripts/cfg/config
+            sed -i "s/DBTYPE=mysql/DBTYPE=$DB_TYPE/" /opt/Eye/scripts/cfg/config
+            sed -i "s/^DBPORT=.*/DBPORT=$DB_PORT/" /opt/Eye/scripts/cfg/config
+            print_info "Backend configuration file scripts/cfg/config created"
+        else
+            print_warn "Backend config template not found, skipping scripts config"
+        fi
+}
+
+
+# Инициализация глобальных переменных
+DB_NAME=""
+DB_USER=""
+DB_HOST=""
+DB_PASS=""
+DB_TYPE="mysql"
+EYE_LANG="russian"
+SQL_CREATE_FILE=""
+
+PHP_CONFIG="/opt/Eye/html/cfg/config.php"
+PERL_CONFIG="/opt/Eye/scripts/cfg/config"
+
+# Проверяем наличие хотя бы одного конфига Eye
+if [[ -f "${PHP_CONFIG}" ]] || [[ -f "${PERL_CONFIG}" ]]; then
+        echo "✓ Eye configuration detected"
+    else
+	echo "Eye installation not found! Bye."
+	exit 101
+    fi
+
+if [[ -f "${PHP_CONFIG}" ]]; then
+            # Извлекаем DB_HOST из PHP-конфига
+            DB_HOST=$(grep -oP 'define\s*\(\s*"DB_HOST"\s*,\s*"\K[^"]+' ${PHP_CONFIG} 2>/dev/null)
+    fi
+if [[ -z "$DB_HOST" && -f "${PERL_CONFIG}" ]]; then
+            # Извлекаем из Perl-конфига
+            DB_HOST=$(grep -oP '^DBHOST=\K.*' ${PERL_CONFIG} 2>/dev/null)
+    fi
+
+if [[ "$DB_HOST" == "127.0.0.1" || "$DB_HOST" == "localhost" || "$DB_HOST" == "::1" ]]; then
+            DB_INSTALL="local"
+        else
+            echo "Remote database detected. Abort installation!"
+            exit 100
+        fi
+
+# === Восстанавливаем DB_TYPE ===
+if [[ -f "${PHP_CONFIG}" ]]; then
+            DB_TYPE=$(grep -oP 'define\s*\(\s*"DB_TYPE"\s*,\s*"\K[^"]+' ${PHP_CONFIG} 2>/dev/null)
+            # В PHP может быть 'pgsql' вместо 'postgresql'
+            if [[ "$DB_TYPE" == "pgsql" ]]; then
+                DB_TYPE="postgresql"
+            elif [[ "$DB_TYPE" == "mysql" ]]; then
+                DB_TYPE="mysql"
+            fi
+        elif [[ -f "${PERL_CONFIG}" ]]; then
+            DB_TYPE=$(grep -oP '^DBTYPE=\K.*' ${PERL_CONFIG} 2>/dev/null)
+        fi
+
+if [[ "$DB_TYPE" == "postgresql" ]]; then
+    echo "Already using PostgreSQL! Nothing to do."
+    exit 0
+fi
+
+DB_TYPE="postgresql"
+
+if [[ -f "$PHP_CONFIG" ]]; then
+    # Извлекаем язык
+    if HTML_LANG=$(grep -oP 'define\s*\(\s*"HTML_LANG"\s*,\s*"\K[^"]+' "$PHP_CONFIG" 2>/dev/null); then
+        case "$HTML_LANG" in
+            russian|ru) EYE_LANG="russian" ;;
+            english|en) EYE_LANG="english" ;;
+        esac
+    fi
+
+    # Извлекаем БД параметры
+    DB_NAME=$(grep -oP 'define\s*\(\s*"DB_NAME"\s*,\s*"\K[^"]+' "$PHP_CONFIG" 2>/dev/null)
+    DB_USER=$(grep -oP 'define\s*\(\s*"DB_USER"\s*,\s*"\K[^"]+' "$PHP_CONFIG" 2>/dev/null)
+    DB_HOST=$(grep -oP 'define\s*\(\s*"DB_HOST"\s*,\s*"\K[^"]+' "$PHP_CONFIG" 2>/dev/null)
+    DB_PASS=$(grep -oP 'define\s*\(\s*"DB_PASS"\s*,\s*"\K[^"]+' "$PHP_CONFIG" 2>/dev/null)
+fi
+
+# читаем из Perl-конфига ===
+
+if [[ -z "$DB_NAME" || -z "$DB_USER" || -z "$DB_PASS" ]] && [[ -f "$PERL_CONFIG" ]]; then
+    while IFS='=' read -r key value; do
+        # Пропускаем комментарии и пустые строки
+        [[ $key =~ ^#.*$ || -z $key ]] && continue
+        case "$key" in
+            DBNAME)  DB_NAME="$value" ;;
+            DBUSER)  DB_USER="$value" ;;
+            DBSERVER) DB_HOST="$value" ;;
+            DBPASS) DB_PASS="$value" ;;
+        esac
+    done < "$PERL_CONFIG"
+    fi
+
+# === Вывод результатов (для отладки или использования в других скриптах) ===
+echo "EYE_LANG=$EYE_LANG"
+echo "DB_NAME=$DB_NAME"
+echo "DB_USER=$DB_USER"
+echo "DB_HOST=$DB_HOST"
+
+# Убедимся, что все необходимые параметры получены
+if [[ -z "$DB_NAME" || -z "$DB_USER" || -z "$DB_PASS" ]]; then
+    print_error "Failed to extract database credentials from config files"
+    exit 1
+fi
+
+stop_eye
+
+eye_migrate2pgsql
+
+start_eye
+
+echo "Maybe need install:"
+echo "\t AltLinux: apt-get install php8.2-pgsql php8.2-pdo_pgsql"
+echo "\t Debian/Ubuntu: apt install php-pgsql"
+
+# Exit with success code
+exit 0

+ 792 - 0
docs/databases/mysql/en/create_db.sql

@@ -0,0 +1,792 @@
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+SET time_zone = "+00:00";
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+
+CREATE TABLE `acl` (
+  `id` int(11) NOT NULL,
+  `name` varchar(30) NOT NULL,
+  `description_english` varchar(250) NOT NULL,
+  `description_russian` varchar(250) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `ad_comp_cache` (
+  `id` int(11) NOT NULL,
+  `name` varchar(63) NOT NULL,
+  `last_found` DATETIME NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `auth_rules` (
+  `id` int(11) NOT NULL,
+  `user_id` int(11) DEFAULT NULL,
+  `ou_id` int(11) DEFAULT NULL,
+  `rule_type` int(11) NOT NULL,
+  `rule` varchar(40) DEFAULT NULL,
+  `description` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `building` (
+  `id` int(11) NOT NULL,
+  `name` varchar(50) NOT NULL,
+  `description` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `config` (
+  `id` int(11) NOT NULL,
+  `option_id` int(11) DEFAULT NULL,
+  `value` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `config_options` (
+  `id` int(11) NOT NULL,
+  `option_name` varchar(50) NOT NULL,
+  `description_russian` text DEFAULT NULL,
+  `description_english` text DEFAULT NULL,
+  `draft` tinyint(1) NOT NULL DEFAULT 0,
+  `uniq` tinyint(1) NOT NULL DEFAULT 1,
+  `option_type` varchar(100) NOT NULL,
+  `default_value` varchar(250) DEFAULT NULL,
+  `min_value` int(11) NOT NULL DEFAULT 0,
+  `max_value` int(11) NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `connections` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `device_id` bigint(20) UNSIGNED NOT NULL,
+  `port_id` bigint(20) UNSIGNED NOT NULL,
+  `auth_id` bigint(20) UNSIGNED NOT NULL,
+  `last_found` datetime NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `customers` (
+  `id` int(11) NOT NULL,
+  `login` varchar(20) DEFAULT NULL,
+  `description` varchar(100) DEFAULT NULL,
+  `password` varchar(255) DEFAULT NULL,
+  `api_key` varchar(255) DEFAULT NULL,
+  `rights` tinyint(1) NOT NULL DEFAULT 3
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `devices` (
+  `id` int(11) NOT NULL,
+  `device_type` int(11) NOT NULL DEFAULT 1,
+  `device_model_id` int(11) DEFAULT 89,
+  `firmware` varchar(100) DEFAULT NULL,
+  `vendor_id` int(11) NOT NULL DEFAULT 1,
+  `device_name` varchar(50) DEFAULT NULL,
+  `building_id` int(11) NOT NULL DEFAULT 1,
+  `ip` varchar(15) DEFAULT NULL,
+  `ip_int` bigint(10) UNSIGNED DEFAULT NULL,
+  `login` varchar(50) DEFAULT NULL,
+  `password` varchar(255) DEFAULT NULL,
+  `protocol` int(11) NOT NULL DEFAULT 0,
+  `control_port` int(11) NOT NULL DEFAULT 23,
+  `port_count` int(11) NOT NULL DEFAULT 0,
+  `sn` varchar(80) DEFAULT NULL,
+  `description` varchar(255) DEFAULT NULL,
+  `snmp_version` tinyint(4) NOT NULL DEFAULT 0,
+  `snmp3_auth_proto` varchar(10) NOT NULL DEFAULT 'sha512',
+  `snmp3_priv_proto` varchar(10) NOT NULL DEFAULT 'aes128',
+  `snmp3_user_rw` varchar(20) DEFAULT NULL,
+  `snmp3_user_rw_password` varchar(20) DEFAULT NULL,
+  `snmp3_user_ro` varchar(20) DEFAULT NULL,
+  `snmp3_user_ro_password` varchar(20) DEFAULT NULL,
+  `community` varchar(50) NOT NULL DEFAULT 'public',
+  `rw_community` varchar(50) NOT NULL DEFAULT 'private',
+  `fdb_snmp_index` tinyint(1) NOT NULL DEFAULT 0,
+  `discovery` tinyint(1) NOT NULL DEFAULT 1,
+  `netflow_save` tinyint(1) NOT NULL DEFAULT 0,
+  `user_acl` tinyint(1) NOT NULL DEFAULT 0,
+  `dhcp` tinyint(1) NOT NULL DEFAULT 0,
+  `nagios` tinyint(1) NOT NULL DEFAULT 0,
+  `active` tinyint(1) NOT NULL DEFAULT 1,
+  `nagios_status` varchar(10) NOT NULL DEFAULT 'UP',
+  `queue_enabled` tinyint(1) NOT NULL DEFAULT 0,
+  `connected_user_only` tinyint(1) NOT NULL DEFAULT 1,
+  `user_id` int(11) DEFAULT NULL,
+  `deleted` tinyint(1) NOT NULL DEFAULT 0,
+  `discovery_locked` tinyint(1) NOT NULL DEFAULT 0,
+  `locked_timestamp` DATETIME NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `device_filter_instances` (
+  `id` int(11) NOT NULL,
+  `instance_id` int(11) DEFAULT NULL,
+  `device_id` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `device_l3_interfaces` (
+  `id` int(11) NOT NULL,
+  `device_id` int(11) DEFAULT NULL,
+  `snmpin` int(11) DEFAULT NULL,
+  `interface_type` int(11) NOT NULL DEFAULT 0,
+  `name` varchar(100) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `device_models` (
+  `id` int(11) NOT NULL,
+  `model_name` varchar(200) DEFAULT NULL,
+  `vendor_id` int(11) DEFAULT 1,
+  `poe_in` tinyint(1) NOT NULL DEFAULT 0,
+  `poe_out` tinyint(1) NOT NULL DEFAULT 0,
+  `nagios_template` varchar(200) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `device_ports` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `device_id` int(11) DEFAULT NULL,
+  `snmp_index` int(11) DEFAULT NULL,
+  `port` int(11) DEFAULT NULL,
+  `ifname` varchar(40) DEFAULT NULL,
+  `port_name` varchar(40) DEFAULT NULL,
+  `description` varchar(50) DEFAULT NULL,
+  `target_port_id` int(11) NOT NULL DEFAULT 0,
+  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
+  `last_mac_count` int(11) DEFAULT 0,
+  `uplink` tinyint(1) NOT NULL DEFAULT 0,
+  `nagios` tinyint(1) NOT NULL DEFAULT 0,
+  `skip` tinyint(1) NOT NULL DEFAULT 0,
+  `vlan` int(11) NOT NULL DEFAULT 1,
+  `tagged_vlan` varchar(250) DEFAULT NULL,
+  `untagged_vlan` varchar(250) DEFAULT NULL,
+  `forbidden_vlan` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `device_types` (
+  `id` int(11) NOT NULL,
+  name_russian varchar(50) DEFAULT NULL,
+  name_english varchar(50) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `dhcp_log` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `mac` varchar(17) NOT NULL,
+  `ip_int` bigint(20) UNSIGNED NOT NULL,
+  `ip` varchar(15) DEFAULT NULL,
+  `action` varchar(10) NOT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `auth_id` bigint(20) UNSIGNED NOT 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
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
+
+CREATE TABLE `dhcp_queue` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `mac` varchar(17) NOT NULL,
+  `ip` varchar(15) DEFAULT NULL,
+  `action` varchar(10) NOT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `dhcp_hostname` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
+
+CREATE TABLE `dns_cache` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `dns` varchar(250) DEFAULT NULL,
+  `ip` bigint(20) UNSIGNED DEFAULT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `dns_queue` (
+  `id` int(11) NOT NULL,
+  `auth_id` int(11) DEFAULT NULL,
+  `name_type` varchar(10) NOT NULL DEFAULT 'A',
+  `name` varchar(200) DEFAULT NULL,
+  `operation_type` varchar(10) NOT NULL DEFAULT 'add',
+  `value` varchar(100) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `filter_instances` (
+  `id` int(11) NOT NULL,
+  `name` varchar(50) DEFAULT NULL,
+  `description` varchar(200) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `filter_list` (
+  `id` int(11) NOT NULL,
+  `name` varchar(50) DEFAULT NULL,
+  `description` varchar(250) DEFAULT NULL,
+  `proto` varchar(10) DEFAULT NULL,
+  `dst` text DEFAULT NULL,
+  `dstport` varchar(20) DEFAULT NULL,
+  `srcport` varchar(20) DEFAULT NULL,
+  `filter_type` int(10) UNSIGNED NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `gateway_subnets` (
+  `id` int(11) NOT NULL,
+  `device_id` int(11) DEFAULT NULL,
+  `subnet_id` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `group_filters` (
+  `id` int(11) NOT NULL,
+  `group_id` int(11) NOT NULL DEFAULT 0,
+  `filter_id` int(11) NOT NULL DEFAULT 0,
+  `rule_order` int(11) NOT NULL DEFAULT 0,
+  `action` tinyint(1) NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `group_list` (
+  `id` int(11) NOT NULL,
+  `instance_id` int(11) NOT NULL DEFAULT 1,
+  `group_name` varchar(50) DEFAULT NULL,
+  `description` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `mac_history` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `mac` varchar(17) DEFAULT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `device_id` bigint(20) UNSIGNED DEFAULT NULL,
+  `port_id` bigint(20) UNSIGNED DEFAULT NULL,
+  `ip` varchar(15) DEFAULT NULL,
+  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
+  `dhcp_hostname` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `mac_vendors` (
+  `id` int(11) NOT NULL,
+  `oui` varchar(20) DEFAULT NULL,
+  `companyname` varchar(255) DEFAULT NULL,
+  `companyaddress` varchar(255) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `ou` (
+  `id` int(11) NOT NULL,
+  `ou_name` varchar(40) DEFAULT NULL,
+  `description` varchar(250) DEFAULT NULL,
+  `default_users` tinyint(1) NOT NULL DEFAULT 0,
+  `default_hotspot` tinyint(1) NOT NULL DEFAULT 0,
+  `nagios_dir` varchar(255) DEFAULT NULL,
+  `nagios_host_use` varchar(50) DEFAULT NULL,
+  `nagios_ping` tinyint(1) NOT NULL DEFAULT 1,
+  `nagios_default_service` varchar(100) DEFAULT NULL,
+  `enabled` int(11) NOT NULL DEFAULT 0,
+  `filter_group_id` int(11) NOT NULL DEFAULT 0,
+  `queue_id` int(11) NOT NULL DEFAULT 0,
+  `dynamic` tinyint(1) NOT NULL DEFAULT 0,
+  `life_duration` decimal(10,2) NOT NULL DEFAULT 24.00,
+  `parent_id` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `queue_list` (
+  `id` int(11) NOT NULL,
+  `queue_name` varchar(20) NOT NULL,
+  `download` int(11) NOT NULL DEFAULT 0,
+  `upload` int(11) NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `remote_syslog` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `device_id` bigint(20) UNSIGNED NOT NULL,
+  `ip` varchar(15) DEFAULT NULL,
+  `message` text NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
+
+CREATE TABLE `sessions` (
+  `id` varchar(128) NOT NULL,
+  `data` text NOT NULL,
+  `last_accessed` int(11) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `subnets` (
+  `id` int(11) NOT NULL,
+  `subnet` varchar(18) DEFAULT NULL,
+  `vlan_tag` int(11) NOT NULL DEFAULT 1,
+  `ip_int_start` bigint(20) NOT NULL,
+  `ip_int_stop` bigint(20) NOT NULL,
+  `dhcp_start` bigint(20) NOT NULL DEFAULT 0,
+  `dhcp_stop` bigint(20) NOT NULL DEFAULT 0,
+  `dhcp_lease_time` int(11) NOT NULL DEFAULT 480,
+  `gateway` bigint(20) NOT NULL DEFAULT 0,
+  `office` tinyint(1) NOT NULL DEFAULT 1,
+  `hotspot` tinyint(1) NOT NULL DEFAULT 0,
+  `vpn` tinyint(1) NOT NULL DEFAULT 0,
+  `free` tinyint(1) NOT NULL DEFAULT 0,
+  `dhcp` tinyint(1) NOT NULL DEFAULT 1,
+  `static` tinyint(1) NOT NULL DEFAULT 0,
+  `dhcp_update_hostname` tinyint(1) NOT NULL DEFAULT 0,
+  `discovery` tinyint(1) NOT NULL DEFAULT 1,
+  `notify` tinyint(1) NOT NULL DEFAULT 7,
+  `description` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `traffic_detail` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
+  `router_id` int(11) NOT NULL DEFAULT 0,
+  `ts` DATETIME NULL DEFAULT NULL,
+  `proto` tinyint(3) UNSIGNED DEFAULT NULL,
+  `src_ip` bigint(20) NOT NULL DEFAULT 0,
+  `dst_ip` bigint(20) NOT NULL DEFAULT 0,
+  `src_port` smallint(5) UNSIGNED NOT NULL,
+  `dst_port` smallint(5) UNSIGNED NOT NULL,
+  `bytes` bigint(20) NOT NULL,
+  `pkt` int(10) UNSIGNED NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `unknown_mac` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `mac` varchar(17) DEFAULT NULL,
+  `port_id` bigint(20) UNSIGNED DEFAULT NULL,
+  `device_id` int(11) DEFAULT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `user_auth` (
+  `id` int(11) NOT NULL,
+  `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
+  `ou_id` int(11) DEFAULT NULL,
+  `ip` varchar(18) DEFAULT NULL,
+  `ip_int` bigint(10) UNSIGNED NOT NULL DEFAULT 0,
+  `save_traf` tinyint(1) NOT NULL DEFAULT 0,
+  `enabled` tinyint(1) NOT NULL DEFAULT 0,
+  `dhcp` tinyint(1) NOT NULL DEFAULT 1,
+  `filter_group_id` tinyint(1) NOT NULL DEFAULT 0,
+  `dynamic` tinyint(1) NOT NULL DEFAULT 0,
+  `end_life` datetime DEFAULT NULL,
+  `deleted` tinyint(4) NOT NULL DEFAULT 0,
+  `description` varchar(250) DEFAULT NULL,
+  `dns_name` varchar(253) DEFAULT NULL,
+  `dns_ptr_only` tinyint(1) NOT NULL DEFAULT 0,
+  `wikiname` varchar(250) DEFAULT NULL,
+  `dhcp_acl` text DEFAULT NULL,
+  `queue_id` int(11) NOT NULL DEFAULT 0,
+  `mac` varchar(17) DEFAULT NULL,
+  `dhcp_action` varchar(10) NOT NULL DEFAULT '',
+  `dhcp_option_set` varchar(50) DEFAULT NULL,
+  `dhcp_time` datetime DEFAULT NULL,
+  `dhcp_hostname` varchar(60) DEFAULT NULL,
+  `last_found` datetime NOT NULL DEFAULT current_timestamp(),
+  `arp_found` datetime DEFAULT NULL,
+  `mac_found` datetime DEFAULT NULL,
+  `blocked` tinyint(1) NOT NULL DEFAULT 0,
+  `day_quota` int(11) NOT NULL DEFAULT 0,
+  `month_quota` int(11) NOT NULL DEFAULT 0,
+  `device_model_id` int(11) DEFAULT 87,
+  `firmware` varchar(100) DEFAULT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `client_id` varchar(250) DEFAULT NULL,
+  `nagios` tinyint(1) NOT NULL DEFAULT 0,
+  `nagios_status` varchar(10) NOT NULL DEFAULT '',
+  `nagios_handler` varchar(50) NOT NULL DEFAULT '',
+  `link_check` tinyint(1) NOT NULL DEFAULT 0,
+  `changed` tinyint(1) NOT NULL DEFAULT 0,
+  `dhcp_changed` int(11) NOT NULL DEFAULT 0,
+  `changed_time` datetime NOT NULL DEFAULT current_timestamp(),
+  `created_by` varchar(10) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `user_auth_alias` (
+  `id` int(11) NOT NULL,
+  `auth_id` int(11) NOT NULL,
+  `alias` varchar(100) DEFAULT NULL,
+  `description` varchar(100) DEFAULT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `user_list` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `login` varchar(255) DEFAULT NULL,
+  `description` varchar(255) DEFAULT NULL,
+  `enabled` tinyint(1) NOT NULL DEFAULT 1,
+  `blocked` tinyint(1) NOT NULL DEFAULT 0,
+  `deleted` tinyint(1) NOT NULL DEFAULT 0,
+  `ou_id` int(11) NOT NULL DEFAULT 0,
+  `device_id` int(11) DEFAULT NULL,
+  `filter_group_id` int(11) NOT NULL DEFAULT 0,
+  `queue_id` int(11) NOT NULL DEFAULT 0,
+  `day_quota` int(11) NOT NULL DEFAULT 0,
+  `month_quota` int(11) NOT NULL DEFAULT 0,
+  `permanent` tinyint(1) NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `user_sessions` (
+  `id` int(11) NOT NULL,
+  `session_id` varchar(128) NOT NULL,
+  `user_id` int(11) NOT NULL,
+  `ip_address` varchar(45) NOT NULL,
+  `user_agent` text NOT NULL,
+  `created_at` int(11) NOT NULL,
+  `last_activity` int(11) NOT NULL,
+  `is_active` tinyint(1) DEFAULT 1
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `user_stats` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `router_id` bigint(20) UNSIGNED DEFAULT 0,
+  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
+  `ts` datetime NOT NULL DEFAULT current_timestamp(),
+  `byte_in` bigint(20) NOT NULL DEFAULT 0,
+  `byte_out` bigint(20) NOT NULL DEFAULT 0,
+  `pkt_in` int(11) NOT NULL DEFAULT 0,
+  `pkt_out` int(11) NOT NULL DEFAULT 0,
+  `step` int(11) NOT NULL DEFAULT 3600
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `user_stats_full` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `router_id` bigint(20) UNSIGNED DEFAULT 0,
+  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
+  `ts` datetime NOT NULL DEFAULT current_timestamp(),
+  `byte_in` bigint(20) NOT NULL DEFAULT 0,
+  `byte_out` bigint(20) NOT NULL DEFAULT 0,
+  `pkt_in` int(11) NOT NULL DEFAULT 0,
+  `pkt_out` int(11) NOT NULL DEFAULT 0,
+  `step` int(11) NOT NULL DEFAULT 600
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `variables` (
+  `id` int(11) NOT NULL,
+  `name` varchar(30) NOT NULL,
+  `value` varchar(255) DEFAULT NULL,
+  `clear_time` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `created` DATETIME NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `vendors` (
+  `id` int(11) NOT NULL,
+  `name` varchar(40) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `version` (
+  `id` int(11) NOT NULL DEFAULT 1,
+  `version` varchar(10) NOT NULL DEFAULT '2.4.14'
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `wan_stats` (
+  `id` int(11) NOT NULL,
+  `ts` datetime NOT NULL DEFAULT current_timestamp(),
+  `router_id` int(11) DEFAULT NULL,
+  `interface_id` int(11) DEFAULT NULL,
+  `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_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `worklog` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
+  `customer` varchar(50) NOT NULL DEFAULT 'system',
+  `ip` varchar(18) NOT NULL DEFAULT '127.0.0.1',
+  `message` text NOT NULL,
+  `level` int(11) NOT NULL DEFAULT 1
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
+
+
+ALTER TABLE `acl`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `ad_comp_cache`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `comp_name` (`name`);
+
+ALTER TABLE `auth_rules`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `rule` (`rule`),
+  ADD KEY `user_id` (`user_id`);
+
+ALTER TABLE `building`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `config`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `option` (`option_id`);
+
+ALTER TABLE `config_options`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `connections`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `auth_id` (`auth_id`),
+  ADD KEY `device_id` (`device_id`,`port_id`);
+
+ALTER TABLE `customers`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `devices`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ip` (`ip`),
+  ADD KEY `device_type` (`device_type`);
+
+ALTER TABLE `device_filter_instances`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `device_l3_interfaces`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `device_models`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `device_ports`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `device_id` (`device_id`),
+  ADD KEY `port` (`port`),
+  ADD KEY `target_port_id` (`target_port_id`);
+
+ALTER TABLE `device_types`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `dhcp_log`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ts` (`ts`,`action`);
+
+ALTER TABLE `dhcp_queue`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ts` (`ts`,`action`);
+
+ALTER TABLE `dns_cache`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `dns` (`dns`,`ip`),
+  ADD KEY `ts` (`ts`);
+
+ALTER TABLE `dns_queue`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `filter_instances`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `name` (`name`);
+
+ALTER TABLE `filter_list`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `Name` (`name`);
+
+ALTER TABLE `gateway_subnets`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `group_filters`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `GroupId` (`group_id`,`filter_id`);
+
+ALTER TABLE `group_list`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `mac_history`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `mac` (`mac`,`ts`),
+  ADD KEY `ip` (`ip`,`ts`),
+  ADD KEY `ts` (`ts`) USING BTREE,
+  ADD KEY `mac_2` (`mac`),
+  ADD KEY `ip_2` (`ip`);
+
+ALTER TABLE `mac_vendors`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `oui` (`oui`);
+
+ALTER TABLE `ou`
+  ADD PRIMARY KEY (`id`);
+ALTER TABLE `ou` ADD FULLTEXT KEY `ou_name` (`ou_name`);
+
+ALTER TABLE `queue_list`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `id` (`id`);
+
+ALTER TABLE `remote_syslog`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `date` (`ts`,`device_id`,`ip`);
+
+ALTER TABLE `sessions`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `last_accessed` (`last_accessed`);
+
+ALTER TABLE `subnets`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ip_int_start` (`ip_int_start`,`ip_int_stop`),
+  ADD KEY `dhcp` (`dhcp`,`office`,`hotspot`,`static`);
+
+ALTER TABLE `traffic_detail`
+  ADD PRIMARY KEY (`id`),
+  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`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ts` (`ts`,`device_id`,`port_id`,`mac`);
+
+ALTER TABLE `user_auth`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `auth_index` (`id`,`user_id`,`ip_int`,`mac`,`ip`,`deleted`) USING BTREE,
+  ADD KEY `deleted` (`deleted`),
+  ADD KEY `ou_id` (`ou_id`);
+
+ALTER TABLE `user_auth_alias`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `auth_id` (`auth_id`);
+
+ALTER TABLE `user_list`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `users` (`id`,`ou_id`,`enabled`,`blocked`,`deleted`);
+
+ALTER TABLE `user_sessions`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `session_id` (`session_id`),
+  ADD KEY `user_id` (`user_id`),
+  ADD KEY `is_active` (`is_active`);
+
+ALTER TABLE `user_stats`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ts` (`ts`,`auth_id`,`router_id`);
+
+ALTER TABLE `user_stats_full`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ts` (`ts`,`auth_id`,`router_id`);
+
+ALTER TABLE `variables`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `name` (`name`),
+  ADD KEY `clear_time` (`clear_time`,`created`);
+
+ALTER TABLE `vendors`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `version`
+  ADD UNIQUE KEY `id` (`id`);
+
+ALTER TABLE `wan_stats`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `main` (`ts`,`router_id`,`interface_id`),
+  ADD KEY `times` (`ts`);
+
+ALTER TABLE `worklog`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `idx_customer` (`customer`,`level`,`ts`),
+  ADD KEY `idx_timestamp` (`level`,`ts`),
+  ADD KEY `idx_auth_id` (`auth_id`,`level`,`ts`);
+
+ALTER TABLE `worklog` ADD INDEX `idx_ts` (`ts`);
+
+ALTER TABLE `acl`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `ad_comp_cache`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `auth_rules`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `building`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `config`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `config_options`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `connections`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `customers`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `devices`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `device_filter_instances`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `device_l3_interfaces`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `device_models`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `device_ports`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `device_types`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `dhcp_log`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `dhcp_queue`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `dns_cache`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `dns_queue`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `filter_instances`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `filter_list`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `gateway_subnets`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `group_filters`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `group_list`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `mac_history`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `mac_vendors`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `ou`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `queue_list`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `remote_syslog`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `subnets`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `traffic_detail`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `unknown_mac`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `user_auth`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `user_auth_alias`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `user_list`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `user_sessions`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `user_stats`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `user_stats_full`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `variables`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `vendors`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `wan_stats`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `worklog`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

+ 360 - 0
docs/databases/mysql/en/data.sql

@@ -0,0 +1,360 @@
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+SET time_zone = "+00:00";
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+
+INSERT INTO `acl` (`id`, `name`, description_english, description_russian) VALUES(0,'Disabled','User disabled','Пользователь отключен');
+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`, `description`) VALUES(1, 'Earth', 'Somewhere');
+
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `description`, `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(2, '2011UAS-2HnD', 9, 1, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(3, 'AT-8000S', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(4, 'AT-8100S/48POE', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(5, 'AT-9000/28', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(6, 'AT-GS950/24', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(7, 'CCR1009-7G-1C-1S+', 9, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(8, 'CCR1036-8G-2S+', 9, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(10, 'CRS317-1G-16S+', 9, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(11, 'CRS326-24S+2Q+', 9, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(12, 'CRS328-24P-4S+', 9, 1, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(14, 'CRS328-4C-20S-4S+', 9, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(15, 'DGS-3120-48TC', 7, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(16, 'ES-2024', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(17, 'ES-2024A', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(18, 'ES-2108', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(19, 'ES-2108-G', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(20, 'ES-3124-4F', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(21, 'GS110TP', 10, 0, 1, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(22, 'GS-4024', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(23, 'HP 1910', 15, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(24, 'ISCOM2110A-MA', 5, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(25, 'ISCOM2110EA-MA', 5, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(26, 'ISCOM2126EA-MA', 5, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(27, 'ISCOM2128EA-MA', 5, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(28, 'Linux server', 1, 0, 0, '');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(29, 'MES2124F', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(30, 'MES2124MB', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(31, 'MES5248', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(32, 'RB2011UAS', 9, 1, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(33, 'RB3011UiAS', 9, 1, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(34, 'RB960PGS', 9, 1, 1, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(35, 'RBD52G-5HacD2HnD', 9, 1, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(36, 'S2940-8G-v2', 6, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(37, 'S2980G-24T', 6, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(38, 'S3750G-24S-E', 6, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(39, 'S5300-52P-LI-AC', 3, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(40, 'S5320-52X-PWR-SI-AC', 3, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(41, 'S5321-28X-SI-AC', 3, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(42, 'S5321-52X-SI-AC', 3, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(43, 'S6320-54C-EI-48S-AC', 3, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(44, 'SNR-S2980G-24T', 6, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(45, 'V1910-16G', 15, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(46, 'V1910-24G-PoE', 15, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(47, 'Windows server', 1, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(48, 'WS-C2960G-24TC-L', 16, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(49, 'WS-C3560G-24TS-S', 16, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(50, 'x210-16GT', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(51, 'x210-24GT', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(52, 'x610-24Ts/X', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(53, 'x610-48Ts', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(54, 'XGS-4728', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(55, 'ZyWall 310', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(56, 'APC Smart-UPS_3000', 20, 0, 0, 'ups.cfg');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(57, 'APC Smart-UPS_5000', 20, 0, 0, 'ups.cfg');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(58, 'Schneider Smart-UPS_3000', 21, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(59, 'SMG-1016M', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(60, 'EATON 9PX 1500i RT 2U', 64, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(61, 'EATON 9PX3000i_RT_2U', 64, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(62, 'EATON 9PX_6000i', 64, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(63, 'EATON PW9130_3000', 64, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(64, 'EATON PW9130_3000VA-R', 64, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(65, 'Epson WF-5620 Series', 59, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(66, 'Epson WF-8590 Series', 59, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(67, 'HP Officejet-7000', 15, 0, 0, 'hp.cfg');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(68, 'OKI C610', 62, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(69, 'OKI MB472', 62, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(70, 'OKI MB491', 62, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(71, 'OKI MC562', 62, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(72, 'OKI MC573', 62, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(73, 'OKI MC861', 62, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(74, 'Panasonic KX-MB2000RU', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(75, 'PT-MZ10KE', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(76, 'PT-VX41', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(77, 'Rave 522AA', 33, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(78, 'DZ570E', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(79, 'DZ6700', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(80, 'Rcq80', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(81, 'RZ12K', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(82, 'RZ660', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(83, 'RZ770', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(84, 'RZ970', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(85, 'XVR-5216', 66, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(86, 'HWg-STE', 68, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(87, 'Computer', 1, 0, 0, '');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(88, 'Mobile Phone', 1, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(89, 'Switch', 1, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(90, 'Projectiondesign F22', 34, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(91, 'DS-I252', 36, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(92, 'LTV-CNE-720-48', 37, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(93, 'U-100', 38, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(94, 'TAU-8', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(95, 'SIP-T21P E2', 39, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(96, 'A510 IP', 40, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(97, 'W60B', 39, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(98, 'TAU-2M', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(99, 'PAP2T', 41, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(100, 'VP-12', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(101, 'SIP-T23P', 39, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(102, 'SPA-2102', 16, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(103, 'RB760iGS', 9, 1, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(104, 'MES2324B', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(105, 'MES2324FB', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(106, 'MES2124P', 2, 0, 1, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(107, 'MES2428P', 2, 0, 1, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(108, 'Symmetra LX 16000', 20, 0, 0, 'symmetra.cfg');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(109, 'SNR-UPS-ONT20', 6, 0, 0, 'ups3.cfg');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(110, 'MES-3728', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(111, 'SNR-S5210G-24TX-UPS-R', 6, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(112, 'SNR-S2985G-24TC', 6, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(113, 'MES-5248', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(114, 'SNR-S5210G-24TX-POE', 6, 0, 1, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(115, 'SNR-S5210G-24TX-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_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`, `description`) VALUES(1, 'default', NULL);
+
+INSERT INTO `group_list` (`id`, `instance_id`, `group_name`, `description`) VALUES(0, 1, 'default', 'Forbidden all');
+INSERT INTO `group_list` (`id`, `instance_id`, `group_name`, `description`) VALUES(1, 1, 'Allow all', 'Allowed all');
+INSERT INTO `group_list` (`id`, `instance_id`, `group_name`, `description`) VALUES(2, 1, 'Users','For users');
+
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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`, `description`, `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`, `description`, `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(2, 'Administrators', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(3, 'Users', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(4, 'VOIP', NULL, 0, 0, 'voip', 'voip', 1, NULL, 1, 4, 5, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(5, 'IPCAM', NULL, 0, 0, 'videocam', 'ip-cam', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(6, 'Printers', NULL, 0, 0, 'printers', 'printers', 1, 'printer-service', 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(7, 'Switches', NULL, 0, 0, 'switches', 'switches', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(8, 'UPS', NULL, 0, 0, 'ups', 'ups', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(9, 'Security', NULL, 0, 0, 'security', 'security', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(10, 'Routers', NULL, 0, 0, 'routers', 'routers', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(11, 'WiFi AP', NULL, 0, 0, 'ap', 'ap', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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`, `description`, `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 `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`, `description`) 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 `vendors` (`id`, `name`) VALUES(1, 'Unknown');
+INSERT INTO `vendors` (`id`, `name`) VALUES(2, 'Eltex');
+INSERT INTO `vendors` (`id`, `name`) VALUES(3, 'Huawei');
+INSERT INTO `vendors` (`id`, `name`) VALUES(4, 'Zyxel');
+INSERT INTO `vendors` (`id`, `name`) VALUES(5, 'Raisecom');
+INSERT INTO `vendors` (`id`, `name`) VALUES(6, 'SNR');
+INSERT INTO `vendors` (`id`, `name`) VALUES(7, 'Dlink');
+INSERT INTO `vendors` (`id`, `name`) VALUES(8, 'Allied Telesis');
+INSERT INTO `vendors` (`id`, `name`) VALUES(9, 'Mikrotik');
+INSERT INTO `vendors` (`id`, `name`) VALUES(10, 'NetGear');
+INSERT INTO `vendors` (`id`, `name`) VALUES(11, 'Ubiquiti');
+INSERT INTO `vendors` (`id`, `name`) VALUES(15, 'HP');
+INSERT INTO `vendors` (`id`, `name`) VALUES(16, 'Cisco');
+INSERT INTO `vendors` (`id`, `name`) VALUES(17, 'Maipu');
+INSERT INTO `vendors` (`id`, `name`) VALUES(18, 'Asus');
+INSERT INTO `vendors` (`id`, `name`) VALUES(19, 'Linux');
+INSERT INTO `vendors` (`id`, `name`) VALUES(20, 'APC');
+INSERT INTO `vendors` (`id`, `name`) VALUES(21, 'Schneider');
+INSERT INTO `vendors` (`id`, `name`) VALUES(33, 'QSC');
+INSERT INTO `vendors` (`id`, `name`) VALUES(34, 'Projectiondesign');
+INSERT INTO `vendors` (`id`, `name`) VALUES(35, 'Lenovo');
+INSERT INTO `vendors` (`id`, `name`) VALUES(36, 'HiWatch');
+INSERT INTO `vendors` (`id`, `name`) VALUES(37, 'LTV');
+INSERT INTO `vendors` (`id`, `name`) VALUES(38, 'Yeastar');
+INSERT INTO `vendors` (`id`, `name`) VALUES(39, 'Yealink');
+INSERT INTO `vendors` (`id`, `name`) VALUES(40, 'Gigaset');
+INSERT INTO `vendors` (`id`, `name`) VALUES(41, 'Linksys');
+INSERT INTO `vendors` (`id`, `name`) VALUES(42, 'Samsung');
+INSERT INTO `vendors` (`id`, `name`) VALUES(43, 'Supermicro');
+INSERT INTO `vendors` (`id`, `name`) VALUES(44, 'RDP');
+INSERT INTO `vendors` (`id`, `name`) VALUES(45, 'SANYO');
+INSERT INTO `vendors` (`id`, `name`) VALUES(46, 'Extreme');
+INSERT INTO `vendors` (`id`, `name`) VALUES(47, 'Intel');
+INSERT INTO `vendors` (`id`, `name`) VALUES(48, 'Micron');
+INSERT INTO `vendors` (`id`, `name`) VALUES(49, 'Gigabyte');
+INSERT INTO `vendors` (`id`, `name`) VALUES(50, 'Acer');
+INSERT INTO `vendors` (`id`, `name`) VALUES(51, 'Seagate');
+INSERT INTO `vendors` (`id`, `name`) VALUES(52, 'SanDisk');
+INSERT INTO `vendors` (`id`, `name`) VALUES(53, 'Toshiba');
+INSERT INTO `vendors` (`id`, `name`) VALUES(54, 'Kingston');
+INSERT INTO `vendors` (`id`, `name`) VALUES(55, 'AddPac');
+INSERT INTO `vendors` (`id`, `name`) VALUES(56, 'Devline');
+INSERT INTO `vendors` (`id`, `name`) VALUES(57, 'Canon');
+INSERT INTO `vendors` (`id`, `name`) VALUES(58, 'Brother');
+INSERT INTO `vendors` (`id`, `name`) VALUES(59, 'Epson');
+INSERT INTO `vendors` (`id`, `name`) VALUES(60, 'IP-COM');
+INSERT INTO `vendors` (`id`, `name`) VALUES(61, 'Panasonic');
+INSERT INTO `vendors` (`id`, `name`) VALUES(62, 'OKI');
+INSERT INTO `vendors` (`id`, `name`) VALUES(63, 'Apple');
+INSERT INTO `vendors` (`id`, `name`) VALUES(64, 'Eaton');
+INSERT INTO `vendors` (`id`, `name`) VALUES(65, 'Barco');
+INSERT INTO `vendors` (`id`, `name`) VALUES(66, 'Trassir');
+INSERT INTO `vendors` (`id`, `name`) VALUES(67, 'Testo');
+INSERT INTO `vendors` (`id`, `name`) VALUES(68, 'Hw-group');
+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 `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 (2,11,'public');
+INSERT INTO `config` VALUES (3,32,'ORG');
+INSERT INTO `config` VALUES (123,19,'1');
+INSERT INTO `config` VALUES (124,35,'120');
+INSERT INTO `config` VALUES (125,9,'2');
+INSERT INTO `config` VALUES (126,41,'/opt/Eye/scripts/fetch_new_arp.pl');
+INSERT INTO `config` VALUES (127,26,'3');
+INSERT INTO `config` VALUES (128,27,'10');
+INSERT INTO `config` VALUES (129,48,'90');
+INSERT INTO `config` VALUES (130,49,'365');
+INSERT INTO `config` VALUES (131,47,'90');
+INSERT INTO `config` VALUES (132,53,'1');
+INSERT INTO `config` VALUES (133,55,'1');
+INSERT INTO `config` VALUES (134,56,'30');
+INSERT INTO `config` VALUES (135,34,'0');
+INSERT INTO `config` VALUES (137,65,'0');
+INSERT INTO `config` VALUES (142,54,'');
+INSERT INTO `config` VALUES (143,17,'1');
+INSERT INTO `config` VALUES (144,37,'/opt/Eye/scripts/sync_mikrotik.pl');
+INSERT INTO `config` VALUES (145,23,'1');
+INSERT INTO `config` VALUES (148,22,'1');
+
+
+INSERT INTO `version` (`id`, `version`) VALUES(1, '3.0.1');
+
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

+ 0 - 0
docs/mysql/nagios.sql → docs/databases/mysql/nagios.sql


+ 1 - 1
docs/mysql/reset_admin.sql → docs/databases/mysql/reset_admin.sql

@@ -1,3 +1,3 @@
 --- default user: admin
 --- default password admin
-INSERT INTO `Customers` (`id`, `Login`, `password`, `api_key`,`rights`) VALUES (1, 'admin', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31','1') ON DUPLICATE KEY UPDATE Login="admin", password="$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG";
+INSERT INTO `customers` (`id`, `login`, `password`, `api_key`,`rights`) VALUES (1, 'admin', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31','1') ON DUPLICATE KEY UPDATE login="admin", password="$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG";

+ 792 - 0
docs/databases/mysql/ru/create_db.sql

@@ -0,0 +1,792 @@
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+SET time_zone = "+00:00";
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+
+CREATE TABLE `acl` (
+  `id` int(11) NOT NULL,
+  `name` varchar(30) NOT NULL,
+  `description_english` varchar(250) NOT NULL,
+  `description_russian` varchar(250) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `ad_comp_cache` (
+  `id` int(11) NOT NULL,
+  `name` varchar(63) NOT NULL,
+  `last_found` DATETIME NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `auth_rules` (
+  `id` int(11) NOT NULL,
+  `user_id` int(11) DEFAULT NULL,
+  `ou_id` int(11) DEFAULT NULL,
+  `rule_type` int(11) NOT NULL,
+  `rule` varchar(40) DEFAULT NULL,
+  `description` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `building` (
+  `id` int(11) NOT NULL,
+  `name` varchar(50) NOT NULL,
+  `description` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `config` (
+  `id` int(11) NOT NULL,
+  `option_id` int(11) DEFAULT NULL,
+  `value` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `config_options` (
+  `id` int(11) NOT NULL,
+  `option_name` varchar(50) NOT NULL,
+  `description_russian` text DEFAULT NULL,
+  `description_english` text DEFAULT NULL,
+  `draft` tinyint(1) NOT NULL DEFAULT 0,
+  `uniq` tinyint(1) NOT NULL DEFAULT 1,
+  `option_type` varchar(100) NOT NULL,
+  `default_value` varchar(250) DEFAULT NULL,
+  `min_value` int(11) NOT NULL DEFAULT 0,
+  `max_value` int(11) NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `connections` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `device_id` bigint(20) UNSIGNED NOT NULL,
+  `port_id` bigint(20) UNSIGNED NOT NULL,
+  `auth_id` bigint(20) UNSIGNED NOT NULL,
+  `last_found` datetime NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `customers` (
+  `id` int(11) NOT NULL,
+  `login` varchar(20) DEFAULT NULL,
+  `description` varchar(100) DEFAULT NULL,
+  `password` varchar(255) DEFAULT NULL,
+  `api_key` varchar(255) DEFAULT NULL,
+  `rights` tinyint(1) NOT NULL DEFAULT 3
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `devices` (
+  `id` int(11) NOT NULL,
+  `device_type` int(11) NOT NULL DEFAULT 1,
+  `device_model_id` int(11) DEFAULT 89,
+  `firmware` varchar(100) DEFAULT NULL,
+  `vendor_id` int(11) NOT NULL DEFAULT 1,
+  `device_name` varchar(50) DEFAULT NULL,
+  `building_id` int(11) NOT NULL DEFAULT 1,
+  `ip` varchar(15) DEFAULT NULL,
+  `ip_int` bigint(10) UNSIGNED DEFAULT NULL,
+  `login` varchar(50) DEFAULT NULL,
+  `password` varchar(255) DEFAULT NULL,
+  `protocol` int(11) NOT NULL DEFAULT 0,
+  `control_port` int(11) NOT NULL DEFAULT 23,
+  `port_count` int(11) NOT NULL DEFAULT 0,
+  `sn` varchar(80) DEFAULT NULL,
+  `description` varchar(255) DEFAULT NULL,
+  `snmp_version` tinyint(4) NOT NULL DEFAULT 0,
+  `snmp3_auth_proto` varchar(10) NOT NULL DEFAULT 'sha512',
+  `snmp3_priv_proto` varchar(10) NOT NULL DEFAULT 'aes128',
+  `snmp3_user_rw` varchar(20) DEFAULT NULL,
+  `snmp3_user_rw_password` varchar(20) DEFAULT NULL,
+  `snmp3_user_ro` varchar(20) DEFAULT NULL,
+  `snmp3_user_ro_password` varchar(20) DEFAULT NULL,
+  `community` varchar(50) NOT NULL DEFAULT 'public',
+  `rw_community` varchar(50) NOT NULL DEFAULT 'private',
+  `fdb_snmp_index` tinyint(1) NOT NULL DEFAULT 0,
+  `discovery` tinyint(1) NOT NULL DEFAULT 1,
+  `netflow_save` tinyint(1) NOT NULL DEFAULT 0,
+  `user_acl` tinyint(1) NOT NULL DEFAULT 0,
+  `dhcp` tinyint(1) NOT NULL DEFAULT 0,
+  `nagios` tinyint(1) NOT NULL DEFAULT 0,
+  `active` tinyint(1) NOT NULL DEFAULT 1,
+  `nagios_status` varchar(10) NOT NULL DEFAULT 'UP',
+  `queue_enabled` tinyint(1) NOT NULL DEFAULT 0,
+  `connected_user_only` tinyint(1) NOT NULL DEFAULT 1,
+  `user_id` int(11) DEFAULT NULL,
+  `deleted` tinyint(1) NOT NULL DEFAULT 0,
+  `discovery_locked` tinyint(1) NOT NULL DEFAULT 0,
+  `locked_timestamp` DATETIME NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `device_filter_instances` (
+  `id` int(11) NOT NULL,
+  `instance_id` int(11) DEFAULT NULL,
+  `device_id` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `device_l3_interfaces` (
+  `id` int(11) NOT NULL,
+  `device_id` int(11) DEFAULT NULL,
+  `snmpin` int(11) DEFAULT NULL,
+  `interface_type` int(11) NOT NULL DEFAULT 0,
+  `name` varchar(100) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `device_models` (
+  `id` int(11) NOT NULL,
+  `model_name` varchar(200) DEFAULT NULL,
+  `vendor_id` int(11) DEFAULT 1,
+  `poe_in` tinyint(1) NOT NULL DEFAULT 0,
+  `poe_out` tinyint(1) NOT NULL DEFAULT 0,
+  `nagios_template` varchar(200) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `device_ports` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `device_id` int(11) DEFAULT NULL,
+  `snmp_index` int(11) DEFAULT NULL,
+  `port` int(11) DEFAULT NULL,
+  `ifname` varchar(40) DEFAULT NULL,
+  `port_name` varchar(40) DEFAULT NULL,
+  `description` varchar(50) DEFAULT NULL,
+  `target_port_id` int(11) NOT NULL DEFAULT 0,
+  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
+  `last_mac_count` int(11) DEFAULT 0,
+  `uplink` tinyint(1) NOT NULL DEFAULT 0,
+  `nagios` tinyint(1) NOT NULL DEFAULT 0,
+  `skip` tinyint(1) NOT NULL DEFAULT 0,
+  `vlan` int(11) NOT NULL DEFAULT 1,
+  `tagged_vlan` varchar(250) DEFAULT NULL,
+  `untagged_vlan` varchar(250) DEFAULT NULL,
+  `forbidden_vlan` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `device_types` (
+  `id` int(11) NOT NULL,
+  name_russian varchar(50) DEFAULT NULL,
+  name_english varchar(50) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `dhcp_log` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `mac` varchar(17) NOT NULL,
+  `ip_int` bigint(20) UNSIGNED NOT NULL,
+  `ip` varchar(15) DEFAULT NULL,
+  `action` varchar(10) NOT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `auth_id` bigint(20) UNSIGNED NOT 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
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
+
+CREATE TABLE `dhcp_queue` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `mac` varchar(17) NOT NULL,
+  `ip` varchar(15) DEFAULT NULL,
+  `action` varchar(10) NOT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `dhcp_hostname` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
+
+CREATE TABLE `dns_cache` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `dns` varchar(250) DEFAULT NULL,
+  `ip` bigint(20) UNSIGNED DEFAULT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `dns_queue` (
+  `id` int(11) NOT NULL,
+  `auth_id` int(11) DEFAULT NULL,
+  `name_type` varchar(10) NOT NULL DEFAULT 'A',
+  `name` varchar(200) DEFAULT NULL,
+  `operation_type` varchar(10) NOT NULL DEFAULT 'add',
+  `value` varchar(100) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `filter_instances` (
+  `id` int(11) NOT NULL,
+  `name` varchar(50) DEFAULT NULL,
+  `description` varchar(200) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `filter_list` (
+  `id` int(11) NOT NULL,
+  `name` varchar(50) DEFAULT NULL,
+  `description` varchar(250) DEFAULT NULL,
+  `proto` varchar(10) DEFAULT NULL,
+  `dst` text DEFAULT NULL,
+  `dstport` varchar(20) DEFAULT NULL,
+  `srcport` varchar(20) DEFAULT NULL,
+  `filter_type` int(10) UNSIGNED NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `gateway_subnets` (
+  `id` int(11) NOT NULL,
+  `device_id` int(11) DEFAULT NULL,
+  `subnet_id` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `group_filters` (
+  `id` int(11) NOT NULL,
+  `group_id` int(11) NOT NULL DEFAULT 0,
+  `filter_id` int(11) NOT NULL DEFAULT 0,
+  `rule_order` int(11) NOT NULL DEFAULT 0,
+  `action` tinyint(1) NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `group_list` (
+  `id` int(11) NOT NULL,
+  `instance_id` int(11) NOT NULL DEFAULT 1,
+  `group_name` varchar(50) DEFAULT NULL,
+  `description` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `mac_history` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `mac` varchar(17) DEFAULT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `device_id` bigint(20) UNSIGNED DEFAULT NULL,
+  `port_id` bigint(20) UNSIGNED DEFAULT NULL,
+  `ip` varchar(15) DEFAULT NULL,
+  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
+  `dhcp_hostname` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `mac_vendors` (
+  `id` int(11) NOT NULL,
+  `oui` varchar(20) DEFAULT NULL,
+  `companyname` varchar(255) DEFAULT NULL,
+  `companyaddress` varchar(255) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `ou` (
+  `id` int(11) NOT NULL,
+  `ou_name` varchar(40) DEFAULT NULL,
+  `description` varchar(250) DEFAULT NULL,
+  `default_users` tinyint(1) NOT NULL DEFAULT 0,
+  `default_hotspot` tinyint(1) NOT NULL DEFAULT 0,
+  `nagios_dir` varchar(255) DEFAULT NULL,
+  `nagios_host_use` varchar(50) DEFAULT NULL,
+  `nagios_ping` tinyint(1) NOT NULL DEFAULT 1,
+  `nagios_default_service` varchar(100) DEFAULT NULL,
+  `enabled` int(11) NOT NULL DEFAULT 0,
+  `filter_group_id` int(11) NOT NULL DEFAULT 0,
+  `queue_id` int(11) NOT NULL DEFAULT 0,
+  `dynamic` tinyint(1) NOT NULL DEFAULT 0,
+  `life_duration` decimal(10,2) NOT NULL DEFAULT 24.00,
+  `parent_id` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `queue_list` (
+  `id` int(11) NOT NULL,
+  `queue_name` varchar(20) NOT NULL,
+  `download` int(11) NOT NULL DEFAULT 0,
+  `upload` int(11) NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `remote_syslog` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `device_id` bigint(20) UNSIGNED NOT NULL,
+  `ip` varchar(15) DEFAULT NULL,
+  `message` text NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
+
+CREATE TABLE `sessions` (
+  `id` varchar(128) NOT NULL,
+  `data` text NOT NULL,
+  `last_accessed` int(11) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `subnets` (
+  `id` int(11) NOT NULL,
+  `subnet` varchar(18) DEFAULT NULL,
+  `vlan_tag` int(11) NOT NULL DEFAULT 1,
+  `ip_int_start` bigint(20) NOT NULL,
+  `ip_int_stop` bigint(20) NOT NULL,
+  `dhcp_start` bigint(20) NOT NULL DEFAULT 0,
+  `dhcp_stop` bigint(20) NOT NULL DEFAULT 0,
+  `dhcp_lease_time` int(11) NOT NULL DEFAULT 480,
+  `gateway` bigint(20) NOT NULL DEFAULT 0,
+  `office` tinyint(1) NOT NULL DEFAULT 1,
+  `hotspot` tinyint(1) NOT NULL DEFAULT 0,
+  `vpn` tinyint(1) NOT NULL DEFAULT 0,
+  `free` tinyint(1) NOT NULL DEFAULT 0,
+  `dhcp` tinyint(1) NOT NULL DEFAULT 1,
+  `static` tinyint(1) NOT NULL DEFAULT 0,
+  `dhcp_update_hostname` tinyint(1) NOT NULL DEFAULT 0,
+  `discovery` tinyint(1) NOT NULL DEFAULT 1,
+  `notify` tinyint(1) NOT NULL DEFAULT 7,
+  `description` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `traffic_detail` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
+  `router_id` int(11) NOT NULL DEFAULT 0,
+  `ts` DATETIME NULL DEFAULT NULL,
+  `proto` tinyint(3) UNSIGNED DEFAULT NULL,
+  `src_ip` bigint(20) NOT NULL DEFAULT 0,
+  `dst_ip` bigint(20) NOT NULL DEFAULT 0,
+  `src_port` smallint(5) UNSIGNED NOT NULL,
+  `dst_port` smallint(5) UNSIGNED NOT NULL,
+  `bytes` bigint(20) NOT NULL,
+  `pkt` int(10) UNSIGNED NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `unknown_mac` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `mac` varchar(17) DEFAULT NULL,
+  `port_id` bigint(20) UNSIGNED DEFAULT NULL,
+  `device_id` int(11) DEFAULT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `user_auth` (
+  `id` int(11) NOT NULL,
+  `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
+  `ou_id` int(11) DEFAULT NULL,
+  `ip` varchar(18) DEFAULT NULL,
+  `ip_int` bigint(10) UNSIGNED NOT NULL DEFAULT 0,
+  `save_traf` tinyint(1) NOT NULL DEFAULT 0,
+  `enabled` tinyint(1) NOT NULL DEFAULT 0,
+  `dhcp` tinyint(1) NOT NULL DEFAULT 1,
+  `filter_group_id` tinyint(1) NOT NULL DEFAULT 0,
+  `dynamic` tinyint(1) NOT NULL DEFAULT 0,
+  `end_life` datetime DEFAULT NULL,
+  `deleted` tinyint(4) NOT NULL DEFAULT 0,
+  `description` varchar(250) DEFAULT NULL,
+  `dns_name` varchar(253) DEFAULT NULL,
+  `dns_ptr_only` tinyint(1) NOT NULL DEFAULT 0,
+  `wikiname` varchar(250) DEFAULT NULL,
+  `dhcp_acl` text DEFAULT NULL,
+  `queue_id` int(11) NOT NULL DEFAULT 0,
+  `mac` varchar(17) DEFAULT NULL,
+  `dhcp_action` varchar(10) NOT NULL DEFAULT '',
+  `dhcp_option_set` varchar(50) DEFAULT NULL,
+  `dhcp_time` datetime NOT NULL DEFAULT current_timestamp(),
+  `dhcp_hostname` varchar(60) DEFAULT NULL,
+  `last_found` datetime NOT NULL DEFAULT current_timestamp(),
+  `arp_found` datetime DEFAULT NULL,
+  `mac_found` datetime DEFAULT NULL,
+  `blocked` tinyint(1) NOT NULL DEFAULT 0,
+  `day_quota` int(11) NOT NULL DEFAULT 0,
+  `month_quota` int(11) NOT NULL DEFAULT 0,
+  `device_model_id` int(11) DEFAULT 87,
+  `firmware` varchar(100) DEFAULT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `client_id` varchar(250) DEFAULT NULL,
+  `nagios` tinyint(1) NOT NULL DEFAULT 0,
+  `nagios_status` varchar(10) NOT NULL DEFAULT '',
+  `nagios_handler` varchar(50) NOT NULL DEFAULT '',
+  `link_check` tinyint(1) NOT NULL DEFAULT 0,
+  `changed` tinyint(1) NOT NULL DEFAULT 0,
+  `dhcp_changed` int(11) NOT NULL DEFAULT 0,
+  `changed_time` datetime NOT NULL DEFAULT current_timestamp(),
+  `created_by` varchar(10) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `user_auth_alias` (
+  `id` int(11) NOT NULL,
+  `auth_id` int(11) NOT NULL,
+  `alias` varchar(100) DEFAULT NULL,
+  `description` varchar(100) DEFAULT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `user_list` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `login` varchar(255) DEFAULT NULL,
+  `description` varchar(255) DEFAULT NULL,
+  `enabled` tinyint(1) NOT NULL DEFAULT 1,
+  `blocked` tinyint(1) NOT NULL DEFAULT 0,
+  `deleted` tinyint(1) NOT NULL DEFAULT 0,
+  `ou_id` int(11) NOT NULL DEFAULT 0,
+  `device_id` int(11) DEFAULT NULL,
+  `filter_group_id` int(11) NOT NULL DEFAULT 0,
+  `queue_id` int(11) NOT NULL DEFAULT 0,
+  `day_quota` int(11) NOT NULL DEFAULT 0,
+  `month_quota` int(11) NOT NULL DEFAULT 0,
+  `permanent` tinyint(1) NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `user_sessions` (
+  `id` int(11) NOT NULL,
+  `session_id` varchar(128) NOT NULL,
+  `user_id` int(11) NOT NULL,
+  `ip_address` varchar(45) NOT NULL,
+  `user_agent` text NOT NULL,
+  `created_at` int(11) NOT NULL,
+  `last_activity` int(11) NOT NULL,
+  `is_active` tinyint(1) DEFAULT 1
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `user_stats` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `router_id` bigint(20) UNSIGNED DEFAULT 0,
+  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
+  `ts` datetime NOT NULL DEFAULT current_timestamp(),
+  `byte_in` bigint(20) NOT NULL DEFAULT 0,
+  `byte_out` bigint(20) NOT NULL DEFAULT 0,
+  `pkt_in` int(11) NOT NULL DEFAULT 0,
+  `pkt_out` int(11) NOT NULL DEFAULT 0,
+  `step` int(11) NOT NULL DEFAULT 3600
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `user_stats_full` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `router_id` bigint(20) UNSIGNED DEFAULT 0,
+  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
+  `ts` datetime NOT NULL DEFAULT current_timestamp(),
+  `byte_in` bigint(20) NOT NULL DEFAULT 0,
+  `byte_out` bigint(20) NOT NULL DEFAULT 0,
+  `pkt_in` int(11) NOT NULL DEFAULT 0,
+  `pkt_out` int(11) NOT NULL DEFAULT 0,
+  `step` int(11) NOT NULL DEFAULT 600
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `variables` (
+  `id` int(11) NOT NULL,
+  `name` varchar(30) NOT NULL,
+  `value` varchar(255) DEFAULT NULL,
+  `clear_time` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `created` DATETIME NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `vendors` (
+  `id` int(11) NOT NULL,
+  `name` varchar(40) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `version` (
+  `id` int(11) NOT NULL DEFAULT 1,
+  `version` varchar(10) NOT NULL DEFAULT '2.4.14'
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `wan_stats` (
+  `id` int(11) NOT NULL,
+  `ts` datetime NOT NULL DEFAULT current_timestamp(),
+  `router_id` int(11) DEFAULT NULL,
+  `interface_id` int(11) DEFAULT NULL,
+  `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_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+CREATE TABLE `worklog` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
+  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
+  `customer` varchar(50) NOT NULL DEFAULT 'system',
+  `ip` varchar(18) NOT NULL DEFAULT '127.0.0.1',
+  `message` text NOT NULL,
+  `level` int(11) NOT NULL DEFAULT 1
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
+
+
+ALTER TABLE `acl`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `ad_comp_cache`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `comp_name` (`name`);
+
+ALTER TABLE `auth_rules`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `rule` (`rule`),
+  ADD KEY `user_id` (`user_id`);
+
+ALTER TABLE `building`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `config`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `option` (`option_id`);
+
+ALTER TABLE `config_options`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `connections`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `auth_id` (`auth_id`),
+  ADD KEY `device_id` (`device_id`,`port_id`);
+
+ALTER TABLE `customers`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `devices`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ip` (`ip`),
+  ADD KEY `device_type` (`device_type`);
+
+ALTER TABLE `device_filter_instances`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `device_l3_interfaces`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `device_models`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `device_ports`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `device_id` (`device_id`),
+  ADD KEY `port` (`port`),
+  ADD KEY `target_port_id` (`target_port_id`);
+
+ALTER TABLE `device_types`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `dhcp_log`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ts` (`ts`,`action`);
+
+ALTER TABLE `dhcp_queue`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ts` (`ts`,`action`);
+
+ALTER TABLE `dns_cache`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `dns` (`dns`,`ip`),
+  ADD KEY `ts` (`ts`);
+
+ALTER TABLE `dns_queue`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `filter_instances`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `name` (`name`);
+
+ALTER TABLE `filter_list`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `Name` (`name`);
+
+ALTER TABLE `gateway_subnets`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `group_filters`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `GroupId` (`group_id`,`filter_id`);
+
+ALTER TABLE `group_list`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `mac_history`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `mac` (`mac`,`ts`),
+  ADD KEY `ip` (`ip`,`ts`),
+  ADD KEY `ts` (`ts`) USING BTREE,
+  ADD KEY `mac_2` (`mac`),
+  ADD KEY `ip_2` (`ip`);
+
+ALTER TABLE `mac_vendors`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `oui` (`oui`);
+
+ALTER TABLE `ou`
+  ADD PRIMARY KEY (`id`);
+ALTER TABLE `ou` ADD FULLTEXT KEY `ou_name` (`ou_name`);
+
+ALTER TABLE `queue_list`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `id` (`id`);
+
+ALTER TABLE `remote_syslog`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `date` (`ts`,`device_id`,`ip`);
+
+ALTER TABLE `sessions`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `last_accessed` (`last_accessed`);
+
+ALTER TABLE `subnets`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ip_int_start` (`ip_int_start`,`ip_int_stop`),
+  ADD KEY `dhcp` (`dhcp`,`office`,`hotspot`,`static`);
+
+ALTER TABLE `traffic_detail`
+  ADD PRIMARY KEY (`id`),
+  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`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ts` (`ts`,`device_id`,`port_id`,`mac`);
+
+ALTER TABLE `user_auth`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `auth_index` (`id`,`user_id`,`ip_int`,`mac`,`ip`,`deleted`) USING BTREE,
+  ADD KEY `deleted` (`deleted`),
+  ADD KEY `ou_id` (`ou_id`);
+
+ALTER TABLE `user_auth_alias`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `auth_id` (`auth_id`);
+
+ALTER TABLE `user_list`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `users` (`id`,`ou_id`,`enabled`,`blocked`,`deleted`);
+
+ALTER TABLE `user_sessions`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `session_id` (`session_id`),
+  ADD KEY `user_id` (`user_id`),
+  ADD KEY `is_active` (`is_active`);
+
+ALTER TABLE `user_stats`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ts` (`ts`,`auth_id`,`router_id`);
+
+ALTER TABLE `user_stats_full`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `ts` (`ts`,`auth_id`,`router_id`);
+
+ALTER TABLE `variables`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `name` (`name`),
+  ADD KEY `clear_time` (`clear_time`,`created`);
+
+ALTER TABLE `vendors`
+  ADD PRIMARY KEY (`id`);
+
+ALTER TABLE `version`
+  ADD UNIQUE KEY `id` (`id`);
+
+ALTER TABLE `wan_stats`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `main` (`ts`,`router_id`,`interface_id`),
+  ADD KEY `times` (`ts`);
+
+ALTER TABLE `worklog`
+  ADD PRIMARY KEY (`id`),
+  ADD KEY `idx_customer` (`customer`,`level`,`ts`),
+  ADD KEY `idx_timestamp` (`level`,`ts`),
+  ADD KEY `idx_auth_id` (`auth_id`,`level`,`ts`);
+
+ALTER TABLE `worklog` ADD INDEX `idx_ts` (`ts`);
+
+ALTER TABLE `acl`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `ad_comp_cache`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `auth_rules`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `building`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `config`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `config_options`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `connections`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `customers`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `devices`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `device_filter_instances`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `device_l3_interfaces`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `device_models`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `device_ports`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `device_types`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `dhcp_log`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `dhcp_queue`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `dns_cache`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `dns_queue`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `filter_instances`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `filter_list`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `gateway_subnets`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `group_filters`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `group_list`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `mac_history`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `mac_vendors`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `ou`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `queue_list`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `remote_syslog`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `subnets`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `traffic_detail`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `unknown_mac`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `user_auth`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `user_auth_alias`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `user_list`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `user_sessions`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `user_stats`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `user_stats_full`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `variables`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `vendors`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `wan_stats`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `worklog`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

+ 359 - 0
docs/databases/mysql/ru/data.sql

@@ -0,0 +1,359 @@
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+SET time_zone = "+00:00";
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+
+INSERT INTO `acl` (`id`, `name`, description_english, description_russian) VALUES(0,'Disabled','User disabled','Пользователь отключен');
+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`, `description`) VALUES(1, 'Earth', 'Somewhere');
+
+INSERT INTO `config_options` (`id`, `option_name`, description_russian, description_english, `draft`, `uniq`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `option_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`, `description`, `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(2, '2011UAS-2HnD', 9, 1, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(3, 'AT-8000S', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(4, 'AT-8100S/48POE', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(5, 'AT-9000/28', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(6, 'AT-GS950/24', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(7, 'CCR1009-7G-1C-1S+', 9, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(8, 'CCR1036-8G-2S+', 9, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(10, 'CRS317-1G-16S+', 9, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(11, 'CRS326-24S+2Q+', 9, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(12, 'CRS328-24P-4S+', 9, 1, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(14, 'CRS328-4C-20S-4S+', 9, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(15, 'DGS-3120-48TC', 7, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(16, 'ES-2024', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(17, 'ES-2024A', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(18, 'ES-2108', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(19, 'ES-2108-G', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(20, 'ES-3124-4F', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(21, 'GS110TP', 10, 0, 1, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(22, 'GS-4024', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(23, 'HP 1910', 15, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(24, 'ISCOM2110A-MA', 5, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(25, 'ISCOM2110EA-MA', 5, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(26, 'ISCOM2126EA-MA', 5, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(27, 'ISCOM2128EA-MA', 5, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(28, 'Linux server', 1, 0, 0, '');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(29, 'MES2124F', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(30, 'MES2124MB', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(31, 'MES5248', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(32, 'RB2011UAS', 9, 1, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(33, 'RB3011UiAS', 9, 1, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(34, 'RB960PGS', 9, 1, 1, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(35, 'RBD52G-5HacD2HnD', 9, 1, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(36, 'S2940-8G-v2', 6, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(37, 'S2980G-24T', 6, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(38, 'S3750G-24S-E', 6, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(39, 'S5300-52P-LI-AC', 3, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(40, 'S5320-52X-PWR-SI-AC', 3, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(41, 'S5321-28X-SI-AC', 3, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(42, 'S5321-52X-SI-AC', 3, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(43, 'S6320-54C-EI-48S-AC', 3, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(44, 'SNR-S2980G-24T', 6, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(45, 'V1910-16G', 15, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(46, 'V1910-24G-PoE', 15, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(47, 'Windows server', 1, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(48, 'WS-C2960G-24TC-L', 16, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(49, 'WS-C3560G-24TS-S', 16, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(50, 'x210-16GT', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(51, 'x210-24GT', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(52, 'x610-24Ts/X', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(53, 'x610-48Ts', 8, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(54, 'XGS-4728', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(55, 'ZyWall 310', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(56, 'APC Smart-UPS_3000', 20, 0, 0, 'ups.cfg');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(57, 'APC Smart-UPS_5000', 20, 0, 0, 'ups.cfg');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(58, 'Schneider Smart-UPS_3000', 21, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(59, 'SMG-1016M', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(60, 'EATON 9PX 1500i RT 2U', 64, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(61, 'EATON 9PX3000i_RT_2U', 64, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(62, 'EATON 9PX_6000i', 64, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(63, 'EATON PW9130_3000', 64, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(64, 'EATON PW9130_3000VA-R', 64, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(65, 'Epson WF-5620 Series', 59, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(66, 'Epson WF-8590 Series', 59, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(67, 'HP Officejet-7000', 15, 0, 0, 'hp.cfg');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(68, 'OKI C610', 62, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(69, 'OKI MB472', 62, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(70, 'OKI MB491', 62, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(71, 'OKI MC562', 62, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(72, 'OKI MC573', 62, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(73, 'OKI MC861', 62, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(74, 'Panasonic KX-MB2000RU', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(75, 'PT-MZ10KE', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(76, 'PT-VX41', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(77, 'Rave 522AA', 33, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(78, 'DZ570E', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(79, 'DZ6700', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(80, 'Rcq80', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(81, 'RZ12K', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(82, 'RZ660', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(83, 'RZ770', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(84, 'RZ970', 61, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(85, 'XVR-5216', 66, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(86, 'HWg-STE', 68, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(87, 'Computer', 1, 0, 0, '');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(88, 'Mobile Phone', 1, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(89, 'Switch', 1, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(90, 'Projectiondesign F22', 34, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(91, 'DS-I252', 36, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(92, 'LTV-CNE-720-48', 37, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(93, 'U-100', 38, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(94, 'TAU-8', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(95, 'SIP-T21P E2', 39, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(96, 'A510 IP', 40, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(97, 'W60B', 39, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(98, 'TAU-2M', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(99, 'PAP2T', 41, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(100, 'VP-12', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(101, 'SIP-T23P', 39, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(102, 'SPA-2102', 16, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(103, 'RB760iGS', 9, 1, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(104, 'MES2324B', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(105, 'MES2324FB', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(106, 'MES2124P', 2, 0, 1, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(107, 'MES2428P', 2, 0, 1, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(108, 'Symmetra LX 16000', 20, 0, 0, 'symmetra.cfg');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(109, 'SNR-UPS-ONT20', 6, 0, 0, 'ups3.cfg');
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(110, 'MES-3728', 4, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(111, 'SNR-S5210G-24TX-UPS-R', 6, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(112, 'SNR-S2985G-24TC', 6, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(113, 'MES-5248', 2, 0, 0, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(114, 'SNR-S5210G-24TX-POE', 6, 0, 1, NULL);
+INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(115, 'SNR-S5210G-24TX-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_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`, `description`) VALUES(1, 'default', NULL);
+
+INSERT INTO `group_list` (`id`, `instance_id`, `group_name`, `description`) VALUES(0, 1, 'default', 'Всё запрещено');
+INSERT INTO `group_list` (`id`, `instance_id`, `group_name`, `description`) VALUES(1, 1, 'Allow all', 'Разрешено всё');
+INSERT INTO `group_list` (`id`, `instance_id`, `group_name`, `description`) VALUES(2, 1, 'Users','Для пользователей');
+
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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`, `description`, `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`, `description`, `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(2, 'Администраторы', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(3, 'Пользователи', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(4, 'VOIP', NULL, 0, 0, 'voip', 'voip', 1, NULL, 1, 4, 5, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(5, 'IPCAM', NULL, 0, 0, 'videocam', 'ip-cam', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(6, 'Принтеры', NULL, 0, 0, 'printers', 'printers', 1, 'printer-service', 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(7, 'Свичи', NULL, 0, 0, 'switches', 'switches', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(8, 'UPS', NULL, 0, 0, 'ups', 'ups', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(9, 'Охрана', NULL, 0, 0, 'security', 'security', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(10, 'Роутеры', NULL, 0, 0, 'routers', 'routers', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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(11, 'WiFi AP', NULL, 0, 0, 'ap', 'ap', 1, NULL, 0, 0, 0, 0, '24.00', NULL);
+INSERT INTO `ou` (`id`, `ou_name`, `description`, `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`, `description`, `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 `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`, `description`) 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 `vendors` (`id`, `name`) VALUES(1, 'Unknown');
+INSERT INTO `vendors` (`id`, `name`) VALUES(2, 'Eltex');
+INSERT INTO `vendors` (`id`, `name`) VALUES(3, 'Huawei');
+INSERT INTO `vendors` (`id`, `name`) VALUES(4, 'Zyxel');
+INSERT INTO `vendors` (`id`, `name`) VALUES(5, 'Raisecom');
+INSERT INTO `vendors` (`id`, `name`) VALUES(6, 'SNR');
+INSERT INTO `vendors` (`id`, `name`) VALUES(7, 'Dlink');
+INSERT INTO `vendors` (`id`, `name`) VALUES(8, 'Allied Telesis');
+INSERT INTO `vendors` (`id`, `name`) VALUES(9, 'Mikrotik');
+INSERT INTO `vendors` (`id`, `name`) VALUES(10, 'NetGear');
+INSERT INTO `vendors` (`id`, `name`) VALUES(11, 'Ubiquiti');
+INSERT INTO `vendors` (`id`, `name`) VALUES(15, 'HP');
+INSERT INTO `vendors` (`id`, `name`) VALUES(16, 'Cisco');
+INSERT INTO `vendors` (`id`, `name`) VALUES(17, 'Maipu');
+INSERT INTO `vendors` (`id`, `name`) VALUES(18, 'Asus');
+INSERT INTO `vendors` (`id`, `name`) VALUES(19, 'Linux');
+INSERT INTO `vendors` (`id`, `name`) VALUES(20, 'APC');
+INSERT INTO `vendors` (`id`, `name`) VALUES(21, 'Schneider');
+INSERT INTO `vendors` (`id`, `name`) VALUES(33, 'QSC');
+INSERT INTO `vendors` (`id`, `name`) VALUES(34, 'Projectiondesign');
+INSERT INTO `vendors` (`id`, `name`) VALUES(35, 'Lenovo');
+INSERT INTO `vendors` (`id`, `name`) VALUES(36, 'HiWatch');
+INSERT INTO `vendors` (`id`, `name`) VALUES(37, 'LTV');
+INSERT INTO `vendors` (`id`, `name`) VALUES(38, 'Yeastar');
+INSERT INTO `vendors` (`id`, `name`) VALUES(39, 'Yealink');
+INSERT INTO `vendors` (`id`, `name`) VALUES(40, 'Gigaset');
+INSERT INTO `vendors` (`id`, `name`) VALUES(41, 'Linksys');
+INSERT INTO `vendors` (`id`, `name`) VALUES(42, 'Samsung');
+INSERT INTO `vendors` (`id`, `name`) VALUES(43, 'Supermicro');
+INSERT INTO `vendors` (`id`, `name`) VALUES(44, 'RDP');
+INSERT INTO `vendors` (`id`, `name`) VALUES(45, 'SANYO');
+INSERT INTO `vendors` (`id`, `name`) VALUES(46, 'Extreme');
+INSERT INTO `vendors` (`id`, `name`) VALUES(47, 'Intel');
+INSERT INTO `vendors` (`id`, `name`) VALUES(48, 'Micron');
+INSERT INTO `vendors` (`id`, `name`) VALUES(49, 'Gigabyte');
+INSERT INTO `vendors` (`id`, `name`) VALUES(50, 'Acer');
+INSERT INTO `vendors` (`id`, `name`) VALUES(51, 'Seagate');
+INSERT INTO `vendors` (`id`, `name`) VALUES(52, 'SanDisk');
+INSERT INTO `vendors` (`id`, `name`) VALUES(53, 'Toshiba');
+INSERT INTO `vendors` (`id`, `name`) VALUES(54, 'Kingston');
+INSERT INTO `vendors` (`id`, `name`) VALUES(55, 'AddPac');
+INSERT INTO `vendors` (`id`, `name`) VALUES(56, 'Devline');
+INSERT INTO `vendors` (`id`, `name`) VALUES(57, 'Canon');
+INSERT INTO `vendors` (`id`, `name`) VALUES(58, 'Brother');
+INSERT INTO `vendors` (`id`, `name`) VALUES(59, 'Epson');
+INSERT INTO `vendors` (`id`, `name`) VALUES(60, 'IP-COM');
+INSERT INTO `vendors` (`id`, `name`) VALUES(61, 'Panasonic');
+INSERT INTO `vendors` (`id`, `name`) VALUES(62, 'OKI');
+INSERT INTO `vendors` (`id`, `name`) VALUES(63, 'Apple');
+INSERT INTO `vendors` (`id`, `name`) VALUES(64, 'Eaton');
+INSERT INTO `vendors` (`id`, `name`) VALUES(65, 'Barco');
+INSERT INTO `vendors` (`id`, `name`) VALUES(66, 'Trassir');
+INSERT INTO `vendors` (`id`, `name`) VALUES(67, 'Testo');
+INSERT INTO `vendors` (`id`, `name`) VALUES(68, 'Hw-group');
+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 `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 (2,11,'public');
+INSERT INTO `config` VALUES (3,32,'ORG');
+INSERT INTO `config` VALUES (123,19,'1');
+INSERT INTO `config` VALUES (124,35,'120');
+INSERT INTO `config` VALUES (125,9,'2');
+INSERT INTO `config` VALUES (126,41,'/opt/Eye/scripts/fetch_new_arp.pl');
+INSERT INTO `config` VALUES (127,26,'3');
+INSERT INTO `config` VALUES (128,27,'10');
+INSERT INTO `config` VALUES (129,48,'90');
+INSERT INTO `config` VALUES (130,49,'365');
+INSERT INTO `config` VALUES (131,47,'90');
+INSERT INTO `config` VALUES (132,53,'1');
+INSERT INTO `config` VALUES (133,55,'1');
+INSERT INTO `config` VALUES (134,56,'30');
+INSERT INTO `config` VALUES (135,34,'0');
+INSERT INTO `config` VALUES (137,65,'0');
+INSERT INTO `config` VALUES (142,54,'');
+INSERT INTO `config` VALUES (143,17,'1');
+INSERT INTO `config` VALUES (144,37,'/opt/Eye/scripts/sync_mikrotik.pl');
+INSERT INTO `config` VALUES (145,23,'1');
+INSERT INTO `config` VALUES (148,22,'1');
+
+INSERT INTO `version` (`id`, `version`) VALUES(1, '3.0.1');
+
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

+ 677 - 0
docs/databases/postgres/en/create_db.sql

@@ -0,0 +1,677 @@
+-- Enable required extensions
+CREATE EXTENSION IF NOT EXISTS pg_trgm;
+CREATE EXTENSION IF NOT EXISTS btree_gin;
+
+-- Access Control List
+CREATE TABLE acl (
+id SERIAL PRIMARY KEY,
+name VARCHAR(30) 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 COLUMN acl.description_english IS 'Description in English';
+COMMENT ON COLUMN acl.description_russian IS 'Description in Russian';
+
+-- Active Directory computer cache
+CREATE TABLE ad_comp_cache (
+id SERIAL PRIMARY KEY,
+name VARCHAR(63) NOT NULL UNIQUE,
+last_found TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+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.last_found IS 'Last time this computer was detected';
+
+-- Authentication rules
+CREATE TABLE auth_rules (
+id SERIAL PRIMARY KEY,
+user_id INTEGER,
+ou_id INTEGER,
+rule_type SMALLINT NOT NULL,
+rule VARCHAR(40) UNIQUE,
+description VARCHAR(250)
+);
+COMMENT ON TABLE auth_rules IS 'User authentication and authorization rules';
+COMMENT ON COLUMN auth_rules.rule_type IS 'Rule type: 0=allow, 1=deny, etc.';
+COMMENT ON COLUMN auth_rules.rule IS 'Rule identifier (unique)';
+
+-- Buildings
+CREATE TABLE building (
+id SERIAL PRIMARY KEY,
+name VARCHAR(50) NOT NULL,
+description VARCHAR(250)
+);
+COMMENT ON TABLE building IS 'Physical buildings/locations';
+COMMENT ON COLUMN building.name IS 'Building name';
+
+-- System configuration
+CREATE TABLE config (
+id SERIAL PRIMARY KEY,
+option_id INTEGER,
+value VARCHAR(250)
+);
+COMMENT ON TABLE config IS 'System configuration values';
+
+-- Configuration options
+CREATE TABLE config_options (
+id SERIAL PRIMARY KEY,
+option_name VARCHAR(50) NOT NULL,
+description_russian TEXT,
+description_english TEXT,
+draft SMALLINT NOT NULL DEFAULT 0,
+uniq SMALLINT NOT NULL DEFAULT 1,
+option_type VARCHAR(100) NOT NULL,
+default_value VARCHAR(250),
+min_value INTEGER NOT NULL DEFAULT 0,
+max_value INTEGER NOT NULL DEFAULT 0
+);
+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.draft IS 'Option is in draft state';
+COMMENT ON COLUMN config_options.uniq IS 'Option is unique (single value)';
+
+-- Network connections
+CREATE TABLE connections (
+id BIGSERIAL PRIMARY KEY,
+device_id BIGINT NOT NULL,
+port_id BIGINT NOT NULL,
+auth_id BIGINT NOT NULL,
+last_found TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+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.port_id IS 'Device port ID';
+COMMENT ON COLUMN connections.auth_id IS 'User authentication ID';
+COMMENT ON COLUMN connections.last_found IS 'Last connection activity time';
+
+-- System users
+CREATE TABLE customers (
+id SERIAL PRIMARY KEY,
+login VARCHAR(20),
+description VARCHAR(100),
+password VARCHAR(255),
+api_key VARCHAR(255),
+rights SMALLINT NOT NULL DEFAULT 3
+);
+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
+CREATE TABLE devices (
+id SERIAL PRIMARY KEY,
+device_type INTEGER NOT NULL DEFAULT 1,
+device_model_id INTEGER DEFAULT 89,
+firmware VARCHAR(100),
+vendor_id INTEGER NOT NULL DEFAULT 1,
+device_name VARCHAR(50),
+building_id INTEGER NOT NULL DEFAULT 1,
+ip INET DEFAULT NULL,
+ip_int BIGINT,
+login VARCHAR(50),
+password VARCHAR(255),
+protocol SMALLINT NOT NULL DEFAULT 0,
+control_port INTEGER NOT NULL DEFAULT 23,
+port_count INTEGER NOT NULL DEFAULT 0,
+sn VARCHAR(80),
+description VARCHAR(255),
+snmp_version SMALLINT NOT NULL DEFAULT 0,
+snmp3_auth_proto VARCHAR(10) NOT NULL DEFAULT 'sha512',
+snmp3_priv_proto VARCHAR(10) NOT NULL DEFAULT 'aes128',
+snmp3_user_rw VARCHAR(20),
+snmp3_user_rw_password VARCHAR(20),
+snmp3_user_ro VARCHAR(20),
+snmp3_user_ro_password VARCHAR(20),
+community VARCHAR(50) NOT NULL DEFAULT 'public',
+rw_community VARCHAR(50) NOT NULL DEFAULT 'private',
+fdb_snmp_index SMALLINT NOT NULL DEFAULT 0,
+discovery SMALLINT NOT NULL DEFAULT 1,
+netflow_save SMALLINT NOT NULL DEFAULT 0,
+user_acl SMALLINT NOT NULL DEFAULT 0,
+dhcp SMALLINT NOT NULL DEFAULT 0,
+nagios SMALLINT NOT NULL DEFAULT 0,
+active SMALLINT NOT NULL DEFAULT 1,
+nagios_status VARCHAR(10) NOT NULL DEFAULT 'UP',
+queue_enabled SMALLINT NOT NULL DEFAULT 0,
+connected_user_only SMALLINT NOT NULL DEFAULT 1,
+user_id INTEGER,
+deleted SMALLINT NOT NULL DEFAULT 0,
+discovery_locked SMALLINT NOT NULL DEFAULT 0,
+locked_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+COMMENT ON TABLE devices IS 'Network devices (switches, routers, etc.)';
+COMMENT ON COLUMN devices.device_type IS 'Device type ID';
+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.discovery IS 'Enable automatic discovery';
+COMMENT ON COLUMN devices.active IS 'Device is active and monitored';
+
+-- Device filter instances
+CREATE TABLE device_filter_instances (
+id SERIAL PRIMARY KEY,
+instance_id INTEGER,
+device_id INTEGER
+);
+COMMENT ON TABLE device_filter_instances IS 'Filter instances assigned to devices';
+
+-- Device L3 interfaces
+CREATE TABLE device_l3_interfaces (
+id SERIAL PRIMARY KEY,
+device_id INTEGER,
+snmpin INTEGER,
+interface_type SMALLINT NOT NULL DEFAULT 0,
+name VARCHAR(100)
+);
+COMMENT ON TABLE device_l3_interfaces IS 'Layer 3 interfaces on devices';
+COMMENT ON COLUMN device_l3_interfaces.interface_type IS 'Interface type: 0=unknown, 1=LAN, 2=WAN, 3=DMZ';
+
+-- Device models
+CREATE TABLE device_models (
+id SERIAL PRIMARY KEY,
+model_name VARCHAR(200),
+vendor_id INTEGER DEFAULT 1,
+poe_in SMALLINT NOT NULL DEFAULT 0,
+poe_out SMALLINT NOT NULL DEFAULT 0,
+nagios_template VARCHAR(200)
+);
+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_out IS 'Provides Power over Ethernet output';
+
+-- Device ports
+CREATE TABLE device_ports (
+id BIGSERIAL PRIMARY KEY,
+device_id INTEGER,
+snmp_index INTEGER,
+port INTEGER,
+ifname VARCHAR(40),
+port_name VARCHAR(40),
+description VARCHAR(50),
+target_port_id INTEGER NOT NULL DEFAULT 0,
+auth_id BIGINT,
+last_mac_count INTEGER DEFAULT 0,
+uplink SMALLINT NOT NULL DEFAULT 0,
+nagios SMALLINT NOT NULL DEFAULT 0,
+skip SMALLINT NOT NULL DEFAULT 0,
+vlan INTEGER NOT NULL DEFAULT 1,
+tagged_vlan VARCHAR(250),
+untagged_vlan VARCHAR(250),
+forbidden_vlan VARCHAR(250)
+);
+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.uplink IS 'This is an uplink port';
+COMMENT ON COLUMN device_ports.vlan IS 'Default/native VLAN';
+
+-- Device types
+CREATE TABLE device_types (
+id SERIAL PRIMARY KEY,
+name_russian VARCHAR(50),
+name_english VARCHAR(50)
+);
+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';
+
+-- DHCP logs
+CREATE TABLE dhcp_log (
+id BIGSERIAL PRIMARY KEY,
+mac MACADDR NOT NULL,
+ip_int BIGINT NOT NULL,
+ip INET DEFAULT NULL,
+action VARCHAR(10) NOT NULL,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+auth_id BIGINT NOT NULL,
+dhcp_hostname 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 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';
+
+-- DHCP queue
+CREATE TABLE dhcp_queue (
+id BIGSERIAL PRIMARY KEY,
+mac MACADDR NOT NULL,
+ip INET DEFAULT NULL,
+action VARCHAR(10) NOT NULL,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+dhcp_hostname VARCHAR(250)
+);
+COMMENT ON TABLE dhcp_queue IS 'Queue of deferred DHCP operations';
+
+-- DNS cache
+CREATE TABLE dns_cache (
+id BIGSERIAL PRIMARY KEY,
+dns VARCHAR(250),
+ip BIGINT,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+COMMENT ON TABLE dns_cache IS 'DNS resolution cache';
+
+-- DNS queue
+CREATE TABLE dns_queue (
+id SERIAL PRIMARY KEY,
+auth_id INTEGER,
+name_type VARCHAR(10) NOT NULL DEFAULT 'A',
+name VARCHAR(200),
+operation_type VARCHAR(10) NOT NULL DEFAULT 'add',
+value VARCHAR(100)
+);
+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.operation_type IS 'Operation type: add, delete, update';
+
+-- Filter instances
+CREATE TABLE filter_instances (
+id SERIAL PRIMARY KEY,
+name VARCHAR(50) UNIQUE,
+description VARCHAR(200)
+);
+COMMENT ON TABLE filter_instances IS 'Filtering policy instances';
+
+-- Firewall rule list
+CREATE TABLE filter_list (
+id SERIAL PRIMARY KEY,
+name VARCHAR(50),
+description VARCHAR(250),
+proto VARCHAR(10),
+dst TEXT,
+dstport VARCHAR(20),
+srcport VARCHAR(20),
+filter_type SMALLINT NOT NULL DEFAULT 0
+);
+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.filter_type IS 'Rule type: 0=allow, 1=deny';
+
+-- Subnet gateways
+CREATE TABLE gateway_subnets (
+id SERIAL PRIMARY KEY,
+device_id INTEGER,
+subnet_id INTEGER
+);
+COMMENT ON TABLE gateway_subnets IS 'Which devices act as gateways for which subnets';
+
+-- Group filter assignments
+CREATE TABLE group_filters (
+id SERIAL PRIMARY KEY,
+group_id INTEGER NOT NULL DEFAULT 0,
+filter_id INTEGER NOT NULL DEFAULT 0,
+rule_order INTEGER NOT NULL DEFAULT 0,
+action SMALLINT NOT NULL DEFAULT 0
+);
+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
+CREATE TABLE group_list (
+id SERIAL PRIMARY KEY,
+instance_id INTEGER NOT NULL DEFAULT 1,
+group_name VARCHAR(50),
+description VARCHAR(250)
+);
+COMMENT ON TABLE group_list IS 'Filtering policy groups';
+
+-- MAC address history
+CREATE TABLE mac_history (
+id BIGSERIAL PRIMARY KEY,
+mac MACADDR NOT NULL,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+device_id BIGINT,
+port_id BIGINT,
+ip INET DEFAULT NULL,
+auth_id BIGINT,
+dhcp_hostname VARCHAR(250)
+);
+COMMENT ON TABLE mac_history IS 'MAC address movement history';
+COMMENT ON COLUMN mac_history.mac IS 'MAC address';
+COMMENT ON COLUMN mac_history.ip IS 'Last used IP address';
+
+-- MAC address vendors
+CREATE TABLE mac_vendors (
+id SERIAL PRIMARY KEY,
+oui VARCHAR(20),
+companyname VARCHAR(255),
+companyaddress VARCHAR(255)
+);
+COMMENT ON TABLE mac_vendors IS 'MAC address vendor database';
+COMMENT ON COLUMN mac_vendors.oui IS 'Organizationally Unique Identifier (first 6 MAC characters)';
+
+-- Organizational Units
+CREATE TABLE ou (
+id SERIAL PRIMARY KEY,
+ou_name VARCHAR(40),
+description VARCHAR(250),
+default_users SMALLINT NOT NULL DEFAULT 0,
+default_hotspot SMALLINT NOT NULL DEFAULT 0,
+nagios_dir VARCHAR(255),
+nagios_host_use VARCHAR(50),
+nagios_ping SMALLINT NOT NULL DEFAULT 1,
+nagios_default_service VARCHAR(100),
+enabled SMALLINT NOT NULL DEFAULT 0,
+filter_group_id INTEGER NOT NULL DEFAULT 0,
+queue_id INTEGER NOT NULL DEFAULT 0,
+dynamic SMALLINT NOT NULL DEFAULT 0,
+life_duration DECIMAL(10,2) NOT NULL DEFAULT 24.00,
+parent_id INTEGER
+);
+COMMENT ON TABLE ou IS 'Organizational Units (departments/groups)';
+COMMENT ON COLUMN ou.ou_name IS 'ou name/identifier';
+COMMENT ON COLUMN ou.life_duration IS 'Default lifetime in hours for dynamic OUs';
+
+-- Traffic shaping queues
+CREATE TABLE queue_list (
+id SERIAL PRIMARY KEY,
+queue_name VARCHAR(20) NOT NULL,
+download INTEGER NOT NULL DEFAULT 0,
+upload INTEGER NOT NULL DEFAULT 0
+);
+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
+CREATE TABLE remote_syslog (
+id BIGSERIAL PRIMARY KEY,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+device_id BIGINT NOT NULL,
+ip INET DEFAULT NULL,
+message TEXT NOT NULL
+);
+COMMENT ON TABLE remote_syslog IS 'Syslog messages from network devices';
+
+-- PHP sessions
+CREATE TABLE sessions (
+id VARCHAR(128) PRIMARY KEY,
+data TEXT NOT NULL,
+last_accessed INTEGER NOT NULL
+);
+COMMENT ON TABLE sessions IS 'PHP session storage';
+
+-- Network subnets
+CREATE TABLE subnets (
+id SERIAL PRIMARY KEY,
+subnet VARCHAR(18),
+vlan_tag INTEGER NOT NULL DEFAULT 1,
+ip_int_start BIGINT NOT NULL,
+ip_int_stop BIGINT NOT NULL,
+dhcp_start BIGINT NOT NULL DEFAULT 0,
+dhcp_stop BIGINT NOT NULL DEFAULT 0,
+dhcp_lease_time INTEGER NOT NULL DEFAULT 480,
+gateway BIGINT NOT NULL DEFAULT 0,
+office SMALLINT NOT NULL DEFAULT 1,
+hotspot SMALLINT NOT NULL DEFAULT 0,
+vpn SMALLINT NOT NULL DEFAULT 0,
+free SMALLINT NOT NULL DEFAULT 0,
+dhcp SMALLINT NOT NULL DEFAULT 1,
+static SMALLINT NOT NULL DEFAULT 0,
+dhcp_update_hostname SMALLINT NOT NULL DEFAULT 0,
+discovery SMALLINT NOT NULL DEFAULT 1,
+notify SMALLINT NOT NULL DEFAULT 7,
+description VARCHAR(250)
+);
+COMMENT ON TABLE subnets IS 'Network subnet configuration';
+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.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';
+
+CREATE TABLE traffic_detail (
+id BIGSERIAL PRIMARY KEY,
+auth_id   bigint,
+router_id integer NOT NULL DEFAULT 0,
+ts TIMESTAMP,
+proto     smallint,
+src_ip    bigint NOT NULL DEFAULT 0,
+dst_ip    bigint NOT NULL DEFAULT 0,
+src_port  integer NOT NULL DEFAULT 0,
+dst_port  integer NOT NULL DEFAULT 0,
+bytes     bigint NOT NULL DEFAULT 0,
+pkt       bigint 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.dst_ip IS 'Destination IP as integer';
+COMMENT ON COLUMN traffic_detail.bytes IS 'Bytes transferred in this flow';
+
+-- Unknown MAC addresses
+CREATE TABLE unknown_mac (
+id BIGSERIAL PRIMARY KEY,
+mac MACADDR NOT NULL,
+port_id BIGINT,
+device_id INTEGER,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+COMMENT ON TABLE unknown_mac IS 'Recently detected unknown MAC addresses';
+
+-- User authorization records
+CREATE TABLE user_auth (
+id SERIAL PRIMARY KEY,
+user_id BIGINT NOT NULL DEFAULT 0,
+ou_id INTEGER,
+ip INET DEFAULT NULL,
+ip_int BIGINT NOT NULL DEFAULT 0,
+save_traf SMALLINT NOT NULL DEFAULT 0,
+enabled SMALLINT NOT NULL DEFAULT 0,
+dhcp SMALLINT NOT NULL DEFAULT 1,
+filter_group_id SMALLINT NOT NULL DEFAULT 0,
+dynamic SMALLINT NOT NULL DEFAULT 0,
+end_life TIMESTAMP,
+deleted SMALLINT NOT NULL DEFAULT 0,
+description VARCHAR(250),
+dns_name VARCHAR(253),
+dns_ptr_only SMALLINT NOT NULL DEFAULT 0,
+wikiname VARCHAR(250),
+dhcp_acl TEXT,
+queue_id INTEGER NOT NULL DEFAULT 0,
+mac MACADDR,
+dhcp_action VARCHAR(10) NOT NULL DEFAULT '',
+dhcp_option_set VARCHAR(50),
+dhcp_time TIMESTAMP,
+dhcp_hostname VARCHAR(60),
+last_found TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+arp_found TIMESTAMP,
+mac_found TIMESTAMP,
+blocked SMALLINT NOT NULL DEFAULT 0,
+day_quota INTEGER NOT NULL DEFAULT 0,
+month_quota INTEGER NOT NULL DEFAULT 0,
+device_model_id INTEGER DEFAULT 87,
+firmware VARCHAR(100),
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+client_id VARCHAR(250),
+nagios SMALLINT NOT NULL DEFAULT 0,
+nagios_status VARCHAR(10) NOT NULL DEFAULT '',
+nagios_handler VARCHAR(50) NOT NULL DEFAULT '',
+link_check SMALLINT NOT NULL DEFAULT 0,
+changed SMALLINT NOT NULL DEFAULT 0,
+dhcp_changed SMALLINT NOT NULL DEFAULT 0,
+changed_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+created_by VARCHAR(10)
+);
+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
+CREATE TABLE user_auth_alias (
+id SERIAL PRIMARY KEY,
+auth_id INTEGER NOT NULL,
+alias VARCHAR(100),
+description VARCHAR(100),
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+COMMENT ON TABLE user_auth_alias IS 'Aliases/DNS names for authorization records';
+
+-- User list
+CREATE TABLE user_list (
+id BIGSERIAL PRIMARY KEY,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+login VARCHAR(255),
+description VARCHAR(255),
+enabled SMALLINT NOT NULL DEFAULT 1,
+blocked SMALLINT NOT NULL DEFAULT 0,
+deleted SMALLINT NOT NULL DEFAULT 0,
+ou_id INTEGER NOT NULL DEFAULT 0,
+device_id INTEGER,
+filter_group_id INTEGER NOT NULL DEFAULT 0,
+queue_id INTEGER NOT NULL DEFAULT 0,
+day_quota INTEGER NOT NULL DEFAULT 0,
+month_quota INTEGER 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.description IS 'Full name';
+COMMENT ON COLUMN user_list.permanent IS 'Permanent (non-dynamic) user';
+
+-- User web sessions
+CREATE TABLE user_sessions (
+id SERIAL PRIMARY KEY,
+session_id VARCHAR(128) NOT NULL,
+user_id INTEGER NOT NULL,
+ip_address VARCHAR(45) NOT NULL,
+user_agent TEXT NOT NULL,
+created_at INTEGER NOT NULL,
+last_activity INTEGER NOT NULL,
+is_active SMALLINT DEFAULT 1
+);
+COMMENT ON TABLE user_sessions IS 'Web interface user sessions';
+
+-- User traffic statistics
+CREATE TABLE user_stats (
+id BIGSERIAL PRIMARY KEY,
+router_id BIGINT DEFAULT 0,
+auth_id BIGINT NOT NULL DEFAULT 0,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+byte_in BIGINT NOT NULL DEFAULT 0,
+byte_out BIGINT NOT NULL DEFAULT 0,
+pkt_in INTEGER NOT NULL DEFAULT 0,
+pkt_out INTEGER NOT NULL DEFAULT 0,
+step SMALLINT NOT NULL DEFAULT 3600
+);
+COMMENT ON TABLE user_stats IS 'Aggregated user traffic statistics';
+
+-- Detailed user statistics
+CREATE TABLE user_stats_full (
+id BIGSERIAL PRIMARY KEY,
+router_id BIGINT DEFAULT 0,
+auth_id BIGINT NOT NULL DEFAULT 0,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+byte_in BIGINT NOT NULL DEFAULT 0,
+byte_out BIGINT NOT NULL DEFAULT 0,
+pkt_in INTEGER NOT NULL DEFAULT 0,
+pkt_out INTEGER NOT NULL DEFAULT 0,
+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';
+
+-- Temporary variables
+CREATE TABLE variables (
+id SERIAL PRIMARY KEY,
+name VARCHAR(30) NOT NULL UNIQUE,
+value VARCHAR(255),
+clear_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+COMMENT ON TABLE variables IS 'Temporary system variables and locks';
+
+-- Device vendors
+CREATE TABLE vendors (
+id SERIAL PRIMARY KEY,
+name VARCHAR(40) NOT NULL
+);
+COMMENT ON TABLE vendors IS 'Network equipment vendors';
+
+-- System version
+CREATE TABLE version (
+id INTEGER PRIMARY KEY DEFAULT 1,
+version VARCHAR(10) NOT NULL DEFAULT '3.0.0'
+);
+COMMENT ON TABLE version IS 'System version information';
+
+-- WAN interface statistics
+CREATE TABLE wan_stats (
+id BIGSERIAL PRIMARY KEY,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+router_id INTEGER,
+interface_id INTEGER,
+bytes_in BIGINT NOT NULL DEFAULT 0,
+bytes_out BIGINT NOT NULL DEFAULT 0,
+forward_in 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.bytes_in IS 'Bytes received on WAN interface';
+COMMENT ON COLUMN wan_stats.bytes_out IS 'Bytes sent from WAN interface';
+
+-- System activity log
+CREATE TABLE worklog (
+id BIGSERIAL PRIMARY KEY,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+auth_id BIGINT NOT NULL DEFAULT 0,
+customer VARCHAR(50) NOT NULL DEFAULT 'system',
+ip INET NOT NULL DEFAULT '127.0.0.1',
+message TEXT NOT NULL,
+level SMALLINT NOT NULL DEFAULT 1
+);
+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';
+
+-- Indexes (same as in the original schema)
+CREATE INDEX idx_devices_ip ON devices(ip);
+CREATE INDEX idx_devices_device_type ON devices(device_type);
+CREATE INDEX idx_devices_active ON devices(active) WHERE active = 1;
+
+CREATE INDEX idx_device_ports_device_id ON device_ports(device_id);
+CREATE INDEX idx_device_ports_port ON device_ports(port);
+CREATE INDEX idx_device_ports_target_port_id ON device_ports(target_port_id);
+
+CREATE INDEX idx_dhcp_log_ts ON dhcp_log(ts, action);
+CREATE INDEX idx_dhcp_queue_ts ON dhcp_queue(ts, action);
+
+CREATE INDEX idx_dns_cache_dns ON dns_cache(dns, ip);
+CREATE INDEX idx_dns_cache_ts ON dns_cache(ts);
+
+CREATE INDEX idx_mac_history_mac ON mac_history(mac, ts);
+CREATE INDEX idx_mac_history_ip ON mac_history(ip, ts);
+CREATE INDEX idx_mac_history_ts ON mac_history(ts);
+
+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_dhcp ON subnets(dhcp, office, hotspot, static);
+
+CREATE INDEX idx_traffic_detail_src ON traffic_detail(auth_id, ts, router_id, src_ip);
+CREATE INDEX idx_traffic_detail_dst ON traffic_detail(auth_id, ts, router_id, dst_ip);
+
+CREATE INDEX idx_unknown_mac_ts ON unknown_mac(ts, 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_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_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_stats_ts ON user_stats(ts, auth_id, router_id);
+CREATE INDEX idx_user_stats_full_ts ON user_stats_full(ts, auth_id, router_id);
+
+CREATE INDEX idx_wan_stats_time ON wan_stats(ts, router_id, interface_id);
+
+CREATE INDEX idx_worklog_customer ON worklog(customer, level, ts);
+CREATE INDEX idx_worklog_level_ts ON worklog(level, ts);
+CREATE INDEX idx_worklog_auth_id ON worklog(auth_id, level, ts);
+CREATE INDEX idx_worklog_ts ON worklog (ts);

+ 538 - 0
docs/databases/postgres/en/data.sql

@@ -0,0 +1,538 @@
+-- Импорт данных в PostgreSQL (сохранены оригинальные названия)
+
+-- ACL (Access Control List)
+INSERT INTO acl (id, name, description_english, description_russian) 
+VALUES 
+(0, 'Disabled','User disabled','Пользователь отключен'),
+(1, 'Full access', 'Full access', 'Полный доступ'),
+(2, 'Operator', 'Editing parameters that are not related to access rights', 'Редактирование параметров, не связанных с правами доступа'),
+(3, 'View only', 'View only', 'Только просмотр')
+ON CONFLICT (id) DO UPDATE SET
+    name = EXCLUDED.name,
+    description_english = EXCLUDED.description_english,
+    description_russian = EXCLUDED.description_russian;
+
+-- Buildings
+INSERT INTO building (id, name, description)
+VALUES (1, 'Earth', 'Somewhere')
+ON CONFLICT (id) DO UPDATE SET
+    name = EXCLUDED.name,
+    description = EXCLUDED.description;
+
+-- Configuration options
+INSERT INTO config_options (id, option_name, description_russian, description_english, draft, uniq, option_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),
+(3, 'dns server', 'ip-адрес DNS-сервера', 'DNS server ip address', 0, 1, 'text', '127.0.0.1', 0, 0),
+(5, 'dhcp server', 'ip-адрес DHCP-сервера', 'ip address of the DHCP server', 0, 1, 'text', '127.0.0.1', 0, 0),
+(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),
+(11, 'default snmp community', 'Read snmp community по умолчанию', 'Read snmp community by default', 0, 1, 'text', 'public', 0, 0),
+(21, 'admin email', 'E-mail администратора', 'Administrator e-mail', 0, 1, 'text', 'root', 0, 0),
+(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),
+(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),
+(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),
+(27, 'history dhcp lease', 'Глубина хранения аренды dhcp-сервера', 'Storage depth of the dhcp server lease', 0, 1, 'int', '1', 0, 0),
+(28, 'router_login', 'Логин для входа на сетевые устройства по умолчанию', 'Default login for network devices', 0, 1, 'text', 'admin', 0, 0),
+(29, 'router_password', 'Пароль по умолчанию на сетевые устройства', 'Default password for network devices', 0, 1, 'text', 'admin', 0, 0),
+(30, 'router_ssh_port', 'Порт ssh по умолчанию', 'SSH default port', 0, 1, 'int', '22', 22, 0),
+(32, 'org name', 'Название организации', 'Organization name', 0, 1, 'text', 'ORG', 0, 0),
+(33, 'office domain', 'Домен организации', 'Organization domain', 0, 1, 'text', 'local', 0, 0),
+(34, 'debug', 'Включить отладку', 'Enable debugging', 0, 1, 'bool', '0', 0, 1),
+(35, 'connections history, days', 'Время хранения истории мест подключения ip-адресов', 'Storage time of the history of connection locations of ip addresses', 0, 1, 'int', '90', 1, 365),
+(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),
+(38, 'regenerate dhcp cconfig', 'Расположение скрипта управления конфигурацией dhcp-серверами', 'Location of the dhcp server configuration management script', 0, 1, 'text', '/opt/Eye/scripts/update-dnsmasq', 0, 0),
+(39, 'regenerate dns cconfig', 'Расположение скрипта управления dns-сервером', 'Location of the dns server management script', 0, 1, 'text', '/opt/Eye/scripts/update-dns', 0, 0),
+(40, 'regenerate nagios cconfig', 'Расположение скрипта конфигурирования Nagios', 'Location of the Nagios configuration script', 0, 1, 'text', '/etc/nagios/restart_nagios', 0, 0),
+(41, 'discovery network', 'Расположение скрипта сканирования сети', 'Location of the network scan script', 0, 1, 'text', '/opt/Eye/scripts/fetch_new_arp.pl', 0, 0),
+(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),
+(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),
+(46, 'update hostname from dhcp', 'Обновлять имя хоста в DNS при получении адреса по DHCP', 'Update the hostname in DNS when receiving the address via DHCP', 0, 1, 'bool', '0', 0, 1),
+(47, 'history worklog', 'Глубина хранения VERBOSE логов работы в интерфейсе администратора', 'Depth of work VERBOSE logs storage in the admin interface', 0, 1, 'int', '90', 0, 1095),
+(48, 'history syslog', 'Глубина хранения логов работы syslog-сервера', 'Syslog server logs storage depth', 0, 1, 'int', '90', 0, 1095),
+(49, 'history traffic stats', 'Глубина хранения статистики трафикаюзеров', 'User traffic statistics storage depth', 0, 1, 'int', '365', 0, 0),
+(50, 'urgent sync access', 'Немедленное изменение списков доступа на роутере после правки записи пользователя', 'Immediate change of access lists on the router after editing the user record', 0, 1, 'bool', '0', 0, 1),
+(51, 'Email_alert', 'Отправлять e-mail уведомления', 'Send e-mail notifications', 0, 1, 'bool', '1', 0, 1),
+(52, 'Sender email', 'E-mail адрес, с которого рассылается почта', 'E-mail address from which mail is sent', 0, 1, 'text', 'root', 0, 0),
+(53, 'log level', 'Каждый уровень включает в себя предыдущий:
+0- ERROR - писать только ошибки
+1 - WARNING - писать предупреждения
+2 - INFO - писать информационные сообщения
+3 - VERBOSE - писать подробную информацию о выполняемых операциях', 'Each level includes the previous one:
+0 - ERROR - write only errors
+1 - WARNING - write warnings
+2 - INFO - write informational
+3 - VERBOSE - write detailed information about the operations performed', 0, 1, 'int', '2', 0, 3),
+(54, 'enable_quotes', 'Включить обработку квот по трафику', 'Enable traffic quota processing', 0, 1, 'bool', '0', 0, 1),
+(55, 'netflow_step', 'Интервал сброса данных из коллектора netflow, минуты', 'Data reset interval from netflow collector, minutes', 0, 1, 'int', '1', 1, 10),
+(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),
+(57, 'nagios_url', 'Адрес сайта nagios', 'nagios site address', 0, 1, 'text', 'http://127.0.0.1/nagios', 0, 0),
+(58, 'cacti_url', 'Адрес сайта cacti', 'cacti site address', 0, 1, 'text', 'http://127.0.0.1/cacti', 0, 0),
+(59, 'torrus_url', 'Адрес сайта Torrus', 'Torrus website address', 0, 1, 'text', 'http://127.0.0.1/torrus/CollectorName/', 0, 0),
+(60, 'wiki_url', 'Адрес wiki', 'Wiki website address', 0, 1, 'text', 'http://127.0.0.1/wiki', 0, 0),
+(61, 'wiki_path', 'Путь к каталогу данных вики', 'Path to wiki data directory', 0, 1, 'text', '/var/www/foswiki/data/', 0, 0),
+(62, 'stat_url', 'Адрес этого сайта', 'Address of this site', 0, 1, 'text', 'http://127.0.0.1/stat', 0, 0),
+(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),
+(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),
+(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),
+(66, 'mikrotik_rest_api_ssl', 'Использовать https для rest api', 'Use HTTPS for rest api', 1, 1, 'bool', '1', 0, 1),
+(67, 'mikrotik_rest_api_port', 'Порт вэб-интерфейса для rest api', 'Web interface port for rest API', 1, 1, 'int', '443', 0, 0),
+(68, 'config_mode', 'Режим конфигурирования. Скрипт опроса устройств не выполняется.', 'Configuration mode. The device polling script is not running.', 0, 1, 'bool', '0', 0, 1),
+(69, 'clean_empty_user', 'Автоматически удалять записи пользователей, не содержащие ip-адресов или автоматических привязок', 'Automatically delete user records that do not contain IP addresses or automatic bindings', 0, 1, 'bool', '0', 0, 1),
+(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),
+(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),
+(72, 'netflow_path', 'Каталог для хранения данных, полученных по netflow от маршрутизаторов', 'The directory for storing data received via netflow from routers', 0, 1, 'text', '/opt/Eye/netflow', 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
+    option_name = EXCLUDED.option_name,
+    description_russian = EXCLUDED.description_russian,
+    description_english = EXCLUDED.description_english,
+    draft = EXCLUDED.draft,
+    uniq = EXCLUDED.uniq,
+    option_type = EXCLUDED.option_type,
+    default_value = EXCLUDED.default_value,
+    min_value = EXCLUDED.min_value,
+    max_value = EXCLUDED.max_value;
+
+-- System configuration values
+INSERT INTO config (id, option_id, value)
+VALUES
+(1, 1, '0'),
+(2, 11, 'public'),
+(3, 32, 'ORG'),
+(123, 19, '1'),
+(124, 35, '120'),
+(125, 9, '2'),
+(126, 41, '/opt/Eye/scripts/fetch_new_arp.pl'),
+(127, 26, '3'),
+(128, 27, '10'),
+(129, 48, '90'),
+(130, 49, '365'),
+(131, 47, '90'),
+(132, 53, '1'),
+(133, 55, '1'),
+(134, 56, '30'),
+(135, 34, '0'),
+(137, 65, '0'),
+(142, 54, ''),
+(143, 17, '1'),
+(144, 37, '/opt/Eye/scripts/sync_mikrotik.pl'),
+(145, 23, '1'),
+(148, 22, '1')
+ON CONFLICT (id) DO UPDATE SET
+    option_id = EXCLUDED.option_id,
+    value = EXCLUDED.value;
+
+-- System users/administrators
+INSERT INTO customers (id, Login, description, password, api_key, rights)
+VALUES (1, 'admin', 'Administrator', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31', 1)
+ON CONFLICT (id) DO UPDATE SET
+    Login = EXCLUDED.Login,
+    description = EXCLUDED.description,
+    password = EXCLUDED.password,
+    api_key = EXCLUDED.api_key,
+    rights = EXCLUDED.rights;
+
+-- Device models
+INSERT INTO device_models (id, model_name, vendor_id, poe_in, poe_out, nagios_template)
+VALUES
+(1, '2011LS', 9, 1, 0, NULL),
+(2, '2011UAS-2HnD', 9, 1, 0, NULL),
+(3, 'AT-8000S', 8, 0, 0, NULL),
+(4, 'AT-8100S/48POE', 8, 0, 0, NULL),
+(5, 'AT-9000/28', 8, 0, 0, NULL),
+(6, 'AT-GS950/24', 8, 0, 0, NULL),
+(7, 'CCR1009-7G-1C-1S+', 9, 0, 0, NULL),
+(8, 'CCR1036-8G-2S+', 9, 0, 0, NULL),
+(10, 'CRS317-1G-16S+', 9, 0, 0, NULL),
+(11, 'CRS326-24S+2Q+', 9, 0, 0, NULL),
+(12, 'CRS328-24P-4S+', 9, 1, 0, NULL),
+(14, 'CRS328-4C-20S-4S+', 9, 0, 0, NULL),
+(15, 'DGS-3120-48TC', 7, 0, 0, NULL),
+(16, 'ES-2024', 4, 0, 0, NULL),
+(17, 'ES-2024A', 4, 0, 0, NULL),
+(18, 'ES-2108', 4, 0, 0, NULL),
+(19, 'ES-2108-G', 4, 0, 0, NULL),
+(20, 'ES-3124-4F', 4, 0, 0, NULL),
+(21, 'GS110TP', 10, 0, 1, NULL),
+(22, 'GS-4024', 4, 0, 0, NULL),
+(23, 'HP 1910', 15, 0, 0, NULL),
+(24, 'ISCOM2110A-MA', 5, 0, 0, NULL),
+(25, 'ISCOM2110EA-MA', 5, 0, 0, NULL),
+(26, 'ISCOM2126EA-MA', 5, 0, 0, NULL),
+(27, 'ISCOM2128EA-MA', 5, 0, 0, NULL),
+(28, 'Linux server', 1, 0, 0, ''),
+(29, 'MES2124F', 2, 0, 0, NULL),
+(30, 'MES2124MB', 2, 0, 0, NULL),
+(31, 'MES5248', 2, 0, 0, NULL),
+(32, 'RB2011UAS', 9, 1, 0, NULL),
+(33, 'RB3011UiAS', 9, 1, 0, NULL),
+(34, 'RB960PGS', 9, 1, 1, NULL),
+(35, 'RBD52G-5HacD2HnD', 9, 1, 0, NULL),
+(36, 'S2940-8G-v2', 6, 0, 0, NULL),
+(37, 'S2980G-24T', 6, 0, 0, NULL),
+(38, 'S3750G-24S-E', 6, 0, 0, NULL),
+(39, 'S5300-52P-LI-AC', 3, 0, 0, NULL),
+(40, 'S5320-52X-PWR-SI-AC', 3, 0, 0, NULL),
+(41, 'S5321-28X-SI-AC', 3, 0, 0, NULL),
+(42, 'S5321-52X-SI-AC', 3, 0, 0, NULL),
+(43, 'S6320-54C-EI-48S-AC', 3, 0, 0, NULL),
+(44, 'SNR-S2980G-24T', 6, 0, 0, NULL),
+(45, 'V1910-16G', 15, 0, 0, NULL),
+(46, 'V1910-24G-PoE', 15, 0, 0, NULL),
+(47, 'Windows server', 1, 0, 0, NULL),
+(48, 'WS-C2960G-24TC-L', 16, 0, 0, NULL),
+(49, 'WS-C3560G-24TS-S', 16, 0, 0, NULL),
+(50, 'x210-16GT', 8, 0, 0, NULL),
+(51, 'x210-24GT', 8, 0, 0, NULL),
+(52, 'x610-24Ts/X', 8, 0, 0, NULL),
+(53, 'x610-48Ts', 8, 0, 0, NULL),
+(54, 'XGS-4728', 4, 0, 0, NULL),
+(55, 'ZyWall 310', 4, 0, 0, NULL),
+(56, 'APC Smart-UPS_3000', 20, 0, 0, 'ups.cfg'),
+(57, 'APC Smart-UPS_5000', 20, 0, 0, 'ups.cfg'),
+(58, 'Schneider Smart-UPS_3000', 21, 0, 0, NULL),
+(59, 'SMG-1016M', 2, 0, 0, NULL),
+(60, 'EATON 9PX 1500i RT 2U', 64, 0, 0, NULL),
+(61, 'EATON 9PX3000i_RT_2U', 64, 0, 0, NULL),
+(62, 'EATON 9PX_6000i', 64, 0, 0, NULL),
+(63, 'EATON PW9130_3000', 64, 0, 0, NULL),
+(64, 'EATON PW9130_3000VA-R', 64, 0, 0, NULL),
+(65, 'Epson WF-5620 Series', 59, 0, 0, NULL),
+(66, 'Epson WF-8590 Series', 59, 0, 0, NULL),
+(67, 'HP Officejet-7000', 15, 0, 0, 'hp.cfg'),
+(68, 'OKI C610', 62, 0, 0, NULL),
+(69, 'OKI MB472', 62, 0, 0, NULL),
+(70, 'OKI MB491', 62, 0, 0, NULL),
+(71, 'OKI MC562', 62, 0, 0, NULL),
+(72, 'OKI MC573', 62, 0, 0, NULL),
+(73, 'OKI MC861', 62, 0, 0, NULL),
+(74, 'Panasonic KX-MB2000RU', 61, 0, 0, NULL),
+(75, 'PT-MZ10KE', 61, 0, 0, NULL),
+(76, 'PT-VX41', 61, 0, 0, NULL),
+(77, 'Rave 522AA', 33, 0, 0, NULL),
+(78, 'DZ570E', 61, 0, 0, NULL),
+(79, 'DZ6700', 61, 0, 0, NULL),
+(80, 'Rcq80', 61, 0, 0, NULL),
+(81, 'RZ12K', 61, 0, 0, NULL),
+(82, 'RZ660', 61, 0, 0, NULL),
+(83, 'RZ770', 61, 0, 0, NULL),
+(84, 'RZ970', 61, 0, 0, NULL),
+(85, 'XVR-5216', 66, 0, 0, NULL),
+(86, 'HWg-STE', 68, 0, 0, NULL),
+(87, 'Computer', 1, 0, 0, ''),
+(88, 'Mobile Phone', 1, 0, 0, NULL),
+(89, 'Switch', 1, 0, 0, NULL),
+(90, 'Projectiondesign F22', 34, 0, 0, NULL),
+(91, 'DS-I252', 36, 0, 0, NULL),
+(92, 'LTV-CNE-720-48', 37, 0, 0, NULL),
+(93, 'U-100', 38, 0, 0, NULL),
+(94, 'TAU-8', 2, 0, 0, NULL),
+(95, 'SIP-T21P E2', 39, 0, 0, NULL),
+(96, 'A510 IP', 40, 0, 0, NULL),
+(97, 'W60B', 39, 0, 0, NULL),
+(98, 'TAU-2M', 2, 0, 0, NULL),
+(99, 'PAP2T', 41, 0, 0, NULL),
+(100, 'VP-12', 2, 0, 0, NULL),
+(101, 'SIP-T23P', 39, 0, 0, NULL),
+(102, 'SPA-2102', 16, 0, 0, NULL),
+(103, 'RB760iGS', 9, 1, 0, NULL),
+(104, 'MES2324B', 2, 0, 0, NULL),
+(105, 'MES2324FB', 2, 0, 0, NULL),
+(106, 'MES2124P', 2, 0, 1, NULL),
+(107, 'MES2428P', 2, 0, 1, NULL),
+(108, 'Symmetra LX 16000', 20, 0, 0, 'symmetra.cfg'),
+(109, 'SNR-UPS-ONT20', 6, 0, 0, 'ups3.cfg'),
+(110, 'MES-3728', 4, 0, 0, NULL),
+(111, 'SNR-S5210G-24TX-UPS-R', 6, 0, 0, NULL),
+(112, 'SNR-S2985G-24TC', 6, 0, 0, NULL),
+(113, 'MES-5248', 2, 0, 0, NULL),
+(114, 'SNR-S5210G-24TX-POE', 6, 0, 1, NULL),
+(115, 'SNR-S5210G-24TX-UPS', 6, 0, 0, NULL),
+(116, 'SNR-S5210X-8F-UPS', 6, 0, 0, NULL),
+(117, 'SNR-S2982G-8T-UPS', 6, 0, 0, NULL)
+ON CONFLICT (id) DO UPDATE SET
+    model_name = EXCLUDED.model_name,
+    vendor_id = EXCLUDED.vendor_id,
+    poe_in = EXCLUDED.poe_in,
+    poe_out = EXCLUDED.poe_out,
+    nagios_template = EXCLUDED.nagios_template;
+
+-- Device types
+INSERT INTO device_types (id, name_russian, name_english)
+VALUES
+(0, 'Роутер', 'Router'),
+(1, 'Свич', 'Switch'),
+(2, 'Шлюз', 'Gateway'),
+(3, 'Сервер', 'Server'),
+(4, 'Точка доступа', 'WiFi Access Point'),
+(5, 'Сетевое устройство', 'Network device')
+ON CONFLICT (id) DO UPDATE SET
+    name_russian = EXCLUDED.name_russian,
+    name_english = EXCLUDED.name_english;
+
+-- Filter instances
+INSERT INTO filter_instances (id, name, description)
+VALUES (1, 'default', NULL)
+ON CONFLICT (id) DO UPDATE SET
+    name = EXCLUDED.name,
+    description = EXCLUDED.description;
+
+-- Filter groups
+INSERT INTO group_list (id, instance_id, group_name, description)
+VALUES
+(0, 1, 'default', 'Forbidden all'),
+(1, 1, 'Allow all', 'Allowed all'),
+(2, 1, 'Users', 'For users')
+ON CONFLICT (id) DO UPDATE SET
+    instance_id = EXCLUDED.instance_id,
+    group_name = EXCLUDED.group_name,
+    description = EXCLUDED.description;
+
+-- Organizational Units
+INSERT INTO ou (id, ou_name, description, 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),
+(1, 'Servers', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 0, 0, 24.00, NULL),
+(2, 'Administrators', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(3, 'Users', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(4, 'VOIP', NULL, 0, 0, 'voip', 'voip', 1, NULL, 1, 4, 5, 0, 24.00, NULL),
+(5, 'IPCAM', NULL, 0, 0, 'videocam', 'ip-cam', 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(6, 'Printers', NULL, 0, 0, 'printers', 'printers', 1, 'printer-service', 0, 0, 0, 0, 24.00, NULL),
+(7, 'Switches', NULL, 0, 0, 'switches', 'switches', 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(8, 'UPS', NULL, 0, 0, 'ups', 'ups', 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(9, 'Security', NULL, 0, 0, 'security', 'security', 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(10, 'Routers', NULL, 0, 0, 'routers', 'routers', 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(11, 'WiFi AP', NULL, 0, 0, 'ap', 'ap', 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(12, 'DHCP', NULL, 1, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(13, 'Guests', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4, 1, 24.00, NULL)
+ON CONFLICT (id) DO UPDATE SET
+    ou_name = EXCLUDED.ou_name,
+    description = EXCLUDED.description,
+    default_users = EXCLUDED.default_users,
+    default_hotspot = EXCLUDED.default_hotspot,
+    nagios_dir = EXCLUDED.nagios_dir,
+    nagios_host_use = EXCLUDED.nagios_host_use,
+    nagios_ping = EXCLUDED.nagios_ping,
+    nagios_default_service = EXCLUDED.nagios_default_service,
+    enabled = EXCLUDED.enabled,
+    filter_group_id = EXCLUDED.filter_group_id,
+    queue_id = EXCLUDED.queue_id,
+    dynamic = EXCLUDED.dynamic,
+    life_duration = EXCLUDED.life_duration,
+    parent_id = EXCLUDED.parent_id;
+
+-- Traffic shaping queues
+INSERT INTO queue_list (id, queue_name, download, upload)
+VALUES
+(0, 'unlimited', 0, 0),
+(1, '2M/2M', 2048, 2048),
+(2, '10M/10M', 10240, 10240),
+(3, '100M/100M', 102400, 102400),
+(4, '50M/50M', 50000, 50000),
+(5, '20M/20M', 20480, 20480),
+(6, '200M/200M', 212400, 212400),
+(7, '1G/1G', 1024000, 1024000),
+(8, '2G/2G', 2048000, 2048000)
+ON CONFLICT (id) DO UPDATE SET
+    queue_name = EXCLUDED.queue_name,
+    download = EXCLUDED.download,
+    upload = EXCLUDED.upload;
+
+-- Network subnets
+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, description)
+VALUES (1, '192.168.2.0/24', 2, 3232236032, 3232236287, 3232236132, 3232236182, 480, 3232236033, 1, 0, 0, 0, 1, 0, 1, 1, 7, 'LAN')
+ON CONFLICT (id) DO UPDATE SET
+    subnet = EXCLUDED.subnet,
+    vlan_tag = EXCLUDED.vlan_tag,
+    ip_int_start = EXCLUDED.ip_int_start,
+    ip_int_stop = EXCLUDED.ip_int_stop,
+    dhcp_start = EXCLUDED.dhcp_start,
+    dhcp_stop = EXCLUDED.dhcp_stop,
+    dhcp_lease_time = EXCLUDED.dhcp_lease_time,
+    gateway = EXCLUDED.gateway,
+    office = EXCLUDED.office,
+    hotspot = EXCLUDED.hotspot,
+    vpn = EXCLUDED.vpn,
+    free = EXCLUDED.free,
+    dhcp = EXCLUDED.dhcp,
+    static = EXCLUDED.static,
+    dhcp_update_hostname = EXCLUDED.dhcp_update_hostname,
+    discovery = EXCLUDED.discovery,
+    notify = EXCLUDED.notify,
+    description = EXCLUDED.description;
+
+-- Device vendors
+INSERT INTO vendors (id, name)
+VALUES
+(1, 'Unknown'),
+(2, 'Eltex'),
+(3, 'Huawei'),
+(4, 'Zyxel'),
+(5, 'Raisecom'),
+(6, 'SNR'),
+(7, 'Dlink'),
+(8, 'Allied Telesis'),
+(9, 'Mikrotik'),
+(10, 'NetGear'),
+(11, 'Ubiquiti'),
+(15, 'HP'),
+(16, 'Cisco'),
+(17, 'Maipu'),
+(18, 'Asus'),
+(19, 'Linux'),
+(20, 'APC'),
+(21, 'Schneider'),
+(33, 'QSC'),
+(34, 'Projectiondesign'),
+(35, 'Lenovo'),
+(36, 'HiWatch'),
+(37, 'LTV'),
+(38, 'Yeastar'),
+(39, 'Yealink'),
+(40, 'Gigaset'),
+(41, 'Linksys'),
+(42, 'Samsung'),
+(43, 'Supermicro'),
+(44, 'RDP'),
+(45, 'SANYO'),
+(46, 'Extreme'),
+(47, 'Intel'),
+(48, 'Micron'),
+(49, 'Gigabyte'),
+(50, 'Acer'),
+(51, 'Seagate'),
+(52, 'SanDisk'),
+(53, 'Toshiba'),
+(54, 'Kingston'),
+(55, 'AddPac'),
+(56, 'Devline'),
+(57, 'Canon'),
+(58, 'Brother'),
+(59, 'Epson'),
+(60, 'IP-COM'),
+(61, 'Panasonic'),
+(62, 'OKI'),
+(63, 'Apple'),
+(64, 'Eaton'),
+(65, 'Barco'),
+(66, 'Trassir'),
+(67, 'Testo'),
+(68, 'Hw-group'),
+(69, 'Tp-link')
+ON CONFLICT (id) DO UPDATE SET
+    name = EXCLUDED.name;
+
+-- Filter rules list
+INSERT INTO filter_list (id, name, description, proto, dst, dstport, srcport, filter_type)
+VALUES
+(1, 'pop3', NULL, 'tcp', '0/0', '110', NULL, 0),
+(3, 'http', NULL, 'tcp', '0/0', '80', NULL, 0),
+(4, 'https', NULL, 'tcp', '0/0', '443', NULL, 0),
+(5, 'icq', NULL, 'tcp', '0/0', '5190', NULL, 0),
+(6, 'jabber', NULL, 'tcp', '0/0', '5222', NULL, 0),
+(9, 'allow_all', 'any', 'all', '0/0', '0', '0', 0),
+(10, 'icmp', NULL, 'icmp', '0/0', '0', NULL, 0),
+(11, 'ftp', NULL, 'tcp', '0/0', '20-21', NULL, 0),
+(15, 'telnet', NULL, 'tcp', '0/0', '23', NULL, 0),
+(16, 'ssh', NULL, 'tcp', '0/0', '22', NULL, 0),
+(28, 'smtp', NULL, 'tcp', '0/0', '25', NULL, 0),
+(32, 'rdp', NULL, 'tcp', '0/0', '3389', NULL, 0),
+(40, 'ntp', NULL, 'udp', '0/0', '123', NULL, 0),
+(44, 'vnc', NULL, 'tcp', '0/0', '5800-5900', NULL, 0),
+(55, 'unprivileged tcp', NULL, 'tcp', '0/0', '1024-65500', NULL, 0),
+(76, 'ipsec', NULL, 'udp', '0/0', '500', NULL, 0),
+(77, 'isakmp', NULL, 'udp', '0/0', '4500', NULL, 0),
+(79, 'pop3s', NULL, 'tcp', '0/0', '995', NULL, 0),
+(80, 'smtps', NULL, 'tcp', '0/0', '465,587', NULL, 0),
+(81, 'imap', NULL, 'tcp', '0/0', '143', NULL, 0),
+(82, 'imaps', NULL, 'tcp', '0/0', '993', NULL, 0),
+(83, 'unprivileged udp', NULL, 'udp', '0/0', '1024-65000', NULL, 0),
+(84, 'pptp', NULL, 'tcp', '0/0', '1723', NULL, 0),
+(85, 'openvpn-udp', NULL, 'udp', '0/0', '1194', NULL, 0),
+(90, 'dns_udp', NULL, 'udp', '0/0', '53', NULL, 0),
+(91, 'dns_tcp', NULL, 'tcp', '0/0', '53', NULL, 0),
+(94, 'squid', NULL, 'tcp', '0/0', '3128', NULL, 0),
+(101, 'snmp', NULL, 'udp', '0/0', '161', NULL, 0),
+(105, 'http_udp', NULL, 'udp', '0/0', '80', NULL, 0),
+(106, 'https_udp', NULL, 'udp', '0/0', '443', NULL, 0),
+(107, 'l2tp-ipsec', NULL, 'udp', '0/0', '1701,4500,500', NULL, 0),
+(108, 'gre', NULL, 'gre', '0/0', NULL, NULL, 0)
+ON CONFLICT (id) DO UPDATE SET
+    name = EXCLUDED.name,
+    description = EXCLUDED.description,
+    proto = EXCLUDED.proto,
+    dst = EXCLUDED.dst,
+    dstport = EXCLUDED.dstport,
+    srcport = EXCLUDED.srcport,
+    filter_type = EXCLUDED.filter_type;
+
+-- Filter group assignments
+INSERT INTO group_filters (id, group_id, filter_id, rule_order, action)
+VALUES
+(1, 2, 90, 1, 1),
+(2, 2, 91, 2, 1),
+(3, 2, 11, 3, 1),
+(5, 2, 3, 4, 1),
+(6, 2, 105, 5, 1),
+(7, 2, 4, 6, 1),
+(8, 2, 106, 7, 1),
+(9, 2, 10, 8, 1),
+(10, 2, 81, 9, 1),
+(11, 2, 82, 10, 1),
+(15, 2, 40, 11, 1),
+(16, 2, 1, 12, 1),
+(17, 2, 79, 13, 1),
+(18, 2, 80, 14, 1),
+(19, 1, 9, 1, 1)
+ON CONFLICT (id) DO UPDATE SET
+    group_id = EXCLUDED.group_id,
+    filter_id = EXCLUDED.filter_id,
+    "order" = EXCLUDED."order",
+    action = EXCLUDED.action;
+
+-- System version
+INSERT INTO version (id, version)
+VALUES (1, '3.0.1')
+ON CONFLICT (id) DO UPDATE SET
+    version = EXCLUDED.version;
+
+-- Обновление последовательностей после импорта данных
+SELECT setval(pg_get_serial_sequence('acl', 'id'), COALESCE((SELECT MAX(id) FROM acl), 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', '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('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('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('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('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('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 $$
+BEGIN
+    RAISE NOTICE 'Импорт данных завершен успешно!';
+    RAISE NOTICE 'Всего импортировано таблиц: 16';
+    RAISE NOTICE 'Всего импортировано записей:';
+    RAISE NOTICE '  - acl: %', (SELECT COUNT(*) FROM acl);
+    RAISE NOTICE '  - building: %', (SELECT COUNT(*) FROM building);
+    RAISE NOTICE '  - config_options: %', (SELECT COUNT(*) FROM config_options);
+    RAISE NOTICE '  - config: %', (SELECT COUNT(*) FROM config);
+    RAISE NOTICE '  - customers: %', (SELECT COUNT(*) FROM customers);
+    RAISE NOTICE '  - device_models: %', (SELECT COUNT(*) FROM device_models);
+    RAISE NOTICE '  - device_types: %', (SELECT COUNT(*) FROM device_types);
+    RAISE NOTICE '  - filter_instances: %', (SELECT COUNT(*) FROM filter_instances);
+    RAISE NOTICE '  - group_list: %', (SELECT COUNT(*) FROM group_list);
+    RAISE NOTICE '  - ou: %', (SELECT COUNT(*) FROM ou);
+    RAISE NOTICE '  - queue_list: %', (SELECT COUNT(*) FROM queue_list);
+    RAISE NOTICE '  - subnets: %', (SELECT COUNT(*) FROM subnets);
+    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 '  - version: %', (SELECT COUNT(*) FROM version);
+END $$;

+ 7 - 0
docs/databases/postgres/reset_admin.sql

@@ -0,0 +1,7 @@
+-- default user: admin
+-- default password: admin
+INSERT INTO "customers" ("id", "Login", "password", "api_key", "rights")
+VALUES (1, 'admin', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31', '1')
+ON CONFLICT ("id") DO UPDATE
+SET "Login" = EXCLUDED."Login",
+    "password" = EXCLUDED."password";

+ 678 - 0
docs/databases/postgres/ru/create_db.sql

@@ -0,0 +1,678 @@
+-- Включаем необходимые расширения
+CREATE EXTENSION IF NOT EXISTS pg_trgm;
+CREATE EXTENSION IF NOT EXISTS btree_gin;
+
+-- Access Control List
+CREATE TABLE acl (
+id SERIAL PRIMARY KEY,
+name VARCHAR(30) NOT NULL,
+description_english VARCHAR(250) NOT NULL,
+description_russian VARCHAR(250) NOT NULL
+);
+COMMENT ON TABLE acl IS 'Список контроля доступа - роли и разрешения';
+COMMENT ON COLUMN acl.description_english IS 'Описание на английском языке';
+COMMENT ON COLUMN acl.description_russian IS 'Описание на русском языке';
+
+-- Кэш компьютеров из Active Directory
+CREATE TABLE ad_comp_cache (
+id SERIAL PRIMARY KEY,
+name VARCHAR(63) NOT NULL UNIQUE,
+last_found TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+COMMENT ON TABLE ad_comp_cache IS 'Кэш компьютеров из Active Directory';
+COMMENT ON COLUMN ad_comp_cache.name IS 'Имя компьютера в AD';
+COMMENT ON COLUMN ad_comp_cache.last_found IS 'Время последнего обнаружения этого компьютера';
+
+-- Правила аутентификации
+CREATE TABLE auth_rules (
+id SERIAL PRIMARY KEY,
+user_id INTEGER,
+ou_id INTEGER,
+rule_type SMALLINT NOT NULL,
+rule VARCHAR(40) UNIQUE,
+description VARCHAR(250)
+);
+COMMENT ON TABLE auth_rules IS 'Правила аутентификации и авторизации пользователей';
+COMMENT ON COLUMN auth_rules.rule_type IS 'Тип правила: 0=разрешить, 1=запретить, и т.д.';
+COMMENT ON COLUMN auth_rules.rule IS 'Идентификатор правила (уникальный)';
+
+-- Здания
+CREATE TABLE building (
+id SERIAL PRIMARY KEY,
+name VARCHAR(50) NOT NULL,
+description VARCHAR(250)
+);
+COMMENT ON TABLE building IS 'Физические здания/локации';
+COMMENT ON COLUMN building.name IS 'Название здания';
+
+-- Системная конфигурация
+CREATE TABLE config (
+id SERIAL PRIMARY KEY,
+option_id INTEGER,
+value VARCHAR(250)
+);
+COMMENT ON TABLE config IS 'Значения системной конфигурации';
+
+-- Опции конфигурации
+CREATE TABLE config_options (
+id SERIAL PRIMARY KEY,
+option_name VARCHAR(50) NOT NULL,
+description_russian TEXT,
+description_english TEXT,
+draft SMALLINT NOT NULL DEFAULT 0,
+uniq SMALLINT NOT NULL DEFAULT 1,
+option_type VARCHAR(100) NOT NULL,
+default_value VARCHAR(250),
+min_value INTEGER NOT NULL DEFAULT 0,
+max_value INTEGER NOT NULL DEFAULT 0
+);
+COMMENT ON TABLE config_options IS 'Доступные опции конфигурации';
+COMMENT ON COLUMN config_options.option_name IS 'Имя/ключ опции';
+COMMENT ON COLUMN config_options.draft IS 'Опция в черновом состоянии';
+COMMENT ON COLUMN config_options.uniq IS 'Опция уникальна (единственное значение)';
+
+-- Сетевые соединения
+CREATE TABLE connections (
+id BIGSERIAL PRIMARY KEY,
+device_id BIGINT NOT NULL,
+port_id BIGINT NOT NULL,
+auth_id BIGINT NOT NULL,
+last_found TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+COMMENT ON TABLE connections IS 'Текущие сетевые соединения (MAC-IP-устройство-порт)';
+COMMENT ON COLUMN connections.device_id IS 'ID сетевого устройства';
+COMMENT ON COLUMN connections.port_id IS 'ID порта устройства';
+COMMENT ON COLUMN connections.auth_id IS 'ID авторизации пользователя';
+COMMENT ON COLUMN connections.last_found IS 'Время последней активности соединения';
+
+-- Пользователи системы
+CREATE TABLE customers (
+id SERIAL PRIMARY KEY,
+login VARCHAR(20),
+description VARCHAR(100),
+password VARCHAR(255),
+api_key VARCHAR(255),
+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=суперадмин';
+
+-- Сетевые устройства
+CREATE TABLE devices (
+id SERIAL PRIMARY KEY,
+device_type INTEGER NOT NULL DEFAULT 1,
+device_model_id INTEGER DEFAULT 89,
+firmware VARCHAR(100),
+vendor_id INTEGER NOT NULL DEFAULT 1,
+device_name VARCHAR(50),
+building_id INTEGER NOT NULL DEFAULT 1,
+ip INET DEFAULT NULL,
+ip_int BIGINT,
+login VARCHAR(50),
+password VARCHAR(255),
+protocol SMALLINT NOT NULL DEFAULT 0,
+control_port INTEGER NOT NULL DEFAULT 23,
+port_count INTEGER NOT NULL DEFAULT 0,
+sn VARCHAR(80),
+description VARCHAR(255),
+snmp_version SMALLINT NOT NULL DEFAULT 0,
+snmp3_auth_proto VARCHAR(10) NOT NULL DEFAULT 'sha512',
+snmp3_priv_proto VARCHAR(10) NOT NULL DEFAULT 'aes128',
+snmp3_user_rw VARCHAR(20),
+snmp3_user_rw_password VARCHAR(20),
+snmp3_user_ro VARCHAR(20),
+snmp3_user_ro_password VARCHAR(20),
+community VARCHAR(50) NOT NULL DEFAULT 'public',
+rw_community VARCHAR(50) NOT NULL DEFAULT 'private',
+fdb_snmp_index SMALLINT NOT NULL DEFAULT 0,
+discovery SMALLINT NOT NULL DEFAULT 1,
+netflow_save SMALLINT NOT NULL DEFAULT 0,
+user_acl SMALLINT NOT NULL DEFAULT 0,
+dhcp SMALLINT NOT NULL DEFAULT 0,
+nagios SMALLINT NOT NULL DEFAULT 0,
+active SMALLINT NOT NULL DEFAULT 1,
+nagios_status VARCHAR(10) NOT NULL DEFAULT 'UP',
+queue_enabled SMALLINT NOT NULL DEFAULT 0,
+connected_user_only SMALLINT NOT NULL DEFAULT 1,
+user_id INTEGER,
+deleted SMALLINT NOT NULL DEFAULT 0,
+discovery_locked SMALLINT NOT NULL DEFAULT 0,
+locked_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+COMMENT ON TABLE devices IS 'Сетевые устройства (коммутаторы, маршрутизаторы и т.д.)';
+COMMENT ON COLUMN devices.device_type IS 'ID типа устройства';
+COMMENT ON COLUMN devices.ip IS 'IP-адрес управления устройством';
+COMMENT ON COLUMN devices.snmp_version IS 'Версия SNMP: 0=отключено, 1=v1, 2=v2c, 3=v3';
+COMMENT ON COLUMN devices.discovery IS 'Включить автоматическое обнаружение';
+COMMENT ON COLUMN devices.active IS 'Устройство активно и мониторится';
+
+-- Экземпляры фильтров устройств
+CREATE TABLE device_filter_instances (
+id SERIAL PRIMARY KEY,
+instance_id INTEGER,
+device_id INTEGER
+);
+COMMENT ON TABLE device_filter_instances IS 'Экземпляры фильтров, назначенные устройствам';
+
+-- L3 интерфейсы устройств
+CREATE TABLE device_l3_interfaces (
+id SERIAL PRIMARY KEY,
+device_id INTEGER,
+snmpin INTEGER,
+interface_type SMALLINT NOT NULL DEFAULT 0,
+name VARCHAR(100)
+);
+COMMENT ON TABLE device_l3_interfaces IS 'Интерфейсы 3 уровня на устройствах';
+COMMENT ON COLUMN device_l3_interfaces.interface_type IS 'Тип интерфейса: 0=неизвестно, 1=LAN, 2=WAN, 3=DMZ';
+
+-- Модели устройств
+CREATE TABLE device_models (
+id SERIAL PRIMARY KEY,
+model_name VARCHAR(200),
+vendor_id INTEGER DEFAULT 1,
+poe_in SMALLINT NOT NULL DEFAULT 0,
+poe_out SMALLINT NOT NULL DEFAULT 0,
+nagios_template VARCHAR(200)
+);
+COMMENT ON TABLE device_models IS 'Модели устройств и их характеристики';
+COMMENT ON COLUMN device_models.poe_in IS 'Поддерживает питание по Ethernet на входе';
+COMMENT ON COLUMN device_models.poe_out IS 'Обеспечивает питание по Ethernet';
+
+-- Порты устройств
+CREATE TABLE device_ports (
+id BIGSERIAL PRIMARY KEY,
+device_id INTEGER,
+snmp_index INTEGER,
+port INTEGER,
+ifname VARCHAR(40),
+port_name VARCHAR(40),
+description VARCHAR(50),
+target_port_id INTEGER NOT NULL DEFAULT 0,
+auth_id BIGINT,
+last_mac_count INTEGER DEFAULT 0,
+uplink SMALLINT NOT NULL DEFAULT 0,
+nagios SMALLINT NOT NULL DEFAULT 0,
+skip SMALLINT NOT NULL DEFAULT 0,
+vlan INTEGER NOT NULL DEFAULT 1,
+tagged_vlan VARCHAR(250),
+untagged_vlan VARCHAR(250),
+forbidden_vlan VARCHAR(250)
+);
+COMMENT ON TABLE device_ports IS 'Порты/интерфейсы сетевых устройств';
+COMMENT ON COLUMN device_ports.port IS 'Номер физического порта';
+COMMENT ON COLUMN device_ports.uplink IS 'Это аплинк-порт';
+COMMENT ON COLUMN device_ports.vlan IS 'VLAN по умолчанию/нативный VLAN';
+
+-- Типы устройств
+CREATE TABLE device_types (
+id SERIAL PRIMARY KEY,
+name_russian VARCHAR(50),
+name_english VARCHAR(50)
+);
+COMMENT ON TABLE device_types IS 'Классификация типов устройств';
+COMMENT ON COLUMN device_types.name_russian IS 'Название типа устройства на русском';
+COMMENT ON COLUMN device_types.name_english IS 'Название типа устройства на английском';
+
+-- Логи DHCP
+CREATE TABLE dhcp_log (
+id BIGSERIAL PRIMARY KEY,
+mac MACADDR NOT NULL,
+ip_int BIGINT NOT NULL,
+ip INET DEFAULT NULL,
+action VARCHAR(10) NOT NULL,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+auth_id BIGINT NOT NULL,
+dhcp_hostname VARCHAR(250),
+circuit_id VARCHAR(255),
+remote_id VARCHAR(255),
+client_id VARCHAR(250)
+);
+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.circuit_id IS 'DHCP опция 82 circuit ID';
+
+-- Очередь DHCP
+CREATE TABLE dhcp_queue (
+id BIGSERIAL PRIMARY KEY,
+mac MACADDR NOT NULL,
+ip INET DEFAULT NULL,
+action VARCHAR(10) NOT NULL,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+dhcp_hostname VARCHAR(250)
+);
+COMMENT ON TABLE dhcp_queue IS 'Очередь отложенных операций DHCP';
+
+-- DNS кэш
+CREATE TABLE dns_cache (
+id BIGSERIAL PRIMARY KEY,
+dns VARCHAR(250),
+ip BIGINT,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+COMMENT ON TABLE dns_cache IS 'Кэш DNS разрешений';
+
+-- Очередь DNS
+CREATE TABLE dns_queue (
+id SERIAL PRIMARY KEY,
+auth_id INTEGER,
+name_type VARCHAR(10) NOT NULL DEFAULT 'A',
+name VARCHAR(200),
+operation_type VARCHAR(10) NOT NULL DEFAULT 'add',
+value VARCHAR(100)
+);
+COMMENT ON TABLE dns_queue IS 'Очередь отложенных операций DNS';
+COMMENT ON COLUMN dns_queue.name_type IS 'Тип DNS записи: A, AAAA, PTR, CNAME';
+COMMENT ON COLUMN dns_queue.operation_type IS 'Тип операции: add, delete, update';
+
+-- Экземпляры фильтров
+CREATE TABLE filter_instances (
+id SERIAL PRIMARY KEY,
+name VARCHAR(50) UNIQUE,
+description VARCHAR(200)
+);
+COMMENT ON TABLE filter_instances IS 'Экземпляры политик фильтрации';
+
+-- Список правил фильтрации
+CREATE TABLE filter_list (
+id SERIAL PRIMARY KEY,
+name VARCHAR(50),
+description VARCHAR(250),
+proto VARCHAR(10),
+dst TEXT,
+dstport VARCHAR(20),
+srcport VARCHAR(20),
+filter_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.filter_type IS 'Тип правила: 0=разрешить, 1=запретить';
+
+-- Шлюзы подсетей
+CREATE TABLE gateway_subnets (
+id SERIAL PRIMARY KEY,
+device_id INTEGER,
+subnet_id INTEGER
+);
+COMMENT ON TABLE gateway_subnets IS 'Какие устройства являются шлюзами для каких подсетей';
+
+-- Назначения фильтров группам
+CREATE TABLE group_filters (
+id SERIAL PRIMARY KEY,
+group_id INTEGER NOT NULL DEFAULT 0,
+filter_id INTEGER NOT NULL DEFAULT 0,
+rule_order INTEGER NOT NULL DEFAULT 0,
+action SMALLINT NOT NULL DEFAULT 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 (
+id SERIAL PRIMARY KEY,
+instance_id INTEGER NOT NULL DEFAULT 1,
+group_name VARCHAR(50),
+description VARCHAR(250)
+);
+COMMENT ON TABLE group_list IS 'Группы политик фильтрации';
+
+-- История MAC-адресов
+CREATE TABLE mac_history (
+id BIGSERIAL PRIMARY KEY,
+mac MACADDR NOT NULL,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+device_id BIGINT,
+port_id BIGINT,
+ip INET DEFAULT NULL,
+auth_id BIGINT,
+dhcp_hostname VARCHAR(250)
+);
+COMMENT ON TABLE mac_history IS 'История перемещений MAC-адресов';
+COMMENT ON COLUMN mac_history.mac IS 'MAC-адрес';
+COMMENT ON COLUMN mac_history.ip IS 'Последний использованный IP-адрес';
+
+-- Производители MAC-адресов
+CREATE TABLE mac_vendors (
+id SERIAL PRIMARY KEY,
+oui VARCHAR(20),
+companyname VARCHAR(255),
+companyaddress VARCHAR(255)
+);
+COMMENT ON TABLE mac_vendors IS 'База данных производителей по MAC-адресам';
+COMMENT ON COLUMN mac_vendors.oui IS 'Organizationally Unique Identifier (первые 6 символов MAC)';
+
+-- Организационные единицы
+CREATE TABLE ou (
+id SERIAL PRIMARY KEY,
+ou_name VARCHAR(40),
+description VARCHAR(250),
+default_users SMALLINT NOT NULL DEFAULT 0,
+default_hotspot SMALLINT NOT NULL DEFAULT 0,
+nagios_dir VARCHAR(255),
+nagios_host_use VARCHAR(50),
+nagios_ping SMALLINT NOT NULL DEFAULT 1,
+nagios_default_service VARCHAR(100),
+enabled SMALLINT NOT NULL DEFAULT 0,
+filter_group_id INTEGER NOT NULL DEFAULT 0,
+queue_id INTEGER NOT NULL DEFAULT 0,
+dynamic SMALLINT NOT NULL DEFAULT 0,
+life_duration DECIMAL(10,2) NOT NULL DEFAULT 24.00,
+parent_id INTEGER
+);
+COMMENT ON TABLE OU IS 'Организационные единицы (отделы/группы)';
+COMMENT ON COLUMN ou.ou_name IS 'Имя/идентификатор ou';
+COMMENT ON COLUMN ou.life_duration IS 'Время жизни по умолчанию в часах для динамических записей';
+
+-- Очереди шейпинга трафика
+CREATE TABLE queue_list (
+id SERIAL PRIMARY KEY,
+queue_name VARCHAR(20) NOT NULL,
+download 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 'Ограничение скорости отдачи в Кбит/с';
+
+-- Удаленные syslog сообщения
+CREATE TABLE remote_syslog (
+id BIGSERIAL PRIMARY KEY,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+device_id BIGINT NOT NULL,
+ip INET DEFAULT NULL,
+message TEXT NOT NULL
+);
+COMMENT ON TABLE remote_syslog IS 'Syslog сообщения от сетевых устройств';
+
+-- PHP сессии
+CREATE TABLE sessions (
+id VARCHAR(128) PRIMARY KEY,
+data TEXT NOT NULL,
+last_accessed INTEGER NOT NULL
+);
+COMMENT ON TABLE sessions IS 'Хранилище PHP сессий';
+
+-- Сетевые подсети
+CREATE TABLE subnets (
+id SERIAL PRIMARY KEY,
+subnet VARCHAR(18),
+vlan_tag INTEGER NOT NULL DEFAULT 1,
+ip_int_start BIGINT NOT NULL,
+ip_int_stop BIGINT NOT NULL,
+dhcp_start BIGINT NOT NULL DEFAULT 0,
+dhcp_stop BIGINT NOT NULL DEFAULT 0,
+dhcp_lease_time INTEGER NOT NULL DEFAULT 480,
+gateway BIGINT NOT NULL DEFAULT 0,
+office SMALLINT NOT NULL DEFAULT 1,
+hotspot SMALLINT NOT NULL DEFAULT 0,
+vpn SMALLINT NOT NULL DEFAULT 0,
+free SMALLINT NOT NULL DEFAULT 0,
+dhcp SMALLINT NOT NULL DEFAULT 1,
+static SMALLINT NOT NULL DEFAULT 0,
+dhcp_update_hostname SMALLINT NOT NULL DEFAULT 0,
+discovery SMALLINT NOT NULL DEFAULT 1,
+notify SMALLINT NOT NULL DEFAULT 7,
+description VARCHAR(250)
+);
+COMMENT ON TABLE subnets IS 'Конфигурация сетевых подсетей';
+COMMENT ON COLUMN subnets.subnet IS 'Сеть в нотации CIDR';
+COMMENT ON COLUMN subnets.vlan_tag IS 'ID VLAN для этой подсети';
+COMMENT ON COLUMN subnets.office IS 'Это офисная подсеть';
+COMMENT ON COLUMN subnets.hotspot IS 'Это публичная/гостевая подсеть';
+COMMENT ON COLUMN subnets.notify IS 'Битовая маска для уведомлений по типу событий';
+
+-- Подробные логи трафика
+CREATE TABLE traffic_detail (
+id BIGSERIAL PRIMARY KEY,
+auth_id   bigint,
+router_id integer NOT NULL DEFAULT 0,
+ts TIMESTAMP,
+proto     smallint,
+src_ip    bigint NOT NULL DEFAULT 0,
+dst_ip    bigint NOT NULL DEFAULT 0,
+src_port  integer NOT NULL DEFAULT 0,
+dst_port  integer NOT NULL DEFAULT 0,
+bytes     bigint NOT NULL DEFAULT 0,
+pkt       bigint 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.dst_ip IS 'Адрес назначения IP в виде целого числа';
+COMMENT ON COLUMN traffic_detail.bytes IS 'Байтов переданно в этом потоке';
+
+-- Неизвестные MAC-адреса
+CREATE TABLE unknown_mac (
+id BIGSERIAL PRIMARY KEY,
+mac MACADDR NOT NULL,
+port_id BIGINT,
+device_id INTEGER,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+COMMENT ON TABLE unknown_mac IS 'Недавно обнаруженные неизвестные MAC-адреса';
+
+-- Записи авторизации пользователей
+CREATE TABLE user_auth (
+id SERIAL PRIMARY KEY,
+user_id BIGINT NOT NULL DEFAULT 0,
+ou_id INTEGER,
+ip INET DEFAULT NULL,
+ip_int BIGINT NOT NULL DEFAULT 0,
+save_traf SMALLINT NOT NULL DEFAULT 0,
+enabled SMALLINT NOT NULL DEFAULT 0,
+dhcp SMALLINT NOT NULL DEFAULT 1,
+filter_group_id SMALLINT NOT NULL DEFAULT 0,
+dynamic SMALLINT NOT NULL DEFAULT 0,
+end_life TIMESTAMP,
+deleted SMALLINT NOT NULL DEFAULT 0,
+description VARCHAR(250),
+dns_name VARCHAR(253),
+dns_ptr_only SMALLINT NOT NULL DEFAULT 0,
+wikiname VARCHAR(250),
+dhcp_acl TEXT,
+queue_id INTEGER NOT NULL DEFAULT 0,
+mac MACADDR,
+dhcp_action VARCHAR(10) NOT NULL DEFAULT '',
+dhcp_option_set VARCHAR(50),
+dhcp_time TIMESTAMP,
+dhcp_hostname VARCHAR(60),
+last_found TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+arp_found TIMESTAMP,
+mac_found TIMESTAMP,
+blocked SMALLINT NOT NULL DEFAULT 0,
+day_quota INTEGER NOT NULL DEFAULT 0,
+month_quota INTEGER NOT NULL DEFAULT 0,
+device_model_id INTEGER DEFAULT 87,
+firmware VARCHAR(100),
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+client_id VARCHAR(250),
+nagios SMALLINT NOT NULL DEFAULT 0,
+nagios_status VARCHAR(10) NOT NULL DEFAULT '',
+nagios_handler VARCHAR(50) NOT NULL DEFAULT '',
+link_check SMALLINT NOT NULL DEFAULT 0,
+changed SMALLINT NOT NULL DEFAULT 0,
+dhcp_changed SMALLINT NOT NULL DEFAULT 0,
+changed_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+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 для этого хоста';
+
+-- Алиасы авторизации пользователей
+CREATE TABLE user_auth_alias (
+id SERIAL PRIMARY KEY,
+auth_id INTEGER NOT NULL,
+alias VARCHAR(100),
+description VARCHAR(100),
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+COMMENT ON TABLE user_auth_alias IS 'Алиасы/DNS имена для записей авторизации';
+
+-- Список пользователей
+CREATE TABLE user_list (
+id BIGSERIAL PRIMARY KEY,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+login VARCHAR(255),
+description VARCHAR(255),
+enabled SMALLINT NOT NULL DEFAULT 1,
+blocked SMALLINT NOT NULL DEFAULT 0,
+deleted SMALLINT NOT NULL DEFAULT 0,
+ou_id INTEGER NOT NULL DEFAULT 0,
+device_id INTEGER,
+filter_group_id INTEGER NOT NULL DEFAULT 0,
+queue_id INTEGER NOT NULL DEFAULT 0,
+day_quota INTEGER NOT NULL DEFAULT 0,
+month_quota INTEGER NOT NULL DEFAULT 0,
+permanent SMALLINT NOT NULL DEFAULT 0
+);
+COMMENT ON TABLE user_list IS 'Учетные записи пользователей в системе';
+COMMENT ON COLUMN user_list.description IS 'Фамилия Имя Отчество';
+COMMENT ON COLUMN user_list.permanent IS 'Это постоянный пользователь (не динамический)';
+
+-- Сессии пользователей (веб-интерфейс)
+CREATE TABLE user_sessions (
+id SERIAL PRIMARY KEY,
+session_id VARCHAR(128) NOT NULL,
+user_id INTEGER NOT NULL,
+ip_address VARCHAR(45) NOT NULL,
+user_agent TEXT NOT NULL,
+created_at INTEGER NOT NULL,
+last_activity INTEGER NOT NULL,
+is_active SMALLINT DEFAULT 1
+);
+COMMENT ON TABLE user_sessions IS 'Сессии пользователей веб-интерфейса';
+
+-- Статистика трафика пользователей
+CREATE TABLE user_stats (
+id BIGSERIAL PRIMARY KEY,
+router_id BIGINT DEFAULT 0,
+auth_id BIGINT NOT NULL DEFAULT 0,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+byte_in BIGINT NOT NULL DEFAULT 0,
+byte_out BIGINT NOT NULL DEFAULT 0,
+pkt_in INTEGER NOT NULL DEFAULT 0,
+pkt_out INTEGER NOT NULL DEFAULT 0,
+step SMALLINT NOT NULL DEFAULT 3600
+);
+COMMENT ON TABLE user_stats IS 'Статистика трафика пользователей (агрегированная)';
+
+-- Подробная статистика пользователей
+CREATE TABLE user_stats_full (
+id BIGSERIAL PRIMARY KEY,
+router_id BIGINT DEFAULT 0,
+auth_id BIGINT NOT NULL DEFAULT 0,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+byte_in BIGINT NOT NULL DEFAULT 0,
+byte_out BIGINT NOT NULL DEFAULT 0,
+pkt_in INTEGER NOT NULL DEFAULT 0,
+pkt_out INTEGER NOT NULL DEFAULT 0,
+step SMALLINT NOT NULL DEFAULT 600
+);
+COMMENT ON TABLE user_stats_full IS 'Подробная статистика трафика пользователей';
+COMMENT ON COLUMN user_stats_full.step IS 'Интервал сбора статистики в секундах';
+
+-- Временные переменные
+CREATE TABLE variables (
+id SERIAL PRIMARY KEY,
+name VARCHAR(30) NOT NULL UNIQUE,
+value VARCHAR(255),
+clear_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+COMMENT ON TABLE variables IS 'Временные системные переменные и блокировки';
+
+-- Производители устройств
+CREATE TABLE vendors (
+id SERIAL PRIMARY KEY,
+name VARCHAR(40) NOT NULL
+);
+COMMENT ON TABLE vendors IS 'Производители сетевого оборудования';
+
+-- Версия системы
+CREATE TABLE version (
+id INTEGER PRIMARY KEY DEFAULT 1,
+version VARCHAR(10) NOT NULL DEFAULT '2.4.14'
+);
+COMMENT ON TABLE version IS 'Информация о версии системы';
+
+-- Статистика WAN интерфейсов
+CREATE TABLE wan_stats (
+id BIGSERIAL PRIMARY KEY,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+router_id INTEGER,
+interface_id INTEGER,
+bytes_in BIGINT NOT NULL DEFAULT 0,
+bytes_out BIGINT NOT NULL DEFAULT 0,
+forward_in BIGINT NOT NULL DEFAULT 0,
+forward_out BIGINT NOT NULL DEFAULT 0
+);
+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 (
+id BIGSERIAL PRIMARY KEY,
+ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+auth_id BIGINT NOT NULL DEFAULT 0,
+customer VARCHAR(50) NOT NULL DEFAULT 'system',
+ip INET NOT NULL DEFAULT '127.0.0.1',
+message TEXT NOT NULL,
+level SMALLINT NOT NULL DEFAULT 1
+);
+COMMENT ON TABLE worklog IS 'Журнал активности и аудита системы';
+COMMENT ON COLUMN worklog.level IS 'Уровень логирования: 1=инфо, 2=предупреждение, 3=ошибка, 4=отладка';
+
+-- Индексы (такие же как в оригинальной структуре)
+CREATE INDEX idx_devices_ip ON devices(ip);
+CREATE INDEX idx_devices_device_type ON devices(device_type);
+CREATE INDEX idx_devices_active ON devices(active) WHERE active = 1;
+
+CREATE INDEX idx_device_ports_device_id ON device_ports(device_id);
+CREATE INDEX idx_device_ports_port ON device_ports(port);
+CREATE INDEX idx_device_ports_target_port_id ON device_ports(target_port_id);
+
+CREATE INDEX idx_dhcp_log_ts ON dhcp_log(ts, action);
+CREATE INDEX idx_dhcp_queue_ts ON dhcp_queue(ts, action);
+
+CREATE INDEX idx_dns_cache_dns ON dns_cache(dns, ip);
+CREATE INDEX idx_dns_cache_ts ON dns_cache(ts);
+
+CREATE INDEX idx_mac_history_mac ON mac_history(mac, ts);
+CREATE INDEX idx_mac_history_ip ON mac_history(ip, ts);
+CREATE INDEX idx_mac_history_ts ON mac_history(ts);
+
+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_dhcp ON subnets(dhcp, office, hotspot, static);
+
+CREATE INDEX idx_traffic_detail_src ON traffic_detail(auth_id, ts, router_id, src_ip);
+CREATE INDEX idx_traffic_detail_dst ON traffic_detail(auth_id, ts, router_id, dst_ip);
+
+CREATE INDEX idx_unknown_mac_ts ON unknown_mac(ts, 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_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_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_stats_ts ON user_stats(ts, auth_id, router_id);
+CREATE INDEX idx_user_stats_full_ts ON user_stats_full(ts, auth_id, router_id);
+
+CREATE INDEX idx_wan_stats_time ON wan_stats(ts, router_id, interface_id);
+
+CREATE INDEX idx_worklog_customer ON worklog(customer, level, ts);
+CREATE INDEX idx_worklog_level_ts ON worklog(level, ts);
+CREATE INDEX idx_worklog_auth_id ON worklog(auth_id, level, ts);
+CREATE INDEX idx_worklog_ts ON worklog (ts);

+ 531 - 0
docs/databases/postgres/ru/data.sql

@@ -0,0 +1,531 @@
+-- Импорт данных в PostgreSQL для русской локали
+
+-- ACL (Access Control List)
+INSERT INTO acl (id, name, description_english, description_russian) 
+VALUES 
+(0, 'Disabled','User disabled','Пользователь отключен'),
+(1, 'Full access', 'Full access', 'Полный доступ'),
+(2, 'Operator', 'Editing parameters that are not related to access rights', 'Редактирование параметров, не связанных с правами доступа'),
+(3, 'View only', 'View only', 'Только просмотр')
+ON CONFLICT (id) DO UPDATE SET
+    name = EXCLUDED.name,
+    description_english = EXCLUDED.description_english,
+    description_russian = EXCLUDED.description_russian;
+
+-- Buildings
+INSERT INTO building (id, name, description)
+VALUES (1, 'Earth', 'Somewhere')
+ON CONFLICT (id) DO UPDATE SET
+    name = EXCLUDED.name,
+    description = EXCLUDED.description;
+
+-- Configuration options
+INSERT INTO config_options (id, option_name, description_russian, description_english, draft, uniq, option_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),
+(3, 'dns server', 'ip-адрес DNS-сервера', 'DNS server ip address', 0, 1, 'text', '127.0.0.1', 0, 0),
+(5, 'dhcp server', 'ip-адрес DHCP-сервера', 'ip address of the DHCP server', 0, 1, 'text', '127.0.0.1', 0, 0),
+(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),
+(11, 'default snmp community', 'Read snmp community по умолчанию','Read snmp community by default', 0, 1, 'text', 'public', 0, 0),
+(21, 'admin email', 'E-mail администратора', 'Administrator e-mail', 0, 1, 'text', 'root', 0, 0),
+(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),
+(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),
+(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),
+(27, 'history dhcp lease', 'Глубина хранения аренды dhcp-сервера','Storage depth of the dhcp server lease', 0, 1, 'int', '1', 0, 0),
+(28, 'router_login', 'Логин для входа на сетевые устройства по умолчанию', 'Default login for network devices', 0, 1, 'text', 'admin', 0, 0),
+(29, 'router_password', 'Пароль по умолчанию на сетевые устройства', 'Default password for network devices', 0, 1, 'text', 'admin', 0, 0),
+(30, 'router_ssh_port', 'Порт ssh по умолчанию', 'SSH default port', 0, 1, 'int', '22', 22, 0),
+(32, 'org name', 'Название организации', 'Organization name', 0, 1, 'text', 'ORG', 0, 0),
+(33, 'office domain', 'Домен организации', 'Organization domain', 0, 1, 'text', 'local', 0, 0),
+(34, 'debug', 'Включить отладку', 'Enable debugging', 0, 1, 'bool', '0', 0, 1),
+(35, 'connections history, days', 'Время хранения истории мест подключения ip-адресов', 'Storage time of the history of connection locations of ip addresses', 0, 1, 'int', '90', 1, 365),
+(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),
+(38, 'regenerate dhcp cconfig', 'Расположение скрипта управления конфигурацией dhcp-серверами', 'Location of the dhcp server configuration management script', 0, 1, 'text', '/opt/Eye/scripts/update-dnsmasq', 0, 0),
+(39, 'regenerate dns cconfig', 'Расположение скрипта управления dns-сервером', 'Location of the dns server management script', 0, 1, 'text', '/opt/Eye/scripts/update-dns', 0, 0),
+(40, 'regenerate nagios cconfig', 'Расположение скрипта конфигурирования Nagios', 'Location of the Nagios configuration script', 0, 1, 'text', '/etc/nagios/restart_nagios', 0, 0),
+(41, 'discovery network', 'Расположение скрипта сканирования сети', 'Location of the network scan script', 0, 1, 'text', '/opt/Eye/scripts/fetch_new_arp.pl', 0, 0),
+(44, 'Ignore hotspot dhcp log', 'Не писать лог событий dhcp-сервера хотспота. Имеет смысл вклчючать, поскольку время аренды в хот-споте как правило маленькое и в записях хот-спота становятся незаметны логи обычных пользователей', 'Do not write the event log of the hotspot dhcp server. It makes sense toinclude 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),
+(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),
+(46, 'update hostname from dhcp', 'Обновлять имя хоста в DNS при получении адреса по DHCP', 'Update the hostname in DNS when receiving the address via DHCP', 0, 1, 'bool', '0', 0, 1),
+(47, 'history worklog', 'Глубина хранения VERBOSE логов работы в интерфейсе администратора', 'Depth of work VERBOSE logs storage in the admin interface', 0, 1, 'int', '90', 0, 1095),
+(48, 'history syslog', 'Глубина хранения логов работы syslog-сервера', 'Syslog server logs storage depth', 0, 1, 'int', '90', 0, 1095),
+(49, 'history traffic stats', 'Глубина хранения статистики трафикаюзеров', 'User traffic statistics storage depth', 0, 1, 'int', '365', 0, 0),
+(50, 'urgent sync access', 'Немедленное изменение списков доступа на роутере после правки записи пользователя', 'Immediate change of access lists on the router after editing the user record ', 0, 1, 'bool', '0', 0, 1),
+(51, 'Email_alert', 'Отправлять e-mail уведомления', 'Send e-mail notifications', 0, 1, 'bool', '1', 0, 1),
+(52, 'Sender email', 'E-mail адрес, с которого рассылается почта','E-mail address from which mail is sent', 0, 1, 'text', 'root', 0, 0),
+(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),
+(54, 'enable_quotes', 'Включить обработку квот по трафику', 'Enable traffic quota processing', 0, 1, 'bool', '0', 0, 1),
+(55, 'netflow_step', 'Интервал сброса данных из коллектора netflow, минуты', 'Data reset interval from netflow collector, minutes', 0, 1, 'int', '1', 1, 10),
+(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),
+(57, 'nagios_url', 'Адрес сайта nagios', 'nagios site address', 0, 1, 'text', 'http://127.0.0.1/nagios', 0, 0),
+(58, 'cacti_url', 'Адрес сайта cacti', 'cacti site address', 0, 1, 'text', 'http://127.0.0.1/cacti', 0, 0),
+(59, 'torrus_url', 'Адрес сайта Torrus', 'Torrus website address', 0, 1, 'text', 'http://127.0.0.1/torrus/CollectorName/', 0, 0),
+(60, 'wiki_url', 'Адрес wiki', 'Wiki website address', 0, 1, 'text', 'http://127.0.0.1/wiki', 0, 0),
+(61, 'wiki_path', 'Путь к каталогу данных вики', 'Path to wiki data directory', 0, 1, 'text', '/var/www/foswiki/data/', 0, 0),
+(62, 'stat_url', 'Адрес этого сайта', 'Address of this site', 0, 1, 'text', 'http://127.0.0.1/stat', 0, 0),
+(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),
+(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),
+(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),
+(66, 'mikrotik_rest_api_ssl', 'Использовать https для rest api', 'Use HTTPS for rest api', 1, 1, 'bool', '1', 0, 1),
+(67, 'mikrotik_rest_api_port', 'Порт вэб-интерфейса для rest api','Web interface port for rest API', 1, 1, 'int', '443', 0, 0),
+(68, 'config_mode', 'Режим конфигурирования. Скрипт опроса устройств не выполняется.', 'Configuration mode. The device polling script is not running.', 0, 1, 'bool', '0', 0, 1),
+(69, 'clean_empty_user', 'Автоматически удалять записи пользователей, не содержащие ip-адресов или автоматических привязок', 'Automatically delete user records that do not contain IP addresses or automatic bindings', 0, 1, 'bool', '0', 0, 1),
+(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),
+(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),
+(72, 'netflow_path', 'Каталог для хранения данных, полученных по netflow от маршрутизаторов', 'The directory for storing data received via netflow from routers', 0, 1, 'text', '/opt/Eye/netflow', 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
+    option_name = EXCLUDED.option_name,
+    description_russian = EXCLUDED.description_russian,
+    description_english = EXCLUDED.description_english,
+    draft = EXCLUDED.draft,
+    uniq = EXCLUDED.uniq,
+    option_type = EXCLUDED.option_type,
+    default_value = EXCLUDED.default_value,
+    min_value = EXCLUDED.min_value,
+    max_value = EXCLUDED.max_value;
+
+-- System configuration values
+INSERT INTO config (id, option_id, value)
+VALUES
+(1, 1, '0'),
+(2, 11, 'public'),
+(3, 32, 'ORG'),
+(123, 19, '1'),
+(124, 35, '120'),
+(125, 9, '2'),
+(126, 41, '/opt/Eye/scripts/fetch_new_arp.pl'),
+(127, 26, '3'),
+(128, 27, '10'),
+(129, 48, '90'),
+(130, 49, '365'),
+(131, 47, '90'),
+(132, 53, '1'),
+(133, 55, '1'),
+(134, 56, '30'),
+(135, 34, '0'),
+(137, 65, '0'),
+(142, 54, ''),
+(143, 17, '1'),
+(144, 37, '/opt/Eye/scripts/sync_mikrotik.pl'),
+(145, 23, '1'),
+(148, 22, '1')
+ON CONFLICT (id) DO UPDATE SET
+    option_id = EXCLUDED.option_id,
+    value = EXCLUDED.value;
+
+-- System users/administrators
+-- В PostgreSQL нет аналога ON DUPLICATE KEY UPDATE, используем ON CONFLICT
+INSERT INTO customers (id, Login, description, password, api_key, rights)
+VALUES (1, 'admin', 'Administrator', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31', 1)
+ON CONFLICT (id) DO UPDATE SET
+    Login = EXCLUDED.Login,
+    description = EXCLUDED.description,
+    password = EXCLUDED.password,
+    api_key = EXCLUDED.api_key,
+    rights = EXCLUDED.rights;
+
+-- Device models
+INSERT INTO device_models (id, model_name, vendor_id, poe_in, poe_out, nagios_template)
+VALUES
+(1, '2011LS', 9, 1, 0, NULL),
+(2, '2011UAS-2HnD', 9, 1, 0, NULL),
+(3, 'AT-8000S', 8, 0, 0, NULL),
+(4, 'AT-8100S/48POE', 8, 0, 0, NULL),
+(5, 'AT-9000/28', 8, 0, 0, NULL),
+(6, 'AT-GS950/24', 8, 0, 0, NULL),
+(7, 'CCR1009-7G-1C-1S+', 9, 0, 0, NULL),
+(8, 'CCR1036-8G-2S+', 9, 0, 0, NULL),
+(10, 'CRS317-1G-16S+', 9, 0, 0, NULL),
+(11, 'CRS326-24S+2Q+', 9, 0, 0, NULL),
+(12, 'CRS328-24P-4S+', 9, 1, 0, NULL),
+(14, 'CRS328-4C-20S-4S+', 9, 0, 0, NULL),
+(15, 'DGS-3120-48TC', 7, 0, 0, NULL),
+(16, 'ES-2024', 4, 0, 0, NULL),
+(17, 'ES-2024A', 4, 0, 0, NULL),
+(18, 'ES-2108', 4, 0, 0, NULL),
+(19, 'ES-2108-G', 4, 0, 0, NULL),
+(20, 'ES-3124-4F', 4, 0, 0, NULL),
+(21, 'GS110TP', 10, 0, 1, NULL),
+(22, 'GS-4024', 4, 0, 0, NULL),
+(23, 'HP 1910', 15, 0, 0, NULL),
+(24, 'ISCOM2110A-MA', 5, 0, 0, NULL),
+(25, 'ISCOM2110EA-MA', 5, 0, 0, NULL),
+(26, 'ISCOM2126EA-MA', 5, 0, 0, NULL),
+(27, 'ISCOM2128EA-MA', 5, 0, 0, NULL),
+(28, 'Linux server', 1, 0, 0, ''),
+(29, 'MES2124F', 2, 0, 0, NULL),
+(30, 'MES2124MB', 2, 0, 0, NULL),
+(31, 'MES5248', 2, 0, 0, NULL),
+(32, 'RB2011UAS', 9, 1, 0, NULL),
+(33, 'RB3011UiAS', 9, 1, 0, NULL),
+(34, 'RB960PGS', 9, 1, 1, NULL),
+(35, 'RBD52G-5HacD2HnD', 9, 1, 0, NULL),
+(36, 'S2940-8G-v2', 6, 0, 0, NULL),
+(37, 'S2980G-24T', 6, 0, 0, NULL),
+(38, 'S3750G-24S-E', 6, 0, 0, NULL),
+(39, 'S5300-52P-LI-AC', 3, 0, 0, NULL),
+(40, 'S5320-52X-PWR-SI-AC', 3, 0, 0, NULL),
+(41, 'S5321-28X-SI-AC', 3, 0, 0, NULL),
+(42, 'S5321-52X-SI-AC', 3, 0, 0, NULL),
+(43, 'S6320-54C-EI-48S-AC', 3, 0, 0, NULL),
+(44, 'SNR-S2980G-24T', 6, 0, 0, NULL),
+(45, 'V1910-16G', 15, 0, 0, NULL),
+(46, 'V1910-24G-PoE', 15, 0, 0, NULL),
+(47, 'Windows server', 1, 0, 0, NULL),
+(48, 'WS-C2960G-24TC-L', 16, 0, 0, NULL),
+(49, 'WS-C3560G-24TS-S', 16, 0, 0, NULL),
+(50, 'x210-16GT', 8, 0, 0, NULL),
+(51, 'x210-24GT', 8, 0, 0, NULL),
+(52, 'x610-24Ts/X', 8, 0, 0, NULL),
+(53, 'x610-48Ts', 8, 0, 0, NULL),
+(54, 'XGS-4728', 4, 0, 0, NULL),
+(55, 'ZyWall 310', 4, 0, 0, NULL),
+(56, 'APC Smart-UPS_3000', 20, 0, 0, 'ups.cfg'),
+(57, 'APC Smart-UPS_5000', 20, 0, 0, 'ups.cfg'),
+(58, 'Schneider Smart-UPS_3000', 21, 0, 0, NULL),
+(59, 'SMG-1016M', 2, 0, 0, NULL),
+(60, 'EATON 9PX 1500i RT 2U', 64, 0, 0, NULL),
+(61, 'EATON 9PX3000i_RT_2U', 64, 0, 0, NULL),
+(62, 'EATON 9PX_6000i', 64, 0, 0, NULL),
+(63, 'EATON PW9130_3000', 64, 0, 0, NULL),
+(64, 'EATON PW9130_3000VA-R', 64, 0, 0, NULL),
+(65, 'Epson WF-5620 Series', 59, 0, 0, NULL),
+(66, 'Epson WF-8590 Series', 59, 0, 0, NULL),
+(67, 'HP Officejet-7000', 15, 0, 0, 'hp.cfg'),
+(68, 'OKI C610', 62, 0, 0, NULL),
+(69, 'OKI MB472', 62, 0, 0, NULL),
+(70, 'OKI MB491', 62, 0, 0, NULL),
+(71, 'OKI MC562', 62, 0, 0, NULL),
+(72, 'OKI MC573', 62, 0, 0, NULL),
+(73, 'OKI MC861', 62, 0, 0, NULL),
+(74, 'Panasonic KX-MB2000RU', 61, 0, 0, NULL),
+(75, 'PT-MZ10KE', 61, 0, 0, NULL),
+(76, 'PT-VX41', 61, 0, 0, NULL),
+(77, 'Rave 522AA', 33, 0, 0, NULL),
+(78, 'DZ570E', 61, 0, 0, NULL),
+(79, 'DZ6700', 61, 0, 0, NULL),
+(80, 'Rcq80', 61, 0, 0, NULL),
+(81, 'RZ12K', 61, 0, 0, NULL),
+(82, 'RZ660', 61, 0, 0, NULL),
+(83, 'RZ770', 61, 0, 0, NULL),
+(84, 'RZ970', 61, 0, 0, NULL),
+(85, 'XVR-5216', 66, 0, 0, NULL),
+(86, 'HWg-STE', 68, 0, 0, NULL),
+(87, 'Computer', 1, 0, 0, ''),
+(88, 'Mobile Phone', 1, 0, 0, NULL),
+(89, 'Switch', 1, 0, 0, NULL),
+(90, 'Projectiondesign F22', 34, 0, 0, NULL),
+(91, 'DS-I252', 36, 0, 0, NULL),
+(92, 'LTV-CNE-720-48', 37, 0, 0, NULL),
+(93, 'U-100', 38, 0, 0, NULL),
+(94, 'TAU-8', 2, 0, 0, NULL),
+(95, 'SIP-T21P E2', 39, 0, 0, NULL),
+(96, 'A510 IP', 40, 0, 0, NULL),
+(97, 'W60B', 39, 0, 0, NULL),
+(98, 'TAU-2M', 2, 0, 0, NULL),
+(99, 'PAP2T', 41, 0, 0, NULL),
+(100, 'VP-12', 2, 0, 0, NULL),
+(101, 'SIP-T23P', 39, 0, 0, NULL),
+(102, 'SPA-2102', 16, 0, 0, NULL),
+(103, 'RB760iGS', 9, 1, 0, NULL),
+(104, 'MES2324B', 2, 0, 0, NULL),
+(105, 'MES2324FB', 2, 0, 0, NULL),
+(106, 'MES2124P', 2, 0, 1, NULL),
+(107, 'MES2428P', 2, 0, 1, NULL),
+(108, 'Symmetra LX 16000', 20, 0, 0, 'symmetra.cfg'),
+(109, 'SNR-UPS-ONT20', 6, 0, 0, 'ups3.cfg'),
+(110, 'MES-3728', 4, 0, 0, NULL),
+(111, 'SNR-S5210G-24TX-UPS-R', 6, 0, 0, NULL),
+(112, 'SNR-S2985G-24TC', 6, 0, 0, NULL),
+(113, 'MES-5248', 2, 0, 0, NULL),
+(114, 'SNR-S5210G-24TX-POE', 6, 0, 1, NULL),
+(115, 'SNR-S5210G-24TX-UPS', 6, 0, 0, NULL),
+(116, 'SNR-S5210X-8F-UPS', 6, 0, 0, NULL),
+(117, 'SNR-S2982G-8T-UPS', 6, 0, 0, NULL)
+ON CONFLICT (id) DO UPDATE SET
+    model_name = EXCLUDED.model_name,
+    vendor_id = EXCLUDED.vendor_id,
+    poe_in = EXCLUDED.poe_in,
+    poe_out = EXCLUDED.poe_out,
+    nagios_template = EXCLUDED.nagios_template;
+
+-- Device types
+INSERT INTO device_types (id, name_russian, name_english)
+VALUES
+(0, 'Роутер', 'Router'),
+(1, 'Свич', 'Switch'),
+(2, 'Шлюз', 'Gateway'),
+(3, 'Сервер', 'Server'),
+(4, 'Точка доступа', 'WiFi Access Point'),
+(5, 'Сетевое устройство', 'Network device')
+ON CONFLICT (id) DO UPDATE SET
+    name_russian = EXCLUDED.name_russian,
+    name_english = EXCLUDED.name_english;
+
+-- Filter instances
+INSERT INTO filter_instances (id, name, description)
+VALUES (1, 'default', NULL)
+ON CONFLICT (id) DO UPDATE SET
+    name = EXCLUDED.name,
+    description = EXCLUDED.description;
+
+-- Filter groups (русские названия)
+INSERT INTO group_list (id, instance_id, group_name, description)
+VALUES
+(0, 1, 'default', 'Всё запрещено'),
+(1, 1, 'Allow all', 'Разрешено всё'),
+(2, 1, 'Users', 'Для пользователей')
+ON CONFLICT (id) DO UPDATE SET
+    instance_id = EXCLUDED.instance_id,
+    group_name = EXCLUDED.group_name,
+    description = EXCLUDED.description;
+
+-- Organizational Units (русские названия)
+INSERT INTO ou (id, ou_name, description, 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),
+(1, 'Сервера', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 0, 0, 24.00, NULL),
+(2, 'Администраторы', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(3, 'Пользователи', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(4, 'VOIP', NULL, 0, 0, 'voip', 'voip', 1, NULL, 1, 4, 5, 0, 24.00, NULL),
+(5, 'IPCAM', NULL, 0, 0, 'videocam', 'ip-cam', 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(6, 'Принтеры', NULL, 0, 0, 'printers', 'printers', 1, 'printer-service', 0, 0, 0, 0, 24.00, NULL),
+(7, 'Свичи', NULL, 0, 0, 'switches', 'switches', 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(8, 'UPS', NULL, 0, 0, 'ups', 'ups', 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(9, 'Охрана', NULL, 0, 0, 'security', 'security', 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(10, 'Роутеры', NULL, 0, 0, 'routers', 'routers', 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(11, 'WiFi AP', NULL, 0, 0, 'ap', 'ap', 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(12, 'DHCP', NULL, 1, 0, NULL, NULL, 1, NULL, 0, 0, 0, 0, 24.00, NULL),
+(13, 'Гости', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4, 1, 24.00, NULL)
+ON CONFLICT (id) DO UPDATE SET
+    ou_name = EXCLUDED.ou_name,
+    description = EXCLUDED.description,
+    default_users = EXCLUDED.default_users,
+    default_hotspot = EXCLUDED.default_hotspot,
+    nagios_dir = EXCLUDED.nagios_dir,
+    nagios_host_use = EXCLUDED.nagios_host_use,
+    nagios_ping = EXCLUDED.nagios_ping,
+    nagios_default_service = EXCLUDED.nagios_default_service,
+    enabled = EXCLUDED.enabled,
+    filter_group_id = EXCLUDED.filter_group_id,
+    queue_id = EXCLUDED.queue_id,
+    dynamic = EXCLUDED.dynamic,
+    life_duration = EXCLUDED.life_duration,
+    parent_id = EXCLUDED.parent_id;
+
+-- Traffic shaping queues
+INSERT INTO queue_list (id, queue_name, download, upload)
+VALUES
+(0, 'unlimited', 0, 0),
+(1, '2M/2M', 2048, 2048),
+(2, '10M/10M', 10240, 10240),
+(3, '100M/100M', 102400, 102400),
+(4, '50M/50M', 50000, 50000),
+(5, '20M/20M', 20480, 20480),
+(6, '200M/200M', 212400, 212400),
+(7, '1G/1G', 1024000, 1024000),
+(8, '2G/2G', 2048000, 2048000)
+ON CONFLICT (id) DO UPDATE SET
+    queue_name = EXCLUDED.queue_name,
+    download = EXCLUDED.download,
+    upload = EXCLUDED.upload;
+
+-- Network subnets
+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, description)
+VALUES (1, '192.168.2.0/24', 2, 3232236032, 3232236287, 3232236132, 3232236182, 480, 3232236033, 1, 0, 0, 0, 1, 0, 1, 1, 7, 'LAN')
+ON CONFLICT (id) DO UPDATE SET
+    subnet = EXCLUDED.subnet,
+    vlan_tag = EXCLUDED.vlan_tag,
+    ip_int_start = EXCLUDED.ip_int_start,
+    ip_int_stop = EXCLUDED.ip_int_stop,
+    dhcp_start = EXCLUDED.dhcp_start,
+    dhcp_stop = EXCLUDED.dhcp_stop,
+    dhcp_lease_time = EXCLUDED.dhcp_lease_time,
+    gateway = EXCLUDED.gateway,
+    office = EXCLUDED.office,
+    hotspot = EXCLUDED.hotspot,
+    vpn = EXCLUDED.vpn,
+    free = EXCLUDED.free,
+    dhcp = EXCLUDED.dhcp,
+    static = EXCLUDED.static,
+    dhcp_update_hostname = EXCLUDED.dhcp_update_hostname,
+    discovery = EXCLUDED.discovery,
+    notify = EXCLUDED.notify,
+    description = EXCLUDED.description;
+
+-- Device vendors
+INSERT INTO vendors (id, name)
+VALUES
+(1, 'Unknown'),
+(2, 'Eltex'),
+(3, 'Huawei'),
+(4, 'Zyxel'),
+(5, 'Raisecom'),
+(6, 'SNR'),
+(7, 'Dlink'),
+(8, 'Allied Telesis'),
+(9, 'Mikrotik'),
+(10, 'NetGear'),
+(11, 'Ubiquiti'),
+(15, 'HP'),
+(16, 'Cisco'),
+(17, 'Maipu'),
+(18, 'Asus'),
+(19, 'Linux'),
+(20, 'APC'),
+(21, 'Schneider'),
+(33, 'QSC'),
+(34, 'Projectiondesign'),
+(35, 'Lenovo'),
+(36, 'HiWatch'),
+(37, 'LTV'),
+(38, 'Yeastar'),
+(39, 'Yealink'),
+(40, 'Gigaset'),
+(41, 'Linksys'),
+(42, 'Samsung'),
+(43, 'Supermicro'),
+(44, 'RDP'),
+(45, 'SANYO'),
+(46, 'Extreme'),
+(47, 'Intel'),
+(48, 'Micron'),
+(49, 'Gigabyte'),
+(50, 'Acer'),
+(51, 'Seagate'),
+(52, 'SanDisk'),
+(53, 'Toshiba'),
+(54, 'Kingston'),
+(55, 'AddPac'),
+(56, 'Devline'),
+(57, 'Canon'),
+(58, 'Brother'),
+(59, 'Epson'),
+(60, 'IP-COM'),
+(61, 'Panasonic'),
+(62, 'OKI'),
+(63, 'Apple'),
+(64, 'Eaton'),
+(65, 'Barco'),
+(66, 'Trassir'),
+(67, 'Testo'),
+(68, 'Hw-group'),
+(69, 'Tp-link')
+ON CONFLICT (id) DO UPDATE SET
+    name = EXCLUDED.name;
+
+-- Filter rules list
+INSERT INTO filter_list (id, name, description, proto, dst, dstport, srcport, filter_type)
+VALUES
+(1, 'pop3', NULL, 'tcp', '0/0', '110', NULL, 0),
+(3, 'http', NULL, 'tcp', '0/0', '80', NULL, 0),
+(4, 'https', NULL, 'tcp', '0/0', '443', NULL, 0),
+(5, 'icq', NULL, 'tcp', '0/0', '5190', NULL, 0),
+(6, 'jabber', NULL, 'tcp', '0/0', '5222', NULL, 0),
+(9, 'allow_all', 'любой трафик', 'all', '0/0', '0', '0', 0),
+(10, 'icmp', NULL, 'icmp', '0/0', '0', NULL, 0),
+(11, 'ftp', NULL, 'tcp', '0/0', '20-21', NULL, 0),
+(15, 'telnet', NULL, 'tcp', '0/0', '23', NULL, 0),
+(16, 'ssh', NULL, 'tcp', '0/0', '22', NULL, 0),
+(28, 'smtp', NULL, 'tcp', '0/0', '25', NULL, 0),
+(32, 'rdp', NULL, 'tcp', '0/0', '3389', NULL, 0),
+(40, 'ntp', NULL, 'udp', '0/0', '123', NULL, 0),
+(44, 'vnc', NULL, 'tcp', '0/0', '5800-5900', NULL, 0),
+(55, 'unprivileged tcp', NULL, 'tcp', '0/0', '1024-65500', NULL, 0),
+(76, 'ipsec', NULL, 'udp', '0/0', '500', NULL, 0),
+(77, 'isakmp', NULL, 'udp', '0/0', '4500', NULL, 0),
+(79, 'pop3s', NULL, 'tcp', '0/0', '995', NULL, 0),
+(80, 'smtps', NULL, 'tcp', '0/0', '465,587', NULL, 0),
+(81, 'imap', NULL, 'tcp', '0/0', '143', NULL, 0),
+(82, 'imaps', NULL, 'tcp', '0/0', '993', NULL, 0),
+(83, 'unprivileged udp', NULL, 'udp', '0/0', '1024-65000', NULL, 0),
+(84, 'pptp', NULL, 'tcp', '0/0', '1723', NULL, 0),
+(85, 'openvpn-udp', NULL, 'udp', '0/0', '1194', NULL, 0),
+(90, 'dns_udp', NULL, 'udp', '0/0', '53', NULL, 0),
+(91, 'dns_tcp', NULL, 'tcp', '0/0', '53', NULL, 0),
+(94, 'squid', NULL, 'tcp', '0/0', '3128', NULL, 0),
+(101, 'snmp', NULL, 'udp', '0/0', '161', NULL, 0),
+(105, 'http_udp', NULL, 'udp', '0/0', '80', NULL, 0),
+(106, 'https_udp', NULL, 'udp', '0/0', '443', NULL, 0),
+(107, 'l2tp-ipsec', NULL, 'udp', '0/0', '1701,4500,500', NULL, 0),
+(108, 'gre', NULL, 'gre', '0/0', NULL, NULL, 0)
+ON CONFLICT (id) DO UPDATE SET
+    name = EXCLUDED.name,
+    description = EXCLUDED.description,
+    proto = EXCLUDED.proto,
+    dst = EXCLUDED.dst,
+    dstport = EXCLUDED.dstport,
+    srcport = EXCLUDED.srcport,
+    filter_type = EXCLUDED.filter_type;
+
+-- Filter group assignments
+INSERT INTO group_filters (id, group_id, filter_id, rule_order, action)
+VALUES
+(1, 2, 90, 1, 1),
+(2, 2, 91, 2, 1),
+(3, 2, 11, 3, 1),
+(5, 2, 3, 4, 1),
+(6, 2, 105, 5, 1),
+(7, 2, 4, 6, 1),
+(8, 2, 106, 7, 1),
+(9, 2, 10, 8, 1),
+(10, 2, 81, 9, 1),
+(11, 2, 82, 10, 1),
+(15, 2, 40, 11, 1),
+(16, 2, 1, 12, 1),
+(17, 2, 79, 13, 1),
+(18, 2, 80, 14, 1),
+(19, 1, 9, 1, 1)
+ON CONFLICT (id) DO UPDATE SET
+    group_id = EXCLUDED.group_id,
+    filter_id = EXCLUDED.filter_id,
+    rule_order = EXCLUDED.rule_order,
+    action = EXCLUDED.action;
+
+-- System version
+INSERT INTO version (id, version)
+VALUES (1, '3.0.1')
+ON CONFLICT (id) DO UPDATE SET
+    version = EXCLUDED.version;
+
+-- Обновление последовательностей после импорта данных
+SELECT setval(pg_get_serial_sequence('acl', 'id'), COALESCE((SELECT MAX(id) FROM acl), 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', '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('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('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('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('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('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 $$
+BEGIN
+    RAISE NOTICE 'Импорт данных для русской локали завершен успешно!';
+    RAISE NOTICE 'Всего импортировано таблиц: 16';
+    RAISE NOTICE 'Всего импортировано записей:';
+    RAISE NOTICE '  - acl: %', (SELECT COUNT(*) FROM acl);
+    RAISE NOTICE '  - building: %', (SELECT COUNT(*) FROM building);
+    RAISE NOTICE '  - config_options: %', (SELECT COUNT(*) FROM config_options);
+    RAISE NOTICE '  - config: %', (SELECT COUNT(*) FROM config);
+    RAISE NOTICE '  - customers: %', (SELECT COUNT(*) FROM customers);
+    RAISE NOTICE '  - device_models: %', (SELECT COUNT(*) FROM device_models);
+    RAISE NOTICE '  - device_types: %', (SELECT COUNT(*) FROM device_types);
+    RAISE NOTICE '  - filter_instances: %', (SELECT COUNT(*) FROM filter_instances);
+    RAISE NOTICE '  - group_list: %', (SELECT COUNT(*) FROM group_list);
+    RAISE NOTICE '  - ou: %', (SELECT COUNT(*) FROM ou);
+    RAISE NOTICE '  - queue_list: %', (SELECT COUNT(*) FROM queue_list);
+    RAISE NOTICE '  - subnets: %', (SELECT COUNT(*) FROM subnets);
+    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 '  - version: %', (SELECT COUNT(*) FROM version);
+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); }
 
 #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);
 

+ 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); }
 
 #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);
 

+ 10 - 10
docs/iptables/parse_ulog.pl

@@ -52,7 +52,7 @@ my $users = new Net::Patricia;
 InitSubnets();
 
 #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"; }
 
 $user_auth_list->execute;
@@ -138,7 +138,7 @@ if ($office_networks->match_string($l_src_ip)) {
         $stats{line}{user}++;
         $stats{pkt}{user_out}+=$l_packets;
         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);
             }
         }
@@ -155,7 +155,7 @@ if ($office_networks->match_string($l_dst_ip)) {
         $stats{pkt}{user_in}+=$l_packets;
         $user_found = 1;
         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);
             }
         }
@@ -195,7 +195,7 @@ $user_ip_aton=StrToIp($user_ip);
 my $auth_id=new_auth($dbh,$user_ip);
 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);
 $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 ($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);
             }
         if ($l_src_ip eq $user_ip) {
@@ -244,17 +244,17 @@ next if (!$user_stats{$row}{htime});
 
 #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);
 
 #hour 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);
 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);
     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; }
 $hour_stat->{byte_in} += $user_stats{$row}{in};
 $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);
 }
 

+ 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.");
 
 #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";
 
 my @authlist_ref = get_records_sql($dbh,$user_auth_sql);
@@ -102,7 +102,7 @@ log_debug("Users status:".Dumper(\%users));
 $lists{'group_all'}=1;
 
 #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;
 foreach my $row (@queuelist_ref) {
@@ -115,12 +115,12 @@ $queues{'queue_'.$row->{id}}{up}=$row->{Upload};
 
 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 %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 $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));
 
 #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 $index=0;

BIN
docs/legacy/mysql/2-6-3.tar.gz


BIN
docs/legacy/mysql/2-7-0.tar.gz


BIN
docs/legacy/mysql/2-7-1.tar.gz


BIN
docs/legacy/mysql/2-7-2.tar.gz


BIN
docs/legacy/mysql/2-7-3.tar.gz


BIN
docs/legacy/mysql/2-7-4.tar.gz


BIN
docs/legacy/mysql/2-7-5.tar.gz


BIN
docs/legacy/mysql/2-7-6.tar.gz


BIN
docs/legacy/mysql/2-7-7.tar.gz


BIN
docs/legacy/mysql/2-7-8.tar.gz


BIN
docs/legacy/mysql/2-7-9.tar.gz


BIN
docs/legacy/updates/2-6-3.tar.gz


BIN
docs/legacy/updates/2-7-0.tar.gz


BIN
docs/legacy/updates/2-7-1.tar.gz


BIN
docs/legacy/updates/2-7-2.tar.gz


BIN
docs/legacy/updates/2-7-3.tar.gz


BIN
docs/legacy/updates/2-7-4.tar.gz


BIN
docs/legacy/updates/2-7-5.tar.gz


BIN
docs/legacy/updates/2-7-6.tar.gz


BIN
docs/legacy/updates/2-7-7.tar.gz


BIN
docs/legacy/updates/2-7-8.tar.gz


BIN
docs/legacy/updates/2-7-9.tar.gz


+ 0 - 1688
docs/mysql/2-8-0/mysql.sql

@@ -1,1688 +0,0 @@
--- phpMyAdmin SQL Dump
--- version 5.2.1
--- https://www.phpmyadmin.net/
---
--- Хост: localhost
--- Время создания: Дек 03 2024 г., 14:57
--- Версия сервера: 10.11.6-MariaDB-0+deb12u1-log
--- Версия PHP: 8.2.26
-
-SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
-START TRANSACTION;
-SET time_zone = "+00:00";
-
-
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8mb4 */;
-
---
--- База данных: `stat`
---
-
-CREATE TABLE `device_filter_instances` (
-   `id` INT NOT NULL AUTO_INCREMENT ,
-   `instance_id` INT NULL DEFAULT NULL ,
-   `device_id` INT NULL DEFAULT NULL , PRIMARY KEY (`id`)
-) ENGINE = InnoDB;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `acl`
---
-
-CREATE TABLE `acl` (
-  `id` int(11) NOT NULL,
-  `name` varchar(30) NOT NULL,
-  `description.english` varchar(250) NOT NULL,
-  `description.russian` varchar(250) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `ad_comp_cache`
---
-
-CREATE TABLE `ad_comp_cache` (
-  `id` int(11) NOT NULL,
-  `name` varchar(63) NOT NULL,
-  `last_found` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `auth_rules`
---
-
-CREATE TABLE `auth_rules` (
-  `id` int(11) NOT NULL,
-  `user_id` int(11) DEFAULT NULL,
-  `ou_id` int(11) DEFAULT NULL,
-  `type` int(11) NOT NULL,
-  `rule` varchar(40) DEFAULT NULL,
-  `comment` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `building`
---
-
-CREATE TABLE `building` (
-  `id` int(11) NOT NULL,
-  `name` varchar(50) NOT NULL,
-  `comment` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `building`
---
-
-INSERT INTO `building` (`id`, `name`, `comment`) VALUES(1, 'Earth', 'Somewhere');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `config`
---
-
-CREATE TABLE `config` (
-  `id` int(11) NOT NULL,
-  `option_id` int(11) DEFAULT NULL,
-  `value` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `config`
---
-
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(1, 1, '0');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(2, 11, 'public');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(3, 32, 'ORG');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(123, 19, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(124, 35, '120');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(125, 9, '2');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(126, 41, '/opt/Eye/scripts/fetch_new_arp.pl');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(127, 26, '3');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(128, 27, '10');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(129, 48, '90');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(130, 49, '365');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(131, 47, '90');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(132, 53, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(133, 55, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(134, 56, '30');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(135, 34, '0');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(137, 65, '0');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(142, 54, '');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(143, 17, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(144, 37, '/opt/Eye/scripts/sync_mikrotik.pl');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(145, 23, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(148, 22, '1');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `config_options`
---
-
-CREATE TABLE `config_options` (
-  `id` int(11) NOT NULL,
-  `option_name` varchar(50) NOT NULL,
-  `description.russian` text DEFAULT NULL,
-  `description.english` text DEFAULT NULL,
-  `draft` tinyint(1) NOT NULL DEFAULT 0,
-  `uniq` tinyint(1) NOT NULL DEFAULT 1,
-  `type` varchar(100) NOT NULL,
-  `default_value` varchar(250) DEFAULT NULL,
-  `min_value` int(11) NOT NULL DEFAULT 0,
-  `max_value` int(11) NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `config_options`
---
-
-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 VERBOSE work 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 сообщения для уровней сообщений WARNING & ERROR', 'Send e-mail messages for message levels WARNING & ERROR', 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);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `connections`
---
-
-CREATE TABLE `connections` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `device_id` bigint(20) UNSIGNED NOT NULL,
-  `port_id` bigint(20) UNSIGNED NOT NULL,
-  `auth_id` bigint(20) UNSIGNED NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Customers`
---
-
-CREATE TABLE `Customers` (
-  `id` int(11) NOT NULL,
-  `Login` varchar(20) DEFAULT 'NULL',
-  `comment` varchar(100) DEFAULT 'NULL',
-  `password` varchar(255) DEFAULT 'NULL',
-  `api_key` varchar(255) DEFAULT NULL,
-  `rights` tinyint(1) NOT NULL DEFAULT 3
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Customers`
---
-
-INSERT INTO `Customers` (`id`, `Login`, `comment`, `password`, `api_key`, `rights`) VALUES(1, 'admin', '', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'Kot5miegiequaeseim3veequeiW2Iv3L', 1);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `devices`
---
-
-CREATE TABLE `devices` (
-  `id` int(11) NOT NULL,
-  `device_type` int(11) NOT NULL DEFAULT 1,
-  `device_model_id` int(11) DEFAULT 89,
-  `firmware` varchar(100) DEFAULT NULL,
-  `vendor_id` int(11) NOT NULL DEFAULT 1,
-  `device_name` varchar(50) DEFAULT NULL,
-  `building_id` int(11) NOT NULL DEFAULT 1,
-  `ip` varchar(15) DEFAULT NULL,
-  `ip_int` BIGINT(10) UNSIGNED DEFAULT NULL,
-  `login` varchar(50) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `protocol` int(11) NOT NULL DEFAULT 0,
-  `control_port` int(11) NOT NULL DEFAULT 23,
-  `port_count` int(11) NOT NULL DEFAULT 0,
-  `SN` varchar(80) DEFAULT NULL,
-  `comment` varchar(255) DEFAULT NULL,
-  `snmp_version` tinyint(4) NOT NULL DEFAULT 0,
-  `snmp3_auth_proto` varchar(10) NOT NULL DEFAULT 'sha512',
-  `snmp3_priv_proto` varchar(10) NOT NULL DEFAULT 'aes128',
-  `snmp3_user_rw` varchar(20) DEFAULT NULL,
-  `snmp3_user_rw_password` varchar(20) DEFAULT NULL,
-  `snmp3_user_ro` varchar(20) DEFAULT NULL,
-  `snmp3_user_ro_password` varchar(20) DEFAULT NULL,
-  `community` varchar(50) NOT NULL DEFAULT 'public',
-  `rw_community` varchar(50) NOT NULL DEFAULT 'private',
-  `fdb_snmp_index` tinyint(1) NOT NULL DEFAULT 0,
-  `discovery` tinyint(1) NOT NULL DEFAULT 1,
-  `netflow_save` tinyint(1) NOT NULL DEFAULT 0,
-  `user_acl` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios` tinyint(1) NOT NULL DEFAULT 0,
-  `active` tinyint(1) NOT NULL DEFAULT 1,
-  `nagios_status` varchar(10) NOT NULL DEFAULT 'UP',
-  `queue_enabled` tinyint(1) NOT NULL DEFAULT 0,
-  `connected_user_only` tinyint(1) NOT NULL DEFAULT 1,
-  `user_id` int(11) DEFAULT NULL,
-  `deleted` tinyint(1) NOT NULL DEFAULT 0,
-  `discovery_locked` tinyint(1) NOT NULL DEFAULT 0,
-  `locked_timestamp` timestamp NULL DEFAULT current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `device_l3_interfaces`
---
-
-CREATE TABLE `device_l3_interfaces` (
-  `id` int(11) NOT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `snmpin` int(11) DEFAULT NULL,
-  `interface_type` int(11) NOT NULL DEFAULT 0,
-  `name` varchar(100) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `device_models`
---
-
-CREATE TABLE `device_models` (
-  `id` int(11) NOT NULL,
-  `model_name` varchar(200) DEFAULT NULL,
-  `vendor_id` int(11) DEFAULT 1,
-  `poe_in` tinyint(1) NOT NULL DEFAULT 0,
-  `poe_out` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios_template` varchar(200) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `device_models`
---
-
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(1, '2011LS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(2, '2011UAS-2HnD', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(3, 'AT-8000S', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(4, 'AT-8100S/48POE', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(5, 'AT-9000/28', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(6, 'AT-GS950/24', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(7, 'CCR1009-7G-1C-1S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(8, 'CCR1036-8G-2S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(10, 'CRS317-1G-16S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(11, 'CRS326-24S+2Q+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(12, 'CRS328-24P-4S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(14, 'CRS328-4C-20S-4S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(15, 'DGS-3120-48TC', 7, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(16, 'ES-2024', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(17, 'ES-2024A', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(18, 'ES-2108', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(19, 'ES-2108-G', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(20, 'ES-3124-4F', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(21, 'GS110TP', 10, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(22, 'GS-4024', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(23, 'HP 1910', 15, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(24, 'ISCOM2110A-MA', 5, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(25, 'ISCOM2110EA-MA', 5, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(26, 'ISCOM2126EA-MA', 5, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(27, 'ISCOM2128EA-MA', 5, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(28, 'Linux server', 1, 0, 0, '');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(29, 'MES2124F', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(30, 'MES2124MB', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(31, 'MES5248', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(32, 'RB2011UAS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(33, 'RB3011UiAS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(34, 'RB960PGS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(35, 'RBD52G-5HacD2HnD', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(36, 'S2940-8G-v2', 6, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(37, 'S2980G-24T', 6, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(38, 'S3750G-24S-E', 6, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(39, 'S5300-52P-LI-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(40, 'S5320-52X-PWR-SI-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(41, 'S5321-28X-SI-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(42, 'S5321-52X-SI-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(43, 'S6320-54C-EI-48S-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(44, 'SNR-S2980G-24T', 6, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(45, 'V1910-16G', 15, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(46, 'V1910-24G-PoE', 15, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(47, 'Windows server', 1, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(48, 'WS-C2960G-24TC-L', 16, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(49, 'WS-C3560G-24TS-S', 16, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(50, 'x210-16GT', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(51, 'x210-24GT', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(52, 'x610-24Ts/X', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(53, 'x610-48Ts', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(54, 'XGS-4728', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(55, 'ZyWall 310', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(56, 'APC Smart-UPS_3000', 20, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(57, 'APC Smart-UPS_5000', 20, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(58, 'Schneider Smart-UPS_3000', 21, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(59, 'SMG-1016M', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(60, 'EATON 9PX 1500i RT 2U', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(61, 'EATON 9PX3000i_RT_2U', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(62, 'EATON 9PX_6000i', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(63, 'EATON PW9130_3000', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(64, 'EATON PW9130_3000VA-R', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(65, 'Epson WF-5620 Series', 59, 0, 0, 'epson.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(66, 'Epson WF-8590 Series', 59, 0, 0, 'epson.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(67, 'HP Officejet-7000', 15, 0, 0, 'hp.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(68, 'OKI C610', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(69, 'OKI MB472', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(70, 'OKI MB491', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(71, 'OKI MC562', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(72, 'OKI MC573', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(73, 'OKI MC861', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(74, 'Panasonic KX-MB2000RU', 61, 0, 0, 'panasonic.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(75, 'PT-MZ10KE', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(76, 'PT-VX41', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(77, 'Rave 522AA', 33, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(78, 'DZ570E', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(79, 'DZ6700', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(80, 'Rcq80', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(81, 'RZ12K', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(82, 'RZ660', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(83, 'RZ770', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(84, 'RZ970', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(85, 'XVR-5216', 66, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(86, 'HWg-STE', 68, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(87, 'Computer', 1, 0, 0, '');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(88, 'Mobile Phone', 1, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(89, 'Switch', 1, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(90, 'Projectiondesign F22', 34, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(91, 'DS-I252', 36, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(92, 'LTV-CNE-720-48', 37, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(93, 'U-100', 38, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(94, 'TAU-8', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(95, 'SIP-T21P E2', 39, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(96, 'A510 IP', 40, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(97, 'W60B', 39, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(98, 'TAU-2M', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(99, 'PAP2T', 41, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(100, 'VP-12', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(101, 'SIP-T23P', 39, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(102, 'SPA-2102', 16, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(103, 'RB760iGS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(104, 'MES2324B', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(105, 'MES2324FB', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(106, 'MES2124P', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(107, 'MES2428P', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(108, 'Symmetra LX 16000', 20, 0, 0, 'symmetra.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(109, 'SNR-UPS-ONT20', 6, 0, 0, 'ups.cfg');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `device_ports`
---
-
-CREATE TABLE `device_ports` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `snmp_index` int(11) DEFAULT NULL,
-  `port` int(11) DEFAULT NULL,
-  `ifName` varchar(40) DEFAULT NULL,
-  `port_name` varchar(40) DEFAULT NULL,
-  `comment` varchar(50) DEFAULT NULL,
-  `target_port_id` int(11) NOT NULL DEFAULT 0,
-  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `last_mac_count` int(11) DEFAULT 0,
-  `uplink` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios` tinyint(1) NOT NULL DEFAULT 0,
-  `skip` tinyint(1) NOT NULL DEFAULT 0,
-  `vlan` int(11) NOT NULL DEFAULT 1,
-  `tagged_vlan` varchar(250) DEFAULT NULL,
-  `untagged_vlan` varchar(250) DEFAULT NULL,
-  `forbidden_vlan` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `device_types`
---
-
-CREATE TABLE `device_types` (
-  `id` int(11) NOT NULL,
-  `name.russian` varchar(50) DEFAULT NULL,
-  `name.english` varchar(50) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `device_types`
---
-
-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, 'Точка доступа', 'Access Point');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(5, 'Сетевое устройство', 'Network device');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `dhcp_log`
---
-
-CREATE TABLE `dhcp_log` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(17) NOT NULL,
-  `ip_int` bigint(20) UNSIGNED NOT NULL,
-  `ip` varchar(15) NOT NULL,
-  `action` varchar(10) NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `auth_id` bigint(20) UNSIGNED NOT 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
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `dhcp_queue`
---
-
-CREATE TABLE `dhcp_queue` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(17) NOT NULL,
-  `ip` varchar(15) NOT NULL,
-  `action` varchar(10) NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `dhcp_hostname` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `dns_cache`
---
-
-CREATE TABLE `dns_cache` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `dns` varchar(250) DEFAULT NULL,
-  `ip` bigint(20) UNSIGNED DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `dns_queue`
---
-
-CREATE TABLE `dns_queue` (
-  `id` int(11) NOT NULL,
-  `auth_id` int(11) DEFAULT NULL,
-  `name_type` varchar(10) NOT NULL DEFAULT 'A',
-  `name` varchar(200) DEFAULT NULL,
-  `type` varchar(10) NOT NULL DEFAULT 'add',
-  `value` varchar(100) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Filter_list`
---
-
-CREATE TABLE `Filter_list` (
-  `id` int(11) NOT NULL,
-  `name` varchar(50) DEFAULT NULL,
-  `comment` varchar(250) DEFAULT NULL,
-  `proto` varchar(10) DEFAULT NULL,
-  `dst` varchar(253) DEFAULT NULL,
-  `dstport` varchar(20) DEFAULT NULL,
-  `srcport` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
-  `type` int(10) UNSIGNED NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Filter_list`
---
-
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(1, 'pop3', NULL, 'tcp', '0/0', '110', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(3, 'http', NULL, 'tcp', '0/0', '80', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(4, 'https', NULL, 'tcp', '0/0', '443', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(5, 'icq', NULL, 'tcp', '0/0', '5190', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(6, 'jabber', NULL, 'tcp', '0/0', '5222', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(9, 'allow_all', 'любой трафик', 'all', '0/0', '0', '0', 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(10, 'icmp', NULL, 'icmp', '0/0', '0', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(11, 'ftp', NULL, 'tcp', '0/0', '20-21', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(15, 'telnet', NULL, 'tcp', '0/0', '23', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(16, 'ssh', NULL, 'tcp', '0/0', '22', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(28, 'smtp', NULL, 'tcp', '0/0', '25', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(32, 'rdp', NULL, 'tcp', '0/0', '3389', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(40, 'ntp', NULL, 'udp', '0/0', '123', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(44, 'vnc', NULL, 'tcp', '0/0', '5800-5900', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(55, 'unprivileged tcp', NULL, 'tcp', '0/0', '1024-65500', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(76, 'ipsec', NULL, 'udp', '0/0', '500', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(77, 'isakmp', NULL, 'udp', '0/0', '4500', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(79, 'pop3s', NULL, 'tcp', '0/0', '995', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(80, 'smtps', NULL, 'tcp', '0/0', '465,587', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(81, 'imap', NULL, 'tcp', '0/0', '143', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(82, 'imaps', NULL, 'tcp', '0/0', '993', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(83, 'unprivileged udp', NULL, 'udp', '0/0', '1024-65000', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(84, 'pptp', NULL, 'tcp', '0/0', '1723', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(85, 'openvpn-udp', NULL, 'udp', '0/0', '1194', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(90, 'dns_udp', NULL, 'udp', '0/0', '53', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(91, 'dns_tcp', NULL, 'tcp', '0/0', '53', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(94, 'squid', NULL, 'tcp', '0/0', '3128', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(101, 'snmp', NULL, 'udp', '0/0', '161', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(105, 'http_udp', NULL, 'udp', '0/0', '80', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(106, 'https_udp', NULL, 'udp', '0/0', '443', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(107, 'l2tp-ipsec', NULL, 'udp', '0/0', '1701,4500,500', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(108, 'gre', NULL, 'gre', '0/0', NULL, NULL, 0);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `gateway_subnets`
---
-
-CREATE TABLE `gateway_subnets` (
-  `id` int(11) NOT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `subnet_id` int(11) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Group_filters`
---
-
-CREATE TABLE `Group_filters` (
-  `id` int(11) NOT NULL,
-  `group_id` int(11) NOT NULL DEFAULT 0,
-  `filter_id` int(11) NOT NULL DEFAULT 0,
-  `order` int(11) NOT NULL DEFAULT 0,
-  `action` tinyint(1) NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Group_filters`
---
-
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(1, 2, 90, 1, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(2, 2, 91, 2, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(3, 2, 11, 3, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(5, 2, 3, 4, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(6, 2, 105, 5, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(7, 2, 4, 6, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(8, 2, 106, 7, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(9, 2, 10, 8, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(10, 2, 81, 9, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(11, 2, 82, 10, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(15, 2, 40, 11, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(16, 2, 1, 12, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(17, 2, 79, 13, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(18, 2, 80, 14, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(19, 1, 9, 1, 1);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `filter_instances`
---
-
-CREATE TABLE `filter_instances` (
-  `id` int(11) NOT NULL,
-  `name` varchar(50) DEFAULT NULL,
-  `comment` varchar(200) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `filter_instances`
---
-
-INSERT INTO `filter_instances` VALUES(1, 'default', NULL);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Group_list`
---
-
-CREATE TABLE `Group_list` (
-  `id` int(11) NOT NULL,
-  `instance_id` int(11) NOT NULL DEFAULT 1,
-  `group_name` varchar(50) DEFAULT NULL,
-  `comment` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Group_list`
---
-
-INSERT INTO `Group_list` VALUES(0, 1, 'default', NULL);
-INSERT INTO `Group_list` VALUES(1, 1, 'Allow all', 'Разрешено всё');
-INSERT INTO `Group_list` VALUES(2, 1, 'Users', 'Для пользователей');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `mac_history`
---
-
-CREATE TABLE `mac_history` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(12) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `device_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `port_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `ip` varchar(16) NOT NULL DEFAULT '',
-  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `dhcp_hostname` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `mac_vendors`
---
-
-CREATE TABLE `mac_vendors` (
-  `id` int(11) NOT NULL,
-  `oui` varchar(20) DEFAULT NULL,
-  `companyName` varchar(255) DEFAULT NULL,
-  `companyAddress` varchar(255) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `OU`
---
-
-CREATE TABLE `OU` (
-  `id` int(11) NOT NULL,
-  `ou_name` varchar(40) DEFAULT NULL,
-  `comment` varchar(250) DEFAULT NULL,
-  `default_users` tinyint(1) NOT NULL DEFAULT 0,
-  `default_hotspot` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios_dir` varchar(255) DEFAULT NULL,
-  `nagios_host_use` varchar(50) DEFAULT NULL,
-  `nagios_ping` tinyint(1) NOT NULL DEFAULT 1,
-  `nagios_default_service` varchar(100) DEFAULT NULL,
-  `enabled` int(11) NOT NULL DEFAULT 0,
-  `filter_group_id` int(11) NOT NULL DEFAULT 0,
-  `queue_id` int(11) NOT NULL DEFAULT 0,
-  `dynamic` tinyint(1) NOT NULL DEFAULT 0,
-  `life_duration` DECIMAL(10,2) NOT NULL DEFAULT '24'
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `OU`
---
-
-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`) VALUES(0, '!Всё', NULL, 0, 0, '/etc/nagios/any', 'generic-host', 1, NULL, 0, 0, 0);
-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`) VALUES(1, 'Сервера', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 0);
-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`) VALUES(2, 'Администраторы', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0);
-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`) VALUES(3, 'Пользователи', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4);
-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`) VALUES(4, 'VOIP', NULL, 0, 0, 'voip', 'voip', 1, NULL, 1, 4, 5);
-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`) VALUES(5, 'IPCAM', NULL, 0, 0, 'videocam', 'ip-cam', 1, NULL, 0, 0, 0);
-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`) VALUES(6, 'Принтеры', NULL, 0, 0, 'printers', 'printers', 1, 'printer-service', 0, 0, 0);
-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`) VALUES(7, 'Свичи', NULL, 0, 0, 'switches', 'switches', 1, NULL, 0, 0, 0);
-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`) VALUES(8, 'UPS', NULL, 0, 0, 'ups', 'ups', 1, NULL, 0, 0, 0);
-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`) VALUES(9, 'Охрана', NULL, 0, 0, 'security', 'security', 1, NULL, 0, 0, 0);
-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`) VALUES(10, 'Роутеры', NULL, 0, 0, 'routers', 'routers', 1, NULL, 0, 0, 0);
-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`) VALUES(11, 'WiFi AP', NULL, 0, 0, 'ap', 'ap', 1, NULL, 0, 0, 0);
-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`) VALUES(12, 'WiFi', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4);
-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`) VALUES(13, 'VPN', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0);
-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`) VALUES(14, 'DHCP', NULL, 1, 0, NULL, NULL, 1, NULL, 0, 0, 0);
-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`) VALUES(15, 'Гости', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Queue_list`
---
-
-CREATE TABLE `Queue_list` (
-  `id` int(11) NOT NULL,
-  `queue_name` varchar(20) NOT NULL,
-  `Download` int(11) NOT NULL DEFAULT 0,
-  `Upload` int(11) NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Queue_list`
---
-
-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);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `remote_syslog`
---
-
-CREATE TABLE `remote_syslog` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `date` timestamp NOT NULL DEFAULT current_timestamp(),
-  `device_id` bigint(20) UNSIGNED NOT NULL,
-  `ip` varchar(15) NOT NULL,
-  `message` text NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `sessions`
---
-
-CREATE TABLE `sessions` (
-  `id` varchar(128) NOT NULL,
-  `data` text NOT NULL,
-  `last_accessed` int(11) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `user_sessions`
---
-
-CREATE TABLE `user_sessions` (
-  `id` int(11) NOT NULL,
-  `session_id` varchar(128) NOT NULL,
-  `user_id` int(11) NOT NULL,
-  `ip_address` varchar(45) NOT NULL,
-  `user_agent` text NOT NULL,
-  `created_at` int(11) NOT NULL,
-  `last_activity` int(11) NOT NULL,
-  `is_active` tinyint(1) DEFAULT 1
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `subnets`
---
-
-CREATE TABLE `subnets` (
-  `id` int(11) NOT NULL,
-  `subnet` varchar(18) DEFAULT NULL,
-  `vlan_tag` int(11) NOT NULL DEFAULT 1,
-  `ip_int_start` bigint(20) NOT NULL,
-  `ip_int_stop` bigint(20) NOT NULL,
-  `dhcp_start` bigint(20) NOT NULL DEFAULT 0,
-  `dhcp_stop` bigint(20) NOT NULL DEFAULT 0,
-  `dhcp_lease_time` int(11) NOT NULL DEFAULT 480,
-  `gateway` bigint(20) NOT NULL DEFAULT 0,
-  `office` tinyint(1) NOT NULL DEFAULT 1,
-  `hotspot` tinyint(1) NOT NULL DEFAULT 0,
-  `vpn` tinyint(1) NOT NULL DEFAULT 0,
-  `free` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp` tinyint(1) NOT NULL DEFAULT 1,
-  `static` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp_update_hostname` tinyint(1) NOT NULL DEFAULT 0,
-  `discovery` tinyint(1) NOT NULL DEFAULT 1,
-  `comment` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Traffic_detail`
---
-
-CREATE TABLE `Traffic_detail` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `router_id` int(11) NOT NULL DEFAULT 0,
-  `timestamp` timestamp NULL DEFAULT NULL,
-  `proto` tinyint(3) UNSIGNED DEFAULT NULL,
-  `src_ip` int(10) UNSIGNED NOT NULL,
-  `dst_ip` int(10) UNSIGNED NOT NULL,
-  `src_port` smallint(5) UNSIGNED NOT NULL,
-  `dst_port` smallint(5) UNSIGNED NOT NULL,
-  `bytes` bigint(20) NOT NULL,
-  `pkt` int(10) UNSIGNED NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Unknown_mac`
---
-
-CREATE TABLE `Unknown_mac` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(12) DEFAULT NULL,
-  `port_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_auth`
---
-
-CREATE TABLE `User_auth` (
-  `id` int(11) NOT NULL,
-  `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `ou_id` int(11) DEFAULT NULL,
-  `ip` varchar(18) NOT NULL DEFAULT '',
-  `ip_int` bigint(10) UNSIGNED NOT NULL DEFAULT 0,
-  `save_traf` tinyint(1) NOT NULL DEFAULT 0,
-  `enabled` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp` tinyint(1) NOT NULL DEFAULT 1,
-  `filter_group_id` tinyint(1) NOT NULL DEFAULT 0,
-  `dynamic` tinyint(1) NOT NULL DEFAULT 0,
-  `eof` datetime DEFAULT NULL,
-  `deleted` tinyint(4) NOT NULL DEFAULT 0,
-  `comments` varchar(250) DEFAULT NULL,
-  `dns_name` varchar(253) DEFAULT NULL,
-  `dns_ptr_only` BOOLEAN NOT NULL DEFAULT FALSE,
-  `WikiName` varchar(250) DEFAULT NULL,
-  `dhcp_acl` text DEFAULT NULL,
-  `queue_id` int(11) NOT NULL DEFAULT 0,
-  `mac` varchar(20) NOT NULL DEFAULT '',
-  `dhcp_action` varchar(10) NOT NULL DEFAULT '',
-  `dhcp_option_set` VARCHAR(50) NULL DEFAULT NULL,
-  `dhcp_time` datetime NOT NULL DEFAULT current_timestamp(),
-  `dhcp_hostname` varchar(60) DEFAULT NULL,
-  `last_found` datetime NOT NULL DEFAULT current_timestamp(),
-  `arp_found` datetime DEFAULT NULL,
-  `blocked` tinyint(1) NOT NULL DEFAULT 0,
-  `day_quota` int(11) NOT NULL DEFAULT 0,
-  `month_quota` int(11) NOT NULL DEFAULT 0,
-  `device_model_id` int(11) DEFAULT 87,
-  `firmware` varchar(100) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `client-id` varchar(250) DEFAULT NULL,
-  `nagios` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios_status` varchar(10) NOT NULL DEFAULT '',
-  `nagios_handler` varchar(50) NOT NULL DEFAULT '',
-  `link_check` tinyint(1) NOT NULL DEFAULT 0,
-  `changed` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp_changed` int(11) NOT NULL DEFAULT 0,
-  `changed_time` datetime NOT NULL DEFAULT current_timestamp(),
-  `created_by` VARCHAR(10) NULL DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_auth_alias`
---
-
-CREATE TABLE `User_auth_alias` (
-  `id` int(11) NOT NULL,
-  `auth_id` int(11) NOT NULL,
-  `alias` varchar(100) DEFAULT NULL,
-  `description` varchar(100) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_list`
---
-
-CREATE TABLE `User_list` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `login` varchar(255) DEFAULT NULL,
-  `fio` varchar(255) DEFAULT NULL,
-  `enabled` tinyint(1) NOT NULL DEFAULT 1,
-  `blocked` tinyint(1) NOT NULL DEFAULT 0,
-  `deleted` tinyint(1) NOT NULL DEFAULT 0,
-  `ou_id` int(11) NOT NULL DEFAULT 0,
-  `device_id` int(11) DEFAULT NULL,
-  `filter_group_id` int(11) NOT NULL DEFAULT 0,
-  `queue_id` int(11) NOT NULL DEFAULT 0,
-  `day_quota` int(11) NOT NULL DEFAULT 0,
-  `month_quota` int(11) NOT NULL DEFAULT 0,
-  `permanent` BOOLEAN NOT NULL DEFAULT FALSE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_stats`
---
-
-CREATE TABLE `User_stats` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `router_id` bigint(20) UNSIGNED DEFAULT 0,
-  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
-  `byte_in` bigint(20) NOT NULL DEFAULT 0,
-  `byte_out` bigint(20) NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_stats_full`
---
-
-CREATE TABLE `User_stats_full` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `router_id` bigint(20) UNSIGNED DEFAULT 0,
-  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
-  `byte_in` bigint(20) NOT NULL DEFAULT 0,
-  `byte_out` bigint(20) NOT NULL DEFAULT 0,
-  `pkt_in` int(11) DEFAULT NULL,
-  `pkt_out` int(11) DEFAULT NULL,
-  `step` int(11) NOT NULL DEFAULT 600
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `variables`
---
-
-CREATE TABLE `variables` (
-  `id` int(11) NOT NULL,
-  `name` varchar(30) NOT NULL,
-  `value` varchar(255) DEFAULT NULL,
-  `clear_time` timestamp NOT NULL DEFAULT current_timestamp(),
-  `created` timestamp NOT NULL DEFAULT current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `vendors`
---
-
-CREATE TABLE `vendors` (
-  `id` int(11) NOT NULL,
-  `name` varchar(40) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `vendors`
---
-
-INSERT INTO `vendors` (`id`, `name`) VALUES(1, 'Unknown');
-INSERT INTO `vendors` (`id`, `name`) VALUES(2, 'Eltex');
-INSERT INTO `vendors` (`id`, `name`) VALUES(3, 'Huawei');
-INSERT INTO `vendors` (`id`, `name`) VALUES(4, 'Zyxel');
-INSERT INTO `vendors` (`id`, `name`) VALUES(5, 'Raisecom');
-INSERT INTO `vendors` (`id`, `name`) VALUES(6, 'SNR');
-INSERT INTO `vendors` (`id`, `name`) VALUES(7, 'Dlink');
-INSERT INTO `vendors` (`id`, `name`) VALUES(8, 'Allied Telesis');
-INSERT INTO `vendors` (`id`, `name`) VALUES(9, 'Mikrotik');
-INSERT INTO `vendors` (`id`, `name`) VALUES(10, 'NetGear');
-INSERT INTO `vendors` (`id`, `name`) VALUES(11, 'Ubiquiti');
-INSERT INTO `vendors` (`id`, `name`) VALUES(15, 'HP');
-INSERT INTO `vendors` (`id`, `name`) VALUES(16, 'Cisco');
-INSERT INTO `vendors` (`id`, `name`) VALUES(17, 'Maipu');
-INSERT INTO `vendors` (`id`, `name`) VALUES(18, 'Asus');
-INSERT INTO `vendors` (`id`, `name`) VALUES(19, 'Linux');
-INSERT INTO `vendors` (`id`, `name`) VALUES(20, 'APC');
-INSERT INTO `vendors` (`id`, `name`) VALUES(21, 'Schneider');
-INSERT INTO `vendors` (`id`, `name`) VALUES(33, 'QSC');
-INSERT INTO `vendors` (`id`, `name`) VALUES(34, 'Projectiondesign');
-INSERT INTO `vendors` (`id`, `name`) VALUES(35, 'Lenovo');
-INSERT INTO `vendors` (`id`, `name`) VALUES(36, 'HiWatch');
-INSERT INTO `vendors` (`id`, `name`) VALUES(37, 'LTV');
-INSERT INTO `vendors` (`id`, `name`) VALUES(38, 'Yeastar');
-INSERT INTO `vendors` (`id`, `name`) VALUES(39, 'Yealink');
-INSERT INTO `vendors` (`id`, `name`) VALUES(40, 'Gigaset');
-INSERT INTO `vendors` (`id`, `name`) VALUES(41, 'Linksys');
-INSERT INTO `vendors` (`id`, `name`) VALUES(42, 'Samsung');
-INSERT INTO `vendors` (`id`, `name`) VALUES(43, 'Supermicro');
-INSERT INTO `vendors` (`id`, `name`) VALUES(44, 'RDP');
-INSERT INTO `vendors` (`id`, `name`) VALUES(45, 'SANYO');
-INSERT INTO `vendors` (`id`, `name`) VALUES(46, 'Extreme');
-INSERT INTO `vendors` (`id`, `name`) VALUES(47, 'Intel');
-INSERT INTO `vendors` (`id`, `name`) VALUES(48, 'Micron');
-INSERT INTO `vendors` (`id`, `name`) VALUES(49, 'Gigabyte');
-INSERT INTO `vendors` (`id`, `name`) VALUES(50, 'Acer');
-INSERT INTO `vendors` (`id`, `name`) VALUES(51, 'Seagate');
-INSERT INTO `vendors` (`id`, `name`) VALUES(52, 'SanDisk');
-INSERT INTO `vendors` (`id`, `name`) VALUES(53, 'Toshiba');
-INSERT INTO `vendors` (`id`, `name`) VALUES(54, 'Kingston');
-INSERT INTO `vendors` (`id`, `name`) VALUES(55, 'AddPac');
-INSERT INTO `vendors` (`id`, `name`) VALUES(56, 'Devline');
-INSERT INTO `vendors` (`id`, `name`) VALUES(57, 'Canon');
-INSERT INTO `vendors` (`id`, `name`) VALUES(58, 'Brother');
-INSERT INTO `vendors` (`id`, `name`) VALUES(59, 'Epson');
-INSERT INTO `vendors` (`id`, `name`) VALUES(60, 'IP-COM');
-INSERT INTO `vendors` (`id`, `name`) VALUES(61, 'Panasonic');
-INSERT INTO `vendors` (`id`, `name`) VALUES(62, 'OKI');
-INSERT INTO `vendors` (`id`, `name`) VALUES(63, 'Apple');
-INSERT INTO `vendors` (`id`, `name`) VALUES(64, 'Eaton');
-INSERT INTO `vendors` (`id`, `name`) VALUES(65, 'Barco');
-INSERT INTO `vendors` (`id`, `name`) VALUES(66, 'Trassir');
-INSERT INTO `vendors` (`id`, `name`) VALUES(67, 'Testo');
-INSERT INTO `vendors` (`id`, `name`) VALUES(68, 'Hw-group');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `version`
---
-
-CREATE TABLE `version` (
-  `id` int(11) NOT NULL DEFAULT 1,
-  `version` varchar(10) NOT NULL DEFAULT '2.4.14'
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `version`
---
-
-INSERT INTO `version` (`id`, `version`) VALUES(1, '2.7.0');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Wan_stats`
---
-
-CREATE TABLE `Wan_stats` (
-  `id` int(11) NOT NULL,
-  `time` datetime NOT NULL DEFAULT current_timestamp(),
-  `router_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,
-  `forward_in` 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;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `worklog`
---
-
-CREATE TABLE `worklog` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `customer` varchar(50) NOT NULL DEFAULT 'system',
-  `ip` varchar(18) NOT NULL DEFAULT '127.0.0.1',
-  `message` text NOT NULL,
-  `level` int(11) NOT NULL DEFAULT 1
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
-
---
--- Индексы сохранённых таблиц
---
-
---
--- Индексы таблицы `acl`
---
-ALTER TABLE `acl`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `ad_comp_cache`
---
-ALTER TABLE `ad_comp_cache`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `comp_name` (`name`);
-
---
--- Индексы таблицы `auth_rules`
---
-ALTER TABLE `auth_rules`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `rule` (`rule`),
-  ADD KEY `user_id` (`user_id`);
-
---
--- Индексы таблицы `building`
---
-ALTER TABLE `building`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `config`
---
-ALTER TABLE `config`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `option` (`option_id`);
-
---
--- Индексы таблицы `config_options`
---
-ALTER TABLE `config_options`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `connections`
---
-ALTER TABLE `connections`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `auth_id` (`auth_id`),
-  ADD KEY `device_id` (`device_id`,`port_id`);
-
---
--- Индексы таблицы `Customers`
---
-ALTER TABLE `Customers`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `devices`
---
-ALTER TABLE `devices`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `ip` (`ip`),
-  ADD KEY `device_type` (`device_type`);
-
---
--- Индексы таблицы `device_l3_interfaces`
---
-ALTER TABLE `device_l3_interfaces`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `device_models`
---
-ALTER TABLE `device_models`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `device_ports`
---
-ALTER TABLE `device_ports`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `device_id` (`device_id`),
-  ADD KEY `port` (`port`),
-  ADD KEY `target_port_id` (`target_port_id`);
-
---
--- Индексы таблицы `device_types`
---
-ALTER TABLE `device_types`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `dhcp_log`
---
-ALTER TABLE `dhcp_log`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`action`);
-
---
--- Индексы таблицы `dhcp_queue`
---
-ALTER TABLE `dhcp_queue`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`action`);
-
---
--- Индексы таблицы `dns_cache`
---
-ALTER TABLE `dns_cache`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `dns` (`dns`,`ip`),
-  ADD KEY `timestamp` (`timestamp`);
-
---
--- Индексы таблицы `Filter_list`
---
-ALTER TABLE `Filter_list`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `Name` (`name`);
-
---
--- Индексы таблицы `gateway_subnets`
---
-ALTER TABLE `gateway_subnets`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `Group_filters`
---
-ALTER TABLE `Group_filters`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `GroupId` (`group_id`,`filter_id`);
-
---
--- Индексы таблицы `Group_list`
---
-ALTER TABLE `Group_list`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `mac_history`
---
-ALTER TABLE `mac_history`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `mac` (`mac`,`timestamp`),
-  ADD KEY `ip` (`ip`,`timestamp`),
-  ADD KEY `timestamp` (`timestamp`) USING BTREE,
-  ADD KEY `mac_2` (`mac`),
-  ADD KEY `ip_2` (`ip`);
-
---
--- Индексы таблицы `mac_vendors`
---
-ALTER TABLE `mac_vendors`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `oui` (`oui`);
-
---
--- Индексы таблицы `OU`
---
-ALTER TABLE `OU`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `Queue_list`
---
-ALTER TABLE `Queue_list`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `id` (`id`);
-
---
--- Индексы таблицы `remote_syslog`
---
-ALTER TABLE `remote_syslog`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `date` (`date`,`device_id`,`ip`);
-
---
--- Индексы таблицы `sessions`
---
-ALTER TABLE `sessions`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `last_accessed` (`last_accessed`);
-
---
--- Индексы таблицы `user_sessions`
---
-ALTER TABLE `user_sessions`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `session_id` (`session_id`),
-  ADD KEY `user_id` (`user_id`),
-  ADD KEY `is_active` (`is_active`);
-
---
--- Индексы таблицы `subnets`
---
-ALTER TABLE `subnets`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `ip_int_start` (`ip_int_start`,`ip_int_stop`),
-  ADD KEY `dhcp` (`dhcp`,`office`,`hotspot`,`static`);
-
---
--- Индексы таблицы `Traffic_detail`
---
-ALTER TABLE `Traffic_detail`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `src` (`auth_id`,`timestamp`,`router_id`,`src_ip`),
-  ADD KEY `dst` (`auth_id`,`timestamp`,`router_id`,`dst_ip`);
-
---
--- Индексы таблицы `Unknown_mac`
---
-ALTER TABLE `Unknown_mac`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`device_id`,`port_id`,`mac`);
-
---
--- Индексы таблицы `User_auth`
---
-ALTER TABLE `User_auth`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `auth_index` (`id`,`user_id`,`ip_int`,`mac`,`ip`,`deleted`) USING BTREE,
-  ADD KEY `deleted` (`deleted`),
-  ADD KEY `ou_id` (`ou_id`);
-
---
--- Индексы таблицы `User_auth_alias`
---
-ALTER TABLE `User_auth_alias`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `auth_id` (`auth_id`);
-
---
--- Индексы таблицы `User_list`
---
-ALTER TABLE `User_list`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `users` (`id`,`ou_id`,`enabled`,`blocked`,`deleted`);
-
---
--- Индексы таблицы `User_stats`
---
-ALTER TABLE `User_stats`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`auth_id`,`router_id`);
-
---
--- Индексы таблицы `User_stats_full`
---
-ALTER TABLE `User_stats_full`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`auth_id`,`router_id`);
-
---
--- Индексы таблицы `variables`
---
-ALTER TABLE `variables`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `name` (`name`),
-  ADD KEY `clear_time` (`clear_time`,`created`);
-
---
--- Индексы таблицы `vendors`
---
-ALTER TABLE `vendors`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `version`
---
-ALTER TABLE `version`
-  ADD UNIQUE KEY `id` (`id`);
-
---
--- Индексы таблицы `Wan_stats`
---
-ALTER TABLE `Wan_stats`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `main` (`time`,`router_id`,`interface_id`),
-  ADD KEY `times` (`time`);
-
---
--- Индексы таблицы `worklog`
---
-ALTER TABLE `worklog`
-  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`);
-
-
---
--- Индексы таблицы `dns_queue`
---
-ALTER TABLE `dns_queue`
-  ADD PRIMARY KEY (`id`);
-
-
---
--- Индексы таблицы `filter_instances`
---
-ALTER TABLE `filter_instances`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `name` (`name`);
-
---
--- AUTO_INCREMENT для сохранённых таблиц
---
-
---
--- AUTO_INCREMENT для таблицы `acl`
---
-ALTER TABLE `acl`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `ad_comp_cache`
---
-ALTER TABLE `ad_comp_cache`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `auth_rules`
---
-ALTER TABLE `auth_rules`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `building`
---
-ALTER TABLE `building`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `config`
---
-ALTER TABLE `config`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `config_options`
---
-ALTER TABLE `config_options`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `connections`
---
-ALTER TABLE `connections`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Customers`
---
-ALTER TABLE `Customers`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `devices`
---
-ALTER TABLE `devices`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `device_l3_interfaces`
---
-ALTER TABLE `device_l3_interfaces`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `device_models`
---
-ALTER TABLE `device_models`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `device_ports`
---
-ALTER TABLE `device_ports`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `device_types`
---
-ALTER TABLE `device_types`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `dhcp_log`
---
-ALTER TABLE `dhcp_log`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `dhcp_queue`
---
-ALTER TABLE `dhcp_queue`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `dns_cache`
---
-ALTER TABLE `dns_cache`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `dns_queue`
---
-ALTER TABLE `dns_queue`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Filter_list`
---
-ALTER TABLE `Filter_list`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `gateway_subnets`
---
-ALTER TABLE `gateway_subnets`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Group_filters`
---
-ALTER TABLE `Group_filters`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Group_list`
---
-ALTER TABLE `Group_list`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `mac_history`
---
-ALTER TABLE `mac_history`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `mac_vendors`
---
-ALTER TABLE `mac_vendors`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `OU`
---
-ALTER TABLE `OU`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Queue_list`
---
-ALTER TABLE `Queue_list`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `remote_syslog`
---
-ALTER TABLE `remote_syslog`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `user_sessions`
---
-ALTER TABLE `user_sessions`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `subnets`
---
-ALTER TABLE `subnets`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Traffic_detail`
---
-ALTER TABLE `Traffic_detail`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Unknown_mac`
---
-ALTER TABLE `Unknown_mac`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_auth`
---
-ALTER TABLE `User_auth`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_auth_alias`
---
-ALTER TABLE `User_auth_alias`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_list`
---
-ALTER TABLE `User_list`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_stats`
---
-ALTER TABLE `User_stats`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_stats_full`
---
-ALTER TABLE `User_stats_full`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `variables`
---
-ALTER TABLE `variables`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `vendors`
---
-ALTER TABLE `vendors`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Wan_stats`
---
-ALTER TABLE `Wan_stats`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `filter_instances`
---
-ALTER TABLE `filter_instances`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `worklog`
---
-ALTER TABLE `worklog`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-COMMIT;
-
-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

+ 0 - 1688
docs/mysql/2-8-1/mysql.sql

@@ -1,1688 +0,0 @@
--- phpMyAdmin SQL Dump
--- version 5.2.1
--- https://www.phpmyadmin.net/
---
--- Хост: localhost
--- Время создания: Дек 03 2024 г., 14:57
--- Версия сервера: 10.11.6-MariaDB-0+deb12u1-log
--- Версия PHP: 8.2.26
-
-SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
-START TRANSACTION;
-SET time_zone = "+00:00";
-
-
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8mb4 */;
-
---
--- База данных: `stat`
---
-
-CREATE TABLE `device_filter_instances` (
-   `id` INT NOT NULL AUTO_INCREMENT ,
-   `instance_id` INT NULL DEFAULT NULL ,
-   `device_id` INT NULL DEFAULT NULL , PRIMARY KEY (`id`)
-) ENGINE = InnoDB;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `acl`
---
-
-CREATE TABLE `acl` (
-  `id` int(11) NOT NULL,
-  `name` varchar(30) NOT NULL,
-  `description.english` varchar(250) NOT NULL,
-  `description.russian` varchar(250) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `ad_comp_cache`
---
-
-CREATE TABLE `ad_comp_cache` (
-  `id` int(11) NOT NULL,
-  `name` varchar(63) NOT NULL,
-  `last_found` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `auth_rules`
---
-
-CREATE TABLE `auth_rules` (
-  `id` int(11) NOT NULL,
-  `user_id` int(11) DEFAULT NULL,
-  `ou_id` int(11) DEFAULT NULL,
-  `type` int(11) NOT NULL,
-  `rule` varchar(40) DEFAULT NULL,
-  `comment` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `building`
---
-
-CREATE TABLE `building` (
-  `id` int(11) NOT NULL,
-  `name` varchar(50) NOT NULL,
-  `comment` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `building`
---
-
-INSERT INTO `building` (`id`, `name`, `comment`) VALUES(1, 'Earth', 'Somewhere');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `config`
---
-
-CREATE TABLE `config` (
-  `id` int(11) NOT NULL,
-  `option_id` int(11) DEFAULT NULL,
-  `value` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `config`
---
-
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(1, 1, '0');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(2, 11, 'public');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(3, 32, 'ORG');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(123, 19, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(124, 35, '120');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(125, 9, '2');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(126, 41, '/opt/Eye/scripts/fetch_new_arp.pl');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(127, 26, '3');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(128, 27, '10');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(129, 48, '90');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(130, 49, '365');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(131, 47, '90');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(132, 53, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(133, 55, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(134, 56, '30');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(135, 34, '0');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(137, 65, '0');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(142, 54, '');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(143, 17, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(144, 37, '/opt/Eye/scripts/sync_mikrotik.pl');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(145, 23, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(148, 22, '1');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `config_options`
---
-
-CREATE TABLE `config_options` (
-  `id` int(11) NOT NULL,
-  `option_name` varchar(50) NOT NULL,
-  `description.russian` text DEFAULT NULL,
-  `description.english` text DEFAULT NULL,
-  `draft` tinyint(1) NOT NULL DEFAULT 0,
-  `uniq` tinyint(1) NOT NULL DEFAULT 1,
-  `type` varchar(100) NOT NULL,
-  `default_value` varchar(250) DEFAULT NULL,
-  `min_value` int(11) NOT NULL DEFAULT 0,
-  `max_value` int(11) NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `config_options`
---
-
-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 VERBOSE work 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 сообщения для уровней сообщений WARNING & ERROR', 'Send e-mail messages for message levels WARNING & ERROR', 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);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `connections`
---
-
-CREATE TABLE `connections` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `device_id` bigint(20) UNSIGNED NOT NULL,
-  `port_id` bigint(20) UNSIGNED NOT NULL,
-  `auth_id` bigint(20) UNSIGNED NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Customers`
---
-
-CREATE TABLE `Customers` (
-  `id` int(11) NOT NULL,
-  `Login` varchar(20) DEFAULT 'NULL',
-  `comment` varchar(100) DEFAULT 'NULL',
-  `password` varchar(255) DEFAULT 'NULL',
-  `api_key` varchar(255) DEFAULT NULL,
-  `rights` tinyint(1) NOT NULL DEFAULT 3
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Customers`
---
-
-INSERT INTO `Customers` (`id`, `Login`, `comment`, `password`, `api_key`, `rights`) VALUES(1, 'admin', '', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'Kot5miegiequaeseim3veequeiW2Iv3L', 1);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `devices`
---
-
-CREATE TABLE `devices` (
-  `id` int(11) NOT NULL,
-  `device_type` int(11) NOT NULL DEFAULT 1,
-  `device_model_id` int(11) DEFAULT 89,
-  `firmware` varchar(100) DEFAULT NULL,
-  `vendor_id` int(11) NOT NULL DEFAULT 1,
-  `device_name` varchar(50) DEFAULT NULL,
-  `building_id` int(11) NOT NULL DEFAULT 1,
-  `ip` varchar(15) DEFAULT NULL,
-  `ip_int` BIGINT(10) UNSIGNED DEFAULT NULL,
-  `login` varchar(50) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `protocol` int(11) NOT NULL DEFAULT 0,
-  `control_port` int(11) NOT NULL DEFAULT 23,
-  `port_count` int(11) NOT NULL DEFAULT 0,
-  `SN` varchar(80) DEFAULT NULL,
-  `comment` varchar(255) DEFAULT NULL,
-  `snmp_version` tinyint(4) NOT NULL DEFAULT 0,
-  `snmp3_auth_proto` varchar(10) NOT NULL DEFAULT 'sha512',
-  `snmp3_priv_proto` varchar(10) NOT NULL DEFAULT 'aes128',
-  `snmp3_user_rw` varchar(20) DEFAULT NULL,
-  `snmp3_user_rw_password` varchar(20) DEFAULT NULL,
-  `snmp3_user_ro` varchar(20) DEFAULT NULL,
-  `snmp3_user_ro_password` varchar(20) DEFAULT NULL,
-  `community` varchar(50) NOT NULL DEFAULT 'public',
-  `rw_community` varchar(50) NOT NULL DEFAULT 'private',
-  `fdb_snmp_index` tinyint(1) NOT NULL DEFAULT 0,
-  `discovery` tinyint(1) NOT NULL DEFAULT 1,
-  `netflow_save` tinyint(1) NOT NULL DEFAULT 0,
-  `user_acl` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios` tinyint(1) NOT NULL DEFAULT 0,
-  `active` tinyint(1) NOT NULL DEFAULT 1,
-  `nagios_status` varchar(10) NOT NULL DEFAULT 'UP',
-  `queue_enabled` tinyint(1) NOT NULL DEFAULT 0,
-  `connected_user_only` tinyint(1) NOT NULL DEFAULT 1,
-  `user_id` int(11) DEFAULT NULL,
-  `deleted` tinyint(1) NOT NULL DEFAULT 0,
-  `discovery_locked` tinyint(1) NOT NULL DEFAULT 0,
-  `locked_timestamp` timestamp NULL DEFAULT current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `device_l3_interfaces`
---
-
-CREATE TABLE `device_l3_interfaces` (
-  `id` int(11) NOT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `snmpin` int(11) DEFAULT NULL,
-  `interface_type` int(11) NOT NULL DEFAULT 0,
-  `name` varchar(100) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `device_models`
---
-
-CREATE TABLE `device_models` (
-  `id` int(11) NOT NULL,
-  `model_name` varchar(200) DEFAULT NULL,
-  `vendor_id` int(11) DEFAULT 1,
-  `poe_in` tinyint(1) NOT NULL DEFAULT 0,
-  `poe_out` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios_template` varchar(200) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `device_models`
---
-
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(1, '2011LS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(2, '2011UAS-2HnD', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(3, 'AT-8000S', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(4, 'AT-8100S/48POE', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(5, 'AT-9000/28', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(6, 'AT-GS950/24', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(7, 'CCR1009-7G-1C-1S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(8, 'CCR1036-8G-2S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(10, 'CRS317-1G-16S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(11, 'CRS326-24S+2Q+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(12, 'CRS328-24P-4S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(14, 'CRS328-4C-20S-4S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(15, 'DGS-3120-48TC', 7, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(16, 'ES-2024', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(17, 'ES-2024A', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(18, 'ES-2108', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(19, 'ES-2108-G', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(20, 'ES-3124-4F', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(21, 'GS110TP', 10, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(22, 'GS-4024', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(23, 'HP 1910', 15, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(24, 'ISCOM2110A-MA', 5, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(25, 'ISCOM2110EA-MA', 5, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(26, 'ISCOM2126EA-MA', 5, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(27, 'ISCOM2128EA-MA', 5, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(28, 'Linux server', 1, 0, 0, '');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(29, 'MES2124F', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(30, 'MES2124MB', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(31, 'MES5248', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(32, 'RB2011UAS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(33, 'RB3011UiAS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(34, 'RB960PGS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(35, 'RBD52G-5HacD2HnD', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(36, 'S2940-8G-v2', 6, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(37, 'S2980G-24T', 6, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(38, 'S3750G-24S-E', 6, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(39, 'S5300-52P-LI-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(40, 'S5320-52X-PWR-SI-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(41, 'S5321-28X-SI-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(42, 'S5321-52X-SI-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(43, 'S6320-54C-EI-48S-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(44, 'SNR-S2980G-24T', 6, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(45, 'V1910-16G', 15, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(46, 'V1910-24G-PoE', 15, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(47, 'Windows server', 1, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(48, 'WS-C2960G-24TC-L', 16, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(49, 'WS-C3560G-24TS-S', 16, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(50, 'x210-16GT', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(51, 'x210-24GT', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(52, 'x610-24Ts/X', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(53, 'x610-48Ts', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(54, 'XGS-4728', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(55, 'ZyWall 310', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(56, 'APC Smart-UPS_3000', 20, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(57, 'APC Smart-UPS_5000', 20, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(58, 'Schneider Smart-UPS_3000', 21, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(59, 'SMG-1016M', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(60, 'EATON 9PX 1500i RT 2U', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(61, 'EATON 9PX3000i_RT_2U', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(62, 'EATON 9PX_6000i', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(63, 'EATON PW9130_3000', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(64, 'EATON PW9130_3000VA-R', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(65, 'Epson WF-5620 Series', 59, 0, 0, 'epson.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(66, 'Epson WF-8590 Series', 59, 0, 0, 'epson.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(67, 'HP Officejet-7000', 15, 0, 0, 'hp.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(68, 'OKI C610', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(69, 'OKI MB472', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(70, 'OKI MB491', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(71, 'OKI MC562', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(72, 'OKI MC573', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(73, 'OKI MC861', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(74, 'Panasonic KX-MB2000RU', 61, 0, 0, 'panasonic.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(75, 'PT-MZ10KE', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(76, 'PT-VX41', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(77, 'Rave 522AA', 33, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(78, 'DZ570E', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(79, 'DZ6700', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(80, 'Rcq80', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(81, 'RZ12K', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(82, 'RZ660', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(83, 'RZ770', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(84, 'RZ970', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(85, 'XVR-5216', 66, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(86, 'HWg-STE', 68, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(87, 'Computer', 1, 0, 0, '');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(88, 'Mobile Phone', 1, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(89, 'Switch', 1, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(90, 'Projectiondesign F22', 34, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(91, 'DS-I252', 36, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(92, 'LTV-CNE-720-48', 37, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(93, 'U-100', 38, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(94, 'TAU-8', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(95, 'SIP-T21P E2', 39, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(96, 'A510 IP', 40, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(97, 'W60B', 39, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(98, 'TAU-2M', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(99, 'PAP2T', 41, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(100, 'VP-12', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(101, 'SIP-T23P', 39, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(102, 'SPA-2102', 16, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(103, 'RB760iGS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(104, 'MES2324B', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(105, 'MES2324FB', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(106, 'MES2124P', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(107, 'MES2428P', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(108, 'Symmetra LX 16000', 20, 0, 0, 'symmetra.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(109, 'SNR-UPS-ONT20', 6, 0, 0, 'ups.cfg');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `device_ports`
---
-
-CREATE TABLE `device_ports` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `snmp_index` int(11) DEFAULT NULL,
-  `port` int(11) DEFAULT NULL,
-  `ifName` varchar(40) DEFAULT NULL,
-  `port_name` varchar(40) DEFAULT NULL,
-  `comment` varchar(50) DEFAULT NULL,
-  `target_port_id` int(11) NOT NULL DEFAULT 0,
-  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `last_mac_count` int(11) DEFAULT 0,
-  `uplink` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios` tinyint(1) NOT NULL DEFAULT 0,
-  `skip` tinyint(1) NOT NULL DEFAULT 0,
-  `vlan` int(11) NOT NULL DEFAULT 1,
-  `tagged_vlan` varchar(250) DEFAULT NULL,
-  `untagged_vlan` varchar(250) DEFAULT NULL,
-  `forbidden_vlan` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `device_types`
---
-
-CREATE TABLE `device_types` (
-  `id` int(11) NOT NULL,
-  `name.russian` varchar(50) DEFAULT NULL,
-  `name.english` varchar(50) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `device_types`
---
-
-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, 'Точка доступа', 'Access Point');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(5, 'Сетевое устройство', 'Network device');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `dhcp_log`
---
-
-CREATE TABLE `dhcp_log` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(17) NOT NULL,
-  `ip_int` bigint(20) UNSIGNED NOT NULL,
-  `ip` varchar(15) NOT NULL,
-  `action` varchar(10) NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `auth_id` bigint(20) UNSIGNED NOT 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
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `dhcp_queue`
---
-
-CREATE TABLE `dhcp_queue` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(17) NOT NULL,
-  `ip` varchar(15) NOT NULL,
-  `action` varchar(10) NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `dhcp_hostname` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `dns_cache`
---
-
-CREATE TABLE `dns_cache` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `dns` varchar(250) DEFAULT NULL,
-  `ip` bigint(20) UNSIGNED DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `dns_queue`
---
-
-CREATE TABLE `dns_queue` (
-  `id` int(11) NOT NULL,
-  `auth_id` int(11) DEFAULT NULL,
-  `name_type` varchar(10) NOT NULL DEFAULT 'A',
-  `name` varchar(200) DEFAULT NULL,
-  `type` varchar(10) NOT NULL DEFAULT 'add',
-  `value` varchar(100) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Filter_list`
---
-
-CREATE TABLE `Filter_list` (
-  `id` int(11) NOT NULL,
-  `name` varchar(50) DEFAULT NULL,
-  `comment` varchar(250) DEFAULT NULL,
-  `proto` varchar(10) DEFAULT NULL,
-  `dst` varchar(253) DEFAULT NULL,
-  `dstport` varchar(20) DEFAULT NULL,
-  `srcport` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
-  `type` int(10) UNSIGNED NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Filter_list`
---
-
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(1, 'pop3', NULL, 'tcp', '0/0', '110', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(3, 'http', NULL, 'tcp', '0/0', '80', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(4, 'https', NULL, 'tcp', '0/0', '443', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(5, 'icq', NULL, 'tcp', '0/0', '5190', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(6, 'jabber', NULL, 'tcp', '0/0', '5222', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(9, 'allow_all', 'любой трафик', 'all', '0/0', '0', '0', 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(10, 'icmp', NULL, 'icmp', '0/0', '0', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(11, 'ftp', NULL, 'tcp', '0/0', '20-21', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(15, 'telnet', NULL, 'tcp', '0/0', '23', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(16, 'ssh', NULL, 'tcp', '0/0', '22', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(28, 'smtp', NULL, 'tcp', '0/0', '25', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(32, 'rdp', NULL, 'tcp', '0/0', '3389', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(40, 'ntp', NULL, 'udp', '0/0', '123', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(44, 'vnc', NULL, 'tcp', '0/0', '5800-5900', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(55, 'unprivileged tcp', NULL, 'tcp', '0/0', '1024-65500', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(76, 'ipsec', NULL, 'udp', '0/0', '500', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(77, 'isakmp', NULL, 'udp', '0/0', '4500', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(79, 'pop3s', NULL, 'tcp', '0/0', '995', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(80, 'smtps', NULL, 'tcp', '0/0', '465,587', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(81, 'imap', NULL, 'tcp', '0/0', '143', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(82, 'imaps', NULL, 'tcp', '0/0', '993', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(83, 'unprivileged udp', NULL, 'udp', '0/0', '1024-65000', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(84, 'pptp', NULL, 'tcp', '0/0', '1723', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(85, 'openvpn-udp', NULL, 'udp', '0/0', '1194', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(90, 'dns_udp', NULL, 'udp', '0/0', '53', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(91, 'dns_tcp', NULL, 'tcp', '0/0', '53', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(94, 'squid', NULL, 'tcp', '0/0', '3128', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(101, 'snmp', NULL, 'udp', '0/0', '161', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(105, 'http_udp', NULL, 'udp', '0/0', '80', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(106, 'https_udp', NULL, 'udp', '0/0', '443', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(107, 'l2tp-ipsec', NULL, 'udp', '0/0', '1701,4500,500', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(108, 'gre', NULL, 'gre', '0/0', NULL, NULL, 0);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `gateway_subnets`
---
-
-CREATE TABLE `gateway_subnets` (
-  `id` int(11) NOT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `subnet_id` int(11) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Group_filters`
---
-
-CREATE TABLE `Group_filters` (
-  `id` int(11) NOT NULL,
-  `group_id` int(11) NOT NULL DEFAULT 0,
-  `filter_id` int(11) NOT NULL DEFAULT 0,
-  `order` int(11) NOT NULL DEFAULT 0,
-  `action` tinyint(1) NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Group_filters`
---
-
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(1, 2, 90, 1, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(2, 2, 91, 2, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(3, 2, 11, 3, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(5, 2, 3, 4, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(6, 2, 105, 5, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(7, 2, 4, 6, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(8, 2, 106, 7, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(9, 2, 10, 8, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(10, 2, 81, 9, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(11, 2, 82, 10, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(15, 2, 40, 11, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(16, 2, 1, 12, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(17, 2, 79, 13, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(18, 2, 80, 14, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(19, 1, 9, 1, 1);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `filter_instances`
---
-
-CREATE TABLE `filter_instances` (
-  `id` int(11) NOT NULL,
-  `name` varchar(50) DEFAULT NULL,
-  `comment` varchar(200) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `filter_instances`
---
-
-INSERT INTO `filter_instances` VALUES(1, 'default', NULL);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Group_list`
---
-
-CREATE TABLE `Group_list` (
-  `id` int(11) NOT NULL,
-  `instance_id` int(11) NOT NULL DEFAULT 1,
-  `group_name` varchar(50) DEFAULT NULL,
-  `comment` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Group_list`
---
-
-INSERT INTO `Group_list` VALUES(0, 1, 'default', NULL);
-INSERT INTO `Group_list` VALUES(1, 1, 'Allow all', 'Разрешено всё');
-INSERT INTO `Group_list` VALUES(2, 1, 'Users', 'Для пользователей');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `mac_history`
---
-
-CREATE TABLE `mac_history` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(12) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `device_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `port_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `ip` varchar(16) NOT NULL DEFAULT '',
-  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `dhcp_hostname` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `mac_vendors`
---
-
-CREATE TABLE `mac_vendors` (
-  `id` int(11) NOT NULL,
-  `oui` varchar(20) DEFAULT NULL,
-  `companyName` varchar(255) DEFAULT NULL,
-  `companyAddress` varchar(255) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `OU`
---
-
-CREATE TABLE `OU` (
-  `id` int(11) NOT NULL,
-  `ou_name` varchar(40) DEFAULT NULL,
-  `comment` varchar(250) DEFAULT NULL,
-  `default_users` tinyint(1) NOT NULL DEFAULT 0,
-  `default_hotspot` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios_dir` varchar(255) DEFAULT NULL,
-  `nagios_host_use` varchar(50) DEFAULT NULL,
-  `nagios_ping` tinyint(1) NOT NULL DEFAULT 1,
-  `nagios_default_service` varchar(100) DEFAULT NULL,
-  `enabled` int(11) NOT NULL DEFAULT 0,
-  `filter_group_id` int(11) NOT NULL DEFAULT 0,
-  `queue_id` int(11) NOT NULL DEFAULT 0,
-  `dynamic` tinyint(1) NOT NULL DEFAULT 0,
-  `life_duration` DECIMAL(10,2) NOT NULL DEFAULT '24'
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `OU`
---
-
-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`) VALUES(0, '!Всё', NULL, 0, 0, '/etc/nagios/any', 'generic-host', 1, NULL, 0, 0, 0);
-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`) VALUES(1, 'Сервера', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 0);
-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`) VALUES(2, 'Администраторы', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0);
-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`) VALUES(3, 'Пользователи', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4);
-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`) VALUES(4, 'VOIP', NULL, 0, 0, 'voip', 'voip', 1, NULL, 1, 4, 5);
-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`) VALUES(5, 'IPCAM', NULL, 0, 0, 'videocam', 'ip-cam', 1, NULL, 0, 0, 0);
-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`) VALUES(6, 'Принтеры', NULL, 0, 0, 'printers', 'printers', 1, 'printer-service', 0, 0, 0);
-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`) VALUES(7, 'Свичи', NULL, 0, 0, 'switches', 'switches', 1, NULL, 0, 0, 0);
-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`) VALUES(8, 'UPS', NULL, 0, 0, 'ups', 'ups', 1, NULL, 0, 0, 0);
-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`) VALUES(9, 'Охрана', NULL, 0, 0, 'security', 'security', 1, NULL, 0, 0, 0);
-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`) VALUES(10, 'Роутеры', NULL, 0, 0, 'routers', 'routers', 1, NULL, 0, 0, 0);
-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`) VALUES(11, 'WiFi AP', NULL, 0, 0, 'ap', 'ap', 1, NULL, 0, 0, 0);
-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`) VALUES(12, 'WiFi', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4);
-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`) VALUES(13, 'VPN', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0);
-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`) VALUES(14, 'DHCP', NULL, 1, 0, NULL, NULL, 1, NULL, 0, 0, 0);
-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`) VALUES(15, 'Гости', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Queue_list`
---
-
-CREATE TABLE `Queue_list` (
-  `id` int(11) NOT NULL,
-  `queue_name` varchar(20) NOT NULL,
-  `Download` int(11) NOT NULL DEFAULT 0,
-  `Upload` int(11) NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Queue_list`
---
-
-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);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `remote_syslog`
---
-
-CREATE TABLE `remote_syslog` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `date` timestamp NOT NULL DEFAULT current_timestamp(),
-  `device_id` bigint(20) UNSIGNED NOT NULL,
-  `ip` varchar(15) NOT NULL,
-  `message` text NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `sessions`
---
-
-CREATE TABLE `sessions` (
-  `id` varchar(128) NOT NULL,
-  `data` text NOT NULL,
-  `last_accessed` int(11) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `user_sessions`
---
-
-CREATE TABLE `user_sessions` (
-  `id` int(11) NOT NULL,
-  `session_id` varchar(128) NOT NULL,
-  `user_id` int(11) NOT NULL,
-  `ip_address` varchar(45) NOT NULL,
-  `user_agent` text NOT NULL,
-  `created_at` int(11) NOT NULL,
-  `last_activity` int(11) NOT NULL,
-  `is_active` tinyint(1) DEFAULT 1
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `subnets`
---
-
-CREATE TABLE `subnets` (
-  `id` int(11) NOT NULL,
-  `subnet` varchar(18) DEFAULT NULL,
-  `vlan_tag` int(11) NOT NULL DEFAULT 1,
-  `ip_int_start` bigint(20) NOT NULL,
-  `ip_int_stop` bigint(20) NOT NULL,
-  `dhcp_start` bigint(20) NOT NULL DEFAULT 0,
-  `dhcp_stop` bigint(20) NOT NULL DEFAULT 0,
-  `dhcp_lease_time` int(11) NOT NULL DEFAULT 480,
-  `gateway` bigint(20) NOT NULL DEFAULT 0,
-  `office` tinyint(1) NOT NULL DEFAULT 1,
-  `hotspot` tinyint(1) NOT NULL DEFAULT 0,
-  `vpn` tinyint(1) NOT NULL DEFAULT 0,
-  `free` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp` tinyint(1) NOT NULL DEFAULT 1,
-  `static` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp_update_hostname` tinyint(1) NOT NULL DEFAULT 0,
-  `discovery` tinyint(1) NOT NULL DEFAULT 1,
-  `comment` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Traffic_detail`
---
-
-CREATE TABLE `Traffic_detail` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `router_id` int(11) NOT NULL DEFAULT 0,
-  `timestamp` timestamp NULL DEFAULT NULL,
-  `proto` tinyint(3) UNSIGNED DEFAULT NULL,
-  `src_ip` int(10) UNSIGNED NOT NULL,
-  `dst_ip` int(10) UNSIGNED NOT NULL,
-  `src_port` smallint(5) UNSIGNED NOT NULL,
-  `dst_port` smallint(5) UNSIGNED NOT NULL,
-  `bytes` bigint(20) NOT NULL,
-  `pkt` int(10) UNSIGNED NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Unknown_mac`
---
-
-CREATE TABLE `Unknown_mac` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(12) DEFAULT NULL,
-  `port_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_auth`
---
-
-CREATE TABLE `User_auth` (
-  `id` int(11) NOT NULL,
-  `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `ou_id` int(11) DEFAULT NULL,
-  `ip` varchar(18) NOT NULL DEFAULT '',
-  `ip_int` bigint(10) UNSIGNED NOT NULL DEFAULT 0,
-  `save_traf` tinyint(1) NOT NULL DEFAULT 0,
-  `enabled` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp` tinyint(1) NOT NULL DEFAULT 1,
-  `filter_group_id` tinyint(1) NOT NULL DEFAULT 0,
-  `dynamic` tinyint(1) NOT NULL DEFAULT 0,
-  `eof` datetime DEFAULT NULL,
-  `deleted` tinyint(4) NOT NULL DEFAULT 0,
-  `comments` varchar(250) DEFAULT NULL,
-  `dns_name` varchar(253) DEFAULT NULL,
-  `dns_ptr_only` BOOLEAN NOT NULL DEFAULT FALSE,
-  `WikiName` varchar(250) DEFAULT NULL,
-  `dhcp_acl` text DEFAULT NULL,
-  `queue_id` int(11) NOT NULL DEFAULT 0,
-  `mac` varchar(20) NOT NULL DEFAULT '',
-  `dhcp_action` varchar(10) NOT NULL DEFAULT '',
-  `dhcp_option_set` VARCHAR(50) NULL DEFAULT NULL,
-  `dhcp_time` datetime NOT NULL DEFAULT current_timestamp(),
-  `dhcp_hostname` varchar(60) DEFAULT NULL,
-  `last_found` datetime NOT NULL DEFAULT current_timestamp(),
-  `arp_found` datetime DEFAULT NULL,
-  `blocked` tinyint(1) NOT NULL DEFAULT 0,
-  `day_quota` int(11) NOT NULL DEFAULT 0,
-  `month_quota` int(11) NOT NULL DEFAULT 0,
-  `device_model_id` int(11) DEFAULT 87,
-  `firmware` varchar(100) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `client-id` varchar(250) DEFAULT NULL,
-  `nagios` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios_status` varchar(10) NOT NULL DEFAULT '',
-  `nagios_handler` varchar(50) NOT NULL DEFAULT '',
-  `link_check` tinyint(1) NOT NULL DEFAULT 0,
-  `changed` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp_changed` int(11) NOT NULL DEFAULT 0,
-  `changed_time` datetime NOT NULL DEFAULT current_timestamp(),
-  `created_by` VARCHAR(10) NULL DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_auth_alias`
---
-
-CREATE TABLE `User_auth_alias` (
-  `id` int(11) NOT NULL,
-  `auth_id` int(11) NOT NULL,
-  `alias` varchar(100) DEFAULT NULL,
-  `description` varchar(100) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_list`
---
-
-CREATE TABLE `User_list` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `login` varchar(255) DEFAULT NULL,
-  `fio` varchar(255) DEFAULT NULL,
-  `enabled` tinyint(1) NOT NULL DEFAULT 1,
-  `blocked` tinyint(1) NOT NULL DEFAULT 0,
-  `deleted` tinyint(1) NOT NULL DEFAULT 0,
-  `ou_id` int(11) NOT NULL DEFAULT 0,
-  `device_id` int(11) DEFAULT NULL,
-  `filter_group_id` int(11) NOT NULL DEFAULT 0,
-  `queue_id` int(11) NOT NULL DEFAULT 0,
-  `day_quota` int(11) NOT NULL DEFAULT 0,
-  `month_quota` int(11) NOT NULL DEFAULT 0,
-  `permanent` BOOLEAN NOT NULL DEFAULT FALSE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_stats`
---
-
-CREATE TABLE `User_stats` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `router_id` bigint(20) UNSIGNED DEFAULT 0,
-  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
-  `byte_in` bigint(20) NOT NULL DEFAULT 0,
-  `byte_out` bigint(20) NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_stats_full`
---
-
-CREATE TABLE `User_stats_full` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `router_id` bigint(20) UNSIGNED DEFAULT 0,
-  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
-  `byte_in` bigint(20) NOT NULL DEFAULT 0,
-  `byte_out` bigint(20) NOT NULL DEFAULT 0,
-  `pkt_in` int(11) DEFAULT NULL,
-  `pkt_out` int(11) DEFAULT NULL,
-  `step` int(11) NOT NULL DEFAULT 600
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `variables`
---
-
-CREATE TABLE `variables` (
-  `id` int(11) NOT NULL,
-  `name` varchar(30) NOT NULL,
-  `value` varchar(255) DEFAULT NULL,
-  `clear_time` timestamp NOT NULL DEFAULT current_timestamp(),
-  `created` timestamp NOT NULL DEFAULT current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `vendors`
---
-
-CREATE TABLE `vendors` (
-  `id` int(11) NOT NULL,
-  `name` varchar(40) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `vendors`
---
-
-INSERT INTO `vendors` (`id`, `name`) VALUES(1, 'Unknown');
-INSERT INTO `vendors` (`id`, `name`) VALUES(2, 'Eltex');
-INSERT INTO `vendors` (`id`, `name`) VALUES(3, 'Huawei');
-INSERT INTO `vendors` (`id`, `name`) VALUES(4, 'Zyxel');
-INSERT INTO `vendors` (`id`, `name`) VALUES(5, 'Raisecom');
-INSERT INTO `vendors` (`id`, `name`) VALUES(6, 'SNR');
-INSERT INTO `vendors` (`id`, `name`) VALUES(7, 'Dlink');
-INSERT INTO `vendors` (`id`, `name`) VALUES(8, 'Allied Telesis');
-INSERT INTO `vendors` (`id`, `name`) VALUES(9, 'Mikrotik');
-INSERT INTO `vendors` (`id`, `name`) VALUES(10, 'NetGear');
-INSERT INTO `vendors` (`id`, `name`) VALUES(11, 'Ubiquiti');
-INSERT INTO `vendors` (`id`, `name`) VALUES(15, 'HP');
-INSERT INTO `vendors` (`id`, `name`) VALUES(16, 'Cisco');
-INSERT INTO `vendors` (`id`, `name`) VALUES(17, 'Maipu');
-INSERT INTO `vendors` (`id`, `name`) VALUES(18, 'Asus');
-INSERT INTO `vendors` (`id`, `name`) VALUES(19, 'Linux');
-INSERT INTO `vendors` (`id`, `name`) VALUES(20, 'APC');
-INSERT INTO `vendors` (`id`, `name`) VALUES(21, 'Schneider');
-INSERT INTO `vendors` (`id`, `name`) VALUES(33, 'QSC');
-INSERT INTO `vendors` (`id`, `name`) VALUES(34, 'Projectiondesign');
-INSERT INTO `vendors` (`id`, `name`) VALUES(35, 'Lenovo');
-INSERT INTO `vendors` (`id`, `name`) VALUES(36, 'HiWatch');
-INSERT INTO `vendors` (`id`, `name`) VALUES(37, 'LTV');
-INSERT INTO `vendors` (`id`, `name`) VALUES(38, 'Yeastar');
-INSERT INTO `vendors` (`id`, `name`) VALUES(39, 'Yealink');
-INSERT INTO `vendors` (`id`, `name`) VALUES(40, 'Gigaset');
-INSERT INTO `vendors` (`id`, `name`) VALUES(41, 'Linksys');
-INSERT INTO `vendors` (`id`, `name`) VALUES(42, 'Samsung');
-INSERT INTO `vendors` (`id`, `name`) VALUES(43, 'Supermicro');
-INSERT INTO `vendors` (`id`, `name`) VALUES(44, 'RDP');
-INSERT INTO `vendors` (`id`, `name`) VALUES(45, 'SANYO');
-INSERT INTO `vendors` (`id`, `name`) VALUES(46, 'Extreme');
-INSERT INTO `vendors` (`id`, `name`) VALUES(47, 'Intel');
-INSERT INTO `vendors` (`id`, `name`) VALUES(48, 'Micron');
-INSERT INTO `vendors` (`id`, `name`) VALUES(49, 'Gigabyte');
-INSERT INTO `vendors` (`id`, `name`) VALUES(50, 'Acer');
-INSERT INTO `vendors` (`id`, `name`) VALUES(51, 'Seagate');
-INSERT INTO `vendors` (`id`, `name`) VALUES(52, 'SanDisk');
-INSERT INTO `vendors` (`id`, `name`) VALUES(53, 'Toshiba');
-INSERT INTO `vendors` (`id`, `name`) VALUES(54, 'Kingston');
-INSERT INTO `vendors` (`id`, `name`) VALUES(55, 'AddPac');
-INSERT INTO `vendors` (`id`, `name`) VALUES(56, 'Devline');
-INSERT INTO `vendors` (`id`, `name`) VALUES(57, 'Canon');
-INSERT INTO `vendors` (`id`, `name`) VALUES(58, 'Brother');
-INSERT INTO `vendors` (`id`, `name`) VALUES(59, 'Epson');
-INSERT INTO `vendors` (`id`, `name`) VALUES(60, 'IP-COM');
-INSERT INTO `vendors` (`id`, `name`) VALUES(61, 'Panasonic');
-INSERT INTO `vendors` (`id`, `name`) VALUES(62, 'OKI');
-INSERT INTO `vendors` (`id`, `name`) VALUES(63, 'Apple');
-INSERT INTO `vendors` (`id`, `name`) VALUES(64, 'Eaton');
-INSERT INTO `vendors` (`id`, `name`) VALUES(65, 'Barco');
-INSERT INTO `vendors` (`id`, `name`) VALUES(66, 'Trassir');
-INSERT INTO `vendors` (`id`, `name`) VALUES(67, 'Testo');
-INSERT INTO `vendors` (`id`, `name`) VALUES(68, 'Hw-group');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `version`
---
-
-CREATE TABLE `version` (
-  `id` int(11) NOT NULL DEFAULT 1,
-  `version` varchar(10) NOT NULL DEFAULT '2.4.14'
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `version`
---
-
-INSERT INTO `version` (`id`, `version`) VALUES(1, '2.7.0');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Wan_stats`
---
-
-CREATE TABLE `Wan_stats` (
-  `id` int(11) NOT NULL,
-  `time` datetime NOT NULL DEFAULT current_timestamp(),
-  `router_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,
-  `forward_in` 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;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `worklog`
---
-
-CREATE TABLE `worklog` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `customer` varchar(50) NOT NULL DEFAULT 'system',
-  `ip` varchar(18) NOT NULL DEFAULT '127.0.0.1',
-  `message` text NOT NULL,
-  `level` int(11) NOT NULL DEFAULT 1
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
-
---
--- Индексы сохранённых таблиц
---
-
---
--- Индексы таблицы `acl`
---
-ALTER TABLE `acl`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `ad_comp_cache`
---
-ALTER TABLE `ad_comp_cache`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `comp_name` (`name`);
-
---
--- Индексы таблицы `auth_rules`
---
-ALTER TABLE `auth_rules`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `rule` (`rule`),
-  ADD KEY `user_id` (`user_id`);
-
---
--- Индексы таблицы `building`
---
-ALTER TABLE `building`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `config`
---
-ALTER TABLE `config`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `option` (`option_id`);
-
---
--- Индексы таблицы `config_options`
---
-ALTER TABLE `config_options`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `connections`
---
-ALTER TABLE `connections`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `auth_id` (`auth_id`),
-  ADD KEY `device_id` (`device_id`,`port_id`);
-
---
--- Индексы таблицы `Customers`
---
-ALTER TABLE `Customers`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `devices`
---
-ALTER TABLE `devices`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `ip` (`ip`),
-  ADD KEY `device_type` (`device_type`);
-
---
--- Индексы таблицы `device_l3_interfaces`
---
-ALTER TABLE `device_l3_interfaces`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `device_models`
---
-ALTER TABLE `device_models`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `device_ports`
---
-ALTER TABLE `device_ports`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `device_id` (`device_id`),
-  ADD KEY `port` (`port`),
-  ADD KEY `target_port_id` (`target_port_id`);
-
---
--- Индексы таблицы `device_types`
---
-ALTER TABLE `device_types`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `dhcp_log`
---
-ALTER TABLE `dhcp_log`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`action`);
-
---
--- Индексы таблицы `dhcp_queue`
---
-ALTER TABLE `dhcp_queue`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`action`);
-
---
--- Индексы таблицы `dns_cache`
---
-ALTER TABLE `dns_cache`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `dns` (`dns`,`ip`),
-  ADD KEY `timestamp` (`timestamp`);
-
---
--- Индексы таблицы `Filter_list`
---
-ALTER TABLE `Filter_list`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `Name` (`name`);
-
---
--- Индексы таблицы `gateway_subnets`
---
-ALTER TABLE `gateway_subnets`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `Group_filters`
---
-ALTER TABLE `Group_filters`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `GroupId` (`group_id`,`filter_id`);
-
---
--- Индексы таблицы `Group_list`
---
-ALTER TABLE `Group_list`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `mac_history`
---
-ALTER TABLE `mac_history`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `mac` (`mac`,`timestamp`),
-  ADD KEY `ip` (`ip`,`timestamp`),
-  ADD KEY `timestamp` (`timestamp`) USING BTREE,
-  ADD KEY `mac_2` (`mac`),
-  ADD KEY `ip_2` (`ip`);
-
---
--- Индексы таблицы `mac_vendors`
---
-ALTER TABLE `mac_vendors`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `oui` (`oui`);
-
---
--- Индексы таблицы `OU`
---
-ALTER TABLE `OU`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `Queue_list`
---
-ALTER TABLE `Queue_list`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `id` (`id`);
-
---
--- Индексы таблицы `remote_syslog`
---
-ALTER TABLE `remote_syslog`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `date` (`date`,`device_id`,`ip`);
-
---
--- Индексы таблицы `sessions`
---
-ALTER TABLE `sessions`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `last_accessed` (`last_accessed`);
-
---
--- Индексы таблицы `user_sessions`
---
-ALTER TABLE `user_sessions`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `session_id` (`session_id`),
-  ADD KEY `user_id` (`user_id`),
-  ADD KEY `is_active` (`is_active`);
-
---
--- Индексы таблицы `subnets`
---
-ALTER TABLE `subnets`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `ip_int_start` (`ip_int_start`,`ip_int_stop`),
-  ADD KEY `dhcp` (`dhcp`,`office`,`hotspot`,`static`);
-
---
--- Индексы таблицы `Traffic_detail`
---
-ALTER TABLE `Traffic_detail`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `src` (`auth_id`,`timestamp`,`router_id`,`src_ip`),
-  ADD KEY `dst` (`auth_id`,`timestamp`,`router_id`,`dst_ip`);
-
---
--- Индексы таблицы `Unknown_mac`
---
-ALTER TABLE `Unknown_mac`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`device_id`,`port_id`,`mac`);
-
---
--- Индексы таблицы `User_auth`
---
-ALTER TABLE `User_auth`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `auth_index` (`id`,`user_id`,`ip_int`,`mac`,`ip`,`deleted`) USING BTREE,
-  ADD KEY `deleted` (`deleted`),
-  ADD KEY `ou_id` (`ou_id`);
-
---
--- Индексы таблицы `User_auth_alias`
---
-ALTER TABLE `User_auth_alias`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `auth_id` (`auth_id`);
-
---
--- Индексы таблицы `User_list`
---
-ALTER TABLE `User_list`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `users` (`id`,`ou_id`,`enabled`,`blocked`,`deleted`);
-
---
--- Индексы таблицы `User_stats`
---
-ALTER TABLE `User_stats`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`auth_id`,`router_id`);
-
---
--- Индексы таблицы `User_stats_full`
---
-ALTER TABLE `User_stats_full`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`auth_id`,`router_id`);
-
---
--- Индексы таблицы `variables`
---
-ALTER TABLE `variables`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `name` (`name`),
-  ADD KEY `clear_time` (`clear_time`,`created`);
-
---
--- Индексы таблицы `vendors`
---
-ALTER TABLE `vendors`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `version`
---
-ALTER TABLE `version`
-  ADD UNIQUE KEY `id` (`id`);
-
---
--- Индексы таблицы `Wan_stats`
---
-ALTER TABLE `Wan_stats`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `main` (`time`,`router_id`,`interface_id`),
-  ADD KEY `times` (`time`);
-
---
--- Индексы таблицы `worklog`
---
-ALTER TABLE `worklog`
-  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`);
-
-
---
--- Индексы таблицы `dns_queue`
---
-ALTER TABLE `dns_queue`
-  ADD PRIMARY KEY (`id`);
-
-
---
--- Индексы таблицы `filter_instances`
---
-ALTER TABLE `filter_instances`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `name` (`name`);
-
---
--- AUTO_INCREMENT для сохранённых таблиц
---
-
---
--- AUTO_INCREMENT для таблицы `acl`
---
-ALTER TABLE `acl`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `ad_comp_cache`
---
-ALTER TABLE `ad_comp_cache`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `auth_rules`
---
-ALTER TABLE `auth_rules`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `building`
---
-ALTER TABLE `building`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `config`
---
-ALTER TABLE `config`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `config_options`
---
-ALTER TABLE `config_options`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `connections`
---
-ALTER TABLE `connections`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Customers`
---
-ALTER TABLE `Customers`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `devices`
---
-ALTER TABLE `devices`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `device_l3_interfaces`
---
-ALTER TABLE `device_l3_interfaces`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `device_models`
---
-ALTER TABLE `device_models`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `device_ports`
---
-ALTER TABLE `device_ports`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `device_types`
---
-ALTER TABLE `device_types`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `dhcp_log`
---
-ALTER TABLE `dhcp_log`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `dhcp_queue`
---
-ALTER TABLE `dhcp_queue`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `dns_cache`
---
-ALTER TABLE `dns_cache`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `dns_queue`
---
-ALTER TABLE `dns_queue`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Filter_list`
---
-ALTER TABLE `Filter_list`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `gateway_subnets`
---
-ALTER TABLE `gateway_subnets`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Group_filters`
---
-ALTER TABLE `Group_filters`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Group_list`
---
-ALTER TABLE `Group_list`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `mac_history`
---
-ALTER TABLE `mac_history`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `mac_vendors`
---
-ALTER TABLE `mac_vendors`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `OU`
---
-ALTER TABLE `OU`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Queue_list`
---
-ALTER TABLE `Queue_list`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `remote_syslog`
---
-ALTER TABLE `remote_syslog`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `user_sessions`
---
-ALTER TABLE `user_sessions`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `subnets`
---
-ALTER TABLE `subnets`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Traffic_detail`
---
-ALTER TABLE `Traffic_detail`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Unknown_mac`
---
-ALTER TABLE `Unknown_mac`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_auth`
---
-ALTER TABLE `User_auth`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_auth_alias`
---
-ALTER TABLE `User_auth_alias`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_list`
---
-ALTER TABLE `User_list`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_stats`
---
-ALTER TABLE `User_stats`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_stats_full`
---
-ALTER TABLE `User_stats_full`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `variables`
---
-ALTER TABLE `variables`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `vendors`
---
-ALTER TABLE `vendors`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Wan_stats`
---
-ALTER TABLE `Wan_stats`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `filter_instances`
---
-ALTER TABLE `filter_instances`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `worklog`
---
-ALTER TABLE `worklog`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-COMMIT;
-
-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

+ 0 - 1690
docs/mysql/2-9-0/mysql.sql

@@ -1,1690 +0,0 @@
--- phpMyAdmin SQL Dump
--- version 5.2.1
--- https://www.phpmyadmin.net/
---
--- Хост: localhost
--- Время создания: Дек 03 2024 г., 14:57
--- Версия сервера: 10.11.6-MariaDB-0+deb12u1-log
--- Версия PHP: 8.2.26
-
-SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
-START TRANSACTION;
-SET time_zone = "+00:00";
-
-
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8mb4 */;
-
---
--- База данных: `stat`
---
-
-CREATE TABLE `device_filter_instances` (
-   `id` INT NOT NULL AUTO_INCREMENT ,
-   `instance_id` INT NULL DEFAULT NULL ,
-   `device_id` INT NULL DEFAULT NULL , PRIMARY KEY (`id`)
-) ENGINE = InnoDB;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `acl`
---
-
-CREATE TABLE `acl` (
-  `id` int(11) NOT NULL,
-  `name` varchar(30) NOT NULL,
-  `description.english` varchar(250) NOT NULL,
-  `description.russian` varchar(250) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `ad_comp_cache`
---
-
-CREATE TABLE `ad_comp_cache` (
-  `id` int(11) NOT NULL,
-  `name` varchar(63) NOT NULL,
-  `last_found` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `auth_rules`
---
-
-CREATE TABLE `auth_rules` (
-  `id` int(11) NOT NULL,
-  `user_id` int(11) DEFAULT NULL,
-  `ou_id` int(11) DEFAULT NULL,
-  `type` int(11) NOT NULL,
-  `rule` varchar(40) DEFAULT NULL,
-  `comment` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `building`
---
-
-CREATE TABLE `building` (
-  `id` int(11) NOT NULL,
-  `name` varchar(50) NOT NULL,
-  `comment` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `building`
---
-
-INSERT INTO `building` (`id`, `name`, `comment`) VALUES(1, 'Earth', 'Somewhere');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `config`
---
-
-CREATE TABLE `config` (
-  `id` int(11) NOT NULL,
-  `option_id` int(11) DEFAULT NULL,
-  `value` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `config`
---
-
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(1, 1, '0');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(2, 11, 'public');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(3, 32, 'ORG');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(123, 19, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(124, 35, '120');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(125, 9, '2');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(126, 41, '/opt/Eye/scripts/fetch_new_arp.pl');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(127, 26, '3');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(128, 27, '10');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(129, 48, '90');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(130, 49, '365');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(131, 47, '90');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(132, 53, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(133, 55, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(134, 56, '30');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(135, 34, '0');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(137, 65, '0');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(142, 54, '');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(143, 17, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(144, 37, '/opt/Eye/scripts/sync_mikrotik.pl');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(145, 23, '1');
-INSERT INTO `config` (`id`, `option_id`, `value`) VALUES(148, 22, '1');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `config_options`
---
-
-CREATE TABLE `config_options` (
-  `id` int(11) NOT NULL,
-  `option_name` varchar(50) NOT NULL,
-  `description.russian` text DEFAULT NULL,
-  `description.english` text DEFAULT NULL,
-  `draft` tinyint(1) NOT NULL DEFAULT 0,
-  `uniq` tinyint(1) NOT NULL DEFAULT 1,
-  `type` varchar(100) NOT NULL,
-  `default_value` varchar(250) DEFAULT NULL,
-  `min_value` int(11) NOT NULL DEFAULT 0,
-  `max_value` int(11) NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `config_options`
---
-
-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 VERBOSE work 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);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `connections`
---
-
-CREATE TABLE `connections` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `device_id` bigint(20) UNSIGNED NOT NULL,
-  `port_id` bigint(20) UNSIGNED NOT NULL,
-  `auth_id` bigint(20) UNSIGNED NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Customers`
---
-
-CREATE TABLE `Customers` (
-  `id` int(11) NOT NULL,
-  `Login` varchar(20) DEFAULT 'NULL',
-  `comment` varchar(100) DEFAULT 'NULL',
-  `password` varchar(255) DEFAULT 'NULL',
-  `api_key` varchar(255) DEFAULT NULL,
-  `rights` tinyint(1) NOT NULL DEFAULT 3
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Customers`
---
-
-INSERT INTO `Customers` (`id`, `Login`, `comment`, `password`, `api_key`, `rights`) VALUES(1, 'admin', '', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'Kot5miegiequaeseim3veequeiW2Iv3L', 1);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `devices`
---
-
-CREATE TABLE `devices` (
-  `id` int(11) NOT NULL,
-  `device_type` int(11) NOT NULL DEFAULT 1,
-  `device_model_id` int(11) DEFAULT 89,
-  `firmware` varchar(100) DEFAULT NULL,
-  `vendor_id` int(11) NOT NULL DEFAULT 1,
-  `device_name` varchar(50) DEFAULT NULL,
-  `building_id` int(11) NOT NULL DEFAULT 1,
-  `ip` varchar(15) DEFAULT NULL,
-  `ip_int` BIGINT(10) UNSIGNED DEFAULT NULL,
-  `login` varchar(50) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `protocol` int(11) NOT NULL DEFAULT 0,
-  `control_port` int(11) NOT NULL DEFAULT 23,
-  `port_count` int(11) NOT NULL DEFAULT 0,
-  `SN` varchar(80) DEFAULT NULL,
-  `comment` varchar(255) DEFAULT NULL,
-  `snmp_version` tinyint(4) NOT NULL DEFAULT 0,
-  `snmp3_auth_proto` varchar(10) NOT NULL DEFAULT 'sha512',
-  `snmp3_priv_proto` varchar(10) NOT NULL DEFAULT 'aes128',
-  `snmp3_user_rw` varchar(20) DEFAULT NULL,
-  `snmp3_user_rw_password` varchar(20) DEFAULT NULL,
-  `snmp3_user_ro` varchar(20) DEFAULT NULL,
-  `snmp3_user_ro_password` varchar(20) DEFAULT NULL,
-  `community` varchar(50) NOT NULL DEFAULT 'public',
-  `rw_community` varchar(50) NOT NULL DEFAULT 'private',
-  `fdb_snmp_index` tinyint(1) NOT NULL DEFAULT 0,
-  `discovery` tinyint(1) NOT NULL DEFAULT 1,
-  `netflow_save` tinyint(1) NOT NULL DEFAULT 0,
-  `user_acl` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios` tinyint(1) NOT NULL DEFAULT 0,
-  `active` tinyint(1) NOT NULL DEFAULT 1,
-  `nagios_status` varchar(10) NOT NULL DEFAULT 'UP',
-  `queue_enabled` tinyint(1) NOT NULL DEFAULT 0,
-  `connected_user_only` tinyint(1) NOT NULL DEFAULT 1,
-  `user_id` int(11) DEFAULT NULL,
-  `deleted` tinyint(1) NOT NULL DEFAULT 0,
-  `discovery_locked` tinyint(1) NOT NULL DEFAULT 0,
-  `locked_timestamp` timestamp NULL DEFAULT current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `device_l3_interfaces`
---
-
-CREATE TABLE `device_l3_interfaces` (
-  `id` int(11) NOT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `snmpin` int(11) DEFAULT NULL,
-  `interface_type` int(11) NOT NULL DEFAULT 0,
-  `name` varchar(100) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `device_models`
---
-
-CREATE TABLE `device_models` (
-  `id` int(11) NOT NULL,
-  `model_name` varchar(200) DEFAULT NULL,
-  `vendor_id` int(11) DEFAULT 1,
-  `poe_in` tinyint(1) NOT NULL DEFAULT 0,
-  `poe_out` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios_template` varchar(200) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `device_models`
---
-
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(1, '2011LS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(2, '2011UAS-2HnD', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(3, 'AT-8000S', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(4, 'AT-8100S/48POE', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(5, 'AT-9000/28', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(6, 'AT-GS950/24', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(7, 'CCR1009-7G-1C-1S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(8, 'CCR1036-8G-2S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(10, 'CRS317-1G-16S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(11, 'CRS326-24S+2Q+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(12, 'CRS328-24P-4S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(14, 'CRS328-4C-20S-4S+', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(15, 'DGS-3120-48TC', 7, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(16, 'ES-2024', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(17, 'ES-2024A', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(18, 'ES-2108', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(19, 'ES-2108-G', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(20, 'ES-3124-4F', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(21, 'GS110TP', 10, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(22, 'GS-4024', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(23, 'HP 1910', 15, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(24, 'ISCOM2110A-MA', 5, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(25, 'ISCOM2110EA-MA', 5, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(26, 'ISCOM2126EA-MA', 5, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(27, 'ISCOM2128EA-MA', 5, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(28, 'Linux server', 1, 0, 0, '');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(29, 'MES2124F', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(30, 'MES2124MB', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(31, 'MES5248', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(32, 'RB2011UAS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(33, 'RB3011UiAS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(34, 'RB960PGS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(35, 'RBD52G-5HacD2HnD', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(36, 'S2940-8G-v2', 6, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(37, 'S2980G-24T', 6, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(38, 'S3750G-24S-E', 6, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(39, 'S5300-52P-LI-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(40, 'S5320-52X-PWR-SI-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(41, 'S5321-28X-SI-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(42, 'S5321-52X-SI-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(43, 'S6320-54C-EI-48S-AC', 3, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(44, 'SNR-S2980G-24T', 6, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(45, 'V1910-16G', 15, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(46, 'V1910-24G-PoE', 15, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(47, 'Windows server', 1, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(48, 'WS-C2960G-24TC-L', 16, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(49, 'WS-C3560G-24TS-S', 16, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(50, 'x210-16GT', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(51, 'x210-24GT', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(52, 'x610-24Ts/X', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(53, 'x610-48Ts', 8, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(54, 'XGS-4728', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(55, 'ZyWall 310', 4, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(56, 'APC Smart-UPS_3000', 20, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(57, 'APC Smart-UPS_5000', 20, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(58, 'Schneider Smart-UPS_3000', 21, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(59, 'SMG-1016M', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(60, 'EATON 9PX 1500i RT 2U', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(61, 'EATON 9PX3000i_RT_2U', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(62, 'EATON 9PX_6000i', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(63, 'EATON PW9130_3000', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(64, 'EATON PW9130_3000VA-R', 64, 0, 0, 'ups.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(65, 'Epson WF-5620 Series', 59, 0, 0, 'epson.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(66, 'Epson WF-8590 Series', 59, 0, 0, 'epson.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(67, 'HP Officejet-7000', 15, 0, 0, 'hp.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(68, 'OKI C610', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(69, 'OKI MB472', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(70, 'OKI MB491', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(71, 'OKI MC562', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(72, 'OKI MC573', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(73, 'OKI MC861', 62, 0, 0, 'oki.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(74, 'Panasonic KX-MB2000RU', 61, 0, 0, 'panasonic.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(75, 'PT-MZ10KE', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(76, 'PT-VX41', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(77, 'Rave 522AA', 33, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(78, 'DZ570E', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(79, 'DZ6700', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(80, 'Rcq80', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(81, 'RZ12K', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(82, 'RZ660', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(83, 'RZ770', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(84, 'RZ970', 61, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(85, 'XVR-5216', 66, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(86, 'HWg-STE', 68, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(87, 'Computer', 1, 0, 0, '');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(88, 'Mobile Phone', 1, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(89, 'Switch', 1, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(90, 'Projectiondesign F22', 34, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(91, 'DS-I252', 36, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(92, 'LTV-CNE-720-48', 37, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(93, 'U-100', 38, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(94, 'TAU-8', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(95, 'SIP-T21P E2', 39, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(96, 'A510 IP', 40, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(97, 'W60B', 39, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(98, 'TAU-2M', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(99, 'PAP2T', 41, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(100, 'VP-12', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(101, 'SIP-T23P', 39, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(102, 'SPA-2102', 16, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(103, 'RB760iGS', 9, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(104, 'MES2324B', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(105, 'MES2324FB', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(106, 'MES2124P', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(107, 'MES2428P', 2, 0, 0, NULL);
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(108, 'Symmetra LX 16000', 20, 0, 0, 'symmetra.cfg');
-INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `poe_in`, `poe_out`, `nagios_template`) VALUES(109, 'SNR-UPS-ONT20', 6, 0, 0, 'ups.cfg');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `device_ports`
---
-
-CREATE TABLE `device_ports` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `snmp_index` int(11) DEFAULT NULL,
-  `port` int(11) DEFAULT NULL,
-  `ifName` varchar(40) DEFAULT NULL,
-  `port_name` varchar(40) DEFAULT NULL,
-  `comment` varchar(50) DEFAULT NULL,
-  `target_port_id` int(11) NOT NULL DEFAULT 0,
-  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `last_mac_count` int(11) DEFAULT 0,
-  `uplink` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios` tinyint(1) NOT NULL DEFAULT 0,
-  `skip` tinyint(1) NOT NULL DEFAULT 0,
-  `vlan` int(11) NOT NULL DEFAULT 1,
-  `tagged_vlan` varchar(250) DEFAULT NULL,
-  `untagged_vlan` varchar(250) DEFAULT NULL,
-  `forbidden_vlan` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `device_types`
---
-
-CREATE TABLE `device_types` (
-  `id` int(11) NOT NULL,
-  `name.russian` varchar(50) DEFAULT NULL,
-  `name.english` varchar(50) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `device_types`
---
-
-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, 'Точка доступа', 'Access Point');
-INSERT INTO `device_types` (`id`, `name.russian`, `name.english`) VALUES(5, 'Сетевое устройство', 'Network device');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `dhcp_log`
---
-
-CREATE TABLE `dhcp_log` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(17) NOT NULL,
-  `ip_int` bigint(20) UNSIGNED NOT NULL,
-  `ip` varchar(15) NOT NULL,
-  `action` varchar(10) NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `auth_id` bigint(20) UNSIGNED NOT 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
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `dhcp_queue`
---
-
-CREATE TABLE `dhcp_queue` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(17) NOT NULL,
-  `ip` varchar(15) NOT NULL,
-  `action` varchar(10) NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `dhcp_hostname` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `dns_cache`
---
-
-CREATE TABLE `dns_cache` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `dns` varchar(250) DEFAULT NULL,
-  `ip` bigint(20) UNSIGNED DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `dns_queue`
---
-
-CREATE TABLE `dns_queue` (
-  `id` int(11) NOT NULL,
-  `auth_id` int(11) DEFAULT NULL,
-  `name_type` varchar(10) NOT NULL DEFAULT 'A',
-  `name` varchar(200) DEFAULT NULL,
-  `type` varchar(10) NOT NULL DEFAULT 'add',
-  `value` varchar(100) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Filter_list`
---
-
-CREATE TABLE `Filter_list` (
-  `id` int(11) NOT NULL,
-  `name` varchar(50) DEFAULT NULL,
-  `comment` varchar(250) DEFAULT NULL,
-  `proto` varchar(10) DEFAULT NULL,
-  `dst` varchar(253) DEFAULT NULL,
-  `dstport` varchar(20) DEFAULT NULL,
-  `srcport` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
-  `type` int(10) UNSIGNED NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Filter_list`
---
-
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(1, 'pop3', NULL, 'tcp', '0/0', '110', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(3, 'http', NULL, 'tcp', '0/0', '80', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(4, 'https', NULL, 'tcp', '0/0', '443', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(5, 'icq', NULL, 'tcp', '0/0', '5190', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(6, 'jabber', NULL, 'tcp', '0/0', '5222', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(9, 'allow_all', 'любой трафик', 'all', '0/0', '0', '0', 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(10, 'icmp', NULL, 'icmp', '0/0', '0', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(11, 'ftp', NULL, 'tcp', '0/0', '20-21', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(15, 'telnet', NULL, 'tcp', '0/0', '23', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(16, 'ssh', NULL, 'tcp', '0/0', '22', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(28, 'smtp', NULL, 'tcp', '0/0', '25', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(32, 'rdp', NULL, 'tcp', '0/0', '3389', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(40, 'ntp', NULL, 'udp', '0/0', '123', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(44, 'vnc', NULL, 'tcp', '0/0', '5800-5900', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(55, 'unprivileged tcp', NULL, 'tcp', '0/0', '1024-65500', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(76, 'ipsec', NULL, 'udp', '0/0', '500', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(77, 'isakmp', NULL, 'udp', '0/0', '4500', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(79, 'pop3s', NULL, 'tcp', '0/0', '995', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(80, 'smtps', NULL, 'tcp', '0/0', '465,587', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(81, 'imap', NULL, 'tcp', '0/0', '143', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(82, 'imaps', NULL, 'tcp', '0/0', '993', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(83, 'unprivileged udp', NULL, 'udp', '0/0', '1024-65000', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(84, 'pptp', NULL, 'tcp', '0/0', '1723', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(85, 'openvpn-udp', NULL, 'udp', '0/0', '1194', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(90, 'dns_udp', NULL, 'udp', '0/0', '53', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(91, 'dns_tcp', NULL, 'tcp', '0/0', '53', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(94, 'squid', NULL, 'tcp', '0/0', '3128', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(101, 'snmp', NULL, 'udp', '0/0', '161', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(105, 'http_udp', NULL, 'udp', '0/0', '80', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(106, 'https_udp', NULL, 'udp', '0/0', '443', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(107, 'l2tp-ipsec', NULL, 'udp', '0/0', '1701,4500,500', NULL, 0);
-INSERT INTO `Filter_list` (`id`, `name`, `comment`, `proto`, `dst`, `dstport`, `srcport`, `type`) VALUES(108, 'gre', NULL, 'gre', '0/0', NULL, NULL, 0);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `gateway_subnets`
---
-
-CREATE TABLE `gateway_subnets` (
-  `id` int(11) NOT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `subnet_id` int(11) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Group_filters`
---
-
-CREATE TABLE `Group_filters` (
-  `id` int(11) NOT NULL,
-  `group_id` int(11) NOT NULL DEFAULT 0,
-  `filter_id` int(11) NOT NULL DEFAULT 0,
-  `order` int(11) NOT NULL DEFAULT 0,
-  `action` tinyint(1) NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Group_filters`
---
-
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(1, 2, 90, 1, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(2, 2, 91, 2, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(3, 2, 11, 3, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(5, 2, 3, 4, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(6, 2, 105, 5, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(7, 2, 4, 6, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(8, 2, 106, 7, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(9, 2, 10, 8, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(10, 2, 81, 9, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(11, 2, 82, 10, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(15, 2, 40, 11, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(16, 2, 1, 12, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(17, 2, 79, 13, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(18, 2, 80, 14, 1);
-INSERT INTO `Group_filters` (`id`, `group_id`, `filter_id`, `order`, `action`) VALUES(19, 1, 9, 1, 1);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `filter_instances`
---
-
-CREATE TABLE `filter_instances` (
-  `id` int(11) NOT NULL,
-  `name` varchar(50) DEFAULT NULL,
-  `comment` varchar(200) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `filter_instances`
---
-
-INSERT INTO `filter_instances` VALUES(1, 'default', NULL);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Group_list`
---
-
-CREATE TABLE `Group_list` (
-  `id` int(11) NOT NULL,
-  `instance_id` int(11) NOT NULL DEFAULT 1,
-  `group_name` varchar(50) DEFAULT NULL,
-  `comment` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Group_list`
---
-
-INSERT INTO `Group_list` VALUES(0, 1, 'default', NULL);
-INSERT INTO `Group_list` VALUES(1, 1, 'Allow all', 'Разрешено всё');
-INSERT INTO `Group_list` VALUES(2, 1, 'Users', 'Для пользователей');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `mac_history`
---
-
-CREATE TABLE `mac_history` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(12) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `device_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `port_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `ip` varchar(16) NOT NULL DEFAULT '',
-  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `dhcp_hostname` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `mac_vendors`
---
-
-CREATE TABLE `mac_vendors` (
-  `id` int(11) NOT NULL,
-  `oui` varchar(20) DEFAULT NULL,
-  `companyName` varchar(255) DEFAULT NULL,
-  `companyAddress` varchar(255) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `OU`
---
-
-CREATE TABLE `OU` (
-  `id` int(11) NOT NULL,
-  `parent_id` INT(11) NULL DEFAULT NULL,
-  `ou_name` varchar(40) DEFAULT NULL,
-  `comment` varchar(250) DEFAULT NULL,
-  `default_users` tinyint(1) NOT NULL DEFAULT 0,
-  `default_hotspot` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios_dir` varchar(255) DEFAULT NULL,
-  `nagios_host_use` varchar(50) DEFAULT NULL,
-  `nagios_ping` tinyint(1) NOT NULL DEFAULT 1,
-  `nagios_default_service` varchar(100) DEFAULT NULL,
-  `enabled` int(11) NOT NULL DEFAULT 0,
-  `filter_group_id` int(11) NOT NULL DEFAULT 0,
-  `queue_id` int(11) NOT NULL DEFAULT 0,
-  `dynamic` tinyint(1) NOT NULL DEFAULT 0,
-  `life_duration` DECIMAL(10,2) NOT NULL DEFAULT '24'
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `OU`
---
-
-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`) VALUES(0, '!Всё', NULL, 0, 0, '/etc/nagios/any', 'generic-host', 1, NULL, 0, 0, 0);
-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`) VALUES(1, 'Сервера', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 0);
-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`) VALUES(2, 'Администраторы', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0);
-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`) VALUES(3, 'Пользователи', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4);
-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`) VALUES(4, 'VOIP', NULL, 0, 0, 'voip', 'voip', 1, NULL, 1, 4, 5);
-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`) VALUES(5, 'IPCAM', NULL, 0, 0, 'videocam', 'ip-cam', 1, NULL, 0, 0, 0);
-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`) VALUES(6, 'Принтеры', NULL, 0, 0, 'printers', 'printers', 1, 'printer-service', 0, 0, 0);
-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`) VALUES(7, 'Свичи', NULL, 0, 0, 'switches', 'switches', 1, NULL, 0, 0, 0);
-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`) VALUES(8, 'UPS', NULL, 0, 0, 'ups', 'ups', 1, NULL, 0, 0, 0);
-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`) VALUES(9, 'Охрана', NULL, 0, 0, 'security', 'security', 1, NULL, 0, 0, 0);
-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`) VALUES(10, 'Роутеры', NULL, 0, 0, 'routers', 'routers', 1, NULL, 0, 0, 0);
-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`) VALUES(11, 'WiFi AP', NULL, 0, 0, 'ap', 'ap', 1, NULL, 0, 0, 0);
-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`) VALUES(12, 'WiFi', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4);
-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`) VALUES(13, 'VPN', NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0, 0);
-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`) VALUES(14, 'DHCP', NULL, 1, 0, NULL, NULL, 1, NULL, 0, 0, 0);
-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`) VALUES(15, 'Гости', NULL, 0, 0, NULL, NULL, 1, NULL, 1, 1, 4);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Queue_list`
---
-
-CREATE TABLE `Queue_list` (
-  `id` int(11) NOT NULL,
-  `queue_name` varchar(20) NOT NULL,
-  `Download` int(11) NOT NULL DEFAULT 0,
-  `Upload` int(11) NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `Queue_list`
---
-
-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);
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `remote_syslog`
---
-
-CREATE TABLE `remote_syslog` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `date` timestamp NOT NULL DEFAULT current_timestamp(),
-  `device_id` bigint(20) UNSIGNED NOT NULL,
-  `ip` varchar(15) NOT NULL,
-  `message` text NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `sessions`
---
-
-CREATE TABLE `sessions` (
-  `id` varchar(128) NOT NULL,
-  `data` text NOT NULL,
-  `last_accessed` int(11) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `user_sessions`
---
-
-CREATE TABLE `user_sessions` (
-  `id` int(11) NOT NULL,
-  `session_id` varchar(128) NOT NULL,
-  `user_id` int(11) NOT NULL,
-  `ip_address` varchar(45) NOT NULL,
-  `user_agent` text NOT NULL,
-  `created_at` int(11) NOT NULL,
-  `last_activity` int(11) NOT NULL,
-  `is_active` tinyint(1) DEFAULT 1
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `subnets`
---
-
-CREATE TABLE `subnets` (
-  `id` int(11) NOT NULL,
-  `subnet` varchar(18) DEFAULT NULL,
-  `vlan_tag` int(11) NOT NULL DEFAULT 1,
-  `ip_int_start` bigint(20) NOT NULL,
-  `ip_int_stop` bigint(20) NOT NULL,
-  `dhcp_start` bigint(20) NOT NULL DEFAULT 0,
-  `dhcp_stop` bigint(20) NOT NULL DEFAULT 0,
-  `dhcp_lease_time` int(11) NOT NULL DEFAULT 480,
-  `gateway` bigint(20) NOT NULL DEFAULT 0,
-  `office` tinyint(1) NOT NULL DEFAULT 1,
-  `hotspot` tinyint(1) NOT NULL DEFAULT 0,
-  `vpn` tinyint(1) NOT NULL DEFAULT 0,
-  `free` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp` tinyint(1) NOT NULL DEFAULT 1,
-  `static` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp_update_hostname` tinyint(1) NOT NULL DEFAULT 0,
-  `discovery` tinyint(1) NOT NULL DEFAULT 1,
-  `notify` tinyint(1) NOT NULL DEFAULT '7',
-  `comment` varchar(250) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Traffic_detail`
---
-
-CREATE TABLE `Traffic_detail` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `router_id` int(11) NOT NULL DEFAULT 0,
-  `timestamp` timestamp NULL DEFAULT NULL,
-  `proto` tinyint(3) UNSIGNED DEFAULT NULL,
-  `src_ip` int(10) UNSIGNED NOT NULL,
-  `dst_ip` int(10) UNSIGNED NOT NULL,
-  `src_port` smallint(5) UNSIGNED NOT NULL,
-  `dst_port` smallint(5) UNSIGNED NOT NULL,
-  `bytes` bigint(20) NOT NULL,
-  `pkt` int(10) UNSIGNED NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Unknown_mac`
---
-
-CREATE TABLE `Unknown_mac` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(12) DEFAULT NULL,
-  `port_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_auth`
---
-
-CREATE TABLE `User_auth` (
-  `id` int(11) NOT NULL,
-  `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `ou_id` int(11) DEFAULT NULL,
-  `ip` varchar(18) NOT NULL DEFAULT '',
-  `ip_int` bigint(10) UNSIGNED NOT NULL DEFAULT 0,
-  `save_traf` tinyint(1) NOT NULL DEFAULT 0,
-  `enabled` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp` tinyint(1) NOT NULL DEFAULT 1,
-  `filter_group_id` tinyint(1) NOT NULL DEFAULT 0,
-  `dynamic` tinyint(1) NOT NULL DEFAULT 0,
-  `eof` datetime DEFAULT NULL,
-  `deleted` tinyint(4) NOT NULL DEFAULT 0,
-  `comments` varchar(250) DEFAULT NULL,
-  `dns_name` varchar(253) DEFAULT NULL,
-  `dns_ptr_only` BOOLEAN NOT NULL DEFAULT FALSE,
-  `WikiName` varchar(250) DEFAULT NULL,
-  `dhcp_acl` text DEFAULT NULL,
-  `queue_id` int(11) NOT NULL DEFAULT 0,
-  `mac` varchar(20) NOT NULL DEFAULT '',
-  `dhcp_action` varchar(10) NOT NULL DEFAULT '',
-  `dhcp_option_set` VARCHAR(50) NULL DEFAULT NULL,
-  `dhcp_time` datetime NOT NULL DEFAULT current_timestamp(),
-  `dhcp_hostname` varchar(60) DEFAULT NULL,
-  `last_found` datetime NOT NULL DEFAULT current_timestamp(),
-  `arp_found` datetime DEFAULT NULL,
-  `blocked` tinyint(1) NOT NULL DEFAULT 0,
-  `day_quota` int(11) NOT NULL DEFAULT 0,
-  `month_quota` int(11) NOT NULL DEFAULT 0,
-  `device_model_id` int(11) DEFAULT 87,
-  `firmware` varchar(100) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `client-id` varchar(250) DEFAULT NULL,
-  `nagios` tinyint(1) NOT NULL DEFAULT 0,
-  `nagios_status` varchar(10) NOT NULL DEFAULT '',
-  `nagios_handler` varchar(50) NOT NULL DEFAULT '',
-  `link_check` tinyint(1) NOT NULL DEFAULT 0,
-  `changed` tinyint(1) NOT NULL DEFAULT 0,
-  `dhcp_changed` int(11) NOT NULL DEFAULT 0,
-  `changed_time` datetime NOT NULL DEFAULT current_timestamp(),
-  `created_by` VARCHAR(10) NULL DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_auth_alias`
---
-
-CREATE TABLE `User_auth_alias` (
-  `id` int(11) NOT NULL,
-  `auth_id` int(11) NOT NULL,
-  `alias` varchar(100) DEFAULT NULL,
-  `description` varchar(100) DEFAULT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_list`
---
-
-CREATE TABLE `User_list` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `login` varchar(255) DEFAULT NULL,
-  `fio` varchar(255) DEFAULT NULL,
-  `enabled` tinyint(1) NOT NULL DEFAULT 1,
-  `blocked` tinyint(1) NOT NULL DEFAULT 0,
-  `deleted` tinyint(1) NOT NULL DEFAULT 0,
-  `ou_id` int(11) NOT NULL DEFAULT 0,
-  `device_id` int(11) DEFAULT NULL,
-  `filter_group_id` int(11) NOT NULL DEFAULT 0,
-  `queue_id` int(11) NOT NULL DEFAULT 0,
-  `day_quota` int(11) NOT NULL DEFAULT 0,
-  `month_quota` int(11) NOT NULL DEFAULT 0,
-  `permanent` BOOLEAN NOT NULL DEFAULT FALSE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_stats`
---
-
-CREATE TABLE `User_stats` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `router_id` bigint(20) UNSIGNED DEFAULT 0,
-  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
-  `byte_in` bigint(20) NOT NULL DEFAULT 0,
-  `byte_out` bigint(20) NOT NULL DEFAULT 0
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `User_stats_full`
---
-
-CREATE TABLE `User_stats_full` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `router_id` bigint(20) UNSIGNED DEFAULT 0,
-  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
-  `byte_in` bigint(20) NOT NULL DEFAULT 0,
-  `byte_out` bigint(20) NOT NULL DEFAULT 0,
-  `pkt_in` int(11) DEFAULT NULL,
-  `pkt_out` int(11) DEFAULT NULL,
-  `step` int(11) NOT NULL DEFAULT 600
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `variables`
---
-
-CREATE TABLE `variables` (
-  `id` int(11) NOT NULL,
-  `name` varchar(30) NOT NULL,
-  `value` varchar(255) DEFAULT NULL,
-  `clear_time` timestamp NOT NULL DEFAULT current_timestamp(),
-  `created` timestamp NOT NULL DEFAULT current_timestamp()
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `vendors`
---
-
-CREATE TABLE `vendors` (
-  `id` int(11) NOT NULL,
-  `name` varchar(40) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `vendors`
---
-
-INSERT INTO `vendors` (`id`, `name`) VALUES(1, 'Unknown');
-INSERT INTO `vendors` (`id`, `name`) VALUES(2, 'Eltex');
-INSERT INTO `vendors` (`id`, `name`) VALUES(3, 'Huawei');
-INSERT INTO `vendors` (`id`, `name`) VALUES(4, 'Zyxel');
-INSERT INTO `vendors` (`id`, `name`) VALUES(5, 'Raisecom');
-INSERT INTO `vendors` (`id`, `name`) VALUES(6, 'SNR');
-INSERT INTO `vendors` (`id`, `name`) VALUES(7, 'Dlink');
-INSERT INTO `vendors` (`id`, `name`) VALUES(8, 'Allied Telesis');
-INSERT INTO `vendors` (`id`, `name`) VALUES(9, 'Mikrotik');
-INSERT INTO `vendors` (`id`, `name`) VALUES(10, 'NetGear');
-INSERT INTO `vendors` (`id`, `name`) VALUES(11, 'Ubiquiti');
-INSERT INTO `vendors` (`id`, `name`) VALUES(15, 'HP');
-INSERT INTO `vendors` (`id`, `name`) VALUES(16, 'Cisco');
-INSERT INTO `vendors` (`id`, `name`) VALUES(17, 'Maipu');
-INSERT INTO `vendors` (`id`, `name`) VALUES(18, 'Asus');
-INSERT INTO `vendors` (`id`, `name`) VALUES(19, 'Linux');
-INSERT INTO `vendors` (`id`, `name`) VALUES(20, 'APC');
-INSERT INTO `vendors` (`id`, `name`) VALUES(21, 'Schneider');
-INSERT INTO `vendors` (`id`, `name`) VALUES(33, 'QSC');
-INSERT INTO `vendors` (`id`, `name`) VALUES(34, 'Projectiondesign');
-INSERT INTO `vendors` (`id`, `name`) VALUES(35, 'Lenovo');
-INSERT INTO `vendors` (`id`, `name`) VALUES(36, 'HiWatch');
-INSERT INTO `vendors` (`id`, `name`) VALUES(37, 'LTV');
-INSERT INTO `vendors` (`id`, `name`) VALUES(38, 'Yeastar');
-INSERT INTO `vendors` (`id`, `name`) VALUES(39, 'Yealink');
-INSERT INTO `vendors` (`id`, `name`) VALUES(40, 'Gigaset');
-INSERT INTO `vendors` (`id`, `name`) VALUES(41, 'Linksys');
-INSERT INTO `vendors` (`id`, `name`) VALUES(42, 'Samsung');
-INSERT INTO `vendors` (`id`, `name`) VALUES(43, 'Supermicro');
-INSERT INTO `vendors` (`id`, `name`) VALUES(44, 'RDP');
-INSERT INTO `vendors` (`id`, `name`) VALUES(45, 'SANYO');
-INSERT INTO `vendors` (`id`, `name`) VALUES(46, 'Extreme');
-INSERT INTO `vendors` (`id`, `name`) VALUES(47, 'Intel');
-INSERT INTO `vendors` (`id`, `name`) VALUES(48, 'Micron');
-INSERT INTO `vendors` (`id`, `name`) VALUES(49, 'Gigabyte');
-INSERT INTO `vendors` (`id`, `name`) VALUES(50, 'Acer');
-INSERT INTO `vendors` (`id`, `name`) VALUES(51, 'Seagate');
-INSERT INTO `vendors` (`id`, `name`) VALUES(52, 'SanDisk');
-INSERT INTO `vendors` (`id`, `name`) VALUES(53, 'Toshiba');
-INSERT INTO `vendors` (`id`, `name`) VALUES(54, 'Kingston');
-INSERT INTO `vendors` (`id`, `name`) VALUES(55, 'AddPac');
-INSERT INTO `vendors` (`id`, `name`) VALUES(56, 'Devline');
-INSERT INTO `vendors` (`id`, `name`) VALUES(57, 'Canon');
-INSERT INTO `vendors` (`id`, `name`) VALUES(58, 'Brother');
-INSERT INTO `vendors` (`id`, `name`) VALUES(59, 'Epson');
-INSERT INTO `vendors` (`id`, `name`) VALUES(60, 'IP-COM');
-INSERT INTO `vendors` (`id`, `name`) VALUES(61, 'Panasonic');
-INSERT INTO `vendors` (`id`, `name`) VALUES(62, 'OKI');
-INSERT INTO `vendors` (`id`, `name`) VALUES(63, 'Apple');
-INSERT INTO `vendors` (`id`, `name`) VALUES(64, 'Eaton');
-INSERT INTO `vendors` (`id`, `name`) VALUES(65, 'Barco');
-INSERT INTO `vendors` (`id`, `name`) VALUES(66, 'Trassir');
-INSERT INTO `vendors` (`id`, `name`) VALUES(67, 'Testo');
-INSERT INTO `vendors` (`id`, `name`) VALUES(68, 'Hw-group');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `version`
---
-
-CREATE TABLE `version` (
-  `id` int(11) NOT NULL DEFAULT 1,
-  `version` varchar(10) NOT NULL DEFAULT '2.4.14'
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
--- Дамп данных таблицы `version`
---
-
-INSERT INTO `version` (`id`, `version`) VALUES(1, '2.7.0');
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `Wan_stats`
---
-
-CREATE TABLE `Wan_stats` (
-  `id` int(11) NOT NULL,
-  `time` datetime NOT NULL DEFAULT current_timestamp(),
-  `router_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,
-  `forward_in` 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;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `worklog`
---
-
-CREATE TABLE `worklog` (
-  `id` bigint(20) UNSIGNED NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
-  `customer` varchar(50) NOT NULL DEFAULT 'system',
-  `ip` varchar(18) NOT NULL DEFAULT '127.0.0.1',
-  `message` text NOT NULL,
-  `level` int(11) NOT NULL DEFAULT 1
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
-
---
--- Индексы сохранённых таблиц
---
-
---
--- Индексы таблицы `acl`
---
-ALTER TABLE `acl`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `ad_comp_cache`
---
-ALTER TABLE `ad_comp_cache`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `comp_name` (`name`);
-
---
--- Индексы таблицы `auth_rules`
---
-ALTER TABLE `auth_rules`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `rule` (`rule`),
-  ADD KEY `user_id` (`user_id`);
-
---
--- Индексы таблицы `building`
---
-ALTER TABLE `building`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `config`
---
-ALTER TABLE `config`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `option` (`option_id`);
-
---
--- Индексы таблицы `config_options`
---
-ALTER TABLE `config_options`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `connections`
---
-ALTER TABLE `connections`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `auth_id` (`auth_id`),
-  ADD KEY `device_id` (`device_id`,`port_id`);
-
---
--- Индексы таблицы `Customers`
---
-ALTER TABLE `Customers`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `devices`
---
-ALTER TABLE `devices`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `ip` (`ip`),
-  ADD KEY `device_type` (`device_type`);
-
---
--- Индексы таблицы `device_l3_interfaces`
---
-ALTER TABLE `device_l3_interfaces`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `device_models`
---
-ALTER TABLE `device_models`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `device_ports`
---
-ALTER TABLE `device_ports`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `device_id` (`device_id`),
-  ADD KEY `port` (`port`),
-  ADD KEY `target_port_id` (`target_port_id`);
-
---
--- Индексы таблицы `device_types`
---
-ALTER TABLE `device_types`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `dhcp_log`
---
-ALTER TABLE `dhcp_log`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`action`);
-
---
--- Индексы таблицы `dhcp_queue`
---
-ALTER TABLE `dhcp_queue`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`action`);
-
---
--- Индексы таблицы `dns_cache`
---
-ALTER TABLE `dns_cache`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `dns` (`dns`,`ip`),
-  ADD KEY `timestamp` (`timestamp`);
-
---
--- Индексы таблицы `Filter_list`
---
-ALTER TABLE `Filter_list`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `Name` (`name`);
-
---
--- Индексы таблицы `gateway_subnets`
---
-ALTER TABLE `gateway_subnets`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `Group_filters`
---
-ALTER TABLE `Group_filters`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `GroupId` (`group_id`,`filter_id`);
-
---
--- Индексы таблицы `Group_list`
---
-ALTER TABLE `Group_list`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `mac_history`
---
-ALTER TABLE `mac_history`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `mac` (`mac`,`timestamp`),
-  ADD KEY `ip` (`ip`,`timestamp`),
-  ADD KEY `timestamp` (`timestamp`) USING BTREE,
-  ADD KEY `mac_2` (`mac`),
-  ADD KEY `ip_2` (`ip`);
-
---
--- Индексы таблицы `mac_vendors`
---
-ALTER TABLE `mac_vendors`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `oui` (`oui`);
-
---
--- Индексы таблицы `OU`
---
-ALTER TABLE `OU`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `Queue_list`
---
-ALTER TABLE `Queue_list`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `id` (`id`);
-
---
--- Индексы таблицы `remote_syslog`
---
-ALTER TABLE `remote_syslog`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `date` (`date`,`device_id`,`ip`);
-
---
--- Индексы таблицы `sessions`
---
-ALTER TABLE `sessions`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `last_accessed` (`last_accessed`);
-
---
--- Индексы таблицы `user_sessions`
---
-ALTER TABLE `user_sessions`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `session_id` (`session_id`),
-  ADD KEY `user_id` (`user_id`),
-  ADD KEY `is_active` (`is_active`);
-
---
--- Индексы таблицы `subnets`
---
-ALTER TABLE `subnets`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `ip_int_start` (`ip_int_start`,`ip_int_stop`),
-  ADD KEY `dhcp` (`dhcp`,`office`,`hotspot`,`static`);
-
---
--- Индексы таблицы `Traffic_detail`
---
-ALTER TABLE `Traffic_detail`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `src` (`auth_id`,`timestamp`,`router_id`,`src_ip`),
-  ADD KEY `dst` (`auth_id`,`timestamp`,`router_id`,`dst_ip`);
-
---
--- Индексы таблицы `Unknown_mac`
---
-ALTER TABLE `Unknown_mac`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`device_id`,`port_id`,`mac`);
-
---
--- Индексы таблицы `User_auth`
---
-ALTER TABLE `User_auth`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `auth_index` (`id`,`user_id`,`ip_int`,`mac`,`ip`,`deleted`) USING BTREE,
-  ADD KEY `deleted` (`deleted`),
-  ADD KEY `ou_id` (`ou_id`);
-
---
--- Индексы таблицы `User_auth_alias`
---
-ALTER TABLE `User_auth_alias`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `auth_id` (`auth_id`);
-
---
--- Индексы таблицы `User_list`
---
-ALTER TABLE `User_list`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `users` (`id`,`ou_id`,`enabled`,`blocked`,`deleted`);
-
---
--- Индексы таблицы `User_stats`
---
-ALTER TABLE `User_stats`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`auth_id`,`router_id`);
-
---
--- Индексы таблицы `User_stats_full`
---
-ALTER TABLE `User_stats_full`
-  ADD PRIMARY KEY (`id`),
-  ADD KEY `timestamp` (`timestamp`,`auth_id`,`router_id`);
-
---
--- Индексы таблицы `variables`
---
-ALTER TABLE `variables`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `name` (`name`),
-  ADD KEY `clear_time` (`clear_time`,`created`);
-
---
--- Индексы таблицы `vendors`
---
-ALTER TABLE `vendors`
-  ADD PRIMARY KEY (`id`);
-
---
--- Индексы таблицы `version`
---
-ALTER TABLE `version`
-  ADD UNIQUE KEY `id` (`id`);
-
---
--- Индексы таблицы `Wan_stats`
---
-ALTER TABLE `Wan_stats`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `main` (`time`,`router_id`,`interface_id`),
-  ADD KEY `times` (`time`);
-
---
--- Индексы таблицы `worklog`
---
-ALTER TABLE `worklog`
-  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`);
-
-
---
--- Индексы таблицы `dns_queue`
---
-ALTER TABLE `dns_queue`
-  ADD PRIMARY KEY (`id`);
-
-
---
--- Индексы таблицы `filter_instances`
---
-ALTER TABLE `filter_instances`
-  ADD PRIMARY KEY (`id`),
-  ADD UNIQUE KEY `name` (`name`);
-
---
--- AUTO_INCREMENT для сохранённых таблиц
---
-
---
--- AUTO_INCREMENT для таблицы `acl`
---
-ALTER TABLE `acl`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `ad_comp_cache`
---
-ALTER TABLE `ad_comp_cache`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `auth_rules`
---
-ALTER TABLE `auth_rules`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `building`
---
-ALTER TABLE `building`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `config`
---
-ALTER TABLE `config`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `config_options`
---
-ALTER TABLE `config_options`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `connections`
---
-ALTER TABLE `connections`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Customers`
---
-ALTER TABLE `Customers`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `devices`
---
-ALTER TABLE `devices`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `device_l3_interfaces`
---
-ALTER TABLE `device_l3_interfaces`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `device_models`
---
-ALTER TABLE `device_models`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `device_ports`
---
-ALTER TABLE `device_ports`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `device_types`
---
-ALTER TABLE `device_types`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `dhcp_log`
---
-ALTER TABLE `dhcp_log`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `dhcp_queue`
---
-ALTER TABLE `dhcp_queue`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `dns_cache`
---
-ALTER TABLE `dns_cache`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `dns_queue`
---
-ALTER TABLE `dns_queue`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Filter_list`
---
-ALTER TABLE `Filter_list`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `gateway_subnets`
---
-ALTER TABLE `gateway_subnets`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Group_filters`
---
-ALTER TABLE `Group_filters`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Group_list`
---
-ALTER TABLE `Group_list`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `mac_history`
---
-ALTER TABLE `mac_history`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `mac_vendors`
---
-ALTER TABLE `mac_vendors`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `OU`
---
-ALTER TABLE `OU`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Queue_list`
---
-ALTER TABLE `Queue_list`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `remote_syslog`
---
-ALTER TABLE `remote_syslog`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `user_sessions`
---
-ALTER TABLE `user_sessions`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `subnets`
---
-ALTER TABLE `subnets`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Traffic_detail`
---
-ALTER TABLE `Traffic_detail`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Unknown_mac`
---
-ALTER TABLE `Unknown_mac`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_auth`
---
-ALTER TABLE `User_auth`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_auth_alias`
---
-ALTER TABLE `User_auth_alias`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_list`
---
-ALTER TABLE `User_list`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_stats`
---
-ALTER TABLE `User_stats`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `User_stats_full`
---
-ALTER TABLE `User_stats_full`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `variables`
---
-ALTER TABLE `variables`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `vendors`
---
-ALTER TABLE `vendors`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `Wan_stats`
---
-ALTER TABLE `Wan_stats`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `filter_instances`
---
-ALTER TABLE `filter_instances`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-
---
--- AUTO_INCREMENT для таблицы `worklog`
---
-ALTER TABLE `worklog`
-  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
-COMMIT;
-
-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

+ 0 - 1
docs/mysql/create_db.sql

@@ -1 +0,0 @@
-CREATE DATABASE IF NOT EXISTS `stat` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

+ 0 - 1
docs/mysql/latest-mysql.sql

@@ -1 +0,0 @@
-./2-9-0/mysql.sql

+ 73 - 0
docs/patches/patch_seq.pl

@@ -0,0 +1,73 @@
+#!/usr/bin/perl
+
+#
+# Copyright (C) Roman Dmitriev, rnd@rajven.ru
+#
+
+use utf8;
+use open ":encoding(utf8)";
+use open ':std', ':encoding(UTF-8)';
+use Encode;
+no warnings 'utf8';
+use English;
+use FindBin '$Bin';
+use lib "/opt/Eye/scripts";
+use Getopt::Long qw(GetOptions);
+use Data::Dumper;
+use eyelib::config;
+use eyelib::main;
+use eyelib::database;
+use eyelib::common;
+use eyelib::net_utils;
+use strict;
+use warnings;
+
+# debug disable force
+$debug = 0;
+
+# === Явное указание портов ===
+my $PG_PORT    = 5432;
+
+# === Подключение к PostgreSQL (цель) ===
+my $pg_dsn = "dbi:Pg:dbname=$DBNAME;host=$DBHOST;port=$PG_PORT;";
+my $pg_db = DBI->connect($pg_dsn, $DBUSER, $DBPASS, {
+    RaiseError => 0,
+    AutoCommit => 1,
+    pg_enable_utf8 => 1,
+    pg_server_prepare => 0
+});
+if (!defined $pg_db) {
+    print "Cannot connect to PostgreSQL server: $DBI::errstr\n";
+    print "For install/configure PostgreSQL server please run migrate2psql.sh!\n";
+    exit 100;
+}
+
+
+print "\n=== Resetting all table sequences ===\n";
+
+# Получаем список всех таблиц из целевой схемы (PostgreSQL)
+my $tables_sql = "SELECT tablename FROM pg_tables WHERE schemaname = 'public'";
+my $sth = $pg_db->prepare($tables_sql);
+$sth->execute();
+
+while (my ($table) = $sth->fetchrow_array) {
+    # Формируем имя последовательности
+    my $seq_name = "${table}_id_seq";
+    # Проверяем, существует ли такая последовательность
+    my ($exists) = $pg_db->selectrow_array(
+        "SELECT 1 FROM pg_class WHERE relname = ? AND relkind = 'S'",
+        undef, $seq_name
+    );
+    if ($exists) {
+        # Получаем MAX(id)
+        my ($max_id) = $pg_db->selectrow_array("SELECT MAX(id) FROM \"$table\"");
+        $max_id //= 1;
+        # Сбрасываем последовательность
+        $pg_db->do("SELECT setval('$seq_name', $max_id)");
+        print "  → $table: sequence reset to $max_id\n";
+    }
+}
+
+print "✅ All sequences updated.\n";
+
+exit 0;

+ 215 - 0
docs/patches/sha512.alt.patch

@@ -0,0 +1,215 @@
+--- USM.pm	2018-06-29 21:06:28.000000000 +0300
++++ USM.sha512.pm	2025-12-03 11:58:04.962638800 +0300
+@@ -25,8 +25,8 @@
+ 
+ use Crypt::DES();
+ use Digest::MD5();
+-use Digest::SHA1();
+-use Digest::HMAC();
++use Digest::SHA qw( hmac_sha1 hmac_sha224 hmac_sha256 hmac_sha384 hmac_sha512 );
++use Digest::HMAC_MD5 qw ( hmac_md5 );
+ 
+ ## Version of the Net::SNMP::Security::USM module
+ 
+@@ -40,7 +40,9 @@
+ 
+ our %EXPORT_TAGS = (
+    authprotos => [
+-      qw( AUTH_PROTOCOL_NONE AUTH_PROTOCOL_HMACMD5 AUTH_PROTOCOL_HMACSHA )
++      qw( AUTH_PROTOCOL_NONE AUTH_PROTOCOL_HMACMD5 AUTH_PROTOCOL_HMACSHA
++          AUTH_PROTOCOL_HMACSHA224 AUTH_PROTOCOL_HMACSHA256.
++          AUTH_PROTOCOL_HMACSHA384 AUTH_PROTOCOL_HMACSHA512 )
+    ],
+    levels     => [
+       qw( SECURITY_LEVEL_NOAUTHNOPRIV SECURITY_LEVEL_AUTHNOPRIV
+@@ -63,9 +65,13 @@
+ 
+ ## RCC 3414 - Authentication protocols
+ 
+-sub AUTH_PROTOCOL_NONE    { '1.3.6.1.6.3.10.1.1.1' } # usmNoAuthProtocol
+-sub AUTH_PROTOCOL_HMACMD5 { '1.3.6.1.6.3.10.1.1.2' } # usmHMACMD5AuthProtocol
+-sub AUTH_PROTOCOL_HMACSHA { '1.3.6.1.6.3.10.1.1.3' } # usmHMACSHAAuthProtocol
++sub AUTH_PROTOCOL_NONE       { '1.3.6.1.6.3.10.1.1.1' } # usmNoAuthProtocol
++sub AUTH_PROTOCOL_HMACMD5    { '1.3.6.1.6.3.10.1.1.2' } # usmHMACMD5AuthProtocol
++sub AUTH_PROTOCOL_HMACSHA    { '1.3.6.1.6.3.10.1.1.3' } # usmHMACSHAAuthProtocol
++sub AUTH_PROTOCOL_HMACSHA224 { '1.3.6.1.6.3.10.1.1.4' } # usmHMAC128SHA224AuthProtocol
++sub AUTH_PROTOCOL_HMACSHA256 { '1.3.6.1.6.3.10.1.1.5' } # usmHMAC192SHA256AuthProtocol
++sub AUTH_PROTOCOL_HMACSHA384 { '1.3.6.1.6.3.10.1.1.6' } # usmHMAC256SHA384AuthProtocol
++sub AUTH_PROTOCOL_HMACSHA512 { '1.3.6.1.6.3.10.1.1.7' } # usmHMAC384SHA512AuthProtocol
+ 
+ ## RFC 3414 - Privacy protocols
+ 
+@@ -124,6 +130,7 @@
+       '_time_epoc'          => time(),                # snmpEngineBoots epoc
+       '_user_name'          => q{},                   # securityName 
+       '_auth_data'          => undef,                 # Authentication data
++      '_auth_maclen'        => undef,                 # MAC length
+       '_auth_key'           => undef,                 # authKey 
+       '_auth_password'      => undef,                 # Authentication password 
+       '_auth_protocol'      => AUTH_PROTOCOL_HMACMD5, # authProtocol
+@@ -280,10 +287,10 @@
+    if ($pdu->security_level() > SECURITY_LEVEL_NOAUTHNOPRIV) {
+ 
+       # Save the location to fill in msgAuthenticationParameters later
+-      $auth_location = $msg->length() + 12 + length $pdu_buffer;
++      $auth_location = $msg->length() + $this->{_auth_maclen} + length $pdu_buffer;
+ 
+       # Set the msgAuthenticationParameters to all zeros
+-      $auth_params = pack 'x12';
++      $auth_params = pack "x$this->{_auth_maclen}";
+    }
+ 
+    if (!defined $msg->prepare(OCTET_STRING, $auth_params)) {
+@@ -418,12 +425,12 @@
+    # to compute the HMAC properly.
+ 
+    if (my $len = length $auth_params) {
+-      if ($len != 12) {
++      if ($len != $this->{_auth_maclen}) {
+          return $this->_error(
+             'The msgAuthenticationParameters length of %d is invalid', $len
+          );
+       }
+-      substr ${$msg->reference}, ($msg->index() - 12), 12, pack 'x12';
++         substr ${$msg->reference}, ($msg->index() - $this->{_auth_maclen}), $this->{_auth_maclen}, pack "x$this->{_auth_maclen}";
+    }
+ 
+    # msgPrivacyParameters::=OCTET STRING
+@@ -747,6 +754,18 @@
+       quotemeta AUTH_PROTOCOL_HMACMD5,   AUTH_PROTOCOL_HMACMD5,
+       '(?:hmac-)?sha(?:-?1|-96)?',       AUTH_PROTOCOL_HMACSHA,
+       quotemeta AUTH_PROTOCOL_HMACSHA,   AUTH_PROTOCOL_HMACSHA,
++      '(?:hmac-)?sha(?:-?224)',          AUTH_PROTOCOL_HMACSHA224,
++      'usmHMAC128SHA224AuthProtocol',    AUTH_PROTOCOL_HMACSHA224,
++      quotemeta AUTH_PROTOCOL_HMACSHA224,AUTH_PROTOCOL_HMACSHA224,
++      '(?:hmac-)?sha(?:-?256)',          AUTH_PROTOCOL_HMACSHA256,
++      'usmHMAC192SHA256AuthProtocol',    AUTH_PROTOCOL_HMACSHA256,
++      quotemeta AUTH_PROTOCOL_HMACSHA256,AUTH_PROTOCOL_HMACSHA256,
++      '(?:hmac-)?sha(?:-?384)',          AUTH_PROTOCOL_HMACSHA384,
++      'usmHMAC256SHA384AuthProtocol',    AUTH_PROTOCOL_HMACSHA384,
++      quotemeta AUTH_PROTOCOL_HMACSHA384,AUTH_PROTOCOL_HMACSHA384,
++      '(?:hmac-)?sha(?:-?512)',          AUTH_PROTOCOL_HMACSHA512,
++      'usmHMAC384SHA512AuthProtocol',    AUTH_PROTOCOL_HMACSHA512,
++      quotemeta AUTH_PROTOCOL_HMACSHA512,AUTH_PROTOCOL_HMACSHA512,
+    };
+ 
+    sub _auth_protocol
+@@ -1099,8 +1118,7 @@
+    }
+ 
+    # Set the msgAuthenticationParameters
+-   substr ${$msg->reference}, -$auth_location, 12, $this->_auth_hmac($msg);
+-
++   substr ${$msg->reference}, -$auth_location, $this->{_auth_maclen}, $this->_auth_hmac($msg);
+    return TRUE;
+ }
+ 
+@@ -1125,7 +1143,7 @@
+    return q{} if (!defined($this->{_auth_data}) || !defined $msg);
+ 
+    return substr
+-      $this->{_auth_data}->reset()->add(${$msg->reference()})->digest(), 0, 12;
++      $this->{_auth_data}(${$msg->reference()}, $this->{_auth_key}), 0, $this->{_auth_maclen};
+ }
+ 
+ sub _auth_data_init
+@@ -1140,13 +1158,33 @@
+ 
+    if ($this->{_auth_protocol} eq AUTH_PROTOCOL_HMACMD5) {
+ 
+-      $this->{_auth_data} =
+-         Digest::HMAC->new($this->{_auth_key}, 'Digest::MD5');
++      $this->{_auth_data} = \&hmac_md5;
++      $this->{_auth_maclen} = 12;
+ 
+    } elsif ($this->{_auth_protocol} eq AUTH_PROTOCOL_HMACSHA) {
+ 
+-      $this->{_auth_data} =
+-         Digest::HMAC->new($this->{_auth_key}, 'Digest::SHA1');
++      $this->{_auth_data} = \&hmac_sha1;
++      $this->{_auth_maclen} = 12;
++
++   } elsif ($this->{_auth_protocol} eq AUTH_PROTOCOL_HMACSHA224) {
++
++      $this->{_auth_data} = \&hmac_sha224;
++      $this->{_auth_maclen} = 16;
++
++   } elsif ($this->{_auth_protocol} eq AUTH_PROTOCOL_HMACSHA256) {
++
++      $this->{_auth_data} = \&hmac_sha256;
++      $this->{_auth_maclen} = 24;
++
++   } elsif ($this->{_auth_protocol} eq AUTH_PROTOCOL_HMACSHA384) {
++
++      $this->{_auth_data} = \&hmac_sha384;
++      $this->{_auth_maclen} = 32;
++
++   } elsif ($this->{_auth_protocol} eq AUTH_PROTOCOL_HMACSHA512) {
++
++      $this->{_auth_data} = \&hmac_sha512;
++      $this->{_auth_maclen} = 48;
+ 
+    } else {
+ 
+@@ -1391,7 +1429,7 @@
+    if ($this->{_auth_protocol} eq AUTH_PROTOCOL_HMACMD5) {
+       $this->{_priv_data}->{hash} = Digest::MD5->new();
+    } elsif ($this->{_auth_protocol} eq AUTH_PROTOCOL_HMACSHA) {
+-      $this->{_priv_data}->{hash} = Digest::SHA1->new();
++      $this->{_priv_data}->{hash} = Digest::SHA->new();
+    }
+ 
+    return TRUE;
+@@ -1626,7 +1664,11 @@
+    my $key_len =
+    {
+       AUTH_PROTOCOL_HMACMD5,    [ 16, 'HMAC-MD5'  ],
+-      AUTH_PROTOCOL_HMACSHA,    [ 20, 'HMAC-SHA1' ],
++      AUTH_PROTOCOL_HMACSHA,    [ 20, 'HMAC-SHA' ],
++      AUTH_PROTOCOL_HMACSHA224, [ 28, 'HMAC-SHA224' ],
++      AUTH_PROTOCOL_HMACSHA256, [ 32, 'HMAC-SHA256' ],
++      AUTH_PROTOCOL_HMACSHA384, [ 48, 'HMAC-SHA384' ],
++      AUTH_PROTOCOL_HMACSHA512, [ 64, 'HMAC-SHA512' ],
+    };
+ 
+    if (!exists $key_len->{$this->{_auth_protocol}}) {
+@@ -1681,7 +1723,7 @@
+       if ($this->{_auth_protocol} eq AUTH_PROTOCOL_HMACMD5) {
+          $hnnn = Digest::MD5->new();
+       } elsif ($this->{_auth_protocol} eq AUTH_PROTOCOL_HMACSHA) {
+-         $hnnn = Digest::SHA1->new();
++         $hnnn = Digest::SHA->new();
+       } else {
+          return $this->_error(
+             'The authProtocol "%s" is unknown', $this->{_auth_protocol}
+@@ -1782,9 +1824,13 @@
+ 
+    my $digests =
+    {
+-      AUTH_PROTOCOL_HMACMD5,  'Digest::MD5',
+-      AUTH_PROTOCOL_HMACSHA,  'Digest::SHA1',
+-   };
++      AUTH_PROTOCOL_HMACMD5,    ['Digest::MD5', ],
++      AUTH_PROTOCOL_HMACSHA,    ['Digest::SHA', 1],
++      AUTH_PROTOCOL_HMACSHA224, ['Digest::SHA', 224],
++      AUTH_PROTOCOL_HMACSHA256, ['Digest::SHA', 256],
++      AUTH_PROTOCOL_HMACSHA384, ['Digest::SHA', 384],
++      AUTH_PROTOCOL_HMACSHA512, ['Digest::SHA', 512],
++  };
+ 
+    if (!exists $digests->{$this->{_auth_protocol}}) {
+       return $this->_error(
+@@ -1792,7 +1838,12 @@
+       );
+    }
+ 
+-   my $digest = $digests->{$this->{_auth_protocol}}->new;
++   my $digest;
++   if (!defined($digests->{$this->{_auth_protocol}}[1])) {
++       $digest = $digests->{$this->{_auth_protocol}}[0]->new;
++       } else {
++       $digest = $digests->{$this->{_auth_protocol}}[0]->new($digests->{$this->{_auth_protocol}}[1]);
++       }
+ 
+    # Create the initial digest using the password
+ 

+ 1 - 1
docs/php-fpm/eye.conf

@@ -32,7 +32,7 @@ php_admin_value[sys_temp_dir] = /opt/Eye/html/tmp
 php_admin_value[upload_tmp_dir] = /opt/Eye/html/tmp
 php_admin_value[open_basedir]= /opt/Eye/html/:/opt/Eye/html/tmp:/opt/Eye/html/sessions
 
-php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f no-reply@oem.ru
+;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f no-reply@oem.ru
 
 php_admin_value[short_open_tag] = On
 php_admin_value[session.save_path] = /opt/Eye/html/sessions

+ 0 - 5
docs/sudoers.d/eye

@@ -1,5 +0,0 @@
-eye        ALL=(root)      NOPASSWD: /opt/Eye/scripts/sync_mikrotik.pl
-eye        ALL=(root)      NOPASSWD: /opt/Eye/scripts/update-dnsmasq
-eye        ALL=(root)      NOPASSWD: /opt/Eye/scripts/fetch_new_arp.pl
-eye        ALL=(root)      NOPASSWD: /opt/Eye/scripts/restart_nagios
-eye        ALL=(root)      NOPASSWD: /opt/Eye/scripts/dnsmasq-hook.sh

+ 0 - 58
docs/update-named

@@ -1,58 +0,0 @@
-#!/bin/bash
-
-logger -t named "Refresh named config request"
-
-/opt/Eye/scripts/print-dns-zones.pl
-[ $? -ne 0 ] && exit 1
-
-RELOAD=
-ZONELIST=`ls -x -1 /var/named/chroot/var/named/master/db.*.new`
-echo "${ZONELIST}" | while read NS2_DB; do
-NS1_DB=`echo "$NS2_DB" | sed 's/.new$//'`
-[ ! -e $NS1_DB ] && {
-    cat $NS2_DB > $NS1_DB
-    chown named:named ${NS1_DB} >/dev/null
-    RELOAD=1
-    continue
-    }
-TMP_R1=`mktemp /tmp/rev_old.XXXXXXXXXX`
-TMP_R2=`mktemp /tmp/rev_new.XXXXXXXXXX`
-S1=`cat $NS1_DB | grep "; serial" | awk '{ print \$1 }'`
-S2=`cat $NS2_DB | grep "; serial" | awk '{ print \$1 }'`
-cat $NS1_DB | grep -v "; serial" >$TMP_R2
-cat $NS2_DB | grep -v "; serial" >$TMP_R1
-diff -aqbBfi $TMP_R2 $TMP_R1 >/dev/null
-state=$?
-rm -f $TMP_R1 >/dev/null
-rm -f $TMP_R2 >/dev/null
-[ ${state} -eq 0 ] && continue
-echo "dns config $NS1_DB changed."
-cat $NS2_DB > $NS1_DB
-RELOAD=1
-rm -f "${NS2_DB}" >/dev/null
-chown named:named ${NS1_DB} >/dev/null
-done
-
-diff -aqbBfi /var/named/chroot/etc/named.dynamic.new /var/named/chroot/etc/named.dynamic >/dev/null
-[ $? -ne 0 ] && {
-    RELOAD=1
-    cat /var/named/chroot/etc/named.dynamic.new >/var/named/chroot/etc/named.dynamic
-    }
-
-if [ -n "${RELOAD}" ]; then
-    logger -t named "Configuration changed. Check config"
-    /usr/sbin/named-checkconf -t /var/named/chroot/ -z >/dev/null
-    if [ $? -eq 0 ]; then
-	logger -t named "Config fine! Restart named"
-        /sbin/service named restart >/dev/null
-        fi
-    else
-	logger -t named "Config not changed! Skip restart"
-    fi
-
-rm -f /var/named/chroot/etc/named.dynamic.new 2>/dev/null
-rm -f /var/named/chroot/var/named/master/db.*.new 2>/dev/null
-
-logger -t named "done"
-
-exit

+ 38 - 35
html/admin/customers/building.php

@@ -2,51 +2,54 @@
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
-if (isset($_POST["remove"])) {
-    $fid = $_POST["f_id"];
-    foreach ($fid as $key => $val) {
-        if (isset($val) and $val > 1) {
-            LOG_INFO($db_link,'Remove building id: '. $val .' '. dump_record($db_link,'building','id='.$val));
-            delete_record($db_link, "building", "id=" . $val);
-        }
+if (getPOST("remove")) {
+    $fid = getPOST("f_id", null, []);
+    $valid_ids = array_filter(array_map('intval', $fid), fn($id) => $id > 1);
+
+    foreach ($valid_ids as $val) {
+        delete_record($db_link, "building", "id=?", [$val]);
     }
+
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST['save'])) {
-    $len = is_array($_POST['r_id']) ? count($_POST['r_id']) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $save_id = intval($_POST['save'][$i]);
-        if ($save_id == 0) {
-            continue;
-        }
-        $len_all = is_array($_POST['r_id']) ? count($_POST['r_id']) : 0;
-        for ($j = 0; $j < $len_all; $j ++) {
-            if (intval($_POST['r_id'][$j]) != $save_id) {
-                continue;
-            }
-            $value = $_POST['f_building_name'][$j];
-            $value_comment = $_POST['f_building_comment'][$j];
-            if (isset($value)) {
-                $new['name'] = $value;
-                $new['comment'] = $value_comment;
-                LOG_INFO($db_link,"Change building id='{$save_id}': name=".$value." comment=".$value_comment);
-                update_record($db_link, "building", "id='{$save_id}'", $new);
-            }
+if (getPOST("save")) {
+    $r_id = getPOST("r_id",null, []);
+    $f_building_name = getPOST("f_building_name", null, []);
+    $f_building_description = getPOST("f_building_description", null, []);
+    $save_flags = getPOST("save", null, []);
+
+    $r_id = array_map('intval', $r_id);
+    $save_flags = array_map('intval', $save_flags);
+
+    foreach ($save_flags as $i => $save_id) {
+        if ($save_id <= 0) continue;
+
+        $found_index = array_search($save_id, $r_id, true);
+        if ($found_index === false) continue;
+
+        $name = trim($f_building_name[$found_index] ?? '');
+        $description = trim($f_building_description[$found_index] ?? '');
+
+        if ($name !== '') {
+            $new = ['name' => $name, 'description' => $description];
+            update_record($db_link, "building", "id=?", $new, [$save_id]);
         }
     }
+
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["create"])) {
-    $building_name = $_POST["new_building"];
-    if (isset($building_name)) {
-        $new['name'] = $building_name;
-        LOG_INFO($db_link,'Add building $building_name');
+if (getPOST("create")) {
+    $building_name = trim(getPOST("new_building", null, ''));
+    
+    if ($building_name !== '') {
+        $new = ['name' => $building_name];
         insert_record($db_link, "building", $new);
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
@@ -62,19 +65,19 @@ print_control_submenu($page_url);
 <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
 <td><b>id</b></td>
 <td><b><?php echo WEB_cell_name; ?></b></td>
-<td><b><?php echo WEB_cell_comment; ?></b></td>
+<td><b><?php echo WEB_cell_description; ?></b></td>
 <td>
 <input type="submit" onclick="return confirm('<?php print WEB_btn_delete; ?>?')" name="remove" value="<?php print WEB_btn_remove; ?>">
 </td>
 </tr>
 <?php
-$t_building = get_records($db_link,'building','TRUE ORDER BY id');
+$t_building = get_records_sql($db_link,'SELECT * FROM building ORDER BY name');
 foreach ($t_building as $row) {
     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\"><input type=\"hidden\" name='r_id[]' value='{$row['id']}'>{$row['id']}</td>\n";
     print "<td class=\"data\"><input type=\"text\" name='f_building_name[]' value='{$row['name']}'></td>\n";
-    print "<td class=\"data\"><input type=\"text\" name='f_building_comment[]' value='{$row['comment']}'></td>\n";
+    print "<td class=\"data\"><input type=\"text\" name='f_building_description[]' value='{$row['description']}'></td>\n";
     print "<td class=\"data\"><button name='save[]' value='{$row['id']}'>".WEB_btn_save."</button></td>\n";
     print "</tr>\n";
 }

+ 56 - 35
html/admin/customers/control-options.php

@@ -3,37 +3,53 @@
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
 
-if (isset($_POST["remove"])) {
-    if (!empty($_POST["f_id"])) {
-        $fid = $_POST["f_id"];
+if (getPOST("remove")) {
+    $fid = getPOST("f_id", null, []);
+    if (!empty($fid) && is_array($fid)) {
         foreach ($fid as $option_id => $config_id) {
-            $opt_def = get_record($db_link, "config_options", "id=" . $option_id);
-            LOG_INFO($db_link, WEB_config_remove_option . " id: " . $config_id . " name: " . $opt_def["option_name"]);
-            delete_record($db_link, "config", "id=" . $config_id);
+            $option_id = (int)$option_id;
+            $config_id = (int)$config_id;
+            
+            if ($option_id <= 0 || $config_id <= 0) continue;
+
+            $opt_def = get_record($db_link, "config_options", "id = ?", [$option_id]);
+            if ($opt_def) {
+                LOG_INFO($db_link, WEB_config_remove_option . " id: " . $config_id . " name: " . ($opt_def["option_name"] ?? ''));
+            }
+            delete_record($db_link, "config", "id = ?", [$config_id]);
         }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST['save'])) {
-    if (!empty($_POST["f_id"])) {
-        $fid = $_POST["f_id"];
+if (getPOST("save")) {
+    $fid = getPOST("f_id", null, []);
+    $f_config_value = getPOST("f_config_value", null, []);
+    if (!empty($fid) && is_array($fid)) {
         foreach ($fid as $option_id => $config_id) {
-            $value = $_POST['f_config_value'][$config_id];
-            $option = get_record_sql($db_link, "SELECT * FROM config_options WHERE id=" . $option_id);
-            if (isset($value)) {
-                $new['value'] = $value;
-            }
-            //crypt password
-            if ($option_id == 29) { 
-                $new['value']=crypt_string($value); 
+            $option_id = (int)$option_id;
+            $config_id = (int)$config_id;
+            
+            if ($option_id <= 0 || $config_id <= 0) continue;
+
+            $value = trim($f_config_value[$config_id] ?? '');
+            $option = get_record($db_link, "config_options", "id = ?", [$option_id]);
+
+            if (!$option) continue;
+
+            $new = [];
+            if ($option_id == 29) {
+                // Пароль — шифруем
+                $new['value'] = crypt_string($value);
             } else {
-            //log event if changed option not password
-                LOG_INFO($db_link, WEB_config_set_option . " id: " . $config_id . " name: " . $option["option_name"] . " = " . $value);
+                // Обычное значение
+                $new['value'] = $value;
+                LOG_INFO($db_link, WEB_config_set_option . " id: " . $config_id . " name: " . ($option["option_name"] ?? '') . " = " . $value);
             }
+
             if (!empty($new)) {
-                update_record($db_link, "config", "id=" . $config_id, $new);
+                update_record($db_link, "config", "id = ?", $new, [$config_id]);
             }
         }
     }
@@ -41,14 +57,19 @@ if (isset($_POST['save'])) {
     exit;
 }
 
-if (isset($_POST["create"])) {
-    $new_option = $_POST["f_new_option"];
-    if (isset($new_option)) {
-        $new['option_id'] = $new_option;
-        $new['value'] = get_option($db_link, $new_option);
-        $opt_def = get_record($db_link, "config_options", "id=$new_option");
-        LOG_INFO($db_link, WEB_config_add_option . " id: " . $new_option . " name: " . $opt_def["option_name"] . " = " . $new['value']);
-        insert_record($db_link, "config", $new);
+if (getPOST("create")) {
+    $new_option = (int)getPOST("f_new_option", null, 0);
+    
+    if ($new_option > 0) {
+        $opt_def = get_record($db_link, "config_options", "id = ?", [$new_option]);
+        if ($opt_def) {
+            $new = [
+                'option_id' => $new_option,
+                'value' => get_option($db_link, $new_option)
+            ];
+            LOG_INFO($db_link, WEB_config_add_option . " id: " . $new_option . " name: " . ($opt_def["option_name"] ?? '') . " = " . ($new['value'] ?? ''));
+            insert_record($db_link, "config", $new);
+        }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
@@ -72,24 +93,24 @@ print_control_submenu($page_url);
                 <td width=20><input type="checkbox" onClick="checkAll(this.checked);"></td>
                 <td width=150><b><?php print WEB_config_option; ?></b></td>
                 <td width=150><b><?php print WEB_config_value; ?></b></td>
-                <td width=350><b><?php print WEB_msg_comment; ?></b></td>
+                <td width=350><b><?php print WEB_msg_description; ?></b></td>
                 <td class="warn">
                     <input type="submit" onclick="return confirm('<?php print WEB_btn_delete; ?>?')" name="remove" value="<?php print WEB_btn_remove; ?>">
                 </td>
                 <td class="up">
-                    <button name='save'><?php print WEB_btn_save; ?></button>
+                    <button name='save' value='save'><?php print WEB_btn_save; ?></button>
                 </td>
             </tr>
 
             <?php
-            $descr_field = "description." . HTML_LANG;
-            $config_sql = "SELECT `config`.`id`,`option_id`,`option_name`,`value`,`type`,`" . $descr_field . "`,`min_value`,`max_value` FROM `config`,`config_options` WHERE `config`.`option_id`=`config_options`.`id` AND `config_options`.`draft`=0 ORDER BY `option_name`";
-            $t_config = mysqli_query($db_link, $config_sql);
-            while ($row = mysqli_fetch_array($t_config)) {
+            $descr_field = "description_" . HTML_LANG;
+            $config_sql = "SELECT config.id,option_id,option_name,value,option_type," . $descr_field . ",min_value,max_value FROM config,config_options WHERE config.option_id=config_options.id AND config_options.draft=0 ORDER BY option_name";
+            $t_config = get_records_sql($db_link, $config_sql);
+            foreach ($t_config as $row) {
                 print "<tr align=center>\n";
                 print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[" . $row["option_id"] . "] value='" . $row['id'] . "'></td>\n";
                 print "<td class=\"data\"><input type=\"text\" value='" . $row['option_name'] . "' disabled=true readonly=true></td>\n";
-                $type = $row['type'];
+                $type = $row['option_type'];
                 print "<td class=\"data\">";
                 $option_value = $row['value'];
                 if ($row['option_id'] == 29) {

+ 103 - 27
html/admin/customers/control-subnets-usage.php

@@ -6,7 +6,8 @@ unset($_POST);
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 print_control_submenu($page_url);
 $zombi_days = get_option($db_link, 35);
-
+// Создаём временную метку: сейчас минус $zombi_days дней
+$zombi_threshold = date('Y-m-d H:i:s', strtotime("-$zombi_days days"));
 ?>
 <div id="cont">
 <br>
@@ -25,33 +26,108 @@ $zombi_days = get_option($db_link, 35);
 	<td><b><?php echo WEB_network_zombi_dhcp; ?><br><?php print "(> ".$zombi_days." ".WEB_days.")"; ?></b></td>
 </tr>
 <?php
-$t_subnets = get_records($db_link,'subnets','office=1 ORDER BY ip_int_start');
+$t_subnets = get_records_SQL($db_link, 'SELECT * FROM subnets WHERE office=1 ORDER BY ip_int_start');
 if (!empty($t_subnets)) {
-foreach ( $t_subnets as $row ) {
-    print "<tr align=center>\n";
-    $cl="data";
-    print "<td class=\"$cl\"><a href=/admin/iplist/index.php?ou=0&cidr=".$row['subnet'].">".$row['subnet']."</a></td>\n";
-    $all_ips = $row['ip_int_stop']-$row['ip_int_start']-3;
-    print "<td class=\"$cl\">".$all_ips."</td>\n";
-#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']);
-    print "<td class=\"$cl\">".$used_all."</td>\n";
-    $free_all = $all_ips - $used_all;
-    print "<td class=\"$cl\">".$free_all."</td>\n";
-    $dhcp_pool = $row['dhcp_stop']-$row['dhcp_start']+1;
-    print "<td class=\"$cl\">".$dhcp_pool."</td>\n";
-#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']);
-    print "<td class=\"$cl\">".$used_dhcp."</td>\n";
-    $free_dhcp = $dhcp_pool - $used_dhcp;
-    print "<td class=\"$cl\">".$free_dhcp."</td>\n";
-    $free_static = $free_all -  $free_dhcp;
-    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)');
-    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)');
-    print "<td class=\"$cl\">".$zombi."</td>\n";
-    print "</tr>\n";
+    foreach ($t_subnets as $row) {
+        print "<tr align=center>\n";
+        $cl = "data";
+
+        // Subnet
+        print "<td class=\"$cl\"><a href=/admin/iplist/index.php?ou=0&cidr=" . htmlspecialchars($row['subnet']) . ">" . htmlspecialchars($row['subnet']) . "</a></td>\n";
+
+        // Total IPs
+        $subnet_ips = max(0, $row['ip_int_stop'] - $row['ip_int_start'] + 1);
+        if ($subnet_ips > 4 ) { $all_ips = $subnet_ips - 3; } else { $all_ips = $subnet_ips; }
+        print "<td class=\"$cl\">" . $all_ips . "</td>\n";
+
+        // Used (total)
+        $used_all = get_count_records($db_link, 'user_auth', 'deleted = 0 AND ip_int >= ? AND ip_int <= ?', [$row['ip_int_start'], $row['ip_int_stop']]);
+        $total_used_percent = ($all_ips > 0) ? ($used_all / $all_ips) * 100 : 0;
+        $total_class = '';
+        if ($total_used_percent >= 95) {
+            $total_class = 'error';
+        } elseif ($total_used_percent >= 85) {
+            $total_class = 'warn';
+        }
+        print "<td class=\"" . ($total_class ?: $cl) . "\">" . $used_all . "</td>\n";
+
+        // Free (total)
+        $free_all = max(0, $all_ips - $used_all);
+
+        $free_total_class = '';
+        if ($all_ips > 0) {
+            $free_total_percent = ($free_all / $all_ips) * 100;
+            if ($free_total_percent <= 5) {
+                $free_total_class = 'error';
+            } elseif ($free_total_percent <= 15) {
+                $free_total_class = 'warn';
+            }
+        }
+        print "<td class=\"" . ($free_total_class ?: $cl) . "\">" . $free_all . "</td>\n";
+
+        // DHCP pool size
+        $dhcp_pool = max(0, $row['dhcp_stop'] - $row['dhcp_start'] + 1);
+        print "<td class=\"$cl\">" . $dhcp_pool . "</td>\n";
+
+        // Used (DHCP)
+        $used_dhcp = 0;
+        if ($dhcp_pool > 0) {
+            $used_dhcp = get_count_records($db_link, 'user_auth', 'deleted = 0 AND ip_int >= ? AND ip_int <= ?', [$row['dhcp_start'], $row['dhcp_stop']]);
+        }
+        $dhcp_used_percent = ($dhcp_pool > 0) ? ($used_dhcp / $dhcp_pool) * 100 : 0;
+        $dhcp_used_class = '';
+        if ($dhcp_used_percent >= 95) {
+            $dhcp_used_class = 'error';
+        } elseif ($dhcp_used_percent >= 85) {
+            $dhcp_used_class = 'warn';
+        }
+        print "<td class=\"" . ($dhcp_used_class ?: $cl) . "\">" . $used_dhcp . "</td>\n";
+
+        // Free (DHCP)
+        $free_dhcp = max(0, $dhcp_pool - $used_dhcp);
+        $free_dhcp_class = '';
+
+        if ($dhcp_pool > 0) {
+            $free_dhcp_percent = ($free_dhcp / $dhcp_pool) * 100;
+            if ($free_dhcp_percent <= 5) {
+                $free_dhcp_class = 'error';
+            } elseif ($free_dhcp_percent <= 15) {
+                $free_dhcp_class = 'warn';
+            }
+        }
+        print "<td class=\"" . ($free_dhcp_class ?: $cl) . "\">" . $free_dhcp . "</td>\n";
+
+        // Free static
+        $free_static = max ( 0, $free_all - $free_dhcp);
+        print "<td class=\"$cl\">" . $free_static . "</td>\n";
+
+        // Zombie (total) — от общего размера подсети
+        $zombi_total = get_count_records($db_link, 'user_auth', 'deleted = 0 AND ip_int >= ? AND ip_int <= ? AND last_found <= ?', [$row['ip_int_start'], $row['ip_int_stop'], $zombi_threshold]);
+        $zombi_total_class = '';
+        if ($all_ips > 0) {
+            $zombi_total_ratio = ($zombi_total / $all_ips) * 100;
+            if ($zombi_total_ratio >= 30) {
+                $zombi_total_class = 'error';
+            } elseif ($zombi_total_ratio >= 20) {
+                $zombi_total_class = 'warn';
+            }
+        }
+        print "<td class=\"" . ($zombi_total_class ?: $cl) . "\">" . $zombi_total . "</td>\n";
+
+        // Zombie (DHCP) — от размера DHCP-пула
+        $zombi_dhcp = get_count_records($db_link, 'user_auth', 'deleted = 0 AND ip_int >= ? AND ip_int <= ? AND last_found <= ?', [$row['dhcp_start'], $row['dhcp_stop'], $zombi_threshold]);
+        $zombi_dhcp_class = '';
+        if ($dhcp_pool > 0) {
+            $zombi_dhcp_ratio = ($zombi_dhcp / $dhcp_pool) * 100;
+            if ($zombi_dhcp_ratio >= 30) {
+                $zombi_dhcp_class = 'error';
+            } elseif ($zombi_dhcp_ratio >= 20) {
+                $zombi_dhcp_class = 'warn';
+            }
+        }
+        print "<td class=\"" . ($zombi_dhcp_class ?: $cl) . "\">" . $zombi_dhcp . "</td>\n";
+
+        print "</tr>\n";
     }
 }
 ?>

+ 3 - 15
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"])) {
-    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'");
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
@@ -74,31 +74,19 @@ if (isset($_POST["discovery2"]) and is_option($db_link, 41)) {
 }
 
 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!");
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
 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!");
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["s_remove"])) {
-    $s_id = $_POST["s_id"];
-    foreach ($s_id as $key => $val) {
-        if (isset($val)) {
-            LOG_INFO($db_link, "Remove subnet id: $val ". dump_record($db_link,'subnets','id='.$val));
-            delete_record($db_link, "subnets", "id=" . $val);
-        }
-    }
-    header("Location: " . $_SERVER["REQUEST_URI"]);
-    exit;
-}
-
 if (isset($_POST["clean_cache"])) {
     LOG_VERBOSE($db_link, "Clean dns cache");
     run_sql($db_link,"DELETE FROM dns_cache");

+ 70 - 94
html/admin/customers/devmodels.php

@@ -5,102 +5,70 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/vendorfilter.php");
 
-if (isset($_POST['save'])) {
-    $saved = array();
-    //button save
-    $len = is_array($_POST['save']) ? count($_POST['save']) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $save_id = intval($_POST['save'][$i]);
-        if ($save_id == 0) { continue;  }
-        array_push($saved,$save_id);
-        }
-    //select box
-    $len = is_array($_POST['f_id']) ? count($_POST['f_id']) : 0;
-    if ($len>0) {
-        for ($i = 0; $i < $len; $i ++) {
-            $save_id = intval($_POST['f_id'][$i]);
-            if ($save_id == 0) { continue; }
-            if (!in_array($save_id, $saved)) { array_push($saved,$save_id); }
-            }
-        }
-    //save changes
-    $len = is_array($saved) ? count($saved) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $save_id = intval($saved[$i]);
-        if ($save_id == 0) { continue;  }
-        $len_all = is_array($_POST['r_id']) ? count($_POST['r_id']) : 0;
-        for ($j = 0; $j < $len_all; $j ++) {
-            if (intval($_POST['r_id'][$j]) != $save_id) { continue; }
-            $new = NULL;
-            if ($save_id>=10000) {
-                $new['vendor_id'] = $_POST['f_vendor'][$j];
-	            $new['model_name'] = $_POST['f_name'][$j];
-	            $new['poe_in'] = $_POST['f_poe_in'][$j];
-	            $new['poe_out'] = $_POST['f_poe_out'][$j];
-	        } else {
-	            $new['poe_in'] = $_POST['f_poe_in'][$j];
-	            $new['poe_out'] = $_POST['f_poe_out'][$j];      
-            }
-            if (!isset($new['poe_in']) OR empty($new['poe_in'])) { $new['poe_in'] = 0; }
-            if (!isset($new['poe_out']) OR empty($new['poe_out'])) { $new['poe_out'] = 0; }
-            $new['nagios_template'] = $_POST['f_nagios'][$j];
-            update_record($db_link, "device_models", "id='{$save_id}'", $new);
+if (getPOST("save")) {
+    $f_ids = getPOST("f_id", null, []);
+    if (!empty($f_ids) && is_array($f_ids)) {
+        // Преобразуем в целые числа
+        $f_ids = array_map('intval', array_filter($f_ids, fn($id) => $id > 0));
+        // Получаем все данные
+        $r_ids       = array_map('intval', getPOST("r_id",       null, []));
+        $f_vendors   = getPOST("f_vendor",   null, []);
+        $f_names     = getPOST("f_name",     null, []);
+        $f_poe_ins   = getPOST("f_poe_in",   null, []);
+        $f_poe_outs  = getPOST("f_poe_out",  null, []);
+        $f_nagios    = getPOST("f_nagios",   null, []);
+        foreach ($f_ids as $save_id) {
+            $idx = array_search($save_id, $r_ids, true);
+            if ($idx === false) continue;
+            $new = [
+                'poe_in'  => !empty($f_poe_ins[$idx])  ? (int)$f_poe_ins[$idx]  : 0,
+                'poe_out' => !empty($f_poe_outs[$idx]) ? (int)$f_poe_outs[$idx] : 0,
+                'nagios_template' => trim($f_nagios[$idx] ?? '')
+            ];
+            // Для кастомных моделей (ID >= 10000)
+            if ($save_id >= 10000) {
+                $new['vendor_id']  = !empty($f_vendors[$idx]) ? (int)$f_vendors[$idx] : 1;
+                $new['model_name'] = trim($f_names[$idx] ?? '');
             }
+
+            update_record($db_link, "device_models", "id = ?", $new, [$save_id]);
         }
+    }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
-    }
+}
 
-if (isset($_POST['remove'])) {
-        $saved = array();
-        //button save
-        $len = is_array($_POST['save']) ? count($_POST['save']) : 0;
-        for ($i = 0; $i < $len; $i ++) {
-            $save_id = intval($_POST['save'][$i]);
-            if ($save_id == 0) { continue;  }
-            array_push($saved,$save_id);
-            }
-        //select box
-        $len = is_array($_POST['f_id']) ? count($_POST['f_id']) : 0;
-        if ($len>0) {
-            for ($i = 0; $i < $len; $i ++) {
-                $save_id = intval($_POST['f_id'][$i]);
-                if ($save_id == 0) { continue; }
-                if (!in_array($save_id, $saved)) { array_push($saved,$save_id); }
-                }
-            }
-        //save changes
-        $len = is_array($saved) ? count($saved) : 0;
-        for ($i = 0; $i < $len; $i ++) {
-            $save_id = intval($saved[$i]);
-            if ($save_id == 0) { continue;  }
-            $len_all = is_array($_POST['r_id']) ? count($_POST['r_id']) : 0;
-            for ($j = 0; $j < $len_all; $j ++) {
-                if (intval($_POST['r_id'][$j]) != $save_id) { continue; }
-                if ($save_id>=10000) { 
-                    delete_record($db_link, "device_models", "id='{$save_id}'");
-                    run_sql($db_link,"UPDATE devices set device_model_id=NULL WHERE device_model_id=".$save_id);
-                    }
-                }
-            }
-        header("Location: " . $_SERVER["REQUEST_URI"]);
-        exit;
+if (getPOST("remove")) {
+    $f_ids = getPOST("f_id", null, []);
+    if (!empty($f_ids) && is_array($f_ids)) {
+        $f_ids = array_map('intval', array_filter($f_ids, fn($id) => $id >= 10000));
+        foreach ($f_ids as $id) {
+            delete_record($db_link, "device_models", "id = ?", [$id]);
+            update_records($db_link, "devices", "device_model_id = ?", ['device_model_id' => null], [$id]);
         }
+    }
+    header("Location: " . $_SERVER["REQUEST_URI"]);
+    exit;
+}
 
-if (isset($_POST["create"])) {
-    $model_name = $_POST["new_model"];
-    if (isset($model_name)) {
-	$max_record = get_record_sql($db_link,"SELECT MAX(id) as max_id FROM device_models");
-	if (!isset($max_record) or $max_record['max_id']<10000) { $next_id = 10000; } else { $next_id = $max_record['max_id'] + 1; }
-        $new['vendor_id']=1;
-        $new['id'] = $next_id;
-        if (isset($f_vendor_select) and $f_vendor_select>1) { $new['vendor_id']=$f_vendor_select; }
-        $new['model_name'] = $model_name;
+if (getPOST("create")) {
+    $model_name = trim(getPOST("new_model", null, ''));
+    if ($model_name !== '') {
+        $max_record = get_record_sql($db_link, "SELECT MAX(id) AS max_id FROM device_models");
+        $next_id = (isset($max_record['max_id']) && $max_record['max_id'] >= 10000)
+            ? (int)$max_record['max_id'] + 1
+            : 10000;
+
+        $new = [
+            'id'         => $next_id,
+            'vendor_id'  => (int)($f_vendor_select ?? 1),
+            'model_name' => $model_name
+        ];
         insert_record($db_link, "device_models", $new);
-        }
+    }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
-    }
+}
 
 unset($_POST);
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
@@ -121,17 +89,26 @@ print_control_submenu($page_url);
 </table>
 
 <?php
-$v_filter='';
-if (!empty($f_vendor_select)) { $v_filter = "WHERE vendor_id=".$f_vendor_select; }
+$params = [];
+$filter = '';
+
+if (!empty($f_vendor_select)) {
+    $filter = 'WHERE vendor_id = ?';
+    $params[] = $f_vendor_select;
+}
+
+$countSQL = "SELECT COUNT(*) FROM device_models $filter";
+$count_records = get_single_field($db_link, $countSQL, $params);
 
-$countSQL="SELECT Count(*) FROM device_models $v_filter";
-$res = mysqli_query($db_link, $countSQL);
-$count_records = mysqli_fetch_array($res);
-$total=ceil($count_records[0]/$displayed);
+$total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed;
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
+$sql = "SELECT * FROM device_models $filter ORDER BY vendor_id, model_name LIMIT ? OFFSET ?";
+$params[] = $displayed;
+$params[] = $start;
+$t_ou = get_records_sql($db_link, $sql, $params);
 ?>
 <br>
 <table class="data">
@@ -147,7 +124,6 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 <td><input id='remove' type="submit" name='remove' value="<?php echo WEB_btn_delete; ?>"></td>
 </tr>
 <?php
-$t_ou = get_records_sql($db_link,'SELECT * FROM device_models '.$v_filter." ORDER BY vendor_id, model_name LIMIT $start,$displayed");
 foreach ($t_ou as $row) {
     print "<tr align=center>\n";
     print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='{$row['id']}'></td>\n";

+ 47 - 47
html/admin/customers/devvendors.php

@@ -4,55 +4,53 @@ $default_displayed=25;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
-if (isset($_POST['save'])) {
-    $saved = array();
-    //button save
-    $len = is_array($_POST['save']) ? count($_POST['save']) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $save_id = intval($_POST['save'][$i]);
-        if ($save_id == 0) { continue;  }
-        if ($save_id<10000) { continue; }
-        array_push($saved,$save_id);
-        }
-    //select box
-    $len = is_array($_POST['f_id']) ? count($_POST['f_id']) : 0;
-    if ($len>0) {
-        for ($i = 0; $i < $len; $i ++) {
-            $save_id = intval($_POST['f_id'][$i]);
-            if ($save_id == 0) { continue; }
-            if ($save_id<10000) { continue; }
-            if (!in_array($save_id, $saved)) { array_push($saved,$save_id); }
-            }
-        }
-    //save changes
-    $len = is_array($saved) ? count($saved) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $save_id = intval($saved[$i]);
-        if ($save_id == 0) { continue;  }
-        if ($save_id<10000) { continue; }
-        $len_all = is_array($_POST['r_id']) ? count($_POST['r_id']) : 0;
-        for ($j = 0; $j < $len_all; $j ++) {
-            if (intval($_POST['r_id'][$j]) != $save_id) { continue; }
-            $new['name'] = $_POST['f_name'][$j];
-            update_record($db_link, "vendors", "id='{$save_id}'", $new);
+// Сохранение изменений
+if (getPOST("save") !== null) {
+    $selected_ids = getPOST("f_id", null, []);
+    
+    if (!empty($selected_ids) && is_array($selected_ids)) {
+        // Преобразуем в целые числа и оставляем только >= 10000
+        $selected_ids = array_filter(array_map('intval', $selected_ids), fn($id) => $id >= 10000);
+        
+        if (!empty($selected_ids)) {
+            $r_ids   = array_map('intval', getPOST("r_id",   null, []));
+            $f_names = getPOST("f_name", null, []);
+            
+            foreach ($selected_ids as $vendor_id) {
+                $idx = array_search($vendor_id, $r_ids, true);
+                if ($idx === false) continue;
+                
+                $name = trim($f_names[$idx] ?? '');
+                if ($name === '') continue;
+                
+                update_record($db_link, "vendors", "id = ?", ['name' => $name], [$vendor_id]);
             }
         }
+    }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
-    }
+}
 
-if (isset($_POST["create"])) {
-    $vendor_name = $_POST["new_vendor"];
-    if (isset($vendor_name)) {
-	$max_record = get_record_sql($db_link,"SELECT MAX(id) as max_id FROM vendors");
-	if (!isset($max_record) or $max_record['max_id']<10000) { $next_id = 10000; } else { $next_id = $max_record['max_id'] + 1; }
-        $new['id'] = $next_id;
-        $new['name'] = $vendor_name;
-        insert_record($db_link, "vendors", $new);
-        }
+// Создание нового производителя
+if (getPOST("create") !== null) {
+    $vendor_name = trim(getPOST("new_vendor", null, ''));
+    
+    if ($vendor_name !== '') {
+        $max_record = get_record_sql($db_link, "SELECT MAX(id) AS max_id FROM vendors");
+        $next_id = (isset($max_record['max_id']) && $max_record['max_id'] >= 10000)
+            ? (int)$max_record['max_id'] + 1
+            : 10000;
+            
+        insert_record($db_link, "vendors", [
+            'id'   => $next_id,
+            'name' => $vendor_name
+        ]);
+    }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
-    }
+}
 
 unset($_POST);
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
@@ -73,14 +71,14 @@ print_control_submenu($page_url);
 </table>
 
 <?php
+
 $countSQL="SELECT Count(*) FROM vendors";
-$res = mysqli_query($db_link, $countSQL);
-$count_records = mysqli_fetch_array($res);
-$total=ceil($count_records[0]/$displayed);
+$count_records = get_single_field($db_link,$countSQL);
+$total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed;
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 
 ?>
 <table class="data">
@@ -91,7 +89,9 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 <td><input type="submit" name='save' value="<?php echo WEB_btn_save; ?>"></td>
 </tr>
 <?php
-$t_ou = get_records_sql($db_link,"SELECT * FROM vendors ORDER BY name LIMIT $start,$displayed");
+$params[]=$displayed;
+$params[]=$start;
+$t_ou = get_records_sql($db_link,"SELECT * FROM vendors ORDER BY name LIMIT ? OFFSET ?", $params);
 foreach ($t_ou as $row) {
     print "<tr align=center>\n";
     print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='{$row['id']}'></td>\n";

+ 81 - 41
html/admin/customers/editcustom.php

@@ -5,19 +5,41 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 $msg_error = "";
 
-if (isset($_POST["edituser"])) {
+$customer=get_record($db_link,'customers',"id=?", [$id]);
+
+if (getPOST("edituser") !== null) {
     global $salt;
-    $new['Login'] = substr(trim($_POST["login"]), 0, 20);
-    $new['comment'] = substr(trim($_POST["comment"]), 0, 100);
-    if (isset($_POST["pass"]) and (strlen(trim($_POST["pass"])) > 0)) {
-        $new['password'] = password_hash($_POST["pass"], PASSWORD_BCRYPT);
-	}
-    if (isset($_POST["api_key"]) and (strlen(trim($_POST["api_key"])) > 20)) {
-        $new['api_key'] = $_POST["api_key"];
-	}
-    $new['rights'] = $_POST["f_acl"] * 1;
-    update_record($db_link, "Customers", "id='$id'", $new);
-    unset($_POST["pass"]);
+
+    $new = [];
+
+    // Логин (макс. 20 символов)
+    $new['login'] = substr(trim(getPOST("login", null, $customer['login'])), 0, 20);
+
+    // Описание (макс. 100 символов)
+    $new['description'] = substr(trim(getPOST("description", null, '')), 0, 100);
+
+    // Пароль (если задан и не пустой)
+    $pass = trim(getPOST("pass", null, ''));
+    if ($pass !== '') {
+        $new['password'] = password_hash($pass, PASSWORD_BCRYPT);
+    }
+
+    // API-ключ (если длина > 20)
+    $api_key = getPOST("api_key", null, randomPassword(20));
+    if (strlen(trim($api_key)) > 20) {
+        $new['api_key'] = substr(trim($api_key),0,20);
+    }
+    if (strlen(trim($api_key)) <20) {
+        $new['api_key'] = $customer['api_key'];
+    }
+    $new['api_key'] = trim($api_key);
+
+    // Права доступа
+    $new['rights'] = (int)getPOST("f_acl", null, 0);
+
+    // Обновление записи
+    update_record($db_link, "customers", "id = ?", $new, [$id]);
+
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
@@ -27,37 +49,55 @@ unset($_POST);
 print_control_submenu($page_url);
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
-$customer=get_record($db_link,'Customers',"id=".$id);
+
 ?>
 
 <div id="cont">
 <br><b><?php echo WEB_customer_titles; ?></b><br>
-	<form name="def" action="editcustom.php?id=<?php echo $id; ?>" method="post">
-		<input type="hidden" name="id" value=<?php echo $id; ?>>
-		<table class="data">
-			<tr>
-				<td><?php echo WEB_customer_login; ?></td>
-				<td><input type="text" name="login" value="<?php print $customer['Login']; ?>" size=20></td>
-			</tr>
-			<tr>
-				<td><?php echo WEB_cell_comment; ?></td>
-				<td><input type="text" name="comment" value="<?php print $customer['comment']; ?>" size=50></td>
-			</tr>
-			<tr>
-				<td><?php echo WEB_customer_password; ?></td>
-				<td><input type="password" name="pass" value="" size=20></td>
-			</tr>
-			<tr>
-				<td><?php echo WEB_customer_api_key; ?></td>
-				<td><input type="text" name="api_key" value="<?php print $customer['api_key']; ?>" size=50></td>
-			</tr>
-			<tr>
-				<td><?php echo WEB_customer_mode; ?></td>
-				<td><?php print_acl_select($db_link,'f_acl',$customer['rights']); ?></td>
-			</tr>
-                        <tr>
-        			<td colspan=2><input type="submit" name="edituser" value="<?php echo WEB_btn_save; ?>"></td>
-                        </tr>
-		</table>
-	</form>
+<form name="def" action="editcustom.php?id=<?php echo $id; ?>" method="post">
+    <input type="hidden" name="id" value="<?php echo $id; ?>">
+    <table class="data">
+        <tr>
+            <td><?php echo WEB_customer_login; ?></td>
+            <td><input type="text" name="login" value="<?php print htmlspecialchars($customer['login']); ?>" size=20></td>
+        </tr>
+        <tr>
+            <td><?php echo WEB_cell_description; ?></td>
+            <td><input type="text" name="description" value="<?php print htmlspecialchars($customer['description']); ?>" size=50></td>
+        </tr>
+        <tr>
+            <td><?php echo WEB_customer_password; ?></td>
+            <td><input type="password" name="pass" value="" size=20></td>
+        </tr>
+        <tr>
+            <td><?php echo WEB_customer_api_key; ?></td>
+            <td>
+                <input type="text" name="api_key" id="api_key" value="<?php print htmlspecialchars($customer['api_key']); ?>" size=50>
+                <!-- Кнопка перегенерации -->
+                <button type="button" onclick="generateApiKey()">🔄</button>
+            </td>
+        </tr>
+        <tr>
+            <td><?php echo WEB_customer_mode; ?></td>
+            <td><?php print_acl_select($db_link,'f_acl',$customer['rights']); ?></td>
+        </tr>
+        <tr>
+            <td colspan=2>
+                <input type="submit" name="edituser" value="<?php echo WEB_btn_save; ?>">
+            </td>
+        </tr>
+    </table>
+</form>
+
+<script>
+function generateApiKey() {
+    const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+    let result = '';
+    for (let i = 0; i < 20; i++) {
+        result += chars.charAt(Math.floor(Math.random() * chars.length));
+    }
+    document.getElementById('api_key').value = result;
+}
+</script>
+
 <?php require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php"); ?>

+ 89 - 76
html/admin/customers/editsubnet.php

@@ -3,104 +3,117 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/idfilter.php");
 
-if (isset($_POST['s_save'])) {
-        $new = [];
+$sSQL = "SELECT * FROM subnets WHERE id= ?";
+$subnet_info = get_record_sql($db_link, $sSQL, [ $id ]);
 
-        // === INPUT CLEANING =====================================================================================
-        $new['subnet'] = trim($_POST['s_subnet']);
-        $new['vlan_tag'] = normalize_vlan($_POST['s_vlan']);
-        $new['office'] = intval_or_zero($_POST['s_office']);
-        $new['hotspot'] = intval_or_zero($_POST['s_hotspot']);
-        $new['vpn'] = intval_or_zero($_POST['s_vpn']);
-        $new['free'] = intval_or_zero($_POST['s_free']);
-        $new['dhcp'] = intval_or_zero($_POST['s_dhcp']);
-        $new['dhcp_lease_time'] = intval_or_zero($_POST['s_lease_time']);
-        $new['static'] = intval_or_zero($_POST['s_static']);
-        $new['discovery'] = intval_or_zero($_POST['s_discovery']);
-        $new['notify'] = intval_or_zero($_POST['s_notify']);
-        $new['dhcp_update_hostname'] = intval_or_zero($_POST['s_dhcp_update']);
-        $new['comment'] = trim($_POST['s_comment']);
+if (getPOST("s_save") !== null) {
+    $new = [];
 
-        // === CIDR / RANGE PROCESSING =============================================================================
+    // === INPUT CLEANING =====================================================================================
+    $new['subnet']              = trim(getPOST("s_subnet", null, $subnet_info['subnet']));
 
-        $range = cidrToRange($new['subnet']);
-        $first_ip     = $range[0];
-        $last_ip      = $range[1];
-        $cidr         = $range[2][1] ?? null;
-        $new['subnet'] = ($cidr && $cidr <= 32) ? "$first_ip/$cidr" : '';
-        $new['ip_int_start'] = ip2long($first_ip);
-        $new['ip_int_stop']  = ip2long($last_ip);
+    // === CIDR / RANGE PROCESSING ============================================================================
+    $range = cidrToRange($new['subnet']);
+    $first_ip = $range[0];
+    $last_ip  = $range[1];
+    $cidr     = $range[2] ?? null;
 
-        // === GATEWAY ===============================================================================================
-
-        $gateway_fallback = ip2long($range[5]);
-        $new['gateway'] = get_dhcp_gateway($_POST['s_gateway'], $gateway_fallback);
+    // Формируем корректный CIDR
+    if ($cidr !== null && $cidr < 32) {
+            $new['subnet'] = "$first_ip/$cidr";
+        } else {
+            $range = cidrToRange($first_ip.'/24');
+            $first_ip = $range[0];
+            $last_ip  = $range[1];
+            $cidr     = $range[2] ?? null;
+            if ($cidr !== null && $cidr < 32) {
+                $new['subnet'] = "$first_ip/$cidr";
+                } else {
+                //abort
+                header("Location: " . $_SERVER["REQUEST_URI"]);
+                exit;
+                }
+        }
 
-        // === GATEWAY VALIDATION ===================================================================================
+    $new['vlan_tag']            = normalize_vlan(getPOST("s_vlan", null, 1));
+    $new['office']              = intval_or_zero(getPOST("s_office", null, 0));
+    $new['hotspot']             = intval_or_zero(getPOST("s_hotspot", null, 0));
+    $new['vpn']                 = intval_or_zero(getPOST("s_vpn", null, 0));
+    $new['free']                = intval_or_zero(getPOST("s_free", null, 0));
+    $new['dhcp']                = intval_or_zero(getPOST("s_dhcp", null, 0));
+    $new['dhcp_lease_time']     = intval_or_zero(getPOST("s_lease_time", null, 0));
+    $new['static']              = intval_or_zero(getPOST("s_static", null, 0));
+    $new['discovery']           = intval_or_zero(getPOST("s_discovery", null, 0));
+    $new['notify']              = intval_or_zero(getPOST("s_notify", null, 0));
+    $new['dhcp_update_hostname']= intval_or_zero(getPOST("s_dhcp_update", null, 0));
+    $new['description']         = trim(getPOST("s_description", null, ''));
 
-        if ( !$new['gateway'] || $new['gateway'] <= $new['ip_int_start'] || $new['gateway'] >= $new['ip_int_stop'] ) {
-              // если введённый gateway не подходит — используем дефолтный
-                $new['gateway'] = $gateway_fallback;
-            }
+    $new['ip_int_start']        = ip2long($first_ip);
+    $new['ip_int_stop']         = ip2long($last_ip);
 
-        // === DHCP RANGE VALIDATION ================================================================================
+    // === GATEWAY ============================================================================================
+    $gateway_fallback = ip2long($range[5]);
+    $new['gateway'] = get_dhcp_gateway(getPOST("s_gateway", null, ''), $gateway_fallback);
 
-        $dhcp_start = ip2long(trim($_POST['s_dhcp_start']));
-        $dhcp_stop  = ip2long(trim($_POST['s_dhcp_stop']));
+    // === GATEWAY VALIDATION =================================================================================
+    if (!$new['gateway'] || $new['gateway'] <= $new['ip_int_start'] || $new['gateway'] >= $new['ip_int_stop']) {
+        $new['gateway'] = $gateway_fallback;
+    }
 
-        if (!validate_dhcp_range(
-            $dhcp_start,
-            $dhcp_stop,
-            $new['ip_int_start'],
-            $new['ip_int_stop']
-        )) {
-            // fallback пул
-            $dhcp_start = ip2long($range[3]);
-            $dhcp_stop  = ip2long($range[4]);
-        }
+    // === DHCP RANGE VALIDATION =============================================================================
+    $dhcp_start = ip2long(trim(getPOST("s_dhcp_start", null, $range[3])));
+    $dhcp_stop  = ip2long(trim(getPOST("s_dhcp_stop", null, $range[4])));
 
-        $new['dhcp_start'] = $dhcp_start;
-        $new['dhcp_stop']  = $dhcp_stop;
+    if (!validate_dhcp_range($dhcp_start, $dhcp_stop, $new['ip_int_start'], $new['ip_int_stop'])) {
+        // fallback пул
+        $dhcp_start = ip2long($range[3]);
+        $dhcp_stop  = ip2long($range[4]);
+    }
 
+    $new['dhcp_start'] = $dhcp_start;
+    $new['dhcp_stop']  = $dhcp_stop;
 
-        // === MODE DEPENDENCY RULES ================================================================================
+    // === MODE DEPENDENCY RULES =============================================================================
 
-        if ($new['hotspot']) {
-            $new['dhcp_update_hostname'] = 0;
-            $new['discovery'] = 0;
-            $new['vpn'] = 0;
+    if ($dhcp_start === $dhcp_stop ) {
+        $new['dhcp'] = 0;
         }
 
-        if ($new['vpn']) {
-            $new['discovery'] = 0;
-            $new['dhcp'] = 0;
-        }
+    if ($new['hotspot']) {
+        $new['dhcp_update_hostname'] = 0;
+        $new['discovery'] = 0;
+        $new['vpn'] = 0;
+    }
 
-        if ($new['office']) {
-            $new['free'] = 0;
-        }
+    if ($new['vpn']) {
+        $new['discovery'] = 0;
+        $new['dhcp'] = 0;
+    }
 
-        if (!$new['office']) {
-            $new['discovery'] = 0;
-            $new['dhcp'] = 0;
-            $new['static'] = 0;
-            $new['dhcp_update_hostname'] = 0;
-            $new['gateway'] = 0;
-            $new['dhcp_start'] = 0;
-            $new['dhcp_stop'] = 0;
-        }
+    if ($new['office']) {
+        $new['free'] = 0;
+    }
+
+    if (!$new['office']) {
+        $new['discovery'] = 0;
+        $new['dhcp'] = 0;
+        $new['static'] = 0;
+        $new['dhcp_update_hostname'] = 0;
+        $new['gateway'] = 0;
+        $new['dhcp_start'] = 0;
+        $new['dhcp_stop'] = 0;
+    }
+
+    update_record($db_link, "subnets", "id = ?", $new, [$id]);
 
-        update_record($db_link, "subnets", "id='$id'", $new);
-        header("Location: /admin/customers/index-subnets.php");
-        exit;
+    header("Location: /admin/customers/index-subnets.php");
+    exit;
 }
 
 unset($_POST);
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
 print_control_submenu($page_url);
 
-$sSQL = "SELECT * FROM subnets WHERE id=$id";
-$subnet_info = get_record_sql($db_link, $sSQL);
 ?>
 
 <div id="cont">
@@ -128,9 +141,9 @@ $subnet_info = get_record_sql($db_link, $sSQL);
             
             <tr>
                 <td></td>
-                <td><b><?php echo WEB_cell_comment; ?></b></td>
+                <td><b><?php echo WEB_cell_description; ?></b></td>
                 <td colspan="2" class="data">
-                    <input type="text" name="s_comment" value="<?php echo $subnet_info['comment']; ?>">
+                    <input type="text" name="s_description" value="<?php echo $subnet_info['description']; ?>">
                 </td>
             </tr>
             

+ 52 - 29
html/admin/customers/index-subnets.php

@@ -3,42 +3,65 @@
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
 
-if (isset($_POST["s_remove"])) {
-    if (!empty($_POST["s_id"])) {
-        $s_id = $_POST["s_id"];
-        foreach ($s_id as $key => $net_id) {
-            if (isset($net_id)) {
-                LOG_INFO($db_link, "Remove subnet id: $net_id ". dump_record($db_link,'subnets','id='.$val));
-                delete_record($db_link, "subnets", "id=" . $net_id);
-                delete_record($db_link, "gateway_subnets", "subnet_id=" . $net_id);
-            }
+// Удаление подсетей
+if (getPOST("s_remove") !== null) {
+    $s_id = getPOST("s_id", null, []);
+    
+    if (!empty($s_id) && is_array($s_id)) {
+        foreach ($s_id as $net_id) {
+            $net_id = trim($net_id);
+            if ($net_id === '') continue;
+            
+            delete_record($db_link, "subnets", "id = ?", [$net_id]);
+            delete_record($db_link, "gateway_subnets", "subnet_id = ?", [$net_id]);
         }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["s_create"])) {
-    $new_subnet = $_POST["s_create_subnet"];
-    if (isset($new_subnet)) {
-        $new['subnet'] = trim($new_subnet);
-        $range = cidrToRange($new['subnet']);
-        $first_user_ip = $range[0];
-        $last_user_ip = $range[1];
-        $cidr = $range[2][1];
-        if (isset($cidr) and $cidr < 32) {
-            $ip = $first_user_ip . '/' . $cidr;
+// Создание новой подсети
+if (getPOST("s_create") !== null) {
+    $new_subnet = trim(getPOST("s_create_subnet", null, ''));
+
+    if ($new_subnet !== '') {
+        $range = cidrToRange($new_subnet);
+        $first_user_ip = $range[0] ?? '';
+        $last_user_ip  = $range[1] ?? '';
+        $cidr          = $range[2] ?? null;
+        // Формируем корректный CIDR
+        if ($cidr !== null && $cidr < 32) {
+            $new_subnet = "$first_user_ip/$cidr";
         } else {
-            $ip = $first_user_ip;
+            $range = cidrToRange($first_user_ip.'/24');
+            $first_user_ip = $range[0] ?? '';
+            $last_user_ip  = $range[1] ?? '';
+            $cidr          = $range[2] ?? null;
+            if ($cidr !== null && $cidr < 32) {
+                $new_subnet = "$first_user_ip/$cidr";
+                } else {
+                //abort
+                header("Location: " . $_SERVER["REQUEST_URI"]);
+                exit;
+                }
         }
-        $new['ip_int_start'] = ip2long($first_user_ip);
-        $new['ip_int_stop'] = ip2long($last_user_ip);
-        $new['dhcp_start'] = ip2long($range[3]);
-        $new['dhcp_stop'] = ip2long($range[4]);
-        $new['gateway'] = ip2long($range[5]);
-        LOG_INFO($db_link, "Create new subnet $new_subnet");
+
+        $start_ip = ip2long($first_user_ip);
+        $stop_ip = ip2long($last_user_ip);
+
+        $new = [
+            'subnet' => $new_subnet,
+            'ip_int_start' => $start_ip,
+            'ip_int_stop'  => $stop_ip,
+            'dhcp_start'   => ip2long($range[3] ?? $first_user_ip),
+            'dhcp_stop'    => ip2long($range[4] ?? $first_user_ip),
+            'gateway'      => ip2long($range[5] ?? $first_user_ip)
+        ];
+
         insert_record($db_link, "subnets", $new);
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
@@ -75,10 +98,10 @@ print_control_submenu($page_url);
                 <td><b><?php echo WEB_network_dyndns; ?></b></td>
                 <td><b><?php echo WEB_network_discovery; ?></b></td>
                 <td><b><?php echo WEB_network_notify; ?></b></td>
-                <td><b><?php echo WEB_cell_comment; ?></b></td>
+                <td><b><?php echo WEB_cell_description; ?></b></td>
             </tr>
             <?php
-            $t_subnets = get_records($db_link, 'subnets', 'True ORDER BY ip_int_start');
+            $t_subnets = get_records_sql($db_link, 'SELECT * FROM subnets ORDER BY ip_int_start');
             foreach ($t_subnets as $row) {
                 print "<tr align=center>\n";
                 print "<td class=\"data\" style='padding:0'><input type=checkbox name=s_id[] value='" . $row['id'] . "'></td>\n";
@@ -93,7 +116,7 @@ print_control_submenu($page_url);
                 print_td_yes_no($row['dhcp_update_hostname']);
                 print_td_yes_no($row['discovery']);
                 print "<td class=\"data\">" . printFlagsByFirstLetter($row['notify']) . " </td>\n";
-                print "<td class=\"data\">" . $row['comment'] . " </td>\n";
+                print "<td class=\"data\">" . $row['description'] . " </td>\n";
                 print "</tr>\n";
                 }
             ?>

+ 34 - 23
html/admin/customers/index.php

@@ -4,38 +4,49 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 $msg_error = "";
 
-if (isset($_POST["create"])) {
-    $login = $_POST["newlogin"];
-    if ($login) {
-	$customer = get_record_sql($db_link,"Select * from Customers WHERE LCase(Login)=LCase('$login')");
+// Создание нового пользователя
+if (getPOST("create") !== null) {
+    $login = trim(getPOST("newlogin", null, ''));
+    
+    if ($login !== '') {
+        $customer = get_record_sql($db_link, "SELECT * FROM customers WHERE LOWER(login) = LOWER(?)", [$login]);
+        
         if (!empty($customer)) {
             $msg_error = "Login $login already exists!";
-            LOG_ERROR($db_link, $msg_error);
-            unset($_POST);
         } else {
-            $new['Login'] = $login;
-	    $new['api_key'] = randomPassword(20);
-            $new['rights'] = 3;
-            LOG_INFO($db_link, "Create new login: $login");
-            $id = insert_record($db_link, "Customers", $new);
-	    if (!empty($id)) { header("Location: editcustom.php?id=$id"); exit; }
+            $new = [
+                'login'    => $login,
+                'api_key'  => randomPassword(20),
+                'rights'   => 3
+            ];
+            $id = insert_record($db_link, "customers", $new);
+            if (!empty($id)) {
+                header("Location: editcustom.php?id=$id");
+                exit;
+            }
         }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["remove"])) {
-    $fid = $_POST["fid"];
-    foreach ($fid as $key => $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);
+// Удаление пользователей
+if (getPOST("remove") !== null) {
+    $fid = getPOST("fid", null, []);
+    
+    if (!empty($fid) && is_array($fid)) {
+        foreach ($fid as $val) {
+            $val = trim($val);
+            if ($val === '' or $val == '1') continue;
+            delete_record($db_link, "customers", "id = ?", [$val]);
         }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
+
 unset($_POST);
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
@@ -50,18 +61,18 @@ print_control_submenu($page_url);
 <tr align="center">
 <td width="30"><input type="checkbox" onClick="checkAll(this.checked);"></td>
 <td><b>Login</b></td>
-<td><b><?php echo WEB_cell_comment; ?></b></td>
+<td><b><?php echo WEB_cell_description; ?></b></td>
 <td><b><?php echo WEB_customer_mode;?></b></td>
 </tr>
 <?php
-$users = get_records($db_link,'Customers','True ORDER BY Login');
+$users = get_records_sql($db_link,'SELECT * FROM customers ORDER BY login');
 foreach ($users as $row) {
     $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'] ]);
     print "<tr align=center>\n";
     print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$row['id']."></td>\n";
-    print "<td class=\"$cl\" align=left width=200><a href=editcustom.php?id=".$row['id'].">" . $row['Login'] . "</a></td>\n";
-    print "<td class=\"$cl\" >". $row['comment']. "</a></td>\n";
+    print "<td class=\"$cl\" align=left width=200><a href=editcustom.php?id=".$row['id'].">" . $row['login'] . "</a></td>\n";
+    print "<td class=\"$cl\" >". $row['description']. "</a></td>\n";
     print "<td class=\"$cl\" >". $acl['name']. "</a></td>\n";
 }
 ?>

+ 25 - 11
html/admin/customers/ipcam.php

@@ -6,22 +6,36 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 $f_ou_id = IPCAM_GROUP_ID;
 
-if (isset($_POST['port_on'])) {
-    $len = is_array($_POST['port_on']) ? count($_POST['port_on']) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $building_id = intval($_POST['port_on'][$i]);
-        set_port_for_group($db_link, $f_ou_id, $building_id, 1);
+// Включение портов
+if (getPOST("port_on") !== null) {
+    $port_on = getPOST("port_on", null, []);
+    
+    if (is_array($port_on)) {
+        foreach ($port_on as $building_id) {
+            $building_id = (int)$building_id;
+            if ($building_id > 0) {
+                set_port_for_group($db_link, $f_ou_id, $building_id, 1);
+            }
+        }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST['port_off'])) {
-    $len = is_array($_POST['port_off']) ? count($_POST['port_off']) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $building_id = intval($_POST['port_off'][$i]);
-        set_port_for_group($db_link, $f_ou_id, $building_id, 0);
+// Отключение портов
+if (getPOST("port_off") !== null) {
+    $port_off = getPOST("port_off", null, []);
+    
+    if (is_array($port_off)) {
+        foreach ($port_off as $building_id) {
+            $building_id = (int)$building_id;
+            if ($building_id > 0) {
+                set_port_for_group($db_link, $f_ou_id, $building_id, 0);
+            }
+        }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
@@ -41,7 +55,7 @@ print_ou_select($db_link, 'f_ou_id', $f_ou_id);
 print "</td>\n";
 print "</tr>\n";
 print "<tr><td colspan=3><br></td></tr>\n";
-$t_config = get_records_sql($db_link, "select id,name from building order by name");
+$t_config = get_records_sql($db_link, "SELECT * FROM building ORDER BY name");
 foreach ($t_config as $row) {
     print "<tr align=center>\n";
     print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$row['id']."></td>\n";

+ 20 - 14
html/admin/devices/edit_gw_instances.php

@@ -4,26 +4,32 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
-$device=get_record($db_link,'devices',"id=".$id);
-$user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_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']]);
 
-if (isset($_POST["s_remove"])) {
-    $s_id = $_POST["gs_id"];
-    foreach ($s_id as $key => $val) {
-        if (isset($val)) {
-            LOG_INFO($db_link, "Remove filter instances from gateway id: $val ". dump_record($db_link,'device_filter_instances','id='.$val));
-            delete_record($db_link, "device_filter_instances", "id=" . $val);
+// Удаление фильтров
+if (getPOST("s_remove") !== null) {
+    $s_id = getPOST("gs_id", null, []);
+    
+    if (!empty($s_id) && is_array($s_id)) {
+        foreach ($s_id as $val) {
+            $val = trim($val);
+            if ($val === '') continue;
+            delete_record($db_link, "device_filter_instances", "id = ?", [$val]);
         }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["s_create"])) {
-    if (!empty($_POST["new_instance"])) {
-        $new['instance_id'] = trim($_POST["new_instance"]);
-        $new['device_id'] = $id;
-        LOG_INFO($db_link, "Add instance id: ".$new['instance_id']." for gateway id: ".$id);
+// Создание нового фильтра
+if (getPOST("s_create") !== null) {
+    $new_instance = trim(getPOST("new_instance", null, ''));
+    if ($new_instance !== '') {
+        $new = [
+            'instance_id' => $new_instance,
+            'device_id'   => $id
+        ];
         insert_record($db_link, "device_filter_instances", $new);
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
@@ -57,7 +63,7 @@ print_url($device['device_name'],"/admin/devices/editdevice.php?id=$id"); ?>
         </td>
 </tr>
 <?php
-$gateway_instances = get_records_sql($db_link,'SELECT device_filter_instances.*,filter_instances.name,filter_instances.comment FROM device_filter_instances LEFT JOIN filter_instances ON device_filter_instances.instance_id = filter_instances.id WHERE device_filter_instances.device_id='.$id);
+$gateway_instances = get_records_sql($db_link,'SELECT device_filter_instances.*,filter_instances.name,filter_instances.description FROM device_filter_instances LEFT JOIN filter_instances ON device_filter_instances.instance_id = filter_instances.id WHERE device_filter_instances.device_id=?',[ $id ]);
 foreach ( $gateway_instances as $row ) {
     print "<tr align=center>\n";
     print "<td class=\"data\" style='padding:0' width=30><input type=checkbox name=gs_id[] value='{$row['id']}'></td>\n";

+ 25 - 14
html/admin/devices/edit_gw_subnets.php

@@ -4,28 +4,39 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
-$device=get_record($db_link,'devices',"id=".$id);
-$user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_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']]);
 
-if (isset($_POST["s_remove"])) {
-    $s_id = $_POST["gs_id"];
-    foreach ($s_id as $key => $val) {
-        if (isset($val)) {
-            LOG_INFO($db_link, "Remove subnet from gateway id: $val ". dump_record($db_link,'gateway_subnets','id='.$val));
-            delete_record($db_link, "gateway_subnets", "id=" . $val);
+// Удаление подсетей шлюза
+if (getPOST("s_remove") !== null) {
+    $s_id = getPOST("gs_id", null, []);
+    
+    if (!empty($s_id) && is_array($s_id)) {
+        foreach ($s_id as $val) {
+            $val = trim($val);
+            if ($val === '') continue;
+            
+            delete_record($db_link, "gateway_subnets", "id = ?", [(int)$val]);
         }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["s_create"])) {
-    if (!empty($_POST["new_subnet"])) {
-        $new['subnet_id'] = trim($_POST["new_subnet"]);
-        $new['device_id'] = $id;
-        LOG_INFO($db_link, "Add subnet id: ".$new['subnet_id']." for gateway id: ".$id);
+// Добавление подсети к шлюзу
+if (getPOST("s_create") !== null) {
+    $new_subnet = trim(getPOST("new_subnet", null, ''));
+    
+    if ($new_subnet !== '') {
+        $new = [
+            'subnet_id' => $new_subnet,
+            'device_id' => $id
+        ];
+        
         insert_record($db_link, "gateway_subnets", $new);
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
@@ -55,7 +66,7 @@ print_url($device['device_name'],"/admin/devices/editdevice.php?id=$id"); ?>
         </td>
 </tr>
 <?php
-$gateway_subnets = get_records_sql($db_link,'SELECT gateway_subnets.*,subnets.subnet,subnets.comment FROM gateway_subnets LEFT JOIN subnets ON gateway_subnets.subnet_id = subnets.id WHERE gateway_subnets.device_id='.$id);
+$gateway_subnets = get_records_sql($db_link,'SELECT gateway_subnets.*,subnets.subnet,subnets.description FROM gateway_subnets LEFT JOIN subnets ON gateway_subnets.subnet_id = subnets.id WHERE gateway_subnets.device_id=?', [$id]);
 foreach ( $gateway_subnets as $row ) {
     print "<tr align=center>\n";
     print "<td class=\"data\" style='padding:0' width=30><input type=checkbox name=gs_id[] value='{$row['id']}'></td>\n";

+ 119 - 90
html/admin/devices/edit_l3int.php

@@ -1,134 +1,163 @@
 <?php
+require_once ($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
+require_once ($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT'] . "/inc/idfilter.php");
 
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
+$device = get_record($db_link, 'devices', "id = ?", [$id]);
+$snmp = getSnmpAccess($device);
+$user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$device['user_id']]);
+$int_list = getIpAdEntIfIndex($db_link, $device['ip'], $snmp);
 
-$device = get_record($db_link,'devices',"id=".$id);
-$snmp=getSnmpAccess($device);
-$user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_id']);
-$int_list = getIpAdEntIfIndex($db_link,$device['ip'],$snmp);
-
-if (isset($_POST["s_remove"])) {
-    $s_id = $_POST["s_id"];
-    foreach ($s_id as $key => $val) {
-        if (isset($val)) {
-            LOG_INFO($db_link, "Remove l3_interface id: $val ". dump_record($db_link,'device_l3_interfaces','id='.$val));
-            delete_record($db_link, "device_l3_interfaces", "id=" . $val);
+// Удаление L3-интерфейсов
+if (getPOST("s_remove") !== null) {
+    $s_id = getPOST("s_id", null, []);
+    
+    if (!empty($s_id) && is_array($s_id)) {
+        foreach ($s_id as $val) {
+            $val = trim($val);
+            if ($val === '') continue;
+            
+            delete_record($db_link, "device_l3_interfaces", "id = ?", [(int)$val]);
         }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST['s_save'])) {
-    $len = is_array($_POST['s_save']) ? count($_POST['s_save']) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $save_id = intval($_POST['s_save'][$i]);
-        $len_all = is_array($_POST['n_id']) ? count($_POST['n_id']) : 0;
-        for ($j = 0; $j < $len_all; $j ++) {
-            if (intval($_POST['n_id'][$j]) != $save_id) { continue; }
-            $new['interface_type'] = $_POST['s_type'][$j]*1;
-            update_record($db_link, "device_l3_interfaces", "id='{$save_id}'", $new);
+// Сохранение ОТМЕЧЕННЫХ L3-интерфейсов
+if (getPOST("s_save") !== null) {
+    $selected_ids = getPOST("s_id", null, []);      // отмеченные чекбоксы
+    $all_ids      = getPOST("n_id", null, []);      // все ID
+    $types        = getPOST("s_type", null, []);
+    
+    if (!empty($selected_ids) && is_array($selected_ids)) {
+        $selected_ids = array_map('intval', $selected_ids);
+        $selected_set = array_flip($selected_ids);
+        
+        foreach ($all_ids as $i => $id) {
+            $id = (int)$id;
+            if ($id <= 0 || !isset($selected_set[$id])) continue;
+            
+            $new = [
+                'interface_type' => (int)($types[$i] ?? 0)
+            ];
+            
+            update_record($db_link, "device_l3_interfaces", "id = ?", $new, [$id]);
         }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["s_create"])) {
-    if (!empty($_POST["s_create_name"])) {
-        $new = NULL;
-        list($new['name'],$new['snmpin'],$new['interface_type']) = explode(";", trim($_POST["s_create_name"]));
-        $new['device_id'] = $id;
-        $new['name']=preg_replace('/\"/','',$new['name']);
-        LOG_INFO($db_link, "Create new l3_interface ".$new['name']);
-        insert_record($db_link, "device_l3_interfaces", $new);
+// Создание нового L3-интерфейса
+if (getPOST("s_create") !== null) {
+    $create_name = trim(getPOST("s_create_name", null, ''));
+    
+    if ($create_name !== '') {
+        $parts = explode(";", $create_name);
+        if (count($parts) >= 3) {
+            $new = [
+                'name'           => preg_replace('/"/', '', trim($parts[0])),
+                'snmpin'         => trim($parts[1]),
+                'interface_type' => (int)trim($parts[2]),
+                'device_id'      => $id
+            ];
+            
+            insert_record($db_link, "device_l3_interfaces", $new);
+        }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
 unset($_POST);
 
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
-
-print_device_submenu($page_url);
-print_editdevice_submenu($page_url,$id,$device['device_type'],$user_info['login']);
-
-?>
-<div id="contsubmenu">
-<br>
-<?php print "<form name=def action='edit_l3int.php?id=".$id."' method=post>"; ?>
-<?php print WEB_list_l3_interfaces."<b>"; print_url($device['device_name'],"/admin/devices/editdevice.php?id=$id"); ?>
-</b> <br>
-<table class="data">
-<tr align="center">
-	<td></td>
-	<td width=30><b>id</b></td>
-	<td><b><?php echo WEB_cell_name; ?></b></td>
-	<td><b><?php echo WEB_cell_type; ?></b></td>
-	<td>
-	<input type="submit" onclick="return confirm('<?php print WEB_msg_delete; ?>?')" name="s_remove" value="<?php print WEB_btn_remove; ?>">
-	</td>
-</tr>
-<?php
-$t_l3_interface = get_records($db_link,'device_l3_interfaces',"device_id=$id ORDER BY name");
+// Автоисправление интерфейсов
+$t_l3_interface = get_records_sql($db_link, "SELECT * FROM device_l3_interfaces WHERE device_id = ? ORDER BY name", [$id]);
 
 $int_by_name = [];
-foreach ($int_list as $row) { 
-    $row['name'] = preg_replace('/\"/','',$row['name']);
-    $int_by_name[$row['name']]=$row;
+foreach ($int_list as $row) {
+    $row['name'] = preg_replace('/"/', '', $row['name']);
+    $int_by_name[$row['name']] = $row;
 }
 $fixed = 0;
 
-//fixing snmp index if not exists by interface name
-foreach ( $t_l3_interface as $row ) {
-    $fix = NULL;
-    if (empty($row['snmpin']) and !empty($int_by_name[$row['name']])) {
-        $fix['snmpin']=$int_by_name[$row['name']]['index'];
-        if (!empty($fix)) {
-            update_record($db_link,'device_l3_interfaces','id='.$row['id'],$fix);
-            }
+// Исправление snmpin по имени
+foreach ($t_l3_interface as $row) {
+    if (empty($row['snmpin']) && !empty($int_by_name[$row['name']])) {
+        update_record($db_link, 'device_l3_interfaces', 'id = ?', ['snmpin' => $int_by_name[$row['name']]['index']], [$row['id']]);
         $fixed = 1;
-        }
     }
+}
 
-//updating interface name by snmp index
-foreach ( $t_l3_interface as $row ) {
-    $fix = NULL;
-    if (!empty($int_list[$row['snmpin']]) and $int_list[$row['snmpin']]['name'] !== $row['name']) {
-        $fix['name']=$int_list[$row['snmpin']]['name'];
-        if (!empty($fix)) {
-            update_record($db_link,'device_l3_interfaces','id='.$row['id'],$fix);
-            }
+// Обновление имени по snmpin
+foreach ($t_l3_interface as $row) {
+    if (!empty($int_list[$row['snmpin']]) && $int_list[$row['snmpin']]['name'] !== $row['name']) {
+        update_record($db_link, 'device_l3_interfaces', 'id = ?', ['name' => $int_list[$row['snmpin']]['name']], [$row['id']]);
         $fixed = 1;
-        }
     }
+}
 
 if ($fixed) {
-    $t_l3_interface = get_records($db_link,'device_l3_interfaces',"device_id=$id ORDER BY name");
-    }
+    $t_l3_interface = get_records_sql($db_link, "SELECT * FROM device_l3_interfaces WHERE device_id = ? ORDER BY name", [$id]);
+}
+
+require_once ($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
 
-foreach ( $t_l3_interface as $row ) {
+print_device_submenu($page_url);
+print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['login']);
+?>
+<div id="contsubmenu">
+<br>
+<form name="def" action="edit_l3int.php?id=<?php echo $id; ?>" method="post">
+<?php echo WEB_list_l3_interfaces . "<b>"; print_url($device['device_name'], "/admin/devices/editdevice.php?id=$id"); ?></b> <br>
+<table class="data">
+<tr align="center">
+    <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
+    <td width=30><b>id</b></td>
+    <td><b><?php echo WEB_cell_name; ?></b></td>
+    <td><b><?php echo WEB_cell_type; ?></b></td>
+    <td>
+        <!-- Кнопки управления справа -->
+        <div style="text-align: right; white-space: nowrap;">
+            <input type="submit" name="s_save" value="<?php echo WEB_btn_save; ?>">
+            <input type="submit" 
+                   onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" 
+                   name="s_remove" 
+                   value="<?php echo WEB_btn_remove; ?>"
+                   style="margin-left: 8px;">
+        </div>
+    </td>
+</tr>
+<?php
+foreach ($t_l3_interface as $row) {
     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\"><input type=\"hidden\" name='n_id[]' value='{$row['id']}'>{$row['snmpin']}</td>\n";
-    print "<td class=\"data\">".$row['name'].'/'.$int_list[$row['snmpin']]['ip']."</td>\n";
-    print "<td class=\"data\">"; print_qa_l3int_select('s_type[]',$row['interface_type']); print "</td>\n";
-    print "<td class=\"data\"><button name='s_save[]' value='{$row['id']}'>".WEB_btn_save."</button></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['snmpin']}</td>\n";
+    print "<td class=\"data\">" . htmlspecialchars($row['name']) . '/' . htmlspecialchars($int_list[$row['snmpin']]['ip'] ?? '') . "</td>\n";
+    print "<td class=\"data\">";
+    print_qa_l3int_select('s_type[]', $row['interface_type']);
+    print "</td>\n";
+    print "<td class=\"data\"></td>\n";
     print "</tr>\n";
-    }
+}
 ?>
 <tr>
-<td colspan=4><?php print WEB_l3_interface_add; print_add_dev_interface($db_link, $id, $int_list, 's_create_name');?>
-</td>
-<td>
-<input type="submit" name="s_create" value="<?php echo WEB_btn_add; ?>">
-</td>
+    <td colspan=4>
+        <?php 
+        echo WEB_l3_interface_add; 
+        print_add_dev_interface($db_link, $id, $int_list, 's_create_name');
+        ?>
+    </td>
+    <td>
+        <input type="submit" name="s_create" value="<?php echo WEB_btn_add; ?>">
+    </td>
 </tr>
 </table>
 </form>
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
+require_once ($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php");
 ?>

+ 114 - 127
html/admin/devices/editdevice.php

@@ -3,146 +3,133 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/idfilter.php");
 
-if (isset($_POST["editdevice"]) and isset($id)) {
-    if (isset($_POST["f_port_count"])) {
-        $sw_ports = $_POST["f_port_count"] * 1;
-    } else {
-        $sw_ports = 0;
-    }
-    $sSQL = "SELECT count(id) from device_ports WHERE device_ports.device_id=$id";
-    $flist = mysqli_query($db_link, $sSQL);
-    list($d_ports) = mysqli_fetch_array($flist);
+$device = get_record($db_link, 'devices', "id = ?", [$id]);
+$user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$device['user_id']]);
+
+if (getPOST("editdevice") !== null && isset($id)) {
+    // === УПРАВЛЕНИЕ ПОРТАМИ ====================================================
+    $sw_ports = (int)getPOST("f_port_count", null, 0);
+    $sSQL = "SELECT COUNT(id) FROM device_ports WHERE device_ports.device_id = ?";
+    $d_ports = (int)get_single_field($db_link, $sSQL, [$id]);
+
     if ($d_ports != $sw_ports) {
         LOG_DEBUG($db_link, "Device id: $id changed port count!");
+        
         if ($sw_ports > $d_ports) {
             $start_port = $d_ports + 1;
             LOG_DEBUG($db_link, "Device id: $id add connection for port from $start_port to $sw_ports.");
             for ($port = $start_port; $port <= $sw_ports; $port++) {
-                $new['device_id'] = $id;
-                $new['snmp_index'] = $port;
-                $new['port'] = $port;
-                insert_record($db_link, "device_ports", $new);
+                insert_record($db_link, "device_ports", [
+                    'device_id'   => $id,
+                    'snmp_index'  => $port,
+                    'port'        => $port
+                ]);
             }
         }
+        
         if ($sw_ports < $d_ports) {
             LOG_DEBUG($db_link, "Device id: $id remove connection for port from $d_ports to $sw_ports");
             for ($port = $d_ports; $port > $sw_ports; $port--) {
-                $port_id = get_id_record($db_link, 'device_ports', "device_id='" . $id . "' and port='" . $port . "'");
+                $port_id = get_id_record($db_link, 'device_ports', "device_id = ? AND port = ?", [$id, $port]);
                 if ($port_id) {
-                    delete_record($db_link, "device_ports", "id='" . $port_id . "'");
-                    run_sql($db_link, "DELETE FROM connections WHERE port_id='" . $port_id . "'");
+                    delete_record($db_link, "device_ports", "id = ?", [$port_id]);
+                    delete_records($db_link, "connections", "port_id = ?", [$port_id]);
                 } else {
                     LOG_DEBUG($db_link, "Device id: $id port_id not found for port: $port!");
                 }
             }
         }
     }
-    unset($new);
-    if (isset($_POST["f_ip"])) {
-        $new['ip'] = $_POST["f_ip"];
-        $new['ip_int'] = ip2long($new['ip']);
-    }
-    $cur_device = get_record_sql($db_link, "SELECT * FROM devices WHERE id=" . $id);
-    //main device info
-    if (!empty($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"])) {
-        $new['device_model_id'] = $_POST["f_device_model_id"] * 1;
-        $new['vendor_id'] = get_device_model_vendor($db_link, $new['device_model_id']);
-    }
-    if (isset($_POST["f_port_count"])) {
-        $new['port_count'] = $sw_ports;
-    }
-    if (isset($_POST["f_devtype_id"])) {
-        $new['device_type'] = $_POST["f_devtype_id"] * 1;
-    }
-    if (isset($_POST["f_comment"])) {
-        $new['comment'] = $_POST["f_comment"];
-    }
-    if (isset($_POST["f_SN"])) {
-        $new['SN'] = $_POST["f_SN"];
-    }
-    if (isset($_POST["f_firmware"])) {
-        $new['firmware'] = $_POST["f_firmware"];
-    }
-    //snmp
-    if (isset($_POST["f_snmp_version"])) {
-        $new['snmp_version'] = $_POST["f_snmp_version"] * 1;
-    }
-    if (isset($_POST["f_community"])) {
-        $new['community'] = substr($_POST["f_community"], 0, 50);
-    }
-    if (isset($_POST["f_snmp3_auth_proto"])) {
-        $new['snmp3_auth_proto'] = trim(substr($_POST["f_snmp3_auth_proto"], 0, 10));
-    }
-    if (isset($_POST["f_snmp3_priv_proto"])) {
-        $new['snmp3_priv_proto'] = trim(substr($_POST["f_snmp3_priv_proto"], 0, 10));
-    }
-    if (isset($_POST["f_rw_community"])) {
-        $new['rw_community'] = substr($_POST["f_rw_community"], 0, 50);
-    }
-    if (isset($_POST["f_snmp3_user_rw"])) {
-        $new['snmp3_user_rw'] = substr($_POST["f_snmp3_user_rw"], 0, 20);
-    }
-    if (isset($_POST["f_snmp3_user_ro"])) {
-        $new['snmp3_user_ro'] = substr($_POST["f_snmp3_user_ro"], 0, 20);
-    }
-    if (isset($_POST["f_snmp3_user_rw_password"])) {
-        $new['snmp3_user_rw_password'] = substr($_POST["f_snmp3_user_rw_password"], 0, 20);
-    }
-    if (isset($_POST["f_snmp3_user_ro_password"])) {
-        $new['snmp3_user_ro_password'] = substr($_POST["f_snmp3_user_ro_password"], 0, 20);
-    }
-    //acl & configuration options
-    if (isset($_POST["f_queue_enabled"])) {
-        $new['queue_enabled'] = $_POST["f_queue_enabled"] * 1;
-    }
-    if (isset($_POST["f_connected_user_only"])) {
-        $new['connected_user_only'] = $_POST["f_connected_user_only"] * 1;
-    }
-    if (isset($_POST["f_dhcp"])) {
-        $new['dhcp'] = $_POST["f_dhcp"] * 1;
-    }
-    if (isset($_POST["f_user_acl"])) {
-        $new['user_acl'] = $_POST["f_user_acl"] * 1;
-    }
-    //interfaces
-    if (isset($_POST["f_wan"])) {
-        $new['wan_int'] = $_POST["f_wan"];
-    }
-    if (isset($_POST["f_lan"])) {
-        $new['lan_int'] = $_POST["f_lan"];
-    }
-    //location
-    if (isset($_POST["f_building_id"])) {
-        $new['building_id'] = $_POST["f_building_id"] * 1;
+
+    // === ОСНОВНЫЕ ДАННЫЕ УСТРОЙСТВА ============================================
+    $new = [];
+    $cur_device = get_record_sql($db_link, "SELECT * FROM devices WHERE id = ?", [$id]);
+
+    // IP-адрес
+    $f_ip = trim(getPOST("f_ip", null, ''));
+    if ($f_ip !== '') {
+        $new['ip'] = $f_ip;
+        $new['ip_int'] = ip2long($f_ip);
+        $cur_auth = get_record_sql($db_link, "SELECT * FROM user_auth WHERE deleted = 0 AND ip = ?", [$f_ip]);
     }
-    //access
-    if (isset($_POST["f_login"])) {
-        $new['login'] = $_POST["f_login"];
+
+    // Модель устройства
+    $f_device_model_id = (int)getPOST("f_device_model_id", null, 0);
+    if ($f_device_model_id > 0) {
+        $new['device_model_id'] = $f_device_model_id;
+        $new['vendor_id'] = get_device_model_vendor($db_link, $f_device_model_id);
     }
-    if (!empty($_POST["f_password"])) {
-        if (!preg_match('/^\*+$/', $_POST["f_password"])) {
-            $new['password'] = crypt_string($_POST["f_password"]);
+
+    // Количество портов
+    $new['port_count'] = $sw_ports;
+
+    // Тип устройства
+    $new['device_type'] = (int)getPOST("f_devtype_id", null, 0);
+
+    // === УПРАВЛЕНИЕ ЭКЗЕМПЛЯРАМИ ФИЛЬТРОВ ======================================
+    if ($new['device_type'] == 2) {
+        // Это шлюз — должен иметь хотя бы один экземпляр
+        $instances_count = get_count_records($db_link, 'device_filter_instances', 'device_id = ?', [$id]);
+        if (empty($instances_count) || $instances_count == 0) {
+            // Создаём стандартный экземпляр (ID=1)
+            insert_record($db_link, "device_filter_instances", [
+                'instance_id' => 1,
+                'device_id'   => $id
+            ]);
+        }
+    } else {
+        // Не шлюз — удаляем все экземпляры
+        if ($device['device_type'] == 2) {
+            $instances_count = get_count_records($db_link, 'device_filter_instances', 'device_id = ?', [$id]);
+            if (!empty($instances_count) && $instances_count > 0) {
+                delete_records($db_link, 'device_filter_instances', 'device_id = ?', [$id]);
+            }
         }
     }
-    if (isset($_POST["f_protocol"])) {
-        $new['protocol'] = $_POST["f_protocol"] * 1;
-    }
-    if (isset($_POST["f_control_port"])) {
-        $new['control_port'] = $_POST["f_control_port"] * 1;
-    }
-    if (isset($_POST["f_save_netflow"])) {
-        $new['netflow_save'] = $_POST["f_save_netflow"] * 1;
-    }
-    //discovery
-    if (isset($_POST["f_discovery"])) {
-        $new['discovery'] = $_POST["f_discovery"];
+
+    // === ОСТАЛЬНЫЕ ПОЛЯ =========================================================
+    $new['description']           = trim(getPOST("f_description", null, ''));
+    $new['sn']                    = trim(getPOST("f_sn", null, ''));
+    $new['firmware']              = trim(getPOST("f_firmware", null, ''));
+
+    // SNMP
+    $new['snmp_version']          = (int)getPOST("f_snmp_version", null, 0);
+    $new['community']             = substr(trim(getPOST("f_community", null, '')), 0, 50);
+    $new['snmp3_auth_proto']      = substr(trim(getPOST("f_snmp3_auth_proto", null, '')), 0, 10);
+    $new['snmp3_priv_proto']      = substr(trim(getPOST("f_snmp3_priv_proto", null, '')), 0, 10);
+    $new['rw_community']          = substr(trim(getPOST("f_rw_community", null, '')), 0, 50);
+    $new['snmp3_user_rw']         = substr(trim(getPOST("f_snmp3_user_rw", null, '')), 0, 20);
+    $new['snmp3_user_ro']         = substr(trim(getPOST("f_snmp3_user_ro", null, '')), 0, 20);
+    $new['snmp3_user_rw_password']= substr(trim(getPOST("f_snmp3_user_rw_password", null, '')), 0, 20);
+    $new['snmp3_user_ro_password']= substr(trim(getPOST("f_snmp3_user_ro_password", null, '')), 0, 20);
+
+    // ACL и настройки
+    $new['queue_enabled']         = (int)getPOST("f_queue_enabled", null, 0);
+    $new['connected_user_only']   = (int)getPOST("f_connected_user_only", null, 0);
+    $new['dhcp']                  = (int)getPOST("f_dhcp", null, 0);
+    $new['user_acl']              = (int)getPOST("f_user_acl", null, 0);
+
+    // Расположение
+    $new['building_id']           = (int)getPOST("f_building_id", null, 0);
+
+    // Доступ
+    $new['login']                 = trim(getPOST("f_login", null, ''));
+    $f_password                   = getPOST("f_password", null, '');
+    if ($f_password !== '' && !preg_match('/^\*+$/', $f_password)) {
+        $new['password'] = crypt_string($f_password);
     }
-    //nagios
-    if (isset($_POST["f_nagios"])) {
-        $new['nagios'] = $_POST["f_nagios"] * 1;
+
+    $new['protocol']              = (int)getPOST("f_protocol", null, 0);
+    $new['control_port']          = (int)getPOST("f_control_port", null, 0);
+    $new['netflow_save']          = (int)getPOST("f_save_netflow", null, 0);
+
+    // Discovery
+    $new['discovery']             = trim(getPOST("f_discovery", null, 0));
+
+    // Nagios
+    $f_nagios                     = (int)getPOST("f_nagios", null, -1);
+    if ($f_nagios !== -1) {
+        $new['nagios'] = $f_nagios;
         if ($new['nagios'] == 0) {
             $new['nagios_status'] = 'UP';
         }
@@ -153,19 +140,19 @@ if (isset($_POST["editdevice"]) and isset($id)) {
         }
     }
 
-    if ($new['device_type'] == 0 or $new['protocol']<0) {
-        $new['queue_enabled'] = 0;
+    // === ЗАВИСИМОСТИ ПО ТИПУ УСТРОЙСТВА ========================================
+    if ($new['device_type'] == 0 || $new['protocol'] < 0) {
+        $new['queue_enabled']       = 0;
         $new['connected_user_only'] = 1;
-        $new['user_acl'] = 0;
+        $new['user_acl']            = 0;
     }
 
-    update_record($db_link, "devices", "id='$id'", $new);
+    // === СОХРАНЕНИЕ =============================================================
+    update_record($db_link, "devices", "id = ?", $new, [$id]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-$device = get_record($db_link, 'devices', "id=" . $id);
-$user_info = get_record_sql($db_link, "SELECT * FROM User_list WHERE id=" . $device['user_id']);
 unset($_POST);
 
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
@@ -224,14 +211,14 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
             print_device_model_select($db_link, 'f_device_model_id', $device['device_model_id']);
             print "</td>\n";
             print "<td class='data' ><input type='text' name='f_firmware' value='" . $device['firmware'] . "'></td>\n";
-            print "<td class='data' ><input type='text' name='f_SN' value='" . $device['SN'] . "'></td>\n";
+            print "<td class='data' ><input type='text' name='f_sn' value='" . $device['sn'] . "'></td>\n";
             print "</tr>\n";
-            print "<tr><td colspan=2>" . WEB_location_name . "</td><td colspan=2>" . WEB_cell_comment . "</td>";
+            print "<tr><td colspan=2>" . WEB_location_name . "</td><td colspan=2>" . WEB_cell_description . "</td>";
             print "</tr><tr>";
             print "<td class='data'>";
             print_building_select($db_link, 'f_building_id', $device['building_id']);
             print "</td>\n";
-            print "<td class='data' colspan=3><input type='text' size=50 name='f_comment' value='" . $device['comment'] . "'></td>\n";
+            print "<td class='data' colspan=3><input type='text' size=50 name='f_description' value='" . $device['description'] . "'></td>\n";
             print "</tr>";
 
             //print gateway settings
@@ -367,4 +354,4 @@ document.getElementById('f_snmp_version').addEventListener('change', function(ev
 
 </script>
 
-<?php require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.simple.php"); ?>
+<?php require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php"); ?>

+ 19 - 17
html/admin/devices/editport.php

@@ -3,28 +3,30 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/idfilter.php");
 
-if (isset($_POST["editport"])) {
-    $new['snmp_index'] = $_POST["f_snmp"] * 1;
-    $new['uplink'] = $_POST["f_uplink"] * 1;
-    $new['nagios'] = $_POST["f_nagios"] * 1;
-    $new['skip'] = $_POST["f_skip"] * 1;
-    $new['comment'] = $_POST["f_comment"];
-    update_record($db_link, "device_ports", "id='$id'", $new);
+if (getPOST("editport") !== null) {
+    $new = [
+        'snmp_index'  => (int)getPOST("f_snmp", null, 0),
+        'uplink'      => (int)getPOST("f_uplink", null, 0),
+        'nagios'      => (int)getPOST("f_nagios", null, 0),
+        'skip'        => (int)getPOST("f_skip", null, 0),
+        'description' => trim(getPOST("f_description", null, ''))
+    ];
 
-    $target_id = $_POST["f_target_port"];
+    update_record($db_link, "device_ports", "id = ?", $new, [$id]);
+
+    $target_id = (int)getPOST("f_target_port", null, 0);
     bind_ports($db_link, $id, $target_id);
 
-    header("location: editport.php?id=$id");
+    header("Location: editport.php?id=$id");
     exit;
 }
 
 unset($_POST);
 
-$device_id = get_record_field($db_link, 'device_ports', 'device_id', "id=" . $id);
-$port = get_record($db_link, 'device_ports', "id=" . $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']);
+$port = get_record($db_link, 'device_ports', "id=?" ,[ $id]);
+$device_id = $port['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'] ]);
 
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
 
@@ -44,7 +46,7 @@ print_editdevice_submenu($page_url, $device_id, $device['device_type'], $user_in
                 print "<input type=\"text\" name='f_snmp' style='text-align:center;' value='" . $port['snmp_index'] . "'>"; ?>
             </div>
             <div class="field">
-                <?php print "<label for='f_ifIndex'>ifIndex</label>"; ?><input type="text" id="f_ifIndex" disabled="disabled" style="text-align:center;" value="<?php print $port['ifName']; ?>" />
+                <?php print "<label for='f_ifIndex'>ifIndex</label>"; ?><input type="text" id="f_ifIndex" disabled="disabled" style="text-align:center;" value="<?php print $port['ifname']; ?>" />
             </div>
             <div class="field">
                 <?php print "<label for='f_uplink'>" . WEB_device_port_uplink . "</label>";
@@ -59,8 +61,8 @@ print_editdevice_submenu($page_url, $device_id, $device['device_type'], $user_in
                 print_qa_select('f_skip', $port['skip']); ?>
             </div>
             <div class="field">
-                <?php print "<label for='f_comment'>" . WEB_cell_comment . "</label>";
-                print "<input type=\"text\" name='f_comment' value='" . $port['comment'] . "' size=38>"; ?>
+                <?php print "<label for='f_description'>" . WEB_cell_description . "</label>";
+                print "<input type=\"text\" name='f_description' value='" . $port['description'] . "' size=38>"; ?>
             </div>
             <div class="field">
                 <?php print "<label for='f_target_port'>" . WEB_device_port_uplink_device . "</label>";

+ 30 - 21
html/admin/devices/index-passive.php

@@ -15,26 +15,35 @@ $unknown=1;
 if (!isset($_POST['f_unknown']) and isset($_POST['OK'])) { $unknown=0; }
 if (isset($_POST['f_unknown'])) { $unknown=$_POST['f_unknown']*1; }
 
+$params =[];
+
 $unknown_checked='';
 if ($unknown) { $unknown_checked='checked="checked"'; }
 
 $sort_table = 'A';
 if ($sort_field == 'login') { $sort_table = 'L'; }
-if ($sort_field == 'fio') { $sort_table = 'L'; }
+if ($sort_field == 'description') { $sort_table = 'L'; }
 if ($sort_field == 'model_name') { $sort_table = 'M'; }
 
 $sort_url = "<a href=index-passive.php?ou=" . $rou;
 
-if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and L.ou_id=$rou "; }
+if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and L.ou_id=? "; $params[]=$rou; }
 
 if ($rsubnet == 0) { $subnet_filter = ''; } else {
     $subnet_range = get_subnet_range($db_link,$rsubnet);
-    if (!empty($subnet_range)) { $subnet_filter = " and A.ip_int>=".$subnet_range['start']." and A.ip_int<=".$subnet_range['stop']; }
+    if (!empty($subnet_range)) { 
+        $subnet_filter = " and A.ip_int>=? and A.ip_int<=?";
+        $params[]=$subnet_range['start'];
+        $params[]=$subnet_range['stop'];
+        }
     }
 
 $d_filter='';
-if ($f_building_id > 0) { $d_filter .= ' and D.building_id=' . $f_building_id; }
-if ($f_devtype_id > 0) { $d_filter .= ' and D.device_type=' . $f_devtype_id; } else { $d_filter .= ' and D.device_type>2'; }
+if ($f_building_id > 0) { $d_filter .= ' and D.building_id=?'; $params[]=$f_building_id; }
+if ($f_devtype_id > 0) { 
+    $d_filter .= ' and D.device_type=?'; 
+    $params[]= $f_devtype_id;
+    } else { $d_filter .= ' and D.device_type>2'; }
 
 $ip_list_filter = $ou_filter.$subnet_filter;
 
@@ -105,21 +114,20 @@ print_device_submenu($page_url);
 $u_filter='';
 if ($unknown and $f_vendor_select==0) { $u_filter=' AND V.id<>1 '; } else {
     if (!empty($f_vendor_select) and $f_vendor_select>=1) {
-        $u_filter = " AND V.id=".$f_vendor_select." ";
+        $u_filter = " AND V.id=? ";
+        $params[]=$f_vendor_select;
         }
     }
 
-$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
 $u_filter $ip_list_filter $d_filter";
-
-$res = mysqli_query($db_link, $countSQL);
-$count_records = mysqli_fetch_array($res);
-$total=ceil($count_records[0]/$displayed);
+$count_records = get_single_field($db_link,$countSQL, $params);
+$total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed;
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 ?>
 <br>
 
@@ -132,21 +140,22 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
         <td align=Center><?php print $sort_url . "&sort=ip_int&order=$new_order>" . WEB_cell_ip . "</a>"; ?></td>
         <td align=Center><?php print $sort_url . "&sort=mac&order=$new_order>" . WEB_cell_mac . "</a>"; ?></td>
         <td align=Center><?php print $sort_url . "&sort=model_name&order=$new_order>".WEB_cell_host_model; ?></td>
-        <td align=Center><?php print WEB_cell_comment; ?></td>
+        <td align=Center><?php print WEB_cell_description; ?></td>
         <td align=Center><?php print WEB_cell_connection; ?></td>
         <td align=Center><?php print $sort_url . "&sort=last_found&order=$new_order>".WEB_cell_last_found."</a>"; ?></td>
     </tr>
 <?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
-FROM User_auth A, User_list L, devices D, device_models M, vendors V
+$sSQL = "SELECT A.id, D.id as dev_id, D.device_type, A.ip, A.mac, A.user_id, L.login, D.description, A.last_found, V.name, M.model_name
+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
 $u_filter $ip_list_filter $d_filter
-ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
-
-$users = get_records_sql($db_link,$sSQL);
+ORDER BY $sort_table.$sort_field $order LIMIT ? OFFSET ?";
+$params[]=$displayed;
+$params[]=$start;
+$users = get_records_sql($db_link,$sSQL, $params);
 foreach ($users as $user) {
-    if ($user['last_found'] == '0000-00-00 00:00:00') { $user['last_found'] = ''; }
+    if (is_empty_datetime($user['last_found'])) { $user['last_found'] = ''; }
     print "<tr align=center>\n";
     $cl = "data";
     print "<td class='".$cl."' style='padding:0'><input type=checkbox name=fid[] value=".$user['dev_id']."></td>\n";
@@ -154,13 +163,13 @@ foreach ($users as $user) {
     print "<td class='".$cl."' ><a href=/admin/users/edituser.php?id=".$user['user_id'].">" . $user['ip'] . "</a></td>\n";
     print "<td class='".$cl."' >" . expand_mac($db_link,$user['mac']) . "</td>\n";
     print "<td class='".$cl."' >".$user['name'].' '.$user['model_name']."</td>\n";
-    print "<td class='".$cl."' >".$user['comment']."</td>\n";
+    print "<td class='".$cl."' >".$user['description']."</td>\n";
     print "<td class='data'>" . get_connection($db_link, $user['id']) . "</td>\n";
     print "<td class='".$cl."' >".$user['last_found']."</td>\n";
     print "</tr>\n";
 }
 print "</table>\n";
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 ?>
 <br>
 <table class="data">

+ 4 - 4
html/admin/devices/index-tree-simple.php

@@ -40,13 +40,13 @@ foreach ($switches as $row) {
     $dev_hash[$dev_id]['type'] = $row['device_type'];
     $dev_hash[$dev_id]['model_name'] = $row['model_name'];
     $dev_hash[$dev_id]['parent_id'] = null; // инициализируем
-    $pSQL = 'SELECT * FROM device_ports WHERE uplink = 1 and device_id='.$dev_id;
-    $uplink = get_record_sql($db_link,$pSQL);
+    $pSQL = 'SELECT * FROM device_ports WHERE uplink = 1 and device_id=?';
+    $uplink = get_record_sql($db_link,$pSQL, [ $dev_id ]);
     if (empty($uplink)) { continue; }
     if (empty($uplink['target_port_id'])) { continue; }
     $dev_hash[$dev_id]['uplink'] = $uplink['port_name'];
-    $parentSQL = 'SELECT * FROM device_ports WHERE device_ports.id='.$uplink['target_port_id'];
-    $parent = get_record_sql($db_link,$parentSQL);
+    $parentSQL = 'SELECT * FROM device_ports WHERE device_ports.id=?';
+    $parent = get_record_sql($db_link,$parentSQL, [$uplink['target_port_id']]);
     // Защита от ссылки на самого себя
     if ($parent['device_id'] == $dev_id) {
         // Устройство ссылается само на себя - пропускаем эту связь

+ 4 - 4
html/admin/devices/index-tree.php

@@ -60,14 +60,14 @@ foreach ($switches as $row) {
     $dev_hash[$dev_id]['model_name'] = $row['model_name'];
     $dev_hash[$dev_id]['parent_id'] = null; // инициализируем
     
-    $pSQL = 'SELECT * FROM device_ports WHERE uplink = 1 and device_id='.$dev_id;
-    $uplink = get_record_sql($db_link,$pSQL);
+    $pSQL = 'SELECT * FROM device_ports WHERE uplink = 1 and device_id=?';
+    $uplink = get_record_sql($db_link,$pSQL, [ $dev_id ]);
     if (empty($uplink)) { continue; }
     if (empty($uplink['target_port_id'])) { continue; }
     
     $dev_hash[$dev_id]['uplink'] = $uplink['port_name'];
-    $parentSQL = 'SELECT * FROM device_ports WHERE device_ports.id='.$uplink['target_port_id'];
-    $parent = get_record_sql($db_link,$parentSQL);
+    $parentSQL = 'SELECT * FROM device_ports WHERE device_ports.id=?';
+    $parent = get_record_sql($db_link,$parentSQL, [$uplink['target_port_id']]);
     
     // Защита от ссылки на самого себя
     if ($parent['device_id'] == $dev_id) {

+ 36 - 15
html/admin/devices/index.php

@@ -8,21 +8,26 @@ $default_sort='device_name';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
-if (isset($_POST["remove_device"])) {
-    $dev_ids = $_POST["fid"];
-    foreach ($dev_ids as $key => $val) {
-        if ($val) { delete_device($db_link,$val); }
+if (getPOST("remove_device") !== null) {
+    $dev_ids = getPOST("fid", null, []);
+    
+    if (!empty($dev_ids) && is_array($dev_ids)) {
+        foreach ($dev_ids as $val) {
+            $val = trim($val);
+            if ($val !== '') {
+                delete_device($db_link, (int)$val);
+            }
         }
+    }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
-    }
+}
 
 print_device_submenu($page_url);
 
-$sort_sql=" ORDER BY device_name";
-if (!empty($sort_field) and !empty($order)) { $sort_sql = " ORDER BY $sort_field $order"; }
-
 ?>
+
 <div id="cont">
 <br>
 <form name="def" action="index.php" method="post">
@@ -48,16 +53,32 @@ if (!empty($sort_field) and !empty($order)) { $sort_sql = " ORDER BY $sort_field
 </tr>
 <?php
 $filter = '';
-if ($f_building_id > 0) { $filter .= ' and building_id=' . $f_building_id; }
-if ($f_devtype_id >= 0) { $filter .= ' and device_type=' . $f_devtype_id; } else { $filter .= ' and device_type<=2'; }
-if ($f_devmodel_id > 0) { $filter .= ' and device_model_id=' . $f_devmodel_id; }
+$params=[];
+if ($f_building_id > 0) { $filter .= ' and building_id=?'; $params[]=$f_building_id; }
+if ($f_devtype_id >= 0) { $filter .= ' and device_type=?'; $params[]=$f_devtype_id; } else { $filter .= ' and device_type<=2'; }
+if ($f_devmodel_id > 0) { $filter .= ' and device_model_id=?'; $params[]= $f_devmodel_id; }
+
+#$countSQL = "SELECT COUNT(*)  FROM devices D
+#LEFT JOIN device_models DM ON D.device_model_id = DM.id
+#LEFT JOIN building B ON D.building_id = B.id
+#WHERE D.deleted = 0 $filter";
+#$count_records = get_single_field($db_link, $countSQL, $params);
+
+#$total=ceil($count_records/$displayed);
+#if ($page>$total) { $page=$total; }
+#if ($page<1) { $page=1; }
+#$start = ($page * $displayed) - $displayed;
+#print_navigation($page_url,$page,$displayed,$count_records,$total);
+
+$sort_sql=" ORDER BY device_name";
+if (!empty($sort_field) and !empty($order)) { $sort_sql = " ORDER BY $sort_field $order"; }
 
 $dSQL = 'SELECT D.*, DM.model_name, B.name AS building_name FROM devices D
 LEFT JOIN device_models DM ON D.device_model_id = DM.id
 LEFT JOIN building B ON D.building_id = B.id
 WHERE D.deleted = 0 ' . $filter . ' ' . $sort_sql;
 
-$switches = get_records_sql($db_link,$dSQL);
+$switches = get_records_sql($db_link,$dSQL, $params);
 foreach ($switches as $row) {
     print "<tr align=center>\n";
     $cl = "data";
@@ -74,9 +95,9 @@ foreach ($switches as $row) {
         print "<td class=\"$cl\">".$row['ip']."</td>\n";
         }
     print "<td class=\"$cl\">" . get_vendor_name($db_link, $row['vendor_id']) . " " . $row['model_name'] . "</td>\n";
-    print '<td class="'.$cl.'" style="width: 1%; white-space: nowrap;">' . $row['SN'] ."</td>\n";
+    print '<td class="'.$cl.'" style="width: 1%; white-space: nowrap;">' . $row['sn'] ."</td>\n";
     print "<td class=\"$cl\">" . get_building($db_link, $row['building_id']);
-    if (!empty($row['comment'])) { print  '<hr style="opacity: 0;">' . $row['comment']; }
+    if (!empty($row['description'])) { print  '<hr style="opacity: 0;">' . $row['description']; }
     print "</td>\n";
     print "<td class=\"$cl\">" . $row['port_count'] . "</td>\n";
     print "<td class=\"$cl\">" . get_qa($row['nagios']) . "</td>\n";
@@ -112,5 +133,5 @@ document.getElementById('building_id').addEventListener('change', function(event
 </script>
 
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

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

@@ -3,17 +3,17 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".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]);
 $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");
 
 print_device_submenu($page_url);
 print_editdevice_submenu($page_url,$id,$device['device_type'],$user_info['login']);
 
-$sSQL = "SELECT port, snmp_index FROM `device_ports` WHERE device_id=".$id;
-$ports_info = get_records_sql($db_link, $sSQL);
+$sSQL = "SELECT port, snmp_index FROM device_ports WHERE device_id=?";
+$ports_info = get_records_sql($db_link, $sSQL, [ $id ]);
 $ports_by_snmp_index=NULL;
 foreach ($ports_info as &$row) { $ports_by_snmp_index[$row["snmp_index"]]=$row["port"]; }
 
@@ -26,7 +26,7 @@ if (!apply_device_lock($db_link,$id)) {
 
 <div id="contsubmenu">
 <?php
-$ports = get_records($db_link,'device_ports',"device_id=$id AND uplink=0 ORDER BY port");
+$ports = get_records($db_link,'device_ports',"device_id=? AND uplink=0 ORDER BY port", [ $id ]);
 print "<b>".WEB_device_mac_table_show."&nbsp".$device['device_name']." (".$device['ip']."):</b>\n";
 
 $snmp_ok = 0;
@@ -66,5 +66,5 @@ if ($snmp_ok) {
 	}
 
 unset_lock_discovery($db_link,$id);
-require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.simple.php");
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php");
 ?>

+ 66 - 39
html/admin/devices/portmactable.php

@@ -4,19 +4,37 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 $port_id = $id;
-$sSQL = "SELECT DP.device_id, DP.port, DP.snmp_index, D.device_name, D.ip, D.vendor_id FROM `device_ports` AS DP, devices AS D WHERE D.id = DP.device_id AND DP.id=$port_id";
-$port_info = get_record_sql($db_link, $sSQL);
+$sSQL = "SELECT DP.device_id, DP.port, DP.snmp_index, D.device_name, D.ip, D.vendor_id FROM device_ports AS DP, devices AS D WHERE D.id = DP.device_id AND DP.id=?";
+$port_info = get_record_sql($db_link, $sSQL, [ $port_id ]);
+if (empty($port_info)) {
+    header("Location: /admin/devices/editdevice.php?id=".$device_id);
+    exit;
+}
 
 $device_id = $port_info["device_id"];
 
-$sSQL = "SELECT port, snmp_index FROM `device_ports` WHERE device_id=".$device_id;
-$ports_info = get_records_sql($db_link, $sSQL);
+$sSQL = "SELECT port, snmp_index FROM device_ports WHERE device_id=?";
+$ports_info = get_records_sql($db_link, $sSQL, [$device_id]);
+if (empty($ports_info)) {
+    header("Location: /admin/devices/editdevice.php?id=".$device_id);
+    exit;
+}
+
 $ports_by_snmp_index=NULL;
 foreach ($ports_info as &$row) { $ports_by_snmp_index[$row["snmp_index"]]=$row["port"]; }
 
-$device=get_record($db_link,'devices',"id=".$device_id);
+$device=get_record($db_link,'devices',"id=?", [$device_id]);
+if (empty($device)) {
+    header("Location: /admin/devices/index.php");
+    exit;
+}
+
 $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)) {
+    header("Location: /admin/devices/index.php");
+    exit;
+}
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
@@ -38,11 +56,12 @@ print "<b>".$port_info['device_name']." [".$port_info['port']."] </b><br>\n";
 
 $sw_auth=NULL;
 $sw_mac=NULL;
-if ($port_info['vendor_id'] == 9) {
-    $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)) {
     $sw_mac = mac_simplify($sw_auth['mac']);
     $sw_mac = preg_replace("/.{2}$/","",$sw_mac);
-    }
+}
 
 $snmp_ok = 0;
 if (!empty($device['ip']) and $device['snmp_version'] > 0) {
@@ -55,19 +74,25 @@ if ($snmp_ok and $port_info['snmp_index'] > 0) {
     $fdb = get_fdb_table($port_info['ip'], $snmp);
     $f_port = $port_info['snmp_index'];
     $port_by_snmp = 0;
-    foreach ($fdb as $a_mac => $a_port) {
-        if (!empty($ports_by_snmp_index[$a_port])) { $port_by_snmp=1; break; }
+    if (!empty($fdb)) {
+        foreach ($fdb as $a_mac => $a_port) {
+            if (!empty($ports_by_snmp_index[$a_port])) { $port_by_snmp=1; break; }
+        }
     }
     if (!$port_by_snmp) { $f_port = $port_info['port']; }
-    foreach ($fdb as $a_mac => $a_port) {
-        if ($a_port == $f_port) {
-            $a_mac = dec_to_hex($a_mac);
-            //mikrotik patch
-            if (!empty($sw_mac) and preg_match('/^'.$sw_mac.'/',mac_simplify($a_mac))) { continue; }
-            print "<tr>";
-            $auth = get_auth_by_mac($db_link, $a_mac);
-            print "<td class=\"data\">" .$auth['auth'] . "</td><td class=\"data\">". $auth['mac']."</td>\n";
-            print "</tr>";
+    if (!empty($fdb)) {
+        foreach ($fdb as $a_mac => $a_port) {
+            if ($a_port == $f_port) {
+                $a_mac = dec_to_hex($a_mac);
+                //mikrotik patch
+                if (!empty($sw_mac) and preg_match('/^'.$sw_mac.'/',mac_simplify($a_mac))) { continue; }
+                print "<tr>";
+                $auth = get_auth_by_mac($db_link, $a_mac);
+                if (!empty($auth)) {
+                    print "<td class=\"data\">" .$auth['auth'] . "</td><td class=\"data\">". $auth['mac']."</td>\n";
+                }
+                print "</tr>";
+                }
             }
         }
     print "</table>\n";
@@ -82,30 +107,32 @@ unset_lock_discovery($db_link,$device_id);
 </tr>
 <?php
 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";
-$t_device = mysqli_query($db_link, $d_sql);
-while (list ($f_ip, $f_int, $f_mac, $f_auth_id, $f_dns, $f_last) = mysqli_fetch_array($t_device)) {
-    $name = $f_ip;
-    if (isset($f_dns) and $f_dns != '') {
-        $name = $f_dns;
+$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);
+if (!empty($t_device)) {
+    foreach ($t_device as $row) {
+        $name = $row['ip'];
+        if (!empty($row['dns_name']) and isset($row['dns'])) { $name = $row['dns_name']; }
+        print "<tr>";
+        print "<td class=\"data\">" . expand_mac($db_link,$row['mac']) . "</td>\n";
+        print "<td class=\"data\"><a href=\"/admin/users/editauth.php?id=".$row['id']."\">" . $name . "</a></td>\n";
+        print "<td class=\"data\">".get_datetime_display($row['last_found'])."</td>\n";
+        print "</tr>";
     }
-    print "<tr>";
-    print "<td class=\"data\">" . expand_mac($db_link,$f_mac) . "</td>\n";
-    print "<td class=\"data\"><a href=\"/admin/users/editauth.php?id=$f_auth_id\">" . $name . "</a></td>\n";
-    print "<td class=\"data\">$f_last</td>\n";
-    print "</tr>";
 }
 
-$maclist = mysqli_query($db_link, "SELECT mac,timestamp from Unknown_mac where port_id=$port_id order by timestamp desc");
-while (list ($fmac, $f_last) = mysqli_fetch_array($maclist)) {
-    print "<tr>";
-    print "<td class=\"data\">" . expand_mac($db_link,$fmac) . "</td>\n";
-    print "<td class=\"data\">Unknown</td>\n";
-    print "<td class=\"data\">$f_last</td>\n";
-    print "</tr>";
+$maclist = get_records_sql($db_link, "SELECT mac,ts from unknown_mac where port_id=? ORDER BY ts desc", [ $port_id ]);
+if (!empty($maclist)) {
+    foreach ($maclist as $row) {
+        print "<tr>";
+        print "<td class=\"data\">" . expand_mac($db_link,$row['mac']) . "</td>\n";
+        print "<td class=\"data\">Unknown</td>\n";
+        print "<td class=\"data\">".get_datetime_display($row['ts'])."</td>\n";
+        print "</tr>";
+    }
 }
 
 print "</table>\n";
 
-require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.simple.php");
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php");
 ?>

+ 10 - 11
html/admin/devices/portsbyvlan.php

@@ -16,14 +16,13 @@ print_device_submenu($page_url);
 </form>
 
 <?php
-$countSQL="SELECT Count(*) FROM `device_ports` AS DP, devices AS D WHERE D.id = DP.device_id AND DP.vlan=$id";
-$res = mysqli_query($db_link, $countSQL);
-$count_records = mysqli_fetch_array($res);
-$total=ceil($count_records[0]/$displayed);
+$countSQL="SELECT Count(*) FROM device_ports AS DP, devices AS D WHERE D.id = DP.device_id AND DP.vlan=?";
+$count_records = get_single_field($db_link,$countSQL, [ $id ]);
+$total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed; 
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 ?>
 
 <table class="data">
@@ -32,16 +31,16 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 <td><?php echo WEB_device_port_name; ?></td>
 </tr>
 <?php
-$sSQL = "SELECT DP.id, DP.port, D.id, D.device_name FROM `device_ports` AS DP, devices AS D WHERE D.id = DP.device_id AND DP.vlan=$id";
-$ports_info = mysqli_query($db_link, $sSQL);
-while (list ($f_port_id,$f_port,$f_switch_id,$f_switch) = mysqli_fetch_array($ports_info)) {
+$sSQL = "SELECT DP.id, DP.port, DP.device_id, D.device_name FROM device_ports AS DP, devices AS D WHERE D.id = DP.device_id AND DP.vlan=?";
+$ports_info = get_records_sql($db_link, $sSQL, [ $id ]);
+foreach ($ports_info as $row) {
     print "<tr>";
-    print "<td class=\"data\"><a href=\"/admin/devices/editdevice.php?id=$f_switch_id\">" . $f_switch . "</a></td>\n";
-    print "<td class=\"data\"><a href=\"/admin/devices/editport.php?id=$f_port_id\">" . $f_port . "</a></td>\n";
+    print "<td class=\"data\"><a href=\"/admin/devices/editdevice.php?id=".$row['device_id']."\">" . $row['device_name']. "</a></td>\n";
+    print "<td class=\"data\"><a href=\"/admin/devices/editport.php?id=".$row['id']."\">" . $row['port'] . "</a></td>\n";
     print "</tr>";
 }
 ?>
 </table>
-<?php print_navigation($page_url,$page,$displayed,$count_records[0],$total); 
+<?php print_navigation($page_url,$page,$displayed,$count_records,$total); 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

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

@@ -3,9 +3,9 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".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 ]);
 $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");
 print_device_submenu($page_url);

+ 15 - 13
html/admin/devices/switchport-conn.php

@@ -3,23 +3,25 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".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 ]);
 
-if (isset($_POST["remove"])) {
-    $fid = $_POST["f_id"];
-    foreach ($fid as $key => $val) {
-        if (isset($val) and $val != 1) {
-                LOG_VERBOSE($db_link, "Remove connection id: $val ".dump_record($db_link,'connections','id='.$val));
-                delete_record($db_link, "connections", "id=" . $val);
+if (getPOST("remove") !== null) {
+    $fid = getPOST("f_id", null, []);
+    if (!empty($fid) && is_array($fid)) {
+        foreach ($fid as $val) {
+            $val = trim($val);
+            if ($val !== '' && $val != 1) {
+                delete_record($db_link, "connections", "id = ?", [(int)$val]);
             }
         }
-        header("Location: " . $_SERVER["REQUEST_URI"]);
-        exit;
     }
+    header("Location: " . $_SERVER["REQUEST_URI"]);
+    exit;
+}
 
 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");
 
@@ -43,11 +45,11 @@ print_editdevice_submenu($page_url,$id,$device['device_type'],$user_info['login'
 
 <?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=? ORDER BY C.port_id ASC", [ $id ]);
 foreach ($connections as $key => $value) {
 print "<tr align=center>\n";
 print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='{$value['id']}'></td>\n";
-$port = get_record($db_link,"device_ports","id=".$value['port_id']);
+$port = get_record($db_link,"device_ports","id=?", [$value['port_id']]);
 print "<td class=\"data\">". $port['port'] . "</a></td>\n";
 print "<td class=\"data\">";
 print_auth_detail($db_link, $value['auth_id']);
@@ -60,5 +62,5 @@ print "</table>\n";
 </form>
 
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

+ 39 - 47
html/admin/devices/switchport.php

@@ -3,60 +3,52 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
-if (isset($_POST["regensnmp"])) {
-    $snmp_index = $_POST["f_snmp_start"] * 1;
-    $sSQL = "SELECT id,port from device_ports WHERE device_ports.device_id=$id order by id";
-    $flist = mysqli_query($db_link, $sSQL);
+// Перегенерация SNMP-индексов
+if (getPOST("regensnmp") !== null) {
+    $snmp_index = (int)getPOST("f_snmp_start", null, 1);
+    $sSQL = "SELECT id, port FROM device_ports WHERE device_ports.device_id = ? ORDER BY id";
+    $flist = get_records_sql($db_link, $sSQL, [$id]);
     LOG_DEBUG($db_link, "Recalc snmp_index for device id: $id with start $snmp_index");
-    while (list ($port_id, $port) = mysqli_fetch_array($flist)) {
-        $snmp = $port + $snmp_index - 1;
-        $new['snmp_index'] = $snmp;
-        update_record($db_link, "device_ports", "id='$port_id'", $new);
+    foreach ($flist as $row) {
+        $snmp = $row['port'] + $snmp_index - 1;
+        update_record($db_link, "device_ports", "id = ?", ['snmp_index' => $snmp], [$row['id']]);
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST['save'])) {
-    $saved = array();
-    //button save
-    $len = is_array($_POST['save']) ? count($_POST['save']) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $save_id = intval($_POST['save'][$i]);
-        if ($save_id == 0) { continue;  }
-        array_push($saved,$save_id);
-        }
-    //select box
-    $len = is_array($_POST['f_id']) ? count($_POST['f_id']) : 0;
-    if ($len>0) {
-        for ($i = 0; $i < $len; $i ++) {
-            $save_id = intval($_POST['f_id'][$i]);
-            if ($save_id == 0) { continue; }
-            if (!in_array($save_id, $saved)) { array_push($saved,$save_id); }
-            }
-        }
-    //save changes
-    $len = is_array($saved) ? count($saved) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $save_id = intval($saved[$i]);
-        if ($save_id == 0) { continue;  }
-        $len_all = is_array($_POST['p_id']) ? count($_POST['p_id']) : 0;
-        for ($j = 0; $j < $len_all; $j ++) {
-            if (intval($_POST['p_id'][$j]) != $save_id) { continue; }
-            $new['port_name'] = $_POST['f_name'][$j];
-            $new['snmp_index'] = $_POST['f_snmp_index'][$j]*1;
-            update_record($db_link, "device_ports", "id='{$save_id}'", $new);
-            }
+// Сохранение ОТМЕЧЕННЫХ портов
+if (getPOST("save") !== null) {
+    $selected_ids = getPOST("f_id", null, []);      // отмеченные чекбоксы
+    $all_ids      = getPOST("p_id", null, []);      // все ID
+    $port_names   = getPOST("f_name", null, []);
+    $snmp_indices = getPOST("f_snmp_index", null, []);
+    
+    if (!empty($selected_ids) && is_array($selected_ids)) {
+        $selected_ids = array_map('intval', $selected_ids);
+        $selected_set = array_flip($selected_ids);
+        
+        foreach ($all_ids as $i => $id) {
+            $id = (int)$id;
+            if ($id <= 0 || !isset($selected_set[$id])) continue;
+            
+            $new = [
+                'port_name'   => trim($port_names[$i] ?? ''),
+                'snmp_index'  => (int)($snmp_indices[$i] ?? 0)
+            ];
+            
+            update_record($db_link, "device_ports", "id = ?", $new, [$id]);
         }
+    }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
-    }
-
+}
 
 unset($_POST);
 
-$device=get_record($db_link,'devices',"id=".$id);
-$user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_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'] ]);
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
@@ -78,7 +70,7 @@ print_editdevice_submenu($page_url,$id,$device['device_type'],$user_info['login'
 <td><?php echo WEB_device_port_name; ?></td>
 <td><?php echo WEB_device_port_snmp_index; ?></td>
 <td><?php echo WEB_device_connected_endpoint; ?></td>
-<td><?php echo WEB_cell_comment; ?></td>
+<td><?php echo WEB_cell_description; ?></td>
 <td><?php echo WEB_device_port_uplink; ?></td>
 <td><?php echo WEB_nagios; ?></td>
 <td><?php echo WEB_cell_skip; ?></td>
@@ -87,8 +79,8 @@ print_editdevice_submenu($page_url,$id,$device['device_type'],$user_info['login'
 <td><?php echo WEB_cell_mac_count; ?></td>
 </tr>
 <?php
-$sSQL = "SELECT * FROM device_ports WHERE device_ports.device_id=$id ORDER BY port";
-$ports=get_records_sql($db_link,$sSQL);
+$sSQL = "SELECT * FROM device_ports WHERE device_ports.device_id=? ORDER BY port";
+$ports=get_records_sql($db_link,$sSQL, [ $id ]);
 foreach ($ports as $row) {
         print "<tr align=center>\n";
         $cl = "data";
@@ -104,7 +96,7 @@ foreach ($ports as $row) {
             print_auth_port($db_link, $row['id'],FALSE);
         }
         print "</td>\n";
-        print "<td class='".$cl."'>" . get_port_comment($db_link, $row['id'],$row['comment']) . "</td>\n";
+        print "<td class='".$cl."'>" . get_port_description($db_link, $row['id'],$row['description']) . "</td>\n";
         print_td_yes($row['uplink'],FALSE,$cl);
         print_td_yes($row['nagios'],FALSE,$cl);
         print_td_yes($row['skip'],FALSE,$cl);
@@ -155,5 +147,5 @@ print "</table>\n";
 </div>
 </form>
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

+ 88 - 62
html/admin/devices/switchstatus.php

@@ -3,67 +3,92 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".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]);
 $snmp = getSnmpAccess($device);
-$device_model = get_record($db_link, 'device_models', "id=" . $device['device_model_id']);
+$device_model = get_record($db_link, 'device_models', "id = ?", [$device['device_model_id']]);
 
-if (isset($_POST["regensnmp"])) {
-    $snmp_index = $_POST["f_snmp_start"] * 1;
-    $sSQL = "SELECT id,port from device_ports WHERE device_ports.device_id=$id order by id";
-    $flist = mysqli_query($db_link, $sSQL);
+// Перегенерация SNMP-индексов
+if (getPOST("regensnmp") !== null) {
+    $snmp_index = (int)getPOST("f_snmp_start", null, 1);
+    $sSQL = "SELECT id, port FROM device_ports WHERE device_ports.device_id = ? ORDER BY id";
+    $flist = get_records_sql($db_link, $sSQL, [$id]);
     LOG_DEBUG($db_link, "Recalc snmp_index for device id: $id with start $snmp_index");
-    while (list($port_id, $port) = mysqli_fetch_array($flist)) {
-        $snmp = $port + $snmp_index - 1;
-        $new['snmp_index'] = $snmp;
-        update_record($db_link, "device_ports", "id='$port_id'", $new);
+    foreach ($flist as $row) {
+        $snmp_val = $row['port'] + $snmp_index - 1;
+        update_record($db_link, "device_ports", "id = ?", ['snmp_index' => $snmp_val], [$row['id']]);
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST['poe_on']) and $device['snmp_version'] > 0) {
-    $len = is_array($_POST['poe_on']) ? count($_POST['poe_on']) : 0;
-    for ($i = 0; $i < $len; $i++) {
-        $port_index = intval($_POST['poe_on'][$i]);
-        $sSQL = "SELECT port from device_ports WHERE device_id=" . $id . " and snmp_index=" . $port_index;
-        $port = get_record_sql($db_link, $sSQL);
-        LOG_DEBUG($db_link, "Device id: " . $id . " enable poe at port " . $port['port'] . " snmp index " . $port_index);
-        set_port_poe_state($device['vendor_id'], $port['port'], $port_index, $device['ip'], $snmp, 1);
+// Включение PoE
+if (getPOST("poe_on") !== null && $device['snmp_version'] > 0) {
+    $poe_on = getPOST("poe_on", null, []);
+    if (!empty($poe_on) && is_array($poe_on)) {
+        foreach ($poe_on as $port_index) {
+            $port_index = (int)$port_index;
+            if ($port_index <= 0) continue;
+            $port = get_record_sql($db_link, 
+                "SELECT port FROM device_ports WHERE device_id = ? AND snmp_index = ?", 
+                [$id, $port_index]
+            );
+            if (!empty($port)) {
+                LOG_DEBUG($db_link, "Device id: $id enable poe at port {$port['port']} snmp index $port_index");
+                set_port_poe_state($device['vendor_id'], $port['port'], $port_index, $device['ip'], $snmp, 1);
+            }
+        }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST['poe_off']) and $device['snmp_version'] > 0) {
-    $len = is_array($_POST['poe_off']) ? count($_POST['poe_off']) : 0;
-    for ($i = 0; $i < $len; $i++) {
-        $port_index = intval($_POST['poe_off'][$i]);
-        $sSQL = "SELECT port from device_ports WHERE device_id=" . $id . " and snmp_index=" . $port_index;
-        $port = get_record_sql($db_link, $sSQL);
-        LOG_DEBUG($db_link, "Device id: " . $id . " disable poe at port " . $port['port'] . " snmp index " . $port_index);
-        set_port_poe_state($device['vendor_id'], $port['port'], $port_index, $device['ip'], $snmp, 0);
+// Отключение PoE
+if (getPOST("poe_off") !== null && $device['snmp_version'] > 0) {
+    $poe_off = getPOST("poe_off", null, []);
+    if (!empty($poe_off) && is_array($poe_off)) {
+        foreach ($poe_off as $port_index) {
+            $port_index = (int)$port_index;
+            if ($port_index <= 0) continue;
+            $port = get_record_sql($db_link, 
+                "SELECT port FROM device_ports WHERE device_id = ? AND snmp_index = ?", 
+                [$id, $port_index]
+            );
+            if (!empty($port)) {
+                LOG_DEBUG($db_link, "Device id: $id disable poe at port {$port['port']} snmp index $port_index");
+                set_port_poe_state($device['vendor_id'], $port['port'], $port_index, $device['ip'], $snmp, 0);
+            }
+        }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST['port_on']) and $device['snmp_version'] > 0) {
-    $len = is_array($_POST['port_on']) ? count($_POST['port_on']) : 0;
-    for ($i = 0; $i < $len; $i++) {
-        $port_index = intval($_POST['port_on'][$i]);
-        LOG_DEBUG($db_link, "Device id: $id enable port with snmp index $port_index");
-        set_port_state($device['vendor_id'], $port_index, $device['ip'], $snmp, 1);
+// Включение портов
+if (getPOST("port_on") !== null && $device['snmp_version'] > 0) {
+    $port_on = getPOST("port_on", null, []);
+    
+    if (!empty($port_on) && is_array($port_on)) {
+        foreach ($port_on as $port_index) {
+            $port_index = (int)$port_index;
+            if ($port_index <= 0) continue;
+            LOG_DEBUG($db_link, "Device id: $id enable port with snmp index $port_index");
+            set_port_state($device['vendor_id'], $port_index, $device['ip'], $snmp, 1);
+        }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST['port_off']) and $device['snmp_version'] > 0) {
-    $len = is_array($_POST['port_off']) ? count($_POST['port_off']) : 0;
-    for ($i = 0; $i < $len; $i++) {
-        $port_index = intval($_POST['port_off'][$i]);
-        LOG_DEBUG($db_link, "Device id: $id disable port with snmp index $port_index");
-        set_port_state($device['vendor_id'], $port_index, $device['ip'], $snmp, 0);
+// Отключение портов
+if (getPOST("port_off") !== null && $device['snmp_version'] > 0) {
+    $port_off = getPOST("port_off", null, []);
+    if (!empty($port_off) && is_array($port_off)) {
+        foreach ($port_off as $port_index) {
+            $port_index = (int)$port_index;
+            if ($port_index <= 0) continue;
+            LOG_DEBUG($db_link, "Device id: $id disable port with snmp index $port_index");
+            set_port_state($device['vendor_id'], $port_index, $device['ip'], $snmp, 0);
+        }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
@@ -76,7 +101,7 @@ if (!apply_device_lock($db_link, $id)) {
     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");
 
@@ -101,6 +126,7 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
             $snmp_ok = check_snmp_access($device['ip'], $snmp);
             $modules_oids = NULL;
             if ($snmp_ok) {
+                update_record($db_link, 'devices', 'id=?', [ 'nagios_status'=> 'UP' ], [ $id ]);
                 $modules_oids = walk_snmp($device["ip"], $snmp, CISCO_MODULES);
                 $vlan_list = get_switch_vlans($device['vendor_id'], $device['ip'], $snmp);
                 //if port number 1 not exists - try detect by snmp interface index
@@ -119,7 +145,7 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
         print "<td>" . WEB_device_port_name . "</td>\n";
         print "<td>" . WEB_device_port_snmp_index . "</td>\n";
         print "<td>" . WEB_device_connected_endpoint . "</td>\n";
-        print "<td>" . WEB_cell_comment . "</td>\n";
+        print "<td>" . WEB_cell_description . "</td>\n";
         print "<td>" . WEB_device_port_uplink . "</td>\n";
         print "<td>" . WEB_nagios . "</td>\n";
         print "<td>" . WEB_cell_skip . "</td>\n";
@@ -134,8 +160,8 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
         }
         print "<td>" . WEB_device_port_control . "</td>\n";
         print "</tr>\n";
-        $sSQL = "SELECT * FROM device_ports WHERE device_ports.device_id=$id ORDER BY port";
-        $ports = get_records_sql($db_link, $sSQL);
+        $sSQL = "SELECT * FROM device_ports WHERE device_ports.device_id=? ORDER BY port";
+        $ports = get_records_sql($db_link, $sSQL, [ $id ]);
         foreach ($ports as $row) {
             print "<tr align=center>\n";
             $cl = "down";
@@ -190,13 +216,13 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
                 print_auth_port($db_link, $row['id'], TRUE);
             }
             print "</td>\n";
-            print "<td class='" . $cl . "' >" . get_port_comment($db_link, $row['id'], $row['comment']) . "</td>\n";
+            print "<td class='" . $cl . "' >" . get_port_description($db_link, $row['id'], $row['description']) . "</td>\n";
             print_td_yes($row['uplink'],FALSE,$cl);
             print_td_yes($row['nagios'],FALSE,$cl);
             print_td_yes($row['skip'],FALSE,$cl);
             $poe_info = "";
 
-            $ifname = $row['ifName'];
+            $ifname = $row['ifname'];
 
             if ($snmp_ok) {
                 //sfp information
@@ -289,14 +315,14 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
                 if (!empty($ifmib_list[$row['snmp_index']])) {
                     $ifname = $ifmib_list[$row['snmp_index']];
                 }
-                if (!isset($row['ifName']) or $row['ifName'] !== $ifname) {
-                    $new_info['ifName'] = $ifname;
+                if (!isset($row['ifname']) or $row['ifname'] !== $ifname) {
+                    $new_info['ifname'] = $ifname;
                 }
             }
 
             //fix port information
             if ($snmp_ok) {
-                update_record($db_link, "device_ports", "id=" . $row['id'], $new_info);
+                update_record($db_link, "device_ports", "id=?", $new_info, [  $row['id'] ]);
             }
 
             $ifname = compact_port_name($ifname);
@@ -409,18 +435,18 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
             <input type='submit' name='regensnmp' value='<?php echo WEB_device_recalc_snmp_port ?>'>
         </div>
 
-        <?php
-        print "<table class=\"data\" cellspacing=\"1\" cellpadding=\"4\">\n";
-        print "<tr><td>" . WEB_port_status . "</td></tr>\n";
-        print "<tr><td class=\"down\">" . WEB_port_oper_down . "</td>";
-        print "<td class=\"up\">" . WEB_port_oper_up . "</td>";
-        print "<td class=\"shutdown\">" . WEB_port_admin_shutdown . "</td><tr>\n";
-        print "</table>\n";
-        print "<table class=\"data\" cellspacing=\"1\" cellpadding=\"4\">\n";
-        print "<tr><td>" . WEB_port_speed . "</td></tr>\n";
-        print "<tr><td class=\"speed10M\">" . WEB_port_speed_10 . "</td><td class=\"speed100M\">" . WEB_port_speed_100 . "</td><td class=\"speed1G\">" . WEB_port_speed_1G . "</td><td class=\"speed10G\">" . WEB_port_speed_10G . "</td><tr>\n";
-        print "</table>\n";
-        print "</form>";
-        unset_lock_discovery($db_link, $id);
-        require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.simple.php");
-        ?>
+<?php
+print "<table class=\"data\" cellspacing=\"1\" cellpadding=\"4\">\n";
+print "<tr><td>" . WEB_port_status . "</td></tr>\n";
+print "<tr><td class=\"down\">" . WEB_port_oper_down . "</td>";
+print "<td class=\"up\">" . WEB_port_oper_up . "</td>";
+print "<td class=\"shutdown\">" . WEB_port_admin_shutdown . "</td><tr>\n";
+print "</table>\n";
+print "<table class=\"data\" cellspacing=\"1\" cellpadding=\"4\">\n";
+print "<tr><td>" . WEB_port_speed . "</td></tr>\n";
+print "<tr><td class=\"speed10M\">" . WEB_port_speed_10 . "</td><td class=\"speed100M\">" . WEB_port_speed_100 . "</td><td class=\"speed1G\">" . WEB_port_speed_1G . "</td><td class=\"speed10G\">" . WEB_port_speed_10G . "</td><tr>\n";
+print "</table>\n";
+print "</form>";
+unset_lock_discovery($db_link, $id);
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php");
+?>

+ 19 - 15
html/admin/filters/editfilter.php

@@ -3,15 +3,20 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
-if (isset($_POST["editfilter"])) {
-    $new['name'] = $_POST["f_name"];
-    $new['dst'] = $_POST["f_dst"];
-    $new['proto'] = $_POST["f_proto"];
-    $new['dstport'] = str_replace(':', '-', $_POST["f_dstport"]);
-    $new['srcport'] = str_replace(':', '-', $_POST["f_srcport"]);
-    $new['comment'] = $_POST["f_comment"];
-    update_record($db_link, "Filter_list", "id='$id'", $new);
-    unset($_POST);
+$filter = get_record($db_link, 'filter_list','id=?', [ $id ]);
+
+if (getPOST("editfilter") !== null) {
+    $new = [
+        'name'        => trim(getPOST("f_name", null, $filter['name'])),
+        'dst'         => trim(getPOST("f_dst", null, '')),
+        'proto'       => trim(getPOST("f_proto", null, '')),
+        'dstport'     => str_replace(':', '-', trim(getPOST("f_dstport", null, ''))),
+        'srcport'     => str_replace(':', '-', trim(getPOST("f_srcport", null, ''))),
+        'description' => trim(getPOST("f_description", null, ''))
+    ];
+
+    update_record($db_link, "filter_list", "id = ?", $new, [$id]);
+
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
@@ -20,7 +25,6 @@ unset($_POST);
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
-$filter = get_record($db_link, 'Filter_list','id='.$id);
 
 print_filters_submenu($page_url);
 
@@ -31,14 +35,14 @@ print "<br> <b>".WEB_title_filter."</b> <br>";
 print "<form name=def action='editfilter.php?id=".$id."' method=post>";
 print "<input type=hidden name=id value=$id>";
 
-if (isset($filter['type']) and $filter['type'] == 0) {
+if (isset($filter['filter_type']) and $filter['filter_type'] == 0) {
     print "<table class=\"data\" cellspacing=\"0\" cellpadding=\"4\">";
     print "<tr><td><b>".WEB_cell_forename."</b></td>";
-    print "<td colspan=2><b>".WEB_cell_comment."</b></td>";
+    print "<td colspan=2><b>".WEB_cell_description."</b></td>";
     print "</tr>";
     print "<tr>";
     print "<td align=left><input type=text name=f_name value='".$filter['name']."'></td>";
-    print "<td colspan=2><input type=text name=f_comment value='".$filter['comment']."'></td>";
+    print "<td colspan=2><input type=text name=f_description value='".$filter['description']."'></td>";
     print "<td><input type=submit name=editfilter value='".WEB_btn_save."'></td>";
     print "</tr>";
     print "<tr>";
@@ -57,12 +61,12 @@ if (isset($filter['type']) and $filter['type'] == 0) {
 } else {
     print "<table class=\"data\" cellspacing=\"0\" cellpadding=\"4\">";
     print "<tr><td><b>".WEB_cell_forename."</b></td>";
-    print "<td><b>".WEB_cell_comment."</b></td>";
+    print "<td><b>".WEB_cell_description."</b></td>";
     print "<td><input type=submit name=editfilter value=".WEB_btn_save."></td>";
     print "</tr>";
     print "<tr>";
     print "<td align=left><input type=text name=f_name value='".$filter['name']."'></td>";
-    print "<td ><input type=text name=f_comment value='".$filter['comment']."'></td>";
+    print "<td ><input type=text name=f_description value='".$filter['description']."'></td>";
     print "<td ><input type=text name=f_dst value='".$filter['dst']."'></td>";
     print "</tr>";
     print "</table>";

+ 69 - 47
html/admin/filters/editgroup.php

@@ -3,71 +3,93 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/idfilter.php");
 
-if (isset($_POST["editgroup"])) {
-    $new['group_name'] = $_POST["f_group_name"];
-    $new['instance_id'] = $_POST["f_instance_id"]*1;
-    $new['comment'] = $_POST["f_group_comment"];
-    update_record($db_link, "Group_list", "id='$id'", $new);
+$group = get_record_sql($db_link, "SELECT * FROM group_list WHERE id=?", [ $id ]);
+
+// Редактирование группы
+if (getPOST("editgroup") !== null) {
+    $new = [
+        'group_name'    => trim(getPOST("f_group_name", null, $group['group_name'])),
+        'instance_id'   => (int)getPOST("f_instance_id", null, 1),
+        'description'   => trim(getPOST("f_group_description", null, ''))
+    ];
+    update_record($db_link, "group_list", "id = ?", $new, [$id]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["addfilter"])) {
-    $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'");
-    if (empty($max_record)) {
-        $forder = 1;
-    } else {
-        $forder = $max_record["morder"] * 1 + 1;
+// Добавление фильтра в группу
+if (getPOST("addfilter") !== null) {
+    $filter_id = (int)getPOST("newfilter", null, 0);
+    
+    if ($filter_id > 0) {
+        $max_record = get_record_sql($db_link, "SELECT MAX(G.rule_order) as morder FROM group_filters AS G WHERE G.group_id = ?", [$id]);
+        $forder = (!empty($max_record) && isset($max_record['morder'])) 
+            ? ((int)$max_record['morder'] + 1) 
+            : 1;
+
+        $new = [
+            'group_id'     => $id,
+            'filter_id'    => $filter_id,
+            'rule_order'   => $forder,
+            'action'       => 1
+        ];
+        insert_record($db_link, "group_filters", $new);
     }
-    $new['group_id'] = $id;
-    $new['filter_id'] = $filter_id;
-    $new['order'] = $forder;
-    $new['action'] = 1;
-    insert_record($db_link, "Group_filters", $new);
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["removefilter"])) {
-    $f_group_filter = $_POST["f_group_filter"];
-    foreach ($f_group_filter as $key => $val) {
-        if (!empty($val)) {
-            delete_record($db_link, "Group_filters", "id=" . $val * 1);
+// Удаление фильтров из группы
+if (getPOST("removefilter") !== null) {
+    $f_group_filter = getPOST("f_group_filter", null, []);
+    
+    if (!empty($f_group_filter) && is_array($f_group_filter)) {
+        foreach ($f_group_filter as $val) {
+            $val = trim($val);
+            if ($val !== '') {
+                delete_record($db_link, "group_filters", "id = ?", [(int)$val]);
+            }
         }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["updateFilters"])) {
-    if (!empty($_POST["f_group_filter"])) {
-        $f_group_filter = $_POST["f_group_filter"];
+// Обновление порядка и действий фильтров
+if (getPOST("updateFilters") !== null) {
+    $f_group_filter = getPOST("f_group_filter", null, []);
+    
+    if (!empty($f_group_filter) && is_array($f_group_filter)) {
+        $f_ord    = getPOST("f_ord",    null, []);
+        $f_action = getPOST("f_action", null, []);
+        
         LOG_DEBUG($db_link, "Update filters for group id: " . $id);
-        for ($i = 0; $i < count($f_group_filter); ++$i) {
-            $group_filter_id = $f_group_filter[$i];
-            if (empty($_POST["f_ord"][$group_filter_id])) {
-                $new['order'] = $i;
-            } else {
-                $new['order'] = $_POST["f_ord"][$group_filter_id] * 1;
-            }
-            if (empty($_POST["f_action"][$group_filter_id])) {
-                $new['action'] = 0;
-            } else {
-                $new['action'] = $_POST["f_action"][$group_filter_id] * 1;
-            }
-            if (!empty($new)) {
-                update_record($db_link, "Group_filters", "id=" . $group_filter_id, $new);
-            }
+        
+        foreach ($f_group_filter as $i => $group_filter_id) {
+            $group_filter_id = (int)$group_filter_id;
+            if ($group_filter_id <= 0) continue;
+            
+            $new = [
+                'rule_order' => isset($f_ord[$group_filter_id]) 
+                    ? (int)$f_ord[$group_filter_id] 
+                    : $i,
+                'action'     => isset($f_action[$group_filter_id]) 
+                    ? (int)$f_action[$group_filter_id] 
+                    : 0
+            ];
+            
+            update_record($db_link, "group_filters", "id = ?", $new, [$group_filter_id]);
         }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
 unset($_POST);
 
-$group = get_record_sql($db_link, "SELECT * FROM Group_list WHERE id=" . $id);
 
 print_filters_submenu($page_url);
 
@@ -85,8 +107,8 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
                 <td class='data' align=right><input type="submit" name="editgroup" value="<?php echo WEB_btn_save; ?>"></td>
             </tr>
             <tr>
-                <td><?php echo WEB_cell_comment; ?></td>
-                <td class='data'><input type="text" name="f_group_comment" value="<?php echo $group['comment']; ?>"></td>
+                <td><?php echo WEB_cell_description; ?></td>
+                <td class='data'><input type="text" name="f_group_description" value="<?php echo $group['description']; ?>"></td>
                 <td class='data'></td>
             </tr>
             <tr>
@@ -107,12 +129,12 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
             </tr>
 
             <?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";
-            $flist = get_records_sql($db_link, $sSQL);
+            $sSQL = "SELECT G.id, G.filter_id, F.name, G.rule_order, G.action, F.description FROM group_filters G, filter_list F WHERE F.id=G.filter_id and group_id=? ORDER BY G.rule_order";
+            $flist = get_records_sql($db_link, $sSQL, [ $id ]);
             foreach ($flist as $row) {
                 print "<tr align=center>\n";
                 print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_group_filter[] value=" . $row['id'] . "></td>\n";
-                print "<td class=\"data\" align=left><input type=text name=f_ord[" . $row['id'] . "] value=" . $row['order'] . " size=4 ></td>\n";
+                print "<td class=\"data\" align=left><input type=text name=f_ord[" . $row['id'] . "] value=" . $row['rule_order'] . " size=4 ></td>\n";
                 print "<td class=\"data\" align=left><a href=editfilter.php?id=" . $row['filter_id'] . ">" . $row['name'] . "</a></td>\n";
                 $cl = "data";
                 if ($row['action']) {
@@ -123,7 +145,7 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
                 print "<td class=" . $cl . ">";
                 print_action_select('f_action[' . $row['id'] . ']', $row['action']);
                 print "</td>";
-                print "<td colspan=2 class=\"data\" align=left>" . $row['comment'] . "</a></td>\n";
+                print "<td colspan=2 class=\"data\" align=left>" . $row['description'] . "</a></td>\n";
                 print "</tr>";
             }
             ?>

+ 37 - 18
html/admin/filters/groups.php

@@ -2,27 +2,46 @@
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
 
-if (isset($_POST["create"])) {
-    $fname = $_POST["newgroup"];
-    if ($fname) {
-        $new['group_name'] = $fname;
-        $new_id = insert_record($db_link, "Group_list", $new);
-        header("location: editgroup.php?id=$new_id");
-        exit;
+// Создание новой группы
+if (getPOST("create") !== null) {
+    $fname = trim(getPOST("newgroup", null, ''));
+    
+    if ($fname !== '') {
+        $new_id = insert_record($db_link, "group_list", ['group_name' => $fname]);
+        if ($new_id) {
+            header("Location: editgroup.php?id=$new_id");
+            exit;
+        }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["remove"])) {
-    $fgid = $_POST["fid"];
-    foreach ($fgid as $key => $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);
+// Удаление групп
+if (getPOST("remove") !== null) {
+    $fgid = getPOST("fid", null, []);
+    
+    if (!empty($fgid) && is_array($fgid)) {
+        foreach ($fgid as $val) {
+            $val = trim($val);
+            if ($val === '') continue;
+            
+            // Сброс привязки в user_auth
+            update_records($db_link, "user_auth", 
+                "deleted = 0 AND filter_group_id = ?", 
+                ['filter_group_id' => 0, 'changed' => 1], 
+                [$val]
+            );
+            
+            // Удаление связей
+            delete_records($db_link, "group_filters", "group_id = ?", [$val]);
+            
+            // Удаление самой группы
+            delete_records($db_link, "group_list", "id = ?", [$val]);
         }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
@@ -40,19 +59,19 @@ print_filters_submenu($page_url);
                 <td><b>Id</b></td>
                 <td width=200><b><?php echo WEB_cell_name; ?></b></td>
                 <td ><b><?php echo WEB_submenu_filter_instance; ?></b></td>
-                <td width=200><b><?php echo WEB_cell_comment; ?></b></td>
+                <td width=200><b><?php echo WEB_cell_description; ?></b></td>
                 <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
             </tr>
             <?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) {
-		$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 "<td class=\"data\" style='padding:0'><input type=checkbox name=fid[] value=" . $row["id"] . "></td>\n";
                 print "<td class=\"data\" ><input type=\"hidden\" name=\"" . $row["id"] . "\" value=" . $row["id"] . ">" . $row["id"] . "</td>\n";
                 print "<td class=\"data\"><a href=editgroup.php?id=" . $row["id"] . ">" . $row["group_name"] . "</a></td>\n";
                 print "<td class=\"data\">". $filter_instance["name"]."</td>\n";
-                print "<td class=\"data\">" . $row["comment"] . "</td>\n";
+                print "<td class=\"data\">" . $row["description"] . "</td>\n";
                 print "<td></td></tr>";
             }
             ?>

+ 41 - 25
html/admin/filters/index.php

@@ -2,32 +2,48 @@
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
 
-if (isset($_POST["create"])) {
-    $fname = $_POST["newfilter"];
-    $ftype = 0;
-    if (isset($_POST['filter_type'])) {
-        $ftype = $_POST["filter_type"] * 1;
-    }
-    if (isset($fname)) {
-        $new['name'] = $fname;
-        $new['type'] = $ftype;
-        $new_id = insert_record($db_link, "Filter_list", $new);
-        header("Location: editfilter.php?id=$new_id");
-        exit;
+// Создание нового фильтра
+if (getPOST("create") !== null) {
+    $fname = trim(getPOST("newfilter", null, ''));
+    $ftype = (int)getPOST("filter_type", null, 0);
+    
+    if ($fname !== '') {
+        $new_id = insert_record($db_link, "filter_list", [
+            'name'         => $fname,
+            'filter_type'  => $ftype
+        ]);
+        
+        if ($new_id) {
+            header("Location: editfilter.php?id=$new_id");
+            exit;
+        }
     }
+    
+    header("Location: " . $_SERVER["REQUEST_URI"]);
+    exit;
 }
 
-if (isset($_POST["remove"])) {
-    $fid = $_POST["fid"];
-    foreach ($fid as $key => $val) {
-        if ($val) {
-            run_sql($db_link, "DELETE FROM Group_filters WHERE filter_id=" . $val);
-            delete_record($db_link, "Filter_list", "id=$val");
+// Удаление фильтров
+if (getPOST("remove") !== null) {
+    $fid = getPOST("fid", null, []);
+    
+    if (!empty($fid) && is_array($fid)) {
+        foreach ($fid as $val) {
+            $val = trim($val);
+            if ($val === '') continue;
+            
+            // Удаляем из связей
+            delete_records($db_link, "group_filters", "filter_id = ?", [(int)$val]);
+            
+            // Удаляем сам фильтр
+            delete_record($db_link, "filter_list", "id = ?", [(int)$val]);
         }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
+
 unset($_POST);
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
 print_filters_submenu($page_url);
@@ -44,18 +60,18 @@ print_filters_submenu($page_url);
                 <td><b><?php echo WEB_traffic_dest_address; ?></b></td>
                 <td><b><?php echo WEB_traffic_dst_port; ?></b></td>
                 <td><b><?php echo WEB_traffic_src_port; ?></b></td>
-                <td><b><?php echo WEB_cell_comment; ?></b></td>
+                <td><b><?php echo WEB_cell_description; ?></b></td>
                 <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
             </tr>
             <?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) {
                 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\" ><input type=hidden name=\"id\" value=" . $row['id'] . ">" . $row['id'] . "</td>\n";
                 print "<td class=\"data\" align=left><a href=editfilter.php?id=" . $row['id'] . ">" . $row['name'] . "</a></td>\n";
-                if (empty($row['comment'])) {
-                    $row['comment'] = '';
+                if (empty($row['description'])) {
+                    $row['description'] = '';
                 }
                 if (empty($row['proto'])) {
                     $row['proto'] = '';
@@ -69,20 +85,20 @@ print_filters_submenu($page_url);
                 if (empty($row['srcport'])) {
                     $row['srcport'] = '';
                 }
-                if ($row['type'] == 0) {
+                if ($row['filter_type'] == 0) {
                     print "<td class=\"data\">IP фильтр</td>\n";
                     print "<td class=\"data\">" . $row['proto'] . "</td>\n";
                     print "<td class=\"data\">" . $row['dst'] . "</td>\n";
                     print "<td class=\"data\">" . $row['dstport'] . "</td>\n";
                     print "<td class=\"data\">" . $row['srcport'] . "</td>\n";
-                    print "<td class=\"data\">" . $row['comment'] . "</td>\n";
+                    print "<td class=\"data\">" . $row['description'] . "</td>\n";
                 } else {
                     print "<td class=\"data\">Name фильтр</td>\n";
                     print "<td class=\"data\"></td>\n";
                     print "<td class=\"data\">" . $row['dst'] . "</td>\n";
                     print "<td class=\"data\"></td>\n";
                     print "<td class=\"data\"></td>\n";
-                    print "<td class=\"data\">" . $row['comment'] . "</td>\n";
+                    print "<td class=\"data\">" . $row['description'] . "</td>\n";
                 }
                 print "<td></td></tr>";
             }

+ 68 - 29
html/admin/filters/instances.php

@@ -2,46 +2,85 @@
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
-if (isset($_POST['save'])) {
-    $len = is_array($_POST['f_id']) ? count($_POST['f_id']) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $save_id = intval($_POST['f_id'][$i]);
-        $len_all = is_array($_POST['r_id']) ? count($_POST['r_id']) : 0;
-        for ($j = 0; $j < $len_all; $j ++) {
-            if (intval($_POST['r_id'][$j]) != $save_id) { continue; }
-            $id = intval($_POST['r_id'][$j]);
-            $new['name'] = trim($_POST['f_name'][$j]);
-            $new['comment'] = trim($_POST['f_comment'][$j]);
-            update_record($db_link, "filter_instances", "id='$id'", $new);
+// Сохранение изменений
+if (getPOST("save") !== null) {
+    $f_ids = getPOST("f_id", null, []);
+    $r_ids = getPOST("r_id", null, []);
+    $f_names = getPOST("f_name", null, []);
+    $f_descriptions = getPOST("f_description", null, []);
+    if (is_array($f_ids) && is_array($r_ids)) {
+        foreach ($f_ids as $save_id) {
+            $save_id = (int)$save_id;
+            if ($save_id <= 0) continue;
+
+            $idx = array_search($save_id, $r_ids, true);
+            if ($idx === false) continue;
+
+            $new = [
+                'name'        => trim($f_names[$idx] ?? ''),
+                'description' => trim($f_descriptions[$idx] ?? '')
+            ];
+
+            update_record($db_link, "filter_instances", "id = ?", $new, [$save_id]);
         }
     }
+
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["create"])) {
-    $instance_name = trim($_POST["new_instance"]);
-    if (!empty($instance_name)) {
-        $instance['name'] = $instance_name;
-        insert_record($db_link, "filter_instances", $instance);
+// Создание нового экземпляра
+if (getPOST("create") !== null) {
+    $instance_name = trim(getPOST("new_instance", null, ''));
+    
+    if ($instance_name !== '') {
+        insert_record($db_link, "filter_instances", ['name' => $instance_name]);
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["remove"])) {
-    $len = is_array($_POST['r_id']) ? count($_POST['r_id']) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $id = intval($_POST['r_id'][$i]);
-        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);
-	    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']);
-		}
-            delete_record($db_link, "filter_instances", "id=" . $id * 1);
+// Удаление экземпляров
+if (getPOST("remove") !== null) {
+    $r_ids = getPOST("r_id", null, []);
+    
+    if (is_array($r_ids)) {
+        foreach ($r_ids as $id) {
+            $id = (int)$id;
+            if ($id <= 1) continue; // защищаем ID <= 1
+            
+            // Находим все группы, использующие этот instance_id
+            $deleted_groups = get_records_sql($db_link, 
+                "SELECT id FROM group_list WHERE instance_id > 1 AND instance_id = ?", 
+                [$id]
+            );
+            
+            if (!empty($deleted_groups)) {
+                foreach ($deleted_groups as $d_group) {
+                    $group_id = (int)($d_group['id'] ?? 0);
+                    if ($group_id <= 0) continue;
+                    
+                    // Сбрасываем привязку в user_auth
+                    update_records($db_link, "user_auth", 
+                        "deleted = 0 AND filter_group_id = ?", 
+                        ['filter_group_id' => 0, 'changed' => 1], 
+                        [$group_id]
+                    );
+
+                    // Удаление связей
+                    delete_records($db_link, "group_filters", "group_id = ?", [$group_id]);
+
+                    // Удаляем группу
+                    delete_record($db_link, "group_list", "id = ?", [$group_id]);
+                }
+            }
+            
+            // Удаляем сам экземпляр
+            delete_record($db_link, "filter_instances", "id = ?", [$id]);
         }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
@@ -57,7 +96,7 @@ print_filters_submenu($page_url);
 	<td><input type="checkbox" onClick="checkAll(this.checked);"></td>
 	<td><b>Id</b></td>
 	<td><b><?php echo WEB_group_instance_name; ?></b></td>
-	<td><b><?php echo WEB_cell_comment; ?></b></td>
+	<td><b><?php echo WEB_cell_description; ?></b></td>
 	<td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
         <?php print "<td><input type=\"submit\" name=\"save\" value='".WEB_btn_save."'></td>"; ?>
 </tr>
@@ -68,7 +107,7 @@ foreach ($t_instance as $row) {
     print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='".$row['id']."'></td>";
     print "<td class=\"data\"><input type=\"hidden\" name='r_id[]' value='".$row['id']."'>".$row['id']."</td>";
     print "<td class=\"data\"><input type=\"text\" name='f_name[]' value='".$row['name']."'></td>";
-    print "<td class=\"data\"><input type=\"text\" name='f_comment[]' value='".$row['comment']."'></td>";
+    print "<td class=\"data\"><input type=\"text\" name='f_description[]' value='".$row['description']."'></td>";
     print "<td colspan=2 class=\"data\"></td>";
     print "</tr>";
 }

+ 120 - 55
html/admin/groups/edit_group.php

@@ -3,65 +3,131 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER["DOCUMENT_ROOT"]."/inc/idfilter.php");
 
-if (isset($_POST['save'])) {
-        $new['ou_name'] = $_POST['f_group_name'];
-        $new['default_users'] = $_POST['f_default']*1;
-        $new['default_hotspot'] = $_POST['f_default_hotspot']*1;
-        $new['nagios_dir'] = $_POST['f_nagios'];
-        $new['nagios_host_use'] = $_POST['f_nagios_host'];
-        $new['nagios_ping'] = $_POST['f_nagios_ping'];
-        $new['nagios_default_service'] = $_POST['f_nagios_service'];
-        $new['queue_id']= $_POST['f_queue_id']*1;
-        $new['filter_group_id']= $_POST['f_filter_group_id']*1;
-        $new['enabled']= $_POST['f_enabled']*1;
-        $new['dynamic']= $_POST['f_dynamic']*1;
-        if ($new['dynamic']) {
-            $tmp_life_duration = str_replace(',', '.',$_POST['f_life_duration']*1);
-            if (!empty($tmp_life_duration) and is_numeric($tmp_life_duration)) { $new['life_duration'] = $tmp_life_duration; }
-            } else { $new['life_duration']=0; }
-        if ($new['default_users'] == TRUE) { run_sql($db_link,"UPDATE OU set default_users=0 WHERE id!='{$id}'"); }
-        if ($new['default_hotspot'] == TRUE) { run_sql($db_link,"UPDATE OU set default_hotspot=0 WHERE id!='{$id}'"); }
-        update_record($db_link, "OU", "id='{$id}'", $new);
-        header("Location: " . $_SERVER["REQUEST_URI"]);
-	exit;
-	}
+$ou_info = get_record_sql($db_link,'SELECT * FROM ou WHERE id=?', [$id]);
 
-if (isset($_POST["s_remove"])) {
-    $s_id = $_POST["s_id"];
-    foreach ($s_id as $key => $val) {
-        if (isset($val)) {
-            LOG_INFO($db_link, "Remove rule id: $val ".dump_record($db_link,'auth_rules','id='.$val));
-            delete_record($db_link, "auth_rules", "id=" . $val);
-        }
+// Сохранение настроек OU
+if (getPOST("save") !== null) {
+    $new = [
+        'ou_name'                => trim(getPOST("f_group_name", null, $ou_info['ou_name'])),
+        'default_users'          => (int)getPOST("f_default", null, 0),
+        'default_hotspot'        => (int)getPOST("f_default_hotspot", null, 0),
+        'nagios_dir'             => trim(getPOST("f_nagios", null, '')),
+        'nagios_host_use'        => trim(getPOST("f_nagios_host", null, '')),
+        'nagios_ping'            => trim(getPOST("f_nagios_ping", null, 0)),
+        'nagios_default_service' => trim(getPOST("f_nagios_service", null, '')),
+        'queue_id'               => (int)getPOST("f_queue_id", null, 0),
+        'filter_group_id'        => (int)getPOST("f_filter_group_id", null, 0),
+        'enabled'                => (int)getPOST("f_enabled", null, 0),
+        'dynamic'                => (int)getPOST("f_dynamic", null, 0)
+    ];
+
+    // Обработка life_duration
+    if ($new['dynamic']) {
+        $tmp_life_duration = str_replace(',', '.', getPOST("f_life_duration", null, 0));
+        $new['life_duration'] = (!empty($tmp_life_duration) && is_numeric($tmp_life_duration)) 
+            ? (float)$tmp_life_duration 
+            : 0;
+    } else {
+        $new['life_duration'] = 0;
+    }
+
+    // Сброс флагов по умолчанию
+    if ($new['default_users']) {
+        update_records($db_link, "ou", "id != ?", ['default_users' => 0], [$id]);
     }
+    if ($new['default_hotspot']) {
+        update_records($db_link, "ou", "id != ?", ['default_hotspot' => 0], [$id]);
+    }
+
+    update_record($db_link, "ou", "id = ?", $new, [$id]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST['s_save'])) {
-    $len = is_array($_POST['s_id']) ? count($_POST['s_id']) : 0;
-    for ($i = 0; $i < $len; $i ++) {
-        $save_id = intval($_POST['s_id'][$i]);
-        $len_all = is_array($_POST['n_id']) ? count($_POST['n_id']) : 0;
-        for ($j = 0; $j < $len_all; $j ++) {
-            if (intval($_POST['n_id'][$j]) != $save_id) { continue; }
-            $new['type'] = $_POST['s_type'][$j];
-            $new['rule'] = trim($_POST['s_rule'][$j]);
-            $new['comment'] = trim($_POST['s_comment'][$j]);
-            update_record($db_link, "auth_rules", "id='{$save_id}'", $new);
+// Удаление правил авторизации
+if (getPOST("s_remove") !== null) {
+    $s_id = getPOST("s_id", null, []);
+    
+    if (!empty($s_id) && is_array($s_id)) {
+        foreach ($s_id as $val) {
+            $val = trim($val);
+            if ($val === '') continue;
+            
+            delete_record($db_link, "auth_rules", "id = ?", [(int)$val]);
         }
     }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-if (isset($_POST["s_create"])) {
-    $new_rule = $_POST["s_new_rule"];
-    if (!empty($new_rule)) {
-        $new['type'] = $_POST["s_new_type"];
-        $new['rule'] = $new_rule;
-        $new['ou_id'] = $id;
-        LOG_INFO($db_link, "Create new rule $new_rule for ou_id: $id");
+// Сохранение изменений в правилах
+if (getPOST("s_save") !== null) {
+    $s_ids = getPOST("s_id", null, []);
+    $n_ids = getPOST("n_id", null, []);
+    $s_types = getPOST("s_type", null, []);
+    $s_rules = getPOST("s_rule", null, []);
+    $s_descriptions = getPOST("s_description", null, []);
+
+    if (is_array($s_ids) && is_array($n_ids)) {
+        // Преобразуем ID в целые числа
+        $n_ids = array_map('intval', $n_ids);
+        $s_ids = array_map('intval', $s_ids);
+        foreach ($s_ids as $save_id) {
+            if ($save_id <= 0) continue;
+            $idx = array_search($save_id, $n_ids, true);
+            if ($idx === false) continue;
+            // Получаем тип правила
+            $rule_type = (int)($s_types[$idx] ?? 3);
+            // Получаем и очищаем правило
+            $raw_rule = trim($s_rules[$idx] ?? '');
+            if ($raw_rule === '') continue;
+            $new_rule = $raw_rule;
+            // Валидация в зависимости от типа
+            if ($rule_type == 1) {
+                // IP-адрес
+                if (!checkValidIp($new_rule)) {
+                    continue; // пропускаем невалидный IP
+                }
+            } elseif ($rule_type == 2) {
+                // MAC-адрес
+                $normalized_mac = MayBeMac($new_rule);
+                if ($normalized_mac === null) {
+                    continue; // пропускаем невалидный MAC
+                }
+                $new_rule = $normalized_mac;
+            }
+            // Для других типов (3 и т.д.) — без валидации
+            $new = [
+                'rule_type'   => $rule_type,
+                'rule'        => $new_rule,
+                'description' => trim($s_descriptions[$idx] ?? '')
+            ];
+            update_record($db_link, "auth_rules", "id = ?", $new, [$save_id]);
+        }
+    }
+    header("Location: " . $_SERVER["REQUEST_URI"]);
+    exit;
+}
+// Создание нового правила
+if (getPOST("s_create") !== null) {
+    $new_rule = trim(getPOST("s_new_rule", null, ''));
+    if ($new_rule !== '') {
+        $rule_type  = (int)getPOST("s_new_type", null, 3);
+        if ($rule_type == 1 and !checkValidIp($new_rule)) {
+                header("Location: " . $_SERVER["REQUEST_URI"]);
+                exit;
+                }
+        if ($rule_type == 2 and MayBeMac($new_rule)==null) {
+                header("Location: " . $_SERVER["REQUEST_URI"]);
+                exit;
+                }
+        if ($rule_type == 2) { $new_rule = MayBeMac($new_rule); }
+        $new = [
+            'rule_type'    => $rule_type,
+            'rule'    => $new_rule,
+            'ou_id'   => $id
+        ];
         insert_record($db_link, "auth_rules", $new);
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
@@ -84,7 +150,7 @@ fix_auth_rules($db_link);
 <td><b><?php print WEB_cell_dynamic; ?></b></td>
 </tr>
 <?php
-$ou_info = get_record_sql($db_link,'SELECT * FROM OU WHERE id='.$id);
+
 print "<tr align=center>\n";
 print "<td colspan=2 class=\"data\"><input type=\"text\" name='f_group_name' value='{$ou_info['ou_name']}' style=\"width:95%;\"></td>\n";
 if ($ou_info['default_users']) { $cl = "up"; } else { $cl="data"; }
@@ -130,19 +196,19 @@ if (!$ou_info['dynamic']) { print "disabled"; }; print " style=\"width:35%;\" ><
     <td width=30><b>id</b></td>
     <td><b><?php echo WEB_cell_type; ?></b></td>
     <td><b><?php echo WEB_ou_rule; ?></b></td>
-    <td><b><?php echo WEB_cell_comment; ?></b></td>
+    <td><b><?php echo WEB_cell_description; ?></b></td>
     <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="s_remove" value="<?php echo WEB_btn_delete; ?>"></td>
-    <?php print "<td><button id='s_save' name='s_save'>".WEB_btn_save."</button></td>"; ?>
+    <?php print "<td><button id='s_save' name='s_save' value='s_save'>".WEB_btn_save."</button></td>"; ?>
 </tr>
 <?php
-$t_auth_rules = get_records($db_link,'auth_rules',"ou_id=$id ORDER BY id");
+$t_auth_rules = get_records_sql($db_link,"SELECT * FROM auth_rules WHERE ou_id=? ORDER BY id", [ $id ]);
 foreach ( $t_auth_rules as $row ) {
     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\"><input type=\"hidden\" name='n_id[]' value='{$row['id']}'>{$row['id']}</td>\n";
-    print "<td class=\"data\">"; print_qa_rule_select("s_type[]","{$row['type']}"); print "</td>\n";
+    print "<td class=\"data\">"; print_qa_rule_select("s_type[]","{$row['rule_type']}"); print "</td>\n";
     print "<td class=\"data\"><input type=\"text\" name='s_rule[]' value='{$row['rule']}'></td>\n";
-    print "<td class=\"data\"><input type=\"text\" name='s_comment[]' value='{$row['comment']}'></td>\n";
+    print "<td class=\"data\"><input type=\"text\" name='s_description[]' value='{$row['description']}'></td>\n";
     print "<td colspan=2 class=\"data\"></td>\n";
     print "</tr>\n";
 }
@@ -170,6 +236,5 @@ document.getElementById('f_dynamic').addEventListener('change', function(event)
 </script>
 
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>
-

+ 26 - 18
html/admin/groups/index.php

@@ -2,29 +2,37 @@
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
-if (isset($_POST["remove"])) {
-    $fid = $_POST["f_id"];
-    foreach ($fid as $key => $val) {
-        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, "DELETE FROM auth_rules WHERE ou_id=$val");
-            delete_record($db_link, "OU", "id=" . $val);
-            }
+// Удаление OU
+if (getPOST("remove") !== null) {
+    $fid = getPOST("f_id", null, []);
+    
+    if (!empty($fid) && is_array($fid)) {
+        foreach ($fid as $val) {
+            $val = (int)$val;
+            if ($val <= 0) continue;
+            // Обнуляем привязки в user_list
+            update_records($db_link, "user_list", "ou_id = ?", ['ou_id' => 0], [$val]);
+            // Обнуляем привязки в user_auth
+            update_records($db_link, "user_auth", "ou_id = ?", ['ou_id' => 0], [$val]);
+            // Удаляем правила авторизации
+            delete_records($db_link, "auth_rules", "ou_id = ?", [$val]);
+            // Удаляем сам OU
+            delete_record($db_link, "ou", "id = ?", [$val]);
         }
+    }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
-    }
+}
 
-if (isset($_POST["create"])) {
-    $ou_name = $_POST["new_ou"];
-    if (isset($ou_name)) {
-        $new['ou_name'] = $ou_name;
-        insert_record($db_link, "OU", $new);
-        }
+// Создание нового OU
+if (getPOST("create") !== null) {
+    $ou_name = trim(getPOST("new_ou", null, ''));
+    if ($ou_name !== '') {
+        insert_record($db_link, "ou", ['ou_name' => $ou_name]);
+    }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
-    }
+}
 
 unset($_POST);
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
@@ -44,7 +52,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 </td>
 </tr>
 <?php
-$t_ou = get_records($db_link,'OU','TRUE ORDER BY ou_name');
+$t_ou = get_records_sql($db_link,'SELECT * FROM ou ORDER BY ou_name');
 foreach ($t_ou as $row) {
     print "<tr align=center>\n";
     print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='{$row['id']}'></td>\n";

+ 28 - 20
html/admin/iplist/auto_rules.php

@@ -5,14 +5,20 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/rulesfilter.php");
 
-if (isset($_POST["removeRule"])) {
-    $r_id = $_POST["f_id"];
-    foreach ($r_id as $key => $val) {
-        if ($val) { delete_record($db_link, "auth_rules", "id=".$val); }
+if (getPOST("removeRule") !== null) {
+    $r_id = getPOST("f_id", null, []);
+    if (!empty($r_id) && is_array($r_id)) {
+        foreach ($r_id as $val) {
+            $val = trim($val);
+            if ($val !== '') {
+                delete_record($db_link, "auth_rules", "id = ?", [(int)$val]);
+            }
         }
+    }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
-    }
+}
 
 print_ip_submenu($page_url);
 ?>
@@ -44,16 +50,17 @@ print_ip_submenu($page_url);
 <?php
 
 $target_filter='';
+$params=[];
 if ($rule_target>0) {
     if ($rule_target==1) { $target_filter = ' AND user_id>0'; }
     if ($rule_target==2) { $target_filter = ' AND ou_id>0'; }
     }
 
 $type_filter='';
-if ($rule_type>0) { $type_filter = ' AND `type`='.$rule_type; }
+if ($rule_type>0) { $type_filter = ' AND type=?'; $params[]=$rule_type; }
 
 $rule_filter='';
-if (!empty($f_rule)) { $rule_filter = ' AND `rule` LIKE "'.$f_rule.'%"'; }
+if (!empty($f_rule)) { $rule_filter = ' AND rule LIKE ?'; $params[]=$f_rule.'%'; }
 
 $rule_filters = '';
 if (!empty($target_filter) or !empty($type_filter) or !empty($rule_filter)) {
@@ -62,28 +69,29 @@ if (!empty($target_filter) or !empty($type_filter) or !empty($rule_filter)) {
 
 fix_auth_rules($db_link);
 $countSQL="SELECT Count(*) FROM auth_rules $rule_filters";
-$res = mysqli_query($db_link, $countSQL);
-$count_records = mysqli_fetch_array($res);
-$total=ceil($count_records[0]/$displayed);
+$count_records = get_single_field($db_link,$countSQL, $params);
+$total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed;
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 ?>
 
-
 <table class="data">
 <tr align="center">
 <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
 <td><b><?php echo WEB_cell_type; ?></b></td>
 <td><b><?php echo WEB_ou_rule; ?></b></td>
 <td colspan=2><b><?php echo WEB_rules_target; ?></b></td>
-<td><b><?php echo WEB_cell_comment; ?></b></td>
+<td><b><?php echo WEB_cell_description; ?></b></td>
 <td align=right><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="removeRule" value="<?php echo WEB_btn_delete; ?>"></td>
 </tr>
 <?php
-$rulesSQL = "SELECT * FROM auth_rules $rule_filters ORDER BY id LIMIT $start,$displayed";
-$t_auth_rules = get_records_sql($db_link,$rulesSQL);
+$rulesSQL = "SELECT * FROM auth_rules $rule_filters ORDER BY id LIMIT ? OFFSET ?";
+$params[]=$displayed;
+$params[]=$start;
+
+$t_auth_rules = get_records_sql($db_link,$rulesSQL, $params);
 foreach ( $t_auth_rules as $row ) {
     print "<tr align=center>\n";
     print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value=".$row["id"]." ></td>\n";
@@ -95,15 +103,15 @@ foreach ( $t_auth_rules as $row ) {
     print "<td class=\"data\">".$row['rule']."</td>\n";
     print "<td colspan=2 class=\"data\" align=left>";
     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($row['ou_id'])) {
-	$ou_info=get_record_sql($db_link,"SELECT * FROM OU WHERE id=".$row['ou_id']);
+	$ou_info=get_record_sql($db_link,"SELECT * FROM ou WHERE id=?", [ $row['ou_id'] ]);
 	if (!empty($ou_info)) { print "Group: &nbsp"; print_url($ou_info['ou_name'],'/admin/groups/edit_group.php?id='.$ou_info['id']); }
 	}
     print "</td>";
-    print "<td class=\"data\" colspan=2>".$row['comment']."</td>\n";
+    print "<td class=\"data\" colspan=2>".$row['description']."</td>\n";
     print "</tr>\n";
 }
 ?>
@@ -127,6 +135,6 @@ document.getElementById('rows').addEventListener('change', function(event) {
 </script>
 
 <?php
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php"); 
+print_navigation($page_url,$page,$displayed,$count_records,$total);
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php"); 
 ?>

+ 51 - 37
html/admin/iplist/deleted.php

@@ -10,31 +10,42 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/enabledfilter.php");
 
-if (isset($_POST['searchComment'])) { $f_comment = $_POST['searchComment']; }
-if (isset($_GET['searchComment'])) { $f_comment = $_GET['searchComment']; }
-if (!isset($f_comment) and isset($_SESSION[$page_url]['comment'])) { $f_comment=$_SESSION[$page_url]['comment']; }
-if (!isset($f_comment)) { $f_comment=''; }
+// Получаем параметр с использованием сессии (page_url задан)
+$f_description = getParam('searchDescription', $page_url, '');
 
-$_SESSION[$page_url]['comment']=$f_comment;
-
-$sort_table = 'User_auth';
+// Сохраняем в сессию
+$_SESSION[$page_url]['description'] = $f_description;
 
+$sort_table = 'user_auth';
 $sort_url = "<a href=deleted.php?";
 
-if ($rsubnet == 0) { $subnet_filter = ''; } else {
-    $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'];
-    }
+$params = [];
+if ($rsubnet == 0) {
+    $subnet_filter = '';
+} else {
+    $subnet_range = get_subnet_range($db_link, $rsubnet);
+    $subnet_filter = " AND user_auth.ip_int >= ? AND user_auth.ip_int <= ?";
+    $params[] = $subnet_range['start'];
+    $params[] = $subnet_range['stop'];
+}
 
 $ip_list_filter = $subnet_filter;
-
 $ip_where = '';
-if (!empty($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 (empty($ip_where)) { $ip_where=" and (User_auth.comments LIKE '$f_comment' OR User_auth.dhcp_hostname LIKE '$f_comment')"; }
+
+if (!empty($f_description)) {
+    if (checkValidIp($f_description)) {
+        $ip_where = " AND ip = ?";
+        $params[] = $f_description;
+    } elseif (checkValidMac($f_description)) {
+        $ip_where = " AND mac = ?";
+        $params[] = mac_dotted($f_description);
+    } else {
+        $ip_where = " AND (user_auth.description LIKE ? OR user_auth.dhcp_hostname LIKE ?)";
+        $params[] = "%$f_description%";
+        $params[] = "%$f_description%";
+    }
     $ip_list_filter = $ip_where;
-    } 
+    }
 
 print_ip_submenu($page_url);
 
@@ -44,20 +55,19 @@ print_ip_submenu($page_url);
 <br>
 <div>
         <b><?php print WEB_network_subnet; ?> - </b><?php print_subnet_select_office($db_link, 'subnet', $rsubnet); ?>
-        <?php echo WEB_ips_search_full; ?>: &nbsp <input type=text name=searchComment value="<?php print $f_comment; ?>">
+        <?php echo WEB_ips_search_full; ?>: &nbsp <input type=text name=searchDescription value="<?php print $f_description; ?>">
         <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
         <input type="submit" value="<?php echo WEB_btn_show; ?>">
 </div>
 
 <?php
-$countSQL="SELECT Count(*) FROM User_auth WHERE User_auth.deleted = 1 $ip_list_filter";
-$res = mysqli_query($db_link, $countSQL);
-$count_records = mysqli_fetch_array($res);
-$total=ceil($count_records[0]/$displayed);
+$countSQL="SELECT Count(*) FROM user_auth WHERE user_auth.deleted = 1 $ip_list_filter";
+$count_records = get_single_field($db_link,$countSQL, $params);
+$total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed; 
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 ?>
 <br>
 
@@ -65,41 +75,45 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 	<tr>
 		<td align=Center><?php print $sort_url . "sort=ip_int&order=$new_order>" . WEB_cell_ip . "</a>"; ?></td>
 		<td align=Center><?php print $sort_url . "sort=mac&order=$new_order>" . WEB_cell_mac . "</a>"; ?></td>
-		<td align=Center><?php print WEB_cell_comment; ?></td>
+		<td align=Center><?php print WEB_cell_description; ?></td>
 		<td align=Center><?php print WEB_cell_dns_name; ?></td>
-		<td align=Center><?php print $sort_url . "sort=timestamp&order=$new_order>".WEB_cell_created."</a>"; ?></td>
+		<td align=Center><?php print $sort_url . "sort=ts&order=$new_order>".WEB_cell_created."</a>"; ?></td>
 		<td align=Center><?php print $sort_url . "sort=changed_time&order=$new_order>".WEB_cell_deleted."</a>"; ?></td>
 		<td align=Center><?php print $sort_url . "sort=last_found&order=$new_order>".WEB_cell_last_found."</a>"; ?></td>
 	</tr>
 <?php
 
 $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
-ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
-$users = get_records_sql($db_link,$sSQL);
+user_auth.id, user_auth.ip, user_auth.mac, user_auth.description, user_auth.dns_name, user_auth.dhcp_hostname, 
+user_auth.dhcp_time, user_auth.last_found, user_auth.ts, user_auth.changed_time
+FROM user_auth WHERE user_auth.deleted = 1 $ip_list_filter
+ORDER BY $sort_table.$sort_field $order LIMIT ? OFFSET ?";
+
+$params[]=$displayed;
+$params[]=$start;
+
+$users = get_records_sql($db_link,$sSQL, $params);
 foreach ($users as $user) {
-    if (empty($user['last_found']) or $user['last_found'] === '0000-00-00 00:00:00') { $user['last_found'] = ''; }
-    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['last_found']) || is_empty_datetime($user['last_found'])) { $user['last_found'] = ''; }
+    if (empty($user['ts']) || is_empty_datetime($user['ts'])) { $user['ts'] = ''; }
+    if (empty($user['changed_time']) || is_empty_datetime($user['changed_time'])) { $user['changed_time'] = ''; }
     print "<tr align=center>\n";
     $cl = "data";
     print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
     print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
     if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
-        print "<td class=\"$cl\" >".$user['comments']." [" . $user['dhcp_hostname'] . "]</td>\n";
+        print "<td class=\"$cl\" >".$user['description']." [" . $user['dhcp_hostname'] . "]</td>\n";
     } else {
-        print "<td class=\"$cl\" >".$user['comments']."</td>\n";
+        print "<td class=\"$cl\" >".$user['description']."</td>\n";
     }
     print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
-    print "<td class=\"$cl\" >".$user['timestamp']."</td>\n";
+    print "<td class=\"$cl\" >".$user['ts']."</td>\n";
     print "<td class=\"$cl\" >".$user['changed_time']."</td>\n";
     print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
     print "</tr>\n";
 }
 print "</table>\n";
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 ?>
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");

+ 49 - 30
html/admin/iplist/doubles.php

@@ -4,21 +4,38 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/cidrfilter.php");
 
-if (isset($_POST["removeauth"])) {
-    $auth_id = $_POST["f_auth_id"];
-    foreach ($auth_id as $key => $val) {
-        if ($val) { delete_user_auth($db_link,$val); }
+// Удаление записей авторизации
+if (getPOST("removeauth") !== null) {
+    $auth_id = getPOST("f_auth_id", null, []);
+    if (!empty($auth_id) && is_array($auth_id)) {
+        foreach ($auth_id as $val) {
+            $val = trim($val);
+            if ($val !== '') {
+                delete_user_auth($db_link, (int)$val);
+            }
         }
+    }
+    
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
-    }
+}
 
-print_ip_submenu($page_url);
-
-if (empty($rcidr)) { $cidr_filter = ''; } else {
+// Фильтрация по CIDR
+$params = [];
+if (!empty($rcidr)) {
     $cidr_range = cidrToRange($rcidr);
-    if (!empty($cidr_range)) { $cidr_filter = " AND (U.ip_int>=".ip2long($cidr_range[0])." AND U.ip_int<=".ip2long($cidr_range[1]).")"; }
+    if (!empty($cidr_range) && isset($cidr_range[0], $cidr_range[1])) {
+        $cidr_filter = " AND (U.ip_int >= ? AND U.ip_int <= ?)";
+        $params[] = ip2long($cidr_range[0]);
+        $params[] = ip2long($cidr_range[1]);
+    } else {
+        $cidr_filter = '';
     }
+} else {
+    $cidr_filter = '';
+}
+
+print_ip_submenu($page_url);
 
 ?>
 <div id="cont">
@@ -33,15 +50,16 @@ if (empty($rcidr)) { $cidr_filter = ''; } else {
     <td align=Center><?php print WEB_cell_login; ?></td>
     <td align=Center><?php print WEB_cell_ip; ?></td>
     <td align=Center><?php print WEB_cell_mac ; ?></td>
-    <td align=Center><?php print WEB_cell_comment; ?></td>
+    <td align=Center><?php print WEB_cell_description; ?></td>
     <td align=Center><?php print WEB_cell_dns_name; ?></td>
     <td align=Center><?php print WEB_cell_created; ?></td>
     <td align=Center><?php print WEB_cell_last_found; ?></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>
 <?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";
-$users = get_records_sql($db_link,$sSQL);
+$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, $params);
 $f_subnet=NULL;
 $f_mac=NULL;
 $f_id=NULL;
@@ -63,15 +81,16 @@ foreach ($users as $row) {
         //если первая запись не выводилась - выводим на печать
         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";
-            $doubles = get_records_sql($db_link,$dSQL);
+            $dSQL = "SELECT  U.id, U.ip, U.mac, U.arp_found FROM user_auth U WHERE $cidr_filter AND U.deleted=0 AND U.mac=?";
+            $params[]= $f_mac;
+            $doubles = get_records_sql($db_link,$dSQL, $params);
             $f_count = count($doubles);
 
             $f_index++;
-            $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['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'] = ''; }
+            $user = get_record_sql($db_link,"SELECT * FROM user_auth WHERE id=?", [$f_id]);
+            if (empty($user['arp_found']) || is_empty_datetime($user['arp_found'])) { $user['arp_found'] = ''; }
+            if (empty($user['ts']) || is_empty_datetime($user['ts'])) { $user['ts'] = ''; }
+            if (empty($user['changed_time']) || is_empty_datetime($user['changed_time'])) { $user['changed_time'] = ''; }
             print "<tr align=center>\n";
             $cl = "data";
             print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_auth_id[] value=".$user["id"];
@@ -81,23 +100,23 @@ foreach ($users as $row) {
             print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
             print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
             if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
-                print "<td class=\"$cl\" >".$user['comments']." [" . $user['dhcp_hostname'] . "]</td>\n";
+                print "<td class=\"$cl\" >".$user['description']." [" . $user['dhcp_hostname'] . "]</td>\n";
                 } else {
-                print "<td class=\"$cl\" >".$user['comments']."</td>\n";
+                print "<td class=\"$cl\" >".$user['description']."</td>\n";
                 }
             print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
-            print "<td class=\"$cl\" >".$user['timestamp']."</td>\n";
-            print "<td class=\"$cl\" >".$user['arp_found']."</td>\n";
+            print "<td class=\"$cl\" >".$user['ts']."</td>\n";
+            print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
             print "</tr>\n";
             $printed[$f_id] = 1;
             }
         //проверяем текущую запись
         if (!isset($printed[$row['id']])) {
             $f_index++;
-            $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['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'] = ''; }
+            $user = get_record_sql($db_link,"SELECT * FROM user_auth WHERE id=?", [$row['id']]);
+            if (empty($user['arp_found']) || is_empty_datetime($user['arp_found'])) { $user['arp_found'] = ''; }
+            if (empty($user['ts']) || is_empty_datetime($user['ts'])) { $user['ts'] = ''; }
+            if (empty($user['changed_time']) || is_empty_datetime($user['changed_time'])) { $user['changed_time'] = ''; }
             print "<tr align=center>\n";
             $cl = "data";
             print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_auth_id[] value=".$user["id"];
@@ -107,13 +126,13 @@ foreach ($users as $row) {
             print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
             print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
             if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
-                print "<td class=\"$cl\" >".$user['comments']." [" . $user['dhcp_hostname'] . "]</td>\n";
+                print "<td class=\"$cl\" >".$user['description']." [" . $user['dhcp_hostname'] . "]</td>\n";
                 } else {
-                print "<td class=\"$cl\" >".$user['comments']."</td>\n";
+                print "<td class=\"$cl\" >".$user['description']."</td>\n";
                 }
             print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
-            print "<td class=\"$cl\" >".$user['timestamp']."</td>\n";
-            print "<td class=\"$cl\" >".$user['arp_found']."</td>\n";
+            print "<td class=\"$cl\" >".$user['ts']."</td>\n";
+            print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
             print "</tr>\n";
             $printed[$row['id']] = 1;
             }

+ 90 - 56
html/admin/iplist/index.php

@@ -14,36 +14,40 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/dynfilter.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'; }
-if ($sort_field == 'ou_name') { $sort_table = 'OU'; }
+$sort_table = 'user_auth';
+if ($sort_field == 'login') { $sort_table = 'user_list'; }
+if ($sort_field == 'description') { $sort_table = 'user_list'; }
+if ($sort_field == 'ou_name') { $sort_table = 'ou'; }
+
+$params=[];
 
 $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=?"; $params[]=$rou; }
 
 if (empty($rcidr)) { $cidr_filter = ''; } else {
     $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>=? and user_auth.ip_int<=?"; }
+    $params[]=ip2long($cidr_range[0]);
+    $params[]=ip2long($cidr_range[1]);
     }
 
 $enabled_filter='';
 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='';
 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='';
 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']); }
@@ -56,23 +60,33 @@ $f_search=replaceSpecialChars($f_search_str);
 $ip_list_type_filter='';
 if ($ip_type>0) {
     //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
-    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
-    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 = '';
 if (!empty($f_search_str)) {
     $f_ip = normalizeIpAddress($f_search_str);
     if (!empty($f_ip)) { 
-        $ip_where = " and ip_int=inet_aton('" . $f_ip . "') ";
+        $ip_where = " and ip=?";
+        $params[]= $f_ip;
         $f_search_str = $f_ip;
         } else {
-        if (checkValidMac($f_search_str)) { $ip_where =" and mac='" . mac_dotted($f_search_str) ."'"; }
-            else {
-            $ip_where =" and (mac like '" . mac_dotted($f_search) . "%' or login like '".$f_search."%' or comments like '".$f_search."%' or dns_name like '".$f_search."%' or dhcp_hostname like '".$f_search."%')"; 
+        if (checkValidMac($f_search_str)) { 
+    	    $ip_where =" and mac=?"; 
+    	    $params[]= mac_dotted($f_search_str);
+    	    } else {
+            $ip_where =" and (mac LIKE ? or login LIKE ? or user_auth.description LIKE ? or user_list.description LIKE ? or dns_name LIKE ? or dhcp_hostname LIKE ?)";
+            $mac_search = MaybeMac($f_search);
+            if (!empty($mac_search)) { $params[]=MaybeMac($f_search).'%'; } else { $params[]=$f_search_str.'%'; }
+            $params[]=$f_search.'%';
+            $params[]=$f_search.'%';
+            $params[]=$f_search.'%';
+            $params[]=$f_search.'%';
+            $params[]=$f_search.'%';
             }
         }
     }
@@ -135,7 +149,7 @@ print_ip_submenu($page_url);
         <h2 id="modal1Title"><?php print WEB_selection_title; ?></h2>
         <input type="hidden" name="ApplyForAll" value="MassChange">
         <table class="data" align=center>
-        <tr><td><input type=checkbox class="putField" name="e_new_ou" value='1'></td><td align=left><?php print WEB_cell_ou."</td><td align=right>";print_ou_select($db_link, 'a_new_ou', 0); ?></td></tr>
+        <tr><td><input type=checkbox class="putField" name="e_new_ou" value='1'></td><td align=left><?php print WEB_cell_ou."</td><td align=right>";print_ou_set($db_link, 'a_new_ou', 0); ?></td></tr>
         <tr><td><input type=checkbox class="putField" name="e_enabled" value='1'></td><td align=left><?php print WEB_cell_enabled."</td><td align=right>";print_qa_select('a_enabled', 1);?></td></tr>
         <tr><td><input type=checkbox class="putField" name="e_group_id" value='1'></td><td align=left><?php print WEB_cell_filter."</td><td align=right>";print_filter_group_select($db_link, 'a_group_id', 0);?></td></tr>
         <tr><td><input type=checkbox class="putField" name="e_queue_id" value='1'></td><td align=left><?php print WEB_cell_shaper."</td><td align=right>";print_queue_select($db_link, 'a_queue_id', 0);?></td></tr>
@@ -181,20 +195,19 @@ print_ip_submenu($page_url);
 <form id="def" name="def">
 
 <?php
-$countSQL="SELECT Count(*) FROM User_auth
-LEFT JOIN User_list
-ON User_auth.user_id = User_list.id
-LEFT JOIN OU
-ON OU.id=User_list.ou_id
-WHERE User_auth.deleted =0 $ip_list_filter";
-
-$res = mysqli_query($db_link, $countSQL);
-$count_records = mysqli_fetch_array($res);
-$total=ceil($count_records[0]/$displayed);
+$countSQL="SELECT Count(*) FROM user_auth
+LEFT JOIN user_list
+ON user_auth.user_id = user_list.id
+LEFT JOIN ou
+ON ou.id=user_list.ou_id
+WHERE user_auth.deleted =0 $ip_list_filter";
+
+$count_records = get_single_field($db_link,$countSQL, $params);
+$total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed;
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 ?>
 <br>
 
@@ -205,41 +218,45 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
                 <td align=Center><?php print $sort_url . "&sort=login&order=$new_order>" . WEB_cell_login . "</a>"; ?></td>
                 <td align=Center><?php print $sort_url . "&sort=ip_int&order=$new_order>" . WEB_cell_ip . "</a>"; ?></td>
                 <td align=Center><?php print $sort_url . "&sort=mac&order=$new_order>" . WEB_cell_mac . "</a>"; ?></td>
-                <td align=Center><?php print WEB_cell_comment; ?></td>
+                <td align=Center><?php print WEB_cell_description; ?></td>
                 <td align=Center><?php print WEB_cell_dns_name; ?></td>
                 <td align=Center><?php print WEB_cell_filter; ?></td>
                 <td align=Center><?php print WEB_cell_shaper; ?></td>
                 <td align=Center><?php print WEB_cell_traf; ?></td>
                 <td align=Center><?php print WEB_cell_dhcp; ?></td>
                 <td align=Center><?php print WEB_cell_acl; ?></td>
-                <td align=Center><?php print $sort_url . "&sort=arp_found&order=$new_order>Last</a>"; ?></td>
+                <td align=Center><?php print $sort_url . "&sort=arp_found&order=$new_order>Arp/Mac</a>"; ?></td>
                 <td align=Center><?php print WEB_cell_connection; ?></td>
         </tr>
 <?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
-LEFT JOIN OU
-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";
+$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
+ON ou.id=user_list.ou_id
+WHERE user_auth.deleted =0 $ip_list_filter
+ORDER BY $sort_table.$sort_field $order LIMIT ? OFFSET ?";
+
+$params[]=$displayed;
+$params[]=$start;
 
-$users = get_records_sql($db_link,$sSQL);
+$users = get_records_sql($db_link,$sSQL, $params);
 foreach ($users as $user) {
-    if ($user['dhcp_time'] == '0000-00-00 00:00:00') {
+    if (is_empty_datetime($user['dhcp_time'])) {
         $dhcp_str = '';
     } else {
         $dhcp_str = $user['dhcp_time'] . " (" . $user['dhcp_action'] . ")";
     }
-    if ($user['last_found'] == '0000-00-00 00:00:00') { $user['last_found'] = ''; }
-    if ($user['arp_found'] == '0000-00-00 00:00:00') { $user['arp_found'] = ''; }
+    if (is_empty_datetime($user['last_found'])) { $user['last_found'] = ''; }
+    if (is_empty_datetime($user['arp_found'])) { $user['arp_found'] = ''; }
+    if (is_empty_datetime($user['mac_found'])) { $user['mac_found'] = ''; }
     print "<tr align=center>\n";
     $cl = "data";
     if (!$user['enabled']) { $cl = "warn"; }
     if ($user['blocked']) { $cl = "error"; }
-    if (!$user['UEnabled'] or $user['UBlocked']) { $cl = "off"; }
+    if ($user['uenabled'] !== 1 || $user['ublocked'] == 1) { $cl = "off"; }
     print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$user['id']."></td>\n";
     print "<td class=\"$cl\" >".$user['ou_name']."</td>\n";
     if (empty($user['login'])) { $user_name = $user['user_id']; } else { $user_name = $user['login']; }
@@ -247,26 +264,42 @@ foreach ($users as $user) {
     print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
     print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
     if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
-        print "<td class=\"$cl\" width=200 >".$user['comments']." [" . $user['dhcp_hostname'] . "]</td>\n";
+        print "<td class=\"$cl\" width=200 >".$user['description']." [" . $user['dhcp_hostname'] . "]</td>\n";
     } else {
-        print "<td class=\"$cl\" width=200 >".$user['comments']."</td>\n";
+        print "<td class=\"$cl\" width=200 >".$user['description']."</td>\n";
     }
-    print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
+
+    $aliases = get_records_sql($db_link, 'SELECT * FROM user_auth_alias WHERE auth_id=?', [$user['id']]);
+    $dns_display = $user['dns_name'];
+    if ($user["dns_ptr_only"]) { $dns_display.='&nbsp(ptr)'; }
+    if (!empty($aliases)) {
+        $dns_display .= '<hr>';
+        $alias_list = [];
+        foreach ($aliases as $alias) {
+            $alias_list[] = htmlspecialchars($alias['alias'], ENT_QUOTES, 'UTF-8');
+        }
+        $dns_display .= implode('<br>', $alias_list);
+    }
+    print "<td class=\"$cl\" >".$dns_display."</td>\n";
     print "<td class=\"$cl\" >" . get_group($db_link, $user['filter_group_id']) . "</td>\n";
     print "<td class=\"$cl\" >" . get_queue($db_link, $user['queue_id']) . "</td>\n";
     print_td_qa($user['save_traf'],FALSE,$cl);
     print_td_qa($user['dhcp'],FALSE,$cl);
     print "<td class=\"$cl\" >".$user['dhcp_acl']."</td>\n";
-    if (empty($user['arp_found'])) {
-        print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
-        } else {
-        print "<td class=\"$cl\" >".$user['arp_found']."</td>\n";
-        }
+    print "<td class=\"$cl\" >";
+    if (!empty($user['arp_found'])) {
+        print $user['arp_found'];
+        } else { print "-"; }
+    print "&nbsp/&nbsp";
+    if (!empty($user['mac_found'])) {
+        print $user['mac_found'];
+        } else { print "-"; }
+    print "</td>\n";
     print "<td class=\"$cl\" >" . get_connection($db_link, $user['id']) . "</td>\n";
     print "</tr>\n";
 }
 print "</table>\n";
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 ?>
 <br>
 <table class="data">
@@ -282,6 +315,7 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 <script src="/js/remodal-auth.js"></script>
 
 <script>
+    
 document.getElementById('ou').addEventListener('change', function(event) {
   const buttonApply = document.getElementById('btn_filter');
   buttonApply.click();
@@ -321,5 +355,5 @@ document.getElementById('dynamic_enabled').addEventListener('change', function(e
 </script>
 
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

+ 30 - 26
html/admin/iplist/nagios.php

@@ -10,23 +10,26 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.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 == 'description') { $sort_table = 'user_list'; }
 
 $sort_url = "<a href=nagios.php?ou=" . $rou; 
 
-if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and User_list.ou_id=$rou "; }
+$params=[];
+if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and user_list.ou_id=?"; $params[]=$rou; }
 
 if ($rsubnet == 0) { $subnet_filter = ''; } else {
     $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>=? and user_auth.ip_int<=?"; }
+    $params[]=$subnet_range['start'];
+    $params[]=$subnet_range['stop'];
     }
 
 $enabled_filter='';
 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;
@@ -67,14 +70,13 @@ print_ip_submenu($page_url);
 </div>
 
 <?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";
-$res = mysqli_query($db_link, $countSQL);
-$count_records = mysqli_fetch_array($res);
-$total=ceil($count_records[0]/$displayed);
+$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, $params);
+$total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed; 
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 ?>
 <br>
 
@@ -86,7 +88,7 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 		<td align=Center><?php print $sort_url . "&sort=login&order=$new_order>" . WEB_cell_login . "</a>"; ?></td>
 		<td align=Center><?php print $sort_url . "&sort=ip_int&order=$new_order>" . WEB_cell_ip . "</a>"; ?></td>
 		<td align=Center><?php print $sort_url . "&sort=mac&order=$new_order>" . WEB_cell_mac . "</a>"; ?></td>
-		<td align=Center><?php print WEB_cell_comment; ?></td>
+		<td align=Center><?php print WEB_cell_description; ?></td>
 		<td align=Center><?php print WEB_cell_wikiname; ?></td>
 		<td align=Center><?php print $sort_url . "&sort=nagios&order=$new_order>" . WEB_cell_nagios; ?></td>
 		<td align=Center><?php print $sort_url . "&sort=link_check&order=$new_order>" . WEB_cell_link; ?></td>
@@ -96,18 +98,20 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 	</tr>
 <?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
-ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
+$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 ? OFFSET ?";
+$params[]=$displayed;
+$params[]=$start;
 
-$users = get_records_sql($db_link,$sSQL);
+$users = get_records_sql($db_link,$sSQL, $params);
 foreach ($users as $user) {
-    if ($user['dhcp_time'] == '0000-00-00 00:00:00') {
+    if (is_empty_datetime($user['dhcp_time'])) {
         $dhcp_str = '';
     } else {
         $dhcp_str = $user['dhcp_time'] . " (" . $user['dhcp_action'] . ")";
     }
-    if ($user['last_found'] == '0000-00-00 00:00:00') { $user['last_found'] = ''; }
+    if (is_empty_datetime($user['last_found'])) { $user['last_found'] = ''; }
     print "<tr align=center>\n";
     $cl = "data";
     if ($user['nagios_status'] == "UP") { $cl = "up"; }
@@ -119,17 +123,17 @@ foreach ($users as $user) {
     print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
     print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
     if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
-        print "<td class=\"$cl\" width=200>".$user['comments']." [" . $user['dhcp_hostname'] . "]</td>\n";
+        print "<td class=\"$cl\" width=200>".$user['description']." [" . $user['dhcp_hostname'] . "]</td>\n";
     } else {
-        print "<td class=\"$cl\" width=200>".$user['comments']."</td>\n";
+        print "<td class=\"$cl\" width=200>".$user['description']."</td>\n";
     }
-    if (!empty($user['WikiName'])) {
+    if (!empty($user['wikiname'])) {
         $wiki_url = rtrim(get_option($db_link, 60),'/');
         if (preg_match('/127.0.0.1/', $wiki_url)) { print "<td class=\"$cl\" ></td>\n"; } else {
             $wiki_web = rtrim(get_option($db_link, 63),'/');
             $wiki_web = ltrim($wiki_web,'/');
-            $wiki_link = $wiki_url.'/'.$wiki_web.'/'.$user['WikiName'];
-            print "<td class=\"$cl\" >"; print_url($user['WikiName'],$wiki_link); print "</td>\n";
+            $wiki_link = $wiki_url.'/'.$wiki_web.'/'.$user['wikiname'];
+            print "<td class=\"$cl\" >"; print_url($user['wikiname'],$wiki_link); print "</td>\n";
             }
         } else {
         print "<td class=\"$cl\" ></td>\n";
@@ -151,7 +155,7 @@ foreach ($users as $user) {
     print "</tr>\n";
 }
 print "</table>\n";
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 ?>
 <br>
 <table class="data">
@@ -189,5 +193,5 @@ document.getElementById('rows').addEventListener('change', function(event) {
 </script>
 
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

+ 46 - 19
html/admin/logs/authlog.php

@@ -21,27 +21,57 @@ if (!isset($auth_id)) { header('Location: /admin/logs/index.php', true, 301); ex
 </form>
 
 <?php
-$log_filter ='';
+$params = [$date1, $date2];
+$log_filter_parts = [];
+// Уровень логирования
+if ($display_log_level == L_ERROR) {
+    $log_filter_parts[] = "level = ?";
+    $params[] = L_ERROR;
+} elseif ($display_log_level == L_WARNING) {
+    $log_filter_parts[] = "level <= ?";
+    $params[] = L_WARNING;
+} elseif ($display_log_level == L_INFO) {
+    $log_filter_parts[] = "level <= ?";
+    $params[] = L_INFO;
+} elseif ($display_log_level == L_VERBOSE) {
+    $log_filter_parts[] = "level <= ?";
+    $params[] = L_VERBOSE;
+}
+// L_DEBUG — ничего не добавляем (все уровни)
 
-if ($display_log_level == L_ERROR) { $log_filter = " and `level`=". L_ERROR." "; }
-if ($display_log_level == L_WARNING) { $log_filter = " and `level`<=".L_WARNING." "; }
-if ($display_log_level == L_INFO) { $log_filter = " and `level`<=".L_INFO." "; }
-if ($display_log_level == L_VERBOSE) { $log_filter = " and `level`<=".L_VERBOSE." "; }
-if ($display_log_level == L_DEBUG) { $log_filter = ""; }
+$log_filter_parts[] = "auth_id = ?";
+$params[] = $auth_id;
 
-if (!empty($log_filter)) { $log_filter = $log_filter." and auth_id=".$auth_id; } else { $log_filter = " and auth_id=".$auth_id; }
-if (!empty($fcustomer)) { $log_filter = $log_filter." and customer LIKE '%".$fcustomer."%'"; }
-if (!empty($fmessage)) { $log_filter = $log_filter." and message LIKE '%".$fmessage."%'"; }
+if (!empty($fcustomer)) {
+    $log_filter_parts[] = "customer LIKE ?";
+    $params[] = '%' . $fcustomer . '%';
+}
+if (!empty($fmessage)) {
+    $log_filter_parts[] = "message LIKE ?";
+    $params[] = '%' . $fmessage . '%';
+}
 
-$countSQL="SELECT Count(*) FROM worklog WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $log_filter";
-$res = mysqli_query($db_link, $countSQL);
-$count_records = mysqli_fetch_array($res);
+// Собираем фильтр
+$log_filter = !empty($log_filter_parts) ? ' AND ' . implode(' AND ', $log_filter_parts) : '';
 
-$total=ceil($count_records[0]/$displayed);
+$countSQL = "SELECT COUNT(*) FROM worklog WHERE ts >= ? AND ts < ?" . $log_filter;
+$count_records = get_single_field($db_link, $countSQL, $params);
+
+$total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed; 
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
+#speedup paging
+$sSQL = "SELECT ts,customer,message,level FROM worklog as S JOIN (SELECT id FROM worklog WHERE ts>=? AND ts<? $log_filter 
+ORDER BY id DESC 
+LIMIT $displayed OFFSET $start) AS I ON S.id = I.id";
+
+$params[]=$displayed;
+$params[]=$start;
+
+$userlog = get_records_sql($db_link, $sSQL, $params);
+
 ?>
 <br>
 <table class="data" width="90%">
@@ -52,12 +82,9 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 		<td class="data"><b><?php echo WEB_log_event; ?></b></td>
 	</tr>
 <?php
-#speedup paging
-$sSQL = "SELECT timestamp,customer,message,level FROM worklog as S JOIN (SELECT id FROM worklog WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $log_filter ORDER BY id DESC LIMIT $start,$displayed) AS I ON S.id = I.id";
-$userlog = get_records_sql($db_link, $sSQL);
 foreach ($userlog as $row) {
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
-    print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
+    print "<td class=\"data\">" . get_datetime_display($row['ts']) . "</td>\n";
     print "<td class=\"data\">" . $row['customer'] . "</td>\n";
     $msg_level = 'INFO';
     if ($row['level'] == L_ERROR) { $msg_level='ERROR'; }
@@ -69,6 +96,6 @@ foreach ($userlog as $row) {
     print "</tr>\n";
 }
 print "</table>\n";
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

+ 43 - 41
html/admin/logs/detaillog.php

@@ -8,31 +8,26 @@ $default_sort='id';
 $sort_table = 'A';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
 
-if (isset($_POST['ip'])) { $f_ip = $_POST['ip']; }
-if (isset($_GET['ip'])) { $f_ip = $_GET['ip']; }
-if (!isset($f_ip) and isset($_SESSION[$page_url]['ip'])) { $f_ip=$_SESSION[$page_url]['ip']; }
-if (empty($f_ip)) { $f_ip = '127.0.0.1'; }
-
-$_SESSION[$page_url]['ip']=$f_ip;
+$f_ip = getParam('ip', $page_url, '127.0.0.1');
+$_SESSION[$page_url]['ip'] = $f_ip;
 
 $ip_where = '';
+$params=[];
 
 if (!empty($f_ip)) {
     if (checkValidIp($f_ip)) {
-        $ip_where = " (src_ip=inet_aton('" . $f_ip . "') or dst_ip=inet_aton('" . $f_ip . "')) AND "; 
+        $ip_where = " (src_ip=? or dst_ip=?) AND "; 
+        $params[]=ip2long($f_ip);
+        $params[]=ip2long($f_ip);
         }
     }
 
-$rdns = 0;
-if (isset($_POST['dns'])) { $rdns=$_POST['dns']*1; }
-$_SESSION[$page_url]['dns']=$rdns;
-$dns_checked='';
-if ($rdns) { $dns_checked='checked="checked"'; }
-
+$rdns = getPOST('dns', $page_url, 0, FILTER_VALIDATE_INT);
+$_SESSION[$page_url]['dns'] = $rdns;
+$dns_checked = $rdns ? 'checked="checked"' : '';
 $dns_cache=NULL;
 
 print_log_submenu($page_url);
-/* print_trafdetail_submenu($page_url,"id=$id&date_start=$date1&date_stop=$date2","<b>".WEB_log_detail_for."<a href=/admin/users/editauth.php?id=$id>$f_ip</a></b> ::&nbsp"); */
 
 ?>
 
@@ -57,16 +52,20 @@ $sort_url = "<a href='detaillog.php?date_start=\"".$date1.'"&date_stop="'.$date2
 if (!empty($f_ip)) { $sort_url .='&f_ip="'.$f_ip.'"'; }
 
 $gateway_filter='';
-if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(router_id=$rgateway) AND"; }
+if (!empty($rgateway) and $rgateway>0) { 
+    $gateway_filter="(router_id=?) AND"; $params[]=$rgateway; 
+    }
 
-$countSQL="SELECT Count(*) FROM Traffic_detail as A WHERE $gateway_filter $ip_where `timestamp`>='$date1' AND `timestamp`<'$date2'";
-$res = mysqli_query($db_link, $countSQL);
-$count_records = mysqli_fetch_array($res);
-$total=ceil($count_records[0]/$displayed);
+$countSQL="SELECT Count(*) FROM traffic_detail as A WHERE $gateway_filter $ip_where ts>=? AND ts< ? ";
+$params[]=$date1;
+$params[]=$date2;
+
+$count_records = get_single_field($db_link,$countSQL, $params);
+$total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed;
-print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+print_navigation($page_url,$page,$displayed,$count_records,$total);
 $gateway_list = get_gateways($db_link);
 ?>
 
@@ -75,7 +74,7 @@ $gateway_list = get_gateways($db_link);
 <tr align="center">
 <td class="data" width=20><b><?php $url = $sort_url.'&sort=id&order='.$new_order."'>id</a>"; print $url; ?></b></td>
 <td class="data" width=20><b><?php echo WEB_cell_login; ?></b></td>
-<td class="data" width=150><b><?php $url = $sort_url.'&sort=timestamp&order='.$new_order."'>".WEB_date."</a>"; print $url; ?></b></td>
+<td class="data" width=150><b><?php $url = $sort_url.'&sort=ts&order='.$new_order."'>".WEB_date."</a>"; print $url; ?></b></td>
 <td class="data" width=30><b><?php echo WEB_cell_gateway; ?></b></td>
 <td class="data" width=30><b><?php echo WEB_traffic_proto; ?></b></td>
 <td class="data" width=150><b><?php $url = $sort_url.'&sort=src_ip&order='.$new_order."'>".WEB_traffic_source_address."</a>"; print $url; ?></b></td>
@@ -88,36 +87,39 @@ $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>
 </tr>
 <?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 
-        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";
-$userdata = mysqli_query($db_link, $fsql);
-while (list ($uid, $auth_id, $udata, $urouter, $uproto, $sip, $sport,$dip, $dport, $ubytes, $upkt) = mysqli_fetch_array($userdata)) {
+$fsql = "SELECT A.id, A.auth_id, A.ts, 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 ts>= ? AND ts< ?
+        ORDER BY ts ASC LIMIT ? OFFSET ?) as T ON A.id = T.id ORDER BY $sort_table.$sort_field $order";
+$params[]=$displayed;
+$params[]=$start;
+
+$userdata = get_records_sql($db_link, $fsql, $params);
+foreach ($userdata as $row) {
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
-    print "<td class=\"data\">$uid</td>\n";
-    print "<td class=\"data\">"; print_auth_simple($db_link,$auth_id); print "</td>\n";
-    print "<td class=\"data\">$udata</td>\n";
-    print "<td class=\"data\">$gateway_list[$urouter]</td>\n";
-    $proto_name = getprotobynumber($uproto);
-    if (!$proto_name) { $proto_name=$uproto; }
+    print "<td class=\"data\">" . $row['id'] . "</td>\n";
+    print "<td class=\"data\">"; print_auth_simple($db_link, $row['auth_id']); print "</td>\n";
+    print "<td class=\"data\">" . get_datetime_display($row['ts']) . "</td>\n";
+    print "<td class=\"data\">" . $gateway_list[$row['router_id']] . "</td>\n";
+    $proto_name = getprotobynumber($row['proto']);
+    if (!$proto_name) { $proto_name = $row['proto']; }
     print "<td class=\"data\">" . $proto_name . "</td>\n";
-    print "<td class=\"data\" align=left>" . long2ip($sip) . "</td>\n";
+    print "<td class=\"data\" align=left>" . long2ip($row['src_ip']) . "</td>\n";
     $ip_name = '-';
-    if ($rdns) { $ip_name = ResolveIP($db_link,$sip); }
+    if ($rdns) { $ip_name = ResolveIP($db_link, $row['src_ip']); }
     print "<td class=\"data\" align=left>" . $ip_name . "</td>\n";
-    print "<td class=\"data\">" .$sport . "</td>\n";
-    print "<td class=\"data\" align=left>" . long2ip($dip) . "</td>\n";
+    print "<td class=\"data\">" . $row['src_port'] . "</td>\n";
+    print "<td class=\"data\" align=left>" . long2ip($row['dst_ip']) . "</td>\n";
     $ip_name = '-';
-    if ($rdns) { $ip_name = ResolveIP($db_link,$dip); }
+    if ($rdns) { $ip_name = ResolveIP($db_link, $row['dst_ip']); }
     print "<td class=\"data\" align=left>" . $ip_name . "</td>\n";
-    print "<td class=\"data\">" . $dport . "</td>\n";
-    print "<td class=\"data\" align=right>" . fbytes($ubytes) . "</td>\n";
-    print "<td class=\"data\" align=right>" . $upkt . "</td>\n";
+    print "<td class=\"data\">" . $row['dst_port'] . "</td>\n";
+    print "<td class=\"data\" align=right>" . fbytes($row['bytes']) . "</td>\n";
+    print "<td class=\"data\" align=right>" . $row['pkt'] . "</td>\n";
     print "</tr>\n";
 }
 ?>
 </table>
-<?php print_navigation($page_url,$page,$displayed,$count_records[0],$total); ?>
+<?php print_navigation($page_url,$page,$displayed,$count_records,$total); ?>
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません