diff --git a/extras/deploy-scripts/deploy_ext_database_el8.sh b/extras/deploy-scripts/deploy_ext_database_el8.sh index 422887b0e2..52bad444fe 100644 --- a/extras/deploy-scripts/deploy_ext_database_el8.sh +++ b/extras/deploy-scripts/deploy_ext_database_el8.sh @@ -9,7 +9,7 @@ # RedHat 8.5 #Constants -S_VERSION='202302081' +S_VERSION='202302201' LOGFILE="/tmp/deploy-ext-db-$(date +%F).log" @@ -275,6 +275,8 @@ EO_CONFIG_F if [ "$MYVER" -eq '80' ] ; then sed -i -e "/query_cache.*/ s/^#*/#/g" /etc/my.cnf sed -i -e "s/#skip-log-bin/skip-log-bin/g" /etc/my.cnf + sed -i -e "s/character-set-server=utf8/character-set-server=utf8mb4/g" /etc/my.cnf + fi execute_cmd "systemctl restart mysqld" "Configuring database engine" diff --git a/extras/deploy-scripts/deploy_ext_database_ubuntu_2204.sh b/extras/deploy-scripts/deploy_ext_database_ubuntu_2204.sh index a82244c3b6..45a99783ab 100644 --- a/extras/deploy-scripts/deploy_ext_database_ubuntu_2204.sh +++ b/extras/deploy-scripts/deploy_ext_database_ubuntu_2204.sh @@ -4,6 +4,7 @@ ############################################################################################################## ## Tested versions ## # Ubuntu 22.04.1 +# Ubuntu 22.04.2 #avoid promps export DEBIAN_FRONTEND=noninteractive @@ -16,7 +17,7 @@ PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf WORKDIR=/opt/pandora/deploy -S_VERSION='202302081' +S_VERSION='202302201' LOGFILE="/tmp/deploy-ext-db-$(date +%F).log" rm -f $LOGFILE &> /dev/null # remove last log before start @@ -181,7 +182,7 @@ cat > /etc/mysql/my.cnf << EOF_DB [mysqld] datadir=/var/lib/mysql user=mysql -character-set-server=utf8 +character-set-server=utf8mb4 skip-character-set-client-handshake # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 @@ -196,7 +197,7 @@ innodb_flush_log_at_trx_commit = 0 innodb_flush_method = O_DIRECT innodb_log_file_size = 64M innodb_log_buffer_size = 16M -innodb_io_capacity = 100 +innodb_io_capacity = 300 thread_cache_size = 8 thread_stack = 256K max_connections = 100 diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index 78f1ef0e41..9386d55647 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -431,7 +431,7 @@ execute_cmd "curl -LSs --output pandorafms_agent_linux-7.0NG.noarch.rpm ${PANDOR execute_cmd "yum install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "installing PandoraFMS packages" # Copy gotty utility -execute_cmd "wget https://pandorafms.com/library/wp-content/uploads/2019/11/gotty_linux_amd64.tar.gz" 'Dowloading gotty util' +execute_cmd "wget https://firefly.pandorafms.com/pandorafms/utils/gotty_linux_amd64.tar.gz" 'Dowloading gotty util' tar xvzf gotty_linux_amd64.tar.gz &>> $LOGFILE execute_cmd "mv gotty /usr/bin/" 'Installing gotty util' diff --git a/extras/deploy-scripts/pandora_deploy_community_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh index 13f90fcf85..cc14ad1ffa 100644 --- a/extras/deploy-scripts/pandora_deploy_community_el8.sh +++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh @@ -5,7 +5,7 @@ ## Tested versions ## # Centos 8.4, 8.5 # Rocky 8.4, 8.5, 8.6, 8.7 -# Almalinuz 8.4, 8.5 +# Almalinux 8.4, 8.5 # RedHat 8.5 #Constants @@ -14,7 +14,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf -S_VERSION='202301251' +S_VERSION='202302201' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" # define default variables @@ -107,6 +107,17 @@ check_root_permissions () { fi } +installing_docker () { + #Installing docker for debug + echo "Start installig docker" &>> "$LOGFILE" + dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo &>> "$LOGFILE" + dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin &>> "$LOGFILE" + systemctl disable --now docker &>> "$LOGFILE" + systemctl disable docker.socket --now &>> "$LOGFILE" + echo "End installig docker" &>> "$LOGFILE" +} + + ## Main echo "Starting PandoraFMS Community deployment EL8 ver. $S_VERSION" @@ -207,6 +218,7 @@ else execute_cmd "dnf config-manager --set-enabled powertools" "Configuring Powertools" fi +execute_cmd "installing_docker" "Installing Docker for debug" #Installing wget execute_cmd "dnf install -y wget" "Installing wget" @@ -454,7 +466,7 @@ innodb_flush_log_at_trx_commit = 0 innodb_flush_method = O_DIRECT innodb_log_file_size = 64M innodb_log_buffer_size = 16M -innodb_io_capacity = 100 +innodb_io_capacity = 300 thread_cache_size = 8 thread_stack = 256K max_connections = 100 @@ -483,6 +495,7 @@ EO_CONFIG_F if [ "$MYVER" -eq '80' ] ; then sed -i -e "/query_cache.*/ s/^#*/#/g" /etc/my.cnf sed -i -e "s/#skip-log-bin/skip-log-bin/g" /etc/my.cnf + sed -i -e "s/character-set-server=utf8/character-set-server=utf8mb4/g" /etc/my.cnf fi execute_cmd "systemctl restart mysqld" "Configuring database engine" @@ -517,7 +530,7 @@ execute_cmd "curl -LSs --output pandorafms_agent_linux-7.0NG.noarch.rpm ${PANDOR execute_cmd "dnf install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "Installing Pandora FMS packages" # Copy gotty utility -execute_cmd "wget https://pandorafms.com/library/wp-content/uploads/2019/11/gotty_linux_amd64.tar.gz" 'Dowloading gotty util' +execute_cmd "wget https://firefly.pandorafms.com/pandorafms/utils/gotty_linux_amd64.tar.gz" 'Dowloading gotty util' tar xvzf gotty_linux_amd64.tar.gz &>> $LOGFILE execute_cmd "mv gotty /usr/bin/" 'Installing gotty util' @@ -743,7 +756,7 @@ execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent" cat > /etc/issue.net << EOF_banner -Welcome to Pandora FMS appliance on CentOS +Welcome to Pandora FMS appliance on RHEL/Rocky Linux 8 ------------------------------------------ Go to Public http://$ipplublic/pandora_console$to to login web console $(ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v "172.17.0.1" | awk '{print $2}' | awk -F '/' '{print "Go to Local http://"$1"/pandora_console to login web console"}') diff --git a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh index b22d5d163f..1446abfab3 100644 --- a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh +++ b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh @@ -4,6 +4,7 @@ ############################################################################################################## ## Tested versions ## # Ubuntu 22.04.1 +# Ubuntu 22.04.2 #avoid promps export DEBIAN_FRONTEND=noninteractive @@ -16,7 +17,7 @@ PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf WORKDIR=/opt/pandora/deploy -S_VERSION='202301251' +S_VERSION='202302201' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" rm -f $LOGFILE &> /dev/null # remove last log before start @@ -106,6 +107,21 @@ check_root_permissions () { fi } +installing_docker () { + #Installing docker for debug + echo "Start installig docker" &>> "$LOGFILE" + mkdir -m 0755 -p /etc/apt/keyrings &>> "$LOGFILE" + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --yes --dearmor -o /etc/apt/keyrings/docker.gpg &>> "$LOGFILE" + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list &>> "$LOGFILE" + apt update -y &>> "$LOGFILE" + apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin &>> "$LOGFILE" + systemctl disable docker --now &>> "$LOGFILE" + systemctl disable docker.socket --now &>> "$LOGFILE" + echo "End installig docker" &>> "$LOGFILE" +} + ## Main echo "Starting PandoraFMS Community deployment Ubuntu 22.04 ver. $S_VERSION" @@ -173,7 +189,7 @@ execute_cmd "cd $WORKDIR" "Moving to workdir: $WORKDIR" ## Install utils execute_cmd "apt update" "Updating repos" -execute_cmd "apt install -y net-tools vim curl wget software-properties-common apt-transport-https" "Installing utils" +execute_cmd "apt install -y net-tools vim curl wget software-properties-common apt-transport-https ca-certificates gnupg lsb-release" "Installing utils" #Installing Apache and php-fpm [ -e "/etc/apt/sources.list.d/ondrej-ubuntu-php-jammy.list" ] || execute_cmd "add-apt-repository ppa:ondrej/php -y" "Enable ppa:ondrej/php repo" @@ -221,7 +237,8 @@ systemctl restart php$PHPVER-fpm &>> "$LOGFILE" php$PHPVER-xml \ php$PHPVER-yaml \ libnet-telnet-perl \ - whois" + whois \ + cron" execute_cmd "apt install -y $console_dependencies" "Installing Pandora FMS Console dependencies" # Server dependencies @@ -254,10 +271,13 @@ server_dependencies=" \ libnet-telnet-perl \ libjson-perl \ libencode-perl \ + cron \ libgeo-ip-perl \ openjdk-8-jdk " execute_cmd "apt install -y $server_dependencies" "Installing Pandora FMS Server dependencies" +execute_cmd "installing_docker" "Installing Docker for debug" + # wmic and pandorawmic execute_cmd "curl -O https://firefly.artica.es/pandorafms/utils/bin/wmic" "Downloading wmic" execute_cmd "curl -O https://firefly.artica.es/pandorafms/utils/bin/pandorawmic" "Downloading pandorawmic" @@ -393,7 +413,7 @@ cat > /etc/mysql/my.cnf << EOF_DB [mysqld] datadir=/var/lib/mysql user=mysql -character-set-server=utf8 +character-set-server=utf8mb4 skip-character-set-client-handshake # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 @@ -408,7 +428,7 @@ innodb_flush_log_at_trx_commit = 0 innodb_flush_method = O_DIRECT innodb_log_file_size = 64M innodb_log_buffer_size = 16M -innodb_io_capacity = 100 +innodb_io_capacity = 300 thread_cache_size = 8 thread_stack = 256K max_connections = 100 @@ -477,7 +497,7 @@ check_cmd_status "Error installing PandoraFMS Agent" # Copy gotty utility cd $WORKDIR &>> "$LOGFILE" -execute_cmd "wget https://pandorafms.com/library/wp-content/uploads/2019/11/gotty_linux_amd64.tar.gz" 'Dowloading gotty util' +execute_cmd "wget https://firefly.pandorafms.com/pandorafms/utils/gotty_linux_amd64.tar.gz" 'Dowloading gotty util' tar xvzf gotty_linux_amd64.tar.gz &>> $LOGFILE execute_cmd "mv gotty /usr/bin/" 'Installing gotty util' @@ -731,10 +751,15 @@ systemctl enable pandora_server &>> "$LOGFILE" execute_cmd "service tentacle_serverd start" "Starting Tentacle Server" systemctl enable tentacle_serverd &>> "$LOGFILE" -# Enabling condole cron +# Enabling console cron execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron" echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab +# Enabling pandoradb cron +execute_cmd "echo 'enabling pandoradb cron' >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS pandoradb cron" +echo "@hourly root bash -c /etc/cron.hourly/pandora_db" >> /etc/crontab + + ## Enabling agent adn configuring Agente sed -i "s/^remote_config.*$/remote_config 1/g" $PANDORA_AGENT_CONF &>> "$LOGFILE" execute_cmd "/etc/init.d/pandora_agent_daemon start" "Starting PandoraFSM Agent" @@ -748,7 +773,7 @@ sed --follow-symlinks -i -e "s/^openssl_conf = openssl_init/#openssl_conf = open cat > /etc/issue.net << EOF_banner -Welcome to Pandora FMS appliance on CentOS +Welcome to Pandora FMS appliance on Ubuntu ------------------------------------------ Go to Public http://$ipplublic/pandora_console$to to login web console $(ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v "172.17.0.1" | awk '{print $2}' | awk -F '/' '{print "Go to Local http://"$1"/pandora_console to login web console"}') diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index c8512ffc13..9af85a5200 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.768, AIX version +# Version 7.0NG.769, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index c98b6c4f48..6650404c74 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.768, FreeBSD Version +# Version 7.0NG.769, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index a17181b6c2..957396affa 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.768, HP-UX Version +# Version 7.0NG.769, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 7eea50cdac..dac6aefc04 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.768, GNU/Linux +# Version 7.0NG.769, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index ed7aae82b3..a12c8ccce7 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.768, GNU/Linux +# Version 7.0NG.769, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index 8c189f05bf..75ff20dba4 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.768, Solaris Version +# Version 7.0NG.769, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 46a569686d..6fca0a4523 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2021 Artica Soluciones Tecnologicas -# Version 7.0NG.768 +# Version 7.0NG.769 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software # Foundation; either version 2 of the Licence or any later version diff --git a/pandora_agents/pc/pandora_agent.redhat.spec b/pandora_agents/pc/pandora_agent.redhat.spec index ae481e3403..ce60c8841f 100644 --- a/pandora_agents/pc/pandora_agent.redhat.spec +++ b/pandora_agents/pc/pandora_agent.redhat.spec @@ -1,6 +1,7 @@ # #Pandora FMS Linux Agent # +%global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 4.0 %define release 1 diff --git a/pandora_agents/pc/pandora_agent.spec b/pandora_agents/pc/pandora_agent.spec index 1bfc289d52..5ad481315a 100644 --- a/pandora_agents/pc/pandora_agent.spec +++ b/pandora_agents/pc/pandora_agent.spec @@ -1,6 +1,7 @@ # #Pandora FMS Linux Agent # +%global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 4.0.1 %define release 1 diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index a723aa503b..e47ec5442a 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.768, AIX version +# Version 7.0NG.769, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index e8dd39e1d2..bc353d4077 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.768 +# Version 7.0NG.769 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index 6b4ea56e3d..7e9f290fd0 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.768, HPUX Version +# Version 7.0NG.769, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 5ca49a15e1..674d2a3992 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.768 +# Version 7.0NG.769 # Licensed under GPL license v2, # (c) 2003-2021 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/linux/pandora_agent.spec b/pandora_agents/shellscript/linux/pandora_agent.spec index 64b33bfecf..9c5e0296c6 100755 --- a/pandora_agents/shellscript/linux/pandora_agent.spec +++ b/pandora_agents/shellscript/linux/pandora_agent.spec @@ -1,6 +1,7 @@ # #Pandora FMS Linux Agent # +%global __os_install_post %{nil} %define name pandorafms_agent %define version 3.2 Summary: Pandora FMS Linux agent diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index b26ec72942..9654e1f2ee 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.768 +# Version 7.0NG.769 # Licensed under GPL license v2, # (c) 2003-2021 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index b9b09e0f02..4fc7cf3202 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.768 +# Version 7.0NG.769 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index 20036302b7..2113795918 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.768, Solaris version +# Version 7.0NG.769, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index e2050f1a5c..b02f88017e 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.768, AIX version +# Version 7.0NG.769, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index dea82407ab..a39c7bab9d 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.768-230215 +Version: 7.0NG.769-230317 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 2af63d3531..791388a3f6 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.768-230215" +pandora_version="7.0NG.769-230317" 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/Darwin/dmg/build_darwin_dmg.sh b/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh index fd449c646b..b8862d3ee9 100644 --- a/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh +++ b/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh @@ -31,7 +31,7 @@ fi if [ "$#" -ge 2 ]; then VERSION="$2" else - VERSION="7.0NG.768" + VERSION="7.0NG.769" fi # Path for the generated DMG file diff --git a/pandora_agents/unix/Darwin/dmg/extras/distribution.xml b/pandora_agents/unix/Darwin/dmg/extras/distribution.xml index 4e4b347f08..f1aebe06a1 100644 --- a/pandora_agents/unix/Darwin/dmg/extras/distribution.xml +++ b/pandora_agents/unix/Darwin/dmg/extras/distribution.xml @@ -19,11 +19,11 @@ - pandorafms_src.pdk + pandorafms_src.pdk - pandorafms_uninstall.pdk + pandorafms_uninstall.pdk - - - - diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index bb9fa19185..6816c99317 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -30,16 +30,21 @@ require_once __DIR__.'/../include/functions_html.php'; if ($config['visual_animation']) { echo ''; } @@ -87,18 +92,36 @@ if (!empty($page) && !empty($sec)) { } $login_body_style = ''; -$login_body_class = ''; // Overrides the default background with the defined by the user. -if (!empty($config['login_background'])) { +$background_url = 'images/backgrounds/background_pandora_console_keys.jpg'; + +if (empty($config['random_background']) === false) { + $random_backgrounds = scandir($config['homedir'].'/images/backgrounds/random_backgrounds'); + unset($random_backgrounds[0], $random_backgrounds[1]); + $random_background = array_rand($random_backgrounds); + $background_url = 'images/backgrounds/random_backgrounds/'.$random_backgrounds[$random_background]; + $background_100 = 'background-size: 100% 100% !important; '; +} + +if (empty($config['login_background']) === false) { $background_url = 'images/backgrounds/'.$config['login_background']; - $login_body_style = "style=\"background-size: 100% 100% !important;background:linear-gradient(74deg, rgba(2, 2, 2, 0.333) 36%, transparent 36%), url('".$background_url."');\""; + $background_100 = 'background-size: 100% 100% !important; '; } // Support for Internet Explorer and Microsoft Edge browsers if (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false) { - $login_body_class = "class='login_body_trident'"; + $background_url = 'images/backgrounds/background_pandora_console_keys.jpg'; + $background_100 = ''; } +if (empty($config['background_opacity']) === false) { + $opacity = $config['background_opacity']; +} else { + $opacity = 30; +} + +$login_body_style = 'style="'.$background_100.'background: linear-gradient(rgba(0,0,0,.'.$opacity.'), rgba(0,0,0,.'.$opacity.")), url('".$background_url."');\""; + // Get alternative custom in case of db fail. $custom_fields = [ 'custom_logo_login', @@ -123,36 +146,36 @@ foreach ($custom_fields as $field) { // Get the custom icons. $docs_logo = ui_get_docs_logo(); $support_logo = ui_get_support_logo(); -echo '
'; +echo '
'; echo '
'; echo '
'; @@ -248,15 +271,30 @@ switch ($login_screen) { echo '
'; echo ''; echo ''; echo ''; } else { echo ''; echo ''; } break; @@ -302,12 +348,13 @@ switch ($login_screen) { echo ''; echo ''; break; @@ -337,17 +384,18 @@ if ($config['enterprise_installed']) { echo ''.__('Forgot your password?'); echo ''; - echo ''; + echo '
'; echo '
'; - html_print_submit_button('Ok', 'reset_correct_button', false); + html_print_submit_button('Ok', 'reset_correct_button', false, ['class' => 'mini float-right']); echo '
'; echo '
'; echo '
'; echo ''; } else if (isset($process_error_message) && !empty($process_error_message)) { - echo '
'; + echo '
'; echo '
'; echo '
'; - echo html_print_image('images/icono_stop.png', true, ['alt' => __('Password reset'), 'border' => 0]); + echo html_print_image('images/icono_stop.png', true, ['alt' => __('Forbidden'), 'border' => 0]); echo '
'; echo '
'; echo '
'; echo '

'.__('ERROR').'

'; echo '

'.$process_error_message.'

