Merge remote-tracking branch 'origin/develop' into ent-4112-Bug-visual-cuadro-de-datos-tipo-string

Conflicts:
	pandora_console/include/styles/js/jquery-ui_custom.css
This commit is contained in:
Tatiana Llorente 2019-06-28 12:28:13 +02:00
commit c28185965a
252 changed files with 14250 additions and 5140 deletions

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.735, AIX version # Version 7.0NG.736, AIX version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # Copyright (c) 2003-2010 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.735, FreeBSD Version # Version 7.0NG.736, FreeBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # Copyright (c) 2003-2010 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.735, HP-UX Version # Version 7.0NG.736, HP-UX Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 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.735, GNU/Linux # Version 7.0NG.736, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 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.735, GNU/Linux # Version 7.0NG.736, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 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.735, Solaris Version # Version 7.0NG.736, Solaris Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 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-2010 Artica Soluciones Tecnologicas # (c) 2006-2010 Artica Soluciones Tecnologicas
# Version 7.0NG.735 # Version 7.0NG.736
# 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

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.735, AIX version # Version 7.0NG.736, 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.735 # Version 7.0NG.736
# 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.735, HPUX Version # Version 7.0NG.736, 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.735 # Version 7.0NG.736
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2010 Artica Soluciones Tecnologicas # (c) 2003-2010 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.735 # Version 7.0NG.736
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2009 Artica Soluciones Tecnologicas # (c) 2003-2009 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.735 # Version 7.0NG.736
# 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.735, Solaris version # Version 7.0NG.736, 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.735, AIX version # Version 7.0NG.736, AIX version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # Copyright (c) 2003-2010 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.735-190614 Version: 7.0NG.736-190628
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.735-190614" pandora_version="7.0NG.736-190628"
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

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.735, GNU/Linux # Version 7.0NG.736, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # Copyright (c) 2003-2012 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.735, FreeBSD Version # Version 7.0NG.736, FreeBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2016 Artica Soluciones Tecnologicas # Copyright (c) 2003-2016 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.735, HP-UX Version # Version 7.0NG.736, HP-UX Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 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.735, GNU/Linux # Version 7.0NG.736, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # Copyright (c) 2003-2014 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.735, GNU/Linux # Version 7.0NG.736, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 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.735, NetBSD Version # Version 7.0NG.736, NetBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # Copyright (c) 2003-2010 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.735, Solaris Version # Version 7.0NG.736, Solaris Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -41,8 +41,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.735'; use constant AGENT_VERSION => '7.0NG.736';
use constant AGENT_BUILD => '190614'; use constant AGENT_BUILD => '190628';
# 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.735 %define version 7.0NG.736
%define release 190614 %define release 190628
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.735 %define version 7.0NG.736
%define release 190614 %define release 190628
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.735" PI_VERSION="7.0NG.736"
PI_BUILD="190614" PI_BUILD="190628"
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-2017 Artica Soluciones Tecnologicas # (c) 2006-2017 Artica Soluciones Tecnologicas
# Version 7.0NG.735 # Version 7.0NG.736
# 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

View File

