Merge branch 'develop' of brutus.artica.es:artica/pandorafms into develop

This commit is contained in:
alejandro.campos@artica.es 2021-08-05 08:10:24 +02:00
commit cb4416ca3f
189 changed files with 6206 additions and 2698 deletions

View File

@ -68,7 +68,7 @@ check_root_permissions () {
install_autodiscover () { install_autodiscover () {
local arch=$1 local arch=$1
wget https://pandorafms.com/library/wp-content/uploads/2020/04/autodiscover-linux.zip wget http://firefly.artica.es/projects/autodiscover-linux.zip
unzip autodiscover-linux.zip unzip autodiscover-linux.zip
chmod +x $arch/autodiscover chmod +x $arch/autodiscover
mv -f $arch/autodiscover /etc/pandora/plugins/autodiscover mv -f $arch/autodiscover /etc/pandora/plugins/autodiscover

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.755-210708 Version: 7.0NG.756-210805
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1014,8 +1014,8 @@ my $Sem = undef;
# Semaphore used to control the number of threads # Semaphore used to control the number of threads
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.755'; use constant AGENT_VERSION => '7.0NG.756';
use constant AGENT_BUILD => '210708'; use constant AGENT_BUILD => '210805';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.755 %define version 7.0NG.756
%define release 210708 %define release 210805
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.755 %define version 7.0NG.756
%define release 210708 %define release 210805
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -9,8 +9,8 @@
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.755" PI_VERSION="7.0NG.756"
PI_BUILD="210708" PI_BUILD="210805"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

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

View File

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

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.755 Build 210708") #define PANDORA_VERSION ("7.0NG.756 Build 210805")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.755(Build 210708))" VALUE "ProductVersion", "(7.0NG.756(Build 210805))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.755-210708 Version: 7.0NG.756-210805
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -30,7 +30,7 @@
global $config; global $config;
check_login(); check_login();
// ACL Check // ACL Check.
if (!check_acl($config['id_user'], 0, 'AR')) { if (!check_acl($config['id_user'], 0, 'AR')) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',
@ -56,7 +56,7 @@ if (is_ajax()) {
} }
/** /**
* The main function of module groups and the enter point to * The main function of module groups and the enter point to
* execute the code. * execute the code.
* *
@ -94,7 +94,7 @@ function mainModuleGroups()
$user_groups = users_get_groups($config['user'], 'AR'); $user_groups = users_get_groups($config['user'], 'AR');
$info = array_filter( $info = array_filter(
$info, $info,
function ($v, $k) use ($user_groups) { function ($v) use ($user_groups) {
return $user_groups[$v['id']] != null; return $user_groups[$v['id']] != null;
}, },
ARRAY_FILTER_USE_BOTH ARRAY_FILTER_USE_BOTH
@ -102,7 +102,7 @@ function mainModuleGroups()
$info = array_filter( $info = array_filter(
$info, $info,
function ($v, $k) use ($agent_group_search) { function ($v) use ($agent_group_search) {
return preg_match( return preg_match(
'/'.$agent_group_search.'/i', '/'.$agent_group_search.'/i',
$v['name'] $v['name']
@ -111,7 +111,7 @@ function mainModuleGroups()
ARRAY_FILTER_USE_BOTH ARRAY_FILTER_USE_BOTH
); );
if (!empty($info)) { if (empty($info) === false) {
$groups_view = ($is_not_paginated) ? $info : array_slice( $groups_view = ($is_not_paginated) ? $info : array_slice(
$info, $info,
$offset, $offset,
@ -156,7 +156,7 @@ function mainModuleGroups()
$array_module_group = array_filter( $array_module_group = array_filter(
$array_module_group, $array_module_group,
function ($v, $k) use ($module_group_search) { function ($v) use ($module_group_search) {
return preg_match('/'.$module_group_search.'/i', $v); return preg_match('/'.$module_group_search.'/i', $v);
}, },
ARRAY_FILTER_USE_BOTH ARRAY_FILTER_USE_BOTH
@ -332,13 +332,16 @@ function mainModuleGroups()
// Orange when the cell for this model group and agent has at least one alert fired. // Orange when the cell for this model group and agent has at least one alert fired.
} else if ($array_data[$key][$k]['critical_module_count'] != 0) { } else if ($array_data[$key][$k]['critical_module_count'] != 0) {
$color = COL_CRITICAL; $color = COL_CRITICAL;
// Red when the cell for this model group and agent has at least one module in critical state and the rest in any state. // Red when the cell for this model group and agent
// has at least one module in critical state and the rest in any state.
} else if ($array_data[$key][$k]['warning_module_count'] != 0) { } else if ($array_data[$key][$k]['warning_module_count'] != 0) {
$color = COL_WARNING; $color = COL_WARNING;
// Yellow when the cell for this model group and agent has at least one in warning state and the rest in green state. // Yellow when the cell for this model group and agent
// has at least one in warning state and the rest in green state.
} else if ($array_data[$key][$k]['unknown_module_count'] != 0) { } else if ($array_data[$key][$k]['unknown_module_count'] != 0) {
$color = COL_UNKNOWN; $color = COL_UNKNOWN;
// Grey when the cell for this model group and agent has at least one module in unknown state and the rest in any state. // Grey when the cell for this model group and agent
// has at least one module in unknown state and the rest in any state.
} else if ($array_data[$key][$k]['normal_module_count'] != 0) { } else if ($array_data[$key][$k]['normal_module_count'] != 0) {
$color = COL_NORMAL; $color = COL_NORMAL;
// Green when the cell for this model group and agent has OK state all modules. // Green when the cell for this model group and agent has OK state all modules.
@ -348,7 +351,7 @@ function mainModuleGroups()
} }
$data[$i][$j] = "<div style='".$cell_style.'background:'.$color.";'>"; $data[$i][$j] = "<div style='".$cell_style.'background:'.$color.";'>";
$data[$i][$j] .= "<a class='info_cell white font_18px' rel='$rel' href='$url'>"; $data[$i][$j] .= '<a class="info_cell white font_18px" rel="'.$rel.'" href="'.$url.'">';
$data[$i][$j] .= $array_data[$key][$k]['total_count']; $data[$i][$j] .= $array_data[$key][$k]['total_count'];
$data[$i][$j] .= '</a></div>'; $data[$i][$j] .= '</a></div>';
} else { } else {

View File

@ -1,418 +0,0 @@
<?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 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.
function pluginreg_extension_main()
{
global $config;
check_login();
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
db_pandora_audit('ACL Violation', 'Trying to access Setup Management');
include 'general/noaccess.php';
return;
}
ui_require_css_file('first_task');
ui_print_page_header(__('Plugin registration'), 'images/extensions.png', false, '', true, '');
echo '<div class="new_task">
<div class="image_task">';
echo html_print_image('images/first_task/icono_grande_import.png', true, ['title' => __('Plugin Registration') ]);
echo '</div>';
echo '<div class="text_task">';
echo '<h3>'.__('Plugin registration').'</h3>';
echo '<p id="description_task">'.__(
"This extension makes registering server plugins an easier task.
Here you can upload a server plugin in .pspz zipped format.
Please refer to the official documentation on how to obtain and use Server Plugins.
<br><br>You can get more plugins in our <a href='http://pandorafms.com/Library/Library/'>Public Resource Library</a> "
).'</p>';
// Upload form
echo "<form name='submit_plugin' method='post' enctype='multipart/form-data'>";
echo '<table class="" id="table1" width="100%" border="0" cellpadding="4" cellspacing="4">';
echo "<tr><td class='datos'><input type='file' name='plugin_upload' />";
echo "<td class='datos'><input type='submit' class='sub next' value='".__('Upload')."' />";
echo '</form></table>';
echo '</div>';
echo '</div>';
$zip = null;
$upload = false;
if (isset($_FILES['plugin_upload'])) {
$config['plugin_store'] = $config['attachment_store'].'/plugin';
$name_file = $_FILES['plugin_upload']['name'];
$zip = zip_open($_FILES['plugin_upload']['tmp_name']);
$upload = true;
}
if ($zip) {
while ($zip_entry = zip_read($zip)) {
if (zip_entry_open($zip, $zip_entry, 'r')) {
if (zip_entry_name($zip_entry) == 'plugin_definition.ini') {
$basepath = $config['attachment_store'];
} else {
$basepath = $config['plugin_store'];
}
$filename = $basepath.'/'.zip_entry_name($zip_entry);
$fp = fopen($filename, 'w');
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
fwrite($fp, $buf);
fclose($fp);
chmod($filename, 0755);
zip_entry_close($zip_entry);
}
}
zip_close($zip);
}
if ($upload) {
// Parse with sections
if (! $ini_array = parse_ini_file($config['attachment_store'].'/plugin_definition.ini', true)) {
echo '<h2 class=error>'.__('Cannot load INI file').'</h2>';
} else {
$version = preg_replace('/.*[.]/', '', $name_file);
$exec_path = $config['plugin_store'].'/'.$ini_array['plugin_definition']['filename'];
$file_exec_path = $exec_path;
if (isset($ini_array['plugin_definition']['execution_command'])
&& ($ini_array['plugin_definition']['execution_command'] != '')
) {
$exec_path = $ini_array['plugin_definition']['execution_command'].' '.$config['plugin_store'].'/'.$ini_array['plugin_definition']['filename'];
}
if (isset($ini_array['plugin_definition']['execution_postcommand'])
&& ($ini_array['plugin_definition']['execution_postcommand'] != '')
) {
$exec_path = $exec_path.' '.$ini_array['plugin_definition']['execution_postcommand'];
}
if (!file_exists($file_exec_path)) {
echo '<h2 class=error>'.__('Plugin exec not found. Aborting!').'</h2>';
unlink($config['attachment_store'].'/plugin_definition.ini');
} else {
// Verify if a plugin with the same name is already registered
$sql0 = "SELECT COUNT(*)
FROM tplugin
WHERE name = '".io_safe_input($ini_array['plugin_definition']['name'])."'";
$result = db_get_sql($sql0);
if ($result > 0) {
echo '<h2 class=error>'.__('Plugin already registered. Aborting!').'</h2>';
unlink($config['attachment_store'].'/plugin_definition.ini');
} else {
$values = [
'name' => io_safe_input($ini_array['plugin_definition']['name']),
'description' => io_safe_input($ini_array['plugin_definition']['description']),
'max_timeout' => $ini_array['plugin_definition']['timeout'],
'execute' => io_safe_input($exec_path),
'net_dst_opt' => $ini_array['plugin_definition']['ip_opt'],
'net_port_opt' => $ini_array['plugin_definition']['port_opt'],
'user_opt' => $ini_array['plugin_definition']['user_opt'],
'pass_opt' => $ini_array['plugin_definition']['pass_opt'],
'parameters' => $ini_array['plugin_definition']['parameters'],
'plugin_type' => $ini_array['plugin_definition']['plugin_type'],
];
switch ($version) {
case 'pspz':
// Fixed the static parameters
// for
// the dinamic parameters of pandoras 5
$total_macros = 0;
$macros = [];
if (!isset($values['parameters'])) {
$values['parameters'] = '';
}
if ($values['net_dst_opt'] != '') {
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Target IP from net';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= $values['net_dst_opt'].' _field'.$total_macros.'_ ';
$macros[(string) $total_macros] = $macro;
}
if ($values['ip_opt'] != '') {
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Target IP';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= $values['ip_opt'].' _field'.$total_macros.'_ ';
$macros[(string) $total_macros] = $macro;
}
if ($values['net_port_opt'] != '') {
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Port from net';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= $values['net_port_opt'].' _field'.$total_macros.'_ ';
$macros[(string) $total_macros] = $macro;
}
if ($values['port_opt'] != '') {
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Port';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= $values['port_opt'].' _field'.$total_macros.'_ ';
$macros[(string) $total_macros] = $macro;
}
if ($values['user_opt'] != '') {
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Username';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= $values['user_opt'].' _field'.$total_macros.'_ ';
$macros[(string) $total_macros] = $macro;
}
if ($values['pass_opt'] != '') {
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Password';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= $values['pass_opt'].' _field'.$total_macros.'_ ';
$macros[(string) $total_macros] = $macro;
}
// A last parameter is defined always to
// add the old "Plug-in parameters" in the
// side of the module
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Plug-in Parameters';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= ' _field'.$total_macros.'_';
$macros[(string) $total_macros] = $macro;
break;
case 'pspz2':
// Fill the macros field.
$total_macros = $ini_array['plugin_definition']['total_macros_provided'];
$macros = [];
for ($it_macros = 1; $it_macros <= $total_macros; $it_macros++) {
$label = 'macro_'.$it_macros;
$macro = [];
$macro['macro'] = '_field'.$it_macros.'_';
$macro['hide'] = $ini_array[$label]['hide'];
$macro['desc'] = io_safe_input(
$ini_array[$label]['description']
);
$macro['help'] = io_safe_input(
$ini_array[$label]['help']
);
$macro['value'] = io_safe_input(
$ini_array[$label]['value']
);
$macros[(string) $it_macros] = $macro;
}
break;
}
if (!empty($macros)) {
$values['macros'] = json_encode($macros);
}
$create_id = db_process_sql_insert('tplugin', $values);
if (empty($create_id)) {
ui_print_error_message(
__('Plug-in Remote Registered unsuccessfull')
);
ui_print_info_message(
__('Please check the syntax of file "plugin_definition.ini"')
);
} else {
for ($ax = 1; $ax <= $ini_array['plugin_definition']['total_modules_provided']; $ax++) {
$label = 'module'.$ax;
$plugin_user = '';
if (isset($ini_array[$label]['plugin_user'])) {
$plugin_user = $ini_array[$label]['plugin_user'];
}
$plugin_pass = '';
if (isset($ini_array[$label]['plugin_pass'])) {
$plugin_pass = $ini_array[$label]['plugin_pass'];
}
$plugin_parameter = '';
if (isset($ini_array[$label]['plugin_parameter'])) {
$plugin_parameter = $ini_array[$label]['plugin_parameter'];
}
$unit = '';
if (isset($ini_array[$label]['unit'])) {
$unit = $ini_array[$label]['unit'];
}
$values = [
'name' => io_safe_input($ini_array[$label]['name']),
'description' => io_safe_input($ini_array[$label]['description']),
'id_group' => $ini_array[$label]['id_group'],
'type' => $ini_array[$label]['type'],
'max' => isset($ini_array[$label]['max']) ? $ini_array[$label]['max'] : '',
'min' => isset($ini_array[$label]['min']) ? $ini_array[$label]['min'] : '',
'module_interval' => isset($ini_array[$label]['module_interval']) ? $ini_array[$label]['module_interval'] : '',
'id_module_group' => $ini_array[$label]['id_module_group'],
'id_modulo' => $ini_array[$label]['id_modulo'],
'plugin_user' => io_safe_input($plugin_user),
'plugin_pass' => io_safe_input($plugin_pass),
'plugin_parameter' => io_safe_input($plugin_parameter),
'unit' => io_safe_input($unit),
'max_timeout' => isset($ini_array[$label]['max_timeout']) ? $ini_array[$label]['max_timeout'] : '',
'history_data' => isset($ini_array[$label]['history_data']) ? $ini_array[$label]['history_data'] : '',
'dynamic_interval' => isset($ini_array[$label]['dynamic_interval']) ? $ini_array[$label]['dynamic_interval'] : '',
'dynamic_min' => isset($ini_array[$label]['dynamic_min']) ? $ini_array[$label]['dynamic_min'] : '',
'dynamic_max' => isset($ini_array[$label]['dynamic_max']) ? $ini_array[$label]['dynamic_max'] : '',
'dynamic_two_tailed' => isset($ini_array[$label]['dynamic_two_tailed']) ? $ini_array[$label]['dynamic_two_tailed'] : '',
'min_warning' => isset($ini_array[$label]['min_warning']) ? $ini_array[$label]['min_warning'] : '',
'max_warning' => isset($ini_array[$label]['max_warning']) ? $ini_array[$label]['max_warning'] : '',
'str_warning' => isset($ini_array[$label]['str_warning']) ? $ini_array[$label]['str_warning'] : '',
'min_critical' => isset($ini_array[$label]['min_critical']) ? $ini_array[$label]['min_critical'] : '',
'max_critical' => isset($ini_array[$label]['max_critical']) ? $ini_array[$label]['max_critical'] : '',
'str_critical' => isset($ini_array[$label]['str_critical']) ? $ini_array[$label]['str_critical'] : '',
'min_ff_event' => isset($ini_array[$label]['min_ff_event']) ? $ini_array[$label]['min_ff_event'] : '',
'tcp_port' => isset($ini_array[$label]['tcp_port']) ? $ini_array[$label]['tcp_port'] : '',
'id_plugin' => $create_id,
];
$macros_component = $macros;
switch ($version) {
case 'pspz':
// Fixed the static parameters
// for
// the dinamic parameters of pandoras 5
foreach ($macros_component as $key => $macro) {
if ($macro['desc'] == 'Target IP from net') {
if (!empty($values['ip_target'])) {
$macros_component[$key]['value'] = io_safe_input($values['ip_target']);
}
}
if ($macro['desc'] == 'Target IP') {
if (!empty($values['ip_target'])) {
$macros_component[$key]['value'] = io_safe_input($values['ip_target']);
}
} else if ($macro['desc'] == 'Port from net') {
if (!empty($values['tcp_port'])) {
$macros_component[$key]['value'] = io_safe_input($values['tcp_port']);
}
} else if ($macro['desc'] == 'Port') {
if (!empty($values['tcp_port'])) {
$macros_component[$key]['value'] = io_safe_input($values['tcp_port']);
}
} else if ($macro['desc'] == 'Username') {
if (!empty($values['plugin_user'])) {
$macros_component[$key]['value'] = io_safe_input($values['plugin_user']);
}
} else if ($macro['desc'] == 'Password') {
if (!empty($values['plugin_pass'])) {
$macros_component[$key]['value'] = io_safe_input($values['plugin_pass']);
}
} else if ($macro['desc'] == 'Plug-in Parameters') {
if (!empty($values['plugin_parameter'])) {
$macros_component[$key]['value'] = io_safe_input($values['plugin_parameter']);
}
}
}
break;
case 'pspz2':
if ($total_macros > 0) {
for ($it_macros = 1; $it_macros <= $total_macros; $it_macros++) {
$macro = 'macro_'.$it_macros.'_value';
// Set the value or use the default
if (isset($ini_array[$label][$macro])) {
$macros_component[(string) $it_macros]['value'] = io_safe_input($ini_array[$label][$macro]);
}
}
}
break;
}
if (!empty($macros_component)) {
$values['macros'] = json_encode($macros_component);
}
db_process_sql_insert('tnetwork_component', $values);
echo '<h3 class=suc>'.__('Module plugin registered').' : '.$ini_array[$label]['name'].'</h3>';
}
echo '<h2 class=suc>'.__('Plugin').' '.$ini_array['plugin_definition']['name'].' '.__('Registered successfully').'</h2>';
}
unlink($config['attachment_store'].'/plugin_definition.ini');
}
}
}
}
}
extensions_add_godmode_menu_option(__('Register plugin'), 'PM', 'gservers', null, 'v1r1');
extensions_add_godmode_function('pluginreg_extension_main');

View File

@ -1047,8 +1047,8 @@ function process_upload_xml($xml)
// Extract policies. // Extract policies.
if ($hook_enterprise === true) { if ($hook_enterprise === true) {
$centralized_management = !is_central_policies_on_node(); $centralized_management = is_management_allowed();
if ($centralized_management) { if ($centralized_management === true) {
process_upload_xml_policy($xml, $group_filter); process_upload_xml_policy($xml, $group_filter);
} }
} }
@ -1080,9 +1080,17 @@ function resource_registration_extension_main()
return; return;
} }
$centralized_management = !is_central_policies_on_node(); if (is_management_allowed() === false) {
if (!$centralized_management) { ui_print_warning_message(
ui_print_warning_message(__('This node is configured with centralized mode. Go to metaconsole to create a policy.')); __(
'This node is configured with centralized mode. Go to %s to create a policy.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/policymanager'
).'">'.__('metaconsole').'</a>'
)
);
return;
} }
echo '<div class=notify>'; echo '<div class=notify>';
@ -1091,7 +1099,7 @@ function resource_registration_extension_main()
echo '<br /><br />'; echo '<br /><br />';
// Upload form // Upload form.
echo "<form name='submit_plugin' method='post' enctype='multipart/form-data'>"; echo "<form name='submit_plugin' method='post' enctype='multipart/form-data'>";
echo '<table class="databox" id="table1" width="98%" border="0" cellpadding="4" cellspacing="4">'; echo '<table class="databox" id="table1" width="98%" border="0" cellpadding="4" cellspacing="4">';
echo '<tr>'; echo '<tr>';
@ -1105,7 +1113,7 @@ function resource_registration_extension_main()
echo '</table>'; echo '</table>';
echo '</form>'; echo '</form>';
if (!isset($_FILES['resource_upload']['tmp_name'])) { if (isset($_FILES['resource_upload']['tmp_name']) === false) {
return; return;
} }

View File

@ -33,10 +33,19 @@ function users_extension_main_god($god=true)
$image = 'images/user.png'; $image = 'images/user.png';
} }
// Header // Header.
ui_print_page_header(__('Users connected'), $image, false, '', $god); ui_print_page_header(__('Users connected'), $image, false, '', $god);
// Get groups user has permission $check_profile = db_get_row('tusuario_perfil', 'id_usuario', $config['id_user'], 'id_up');
if ($check_profile === false && !users_is_admin()) {
return ui_print_error_message(
__('This user does not have any associated profile'),
'',
false
);
}
// Get groups user has permission.
$group_um = users_get_groups_UM($config['id_user']); $group_um = users_get_groups_UM($config['id_user']);
// Is admin or has group permissions all. // Is admin or has group permissions all.
$groups = implode(',', array_keys($group_um, 1)); $groups = implode(',', array_keys($group_um, 1));
@ -44,6 +53,15 @@ function users_extension_main_god($god=true)
// Get user conected last 5 minutes.Show only those on which the user has permission. // Get user conected last 5 minutes.Show only those on which the user has permission.
switch ($config['dbtype']) { switch ($config['dbtype']) {
case 'mysql': case 'mysql':
if (users_is_admin()) {
$sql = sprintf(
'SELECT tusuario.id_user, tusuario.last_connect
FROM tusuario
WHERE last_connect > (UNIX_TIMESTAMP(NOW()) - '.SECONDS_5MINUTES.')
GROUP BY tusuario.id_user
ORDER BY last_connect DESC'
);
} else {
$sql = sprintf( $sql = sprintf(
'SELECT tusuario.id_user, tusuario.last_connect 'SELECT tusuario.id_user, tusuario.last_connect
FROM tusuario FROM tusuario
@ -54,9 +72,19 @@ function users_extension_main_god($god=true)
ORDER BY last_connect DESC', ORDER BY last_connect DESC',
$groups $groups
); );
}
break; break;
case 'postgresql': case 'postgresql':
if (users_is_admin()) {
$sql = sprintf(
"SELECT tusuario.id_user, tusuario.last_connect
FROM tusuario
WHERE last_connect > (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - ".SECONDS_5MINUTES.')
GROUP BY tusuario.id_user
ORDER BY last_connect DESC'
);
} else {
$sql = sprintf( $sql = sprintf(
"SELECT tusuario.id_user, tusuario.last_connect "SELECT tusuario.id_user, tusuario.last_connect
FROM tusuario FROM tusuario
@ -67,9 +95,19 @@ function users_extension_main_god($god=true)
ORDER BY last_connect DESC', ORDER BY last_connect DESC',
$groups $groups
); );
}
break; break;
case 'oracle': case 'oracle':
if (users_is_admin()) {
$sql = sprintf(
"SELECT tusuario.id_user, tusuario.last_connect
FROM tusuario
WHERE last_connect > (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - '.SECONDS_5MINUTES.')
GROUP BY tusuario.id_user
ORDER BY last_connect DESC'
);
} else {
$sql = sprintf( $sql = sprintf(
"SELECT tusuario.id_user, tusuario.last_connect "SELECT tusuario.id_user, tusuario.last_connect
FROM tusuario FROM tusuario
@ -80,15 +118,20 @@ function users_extension_main_god($god=true)
ORDER BY last_connect DESC', ORDER BY last_connect DESC',
$groups $groups
); );
}
break;
default:
// Nothing to do.
break; break;
} }
$rows = db_get_all_rows_sql($sql); $rows = db_get_all_rows_sql($sql);
if (empty($rows)) { if (empty($rows)) {
$rows = []; $rows = [];
echo "<div class='nf'>".__('No other users connected').'</div>'; echo "<div class='nf'>".__('No other users connected').'</div>';
} else { } else {
$table = new StdClass();
$table->cellpadding = 0; $table->cellpadding = 0;
$table->cellspacing = 0; $table->cellspacing = 0;
$table->width = '100%'; $table->width = '100%';
@ -105,7 +148,7 @@ function users_extension_main_god($god=true)
$rowPair = true; $rowPair = true;
$iterator = 0; $iterator = 0;
// Get data // Get data.
foreach ($rows as $row) { foreach ($rows as $row) {
// Get data of user's last login. // Get data of user's last login.
switch ($config['dbtype']) { switch ($config['dbtype']) {
@ -135,6 +178,10 @@ function users_extension_main_god($god=true)
) )
); );
break; break;
default:
// Nothing to do.
break;
} }
if ($rowPair) { if ($rowPair) {

View File

@ -82,6 +82,14 @@ include/lib/WSManager.php
include/lib/WebSocketServer.php include/lib/WebSocketServer.php
include/lib/WebSocketUser.php include/lib/WebSocketUser.php
operation/network/network_explorer.php operation/network/network_explorer.php
enterprise/meta/advanced/synchronizing.php
enterprise/meta/advanced/synchronizing.os.php
enterprise/meta/advanced/synchronizing.module_groups.php
enterprise/meta/advanced/synchronizing.component.php
enterprise/meta/advanced/synchronizing.alert.php
enterprise/meta/advanced/synchronizing.user.php
enterprise/meta/advanced/synchronizing.tag.php
enterprise/meta/advanced/synchronizing.group.php
operation/visual_console/pure_ajax.php operation/visual_console/pure_ajax.php
include/ajax/update_manager.ajax.php include/ajax/update_manager.ajax.php
godmode/update_manager/update_manager.css godmode/update_manager/update_manager.css
@ -90,6 +98,8 @@ godmode/update_manager/update_manager.online.php
include/javascript/update_manager.js include/javascript/update_manager.js
enterprise/include/functions_update_manager.php enterprise/include/functions_update_manager.php
include/ajax/rolling_release.ajax.php include/ajax/rolling_release.ajax.php
extensions/plugin_registration.php
enterprise/include/functions_plugins.php
include/help/en/help_event_alert.php include/help/en/help_event_alert.php
include/help/es/help_event_alert.php include/help/es/help_event_alert.php
enterprise/godmode/alerts/alert_events.php enterprise/godmode/alerts/alert_events.php

View File

@ -1,5 +1,9 @@
START TRANSACTION; START TRANSACTION;
ALTER TABLE `tmetaconsole_setup` ADD COLUMN `unified` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE `tlayout` ADD COLUMN `auto_adjust` INTEGER UNSIGNED NOT NULL default 0;
ALTER TABLE `tlayout_data` ADD COLUMN `title` TEXT default '';
CREATE TABLE IF NOT EXISTS `talert_execution_queue` ( CREATE TABLE IF NOT EXISTS `talert_execution_queue` (
`id` int(10) unsigned NOT NULL auto_increment, `id` int(10) unsigned NOT NULL auto_increment,
`id_alert_template_module` int(10) unsigned NOT NULL, `id_alert_template_module` int(10) unsigned NOT NULL,
@ -10,9 +14,20 @@ CREATE TABLE IF NOT EXISTS `talert_execution_queue` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tsync_queue` (
`id` serial,
`sql` MEDIUMTEXT,
`target` bigint(20) unsigned NOT NULL,
`utimestamp` bigint(20) default '0',
`operation` text,
`table` text,
`error` MEDIUMTEXT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
UPDATE `tlink` SET `link` = 'https://pandorafms.com/manual/' WHERE `id_link` = 0000000001; UPDATE `tlink` SET `link` = 'https://pandorafms.com/manual/' WHERE `id_link` = 0000000001;
UPDATE pandora.tuser_task UPDATE `tuser_task`
SET parameters='a:7:{i:0;a:7:{s:11:"description";s:30:"Template pending to be created";s:5:"table";s:16:"treport_template";s:8:"field_id";s:9:"id_report";s:10:"field_name";s:4:"name";s:8:"required";b:1;s:4:"type";s:3:"int";s:9:"acl_group";s:8:"id_group";}i:1;a:7:{s:11:"description";s:6:"Agents";s:5:"table";s:7:"tagente";s:8:"field_id";s:9:"id_agente";s:10:"field_name";s:6:"nombre";s:8:"multiple";b:1;s:4:"type";s:3:"int";s:9:"acl_group";s:8:"id_grupo";}i:2;a:2:{s:11:"description";s:16:"Report per agent";s:10:"select_two";b:1;}i:3;a:2:{s:11:"description";s:11:"Report name";s:4:"type";s:6:"string";}i:4;a:2:{s:11:"description";s:47:"Send to e-mail addresses (separated by a comma)";s:4:"type";s:4:"text";}i:5;a:2:{s:11:"description";s:7:"Subject";s:8:"optional";i:1;}i:6;a:3:{s:11:"description";s:7:"Message";s:4:"type";s:4:"text";s:8:"optional";i:1;}}i:7;a:2:{s:11:"description";s:11:"Report Type";s:4:"type";s:11:"report_type";}}' SET parameters='a:7:{i:0;a:7:{s:11:"description";s:30:"Template pending to be created";s:5:"table";s:16:"treport_template";s:8:"field_id";s:9:"id_report";s:10:"field_name";s:4:"name";s:8:"required";b:1;s:4:"type";s:3:"int";s:9:"acl_group";s:8:"id_group";}i:1;a:7:{s:11:"description";s:6:"Agents";s:5:"table";s:7:"tagente";s:8:"field_id";s:9:"id_agente";s:10:"field_name";s:6:"nombre";s:8:"multiple";b:1;s:4:"type";s:3:"int";s:9:"acl_group";s:8:"id_grupo";}i:2;a:2:{s:11:"description";s:16:"Report per agent";s:10:"select_two";b:1;}i:3;a:2:{s:11:"description";s:11:"Report name";s:4:"type";s:6:"string";}i:4;a:2:{s:11:"description";s:47:"Send to e-mail addresses (separated by a comma)";s:4:"type";s:4:"text";}i:5;a:2:{s:11:"description";s:7:"Subject";s:8:"optional";i:1;}i:6;a:3:{s:11:"description";s:7:"Message";s:4:"type";s:4:"text";s:8:"optional";i:1;}}i:7;a:2:{s:11:"description";s:11:"Report Type";s:4:"type";s:11:"report_type";}}'
WHERE id=2; WHERE id=2;
@ -21,7 +36,7 @@ UPDATE `tuser_task_scheduled` SET
`args`= REPLACE(`args`, 's:15:"first_execution"', 'i:2;s:0:"";i:7;s:3:"PDF";s:15:"first_execution"') `args`= REPLACE(`args`, 's:15:"first_execution"', 'i:2;s:0:"";i:7;s:3:"PDF";s:15:"first_execution"')
WHERE `id_user_task` = 2; WHERE `id_user_task` = 2;
ALTER TABLE `tlayout` ADD COLUMN `auto_adjust` INTEGER UNSIGNED NOT NULL default 0; UPDATE `tconfig` SET `value` = 0 WHERE `token` = 'centralized_management';
DELETE ta FROM `tagente` ta LEFT JOIN `tgrupo` tg on ta.`id_grupo` = tg.`id_grupo` WHERE tg.`id_grupo` IS NULL; DELETE ta FROM `tagente` ta LEFT JOIN `tgrupo` tg on ta.`id_grupo` = tg.`id_grupo` WHERE tg.`id_grupo` IS NULL;

View File

@ -0,0 +1,35 @@
CREATE PROCEDURE updateSnmpAlerts()
BEGIN
DECLARE tokenId INT DEFAULT 0;
DECLARE procedureRun INT DEFAULT 0;
DECLARE done BOOLEAN DEFAULT FALSE;
DECLARE a, b INT DEFAULT 0;
DECLARE alertsCur CURSOR FOR SELECT id, id_alert_command FROM talert_actions;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
SELECT id_config, value INTO tokenId, procedureRun FROM tconfig WHERE token = 'update_snmp_alerts_procedure_already_run' LIMIT 1;
IF procedureRun < 1 THEN
SET done = FALSE;
OPEN alertsCur;
read_loop: LOOP
FETCH alertsCur INTO a, b;
IF done THEN
LEAVE read_loop;
END IF;
UPDATE talert_snmp SET id_alert = b WHERE id_alert = a;
UPDATE talert_snmp_action SET alert_type = b WHERE alert_type = a;
END LOOP;
CLOSE alertsCur;
IF tokenId < 1 THEN
INSERT INTO tconfig (id_config, token, value) VALUES ('', 'update_snmp_alerts_procedure_already_run', '1');
ELSE
UPDATE tconfig SET value = 1 WHERE token = 'update_snmp_alerts_procedure_already_run';
END IF;
END IF;
END

View File

@ -418,6 +418,8 @@ ALTER TABLE `tmetaconsole_setup` MODIFY COLUMN `meta_dbuser` text NULL,
ALTER TABLE `tmetaconsole_setup` ADD COLUMN `server_uid` TEXT NOT NULL default ''; ALTER TABLE `tmetaconsole_setup` ADD COLUMN `server_uid` TEXT NOT NULL default '';
ALTER TABLE `tmetaconsole_setup` ADD COLUMN `unified` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tprofile_view` -- Table `tprofile_view`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
@ -1438,13 +1440,13 @@ ALTER TABLE `ttag` MODIFY COLUMN `name` text NOT NULL default '';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 47); INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 48);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package', 755); INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package', 756);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
UPDATE `tconfig` SET `value` = 'mini_severity,evento,id_agente,estado,timestamp' WHERE `token` LIKE 'event_fields'; UPDATE `tconfig` SET `value` = 'mini_severity,evento,id_agente,estado,timestamp' WHERE `token` LIKE 'event_fields';
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_api_password'; DELETE FROM `tconfig` WHERE `token` LIKE 'integria_api_password';
@ -2255,6 +2257,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
`linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0, `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0,
`linked_layout_node_id` INT(10) NOT NULL default 0, `linked_layout_node_id` INT(10) NOT NULL default 0,
`cache_expiration` INTEGER UNSIGNED NOT NULL default 0, `cache_expiration` INTEGER UNSIGNED NOT NULL default 0,
`title` TEXT default '',
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET=utf8; ) ENGINE = InnoDB DEFAULT CHARSET=utf8;
@ -2564,7 +2567,7 @@ ALTER TABLE `tnetflow_filter` MODIFY COLUMN `router_ip` text NOT NULL;
UPDATE tuser_task set parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report"; UPDATE tuser_task set parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report";
INSERT IGNORE INTO tuser_task VALUES (8, 'cron_task_generate_csv_log', 'a:1:{i:0;a:2:{s:11:"description";s:14:"Send to e-mail";s:4:"type";s:4:"text";}}', 'Send csv log'); INSERT IGNORE INTO tuser_task VALUES (8, 'cron_task_generate_csv_log', 'a:1:{i:0;a:2:{s:11:"description";s:14:"Send to e-mail";s:4:"type";s:4:"text";}}', 'Send csv log');
UPDATE `tuser_task` SET `parameters`='a:4:{i:0;a:6:{s:11:"description";s:28:"Report pending to be created";s:5:"table";s:7:"treport";s:8:"field_id";s:9:"id_report";s:10:"field_name";s:4:"name";s:4:"type";s:3:"int";s:9:"acl_group";s:8:"id_group";}i:1;a:2:{s:11:"description";s:426:"Save to disk in path<a href="javascript:" class="tip" style="" ><img src="http://172.16.0.2/pandora_console/images/tip_help.png" data-title="The Apache user should have read-write access on this folder. E.g. /var/www/html/pandora_console/attachment" data-use_title_for_force_title="1" class="forced_title" alt="The Apache user should have read-write access on this folder. E.g. /var/www/html/pandora_console/attachment" /></a>";s:4:"type";s:6:"string";}i:2;a:2:{s:11:"description";s:16:"File nane prefix";s:4:"type";s:6:"string";}i:3;a:2:{s:11:"description";s:11:"Report Type";s:4:"type";s:11:"report_type";}}' WHERE `id`=3; UPDATE `tuser_task` SET `parameters`='a:4:{i:0;a:6:{s:11:"description";s:28:"Report pending to be created";s:5:"table";s:7:"treport";s:8:"field_id";s:9:"id_report";s:10:"field_name";s:4:"name";s:4:"type";s:3:"int";s:9:"acl_group";s:8:"id_group";}i:1;a:2:{s:11:"description";s:426:"Save to disk in path<a href="javascript:" class="tip" style="" ><img src="http://172.16.0.2/pandora_console/images/tip_help.png" data-title="The Apache user should have read-write access on this folder. E.g. /var/www/html/pandora_console/attachment" data-use_title_for_force_title="1" class="forced_title" alt="The Apache user should have read-write access on this folder. E.g. /var/www/html/pandora_console/attachment" /></a>";s:4:"type";s:6:"string";}i:2;a:2:{s:11:"description";s:16:"File nane prefix";s:4:"type";s:6:"string";}i:3;a:2:{s:11:"description";s:11:"Report Type";s:4:"type";s:11:"report_type";}}' WHERE `id`=3;
UPDATE pandora.tuser_task UPDATE `tuser_task`
SET parameters='a:7:{i:0;a:7:{s:11:"description";s:30:"Template pending to be created";s:5:"table";s:16:"treport_template";s:8:"field_id";s:9:"id_report";s:10:"field_name";s:4:"name";s:8:"required";b:1;s:4:"type";s:3:"int";s:9:"acl_group";s:8:"id_group";}i:1;a:7:{s:11:"description";s:6:"Agents";s:5:"table";s:7:"tagente";s:8:"field_id";s:9:"id_agente";s:10:"field_name";s:6:"nombre";s:8:"multiple";b:1;s:4:"type";s:3:"int";s:9:"acl_group";s:8:"id_grupo";}i:2;a:2:{s:11:"description";s:16:"Report per agent";s:10:"select_two";b:1;}i:3;a:2:{s:11:"description";s:11:"Report name";s:4:"type";s:6:"string";}i:4;a:2:{s:11:"description";s:47:"Send to e-mail addresses (separated by a comma)";s:4:"type";s:4:"text";}i:5;a:2:{s:11:"description";s:7:"Subject";s:8:"optional";i:1;}i:6;a:3:{s:11:"description";s:7:"Message";s:4:"type";s:4:"text";s:8:"optional";i:1;}}i:7;a:2:{s:11:"description";s:11:"Report Type";s:4:"type";s:11:"report_type";}}' WHERE id=2; SET parameters='a:7:{i:0;a:7:{s:11:"description";s:30:"Template pending to be created";s:5:"table";s:16:"treport_template";s:8:"field_id";s:9:"id_report";s:10:"field_name";s:4:"name";s:8:"required";b:1;s:4:"type";s:3:"int";s:9:"acl_group";s:8:"id_group";}i:1;a:7:{s:11:"description";s:6:"Agents";s:5:"table";s:7:"tagente";s:8:"field_id";s:9:"id_agente";s:10:"field_name";s:6:"nombre";s:8:"multiple";b:1;s:4:"type";s:3:"int";s:9:"acl_group";s:8:"id_grupo";}i:2;a:2:{s:11:"description";s:16:"Report per agent";s:10:"select_two";b:1;}i:3;a:2:{s:11:"description";s:11:"Report name";s:4:"type";s:6:"string";}i:4;a:2:{s:11:"description";s:47:"Send to e-mail addresses (separated by a comma)";s:4:"type";s:4:"text";}i:5;a:2:{s:11:"description";s:7:"Subject";s:8:"optional";i:1;}i:6;a:3:{s:11:"description";s:7:"Message";s:4:"type";s:4:"text";s:8:"optional";i:1;}}i:7;a:2:{s:11:"description";s:11:"Report Type";s:4:"type";s:11:"report_type";}}' WHERE id=2;
DELETE FROM `tuser_task` WHERE id = 6; DELETE FROM `tuser_task` WHERE id = 6;
@ -2738,7 +2741,7 @@ CREATE TABLE `tremote_command_target` (
FOREIGN KEY (`rcmd_id`) REFERENCES `tremote_command`(`id`) FOREIGN KEY (`rcmd_id`) REFERENCES `tremote_command`(`id`)
ON UPDATE CASCADE ON DELETE CASCADE ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
=========
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `trecon_script` -- Table `trecon_script`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
@ -4042,6 +4045,20 @@ DELETE FROM `tconfig` WHERE `token` = 'ipam_installed';
DELETE FROM `tconfig` WHERE `token` = 'ipam_recon_script_id'; DELETE FROM `tconfig` WHERE `token` = 'ipam_recon_script_id';
-- ----------------------------------------------------------------------
-- Table `tsync_queue`
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tsync_queue` (
`id` serial,
`sql` MEDIUMTEXT,
`target` bigint(20) unsigned NOT NULL,
`utimestamp` bigint(20) default '0',
`operation` text,
`table` text,
`error` MEDIUMTEXT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `tperfil` DROP COLUMN `incident_view`; ALTER TABLE `tperfil` DROP COLUMN `incident_view`;
ALTER TABLE `tperfil` DROP COLUMN `incident_edit`; ALTER TABLE `tperfil` DROP COLUMN `incident_edit`;
ALTER TABLE `tperfil` DROP COLUMN `incident_management`; ALTER TABLE `tperfil` DROP COLUMN `incident_management`;

View File

@ -11,21 +11,25 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
require_once 'include/functions.php'; require_once __DIR__.'/../include/functions.php';
require_once 'include/functions_html.php'; require_once __DIR__.'/../include/functions_html.php';
require_once 'include/functions_ui.php'; require_once __DIR__.'/../include/functions_ui.php';
require_once 'include/functions_io.php'; require_once __DIR__.'/../include/functions_io.php';
require_once 'include/functions_extensions.php'; require_once __DIR__.'/../include/functions_extensions.php';
global $config;
$config['homedir'] = realpath(__DIR__.'/../');
echo '<html>'; echo '<html>';
ob_start('ui_process_page_head'); ob_start('ui_process_page_head');
echo '<link rel="stylesheet" href="include/styles/pandora.css" type="text/css">'; echo '<link rel="stylesheet" href="include/styles/pandora.css" type="text/css">';
echo '</head>'."\n"; echo '</head>'."\n";
require_once 'include/functions_themes.php'; require_once __DIR__.'/../include/functions_themes.php';
ob_start('ui_process_page_body'); ob_start('ui_process_page_body');
// At this point, $login_screen is setted with the error type desired // At this point, $login_screen is set with the error type desired.
require 'login_page.php'; require __DIR__.'/login_page.php';
?> ?>
</body> </body>

View File

@ -63,6 +63,7 @@ switch ($login_screen) {
case 'error_perms': case 'error_perms':
case 'homedir_bad_defined': case 'homedir_bad_defined':
case 'homeurl_bad_defined': case 'homeurl_bad_defined':
case 'disabled_access_node':
$logo_link = 'index.php'; $logo_link = 'index.php';
$logo_title = __('Go to Login'); $logo_title = __('Go to Login');
break; break;
@ -208,6 +209,7 @@ if (is_metaconsole() === true) {
switch ($login_screen) { switch ($login_screen) {
case 'logout': case 'logout':
case 'login': case 'login':
case 'disabled_access_node':
if (!empty($page) && !empty($sec)) { if (!empty($page) && !empty($sec)) {
foreach ($_POST as $key => $value) { foreach ($_POST as $key => $value) {
html_print_input_hidden(io_safe_input($key), io_safe_input($value)); html_print_input_hidden(io_safe_input($key), io_safe_input($value));
@ -508,9 +510,29 @@ if ($login_screen == 'logout') {
echo '</div>'; echo '</div>';
} }
if ($login_screen === 'disabled_access_node') {
echo '<div id="disabled_access_node" title="'.__('User node access not enabled').'">';
echo '<div class="content_alert">';
echo '<div class="icon_message_alert">';
echo html_print_image('images/icono_logo_pandora.png', true, ['alt' => __('Centralized user in metaconsole'), 'border' => 0]);
echo '</div>';
echo '<div class="content_message_alert">';
echo '<div class="text_message_alert">';
echo '<h1>'.__('Centralized user in metaconsole').'</h1>';
echo '<p>'.__('This user does not have access on node, please enable node access on this user from metaconsole.').'</p>';
echo '</div>';
echo '<div class="button_message_alert">';
html_print_submit_button('Ok', 'hide-login-logout', false);
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
}
switch ($login_screen) { switch ($login_screen) {
case 'error_dbconfig': case 'error_dbconfig':
case 'error_authconfig': case 'error_authconfig':
case 'disabled_node_access':
if (!isset($config['rb_product_name_alt'])) { if (!isset($config['rb_product_name_alt'])) {
$title = __('Problem with %s database', get_product_name()); $title = __('Problem with %s database', get_product_name());
} else { } else {
@ -694,6 +716,29 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', '
}); });
break; break;
case 'disabled_access_node':
$(document).ready (function () {
$(function() {
$("#disabled_access_node").dialog({
resizable: true,
draggable: true,
modal: true,
height: 220,
width: 528,
clickOutside: true,
overlay: {
opacity: 0.5,
background: "black"
}
});
});
$("#submit-hide-login-logout").click (function () {
document.location = "<?php echo ui_get_full_url('index.php'); ?>";
});
});
break;
default: default:
$(document).ready (function () { $(document).ready (function () {
// IE9- modal warning window // IE9- modal warning window

View File

@ -31,9 +31,8 @@ ui_require_css_file('maintenance');
?> ?>
<html> <html>
<body> <body>
<h1>Ups ...</h1>
<div class="responsive">
<div class="responsive center padding-6">
<p><?php echo __('Maintenance tasks in progress'); ?></p> <p><?php echo __('Maintenance tasks in progress'); ?></p>
<br> <br>
<br> <br>

View File

@ -0,0 +1,79 @@
<?php
/**
* Static page to lock access to console
*
* @category Wizard
* @package Pandora FMS
* @subpackage Applications.VMware
* @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.
ui_require_css_file('maintenance');
?>
<html>
<body>
<div class="responsive center padding-6">
<p><?php echo __('You cannot use this node until system is unified'); ?></p>
<br>
<br>
<?php
html_print_image(
'images/maintenance.png',
false,
[
'class' => 'responsive',
'width' => 800,
]
);
?>
<br>
<br>
<p>
<?php
echo __(
'Please navigate to %s to unify system',
'<a href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/command_center'
).'" target="_new">'.__('command center').'</a>'
);
?>
</p>
<br>
<p><?php echo __('You will be automatically redirected when all tasks finish'); ?></p>
</div>
</body>
<script type="text/javascript">
$(document).ready(function() {
setTimeout(
function() {
location.reload();
},
10000
);
})
</script>
</html>

View File

@ -230,7 +230,7 @@ if (!$new_agent && $alias != '') {
$agent_options_update = 'agent_options_update'; $agent_options_update = 'agent_options_update';
// Delete link from here. // Delete link from here.
if (!is_central_policies_on_node()) { if (is_management_allowed() === true) {
$table_agent_name .= "<a onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=".$id_agente."&search=&offset=0&sort_field=&sort=none'>".html_print_image( $table_agent_name .= "<a onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=".$id_agente."&search=&offset=0&sort_field=&sort=none'>".html_print_image(
'images/cross.png', 'images/cross.png',
true, true,
@ -392,9 +392,9 @@ $table_os .= '</span></div></div></div>';
// Network server. // Network server.
$servers = servers_get_names(); $servers = servers_get_names();
if (!array_key_exists($server_name, $servers)) { // Set the agent have not server.
$server_Name = 0; if (array_key_exists($server_name, $servers) === false) {
// Set the agent have not server. $server_name = 0;
} }
$table_server = '<div class="label_select"><p class="input_label">'.__('Server').'</p>'; $table_server = '<div class="label_select"><p class="input_label">'.__('Server').'</p>';

View File

@ -1494,7 +1494,7 @@ if ($update_module || $create_module) {
$ff_event_normal = (int) get_parameter('ff_event_normal'); $ff_event_normal = (int) get_parameter('ff_event_normal');
$ff_event_warning = (int) get_parameter('ff_event_warning'); $ff_event_warning = (int) get_parameter('ff_event_warning');
$ff_event_critical = (int) get_parameter('ff_event_critical'); $ff_event_critical = (int) get_parameter('ff_event_critical');
$ff_type = (int) get_parameter('ff_type', $module['ff_type']); $ff_type = (int) get_parameter('ff_type');
$each_ff = (int) get_parameter('each_ff', $module['each_ff']); $each_ff = (int) get_parameter('each_ff', $module['each_ff']);
$ff_timeout = (int) get_parameter('ff_timeout'); $ff_timeout = (int) get_parameter('ff_timeout');
$unit = (string) get_parameter('unit'); $unit = (string) get_parameter('unit');

View File

@ -110,9 +110,14 @@ ui_print_standard_header(
] ]
); );
if (is_central_policies_on_node()) { if (is_management_allowed() === false) {
ui_print_warning_message( ui_print_warning_message(
__('This node is configured with centralized mode. To delete an agent go to metaconsole.') __(
'This node is configured with centralized mode. Go to %s to delete an agent',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=monitoring&sec2=monitoring/wizard/wizard'
).'">'.__('metaconsole').'</a>'
)
); );
} }
@ -912,7 +917,7 @@ if ($agents !== false) {
echo html_print_image('images/lightbulb.png', true, ['alt' => __('Disable agent'), 'title' => __('Disable agent'), 'class' => 'invert_filter']).'</a>'; echo html_print_image('images/lightbulb.png', true, ['alt' => __('Disable agent'), 'title' => __('Disable agent'), 'class' => 'invert_filter']).'</a>';
} }
if ($check_aw && !is_central_policies_on_node()) { if ($check_aw && is_management_allowed() === true) {
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente& echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
borrar_agente=".$agent['id_agente']."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'"; borrar_agente=".$agent['id_agente']."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'";

View File

@ -170,9 +170,9 @@ $checked = get_parameter('checked');
if (($policy_page) || (isset($agent))) { if (($policy_page) || (isset($agent))) {
if ($policy_page) { if ($policy_page) {
$show_creation = !is_central_policies_on_node(); $show_creation = is_management_allowed();
} else { } else {
if (!isset($all_groups)) { if (isset($all_groups) === false) {
$all_groups = agents_get_all_groups_agent( $all_groups = agents_get_all_groups_agent(
$agent['id_agente'], $agent['id_agente'],
$agent['id_grupo'] $agent['id_grupo']
@ -184,7 +184,7 @@ if (($policy_page) || (isset($agent))) {
} }
} }
if ($show_creation) { if ($show_creation === true) {
// Create module/type combo. // Create module/type combo.
echo '<form id="create_module_type" method="post" action="'.$url.'">'; echo '<form id="create_module_type" method="post" action="'.$url.'">';
if (!$policy_page) { if (!$policy_page) {

View File

@ -108,6 +108,7 @@ function add_component_selection($id_network_component_type)
$data[0] = __('Using module component').' '; $data[0] = __('Using module component').' ';
$component_groups = network_components_get_groups($id_network_component_type); $component_groups = network_components_get_groups($id_network_component_type);
$data[1] = '<span id="component_group" class="left">'; $data[1] = '<span id="component_group" class="left">';
$data[1] .= html_print_select( $data[1] .= html_print_select(
$component_groups, $component_groups,
@ -1385,7 +1386,7 @@ $(document).ready (function () {
tag_name = $(value).html(); tag_name = $(value).html();
if (tag_name != <?php echo "'".__('None')."'"; ?>) { if (tag_name != <?php echo "'".__('None')."'"; ?>) {
$("select[name='id_tag_selected[]']").append(value); $("select[name='id_tag_selected[]']").append(value);
$("#id_tag_available").find("option[value='" + id_tag + "']").remove(); $("#id_tag_available").find("option[value='" + tag_name + "']").remove();
$("#id_tag_selected").find("option[value='']").remove(); $("#id_tag_selected").find("option[value='']").remove();
if($("#id_tag_available option").length == 0) { if($("#id_tag_available option").length == 0) {
$("select[name='id_tag_available[]']").append(value); $("select[name='id_tag_available[]']").append(value);

View File

@ -213,9 +213,15 @@ if ($delete_action) {
); );
} }
if (is_central_policies_on_node() === true) { $is_management_allowed = is_management_allowed();
if ($is_management_allowed === false) {
ui_print_warning_message( ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.') __(
'This node is configured with centralized mode. All alert actions information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/alerts/alert_actions&tab=action&pure=0'
).'">'.__('metaconsole').'</a>'
)
); );
} }
@ -320,7 +326,7 @@ $table->head = [];
$table->head[0] = __('Name'); $table->head[0] = __('Name');
$table->head[1] = __('Command'); $table->head[1] = __('Command');
$table->head[2] = __('Group'); $table->head[2] = __('Group');
if (is_central_policies_on_node() === false) { if (is_management_allowed() === true) {
$table->head[3] = __('Copy'); $table->head[3] = __('Copy');
$table->head[4] = __('Delete'); $table->head[4] = __('Delete');
} }
@ -337,7 +343,7 @@ $table->align[3] = 'left';
$table->align[4] = 'left'; $table->align[4] = 'left';
$filter = []; $filter = [];
if (!is_user_admin($config['id_user']) && $group === 0) { if (!is_user_admin($config['id_user'])) {
$filter['talert_actions.id_group'] = array_keys( $filter['talert_actions.id_group'] = array_keys(
users_get_groups(false, 'LM') users_get_groups(false, 'LM')
); );
@ -406,7 +412,7 @@ foreach ($actions as $action) {
$data[3] = ''; $data[3] = '';
$data[4] = ''; $data[4] = '';
if (is_central_policies_on_node() === false if (is_management_allowed() === true
&& check_acl($config['id_user'], $action['id_group'], 'LM') && check_acl($config['id_user'], $action['id_group'], 'LM')
) { ) {
$table->cellclass[] = [ $table->cellclass[] = [
@ -459,7 +465,7 @@ if (isset($data)) {
ui_print_info_message(['no_close' => true, 'message' => __('No alert actions configured') ]); ui_print_info_message(['no_close' => true, 'message' => __('No alert actions configured') ]);
} }
if (is_central_policies_on_node() === false) { if (is_management_allowed() === true) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&pure='.$pure.'">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&pure='.$pure.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');

View File

@ -48,7 +48,11 @@ if (is_ajax()) {
$id = (int) get_parameter('id', 0); $id = (int) get_parameter('id', 0);
$get_recovery_fields = (int) get_parameter('get_recovery_fields', 1); $get_recovery_fields = (int) get_parameter('get_recovery_fields', 1);
$is_central_policies_on_node = is_central_policies_on_node(); // Snmp alerts are not in the metaconsole so they cannot be centralized.
$is_management_allowed = false;
if ($get_recovery_fields !== 0) {
$is_management_allowed = !is_management_allowed();
}
// If command ID is not provided, check for action id. // If command ID is not provided, check for action id.
if ($id == 0) { if ($id == 0) {
@ -144,7 +148,7 @@ if (is_ajax()) {
0, 0,
'', '',
false, false,
$is_central_policies_on_node, $is_management_allowed,
"removeTinyMCE('textarea_field".$i."_value')", "removeTinyMCE('textarea_field".$i."_value')",
'', '',
true true
@ -156,7 +160,7 @@ if (is_ajax()) {
0, 0,
'', '',
true, true,
$is_central_policies_on_node, $is_management_allowed,
"addTinyMCE('textarea_field".$i."_value')", "addTinyMCE('textarea_field".$i."_value')",
'', '',
true true
@ -171,7 +175,7 @@ if (is_ajax()) {
'class="fields"', 'class="fields"',
true, true,
'', '',
$is_central_policies_on_node $is_management_allowed
); );
$editor_type_chkbx = '<div id="command_div"><b><small>'; $editor_type_chkbx = '<div id="command_div"><b><small>';
@ -181,7 +185,7 @@ if (is_ajax()) {
0, 0,
'', '',
false, false,
$is_central_policies_on_node, $is_management_allowed,
"removeTinyMCE('textarea_field".$i."_recovery_value')", "removeTinyMCE('textarea_field".$i."_recovery_value')",
'', '',
true true
@ -193,7 +197,7 @@ if (is_ajax()) {
0, 0,
'', '',
true, true,
$is_central_policies_on_node, $is_management_allowed,
"addTinyMCE('textarea_field".$i."_recovery_value')", "addTinyMCE('textarea_field".$i."_recovery_value')",
'', '',
true true
@ -208,7 +212,7 @@ if (is_ajax()) {
'class="fields_recovery"', 'class="fields_recovery"',
true, true,
'', '',
$is_central_policies_on_node $is_management_allowed
); );
} else if (preg_match('/^_content_type_$/i', $field_value)) { } else if (preg_match('/^_content_type_$/i', $field_value)) {
$editor_type_chkbx = '<div id="command_div"><b><small>'; $editor_type_chkbx = '<div id="command_div"><b><small>';
@ -222,7 +226,7 @@ if (is_ajax()) {
'text/plain', 'text/plain',
'', '',
'', '',
$is_central_policies_on_node, $is_management_allowed,
'', '',
'', '',
true true
@ -234,7 +238,7 @@ if (is_ajax()) {
'text/html', 'text/html',
'', '',
'text/html', 'text/html',
$is_central_policies_on_node, $is_management_allowed,
'', '',
'', '',
true true
@ -253,7 +257,7 @@ if (is_ajax()) {
'text/plain', 'text/plain',
'', '',
'', '',
$is_central_policies_on_node, $is_management_allowed,
'', '',
'', '',
true true
@ -265,7 +269,7 @@ if (is_ajax()) {
'text/html', 'text/html',
'', '',
'text/html', 'text/html',
$is_central_policies_on_node, $is_management_allowed,
'', '',
'', '',
true true
@ -301,7 +305,7 @@ if (is_ajax()) {
false, false,
false, false,
'fields', 'fields',
$is_central_policies_on_node $is_management_allowed
); );
$rfield .= html_print_select( $rfield .= html_print_select(
@ -315,7 +319,7 @@ if (is_ajax()) {
false, false,
false, false,
'fields', 'fields',
$is_central_policies_on_node $is_management_allowed
); );
$ffield .= html_print_input_text('field'.$i.'_value[]', '', '', 10, 10, true, false, false, '', 'datepicker'); $ffield .= html_print_input_text('field'.$i.'_value[]', '', '', 10, 10, true, false, false, '', 'datepicker');
@ -329,7 +333,7 @@ if (is_ajax()) {
'style="min-height:40px; '.$style.'" class="fields"', 'style="min-height:40px; '.$style.'" class="fields"',
true, true,
'', '',
$is_central_policies_on_node $is_management_allowed
); );
@ -341,7 +345,7 @@ if (is_ajax()) {
'style="min-height:40px; '.$style.'" class="fields_recovery', 'style="min-height:40px; '.$style.'" class="fields_recovery',
true, true,
'', '',
$is_central_policies_on_node $is_management_allowed
); );
} else { } else {
$fields_value_select = []; $fields_value_select = [];
@ -375,7 +379,7 @@ if (is_ajax()) {
false, false,
false, false,
'fields', 'fields',
$is_central_policies_on_node $is_management_allowed
); );
$rfield = html_print_select( $rfield = html_print_select(
$fields_value_select, $fields_value_select,
@ -388,7 +392,7 @@ if (is_ajax()) {
false, false,
false, false,
'fields_recovery', 'fields_recovery',
$is_central_policies_on_node $is_management_allowed
); );
} else { } else {
$ffield = html_print_textarea( $ffield = html_print_textarea(
@ -399,7 +403,7 @@ if (is_ajax()) {
'style="'.$style.'" class="fields min-height-40px"', 'style="'.$style.'" class="fields min-height-40px"',
true, true,
'', '',
$is_central_policies_on_node $is_management_allowed
); );
$rfield = html_print_textarea( $rfield = html_print_textarea(
'field'.$i.'_recovery_value', 'field'.$i.'_recovery_value',
@ -409,7 +413,7 @@ if (is_ajax()) {
'style="'.$style.'" class="fields_recovery min-height-40px', 'style="'.$style.'" class="fields_recovery min-height-40px',
true, true,
'', '',
$is_central_policies_on_node $is_management_allowed
); );
} }
} }
@ -422,7 +426,7 @@ if (is_ajax()) {
'style="'.$style.'" class="fields min-height-40px"', 'style="'.$style.'" class="fields min-height-40px"',
true, true,
'', '',
$is_central_policies_on_node $is_management_allowed
); );
$rfield = html_print_textarea( $rfield = html_print_textarea(
'field'.$i.'_recovery_value', 'field'.$i.'_recovery_value',
@ -432,7 +436,7 @@ if (is_ajax()) {
'style="'.$style.'" class="fields_recovery min-height-40px"', 'style="'.$style.'" class="fields_recovery min-height-40px"',
true, true,
'', '',
$is_central_policies_on_node $is_management_allowed
); );
} }
@ -610,11 +614,15 @@ if ($copy_command) {
} }
} }
$is_central_policies_on_node = is_central_policies_on_node(); $is_management_allowed = is_management_allowed();
if ($is_management_allowed === false) {
if ($is_central_policies_on_node === true) {
ui_print_warning_message( ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.') __(
'This node is configured with centralized mode. All alert commands information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/alerts/alert_commands&tab=command&pure=0'
).'">'.__('metaconsole').'</a>'
)
); );
} }
@ -682,7 +690,7 @@ foreach ($commands as $command) {
$table->cellclass[]['action'] = 'action_buttons'; $table->cellclass[]['action'] = 'action_buttons';
// (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group. // (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group.
if ($is_central_policies_on_node === false && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) { if ($is_management_allowed === true && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) {
if (check_acl($config['id_user'], 0, 'PM') || is_user_admin( if (check_acl($config['id_user'], 0, 'PM') || is_user_admin(
$config['id_user $config['id_user
'] ']
@ -714,7 +722,7 @@ if (isset($data) === true && count($table->data) > 0) {
); );
} }
if ($is_central_policies_on_node === false && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) { if ($is_management_allowed === true && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');

View File

@ -259,9 +259,14 @@ if ($delete_template) {
); );
} }
if (is_central_policies_on_node() === true) { if (is_management_allowed() === false) {
ui_print_warning_message( ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.') __(
'This node is configured with centralized mode. All alert templates information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/alerts/alert_templates&tab=template'
).'">'.__('metaconsole').'</a>'
)
); );
} }
@ -409,7 +414,7 @@ foreach ($templates as $template) {
$data[1] = ui_print_group_icon($template['id_group'], true); $data[1] = ui_print_group_icon($template['id_group'], true);
$data[3] = alerts_get_alert_templates_type_name($template['type']); $data[3] = alerts_get_alert_templates_type_name($template['type']);
if (is_central_policies_on_node() === false if (is_management_allowed() === true
&& check_acl($config['id_user'], $template['id_group'], 'LM') && check_acl($config['id_user'], $template['id_group'], 'LM')
) { ) {
$table->cellclass[][4] = 'action_buttons'; $table->cellclass[][4] = 'action_buttons';
@ -469,7 +474,7 @@ if (isset($data) === true) {
); );
} }
if (is_central_policies_on_node() === false) { if (is_management_allowed() === true) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');

View File

@ -101,11 +101,16 @@ if (!$is_in_group && $al_action['id_group'] != 0) {
exit; exit;
} }
$is_central_policies_on_node = is_central_policies_on_node(); $is_management_allowed = is_management_allowed();
if ($is_central_policies_on_node === true) { if ($is_management_allowed === false) {
ui_print_warning_message( ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.') __(
'This node is configured with centralized mode. All alert actions information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/alerts/configure_alert_action&tab=action&pure=0&id='.$id
).'">'.__('metaconsole').'</a>'
)
); );
} }
@ -178,7 +183,7 @@ $table->data[0][1] = html_print_input_text(
'', '',
'', '',
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
if (io_safe_output($name) == 'Monitoring Event') { if (io_safe_output($name) == 'Monitoring Event') {
@ -214,7 +219,7 @@ $table->data[1][1] = '<div class="w250px inline">'.html_print_select_groups(
false, false,
true, true,
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
).'</div>'; ).'</div>';
$table->colspan[1][1] = 2; $table->colspan[1][1] = 2;
@ -248,10 +253,10 @@ $table->data[2][1] = html_print_select_from_sql(
true, true,
false, false,
false, false,
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[2][1] .= ' '; $table->data[2][1] .= ' ';
if ($is_central_policies_on_node === false if ($is_management_allowed === true
&& check_acl($config['id_user'], 0, 'PM') && !$disabled && check_acl($config['id_user'], 0, 'PM') && !$disabled
) { ) {
$table->data[2][1] .= __('Create Command'); $table->data[2][1] .= __('Create Command');
@ -275,7 +280,7 @@ $table->data[3][1] = html_print_extended_select_for_time(
false, false,
true, true,
'', '',
($is_central_policies_on_node | $disabled), (!$is_management_allowed | $disabled),
false, false,
'', '',
false, false,
@ -359,7 +364,7 @@ echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/ale
$table_html = html_print_table($table, true); $table_html = html_print_table($table, true);
echo $table_html; echo $table_html;
if ($is_central_policies_on_node === false) { if ($is_management_allowed === true) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) { if ($id) {
html_print_input_hidden('id', $id); html_print_input_hidden('id', $id);

View File

@ -105,6 +105,7 @@ if ($update_command) {
$alert['command'] = $command; $alert['command'] = $command;
$alert['description'] = $description; $alert['description'] = $description;
$alert['id_group'] = $id_group; $alert['id_group'] = $id_group;
$alert['fields_hidden'] = io_json_mb_encode($fields_hidden);
} }
} }
@ -155,11 +156,16 @@ if (empty($fields_hidden) === false) {
} }
$is_central_policies_on_node = is_central_policies_on_node(); $is_management_allowed = is_management_allowed();
if ($is_central_policies_on_node === true) { if ($is_management_allowed === false) {
ui_print_warning_message( ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.') __(
'This node is configured with centralized mode. All alert commands information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/alerts/configure_alert_command&pure=0&id='.$id
).'">'.__('metaconsole').'</a>'
)
); );
} }
@ -203,7 +209,7 @@ $table->data['name'][2] = html_print_input_text(
'', '',
'', '',
'', '',
$is_central_policies_on_node !$is_management_allowed
); );
$table->colspan['command'][1] = 3; $table->colspan['command'][1] = 3;
@ -216,7 +222,7 @@ $table->data['command'][1] = html_print_textarea(
'', '',
true, true,
'', '',
$is_central_policies_on_node !$is_management_allowed
); );
$return_all_group = false; $return_all_group = false;
@ -240,7 +246,7 @@ $table->data['group'][1] = '<div class="w250px inline">'.html_print_select_group
false, false,
true, true,
'', '',
$is_central_policies_on_node !$is_management_allowed
).'</div>'; ).'</div>';
$table->colspan['description'][1] = 3; $table->colspan['description'][1] = 3;
@ -253,7 +259,7 @@ $table->data['description'][1] = html_print_textarea(
'', '',
true, true,
'', '',
$is_central_policies_on_node !$is_management_allowed
); );
@ -283,7 +289,7 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
'', '',
'', '',
'', '',
$is_central_policies_on_node !$is_management_allowed
); );
$table->data['field'.$i][2] = sprintf(__('Field %s values'), $i); $table->data['field'.$i][2] = sprintf(__('Field %s values'), $i);
@ -321,7 +327,7 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
'', '',
'', '',
'', '',
$is_central_policies_on_node !$is_management_allowed
); );
$table->data['field'.$i][4] = __('Hide'); $table->data['field'.$i][4] = __('Hide');
@ -330,7 +336,7 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
'field'.$i.'_hide', 'field'.$i.'_hide',
1, 1,
$selected, $selected,
$is_central_policies_on_node, !$is_management_allowed,
'cursor: \'pointer\'', 'cursor: \'pointer\'',
'class="hide_inputs"', 'class="hide_inputs"',
true true
@ -340,7 +346,7 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/alert_commands&pure='.$pure.'">'; echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/alert_commands&pure='.$pure.'">';
html_print_table($table); html_print_table($table);
if ($is_central_policies_on_node === false) { if ($is_management_allowed === true) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) { if ($id) {
html_print_input_hidden('id', $id); html_print_input_hidden('id', $id);

View File

@ -36,7 +36,9 @@ $id = (int) get_parameter('id');
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
$step = (int) get_parameter('step', 1); $step = (int) get_parameter('step', 1);
// We set here the number of steps. // We set here the number of steps.
define('LAST_STEP', 3); if (defined('LAST_STEP') === false) {
define('LAST_STEP', 3);
}
if ($duplicate_template) { if ($duplicate_template) {
$source_id = (int) get_parameter('source_id'); $source_id = (int) get_parameter('source_id');
@ -368,17 +370,19 @@ function update_template($step)
} }
$is_central_policies_on_node = is_central_policies_on_node(); $is_management_allowed = is_management_allowed();
if ($is_central_policies_on_node === true) { if ($is_management_allowed === false) {
ui_print_warning_message( ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.') __(
'This node is configured with centralized mode. All alerts templates information is read only. Go to Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/alerts/configure_alert_template&pure=0&id='.$id.'&step='.$step
).'">'.__('metaconsole').'</a>'
)
); );
} }
// We set here the number of steps.
define('LAST_STEP', 3);
$step = (int) get_parameter('step', 1); $step = (int) get_parameter('step', 1);
$create_alert = (bool) get_parameter('create_alert'); $create_alert = (bool) get_parameter('create_alert');
@ -609,7 +613,7 @@ if ($step == 2) {
1, 1,
$monday, $monday,
true, true,
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[0][1] .= __('Tue'); $table->data[0][1] .= __('Tue');
$table->data[0][1] .= html_print_checkbox( $table->data[0][1] .= html_print_checkbox(
@ -617,7 +621,7 @@ if ($step == 2) {
1, 1,
$tuesday, $tuesday,
true, true,
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[0][1] .= __('Wed'); $table->data[0][1] .= __('Wed');
$table->data[0][1] .= html_print_checkbox( $table->data[0][1] .= html_print_checkbox(
@ -625,7 +629,7 @@ if ($step == 2) {
1, 1,
$wednesday, $wednesday,
true, true,
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[0][1] .= __('Thu'); $table->data[0][1] .= __('Thu');
$table->data[0][1] .= html_print_checkbox( $table->data[0][1] .= html_print_checkbox(
@ -633,7 +637,7 @@ if ($step == 2) {
1, 1,
$thursday, $thursday,
true, true,
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[0][1] .= __('Fri'); $table->data[0][1] .= __('Fri');
$table->data[0][1] .= html_print_checkbox( $table->data[0][1] .= html_print_checkbox(
@ -641,7 +645,7 @@ if ($step == 2) {
1, 1,
$friday, $friday,
true, true,
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[0][1] .= __('Sat'); $table->data[0][1] .= __('Sat');
$table->data[0][1] .= html_print_checkbox( $table->data[0][1] .= html_print_checkbox(
@ -649,7 +653,7 @@ if ($step == 2) {
1, 1,
$saturday, $saturday,
true, true,
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[0][1] .= __('Sun'); $table->data[0][1] .= __('Sun');
$table->data[0][1] .= html_print_checkbox( $table->data[0][1] .= html_print_checkbox(
@ -657,7 +661,7 @@ if ($step == 2) {
1, 1,
$sunday, $sunday,
true, true,
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[0][2] = __('Use special days list'); $table->data[0][2] = __('Use special days list');
@ -666,7 +670,7 @@ if ($step == 2) {
1, 1,
$special_day, $special_day,
true, true,
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[1][0] = __('Time from'); $table->data[1][0] = __('Time from');
@ -687,7 +691,7 @@ if ($step == 2) {
'', '',
'', '',
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[1][2] = __('Time to'); $table->data[1][2] = __('Time to');
$table->data[1][3] = html_print_input_text( $table->data[1][3] = html_print_input_text(
@ -707,7 +711,7 @@ if ($step == 2) {
'', '',
'', '',
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->colspan['threshold'][1] = 3; $table->colspan['threshold'][1] = 3;
@ -723,7 +727,7 @@ if ($step == 2) {
false, false,
true, true,
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[3][0] = __('Min. number of alerts'); $table->data[3][0] = __('Min. number of alerts');
@ -744,7 +748,7 @@ if ($step == 2) {
'', '',
'', '',
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[3][2] = __('Reset counter for non-sustained alerts'); $table->data[3][2] = __('Reset counter for non-sustained alerts');
@ -757,7 +761,7 @@ if ($step == 2) {
1, 1,
$min_alerts_reset_counter, $min_alerts_reset_counter,
true, true,
($is_central_policies_on_node | $disabled), (!$is_management_allowed | $disabled),
'', '',
false, false,
$create_template == 1 ? 'checked=checked' : '' $create_template == 1 ? 'checked=checked' : ''
@ -781,7 +785,7 @@ if ($step == 2) {
'', '',
'', '',
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[4][2] = __('Disable event'); $table->data[4][2] = __('Disable event');
@ -790,7 +794,7 @@ if ($step == 2) {
1, 1,
$disable_event, $disable_event,
true, true,
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[5][0] = __('Default action'); $table->data[5][0] = __('Default action');
@ -818,7 +822,7 @@ if ($step == 2) {
true, true,
false, false,
false, false,
($is_central_policies_on_node | $disabled), (!$is_management_allowed | $disabled),
false, false,
false, false,
0 0
@ -840,7 +844,7 @@ if ($step == 2) {
false, false,
false, false,
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[6][1] .= '<span id="matches_value" '.($show_matches ? '' : 'class="invisible"').'>'; $table->data[6][1] .= '<span id="matches_value" '.($show_matches ? '' : 'class="invisible"').'>';
$table->data[6][1] .= '&nbsp;'.html_print_checkbox('matches_value', 1, $matches, true); $table->data[6][1] .= '&nbsp;'.html_print_checkbox('matches_value', 1, $matches, true);
@ -949,7 +953,7 @@ if ($step == 2) {
false, false,
false, false,
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->colspan[0][1] = 2; $table->colspan[0][1] = 2;
@ -975,7 +979,7 @@ if ($step == 2) {
0, 0,
'', '',
false, false,
($is_central_policies_on_node | $disabled), (!$is_management_allowed | $disabled),
"removeTinyMCE('textarea_field".$i."')", "removeTinyMCE('textarea_field".$i."')",
'', '',
true true
@ -988,7 +992,7 @@ if ($step == 2) {
0, 0,
'', '',
true, true,
($is_central_policies_on_node | $disabled), (!$is_management_allowed | $disabled),
"addTinyMCE('textarea_field".$i."')", "addTinyMCE('textarea_field".$i."')",
'', '',
true true
@ -1004,7 +1008,7 @@ if ($step == 2) {
'class="fields" min-height-40px', 'class="fields" min-height-40px',
true, true,
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
// Recovery. // Recovery.
@ -1016,7 +1020,7 @@ if ($step == 2) {
0, 0,
'', '',
false, false,
($is_central_policies_on_node | $disabled), (!$is_management_allowed | $disabled),
"removeTinyMCE('textarea_field".$i."_recovery')", "removeTinyMCE('textarea_field".$i."_recovery')",
'', '',
true true
@ -1029,7 +1033,7 @@ if ($step == 2) {
0, 0,
'', '',
true, true,
($is_central_policies_on_node | $disabled), (!$is_management_allowed | $disabled),
"addTinyMCE('textarea_field".$i."_recovery')", "addTinyMCE('textarea_field".$i."_recovery')",
'', '',
true true
@ -1045,7 +1049,7 @@ if ($step == 2) {
'class="fields min-height-40px"', 'class="fields min-height-40px"',
true, true,
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
} }
} else { } else {
@ -1102,7 +1106,7 @@ if ($step == 2) {
'', '',
'', '',
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
@ -1134,7 +1138,7 @@ if ($step == 2) {
false, false,
true, true,
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
).'</div>'; ).'</div>';
@ -1147,7 +1151,7 @@ if ($step == 2) {
'', '',
true, true,
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
$table->data[2][0] = __('Priority'); $table->data[2][0] = __('Priority');
@ -1162,7 +1166,7 @@ if ($step == 2) {
false, false,
false, false,
'', '',
($is_central_policies_on_node | $disabled) (!$is_management_allowed | $disabled)
); );
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
@ -1200,7 +1204,7 @@ if ($id) {
} }
if (!$disabled) { if (!$disabled) {
if ($is_central_policies_on_node === false) { if ($is_management_allowed === true) {
if ($step >= LAST_STEP) { if ($step >= LAST_STEP) {
html_print_submit_button( html_print_submit_button(
__('Finish'), __('Finish'),

View File

@ -1,40 +1,55 @@
<?php <?php
/**
* Category.
*
* @category Category
* @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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Load global vars.
// ==================================================
// 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.
// Load global vars
global $config; global $config;
// Check login and ACLs // Check login and ACLs.
check_login(); check_login();
enterprise_hook('open_meta_frame'); enterprise_hook('open_meta_frame');
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) { if (!check_acl($config['id_user'], 0, 'PM') && !is_user_admin($config['id_user'])) {
db_pandora_audit('ACL Violation', 'Trying to access Categories Management'); db_pandora_audit('ACL Violation', 'Trying to access Categories Management');
include 'general/noaccess.php'; include 'general/noaccess.php';
return; return;
} }
// Include functions code // Include functions code.
require_once $config['homedir'].'/include/functions_categories.php'; require_once $config['homedir'].'/include/functions_categories.php';
// Get parameters // Get parameters.
$delete = (int) get_parameter('delete_category', 0); $delete = (int) get_parameter('delete_category', 0);
$search = (int) get_parameter('search_category', 0); $search = (int) get_parameter('search_category', 0);
$category_name = (string) get_parameter('category_name', ''); $category_name = (string) get_parameter('category_name', '');
$tab = (string) get_parameter('tab', 'list'); $tab = (string) get_parameter('tab', 'list');
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
$buttons = [ $buttons = [
'list' => [ 'list' => [
'active' => false, 'active' => false,
@ -66,34 +81,47 @@ if (defined('METACONSOLE')) {
$buttons[$tab]['active'] = true; $buttons[$tab]['active'] = true;
// Header // Header.
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
ui_meta_print_header(__('Categories configuration'), __('List'), $buttons); ui_meta_print_header(__('Categories configuration'), __('List'), $buttons);
} else { } else {
ui_print_page_header(__('Categories configuration'), 'images/gm_modules.png', false, '', true, $buttons); ui_print_page_header(__('Categories configuration'), 'images/gm_modules.png', false, '', true, $buttons);
} }
$is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
ui_print_warning_message(
__(
'This node is configured with centralized mode. All categories information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/category/category&tab=list&pure='.(int) $config['pure']
).'">'.__('metaconsole').'</a>'
)
);
}
// Two actions can performed in this page: search and delete categories // Two actions can performed in this page: search and delete categories
// Delete action: This will delete a category // Delete action: This will delete a category.
if ($delete != 0) { if ($is_management_allowed === true && $delete != 0) {
$return_delete = categories_delete_category($delete); $return_delete = categories_delete_category($delete);
if (!$return_delete) { if (!$return_delete) {
db_pandora_audit('Category management', "Fail try to delete category #$delete"); db_pandora_audit('Category management', 'Fail try to delete category #'.$delete);
ui_print_error_message(__('Error deleting category')); ui_print_error_message(__('Error deleting category'));
} else { } else {
db_pandora_audit('Category management', "Delete category #$delete"); db_pandora_audit('Category management', 'Delete category #'.$delete);
ui_print_success_message(__('Successfully deleted category')); ui_print_success_message(__('Successfully deleted category'));
} }
} }
// statements for pagination // Statements for pagination.
$url = ui_get_url_refresh(); $url = ui_get_url_refresh();
$total_categories = categories_get_category_count(); $total_categories = categories_get_category_count();
$filter['offset'] = (int) get_parameter('offset'); $filter['offset'] = (int) get_parameter('offset');
$filter['limit'] = (int) $config['block_size']; $filter['limit'] = (int) $config['block_size'];
// Search action: This will filter the display category view // Search action: This will filter the display category view.
$result = false; $result = false;
$result = db_get_all_rows_filter( $result = db_get_all_rows_filter(
@ -104,12 +132,12 @@ $result = db_get_all_rows_filter(
] ]
); );
// Display categories previously filtered or not // Display categories previously filtered or not.
$rowPair = true; $rowPair = true;
$iterator = 0; $iterator = 0;
if (!empty($result)) { if (empty($result) === false) {
// Prepare pagination // Prepare pagination.
ui_pagination($total_categories, $url); ui_pagination($total_categories, $url);
$table = new stdClass(); $table = new stdClass();
@ -123,7 +151,9 @@ if (!empty($result)) {
$table->style[0] = 'font-weight: bold; text-align:left'; $table->style[0] = 'font-weight: bold; text-align:left';
$table->style[1] = 'text-align:center; width: 100px;'; $table->style[1] = 'text-align:center; width: 100px;';
$table->head[0] = __('Category name'); $table->head[0] = __('Category name');
if ($is_management_allowed === true) {
$table->head[1] = __('Actions'); $table->head[1] = __('Actions');
}
foreach ($result as $category) { foreach ($result as $category) {
if ($rowPair) { if ($rowPair) {
@ -137,7 +167,7 @@ if (!empty($result)) {
$data = []; $data = [];
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
$data[0] = "<a href='index.php?sec=advanced&sec2=godmode/category/edit_category&action=update&id_category=".$category['id'].'&pure='.(int) $config['pure']."'>".$category['name'].'</a>'; $data[0] = "<a href='index.php?sec=advanced&sec2=godmode/category/edit_category&action=update&id_category=".$category['id'].'&pure='.(int) $config['pure']."'>".$category['name'].'</a>';
$data[1] = "<a href='index.php?sec=advanced&sec2=godmode/category/edit_category&action=update&id_category=".$category['id'].'&pure='.(int) $config['pure']."'>".html_print_image( $data[1] = "<a href='index.php?sec=advanced&sec2=godmode/category/edit_category&action=update&id_category=".$category['id'].'&pure='.(int) $config['pure']."'>".html_print_image(
'images/config.png', 'images/config.png',
@ -150,7 +180,13 @@ if (!empty($result)) {
['title' => 'Delete'] ['title' => 'Delete']
).'</a>'; ).'</a>';
} else { } else {
if ($is_management_allowed === true) {
$data[0] = "<a href='index.php?sec=gmodules&sec2=godmode/category/edit_category&action=update&id_category=".$category['id'].'&pure='.(int) $config['pure']."'>".$category['name'].'</a>'; $data[0] = "<a href='index.php?sec=gmodules&sec2=godmode/category/edit_category&action=update&id_category=".$category['id'].'&pure='.(int) $config['pure']."'>".$category['name'].'</a>';
} else {
$data[0] = $category['name'];
}
if ($is_management_allowed === true) {
$table->cellclass[][1] = 'action_buttons'; $table->cellclass[][1] = 'action_buttons';
$data[1] = "<a href='index.php?sec=gmodules&sec2=godmode/category/edit_category&action=update&id_category=".$category['id'].'&pure='.(int) $config['pure']."'>".html_print_image( $data[1] = "<a href='index.php?sec=gmodules&sec2=godmode/category/edit_category&action=update&id_category=".$category['id'].'&pure='.(int) $config['pure']."'>".html_print_image(
'images/config.png', 'images/config.png',
@ -163,6 +199,7 @@ if (!empty($result)) {
['title' => 'Delete'] ['title' => 'Delete']
).'</a>'; ).'</a>';
} }
}
array_push($table->data, $data); array_push($table->data, $data);
} }
@ -170,21 +207,23 @@ if (!empty($result)) {
html_print_table($table); html_print_table($table);
ui_pagination($total_categories, $url, $offset, 0, false, 'offset', true, 'pagination-bottom'); ui_pagination($total_categories, $url, $offset, 0, false, 'offset', true, 'pagination-bottom');
} else { } else {
// No categories available or selected // No categories available or selected.
ui_print_info_message(['no_close' => true, 'message' => __('No categories found') ]); ui_print_info_message(['no_close' => true, 'message' => __('No categories found') ]);
} }
// Form to add new categories or search categories if ($is_management_allowed === true) {
echo "<div class='w100p right_align'>"; // Form to add new categories or search categories.
if (defined('METACONSOLE')) { echo "<div class='w100p right_align'>";
if (is_metaconsole() === true) {
echo '<form method="post" action="index.php?sec=advanced&sec2=godmode/category/edit_category&action=new&pure='.(int) $config['pure'].'">'; echo '<form method="post" action="index.php?sec=advanced&sec2=godmode/category/edit_category&action=new&pure='.(int) $config['pure'].'">';
} else { } else {
echo '<form method="post" action="index.php?sec=gmodules&sec2=godmode/category/edit_category&action=new&pure='.(int) $config['pure'].'">'; echo '<form method="post" action="index.php?sec=gmodules&sec2=godmode/category/edit_category&action=new&pure='.(int) $config['pure'].'">';
} }
html_print_input_hidden('create_category', '1', true); html_print_input_hidden('create_category', '1', true);
html_print_submit_button(__('Create category'), 'create_button', false, 'class="sub next"'); html_print_submit_button(__('Create category'), 'create_button', false, 'class="sub next"');
echo '</form>'; echo '</form>';
echo '</div>'; echo '</div>';
enterprise_hook('close_meta_frame'); enterprise_hook('close_meta_frame');
}

View File

@ -263,15 +263,7 @@ if (defined('METACONSOLE')) {
$sec = 'gagente'; $sec = 'gagente';
} }
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'].'" >';
if (isset($config['metaconsole_agent_cache']) && $config['metaconsole_agent_cache'] == 1) {
$confirm_bottom = " onsubmit=' return message_check_create();'";
}
} else {
$confirm_bottom = '';
}
echo '<form name="grupo" method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/group_list&pure='.$config['pure'].'"'.$confirm_bottom.' >';
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_button(__('Back'), 'button_back', false, '', 'class="sub cancel"'); html_print_button(__('Back'), 'button_back', false, '', 'class="sub cancel"');
@ -291,15 +283,6 @@ enterprise_hook('close_meta_frame');
?> ?>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
function message_check_create() {
var return_value = false;
return_value = confirm("<?php echo __("WARNING: You\'re trying to create a group in a node member of a metaconsole.\\n\\nThis group and all of this contents will not be visible in the metaconsole.\\n\\nIf you want to create a visible group, you must do it from the metaconsole and propagate to the node. "); ?>");
return return_value;
}
function icon_changed () { function icon_changed () {
var inputs = []; var inputs = [];
var data = this.value; var data = this.value;

View File

@ -379,6 +379,19 @@ if (is_metaconsole() === true) {
); );
} }
$is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
ui_print_warning_message(
__(
'This node is configured with centralized mode. All groups information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/groups/group_list&tab=groups'
).'">'.__('metaconsole').'</a>'
)
);
}
// Load credential store view before parse list-tree forms. // Load credential store view before parse list-tree forms.
if ($tab == 'credbox') { if ($tab == 'credbox') {
include_once __DIR__.'/credential_store.php'; include_once __DIR__.'/credential_store.php';
@ -392,7 +405,10 @@ $delete_group = (bool) get_parameter('delete_group');
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
// Create group. // Create group.
if (($create_group) && ((bool) check_acl($config['id_user'], 0, 'PM') === true)) { if ($is_management_allowed === true
&& $create_group === true
&& ((bool) check_acl($config['id_user'], 0, 'PM') === true)
) {
$name = (string) get_parameter('name'); $name = (string) get_parameter('name');
$icon = (string) get_parameter('icon'); $icon = (string) get_parameter('icon');
$id_parent = (int) get_parameter('id_parent'); $id_parent = (int) get_parameter('id_parent');
@ -448,7 +464,7 @@ if (($create_group) && ((bool) check_acl($config['id_user'], 0, 'PM') === true))
} }
// Update group. // Update group.
if ($update_group) { if ($is_management_allowed === true && $update_group === true) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
$name = (string) get_parameter('name'); $name = (string) get_parameter('name');
$icon = (string) get_parameter('icon'); $icon = (string) get_parameter('icon');
@ -520,7 +536,10 @@ if ($update_group) {
} }
// Delete group. // Delete group.
if (($delete_group) && ((bool) check_acl($config['id_user'], 0, 'PM') === true)) { if ($is_management_allowed === true
&& $delete_group === true
&& ((bool) check_acl($config['id_user'], 0, 'PM') === true)
) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
$usedGroup = groups_check_used($id_group); $usedGroup = groups_check_used($id_group);
@ -701,7 +720,6 @@ if (($delete_group) && ((bool) check_acl($config['id_user'], 0, 'PM') === true))
} }
} }
// Credential store is loaded previously in this document to avoid // Credential store is loaded previously in this document to avoid
// process group tree - list forms. // process group tree - list forms.
if ($tab == 'tree') { if ($tab == 'tree') {
@ -817,15 +835,24 @@ if ($tab == 'tree') {
$table->headstyle[4] = 'min-width: 100px;'; $table->headstyle[4] = 'min-width: 100px;';
$table->head[5] = __('Description'); $table->head[5] = __('Description');
$table->headstyle[5] = 'min-width: 100px;'; $table->headstyle[5] = 'min-width: 100px;';
if ($is_management_allowed === true) {
$table->head[6] = __('Actions'); $table->head[6] = __('Actions');
$table->headstyle[6] = 'min-width: 100px;'; $table->headstyle[6] = 'min-width: 100px;';
}
$table->align = []; $table->align = [];
$table->align[0] = 'left'; $table->align[0] = 'left';
$table->align[2] = 'left'; $table->align[2] = 'left';
if ($is_management_allowed === true) {
$table->align[6] = 'left'; $table->align[6] = 'left';
}
$table->size[0] = '3%'; $table->size[0] = '3%';
$table->size[5] = '30%'; $table->size[5] = '30%';
if ($is_management_allowed === true) {
$table->size[6] = '5%'; $table->size[6] = '5%';
}
$table->data = []; $table->data = [];
foreach ($groups as $key => $group) { foreach ($groups as $key => $group) {
@ -837,7 +864,12 @@ if ($tab == 'tree') {
} }
$table->data[$key][0] = $group['id_grupo']; $table->data[$key][0] = $group['id_grupo'];
if ($is_management_allowed === true) {
$table->data[$key][1] = '<a href="'.$url.'">'.$group['nombre'].'</a>'; $table->data[$key][1] = '<a href="'.$url.'">'.$group['nombre'].'</a>';
} else {
$table->data[$key][1] = $group['nombre'];
}
if ($group['icon'] != '') { if ($group['icon'] != '') {
$table->data[$key][2] = html_print_image( $table->data[$key][2] = html_print_image(
'images/groups_small/'.$group['icon'].'.png', 'images/groups_small/'.$group['icon'].'.png',
@ -862,6 +894,7 @@ if ($tab == 'tree') {
$table->data[$key][3] = ($group['disabled']) ? __('Disabled') : __('Enabled'); $table->data[$key][3] = ($group['disabled']) ? __('Disabled') : __('Enabled');
$table->data[$key][4] = $group['parent_name']; $table->data[$key][4] = $group['parent_name'];
$table->data[$key][5] = $group['description']; $table->data[$key][5] = $group['description'];
if ($is_management_allowed === true) {
$table->cellclass[$key][6] = 'action_buttons'; $table->cellclass[$key][6] = 'action_buttons';
$table->data[$key][6] = '<a href="'.$url.'">'.html_print_image( $table->data[$key][6] = '<a href="'.$url.'">'.html_print_image(
'images/config.png', 'images/config.png',
@ -893,6 +926,7 @@ if ($tab == 'tree') {
] ]
).'</a>'; ).'</a>';
} }
}
echo ui_pagination( echo ui_pagination(
$groups_count, $groups_count,
@ -924,7 +958,10 @@ if ($tab == 'tree') {
} }
} }
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
if ($is_management_allowed === true
&& (bool) check_acl($config['id_user'], 0, 'PM') === true
) {
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/configure_group">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/configure_group">';
echo '<div class="action-buttons w100p">'; echo '<div class="action-buttons w100p">';
html_print_submit_button(__('Create group'), 'crt', false, 'class="sub next"'); html_print_submit_button(__('Create group'), 'crt', false, 'class="sub next"');

View File

@ -1,9 +1,8 @@
<?php <?php
/** /**
* Extension to manage a list of gateways and the node address where they should * Module Groups.
* point to.
* *
* @category Extensions * @category Module groups
* @package Pandora FMS * @package Pandora FMS
* @subpackage Community * @subpackage Community
* @version 1.0.0 * @version 1.0.0
@ -40,7 +39,7 @@ if (! check_acl($config['id_user'], 0, 'PM')) {
return; return;
} }
if (is_ajax()) { if (is_ajax() === true) {
$get_group_json = (bool) get_parameter('get_group_json'); $get_group_json = (bool) get_parameter('get_group_json');
$get_group_agents = (bool) get_parameter('get_group_agents'); $get_group_agents = (bool) get_parameter('get_group_agents');
@ -65,7 +64,7 @@ if (is_ajax()) {
return; return;
} }
if (!is_metaconsole()) { if (is_metaconsole() === false) {
// Header. // Header.
ui_print_page_header( ui_print_page_header(
__('Module groups defined in %s', get_product_name()), __('Module groups defined in %s', get_product_name()),
@ -77,12 +76,25 @@ if (!is_metaconsole()) {
); );
} }
$is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
ui_print_warning_message(
__(
'This node is configured with centralized mode. All module groups information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/component_management&tab=module_group'
).'">'.__('metaconsole').'</a>'
)
);
}
$create_group = (bool) get_parameter('create_group'); $create_group = (bool) get_parameter('create_group');
$update_group = (bool) get_parameter('update_group'); $update_group = (bool) get_parameter('update_group');
$delete_group = (bool) get_parameter('delete_group'); $delete_group = (bool) get_parameter('delete_group');
// Create group. // Create group.
if ($create_group) { if ($is_management_allowed === true && $create_group === true) {
$name = (string) get_parameter('name'); $name = (string) get_parameter('name');
$icon = (string) get_parameter('icon'); $icon = (string) get_parameter('icon');
$id_parent = (int) get_parameter('id_parent'); $id_parent = (int) get_parameter('id_parent');
@ -115,7 +127,7 @@ if ($create_group) {
} }
// Update group. // Update group.
if ($update_group) { if ($is_management_allowed === true && $update_group === true) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
$name = (string) get_parameter('name'); $name = (string) get_parameter('name');
$icon = (string) get_parameter('icon'); $icon = (string) get_parameter('icon');
@ -151,7 +163,7 @@ if ($update_group) {
} }
// Delete group. // Delete group.
if ($delete_group) { if ($is_management_allowed === true && $delete_group === true) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
$result = db_process_sql_delete('tmodule_group', ['id_mg' => $id_group]); $result = db_process_sql_delete('tmodule_group', ['id_mg' => $id_group]);
@ -217,7 +229,6 @@ $total_groups = db_get_num_rows('SELECT * FROM tmodule_group');
$url = ui_get_url_refresh(['offset' => false]); $url = ui_get_url_refresh(['offset' => false]);
$offset = (int) get_parameter('offset', 0); $offset = (int) get_parameter('offset', 0);
$sql = 'SELECT * $sql = 'SELECT *
FROM tmodule_group FROM tmodule_group
ORDER BY name ASC ORDER BY name ASC
@ -229,28 +240,40 @@ $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->class = 'info_table'; $table->class = 'info_table';
if (!empty($groups)) { if (empty($groups) === false) {
$table->head = []; $table->head = [];
$table->head[0] = __('ID'); $table->head[0] = __('ID');
$table->head[1] = __('Name'); $table->head[1] = __('Name');
if ($is_management_allowed === true) {
$table->head[2] = __('Delete'); $table->head[2] = __('Delete');
}
$table->align = []; $table->align = [];
$table->align[1] = 'left'; $table->align[1] = 'left';
if ($is_management_allowed === true) {
$table->align[2] = 'left'; $table->align[2] = 'left';
$table->size[2] = '5%'; $table->size[2] = '5%';
}
$table->data = []; $table->data = [];
foreach ($groups as $id_group) { foreach ($groups as $id_group) {
$data = []; $data = [];
$data[0] = $id_group['id_mg']; $data[0] = $id_group['id_mg'];
if ($is_management_allowed === true) {
$data[1] = '<strong><a href="index.php?sec=gmodules&sec2=godmode/groups/configure_modu_group&id_group='.$id_group['id_mg'].'">'.ui_print_truncate_text($id_group['name'], GENERIC_SIZE_TEXT).'</a></strong>'; $data[1] = '<strong><a href="index.php?sec=gmodules&sec2=godmode/groups/configure_modu_group&id_group='.$id_group['id_mg'].'">'.ui_print_truncate_text($id_group['name'], GENERIC_SIZE_TEXT).'</a></strong>';
if (is_metaconsole()) { if (is_metaconsole() === true) {
$data[2] = '<a href="index.php?sec=advanced&sec2=advanced/component_management&tab=module_group&id_group='.$id_group['id_mg'].'&delete_group=1" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['border' => '0']).'</a>'; $data[2] = '<a href="index.php?sec=advanced&sec2=advanced/component_management&tab=module_group&id_group='.$id_group['id_mg'].'&delete_group=1" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['border' => '0']).'</a>';
} else { } else {
$table->cellclass[][2] = 'action_buttons'; $table->cellclass[][2] = 'action_buttons';
$data[2] = '<a href="index.php?sec=gmodules&sec2=godmode/groups/modu_group_list&id_group='.$id_group['id_mg'].'&delete_group=1" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['border' => '0']).'</a>'; $data[2] = '<a href="index.php?sec=gmodules&sec2=godmode/groups/modu_group_list&id_group='.$id_group['id_mg'].'&delete_group=1" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['border' => '0']).'</a>';
} }
} else {
$data[1] = '<strong>';
$data[1] .= ui_print_truncate_text($id_group['name'], GENERIC_SIZE_TEXT);
$data[1] .= '</strong>';
}
array_push($table->data, $data); array_push($table->data, $data);
} }
@ -267,13 +290,15 @@ if (!empty($groups)) {
); );
} }
echo '<form method="post" action="index.php?sec=gmodules&sec2=godmode/groups/configure_modu_group">'; if ($is_management_allowed === true) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<form method="post" action="index.php?sec=gmodules&sec2=godmode/groups/configure_modu_group">';
html_print_submit_button( echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(
__('Create module group'), __('Create module group'),
'crt', 'crt',
false, false,
'class="sub next"' 'class="sub next"'
); );
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
}

View File

@ -38,6 +38,19 @@ if (!check_acl($config['id_user'], 0, 'UM')) {
return; return;
} }
if (is_management_allowed() === false) {
ui_print_warning_message(
__(
'This node is configured with centralized mode. All profiles user information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/users_setup&tab=profile&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
return;
}
require_once 'include/functions_agents.php'; require_once 'include/functions_agents.php';
require_once 'include/functions_alerts.php'; require_once 'include/functions_alerts.php';
require_once $config['homedir'].'/include/functions_profile.php'; require_once $config['homedir'].'/include/functions_profile.php';

View File

@ -201,7 +201,7 @@ $table->data[2][1] = html_print_select(
echo '<form method="post" id="form_agents" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents">'; echo '<form method="post" id="form_agents" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents">';
html_print_table($table); html_print_table($table);
if (is_central_policies_on_node() === false) { if (is_management_allowed() === true) {
attachActionButton('delete', 'delete', $table->width); attachActionButton('delete', 'delete', $table->width);
} }

View File

@ -38,6 +38,19 @@ if (! check_acl($config['id_user'], 0, 'UM')) {
return; return;
} }
if (is_management_allowed() === false) {
ui_print_warning_message(
__(
'This node is configured with centralized mode. All profiles user information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/users_setup&tab=profile&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
return;
}
require_once 'include/functions_agents.php'; require_once 'include/functions_agents.php';
require_once 'include/functions_alerts.php'; require_once 'include/functions_alerts.php';
require_once $config['homedir'].'/include/functions_profile.php'; require_once $config['homedir'].'/include/functions_profile.php';

View File

@ -845,11 +845,9 @@ echo '<h3 class="error invisible" id="message"> </h3>';
html_print_input_hidden('id_agente', $id_agente); html_print_input_hidden('id_agente', $id_agente);
if (is_central_policies_on_node() === false) { attachActionButton('update_agents', 'update', $table->width);
attachActionButton('update_agents', 'update', $table->width);
}
// Shown and hide div // Shown and hide div.
echo '</div></form>'; echo '</div></form>';
ui_require_jquery_file('form'); ui_require_jquery_file('form');

View File

@ -333,8 +333,15 @@ $agentstab = [
echo '</div>'; echo '</div>';
} }
if ($tab == 'massive_policies' && is_central_policies_on_node()) { if ($tab == 'massive_policies' && is_management_allowed() === false) {
ui_print_warning_message(__('This node is configured with centralized mode. All policies information is read only. Go to metaconsole to manage it.')); ui_print_warning_message(
__(
'This node is configured with centralized mode. All policies information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/policymanager'
).'">'.__('metaconsole').'</a>'
)
);
return; return;
} }
@ -393,8 +400,15 @@ $agentstab = [
</script> </script>
<?php <?php
if (is_central_policies_on_node() && $option == 'delete_agents') { if (is_management_allowed() === false && $option == 'delete_agents') {
ui_print_warning_message(__('This node is configured with centralized mode. To delete an agent go to metaconsole.')); ui_print_warning_message(
__(
'This node is configured with centralized mode. To delete agents go to %s',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=monitoring&sec2=monitoring/wizard/wizard'
).'">'.__('metaconsole').'</a>'
)
);
} }
echo '<br />'; echo '<br />';

View File

@ -282,13 +282,16 @@ if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, '
$sub['godmode/servers/modificar_server']['id'] = 'Manage servers'; $sub['godmode/servers/modificar_server']['id'] = 'Manage servers';
} }
// This subtabs are only for Pandora Admin // This subtabs are only for Pandora Admin.
if (check_acl($config['id_user'], 0, 'PM')) { if (check_acl($config['id_user'], 0, 'PM')) {
enterprise_hook('ha_cluster'); enterprise_hook('ha_cluster');
$sub['godmode/servers/plugin']['text'] = __('Plugins'); $sub['godmode/servers/plugin']['text'] = __('Plugins');
$sub['godmode/servers/plugin']['id'] = 'Plugins'; $sub['godmode/servers/plugin']['id'] = 'Plugins';
$sub['godmode/servers/plugin_registration']['text'] = __('Register Plugin');
$sub['godmode/servers/plugin_registration']['id'] = 'register_plugin';
enterprise_hook('export_target_submenu'); enterprise_hook('export_target_submenu');
enterprise_hook('manage_satellite_submenu'); enterprise_hook('manage_satellite_submenu');

View File

@ -255,7 +255,7 @@ foreach ($groups as $group) {
$tabulation = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $group['deep']); $tabulation = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $group['deep']);
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
$data[0] = $tabulation.'<a href="index.php?sec=advanced&sec2=godmode/modules/manage_nc_groups&id='.$group['id_sg'].'">'.$group['name'].'</a>'; $data[0] = $tabulation.'<a href="index.php?sec=advanced&sec2=godmode/modules/manage_nc_groups&id='.$group['id_sg'].'">'.$group['name'].'</a>';
} else { } else {
$data[0] = $tabulation.'<a href="index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups&id='.$group['id_sg'].'">'.$group['name'].'</a>'; $data[0] = $tabulation.'<a href="index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups&id='.$group['id_sg'].'">'.$group['name'].'</a>';
@ -270,8 +270,15 @@ foreach ($groups as $group) {
array_push($table->data, $data); array_push($table->data, $data);
} }
if (is_management_allowed() === false && !is_metaconsole()) { if (is_management_allowed() === false && is_metaconsole() === false) {
ui_print_warning_message(__('This node is configured with centralized mode. This page is for read only. Go to metaconsole to manage the component groups.')); ui_print_warning_message(
__(
'This node is configured with centralized mode. Component groups are read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/modules/manage_nc_groups'
).'">'.__('metaconsole').'</a>'
)
);
} }
if (isset($data)) { if (isset($data)) {

View File

@ -1,9 +1,8 @@
<?php <?php
/** /**
* Extension to manage a list of gateways and the node address where they should * Remote components
* point to.
* *
* @category Extensions * @category Remote Components
* @package Pandora FMS * @package Pandora FMS
* @subpackage Community * @subpackage Community
* @version 1.0.0 * @version 1.0.0
@ -48,7 +47,7 @@ enterprise_include_once('meta/include/functions_components_meta.php');
require_once $config['homedir'].'/include/functions_component_groups.php'; require_once $config['homedir'].'/include/functions_component_groups.php';
// Header. // Header.
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
$sec = 'advanced'; $sec = 'advanced';
$id_modulo = (int) get_parameter('id_component_type'); $id_modulo = (int) get_parameter('id_component_type');
@ -67,6 +66,11 @@ if (defined('METACONSOLE')) {
$sec = 'gmodules'; $sec = 'gmodules';
} }
$is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
}
$type = (int) get_parameter('type'); $type = (int) get_parameter('type');
$name = io_safe_input(strip_tags(io_safe_output((string) get_parameter('name')))); $name = io_safe_input(strip_tags(io_safe_output((string) get_parameter('name'))));
$description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description')))); $description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description'))));
@ -87,7 +91,7 @@ $macros = (string) get_parameter('macros');
$id_modulo = (int) get_parameter('id_component_type'); $id_modulo = (int) get_parameter('id_component_type');
$new_component = (bool) get_parameter('new_component'); $new_component = (bool) get_parameter('new_component');
if (!empty($macros)) { if (empty($macros) === false) {
$macros = json_decode(base64_decode($macros), true); $macros = json_decode(base64_decode($macros), true);
foreach ($macros as $k => $m) { foreach ($macros as $k => $m) {
@ -179,7 +183,7 @@ $create_network_from_snmp_browser = (bool) get_parameter(
0 0
); );
if ($duplicate_network_component) { if ($is_management_allowed === true && $duplicate_network_component) {
$source_id = (int) get_parameter('source_id'); $source_id = (int) get_parameter('source_id');
$id = network_components_duplicate_network_component($source_id); $id = network_components_duplicate_network_component($source_id);
@ -267,7 +271,7 @@ $custom_string_2 = '';
$custom_string_3 = ''; $custom_string_3 = '';
// Header. // Header.
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
components_meta_print_header(); components_meta_print_header();
$sec = 'advanced'; $sec = 'advanced';
} else { } else {
@ -292,6 +296,17 @@ if (defined('METACONSOLE')) {
$sec = 'gmodules'; $sec = 'gmodules';
} }
if ($is_management_allowed === false) {
ui_print_warning_message(
__(
'This node is configured with centralized mode. All remote components are read only. Go to %s to manage them.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/modules/manage_network_components&tab=network&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
}
if ($type >= MODULE_TYPE_REMOTE_SNMP && $type <= MODULE_TYPE_REMOTE_SNMP_PROC) { if ($type >= MODULE_TYPE_REMOTE_SNMP && $type <= MODULE_TYPE_REMOTE_SNMP_PROC) {
// New support for snmp v3. // New support for snmp v3.
$tcp_send = $snmp_version; $tcp_send = $snmp_version;
@ -307,7 +322,7 @@ if ($type >= MODULE_TYPE_REMOTE_SNMP && $type <= MODULE_TYPE_REMOTE_SNMP_PROC) {
$custom_string_2 = $command_os; $custom_string_2 = $command_os;
} }
if ($create_component) { if ($is_management_allowed === true && $create_component) {
$name_check = db_get_value( $name_check = db_get_value(
'name', 'name',
'tnetwork_component', 'tnetwork_component',
@ -410,7 +425,7 @@ if ($create_component) {
$id = 0; $id = 0;
} }
if ($update_component) { if ($is_management_allowed === true && $update_component) {
$id = (int) get_parameter('id'); $id = (int) get_parameter('id');
if (!empty($name)) { if (!empty($name)) {
@ -502,7 +517,7 @@ if ($update_component) {
$id = 0; $id = 0;
} }
if ($delete_component) { if ($is_management_allowed === true && $delete_component) {
$id = (int) get_parameter('id'); $id = (int) get_parameter('id');
$result = network_components_delete_network_component($id); $result = network_components_delete_network_component($id);
@ -527,7 +542,7 @@ if ($delete_component) {
$id = 0; $id = 0;
} }
if ($multiple_delete) { if ($is_management_allowed === true && $multiple_delete) {
$ids = (array) get_parameter('delete_multiple', []); $ids = (array) get_parameter('delete_multiple', []);
foreach ($ids as $id) { foreach ($ids as $id) {
@ -645,7 +660,7 @@ $table->data[0][3] = html_print_input_text(
255, 255,
true true
); );
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
$table->data[0][4] = '<div>'; $table->data[0][4] = '<div>';
} else { } else {
$table->data[0][4] = '<div class="action-buttons">'; $table->data[0][4] = '<div class="action-buttons">';
@ -660,7 +675,7 @@ $table->data[0][4] .= html_print_submit_button(
); );
$table->data[0][4] .= '</div>'; $table->data[0][4] .= '</div>';
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
$filter = '<form class="filters_form" method="post" action="'.$url.'">'; $filter = '<form class="filters_form" method="post" action="'.$url.'">';
$filter .= html_print_table($table, true); $filter .= html_print_table($table, true);
$filter .= '</form>'; $filter .= '</form>';
@ -713,26 +728,38 @@ unset($table);
$table->width = '100%'; $table->width = '100%';
$table->head = []; $table->head = [];
$table->class = 'info_table'; $table->class = 'info_table';
$table->head['checkbox'] = html_print_checkbox( if ($is_management_allowed === true) {
$table->head['checkbox'] = html_print_checkbox(
'all_delete', 'all_delete',
0, 0,
false, false,
true, true,
false false
); );
}
$table->head[0] = __('Module name'); $table->head[0] = __('Module name');
$table->head[1] = __('Server'); $table->head[1] = __('Server');
$table->head[2] = __('Type'); $table->head[2] = __('Type');
$table->head[3] = __('Description'); $table->head[3] = __('Description');
$table->head[4] = __('Group'); $table->head[4] = __('Group');
$table->head[5] = __('Max/Min'); $table->head[5] = __('Max/Min');
$table->head[6] = __('Action'); if ($is_management_allowed === true) {
$table->head[6] = __('Action');
}
$table->size = []; $table->size = [];
$table->size['checkbox'] = '20px'; if ($is_management_allowed === true) {
$table->size['checkbox'] = '20px';
}
$table->size[1] = '40px'; $table->size[1] = '40px';
$table->size[2] = '50px'; $table->size[2] = '50px';
$table->size[6] = '80px'; if ($is_management_allowed === true) {
$table->align[6] = 'left'; $table->size[6] = '80px';
$table->align[6] = 'left';
}
$table->data = []; $table->data = [];
foreach ($components as $component) { foreach ($components as $component) {
@ -743,6 +770,7 @@ foreach ($components as $component) {
$component['min'] = __('N/A'); $component['min'] = __('N/A');
} }
if ($is_management_allowed === true) {
$data['checkbox'] = html_print_checkbox_extended( $data['checkbox'] = html_print_checkbox_extended(
'delete_multiple[]', 'delete_multiple[]',
$component['id_nc'], $component['id_nc'],
@ -756,6 +784,10 @@ foreach ($components as $component) {
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/modules/manage_network_components&id='.$component['id_nc'].'&pure='.$pure.'">'; $data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/modules/manage_network_components&id='.$component['id_nc'].'&pure='.$pure.'">';
$data[0] .= io_safe_output($component['name']); $data[0] .= io_safe_output($component['name']);
$data[0] .= '</a>'; $data[0] .= '</a>';
} else {
$data[0] = io_safe_output($component['name']);
}
switch ($component['id_modulo']) { switch ($component['id_modulo']) {
case MODULE_NETWORK: case MODULE_NETWORK:
$data[1] .= html_print_image( $data[1] .= html_print_image(
@ -811,6 +843,7 @@ foreach ($components as $component) {
$data[4] = network_components_get_group_name($component['id_group']); $data[4] = network_components_get_group_name($component['id_group']);
$data[5] = $component['max'].' / '.$component['min']; $data[5] = $component['max'].' / '.$component['min'];
if ($is_management_allowed === true) {
$table->cellclass[][6] = 'action_buttons'; $table->cellclass[][6] = 'action_buttons';
$data[6] = '<a class="inline_line float-left" href="'.$url.'&search_id_group='.$search_id_group.'search_string='.$search_string.'&duplicate_network_component=1&source_id='.$component['id_nc'].'">'.html_print_image( $data[6] = '<a class="inline_line float-left" href="'.$url.'&search_id_group='.$search_id_group.'search_string='.$search_string.'&duplicate_network_component=1&source_id='.$component['id_nc'].'">'.html_print_image(
'images/copy.png', 'images/copy.png',
@ -830,13 +863,17 @@ foreach ($components as $component) {
'class' => 'invert_filter', 'class' => 'invert_filter',
] ]
).'</a>'; ).'</a>';
}
array_push($table->data, $data); array_push($table->data, $data);
} }
if (isset($data)) { if (isset($data) === true) {
if ($is_management_allowed === true) {
echo "<form method='post' action='index.php?sec=".$sec.'&sec2=godmode/modules/manage_network_components&search_id_group=0search_string=&pure='.$pure."'>"; echo "<form method='post' action='index.php?sec=".$sec.'&sec2=godmode/modules/manage_network_components&search_id_group=0search_string=&pure='.$pure."'>";
html_print_input_hidden('multiple_delete', 1); html_print_input_hidden('multiple_delete', 1);
}
html_print_table($table); html_print_table($table);
ui_pagination( ui_pagination(
$total_components, $total_components,
@ -848,6 +885,7 @@ if (isset($data)) {
true, true,
'pagination-bottom' 'pagination-bottom'
); );
if ($is_management_allowed === true) {
echo "<div id='btn_delete_5' class='float-right'>"; echo "<div id='btn_delete_5' class='float-right'>";
html_print_submit_button( html_print_submit_button(
__('Delete'), __('Delete'),
@ -857,6 +895,7 @@ if (isset($data)) {
); );
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
}
} else { } else {
ui_print_info_message( ui_print_info_message(
[ [
@ -866,10 +905,11 @@ if (isset($data)) {
); );
} }
echo '<form method="post" action="'.$url.'">'; if ($is_management_allowed === true) {
echo '<div class="right_align mrgn_btn_15px">'; echo '<form method="post" action="'.$url.'">';
html_print_input_hidden('new_component', 1); echo '<div class="right_align mrgn_btn_15px">';
html_print_select( html_print_input_hidden('new_component', 1);
html_print_select(
[ [
COMPONENT_TYPE_NETWORK => __('Create a new network component'), COMPONENT_TYPE_NETWORK => __('Create a new network component'),
COMPONENT_TYPE_PLUGIN => __('Create a new plugin component'), COMPONENT_TYPE_PLUGIN => __('Create a new plugin component'),
@ -882,15 +922,16 @@ html_print_select(
'', '',
'', '',
'' ''
); );
html_print_submit_button( html_print_submit_button(
__('Create'), __('Create'),
'crt', 'crt',
false, false,
'class="sub next mrgn_lft_5px"' 'class="sub next mrgn_lft_5px"'
); );
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
}
enterprise_hook('close_meta_frame'); enterprise_hook('close_meta_frame');

View File

@ -182,6 +182,7 @@ if (isset($id)) {
$snmp3_privacy_pass = io_output_password( $snmp3_privacy_pass = io_output_password(
$component['custom_string_2'] $component['custom_string_2']
); );
unset($tcp_send);
$snmp3_security_level = $component['custom_string_3']; $snmp3_security_level = $component['custom_string_3'];
} else if ($type >= MODULE_TYPE_REMOTE_CMD && $type <= MODULE_TYPE_REMOTE_CMD_INC) { } else if ($type >= MODULE_TYPE_REMOTE_CMD && $type <= MODULE_TYPE_REMOTE_CMD_INC) {
$command_text = $component['tcp_send']; $command_text = $component['tcp_send'];

View File

@ -1,19 +1,36 @@
<?php <?php
/**
* Manage plugins.
*
* @category Utility
* @package Pandora FMS
* @subpackage Plugins
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config; global $config;
require_once $config['homedir'].'/include/functions_plugins.php';
if (is_ajax()) { if (is_ajax()) {
$get_plugin_description = get_parameter('get_plugin_description'); $get_plugin_description = get_parameter('get_plugin_description');
$get_list_modules_and_component_locked_plugin = (bool) get_parameter('get_list_modules_and_component_locked_plugin', 0); $get_list_modules_and_component_locked_plugin = (bool) get_parameter('get_list_modules_and_component_locked_plugin', 0);
@ -112,7 +129,6 @@ $edit_file = get_parameter('edit_file', false);
$update_file = get_parameter('update_file', false); $update_file = get_parameter('update_file', false);
$plugin_command = get_parameter('plugin_command', ''); $plugin_command = get_parameter('plugin_command', '');
$tab = get_parameter('tab', ''); $tab = get_parameter('tab', '');
$deploy_plugin = get_parameter('deploy_plugin', 0);
if ($view != '') { if ($view != '') {
$form_id = $view; $form_id = $view;
@ -283,11 +299,12 @@ $sec = 'gservers';
if (($create != '') || ($view != '')) { if (($create != '') || ($view != '')) {
enterprise_hook('open_meta_frame'); enterprise_hook('open_meta_frame');
$management_allowed = is_management_allowed();
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
components_meta_print_header(); components_meta_print_header();
$sec = 'advanced'; $sec = 'advanced';
$management_allowed = is_management_allowed(); if ($management_allowed === false) {
if (!$management_allowed) {
ui_print_warning_message(__('To manage plugin you must activate centralized management')); ui_print_warning_message(__('To manage plugin you must activate centralized management'));
} }
} else { } else {
@ -309,8 +326,7 @@ if (($create != '') || ($view != '')) {
); );
} }
$management_allowed = !is_central_policies_on_node(); if ($management_allowed === false) {
if (!$management_allowed) {
ui_print_warning_message( ui_print_warning_message(
__( __(
'This console is not manager of this environment, 'This console is not manager of this environment,
@ -619,36 +635,6 @@ if (($create != '') || ($view != '')) {
__('To manage plugin you must activate centralized management') __('To manage plugin you must activate centralized management')
); );
} }
if (!$config['metaconsole_deploy_plugin_server'] && $management_allowed) {
$deploy_plugin_server = true;
echo '<div id="deploy_messages" class="invisible">';
echo '<span>'.__('The previous configuration of plugins has been imported from the nodes. Please check that the definitions are correct.').'</br></br>'.'<b>'.__('Note:').'</b>'.__(
'These definitions will not be operational until you manually
copy the files from the nodes to the atachment/plugin/ directory of the meta console.'
).'</br></br>'.__('You can find more information at:')."<a href='https://pandorafms.com/manual'>https://pandorafms.com/manual</a>".'</span>';
echo '</div>';
?>
<script type="text/javascript">
$(document).ready(function () {
$("#deploy_messages").dialog({
resizable: true,
draggable: true,
modal: true,
height: 220,
title: '<?php echo __('Warning'); ?>',
width: 528,
overlay: {
opacity: 0.5,
background: "black"
}
});
});
</script>
<?php
config_update_value('metaconsole_deploy_plugin_server', 1);
}
} else { } else {
ui_print_page_header( ui_print_page_header(
__( __(
@ -661,8 +647,8 @@ if (($create != '') || ($view != '')) {
true true
); );
$management_allowed = !is_central_policies_on_node(); $management_allowed = is_management_allowed();
if (!$management_allowed) { if ($management_allowed === false) {
ui_print_warning_message( ui_print_warning_message(
__( __(
'This console is not manager of this environment, 'This console is not manager of this environment,
@ -820,180 +806,20 @@ if (($create != '') || ($view != '')) {
} }
} }
if ((int) $plugin_id > 0) {
if ($plugin_id != 0) { // Delete all iformation related with this plugin.
// Delete all the modules with this plugin
$plugin_modules = db_get_all_rows_filter(
'tagente_modulo',
['id_plugin' => $plugin_id]
);
if (empty($plugin_modules)) {
$plugin_modules = [];
}
foreach ($plugin_modules as $pm) {
modules_delete_agent_module($pm['id_agente_modulo']);
}
if (enterprise_installed()) {
enterprise_include_once('include/functions_policies.php');
$policies_ids = db_get_all_rows_filter('tpolicy_modules', ['id_plugin' => $plugin_id]);
foreach ($policies_ids as $policies_id) {
policies_change_delete_pending_module($policies_id['id']);
}
}
if (is_metaconsole()) {
enterprise_include_once('include/functions_plugins.php');
$result = plugins_delete_plugin($plugin_id); $result = plugins_delete_plugin($plugin_id);
if (!$result) { if (empty($result) === false) {
ui_print_error_message(__('Problem deleting plugin')); ui_print_error_message(
implode('<br>', $result)
);
} else { } else {
ui_print_success_message(__('Plugin deleted successfully')); ui_print_success_message(__('Plugin deleted successfully'));
} }
} }
} }
}
if ($deploy_plugin) { // If not edition or insert, then list available plugins.
if (is_metaconsole()) {
enterprise_include_once('include/functions_plugins.php');
$result = plugins_deploy_plugin($deploy_plugin);
if (!$result) {
ui_print_error_message(__('Problem deploying plugin'));
} else {
ui_print_success_message(__('Plugin deployed successfully'));
}
}
}
if ($deploy_plugin_server) {
$setup = db_get_all_rows_in_table('tmetaconsole_setup');
// recorremos todos los nodos.
foreach ($setup as $key => $value) {
// Obtenemos los plugins de la meta.
$all_plugin_meta = db_get_all_rows_sql('SELECT SQL_NO_CACHE * FROM tplugin', false, false);
// Conectamos con el nodo.
if (metaconsole_connect($value) == NOERR) {
$values = [];
// Obtenemos los plugin del nodo.
$node_plugin_server = db_get_all_rows_sql('SELECT SQL_NO_CACHE * FROM tplugin', false, false);
foreach ($node_plugin_server as $key2 => $plugin) {
// Comprobamos si el id esta meta y nodo al mismo tiempo.
$key_exists = array_search($plugin['id'], array_column($all_plugin_meta, 'id'));
if ($key_exists !== false) {
// Si el plugin tiene el mismo id pero diferentes datos.
if ($all_plugin_meta[$key_exists] != $plugin) {
$old_id = $plugin['id'];
$new_id = ($plugin['id'] + (1000 * $value['id']));
// El plugin del nodo pasa a tener otro id y otro nombre.
$plugin['id'] = $new_id;
$plugin['name'] = $plugin['name'].'_'.$value['server_name'];
$result_update = db_process_sql_update(
'tplugin',
[
'id' => $new_id,
'name' => $plugin['name'],
],
['id' => $old_id]
);
if ($result_update) {
db_process_sql_update(
'tagente_modulo',
['id_plugin' => $new_id],
['id_plugin' => $old_id]
);
db_process_sql_update(
'tnetwork_component',
['id_plugin' => $new_id],
['id_plugin' => $old_id]
);
db_process_sql_update(
'tpolicy_modules',
['id_plugin' => $new_id],
['id_plugin' => $old_id]
);
}
// New plugins to insert in the metaconsole.
$values[$plugin['id']] = $plugin;
}
} else {
// Exists in the node, but does not exist in the metaconsole.
$values[$plugin['id']] = $plugin;
}
}
// Restore to metaconsole.
metaconsole_restore_db();
// Insert in metaconsole.
if (!empty($values)) {
foreach ($values as $key2 => $val) {
// Insert into metaconsole.
$result_insert = db_process_sql_insert('tplugin', $val);
}
}
}
}
$all_plugin_meta = db_get_all_rows_sql('SELECT SQL_NO_CACHE * FROM tplugin', false, false);
foreach ($setup as $key => $value) {
if (metaconsole_connect($value) == NOERR) {
$all_plugin_node = db_get_all_rows_sql('SELECT SQL_NO_CACHE * FROM tplugin', false, false);
$array_diff = array_diff(array_column($all_plugin_meta, 'id'), array_column($all_plugin_node, 'id'));
foreach ($array_diff as $key2 => $pluginid) {
$other = [];
$plugin_meta = $all_plugin_meta[$key2];
unset($plugin_meta['id']);
$other['name'] = urlencode($plugin_meta['name']);
$other['description'] = urlencode($plugin_meta['description']);
$other['max_timeout'] = $plugin_meta['max_timeout'];
$other['max_retries'] = $plugin_meta['max_retries'];
$other['execute'] = urlencode($plugin_meta['execute']);
$other['net_dst_opt'] = $plugin_meta['net_dst_opt'];
$other['net_port_opt'] = $plugin_meta['net_port_opt'];
$other['user_opt'] = $plugin_meta['user_opt'];
$other['pass_opt'] = $plugin_meta['pass_opt'];
$other['plugin_type'] = $plugin_meta['plugin_type'];
$other['macros'] = urlencode($plugin_meta['macros']);
$other['parameters'] = urlencode($plugin_meta['parameters']);
$other = implode('%7E', $other);
$auth_token = json_decode($value['auth_token']);
$url = $value['server_url'].'include/api.php?op=set&op2=push_plugin'.'&id='.$pluginid.'&other_mode=url_encode_separator_%7E&other='.$other."&apipass=$auth_token->api_password"."&user=$auth_token->console_user&pass=$auth_token->console_password";
$file_path = realpath($plugin_meta['execute']);
$post = '';
if (file_exists($file_path)) {
$post = ['file' => curl_file_create($file_path)];
}
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL, $url);
curl_setopt($curlObj, CURLOPT_POST, 1);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $post);
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, false);
$api_result = curl_exec($curlObj);
curl_close($curlObj);
}
}
// restore to metaconsole
metaconsole_restore_db();
}
}
// If not edition or insert, then list available plugins
$rows = db_get_all_rows_sql('SELECT * FROM tplugin ORDER BY name'); $rows = db_get_all_rows_sql('SELECT * FROM tplugin ORDER BY name');
if ($rows !== false) { if ($rows !== false) {
@ -1081,16 +907,6 @@ if (($create != '') || ($view != '')) {
'class' => 'invert_filter', 'class' => 'invert_filter',
] ]
).'</a>'; ).'</a>';
if (is_metaconsole()) {
echo "&nbsp;&nbsp;&nbsp;<a href='index.php?sec=$sec&sec2=godmode/servers/plugin&tab=$tab&deploy_plugin=".$row['id'].'&tab=plugins&pure='.$config['pure']."'>".html_print_image(
'images/deploy.png',
true,
[
'title' => __('Deploy'),
'width' => '21 px',
]
).'</a>&nbsp;&nbsp;';
}
echo '</td>'; echo '</td>';
} }

View File

@ -0,0 +1,571 @@
<?php
/**
* Plugin registration.
*
* @category Plugins
* @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.
* ============================================================================
*/
use PandoraFMS\Enterprise\Metaconsole\Synchronizer;
use PandoraFMS\Tools\Files;
// Load global vars.
global $config;
// Check ACL and Login.
check_login();
if ((bool) check_acl($config['id_user'], 0, 'PM') === false
|| (bool) check_acl($config['id_user'], 0, 'AW') === false
) {
db_pandora_audit(
'ACL Violation',
'Trying to access Plugin Management'
);
include 'general/noaccess.php';
return;
}
ui_require_css_file('first_task');
if (is_metaconsole() === true) {
enterprise_include_once('meta/include/functions_components_meta.php');
enterprise_hook('open_meta_frame');
components_meta_print_header();
$sec = 'advanced';
$management_allowed = is_management_allowed();
if ($management_allowed === false) {
ui_print_warning_message(
__('To manage plugin you must activate centralized management')
);
return;
}
} else {
ui_print_page_header(
__('PLUGIN REGISTRATION'),
'images/gm_servers.png',
false,
'',
true
);
$management_allowed = is_management_allowed();
if ($management_allowed === false) {
ui_print_warning_message(
__(
'This console is not manager of this environment, please manage this feature from feature from %s.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/servers/plugin_registration&tab=plugin_registration&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
return;
}
}
$str = 'This extension makes registering server plugins an easier task.';
$str .= ' Here you can upload a server plugin in .pspz zipped format.';
$str .= ' Please refer to the official documentation on how to obtain and use Server Plugins.';
$output = '<div class="new_task">';
$output .= '<div class="image_task">';
$output .= html_print_image(
'images/first_task/icono_grande_import.png',
true,
['title' => __('Plugin Registration') ]
);
$output .= '</div>';
$output .= '<div class="text_task">';
$output .= '<h3>'.__('Plugin registration').'</h3>';
$output .= '<p id="description_task">';
$output .= __($str);
$output .= '<br><br>';
$output .= __('You can get more plugins in our');
$output .= '<a href="http://pandorafms.com/Library/Library/">';
$output .= ' '.__('Public Resource Library');
$output .= '</a>';
$output .= '</p>';
// Upload form.
$output .= "<form name='submit_plugin' method='post' enctype='multipart/form-data'>";
$output .= '<table class="" id="table1" width="100%" border="0" cellpadding="4" cellspacing="4">';
$output .= "<tr><td class='datos'><input type='file' name='plugin_upload' />";
$output .= "<td class='datos'><input type='submit' class='sub next' value='".__('Upload')."' />";
$output .= '</form></table>';
$output .= '</div>';
$output .= '</div>';
echo $output;
$zip = null;
$upload = false;
if (isset($_FILES['plugin_upload']) === true) {
$basepath = $config['attachment_store'].'/plugin';
$filename = $_FILES['plugin_upload']['name'];
$uploaded_filename = $_FILES['plugin_upload']['tmp_name'];
$tmp_path = Files::tempdirnam(
$config['attachment_store'].'/downloads/',
'plugin_uploaded_'
);
if ($tmp_path === false) {
$error = __('Failed to create temporary directory');
}
} else {
$error = '';
}
if ($error === null) {
if (Files::unzip($uploaded_filename, $tmp_path) === true) {
// Successfully extracted to tmp directory.
// Grant execution over all files found.
Files::chmod($tmp_path, 0755);
// Operate.
$ini_array = parse_ini_file($tmp_path.'/plugin_definition.ini', true);
// Clean plugin_definition.ini file.
unlink($tmp_path.'/plugin_definition.ini');
// Parse with sections.
if ($ini_array === false) {
$error = __('Cannot load INI file');
} else {
// Relocate files to target destination.
Files::move($tmp_path.'/*', $basepath.'/', true);
// Extract information.
$version = preg_replace('/.*[.]/', '', $filename);
$exec_path = $basepath.'/'.$ini_array['plugin_definition']['filename'];
$file_exec_path = $exec_path;
if (isset($ini_array['plugin_definition']['execution_command']) === true
&& empty($ini_array['plugin_definition']['execution_command']) === false
) {
$exec_path = $ini_array['plugin_definition']['execution_command'];
$exec_path .= ' '.$basepath.'/';
$exec_path .= $ini_array['plugin_definition']['filename'];
}
if (isset($ini_array['plugin_definition']['execution_postcommand']) === true
&& empty($ini_array['plugin_definition']['execution_postcommand']) === false
) {
$exec_path .= ' '.$ini_array['plugin_definition']['execution_postcommand'];
}
if (file_exists($file_exec_path) === false) {
$error = __('Plugin exec not found. Aborting!');
unlink($config['attachment_store'].'/plugin_definition.ini');
} else {
// Verify if a plugin with the same name is already registered.
$sql = sprintf(
'SELECT COUNT(*) FROM tplugin WHERE name = "%s"',
io_safe_input($ini_array['plugin_definition']['name'])
);
$result = db_get_sql($sql);
if ($result > 0) {
$error = __('Plugin already registered. Aborting!');
unlink($config['attachment_store'].'/plugin_definition.ini');
} else {
$values = [
'name' => io_safe_input($ini_array['plugin_definition']['name']),
'description' => io_safe_input($ini_array['plugin_definition']['description']),
'max_timeout' => $ini_array['plugin_definition']['timeout'],
'execute' => io_safe_input($exec_path),
'net_dst_opt' => $ini_array['plugin_definition']['ip_opt'],
'net_port_opt' => $ini_array['plugin_definition']['port_opt'],
'user_opt' => $ini_array['plugin_definition']['user_opt'],
'pass_opt' => $ini_array['plugin_definition']['pass_opt'],
'parameters' => $ini_array['plugin_definition']['parameters'],
'plugin_type' => $ini_array['plugin_definition']['plugin_type'],
];
switch ($version) {
case 'pspz':
// Fixed the static parameters
// for
// the dinamic parameters of pandoras 5.
$total_macros = 0;
$macros = [];
if (isset($values['parameters']) === false) {
$values['parameters'] = '';
}
if (empty($values['net_dst_opt']) === false) {
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Target IP from net';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= $values['net_dst_opt'].' _field'.$total_macros.'_ ';
$macros[(string) $total_macros] = $macro;
}
if (empty($values['ip_opt']) === false) {
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Target IP';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= $values['ip_opt'].' _field'.$total_macros.'_ ';
$macros[(string) $total_macros] = $macro;
}
if (empty($values['net_port_opt']) === false) {
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Port from net';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= $values['net_port_opt'].' _field'.$total_macros.'_ ';
$macros[(string) $total_macros] = $macro;
}
if (empty($values['port_opt']) === false) {
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Port';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= $values['port_opt'].' _field'.$total_macros.'_ ';
$macros[(string) $total_macros] = $macro;
}
if (empty($values['user_opt']) === false) {
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Username';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= $values['user_opt'].' _field'.$total_macros.'_ ';
$macros[(string) $total_macros] = $macro;
}
if (empty($values['pass_opt']) === false) {
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Password';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= $values['pass_opt'].' _field'.$total_macros.'_ ';
$macros[(string) $total_macros] = $macro;
}
// A last parameter is defined always to
// add the old "Plug-in parameters" in the
// side of the module.
$total_macros++;
$macro = [];
$macro['macro'] = '_field'.$total_macros.'_';
$macro['desc'] = 'Plug-in Parameters';
$macro['help'] = '';
$macro['value'] = '';
$values['parameters'] .= ' _field'.$total_macros.'_';
$macros[(string) $total_macros] = $macro;
break;
case 'pspz2':
// Fill the macros field.
$total_macros = $ini_array['plugin_definition']['total_macros_provided'];
$macros = [];
for ($it_macros = 1; $it_macros <= $total_macros; $it_macros++) {
$label = 'macro_'.$it_macros;
$macro = [];
$macro['macro'] = '_field'.$it_macros.'_';
$macro['hide'] = $ini_array[$label]['hide'];
$macro['desc'] = io_safe_input(
$ini_array[$label]['description']
);
$macro['help'] = io_safe_input(
$ini_array[$label]['help']
);
$macro['value'] = io_safe_input(
$ini_array[$label]['value']
);
$macros[(string) $it_macros] = $macro;
}
break;
default:
// Not possible.
break;
}
if (empty($macros) === false) {
$values['macros'] = json_encode($macros);
}
$create_id = db_process_sql_insert('tplugin', $values);
if (empty($create_id) === true) {
ui_print_error_message(
__('Plug-in Remote Registered unsuccessfull')
);
ui_print_info_message(
__('Please check the syntax of file "plugin_definition.ini"')
);
} else {
for ($ax = 1; $ax <= $ini_array['plugin_definition']['total_modules_provided']; $ax++) {
$label = 'module'.$ax;
$plugin_user = '';
if (isset($ini_array[$label]['plugin_user']) === true) {
$plugin_user = $ini_array[$label]['plugin_user'];
}
$plugin_pass = '';
if (isset($ini_array[$label]['plugin_pass']) === true) {
$plugin_pass = $ini_array[$label]['plugin_pass'];
}
$plugin_parameter = '';
if (isset($ini_array[$label]['plugin_parameter']) === true) {
$plugin_parameter = $ini_array[$label]['plugin_parameter'];
}
$unit = '';
if (isset($ini_array[$label]['unit']) === true) {
$unit = $ini_array[$label]['unit'];
}
$values = [
'name' => io_safe_input($ini_array[$label]['name']),
'description' => io_safe_input($ini_array[$label]['description']),
'id_group' => $ini_array[$label]['id_group'],
'type' => $ini_array[$label]['type'],
'max' => ($ini_array[$label]['max'] ?? ''),
'min' => ($ini_array[$label]['min'] ?? ''),
'module_interval' => ($ini_array[$label]['module_interval'] ?? ''),
'id_module_group' => $ini_array[$label]['id_module_group'],
'id_modulo' => $ini_array[$label]['id_modulo'],
'plugin_user' => io_safe_input($plugin_user),
'plugin_pass' => io_safe_input($plugin_pass),
'plugin_parameter' => io_safe_input($plugin_parameter),
'unit' => io_safe_input($unit),
'max_timeout' => ($ini_array[$label]['max_timeout'] ?? ''),
'history_data' => ($ini_array[$label]['history_data'] ?? ''),
'dynamic_interval' => ($ini_array[$label]['dynamic_interval'] ?? ''),
'dynamic_min' => ($ini_array[$label]['dynamic_min'] ?? ''),
'dynamic_max' => ($ini_array[$label]['dynamic_max'] ?? ''),
'dynamic_two_tailed' => ($ini_array[$label]['dynamic_two_tailed'] ?? ''),
'min_warning' => ($ini_array[$label]['min_warning'] ?? ''),
'max_warning' => ($ini_array[$label]['max_warning'] ?? ''),
'str_warning' => ($ini_array[$label]['str_warning'] ?? ''),
'min_critical' => ($ini_array[$label]['min_critical'] ?? ''),
'max_critical' => ($ini_array[$label]['max_critical'] ?? ''),
'str_critical' => ($ini_array[$label]['str_critical'] ?? ''),
'min_ff_event' => ($ini_array[$label]['min_ff_event'] ?? ''),
'tcp_port' => ($ini_array[$label]['tcp_port'] ?? ''),
'id_plugin' => $create_id,
];
$macros_component = $macros;
switch ($version) {
case 'pspz':
// Fixed the static parameters
// for
// the dinamic parameters of pandoras 5.
foreach ($macros_component as $key => $macro) {
if ($macro['desc'] === 'Target IP from net') {
if (empty($values['ip_target']) === false) {
$macros_component[$key]['value'] = io_safe_input(
$values['ip_target']
);
}
}
if ($macro['desc'] === 'Target IP') {
if (empty($values['ip_target']) === false) {
$macros_component[$key]['value'] = io_safe_input(
$values['ip_target']
);
}
} else if ($macro['desc'] === 'Port from net') {
if (empty($values['tcp_port']) === false) {
$macros_component[$key]['value'] = io_safe_input(
$values['tcp_port']
);
}
} else if ($macro['desc'] === 'Port') {
if (empty($values['tcp_port']) === false) {
$macros_component[$key]['value'] = io_safe_input(
$values['tcp_port']
);
}
} else if ($macro['desc'] === 'Username') {
if (empty($values['plugin_user']) === false) {
$macros_component[$key]['value'] = io_safe_input(
$values['plugin_user']
);
}
} else if ($macro['desc'] === 'Password') {
if (empty($values['plugin_pass']) === false) {
$macros_component[$key]['value'] = io_safe_input(
$values['plugin_pass']
);
}
} else if ($macro['desc'] === 'Plug-in Parameters') {
if (empty($values['plugin_parameter']) === false) {
$macros_component[$key]['value'] = io_safe_input(
$values['plugin_parameter']
);
}
}
}
break;
case 'pspz2':
if ($total_macros > 0) {
for ($it_macros = 1; $it_macros <= $total_macros; $it_macros++) {
$macro = 'macro_'.$it_macros.'_value';
// Set the value or use the default.
if (isset($ini_array[$label][$macro]) === true) {
$macros_component[(string) $it_macros]['value'] = io_safe_input(
$ini_array[$label][$macro]
);
}
}
}
break;
default:
// Not possible.
break;
}
if (empty($macros_component) === false) {
$values['macros'] = json_encode($macros_component);
}
db_process_sql_insert('tnetwork_component', $values);
ui_print_success_message(
__('Module plugin registered').' : '.$ini_array[$label]['name']
);
}
ui_print_success_message(
__('Plugin').' '.$ini_array['plugin_definition']['name'].' '.__('Registered successfully')
);
}
unlink($config['attachment_store'].'/plugin_definition.ini');
}
}
}
// Clean.
Files::rmrf($tmp_path);
} else {
$error = __('Unable to uncompress uploaded file');
}
}
if (file_exists($uploaded_filename) === true) {
if (is_metaconsole() === true && is_management_allowed() === true) {
// Keep uploaded file to be transferred to nodes.
if (is_dir($config['attachment_store'].'/downloads/') === false) {
mkdir($config['attachment_store'].'/downloads/');
}
$keep = move_uploaded_file(
$uploaded_filename,
$config['attachment_store'].'/downloads/'.$filename
);
if ($keep === false) {
$error = __(
'Cannot move uploaded file to %s.',
$config['attachment_store'].'/downloads/'
);
}
} else {
// Clean temporary files.
unlink($uploaded_filename);
}
}
if ($error !== null && $error !== '') {
ui_print_error_message($error);
} else if ($error === null
&& is_management_allowed() === true
&& is_metaconsole() === true
) {
$attachment = '/'.str_replace(
$config['homedir'],
'',
$config['attachment_store']
);
$sc = new Synchronizer();
$sc->queueOperation(
Synchronizer::OPERATION_REFRESH_PLUGIN,
ui_get_full_url(
$attachment.'/downloads/'.$filename,
false,
false,
false
)
);
}
if (is_metaconsole() === true) {
enterprise_hook('close_meta_frame');
}

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* Os.
*
* @category Os
* @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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Load global vars.
// ==================================================
// 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.
// Load global vars
global $config; global $config;
check_login(); check_login();
@ -22,6 +37,19 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user
return; return;
} }
$is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
ui_print_warning_message(
__(
'This node is configured with centralized mode. All OS definitions are read only. Go to %s to manage them.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2=list&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
}
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
@ -31,11 +59,19 @@ $table->head[0] = '';
$table->head[1] = __('ID'); $table->head[1] = __('ID');
$table->head[2] = __('Name'); $table->head[2] = __('Name');
$table->head[3] = __('Description'); $table->head[3] = __('Description');
$table->head[4] = ''; if ($is_management_allowed === true) {
$table->head[4] = '';
}
$table->align[0] = 'center'; $table->align[0] = 'center';
$table->align[4] = 'center'; if ($is_management_allowed === true) {
$table->align[4] = 'center';
}
$table->size[0] = '20px'; $table->size[0] = '20px';
$table->size[4] = '20px'; if ($is_management_allowed === true) {
$table->size[4] = '20px';
}
// Prepare pagination. // Prepare pagination.
$offset = (int) get_parameter('offset'); $offset = (int) get_parameter('offset');
@ -59,14 +95,19 @@ foreach ($osList as $os) {
$data = []; $data = [];
$data[] = ui_print_os_icon($os['id_os'], false, true); $data[] = ui_print_os_icon($os['id_os'], false, true);
$data[] = $os['id_os']; $data[] = $os['id_os'];
if (is_metaconsole()) { if ($is_management_allowed === true) {
if (is_metaconsole() === true) {
$data[] = '<a href="index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&action=edit&tab2=builder&id_os='.$os['id_os'].'">'.io_safe_output($os['name']).'</a>'; $data[] = '<a href="index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&action=edit&tab2=builder&id_os='.$os['id_os'].'">'.io_safe_output($os['name']).'</a>';
} else { } else {
$data[] = '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&action=edit&tab=builder&id_os='.$os['id_os'].'">'.io_safe_output($os['name']).'</a>'; $data[] = '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&action=edit&tab=builder&id_os='.$os['id_os'].'">'.io_safe_output($os['name']).'</a>';
} }
} else {
$data[] = io_safe_output($os['name']);
}
$data[] = ui_print_truncate_text(io_safe_output($os['description']), 'description', true, true); $data[] = ui_print_truncate_text(io_safe_output($os['description']), 'description', true, true);
if ($is_management_allowed === true) {
$table->cellclass[][4] = 'action_buttons'; $table->cellclass[][4] = 'action_buttons';
if ($os['id_os'] > 16) { if ($os['id_os'] > 16) {
if (is_metaconsole()) { if (is_metaconsole()) {
@ -78,11 +119,12 @@ foreach ($osList as $os) {
// The original icons of pandora don't delete. // The original icons of pandora don't delete.
$data[] = ''; $data[] = '';
} }
}
$table->data[] = $data; $table->data[] = $data;
} }
if (isset($data)) { if (isset($data) === true) {
ui_pagination($count_osList, ui_get_url_refresh(['message' => false]), $offset); ui_pagination($count_osList, ui_get_url_refresh(['message' => false]), $offset);
html_print_table($table); html_print_table($table);
ui_pagination($count_osList, ui_get_url_refresh(['message' => false]), $offset, 0, false, 'offset', true, 'pagination-bottom'); ui_pagination($count_osList, ui_get_url_refresh(['message' => false]), $offset, 0, false, 'offset', true, 'pagination-bottom');
@ -90,7 +132,7 @@ if (isset($data)) {
ui_print_info_message(['no_close' => true, 'message' => __('There are no defined operating systems') ]); ui_print_info_message(['no_close' => true, 'message' => __('There are no defined operating systems') ]);
} }
if (is_metaconsole()) { if (is_metaconsole() === true) {
echo '<form method="post" action="index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2=builder">'; echo '<form method="post" action="index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2=builder">';
echo "<div style='text-align:right;width:".$table->width."'>"; echo "<div style='text-align:right;width:".$table->width."'>";
html_print_submit_button(__('Create OS'), '', false, 'class="sub next"'); html_print_submit_button(__('Create OS'), '', false, 'class="sub next"');

View File

@ -1,10 +1,10 @@
<?php <?php
/** /**
* OS Edition * Os.
* *
* @category Server * @category Os
* @package Pandora FMS * @package Pandora FMS
* @subpackage Godmode * @subpackage Community
* @version 1.0.0 * @version 1.0.0
* @license See below * @license See below
* *
@ -26,7 +26,7 @@
* ============================================================================ * ============================================================================
*/ */
// Begin. // Load global vars.
global $config; global $config;
check_login(); check_login();
@ -40,7 +40,7 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user
$action = get_parameter('action', 'new'); $action = get_parameter('action', 'new');
$idOS = get_parameter('id_os', 0); $idOS = get_parameter('id_os', 0);
$id_message = get_parameter('message', 0); $id_message = get_parameter('message', 0);
if (is_metaconsole()) { if (is_metaconsole() === true) {
$tab = get_parameter('tab2', 'list'); $tab = get_parameter('tab2', 'list');
} else { } else {
$tab = get_parameter('tab', 'list'); $tab = get_parameter('tab', 'list');
@ -57,16 +57,14 @@ if ($idOS) {
$icon = get_parameter('icon', 0); $icon = get_parameter('icon', 0);
} }
$is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
}
$message = ''; $message = '';
if ($is_management_allowed === true) {
switch ($action) { switch ($action) {
case 'new':
default:
$actionHidden = 'save';
$textButton = __('Create');
$classButton = 'class="sub next"';
break;
case 'edit': case 'edit':
$actionHidden = 'update'; $actionHidden = 'update';
$textButton = __('Update'); $textButton = __('Update');
@ -98,7 +96,7 @@ switch ($action) {
$message = 1; $message = 1;
} }
if (is_metaconsole()) { if (is_metaconsole() === true) {
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message); header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message);
} else { } else {
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message); header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
@ -114,7 +112,7 @@ switch ($action) {
$values['name'] = $name; $values['name'] = $name;
$values['description'] = $description; $values['description'] = $description;
// Only for Metaconsole. Save the previous name for synchronizing. // Only for Metaconsole. Save the previous name for synchronizing.
if (is_metaconsole()) { if (is_metaconsole() === true) {
$values['previous_name'] = db_get_value('name', 'tconfig_os', 'id_os', $idOS); $values['previous_name'] = db_get_value('name', 'tconfig_os', 'id_os', $idOS);
} }
@ -140,7 +138,7 @@ switch ($action) {
$actionHidden = 'update'; $actionHidden = 'update';
$textButton = __('Update'); $textButton = __('Update');
$classButton = 'class="sub upd"'; $classButton = 'class="sub upd"';
if (is_metaconsole()) { if (is_metaconsole() === true) {
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message); header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message);
} else { } else {
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message); header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
@ -163,16 +161,24 @@ switch ($action) {
} }
} }
if (is_metaconsole()) { if (is_metaconsole() === true) {
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message); header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message);
} else { } else {
header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message); header('Location:'.$config['homeurl'].'index.php?sec=gsetup&sec2=godmode/setup/os&tab='.$tab.'&message='.$message);
} }
break; break;
default:
case 'new':
$actionHidden = 'save';
$textButton = __('Create');
$classButton = 'class="sub next"';
break;
}
} }
$buttons = [ $buttons = [];
'list' => [ $buttons['list'] = [
'active' => false, 'active' => false,
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=list">'.html_print_image( 'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=list">'.html_print_image(
'images/list.png', 'images/list.png',
@ -182,8 +188,9 @@ $buttons = [
'class' => 'invert_filter', 'class' => 'invert_filter',
] ]
).'</a>', ).'</a>',
], ];
'builder' => [ if ($is_management_allowed === true) {
$buttons['builder'] = [
'active' => false, 'active' => false,
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=builder">'.html_print_image( 'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=builder">'.html_print_image(
'images/builder.png', 'images/builder.png',
@ -193,8 +200,8 @@ $buttons = [
'class' => 'invert_filter', 'class' => 'invert_filter',
] ]
).'</a>', ).'</a>',
], ];
]; }
$buttons[$tab]['active'] = true; $buttons[$tab]['active'] = true;
@ -260,11 +267,14 @@ if (empty($id_message) === false) {
switch ($tab) { switch ($tab) {
case 'list': case 'list':
default:
include_once $config['homedir'].'/godmode/setup/os.list.php'; include_once $config['homedir'].'/godmode/setup/os.list.php';
break; break;
case 'builder': case 'builder':
include_once $config['homedir'].'/godmode/setup/os.builder.php'; include_once $config['homedir'].'/godmode/setup/os.builder.php';
break; break;
default:
// Default.
break;
} }

View File

@ -987,14 +987,11 @@ if ($create_alert || $update_alert) {
echo '</td></tr>'; echo '</td></tr>';
// Alert type (e-mail, event etc.) // Alert type (e-mail, event etc.)
echo '<tr><td class="datos">'.__('Alert action').'</td><td class="datos">'; echo '<tr><td class="datos">'.__('Alert commands').'</td><td class="datos">';
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
html_print_select_from_sql( html_print_select_from_sql(
'SELECT id, name 'SELECT id, name
FROM talert_actions FROM talert_commands
ORDER BY name', ORDER BY name',
'alert_type', 'alert_type',
$alert_type, $alert_type,
@ -1005,24 +1002,6 @@ if ($create_alert || $update_alert) {
false, false,
false false
); );
break;
case 'oracle':
html_print_select_from_sql(
'SELECT id, dbms_lob.substr(name,4000,1) as name
FROM talert_actions
ORDER BY dbms_lob.substr(name,4000,1)',
'alert_type',
$alert_type,
'',
'',
0,
false,
false,
false
);
break;
}
echo '</td></tr>'; echo '</td></tr>';
echo '<tr><td class="datos">'.__('Position').'</td><td class="datos">'; echo '<tr><td class="datos">'.__('Position').'</td><td class="datos">';
@ -1482,7 +1461,6 @@ function time_changed () {
$(document).ready (function () { $(document).ready (function () {
$('#time_threshold').change (time_changed); $('#time_threshold').change (time_changed);
$("input[name=all_delete_box]").change (function() { $("input[name=all_delete_box]").change (function() {
if ($(this).is(":checked")) { if ($(this).is(":checked")) {
$("input[name='delete_ids[]']").check(); $("input[name='delete_ids[]']").check();
@ -1503,10 +1481,9 @@ $(document).ready (function () {
value: "1" value: "1"
}); });
values.push ({ values.push ({
name: "id_action", name: "id",
value: this.value value: this.value
}); });
values.push ({ values.push ({
name: "get_recovery_fields", name: "get_recovery_fields",
value: "0" value: "0"
@ -1515,13 +1492,11 @@ $(document).ready (function () {
values, values,
function (data, status) { function (data, status) {
var max_fields = parseInt('<?php echo $config['max_macro_fields']; ?>'); var max_fields = parseInt('<?php echo $config['max_macro_fields']; ?>');
original_command = js_html_entity_decode (data["command"]); original_command = js_html_entity_decode (data["command"]);
command_description = js_html_entity_decode (data["description"]); command_description = js_html_entity_decode (data["description"]);
for (i = 1; i <= max_fields; i++) { for (i = 1; i <= max_fields; i++) {
var old_value = ''; var old_value = '';
// Only keep the value if is provided from hidden (first time) // Only keep the value if is provided from hidden (first time).
var id_field = $("[name=field" + i + "_value]").attr('id'); var id_field = $("[name=field" + i + "_value]").attr('id');
if (id_field == "hidden-field" + i + "_value") { if (id_field == "hidden-field" + i + "_value") {
@ -1535,24 +1510,10 @@ $(document).ready (function () {
else { else {
$('#table_macros-field' + i).replaceWith(data["fields_rows"][i]); $('#table_macros-field' + i).replaceWith(data["fields_rows"][i]);
// The row provided has a predefined class. We delete it // The row provided has a predefined class. We delete it.
$('#table_macros-field' + i) $('#table_macros-field' + i)
.removeAttr('class'); .removeAttr('class');
//Remove this to put the help message in alert commands, to do it more general
// Add help hint only in first field
/*if (i == 1) {
var td_content =
$('#table_macros-field' + i)
.find('td').eq(0);
td_content
.html(
td_content.html() +
$('#help_snmp_alert_hint').html()
);
}*/
$("[name=field" + i + "_value]").val(old_value); $("[name=field" + i + "_value]").val(old_value);
$('#table_macros-field').show(); $('#table_macros-field').show();
} }
@ -1562,7 +1523,7 @@ $(document).ready (function () {
); );
}); });
// Charge the fields of the action // Charge the fields of the action.
$("#alert_type").trigger('change'); $("#alert_type").trigger('change');
$("#submit-delete_button").click (function () { $("#submit-delete_button").click (function () {

View File

@ -1,20 +1,35 @@
<?php <?php
/**
* Tags.
*
* @category Tags
* @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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Load global vars.
// ==================================================
// 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.
// Load global vars
global $config; global $config;
// Check login and ACLs // Check login and ACLs.
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) { if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
@ -23,36 +38,36 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user
return; return;
} }
// Include functions code // Include functions code.
require_once $config['homedir'].'/include/functions_tags.php'; require_once $config['homedir'].'/include/functions_tags.php';
// Get parameters // Get parameters.
$delete = (int) get_parameter('delete_tag', 0); $delete = (int) get_parameter('delete_tag', 0);
$tag_name = (string) get_parameter('tag_name', ''); $tag_name = (string) get_parameter('tag_name', '');
$tab = (string) get_parameter('tab', 'list'); $tab = (string) get_parameter('tab', 'list');
if ($delete != 0 && is_metaconsole()) { if ($delete !== 0 && is_metaconsole() === true) {
open_meta_frame(); open_meta_frame();
} }
if ($tag_name != '' && is_metaconsole()) { if ($tag_name != '' && is_metaconsole() === true) {
open_meta_frame(); open_meta_frame();
} }
// Metaconsole nodes // Metaconsole nodes.
$servers = false; $servers = false;
if (is_metaconsole()) { if (is_metaconsole() === true) {
enterprise_include_once('include/functions_metaconsole.php'); enterprise_include_once('include/functions_metaconsole.php');
$servers = metaconsole_get_servers(); $servers = metaconsole_get_servers();
} }
// Ajax tooltip to deploy module's count info of a tag. // Ajax tooltip to deploy module's count info of a tag.
if (is_ajax()) { if (is_ajax() === true) {
ob_clean(); ob_clean();
$get_tag_tooltip = (bool) get_parameter('get_tag_tooltip', 0); $get_tag_tooltip = (bool) get_parameter('get_tag_tooltip', 0);
if ($get_tag_tooltip) { if ($get_tag_tooltip === true) {
$id_tag = (int) get_parameter('id_tag'); $id_tag = (int) get_parameter('id_tag');
$tag = tags_search_tag_id($id_tag); $tag = tags_search_tag_id($id_tag);
if ($tag === false) { if ($tag === false) {
@ -60,7 +75,7 @@ if (is_ajax()) {
} }
$local_modules_count = 0; $local_modules_count = 0;
if (is_metaconsole() && !empty($servers)) { if (is_metaconsole() === true && empty($servers) === false) {
$local_modules_count = array_reduce( $local_modules_count = array_reduce(
$servers, $servers,
function ($counter, $server) use ($id_tag) { function ($counter, $server) use ($id_tag) {
@ -78,7 +93,7 @@ if (is_ajax()) {
} }
$policy_modules_count = 0; $policy_modules_count = 0;
if (is_metaconsole() && !empty($servers)) { if (is_metaconsole() === true && empty($servers) === false) {
$policy_modules_count = array_reduce( $policy_modules_count = array_reduce(
$servers, $servers,
function ($counter, $server) use ($id_tag) { function ($counter, $server) use ($id_tag) {
@ -106,8 +121,7 @@ if (is_ajax()) {
return; return;
} }
// ~ enterprise_hook('open_meta_frame'); if (is_metaconsole() === true) {
if (is_metaconsole()) {
$sec = 'advanced'; $sec = 'advanced';
} else { } else {
$sec = 'gmodules'; $sec = 'gmodules';
@ -129,11 +143,8 @@ $buttons = [
$buttons[$tab]['active'] = true; $buttons[$tab]['active'] = true;
if (is_metaconsole()) { if (is_metaconsole() === false) {
// Print header // Header.
// ui_meta_print_header(__('Tags'), "", $buttons);
} else {
// Header
ui_print_page_header( ui_print_page_header(
__('Tags configuration'), __('Tags configuration'),
'images/tag.png', 'images/tag.png',
@ -145,39 +156,51 @@ if (is_metaconsole()) {
} }
// Two actions can performed in this page: search and delete tags // Two actions can performed in this page: search and delete tags
// Delete action: This will delete a tag // Delete action: This will delete a tag.
if ($delete != 0) { if ($delete !== 0) {
$return_delete = tags_delete_tag($delete); $return_delete = tags_delete_tag($delete);
if ($return_delete === false) { if ($return_delete === false) {
db_pandora_audit('Tag management', "Fail try to delete tag #$delete"); db_pandora_audit('Tag management', 'Fail try to delete tag #'.$delete);
ui_print_error_message(__('Error deleting tag')); ui_print_error_message(__('Error deleting tag'));
} else { } else {
db_pandora_audit('Tag management', "Delete tag #$delete"); db_pandora_audit('Tag management', 'Delete tag #'.$delete);
ui_print_success_message(__('Successfully deleted tag')); ui_print_success_message(__('Successfully deleted tag'));
} }
} }
// Search action: This will filter the display tag view $is_management_allowed = is_management_allowed();
if ($is_management_allowed === false) {
ui_print_warning_message(
__(
'This node is configured with centralized mode. All tags information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/component_management'
).'">'.__('metaconsole').'</a>'
)
);
}
// Search action: This will filter the display tag view.
$filter = []; $filter = [];
// Filtered view? // Filtered view?
if (!empty($tag_name)) { if (empty($tag_name) === false) {
$filter['name'] = $tag_name; $filter['name'] = $tag_name;
} }
// If the user has filtered the view // If the user has filtered the view.
$filter_performed = !empty($filter); $filter_performed = !empty($filter);
$filter['offset'] = (int) get_parameter('offset'); $filter['offset'] = (int) get_parameter('offset');
$filter['limit'] = (int) $config['block_size']; $filter['limit'] = (int) $config['block_size'];
// statements for pagination // Statements for pagination.
$url = ui_get_url_refresh(); $url = ui_get_url_refresh();
$total_tags = tags_get_tag_count($filter); $total_tags = tags_get_tag_count($filter);
$result = tags_search_tag(false, $filter); $result = tags_search_tag(false, $filter);
// Filter form // Filter form.
$table = new StdClass(); $table = new StdClass();
$table->class = 'databox filters'; $table->class = 'databox filters';
$table->width = '100%'; $table->width = '100%';
@ -198,18 +221,18 @@ $table->data[] = $row;
$filter_form = '<form method="POST" action="index.php?sec='.$sec.'&sec2=godmode/tag/tag&tag_name="'.$tag_name.'>'; $filter_form = '<form method="POST" action="index.php?sec='.$sec.'&sec2=godmode/tag/tag&tag_name="'.$tag_name.'>';
$filter_form .= html_print_table($table, true); $filter_form .= html_print_table($table, true);
$filter_form .= '</form>'; $filter_form .= '</form>';
// End of filter form // End of filter form.
if (!empty($result)) { if (empty($result) === false) {
if (!is_metaconsole()) { if (is_metaconsole() === false) {
echo $filter_form; echo $filter_form;
} else { } else {
ui_toggle($filter_form, __('Show Options')); ui_toggle($filter_form, __('Show Options'));
} }
// Prepare pagination // Prepare pagination.
ui_pagination($total_tags, $url); ui_pagination($total_tags, $url);
// Display tags previously filtered or not // Display tags previously filtered or not.
$rowPair = true; $rowPair = true;
$iterator = 0; $iterator = 0;
@ -240,7 +263,9 @@ if (!empty($result)) {
$table->head[3] = __('Number of modules affected'); $table->head[3] = __('Number of modules affected');
$table->head[4] = __('Email'); $table->head[4] = __('Email');
$table->head[5] = __('Phone'); $table->head[5] = __('Phone');
if ($is_management_allowed === true) {
$table->head[6] = __('Actions'); $table->head[6] = __('Actions');
}
foreach ($result as $tag) { foreach ($result as $tag) {
if ($rowPair) { if ($rowPair) {
@ -254,11 +279,18 @@ if (!empty($result)) {
$data = []; $data = [];
$data[0] = "<a href='index.php?sec=".$sec.'&sec2=godmode/tag/edit_tag&action=update&id_tag='.$tag['id_tag']."'>".$tag['name'].'</a>'; if ($is_management_allowed === true) {
$data[0] = "<a href='index.php?sec=".$sec.'&sec2=godmode/tag/edit_tag&action=update&id_tag='.$tag['id_tag']."'>";
$data[0] .= $tag['name'];
$data[0] .= '</a>';
} else {
$data[0] = $tag['name'];
}
$data[1] = ui_print_truncate_text($tag['description'], 'description', false); $data[1] = ui_print_truncate_text($tag['description'], 'description', false);
$data[2] = '<a href="'.$tag['url'].'">'.$tag['url'].'</a>'; $data[2] = '<a href="'.$tag['url'].'">'.$tag['url'].'</a>';
// The tooltip needs a title on the item, don't delete the title // The tooltip needs a title on the item, don't delete the title.
$data[3] = '<a class="tag_details img_help" title="'.__('Tag details').'" $data[3] = '<a class="tag_details img_help" title="'.__('Tag details').'"
href="'.ui_get_full_url(false, false, false, false).'/ajax.php?page=godmode/tag/tag&get_tag_tooltip=1&id_tag='.$tag['id_tag'].'">'.html_print_image( href="'.ui_get_full_url(false, false, false, false).'/ajax.php?page=godmode/tag/tag&get_tag_tooltip=1&id_tag='.$tag['id_tag'].'">'.html_print_image(
'images/zoom.png', 'images/zoom.png',
@ -267,7 +299,7 @@ if (!empty($result)) {
).'</a> '; ).'</a> ';
$modules_count = 0; $modules_count = 0;
if (is_metaconsole() && !empty($servers)) { if (is_metaconsole() === true && empty($servers) === false) {
$tag_id = $tag['id_tag']; $tag_id = $tag['id_tag'];
$modules_count = array_reduce( $modules_count = array_reduce(
$servers, $servers,
@ -292,11 +324,20 @@ if (!empty($result)) {
if ($email_large == $email_small) { if ($email_large == $email_small) {
$output = $email_large; $output = $email_large;
} else { } else {
$output = "<div title='".sprintf(__('Emails for the tag: %s'), $tag['name'])."' class='email_large invisible' id='email_large_".$tag['id_tag']."'>".$email_large.'</div>'.'<span id="value_'.$tag['id_tag'].'">'.$email_small.'</span> '."<a href='javascript: show_dialog(".$tag['id_tag'].")'>".html_print_image( $title_mail = sprintf(__('Emails for the tag: %s'), $tag['name']);
$output = "<div title='".$title_mail."' class='email_large invisible' id='email_large_".$tag['id_tag']."'>";
$output .= $email_large;
$output .= '</div>';
$output .= '<span id="value_'.$tag['id_tag'].'">';
$output .= $email_small;
$output .= '</span> ';
$output .= "<a href='javascript: show_dialog(".$tag['id_tag'].")'>";
$output .= html_print_image(
'images/rosette.png', 'images/rosette.png',
true, true,
['class' => 'invert_filter'] ['class' => 'invert_filter']
).''.'</a></span>'; );
$output .= '</a></span>';
} }
$data[4] = $output; $data[4] = $output;
@ -306,24 +347,34 @@ if (!empty($result)) {
if ($phone_large == $phone_small) { if ($phone_large == $phone_small) {
$output = $phone_large; $output = $phone_large;
} else { } else {
$output = "<div title='".sprintf(__('Phones for the tag: %s'), $tag['name'])."' class='phone_large invisible' id='phone_large_".$tag['id_tag']."'>".$phone_large.'</div>'.'<span id="value_'.$tag['id_tag'].'">'.$phone_small.'</span> '."<a href='javascript: show_phone_dialog(".$tag['id_tag'].")'>".html_print_image( $t_phone = sprintf(__('Phones for the tag: %s'), $tag['name']);
$output = "<div title='".$t_phone."' class='phone_large invisible' id='phone_large_".$tag['id_tag']."'>";
$output .= $phone_large;
$output .= '</div>';
$output .= '<span id="value_'.$tag['id_tag'].'">'.$phone_small.'</span> ';
$output .= "<a href='javascript: show_phone_dialog(".$tag['id_tag'].")'>";
$output .= html_print_image(
'images/rosette.png', 'images/rosette.png',
true, true,
['class' => 'invert_filter'] ['class' => 'invert_filter']
).''.'</a></span>'; );
$output .= '</a></span>';
} }
$data[5] = $output; $data[5] = $output;
if ($is_management_allowed === true) {
$table->cellclass[][6] = 'action_buttons'; $table->cellclass[][6] = 'action_buttons';
$data[6] = "<a href='index.php?sec=".$sec.'&sec2=godmode/tag/edit_tag&action=update&id_tag='.$tag['id_tag']."'>".html_print_image( $data[6] = "<a href='index.php?sec=".$sec.'&sec2=godmode/tag/edit_tag&action=update&id_tag='.$tag['id_tag']."'>";
$data[6] .= html_print_image(
'images/config.png', 'images/config.png',
true, true,
[ [
'title' => 'Edit', 'title' => 'Edit',
'class' => 'invert_filter', 'class' => 'invert_filter',
] ]
).'</a>'; );
$data[6] .= '</a>';
$data[6] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/tag/tag&delete_tag='.$tag['id_tag'].'"onclick="if (! confirm (\''.__('Are you sure?').'\')) return false">'.html_print_image( $data[6] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/tag/tag&delete_tag='.$tag['id_tag'].'"onclick="if (! confirm (\''.__('Are you sure?').'\')) return false">'.html_print_image(
'images/cross.png', 'images/cross.png',
true, true,
@ -332,13 +383,15 @@ if (!empty($result)) {
'class' => 'invert_filter', 'class' => 'invert_filter',
] ]
).'</a>'; ).'</a>';
}
array_push($table->data, $data); array_push($table->data, $data);
} }
html_print_table($table); html_print_table($table);
ui_pagination($total_tags, $url, 0, 0, false, 'offset', true, 'pagination-bottom'); ui_pagination($total_tags, $url, 0, 0, false, 'offset', true, 'pagination-bottom');
} else { } else {
if (is_metaconsole()) { if (is_metaconsole() === true) {
ui_toggle($filter_form, __('Show Options')); ui_toggle($filter_form, __('Show Options'));
ui_print_info_message(['no_close' => true, 'message' => __('No tags defined')]); ui_print_info_message(['no_close' => true, 'message' => __('No tags defined')]);
} else if ($filter_performed) { } else if ($filter_performed) {
@ -349,7 +402,8 @@ if (!empty($result)) {
} }
} }
echo '<table border=0 cellpadding=0 cellspacing=0 width=100%>'; if ($is_management_allowed === true) {
echo '<table border=0 cellpadding=0 cellspacing=0 width=100%>';
echo '<tr>'; echo '<tr>';
echo '<td align=right>'; echo '<td align=right>';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/tag/edit_tag&action=new">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/tag/edit_tag&action=new">';
@ -358,17 +412,16 @@ echo '<table border=0 cellpadding=0 cellspacing=0 width=100%>';
echo '</form>'; echo '</form>';
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';
}
if ($delete != 0 && is_metaconsole()) { if ($delete != 0 && is_metaconsole() === true) {
close_meta_frame(); close_meta_frame();
} }
// ~ enterprise_hook('close_meta_frame');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$("a.tag_details") $("a.tag_details")
.tooltip({ .tooltip({
track: true, track: true,
@ -376,7 +429,6 @@ if ($delete != 0 && is_metaconsole()) {
open: function (evt, ui) { open: function (evt, ui) {
var elem = $(this); var elem = $(this);
var uri = elem.prop('href'); var uri = elem.prop('href');
if (typeof uri !== 'undefined' && uri.length > 0) { if (typeof uri !== 'undefined' && uri.length > 0) {
var jqXHR = $.ajax(uri).done(function(data) { var jqXHR = $.ajax(uri).done(function(data) {
elem.tooltip('option', 'content', data); elem.tooltip('option', 'content', data);
@ -384,14 +436,12 @@ if ($delete != 0 && is_metaconsole()) {
// Store the connection handler // Store the connection handler
elem.data('jqXHR', jqXHR); elem.data('jqXHR', jqXHR);
} }
$(".ui-tooltip>.ui-tooltip-content:not(.cluetip-default)") $(".ui-tooltip>.ui-tooltip-content:not(.cluetip-default)")
.addClass("cluetip-default"); .addClass("cluetip-default");
}, },
close: function (evt, ui) { close: function (evt, ui) {
var elem = $(this); var elem = $(this);
var jqXHR = elem.data('jqXHR'); var jqXHR = elem.data('jqXHR');
// Close the connection handler // Close the connection handler
if (typeof jqXHR !== 'undefined') if (typeof jqXHR !== 'undefined')
jqXHR.abort(); jqXHR.abort();
@ -401,19 +451,16 @@ if ($delete != 0 && is_metaconsole()) {
event.preventDefault(); event.preventDefault();
}) })
.css('cursor', 'help'); .css('cursor', 'help');
$(".email_large, .phone_large").dialog({ $(".email_large, .phone_large").dialog({
autoOpen: false, autoOpen: false,
resizable: true, resizable: true,
width: 400, width: 400,
height: 200 height: 200
}); });
function show_dialog(id) { function show_dialog(id) {
$("#email_large_" + id).dialog("open"); $("#email_large_" + id).dialog("open");
} }
function show_phone_dialog(id) { function show_phone_dialog(id) {
$("#phone_large_" + id).dialog("open"); $("#phone_large_" + id).dialog("open");
} }
</script> </script>

View File

@ -70,6 +70,10 @@ if (empty($license) === true) {
} }
$mode_str = ''; $mode_str = '';
if (isset($mode) === false) {
$mode = null;
}
if ($mode === Manager::MODE_ONLINE) { if ($mode === Manager::MODE_ONLINE) {
$mode_str = 'online'; $mode_str = 'online';
} else if ($mode === Manager::MODE_OFFLINE) { } else if ($mode === Manager::MODE_OFFLINE) {

View File

@ -941,6 +941,15 @@ class Client
$queries = preg_split("/(;\n)|(;\n\r)/", $sql); $queries = preg_split("/(;\n)|(;\n\r)/", $sql);
foreach ($queries as $query) { foreach ($queries as $query) {
if (empty($query) !== true) { if (empty($query) !== true) {
if (preg_match('/^\s*LOAD\s+(.*)$/i', $query, $matches) > 0) {
$filepath = dirname($mr_file).'/'.$matches[1];
if (file_exists($filepath) === true) {
$query = file_get_contents($filepath);
} else {
throw new \Exception('Cannot load file: '.$filepath);
}
}
if ($dbh->query($query) === false) { if ($dbh->query($query) === false) {
// 1022: Duplicate key in table. // 1022: Duplicate key in table.
// 1050: Table already defined. // 1050: Table already defined.
@ -1331,18 +1340,17 @@ class Client
error_reporting(E_ALL ^ E_NOTICE); error_reporting(E_ALL ^ E_NOTICE);
set_error_handler( set_error_handler(
function ($errno, $errstr) { function ($errno, $errstr) {
if (preg_match('/Undefined index/', $errstr) > 1) {
return;
}
throw new \Exception($errstr, $errno); throw new \Exception($errstr, $errno);
} },
E_ERROR
); );
register_shutdown_function( register_shutdown_function(
function () { function () {
$error = error_get_last(); $error = error_get_last();
if (null !== $error) { if (null !== $error
&& $error['type'] === E_ERROR
) {
echo __('Failed to analyze package: %s', $error['message']); echo __('Failed to analyze package: %s', $error['message']);
} }
} }
@ -1425,7 +1433,8 @@ class Client
set_error_handler( set_error_handler(
function ($errno, $errstr) { function ($errno, $errstr) {
throw new \Exception($errstr, $errno); throw new \Exception($errstr, $errno);
} },
E_ERROR
); );
if ($package === null) { if ($package === null) {

View File

@ -296,7 +296,7 @@ if ($new_user && $config['admin_can_add_user']) {
// This attributes are inherited from global configuration // This attributes are inherited from global configuration
$user_info['block_size'] = $config['block_size']; $user_info['block_size'] = $config['block_size'];
if (enterprise_installed() && defined('METACONSOLE')) { if (enterprise_installed() && is_metaconsole() === true) {
$user_info['metaconsole_agents_manager'] = 0; $user_info['metaconsole_agents_manager'] = 0;
$user_info['metaconsole_assigned_server'] = ''; $user_info['metaconsole_assigned_server'] = '';
$user_info['metaconsole_access_node'] = 0; $user_info['metaconsole_access_node'] = 0;

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* Profiles.
*
* @category Profiles
* @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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Load global vars.
// ==================================================
// 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.
// Load global vars
global $config; global $config;
check_login(); check_login();
@ -36,8 +51,8 @@ enterprise_include_once('meta/include/functions_users_meta.php');
$tab = get_parameter('tab', 'profile'); $tab = get_parameter('tab', 'profile');
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
// Header // Header.
if (!defined('METACONSOLE')) { if (is_metaconsole() === false) {
$buttons = [ $buttons = [
'user' => [ 'user' => [
'active' => false, 'active' => false,
@ -79,15 +94,27 @@ if (!defined('METACONSOLE')) {
$sec = 'advanced'; $sec = 'advanced';
} }
$delete_profile = (bool) get_parameter('delete_profile'); $delete_profile = (bool) get_parameter('delete_profile');
$create_profile = (bool) get_parameter('create_profile'); $create_profile = (bool) get_parameter('create_profile');
$update_profile = (bool) get_parameter('update_profile'); $update_profile = (bool) get_parameter('update_profile');
$id_profile = (int) get_parameter('id'); $id_profile = (int) get_parameter('id');
// Profile deletion $is_management_allowed = true;
if ($delete_profile) { if (is_management_allowed() === false) {
// Delete profile $is_management_allowed = false;
ui_print_warning_message(
__(
'This node is configured with centralized mode. All profiles information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/users_setup&tab=profile&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
}
// Profile deletion.
if ($is_management_allowed === true && $delete_profile === true) {
// Delete profile.
$profile = db_get_row('tperfil', 'id_perfil', $id_profile); $profile = db_get_row('tperfil', 'id_perfil', $id_profile);
$ret = profile_delete_profile_and_clean_users($id_profile); $ret = profile_delete_profile_and_clean_users($id_profile);
if ($ret === false) { if ($ret === false) {
@ -103,44 +130,44 @@ if ($delete_profile) {
$id_profile = 0; $id_profile = 0;
} }
// Store the variables when create or update // Store the variables when create or update.
if ($create_profile || $update_profile) { if ($is_management_allowed === true && ($create_profile === true || $update_profile === true)) {
$name = get_parameter('name'); $name = get_parameter('name');
// Agents // Agents.
$agent_view = (bool) get_parameter('agent_view'); $agent_view = (bool) get_parameter('agent_view');
$agent_edit = (bool) get_parameter('agent_edit'); $agent_edit = (bool) get_parameter('agent_edit');
$agent_disable = (bool) get_parameter('agent_disable'); $agent_disable = (bool) get_parameter('agent_disable');
// Alerts // Alerts.
$alert_edit = (bool) get_parameter('alert_edit'); $alert_edit = (bool) get_parameter('alert_edit');
$alert_management = (bool) get_parameter('alert_management'); $alert_management = (bool) get_parameter('alert_management');
// Users // Users.
$user_management = (bool) get_parameter('user_management'); $user_management = (bool) get_parameter('user_management');
// DB // DB.
$db_management = (bool) get_parameter('db_management'); $db_management = (bool) get_parameter('db_management');
// Pandora // Pandora.
$pandora_management = (bool) get_parameter('pandora_management'); $pandora_management = (bool) get_parameter('pandora_management');
// Events // Events.
$event_view = (bool) get_parameter('event_view'); $event_view = (bool) get_parameter('event_view');
$event_edit = (bool) get_parameter('event_edit'); $event_edit = (bool) get_parameter('event_edit');
$event_management = (bool) get_parameter('event_management'); $event_management = (bool) get_parameter('event_management');
// Reports // Reports.
$report_view = (bool) get_parameter('report_view'); $report_view = (bool) get_parameter('report_view');
$report_edit = (bool) get_parameter('report_edit'); $report_edit = (bool) get_parameter('report_edit');
$report_management = (bool) get_parameter('report_management'); $report_management = (bool) get_parameter('report_management');
// Network maps // Network maps.
$map_view = (bool) get_parameter('map_view'); $map_view = (bool) get_parameter('map_view');
$map_edit = (bool) get_parameter('map_edit'); $map_edit = (bool) get_parameter('map_edit');
$map_management = (bool) get_parameter('map_management'); $map_management = (bool) get_parameter('map_management');
// Visual console // Visual console.
$vconsole_view = (bool) get_parameter('vconsole_view'); $vconsole_view = (bool) get_parameter('vconsole_view');
$vconsole_edit = (bool) get_parameter('vconsole_edit'); $vconsole_edit = (bool) get_parameter('vconsole_edit');
$vconsole_management = (bool) get_parameter('vconsole_management'); $vconsole_management = (bool) get_parameter('vconsole_management');
@ -170,9 +197,9 @@ if ($create_profile || $update_profile) {
]; ];
} }
// Update profile // Update profile.
if ($update_profile) { if ($is_management_allowed === true && $update_profile === true) {
if ($name) { if (empty($name) === false) {
$ret = db_process_sql_update('tperfil', $values, ['id_perfil' => $id_profile]); $ret = db_process_sql_update('tperfil', $values, ['id_perfil' => $id_profile]);
if ($ret !== false) { if ($ret !== false) {
$info = '{"Name":"'.$name.'", $info = '{"Name":"'.$name.'",
@ -216,9 +243,9 @@ if ($update_profile) {
$id_profile = 0; $id_profile = 0;
} }
// Create profile // Create profile.
if ($create_profile) { if ($is_management_allowed === true && $create_profile === true) {
if ($name) { if (empty($name) === false) {
$ret = db_process_sql_insert('tperfil', $values); $ret = db_process_sql_insert('tperfil', $values);
if ($ret !== false) { if ($ret !== false) {
@ -295,7 +322,9 @@ $table->head['VR'] = 'VR';
$table->head['VW'] = 'VW'; $table->head['VW'] = 'VW';
$table->head['VM'] = 'VM'; $table->head['VM'] = 'VM';
$table->head['PM'] = 'PM'; $table->head['PM'] = 'PM';
$table->head['operations'] = '<span title="Operations">'.__('Op.').'</span>'; if ($is_management_allowed === true) {
$table->head['operations'] = '<span title="Operations">'.__('Op.').'</span>';
}
$table->align = array_fill(1, 11, 'center'); $table->align = array_fill(1, 11, 'center');
@ -320,7 +349,9 @@ $table->size['VR'] = '10px';
$table->size['VW'] = '10px'; $table->size['VW'] = '10px';
$table->size['VM'] = '10px'; $table->size['VM'] = '10px';
$table->size['PM'] = '10px'; $table->size['PM'] = '10px';
$table->size['operations'] = '5%'; if ($is_management_allowed === true) {
$table->size['operations'] = '5%';
}
$profiles = db_get_all_rows_in_table('tperfil'); $profiles = db_get_all_rows_in_table('tperfil');
if ($profiles === false) { if ($profiles === false) {
@ -337,28 +368,36 @@ $img = html_print_image(
); );
foreach ($profiles as $profile) { foreach ($profiles as $profile) {
$data['profiles'] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_profile&id='.$profile['id_perfil'].'&pure='.$pure.'">'.$profile['name'].'</a>'; if ($is_management_allowed === true) {
$data['AR'] = ($profile['agent_view'] ? $img : ''); $data['profiles'] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_profile&id='.$profile['id_perfil'].'&pure='.$pure.'">';
$data['AW'] = ($profile['agent_edit'] ? $img : ''); $data['profiles'] .= $profile['name'];
$data['AD'] = ($profile['agent_disable'] ? $img : ''); $data['profiles'] .= '</a>';
$data['LW'] = ($profile['alert_edit'] ? $img : ''); } else {
$data['LM'] = ($profile['alert_management'] ? $img : ''); $data['profiles'] = $profile['name'];
$data['UM'] = ($profile['user_management'] ? $img : ''); }
$data['DM'] = ($profile['db_management'] ? $img : '');
$data['ER'] = ($profile['event_view'] ? $img : ''); $data['AR'] = (empty($profile['agent_view']) === false) ? $img : '';
$data['EW'] = ($profile['event_edit'] ? $img : ''); $data['AW'] = (empty($profile['agent_edit']) === false) ? $img : '';
$data['EM'] = ($profile['event_management'] ? $img : ''); $data['AD'] = (empty($profile['agent_disable']) === false) ? $img : '';
$data['RR'] = ($profile['report_view'] ? $img : ''); $data['LW'] = (empty($profile['alert_edit']) === false) ? $img : '';
$data['RW'] = ($profile['report_edit'] ? $img : ''); $data['LM'] = (empty($profile['alert_management']) === false) ? $img : '';
$data['RM'] = ($profile['report_management'] ? $img : ''); $data['UM'] = (empty($profile['user_management']) === false) ? $img : '';
$data['MR'] = ($profile['map_view'] ? $img : ''); $data['DM'] = (empty($profile['db_management']) === false) ? $img : '';
$data['MW'] = ($profile['map_edit'] ? $img : ''); $data['ER'] = (empty($profile['event_view']) === false) ? $img : '';
$data['MM'] = ($profile['map_management'] ? $img : ''); $data['EW'] = (empty($profile['event_edit']) === false) ? $img : '';
$data['VR'] = ($profile['vconsole_view'] ? $img : ''); $data['EM'] = (empty($profile['event_management']) === false) ? $img : '';
$data['VW'] = ($profile['vconsole_edit'] ? $img : ''); $data['RR'] = (empty($profile['report_view']) === false) ? $img : '';
$data['VM'] = ($profile['vconsole_management'] ? $img : ''); $data['RW'] = (empty($profile['report_edit']) === false) ? $img : '';
$data['PM'] = ($profile['pandora_management'] ? $img : ''); $data['RM'] = (empty($profile['report_management']) === false) ? $img : '';
$data['MR'] = (empty($profile['map_view']) === false) ? $img : '';
$data['MW'] = (empty($profile['map_edit']) === false) ? $img : '';
$data['MM'] = (empty($profile['map_management']) === false) ? $img : '';
$data['VR'] = (empty($profile['vconsole_view']) === false) ? $img : '';
$data['VW'] = (empty($profile['vconsole_edit']) === false) ? $img : '';
$data['VM'] = (empty($profile['vconsole_management']) === false) ? $img : '';
$data['PM'] = (empty($profile['pandora_management']) === false) ? $img : '';
$table->cellclass[]['operations'] = 'action_buttons'; $table->cellclass[]['operations'] = 'action_buttons';
if ($is_management_allowed === true) {
$data['operations'] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_profile&id='.$profile['id_perfil'].'&pure='.$pure.'">'.html_print_image( $data['operations'] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_profile&id='.$profile['id_perfil'].'&pure='.$pure.'">'.html_print_image(
'images/config.png', 'images/config.png',
true, true,
@ -371,25 +410,32 @@ foreach ($profiles as $profile) {
$data['operations'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/users/profile_list&delete_profile=1&id='.$profile['id_perfil'].'&pure='.$pure.'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image( $data['operations'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/users/profile_list&delete_profile=1&id='.$profile['id_perfil'].'&pure='.$pure.'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
'images/cross.png', 'images/cross.png',
true, true,
['class' => 'invert_filter'] [
'title' => __('Delete'),
'class' => 'invert_filter',
]
).'</a>'; ).'</a>';
} }
}
array_push($table->data, $data); array_push($table->data, $data);
} }
if (isset($data)) { if (isset($data) === true) {
html_print_table($table); html_print_table($table);
} else { } else {
echo "<div class='nf'>".__('There are no defined profiles').'</div>'; echo "<div class='nf'>".__('There are no defined profiles').'</div>';
} }
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/users/configure_profile&pure='.$pure.'">'; if ($is_management_allowed === true) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/users/configure_profile&pure='.$pure.'">';
html_print_input_hidden('new_profile', 1); echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"'); html_print_input_hidden('new_profile', 1);
echo '</div>'; html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"');
echo '</form>'; echo '</div>';
echo '</form>';
}
unset($table); unset($table);
enterprise_hook('close_meta_frame'); enterprise_hook('close_meta_frame');

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* Users.
*
* @category Users
* @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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Load global vars.
// ==================================================
// 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.
// Load global vars
global $config; global $config;
check_login(); check_login();
@ -112,6 +127,10 @@ switch ($sortField) {
'order' => 'DESC', 'order' => 'DESC',
]; ];
break; break;
default:
// Not possible.
break;
} }
break; break;
@ -132,6 +151,10 @@ switch ($sortField) {
'order' => 'DESC', 'order' => 'DESC',
]; ];
break; break;
default:
// Not possible.
break;
} }
break; break;
@ -152,6 +175,10 @@ switch ($sortField) {
'order' => 'DESC', 'order' => 'DESC',
]; ];
break; break;
default:
// Not possible.
break;
} }
break; break;
@ -171,8 +198,8 @@ switch ($sortField) {
$buttons[$tab]['active'] = true; $buttons[$tab]['active'] = true;
// Header // Header.
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
user_meta_print_header(); user_meta_print_header();
$sec = 'advanced'; $sec = 'advanced';
} else { } else {
@ -234,9 +261,9 @@ if (defined('METACONSOLE')) {
$disable_user = get_parameter('disable_user', false); $disable_user = get_parameter('disable_user', false);
if ((bool) get_parameter('user_del', false) === true) { if ((bool) get_parameter('user_del', false) === true) {
// delete user // Delete user.
$id_user = get_parameter('delete_user', 0); $id_user = get_parameter('delete_user', 0);
// Only allow delete user if is not the actual user // Only allow delete user if is not the actual user.
if ($id_user != $config['id_user']) { if ($id_user != $config['id_user']) {
$user_row = users_get_user_by_id($id_user); $user_row = users_get_user_by_id($id_user);
@ -255,13 +282,13 @@ if ((bool) get_parameter('user_del', false) === true) {
__('There was a problem deleting the user') __('There was a problem deleting the user')
); );
// Delete the user in all the consoles // Delete the user in all the consoles.
if (defined('METACONSOLE') && isset($_GET['delete_all'])) { if (is_metaconsole() === true && isset($_GET['delete_all'])) {
$servers = metaconsole_get_servers(); $servers = metaconsole_get_servers();
foreach ($servers as $server) { foreach ($servers as $server) {
// Connect to the remote console. // Connect to the remote console.
if (metaconsole_connect($server) === NOERR) { if (metaconsole_connect($server) === NOERR) {
// Delete the user // Delete the user.
$result = delete_user($id_user); $result = delete_user($id_user);
if ($result) { if ($result) {
db_pandora_audit( db_pandora_audit(
@ -274,7 +301,7 @@ if ((bool) get_parameter('user_del', false) === true) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
// Log to the metaconsole too // Log to the metaconsole too.
if ($result) { if ($result) {
db_pandora_audit( db_pandora_audit(
'User management', 'User management',
@ -293,7 +320,7 @@ if ((bool) get_parameter('user_del', false) === true) {
ui_print_error_message(__('There was a problem deleting the user')); ui_print_error_message(__('There was a problem deleting the user'));
} }
} else if (isset($_GET['profile_del'])) { } else if (isset($_GET['profile_del'])) {
// delete profile // Delete profile.
$id_profile = (int) get_parameter_post('delete_profile'); $id_profile = (int) get_parameter_post('delete_profile');
$result = profile_delete_profile($id_profile); $result = profile_delete_profile($id_profile);
ui_print_result_message( ui_print_result_message(
@ -302,7 +329,7 @@ if ((bool) get_parameter('user_del', false) === true) {
__('There was a problem deleting the profile') __('There was a problem deleting the profile')
); );
} else if ($disable_user !== false) { } else if ($disable_user !== false) {
// disable_user // Disable_user.
$id_user = get_parameter('id', 0); $id_user = get_parameter('id', 0);
if ($id_user !== 0) { if ($id_user !== 0) {
@ -367,8 +394,21 @@ $table->data[0][4] = html_print_submit_button(
true true
); );
$is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
ui_print_warning_message(
__(
'This node is configured with centralized mode. All users information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/users_setup&tab=user&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
}
if (defined('METACONSOLE')) {
if (is_metaconsole() === true) {
$table->width = '96%'; $table->width = '96%';
$form_filter = "<form class='filters_form' method='post'>"; $form_filter = "<form class='filters_form' method='post'>";
$form_filter .= html_print_table($table, true); $form_filter .= html_print_table($table, true);
@ -415,21 +455,24 @@ $table->head[2] = __('Last contact').ui_get_sorting_arrows($url_up_last, $url_do
$table->head[3] = __('Admin'); $table->head[3] = __('Admin');
$table->head[4] = __('Profile / Group'); $table->head[4] = __('Profile / Group');
$table->head[5] = __('Description'); $table->head[5] = __('Description');
$table->head[6] = '<span title="Operations">'.__('Op.').'</span>'; if ($is_management_allowed === true) {
if (!defined('METACONSOLE')) { $table->head[6] = '<span title="Operations">'.__('Op.').'</span>';
}
if (is_metaconsole() === false) {
$table->align[2] = ''; $table->align[2] = '';
$table->size[2] = '150px'; $table->size[2] = '150px';
} }
$table->align[3] = 'left'; $table->align[3] = 'left';
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
$table->size[6] = '110px'; $table->size[6] = '110px';
} else { } else {
$table->size[6] = '85px'; $table->size[6] = '85px';
} }
if (!defined('METACONSOLE')) { if (is_metaconsole() === false) {
$table->valign[0] = 'top'; $table->valign[0] = 'top';
$table->valign[1] = 'top'; $table->valign[1] = 'top';
$table->valign[2] = 'top'; $table->valign[2] = 'top';
@ -457,7 +500,7 @@ if ($user_is_admin) {
} }
} }
// Filter the users // Filter the users.
if ($search) { if ($search) {
foreach ($info1 as $iterator => $user_info) { foreach ($info1 as $iterator => $user_info) {
$found = false; $found = false;
@ -498,7 +541,7 @@ if ($search) {
$info = $info1; $info = $info1;
// Prepare pagination // Prepare pagination.
ui_pagination(count($info)); ui_pagination(count($info));
$offset = (int) get_parameter('offset'); $offset = (int) get_parameter('offset');
@ -515,18 +558,22 @@ foreach ($info as $user_id => $user_info) {
// User profiles. // User profiles.
if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) { if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) {
$user_profiles = db_get_all_rows_field_filter('tusuario_perfil', 'id_usuario', $user_id); $user_profiles = db_get_all_rows_field_filter(
'tusuario_perfil',
'id_usuario',
$user_id
);
} else { } else {
$user_profiles_aux = users_get_user_profile($user_id); $user_profiles_aux = users_get_user_profile($user_id);
$user_profiles = []; $user_profiles = [];
foreach ($group_um as $key => $value) { foreach ($group_um as $key => $value) {
if (isset($user_profiles_aux[$key])) { if (isset($user_profiles_aux[$key]) === true) {
$user_profiles[$key] = $user_profiles_aux[$key]; $user_profiles[$key] = $user_profiles_aux[$key];
unset($user_profiles_aux[$key]); unset($user_profiles_aux[$key]);
} }
} }
if (!empty($user_profiles_aux)) { if (empty($user_profiles_aux) === false) {
$user_info['not_delete'] = 1; $user_info['not_delete'] = 1;
} }
@ -537,7 +584,7 @@ foreach ($info as $user_id => $user_info) {
$cont++; $cont++;
// Manual pagination due the complicated process of the ACL data // Manual pagination due the complicated process of the ACL data.
if ($cont <= $offset) { if ($cont <= $offset) {
continue; continue;
} }
@ -560,7 +607,13 @@ foreach ($info as $user_id => $user_info) {
$iterator++; $iterator++;
if ($user_is_admin || $config['id_user'] == $user_info['id_user'] || (!$user_info['is_admin'] && (!isset($user_info['edit']) || isset($group_um[0]) || (isset($user_info['edit']) && $user_info['edit'])))) { if ($is_management_allowed === true
&& ($user_is_admin
|| $config['id_user'] == $user_info['id_user']
|| (!$user_info['is_admin'] && (!isset($user_info['edit'])
|| isset($group_um[0]) || (isset($user_info['edit'])
&& $user_info['edit']))))
) {
$data[0] = '<a href="#" onclick="document.forms[\'edit_user_form_'.$user_info['id_user'].'\'].submit();">'.$user_id.'</a>'; $data[0] = '<a href="#" onclick="document.forms[\'edit_user_form_'.$user_info['id_user'].'\'].submit();">'.$user_id.'</a>';
} else { } else {
$data[0] = $user_id; $data[0] = $user_id;
@ -627,8 +680,12 @@ foreach ($info as $user_id => $user_info) {
$total_profile++; $total_profile++;
} }
if (isset($user_info['not_delete'])) { if (isset($user_info['not_delete']) === true) {
$data[4] .= __('Other profiles are also assigned.').ui_print_help_tip(__('Other profiles you cannot manage are also assigned. These profiles are not shown. You cannot enable/disable or delete this user.'), true); $data[4] .= __('Other profiles are also assigned.');
$data[4] .= ui_print_help_tip(
__('Other profiles you cannot manage are also assigned. These profiles are not shown. You cannot enable/disable or delete this user.'),
true
);
} }
$data[4] .= '</div>'; $data[4] .= '</div>';
@ -638,9 +695,15 @@ foreach ($info as $user_id => $user_info) {
$data[5] = ui_print_string_substr($user_info['comments'], 24, true); $data[5] = ui_print_string_substr($user_info['comments'], 24, true);
if ($is_management_allowed === true) {
$table->cellclass[][6] = 'action_buttons'; $table->cellclass[][6] = 'action_buttons';
$data[6] = ''; $data[6] = '';
if ($user_is_admin || $config['id_user'] == $user_info['id_user'] || isset($group_um[0]) || (!$user_info['is_admin'] && (!isset($user_info['edit']) || (isset($user_info['edit']) && $user_info['edit'])))) { if ($user_is_admin
|| $config['id_user'] == $user_info['id_user']
|| isset($group_um[0])
|| (!$user_info['is_admin'] && (!isset($user_info['edit'])
|| (isset($user_info['edit']) && $user_info['edit'])))
) {
// Disable / Enable user. // Disable / Enable user.
if (isset($user_info['not_delete']) === false) { if (isset($user_info['not_delete']) === false) {
if ($user_info['disabled'] == 0) { if ($user_info['disabled'] == 0) {
@ -705,7 +768,10 @@ foreach ($info as $user_id => $user_info) {
); );
$data[6] .= '</form>'; $data[6] .= '</form>';
if ($config['admin_can_delete_user'] && $user_info['id_user'] != $config['id_user'] && isset($user_info['not_delete']) === false) { if ($config['admin_can_delete_user']
&& $user_info['id_user'] != $config['id_user']
&& isset($user_info['not_delete']) === false
) {
$data[6] .= '<form method="POST" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;pure='.$pure.'" class="inline">'; $data[6] .= '<form method="POST" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;pure='.$pure.'" class="inline">';
$data[6] .= html_print_input_hidden( $data[6] .= html_print_input_hidden(
'delete_user', 'delete_user',
@ -748,23 +814,12 @@ foreach ($info as $user_id => $user_info) {
'1', '1',
true true
); );
$data[6] .= html_print_input_image(
'submit_delete_all',
'images/cross_double.png',
'',
'',
true,
[
'data-title' => __('Delete from all consoles'),
'data-use_title_for_force_title' => '1',
'class' => 'forced_title no-padding',
]
);
$data[6] .= '</form>'; $data[6] .= '</form>';
} }
} else { } else {
$data[6] .= ''; $data[6] .= '';
// Delete button not in this mode // Delete button not in this mode.
}
} }
} }
@ -776,13 +831,15 @@ ui_pagination(count($info), false, 0, 0, false, 'offset', true, 'pagination-bott
echo '<div style="width: '.$table->width.'" class="action-buttons">'; echo '<div style="width: '.$table->width.'" class="action-buttons">';
unset($table); unset($table);
if ($config['admin_can_add_user'] !== false) { if ($is_management_allowed === true) {
if ($config['admin_can_add_user'] !== false) {
echo '<form method="post" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_user&pure='.$pure.'">'; echo '<form method="post" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_user&pure='.$pure.'">';
html_print_input_hidden('new_user', 1); html_print_input_hidden('new_user', 1);
html_print_submit_button(__('Create user'), 'crt', false, 'class="sub next"'); html_print_submit_button(__('Create user'), 'crt', false, 'class="sub next"');
echo '</form>'; echo '</form>';
} else { } else {
echo '<i>'.__("The current authentication scheme doesn't support creating users on %s", get_product_name()).'</i>'; echo '<i>'.__("The current authentication scheme doesn't support creating users on %s", get_product_name()).'</i>';
}
} }
echo '</div>'; echo '</div>';

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -1914,7 +1914,7 @@ if ($get_events_fired) {
$idGroup = get_parameter('id_group'); $idGroup = get_parameter('id_group');
$agents = get_parameter('agents', null); $agents = get_parameter('agents', null);
$query = ' AND id_evento >= '.$id; $query = ' AND id_evento > '.$id;
$type = []; $type = [];
$alert = get_parameter('alert_fired'); $alert = get_parameter('alert_fired');

View File

@ -29,18 +29,36 @@
// Begin. // Begin.
require_once 'config.php'; require_once 'config.php';
require_once 'functions_api.php'; require_once 'functions_api.php';
require '../vendor/autoload.php';
global $config; global $config;
define('DEBUG', 0); define('DEBUG', 0);
define('VERBOSE', 0); define('VERBOSE', 0);
// Load extra classes.
require_once $config['homedir'].'/vendor/autoload.php';
// Enterprise support.
if (file_exists($config['homedir'].'/'.ENTERPRISE_DIR.'/load_enterprise.php') === true) {
include_once $config['homedir'].'/'.ENTERPRISE_DIR.'/load_enterprise.php';
}
// TESTING THE UPDATE MANAGER. // TESTING THE UPDATE MANAGER.
enterprise_include_once('load_enterprise.php'); enterprise_include_once('load_enterprise.php');
enterprise_include_once('include/functions_enterprise_api.php'); enterprise_include_once('include/functions_enterprise_api.php');
enterprise_include_once('include/functions_metaconsole.php');
$ipOrigin = $_SERVER['REMOTE_ADDR']; $ipOrigin = $_SERVER['REMOTE_ADDR'];
// Sometimes input is badly retrieved from caller...
if (empty($_REQUEST) === true) {
$data = explode('&', urldecode(file_get_contents('php://input')));
foreach ($data as $d) {
$r = explode('=', $d, 2);
$_POST[$r[0]] = $r[1];
$_GET[$r[0]] = $r[1];
}
}
// Get the parameters and parse if necesary. // Get the parameters and parse if necesary.
$op = get_parameter('op'); $op = get_parameter('op');
$op2 = get_parameter('op2'); $op2 = get_parameter('op2');
@ -85,8 +103,21 @@ if ($info == 'version') {
exit; exit;
} }
if (isInACL($ipOrigin)) { if (empty($apiPassword) === true
if (empty($apiPassword) || (!empty($apiPassword) && $api_password === $apiPassword)) { || (empty($apiPassword) === false && $api_password === $apiPassword)
&& (enterprise_hook('metaconsole_validate_origin', [get_parameter('server_auth')]) === true
|| enterprise_hook('console_validate_origin', [get_parameter('server_auth')]) === true)
) {
// Allow internal direct node -> metaconsole connection
// or node -> own console connection.
$config['__internal_call'] = true;
$config['id_usuario'] = 'admin';
// Compat.
$config['id_user'] = 'admin';
$correctLogin = true;
} else if ((bool) isInACL($ipOrigin) === true) {
// External access.
if (empty($apiPassword) === true || (empty($apiPassword) === false && $api_password === $apiPassword)) {
$user_in_db = process_user_login($user, $password, true); $user_in_db = process_user_login($user, $password, true);
if ($user_in_db !== false) { if ($user_in_db !== false) {
$config['id_usuario'] = $user_in_db; $config['id_usuario'] = $user_in_db;
@ -262,7 +293,7 @@ if ($correctLogin) {
break; break;
case 'event': case 'event':
// Preventive check for users if not available write events // Preventive check for users if not available write events.
if (! check_acl($config['id_user'], $event['id_grupo'], 'EW')) { if (! check_acl($config['id_user'], $event['id_grupo'], 'EW')) {
return false; return false;
} }

View File

@ -319,7 +319,7 @@ function process_user_login_remote($login, $pass, $api=false)
defined('METACONSOLE') defined('METACONSOLE')
); );
if ($return === 'error_permissions') { if ($result === 'error_permissions') {
$config['auth_error'] = __('Problems with configuration permissions. Please contact with Administrator'); $config['auth_error'] = __('Problems with configuration permissions. Please contact with Administrator');
return false; return false;
} }
@ -344,25 +344,12 @@ function process_user_login_remote($login, $pass, $api=false)
&& (isset($config['ad_advanced_config']) && (isset($config['ad_advanced_config'])
&& $config['ad_advanced_config']) && $config['ad_advanced_config'])
) { ) {
if (defined('METACONSOLE')) { if (is_management_allowed() === false) {
enterprise_include_once('include/functions_metaconsole.php'); $config['auth_error'] = __('Please, login into metaconsole first');
enterprise_include_once('meta/include/functions_groups_meta.php');
$return = groups_meta_synchronizing();
if ($return['group_create_err'] > 0 || $return['group_update_err'] > 0) {
$config['auth_error'] = __('Fail the group synchronizing');
return false; return false;
} }
$return = meta_tags_synchronizing(); // Create the user.
if ($return['tag_create_err'] > 0 || $return['tag_update_err'] > 0) {
$config['auth_error'] = __('Fail the tag synchronizing');
return false;
}
}
// Create the user
if (enterprise_hook( if (enterprise_hook(
'prepare_permissions_groups_of_user_ad', 'prepare_permissions_groups_of_user_ad',
[ [
@ -377,53 +364,47 @@ function process_user_login_remote($login, $pass, $api=false)
] ]
) === false ) === false
) { ) {
$config['auth_error'] = __( $config['auth_error'] = __('User not found in database or incorrect password');
'User not found in database
or incorrect password'
);
return false; return false;
} }
} else if ($config['auth'] === 'ldap') { } else if ($config['auth'] === 'ldap') {
if (defined('METACONSOLE')) { if (is_management_allowed() === false) {
enterprise_include_once('include/functions_metaconsole.php'); $config['auth_error'] = __('Please, login into metaconsole first');
enterprise_include_once('meta/include/functions_groups_meta.php');
$return = groups_meta_synchronizing();
if ($return['group_create_err'] > 0 || $return['group_update_err'] > 0) {
$config['auth_error'] = __('Fail the group synchronizing');
return false; return false;
} }
$return = meta_tags_synchronizing();
if ($return['tag_create_err'] > 0 || $return['tag_update_err'] > 0) {
$config['auth_error'] = __('Fail the tag synchronizing');
return false;
}
}
$permissions = fill_permissions_ldap($sr); $permissions = fill_permissions_ldap($sr);
if (empty($permissions)) { if (empty($permissions) === true) {
$config['auth_error'] = __('User not found in database or incorrect password'); $config['auth_error'] = __('User not found in database or incorrect password');
return false; return false;
} else { } else {
$user_info['fullname'] = $sr['cn'][0]; $user_info['fullname'] = $sr['cn'][0];
$user_info['email'] = $sr['mail'][0]; $user_info['email'] = $sr['mail'][0];
// Create the user // Create the user.
$create_user = create_user_and_permisions_ldap($login, $pass, $user_info, $permissions, defined('METACONSOLE')); $create_user = create_user_and_permisions_ldap(
$login,
$pass,
$user_info,
$permissions,
is_metaconsole()
);
} }
} else { } else {
$user_info = [ $user_info = [
'fullname' => $login, 'fullname' => $login,
'comments' => 'Imported from '.$config['auth'], 'comments' => 'Imported from '.$config['auth'],
]; ];
if (is_metaconsole() && $config['auth'] === 'ad') { if (is_metaconsole() === true && $config['auth'] === 'ad') {
$user_info['metaconsole_access_node'] = $config['ad_adv_user_node']; $user_info['metaconsole_access_node'] = $config['ad_adv_user_node'];
} }
// Create the user in the local database if (is_management_allowed() === false) {
$config['auth_error'] = __('Please, login into metaconsole first');
return false;
}
// Create the user in the local database.
if (create_user($login, $pass, $user_info) === false) { if (create_user($login, $pass, $user_info) === false) {
$config['auth_error'] = __('User not found in database or incorrect password'); $config['auth_error'] = __('User not found in database or incorrect password');
return false; return false;
@ -436,61 +417,6 @@ function process_user_login_remote($login, $pass, $api=false)
false, false,
$config['default_assign_tags'] $config['default_assign_tags']
); );
// TODO: Check the creation in the nodes
if (is_metaconsole()) {
enterprise_include_once('include/functions_metaconsole.php');
enterprise_include_once('meta/include/functions_groups_meta.php');
$return = groups_meta_synchronizing();
if ($return['group_create_err'] > 0 || $return['group_update_err'] > 0) {
$config['auth_error'] = __('Fail the group synchronizing');
return false;
}
$return = meta_tags_synchronizing();
if ($return['tag_create_err'] > 0 || $return['tag_update_err'] > 0) {
$config['auth_error'] = __('Fail the tag synchronizing');
return false;
}
$servers = metaconsole_get_servers();
foreach ($servers as $server) {
$perfil_maestro = db_get_row(
'tperfil',
'id_perfil',
$config['default_remote_profile']
);
if (metaconsole_connect($server) == NOERR) {
if (!profile_exist($perfil_maestro['name'])) {
unset($perfil_maestro['id_perfil']);
$id_profile = db_process_sql_insert('tperfil', $perfil_maestro);
} else {
$id_profile = db_get_value('id_perfil', 'tperfil', 'name', $perfil_maestro['name']);
}
if ($config['auth'] === 'ad') {
unset($user_info['metaconsole_access_node']);
$user_info['not_login'] = (int) !$config['ad_adv_user_node'];
}
if (create_user($login, $pass, $user_info) === false) {
continue;
}
profile_create_user_profile(
$login,
$id_profile,
$config['default_remote_group'],
false,
$config['default_assign_tags']
);
}
metaconsole_restore_db();
}
}
} }
return $login; return $login;
@ -809,7 +735,14 @@ function ldap_process_user_login($login, $password)
} }
// Connect to the LDAP server // Connect to the LDAP server
if (stripos($config['ldap_server'], 'ldap://') !== false
|| stripos($config['ldap_server'], 'ldaps://') !== false
|| stripos($config['ldap_server'], 'ldapi://') !== false
) {
$ds = @ldap_connect($config['ldap_server'].':'.$config['ldap_port']);
} else {
$ds = @ldap_connect($config['ldap_server'], $config['ldap_port']); $ds = @ldap_connect($config['ldap_server'], $config['ldap_port']);
}
if (!$ds) { if (!$ds) {
$config['auth_error'] = 'Error connecting to LDAP server'; $config['auth_error'] = 'Error connecting to LDAP server';
@ -1467,7 +1400,7 @@ function local_ldap_search($ldap_host, $ldap_port=389, $ldap_version=3, $dn, $ac
} }
if (!empty($ldap_admin_pass)) { if (!empty($ldap_admin_pass)) {
$ldap_admin_pass = ' -w '.$ldap_admin_pass; $ldap_admin_pass = ' -w '.escapeshellarg($ldap_admin_pass);
} }
$dn = " -b '".$dn."'"; $dn = " -b '".$dn."'";

View File

@ -26,6 +26,8 @@
* ============================================================================ * ============================================================================
*/ */
use PandoraFMS\Tools\Files;
global $config; global $config;
require_once $config['homedir'].'/include/functions_db.php'; require_once $config['homedir'].'/include/functions_db.php';
@ -2394,6 +2396,10 @@ class ConsoleSupervisor
return; return;
} }
// Only ask for messages once every 2 hours.
$future = (time() + 2 * SECONDS_1HOUR);
config_update_value('last_um_check', $future);
$messages = update_manager_get_messages(); $messages = update_manager_get_messages();
if (is_array($messages) === true) { if (is_array($messages) === true) {
$source_id = get_notification_source_id( $source_id = get_notification_source_id(
@ -2645,13 +2651,15 @@ class ConsoleSupervisor
{ {
global $config; global $config;
if ((int) $config['clean_phantomjs_cache'] !== 1) { if (isset($config['clean_phantomjs_cache']) !== true
|| (int) $config['clean_phantomjs_cache'] !== 1
) {
return; return;
} }
$cache_dir = $config['homedir'].'/attachment/cache'; $cache_dir = $config['homedir'].'/attachment/cache';
if (is_dir($cache_dir) === true) { if (is_dir($cache_dir) === true) {
rrmdir($cache_dir); Files::rmrf($cache_dir);
} }
// Clean process has ended. // Clean process has ended.

View File

@ -197,8 +197,11 @@ class TreeGroupEdition extends TreeGroup
$group_stats[$group['gid']] = $this->getProcessedItem( $group_stats[$group['gid']] = $this->getProcessedItem(
$group_stats[$group['gid']] $group_stats[$group['gid']]
); );
if (is_management_allowed() === true) {
$group_stats[$group['gid']]['delete']['messages'] = $messages; $group_stats[$group['gid']]['delete']['messages'] = $messages;
$group_stats[$group['gid']]['edit'] = 1; $group_stats[$group['gid']]['edit'] = 1;
}
$group_stats[$group['gid']]['alerts'] = ''; $group_stats[$group['gid']]['alerts'] = '';
} }

View File

@ -1,38 +1,54 @@
<?php <?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
//
// 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 * Configuraton sample file.
* @subpackage Config *
* @category Config
* @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.
* ============================================================================
*/ */
// Default values /*
// $config["dbname"]="pandora"; * Default values
// $config["dbuser"]="pandora"; * $config["dbname"]="pandora";
// $config["dbpass"]="pandora"; * $config["dbuser"]="pandora";
// $config["dbhost"]="localhost"; * $config["dbpass"]="pandora";
// This is used for reporting, please add "/" character at the end * $config["dbhost"]="localhost";
// $config["homedir"]="/var/www/pandora_console/"; *
// $config["homeurl"]="/pandora_console/"; *
// $config["auth"]["scheme"] = "mysql"; * This is used for reporting, please add "/" character at the end
* $config["homedir"]="/var/www/pandora_console/";
/** * $config["homeurl"]="/pandora_console/";
* Do not display any ERROR * $config["auth"]["scheme"] = "mysql";
*/
// By default report any error but notices.
error_reporting(E_ALL ^ E_NOTICE);
/*
* Uncomment to display only critical errors.
* error_reporting(E_ERROR);
* Uncomment to display none errors.
* error_reporting(0);
*/ */
error_reporting(E_ALL);
// Display ALL errors
// error_reporting(E_ERROR);
$ownDir = dirname(__FILE__).DIRECTORY_SEPARATOR; $ownDir = dirname(__FILE__).DIRECTORY_SEPARATOR;
require $ownDir.'config_process.php'; require $ownDir.'config_process.php';

View File

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

View File

@ -233,6 +233,7 @@ define('BARS_GRAPH', 18);
define('CLOCK', 19); define('CLOCK', 19);
define('COLOR_CLOUD', 20); define('COLOR_CLOUD', 20);
define('NETWORK_LINK', 21); define('NETWORK_LINK', 21);
define('ODOMETER', 22);
// Some styles. // Some styles.
define('MIN_WIDTH', 300); define('MIN_WIDTH', 300);
define('MIN_HEIGHT', 120); define('MIN_HEIGHT', 120);

View File

@ -11,8 +11,28 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
function mysql_connect_db($host=null, $db=null, $user=null, $pass=null, $port=null, $charset=null)
{
/**
* Connect db
*
* @param string $host Host.
* @param string $db Db.
* @param string $user User.
* @param string $pass Pass.
* @param string $port Port.
* @param string $charset Charset.
*
* @return mysqli|false
*/
function mysql_connect_db(
$host=null,
$db=null,
$user=null,
$pass=null,
$port=null,
$charset=null
) {
global $config; global $config;
if ($host === null) { if ($host === null) {
@ -140,15 +160,23 @@ function mysql_db_get_all_rows_sql($sql, $search_history_db=false, $cache=true,
/** /**
* Get the first value of the first row of a table in the database. * Get the first value of the first row of a table in the database.
* *
* @param string Field name to get * @param string $field Field name to get.
* @param string Table to retrieve the data * @param string $table Table to retrieve the data.
* @param string Field to filter elements * @param string $field_search Field to filter elements.
* @param string Condition the field must have * @param string $condition Condition the field must have.
* @param boolean $search_history_db Search in historical db.
* @param boolean $cache Enable cache or not.
* *
* @return mixed Value of first column of the first row. False if there were no row. * @return mixed Value of first column of the first row. False if there were no row.
*/ */
function mysql_db_get_value($field, $table, $field_search=1, $condition=1, $search_history_db=false) function mysql_db_get_value(
{ $field,
$table,
$field_search=1,
$condition=1,
$search_history_db=false,
$cache=true
) {
if (is_int($condition)) { if (is_int($condition)) {
$sql = sprintf( $sql = sprintf(
'SELECT %s FROM %s WHERE %s = %d LIMIT 1', 'SELECT %s FROM %s WHERE %s = %d LIMIT 1',
@ -175,7 +203,7 @@ function mysql_db_get_value($field, $table, $field_search=1, $condition=1, $sear
); );
} }
$result = db_get_all_rows_sql($sql, $search_history_db); $result = db_get_all_rows_sql($sql, $search_history_db, $cache);
if ($result === false) { if ($result === false) {
return false; return false;
@ -371,6 +399,10 @@ function mysql_db_process_sql($sql, $rettype='affected_rows', $dbconnection='',
return false; return false;
} }
if (isset($config['dbcache']) === true) {
$cache = $config['dbcache'];
}
if ($cache && ! empty($sql_cache[$sql_cache['id']][$sql])) { if ($cache && ! empty($sql_cache[$sql_cache['id']][$sql])) {
$retval = $sql_cache[$sql_cache['id']][$sql]; $retval = $sql_cache[$sql_cache['id']][$sql];
$sql_cache['saved'][$sql_cache['id']]++; $sql_cache['saved'][$sql_cache['id']]++;
@ -814,10 +846,10 @@ function mysql_db_get_value_sql($sql, $dbconnection=false)
* *
* @return mixed The first row of the result or false * @return mixed The first row of the result or false
*/ */
function mysql_db_get_row_sql($sql, $search_history_db=false) function mysql_db_get_row_sql($sql, $search_history_db=false, $cache=true)
{ {
$sql .= ' LIMIT 1'; $sql .= ' LIMIT 1';
$result = db_get_all_rows_sql($sql, $search_history_db); $result = db_get_all_rows_sql($sql, $search_history_db, $cache);
if ($result === false) { if ($result === false) {
return false; return false;
@ -1506,3 +1538,118 @@ function db_run_sql_file($location)
return false; return false;
} }
} }
/**
* Inserts multiples strings into database.
*
* @param string $table Table to insert into.
* @param mixed $values A single value or array of values to insert
* (can be a multiple amount of rows).
* @param boolean $only_query Sql string.
*
* @return mixed False in case of error or invalid values passed.
* Affected rows otherwise.
*/
function mysql_db_process_sql_insert_multiple($table, $values, $only_query)
{
// Empty rows or values not processed.
if (empty($values) === true || is_array($values) === false) {
return false;
}
$query = sprintf('INSERT INTO `%s`', $table);
$j = 1;
$max_total = count($values);
foreach ($values as $key => $value) {
$fields = [];
$values_str = '';
$i = 1;
$max = count($value);
foreach ($value as $k => $v) {
if ($j === 1) {
// Add the correct escaping to values.
$field = sprintf('`%s`', $k);
array_push($fields, $field);
}
if (isset($v) === false) {
$values_str .= 'NULL';
} else if (is_int($v) || is_bool($v)) {
$values_str .= sprintf('%d', $v);
} else if (is_float($v) || is_double($v)) {
$values_str .= sprintf('%f', $v);
} else {
$values_str .= sprintf("'%s'", $v);
}
if ($i < $max) {
$values_str .= ',';
}
$i++;
}
if ($j === 1) {
$query .= sprintf(' (%s) VALUES', implode(', ', $fields));
}
$query .= ' ('.$values_str.')';
if ($j < $max_total) {
$query .= ',';
}
$j++;
}
if ($only_query === true) {
$result = $query;
} else {
$result = db_process_sql($query);
}
return $result;
}
/**
* Updates multiples strings into database.
*
* @param string $table Table to update into.
* @param mixed $values A single value or array of values to update
* (can be a multiple amount of rows).
* @param boolean $only_query Sql string.
*
* @return mixed False in case of error or invalid values passed.
* Affected rows otherwise.
*/
function mysql_db_process_sql_update_multiple($table, $values, $only_query)
{
// Empty rows or values not processed.
if (empty($values) === true || is_array($values) === false) {
return false;
}
$res = [];
foreach ($values as $field => $update) {
$query = sprintf('UPDATE `%s` SET', $table);
$query .= sprintf(' `%s` = CASE `%s`', $field, $field);
foreach ($update as $where => $set) {
$query .= sprintf(' WHEN "%s" THEN "%s"', $where, $set);
}
$query .= sprintf(' ELSE `%s` END', $field);
$query .= sprintf(' WHERE `%s` IN (%s)', $field, '"'.implode('","', array_keys($update)).'"');
if ($only_query === true) {
$res[] = $query;
} else {
$res['table'] = $table;
$res['fields'][$field] = db_process_sql($query);
}
}
return $res;
}

View File

@ -72,15 +72,23 @@ function oracle_connect_db($host=null, $db=null, $user=null, $pass=null, $port=n
/** /**
* Get the first value of the first row of a table in the database. * Get the first value of the first row of a table in the database.
* *
* @param string Field name to get * @param string $field Field name to get.
* @param string Table to retrieve the data * @param string $table Table to retrieve the data.
* @param string Field to filter elements * @param string $field_search Field to filter elements.
* @param string Condition the field must have * @param string $condition Condition the field must have.
* @param boolean $search_history_db Search in historical db.
* @param boolean $cache Enable cache or not.
* *
* @return mixed Value of first column of the first row. False if there were no row. * @return mixed Value of first column of the first row. False if there were no row.
*/ */
function oracle_db_get_value($field, $table, $field_search=1, $condition=1, $search_history_db=false) function oracle_db_get_value(
{ $field,
$table,
$field_search=1,
$condition=1,
$search_history_db=false,
$cache=false
) {
if (is_int($condition)) { if (is_int($condition)) {
$sql = sprintf( $sql = sprintf(
'SELECT * 'SELECT *
@ -113,7 +121,7 @@ function oracle_db_get_value($field, $table, $field_search=1, $condition=1, $sea
); );
} }
$result = db_get_all_rows_sql($sql, $search_history_db); $result = db_get_all_rows_sql($sql, $search_history_db, $cache);
if ($result === false) { if ($result === false) {
return false; return false;
@ -996,10 +1004,10 @@ function oracle_db_get_value_sql($sql, $dbconnection=false)
* *
* @return mixed The first row of the result or false * @return mixed The first row of the result or false
*/ */
function oracle_db_get_row_sql($sql, $search_history_db=false) function oracle_db_get_row_sql($sql, $search_history_db=false, $cache=true)
{ {
$sql = 'SELECT * FROM ('.$sql.') WHERE rownum < 2'; $sql = 'SELECT * FROM ('.$sql.') WHERE rownum < 2';
$result = oracle_db_get_all_rows_sql($sql, $search_history_db); $result = oracle_db_get_all_rows_sql($sql, $search_history_db, $cache);
if ($result === false) { if ($result === false) {
return false; return false;

View File

@ -53,15 +53,23 @@ function postgresql_connect_db($host=null, $db=null, $user=null, $pass=null, $po
/** /**
* Get the first value of the first row of a table in the database. * Get the first value of the first row of a table in the database.
* *
* @param string Field name to get * @param string $field Field name to get.
* @param string Table to retrieve the data * @param string $table Table to retrieve the data.
* @param string Field to filter elements * @param string $field_search Field to filter elements.
* @param string Condition the field must have * @param string $condition Condition the field must have.
* @param boolean $search_history_db Search in historical db.
* @param boolean $cache Enable cache or not.
* *
* @return mixed Value of first column of the first row. False if there were no row. * @return mixed Value of first column of the first row. False if there were no row.
*/ */
function postgresql_db_get_value($field, $table, $field_search=1, $condition=1, $search_history_db=false) function postgresql_db_get_value(
{ $field,
$table,
$field_search=1,
$condition=1,
$search_history_db=false,
$cache=true
) {
if ($field_search[0] == '`') { if ($field_search[0] == '`') {
$field_search = str_replace('`', '', $field_search); $field_search = str_replace('`', '', $field_search);
} }
@ -92,7 +100,7 @@ function postgresql_db_get_value($field, $table, $field_search=1, $condition=1,
); );
} }
$result = db_get_all_rows_sql($sql, $search_history_db); $result = db_get_all_rows_sql($sql, $search_history_db, $cache);
if ($result === false) { if ($result === false) {
return false; return false;
@ -705,10 +713,10 @@ function postgresql_db_get_value_sql($sql, $dbconnection=false)
* *
* @return mixed The first row of the result or false * @return mixed The first row of the result or false
*/ */
function postgresql_db_get_row_sql($sql, $search_history_db=false) function postgresql_db_get_row_sql($sql, $search_history_db=false, $cache=true)
{ {
$sql .= ' LIMIT 1'; $sql .= ' LIMIT 1';
$result = postgresql_db_get_all_rows_sql($sql, $search_history_db); $result = postgresql_db_get_all_rows_sql($sql, $search_history_db, $cache);
if ($result === false) { if ($result === false) {
return false; return false;

View File

@ -1745,17 +1745,34 @@ function has_metaconsole()
/** /**
* @brief Check if there is management operations are allowed in current context * Check if there is management operations are allowed in current context
* (node // meta) *
* @param string $hkey Hash ke.
* *
* @return boolean * @return boolean
*/ */
function is_management_allowed($hkey='') function is_management_allowed($hkey='')
{
return ( (is_metaconsole() && is_centrallised())
|| (!is_metaconsole() && !is_centrallised())
|| (!is_metaconsole() && is_centrallised()) && $hkey == generate_hash_to_api());
}
/**
* Return true if is a centrallised environment.
*
* @return boolean
*/
function is_centrallised()
{ {
global $config; global $config;
return ( (is_metaconsole() && $config['centralized_management'])
|| (!is_metaconsole() && !$config['centralized_management']) if (isset($config['centralized_management']) === false) {
|| (!is_metaconsole() && $config['centralized_management']) && $hkey == generate_hash_to_api()); return false;
}
return (bool) $config['centralized_management'];
} }
@ -1767,21 +1784,7 @@ function is_management_allowed($hkey='')
*/ */
function is_central_policies() function is_central_policies()
{ {
global $config; return is_metaconsole() && is_centrallised();
return is_metaconsole() && $config['centralized_management'];
}
/**
* @brief Check if there is centralized management in node environment. Usefull
* to reduce the policy functionallity on nodes.
*
* @return boolean
*/
function is_central_policies_on_node()
{
global $config;
return (!is_metaconsole()) && $config['centralized_management'];
} }
@ -2259,13 +2262,16 @@ function check_login($output=true)
return false; return false;
} }
// No exists $config. Exit inmediatly // No exists $config. Exit inmediatly.
include 'general/noaccess.php'; include 'general/noaccess.php';
exit; exit;
} }
if ((isset($_SESSION['id_usuario'])) and ($_SESSION['id_usuario'] != '')) { if ((isset($_SESSION['id_usuario'])) && ($_SESSION['id_usuario'] != '')) {
if (is_user($_SESSION['id_usuario'])) { if (is_user($_SESSION['id_usuario'])
|| (isset($_SESSION['merge-request-user-trick']) === true
&& $_SESSION['merge-request-user-trick'] === $_SESSION['id_usuario'])
) {
$config['id_user'] = $_SESSION['id_usuario']; $config['id_user'] = $_SESSION['id_usuario'];
return true; return true;
@ -2549,7 +2555,9 @@ function get_users_acl($id_user)
{ {
static $users_acl_cache = []; static $users_acl_cache = [];
if (is_array($users_acl_cache[$id_user])) { if (isset($users_acl_cache[$id_user]) === true
&& is_array($users_acl_cache[$id_user]) === true
) {
$rowdup = $users_acl_cache[$id_user]; $rowdup = $users_acl_cache[$id_user];
} else { } else {
$query = sprintf( $query = sprintf(
@ -4353,6 +4361,8 @@ function pandora_xhprof_display_result($key='', $method='link')
switch ($method) { switch ($method) {
case 'console': case 'console':
error_log("'{$new_url}'"); error_log("'{$new_url}'");
break;
case 'link': case 'link':
default: default:
echo "<a href='{$new_url}' target='_new'>Performance</a>\n"; echo "<a href='{$new_url}' target='_new'>Performance</a>\n";

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