diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh
index 2e40524588..c16729bca0 100644
--- a/extras/deploy-scripts/pandora_deploy_community.sh
+++ b/extras/deploy-scripts/pandora_deploy_community.sh
@@ -11,7 +11,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf
PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
-S_VERSION='2023050901'
+S_VERSION='2023062901'
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables
@@ -285,8 +285,7 @@ console_dependencies=" \
mod_ssl \
libzstd \
openldap-clients \
- chromium \
- http://firefly.pandorafms.com/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm"
+ chromium"
execute_cmd "yum install -y $console_dependencies" "Installing Pandora FMS Console dependencies"
# Server dependencies
@@ -313,7 +312,6 @@ server_dependencies=" \
bind-utils \
whois \
cpanminus \
- http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \
http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \
https://firefly.pandorafms.com/centos7/pandorawmic-1.0.0-1.x86_64.rpm"
execute_cmd "yum install -y $server_dependencies" "Installing Pandora FMS Server dependencies"
@@ -341,7 +339,6 @@ execute_cmd "yum install -y $oracle_dependencies || yum reinstall -y $oracle_dep
#ipam dependencies
ipam_dependencies=" \
- http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \
perl(NetAddr::IP) \
perl(Sys::Syslog) \
perl(DBI) \
@@ -719,6 +716,9 @@ echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cro
systemctl enable pandora_agent_daemon &>> $LOGFILE
execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent"
+# Enable postrix
+systemctl enable postfix --now &>> "$LOGFILE"
+
#SSH banner
[ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me)
diff --git a/extras/deploy-scripts/pandora_deploy_community_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh
index 972a094c95..3b4dde6cef 100644
--- a/extras/deploy-scripts/pandora_deploy_community_el8.sh
+++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh
@@ -14,7 +14,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf
PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
-S_VERSION='2023050901'
+S_VERSION='2023062901'
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables
@@ -344,8 +344,7 @@ console_dependencies=" \
http://firefly.pandorafms.com/centos8/chromium-110.0.5481.177-1.el7.x86_64.rpm \
http://firefly.pandorafms.com/centos8/chromium-common-110.0.5481.177-1.el7.x86_64.rpm \
http://firefly.pandorafms.com/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \
- http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \
- http://firefly.pandorafms.com/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm"
+ http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm"
execute_cmd "dnf install -y $console_dependencies" "Installing Pandora FMS Console dependencies"
# Server dependencies
@@ -371,7 +370,7 @@ server_dependencies=" \
java \
bind-utils \
whois \
- http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \
+ libnsl \
http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \
https://firefly.pandorafms.com/centos8/pandorawmic-1.0.0-1.x86_64.rpm"
execute_cmd "dnf install -y $server_dependencies" "Installing Pandora FMS Server dependencies"
@@ -399,7 +398,6 @@ execute_cmd "dnf install -y $oracle_dependencies" "Installing Oracle Instant cli
#ipam dependencies
ipam_dependencies=" \
- http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \
perl(NetAddr::IP) \
perl(Sys::Syslog) \
perl(DBI) \
@@ -622,8 +620,9 @@ sed -i -e "s/^upload_max_filesize.*/upload_max_filesize = 800M/g" /etc/php.ini
sed -i -e "s/^memory_limit.*/memory_limit = 800M/g" /etc/php.ini
sed -i -e "s/.*post_max_size =.*/post_max_size = 800M/" /etc/php.ini
-#adding 900s to httpd timeout
+#adding 900s to httpd timeout and 300 to ProxyTimeout
echo 'TimeOut 900' > /etc/httpd/conf.d/timeout.conf
+echo 'ProxyTimeout 300' >> /etc/httpd/conf.d/timeout.conf
cat > /var/www/html/index.html << EOF_INDEX
@@ -787,6 +786,9 @@ echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cro
systemctl enable pandora_agent_daemon &>> "$LOGFILE"
execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent"
+# Enable postfix
+systemctl enable postfix --now &>> "$LOGFILE"
+
#SSH banner
[ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me)
diff --git a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh
index 3d31ae10af..7e2ff6f532 100644
--- a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh
+++ b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh
@@ -17,7 +17,7 @@ PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
WORKDIR=/opt/pandora/deploy
-S_VERSION='2023050901'
+S_VERSION='2023062901'
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
rm -f $LOGFILE &> /dev/null # remove last log before start
@@ -265,7 +265,6 @@ server_dependencies=" \
openssh-client \
postfix \
unzip \
- xprobe \
coreutils \
libio-compress-perl \
libmoosex-role-timer-perl \
@@ -287,6 +286,7 @@ server_dependencies=" \
libgeo-ip-perl \
arping \
snmp-mibs-downloader \
+ libnsl2 \
openjdk-8-jdk "
execute_cmd "apt install -y $server_dependencies" "Installing Pandora FMS Server dependencies"
@@ -299,17 +299,7 @@ echo -en "${cyan}Installing wmic and pandorawmic...${reset}"
chmod +x pandorawmic wmic &>> "$LOGFILE" && \
cp -a wmic /usr/bin/ &>> "$LOGFILE" && \
cp -a pandorawmic /usr/bin/ &>> "$LOGFILE"
-check_cmd_status "Error Installing phanromjs"
-
-# phantomjs
-echo -en "${cyan}Installing phantomjs...${reset}"
- export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"
- export OPENSSL_CONF=/etc/ssl
- curl -LSs -O "https://firefly.pandorafms.com/pandorafms/utils/$PHANTOM_JS.tar.bz2" &>> "$LOGFILE" && \
- tar xvjf "$PHANTOM_JS.tar.bz2" &>> "$LOGFILE" && \
- mv $PHANTOM_JS/bin/phantomjs /usr/bin &>> "$LOGFILE" && \
- /usr/bin/phantomjs --version &>> "$LOGFILE"
-check_cmd_status "Error Installing phanromjs"
+check_cmd_status "Error Installing pandorawmic/wmic"
# create symlink for fping
rm -f /usr/sbin/fping &>> "$LOGFILE"
@@ -370,7 +360,6 @@ source '/root/.profile' &>> "$LOGFILE"
#ipam dependencies
ipam_dependencies=" \
- xprobe \
libnetaddr-ip-perl \
coreutils \
libdbd-mysql-perl \
@@ -619,8 +608,9 @@ sed --follow-symlinks -i -e "s/^memory_limit.*/memory_limit = 800M/g" /etc/php.i
sed --follow-symlinks -i -e "s/.*post_max_size =.*/post_max_size = 800M/" /etc/php.ini
sed --follow-symlinks -i -e "s/^disable_functions/;disable_functions/" /etc/php.ini
-#adding 900s to httpd timeout
-#echo 'TimeOut 900' > /etc/httpd/conf.d/timeout.conf
+#adding 900s to httpd timeout and 300 to ProxyTimeout
+echo 'TimeOut 900' > /etc/apache2/conf-enabled/timeout.conf
+echo 'ProxyTimeout 300' >> /etc/apache2/conf-enabled/timeout.conf
cat > /var/www/html/index.html << EOF_INDEX
@@ -792,6 +782,9 @@ systemctl enable pandora_agent_daemon &>> "$LOGFILE"
#fix path phantomjs
sed --follow-symlinks -i -e "s/^openssl_conf = openssl_init/#openssl_conf = openssl_init/g" /etc/ssl/openssl.cnf &>> "$LOGFILE"
+# Enable postfix
+systemctl enable postfix --now &>> "$LOGFILE"
+
#SSH banner
[ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me)
diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index 25cc4317bc..befff3be5c 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
package: pandorafms-agent-unix
-Version: 7.0NG.772-230718
+Version: 7.0NG.772-230720
Architecture: all
Priority: optional
Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index 841e77f29d..0f507262b8 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-pandora_version="7.0NG.772-230718"
+pandora_version="7.0NG.772-230720"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 2d7565e722..066c703237 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1031,7 +1031,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.772';
-use constant AGENT_BUILD => '230718';
+use constant AGENT_BUILD => '230720';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 7adf1af667..b6b857863e 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.772
-%define release 230718
+%define release 230720
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 2fb3a3c47f..7df3b5fca9 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.772
-%define release 230718
+%define release 230720
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index 476bcfff87..14939dc1e0 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.772"
-PI_BUILD="230718"
+PI_BUILD="230720"
OS_NAME=`uname -s`
FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 25d53728df..656dff5ec3 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
-{230718}
+{230720}
ViewReadme
{Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 37b5d7b223..8cb58c7095 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.772 Build 230718")
+#define PANDORA_VERSION ("7.0NG.772 Build 230720")
string pandora_path;
string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index f0fb52d90c..009659b454 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
- VALUE "ProductVersion", "(7.0NG.772(Build 230718))"
+ VALUE "ProductVersion", "(7.0NG.772(Build 230720))"
VALUE "FileVersion", "1.0.0.0"
END
END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index 93e195b067..66c16b35b1 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
package: pandorafms-console
-Version: 7.0NG.772-230718
+Version: 7.0NG.772-230720
Architecture: all
Priority: optional
Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 1dec27507e..a2c66fff09 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-pandora_version="7.0NG.772-230718"
+pandora_version="7.0NG.772-230720"
package_pear=0
package_pandora=1
diff --git a/pandora_console/extras/mr/65.sql b/pandora_console/extras/mr/65.sql
index d635c9b002..623c0a36f0 100644
--- a/pandora_console/extras/mr/65.sql
+++ b/pandora_console/extras/mr/65.sql
@@ -1,5 +1,23 @@
START TRANSACTION;
+CREATE TABLE IF NOT EXISTS `tnetwork_explorer_filter` (
+`id` INT NOT NULL,
+`filter_name` VARCHAR(45) NULL,
+`top` VARCHAR(45) NULL,
+`action` VARCHAR(45) NULL,
+`advanced_filter` TEXT NULL,
+PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
+
+CREATE TABLE IF NOT EXISTS `tnetwork_usage_filter` (
+`id` INT NOT NULL auto_increment,
+`filter_name` VARCHAR(45) NULL,
+`top` VARCHAR(45) NULL,
+`action` VARCHAR(45) NULL,
+`advanced_filter` TEXT NULL,
+PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
+
ALTER TABLE `tlayout`
ADD COLUMN `grid_color` VARCHAR(45) NOT NULL DEFAULT '#cccccc' AFTER `maintenance_mode`,
ADD COLUMN `grid_size` VARCHAR(45) NOT NULL DEFAULT '10' AFTER `grid_color`;
diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php
index c8413d670e..6616cd765c 100644
--- a/pandora_console/godmode/setup/setup_auth.php
+++ b/pandora_console/godmode/setup/setup_auth.php
@@ -210,7 +210,7 @@ if (is_ajax() === true) {
// Ldapsearch timeout.
// Default Ldapsearch timeout.
- set_when_empty($config['ldap_searh_timeout'], 5);
+ set_when_empty($config['ldap_search_timeout'], 5);
$row = [];
$row['name'] = __('Ldap search timeout (secs)');
$row['control'] = html_print_input_text(
@@ -558,7 +558,13 @@ echo '';
if ($('input[type=checkbox][name=secondary_ldap_enabled]:checked').val() == 1) {
$("tr[id*='ldap_'][id$='_secondary']").show();
} else {
- $( "tr[id*='ldap_'][id$='_secondary']" ).hide();
+ $( "tr[id*='ldap_'][id$='_secondary']" ).hide();
+ }
+
+ if ($('input[type=checkbox][name=secondary_active_directory]:checked').val() == 1) {
+ $("tr[id*='ad_'][id$='_secondary']").show();
+ } else {
+ $( "tr[id*='ad_'][id$='_secondary']" ).hide();
}
}
$( document ).ready(function() {
diff --git a/pandora_console/images/widgets/netflow.png b/pandora_console/images/widgets/netflow.png
new file mode 100644
index 0000000000..5a34c1635f
Binary files /dev/null and b/pandora_console/images/widgets/netflow.png differ
diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php
index 9ebeaaf167..a24769e528 100644
--- a/pandora_console/include/auth/mysql.php
+++ b/pandora_console/include/auth/mysql.php
@@ -237,8 +237,13 @@ function process_user_login_remote($login, $pass, $api=false)
// Active Directory.
case 'ad':
- if (enterprise_hook('ad_process_user_login', [$login, $pass]) === false) {
- $config['auth_error'] = 'User not found in database or incorrect password';
+ $sr = enterprise_hook('ad_process_user_login', [$login, $pass]);
+ // Try with secondary server.
+ if ($sr === false && (bool) $config['secondary_active_directory'] === true) {
+ $sr = enterprise_hook('ad_process_user_login', [$login, $pass, true]);
+ }
+
+ if ($sr === false) {
return false;
}
break;
diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php
index cb9435b559..9142f9a692 100644
--- a/pandora_console/include/class/ConsoleSupervisor.php
+++ b/pandora_console/include/class/ConsoleSupervisor.php
@@ -1807,7 +1807,8 @@ class ConsoleSupervisor
$this->cleanNotifications('NOTIF.PHP.SERIALIZE_PRECISION');
}
- if (version_compare('8.1', PHP_VERSION) >= 0) {
+ // If PHP_VERSION is lower than 8.0.27 version_compare() returns 1.
+ if (version_compare('8.0.27', PHP_VERSION) === 1) {
$url = 'https://www.php.net/supported-versions.php';
$this->notify(
[
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index b384fdf8d2..99d33b658e 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
-$build_version = 'PC230718';
+$build_version = 'PC230720';
$pandora_version = 'v7.0NG.772';
// Do not overwrite default timezone set if defined.
diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php
index 7a189756ad..e016baaf4b 100644
--- a/pandora_console/include/functions_agents.php
+++ b/pandora_console/include/functions_agents.php
@@ -2770,6 +2770,69 @@ function agents_delete_agent($id_agents, $disableACL=false)
enterprise_include_once('include/functions_agents.php');
enterprise_hook('agent_delete_from_cache', [$id_agent]);
+ // Delete agent from visual console.
+ db_process_sql_delete(
+ 'tlayout_data',
+ ['id_agent' => $id_agent]
+ );
+
+ // Delete agent from visual dashboards.
+ db_process_sql(
+ 'UPDATE twidget_dashboard
+ SET options = NULL
+ WHERE options LIKE ("%\"agentid\":\"'.$id_agent.'\"%")'
+ );
+
+ // Delete agent from treport.
+ db_process_sql_delete(
+ 'treport_content',
+ ['id_agent' => $id_agent]
+ );
+
+ // Delete rules from tevent alerts (correlative alerts)
+ db_process_sql_delete(
+ 'tevent_rule',
+ [
+ 'agent' => $id_agent,
+ 'operator_agent' => '==',
+ ]
+ );
+
+ db_process_sql_delete(
+ 'tevent_rule',
+ [
+ 'log_agent' => $id_agent,
+ 'operator_log_agent' => '==',
+ ]
+ );
+
+ // Delete from gis maps history
+ db_process_sql_delete(
+ 'tgis_data_history',
+ ['tagente_id_agente' => $id_agent]
+ );
+
+ // Delete from policies.
+ db_process_sql_delete(
+ 'tpolicy_agents',
+ ['id_agent' => $id_agent]
+ );
+
+ // Delete from tnetwork maps
+ db_process_sql_delete(
+ 'titem',
+ ['source_data' => $id_agent]
+ );
+
+ db_process_sql_delete(
+ 'trel_item',
+ [
+ 'id_parent_source_data' => $id_agent,
+ 'id_child_source_data' => $id_agent,
+ ],
+ 'OR'
+ );
+
// Delete agent from fav menu.
db_process_sql_delete(
'tfavmenu_user',
diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index 7a82254cf8..d1de857ae9 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -627,6 +627,30 @@ function config_update_config()
$error_update[] = __('Domain');
}
+ if (config_update_value('secondary_active_directory', get_parameter('secondary_active_directory'), true) === false) {
+ $error_update[] = __('Secondary active directory');
+ }
+
+ if (config_update_value('ad_server_secondary', get_parameter('ad_server_secondary'), true) === false) {
+ $error_update[] = __('Secondary active directory server');
+ }
+
+ if (config_update_value('ad_port_secondary', get_parameter('ad_port_secondary'), true) === false) {
+ $error_update[] = __('Secondary active directory port');
+ }
+
+ if (config_update_value('ad_start_tls_secondary', get_parameter('ad_start_tls_secondary'), true) === false) {
+ $error_update[] = __('Secondary start TLS');
+ }
+
+ if (config_update_value('ad_search_timeout', get_parameter('ad_search_timeout'), true) === false) {
+ $error_update[] = __('AD search timeout');
+ }
+
+ if (config_update_value('ad_domain_secondary', get_parameter('ad_domain_secondary'), true) === false) {
+ $error_update[] = __('Secondary domain');
+ }
+
if (config_update_value('ad_adv_perms', get_parameter('ad_adv_perms'), true) === false) {
$error_update[] = __('Advanced Permisions AD');
}
@@ -3100,6 +3124,14 @@ function config_process_config()
config_update_value('ad_port', 389);
}
+ if (!isset($config['ad_server_secondary'])) {
+ config_update_value('ad_server_secondary', 'localhost');
+ }
+
+ if (!isset($config['ad_port_secondary'])) {
+ config_update_value('ad_port_secondary', 389);
+ }
+
if (!isset($config['ad_start_tls'])) {
config_update_value('ad_start_tls', 0);
}
diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php
index de0f45f053..61f0d472be 100644
--- a/pandora_console/include/functions_graph.php
+++ b/pandora_console/include/functions_graph.php
@@ -4407,7 +4407,10 @@ function graph_netflow_circular_mesh($data)
include_once $config['homedir'].'/include/graphs/functions_d3.php';
- return d3_relationship_graph($data['elements'], $data['matrix'], 900, true);
+ $width = (empty($data['width']) === false) ? $data['width'] : 900;
+ $height = (empty($data['height']) === false) ? $data['height'] : 900;
+
+ return d3_relationship_graph($data['elements'], $data['matrix'], $width, true, $height);
}
@@ -4766,19 +4769,18 @@ function graph_monitor_wheel($width=550, $height=600, $filter=false)
$filter_module_group = (!empty($filter) && !empty($filter['module_group'])) ? $filter['module_group'] : false;
if ($filter['group'] != 0) {
- $filter_subgroups = '';
- if (!$filter['dont_show_subgroups']) {
- $filter_subgroups = ' || parent IN ('.$filter['group'].')';
+ if ($filter['dont_show_subgroups'] === false) {
+ $groups = groups_get_children($filter['group']);
+ $groups_ax = [];
+ foreach ($groups as $g) {
+ $groups_ax[$g['id_grupo']] = $g;
+ }
+
+ $groups = $groups_ax;
+ } else {
+ $groups = groups_get_group_by_id($filter['group']);
+ $groups[$group['id_grupo']] = $group;
}
-
- $groups = db_get_all_rows_sql('SELECT * FROM tgrupo where id_grupo IN ('.$filter['group'].') '.$filter_subgroups);
-
- $groups_ax = [];
- foreach ($groups as $g) {
- $groups_ax[$g['id_grupo']] = $g;
- }
-
- $groups = $groups_ax;
} else {
$groups = users_get_groups(false, 'AR', false, true, (!empty($filter) && isset($filter['group']) ? $filter['group'] : null));
}
diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php
index 59d02ccb4f..79fcd9a0db 100644
--- a/pandora_console/include/functions_netflow.php
+++ b/pandora_console/include/functions_netflow.php
@@ -1233,7 +1233,9 @@ function netflow_draw_item(
$max_aggregates,
$connection_name='',
$output='HTML',
- $address_resolution=false
+ $address_resolution=false,
+ $width_content=false,
+ $height_content=false
) {
$aggregate = $filter['aggregate'];
$interval = ($end_date - $start_date);
@@ -1432,6 +1434,9 @@ function netflow_draw_item(
netflow_aggregate_is_ip($aggregate)
);
+ $data_circular['width'] = $width_content;
+ $data_circular['height'] = $height_content;
+
$html = '
';
$html .= graph_netflow_circular_mesh($data_circular);
$html .= '
';
@@ -1734,7 +1739,12 @@ function netflow_get_top_summary(
switch ($top_action) {
case 'listeners':
if (empty(!$filter)) {
- $netflow_filter['ip_src'] = $filter;
+ if (!is_array($filter)) {
+ $netflow_filter['ip_src'] = $filter;
+ } else {
+ $netflow_filter['ip_src'] = $filter['ip'];
+ $netflow_filter['advanced_filter'] = $filter['advanced_filter'];
+ }
}
$sort = 'dstip';
@@ -1742,7 +1752,12 @@ function netflow_get_top_summary(
case 'talkers':
if (empty(!$filter)) {
- $netflow_filter['ip_dst'] = $filter;
+ if (!is_array($filter)) {
+ $netflow_filter['ip_dst'] = $filter;
+ } else {
+ $netflow_filter['ip_dst'] = $filter['ip'];
+ $netflow_filter['advanced_filter'] = $filter['advanced_filter'];
+ }
}
$sort = 'srcip';
@@ -2069,7 +2084,7 @@ function netflow_aggregate_is_ip($aggregate)
*
* @return array With map structure.
*/
-function netflow_build_map_data($start_date, $end_date, $top, $aggregate)
+function netflow_build_map_data($start_date, $end_date, $top, $aggregate, $advanced_filter='')
{
// Pass an empty filter data structure.
$data = netflow_get_relationships_raw_data(
@@ -2083,7 +2098,7 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate)
'ip_src' => '',
'dst_port' => '',
'src_port' => '',
- 'advanced_filter' => '',
+ 'advanced_filter' => $advanced_filter,
'router_ip' => '',
],
$top,
diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php
index 0cba3c045d..498602a1d1 100644
--- a/pandora_console/include/graphs/functions_d3.php
+++ b/pandora_console/include/graphs/functions_d3.php
@@ -57,7 +57,7 @@ function include_javascript_d3($return=false)
}
-function d3_relationship_graph($elements, $matrix, $width=700, $return=false)
+function d3_relationship_graph($elements, $matrix, $width=700, $return=false, $height=700)
{
global $config;
@@ -72,7 +72,7 @@ function d3_relationship_graph($elements, $matrix, $width=700, $return=false)
$output = '';
$output .= include_javascript_d3(true);
$output .= "";
if (!$return) {
diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js
index 0c39ca55aa..f99f0448da 100644
--- a/pandora_console/include/graphs/pandora.d3.js
+++ b/pandora_console/include/graphs/pandora.d3.js
@@ -22,7 +22,7 @@
// matrix = [[0, 0, 2], // a[a => a, a => b, a => c]
// [5, 0, 1], // b[b => a, b => b, b => c]
// [2, 3, 0]]; // c[c => a, c => b, c => c]
-function chordDiagram(recipient, elements, matrix, width) {
+function chordDiagram(recipient, elements, matrix, width, height) {
d3.chart = d3.chart || {};
d3.chart.chordWheel = function(options) {
// Default values
@@ -59,10 +59,13 @@ function chordDiagram(recipient, elements, matrix, width) {
.enter()
.append("svg:svg")
.attr("width", width)
- .attr("height", width)
+ .attr("height", height)
.attr("class", "dependencyWheel")
.append("g")
- .attr("transform", "translate(" + width / 2 + "," + width / 2 + ")");
+ .attr(
+ "transform",
+ "translate(" + width / 2 + "," + height / 2 + ") scale(1.2)"
+ );
var arc = d3.svg
.arc()
@@ -206,8 +209,8 @@ function chordDiagram(recipient, elements, matrix, width) {
.on("mousemove", move_tooltip);
function move_tooltip(d) {
- x = d3.event.pageX + 10;
- y = d3.event.pageY + 10;
+ x = d3.event.layerX + 10;
+ y = d3.event.layerY + 10;
$("#tooltip").css("left", x + "px");
$("#tooltip").css("top", y + "px");
diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php
index b9e9971507..14712eee27 100644
--- a/pandora_console/include/lib/Dashboard/Widget.php
+++ b/pandora_console/include/lib/Dashboard/Widget.php
@@ -416,6 +416,10 @@ class Widget
$className .= '\OsQuickReportWidget';
break;
+ case 'netflow':
+ $className .= '\Netflow';
+ break;
+
case 'GroupedMeterGraphs':
case 'ColorModuleTabs':
case 'BlockHistogram':
diff --git a/pandora_console/include/lib/Dashboard/Widgets/netflow.php b/pandora_console/include/lib/Dashboard/Widgets/netflow.php
new file mode 100644
index 0000000000..be603e452b
--- /dev/null
+++ b/pandora_console/include/lib/Dashboard/Widgets/netflow.php
@@ -0,0 +1,465 @@
+width = $width;
+
+ // Height.
+ $this->height = $height;
+
+ // Grid Width.
+ $this->gridWidth = $gridWidth;
+
+ // Options.
+ $this->values = $this->getOptionsWidget();
+
+ // Positions.
+ $this->position = $this->getPositionWidget();
+
+ // Page.
+ $this->page = basename(__FILE__);
+
+ // ClassName.
+ $class = new \ReflectionClass($this);
+ $this->className = $class->getShortName();
+
+ // Title.
+ $this->title = __('Netflow');
+
+ // Name.
+ if (empty($this->name) === true) {
+ $this->name = 'netflow';
+ }
+ }
+
+
+ /**
+ * Generates inputs for form (specific).
+ *
+ * @return array Of inputs.
+ *
+ * @throws Exception On error.
+ */
+ public function getFormInputs(): array
+ {
+ $values = $this->values;
+
+ // Retrieve global - common inputs.
+ $inputs = parent::getFormInputs();
+
+ // Default values.
+ if (isset($values['quantity']) === false) {
+ $values['quantity'] = 5;
+ }
+
+ // Default values.
+ if (isset($values['period']) === false) {
+ $values['period'] = SECONDS_1WEEK;
+ }
+
+ // Default values.
+ if (isset($values['max_values']) === false) {
+ $values['max_values'] = 10;
+ }
+
+ // Period.
+ $inputs[] = [
+ 'label' => __('Interval'),
+ 'arguments' => [
+ 'name' => 'period',
+ 'type' => 'interval',
+ 'value' => $values['period'],
+ 'nothing' => __('None'),
+ 'nothing_value' => 0,
+ 'style_icon' => 'flex-grow: 0',
+ ],
+ ];
+ $chart_types = netflow_get_chart_types();
+ $chart_types['usage_map'] = __('Usage map');
+ $inputs[] = [
+ 'label' => __('Type graph'),
+ 'arguments' => [
+ 'name' => 'chart_type',
+ 'type' => 'select',
+ 'fields' => $chart_types,
+ 'selected' => $values['chart_type'],
+ ],
+ ];
+
+ $aggregate_list = [
+ 'srcip' => __('Src Ip Address'),
+ 'dstip' => __('Dst Ip Address'),
+ 'srcport' => __('Src Port'),
+ 'dstport' => __('Dst Port'),
+ ];
+ $inputs[] = [
+ 'label' => __('Aggregated by'),
+ 'id' => 'aggregated',
+ 'arguments' => [
+ 'name' => 'aggregate',
+ 'type' => 'select',
+ 'fields' => $aggregate_list,
+ 'selected' => $values['aggregate'],
+ ],
+ ];
+
+ $inputs[] = [
+ 'label' => __('Data to show'),
+ 'id' => 'data_to_show',
+ 'arguments' => [
+ 'name' => 'action',
+ 'type' => 'select',
+ 'fields' => network_get_report_actions(),
+ 'selected' => $values['action'],
+ ],
+ ];
+
+ $max_values = [
+ '2' => '2',
+ '5' => '5',
+ '10' => '10',
+ '15' => '15',
+ '20' => '20',
+ '25' => '25',
+ '50' => '50',
+ ];
+
+ $inputs[] = [
+ 'label' => __('Max values'),
+ 'arguments' => [
+ 'name' => 'max_values',
+ 'type' => 'select',
+ 'fields' => $max_values,
+ 'selected' => $values['max_values'],
+ ],
+ ];
+
+ return $inputs;
+ }
+
+
+ /**
+ * Get Post for widget.
+ *
+ * @return array
+ */
+ public function getPost():array
+ {
+ // Retrieve global - common inputs.
+ $values = parent::getPost();
+
+ $values['period'] = \get_parameter('period', 0);
+ $values['chart_type'] = \get_parameter('chart_type', '');
+ $values['aggregate'] = \get_parameter('aggregate');
+ $values['max_values'] = \get_parameter('max_values', 10);
+ $values['action'] = \get_parameter('action', 'srcip');
+
+ return $values;
+ }
+
+
+ /**
+ * Draw widget.
+ *
+ * @return string
+ */
+ public function load()
+ {
+ ui_require_css_file('netflow_widget', 'include/styles/', true);
+ global $config;
+
+ $output = '';
+
+ $size = parent::getSize();
+
+ $start_date = (time() - $this->values['period']);
+ $end_date = time();
+ if ($this->values['chart_type'] === 'usage_map') {
+ $map_data = netflow_build_map_data(
+ $start_date,
+ $end_date,
+ $this->values['max_values'],
+ ($this->values['action'] === 'talkers') ? 'srcip' : 'dstip'
+ );
+ $has_data = !empty($map_data['nodes']);
+
+ if ($has_data === true) {
+ $map_manager = new \NetworkMap($map_data);
+ $map_manager->printMap();
+ } else {
+ ui_print_info_message(__('No data to show'));
+ }
+ } else {
+ $netflowContainerClass = ($this->values['chart_type'] === 'netflow_data' || $this->values['chart_type'] === 'netflow_summary' || $this->values['chart_type'] === 'netflow_top_N') ? '' : 'white_box';
+ $filter = [
+ 'aggregate' => $this->values['aggregate'],
+ 'netflow_monitoring_interval' => 300,
+ ];
+
+ $output .= html_print_input_hidden(
+ 'selected_style_theme',
+ $config['style'],
+ true
+ );
+ $style = 'width:100%; height: 100%; border: none;';
+ if ($this->values['chart_type'] !== 'netflow_area') {
+ $style .= ' width: 95%;';
+ }
+
+ if ($size['width'] > $size['height']) {
+ $size['width'] = $size['height'];
+ }
+
+ // Draw the netflow chart.
+ $output .= html_print_div(
+ [
+ 'class' => $netflowContainerClass,
+ 'style' => $style,
+ 'content' => netflow_draw_item(
+ $start_date,
+ $end_date,
+ 12,
+ $this->values['chart_type'],
+ $filter,
+ $this->values['max_values'],
+ '',
+ 'HTML',
+ 0,
+ ($size['width'] - 50),
+ ($size['height'] - 20),
+ ),
+ ],
+ true
+ );
+ }
+
+ return $output;
+
+ }
+
+
+ /**
+ * Return aux javascript code for forms.
+ *
+ * @return string
+ */
+ public function getFormJS()
+ {
+ return '
+ $(document).ready(function(){
+ //Limit 1 week
+ $("#period_select option").each(function(key, element){
+ if(element.value > 604800){
+ $(element).remove();
+ }
+ })
+ $("#period_manual option").each(function(key, element){
+ if(element.value > 604800){
+ $(element).remove();
+ }
+ });
+ $("#period_manual input").on("change", function(e){
+ if($("#hidden-period").val() > 604800) {
+ $(this).val(1);
+ $("#hidden-period").val(604800);
+ $("#period_manual select option").removeAttr("selected");
+ setTimeout(() => {
+ $("#period_default select option[value=\'604800\']").attr("selected", "selected");
+ $("#period_manual select option[value=\'604800\']").attr("selected", "selected");
+ $("#period_manual select").val(604800);
+ }, 500);
+ }
+ });
+ if($("#chart_type").val() === "usage_map") {
+ $("#data_to_show").show();
+ $("#aggregated").hide();
+ } else {
+ $("#data_to_show").hide();
+ $("#aggregated").show();
+ }
+ $("#chart_type").on("change", function(e){
+ if(this.value === "usage_map") {
+ $("#data_to_show").show();
+ $("#aggregated").hide();
+ } else {
+ $("#data_to_show").hide();
+ $("#aggregated").show();
+ }
+ });
+ });
+ ';
+ }
+
+
+ /**
+ * Get description.
+ *
+ * @return string.
+ */
+ public static function getDescription()
+ {
+ return __('Netflow');
+ }
+
+
+ /**
+ * Get Name.
+ *
+ * @return string.
+ */
+ public static function getName()
+ {
+ return 'netflow';
+ }
+
+
+ /**
+ * Get size Modal Configuration.
+ *
+ * @return array
+ */
+ public function getSizeModalConfiguration(): array
+ {
+ $size = [
+ 'width' => 400,
+ 'height' => 530,
+ ];
+
+ return $size;
+ }
+
+
+}
diff --git a/pandora_console/include/styles/netflow_widget.css b/pandora_console/include/styles/netflow_widget.css
new file mode 100644
index 0000000000..c7be7fe90d
--- /dev/null
+++ b/pandora_console/include/styles/netflow_widget.css
@@ -0,0 +1,13 @@
+.menu_graph {
+ display: none;
+}
+.parent_graph {
+ width: 97% !important;
+}
+#image_hide_show_labels {
+ display: none !important;
+}
+
+.select2-search--dropdown .select2-search__field {
+ padding: 0px !important;
+}
diff --git a/pandora_console/index.php b/pandora_console/index.php
index 96be49a6af..75c00af9b1 100755
--- a/pandora_console/index.php
+++ b/pandora_console/index.php
@@ -712,7 +712,6 @@ if (isset($config['id_user']) === false) {
login_check_failed($nick);
}
- $config['auth_error'] = __('User is blocked');
$login_failed = true;
}
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 2a21ae2c9c..548f57b24b 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -131,7 +131,7 @@
false,
- 'text' => '
'.html_print_image(
+ 'text' => ''.html_print_image(
'images/network@svg.svg',
true,
[
diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php
index 15716e653c..5d402a5793 100644
--- a/pandora_console/operation/network/network_report.php
+++ b/pandora_console/operation/network/network_report.php
@@ -39,10 +39,26 @@ if (! check_acl($config['id_user'], 0, 'AR')) {
exit;
}
+// Ajax callbacks.
+if (is_ajax() === true) {
+ $get_filter_values = get_parameter('get_filter_values', 0);
+ // Get values of the current network filter.
+ if ($get_filter_values) {
+ $id = get_parameter('id');
+ $filter_values = db_get_row_filter('tnetwork_explorer_filter', ['id' => $id]);
+ // Decode HTML entities.
+ $filter_values['advanced_filter'] = io_safe_output($filter_values['advanced_filter']);
+ echo json_encode($filter_values);
+ }
+
+ return;
+}
+
// Include JS timepicker.
ui_include_time_picker();
// Query params and other initializations.
+$filter_id = (int) get_parameter('filter_id', 0);
$time_greater = get_parameter('time_greater', date(TIME_FORMAT));
$date_greater = get_parameter('date_greater', date(DATE_FORMAT));
$utimestamp_greater = strtotime($date_greater.' '.$time_greater);
@@ -59,6 +75,13 @@ $top = (int) get_parameter('top', 10);
$main_value = ((bool) get_parameter('remove_filter', 0)) ? '' : get_parameter('main_value', '');
if (is_numeric($main_value) && !in_array($action, ['udp', 'tcp'])) {
$main_value = '';
+} else {
+ $filter['ip'] = $main_value;
+}
+
+$advanced_filter = get_parameter('advanced_filter', '');
+if ($advanced_filter !== '') {
+ $filter['advanced_filter'] = $advanced_filter;
}
$order_by = get_parameter('order_by', 'bytes');
@@ -66,30 +89,143 @@ if (!in_array($order_by, ['bytes', 'pkts', 'flows'])) {
$order_by = 'bytes';
}
-$style_end = ($is_period) ? 'display: none;' : '';
-$style_period = ($is_period) ? '' : 'display: none;';
+$save = get_parameter('save_button', '');
+$update = get_parameter('update_button', '');
+
+// Save user defined filter.
+if ($save != '' && check_acl($config['id_user'], 0, 'AW')) {
+ // Save filter args.
+ $data['filter_name'] = get_parameter('filter_name');
+ $data['top'] = $top;
+ $data['action'] = $action;
+ $data['advanced_filter'] = $advanced_filter;
+
+
+ $filter_id = db_process_sql_insert('tnetwork_explorer_filter', $data);
+ if ($filter_id === false) {
+ $filter_id = 0;
+ ui_print_error_message(__('Error creating filter'));
+ } else {
+ ui_print_success_message(__('Filter created successfully'));
+ }
+} else if ($update != '' && check_acl($config['id_user'], 0, 'AW')) {
+ // Update current filter.
+ // Do not update the filter name and group.
+ $data['top'] = $top;
+ $data['action'] = $action;
+ $data['advanced_filter'] = $advanced_filter;
+
+ $result = db_process_sql_update(
+ 'tnetwork_explorer_filter',
+ $data,
+ ['id' => $filter_id]
+ );
+ ui_print_result_message(
+ $result,
+ __('Filter updated successfully'),
+ __('Error updating filter')
+ );
+}
// Build the table.
-$table = new stdClass();
-$table->class = 'filter-table-adv';
-$table->width = '100%';
-$table->data = [];
+$filterTable = new stdClass();
+$filterTable->id = '';
+$filterTable->class = 'filter-table-adv';
+$filterTable->size = [];
+$filterTable->size[0] = '33%';
+$filterTable->size[1] = '33%';
+$filterTable->size[2] = '33%';
+$filterTable->data = [];
-$table->data[0][] = html_print_label_input_block(
- __('Data to show'),
- html_print_select(
- network_get_report_actions(false),
- 'action',
- $action,
+$filterTable->data[0][0] = html_print_label_input_block(
+ __('Interval'),
+ html_print_extended_select_for_time(
+ 'period',
+ $period,
'',
'',
0,
+ false,
+ true
+ ),
+ [ 'div_id' => 'period_container' ]
+);
+
+$filterTable->data[0][0] .= html_print_label_input_block(
+ __('Start date'),
+ html_print_div(
+ [
+ 'class' => '',
+ 'content' => html_print_input_text(
+ 'date_lower',
+ $date_lower,
+ false,
+ 13,
+ 10,
+ true
+ ).html_print_image(
+ 'images/calendar_view_day.png',
+ true,
+ [
+ 'alt' => 'calendar',
+ 'class' => 'main_menu_icon invert_filter',
+ ]
+ ).html_print_input_text(
+ 'time_lower',
+ $time_lower,
+ false,
+ 10,
+ 8,
+ true
+ ),
+ ],
+ true
+ ),
+ [ 'div_id' => 'end_date_container' ]
+);
+
+$filterTable->data[0][1] = html_print_label_input_block(
+ __('End date'),
+ html_print_div(
+ [
+ 'content' => html_print_input_text(
+ 'date',
+ $date_greater,
+ false,
+ 13,
+ 10,
+ true
+ ).html_print_image(
+ 'images/calendar_view_day.png',
+ true,
+ ['alt' => 'calendar']
+ ).html_print_input_text(
+ 'time',
+ $time_greater,
+ false,
+ 10,
+ 8,
+ true
+ ),
+ ],
true
)
);
-$table->data[0][] = html_print_label_input_block(
- __('Number of result to show'),
+$filterTable->data[0][2] = html_print_label_input_block(
+ __('Defined period'),
+ html_print_checkbox_switch(
+ 'is_period',
+ 1,
+ ($is_period === true) ? 1 : 0,
+ true,
+ false,
+ 'nf_view_click_period()'
+ )
+);
+
+$filterTable->data[1][] = html_print_label_input_block(
+ __('Results to show'),
html_print_select(
[
'5' => 5,
@@ -110,95 +246,62 @@ $table->data[0][] = html_print_label_input_block(
)
);
-$table->data[1][] = html_print_label_input_block(
- __('Start date'),
- html_print_div(
- [
- 'id' => 'end_date_container',
- 'content' => html_print_input_text(
- 'date_lower',
- $date_lower,
- '',
- 10,
- 10,
- true
- ).html_print_input_text(
- 'time_lower',
- $time_lower,
- '',
- 7,
- 8,
- true
- ),
- ],
- true
- ).html_print_div(
- [
- 'id' => 'period_container',
- 'style' => 'display: none;',
- 'content' => html_print_label_input_block(
- '',
- html_print_extended_select_for_time(
- 'period',
- $period,
- '',
- '',
- 0,
- false,
- true
- ),
- ),
- ],
+$filterTable->data[1][] = html_print_label_input_block(
+ __('Data to show'),
+ html_print_select(
+ network_get_report_actions(),
+ 'action',
+ $action,
+ '',
+ '',
+ 0,
true
)
);
-$table->data[1][] = html_print_label_input_block(
- __('End date'),
- html_print_div(
- [
- 'id' => '',
- 'class' => '',
- 'content' => html_print_input_text(
- 'date_greater',
- $date_greater,
- '',
- 10,
- 10,
- true
- ).html_print_input_text(
- 'time_greater',
- $time_greater,
- '',
- 7,
- 8,
- true
- ),
- ],
- true
- )
+$advanced_toggle = new stdClass();
+$advanced_toggle->class = 'filter-table-adv';
+$advanced_toggle->size = [];
+$advanced_toggle->size[0] = '50%';
+$advanced_toggle->size[1] = '50%';
+$advanced_toggle->width = '100%';
+$user_groups = users_get_groups($config['id_user'], 'AR', $own_info['is_admin'], true);
+$user_groups[0] = 0;
+// Add all groups.
+$sql = 'SELECT * FROM tnetwork_explorer_filter';
+$advanced_toggle->data[0][0] = html_print_label_input_block(
+ __('Load Filter'),
+ html_print_select_from_sql($sql, 'filter_id', $filter_id, '', __('Select a filter'), 0, true, false, true, false, 'width:100%;')
);
-
-$table->data[2][] = html_print_label_input_block(
- __('Defined period'),
- html_print_checkbox_switch(
- 'is_period',
- 1,
- ($is_period === true) ? 1 : 0,
+$advanced_toggle->data[0][1] = html_print_label_input_block(
+ __('Filter name'),
+ html_print_input_text('filter_name', '', false, 40, 45, true, false, false, '', 'w100p')
+);
+$advanced_toggle->colspan[1][0] = 2;
+$advanced_toggle->data[1][0] = html_print_label_input_block(
+ __('Filter').ui_print_help_icon('pcap_filter', true),
+ html_print_textarea('advanced_filter', 4, 10, $advanced_filter, 'style="width:100%"', true)
+);
+$filterTable->colspan[2][0] = 3;
+$filterTable->data[2][0] = html_print_label_input_block(
+ '',
+ ui_toggle(
+ html_print_table($advanced_toggle, true),
+ __('Advanced'),
+ '',
+ '',
true,
- false,
- 'network_report_click_period(event)'
+ true,
+ '',
+ 'white-box-content',
+ 'box-flat white_table_graph'
)
);
-echo '';
ui_toggle(
- $outputTable,
- '',
- __('Filters'),
- '',
+ $filterInputTable,
+ '',
+ __('Filter'),
+ 'search',
true,
false,
'',
- 'white-box-content',
+ 'white-box-content no_border',
'box-flat white_table_graph fixed_filter_bar'
);
html_print_action_buttons(
@@ -246,7 +378,7 @@ $data = netflow_get_top_summary(
$action,
$utimestamp_lower,
$utimestamp_greater,
- $main_value,
+ $filter,
$order_by
);
@@ -450,6 +582,26 @@ if (empty($data)) {
?>
diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php
index e3919e90b9..ff2c99869d 100644
--- a/pandora_console/operation/network/network_usage_map.php
+++ b/pandora_console/operation/network/network_usage_map.php
@@ -34,6 +34,21 @@ global $config;
check_login();
+// Ajax callbacks.
+if (is_ajax() === true) {
+ $get_filter_values = get_parameter('get_filter_values', 0);
+ // Get values of the current network filter.
+ if ($get_filter_values) {
+ $id = get_parameter('id');
+ $filter_values = db_get_row_filter('tnetwork_usage_filter', ['id' => $id]);
+ // Decode HTML entities.
+ $filter_values['advanced_filter'] = io_safe_output($filter_values['advanced_filter']);
+ echo json_encode($filter_values);
+ }
+
+ return;
+}
+
// Header.
ui_print_standard_header(
__('Network usage map'),
@@ -76,6 +91,7 @@ $is_period = (bool) get_parameter('is_period', false);
$period = (int) get_parameter('period', SECONDS_1HOUR);
$time_lower = get_parameter('time_lower', date(TIME_FORMAT, ($utimestamp_greater - $period)));
$date_lower = get_parameter('date_lower', date(DATE_FORMAT, ($utimestamp_greater - $period)));
+$advanced_filter = get_parameter('advanced_filter', '');
$utimestamp_lower = ($is_period) ? ($utimestamp_greater - $period) : strtotime($date_lower.' '.$time_lower);
if (!$is_period) {
$period = ($utimestamp_greater - $utimestamp_lower);
@@ -88,6 +104,44 @@ if (in_array($order_by, ['bytes', 'pkts', 'flows']) === false) {
$order_by = 'bytes';
}
+$save = get_parameter('save_button', '');
+$update = get_parameter('update_button', '');
+
+// Save user defined filter.
+if ($save != '' && check_acl($config['id_user'], 0, 'AW')) {
+ // Save filter args.
+ $data['filter_name'] = get_parameter('filter_name');
+ $data['top'] = $top;
+ $data['action'] = $action;
+ $data['advanced_filter'] = $advanced_filter;
+
+
+ $filter_id = db_process_sql_insert('tnetwork_usage_filter', $data);
+ if ($filter_id === false) {
+ $filter_id = 0;
+ ui_print_error_message(__('Error creating filter'));
+ } else {
+ ui_print_success_message(__('Filter created successfully'));
+ }
+} else if ($update != '' && check_acl($config['id_user'], 0, 'AW')) {
+ // Update current filter.
+ // Do not update the filter name and group.
+ $data['top'] = $top;
+ $data['action'] = $action;
+ $data['advanced_filter'] = $advanced_filter;
+
+ $result = db_process_sql_update(
+ 'tnetwork_usage_filter',
+ $data,
+ ['id' => $filter_id]
+ );
+ ui_print_result_message(
+ $result,
+ __('Filter updated successfully'),
+ __('Error updating filter')
+ );
+}
+
if ((bool) $config['activate_netflow'] === true) {
$netflow_button = html_print_submit_button(
__('Show netflow map'),
@@ -95,6 +149,27 @@ if ((bool) $config['activate_netflow'] === true) {
false,
['icon' => 'update'],
true
+ ).html_print_submit_button(
+ __('Save as new filter'),
+ 'save_button',
+ false,
+ [
+ 'icon' => 'load',
+ 'onClick' => 'return defineFilterName();',
+ 'mode' => 'mini secondary',
+ 'class' => 'mrgn_right_10px',
+ ],
+ true
+ ).html_print_submit_button(
+ __('Update current filter'),
+ 'update_button',
+ false,
+ [
+ 'icon' => 'load',
+ 'mode' => 'mini secondary',
+ 'class' => 'mrgn_right_10px',
+ ],
+ true
);
} else {
$netflow_button = '';
@@ -232,6 +307,44 @@ $filterTable->data[1][] = html_print_label_input_block(
)
);
+$advanced_toggle = new stdClass();
+$advanced_toggle->class = 'filter-table-adv';
+$advanced_toggle->size = [];
+$advanced_toggle->size[0] = '50%';
+$advanced_toggle->size[1] = '50%';
+$advanced_toggle->width = '100%';
+$user_groups = users_get_groups($config['id_user'], 'AR', $own_info['is_admin'], true);
+$user_groups[0] = 0;
+$sql = 'SELECT * FROM tnetwork_usage_filter';
+$advanced_toggle->data[0][0] = html_print_label_input_block(
+ __('Load Filter'),
+ html_print_select_from_sql($sql, 'filter_id', $filter_id, '', __('Select a filter'), 0, true, false, true, false, 'width:100%;')
+);
+$advanced_toggle->data[0][1] = html_print_label_input_block(
+ __('Filter name'),
+ html_print_input_text('filter_name', '', false, 40, 45, true, false, false, '', 'w100p')
+);
+$advanced_toggle->colspan[1][0] = 2;
+$advanced_toggle->data[1][0] = html_print_label_input_block(
+ __('Filter').ui_print_help_icon('pcap_filter', true),
+ html_print_textarea('advanced_filter', 4, 10, $advanced_filter, 'style="width:100%"', true)
+);
+$filterTable->colspan[2][0] = 3;
+$filterTable->data[2][0] = html_print_label_input_block(
+ '',
+ ui_toggle(
+ html_print_table($advanced_toggle, true),
+ __('Advanced'),
+ '',
+ '',
+ true,
+ true,
+ '',
+ 'white-box-content',
+ 'box-flat white_table_graph'
+ )
+);
+
$filterInputTable = '