@ -3,7 +3,7 @@ AllowLanguageSelection
{Yes} {Yes}
AppName AppName
{Pandora FMS Windows Agent v7.0NG.735} {Pandora FMS Windows Agent v7.0NG.736}
ApplicationID ApplicationID
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F} {17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{190614} {190628}
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.735(Build 190614)") #define PANDORA_VERSION ("7.0NG.736(Build 190628)")
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.735(Build 190614))" VALUE "ProductVersion", "(7.0NG.736(Build 190628))"
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.735-190614 Version: 7.0NG.736-190628
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.735-190614" pandora_version="7.0NG.736-190628"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -1,23 +1,24 @@
<?php <?php
/**
* Pandora FMS - http://pandorafms.com
* ==================================================
* Copyright (c) 2005-2011 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.
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 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.
$refr = (int) get_parameter('refresh', 0);
// By default 30 seconds
function mainAgentsModules() function mainAgentsModules()
{ {
global $config; global $config;
// Load global vars // Load global vars.
include_once 'include/config.php'; include_once 'include/config.php';
include_once 'include/functions_reporting.php'; include_once 'include/functions_reporting.php';
include_once $config['homedir'].'/include/functions_agents.php'; include_once $config['homedir'].'/include/functions_agents.php';
@ -25,7 +26,7 @@ function mainAgentsModules()
include_once $config['homedir'].'/include/functions_users.php'; include_once $config['homedir'].'/include/functions_users.php';
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',
@ -37,7 +38,7 @@ function mainAgentsModules()
// Update network modules for this group // Update network modules for this group
// Check for Network FLAG change request // Check for Network FLAG change request
// Made it a subquery, much faster on both the database and server side // Made it a subquery, much faster on both the database and server side.
if (isset($_GET['update_netgroup'])) { if (isset($_GET['update_netgroup'])) {
$group = get_parameter_get('update_netgroup', 0); $group = get_parameter_get('update_netgroup', 0);
if (check_acl($config['id_user'], $group, 'AW')) { if (check_acl($config['id_user'], $group, 'AW')) {
@ -62,7 +63,7 @@ function mainAgentsModules()
$modulegroup = get_parameter('modulegroup', 0); $modulegroup = get_parameter('modulegroup', 0);
$refr = (int) get_parameter('refresh', 0); $refr = (int) get_parameter('refresh', 0);
// By default 30 seconds // By default 30 seconds.
$recursion = get_parameter('recursion', 0); $recursion = get_parameter('recursion', 0);
$group_id = (int) get_parameter('group_id', 0); $group_id = (int) get_parameter('group_id', 0);
$offset = (int) get_parameter('offset', 0); $offset = (int) get_parameter('offset', 0);
@ -79,7 +80,8 @@ function mainAgentsModules()
$full_modules_selected = explode(';', get_parameter('full_modules_selected', 0)); $full_modules_selected = explode(';', get_parameter('full_modules_selected', 0));
$full_agents_id = explode(';', get_parameter('full_agents_id', 0)); $full_agents_id = explode(';', get_parameter('full_agents_id', 0));
if ($save_serialize && $update_item == '') { // In full screen there is no pagination neither filters.
if (( ($config['pure'] == 0 && $save_serialize) && $update_item == '' ) || ( ($config['pure'] == 1 && $save_serialize == 0) && $update_item == '' )) {
$unserialize_modules_selected = unserialize_in_temp($config['id_user'].'_agent_module', true, 1); $unserialize_modules_selected = unserialize_in_temp($config['id_user'].'_agent_module', true, 1);
$unserialize_agents_id = unserialize_in_temp($config['id_user'].'_agents', true, 1); $unserialize_agents_id = unserialize_in_temp($config['id_user'].'_agents', true, 1);
if ($unserialize_modules_selected) { if ($unserialize_modules_selected) {
@ -102,7 +104,6 @@ function mainAgentsModules()
serialize_in_temp($agents_id, $config['id_user'].'_agents', 1); serialize_in_temp($agents_id, $config['id_user'].'_agents', 1);
} }
// if($agents_id != -1) $agents_id = null;
if ($config['pure'] == 0) { if ($config['pure'] == 0) {
if ($modules_selected[0] && $agents_id[0]) { if ($modules_selected[0] && $agents_id[0]) {
$full_modules = urlencode(implode(';', $modules_selected)); $full_modules = urlencode(implode(';', $modules_selected));
@ -124,13 +125,13 @@ function mainAgentsModules()
} }
} }
// groups // Groups.
$filter_groups_label = '<b>'.__('Group').'</b>'; $filter_groups_label = '<b>'.__('Group').'</b>';
$filter_groups = html_print_select_groups(false, 'AR', true, 'group_id', $group_id, '', '', '', true, false, true, '', false, 'width: auto;'); $filter_groups = html_print_select_groups(false, 'AR', true, 'group_id', $group_id, '', '', '', true, false, true, '', false, 'width: auto;');
$filter_recursion_label = '<b>'.__('Recursion').'</b>'; $filter_recursion_label = '<b>'.__('Recursion').'</b>';
$filter_recursion = html_print_checkbox('recursion', 1, 0, true); $filter_recursion = html_print_checkbox('recursion', 1, 0, true);
// groups module // Groups module.
$filter_module_groups_label = '<b>'.__('Module group').'</b>'; $filter_module_groups_label = '<b>'.__('Module group').'</b>';
$filter_module_groups = html_print_select_from_sql( $filter_module_groups = html_print_select_from_sql(
'SELECT * FROM tmodule_group ORDER BY name', 'SELECT * FROM tmodule_group ORDER BY name',
@ -146,7 +147,7 @@ function mainAgentsModules()
'width: auto;' 'width: auto;'
); );
// agent // Agent.
$agents = agents_get_group_agents($group_id); $agents = agents_get_group_agents($group_id);
if ((empty($agents)) || $agents == -1) { if ((empty($agents)) || $agents == -1) {
$agents = []; $agents = [];
@ -155,7 +156,7 @@ function mainAgentsModules()
$filter_agents_label = '<b>'.__('Agents').'</b>'; $filter_agents_label = '<b>'.__('Agents').'</b>';
$filter_agents = html_print_select($agents, 'id_agents2[]', $agents_id, '', '', 0, true, true, true, '', false, 'min-width: 180px; max-width: 200px;'); $filter_agents = html_print_select($agents, 'id_agents2[]', $agents_id, '', '', 0, true, true, true, '', false, 'min-width: 180px; max-width: 200px;');
// type show // Type show.
$selection = [ $selection = [
0 => __('Show common modules'), 0 => __('Show common modules'),
1 => __('Show all modules'), 1 => __('Show all modules'),
@ -163,12 +164,12 @@ function mainAgentsModules()
$filter_type_show_label = '<b>'.__('Show common modules').'</b>'; $filter_type_show_label = '<b>'.__('Show common modules').'</b>';
$filter_type_show = html_print_select($selection, 'selection_agent_module', $selection_a_m, '', '', 0, true, false, true, '', false, 'min-width: 180px;'); $filter_type_show = html_print_select($selection, 'selection_agent_module', $selection_a_m, '', '', 0, true, false, true, '', false, 'min-width: 180px;');
// modules // Modules.
$all_modules = select_modules_for_agent_group($group_id, $agents_id, $selection_a_m, false); $all_modules = select_modules_for_agent_group($group_id, $agents_id, $selection_a_m, false);
$filter_modules_label = '<b>'.__('Module').'</b>'; $filter_modules_label = '<b>'.__('Module').'</b>';
$filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', '', 0, true, true, false, '', false, 'min-width: 180px; max-width: 200px;'); $filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', '', 0, true, true, false, '', false, 'min-width: 180px; max-width: 200px;');
// update // Update.
$filter_update = html_print_submit_button(__('Update item'), 'edit_item', false, 'class="sub upd"', true); $filter_update = html_print_submit_button(__('Update item'), 'edit_item', false, 'class="sub upd"', true);
$onheader = [ $onheader = [
@ -178,8 +179,11 @@ function mainAgentsModules()
'combo_groups' => $filter_groups, 'combo_groups' => $filter_groups,
]; ];
// Old style table, we need a lot of special formatting,don't use table function /*
// Prepare old-style table * Old style table, we need a lot of special formatting,don't use table function.
* Prepare old-style table.
*/
if ($config['pure'] == 0) { if ($config['pure'] == 0) {
// Header. // Header.
ui_print_page_header( ui_print_page_header(
@ -200,38 +204,51 @@ function mainAgentsModules()
$full_modules = urlencode(implode(';', $full_modules_selected)); $full_modules = urlencode(implode(';', $full_modules_selected));
$full_agents = urlencode(implode(';', $full_agents_id)); $full_agents = urlencode(implode(';', $full_agents_id));
$url = " index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset=$offset $url = 'index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset=$offset
&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr&full_modules_selected=$full_modules &group_id=$group_id&modulegroup=$modulegroup&refresh=$refr&full_modules_selected=$full_modules
&full_agents_id=$full_agents&selection_agent_module=$selection_a_m"; &full_agents_id=$full_agents&selection_agent_module=$selection_a_m';
} else { } else {
$url = " index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset=$offset&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr"; $url = 'index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset=$offset&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr';
} }
// Floating menu - Start // Floating menu - Start.
echo '<div id="vc-controls" style="z-index: 999">'; echo '<div id="vc-controls" style="z-index: 999">';
echo '<div id="menu_tab">'; echo '<div id="menu_tab">';
echo '<ul class="mn">'; echo '<ul class="mn">';
// Quit fullscreen // Quit fullscreen.
echo '<li class="nomn">'; echo '<li class="nomn">';
echo '<a target="_top" href="'.$url.'">'; echo '<a target="_top" href="'.$url.'">';
echo html_print_image('images/normal_screen.png', true, ['title' => __('Back to normal mode')]); echo html_print_image('images/normal_screen.png', true, ['title' => __('Back to normal mode')]);
echo '</a>'; echo '</a>';
echo '</li>'; echo '</li>';
// Countdown // Countdown.
echo '<li class="nomn">'; echo '<li class="nomn">';
echo '<div class="vc-refr">'; echo '<div class="vc-refr">';
echo '<div class="vc-countdown"></div>'; echo '<div class="vc-countdown style="display: inline;"></div>';
echo '<div id="vc-refr-form">'; echo '<div id="vc-refr-form">';
echo __('Refresh').':'; echo __('Refresh').':';
echo html_print_select(get_refresh_time_array(), 'refresh', $refr, '', '', 0, true, false, false); echo html_print_select(
get_refresh_time_array(),
'refresh',
$refr,
'',
'',
0,
true,
false,
false,
'',
false,
'margin-top: 3px;'
);
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';
echo '</li>'; echo '</li>';
// Console name // Console name.
echo '<li class="nomn">'; echo '<li class="nomn">';
echo '<div class="vc-title">'.__('Agent/module view').'</div>'; echo '<div class="vc-title">'.__('Agent/module view').'</div>';
echo '</li>'; echo '</li>';
@ -240,35 +257,35 @@ function mainAgentsModules()
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';
// Floating menu - End // Floating menu - End.
ui_require_jquery_file('countdown'); ui_require_jquery_file('countdown');
} }
if ($config['pure'] != 1) { if ($config['pure'] != 1) {
echo '<form method="post" action="'.ui_get_url_refresh(['offset' => $offset, 'hor_offset' => $offset, 'group_id' => $group_id, 'modulegroup' => $modulegroup]).'">'; $show_filters = '<form method="post" action="'.ui_get_url_refresh(['offset' => $offset, 'hor_offset' => $offset, 'group_id' => $group_id, 'modulegroup' => $modulegroup]).'" style="width:100%;">';
$show_filters .= '<table class="white_table" cellpadding="0" cellspacing="0" border="0" style="width:100%; border:none;">';
echo '<table class="databox filters" cellpadding="0" cellspacing="0" border="0" style="width:100%;">'; $show_filters .= '<tr>';
echo '<tr>'; $show_filters .= '<td>'.$filter_groups_label.'</td>';
echo '<td>'.$filter_groups_label.'</td>'; $show_filters .= '<td>'.$filter_groups.'&nbsp;&nbsp;&nbsp;'.$filter_recursion_label.$filter_recursion.'</td>';
echo '<td>'.$filter_groups.'&nbsp;&nbsp;&nbsp;'.$filter_recursion_label.$filter_recursion.'</td>'; $show_filters .= '<td></td>';
echo '<td></td>'; $show_filters .= '<td></td>';
echo '<td></td>'; $show_filters .= '<td>'.$filter_module_groups_label.'</td>';
echo '<td>'.$filter_module_groups_label.'</td>'; $show_filters .= '<td>'.$filter_module_groups.'</td>';
echo '<td>'.$filter_module_groups.'</td>'; $show_filters .= '</tr>';
echo '</tr>'; $show_filters .= '<tr>';
echo '<tr>'; $show_filters .= '<td>'.$filter_agents_label.'</td>';
echo '<td>'.$filter_agents_label.'</td>'; $show_filters .= '<td>'.$filter_agents.'</td>';
echo '<td>'.$filter_agents.'</td>'; $show_filters .= '<td>'.$filter_type_show_label.'</td>';
echo '<td>'.$filter_type_show_label.'</td>'; $show_filters .= '<td>'.$filter_type_show.'</td>';
echo '<td>'.$filter_type_show.'</td>'; $show_filters .= '<td>'.$filter_modules_label.'</td>';
echo '<td>'.$filter_modules_label.'</td>'; $show_filters .= '<td>'.$filter_modules.'</td>';
echo '<td>'.$filter_modules.'</td>'; $show_filters .= '</tr>';
echo '</tr>'; $show_filters .= '<tr>';
echo '<tr>'; $show_filters .= "<td colspan=6 ><span style='float: right; padding-right: 20px;'>".$filter_update.'</sapn></td>';
echo "<td colspan=6 ><span style='float: right; padding-right: 20px;'>".$filter_update.'</sapn></td>'; $show_filters .= '</tr>';
echo '</tr>'; $show_filters .= '</table>';
echo '</table>'; $show_filters .= '</form>';
echo '</form>'; ui_toggle($show_filters, __('Filters'));
} }
if ($agents_id[0] != -1) { if ($agents_id[0] != -1) {
@ -291,7 +308,7 @@ function mainAgentsModules()
$count = 0; $count = 0;
foreach ($agents as $agent) { foreach ($agents as $agent) {
// TODO TAGS agents_get_modules // TODO TAGS agents_get_modules.
$module = agents_get_modules( $module = agents_get_modules(
$agent, $agent,
false, false,
@ -339,7 +356,7 @@ function mainAgentsModules()
} }
} }
} else { } else {
// TODO TAGS agents_get_modules // TODO TAGS agents_get_modules.
$all_modules = agents_get_modules( $all_modules = agents_get_modules(
$agents, $agents,
false, false,
@ -414,11 +431,11 @@ function mainAgentsModules()
if ($hor_offset > 0) { if ($hor_offset > 0) {
$new_hor_offset = ($hor_offset - $block); $new_hor_offset = ($hor_offset - $block);
echo "<th width='20px' "."style='vertical-align:top; padding-top: 35px;' "."rowspan='".($nagents + 1)."'>"."<a href='index.php?".'extension_in_menu=estado&'.'sec=extensions&'.'sec2=extensions/agents_modules&'.'refr=0&'.'save_serialize=1&'.'selection_a_m='.$selection_a_m.'&'.'hor_offset='.$new_hor_offset.'&'.'offset='.$offset."'>".html_print_image( echo "<th width='20px' style='vertical-align: middle; text-align: center;' rowspan='".($nagents + 1)."'><a href='index.php?".'extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&refr=0&save_serialize=1&selection_a_m='.$selection_a_m.'&hor_offset='.$new_hor_offset.'&offset='.$offset."'>".html_print_image(
'images/arrow_left.png', 'images/arrow_left_green.png',
true, true,
['title' => __('Previous modules')] ['title' => __('Previous modules')]
).'</a>'.'</th>'; ).'</a></th>';
} }
$nmodules = 0; $nmodules = 0;
@ -440,11 +457,11 @@ function mainAgentsModules()
if (($hor_offset + $block) < $nmodules) { if (($hor_offset + $block) < $nmodules) {
$new_hor_offset = ($hor_offset + $block); $new_hor_offset = ($hor_offset + $block);
echo "<th width='20px' "."style='vertical-align:top; padding-top: 35px;' "."rowspan='".($nagents + 1)."'>"."<a href='index.php?".'extension_in_menu=estado&'.'sec=extensions&'.'sec2=extensions/agents_modules&'.'save_serialize=1&'.'selection_a_m='.$selection_a_m.'&'.'hor_offset='.$new_hor_offset.'&'.'offset='.$offset."'>".html_print_image( echo "<th width='20px' style='vertical-align: middle; text-align: center;' rowspan='".($nagents + 1)."'><a href='index.php?".'extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&selection_a_m='.$selection_a_m.'&hor_offset='.$new_hor_offset.'&offset='.$offset."'>".html_print_image(
'images/arrow.png', 'images/arrow_right_green.png',
true, true,
['title' => __('More modules')] ['title' => __('More modules')]
).'</a>'.'</th>'; ).'</a></th>';
} }
echo '</tr>'; echo '</tr>';
@ -457,12 +474,12 @@ function mainAgentsModules()
$filter_agents['id_grupo'] = $group_id; $filter_agents['id_grupo'] = $group_id;
} }
// Prepare pagination // Prepare pagination.
$url = 'index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&'.'hor_offset='.$hor_offset.'&selection_a_m='.$selection_a_m; $url = 'index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&hor_offset='.$hor_offset.'&selection_a_m='.$selection_a_m;
ui_pagination($total_pagination, $url); ui_pagination($total_pagination, $url);
foreach ($agents as $agent) { foreach ($agents as $agent) {
// Get stats for this group // Get stats for this group.
$agent_status = agents_get_status($agent['id_agente']); $agent_status = agents_get_status($agent['id_agente']);
$alias = db_get_row('tagente', 'id_agente', $agent['id_agente']); $alias = db_get_row('tagente', 'id_agente', $agent['id_agente']);
if (empty($alias['alias'])) { if (empty($alias['alias'])) {
@ -471,29 +488,29 @@ function mainAgentsModules()
switch ($agent_status) { switch ($agent_status) {
case 4: case 4:
// Alert fired status // Alert fired status.
$rowcolor = 'group_view_alrm'; $rowcolor = 'group_view_alrm';
break; break;
case 1: case 1:
// Critical status // Critical status.
$rowcolor = 'group_view_crit'; $rowcolor = 'group_view_crit';
break; break;
case 2: case 2:
// Warning status // Warning status.
$rowcolor = 'group_view_warn'; $rowcolor = 'group_view_warn';
break; break;
case 0: case 0:
// Normal status // Normal status.
$rowcolor = 'group_view_ok'; $rowcolor = 'group_view_ok';
break; break;
case 3: case 3:
case -1: case -1:
default: default:
// Unknown status // Unknown status.
$rowcolor = 'group_view_unk'; $rowcolor = 'group_view_unk';
break; break;
} }
@ -502,7 +519,7 @@ function mainAgentsModules()
echo "<td class='$rowcolor'> echo "<td class='$rowcolor'>
<a class='$rowcolor' href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$agent['id_agente']."'>".$alias['alias'].'</a></td>'; <a class='$rowcolor' href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$agent['id_agente']."'>".$alias['alias'].'</a></td>';
// TODO TAGS agents_get_modules // TODO TAGS agents_get_modules.
$agent_modules = agents_get_modules($agent['id_agente'], false, $filter_module_group, true, true); $agent_modules = agents_get_modules($agent['id_agente'], false, $filter_module_group, true, true);
$nmodules = 0; $nmodules = 0;
@ -572,18 +589,23 @@ function mainAgentsModules()
echo '</table>'; echo '</table>';
echo "<div class='legend_basic' style='width: 96%'>"; $show_legend = "<div class='legend_white'>";
$show_legend .= "<div style='display: flex;align-items: center;'>
<div class='legend_square_simple'><div style='background-color: ".COL_ALERTFIRED.";'></div></div>".__('Orange cell when the module has fired alerts').'</div>';
$show_legend .= "<div style='display: flex;align-items: center;'>
<div class='legend_square_simple'><div style='background-color: ".COL_CRITICAL.";'></div></div>".__('Red cell when the module has a critical status').'
</div>';
$show_legend .= "<div style='display: flex;align-items: center;'>
<div class='legend_square_simple'><div style='background-color: ".COL_WARNING.";'></div></div>".__('Yellow cell when the module has a warning status').'</div>';
$show_legend .= "<div style='display: flex;align-items: center;'>
<div class='legend_square_simple'><div style='background-color: ".COL_NORMAL.";'></div></div>".__('Green cell when the module has a normal status').'</div>';
$show_legend .= "<div style='display: flex;align-items: center;'>
<div class='legend_square_simple'><div style='background-color: ".COL_UNKNOWN.";'></div></div>".__('Grey cell when the module has an unknown status').'</div>';
$show_legend .= "<div style='display: flex;align-items: center;'>
<div class='legend_square_simple'><div style='background-color: ".COL_NOTINIT.";'></div></div>".__("Cell turns blue when the module is in 'not initialize' status").'</div>';
$show_legend .= '</div>';
ui_toggle($show_legend, __('Legend'));
echo '<table>';
echo "<tr><td colspan='2' style='padding-bottom: 10px;'><b>".__('Legend').'</b></td></tr>';
echo "<tr><td class='legend_square_simple'><div style='background-color: ".COL_ALERTFIRED.";'></div></td><td>".__('Orange cell when the module has fired alerts').'</td></tr>';
echo "<tr><td class='legend_square_simple'><div style='background-color: ".COL_CRITICAL.";'></div></td><td>".__('Red cell when the module has a critical status').'</td></tr>';
echo "<tr><td class='legend_square_simple'><div style='background-color: ".COL_WARNING.";'></div></td><td>".__('Yellow cell when the module has a warning status').'</td></tr>';
echo "<tr><td class='legend_square_simple'><div style='background-color: ".COL_NORMAL.";'></div></td><td>".__('Green cell when the module has a normal status').'</td></tr>';
echo "<tr><td class='legend_square_simple'><div style='background-color: ".COL_UNKNOWN.";'></div></td><td>".__('Grey cell when the module has an unknown status').'</td></tr>';
echo "<tr><td class='legend_square_simple'><div style='background-color: ".COL_NOTINIT.";'></div></td><td>".__("Cell turns blue when the module is in 'not initialize' status").'</td></tr>';
echo '</table>';
echo '</div>';
$pure_var = $config['pure']; $pure_var = $config['pure'];
if ($pure_var) { if ($pure_var) {
$pure_var = 1; $pure_var = 1;
@ -627,16 +649,14 @@ $ignored_params['refresh'] = '';
$.each($('.th_class_module_r'), function (i, elem) { $.each($('.th_class_module_r'), function (i, elem) {
id = $(elem).attr('id').replace('th_module_r_', ''); id = $(elem).attr('id').replace('th_module_r_', '');
$("#th_module_r_" + id).height(($("#div_module_r_" + id).width() + 10) + 'px'); $("#th_module_r_" + id).height(($("#div_module_r_" + id).width() + 10) + 'px');
//$("#div_module_r_" + id).css('margin-top', (max_width - $("#div_module_r_" + id).width()) + 'px');
$("#div_module_r_" + id).css('margin-top', (max_width - 20) + 'px'); $("#div_module_r_" + id).css('margin-top', (max_width - 20) + 'px');
$("#div_module_r_" + id).show(); $("#div_module_r_" + id).show();
}); });
var refr =" . $refr . "; var refr = '<?php echo get_parameter('refresh', 0); ?>';
var pure =" . $pure_var . "; var pure = '<?php echo get_parameter('pure', 0); ?>';
var href ='" . ui_get_url_refresh ($ignored_params) . "'; var href =' <?php echo ui_get_url_refresh($ignored_params); ?>';
if (pure) { if (pure) {
var startCountDown = function (duration, cb) { var startCountDown = function (duration, cb) {
$('div.vc-countdown').countdown('destroy'); $('div.vc-countdown').countdown('destroy');
@ -646,7 +666,7 @@ $ignored_params['refresh'] = '';
$('div.vc-countdown').countdown({ $('div.vc-countdown').countdown({
until: t, until: t,
format: 'MS', format: 'MS',
layout: '(%M%nn%M:%S%nn%S Until refresh)', layout: '(%M%nn%M:%S%nn%S <?php echo __('Until next'); ?>) ',
alwaysExpire: true, alwaysExpire: true,
onExpiry: function () { onExpiry: function () {
$('div.vc-countdown').countdown('destroy'); $('div.vc-countdown').countdown('destroy');
@ -655,8 +675,11 @@ $ignored_params['refresh'] = '';
} }
}); });
} }
startCountDown(refr, false); if(refr>0){
startCountDown(refr, false);
}
var controls = document.getElementById('vc-controls'); var controls = document.getElementById('vc-controls');
autoHideElement(controls, 1000); autoHideElement(controls, 1000);

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* Module groups.
*
* @category Extensions
* @package Pandora FMS
* @subpackage Module groups view.
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 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-2011 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.
// Load global vars
global $config; global $config;
check_login(); check_login();
@ -32,10 +47,12 @@ 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.
*/ *
* @return void
*/
function mainModuleGroups() function mainModuleGroups()
{ {
global $config; global $config;
@ -68,13 +85,20 @@ function mainModuleGroups()
$info = array_filter( $info = array_filter(
$info, $info,
function ($v, $k) use ($agent_group_search) { function ($v, $k) use ($agent_group_search) {
return preg_match("/$agent_group_search/i", $v['name']); return preg_match(
'/'.$agent_group_search.'/i',
$v['name']
);
}, },
ARRAY_FILTER_USE_BOTH ARRAY_FILTER_USE_BOTH
); );
if (!empty($info)) { if (!empty($info)) {
$groups_view = $is_not_paginated ? $info : array_slice($info, $offset, $config['block_size']); $groups_view = ($is_not_paginated) ? $info : array_slice(
$info,
$offset,
$config['block_size']
);
$agents_counters = array_reduce( $agents_counters = array_reduce(
$groups_view, $groups_view,
function ($carry, $item) { function ($carry, $item) {
@ -113,7 +137,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, $k) 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
); );
@ -125,66 +149,75 @@ function mainModuleGroups()
$array_for_defect[$key]['data']['icon'] = $value['icon']; $array_for_defect[$key]['data']['icon'] = $value['icon'];
} }
$sql = "SELECT SUM(IF(tae.alert_fired <> 0, 1, 0)) AS alerts_module_count, $sql = sprintf(
SUM(IF($condition_warning, 1, 0)) AS warning_module_count, "SELECT SUM(IF(tae.alert_fired <> 0, 1, 0)) AS alerts_module_count,
SUM(IF($condition_unknown, 1, 0)) AS unknown_module_count, SUM(IF(%s, 1, 0)) AS warning_module_count,
SUM(IF($condition_not_init, 1, 0)) AS notInit_module_count, SUM(IF(%s, 1, 0)) AS unknown_module_count,
SUM(IF($condition_critical, 1, 0)) AS critical_module_count, SUM(IF(%s, 1, 0)) AS notInit_module_count,
SUM(IF($condition_normal, 1, 0)) AS normal_module_count, SUM(IF(%s, 1, 0)) AS critical_module_count,
COUNT(tae.id_agente_modulo) AS total_count, SUM(IF(%s, 1, 0)) AS normal_module_count,
tmg.id_mg, COUNT(tae.id_agente_modulo) AS total_count,
tmg.name as n, tmg.id_mg,
tg.id_grupo tmg.name as n,
FROM ( tg.id_grupo
SELECT tam.id_agente_modulo, FROM (
tam.id_module_group, SELECT tam.id_agente_modulo,
ta.id_grupo AS g, tam.id_module_group,
tae.estado, ta.id_grupo AS g,
SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired tae.estado,
FROM tagente_modulo tam SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired
LEFT JOIN talert_template_modules tatm FROM tagente_modulo tam
ON tatm.id_agent_module = tam.id_agente_modulo LEFT JOIN talert_template_modules tatm
AND tatm.times_fired = 1 ON tatm.id_agent_module = tam.id_agente_modulo
LEFT JOIN tagente_estado tae AND tatm.times_fired = 1
ON tae.id_agente_modulo = tam.id_agente_modulo LEFT JOIN tagente_estado tae
INNER JOIN tagente ta ON tae.id_agente_modulo = tam.id_agente_modulo
ON ta.id_agente = tam.id_agente INNER JOIN tagente ta
WHERE ta.disabled = 0 ON ta.id_agente = tam.id_agente
AND tam.disabled = 0 WHERE ta.disabled = 0
AND tam.delete_pending = 0 AND tam.disabled = 0
AND ta.id_grupo IN ($ids_group) AND tam.delete_pending = 0
GROUP BY tam.id_agente_modulo AND ta.id_grupo IN (%s)
UNION ALL GROUP BY tam.id_agente_modulo
SELECT tam.id_agente_modulo, UNION ALL
tam.id_module_group, SELECT tam.id_agente_modulo,
tasg.id_group AS g, tam.id_module_group,
tae.estado, tasg.id_group AS g,
SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired tae.estado,
FROM tagente_modulo tam SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired
LEFT JOIN talert_template_modules tatm FROM tagente_modulo tam
ON tatm.id_agent_module = tam.id_agente_modulo LEFT JOIN talert_template_modules tatm
AND tatm.times_fired = 1 ON tatm.id_agent_module = tam.id_agente_modulo
LEFT JOIN tagente_estado tae AND tatm.times_fired = 1
ON tae.id_agente_modulo = tam.id_agente_modulo LEFT JOIN tagente_estado tae
INNER JOIN tagente ta ON tae.id_agente_modulo = tam.id_agente_modulo
ON ta.id_agente = tam.id_agente INNER JOIN tagente ta
INNER JOIN tagent_secondary_group tasg ON ta.id_agente = tam.id_agente
ON ta.id_agente = tasg.id_agent INNER JOIN tagent_secondary_group tasg
WHERE ta.disabled = 0 ON ta.id_agente = tasg.id_agent
AND tam.disabled = 0 WHERE ta.disabled = 0
AND tam.delete_pending = 0 AND tam.disabled = 0
AND tasg.id_group IN ($ids_group) AND tam.delete_pending = 0
GROUP BY tam.id_agente_modulo, tasg.id_group AND tasg.id_group IN (%s)
) AS tae GROUP BY tam.id_agente_modulo, tasg.id_group
RIGHT JOIN tgrupo tg ) AS tae
ON tg.id_grupo = tae.g RIGHT JOIN tgrupo tg
INNER JOIN ( ON tg.id_grupo = tae.g
SELECT * FROM tmodule_group INNER JOIN (
UNION ALL SELECT * FROM tmodule_group
SELECT 0 AS 'id_mg', 'Nothing' AS 'name' UNION ALL
) AS tmg SELECT 0 AS 'id_mg', 'Nothing' AS 'name'
ON tae.id_module_group = tmg.id_mg ) AS tmg
GROUP BY tae.g, tmg.id_mg"; ON tae.id_module_group = tmg.id_mg
GROUP BY tae.g, tmg.id_mg",
$condition_warning,
$condition_unknown,
$condition_not_init,
$condition_critical,
$condition_normal,
$ids_group,
$ids_group
);
$array_data_prev = db_get_all_rows_sql($sql); $array_data_prev = db_get_all_rows_sql($sql);
@ -220,9 +253,21 @@ function mainModuleGroups()
echo '<td>'; echo '<td>';
echo '</tr></table>'; echo '</tr></table>';
$cell_style = '
min-width: 60px;
width: 100%;
margin: 0;
overflow:hidden;
text-align: center;
padding: 5px;
padding-bottom:10px;
font-size: 18px;
text-align: center;
';
if (true) { if (true) {
$table = new StdClass(); $table = new StdClass();
$table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; padding-right: 10px; min-width: 230px;'; $table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; min-width: 230px;';
$table->width = '100%'; $table->width = '100%';
$head[0] = __('Groups'); $head[0] = __('Groups');
@ -248,28 +293,28 @@ function mainModuleGroups()
$color = '#FFA631'; $color = '#FFA631';
// 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 = '#FC4444'; $color = '#e63c52';
// 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 = '#FAD403'; $color = '#f3b200';
// 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 = '#B2B2B2 '; $color = '#B2B2B2 ';
// 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 = '#80BA27'; $color = '#82b92e';
// 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.
} else if ($array_data[$key][$k]['notInit_module_count'] != 0) { } else if ($array_data[$key][$k]['notInit_module_count'] != 0) {
$color = '#5BB6E5'; $color = '#5BB6E5';
// Blue when the cell for this module group and all modules have not init value. // Blue when the cell for this module group and all modules have not init value.
} }
$data[$i][$j] = "<div style='background:$color; height: 20px;min-width: 60px;max-width:5%;overflow:hidden; margin-left: auto; margin-right: auto; text-align: center; padding: 5px;padding-bottom:10px;font-size: 18px;line-height:25px;'>"; $data[$i][$j] = "<div style='".$cell_style.'background:'.$color.";'>";
$data[$i][$j] .= "<a class='info_cell' rel='$rel' href='$url' style='color:white;font-size: 18px;'>"; $data[$i][$j] .= "<a class='info_cell' rel='$rel' href='$url' style='color:white;font-size: 18px;'>";
$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 {
$data[$i][$j] = "<div style='background:white; height: 20px;min-width: 60px;max-width:5%;overflow:hidden; margin-left: auto; margin-right: auto; text-align: center; padding: 5px;padding-bottom:10px;font-size: 18px;line-height:25px;'>"; $data[$i][$j] = "<div style='background:white;".$cell_style."'>";
$data[$i][$j] .= 0; $data[$i][$j] .= 0;
$data[$i][$j] .= '</div>'; $data[$i][$j] .= '</div>';
} }
@ -278,7 +323,7 @@ function mainModuleGroups()
} }
} else { } else {
foreach ($value['gm'] as $k => $v) { foreach ($value['gm'] as $k => $v) {
$data[$i][$j] = "<div style='background:white; height: 20px;min-width: 60px;max-width:5%;overflow:hidden; margin-left: auto; margin-right: auto; text-align: center; padding: 5px;padding-bottom:10px;font-size: 18px;line-height:25px;'>"; $data[$i][$j] = "<div style='background:white; min-width: 60px;max-width:5%;overflow:hidden; margin-left: auto; margin-right: auto; text-align: center; padding: 5px;padding-bottom:10px;font-size: 18px;line-height:25px;'>";
$data[$i][$j] .= 0; $data[$i][$j] .= 0;
$data[$i][$j] .= '</div>'; $data[$i][$j] .= '</div>';
$j++; $j++;

View File

@ -1,26 +1,60 @@
<?php <?php
/**
* Net tools utils.
*
* @category Extensions
* @package Pandora FMS
* @subpackage NetTools
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 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.
// ================================================== global $config;
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list // Requires.
// This program is free software; you can redistribute it and/or require_once $config['homedir'].'/include/functions.php';
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2 // This extension is usefull only if the agent has associated IP.
// 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.
$id_agente = get_parameter('id_agente'); $id_agente = get_parameter('id_agente');
// This extension is usefull only if the agent has associated IP
$address = agents_get_address($id_agente); $address = agents_get_address($id_agente);
if (!empty($address) || empty($id_agente)) { if (!empty($address) || empty($id_agente)) {
extensions_add_opemode_tab_agent('network_tools', 'Network Tools', 'extensions/net_tools/nettool.png', 'main_net_tools', 'v1r1', 'AW'); extensions_add_opemode_tab_agent(
'network_tools',
'Network Tools',
'extensions/net_tools/nettool.png',
'main_net_tools',
'v1r1',
'AW'
);
} }
/**
* Searchs for command.
*
* @param string $command Command.
*
* @return string Path.
*/
function whereis_the_command($command) function whereis_the_command($command)
{ {
global $config; global $config;
@ -63,6 +97,9 @@ function whereis_the_command($command)
return $snmpget_path; return $snmpget_path;
} }
break; break;
default:
return null;
} }
} }
@ -87,85 +124,20 @@ function whereis_the_command($command)
} }
function main_net_tools() /**
* Execute net tools action.
*
* @param integer $operation Operation.
* @param string $ip Ip.
* @param string $community Community.
* @param string $snmp_version SNMP version.
*
* @return void
*/
function net_tools_execute($operation, $ip, $community, $snmp_version)
{ {
$id_agente = get_parameter('id_agente');
$principal_ip = db_get_sql("SELECT direccion FROM tagente WHERE id_agente = $id_agente");
$list_address = db_get_all_rows_sql('select id_a from taddress_agent where id_agent = '.$id_agente);
foreach ($list_address as $address) {
$ids[] = join(',', $address);
}
$ids_address = implode(',', $ids);
$ips = db_get_all_rows_sql('select ip from taddress where id_a in ('.$ids_address.')');
if ($ips == '') {
echo "<div class='error' style='margin-top:5px'>".__('The agent hasn\'t got IP').'</div>';
return;
}
echo "
<script type='text/javascript'>
function mostrarColumns(ValueSelect) {
value = ValueSelect.value;
if (value == 3) {
$('netToolTable').css('width','100%');
$('#snmpcolumn').show();
}
else {
$('netToolTable').css('width','100%');
$('#snmpcolumn').hide();
}
}
</script>";
echo '<div>';
echo "<form name='actionbox' method='post'>";
echo "<table class='databox filters' width=100% id=netToolTable>";
echo '<tr><td>';
echo __('Operation');
ui_print_help_tip(
__('You can set the command path in the menu Administration -&gt; Extensions -&gt; Config Network Tools')
);
echo '</td><td>';
echo "<select name='operation' onChange='mostrarColumns(this);'>";
echo "<option value='1'>".__('Traceroute');
echo "<option value='2'>".__('Ping host & Latency');
echo "<option value='3'>".__('SNMP Interface status');
echo "<option value='4'>".__('Basic TCP Port Scan');
echo "<option value='5'>".__('DiG/Whois Lookup');
echo '</select>';
echo '</td>';
echo '<td>';
echo __('IP address');
echo '</td><td>';
echo "<select name='select_ips'>";
foreach ($ips as $ip) {
if ($ip['ip'] == $principal_ip) {
echo "<option value='".$ip['ip']."' selected = 'selected'>".$ip['ip'];
} else {
echo "<option value='".$ip['ip']."'>".$ip['ip'];
}
}
echo '</select>';
echo '</td>';
echo "<td id='snmpcolumn' style=\"display:none;\">";
echo __('SNMP Community').'&nbsp;';
echo "<input name=community type=text value='public'>";
echo '</td><td>';
echo "<input style='margin:0px;' name=submit type=submit class='sub next' value='".__('Execute')."'>";
echo '</td>';
echo '</tr></table>';
echo '</form>';
$operation = get_parameter('operation', 0);
$community = get_parameter('community', 'public');
$ip = get_parameter('select_ips');
if (!validate_address($ip)) { if (!validate_address($ip)) {
ui_print_error_message(__('The ip or dns name entered cannot be resolved')); ui_print_error_message(__('The ip or dns name entered cannot be resolved'));
} else { } else {
switch ($operation) { switch ($operation) {
case 1: case 1:
@ -175,7 +147,7 @@ function main_net_tools()
} else { } else {
echo '<h3>'.__('Traceroute to ').$ip.'</h3>'; echo '<h3>'.__('Traceroute to ').$ip.'</h3>';
echo '<pre>'; echo '<pre>';
echo system("$traceroute $ip"); echo system($traceroute.' '.$ip);
echo '</pre>'; echo '</pre>';
} }
break; break;
@ -187,7 +159,7 @@ function main_net_tools()
} else { } else {
echo '<h3>'.__('Ping to %s', $ip).'</h3>'; echo '<h3>'.__('Ping to %s', $ip).'</h3>';
echo '<pre>'; echo '<pre>';
echo system("$ping -c 5 $ip"); echo system($ping.' -c 5 '.$ip);
echo '</pre>'; echo '</pre>';
} }
break; break;
@ -199,7 +171,7 @@ function main_net_tools()
} else { } else {
echo '<h3>'.__('Basic TCP Scan on ').$ip.'</h3>'; echo '<h3>'.__('Basic TCP Scan on ').$ip.'</h3>';
echo '<pre>'; echo '<pre>';
echo system("$nmap -F $ip"); echo system($nmap.' -F '.$ip);
echo '</pre>'; echo '</pre>';
} }
break; break;
@ -212,7 +184,7 @@ function main_net_tools()
ui_print_error_message(__('Dig executable does not exist.')); ui_print_error_message(__('Dig executable does not exist.'));
} else { } else {
echo '<pre>'; echo '<pre>';
echo system("dig $ip"); echo system('dig '.$ip);
echo '</pre>'; echo '</pre>';
} }
@ -221,51 +193,227 @@ function main_net_tools()
ui_print_error_message(__('Whois executable does not exist.')); ui_print_error_message(__('Whois executable does not exist.'));
} else { } else {
echo '<pre>'; echo '<pre>';
echo system("whois $ip"); echo system('whois '.$ip);
echo '</pre>'; echo '</pre>';
} }
break; break;
case 3: case 3:
$snmp_obj = [
'ip_target' => $ip,
'snmp_version' => $snmp_version,
'snmp_community' => $community,
'format' => '-Oqn',
];
$snmp_obj['base_oid'] = '.1.3.6.1.2.1.1.3.0';
$result = get_h_snmpwalk($snmp_obj);
echo '<h3>'.__('SNMP information for ').$ip.'</h3>'; echo '<h3>'.__('SNMP information for ').$ip.'</h3>';
echo '<h4>'.__('Uptime').'</h4>';
$snmpget = whereis_the_command('snmpget'); echo '<pre>';
if (empty($snmpget)) { if (empty($result)) {
ui_print_error_message(__('SNMPget executable does not exist.')); ui_print_error_message(__('Target unreachable.'));
break;
} else { } else {
echo '<h4>'.__('Uptime').'</h4>'; echo array_pop($result);
echo '<pre>';
echo exec("$snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.3.0 ");
echo '</pre>';
echo '<h4>'.__('Device info').'</h4>';
echo '<pre>';
echo system("$snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.1.0 ");
echo '</pre>';
echo '<h4>Interface Information</h4>';
echo '<table class=databox>';
echo '<tr><th>'.__('Interface');
echo '<th>'.__('Status');
$int_max = exec("$snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.1.0 ");
for ($ax = 0; $ax < $int_max; $ax++) {
$interface = exec("$snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.2.1.2.$ax ");
$estado = exec("$snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.2.1.8.$ax ");
echo "<tr><td>$interface<td>$estado";
}
echo '</table>';
} }
echo '</pre>';
echo '<h4>'.__('Device info').'</h4>';
echo '<pre>';
$snmp_obj['base_oid'] = '.1.3.6.1.2.1.1.1.0';
$result = get_h_snmpwalk($snmp_obj);
if (empty($result)) {
ui_print_error_message(__('Target unreachable.'));
break;
} else {
echo array_pop($result);
}
echo '</pre>';
echo '<h4>Interface Information</h4>';
$table = new StdClass();
$table->class = 'databox';
$table->head = [];
$table->head[] = __('Interface');
$table->head[] = __('Status');
$i = 0;
$base_oid = '.1.3.6.1.2.1.2.2.1';
$idx_oids = '.1';
$names_oids = '.2';
$status_oids = '.8';
$snmp_obj['base_oid'] = $base_oid.$idx_oids;
$idx = get_h_snmpwalk($snmp_obj);
$snmp_obj['base_oid'] = $base_oid.$names_oids;
$names = get_h_snmpwalk($snmp_obj);
$snmp_obj['base_oid'] = $base_oid.$status_oids;
$statuses = get_h_snmpwalk($snmp_obj);
foreach ($idx as $k => $v) {
$index = str_replace($base_oid.$idx_oids, '', $k);
$name = $names[$base_oid.$names_oids.$index];
$status = $statuses[$base_oid.$status_oids.$index];
$table->data[$i][0] = $name;
$table->data[$i++][1] = $status;
}
html_print_table($table);
break;
default:
// Ignore.
break; break;
} }
} }
}
/**
* Main function.
*
* @return void
*/
function main_net_tools()
{
$operation = get_parameter('operation', 0);
$community = get_parameter('community', 'public');
$ip = get_parameter('select_ips');
$snmp_version = get_parameter('select_version');
// Show form.
$id_agente = get_parameter('id_agente', 0);
$principal_ip = db_get_sql(
sprintf(
'SELECT direccion FROM tagente WHERE id_agente = %d',
$id_agente
)
);
$list_address = db_get_all_rows_sql(
sprintf(
'SELECT id_a FROM taddress_agent WHERE id_agent = %d',
$id_agente
)
);
foreach ($list_address as $address) {
$ids[] = join(',', $address);
}
$ips = db_get_all_rows_sql(
sprintf(
'SELECT ip FROM taddress WHERE id_a IN (%s)',
join($ids)
)
);
if ($ips == '') {
echo "<div class='error' style='margin-top:5px'>".__('The agent hasn\'t got IP').'</div>';
return;
}
// Javascript.
?>
<script type='text/javascript'>
$(document).ready(function(){
mostrarColumns($('#operation :selected').val());
});
function mostrarColumns(value) {
if (value == 3) {
$('.snmpcolumn').show();
}
else {
$('.snmpcolumn').hide();
}
}
</script>
<?php
echo '<div>';
echo "<form name='actionbox' method='post'>";
echo "<table class='databox filters' width=100% id=netToolTable>";
echo '<tr><td>';
echo __('Operation');
ui_print_help_tip(
__('You can set the command path in the menu Administration -&gt; Extensions -&gt; Config Network Tools')
);
echo '</td><td>';
html_print_select(
[
1 => __('Traceroute'),
2 => __('Ping host & Latency'),
3 => __('SNMP Interface status'),
4 => __('Basic TCP Port Scan'),
5 => __('DiG/Whois Lookup'),
],
'operation',
$operation,
'mostrarColumns(this.value)',
__('Please select')
);
echo '</td>';
echo '<td>';
echo __('IP address');
echo '</td><td>';
$ips_for_select = array_reduce(
$ips,
function ($carry, $item) {
$carry[$item['ip']] = $item['ip'];
return $carry;
}
);
html_print_select(
$ips_for_select,
'select_ips',
$principal_ip
);
echo '</td>';
echo "<td class='snmpcolumn'>";
echo __('SNMP Version');
html_print_select(
[
'1' => 'v1',
'2c' => 'v2c',
],
'select_version',
$snmp_version
);
echo '</td><td class="snmpcolumn">';
echo __('SNMP Community').'&nbsp;';
html_print_input_text('community', $community);
echo '</td><td>';
echo "<input style='margin:0px;' name=submit type=submit class='sub next' value='".__('Execute')."'>";
echo '</td>';
echo '</tr></table>';
echo '</form>';
if ($operation) {
// Execute form.
net_tools_execute($operation, $ip, $community, $snmp_version);
}
echo '</div>'; echo '</div>';
} }
/**
* Add option.
*
* @return void
*/
function godmode_net_tools() function godmode_net_tools()
{ {
global $config; global $config;

View File

@ -11,5 +11,5 @@
#graph_container { #graph_container {
width: 800px; width: 800px;
margin: 20px auto !important; margin: 20px auto;
} }

