diff --git a/extras/deploy-scripts/pandora_agent_deploy.sh b/extras/deploy-scripts/pandora_agent_deploy.sh index 74db9d7c72..281ad530a9 100644 --- a/extras/deploy-scripts/pandora_agent_deploy.sh +++ b/extras/deploy-scripts/pandora_agent_deploy.sh @@ -4,7 +4,7 @@ # define variables PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf -S_VERSION='2021100601' +S_VERSION='2022052301' LOGFILE="/tmp/pandora-agent-deploy-$(date +%F).log" # Ansi color code variables @@ -49,7 +49,6 @@ check_cmd_status () { } check_repo_connection () { - execute_cmd "ping -c 2 8.8.8.8" "Checking internet connection" execute_cmd "ping -c 2 firefly.artica.es" "Checking Community repo" } @@ -79,10 +78,15 @@ echo "Starting PandoraFMS Agent deployment ver. $S_VERSION" execute_cmd "[ $PANDORA_SERVER_IP ]" 'Check Server IP Address' 'Please define env variable PANDORA_SERVER_IP' +#Detect OS +os_name=$(grep ^PRETTY_NAME= /etc/os-release | cut -d '=' -f2 | tr -d '"') +execute_cmd "echo $os_name" "OS detected: ${os_name}" + # Check OS. OS=$([[ $(grep '^ID_LIKE=' /etc/os-release) ]] && grep ^ID_LIKE= /etc/os-release | cut -d '=' -f2 | tr -d '"' || grep ^ID= /etc/os-release | cut -d '=' -f2 | tr -d '"') [[ $OS =~ 'rhel' ]] && OS_RELEASE=$OS +[[ $OS =~ 'fedora' ]] && OS_RELEASE=$OS [[ $OS =~ 'debian' ]] && OS_RELEASE=$OS #[[ $OS == 'rhel fedora' ]] && OS_RELEASE=$OS #[[ $OS == 'centos rhel fedora' ]] && OS_RELEASE=$OS @@ -113,17 +117,40 @@ execute_cmd "cd $HOME/pandora_deploy_tmp" "Moving to workspace: $HOME/pandora_d # Downloading and installing packages -if [[ $OS_RELEASE =~ 'rhel' ]]; then - yum install -y perl wget curl perl-Sys-Syslog unzip &>> $LOGFILE - echo -e "${cyan}Instaling agent dependencies...${reset}" ${green}OK${reset} +if [[ $OS_RELEASE =~ 'rhel' ]] || [[ $OS_RELEASE =~ 'fedora' ]]; then + ## Extra steps on redhat + if [ "$(grep -Ei 'Red Hat Enterprise' /etc/redhat-release)" ]; then + ## In case REDHAT + # Check susbscription manager status: + echo -en "${cyan}Checking Red Hat Enterprise subscription... ${reset}" + subscription-manager list &>> "$LOGFILE" + subscription-manager status &>> "$LOGFILE" + check_cmd_status 'Error checking subscription status, make sure your server is activated and suscribed to Red Hat Enterprise repositories' + + fi + + # Check rh version + if [ $(sed -nr 's/VERSION_ID+=\s*"([0-9]).*"$/\1/p' /etc/os-release) -eq '8' ] ; then + package_manager_cmd=dnf + elif [ $(sed -nr 's/VERSION_ID+=\s*"([0-9]).*"$/\1/p' /etc/os-release) -eq '7' ] ; then + package_manager_cmd=yum + + fi + + # Install dependencies + $package_manager_cmd install -y perl wget curl perl-Sys-Syslog unzip &>> $LOGFILE + echo -e "${cyan}Installing agent dependencies...${reset}" ${green}OK${reset} - yum install -y http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm &>> $LOGFILE - echo -e "${cyan}Instaling Pandora FMS agent...${reset}" ${green}OK${reset} + # Insatall pandora agent + $package_manager_cmd install -y http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm &>> $LOGFILE + echo -en "${cyan}Installing Pandora FMS agent...${reset}" + check_cmd_status 'Error installing Pandora FMS agent' + fi if [[ $OS_RELEASE == 'debian' ]]; then execute_cmd "apt update" 'Updating repos' - execute_cmd "apt install -y perl wget curl unzip procps python3 python3-pip" 'Instaling agent dependencies' + execute_cmd "apt install -y perl wget curl unzip procps python3 python3-pip" 'Installing agent dependencies' execute_cmd 'wget http://firefly.artica.es/pandorafms/latest/Debian_Ubuntu/pandorafms.agent_unix_7.0NG.deb' 'Downloading Pandora FMS agent dependencies' execute_cmd 'apt install -y ./pandorafms.agent_unix_7.0NG.deb' 'Installing Pandora FMS agent' fi diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index cb800cf29b..a0f08822e1 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -11,7 +11,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf -S_VERSION='2022020801' +S_VERSION='2022050901' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" # define default variables @@ -82,7 +82,6 @@ check_pre_pandora () { } check_repo_connection () { - execute_cmd "ping -c 2 8.8.8.8" "Checking internet connection" execute_cmd "ping -c 2 firefly.artica.es" "Checking Community repo" execute_cmd "ping -c 2 support.pandorafms.com" "Checking Enterprise repo" } @@ -257,6 +256,8 @@ console_dependencies=" \ poppler-data \ php-yaml \ mod_ssl \ + libzstd \ + openldap-clients \ http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm" execute_cmd "yum install -y $console_dependencies" "Installing Pandora FMS Console dependencies" @@ -422,7 +423,7 @@ execute_cmd "curl -LSs --output pandorafms_agent_unix-7.0NG.noarch.rpm ${PANDORA execute_cmd "yum install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "installing PandoraFMS packages" # Copy gotty utility -execute_cmd "wget https://github.com/yudai/gotty/releases/download/v1.0.1/gotty_linux_amd64.tar.gz" 'Dowloading gotty util' +execute_cmd "wget https://pandorafms.com/library/wp-content/uploads/2019/11/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 0b17821b46..5b549a2933 100644 --- a/extras/deploy-scripts/pandora_deploy_community_el8.sh +++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh @@ -14,7 +14,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf -S_VERSION='2022050501' +S_VERSION='2022052501' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" # define default variables @@ -86,7 +86,6 @@ check_pre_pandora () { } check_repo_connection () { - execute_cmd "ping -c 2 8.8.8.8" "Checking internet connection" execute_cmd "ping -c 2 firefly.artica.es" "Checking Community repo" execute_cmd "ping -c 2 support.pandorafms.com" "Checking Enterprise repo" } @@ -308,6 +307,8 @@ console_dependencies=" \ poppler-data \ php-yaml \ mod_ssl \ + libzstd \ + openldap-clients \ http://firefly.artica.es/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \ http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm \ http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm" @@ -420,7 +421,9 @@ echo "create database $DBNAME" | mysql -uroot -P$DBPORT -h$DBHOST check_cmd_status "Error creating database $DBNAME, is this an empty node? if you have a previus installation please contact with support." echo "CREATE USER \"$DBUSER\"@'%' IDENTIFIED BY \"$DBPASS\";" | mysql -uroot -P$DBPORT -h$DBHOST +echo "ALTER USER \"$DBUSER\"@'%' IDENTIFIED WITH mysql_native_password BY \"$DBPASS\"" | mysql -uroot -P$DBPORT -h$DBHOST echo "GRANT ALL PRIVILEGES ON $DBNAME.* TO \"$DBUSER\"@'%'" | mysql -uroot -P$DBPORT -h$DBHOST + export MYSQL_PWD=$DBPASS #Generating my.cnf @@ -495,7 +498,7 @@ execute_cmd "curl -LSs --output pandorafms_agent_unix-7.0NG.noarch.rpm ${PANDORA execute_cmd "dnf install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "Installing Pandora FMS packages" # Copy gotty utility -execute_cmd "wget https://github.com/yudai/gotty/releases/download/v1.0.1/gotty_linux_amd64.tar.gz" 'Dowloading gotty util' +execute_cmd "wget https://pandorafms.com/library/wp-content/uploads/2019/11/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/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 9ecafc4278..a0036b2d74 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.762-220526 +Version: 7.0NG.762-220621 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 2f53dd808c..120963407c 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.762-220526" +pandora_version="7.0NG.762-220621" 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 5b3c9dd9d5..08c1d4b6eb 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.762'; -use constant AGENT_BUILD => '220526'; +use constant AGENT_BUILD => '220621'; # 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 8299497d86..baea70960f 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.762 -%define release 220526 +%define release 220621 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 40526689b5..af0f1b3595 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.762 -%define release 220526 +%define release 220621 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 7a9e80dd1d..bfb6150270 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.762" -PI_BUILD="220526" +PI_BUILD="220621" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 47da22e370..fef7490e41 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{220526} +{220621} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 35960c8b33..ddc0746f56 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.762 Build 220526") +#define PANDORA_VERSION ("7.0NG.762 Build 220621") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index ba4dbe45be..bc78bf9669 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.762(Build 220526))" + VALUE "ProductVersion", "(7.0NG.762(Build 220621))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 978273000c..20416c9a6a 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.762-220526 +Version: 7.0NG.762-220621 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 3f8ce11bce..d76894ce29 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.762-220526" +pandora_version="7.0NG.762-220621" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index fe13fd3149..73284cb169 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -1665,3 +1665,4 @@ godmode/um_client/vendor/sebastian/object-enumerator/tests godmode/um_client/vendor/sebastian/object-enumerator godmode/um_client/vendor/sebastian godmode/um_client/vendor +/update_manager_client/resources/styles/pandora.css \ No newline at end of file diff --git a/pandora_console/extras/mr/55.sql b/pandora_console/extras/mr/55.sql new file mode 100644 index 0000000000..246e8b641f --- /dev/null +++ b/pandora_console/extras/mr/55.sql @@ -0,0 +1,54 @@ +START TRANSACTION; + +ALTER TABLE `tuser_double_auth` DROP FOREIGN KEY `tuser_double_auth_ibfk_1`, MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL; +ALTER TABLE `tnotification_user` DROP FOREIGN KEY `tnotification_user_ibfk_2`, MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL; +ALTER TABLE `tnotification_source_user` DROP FOREIGN KEY `tnotification_source_user_ibfk_2`, MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL; +ALTER TABLE `tnotification_source_group_user` DROP FOREIGN KEY `tnotification_source_group_user_ibfk_2`, MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL; +ALTER TABLE `tvisual_console_elements_cache` DROP FOREIGN KEY `tvisual_console_elements_cache_ibfk_3`, MODIFY COLUMN `user_id` VARCHAR(255) DEFAULT NULL; +ALTER TABLE `tusuario` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL DEFAULT '0'; +ALTER TABLE `tuser_double_auth` ADD CONSTRAINT `tuser_double_auth_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `tusuario` (`id_user`) ON DELETE CASCADE; +ALTER TABLE `tnotification_user` ADD CONSTRAINT `tnotification_user_ibfk_2` FOREIGN KEY (`id_user`) REFERENCES `tusuario` (`id_user`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `tnotification_source_user` ADD CONSTRAINT `tnotification_source_user_ibfk_2` FOREIGN KEY (`id_user`) REFERENCES `tusuario` (`id_user`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `tnotification_source_group_user` ADD CONSTRAINT `tnotification_source_group_user_ibfk_2` FOREIGN KEY (`id_user`) REFERENCES `tusuario` (`id_user`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `tvisual_console_elements_cache` ADD CONSTRAINT `tvisual_console_elements_cache_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `tusuario` (`id_user`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `tattachment` MODIFY COLUMN `id_usuario` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `tevento` MODIFY COLUMN `id_usuario` VARCHAR(255) NOT NULL DEFAULT '0'; +ALTER TABLE `tincidencia` MODIFY COLUMN `id_usuario` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `tnota` MODIFY COLUMN `id_usuario` VARCHAR(255) NOT NULL DEFAULT '0'; +ALTER TABLE `tsesion` MODIFY COLUMN `id_usuario` VARCHAR(255) NOT NULL DEFAULT '0'; +ALTER TABLE `ttrap` MODIFY COLUMN `id_usuario` VARCHAR(255) DEFAULT ''; +ALTER TABLE `tusuario_perfil` MODIFY COLUMN `id_usuario` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `treset_pass_history` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL; +ALTER TABLE `tmensajes` MODIFY COLUMN `id_usuario_origen` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `tgraph` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `treport` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `tplanned_downtime` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL DEFAULT '0'; +ALTER TABLE `tnetwork_map` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL; +ALTER TABLE `tpassword_history` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL; +ALTER TABLE `tupdate_journal` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `tmap` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `tdashboard` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `treport_template` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `tmetaconsole_event` MODIFY COLUMN `id_usuario` VARCHAR(255) NOT NULL DEFAULT '0'; +ALTER TABLE `tmetaconsole_event_history` MODIFY COLUMN `id_usuario` VARCHAR(255) NOT NULL DEFAULT '0'; +ALTER TABLE `treset_pass` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `tuser_task_scheduled` MODIFY COLUMN `id_usuario` VARCHAR(255) NOT NULL DEFAULT '0'; +ALTER TABLE `tbackup` MODIFY COLUMN `id_user` VARCHAR(255) DEFAULT ''; + +ALTER TABLE `tservice` ADD COLUMN `enable_sunburst` tinyint(1) NOT NULL default 0; +ALTER TABLE `tdashboard` MODIFY `name` TEXT NOT NULL DEFAULT ''; + +ALTER TABLE `tagente` ADD COLUMN `satellite_server` INT NOT NULL default 0; +ALTER TABLE `tmetaconsole_agent` ADD COLUMN `satellite_server` INT NOT NULL default 0; +SET @st_oum763 = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'tautoconfig' AND table_schema = DATABASE() AND column_name = 'disabled') > 0, + "SELECT 1", + "ALTER TABLE `tautoconfig` ADD COLUMN `disabled` TINYINT DEFAULT 0" +)); + +PREPARE pr_oum763 FROM @st_oum763; +EXECUTE pr_oum763; +DEALLOCATE PREPARE pr_oum763; + +COMMIT; + diff --git a/pandora_console/general/first_task/HA_cluster_builder.php b/pandora_console/general/first_task/HA_cluster_builder.php index 2f0bb24a20..e475dfdf1a 100644 --- a/pandora_console/general/first_task/HA_cluster_builder.php +++ b/pandora_console/general/first_task/HA_cluster_builder.php @@ -37,7 +37,7 @@ ui_require_css_file('first_task'); ui_print_info_message(['no_close' => true, 'message' => __('There are no HA clusters defined yet.') ]); ?> -
+
__('Clusters')]); ?>
diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index b1b0a5e48a..7384ac17ff 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -954,7 +954,7 @@ echo sprintf('
', $menuTypeClass); $("a.autorefresh").click (function () { $("a.autorefresh_txt").toggle (); - $("#combo_refr").toggle (); + $("#combo_refr").toggle(); $("select#ref").change (function () { href = $("a.autorefresh").attr ("href"); diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index f0b75c51a5..590dbe328a 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -26,6 +26,8 @@ * ============================================================================ */ +use function PHPSTORM_META\map; + // Begin. if (isset($config['id_user']) === false) { include 'general/login_page.php'; @@ -57,52 +59,22 @@ if (isset($config['autohidden_menu']) === true && (bool) $config['autohidden_men // Start of full lateral menu. echo sprintf('
'; + +$table_satellite = ''; +if ($remote_agent === true) { + // Satellite server selector. + $satellite_servers = db_get_all_rows_filter( + 'tserver', + ['server_type' => SERVER_TYPE_ENTERPRISE_SATELLITE], + [ + 'id_server', + 'name', + ] + ); + + $satellite_names = []; + if (empty($satellite_servers) === false) { + foreach ($satellite_servers as $s_server) { + $satellite_names[$s_server['id_server']] = $s_server['name']; + } + + $table_satellite = '

'.__('Satellite').'

'; + $table_satellite .= '
'; + + $table_satellite .= html_print_input( + [ + 'type' => 'select', + 'fields' => $satellite_names, + 'name' => 'satellite_server', + 'selected' => $satellite_server, + 'nothing' => __('None'), + 'nothinf_value' => 0, + 'return' => true, + ] + ).'
'; + } +} + // Description. $table_description = '

'.__('Description').'

'; $table_description .= html_print_textarea( @@ -443,7 +482,7 @@ $table_description .= html_print_textarea( echo '
'.$table_agent_name.$table_alias.$table_ip.$table_primary_group.'
-
'.$table_interval.$table_os.$table_server.$table_description.'
+
'.$table_interval.$table_os.$table_server.$table_satellite.$table_description.'
'; if (!$new_agent && $alias != '') { echo $table_qr_code; @@ -523,7 +562,6 @@ if (enterprise_installed()) { $table_adv_cascade .= $cps_html; } - $table_adv_parent = '
'; $params = []; $params['return'] = true; @@ -536,6 +574,11 @@ $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()) { diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 8e63416b97..4d26746ed1 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -155,6 +155,7 @@ $alert_d7 = 1; $alert_recovery = 0; $alert_priority = 0; $server_name = ''; +$satellite_server = 0; $grupo = 0; $id_os = 9; // Windows. @@ -985,6 +986,7 @@ if ($update_agent) { $old_values = db_get_row('tagente', 'id_agente', $id_agente); $fields = db_get_all_fields_in_table('tagent_custom_fields'); $secondary_groups = (string) get_parameter('secondary_hidden', ''); + $satellite_server = (int) get_parameter('satellite_server', 0); if ($fields === false) { $fields = []; @@ -1092,6 +1094,7 @@ if ($update_agent) { 'quiet' => $quiet, 'cps' => $cps, 'safe_mode_module' => $safe_mode_module, + 'satellite_server' => $satellite_server, ]; if ($config['metaconsole_agent_cache'] == 1) { @@ -1230,6 +1233,7 @@ if ($id_agente) { $cps = $agent['cps']; $safe_mode_module = $agent['safe_mode_module']; $safe_mode = ($safe_mode_module) ? 1 : 0; + $satellite_server = (int) $agent['satellite_server']; } $update_module = (bool) get_parameter('update_module'); diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 9c63363df2..a84bf918f8 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -315,7 +315,20 @@ html_print_select_groups( '', false ); -echo '
'; +echo '
'; + +// Recursion checkbox. +echo ''; +echo __('Recursion').' '; +html_print_checkbox( + 'recursion', + 1, + $recursion, + false, + false, + 'this.form.submit()' +); +echo ''; echo ''; echo __('Show Agents').' '; $fields = [ @@ -346,19 +359,6 @@ foreach ($pre_fields as $key => $value) { html_print_select($fields, 'os', $os, 'this.form.submit()', 'All', 0); -echo ''; - -echo ''; -echo __('Recursion').' '; -html_print_checkbox( - 'recursion', - 1, - $recursion, - false, - false, - 'this.form.submit()' -); - echo ''; echo __('Search').' '; html_print_input_text('search', $search, '', 12); diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php index 4eec189958..f17fbc0ccf 100644 --- a/pandora_console/godmode/agentes/planned_downtime.editor.php +++ b/pandora_console/godmode/agentes/planned_downtime.editor.php @@ -539,6 +539,12 @@ if ($id_downtime > 0) { // only action to postpone on once type is enabled and the other are disabled. $disabled_in_execution = (int) $running; +$return_all_group = false; + +if (users_can_manage_group_all('AW') === true || $disabled) { + $return_all_group = true; +} + $table = new StdClass(); $table->class = 'databox filters'; $table->width = '100%'; @@ -557,7 +563,7 @@ $table->data[1][0] = __('Group'); $table->data[1][1] = '
'.html_print_select_groups( false, $access, - true, + $return_all_group, 'id_group', $id_group, '', @@ -793,7 +799,7 @@ $table->width = '100%'; $table->data = []; $table->data[0][0] = __('Group filter'); -$table->data[0][1] = html_print_select_groups(false, $access, true, 'filter_group', $filter_group, '', '', '', true, false, true, '', false, 'min-width:180px;margin-right:15px;'); +$table->data[0][1] = html_print_select_groups(false, $access, $return_all_group, 'filter_group', $filter_group, '', '', '', true, false, true, '', false, 'min-width:180px;margin-right:15px;'); $table->data[0][2] = __('Recursion').'  '.html_print_checkbox('recursion', 1, $recursion, true, false, ''); $table->data[1][0] = __('Available agents'); diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 8b276d7233..068026c953 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -261,7 +261,7 @@ $table->data[2][1] = html_print_select_from_sql( 'id_command', $id_command, '', - __('None'), + '', 0, true, false, diff --git a/pandora_console/godmode/massive/massive_delete_agents.php b/pandora_console/godmode/massive/massive_delete_agents.php index e85a12486d..cc87efebed 100755 --- a/pandora_console/godmode/massive/massive_delete_agents.php +++ b/pandora_console/godmode/massive/massive_delete_agents.php @@ -140,7 +140,7 @@ function process_manage_delete($id_agents) } -$id_group = (int) get_parameter('id_group'); +$id_group = (is_metaconsole() === true) ? get_parameter('id_group', '') : (int) get_parameter('id_group'); $id_agents = get_parameter('id_agents'); $recursion = get_parameter('recursion'); $delete = (bool) get_parameter_post('delete'); @@ -282,15 +282,15 @@ $table->data[3][0] .= ''; -$agents = agents_get_group_agents( - array_keys(users_get_groups($config['id_user'], 'AW', false)), - ['disabled' => 2], - 'none', - false, - false, - is_metaconsole(), - '|' -); +$agents = []; +if (is_metaconsole() === false) { + $agents = agents_get_group_agents( + array_keys(users_get_groups($config['id_user'], 'AW', false)), + ['disabled' => 2], + 'none' + ); +} + $table->data[3][1] = html_print_select( $agents, diff --git a/pandora_console/godmode/massive/massive_delete_alerts.php b/pandora_console/godmode/massive/massive_delete_alerts.php index 39028789de..37961cded8 100755 --- a/pandora_console/godmode/massive/massive_delete_alerts.php +++ b/pandora_console/godmode/massive/massive_delete_alerts.php @@ -258,9 +258,9 @@ $table->style[0] = 'font-weight: bold;'; $table->style[2] = 'font-weight: bold;'; $table->size = []; $table->size[0] = '15%'; -$table->size[1] = '40%'; +$table->size[1] = '35%'; $table->size[2] = '15%'; -$table->size[3] = '40%'; +$table->size[3] = '35%'; $table->data = []; @@ -276,7 +276,12 @@ $table->data[0][1] = html_print_select( false, __('Select'), 0, - true + true, + false, + true, + '', + false, + 'width: 100%;' ); $table->data[0][2] = ''; $table->data[0][3] = ''; @@ -295,7 +300,8 @@ $table->data[1][1] = html_print_select_groups( false, true, '', - $id_alert_template == 0 + $id_alert_template == 0, + 'width: 100%;' ); $table->data[0][2] = __('Show alerts on disabled modules'); diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 73164c4c2f..c3734ca90f 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Copyright (c) 2005-2022 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 @@ -89,9 +89,9 @@ if ($update) { $agents_ = []; } - // If the option to select all of one group or module type is checked + // If the option to select all of one group or module type is checked. if ($force) { - if ($force == 'type') { + if ($force === 'type') { $type_condition = ''; if ($module_type != 0) { $type_condition = "AND tam.id_tipo_modulo = $module_type"; @@ -109,7 +109,7 @@ if ($update) { $agents_ = []; } - // Create an array of agent ids + // Create an array of agent ids. $agents_ = extract_column($agents_, 'id_agente'); foreach ($agents_ as $id_agent) { @@ -136,7 +136,7 @@ if ($update) { if ($success == 0) { $error_msg = __('Error updating the modules from a module type'); } - } else if ($force == 'group') { + } else if ($force === 'group') { $agents_ = array_keys(agents_get_group_agents($group_select, false, 'none')); foreach ($agents_ as $id_agent) { @@ -2226,28 +2226,30 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' $values['quiet'] = get_parameter('quiet_select'); } - $filter_modules = false; - - if (!is_numeric($module_name) or ($module_name != 0)) { - $filter_modules['nombre'] = $module_name; - } - - // Whether to update module tag info + // Whether to update module tag info. $update_tags = get_parameter('id_tag', false); if (array_search(0, $agents_select) !== false) { - // Apply at All agents. - $modules = db_get_all_rows_filter( - 'tagente_modulo', - $filter_modules, - [ - 'id_agente_modulo', - 'id_tipo_modulo', - ] + if (is_numeric($module_name) === false || ($module_name !== 0)) { + $filterModules = sprintf('AND tam.nombre = \'%s\'', $module_name); + } else { + $filterModules = ''; + } + + // Apply at All agents (within valid groups). + $modules = db_get_all_rows_sql( + sprintf( + 'SELECT tam.id_agente_modulo, tam.id_tipo_modulo + FROM tagente_modulo tam INNER JOIN tagente ta + ON ta.id_agente = tam.id_agente + WHERE ta.id_grupo IN (%s) %s;', + implode(',', array_keys(users_get_groups())), + $filterModules + ) ); } else { - if ($module_name == '0') { - // Any module + if ($module_name === '0') { + // Any module. $modules = db_get_all_rows_filter( 'tagente_modulo', ['id_agente' => $agents_select], @@ -2275,12 +2277,12 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' return false; } - if (($module_status == 'unknown') && ($module_name == '0')) { + if (($module_status === 'unknown') && ($module_name == '0')) { $modules_to_delete = []; foreach ($modules as $mod_id) { $mod_status = (int) db_get_value_filter('estado', 'tagente_estado', ['id_agente_modulo' => $mod_id]); - // Unknown, not init and no data modules + // Unknown, not init and no data modules. if ($mod_status == 3 || $mod_status == 4 || $mod_status == 5) { $modules_to_delete[$mod_id] = $mod_id; } diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index aeecc25273..bb43ad0df5 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -525,21 +525,21 @@ $menu_godmode['links']['sub'] = $sub; // Update Manager if (check_acl($config['id_user'], 0, 'PM') && $config['enable_update_manager']) { - $menu_godmode['messages']['text'] = __('Update manager'); + $menu_godmode['messages']['text'] = __('Warp Update'); $menu_godmode['messages']['id'] = 'god-um_messages'; $menu_godmode['messages']['sec2'] = ''; $sub = []; - $sub['godmode/update_manager/update_manager&tab=offline']['text'] = __('Update Manager offline'); + $sub['godmode/update_manager/update_manager&tab=offline']['text'] = __('Update offline'); $sub['godmode/update_manager/update_manager&tab=offline']['id'] = 'Offline'; - $sub['godmode/update_manager/update_manager&tab=online']['text'] = __('Update Manager online'); + $sub['godmode/update_manager/update_manager&tab=online']['text'] = __('Update online'); $sub['godmode/update_manager/update_manager&tab=online']['id'] = 'Online'; - $sub['godmode/update_manager/update_manager&tab=setup']['text'] = __('Update Manager options'); + $sub['godmode/update_manager/update_manager&tab=setup']['text'] = __('Options'); $sub['godmode/update_manager/update_manager&tab=setup']['id'] = 'Options'; - $sub['godmode/update_manager/update_manager&tab=history']['text'] = __('Update Manager journal'); + $sub['godmode/update_manager/update_manager&tab=history']['text'] = __('Warp journal'); $sub['godmode/update_manager/update_manager&tab=history']['id'] = 'Journal'; $menu_godmode['messages']['sub'] = $sub; diff --git a/pandora_console/godmode/modules/manage_network_components_form_wizard.php b/pandora_console/godmode/modules/manage_network_components_form_wizard.php index 0fa9d763c5..15b8f2a508 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_wizard.php +++ b/pandora_console/godmode/modules/manage_network_components_form_wizard.php @@ -178,6 +178,7 @@ switch ($type) { break; } +$query_filter = []; if (empty($query_filter) === false) { $query_filter = json_decode($query_filter, true); } diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 724d695f6a..6a8ea04e0f 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -606,6 +606,7 @@ switch ($action) { $event_graph_by_criticity = $style['event_graph_by_criticity']; $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; $include_extended_events = $item['show_extended_events']; + $custom_data_events = $style['custom_data_events']; $filter_search = $style['event_filter_search']; $filter_exclude = $style['event_filter_exclude']; @@ -631,6 +632,7 @@ switch ($action) { $include_extended_events = $item['show_extended_events']; + $custom_data_events = $style['custom_data_events']; break; case 'event_report_module': @@ -665,6 +667,7 @@ switch ($action) { $include_extended_events = $item['show_extended_events']; + $custom_data_events = $style['custom_data_events']; break; case 'general': @@ -2911,6 +2914,23 @@ $class = 'databox filters'; + + + + + + + + + @@ -5974,6 +5994,7 @@ function chooseType() { $("#row_event_graph_by_criticity").hide(); $("#row_event_graph_by_validated").hide(); $("#row_extended_events").hide(); + $("#row_custom_data_events").hide(); $("#row_netflow_filter").hide(); $("#row_max_values").hide(); $("#row_resolution").hide(); @@ -6044,6 +6065,7 @@ function chooseType() { $("#row_event_graph_by_criticity").show(); $("#row_event_graph_by_validated").show(); $("#row_extended_events").show(); + $("#row_custom_data_events").show(); $("#row_filter_search").show(); $("#row_filter_exclude").show(); @@ -6371,6 +6393,7 @@ function chooseType() { $("#row_event_graph_by_validated").show(); $("#row_event_type").show(); $("#row_extended_events").show(); + $("#row_custom_data_events").show(); $("#row_filter_search").show(); $("#row_filter_exclude").show(); @@ -6389,7 +6412,7 @@ function chooseType() { $("#row_event_graphs").show(); $("#row_event_type").show(); $("#row_extended_events").show(); - $("#row_extended_events").show(); + $("#row_custom_data_events").show(); $("#row_event_graph_by_user").show(); $("#row_event_graph_by_criticity").show(); @@ -6414,6 +6437,7 @@ function chooseType() { $("#row_event_graphs").show(); $("#row_event_type").show(); $("#row_extended_events").show(); + $("#row_custom_data_events").show(); $("#row_event_graph_by_user").show(); $("#row_event_graph_by_criticity").show(); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 608f2f6a54..94c9e0b454 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2224,12 +2224,18 @@ switch ($action) { $filter_event_status ); + $custom_data_events = get_parameter_switch( + 'custom_data_events', + 0 + ); + $style['event_graph_by_agent'] = $event_graph_by_agent; $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; $style['event_filter_search'] = $event_filter_search; $style['event_filter_exclude'] = $event_filter_exclude; + $style['custom_data_events'] = $custom_data_events; if ($label != '') { @@ -2957,6 +2963,11 @@ switch ($action) { '' ); + $custom_data_events = get_parameter_switch( + 'custom_data_events', + 0 + ); + // Added for events items. $style['show_summary_group'] = $show_summary_group; @@ -2976,6 +2987,7 @@ switch ($action) { $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; $style['event_filter_search'] = $event_filter_search; $style['event_filter_exclude'] = $event_filter_exclude; + $style['custom_data_events'] = $custom_data_events; if ($label != '') { $style['label'] = $label; diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index ad74c490c2..8c41cdda18 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -256,16 +256,18 @@ $table->style[0] = 'font-weight: bold'; $table->size[0] = '70%'; $table->size[1] = '30%'; -// enterprise_hook('enterprise_warnings_history_days'); $table->data[1][0] = __('Max. days before delete events'); - -$table->data[1][1] = html_print_input_text( - 'event_purge', - $config['event_purge'], - '', - 5, - 5, - true +$table->data[1][1] = html_print_input( + [ + 'type' => 'number', + 'size' => 5, + 'max' => 99999, + 'name' => 'event_purge', + 'value' => $config['event_purge'], + 'return' => true, + 'min' => ((((bool) $config['history_event_enabled'] === true) && $config['history_event_days'] > 0) ? $config['history_event_days'] + 1 : null), + 'style' => 'width:43px', + ] ); $table->data[2][0] = __('Max. days before delete traps'); diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index 6829d445e1..35fcaf172c 100755 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -1,8 +1,20 @@ __('Other'), ]; -// Form submitted -// ============= +// Form submitted. $update_alert = (bool) get_parameter('update_alert', false); $create_alert = (bool) get_parameter('create_alert', false); $save_alert = (bool) get_parameter('save_alert', false); $modify_alert = (bool) get_parameter('modify_alert', false); $delete_alert = (bool) get_parameter('delete_alert', false); $multiple_delete = (bool) get_parameter('multiple_delete', false); -$add_action = (bool) get_parameter('add_alert', 0); +$add_action = (bool) get_parameter('add_alert', false); $delete_action = get_parameter('delete_action', 0); $duplicate_alert = get_parameter('duplicate_alert', 0); -if ($add_action) { +if ($add_action === true) { $values['id_alert_snmp'] = (int) get_parameter('id_alert_snmp'); $values['alert_type'] = (int) get_parameter('alert_type'); $values[db_escape_key_identifier('al_field1')] = get_parameter('field1_value'); @@ -79,37 +91,41 @@ if ($delete_action) { } if ($update_alert || $modify_alert) { - ui_print_page_header( - __('SNMP Console').' » '.__('Update alert'), - 'images/op_snmp.png', - false, - 'snmp_alert_update_tab', - false - ); + $subTitle = __('Update alert'); + $helpString = 'snmp_alert_update_tab'; } else if ($create_alert || $save_alert) { - ui_print_page_header( - __('SNMP Console').' » '.__('Create alert'), - 'images/op_snmp.png', - false, - 'snmp_alert_overview_tab', - false - ); + $subTitle = __('Create alert'); + $helpString = 'snmp_alert_overview_tab'; } else { - ui_print_page_header( - __('SNMP Console').' » '.__('Alert overview'), - 'images/op_snmp.png', - false, - '', - false - ); + $subTitle = __('Alert overview'); + $helpString = ''; } +ui_print_standard_header( + $subTitle, + 'images/op_snmp.png', + false, + $helpString, + false, + [], + [ + [ + 'link' => '', + 'label' => __('Alerts'), + ], + [ + 'link' => '', + 'label' => __('SNMP Console'), + ], + ] +); + if ($save_alert || $modify_alert) { $id_as = (int) get_parameter('id_alert_snmp', -1); $source_ip = (string) get_parameter_post('source_ip'); $alert_type = (int) get_parameter_post('alert_type'); - // Event, e-mail + // Event, e-mail. $description = (string) get_parameter_post('description'); $oid = (string) get_parameter_post('oid'); $custom_value = (string) get_parameter_post('custom_value'); @@ -269,7 +285,7 @@ if ($save_alert || $modify_alert) { $result = db_process_sql_insert('talert_snmp', $values); - if (!$result) { + if ((bool) $result === false) { db_pandora_audit( AUDIT_LOG_SNMP_MANAGEMENT, 'Fail try to create snmp alert' @@ -278,7 +294,10 @@ if ($save_alert || $modify_alert) { } else { db_pandora_audit( AUDIT_LOG_SNMP_MANAGEMENT, - "Create snmp alert #$result" + sprintf( + 'Create snmp alert #%s', + $result + ) ); ui_print_success_message(__('Successfully created')); } @@ -405,24 +424,29 @@ if ($save_alert || $modify_alert) { $result = db_process_sql($sql); - if (!$result) { + if ((bool) $result === false) { db_pandora_audit( AUDIT_LOG_SNMP_MANAGEMENT, - "Fail try to update snmp alert #$id_as" + sprintf( + 'Fail try to update snmp alert #%s', + $id_as + ) ); ui_print_error_message(__('There was a problem updating the alert')); } else { db_pandora_audit( AUDIT_LOG_SNMP_MANAGEMENT, - "Update snmp alert #$id_as" + sprintf( + 'Update snmp alert #%s', + $id_as + ) ); ui_print_success_message(__('Successfully updated')); } } } -// From variable init -// ================== +// From variable init. if ($update_alert || $duplicate_alert) { $id_as = (int) get_parameter('id_alert_snmp', -1); @@ -516,11 +540,11 @@ if ($update_alert || $duplicate_alert) { return; } } else if ($create_alert) { - // Variable init + // Variable init. $id_as = -1; $source_ip = ''; $alert_type = 1; - // Event, e-mail + // Event, e-mail. $description = ''; $oid = ''; $custom_value = ''; @@ -595,40 +619,46 @@ if ($update_alert || $duplicate_alert) { $group = 0; } -// Duplicate alert snmp +// Duplicate alert snmp. if ($duplicate_alert) { $values_duplicate = $alert; - if (!empty($values_duplicate)) { + if (empty($values_duplicate) === false) { unset($values_duplicate['id_as']); $result = db_process_sql_insert('talert_snmp', $values_duplicate); if (!$result) { db_pandora_audit( AUDIT_LOG_SNMP_MANAGEMENT, - "Fail try to duplicate snmp alert #$id_as" + sprintf( + 'Fail try to duplicate snmp alert #%s', + $id_as + ) ); ui_print_error_message(__('There was a problem duplicating the alert')); } else { db_pandora_audit( AUDIT_LOG_SNMP_MANAGEMENT, - "Duplicate snmp alert #$id_as" + sprintf( + 'Duplicate snmp alert #%s', + $id_as + ) ); ui_print_success_message(__('Successfully Duplicate')); } } else { db_pandora_audit( AUDIT_LOG_SNMP_MANAGEMENT, - "Fail try to duplicate snmp alert #$id_as" + sprintf( + 'Fail try to duplicate snmp alert #%s', + $id_as + ) ); ui_print_error_message(__('There was a problem duplicating the alert')); } } -// Header -// Alert Delete -// ============= if ($delete_alert) { - // Delete alert + // Delete alert. $alert_delete = (int) get_parameter_get('delete_alert', 0); $result = db_process_sql_delete( @@ -639,13 +669,19 @@ if ($delete_alert) { if ($result === false) { db_pandora_audit( AUDIT_LOG_SNMP_MANAGEMENT, - "Fail try to delete snmp alert #$alert_delete" + sprintf( + 'Fail try to delete snmp alert #%s', + $alert_delete + ) ); ui_print_error_message(__('There was a problem deleting the alert')); } else { db_pandora_audit( AUDIT_LOG_SNMP_MANAGEMENT, - "Delete snmp alert #$alert_delete" + sprintf( + 'Delete snmp alert #%s', + $alert_delete + ) ); ui_print_success_message(__('Successfully deleted')); } @@ -666,18 +702,24 @@ if ($multiple_delete) { if ($result !== false) { db_pandora_audit( AUDIT_LOG_SNMP_MANAGEMENT, - "Delete snmp alert #$alert_delete" + sprintf( + 'Delete snmp alert #%s', + $alert_delete + ) ); $count++; } else { db_pandora_audit( AUDIT_LOG_SNMP_MANAGEMENT, - "Fail try to delete snmp alert #$alert_delete" + sprintf( + 'Fail try to delete snmp alert #%s', + $alert_delete + ) ); } } - if ($count == $total) { + if ($count === $total) { ui_print_success_message( __('Successfully deleted alerts (%s / %s)', $count, $total) ); @@ -692,7 +734,7 @@ $user_groups = users_get_groups($config['id_user'], 'AR', true); $str_user_groups = ''; $i = 0; foreach ($user_groups as $id => $name) { - if ($i == 0) { + if ($i === 0) { $str_user_groups .= $id; } else { $str_user_groups .= ','.$id; @@ -701,10 +743,9 @@ foreach ($user_groups as $id => $name) { $i++; } -// Alert form +// Alert form. if ($create_alert || $update_alert) { - // if (isset ($_GET["update_alert"])) { - // the update_alert means the form should be displayed. If update_alert > 1 then an existing alert is updated + // The update_alert means the form should be displayed. If update_alert > 1 then an existing alert is updated. echo '
'; html_print_input_hidden('id_alert_snmp', $id_as); @@ -717,32 +758,39 @@ if ($create_alert || $update_alert) { html_print_input_hidden('modify_alert', 1); } - // SNMP alert filters + // SNMP alert filters. echo ''; - // Description - echo ''.''.''.''; + // Description. + echo ''; + echo ''; + echo ''; + echo ''; - // echo ''; - // OID - echo ''.''.''; + echo ''; + echo ''; + echo ''; + echo ''; - // Custom + // Custom. echo ''; + echo ''; + echo ''; - // SNMP Agent + // SNMP Agent. echo ''; + echo ''; + echo ''; $return_all_group = false; @@ -750,7 +798,7 @@ if ($create_alert || $update_alert) { $return_all_group = true; } - // Group + // Group. echo ''; + echo ''; + echo ''; - // Trap type + // Trap type. echo ''; + echo ''; + echo ''; - // Single value + // Single value. echo ''; + echo ''; + echo ''; - // Variable bindings/Data #1 - echo ''.''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #2 - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #3 - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #4 - echo ''.''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #5 - echo ''.''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #6 - echo ''.''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #7 - echo ''.''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #8 - echo ''.''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #9 - echo ''.''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #10 - echo ''.''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #11 - echo ''.''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #12 - echo ''.''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #13 - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #14 - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #15 - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #16 - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #17 - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #18 - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #19 - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; - // Variable bindings/Data #20 - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; - // Alert fields + // Alert fields. $al = [ 'al_field1' => $al_field1, 'al_field2' => $al_field2, @@ -974,7 +1061,7 @@ if ($create_alert || $update_alert) { 'al_field20' => $al_field20, ]; - // Hidden div with help hint to fill with javascript + // Hidden div with help hint to fill with javascript. html_print_div(['id' => 'help_snmp_alert_hint', 'content' => ui_print_help_icon('snmp_alert_field1', true), 'hidden' => true]); for ($i = 1; $i <= $config['max_macro_fields']; $i++) { @@ -984,7 +1071,7 @@ if ($create_alert || $update_alert) { echo ''; } - // Max / Min alerts + // Max / Min alerts. echo ''; - // Time Threshold + // Time Threshold. echo ''; - // Priority + // Priority. echo ''; @@ -1048,10 +1135,11 @@ if ($create_alert || $update_alert) { echo "
'.__('Description').''; - html_print_textarea('description', 3, 2, $description, 'class="w400px"'); - echo '
'.__('Description').''; + html_print_textarea('description', 3, 2, $description, 'class="w400px"'); + echo '
' . __('Alert filters') . ui_print_help_icon("snmp_alert_filters", true) . '
'.__('Enterprise String').ui_print_help_tip(__('Matches substrings. End the string with $ for exact matches.'), true).''; + // OID. + echo '
'.__('Enterprise String').ui_print_help_tip(__('Matches substrings. End the string with $ for exact matches.'), true).''; html_print_input_text('oid', $oid, '', 50, 255); - echo '
'.__('Custom Value/OID'); echo ''; html_print_textarea('custom_value', 2, 2, $custom_value, 'class="w400px"'); - echo '
'.__('SNMP Agent').' (IP)'; html_print_input_text('source_ip', $source_ip, '', 20); - echo '
'.__('Group').''; echo '
'; html_print_select_groups( @@ -774,183 +822,222 @@ if ($create_alert || $update_alert) { false ); echo '
'; - echo '
'.__('Trap type').''; echo html_print_select($trap_types, 'trap_type', $trap_type, '', '', '', false, false, false); - echo '
'.__('Single value').''; html_print_input_text('single_value', $single_value, '', 20); - echo '
'.__('Variable bindings/Data').''; + // Variable bindings/Data #1. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_1', $order_1, '', 4); html_print_input_text('custom_oid_data_1', $custom_oid_data_1, '', 60); - echo '
'.__('Variable bindings/Data'); - // echo ui_print_help_icon ("snmp_alert_custom", true); - echo ''; + // Variable bindings/Data #2. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_2', $order_2, '', 4); html_print_input_text('custom_oid_data_2', $custom_oid_data_2, '', 60); - echo '
'.__('Variable bindings/Data'); - // echo ui_print_help_icon ("snmp_alert_custom", true); - echo ''; + // Variable bindings/Data #3. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_3', $order_3, '', 4); html_print_input_text('custom_oid_data_3', $custom_oid_data_3, '', 60); - echo '
'.__('Variable bindings/Data'); - // echo ui_print_help_icon ("snmp_alert_custom", true); - echo ''; + // Variable bindings/Data #4. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_4', $order_4, '', 4); html_print_input_text('custom_oid_data_4', $custom_oid_data_4, '', 60); - echo '
'.__('Variable bindings/Data'); - // echo ui_print_help_icon ("snmp_alert_custom", true); - echo ''; + // Variable bindings/Data #5. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_5', $order_5, '', 4); html_print_input_text('custom_oid_data_5', $custom_oid_data_5, '', 60); - echo '
'.__('Variable bindings/Data'); - // echo ui_print_help_icon ("snmp_alert_custom", true); - echo ''; + // Variable bindings/Data #6. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_6', $order_6, '', 4); html_print_input_text('custom_oid_data_6', $custom_oid_data_6, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #7. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_7', $order_7, '', 4); html_print_input_text('custom_oid_data_7', $custom_oid_data_7, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #8. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_8', $order_8, '', 4); html_print_input_text('custom_oid_data_8', $custom_oid_data_8, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #9. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_9', $order_9, '', 4); html_print_input_text('custom_oid_data_9', $custom_oid_data_9, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #10. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_10', $order_10, '', 4); html_print_input_text('custom_oid_data_10', $custom_oid_data_10, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #11. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_11', $order_11, '', 4); html_print_input_text('custom_oid_data_11', $custom_oid_data_11, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #12. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_12', $order_12, '', 4); html_print_input_text('custom_oid_data_12', $custom_oid_data_12, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #13. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_13', $order_13, '', 4); html_print_input_text('custom_oid_data_13', $custom_oid_data_13, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #14. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_14', $order_14, '', 4); html_print_input_text('custom_oid_data_14', $custom_oid_data_14, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #15. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_15', $order_15, '', 4); html_print_input_text('custom_oid_data_15', $custom_oid_data_15, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #16. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_16', $order_16, '', 4); html_print_input_text('custom_oid_data_16', $custom_oid_data_16, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #17. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_17', $order_17, '', 4); html_print_input_text('custom_oid_data_17', $custom_oid_data_17, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #18. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_18', $order_18, '', 4); html_print_input_text('custom_oid_data_18', $custom_oid_data_18, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #19. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_19', $order_19, '', 4); html_print_input_text('custom_oid_data_19', $custom_oid_data_19, '', 60); - echo '
'.__('Variable bindings/Data'); - echo ''; + // Variable bindings/Data #20. + echo '
'.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_20', $order_20, '', 4); html_print_input_text('custom_oid_data_20', $custom_oid_data_20, '', 60); - echo '
'.__('Min. number of alerts').''; html_print_input_text('min_alerts', $min_alerts, '', 3); @@ -992,7 +1079,7 @@ if ($create_alert || $update_alert) { html_print_input_text('max_alerts', $max_alerts, '', 3); echo '
'.__('Time threshold').''; $fields = []; @@ -1014,7 +1101,7 @@ if ($create_alert || $update_alert) { html_print_input_text('time_other', 0, '', 6); echo ' '.__('seconds').'
'.__('Priority').''; echo html_print_select(get_priorities(), 'priority', $priority, '', '', '0', false, false, false); echo '
"; echo '
'; + html_print_button(__('Back'), 'button_back', false, '', 'class="sub cancel margin-right-05"'); if ($id_as > 0) { - html_print_submit_button(__('Update'), 'submit', false, 'class="sub upd"', false); + html_print_submit_button(__('Update'), 'submit', false, 'class="sub upd"'); } else { - html_print_submit_button(__('Create'), 'submit', false, 'class="sub wand"', false); + html_print_submit_button(__('Create'), 'submit', false, 'class="sub wand"'); } echo '
'; @@ -1089,119 +1177,68 @@ if ($create_alert || $update_alert) { $form_filter .= '
'; $form_filter .= ''; - // echo "
"; ui_toggle($form_filter, __('Alert SNMP control filter'), __('Toggle filter(s)')); $filter = []; $offset = (int) get_parameter('offset'); $limit = (int) $config['block_size']; if ($filter_param) { - // Move the first page + // Move the first page. $offset = 0; - $url_pagination = 'index.php?'.'sec=snmpconsole&'.'sec2=godmode/snmpconsole/snmp_alert&'.'free_search='.$free_search.'&'.'trap_type_filter='.$trap_type_filter.'&'.'priority_filter='.$priority_filter; + $url_pagination = 'index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_alert&free_search='.$free_search.'&trap_type_filter='.$trap_type_filter.'&priority_filter='.$priority_filter; } else { - $url_pagination = 'index.php?'.'sec=snmpconsole&'.'sec2=godmode/snmpconsole/snmp_alert&'.'free_search='.$free_search.'&'.'trap_type_filter='.$trap_type_filter.'&'.'priority_filter='.$priority_filter.'&'.'offset='.$offset; + $url_pagination = 'index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_alert&free_search='.$free_search.'&trap_type_filter='.$trap_type_filter.'&priority_filter='.$priority_filter.'&offset='.$offset; } $where_sql = ''; - if (!empty($free_search)) { - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - // $where_sql = ' 1 = 1'; - if ($trap_type_filter != SNMP_TRAP_TYPE_NONE) { - $where_sql .= ' AND `trap_type` = '.$trap_type_filter; - } - - if ($priority_filter != -1) { - $where_sql .= ' AND `priority` = '.$priority_filter; - } - - $where_sql .= " AND (`single_value` LIKE '%".$free_search."%' - OR `_snmp_f10_` LIKE '%".$free_search."%' - OR `_snmp_f9_` LIKE '%".$free_search."%' - OR `_snmp_f8_` LIKE '%".$free_search."%' - OR `_snmp_f7_` LIKE '%".$free_search."%' - OR `_snmp_f6_` LIKE '%".$free_search."%' - OR `_snmp_f5_` LIKE '%".$free_search."%' - OR `_snmp_f4_` LIKE '%".$free_search."%' - OR `_snmp_f3_` LIKE '%".$free_search."%' - OR `_snmp_f2_` LIKE '%".$free_search."%' - OR `_snmp_f1_` LIKE '%".$free_search."%' - OR `oid` LIKE '%".$free_search."%' - OR `custom_oid` LIKE '%".$free_search."%' - OR `agent` LIKE '%".$free_search."%' - OR `description` LIKE '%".$free_search."%')"; - break; - - case 'oracle': - // $where_sql = ' 1 = 1'; - if ($trap_type_filter != SNMP_TRAP_TYPE_NONE) { - $where_sql .= ' AND trap_type = '.$trap_type_filter; - } - - if ($priority_filter != -1) { - $where_sql .= ' AND priority = '.$priority_filter; - } - - $where_sql .= " AND (single_value LIKE '%".$free_search."%' - OR \"_snmp_f10_\" LIKE '%".$free_search."%' - OR \"_snmp_f9_\" LIKE '%".$free_search."%' - OR \"_snmp_f8_\" LIKE '%".$free_search."%' - OR \"_snmp_f7_\" LIKE '%".$free_search."%' - OR \"_snmp_f6_\" LIKE '%".$free_search."%' - OR \"_snmp_f5_\" LIKE '%".$free_search."%' - OR \"_snmp_f4_\" LIKE '%".$free_search."%' - OR \"_snmp_f3_\" LIKE '%".$free_search."%' - OR \"_snmp_f2_\" LIKE '%".$free_search."%' - OR \"_snmp_f1_\" LIKE '%".$free_search."%' - OR oid LIKE '%".$free_search."%' - OR custom_oid LIKE '%".$free_search."%' - OR agent LIKE '%".$free_search."%' - OR description LIKE '%".$free_search."%')"; - break; + if (empty($free_search) === false) { + if ($trap_type_filter != SNMP_TRAP_TYPE_NONE) { + $where_sql .= ' AND `trap_type` = '.$trap_type_filter; } + + if ($priority_filter != -1) { + $where_sql .= ' AND `priority` = '.$priority_filter; + } + + $where_sql .= " AND (`single_value` LIKE '%".$free_search."%' + OR `_snmp_f10_` LIKE '%".$free_search."%' + OR `_snmp_f9_` LIKE '%".$free_search."%' + OR `_snmp_f8_` LIKE '%".$free_search."%' + OR `_snmp_f7_` LIKE '%".$free_search."%' + OR `_snmp_f6_` LIKE '%".$free_search."%' + OR `_snmp_f5_` LIKE '%".$free_search."%' + OR `_snmp_f4_` LIKE '%".$free_search."%' + OR `_snmp_f3_` LIKE '%".$free_search."%' + OR `_snmp_f2_` LIKE '%".$free_search."%' + OR `_snmp_f1_` LIKE '%".$free_search."%' + OR `oid` LIKE '%".$free_search."%' + OR `custom_oid` LIKE '%".$free_search."%' + OR `agent` LIKE '%".$free_search."%' + OR `description` LIKE '%".$free_search."%')"; } - $count = db_get_value_sql( - "SELECT COUNT(*) - FROM talert_snmp WHERE id_group IN ($str_user_groups) ".$where_sql + $count = (int) db_get_value_sql( + 'SELECT COUNT(*) + FROM talert_snmp WHERE id_group IN ('.$str_user_groups.') '.$where_sql ); $result = []; - // Overview - if ($count == 0) { + // Overview. + if ($count === 0) { $result = []; ui_print_info_message(['no_close' => true, 'message' => __('There are no SNMP alerts') ]); } else { ui_pagination($count, $url_pagination); - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - $where_sql .= ' LIMIT '.$limit.' OFFSET '.$offset; - $result = db_get_all_rows_sql( - "SELECT * - FROM talert_snmp - WHERE id_group IN ($str_user_groups) ".$where_sql - ); - break; - case 'oracle': - $sql = "SELECT * - FROM talert_snmp - WHERE id_group IN ($str_user_groups) ".$where_sql; - $set = []; - if (isset($offset) && isset($limit)) { - $set['limit'] = $limit; - $set['offset'] = $offset; - } - - $result = oracle_recode_query($sql, $set, 'AND', false); - break; - } + $where_sql .= ' LIMIT '.$limit.' OFFSET '.$offset; + $result = db_get_all_rows_sql( + 'SELECT * + FROM talert_snmp + WHERE id_group IN ('.$str_user_groups.') '.$where_sql + ); } $table = new stdClass(); @@ -1250,7 +1287,7 @@ if ($create_alert || $update_alert) { $data = []; $data[0] = $row['position']; - $url = 'index.php?'.'sec=snmpconsole&'.'sec2=godmode/snmpconsole/snmp_alert&'.'id_alert_snmp='.$row['id_as'].'&'.'update_alert=1'; + $url = 'index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_alert&id_alert_snmp='.$row['id_as'].'&update_alert=1'; $data[1] = ''; $data[1] .= ''; @@ -1281,50 +1318,86 @@ if ($create_alert || $update_alert) { } $data[1] .= '
'; - - $data[2] = $row['agent']; $data[3] = $row['oid']; $data[4] = $row['custom_oid']; $data[5] = $row['description']; $data[6] = $row['times_fired']; - if (($row['last_fired'] != '1970-01-01 00:00:00') and ($row['last_fired'] != '01-01-1970 00:00:00')) { + if (($row['last_fired'] !== '1970-01-01 00:00:00') && ($row['last_fired'] !== '01-01-1970 00:00:00')) { $data[7] = ui_print_timestamp($row['last_fired'], true); } else { $data[7] = __('Never'); } - if (check_acl_restricted_all($config['id_user'], $row['id_group'], 'LW')) { - $data[8] = ''.html_print_image( - 'images/copy.png', - true, - [ - 'alt' => __('Duplicate'), - 'title' => __('Duplicate'), - ] - ).''.''.html_print_image( - 'images/config.png', - true, - [ - 'border' => '0', - 'alt' => __('Update'), - ] - ).''.''.html_print_image( - 'images/add.png', - true, - [ - 'title' => __('Add action'), - ] - ).''.''.html_print_image( - 'images/cross.png', - true, - [ - 'border' => '0', - 'alt' => __('Delete'), - ] - ).''; + $data[8] = ''; + $data[9] = ''; + if ((bool) check_acl_restricted_all($config['id_user'], $row['id_group'], 'LW') === true) { + $data[8] = html_print_anchor( + [ + 'href' => sprintf( + 'index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_alert&duplicate_alert=1&id_alert_snmp=%s', + $row['id_as'] + ), + 'content' => html_print_image( + 'images/copy.png', + true, + [ + 'alt' => __('Duplicate'), + 'title' => __('Duplicate'), + ] + ), + ], + true + ); + $data[8] .= html_print_anchor( + [ + 'href' => sprintf( + 'index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_alert&update_alert=1&id_alert_snmp=%s', + $row['id_as'] + ), + 'content' => html_print_image( + 'images/config.png', + true, + [ + 'alt' => __('Update'), + 'border' => 0, + ] + ), + ], + true + ); + $data[8] .= html_print_anchor( + [ + 'href' => sprintf( + 'javascript:show_add_action_snmp(\'%s\');"', + $row['id_as'] + ), + 'content' => html_print_image( + 'images/add.png', + true, + [ + 'title' => __('Add action'), + ] + ), + ], + true + ); + $data[8] .= html_print_anchor( + [ + 'href' => 'javascript: ', + 'content' => html_print_image( + 'images/cross.png', + true, + [ + 'title' => __('Delete action'), + ] + ), + 'onClick' => 'delete_snmp_alert('.$row['id_as'].')', + ], + true + ); $data[9] = html_print_checkbox_extended( 'delete_ids[]', @@ -1335,71 +1408,47 @@ if ($create_alert || $update_alert) { 'class="chk_delete"', true ); - } else { - $data[8] = ''; - $data[9] = ''; } $idx = count($table->data); - // The current index of the table is 1 less than the count of table data so we count before adding to table->data + // The current index of the table is 1 less than the count of table data so we count before adding to table->data. array_push($table->data, $data); $table->rowclass[$idx] = get_priority_class($row['priority']); } - // DIALOG ADD MORE ACTIONS + // DIALOG ADD MORE ACTIONS. echo '