Merge branch 'develop' into 'ent-7184-duplicate-web-server-module'

# Conflicts:
#   pandora_console/include/functions_modules.php
This commit is contained in:
José González 2021-05-05 07:37:02 +00:00
commit 385366a9e1
221 changed files with 27967 additions and 21963 deletions

View File

@ -0,0 +1,169 @@
#!/bin/bash
#export PANDORA_SERVER_IP='newdemos.artica.es' && curl -sSL http://firefly.artica.es/projects/pandora_deploy_agent.sh | bash
# define variables
PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
S_VERSION='2021012801'
LOGFILE="/tmp/pandora-agent-deploy-$(date +%F).log"
# Ansi color code variables
red="\e[0;91m"
green="\e[0;92m"
bold="\e[1m"
cyan="\e[0;36m"
yellow="\e[0;33m"
reset="\e[0m"
# Functions
execute_cmd () {
local cmd="$1"
local msg="$2"
echo -e "${cyan}$msg...${reset}"
$cmd &>> $LOGFILE
if [ $? -ne 0 ]; then
echo -e "${red}Fail${reset}"
[[ $3 ]] && echo "$3 "
echo "Error installing Pandora FMS Agent for detailed error please check log: $LOGFILE"
rm -rf $HOME/pandora_deploy_tmp &>> $LOGFILE
exit 1
else
echo -e "\e[1A\e ${cyan}$msg...${reset} ${green}OK${reset}"
return 0
fi
}
check_cmd_status () {
if [ $? -ne 0 ]; then
echo -e "${red}Fail${reset}"
[ "$1" ] && echo "$1"
echo "Error installing Pandora FMS Agent for detailed error please check log: $LOGFILE"
rm -rf $HOME/pandora_deploy_tmp/*.rpm* &>> $LOGFILE
exit 1
else
echo -e "${green}OK${reset}"
return 0
fi
}
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"
}
check_root_permissions () {
echo -en "${cyan}Checking root account... ${reset}"
if [ "$(whoami)" != "root" ]; then
echo -e "${red}Fail${reset}"
echo "Please use a root account or sudo for installing PandoraFMS"
echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE"
exit 1
else
echo -e "${green}OK${reset}"
fi
}
install_autodiscover () {
local arch=$1
wget https://pandorafms.com/library/wp-content/uploads/2020/04/autodiscover-linux.zip
unzip autodiscover-linux.zip
chmod +x $arch/autodiscover
mv -f $arch/autodiscover /etc/pandora/plugins/autodiscover
}
## Main
echo "Starting PandoraFMS Agent deployment ver. $S_VERSION"
execute_cmd "[ $PANDORA_SERVER_IP ]" 'Check Server IP Address' 'Please define env variable PANDORA_SERVER_IP'
# 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 fedora' ]] && OS_RELEASE=$OS
[[ $OS == 'centos rhel fedora' ]] && OS_RELEASE=$OS
[[ $OS == 'debian' ]] && OS_RELEASE=$OS
# initialice logfile
execute_cmd "echo 'Starting community deployment' > $LOGFILE" "All installer activity is logged on $LOGFILE"
echo "Community installer version: $S_VERSION" >> $LOGFILE
# Pre checks
echo -en "${cyan}Checking compatible OS... ${reset}"
[[ $OS_RELEASE ]]
check_cmd_status "Error not compatible OS, $OS"
# Root permisions
check_root_permissions
# Connectivity
check_repo_connection
# Execute tools check
execute_cmd "grep --version" 'Checking needed tools: grep'
execute_cmd "sed --version" 'Checking needed tools: sed'
# Creating working directory
rm -rf $HOME/pandora_deploy_tmp/ &>> $LOGFILE
mkdir $HOME/pandora_deploy_tmp &>> $LOGFILE
execute_cmd "cd $HOME/pandora_deploy_tmp" "Moving to workspace: $HOME/pandora_deploy_tmp"
# Downloading and installing packages
if [[ $OS_RELEASE == 'rhel fedora' ]] || [[ $OS_RELEASE == 'centos rhel fedora' ]]; then
yum install -y perl wget curl perl-Sys-Syslog unzip &>> $LOGFILE
echo -e "${cyan}Instaling 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}
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 '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
# Configuring Agente
[[ $PANDORA_SERVER_IP ]] && sed -i "s/^server_ip.*$/server_ip $PANDORA_SERVER_IP/g" $PANDORA_AGENT_CONF
[[ $PANDORA_REMOTE_CONFIG ]] && sed -i "s/^remote_config.*$/remote_config $PANDORA_REMOTE_CONFIG/g" $PANDORA_AGENT_CONF
[[ $PANDORA_GROUP ]] && sed -i "s/^group.*$/group $PANDORA_GROUP/g" $PANDORA_AGENT_CONF
[[ $PANDORA_DEBUG ]] && sed -i "s/^debug.*$/debug $PANDORA_DEBUG/g" $PANDORA_AGENT_CONF
[[ $PANDORA_AGENT_NAME ]] && sed -i "s/^#agent_name.*$/agent_name $PANDORA_AGENT_NAME/g" $PANDORA_AGENT_CONF
[[ $PANDORA_AGENT_ALIAS ]] && sed -i "s/^#agent_alias.*$/agent_alias $PANDORA_AGENT_ALIAS/g" $PANDORA_AGENT_CONF
[[ $PANDORA_SECONDARY_GROUPS ]] && sed -i "s/^# secondary_groups.*$/secondary_groups $PANDORA_SECONDARY_GROUPS/g" $PANDORA_AGENT_CONF
[[ $TIMEZONE ]] && ln -sfn /usr/share/zoneinfo/$TIMEZONE /etc/localtime
#installing autodiscover
arch=$(uname -m)
case $arch in
x86_64)
execute_cmd 'install_autodiscover x86_64' "installing service autodiscover on $arch" 'Error unable to install autodiscovery'
;;
x86)
execute_cmd 'install_autodiscover x84' "installing service autodiscover on $arch" 'Error unable to install autodiscovery'
;;
armv7l)
echo -e "${cyan}Skiping autodiscover installation arch $arch not suported${reset}"
;;
*)
echo -e "${yellow}Skiping autodiscover installation arch $arch not suported${reset}"
;;
esac
#Starting pandora agent daemon.
execute_cmd '/etc/init.d/pandora_agent_daemon restart' 'Starting Pandora Agent'
cd
execute_cmd 'rm -rf $HOME/pandora_deploy_tmp' 'Cleaning up temporay files'
echo -e "${green}PandoraFMS Agent installed and running, sending data to: $PANDORA_SERVER_IP${reset}"

View File

@ -117,7 +117,7 @@ check_pre_pandora
check_repo_connection check_repo_connection
# Systemd # Systemd
execute_cmd "systemctl status" "Cheking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env plese check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8' execute_cmd "systemctl status" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env plese check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8'
# Check memomry greather or equal to 2G # Check memomry greather or equal to 2G
execute_cmd "[ $(grep MemTotal /proc/meminfo | awk '{print $2}') -ge 1700000 ]" 'Checking memory (required: 2 GB)' execute_cmd "[ $(grep MemTotal /proc/meminfo | awk '{print $2}') -ge 1700000 ]" 'Checking memory (required: 2 GB)'
@ -247,7 +247,15 @@ server_dependencies=" \
perl-Time-HiRes \ perl-Time-HiRes \
nfdump \ nfdump \
net-snmp-utils \ net-snmp-utils \
http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/wmi-1.3.14-4.el7.art.x86_64.rpm" perl(NetAddr::IP) \
perl(Sys::Syslog) \
perl(DBI) \
perl(XML::Simple) \
perl(Geo::IP) \
perl(IO::Socket::INET6) \
perl(XML::Twig) \
http://firefly.artica.es/centos7/xprobe2-0.3-12.2.x86_64.rpm \
http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm"
execute_cmd "yum install -y $server_dependencies" "Installing Pandora FMS Server dependencies" execute_cmd "yum install -y $server_dependencies" "Installing Pandora FMS Server dependencies"
# SDK VMware perl dependencies # SDK VMware perl dependencies
@ -475,7 +483,7 @@ net.core.optmem_max = 81920
EO_KO EO_KO
execute_cmd "sysctl --system" "Applying Kernel optimization" [ -d /dev/lxd/ ] || execute_cmd "sysctl --system" "Applying Kernel optimization"
# Fix pandora_server.{log,error} permissions to allow Console check them # Fix pandora_server.{log,error} permissions to allow Console check them
chown pandora:apache /var/log/pandora chown pandora:apache /var/log/pandora

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, AIX version # Version 7.0NG.754, AIX version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, FreeBSD Version # Version 7.0NG.754, FreeBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, HP-UX Version # Version 7.0NG.754, HP-UX Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, GNU/Linux # Version 7.0NG.754, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, GNU/Linux # Version 7.0NG.754, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, Solaris Version # Version 7.0NG.754, Solaris Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent # Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas # (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.752 # Version 7.0NG.754
# This program is Free Software, you can redistribute it and/or modify it # This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software # under the terms of the GNU General Public Licence as published by the Free Software
# Foundation; either version 2 of the Licence or any later version # Foundation; either version 2 of the Licence or any later version

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.752, AIX version # Version 7.0NG.754, AIX version
# General Parameters # General Parameters
# ================== # ==================

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.752 # Version 7.0NG.754
# FreeBSD/IPSO version # FreeBSD/IPSO version
# Licenced under GPL licence, 2003-2007 Sancho Lerena # Licenced under GPL licence, 2003-2007 Sancho Lerena

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.752, HPUX Version # Version 7.0NG.754, HPUX Version
# General Parameters # General Parameters
# ================== # ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752 # Version 7.0NG.754
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2021 Artica Soluciones Tecnologicas # (c) 2003-2021 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net # please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752 # Version 7.0NG.754
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2021 Artica Soluciones Tecnologicas # (c) 2003-2021 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net # please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752 # Version 7.0NG.754
# Licensed under GPL license v2, # Licensed under GPL license v2,
# please visit http://pandora.sourceforge.net # please visit http://pandora.sourceforge.net

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.752, Solaris version # Version 7.0NG.754, Solaris version
# General Parameters # General Parameters
# ================== # ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, AIX version # Version 7.0NG.754, AIX version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.752-210329 Version: 7.0NG.754-210505
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.752-210329" pandora_version="7.0NG.754-210505"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -24,7 +24,7 @@ fi
if [ "$#" -ge 2 ]; then if [ "$#" -ge 2 ]; then
VERSION="$2" VERSION="$2"
else else
VERSION="7.0NG.752" VERSION="7.0NG.754"
fi fi
# Path for the generated DMG file # Path for the generated DMG file

View File

@ -19,11 +19,11 @@
<choice id="com.pandorafms.pandorafms_src" visible="false"> <choice id="com.pandorafms.pandorafms_src" visible="false">
<pkg-ref id="com.pandorafms.pandorafms_src"/> <pkg-ref id="com.pandorafms.pandorafms_src"/>
</choice> </choice>
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.752" onConclusion="none">pandorafms_src.pdk</pkg-ref> <pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.754" onConclusion="none">pandorafms_src.pdk</pkg-ref>
<choice id="com.pandorafms.pandorafms_uninstall" visible="true" customLocation="/Applications"> <choice id="com.pandorafms.pandorafms_uninstall" visible="true" customLocation="/Applications">
<pkg-ref id="com.pandorafms.pandorafms_uninstall"/> <pkg-ref id="com.pandorafms.pandorafms_uninstall"/>
</choice> </choice>
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.752" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref> <pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.754" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
<!-- <installation-check script="check()" /> <!-- <installation-check script="check()" />
<script> <script>
<![CDATA[ <![CDATA[

View File

@ -5,9 +5,9 @@
<key>CFBundleIconFile</key> <string>pandorafms.icns</string> <key>CFBundleIconFile</key> <string>pandorafms.icns</string>
<key>CFBundleIdentifier</key> <string>com.pandorafms.pandorafms_uninstall</string> <key>CFBundleIdentifier</key> <string>com.pandorafms.pandorafms_uninstall</string>
<key>CFBundleVersion</key> <string>7.0NG.752</string> <key>CFBundleVersion</key> <string>7.0NG.754</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.752 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string> <key>CFBundleGetInfoString</key> <string>7.0NG.754 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
<key>CFBundleShortVersionString</key> <string>7.0NG.752</string> <key>CFBundleShortVersionString</key> <string>7.0NG.754</string>
<key>NSPrincipalClass</key><string>NSApplication</string> <key>NSPrincipalClass</key><string>NSApplication</string>
<key>NSMainNibFile</key><string>MainMenu</string> <key>NSMainNibFile</key><string>MainMenu</string>

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, GNU/Linux # Version 7.0NG.754, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, FreeBSD Version # Version 7.0NG.754, FreeBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, HP-UX Version # Version 7.0NG.754, HP-UX Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, GNU/Linux # Version 7.0NG.754, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, GNU/Linux # Version 7.0NG.754, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, NetBSD Version # Version 7.0NG.754, NetBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.752, Solaris Version # Version 7.0NG.754, Solaris Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -592,7 +592,6 @@ BEGIN {
my ($self) = @_; my ($self) = @_;
if ($YAML == 0) { if ($YAML == 0) {
$self->set_last_error('Cannot use commands without YAML dependency, please install it.');
return; return;
} }
@ -1015,8 +1014,8 @@ my $Sem = undef;
# Semaphore used to control the number of threads # Semaphore used to control the number of threads
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.752'; use constant AGENT_VERSION => '7.0NG.754';
use constant AGENT_BUILD => '210329'; use constant AGENT_BUILD => '210505';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;
@ -4030,6 +4029,14 @@ if ($Conf{'proxy_mode'}) {
} }
} }
# Advice if YAML::Tiny is allowed in this system
eval {
eval 'require YAML::Tiny;1' or die('YAML::Tiny lib not found, commands feature won\'t be available');
};
if ($@) {
log_message ('error', 'Cannot use commands without YAML dependency, please install it.');
}
# Add the plugins directory to the PATH # Add the plugins directory to the PATH
$ENV{'PATH'} .= ":$ConfDir/plugins"; $ENV{'PATH'} .= ":$ConfDir/plugins";

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.752 %define version 7.0NG.754
%define release 210329 %define release 210505
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.752 %define version 7.0NG.754
%define release 210329 %define release 210505
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -9,8 +9,8 @@
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.752" PI_VERSION="7.0NG.754"
PI_BUILD="210329" PI_BUILD="210505"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0
@ -166,7 +166,7 @@ uninstall () {
rm -f $DESTDIR/etc/newsyslog.d/pandora_agent.conf rm -f $DESTDIR/etc/newsyslog.d/pandora_agent.conf
# Remove systemd service if exists # Remove systemd service if exists
if [ `systemctl --v 2> /dev/null | grep systemd | wc -l` != 0 ] if [ `command -v systemctl` ]
then then
PANDORA_AGENT_SERVICE="/etc/systemd/system/pandora_agent_daemon.service" PANDORA_AGENT_SERVICE="/etc/systemd/system/pandora_agent_daemon.service"
rm -f $PANDORA_AGENT_SERVICE rm -f $PANDORA_AGENT_SERVICE
@ -482,7 +482,7 @@ install () {
fi fi
# Create systemd service # Create systemd service
if [ `systemctl --v 2> /dev/null | grep systemd | wc -l` != 0 ] if [ `command -v systemctl` ]
then then
echo "Creating systemd service for pandora_agent_daemon" echo "Creating systemd service for pandora_agent_daemon"

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent # Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas # (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.752 # Version 7.0NG.754
# This program is Free Software, you can redistribute it and/or modify it # This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software # under the terms of the GNU General Public Licence as published by the Free Software
# Foundation; either version 2 of the Licence or any later version # Foundation; either version 2 of the Licence or any later version

View File

@ -3,7 +3,7 @@ AllowLanguageSelection
{Yes} {Yes}
AppName AppName
{Pandora FMS Windows Agent v7.0NG.752} {Pandora FMS Windows Agent v7.0NG.754}
ApplicationID ApplicationID
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F} {17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{210329} {210505}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -81,6 +81,7 @@ Pandora_Module::Pandora_Module (string name) {
this->module_ff_type = ""; this->module_ff_type = "";
this->module_alert_template = ""; this->module_alert_template = "";
this->module_crontab = ""; this->module_crontab = "";
this->module_wait_timeout = 500;
} }
/** /**
@ -1722,3 +1723,18 @@ Pandora_Module::isIntensive () {
return true; return true;
} }
/**
* Set the WaitForSingleObject timeout.
*
* @param timeout Timeout in milliseconds.
*/
void
Pandora_Module::setWaitTimeout (int timeout) {
if (timeout < 0) {
return;
}
this->module_wait_timeout = timeout;
}

View File

@ -216,6 +216,7 @@ namespace Pandora_Modules {
string getDataOutput (Pandora_Data *data); string getDataOutput (Pandora_Data *data);
void cleanDataList (); void cleanDataList ();
int module_wait_timeout;
public: public:
Pandora_Module (string name); Pandora_Module (string name);
virtual ~Pandora_Module (); virtual ~Pandora_Module ();
@ -231,6 +232,7 @@ namespace Pandora_Modules {
int getInterval (); int getInterval ();
int getIntensiveInterval (); int getIntensiveInterval ();
void setTimeout (int timeout); void setTimeout (int timeout);
void setWaitTimeout (int timeout);
int getTimeout (); int getTimeout ();
string getSave (); string getSave ();
bool getAsync (); bool getAsync ();

View File

@ -172,7 +172,7 @@ Pandora_Module_Exec::run () {
string output; string output;
int tickbase = GetTickCount(); int tickbase = GetTickCount();
while ( (dwRet = WaitForSingleObject (pi.hProcess, 500)) != WAIT_ABANDONED ) { while ( (dwRet = WaitForSingleObject (pi.hProcess, this->module_wait_timeout)) != WAIT_ABANDONED ) {
PeekNamedPipe (out_read, buffer, BUFSIZE, &read, &avail, NULL); PeekNamedPipe (out_read, buffer, BUFSIZE, &read, &avail, NULL);
if (avail > 0) { if (avail > 0) {
ReadFile (out_read, buffer, BUFSIZE, &read, NULL); ReadFile (out_read, buffer, BUFSIZE, &read, NULL);
@ -180,11 +180,6 @@ Pandora_Module_Exec::run () {
output += (char *) buffer; output += (char *) buffer;
} }
/* Change the output encoding */
if (this->native_encoding != -1){
changeOutputEncoding(&output);
}
if (dwRet == WAIT_OBJECT_0) { if (dwRet == WAIT_OBJECT_0) {
break; break;
} else if(this->getTimeout() < GetTickCount() - tickbase) { } else if(this->getTimeout() < GetTickCount() - tickbase) {
@ -220,6 +215,10 @@ Pandora_Module_Exec::run () {
} }
// Command output mode // Command output mode
else if (!output.empty()) { else if (!output.empty()) {
/* Change the output encoding */
if (this->native_encoding != -1){
changeOutputEncoding(&output);
}
this->setOutput (output); this->setOutput (output);
} else { } else {
this->setOutput (""); this->setOutput ("");
@ -471,4 +470,3 @@ void Pandora_Module_Exec::changeOutputEncoding(string * string_change){
} }
} }

View File

@ -124,6 +124,7 @@ using namespace Pandora_Strutils;
#define TOKEN_NATIVE_ENCODING ("module_native_encoding") #define TOKEN_NATIVE_ENCODING ("module_native_encoding")
#define TOKEN_ALERT_TEMPLATE ("module_alert_template") #define TOKEN_ALERT_TEMPLATE ("module_alert_template")
#define TOKEN_USER_SESSION ("module_user_session ") #define TOKEN_USER_SESSION ("module_user_session ")
#define TOKEN_WAIT_TIMEOUT ("module_wait_timeout ")
string string
parseLine (string line, string token) { parseLine (string line, string token) {
@ -178,7 +179,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
string module_critical_instructions, module_warning_instructions, module_unknown_instructions, module_tags; string module_critical_instructions, module_warning_instructions, module_unknown_instructions, module_tags;
string module_critical_inverse, module_warning_inverse, module_quiet, module_ff_interval; string module_critical_inverse, module_warning_inverse, module_quiet, module_ff_interval;
string module_native_encoding, module_alert_template, module_ff_type; string module_native_encoding, module_alert_template, module_ff_type;
string macro; string macro, module_wait_timeout;
Pandora_Module *module; Pandora_Module *module;
bool numeric; bool numeric;
Module_Type type; Module_Type type;
@ -260,6 +261,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_alert_template = ""; module_alert_template = "";
module_user_session = ""; module_user_session = "";
macro = ""; macro = "";
module_wait_timeout = "";
stringtok (tokens, definition, "\n"); stringtok (tokens, definition, "\n");
@ -291,6 +293,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
if (module_exec == "") { if (module_exec == "") {
module_exec = parseLine (line, TOKEN_EXEC); module_exec = parseLine (line, TOKEN_EXEC);
} }
if (module_wait_timeout == "") {
module_wait_timeout = parseLine (line, TOKEN_WAIT_TIMEOUT);
}
if (module_proc == "") { if (module_proc == "") {
module_proc = parseLine (line, TOKEN_PROC); module_proc = parseLine (line, TOKEN_PROC);
} }
@ -1130,6 +1135,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
if (module_timeout != "") { if (module_timeout != "") {
module->setTimeout (atoi (module_timeout.c_str ())); module->setTimeout (atoi (module_timeout.c_str ()));
} }
if (module_wait_timeout != "") {
module->setWaitTimeout (atoi (module_wait_timeout.c_str ()));
}
} else if (module_proc != "") { } else if (module_proc != "") {
module = new Pandora_Module_Proc (module_name, module = new Pandora_Module_Proc (module_name,
@ -1230,6 +1238,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
if (module_timeout != ""){ if (module_timeout != ""){
module->setTimeout(atoi(module_timeout.c_str())); module->setTimeout(atoi(module_timeout.c_str()));
} }
if (module_wait_timeout != "") {
module->setWaitTimeout (atoi (module_wait_timeout.c_str ()));
}
} else if (module_ping != "") { } else if (module_ping != "") {
if (module_ping_count == "") { if (module_ping_count == "") {
module_ping_count = "1"; module_ping_count = "1";

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.752(Build 210329)") #define PANDORA_VERSION ("7.0NG.754(Build 210505)")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.752(Build 210329))" VALUE "ProductVersion", "(7.0NG.754(Build 210505))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.752-210329 Version: 7.0NG.754-210505
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.752-210329" pandora_version="7.0NG.754-210505"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -61,7 +61,7 @@ if (isset($config['console_log_enabled']) === true
ini_set('error_log', $config['homedir'].'/log/console.log'); ini_set('error_log', $config['homedir'].'/log/console.log');
} else { } else {
ini_set('log_errors', 0); ini_set('log_errors', 0);
ini_set('error_log', 0); ini_set('error_log', null);
} }
// Sometimes input is badly retrieved from caller... // Sometimes input is badly retrieved from caller...

View File

@ -196,6 +196,7 @@ function mainModuleGroups()
ON ta.id_agente = tam.id_agente ON ta.id_agente = tam.id_agente
WHERE ta.disabled = 0 WHERE ta.disabled = 0
AND tam.disabled = 0 AND tam.disabled = 0
AND tam.id_modulo <> 0
AND tam.delete_pending = 0 AND tam.delete_pending = 0
AND ta.id_grupo IN (%s) AND ta.id_grupo IN (%s)
GROUP BY tam.id_agente_modulo GROUP BY tam.id_agente_modulo

View File

@ -1096,8 +1096,13 @@ function resource_registration_extension_main()
} }
$xml = simplexml_load_file($_FILES['resource_upload']['tmp_name'], null, LIBXML_NOCDATA); $xml = simplexml_load_file($_FILES['resource_upload']['tmp_name'], null, LIBXML_NOCDATA);
if ($xml === false) {
process_upload_xml($xml); ui_print_error_message(
__('Error uploading resource. Check if the selected file is a valid resource template in .ptr format')
);
} else {
process_upload_xml($xml);
}
} }

View File

@ -0,0 +1,36 @@
START TRANSACTION;
ALTER TABLE `tgrupo` ADD COLUMN `max_agents` int(10) NOT NULL DEFAULT 0;
ALTER TABLE `tagent_custom_fields` MODIFY COLUMN `combo_values` TEXT NOT NULL DEFAULT '';
ALTER TABLE `treport_content` MODIFY `external_source` MEDIUMTEXT;
ALTER TABLE `treport_content_template` MODIFY `external_source` MEDIUMTEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `agent` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `id_usuario` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `id_grupo` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `evento` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `event_type` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `module` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `alert` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `criticity` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `user_comment` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `id_tag` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `name` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `group_recursion` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `log_content` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `log_source` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `log_agent` TEXT;
ALTER TABLE tevent_filter ADD COLUMN `server_id` int(10) NOT NULL default 0;
UPDATE `talert_commands` SET `fields_descriptions` = '[\"Event&#x20;name\",\"Event&#x20;type\",\"Source\",\"Agent&#x20;name&#x20;or&#x20;_agent_\",\"Event&#x20;severity\",\"ID&#x20;extra\",\"Tags&#x20;separated&#x20;by&#x20;commas\",\"Comments\",\"\",\"\"]' WHERE `name` = "Monitoring&#x20;Event";
UPDATE `tskin` SET `name` = 'Default&#x20;theme' , `relative_path` = 'pandora.css' WHERE `id` = 1;
UPDATE `tskin` SET `name` = 'Black&#x20;theme' , `relative_path` = 'Black&#x20;theme' , `description` = 'Black&#x20;theme' WHERE `id` = 2;
UPDATE `tevent_rule` SET `criticity` = NULL, `operator_criticity` = NULL WHERE `criticity` = 99;
UPDATE `tevent_rule` SET `id_grupo` = NULL, `operator_id_grupo` = NULL WHERE `id_grupo` = 0;
UPDATE `tevent_rule` SET `id_tag` = NULL, `operator_id_tag` = NULL WHERE `id_tag` = 0;
UPDATE `tevent_rule` SET `operator_criticity` = '==' WHERE `criticity` != 99 AND `criticity` IS NOT NULL AND `criticity` != '';
UPDATE `tevent_rule` SET `operator_id_grupo` = '==' WHERE `id_grupo` != 0 AND `id_grupo` IS NOT NULL AND `id_grupo` != '';
UPDATE `tevent_rule` SET `operator_id_tag` = '==' WHERE `id_tag` != 0 AND `id_tag` IS NOT NULL AND `id_tag` != '';
COMMIT;

View File

@ -565,6 +565,9 @@ CREATE TABLE IF NOT EXISTS `tskin` (
PRIMARY KEY (id) PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
UPDATE `tskin` SET `name` = 'Default&#x20;theme' , `relative_path` = 'pandora.css' WHERE `id` = 1;
UPDATE `tskin` SET `name` = 'Black&#x20;theme' , `relative_path` = 'Black&#x20;theme' , `description` = 'Black&#x20;theme' WHERE `id` = 2;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tpolicy_queue` -- Table `tpolicy_queue`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
@ -625,6 +628,22 @@ ALTER TABLE `tevent_rule` MODIFY COLUMN `event_type` enum('','unknown','alert_fi
ALTER TABLE `tevent_rule` MODIFY COLUMN `criticity` int(4) unsigned DEFAULT NULL; ALTER TABLE `tevent_rule` MODIFY COLUMN `criticity` int(4) unsigned DEFAULT NULL;
ALTER TABLE `tevent_rule` MODIFY COLUMN `id_grupo` mediumint(4) DEFAULT NULL; ALTER TABLE `tevent_rule` MODIFY COLUMN `id_grupo` mediumint(4) DEFAULT NULL;
ALTER TABLE `tevent_rule` MODIFY COLUMN `agent` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `id_usuario` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `id_grupo` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `evento` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `event_type` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `module` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `alert` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `criticity` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `user_comment` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `id_tag` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `name` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `group_recursion` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `log_content` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `log_source` TEXT;
ALTER TABLE `tevent_rule` MODIFY COLUMN `log_agent` TEXT;
UPDATE `tevent_rule` SET `operator_agent` = "REGEX" WHERE `agent` != ''; UPDATE `tevent_rule` SET `operator_agent` = "REGEX" WHERE `agent` != '';
UPDATE `tevent_rule` SET `operator_id_usuario` = "REGEX" WHERE `id_usuario` != ''; UPDATE `tevent_rule` SET `operator_id_usuario` = "REGEX" WHERE `id_usuario` != '';
UPDATE `tevent_rule` SET `operator_id_grupo` = "REGEX" WHERE `id_grupo` > 0; UPDATE `tevent_rule` SET `operator_id_grupo` = "REGEX" WHERE `id_grupo` > 0;
@ -811,7 +830,7 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` (
`description` mediumtext, `description` mediumtext,
`text_agent` text, `text_agent` text,
`text` TEXT, `text` TEXT,
`external_source` Text, `external_source` mediumtext,
`treport_custom_sql_id` INTEGER UNSIGNED default 0, `treport_custom_sql_id` INTEGER UNSIGNED default 0,
`header_definition` TinyText default NULL, `header_definition` TinyText default NULL,
`column_separator` TinyText default NULL, `column_separator` TinyText default NULL,
@ -1487,6 +1506,7 @@ ALTER TABLE tevent_filter ADD COLUMN `id_extra` tinytext NOT NULL;
ALTER TABLE tevent_filter ADD COLUMN `id_source_event` int(10); ALTER TABLE tevent_filter ADD COLUMN `id_source_event` int(10);
ALTER TABLE `tevent_filter` MODIFY COLUMN `user_comment` text NOT NULL; ALTER TABLE `tevent_filter` MODIFY COLUMN `user_comment` text NOT NULL;
ALTER TABLE `tevent_filter` MODIFY COLUMN `severity` text NOT NULL; ALTER TABLE `tevent_filter` MODIFY COLUMN `severity` text NOT NULL;
ALTER TABLE tevent_filter ADD COLUMN `server_id` int(10) NOT NULL default 0;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tusuario` -- Table `tusuario`
@ -1741,6 +1761,7 @@ ALTER TABLE `treport_content` ADD COLUMN `landscape` tinyint(1) UNSIGNED NOT NUL
ALTER TABLE `treport_content` ADD COLUMN `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0; ALTER TABLE `treport_content` ADD COLUMN `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `treport_content` ADD COLUMN `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0; ALTER TABLE `treport_content` ADD COLUMN `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `treport_content` ADD COLUMN `graph_render` tinyint(1) UNSIGNED NOT NULL default 0; ALTER TABLE `treport_content` ADD COLUMN `graph_render` tinyint(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `treport_content` MODIFY `external_source` MEDIUMTEXT;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tmodule_relationship` -- Table `tmodule_relationship`
@ -2501,6 +2522,7 @@ CREATE TABLE `tnotification_source_group_user` (
-- Add alert command 'Generate notification' -- Add alert command 'Generate notification'
-- ---------------------------------------------------------------------- -- ----------------------------------------------------------------------
INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate&#x20;Notification','Internal&#x20;type','This&#x20;command&#x20;allows&#x20;you&#x20;to&#x20;send&#x20;an&#x20;internal&#x20;notification&#x20;to&#x20;any&#x20;user&#x20;or&#x20;group.',1,'[\"Destination&#x20;user\",\"Destination&#x20;group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate&#x20;Notification','Internal&#x20;type','This&#x20;command&#x20;allows&#x20;you&#x20;to&#x20;send&#x20;an&#x20;internal&#x20;notification&#x20;to&#x20;any&#x20;user&#x20;or&#x20;group.',1,'[\"Destination&#x20;user\",\"Destination&#x20;group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
UPDATE `talert_commands` SET `fields_descriptions` = '[\"Event&#x20;name\",\"Event&#x20;type\",\"Source\",\"Agent&#x20;name&#x20;or&#x20;_agent_\",\"Event&#x20;severity\",\"ID&#x20;extra\",\"Tags&#x20;separated&#x20;by&#x20;commas\",\"Comments\",\"\",\"\"]' WHERE `name` = "Monitoring&#x20;Event";
-- ---------------------------------------------------------------------- -- ----------------------------------------------------------------------
-- Update message references and pre-configure notifications -- Update message references and pre-configure notifications
@ -2519,7 +2541,7 @@ INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Di
-- ---------------------------------------------------------------------- -- ----------------------------------------------------------------------
-- Add column in table `tagent_custom_fields` -- Add column in table `tagent_custom_fields`
-- ---------------------------------------------------------------------- -- ----------------------------------------------------------------------
ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` VARCHAR(255) DEFAULT ''; ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` TEXT NOT NULL DEFAULT '';
-- ---------------------------------------------------------------------- -- ----------------------------------------------------------------------
-- Add column in table `tnetflow_filter` -- Add column in table `tnetflow_filter`
@ -2848,6 +2870,12 @@ UPDATE twidget SET description='Show a visual console' WHERE class_name='MapsMad
UPDATE twidget SET description='Clock' WHERE class_name='ClockWidget'; UPDATE twidget SET description='Clock' WHERE class_name='ClockWidget';
UPDATE twidget SET description='Group status' WHERE class_name='SystemGroupStatusWidget'; UPDATE twidget SET description='Group status' WHERE class_name='SystemGroupStatusWidget';
--
-- Modifies tgrupo table.
--
ALTER TABLE tgrupo ADD COLUMN max_agents int(10) NOT NULL DEFAULT 0;
-- ---------------------------------------------------------------------- -- ----------------------------------------------------------------------
-- Table `tnode_relations` -- Table `tnode_relations`
-- ---------------------------------------------------------------------- -- ----------------------------------------------------------------------

View File

@ -53,8 +53,8 @@ ui_print_info_message(['no_close' => true, 'message' => __('There are no HA clus
<?php <?php
if (check_acl($config['id_user'], 0, 'PM')) { if (check_acl($config['id_user'], 0, 'PM')) {
echo "<div id='create_master_window' class='invisible'></div>"; echo "<div id='create_master_window' style='display: none'></div>";
echo "<div id='msg' class='invisible'></div>"; echo "<div id='msg' style='display: none'></div>";
?> ?>
<input onclick="show_create_ha_cluster();" type="submit" class="button_task ui_toggle" value="<?php echo __('Add new node'); ?>" /> <input onclick="show_create_ha_cluster();" type="submit" class="button_task ui_toggle" value="<?php echo __('Add new node'); ?>" />
<?php <?php

View File

@ -24,6 +24,14 @@ if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'],
return; return;
} }
\ui_print_page_header(
__('Monitoring').' &raquo; '.__('Clusters'),
'images/chart.png',
false,
'',
false
);
ui_require_css_file('first_task'); ui_require_css_file('first_task');
?> ?>
<?php <?php

View File

@ -931,24 +931,19 @@ foreach ($fields as $field) {
} }
if ($field['combo_values'] !== '') { if ($field['combo_values'] !== '') {
$data_field[1] = html_print_select( $data_field[1] = html_print_input(
$combo_values, [
'customvalue_'.$field['id_field'], 'type' => 'select_search',
$custom_value, 'fields' => $combo_values,
'', 'name' => 'customvalue_'.$field['id_field'],
__('None'), 'selected' => $custom_value,
'', 'nothing' => __('None'),
true, 'nothing_value' => '',
false, 'return' => true,
false, 'sort' => false,
'', 'size' => '400px',
false, 'dropdownAutoWidth' => true,
false, ]
false,
false,
false,
'',
false
); );
}; };

View File

@ -37,6 +37,8 @@ require_once $config['homedir'].'/include/functions_cron.php';
ui_require_javascript_file('encode_decode_base64'); ui_require_javascript_file('encode_decode_base64');
ui_require_css_file('agent_manager'); ui_require_css_file('agent_manager');
use PandoraFMS\Event;
check_login(); check_login();
// Get tab parameter to check ACL in each tabs. // Get tab parameter to check ACL in each tabs.
@ -229,6 +231,9 @@ if ($create_agent) {
if ($alias == '') { if ($alias == '') {
$agent_creation_error = __('No agent alias specified'); $agent_creation_error = __('No agent alias specified');
$agent_created_ok = 0; $agent_created_ok = 0;
} else if (group_allow_more_agents($grupo, true, 'create') === false) {
$agent_creation_error = __('Agent cannot be created due to the maximum agent limit for this group');
$agent_created_ok = 0;
} else { } else {
if ($alias_as_name) { if ($alias_as_name) {
$sql = 'SELECT nombre FROM tagente WHERE nombre = "'.$alias.'"'; $sql = 'SELECT nombre FROM tagente WHERE nombre = "'.$alias.'"';
@ -400,7 +405,7 @@ if ($id_agente) {
// Module tab. // Module tab.
$moduletab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=module&amp;id_agente='.$id_agente.'">'.html_print_image( $moduletab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=module&amp;id_agente='.$id_agente.'">'.html_print_image(
'images/module.png', 'images/gm_modules.png',
true, true,
[ [
'title' => __('Modules'), 'title' => __('Modules'),
@ -416,7 +421,7 @@ if ($id_agente) {
// Alert tab. // Alert tab.
$alerttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=alert&amp;id_agente='.$id_agente.'">'.html_print_image( $alerttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=alert&amp;id_agente='.$id_agente.'">'.html_print_image(
'images/bell.png', 'images/gm_alerts.png',
true, true,
[ [
'title' => __('Alerts'), 'title' => __('Alerts'),
@ -1034,6 +1039,8 @@ if ($update_agent) {
if ($grupo <= 0) { if ($grupo <= 0) {
ui_print_error_message(__('The group id %d is incorrect.', $grupo)); ui_print_error_message(__('The group id %d is incorrect.', $grupo));
} else if (group_allow_more_agents($grupo, true, 'update') === false) {
ui_print_error_message(__('Agent cannot be updated due to the maximum agent limit for this group'));
} else if ($exists_ip) { } else if ($exists_ip) {
ui_print_error_message(__('Duplicate main IP address')); ui_print_error_message(__('Duplicate main IP address'));
} else { } else {

View File

@ -33,7 +33,7 @@ if ($id_field) {
$name = $field['name']; $name = $field['name'];
$display_on_front = $field['display_on_front']; $display_on_front = $field['display_on_front'];
$is_password_type = $field['is_password_type']; $is_password_type = $field['is_password_type'];
$combo_values = $field['combo_values']; $combo_values = $field['combo_values'] ? $field['combo_values'] : '';
$is_combo_enable = $config['is_combo_enable']; $is_combo_enable = $config['is_combo_enable'];
ui_print_page_header(__('Update agent custom field'), 'images/custom_field.png', false, '', true, ''); ui_print_page_header(__('Update agent custom field'), 'images/custom_field.png', false, '', true, '');
} else { } else {
@ -116,12 +116,12 @@ $table->data[4][0] = __('Combo values').ui_print_help_tip(
__('Set values separated by comma'), __('Set values separated by comma'),
true true
); );
$table->data[4][1] = html_print_input_text( $table->data[4][1] = html_print_textarea(
'combo_values', 'combo_values',
3,
65,
io_safe_output($combo_values), io_safe_output($combo_values),
'', '',
35,
200,
true true
); );
@ -144,7 +144,7 @@ echo '</form>';
<script> <script>
$(document).ready (function () { $(document).ready (function () {
if($('input[type=hidden][name=update_field]').val() == 1 && $('input[type=text][name=combo_values]').val() != ''){ if($('input[type=hidden][name=update_field]').val() == 1 && $('#textarea_combo_values').val() != ''){
$('input[type=checkbox][name=is_combo_enable]').prop('checked', true); $('input[type=checkbox][name=is_combo_enable]').prop('checked', true);
$('#configure_field-4').show(); $('#configure_field-4').show();
$('input[type=checkbox][name=is_password_type]').change(function (e) { $('input[type=checkbox][name=is_password_type]').change(function (e) {
@ -155,7 +155,7 @@ $(document).ready (function () {
e.preventDefault(); e.preventDefault();
}); });
$('input[type=checkbox][name=is_combo_enable]').change(function (e) { $('input[type=checkbox][name=is_combo_enable]').change(function (e) {
if($('input[type=text][name=combo_values]').val() != '' && $('input[type=checkbox][name=is_combo_enable]').prop('checked', true)){ if($('#textarea_combo_values').val() != '' && $('input[type=checkbox][name=is_combo_enable]').prop('checked', true)){
dialog_message("#message_set_combo"); dialog_message("#message_set_combo");
$('input[type=checkbox][name=is_combo_enable]').prop('checked', true); $('input[type=checkbox][name=is_combo_enable]').prop('checked', true);
$('#configure_field-4').show(); $('#configure_field-4').show();

View File

@ -1072,6 +1072,7 @@ foreach ($modules as $module) {
[ [
'alt' => __('Enable module'), 'alt' => __('Enable module'),
'title' => __('Enable module'), 'title' => __('Enable module'),
'class' => 'invert_filter_important',
] ]
).'</a>'; ).'</a>';
} else { } else {

View File

@ -115,7 +115,12 @@ function add_component_selection($id_network_component_type)
'', '',
'---'.__('Manual setup').'---', '---'.__('Manual setup').'---',
0, 0,
true true,
false,
true,
'',
false,
'width: 460px; '
); );
$data[1] .= '</span>'; $data[1] .= '</span>';
$data[1] .= ' <span id="component_loading" class="invisible">'; $data[1] .= ' <span id="component_loading" class="invisible">';
@ -1357,12 +1362,11 @@ $(document).ready (function () {
jQuery.each($("select[name='id_tag_available[]'] option:selected"), function (key, value) { jQuery.each($("select[name='id_tag_available[]'] option:selected"), function (key, value) {
tag_name = $(value).html(); tag_name = $(value).html();
if (tag_name != <?php echo "'".__('None')."'"; ?>) { if (tag_name != <?php echo "'".__('None')."'"; ?>) {
id_tag = $(value).attr('value'); $("select[name='id_tag_selected[]']").append(value);
$("select[name='id_tag_selected[]']").append($("<option></option>").val(id_tag).html('<i>' + tag_name + '</i>'));
$("#id_tag_available").find("option[value='" + id_tag + "']").remove(); $("#id_tag_available").find("option[value='" + id_tag + "']").remove();
$("#id_tag_selected").find("option[value='']").remove(); $("#id_tag_selected").find("option[value='']").remove();
if($("#id_tag_available option").length == 0) { if($("#id_tag_available option").length == 0) {
$("select[name='id_tag_available[]']").append($("<option></option>").val('').html('<i><?php echo __('None'); ?></i>')); $("select[name='id_tag_available[]']").append(value);
} }
} }
}); });
@ -1373,11 +1377,11 @@ $(document).ready (function () {
tag_name = $(value).html(); tag_name = $(value).html();
if (tag_name != <?php echo "'".__('None')."'"; ?>) { if (tag_name != <?php echo "'".__('None')."'"; ?>) {
id_tag = $(value).attr('value'); id_tag = $(value).attr('value');
$("select[name='id_tag_available[]']").append($("<option>").val(id_tag).html('<i>' + tag_name + '</i>')); $("select[name='id_tag_available[]']").append(value);
$("#id_tag_selected").find("option[value='" + id_tag + "']").remove(); $("#id_tag_selected").find("option[value='" + id_tag + "']").remove();
$("#id_tag_available").find("option[value='']").remove(); $("#id_tag_available").find("option[value='']").remove();
if($("#id_tag_selected option").length == 0) { if($("#id_tag_selected option").length == 0) {
$("select[name='id_tag_selected[]']").append($("<option></option>").val('').html('<i><?php echo __('None'); ?></i>')); $("select[name='id_tag_selected[]']").append(value);
} }
} }
}); });

View File

@ -61,6 +61,11 @@ if (defined('METACONSOLE')) {
$sec = 'galertas'; $sec = 'galertas';
} }
$can_edit_all = false;
if (check_acl_restricted_all($config['id_user'], 0, 'LM')) {
$can_edit_all = true;
}
// Header. // Header.
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
alerts_meta_print_header(); alerts_meta_print_header();
@ -79,30 +84,13 @@ if ($copy_action) {
$al_action = alerts_get_alert_action($id); $al_action = alerts_get_alert_action($id);
if (!check_acl_restricted_all($config['id_user'], $al_action['id_group'], 'LM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
);
include 'general/noaccess.php';
exit;
}
if ($al_action !== false) { if ($al_action !== false) {
// If user tries to copy an action with group=ALL. // If user who doesn't have permission to modify group all tries to copy an action with group=ALL.
if ($al_action['id_group'] == 0) { if ($can_edit_all == false && $al_action['id_group'] == 0) {
// Then must have "PM" access privileges. $al_action['id_group'] = users_get_first_group(false, 'LM', false);
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
);
include 'general/noaccess.php';
exit;
}
} else { } else {
$own_info = get_user_info($config['id_user']); $own_info = get_user_info($config['id_user']);
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { if ($can_edit_all == true || check_acl($config['id_user'], 0, 'PM')) {
$own_groups = array_keys( $own_groups = array_keys(
users_get_groups($config['id_user'], 'LM') users_get_groups($config['id_user'], 'LM')
); );
@ -125,7 +113,7 @@ if ($copy_action) {
} }
} }
$result = alerts_clone_alert_action($id); $result = alerts_clone_alert_action($id, $al_action['id_group']);
if ($result) { if ($result) {
db_pandora_audit( db_pandora_audit(
@ -397,10 +385,9 @@ foreach ($actions as $action) {
$data = []; $data = [];
if (check_acl_restricted_all($config['id_user'], $action['id_group'], 'LM')) { $data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&id='.$action['id'].'&pure='.$pure.'">'.$action['name'].'</a>';
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&id='.$action['id'].'&pure='.$pure.'">'.$action['name'].'</a>'; if ($action['id_group'] == 0 && $can_edit_all == false) {
} else { $data[0] .= ui_print_help_tip(__('You cannot edit this action, You don\'t have the permission to edit All group.'), true);
$data[0] = $action['name'];
} }
$data[1] = $action['command_name']; $data[1] = $action['command_name'];
@ -420,7 +407,7 @@ foreach ($actions as $action) {
$data[4] = ''; $data[4] = '';
if (is_central_policies_on_node() === false if (is_central_policies_on_node() === false
&& check_acl_restricted_all($config['id_user'], $action['id_group'], 'LM') && check_acl($config['id_user'], $action['id_group'], 'LM')
) { ) {
$table->cellclass[] = [ $table->cellclass[] = [
3 => 'action_buttons', 3 => 'action_buttons',
@ -430,10 +417,35 @@ foreach ($actions as $action) {
$id_action = $action['id']; $id_action = $action['id'];
$text_confirm = __('Are you sure?'); $text_confirm = __('Are you sure?');
$data[3] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions" $data[3] = '<form method="post" style="display: inline; float: right" onsubmit="if (!confirm(\''.$text_confirm.'\')) return false;">';
onClick="copy_action('.$id_action.',\''.$text_confirm.'\');">'.html_print_image('images/copy.png', true, ['class' => 'invert_filter']).'</a>'; $data[3] .= html_print_input_hidden('copy_action', 1, true);
$data[4] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions" $data[3] .= html_print_input_hidden('id', $id_action, true);
onClick="delete_action('.$id_action.',\''.$text_confirm.'\');">'.html_print_image('images/cross.png', true, ['class' => 'invert_filter']).'</a>'; $data[3] .= html_print_input_image(
'dup',
'images/copy.png',
1,
'',
true,
['title' => __('Duplicate')]
);
$data[3] .= '</form> ';
if ($action['id_group'] != 0 || $can_edit_all == true) {
$data[4] = '<form method="post" style="display: inline; float: right" onsubmit="if (!confirm(\''.$text_confirm.'\')) return false;">';
$data[4] .= html_print_input_hidden('delete_action', 1, true);
$data[4] .= html_print_input_hidden('id', $id_action, true);
$data[4] .= html_print_input_image(
'del',
'images/cross.png',
1,
'',
true,
['title' => __('Delete')]
);
$data[4] .= '</form> ';
} else {
$data[4] = '';
}
} }
array_push($table->data, $data); array_push($table->data, $data);
@ -458,44 +470,3 @@ if (is_central_policies_on_node() === false) {
enterprise_hook('close_meta_frame'); enterprise_hook('close_meta_frame');
?> ?>
<script type="text/javascript">
function copy_action(id_action, text_confirm) {
if (!confirm(text_confirm)) {
return false;
} else {
jQuery.post ("ajax.php",
{
"page" : "godmode/alerts/alert_actions",
"copy_action" : 1,
"id" : id_action
},
function (data, status) {
// No data.
},
"json"
);
}
}
function delete_action(id_action, text_confirm) {
if (!confirm(text_confirm)) {
return false;
} else {
jQuery.post ("ajax.php",
{
"page" : "godmode/alerts/alert_actions",
"delete_action" : 1,
"id" : id_action
},
function (data, status) {
// No data.
},
"json"
);
}
}
</script>

View File

@ -28,12 +28,6 @@ if (! check_acl($config['id_user'], 0, 'LM')) {
exit; exit;
} }
if (!check_acl($config['id_user'], 0, 'PM') && !is_user_admin($config['id_user'])) {
echo "<div id='message_permissions' title='".__('Permissions warning')."' style='display:none;'>";
echo "<p style='text-align: center;font-weight: bold;'>".__('Command management is limited to administrator users or user profiles with permissions over Pandora FMS management').'</p>';
echo '</div>';
}
if (is_metaconsole()) { if (is_metaconsole()) {
$sec = 'advanced'; $sec = 'advanced';
} else { } else {
@ -46,6 +40,8 @@ $create_command = (bool) get_parameter('create_command');
$delete_command = (bool) get_parameter('delete_command'); $delete_command = (bool) get_parameter('delete_command');
$copy_command = (bool) get_parameter('copy_command'); $copy_command = (bool) get_parameter('copy_command');
$url = 'index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands';
if (is_ajax()) { if (is_ajax()) {
$get_alert_command = (bool) get_parameter('get_alert_command'); $get_alert_command = (bool) get_parameter('get_alert_command');
if ($get_alert_command) { if ($get_alert_command) {
@ -465,6 +461,20 @@ if (is_ajax()) {
return; return;
} }
// This check should be after ajax. Because, ajax will be called from configure_alert_action.
if (!check_acl($config['id_user'], 0, 'PM') && !is_user_admin(
$config['id_user
']
)
) {
echo "<div id='message_permissions' title='".__('Permissions warning')."' s
tyle='display:none;'>";
echo "<p style='text-align: center;font-weight: bold; margin: 15px'>".__(
'Command management is limited to administrator users or user profiles with permissions PM'
).'</p>';
echo '</div>';
}
enterprise_hook('open_meta_frame'); enterprise_hook('open_meta_frame');
if ($update_command) { if ($update_command) {
@ -634,6 +644,12 @@ if ($commands === false) {
$commands = []; $commands = [];
} }
// Pagination.
$total_commands = count($commands);
$offset = (int) get_parameter('offset');
$limit = (int) $config['block_size'];
$commands = array_slice($commands, $offset, $limit);
foreach ($commands as $command) { foreach ($commands as $command) {
$data = []; $data = [];
@ -667,21 +683,35 @@ foreach ($commands as $command) {
// (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group. // (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group.
if ($is_central_policies_on_node === false && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) { if ($is_central_policies_on_node === false && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) {
$data['action'] = '<span class="inline_flex">'; if (check_acl($config['id_user'], 0, 'PM') || is_user_admin(
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&amp;copy_command=1&id='.$command['id'].'&pure='.$pure.'" $config['id_user
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/copy.png', true, ['class' => 'invert_filter']).'</a>'; ']
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&delete_command=1&id='.$command['id'].'&pure='.$pure.'" )
) {
$data['action'] = '<span class="inline_flex">';
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&amp;copy_command=1&id='.$command['id'].'&pure='.$pure.'"
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/copy.png', true, ['class' => 'invert_filter']).'</a>';
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&delete_command=1&id='.$command['id'].'&pure='.$pure.'"
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['class' => 'invert_filter']).'</a>'; onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['class' => 'invert_filter']).'</a>';
$data['action'] .= '</span>'; $data['action'] .= '</span>';
}
} }
array_push($table->data, $data); array_push($table->data, $data);
} }
if (count($table->data) > 0) { ui_pagination($total_commands, $url);
if (isset($data) === true && count($table->data) > 0) {
html_print_table($table); html_print_table($table);
ui_pagination($total_commands, $url, 0, 0, false, 'offset', true, 'pagination-bottom');
} else { } else {
ui_print_info_message(['no_close' => true, 'message' => __('No alert commands configured') ]); ui_print_info_message(
[
'no_close' => true,
'message' => __('No alert commands configured'),
]
);
} }
if ($is_central_policies_on_node === false && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) { if ($is_central_policies_on_node === false && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) {

View File

@ -882,9 +882,11 @@ foreach ($simple_alerts as $alert) {
['title' => __('Add action')] ['title' => __('Add action')]
); );
} else { } else {
$data[4] .= '<a href="javascript:show_add_action(\''.$alert['id'].'\');">'; if ((int) $alert['id_policy_alerts'] === 0) {
$data[4] .= html_print_image('images/add.png', true, ['title' => __('Add action'), 'class' => 'invert_filter']); $data[4] .= '<a href="javascript:show_add_action(\''.$alert['id'].'\');">';
$data[4] .= '</a>'; $data[4] .= html_print_image('images/add.png', true, ['title' => __('Add action'), 'class' => 'invert_filter']);
$data[4] .= '</a>';
}
} }
} }

View File

@ -401,17 +401,16 @@ foreach ($templates as $template) {
$data = []; $data = [];
if (check_acl_restricted_all($config['id_user'], $template['id_group'], 'LM')) { $data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&id='.$template['id'].'&pure='.$pure.'">'.$template['name'].'</a>';
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&id='.$template['id'].'&pure='.$pure.'">'.$template['name'].'</a>'; if (!check_acl_restricted_all($config['id_user'], $template['id_group'], 'LM')) {
} else { $data[0] .= ui_print_help_tip(__('You cannot edit this alert template, You don\'t have the permission to edit All group.'), true);
$data[0] = $template['name'];
} }
$data[1] = ui_print_group_icon($template['id_group'], true); $data[1] = ui_print_group_icon($template['id_group'], true);
$data[3] = alerts_get_alert_templates_type_name($template['type']); $data[3] = alerts_get_alert_templates_type_name($template['type']);
if (is_central_policies_on_node() === false if (is_central_policies_on_node() === false
&& check_acl_restricted_all($config['id_user'], $template['id_group'], 'LM') && check_acl($config['id_user'], $template['id_group'], 'LM')
) { ) {
$table->cellclass[][4] = 'action_buttons'; $table->cellclass[][4] = 'action_buttons';
$data[4] = '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'" class="float-left inline_line">'; $data[4] = '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'" class="float-left inline_line">';
@ -427,18 +426,20 @@ foreach ($templates as $template) {
); );
$data[4] .= '</form> '; $data[4] .= '</form> ';
$data[4] .= '<form method="post" class="float-right inline_line" onsubmit="if (!confirm(\''.__('Are you sure?').'\')) return false;">'; if (check_acl_restricted_all($config['id_user'], $template['id_group'], 'LM')) {
$data[4] .= html_print_input_hidden('delete_template', 1, true); $data[4] .= '<form method="post" class="float-right inline_line" onsubmit="if (!confirm(\''.__('Are you sure?').'\')) return false;">';
$data[4] .= html_print_input_hidden('id', $template['id'], true); $data[4] .= html_print_input_hidden('delete_template', 1, true);
$data[4] .= html_print_input_image( $data[4] .= html_print_input_hidden('id', $template['id'], true);
'del', $data[4] .= html_print_input_image(
'images/cross.png', 'del',
1, 'images/cross.png',
'', 1,
true, '',
['title' => __('Delete')] true,
); ['title' => __('Delete')]
$data[4] .= '</form> '; );
$data[4] .= '</form> ';
}
} else { } else {
$data[4] = ''; $data[4] = '';
} }

View File

@ -58,7 +58,7 @@ if (defined('METACONSOLE')) {
if ($al_action !== false) { if ($al_action !== false) {
$own_info = get_user_info($config['id_user']); $own_info = get_user_info($config['id_user']);
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { if ($own_info['is_admin'] || check_acl_restricted_all($config['id_user'], 0, 'LM')) {
$own_groups = array_keys(users_get_groups($config['id_user'], 'LM')); $own_groups = array_keys(users_get_groups($config['id_user'], 'LM'));
} else { } else {
$own_groups = array_keys(users_get_groups($config['id_user'], 'LM', false)); $own_groups = array_keys(users_get_groups($config['id_user'], 'LM', false));
@ -91,8 +91,15 @@ if ($al_action !== false) {
true true
); );
} }
$is_in_group = true;
} }
if (!$is_in_group && $al_action['id_group'] != 0) {
db_pandora_audit('ACL Violation', 'Trying to access unauthorized alert action configuration');
include 'general/noaccess.php';
exit;
}
$is_central_policies_on_node = is_central_policies_on_node(); $is_central_policies_on_node = is_central_policies_on_node();
@ -102,6 +109,11 @@ if ($is_central_policies_on_node === true) {
); );
} }
$disabled = !$is_in_group;
$disabled_attr = '';
if ($disabled) {
$disabled_attr = 'disabled="disabled"';
}
$name = ''; $name = '';
$id_command = ''; $id_command = '';
@ -116,15 +128,6 @@ if ($id) {
$group = $action['id_group']; $group = $action['id_group'];
$action_threshold = $action['action_threshold']; $action_threshold = $action['action_threshold'];
$create_wu_integria = $action['create_wu_integria']; $create_wu_integria = $action['create_wu_integria'];
if (!check_acl_restricted_all($config['id_user'], $action['id_group'], 'LM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
);
include 'general/noaccess.php';
exit;
}
} }
// Hidden div with help hint to fill with javascript. // Hidden div with help hint to fill with javascript.
@ -175,7 +178,7 @@ $table->data[0][1] = html_print_input_text(
'', '',
'', '',
'', '',
$is_central_policies_on_node ($is_central_policies_on_node | $disabled)
); );
if (io_safe_output($name) == 'Monitoring Event') { if (io_safe_output($name) == 'Monitoring Event') {
@ -194,7 +197,7 @@ $own_info = get_user_info($config['id_user']);
$return_all_group = false; $return_all_group = false;
if (users_can_manage_group_all('LW') === true) { if (users_can_manage_group_all('LW') === true || $disabled) {
$return_all_group = true; $return_all_group = true;
} }
@ -211,7 +214,7 @@ $table->data[1][1] = '<div class="w250px inline">'.html_print_select_groups(
false, false,
true, true,
'', '',
$is_central_policies_on_node ($is_central_policies_on_node | $disabled)
).'</div>'; ).'</div>';
$table->colspan[1][1] = 2; $table->colspan[1][1] = 2;
@ -245,11 +248,11 @@ $table->data[2][1] = html_print_select_from_sql(
true, true,
false, false,
false, false,
$is_central_policies_on_node ($is_central_policies_on_node | $disabled)
); );
$table->data[2][1] .= ' '; $table->data[2][1] .= ' ';
if ($is_central_policies_on_node === false if ($is_central_policies_on_node === false
&& check_acl($config['id_user'], 0, 'PM') && check_acl($config['id_user'], 0, 'PM') && !$disabled
) { ) {
$table->data[2][1] .= __('Create Command'); $table->data[2][1] .= __('Create Command');
$table->data[2][1] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">'; $table->data[2][1] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">';
@ -272,7 +275,7 @@ $table->data[3][1] = html_print_extended_select_for_time(
false, false,
true, true,
'', '',
$is_central_policies_on_node, ($is_central_policies_on_node | $disabled),
false, false,
'', '',
false, false,
@ -304,11 +307,21 @@ $table->data[5][2] = html_print_textarea(
true true
); );
$table->data[6][0] = __('Create workunit on recovery').ui_print_help_tip( // Selector will work only with Integria activated.
$integriaIdName = 'integria_wu';
$table->data[$integriaIdName][0] = __('Create workunit on recovery').ui_print_help_tip(
__('If closed status is set on recovery, a workunit will be added to the ticket in Integria IMS rather that closing the ticket.'), __('If closed status is set on recovery, a workunit will be added to the ticket in Integria IMS rather that closing the ticket.'),
true true
); );
$table->data[6][1] = html_print_checkbox_switch_extended('create_wu_integria', 1, $create_wu_integria, false, '', '', true); $table->data[$integriaIdName][1] = html_print_checkbox_switch_extended(
'create_wu_integria',
1,
$create_wu_integria,
false,
'',
$disabled_attr,
true
);
for ($i = 1; $i <= $config['max_macro_fields']; $i++) { for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
$table->data['field'.$i][0] = html_print_image( $table->data['field'.$i][0] = html_print_image(
@ -328,17 +341,21 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
$table->data['field'.$i][1] .= html_print_input_hidden( $table->data['field'.$i][1] .= html_print_input_hidden(
'field'.$i.'_value', 'field'.$i.'_value',
(!empty($action['field'.$i]) || $action['field'.$i] == 0) ? $action['field'.$i] : '', (!empty($action['field'.$i]) || $action['field'.$i] == 0) ? $action['field'.$i] : '',
true true,
'',
$disabled_attr
); );
$table->data['field'.$i][2] .= html_print_input_hidden( $table->data['field'.$i][2] .= html_print_input_hidden(
'field'.$i.'_recovery_value', 'field'.$i.'_recovery_value',
(!empty($action['field'.$i.'_recovery']) || $action['field'.$i] == 0) ? $action['field'.$i.'_recovery'] : '', (!empty($action['field'.$i.'_recovery']) || $action['field'.$i] == 0) ? $action['field'.$i.'_recovery'] : '',
true true,
'',
$disabled_attr
); );
} }
echo '<form method="post" action="'.'index.php?sec='.$sec.'&'.'sec2=godmode/alerts/alert_actions&'.'pure='.$pure.'">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions&pure='.$pure.'">';
$table_html = html_print_table($table, true); $table_html = html_print_table($table, true);
echo $table_html; echo $table_html;
@ -346,18 +363,7 @@ if ($is_central_policies_on_node === false) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) { if ($id) {
html_print_input_hidden('id', $id); html_print_input_hidden('id', $id);
if ($al_action['id_group'] == 0) { if (!$disabled) {
// Then must have "PM" access privileges.
if (check_acl($config['id_user'], 0, 'PM')) {
html_print_input_hidden('update_action', 1);
html_print_submit_button(
__('Update'),
'create',
false,
'class="sub upd"'
);
}
} else {
html_print_input_hidden('update_action', 1); html_print_input_hidden('update_action', 1);
html_print_submit_button( html_print_submit_button(
__('Update'), __('Update'),
@ -365,6 +371,12 @@ if ($is_central_policies_on_node === false) {
false, false,
'class="sub upd"' 'class="sub upd"'
); );
} else {
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions">';
html_print_submit_button(__('Back'), 'back', false, 'class="sub upd"');
echo '</form>';
echo '</div>';
} }
} else { } else {
html_print_input_hidden('create_action', 1); html_print_input_hidden('create_action', 1);
@ -391,6 +403,7 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
$(document).ready (function () { $(document).ready (function () {
var original_command; var original_command;
var origicommand_descriptionnal_command; var origicommand_descriptionnal_command;
var integriaWorkUnitName = "<?php echo $integriaIdName; ?>";
if (<?php echo (int) $id_command; ?>) { if (<?php echo (int) $id_command; ?>) {
original_command = "<?php echo str_replace("\r\n", '<br>', addslashes(io_safe_output(alerts_get_alert_command_command($id_command)))); ?>"; original_command = "<?php echo str_replace("\r\n", '<br>', addslashes(io_safe_output(alerts_get_alert_command_command($id_command)))); ?>";
@ -592,6 +605,13 @@ $(document).ready (function () {
} }
// Allow create workunit if Integria IMS Ticket is selected.
if (data['id'] == '14') {
$("#table_macros-"+integriaWorkUnitName).css('display', 'table-row');
} else {
$("#table_macros-"+integriaWorkUnitName).css('display', 'none');
}
var max_fields = parseInt('<?php echo $config['max_macro_fields']; ?>'); var max_fields = parseInt('<?php echo $config['max_macro_fields']; ?>');
// Change the selected group // Change the selected group
@ -608,6 +628,7 @@ $(document).ready (function () {
for (i = 1; i <= max_fields; i++) { for (i = 1; i <= max_fields; i++) {
var old_value = ''; var old_value = '';
var old_recovery_value = ''; var old_recovery_value = '';
var disabled = '';
var field_row = data["fields_rows"][i]; var field_row = data["fields_rows"][i];
var $table_macros_field = $('#table_macros-field' + i); var $table_macros_field = $('#table_macros-field' + i);
@ -623,6 +644,7 @@ $(document).ready (function () {
== ("hidden-field" + i + "_value")) { == ("hidden-field" + i + "_value")) {
old_value = $("[name=field" + i + "_value]").val(); old_value = $("[name=field" + i + "_value]").val();
disabled = $("[name=field" + i + "_value]").attr('disabled');
} }
if (($("[name=field" + i + "_recovery_value]").attr('id')) if (($("[name=field" + i + "_recovery_value]").attr('id'))
@ -689,6 +711,10 @@ $(document).ready (function () {
$('#help_alert_macros_hint').html()); $('#help_alert_macros_hint').html());
} }
if (disabled) {
$("[name=field" + i + "_value]").attr('disabled','disabled');
$("[name=field" + i + "_recovery_value]").attr('disabled','disabled');
}
$table_macros_field.show(); $table_macros_field.show();
} }

View File

@ -38,7 +38,6 @@ $step = (int) get_parameter('step', 1);
// We set here the number of steps. // We set here the number of steps.
define('LAST_STEP', 3); define('LAST_STEP', 3);
// If user tries to duplicate/edit a template with group=ALL then must have "PM" access privileges
if ($duplicate_template) { if ($duplicate_template) {
$source_id = (int) get_parameter('source_id'); $source_id = (int) get_parameter('source_id');
$a_template = alerts_get_alert_template($source_id); $a_template = alerts_get_alert_template($source_id);
@ -52,19 +51,14 @@ if (defined('METACONSOLE')) {
$sec = 'galertas'; $sec = 'galertas';
} }
$can_edit_all = false;
if (check_acl_restricted_all($config['id_user'], 0, 'LM')) {
$can_edit_all = true;
}
if ($a_template !== false) { if ($a_template !== false) {
// If user tries to duplicate/edit a template with group=ALL // If user tries to duplicate/edit a template with group=ALL
if ($a_template['id_group'] == 0) { if ($a_template['id_group'] == 0) {
if (users_can_manage_group_all('LM') === false) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
);
include 'general/noaccess.php';
exit;
}
// Header
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
alerts_meta_print_header(); alerts_meta_print_header();
} else { } else {
@ -146,7 +140,12 @@ if ($a_template !== false) {
if ($duplicate_template) { if ($duplicate_template) {
$source_id = (int) get_parameter('source_id'); $source_id = (int) get_parameter('source_id');
$id = alerts_duplicate_alert_template($source_id); // If user doesn't have the permission to access All group and source template is All group, then group is changed to the first group of user.
if ($can_edit_all == false && a_template['id_group'] == 0) {
$a_template['id_group'] = users_get_first_group(false, 'LM', false);
}
$id = alerts_duplicate_alert_template($source_id, $a_template['id_group']);
if ($id) { if ($id) {
db_pandora_audit('Template alert management', 'Duplicate alert template '.$source_id.' clone to '.$id); db_pandora_audit('Template alert management', 'Duplicate alert template '.$source_id.' clone to '.$id);
@ -386,6 +385,14 @@ $create_alert = (bool) get_parameter('create_alert');
$create_template = (bool) get_parameter('create_template'); $create_template = (bool) get_parameter('create_template');
$update_template = (bool) get_parameter('update_template'); $update_template = (bool) get_parameter('update_template');
$disabled = false;
if (!$create_alert && !$create_template) {
// When user edits a template with All group, user must have "LM" access privileges againt All group.
if ($a_template['id_group'] == 0 && !$can_edit_all) {
$disabled = true;
}
}
$name = ''; $name = '';
$description = ''; $description = '';
$type = ''; $type = '';
@ -602,7 +609,7 @@ if ($step == 2) {
1, 1,
$monday, $monday,
true, true,
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[0][1] .= __('Tue'); $table->data[0][1] .= __('Tue');
$table->data[0][1] .= html_print_checkbox( $table->data[0][1] .= html_print_checkbox(
@ -610,7 +617,7 @@ if ($step == 2) {
1, 1,
$tuesday, $tuesday,
true, true,
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[0][1] .= __('Wed'); $table->data[0][1] .= __('Wed');
$table->data[0][1] .= html_print_checkbox( $table->data[0][1] .= html_print_checkbox(
@ -618,7 +625,7 @@ if ($step == 2) {
1, 1,
$wednesday, $wednesday,
true, true,
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[0][1] .= __('Thu'); $table->data[0][1] .= __('Thu');
$table->data[0][1] .= html_print_checkbox( $table->data[0][1] .= html_print_checkbox(
@ -626,7 +633,7 @@ if ($step == 2) {
1, 1,
$thursday, $thursday,
true, true,
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[0][1] .= __('Fri'); $table->data[0][1] .= __('Fri');
$table->data[0][1] .= html_print_checkbox( $table->data[0][1] .= html_print_checkbox(
@ -634,7 +641,7 @@ if ($step == 2) {
1, 1,
$friday, $friday,
true, true,
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[0][1] .= __('Sat'); $table->data[0][1] .= __('Sat');
$table->data[0][1] .= html_print_checkbox( $table->data[0][1] .= html_print_checkbox(
@ -642,7 +649,7 @@ if ($step == 2) {
1, 1,
$saturday, $saturday,
true, true,
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[0][1] .= __('Sun'); $table->data[0][1] .= __('Sun');
$table->data[0][1] .= html_print_checkbox( $table->data[0][1] .= html_print_checkbox(
@ -650,7 +657,7 @@ if ($step == 2) {
1, 1,
$sunday, $sunday,
true, true,
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[0][2] = __('Use special days list'); $table->data[0][2] = __('Use special days list');
@ -659,7 +666,7 @@ if ($step == 2) {
1, 1,
$special_day, $special_day,
true, true,
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[1][0] = __('Time from'); $table->data[1][0] = __('Time from');
@ -680,7 +687,7 @@ if ($step == 2) {
'', '',
'', '',
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[1][2] = __('Time to'); $table->data[1][2] = __('Time to');
$table->data[1][3] = html_print_input_text( $table->data[1][3] = html_print_input_text(
@ -700,7 +707,7 @@ if ($step == 2) {
'', '',
'', '',
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->colspan['threshold'][1] = 3; $table->colspan['threshold'][1] = 3;
@ -716,7 +723,7 @@ if ($step == 2) {
false, false,
true, true,
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[3][0] = __('Min. number of alerts'); $table->data[3][0] = __('Min. number of alerts');
@ -737,7 +744,7 @@ if ($step == 2) {
'', '',
'', '',
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[3][2] = __('Reset counter for non-sustained alerts'); $table->data[3][2] = __('Reset counter for non-sustained alerts');
@ -750,7 +757,7 @@ if ($step == 2) {
1, 1,
$min_alerts_reset_counter, $min_alerts_reset_counter,
true, true,
$is_central_policies_on_node, $is_central_policies_on_node | $disabled,
'', '',
false, false,
$create_template == 1 ? 'checked=checked' : '' $create_template == 1 ? 'checked=checked' : ''
@ -774,7 +781,7 @@ if ($step == 2) {
'', '',
'', '',
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[4][2] = __('Disable event'); $table->data[4][2] = __('Disable event');
@ -783,7 +790,7 @@ if ($step == 2) {
1, 1,
$disable_event, $disable_event,
true, true,
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[5][0] = __('Default action'); $table->data[5][0] = __('Default action');
@ -811,7 +818,7 @@ if ($step == 2) {
true, true,
false, false,
false, false,
$is_central_policies_on_node, $is_central_policies_on_node | $disabled,
false, false,
false, false,
0 0
@ -833,7 +840,7 @@ if ($step == 2) {
false, false,
false, false,
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[6][1] .= '<span id="matches_value" '.($show_matches ? '' : 'class="invisible"').'>'; $table->data[6][1] .= '<span id="matches_value" '.($show_matches ? '' : 'class="invisible"').'>';
$table->data[6][1] .= '&nbsp;'.html_print_checkbox('matches_value', 1, $matches, true); $table->data[6][1] .= '&nbsp;'.html_print_checkbox('matches_value', 1, $matches, true);
@ -886,7 +893,8 @@ if ($step == 2) {
'', '',
5, 5,
255, 255,
true true,
$disabled
); );
$table->colspan['min'][1] = 3; $table->colspan['min'][1] = 3;
@ -897,7 +905,8 @@ if ($step == 2) {
'', '',
5, 5,
255, 255,
true true,
$disabled
); );
$table->colspan['max'][1] = 3; $table->colspan['max'][1] = 3;
@ -940,7 +949,7 @@ if ($step == 2) {
false, false,
false, false,
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->colspan[0][1] = 2; $table->colspan[0][1] = 2;
@ -966,7 +975,7 @@ if ($step == 2) {
0, 0,
'', '',
false, false,
$is_central_policies_on_node, $is_central_policies_on_node | $disabled,
"removeTinyMCE('textarea_field".$i."')", "removeTinyMCE('textarea_field".$i."')",
'', '',
true true
@ -979,7 +988,7 @@ if ($step == 2) {
0, 0,
'', '',
true, true,
$is_central_policies_on_node, $is_central_policies_on_node | $disabled,
"addTinyMCE('textarea_field".$i."')", "addTinyMCE('textarea_field".$i."')",
'', '',
true true
@ -995,7 +1004,7 @@ if ($step == 2) {
'class="fields" min-height-40px', 'class="fields" min-height-40px',
true, true,
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
// Recovery. // Recovery.
@ -1007,7 +1016,7 @@ if ($step == 2) {
0, 0,
'', '',
false, false,
$is_central_policies_on_node, $is_central_policies_on_node | $disabled,
"removeTinyMCE('textarea_field".$i."_recovery')", "removeTinyMCE('textarea_field".$i."_recovery')",
'', '',
true true
@ -1020,7 +1029,7 @@ if ($step == 2) {
0, 0,
'', '',
true, true,
$is_central_policies_on_node, $is_central_policies_on_node | $disabled,
"addTinyMCE('textarea_field".$i."_recovery')", "addTinyMCE('textarea_field".$i."_recovery')",
'', '',
true true
@ -1036,7 +1045,7 @@ if ($step == 2) {
'class="fields min-height-40px"', 'class="fields min-height-40px"',
true, true,
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
} }
} else { } else {
@ -1093,7 +1102,7 @@ if ($step == 2) {
'', '',
'', '',
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
@ -1103,8 +1112,12 @@ if ($step == 2) {
$return_all_group = false; $return_all_group = false;
if (users_can_manage_group_all('LM') === true) { if (users_can_manage_group_all('LM') === true || $disabled) {
$return_all_group = true; $return_all_group = true;
} else {
if ($id_group == 0) {
$id_group = users_get_first_group(false, 'LM', false);
}
} }
$table->data[0][1] .= '&nbsp;'; $table->data[0][1] .= '&nbsp;';
@ -1121,7 +1134,7 @@ if ($step == 2) {
false, false,
true, true,
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
).'</div>'; ).'</div>';
@ -1134,7 +1147,7 @@ if ($step == 2) {
'', '',
true, true,
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
$table->data[2][0] = __('Priority'); $table->data[2][0] = __('Priority');
@ -1149,7 +1162,7 @@ if ($step == 2) {
false, false,
false, false,
'', '',
$is_central_policies_on_node $is_central_policies_on_node | $disabled
); );
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
@ -1186,16 +1199,6 @@ if ($id) {
html_print_input_hidden('create_template', 1); html_print_input_hidden('create_template', 1);
} }
$disabled = false;
if (!$create_alert && !$create_template) {
if ($a_template['id_group'] == 0) {
// then must have "PM" access privileges
if (! check_acl($config['id_user'], 0, 'PM')) {
$disabled = true;
}
}
}
if (!$disabled) { if (!$disabled) {
if ($is_central_policies_on_node === false) { if ($is_central_policies_on_node === false) {
if ($step >= LAST_STEP) { if ($step >= LAST_STEP) {

View File

@ -44,7 +44,7 @@ $sec2 = safe_url_extraclean($sec2);
$sec = get_parameter_get('sec'); $sec = get_parameter_get('sec');
$sec = safe_url_extraclean($sec); $sec = safe_url_extraclean($sec);
// Layers // Layers.
$layer_ids = get_parameter('layer_ids', []); $layer_ids = get_parameter('layer_ids', []);
$layers = get_parameter('layers', []); $layers = get_parameter('layers', []);
$layer_list = []; $layer_list = [];
@ -84,9 +84,10 @@ switch ($action) {
$map_default_latitude = get_parameter('map_default_latitude'); $map_default_latitude = get_parameter('map_default_latitude');
$map_default_altitude = get_parameter('map_default_altitude'); $map_default_altitude = get_parameter('map_default_altitude');
$map_group_id = get_parameter('map_group_id'); $map_group_id = get_parameter('map_group_id');
$map_levels_zoom = get_parameter('map_levels_zoom'); $map_levels_zoom = get_parameter('map_levels_zoom', 16);
$map_connection_list_temp = explode(',', get_parameter('map_connection_list')); $map_connection_list_temp = explode(',', get_parameter('map_connection_list'));
$listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection');
foreach ($map_connection_list_temp as $index => $value) { foreach ($map_connection_list_temp as $index => $value) {
@ -99,14 +100,14 @@ switch ($action) {
$map_connection_default = get_parameter('map_connection_default'); $map_connection_default = get_parameter('map_connection_default');
$map_connection_list = []; $map_connection_list = [];
foreach ($map_connection_list_temp as $idMapConnection) { foreach ($listConnectionTemp as $idMapConnection) {
$default = 0; $default = 0;
if ($map_connection_default == $idMapConnection) { if ($map_connection_default == $idMapConnection['id_tmap_connection']) {
$default = 1; $default = 1;
} }
$map_connection_list[] = [ $map_connection_list[] = [
'id_conection' => $idMapConnection, 'id_conection' => $idMapConnection['id_tmap_connection'],
'default' => $default, 'default' => $default,
]; ];
} }
@ -124,7 +125,7 @@ switch ($action) {
$map_levels_zoom $map_levels_zoom
); );
if (empty($invalidFields) && get_parameter('map_connection_list') != '') { if (empty($invalidFields)) {
$idMap = gis_save_map( $idMap = gis_save_map(
$map_name, $map_name,
$map_initial_longitude, $map_initial_longitude,
@ -139,8 +140,13 @@ switch ($action) {
$map_connection_list, $map_connection_list,
$layer_list $layer_list
); );
$mapCreatedOk = true; if ($idMap) {
$next_action = 'update_saved'; $mapCreatedOk = true;
$next_action = 'update_saved';
} else {
$next_action = 'save_new';
$mapCreatedOk = false;
}
} else { } else {
$next_action = 'save_new'; $next_action = 'save_new';
$mapCreatedOk = false; $mapCreatedOk = false;
@ -168,7 +174,7 @@ switch ($action) {
$map_group_id = ''; $map_group_id = '';
$map_connection_list = []; $map_connection_list = [];
$layer_list = []; $layer_list = [];
$map_levels_zoom = 0; $map_levels_zoom = 16;
break; break;
case 'edit_map': case 'edit_map':
@ -188,9 +194,12 @@ switch ($action) {
$map_default_latitude = get_parameter('map_default_latitude'); $map_default_latitude = get_parameter('map_default_latitude');
$map_default_altitude = get_parameter('map_default_altitude'); $map_default_altitude = get_parameter('map_default_altitude');
$map_group_id = get_parameter('map_group_id'); $map_group_id = get_parameter('map_group_id');
$map_levels_zoom = get_parameter('map_levels_zoom'); $map_levels_zoom = get_parameter('map_levels_zoom', 16);
$map_connection_list_temp = explode(',', get_parameter('map_connection_list')); $map_connection_list_temp = explode(',', get_parameter('map_connection_list'));
$listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection');
foreach ($map_connection_list_temp as $index => $value) { foreach ($map_connection_list_temp as $index => $value) {
$cleanValue = trim($value); $cleanValue = trim($value);
if ($cleanValue == '') { if ($cleanValue == '') {
@ -201,14 +210,14 @@ switch ($action) {
$map_connection_default = get_parameter('map_connection_default'); $map_connection_default = get_parameter('map_connection_default');
$map_connection_list = []; $map_connection_list = [];
foreach ($map_connection_list_temp as $idMapConnection) { foreach ($listConnectionTemp as $idMapConnection) {
$default = 0; $default = 0;
if ($map_connection_default == $idMapConnection) { if ($map_connection_default == $idMapConnection['id_tmap_connection']) {
$default = 1; $default = 1;
} }
$map_connection_list[] = [ $map_connection_list[] = [
'id_conection' => $idMapConnection, 'id_conection' => $idMapConnection['id_tmap_connection'],
'default' => $default, 'default' => $default,
]; ];
} }
@ -226,7 +235,7 @@ switch ($action) {
$map_levels_zoom $map_levels_zoom
); );
if (empty($invalidFields) && get_parameter('map_connection_list') != '') { if (empty($invalidFields)) {
// TODO // TODO
gis_update_map( gis_update_map(
$idMap, $idMap,
@ -263,7 +272,7 @@ switch ($action) {
$url = 'index.php?sec='.$sec.'&sec2='.$sec2.'&map_id='.$idMap.'&action='.$next_action; $url = 'index.php?sec='.$sec.'&sec2='.$sec2.'&map_id='.$idMap.'&action='.$next_action;
$buttons['gis_maps_list'] = [ $buttons['gis_maps_list'] = [
'active' => true, 'active' => false,
'text' => '<a href="index.php?sec=godgismaps&sec2=operation/gis_maps/gis_map">'.html_print_image( 'text' => '<a href="index.php?sec=godgismaps&sec2=operation/gis_maps/gis_map">'.html_print_image(
'images/list.png', 'images/list.png',
true, true,
@ -275,7 +284,7 @@ $buttons['gis_maps_list'] = [
]; ];
if ($idMap) { if ($idMap) {
$buttons['view_gis'] = [ $buttons['view_gis'] = [
'active' => true, 'active' => false,
'text' => '<a href="index.php?sec=gismaps&sec2=operation/gis_maps/render_view&map_id='.$idMap.'">'.html_print_image( 'text' => '<a href="index.php?sec=gismaps&sec2=operation/gis_maps/render_view&map_id='.$idMap.'">'.html_print_image(
'images/op_gis.png', 'images/op_gis.png',
true, true,
@ -457,7 +466,7 @@ $table->data[1][0] = __('Add Map connection').$iconError;
$table->data[1][1] = "<table class='no-class' border='0' id='map_connection'> $table->data[1][1] = "<table class='no-class' border='0' id='map_connection'>
<tr> <tr>
<td > <td >
".html_print_select($listConnection, 'map_connection', '', '', '', '0', true)." ".html_print_select($listConnection, 'map_connection_list', '', '', '', '0', true)."
</td> </td>
<td > <td >
<a href='javascript: addConnectionMap();'>".html_print_image( <a href='javascript: addConnectionMap();'>".html_print_image(
@ -504,7 +513,11 @@ $table->data[2][1] = html_print_select_groups(
); );
$table->data[3][0] = __('Default zoom'); $table->data[3][0] = __('Default zoom');
$table->data[3][1] = html_print_input_text('map_zoom_level', $map_zoom_level, '', 2, 4, true).html_print_input_hidden('map_levels_zoom', $map_levels_zoom, true); $table->data[3][1] = html_print_input_text('map_zoom_level', $map_zoom_level, '', 2, 4, true).html_print_input_hidden(
'map_levels_zoom',
$map_levels_zoom,
true
);
$table->data[4][0] = __('Center Latitude').':'; $table->data[4][0] = __('Center Latitude').':';
$table->data[4][1] = html_print_input_text('map_initial_latitude', $map_initial_latitude, '', 8, 8, true); $table->data[4][1] = html_print_input_text('map_initial_latitude', $map_initial_latitude, '', 8, 8, true);
@ -571,6 +584,9 @@ $params['hidden_input_idagent_name'] = 'agent_id';
$params['input_name'] = 'agent_alias'; $params['input_name'] = 'agent_alias';
$params['value'] = ''; $params['value'] = '';
$params['javascript_function_action_after_select'] = 'active_button_add_agent'; $params['javascript_function_action_after_select'] = 'active_button_add_agent';
$params['javascript_is_function_select'] = true;
$params['disabled_javascript_on_blur_function'] = false;
$table->data[1][1] .= ui_print_agent_autocomplete_input($params); $table->data[1][1] .= ui_print_agent_autocomplete_input($params);
@ -585,7 +601,7 @@ $table->data[1][1] .= '</td>
</td> </td>
</tr>'; </tr>';
// Group items // Group items.
$group_select = html_print_select_groups($config['id_user'], 'AR', false, 'layer_group_id', '', '', '', 0, true); $group_select = html_print_select_groups($config['id_user'], 'AR', false, 'layer_group_id', '', '', '', 0, true);
$params = []; $params = [];
$params['return'] = true; $params['return'] = true;
@ -597,8 +613,10 @@ $params['input_name'] = 'agent_alias_for_data';
$params['value'] = ''; $params['value'] = '';
$params['javascript_function_action_after_select'] = 'toggleAddGroupBtn'; $params['javascript_function_action_after_select'] = 'toggleAddGroupBtn';
$params['selectbox_group'] = 'layer_group_id'; $params['selectbox_group'] = 'layer_group_id';
// Filter by group $params['javascript_is_function_select'] = true;
$params['disabled_javascript_on_blur_function'] = true;
// Filter by group.
$params['disabled_javascript_on_blur_function'] = false;
$agent_for_group_input = ui_print_agent_autocomplete_input($params); $agent_for_group_input = ui_print_agent_autocomplete_input($params);
$add_group_btn = html_print_button(__('Add'), 'add_group', true, '', 'class="sub add"', true); $add_group_btn = html_print_button(__('Add'), 'add_group', true, '', 'class="sub add"', true);

View File

@ -1,16 +1,32 @@
<?php <?php
/**
* Configure agent groups.
*
* @category Agents group management.
* @package Pandora FMS
* @subpackage User interface.
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 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
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* 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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 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
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// 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.
global $config; global $config;
check_login(); check_login();
@ -27,7 +43,7 @@ require_once $config['homedir'].'/include/functions_groups.php';
require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_users.php';
enterprise_include_once('meta/include/functions_agents_meta.php'); enterprise_include_once('meta/include/functions_agents_meta.php');
// Init vars // Default values.
$icon = ''; $icon = '';
$name = ''; $name = '';
$id_parent = 0; $id_parent = 0;
@ -39,6 +55,7 @@ $skin = 0;
$contact = ''; $contact = '';
$other = ''; $other = '';
$description = ''; $description = '';
$max_agents = 0;
$create_group = (bool) get_parameter('create_group'); $create_group = (bool) get_parameter('create_group');
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
@ -62,6 +79,7 @@ if ($id_group) {
$description = $group['description']; $description = $group['description'];
$contact = $group['contact']; $contact = $group['contact'];
$other = $group['other']; $other = $group['other'];
$max_agents = $group['max_agents'];
} else { } else {
ui_print_error_message(__('There was a problem loading group')); ui_print_error_message(__('There was a problem loading group'));
echo '</table>'; echo '</table>';
@ -149,12 +167,12 @@ if ($id_group) {
$table->data[2][1] .= html_print_select_groups( $table->data[2][1] .= html_print_select_groups(
false, false,
'AR', 'AR',
true, false,
'id_parent', 'id_parent',
$id_parent, $id_parent,
'', '',
'', __('None'),
'', -1,
true, true,
false, false,
true, true,
@ -174,7 +192,9 @@ if ($id_group) {
'name' => 'id_parent', 'name' => 'id_parent',
'selected' => $id_parent, 'selected' => $id_parent,
'return' => true, 'return' => true,
'returnAllGroup' => true, 'returnAllGroup' => false,
'nothing' => __('None'),
'nothing_value' => -1,
] ]
); );
$table->data[2][1] .= '</div>'; $table->data[2][1] .= '</div>';
@ -182,7 +202,7 @@ if ($id_group) {
if ($acl_parent) { if ($acl_parent) {
$table->data[2][1] .= ' <span id="parent_preview">'; $table->data[2][1] .= ' <span id="parent_preview">';
$table->data[2][1] .= html_print_image('images/groups_small/'.groups_get_icon($id_parent).'.png', true); $table->data[2][1] .= html_print_image('images/groups_small/'.( $id_parent != 0 ? groups_get_icon($id_parent) : 'without_group').'.png', true);
$table->data[2][1] .= '</span>'; $table->data[2][1] .= '</span>';
} }
@ -217,11 +237,14 @@ $table->data[$i][0] = __('Other').ui_print_help_tip(__('Information accessible t
$table->data[$i][1] = html_print_textarea('other', 4, 40, $other, "class='min-height-0px'", true); $table->data[$i][1] = html_print_textarea('other', 4, 40, $other, "class='min-height-0px'", true);
$i++; $i++;
$isFunctionSkins = enterprise_include_once('include/functions_skins.php'); // $isFunctionSkins = enterprise_include_once('include/functions_skins.php');
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK && !defined('METACONSOLE')) { // if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK && !defined('METACONSOLE')) {
$table->data[9][0] = __('Skin'); // $table->data[10][0] = __('Skin');
$table->data[9][1] = skins_print_select($config['id_user'], 'skin', $skin, '', __('None'), 0, true); // $table->data[10][1] = skins_print_select($config['id_user'], 'skin', $skin, '', __('None'), 0, true);
} // }
$table->data[$i][0] = __('Max agents allowed').'&nbsp;'.ui_print_help_tip(__('Set the maximum of agents allowed for this group. 0 is unlimited.'), true);
$table->data[$i][1] = html_print_input_text('max_agents', $max_agents, '', 10, 255, true);
$i++;
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$sec = 'advanced'; $sec = 'advanced';
@ -240,6 +263,7 @@ if (isset($config['metaconsole_node_id']) && $config['metaconsole_node_id'] > 0)
echo '<form name="grupo" method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/group_list&pure='.$config['pure'].'"'.$confirm_bottom.' >'; echo '<form name="grupo" method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/group_list&pure='.$config['pure'].'"'.$confirm_bottom.' >';
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_button(__('Back'), 'button_back', false, '', 'class="sub cancel"');
if ($id_group) { if ($id_group) {
html_print_input_hidden('update_group', 1); html_print_input_hidden('update_group', 1);
html_print_input_hidden('id_group', $id_group); html_print_input_hidden('id_group', $id_group);
@ -330,5 +354,8 @@ function parent_changed () {
$(document).ready (function () { $(document).ready (function () {
$('#icon').change (icon_changed); $('#icon').change (icon_changed);
$('#id_parent').change (parent_changed); $('#id_parent').change (parent_changed);
$('#button-button_back').on('click', function(){
window.location = '<?php echo ui_get_full_url('index.php?sec='.$sec.'&sec2=godmode/groups/group_list'); ?>';
});
}); });
</script> </script>

View File

@ -39,14 +39,14 @@ require_once $config['homedir'].'/include/functions_groups.php';
require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_users.php';
if (is_metaconsole()) { if (is_metaconsole() === true) {
enterprise_include_once('include/functions_metaconsole.php'); enterprise_include_once('include/functions_metaconsole.php');
enterprise_include_once('meta/include/functions_agents_meta.php'); enterprise_include_once('meta/include/functions_agents_meta.php');
enterprise_hook('open_meta_frame'); enterprise_hook('open_meta_frame');
} }
if (is_ajax()) { if (is_ajax() === true) {
if (! check_acl($config['id_user'], 0, 'AR')) { if ((bool) check_acl($config['id_user'], 0, 'AR') === false) {
db_pandora_audit('ACL Violation', 'Trying to access Group Management'); db_pandora_audit('ACL Violation', 'Trying to access Group Management');
include 'general/noaccess.php'; include 'general/noaccess.php';
return; return;
@ -56,13 +56,13 @@ if (is_ajax()) {
$get_group_agents = (bool) get_parameter('get_group_agents'); $get_group_agents = (bool) get_parameter('get_group_agents');
$get_is_disabled = (bool) get_parameter('get_is_disabled'); $get_is_disabled = (bool) get_parameter('get_is_disabled');
if ($get_group_json) { if ($get_group_json === true) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
if ($id_group == 0) { if ($id_group === 0 || $id_group === -1) {
$group = [ $group = [
'id_grupo' => 0, 'id_grupo' => 0,
'nombre' => 'All', 'nombre' => 'None',
'icon' => 'world', 'icon' => 'world',
'parent' => 0, 'parent' => 0,
'disabled' => 0, 'disabled' => 0,
@ -72,7 +72,7 @@ if (is_ajax()) {
return; return;
} }
if (! check_acl($config['id_user'], $id_group, 'AR')) { if ((bool) check_acl($config['id_user'], $id_group, 'AR') === false) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',
'Trying to access Alert Management' 'Trying to access Alert Management'
@ -87,7 +87,7 @@ if (is_ajax()) {
return; return;
} }
if ($get_group_agents) { if ($get_group_agents === true) {
ob_clean(); ob_clean();
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
$disabled = (int) get_parameter('disabled', 0); $disabled = (int) get_parameter('disabled', 0);
@ -108,10 +108,13 @@ if (is_ajax()) {
// (by default and for compatibility show void agents). // (by default and for compatibility show void agents).
$show_void_agents = (int) get_parameter('show_void_agents', 1); $show_void_agents = (int) get_parameter('show_void_agents', 1);
$serialized = (bool) get_parameter('serialized', false); $serialized = (bool) get_parameter('serialized', false);
$serialized_separator = (string) get_parameter('serialized_separator', '|'); $serialized_separator = (string) get_parameter(
'serialized_separator',
'|'
);
$force_serialized = (bool) get_parameter('force_serialized', false); $force_serialized = (bool) get_parameter('force_serialized', false);
if (! check_acl($config['id_user'], $id_group, 'AR')) { if ((bool) check_acl($config['id_user'], $id_group, 'AR') === false) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',
'Trying to access Alert Management' 'Trying to access Alert Management'
@ -120,12 +123,15 @@ if (is_ajax()) {
return; return;
} }
if (https_is_running()) { if (https_is_running() === true) {
header('Content-type: application/json'); header('Content-type: application/json');
} }
if ($filter_agents_json != '') { if ($filter_agents_json != '') {
$filter['id_agente'] = json_decode(io_safe_output($filter_agents_json), true); $filter['id_agente'] = json_decode(
io_safe_output($filter_agents_json),
true
);
} }
if ($all_agents) { if ($all_agents) {
@ -142,7 +148,6 @@ if (is_ajax()) {
$filter['status'] = $status_agents; $filter['status'] = $status_agents;
} }
// Juanma (22/05/2014) Fix: If remove void agents set.
$_sql_post = ' 1=1 '; $_sql_post = ' 1=1 ';
if ($show_void_agents == 0) { if ($show_void_agents == 0) {
$_sql_post .= ' AND id_agente IN (SELECT a.id_agente FROM tagente a, tagente_modulo b WHERE a.id_agente=b.id_agente AND b.delete_pending=0) AND \'1\''; $_sql_post .= ' AND id_agente IN (SELECT a.id_agente FROM tagente a, tagente_modulo b WHERE a.id_agente=b.id_agente AND b.delete_pending=0) AND \'1\'';
@ -172,7 +177,9 @@ if (is_ajax()) {
$agents_aux = []; $agents_aux = [];
foreach ($agents as $key => $value) { foreach ($agents as $key => $value) {
if (preg_match('/'.$search.'/', io_safe_output($value))) { if (empty($search) === true) {
$agents_aux[$key] = $value;
} else if (preg_match('/'.$search.'/', io_safe_output($value)) === true) {
$agents_aux[$key] = $value; $agents_aux[$key] = $value;
} }
} }
@ -197,7 +204,10 @@ if (is_ajax()) {
'id_tmetaconsole_setup' => $agent_info[0], 'id_tmetaconsole_setup' => $agent_info[0],
] ]
); );
} else if ($serialized && !is_metaconsole() && $force_serialized) { } else if ($serialized
&& is_metaconsole() === false
&& $force_serialized
) {
$agent_info = explode($serialized_separator, $k); $agent_info = explode($serialized_separator, $k);
$agent_disabled = db_get_value_filter( $agent_disabled = db_get_value_filter(
'disabled', 'disabled',
@ -233,10 +243,14 @@ if (is_ajax()) {
return; return;
} }
if ($get_is_disabled) { if ($get_is_disabled === true) {
$index = get_parameter('id_agent'); $index = get_parameter('id_agent');
$agent_disabled = db_get_value_filter('disabled', 'tagente', ['id_agente' => $index]); $agent_disabled = db_get_value_filter(
'disabled',
'tagente',
['id_agente' => $index]
);
$return['disabled'] = $agent_disabled; $return['disabled'] = $agent_disabled;
$return['id_agent'] = $index; $return['id_agent'] = $index;
@ -251,15 +265,9 @@ if (is_ajax()) {
$tab = (string) get_parameter('tab', 'groups'); $tab = (string) get_parameter('tab', 'groups');
if ($tab != 'credbox' && ! check_acl( if ($tab !== 'credbox'
$config['id_user'], && (bool) check_acl($config['id_user'], 0, 'PM') === false
0, && (bool) check_acl($config['id_user'], 0, 'AW') === false
'PM'
) && ! check_acl(
$config['id_user'],
0,
'AW'
)
) { ) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',
@ -267,9 +275,9 @@ if ($tab != 'credbox' && ! check_acl(
); );
include 'general/noaccess.php'; include 'general/noaccess.php';
return; return;
} else if ($tab == 'credbox' } else if ($tab === 'credbox'
&& !check_acl($config['id_user'], 0, 'UM') && (bool) check_acl($config['id_user'], 0, 'UM') === false
&& !check_acl($config['id_user'], 0, 'PM') && (bool) check_acl($config['id_user'], 0, 'PM') === false
) { ) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',
@ -339,7 +347,7 @@ switch ($tab) {
} }
// Header. // Header.
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
agents_meta_print_header(); agents_meta_print_header();
echo '<div class="notify">'; echo '<div class="notify">';
echo __('Edit or delete groups can cause problems with synchronization'); echo __('Edit or delete groups can cause problems with synchronization');
@ -368,7 +376,7 @@ $delete_group = (bool) get_parameter('delete_group');
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
// Create group. // Create group.
if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) { if (($create_group) && ((bool) check_acl($config['id_user'], 0, 'PM') === true)) {
$name = (string) get_parameter('name'); $name = (string) get_parameter('name');
$icon = (string) get_parameter('icon'); $icon = (string) get_parameter('icon');
$id_parent = (int) get_parameter('id_parent'); $id_parent = (int) get_parameter('id_parent');
@ -379,6 +387,7 @@ if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) {
$description = (string) get_parameter('description'); $description = (string) get_parameter('description');
$contact = (string) get_parameter('contact'); $contact = (string) get_parameter('contact');
$other = (string) get_parameter('other'); $other = (string) get_parameter('other');
$max_agents = (int) get_parameter('max_agents', 0);
$check = db_get_value('nombre', 'tgrupo', 'nombre', $name); $check = db_get_value('nombre', 'tgrupo', 'nombre', $name);
$propagate = (bool) get_parameter('propagate'); $propagate = (bool) get_parameter('propagate');
@ -403,6 +412,7 @@ if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) {
'propagate' => $propagate, 'propagate' => $propagate,
'other' => $other, 'other' => $other,
'password' => io_safe_input($group_pass), 'password' => io_safe_input($group_pass),
'max_agents' => $max_agents,
]; ];
$result = db_process_sql_insert('tgrupo', $values); $result = db_process_sql_insert('tgrupo', $values);
@ -436,6 +446,7 @@ if ($update_group) {
$description = (string) get_parameter('description'); $description = (string) get_parameter('description');
$contact = (string) get_parameter('contact'); $contact = (string) get_parameter('contact');
$other = (string) get_parameter('other'); $other = (string) get_parameter('other');
$max_agents = (int) get_parameter('max_agents', 0);
$aviable_name = true; $aviable_name = true;
if (preg_match('/script/i', $name)) { if (preg_match('/script/i', $name)) {
@ -460,7 +471,7 @@ if ($update_group) {
$values = [ $values = [
'nombre' => $name, 'nombre' => $name,
'icon' => empty($icon) ? '' : substr($icon, 0, -4), 'icon' => empty($icon) ? '' : substr($icon, 0, -4),
'parent' => $id_parent, 'parent' => $id_parent == -1 ? 0 : $id_parent,
'disabled' => !$alerts_enabled, 'disabled' => !$alerts_enabled,
'custom_id' => $custom_id, 'custom_id' => $custom_id,
'id_skin' => $skin, 'id_skin' => $skin,
@ -469,6 +480,7 @@ if ($update_group) {
'propagate' => $propagate, 'propagate' => $propagate,
'other' => $other, 'other' => $other,
'password' => io_safe_input($group_pass), 'password' => io_safe_input($group_pass),
'max_agents' => $max_agents,
]; ];
$result = db_process_sql_update( $result = db_process_sql_update(
@ -492,7 +504,7 @@ if ($update_group) {
} }
// Delete group. // Delete group.
if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) { if (($delete_group) && ((bool) check_acl($config['id_user'], 0, 'PM') === true)) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
$usedGroup = groups_check_used($id_group); $usedGroup = groups_check_used($id_group);
@ -508,28 +520,42 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
$success_nodes = []; $success_nodes = [];
$error_nodes = []; $error_nodes = [];
// Check if the group can be deleted or not. // Check if the group can be deleted or not.
foreach ($servers as $server) { if (isset($servers) === true
if (metaconsole_connect($server) == NOERR) { && is_array($servers) === true
$result_exist_group = db_get_row_filter('tgrupo', ['nombre' => $group_name, 'id_grupo' => $id_group]); ) {
if ($result_exist_group !== false) { foreach ($servers as $server) {
$used_group = groups_check_used($id_group); if (metaconsole_connect($server) == NOERR) {
// Save the names of the nodes that are empty and can be deleted, and those that cannot. $result_exist_group = db_get_row_filter(
if (!$used_group['return']) { 'tgrupo',
$success_nodes[] .= $server['server_name']; [
$success_counter++; 'nombre' => $group_name,
} else { 'id_grupo' => $id_group,
$error_nodes[] .= $server['server_name']; ]
$error_counter++; );
if ($result_exist_group !== false) {
$used_group = groups_check_used($id_group);
// Save the names of the nodes that are empty
// and can be deleted, and those that cannot.
if (!$used_group['return']) {
$success_nodes[] .= $server['server_name'];
$success_counter++;
} else {
$error_nodes[] .= $server['server_name'];
$error_counter++;
}
} }
} }
}
metaconsole_restore_db(); metaconsole_restore_db();
}
} }
if ($error_counter > 0) { if ($error_counter > 0) {
ui_print_error_message( ui_print_error_message(
__('The group %s could not be deleted because it is not empty in the nodes', $group_name).': '.implode(', ', $error_nodes) __(
'The group %s could not be deleted because it is not empty in the nodes',
$group_name
).': '.implode(', ', $error_nodes)
); );
$errors_meta = true; $errors_meta = true;
} else { } else {
@ -540,60 +566,80 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
$success_deleting = []; $success_deleting = [];
$error_connecting_node = []; $error_connecting_node = [];
// Delete the group in the nodes. // Delete the group in the nodes.
foreach ($servers as $server) { if (isset($servers) === true
if (metaconsole_connect($server) == NOERR) { && is_array($servers) === true
$group = db_get_row_filter( ) {
'tgrupo', foreach ($servers as $server) {
['id_grupo' => $id_group] if (metaconsole_connect($server) == NOERR) {
); $group = db_get_row_filter(
'tgrupo',
['id_grupo' => $id_group]
);
db_process_sql_update( db_process_sql_update(
'tgrupo', 'tgrupo',
['parent' => $group['parent']], ['parent' => $group['parent']],
['parent' => $id_group] ['parent' => $id_group]
); );
db_process_sql_delete( db_process_sql_delete(
'tgroup_stat', 'tgroup_stat',
['id_group' => $id_group] ['id_group' => $id_group]
); );
$result = db_process_sql_delete( $result = db_process_sql_delete(
'tgrupo', 'tgrupo',
['id_grupo' => $id_group] ['id_grupo' => $id_group]
); );
if ($result === false) { if ($result === false) {
$error_deleting[] .= $server['server_name']; $error_deleting[] .= $server['server_name'];
$error_deleting_counter++; $error_deleting_counter++;
} else {
$success_deleting[] .= $server['server_name'];
$success_deleting_counter++;
}
} else { } else {
$success_deleting[] .= $server['server_name']; $error_deleting_counter++;
$success_deleting_counter++; $error_connecting_node[] .= $server['server_name'];
} }
} else {
$error_deleting_counter++;
$error_connecting_node[] .= $server['server_name'];
}
metaconsole_restore_db(); metaconsole_restore_db();
}
} }
// If the group could not be deleted in any node, do not delete it in meta. // If the group could not be deleted in any node,
// do not delete it in meta.
if ($error_deleting_counter > 0) { if ($error_deleting_counter > 0) {
$errors_meta = true; $errors_meta = true;
if (!empty($error_connecting_node)) { if (empty($error_connecting_node) === false) {
ui_print_error_message(__('Error connecting to %s', implode(', ', $error_connecting_node).'. The group has not been deleted in the metaconsole.')); ui_print_error_message(
__(
'Error connecting to %s',
implode(
', ',
$error_connecting_node
).'. The group has not been deleted in the metaconsole.'
)
);
} }
if (!empty($error_deleting)) { if (empty($error_deleting) === false) {
ui_print_error_message( ui_print_error_message(
__('The group has not been deleted in the metaconsole due to an error in the node database').': '.implode(', ', $error_deleting) __(
'The group has not been deleted in the metaconsole due to an error in the node database'
).': '.implode(', ', $error_deleting)
); );
} }
} }
if ($success_deleting_counter > 0) { if ($success_deleting_counter > 0) {
ui_print_success_message(__('The group %s has been deleted in the nodes', $group_name).': '.implode(', ', $success_deleting)); ui_print_success_message(
__(
'The group %s has been deleted in the nodes',
$group_name
).': '.implode(', ', $success_deleting)
);
} }
} }
} }
@ -624,12 +670,17 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
if ($result && (!$usedGroup['return'])) { if ($result && (!$usedGroup['return'])) {
ui_print_success_message(__('Group successfully deleted')); ui_print_success_message(__('Group successfully deleted'));
} else { } else {
ui_print_error_message(__('There was a problem deleting group')); ui_print_error_message(
__('There was a problem deleting group')
);
} }
} }
} else { } else {
ui_print_error_message( ui_print_error_message(
sprintf(__('The group is not empty. It is use in %s.'), implode(', ', $usedGroup['tables'])) sprintf(
__('The group is not empty. It is use in %s.'),
implode(', ', $usedGroup['tables'])
)
); );
} }
} }
@ -662,14 +713,14 @@ if ($tab == 'tree') {
$search = (string) get_parameter('search', ''); $search = (string) get_parameter('search', '');
$block_size = $config['block_size']; $block_size = $config['block_size'];
if (!empty($search)) { if (empty($search) === false) {
$search_name = 'AND t.nombre LIKE "%'.$search.'%"'; $search_name = 'AND t.nombre LIKE "%'.$search.'%"';
} }
if (!users_can_manage_group_all('AR')) { if (users_can_manage_group_all('AR') === false) {
$user_groups_acl = users_get_groups(false, 'AR'); $user_groups_acl = users_get_groups(false, 'AR');
$groups_acl = implode(',', $user_groups_ACL); $groups_acl = implode('","', $user_groups_acl);
if (empty($groups_acl)) { if (empty($groups_acl) === true) {
return ui_print_info_message( return ui_print_info_message(
[ [
'no_close' => true, 'no_close' => true,
@ -678,13 +729,20 @@ if ($tab == 'tree') {
); );
} }
$acl = 'AND t.id_grupo IN ('.$groups_acl.')'; $acl = 'AND t.nombre IN ("'.$groups_acl.'")';
} }
$form = "<form method='post' action=''>"; $form = "<form method='post' action=''>";
$form .= "<table class='databox filters bolder' width='100%'>"; $form .= "<table class='databox filters bolder' width='100%'>";
$form .= '<tr><td>'.__('Search').'&nbsp;'; $form .= '<tr><td>'.__('Search').'&nbsp;';
$form .= html_print_input_text('search', $search, '', 100, 100, true); $form .= html_print_input_text(
'search',
$search,
'',
100,
100,
true
);
$form .= '</td><td>'; $form .= '</td><td>';
$form .= "<input name='find' type='submit' class='sub search' value='".__('Search')."'>"; $form .= "<input name='find' type='submit' class='sub search' value='".__('Search')."'>";
$form .= '<td></tr>'; $form .= '<td></tr>';
@ -713,7 +771,7 @@ if ($tab == 'tree') {
$groups = db_get_all_rows_sql($groups_sql); $groups = db_get_all_rows_sql($groups_sql);
if (!empty($groups)) { if (empty($groups) === false) {
// Count all groups for pagination only saw user and filters. // Count all groups for pagination only saw user and filters.
$groups_sql_count = sprintf( $groups_sql_count = sprintf(
'SELECT count(*) 'SELECT count(*)
@ -799,7 +857,7 @@ if ($tab == 'tree') {
] ]
).'</a>'; ).'</a>';
if (is_metaconsole()) { if (is_metaconsole() === true) {
$confirm_message = __('Are you sure? This group will also be deleted in all the nodes.'); $confirm_message = __('Are you sure? This group will also be deleted in all the nodes.');
} else { } else {
$confirm_message = __('Are you sure?'); $confirm_message = __('Are you sure?');
@ -841,11 +899,16 @@ if ($tab == 'tree') {
'pagination-bottom' 'pagination-bottom'
); );
} else { } else {
ui_print_info_message(['no_close' => true, 'message' => __('There are no defined groups') ]); ui_print_info_message(
[
'no_close' => true,
'message' => __('There are no defined groups'),
]
);
} }
} }
if (check_acl($config['id_user'], 0, 'PM')) { if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/configure_group">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/configure_group">';
echo '<div class="action-buttons w100p">'; echo '<div class="action-buttons w100p">';
html_print_submit_button(__('Create group'), 'crt', false, 'class="sub next"'); html_print_submit_button(__('Create group'), 'crt', false, 'class="sub next"');
@ -860,7 +923,7 @@ $tab = 'group_edition';
?> ?>
<?php if (!is_metaconsole()) { ?> <?php if (is_metaconsole() === false) { ?>
<script type="text/javascript" src="include/javascript/fixed-bottom-box.js"></script> <script type="text/javascript" src="include/javascript/fixed-bottom-box.js"></script>
<?php } else { ?> <?php } else { ?>
<script type="text/javascript" src="../../include/javascript/fixed-bottom-box.js"></script> <script type="text/javascript" src="../../include/javascript/fixed-bottom-box.js"></script>
@ -900,7 +963,6 @@ $tab = 'group_edition';
treeController.init({ treeController.init({
recipient: $("div#tree-controller-recipient"), recipient: $("div#tree-controller-recipient"),
//detailRecipient: $.fixedBottomBox({ width: 400, height: window.innerHeight * 0.9 }),
page: parameters['page'], page: parameters['page'],
emptyMessage: "<?php echo __('No data found'); ?>", emptyMessage: "<?php echo __('No data found'); ?>",
foundMessage: "<?php echo __('Found groups'); ?>", foundMessage: "<?php echo __('Found groups'); ?>",

View File

@ -506,7 +506,7 @@ $id_os = 0;
$server_name = 0; $server_name = 0;
$description = ''; $description = '';
echo '<div id="form_agents" class="invisible">'; echo '<div id="form_agents" style="display:none">';
$table = new StdClass(); $table = new StdClass();
$table->width = '100%'; $table->width = '100%';
@ -819,24 +819,17 @@ foreach ($fields as $field) {
} }
if ($field['combo_values'] !== '') { if ($field['combo_values'] !== '') {
$data[1] = html_print_select( $data[1] = html_print_input(
$combo_values, [
'customvalue_'.$field['id_field'], 'type' => 'select_search',
$custom_value, 'fields' => $combo_values,
'', 'name' => 'customvalue_'.$field['id_field'],
__('No change'), 'selected' => $custom_value,
'', 'nothing' => __('No change'),
true, 'nothing_value' => '',
false, 'return' => true,
false, 'sort' => false,
'', ]
false,
false,
false,
false,
false,
'',
false
); );
}; };

View File

@ -46,7 +46,7 @@ if (defined('METACONSOLE')) {
$sec = 'gmodules'; $sec = 'gmodules';
} }
if (is_management_allowed() === true) { if (is_management_allowed() === true || is_metaconsole()) {
$create = (bool) get_parameter('create'); $create = (bool) get_parameter('create');
$update = (bool) get_parameter('update'); $update = (bool) get_parameter('update');
$delete = (bool) get_parameter('delete'); $delete = (bool) get_parameter('delete');
@ -125,7 +125,7 @@ if ($delete) {
['id_sg' => $id] ['id_sg' => $id]
); );
if (($result !== false) and ($result1 !== false)) { if (($result !== false) && ($result1 !== false)) {
$result = true; $result = true;
} else { } else {
$result = false; $result = false;
@ -187,7 +187,7 @@ if ($multiple_delete) {
); );
} }
if (($id || $new) && !$delete && !$multiple_delete && is_management_allowed() === true) { if (($id || $new) && !$delete && !$multiple_delete && (is_management_allowed() === true || is_metaconsole())) {
include_once 'manage_nc_groups_form.php'; include_once 'manage_nc_groups_form.php';
return; return;
} }
@ -230,7 +230,7 @@ $table->class = 'info_table';
$table->head = []; $table->head = [];
$table->head['checkbox'] = html_print_checkbox('all_delete', 0, false, true, false); $table->head['checkbox'] = html_print_checkbox('all_delete', 0, false, true, false);
$table->head[0] = __('Name'); $table->head[0] = __('Name');
if (is_management_allowed() === true) { if (is_management_allowed() === true || is_metaconsole()) {
$table->head[1] = __('Action'); $table->head[1] = __('Action');
} }
@ -262,15 +262,15 @@ foreach ($groups as $group) {
} }
$table->cellclass[][1] = 'action_buttons'; $table->cellclass[][1] = 'action_buttons';
if (is_management_allowed() === true) { if (is_management_allowed() === true || is_metaconsole()) {
$data[1] = "<a onclick='if(confirm(\"".__('Are you sure?')."\")) return true; else return false;' $data[1] = "<a onclick='if(confirm(\"".__('Are you sure?')."\")) return true; else return false;'
href='index.php?sec=".$sec.'&sec2=godmode/modules/manage_nc_groups&delete=1&id='.$group['id_sg']."&offset=0'>".html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']).'</a>'; href='index.php?sec=".$sec.'&sec2=godmode/modules/manage_nc_groups&delete=1&id='.$group['id_sg']."&offset=0'>".html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>';
} }
array_push($table->data, $data); array_push($table->data, $data);
} }
if (is_management_allowed() === false) { if (is_management_allowed() === false && !is_metaconsole()) {
ui_print_warning_message(__('This node is configured with centralized mode. This page is for read only. Go to metaconsole to manage the component groups.')); ui_print_warning_message(__('This node is configured with centralized mode. This page is for read only. Go to metaconsole to manage the component groups.'));
} }
@ -278,7 +278,7 @@ if (isset($data)) {
echo "<form method='post' action='index.php?sec=".$sec."&sec2=godmode/modules/manage_nc_groups'>"; echo "<form method='post' action='index.php?sec=".$sec."&sec2=godmode/modules/manage_nc_groups'>";
html_print_input_hidden('multiple_delete', 1); html_print_input_hidden('multiple_delete', 1);
html_print_table($table); html_print_table($table);
if (is_management_allowed() === true) { if (is_management_allowed() === true || is_metaconsole()) {
echo "<div class='pdd_l_10px float-right mrgn_btn_15px'>"; echo "<div class='pdd_l_10px float-right mrgn_btn_15px'>";
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
echo '</div>'; echo '</div>';
@ -289,7 +289,7 @@ if (isset($data)) {
ui_print_info_message(['no_close' => true, 'message' => __('There are no defined component groups') ]); ui_print_info_message(['no_close' => true, 'message' => __('There are no defined component groups') ]);
} }
if (is_management_allowed() === true) { if (is_management_allowed() === true || is_metaconsole()) {
echo '<form method="post" action='.$url.'>'; echo '<form method="post" action='.$url.'>';
echo '<div class="float-right">'; echo '<div class="float-right">';
html_print_input_hidden('new', 1); html_print_input_hidden('new', 1);

View File

@ -568,71 +568,19 @@ if ($id || $new_component
return; return;
} }
$url = ui_get_url_refresh(
[
'offset' => false,
'id' => false,
'create_component' => false,
'update_component' => false,
'delete_component' => false,
'id_network_component' => false,
'upd' => false,
'crt' => false,
'type' => false,
'name' => false,
'description' => false,
'max' => false,
'min' => false,
'tcp_send' => false,
'tcp_rcv' => false,
'tcp_port' => false,
'snmp_oid' => false,
'snmp_community' => false,
'id_module_group' => false,
'module_interval' => false,
'id_group' => false,
'plugin_user' => false,
'plugin_pass' => false,
'plugin_parameter' => false,
'macros' => false,
'max_timeout' => false,
'max_retries' => false,
'id_modulo' => false,
'id_plugin' => false,
'history_data' => false,
'dynamic_interval' => false,
'dynamic_max' => false,
'dynamic_min' => false,
'dynamic_two_tailed' => false,
'min_warning' => false,
'max_warning' => false,
'str_warning' => false,
'min_critical' => false,
'max_critical' => false,
'str_critical' => false,
'ff_event' => false,
'id_component_type' => false,
'critical_instructions' => false,
'warning_instructions' => false,
'unknown_instructions' => false,
'critical_inverse' => false,
'warning_inverse' => false,
'id_category' => false,
'tags' => false,
'ff_event_normal' => false,
'ff_event_warning' => false,
'ff_event_critical' => false,
'each_ff' => false,
'ff_type' => false,
]
);
$search_id_group = (int) get_parameter('search_id_group'); $search_id_group = (int) get_parameter('search_id_group');
$search_string = (string) get_parameter('search_string'); $search_string = (string) get_parameter('search_string');
if (!empty($search_string)) {
$search_string = trim($search_string, '&#x20;'); $url = ui_get_url_refresh(
} [
'offset' => false,
'search_string' => $search_string,
'search_id_group' => $search_id_group,
],
true,
false
);
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';

View File

@ -357,7 +357,7 @@ if (defined('METACONSOLE')) {
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_button(__('Go back'), 'go_back', false, 'history.go(-1);', 'class="sub cancel"'); html_print_button(__('Go back'), 'go_back', false, '', 'class="sub cancel"');
html_print_input_hidden('id_component_type', $id_component_type); html_print_input_hidden('id_component_type', $id_component_type);
if ($id) { if ($id) {
html_print_input_hidden('update_component', 1); html_print_input_hidden('update_component', 1);
@ -376,6 +376,11 @@ ui_require_javascript_file('pandora_modules');
?> ?>
<script language="JavaScript" type="text/javascript"> <script language="JavaScript" type="text/javascript">
<!-- <!--
$('#button-go_back').click(function () {
window.location.href = "<?php echo ui_get_full_url('index.php?sec=templates&sec2=godmode/modules/manage_network_components'); ?>";
});
function type_change () { function type_change () {
// type 1-4 - Generic_xxxxxx // type 1-4 - Generic_xxxxxx
if ((document.component.type.value > 0) && (document.component.type.value < 5)) { if ((document.component.type.value > 0) && (document.component.type.value < 5)) {

View File

@ -194,22 +194,22 @@ if ($delete_layout || $copy_layout) {
} }
if ($copy_layout) { if ($copy_layout) {
// Number of inserts // Number of inserts.
$ninsert = (int) 0; $ninsert = (int) 0;
// Return from DB the source layout // Return from DB the source layout.
$layout_src = db_get_all_rows_filter( $layout_src = db_get_all_rows_filter(
'tlayout', 'tlayout',
['id' => $id_layout] ['id' => $id_layout]
); );
// Name of dst // Name of dst.
$name_dst = get_parameter( $name_dst = get_parameter(
'name_dst', 'name_dst',
$layout_src[0]['name'].' copy' $layout_src[0]['name'].' copy'
); );
// Create the new Console // Create the new Console.
$idGroup = $layout_src[0]['id_group']; $idGroup = $layout_src[0]['id_group'];
$background = $layout_src[0]['background']; $background = $layout_src[0]['background'];
$height = $layout_src[0]['height']; $height = $layout_src[0]['height'];
@ -217,12 +217,15 @@ if ($delete_layout || $copy_layout) {
$visualConsoleName = $name_dst; $visualConsoleName = $name_dst;
$values = [ $values = [
'name' => $visualConsoleName, 'name' => $visualConsoleName,
'id_group' => $idGroup, 'id_group' => $idGroup,
'background' => $background, 'background' => $background,
'height' => $height, 'height' => $height,
'width' => $width, 'width' => $width,
'background_color' => $layout_src[0]['background_color'],
'is_favourite' => $layout_src[0]['is_favourite'],
]; ];
$result = db_process_sql_insert('tlayout', $values); $result = db_process_sql_insert('tlayout', $values);
$idNewVisualConsole = $result; $idNewVisualConsole = $result;
@ -517,7 +520,7 @@ if ($maps) {
if (!is_metaconsole()) { if (!is_metaconsole()) {
echo '<div class="action-buttons w100p right_align">'; echo '<div class="action-buttons w100p right_align">';
} else { } else {
echo '<div class="w100p right right_align">'; echo '<div class="w100p right right_align mrgn_btn_20px">';
} }
} }

View File

@ -3739,6 +3739,7 @@ function print_General_list($width, $action, $idItem=null, $type='general')
$params['use_input_id_server'] = true; $params['use_input_id_server'] = true;
$params['input_id_server_id'] = 'hidden-id_server'; $params['input_id_server_id'] = 'hidden-id_server';
$params['disabled_javascript_on_blur_function'] = true; $params['disabled_javascript_on_blur_function'] = true;
$params['javascript_is_function_select'] = true;
} }
ui_print_agent_autocomplete_input($params); ui_print_agent_autocomplete_input($params);

View File

@ -742,7 +742,7 @@ switch ($action) {
} }
$own_info = get_user_info($config['id_user']); $own_info = get_user_info($config['id_user']);
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'RM')) { if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'RM') || check_acl($config['id_user'], 0, 'RR')) {
$return_all_group = true; $return_all_group = true;
} else { } else {
$return_all_group = false; $return_all_group = false;

View File

@ -85,7 +85,7 @@ visual_map_editor_print_item_palette($visualConsole['id'], $background);
if (!defined('METACONSOLE')) { if (!defined('METACONSOLE')) {
echo '<div id="frame_view" class="frame_view_meta">'; echo '<div id="frame_view" class="frame_view_meta">';
} else { } else {
echo '<div id="frame_view" class="frame_view_node">'; echo '<div id="frame_view" class="frame_view_node mrgn_top_meta_35px">';
} }
echo '<div id="background" class="" style="top:0px; echo '<div id="background" class="" style="top:0px;

View File

@ -795,7 +795,7 @@ if ($config['legacy_vc']) {
$buttons['view'] = [ $buttons['view'] = [
'active' => false, 'active' => false,
'text' => '<a href="'.$url_view.'">'.html_print_image('images/operation.png', true, ['title' => __('View'), 'class' => 'invert_filter']).'</a>', 'text' => '<a href="'.$url_view.'">'.html_print_image('images/eye.png', true, ['title' => __('View'), 'class' => 'invert_filter']).'</a>',
]; ];
if ($idVisualConsole === false) { if ($idVisualConsole === false) {

View File

@ -278,26 +278,26 @@ if ($mapConnectionData != null) {
} }
} }
// Open Street Map Connection. // Open Street Map Connection.
$optionsConnectionOSMTable = '<table class="databox" border="0" cellpadding="4" cellspacing="4" width="50%">'.'<tr class="row_0">'.'<td>'.htmlentities( $optionsConnectionOSMTable = '<table class="databox" border="0" cellpadding="4" cellspacing="4" width="50%"><tr class="row_0"><td>'.htmlentities(
__('Tile Server URL'), __('Tile Server URL'),
ENT_QUOTES, ENT_QUOTES,
'UTF-8' 'UTF-8'
).':</td>'.'<td><input id="type" type="hidden" name="type" value="OSM" />'.html_print_input_text( ).':</td><td><input id="type" type="hidden" name="type" value="OSM" />'.html_print_input_text(
'url', 'url',
$mapConnectionDataUrl, $mapConnectionDataUrl,
'', '',
45, 45,
90, 90,
true true
).'</td>'.'</tr>'.'</table>'; ).'</td></tr></table>';
// Google Maps Connection. // Google Maps Connection.
$gmaps_types['G_PHYSICAL_MAP'] = __('Google Physical'); $gmaps_types['G_PHYSICAL_MAP'] = __('Google Physical');
$gmaps_types['G_HYBRID_MAP'] = __('Google Hybrid'); $gmaps_types['G_HYBRID_MAP'] = __('Google Hybrid');
$gmaps_types['G_SATELITE_MAP'] = __('Google Satelite'); $gmaps_types['G_SATELITE_MAP'] = __('Google Satelite');
// TODO: Use label tags for the forms. // TODO: Use label tags for the forms.
$optionsConnectionGmapTable = '<table class="databox" border="0" cellpadding="4" cellspacing="4" width="90%">'.'<tr class="row_0">'.'<td>'.__('Google Map Type').':</td>'.'<td><input id="type" type="hidden" name="type" value="Gmap" />'.trim( $optionsConnectionGmapTable = '<table class="databox" border="0" cellpadding="4" cellspacing="4" width="90%"><tr class="row_0"><td>'.__('Google Map Type').':</td><td><input id="type" type="hidden" name="type" value="Gmap" />'.trim(
html_print_select( html_print_select(
$gmaps_types, $gmaps_types,
'gmap_type', 'gmap_type',
@ -305,181 +305,223 @@ $optionsConnectionOSMTable = '<table class="databox" border="0" cellpadding="4"
'', '',
'', '',
0, 0,
true true,
false,
true,
'',
false,
false,
false,
false,
false,
'',
false,
false,
false,
false,
false
) )
).'</td>'.'</tr>'.'<tr class="row_2">'.'<td>'.__('Google Maps Key').':</td>'.'</tr>'.'<tr class="row_3">'.'<td colspan="2">'.html_print_input_text( ).'</td></tr><tr class="row_2"><td>'.__('Google Maps Key').':</td></tr><tr class="row_3"><td colspan="2">'.html_print_input_text(
'gmap_key', 'gmap_key',
$gmap_key, $gmap_key,
'', '',
90, 90,
128, 128,
true true
).'</td>'.'</tr>'.'</table>'; ).'</td></tr></table>';
// Image Map Connection. // Image Map Connection.
$optionsConnectionImageTable = '<table class="databox" border="0" cellpadding="4" cellspacing="4" width="50%">'.'<tr class="row_0">'.'<td>'.__('Image URL').':</td>'.'<td colspan="3"><input id="type" type="hidden" name="type" value="Static_Image" />'.html_print_input_text( $optionsConnectionImageTable = '<table class="databox" border="0" cellpadding="4" cellspacing="4" width="50%"><tr class="row_0"><td>'.__('Image URL').':</td><td colspan="3"><input id="type" type="hidden" name="type" value="Static_Image" />'.html_print_input_text(
'url', 'url',
$mapConnectionDataUrl, $mapConnectionDataUrl,
'', '',
45, 45,
90, 90,
true true
).'</td>'.'</tr>'.'<tr class="row_1">'.'<td colspan="4"><strong>'.__('Corners of the area of the image').':</strong></td>'.'</tr>'.'<tr class="row_2">'.'<td>'.__('Left').':</td>'.'<td>'.html_print_input_text( ).'</td></tr><tr class="row_1"><td colspan="4"><strong>'.__('Corners of the area of the image').':</strong></td></tr><tr class="row_2"><td>'.__('Left').':</td><td>'.html_print_input_text(
'bb_left', 'bb_left',
$bb_left, $bb_left,
'', '',
25, 25,
25, 25,
true true
).'</td>'.'<td>'.__('Bottom').':</td>'.'<td>'.html_print_input_text( ).'</td><td>'.__('Bottom').':</td><td>'.html_print_input_text(
'bb_bottom', 'bb_bottom',
$bb_bottom, $bb_bottom,
'', '',
25, 25,
25, 25,
true true
).'</td>'.'</tr>'.'<tr class="row_3">'.'<td>'.__('Right').':</td>'.'<td>'.html_print_input_text( ).'</td></tr><tr class="row_3"><td>'.__('Right').':</td><td>'.html_print_input_text(
'bb_right', 'bb_right',
$bb_right, $bb_right,
'', '',
25, 25,
25, 25,
true true
).'</td>'.'<td>'.__('Top').':</td>'.'<td>'.html_print_input_text( ).'</td><td>'.__('Top').':</td><td>'.html_print_input_text(
'bb_top', 'bb_top',
$bb_top, $bb_top,
'', '',
25, 25,
25, 25,
true true
).'</td>'.'</tr>'.'<tr class="row_4">'.'<td colspan="4"><strong>'.__('Image Size').':</strong></td>'.'</tr>'.'<tr class="row_5">'.'<td>'.__('Width').':</td>'.'<td>'.html_print_input_text('image_width', $image_width, '', 25, 25, true).'</td>'.'<td>'.__('Height').':</td>'.'<td>'.html_print_input_text('image_height', $image_height, '', 25, 25, true).'</td>'.'</tr>'.'</table>'; ).'</td></tr><tr class="row_4"><td colspan="4"><strong>'.__('Image Size').':</strong></td></tr><tr class="row_5"><td>'.__('Width').':</td><td>'.html_print_input_text(
'image_width',
$image_width,
'',
25,
25,
true
).'</td><td>'.__('Height').':</td><td>'.html_print_input_text(
'image_height',
$image_height,
'',
25,
25,
true
).'</td></tr></table>';
// WMS Server Connection. // WMS Server Connection.
$optionsConnectionWMSTable = '<table class="databox" border="0" cellpadding="4" cellspacing="4" width="50%">'.'<tr class="row_0">'.'<td>'.__('WMS Server URL').'</td>'.'<td>'.'<input id="type" type="hidden" name="type" value="WMS" />'.html_print_input_text('url', $mapConnectionDataUrl, '', 90, 255, true).'</td>'.'</tr>'.'<tr class="row_1">'.'<td>'.__('Layers').'</td>'.'<td>'.html_print_input_text('layers', $layers, '', 90, 255, true).'</td>'.'</tr>'.'</table>'; $optionsConnectionWMSTable = '<table class="databox" border="0" cellpadding="4" cellspacing="4" width="50%"><tr class="row_0"><td>'.__('WMS Server URL').'</td><td><input id="type" type="hidden" name="type" value="WMS" />'.html_print_input_text(
'url',
$mapConnectionDataUrl,
'',
90,
255,
true
).'</td></tr><tr class="row_1"><td>'.__('Layers').'</td><td>'.html_print_input_text(
'layers',
$layers,
'',
90,
255,
true
).'</td></tr></table>';
if ($mapConnectionData != null) { if ($mapConnectionData != null) {
switch ($mapConnection_type) { switch ($mapConnection_type) {
case 'OSM': case 'OSM':
$optionsConnectionTypeTable = $optionsConnectionOSMTable; $optionsConnectionTypeTable = $optionsConnectionOSMTable;
break; break;
case 'Gmap': case 'Gmap':
$optionsConnectionTypeTable = $optionsConnectionGmapTable; $optionsConnectionTypeTable = $optionsConnectionGmapTable;
break; break;
case 'Static_Image': case 'Static_Image':
$optionsConnectionTypeTable = $optionsConnectionImageTable; $optionsConnectionTypeTable = $optionsConnectionImageTable;
break; break;
case 'WMS': case 'WMS':
$optionsConnectionTypeTable = $optionsConnectionWMSTable; $optionsConnectionTypeTable = $optionsConnectionWMSTable;
break; break;
default: default:
// Default. // Default.
break; break;
}
} }
}
echo "<div id='form_map_connection_type'>".$optionsConnectionTypeTable.'</div>'; echo "<div id='form_map_connection_type'>".$optionsConnectionTypeTable.'</div>';
echo '<h4>'.__('Preview to select the center of the map and the default position of an agent without gis data').'</h4><br>'; echo '<h4>'.__('Preview to select the center of the map and the default position of an agent without gis data').'</h4><br>';
html_print_button(__('Load preview map'), 'button_refresh', false, 'refreshMapView();', 'class="sub"'); html_print_button(__('Load preview map'), 'button_refresh', false, 'refreshMapView();', 'class="sub next"');
echo '<br /><br />'; echo '<br /><br />';
echo "<div id='map' class='map_gis_step2'></div>"; echo "<div id='map' class='map_gis_step2'></div>";
$table->width = '60%'; $table->width = '60%';
$table->data = []; $table->data = [];
// $table->colspan[0][3] = 3; // $table->colspan[0][3] = 3;
$table->data[0][0] = ''; $table->data[0][0] = '';
$table->data[0][1] = __('Map Center'); $table->data[0][1] = __('Map Center');
$table->data[0][2] = __('Default position for agents without GIS data'); $table->data[0][2] = __('Default position for agents without GIS data');
$table->data[1][0] = __('Change in the map'); $table->data[1][0] = __('Change in the map');
$table->data[1][1] = html_print_radio_button_extended( $table->data[1][1] = html_print_radio_button_extended(
'radio_button', 'radio_button',
1, 1,
'', '',
1, 1,
false, false,
'changeSetManualPosition(true, false)', 'changeSetManualPosition(true, false)',
'', '',
true true
); );
$table->data[1][2] = html_print_radio_button_extended( $table->data[1][2] = html_print_radio_button_extended(
'radio_button', 'radio_button',
2, 2,
'', '',
0, 0,
false, false,
'changeSetManualPosition(false, true)', 'changeSetManualPosition(false, true)',
'', '',
true true
); );
$table->data[2][0] = __('Latitude'); $table->data[2][0] = __('Latitude');
$table->data[2][1] = html_print_input_text( $table->data[2][1] = html_print_input_text(
'center_latitude', 'center_latitude',
$mapConnection_centerLatitude, $mapConnection_centerLatitude,
'', '',
10, 10,
10, 10,
true true
); );
$table->data[2][2] = html_print_input_text( $table->data[2][2] = html_print_input_text(
'default_latitude', 'default_latitude',
$mapConnection_defaultLatitude, $mapConnection_defaultLatitude,
'', '',
10, 10,
10, 10,
true true
); );
$table->data[3][0] = __('Longitude'); $table->data[3][0] = __('Longitude');
$table->data[3][1] = html_print_input_text( $table->data[3][1] = html_print_input_text(
'center_longitude', 'center_longitude',
$mapConnection_centerLongitude, $mapConnection_centerLongitude,
'', '',
10, 10,
10, 10,
true true
); );
$table->data[3][2] = html_print_input_text( $table->data[3][2] = html_print_input_text(
'default_longitude', 'default_longitude',
$mapConnection_defaultLongitude, $mapConnection_defaultLongitude,
'', '',
10, 10,
10, 10,
true true
); );
$table->data[4][0] = __('Altitude'); $table->data[4][0] = __('Altitude');
$table->data[4][1] = html_print_input_text( $table->data[4][1] = html_print_input_text(
'center_altitude', 'center_altitude',
$mapConnection_centerAltitude, $mapConnection_centerAltitude,
'', '',
10, 10,
10, 10,
true true
); );
$table->data[4][2] = html_print_input_text( $table->data[4][2] = html_print_input_text(
'default_altitude', 'default_altitude',
$mapConnection_defaultAltitude, $mapConnection_defaultAltitude,
'', '',
10, 10,
10, 10,
true true
); );
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons w90p left">'; echo '<div class="action-buttons w90p float-left">';
html_print_submit_button(__('Save'), '', false, 'class="sub save wand"'); html_print_submit_button(__('Save'), '', false, 'class="sub save wand"');
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
ui_require_javascript_file('OpenLayers/OpenLayers'); ui_require_javascript_file('OpenLayers/OpenLayers');
ui_require_javascript_file('openlayers.pandora'); ui_require_javascript_file('openlayers.pandora');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
var setCenter = true; var setCenter = true;
var centerPoint = null; var centerPoint = null;
@ -649,7 +691,6 @@ function selMapConnectionType() {
$('#form_map_connection_type').html('<?php echo $optionsConnectionOSMTable; ?>').hide(); $('#form_map_connection_type').html('<?php echo $optionsConnectionOSMTable; ?>').hide();
break; break;
case 'Gmap': case 'Gmap':
// TODO: Validate there is a key, and use it
$('#form_map_connection_type').html('<?php echo $optionsConnectionGmapTable; ?>').hide(); $('#form_map_connection_type').html('<?php echo $optionsConnectionGmapTable; ?>').hide();
break; break;
case 'Static_Image': case 'Static_Image':

View File

@ -44,6 +44,9 @@ if (! check_acl($config['id_user'], 0, 'PM')
return; return;
} }
// Load needed resources.
ui_require_css_file('setup.multicolumn');
$update_config = get_parameter('update_config', 0); $update_config = get_parameter('update_config', 0);
if ($update_config == 1 && $config['history_db_enabled'] == 1) { if ($update_config == 1 && $config['history_db_enabled'] == 1) {
if (! isset($config['history_db_connection']) if (! isset($config['history_db_connection'])
@ -649,7 +652,7 @@ $table_other->data[16][1] = html_print_input_text(
echo '<form id="form_setup" method="post">'; echo '<form id="form_setup" method="post">';
echo '<fieldset>'; echo '<fieldset class="full-column">';
echo '<legend>'.__('Database maintenance status').' '.ui_print_help_icon('database_maintenance_status_tab', true).'</legend>'; echo '<legend>'.__('Database maintenance status').' '.ui_print_help_icon('database_maintenance_status_tab', true).'</legend>';
html_print_table($table_status); html_print_table($table_status);
echo '</fieldset>'; echo '</fieldset>';

View File

@ -834,7 +834,7 @@ echo '</form>';
// AJAX call to check API connection. // AJAX call to check API connection.
$.ajax({ $.ajax({
type: "GET", type: "POST",
url: url, url: url,
dataType: "json", dataType: "json",
data: data data: data

File diff suppressed because it is too large Load Diff

View File

@ -66,6 +66,7 @@ if (is_ajax()) {
function ($counter, $server) use ($id_tag) { function ($counter, $server) use ($id_tag) {
if (metaconsole_connect($server) === NOERR) { if (metaconsole_connect($server) === NOERR) {
$counter += tags_get_local_modules_count($id_tag); $counter += tags_get_local_modules_count($id_tag);
metaconsole_restore_db();
} }
return $counter; return $counter;
@ -83,6 +84,7 @@ if (is_ajax()) {
function ($counter, $server) use ($id_tag) { function ($counter, $server) use ($id_tag) {
if (metaconsole_connect($server) === NOERR) { if (metaconsole_connect($server) === NOERR) {
$counter += tags_get_policy_modules_count($id_tag); $counter += tags_get_policy_modules_count($id_tag);
metaconsole_restore_db();
} }
return $counter; return $counter;
@ -272,6 +274,7 @@ if (!empty($result)) {
function ($counter, $server) use ($tag_id) { function ($counter, $server) use ($tag_id) {
if (metaconsole_connect($server) === NOERR) { if (metaconsole_connect($server) === NOERR) {
$counter += tags_get_modules_count($tag_id); $counter += tags_get_modules_count($tag_id);
metaconsole_restore_db();
} }
return $counter; return $counter;

View File

@ -1111,7 +1111,9 @@ if ($dashboards === false) {
} }
} }
$home_screen .= '<div id="show_db" style="display: none; width: 100%;">';
$home_screen .= html_print_select($dashboards_aux, 'dashboard', $user_info['data_section'], '', '', '', true); $home_screen .= html_print_select($dashboards_aux, 'dashboard', $user_info['data_section'], '', '', '', true);
$home_screen .= '</div>';
$layouts = visual_map_get_user_layouts($config['id_user'], true); $layouts = visual_map_get_user_layouts($config['id_user'], true);
@ -1124,6 +1126,7 @@ if ($layouts === false) {
} }
} }
$home_screen .= '<div id="show_vc" style="display: none; width: 100%;">';
$home_screen .= html_print_select( $home_screen .= html_print_select(
$layouts_aux, $layouts_aux,
'visual_console', 'visual_console',
@ -1133,6 +1136,8 @@ $home_screen .= html_print_select(
'', '',
true true
); );
$home_screen .= '</div>';
$home_screen .= html_print_input_text( $home_screen .= html_print_input_text(
'data_section', 'data_section',
$user_info['data_section'], $user_info['data_section'],
@ -1664,46 +1669,64 @@ function show_data_section () {
$("#text-data_section").css("display", "none"); $("#text-data_section").css("display", "none");
$("#dashboard").css("display", ""); $("#dashboard").css("display", "");
$("#visual_console").css("display", "none"); $("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "inline-grid");
break; break;
case <?php echo "'".'Visual console'."'"; ?>: case <?php echo "'".'Visual console'."'"; ?>:
$("#text-data_section").css("display", "none"); $("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none"); $("#dashboard").css("display", "none");
$("#visual_console").css("display", ""); $("#visual_console").css("display", "");
$("#show_vc").css("display", "inline-grid");
$("#show_db").css("display", "none");
break; break;
case <?php echo "'".'Event list'."'"; ?>: case <?php echo "'".'Event list'."'"; ?>:
$("#text-data_section").css("display", "none"); $("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none"); $("#dashboard").css("display", "none");
$("#visual_console").css("display", "none"); $("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break; break;
case <?php echo "'".'Group view'."'"; ?>: case <?php echo "'".'Group view'."'"; ?>:
$("#text-data_section").css("display", "none"); $("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none"); $("#dashboard").css("display", "none");
$("#visual_console").css("display", "none"); $("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break; break;
case <?php echo "'".'Tactical view'."'"; ?>: case <?php echo "'".'Tactical view'."'"; ?>:
$("#text-data_section").css("display", "none"); $("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none"); $("#dashboard").css("display", "none");
$("#visual_console").css("display", "none"); $("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break; break;
case <?php echo "'".'Alert detail'."'"; ?>: case <?php echo "'".'Alert detail'."'"; ?>:
$("#text-data_section").css("display", "none"); $("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none"); $("#dashboard").css("display", "none");
$("#visual_console").css("display", "none"); $("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break; break;
case <?php echo "'".'External link'."'"; ?>: case <?php echo "'".'External link'."'"; ?>:
$("#text-data_section").css("display", ""); $("#text-data_section").css("display", "");
$("#dashboard").css("display", "none"); $("#dashboard").css("display", "none");
$("#visual_console").css("display", "none"); $("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break; break;
case <?php echo "'".'Other'."'"; ?>: case <?php echo "'".'Other'."'"; ?>:
$("#text-data_section").css("display", ""); $("#text-data_section").css("display", "");
$("#dashboard").css("display", "none"); $("#dashboard").css("display", "none");
$("#visual_console").css("display", "none"); $("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break; break;
case <?php echo "'".'Default'."'"; ?>: case <?php echo "'".'Default'."'"; ?>:
$("#text-data_section").css("display", "none"); $("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none"); $("#dashboard").css("display", "none");
$("#visual_console").css("display", "none"); $("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break; break;
} }
} }

View File

@ -260,21 +260,21 @@ if (isset($_GET['user_del'])) {
if (defined('METACONSOLE') && isset($_GET['delete_all'])) { if (defined('METACONSOLE') && isset($_GET['delete_all'])) {
$servers = metaconsole_get_servers(); $servers = metaconsole_get_servers();
foreach ($servers as $server) { foreach ($servers as $server) {
// Connect to the remote console // Connect to the remote console.
metaconsole_connect($server); if (metaconsole_connect($server) === NOERR) {
// Delete the user
$result = delete_user($id_user);
if ($result) {
db_pandora_audit(
'User management',
__('Deleted user %s from metaconsole', io_safe_input($id_user))
);
}
// Delete the user // Restore the db connection.
$result = delete_user($id_user); metaconsole_restore_db();
if ($result) {
db_pandora_audit(
'User management',
__('Deleted user %s from metaconsole', io_safe_input($id_user))
);
} }
// Restore the db connection
metaconsole_restore_db();
// Log to the metaconsole too // Log to the metaconsole too
if ($result) { if ($result) {
db_pandora_audit( db_pandora_audit(
@ -440,17 +440,21 @@ if (!defined('METACONSOLE')) {
$table->valign[6] = 'top'; $table->valign[6] = 'top';
} }
$group_um = users_get_groups_UM($config['id_user']);
$info1 = []; $info1 = [];
$user_is_admin = users_is_admin(); $user_is_admin = users_is_admin();
// Is admin or has group permissions all.
if ($user_is_admin || isset($group_um[0])) { if ($user_is_admin) {
$info1 = get_users($order); $info1 = get_users($order);
} else { } else {
foreach ($group_um as $group => $value) { $group_um = users_get_groups_UM($config['id_user']);
$info1 = array_merge($info1, users_get_users_by_group($group, $value)); // 0 is the group 'all'.
if (isset($group_um[0])) {
$info1 = get_users($order);
} else {
foreach ($group_um as $group => $value) {
$info1 = array_merge($info1, users_get_users_by_group($group, $value));
}
} }
} }
@ -591,10 +595,10 @@ foreach ($info as $user_id => $user_info) {
$data[4] .= '<div class="text_end">'; $data[4] .= '<div class="text_end">';
foreach ($user_profiles as $row) { foreach ($user_profiles as $row) {
if ($total_profile <= 5) { if ($total_profile <= 5) {
$data[4] .= "<div class='left'>"; $data[4] .= "<div class='float-left'>";
$data[4] .= profile_get_name($row['id_perfil']); $data[4] .= profile_get_name($row['id_perfil']);
$data[4] .= ' / </div>'; $data[4] .= ' / </div>';
$data[4] .= "<div class='left pdd_l_5px'>"; $data[4] .= "<div class='float-left pdd_l_5px'>";
$data[4] .= groups_get_name($row['id_grupo'], true); $data[4] .= groups_get_name($row['id_grupo'], true);
$data[4] .= '</div>'; $data[4] .= '</div>';

View File

@ -713,6 +713,19 @@ class DiscoveryTaskList extends HTML
$data[6] .= __('Discovery.Cloud.Aws.RDS'); $data[6] .= __('Discovery.Cloud.Aws.RDS');
break; break;
case DISCOVERY_CLOUD_AWS_S3:
// Discovery Cloud S3.
$data[6] = html_print_image(
'images/op_network.png',
true,
[
'title' => __('Discovery Cloud S3'),
'class' => 'invert_filter',
]
).'&nbsp;&nbsp;';
$data[6] .= __('Discovery.Cloud.Aws.S3');
break;
case DISCOVERY_APP_MYSQL: case DISCOVERY_APP_MYSQL:
// Discovery Applications MySQL. // Discovery Applications MySQL.
$data[6] = html_print_image( $data[6] = html_print_image(
@ -868,6 +881,7 @@ class DiscoveryTaskList extends HTML
&& $task['type'] != DISCOVERY_APP_DB2 && $task['type'] != DISCOVERY_APP_DB2
&& $task['type'] != DISCOVERY_APP_SAP && $task['type'] != DISCOVERY_APP_SAP
&& $task['type'] != DISCOVERY_CLOUD_AWS_RDS && $task['type'] != DISCOVERY_CLOUD_AWS_RDS
&& $task['type'] != DISCOVERY_CLOUD_AWS_S3
) { ) {
if (check_acl($config['id_user'], 0, 'MR')) { if (check_acl($config['id_user'], 0, 'MR')) {
$data[9] .= '<a href="#" onclick="show_map('.$task['id_rt'].',\''.$task['name'].'\')">'; $data[9] .= '<a href="#" onclick="show_map('.$task['id_rt'].',\''.$task['name'].'\')">';
@ -1024,7 +1038,9 @@ class DiscoveryTaskList extends HTML
*/ */
public function getTargetWiz($task, $script=false) public function getTargetWiz($task, $script=false)
{ {
if ($script !== false) { if ($script !== false
|| (int) $task['type'] === DISCOVERY_HOSTDEVICES_CUSTOM
) {
switch ($script['type']) { switch ($script['type']) {
case DISCOVERY_SCRIPT_APP_VMWARE: case DISCOVERY_SCRIPT_APP_VMWARE:
return 'wiz=app&mode=vmware&page=0'; return 'wiz=app&mode=vmware&page=0';
@ -1044,6 +1060,9 @@ class DiscoveryTaskList extends HTML
case DISCOVERY_CLOUD_AZURE_COMPUTE: case DISCOVERY_CLOUD_AZURE_COMPUTE:
return 'wiz=cloud&mode=azure&ki='.$task['auth_strings'].'&sub=compute&page=0'; return 'wiz=cloud&mode=azure&ki='.$task['auth_strings'].'&sub=compute&page=0';
case DISCOVERY_CLOUD_AWS_S3:
return 'wiz=cloud&mode=amazonws&ki='.$task['auth_strings'].'&sub=s3&page=0';
default: default:
return 'wiz=cloud'; return 'wiz=cloud';
} }
@ -1491,6 +1510,9 @@ class DiscoveryTaskList extends HTML
$simple_data[] = $tmp; $simple_data[] = $tmp;
if (is_array($data['modules'])) { if (is_array($data['modules'])) {
// Alphabetically sort.
ksort($data['modules'], (SORT_STRING | SORT_FLAG_CASE));
$simple_data = array_merge( $simple_data = array_merge(
$simple_data, $simple_data,
array_reduce( array_reduce(

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -257,6 +257,11 @@ if ($save_event_filter) {
$values['id_extra'] = get_parameter('id_extra'); $values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment'); $values['user_comment'] = get_parameter('user_comment');
$values['id_source_event'] = get_parameter('id_source_event'); $values['id_source_event'] = get_parameter('id_source_event');
if (is_metaconsole()) {
$values['server_id'] = get_parameter('server_id');
}
$exists = (bool) db_get_value_filter( $exists = (bool) db_get_value_filter(
'id_filter', 'id_filter',
'tevent_filter', 'tevent_filter',
@ -305,6 +310,10 @@ if ($update_event_filter) {
$values['user_comment'] = get_parameter('user_comment'); $values['user_comment'] = get_parameter('user_comment');
$values['id_source_event'] = get_parameter('id_source_event'); $values['id_source_event'] = get_parameter('id_source_event');
if (is_metaconsole()) {
$values['server_id'] = get_parameter('server_id');
}
if (io_safe_output($values['tag_with']) == '["0"]') { if (io_safe_output($values['tag_with']) == '["0"]') {
$values['tag_with'] = '[]'; $values['tag_with'] = '[]';
} }
@ -371,6 +380,13 @@ if ($get_filter_values) {
} }
} }
if (is_metaconsole()) {
$server_name = db_get_value('server_name', 'tmetaconsole_setup', 'id', $event_filter['server_id']);
if ($server_name !== false) {
$event_filter['server_name'] = $server_name;
}
}
$event_filter['module_search'] = io_safe_output(db_get_value_filter('nombre', 'tagente_modulo', ['id_agente_modulo' => $event_filter['id_agent_module']])); $event_filter['module_search'] = io_safe_output(db_get_value_filter('nombre', 'tagente_modulo', ['id_agente_modulo' => $event_filter['id_agent_module']]));
} }
@ -402,6 +418,8 @@ if ($load_filter_modal) {
); );
echo '<div id="load-filter-select" class="load-filter-modal">'; echo '<div id="load-filter-select" class="load-filter-modal">';
echo '<form method="post" id="form_load_filter">';
$table = new StdClass; $table = new StdClass;
$table->id = 'load_filter_form'; $table->id = 'load_filter_form';
$table->width = '100%'; $table->width = '100%';
@ -441,13 +459,15 @@ if ($load_filter_modal) {
__('Load filter'), __('Load filter'),
'load_filter', 'load_filter',
false, false,
'class="sub upd" onclick="load_form_filter();"', 'class="sub upd"',
true true
); );
$data[1] .= html_print_input_hidden('load_filter', 1, true);
$table->data[] = $data; $table->data[] = $data;
$table->rowclass[] = ''; $table->rowclass[] = '';
html_print_table($table); html_print_table($table);
echo '</form>';
echo '</div>'; echo '</div>';
?> ?>
<script type="text/javascript"> <script type="text/javascript">
@ -460,7 +480,8 @@ function show_filter() {
width: 450 width: 450
}); });
} }
//aki
function load_form_filter() { function load_form_filter() {
jQuery.post ( jQuery.post (
"<?php echo ui_get_full_url('ajax.php', false, false, false); ?>", "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
@ -471,7 +492,6 @@ function load_form_filter() {
}, },
function (data) { function (data) {
jQuery.each (data, function (i, val) { jQuery.each (data, function (i, val) {
console.log(val);
if (i == 'id_name') if (i == 'id_name')
$("#hidden-id_name").val(val); $("#hidden-id_name").val(val);
if (i == 'id_group'){ if (i == 'id_group'){
@ -517,6 +537,10 @@ function load_form_filter() {
$("#text-user_comment").val(val); $("#text-user_comment").val(val);
if (i == 'id_source_event') if (i == 'id_source_event')
$("#text-id_source_event").val(val); $("#text-id_source_event").val(val);
if (i == 'server_id')
$("#server_id").val(val);
if (i == 'server_name')
$("#select2-server_id-container").text(val);
if(i == 'date_from') if(i == 'date_from')
$("#text-date_from").val(val); $("#text-date_from").val(val);
if(i == 'date_to') if(i == 'date_to')
@ -747,7 +771,8 @@ function save_new_filter() {
"source": $("#text-source").val(), "source": $("#text-source").val(),
"id_extra": $("#text-id_extra").val(), "id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val(), "user_comment": $("#text-user_comment").val(),
"id_source_event": $("#text-id_source_event").val() "id_source_event": $("#text-id_source_event").val(),
"server_id": $("#server_id").val()
}, },
function (data) { function (data) {
$("#info_box").hide(); $("#info_box").hide();
@ -817,7 +842,8 @@ function save_update_filter() {
"source": $("#text-source").val(), "source": $("#text-source").val(),
"id_extra": $("#text-id_extra").val(), "id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val(), "user_comment": $("#text-user_comment").val(),
"id_source_event": $("#text-id_source_event").val() "id_source_event": $("#text-id_source_event").val(),
"server_id": $("#server_id").val()
}, },
function (data) { function (data) {
@ -1381,6 +1407,12 @@ if ($get_extended_event) {
'EW', 'EW',
$event['clean_tags'], $event['clean_tags'],
$childrens_ids $childrens_ids
)) || (tags_checks_event_acl(
$config['id_user'],
$event['id_grupo'],
'ER',
$event['clean_tags'],
$childrens_ids
))) )))
) { ) {
$tabs .= "<li><a href='#extended_event_responses_page' id='link_responses'>".html_print_image( $tabs .= "<li><a href='#extended_event_responses_page' id='link_responses'>".html_print_image(
@ -1444,6 +1476,12 @@ if ($get_extended_event) {
'EW', 'EW',
$event['clean_tags'], $event['clean_tags'],
$childrens_ids $childrens_ids
)) || (tags_checks_event_acl(
$config['id_user'],
$event['id_grupo'],
'ER',
$event['clean_tags'],
$childrens_ids
))) )))
) { ) {
$responses = events_page_responses($event); $responses = events_page_responses($event);
@ -1465,15 +1503,21 @@ if ($get_extended_event) {
$related = events_page_related($event, $server); $related = events_page_related($event, $server);
} }
$connected = true;
if ($meta) { if ($meta) {
metaconsole_connect($server); if (metaconsole_connect($server) === NOERR) {
$connected = true;
} else {
$connected = false;
}
} }
$custom_fields = events_page_custom_fields($event); if ($connected === true) {
$custom_fields = events_page_custom_fields($event);
$custom_data = events_page_custom_data($event);
}
$custom_data = events_page_custom_data($event); if ($meta && $connected === true) {
if ($meta) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
@ -1865,11 +1909,12 @@ if ($get_table_response_command) {
} }
if ($get_events_fired) { if ($get_events_fired) {
global $config;
$id = get_parameter('id_row'); $id = get_parameter('id_row');
$idGroup = get_parameter('id_group'); $idGroup = get_parameter('id_group');
$agents = get_parameter('agents', null); $agents = get_parameter('agents', null);
$query = ' AND id_evento > '.$id; $query = ' AND id_evento >= '.$id;
$type = []; $type = [];
$alert = get_parameter('alert_fired'); $alert = get_parameter('alert_fired');
@ -1889,7 +1934,10 @@ if ($get_events_fired) {
if ($critical == 'true') { if ($critical == 'true') {
$resultCritical = alerts_get_event_status_group( $resultCritical = alerts_get_event_status_group(
$idGroup, $idGroup,
'going_up_critical', [
'going_up_critical',
'going_down_critical',
],
$query, $query,
$agents $agents
); );
@ -1899,7 +1947,10 @@ if ($get_events_fired) {
if ($warning == 'true') { if ($warning == 'true') {
$resultWarning = alerts_get_event_status_group( $resultWarning = alerts_get_event_status_group(
$idGroup, $idGroup,
'going_up_warning', [
'going_up_warning',
'going_down_warning',
],
$query, $query,
$agents $agents
); );

View File

@ -1,17 +1,32 @@
<?php <?php
// Pandora FMS - http://pandorafms.com /**
// ================================================== * Tree view.
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas *
// Please see http://pandorafms.org for full contribution list * @category Tree
// This program is free software; you can redistribute it and/or * @package Pandora FMS
// modify it under the terms of the GNU Lesser General Public License * @subpackage Community
// as published by the Free Software Foundation; version 2 * @version 1.0.0
// This program is distributed in the hope that it will be useful, * @license See below
// 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. * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
// Only accesible by ajax * | __/| _ | | _ || _ | _| _ | | ___| |__ |
if (is_ajax()) { * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 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
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* 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.
* ============================================================================
*/
if (is_ajax() === true) {
global $config; global $config;
// Login check. // Login check.
@ -34,7 +49,7 @@ if (is_ajax()) {
$getGroupStatus = (bool) get_parameter('getGroupStatus', 0); $getGroupStatus = (bool) get_parameter('getGroupStatus', 0);
$getDetail = (bool) get_parameter('getDetail'); $getDetail = (bool) get_parameter('getDetail');
if ($getChildren) { if ($getChildren === true) {
$type = get_parameter('type', 'group'); $type = get_parameter('type', 'group');
$rootType = get_parameter('rootType', ''); $rootType = get_parameter('rootType', '');
$id = get_parameter('id', -1); $id = get_parameter('id', -1);
@ -55,47 +70,111 @@ if (is_ajax()) {
$agent_a = check_acl($config['id_user'], 0, 'AR'); $agent_a = check_acl($config['id_user'], 0, 'AR');
$agent_w = check_acl($config['id_user'], 0, 'AW'); $agent_w = check_acl($config['id_user'], 0, 'AW');
$access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'); $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR');
$switch_type = !empty($rootType) ? $rootType : $type; $switch_type = (empty($rootType) === false) ? $rootType : $type;
switch ($switch_type) { switch ($switch_type) {
case 'os': case 'os':
$tree = new TreeOS($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); $tree = new TreeOS(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break; break;
case 'module_group': case 'module_group':
$tree = new TreeModuleGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); $tree = new TreeModuleGroup(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break; break;
case 'module': case 'module':
$tree = new TreeModule($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); $tree = new TreeModule(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break; break;
case 'tag': case 'tag':
$tree = new TreeTag($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); $tree = new TreeTag(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break; break;
case 'group': case 'group':
if (is_metaconsole()) { if (is_metaconsole() === true) {
if (!class_exists('TreeGroupMeta')) { if (class_exists('TreeGroupMeta') === false) {
break; break;
} }
$tree = new TreeGroupMeta($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); $tree = new TreeGroupMeta(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
} else { } else {
$tree = new TreeGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); $tree = new TreeGroup(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
} }
break; break;
case 'policies': case 'policies':
if (!class_exists('TreePolicies')) { if (class_exists('TreePolicies') === false) {
break; break;
} }
$tree = new TreePolicies($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); $tree = new TreePolicies(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break; break;
case 'group_edition': case 'group_edition':
$tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); $tree = new TreeGroupEdition(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break; break;
case 'services': case 'services':
@ -112,7 +191,7 @@ if (is_ajax()) {
break; break;
default: default:
// FIXME. No error handler // No error handler.
return; return;
} }
@ -123,14 +202,14 @@ if (is_ajax()) {
return; return;
} }
if ($getDetail) { if ($getDetail === true) {
include_once $config['homedir'].'/include/functions_treeview.php'; include_once $config['homedir'].'/include/functions_treeview.php';
$id = (int) get_parameter('id'); $id = (int) get_parameter('id');
$type = (string) get_parameter('type'); $type = (string) get_parameter('type');
$server = []; $server = [];
if (is_metaconsole()) { if (is_metaconsole() === true) {
$server_id = (int) get_parameter('serverID'); $server_id = (int) get_parameter('serverID');
$server = metaconsole_get_servers($server_id); $server = metaconsole_get_servers($server_id);
} }
@ -142,7 +221,7 @@ if (is_ajax()) {
echo '</style>'; echo '</style>';
echo '<div class="left_align backgrund_primary_important">'; echo '<div class="left_align backgrund_primary_important">';
if (!empty($id) && !empty($type)) { if (empty($id) === false && empty($type) === false) {
switch ($type) { switch ($type) {
case 'agent': case 'agent':
treeview_printTable($id, $server, true); treeview_printTable($id, $server, true);
@ -157,7 +236,7 @@ if (is_ajax()) {
break; break;
default: default:
// Nothing // Nothing.
break; break;
} }
} }

View File

@ -36,6 +36,7 @@ define('DEBUG', 0);
define('VERBOSE', 0); define('VERBOSE', 0);
// TESTING THE UPDATE MANAGER. // TESTING THE UPDATE MANAGER.
enterprise_include_once('load_enterprise.php');
enterprise_include_once('include/functions_enterprise_api.php'); enterprise_include_once('include/functions_enterprise_api.php');
$ipOrigin = $_SERVER['REMOTE_ADDR']; $ipOrigin = $_SERVER['REMOTE_ADDR'];
@ -54,8 +55,9 @@ $api_password = get_parameter('apipass', '');
$password = get_parameter('pass', ''); $password = get_parameter('pass', '');
$user = get_parameter('user', ''); $user = get_parameter('user', '');
$info = get_parameter('info', ''); $info = get_parameter('info', '');
$raw_decode = (bool) get_parameter('raw_decode', false);
$other = parseOtherParameter($otherSerialize, $otherMode); $other = parseOtherParameter($otherSerialize, $otherMode, $raw_decode);
$apiPassword = io_output_password( $apiPassword = io_output_password(
db_get_value_filter( db_get_value_filter(
'value', 'value',
@ -311,7 +313,7 @@ if ($correctLogin) {
} }
// Logout. // Logout.
if (session_status() === PHP_SESSION_ACTIVE) { if (session_status() !== PHP_SESSION_DISABLED) {
$_SESSION = []; $_SESSION = [];
// Could give a warning if no session file is created. Ignore. // Could give a warning if no session file is created. Ignore.
@session_destroy(); @session_destroy();

View File

@ -2085,7 +2085,13 @@ class AgentWizard extends HTML
$tmp->ip_target($this->targetIp); $tmp->ip_target($this->targetIp);
$tmp->id_modulo(MODULE_PLUGIN); $tmp->id_modulo(MODULE_PLUGIN);
if (empty($candidate['macros']) === true) { if ($this->wizardSection === 'snmp_interfaces_explorer'
&& empty($candidate['macros']) === true
) {
// Use definition provided.
$tmp->id_plugin($candidate['id_plugin']);
$tmp->macros(base64_decode($candidate['macros']));
} else {
$fieldsPlugin = db_get_value_sql( $fieldsPlugin = db_get_value_sql(
sprintf( sprintf(
'SELECT macros FROM tplugin WHERE id=%d', 'SELECT macros FROM tplugin WHERE id=%d',
@ -2115,10 +2121,6 @@ class AgentWizard extends HTML
$tmp->id_plugin($infoMacros['server_plugin']); $tmp->id_plugin($infoMacros['server_plugin']);
$tmp->macros(json_encode($fieldsPlugin)); $tmp->macros(json_encode($fieldsPlugin));
} else {
// Use definition provided.
$tmp->id_plugin($candidate['id_plugin']);
$tmp->macros(base64_decode($candidate['macros']));
} }
} }
} }
@ -4313,15 +4315,6 @@ class AgentWizard extends HTML
'form="form-create-modules"' 'form="form-create-modules"'
); );
// Execution type module.
$data[6] .= html_print_input_hidden(
'module-execution_type-'.$uniqueId,
$module['execution_type'],
true,
$md5IdBlock,
'form="form-create-modules"'
);
// WMI Query class. // WMI Query class.
$data[6] .= html_print_input_hidden( $data[6] .= html_print_input_hidden(
'module-query_class-'.$uniqueId, 'module-query_class-'.$uniqueId,

View File

@ -840,6 +840,7 @@ class AgentsAlerts extends HTML
'label' => __('Full screen'), 'label' => __('Full screen'),
'id' => 'img-full-screen', 'id' => 'img-full-screen',
'surround_start' => '<div id="full_screen_refresh_box">', 'surround_start' => '<div id="full_screen_refresh_box">',
'attributes' => 'style="margin-left: 0px"',
'arguments' => [ 'arguments' => [
'type' => 'button', 'type' => 'button',
'return' => true, 'return' => true,

View File

@ -185,6 +185,7 @@ class CustomNetScan extends Wizard
$this->task['id_recon_server'] = $server_id; $this->task['id_recon_server'] = $server_id;
$this->task['id_group'] = $id_group; $this->task['id_group'] = $id_group;
$this->task['interval_sweep'] = $interval; $this->task['interval_sweep'] = $interval;
$this->task['type'] = DISCOVERY_HOSTDEVICES_CUSTOM;
if (isset($this->task['id_rt']) === false) { if (isset($this->task['id_rt']) === false) {
// Create. // Create.

View File

@ -472,6 +472,11 @@ class HTML
bool $return=false, bool $return=false,
bool $direct=false bool $direct=false
) { ) {
global $config;
if ($config['style'] === 'pandora_black') {
$text_color = 'style="color: white"';
}
$output = ''; $output = '';
if ($input['hidden'] == 1) { if ($input['hidden'] == 1) {
$class = ' hidden'; $class = ' hidden';
@ -488,7 +493,7 @@ class HTML
$toggle = (bool) $input['toggle']; $toggle = (bool) $input['toggle'];
if (isset($input['label']) === true) { if (isset($input['label']) === true) {
$output .= '<span>'.$input['label'].'</span>'; $output .= '<span '.$text_color.'>'.$input['label'].'</span>';
} }
// Print independent block of inputs. // Print independent block of inputs.
@ -559,7 +564,7 @@ class HTML
} }
if (isset($input['label']) === true) { if (isset($input['label']) === true) {
$output .= '<label>'.$input['label'].'</label>'; $output .= '<label '.$text_color.'>'.$input['label'].'</label>';
} }
$output .= self::printInput($input['arguments']); $output .= self::printInput($input['arguments']);

View File

@ -1727,7 +1727,10 @@ class NetworkMap
$item['image_height'] = 0; $item['image_height'] = 0;
if (empty($node['style']['image']) === false) { if (empty($node['style']['image']) === false) {
$item['image_url'] = ui_get_full_url( $item['image_url'] = ui_get_full_url(
$node['style']['image'] $node['style']['image'],
false,
false,
false
); );
$image_size = getimagesize( $image_size = getimagesize(
$config['homedir'].'/'.$node['style']['image'] $config['homedir'].'/'.$node['style']['image']
@ -2837,13 +2840,7 @@ class NetworkMap
*/ */
public function loadSimpleInterface() public function loadSimpleInterface()
{ {
$output = '<div id="open_version_dialog" class="invisible">'; $output = '';
$output .= __(
'In the Open version of %s can not be edited nodes or map',
get_product_name()
);
$output .= '</div>';
$output .= '<div id="dialog_node_edit" class="invisible" title="'; $output .= '<div id="dialog_node_edit" class="invisible" title="';
$output .= __('Edit node').'">'; $output .= __('Edit node').'">';
$output .= '<div class="left w100p">'; $output .= '<div class="left w100p">';
@ -2893,6 +2890,12 @@ class NetworkMap
$id = 'dialog_node_edit'; $id = 'dialog_node_edit';
if (!enterprise_installed()) { if (!enterprise_installed()) {
$id = 'open_version_dialog'; $id = 'open_version_dialog';
$output = '<div id="open_version" style="display: none" title="'.__('Warning').'">';
$output .= '<div class="center mrgn_top_20px w90p font_13px">'.__(
'In the Open version of %s can not be edited nodes or map',
get_product_name()
);
$output .= '</div></div>';
} }
$output .= '<div id="'.$id.'" class="invisible" title="'; $output .= '<div id="'.$id.'" class="invisible" title="';
@ -3391,7 +3394,7 @@ class NetworkMap
&& isset($this->useTooltipster) && isset($this->useTooltipster)
&& $this->useTooltipster == true && $this->useTooltipster == true
) { ) {
$output .= '<script type="text/javascript" src="'.ui_get_full_url( $output = '<script type="text/javascript" src="'.ui_get_full_url(
'include/javascript/d3.3.5.14.js' 'include/javascript/d3.3.5.14.js'
).'" charset="utf-8"></script>'; ).'" charset="utf-8"></script>';
$output .= '<script type="text/javascript" src="'.ui_get_full_url( $output .= '<script type="text/javascript" src="'.ui_get_full_url(
@ -3443,13 +3446,35 @@ class NetworkMap
$networkmap['filter']['l2_network_interfaces'] = 1; $networkmap['filter']['l2_network_interfaces'] = 1;
$output .= '<script type="text/javascript" src="'.$config['homeurl'].'include/javascript/d3.3.5.14.js" charset="utf-8"></script>'; $output .= '<script type="text/javascript" src="';
$output .= ui_get_full_url(
'include/javascript/d3.3.5.14.js',
false,
false,
false
);
$output .= '" charset="utf-8"></script>';
if (isset($this->map['__simulated']) === false) { if (isset($this->map['__simulated']) === false) {
// Load context menu if manageable networkmap. // Load context menu if manageable networkmap.
$output .= '<script type="text/javascript" src="'.$config['homeurl'].'include/javascript/jquery.contextMenu.js"></script>'; $output .= '<script type="text/javascript" src="';
$output .= ui_get_full_url(
'include/javascript/jquery.contextMenu.js',
false,
false,
false
);
$output .= '" charset="utf-8"></script>';
} }
$output .= '<script type="text/javascript" src="'.$config['homeurl'].'include/javascript/functions_pandora_networkmap.js"></script>'; $output .= '<script type="text/javascript" src="';
$output .= ui_get_full_url(
'include/javascript/functions_pandora_networkmap.js',
false,
false,
false
);
$output .= '" charset="utf-8"></script>';
// Open networkconsole_id div. // Open networkconsole_id div.
$output .= '<div id="networkconsole_'.$networkmap['id'].'"'; $output .= '<div id="networkconsole_'.$networkmap['id'].'"';

View File

@ -1,15 +1,30 @@
<?php <?php
// Pandora FMS- http://pandorafms.com /**
// ================================================== * Tree view.
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas *
// Please see http://pandorafms.org for full contribution list * @category Tree
// This program is free software; you can redistribute it and/or * @package Pandora FMS
// modify it under the terms of the GNU Lesser General Public License * @subpackage Community
// as published by the Free Software Foundation; version 2 * @version 1.0.0
// This program is distributed in the hope that it will be useful, * @license See below
// 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. * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 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
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* 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.
* ============================================================================
*/
class Tree class Tree
{ {

View File

@ -1,32 +1,86 @@
<?php <?php
// Pandora FMS- http://pandorafms.com /**
// ================================================== * Tree view.
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas *
// Please see http://pandorafms.org for full contribution list * @category Tree
// This program is free software; you can redistribute it and/or * @package Pandora FMS
// modify it under the terms of the GNU Lesser General Public License * @subpackage Community
// as published by the Free Software Foundation; version 2 * @version 1.0.0
// This program is distributed in the hope that it will be useful, * @license See below
// 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. * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 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
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* 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.
* ============================================================================
*/
global $config; global $config;
require_once $config['homedir'].'/include/class/Tree.class.php'; require_once $config['homedir'].'/include/class/Tree.class.php';
/**
* Tree group class.
*/
class TreeGroup extends Tree class TreeGroup extends Tree
{ {
/**
* Propagate ACL.
*
* @var boolean
*/
protected $propagateCounters = true; protected $propagateCounters = true;
/**
* Display all groups.
*
* @var boolean
*/
protected $displayAllGroups = false; protected $displayAllGroups = false;
public function __construct($type, $rootType='', $id=-1, $rootID=-1, $serverID=false, $childrenMethod='on_demand', $access='AR') /**
{ * Construct.
*
* @param string $type Type.
* @param string $rootType Root.
* @param integer $id Id.
* @param integer $rootID Root Id.
* @param boolean $serverID Server.
* @param string $childrenMethod Method children.
* @param string $access Access ACL.
*/
public function __construct(
$type,
$rootType='',
$id=-1,
$rootID=-1,
$serverID=false,
$childrenMethod='on_demand',
$access='AR'
) {
global $config; global $config;
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); parent::__construct(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
$this->L1fieldName = 'id_group'; $this->L1fieldName = 'id_group';
$this->L1extraFields = [ $this->L1extraFields = [
@ -42,18 +96,37 @@ class TreeGroup extends Tree
} }
/**
* Setter propagate counters.
*
* @param boolean $value True or ffalse.
*
* @return void
*/
public function setPropagateCounters($value) public function setPropagateCounters($value)
{ {
$this->propagateCounters = (bool) $value; $this->propagateCounters = (bool) $value;
} }
/**
* Setter all groups.
*
* @param boolean $value True or ffalse.
*
* @return void
*/
public function setDisplayAllGroups($value) public function setDisplayAllGroups($value)
{ {
$this->displayAllGroups = (bool) $value; $this->displayAllGroups = (bool) $value;
} }
/**
* Get data.
*
* @return void
*/
protected function getData() protected function getData()
{ {
if ($this->id == -1) { if ($this->id == -1) {
@ -66,22 +139,36 @@ class TreeGroup extends Tree
} }
/**
* Filter search groups.
*
* @return string
*/
protected function getGroupSearchFilter() protected function getGroupSearchFilter()
{ {
return ''; return '';
} }
/**
* First level tree.
*
* @return void
*/
protected function getFirstLevel() protected function getFirstLevel()
{ {
$processed_items = $this->getProcessedGroups(); $processed_items = $this->getProcessedGroups();
if (!empty($processed_items)) { if (empty($processed_items) === false) {
// Filter by group name. This should be done after rerieving the items cause we need the possible items descendants // Filter by group name. This should be done after rerieving
if (!empty($this->filter['searchGroup'])) { // the items cause we need the possible items descendants.
// Save the groups which intersect with the user groups if (empty($this->filter['searchGroup']) === false) {
$groups = db_get_all_rows_filter('tgrupo', ['nombre' => '%'.$this->filter['searchGroup'].'%']); // Save the groups which intersect with the user groups.
if ($groups == false) { $groups = db_get_all_rows_filter(
'tgrupo',
['nombre' => '%'.$this->filter['searchGroup'].'%']
);
if ($groups === false) {
$groups = []; $groups = [];
} }
@ -90,7 +177,7 @@ class TreeGroup extends Tree
$groups, $groups,
function ($userGroups, $group) use ($userGroupsACL) { function ($userGroups, $group) use ($userGroupsACL) {
$group_id = $group['id_grupo']; $group_id = $group['id_grupo'];
if (isset($userGroupsACL[$group_id])) { if (isset($userGroupsACL[$group_id]) === true) {
$userGroups[$group_id] = $userGroupsACL[$group_id]; $userGroups[$group_id] = $userGroupsACL[$group_id];
} }
@ -99,14 +186,22 @@ class TreeGroup extends Tree
[] []
); );
$result = self::extractGroupsWithIDs($processed_items, $ids_hash); $result = self::extractGroupsWithIDs(
$processed_items,
$ids_hash
);
$processed_items = ($result === false) ? [] : $result; $processed_items = ($result === false) ? [] : $result;
} }
// groupID filter. To access the view from tactical views f.e. // GroupID filter. To access the view from tactical views f.e.
if (!empty($this->filter['groupID'])) { if (empty($this->filter['groupID']) === false) {
$result = self::extractItemWithID($processed_items, $this->filter['groupID'], 'group', $this->strictACL); $result = self::extractItemWithID(
$processed_items,
$this->filter['groupID'],
'group',
$this->strictACL
);
$processed_items = ($result === false) ? [] : [$result]; $processed_items = ($result === false) ? [] : [$result];
} }
@ -116,56 +211,64 @@ class TreeGroup extends Tree
} }
/**
* Process group
*
* @return mixed
*/
protected function getProcessedGroups() protected function getProcessedGroups()
{ {
$processed_groups = []; $processed_groups = [];
// Index and process the groups // Index and process the groups.
$groups = $this->getGroupCounters(); $groups = $this->getGroupCounters();
// If user have not permissions in parent, set parent node to 0 (all) // If user have not permissions in parent, set parent node to 0 (all)
// Avoid to do foreach for admins // Avoid to do foreach for admins.
if (!users_can_manage_group_all('AR')) { if (users_can_manage_group_all('AR') === false) {
foreach ($groups as $id => $group) { foreach ($groups as $id => $group) {
if (!isset($this->userGroups[$groups[$id]['parent']])) { if (isset($this->userGroups[$groups[$id]['parent']]) === false) {
$groups[$id]['parent'] = 0; $groups[$id]['parent'] = 0;
} }
} }
} }
// Build the group hierarchy // Build the group hierarchy.
foreach ($groups as $id => $group) { foreach ($groups as $id => $group) {
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { if (isset($groups[$id]['parent']) === true
&& ($groups[$id]['parent'] != 0)
) {
$parent = $groups[$id]['parent']; $parent = $groups[$id]['parent'];
// Parent exists // Parent exists.
if (!isset($groups[$parent]['children'])) { if (isset($groups[$parent]['children']) === false) {
$groups[$parent]['children'] = []; $groups[$parent]['children'] = [];
} }
// Store a reference to the group into the parent // Store a reference to the group into the parent.
$groups[$parent]['children'][] = &$groups[$id]; $groups[$parent]['children'][] = &$groups[$id];
// This group was introduced into a parent // This group was introduced into a parent.
$groups[$id]['have_parent'] = true; $groups[$id]['have_parent'] = true;
} }
} }
// Sort the children groups // Sort the children groups.
foreach ($groups as $id => $group) { foreach ($groups as $id => $group) {
if (isset($groups[$id]['children'])) { if (isset($groups[$id]['children']) === true) {
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']); usort($groups[$id]['children'], ['Tree', 'cmpSortNames']);
} }
} }
// Filter groups and eliminates the reference to children groups out of her parent // Filter groups and eliminates the reference to
// children groups out of her parent.
$groups = array_filter( $groups = array_filter(
$groups, $groups,
function ($group) { function ($group) {
return !$group['have_parent']; return !$group['have_parent'];
} }
); );
// Propagate child counters to her parents // Propagate child counters to her parents.
if ($this->propagateCounters) { if ($this->propagateCounters === true) {
self::processCounters($groups); self::processCounters($groups);
// Filter groups and eliminates the reference to empty groups // Filter groups and eliminates the reference to empty groups.
$groups = $this->deleteEmptyGroups($groups); $groups = $this->deleteEmptyGroups($groups);
} else { } else {
$groups = $this->deleteEmptyGroupsNotPropagate($groups); $groups = $this->deleteEmptyGroupsNotPropagate($groups);

View File

@ -1,31 +1,81 @@
<?php <?php
// Pandora FMS- http://pandorafms.com /**
// ================================================== * Tree view.
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas *
// Please see http://pandorafms.org for full contribution list * @category Tree
// This program is free software; you can redistribute it and/or * @package Pandora FMS
// modify it under the terms of the GNU Lesser General Public License * @subpackage Community
// as published by the Free Software Foundation; version 2 * @version 1.0.0
// This program is distributed in the hope that it will be useful, * @license See below
// 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. * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 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
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* 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.
* ============================================================================
*/
global $config; global $config;
require_once $config['homedir'].'/include/class/Tree.class.php'; require_once $config['homedir'].'/include/class/Tree.class.php';
/**
* Tree group edition.
*/
class TreeGroupEdition extends TreeGroup class TreeGroupEdition extends TreeGroup
{ {
public function __construct($type, $rootType='', $id=-1, $rootID=-1, $serverID=false, $childrenMethod='on_demand', $access='AR') /**
{ * Construct.
*
* @param string $type Type.
* @param string $rootType Root.
* @param integer $id Id.
* @param integer $rootID Root Id.
* @param boolean $serverID Server.
* @param string $childrenMethod Method children.
* @param string $access Access ACL.
*/
public function __construct(
$type,
$rootType='',
$id=-1,
$rootID=-1,
$serverID=false,
$childrenMethod='on_demand',
$access='AR'
) {
global $config; global $config;
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); parent::__construct(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
} }
/**
* Get data.
*
* @return void
*/
protected function getData() protected function getData()
{ {
if ($this->id == -1) { if ($this->id == -1) {
@ -34,46 +84,54 @@ class TreeGroupEdition extends TreeGroup
} }
/**
* Get process group.
*
* @return mixed
*/
protected function getProcessedGroups() protected function getProcessedGroups()
{ {
$processed_groups = []; $processed_groups = [];
// Index and process the groups // Index and process the groups.
$groups = $this->getGroupCounters(); $groups = $this->getGroupCounters();
// If user have not permissions in parent, set parent node to 0 (all) // If user have not permissions in parent, set parent node to 0 (all)
// Avoid to do foreach for admins // Avoid to do foreach for admins.
if (!users_can_manage_group_all('AR')) { if (users_can_manage_group_all('AR') === false) {
foreach ($groups as $id => $group) { foreach ($groups as $id => $group) {
if (!isset($this->userGroups[$groups[$id]['parent']])) { if (isset($this->userGroups[$groups[$id]['parent']]) === false) {
$groups[$id]['parent'] = 0; $groups[$id]['parent'] = 0;
} }
} }
} }
// Build the group hierarchy // Build the group hierarchy.
foreach ($groups as $id => $group) { foreach ($groups as $id => $group) {
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { if (isset($groups[$id]['parent']) === true
&& ($groups[$id]['parent'] != 0)
) {
$parent = $groups[$id]['parent']; $parent = $groups[$id]['parent'];
// Parent exists // Parent exists.
if (!isset($groups[$parent]['children'])) { if (isset($groups[$parent]['children']) === false) {
$groups[$parent]['children'] = []; $groups[$parent]['children'] = [];
} }
// Store a reference to the group into the parent // Store a reference to the group into the parent.
$groups[$parent]['children'][] = &$groups[$id]; $groups[$parent]['children'][] = &$groups[$id];
// This group was introduced into a parent // This group was introduced into a parent.
$groups[$id]['have_parent'] = true; $groups[$id]['have_parent'] = true;
} }
} }
// Sort the children groups // Sort the children groups.
foreach ($groups as $id => $group) { foreach ($groups as $id => $group) {
if (isset($groups[$id]['children'])) { if (isset($groups[$id]['children']) === true) {
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']); usort($groups[$id]['children'], ['Tree', 'cmpSortNames']);
} }
} }
// Filter groups and eliminates the reference to children groups out of her parent // Filter groups and eliminates the reference
// to children groups out of her parent.
$groups = array_filter( $groups = array_filter(
$groups, $groups,
function ($group) { function ($group) {
@ -81,11 +139,25 @@ class TreeGroupEdition extends TreeGroup
} }
); );
// Filter groups that user has permission.
$groups = array_filter(
$groups,
function ($group) {
global $config;
return check_acl($config['id_user'], $group['id'], 'AR');
}
);
usort($groups, ['Tree', 'cmpSortNames']); usort($groups, ['Tree', 'cmpSortNames']);
return $groups; return $groups;
} }
/**
* Get group counters.
*
* @return mixed
*/
protected function getGroupCounters() protected function getGroupCounters()
{ {
$messages = [ $messages = [
@ -93,10 +165,25 @@ class TreeGroupEdition extends TreeGroup
'cancel' => __('Cancel'), 'cancel' => __('Cancel'),
'messg' => __('Are you sure?'), 'messg' => __('Are you sure?'),
]; ];
$sql = 'SELECT id_grupo AS gid,
nombre as name, parent, icon $group_acl = '';
if (users_can_manage_group_all('AR') === false) {
$user_groups_str = implode(',', $this->userGroupsArray);
$group_acl = sprintf(
'AND id_grupo IN (%s)',
$user_groups_str
);
}
$sql = sprintf(
'SELECT id_grupo AS gid,
nombre as name,
parent,
icon
FROM tgrupo FROM tgrupo
'; WHERE 1=1 %s',
$group_acl
);
$stats = db_get_all_rows_sql($sql); $stats = db_get_all_rows_sql($sql);
$group_stats = []; $group_stats = [];
@ -107,7 +194,9 @@ class TreeGroupEdition extends TreeGroup
$group_stats[$group['gid']]['id'] = $group['gid']; $group_stats[$group['gid']]['id'] = $group['gid'];
$group_stats[$group['gid']]['type'] = 'group'; $group_stats[$group['gid']]['type'] = 'group';
$group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]); $group_stats[$group['gid']] = $this->getProcessedItem(
$group_stats[$group['gid']]
);
$group_stats[$group['gid']]['delete']['messages'] = $messages; $group_stats[$group['gid']]['delete']['messages'] = $messages;
$group_stats[$group['gid']]['edit'] = 1; $group_stats[$group['gid']]['edit'] = 1;
$group_stats[$group['gid']]['alerts'] = ''; $group_stats[$group['gid']]['alerts'] = '';

View File

@ -20,8 +20,8 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC210329'; $build_version = 'PC210505';
$pandora_version = 'v7.0NG.752'; $pandora_version = 'v7.0NG.754';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.
$script_tz = @date_default_timezone_get(); $script_tz = @date_default_timezone_get();

View File

@ -626,6 +626,7 @@ define('DISCOVERY_APP_SAP', 10);
define('DISCOVERY_APP_DB2', 11); define('DISCOVERY_APP_DB2', 11);
define('DISCOVERY_APP_MICROSOFT_SQL_SERVER', 12); define('DISCOVERY_APP_MICROSOFT_SQL_SERVER', 12);
define('DISCOVERY_CLOUD_GCP_COMPUTE_ENGINE', 13); define('DISCOVERY_CLOUD_GCP_COMPUTE_ENGINE', 13);
define('DISCOVERY_CLOUD_AWS_S3', 14);
// Force task build tmp results. // Force task build tmp results.
define('DISCOVERY_REVIEW', 0); define('DISCOVERY_REVIEW', 0);

View File

@ -2252,12 +2252,16 @@ function check_login($output=true)
return true; return true;
} }
} else { } else {
include_once $config['homedir'].'/mobile/include/db.class.php';
include_once $config['homedir'].'/mobile/include/system.class.php';
include_once $config['homedir'].'/mobile/include/user.class.php'; include_once $config['homedir'].'/mobile/include/user.class.php';
if (isset($_SESSION['user'])) { if (isset($_SESSION['user'])) {
$user = $_SESSION['user']; $user = User::getInstance();
$id_user = $user->getIdUser(); $id_user = $user->getIdUser();
if (is_user($id_user)) { if (is_user($id_user)) {
$_SESSION['id_usuario'] = $id_user;
$config['id_user'] = $id_user;
return true; return true;
} }
} }
@ -2853,7 +2857,11 @@ function can_user_access_node()
{ {
global $config; global $config;
$userinfo = get_user_info($config['id_user']); static $userinfo;
if ($userinfo === null) {
$userinfo = get_user_info($config['id_user']);
}
if (is_metaconsole()) { if (is_metaconsole()) {
return $userinfo['is_admin'] == 1 ? 1 : $userinfo['metaconsole_access_node']; return $userinfo['is_admin'] == 1 ? 1 : $userinfo['metaconsole_access_node'];

View File

@ -1,27 +1,38 @@
<?php <?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 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 Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// 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.
/** /**
* @package Include * Agents Functions.
* @subpackage Agents *
* @category Agents functions.
* @package Pandora FMS
* @subpackage User interface.
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 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
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* 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.
* ============================================================================
*/ */
// Begin.
require_once $config['homedir'].'/include/functions.php'; require_once $config['homedir'].'/include/functions.php';
require_once $config['homedir'].'/include/functions_modules.php'; require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_users.php';
use PandoraFMS\Enterprise\RCMDFile as RCMDFile; use PandoraFMS\Enterprise\RCMDFile as RCMDFile;
use PandoraFMS\Event;
/** /**
@ -203,11 +214,13 @@ function agents_create_agent(
$values=false, $values=false,
$alias_as_name=false $alias_as_name=false
) { ) {
if (empty($name)) { global $config;
if (empty($name) === true) {
return false; return false;
} }
if (empty($id_group) && (int) $id_group != 0) { if (empty($id_group) === true && (int) $id_group !== 0) {
return false; return false;
} }
@ -216,11 +229,11 @@ function agents_create_agent(
$interval = false; $interval = false;
} }
if (empty($interval)) { if (empty($interval) === true) {
return false; return false;
} }
if (! is_array($values)) { if (is_array($values) === false) {
$values = []; $values = [];
} }
@ -229,17 +242,22 @@ function agents_create_agent(
$values['id_grupo'] = $id_group; $values['id_grupo'] = $id_group;
$values['intervalo'] = $interval; $values['intervalo'] = $interval;
if (!empty($ip_address)) { if (empty($ip_address) === false) {
$values['direccion'] = $ip_address; $values['direccion'] = $ip_address;
} }
// Check if group has limit or overrides the agent limit.
if (group_allow_more_agents($id_group, true, 'create') === false) {
return false;
}
$id_agent = db_process_sql_insert('tagente', $values); $id_agent = db_process_sql_insert('tagente', $values);
if ($id_agent === false) { if ($id_agent === false) {
return false; return false;
} }
// Create address for this agent in taddress. // Create address for this agent in taddress.
if (!empty($ip_address)) { if (empty($ip_address) === false) {
agents_add_address($id_agent, $ip_address); agents_add_address($id_agent, $ip_address);
} }
@ -1084,6 +1102,7 @@ function agents_common_modules($id_agent, $filter=false, $indexed=true, $get_not
* @param string $separator Only in metaconsole. Separator for the serialized data. By default |. * @param string $separator Only in metaconsole. Separator for the serialized data. By default |.
* @param boolean $add_alert_bulk_op //TODO documentation * @param boolean $add_alert_bulk_op //TODO documentation
* @param boolean $force_serialized. If the agent has not id_server (typically in node) put 0 as <server_id>. * @param boolean $force_serialized. If the agent has not id_server (typically in node) put 0 as <server_id>.
* @param boolean $meta_fields If true, then id_agente is returned instead id_tagente.
* *
* @return array An array with all agents in the group or an empty array * @return array An array with all agents in the group or an empty array
*/ */
@ -1096,7 +1115,8 @@ function agents_get_group_agents(
$serialized=false, $serialized=false,
$separator='|', $separator='|',
$add_alert_bulk_op=false, $add_alert_bulk_op=false,
$force_serialized=false $force_serialized=false,
$meta_fields=false
) { ) {
global $config; global $config;
@ -1268,11 +1288,19 @@ function agents_get_group_agents(
if (is_metaconsole()) { if (is_metaconsole()) {
$table_name = 'tmetaconsole_agent ta LEFT JOIN tmetaconsole_agent_secondary_group tasg ON ta.id_agente = tasg.id_agent'; $table_name = 'tmetaconsole_agent ta LEFT JOIN tmetaconsole_agent_secondary_group tasg ON ta.id_agente = tasg.id_agent';
$fields = [ if ($meta_fields === true) {
'ta.id_tagente AS id_agente', $fields = [
'alias', 'id_agente',
'ta.id_tmetaconsole_setup AS id_server', 'alias',
]; 'ta.id_tmetaconsole_setup AS id_server',
];
} else {
$fields = [
'ta.id_tagente AS id_agente',
'alias',
'ta.id_tmetaconsole_setup AS id_server',
];
}
} else { } else {
$table_name = 'tagente LEFT JOIN tagent_secondary_group ON id_agente=id_agent'; $table_name = 'tagente LEFT JOIN tagent_secondary_group ON id_agente=id_agent';
@ -3253,6 +3281,7 @@ function agents_get_agent_custom_field($agent_id, $custom_field_name)
* @param boolean $selection Show common (false) or all modules (true). * @param boolean $selection Show common (false) or all modules (true).
* @param boolean $return Return (false) or dump to output (true). * @param boolean $return Return (false) or dump to output (true).
* @param boolean $index_by_name Use module name as key. * @param boolean $index_by_name Use module name as key.
* @param boolean $pure_return Return as retrieved from DB.
* *
* @return array With modules or null if error. * @return array With modules or null if error.
*/ */
@ -3261,7 +3290,8 @@ function select_modules_for_agent_group(
$id_agents, $id_agents,
$selection, $selection,
$return=true, $return=true,
$index_by_name=false $index_by_name=false,
$pure_return=false
) { ) {
global $config; global $config;
$agents = (empty($id_agents)) ? [] : implode(',', $id_agents); $agents = (empty($id_agents)) ? [] : implode(',', $id_agents);
@ -3341,6 +3371,10 @@ function select_modules_for_agent_group(
return; return;
} }
if ($pure_return === true) {
return $modules;
}
$modules_array = []; $modules_array = [];
foreach ($modules as $value) { foreach ($modules as $value) {
if ($index_by_name) { if ($index_by_name) {
@ -3841,6 +3875,70 @@ function agents_get_last_status_change($id_agent)
} }
/**
* Checks if group allow more agents due itself limitation.
*
* @param integer $id_group Id of the group.
* @param boolean $generateEvent If true and the check fails, will generate an event.
* @param string $action Action for perform (only if generateEvent is true).
*
* @return boolean True if allow more agents.
*/
function group_allow_more_agents(
int $id_group,
bool $generateEvent=false,
string $action='create'
):bool {
global $config;
$groupMaxAgents = (int) db_get_value('max_agents', 'tgrupo', sprintf('id_grupo = %d', $id_group));
$groupCountAgents = (int) db_get_num_rows(sprintf('SELECT nombre FROM tagente WHERE id_grupo = "%s"', $id_group));
// If `max_agents` is not defined or the count of agents in the group is below of max agents allowed.
$output = ($groupMaxAgents === 0 || $groupCountAgents < $groupMaxAgents);
if ($output === false && $generateEvent === true) {
// Get the group name.
$groupName = db_get_value(
'nombre',
'tgrupo',
'id_grupo',
$id_group
);
// New event.
$evt = new Event;
// Set parameters.
$evt->evento(
sprintf(
'Agent cannot be %sd due to the maximum agent limit for group %s',
$action,
$groupName
)
);
$evt->id_grupo($id_group);
$evt->id_agente(0);
$evt->id_agentmodule(0);
$evt->id_usuario($config['id_user']);
$evt->estado(EVENT_STATUS_NEW);
$evt->event_type(EVENTS_SYSTEM);
$evt->criticity(EVENT_CRIT_WARNING);
$evt->timestamp(date('Y-m-d H:i:s'));
$evt->utimestamp(time());
$evt->data(0);
$evt->source('agent_creation');
// Any fields are only available in meta.
if (is_metaconsole() === true) {
$evt->id_source_event(0);
}
// Save the event.
$evt->save();
}
return $output;
}
/** /**
* Return the list of agents for a planned downtime * Return the list of agents for a planned downtime
* *
@ -3850,7 +3948,7 @@ function agents_get_last_status_change($id_agent)
* *
* @return array * @return array
*/ */
function get_planned_downtime_agents_list($id_downtime, $filter_cond, $id_groups_str) function get_planned_downtime_agents_list($id_downtime, $filter_cond, $id_groups_str):array
{ {
$agents = []; $agents = [];

View File

@ -173,13 +173,22 @@ function alerts_get_event_status_group($idGroup, $type='alert_fired', $query='AN
$idAgents = array_values($agents); $idAgents = array_values($agents);
} }
$result = db_get_all_rows_sql( $sql = sprintf(
'SELECT id_evento 'SELECT id_evento
FROM tevento FROM tevento
WHERE estado = 0 AND id_agente IN (0,'.implode(',', $idAgents).') '.$typeWhere.$query.' WHERE estado = 0
ORDER BY id_evento DESC LIMIT 1' AND id_agente IN (0, %s)
%s
%s
ORDER BY id_evento DESC
LIMIT 1',
implode(',', $idAgents),
$typeWhere,
$query
); );
$result = db_get_all_rows_sql($sql);
if ($result === false) { if ($result === false) {
return false; return false;
} }
@ -439,10 +448,11 @@ function alerts_delete_alert_action($id_alert_action)
* Clone an alert action. * Clone an alert action.
* *
* @param int Id of the original alert action * @param int Id of the original alert action
* @param int Agent group id if it wants to be changed when clone.
* *
* @return mixed Id of the cloned action or false in case of fail. * @return mixed Id of the cloned action or false in case of fail.
*/ */
function alerts_clone_alert_action($id_alert_action) function alerts_clone_alert_action($id_alert_action, $id_group)
{ {
$id_alert_action = safe_int($id_alert_action, 1); $id_alert_action = safe_int($id_alert_action, 1);
if (empty($id_alert_action)) { if (empty($id_alert_action)) {
@ -455,6 +465,10 @@ function alerts_clone_alert_action($id_alert_action)
return false; return false;
} }
if ($id_group != '') {
$action['id_group'] = $id_group;
}
unset($action['id']); unset($action['id']);
return alerts_create_alert_action($action['name'].' '.__('copy'), $action['id_alert_command'], $action); return alerts_create_alert_action($action['name'].' '.__('copy'), $action['id_alert_command'], $action);
@ -1121,10 +1135,11 @@ function alerts_get_alert_template_field3_recovery($id_alert_template)
* Duplicates an alert template. * Duplicates an alert template.
* *
* @param int Id of an alert template. * @param int Id of an alert template.
* @param int Agent group id if it wants to be changed when duplicate.
* *
* @return mixed Duplicates an alert template or false if something goes wrong. * @return mixed Duplicates an alert template or false if something goes wrong.
*/ */
function alerts_duplicate_alert_template($id_alert_template) function alerts_duplicate_alert_template($id_alert_template, $id_group)
{ {
$template = alerts_get_alert_template($id_alert_template); $template = alerts_get_alert_template($id_alert_template);
@ -1132,6 +1147,10 @@ function alerts_duplicate_alert_template($id_alert_template)
return false; return false;
} }
if ($id_group != '') {
$template['id_group'] = $id_group;
}
$name = io_safe_input(__('Copy of').' ').$template['name']; $name = io_safe_input(__('Copy of').' ').$template['name'];
$type = $template['type']; $type = $template['type'];
@ -2125,8 +2144,6 @@ function get_group_alerts(
$disabled = $filter; $disabled = $filter;
} }
$filter .= ' AND talert_template_modules.disabled = 0 ';
switch ($disabled) { switch ($disabled) {
case 'notfired': case 'notfired':
$filter .= ' AND times_fired = 0 AND talert_template_modules.disabled = 0'; $filter .= ' AND times_fired = 0 AND talert_template_modules.disabled = 0';
@ -2144,9 +2161,13 @@ function get_group_alerts(
$filter .= ' AND talert_template_modules.disabled = 0'; $filter .= ' AND talert_template_modules.disabled = 0';
break; break;
default: case 'all':
$filter .= ''; $filter .= '';
break; break;
default:
$filter .= ' AND talert_template_modules.disabled = 0 ';
break;
} }
// WHEN SELECT ALL TAGS TO FILTER ALERTS // WHEN SELECT ALL TAGS TO FILTER ALERTS
@ -2186,8 +2207,8 @@ function get_group_alerts(
WHERE 1 = 0'; WHERE 1 = 0';
} else { } else {
$subQuery = 'SELECT id_agente_modulo $subQuery = 'SELECT id_agente_modulo
FROM tagente_modulo FROM tagente_modulo tam
WHERE delete_pending = 0 WHERE delete_pending = 0 AND tam.disabled = 0
AND id_agente IN (SELECT id_agente AND id_agente IN (SELECT id_agente
FROM tagente ta FROM tagente ta
LEFT JOIN tagent_secondary_group tasg LEFT JOIN tagent_secondary_group tasg

View File

@ -43,11 +43,12 @@ use PandoraFMS\Enterprise\Cluster;
/** /**
* Parse the "other" parameter. * Parse the "other" parameter.
* *
* @param string $other * @param string $other
* @param mixed $otherType * @param mixed $otherType
* @param boolean $rawDecode Decode string in which the sequences with percent (%) signs followed by two hex digits have been replaced with literal characters.
* @return mixed * @return mixed
*/ */
function parseOtherParameter($other, $otherType) function parseOtherParameter($other, $otherType, $rawDecode)
{ {
switch ($otherType) { switch ($otherType) {
case 'url_encode': case 'url_encode':
@ -65,12 +66,12 @@ function parseOtherParameter($other, $otherType)
'data' => explode($separator, $other), 'data' => explode($separator, $other),
]; ];
foreach ($returnVar['data'] as $index => $element) { foreach ($returnVar['data'] as $index => $element) {
$returnVar['data'][$index] = urldecode($element); $returnVar['data'][$index] = $rawDecode ? rawurldecode($element) : urldecode($element);
} }
} else { } else {
$returnVar = [ $returnVar = [
'type' => 'string', 'type' => 'string',
'data' => urldecode($other), 'data' => $rawDecode ? rawurldecode($other) : urldecode($other),
]; ];
} }
break; break;
@ -375,6 +376,103 @@ function api_get_test_event_replication_db()
// -------------------------DEFINED OPERATIONS FUNCTIONS----------------- // -------------------------DEFINED OPERATIONS FUNCTIONS-----------------
/**
* Example: http://localhost/pandora_console/include/api.php?op=get&op2=license&user=admin&apipass=1234&pass=pandora&return_type=json
* Retrieve license information.
*
* @param null $trash1 Not used.
* @param null $trash1 Not used.
* @param null $trash1 Not used.
* @param string $returnType Return type (string, json...).
*
* @return void
*/
function api_get_license($trash1, $trash2, $trash3, $returnType='json')
{
global $config;
check_login();
if (! check_acl($config['id_user'], 0, 'PM')) {
returnError('forbidden', $returnType);
return;
}
enterprise_include_once('include/functions_license.php');
$license = enterprise_hook('license_get_info');
if ($license === ENTERPRISE_NOT_HOOK) {
// Not an enterprise environment?
if (license_free()) {
$license = 'PANDORA_FREE';
}
returnData(
$returnType,
[
'type' => 'array',
'data' => ['license_mode' => $license],
]
);
return;
}
returnData(
$returnType,
[
'type' => 'array',
'data' => $license,
]
);
}
/**
* Example: http://localhost/pandora_console/include/api.php?op=get&op2=license_remaining&user=admin&apipass=1234&pass=pandora&return_type=json
* Retrieve license status agents or modules left.
*
* @param null $trash1 Not used.
* @param null $trash1 Not used.
* @param null $trash1 Not used.
* @param string $returnType Return type (string, json...).
*
* @return void
*/
function api_get_license_remaining(
$trash1,
$trash2,
$trash3,
$returnType='json'
) {
enterprise_include_once('include/functions_license.php');
$license = enterprise_hook('license_get_info');
if ($license === ENTERPRISE_NOT_HOOK) {
if (license_free()) {
returnData(
$returnType,
[
'type' => 'integer',
'data' => PHP_INT_MAX,
]
);
} else {
returnError('get-license', 'Failed to verify license.');
}
return;
}
returnData(
$returnType,
[
'type' => 'integer',
'data' => ($license['limit'] - $license['count_enabled']),
]
);
}
function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db) function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db)
{ {
$returnAllGroup = true; $returnAllGroup = true;
@ -1381,6 +1479,12 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3)
return; return;
} }
// Check if group allow more agents or have limit stablished.
if (group_allow_more_agents($idGroup, true, 'update') === false) {
returnError('Agent cannot be updated due to the maximum agent limit for this group');
return;
}
// Check selected parent // Check selected parent
if ($idParent != 0) { if ($idParent != 0) {
$parentCheck = agents_check_access_agent($idParent); $parentCheck = agents_check_access_agent($idParent);
@ -1578,10 +1682,12 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3)
// Check if agent exists (BUG WC-50518-2). // Check if agent exists (BUG WC-50518-2).
if ($alias == '' && $alias_as_name === 0) { if ($alias == '' && $alias_as_name === 0) {
returnError('No agent alias specified'); returnError('No agent alias specified');
} else if (agents_get_agent_id($server_name)) { } else if (agents_get_agent_id($nombre_agente)) {
returnError('The agent name already exists in DB.'); returnError('The agent name already exists in DB.');
} else if (db_get_value_sql('SELECT id_grupo FROM tgrupo WHERE id_grupo = '.$grupo) === false) { } else if (db_get_value_sql('SELECT id_grupo FROM tgrupo WHERE id_grupo = '.$grupo) === false) {
returnError('The group does not exist.'); returnError('The group does not exist.');
} else if (group_allow_more_agents($grupo, true, 'create') === false) {
returnError('Agent cannot be created due to the maximum agent limit for this group');
} else if (db_get_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = '.$id_os) === false) { } else if (db_get_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = '.$id_os) === false) {
returnError('The OS does not exist.'); returnError('The OS does not exist.');
} else if ($server_name === false) { } else if ($server_name === false) {
@ -6276,6 +6382,136 @@ function api_set_delete_module_template_by_names($id, $id2, $other, $trash1)
} }
/**
* Validate an alert
*
* @param string $id1 Alert template name (eg. 'Warning condition')
* @param string $trash1 Do nnot use.
* @param array $other [1] id/name agent.
* [2] id/name module
* [3] Use agent/module alias.
* @param string $trash2 Do not use
* @return void
*/
function api_set_validate_alert($id1, $trash1, $other, $trash2)
{
global $config;
if (defined('METACONSOLE')) {
return;
}
if (!check_acl($config['id_user'], 0, 'LW')) {
returnError('forbidden');
return;
}
if ($id1 === '') {
returnError(
'error_validate_alert',
__('Error validating alert. Id_template cannot be left blank.')
);
return;
}
if ($other['data'][0] == '') {
returnError(
'error_validate_alert',
__('Error validating alert. Id_agent cannot be left blank.')
);
return;
}
if ($other['data'][1] == '') {
returnError(
'error_validate_alert',
__('Error validating alert. Id_module cannot be left blank.')
);
return;
}
if ($other['data'][2] == 1) {
$use_alias = true;
}
$values = [
'alert_name' => $id1,
'id_agent' => $other['data'][0],
'id_agent_module' => $other['data'][1],
];
if ($use_alias === true) {
$id_agents = agents_get_agent_id_by_alias($values['id_agent']);
foreach ($id_agents as $id) {
$values['id_agent'] = $id['id_agente'];
$values['id_agent_module'] = db_get_value_filter(
'id_agente_modulo as id_module',
'tagente_modulo',
[
'id_agente' => $values['id_agent'],
'nombre' => $values['id_agent_module'],
]
);
$id_template = db_get_value_filter(
'id as id_template',
'talert_templates',
[
'name' => $values['alert_name'],
]
);
// Get alert id.
$id_alert = db_get_value_filter(
'id as id_alert',
'talert_template_modules',
[
'id_agent_module' => $values['id_agent_module'],
'id_alert_template' => $id_template,
]
);
}
$result = alerts_validate_alert_agent_module($id_alert);
} else {
$id_template = db_get_value_filter(
'id as id_template',
'talert_templates',
[
'name' => $values['alert_name'],
]
);
// Get alert id.
$id_alert = db_get_value_filter(
'id as id_alert',
'talert_template_modules',
[
'id_agent_module' => $values['id_agent_module'],
'id_alert_template' => $id_template,
]
);
if ($id_alert === false) {
returnError(
'error_validate_alert',
__('Error validating alert. Specified alert does not exist.')
);
return;
}
$result = alerts_validate_alert_agent_module($id_alert);
}
if ($result) {
returnData('string', ['type' => 'string', 'data' => 'Alert succesfully validated']);
} else {
returnData('string', ['type' => 'string', 'data' => __('Error validating alert')]);
}
}
/** /**
* Validate all alerts. And return a message with the result of the operation. * Validate all alerts. And return a message with the result of the operation.
* *
@ -8175,6 +8411,7 @@ function api_set_create_group($id, $thrash1, $other, $thrash3)
$values['custom_id'] = $safe_other_data[5]; $values['custom_id'] = $safe_other_data[5];
$values['contact'] = $safe_other_data[6]; $values['contact'] = $safe_other_data[6];
$values['other'] = $safe_other_data[7]; $values['other'] = $safe_other_data[7];
$values['max_agents'] = $safe_other_data[8];
$id_group = groups_create_group($group_name, $values); $id_group = groups_create_group($group_name, $values);
@ -8254,7 +8491,8 @@ function api_set_update_group($id_group, $thrash2, $other, $thrash3)
$disabled = $other['data'][5]; $disabled = $other['data'][5];
$custom_id = $other['data'][6]; $custom_id = $other['data'][6];
$contact = $other['data'][7]; $contact = $other['data'][7];
$other = $other['data'][8]; $otherData = $other['data'][8];
$maxAgents = $other['data'][9];
$return = db_process_sql_update( $return = db_process_sql_update(
'tgrupo', 'tgrupo',
@ -8267,7 +8505,8 @@ function api_set_update_group($id_group, $thrash2, $other, $thrash3)
'disabled' => $disabled, 'disabled' => $disabled,
'custom_id' => $custom_id, 'custom_id' => $custom_id,
'contact' => $contact, 'contact' => $contact,
'other' => $other, 'other' => $otherData,
'max_agents' => $maxAgents,
], ],
['id_grupo' => $id_group] ['id_grupo' => $id_group]
); );
@ -12315,6 +12554,7 @@ function api_set_create_tag($id, $trash1, $other, $returnType)
// http://127.0.0.1/pandora_console/include/api.php?op=set&op2=create_event&id=name_event&other=2|system|3|admin|2|1|10|0|comments||Pandora||critical_inst|warning_inst|unknown_inst|other||&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora // http://127.0.0.1/pandora_console/include/api.php?op=set&op2=create_event&id=name_event&other=2|system|3|admin|2|1|10|0|comments||Pandora||critical_inst|warning_inst|unknown_inst|other||&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
// http://127.0.0.1/pandora_console/include/api.php?op=set&op2=create_event&id=name_event&other=textodelevento|10|2|0|admin|going_down_critical|4|&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
function api_set_create_event($id, $trash1, $other, $returnType) function api_set_create_event($id, $trash1, $other, $returnType)
{ {
global $config; global $config;

View File

@ -200,8 +200,20 @@ function config_update_config()
$error_update[] = __('Use cert.'); $error_update[] = __('Use cert.');
} }
if (!config_update_value('attachment_store', (string) get_parameter('attachment_store'))) { $attachment_store = (string) get_parameter('attachment_store');
if (file_exists($attachment_store) === false
|| is_writable($attachment_store) === false
) {
$error_update[] = __('Attachment store'); $error_update[] = __('Attachment store');
$error_update[] .= __(
"Path doesn't exists or is not writable"
);
} else {
if (config_update_value('attachment_store', $attachment_store) === false) {
$error_update[] = __(
'Attachment store.'
);
}
} }
if (!config_update_value('list_ACL_IPs_for_API', (string) get_parameter('list_ACL_IPs_for_API'))) { if (!config_update_value('list_ACL_IPs_for_API', (string) get_parameter('list_ACL_IPs_for_API'))) {
@ -1645,7 +1657,11 @@ function config_update_config()
$integria_hostname = (string) get_parameter('integria_hostname', $config['integria_hostname']); $integria_hostname = (string) get_parameter('integria_hostname', $config['integria_hostname']);
if (parse_url($integria_hostname, PHP_URL_SCHEME) === null) { if (parse_url($integria_hostname, PHP_URL_SCHEME) === null) {
$integria_hostname = 'http://'.$integria_hostname; if (empty($_SERVER['HTTPS']) === false) {
$integria_hostname = 'https://'.$integria_hostname;
} else {
$integria_hostname = 'http://'.$integria_hostname;
}
} }
if (!config_update_value('integria_hostname', $integria_hostname)) { if (!config_update_value('integria_hostname', $integria_hostname)) {
@ -3358,6 +3374,32 @@ function config_user_set_custom_config()
} }
} }
if ((isset($userinfo['id_skin']) && $userinfo['id_skin'] !== 0)) {
if ((int) $userinfo['id_skin'] === 1) {
$config['style'] = 'pandora';
}
if ((int) $userinfo['id_skin'] === 2) {
$config['style'] = 'pandora_black';
}
}
$skin = get_parameter('skin', false);
$sec2_aux = get_parameter('sec2');
if ($sec2_aux != 'godmode/groups/group_list' && $skin !== false) {
$id_user_aux = get_parameter('id');
if ($id_user_aux == $config['id_user']) {
if ((int) $skin === 1 || (int) $skin === 0) {
$config['style'] = 'pandora';
}
if ((int) $skin === 2) {
$config['style'] = 'pandora_black';
}
}
}
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$config['metaconsole_access'] = $userinfo['metaconsole_access']; $config['metaconsole_access'] = $userinfo['metaconsole_access'];
} }

Some files were not shown because too many files have changed in this diff Show More