View File

@ -1,3 +0,0 @@
/general/login_identification_wizard.php
/general/login_required.php
/godmode/update_manager/update_manager.messages.php

View File

@ -1,6 +1,28 @@
START TRANSACTION; START TRANSACTION;
ALTER TABLE `tmetaconsole_agent` ADD INDEX `id_tagente_idx` (`id_tagente`);
DELETE FROM `ttipo_modulo` WHERE `nombre` LIKE 'log4x'; DELETE FROM `ttipo_modulo` WHERE `nombre` LIKE 'log4x';
CREATE TABLE IF NOT EXISTS `tcredential_store` (
`identifier` varchar(100) NOT NULL,
`id_group` mediumint(4) unsigned NOT NULL DEFAULT 0,
`product` enum('CUSTOM', 'AWS', 'AZURE', 'GOOGLE') default 'CUSTOM',
`username` text,
`password` text,
`extra_1` text,
`extra_2` text,
PRIMARY KEY (`identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `tcredential_store` (`identifier`, `id_group`, `product`, `username`, `password`) VALUES ("imported_aws_account", 0, "AWS", (SELECT `value` FROM `tconfig` WHERE `token` = "aws_access_key_id" LIMIT 1), (SELECT `value` FROM `tconfig` WHERE `token` = "aws_secret_access_key" LIMIT 1));
DELETE FROM `tcredential_store` WHERE `username` IS NULL AND `password` IS NULL;
UPDATE `tagente` ta INNER JOIN `tagente` taa on ta.`id_parent` = taa.`id_agente` AND taa.`nombre` IN ("us-east-1", "us-east-2", "us-west-1", "us-west-2", "ca-central-1", "eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "ap-northeast-1", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-south-1", "sa-east-1") SET ta.nombre = md5(concat((SELECT `username` FROM `tcredential_store` WHERE `identifier` = "imported_aws_account" LIMIT 1), ta.`nombre`));
UPDATE `tagente` SET `nombre` = md5(concat((SELECT `username` FROM `tcredential_store` WHERE `identifier` = "imported_aws_account" LIMIT 1), `nombre`)) WHERE `nombre` IN ("Aws", "us-east-1", "us-east-2", "us-west-1", "us-west-2", "ca-central-1", "eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "ap-northeast-1", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-south-1", "sa-east-1");
UPDATE `trecon_task` SET `auth_strings` = "imported_aws_account" WHERE `type` IN (2,6,7);
COMMIT; COMMIT;

View File

@ -1007,10 +1007,12 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` (
`agent_version` varchar(100) default '', `agent_version` varchar(100) default '',
`ultimo_contacto_remoto` datetime default '1970-01-01 00:00:00', `ultimo_contacto_remoto` datetime default '1970-01-01 00:00:00',
`disabled` tinyint(2) NOT NULL default '0', `disabled` tinyint(2) NOT NULL default '0',
`remote` tinyint(1) NOT NULL default '0',
`id_parent` int(10) unsigned default '0', `id_parent` int(10) unsigned default '0',
`custom_id` varchar(255) default '', `custom_id` varchar(255) default '',
`server_name` varchar(100) default '', `server_name` varchar(100) default '',
`cascade_protection` tinyint(2) NOT NULL default '0', `cascade_protection` tinyint(2) NOT NULL default '0',
`cascade_protection_module` int(10) unsigned default '0',
`timezone_offset` TINYINT(2) NULL DEFAULT '0' COMMENT 'number of hours of diference with the server timezone' , `timezone_offset` TINYINT(2) NULL DEFAULT '0' COMMENT 'number of hours of diference with the server timezone' ,
`icon_path` VARCHAR(127) NULL DEFAULT NULL COMMENT 'path in the server to the image of the icon representing the agent' , `icon_path` VARCHAR(127) NULL DEFAULT NULL COMMENT 'path in the server to the image of the icon representing the agent' ,
`update_gis_data` TINYINT(1) NOT NULL DEFAULT '1' COMMENT 'set it to one to update the position data (altitude, longitude, latitude) when getting information from the agent or to 0 to keep the last value and do not update it' , `update_gis_data` TINYINT(1) NOT NULL DEFAULT '1' COMMENT 'set it to one to update the position data (altitude, longitude, latitude) when getting information from the agent or to 0 to keep the last value and do not update it' ,
@ -1025,19 +1027,21 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` (
`fired_count` bigint(20) NOT NULL default '0', `fired_count` bigint(20) NOT NULL default '0',
`update_module_count` tinyint(1) NOT NULL default '0', `update_module_count` tinyint(1) NOT NULL default '0',
`update_alert_count` tinyint(1) NOT NULL default '0', `update_alert_count` tinyint(1) NOT NULL default '0',
`update_secondary_groups` tinyint(1) NOT NULL default '0',
`transactional_agent` tinyint(1) NOT NULL default '0',
`alias` varchar(600) BINARY NOT NULL default '',
`alias_as_name` tinyint(2) NOT NULL default '0',
`safe_mode_module` int(10) unsigned NOT NULL default '0',
`cps` int NOT NULL default 0,
PRIMARY KEY (`id_agente`), PRIMARY KEY (`id_agente`),
KEY `nombre` (`nombre`(255)), KEY `nombre` (`nombre`(255)),
KEY `direccion` (`direccion`), KEY `direccion` (`direccion`),
KEY `id_tagente_idx` (`id_tagente`),
KEY `disabled` (`disabled`), KEY `disabled` (`disabled`),
KEY `id_grupo` (`id_grupo`), KEY `id_grupo` (`id_grupo`),
FOREIGN KEY (`id_tmetaconsole_setup`) REFERENCES tmetaconsole_setup(`id`) ON DELETE CASCADE ON UPDATE CASCADE FOREIGN KEY (`id_tmetaconsole_setup`) REFERENCES tmetaconsole_setup(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE tmetaconsole_agent ADD COLUMN `remote` tinyint(1) NOT NULL default '0';
ALTER TABLE tmetaconsole_agent ADD COLUMN `cascade_protection_module` int(10) default '0';
ALTER TABLE tmetaconsole_agent ADD COLUMN `transactional_agent` tinyint(1) NOT NULL default '0';
ALTER TABLE tmetaconsole_agent ADD COLUMN `alias` VARCHAR(600) not null DEFAULT '';
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `ttransaction` -- Table `ttransaction`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
@ -1235,13 +1239,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned;
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', 28); INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 29);
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_enterprise', '735'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '736');
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');
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
@ -2192,3 +2196,16 @@ CREATE TABLE `tvisual_console_elements_cache` (
ON UPDATE CASCADE ON UPDATE CASCADE
) engine=InnoDB DEFAULT CHARSET=utf8; ) engine=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `tcredential_store`
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tcredential_store` (
`identifier` varchar(100) NOT NULL,
`id_group` mediumint(4) unsigned NOT NULL DEFAULT 0,
`product` enum('CUSTOM', 'AWS', 'AZURE', 'GOOGLE') default 'CUSTOM',
`username` text,
`password` text,
`extra_1` text,
`extra_2` text,
PRIMARY KEY (`identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -35,6 +35,7 @@ ui_require_css_file('firts_task');
</p> </p>
<form action="index.php?sec=gservers&sec2=godmode/servers/discovery" method="post"> <form action="index.php?sec=gservers&sec2=godmode/servers/discovery" method="post">
<input type="submit" class="button_task" value="<?php echo __('Discover'); ?>" /> <input type="submit" class="button_task" value="<?php echo __('Discover'); ?>" />
<input type="hidden" name="discovery_hint" value="1"/>
</form> </form>
</div> </div>
</div> </div>

View File

@ -20,6 +20,8 @@ if (isset($_SERVER['REQUEST_TIME'])) {
$time = get_system_time(); $time = get_system_time();
} }
ui_require_css_file('footer');
$license_file = 'general/license/pandora_info_'.$config['language'].'.html'; $license_file = 'general/license/pandora_info_'.$config['language'].'.html';
if (! file_exists($config['homedir'].$license_file)) { if (! file_exists($config['homedir'].$license_file)) {
$license_file = 'general/license/pandora_info_en.html'; $license_file = 'general/license/pandora_info_en.html';
@ -41,9 +43,17 @@ if ($current_package == 0) {
$build_package_version = $current_package; $build_package_version = $current_package;
} }
echo sprintf(__('%s %s - Build %s - MR %s', get_product_name(), $pandora_version, $build_package_version, $config['MR'])); echo __(
'%s %s - Build %s - MR %s',
get_product_name(),
$pandora_version,
$build_package_version,
$config['MR']
);
echo '</a><br />';
echo '<small><span>'.__('Page generated on %s', date('Y-m-d H:i:s')).'</span></small>';
echo '</a> ';
if (isset($config['debug'])) { if (isset($config['debug'])) {
$cache_info = []; $cache_info = [];

View File

@ -19,8 +19,8 @@ if (isset($config['homedir'])) {
ui_require_css_file('login'); ui_require_css_file('login');
require_once $homedir.'include/functions_ui.php'; require_once __DIR__.'/../include/functions_ui.php';
require_once $homedir.'include/functions.php'; require_once __DIR__.'/../include/functions.php';
require_once __DIR__.'/../include/functions_html.php'; require_once __DIR__.'/../include/functions_html.php';
@ -518,6 +518,7 @@ if ($login_screen == 'error_authconfig' || $login_screen == 'error_emptyconfig'
ui_require_css_file('dialog'); ui_require_css_file('dialog');
ui_require_css_file('jquery-ui.min', 'include/styles/js/'); ui_require_css_file('jquery-ui.min', 'include/styles/js/');
ui_require_jquery_file('jquery-ui.min'); ui_require_jquery_file('jquery-ui.min');
ui_require_jquery_file('jquery-ui_custom');
?> ?>
<?php <?php

View File

@ -103,199 +103,203 @@ if (!empty($all_data)) {
$data['server_sanity'] = format_numeric((100 - $data['module_sanity']), 1); $data['server_sanity'] = format_numeric((100 - $data['module_sanity']), 1);
} }
ui_require_css_file('logon');
?> echo '<div id="welcome_panel">';
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="25%" style="padding-right: 20px;" valign="top">
<?php
//
// Overview Table.
//
$table = new stdClass();
$table->class = 'databox';
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->head = [];
$table->data = [];
$table->headstyle[0] = 'text-align:center;';
$table->width = '100%';
$table->head[0] = '<span>'.__('%s Overview', get_product_name()).'</span>';
$table->head_colspan[0] = 4;
// Indicators. //
$tdata = []; // Overview Table.
$stats = reporting_get_stats_indicators($data, 120, 10, false); //
$status = '<table class="status_tactical">'; $table = new stdClass();
foreach ($stats as $stat) { $table->class = 'no-class';
$status .= '<tr><td><b>'.$stat['title'].'</b></td><td>'.$stat['graph'].'</td></tr>'; $table->cellpadding = 4;
} $table->cellspacing = 4;
$table->head = [];
$table->data = [];
$table->headstyle[0] = 'text-align:center;';
$table->width = '100%';
$table->head_colspan[0] = 4;
$status .= '</table>'; // Indicators.
$table->data[0][0] = $status; $tdata = [];
$table->rowclass[] = ''; $stats = reporting_get_stats_indicators($data, 120, 10, false);
$status = '<table class="status_tactical">';
foreach ($stats as $stat) {
$status .= '<tr><td><b>'.$stat['title'].'</b></td><td>'.$stat['graph'].'</td></tr>';
}
$table->data[] = $tdata; $status .= '</table>';
$table->data[0][0] = $status;
$table->rowclass[] = '';
// Alerts. $table->data[] = $tdata;
$tdata = [];
$tdata[0] = reporting_get_stats_alerts($data);
$table->rowclass[] = '';
$table->data[] = $tdata;
// Modules by status. // Alerts.
$tdata = []; $tdata = [];
$tdata[0] = reporting_get_stats_modules_status($data, 180, 100); $tdata[0] = reporting_get_stats_alerts($data);
$table->rowclass[] = ''; $table->rowclass[] = '';
$table->data[] = $tdata; $table->data[] = $tdata;
// Total agents and modules. // Modules by status.
$tdata = []; $tdata = [];
$tdata[0] = reporting_get_stats_agents_monitors($data); $tdata[0] = reporting_get_stats_modules_status($data, 180, 100);
$table->rowclass[] = ''; $table->rowclass[] = '';
$table->data[] = $tdata; $table->data[] = $tdata;
// Users. // Total agents and modules.
if (users_is_admin()) { $tdata = [];
$tdata = []; $tdata[0] = reporting_get_stats_agents_monitors($data);
$tdata[0] = reporting_get_stats_users($data); $table->rowclass[] = '';
$table->rowclass[] = ''; $table->data[] = $tdata;
$table->data[] = $tdata;
}
html_print_table($table); // Users.
unset($table); if (users_is_admin()) {
?> $tdata = [];
$tdata[0] = reporting_get_stats_users($data);
$table->rowclass[] = '';
</td> $table->data[] = $tdata;
}
<td width="75%" valign="top">
ui_toggle(
html_print_table($table, true),
<?php __('%s Overview', get_product_name()),
$options = []; '',
$options['id_user'] = $config['id_user']; 'overview',
$options['modal'] = false; false
$options['limit'] = 3; );
$news = get_news($options); unset($table);
echo '<div id="right">';
// News.
$options = [];
$options['id_user'] = $config['id_user'];
$options['modal'] = false;
$options['limit'] = 3;
$news = get_news($options);
if (!empty($news)) { if (!empty($news)) {
// NEWS BOARD. ui_require_css_file('news');
echo '<div id="news_board">'; // NEWS BOARD.
if ($config['prominent_time'] == 'timestamp') {
$comparation_suffix = '';
} else {
$comparation_suffix = __('ago');
}
echo '<table cellpadding="0" width=100% cellspacing="0" class="databox filters">'; $output_news = '<div id="news_board" class="new">';
echo '<tr><th style="text-align:center;"><span >'.__('News board').'</span></th></tr>'; foreach ($news as $article) {
if ($config['prominent_time'] == 'timestamp') { $image = false;
$comparation_suffix = ''; if ($article['text'] == '&amp;lt;p&#x20;style=&quot;text-align:&#x20;center;&#x20;font-size:&#x20;13px;&quot;&amp;gt;Hello,&#x20;congratulations,&#x20;if&#x20;you&apos;ve&#x20;arrived&#x20;here&#x20;you&#x20;already&#x20;have&#x20;an&#x20;operational&#x20;monitoring&#x20;console.&#x20;Remember&#x20;that&#x20;our&#x20;forums&#x20;and&#x20;online&#x20;documentation&#x20;are&#x20;available&#x20;24x7&#x20;to&#x20;get&#x20;you&#x20;out&#x20;of&#x20;any&#x20;trouble.&#x20;You&#x20;can&#x20;replace&#x20;this&#x20;message&#x20;with&#x20;a&#x20;personalized&#x20;one&#x20;at&#x20;Admin&#x20;tools&#x20;-&amp;amp;gt;&#x20;Site&#x20;news.&amp;lt;/p&amp;gt;&#x20;') {
} else { $image = true;
$comparation_suffix = __('ago'); }
}
foreach ($news as $article) { $text_bbdd = io_safe_output($article['text']);
$image = false; $text = html_entity_decode($text_bbdd);
if ($article['text'] == '&amp;lt;p&#x20;style=&quot;text-align:&#x20;center;&#x20;font-size:&#x20;13px;&quot;&amp;gt;Hello,&#x20;congratulations,&#x20;if&#x20;you&apos;ve&#x20;arrived&#x20;here&#x20;you&#x20;already&#x20;have&#x20;an&#x20;operational&#x20;monitoring&#x20;console.&#x20;Remember&#x20;that&#x20;our&#x20;forums&#x20;and&#x20;online&#x20;documentation&#x20;are&#x20;available&#x20;24x7&#x20;to&#x20;get&#x20;you&#x20;out&#x20;of&#x20;any&#x20;trouble.&#x20;You&#x20;can&#x20;replace&#x20;this&#x20;message&#x20;with&#x20;a&#x20;personalized&#x20;one&#x20;at&#x20;Admin&#x20;tools&#x20;-&amp;amp;gt;&#x20;Site&#x20;news.&amp;lt;/p&amp;gt;&#x20;') { $output_news .= '<span class="green_title">'.$article['subject'].'</span>';
$image = true; $output_news .= '<div class="new content">';
} $output_news .= '<p>'.__('by').' <b>'.$article['author'].'</b> <i>'.ui_print_timestamp($article['timestamp'], true).'</i> '.$comparation_suffix.'</p>';
if ($image) {
$output_news .= '<center><img src="./images/welcome_image.png" alt="img colabora con nosotros - Support" width="191" height="207"></center>';
}
$text_bbdd = io_safe_output($article['text']); $output_news .= nl2br($text);
$text = html_entity_decode($text_bbdd); $output_news .= '</div>';
echo '<tr><th class="green_title">'.$article['subject'].'</th></tr>'; }
echo '<tr><td>'.__('by').' <b>'.$article['author'].'</b> <i>'.ui_print_timestamp($article['timestamp'], true).'</i> '.$comparation_suffix.'</td></tr>';
echo '<tr><td class="datos">';
if ($image) {
echo '<center><img src="./images/welcome_image.png" alt="img colabora con nosotros - Support" width="191" height="207"></center>';
}
echo nl2br($text); $output_news .= '</div>';
echo '</td></tr>';
}
echo '</table>'; // News board.
echo '</div>'; ui_toggle(
// News board. $output_news,
echo '<br><br>'; __('News board'),
'',
'news',
false
);
// END OF NEWS BOARD.
}
// END OF NEWS BOARD. // LAST ACTIVITY.
} // Show last activity from this user.
$table = new stdClass();
// LAST ACTIVITY. $table->class = 'no-td-padding info_table';
// Show last activity from this user. $table->cellpadding = 0;
echo '<div id="activity">'; $table->cellspacing = 0;
$table->width = '100%';
$table = new stdClass(); // Don't specify px.
$table->class = 'info_table'; $table->data = [];
$table->cellpadding = 0; $table->size = [];
$table->cellspacing = 0; $table->headstyle = [];
$table->width = '100%'; $table->size[0] = '5%';
// Don't specify px. $table->size[1] = '15%';
$table->data = []; $table->headstyle[1] = 'min-width: 12em;';
$table->size = []; $table->size[2] = '5%';
$table->size[0] = '5%'; $table->headstyle[2] = 'min-width: 65px;';
$table->size[1] = '15%'; $table->size[3] = '10%';
$table->size[2] = '15%'; $table->size[4] = '25%';
$table->size[3] = '10%'; $table->head = [];
$table->size[4] = '25%'; $table->head[0] = __('User');
$table->head = []; $table->head[1] = __('Action');
$table->head[0] = __('User'); $table->head[2] = __('Date');
$table->head[1] = __('Action'); $table->head[3] = __('Source IP');
$table->head[2] = __('Date'); $table->head[4] = __('Comments');
$table->head[3] = __('Source IP'); $table->align[4] = 'left';
$table->head[4] = __('Comments'); $sql = sprintf(
$table->title = '<span>'.__('This is your last activity performed on the %s console', get_product_name()).'</span>'; 'SELECT id_usuario,accion, ip_origen,descripcion,utimestamp
$sql = sprintf( FROM tsesion
'SELECT id_usuario,accion, ip_origen,descripcion,utimestamp WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - '.SECONDS_1WEEK.")
FROM tsesion AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 10",
WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - '.SECONDS_1WEEK.") $config['id_user']
AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 10", );
$config['id_user']
);
$sessions = db_get_all_rows_sql($sql); $sessions = db_get_all_rows_sql($sql);
if ($sessions === false) { if ($sessions === false) {
$sessions = []; $sessions = [];
} }
foreach ($sessions as $session) { foreach ($sessions as $session) {
$data = []; $data = [];
$session_id_usuario = $session['id_usuario']; $session_id_usuario = $session['id_usuario'];
$session_ip_origen = $session['ip_origen']; $session_ip_origen = $session['ip_origen'];
$data[0] = '<strong>'.$session_id_usuario.'</strong>';
$data[1] = ui_print_session_action_icon($session['accion'], true).' '.$session['accion'];
$data[2] = ui_print_help_tip(
date($config['date_format'], $session['utimestamp']),
true
).human_time_comparation($session['utimestamp'], 'tiny');
$data[3] = $session_ip_origen;
$description = str_replace([',', ', '], ', ', $session['descripcion']);
if (strlen($description) > 100) {
$data[4] = '<div >'.io_safe_output(substr($description, 0, 150).'...').'</div>';
} else {
$data[4] = '<div >'.io_safe_output($description).'</div>';
}
$data[0] = '<strong>'.$session_id_usuario.'</strong>'; array_push($table->data, $data);
$data[1] = ui_print_session_action_icon($session['accion'], true).' '.$session['accion']; }
$data[2] = ui_print_help_tip(
date($config['date_format'], $session['utimestamp']),
true
).human_time_comparation($session['utimestamp'], 'tiny');
$data[3] = $session_ip_origen;
$description = str_replace([',', ', '], ', ', $session['descripcion']);
if (strlen($description) > 100) {
$data[4] = '<div >'.io_safe_output(substr($description, 0, 150).'...').'</div>';
} else {
$data[4] = '<div >'.io_safe_output($description).'</div>';
}
array_push($table->data, $data); $activity .= html_print_table($table, true);
} unset($table);
echo "<div style='width:100%; overflow-x:auto;'>"; ui_toggle(
html_print_table($table); $activity,
unset($table); __('Latest activity'),
echo '</div>'; '',
echo '</div>'; 'activity',
// END OF LAST ACTIVIYY. false,
?> false,
'',
'white-box-content padded'
</td> );
// END OF LAST ACTIVIYY.
</tr> // Close right panel.
</table> echo '</div>';
// Close welcome panel.
echo '</div>';

View File

@ -30,12 +30,6 @@ $(document).ready(function(){
} }
}); });
// Set the height of the menu.
$(window).on('load', function (){
$("#menu_full").height($("#container").height());
});
</script> </script>
<?php <?php
$autohidden_menu = 0; $autohidden_menu = 0;

View File

@ -94,7 +94,7 @@ $table->data[1] = $data;
$form = '<form name="query_sel" method="post" action="index.php?sec=glog&sec2=godmode/admin_access_logs">'; $form = '<form name="query_sel" method="post" action="index.php?sec=glog&sec2=godmode/admin_access_logs">';
$form .= html_print_table($table, true); $form .= html_print_table($table, true);
$form .= '</form>'; $form .= '</form>';
ui_toggle($form, __('Filter'), '', false); ui_toggle($form, __('Filter'), '', '', false);
$filter = '1=1'; $filter = '1=1';

View File

@ -176,7 +176,7 @@ if ($disk_conf_delete) {
@unlink($filename['conf']); @unlink($filename['conf']);
} }
echo '<form name="conf_agent" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">'; echo '<form autocomplete="new-password" name="conf_agent" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">';
// Custom ID. // Custom ID.
$custom_id_div = '<div class="label_select">'; $custom_id_div = '<div class="label_select">';
@ -245,7 +245,7 @@ if (!$new_agent && $alias != '') {
$table_agent_name .= '</div></div></div>'; $table_agent_name .= '</div></div></div>';
// QR code div. // QR code div.
$table_qr_code = '<div class="agent_qr white_box">'; $table_qr_code = '<div class="box-shadow agent_qr white_box">';
$table_qr_code .= '<p class="input_label">'.__('QR Code Agent view').': </p>'; $table_qr_code .= '<p class="input_label">'.__('QR Code Agent view').': </p>';
$table_qr_code .= '<div id="qr_container_image"></div>'; $table_qr_code .= '<div id="qr_container_image"></div>';
if ($id_agente) { if ($id_agente) {
@ -401,7 +401,7 @@ $table_description .= html_print_textarea(
// QR code. // QR code.
echo '<div class="first_row"> echo '<div class="first_row">
<div class="agent_options '.$agent_options_update.' white_box"> <div class="box-shadow agent_options '.$agent_options_update.' white_box">
<div class="agent_options_column_left">'.$table_agent_name.$table_alias.$table_ip.$table_primary_group.'</div> <div class="agent_options_column_left">'.$table_agent_name.$table_alias.$table_ip.$table_primary_group.'</div>
<div class="agent_options_column_right">'.$table_interval.$table_os.$table_server.$table_description.'</div> <div class="agent_options_column_right">'.$table_interval.$table_os.$table_server.$table_description.'</div>
</div>'; </div>';
@ -413,8 +413,8 @@ echo '</div>';
if (enterprise_installed()) { if (enterprise_installed()) {
$secondary_groups_selected = enterprise_hook('agents_get_secondary_groups', [$id_agente]); $secondary_groups_selected = enterprise_hook('agents_get_secondary_groups', [$id_agente]);
$table_adv_secondary_groups = '<div class="label_select"><p class="input_label">'.__('Secondary groups').': </p></div>'; $adv_secondary_groups_label = '<div class="label_select"><p class="input_label">'.__('Secondary groups').': </p></div>';
$table_adv_secondary_groups_left = html_print_select_groups( $adv_secondary_groups_left = html_print_select_groups(
false, false,
// Use the current user to select the groups. // Use the current user to select the groups.
'AR', 'AR',
@ -441,7 +441,7 @@ if (enterprise_installed()) {
// CSS classnames (default). // CSS classnames (default).
false, false,
// Not disabled (default). // Not disabled (default).
'width:50%; min-width:170px;', 'min-width:170px;',
// Inline styles (default). // Inline styles (default).
false, false,
// Option style select (default). // Option style select (default).
@ -455,7 +455,7 @@ if (enterprise_installed()) {
// Do not show the primary group in this selection. // Do not show the primary group in this selection.
); );
$table_adv_secondary_groups_arrows = html_print_input_image( $adv_secondary_groups_arrows = html_print_input_image(
'add_secondary', 'add_secondary',
'images/darrowright_green.png', 'images/darrowright_green.png',
1, 1,
@ -479,7 +479,7 @@ if (enterprise_installed()) {
] ]
); );
$table_adv_secondary_groups_right .= html_print_select( $adv_secondary_groups_right .= html_print_select(
$secondary_groups_selected['for_select'], $secondary_groups_selected['for_select'],
// Values. // Values.
'secondary_groups_selected', 'secondary_groups_selected',
@ -502,7 +502,7 @@ if (enterprise_installed()) {
// Class. // Class.
false, false,
// Disabled. // Disabled.
'width:50%; min-width:170px;' 'min-width:170px;'
// Style. // Style.
); );
@ -579,7 +579,7 @@ if (enterprise_installed()) {
} }
$table_adv_parent = '<div class="label_select"><p class="input_label">'.__('Parent').': </p>'; $table_adv_parent = '<div class="label_select"><label class="input_label">'.__('Parent').': </label>';
$params = []; $params = [];
$params['return'] = true; $params['return'] = true;
$params['show_helptip'] = true; $params['show_helptip'] = true;
@ -648,13 +648,15 @@ $table_adv_module_mode .= html_print_radio_button_extended(
$table_adv_module_mode .= '</div></div>'; $table_adv_module_mode .= '</div></div>';
// Status (Disabled / Enabled). // Status (Disabled / Enabled).
$table_adv_status = '<div class="label_select_simple label_simple_one_item"><p class="input_label input_label_simple">'.__('Disabled').': '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).'</p>'; $table_adv_status = '<div class="label_select_simple label_simple_one_item">';
$table_adv_status .= html_print_checkbox_switch( $table_adv_status .= html_print_checkbox_switch(
'disabled', 'disabled',
1, 1,
$disabled, $disabled,
true true
).'</div>'; );
$table_adv_status .= '<p class="input_label input_label_simple">'.__('Disabled').': '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).'</p>';
$table_adv_status .= '</div>';
// Url address. // Url address.
if (enterprise_installed()) { if (enterprise_installed()) {
@ -665,7 +667,14 @@ if (enterprise_installed()) {
'', '',
45, 45,
255, 255,
true true,
false,
false,
'',
'',
'',
// Autocomplete.
'new-password'
).'</div>'; ).'</div>';
} else { } else {
$table_adv_url = '<div class="label_select"><p class="input_label">'.__('Url address').': </p></div>'; $table_adv_url = '<div class="label_select"><p class="input_label">'.__('Url address').': </p></div>';
@ -679,9 +688,11 @@ if (enterprise_installed()) {
).'</div>'; ).'</div>';
} }
$table_adv_quiet = '<div class="label_select_simple label_simple_one_item"><p class="input_label input_label_simple">'.__('Quiet').': '; $table_adv_quiet = '<div class="label_select_simple label_simple_one_item">';
$table_adv_quiet .= html_print_checkbox_switch('quiet', 1, $quiet, true);
$table_adv_quiet .= '<p class="input_label input_label_simple">'.__('Quiet').': ';
$table_adv_quiet .= ui_print_help_tip(__('The agent still runs but the alerts and events will be stop'), true).'</p>'; $table_adv_quiet .= ui_print_help_tip(__('The agent still runs but the alerts and events will be stop'), true).'</p>';
$table_adv_quiet .= html_print_checkbox_switch('quiet', 1, $quiet, true).'</div>'; $table_adv_quiet .= '</div>';
$listIcons = gis_get_array_list_icons(); $listIcons = gis_get_array_list_icons();
@ -753,31 +764,46 @@ if ($config['activate_gis']) {
// General display distribution. // General display distribution.
$table_adv_options = $table_adv_secondary_groups.'<div class="secondary_groups_select" style="margin-bottom:30px;"> $table_adv_options = '
<div class="secondary_groups_list_left"> <div class="secondary_groups_list">
'.$table_adv_secondary_groups_left.' '.$adv_secondary_groups_label.'
<div class="sg_source">
'.$adv_secondary_groups_left.'
</div>
<div class="secondary_group_arrows">
'.$adv_secondary_groups_arrows.'
</div>
<div class="sg_target">
'.$adv_secondary_groups_right.'
</div>
</div> </div>
<div class="secondary_groups_select_arrows"> <div class="agent_av_opt_right" >
'.$table_adv_secondary_groups_arrows.' '.$table_adv_parent.$table_adv_module_mode.$table_adv_cascade;
</div>
<div class="secondary_groups_list_right">
'.$table_adv_secondary_groups_right.'
</div>
</div>
<div class="agent_options agent_options_adv">
<div class="agent_options_column_left" >'.$table_adv_parent.$table_adv_module_mode.$table_adv_cascade;
if ($new_agent) { if ($new_agent) {
// If agent is new, show custom id as old style format. // If agent is new, show custom id as old style format.
$table_adv_options .= $custom_id_div; $table_adv_options .= $custom_id_div;
} }
$table_adv_options .= $table_adv_gis.'</div> $table_adv_options .= '</div>';
<div class="agent_options_column_right" >'.$table_adv_agent_icon.$table_adv_url.$table_adv_quiet.$table_adv_status.$table_adv_remote.$table_adv_safe.'</div>
</div>'; $table_adv_options .= '
<div class="agent_av_opt_left" >
'.$table_adv_gis.$table_adv_agent_icon.$table_adv_url.$table_adv_quiet.$table_adv_status.$table_adv_remote.$table_adv_safe.'
</div>';
echo '<div class="ui_toggle">'; echo '<div class="ui_toggle">';
ui_toggle($table_adv_options, __('Advanced options'), '', true, false, 'white_box white_box_opened'); ui_toggle(
$table_adv_options,
__('Advanced options'),
'',
'',
true,
false,
'white_box white_box_opened',
'no-border flex'
);
echo '</div>'; echo '</div>';
@ -831,7 +857,7 @@ foreach ($fields as $field) {
$custom_value = ''; $custom_value = '';
} }
$table->rowstyle[$i] = 'cursor: pointer;'; $table->rowstyle[$i] = 'cursor: pointer;user-select: none;';
if (!empty($custom_value)) { if (!empty($custom_value)) {
$table->rowstyle[($i + 1)] = 'display: table-row;'; $table->rowstyle[($i + 1)] = 'display: table-row;';
} else { } else {
@ -895,14 +921,16 @@ foreach ($fields as $field) {
if (!empty($fields)) { if (!empty($fields)) {
echo '<div class="ui_toggle">'; echo '<div class="ui_toggle">';
ui_toggle( ui_toggle(
html_print_table($table, true), html_print_table($table, true),
__('Custom fields'), __('Custom fields'),
'', '',
true, '',
false, true,
'white_box white_box_opened' false,
); 'white_box white_box_opened',
'no-border'
);
echo '</div>'; echo '</div>';
} }

View File

@ -322,7 +322,7 @@ if ($create_modules) {
} else if (preg_match('/ifAdminStatus/', $name_array[1])) { } else if (preg_match('/ifAdminStatus/', $name_array[1])) {
$module_type = 2; $module_type = 2;
} else if (preg_match('/ifOperStatus/', $name_array[1])) { } else if (preg_match('/ifOperStatus/', $name_array[1])) {
$module_type = 18; $module_type = 2;
} else { } else {
$module_type = 4; $module_type = 4;
} }
@ -608,11 +608,11 @@ ui_require_jquery_file('bgiframe');
$(document).ready (function () { $(document).ready (function () {
var inputActive = true; var inputActive = true;
$(document).data('text_for_module', $("#none_text").html()); $(document).data('text_for_module', $("#none_text").html());
$("#id_snmp").change(snmp_changed_by_multiple_snmp); $("#id_snmp").change(snmp_changed_by_multiple_snmp);
$("#snmp_version").change(function () { $("#snmp_version").change(function () {
if (this.value == "3") { if (this.value == "3") {
$("#snmp3_options").css("display", ""); $("#snmp3_options").css("display", "");
@ -621,7 +621,7 @@ $(document).ready (function () {
$("#snmp3_options").css("display", "none"); $("#snmp3_options").css("display", "none");
} }
}); });
$("#walk_form").submit(function() { $("#walk_form").submit(function() {
$("#submit-snmp_walk").disable (); $("#submit-snmp_walk").disable ();
$("#oid_loading").show (); $("#oid_loading").show ();
@ -632,15 +632,15 @@ $(document).ready (function () {
function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
var idSNMP = Array(); var idSNMP = Array();
jQuery.each ($("#id_snmp option:selected"), function (i, val) { jQuery.each ($("#id_snmp option:selected"), function (i, val) {
idSNMP.push($(val).val()); idSNMP.push($(val).val());
}); });
$('#module').attr ('disabled', 1); $('#module').attr ('disabled', 1);
$('#module').empty (); $('#module').empty ();
$('#module').append ($('<option></option>').html ("Loading...").attr ("value", 0)); $('#module').append ($('<option></option>').html ("Loading...").attr ("value", 0));
jQuery.post ('ajax.php', jQuery.post ('ajax.php',
{"page" : "godmode/agentes/agent_manager", {"page" : "godmode/agentes/agent_manager",
"get_modules_json_for_multiple_snmp": 1, "get_modules_json_for_multiple_snmp": 1,
"id_snmp[]": idSNMP, "id_snmp[]": idSNMP,
@ -655,7 +655,7 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
$('#module').fadeIn ('normal'); $('#module').fadeIn ('normal');
c++; c++;
}); });
if (c == 0) { if (c == 0) {
if (typeof($(document).data('text_for_module')) != 'undefined') { if (typeof($(document).data('text_for_module')) != 'undefined') {
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true)); $('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true));
@ -666,11 +666,11 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
} }
else { else {
var anyText = $("#any_text").html(); //Trick for catch the translate text. var anyText = $("#any_text").html(); //Trick for catch the translate text.
if (anyText == null) { if (anyText == null) {
anyText = 'Any'; anyText = 'Any';
} }
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).prop('selected', true)); $('#module').append ($('<option></option>').html (anyText).attr ("value", 0).prop('selected', true));
} }
} }
@ -684,4 +684,3 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
/* ]]> */ /* ]]> */
</script> </script>

View File

@ -1213,7 +1213,7 @@ if ($update_module || $create_module) {
$max_timeout = (int) get_parameter('max_timeout'); $max_timeout = (int) get_parameter('max_timeout');
$max_retries = (int) get_parameter('max_retries'); $max_retries = (int) get_parameter('max_retries');
$min = (int) get_parameter_post('min'); $min = (int) get_parameter('min');
$max = (int) get_parameter('max'); $max = (int) get_parameter('max');
$interval = (int) get_parameter('module_interval', $intervalo); $interval = (int) get_parameter('module_interval', $intervalo);
$ff_interval = (int) get_parameter('module_ff_interval'); $ff_interval = (int) get_parameter('module_ff_interval');

View File

@ -163,7 +163,7 @@ echo '<td>';
echo __('Group').'&nbsp;'; echo __('Group').'&nbsp;';
$own_info = get_user_info($config['id_user']); $own_info = get_user_info($config['id_user']);
if (!$own_info['is_admin'] && !check_acl($config['id_user'], 0, 'AW')) { if (!$own_info['is_admin'] && check_acl($config['id_user'], 0, 'AW')) {
$return_all_group = false; $return_all_group = false;
} else { } else {
$return_all_group = true; $return_all_group = true;

View File

@ -267,10 +267,10 @@ if ($id_agent_module) {
$cron_interval = explode(' ', $module['cron_interval']); $cron_interval = explode(' ', $module['cron_interval']);
if (isset($cron_interval[4])) { if (isset($cron_interval[4])) {
$minute_from = $cron_interval[0]; $minute_from = $cron_interval[0];
$min = explode('-', $minute_from); $minute = explode('-', $minute_from);
$minute_from = $min[0]; $minute_from = $minute[0];
if (isset($min[1])) { if (isset($minute[1])) {
$minute_to = $min[1]; $minute_to = $minute[1];
} }
$hour_from = $cron_interval[1]; $hour_from = $cron_interval[1];
@ -583,7 +583,13 @@ echo '<h3 id="message" class="error invisible"></h3>';
// TODO: Change to the ui_print_error system // TODO: Change to the ui_print_error system
echo '<form method="post" id="module_form">'; echo '<form method="post" id="module_form">';
html_print_table($table_simple); ui_toggle(
html_print_table($table_simple, true),
__('Base options'),
'',
'',
false
);
ui_toggle( ui_toggle(
html_print_table($table_advanced, true), html_print_table($table_advanced, true),

View File

@ -162,7 +162,7 @@ $edit_module = (bool) get_parameter_get('edit_module');
$table_simple = new stdClass(); $table_simple = new stdClass();
$table_simple->id = 'simple'; $table_simple->id = 'simple';
$table_simple->width = '100%'; $table_simple->width = '100%';
$table_simple->class = 'databox'; $table_simple->class = 'no-class';
$table_simple->data = []; $table_simple->data = [];
$table_simple->style = []; $table_simple->style = [];
$table_simple->style[0] = 'font-weight: bold; width: 25%;'; $table_simple->style[0] = 'font-weight: bold; width: 25%;';
@ -637,7 +637,7 @@ if ($disabledBecauseInPolicy) {
$table_advanced = new stdClass(); $table_advanced = new stdClass();
$table_advanced->id = 'advanced'; $table_advanced->id = 'advanced';
$table_advanced->width = '100%'; $table_advanced->width = '100%';
$table_advanced->class = 'databox filters'; $table_advanced->class = 'no-class';
$table_advanced->data = []; $table_advanced->data = [];
$table_advanced->style = []; $table_advanced->style = [];
$table_advanced->style[0] = $table_advanced->style[3] = $table_advanced->style[5] = 'font-weight: bold;'; $table_advanced->style[0] = $table_advanced->style[3] = $table_advanced->style[5] = 'font-weight: bold;';
@ -1066,7 +1066,7 @@ if (check_acl($config['id_user'], 0, 'PM')) {
$table_macros = new stdClass(); $table_macros = new stdClass();
$table_macros->id = 'module_macros'; $table_macros->id = 'module_macros';
$table_macros->width = '100%'; $table_macros->width = '100%';
$table_macros->class = 'databox filters'; $table_macros->class = 'no-class';
$table_macros->data = []; $table_macros->data = [];
$table_macros->style = []; $table_macros->style = [];
$table_macros->style[0] = 'font-weight: bold;'; $table_macros->style[0] = 'font-weight: bold;';
@ -1107,7 +1107,7 @@ html_print_input_hidden('module_macro_count', $macro_count);
$table_new_relations = new stdClass(); $table_new_relations = new stdClass();
$table_new_relations->id = 'module_new_relations'; $table_new_relations->id = 'module_new_relations';
$table_new_relations->width = '100%'; $table_new_relations->width = '100%';
$table_new_relations->class = 'databox filters'; $table_new_relations->class = 'no-class';
$table_new_relations->data = []; $table_new_relations->data = [];
$table_new_relations->style = []; $table_new_relations->style = [];
$table_new_relations->style[0] = 'width: 10%; font-weight: bold;'; $table_new_relations->style[0] = 'width: 10%; font-weight: bold;';

View File

@ -37,14 +37,10 @@ $table->head = [];
$table->data = []; $table->data = [];
$table->size = []; $table->size = [];
$table->size = []; $table->size = [];
$table->size[0] = '5%'; $table->style[0] = 'font-weight: bold;';
$table->size[1] = '25%'; $table->style[1] = 'font-weight: bold;display: flex;align-items: baseline;';
$table->size[2] = '5%'; $table->style[2] = 'font-weight: bold;';
$table->size[3] = '20%'; $table->style[3] = 'font-weight: bold;';
$table->style[0] = 'font-weight: bold; ';
$table->style[1] = 'font-weight: bold; ';
$table->style[2] = 'font-weight: bold; ';
$table->style[3] = 'font-weight: bold; ';
// This is because if this view is reused after list alert view then // This is because if this view is reused after list alert view then
// styles in the previous view can affect this table. // styles in the previous view can affect this table.
@ -89,7 +85,7 @@ $table->data[0][1] = html_print_select(
true, true,
'', '',
($id_agente == 0), ($id_agente == 0),
'width: 250px;' 'min-width: 250px;margin-right: 0.5em;'
); );
$table->data[0][1] .= ' <span id="latest_value" class="invisible">'.__('Latest value').': '; $table->data[0][1] .= ' <span id="latest_value" class="invisible">'.__('Latest value').': ';
$table->data[0][1] .= '<span id="value">&nbsp;</span></span>'; $table->data[0][1] .= '<span id="value">&nbsp;</span></span>';
@ -117,7 +113,7 @@ $table->data[1][1] = html_print_select(
true, true,
'', '',
false, false,
'width: 250px;' 'min-width: 250px;'
); );
$table->data[1][1] .= '<span id="advanced_action" class="advanced_actions invisible"><br>'; $table->data[1][1] .= '<span id="advanced_action" class="advanced_actions invisible"><br>';
$table->data[1][1] .= __('Number of alerts match from').' '; $table->data[1][1] .= __('Number of alerts match from').' ';
@ -127,9 +123,9 @@ $table->data[1][1] .= html_print_input_text('fires_max', '', '', 4, 10, true);
$table->data[1][1] .= '</span>'; $table->data[1][1] .= '</span>';
if (check_acl($config['id_user'], 0, 'LM')) { if (check_acl($config['id_user'], 0, 'LM')) {
$table->data[1][1] .= '<a style="margin-left:5px;" href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_action&pure='.$pure.'">'; $table->data[1][1] .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_action&pure='.$pure.'">';
$table->data[1][1] .= html_print_image('images/add.png', true); $table->data[1][1] .= html_print_image('images/add.png', true);
$table->data[1][1] .= '<span style="margin-left:5px;vertical-align:middle;">'.__('Create Action').'</span>'; $table->data[1][1] .= '<span style="margin-left:0.5em;">'.__('Create Action').'</span>';
$table->data[1][1] .= '</a>'; $table->data[1][1] .= '</a>';
} }
@ -162,13 +158,13 @@ if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
if (check_acl($config['id_user'], 0, 'LM')) { if (check_acl($config['id_user'], 0, 'LM')) {
$table->data[2][1] .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'">'; $table->data[2][1] .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'">';
$table->data[2][1] .= html_print_image('images/add.png', true); $table->data[2][1] .= html_print_image('images/add.png', true);
$table->data[2][1] .= '<span style="margin-left:5px;vertical-align:middle;">'.__('Create Template').'</span>'; $table->data[2][1] .= '<span style="margin-left:0.5em;">'.__('Create Template').'</span>';
$table->data[2][1] .= '</a>'; $table->data[2][1] .= '</a>';
} }
$table->data[3][0] = __('Threshold'); $table->data[3][0] = __('Threshold');
$table->data[3][1] = html_print_input_text('module_action_threshold', '0', '', 5, 7, true); $table->data[3][1] = html_print_input_text('module_action_threshold', '0', '', 5, 7, true);
$table->data[3][1] .= ' '.__('seconds'); $table->data[3][1] .= '<span style="margin-left:0.5em;">'.__('seconds').'</span>';
if (!isset($step)) { if (!isset($step)) {
echo '<form class="add_alert_form" method="post">'; echo '<form class="add_alert_form" method="post">';

View File

@ -438,11 +438,11 @@ if (! $id_agente) {
$table->style = []; $table->style = [];
$table->style[0] = 'font-weight: bold;'; $table->style[0] = 'font-weight: bold;';
$table->head[0] = __('Agent').ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectAgentUp, $selectAgentDown); $table->head[0] = __('Agent').ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectAgentUp, $selectAgentDown);
$table->size[0] = '4%'; $table->headstyle[0] = 'width: 100%; min-width: 12em;';
$table->size[1] = '8%'; $table->headstyle[1] = 'min-width: 15em;';
$table->size[2] = '8%'; $table->headstyle[2] = 'min-width: 20em;';
$table->size[3] = '4%'; $table->headstyle[3] = 'min-width: 1em;';
$table->size[4] = '4%'; $table->headstyle[4] = 'min-width: 15em;';
/* /*
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
@ -450,16 +450,11 @@ if (! $id_agente) {
}*/ }*/
} else { } else {
$table->head[0] = __('Module').ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown); $table->head[0] = __('Module').ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown);
// Different sizes or the layout screws up $table->headstyle[0] = 'width: 100%; min-width: 15em;';
$table->size[0] = '0%'; $table->headstyle[1] = 'min-width: 15em;';
$table->size[1] = '10%'; $table->headstyle[2] = 'min-width: 20em;';
$table->size[2] = '30%'; $table->headstyle[3] = 'min-width: 1em;';
/* $table->headstyle[4] = 'min-width: 15em;';
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
$table->size[4] = '25%';
} */
$table->size[3] = '1%';
$table->size[4] = '1%';
} }
$table->head[1] = __('Template').ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown); $table->head[1] = __('Template').ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown);

View File

@ -317,9 +317,9 @@ $(document).ready (function () {
jQuery.post (<?php echo "'".ui_get_full_url('ajax.php', false, false, false)."'"; ?>, jQuery.post (<?php echo "'".ui_get_full_url('ajax.php', false, false, false)."'"; ?>,
values, values,
function (data, status) { function (data, status) {
original_command = js_html_entity_decode (data["command"]); original_command = data["command"];
render_command_preview (original_command); render_command_preview (original_command);
command_description = js_html_entity_decode (data["description"]); command_description = data["description"];
render_command_description(command_description); render_command_description(command_description);
var max_fields = parseInt('<?php echo $config['max_macro_fields']; ?>'); var max_fields = parseInt('<?php echo $config['max_macro_fields']; ?>');

View File

@ -60,96 +60,12 @@ $fields_selected = explode(',', $config['event_fields']);
$result_selected = []; $result_selected = [];
// show list of fields selected. // Show list of fields selected.
if ($fields_selected[0] != '') { if ($fields_selected[0] != '') {
foreach ($fields_selected as $field_selected) { foreach ($fields_selected as $field_selected) {
switch ($field_selected) { $result_selected[$field_selected] = events_get_column_name(
case 'id_evento': $field_selected
$result = __('Event Id'); );
break;
case 'evento':
$result = __('Event Name');
break;
case 'id_agente':
$result = __('Agent Name');
break;
case 'id_usuario':
$result = __('User');
break;
case 'id_grupo':
$result = __('Group');
break;
case 'estado':
$result = __('Status');
break;
case 'timestamp':
$result = __('Timestamp');
break;
case 'event_type':
$result = __('Event Type');
break;
case 'id_agentmodule':
$result = __('Module Name');
break;
case 'id_alert_am':
$result = __('Alert');
break;
case 'criticity':
$result = __('Severity');
break;
case 'user_comment':
$result = __('Comment');
break;
case 'tags':
$result = __('Tags');
break;
case 'source':
$result = __('Source');
break;
case 'id_extra':
$result = __('Extra Id');
break;
case 'owner_user':
$result = __('Owner');
break;
case 'ack_utimestamp':
$result = __('ACK Timestamp');
break;
case 'instructions':
$result = __('Instructions');
break;
case 'server_name':
$result = __('Server Name');
break;
case 'data':
$result = __('Data');
break;
case 'module_status':
$result = __('Module Status');
break;
}
$result_selected[$field_selected] = $result;
} }
} }
@ -177,7 +93,8 @@ $fields_available = [];
$fields_available['id_evento'] = __('Event Id'); $fields_available['id_evento'] = __('Event Id');
$fields_available['evento'] = __('Event Name'); $fields_available['evento'] = __('Event Name');
$fields_available['id_agente'] = __('Agent Name'); $fields_available['id_agente'] = __('Agent ID');
$fields_available['agent_name'] = __('Agent Name');
$fields_available['id_usuario'] = __('User'); $fields_available['id_usuario'] = __('User');
$fields_available['id_grupo'] = __('Group'); $fields_available['id_grupo'] = __('Group');
$fields_available['estado'] = __('Status'); $fields_available['estado'] = __('Status');
@ -196,13 +113,13 @@ $fields_available['instructions'] = __('Instructions');
$fields_available['server_name'] = __('Server Name'); $fields_available['server_name'] = __('Server Name');
$fields_available['data'] = __('Data'); $fields_available['data'] = __('Data');
$fields_available['module_status'] = __('Module Status'); $fields_available['module_status'] = __('Module Status');
$fields_available['mini_severity'] = __('Severity mini');
// remove fields already selected
// Remove fields already selected.
foreach ($fields_available as $key => $available) { foreach ($fields_available as $key => $available) {
foreach ($result_selected as $selected) { if (isset($result_selected[$key])) {
if ($selected == $available) { unset($fields_available[$key]);
unset($fields_available[$key]);
}
} }
} }

View File

@ -50,17 +50,10 @@ if (check_acl($config['id_user'], 0, 'PM')) {
'text' => '<a href="index.php?sec=eventos&sec2=godmode/events/events&amp;section=responses&amp;pure='.$config['pure'].'">'.html_print_image('images/event_responses.png', true, ['title' => __('Event responses')]).'</a>', 'text' => '<a href="index.php?sec=eventos&sec2=godmode/events/events&amp;section=responses&amp;pure='.$config['pure'].'">'.html_print_image('images/event_responses.png', true, ['title' => __('Event responses')]).'</a>',
]; ];
if (!is_metaconsole()) { $buttons['fields'] = [
$buttons['fields'] = [ 'active' => false,
'active' => false, 'text' => '<a href="index.php?sec=eventos&sec2=godmode/events/events&amp;section=fields&amp;pure='.$config['pure'].'">'.html_print_image('images/custom_columns.png', true, ['title' => __('Custom fields')]).'</a>',
'text' => '<a href="index.php?sec=eventos&sec2=godmode/events/events&amp;section=fields&amp;pure='.$config['pure'].'">'.html_print_image('images/custom_columns.png', true, ['title' => __('Custom fields')]).'</a>', ];
];
} else {
$buttons['fields'] = [
'active' => false,
'text' => '<a href="index.php?sec=eventos&sec2=event/custom_events&amp;section=fields&amp;pure='.$config['pure'].'">'.html_print_image('images/custom_columns.png', true, ['title' => __('Custom fields')]).'</a>',
];
}
} }
switch ($section) { switch ($section) {

View File

@ -0,0 +1,632 @@
<?php
/**
* Credentials management view.
*
* @category Credentials management
* @package Pandora FMS
* @subpackage Opensource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
global $config;
// Check access.
check_login();
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access event viewer'
);
if (is_ajax()) {
return ['error' => 'noaccess'];
}
include 'general/noaccess.php';
return;
}
// Required files.
ui_require_css_file('credential_store');
require_once $config['homedir'].'/include/functions_credential_store.php';
require_once $config['homedir'].'/include/functions_io.php';
if (is_ajax()) {
$draw = get_parameter('draw', 0);
$filter = get_parameter('filter', []);
$get_key = get_parameter('get_key', 0);
$new_form = get_parameter('new_form', 0);
$new_key = get_parameter('new_key', 0);
$update_key = get_parameter('update_key', 0);
$delete_key = get_parameter('delete_key', 0);
if ($new_form) {
echo print_inputs();
exit;
}
if ($delete_key) {
$identifier = get_parameter('identifier', null);
if (empty($identifier)) {
ajax_msg('error', __('identifier cannot be empty'));
}
if (db_process_sql_delete(
'tcredential_store',
['identifier' => $identifier]
) === false
) {
ajax_msg('error', $config['dbconnection']->error, true);
} else {
ajax_msg('result', $identifier, true);
}
}
if ($update_key) {
$data = get_parameter('values', null);
if ($data === null || !is_array($data)) {
echo json_encode(['error' => __('Invalid parameters, please retry')]);
exit;
}
$values = [];
foreach ($data as $key => $value) {
if ($key == 'identifier') {
$identifier = base64_decode($value);
} else if ($key == 'product') {
$product = base64_decode($value);
} else {
$values[$key] = base64_decode($value);
}
}
if (empty($identifier)) {
ajax_msg('error', __('identifier cannot be empty'));
}
if (empty($product)) {
ajax_msg('error', __('product cannot be empty'));
}
if (db_process_sql_update(
'tcredential_store',
$values,
['identifier' => $identifier]
) === false
) {
ajax_msg('error', $config['dbconnection']->error);
} else {
ajax_msg('result', $identifier);
}
exit;
}
if ($new_key) {
$data = get_parameter('values', null);
if ($data === null || !is_array($data)) {
echo json_encode(['error' => __('Invalid parameters, please retry')]);
exit;
}
$values = [];
foreach ($data as $key => $value) {
$values[$key] = base64_decode($value);
if ($key == 'identifier') {
$values[$key] = preg_replace('/\s+/', '-', trim($values[$key]));
}
}
$identifier = $values['identifier'];
if (empty($identifier)) {
ajax_msg('error', __('identifier cannot be empty'));
}
if (empty($values['product'])) {
ajax_msg('error', __('product cannot be empty'));
}
if (db_process_sql_insert('tcredential_store', $values) === false) {
ajax_msg('error', $config['dbconnection']->error);
} else {
ajax_msg('result', $identifier);
}
exit;
}
if ($get_key) {
$identifier = get_parameter('identifier', null);
$key = get_key($identifier);
echo print_inputs($key);
exit;
}
if ($draw) {
// Datatables offset, limit and order.
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
$order = get_datatable_order(true);
try {
ob_start();
$fields = [
'cs.*',
'tg.nombre as `group`',
];
// Retrieve data.
$data = credentials_get_all(
// Fields.
$fields,
// Filter.
$filter,
// Offset.
$start,
// Limit.
$length,
// Order.
$order['direction'],
// Sort field.
$order['field']
);
// Retrieve counter.
$count = credentials_get_all(
'count',
$filter
);
if ($data) {
$data = array_reduce(
$data,
function ($carry, $item) {
// Transforms array of arrays $data into an array
// of objects, making a post-process of certain fields.
$tmp = (object) $item;
$tmp->username = io_safe_output($tmp->username);
if (empty($tmp->group)) {
$tmp->group = __('All');
} else {
$tmp->group = io_safe_output($tmp->group);
}
$carry[] = $tmp;
return $carry;
}
);
}
// Datatables format: RecordsTotal && recordsfiltered.
echo json_encode(
[
'data' => $data,
'recordsTotal' => $count,
'recordsFiltered' => $count,
]
);
// Capture output.
$response = ob_get_clean();
} catch (Exception $e) {
return json_encode(['error' => $e->getMessage()]);
}
// If not valid, show error with issue.
json_decode($response);
if (json_last_error() == JSON_ERROR_NONE) {
// If valid dump.
echo $response;
} else {
echo json_encode(
['error' => $response]
);
}
exit;
}
exit;
}
// Datatables list.
try {
$columns = [
'group',
'identifier',
'product',
'username',
'options',
];
$column_names = [
__('Group'),
__('Identifier'),
__('Product'),
__('User'),
[
'text' => __('Options'),
'class' => 'action_buttons',
],
];
$table_id = 'keystore';
// Load datatables user interface.
ui_print_datatable(
[
'id' => $table_id,
'class' => 'info_table',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => 'godmode/groups/credential_store',
'ajax_postprocess' => 'process_datatables_item(item)',
'no_sortable_columns' => [-1],
'order' => [
'field' => 'identifier',
'direction' => 'asc',
],
'search_button_class' => 'sub filter float-right',
'form' => [
'inputs' => [
[
'label' => __('Group'),
'type' => 'select',
'id' => 'filter_id_group',
'name' => 'filter_id_group',
'options' => users_get_groups_for_select(
$config['id_user'],
'AR',
true,
true,
false
),
],
[
'label' => __('Free search'),
'type' => 'text',
'class' => 'mw250px',
'id' => 'free_search',
'name' => 'free_search',
],
],
],
]
);
} catch (Exception $e) {
echo $e->getMessage();
}
// Auxiliar div.
$new = '<div id="new_key" style="display: none"><form id="form_new">';
$new .= '</form></div>';
$details = '<div id="info_key" style="display: none"><form id="form_update">';
$details .= '</form></div>';
$aux = '<div id="aux" style="display: none"></div>';
echo $new.$details.$aux;
// Create button.
echo '<div class="w100p flex-content-right">';
html_print_submit_button(
__('Add key'),
'create',
false,
'class="sub next"'
);
echo '</div>';
?>
<script type="text/javascript">
function process_datatables_item(item) {
item.options = '<a href="javascript:" onclick="display_key(\'';
item.options += item.identifier;
item.options += '\')" ><?php echo html_print_image('images/eye.png', true, ['title' => __('Show')]); ?></a>';
item.options += '<a href="javascript:" onclick="delete_key(\'';
item.options += item.identifier;
item.options += '\')" ><?php echo html_print_image('images/cross.png', true, ['title' => __('Delete')]); ?></a>';
}
function handle_response(data) {
var title = "<?php echo __('Success'); ?>";
var text = '';
var failed = 0;
try {
data = JSON.parse(data);
text = data['result'];
} catch (err) {
title = "<?php echo __('Failed'); ?>";
text = err.message;
failed = 1;
}
if (!failed && data['error']) {
title = "<?php echo __('Failed'); ?>";
text = data['error'];
failed = 1;
}
$('#aux').empty();
$('#aux').html(text);
$('#aux').dialog({
width: 450,
position: {
my: 'center',
at: 'center',
of: window,
collision: 'fit'
},
title: title,
buttons: [
{
text: 'OK',
click: function(e) {
if (!failed) {
dt_<?php echo $table_id; ?>.draw(0);
$(".ui-dialog-content").dialog("close");
cleanupDOM();
} else {
$(this).dialog('close');
}
}
}
]
});
}
function delete_key(id) {
$('#aux').empty();
$('#aux').text('<?php echo __('Are you sure?'); ?>');
$('#aux').dialog({
title: '<?php echo __('Delete'); ?> ' + id,
buttons: [
{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
text: '<?php echo __('Cancel'); ?>',
click: function(e) {
$(this).dialog('close');
cleanupDOM();
}
},
{
text: 'Delete',
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
click: function(e) {
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'godmode/groups/credential_store',
delete_key: 1,
identifier: id
},
datatype: "json",
success: function (data) {
handle_response(data);
},
error: function(e) {
handle_response(e);
}
});
}
}
]
});
}
function display_key(id) {
$('#form_update').empty();
$('#form_update').html('Loading...');
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'godmode/groups/credential_store',
get_key: 1,
identifier: id
},
success: function (data) {
$('#info_key').dialog({
width: 580,
height: 400,
position: {
my: 'center',
at: 'center',
of: window,
collision: 'fit'
},
title: id,
buttons: [
{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
text: '<?php echo __('Cancel'); ?>',
click: function(e) {
$(this).dialog('close');
cleanupDOM();
}
},
{
text: 'Update',
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
click: function(e) {
var values = {};
$('#form_update :input').each(function() {
values[this.name] = btoa($(this).val());
});
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'godmode/groups/credential_store',
update_key: 1,
values: values
},
datatype: "json",
success: function (data) {
handle_response(data);
},
error: function(e) {
handle_response(e);
}
});
}
}
]
});
$('#form_update').html(data);
}
})
}
function cleanupDOM() {
$('#div-identifier').empty();
$('#div-product').empty();
$('#div-username').empty();
$('#div-password').empty();
$('#div-extra_1').empty();
$('#div-extra_2').empty();
}
function calculate_inputs() {
if ($('#product :selected').val() == "CUSTOM") {
$('#div-username label').text('<?php echo __('Username'); ?>');
$('#div-password label').text('<?php echo __('Password'); ?>');
$('#div-extra_1 label').text('<?php echo __('Extra'); ?>');
$('#div-extra_2 label').text('<?php echo __('Extra (2)'); ?>');
$('#div-extra_1').show();
$('#div-extra_2').show();
} else if ($('#product :selected').val() == "AWS") {
$('#div-username label').text('<?php echo __('Access key ID'); ?>');
$('#div-password label').text('<?php echo __('Secret access key'); ?>');
$('#div-extra_1').hide();
$('#div-extra_2').hide();
} else if ($('#product :selected').val() == "AZURE") {
$('#div-username label').text('<?php echo __('Account ID'); ?>');
$('#div-password label').text('<?php echo __('Password'); ?>');
$('#div-extra_1 label').text('<?php echo __('Tenant or domain name'); ?>');
$('#div-extra_2 label').text('<?php echo __('Subscription id'); ?>');
$('#div-extra_1').show();
$('#div-extra_2').show();
}
}
function add_key() {
// Clear form.
$('#form_update').empty();
$('#form_update').html('Loading...');
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'godmode/groups/credential_store',
new_form: 1
},
success: function(data) {
$('#form_new').html(data);
$('#id_group').val(0);
// By default AWS.
$('#product').val('AWS');
calculate_inputs();
$('#product').on('change', function() {
calculate_inputs()
});
// Show form.
$('#new_key').dialog({
width: 580,
height: 400,
position: {
my: 'center',
at: 'center',
of: window,
collision: 'fit'
},
title: "<?php echo __('Register new key into keystore'); ?>",
buttons: [
{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
text: "<?php echo __('Cancel'); ?>",
click: function(e) {
$(this).dialog('close');
cleanupDOM();
}
},
{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
text: 'OK',
click: function(e) {
var values = {};
console.log($('#form_new'));
$('#form_new :input').each(function() {
values[this.name] = btoa($(this).val());
});
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'godmode/groups/credential_store',
new_key: 1,
values: values
},
datatype: "json",
success: function (data) {
handle_response(data);
},
error: function(e) {
handle_response(e);
}
});
}
},
]
});
}
})
}
$(document).ready(function(){
$("#submit-create").on('click', function(){
add_key();
});
});
</script>

View File

@ -1,20 +1,36 @@
<?php <?php
/**
* Group management view.
*
* @category Group View
* @package Pandora FMS
* @subpackage Opensource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 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-2010 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.
ui_require_css_file('tree'); ui_require_css_file('tree');
ui_require_css_file('fixed-bottom-box'); ui_require_css_file('fixed-bottom-box');
// Load global vars // Load global vars.
global $config; global $config;
check_login(); check_login();
@ -76,15 +92,17 @@ if (is_ajax()) {
$recursion = (int) get_parameter('recursion', 0); $recursion = (int) get_parameter('recursion', 0);
$privilege = (string) get_parameter('privilege', ''); $privilege = (string) get_parameter('privilege', '');
$all_agents = (int) get_parameter('all_agents', 0); $all_agents = (int) get_parameter('all_agents', 0);
// Is is possible add keys prefix to avoid auto sorting in js object conversion // Is is possible add keys prefix to avoid auto sorting in
// js object conversion.
$keys_prefix = (string) get_parameter('keys_prefix', ''); $keys_prefix = (string) get_parameter('keys_prefix', '');
// This attr is for the operation "bulk alert accions add", it controls the query that take the agents // This attr is for the operation "bulk alert accions add", it controls
// from db // the query that take the agents from db.
$add_alert_bulk_op = get_parameter('add_alert_bulk_op', false); $add_alert_bulk_op = get_parameter('add_alert_bulk_op', false);
// Ids of agents to be include in the SQL clause as id_agent IN () // Ids of agents to be include in the SQL clause as id_agent IN ().
$filter_agents_json = (string) get_parameter('filter_agents_json', ''); $filter_agents_json = (string) get_parameter('filter_agents_json', '');
$status_agents = (int) get_parameter('status_agents', AGENT_STATUS_ALL); $status_agents = (int) get_parameter('status_agents', AGENT_STATUS_ALL);
// Juanma (22/05/2014) Fix: If setted remove void agents from result (by default and for compatibility show void agents) // Juanma (22/05/2014) Fix: If setted remove void agents from result
// (by default and for compatibility show void agents).
$show_void_agents = (int) get_parameter('show_void_agents', 1); $show_void_agents = (int) get_parameter('show_void_agents', 1);
$serialized = (bool) get_parameter('serialized', false); $serialized = (bool) get_parameter('serialized', false);
$serialized_separator = (string) get_parameter('serialized_separator', '|'); $serialized_separator = (string) get_parameter('serialized_separator', '|');
@ -121,7 +139,7 @@ if (is_ajax()) {
$filter['status'] = $status_agents; $filter['status'] = $status_agents;
} }
// Juanma (22/05/2014) Fix: If remove void agents setted // Juanma (22/05/2014) Fix: If remove void agents set.
$_sql_post = ' 1=1 '; $_sql_post = ' 1=1 ';
if ($show_void_agents == 0) { if ($show_void_agents == 0) {
$_sql_post .= ' AND id_agente IN (SELECT a.id_agente FROM tagente a, tagente_modulo b WHERE a.id_agente=b.id_agente AND b.delete_pending=0) AND \'1\''; $_sql_post .= ' AND id_agente IN (SELECT a.id_agente FROM tagente a, tagente_modulo b WHERE a.id_agente=b.id_agente AND b.delete_pending=0) AND \'1\'';
@ -131,8 +149,9 @@ if (is_ajax()) {
$id_groups_get_agents = $id_group; $id_groups_get_agents = $id_group;
if ($id_group == 0 && $privilege != '') { if ($id_group == 0 && $privilege != '') {
$groups = users_get_groups($config['id_user'], $privilege, false); $groups = users_get_groups($config['id_user'], $privilege, false);
// if group ID doesn't matter and $privilege is specified (like 'AW'), // If group ID doesn't matter and $privilege is specified
// retruns all agents that current user has $privilege privilege for. // (like 'AW'), retruns all agents that current user has $privilege
// privilege for.
$id_groups_get_agents = array_keys($groups); $id_groups_get_agents = array_keys($groups);
} }
@ -149,13 +168,13 @@ if (is_ajax()) {
); );
$agents_disabled = []; $agents_disabled = [];
// Add keys prefix // Add keys prefix.
if ($keys_prefix !== '') { if ($keys_prefix !== '') {
foreach ($agents as $k => $v) { foreach ($agents as $k => $v) {
$agents[$keys_prefix.$k] = $v; $agents[$keys_prefix.$k] = $v;
unset($agents[$k]); unset($agents[$k]);
if ($all_agents) { if ($all_agents) {
// Unserialize to get the status // Unserialize to get the status.
if ($serialized && is_metaconsole()) { if ($serialized && is_metaconsole()) {
$agent_info = explode($serialized_separator, $k); $agent_info = explode($serialized_separator, $k);
$agent_disabled = db_get_value_filter( $agent_disabled = db_get_value_filter(
@ -174,7 +193,8 @@ if (is_ajax()) {
['id_agente' => $agent_info[1]] ['id_agente' => $agent_info[1]]
); );
} else if (!$serialized && is_metaconsole()) { } else if (!$serialized && is_metaconsole()) {
// Cannot retrieve the disabled status. Mark all as not disabled // Cannot retrieve the disabled status.
// Mark all as not disabled.
$agent_disabled = 0; $agent_disabled = 0;
} else { } else {
$agent_disabled = db_get_value_filter( $agent_disabled = db_get_value_filter(
@ -226,11 +246,13 @@ if (! check_acl($config['id_user'], 0, 'PM')) {
} }
$sec = defined('METACONSOLE') ? 'advanced' : 'gagente'; $sec = defined('METACONSOLE') ? 'advanced' : 'gagente';
$url_tree = "index.php?sec=$sec&sec2=godmode/groups/group_list&tab=tree"; $url_credbox = 'index.php?sec='.$sec.'&sec2=godmode/groups/group_list&tab=credbox';
$url_groups = "index.php?sec=$sec&sec2=godmode/groups/group_list&tab=groups"; $url_tree = 'index.php?sec='.$sec.'&sec2=godmode/groups/group_list&tab=tree';
$url_groups = 'index.php?sec='.$sec.'&sec2=godmode/groups/group_list&tab=groups';
$buttons['tree'] = [ $buttons['tree'] = [
'active' => false, 'active' => false,
'text' => "<a href='$url_tree'>".html_print_image( 'text' => '<a href="'.$url_tree.'">'.html_print_image(
'images/gm_massive_operations.png', 'images/gm_massive_operations.png',
true, true,
[ [
@ -241,7 +263,7 @@ $buttons['tree'] = [
$buttons['groups'] = [ $buttons['groups'] = [
'active' => false, 'active' => false,
'text' => "<a href='$url_groups'>".html_print_image( 'text' => '<a href="'.$url_groups.'">'.html_print_image(
'images/group.png', 'images/group.png',
true, true,
[ [
@ -250,21 +272,38 @@ $buttons['groups'] = [
).'</a>', ).'</a>',
]; ];
$buttons['credbox'] = [
'active' => false,
'text' => '<a href="'.$url_credbox.'">'.html_print_image(
'images/key.png',
true,
[
'title' => __('Credential Store'),
]
).'</a>',
];
$tab = (string) get_parameter('tab', 'groups'); $tab = (string) get_parameter('tab', 'groups');
// Marks correct tab $title = __('Groups defined in %s', get_product_name());
// Marks correct tab.
switch ($tab) { switch ($tab) {
case 'tree': case 'tree':
$buttons['tree']['active'] = true; $buttons['tree']['active'] = true;
break; break;
case 'credbox':
$buttons['credbox']['active'] = true;
$title = __('Credential store');
break;
case 'groups': case 'groups':
default: default:
$buttons['groups']['active'] = true; $buttons['groups']['active'] = true;
break; break;
} }
// Header // Header.
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
agents_meta_print_header(); agents_meta_print_header();
echo '<div class="notify">'; echo '<div class="notify">';
@ -272,7 +311,7 @@ if (defined('METACONSOLE')) {
echo '</div>'; echo '</div>';
} else { } else {
ui_print_page_header( ui_print_page_header(
__('Groups defined in %s', get_product_name()), $title,
'images/group.png', 'images/group.png',
false, false,
'group_list_tab', 'group_list_tab',
@ -281,12 +320,19 @@ if (defined('METACONSOLE')) {
); );
} }
// Load credential store view before parse list-tree forms.
if ($tab == 'credbox') {
include_once __DIR__.'/credential_store.php';
// Stop script.
return;
}
$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');
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
// Create group // Create group.
if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) { if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) {
$name = (string) get_parameter('name'); $name = (string) get_parameter('name');
$icon = (string) get_parameter('icon'); $icon = (string) get_parameter('icon');
@ -301,7 +347,7 @@ if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) {
$check = db_get_value('nombre', 'tgrupo', 'nombre', $name); $check = db_get_value('nombre', 'tgrupo', 'nombre', $name);
$propagate = (bool) get_parameter('propagate'); $propagate = (bool) get_parameter('propagate');
// Check if name field is empty // Check if name field is empty.
if ($name != '') { if ($name != '') {
if (!$check) { if (!$check) {
$values = [ $values = [
@ -328,12 +374,11 @@ if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) {
ui_print_error_message(__('Each group must have a different name')); ui_print_error_message(__('Each group must have a different name'));
} }
} else { } else {
// $result = false;
ui_print_error_message(__('Group must have a name')); ui_print_error_message(__('Group must have a name'));
} }
} }
// Update group // Update group.
if ($update_group) { if ($update_group) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
$name = (string) get_parameter('name'); $name = (string) get_parameter('name');
@ -349,49 +394,35 @@ if ($update_group) {
$contact = (string) get_parameter('contact'); $contact = (string) get_parameter('contact');
$other = (string) get_parameter('other'); $other = (string) get_parameter('other');
// Check if name field is empty // Check if name field is empty.
if ($name != '') { if ($name != '') {
switch ($config['dbtype']) { $sql = sprintf(
case 'mysql': 'UPDATE tgrupo
$sql = sprintf( SET nombre = "%s",
'UPDATE tgrupo SET nombre = "%s", icon = "%s",
icon = "%s", disabled = %d, parent = %d, custom_id = "%s", propagate = %d, id_skin = %d, description = "%s", contact = "%s", other = "%s", password = "%s" disabled = %d,
WHERE id_grupo = %d', parent = %d,
$name, custom_id = "%s",
empty($icon) ? '' : substr($icon, 0, -4), propagate = %d,
!$alerts_enabled, id_skin = %d,
$id_parent, description = "%s",
$custom_id, contact = "%s",
$propagate, other = "%s",
$skin, password = "%s"
$description, WHERE id_grupo = %d',
$contact, $name,
$other, empty($icon) ? '' : substr($icon, 0, -4),
$group_pass, !$alerts_enabled,
$id_group $id_parent,
); $custom_id,
break; $propagate,
$skin,
case 'postgresql': $description,
case 'oracle': $contact,
$sql = sprintf( $other,
'UPDATE tgrupo SET nombre = \'%s\', $group_pass,
icon = \'%s\', disabled = %d, parent = %d, custom_id = \'%s\', propagate = %d, id_skin = %d, description = \'%s\', contact = \'%s\', other = \'%s\' $id_group
WHERE id_grupo = %d', );
$name,
substr($icon, 0, -4),
!$alerts_enabled,
$id_parent,
$custom_id,
$propagate,
$skin,
$description,
$contact,
$other,
$id_group
);
break;
}
$result = db_process_sql($sql); $result = db_process_sql($sql);
} else { } else {
@ -405,7 +436,7 @@ if ($update_group) {
} }
} }
// Delete group // Delete group.
if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) { if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
@ -445,7 +476,14 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
} }
} }
// Credential store is loaded previously in this document to avoid
// process group tree - list forms.
if ($tab == 'tree') { if ($tab == 'tree') {
/*
* Group tree view.
*/
echo html_print_image( echo html_print_image(
'images/spinner.gif', 'images/spinner.gif',
true, true,
@ -456,6 +494,10 @@ if ($tab == 'tree') {
); );
echo "<div id='tree-controller-recipient'></div>"; echo "<div id='tree-controller-recipient'></div>";
} else { } else {
/*
* Group list view.
*/
$acl = ''; $acl = '';
$search_name = ''; $search_name = '';
$offset = (int) get_parameter('offset', 0); $offset = (int) get_parameter('offset', 0);
@ -463,17 +505,22 @@ if ($tab == 'tree') {
$block_size = $config['block_size']; $block_size = $config['block_size'];
if (!empty($search)) { if (!empty($search)) {
$search_name = "AND t.nombre LIKE '%$search%'"; $search_name = 'AND t.nombre LIKE "%'.$search.'%"';
} }
if (!users_can_manage_group_all('AR')) { if (!users_can_manage_group_all('AR')) {
$user_groups_acl = users_get_groups(false, 'AR'); $user_groups_acl = users_get_groups(false, 'AR');
$groups_acl = implode(',', $user_groups_ACL); $groups_acl = implode(',', $user_groups_ACL);
if (empty($groups_acl)) { if (empty($groups_acl)) {
return ui_print_info_message(['no_close' => true, 'message' => __('There are no defined groups') ]); return ui_print_info_message(
[
'no_close' => true,
'message' => __('There are no defined groups'),
]
);
} }
$acl = "AND t.id_grupo IN ($groups_acl)"; $acl = 'AND t.id_grupo IN ('.$groups_acl.')';
} }
$form = "<form method='post' action=''>"; $form = "<form method='post' action=''>";
@ -488,29 +535,37 @@ if ($tab == 'tree') {
echo $form; echo $form;
$groups_sql = "SELECT t.*, $groups_sql = sprintf(
'SELECT t.*,
p.nombre AS parent_name, p.nombre AS parent_name,
IF(t.parent=p.id_grupo, 1, 0) AS has_child IF(t.parent=p.id_grupo, 1, 0) AS has_child
FROM tgrupo t FROM tgrupo t
LEFT JOIN tgrupo p LEFT JOIN tgrupo p
ON t.parent=p.id_grupo ON t.parent=p.id_grupo
WHERE 1=1 WHERE 1=1
$acl %s
$search_name %s
ORDER BY nombre ORDER BY nombre
LIMIT $offset, $block_size LIMIT %d, %d',
"; $acl,
$search_name,
$offset,
$block_size
);
$groups = db_get_all_rows_sql($groups_sql); $groups = db_get_all_rows_sql($groups_sql);
if (!empty($groups)) { if (!empty($groups)) {
// Count all groups for pagination only saw user and filters // Count all groups for pagination only saw user and filters.
$groups_sql_count = "SELECT count(*) $groups_sql_count = sprintf(
'SELECT count(*)
FROM tgrupo t FROM tgrupo t
WHERE 1=1 WHERE 1=1
$acl %s
$search_name %s',
"; $acl,
$search_name
);
$groups_count = db_get_value_sql($groups_sql_count); $groups_count = db_get_value_sql($groups_sql_count);
$table = new StdClass(); $table = new StdClass();
@ -545,7 +600,7 @@ if ($tab == 'tree') {
$url = 'index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group='.$group['id_grupo']; $url = 'index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group='.$group['id_grupo'];
$url_delete = 'index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group='.$group['id_grupo']; $url_delete = 'index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group='.$group['id_grupo'];
$table->data[$key][0] = $group['id_grupo']; $table->data[$key][0] = $group['id_grupo'];
$table->data[$key][1] = "<a href='$url'>".$group['nombre'].'</a>'; $table->data[$key][1] = '<a href="'.$url.'">'.$group['nombre'].'</a>';
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',
@ -553,22 +608,25 @@ if ($tab == 'tree') {
[ [
'style' => '', 'style' => '',
'class' => 'bot', 'class' => 'bot',
'alt' => $group['nombre'], 'alt' => $group['nombre'],
'title' => $group['nombre'], 'title' => $group['nombre'],
false, false, false, true ],
] false,
false,
false,
true
); );
} else { } else {
$table->data[$key][2] = ''; $table->data[$key][2] = '';
} }
// reporting_get_group_stats // Reporting_get_group_stats.
$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'];
$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',
true, true,
[ [

View File

@ -31,6 +31,7 @@ require_once $config['homedir'].'/include/functions_users.php';
if (is_ajax()) { if (is_ajax()) {
$get_agents = (bool) get_parameter('get_agents'); $get_agents = (bool) get_parameter('get_agents');
$recursion = (int) get_parameter('recursion'); $recursion = (int) get_parameter('recursion');
$disabled_modules = (int) get_parameter('disabled_modules');
if ($get_agents) { if ($get_agents) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
@ -44,12 +45,18 @@ if (is_ajax()) {
$groups = [$id_group]; $groups = [$id_group];
} }
if ($disabled_modules == 0) {
$filter['tagente_modulo.disabled'] = '<> 1';
} else {
unset($filter['tagente_modulo.disabled']);
}
$agents_alerts = []; $agents_alerts = [];
foreach ($groups as $group) { foreach ($groups as $group) {
$agents_alerts_one_group = alerts_get_agents_with_alert_template( $agents_alerts_one_group = alerts_get_agents_with_alert_template(
$id_alert_template, $id_alert_template,
$group, $group,
false, $filter,
[ [
'tagente.alias', 'tagente.alias',
'tagente.id_agente', 'tagente.id_agente',
@ -253,6 +260,11 @@ $table->data[1][1] = html_print_select_groups(
'', '',
$id_alert_template == 0 $id_alert_template == 0
); );
$table->data[0][2] = __('Show alerts on disabled modules');
$table->data[0][3] = html_print_checkbox('disabled_modules', 1, false, true, false);
$table->data[1][2] = __('Group recursion'); $table->data[1][2] = __('Group recursion');
$table->data[1][3] = html_print_checkbox('recursion', 1, false, true, false); $table->data[1][3] = html_print_checkbox('recursion', 1, false, true, false);
@ -360,6 +372,7 @@ $(document).ready (function () {
"get_agents" : 1, "get_agents" : 1,
"id_group" : this.value, "id_group" : this.value,
"recursion" : $("#checkbox-recursion").is(":checked") ? 1 : 0, "recursion" : $("#checkbox-recursion").is(":checked") ? 1 : 0,
"disabled_modules" : $("#checkbox-disabled_modules").is(":checked") ? 1 : 0,
"id_alert_template" : $("#id_alert_template").val(), "id_alert_template" : $("#id_alert_template").val(),
// Add a key prefix to avoid auto sorting in js object conversion // Add a key prefix to avoid auto sorting in js object conversion
"keys_prefix" : "_" "keys_prefix" : "_"
@ -387,6 +400,10 @@ $(document).ready (function () {
$("#modules_selection_mode").change (function() { $("#modules_selection_mode").change (function() {
$("#id_agents").trigger('change'); $("#id_agents").trigger('change');
}); });
$("#checkbox-disabled_modules").click(function () {
$("#id_group").trigger("change");
});
}); });
/* ]]> */ /* ]]> */
</script> </script>

View File

@ -208,7 +208,7 @@ if (!empty($sub)) {
} }
if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, 'PM') || check_acl($config['id_user'], 0, 'RR')) { if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, 'PM')) {
// Servers // Servers
$menu_godmode['gservers']['text'] = __('Servers'); $menu_godmode['gservers']['text'] = __('Servers');
$menu_godmode['gservers']['sec2'] = 'godmode/servers/modificar_server'; $menu_godmode['gservers']['sec2'] = 'godmode/servers/modificar_server';
@ -418,9 +418,11 @@ if (is_array($config['extensions'])) {
$sub['godmode/extensions']['type'] = 'direct'; $sub['godmode/extensions']['type'] = 'direct';
$sub['godmode/extensions']['subtype'] = 'nolink'; $sub['godmode/extensions']['subtype'] = 'nolink';
$submenu = array_merge($menu_godmode['gextensions']['sub'], $sub); if (is_array($menu_godmode['gextensions']['sub'])) {
if ($menu_godmode['gextensions']['sub'] != null) { $submenu = array_merge($menu_godmode['gextensions']['sub'], $sub);
$menu_godmode['gextensions']['sub'] = $submenu; if ($menu_godmode['gextensions']['sub'] != null) {
$menu_godmode['gextensions']['sub'] = $submenu;
}
} }
} }

View File

@ -36,6 +36,9 @@ require_once $config['homedir'].'/include/functions_component_groups.php';
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
components_meta_print_header(); components_meta_print_header();
$sec = 'advanced'; $sec = 'advanced';
$id_modulo = (int) get_parameter('id_component_type');
$new_component = (bool) get_parameter('new_component');
} else { } else {
/* /*
Hello there! :) Hello there! :)

View File

@ -414,7 +414,7 @@ if ($edit_container) {
echo "<table width='100%' cellpadding=4 cellspacing=4 class='databox filters'>"; echo "<table width='100%' cellpadding=4 cellspacing=4 class='databox filters'>";
echo '<tr>'; echo '<tr>';
echo '<td>'; echo '<td>';
echo ui_toggle($single_table, 'Simple module graph', '', true, true); echo ui_toggle($single_table, 'Simple module graph', '', '', true);
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';
@ -466,7 +466,7 @@ if ($edit_container) {
echo "<table width='100%' cellpadding=4 cellspacing=4 class='databox filters'>"; echo "<table width='100%' cellpadding=4 cellspacing=4 class='databox filters'>";
echo '<tr>'; echo '<tr>';
echo '<td>'; echo '<td>';
echo ui_toggle(html_print_table($table, true), 'Custom graph', '', true, true); echo ui_toggle(html_print_table($table, true), 'Custom graph', '', '', true);
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';
@ -561,7 +561,7 @@ if ($edit_container) {
echo "<table width='100%' cellpadding=4 cellspacing=4 class='databox filters'>"; echo "<table width='100%' cellpadding=4 cellspacing=4 class='databox filters'>";
echo '<tr>'; echo '<tr>';
echo '<td>'; echo '<td>';
echo ui_toggle(html_print_table($table, true), 'Dynamic rules for simple module graph', '', true, true); echo ui_toggle(html_print_table($table, true), 'Dynamic rules for simple module graph', '', '', true);
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';

View File

@ -356,9 +356,35 @@ echo "<td style='vertical-align: top;'>".__('Agents').'</td>';
echo '<td></td>'; echo '<td></td>';
echo "<td style='vertical-align: top;'>".__('Modules').'</td>'; echo "<td style='vertical-align: top;'>".__('Modules').'</td>';
echo '</tr><tr>'; echo '</tr><tr>';
echo '<td>'.html_print_select(agents_get_group_agents(), 'id_agents[]', 0, false, '', '', true, true, true, '', false, '').'</td>'; echo '<td style="width: 50%;">'.html_print_select(
echo "<td style='vertical-align: center; text-align: center;'>".html_print_image('images/darrowright.png', true).'</td>'; agents_get_group_agents(),
echo '<td>'.html_print_select([], 'module[]', 0, false, '', 0, true, true, true, '', false, '').'</td>'; 'id_agents[]',
0,
false,
'',
'',
true,
true,
true,
'w100p',
false,
''
).'</td>';
echo "<td style='width: 3em;vertical-align: center; text-align: center;'>".html_print_image('images/darrowright.png', true).'</td>';
echo '<td style="width: 50%;">'.html_print_select(
[],
'module[]',
0,
false,
'',
0,
true,
true,
true,
'w100p',
false,
''
).'</td>';
echo '</tr><tr>'; echo '</tr><tr>';
echo "<td colspan='3'>"; echo "<td colspan='3'>";
echo "<table cellpadding='4'><tr>"; echo "<table cellpadding='4'><tr>";

View File

@ -3526,6 +3526,7 @@ $(document).ready (function () {
$("#submit-create_item").click(function () { $("#submit-create_item").click(function () {
var type = $('#type').val(); var type = $('#type').val();
var name = $('#text-name').val();
switch (type){ switch (type){
case 'alert_report_module': case 'alert_report_module':
case 'alert_report_agent': case 'alert_report_agent':
@ -3556,6 +3557,13 @@ $(document).ready (function () {
default: default:
break; break;
} }
if($('#text-name').val() == ''){
alert( <?php echo "'".__('Please insert a name')."'"; ?> );
return false;
}
}); });
$("#submit-edit_item").click(function () { $("#submit-edit_item").click(function () {

View File

@ -774,31 +774,28 @@ switch ($action) {
$table->head[1] = __('Description'); $table->head[1] = __('Description');
$table->head[2] = __('HTML'); $table->head[2] = __('HTML');
$table->head[3] = __('XML'); $table->head[3] = __('XML');
$table->size[0] = '20%'; $table->size[0] = '60%';
$table->size[1] = '30%'; $table->size[1] = '20%';
$table->size[2] = '2%'; $table->size[2] = '2%';
$table->headstyle[2] = 'min-width: 35px;'; $table->headstyle[2] = 'min-width: 35px;text-align: center;';
$table->size[3] = '2%'; $table->size[3] = '2%';
$table->headstyle[3] = 'min-width: 35px;'; $table->headstyle[3] = 'min-width: 35px;text-align: center;';
$table->size[4] = '2%'; $table->size[4] = '2%';
$table->headstyle[4] = 'min-width: 35px;'; $table->headstyle[4] = 'min-width: 35px;text-align: center;';
$table->size[5] = '2%';
$table->headstyle[5] = 'min-width: 35px;';
$table->size[6] = '2%';
$table->headstyle[6] = 'min-width: 35px;';
$table->size[7] = '5%';
$table->headstyle['csv'] = 'min-width: 65px;';
$table->style[7] = 'text-align: center;';
$table->headstyle[9] = 'min-width: 100px;';
$table->style[9] = 'text-align: center;';
$next = 4; $next = 4;
// Calculate dinamically the number of the column. // Calculate dinamically the number of the column.
if (enterprise_hook('load_custom_reporting_1') !== ENTERPRISE_NOT_HOOK) { if (enterprise_hook('load_custom_reporting_1', [$table]) !== ENTERPRISE_NOT_HOOK) {
$next = 7; $next = 7;
} }
$table->size[$next] = '2%';
$table->style[$next] = 'text-align: center;';
$table->headstyle[($next + 2)] = 'min-width: 100px;';
$table->style[($next + 2)] = 'text-align: center;';
// Admin options only for RM flag. // Admin options only for RM flag.
if (check_acl($config['id_user'], 0, 'RM')) { if (check_acl($config['id_user'], 0, 'RM')) {
$table->head[$next] = __('Private'); $table->head[$next] = __('Private');

View File

@ -254,10 +254,12 @@ function update_button_palette_callback() {
var values = {}; var values = {};
values = readFields(); values = readFields();
if (values["map_linked"] == 0) { if (selectedItem == "static_graph") {
if (values["agent"] == "" || values["agent"] == "none") { if (values["map_linked"] == 0) {
dialog_message("#message_alert_no_agent"); if (values["agent"] == "" || values["agent"] == "none") {
return false; dialog_message("#message_alert_no_agent");
return false;
}
} }
} }
// TODO VALIDATE DATA // TODO VALIDATE DATA

View File

@ -25,6 +25,8 @@ if (empty($visualConsole)) {
exit; exit;
} }
ui_require_css_file('visual_maps');
// ACL for the existing visual console // ACL for the existing visual console
// if (!isset($vconsole_read)) // if (!isset($vconsole_read))
// $vconsole_read = check_acl ($config['id_user'], $visualConsole['id_group'], "VR"); // $vconsole_read = check_acl ($config['id_user'], $visualConsole['id_group'], "VR");
@ -170,6 +172,7 @@ echo "<div id='delete_in_progress_dialog' style='display: none; text-align: cent
// CSS // CSS
ui_require_css_file('color-picker', 'include/styles/js/'); ui_require_css_file('color-picker', 'include/styles/js/');
ui_require_css_file('jquery-ui.min', 'include/styles/js/'); ui_require_css_file('jquery-ui.min', 'include/styles/js/');
ui_require_jquery_file('jquery-ui_custom');
// Javascript // Javascript
ui_require_jquery_file('colorpicker'); ui_require_jquery_file('colorpicker');

View File

@ -130,5 +130,11 @@ if ($classname_selected === null) {
} }
} }
// Show hints if there is no task
if (get_parameter('discovery_hint', 0)) {
ui_require_css_file('discovery-hint');
ui_print_info_message(__('You must create a task first'));
}
Wizard::printBigButtonsList($wiz_data); Wizard::printBigButtonsList($wiz_data);
} }

View File

@ -280,7 +280,7 @@ if (($create != '') || ($view != '')) {
} else { } else {
if ($create != '') { if ($create != '') {
ui_print_page_header( ui_print_page_header(
__('Plugin creation'), __('Plugin registration'),
'images/gm_servers.png', 'images/gm_servers.png',
false, false,
'plugin_definition', 'plugin_definition',

View File

@ -51,11 +51,11 @@ $table->style[0] = 'font-weight: bold';
$table->align = []; $table->align = [];
$table->align[1] = 'center'; $table->align[1] = 'center';
$table->align[3] = 'center'; $table->align[3] = 'center';
$table->align[8] = 'center'; $table->align[8] = 'right';
$table->headstyle[1] = 'text-align:center'; $table->headstyle[1] = 'text-align:center';
$table->headstyle[3] = 'text-align:center'; $table->headstyle[3] = 'text-align:center';
$table->headstyle[8] = 'text-align:center'; $table->headstyle[8] = 'text-align:right;width: 120px;';
// $table->title = __('Tactical server information'); // $table->title = __('Tactical server information');
$table->titleclass = 'tabletitle'; $table->titleclass = 'tabletitle';
@ -234,7 +234,8 @@ if ($tiny) {
ui_toggle( ui_toggle(
html_print_table($table, true), html_print_table($table, true),
__('Tactical server information'), __('Tactical server information'),
false, '',
'',
$hidden_toggle $hidden_toggle
); );
} else { } else {

View File

@ -135,7 +135,9 @@ $table->data[9][0] = '<strong>'.__('Licensed to').'</strong>';
$table->data[9][1] = html_print_input_text('licensed_to', $license['licensed_to'], '', 64, 255, true, true); $table->data[9][1] = html_print_input_text('licensed_to', $license['licensed_to'], '', 64, 255, true, true);
html_print_table($table); html_print_table($table);
if (enterprise_installed()) {
// If DESTDIR is defined the enterprise license is expired.
if (enterprise_installed() || defined('DESTDIR')) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_input_hidden('update_settings', 1); html_print_input_hidden('update_settings', 1);
html_print_submit_button(__('Validate'), 'update_button', false, 'class="sub upd"'); html_print_submit_button(__('Validate'), 'update_button', false, 'class="sub upd"');

View File

@ -1113,15 +1113,6 @@ $row++;
$table_other->data[$row][0] = __('Show QR Code icon in the header');
$table_other->data[$row][1] = html_print_checkbox_switch(
'show_qr_code_header',
1,
$config['show_qr_code_header'],
true
);
$row++;
$table_other->data[$row][0] = __('Custom graphviz directory').ui_print_help_tip(__('Custom directory where the graphviz binaries are stored.'), true); $table_other->data[$row][0] = __('Custom graphviz directory').ui_print_help_tip(__('Custom directory where the graphviz binaries are stored.'), true);
$table_other->data[$row][1] = html_print_input_text( $table_other->data[$row][1] = html_print_input_text(
'graphviz_bin_dir', 'graphviz_bin_dir',

View File

@ -1275,7 +1275,7 @@ if ($create_alert || $update_alert) {
$table->align[7] = 'left'; $table->align[7] = 'left';
$table->head[8] = __('Action'); $table->head[8] = __('Action');
$table->size[8] = '90px'; $table->size[8] = '120px';
$table->align[8] = 'left'; $table->align[8] = 'left';
$table->head[9] = html_print_checkbox('all_delete_box', '1', false, true); $table->head[9] = html_print_checkbox('all_delete_box', '1', false, true);

View File

@ -34,7 +34,7 @@
float: none; float: none;
} }
#drop_file a { #drop_file a {
background-color: #80ba27; background-color: #82b92e;
border-radius: 2px; border-radius: 2px;
color: #ffffff; color: #ffffff;
cursor: pointer; cursor: pointer;
@ -101,7 +101,7 @@
width: 15px; width: 15px;
} }
.fileupload_form ul li div { .fileupload_form ul li div {
display: block !important; display: block;
} }
.fileupload_form ul li.working span { .fileupload_form ul li.working span {
background-position: 0 -12px; background-position: 0 -12px;
@ -183,39 +183,22 @@ div#box_online * {
.update_text a { .update_text a {
font-size: 11pt; font-size: 11pt;
color: #82b92e !important; color: #82b92e;
} }
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
float: left !important; float: left;
padding-left: 19px; padding-left: 19px;
padding-bottom: 5px; padding-bottom: 5px;
} }
.ui-dialog-buttonset > button.ui-button.ui-corner-all.ui-widget {
background-color: #cecece !important;
border: none !important;
border-radius: 2px !important;
text-transform: uppercase !important;
font-weight: bold !important;
}
.ui-dialog-buttonset > button.success_button.ui-button.ui-corner-all.ui-widget,
.update_manager_button {
background-color: #82b92e !important;
color: #fff !important;
border-radius: 2px !important;
text-transform: uppercase !important;
font-weight: bold !important;
}
a.update_manager_button { a.update_manager_button {
padding: 10px 12px; padding: 10px 12px;
margin-top: 10px; margin-top: 10px;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
font-size: 16px !important; font-size: 16px;
border-radius: 4px !important; border-radius: 4px;
text-decoration: none; text-decoration: none;
font-family: "Open Sans", sans-serif; font-family: "Open Sans", sans-serif;
} }
@ -231,7 +214,7 @@ a.update_manager_button:after {
.ui-draggable, .ui-draggable,
.ui-draggable .ui-dialog-titlebar { .ui-draggable .ui-dialog-titlebar {
cursor: default !important; cursor: default;
} }
#box_online #pkg_version { #box_online #pkg_version {
@ -242,10 +225,10 @@ a.update_manager_button:after {
/* METACONSOLE */ /* METACONSOLE */
.box_online_meta { .box_online_meta {
background: none !important; background: none;
min-height: 400px !important; min-height: 400px;
text-align: center; text-align: center;
border: none !important; border: none;
} }
div#box_online.box_online_meta * { div#box_online.box_online_meta * {
@ -277,7 +260,7 @@ div#box_online.box_online_meta * {
} }
.update_manager_warning p { .update_manager_warning p {
font-size: 10pt !important; font-size: 10pt;
} }
.update_manager_warning img { .update_manager_warning img {
@ -287,8 +270,8 @@ div#box_online.box_online_meta * {
a.update_manager_button_open { a.update_manager_button_open {
padding: 5px 10px; padding: 5px 10px;
font-size: 16px !important; font-size: 16px;
border-radius: 4px !important; border-radius: 4px;
text-decoration: none; text-decoration: none;
border: 1px solid #82b92e; border: 1px solid #82b92e;
color: #82b92e; color: #82b92e;

View File

@ -297,7 +297,14 @@ if (defined('METACONSOLE')) {
$form_filter = "<form method='post'>"; $form_filter = "<form method='post'>";
$form_filter .= html_print_table($table, true); $form_filter .= html_print_table($table, true);
$form_filter .= '</form>'; $form_filter .= '</form>';
ui_toggle($form_filter, __('Users control filter'), __('Toggle filter(s)'), !$search); ui_toggle(
$form_filter,
__('Users control filter'),
__('Toggle filter(s)'),
'',
'',
!$search
);
} }
// Urls to sort the table. // Urls to sort the table.

View File

@ -651,20 +651,24 @@ class DiscoveryTaskList extends Wizard
array_push($table->data, $data); array_push($table->data, $data);
} }
echo '<h2>'.__('Server tasks').'</h2>';
if (empty($table->data)) { if (empty($table->data)) {
echo '<div class="nf">'.__('Server').' '.$server_name.' '.__('has no discovery tasks assigned').'</div>'; $content = '<div class="nf">'.__('Server').' '.$server_name.' '.__('has no discovery tasks assigned').'</div>';
return false; $return = false;
} else { } else {
html_print_table($table); $content = html_print_table($table, true);
$return = true;
} }
ui_toggle($content, __('Server Tasks'), '', '', false);
// Div neccesary for modal map task. // Div neccesary for modal map task.
echo '<div id="map_task" style="display:none"></div>'; echo '<div id="map_task" style="display:none"></div>';
unset($table); unset($table);
ui_require_javascript_file('pandora_taskList'); ui_require_javascript_file('pandora_taskList');
return $return;
} }
return true; return true;
@ -695,7 +699,7 @@ class DiscoveryTaskList extends Wizard
if ($script !== false) { if ($script !== false) {
switch ($script['type']) { switch ($script['type']) {
case DISCOVERY_SCRIPT_CLOUD_AWS: case DISCOVERY_SCRIPT_CLOUD_AWS:
return 'wiz=cloud&mode=amazonws&page=1'; return 'wiz=cloud&mode=amazonws&ki='.$task['auth_strings'].'&page=1';
case DISCOVERY_SCRIPT_APP_VMWARE: case DISCOVERY_SCRIPT_APP_VMWARE:
return 'wiz=app&mode=vmware&page=0'; return 'wiz=app&mode=vmware&page=0';
@ -718,10 +722,10 @@ class DiscoveryTaskList extends Wizard
case DISCOVERY_CLOUD_AWS: case DISCOVERY_CLOUD_AWS:
case DISCOVERY_CLOUD_AWS_EC2: case DISCOVERY_CLOUD_AWS_EC2:
return 'wiz=cloud&mode=amazonws&page=1'; return 'wiz=cloud&mode=amazonws&ki='.$task['auth_strings'].'&page=1';
case DISCOVERY_CLOUD_AWS_RDS: case DISCOVERY_CLOUD_AWS_RDS:
return 'wiz=cloud&mode=amazonws&sub=rds&page=0'; return 'wiz=cloud&mode=amazonws&ki='.$task['auth_strings'].'&sub=rds&page=0';
default: default:
if ($task['description'] == 'console_task') { if ($task['description'] == 'console_task') {

View File

@ -1048,7 +1048,7 @@ class Wizard
*/ */
public static function printBigButtonsList($list_data) public static function printBigButtonsList($list_data)
{ {
echo '<ul>'; echo '<ul class="bigbuttonlist">';
array_map('self::printBigButtonElement', $list_data); array_map('self::printBigButtonElement', $list_data);
echo '</ul>'; echo '</ul>';
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

File diff suppressed because it is too large Load Diff

View File

@ -392,11 +392,16 @@ if (check_login()) {
switch ($row['module_type']) { switch ($row['module_type']) {
case 15: case 15:
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module_id); $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module_id);
// System Uptime:
// In case of System Uptime module, shows data in format "Days hours minutes seconds" if and only if
// selected module unit is "_timeticks_"
// Take notice that selected unit may not be postrocess unit
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
if ($post_process > 0) { $data_macro = modules_get_unit_macro($row[$attr[0]], $unit);
$data[] = human_milliseconds_to_string(($row['data'] / $post_process)); if ($data_macro) {
$data[] = $data_macro;
} else { } else {
$data[] = human_milliseconds_to_string($row['data']); $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision']));
} }
} else { } else {
$data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision']));
@ -824,23 +829,28 @@ if (check_login()) {
$table->head[7] = __('Data'); $table->head[7] = __('Data');
$table->head[8] = __('Graph'); $table->head[8] = __('Graph');
$table->head[9] = __('Last contact').ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastContactUp, $selectLastContactDown); $table->head[9] = __('Last contact').ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastContactUp, $selectLastContactDown);
$table->align = [ $table->align = [];
'left', $table->align[0] = 'center';
'left', $table->align[1] = 'left';
'left', $table->align[2] = 'left';
'left', $table->align[3] = 'left';
'left', $table->align[4] = 'left';
'left', $table->align[5] = 'left';
'left', $table->align[6] = 'center';
'left', $table->align[7] = 'left';
'left', $table->align[8] = 'center';
]; $table->align[9] = 'right';
$table->headstyle[2] = 'min-width: 60px'; $table->headstyle[2] = 'min-width: 85px';
$table->headstyle[3] = 'min-width: 100px'; $table->headstyle[3] = 'min-width: 130px';
$table->headstyle[5] = 'min-width: 60px'; $table->size[3] = '30%';
$table->headstyle[8] = 'min-width: 85px'; $table->style[3] = 'max-width: 28em;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;';
$table->headstyle[9] = 'min-width: 100px'; $table->size[4] = '30%';
$table->headstyle[5] = 'min-width: 85px';
$table->headstyle[6] = 'min-width: 125px; text-align: center;';
$table->headstyle[7] = 'min-width: 125px;';
$table->headstyle[8] = 'min-width: 100px; text-align: center;';
$table->headstyle[9] = 'min-width: 120px; text-align: right;';
$last_modulegroup = 0; $last_modulegroup = 0;
$rowIndex = 0; $rowIndex = 0;
@ -879,14 +889,14 @@ if (check_login()) {
$last_modulegroup = $module['id_module_group']; $last_modulegroup = $module['id_module_group'];
} }
// End of title of group // End of title of group.
} }
$data = []; $data = [];
if (($module['id_modulo'] != 1) && ($module['id_tipo_modulo'] != 100)) { if (($module['id_modulo'] != 1) && ($module['id_tipo_modulo'] != 100)) {
if ($agent_w) { if ($agent_w) {
if ($module['flag'] == 0) { if ($module['flag'] == 0) {
$data[0] = '<a href="index.php?'.'sec=estado&amp;'.'sec2=operation/agentes/ver_agente&amp;'.'id_agente='.$id_agente.'&amp;'.'id_agente_modulo='.$module['id_agente_modulo'].'&amp;'.'flag=1&amp;'.'refr=60">'.html_print_image('images/target.png', true, ['border' => '0', 'title' => __('Force')]).'</a>'; $data[0] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'&amp;id_agente_modulo='.$module['id_agente_modulo'].'&amp;flag=1&amp;refr=60">'.html_print_image('images/target.png', true, ['border' => '0', 'title' => __('Force')]).'</a>';
} else { } else {
$data[0] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'&amp;id_agente_modulo='.$module['id_agente_modulo'].'&amp;refr=60">'.html_print_image('images/refresh.png', true, ['border' => '0', 'title' => __('Refresh')]).'</a>'; $data[0] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'&amp;id_agente_modulo='.$module['id_agente_modulo'].'&amp;refr=60">'.html_print_image('images/refresh.png', true, ['border' => '0', 'title' => __('Refresh')]).'</a>';
} }
@ -1074,7 +1084,7 @@ if (check_login()) {
if ($data_macro) { if ($data_macro) {
$salida = $data_macro; $salida = $data_macro;
} else { } else {
$salida .= '&nbsp;'.'<i>'.io_safe_output($module['unit']).'</i>'; $salida .= '&nbsp;<i>'.io_safe_output($module['unit']).'</i>';
} }
} }
} else { } else {
@ -1120,17 +1130,17 @@ if (check_login()) {
$draw_events = 0; $draw_events = 0;
} }
$link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&amp;".'period='.SECONDS_1DAY.'&amp;'.'id='.$module['id_agente_modulo'].'&amp;'.'label='.rawurlencode( $link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&amp;".'period='.SECONDS_1DAY.'&amp;id='.$module['id_agente_modulo'].'&amp;label='.rawurlencode(
urlencode( urlencode(
base64_encode($module['nombre']) base64_encode($module['nombre'])
) )
).'&amp;'.'refresh='.SECONDS_10MINUTES.'&amp;'."draw_events=$draw_events', 'day_".$win_handle."', 1000, 650)"; ).'&amp;refresh='.SECONDS_10MINUTES.'&amp;'."draw_events=$draw_events', 'day_".$win_handle."', 1000, 700)";
if (!is_snapshot_data($module['datos'])) { if (!is_snapshot_data($module['datos'])) {
$data[8] .= '<a href="javascript:'.$link.'">'.html_print_image('images/chart_curve.png', true, ['border' => '0', 'alt' => '']).'</a> &nbsp;&nbsp;'; $data[8] .= '<a href="javascript:'.$link.'">'.html_print_image('images/chart_curve.png', true, ['border' => '0', 'alt' => '']).'</a> &nbsp;&nbsp;';
} }
$server_name = ''; $server_name = '';
$data[8] .= "<a href='javascript: ".'show_module_detail_dialog('.$module['id_agente_modulo'].', '.$id_agente.', '.'"'.$server_name.'", '.(0).', '.SECONDS_1DAY.', " '.modules_get_agentmodule_name($module['id_agente_modulo'])."\")'>".html_print_image('images/binary.png', true, ['border' => '0', 'alt' => '']).'</a>'; $data[8] .= "<a href='javascript: ".'show_module_detail_dialog('.$module['id_agente_modulo'].', '.$id_agente.', "'.$server_name.'", '.(0).', '.SECONDS_1DAY.', " '.modules_get_agentmodule_name($module['id_agente_modulo'])."\")'>".html_print_image('images/binary.png', true, ['border' => '0', 'alt' => '']).'</a>';
} }
if ($module['estado'] == 3) { if ($module['estado'] == 3) {
@ -1177,7 +1187,7 @@ if (check_login()) {
ui_print_info_message([ 'no_close' => true, 'message' => __('This agent doesn\'t have any active monitors.') ]); ui_print_info_message([ 'no_close' => true, 'message' => __('This agent doesn\'t have any active monitors.') ]);
} }
} else { } else {
$url = 'index.php?'.'sec=estado&'.'sec2=operation/agentes/ver_agente&'.'id_agente='.$id_agente.'&'.'refr=&filter_monitors=1&'.'status_filter_monitor='.$status_filter_monitor.'&'.'status_text_monitor='.$status_text_monitor.'&'.'status_module_group='.$status_module_group; $url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.'&status_text_monitor='.$status_text_monitor.'&status_module_group='.$status_module_group;
if ($paginate_module) { if ($paginate_module) {
ui_pagination( ui_pagination(

View File

@ -151,6 +151,10 @@ if (is_ajax()) {
ob_clean(); ob_clean();
echo '<style type="text/css">';
include_once __DIR__.'/../styles/progress.css';
echo '</style>';
echo '<div class="left_align">'; echo '<div class="left_align">';
if (!empty($id) && !empty($type)) { if (!empty($id) && !empty($type)) {
switch ($type) { switch ($type) {

View File

@ -1206,6 +1206,8 @@ switch ($action) {
switch ($type) { switch ($type) {
case 'auto_sla_graph': case 'auto_sla_graph':
$elementFields['event_max_time_row'] = $elementFields['period']; $elementFields['event_max_time_row'] = $elementFields['period'];
break;
case 'percentile_item': case 'percentile_item':
case 'percentile_bar': case 'percentile_bar':
$elementFields['width_percentile'] = $elementFields['width']; $elementFields['width_percentile'] = $elementFields['width'];

View File

@ -1257,11 +1257,8 @@ function fill_permissions_ldap($sr)
global $config; global $config;
$permissions = []; $permissions = [];
$permissions_profile = []; $permissions_profile = [];
if (defined('METACONSOLE')) {
$meta = true;
}
if ($meta && (bool) $config['ldap_save_profile'] === false && $config['ldap_advanced_config'] == 0) { if ((bool) $config['ldap_save_profile'] === false && ($config['ldap_advanced_config'] == 0 || $config['ldap_advanced_config'] == '')) {
$result = 0; $result = 0;
$result = db_get_all_rows_filter( $result = db_get_all_rows_filter(
'tusuario_perfil', 'tusuario_perfil',
@ -1287,43 +1284,9 @@ function fill_permissions_ldap($sr)
return $permissions_profile; return $permissions_profile;
} }
if ((bool) $config['ldap_save_profile'] === false && $config['ldap_advanced_config'] == '') {
$result = db_get_all_rows_filter(
'tusuario_perfil',
['id_usuario' => $sr['uid'][0]]
);
if ($result == false) {
$permissions[0]['profile'] = $config['default_remote_profile'];
$permissions[0]['groups'][] = $config['default_remote_group'];
$permissions[0]['tags'] = $config['default_assign_tags'];
$permissions[0]['no_hierarchy'] = $config['default_no_hierarchy'];
return $permissions;
}
foreach ($result as $perms) {
$permissions_profile[] = [
'profile' => $perms['id_perfil'],
'groups' => [$perms['id_grupo']],
'tags' => $perms['tags'],
'no_hierarchy' => (bool) $perms['no_hierarchy'] ? 1 : 0,
];
}
return $permissions_profile;
}
if ($config['ldap_advanced_config'] == 1 && $config['ldap_save_profile'] == 1) { if ($config['ldap_advanced_config'] == 1 && $config['ldap_save_profile'] == 1) {
$ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true); $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
foreach ($ldap_adv_perms as $ldap_adv_perm) { return get_advanced_permissions($ldap_adv_perms, $sr);
$permissions[] = [
'profile' => $ldap_adv_perm['profile'],
'groups' => $ldap_adv_perm['group'],
'tags' => implode(',', $ldap_adv_perm['tags']),
'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
];
}
return $permissions;
} }
if ($config['ldap_advanced_config'] == 1 && $config['ldap_save_profile'] == 0) { if ($config['ldap_advanced_config'] == 1 && $config['ldap_save_profile'] == 0) {
@ -1333,25 +1296,16 @@ function fill_permissions_ldap($sr)
); );
if ($result == false) { if ($result == false) {
$ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true); $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
foreach ($ldap_adv_perms as $ldap_adv_perm) { return get_advanced_permissions($ldap_adv_perms, $sr);
$permissions[] = [
'profile' => $ldap_adv_perm['profile'],
'groups' => $ldap_adv_perm['group'],
'tags' => implode(',', $ldap_adv_perm['tags']),
'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
];
}
return $permissions;
} }
foreach ($result as $perms) { foreach ($result as $perms) {
$permissions_profile[] = [ $permissions_profile[] = [
'profile' => $perms['id_perfil'], 'profile' => $perms['id_perfil'],
'groups' => [$perms['id_grupo']], 'groups' => [$perms['id_grupo']],
'tags' => $perms['tags'], 'tags' => $perms['tags'],
'no_hierarchy' => (bool) $perms['no_hierarchy'] ? 1 : 0, 'no_hierarchy' => (bool) $perms['no_hierarchy'] ? 1 : 0,
]; ];
}; };
return $permissions_profile; return $permissions_profile;
@ -1365,22 +1319,43 @@ function fill_permissions_ldap($sr)
return $permissions; return $permissions;
} }
// Decode permissions in advanced mode return $permissions;
$ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true); }
/**
* Get permissions in advanced mode.
*
* @param array ldap_adv_perms
*
* @return array
*/
function get_advanced_permissions($ldap_adv_perms, $sr)
{
$permissions = [];
foreach ($ldap_adv_perms as $ldap_adv_perm) { foreach ($ldap_adv_perms as $ldap_adv_perm) {
$attributes = $ldap_adv_perm['groups_ldap']; $attributes = $ldap_adv_perm['groups_ldap'];
foreach ($attributes as $attr) { if (!empty($attributes[0])) {
$attr = explode('=', $attr, 2); foreach ($attributes as $attr) {
foreach ($sr[$attr[0]] as $s_attr) { $attr = explode('=', $attr, 2);
if (preg_match('/'.$attr[1].'/', $s_attr)) { foreach ($sr[$attr[0]] as $s_attr) {
$permissions[] = [ if (preg_match('/'.$attr[1].'/', $s_attr)) {
'profile' => $ldap_adv_perm['profile'], $permissions[] = [
'groups' => $ldap_adv_perm['group'], 'profile' => $ldap_adv_perm['profile'],
'tags' => implode(',', $ldap_adv_perm['tags']), 'groups' => $ldap_adv_perm['group'],
'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0, 'tags' => implode(',', $ldap_adv_perm['tags']),
]; 'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
];
}
} }
} }
} else {
$permissions[] = [
'profile' => $ldap_adv_perm['profile'],
'groups' => $ldap_adv_perm['group'],
'tags' => implode(',', $ldap_adv_perm['tags']),
'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
];
} }
} }

View File

@ -62,6 +62,7 @@ if (file_exists('languages/'.$user_language.'.mo')) {
<link rel="stylesheet" href="styles/pandora.css" type="text/css" /> <link rel="stylesheet" href="styles/pandora.css" type="text/css" />
<link rel="stylesheet" href="styles/pandora_minimal.css" type="text/css" /> <link rel="stylesheet" href="styles/pandora_minimal.css" type="text/css" />
<link rel="stylesheet" href="styles/js/jquery-ui.min.css" type="text/css" /> <link rel="stylesheet" href="styles/js/jquery-ui.min.css" type="text/css" />
<link rel="stylesheet" href="styles/js/jquery-ui_custom.css" type="text/css" />
<script language="javascript" type='text/javascript' src='javascript/pandora.js'></script> <script language="javascript" type='text/javascript' src='javascript/pandora.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery-3.3.1.min.js'></script> <script language="javascript" type='text/javascript' src='javascript/jquery-3.3.1.min.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery.pandora.js'></script> <script language="javascript" type='text/javascript' src='javascript/jquery.pandora.js'></script>

View File

@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/functions_db.php';
require_once $config['homedir'].'/include/functions_io.php'; require_once $config['homedir'].'/include/functions_io.php';
require_once $config['homedir'].'/include/functions_notifications.php'; require_once $config['homedir'].'/include/functions_notifications.php';
require_once $config['homedir'].'/include/functions_servers.php'; require_once $config['homedir'].'/include/functions_servers.php';
require_once $config['homedir'].'/include/functions_update_manager.php';
// Enterprise includes. // Enterprise includes.
enterprise_include_once('include/functions_metaconsole.php'); enterprise_include_once('include/functions_metaconsole.php');
@ -1940,6 +1941,7 @@ class ConsoleSupervisor
public function checkUpdateManagerRegistration() public function checkUpdateManagerRegistration()
{ {
global $config; global $config;
include_once $config['homedir'].'/include/functions_update_manager.php';
$login = get_parameter('login', false); $login = get_parameter('login', false);
if (update_manager_verify_registration() === false) { if (update_manager_verify_registration() === false) {
@ -2244,6 +2246,7 @@ class ConsoleSupervisor
public function getUMMessages() public function getUMMessages()
{ {
global $config; global $config;
include_once $config['homedir'].'/include/functions_update_manager.php';
if (update_manager_verify_registration() === false) { if (update_manager_verify_registration() === false) {
// Console not subscribed. // Console not subscribed.
@ -2261,8 +2264,6 @@ class ConsoleSupervisor
$future = (time() + 2 * SECONDS_1HOUR); $future = (time() + 2 * SECONDS_1HOUR);
config_update_value('last_um_check', $future); config_update_value('last_um_check', $future);
include_once $config['homedir'].'/include/functions_update_manager.php';
$params = [ $params = [
'pandora_uid' => $config['pandora_uid'], 'pandora_uid' => $config['pandora_uid'],
'timezone' => $config['timezone'], 'timezone' => $config['timezone'],

View File

@ -2845,6 +2845,7 @@ class NetworkMap
html_print_table($table, true), html_print_table($table, true),
__('Node Details'), __('Node Details'),
__('Node Details'), __('Node Details'),
'',
false, false,
true true
); );
@ -2897,6 +2898,7 @@ class NetworkMap
html_print_table($table, true), html_print_table($table, true),
__('Node Details'), __('Node Details'),
__('Node Details'), __('Node Details'),
'',
false, false,
true true
); );
@ -2922,6 +2924,7 @@ class NetworkMap
html_print_table($table, true), html_print_table($table, true),
__('Interface Information (SNMP)'), __('Interface Information (SNMP)'),
__('Interface Information (SNMP)'), __('Interface Information (SNMP)'),
'',
true, true,
true true
); );
@ -2996,6 +2999,7 @@ class NetworkMap
html_print_table($table, true), html_print_table($table, true),
__('Node options'), __('Node options'),
__('Node options'), __('Node options'),
'',
true, true,
true true
); );
@ -3056,6 +3060,7 @@ class NetworkMap
html_print_table($table, true), html_print_table($table, true),
__('Relations'), __('Relations'),
__('Relations'), __('Relations'),
'',
true, true,
true true
); );
@ -3165,6 +3170,7 @@ class NetworkMap
$add_agent_node_html, $add_agent_node_html,
__('Add agent node'), __('Add agent node'),
__('Add agent node'), __('Add agent node'),
'',
false, false,
true true
); );
@ -3216,6 +3222,7 @@ class NetworkMap
$add_agent_node_html, $add_agent_node_html,
__('Add agent node (filter by group)'), __('Add agent node (filter by group)'),
__('Add agent node'), __('Add agent node'),
'',
true, true,
true true
); );
@ -3256,6 +3263,7 @@ class NetworkMap
$add_agent_node_html, $add_agent_node_html,
__('Add fictional point'), __('Add fictional point'),
__('Add agent node'), __('Add agent node'),
'',
true, true,
true true
); );

View File

@ -72,6 +72,8 @@ class TreeService extends Tree
protected function getFirstLevel() protected function getFirstLevel()
{ {
global $config;
$processed_items = $this->getProcessedServices(); $processed_items = $this->getProcessedServices();
$ids = array_keys($processed_items); $ids = array_keys($processed_items);

View File

@ -20,8 +20,8 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC190614'; $build_version = 'PC190628';
$pandora_version = 'v7.0NG.735'; $pandora_version = 'v7.0NG.736';
// 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

@ -39,10 +39,11 @@ define('TIME_FORMAT', 'H:i:s');
define('TIME_FORMAT_JS', 'HH:mm:ss'); define('TIME_FORMAT_JS', 'HH:mm:ss');
// Events state constants. // Events state constants.
define('EVENT_ALL', -1);
define('EVENT_NEW', 0); define('EVENT_NEW', 0);
define('EVENT_VALIDATE', 1); define('EVENT_VALIDATE', 1);
define('EVENT_PROCESS', 2); define('EVENT_PROCESS', 2);
define('EVENT_NO_VALIDATED', 3);
// Agents disabled status. // Agents disabled status.
@ -65,7 +66,7 @@ define('ERR_NODATA', -70000);
define('ERR_CONNECTION', -80000); define('ERR_CONNECTION', -80000);
define('ERR_DISABLED', -90000); define('ERR_DISABLED', -90000);
define('ERR_WRONG', -100000); define('ERR_WRONG', -100000);
define('ERR_WRONG_NAME', -100001); define('ERR_WRONG_MR', -100001);
define('ERR_WRONG_PARAMETERS', -100002); define('ERR_WRONG_PARAMETERS', -100002);
define('ERR_ACL', -110000); define('ERR_ACL', -110000);
define('ERR_AUTH', -120000); define('ERR_AUTH', -120000);
@ -137,19 +138,19 @@ switch ($config['dbtype']) {
// Color constants. // Color constants.
define('COL_CRITICAL', '#FC4444'); define('COL_CRITICAL', '#e63c52');
define('COL_WARNING', '#FAD403'); define('COL_WARNING', '#f3b200');
define('COL_WARNING_DARK', '#FFB900'); define('COL_WARNING_DARK', '#FFB900');
define('COL_NORMAL', '#80BA27'); define('COL_NORMAL', '#82b92e');
define('COL_NOTINIT', '#3BA0FF'); define('COL_NOTINIT', '#4a83f3');
define('COL_UNKNOWN', '#B2B2B2'); define('COL_UNKNOWN', '#B2B2B2');
define('COL_DOWNTIME', '#976DB1'); define('COL_DOWNTIME', '#976DB1');
define('COL_IGNORED', '#DDD'); define('COL_IGNORED', '#DDD');
define('COL_ALERTFIRED', '#FFA631'); define('COL_ALERTFIRED', '#F36201');
define('COL_MINOR', '#F099A2'); define('COL_MINOR', '#B2B2B2');
define('COL_MAJOR', '#C97A4A'); define('COL_MAJOR', '#C97A4A');
define('COL_INFORMATIONAL', '#E4E4E4'); define('COL_INFORMATIONAL', '#E4E4E4');
define('COL_MAINTENANCE', '#3BA0FF'); define('COL_MAINTENANCE', '#4a83f3');
define('COL_GRAPH1', '#C397F2'); define('COL_GRAPH1', '#C397F2');
define('COL_GRAPH2', '#FFE66C'); define('COL_GRAPH2', '#FFE66C');

View File

@ -902,6 +902,47 @@ function set_cookie($name, $value)
} }
/**
* Returns database ORDER clause from datatables AJAX call.
*
* @param boolean $as_array Return as array or as string.
*
* @return string Order or empty.
*/
function get_datatable_order($as_array=false)
{
$order = get_parameter('order');
if (is_array($order)) {
$column = $order[0]['column'];
$direction = $order[0]['dir'];
}
if (!isset($column) || !isset($direction)) {
return '';
}
$columns = get_parameter('columns');
if (is_array($columns)) {
$column_name = $columns[$column]['data'];
}
if (!isset($column_name)) {
return '';
}
if ($as_array) {
return [
'direction' => $direction,
'field' => $column_name,
];
}
return $column_name.' '.$direction;
}
/** /**
* Get a parameter from a request. * Get a parameter from a request.
* *
@ -1392,6 +1433,11 @@ function enterprise_installed()
{ {
$return = false; $return = false;
// Load enterprise extensions.
if (defined('DESTDIR')) {
return $return;
}
if (defined('PANDORA_ENTERPRISE')) { if (defined('PANDORA_ENTERPRISE')) {
if (PANDORA_ENTERPRISE) { if (PANDORA_ENTERPRISE) {
$return = true; $return = true;
@ -1444,7 +1490,7 @@ function enterprise_include($filename)
{ {
global $config; global $config;
// Load enterprise extensions // Load enterprise extensions.
if (defined('DESTDIR')) { if (defined('DESTDIR')) {
$destdir = DESTDIR; $destdir = DESTDIR;
} else { } else {
@ -1470,11 +1516,24 @@ function enterprise_include($filename)
} }
/**
* Includes a file from enterprise section.
*
* @param string $filename Target file.
*
* @return mixed Result code.
*/
function enterprise_include_once($filename) function enterprise_include_once($filename)
{ {
global $config; global $config;
// Load enterprise extensions // Load enterprise extensions.
if (defined('DESTDIR')) {
$destdir = DESTDIR;
} else {
$destdir = '';
}
$filepath = realpath($config['homedir'].'/'.ENTERPRISE_DIR.'/'.$filename); $filepath = realpath($config['homedir'].'/'.ENTERPRISE_DIR.'/'.$filename);
if ($filepath === false) { if ($filepath === false) {
@ -1574,6 +1633,11 @@ function safe_sql_string($string)
} }
/**
* Verifies if current Pandora FMS installation is a Metaconsole.
*
* @return boolean True metaconsole installation, false if not.
*/
function is_metaconsole() function is_metaconsole()
{ {
global $config; global $config;
@ -1581,6 +1645,18 @@ function is_metaconsole()
} }
/**
* Check if current Pandora FMS installation has joined a Metaconsole env.
*
* @return boolean True joined, false if not.
*/
function has_metaconsole()
{
global $config;
return (bool) $config['node_metaconsole'] && (bool) $config['metaconsole_node_id'];
}
/** /**
* @brief Check if there is management operations are allowed in current context * @brief Check if there is management operations are allowed in current context
* (node // meta) * (node // meta)
@ -1760,6 +1836,52 @@ function array_key_to_offset($array, $key)
} }
/**
* Undocumented function
*
* @param array $arguments Following format:
* [
* 'ip_target'
* 'snmp_version'
* 'snmp_community'
* 'snmp3_auth_user'
* 'snmp3_security_level'
* 'snmp3_auth_method'
* 'snmp3_auth_pass'
* 'snmp3_privacy_method'
* 'snmp3_privacy_pass'
* 'quick_print'
* 'base_oid'
* 'snmp_port'
* 'server_to_exec'
* 'extra_arguments'
* 'format'
* ]
*
* @return array SNMP result.
*/
function get_h_snmpwalk(array $arguments)
{
return get_snmpwalk(
$arguments['ip_target'],
$arguments['snmp_version'],
isset($arguments['snmp_community']) ? $arguments['snmp_community'] : '',
isset($arguments['snmp3_auth_user']) ? $arguments['snmp3_auth_user'] : '',
isset($arguments['snmp3_security_level']) ? $arguments['snmp3_security_level'] : '',
isset($arguments['snmp3_auth_method']) ? $arguments['snmp3_auth_method'] : '',
isset($arguments['snmp3_auth_pass']) ? $arguments['snmp3_auth_pass'] : '',
isset($arguments['snmp3_privacy_method']) ? $arguments['snmp3_privacy_method'] : '',
isset($arguments['snmp3_privacy_pass']) ? $arguments['snmp3_privacy_pass'] : '',
isset($arguments['quick_print']) ? $arguments['quick_print'] : 0,
isset($arguments['base_oid']) ? $arguments['base_oid'] : '',
isset($arguments['snmp_port']) ? $arguments['snmp_port'] : '',
isset($arguments['server_to_exec']) ? $arguments['server_to_exec'] : 0,
isset($arguments['extra_arguments']) ? $arguments['extra_arguments'] : '',
isset($arguments['format']) ? $arguments['format'] : '-Oa'
);
}
/** /**
* Make a snmpwalk and return it. * Make a snmpwalk and return it.
* *
@ -1880,11 +2002,16 @@ function get_snmpwalk(
exec($command_str, $output, $rc); exec($command_str, $output, $rc);
} }
// Parse the output of snmpwalk // Parse the output of snmpwalk.
$snmpwalk = []; $snmpwalk = [];
foreach ($output as $line) { foreach ($output as $line) {
// Separate the OID from the value // Separate the OID from the value.
$full_oid = explode(' = ', $line); if (strpos($format, 'q') === false) {
$full_oid = explode(' = ', $line, 2);
} else {
$full_oid = explode(' ', $line, 2);
}
if (isset($full_oid[1])) { if (isset($full_oid[1])) {
$snmpwalk[$full_oid[0]] = $full_oid[1]; $snmpwalk[$full_oid[0]] = $full_oid[1];
} }

View File

@ -1614,9 +1614,9 @@ function agents_get_interval($id_agent)
* *
* @param Agent object. * @param Agent object.
* *
* @return The interval value and status of last contact * @return The interval value and status of last contact or True /False
*/ */
function agents_get_interval_status($agent) function agents_get_interval_status($agent, $return_html=true)
{ {
$return = ''; $return = '';
$last_time = time_w_fixed_tz($agent['ultimo_contacto']); $last_time = time_w_fixed_tz($agent['ultimo_contacto']);
@ -1624,9 +1624,18 @@ function agents_get_interval_status($agent)
$diferencia = ($now - $last_time); $diferencia = ($now - $last_time);
$time = ui_print_timestamp($last_time, true, ['style' => 'font-size:6.5pt']); $time = ui_print_timestamp($last_time, true, ['style' => 'font-size:6.5pt']);
$min_interval = modules_get_agentmodule_mininterval_no_async($agent['id_agente']); $min_interval = modules_get_agentmodule_mininterval_no_async($agent['id_agente']);
$return = $time; if ($return_html) {
$return = $time;
} else {
$return = true;
}
if ($diferencia > ($min_interval['min_interval'] * 2) && $min_interval['num_interval'] > 0) { if ($diferencia > ($min_interval['min_interval'] * 2) && $min_interval['num_interval'] > 0) {
$return = '<b><span style="color: #ff0000;">'.$time.'</span></b>'; if ($return_html) {
$return = '<b><span style="color: #ff0000;">'.$time.'</span></b>';
} else {
$return = false;
}
} }
return $return; return $return;
@ -3367,3 +3376,35 @@ function agents_get_image_status($status)
return $image_status; return $image_status;
} }
/**
* Animation GIF to show agent's status.
*
* @return string HTML code with heartbeat image.
*/
function agents_get_status_animation($up=true)
{
switch ($up) {
case true:
default:
return html_print_image(
'images/heartbeat_green.gif',
true,
[
'width' => '170',
'height' => '40',
]
);
case false:
return html_print_image(
'images/heartbeat_red.gif',
true,
[
'width' => '170',
'height' => '40',
]
);
}
}

View File

@ -1783,12 +1783,14 @@ function alerts_validate_alert_agent_module($id_alert_agent_module, $noACLs=fals
['id' => $id] ['id' => $id]
); );
$template_name = io_safe_output(db_get_value('name', 'talert_templates', 'id', $alert['id_alert_template']));
$module_name = io_safe_output(db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $alert['id_agent_module']));
if ($result > 0) { if ($result > 0) {
// Update fired alert count on the agent // Update fired alert count on the agent
db_process_sql(sprintf('UPDATE tagente SET update_alert_count=1 WHERE id_agente = %d', $agent_id)); db_process_sql(sprintf('UPDATE tagente SET update_alert_count=1 WHERE id_agente = %d', $agent_id));
events_create_event( events_create_event(
'Manual validation of alert for '.alerts_get_alert_template_description($alert['id_alert_template']), 'Manual validation of alert '.$template_name.' assigned to '.$module_name.'',
$group_id, $group_id,
$agent_id, $agent_id,
1, 1,
@ -1914,7 +1916,6 @@ function alerts_get_agents_with_alert_template($id_alert_template, $id_group, $f
$filter[] = 'tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module'; $filter[] = 'tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module';
$filter[] = 'tagente_modulo.id_agente = tagente.id_agente'; $filter[] = 'tagente_modulo.id_agente = tagente.id_agente';
$filter['id_alert_template'] = $id_alert_template; $filter['id_alert_template'] = $id_alert_template;
$filter['tagente_modulo.disabled'] = '<> 1';
$filter['delete_pending'] = '<> 1'; $filter['delete_pending'] = '<> 1';
if (empty($id_agents)) { if (empty($id_agents)) {

View File

@ -11519,7 +11519,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
if ($other['data'][18] != '') { if ($other['data'][18] != '') {
$values['id_extra'] = $other['data'][18]; $values['id_extra'] = $other['data'][18];
$sql_validation = 'SELECT id_evento FROM tevento where estado=0 and id_extra ="'.$other['data'][18].'";'; $sql_validation = 'SELECT id_evento FROM tevento where estado IN (0,2) and id_extra ="'.$other['data'][18].'";';
$validation = db_get_all_rows_sql($sql_validation); $validation = db_get_all_rows_sql($sql_validation);
if ($validation) { if ($validation) {
foreach ($validation as $val) { foreach ($validation as $val) {

View File

@ -0,0 +1,439 @@
<?php
/**
* Credentials management auxiliary functions.
*
* @category Credentials management library.
* @package Pandora FMS
* @subpackage Opensource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 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.
/**
* Returns an array with all the credentials matching filter and ACL.
*
* @param array $fields Fields array or 'count' keyword to retrieve count.
* @param array $filter Filters to be applied.
* @param integer $offset Offset (pagination).
* @param integer $limit Limit (pagination).
* @param string $order Sort order.
* @param string $sort_field Sort field.
*
* @return array With all results or false if error.
* @throws Exception On error.
*/
function credentials_get_all(
$fields,
array $filter,
$offset=null,
$limit=null,
$order=null,
$sort_field=null
) {
$sql_filters = [];
$order_by = '';
$pagination = '';
global $config;
$user_is_admin = users_is_admin();
if (!is_array($filter)) {
error_log('[credential_get_all] Filter must be an array.');
throw new Exception('[credential_get_all] Filter must be an array.');
}
$count = false;
if (!is_array($fields) && $fields == 'count') {
$fields = ['cs.*'];
$count = true;
} else if (!is_array($fields)) {
error_log('[credential_get_all] Fields must be an array or "count".');
throw new Exception('[credential_get_all] Fields must be an array or "count".');
}
if (isset($filter['free_search']) && !empty($filter['free_search'])) {
$sql_filters[] = vsprintf(
' AND (lower(cs.username) like lower("%%%s%%")
OR cs.identifier like "%%%s%%"
OR lower(cs.product) like lower("%%%s%%"))',
array_fill(0, 3, $filter['free_search'])
);
}
if (isset($filter['filter_id_group']) && $filter['filter_id_group'] > 0) {
$propagate = db_get_value(
'propagate',
'tgrupo',
'id_grupo',
$filter['filter_id_group']
);
if (!$propagate) {
$sql_filters[] = sprintf(
' AND cs.id_group = %d ',
$filter['filter_id_group']
);
} else {
$groups = [ $filter['filter_id_group'] ];
$childrens = groups_get_childrens($id_group, null, true);
if (!empty($childrens)) {
foreach ($childrens as $child) {
$groups[] = (int) $child['id_grupo'];
}
}
$filter['filter_id_group'] = $groups;
$sql_filters[] = sprintf(
' AND cs.id_group IN (%s) ',
join(',', $filter['filter_id_group'])
);
}
}
if (isset($filter['group_list']) && is_array($filter['group_list'])) {
$sql_filters[] = sprintf(
' AND cs.id_group IN (%s) ',
join(',', $filter['group_list'])
);
}
if (isset($order)) {
$dir = 'asc';
if ($order == 'desc') {
$dir = 'desc';
};
if (in_array(
$sort_field,
[
'group',
'identifier',
'product',
'username',
'options',
]
)
) {
$order_by = sprintf(
'ORDER BY `%s` %s',
$sort_field,
$dir
);
}
}
if (isset($limit) && $limit > 0
&& isset($offset) && $offset >= 0
) {
$pagination = sprintf(
' LIMIT %d OFFSET %d ',
$limit,
$offset
);
}
$sql = sprintf(
'SELECT %s
FROM tcredential_store cs
LEFT JOIN tgrupo tg
ON tg.id_grupo = cs.id_group
WHERE 1=1
%s
%s
%s',
join(',', $fields),
join(',', $sql_filters),
$order_by,
$pagination
);
if ($count) {
$sql = sprintf('SELECT count(*) as n FROM ( %s ) tt', $sql);
return db_get_value_sql($sql);
}
return db_get_all_rows_sql($sql);
}
/**
* Retrieves target key from keystore or false in case of error.
*
* @param string $identifier Key identifier.
*
* @return array Key or false if error.
*/
function get_key($identifier)
{
return db_get_row_filter(
'tcredential_store',
[ 'identifier' => $identifier ]
);
}
/**
* Minor function to dump json message as ajax response.
*
* @param string $type Type: result || error.
* @param string $msg Message.
* @param boolean $delete Deletion messages.
*
* @return void
*/
function ajax_msg($type, $msg, $delete=false)
{
$msg_err = 'Failed while saving: %s';
$msg_ok = 'Successfully saved into keystore ';
if ($delete) {
$msg_err = 'Failed while removing: %s';
$msg_ok = 'Successfully deleted ';
}
if ($type == 'error') {
echo json_encode(
[
$type => ui_print_error_message(
__(
$msg_err,
$msg
),
'',
true
),
]
);
} else {
echo json_encode(
[
$type => ui_print_success_message(
__(
$msg_ok,
$msg
),
'',
true
),
]
);
}
exit;
}
/**
* Generates inputs for new/update forms.
*
* @param array $values Values or null.
*
* @return string Inputs.
*/
function print_inputs($values=null)
{
if (!is_array($values)) {
$values = [];
}
$return = '';
$return .= html_print_input(
[
'label' => __('Identifier'),
'name' => 'identifier',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $values['identifier'],
'disabled' => (bool) $values['identifier'],
'return' => true,
'script' => 'alert(\'puta\')',
]
);
$return .= html_print_input(
[
'label' => __('Group'),
'name' => 'id_group',
'id' => 'id_group',
'input_class' => 'flex-row',
'type' => 'select_groups',
'selected' => $values['id_group'],
'return' => true,
'class' => 'w50p',
]
);
$return .= html_print_input(
[
'label' => __('Product'),
'name' => 'product',
'input_class' => 'flex-row',
'type' => 'select',
'script' => 'calculate_inputs()',
'fields' => [
// 'CUSTOM' => __('Custom'),
'AWS' => __('Aws'),
// 'AZURE' => __('Azure'),
// 'GOOGLE' => __('Google'),
],
'selected' => $values['product'],
'disabled' => (bool) $values['product'],
'return' => true,
]
);
$user_label = __('Username');
$pass_label = __('Password');
$extra_1_label = __('Extra');
$extra_2_label = __('Extra (2)');
$extra1 = true;
$extra2 = true;
// Remember to update credential_store.php also.
switch ($values['product']) {
case 'AWS':
$user_label = __('Access key ID');
$pass_label = __('Secret access key');
$extra1 = false;
$extra2 = false;
break;
case 'AZURE':
$user_label = __('Account ID');
$pass_label = __('Password');
$extra_1_label = __('Tenant or domain name');
$extra_2_label = __('Subscription id');
break;
case 'GOOGLE':
// Need further investigation.
case 'CUSTOM':
default:
// Use defaults.
break;
}
$return .= html_print_input(
[
'label' => $user_label,
'name' => 'username',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $values['username'],
'return' => true,
]
);
$return .= html_print_input(
[
'label' => $pass_label,
'name' => 'password',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $values['password'],
'return' => true,
]
);
if ($extra1) {
$return .= html_print_input(
[
'label' => $extra_1_label,
'name' => 'extra_1',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $values['extra_1'],
'return' => true,
]
);
}
if ($extra2) {
$return .= html_print_input(
[
'label' => $extra_2_label,
'name' => 'extra_2',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $values['extra_2'],
'return' => true,
'display' => $extra2,
]
);
}
return $return;
}
/**
* Retrieve all identifiers available for current user.
*
* @param string $product Target product.
*
* @return array Of account identifiers.
*/
function credentials_list_accounts($product)
{
global $config;
check_login();
include_once $config['homedir'].'/include/functions_users.php';
static $user_groups;
if (!isset($user_groups)) {
$user_groups = users_get_groups(
$config['id_user'],
'AR'
);
// Always add group 'ALL' because 'ALL' group credentials
// must be available for all users.
if (is_array($user_groups)) {
$user_groups = ([0] + array_keys($user_groups));
} else {
$user_groups = [0];
}
}
$creds = credentials_get_all(
['identifier'],
[
'product' => $product,
'group_list' => $user_groups,
]
);
if ($creds === false) {
return [];
}
$ret = array_reduce(
$creds,
function ($carry, $item) {
$carry[$item['identifier']] = $item['identifier'];
return $carry;
}
);
return $ret;
}

View File

@ -184,7 +184,7 @@ function custom_graphs_search($id_group, $search)
FROM tgraph_source FROM tgraph_source
WHERE id_graph = '.$graph['id_graph'].'' WHERE id_graph = '.$graph['id_graph'].''
); );
$graphs[$graph['id_graph']]['id_graph'] = $graph['id_graph'];
$graphs[$graph['id_graph']]['graphs_count'] = $graphsCount; $graphs[$graph['id_graph']]['graphs_count'] = $graphsCount;
$graphs[$graph['id_graph']]['name'] = $graph['name']; $graphs[$graph['id_graph']]['name'] = $graph['name'];
$graphs[$graph['id_graph']]['description'] = $graph['description']; $graphs[$graph['id_graph']]['description'] = $graph['description'];

View File

@ -2023,3 +2023,58 @@ function db_check_minor_relase_available_to_um($package, $ent, $offline)
return false; return false;
} }
} }
/**
* Tries to get a lock with current name.
*
* @param string $lockname Lock name.
* @param integer $expiration_time Expiration time.
*
* @return integer 1 - lock OK, able to continue executing
* 0 - already locked by another process.
* NULL: something really bad happened
*/
function db_get_lock($lockname, $expiration_time=86400)
{
$lock_status = db_get_value_sql(
sprintf(
'SELECT IS_FREE_LOCK("%s")',
$lockname
)
);
if ($lock_status == 1) {
$lock_status = db_get_value_sql(
sprintf(
'SELECT GET_LOCK("%s", %d)',
$lockname,
$expiration_time
)
);
return $lock_status;
}
return 0;
}
/**
* Release a previously defined lock.
*
* @param string $lockname Lock name.
*
* @return integer 1 Lock released.
* 0 cannot release (not owned).
* NULL lock does not exist.
*/
function db_release_lock($lockname)
{
return db_get_value_sql(
sprintf(
'SELECT RELEASE_LOCK("%s")',
$lockname
)
);
}

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