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
# 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
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 \
nfdump \
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"
# SDK VMware perl dependencies
@ -475,7 +483,7 @@ net.core.optmem_max = 81920
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
chown pandora:apache /var/log/pandora

View File

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

View File

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

View File

@ -1,5 +1,5 @@
# 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,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (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
# 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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

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

View File

@ -19,11 +19,11 @@
<choice id="com.pandorafms.pandorafms_src" visible="false">
<pkg-ref id="com.pandorafms.pandorafms_src"/>
</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">
<pkg-ref id="com.pandorafms.pandorafms_uninstall"/>
</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()" />
<script>
<![CDATA[

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
# 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,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

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

View File

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

View File

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

View File

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

View File

@ -592,7 +592,6 @@ BEGIN {
my ($self) = @_;
if ($YAML == 0) {
$self->set_last_error('Cannot use commands without YAML dependency, please install it.');
return;
}
@ -1015,8 +1014,8 @@ my $Sem = undef;
# Semaphore used to control the number of threads
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.752';
use constant AGENT_BUILD => '210329';
use constant AGENT_VERSION => '7.0NG.754';
use constant AGENT_BUILD => '210505';
# Agent log default file size maximum and instances
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
$ENV{'PATH'} .= ":$ConfDir/plugins";

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (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
# 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

View File

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

View File

@ -81,6 +81,7 @@ Pandora_Module::Pandora_Module (string name) {
this->module_ff_type = "";
this->module_alert_template = "";
this->module_crontab = "";
this->module_wait_timeout = 500;
}
/**
@ -1722,3 +1723,18 @@ Pandora_Module::isIntensive () {
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);
void cleanDataList ();
int module_wait_timeout;
public:
Pandora_Module (string name);
virtual ~Pandora_Module ();
@ -231,6 +232,7 @@ namespace Pandora_Modules {
int getInterval ();
int getIntensiveInterval ();
void setTimeout (int timeout);
void setWaitTimeout (int timeout);
int getTimeout ();
string getSave ();
bool getAsync ();

View File

@ -172,7 +172,7 @@ Pandora_Module_Exec::run () {
string output;
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);
if (avail > 0) {
ReadFile (out_read, buffer, BUFSIZE, &read, NULL);
@ -180,11 +180,6 @@ Pandora_Module_Exec::run () {
output += (char *) buffer;
}
/* Change the output encoding */
if (this->native_encoding != -1){
changeOutputEncoding(&output);
}
if (dwRet == WAIT_OBJECT_0) {
break;
} else if(this->getTimeout() < GetTickCount() - tickbase) {
@ -220,6 +215,10 @@ Pandora_Module_Exec::run () {
}
// Command output mode
else if (!output.empty()) {
/* Change the output encoding */
if (this->native_encoding != -1){
changeOutputEncoding(&output);
}
this->setOutput (output);
} else {
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_ALERT_TEMPLATE ("module_alert_template")
#define TOKEN_USER_SESSION ("module_user_session ")
#define TOKEN_WAIT_TIMEOUT ("module_wait_timeout ")
string
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_inverse, module_warning_inverse, module_quiet, module_ff_interval;
string module_native_encoding, module_alert_template, module_ff_type;
string macro;
string macro, module_wait_timeout;
Pandora_Module *module;
bool numeric;
Module_Type type;
@ -260,6 +261,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_alert_template = "";
module_user_session = "";
macro = "";
module_wait_timeout = "";
stringtok (tokens, definition, "\n");
@ -291,6 +293,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
if (module_exec == "") {
module_exec = parseLine (line, TOKEN_EXEC);
}
if (module_wait_timeout == "") {
module_wait_timeout = parseLine (line, TOKEN_WAIT_TIMEOUT);
}
if (module_proc == "") {
module_proc = parseLine (line, TOKEN_PROC);
}
@ -1130,6 +1135,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
if (module_timeout != "") {
module->setTimeout (atoi (module_timeout.c_str ()));
}
if (module_wait_timeout != "") {
module->setWaitTimeout (atoi (module_wait_timeout.c_str ()));
}
} else if (module_proc != "") {
module = new Pandora_Module_Proc (module_name,
@ -1230,6 +1238,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
if (module_timeout != ""){
module->setTimeout(atoi(module_timeout.c_str()));
}
if (module_wait_timeout != "") {
module->setWaitTimeout (atoi (module_wait_timeout.c_str ()));
}
} else if (module_ping != "") {
if (module_ping_count == "") {
module_ping_count = "1";

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#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_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
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"
END
END

View File

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

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.752-210329"
pandora_version="7.0NG.754-210505"
package_pear=0
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');
} else {
ini_set('log_errors', 0);
ini_set('error_log', 0);
ini_set('error_log', null);
}
// Sometimes input is badly retrieved from caller...

View File

@ -196,6 +196,7 @@ function mainModuleGroups()
ON ta.id_agente = tam.id_agente
WHERE ta.disabled = 0
AND tam.disabled = 0
AND tam.id_modulo <> 0
AND tam.delete_pending = 0
AND ta.id_grupo IN (%s)
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);
process_upload_xml($xml);
if ($xml === false) {
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)
) 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`
-- ---------------------------------------------------------------------
@ -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 `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_id_usuario` = "REGEX" WHERE `id_usuario` != '';
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,
`text_agent` text,
`text` TEXT,
`external_source` Text,
`external_source` mediumtext,
`treport_custom_sql_id` INTEGER UNSIGNED default 0,
`header_definition` 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` MODIFY COLUMN `user_comment` 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`
@ -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 `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` MODIFY `external_source` MEDIUMTEXT;
-- ---------------------------------------------------------------------
-- Table `tmodule_relationship`
@ -2501,6 +2522,7 @@ CREATE TABLE `tnotification_source_group_user` (
-- 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\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
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
@ -2519,7 +2541,7 @@ INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Di
-- ----------------------------------------------------------------------
-- 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`
@ -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='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`
-- ----------------------------------------------------------------------

View File

@ -53,8 +53,8 @@ ui_print_info_message(['no_close' => true, 'message' => __('There are no HA clus
<?php
if (check_acl($config['id_user'], 0, 'PM')) {
echo "<div id='create_master_window' class='invisible'></div>";
echo "<div id='msg' class='invisible'></div>";
echo "<div id='create_master_window' style='display: none'></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'); ?>" />
<?php

View File

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

View File

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

View File

@ -37,6 +37,8 @@ require_once $config['homedir'].'/include/functions_cron.php';
ui_require_javascript_file('encode_decode_base64');
ui_require_css_file('agent_manager');
use PandoraFMS\Event;
check_login();
// Get tab parameter to check ACL in each tabs.
@ -229,6 +231,9 @@ if ($create_agent) {
if ($alias == '') {
$agent_creation_error = __('No agent alias specified');
$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 {
if ($alias_as_name) {
$sql = 'SELECT nombre FROM tagente WHERE nombre = "'.$alias.'"';
@ -400,7 +405,7 @@ if ($id_agente) {
// 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(
'images/module.png',
'images/gm_modules.png',
true,
[
'title' => __('Modules'),
@ -416,7 +421,7 @@ if ($id_agente) {
// 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(
'images/bell.png',
'images/gm_alerts.png',
true,
[
'title' => __('Alerts'),
@ -1034,6 +1039,8 @@ if ($update_agent) {
if ($grupo <= 0) {
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) {
ui_print_error_message(__('Duplicate main IP address'));
} else {

View File

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

View File

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

View File

@ -115,7 +115,12 @@ function add_component_selection($id_network_component_type)
'',
'---'.__('Manual setup').'---',
0,
true
true,
false,
true,
'',
false,
'width: 460px; '
);
$data[1] .= '</span>';
$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) {
tag_name = $(value).html();
if (tag_name != <?php echo "'".__('None')."'"; ?>) {
id_tag = $(value).attr('value');
$("select[name='id_tag_selected[]']").append($("<option></option>").val(id_tag).html('<i>' + tag_name + '</i>'));
$("select[name='id_tag_selected[]']").append(value);
$("#id_tag_available").find("option[value='" + id_tag + "']").remove();
$("#id_tag_selected").find("option[value='']").remove();
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();
if (tag_name != <?php echo "'".__('None')."'"; ?>) {
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_available").find("option[value='']").remove();
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';
}
$can_edit_all = false;
if (check_acl_restricted_all($config['id_user'], 0, 'LM')) {
$can_edit_all = true;
}
// Header.
if (defined('METACONSOLE')) {
alerts_meta_print_header();
@ -79,30 +84,13 @@ if ($copy_action) {
$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 user tries to copy an action with group=ALL.
if ($al_action['id_group'] == 0) {
// Then must have "PM" access privileges.
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
);
include 'general/noaccess.php';
exit;
}
// If user who doesn't have permission to modify group all tries to copy an action with group=ALL.
if ($can_edit_all == false && $al_action['id_group'] == 0) {
$al_action['id_group'] = users_get_first_group(false, 'LM', false);
} else {
$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(
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) {
db_pandora_audit(
@ -397,10 +385,9 @@ foreach ($actions as $action) {
$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>';
} else {
$data[0] = $action['name'];
$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) {
$data[0] .= ui_print_help_tip(__('You cannot edit this action, You don\'t have the permission to edit All group.'), true);
}
$data[1] = $action['command_name'];
@ -420,7 +407,7 @@ foreach ($actions as $action) {
$data[4] = '';
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[] = [
3 => 'action_buttons',
@ -430,10 +417,35 @@ foreach ($actions as $action) {
$id_action = $action['id'];
$text_confirm = __('Are you sure?');
$data[3] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions"
onClick="copy_action('.$id_action.',\''.$text_confirm.'\');">'.html_print_image('images/copy.png', true, ['class' => 'invert_filter']).'</a>';
$data[4] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions"
onClick="delete_action('.$id_action.',\''.$text_confirm.'\');">'.html_print_image('images/cross.png', true, ['class' => 'invert_filter']).'</a>';
$data[3] = '<form method="post" style="display: inline; float: right" onsubmit="if (!confirm(\''.$text_confirm.'\')) return false;">';
$data[3] .= html_print_input_hidden('copy_action', 1, true);
$data[3] .= html_print_input_hidden('id', $id_action, true);
$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);
@ -458,44 +470,3 @@ if (is_central_policies_on_node() === false) {
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;
}
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()) {
$sec = 'advanced';
} else {
@ -46,6 +40,8 @@ $create_command = (bool) get_parameter('create_command');
$delete_command = (bool) get_parameter('delete_command');
$copy_command = (bool) get_parameter('copy_command');
$url = 'index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands';
if (is_ajax()) {
$get_alert_command = (bool) get_parameter('get_alert_command');
if ($get_alert_command) {
@ -465,6 +461,20 @@ if (is_ajax()) {
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');
if ($update_command) {
@ -634,6 +644,12 @@ if ($commands === false) {
$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) {
$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.
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">';
$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.'"
if (check_acl($config['id_user'], 0, 'PM') || is_user_admin(
$config['id_user
']
)
) {
$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>';
$data['action'] .= '</span>';
$data['action'] .= '</span>';
}
}
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);
ui_pagination($total_commands, $url, 0, 0, false, 'offset', true, 'pagination-bottom');
} 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')) {
@ -716,4 +746,4 @@ enterprise_hook('close_meta_frame');
});
}
</script>
</script>

View File

@ -882,9 +882,11 @@ foreach ($simple_alerts as $alert) {
['title' => __('Add action')]
);
} else {
$data[4] .= '<a href="javascript:show_add_action(\''.$alert['id'].'\');">';
$data[4] .= html_print_image('images/add.png', true, ['title' => __('Add action'), 'class' => 'invert_filter']);
$data[4] .= '</a>';
if ((int) $alert['id_policy_alerts'] === 0) {
$data[4] .= '<a href="javascript:show_add_action(\''.$alert['id'].'\');">';
$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 = [];
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>';
} else {
$data[0] = $template['name'];
$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')) {
$data[0] .= ui_print_help_tip(__('You cannot edit this alert template, You don\'t have the permission to edit All group.'), true);
}
$data[1] = ui_print_group_icon($template['id_group'], true);
$data[3] = alerts_get_alert_templates_type_name($template['type']);
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';
$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 method="post" class="float-right inline_line" onsubmit="if (!confirm(\''.__('Are you sure?').'\')) return false;">';
$data[4] .= html_print_input_hidden('delete_template', 1, true);
$data[4] .= html_print_input_hidden('id', $template['id'], true);
$data[4] .= html_print_input_image(
'del',
'images/cross.png',
1,
'',
true,
['title' => __('Delete')]
);
$data[4] .= '</form> ';
if (check_acl_restricted_all($config['id_user'], $template['id_group'], 'LM')) {
$data[4] .= '<form method="post" class="float-right inline_line" onsubmit="if (!confirm(\''.__('Are you sure?').'\')) return false;">';
$data[4] .= html_print_input_hidden('delete_template', 1, true);
$data[4] .= html_print_input_hidden('id', $template['id'], true);
$data[4] .= html_print_input_image(
'del',
'images/cross.png',
1,
'',
true,
['title' => __('Delete')]
);
$data[4] .= '</form> ';
}
} else {
$data[4] = '';
}

View File

@ -58,7 +58,7 @@ if (defined('METACONSOLE')) {
if ($al_action !== false) {
$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'));
} else {
$own_groups = array_keys(users_get_groups($config['id_user'], 'LM', false));
@ -91,8 +91,15 @@ if ($al_action !== false) {
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();
@ -102,6 +109,11 @@ if ($is_central_policies_on_node === true) {
);
}
$disabled = !$is_in_group;
$disabled_attr = '';
if ($disabled) {
$disabled_attr = 'disabled="disabled"';
}
$name = '';
$id_command = '';
@ -116,15 +128,6 @@ if ($id) {
$group = $action['id_group'];
$action_threshold = $action['action_threshold'];
$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.
@ -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') {
@ -194,7 +197,7 @@ $own_info = get_user_info($config['id_user']);
$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;
}
@ -211,7 +214,7 @@ $table->data[1][1] = '<div class="w250px inline">'.html_print_select_groups(
false,
true,
'',
$is_central_policies_on_node
($is_central_policies_on_node | $disabled)
).'</div>';
$table->colspan[1][1] = 2;
@ -245,11 +248,11 @@ $table->data[2][1] = html_print_select_from_sql(
true,
false,
false,
$is_central_policies_on_node
($is_central_policies_on_node | $disabled)
);
$table->data[2][1] .= ' ';
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] .= '<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,
true,
'',
$is_central_policies_on_node,
($is_central_policies_on_node | $disabled),
false,
'',
false,
@ -304,11 +307,21 @@ $table->data[5][2] = html_print_textarea(
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.'),
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++) {
$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(
'field'.$i.'_value',
(!empty($action['field'.$i]) || $action['field'.$i] == 0) ? $action['field'.$i] : '',
true
true,
'',
$disabled_attr
);
$table->data['field'.$i][2] .= html_print_input_hidden(
'field'.$i.'_recovery_value',
(!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);
echo $table_html;
@ -346,18 +363,7 @@ if ($is_central_policies_on_node === false) {
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) {
html_print_input_hidden('id', $id);
if ($al_action['id_group'] == 0) {
// 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 {
if (!$disabled) {
html_print_input_hidden('update_action', 1);
html_print_submit_button(
__('Update'),
@ -365,6 +371,12 @@ if ($is_central_policies_on_node === false) {
false,
'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 {
html_print_input_hidden('create_action', 1);
@ -391,6 +403,7 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
$(document).ready (function () {
var original_command;
var origicommand_descriptionnal_command;
var integriaWorkUnitName = "<?php echo $integriaIdName; ?>";
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)))); ?>";
@ -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']; ?>');
// Change the selected group
@ -608,6 +628,7 @@ $(document).ready (function () {
for (i = 1; i <= max_fields; i++) {
var old_value = '';
var old_recovery_value = '';
var disabled = '';
var field_row = data["fields_rows"][i];
var $table_macros_field = $('#table_macros-field' + i);
@ -623,6 +644,7 @@ $(document).ready (function () {
== ("hidden-field" + i + "_value")) {
old_value = $("[name=field" + i + "_value]").val();
disabled = $("[name=field" + i + "_value]").attr('disabled');
}
if (($("[name=field" + i + "_recovery_value]").attr('id'))
@ -689,6 +711,10 @@ $(document).ready (function () {
$('#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();
}

View File

@ -38,7 +38,6 @@ $step = (int) get_parameter('step', 1);
// We set here the number of steps.
define('LAST_STEP', 3);
// If user tries to duplicate/edit a template with group=ALL then must have "PM" access privileges
if ($duplicate_template) {
$source_id = (int) get_parameter('source_id');
$a_template = alerts_get_alert_template($source_id);
@ -52,19 +51,14 @@ if (defined('METACONSOLE')) {
$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 user tries to duplicate/edit a template with group=ALL
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')) {
alerts_meta_print_header();
} else {
@ -146,7 +140,12 @@ if ($a_template !== false) {
if ($duplicate_template) {
$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) {
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');
$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 = '';
$description = '';
$type = '';
@ -602,7 +609,7 @@ if ($step == 2) {
1,
$monday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][1] .= __('Tue');
$table->data[0][1] .= html_print_checkbox(
@ -610,7 +617,7 @@ if ($step == 2) {
1,
$tuesday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][1] .= __('Wed');
$table->data[0][1] .= html_print_checkbox(
@ -618,7 +625,7 @@ if ($step == 2) {
1,
$wednesday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][1] .= __('Thu');
$table->data[0][1] .= html_print_checkbox(
@ -626,7 +633,7 @@ if ($step == 2) {
1,
$thursday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][1] .= __('Fri');
$table->data[0][1] .= html_print_checkbox(
@ -634,7 +641,7 @@ if ($step == 2) {
1,
$friday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][1] .= __('Sat');
$table->data[0][1] .= html_print_checkbox(
@ -642,7 +649,7 @@ if ($step == 2) {
1,
$saturday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][1] .= __('Sun');
$table->data[0][1] .= html_print_checkbox(
@ -650,7 +657,7 @@ if ($step == 2) {
1,
$sunday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][2] = __('Use special days list');
@ -659,7 +666,7 @@ if ($step == 2) {
1,
$special_day,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$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][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;
@ -716,7 +723,7 @@ if ($step == 2) {
false,
true,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$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');
@ -750,7 +757,7 @@ if ($step == 2) {
1,
$min_alerts_reset_counter,
true,
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
'',
false,
$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');
@ -783,7 +790,7 @@ if ($step == 2) {
1,
$disable_event,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[5][0] = __('Default action');
@ -811,7 +818,7 @@ if ($step == 2) {
true,
false,
false,
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
false,
false,
0
@ -833,7 +840,7 @@ if ($step == 2) {
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] .= '&nbsp;'.html_print_checkbox('matches_value', 1, $matches, true);
@ -886,7 +893,8 @@ if ($step == 2) {
'',
5,
255,
true
true,
$disabled
);
$table->colspan['min'][1] = 3;
@ -897,7 +905,8 @@ if ($step == 2) {
'',
5,
255,
true
true,
$disabled
);
$table->colspan['max'][1] = 3;
@ -940,7 +949,7 @@ if ($step == 2) {
false,
false,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->colspan[0][1] = 2;
@ -966,7 +975,7 @@ if ($step == 2) {
0,
'',
false,
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
"removeTinyMCE('textarea_field".$i."')",
'',
true
@ -979,7 +988,7 @@ if ($step == 2) {
0,
'',
true,
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
"addTinyMCE('textarea_field".$i."')",
'',
true
@ -995,7 +1004,7 @@ if ($step == 2) {
'class="fields" min-height-40px',
true,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
// Recovery.
@ -1007,7 +1016,7 @@ if ($step == 2) {
0,
'',
false,
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
"removeTinyMCE('textarea_field".$i."_recovery')",
'',
true
@ -1020,7 +1029,7 @@ if ($step == 2) {
0,
'',
true,
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
"addTinyMCE('textarea_field".$i."_recovery')",
'',
true
@ -1036,7 +1045,7 @@ if ($step == 2) {
'class="fields min-height-40px"',
true,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
}
} 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;
if (users_can_manage_group_all('LM') === true) {
if (users_can_manage_group_all('LM') === true || $disabled) {
$return_all_group = true;
} else {
if ($id_group == 0) {
$id_group = users_get_first_group(false, 'LM', false);
}
}
$table->data[0][1] .= '&nbsp;';
@ -1121,7 +1134,7 @@ if ($step == 2) {
false,
true,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
).'</div>';
@ -1134,7 +1147,7 @@ if ($step == 2) {
'',
true,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[2][0] = __('Priority');
@ -1149,7 +1162,7 @@ if ($step == 2) {
false,
false,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
if (defined('METACONSOLE')) {
@ -1186,16 +1199,6 @@ if ($id) {
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 ($is_central_policies_on_node === false) {
if ($step >= LAST_STEP) {

View File

@ -44,7 +44,7 @@ $sec2 = safe_url_extraclean($sec2);
$sec = get_parameter_get('sec');
$sec = safe_url_extraclean($sec);
// Layers
// Layers.
$layer_ids = get_parameter('layer_ids', []);
$layers = get_parameter('layers', []);
$layer_list = [];
@ -84,9 +84,10 @@ switch ($action) {
$map_default_latitude = get_parameter('map_default_latitude');
$map_default_altitude = get_parameter('map_default_altitude');
$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'));
$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) {
@ -99,14 +100,14 @@ switch ($action) {
$map_connection_default = get_parameter('map_connection_default');
$map_connection_list = [];
foreach ($map_connection_list_temp as $idMapConnection) {
foreach ($listConnectionTemp as $idMapConnection) {
$default = 0;
if ($map_connection_default == $idMapConnection) {
if ($map_connection_default == $idMapConnection['id_tmap_connection']) {
$default = 1;
}
$map_connection_list[] = [
'id_conection' => $idMapConnection,
'id_conection' => $idMapConnection['id_tmap_connection'],
'default' => $default,
];
}
@ -124,7 +125,7 @@ switch ($action) {
$map_levels_zoom
);
if (empty($invalidFields) && get_parameter('map_connection_list') != '') {
if (empty($invalidFields)) {
$idMap = gis_save_map(
$map_name,
$map_initial_longitude,
@ -139,8 +140,13 @@ switch ($action) {
$map_connection_list,
$layer_list
);
$mapCreatedOk = true;
$next_action = 'update_saved';
if ($idMap) {
$mapCreatedOk = true;
$next_action = 'update_saved';
} else {
$next_action = 'save_new';
$mapCreatedOk = false;
}
} else {
$next_action = 'save_new';
$mapCreatedOk = false;
@ -168,7 +174,7 @@ switch ($action) {
$map_group_id = '';
$map_connection_list = [];
$layer_list = [];
$map_levels_zoom = 0;
$map_levels_zoom = 16;
break;
case 'edit_map':
@ -188,9 +194,12 @@ switch ($action) {
$map_default_latitude = get_parameter('map_default_latitude');
$map_default_altitude = get_parameter('map_default_altitude');
$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'));
$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) {
$cleanValue = trim($value);
if ($cleanValue == '') {
@ -201,14 +210,14 @@ switch ($action) {
$map_connection_default = get_parameter('map_connection_default');
$map_connection_list = [];
foreach ($map_connection_list_temp as $idMapConnection) {
foreach ($listConnectionTemp as $idMapConnection) {
$default = 0;
if ($map_connection_default == $idMapConnection) {
if ($map_connection_default == $idMapConnection['id_tmap_connection']) {
$default = 1;
}
$map_connection_list[] = [
'id_conection' => $idMapConnection,
'id_conection' => $idMapConnection['id_tmap_connection'],
'default' => $default,
];
}
@ -226,7 +235,7 @@ switch ($action) {
$map_levels_zoom
);
if (empty($invalidFields) && get_parameter('map_connection_list') != '') {
if (empty($invalidFields)) {
// TODO
gis_update_map(
$idMap,
@ -263,7 +272,7 @@ switch ($action) {
$url = 'index.php?sec='.$sec.'&sec2='.$sec2.'&map_id='.$idMap.'&action='.$next_action;
$buttons['gis_maps_list'] = [
'active' => true,
'active' => false,
'text' => '<a href="index.php?sec=godgismaps&sec2=operation/gis_maps/gis_map">'.html_print_image(
'images/list.png',
true,
@ -275,7 +284,7 @@ $buttons['gis_maps_list'] = [
];
if ($idMap) {
$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(
'images/op_gis.png',
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'>
<tr>
<td >
".html_print_select($listConnection, 'map_connection', '', '', '', '0', true)."
".html_print_select($listConnection, 'map_connection_list', '', '', '', '0', true)."
</td>
<td >
<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][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][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['value'] = '';
$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);
@ -585,7 +601,7 @@ $table->data[1][1] .= '</td>
</td>
</tr>';
// Group items
// Group items.
$group_select = html_print_select_groups($config['id_user'], 'AR', false, 'layer_group_id', '', '', '', 0, true);
$params = [];
$params['return'] = true;
@ -597,8 +613,10 @@ $params['input_name'] = 'agent_alias_for_data';
$params['value'] = '';
$params['javascript_function_action_after_select'] = 'toggleAddGroupBtn';
$params['selectbox_group'] = 'layer_group_id';
// Filter by group
$params['disabled_javascript_on_blur_function'] = true;
$params['javascript_is_function_select'] = true;
// Filter by group.
$params['disabled_javascript_on_blur_function'] = false;
$agent_for_group_input = ui_print_agent_autocomplete_input($params);
$add_group_btn = html_print_button(__('Add'), 'add_group', true, '', 'class="sub add"', true);

View File

@ -1,16 +1,32 @@
<?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
// ==================================================
// 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.
global $config;
check_login();
@ -27,7 +43,7 @@ require_once $config['homedir'].'/include/functions_groups.php';
require_once $config['homedir'].'/include/functions_users.php';
enterprise_include_once('meta/include/functions_agents_meta.php');
// Init vars
// Default values.
$icon = '';
$name = '';
$id_parent = 0;
@ -39,6 +55,7 @@ $skin = 0;
$contact = '';
$other = '';
$description = '';
$max_agents = 0;
$create_group = (bool) get_parameter('create_group');
$id_group = (int) get_parameter('id_group');
@ -62,6 +79,7 @@ if ($id_group) {
$description = $group['description'];
$contact = $group['contact'];
$other = $group['other'];
$max_agents = $group['max_agents'];
} else {
ui_print_error_message(__('There was a problem loading group'));
echo '</table>';
@ -149,12 +167,12 @@ if ($id_group) {
$table->data[2][1] .= html_print_select_groups(
false,
'AR',
true,
false,
'id_parent',
$id_parent,
'',
'',
'',
__('None'),
-1,
true,
false,
true,
@ -174,7 +192,9 @@ if ($id_group) {
'name' => 'id_parent',
'selected' => $id_parent,
'return' => true,
'returnAllGroup' => true,
'returnAllGroup' => false,
'nothing' => __('None'),
'nothing_value' => -1,
]
);
$table->data[2][1] .= '</div>';
@ -182,7 +202,7 @@ if ($id_group) {
if ($acl_parent) {
$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>';
}
@ -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);
$i++;
$isFunctionSkins = enterprise_include_once('include/functions_skins.php');
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK && !defined('METACONSOLE')) {
$table->data[9][0] = __('Skin');
$table->data[9][1] = skins_print_select($config['id_user'], 'skin', $skin, '', __('None'), 0, true);
}
// $isFunctionSkins = enterprise_include_once('include/functions_skins.php');
// if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK && !defined('METACONSOLE')) {
// $table->data[10][0] = __('Skin');
// $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')) {
$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.' >';
html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_button(__('Back'), 'button_back', false, '', 'class="sub cancel"');
if ($id_group) {
html_print_input_hidden('update_group', 1);
html_print_input_hidden('id_group', $id_group);
@ -330,5 +354,8 @@ function parent_changed () {
$(document).ready (function () {
$('#icon').change (icon_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>

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_users.php';
if (is_metaconsole()) {
if (is_metaconsole() === true) {
enterprise_include_once('include/functions_metaconsole.php');
enterprise_include_once('meta/include/functions_agents_meta.php');
enterprise_hook('open_meta_frame');
}
if (is_ajax()) {
if (! check_acl($config['id_user'], 0, 'AR')) {
if (is_ajax() === true) {
if ((bool) check_acl($config['id_user'], 0, 'AR') === false) {
db_pandora_audit('ACL Violation', 'Trying to access Group Management');
include 'general/noaccess.php';
return;
@ -56,13 +56,13 @@ if (is_ajax()) {
$get_group_agents = (bool) get_parameter('get_group_agents');
$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');
if ($id_group == 0) {
if ($id_group === 0 || $id_group === -1) {
$group = [
'id_grupo' => 0,
'nombre' => 'All',
'nombre' => 'None',
'icon' => 'world',
'parent' => 0,
'disabled' => 0,
@ -72,7 +72,7 @@ if (is_ajax()) {
return;
}
if (! check_acl($config['id_user'], $id_group, 'AR')) {
if ((bool) check_acl($config['id_user'], $id_group, 'AR') === false) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
@ -87,7 +87,7 @@ if (is_ajax()) {
return;
}
if ($get_group_agents) {
if ($get_group_agents === true) {
ob_clean();
$id_group = (int) get_parameter('id_group');
$disabled = (int) get_parameter('disabled', 0);
@ -108,10 +108,13 @@ if (is_ajax()) {
// (by default and for compatibility show void agents).
$show_void_agents = (int) get_parameter('show_void_agents', 1);
$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);
if (! check_acl($config['id_user'], $id_group, 'AR')) {
if ((bool) check_acl($config['id_user'], $id_group, 'AR') === false) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
@ -120,12 +123,15 @@ if (is_ajax()) {
return;
}
if (https_is_running()) {
if (https_is_running() === true) {
header('Content-type: application/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) {
@ -142,7 +148,6 @@ if (is_ajax()) {
$filter['status'] = $status_agents;
}
// Juanma (22/05/2014) Fix: If remove void agents set.
$_sql_post = ' 1=1 ';
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\'';
@ -172,7 +177,9 @@ if (is_ajax()) {
$agents_aux = [];
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;
}
}
@ -197,7 +204,10 @@ if (is_ajax()) {
'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_disabled = db_get_value_filter(
'disabled',
@ -233,10 +243,14 @@ if (is_ajax()) {
return;
}
if ($get_is_disabled) {
if ($get_is_disabled === true) {
$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['id_agent'] = $index;
@ -251,15 +265,9 @@ if (is_ajax()) {
$tab = (string) get_parameter('tab', 'groups');
if ($tab != 'credbox' && ! check_acl(
$config['id_user'],
0,
'PM'
) && ! check_acl(
$config['id_user'],
0,
'AW'
)
if ($tab !== 'credbox'
&& (bool) check_acl($config['id_user'], 0, 'PM') === false
&& (bool) check_acl($config['id_user'], 0, 'AW') === false
) {
db_pandora_audit(
'ACL Violation',
@ -267,9 +275,9 @@ if ($tab != 'credbox' && ! check_acl(
);
include 'general/noaccess.php';
return;
} else if ($tab == 'credbox'
&& !check_acl($config['id_user'], 0, 'UM')
&& !check_acl($config['id_user'], 0, 'PM')
} else if ($tab === 'credbox'
&& (bool) check_acl($config['id_user'], 0, 'UM') === false
&& (bool) check_acl($config['id_user'], 0, 'PM') === false
) {
db_pandora_audit(
'ACL Violation',
@ -339,7 +347,7 @@ switch ($tab) {
}
// Header.
if (defined('METACONSOLE')) {
if (is_metaconsole() === true) {
agents_meta_print_header();
echo '<div class="notify">';
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);
// 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');
$icon = (string) get_parameter('icon');
$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');
$contact = (string) get_parameter('contact');
$other = (string) get_parameter('other');
$max_agents = (int) get_parameter('max_agents', 0);
$check = db_get_value('nombre', 'tgrupo', 'nombre', $name);
$propagate = (bool) get_parameter('propagate');
@ -403,6 +412,7 @@ if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) {
'propagate' => $propagate,
'other' => $other,
'password' => io_safe_input($group_pass),
'max_agents' => $max_agents,
];
$result = db_process_sql_insert('tgrupo', $values);
@ -436,6 +446,7 @@ if ($update_group) {
$description = (string) get_parameter('description');
$contact = (string) get_parameter('contact');
$other = (string) get_parameter('other');
$max_agents = (int) get_parameter('max_agents', 0);
$aviable_name = true;
if (preg_match('/script/i', $name)) {
@ -460,7 +471,7 @@ if ($update_group) {
$values = [
'nombre' => $name,
'icon' => empty($icon) ? '' : substr($icon, 0, -4),
'parent' => $id_parent,
'parent' => $id_parent == -1 ? 0 : $id_parent,
'disabled' => !$alerts_enabled,
'custom_id' => $custom_id,
'id_skin' => $skin,
@ -469,6 +480,7 @@ if ($update_group) {
'propagate' => $propagate,
'other' => $other,
'password' => io_safe_input($group_pass),
'max_agents' => $max_agents,
];
$result = db_process_sql_update(
@ -492,7 +504,7 @@ if ($update_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');
$usedGroup = groups_check_used($id_group);
@ -508,28 +520,42 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
$success_nodes = [];
$error_nodes = [];
// Check if the group can be deleted or not.
foreach ($servers as $server) {
if (metaconsole_connect($server) == NOERR) {
$result_exist_group = db_get_row_filter('tgrupo', ['nombre' => $group_name, 'id_grupo' => $id_group]);
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++;
if (isset($servers) === true
&& is_array($servers) === true
) {
foreach ($servers as $server) {
if (metaconsole_connect($server) == NOERR) {
$result_exist_group = db_get_row_filter(
'tgrupo',
[
'nombre' => $group_name,
'id_grupo' => $id_group,
]
);
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) {
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;
} else {
@ -540,60 +566,80 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
$success_deleting = [];
$error_connecting_node = [];
// Delete the group in the nodes.
foreach ($servers as $server) {
if (metaconsole_connect($server) == NOERR) {
$group = db_get_row_filter(
'tgrupo',
['id_grupo' => $id_group]
);
if (isset($servers) === true
&& is_array($servers) === true
) {
foreach ($servers as $server) {
if (metaconsole_connect($server) == NOERR) {
$group = db_get_row_filter(
'tgrupo',
['id_grupo' => $id_group]
);
db_process_sql_update(
'tgrupo',
['parent' => $group['parent']],
['parent' => $id_group]
);
db_process_sql_update(
'tgrupo',
['parent' => $group['parent']],
['parent' => $id_group]
);
db_process_sql_delete(
'tgroup_stat',
['id_group' => $id_group]
);
db_process_sql_delete(
'tgroup_stat',
['id_group' => $id_group]
);
$result = db_process_sql_delete(
'tgrupo',
['id_grupo' => $id_group]
);
$result = db_process_sql_delete(
'tgrupo',
['id_grupo' => $id_group]
);
if ($result === false) {
$error_deleting[] .= $server['server_name'];
$error_deleting_counter++;
if ($result === false) {
$error_deleting[] .= $server['server_name'];
$error_deleting_counter++;
} else {
$success_deleting[] .= $server['server_name'];
$success_deleting_counter++;
}
} else {
$success_deleting[] .= $server['server_name'];
$success_deleting_counter++;
$error_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) {
$errors_meta = true;
if (!empty($error_connecting_node)) {
ui_print_error_message(__('Error connecting to %s', implode(', ', $error_connecting_node).'. The group has not been deleted in the metaconsole.'));
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.'
)
);
}
if (!empty($error_deleting)) {
if (empty($error_deleting) === false) {
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) {
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'])) {
ui_print_success_message(__('Group successfully deleted'));
} else {
ui_print_error_message(__('There was a problem deleting group'));
ui_print_error_message(
__('There was a problem deleting group')
);
}
}
} else {
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', '');
$block_size = $config['block_size'];
if (!empty($search)) {
if (empty($search) === false) {
$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');
$groups_acl = implode(',', $user_groups_ACL);
if (empty($groups_acl)) {
$groups_acl = implode('","', $user_groups_acl);
if (empty($groups_acl) === true) {
return ui_print_info_message(
[
'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 .= "<table class='databox filters bolder' width='100%'>";
$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 .= "<input name='find' type='submit' class='sub search' value='".__('Search')."'>";
$form .= '<td></tr>';
@ -713,7 +771,7 @@ if ($tab == 'tree') {
$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.
$groups_sql_count = sprintf(
'SELECT count(*)
@ -799,7 +857,7 @@ if ($tab == 'tree') {
]
).'</a>';
if (is_metaconsole()) {
if (is_metaconsole() === true) {
$confirm_message = __('Are you sure? This group will also be deleted in all the nodes.');
} else {
$confirm_message = __('Are you sure?');
@ -841,11 +899,16 @@ if ($tab == 'tree') {
'pagination-bottom'
);
} 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 '<div class="action-buttons w100p">';
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>
<?php } else { ?>
<script type="text/javascript" src="../../include/javascript/fixed-bottom-box.js"></script>
@ -900,7 +963,6 @@ $tab = 'group_edition';
treeController.init({
recipient: $("div#tree-controller-recipient"),
//detailRecipient: $.fixedBottomBox({ width: 400, height: window.innerHeight * 0.9 }),
page: parameters['page'],
emptyMessage: "<?php echo __('No data found'); ?>",
foundMessage: "<?php echo __('Found groups'); ?>",

View File

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

View File

@ -46,7 +46,7 @@ if (defined('METACONSOLE')) {
$sec = 'gmodules';
}
if (is_management_allowed() === true) {
if (is_management_allowed() === true || is_metaconsole()) {
$create = (bool) get_parameter('create');
$update = (bool) get_parameter('update');
$delete = (bool) get_parameter('delete');
@ -125,7 +125,7 @@ if ($delete) {
['id_sg' => $id]
);
if (($result !== false) and ($result1 !== false)) {
if (($result !== false) && ($result1 !== false)) {
$result = true;
} else {
$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';
return;
}
@ -230,7 +230,7 @@ $table->class = 'info_table';
$table->head = [];
$table->head['checkbox'] = html_print_checkbox('all_delete', 0, false, true, false);
$table->head[0] = __('Name');
if (is_management_allowed() === true) {
if (is_management_allowed() === true || is_metaconsole()) {
$table->head[1] = __('Action');
}
@ -262,15 +262,15 @@ foreach ($groups as $group) {
}
$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;'
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);
}
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.'));
}
@ -278,7 +278,7 @@ if (isset($data)) {
echo "<form method='post' action='index.php?sec=".$sec."&sec2=godmode/modules/manage_nc_groups'>";
html_print_input_hidden('multiple_delete', 1);
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'>";
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
echo '</div>';
@ -289,7 +289,7 @@ if (isset($data)) {
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 '<div class="float-right">';
html_print_input_hidden('new', 1);

View File

@ -568,71 +568,19 @@ if ($id || $new_component
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_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->width = '100%';

View File

@ -357,7 +357,7 @@ if (defined('METACONSOLE')) {
html_print_table($table);
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);
if ($id) {
html_print_input_hidden('update_component', 1);
@ -376,6 +376,11 @@ ui_require_javascript_file('pandora_modules');
?>
<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 () {
// type 1-4 - Generic_xxxxxx
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) {
// Number of inserts
// Number of inserts.
$ninsert = (int) 0;
// Return from DB the source layout
// Return from DB the source layout.
$layout_src = db_get_all_rows_filter(
'tlayout',
['id' => $id_layout]
);
// Name of dst
// Name of dst.
$name_dst = get_parameter(
'name_dst',
$layout_src[0]['name'].' copy'
);
// Create the new Console
// Create the new Console.
$idGroup = $layout_src[0]['id_group'];
$background = $layout_src[0]['background'];
$height = $layout_src[0]['height'];
@ -217,12 +217,15 @@ if ($delete_layout || $copy_layout) {
$visualConsoleName = $name_dst;
$values = [
'name' => $visualConsoleName,
'id_group' => $idGroup,
'background' => $background,
'height' => $height,
'width' => $width,
'name' => $visualConsoleName,
'id_group' => $idGroup,
'background' => $background,
'height' => $height,
'width' => $width,
'background_color' => $layout_src[0]['background_color'],
'is_favourite' => $layout_src[0]['is_favourite'],
];
$result = db_process_sql_insert('tlayout', $values);
$idNewVisualConsole = $result;
@ -517,7 +520,7 @@ if ($maps) {
if (!is_metaconsole()) {
echo '<div class="action-buttons w100p right_align">';
} 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['input_id_server_id'] = 'hidden-id_server';
$params['disabled_javascript_on_blur_function'] = true;
$params['javascript_is_function_select'] = true;
}
ui_print_agent_autocomplete_input($params);

View File

@ -742,7 +742,7 @@ switch ($action) {
}
$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;
} else {
$return_all_group = false;

View File

@ -85,7 +85,7 @@ visual_map_editor_print_item_palette($visualConsole['id'], $background);
if (!defined('METACONSOLE')) {
echo '<div id="frame_view" class="frame_view_meta">';
} 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;

View File

@ -795,7 +795,7 @@ if ($config['legacy_vc']) {
$buttons['view'] = [
'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) {

View File

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

View File

@ -44,6 +44,9 @@ if (! check_acl($config['id_user'], 0, 'PM')
return;
}
// Load needed resources.
ui_require_css_file('setup.multicolumn');
$update_config = get_parameter('update_config', 0);
if ($update_config == 1 && $config['history_db_enabled'] == 1) {
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 '<fieldset>';
echo '<fieldset class="full-column">';
echo '<legend>'.__('Database maintenance status').' '.ui_print_help_icon('database_maintenance_status_tab', true).'</legend>';
html_print_table($table_status);
echo '</fieldset>';

View File

@ -834,7 +834,7 @@ echo '</form>';
// AJAX call to check API connection.
$.ajax({
type: "GET",
type: "POST",
url: url,
dataType: "json",
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) {
if (metaconsole_connect($server) === NOERR) {
$counter += tags_get_local_modules_count($id_tag);
metaconsole_restore_db();
}
return $counter;
@ -83,6 +84,7 @@ if (is_ajax()) {
function ($counter, $server) use ($id_tag) {
if (metaconsole_connect($server) === NOERR) {
$counter += tags_get_policy_modules_count($id_tag);
metaconsole_restore_db();
}
return $counter;
@ -272,6 +274,7 @@ if (!empty($result)) {
function ($counter, $server) use ($tag_id) {
if (metaconsole_connect($server) === NOERR) {
$counter += tags_get_modules_count($tag_id);
metaconsole_restore_db();
}
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 .= '</div>';
$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(
$layouts_aux,
'visual_console',
@ -1133,6 +1136,8 @@ $home_screen .= html_print_select(
'',
true
);
$home_screen .= '</div>';
$home_screen .= html_print_input_text(
'data_section',
$user_info['data_section'],
@ -1664,46 +1669,64 @@ function show_data_section () {
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "inline-grid");
break;
case <?php echo "'".'Visual console'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "");
$("#show_vc").css("display", "inline-grid");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Event list'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Group view'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Tactical view'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Alert detail'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'External link'."'"; ?>:
$("#text-data_section").css("display", "");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Other'."'"; ?>:
$("#text-data_section").css("display", "");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Default'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
}
}

View File

@ -260,21 +260,21 @@ if (isset($_GET['user_del'])) {
if (defined('METACONSOLE') && isset($_GET['delete_all'])) {
$servers = metaconsole_get_servers();
foreach ($servers as $server) {
// Connect to the remote console
metaconsole_connect($server);
// Connect to the remote console.
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
$result = delete_user($id_user);
if ($result) {
db_pandora_audit(
'User management',
__('Deleted user %s from metaconsole', io_safe_input($id_user))
);
// Restore the db connection.
metaconsole_restore_db();
}
// Restore the db connection
metaconsole_restore_db();
// Log to the metaconsole too
if ($result) {
db_pandora_audit(
@ -440,17 +440,21 @@ if (!defined('METACONSOLE')) {
$table->valign[6] = 'top';
}
$group_um = users_get_groups_UM($config['id_user']);
$info1 = [];
$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);
} else {
foreach ($group_um as $group => $value) {
$info1 = array_merge($info1, users_get_users_by_group($group, $value));
$group_um = users_get_groups_UM($config['id_user']);
// 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">';
foreach ($user_profiles as $row) {
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] .= ' / </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] .= '</div>';

View File

@ -713,6 +713,19 @@ class DiscoveryTaskList extends HTML
$data[6] .= __('Discovery.Cloud.Aws.RDS');
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:
// Discovery Applications MySQL.
$data[6] = html_print_image(
@ -868,6 +881,7 @@ class DiscoveryTaskList extends HTML
&& $task['type'] != DISCOVERY_APP_DB2
&& $task['type'] != DISCOVERY_APP_SAP
&& $task['type'] != DISCOVERY_CLOUD_AWS_RDS
&& $task['type'] != DISCOVERY_CLOUD_AWS_S3
) {
if (check_acl($config['id_user'], 0, 'MR')) {
$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)
{
if ($script !== false) {
if ($script !== false
|| (int) $task['type'] === DISCOVERY_HOSTDEVICES_CUSTOM
) {
switch ($script['type']) {
case DISCOVERY_SCRIPT_APP_VMWARE:
return 'wiz=app&mode=vmware&page=0';
@ -1044,6 +1060,9 @@ class DiscoveryTaskList extends HTML
case DISCOVERY_CLOUD_AZURE_COMPUTE:
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:
return 'wiz=cloud';
}
@ -1491,6 +1510,9 @@ class DiscoveryTaskList extends HTML
$simple_data[] = $tmp;
if (is_array($data['modules'])) {
// Alphabetically sort.
ksort($data['modules'], (SORT_STRING | SORT_FLAG_CASE));
$simple_data = array_merge(
$simple_data,
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['user_comment'] = get_parameter('user_comment');
$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(
'id_filter',
'tevent_filter',
@ -305,6 +310,10 @@ if ($update_event_filter) {
$values['user_comment'] = get_parameter('user_comment');
$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"]') {
$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']]));
}
@ -402,6 +418,8 @@ if ($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->id = 'load_filter_form';
$table->width = '100%';
@ -441,13 +459,15 @@ if ($load_filter_modal) {
__('Load filter'),
'load_filter',
false,
'class="sub upd" onclick="load_form_filter();"',
'class="sub upd"',
true
);
$data[1] .= html_print_input_hidden('load_filter', 1, true);
$table->data[] = $data;
$table->rowclass[] = '';
html_print_table($table);
echo '</form>';
echo '</div>';
?>
<script type="text/javascript">
@ -460,7 +480,8 @@ function show_filter() {
width: 450
});
}
//aki
function load_form_filter() {
jQuery.post (
"<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
@ -471,7 +492,6 @@ function load_form_filter() {
},
function (data) {
jQuery.each (data, function (i, val) {
console.log(val);
if (i == 'id_name')
$("#hidden-id_name").val(val);
if (i == 'id_group'){
@ -517,6 +537,10 @@ function load_form_filter() {
$("#text-user_comment").val(val);
if (i == 'id_source_event')
$("#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')
$("#text-date_from").val(val);
if(i == 'date_to')
@ -747,7 +771,8 @@ function save_new_filter() {
"source": $("#text-source").val(),
"id_extra": $("#text-id_extra").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) {
$("#info_box").hide();
@ -817,7 +842,8 @@ function save_update_filter() {
"source": $("#text-source").val(),
"id_extra": $("#text-id_extra").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) {
@ -1381,6 +1407,12 @@ if ($get_extended_event) {
'EW',
$event['clean_tags'],
$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(
@ -1444,6 +1476,12 @@ if ($get_extended_event) {
'EW',
$event['clean_tags'],
$childrens_ids
)) || (tags_checks_event_acl(
$config['id_user'],
$event['id_grupo'],
'ER',
$event['clean_tags'],
$childrens_ids
)))
) {
$responses = events_page_responses($event);
@ -1465,15 +1503,21 @@ if ($get_extended_event) {
$related = events_page_related($event, $server);
}
$connected = true;
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) {
if ($meta && $connected === true) {
metaconsole_restore_db();
}
@ -1865,11 +1909,12 @@ if ($get_table_response_command) {
}
if ($get_events_fired) {
global $config;
$id = get_parameter('id_row');
$idGroup = get_parameter('id_group');
$agents = get_parameter('agents', null);
$query = ' AND id_evento > '.$id;
$query = ' AND id_evento >= '.$id;
$type = [];
$alert = get_parameter('alert_fired');
@ -1889,7 +1934,10 @@ if ($get_events_fired) {
if ($critical == 'true') {
$resultCritical = alerts_get_event_status_group(
$idGroup,
'going_up_critical',
[
'going_up_critical',
'going_down_critical',
],
$query,
$agents
);
@ -1899,7 +1947,10 @@ if ($get_events_fired) {
if ($warning == 'true') {
$resultWarning = alerts_get_event_status_group(
$idGroup,
'going_up_warning',
[
'going_up_warning',
'going_down_warning',
],
$query,
$agents
);

View File

@ -1,17 +1,32 @@
<?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.
// Only accesible by ajax
if (is_ajax()) {
/**
* Tree view.
*
* @category Tree
* @package Pandora FMS
* @subpackage Community
* @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.
* ============================================================================
*/
if (is_ajax() === true) {
global $config;
// Login check.
@ -34,7 +49,7 @@ if (is_ajax()) {
$getGroupStatus = (bool) get_parameter('getGroupStatus', 0);
$getDetail = (bool) get_parameter('getDetail');
if ($getChildren) {
if ($getChildren === true) {
$type = get_parameter('type', 'group');
$rootType = get_parameter('rootType', '');
$id = get_parameter('id', -1);
@ -55,47 +70,111 @@ if (is_ajax()) {
$agent_a = check_acl($config['id_user'], 0, 'AR');
$agent_w = check_acl($config['id_user'], 0, 'AW');
$access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
$switch_type = !empty($rootType) ? $rootType : $type;
$access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR');
$switch_type = (empty($rootType) === false) ? $rootType : $type;
switch ($switch_type) {
case 'os':
$tree = new TreeOS($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
$tree = new TreeOS(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break;
case 'module_group':
$tree = new TreeModuleGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
$tree = new TreeModuleGroup(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break;
case 'module':
$tree = new TreeModule($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
$tree = new TreeModule(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break;
case 'tag':
$tree = new TreeTag($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
$tree = new TreeTag(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break;
case 'group':
if (is_metaconsole()) {
if (!class_exists('TreeGroupMeta')) {
if (is_metaconsole() === true) {
if (class_exists('TreeGroupMeta') === false) {
break;
}
$tree = new TreeGroupMeta($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
$tree = new TreeGroupMeta(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
} else {
$tree = new TreeGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
$tree = new TreeGroup(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
}
break;
case 'policies':
if (!class_exists('TreePolicies')) {
if (class_exists('TreePolicies') === false) {
break;
}
$tree = new TreePolicies($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
$tree = new TreePolicies(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break;
case 'group_edition':
$tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
$tree = new TreeGroupEdition(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
break;
case 'services':
@ -112,7 +191,7 @@ if (is_ajax()) {
break;
default:
// FIXME. No error handler
// No error handler.
return;
}
@ -123,14 +202,14 @@ if (is_ajax()) {
return;
}
if ($getDetail) {
if ($getDetail === true) {
include_once $config['homedir'].'/include/functions_treeview.php';
$id = (int) get_parameter('id');
$type = (string) get_parameter('type');
$server = [];
if (is_metaconsole()) {
if (is_metaconsole() === true) {
$server_id = (int) get_parameter('serverID');
$server = metaconsole_get_servers($server_id);
}
@ -142,7 +221,7 @@ if (is_ajax()) {
echo '</style>';
echo '<div class="left_align backgrund_primary_important">';
if (!empty($id) && !empty($type)) {
if (empty($id) === false && empty($type) === false) {
switch ($type) {
case 'agent':
treeview_printTable($id, $server, true);
@ -157,7 +236,7 @@ if (is_ajax()) {
break;
default:
// Nothing
// Nothing.
break;
}
}

View File

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

View File

@ -2085,7 +2085,13 @@ class AgentWizard extends HTML
$tmp->ip_target($this->targetIp);
$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(
sprintf(
'SELECT macros FROM tplugin WHERE id=%d',
@ -2115,10 +2121,6 @@ class AgentWizard extends HTML
$tmp->id_plugin($infoMacros['server_plugin']);
$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"'
);
// 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.
$data[6] .= html_print_input_hidden(
'module-query_class-'.$uniqueId,

View File

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

View File

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

View File

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

View File

@ -1727,7 +1727,10 @@ class NetworkMap
$item['image_height'] = 0;
if (empty($node['style']['image']) === false) {
$item['image_url'] = ui_get_full_url(
$node['style']['image']
$node['style']['image'],
false,
false,
false
);
$image_size = getimagesize(
$config['homedir'].'/'.$node['style']['image']
@ -2837,13 +2840,7 @@ class NetworkMap
*/
public function loadSimpleInterface()
{
$output = '<div id="open_version_dialog" class="invisible">';
$output .= __(
'In the Open version of %s can not be edited nodes or map',
get_product_name()
);
$output .= '</div>';
$output = '';
$output .= '<div id="dialog_node_edit" class="invisible" title="';
$output .= __('Edit node').'">';
$output .= '<div class="left w100p">';
@ -2893,6 +2890,12 @@ class NetworkMap
$id = 'dialog_node_edit';
if (!enterprise_installed()) {
$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="';
@ -3391,7 +3394,7 @@ class NetworkMap
&& isset($this->useTooltipster)
&& $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'
).'" charset="utf-8"></script>';
$output .= '<script type="text/javascript" src="'.ui_get_full_url(
@ -3443,13 +3446,35 @@ class NetworkMap
$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) {
// 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.
$output .= '<div id="networkconsole_'.$networkmap['id'].'"';

View File

@ -1,15 +1,30 @@
<?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.
/**
* Tree view.
*
* @category Tree
* @package Pandora FMS
* @subpackage Community
* @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.
* ============================================================================
*/
class Tree
{

View File

@ -1,32 +1,86 @@
<?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.
/**
* Tree view.
*
* @category Tree
* @package Pandora FMS
* @subpackage Community
* @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.
* ============================================================================
*/
global $config;
require_once $config['homedir'].'/include/class/Tree.class.php';
/**
* Tree group class.
*/
class TreeGroup extends Tree
{
/**
* Propagate ACL.
*
* @var boolean
*/
protected $propagateCounters = true;
/**
* Display all groups.
*
* @var boolean
*/
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;
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
parent::__construct(
$type,
$rootType,
$id,
$rootID,
$serverID,
$childrenMethod,
$access
);
$this->L1fieldName = 'id_group';
$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)
{
$this->propagateCounters = (bool) $value;
}
/**
* Setter all groups.
*
* @param boolean $value True or ffalse.
*
* @return void
*/
public function setDisplayAllGroups($value)
{
$this->displayAllGroups = (bool) $value;
}
/**
* Get data.
*
* @return void
*/
protected function getData()
{
if ($this->id == -1) {
@ -66,22 +139,36 @@ class TreeGroup extends Tree
}
/**
* Filter search groups.
*
* @return string
*/
protected function getGroupSearchFilter()
{
return '';
}
/**
* First level tree.
*
* @return void
*/
protected function getFirstLevel()
{
$processed_items = $this->getProcessedGroups();
if (!empty($processed_items)) {
// Filter by group name. This should be done after rerieving the items cause we need the possible items descendants
if (!empty($this->filter['searchGroup'])) {
// Save the groups which intersect with the user groups
$groups = db_get_all_rows_filter('tgrupo', ['nombre' => '%'.$this->filter['searchGroup'].'%']);
if ($groups == false) {
if (empty($processed_items) === false) {
// Filter by group name. This should be done after rerieving
// the items cause we need the possible items descendants.
if (empty($this->filter['searchGroup']) === false) {
// Save the groups which intersect with the user groups.
$groups = db_get_all_rows_filter(
'tgrupo',
['nombre' => '%'.$this->filter['searchGroup'].'%']
);
if ($groups === false) {
$groups = [];
}
@ -90,7 +177,7 @@ class TreeGroup extends Tree
$groups,
function ($userGroups, $group) use ($userGroupsACL) {
$group_id = $group['id_grupo'];
if (isset($userGroupsACL[$group_id])) {
if (isset($userGroupsACL[$group_id]) === true) {
$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;
}
// groupID filter. To access the view from tactical views f.e.
if (!empty($this->filter['groupID'])) {
$result = self::extractItemWithID($processed_items, $this->filter['groupID'], 'group', $this->strictACL);
// GroupID filter. To access the view from tactical views f.e.
if (empty($this->filter['groupID']) === false) {
$result = self::extractItemWithID(
$processed_items,
$this->filter['groupID'],
'group',
$this->strictACL
);
$processed_items = ($result === false) ? [] : [$result];
}
@ -116,56 +211,64 @@ class TreeGroup extends Tree
}
/**
* Process group
*
* @return mixed
*/
protected function getProcessedGroups()
{
$processed_groups = [];
// Index and process the groups
// Index and process the groups.
$groups = $this->getGroupCounters();
// If user have not permissions in parent, set parent node to 0 (all)
// Avoid to do foreach for admins
if (!users_can_manage_group_all('AR')) {
// Avoid to do foreach for admins.
if (users_can_manage_group_all('AR') === false) {
foreach ($groups as $id => $group) {
if (!isset($this->userGroups[$groups[$id]['parent']])) {
if (isset($this->userGroups[$groups[$id]['parent']]) === false) {
$groups[$id]['parent'] = 0;
}
}
}
// Build the group hierarchy
// Build the group hierarchy.
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 exists
if (!isset($groups[$parent]['children'])) {
// Parent exists.
if (isset($groups[$parent]['children']) === false) {
$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];
// This group was introduced into a parent
// This group was introduced into a parent.
$groups[$id]['have_parent'] = true;
}
}
// Sort the children groups
// Sort the children groups.
foreach ($groups as $id => $group) {
if (isset($groups[$id]['children'])) {
if (isset($groups[$id]['children']) === true) {
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,
function ($group) {
return !$group['have_parent'];
}
);
// Propagate child counters to her parents
if ($this->propagateCounters) {
// Propagate child counters to her parents.
if ($this->propagateCounters === true) {
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);
} else {
$groups = $this->deleteEmptyGroupsNotPropagate($groups);

View File

@ -1,31 +1,81 @@
<?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.
/**
* Tree view.
*
* @category Tree
* @package Pandora FMS
* @subpackage Community
* @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.
* ============================================================================
*/
global $config;
require_once $config['homedir'].'/include/class/Tree.class.php';
/**
* Tree group edition.
*/
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;
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()
{
if ($this->id == -1) {
@ -34,46 +84,54 @@ class TreeGroupEdition extends TreeGroup
}
/**
* Get process group.
*
* @return mixed
*/
protected function getProcessedGroups()
{
$processed_groups = [];
// Index and process the groups
// Index and process the groups.
$groups = $this->getGroupCounters();
// If user have not permissions in parent, set parent node to 0 (all)
// Avoid to do foreach for admins
if (!users_can_manage_group_all('AR')) {
// Avoid to do foreach for admins.
if (users_can_manage_group_all('AR') === false) {
foreach ($groups as $id => $group) {
if (!isset($this->userGroups[$groups[$id]['parent']])) {
if (isset($this->userGroups[$groups[$id]['parent']]) === false) {
$groups[$id]['parent'] = 0;
}
}
}
// Build the group hierarchy
// Build the group hierarchy.
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 exists
if (!isset($groups[$parent]['children'])) {
// Parent exists.
if (isset($groups[$parent]['children']) === false) {
$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];
// This group was introduced into a parent
// This group was introduced into a parent.
$groups[$id]['have_parent'] = true;
}
}
// Sort the children groups
// Sort the children groups.
foreach ($groups as $id => $group) {
if (isset($groups[$id]['children'])) {
if (isset($groups[$id]['children']) === true) {
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,
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']);
return $groups;
}
/**
* Get group counters.
*
* @return mixed
*/
protected function getGroupCounters()
{
$messages = [
@ -93,10 +165,25 @@ class TreeGroupEdition extends TreeGroup
'cancel' => __('Cancel'),
'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
';
WHERE 1=1 %s',
$group_acl
);
$stats = db_get_all_rows_sql($sql);
$group_stats = [];
@ -107,7 +194,9 @@ class TreeGroupEdition extends TreeGroup
$group_stats[$group['gid']]['id'] = $group['gid'];
$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']]['edit'] = 1;
$group_stats[$group['gid']]['alerts'] = '';

View File

@ -20,8 +20,8 @@
/**
* Pandora build version and version
*/
$build_version = 'PC210329';
$pandora_version = 'v7.0NG.752';
$build_version = 'PC210505';
$pandora_version = 'v7.0NG.754';
// Do not overwrite default timezone set if defined.
$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_MICROSOFT_SQL_SERVER', 12);
define('DISCOVERY_CLOUD_GCP_COMPUTE_ENGINE', 13);
define('DISCOVERY_CLOUD_AWS_S3', 14);
// Force task build tmp results.
define('DISCOVERY_REVIEW', 0);

View File

@ -2252,12 +2252,16 @@ function check_login($output=true)
return true;
}
} 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';
if (isset($_SESSION['user'])) {
$user = $_SESSION['user'];
$user = User::getInstance();
$id_user = $user->getIdUser();
if (is_user($id_user)) {
$_SESSION['id_usuario'] = $id_user;
$config['id_user'] = $id_user;
return true;
}
}
@ -2853,7 +2857,11 @@ function can_user_access_node()
{
global $config;
$userinfo = get_user_info($config['id_user']);
static $userinfo;
if ($userinfo === null) {
$userinfo = get_user_info($config['id_user']);
}
if (is_metaconsole()) {
return $userinfo['is_admin'] == 1 ? 1 : $userinfo['metaconsole_access_node'];

View File

@ -1,27 +1,38 @@
<?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
* @subpackage Agents
* Agents Functions.
*
* @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_modules.php';
require_once $config['homedir'].'/include/functions_users.php';
use PandoraFMS\Enterprise\RCMDFile as RCMDFile;
use PandoraFMS\Event;
/**
@ -203,11 +214,13 @@ function agents_create_agent(
$values=false,
$alias_as_name=false
) {
if (empty($name)) {
global $config;
if (empty($name) === true) {
return false;
}
if (empty($id_group) && (int) $id_group != 0) {
if (empty($id_group) === true && (int) $id_group !== 0) {
return false;
}
@ -216,11 +229,11 @@ function agents_create_agent(
$interval = false;
}
if (empty($interval)) {
if (empty($interval) === true) {
return false;
}
if (! is_array($values)) {
if (is_array($values) === false) {
$values = [];
}
@ -229,17 +242,22 @@ function agents_create_agent(
$values['id_grupo'] = $id_group;
$values['intervalo'] = $interval;
if (!empty($ip_address)) {
if (empty($ip_address) === false) {
$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);
if ($id_agent === false) {
return false;
}
// Create address for this agent in taddress.
if (!empty($ip_address)) {
if (empty($ip_address) === false) {
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 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 $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
*/
@ -1096,7 +1115,8 @@ function agents_get_group_agents(
$serialized=false,
$separator='|',
$add_alert_bulk_op=false,
$force_serialized=false
$force_serialized=false,
$meta_fields=false
) {
global $config;
@ -1268,11 +1288,19 @@ function agents_get_group_agents(
if (is_metaconsole()) {
$table_name = 'tmetaconsole_agent ta LEFT JOIN tmetaconsole_agent_secondary_group tasg ON ta.id_agente = tasg.id_agent';
$fields = [
'ta.id_tagente AS id_agente',
'alias',
'ta.id_tmetaconsole_setup AS id_server',
];
if ($meta_fields === true) {
$fields = [
'id_agente',
'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 {
$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 $return Return (false) or dump to output (true).
* @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.
*/
@ -3261,7 +3290,8 @@ function select_modules_for_agent_group(
$id_agents,
$selection,
$return=true,
$index_by_name=false
$index_by_name=false,
$pure_return=false
) {
global $config;
$agents = (empty($id_agents)) ? [] : implode(',', $id_agents);
@ -3341,6 +3371,10 @@ function select_modules_for_agent_group(
return;
}
if ($pure_return === true) {
return $modules;
}
$modules_array = [];
foreach ($modules as $value) {
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
*
@ -3850,7 +3948,7 @@ function agents_get_last_status_change($id_agent)
*
* @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 = [];

View File

@ -173,13 +173,22 @@ function alerts_get_event_status_group($idGroup, $type='alert_fired', $query='AN
$idAgents = array_values($agents);
}
$result = db_get_all_rows_sql(
$sql = sprintf(
'SELECT id_evento
FROM tevento
WHERE estado = 0 AND id_agente IN (0,'.implode(',', $idAgents).') '.$typeWhere.$query.'
ORDER BY id_evento DESC LIMIT 1'
FROM tevento
WHERE estado = 0
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) {
return false;
}
@ -439,10 +448,11 @@ function alerts_delete_alert_action($id_alert_action)
* Clone an 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.
*/
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);
if (empty($id_alert_action)) {
@ -455,6 +465,10 @@ function alerts_clone_alert_action($id_alert_action)
return false;
}
if ($id_group != '') {
$action['id_group'] = $id_group;
}
unset($action['id']);
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.
*
* @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.
*/
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);
@ -1132,6 +1147,10 @@ function alerts_duplicate_alert_template($id_alert_template)
return false;
}
if ($id_group != '') {
$template['id_group'] = $id_group;
}
$name = io_safe_input(__('Copy of').' ').$template['name'];
$type = $template['type'];
@ -2125,8 +2144,6 @@ function get_group_alerts(
$disabled = $filter;
}
$filter .= ' AND talert_template_modules.disabled = 0 ';
switch ($disabled) {
case 'notfired':
$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';
break;
default:
case 'all':
$filter .= '';
break;
default:
$filter .= ' AND talert_template_modules.disabled = 0 ';
break;
}
// WHEN SELECT ALL TAGS TO FILTER ALERTS
@ -2186,8 +2207,8 @@ function get_group_alerts(
WHERE 1 = 0';
} else {
$subQuery = 'SELECT id_agente_modulo
FROM tagente_modulo
WHERE delete_pending = 0
FROM tagente_modulo tam
WHERE delete_pending = 0 AND tam.disabled = 0
AND id_agente IN (SELECT id_agente
FROM tagente ta
LEFT JOIN tagent_secondary_group tasg

View File

@ -43,11 +43,12 @@ use PandoraFMS\Enterprise\Cluster;
/**
* Parse the "other" parameter.
*
* @param string $other
* @param mixed $otherType
* @param string $other
* @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
*/
function parseOtherParameter($other, $otherType)
function parseOtherParameter($other, $otherType, $rawDecode)
{
switch ($otherType) {
case 'url_encode':
@ -65,12 +66,12 @@ function parseOtherParameter($other, $otherType)
'data' => explode($separator, $other),
];
foreach ($returnVar['data'] as $index => $element) {
$returnVar['data'][$index] = urldecode($element);
$returnVar['data'][$index] = $rawDecode ? rawurldecode($element) : urldecode($element);
}
} else {
$returnVar = [
'type' => 'string',
'data' => urldecode($other),
'data' => $rawDecode ? rawurldecode($other) : urldecode($other),
];
}
break;
@ -375,6 +376,103 @@ function api_get_test_event_replication_db()
// -------------------------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)
{
$returnAllGroup = true;
@ -1381,6 +1479,12 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3)
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
if ($idParent != 0) {
$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).
if ($alias == '' && $alias_as_name === 0) {
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.');
} else if (db_get_value_sql('SELECT id_grupo FROM tgrupo WHERE id_grupo = '.$grupo) === false) {
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) {
returnError('The OS does not exist.');
} 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.
*
@ -8175,6 +8411,7 @@ function api_set_create_group($id, $thrash1, $other, $thrash3)
$values['custom_id'] = $safe_other_data[5];
$values['contact'] = $safe_other_data[6];
$values['other'] = $safe_other_data[7];
$values['max_agents'] = $safe_other_data[8];
$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];
$custom_id = $other['data'][6];
$contact = $other['data'][7];
$other = $other['data'][8];
$otherData = $other['data'][8];
$maxAgents = $other['data'][9];
$return = db_process_sql_update(
'tgrupo',
@ -8267,7 +8505,8 @@ function api_set_update_group($id_group, $thrash2, $other, $thrash3)
'disabled' => $disabled,
'custom_id' => $custom_id,
'contact' => $contact,
'other' => $other,
'other' => $otherData,
'max_agents' => $maxAgents,
],
['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=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)
{
global $config;

View File

@ -200,8 +200,20 @@ function config_update_config()
$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[] .= __(
"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'))) {
@ -1645,7 +1657,11 @@ function config_update_config()
$integria_hostname = (string) get_parameter('integria_hostname', $config['integria_hostname']);
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)) {
@ -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')) {
$config['metaconsole_access'] = $userinfo['metaconsole_access'];
}

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