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/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 5a537cea8d..5a6b6e4894 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.769-230221 +Version: 7.0NG.769-230310 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 3bdb964eb0..0ff5c31c0b 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.769-230221" +pandora_version="7.0NG.769-230310" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index cd0fdd0989..0e6522165b 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1023,7 +1023,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.769'; -use constant AGENT_BUILD => '230221'; +use constant AGENT_BUILD => '230310'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 1a82c15221..c23d462fd1 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.769 -%define release 230221 +%define release 230310 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 4015375532..33324b25e1 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.769 -%define release 230221 +%define release 230310 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 6d8458b318..ab50df62d1 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.769" -PI_BUILD="230221" +PI_BUILD="230310" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index bd75795838..8d6bea8586 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230221} +{230310} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index f38933f5b9..024db5dc39 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.769 Build 230221") +#define PANDORA_VERSION ("7.0NG.769 Build 230310") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 21f5675492..63db898d79 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.769(Build 230221))" + VALUE "ProductVersion", "(7.0NG.769(Build 230310))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 919f840961..de8bff7c41 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.769-230221 +Version: 7.0NG.769-230310 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 524fd6c38c..486224eab7 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.769-230221" +pandora_version="7.0NG.769-230310" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 487f1b476d..d3467b846c 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -377,17 +377,17 @@ function mainAgentsModules() $fullscreen['text'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; + &full_agents_id='.$full_agents.'&selection_agent_module='.$selection_a_m.'">'.html_print_image('images/fullscreen@svg.svg', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; } else if ($full_modules_selected[0] && $full_agents_id[0]) { $full_modules = urlencode(implode(';', $full_modules_selected)); $full_agents = urlencode(implode(';', $full_agents_id)); $fullscreen['text'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; + &full_agents_id='.$full_agents.'&selection_agent_module='.$selection_a_m.'">'.html_print_image('images/fullscreen@svg.svg', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; } else { $fullscreen['text'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; + offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&show_type='.$show_type.'">'.html_print_image('images/fullscreen@svg.svg', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; } } @@ -397,61 +397,139 @@ function mainAgentsModules() 1 => __('Show module data'), ]; - $filter_type_label = ''.__('Information to be shown').''; - $filter_type = html_print_select($show_select, 'show_type', $show_type, '', '', 0, true, false, false, '', false, 'min-width: 180px;'); - - // Groups. - $filter_groups_label = ''.__('Group').''; - $filter_groups = html_print_select_groups(false, 'AR', true, 'group_id', $group_id, '', '', '', true, false, true, '', false, 'width: auto;'); - - $filter_recursion_label = ''.__('Recursion').''; - $filter_recursion = html_print_checkbox('recursion', 1, 0, true).''; - // Groups module. - $filter_module_groups_label = ''.__('Module group').''; - $filter_module_groups = html_print_select_from_sql( - 'SELECT * FROM tmodule_group ORDER BY name', - 'modulegroup', - $modulegroup, - '', - __('All'), - 0, - true, - false, - true, - false, - 'width: auto;' + $filter_type = html_print_label_input_block( + __('Information to be shown'), + html_print_select( + $show_select, + 'show_type', + $show_type, + '', + '', + 0, + true, + false, + false, + '', + false, + 'width: 100%;' + ) + ); + + $filter_groups = html_print_label_input_block( + __('Group'), + html_print_select_groups( + false, + 'AR', + true, + 'group_id', + $group_id, + '', + '', + '', + true, + false, + true, + '', + false, + 'width: 100%;' + ) + ); + + $filter_groups .= html_print_label_input_block( + __('Recursion'), + html_print_checkbox_switch('recursion', 1, 0, true), + [ + 'div_class' => 'add-input-reverse', + 'label_class' => 'label-thin', + ] + ); + + $filter_module_groups = html_print_label_input_block( + __('Module group'), + html_print_select_from_sql( + 'SELECT * FROM tmodule_group ORDER BY name', + 'modulegroup', + $modulegroup, + '', + __('All'), + 0, + true, + false, + true, + false, + 'width: 100%;' + ) ); - // Agent. $agents = agents_get_group_agents($group_id); if ((empty($agents)) || $agents == -1) { $agents = []; } - $filter_agents_label = ''.__('Agents').''; - $filter_agents = html_print_select($agents, 'id_agents2[]', $agents_id, '', '', 0, true, true, true, '', false, 'min-width: 180px; max-width: 200px;'); + $filter_agents = html_print_label_input_block( + __('Agents'), + html_print_select( + $agents, + 'id_agents2[]', + $agents_id, + '', + '', + 0, + true, + true, + true, + '', + false, + 'width: 100%;' + ) + ); // Type show. $selection = [ 0 => __('Show common modules'), 1 => __('Show all modules'), ]; - $filter_type_show_label = ''.__('Show common modules').''; - $filter_type_show = html_print_select($selection, 'selection_agent_module', $selection_a_m, '', '', 0, true, false, true, '', false, 'min-width: 180px;'); + $filter_type_show = html_print_label_input_block( + __('Show common modules'), + html_print_select( + $selection, + 'selection_agent_module', + $selection_a_m, + '', + '', + 0, + true, + false, + true, + '', + false, + 'width: 100%;' + ) + ); // Modules. $all_modules = select_modules_for_agent_group($group_id, $agents_id, $selection_a_m, false); - $filter_modules_label = ''.__('Module').''; - $filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', '', 0, true, true, false, '', false, 'min-width: 180px; max-width: 200px;'); - - // Update. - $filter_update = html_print_submit_button(__('Update item'), 'edit_item', false, 'class="sub upd"', true); + $filter_modules = html_print_label_input_block( + __('Module'), + html_print_select( + $all_modules, + 'module[]', + $modules_selected, + '', + '', + 0, + true, + true, + false, + '', + false, + 'width: 100%;' + ) + ); $onheader = [ - 'updated_time' => $updated_time, - 'fullscreen' => $fullscreen, - 'combo_module_groups' => $filter_module_groups, - 'combo_groups' => $filter_groups, + 'updated_time' => $updated_time, + 'fullscreen' => $fullscreen, ]; /* @@ -467,7 +545,7 @@ function mainAgentsModules() false, '', false, - (array) $updated_time, + $onheader, [ [ 'link' => '', @@ -479,12 +557,6 @@ function mainAgentsModules() ], ] ); - - echo ''; - echo ''; - echo "'; - echo ''; - echo '
".$fullscreen['text'].'
'; } else { if ($full_agents_id[0]) { $full_modules = urlencode(implode(';', $full_modules_selected)); @@ -525,11 +597,11 @@ function mainAgentsModules() echo '
  • '; echo ''; echo html_print_image( - 'images/normal_screen.png', + 'images/exit_fullscreen@svg.svg', true, [ 'title' => __('Back to normal mode'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); echo ''; @@ -574,35 +646,46 @@ function mainAgentsModules() if ($config['pure'] != 1) { $show_filters = '
    '; - $show_filters .= ''; + $show_filters .= '
    '; $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; $show_filters .= ''; $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; $show_filters .= ''; - $show_filters .= ''; $show_filters .= ''; - $show_filters .= ''; $show_filters .= ''; $show_filters .= ''; - $show_filters .= ''; - $show_filters .= "'; - $show_filters .= ''; $show_filters .= '
    '.$filter_type_label.''.$filter_type.''.$filter_type.''.$filter_groups.''.$filter_module_groups.'
    '.$filter_groups_label.''.$filter_groups.'   '.$filter_recursion_label.$filter_recursion.''.$filter_module_groups_label.''.$filter_module_groups.'
    '.$filter_agents_label.''.$filter_agents.''.$filter_type_show_label.''.$filter_type_show.''.$filter_modules_label.''.$filter_modules.'
    ".$filter_update.'
    '; + $show_filters .= html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Filter'), + 'srcbutton', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + ], + true + ), + ], + true + ); $show_filters .= '
    '; + ui_toggle( $show_filters, - __('Filters ').ui_print_help_tip(__('Secondary groups and agent subgroups will be taken into account.'), true) + ''.__('Filters ').''.ui_print_help_tip(__('Secondary groups and agent subgroups will be taken into account.'), true), + 'filter_form', + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' ); } @@ -751,11 +834,11 @@ function mainAgentsModules() return; } - echo ''; + echo '
    '; echo ''; - echo "'; + echo "'; if ($hor_offset > 0) { $new_hor_offset = ($hor_offset - $block); @@ -804,7 +887,20 @@ function mainAgentsModules() // Prepare pagination. $url = 'index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&hor_offset='.$hor_offset.'&selection_a_m='.$selection_a_m; - ui_pagination($total_pagination, $url); + $tablePagination = ui_pagination( + $total_pagination, + $url, + 0, + 0, + true, + 'offset', + false + ); + + html_print_action_buttons( + '', + [ 'right_content' => $tablePagination ] + ); foreach ($agents as $agent) { // Get stats for this group. diff --git a/pandora_console/extensions/api_checker.php b/pandora_console/extensions/api_checker.php index 6b4dcf4d72..9b08815349 100755 --- a/pandora_console/extensions/api_checker.php +++ b/pandora_console/extensions/api_checker.php @@ -195,129 +195,183 @@ function extension_api_checker() ); } - ui_print_page_header( - __('API checker'), + // Header. + ui_print_standard_header( + __('Extensions'), 'images/extensions.png', false, '', true, - '' + [], + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Extension manager'), + ], + [ + 'link' => '', + 'label' => __('API checker'), + ], + ] ); $table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox filters filter-table-adv'; + $table->size[0] = '50%'; + $table->size[1] = '50%'; $table->data = []; $row = []; - $row[] = __('IP'); - $row[] = html_print_input_text('ip', $ip, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('IP'), + html_print_input_text('ip', $ip, '', 50, 255, true) + ); + + $row[] = html_print_label_input_block( + __('%s Console URL', get_product_name()), + html_print_input_text('pandora_url', $pandora_url, '', 50, 255, true) + ); $table->data[] = $row; $row = []; - $row[] = __('%s Console URL', get_product_name()); - $row[] = html_print_input_text('pandora_url', $pandora_url, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('API Token').ui_print_help_tip(__('Use API Token instead API Pass, User and Password.'), true), + html_print_input_text('token', $token, '', 50, 255, true) + ); + + $row[] = html_print_label_input_block( + __('API Pass'), + html_print_input_password('apipass', $apipass, '', 50, 255, true) + ); $table->data[] = $row; $row = []; - $row[] = __('API Token').ui_print_help_tip(__('Use API Token instead API Pass, User and Password.'), true); - $row[] = html_print_input_text('token', $token, '', 50, 255, true); - $table->data[] = $row; + $row[] = html_print_label_input_block( + __('User'), + html_print_input_text('user', $user, '', 50, 255, true) + ); - $row = []; - $row[] = __('API Pass'); - $row[] = html_print_input_password('apipass', $apipass, '', 50, 255, true); - $table->data[] = $row; - - $row = []; - $row[] = __('User'); - $row[] = html_print_input_text('user', $user, '', 50, 255, true); - $table->data[] = $row; - - $row = []; - $row[] = __('Password'); - $row[] = html_print_input_password('password', $password, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('Password'), + html_print_input_password('password', $password, '', 50, 255, true) + ); $table->data[] = $row; $table2 = new stdClass(); + $table2->width = '100%'; + $table2->class = 'databox filters filter-table-adv'; + $table2->size[0] = '50%'; + $table2->size[1] = '50%'; $table2->data = []; $row = []; - $row[] = __('Action (get or set)'); - $row[] = html_print_input_text('op', $op, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('Action (get or set)'), + html_print_input_text('op', $op, '', 50, 255, true) + ); + + $row[] = html_print_label_input_block( + __('Operation'), + html_print_input_text('op2', $op2, '', 50, 255, true) + ); $table2->data[] = $row; $row = []; - $row[] = __('Operation'); - $row[] = html_print_input_text('op2', $op2, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('ID'), + html_print_input_text('id', $id, '', 50, 255, true) + ); + + $row[] = html_print_label_input_block( + __('ID 2'), + html_print_input_text('id2', $id2, '', 50, 255, true) + ); $table2->data[] = $row; $row = []; - $row[] = __('ID'); - $row[] = html_print_input_text('id', $id, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('Return Type'), + html_print_input_text('return_type', $return_type, '', 50, 255, true) + ); + + $row[] = html_print_label_input_block( + __('Other'), + html_print_input_text('other', $other, '', 50, 255, true) + ); $table2->data[] = $row; $row = []; - $row[] = __('ID 2'); - $row[] = html_print_input_text('id2', $id2, '', 50, 255, true); - $table2->data[] = $row; - - $row = []; - $row[] = __('Return Type'); - $row[] = html_print_input_text('return_type', $return_type, '', 50, 255, true); - $table2->data[] = $row; - - $row = []; - $row[] = __('Other'); - $row[] = html_print_input_text('other', $other, '', 50, 255, true); - $table2->data[] = $row; - - $row = []; - $row[] = __('Other Mode'); - $row[] = html_print_input_text('other_mode', $other_mode, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('Other Mode'), + html_print_input_text('other_mode', $other_mode, '', 50, 255, true) + ); $table2->data[] = $row; $table3 = new stdClass(); + $table3->width = '100%'; + $table3->class = 'databox filters filter-table-adv'; + $table3->size[0] = '50%'; + $table3->size[1] = '50%'; $table3->data = []; $row = []; - $row[] = __('Raw URL'); - $row[] = html_print_input_text('url', $url, '', 50, 2048, true); + $row[] = html_print_label_input_block( + __('Raw URL'), + html_print_input_text('url', $url, '', 50, 2048, true) + ); $table3->data[] = $row; - echo ""; - echo '
    '; + echo ""; + echo '
    '; echo ''.__('Credentials').''; html_print_table($table); echo '
    '; - echo '
    '; + echo '
    '; echo ''.__('Call parameters').' '.ui_print_help_tip(__('Action: get Operation: module_last_value id: 63'), true).''; html_print_table($table2); echo '
    '; echo "
    "; echo '
    '; - echo '
    '; + echo '
    '; echo ''.__('Custom URL').''; html_print_table($table3); echo '
    '; - echo "
    "; html_print_input_hidden('api_execute', 1); - html_print_submit_button(__('Call'), 'submit', false, 'class="sub next"'); - echo '
    '; + + html_print_action_buttons( + html_print_submit_button( + __('Call'), + 'submit', + false, + [ 'icon' => 'next' ], + true + ) + ); + echo ''; if ($api_execute === true) { - echo '
    '; + echo '
    '; echo ''.__('Result').''; - echo __('URL').'
    '; - html_print_input_password('url', $return_call_api['url'], '', 150, 255, false, true); - echo " "; - html_print_image('images/input_zoom.png'); - echo ''; + echo html_print_label_input_block( + __('URL'), + html_print_input_password('url', $return_call_api['url'], '', 150, 255, true, true, false, 'mrgn_top_10px'), + ['label_class' => 'font-title-font'] + ); echo '
    '; - echo __('Result').'
    '; - html_print_textarea('result', 30, 20, $return_call_api['result'], 'readonly="readonly"'); + echo html_print_label_input_block( + __('Result'), + html_print_textarea('result', 30, 20, $return_call_api['result'], 'readonly="readonly"', true, 'w100p mrgn_top_10px'), + ['label_class' => 'font-title-font'] + ); echo '
    '; } ?> diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index 638d795b31..25965efb0c 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -21,13 +21,23 @@ function extension_db_status() $db_name = get_parameter('db_name', ''); $db_status_execute = (bool) get_parameter('db_status_execute', false); - ui_print_page_header( + ui_print_standard_header( __('DB Schema check'), 'images/extensions.png', false, 'db_status_tab', true, - '' + [], + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Run test'), + ], + ] ); if (!is_user_admin($config['id_user'])) { @@ -46,32 +56,89 @@ function extension_db_status() __('At the moment the checks is for MySQL/MariaDB.') ); - echo "
    "; + echo ""; echo '
    '; echo ''.__('DB settings').''; $table = new stdClass(); $table->data = []; $row = []; - $row[] = __('DB User with privileges'); - $row[] = html_print_input_text('db_user', $db_user, '', 50, 255, true); - $row[] = __('DB Password for this user'); - $row[] = html_print_input_password('db_password', $db_password, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('DB User with privileges'), + html_print_input_text( + 'db_user', + $db_user, + '', + 50, + 255, + true, + false, + false, + '', + 'w100p mrgn_top_10px' + ) + ); + $row[] = html_print_label_input_block( + __('DB Password for this user'), + html_print_input_password( + 'db_password', + $db_password, + '', + 50, + 255, + true, + false, + false, + 'w100p mrgn_top_10px' + ) + ); $table->data[] = $row; $row = []; - $row[] = __('DB Hostname'); - $row[] = html_print_input_text('db_host', $db_host, '', 50, 255, true); - $row[] = __('DB Name (temporal for testing)'); - $row[] = html_print_input_text('db_name', $db_name, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('DB Hostname'), + html_print_input_text( + 'db_host', + $db_host, + '', + 50, + 255, + true, + false, + false, + '', + 'w100p mrgn_top_10px' + ) + ); + $row[] = html_print_label_input_block( + __('DB Name (temporal for testing)'), + html_print_input_text( + 'db_name', + $db_name, + '', + 50, + 255, + true, + false, + false, + '', + 'w100p mrgn_top_10px' + ) + ); $table->data[] = $row; html_print_table($table); echo '
    '; - echo "
    "; - html_print_input_hidden('db_status_execute', 1); - html_print_submit_button(__('Execute Test'), 'submit', false, 'class="sub next"'); - echo '
    '; + html_print_action_buttons( + html_print_submit_button( + __('Execute Test'), + 'submit', + false, + [ 'icon' => 'cog' ], + true + ) + ); + html_print_input_hidden('db_status_execute', 1); echo ''; if ($db_status_execute) { diff --git a/pandora_console/extensions/dbmanager.php b/pandora_console/extensions/dbmanager.php index db92dda0a9..1ec40b79f1 100644 --- a/pandora_console/extensions/dbmanager.php +++ b/pandora_console/extensions/dbmanager.php @@ -76,10 +76,6 @@ function dbmgr_extension_main() global $config; - if (is_metaconsole() === true) { - open_meta_frame(); - } - if (!is_user_admin($config['id_user'])) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, @@ -92,7 +88,21 @@ function dbmgr_extension_main() $sql = (string) get_parameter('sql'); $node_id = (int) get_parameter('node_id', -1); - ui_print_page_header(__('Database interface'), 'images/gm_db.png', false, false, true); + // Header. + ui_print_standard_header( + __('Database interface'), + 'images/gm_db.png', + false, + '', + true, + [], + [ + [ + 'link' => '', + 'label' => __('Extensions'), + ], + ] + ); if (is_metaconsole() === true) { $img = '../../images/warning_modern.png'; @@ -122,47 +132,37 @@ function dbmgr_extension_main() echo $warning_message; } + ui_print_warning_message( + __( + "This is an advanced extension to interface with %s database directly from WEB console + using native SQL sentences. Please note that you can damage your %s installation + if you don't know exactly what are you are doing, + this means that you can severily damage your setup using this extension. + This extension is intended to be used only by experienced users + with a depth knowledge of %s internals.", + get_product_name(), + get_product_name(), + get_product_name() + ) + ); + echo "
    "; $table = new stdClass(); $table->id = 'db_interface'; - $table->class = 'databox'; + $table->class = 'databox no_border filter-table-adv'; $table->width = '100%'; $table->data = []; - $table->head = []; $table->colspan = []; - $table->rowstyle = []; + $table->style[0] = 'width: 30%;'; + $table->style[1] = 'width: 70%;'; - $table->colspan[0][0] = 2; $table->colspan[1][0] = 2; - $table->rowspan[2][0] = 3; - $table->rowclass[0] = 'notify'; - $table->rowclass[3] = 'pdd_5px'; - $table->rowclass[3] = 'flex-content-right'; - $table->rowclass[4] = 'flex-content-right'; - - $data[0][0] = __( - "This is an advanced extension to interface with %s database directly from WEB console - using native SQL sentences. Please note that you can damage your %s installation - if you don't know exactly what are you are doing, - this means that you can severily damage your setup using this extension. - This extension is intended to be used only by experienced users - with a depth knowledge of %s internals.", - get_product_name(), - get_product_name(), - get_product_name() - ); - - $data[1][0] = "Some samples of usage:
    SHOW STATUS;
    DESCRIBE tagente
    SELECT * FROM tserver
    UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'
    "; - - $data[2][0] = html_print_textarea( - 'sql', - 5, - 50, - html_entity_decode($sql, ENT_QUOTES), - '', - true + $data[0][0] = "Some samples of usage:
    SHOW STATUS;
    DESCRIBE tagente
    SELECT * FROM tserver
    UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'
    "; + $data[0][0] = html_print_label_input_block( + __('Some samples of usage:'), + "
    SHOW STATUS;
    DESCRIBE tagente
    SELECT * FROM tserver
    UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'
    " ); if (is_metaconsole() === true) { @@ -181,32 +181,57 @@ function dbmgr_extension_main() $servers = []; } - $data[3][2] = html_print_input( - [ - 'name' => 'node_id', - 'type' => 'select', - 'fields' => $servers, - 'selected' => $node_id, - 'nothing' => __('This metaconsole'), - 'nothing_value' => -1, - 'return' => true, - 'label' => _('Select query target'), - ] + $data[0][1] = html_print_label_input_block( + __('Select query target'), + html_print_select( + $servers, + 'node_id', + $node_id, + '', + __('This metaconsole'), + -1, + true, + false, + false, + 'w40p', + false, + 'width: 40%;' + ) ); } - $data[4][2] = '
    '; - $data[4][2] .= html_print_submit_button( + $data[1][0] = html_print_textarea( + 'sql', + 3, + 50, + html_entity_decode($sql, ENT_QUOTES), + 'placeholder="'.__('Type your query here...').'"', + true, + 'w100p' + ); + + $execute_button = html_print_submit_button( __('Execute SQL'), '', false, - 'class="sub next"', + [ 'icon' => 'cog' ], true ); - $data[4][2] .= '
    '; $table->data = $data; - html_print_table($table); + // html_print_table($table); + html_print_action_buttons($execute_button); + ui_toggle( + html_print_table($table, true), + ''.__('SQL query').'', + __('SQL query'), + 'query', + false, + false, + '', + 'white-box-content no_border', + 'box-flat white_table_graph fixed_filter_bar' + ); echo ''; // Processing SQL Code. @@ -214,10 +239,6 @@ function dbmgr_extension_main() return; } - echo '
    '; - echo '
    '; - echo '
    '; - try { if (\is_metaconsole() === true && $node_id !== -1) { $node = new Node($node_id); @@ -227,7 +248,7 @@ function dbmgr_extension_main() 'dbport' => $node->dbport(), 'dbname' => $node->dbname(), 'dbuser' => $node->dbuser(), - 'dbpass' => $node->dbpass(), + 'dbpass' => io_output_password($node->dbpass()), ] ); $error = ''; @@ -282,22 +303,17 @@ function dbmgr_extension_main() html_print_table($table); echo ''; - if (is_metaconsole()) { - close_meta_frame(); - } - } if (is_metaconsole() === true) { // This adds a option in the operation menu. extensions_add_meta_menu_option( - 'DB interface', + __('DB interface'), 'PM', 'gextensions', 'database.png', - 'v1r1', - 'gdbman' + 'v1r1' ); extensions_add_meta_function('dbmgr_extension_main'); diff --git a/pandora_console/extensions/dbmanager/dbmanager.css b/pandora_console/extensions/dbmanager/dbmanager.css index 1e44dce3a8..1882b71e92 100644 --- a/pandora_console/extensions/dbmanager/dbmanager.css +++ b/pandora_console/extensions/dbmanager/dbmanager.css @@ -24,7 +24,6 @@ table.dbmanager th { } textarea { - min-height: 50px; - height: 50px; - width: 95%; + width: 100% !important; + max-width: 100% !important; } diff --git a/pandora_console/extensions/extension_uploader.php b/pandora_console/extensions/extension_uploader.php index f5447703e8..d989a3661b 100644 --- a/pandora_console/extensions/extension_uploader.php +++ b/pandora_console/extensions/extension_uploader.php @@ -25,13 +25,28 @@ function extension_uploader_extensions() return; } - ui_print_page_header( - __('Uploader extension'), + // Header. + ui_print_standard_header( + __('Extensions'), 'images/extensions.png', false, '', true, - '' + [], + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Extension manager'), + ], + [ + 'link' => '', + 'label' => __('Uploader extension'), + ], + ] ); $upload = (bool) get_parameter('upload', 0); @@ -77,20 +92,52 @@ function extension_uploader_extensions() $table = new stdClass(); $table->width = '100%'; - $table->class = 'databox filters'; + $table->class = 'databox filters filter-table-adv'; + $table->size[0] = '20%'; + $table->size[1] = '20%'; + $table->size[2] = '60%'; $table->data = []; - $table->data[0][0] = __('Upload extension'); - $table->data[0][1] = html_print_input_file('extension', true).ui_print_help_tip(__('Upload the extension as a zip file.'), true); + + $table->data[0][0] = html_print_label_input_block( + __('Upload extension').ui_print_help_tip(__('Upload the extension as a zip file.'), true), + html_print_input_file( + 'extension', + true, + [ + 'required' => true, + 'accept' => '.zip', + ] + ) + ); + if (enterprise_installed()) { - $table->data[0][2] = __('Upload enterprise extension').' '.html_print_checkbox('upload_enterprise', 1, false, true); + $table->data[0][1] = html_print_label_input_block( + __('Upload enterprise extension'), + html_print_checkbox( + 'upload_enterprise', + 1, + false, + true + ) + ); + } else { + $table->data[0][1] = ''; } + $table->data[0][2] = ''; + echo "
    "; html_print_table($table); - echo "
    "; html_print_input_hidden('upload', 1); - html_print_submit_button(__('Upload'), 'submit', false, 'class="sub add"'); - echo '
    '; + html_print_action_buttons( + html_print_submit_button( + __('Upload'), + 'submit', + false, + ['icon' => 'wand'], + true + ) + ); echo ''; } diff --git a/pandora_console/extensions/files_repo.php b/pandora_console/extensions/files_repo.php index c319954748..0313af90b2 100644 --- a/pandora_console/extensions/files_repo.php +++ b/pandora_console/extensions/files_repo.php @@ -126,8 +126,30 @@ function pandora_files_repo_godmode() 'godmode' => $godmode, 'operation' => $operation, ]; + // Header. - ui_print_page_header(__('Files repository manager'), 'images/extensions.png', false, '', true, $onheader); + ui_print_standard_header( + __('Extensions'), + 'images/extensions.png', + false, + '', + true, + $onheader, + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Extension manager'), + ], + [ + 'link' => '', + 'label' => __('Files repository manager'), + ], + ] + ); $full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/'; include_once $full_extensions_dir.'files_repo/functions_files_repo.php'; diff --git a/pandora_console/extensions/files_repo/files_repo_form.php b/pandora_console/extensions/files_repo/files_repo_form.php index a78606c271..d96357e87b 100644 --- a/pandora_console/extensions/files_repo/files_repo_form.php +++ b/pandora_console/extensions/files_repo/files_repo_form.php @@ -32,17 +32,15 @@ if (isset($file_id) && $file_id > 0) { $table = new stdClass(); $table->width = '100%'; -$table->class = 'databox filters'; -$table->style = []; -$table->style[0] = 'font-weight: bold;'; -$table->style[2] = 'text-align: center;'; -$table->colspan = []; +$table->class = 'databox filters filter-table-adv'; +$table->size[0] = '50%'; +$table->size[1] = '50%'; $table->data = []; -// GROUPS +// GROUPS. $groups = groups_get_all(); -// Add the All group to the beginning to be always the first -// Use this instead array_unshift to keep the array keys +// Add the All group to the beginning to be always the first. +// Use this instead array_unshift to keep the array keys. $groups = ([0 => __('All')] + $groups); $groups_selected = []; foreach ($groups as $id => $name) { @@ -52,66 +50,110 @@ foreach ($groups as $id => $name) { } $row = []; -$row[0] = __('Groups'); -$row[1] = '
    '.html_print_select_groups( - // Id_user. - false, - // Privilege. - 'AR', - // ReturnAllGroup. - true, - // Name. - 'groups[]', - // Selected. - $groups_selected, - // Script. - '', - // Nothing. - '', - // Nothing_value. - 0, - // Return. - true, - // Multiple. - true -).'
    '; -$table->data[] = $row; -$table->colspan[][1] = 3; +$row[0] = html_print_label_input_block( + __('Groups'), + html_print_select_groups( + // Id_user. + false, + // Privilege. + 'AR', + // ReturnAllGroup. + true, + // Name. + 'groups[]', + // Selected. + $groups_selected, + // Script. + '', + // Nothing. + '', + // Nothing_value. + 0, + // Return. + true, + // Multiple. + true + ) +); -// DESCRIPTION -$row = []; -$row[0] = __('Description'); -$row[0] .= ui_print_help_tip(__('Only 200 characters are permitted'), true); -$row[1] = html_print_textarea('description', 3, 20, $file['description'], 'class="file_repo_description"', true); +// DESCRIPTION. +$row[1] = html_print_label_input_block( + __('Description').ui_print_help_tip(__('Only 200 characters are permitted'), true), + html_print_textarea( + 'description', + 4, + 20, + $file['description'], + 'class="file_repo_description" style="min-height: 60px; max-height: 60px;"', + true + ) +); $table->data[] = $row; -$table->colspan[][1] = 3; -// FILE and SUBMIT BUTTON +// FILE and SUBMIT BUTTON. $row = []; -// Public checkbox +// Public checkbox. $checkbox = html_print_checkbox('public', 1, (bool) !empty($file['hash']), true); $style = 'class="inline padding-2-10"'; $row[0] = __('File'); if ($file_id > 0) { - $row[1] = $file['name']; - $row[2] = "
    ".__('Public link')." $checkbox
    "; - $row[3] = html_print_submit_button(__('Update'), 'submit', false, 'class="sub upd"', true); - $row[3] .= html_print_input_hidden('update_file', 1, true); - $row[3] .= html_print_input_hidden('file_id', $file_id, true); + $submit_button = html_print_submit_button( + __('Update'), + 'submit', + false, + ['icon' => 'wand'], + true + ); + + $row[0] = html_print_label_input_block( + __('File'), + $file['name'] + ); + + $row[1] = html_print_label_input_block( + __('Public link'), + $checkbox.html_print_input_hidden( + 'file_id', + $file_id, + true + ) + ); } else { - $row[1] = html_print_input_file('upfile', true); - $row[2] = "
    ".__('Public link')." $checkbox
    "; - $row[3] = html_print_submit_button(__('Add'), 'submit', false, 'class="sub add"', true); - $row[3] .= html_print_input_hidden('add_file', 1, true); + $submit_button = html_print_submit_button( + __('Add'), + 'submit', + false, + ['icon' => 'wand'], + true + ); + + $row[0] = html_print_label_input_block( + __('File'), + html_print_input_file( + 'upfile', + true + ) + ); + + $row[1] = html_print_label_input_block( + __('Public link'), + $checkbox.html_print_input_hidden( + 'add_file', + 1, + true + ) + ); } + + $table->data[] = $row; -$table->colspan[][1] = 1; $url = ui_get_full_url('index.php?sec=godmode/extensions&sec2=extensions/files_repo'); echo "
    "; html_print_table($table); +html_print_action_buttons($submit_button); echo ''; ?> diff --git a/pandora_console/extensions/files_repo/files_repo_list.php b/pandora_console/extensions/files_repo/files_repo_list.php index 783e155dc4..6c75218d18 100644 --- a/pandora_console/extensions/files_repo/files_repo_list.php +++ b/pandora_console/extensions/files_repo/files_repo_list.php @@ -98,7 +98,7 @@ if (!empty($files)) { // Last modification // Public URL $data[4] = ''; - $table->cellclass[][4] = 'action_buttons'; + $table->cellclass[][4] = 'table_action_buttons'; if (!empty($file['hash'])) { $public_url = ui_get_full_url( EXTENSIONS_DIR.'/files_repo/files_repo_get_file.php?file='.$file['hash'] diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 54306ac5d7..3ccf1af688 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -1,16 +1,32 @@ '', + 'label' => __('Resources'), + ], + [ + 'link' => '', + 'label' => __('Insert Data'), + ], + ] + ); if (! check_acl($config['id_user'], 0, 'AW') && ! is_user_admin($config['id_user'])) { db_pandora_audit( @@ -84,6 +117,13 @@ function mainInsertData() $csv = false; } + ui_print_warning_message( + sprintf( + __('Please check that the directory "%s" is writeable by the apache user.

    The CSV file format is date;value<newline>date;value<newline>... The date in CSV is in format Y/m/d H:i:s.'), + $config['remote_config'] + ) + ); + if ($save) { if (!check_acl($config['id_user'], agents_get_agent_group($agent_id), 'AW')) { ui_print_error_message(__('You haven\'t privileges for insert data in the agent.')); @@ -140,27 +180,25 @@ function mainInsertData() } } - echo '
    '; - echo sprintf( - __('Please check that the directory "%s" is writeable by the apache user.

    The CSV file format is date;value<newline>date;value<newline>... The date in CSV is in format Y/m/d H:i:s.'), - $config['remote_config'] - ); - echo '
    '; + $modules = []; + if ($agent_id > 0) { + $modules = agents_get_modules($agent_id, false, ['delete_pending' => 0]); + } $table = new stdClass(); - $table->width = '100%'; - $table->class = 'databox filters'; + $table->class = 'databox filter-table-adv'; $table->style = []; - $table->style[0] = 'font-weight: bolder;'; - + $table->cellstyle[0][0] = 'width: 0'; + $table->cellstyle[0][1] = 'width: 0'; $table->data = []; - - $table->data[0][0] = __('Agent'); + $table->data[0][0] = ''; + $table->data[0][1] = ''; + $table->data[0][2] = ''; $params = []; $params['return'] = true; $params['show_helptip'] = true; $params['input_name'] = 'agent_name'; - $params['value'] = $agent_name; + $params['value'] = ($save === true) ? '' : $agent_name; $params['javascript_is_function_select'] = true; $params['javascript_name_function_select'] = 'custom_select_function'; $params['javascript_code_function_select'] = ''; @@ -170,18 +208,12 @@ function mainInsertData() $params['hidden_input_idagent_name'] = 'agent_id'; $params['hidden_input_idagent_value'] = $agent_id; - $table->data[0][1] = ui_print_agent_autocomplete_input($params); - - $table->data[1][0] = __('Module'); - $modules = []; - if ($agent_id) { - $modules = agents_get_modules($agent_id, false, ['delete_pending' => 0]); - } + $table->data[1][0] = html_print_div(['class' => 'flex flex-items-center', 'content' => ui_print_agent_autocomplete_input($params)], true); $table->data[1][1] = html_print_select( $modules, 'id_agent_module', - $id_agent_module, + ($save === true) ? '' : $id_agent_module, true, __('Select'), 0, @@ -191,22 +223,45 @@ function mainInsertData() '', empty($agent_id) ); - $table->data[2][0] = __('Data'); - $table->data[2][1] = html_print_input_text('data', $data, __('Data'), 40, 60, true); - $table->data[3][0] = __('Date'); - $table->data[3][1] = html_print_input_text('date', $date, '', 11, 11, true).' '; - $table->data[3][1] .= html_print_input_text('time', $time, '', 7, 7, true); - $table->data[4][0] = __('CSV'); - $table->data[4][1] = html_print_input_file('csv', true); + $table->data[1][2] = html_print_input_text('data', ($save === true) ? date(DATE_FORMAT) : $data, __('Data'), 10, 60, true); + $table->data[1][2] .= ' '; + $table->data[1][2] .= html_print_input_text('time', ($save === true) ? date(TIME_FORMAT) : $time, '', 10, 7, true); + + $table->data[2][0] = ''; + $table->data[2][1] = ''; + $table->data[3][0] = html_print_input_text( + 'data', + $data, + __('Data'), + 40, + 60, + true + ); + $table->data[3][1] = html_print_div( + [ + 'class' => '', + 'content' => html_print_input_file('csv', true), + ], + true + ); echo "
    "; html_print_table($table); - echo "
    "; html_print_input_hidden('save', 1); - html_print_submit_button(__('Save'), 'submit', ($id_agent === ''), 'class="sub next"'); - echo '
    '; + + html_print_action_buttons( + html_print_submit_button( + __('Save'), + 'submit', + // (empty($id_agent) === true), + false, + [ 'icon' => 'next' ], + true + ), + ['type' => 'form_action'] + ); echo ''; @@ -257,8 +312,8 @@ function mainInsertData() $('#id_agent_module').enable(); $('#id_agent_module').fadeIn ('normal'); - $('#submit-submit').enable(); - $('#submit-submit').fadeIn ('normal'); + $('button [name="submit"]').removeClass('disabled_action_button'); + $('button [name="submit"]').fadeIn ('normal'); } }); } diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index a04e6a08dc..e554b34b51 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -266,24 +266,68 @@ function mainModuleGroups() ] ); - echo "
    ".__('Agents').' / '.__('Modules').'".__('Agents').' / '.__('Modules').'
    - "; - echo ""; + $output = ""; - echo '
    '; - echo __('Search by agent group').' '; - html_print_input_text('agent_group_search', $agent_group_search); + $output .= ""; + $output .= ''; + $output .= '
    '; + $output .= html_print_label_input_block( + __('Search by agent group'), + html_print_input_text( + 'agent_group_search', + $agent_group_search, + '', + 50, + 255, + true + ) + ); - echo ''; - echo __('Search by module group').' '; - html_print_input_text('module_group_search', $module_group_search); + $output .= ''; + $output .= html_print_label_input_block( + __('Search by module group'), + html_print_input_text( + 'module_group_search', + $module_group_search, + '', + 50, + 255, + true + ) + ); + $output .= '
    '; - echo '
    '; - echo ""; - echo ''; - echo ''; - echo '
    '; + $output .= html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Filter'), + 'srcbutton', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + ], + true + ), + ], + true + ); + + $output .= ''; + + ui_toggle( + $output, + ''.__('Filters').'', + 'filter_form', + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' + ); $cell_style = ' min-width: 60px; @@ -299,26 +343,35 @@ function mainModuleGroups() if ($info && $array_module_group) { $table = new StdClass(); - $table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; min-width: 230px;'; + $table->class = 'info_table'; + $table->style[0] = 'font-weight: bolder; min-width: 230px;'; $table->width = '100%'; - if ($config['style'] === 'pandora_black' && !is_metaconsole()) { - $background_color = '#333'; - } else { - $background_color = '#fff'; - } - $head[0] = __('Groups'); $headstyle[0] = 'width: 20%; font-weight: bolder;'; foreach ($array_module_group as $key => $value) { - $headstyle[] = 'min-width: 60px;max-width: 5%;text-align:center; color: #ffffff; background-color: #373737; font-weight: bolder;'; - $head[] = ui_print_truncate_text($value, GENERIC_SIZE_TEXT, true, true, true, '…', 'color:#FFF'); + $headstyle[] = 'min-width: 60px;max-width: 5%;text-align:center; font-weight: bolder;'; + $head[] = ui_print_truncate_text( + $value, + GENERIC_SIZE_TEXT, + true, + true, + true, + '…' + ); } $i = 0; foreach ($array_for_defect as $key => $value) { $deep = groups_get_group_deep($key); - $data[$i][0] = $deep.ui_print_truncate_text($value['data']['name'], GENERIC_SIZE_TEXT, true, true, true, '…', 'color:#FFF'); + $data[$i][0] = $deep.ui_print_truncate_text( + $value['data']['name'], + GENERIC_SIZE_TEXT, + true, + true, + true, + '…' + ); $j = 1; if (isset($array_data[$key])) { foreach ($value['gm'] as $k => $v) { @@ -378,25 +431,37 @@ function mainModuleGroups() $table->headstyle = $headstyle; $table->data = $data; - ui_pagination($counter); - echo "
    "; html_print_table($table); echo '
    '; - ui_pagination($counter); + $tablePagination = ui_pagination( + $counter, + false, + 0, + 0, + true, + 'offset', + false + ); - echo "
    "; - echo ''; - echo "'; - echo "'; - echo "'; - echo "'; - echo "'; - echo "'; - echo "'; - echo '
    ".__('Legend').'
    ".__('Orange cell when the module group and agent have at least one alarm fired.').'
    ".__('Red cell when the module group and agent have at least one module in critical status and the others in any status').'
    ".__('Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status').'
    ".__('Grey cell when the module group and agent have at least one in unknown status and the others in green status').'
    ".__('Green cell when the module group and agent have all modules in OK status').'
    ".__('Blue cell when the module group and agent have all modules in not init status.').'
    '; - echo '
    '; + html_print_action_buttons( + '', + [ 'right_content' => $tablePagination ] + ); + + $show_legend = '
    '; + $show_legend .= ''; + $show_legend .= "'; + $show_legend .= "'; + $show_legend .= "'; + $show_legend .= "'; + $show_legend .= "'; + $show_legend .= "'; + $show_legend .= '
    ".__('Orange cell when the module group and agent have at least one alarm fired.').'
    ".__('Red cell when the module group and agent have at least one module in critical status and the others in any status').'
    ".__('Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status').'
    ".__('Grey cell when the module group and agent have at least one in unknown status and the others in green status').'
    ".__('Green cell when the module group and agent have all modules in OK status').'
    ".__('Blue cell when the module group and agent have all modules in not init status.').'
    '; + $show_legend .= '
    '; + + ui_toggle($show_legend, __('Legend')); } else { ui_print_info_message(['no_close' => true, 'message' => __('This table shows in columns the modules group and in rows agents group. The cell shows all modules') ]); ui_print_info_message(['no_close' => true, 'message' => __('There are no defined groups or module groups') ]); diff --git a/pandora_console/extensions/pandora_logs.php b/pandora_console/extensions/pandora_logs.php index 21b817b978..28dcaa0814 100644 --- a/pandora_console/extensions/pandora_logs.php +++ b/pandora_console/extensions/pandora_logs.php @@ -11,11 +11,12 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -function view_logfile($file_name) +function view_logfile($file_name, $toggle=false) { global $config; $memory_limit = ini_get('memory_limit'); + $code = ''; if (strstr($memory_limit, 'M') !== false) { $memory_limit = str_replace('M', '', $memory_limit); @@ -31,21 +32,37 @@ function view_logfile($file_name) $file_size = filesize($file_name); if ($memory_limit < $file_size) { - echo "

    $file_name (".__('File is too large than PHP memory allocated in the system.').')

    '; - echo '

    '.__('The preview file is imposible.').'

    '; + $code .= '

    '.$file_name.' ('.__('File is too large than PHP memory allocated in the system.').')

    '; + $code .= '

    '.__('The preview file is imposible.').'

    '; } else if ($file_size > ($config['max_log_size'] * 1000)) { $data = file_get_contents($file_name, false, null, ($file_size - ($config['max_log_size'] * 1000))); - echo "

    $file_name (".format_numeric(filesize($file_name) / 1024).' KB) '.ui_print_help_tip(__('The folder /var/log/pandora must have pandora:apache and its content too.'), true).'

    '; - echo "

    '; + $code .= "

    $file_name (".format_numeric(filesize($file_name) / 1024).' KB) '.ui_print_help_tip(__('The folder /var/log/pandora must have pandora:apache and its content too.'), true).'

    '; + $code .= "

    '; } else { $data = file_get_contents($file_name); - echo "

    $file_name (".format_numeric(filesize($file_name) / 1024).' KB) '.ui_print_help_tip(__('The folder /var/log/pandora must have pandora:apache and its content too.'), true).'

    '; - echo "

    '; + $code .= "

    $file_name (".format_numeric(filesize($file_name) / 1024).' KB) '.ui_print_help_tip(__('The folder /var/log/pandora must have pandora:apache and its content too.'), true).'

    '; + $code .= "

    '; + } + + if ($toggle === true) { + ui_toggle( + $code, + ''.$file_name.'', + $file_name, + 'a', + false, + false, + '', + 'white-box-content no_border', + 'filter-datatable-main box-flat white_table_graph' + ); + } else { + echo $code; } } } @@ -64,21 +81,45 @@ function pandoralogs_extension_main() return; } - ui_print_page_header(__('System logfile viewer'), 'images/extensions.png', false, '', true, ''); + // Header. + ui_print_standard_header( + __('Extensions'), + 'images/extensions.png', + false, + '', + true, + [], + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Extension manager'), + ], + [ + 'link' => '', + 'label' => __('System logfile viewer'), + ], + ] + ); - echo '

    '.__('Use this tool to view your %s logfiles directly on the console', get_product_name()).'

    '; - - echo '

    '.__('You can choose the amount of information shown in general setup (Log size limit in system logs viewer extension), '.($config['max_log_size'] * 1000).'B at the moment').'

    '; + ui_print_info_message( + __('Use this tool to view your %s logfiles directly on the console', get_product_name()).'
    + '.__('You can choose the amount of information shown in general setup (Log size limit in system logs viewer extension), '.($config['max_log_size'] * 1000).'B at the moment') + ); $logs_directory = (!empty($config['server_log_dir'])) ? io_safe_output($config['server_log_dir']) : '/var/log/pandora'; // Do not attempt to show console log if disabled. if ($config['console_log_enabled']) { - view_logfile($config['homedir'].'/log/console.log'); + view_logfile($config['homedir'].'/log/console.log', true); } - view_logfile($logs_directory.'/pandora_server.log'); - view_logfile($logs_directory.'/pandora_server.error'); + view_logfile($logs_directory.'/pandora_server.log', true); + view_logfile($logs_directory.'/pandora_server.error', true); + } diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index 7cbb5607e1..9182380a95 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -151,7 +151,7 @@ function quickShell() 'name' => 'submit', 'label' => __('Retry'), 'type' => 'submit', - 'attributes' => 'class="sub next"', + 'attributes' => ['icon' => 'next'], 'return' => true, ], ], @@ -202,7 +202,7 @@ function quickShell() 'arguments' => [ 'type' => 'submit', 'label' => __('Connect'), - 'attributes' => 'class="sub next"', + 'attributes' => ['icon' => 'cog'], ], ], ], @@ -544,7 +544,7 @@ if (empty($agent_id) === false // TabName. __('QuickShell'), // TabIcon. - 'images/ehorus/terminal.png', + 'images/quick-shell@svg.svg', // TabFunction. 'quickShell', // Version. diff --git a/pandora_console/extensions/realtime_graphs.php b/pandora_console/extensions/realtime_graphs.php index 8f978f0fac..133af5b3f8 100644 --- a/pandora_console/extensions/realtime_graphs.php +++ b/pandora_console/extensions/realtime_graphs.php @@ -74,61 +74,11 @@ function pandora_realtime_graphs() ); } - $chart[time()]['graph'] = '0'; - $interactive_graph = true; - $color = []; - $legend = ''; - $long_index = []; - $no_data_image = ''; - - $canvas = '
    '; - $canvas .= '
    '; - - $width = 800; - $height = 300; - - $data_array['realtime']['data'][0][0] = (time() - 10); - $data_array['realtime']['data'][0][1] = 0; - $data_array['realtime']['data'][1][0] = time(); - $data_array['realtime']['data'][1][1] = 0; - $data_array['realtime']['color'] = 'green'; - - $params = [ - 'agent_module_id' => false, - 'period' => 300, - 'width' => $width, - 'height' => $height, - 'unit' => $unit, - 'only_image' => $only_image, - 'homeurl' => $homeurl, - 'type_graph' => 'area', - 'font' => $config['fontpath'], - 'font-size' => $config['font_size'], - 'array_data_create' => $data_array, - 'show_legend' => false, - 'show_menu' => false, - ]; - - $canvas .= grafico_modulo_sparse($params); - - $canvas .= '
    '; - echo $canvas; - $table = new stdClass(); $table->width = '100%'; $table->id = 'table-form'; - $table->class = 'databox filters'; + $table->class = 'filter-table-adv'; $table->style = []; - $table->cellpadding = '0'; - $table->cellspacing = '0'; - $table->style['graph'] = 'font-weight: bold;'; - $table->style['refresh'] = 'font-weight: bold;'; - $table->style['incremental'] = 'font-weight: bold;'; - $table->style['reset'] = 'font-weight: bold;'; - $table->style['snmp_address'] = 'font-weight: bold;'; - $table->style['snmp_community'] = 'font-weight: bold;'; - $table->style['snmp_oid'] = 'font-weight: bold;'; - $table->style['snmp_oid'] = 'font-weight: bold;'; $table->data = []; $graph_fields['cpu_load'] = __('%s Server CPU', get_product_name()); @@ -158,15 +108,22 @@ function pandora_realtime_graphs() $refresh = get_parameter('refresh', '1000'); if ($graph != 'snmp_module') { - $data['graph'] = __('Graph').'  '; - $data['graph'] .= html_print_select( - $graph_fields, - 'graph', - $graph, - '', - '', - 0, - true + $data['graph'] = html_print_label_input_block( + __('Graph'), + html_print_select( + $graph_fields, + 'graph', + $graph, + '', + '', + 0, + true, + false, + true, + '', + false, + 'width: 100%' + ) ); } @@ -179,18 +136,35 @@ function pandora_realtime_graphs() $agent_alias = io_safe_output(get_parameter('agent_alias', '')); $module_name = io_safe_output(get_parameter('module_name', '')); $module_incremental = get_parameter('incremental', 0); - $data['module_info'] = $agent_alias.': '.$module_name.''; - - // Append all the hidden in this cell. - $data['module_info'] .= html_print_input_hidden( - 'incremental', - $module_incremental, - true + $data['module_info'] = html_print_label_input_block( + $agent_alias.': '.$module_name, + html_print_input_hidden( + 'incremental', + $module_incremental, + true + ).html_print_select( + ['snmp_module' => '-'], + 'graph', + 'snmp_module', + '', + '', + 0, + true, + false, + true, + '', + false, + 'width: 100%; display: none;' + ) ); - $data['module_info'] .= html_print_select( - ['snmp_module' => '-'], - 'graph', - 'snmp_module', + } + + $data['refresh'] = html_print_label_input_block( + __('Refresh interval'), + html_print_select( + $refresh_fields, + 'refresh', + $refresh, '', '', 0, @@ -199,33 +173,17 @@ function pandora_realtime_graphs() true, '', false, - 'display: none;' + 'width: 100%' + ) + ); + + if ($graph != 'snmp_module') { + $data['incremental'] = html_print_label_input_block( + __('Incremental'), + html_print_checkbox_switch('incremental', 1, 0, true) ); } - $data['refresh'] = __('Refresh interval').'  '; - $data['refresh'] .= html_print_select( - $refresh_fields, - 'refresh', - $refresh, - '', - '', - 0, - true - ); - if ($graph != 'snmp_module') { - $data['incremental'] = __('Incremental').'  '; - $data['incremental'] .= html_print_checkbox('incremental', 1, 0, true); - } - - $data['reset'] = html_print_button( - __('Clear graph'), - 'reset', - false, - 'javascript:realtimeGraphs.clearGraph();', - 'class="sub delete mgn_tp_0" ', - true - ); $table->data[] = $data; if ($graph == 'snmp_interface' || $graph == 'snmp_module') { @@ -236,10 +194,79 @@ function pandora_realtime_graphs() html_print_input_hidden('rel_path', get_parameter('rel_path', '')); // Print the form. - echo '
    '; - html_print_table($table); - echo '
    '; + $searchForm = '
    '; + $searchForm .= html_print_table($table, true); + $searchForm .= html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Clear graph'), + 'srcbutton', + false, + [ + 'icon' => 'delete', + 'mode' => 'mini', + 'onClick' => 'javascript:realtimeGraphs.clearGraph();', + ], + true + ), + ], + true + ); + $searchForm .= '
    '; + ui_toggle( + $searchForm, + ''.__('Filters').'', + 'filter_form', + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' + ); + + $chart[time()]['graph'] = '0'; + $canvas = '
    '; + $canvas .= '
    '; + + $width = 800; + $height = 300; + + $data_array['realtime']['data'][0][0] = (time() - 10); + $data_array['realtime']['data'][0][1] = 0; + $data_array['realtime']['data'][1][0] = time(); + $data_array['realtime']['data'][1][1] = 0; + $data_array['realtime']['color'] = 'green'; + + $params = [ + 'agent_module_id' => false, + 'period' => 300, + 'width' => $width, + 'height' => $height, + 'only_image' => false, + 'type_graph' => 'area', + 'font' => $config['fontpath'], + 'font-size' => $config['font_size'], + 'array_data_create' => $data_array, + 'show_legend' => false, + 'show_menu' => false, + 'backgroundColor' => 'transparent', + ]; + + $canvas .= grafico_modulo_sparse($params); + + $canvas .= '
    '; + + html_print_div( + [ + 'class' => 'white_box', + 'content' => $canvas, + ] + ); + + // echo $canvas; // Define a custom action to save // the OID selected in the SNMP browser to the form. html_print_input_hidden( diff --git a/pandora_console/extensions/realtime_graphs/realtime_graphs.css b/pandora_console/extensions/realtime_graphs/realtime_graphs.css index a5dfa19975..a839ad6ab0 100644 --- a/pandora_console/extensions/realtime_graphs/realtime_graphs.css +++ b/pandora_console/extensions/realtime_graphs/realtime_graphs.css @@ -12,6 +12,5 @@ #graph_container { width: 800px; margin: 20px auto; - background-color: white; border-radius: 3px; } diff --git a/pandora_console/extensions/resource_exportation.php b/pandora_console/extensions/resource_exportation.php index b6e594c744..905b389eee 100755 --- a/pandora_console/extensions/resource_exportation.php +++ b/pandora_console/extensions/resource_exportation.php @@ -1,16 +1,32 @@ \n"; break; @@ -224,18 +209,6 @@ function output_xml_report($id) echo '\n"; break; - case 'event_report_module': - break; - - case 'alert_report_module': - break; - - case 'alert_report_agent': - break; - - case 'alert_report_group': - break; - case 'url': echo ''; break; @@ -245,6 +218,29 @@ function output_xml_report($id) echo ''; echo ''; break; + + case 1: + case 'simple_graph': + case 'simple_baseline_graph': + case 6: + case 'monitor_report': + case 7: + case 'avg_value': + case 8: + case 'max_value': + case 9: + case 'min_value': + case 10: + case 'sumatory': + case 'agent_detailed_event': + case 'event_report_agent': + case 'event_report_module': + case 'alert_report_module': + case 'alert_report_agent': + case 'alert_report_group': + default: + // Do nothing. + break; } echo "\n"; @@ -417,25 +413,59 @@ function resource_exportation_extension_main() $hook_enterprise = enterprise_include('extensions/resource_exportation/functions.php'); - ui_print_page_header(__('Resource exportation'), 'images/extensions.png', false, '', true, ''); + ui_print_standard_header( + __('Resource exportation'), + 'images/extensions.png', + false, + '', + true, + [], + [ + [ + 'link' => '', + 'label' => __('Resources'), + ], + [ + 'link' => '', + 'label' => __('Resource exporting'), + ], + ] + ); - echo '
    '; - echo __('This extension makes exportation of resource template more easy.').' '.__('You can export resource templates in .ptr format.'); - echo '
    '; - - echo '

    '; + ui_print_warning_message( + __('This extension makes exportation of resource template more easy.').'
    '.__('You can export resource templates in .ptr format.') + ); $table = new stdClass(); - $table->width = '100%'; - $table->style[0] = 'width: 30%;'; - $table->style[1] = 'width: 10%;'; - $table->class = 'databox filters'; - $table->data[0][0] = __('Report'); - $table->data[0][1] = html_print_select_from_sql('SELECT id_report, name FROM treport', 'report', '', '', '', 0, true); - $table->data[0][2] = html_print_button(__('Export'), '', false, 'export_to_ptr(\'report\');', 'class="sub config"', true); - $table->data[1][0] = __('Visual console'); - $table->data[1][1] = html_print_select_from_sql('SELECT id, name FROM tlayout', 'visual_console', '', '', '', 0, true); - $table->data[1][2] = html_print_button(__('Export'), '', false, 'export_to_ptr(\'visual_console\');', 'class="sub config"', true); + $table->class = 'databox filter-table-adv'; + $table->id = 'resource_exportation_table'; + $table->style = []; + $table->style[0] = 'width: 30%'; + $table->style[1] = 'vertical-align: bottom;'; + $table->data = []; + $table->data[0][] = html_print_label_input_block( + __('Report'), + html_print_div( + [ + 'class' => 'flex-content-left', + 'content' => html_print_select_from_sql('SELECT id_report, name FROM treport', 'report', '', '', '', 0, true), + ], + true + ) + ); + $table->data[0][] = html_print_button(__('Export'), '', false, 'export_to_ptr(\'report\');', ['mode' => 'link'], true); + + $table->data[1][] = html_print_label_input_block( + __('Visual console'), + html_print_div( + [ + 'class' => 'flex-content-left', + 'content' => html_print_select_from_sql('SELECT id, name FROM tlayout', 'visual_console', '', '', '', 0, true), + ], + true + ) + ); + $table->data[1][] = html_print_button(__('Export'), '', false, 'export_to_ptr(\'visual_console\');', ['mode' => 'link'], true); if ($hook_enterprise === true) { add_rows_for_enterprise($table->data); diff --git a/pandora_console/extensions/resource_registration.php b/pandora_console/extensions/resource_registration.php index 732c0151ea..d76814e886 100755 --- a/pandora_console/extensions/resource_registration.php +++ b/pandora_console/extensions/resource_registration.php @@ -1,4 +1,5 @@ group)); break; - case 'event_report_module': - break; - - case 'alert_report_module': - break; - - case 'alert_report_agent': - break; - - case 'alert_report_group': - break; - case 'url': $values['external_source'] = io_safe_input($item['url']); break; @@ -426,9 +384,32 @@ function process_upload_xml_report($xml, $group_filter=0) $values['line_separator'] = io_safe_input($item['line_separator']); $values['column_separator'] = io_safe_input($item['column_separator']); break; + + case 1: + case 'simple_graph': + case 'simple_baseline_graph': + case 6: + case 'monitor_report': + case 7: + case 'avg_value': + case 8: + case 'max_value': + case 9: + case 'min_value': + case 10: + case 'sumatory': + case 'event_report_module': + case 'alert_report_module': + case 'alert_report_agent': + case 'alert_report_group': + case 'agent_detailed_event': + case 'event_report_agent': + default: + // Do nothing. + break; } - if (empty($agents_item)) { + if (empty($agents_item) === true) { $id_content = db_process_sql_insert('treport_content', $values); ui_print_result_message( $id_content, @@ -782,7 +763,7 @@ function process_upload_xml_visualmap($xml, $filter_group=0) function process_upload_xml_component($xml) { - // Extract components + // Extract components. $components = []; foreach ($xml->xpath('/component') as $componentElement) { $name = io_safe_input((string) $componentElement->name); @@ -838,7 +819,7 @@ function process_upload_xml_component($xml) $idComponent = false; switch ((int) $componentElement->module_source) { case 1: - // Local component + // Local component. $values = [ 'description' => $description, 'id_network_component_group' => $group, @@ -854,12 +835,12 @@ function process_upload_xml_component($xml) // Network component // for modules // 15 = remote_snmp, 16 = remote_snmp_inc, - // 17 = remote_snmp_string, 18 = remote_snmp_proc + // 17 = remote_snmp_string, 18 = remote_snmp_proc. $custom_string_1 = ''; $custom_string_2 = ''; $custom_string_3 = ''; if ($type >= 15 && $type <= 18) { - // New support for snmp v3 + // New support for snmp v3. $tcp_send = $snmp_version; $plugin_user = $auth_user; $plugin_pass = $auth_password; @@ -909,13 +890,13 @@ function process_upload_xml_component($xml) 'post_process' => $post_process, ] ); - if ((bool) $idComponent) { + if ((bool) $idComponent === true) { $components[] = $idComponent; } break; case 4: - // Plugin component + // Plugin component. $idComponent = network_components_create_network_component( $name, $type, @@ -956,17 +937,13 @@ function process_upload_xml_component($xml) 'post_process' => $post_process, ] ); - if ((bool) $idComponent) { + if ((bool) $idComponent === true) { $components[] = $idComponent; } break; - case 5: - // Prediction component - break; - case 6: - // WMI component + // WMI component. $idComponent = network_components_create_network_component( $name, $type, @@ -1013,13 +990,17 @@ function process_upload_xml_component($xml) 'post_process' => $post_process, ] ); - if ((bool) $idComponent) { + if ((bool) $idComponent === true) { $components[] = $idComponent; } break; + case 5: + // Prediction component. case 7: - // Web component + // Web component. + default: + // Do nothing. break; } @@ -1030,9 +1011,9 @@ function process_upload_xml_component($xml) ); } - // Extract the template + // Extract the template. $templateElement = $xml->xpath('//template'); - if (!empty($templateElement)) { + if (empty($templateElement) === false) { $templateElement = $templateElement[0]; $templateName = (string) $templateElement->name; @@ -1092,9 +1073,26 @@ function resource_registration_extension_main() include_once $config['homedir'].'/include/functions_db.php'; enterprise_include_once('include/functions_local_components.php'); - ui_print_page_header(__('Resource registration'), 'images/extensions.png', false, '', true, ''); + ui_print_standard_header( + __('Resource registration'), + 'images/extensions.png', + false, + '', + true, + [], + [ + [ + 'link' => '', + 'label' => __('Resources'), + ], + [ + 'link' => '', + 'label' => __('Resource registration'), + ], + ] + ); - if (!extension_loaded('libxml')) { + if (extension_loaded('libxml') === false) { ui_print_error_message(_('Error, please install the PHP libXML in the system.')); return; @@ -1119,15 +1117,42 @@ function resource_registration_extension_main() return; } - echo '
    '; - echo __('This extension makes registering resource templates easier.').' '.__('Here you can upload a resource template in .ptr format.').' '.__('Please refer to our documentation for more information on how to obtain and use %s resources.', get_product_name()).' '.'

    '.__('You can get more resurces in our Public Resource Library'); - echo '
    '; + ui_print_warning_message( + __('This extension makes registering resource templates easier.').'
    '.__('Here you can upload a resource template in .ptr format.').'
    '.__('Please refer to our documentation for more information on how to obtain and use %s resources.', get_product_name()).' '.'

    '.__('You can get more resurces in our Public Resource Library') + ); - echo '

    '; + $table = new stdClass(); + $table->class = 'databox filter-table-adv'; + $table->id = 'resource_registration_table'; + + $table->data = []; + + $table->data[0][] = html_print_label_input_block( + __('File to upload'), + html_print_input_file('resource_upload', true) + ); + + $table->data[0][] = html_print_label_input_block( + __('Group filter'), + html_print_select_groups(false, 'AW', true, 'group', '', '', __('All'), 0, true) + ); // Upload form. - echo "
    "; - echo ''; + echo ''; + html_print_table($table); + html_print_action_buttons( + html_print_submit_button( + __('Upload'), + 'upload', + false, + [ 'icon' => 'wand' ], + true + ), + ['type' => 'form_action'] + ); + echo ''; + /* + echo '
    '; echo ''; echo "'; @@ -1136,8 +1161,7 @@ function resource_registration_extension_main() echo ''; echo "'; - echo '
    "; echo ''.__('Group filter: ').'"; echo '
    '; - echo ''; + echo '';*/ if (isset($_FILES['resource_upload']['tmp_name']) === false) { return; diff --git a/pandora_console/extensions/users_connected.php b/pandora_console/extensions/users_connected.php index 40b17f4903..ad6282c598 100644 --- a/pandora_console/extensions/users_connected.php +++ b/pandora_console/extensions/users_connected.php @@ -1,16 +1,33 @@ '', + 'label' => __('Workspace'), + ], + [ + 'link' => '', + 'label' => __('Users connected'), + ], + ] + ); $check_profile = db_get_row('tusuario_perfil', 'id_usuario', $config['id_user'], 'id_up'); if ($check_profile === false && !users_is_admin()) { diff --git a/pandora_console/extras/mr/62.sql b/pandora_console/extras/mr/62.sql new file mode 100644 index 0000000000..76f0a84c4e --- /dev/null +++ b/pandora_console/extras/mr/62.sql @@ -0,0 +1,158 @@ +START TRANSACTION; + +UPDATE tconfig_os SET `icon_name` = 'linux@os.svg' WHERE `id_os` = 1; +UPDATE tconfig_os SET `icon_name` = 'solaris@os.svg' WHERE `id_os` = 2; +UPDATE tconfig_os SET `icon_name` = 'aix@os.svg' WHERE `id_os` = 3; +UPDATE tconfig_os SET `icon_name` = 'freebsd@os.svg' WHERE `id_os` = 4; +UPDATE tconfig_os SET `icon_name` = 'HP@os.svg' WHERE `id_os` = 5; +UPDATE tconfig_os SET `icon_name` = 'cisco@os.svg' WHERE `id_os` = 7; +UPDATE tconfig_os SET `icon_name` = 'apple@os.svg' WHERE `id_os` = 8; +UPDATE tconfig_os SET `icon_name` = 'windows@os.svg' WHERE `id_os` = 9; +UPDATE tconfig_os SET `icon_name` = 'other-OS@os.svg' WHERE `id_os` = 10; +UPDATE tconfig_os SET `icon_name` = 'network-server@os.svg' WHERE `id_os` = 11; +UPDATE tconfig_os SET `icon_name` = 'network-server@os.svg' WHERE `id_os` = 12; +UPDATE tconfig_os SET `icon_name` = 'network-server@os.svg' WHERE `id_os` = 13; +UPDATE tconfig_os SET `icon_name` = 'embedded@os.svg' WHERE `id_os` = 14; +UPDATE tconfig_os SET `icon_name` = 'android@os.svg' WHERE `id_os` = 15; +UPDATE tconfig_os SET `icon_name` = 'vmware@os.svg' WHERE `id_os` = 16; +UPDATE tconfig_os SET `icon_name` = 'routers@os.svg' WHERE `id_os` = 17; +UPDATE tconfig_os SET `icon_name` = 'switch@os.svg' WHERE `id_os` = 18; +UPDATE tconfig_os SET `icon_name` = 'satellite@os.svg' WHERE `id_os` = 19; +UPDATE tconfig_os SET `icon_name` = 'mainframe@os.svg' WHERE `id_os` = 20; +UPDATE tconfig_os SET `icon_name` = 'cluster@os.svg' WHERE `id_os` = 100; + +UPDATE tgrupo SET `icon` = 'servers@groups.svg' WHERE `id_grupo` = 2; +UPDATE tgrupo SET `icon` = 'firewall@groups.svg' WHERE `id_grupo` = 4; +UPDATE tgrupo SET `icon` = 'database@groups.svg' WHERE `id_grupo` = 8; +UPDATE tgrupo SET `icon` = 'network@groups.svg' WHERE `id_grupo` = 9; +UPDATE tgrupo SET `icon` = 'unknown@groups.svg' WHERE `id_grupo` = 10; +UPDATE tgrupo SET `icon` = 'workstation@groups.svg' WHERE `id_grupo` = 11; +UPDATE tgrupo SET `icon` = 'applications@groups.svg' WHERE `id_grupo` = 12; +UPDATE tgrupo SET `icon` = 'web@groups.svg' WHERE `id_grupo` = 13; + +UPDATE `ttipo_modulo` SET `icon` = 'data-server@svg.svg' WHERE `id_tipo` = 1; +UPDATE `ttipo_modulo` SET `icon` = 'generic-boolean@svg.svg' WHERE `id_tipo` = 2; +UPDATE `ttipo_modulo` SET `icon` = 'generic-string@svg.svg' WHERE `id_tipo` = 3; +UPDATE `ttipo_modulo` SET `icon` = 'data-server@svg.svg' WHERE `id_tipo` = 4; +UPDATE `ttipo_modulo` SET `icon` = 'data-server@svg.svg' WHERE `id_tipo` = 5; +UPDATE `ttipo_modulo` SET `icon` = 'ICMP-network-boolean-data@svg.svg' WHERE `id_tipo` = 6; +UPDATE `ttipo_modulo` SET `icon` = 'ICMP-network-latency@svg.svg' WHERE `id_tipo` = 7; +UPDATE `ttipo_modulo` SET `icon` = 'TCP-network-numeric-data@svg.svg' WHERE `id_tipo` = 8; +UPDATE `ttipo_modulo` SET `icon` = 'TCP-network-boolean-data@svg.svg' WHERE `id_tipo` = 9; +UPDATE `ttipo_modulo` SET `icon` = 'TCP-network-alphanumeric-data@svg.svg' WHERE `id_tipo` = 10; +UPDATE `ttipo_modulo` SET `icon` = 'TCP-network-incremental-data@svg.svg' WHERE `id_tipo` = 11; +UPDATE `ttipo_modulo` SET `icon` = 'SNMP-network-numeric-data@svg.svg' WHERE `id_tipo` = 15; +UPDATE `ttipo_modulo` SET `icon` = 'SNMP-network-incremental-data@svg.svg' WHERE `id_tipo` = 16; +UPDATE `ttipo_modulo` SET `icon` = 'SNMP-network-alphanumeric-data@svg.svg' WHERE `id_tipo` = 17; +UPDATE `ttipo_modulo` SET `icon` = 'SNMP-network-incremental-data@svg.svg' WHERE `id_tipo` = 18; +UPDATE `ttipo_modulo` SET `icon` = 'asynchronus-data@svg.svg' WHERE `id_tipo` = 21; +UPDATE `ttipo_modulo` SET `icon` = 'asynchronus-data@svg.svg' WHERE `id_tipo` = 22; +UPDATE `ttipo_modulo` SET `icon` = 'asynchronus-data@svg.svg' WHERE `id_tipo` = 23; +UPDATE `ttipo_modulo` SET `icon` = 'wux@svg.svg' WHERE `id_tipo` = 25; +UPDATE `ttipo_modulo` SET `icon` = 'server-web@svg.svg' WHERE `id_tipo` = 30; +UPDATE `ttipo_modulo` SET `icon` = 'web-analisys-data@svg.svg' WHERE `id_tipo` = 31; +UPDATE `ttipo_modulo` SET `icon` = 'server-web@svg.svg' WHERE `id_tipo` = 32; +UPDATE `ttipo_modulo` SET `icon` = 'server-web@svg.svg' WHERE `id_tipo` = 33; +UPDATE `ttipo_modulo` SET `icon` = 'remote-execution-numeric-data@svg.svg' WHERE `id_tipo` = 34; +UPDATE `ttipo_modulo` SET `icon` = 'remote-execution-boolean-data@svg.svg' WHERE `id_tipo` = 35; +UPDATE `ttipo_modulo` SET `icon` = 'remote-execution-alphanumeric-data@svg.svg' WHERE `id_tipo` = 36; +UPDATE `ttipo_modulo` SET `icon` = 'remote-execution-incremental-data@svg.svg' WHERE `id_tipo` = 37; +UPDATE `ttipo_modulo` SET `icon` = 'server-web@svg.svg' WHERE `id_tipo` = 38; +UPDATE `ttipo_modulo` SET `icon` = 'keepalive@svg.svg' WHERE `id_tipo` = 100; + +CREATE TABLE IF NOT EXISTS `tagent_filter` ( + `id_filter` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_name` VARCHAR(600) NOT NULL, + `id_group_filter` INT NOT NULL DEFAULT 0, + `group_id` INT NOT NULL DEFAULT 0, + `recursion` TEXT, + `status` INT NOT NULL DEFAULT -1, + `search` TEXT, + `id_os` INT NOT NULL DEFAULT 0, + `policies` TEXT, + `search_custom` TEXT, + `ag_custom_fields` TEXT, + PRIMARY KEY (`id_filter`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +CREATE TABLE `tevent_sound` ( + `id` INT NOT NULL AUTO_INCREMENT, + `name` TEXT NULL, + `sound` TEXT NULL, + `active` TINYINT NOT NULL DEFAULT '1', +PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE INDEX agente_modulo_estado ON tevento (estado, id_agentmodule); +CREATE INDEX idx_disabled ON talert_template_modules (disabled); + +INSERT INTO `treport_custom_sql` (`name`, `sql`) VALUES ('Agent safe mode not enable', 'select alias from tagente where safe_mode_module = 0'); + +CREATE TABLE IF NOT EXISTS `twelcome_tip` ( + `id` INT NOT NULL AUTO_INCREMENT, + `id_lang` VARCHAR(20) NULL, + `id_profile` INT NOT NULL, + `title` VARCHAR(255) NOT NULL, + `text` TEXT NOT NULL, + `url` VARCHAR(255) NULL, + `enable` TINYINT NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +CREATE TABLE IF NOT EXISTS `twelcome_tip_file` ( + `id` INT NOT NULL AUTO_INCREMENT, + `twelcome_tip_file` INT NOT NULL, + `filename` VARCHAR(255) NOT NULL, + `path` VARCHAR(255) NOT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `twelcome_tip_file` + FOREIGN KEY (`twelcome_tip_file`) + REFERENCES `twelcome_tip` (`id`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +INSERT INTO `twelcome_tip` VALUES +(1,'es',0,'¿Sabías que puedes monitorizar webs?','De manera sencilla a través de chequeos HTTP estándar o transaccional mediante transacciones centralizadas WUX, o descentralizadas con el plugin UX de agente.','https://pandorafms.com/manual/es/documentation/03_monitoring/06_web_monitoring','1'), +(2,'es',0,'Monitorización remota de dispositivos SNMP','Los dispositivos de red como switches, AP, routers y firewalls se pueden monitorizar remotamente usando el protocolo SNMP. Basta con saber su IP, la comunidad SNMP y lanzar un wizard SNMP desde la consola.','https://pandorafms.com/manual/es/documentation/03_monitoring/03_remote_monitoring#monitorizacion_snmp','1'), +(3,'es',0,'Monitorizar rutas desde una IP a otra','Existe un plugin especial que sirve para monitorizar visualmente las rutas desde una IP a otra de manera visual y dinámica, según va cambiando con el tiempo.','https://pandorafms.com/manual/es/documentation/03_monitoring/03_remote_monitoring#monitorizacion_de_rutas','1'), +(4,'es',0,'¿Tu red pierde paquetes?','Se puede medir la pérdida de paquetes en tu red usando un agente y un plugin libre llamado “Packet Loss”. Esto es especialmente útil en redes Wifi o redes compartidas con muchos usuarios. Escribimos un artículo en nuestro blog hablando de ello, echale un vistazo','https://pandorafms.com/blog/es/perdida-de-paquetes/','1'), +(5,'es',0,'Usar Telegram con Pandora FMS','Perfecto para recibir alertas con gráficas empotradas y personalizar así la recepción de avisos de manera individual o en un canal común con mas personas. ','https://pandorafms.com/library/telegram-bot-cli/','1'), +(6,'es',0,'Monitorizar JMX (Tomcat, Websphere, Weblogic, Jboss, Apache Kafka, Jetty, GlassFish…)','Existe un plugin Enterprise que sirve para monitorizar cualquier tecnología JMX. Se puede usar de manera local (como plugin local) o de manera remota con el plugin server.','https://pandorafms.com/library/jmx-monitoring/','1'), +(7,'es',0,'¿Sabes que cada usuario puede tener su propia Zona Horaria?','Se puede establecer zonas horarias diferentes para cada usuario, de manera que interprete los datos teniendo en cuenta la diferencia horaria. Pandora FMS también puede tener servidores y agentes en diferentes zonas horarias. ¡Por todo el mundo!','','1'), +(8,'es',0,'Paradas planificadas','Se puede definir, a nivel de agente y a nivel de módulo, períodos en los cuales se ignoren las alertas y/o los datos recogidos. Es perfecto para planificar paradas de servicio o desconexión de los sistemas monitorizados. También afecta a los informes SLA, evitando que se tengan en cuenta esos intervalos de tiempo. ','https://pandorafms.com/manual/es/documentation/04_using/11_managing_and_administration#paradas_de_servicio_planificadas','1'), +(9,'es',0,'Personalizar los emails de alerta ','¿Sabías que se pueden personalizar los mails de alertas de Pandora? Solo tienes que editar el código HTML por defecto de las acciones de alerta de tipo email. ','https://pandorafms.com/manual/en/documentation/04_using/01_alerts#editing_an_action','1'), +(10,'es',0,'Usando iconos personalizados en consolas visuales ','Gracias a los iconos personalizados se pueden crear vistas muy personalizadas, como la de la imagen, que representa racks con los tipos de servidores en el orden que están colocados dentro del rack. Perfecto para que un técnico sepa exactamente qué máquina esta fallando. Más visual no puede ser, de ahi el nombre. ','https://pandorafms.com/manual/start?id=es/documentation/04_using/05_data_presentation_visual_maps','1'), +(11,'es',0,'Consolas visuales: mapas de calor ','La consola permite integrar en un fondo personalizado una serie de datos, que en función de su valor se representen con unos colores u otros, en tiempo real. Las aplicaciones son infinitas, solo depende de tu imaginación. ','https://pandorafms.com/manual/es/documentation/04_using/05_data_presentation_visual_maps#mapa_de_calor_o_nube_de_color','1'), +(12,'es',0,'Auditoría interna de la consola ','La consola registra todas las actividades relevantes de cada usuario conectado a la consola. Esto incluye la aplicación de configuraciones, validaciones de eventos y alertas, conexión y desconexión y cientos de otras operaciones. La seguridad en Pandora FMS ha sido siempre una de las características del diseño de su arquitectura. ','https://pandorafms.com/manual/es/documentation/04_using/11_managing_and_administration#log_de_auditoria','1'), +(13,'es',0,'Sistema de provisión automática de agentes ','El sistema de autoprovisión de agentes, permite que un agente recién ingresado en el sistema aplique automáticamente cambios en su configuración (como moverlo de grupo, asignarle ciertos valores en campos personalizados) y por supuesto aplicarle determinadas politicas de monitorización. Es una de las funcionalidades más potentes, orientadas a gestionar parques de sistemas muy extensos. ','https://pandorafms.com/manual/start?id=es/documentation/02_installation/05_configuration_agents#configuracion_automatica_de_agentes','1'), +(14,'es',0,'Modo oscuro ','¿Sabes que existe un modo oscuro en Pandora FMS? Un administrador lo puede activar a nivel global desde las opciones de configuración visuales o cualquier usuario a nivel individual, en las opciones de usuario. ','','1'), +(15,'es',0,'Google Sheet ','¿Sabes que se puede coger el valor de una celda de una hoja de cálculo de Google Sheet?, utilizamos la API para pedir el dato a través de un plugin remoto. Es perfecto para construir cuadros de mando de negocio, obtener alertas en tiempo real y crear tus propios informes a medida. ','https://pandorafms.com/library/google-sheets-plugin/','1'), +(16,'es',0,'Tablas de ARP','¿Sabes que existe un módulo de inventario para sacar las tablas ARP de tus servidores windows? Es fácil de instalar y puede darte información muy detallada de tus equipos.','https://pandorafms.com/library/arp-table-windows-local/','1'), +(17,'es',0,'Enlaces de red en la consola visual ','Existe un elemento de consola visual llamado “Network link” que permite mostrar visualmente la unión de dos interfaces de red, su estado y el tráfico de subida/bajada, de una manera muy visual. ','https://pandorafms.com/manual/es/documentation/04_using/05_data_presentation_visual_maps#enlace_de_red','1'), +(18,'es',0,'¿Conoces los informes de disponibilidad? ','Son muy útiles ya que te dicen el tiempo (%) que un chequeo ha estado en diferentes estados a lo largo de un lapso de tiempo, por ejemplo, una semana. Ofrece datos crudos completos de lo que se ha hecho con el detalle suficiente para convencer a un proveedor o un cliente. ','','1'), +(19,'es',0,'Gráficas de disponibilidad ','Parecidos a los informes de disponibilidad, pero mucho mas visuales, ofrecen el detalle de estado de un monitor a lo largo del tiempo. Se pueden agrupar con otro módulo para ofrecer datos finales teniendo en cuenta la alta disponibilidad de un servicio. Son perfectos para su uso en informes a proveedores y/o clientes. ','https://pandorafms.com/manual/es/documentation/04_using/08_data_presentation_reports#grafico_de_disponibilidad','1'), +(20,'es',0,'Zoom en gráficas de datos ','¿Sabes que Pandora FMS permite hacer zoom en una parte de la gráfica. Con eso ampliarás la información de la gráfica. Si estás viendo una gráfica de un mes y amplías, podrás ver los datos de ese intervalo. Si utilizas una gráfica con datos de resolución completa (los llamamos gráficas TIP) podrás ver el detalle de cada dato, aunque tu gráfica tenga miles de muestras. ','','1'), +(21,'es',0,'Gráficas de resolución completa ','Pandora FMS y otras herramientas cuando tienen que mostrar una gráfica obtienen los datos de la fuente de datos y luego “simplifican” la gráfica, ya que si la serie de datos tiene 10,000 elementos y la gráfica solo tiene 300 pixeles de ancho no pueden caber todos, asi que se “simplifican” esos 10,000 puntos en solo 300. Sin embargo al simplificar se pierde “detalle” en la gráfica, y por supuesto no podemos “hacer zoom”. Las gráficas de Pandora FMS permiten mostrar y usar todos los datos en una gráfica, que llamamos “TIP” que muestra todos los puntos superpuestos y además permite que al hacer zoom no se pierda resolución. ','','1'), +(22,'es',0,'Política de contraseñas','La consola de Pandora FMS tiene un sistema de gestión de política de credenciales, para reforzar la seguridad local (además de permitir la autenticación externa contra un LDAP, Active Directory o SAML). A través de este sistema podemos forzar cambios de password cada X días, guardar un histórico de passwords usadas o evitar el uso de ciertas contraseñas entre otras acciones. ','https://pandorafms.com/manual/es/documentation/04_using/12_console_setup?s%5B%5D%3Dcontrase%25C3%25B1as#password_policy','1'), +(23,'es',0,'Autenticación de doble factor ','Es posible activar (y forzar su uso a todos los usuarios) un sistema de doble autenticación (usando Google Auth) para que cualquier usuario se autentique además de con una contraseña, con un sistema de token de un solo uso, dando al sistema mucha más seguridad. ','https://pandorafms.com/manual/en/documentation/04_using/12_console_setup?s%5B%5D%3Dgoogle%26s%5B%5D%3Dauth#authentication','1'); + +INSERT INTO `twelcome_tip_file` (`twelcome_tip_file`, `filename`, `path`) VALUES +(1, 'monitorizar_web.png', 'images/tips/'), +(2, 'monitorizar_snmp.png', 'images/tips/'), +(3, 'monitorizar_desde_ip.png', 'images/tips/'), +(4, 'tu_red_pierde_paquetes.png', 'images/tips/'), +(5, 'telegram_con_pandora.png', 'images/tips/'), +(6, 'monitorizar_con_jmx.png', 'images/tips/'), +(7, 'usuario_zona_horaria.png', 'images/tips/'), +(8, 'paradas_planificadas.png', 'images/tips/'), +(9, 'personalizar_los_emails.png', 'images/tips/'), +(10, 'iconos_personalizados.png', 'images/tips/'), +(11, 'mapa_de_calor.png', 'images/tips/'), +(12, 'auditoria.png', 'images/tips/'), +(15, 'google_sheets.png', 'images/tips/'), +(17, 'enlaces_consola_visual.png', 'images/tips/'), +(18, 'informe_disponibiliad.png', 'images/tips/'), +(19, 'graficas_disponibilidad.png', 'images/tips/'), +(20, 'zoom_en_graficas.png', 'images/tips/'), +(22, 'politica_de_pass.png', 'images/tips/'); + +COMMIT; diff --git a/pandora_console/general/first_task/custom_fields.php b/pandora_console/general/first_task/custom_fields.php index c8767a3c48..11f9f30c2d 100644 --- a/pandora_console/general/first_task/custom_fields.php +++ b/pandora_console/general/first_task/custom_fields.php @@ -1,16 +1,32 @@ true, 'message' => __('There are no custom __('Custom Fields')]); ?>
    -

    +

    true, 'message' => __('There are no custom ?>

    + 'action-buttons', + 'content' => html_print_submit_button( + __('Create Custom Fields'), + 'button_task', + false, + [ 'icon' => 'next' ], + true + ), + ] + ); + ?>
    diff --git a/pandora_console/general/first_task/custom_graphs.php b/pandora_console/general/first_task/custom_graphs.php index 9429218133..96f4c1262b 100644 --- a/pandora_console/general/first_task/custom_graphs.php +++ b/pandora_console/general/first_task/custom_graphs.php @@ -15,9 +15,6 @@ global $config; check_login(); ui_require_css_file('first_task'); ?> - true, 'message' => __('There are no custom graphs defined yet.') ]); -?>
    @@ -36,7 +33,17 @@ ui_print_info_message(['no_close' => true, 'message' => __('There are no custom ?>

    - + 'wand'], + true + ) + ); + ?>
    \ No newline at end of file diff --git a/pandora_console/general/first_task/map_builder.php b/pandora_console/general/first_task/map_builder.php index de964bf087..6091b45d61 100755 --- a/pandora_console/general/first_task/map_builder.php +++ b/pandora_console/general/first_task/map_builder.php @@ -1,28 +1,38 @@ true, - 'message' => __('There are no visual console defined yet.'), - ] -); if ($vconsoles_write || $vconsoles_manage) { ?> @@ -31,7 +41,7 @@ if ($vconsoles_write || $vconsoles_manage) { __('Visual Console')]); ?>
    -

    +

    - - + 'wand'], + true + ) + ); + ?>
    diff --git a/pandora_console/general/first_task/planned_downtime.php b/pandora_console/general/first_task/planned_downtime.php index 6bfbe5627b..a88a3e0fc3 100644 --- a/pandora_console/general/first_task/planned_downtime.php +++ b/pandora_console/general/first_task/planned_downtime.php @@ -1,16 +1,32 @@ __('Scehduled Downtime')]); ?>
    -

    +

    - +
    diff --git a/pandora_console/general/first_task/service_list.php b/pandora_console/general/first_task/service_list.php index f3b816c006..dae4eedb08 100755 --- a/pandora_console/general/first_task/service_list.php +++ b/pandora_console/general/first_task/service_list.php @@ -1,29 +1,44 @@ - true, 'message' => __('There are no services defined yet.') ]); ?>
    - __('Services')]); ?> + __('Services'), 'class' => 'w120px']); ?>
    -

    +

    - + 'wand'], + true + ) + ); + ?>
    -
    ', $menuTypeClass); ?> -
    +
    ', $menuTypeClass); // ======= Servers List =============================================== if ((bool) check_acl($config['id_user'], 0, 'AW') !== false) { - $servers_list = '
    '; $servers = []; $servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver'); if ($servers['all'] != 0) { @@ -45,22 +44,33 @@ echo sprintf('
    ', $menuTypeClass); $servers['down'] = ($servers['all'] - $servers['up']); if ($servers['up'] == 0) { // All Servers down or no servers at all. - $servers_check_img = html_print_image('images/header_down_gray.png', true, ['alt' => 'cross', 'class' => 'bot', 'title' => __('All systems').': '.__('Down')]); + $servers_check_img = html_print_image('images/system_error@header.svg', true, ['alt' => 'cross', 'class' => 'main_menu_icon bot', 'title' => __('All systems').': '.__('Down')]); } else if ($servers['down'] != 0) { // Some servers down. - $servers_check_img = html_print_image('images/header_warning_gray.png', true, ['alt' => 'error', 'class' => 'bot', 'title' => $servers['down'].' '.__('servers down')]); + $servers_check_img = html_print_image('images/system_warning@header.svg', true, ['alt' => 'error', 'class' => 'main_menu_icon bot', 'title' => $servers['down'].' '.__('servers down')]); } else { // All servers up. - $servers_check_img = html_print_image('images/header_ready_gray.png', true, ['alt' => 'ok', 'class' => 'bot', 'title' => __('All systems').': '.__('Ready')]); + $servers_check_img = html_print_image('images/system_ok@header.svg', true, ['alt' => 'ok', 'class' => 'main_menu_icon bot', 'title' => __('All systems').': '.__('Ready')]); } unset($servers); // Since this is the header, we don't like to trickle down variables. - $servers_check_img_link = ''; - $servers_check_img_link .= $servers_check_img; - $servers_check_img_link .= ''; + $servers_check_img_link = html_print_anchor( + [ + 'href' => 'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', + 'content' => $servers_check_img, + ], + true + ); }; - $servers_list .= $servers_check_img_link.'
    '; + + $servers_list = html_print_div( + [ + 'id' => 'servers_list', + 'content' => $servers_check_img_link, + ], + true + ); } @@ -71,9 +81,9 @@ echo sprintf('
    ', $menuTypeClass); $check_minor_release_available = db_check_minor_relase_available(); - if ($check_minor_release_available) { + if ($check_minor_release_available === true) { if (users_is_admin($config['id_user'])) { - if ($config['language'] == 'es') { + if ($config['language'] === 'es') { set_pandora_error_for_header('Hay una o mas revisiones menores en espera para ser actualizadas. '.__('Sobre actualización de revisión menor').'', 'Revisión/es menor/es disponible/s'); } else { set_pandora_error_for_header('There are one or more minor releases waiting for update. '.__('About minor release update').'', 'minor release/s available'); @@ -227,10 +237,10 @@ echo sprintf('
    ', $menuTypeClass); if ($do_refresh) { $autorefresh_img = html_print_image( - 'images/header_refresh_gray.png', + 'images/auto_refresh@header.svg', true, [ - 'class' => 'bot', + 'class' => 'main_menu_icon bot', 'alt' => 'lightning', 'title' => __('Configure autorefresh'), ] @@ -293,10 +303,10 @@ echo sprintf('
    ', $menuTypeClass); $display_counter = 'display:block'; } else { $autorefresh_img = html_print_image( - 'images/header_refresh_disabled_gray.png', + 'images/auto_refresh@header.svg', true, [ - 'class' => 'bot autorefresh_disabled invert_filter', + 'class' => 'main_menu_icon bot autorefresh_disabled invert_filter', 'alt' => 'lightning', 'title' => __('Disabled autorefresh'), ] @@ -312,10 +322,10 @@ echo sprintf('
    ', $menuTypeClass); } } else { $autorefresh_img = html_print_image( - 'images/header_refresh_disabled_gray.png', + 'images/auto_refresh@header.svg', true, [ - 'class' => 'bot autorefresh_disabled invert_filter', + 'class' => 'main_menu_icon bot autorefresh_disabled invert_filter', 'alt' => 'lightning', 'title' => __('Disabled autorefresh'), ] @@ -350,9 +360,10 @@ echo sprintf('
    ', $menuTypeClass); $header_feedback .= ''; $header_feedback .= ''; $header_feedback .= html_print_image( - 'images/feedback-header.png', + 'images/send_feedback@header.svg', true, [ + 'class' => 'main_menu_icon invert_filter', 'title' => __('Feedback'), 'id' => 'feedback-header', 'alt' => __('Feedback'), @@ -373,11 +384,11 @@ echo sprintf('
    ', $menuTypeClass); $header_support = '
    '; $header_support .= ''; $header_support .= html_print_image( - 'images/header_support.png', + 'images/support@header.svg', true, [ 'title' => __('Go to support'), - 'class' => 'bot invert_filter', + 'class' => 'main_menu_icon bot invert_filter', 'alt' => 'user', ] ); @@ -387,11 +398,11 @@ echo sprintf('
    ', $menuTypeClass); $header_docu = '
    '; $header_docu .= ''; $header_docu .= html_print_image( - 'images/header_docu.png', + 'images/documentation@header.svg', true, [ 'title' => __('Go to documentation'), - 'class' => 'bot invert_filter', + 'class' => 'main_menu_icon bot invert_filter', 'alt' => 'user', ] ); @@ -399,34 +410,38 @@ echo sprintf('
    ', $menuTypeClass); // User. - if (is_user_admin($config['id_user']) == 1) { - $header_user = html_print_image( - 'images/header_user_admin_green.png', - true, - [ - 'title' => __('Edit my user'), - 'class' => 'bot', - 'alt' => 'user', - ] - ); - } else { - $header_user = html_print_image( - 'images/header_user_green.png', - true, - [ - 'title' => __('Edit my user'), - 'class' => 'bot', - 'alt' => 'user', - ] - ); - } + // $headerUserImage = (is_user_admin($config['id_user']) === true) ? 'images/header_user_admin_green.png' : 'images/header_user_green.png'; + $headerUser = []; + $headerUser[] = html_print_image( + 'images/edit_user@header.svg', + true, + [ + 'title' => __('Edit my user'), + 'class' => 'main_menu_icon bot invert_filter', + 'alt' => 'user', + ] + ); - $header_user = ''; + $headerUser[] = sprintf('[ %s ]', $config['id_user']); + + $header_user = html_print_div( + [ + 'id' => 'header_user', + 'content' => html_print_anchor( + [ + 'href' => sprintf('index.php?sec=gusuarios&sec2=godmode/users/configure_user&edit_user=1&pure=0&id_user=%s', $config['id_user']), + 'content' => implode('', $headerUser), + ], + true + ), + ], + true + ); // Logout. $header_logout = ' - - - - diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index cd45f34f48..8517b1c46c 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 ''; 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 '
    '; @@ -476,8 +551,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 '
    '; @@ -485,9 +561,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 '
    '; @@ -500,12 +603,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 '
    '; @@ -528,8 +637,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 '
    '; @@ -547,8 +657,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 '
    '; @@ -655,8 +766,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 '
    '; @@ -711,7 +823,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'); }); @@ -726,19 +838,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; @@ -749,7 +865,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: { @@ -759,7 +874,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 = ""; }); }); @@ -773,7 +888,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, @@ -791,8 +905,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" @@ -800,12 +914,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; } @@ -816,7 +929,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: { @@ -826,7 +938,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'); }); }); @@ -837,7 +949,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: { @@ -857,7 +968,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, @@ -870,5 +980,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..ca213bae37 100644 --- a/pandora_console/godmode/agentes/agent_conf_gis.php +++ b/pandora_console/godmode/agentes/agent_conf_gis.php @@ -59,7 +59,7 @@ ui_print_warning_message( ] ); -$table = new StdClass(); +$table = new stdClass(); $table->width = '100%'; $table->class = 'databox filters'; $table->data = []; diff --git a/pandora_console/godmode/agentes/agent_incidents.php b/pandora_console/godmode/agentes/agent_incidents.php index 796a3afd77..e7e442e7e3 100644 --- a/pandora_console/godmode/agentes/agent_incidents.php +++ b/pandora_console/godmode/agentes/agent_incidents.php @@ -59,23 +59,22 @@ $result = integria_api_call(null, null, null, null, 'get_incidents', $params, fa $result = json_decode($result, true); -$count = count($result); - -$result = array_slice($result, $offset, $config['block_size']); - -if (empty($result)) { +if (empty($result) === true) { $result = []; $count = 0; echo '
    '.__('No incidents associated to this agent').'

    '; return; +} else { + $count = count($result); + $result = array_slice($result, $offset, $config['block_size']); } -// Show pagination +// Show pagination. ui_pagination($count, $url, $offset, 0, false, 'offset'); // ($count + $offset) it's real count of incidents because it's use LIMIT $offset in query. echo '
    '; -// Show headers +// Show headers. $table->width = '100%'; $table->class = 'databox'; $table->cellpadding = 4; diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 836b68ba68..f524fb7d9e 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -1,11 +1,11 @@ '; echo '
    '; // Custom ID. $custom_id_div = '
    '; -$custom_id_div .= '

    '.__('Custom ID').':

    '; +$custom_id_div .= '

    '.__('Custom ID').':

    '; $custom_id_div .= html_print_input_text( 'custom_id', $custom_id, @@ -209,107 +206,214 @@ $custom_id_div .= html_print_input_text( 'agent_custom_id' ).'
    '; -if (!$new_agent && $alias != '') { - $table_agent_name = '

    '.__('Agent name').'

    '; - $table_agent_name .= '
    '; - $table_agent_name .= '
    '.html_print_input_text('agente', $nombre_agente, '', 50, 100, true).'
    '; - $table_agent_name .= '
    '; +// Get groups. +$groups = users_get_groups($config['id_user'], 'AR', false); - if ($id_agente) { - $table_agent_name .= ''; - $table_agent_name .= ''; - $table_agent_name .= html_print_image( - 'images/zoom.png', - true, - [ - 'border' => 0, - 'title' => __('Agent detail'), - 'class' => 'invert_filter', - ] - ); - $table_agent_name .= ''; +// Get modules. +$modules = db_get_all_rows_sql( + 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo + WHERE id_agente = '.$id_parent +); +$modules_values = []; +$modules_values[0] = __('Any'); +if (is_array($modules) === true) { + foreach ($modules as $m) { + $modules_values[$m['id_module']] = $m['name']; } +} - $agent_options_update = 'agent_options_update'; - - // Delete link from here. - if (is_management_allowed() === true) { - $table_agent_name .= "".html_print_image( - 'images/cross.png', - true, - [ - 'title' => __('Delete agent'), - 'class' => 'invert_filter', - ] - ).''; - } - - // Remote configuration available. +// Remote configuration available. +if (isset($filename) === true && file_exists($filename['md5']) === true) { + $remote_agent = true; + $agent_md5 = md5(io_safe_output(agents_get_name($id_agente)), false); +} else { $remote_agent = false; - if (isset($filename)) { - if (file_exists($filename['md5'])) { - $remote_agent = true; +} - $agent_name = agents_get_name($id_agente); - $agent_name = io_safe_output($agent_name); - $agent_md5 = md5($agent_name, false); +// Get Servers. +$servers = servers_get_names(); +// Set the agent have not server. +if (array_key_exists($server_name, $servers) === false) { + $server_name = 0; +} - $table_agent_name .= ''; - $table_agent_name .= html_print_image( - 'images/application_edit.png', - true, - [ - 'border' => 0, - 'title' => __('This agent can be remotely configured'), - 'class' => 'invert_filter', - ] - ); - $table_agent_name .= ''; +if ($new_agent === true) { + // Set first server by default. + $servers_get_names = $servers; + $array_keys_servers_get_names = array_keys($servers_get_names); + $server_name = reset($array_keys_servers_get_names); +} + + +// QR Code table. +if ($new_agent === false) { + $CodeQRContent .= html_print_div(['id' => 'qr_container_image'], true); + $CodeQRContent .= html_print_anchor( + [ + 'id' => 'qr_code_agent_view', + 'href' => ui_get_full_url('mobile/index.php?page=agent&id='.$id_agente), + ], + true + ); + $CodeQRContent .= '
    '.$custom_id_div; + + // QR code div. + $CodeQRTable = html_print_div( + [ + 'class' => 'agent_qr', + 'content' => $CodeQRContent, + ], + true + ); +} else { + $CodeQRTable = ''; +} + +// Advanced mode. +if (enterprise_installed() === true) { + // Safe operation mode. + if ($new_agent === false) { + $sql_modules = db_get_all_rows_sql( + 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo + WHERE id_agente = '.$id_agente + ); + $safe_mode_modules = []; + $safe_mode_modules[0] = __('Any'); + if (is_array($sql_modules) === true) { + foreach ($sql_modules as $m) { + $safe_mode_modules[$m['id_module']] = $m['name']; + } } } - $table_agent_name .= '
    '; - - // QR code div. - $table_qr_code = '
    '; - $table_qr_code .= '

    '.__('QR Code Agent view').'

    '; - $table_qr_code .= '
    '; - if ($id_agente) { - $table_qr_code .= ""; + // Calculate cps value - agents. + if ($new_agent === false) { + $cps_val = service_agents_cps($id_agente); + } else { + // No agent defined, use received cps as base value. + if ($cps >= 0) { + $cps_val = $cps; + } } - // Add Custom id div. - $table_qr_code .= '
    '; - $table_qr_code .= $custom_id_div; - $table_qr_code .= '
    '; + // Parent agents. + $paramsParentAgent = []; + $paramsParentAgent['return'] = true; + $paramsParentAgent['show_helptip'] = false; + $paramsParentAgent['input_name'] = 'id_parent'; + $paramsParentAgent['print_hidden_input_idagent'] = true; + $paramsParentAgent['hidden_input_idagent_name'] = 'id_agent_parent'; + $paramsParentAgent['hidden_input_idagent_value'] = $id_parent; + $paramsParentAgent['value'] = db_get_value('alias', 'tagente', 'id_agente', $id_parent); + $paramsParentAgent['selectbox_id'] = 'cascade_protection_module'; + $paramsParentAgent['javascript_is_function_select'] = true; + $paramsParentAgent['cascade_protection'] = true; + $paramsParentAgent['input_style'] = 'width: 100%;'; + + if ($id_agente !== 0) { + // Deletes the agent's offspring. + $paramsParentAgent['delete_offspring_agents'] = $id_agente; + } } -if ($new_agent) { - $label_select_child_left = 'label_select_child_left'; - $label_select_parent = 'label_select_parent'; +$listIcons = gis_get_array_list_icons(); + +$arraySelectIcon = []; +foreach ($listIcons as $index => $value) { + $arraySelectIcon[$index] = $index; } -$table_alias = '

    '.__('Alias').'

    '; -$table_alias .= '
    '; -$table_alias .= '
    '.html_print_input_text('alias', $alias, '', 50, 100, true, false, true).'
    '; -if ($new_agent) { - $table_alias .= '
    '.html_print_checkbox_switch('alias_as_name', 1, $config['alias_as_name'], true).__('Use alias as name').'
    '; +// Agent icons. +$path = 'images/gis_map/icons/'; +// TODO set better method the path. +$table_adv_agent_icon = '

    '.__('Agent icon').'

    '; +if ($icon_path == '') { + $display_icons = 'none'; + // Hack to show no icon. Use any given image to fix not found image errors. + $path_without = 'images/spinner.gif'; + $path_default = 'images/spinner.gif'; + $path_ok = 'images/spinner.gif'; + $path_bad = 'images/spinner.gif'; + $path_warning = 'images/spinner.gif'; +} else { + $display_icons = ''; + $path_without = $path.$icon_path.'.default.png'; + $path_default = $path.$icon_path.'.default.png'; + $path_ok = $path.$icon_path.'.ok.png'; + $path_bad = $path.$icon_path.'.bad.png'; + $path_warning = $path.$icon_path.'.warning.png'; } -$table_alias .= '
    '; +$tableAgent = new stdClass(); +$tableAgent->class = 'floating_form primary_form'; +$tableAgent->data = []; +$tableAgent->style = []; +$tableAgent->cellclass = []; +$tableAgent->colspan = []; +$tableAgent->rowspan = []; -$table_ip = '

    '.__('IP Address').'

    '; -$table_ip .= '
    '; -$table_ip .= '
    '.html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).'
    '; -$table_ip .= '
    '.html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').'
    '; -$table_ip .= '
    '.html_print_input( +// Agent name. +if ($new_agent === false) { + $tableAgent->data['caption_name'][0] = __('Agent name'); + $tableAgent->rowclass['name'] = 'w540px'; + $tableAgent->cellstyle['name'][0] = 'width: 100%;'; + $tableAgent->data['name'][0] = html_print_input_text('agente', $nombre_agente, '', 76, 100, true, false, false, '', 'w100p'); + $tableAgent->data['name'][0] .= html_print_div( + [ + 'class' => 'moduleIdBox', + 'content' => __('ID').' '.$id_agente.'', + ], + true + ); + // Agent options for QR code. + $agent_options_update = 'agent_options_update'; +} + +// Alias. +$tableAgent->data['caption_alias'][0] = __('Alias'); +$tableAgent->rowclass['alias'] = 'w540px'; +$tableAgent->data['alias'][0] = html_print_input_text('alias', $alias, '', 50, 100, true, false, true, '', 'w540px'); +if ($new_agent === true) { + $tableAgent->rowclass['additional_alias'] = 'subinput'; + $tableAgent->data['additional_alias'][0] = html_print_checkbox_switch('alias_as_name', 1, $config['alias_as_name'], true); + $tableAgent->data['additional_alias'][1] = __('Use alias as name'); +} else { + if ($remote_agent === true) { + $tableAgent->data['alias'][0] .= html_print_anchor( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$id_agente.'&disk_conf='.$agent_md5, + 'content' => html_print_image( + 'images/remote-configuration@svg.svg', + true, + [ + 'border' => 0, + 'title' => __('This agent can be remotely configured'), + 'class' => 'invert_filter after_input_icon', + ] + ), + ], + true + ); + } +} + +// Ip adress. +$tableAgent->data['caption_ip_address'] = __('IP Address'); +$tableAgent->rowclass['ip_address'] = 'w540px'; +$tableAgent->data['ip_address'][0] = html_print_input_text('direccion', $direccion_agente, '', 16, 100, true, false, false, '', 'w540px'); + +$tableAgent->rowclass['additional_ip_address'] = 'subinput'; +$tableAgent->data['additional_ip_address'][0] = html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true); +$tableAgent->data['additional_ip_address'][1] = __('Unique IP'); +$tableAgent->cellclass['additional_ip_address'][1] = 'w120px'; +$tableAgent->data['additional_ip_address'][2] = html_print_input( [ 'type' => 'switch', 'id' => 'fixed_ip', 'name' => 'fixed_ip', 'value' => $fixed_ip, ] -).__('Fix IP address').'

    '.ui_print_help_tip(__('Avoid automatic IP address update when agent IP changes.'), true).'

    '; +); $table_ip .= '
    '; @@ -336,48 +440,73 @@ $modules = db_get_all_rows_sql( 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo WHERE id_agente = '.$id_parent ); -$modules_values = []; -$modules_values[0] = __('Any'); -if (is_array($modules)) { - foreach ($modules as $m) { - $modules_values[$m['id_module']] = $m['name']; - } +$tableAgent->data['additional_ip_address'][3] = __('Fix IP address'); +$tableAgent->data['additional_ip_address'][3] .= ui_print_help_tip(__('Avoid automatic IP address update when agent IP changes.'), true); + +// IP Address List. +if ($new_agent === false) { + $tableAgent->data['caption_ip_address_list'] = __('IP Address list'); + $tableAgent->data['ip_address_list'][0] = html_print_select(agents_get_addresses($id_agente), 'address_list', $direccion_agente, '', '', 0, true, false, true, 'w540px'); + $tableAgent->rowclass['additional_ip_address_list'] = 'subinput'; + $tableAgent->data['additional_ip_address_list'][0] = html_print_checkbox_switch('delete_ip', 1, false, true); + $tableAgent->data['additional_ip_address_list'][1] = __('Delete selected IPs'); } -$table_primary_group = '

    '.__('Primary group').'

    '; -$table_primary_group .= '
    '; -// Cannot change primary group if user have not permission for that group. -if (isset($groups[$grupo]) || $new_agent) { - $table_primary_group .= html_print_input( - [ - 'type' => 'select_groups', - 'returnAllGroup' => false, - 'name' => 'grupo', - 'selected' => $grupo, - 'return' => true, - 'required' => true, - 'privilege' => 'AW', - ] +// Select primary group. +$tableAgent->data['caption_primary_group'][0] = __('Primary group'); +if (isset($groups[$grupo]) === true || $new_agent === true) { + $tableAgent->rowclass['primary_group'] = 'w540px'; + // Cannot change primary group if user have not permission for that group. + $tableAgent->data['primary_group'][0] = html_print_select_groups( + false, + 'AW', + false, + 'grupo', + $grupo, + '', + '', + 0, + true, + false, + true, + '', + false, + '', + '', + false, + 'id_grupo', + false, + false, + false, + '540px', + false, + true, ); } else { - $table_primary_group .= groups_get_name($grupo); - $table_primary_group .= html_print_input_hidden('grupo', $grupo, true); + $tableAgent->data['primary_group'][0] .= groups_get_name($grupo); + $tableAgent->data['primary_group'][0] .= html_print_input_hidden('grupo', $grupo, true); } -$table_primary_group .= '
    '; -if ($id_agente === 0) { - $hidden = 'display: none;'; -} else { - $hidden = ''; -} +$tableAgent->data['primary_group'][0] .= html_print_div( + [ + 'content' => ui_print_group_icon( + $grupo, + true, + '', + ($id_agente === 0) ? 'display: none;' : '', + true, + false, + false, + 'after_input_icon' + ), + ], + true +); -$table_primary_group .= ui_print_group_icon($grupo, true, 'groups_small', $hidden); - -$table_primary_group .= '
    '; - -$table_interval = '

    '.__('Interval').'

    '; -$table_interval .= '
    '; -$table_interval .= html_print_extended_select_for_time( +$tableAgent->data['caption_interval'][0] = __('Interval'); +// $tableAgent->rowstyle['interval'] = 'width: 260px'; +$tableAgent->rowclass['interval'] = 'w540px'; +$tableAgent->data['interval'][0] = html_print_extended_select_for_time( 'intervalo', $intervalo, '', @@ -387,61 +516,82 @@ $table_interval .= html_print_extended_select_for_time( true, false, true, - 'w40p' + 'w33p' ); - - if ($intervalo < SECONDS_5MINUTES) { - $table_interval .= clippy_context_help('interval_agent_min'); + $tableAgent->data['interval'][0] .= clippy_context_help('interval_agent_min'); } -$table_interval .= '
    '; - -$table_os = '

    '.__('OS').'

    '; -$table_os .= '
    '; -$table_os .= html_print_select_from_sql( +$tableAgent->data['caption_os'][0] = __('OS'); +$tableAgent->rowclass['os'] = 'w540px'; +$tableAgent->data['os'][0] = html_print_select_from_sql( 'SELECT id_os, name FROM tconfig_os', 'id_os', $id_os, '', '', '0', + true, + false, + true, + false, + 'width: 540px;' +); +$tableAgent->data['os'][0] .= html_print_div( + [ + 'class' => 'after_input_icon', + 'id' => 'os_preview', + 'content' => ui_print_os_icon( + $id_os, + false, + true + ), + ], true ); -$table_os .= '
    '; -$table_os .= ui_print_os_icon($id_os, false, true); -$table_os .= '
    '; -// Network server. -$servers = servers_get_names(); -// Set the agent have not server. -if (array_key_exists($server_name, $servers) === false) { - $server_name = 0; -} - -$table_server = '

    '.__('Server').'

    '; -$table_server .= '
    '; -if ($new_agent) { - // Set first server by default. - $servers_get_names = $servers; - $array_keys_servers_get_names = array_keys($servers_get_names); - $server_name = reset($array_keys_servers_get_names); -} - -$table_server .= html_print_select( +$tableAgent->data['caption_server'][0] = __('Server'); +$tableAgent->rowclass['server'] = 'w540px'; +$tableAgent->data['server'][0] = html_print_select( $servers, 'server_name', $server_name, '', __('None'), 0, - true -).'
    '; + true, + false, + true, + 'w540px', + false, + 'width: 540px;' +); +// Description. +$tableAgent->data['caption_description'][0] = __('Description'); +$tableAgent->rowclass['description'] = 'w540px'; +$tableAgent->data['description'][0] = html_print_textarea( + 'comentarios', + 3, + 80, + $comentarios, + '', + true, + 'agent_description w540px' +); -$table_satellite = ''; -if ($remote_agent === true) { +html_print_div( + [ + 'class' => 'box-flat white_table_flex white_box agent_details_col', + 'style' => 'display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px', + 'content' => html_print_table($tableAgent, true).$CodeQRTable, + ] +); +/* + TODO REVIEW + $table_satellite = ''; + if ($remote_agent === true) { // Satellite server selector. $satellite_servers = db_get_all_rows_filter( 'tserver', @@ -473,148 +623,70 @@ if ($remote_agent === true) { ] ).'
    '; } -} + } +*/ -// Description. -$table_description = '

    '.__('Description').'

    '; -$table_description .= html_print_textarea( - 'comentarios', - 3, - 10, - $comentarios, - '', - true, - 'agent_description' -).'
    '; - -// QR code. -echo '
    -
    -
    '.$table_agent_name.$table_alias.$table_ip.$table_primary_group.'
    -
    '.$table_interval.$table_os.$table_server.$table_satellite.$table_description.'
    -
    '; -if (!$new_agent && $alias != '') { - echo $table_qr_code; -} - -echo '
    '; - -if (enterprise_installed()) { - $adv_secondary_groups_label = '
    '; - $adv_secondary_groups_label .= '

    '; - $adv_secondary_groups_label .= __('Secondary groups'); - $adv_secondary_groups_label .= '

    '; - $adv_secondary_groups_label .= '
    '; - $select_agent_secondary = html_print_select_agent_secondary( +// Advanced options. +$tableAdvancedAgent = new stdClass(); +$tableAdvancedAgent->class = 'filter-table-adv floating_form primary_form'; +$tableAdvancedAgent->data = []; +$tableAdvancedAgent->style = []; +$tableAdvancedAgent->cellclass = []; +$tableAdvancedAgent->colspan = []; +$tableAdvancedAgent->rowspan = []; +// Secondary groups. +$tableAdvancedAgent->data['secondary_groups'][] = html_print_label_input_block( + __('Secondary groups'), + html_print_select_agent_secondary( $agent, $id_agente - ); + ) +); - // Safe operation mode. - if ($id_agente) { - $sql_modules = db_get_all_rows_sql( - 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo - WHERE id_agente = '.$id_agente - ); - $safe_mode_modules = []; - $safe_mode_modules[0] = __('Any'); - if (is_array($sql_modules)) { - foreach ($sql_modules as $m) { - $safe_mode_modules[$m['id_module']] = $m['name']; - } - } - - $table_adv_safe = '

    '.__('Safe operation mode').'

    '; - $table_adv_safe .= html_print_checkbox_switch('safe_mode', 1, $safe_mode, true); - $table_adv_safe .= __('Module').' '.html_print_select($safe_mode_modules, 'safe_mode_module', $safe_mode_module, '', '', 0, true).'
    '; - } - - // Remote configuration. - $table_adv_remote = '

    '.__('Remote configuration').'

    '; - - if (!$new_agent && isset($filename) && file_exists($filename['md5'])) { - $table_adv_remote .= date('F d Y H:i:s', fileatime($filename['md5'])); - // Delete remote configuration. - $table_adv_remote .= ''; - $table_adv_remote .= html_print_image( - 'images/cross.png', - true, - [ - 'title' => __('Delete remote configuration file'), - 'style' => 'vertical-align: middle;', - 'class' => 'invert_filter', - ] - ).''; - $table_adv_remote .= ''; - } else { - $table_adv_remote .= ''.__('Not available').''; - } - - $table_adv_remote .= '
    '; +// Parent agent. +$tableAdvancedAgent->data['parent_agent'][] = html_print_label_input_block( + __('Parent'), + ui_print_agent_autocomplete_input($paramsParentAgent) +); - // Calculate cps value - agents. - if ($id_agente) { - $cps_val = service_agents_cps($id_agente); - } else { - // No agent defined, use received cps as base value. - if ($cps >= 0) { - $cps_val = $cps; - } - } - - $cps_html = '
    '; - $cps_html .= html_print_checkbox_switch('cps', $cps_val, ($cps >= 0), true); - $cps_html .= __('Cascade protection services').' '; - $cps_html .= '
    '; - - $table_adv_cascade .= $cps_html; -} - -$table_adv_parent = '
    '; -$params = []; -$params['return'] = true; -$params['show_helptip'] = true; -$params['input_name'] = 'id_parent'; -$params['print_hidden_input_idagent'] = true; -$params['hidden_input_idagent_name'] = 'id_agent_parent'; -$params['hidden_input_idagent_value'] = $id_parent; -$params['value'] = db_get_value('alias', 'tagente', 'id_agente', $id_parent); -$params['selectbox_id'] = 'cascade_protection_module'; -$params['javascript_is_function_select'] = true; -$params['cascade_protection'] = true; -if ($id_agente !== 0) { - // Deletes the agent's offspring. - $params['delete_offspring_agents'] = $id_agente; -} - -$table_adv_parent .= '
    '; -$table_adv_parent .= ui_print_agent_autocomplete_input($params); -if (enterprise_installed()) { - $table_adv_parent .= html_print_checkbox_switch( +if (enterprise_installed() === true) { + $cascadeProtectionContents = []; + $cascadeProtectionContents[] = html_print_checkbox_switch( 'cascade_protection', 1, $cascade_protection, true - ).__('Cascade protection').' '; + ); - $table_adv_parent .= __('Module').' '.html_print_select( + $cascadeProtectionContents[] = html_print_select( $modules_values, 'cascade_protection_module', $cascade_protection_module, '', '', 0, - true + true, + false, + true, + 'w220p' + ); + + $tableAdvancedAgent->data['caption_cascade_protection'][] = html_print_label_input_block( + __('Cascade protection modules'), + html_print_div( + [ + 'class' => 'flex-row-center', + 'content' => implode('', $cascadeProtectionContents), + ], + true + ) ); } -$table_adv_parent .= '
    '; - -// Learn mode / Normal mode. -$table_adv_module_mode = '

    '.__('Module definition').'

    '; -$table_adv_module_mode .= '
    '; -$table_adv_module_mode .= html_print_radio_button_extended( +// Module Definition (Learn mode). +$switchButtons = []; +$switchButtons[] = html_print_radio_button_extended( 'modo', 1, __('Learning mode'), @@ -624,7 +696,7 @@ $table_adv_module_mode .= html_print_radio_button_extended( '', true ); -$table_adv_module_mode .= html_print_radio_button_extended( +$switchButtons[] = html_print_radio_button_extended( 'modo', 0, __('Normal mode'), @@ -634,7 +706,7 @@ $table_adv_module_mode .= html_print_radio_button_extended( '', true ); -$table_adv_module_mode .= html_print_radio_button_extended( +$switchButtons[] = html_print_radio_button_extended( 'modo', 2, __('Autodisable mode'), @@ -644,23 +716,73 @@ $table_adv_module_mode .= html_print_radio_button_extended( '', true ); -$table_adv_module_mode .= '
    '; -// Status (Disabled / Enabled). -$table_adv_status = '
    '; -$table_adv_status .= html_print_checkbox_switch( - 'disabled', - 1, - $disabled, - true +$tableAdvancedAgent->data['module_definition'][] = html_print_label_input_block( + __('Module definition'), + html_print_div( + [ + 'class' => 'switch_radio_button', + 'content' => implode('', $switchButtons), + ], + true + ) +); + +// CPS - Cascade Protection Services. +$tableAdvancedAgent->data['cps_value'][] = html_print_label_input_block( + __('Cascade protection services'), + html_print_checkbox_switch('cps', $cps_val, ($cps >= 0), true) +); + +// Update GIS data. +if ((bool) $config['activate_gis'] === true) { + $tableAdvancedAgent->data['gis'][] = html_print_label_input_block( + __('Update new GIS data'), + html_print_checkbox_switch('update_gis_data', 1, ($new_agent === true), true) + ); +} + +// Agent Icons. +$tableAdvancedAgent->data['agent_icon'][] = html_print_label_input_block( + __('Agent icon'), + html_print_select( + $arraySelectIcon, + 'icon_path', + $icon_path, + 'changeIcons();', + __('None'), + '', + true, + false, + true, + 'w540px' + ).html_print_image( + $path_ok, + true, + [ + 'id' => 'icon_ok', + 'style' => 'display:'.$display_icons.';', + ] + ).html_print_image( + $path_bad, + true, + [ + 'id' => 'icon_bad', + 'style' => 'display:'.$display_icons.';', + ] + ).html_print_image( + $path_warning, + true, + [ + 'id' => 'icon_warning', + 'style' => 'display:'.$display_icons.';', + ] + ) ); -$table_adv_status .= '

    '.__('Disabled mode').'

    '; -$table_adv_status .= '
    '; // Url address. -if (enterprise_installed()) { - $table_adv_url = '

    '.__('Url address').'

    '; - $table_adv_url .= html_print_input_text( +if (enterprise_installed() === true) { + $urlAddressInput = html_print_input_text( 'url_description', $url_description, '', @@ -670,152 +792,131 @@ if (enterprise_installed()) { false, false, '', - '', + 'w540px', '', // Autocomplete. 'new-password' - ).'
    '; + ); } else { - $table_adv_url = '

    '.__('Url address').'

    '; - $table_adv_url .= html_print_input_text( + $urlAddressInput = html_print_input_text( 'url_description', $url_description, '', 45, 255, true - ).''; + ); } -$table_adv_quiet = '
    '; -$table_adv_quiet .= html_print_checkbox_switch('quiet', 1, $quiet, true); -$table_adv_quiet .= '

    '.__('Quiet').'

    '; -$table_adv_quiet .= '
    '; +$tableAdvancedAgent->data['url_description'][] = html_print_label_input_block( + __('URL Address'), + $urlAddressInput +); -$listIcons = gis_get_array_list_icons(); +// Agent status. +$tableAdvancedAgent->data['agent_status'][] = html_print_label_input_block( + __('Disabled mode'), + html_print_checkbox_switch( + 'disabled', + 1, + $disabled, + true + ) +); -$arraySelectIcon = []; -foreach ($listIcons as $index => $value) { - $arraySelectIcon[$index] = $index; +// Quiet mode. +$tableAdvancedAgent->data['agent_quiet'][] = html_print_label_input_block( + __('Quiet'), + html_print_checkbox_switch('quiet', 1, $quiet, true) +); + +// Remote configuration. +if ($new_agent === false && isset($filename) === true && file_exists($filename['md5']) === true) { + $remoteConfigurationElements = []; + $remoteConfigurationElements[] = html_print_input_text( + 'remote_file_timestamp', + date('F d Y H:i:s', fileatime($filename['md5'])), + '', + 0, + 100, + true, + true, + false, + '', + 'w540px' + ); + $remoteConfigurationElements[] = html_print_anchor( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&disk_conf_delete=1&id_agente='.$id_agente, + 'content' => html_print_image( + 'images/delete.svg', + true, + [ + 'border' => 0, + 'title' => __('Delete remote configuration file'), + 'class' => 'invert_filter after_input_icon', + ] + ), + ], + true + ); + + $tableAdvancedAgent->data['remote_configuration'][] = html_print_label_input_block( + __('Remote configuration'), + html_print_div( + [ + 'class' => 'flex-row-center', + 'content' => implode('', $remoteConfigurationElements), + ], + true + ) + ); } -$path = 'images/gis_map/icons/'; -// TODO set better method the path. -$table_adv_agent_icon = '

    '.__('Agent icon').'

    '; -if ($icon_path == '') { - $display_icons = 'none'; - // Hack to show no icon. Use any given image to fix not found image errors. - $path_without = 'images/spinner.gif'; - $path_default = 'images/spinner.gif'; - $path_ok = 'images/spinner.gif'; - $path_bad = 'images/spinner.gif'; - $path_warning = 'images/spinner.gif'; -} else { - $display_icons = ''; - $path_without = $path.$icon_path.'.default.png'; - $path_default = $path.$icon_path.'.default.png'; - $path_ok = $path.$icon_path.'.ok.png'; - $path_bad = $path.$icon_path.'.bad.png'; - $path_warning = $path.$icon_path.'.warning.png'; -} - -$table_adv_agent_icon .= html_print_select( - $arraySelectIcon, - 'icon_path', - $icon_path, - 'changeIcons();', - __('None'), - '', +// Safe operation mode. +$safeOperationElements = []; +$safeOperationElements[] = html_print_checkbox_switch( + 'safe_mode', + 1, + $safe_mode, true -).html_print_image( - $path_ok, - true, - [ - 'id' => 'icon_ok', - 'style' => 'display:'.$display_icons.';', - ] -).html_print_image( - $path_bad, - true, - [ - 'id' => 'icon_bad', - 'style' => 'display:'.$display_icons.';', - ] -).html_print_image( - $path_warning, - true, - [ - 'id' => 'icon_warning', - 'style' => 'display:'.$display_icons.';', - ] -).'
    '; +); +$safeOperationElements[] = html_print_select( + $safe_mode_modules, + 'safe_mode_module', + $safe_mode_module, + '', + '', + 0, + true +); -if ($config['activate_gis']) { - $table_adv_gis = '

    '.__('Update new GIS data:').'

    '; - if ($new_agent) { - $update_gis_data = true; - } +$tableAdvancedAgent->data['safe_operation'][] = html_print_label_input_block( + __('Safe operation mode'), + html_print_div( + [ + 'class' => 'flex-row-center', + 'content' => implode('', $safeOperationElements), + ], + true + ) +); - $table_adv_gis .= html_print_checkbox_switch('update_gis_data', 1, $update_gis_data, true).'No / Yes
    '; -} - - -if (enterprise_installed()) { - $advanced_div = '
    '; -} else { - $advanced_div = ''; - -$table_adv_options .= '
    '; -$table_adv_options .= $table_adv_parent; -$table_adv_options .= $table_adv_module_mode; -$table_adv_options .= $table_adv_cascade; - -if ($new_agent) { - // If agent is new, show custom id as old style format. - $table_adv_options .= $custom_id_div; -} - -$table_adv_options .= '
    '; - -$table_adv_options .= ' -
    - '.$table_adv_gis.$table_adv_agent_icon.$table_adv_url.$table_adv_quiet.$table_adv_status.$table_adv_remote.$table_adv_safe.' -
    '; - -if (enterprise_installed()) { - echo '
    '; +if (enterprise_installed() === true) { ui_toggle( - $table_adv_options, - __('Advanced options'), + html_print_table($tableAdvancedAgent, true), + ''.__('Advanced options').'', '', '', true, false, - 'white_box white_box_opened', - 'no-border flex' + 'white_box_content', + 'no-border white_table_graph' ); - echo '
    '; } -$table = new stdClass(); -$table->width = '100%'; -$table->class = 'custom_fields_table'; - -$table->head = [ - 0 => __('Click to display'), -]; -$table->class = 'info_table'; -$table->style = []; -$table->style[0] = 'font-weight: bold;'; -$table->data = []; -$table->rowstyle = []; +// Custom fields. +$customOutputData = ''; $fields = db_get_all_fields_in_table('tagent_custom_fields'); @@ -823,13 +924,8 @@ if ($fields === false) { $fields = []; } -$i = 0; foreach ($fields as $field) { - $id_custom_field = $field['id_field']; - - $data[0] = '
    '; - $data[0] .= ''.$field['name'].''; - $data[0] .= '
    '; + // Filling the data. $combo = []; $combo = $field['combo_values']; $combo = explode(',', $combo); @@ -851,15 +947,8 @@ foreach ($fields as $field) { $custom_value = ''; } - $table->rowstyle[$i] = 'cursor: pointer;user-select: none;'; - if (!empty($custom_value)) { - $table->rowstyle[($i + 1)] = 'display: table-row;'; - } else { - $table->rowstyle[($i + 1)] = 'display: none;'; - } - - if ($field['is_password_type']) { - $data_field[1] = html_print_input_text_extended( + if ((bool) $field['is_password_type'] === true) { + $customContent = html_print_input_text_extended( 'customvalue_'.$field['id_field'], $custom_value, 'customvalue_'.$field['id_field'], @@ -887,7 +976,7 @@ foreach ($fields as $field) { 2, 65, $link_text, - 'class="min-height-30px', + 'class="min-height-30px w100p"', true ); $data_field[1] .= '
    '; @@ -898,22 +987,22 @@ foreach ($fields as $field) { 2, 65, $link_url, - 'class="min-height-30px', + 'class="min-height-30px w100p"', true ); } else { - $data_field[1] = html_print_textarea( + $customContent = html_print_textarea( 'customvalue_'.$field['id_field'], 2, 65, $custom_value, - 'class="min-height-30px', + 'class="min-height-30px w100p"', true ); } - if ($field['combo_values'] !== '') { - $data_field[1] = html_print_input( + if (empty($field['combo_values']) === false) { + $customContent = html_print_input( [ 'type' => 'select_search', 'fields' => $combo_values, @@ -929,61 +1018,32 @@ foreach ($fields as $field) { ); }; - $table->rowid[] = 'name_field-'.$id_custom_field; - $table->data[] = $data; - - $table->rowid[] = 'field-'.$id_custom_field; - $table->data[] = $data_field; - $i += 2; + $customOutputData .= ui_toggle( + html_print_div( + [ 'content' => $customContent ], + true + ), + $field['name'], + $field['name'], + 'custom_field_toggle_'.$field['id_field'], + true, + true, + ); } -if (enterprise_installed()) { - if (!empty($fields)) { - echo '
    '; - ui_toggle( - html_print_table($table, true), - __('Custom fields'), - '', - '', - true, - false, - 'white_box white_box_opened', - 'no-border' - ); - echo '
    '; - } -} else { - echo '
    '; +if (empty($fields) === false) { ui_toggle( - $table_adv_options, - __('Advanced options'), + $customOutputData, + ''.__('Custom fields').'', '', '', true, false, - 'white_box white_box_opened', - 'no-border flex' + 'white_box white_box_opened white_table_graph_fixed', + 'no-border custom_fields_elements' ); - if (!empty($fields)) { - ui_toggle( - html_print_table($table, true), - __('Custom fields'), - '', - '', - true, - false, - 'white_box white_box_opened', - 'no-border' - ); - } - - echo '
    '; - - echo '
    '; } -echo '
    '; - // The context help about the learning mode. if ($modo == 0) { echo ""; @@ -994,28 +1054,51 @@ if ($modo == 0) { echo clippy_context_help('modules_not_learning_mode'); echo ''; - -if ($id_agente) { - echo '
    '; - html_print_submit_button( +if ($new_agent === false) { + $actionButtons = html_print_submit_button( __('Update'), 'updbutton', false, - 'class="sub upd"' + [ 'icon' => 'update'], + true ); - html_print_input_hidden('update_agent', 1); - html_print_input_hidden('id_agente', $id_agente); + $actionButtons .= html_print_input_hidden('update_agent', 1); + $actionButtons .= html_print_input_hidden('id_agente', $id_agente); + + if (is_management_allowed() === true) { + $actionButtons .= html_print_button( + __('Delete agent'), + 'deleteAgent', + false, + 'deleteAgentDialog('.$id_agente.')', + [ + 'icon' => 'delete', + 'mode' => 'secondary dialog_opener', + ], + true + ); + } } else { - html_print_submit_button( + $actionButtons = html_print_input_hidden('create_agent', 1); + $actionButtons .= html_print_submit_button( __('Create'), 'crtbutton', false, - 'class="sub wand"' + [ 'icon' => 'wand'], + true ); - html_print_input_hidden('create_agent', 1); } -echo '
    '; +$actionButtons .= html_print_go_back_button( + 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente', + ['button_class' => ''], + true +); + +html_print_action_buttons($actionButtons, ['type' => 'form_action']); + +echo '
    '; +echo ''; ui_require_jquery_file('pandora.controls'); ui_require_jquery_file('ajaxqueue'); @@ -1035,6 +1118,15 @@ ui_require_jquery_file('bgiframe'); } } + function deleteAgentDialog($idAgente) { + confirmDialog({ + title: "", + message: "", + onAccept: function() { + window.location.assign('index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente='+$idAgente); + } + }); + } //Use this function for change 3 icons when change the selectbox function changeIcons() { diff --git a/pandora_console/godmode/agentes/agent_template.php b/pandora_console/godmode/agentes/agent_template.php index 933b37fbce..ea5c8176c8 100644 --- a/pandora_console/godmode/agentes/agent_template.php +++ b/pandora_console/godmode/agentes/agent_template.php @@ -1,20 +1,35 @@ $id_agente, 'id_tipo_modulo' => $row2['type'], @@ -113,14 +129,14 @@ if (isset($_POST['template_id'])) { $name = $row2['name']; - // Put tags in array if the component has to add them later - if (!empty($row2['tags'])) { + // Put tags in array if the component has to add them later. + if (empty($row2['tags']) === false) { $tags = explode(',', $row2['tags']); } else { $tags = []; } - // Check if this module exists in the agent + // Check if this module exists in the agent. $module_name_check = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['delete_pending' => 0, 'nombre' => $name, 'id_agente' => $id_agente]); if ($module_name_check !== false) { @@ -132,13 +148,13 @@ if (isset($_POST['template_id'])) { if ($id_agente_modulo === false) { $error_count++; } else { - if (!empty($tags)) { - // Creating tags + if (empty($tags) === false) { + // Creating tags. $tag_ids = []; foreach ($tags as $tag_name) { $tag_id = tags_get_id($tag_name); - // If tag exists in the system we store to create it + // If tag exists in the system we store to create it. $tag_ids[] = $tag_id; } @@ -152,7 +168,7 @@ if (isset($_POST['template_id'])) { } if ($error_count > 0) { - if (empty($modules_already_added)) { + if (empty($modules_already_added) === true) { ui_print_error_message(__('Error adding modules').sprintf(' (%s)', $error_count)); } else { ui_print_error_message(__('Error adding modules. The following errors already exists: ').implode(', ', $modules_already_added)); @@ -168,8 +184,6 @@ if (isset($_POST['template_id'])) { // ========================== // TEMPLATE ASSIGMENT FORM // ========================== -echo '
    '; - $nps = db_get_all_fields_in_table('tnetwork_profile', 'name'); if ($nps === false) { $nps = []; @@ -180,44 +194,45 @@ foreach ($nps as $row) { $select[$row['id_np']] = $row['name']; } -echo ''; -echo "'; -echo ''; -echo ''; -echo ''; -echo '
    "; -html_print_select($select, 'template_id', '', '', '', 0, false, false, true, '', false, 'max-width: 200px !important'); -echo ''; -html_print_submit_button(__('Assign'), 'crt', false, 'class="sub next mgn_tp_0"'); -echo '
    '; -echo ''; +$filterTable = new stdClass(); +$filterTable->width = '100%'; +$filterTable->class = 'fixed_filter_bar'; +$filterTable->data = []; +$filterTable->data[0][0] = __('Module templates'); +$filterTable->data[1][0] = html_print_select($select, 'template_id', '', '', '', 0, true, false, true, '', false, 'max-width: 200px !important'); +$filterTable->data[1][1] = html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Assign'), + 'crt', + false, + [ + 'icon' => 'wand', + 'mode' => 'secondary mini', + ], + true + ), + ], + true +); + +$outputFilterTable = '
    '; +$outputFilterTable .= html_print_table($filterTable, true); +$outputFilterTable .= '
    '; + +echo $outputFilterTable; // ========================== // MODULE VISUALIZATION TABLE // ========================== -switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - $sql = sprintf( - 'SELECT * - FROM tagente_modulo - WHERE id_agente = %d AND delete_pending = false - ORDER BY id_module_group, nombre', - $id_agente - ); - break; - - case 'oracle': - $sql = sprintf( - 'SELECT * - FROM tagente_modulo - WHERE id_agente = %d - AND (delete_pending <> 1 AND delete_pending IS NOT NULL) - ORDER BY id_module_group, dbms_lob.substr(nombre,4000,1)', - $id_agente - ); - break; -} +$sql = sprintf( + 'SELECT * + FROM tagente_modulo + WHERE id_agente = %d AND delete_pending = false + ORDER BY id_module_group, nombre', + $id_agente +); $result = db_get_all_rows_sql($sql); if ($result === false) { @@ -233,10 +248,10 @@ $table->head = []; $table->data = []; $table->align = []; -$table->head[0] = __('Module name'); -$table->head[1] = __('Type'); -$table->head[2] = __('Description'); -$table->head[3] = __('Action'); +$table->head[0] = ''.__('Module name').''; +$table->head[1] = ''.__('Type').''; +$table->head[2] = ''.__('Description').''; +$table->head[3] = ''.__('Action').''; $table->align[1] = 'left'; $table->align[3] = 'left'; @@ -245,27 +260,43 @@ $table->size[1] = '5%'; $table->size[3] = '8%'; foreach ($result as $row) { + $table->cellclass[][3] = 'table_action_buttons'; + $data = []; $data[0] = ''.$row['nombre']; - if ($row['id_tipo_modulo'] > 0) { - $data[1] = html_print_image('images/'.modules_show_icon_type($row['id_tipo_modulo']), true, ['border' => '0', 'class' => 'invert_filter']); - } else { - $data[1] = ''; - } - + $data[1] = ($row['id_tipo_modulo'] > 0) ? ui_print_moduletype_icon($row['id_tipo_modulo'], true, false, true) : ''; $data[2] = mb_substr($row['descripcion'], 0, 60); - - $table->cellclass[][3] = 'action_buttons'; - $data[3] = ''.html_print_image('images/cross.png', true, ['class' => 'invert_filter', 'border' => '0', 'alt' => __('Delete'), 'onclick' => "if (!confirm('".__('Are you sure?')."')) return false;"]).''; - $data[3] .= ''.html_print_image('images/config.png', true, ['class' => 'invert_filter', 'border' => '0', 'alt' => __('Update')]).''; + $data[3] = html_print_menu_button( + [ + 'href' => 'index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&tab=template&id_agente='.$id_agente.'&delete_module='.$row['id_agente_modulo'], + 'image' => 'images/delete.svg', + 'title' => __('Delete'), + 'onClick' => 'if (!confirm(\''.__('Are you sure?').'\')) return false;', + ], + true + ); + $data[3] .= html_print_menu_button( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&edit_module=1&id_agent_module='.$row['id_agente_modulo'], + 'image' => 'images/edit.svg', + 'title' => __('Edit'), + ], + true + ); array_push($table->data, $data); } -if (!empty($table->data)) { - html_print_table($table); - unset($table); +if (empty($table->data) === false) { + $output = html_print_table($table, true); } else { - ui_print_empty_data(__('No modules')); + $output = ui_print_empty_data(__('No modules'), '', true); } + +html_print_div( + [ + 'class' => 'datatable_form', + 'content' => $output, + ] +); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index ab01bbf47f..a5a1445341 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -295,7 +295,6 @@ if ($create_agent) { 'fixed_ip' => $fixed_ip, ] ); - enterprise_hook('update_agent', [$id_agente]); } else { $id_agente = false; } @@ -377,94 +376,97 @@ $img_style = [ if ($id_agente) { // View tab. - $viewtab['text'] = ''.html_print_image( - 'images/eye.png', - true, + $viewtab['text'] = html_print_anchor( [ - 'title' => __('View'), - 'class' => 'invert_filter', - ] - ).''; - - if ($tab == 'view') { - $viewtab['active'] = true; - } else { - $viewtab['active'] = false; - } + 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente, + 'content' => html_print_image( + 'images/enable.svg', + true, + [ + 'title' => __('View'), + 'class' => 'invert_filter main_menu_icon', + ] + ), + ], + true + ); + $viewtab['active'] = ($tab === 'view'); $viewtab['operation'] = 1; // Main tab. - $maintab['text'] = ''.html_print_image( - 'images/gm_setup.png', - true, + $maintab['text'] = html_print_anchor( [ - 'title' => __('Setup'), - 'class' => 'invert_filter', - ] - ).''; - if ($tab == 'main') { - $maintab['active'] = true; - } else { - $maintab['active'] = false; - } + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$id_agente, + 'content' => html_print_image( + 'images/configuration@svg.svg', + true, + [ + 'title' => __('Setup'), + 'class' => 'invert_filter main_menu_icon', + ] + ), + ], + true + ); + + $maintab['active'] = ($tab === 'main'); // Module tab. - $moduletab['text'] = ''.html_print_image( - 'images/gm_modules.png', - true, + $moduletab['text'] = html_print_anchor( [ - 'title' => __('Modules'), - 'class' => 'invert_filter', - ] - ).''; + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente, + 'content' => html_print_image( + 'images/modules@svg.svg', + true, + [ + 'title' => __('Modules'), + 'class' => 'invert_filter main_menu_icon', + ] + ), + ], + true + ); - if ($tab == 'module') { - $moduletab['active'] = true; - } else { - $moduletab['active'] = false; - } + $moduletab['active'] = ($tab === 'module'); // Alert tab. - $alerttab['text'] = ''.html_print_image( - 'images/gm_alerts.png', - true, + $alerttab['text'] = html_print_anchor( [ - 'title' => __('Alerts'), - 'class' => 'invert_filter', - ] - ).''; + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$id_agente, + 'content' => html_print_image( + 'images/alert@svg.svg', + true, + [ + 'title' => __('Alerts'), + 'class' => 'invert_filter main_menu_icon', + ] + ), + ], + true + ); - if ($tab == 'alert') { - $alerttab['active'] = true; - } else { - $alerttab['active'] = false; - } + $alerttab['active'] = ($tab === 'alert'); // Template tab. - $templatetab['text'] = ''.html_print_image( - 'images/templates.png', - true, + $templatetab['text'] = html_print_menu_button( [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=template&id_agente='.$id_agente, + 'image' => 'images/modules-group@svg.svg', 'title' => __('Module templates'), - 'class' => 'invert_filter', - ] - ).''; - - if ($tab == 'template') { - $templatetab['active'] = true; - } else { - $templatetab['active'] = false; - } + ], + true + ); + $templatetab['active'] = ($tab === 'template'); // Inventory. $inventorytab['text'] = ''.html_print_image( - 'images/page_white_text.png', + 'images/hardware-software-component@svg.svg', true, [ 'title' => __('Inventory'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ).''; @@ -474,11 +476,6 @@ if ($id_agente) { $inventorytab['active'] = false; } - if ($inventorytab == -1) { - $inventorytab = ''; - } - - $has_remote_conf = enterprise_hook( 'config_agents_has_remote_configuration', [$id_agente] @@ -490,7 +487,7 @@ if ($id_agente) { if ($has_remote_conf === true) { // Plugins. $pluginstab = enterprise_hook('plugins_tab'); - if ($pluginstab == -1) { + if ($pluginstab === ENTERPRISE_NOT_HOOK) { $pluginstab = ''; } } else { @@ -500,60 +497,60 @@ if ($id_agente) { // Collection. if ((int) $config['license_nms'] !== 1) { $collectiontab = enterprise_hook('collection_tab'); - - if ($collectiontab == -1) { + if ($collectiontab === ENTERPRISE_NOT_HOOK) { $collectiontab = ''; } + } else { + $collectiontab = ''; } // NetworkConfigManager tab. $ncm_tab = enterprise_hook('networkconfigmanager_tab'); - if ($ncm_tab === ENTERPRISE_NOT_HOOK) { $ncm_tab = ''; } // Group tab. - $grouptab['text'] = ''.html_print_image( - 'images/group.png', - true, + $grouptab['text'] = html_print_menu_button( [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&ag_group='.$group, + 'image' => 'images/groups@svg.svg', 'title' => __('Group'), - 'class' => 'invert_filter', - ] - ).''; + ], + true + ); $grouptab['active'] = false; $gistab = []; - // GIS tab. - if ($config['activate_gis']) { - $gistab['text'] = ''.html_print_image( - 'images/gm_gis.png', - true, - [ - 'title' => __('GIS data'), - 'class' => 'invert_filter', - ] - ).''; + // TODO. OVERRIDE. + $config['activate_gis'] = true; - if ($tab == 'gis') { - $gistab['active'] = true; - } else { - $gistab['active'] = false; - } + // GIS tab. + if ((bool) $config['activate_gis'] === true) { + $gistab['text'] = html_print_menu_button( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=gis&id_agente='.$id_agente, + 'image' => 'images/poi@svg.svg', + 'title' => __('GIS data'), + ], + true + ); + + $gistab['active'] = ($tab === 'gis'); } // Agent wizard tab. - $agent_wizard['text'] = ''.html_print_image( - 'images/wand_agent.png', - true, + $agent_wizard['text'] = html_print_menu_button( [ + 'href' => 'javascript:', + 'class' => 'agent_wizard_tab', + 'image' => 'images/wizard@svg.svg', 'title' => __('Agent wizard'), - 'class' => 'invert_filter', - ] - ).''; + ], + true + ); // Hidden subtab layer. $agent_wizard['sub_menu'] = '
    '; } -echo '
    '; +echo '
    '; +echo ''; if (!$id) { $user_id_update_view = $user_id; @@ -1637,71 +1703,139 @@ if (!$id) { if (is_metaconsole() === true) { $access_or_pagination = $meta_access; -} else { - $access_or_pagination = $size_pagination; -} + if ($id != '' && !$is_err) { + $div_user_info = ' + '; + } else { + $div_user_info = ' + '; + } -if ($id != '' && !$is_err) { - $div_user_info = ' - '; -} else { - $div_user_info = ' - '; -} + echo '
    +
    + +

    Extra info

    '.$email.$phone.$not_login.$local_user.$session_time.'
    +
    +
    +
    '.$language.$access_or_pagination.$skin.$default_event_filter.$double_authentication.'
    + +
    '.$timezone; -echo '
    -
    - -

    Extra info

    '.$email.$phone.$not_login.$local_user.$session_time.'
    -
    -
    -
    '.$language.$access_or_pagination.$skin.$home_screen.$default_event_filter.$double_authentication.'
    - -
    '.$timezone; -if (is_metaconsole() === false) { - echo '
    - - - '.$area_data_timezone_polys.$area_data_timezone_rects.' -
    '; -} else { echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_access_node; -} -echo '
    -
    + $autorefresh_show = '

    '._('Autorefresh').ui_print_help_tip( + __('This will activate autorefresh in selected pages'), + true + ).'

    '; + $select_out = html_print_select( + $autorefresh_list_out, + 'autorefresh_list_out[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%' + ); + $arrows = ' '; + $select_in = html_print_select( + $autorefresh_list, + 'autorefresh_list[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%' + ); -
    -
    '.$comments.'
    -
    '; + $table_ichanges = ''; -html_print_div( - [ - 'class' => 'user_edit_third_row white_box', - 'content' => html_print_div( + $autorefresh_show .= $table_ichanges; + + // Time autorefresh. + $times = get_refresh_time_array(); + $time_autorefresh = '

    '.__('Time autorefresh'); + $time_autorefresh .= ui_print_help_tip( + __('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'), + true + ).'

    '; + $time_autorefresh .= html_print_select( + $times, + 'time_autorefresh', + $user_info['time_autorefresh'], + '', + '', + '', + true, + false, + false + ).'
    '; + + + echo '
    +
    +
    '.$autorefresh_show.$time_autorefresh.'
    +
    +
    '.$comments.'
    +
    '; + + if (empty($ehorus) === false) { + html_print_div( [ - 'class' => 'edit_user_allowed_ip', - 'content' => $allowedIP, + 'class' => 'user_edit_third_row white_box', + 'content' => $ehorus, ], true - ), - ] -); - -if (!empty($ehorus)) { - echo '
    '.$ehorus.'
    '; + ); + } +} else { + $access_or_pagination = $size_pagination; + // WIP: Only for node. + include_once 'user_management.php'; } -echo '
    '; -echo '
    '; -if ($config['admin_can_add_user']) { +if ((bool) $config['admin_can_add_user'] === true) { html_print_csrf_hidden(); - if ($new_user) { - html_print_input_hidden('create_user', 1); - } else { - html_print_input_hidden('update_user', 1); - } + html_print_input_hidden((($new_user === true) ? 'create_user' : 'update_user'), 1); } echo '
    '; @@ -1709,42 +1843,49 @@ if ($new_user === true) { html_print_input_hidden('json_profile', $json_profile); } +echo '
    '; echo ''; +echo '
    '; -if ($is_err === true && $new_user === true) { - profile_print_profile_table($id, io_safe_output($json_profile), false, true); -} else { - profile_print_profile_table($id, io_safe_output($json_profile)); -} +$actionButtons = []; -echo '
    '; - -echo '
    '; -if ($config['admin_can_add_user']) { - if ($new_user) { - html_print_submit_button( - __('Create'), - 'crtbutton', - false, - 'class="sub wand" form="user_profile_form"' - ); +if ((bool) $config['admin_can_add_user'] === true) { + if ($new_user === true) { + $submitButtonCaption = __('Create'); + $submitButtonName = 'crtbutton'; + $submitButtonIcon = 'wand'; } else { - html_print_submit_button( - __('Update'), - 'uptbutton', - false, - 'class="sub upd" form="user_profile_form"' - ); + $submitButtonCaption = __('Update'); + $submitButtonName = 'uptbutton'; + $submitButtonIcon = 'update'; } + + $actionButtons[] = html_print_submit_button( + $submitButtonCaption, + $submitButtonName, + false, + [ + 'icon' => $submitButtonIcon, + 'form' => 'user_profile_form', + ], + true + ); } -echo '
    '; +if ((bool) check_acl($config['id_user'], 0, 'UM') === true) { + $actionButtons[] = html_print_go_back_button( + ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/user_list&tab=user&pure=0'), + ['button_class' => ''], + true + ); +} +html_print_action_buttons(implode('', $actionButtons), ['type' => 'form_action']); echo ''; -enterprise_hook('close_meta_frame'); +// This is an image generated for JS. $delete_image = html_print_input_image( 'del', 'images/cross.png', @@ -1757,7 +1898,7 @@ $delete_image = html_print_input_image( ] ); -if (!is_metaconsole()) { +if (is_metaconsole() === false) { ?> + $dialogContainer + .empty() + .append(message) + .append($button); + + var request; + + $button.click(function(e) { + e.preventDefault(); + + $dialogContainer.html($loadingSpinner); + + // Deactivate the double auth + request = $.ajax({ + url: "", + type: 'POST', + dataType: 'json', + data: { + page: 'include/ajax/double_auth.ajax', + id_user: userID, + FA_forced: 1, + deactivate_double_auth: 1 + }, + complete: function(xhr, textStatus) { + + }, + success: function(data, textStatus, xhr) { + if (data === -1) { + $dialogContainer.html("
    '.__('Authentication error').'
    '; ?>"); + } else if (data) { + $dialogContainer.html("
    '.__('The double autentication was deactivated successfully').'
    '; ?>"); + $("input#checkbox-double_auth").prop("checked", false); + } else { + $dialogContainer.html("
    '.__('There was an error deactivating the double autentication').'
    '; ?>"); + } + }, + error: function(xhr, textStatus, errorThrown) { + $dialogContainer.html("
    '.__('There was an error deactivating the double autentication').'
    '; ?>"); + } + }); + }); + + + $("div#dialog-double_auth").dialog({ + resizable: true, + draggable: true, + modal: true, + title: "", + overlay: { + opacity: 0.5, + background: "black" + }, + width: 300, + height: 150, + close: function(event, ui) { + // Abort the ajax request + if (typeof request != 'undefined') + request.abort(); + // Remove the contained html + $dialogContainer.empty(); + + } + }) + .show(); + } + + + /* ]]> */ + \ No newline at end of file diff --git a/pandora_console/godmode/users/profile_list.php b/pandora_console/godmode/users/profile_list.php index 7ce7c82cc0..e47e989d0f 100644 --- a/pandora_console/godmode/users/profile_list.php +++ b/pandora_console/godmode/users/profile_list.php @@ -31,8 +31,6 @@ global $config; check_login(); -enterprise_hook('open_meta_frame'); - require_once $config['homedir'].'/include/functions_profile.php'; require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_groups.php'; @@ -57,22 +55,22 @@ if (is_metaconsole() === false) { 'user' => [ 'active' => false, 'text' => ''.html_print_image( - 'images/gm_users.png', + 'images/user.svg', true, [ 'title' => __('User management'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_user', ] ).'', ], 'profile' => [ 'active' => false, 'text' => ''.html_print_image( - 'images/profiles.png', + 'images/suitcase@svg.svg', true, [ 'title' => __('Profile management'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_user', ] ).'', ], @@ -80,13 +78,24 @@ if (is_metaconsole() === false) { $buttons[$tab]['active'] = true; - ui_print_page_header( - __('User management').' » '.__('Profiles defined on %s', get_product_name()), - 'images/gm_users.png', + // Header. + ui_print_standard_header( + __('User Profile management'), + 'images/user.svg', false, 'profile_tab', - true, - $buttons + false, + $buttons, + [ + [ + 'link' => '', + 'label' => __('Profiles'), + ], + [ + 'link' => '', + 'label' => __('Manage users'), + ], + ] ); $sec = 'gusuarios'; } else { @@ -312,8 +321,8 @@ if ($is_management_allowed === true && $create_profile === true) { $table = new stdClass(); $table->cellpadding = 0; $table->cellspacing = 0; +$table->styleTable = 'margin: 10px'; $table->class = 'info_table profile_list'; -$table->width = '100%'; $table->head = []; $table->data = []; @@ -322,36 +331,37 @@ $table->align = []; $table->head['profiles'] = __('Profiles'); -$table->head['AR'] = 'AR'; -$table->head['AW'] = 'AW'; -$table->head['AD'] = 'AD'; -$table->head['LW'] = 'LW'; -$table->head['LM'] = 'LM'; -$table->head['UM'] = 'UM'; -$table->head['DM'] = 'DM'; -$table->head['ER'] = 'ER'; -$table->head['EW'] = 'EW'; -$table->head['EM'] = 'EM'; -$table->head['RR'] = 'RR'; -$table->head['RW'] = 'RW'; -$table->head['RM'] = 'RM'; -$table->head['MR'] = 'MR'; -$table->head['MW'] = 'MW'; -$table->head['MM'] = 'MM'; -$table->head['VR'] = 'VR'; -$table->head['VW'] = 'VW'; -$table->head['VM'] = 'VM'; -$table->head['NR'] = 'NR'; -$table->head['NW'] = 'NW'; -$table->head['NM'] = 'NM'; -$table->head['PM'] = 'PM'; +$table->head['AR'] = ''.'AR'.''; +$table->head['AW'] = ''.'AW'.''; +$table->head['AD'] = ''.'AD'.''; +$table->head['LW'] = ''.'LW'.''; +$table->head['LM'] = ''.'LM'.''; +$table->head['UM'] = ''.'UM'.''; +$table->head['DM'] = ''.'DM'.''; +$table->head['ER'] = ''.'ER'.''; +$table->head['EW'] = ''.'EW'.''; +$table->head['EM'] = ''.'EM'.''; +$table->head['RR'] = ''.'RR'.''; +$table->head['RW'] = ''.'RW'.''; +$table->head['RM'] = ''.'RM'.''; +$table->head['MR'] = ''.'MR'.''; +$table->head['MW'] = ''.'MW'.''; +$table->head['MM'] = ''.'MM'.''; +$table->head['VR'] = ''.'VR'.''; +$table->head['VW'] = ''.'VW'.''; +$table->head['VM'] = ''.'VM'.''; +$table->head['NR'] = ''.'NR'.''; +$table->head['NW'] = ''.'NW'.''; +$table->head['NM'] = ''.'NM'.''; +$table->head['PM'] = ''.'PM'.''; + if ($is_management_allowed === true) { $table->head['operations'] = ''.__('Op.').''; } $table->align = array_fill(1, 11, 'center'); -$table->size['profiles'] = '200px'; +$table->size['profiles'] = '150px'; $table->size['AR'] = '10px'; $table->size['AW'] = '10px'; $table->size['AD'] = '10px'; @@ -376,7 +386,7 @@ $table->size['NW'] = '10px'; $table->size['NM'] = '10px'; $table->size['PM'] = '10px'; if ($is_management_allowed === true) { - $table->size['operations'] = '5%'; + $table->size['operations'] = '6%'; } $profiles = db_get_all_rows_in_table('tperfil'); @@ -385,11 +395,11 @@ if ($profiles === false) { } $img = html_print_image( - 'images/ok.png', + 'images/validate.svg', true, [ 'border' => 0, - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', ] ); @@ -425,25 +435,32 @@ foreach ($profiles as $profile) { $data['NW'] = (empty($profile['network_config_edit']) === false) ? $img : ''; $data['NM'] = (empty($profile['network_config_management']) === false) ? $img : ''; $data['PM'] = (empty($profile['pandora_management']) === false) ? $img : ''; - $table->cellclass[]['operations'] = 'action_buttons'; + $table->cellclass[]['operations'] = 'table_action_buttons'; if ($is_management_allowed === true) { $data['operations'] = ''.html_print_image( - 'images/config.png', + 'images/edit.svg', true, [ 'title' => __('Edit'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', ] ).''; - if (check_acl($config['id_user'], 0, 'PM') || users_is_admin()) { - $data['operations'] .= ''.html_print_image( - 'images/cross.png', - true, + if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) users_is_admin() === true) { + $data['operations'] .= html_print_anchor( [ - 'title' => __('Delete'), - 'class' => 'invert_filter', - ] - ).''; + 'href' => 'index.php?sec='.$sec.'&sec2=godmode/users/profile_list&delete_profile=1&id='.$profile['id_perfil'].'&pure='.$pure, + 'onClick' => 'if (!confirm(\' '.__('Are you sure?').'\')) return false;', + 'content' => html_print_image( + 'images/delete.svg', + true, + [ + 'title' => __('Delete'), + 'class' => 'invert_filter main_menu_icon', + ] + ), + ], + true + ); } } @@ -458,13 +475,21 @@ if (isset($data) === true) { if ($is_management_allowed === true) { echo '
    '; - echo '
    '; html_print_input_hidden('new_profile', 1); - html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"'); - echo '
    '; + html_print_action_buttons( + html_print_submit_button( + __('Create profile'), + 'crt', + false, + [ 'icon' => 'next' ], + true + ), + [ + 'type' => 'data_table', + 'class' => 'fixed_action_buttons', + ] + ); echo '
    '; } unset($table); - -enterprise_hook('close_meta_frame'); diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 85e713bed0..e4fe4225fa 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.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 @@ -132,8 +132,6 @@ if (is_ajax()) { } } -enterprise_hook('open_meta_frame'); - $sortField = get_parameter('sort_field'); $sort = get_parameter('sort', 'none'); $tab = get_parameter('tab', 'user'); @@ -247,22 +245,22 @@ if (is_metaconsole() === true) { 'user' => [ 'active' => false, 'text' => ''.html_print_image( - 'images/gm_users.png', + 'images/user.svg', true, [ 'title' => __('User management'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', ] ).'', ], 'profile' => [ 'active' => false, 'text' => ''.html_print_image( - 'images/profiles.png', + 'images/suitcase@svg.svg', true, [ 'title' => __('Profile management'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', ] ).'', ], @@ -272,11 +270,11 @@ if (is_metaconsole() === true) { 'user' => [ 'active' => false, 'text' => ''.html_print_image( - 'images/gm_users.png', + 'images/user.svg', true, [ 'title' => __('User management'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', ] ).'', ], @@ -285,13 +283,24 @@ if (is_metaconsole() === true) { $buttons[$tab]['active'] = true; - ui_print_page_header( - __('User management').' » '.__('Users defined on %s', get_product_name()), - 'images/gm_users.png', + // Header. + ui_print_standard_header( + __('Users management'), + 'images/user.svg', false, '', - true, - $buttons + false, + $buttons, + [ + [ + 'link' => '', + 'label' => __('Profiles'), + ], + [ + 'link' => '', + 'label' => __('Manage users'), + ], + ] ); $sec = 'gusuarios'; @@ -326,8 +335,11 @@ if ($delete_user === true) { ); if (isset($private_dashboards) === true) { - db_process_sql_delete('tdashboard', ['id_user' => $id_user]); - header('Refresh:1'); + $dashboardRemoveResult = db_process_sql_delete('tdashboard', ['id_user' => $id_user]); + // Refresh the view when delete private dashboards. For review. + if ($dashboardRemoveResult === false || (int) $dashboardRemoveResult > 0) { + header('Refresh:1'); + } } $result = delete_user($id_user); @@ -449,12 +461,14 @@ if (($filter_group == 0) && ($filter_search == '')) { $search = false; } -$table = new stdClass(); -$table->width = '100%'; -$table->class = 'databox filters'; -$table->rowclass[0] = ''; -$table->data[0][0] = ''.__('Group').''; -$table->data[0][1] = html_print_select_groups( +$filterTable = new stdClass(); +$filterTable->width = '100%'; +$filterTable->class = 'fixed_filter_bar'; +$filterTable->rowclass[0] = ''; +$filterTable->cellstyle[0][0] = 'width:0'; +$filterTable->cellstyle[0][1] = 'width:0'; +$filterTable->data[0][0] = __('Group'); +$filterTable->data[1][0] = html_print_select_groups( false, 'AR', true, @@ -465,8 +479,8 @@ $table->data[0][1] = html_print_select_groups( 0, true ); -$table->data[0][2] = ''.__('Search').''.ui_print_help_tip(__('Search by username, fullname or email'), true); -$table->data[0][3] = html_print_input_text( +$filterTable->data[0][1] = __('Search').ui_print_help_tip(__('Search by username, fullname or email'), true); +$filterTable->data[1][1] = html_print_input_text( 'filter_search', $filter_search, __('Search by username, fullname or email'), @@ -474,11 +488,16 @@ $table->data[0][3] = html_print_input_text( 90, true ); -$table->data[0][4] = html_print_submit_button( +$filterTable->cellstyle[1][2] = 'vertical-align: bottom'; +$filterTable->data[1][2] = html_print_submit_button( __('Search'), 'search', false, - ['class' => 'sub search'], + [ + 'icon' => 'search', + 'class' => 'float-right', + 'mode' => 'secondary mini', + ], true ); @@ -503,22 +522,16 @@ if (is_metaconsole() === false && is_management_allowed() === false) { if (is_metaconsole() === true) { - $table->width = '96%'; + $filterTable->width = '96%'; $form_filter = "
    "; - $form_filter .= html_print_table($table, true); + $form_filter .= html_print_table($filterTable, true); $form_filter .= '
    '; ui_toggle($form_filter, __('Show Options')); } else { $form_filter = "
    "; - $form_filter .= html_print_table($table, true); + $form_filter .= html_print_table($filterTable, true); $form_filter .= '
    '; - ui_toggle( - $form_filter, - __('Users control filter'), - __('Toggle filter(s)'), - '', - !$search - ); + echo $form_filter; } // Urls to sort the table. @@ -533,8 +546,9 @@ $url_down_last = '?sec='.$sec.'&sec2=godmode/users/user_list&sort_field=last_con $table = new stdClass(); $table->cellpadding = 0; $table->cellspacing = 0; -$table->width = '100%'; -$table->class = 'info_table'; +$table->class = 'info_table tactical_table'; +$table->id = 'user_list'; +$table->styleTable = 'margin: 0 10px'; $table->head = []; $table->data = []; @@ -542,15 +556,18 @@ $table->align = []; $table->size = []; $table->valign = []; -$table->head[0] = __('User ID').ui_get_sorting_arrows($url_up_id, $url_down_id, $selectUserIDUp, $selectUserIDDown); -$table->head[1] = __('Name').ui_get_sorting_arrows($url_up_name, $url_down_name, $selectFullnameUp, $selectFullnameDown); -$table->head[2] = __('Last contact').ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastConnectUp, $selectLastConnectDown); +$table->head[0] = ''.__('User ID').''; +$table->head[0] .= ui_get_sorting_arrows($url_up_id, $url_down_id, $selectUserIDUp, $selectUserIDDown); +$table->head[1] = ''.__('Name').''; +$table->head[1] .= ui_get_sorting_arrows($url_up_name, $url_down_name, $selectFullnameUp, $selectFullnameDown); +$table->head[2] = ''.__('Last contact').''; +$table->head[2] .= ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastConnectUp, $selectLastConnectDown); -$table->head[3] = __('Admin'); -$table->head[4] = __('Profile / Group'); -$table->head[5] = __('Description'); +$table->head[3] = ''.__('Admin').''; +$table->head[4] = ''.__('Profile / Group').''; +$table->head[5] = ''.__('Description').''; if ($is_management_allowed === true) { - $table->head[6] = ''.__('Op.').''; + $table->head[6] = ''.__('Actions').''; } if (is_metaconsole() === false) { @@ -585,7 +602,7 @@ if ($user_is_admin) { } else { $group_um = users_get_groups_UM($config['id_user']); // 0 is the group 'all'. - if (isset($group_um[0])) { + if (isset($group_um[0]) === true) { $info1 = get_users($order); } else { foreach ($group_um as $group => $value) { @@ -642,9 +659,6 @@ foreach ($info1 as $user_id => $user_info) { $info = $info1; -// Prepare pagination. -ui_pagination(count($info)); - $offset = (int) get_parameter('offset'); $limit = (int) $config['block_size']; @@ -714,7 +728,13 @@ foreach ($info as $user_id => $user_info) { || isset($group_um[0]) || (isset($user_info['edit']) && $user_info['edit'])))) ) { - $data[0] = ''.$user_id.''; + $data[0] = html_print_anchor( + [ + 'href' => ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/configure_user&edit_user=1&pure=0&id_user='.$user_id), + 'content' => $user_id, + ], + true + ); } else { $data[0] = $user_id; } @@ -728,12 +748,12 @@ foreach ($info as $user_id => $user_info) { if ($user_info['is_admin']) { $data[3] = html_print_image( - 'images/user_suit.png', + 'images/user.svg', true, [ 'alt' => __('Admin'), 'title' => __('Administrator'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ).' '; } else { @@ -792,10 +812,10 @@ foreach ($info as $user_id => $user_info) { } $data[5] = ui_print_string_substr($user_info['comments'], 24, true); - + $table->cellclass[][6] = 'table_action_buttons'; + $data[6] = ''; + $userListActionButtons = []; if ($is_management_allowed === true) { - $table->cellclass[][6] = 'action_buttons'; - $data[6] = ''; if ($user_is_admin || $config['id_user'] == $user_info['id_user'] || isset($group_um[0]) @@ -804,32 +824,49 @@ foreach ($info as $user_id => $user_info) { ) { // Disable / Enable user. if (isset($user_info['not_delete']) === false) { - if ($user_info['disabled'] == 0) { + if ((int) $user_info['disabled'] === 0) { $toDoString = __('Disable'); $toDoAction = '1'; - $toDoImage = 'images/lightbulb.png'; + $toDoImage = 'images/disable.svg'; $toDoClass = ''; } else { $toDoString = __('Enable'); $toDoAction = '0'; - $toDoImage = 'images/lightbulb_off.png'; + $toDoImage = 'images/enable.svg'; $toDoClass = 'filter_none'; } - $data[6] = '
    '; - $data[6] .= html_print_input_hidden( + $userListActionButtons[] = html_print_menu_button( + [ + 'href' => ui_get_full_url( + sprintf( + 'index.php?sec=%s&sec2=godmode/users/user_list&disable_user=%s&pure=%s&id=%s', + $sec, + $toDoAction, + $pure, + $user_info['id_user'] + ) + ), + 'image' => $toDoImage, + 'title' => $toDoString, + ], + true + ); + /* + $data[6] = ''; + $data[6] .= html_print_input_hidden( 'id', $user_info['id_user'], true - ); - // Same csrf for every disable button for submit. - $data[6] .= $csrf; - $data[6] .= html_print_input_hidden( + ); + // Same csrf for every disable button for submit. + $data[6] .= $csrf; + $data[6] .= html_print_input_hidden( 'disable_user', $toDoAction, true - ); - $data[6] .= html_print_input_image( + ); + $data[6] .= html_print_input_image( 'submit_disable_enable', $toDoImage, '', @@ -838,66 +875,102 @@ foreach ($info as $user_id => $user_info) { [ 'data-title' => $toDoString, 'data-use_title_for_force_title' => '1', - 'class' => 'forced_title no-padding '.$toDoClass, + 'class' => 'main_menu_icon forced_title no-padding '.$toDoClass, ] - ); - $data[6] .= '
    '; + ); + $data[6] .= ''; + */ } - // Edit user. - $data[6] .= '
    '; - $data[6] .= html_print_input_hidden( + /* + // Edit user. + $data[6] .= ''; + $data[6] .= html_print_input_hidden( 'id_user', $user_info['id_user'], true - ); - $data[6] .= html_print_input_hidden( + ); + $data[6] .= html_print_input_hidden( 'edit_user', '1', true - ); - $data[6] .= html_print_input_image( + ); + $data[6] .= html_print_input_image( 'submit_edit_user', - 'images/config.png', + 'images/edit.svg', '', 'padding:0', true, [ 'data-title' => __('Edit'), 'data-use_title_for_force_title' => '1', - 'class' => 'forced_title no-padding', + 'class' => 'main_menu_icon forced_title no-padding', ] + ); + $data[6] .= '
    ';*/ + + $userListActionButtons[] = html_print_menu_button( + [ + 'href' => ui_get_full_url( + sprintf( + 'index.php?sec=%s&sec2=godmode/users/configure_user&edit_user=1&pure=%s&id_user=%s', + $sec, + $pure, + $user_info['id_user'] + ) + ), + 'image' => 'images/edit.svg', + 'title' => __('Edit user'), + ], + true ); - $data[6] .= ''; if ($config['admin_can_delete_user'] && $user_info['id_user'] != $config['id_user'] && isset($user_info['not_delete']) === false ) { - $data[6] .= '
    '; - $data[6] .= html_print_input_hidden( + /* + $offset_delete = ($offset >= count($info) - 1) ? ($offset - $config['block_size']) : $offset; + $data[6] .= ''; + $data[6] .= html_print_input_hidden( 'delete_user', $user_info['id_user'], true - ); - $data[6] .= html_print_input_hidden( + ); + $data[6] .= html_print_input_hidden( 'user_del', '1', true - ); - $data[6] .= html_print_input_image( + ); + $data[6] .= html_print_input_image( 'submit_delete_user', - 'images/cross.png', + 'images/delete.svg', '', 'padding:0', true, [ 'data-title' => __('Delete'), 'data-use_title_for_force_title' => '1', - 'class' => 'forced_title no-padding', + 'class' => 'main_menu_icon forced_title no-padding', ] + ); + $data[6] .= '
    '; + */ + $userListActionButtons[] = html_print_menu_button( + [ + 'href' => ui_get_full_url( + sprintf( + 'index.php?sec=%s&sec2=godmode/users/user_list&user_del=1&pure=%s&delete_user=%s', + $sec, + $pure, + $user_info['id_user'] + ) + ), + 'image' => 'images/delete.svg', + 'title' => __('Delete'), + ], + true ); - $data[6] .= ''; if (is_metaconsole() === true) { $data[6] .= '
    '; @@ -917,11 +990,16 @@ foreach ($info as $user_id => $user_info) { true ); $data[6] .= '
    '; + } else { + $data[6] = implode('', $userListActionButtons); } } else { $data[6] .= ''; // Delete button not in this mode. } + + // TODO. Check this in META!!! + $data[6] = implode('', $userListActionButtons); } else { $data[6] .= ''; // Delete button not in this mode. @@ -932,26 +1010,45 @@ foreach ($info as $user_id => $user_info) { } html_print_table($table); -ui_pagination(count($info), false, 0, 0, false, 'offset', true, 'pagination-bottom'); - -echo '
    '; +$tablePagination = ui_pagination(count($info), false, 0, 0, true, 'offset', false, 'dataTables_paginate paging_simple_numbers'); unset($table); if ($is_management_allowed === true) { if ($config['admin_can_add_user'] !== false) { echo '
    '; + html_print_action_buttons( + html_print_submit_button( + __('Create user'), + 'crt', + false, + [ 'icon' => 'wand' ], + true + ), + [ + 'type' => 'form_action', + 'right_content' => $tablePagination, + ], + ); html_print_input_hidden('new_user', 1); - html_print_submit_button(__('Create user'), 'crt', false, 'class="sub next"'); echo '
    '; } else { echo ''.__("The current authentication scheme doesn't support creating users on %s", get_product_name()).''; } +} else { + html_print_action_buttons( + html_print_submit_button( + __('Create user'), + 'none', + true, + [ 'icon' => 'wand' ], + true + ), + [ + 'type' => 'form_action', + 'right_content' => $tablePagination, + ], + ); } - -echo '
    '; - -enterprise_hook('close_meta_frame'); - ?> + '; + if (check_acl($config['id_user'], 0, 'AW')) { + echo '
    '; + + $table = new StdClass; + $table->id = 'save_filter_form'; + $table->width = '100%'; + $table->size = []; + $table->size[0] = '50%'; + $table->size[1] = '50%'; + $table->class = 'filter-table-adv'; + $data = []; + + $table->rowid[0] = 'update_save_selector'; + $data[0][0] = html_print_label_input_block( + __('New filter'), + html_print_radio_button( + 'filter_mode', + 'new', + '', + true, + true + ) + ); + + $data[0][1] = html_print_label_input_block( + __('Update/delete filter'), + html_print_radio_button( + 'filter_mode', + 'update', + '', + false, + true + ) + ); + + $table->rowid[1] = 'save_filter_row1'; + $data[1][0] = html_print_label_input_block( + __('Filter name'), + html_print_input_text('id_name', '', '', 15, 255, true) + ); + + $labelInput = __('Filter group'); + if (is_metaconsole() === true) { + $labelInput = __('Save in Group'); + } + + $user_groups_array = users_get_groups_for_select( + $config['id_user'], + 'AW', + users_can_manage_group_all('AW'), + true + ); + + $data[1][1] = html_print_label_input_block( + $labelInput, + html_print_select( + $user_groups_array, + 'id_group_filter_dialog', + $id_group_filter, + '', + '', + 0, + true, + false, + false + ), + ['div_class' => 'filter-group-dialog'] + ); + + $table->rowid[2] = 'save_filter_row2'; + + $table->data[] = $data; + $table->rowclass[] = ''; + $user_groups = users_get_groups( + $config['id_user'], + 'AW', + users_can_manage_group_all('AW'), + true + ); + + $sql = 'SELECT id_filter, id_name + FROM tagent_filter + WHERE id_group_filter IN ('.implode(',', array_keys($user_groups)).')'; + + $agent_filters = db_get_all_rows_sql($sql); + + $_filters_update = []; + + if ($agent_filters !== false) { + foreach ($agent_filters as $agent_filter) { + $_filters_update[$agent_filter['id_filter']] = $agent_filter['id_name']; + } + } + + $data[2][0] = html_print_label_input_block( + __('Filter'), + html_print_select( + $_filters_update, + 'overwrite_filter', + '', + '', + '', + 0, + true + ) + ); + + $table->data = $data; + + html_print_table($table); + html_print_div( + [ + 'id' => 'submit-save_filter', + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Save current filter'), + 'srcbutton', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + 'onclick' => 'save_new_filter();', + ], + true + ), + ], + false + ); + + $input_actions = html_print_submit_button( + __('Delete filter'), + 'delete_filter', + false, + [ + 'icon' => 'delete', + 'mode' => 'mini', + 'onclick' => 'save_delete_filter();', + ], + true + ); + + $input_actions .= html_print_submit_button( + __('Update filter'), + 'srcbutton', + false, + [ + 'icon' => 'update', + 'mode' => 'mini', + 'onclick' => 'save_update_filter();', + ], + true + ); + + html_print_div( + [ + 'id' => 'update_filter_row', + 'class' => 'action-buttons', + 'content' => $input_actions, + ], + false + ); + } else { + include 'general/noaccess.php'; + } + + echo ''; + ?> + + data[] = $row; } - if (!empty($table->data)) { + if (empty($table->data) === false) { html_print_table($table); } else { ui_print_info_message(['no_close' => true, 'message' => __('No alerts found') ]); @@ -663,9 +663,9 @@ if ($get_agent_alerts_datatable === true) { include_once $config['homedir'].'/operation/agentes/alerts_status.functions.php'; include_once $config['homedir'].'/include/functions_users.php'; - $agent_a = check_acl($config['id_user'], 0, 'AR'); - $agent_w = check_acl($config['id_user'], 0, 'AW'); - $access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'); + $agent_a = (bool) check_acl($config['id_user'], 0, 'AR'); + $agent_w = (bool) check_acl($config['id_user'], 0, 'AW'); + $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR'); $all_groups = get_parameter('all_groups'); $idAgent = (int) get_parameter('id_agent'); @@ -861,7 +861,7 @@ if ($get_agent_alerts_datatable === true) { if (is_metaconsole() === true) { include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php'; - if ($idAgent != 0) { + if ($idAgent !== 0) { $alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter); $countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter); @@ -875,7 +875,7 @@ if ($get_agent_alerts_datatable === true) { $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter); } } else { - if ($idAgent != 0) { + if ($idAgent !== 0) { $alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter); $countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter); diff --git a/pandora_console/include/ajax/audit_log.php b/pandora_console/include/ajax/audit_log.php index 3bf5e09d24..4d92704852 100644 --- a/pandora_console/include/ajax/audit_log.php +++ b/pandora_console/include/ajax/audit_log.php @@ -135,18 +135,15 @@ if ($load_filter_modal) { $table->width = '100%'; $table->cellspacing = 4; $table->cellpadding = 4; - $table->class = 'databox'; + $table->class = 'databox no_border'; if (is_metaconsole()) { $table->cellspacing = 0; $table->cellpadding = 0; - $table->class = 'databox filters'; + $table->class = 'databox filters no_border'; } $table->styleTable = 'font-weight: bold; color: #555; text-align:left;'; - $filter_id_width = '200px'; - if (is_metaconsole()) { - $filter_id_width = '150px'; - } + $filter_id_width = 'w100p'; $data = []; $table->rowid[3] = 'update_filter_row1'; @@ -165,11 +162,17 @@ if ($load_filter_modal) { false, 'margin-left:5px; width:'.$filter_id_width.';' ); + + $table->rowclass[] = 'display-grid'; $data[1] = html_print_submit_button( __('Load filter'), 'load_filter', false, - 'class="sub upd" onclick="load_filter_values()"', + [ + 'class' => 'mini w25p', + 'style' => 'margin-left: 73%', + 'onclick' => 'load_filter_values();', + ], true ); $data[1] .= html_print_input_hidden('load_filter', 1, true); @@ -186,7 +189,7 @@ function show_filter() { draggable: true, modal: false, closeOnEscape: true, - width: 450 + width: 500 }); } @@ -238,7 +241,7 @@ $(document).ready (function() { if ($save_filter_modal) { - echo '
    '; + echo '
    '; if (check_acl($config['id_user'], 0, 'EW') === 1 || check_acl($config['id_user'], 0, 'EM') === 1) { echo '
    '; @@ -247,9 +250,9 @@ if ($save_filter_modal) { $table->width = '100%'; $table->cellspacing = 4; $table->cellpadding = 4; - $table->class = 'databox'; + $table->class = 'databox no_border'; if (is_metaconsole()) { - $table->class = 'databox filters'; + $table->class = 'databox filters no_border'; $table->cellspacing = 0; $table->cellpadding = 0; } @@ -289,7 +292,11 @@ if ($save_filter_modal) { __('Save filter'), 'save_filter', false, - 'class="sub wand" onclick="save_new_filter();"', + [ + 'class' => 'mini w25p', + 'style' => 'margin-left: 56%', + 'onclick' => 'save_new_filter();', + ], true ); @@ -317,11 +324,16 @@ if ($save_filter_modal) { 0, true ); + $table->rowclass[] = 'display-grid'; $data[1] = html_print_submit_button( __('Update filter'), 'update_filter', false, - 'class="sub upd" onclick="save_update_filter();"', + [ + 'class' => 'mini w25p', + 'style' => 'margin-left: 56%', + 'onclick' => 'save_update_filter();', + ], true ); @@ -359,7 +371,8 @@ function show_save_filter() { resizable: true, draggable: true, modal: false, - closeOnEscape: true + closeOnEscape: true, + width: 380 }); } diff --git a/pandora_console/include/ajax/double_auth.ajax.php b/pandora_console/include/ajax/double_auth.ajax.php index 0f85c9c0f5..3a995ce43a 100644 --- a/pandora_console/include/ajax/double_auth.ajax.php +++ b/pandora_console/include/ajax/double_auth.ajax.php @@ -1,21 +1,39 @@ $id_user]; db_process_sql_delete('tuser_double_auth', $where); - // Insert the new value + // Insert the new value. $values = [ 'id_user' => $id_user, 'secret' => $secret, @@ -116,12 +134,12 @@ if ($save_double_auth_secret) { return; } -// Disable the double auth for the user +// Disable the double auth for the user. $deactivate_double_auth = (bool) get_parameter('deactivate_double_auth'); if ($deactivate_double_auth) { $result = false; - // Delete the actual value (if exists) + // Delete the actual value (if exists). $where = ['id_user' => $id_user]; $result = db_process_sql_delete('tuser_double_auth', $where); @@ -129,7 +147,7 @@ if ($deactivate_double_auth) { return; } -// Get the info page to the container dialog +// Get the info page to the container dialog. $get_double_auth_data_page = (bool) get_parameter('get_double_auth_data_page'); if ($get_double_auth_data_page) { $secret = db_get_value('secret', 'tuser_double_auth', 'id_user', $id_user); @@ -146,7 +164,7 @@ if ($get_double_auth_data_page) { $html .= '

    '; $html .= '
    '; $html .= '
    '; - $html .= __('Code').": $secret"; + $html .= __('Code').': '.$secret.''; $html .= '
    '; $html .= __('QR').':
    '; $html .= '
    '; @@ -161,7 +179,7 @@ if ($get_double_auth_data_page) { var secret = ""; var id_user_auth = ""; - // QR code with the secret to add it to the app + // QR code with the secret to add it to the app. paint_qrcode("otpauth://totp/"+id_user_auth+"?secret="+secret, $("div#qr-container").get(0), 200, 200); $("div#qr-container").attr("title", "").find("canvas").remove(); @@ -179,7 +197,7 @@ if ($get_double_auth_data_page) { return; } -// Get the info page to the container dialog +// Get the info page to the container dialog. $get_double_auth_info_page = (bool) get_parameter('get_double_auth_info_page'); if ($get_double_auth_info_page) { $container_id = (string) get_parameter('containerID'); @@ -209,14 +227,14 @@ if ($get_double_auth_info_page) { ob_clean(); ?> data)) { - if ($filter_monitors) { - ui_print_info_message([ 'no_close' => true, 'message' => __('Any monitors aren\'t with this filter.') ]); - } else { - ui_print_info_message([ 'no_close' => true, 'message' => __('This agent doesn\'t have any active monitors.') ]); - } + if (empty($table->data) === true) { + ui_print_info_message( + [ + 'no_close' => true, + 'message' => ($filter_monitors === true) ? __('Any monitors aren\'t with this filter.') : __('This agent doesn\'t have any active monitors.'), + ] + ); } else { $url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.'&status_text_monitor='.$status_text_monitor.'&status_module_group='.$status_module_group; - if ($paginate_module) { + if ($paginate_module === true) { ui_pagination( $count_modules, false, @@ -1349,7 +1376,7 @@ if (check_login()) { html_print_table($table); - if ($paginate_module) { + if ($paginate_module === true) { ui_pagination( $count_modules, false, @@ -1372,7 +1399,7 @@ if (check_login()) { unset($table_data); } - if ($get_type) { + if ($get_type === true) { $id_module = (int) get_parameter('id_module'); $module = modules_get_agentmodule($id_module); $graph_type = return_graphtype($module['id_tipo_modulo']); @@ -1626,7 +1653,7 @@ if (check_login()) { // If not valid it will throw an exception. json_decode($response); - if (json_last_error() == JSON_ERROR_NONE) { + if (json_last_error() === JSON_ERROR_NONE) { // If valid dump. echo $response; } else { @@ -1740,6 +1767,29 @@ if (check_login()) { } } + if ($delete_monitor_filter) { + $id = get_parameter('id'); + + $user_groups = users_get_groups( + $config['id_user'], + 'AW', + users_can_manage_group_all('AW'), + true + ); + + $sql = 'DELETE + FROM tmonitor_filter + WHERE id_filter = '.$id.' AND id_group_filter IN ('.implode(',', array_keys($user_groups)).')'; + + $monitor_filters = db_process_sql($sql); + + if ($monitor_filters === false) { + echo 'error'; + } else { + echo 'ok'; + } + } + if ($get_monitor_filters) { $sql = 'SELECT id_filter, id_name FROM tmonitor_filter'; @@ -1760,7 +1810,7 @@ if (check_login()) { $user_groups = users_get_groups( $config['id_user'], 'AR', - users_can_manage_group_all(), + users_can_manage_group_all('AR'), true ); @@ -1775,56 +1825,54 @@ if (check_login()) { $filters[$event_filter['id_filter']] = $event_filter['id_name']; } - echo '
    '; + echo '
    '; echo '
    '; $table = new StdClass; $table->id = 'load_filter_form'; $table->width = '100%'; - $table->cellspacing = 4; - $table->cellpadding = 4; - $table->class = 'databox'; - if (is_metaconsole()) { - $table->cellspacing = 0; - $table->cellpadding = 0; - $table->class = 'databox filters'; - } - - $table->styleTable = 'font-weight: bold; color: #555; text-align:left;'; - $filter_id_width = '200px'; - if (is_metaconsole()) { - $filter_id_width = '150px'; - } + $table->class = 'filter-table-adv'; $data = []; $table->rowid[3] = 'update_filter_row1'; - $data[0] = __('Load filter').$jump; - $data[0] .= html_print_select( - $filters, - 'filter_id', - $current, - '', - __('None'), - 0, - true, - false, - true, - '', - false, - 'margin-left:5px; width:'.$filter_id_width.';' - ); - $data[1] = html_print_submit_button( + $data[0] = html_print_label_input_block( __('Load filter'), - 'load_filter', - false, - 'class="sub upd"', - true + html_print_select( + $filters, + 'filter_id', + $current, + '', + __('None'), + 0, + true, + false, + true, + '', + false + ) ); - $data[1] .= html_print_input_hidden('load_filter', 1, true); + $table->data[] = $data; $table->rowclass[] = ''; html_print_table($table); + html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Load filter'), + 'srcbutton', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + ], + true + ), + ], + false + ); + echo html_print_input_hidden('load_filter', 1, true); echo '
    '; echo '
    '; ?> @@ -1850,90 +1898,75 @@ if (check_login()) { } if ($save_filter_modal) { - echo '
    '; + echo '
    '; if (check_acl($config['id_user'], 0, 'AW')) { echo '
    '; $table = new StdClass; $table->id = 'save_filter_form'; - $table->width = '100%'; - $table->cellspacing = 4; - $table->cellpadding = 4; - $table->class = 'databox'; - if (is_metaconsole()) { - $table->class = 'databox filters'; - $table->cellspacing = 0; - $table->cellpadding = 0; - } - - $table->styleTable = 'font-weight: bold; text-align:left;'; - if (!is_metaconsole()) { - $table->style[0] = 'width: 50%; width:50%;'; - } - + $table->size = []; + $table->size[0] = '50%'; + $table->size[1] = '50%'; + $table->class = 'filter-table-adv'; $data = []; + $table->rowid[0] = 'update_save_selector'; - $data[0] = html_print_radio_button( - 'filter_mode', - 'new', - '', - true, - true - ).__('New filter').''; + $data[0][0] = html_print_label_input_block( + __('New filter'), + html_print_radio_button( + 'filter_mode', + 'new', + '', + true, + true + ) + ); - $data[1] = html_print_radio_button( - 'filter_mode', - 'update', - '', - false, - true - ).__('Update filter').''; + $data[0][1] = html_print_label_input_block( + __('Update/delete filter'), + html_print_radio_button( + 'filter_mode', + 'update', + '', + false, + true + ) + ); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; $table->rowid[1] = 'save_filter_row1'; - $data[0] = __('Filter name').$jump; - $data[0] .= html_print_input_text('id_name', '', '', 15, 255, true); - if (is_metaconsole()) { - $data[1] = __('Save in Group').$jump; - } else { - $data[1] = __('Filter group').$jump; + $data[1][0] = html_print_label_input_block( + __('Filter name'), + html_print_input_text('id_name', '', '', 15, 255, true) + ); + + $labelInput = __('Filter group'); + if (is_metaconsole() === true) { + $labelInput = __('Save in Group'); } $user_groups_array = users_get_groups_for_select( $config['id_user'], 'AW', - users_can_manage_group_all(), + users_can_manage_group_all('AW'), true ); - $data[1] .= html_print_select( - $user_groups_array, - 'id_group_filter_dialog', - $id_group_filter, - '', - '', - 0, - true, - false, - false, - 'w130' + $data[1][1] = html_print_label_input_block( + $labelInput, + html_print_select( + $user_groups_array, + 'id_group_filter_dialog', + $id_group_filter, + '', + '', + 0, + true, + false, + false + ), + ['div_class' => 'filter-group-dialog'] ); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; $table->rowid[2] = 'save_filter_row2'; - - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $table->rowid[3] = 'update_filter_row1'; - $data[0] = __('Overwrite filter').$jump; - $sql = 'SELECT id_filter, id_name FROM tmonitor_filter'; $monitor_filters = db_get_all_rows_sql($sql); @@ -1945,36 +1978,74 @@ if (check_login()) { } } - $data[0] .= html_print_select( - $_filters_update, - 'overwrite_filter', - '', - '', - '', - 0, - true - ); - $data[1] = html_print_submit_button( - __('Update filter'), - 'update_filter', - false, - 'class="sub upd" onclick="save_update_filter();"', - true + $data[2][0] = html_print_label_input_block( + __('Overwrite filter'), + html_print_select( + $_filters_update, + 'overwrite_filter', + '', + '', + '', + 0, + true + ) ); - $table->data[] = $data; - $table->rowclass[] = ''; + $table->data = $data; html_print_table($table); - echo '
    '; - echo html_print_submit_button( - __('Save filter'), - 'save_filter', - false, - 'class="sub upd float-right" onclick="save_new_filter();"', - true - ); - echo '
    '; + + html_print_div( + [ + 'id' => 'submit-save_filter', + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Save current filter'), + 'srcbutton', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + 'onclick' => 'save_new_filter();', + ], + true + ), + ], + false + ); + + $input_actions = html_print_submit_button( + __('Delete filter'), + 'delete_filter', + false, + [ + 'icon' => 'delete', + 'mode' => 'mini', + 'onclick' => 'save_delete_filter();', + ], + true + ); + + $input_actions .= html_print_submit_button( + __('Update filter'), + 'srcbutton', + false, + [ + 'icon' => 'update', + 'mode' => 'mini', + 'onclick' => 'save_update_filter();', + ], + true + ); + + html_print_div( + [ + 'id' => 'update_filter_row', + 'class' => 'action-buttons', + 'content' => $input_actions, + ], + false + ); } else { include 'general/noaccess.php'; } @@ -1983,29 +2054,34 @@ if (check_login()) { ?> + id_agente = (int) get_parameter('id_agente', 0); - $this->operation = get_parameter('operation', 0); + $this->id_agente = (int) get_parameter('id_agente'); + $this->operation = (int) get_parameter('operation'); $this->community = (string) get_parameter('community', 'public'); $this->ip = (string) get_parameter('select_ips'); $this->snmp_version = (string) get_parameter('select_version'); @@ -389,7 +389,13 @@ class ExternalTools extends HTML 'id' => '', 'class' => 'action-buttons', 'style' => 'width: 100%', - 'content' => html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"', true), + 'content' => html_print_submit_button( + __('Update'), + 'update_button', + false, + [ 'icon' => 'update' ], + true + ), ], true ); @@ -522,14 +528,16 @@ class ExternalTools extends HTML // Form table. $table = new StdClass(); - $table->class = 'databox filters w100p'; + $table->class = 'fixed_filter_bar'; $table->id = 'externalToolTable'; - + $table->cellstyle['captions'][0] = 'width: 0'; + $table->cellstyle['captions'][1] = 'width: 0'; + $table->cellstyle['captions'][2] = 'width: 0'; $table->data = []; - $table->data[0][0] = __('Operation'); + $table->data['captions'][0] = __('Operation'); - $table->data[0][1] = html_print_select( + $table->data['inputs'][0] = html_print_select( $commandList, 'operation', $this->operation, @@ -539,8 +547,8 @@ class ExternalTools extends HTML true ); - $table->data[0][2] = __('IP Adress'); - $table->data[0][3] = html_print_select( + $table->data['captions'][1] = __('IP Adress'); + $table->data['inputs'][1] = html_print_select( $ipsSelect, 'select_ips', $principal_ip, @@ -550,10 +558,10 @@ class ExternalTools extends HTML true ); - $table->cellclass[0][4] = 'snmpcolumn'; - $table->data[0][4] = __('SNMP Version'); - $table->data[0][4] .= ' '; - $table->data[0][4] .= html_print_select( + $table->cellclass['captions'][2] = 'snmpcolumn'; + $table->cellclass['inputs'][2] = 'snmpcolumn'; + $table->data['captions'][2] = __('SNMP Version'); + $table->data['inputs'][2] = html_print_select( [ '1' => 'v1', '2c' => 'v2c', @@ -566,10 +574,10 @@ class ExternalTools extends HTML true ); - $table->cellclass[0][5] = 'snmpcolumn'; - $table->data[0][5] = __('SNMP Community'); - $table->data[0][5] .= ' '; - $table->data[0][5] .= html_print_input_text( + $table->cellclass['captions'][3] = 'snmpcolumn'; + $table->cellclass['inputs'][3] = 'snmpcolumn'; + $table->data['captions'][3] = __('SNMP Community'); + $table->data['inputs'][3] = html_print_input_text( 'community', $this->community, '', @@ -578,7 +586,22 @@ class ExternalTools extends HTML true ); - $table->data[0][6] = ""; + $table->data['inputs'][4] = html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Execute'), + 'submit', + false, + [ + 'icon' => 'cog', + 'mode' => 'mini', + ], + true + ), + ], + true + ); // Output string. $output = ''; @@ -698,10 +721,10 @@ class ExternalTools extends HTML try { // If caption is not added, don't show anything. if (empty($caption) === false) { - $output .= sprintf('

    %s

    ', $caption); + $output .= sprintf('

    %s

    ', $caption); } - $output .= '
    ';
    +            $output .= '
    ';
     
                 // Only perform an execution if command is passed. Avoid errors.
                 if (empty($command) === false) {
    @@ -766,7 +789,7 @@ class ExternalTools extends HTML
                         'format'         => '-Oqn',
                     ];
     
    -                echo '

    '.__('SNMP information for ').$ip.'

    '; + echo '

    '.__('SNMP information for ').$ip.'

    '; $snmp_obj['base_oid'] = '.1.3.6.1.2.1.1.3.0'; $result = get_h_snmpwalk($snmp_obj); @@ -828,7 +851,7 @@ class ExternalTools extends HTML html_print_table($table); } else if ((int) $operation === COMMAND_DIGWHOIS) { - echo '

    '.__('Domain and IP information for ').$ip.'

    '; + echo '

    '.__('Domain and IP information for ').$ip.'

    '; // Dig execution. $dig = $this->whereIsTheCommand('dig'); diff --git a/pandora_console/include/class/HTML.class.php b/pandora_console/include/class/HTML.class.php index f2b6ed3630..ca74f7dc46 100644 --- a/pandora_console/include/class/HTML.class.php +++ b/pandora_console/include/class/HTML.class.php @@ -311,7 +311,7 @@ class HTML public function printBreadcrum() { return implode( - ' / ', + ' / ', $this->breadcrum ); } @@ -398,7 +398,7 @@ class HTML * * @return void */ - public static function printGoBackButton($url=null) + public static function printGoBackButton($url=null, $return=false) { if (isset($url) === false) { $url = ui_get_full_url( @@ -418,14 +418,21 @@ class HTML 'name' => 'submit', 'label' => __('Go back'), 'type' => 'submit', - 'attributes' => 'class="sub cancel"', + 'attributes' => [ + 'icon' => 'back', + 'mode' => 'secondary', + ], 'return' => true, ], ], ], ]; - self::printForm($form); + if ($return === true) { + return self::printForm($form, $return); + } + + self::printForm($form, $return); } @@ -537,7 +544,7 @@ class HTML 'container_class' => $input['toggle_container_class'], 'img_a' => $input['toggle_img_a'], 'img_b' => $input['toggle_img_b'], - 'clean' => (isset($input['toggle_clean']) ? $input['toggle_clean'] : true), + 'clean' => (isset($input['toggle_clean']) ? $input['toggle_clean'] : false), ] ); } else { @@ -803,10 +810,13 @@ class HTML $output_head .= 'id="'.$form['id'].'" '; } + $output_head .= 'class="max_floating_element_size '; if (isset($form['class']) === true) { - $output_head .= 'class="discovery '.$form['class'].'" '; + $output_head .= 'discovery '.$form['class'].' '; } + $output_head .= '"'; + if (isset($form['onsubmit']) === true) { $output_head .= 'onsubmit="'.$form['onsubmit'].'" '; } @@ -870,7 +880,7 @@ class HTML $output .= '
    '; } else { if ($print_white_box === true) { - $output .= '
    '; + $output .= '
    '; } $output .= '