'; + echo '
'; echo '
'; + echo '
'; echo '
'; - html_print_submit_button('Ok', 'reset_correct_button', false); + html_print_submit_button('Ok', 'reset_correct_button', false, ['class' => 'mini float-right']); echo '
'; echo '
'; echo '
'; @@ -472,8 +552,9 @@ if (isset($correct_reset_pass_process)) { echo '

'.__('SUCCESS').'

'; echo '

'.$correct_reset_pass_process.'

'; echo '
'; + echo '
'; echo '
'; - html_print_submit_button('Ok', 'final_process_correct_button', false); + html_print_submit_button('Ok', 'final_process_correct_button', false, ['class' => 'mini float-right']); echo '
'; echo '
'; echo ''; @@ -481,9 +562,36 @@ if (isset($correct_reset_pass_process)) { } if (isset($login_failed)) { - $nick = get_parameter_post('nick'); - $fails = db_get_value('failed_attempt', 'tusuario', 'id_user', $nick); + $nick = io_safe_input(get_parameter_post('nick')); + $user_in_db = db_get_row_filter( + 'tusuario', + ['id_user' => $nick], + '*' + ); + $fails = $user_in_db['failed_attempt']; + // If user not exist, and attempts its enable, lets make array and fails attemps. + if ($fails == false && $config['enable_pass_policy'] && $user_in_db === false) { + $nick_array_error = json_decode(base64_decode($config['nicks_error']), true); + $nick = strtolower($nick); + if (isset($nick_array_error[$nick]) !== false) { + $nick_array_error[$nick] += 1; + } else { + $nick_array_error[$nick] = 1; + } + + $fails = $nick_array_error[$nick]; + // Save or update the array. + if ($config['nicks_error']) { + config_update_value('nicks_error', base64_encode(json_encode($nick_array_error))); + } else { + config_create_value('nicks_error', base64_encode(json_encode($nick_array_error))); + } + } else { + $fails = ++$fails; + } + $attemps = ($config['number_attempts'] - $fails); + $attemps = ($attemps < 0) ? 0 : $attemps; echo '
'; echo '
'; echo '
'; @@ -496,12 +604,18 @@ if (isset($login_failed)) { echo '
'; if ($config['enable_pass_policy']) { echo '
'; - echo '

Remaining attempts: '.$attemps.'

'; + if ($attemps !== 0 && $user_in_db['login_blocked'] == 0) { + echo '

'.__('Remaining attempts: ').$attemps.'

'; + } else { + echo '

'.__('User is blocked').'

'; + } + echo '
'; } + echo '
'; echo '
'; - html_print_submit_button('Ok', 'hide-login-error', false); + html_print_submit_button('Ok', 'hide-login-error', false, ['class' => ' mini float-right']); echo '
'; echo '
'; echo '
'; @@ -524,8 +638,9 @@ if ($login_screen == 'logout') { } echo ''; + echo '
'; echo '
'; - html_print_submit_button('Ok', 'hide-login-logout', false); + html_print_submit_button('Ok', 'hide-login-logout', false, ['class' => ' mini float-right']); echo '
'; echo ''; echo ''; @@ -543,8 +658,9 @@ if ($login_screen === 'disabled_access_node') { echo '

'.__('Centralized user in metaconsole').'

'; echo '

'.__('This user does not have access on node, please enable node access on this user from metaconsole.').'

'; echo ''; + echo '
'; echo '
'; - html_print_submit_button('Ok', 'hide-login-logout', false); + html_print_submit_button('Ok', 'hide-login-logout', false, ['class' => 'mini float-right']); echo '
'; echo ''; echo ''; @@ -651,8 +767,9 @@ if ($login_screen == 'error_authconfig' || $login_screen == 'error_emptyconfig' echo '

'.$title.'

'; echo '

'.$message.''; echo ''; + echo '
'; echo '

'; - html_print_submit_button('Ok', 'hide-login-error', false); + html_print_submit_button('Ok', 'hide-login-error', false, ['class' => 'mini float-right']); echo '
'; echo ''; echo ''; @@ -707,7 +824,7 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' }); }); - $("#submit-hide-login-error").click (function () { + $("#button-hide-login-error").click (function () { $("#modal_alert" ).dialog('close'); }); @@ -722,19 +839,23 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 220, width: 528, clickOutside: true, overlay: { opacity: 0.5, background: "black" + }, + open: function (event, ui) { + $(".ui-widget-overlay").click(function () { + $('#login_logout').dialog('close'); + }); } }); }); - $("#submit-hide-login-logout").click (function () { - document.location = ""; - }); + $("#button-hide-login-logout").click (function () { + $( "#login_logout" ).dialog( "close" ); + }); }); break; @@ -745,7 +866,6 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 220, width: 528, clickOutside: true, overlay: { @@ -755,7 +875,7 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' }); }); - $("#submit-hide-login-logout").click (function () { + $("#button-hide-login-logout").click (function () { document.location = ""; }); }); @@ -769,7 +889,6 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 400, width: 700, overlay: { opacity: 0.5, @@ -787,8 +906,8 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 220, - width: 528, + height: 230, + width: 530, overlay: { opacity: 0.5, background: "black" @@ -796,12 +915,11 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' }); }); - $("#submit-hide-login-error").click (function () { + $("#button-hide-login-error").click (function () { $("#login_failed" ).dialog('close'); $("#login_correct_pass").dialog('close'); }); }); - $('#nick').focus(); break; } @@ -812,7 +930,6 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 220, width: 528, clickOutside: true, overlay: { @@ -822,7 +939,7 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' }); }); - $("#submit-reset_correct_button").click (function () { + $("#button-reset_correct_button").click (function () { $("#reset_correct").dialog('close'); }); }); @@ -833,7 +950,6 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 220, width: 528, clickOutside: true, overlay: { @@ -853,7 +969,6 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 220, width: 528, overlay: { opacity: 0.5, @@ -866,5 +981,18 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' }); } + $(document).ready(function () { + $('#submit-login_button span').removeAttr('style'); + $('#spinner_login').hide(); + }); + + $('#submit-login_button').click(function (e) { + $('.login_nick').hide(); + $('.login_pass').hide(); + $('.login_button').hide(); + $('.reset_password').hide(); + $('#spinner_login').show(); + }); + /* ]]> */ diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index 972e6f37ca..2b88b6a103 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -124,8 +124,14 @@ foreach ($stats as $stat) { } $status .= ''; +$table->rowclass = []; +$table->rowclass[0] = 'w100p'; +$table->rowclass[1] = 'w100p'; +$table->rowclass[2] = 'w100p'; +$table->rowclass[3] = 'w100p'; +$table->rowclass[4] = 'w100p'; +$table->rowclass[5] = 'w100p'; $table->data[0][0] = $status; -$table->rowclass[] = ''; $table->data[] = $tdata; diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index 3ce49b646a..1f9a204d95 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas * Please see http://pandorafms.org for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -26,38 +26,21 @@ * ============================================================================ */ -use function PHPSTORM_META\map; - // Begin. if (isset($config['id_user']) === false) { include 'general/login_page.php'; exit(); } -?> - -', $menuTypeClass); + $url_logo = ui_get_full_url('index.php'); if (is_reporting_console_node() === true) { $url_logo = 'index.php?logged=1&sec=discovery&sec2=godmode/servers/discovery&wiz=tasklist'; @@ -76,311 +59,401 @@ html_print_div( ), ], true - ), + ).'
', ] ); -require 'operation/menu.php'; -require 'godmode/menu.php'; +$display_classic = ''; +$display_collapsed = 'display: none;'; +if ($menuTypeClass === 'collapsed') { + $display_classic = 'display: none;'; + $display_collapsed = ''; +} -html_print_div( - [ - 'id' => 'button_collapse', - 'class' => sprintf('button_collapse button_%s', $menuTypeClass), - ] -); + +// Tabs. +echo ''; -// Menu_container. -ui_require_jquery_file('cookie'); -$config_fixed_header = false; -if (isset($config['fixed_header']) === true) { - $config_fixed_header = $config['fixed_header']; -} +echo '
'; +require 'operation/menu.php'; +echo '
'; +echo '
'; +require 'godmode/menu.php'; +echo '
'; +echo ''; ?> - - - diff --git a/pandora_console/general/mysqlerr.php b/pandora_console/general/mysqlerr.php index fe24117d3a..6368122da3 100644 --- a/pandora_console/general/mysqlerr.php +++ b/pandora_console/general/mysqlerr.php @@ -1,167 +1,77 @@ - - - - - - -
- -
- - - - /images/icono_cerrar.png'> -
- -
- /images/mysqlerr.png'> -
- -
-
- $value) { - if (preg_match('/._alt/i', $key)) { - $custom_conf_enabled = true; - break; - } +$custom_conf_enabled = false; +foreach ($config as $key => $value) { + if (preg_match('/._alt/i', $key)) { + $custom_conf_enabled = true; + break; } +} - if (!$custom_conf_enabled || isset($config['custom_docs_url_alt'])) { - if (isset($config['custom_docs_url_alt'])) { - $docs_url = $config['custom_docs_url_alt']; - } else { - $docs_url = 'https://pandorafms.com/manual/en/documentation/02_installation/04_configuration'; - } - - echo ' - -
- '.__('Documentation').' - -
-
- '; +if (empty($custom_conf_enabled) === true || isset($config['custom_docs_url_alt']) === true) { + if (isset($config['custom_docs_url_alt']) === true) { + $docs_url = $config['custom_docs_url_alt']; + } else { + $docs_url = 'https://pandorafms.com/manual/en/documentation/02_installation/04_configuration'; } +} + +echo '
'; + echo '
'; + echo '
'; + echo html_print_image('images/mysqlerr.png', true, ['alt' => __('Mysql error'), 'border' => 0]); + echo '
'; + echo '
'; + echo '
'; + echo '

'.__('Database error').'

'; + echo '

'.$message.'

'; + echo '
'; + echo '
'; + echo '
'; + html_print_submit_button( + __('Documentation'), + 'mysqlerr_button', + false, + ['class' => 'mini float-right'] + ); + echo '
'; + echo '
'; + echo '
'; + echo '
'; + ?> - ?> - - - -
- -
- - - diff --git a/pandora_console/general/pandora_help.php b/pandora_console/general/pandora_help.php index 9d0a5e79d6..c78c006a9f 100644 --- a/pandora_console/general/pandora_help.php +++ b/pandora_console/general/pandora_help.php @@ -77,7 +77,7 @@ if (! $id || ! file_exists($help_file)) { echo '
'.__("%s help system has been called with a help reference that currently don't exist. There is no help content to show.", get_product_name()).'
'; echo '

'; echo ''; echo ''; ?> diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php index 1c8249ddf5..8714d1ec12 100644 --- a/pandora_console/general/register.php +++ b/pandora_console/general/register.php @@ -31,6 +31,7 @@ global $config; require_once $config['homedir'].'/include/functions_register.php'; require_once $config['homedir'].'/include/class/WelcomeWindow.class.php'; +require_once $config['homedir'].'/include/class/TipsWindow.class.php'; if ((bool) is_ajax() === true) { @@ -109,6 +110,16 @@ try { $welcome = false; } +try { + if (isset($_SESSION['showed_tips_window']) === false) { + $tips_window = new TipsWindow(); + if ($tips_window !== null) { + $tips_window->run(); + } + } +} catch (Exception $e) { +} + $double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $config['id_user']); if (isset($config['2FA_all_users']) === false) { diff --git a/pandora_console/godmode/agentes/agent_conf_gis.php b/pandora_console/godmode/agentes/agent_conf_gis.php index 6b80ed752a..460f977b9e 100644 --- a/pandora_console/godmode/agentes/agent_conf_gis.php +++ b/pandora_console/godmode/agentes/agent_conf_gis.php @@ -59,81 +59,112 @@ ui_print_warning_message( ] ); -$table = new StdClass(); +$table = new stdClass(); $table->width = '100%'; -$table->class = 'databox filters'; +$table->class = 'databox filter-table-adv mrgn_top_15px pdd_t_0px_important'; $table->data = []; $table->cellpadding = 0; $table->cellspacing = 0; $table->head[0] = __('Agent position'); $table->head_colspan[0] = 4; $table->headstyle[0] = 'text-align:center'; -$table->style[0] = 'font-weight: bold; '; -$table->style[2] = 'font-weight: bold; '; +$table->size[0] = '50%'; +$table->size[2] = '50%'; -$table->data[1][0] = __('Latitude: '); -$table->data[1][1] = html_print_input_text_extended( - 'latitude', - $agentData['stored_latitude'], - 'text-latitude', - '', - 20, - 20, - false, - '', - [ - 'onchange' => 'setIgnoreGISDataEnabled()', - 'onkeyup' => 'setIgnoreGISDataEnabled()', - ], - true +$table->data[1][0] = html_print_label_input_block( + __('Latitude: '), + html_print_input_text_extended( + 'latitude', + $agentData['stored_latitude'], + 'text-latitude', + '', + 20, + 20, + false, + '', + [ + 'onchange' => 'setIgnoreGISDataEnabled()', + 'onkeyup' => 'setIgnoreGISDataEnabled()', + ], + true + ) ); -$table->data[1][2] = __('Longitude: '); -$table->data[1][3] = html_print_input_text_extended( - 'longitude', - $agentData['stored_longitude'], - 'text-longitude', - '', - 20, - 20, - false, - '', - [ - 'onchange' => 'setIgnoreGISDataEnabled()', - 'onkeyup' => 'setIgnoreGISDataEnabled()', - ], - true +$table->data[1][1] = html_print_label_input_block( + __('Longitude: '), + html_print_input_text_extended( + 'longitude', + $agentData['stored_longitude'], + 'text-longitude', + '', + 20, + 20, + false, + '', + [ + 'onchange' => 'setIgnoreGISDataEnabled()', + 'onkeyup' => 'setIgnoreGISDataEnabled()', + ], + true + ) ); -$table->data[2][0] = __('Altitude: '); -$table->data[2][1] = html_print_input_text_extended( - 'altitude', - $agentData['stored_altitude'], - 'text-altitude', - '', - 10, - 10, - false, - '', - [ - 'onchange' => 'setIgnoreGISDataEnabled()', - 'onkeyup' => 'setIgnoreGISDataEnabled()', - ], - true +$table->data[2][0] = html_print_label_input_block( + __('Altitude: '), + html_print_input_text_extended( + 'altitude', + $agentData['stored_altitude'], + 'text-altitude', + '', + 10, + 10, + false, + '', + [ + 'onchange' => 'setIgnoreGISDataEnabled()', + 'onkeyup' => 'setIgnoreGISDataEnabled()', + ], + true + ) ); -$table->data[2][2] = __('Ignore new GIS data:'); -$table->data[2][3] = __('Yes').' '.html_print_radio_button_extended('update_gis_data', 0, '', $updateGisData, false, '', 'class="mrgn_right_40px"', true); -$table->data[2][3] .= __('No').' '.html_print_radio_button_extended('update_gis_data', 1, '', $updateGisData, false, '', 'class="mrgn_right_40px"', true); +$table->data[2][1] = html_print_label_input_block( + __('Ignore new GIS data: '), + '
'.__('Yes').' '.html_print_radio_button_extended( + 'update_gis_data', + 0, + '', + $updateGisData, + false, + '', + 'class="mrgn_right_40px"', + true + ).__('No').' '.html_print_radio_button_extended( + 'update_gis_data', + 1, + '', + $updateGisData, + false, + '', + 'class="mrgn_right_40px"', + true + ).'
' +); $url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=gis&id_agente='.$id_agente; -echo "
"; +echo ""; html_print_input_hidden('update_gis', 1); html_print_table($table); -echo '
'; -html_print_submit_button(__('Update'), '', false, 'class="sub upd"'); -echo '
'; +html_print_action_buttons( + html_print_submit_button( + __('Update'), + '', + false, + ['icon' => 'wand'], + true + ) +); echo '
'; ?> - 'delete', + 'mode' => 'secondary', + ], + true + ); + $actionButtons .= html_print_input_hidden('update_module', 1, true); + $actionButtons .= html_print_input_hidden('id_agent_module', $id_agent_module, true); + $actionButtons .= html_print_input_hidden('id_module_type', $id_module_type, true); } else { - html_print_submit_button( + $actionButtons = html_print_submit_button( __('Create'), 'crtbutton', false, - 'class="sub wand"' + [ 'icon' => 'wand' ], + true ); - html_print_input_hidden('id_module', $moduletype); - html_print_input_hidden('create_module', 1); - if ($config['enterprise_installed'] && $remote_conf) { - ?> - - '; -echo ''; +$actionButtons .= html_print_go_back_button( + 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente, + ['button_class' => ''], + true +); + +$outputForm .= html_print_action_buttons( + $actionButtons, + ['type' => 'form_action'], + true +); + +if ((bool) $config['enterprise_installed'] === true && $remote_conf === true) { + $outputForm .= ''; +} + +$outputForm .= ''; + +html_print_div( + [ + 'class' => 'max_floating_element_size', + 'content' => $outputForm, + ], + false +); ui_require_jquery_file('ui'); ui_require_jquery_file('form'); diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index d1c615de96..0231245274 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -1,8 +1,8 @@ '; - $data[1] .= html_print_select( + $data[0] = ''; + $data[0] .= html_print_select( $component_groups, 'network_component_group', '', @@ -119,15 +119,13 @@ function add_component_selection($id_network_component_type) 0, true, false, - false + false, + 'w50p' ); - $data[1] .= ''; - $data[1] .= html_print_input_hidden('id_module_component_type', $id_network_component_type, true); - $data[1] .= ''; - $data[1] .= ''; + $data[1] = ''; + $data[1] = ''; - $data[1] .= ' '; + $data[1] .= ''; + $data[1] .= html_print_input_hidden('id_module_component_type', $id_network_component_type, true); - $table_simple->colspan['module_component'][1] = 3; - $table_simple->rowstyle['module_component'] = $background_row; + $table_simple->rowstyle['module_component'] = $background_row.'; padding-bottom: 10px; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;'; prepend_table_simple($data, 'module_component'); + + $data = []; + $data[0] = __('Using module component').' '; + $table_simple->rowstyle['caption_module_component'] = $background_row.'; padding-top: 5px; border-top-left-radius: 8px; border-top-right-radius: 8px;'; + prepend_table_simple($data, 'caption_module_component'); } @@ -163,8 +162,9 @@ $disabledBecauseInPolicy = false; $disabledTextBecauseInPolicy = ''; $largeClassDisabledBecauseInPolicy = ''; -$page = get_parameter('page', ''); - +$update_module_id = (int) get_parameter_get('update_module'); +$edit_module = (bool) get_parameter_get('edit_module'); +$page = get_parameter('page', ''); $in_policies_page = strstr($page, 'policy_modules'); if ($in_policies_page === false && $id_agent_module) { @@ -190,59 +190,18 @@ if ($disabledBecauseInPolicy) { $classdisabledBecauseInPolicy = ''; } -$update_module_id = (int) get_parameter_get('update_module'); -$edit_module = (bool) get_parameter_get('edit_module'); -$table_simple = new stdClass(); -$table_simple->id = 'simple'; -$table_simple->width = '100%'; -$table_simple->class = 'no-class'; -$table_simple->data = []; -$table_simple->style = []; -$table_simple->style[0] = 'font-weight: bold; width: 25%;'; -$table_simple->style[1] = 'width: 25%'; -$table_simple->style[2] = 'font-weight: bold; width: 25%;'; -$table_simple->style[3] = 'width: 25%'; -$table_simple->cellclass = []; - -$table_simple->colspan = []; - -$table_simple->rowspan = []; - -$table_simple->rowspan[2][2] = 3; -$table_simple->colspan[2][2] = 2; -$table_simple->colspan[3][1] = 3; - -$table_simple->data[0][0] = __('Name'); -$table_simple->data[0][1] = html_print_input_text_extended( - 'name', - $name, - 'text-name', - '', - 45, - 100, - $disabledBecauseInPolicy, - '', - $largeClassDisabledBecauseInPolicy, - true -); - -if (!empty($id_agent_module) && isset($id_agente)) { - $table_simple->data[0][1] .= ' '.__('ID').'  '.$id_agent_module.' '; - - $table_simple->data[0][1] .= ' '; - $table_simple->data[0][1] .= html_print_image( - 'images/cross.png', - true, +if (empty($id_agent_module) === false && isset($id_agente) === true) { + $moduleIdContent = html_print_div( [ - 'title' => __('Delete module'), - 'class' => 'invert_filter', - ] + 'class' => 'moduleIdBox', + 'content' => __('ID').' '.$id_agent_module.'', + ], + true ); - $table_simple->data[0][1] .= ' '; +} else { + $moduleIdContent = ''; } -$disabled_enable = 0; $policy_link = db_get_value( 'policy_linked', 'tagente_modulo', @@ -250,20 +209,91 @@ $policy_link = db_get_value( $id_agent_module ); -if ($policy_link != 0) { +if ((int) $policy_link !== 0) { $disabled_enable = 1; +} else { + $disabled_enable = 0; } -$table_simple->data[0][2] = __('Disabled'); -$table_simple->data[0][2] .= html_print_checkbox( +if ((isset($id_agent_module) === true && $id_agent_module > 0) || (int) $id_policy_module !== 0) { + $edit = false; +} else { + $edit = true; +} + +$table_simple = new stdClass(); +$table_simple->id = 'simple'; +$table_simple->styleTable = 'border-radius: 8px;'; +$table_simple->class = 'w100p floating_form'; +$table_simple->data = []; +$table_simple->style = []; +$table_simple->cellclass = []; +$table_simple->colspan = []; +$table_simple->rowspan = []; +$table_simple->cellpadding = 2; +$table_simple->cellspacing = 0; +$table_simple->rowspan[3][2] = 3; +$table_simple->rowspan[4][2] = 3; +// Special configuration for some rows. +$table_simple->rowclass['caption_target_ip'] = 'field_half_width pdd_t_10px'; +$table_simple->rowclass['target_ip'] = 'field_half_width'; +$table_simple->rowclass['caption_tcp_send_receive'] = 'field_half_width pdd_t_10px'; +$table_simple->rowclass['tcp_send_receive'] = 'field_half_width'; +$table_simple->rowclass['caption_configuration_data'] = 'field_half_width pdd_t_10px'; +$table_simple->rowclass['textarea_configuration_data'] = 'field_half_width'; +$table_simple->rowclass['configuration_data'] = 'field_half_width'; +$table_simple->cellstyle['configuration_data'][0] = 'justify-content: flex-end;padding-top: 10px;'; +$table_simple->rowclass['textarea_web_checks'] = 'field_half_width'; +$table_simple->rowclass['buttons_web_checks'] = 'field_half_width'; +$table_simple->cellstyle['buttons_web_checks'][0] = 'justify-content: flex-end;padding-top: 10px;'; + +$table_simple->rowclass['caption_module_name'] = 'field_half_width pdd_t_10px'; +$table_simple->rowclass['module_name'] = 'field_half_width'; +$table_simple->data['caption_module_name'][0] = __('Name'); +$table_simple->data['caption_module_name'][1] = __('Disabled'); +$table_simple->data['module_name'][0] = html_print_input_text_extended( + 'name', + $name, + 'text-name', + '', + 65, + 100, + $disabledBecauseInPolicy, + '', + $largeClassDisabledBecauseInPolicy, + true +).$moduleIdContent; + +$table_simple->data['module_name'][1] = html_print_checkbox_switch( 'disabled', 1, $disabled, true, $disabled_enable ); -$table_simple->data[0][3] = __('Module group'); -$table_simple->data[0][3] .= html_print_select_from_sql( +/* + html_print_checkbox( + 'disabled', + 1, + $disabled, + true, + $disabled_enable, + '', + false, + '', + '', + 'style="margin-left: 5px;"' + ); +*/ +// Caption for Module group and Type. +$table_simple->rowclass['captions_module_n_type'] = 'field_half_width pdd_t_10px'; +$table_simple->rowclass['module_n_type'] = 'field_half_width'; +$table_simple->data['captions_module_n_type'][0] = html_print_input_hidden('id_module_type_hidden', $id_module_type, true); +$table_simple->data['captions_module_n_type'][0] .= __('Module group'); +$table_simple->data['captions_module_n_type'][1] = __('Type').ui_print_help_icon($help_type, true, '', '', '', 'module_type_help'); +// Module group and Type. +$table_simple->rowclass['module_n_type'] = 'field_half_width'; +$table_simple->data['module_n_type'][0] .= html_print_select_from_sql( 'SELECT id_mg, name FROM tmodule_group ORDER BY name', 'id_module_group', $id_module_group, @@ -274,21 +304,10 @@ $table_simple->data[0][3] .= html_print_select_from_sql( false, true, $disabledBecauseInPolicy, - 'width: 150px' + 'width: 480px' ); -if ((isset($id_agent_module) && $id_agent_module) || $id_policy_module != 0) { - $edit = false; -} else { - $edit = true; -} - -$in_policy = strstr($page, 'policy_modules'); - -$table_simple->data[1][0] = __('Type').' '.ui_print_help_icon($help_type, true, '', 'images/help_green.png', '', 'module_type_help'); -$table_simple->data[1][0] .= html_print_input_hidden('id_module_type_hidden', $id_module_type, true); - -if (!$edit) { +if ($edit === false) { $sql = sprintf( 'SELECT id_tipo, nombre FROM ttipo_modulo @@ -304,24 +323,13 @@ if (!$edit) { $type_names_hash[$tn['id_tipo']] = $tn['nombre']; } - $table_simple->data[1][1] = ''.modules_get_moduletype_description($id_module_type).' ('.$type_names_hash[$id_module_type].')'; - $table_simple->data[1][1] .= html_print_input_hidden( - 'type_names', - base64_encode(io_json_mb_encode($type_names_hash)), - true - ); + $table_simple->data['module_n_type'][1] = ''.modules_get_moduletype_description($id_module_type).' ('.$type_names_hash[$id_module_type].')'; } else { - if (isset($id_module_type)) { - $idModuleType = $id_module_type; - } else { - $idModuleType = ''; - } - + $idModuleType = (isset($id_module_type) === true) ? $id_module_type : ''; // Removed web analysis and log4x from select. $tipe_not_in = '24, 25'; - // TODO: FIX credential store for remote command in metaconsole. - if (is_metaconsole()) { - $tipe_not_in = '24, 25, 34, 35, 36, 37'; + if (is_metaconsole() === true) { + $tipe_not_in .= ', 34, 35, 36, 37'; } $sql = sprintf( @@ -347,7 +355,7 @@ if (!$edit) { } } - $table_simple->data[1][1] = html_print_select( + $table_simple->data['module_n_type'][1] = html_print_select( $type_description_hash, 'id_module_type', $idModuleType, @@ -359,24 +367,41 @@ if (!$edit) { false, '', false, - 'width:200px', + 'width: 480px;', false, 100 ); - - // Store the relation between id and name of the types on a hidden field. - $table_simple->data[1][1] .= html_print_input_hidden( - 'type_names', - base64_encode(io_json_mb_encode($type_names_hash)), - true - ); } -if ($edit_module) { +// Store the relation between id and name of the types on a hidden field. +$table_simple->data['module_n_type'][1] .= html_print_input_hidden( + 'type_names', + base64_encode(io_json_mb_encode($type_names_hash)), + true +); + + +if ($edit_module === true) { $id_module_type = (int) $id_module_type; + // Check if the module type is string. + switch ($id_module_type) { + case MODULE_TYPE_GENERIC_DATA_STRING: + case MODULE_TYPE_REMOTE_TCP_STRING: + case MODULE_TYPE_REMOTE_SNMP_STRING: + case MODULE_TYPE_ASYNC_STRING: + case MODULE_TYPE_WEB_CONTENT_STRING: + case MODULE_TYPE_REMOTE_CMD_STRING: + $stringTypeModule = true; + break; + + default: + $stringTypeModule = false; + break; + } + if (($id_module_type >= 1 && $id_module_type <= 5) || ($id_module_type >= 21 && $id_module_type <= 23) - || ($id_module_type == 100) + || ($id_module_type === 100) ) { $help_header = 'local_module'; } @@ -397,128 +422,185 @@ if ($edit_module) { if ($id_module_type >= 30 && $id_module_type <= 33) { $help_header = 'webserver_module_tab'; } - - $table_simple->data[1][0] = __('Type').' '; - $table_simple->data[1][0] .= ui_print_help_icon($help_header, true); } -if ($disabledBecauseInPolicy) { - $table_simple->data[1][3] .= html_print_input_hidden( +if ((bool) $disabledBecauseInPolicy === true) { + $table_simple->data['module'][0] .= html_print_input_hidden( 'id_module_group', $id_module_group, true ); } -$table_simple->data[2][0] = __('Warning threshold'); -if (!modules_is_string_type($id_module_type) || $edit) { - $table_simple->data[2][1] .= ''.__('Min. ').''; - $table_simple->data[2][1] .= html_print_input_text( +// Thresholds Table. +$tableBasicThresholds = new stdClass(); +$tableBasicThresholds->class = 'w100p'; +$tableBasicThresholds->id = 'basic_thresholds'; +$tableBasicThresholds->style = []; +$tableBasicThresholds->rowclass = []; +$tableBasicThresholds->data = []; + +// WARNING THRESHOLD. +$tableBasicThresholds->rowclass['caption_warning_threshold'] = 'field_half_width pdd_t_10px'; +$tableBasicThresholds->rowclass['warning_threshold'] = 'field_half_width'; +$tableBasicThresholds->data['caption_warning_threshold'][0] .= __('Warning threshold').' '; + +if ((isset($stringTypeModule) === false || $stringTypeModule === false)) { + $tableBasicThresholds->data['caption_warning_threshold'][0] .= '('.__('Min / Max').')'; + $tableBasicThresholds->data['warning_threshold'][0] .= html_print_input_text( 'min_warning', $min_warning, '', 10, 255, true, - $disabledBecauseInPolicy, + $disabledBecauseInPolicy || $edit === true, false, '', $classdisabledBecauseInPolicy ); - $table_simple->data[2][1] .= '
'.__('Max.').''; - $table_simple->data[2][1] .= html_print_input_text( + $tableBasicThresholds->data['warning_threshold'][1] .= html_print_input_text( 'max_warning', $max_warning, '', 10, 255, true, - $disabledBecauseInPolicy, + $disabledBecauseInPolicy || $edit === true, false, '', $classdisabledBecauseInPolicy ).'
'; + + $tableBasicThresholds->data['switch_warning_threshold'][0] .= html_print_switch_radio_button( + [ + html_print_radio_button_extended('warning_thresholds_checks', 'normal_warning', __('Normal'), ($percentage_warning && $warning_inverse) === false, false, '', '', true, false, '', 'radius-normal_warning'), + html_print_radio_button_extended('warning_thresholds_checks', 'warning_inverse', __('Inverse interval'), $warning_inverse, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-warning_inverse'), + html_print_radio_button_extended('warning_thresholds_checks', 'percentage_warning', __('Percentage'), $percentage_warning, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-percentage_warning'), + ], + [ 'class' => 'margin-top-10' ], + true + ); } -if (modules_is_string_type($id_module_type) || $edit) { - $table_simple->data[2][1] .= ''.__('Str.').''; - $table_simple->data[2][1] .= html_print_input_text( +if (isset($stringTypeModule) === true && $stringTypeModule === true) { + $basicThresholdsIntervalWarning = []; + $basicThresholdsIntervalWarning[] = ''.__('Inverse interval').''; + $basicThresholdsIntervalWarning[] = html_print_checkbox_switch( + 'warning_inverse_string', + 1, + $warning_inverse, + true, + $disabledBecauseInPolicy + ); + + $tableBasicThresholds->rowclass['caption_switch_warning_inverse_string'] = 'field_half_width'; + $tableBasicThresholds->data['caption_switch_warning_inverse_string'][0] = html_print_div( + [ + 'class' => 'margin-top-10', + 'style' => 'display: flex; flex-direction: row-reverse; align-items: center;', + 'content' => implode('', $basicThresholdsIntervalWarning), + ], + true + ); + + $tableBasicThresholds->data['caption_warning_threshold'][0] .= '('.__('Str.').')'; + $tableBasicThresholds->data['warning_threshold'][0] .= html_print_input_text( 'str_warning', str_replace('"', '', $str_warning), '', 10, 1024, true, - $disabledBecauseInPolicy, + $disabledBecauseInPolicy || $edit === false, false, '', $classdisabledBecauseInPolicy ).''; } -$table_simple->data[2][1] .= '
'.__('Inverse interval').''; -$table_simple->data[2][1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true, $disabledBecauseInPolicy); -$table_simple->data[2][1] .= '
'; -if (modules_is_string_type($id_module_type) === false) { - $table_simple->data[2][1] .= '
'.__('Percentage').''; - $table_simple->data[2][1] .= html_print_checkbox('percentage_warning', 1, $percentage_warning, true, $disabledBecauseInPolicy); - $table_simple->data[2][1] .= ui_print_help_tip('Defines threshold as a percentage of value decrease/increment', true); - $table_simple->data[2][1] .= '
'; -} - -$table_simple->data[3][0] .= ''.__('Change to critical status after'); -$table_simple->data[3][1] .= html_print_input_text( - 'warning_time', - $warning_time, - '', - 5, - 255, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy +$tableBasicThresholds->data['switch_warning_threshold'][0] .= html_print_div( + [ + 'id' => 'percentage_warning', + 'content' => $divPercentageContent, + ], + true ); -$table_simple->data[3][1] .= '  '.__('intervals in warning status.').''; -if (!modules_is_string_type($id_module_type) || $edit) { - $table_simple->data[2][2] = ' '; -} - -$table_simple->data[4][0] = __('Critical threshold'); -if (!modules_is_string_type($id_module_type) || $edit) { - $table_simple->data[4][1] .= ''.__('Min. ').''; - $table_simple->data[4][1] .= html_print_input_text( +// CRITICAL THRESHOLD. +$tableBasicThresholds->rowclass['caption_critical_threshold'] = 'field_half_width pdd_t_10px'; +$tableBasicThresholds->rowclass['critical_threshold'] = 'field_half_width'; +$tableBasicThresholds->data['caption_critical_threshold'][0] .= __('Critical threshold').' '; +if ((isset($stringTypeModule) === false || $stringTypeModule === false)) { + $tableBasicThresholds->data['caption_critical_threshold'][0] .= '('.__('Min / Max').')'; + $tableBasicThresholds->data['critical_threshold'][0] .= html_print_input_text( 'min_critical', $min_critical, '', 10, 255, true, - $disabledBecauseInPolicy, + $disabledBecauseInPolicy || $edit === false, false, '', $classdisabledBecauseInPolicy ); - $table_simple->data[4][1] .= '
'.__('Max.').''; - $table_simple->data[4][1] .= html_print_input_text( + $tableBasicThresholds->data['critical_threshold'][1] .= html_print_input_text( 'max_critical', $max_critical, '', 10, 255, true, - $disabledBecauseInPolicy, + $disabledBecauseInPolicy || $edit === false, false, '', $classdisabledBecauseInPolicy ).'
'; + + $tableBasicThresholds->data['switch_critical_threshold'][0] .= html_print_switch_radio_button( + [ + html_print_radio_button_extended('critical_thresholds_checks', 'normal_critical', __('Normal'), ($percentage_critical && $critical_inverse) === false, false, '', '', true, false, '', 'radius-normal_critical'), + html_print_radio_button_extended('critical_thresholds_checks', 'critical_inverse', __('Inverse interval'), $critical_inverse, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-critical_inverse'), + html_print_radio_button_extended('critical_thresholds_checks', 'percentage_critical', __('Percentage'), $percentage_critical, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-percentage_critical'), + ], + [ 'class' => 'margin-top-10' ], + true + ); } -if (modules_is_string_type($id_module_type) || $edit) { - $table_simple->data[4][1] .= ''.__('Str.').''; - $table_simple->data[4][1] .= html_print_input_text( +if (isset($stringTypeModule) === true && $stringTypeModule === true) { + $basicThresholdsIntervalCritical = []; + $basicThresholdsIntervalCritical[] = ''.__('Inverse interval').''; + $basicThresholdsIntervalCritical[] = html_print_checkbox_switch( + 'critical_inverse_string', + 1, + $critical_inverse, + true, + $disabledBecauseInPolicy + ); + + $tableBasicThresholds->rowclass['caption_switch_critical_inverse_string'] = 'field_half_width'; + $tableBasicThresholds->data['caption_switch_critical_inverse_string'][0] = html_print_div( + [ + 'class' => 'margin-top-10', + 'style' => 'display: flex; flex-direction: row-reverse; align-items: center;', + 'content' => implode('', $basicThresholdsIntervalCritical), + ], + true + ); + + $tableBasicThresholds->data['switch_critical_threshold'][0] .= html_print_div( + [ + 'id' => 'percentage_critical', + 'content' => $divPercentageContent, + ], + true + ); + + $tableBasicThresholds->data['caption_critical_threshold'][0] .= '('.__('Str.').')'; + $tableBasicThresholds->data['critical_threshold'][0] .= html_print_input_text( 'str_critical', str_replace('"', '', $str_critical), '', @@ -529,36 +611,32 @@ if (modules_is_string_type($id_module_type) || $edit) { false, '', $classdisabledBecauseInPolicy - ).''; + ); } -$table_simple->data[4][1] .= '
'.__('Inverse interval').''; -$table_simple->data[4][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true, $disabledBecauseInPolicy); -$table_simple->data[4][1] .= '
'; - - -if (modules_is_string_type($id_module_type) === false) { - $table_simple->data[4][1] .= '
'.__('Percentage').''; - $table_simple->data[4][1] .= ui_print_help_tip('Defines threshold as a percentage of value decrease/increment', true); - $table_simple->data[4][1] .= html_print_checkbox('percentage_critical', 1, $percentage_critical, true, $disabledBecauseInPolicy); - $table_simple->data[4][1] .= '
'; +$table_simple->rowstyle['thresholds_table'] = 'margin-top: 15px;height: 340px;width: 100%'; +$table_simple->cellclass['thresholds_table'][0] = 'table_section half_section_left'; +$table_simple->data['thresholds_table'][0] = html_print_table($tableBasicThresholds, true); +if (modules_is_string_type($id_module_type) === false || (bool) $edit === true) { + $table_simple->cellclass['thresholds_table'][1] = 'table_section half_section_rigth'; + $table_simple->data['thresholds_table'][1] = ' '; } -$table_simple->data[5][0] = __('Historical data'); +$table_simple->data['caption_historical_data'][0] = __('Historical data'); if ($disabledBecauseInPolicy) { // If is disabled, we send a hidden in his place and print a false // checkbox because HTML dont send disabled fields // and could be disabled by error. - $table_simple->data[5][1] = html_print_checkbox( + $table_simple->data['historical_data'][0] = html_print_checkbox_switch( 'history_data_fake', 1, $history_data, true, $disabledBecauseInPolicy ); - $table_simple->data[5][1] .= ''; + $table_simple->data['historical_data'][0] .= html_print_input_hidden('history_data', (int) $history_data, true); } else { - $table_simple->data[5][1] = html_print_checkbox( + $table_simple->data['historical_data'][0] = html_print_checkbox_switch( 'history_data', 1, $history_data, @@ -567,359 +645,10 @@ if ($disabledBecauseInPolicy) { ); } -// Advanced form part. -$table_advanced = new stdClass(); -$table_advanced->id = 'advanced'; -$table_advanced->width = '100%'; -$table_advanced->class = 'no-class'; -$table_advanced->data = []; -$table_advanced->style = []; -$table_advanced->style[0] = $table_advanced->style[3] = $table_advanced->style[5] = 'font-weight: bold;'; -$table_advanced->colspan = []; - -$table_advanced->colspan[5][1] = 3; - -$table_advanced->data[0][0] = __('Custom ID'); -$table_advanced->colspan[0][1] = 2; -$table_advanced->data[0][1] = html_print_input_text( - 'custom_id', - $custom_id, - '', - 20, - 65, - true, - (($config['module_custom_id_ro'] && $__code_from != 'policies') ? true : $disabledBecauseInPolicy), - false, - '', - (($config['module_custom_id_ro'] && $__code_from != 'policies') ? 'readonly' : $classdisabledBecauseInPolicy) -); - -$table_advanced->data[0][3] = __('Unit'); -$table_advanced->data[0][4] = html_print_input_text( - 'unit', - $unit, - '', - 20, - 65, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -); -// $table_advanced->colspan[1][4] = 3; -$table_advanced->data[0][4] = html_print_extended_select_for_unit( - 'unit', - $unit, - '', - 'none', - '0', - false, - true, - false, - false -); -$table_advanced->colspan[0][4] = 3; - -$module_id_policy_module = 0; -if (isset($module['id_policy_module'])) { - $module_id_policy_module = $module['id_policy_module']; -} - -// In the data modules, the interval is not in seconds. It is a factor -// to be multiplied for the agent interval -if ($moduletype == MODULE_DATA) { - $table_advanced->data[1][0] = __('Interval'); - $table_advanced->colspan[1][1] = 2; - $interval_factor = 1; - if (isset($id_agente)) { - $agent_interval = (float) agents_get_interval($id_agente); - if ($agent_interval > 0) { - $interval = (float) $interval; - $interval_factor = ($interval / $agent_interval); - } - - $table_advanced->data[1][1] = human_time_description_raw($interval).' ('.sprintf(__('Agent interval x %s'), $interval_factor).') '; - } else { - $table_advanced->data[1][1] = sprintf(__('Agent interval x %s'), $interval_factor); - } - - if ($__code_from == 'policies') { - // If is the policy form, module_interval will store the factor (not the seconds). - // So server will transform it to interval in seconds. - $table_advanced->data[1][1] = sprintf(__('Default').': 1', $interval_factor); - $table_advanced->data[1][1] .= html_print_input_hidden('module_interval', $interval_factor, true); - } - - // If it is a non policy form, the module_interval will not provided and will. - // be taken the agent interval (this code is at configurar_agente.php). -} else { - $table_advanced->data[1][0] = __('Interval'); - $table_advanced->colspan[1][1] = 2; - $table_advanced->data[1][1] = html_print_extended_select_for_time('module_interval', $interval, '', '', '0', false, true, false, false, $classdisabledBecauseInPolicy, $disabledBecauseInPolicy); -} - -$table_advanced->data[1][1] .= html_print_input_hidden('moduletype', $moduletype, true); - -$table_advanced->data[1][3] = __('Post process'); -$table_advanced->data[1][4] = html_print_extended_select_for_post_process( - 'post_process', - $post_process, - '', - '', - '0', - false, - true, - 'width:10em', - false, - $disabledBecauseInPolicy -); -$table_advanced->colspan[1][4] = 3; - -$table_advanced->data[2][0] = __('Min. Value'); -$table_advanced->colspan[2][1] = 2; - -$table_advanced->data[2][1] = html_print_input_text('min', $min, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy); -$table_advanced->data[2][3] = __('Max. Value'); -$table_advanced->data[2][4] = html_print_input_text('max', $max, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy); -$table_advanced->colspan[2][4] = 3; - -$table_advanced->data[3][0] = __('Dynamic Threshold Interval'); -$table_advanced->data[3][1] = html_print_extended_select_for_time( - 'dynamic_interval', - $dynamic_interval, - '', - __('None'), - '0', - 10, - true, - 'width:150px', - false, - $classdisabledBecauseInPolicy, - $disabledBecauseInPolicy -); -$table_advanced->data[3][1] .= ''.html_print_image( - 'images/cog.png', - true, - [ - 'title' => __('Advanced options Dynamic Threshold'), - 'class' => 'invert_filter', - ] -).''; - -$table_advanced->cellclass[3][2] = 'hide_dinamic'; -$table_advanced->cellclass[3][3] = 'hide_dinamic'; - - -$table_advanced->data[3][2] = ''.__('Dynamic Threshold Min. ').''; -$table_advanced->data[3][2] .= html_print_input_text( - 'dynamic_min', - $dynamic_min, - '', - 10, - 255, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -); -$table_advanced->data[3][2] .= '
'.__('Dynamic Threshold Max. ').''; -$table_advanced->data[3][2] .= html_print_input_text( - 'dynamic_max', - $dynamic_max, - '', - 10, - 255, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -); -$table_advanced->data[3][3] = ''.__('Dynamic Threshold Two Tailed: ').''; -$table_advanced->data[3][3] .= html_print_checkbox('dynamic_two_tailed', 1, $dynamic_two_tailed, true, $disabledBecauseInPolicy); - - - -$table_advanced->data[4][0] = __('Export target'); -// Default text message for export target select and disabled option -$none_text = __('None'); -$disabled_export = false; - -if ($__code_from == 'policies') { - $none_text = __('Not needed'); - $disabled_export = true; -} - -$table_advanced->data[4][1] = html_print_select_from_sql( - 'SELECT id, name FROM tserver_export ORDER BY name', - 'id_export', - $id_export, - '', - $none_text, - '0', - true, - false, - false, - $disabled_export -); -$table_advanced->colspan[4][1] = 2; - -// Code comes from module_editor. -if ($__code_from == 'modules') { - $throw_unknown_events_check = modules_is_disable_type_event($id_agent_module, EVENTS_GOING_UNKNOWN); -} else { - global $__id_pol_mod; - - $throw_unknown_events_check = policy_module_is_disable_type_event($__id_pol_mod, EVENTS_GOING_UNKNOWN); -} - -$table_advanced->data[4][3] = __('Discard unknown events'); -$table_advanced->data[4][4] = html_print_checkbox( - 'throw_unknown_events', - 1, - $throw_unknown_events_check, - true, - $disabledBecauseInPolicy -); -$table_advanced->colspan[4][4] = 3; - - -// FF stands for Flip-flop. -$table_advanced->colspan[5][1] = 5; -$table_advanced->cellclass[5][1] = 'font_bold'; - - -$table_advanced->data[5][0] = __('FF threshold').' '; - -$table_advanced->data[5][1] .= __('Keep counters'); -$table_advanced->data[5][1] .= html_print_checkbox( - 'ff_type', - 1, - $ff_type, - true, - $disabledBecauseInPolicy -).'
'; - -$table_advanced->data[5][1] .= html_print_radio_button( - 'each_ff', - 0, - '', - $each_ff, - true, - $disabledBecauseInPolicy -); -$table_advanced->data[5][1] .= ' '.__('All state changing').' : '; -$table_advanced->data[5][1] .= html_print_input_text( - 'ff_event', - $ff_event, - '', - 5, - 15, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -).'
'; -$table_advanced->data[5][1] .= html_print_radio_button( - 'each_ff', - 1, - '', - $each_ff, - true, - $disabledBecauseInPolicy -); - -$table_advanced->data[5][1] .= ' '.__('Each state changing').' : '; -$table_advanced->data[5][1] .= __('To normal'); -$table_advanced->data[5][1] .= html_print_input_text( - 'ff_event_normal', - $ff_event_normal, - '', - 5, - 15, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -).' '; - -$table_advanced->data[5][1] .= __('To warning'); -$table_advanced->data[5][1] .= html_print_input_text( - 'ff_event_warning', - $ff_event_warning, - '', - 5, - 15, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -).' '; - -$table_advanced->data[5][1] .= __('To critical'); -$table_advanced->data[5][1] .= html_print_input_text( - 'ff_event_critical', - $ff_event_critical, - '', - 5, - 15, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -); - - -$table_advanced->data[6][0] = __('FF interval'); -$table_advanced->data[6][1] = html_print_input_text( - 'module_ff_interval', - $ff_interval, - '', - 5, - 10, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -); -$table_advanced->colspan[6][1] = 2; - -$table_advanced->data[6][3] = __('FF timeout'); - -$module_type_name = modules_get_type_name($id_module_type); -$table_advanced->data[6][4] = ''; -if (preg_match('/async/', $module_type_name) || $edit) { - $table_advanced->data[6][4] .= ''.html_print_input_text( - 'ff_timeout', - $ff_timeout, - '', - 5, - 10, - true, - $disabledBecauseInPolicy - ).''; -} - -if (!preg_match('/async/', $module_type_name) || $edit) { - $table_advanced->data[6][4] .= ''.__('Disabled').''; -} - -$table_advanced->colspan[6][4] = 3; - -/* - Tags */ -// This var comes from module_manager_editor.php or policy_modules.php +// Business Logic for Advanced Part. global $__code_from; -$table_advanced->data[7][0] = __('Tags available'); -// Code comes from module_editor -if ($__code_from == 'modules') { +// Code comes from module_editor. +if ($__code_from === 'modules') { $__table_modules = 'ttag_module'; $__id_where = 'b.id_agente_modulo'; $__id = (int) $id_agent_module; @@ -927,7 +656,7 @@ if ($__code_from == 'modules') { $__sql = ' AND b.id_policy_module = 0'; $__sql_policy = ' AND b.id_policy_module != 0'; } else { - // Code comes from policy module editor + // Code comes from policy module editor. global $__id_pol_mod; $__table_modules = 'ttag_policy_module'; $__id_where = 'b.id_policy_module'; @@ -936,8 +665,132 @@ if ($__code_from == 'modules') { $__sql = ''; } -if (!tags_has_user_acl_tags($config['id_user'])) { - $table_advanced->data[7][1] = html_print_select_from_sql( +// In the data modules, the interval is not in seconds. It is a factor +// to be multiplied for the agent interval. +if ((int) $moduletype === MODULE_DATA) { + $interval_factor = 1; + if (isset($id_agente) === true) { + $agent_interval = (float) agents_get_interval($id_agente); + if ($agent_interval > 0) { + $interval = (float) $interval; + $interval_factor = ($interval / $agent_interval); + } + + $outputExecutionInterval = human_time_description_raw($interval).' ('.sprintf(__('Agent interval x %s'), $interval_factor).') '; + } else { + $outputExecutionInterval = sprintf(__('Agent interval x %s'), $interval_factor); + } + + if ($__code_from === 'policies') { + // If is the policy form, module_interval will store the factor (not the seconds). + // So server will transform it to interval in seconds. + $outputExecutionInterval = sprintf(__('Default').': 1', $interval_factor); + $outputExecutionInterval .= html_print_input_hidden('module_interval', $interval_factor, true); + } + + // If it is a non policy form, the module_interval will not provided and will. + // be taken the agent interval (this code is at configurar_agente.php). +} else { + $outputExecutionInterval = html_print_extended_select_for_time('module_interval', $interval, '', '', '0', false, true, false, false, $classdisabledBecauseInPolicy, $disabledBecauseInPolicy); +} + +$module_id_policy_module = 0; +if (isset($module['id_policy_module']) === true) { + $module_id_policy_module = $module['id_policy_module']; +} + +$cps_array[-1] = __('Disabled'); +if ($cps_module > 0) { + $cps_array[$cps_module] = __('Enabled'); +} else { + $cps_inc = 0; + if (isset($id_agent_module) === true && empty($id_agent_module) === false) { + $cps_inc = enterprise_hook('service_modules_cps', [$id_agent_module]); + if ($cps_inc === ENTERPRISE_NOT_HOOK) { + $cps_inc = 0; + } + } + + $cps_array[$cps_inc] = __('Enabled'); +} + +// JS Scripts for ff thresholds. +ob_start(); +?> + +id = 'advanced'; +$table_advanced->styleTable = 'border-radius: 8px'; +$table_advanced->width = '100%'; +$table_advanced->class = 'w100p floating_form'; +$table_advanced->data = []; +$table_advanced->style = []; +$table_advanced->rowclass = []; +$table_advanced->cellclass = []; +$table_advanced->colspan = []; +$table_advanced->rowspan = []; + +$table_advanced->data['title_1'] = html_print_subtitle_table(__('Identification and Categorization')); +$table_advanced->rowclass['captions_custom_category'] = 'field_half_width pdd_t_10px'; +$table_advanced->rowclass['custom_id_category'] = 'field_half_width'; +$table_advanced->data['captions_custom_category'][0] = __('Custom ID'); +$table_advanced->data['captions_custom_category'][1] = __('Category'); + +$table_advanced->data['custom_id_category'][0] = html_print_input_text( + 'custom_id', + $custom_id, + '', + 20, + 65, + true, + (($config['module_custom_id_ro'] && $__code_from !== 'policies') ? true : $disabledBecauseInPolicy), + false, + '', + (($config['module_custom_id_ro'] && $__code_from !== 'policies') ? 'readonly' : $classdisabledBecauseInPolicy) +); + +if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { + $table_advanced->data['custom_id_category'][1] = html_print_select( + categories_get_all_categories('forselect'), + 'id_category', + $id_category, + '', + __('None'), + 0, + true, + false, + true, + '', + $disabledBecauseInPolicy + ); +} else { + // Store in a hidden field if is not visible to avoid delete the value. + $table_advanced->data['custom_id_category'][1] .= html_print_input_hidden('id_category', $id_category, true); +} + +// Tags. +$table_advanced->rowclass['caption_tags_module_parent'] = 'field_half_width pdd_t_10px'; +$table_advanced->rowclass['tags_module_parent'] = 'field_half_width'; +$table_advanced->data['caption_tags_module_parent'][0] = __('Tags available'); + +$tagsAvailableData = ''; +$tagsCompleteData = ''; +if (tags_has_user_acl_tags($config['id_user']) === false) { + $tagsAvailableData .= html_print_select_from_sql( "SELECT id_tag, name FROM ttag WHERE id_tag NOT IN ( @@ -959,10 +812,10 @@ if (!tags_has_user_acl_tags($config['id_user'])) { ); } else { $user_tags = tags_get_user_tags($config['id_user'], 'AW'); - if (!empty($user_tags)) { + if (empty($user_tags) === false) { $id_user_tags = array_keys($user_tags); - $table_advanced->data[7][1] = html_print_select_from_sql( + $tagsAvailableData .= html_print_select_from_sql( 'SELECT id_tag, name FROM ttag WHERE id_tag IN ('.implode(',', $id_user_tags).") AND @@ -984,12 +837,12 @@ if (!tags_has_user_acl_tags($config['id_user'])) { '5' ); } else { - $table_advanced->data[7][1] = html_print_select_from_sql( + $tagsAvailableData .= html_print_select_from_sql( "SELECT id_tag, name - FROM ttag + FROM ttag WHERE id_tag NOT IN ( SELECT a.id_tag - FROM ttag a, $__table_modules b + FROM ttag a, $__table_modules b WHERE a.id_tag = b.id_tag AND $__id_where = $__id ) ORDER BY name", 'id_tag_available[]', @@ -1007,47 +860,145 @@ if (!tags_has_user_acl_tags($config['id_user'])) { } } -$table_advanced->data[7][2] = html_print_image( - 'images/darrowright.png', +$tagsAvailableData .= html_print_image( + 'images/plus.svg', true, [ 'id' => 'right', 'title' => __('Add tags to module'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter clickable mrgn_lft_5px', ] ); -$table_advanced->data[7][2] .= '



'.html_print_image( - 'images/darrowleft.png', - true, + +$tagsCompleteData = html_print_div( [ - 'id' => 'left', - 'title' => __('Delete tags to module'), - 'class' => 'invert_filter', - ] + 'class' => 'tags_available_container', + 'content' => $tagsAvailableData, + ], + true ); -$table_advanced->data[7][3] = ''.__('Tags selected').''; -$table_advanced->data[7][4] = html_print_select_from_sql( - "SELECT a.id_tag, name - FROM ttag a, $__table_modules b - WHERE a.id_tag = b.id_tag AND $__id_where = $__id - $__sql - ORDER BY name", + +$sqlGetTags = sprintf( + 'SELECT a.id_tag, name FROM ttag a, %s b WHERE a.id_tag = b.id_tag AND %s = %s %s ORDER BY name', + $__table_modules, + $__id_where, + $__id, + $__sql +); + +$listSelectedTags = db_get_all_rows_sql($sqlGetTags); +if (empty($listSelectedTags) === false) { + $listSelectedTagShow = array_reduce( + $listSelectedTags, + function ($carry, $item) { + $carry[] = $item['id_tag']; + return $carry; + } + ); +} else { + $listSelectedTagShow = []; +} + + +$tagsCompleteData .= html_print_div( + [ + 'class' => 'tags_selected_container', + 'content' => html_print_select_from_sql( + $sqlGetTags, + 'id_tag_selected[]', + $listSelectedTagShow, + '', + '', + '', + true, + true, + false, + $disabledBecauseInPolicy, + 'width: 200px;', + '5' + ), + ], + true +); +/* + $tagsCompleteData .= html_print_select( + $listSelectedTags, 'id_tag_selected[]', + $listSelectedTagShow, '', '', - '', - '', + 0, true, true, false, + '', $disabledBecauseInPolicy, - 'width: 200px', - '5' + 'width: 200px;' + ); +*/ +$table_advanced->data['tags_module_parent'][0] .= html_print_div( + [ + 'class' => 'tags_complete_container', + 'content' => $tagsCompleteData, + ], + true ); -if ($__code_from == 'modules') { - $table_advanced->data[7][5] = ''.__('Tags from policy').''; - $table_advanced->data[7][6] = html_print_select_from_sql( +if ((bool) $in_policies_page === false) { + // Cannot select the current module to be itself parent. + $module_parent_filter = ($id_agent_module) ? ['tagente_modulo.id_agente_modulo' => '<>'.$id_agent_module] : []; + $table_advanced->data['caption_tags_module_parent'][1] = __('Module parent'); + // TODO. Review cause dont know not works. + /* + $agent = new Agent($id_agente); + $modules_can_be_parent = $agent->searchModules( + $module_parent_filter, + 0 + ); + */ + $modules_can_be_parent = agents_get_modules( + $id_agente, + false, + $module_parent_filter + ); + // If the user cannot have access to parent module, only print the name. + if ((int) $parent_module_id !== 0 + && in_array($parent_module_id, array_keys($modules_can_be_parent)) === true + ) { + $parentModuleOutput = db_get_value( + 'nombre', + 'tagente_modulo', + 'id_agente_modulo', + $parent_module_id + ); + } else { + $parentModuleOutput = html_print_select( + $modules_can_be_parent, + 'parent_module_id', + $parent_module_id, + '', + __('Not assigned'), + '0', + true + ); + } + + $table_advanced->cellstyle['tags_module_parent'][1] = 'align-self: flex-start;'; + $table_advanced->data['tags_module_parent'][1] = html_print_div( + [ + 'class' => 'parent_module_container w100p', + 'content' => $parentModuleOutput, + ], + true, + ); +} + +$table_advanced->rowclass['caption_tags_from_policy_module_parent'] = 'field_half_width pdd_t_10px'; +$table_advanced->rowclass['tags_from_policy_module_parent'] = 'field_half_width'; + +if ($__code_from === 'modules') { + $table_advanced->data['caption_tags_from_policy_module_parent'][0] = __('Tags from policy'); + $table_advanced->data['tags_from_policy_module_parent'][0] = html_print_select_from_sql( "SELECT a.id_tag, name FROM ttag a, $__table_modules b WHERE a.id_tag = b.id_tag AND $__id_where = $__id @@ -1065,147 +1016,406 @@ if ($__code_from == 'modules') { 'width: 200px', '5' ); + + $table_advanced->data['tags_from_policy_module_parent'][1] = ''; } -$table_advanced->data[8][0] = __('Quiet'); -$table_advanced->data[8][1] = html_print_checkbox('quiet_module', 1, $quiet_module, true, $disabledBecauseInPolicy); - -$cps_array[-1] = __('Disabled'); -if ($cps_module > 0) { - $cps_array[$cps_module] = __('Enabled'); -} else { - $cps_inc = 0; - if ($id_agent_module) { - $cps_inc = enterprise_hook('service_modules_cps', [$id_agent_module]); - if ($cps_inc === ENTERPRISE_NOT_HOOK) { - $cps_inc = 0; - } - } - - $cps_array[$cps_inc] = __('Enabled'); -} - -$table_advanced->data[8][2] = ''; -$table_advanced->data[8][3] = __('Cascade Protection Services'); -$table_advanced->colspan[8][4] = 3; -$table_advanced->data[8][4] = html_print_select($cps_array, 'cps_module', $cps_module, '', '', 0, true, false, true, '', $disabledBecauseInPolicy); - -$textarea_custom_style = ' class="min-height-0px"'; - -$table_advanced->data[9][0] = __('Description'); -$table_advanced->colspan[9][1] = 6; -$table_advanced->data[9][1] = html_print_textarea( +$table_advanced->rowclass['caption_textarea_description_instructions'] = 'field_half_width pdd_t_10px'; +$table_advanced->rowclass['textarea_description_instructions'] = 'field_half_width'; +$table_advanced->data['caption_textarea_description_instructions'][0] = __('Description'); +$table_advanced->data['caption_textarea_description_instructions'][1] = __('Unknown instructions'); +$table_advanced->data['textarea_description_instructions'][0] = html_print_textarea( 'description', - 3, - 65, + 5, + 35, $description, - $disabledTextBecauseInPolicy.$textarea_custom_style, + $disabledTextBecauseInPolicy, + true, + $largeClassDisabledBecauseInPolicy +); +$table_advanced->data['textarea_description_instructions'][1] = html_print_textarea( + 'unknown_instructions', + 5, + 35, + $unknown_instructions, + $disabledTextBecauseInPolicy, true, $largeClassDisabledBecauseInPolicy ); -$table_advanced->data[10][0] = __('Critical instructions'); -$table_advanced->data[10][1] = html_print_textarea('critical_instructions', 3, 65, $critical_instructions, $disabledTextBecauseInPolicy.$textarea_custom_style, true, $largeClassDisabledBecauseInPolicy); -$table_advanced->colspan[10][1] = 6; +$table_advanced->rowclass['caption_textarea_crit_warn_instructions'] = 'field_half_width pdd_t_10px'; +$table_advanced->rowclass['textarea_crit_warn_instructions'] = 'field_half_width'; +$table_advanced->data['caption_textarea_crit_warn_instructions'][1] = __('Warning instructions'); +$table_advanced->data['caption_textarea_crit_warn_instructions'][0] = __('Critical instructions'); +$table_advanced->data['textarea_crit_warn_instructions'][0] = html_print_textarea( + 'critical_instructions', + 5, + 35, + $critical_instructions, + $disabledTextBecauseInPolicy, + true, + $largeClassDisabledBecauseInPolicy +); -$table_advanced->data[11][0] = __('Warning instructions'); -$table_advanced->data[11][1] = html_print_textarea('warning_instructions', 3, 65, $warning_instructions, $disabledTextBecauseInPolicy.$textarea_custom_style, true, $largeClassDisabledBecauseInPolicy); -$table_advanced->colspan[11][1] = 6; +$table_advanced->data['textarea_crit_warn_instructions'][1] = html_print_textarea( + 'warning_instructions', + 5, + 35, + $warning_instructions, + $disabledTextBecauseInPolicy, + true, + $largeClassDisabledBecauseInPolicy +); -$table_advanced->data[12][0] = __('Unknown instructions'); -$table_advanced->data[12][1] = html_print_textarea('unknown_instructions', 3, 65, $unknown_instructions, $disabledTextBecauseInPolicy.$textarea_custom_style, true, $largeClassDisabledBecauseInPolicy); -$table_advanced->colspan[12][1] = 6; +$table_advanced->data['title_2'] = html_print_subtitle_table(__('Execution interval')); -if (isset($id_agente) && $moduletype == MODULE_DATA) { +$table_advanced->data['caption_execution_interval'][0] = __('Interval'); +$table_advanced->data['execution_interval'][0] = ''.$outputExecutionInterval.''; +$table_advanced->data['execution_interval'][0] .= html_print_input_hidden('moduletype', $moduletype, true); + +// Cron Table. +$tableCron = new stdClass(); +$tableCron->class = 'w100p'; +$tableCron->id = 'advanced_cron'; +$tableCron->style = []; +$tableCron->rowclass = []; +$tableCron->data = []; + +// Cron table styles. +$tableCron->cellstyle['cron_from_select'][0] = 'padding: 0; margin: 0 -4px; width: 100%;'; +$tableCron->cellstyle['cron_to_select'][0] = 'padding: 0; margin: 0 -4px; width: 100%;'; + +if (isset($id_agente) === true && (int) $moduletype === MODULE_DATA) { $has_remote_conf = enterprise_hook('config_agents_has_remote_configuration', [$agent['id_agente']]); - if ($has_remote_conf) { - $table_advanced->data[13][0] = __('Cron from'); - $table_advanced->data[13][1] = html_print_extended_select_for_cron($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, $disabledBecauseInPolicy); - $table_advanced->colspan[13][1] = 6; + $tableCron->data['caption_cron_from_select'][0] = __('Cron from'); + $tableCron->data['cron_from_select'][0] = html_print_extended_select_for_cron($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, ((bool) $has_remote_conf === true) ? $disabledBecauseInPolicy : true); - $table_advanced->data[14][0] = __('Cron to'); - $table_advanced->data[14][1] = html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, $disabledBecauseInPolicy, true); - $table_advanced->colspan[14][1] = 6; - } else { - $table_advanced->data[13][0] = __('Cron from'); - $table_advanced->data[13][1] = html_print_extended_select_for_cron($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, true); - $table_advanced->colspan[13][1] = 6; - - $table_advanced->data[14][0] = __('Cron to'); - $table_advanced->data[14][1] = html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, true, true); - $table_advanced->colspan[14][1] = 6; - } + $tableCron->data['caption_cron_to_select'][0] = __('Cron to'); + $tableCron->data['cron_to_select'][0] = html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, ((bool) $has_remote_conf === true) ? $disabledBecauseInPolicy : true, true); } else { - $table_advanced->data[13][0] = __('Cron from'); - $table_advanced->data[13][1] = html_print_extended_select_for_cron($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, $disabledBecauseInPolicy); - $table_advanced->colspan[13][1] = 6; + $tableCron->data['caption_cron_from_select'][0] = __('Cron from'); + $tableCron->data['cron_from_select'][0] = html_print_extended_select_for_cron($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, $disabledBecauseInPolicy); - $table_advanced->data[14][0] = __('Cron to'); - $table_advanced->data[14][1] = html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, $disabledBecauseInPolicy, true); - $table_advanced->colspan[14][1] = 6; + $tableCron->data['caption_cron_to_select'][0] = __('Cron to'); + $tableCron->data['cron_to_select'][0] = html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, $disabledBecauseInPolicy, true); } -$table_advanced->data[15][0] = __('Timeout'); -$table_advanced->data[15][1] = html_print_input_text('max_timeout', $max_timeout, '', 5, 10, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy); -$table_advanced->data[15][2] = ''; -$table_advanced->data[15][3] = __('Retries'); -$table_advanced->data[15][4] = html_print_input_text('max_retries', $max_retries, '', 5, 10, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy); -$table_advanced->colspan[15][4] = 3; +$table_advanced->rowclass['cron_section'] = 'table_section full_section'; +$table_advanced->data['cron_section'] = html_print_table($tableCron, true); -if (check_acl($config['id_user'], 0, 'PM')) { - $table_advanced->data[16][0] = __('Category'); - $table_advanced->data[16][1] = html_print_select( - categories_get_all_categories('forselect'), - 'id_category', - $id_category, +$table_advanced->data['title_3'] = html_print_subtitle_table(__('Thresholds and state changes')); + +$table_advanced->rowclass['caption_min_max_values'] = 'w50p pdd_t_10px'; +$table_advanced->rowclass['min_max_values'] = 'w50p'; +$table_advanced->data['caption_min_max_values'][0] = __('Min. Value'); +$table_advanced->data['caption_min_max_values'][1] = __('Max. Value'); + +$table_advanced->data['min_max_values'][0] = html_print_input_text('min', $min, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy.' w100p'); +$table_advanced->data['min_max_values'][1] = html_print_input_text('max', $max, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy.' w100p'); + +// Dynamic Threholds. +$tableDynamicThreshold = new stdClass(); +$tableDynamicThreshold->class = 'w100p'; +$tableDynamicThreshold->id = 'advanced_dynamic'; +$tableDynamicThreshold->style = []; +$tableDynamicThreshold->rowclass = []; +$tableDynamicThreshold->data = []; + +$tableDynamicThreshold->data['caption_dynamic_threshold_interval'][0] = __('Dynamic Threshold Interval'); +$tableDynamicThreshold->rowclass['dynamic_threshold_interval'] = 'w540px'; +$tableDynamicThreshold->data['dynamic_threshold_interval'][0] = html_print_extended_select_for_time( + 'dynamic_interval', + $dynamic_interval, + '', + __('None'), + '0', + 10, + true, + '', + false, + $classdisabledBecauseInPolicy.' w50p', + $disabledBecauseInPolicy +); + +$tableDynamicThreshold->rowclass['caption_adv_dynamic_threshold_interval'] = 'pdd_t_10px w100p'; +$tableDynamicThreshold->rowclass['adv_dynamic_threshold_interval'] = 'w100p'; +$tableDynamicThreshold->cellclass['caption_adv_dynamic_threshold_interval'][0] = 'w33p'; +$tableDynamicThreshold->cellclass['caption_adv_dynamic_threshold_interval'][1] = 'w33p'; +$tableDynamicThreshold->cellclass['adv_dynamic_threshold_interval'][0] = 'w33p'; +$tableDynamicThreshold->cellclass['adv_dynamic_threshold_interval'][1] = 'w33p'; +$tableDynamicThreshold->data['caption_adv_dynamic_threshold_interval'][0] = __('Min.'); +$tableDynamicThreshold->data['caption_adv_dynamic_threshold_interval'][1] = __('Max.'); +$tableDynamicThreshold->data['adv_dynamic_threshold_interval'][0] = html_print_input_text( + 'dynamic_min', + $dynamic_min, + '', + 10, + 255, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy.' w100p' +); +$tableDynamicThreshold->data['adv_dynamic_threshold_interval'][1] = html_print_input_text( + 'dynamic_max', + $dynamic_max, + '', + 10, + 255, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy.' w100p' +); + +$tableDynamicThreshold->rowclass['caption_adv_dynamic_threshold_twotailed'] = 'pdd_t_10px w100p'; +$tableDynamicThreshold->rowclass['adv_dynamic_threshold_twotailed'] = 'w100p'; +$tableDynamicThreshold->cellclass['caption_adv_dynamic_threshold_twotailed'][0] = 'w33p'; +$tableDynamicThreshold->cellclass['adv_dynamic_threshold_twotailed'][0] = 'w33p'; +$tableDynamicThreshold->data['caption_adv_dynamic_threshold_twotailed'][0] = __('Two Tailed'); +$tableDynamicThreshold->data['adv_dynamic_threshold_twotailed'][0] = html_print_checkbox_switch( + 'dynamic_two_tailed', + 1, + $dynamic_two_tailed, + true, + $disabledBecauseInPolicy +); + +$table_advanced->rowclass['dynamic_threshold_table'] = 'table_section full_section'; +$table_advanced->data['dynamic_threshold_table'] = html_print_table($tableDynamicThreshold, true); + +$tableFFThreshold = new stdClass(); +$tableFFThreshold->class = 'w100p'; +$tableFFThreshold->id = 'advanced_flipflop'; +$tableFFThreshold->style = []; +$tableFFThreshold->rowclass = []; +$tableFFThreshold->data = []; +// FF stands for Flip-flop. +$tableFFThreshold->data['caption_ff_main_thresholds'][0] = __('FF threshold'); +$tableFFThreshold->rowclass['ff_main_thresholds'] = 'w100p'; +$tableFFThreshold->data['ff_main_thresholds'][0] = html_print_switch_radio_button( + [ + html_print_radio_button_extended('each_ff', 0, __('All state changing'), $each_ff, false, 'ffStateChange(0)', '', true, false, '', 'ff_all_state'), + html_print_radio_button_extended('each_ff', 1, __('Each state changing'), $each_ff, false, 'ffStateChange(1)', '', true, false, '', 'ff_each_state'), + ], + [ 'add_content' => $ffThresholdsScript ], + true +); + +$tableFFThreshold->rowclass['caption_ff_thresholds_all'] = 'w50p ff_thresholds_line pdd_t_10px'; +$tableFFThreshold->rowclass['ff_thresholds_all'] = 'w50p ff_thresholds_line'; +$tableFFThreshold->cellclass['caption_ff_thresholds_all'][0] = 'w50p'; +$tableFFThreshold->cellclass['ff_thresholds_all'][0] = 'w50p'; +$tableFFThreshold->data['caption_ff_thresholds_all'][0] = __('Change all states'); +$tableFFThreshold->data['ff_thresholds_all'][0] = html_print_input_text( + 'ff_event', + $ff_event, + '', + 5, + 15, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy +); + +$tableFFThreshold->rowclass['caption_ff_thresholds_each'] = 'w50p ff_thresholds_line pdd_t_10px'; +$tableFFThreshold->rowclass['ff_thresholds_each'] = 'w50p ff_thresholds_line'; +$tableFFThreshold->cellclass['caption_ff_thresholds_each'][0] = 'w33p'; +$tableFFThreshold->cellclass['caption_ff_thresholds_each'][1] = 'w33p'; +$tableFFThreshold->cellclass['caption_ff_thresholds_each'][2] = 'w33p'; +$tableFFThreshold->cellclass['ff_thresholds_each'][0] = 'w33p'; +$tableFFThreshold->cellclass['ff_thresholds_each'][1] = 'w33p'; +$tableFFThreshold->cellclass['ff_thresholds_each'][2] = 'w33p'; +$tableFFThreshold->data['caption_ff_thresholds_each'][0] = __('To normal'); +$tableFFThreshold->data['caption_ff_thresholds_each'][1] = __('To warning'); +$tableFFThreshold->data['caption_ff_thresholds_each'][2] = __('To critical'); + +$tableFFThreshold->data['ff_thresholds_each'][0] = html_print_input_text( + 'ff_event_normal', + $ff_event_normal, + '', + 5, + 15, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy +); + +$tableFFThreshold->data['ff_thresholds_each'][1] = html_print_input_text( + 'ff_event_warning', + $ff_event_warning, + '', + 5, + 15, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy +); + +$tableFFThreshold->data['ff_thresholds_each'][2] = html_print_input_text( + 'ff_event_critical', + $ff_event_critical, + '', + 5, + 15, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy +); + + +$table_advanced->rowclass['flipflop_thresholds_table'] = 'table_section full_section'; +$table_advanced->data['flipflop_thresholds_table'] = html_print_table($tableFFThreshold, true); + +$table_advanced->rowclass['caption_ff_interval_timeout'] = 'w50p'; +$table_advanced->rowclass['ff_interval_timeout'] = 'w50p'; +$table_advanced->cellclass['caption_ff_interval_timeout'][0] = 'w50p'; +$table_advanced->cellclass['caption_ff_interval_timeout'][1] = 'w50p'; +$table_advanced->cellclass['ff_interval_timeout'][0] = 'w50p'; +$table_advanced->cellclass['ff_interval_timeout'][1] = 'w50p'; +$table_advanced->data['caption_ff_interval_timeout'][0] = __('FF interval'); +$table_advanced->data['caption_ff_interval_timeout'][1] = __('FF timeout'); +$table_advanced->data['ff_interval_timeout'][0] = html_print_input_text( + 'module_ff_interval', + $ff_interval, + '', + 5, + 10, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy.' w100p' +); + +$module_type_name = modules_get_type_name($id_module_type); +$table_advanced->data['ff_interval_timeout'][1] = ''; +if ((bool) preg_match('/async/', $module_type_name) === true || $edit === true) { + $table_advanced->data['ff_interval_timeout'][1] .= ''.html_print_input_text( + 'ff_timeout', + $ff_timeout, '', - __('None'), - 0, + 5, + 10, true, - false, - true, - '', $disabledBecauseInPolicy - ); - $table_advanced->colspan[16][1] = 6; + ).''; +} + +if ((bool) preg_match('/async/', $module_type_name) === false || $edit === true) { + $table_advanced->data['ff_interval_timeout'][1] .= ''.__('Disabled').''; +} + +$table_advanced->data['caption_ff_keep_counters'][0] = __('Keep counters'); +$table_advanced->data['ff_keep_counters'][0] = html_print_checkbox_switch( + 'ff_type', + 1, + $ff_type, + true, + $disabledBecauseInPolicy +); + +$table_advanced->data['title_4'] = html_print_subtitle_table(__('Data and their processing')); + +$table_advanced->rowclass['caption_process_unit'] = 'w50p'; +$table_advanced->rowclass['process_unit'] = 'w50p'; +$table_advanced->data['caption_process_unit'][0] = __('Unit'); +$table_advanced->data['caption_process_unit'][1] = __('Post process'); +$table_advanced->data['process_unit'][0] = html_print_extended_select_for_unit( + 'unit', + $unit, + '', + 'none', + '0', + false, + true, + 'width: 100%', + false +); +$table_advanced->data['process_unit'][1] = html_print_extended_select_for_post_process( + 'post_process', + $post_process, + '', + '', + '0', + false, + true, + 'width:10em', + false, + $disabledBecauseInPolicy +); + +$table_advanced->data['title_5'] = html_print_subtitle_table(__('Notifications and alerts')); + +$table_advanced->data['caption_export_target'][0] = __('Export target'); +if ($__code_from === 'policies') { + $none_text = __('Not needed'); + $disabled_export = true; } else { - // Store in a hidden field if is not visible to avoid delete the value. - $table_advanced->data[15][4] .= html_print_input_hidden('id_category', $id_category, true); + $none_text = __('None'); + $disabled_export = false; } -if (!$in_policy) { - // Cannot select the current module to be itself parent. - $module_parent_filter = ($id_agent_module) ? ['tagente_modulo.id_agente_modulo' => "<>$id_agent_module"] : ''; - $table_advanced->data[17][0] = __('Module parent'); - $modules_can_be_parent = agents_get_modules( - $id_agente, - false, - $module_parent_filter - ); - // If the user cannot have access to parent module, only print the name. - if ($parent_module_id != 0 - && !in_array($parent_module_id, array_keys($modules_can_be_parent)) - ) { - $table_advanced->data[17][1] = db_get_value( - 'nombre', - 'tagente_modulo', - 'id_agente_modulo', - $parent_module_id - ); - } else { - $table_advanced->data[17][1] = html_print_select( - $modules_can_be_parent, - 'parent_module_id', - $parent_module_id, - '', - __('Not assigned'), - '0', - true - ); - } +$table_advanced->data['export_target'][0] = html_print_select_from_sql( + 'SELECT id, name FROM tserver_export ORDER BY name', + 'id_export', + $id_export, + '', + $none_text, + '0', + true, + false, + false, + $disabled_export +); +// Code comes from module_editor. +if ($__code_from === 'modules') { + $throw_unknown_events_check = modules_is_disable_type_event($id_agent_module, EVENTS_GOING_UNKNOWN); +} else { + global $__id_pol_mod; + + $throw_unknown_events_check = policy_module_is_disable_type_event($__id_pol_mod, EVENTS_GOING_UNKNOWN); } +$table_advanced->data['caption_discard_unknown'][0] = __('Discard unknown events'); +$table_advanced->data['discard_unknown'][0] = html_print_checkbox_switch( + 'throw_unknown_events', + 1, + $throw_unknown_events_check, + true, + $disabledBecauseInPolicy +); + +$table_advanced->data['caption_quiet'][0] = __('Quiet'); +$table_advanced->data['quiet'][0] = html_print_checkbox_switch( + 'quiet_module', + 1, + $quiet_module, + true, + $disabledBecauseInPolicy +); + +$table_advanced->data['caption_cascade_protection'][0] = __('Cascade Protection Services'); +$table_advanced->data['cascade_protection'][0] = html_print_select($cps_array, 'cps_module', $cps_module, '', '', 0, true, false, true, '', $disabledBecauseInPolicy); + + +$table_advanced->rowclass['caption_max_timeout_retries'] = 'w50p'; +$table_advanced->rowclass['max_timeout_retries'] = 'w50p'; +$table_advanced->data['caption_max_timeout_retries'][0] = __('Timeout'); +$table_advanced->data['caption_max_timeout_retries'][1] = __('Retries'); +$table_advanced->data['max_timeout_retries'][0] = html_print_input_text('max_timeout', $max_timeout, '', 5, 10, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy.' w100p'); +$table_advanced->data['max_timeout_retries'][1] = html_print_input_text('max_retries', $max_retries, '', 5, 10, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy.' w100p'); // Advanced form part. $table_macros = new stdClass(); @@ -1228,7 +1438,7 @@ if (isset($module_macros)) { $table_macros->data[$macro_count][2] = __('Value'); $table_macros->data[$macro_count][3] = html_print_input_text('module_macro_values[]', $macro_value, '', 50, 60, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy); if (!$disabledBecauseInPolicy) { - $table_macros->data[$macro_count][4] = ''.html_print_image('images/cross.png', true, ['class' => 'invert_filter']).''; + $table_macros->data[$macro_count][4] = ''.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).''; } $macro_count++; @@ -1237,7 +1447,7 @@ if (isset($module_macros)) { } if (!$disabledBecauseInPolicy) { - $table_macros->data[$macro_count][0] = ''.__('Custom macros').' '.html_print_image('images/add.png', true, ['class' => 'invert_filter']).''; + $table_macros->data[$macro_count][0] = ''.__('Custom macros').' '.html_print_image('images/fail@svg.svg', true, ['style' => 'rotate:45deg', 'class' => 'main_menu_icon invert_filter']).''; $table_macros->colspan[$macro_count][0] = 5; } @@ -1326,14 +1536,15 @@ $table_relations->data[-1][1] = ''; $table_relations->data[-1][2] = ''; $table_relations->data[-1][3] = ''; $table_relations->data[-1][3] .= html_print_image( - 'images/lock_mc.png', - true + 'images/policy@svg.svg', + true, + ['class' => 'main_menu_icon invert_filter'] ).''; $table_relations->data[-1][4] = ''; $table_relations->data[-1][4] .= html_print_image( - 'images/cross.png', + 'images/delete.svg', true, - ['class' => 'invert_filter'] + ['class' => 'main_menu_icon invert_filter'] ).''; @@ -1389,15 +1600,15 @@ if ($id_agent_module) { $table_relations->data[$relations_count][2] = ($module_relation['type'] === 'direct') ? __('Direct') : __('Failover'); // Lock relationship updates. $table_relations->data[$relations_count][3] = ''.html_print_image( - 'images/lock_mc.png', + 'images/policy@svg.svg', true, - ['class' => 'invert_filter'] + ['class' => 'main_menu_icon invert_filter'] ).''; // Delete relationship. $table_relations->data[$relations_count][4] = ''.html_print_image( - 'images/cross.png', + 'images/delete.svg', true, - ['class' => 'invert_filter'] + ['class' => 'main_menu_icon invert_filter'] ).''; $relations_count++; } @@ -1406,7 +1617,6 @@ if ($id_agent_module) { html_print_input_hidden('module_relations_count', $relations_count); ui_require_jquery_file('json'); - ?> diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index 4e00e0b340..f9c1117377 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -1,9 +1,8 @@ "; // Define a custom action to save the OID selected @@ -63,13 +64,13 @@ if (strstr($page, 'policy_modules') === false) { if ($disabledBecauseInPolicy) { $disabledTextBecauseInPolicy = 'readonly = "yes"'; $classdisabledBecauseInPolicy = 'readonly'; - $largeclassdisabledBecauseInPolicy = 'class = readonly'; + $largeclassdisabledBecauseInPolicy = 'readonly'; } } define('ID_NETWORK_COMPONENT_TYPE', 2); -if (empty($edit_module)) { +if (empty($edit_module) === true) { // Function in module_manager_editor_common.php. add_component_selection(ID_NETWORK_COMPONENT_TYPE); } @@ -78,12 +79,20 @@ $extra_title = __('Network server module'); $data = []; $data[0] = __('Target IP'); +if ((int) $id_module_type !== 6 && $id_module_type !== 7) { + $data[1] = __('Port'); +} + +$table_simple->rowclass['caption_target_ip'] = 'w50p'; +push_table_simple($data, 'caption_target_ip'); + +$data = []; // Show agent_for defect. -if ($page == 'enterprise/godmode/policies/policy_modules') { - if ($ip_target != 'auto' && $ip_target != '') { +if ($page === 'enterprise/godmode/policies/policy_modules') { + if (empty($ip_target) === false && $ip_target !== 'auto') { $custom_ip_target = $ip_target; $ip_target = 'custom'; - } else if ($ip_target == '') { + } else if (empty($ip_target) === true) { $ip_target = 'force_pri'; $custom_ip_target = ''; } else { @@ -95,7 +104,7 @@ if ($page == 'enterprise/godmode/policies/policy_modules') { $target_ip_values['force_pri'] = __('Force primary key'); $target_ip_values['custom'] = __('Custom'); - $data[1] = html_print_select( + $data[0] = html_print_select( $target_ip_values, 'ip_target', $ip_target, @@ -105,39 +114,38 @@ if ($page == 'enterprise/godmode/policies/policy_modules') { true, false, false, - '', + 'w100p', false, - 'width:200px;' ); - $data[1] .= html_print_input_text('custom_ip_target', $custom_ip_target, '', 15, 60, true); + $data[0] .= html_print_input_text('custom_ip_target', $custom_ip_target, '', 0, 60, true, false, false, '', 'w100p'); } else { - if ($ip_target == 'auto') { + if ($ip_target === 'auto') { $ip_target = agents_get_address($id_agente); } - $data[1] = html_print_input_text('ip_target', $ip_target, '', 15, 60, true); + $data[0] = html_print_input_text('ip_target', $ip_target, '', 0, 60, true, false, false, '', 'w100p'); } // In ICMP modules, port is not configurable. -if ($id_module_type >= 6 && $id_module_type <= 7) { - $data[2] = ''; - $data[3] = ''; -} else { - $data[2] = __('Port'); - $data[3] = html_print_input_text( +if ($id_module_type !== 6 && $id_module_type !== 7) { + $tcp_port = (empty($tcp_port) === false) ? $tcp_port : get_parameter('tcp_port'); + $data[1] = html_print_input_text( 'tcp_port', $tcp_port, '', - 5, + 0, 20, true, $disabledBecauseInPolicy, false, '', - $classdisabledBecauseInPolicy + $classdisabledBecauseInPolicy.' w100p', ); +} else { + $data[1] = ''; } +$table_simple->rowclass['target_ip'] = 'w50p'; push_table_simple($data, 'target_ip'); $user_groups = users_get_groups(false, 'AR'); @@ -162,7 +170,10 @@ if (empty($credentials) === false) { $data = []; $data[0] = __('Credential store'); - $data[1] = html_print_select( + push_table_simple($data, 'caption_snmp_credentials'); + + $data = []; + $data[0] = html_print_select( $fields, 'credentials', 0, @@ -178,102 +189,93 @@ if (empty($credentials) === false) { '', false ); - push_table_simple($data, 'snmp_credentials'); } +$data = []; +$data[0] = __('SNMP community'); +$data[1] = __('SNMP version'); +$data[2] = __('SNMP OID'); +$data[2] .= ui_print_help_icon('snmpwalk', true); +$table_simple->cellclass['snmp_1'][0] = 'w25p'; +$table_simple->cellclass['snmp_1'][1] = 'w25p'; +$table_simple->cellclass['snmp_1'][2] = 'w50p'; +push_table_simple($data, 'snmp_1'); + +if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && isset($id_agent_module) === true) { + $adopt = policies_is_module_adopt($id_agent_module); +} else { + $adopt = false; +} + +if ($adopt === false) { + $snmpCommunityInput = html_print_input_text( + 'snmp_community', + $snmp_community, + '', + 0, + 60, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy.' w100p' + ); +} else { + $snmpCommunityInput = html_print_input_text( + 'snmp_community', + $snmp_community, + '', + 0, + 60, + true, + false, + false, + '', + 'w100p' + ); +} $snmp_versions['1'] = 'v. 1'; $snmp_versions['2'] = 'v. 2'; $snmp_versions['2c'] = 'v. 2c'; $snmp_versions['3'] = 'v. 3'; -$data = []; -$data[0] = __('SNMP community'); -$adopt = false; -if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && isset($id_agent_module)) { - $adopt = policies_is_module_adopt($id_agent_module); -} +$snmpVersionsInput = html_print_select( + $snmp_versions, + 'snmp_version', + ($id_module_type >= 15 && $id_module_type <= 18) ? $snmp_version : 0, + '', + '', + '', + true, + false, + false, + '', + $disabledBecauseInPolicy, + 'width: 100%', + '', + $classdisabledBecauseInPolicy.' w100p' +); -if (!$adopt) { - $data[1] = html_print_input_text( - 'snmp_community', - $snmp_community, - '', - 15, - 60, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy - ); -} else { - $data[1] = html_print_input_text( - 'snmp_community', - $snmp_community, - '', - 15, - 60, - true, - false - ); -} - -$data[2] = _('SNMP version'); - -if ($id_module_type >= 15 && $id_module_type <= 18) { - $data[3] = html_print_select( - $snmp_versions, - 'snmp_version', - $snmp_version, - '', - '', - '', - true, - false, - false, - '', - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy - ); -} else { - $data[3] = html_print_select( - $snmp_versions, - 'snmp_version', - 0, - '', - '', - '', - true, - false, - false, - '', - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy - ); -} - -if ($disabledBecauseInPolicy) { +if ($disabledBecauseInPolicy === true) { if ($id_module_type >= 15 && $id_module_type <= 18) { - $data[3] .= html_print_input_hidden('snmp_version', $tcp_send, true); + $snmpVersionsInput .= html_print_input_hidden('snmp_version', $tcp_send, true); } } -push_table_simple($data, 'snmp_1'); - $data = []; -$data[0] = __('SNMP OID'); -$data[1] = ''; -$data[1] .= html_print_input_text( +$table_simple->cellclass['snmp_2'][0] = 'w25p'; +$table_simple->cellclass['snmp_2'][1] = 'w25p'; +$table_simple->cellclass['snmp_2'][2] = 'w50p'; + +$data[0] = $snmpCommunityInput; +$data[1] = $snmpVersionsInput; +$data[2] = html_print_input_text( 'snmp_oid', $snmp_oid, '', - 30, + 0, 255, true, $disabledBecauseInPolicy, @@ -281,8 +283,8 @@ $data[1] .= html_print_input_text( '', $classdisabledBecauseInPolicy ); -$data[1] .= ''; -$data[1] .= html_print_button( - __('SNMP walk'), +$data[2] .= ''; +$data[2] .= html_print_button( + __('SNMP Walk'), 'snmp_walk', false, 'snmpBrowserWindow()', - 'class="sub next"', + [ 'mode' => 'link' ], true ); -$data[1] .= ui_print_help_icon('snmpwalk', true); -$data[1] .= ''; -$table_simple->colspan['snmp_2'][1] = 3; push_table_simple($data, 'snmp_2'); // Advanced stuff. $data = []; $data[0] = __('TCP send'); -$data[1] = html_print_textarea( +$data[1] = __('TCP receive'); + +push_table_simple($data, 'caption_tcp_send_receive'); + +$data = []; +$data[0] = html_print_textarea( 'tcp_send', 2, 65, @@ -331,11 +334,6 @@ $data[1] = html_print_textarea( true, $largeclassdisabledBecauseInPolicy ); -$table_simple->colspan['tcp_send'][1] = 3; - -push_table_simple($data, 'tcp_send'); - -$data[0] = __('TCP receive'); $data[1] = html_print_textarea( 'tcp_rcv', 2, @@ -345,9 +343,8 @@ $data[1] = html_print_textarea( true, $largeclassdisabledBecauseInPolicy ); -$table_simple->colspan['tcp_receive'][1] = 3; -push_table_simple($data, 'tcp_receive'); +push_table_simple($data, 'tcp_send_receive'); if ($id_module_type < 8 || $id_module_type > 11) { // NOT TCP. @@ -475,33 +472,41 @@ push_table_simple($data, 'field_snmpv3_row3'); $data = []; $data[0] = __('Command'); -$data[1] = html_print_input_text_extended( - 'command_text', - $command_text, - 'command_text', - '', - 100, - 10000, - $disabledBecauseInPolicy, - '', - $largeClassDisabledBecauseInPolicy, - true -); -$data[1] .= ui_print_help_tip( +$data[0] .= ui_print_help_tip( __( 'Please use single quotation marks when necessary. '."\n".' If double quotation marks are needed, please escape them with a backslash (\")' ), true ); -$table_simple->colspan['row-cmd-row-1'][1] = 3; +push_table_simple($data, 'caption-row-cmd-row-1'); + +$data = []; +$data[0] = html_print_input_text_extended( + 'command_text', + $command_text, + 'command_text', + '', + 0, + 10000, + $disabledBecauseInPolicy, + '', + $largeClassDisabledBecauseInPolicy.' class="w100p"', + true +); +$table_simple->rowclass['row-cmd-row-1'] = 'w100p'; push_table_simple($data, 'row-cmd-row-1'); -require_once $config['homedir'].'/include/class/CredentialStore.class.php'; -$array_credential_identifier = CredentialStore::getKeys('CUSTOM'); - +$data = []; $data[0] = __('Credential identifier'); -$data[1] = html_print_select( +$data[1] = __('Connection method'); +// $table_simple->rowclass['row-cmd-row-1'] = 'w100p'; +$table_simple->cellclass['caption-row-cmd-row-2'][0] = 'w50p'; +$table_simple->cellclass['caption-row-cmd-row-2'][1] = 'w50p'; +push_table_simple($data, 'caption-row-cmd-row-2'); + +$data = []; +$data[0] = html_print_select( $array_credential_identifier, 'command_credential_identifier', $command_credential_identifier, @@ -512,10 +517,18 @@ $data[1] = html_print_select( false, false, '', - $disabledBecauseInPolicy + $disabledBecauseInPolicy, + 'width: 100%;' ); -$data[1] .= '

'.__('Manage credentials').''; +$data[0] .= html_print_button( + __('Manage credentials'), + 'manage_credentials_button', + false, + 'window.location.assign("index.php?sec=gmodules&sec2=godmode/groups/group_list&tab=credbox")', + [ 'mode' => 'link' ], + true +); $array_os = [ 'inherited' => __('Inherited'), @@ -523,8 +536,7 @@ $array_os = [ 'windows' => __('Windows remote'), ]; -$data[2] = __('Connection method'); -$data[3] = html_print_select( +$data[1] = html_print_select( $array_os, 'command_os', $command_os, @@ -535,9 +547,11 @@ $data[3] = html_print_select( false, false, '', - $disabledBecauseInPolicy + $disabledBecauseInPolicy, + 'width: 100%;' ); - +$table_simple->cellclass['row-cmd-row-2'][0] = 'w50p'; +$table_simple->cellclass['row-cmd-row-2'][1] = 'w50p'; push_table_simple($data, 'row-cmd-row-2'); if ($id_module_type !== 34 @@ -545,7 +559,9 @@ if ($id_module_type !== 34 && $id_module_type !== 36 && $id_module_type !== 37 ) { + $table_simple->rowstyle['caption-row-cmd-row-1'] = 'display: none;'; $table_simple->rowstyle['row-cmd-row-1'] = 'display: none;'; + $table_simple->rowstyle['caption-row-cmd-row-2'] = 'display: none;'; $table_simple->rowstyle['row-cmd-row-2'] = 'display: none;'; } @@ -581,9 +597,13 @@ $(document).ready (function () { (this.value == "37") ) { $("#simple-row-cmd-row-1").attr("style", ""); + $("#simple-caption-row-cmd-row-1").attr("style", ""); $("#simple-row-cmd-row-2").attr("style", ""); + $("#simple-caption-row-cmd-row-2").attr("style", ""); } else { + $("#simple-caption-row-cmd-row-1").css("display", "none"); $("#simple-row-cmd-row-1").css("display", "none"); + $("#simple-caption-row-cmd-row-2").css("display", "none"); $("#simple-row-cmd-row-2").css("display", "none"); } }); @@ -704,7 +724,7 @@ $(document).ready (function () { $("#text-custom_ip_target").hide(); } $('#ip_target').change(function() { - if($(this).val() == 'custom') { + if($(this).val() === 'custom') { $("#text-custom_ip_target").show(); } else{ diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index 2cc0ec3d8e..9477091e95 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -89,8 +89,7 @@ $password_fields = []; // If there are $macros, we create the form fields if (!empty($macros)) { - $macros = json_decode($macros, true); - + $macros = json_decode(io_safe_output($macros), true); foreach ($macros as $k => $m) { $data = []; $data[0] = $m['desc']; diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index cf35c8b0bf..92f98c808b 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -1,16 +1,31 @@ ** + // Erase the key of array serialize as **. $chunks = explode('**', reset(array_keys($ops))); $first_op = explode('_', $chunks[1]); - - - if (isset($first_op[1]) && $first_op[1] == 'avg') { + if (isset($first_op[1]) === true && $first_op[1] === 'avg') { $selected = 'synthetic_avg_selected'; } else { $selected = 'synthetic_selected'; @@ -109,23 +119,28 @@ $extra_title = __('Prediction server module'); $data = []; $data[0] = __('Source module'); $data[0] .= ui_print_help_icon('prediction_source_module', true); -$data[1] = ''; +push_table_simple($data, 'caption_module_service_synthetic_selector'); // Services and Synthetic are an Enterprise feature. $module_service_synthetic_selector = enterprise_hook('get_module_service_synthetic_selector', [$selected]); if ($module_service_synthetic_selector !== ENTERPRISE_NOT_HOOK) { - $data[1] = $module_service_synthetic_selector; + $data = []; + $data[0] = $module_service_synthetic_selector; $table_simple->colspan['module_service_synthetic_selector'][1] = 3; push_table_simple($data, 'module_service_synthetic_selector'); - - $data = []; - $data[0] = ''; } -$data[1] = '
'; -$data[1] .= html_print_label(__('Agent'), 'agent_name', true).'
'; +$data = []; +$data[0] = __('Agent'); +$data[1] = __('Module'); +$data[2] = __('Period'); +$table_simple->cellclass['caption_prediction_module'][0] = 'w33p'; +$table_simple->cellclass['caption_prediction_module'][1] = 'w33p'; +$table_simple->cellclass['caption_prediction_module'][2] = 'w33p'; +push_table_simple($data, 'caption_prediction_module'); -// Get module and agent of the target prediction module +$data = []; +// Get module and agent of the target prediction module. if (empty($prediction_module) === false) { $id_agente_clean = modules_get_agentmodule_agent($prediction_module); $prediction_module_agent = modules_get_agentmodule_agent_name($prediction_module); @@ -137,7 +152,6 @@ if (empty($prediction_module) === false) { $agent_alias = ''; } - $params = []; $params['return'] = true; $params['show_helptip'] = true; @@ -147,106 +161,105 @@ $params['javascript_is_function_select'] = true; $params['selectbox_id'] = 'prediction_module'; $params['none_module_text'] = __('Select Module'); $params['use_hidden_input_idagent'] = true; +$params['input_style'] = 'width: 100%;'; $params['hidden_input_idagent_id'] = 'hidden-id_agente_module_prediction'; -$data[1] .= ui_print_agent_autocomplete_input($params); +$data[0] = ui_print_agent_autocomplete_input($params); -$data[1] .= '
'; -$data[1] .= html_print_label(__('Module'), 'prediction_module', true).'
'; -if ($id_agente) { - $sql = 'SELECT id_agente_modulo, nombre - FROM tagente_modulo - WHERE delete_pending = 0 - AND history_data = 1 - AND id_agente = '.$id_agente_clean.' - AND id_agente_modulo <> '.$id_agente_modulo; - - $data[1] .= html_print_input( - [ - 'type' => 'select_from_sql', - 'sql' => $sql, - 'name' => 'prediction_module', - 'selected' => $prediction_module, - 'nothing' => __('Select Module'), - 'nothing_value' => 0, - 'return' => true, - ] +if ($id_agente > 0) { + $predictionModuleInput = html_print_select_from_sql( + 'SELECT id_agente_modulo, nombre + FROM tagente_modulo + WHERE delete_pending = 0 + AND history_data = 1 + AND id_agente = '.$id_agente_clean.' + AND id_agente_modulo <> '.$id_agente_modulo, + 'prediction_module', + $prediction_module, + '', + __('Select Module'), + 0, + true, + false, + true, + false, + 'width: 100%;' ); } else { - $data[1] .= ''; + $predictionModuleInput = ''; } -$data[1] .= '
'; -$data[1] .= html_print_label(__('Period'), 'custom_integer_2', true).'
'; - -$periods[0] = __('Weekly'); -$periods[1] = __('Monthly'); -$periods[2] = __('Daily'); -$data[1] .= html_print_select($periods, 'custom_integer_2', $custom_integer_2, '', '', 0, true); - -$data[1] .= html_print_input_hidden('id_agente_module_prediction', $id_agente, true); -$data[1] .= '
'; - -$table_simple->colspan['prediction_module'][1] = 3; +$data[1] = $predictionModuleInput; +$data[2] = html_print_select([__('Weekly'), __('Monthly'), __('Daily')], 'custom_integer_2', $custom_integer_2, '', '', 0, true, false, true, '', false, 'width: 100%;'); +$data[2] .= html_print_input_hidden('id_agente_module_prediction', $id_agente, true); +$table_simple->cellclass['prediction_module'][0] = 'w33p'; +$table_simple->cellclass['prediction_module'][1] = 'w33p'; +$table_simple->cellclass['prediction_module'][2] = 'w33p'; push_table_simple($data, 'prediction_module'); $data = []; -$data[0] = ''; +$data[0] = __('Calculation type'); +$data[1] = __('Future estimation'); +$data[2] = __('Limit value'); +$table_simple->cellclass['caption_capacity_planning'][0] = 'w33p'; +$table_simple->cellclass['caption_capacity_planning'][1] = 'w33p'; +$table_simple->cellclass['caption_capacity_planning'][2] = 'w33p'; +push_table_simple($data, 'caption_capacity_planning'); -$data[1] .= html_print_label(__('Calculation type'), 'estimation_type', true).'
'; -$data[1] .= html_print_input( +$data = []; +$data[0] = html_print_select( [ - 'type' => 'select', - 'return' => 'true', - 'name' => 'estimation_type', - 'class' => 'w250px', - 'fields' => [ - 'estimation_absolute' => __('Estimated absolute value'), - 'estimation_calculation' => __('Calculation of days to reach limit'), - ], - 'selected' => $estimation_type, + 'estimation_absolute' => __('Estimated absolute value'), + 'estimation_calculation' => __('Calculation of days to reach limit'), ], - 'div', - false + 'estimation_type', + $estimation_type, + '', + '', + 0, + true, + false, + true, + '', + false, + 'width: 100%;' ); -$data[1] .= '
'; -$data[1] .= html_print_label(__('Future estimation'), 'estimation_interval', true).'
'; -$data[1] .= html_print_input( +$data[1] = html_print_input( [ 'type' => 'interval', 'return' => 'true', 'name' => 'estimation_interval', 'value' => $estimation_interval, + 'class' => 'w100p', ], 'div', false ); -$data[1] .= '
'; - -$data[1] .= '
'; -$data[1] .= html_print_label(__('Limit value'), 'estimation_days', true).'
'; -$data[1] .= html_print_input( +$data[2] = html_print_input( [ 'type' => 'number', 'return' => 'true', 'id' => 'estimation_days', 'name' => 'estimation_days', 'value' => $estimation_interval, + 'class' => 'w100p', ] ); -$data[1] .= '
'; - +$table_simple->cellclass['capacity_planning'][0] = 'w33p'; +$table_simple->cellclass['capacity_planning'][1] = 'w33p'; +$table_simple->cellclass['capacity_planning'][2] = 'w33p'; push_table_simple($data, 'capacity_planning'); // Services are an Enterprise feature. $selector_form = enterprise_hook('get_selector_form', [$custom_integer_1]); if ($selector_form !== ENTERPRISE_NOT_HOOK) { $data = []; - $data[0] = ''; - $data[1] = $selector_form; + $data[0] = $selector_form['caption']; + push_table_simple($data, 'caption_service_module'); - $table_simple->colspan['service_module'][1] = 3; + $data = []; + $data[0] = $selector_form['input']; push_table_simple($data, 'service_module'); } @@ -254,38 +267,31 @@ if ($selector_form !== ENTERPRISE_NOT_HOOK) { $synthetic_module_form = enterprise_hook('get_synthetic_module_form'); if ($synthetic_module_form !== ENTERPRISE_NOT_HOOK) { $data = []; - $data[0] = ''; - $data[1] = $synthetic_module_form; - + $data[0] = $synthetic_module_form; push_table_simple($data, 'synthetic_module'); } $trending_module_form = enterprise_hook('get_trending_module_form', [$custom_string_1]); if ($trending_module_form !== ENTERPRISE_NOT_HOOK) { $data = []; - $data[0] = ''; - $data[1] .= $trending_module_form; + $data[0] = $trending_module_form['caption']; + push_table_simple($data, 'caption_trending_module'); + $data = []; + $data[0] = $trending_module_form['input']; push_table_simple($data, 'trending_module'); } - - // Netflow modules are an Enterprise feature. $netflow_module_form = enterprise_hook('get_netflow_module_form', [$custom_integer_1]); if ($netflow_module_form !== ENTERPRISE_NOT_HOOK) { $data = []; $data[0] = ''; $data[1] = $netflow_module_form; - - $table_simple->colspan['netflow_module_form'][1] = 3; push_table_simple($data, 'netflow_module'); } - - - -// Removed common useless parameter +// Removed common useless parameter. unset($table_advanced->data[3]); ?> \ No newline at end of file diff --git a/pandora_console/godmode/massive/massive_delete_agents.php b/pandora_console/godmode/massive/massive_delete_agents.php index 7a42dc721d..bb0dd1799d 100755 --- a/pandora_console/godmode/massive/massive_delete_agents.php +++ b/pandora_console/godmode/massive/massive_delete_agents.php @@ -148,7 +148,11 @@ $delete = (bool) get_parameter_post('delete'); if ($delete === true) { $result = process_manage_delete($id_agents); - $info = '{"Agent":"'.implode(',', $id_agents).'"}'; + if (empty($id_agents) === true) { + $info = '{"Agent":"empty"}'; + } else { + $info = '{"Agent":"'.implode(',', $id_agents).'"}'; + } if ($result === true) { db_pandora_audit( diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 85a0006986..a03e278957 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -2094,46 +2094,21 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' switch ($field) { case 'id_plugin': if ($value != 0) { - $value_field_1 = get_parameter('_field1_', ''); - $value_field_1_desc = get_parameter('desc_field1_', ''); - - $value_field_2 = get_parameter('_field2_', ''); - $value_field_2_desc = get_parameter('desc_field2_', ''); - - $value_field_3 = get_parameter('_field3_', ''); - $value_field_3_desc = get_parameter('desc_field3_', ''); - - $value_field_4 = get_parameter('_field4_', ''); - $value_field_4_desc = get_parameter('desc_field4_', ''); - - $value_field_5 = get_parameter('_field5_', ''); - $value_field_5_desc = get_parameter('desc_field5_', ''); - - $values['macros'] = '{"1":{"macro":"_field1_","desc":"'.io_safe_input($value_field_1_desc).'","help":"'.io_safe_input($value_field_1_desc).'","value":"'.$value_field_1.'"}'; - - if ($value_field_2_desc != '') { - $values['macros'] .= ',"2":{"macro":"_field2_","desc":"'.io_safe_input($value_field_2_desc).'","help":"'.io_safe_input($value_field_2_desc).'","value":"'.$value_field_2.'"}'; - - if ($value_field_3_desc != '') { - $values['macros'] .= ',"3":{"macro":"_field3_","desc":"'.io_safe_input($value_field_3_desc).'","help":"'.io_safe_input($value_field_3_desc).'","value":"'.$value_field_3.'"}'; - - if ($value_field_4_desc != '') { - $values['macros'] .= ',"4":{"macro":"_field4_","desc":"'.io_safe_input($value_field_4_desc).'","help":"'.io_safe_input($value_field_4_desc).'","value":"'.$value_field_4.'"}'; - - if ($value_field_5_desc != '') { - $values['macros'] .= ',"5":{"macro":"_field5_","desc":"'.io_safe_input($value_field_5_desc).'","help":"'.io_safe_input($value_field_5_desc).'","value":"'.$value_field_5.'"}'; - } else { - $values['macros'] .= '}'; - } - } else { - $values['macros'] .= '}'; - } - } else { - $values['macros'] .= '}'; + for ($i = 0; $i <= 15; $i++) { + $value_field = get_parameter('_field'.$i.'_', ''); + $value_field_desc = get_parameter('desc_field'.$i.'_', ''); + if ($value_field_desc != '') { + $values['macros'][$i] = [ + 'macro' => '_field'.$i.'_', + 'desc' => io_safe_input($value_field_desc), + 'help' => io_safe_input($value_field_desc), + 'value' => $value_field, + ]; } - } else { - $values['macros'] .= '}'; } + + $values['macros'] = json_encode($values['macros']); + $values[$field] = $value; } break; @@ -2260,7 +2235,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' // Apply at All agents (within valid groups). $modules = db_get_all_rows_sql( sprintf( - 'SELECT tam.id_agente_modulo, tam.id_tipo_modulo + 'SELECT tam.id_agente_modulo, tam.id_tipo_modulo,tam.macros, tam.id_plugin FROM tagente_modulo tam INNER JOIN tagente ta ON ta.id_agente = tam.id_agente WHERE ta.id_grupo IN (%s) %s;', @@ -2277,6 +2252,8 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' [ 'id_agente_modulo', 'id_tipo_modulo', + 'macros', + 'id_plugin', ] ); } else { @@ -2289,6 +2266,8 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' [ 'id_agente_modulo', 'id_tipo_modulo', + 'macros', + 'id_plugin', ] ); } @@ -2346,6 +2325,23 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' } } + if ($module['macros'] && $module['id_plugin'] == $values['id_plugin']) { + $module_macros = json_decode($module['macros'], true); + $values_macros = json_decode($values['macros'], true); + + foreach ($values_macros as $k => $value_macro) { + foreach ($module_macros as $s => $module_macro) { + if ($value_macro['macro'] == $module_macro['macro'] && $value_macro['value'] !== '') { + $module_macros[$s]['value'] = $value_macro['value']; + $module_macros[$s]['desc'] = $value_macro['desc']; + $module_macros[$s]['help'] = $value_macro['help']; + } + } + } + + $values['macros'] = json_encode($module_macros); + } + $result = modules_update_agent_module( $module['id_agente_modulo'], $values, diff --git a/pandora_console/godmode/massive/massive_edit_users.php b/pandora_console/godmode/massive/massive_edit_users.php index 2f1cbeb4fe..ddbd45c440 100644 --- a/pandora_console/godmode/massive/massive_edit_users.php +++ b/pandora_console/godmode/massive/massive_edit_users.php @@ -61,7 +61,6 @@ if (is_management_allowed() === false) { if (is_metaconsole() === true) { include_once $config['homedir'].'/include/functions_visual_map.php'; - open_meta_frame(); } $edit_users = (int) get_parameter('edit_users'); @@ -589,8 +588,6 @@ if (is_metaconsole() === false) { }); diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index d2e11b8c89..100b3eb933 100755 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.php @@ -216,7 +216,7 @@ if ($option == '') { $alertstab = [ 'text' => ''.html_print_image( - 'images/bell.png', + 'images/alert@svg.svg', true, [ 'title' => __('Alerts operations'), @@ -228,7 +228,7 @@ $alertstab = [ $userstab = [ 'text' => ''.html_print_image( - 'images/user.png', + 'images/user.svg', true, [ 'title' => __('Users operations'), @@ -240,7 +240,7 @@ $userstab = [ $agentstab = [ 'text' => ''.html_print_image( - 'images/agent.png', + 'images/agents@svg.svg', true, [ 'title' => __('Agents operations'), @@ -252,7 +252,7 @@ $agentstab = [ $modulestab = [ 'text' => ''.html_print_image( - 'images/module.png', + 'images/modules@svg.svg', true, [ 'title' => __('Modules operations'), @@ -264,7 +264,7 @@ $modulestab = [ $pluginstab = [ 'text' => ''.html_print_image( - 'images/plugin.png', + 'images/plugins@svg.svg', true, [ 'title' => __('Plugins operations'), diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index d98eb9d3c6..2efafad20b 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -33,10 +33,11 @@ require_once 'include/functions_menu.php'; check_login(); -$access_console_node = !is_reporting_console_node(); +$access_console_node = is_reporting_console_node() === false; $menu_godmode = []; $menu_godmode['class'] = 'godmode'; +$menuGodmode = []; if ($access_console_node === true) { enterprise_include('godmode/menu.php'); } @@ -49,7 +50,7 @@ if ((bool) check_acl($config['id_user'], 0, 'AR') === true ) { $sub = []; $sub['godmode/servers/discovery&wiz=main']['text'] = __('Start'); - $sub['godmode/servers/discovery&wiz=main']['id'] = 'Discovery'; + $sub['godmode/servers/discovery&wiz=main']['id'] = 'discovery'; $sub['godmode/servers/discovery&wiz=tasklist']['text'] = __('Task list'); $sub['godmode/servers/discovery&wiz=tasklist']['id'] = 'tasklist'; @@ -71,6 +72,8 @@ if ((bool) check_acl($config['id_user'], 0, 'AR') === true $sub['godmode/servers/discovery&wiz=hd']['text'] = __('Host & devices'); $sub['godmode/servers/discovery&wiz=hd']['id'] = 'hd'; + $sub['godmode/servers/discovery&wiz=hd']['type'] = 'direct'; + $sub['godmode/servers/discovery&wiz=hd']['subtype'] = 'nolink'; $sub['godmode/servers/discovery&wiz=hd']['sub2'] = $sub2; } @@ -92,36 +95,36 @@ if ($access_console_node === true) { $sub = []; if ((bool) check_acl($config['id_user'], 0, 'AW') === true || (bool) check_acl($config['id_user'], 0, 'AD') === true) { $sub['godmode/agentes/modificar_agente']['text'] = __('Manage agents'); - $sub['godmode/agentes/modificar_agente']['id'] = 'Manage agents'; + $sub['godmode/agentes/modificar_agente']['id'] = 'Manage_agents'; $sub['godmode/agentes/modificar_agente']['subsecs'] = ['godmode/agentes/configurar_agente']; } if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { $sub['godmode/agentes/fields_manager']['text'] = __('Custom fields'); - $sub['godmode/agentes/fields_manager']['id'] = 'Custom fields'; + $sub['godmode/agentes/fields_manager']['id'] = 'custom_fields'; $sub['godmode/modules/manage_nc_groups']['text'] = __('Component groups'); - $sub['godmode/modules/manage_nc_groups']['id'] = 'Component groups'; + $sub['godmode/modules/manage_nc_groups']['id'] = 'component_groups'; // Category. $sub['godmode/category/category']['text'] = __('Module categories'); - $sub['godmode/category/category']['id'] = 'Module categories'; + $sub['godmode/category/category']['id'] = 'module_categories'; $sub['godmode/category/category']['subsecs'] = 'godmode/category/edit_category'; $sub['godmode/modules/module_list']['text'] = __('Module types'); - $sub['godmode/modules/module_list']['id'] = 'Module types'; + $sub['godmode/modules/module_list']['id'] = 'module_types'; $sub['godmode/groups/modu_group_list']['text'] = __('Module groups'); - $sub['godmode/groups/modu_group_list']['id'] = 'Module groups'; + $sub['godmode/groups/modu_group_list']['id'] = 'module_groups'; $sub['godmode/setup/os']['text'] = __('Operating systems'); - $sub['godmode/setup/os']['id'] = 'Edit OS'; + $sub['godmode/setup/os']['id'] = 'edit_OS'; } if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { // Netflow. if ((bool) $config['activate_netflow'] === true) { $sub['godmode/netflow/nf_edit']['text'] = __('Netflow filters'); - $sub['godmode/netflow/nf_edit']['id'] = 'Netflow filters'; + $sub['godmode/netflow/nf_edit']['id'] = 'netflow_filters'; } } @@ -135,13 +138,13 @@ if ($access_console_node === true) { $sub = []; if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { $sub['godmode/groups/group_list']['text'] = __('Manage agents groups'); - $sub['godmode/groups/group_list']['id'] = 'Manage agents groups'; + $sub['godmode/groups/group_list']['id'] = 'manage_agents_groups'; } if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { // Tag. $sub['godmode/tag/tag']['text'] = __('Module tags'); - $sub['godmode/tag/tag']['id'] = 'Module tags'; + $sub['godmode/tag/tag']['id'] = 'module_tags'; $sub['godmode/tag/tag']['subsecs'] = 'godmode/tag/edit_tag'; enterprise_hook('enterprise_acl_submenu'); @@ -149,12 +152,12 @@ if ($access_console_node === true) { if ((bool) check_acl($config['id_user'], 0, 'UM') === true) { $sub['godmode/users/user_list']['text'] = __('Users management'); - $sub['godmode/users/user_list']['id'] = 'Users management'; + $sub['godmode/users/user_list']['id'] = 'Users_management'; } if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { $sub['godmode/users/profile_list']['text'] = __('Profile management'); - $sub['godmode/users/profile_list']['id'] = 'Profile management'; + $sub['godmode/users/profile_list']['id'] = 'Profile_management'; } if (empty($sub) === false) { @@ -172,17 +175,17 @@ if ($access_console_node === true) { $sub['templates']['subtype'] = 'nolink'; $sub2 = []; $sub2['godmode/modules/manage_module_templates']['text'] = __('Module templates'); - $sub2['godmode/modules/manage_module_templates']['id'] = 'Module templates'; + $sub2['godmode/modules/manage_module_templates']['id'] = 'module_templates'; $sub2['godmode/modules/private_enterprise_numbers']['text'] = __('Private Enterprise Numbers'); - $sub2['godmode/modules/private_enterprise_numbers']['id'] = 'Private Enterprise Numbers'; + $sub2['godmode/modules/private_enterprise_numbers']['id'] = 'private_Enterprise_Numbers'; $sub2['enterprise/godmode/modules/local_components']['text'] = __('Local components'); - $sub2['enterprise/godmode/modules/local_components']['id'] = 'Local components'; + $sub2['enterprise/godmode/modules/local_components']['id'] = 'local_components'; $sub2['godmode/modules/manage_network_components']['text'] = __('Remote components'); - $sub2['godmode/modules/manage_network_components']['id'] = 'Network components'; + $sub2['godmode/modules/manage_network_components']['id'] = 'network_components'; $sub['templates']['sub2'] = $sub2; $sub['godmode/modules/manage_inventory_modules']['text'] = __('Inventory modules'); - $sub['godmode/modules/manage_inventory_modules']['id'] = 'Inventory modules'; + $sub['godmode/modules/manage_inventory_modules']['id'] = 'Inventory_modules'; enterprise_hook('autoconfiguration_menu'); enterprise_hook('agent_repository_menu'); @@ -199,7 +202,7 @@ if ($access_console_node === true) { if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { $sub['gmassive']['text'] = __('Bulk operations'); - $sub['gmassive']['id'] = 'Bulk operations'; + $sub['gmassive']['id'] = 'Bulk_operations'; $sub['gmassive']['type'] = 'direct'; $sub['gmassive']['subtype'] = 'nolink'; $sub2 = []; @@ -221,7 +224,7 @@ if ($access_console_node === true) { if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) check_acl($config['id_user'], 0, 'UM') === true) { $sub['godmode/groups/group_list&tab=credbox']['text'] = __('Credential store'); - $sub['godmode/groups/group_list&tab=credbox']['id'] = 'credential store'; + $sub['godmode/groups/group_list&tab=credbox']['id'] = 'credential_store'; } // Manage events. @@ -229,14 +232,14 @@ if ($access_console_node === true) { if ((bool) check_acl($config['id_user'], 0, 'EW') === true || (bool) check_acl($config['id_user'], 0, 'EM') === true) { // Custom event fields. $sub2['godmode/events/events§ion=filter']['text'] = __('Event filters'); - $sub2['godmode/events/events§ion=filter']['id'] = 'Event filters'; + $sub2['godmode/events/events§ion=filter']['id'] = 'event_filters'; } if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { $sub2['godmode/events/events§ion=fields']['text'] = __('Custom columns'); - $sub2['godmode/events/events§ion=fields']['id'] = 'Custom events'; + $sub2['godmode/events/events§ion=fields']['id'] = 'Custom_events'; $sub2['godmode/events/events§ion=responses']['text'] = __('Event responses'); - $sub2['godmode/events/events§ion=responses']['id'] = 'Event responses'; + $sub2['godmode/events/events§ion=responses']['id'] = 'Event_responses'; } if (empty($sub2) === false) { @@ -265,12 +268,12 @@ if ($access_console_node === true) { $sub = []; $sub['godmode/alerts/alert_list']['text'] = __('List of Alerts'); - $sub['godmode/alerts/alert_list']['id'] = 'List of Alerts'; + $sub['godmode/alerts/alert_list']['id'] = 'List_of_Alerts'; $sub['godmode/alerts/alert_list']['pages'] = ['godmode/alerts/alert_view']; if ((bool) check_acl($config['id_user'], 0, 'LM') === true) { $sub['godmode/alerts/alert_templates']['text'] = __('Templates'); - $sub['godmode/alerts/alert_templates']['id'] = 'Templates'; + $sub['godmode/alerts/alert_templates']['id'] = 'templates'; $sub['godmode/alerts/alert_templates']['pages'] = ['godmode/alerts/configure_alert_template']; $sub['godmode/alerts/alert_actions']['text'] = __('Actions'); @@ -280,12 +283,12 @@ if ($access_console_node === true) { $sub['godmode/alerts/alert_commands']['id'] = 'Commands'; $sub['godmode/alerts/alert_commands']['pages'] = ['godmode/alerts/configure_alert_command']; $sub['godmode/alerts/alert_special_days']['text'] = __('Special days list'); - $sub['godmode/alerts/alert_special_days']['id'] = __('Special days list'); + $sub['godmode/alerts/alert_special_days']['id'] = 'Special_days_list'; $sub['godmode/alerts/alert_special_days']['pages'] = ['godmode/alerts/configure_alert_special_days']; enterprise_hook('eventalerts_submenu'); $sub['godmode/snmpconsole/snmp_alert']['text'] = __('SNMP alerts'); - $sub['godmode/snmpconsole/snmp_alert']['id'] = 'SNMP alerts'; + $sub['godmode/snmpconsole/snmp_alert']['id'] = 'SNMP_alerts'; enterprise_hook('alert_inventory_submenu'); } @@ -302,7 +305,7 @@ if ($access_console_node === true) { if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { $sub['godmode/servers/modificar_server']['text'] = __('Manage servers'); - $sub['godmode/servers/modificar_server']['id'] = 'Manage servers'; + $sub['godmode/servers/modificar_server']['id'] = 'Manage_servers'; } // This subtabs are only for Pandora Admin. @@ -339,7 +342,7 @@ if ($access_console_node === true) { $sub2 = []; $sub2['godmode/setup/setup§ion=general']['text'] = __('General Setup'); - $sub2['godmode/setup/setup§ion=general']['id'] = 'General Setup'; + $sub2['godmode/setup/setup§ion=general']['id'] = 'general_Setup'; $sub2['godmode/setup/setup§ion=general']['refr'] = 0; enterprise_hook('password_submenu'); @@ -380,13 +383,16 @@ if ($access_console_node === true) { $sub2['godmode/setup/setup§ion=external_tools']['text'] = __('External Tools'); $sub2['godmode/setup/setup§ion=external_tools']['refr'] = 0; + $sub2['godmode/setup/setup§ion=welcome_tips']['text'] = __('Welcome Tips'); + $sub2['godmode/setup/setup§ion=welcome_tips']['refr'] = 0; + if ((bool) $config['activate_gis'] === true) { $sub2['godmode/setup/setup§ion=gis']['text'] = __('Map conections GIS'); } $sub['general']['sub2'] = $sub2; $sub['godmode/setup/license']['text'] = __('License'); - $sub['godmode/setup/license']['id'] = 'License'; + $sub['godmode/setup/license']['id'] = 'license'; enterprise_hook('skins_submenu'); @@ -406,28 +412,28 @@ if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) check_acl($ if ($access_console_node === true) { // Audit //meter en extensiones. $sub['godmode/audit_log']['text'] = __('System audit log'); - $sub['godmode/audit_log']['id'] = 'System audit log'; + $sub['godmode/audit_log']['id'] = 'system_audit_log'; $sub['godmode/setup/links']['text'] = __('Links'); - $sub['godmode/setup/links']['id'] = 'Links'; + $sub['godmode/setup/links']['id'] = 'links'; $sub['tools/diagnostics']['text'] = __('Diagnostic info'); - $sub['tools/diagnostics']['id'] = 'Diagnostic info'; + $sub['tools/diagnostics']['id'] = 'diagnostic_info'; enterprise_hook('omnishell'); enterprise_hook('ipam_submenu'); $sub['godmode/setup/news']['text'] = __('Site news'); - $sub['godmode/setup/news']['id'] = 'Site news'; + $sub['godmode/setup/news']['id'] = 'site_news'; } $sub['godmode/setup/file_manager']['text'] = __('File manager'); - $sub['godmode/setup/file_manager']['id'] = 'File manager'; + $sub['godmode/setup/file_manager']['id'] = 'file_manager'; if ($access_console_node === true) { if (is_user_admin($config['id_user']) === true) { $sub['extensions/db_status']['text'] = __('DB Schema Check'); - $sub['extensions/db_status']['id'] = 'DB Schema Check'; + $sub['extensions/db_status']['id'] = 'DB_Schema_Check'; $sub['extensions/db_status']['sec'] = 'gextensions'; $sub['extensions/dbmanager']['text'] = __('DB Interface'); - $sub['extensions/dbmanager']['id'] = 'DB Interface'; + $sub['extensions/dbmanager']['id'] = 'DB_Interface'; $sub['extensions/dbmanager']['sec'] = 'gextensions'; enterprise_hook('dbBackupManager'); enterprise_hook('elasticsearch_interface_menu'); @@ -435,6 +441,10 @@ if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) check_acl($ } } + $sub['godmode/events/configuration_sounds']['text'] = __('Accoustic console setup'); + $sub['godmode/events/configuration_sounds']['id'] = 'Accoustic console setup'; + $sub['godmode/events/configuration_sounds']['pages'] = ['godmode/events/configuration_sounds']; + $menu_godmode['gextensions']['sub'] = $sub; } @@ -465,7 +475,7 @@ if ($access_console_node === true) { // Check if was displayed inside other menu. if (empty($extension['godmode_menu']['fatherId']) === true) { $sub2[$extmenu['sec2']]['text'] = __($extmenu['name']); - $sub2[$extmenu['sec2']]['id'] = $extmenu['name']; + $sub2[$extmenu['sec2']]['id'] = str_replace(' ', '_', $extmenu['name']); $sub2[$extmenu['sec2']]['refr'] = 0; } else { if (is_array($extmenu) === true && array_key_exists('fatherId', $extmenu) === true) { @@ -473,7 +483,7 @@ if ($access_console_node === true) { if (array_key_exists('subfatherId', $extmenu) === true) { if (strlen($extmenu['subfatherId']) > 0) { $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]['text'] = __($extmenu['name']); - $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]['id'] = $extmenu['name']; + $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]['id'] = str_replace(' ', '_', $extmenu['name']); $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]['refr'] = 0; $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]['icon'] = $extmenu['icon']; $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]['sec'] = 'extensions'; @@ -482,7 +492,7 @@ if ($access_console_node === true) { $menu_godmode[$extmenu['fatherId']]['hasExtensions'] = true; } else { $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]['text'] = __($extmenu['name']); - $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]['id'] = $extmenu['name']; + $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]['id'] = str_replace(' ', '_', $extmenu['name']); $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]['refr'] = 0; $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]['icon'] = $extmenu['icon']; $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]['sec'] = $extmenu['fatherId']; @@ -492,7 +502,7 @@ if ($access_console_node === true) { } } else { $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]['text'] = __($extmenu['name']); - $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]['id'] = $extmenu['name']; + $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]['id'] = str_replace(' ', '_', $extmenu['name']); $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]['refr'] = 0; $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]['icon'] = $extmenu['icon']; $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]['sec'] = 'gextensions'; @@ -507,13 +517,13 @@ if ($access_console_node === true) { // Complete the submenu. $extension_view = []; - $extension_view['godmode/extensions']['id'] = 'Extension manager view'; + $extension_view['godmode/extensions']['id'] = 'extension_manager_view'; $extension_view['godmode/extensions']['text'] = __('Extension manager view'); $extension_submenu = array_merge($extension_view, $sub2); $sub['godmode/extensions']['sub2'] = $extension_submenu; $sub['godmode/extensions']['text'] = __('Extension manager'); - $sub['godmode/extensions']['id'] = 'Extension manager'; + $sub['godmode/extensions']['id'] = 'extension_manager'; $sub['godmode/extensions']['type'] = 'direct'; $sub['godmode/extensions']['subtype'] = 'nolink'; diff --git a/pandora_console/godmode/module_library/module_library_view.php b/pandora_console/godmode/module_library/module_library_view.php index aeab26be20..aea7681f3b 100644 --- a/pandora_console/godmode/module_library/module_library_view.php +++ b/pandora_console/godmode/module_library/module_library_view.php @@ -45,18 +45,18 @@ if (! check_acl($config['id_user'], 0, 'AR')) { if (check_acl($config['id_user'], 0, 'PM') && enterprise_installed()) { $buttons['setup'] = [ 'active' => false, - 'text' => ''.html_print_image('images/gm_setup.png', true, ['title' => __('Setup'), 'class' => 'invert_filter']).'', + 'text' => ''.html_print_image('images/configuration@svg.svg', true, ['title' => __('Setup'), 'class' => 'main_menu_icon invert_filter']).'', ]; } $buttons['categories'] = [ 'active' => false, - 'text' => ''.html_print_image('images/list.png', true, ['title' => __('Categories'), 'class' => 'invert_filter']).'', + 'text' => ''.html_print_image('images/logs@svg.svg', true, ['title' => __('Categories'), 'class' => 'main_menu_icon invert_filter']).'', ]; $buttons['view'] = [ 'active' => false, - 'text' => ''.html_print_image('images/eye_show.png', true, ['title' => __('View'), 'class' => 'invert_filter']).'', + 'text' => ''.html_print_image('images/see-details@svg.svg', true, ['title' => __('View'), 'class' => 'main_menu_icon invert_filter']).'', ]; diff --git a/pandora_console/godmode/modules/manage_inventory_modules.php b/pandora_console/godmode/modules/manage_inventory_modules.php index e81fa05cd9..86cd55bcb6 100644 --- a/pandora_console/godmode/modules/manage_inventory_modules.php +++ b/pandora_console/godmode/modules/manage_inventory_modules.php @@ -33,7 +33,6 @@ $management_allowed = is_management_allowed(); if (is_metaconsole() === true) { $sec = 'advanced'; enterprise_include_once('meta/include/functions_components_meta.php'); - enterprise_hook('open_meta_frame'); components_meta_print_header(); if ($management_allowed === false) { @@ -41,12 +40,24 @@ if (is_metaconsole() === true) { } } else { $sec = 'gmodules'; - ui_print_page_header( - __('Module management').' » '.__('Inventory modules'), - 'images/page_white_text.png', + + ui_print_standard_header( + __('Inventory modules'), + 'images/hardware-software-component@svg.svg', false, '', - true + true, + [], + [ + [ + 'link' => '', + 'label' => __('Configuration'), + ], + [ + 'link' => '', + 'label' => __('Inventory modules'), + ], + ] ); if ($management_allowed === false) { @@ -266,7 +277,7 @@ if ($create_module_inventory === true) { $total_modules = db_get_sql('SELECT COUNT(*) FROM tmodule_inventory'); $table = new stdClass(); -$table->width = '100%'; +$table->styleTable = 'margin: 10px 10px 0; width: -webkit-fill-available; width: -moz-available'; $table->class = 'info_table'; $table->size = []; $table->size[0] = '140px'; @@ -282,6 +293,7 @@ $table->head[3] = __('Interpreter'); if ($management_allowed === true) { $table->head[4] = __('Action').html_print_checkbox('all_delete', 0, false, true, false); + $table->size[4] = '80px'; } $result = inventory_get_modules_list($offset); @@ -302,9 +314,15 @@ if ($result === false) { $data[1] = $row['description']; if ($row['os_name'] == null) { - $data[2] = html_print_image('images/agent.png', true, ['border' => '0', 'alt' => __('Agent'), 'title' => __('Agent'), 'height' => '18', 'class' => 'invert_filter']); + $data[2] = html_print_image('images/agents@svg.svg', true, ['border' => '0', 'alt' => __('Agent'), 'title' => __('Agent'), 'height' => '18', 'class' => 'invert_filter main_menu_icon']); } else { - $data[2] = ui_print_os_icon($row['id_os'], false, true); + $data[2] = html_print_div( + [ + 'class' => 'invert_filter main_menu_icon', + 'content' => ui_print_os_icon($row['id_os'], false, true), + ], + true + ); } if ($row['interpreter'] == '') { @@ -315,45 +333,78 @@ if ($result === false) { if ($management_allowed === true) { // Update module. - $data[4] = ''; - $data[4] .= html_print_image('images/config.png', true, ['border' => '0', 'title' => __('Update'), 'class' => 'invert_filter']).''; + $data[4] = ''; } array_push($table->data, $data); } - echo "
"; + echo ''; html_print_input_hidden('multiple_delete', 1); - ui_pagination($total_modules, 'index.php?sec='.$sec.'&sec2=godmode/modules/manage_inventory_modules', $offset); html_print_table($table); - ui_pagination($total_modules, 'index.php?sec='.$sec.'&sec2=godmode/modules/manage_inventory_modules', $offset, 0, false, 'offset', true, 'pagination-bottom'); - echo "
"; + echo ''; + + echo '
'; + echo html_print_input_hidden('create_module_inventory', 1); + echo ''; + + $tablePagination = ui_pagination( + $total_modules, + 'index.php?sec='.$sec.'&sec2=godmode/modules/manage_inventory_modules', + $offset, + 0, + true, + 'offset', + false + ); + + $actionButtons = ''; + if ($management_allowed === true) { - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); + $actionButtons .= html_print_submit_button( + __('Create'), + 'crt', + false, + [ + 'icon' => 'wand', + 'form' => 'form_create', + ], + true + ); + + $actionButtons .= html_print_submit_button( + __('Delete'), + 'delete_btn', + false, + [ + 'icon' => 'delete', + 'mode' => 'secondary', + 'form' => 'form_delete', + ], + true + ); } - echo '
'; - echo ''; + html_print_action_buttons( + $actionButtons, + [ + 'type' => 'form_action', + 'right_content' => $tablePagination, + ], + false + ); } -if ($management_allowed === true) { - echo '
'; - echo '
'; - html_print_input_hidden('create_module_inventory', 1); - html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"'); - echo '
'; - echo '
'; -} - - if (is_metaconsole() === true) { - enterprise_hook('close_meta_frame'); echo '