mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 00:34:46 +02:00
conflict resolution
This commit is contained in:
commit
95d264059a
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735, AIX version
|
||||
# Version 7.0NG.736, AIX version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735, FreeBSD Version
|
||||
# Version 7.0NG.736, FreeBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# 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,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735, GNU/Linux
|
||||
# Version 7.0NG.736, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735, GNU/Linux
|
||||
# Version 7.0NG.736, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735, Solaris Version
|
||||
# Version 7.0NG.736, Solaris Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Base config file for Pandora FMS Windows Agent
|
||||
# (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
|
||||
# under the terms of the GNU General Public Licence as published by the Free Software
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.735, AIX version
|
||||
# Version 7.0NG.736, AIX version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.735
|
||||
# Version 7.0NG.736
|
||||
# FreeBSD/IPSO version
|
||||
# Licenced under GPL licence, 2003-2007 Sancho Lerena
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.735, HPUX Version
|
||||
# Version 7.0NG.736, HPUX Version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735
|
||||
# Version 7.0NG.736
|
||||
# Licensed under GPL license v2,
|
||||
# (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735
|
||||
# Version 7.0NG.736
|
||||
# Licensed under GPL license v2,
|
||||
# (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735
|
||||
# Version 7.0NG.736
|
||||
# Licensed under GPL license v2,
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.735, Solaris version
|
||||
# Version 7.0NG.736, Solaris version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735, AIX version
|
||||
# Version 7.0NG.736, AIX version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.735-190625
|
||||
Version: 7.0NG.736-190704
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -14,7 +14,7 @@
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.735-190625"
|
||||
pandora_version="7.0NG.736-190704"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735, GNU/Linux
|
||||
# Version 7.0NG.736, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2012 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735, FreeBSD Version
|
||||
# Version 7.0NG.736, FreeBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2016 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# 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,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735, GNU/Linux
|
||||
# Version 7.0NG.736, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2014 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735, GNU/Linux
|
||||
# Version 7.0NG.736, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735, NetBSD Version
|
||||
# Version 7.0NG.736, NetBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.735, Solaris Version
|
||||
# Version 7.0NG.736, Solaris Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -41,8 +41,8 @@ my $Sem = undef;
|
||||
# Semaphore used to control the number of threads
|
||||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.735';
|
||||
use constant AGENT_BUILD => '190625';
|
||||
use constant AGENT_VERSION => '7.0NG.736';
|
||||
use constant AGENT_BUILD => '190704';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
@ -2,8 +2,8 @@
|
||||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.735
|
||||
%define release 190625
|
||||
%define version 7.0NG.736
|
||||
%define release 190704
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -2,8 +2,8 @@
|
||||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.735
|
||||
%define release 190625
|
||||
%define version 7.0NG.736
|
||||
%define release 190704
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -9,8 +9,8 @@
|
||||
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.735"
|
||||
PI_BUILD="190625"
|
||||
PI_VERSION="7.0NG.736"
|
||||
PI_BUILD="190704"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Base config file for Pandora FMS Windows Agent
|
||||
# (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
|
||||
# under the terms of the GNU General Public Licence as published by the Free Software
|
||||
|
@ -3,7 +3,7 @@ AllowLanguageSelection
|
||||
{Yes}
|
||||
|
||||
AppName
|
||||
{Pandora FMS Windows Agent v7.0NG.735}
|
||||
{Pandora FMS Windows Agent v7.0NG.736}
|
||||
|
||||
ApplicationID
|
||||
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
|
||||
@ -186,7 +186,7 @@ UpgradeApplicationID
|
||||
{}
|
||||
|
||||
Version
|
||||
{190625}
|
||||
{190704}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
||||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.735(Build 190625)")
|
||||
#define PANDORA_VERSION ("7.0NG.736(Build 190704)")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
@ -11,7 +11,7 @@ BEGIN
|
||||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.735(Build 190625))"
|
||||
VALUE "ProductVersion", "(7.0NG.736(Build 190704))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-console
|
||||
Version: 7.0NG.735-190625
|
||||
Version: 7.0NG.736-190704
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -14,7 +14,7 @@
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.735-190625"
|
||||
pandora_version="7.0NG.736-190704"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
@ -69,7 +69,7 @@ function extension_db_status()
|
||||
|
||||
echo "<div style='text-align: right;'>";
|
||||
html_print_input_hidden('db_status_execute', 1);
|
||||
html_print_submit_button(__('Execute Test'), 'submit', false, 'class="sub"');
|
||||
html_print_submit_button(__('Execute Test'), 'submit', false, 'class="sub next"');
|
||||
echo '</div>';
|
||||
|
||||
echo '</form>';
|
||||
|
@ -1,26 +1,60 @@
|
||||
<?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
|
||||
// ==================================================
|
||||
// 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.
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
// Requires.
|
||||
require_once $config['homedir'].'/include/functions.php';
|
||||
|
||||
// This extension is usefull only if the agent has associated IP.
|
||||
$id_agente = get_parameter('id_agente');
|
||||
|
||||
// This extension is usefull only if the agent has associated IP
|
||||
$address = agents_get_address($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)
|
||||
{
|
||||
global $config;
|
||||
@ -63,6 +97,9 @@ function whereis_the_command($command)
|
||||
return $snmpget_path;
|
||||
}
|
||||
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 -> Extensions -> 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').' ';
|
||||
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)) {
|
||||
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 {
|
||||
switch ($operation) {
|
||||
case 1:
|
||||
@ -175,7 +147,7 @@ function main_net_tools()
|
||||
} else {
|
||||
echo '<h3>'.__('Traceroute to ').$ip.'</h3>';
|
||||
echo '<pre>';
|
||||
echo system("$traceroute $ip");
|
||||
echo system($traceroute.' '.$ip);
|
||||
echo '</pre>';
|
||||
}
|
||||
break;
|
||||
@ -187,7 +159,7 @@ function main_net_tools()
|
||||
} else {
|
||||
echo '<h3>'.__('Ping to %s', $ip).'</h3>';
|
||||
echo '<pre>';
|
||||
echo system("$ping -c 5 $ip");
|
||||
echo system($ping.' -c 5 '.$ip);
|
||||
echo '</pre>';
|
||||
}
|
||||
break;
|
||||
@ -199,7 +171,7 @@ function main_net_tools()
|
||||
} else {
|
||||
echo '<h3>'.__('Basic TCP Scan on ').$ip.'</h3>';
|
||||
echo '<pre>';
|
||||
echo system("$nmap -F $ip");
|
||||
echo system($nmap.' -F '.$ip);
|
||||
echo '</pre>';
|
||||
}
|
||||
break;
|
||||
@ -212,7 +184,7 @@ function main_net_tools()
|
||||
ui_print_error_message(__('Dig executable does not exist.'));
|
||||
} else {
|
||||
echo '<pre>';
|
||||
echo system("dig $ip");
|
||||
echo system('dig '.$ip);
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
@ -221,51 +193,227 @@ function main_net_tools()
|
||||
ui_print_error_message(__('Whois executable does not exist.'));
|
||||
} else {
|
||||
echo '<pre>';
|
||||
echo system("whois $ip");
|
||||
echo system('whois '.$ip);
|
||||
echo '</pre>';
|
||||
}
|
||||
break;
|
||||
|
||||
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>';
|
||||
|
||||
$snmpget = whereis_the_command('snmpget');
|
||||
if (empty($snmpget)) {
|
||||
ui_print_error_message(__('SNMPget executable does not exist.'));
|
||||
echo '<h4>'.__('Uptime').'</h4>';
|
||||
echo '<pre>';
|
||||
if (empty($result)) {
|
||||
ui_print_error_message(__('Target unreachable.'));
|
||||
break;
|
||||
} else {
|
||||
echo '<h4>'.__('Uptime').'</h4>';
|
||||
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 array_pop($result);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 -> Extensions -> 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').' ';
|
||||
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>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add option.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function godmode_net_tools()
|
||||
{
|
||||
global $config;
|
||||
|
@ -173,7 +173,7 @@ function pandora_realtime_graphs()
|
||||
$table->colspan[2]['snmp_oid'] = 2;
|
||||
|
||||
$data['snmp_ver'] = __('Version').' '.html_print_select($snmp_versions, 'snmp_version', $snmp_ver, '', '', 0, true);
|
||||
$data['snmp_ver'] .= ' '.html_print_button(__('SNMP walk'), 'snmp_walk', false, 'javascript:realtimeGraphs.snmpBrowserWindow();', 'class="sub next"', true);
|
||||
$data['snmp_ver'] .= ' '.html_print_button(__('SNMP walk'), 'snmp_walk', false, 'javascript:snmpBrowserWindow();', 'class="sub next"', true);
|
||||
$table->colspan[2]['snmp_ver'] = 2;
|
||||
|
||||
$table->data[] = $data;
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
var plot;
|
||||
var plotOptions = {
|
||||
legend: { container: $("#chartLegend") },
|
||||
legend: {
|
||||
container: $("#chartLegend")
|
||||
},
|
||||
xaxis: {
|
||||
tickFormatter: function(timestamp, axis) {
|
||||
var date = new Date(timestamp * 1000);
|
||||
@ -131,47 +133,6 @@
|
||||
resetDataPooling();
|
||||
}
|
||||
|
||||
// Set the form OID to the value selected in the SNMP browser
|
||||
function setOID() {
|
||||
if ($("#snmp_browser_version").val() == "3") {
|
||||
$("#text-snmp_oid").val($("#table1-0-1").text());
|
||||
} else {
|
||||
$("#text-snmp_oid").val($("#snmp_selected_oid").text());
|
||||
}
|
||||
|
||||
// Close the SNMP browser
|
||||
$(".ui-dialog-titlebar-close").trigger("click");
|
||||
}
|
||||
|
||||
// Show the SNMP browser window
|
||||
function snmpBrowserWindow() {
|
||||
// Keep elements in the form and the SNMP browser synced
|
||||
$("#text-target_ip").val($("#text-ip_target").val());
|
||||
$("#text-community").val($("#text-snmp_community").val());
|
||||
$("#snmp_browser_version").val($("#snmp_version").val());
|
||||
$("#snmp3_browser_auth_user").val($("#snmp3_auth_user").val());
|
||||
$("#snmp3_browser_security_level").val($("#snmp3_security_level").val());
|
||||
$("#snmp3_browser_auth_method").val($("#snmp3_auth_method").val());
|
||||
$("#snmp3_browser_auth_pass").val($("#snmp3_auth_pass").val());
|
||||
$("#snmp3_browser_privacy_method").val($("#snmp3_privacy_method").val());
|
||||
$("#snmp3_browser_privacy_pass").val($("#snmp3_privacy_pass").val());
|
||||
|
||||
$("#snmp_browser_container")
|
||||
.show()
|
||||
.dialog({
|
||||
title: "",
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
width: 920,
|
||||
height: 500
|
||||
});
|
||||
}
|
||||
|
||||
function shortNumber(number) {
|
||||
if (Math.round(number) != number) return number;
|
||||
number = Number.parseInt(number);
|
||||
@ -187,6 +148,7 @@
|
||||
|
||||
return number + " " + shorts[pos];
|
||||
}
|
||||
|
||||
function roundToTwo(num) {
|
||||
return +(Math.round(num + "e+2") + "e-2");
|
||||
}
|
||||
|
@ -1,6 +1,28 @@
|
||||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tmetaconsole_agent` ADD INDEX `id_tagente_idx` (`id_tagente`);
|
||||
|
||||
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;
|
||||
|
@ -1007,10 +1007,12 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` (
|
||||
`agent_version` varchar(100) default '',
|
||||
`ultimo_contacto_remoto` datetime default '1970-01-01 00:00:00',
|
||||
`disabled` tinyint(2) NOT NULL default '0',
|
||||
`remote` tinyint(1) NOT NULL default '0',
|
||||
`id_parent` int(10) unsigned default '0',
|
||||
`custom_id` varchar(255) default '',
|
||||
`server_name` varchar(100) default '',
|
||||
`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' ,
|
||||
`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' ,
|
||||
@ -1025,19 +1027,21 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` (
|
||||
`fired_count` bigint(20) NOT NULL default '0',
|
||||
`update_module_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`),
|
||||
KEY `nombre` (`nombre`(255)),
|
||||
KEY `direccion` (`direccion`),
|
||||
KEY `id_tagente_idx` (`id_tagente`),
|
||||
KEY `disabled` (`disabled`),
|
||||
KEY `id_grupo` (`id_grupo`),
|
||||
FOREIGN KEY (`id_tmetaconsole_setup`) REFERENCES tmetaconsole_setup(`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) 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`
|
||||
-- ---------------------------------------------------------------------
|
||||
@ -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 ('small_operation_step_datos_purge', '1000');
|
||||
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_support_logo', 'default_support.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';
|
||||
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');
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
@ -2192,3 +2196,16 @@ CREATE TABLE `tvisual_console_elements_cache` (
|
||||
ON UPDATE CASCADE
|
||||
) 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;
|
||||
|
@ -35,6 +35,7 @@ ui_require_css_file('firts_task');
|
||||
</p>
|
||||
<form action="index.php?sec=gservers&sec2=godmode/servers/discovery" method="post">
|
||||
<input type="submit" class="button_task" value="<?php echo __('Discover'); ?>" />
|
||||
<input type="hidden" name="discovery_hint" value="1"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -777,7 +777,7 @@ $table_adv_options = '
|
||||
'.$adv_secondary_groups_right.'
|
||||
</div>
|
||||
</div>
|
||||
<div class="adv_right" >
|
||||
<div class="agent_av_opt_right" >
|
||||
'.$table_adv_parent.$table_adv_module_mode.$table_adv_cascade;
|
||||
|
||||
if ($new_agent) {
|
||||
@ -788,7 +788,7 @@ if ($new_agent) {
|
||||
$table_adv_options .= '</div>';
|
||||
|
||||
$table_adv_options .= '
|
||||
<div class="adv_left" >
|
||||
<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>';
|
||||
|
||||
|
@ -23,7 +23,6 @@ $idAgent = (int) get_parameter('id_agente', 0);
|
||||
$ipAgent = db_get_value('direccion', 'tagente', 'id_agente', $idAgent);
|
||||
|
||||
check_login();
|
||||
|
||||
$ip_target = (string) get_parameter('ip_target', $ipAgent);
|
||||
$use_agent = get_parameter('use_agent');
|
||||
$snmp_community = (string) get_parameter('snmp_community', 'public');
|
||||
@ -469,6 +468,9 @@ if (enterprise_installed()) {
|
||||
if ($row['server_type'] != 13) {
|
||||
$s_type = ' (Standard)';
|
||||
} else {
|
||||
// Check if satellite server has remote configuration enabled
|
||||
$satellite_remote = config_agents_has_remote_configuration($id_agent);
|
||||
$id_satellite = $row['id_server'];
|
||||
$s_type = ' (Satellite)';
|
||||
}
|
||||
|
||||
@ -477,7 +479,17 @@ if (enterprise_installed()) {
|
||||
}
|
||||
|
||||
$table->data[1][2] = '<b>'.__('Server to execute command').'</b>';
|
||||
$table->data[1][3] = html_print_select($servers_to_exec, 'server_to_exec', $server_to_exec, '', '', '', true);
|
||||
$table->data[1][2] .= '<span id=satellite_remote_tip>'.ui_print_help_tip(__('In order to use remote executions you need to enable remote execution in satellite server'), true, 'images/tip_help.png', false, 'display:').'</span>';
|
||||
$table->data[1][4] = html_print_select(
|
||||
$servers_to_exec,
|
||||
'server_to_exec',
|
||||
$server_to_exec,
|
||||
'satellite_remote_warn('.$id_satellite.','.$satellite_remote.')
|
||||
',
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
$snmp_versions['1'] = 'v. 1';
|
||||
$snmp_versions['2'] = 'v. 2';
|
||||
@ -607,8 +619,12 @@ ui_require_jquery_file('bgiframe');
|
||||
/* <![CDATA[ */
|
||||
|
||||
$(document).ready (function () {
|
||||
|
||||
|
||||
var inputActive = true;
|
||||
|
||||
$('#server_to_exec option').trigger('change');
|
||||
|
||||
$(document).data('text_for_module', $("#none_text").html());
|
||||
|
||||
$("#id_snmp").change(snmp_changed_by_multiple_snmp);
|
||||
@ -628,6 +644,7 @@ $(document).ready (function () {
|
||||
$("#no_snmp").hide ();
|
||||
$("#form_interfaces").hide ();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
|
||||
@ -682,5 +699,20 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
|
||||
"json");
|
||||
}
|
||||
|
||||
|
||||
function satellite_remote_warn(id_satellite, remote)
|
||||
{
|
||||
if(!remote)
|
||||
{
|
||||
$('#server_to_exec option[value='+id_satellite+']').prop('disabled', true);
|
||||
$('#satellite_remote_tip').removeAttr("style").show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#satellite_remote_tip').removeAttr("style").hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ]]> */
|
||||
</script>
|
||||
|
@ -1213,7 +1213,7 @@ if ($update_module || $create_module) {
|
||||
|
||||
$max_timeout = (int) get_parameter('max_timeout');
|
||||
$max_retries = (int) get_parameter('max_retries');
|
||||
$min = (int) get_parameter_post('min');
|
||||
$min = (int) get_parameter('min');
|
||||
$max = (int) get_parameter('max');
|
||||
$interval = (int) get_parameter('module_interval', $intervalo);
|
||||
$ff_interval = (int) get_parameter('module_ff_interval');
|
||||
|
@ -163,7 +163,7 @@ echo '<td>';
|
||||
|
||||
echo __('Group').' ';
|
||||
$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, 'AR') && !check_acl($config['id_user'], 0, 'AW')) {
|
||||
$return_all_group = false;
|
||||
} else {
|
||||
$return_all_group = true;
|
||||
@ -680,7 +680,7 @@ if ($agents !== false) {
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
ui_pagination($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled&os=$os", $offset, 0, false, 'offset', true, 'pagination-bottom');
|
||||
ui_pagination($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled&os=$os", $offset);
|
||||
echo "<table width='100%'><tr><td align='right'>";
|
||||
} else {
|
||||
ui_print_info_message(['no_close' => true, 'message' => __('There are no defined agents') ]);
|
||||
|
@ -267,10 +267,10 @@ if ($id_agent_module) {
|
||||
$cron_interval = explode(' ', $module['cron_interval']);
|
||||
if (isset($cron_interval[4])) {
|
||||
$minute_from = $cron_interval[0];
|
||||
$min = explode('-', $minute_from);
|
||||
$minute_from = $min[0];
|
||||
if (isset($min[1])) {
|
||||
$minute_to = $min[1];
|
||||
$minute = explode('-', $minute_from);
|
||||
$minute_from = $minute[0];
|
||||
if (isset($minute[1])) {
|
||||
$minute_to = $minute[1];
|
||||
}
|
||||
|
||||
$hour_from = $cron_interval[1];
|
||||
|
@ -506,45 +506,5 @@ $(document).ready (function () {
|
||||
});
|
||||
});
|
||||
|
||||
// Show the SNMP browser window
|
||||
function snmpBrowserWindow () {
|
||||
|
||||
// Keep elements in the form and the SNMP browser synced
|
||||
$('#text-target_ip').val($('#text-ip_target').val());
|
||||
$('#text-community').val($('#text-snmp_community').val());
|
||||
$('#snmp_browser_version').val($('#snmp_version').val());
|
||||
$('#text-snmp3_browser_auth_user').val($('#text-snmp3_auth_user').val());
|
||||
$('#snmp3_browser_security_level').val($('#snmp3_security_level').val());
|
||||
$('#snmp3_browser_auth_method').val($('#snmp3_auth_method').val());
|
||||
$('#password-snmp3_browser_auth_pass').val($('#password-snmp3_auth_pass').val());
|
||||
$('#snmp3_browser_privacy_method').val($('#snmp3_privacy_method').val());
|
||||
$('#password-snmp3_browser_privacy_pass').val($('#password-snmp3_privacy_pass').val());
|
||||
|
||||
$("#snmp_browser_container").show().dialog ({
|
||||
title: '',
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
width: 920,
|
||||
height: 500
|
||||
});
|
||||
}
|
||||
|
||||
// Set the form OID to the value selected in the SNMP browser
|
||||
function setOID () {
|
||||
|
||||
if($('#snmp_browser_version').val() == '3'){
|
||||
$('#text-snmp_oid').val($('#table1-0-1').text());
|
||||
} else {
|
||||
$('#text-snmp_oid').val($('#snmp_selected_oid').text());
|
||||
}
|
||||
|
||||
// Close the SNMP browser
|
||||
$('.ui-dialog-titlebar-close').trigger('click');
|
||||
}
|
||||
|
||||
</script>
|
||||
|
@ -52,7 +52,7 @@ if ($migrate_malformed) {
|
||||
|
||||
// Header.
|
||||
ui_print_page_header(
|
||||
__('Planned Downtime'),
|
||||
__('Scheduled Downtime'),
|
||||
'images/gm_monitoring.png',
|
||||
false,
|
||||
'planned_downtime',
|
||||
@ -136,9 +136,6 @@ $table_form = new StdClass();
|
||||
$table_form->class = 'databox filters';
|
||||
$table_form->width = '100%';
|
||||
$table_form->rowstyle = [];
|
||||
$table_form->rowstyle[0] = 'background-color: #f9faf9;';
|
||||
$table_form->rowstyle[1] = 'background-color: #f9faf9;';
|
||||
$table_form->rowstyle[2] = 'background-color: #f9faf9;';
|
||||
$table_form->data = [];
|
||||
|
||||
$row = [];
|
||||
|
@ -113,6 +113,8 @@ $fields_available['instructions'] = __('Instructions');
|
||||
$fields_available['server_name'] = __('Server Name');
|
||||
$fields_available['data'] = __('Data');
|
||||
$fields_available['module_status'] = __('Module Status');
|
||||
$fields_available['mini_severity'] = __('Severity mini');
|
||||
|
||||
|
||||
// Remove fields already selected.
|
||||
foreach ($fields_available as $key => $available) {
|
||||
@ -124,7 +126,7 @@ foreach ($fields_available as $key => $available) {
|
||||
$table->data[0][0] = '<b>'.__('Fields available').'</b>';
|
||||
$table->data[1][0] = html_print_select($fields_available, 'fields_available[]', true, '', '', 0, true, true, false, '', false, 'width: 300px');
|
||||
$table->data[1][1] = '<a href="javascript:">'.html_print_image(
|
||||
'images/darrowright.png',
|
||||
'images/darrowright_green.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'right',
|
||||
@ -132,7 +134,7 @@ $table->data[1][1] = '<a href="javascript:">'.html_print_image(
|
||||
]
|
||||
).'</a>';
|
||||
$table->data[1][1] .= '<br><br><br><br><a href="javascript:">'.html_print_image(
|
||||
'images/darrowleft.png',
|
||||
'images/darrowleft_green.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'left',
|
||||
|
@ -50,17 +50,10 @@ if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
'text' => '<a href="index.php?sec=eventos&sec2=godmode/events/events&section=responses&pure='.$config['pure'].'">'.html_print_image('images/event_responses.png', true, ['title' => __('Event responses')]).'</a>',
|
||||
];
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
$buttons['fields'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=eventos&sec2=godmode/events/events&section=fields&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&section=fields&pure='.$config['pure'].'">'.html_print_image('images/custom_columns.png', true, ['title' => __('Custom fields')]).'</a>',
|
||||
];
|
||||
}
|
||||
$buttons['fields'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=eventos&sec2=godmode/events/events&section=fields&pure='.$config['pure'].'">'.html_print_image('images/custom_columns.png', true, ['title' => __('Custom fields')]).'</a>',
|
||||
];
|
||||
}
|
||||
|
||||
switch ($section) {
|
||||
|
632
pandora_console/godmode/groups/credential_store.php
Normal file
632
pandora_console/godmode/groups/credential_store.php
Normal 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>
|
@ -1,20 +1,36 @@
|
||||
<?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
|
||||
// ==================================================
|
||||
// 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.
|
||||
// Begin.
|
||||
ui_require_css_file('tree');
|
||||
ui_require_css_file('fixed-bottom-box');
|
||||
|
||||
// Load global vars
|
||||
// Load global vars.
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
@ -76,15 +92,17 @@ if (is_ajax()) {
|
||||
$recursion = (int) get_parameter('recursion', 0);
|
||||
$privilege = (string) get_parameter('privilege', '');
|
||||
$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', '');
|
||||
// This attr is for the operation "bulk alert accions add", it controls the query that take the agents
|
||||
// from db
|
||||
// This attr is for the operation "bulk alert accions add", it controls
|
||||
// the query that take the agents from db.
|
||||
$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', '');
|
||||
$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);
|
||||
$serialized = (bool) get_parameter('serialized', false);
|
||||
$serialized_separator = (string) get_parameter('serialized_separator', '|');
|
||||
@ -121,7 +139,7 @@ if (is_ajax()) {
|
||||
$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 ';
|
||||
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\'';
|
||||
@ -131,8 +149,9 @@ if (is_ajax()) {
|
||||
$id_groups_get_agents = $id_group;
|
||||
if ($id_group == 0 && $privilege != '') {
|
||||
$groups = users_get_groups($config['id_user'], $privilege, false);
|
||||
// if group ID doesn't matter and $privilege is specified (like 'AW'),
|
||||
// retruns all agents that current user has $privilege privilege for.
|
||||
// If group ID doesn't matter and $privilege is specified
|
||||
// (like 'AW'), retruns all agents that current user has $privilege
|
||||
// privilege for.
|
||||
$id_groups_get_agents = array_keys($groups);
|
||||
}
|
||||
|
||||
@ -149,13 +168,13 @@ if (is_ajax()) {
|
||||
);
|
||||
|
||||
$agents_disabled = [];
|
||||
// Add keys prefix
|
||||
// Add keys prefix.
|
||||
if ($keys_prefix !== '') {
|
||||
foreach ($agents as $k => $v) {
|
||||
$agents[$keys_prefix.$k] = $v;
|
||||
unset($agents[$k]);
|
||||
if ($all_agents) {
|
||||
// Unserialize to get the status
|
||||
// Unserialize to get the status.
|
||||
if ($serialized && is_metaconsole()) {
|
||||
$agent_info = explode($serialized_separator, $k);
|
||||
$agent_disabled = db_get_value_filter(
|
||||
@ -174,7 +193,8 @@ if (is_ajax()) {
|
||||
['id_agente' => $agent_info[1]]
|
||||
);
|
||||
} 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;
|
||||
} else {
|
||||
$agent_disabled = db_get_value_filter(
|
||||
@ -226,11 +246,13 @@ if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
}
|
||||
|
||||
$sec = defined('METACONSOLE') ? 'advanced' : 'gagente';
|
||||
$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";
|
||||
$url_credbox = 'index.php?sec='.$sec.'&sec2=godmode/groups/group_list&tab=credbox';
|
||||
$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'] = [
|
||||
'active' => false,
|
||||
'text' => "<a href='$url_tree'>".html_print_image(
|
||||
'text' => '<a href="'.$url_tree.'">'.html_print_image(
|
||||
'images/gm_massive_operations.png',
|
||||
true,
|
||||
[
|
||||
@ -241,7 +263,7 @@ $buttons['tree'] = [
|
||||
|
||||
$buttons['groups'] = [
|
||||
'active' => false,
|
||||
'text' => "<a href='$url_groups'>".html_print_image(
|
||||
'text' => '<a href="'.$url_groups.'">'.html_print_image(
|
||||
'images/group.png',
|
||||
true,
|
||||
[
|
||||
@ -250,21 +272,38 @@ $buttons['groups'] = [
|
||||
).'</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');
|
||||
|
||||
// Marks correct tab
|
||||
$title = __('Groups defined in %s', get_product_name());
|
||||
// Marks correct tab.
|
||||
switch ($tab) {
|
||||
case 'tree':
|
||||
$buttons['tree']['active'] = true;
|
||||
break;
|
||||
|
||||
case 'credbox':
|
||||
$buttons['credbox']['active'] = true;
|
||||
$title = __('Credential store');
|
||||
break;
|
||||
|
||||
case 'groups':
|
||||
default:
|
||||
$buttons['groups']['active'] = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Header
|
||||
// Header.
|
||||
if (defined('METACONSOLE')) {
|
||||
agents_meta_print_header();
|
||||
echo '<div class="notify">';
|
||||
@ -272,7 +311,7 @@ if (defined('METACONSOLE')) {
|
||||
echo '</div>';
|
||||
} else {
|
||||
ui_print_page_header(
|
||||
__('Groups defined in %s', get_product_name()),
|
||||
$title,
|
||||
'images/group.png',
|
||||
false,
|
||||
'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');
|
||||
$update_group = (bool) get_parameter('update_group');
|
||||
$delete_group = (bool) get_parameter('delete_group');
|
||||
$pure = get_parameter('pure', 0);
|
||||
|
||||
// Create group
|
||||
// Create group.
|
||||
if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) {
|
||||
$name = (string) get_parameter('name');
|
||||
$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);
|
||||
$propagate = (bool) get_parameter('propagate');
|
||||
|
||||
// Check if name field is empty
|
||||
// Check if name field is empty.
|
||||
if ($name != '') {
|
||||
if (!$check) {
|
||||
$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'));
|
||||
}
|
||||
} else {
|
||||
// $result = false;
|
||||
ui_print_error_message(__('Group must have a name'));
|
||||
}
|
||||
}
|
||||
|
||||
// Update group
|
||||
// Update group.
|
||||
if ($update_group) {
|
||||
$id_group = (int) get_parameter('id_group');
|
||||
$name = (string) get_parameter('name');
|
||||
@ -349,49 +394,35 @@ if ($update_group) {
|
||||
$contact = (string) get_parameter('contact');
|
||||
$other = (string) get_parameter('other');
|
||||
|
||||
// Check if name field is empty
|
||||
// Check if name field is empty.
|
||||
if ($name != '') {
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
$sql = sprintf(
|
||||
'UPDATE tgrupo SET nombre = "%s",
|
||||
icon = "%s", disabled = %d, parent = %d, custom_id = "%s", propagate = %d, id_skin = %d, description = "%s", contact = "%s", other = "%s", password = "%s"
|
||||
WHERE id_grupo = %d',
|
||||
$name,
|
||||
empty($icon) ? '' : substr($icon, 0, -4),
|
||||
!$alerts_enabled,
|
||||
$id_parent,
|
||||
$custom_id,
|
||||
$propagate,
|
||||
$skin,
|
||||
$description,
|
||||
$contact,
|
||||
$other,
|
||||
$group_pass,
|
||||
$id_group
|
||||
);
|
||||
break;
|
||||
|
||||
case 'postgresql':
|
||||
case 'oracle':
|
||||
$sql = sprintf(
|
||||
'UPDATE tgrupo SET nombre = \'%s\',
|
||||
icon = \'%s\', disabled = %d, parent = %d, custom_id = \'%s\', propagate = %d, id_skin = %d, description = \'%s\', contact = \'%s\', other = \'%s\'
|
||||
WHERE id_grupo = %d',
|
||||
$name,
|
||||
substr($icon, 0, -4),
|
||||
!$alerts_enabled,
|
||||
$id_parent,
|
||||
$custom_id,
|
||||
$propagate,
|
||||
$skin,
|
||||
$description,
|
||||
$contact,
|
||||
$other,
|
||||
$id_group
|
||||
);
|
||||
break;
|
||||
}
|
||||
$sql = sprintf(
|
||||
'UPDATE tgrupo
|
||||
SET nombre = "%s",
|
||||
icon = "%s",
|
||||
disabled = %d,
|
||||
parent = %d,
|
||||
custom_id = "%s",
|
||||
propagate = %d,
|
||||
id_skin = %d,
|
||||
description = "%s",
|
||||
contact = "%s",
|
||||
other = "%s",
|
||||
password = "%s"
|
||||
WHERE id_grupo = %d',
|
||||
$name,
|
||||
empty($icon) ? '' : substr($icon, 0, -4),
|
||||
!$alerts_enabled,
|
||||
$id_parent,
|
||||
$custom_id,
|
||||
$propagate,
|
||||
$skin,
|
||||
$description,
|
||||
$contact,
|
||||
$other,
|
||||
$group_pass,
|
||||
$id_group
|
||||
);
|
||||
|
||||
$result = db_process_sql($sql);
|
||||
} else {
|
||||
@ -405,7 +436,7 @@ if ($update_group) {
|
||||
}
|
||||
}
|
||||
|
||||
// Delete group
|
||||
// Delete group.
|
||||
if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
|
||||
$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') {
|
||||
/*
|
||||
* Group tree view.
|
||||
*/
|
||||
|
||||
echo html_print_image(
|
||||
'images/spinner.gif',
|
||||
true,
|
||||
@ -456,6 +494,10 @@ if ($tab == 'tree') {
|
||||
);
|
||||
echo "<div id='tree-controller-recipient'></div>";
|
||||
} else {
|
||||
/*
|
||||
* Group list view.
|
||||
*/
|
||||
|
||||
$acl = '';
|
||||
$search_name = '';
|
||||
$offset = (int) get_parameter('offset', 0);
|
||||
@ -463,17 +505,22 @@ if ($tab == 'tree') {
|
||||
$block_size = $config['block_size'];
|
||||
|
||||
if (!empty($search)) {
|
||||
$search_name = "AND t.nombre LIKE '%$search%'";
|
||||
$search_name = 'AND t.nombre LIKE "%'.$search.'%"';
|
||||
}
|
||||
|
||||
if (!users_can_manage_group_all('AR')) {
|
||||
$user_groups_acl = users_get_groups(false, 'AR');
|
||||
$groups_acl = implode(',', $user_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=''>";
|
||||
@ -488,29 +535,37 @@ if ($tab == 'tree') {
|
||||
|
||||
echo $form;
|
||||
|
||||
$groups_sql = "SELECT t.*,
|
||||
$groups_sql = sprintf(
|
||||
'SELECT t.*,
|
||||
p.nombre AS parent_name,
|
||||
IF(t.parent=p.id_grupo, 1, 0) AS has_child
|
||||
FROM tgrupo t
|
||||
LEFT JOIN tgrupo p
|
||||
FROM tgrupo t
|
||||
LEFT JOIN tgrupo p
|
||||
ON t.parent=p.id_grupo
|
||||
WHERE 1=1
|
||||
$acl
|
||||
$search_name
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
ORDER BY nombre
|
||||
LIMIT $offset, $block_size
|
||||
";
|
||||
LIMIT %d, %d',
|
||||
$acl,
|
||||
$search_name,
|
||||
$offset,
|
||||
$block_size
|
||||
);
|
||||
|
||||
$groups = db_get_all_rows_sql($groups_sql);
|
||||
|
||||
if (!empty($groups)) {
|
||||
// Count all groups for pagination only saw user and filters
|
||||
$groups_sql_count = "SELECT count(*)
|
||||
// Count all groups for pagination only saw user and filters.
|
||||
$groups_sql_count = sprintf(
|
||||
'SELECT count(*)
|
||||
FROM tgrupo t
|
||||
WHERE 1=1
|
||||
$acl
|
||||
$search_name
|
||||
";
|
||||
%s
|
||||
%s',
|
||||
$acl,
|
||||
$search_name
|
||||
);
|
||||
$groups_count = db_get_value_sql($groups_sql_count);
|
||||
|
||||
$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_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][1] = "<a href='$url'>".$group['nombre'].'</a>';
|
||||
$table->data[$key][1] = '<a href="'.$url.'">'.$group['nombre'].'</a>';
|
||||
if ($group['icon'] != '') {
|
||||
$table->data[$key][2] = html_print_image(
|
||||
'images/groups_small/'.$group['icon'].'.png',
|
||||
@ -553,22 +608,25 @@ if ($tab == 'tree') {
|
||||
[
|
||||
'style' => '',
|
||||
'class' => 'bot',
|
||||
'alt' => $group['nombre'],
|
||||
'alt' => $group['nombre'],
|
||||
'title' => $group['nombre'],
|
||||
false, false, false, true
|
||||
]
|
||||
],
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$table->data[$key][2] = '';
|
||||
}
|
||||
|
||||
|
||||
// reporting_get_group_stats
|
||||
$table->data[$key][3] = $group['disabled'] ? __('Disabled') : __('Enabled');
|
||||
// Reporting_get_group_stats.
|
||||
$table->data[$key][3] = ($group['disabled']) ? __('Disabled') : __('Enabled');
|
||||
$table->data[$key][4] = $group['parent_name'];
|
||||
$table->data[$key][5] = $group['description'];
|
||||
$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',
|
||||
true,
|
||||
[
|
||||
|
@ -177,6 +177,9 @@ $table->data['operations'][1] .= html_print_checkbox('copy_alerts', 1, true, tru
|
||||
$table->data['operations'][1] .= html_print_label(__('Copy alerts'), 'checkbox-copy_alerts', true);
|
||||
$table->data['operations'][1] .= '</span>';
|
||||
|
||||
$table->data['form_modules_filter'][0] = __('Filter Modules');
|
||||
$table->data['form_modules_filter'][1] = html_print_input_text('filter_modules', '', '', 20, 255, true);
|
||||
|
||||
$table->data[1][0] = __('Modules');
|
||||
$table->data[1][1] = '<span class="with_modules'.(empty($modules) ? ' invisible' : '').'">';
|
||||
$table->data[1][1] .= html_print_select(
|
||||
@ -302,6 +305,8 @@ echo '<h3 class="error invisible" id="message"> </h3>';
|
||||
ui_require_jquery_file('form');
|
||||
ui_require_jquery_file('pandora.controls');
|
||||
?>
|
||||
|
||||
<script type="text/javascript" src="include/javascript/pandora_modules.js"></script>
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
var module_alerts;
|
||||
@ -478,6 +483,9 @@ $(document).ready (function () {
|
||||
}
|
||||
$("#fieldset_targets").show ();
|
||||
$("#target_modules, #target_alerts").enable ();
|
||||
//Filter modules. Call the function when the select is fully loaded.
|
||||
var textNoData = "<?php echo __('None'); ?>";
|
||||
filterByText($('#target_modules'), $("#text-filter_modules"), textNoData);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
@ -429,6 +429,11 @@ $table->data['form_modules_3'][1] = html_print_select(
|
||||
);
|
||||
$table->data['form_modules_3'][3] = '';
|
||||
|
||||
$table->rowstyle['form_modules_filter'] = 'vertical-align: top;';
|
||||
$table->rowclass['form_modules_filter'] = 'select_modules_row select_modules_row_2';
|
||||
$table->data['form_modules_filter'][0] = __('Filter Modules');
|
||||
$table->data['form_modules_filter'][1] = html_print_input_text('filter_modules', '', '', 20, 255, true);
|
||||
|
||||
$table->rowstyle['form_modules_2'] = 'vertical-align: top;';
|
||||
$table->rowclass['form_modules_2'] = 'select_modules_row select_modules_row_2';
|
||||
$table->data['form_modules_2'][0] = __('Modules');
|
||||
@ -571,6 +576,7 @@ if ($selection_mode == 'modules') {
|
||||
}
|
||||
?>
|
||||
|
||||
<script type="text/javascript" src="include/javascript/pandora_modules.js"></script>
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
|
||||
@ -650,6 +656,9 @@ $(document).ready (function () {
|
||||
});
|
||||
$("#module_loading").hide();
|
||||
$("#module_name").removeAttr ("disabled");
|
||||
//Filter modules. Call the function when the select is fully loaded.
|
||||
var textNoData = "<?php echo __('None'); ?>";
|
||||
filterByText($('#module_name'), $("#text-filter_modules"), textNoData);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
@ -388,6 +388,11 @@ $table->data['form_modules_4'][1] = html_print_select(
|
||||
true
|
||||
);
|
||||
|
||||
$table->rowstyle['form_modules_filter'] = 'vertical-align: top;';
|
||||
$table->rowclass['form_modules_filter'] = 'select_modules_row select_modules_row_2';
|
||||
$table->data['form_modules_filter'][0] = __('Filter Modules');
|
||||
$table->data['form_modules_filter'][1] = html_print_input_text('filter_modules', '', '', 20, 255, true);
|
||||
|
||||
$table->rowstyle['form_modules_2'] = 'vertical-align: top;';
|
||||
$table->rowclass['form_modules_2'] = 'select_modules_row select_modules_row_2';
|
||||
$table->data['form_modules_2'][0] = __('Modules');
|
||||
@ -1247,6 +1252,9 @@ $(document).ready (function () {
|
||||
});
|
||||
$("#module_loading").hide ();
|
||||
$("#module_name").removeAttr ("disabled");
|
||||
//Filter modules. Call the function when the select is fully loaded.
|
||||
var textNoData = "<?php echo __('None'); ?>";
|
||||
filterByText($('#module_name'), $("#text-filter_modules"), textNoData);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
@ -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
|
||||
$menu_godmode['gservers']['text'] = __('Servers');
|
||||
$menu_godmode['gservers']['sec2'] = 'godmode/servers/modificar_server';
|
||||
|
@ -277,7 +277,7 @@ if (isset($data)) {
|
||||
}
|
||||
|
||||
|
||||
echo '<form method="post">';
|
||||
echo '<form method="post" action='.$url.'>';
|
||||
echo '<div class="" style="float:right;">';
|
||||
html_print_input_hidden('new', 1);
|
||||
html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"');
|
||||
|
@ -582,6 +582,9 @@ switch ($action) {
|
||||
|
||||
$filter_search = $style['event_filter_search'];
|
||||
|
||||
$filter_event_severity = json_decode($style['filter_event_severity'], true);
|
||||
$filter_event_status = json_decode($style['filter_event_status'], true);
|
||||
$filter_event_type = json_decode($style['filter_event_type'], true);
|
||||
|
||||
|
||||
$include_extended_events = $item['show_extended_events'];
|
||||
@ -4286,6 +4289,8 @@ function chooseType() {
|
||||
$("#row_event_filter").show();
|
||||
$("#row_event_graphs").show();
|
||||
|
||||
|
||||
|
||||
$("#row_event_graph_by_agent").show();
|
||||
$("#row_event_graph_by_user").show();
|
||||
$("#row_event_graph_by_criticity").show();
|
||||
@ -4293,6 +4298,11 @@ function chooseType() {
|
||||
$("#row_extended_events").show();
|
||||
|
||||
$("#row_filter_search").show();
|
||||
|
||||
$("#row_event_severity").show();
|
||||
$("#row_event_status").show();
|
||||
$("#row_event_type").show();
|
||||
|
||||
$("#row_historical_db_check").hide();
|
||||
break;
|
||||
|
||||
|
@ -254,10 +254,12 @@ function update_button_palette_callback() {
|
||||
var values = {};
|
||||
|
||||
values = readFields();
|
||||
if (values["map_linked"] == 0) {
|
||||
if (values["agent"] == "" || values["agent"] == "none") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
return false;
|
||||
if (selectedItem == "static_graph") {
|
||||
if (values["map_linked"] == 0) {
|
||||
if (values["agent"] == "" || values["agent"] == "none") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO VALIDATE DATA
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ if (($create != '') || ($view != '')) {
|
||||
} else {
|
||||
if ($create != '') {
|
||||
ui_print_page_header(
|
||||
__('Plugin creation'),
|
||||
__('Plugin registration'),
|
||||
'images/gm_servers.png',
|
||||
false,
|
||||
'plugin_definition',
|
||||
|
@ -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][1] = html_print_input_text(
|
||||
'graphviz_bin_dir',
|
||||
|
@ -699,7 +699,7 @@ class DiscoveryTaskList extends Wizard
|
||||
if ($script !== false) {
|
||||
switch ($script['type']) {
|
||||
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:
|
||||
return 'wiz=app&mode=vmware&page=0';
|
||||
@ -722,10 +722,10 @@ class DiscoveryTaskList extends Wizard
|
||||
|
||||
case DISCOVERY_CLOUD_AWS:
|
||||
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:
|
||||
return 'wiz=cloud&mode=amazonws&sub=rds&page=0';
|
||||
return 'wiz=cloud&mode=amazonws&ki='.$task['auth_strings'].'&sub=rds&page=0';
|
||||
|
||||
default:
|
||||
if ($task['description'] == 'console_task') {
|
||||
|
@ -1048,7 +1048,7 @@ class Wizard
|
||||
*/
|
||||
public static function printBigButtonsList($list_data)
|
||||
{
|
||||
echo '<ul>';
|
||||
echo '<ul class="bigbuttonlist">';
|
||||
array_map('self::printBigButtonElement', $list_data);
|
||||
echo '</ul>';
|
||||
}
|
||||
|
@ -75,13 +75,73 @@ $graphic_event_group = (bool) get_parameter('graphic_event_group');
|
||||
$get_table_response_command = (bool) get_parameter('get_table_response_command');
|
||||
$save_filter_modal = get_parameter('save_filter_modal', 0);
|
||||
$load_filter_modal = get_parameter('load_filter_modal', 0);
|
||||
$save_filter = get_parameter('save_filter', 0);
|
||||
$get_filter_values = get_parameter('get_filter_values', 0);
|
||||
$update_event_filter = get_parameter('update_event_filter', 0);
|
||||
$save_event_filter = get_parameter('save_event_filter', 0);
|
||||
$in_process_event = get_parameter('in_process_event', 0);
|
||||
$validate_event = get_parameter('validate_event', 0);
|
||||
$delete_event = get_parameter('delete_event', 0);
|
||||
$get_event_filters = get_parameter('get_event_filters', 0);
|
||||
$get_comments = get_parameter('get_comments', 0);
|
||||
|
||||
if ($get_comments) {
|
||||
$event = get_parameter('event', false);
|
||||
$filter = get_parameter('filter', false);
|
||||
|
||||
if ($event === false) {
|
||||
return __('Failed to retrieve comments');
|
||||
}
|
||||
|
||||
if ($filter['group_rep'] == 1) {
|
||||
$events = events_get_all(
|
||||
['te.*'],
|
||||
// Filter.
|
||||
$filter,
|
||||
// Offset.
|
||||
null,
|
||||
// Limit.
|
||||
null,
|
||||
// Order.
|
||||
null,
|
||||
// Sort_field.
|
||||
null,
|
||||
// History.
|
||||
$filter['history'],
|
||||
// Return_sql.
|
||||
false,
|
||||
// Having.
|
||||
sprintf(
|
||||
' HAVING max_id_evento = %d',
|
||||
$event['id_evento']
|
||||
)
|
||||
);
|
||||
if ($events !== false) {
|
||||
$event = $events[0];
|
||||
}
|
||||
} else {
|
||||
$events = events_get_event(
|
||||
$event['id_evento'],
|
||||
false,
|
||||
$meta,
|
||||
$history
|
||||
);
|
||||
|
||||
if ($events !== false) {
|
||||
$event = $events[0];
|
||||
}
|
||||
}
|
||||
|
||||
echo events_page_comments($event, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_event_filters) {
|
||||
$event_filter = events_get_event_filter_select();
|
||||
|
||||
echo io_json_mb_encode($event_filter);
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete event (filtered or not).
|
||||
if ($delete_event) {
|
||||
@ -267,6 +327,17 @@ if ($get_filter_values) {
|
||||
|
||||
$event_filter = events_get_event_filter($id_filter);
|
||||
|
||||
if ($event_filter === false) {
|
||||
$event_filter = [
|
||||
'status' => EVENT_NO_VALIDATED,
|
||||
'event_view_hr' => $config['event_view_hr'],
|
||||
'group_rep' => 1,
|
||||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'history' => false,
|
||||
];
|
||||
}
|
||||
|
||||
$event_filter['search'] = io_safe_output($event_filter['search']);
|
||||
$event_filter['id_name'] = io_safe_output($event_filter['id_name']);
|
||||
$event_filter['tag_with'] = base64_encode(
|
||||
@ -590,7 +661,7 @@ function save_new_filter() {
|
||||
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{
|
||||
"page" : "operation/events/events_list",
|
||||
"page" : "include/ajax/events",
|
||||
"save_event_filter" : 1,
|
||||
"id_name" : $("#text-id_name").val(),
|
||||
"id_group" : $("select#id_group").val(),
|
||||
@ -659,7 +730,7 @@ function save_update_filter() {
|
||||
var name_filter_update = $("#overwrite_filter option[value='"+id_filter_update+"']").text();
|
||||
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{"page" : "operation/events/events_list",
|
||||
{"page" : "include/ajax/events",
|
||||
"update_event_filter" : 1,
|
||||
"id" : $("#overwrite_filter").val(),
|
||||
"id_group" : $("select#id_group").val(),
|
||||
@ -712,7 +783,7 @@ function save_update_filter() {
|
||||
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('none')."'"; ?> ).attr ("value", 0));
|
||||
// Reload filters select
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{"page" : "operation/events/events_list",
|
||||
{"page" : "include/ajax/events",
|
||||
"get_event_filters" : 1
|
||||
},
|
||||
function (data) {
|
||||
@ -1040,6 +1111,7 @@ if ($get_extended_event) {
|
||||
global $config;
|
||||
|
||||
$event = get_parameter('event', false);
|
||||
$filter = get_parameter('filter', false);
|
||||
|
||||
if ($event === false) {
|
||||
return;
|
||||
@ -1079,29 +1151,37 @@ if ($get_extended_event) {
|
||||
}
|
||||
|
||||
// Check ACLs.
|
||||
$access = false;
|
||||
if (is_user_admin($config['id_user'])) {
|
||||
// Do nothing if you're admin, you get full access.
|
||||
$__ignored_line = 0;
|
||||
$access = true;
|
||||
} else if ($config['id_user'] == $event['owner_user']) {
|
||||
// Do nothing if you're the owner user, you get access.
|
||||
$__ignored_line = 0;
|
||||
$access = true;
|
||||
} else if ($event['id_grupo'] == 0) {
|
||||
// If the event has access to all groups, you get access.
|
||||
$__ignored_line = 0;
|
||||
$access = true;
|
||||
} else {
|
||||
// Get your groups.
|
||||
$groups = users_get_groups($config['id_user'], 'ER');
|
||||
|
||||
if (in_array($event['id_grupo'], array_keys($groups))) {
|
||||
// If event group is among the groups of the user, you get access.
|
||||
$__ignored_line = 0;
|
||||
} else {
|
||||
// If all the access types fail, abort.
|
||||
echo 'Access denied';
|
||||
return false;
|
||||
$access = true;
|
||||
} else if ($event['id_agente']
|
||||
&& agents_check_access_agent($event['id_agente'], 'ER')
|
||||
) {
|
||||
// Secondary group, indirect access.
|
||||
$access = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$access) {
|
||||
// If all the access types fail, abort.
|
||||
echo 'Access denied';
|
||||
return false;
|
||||
}
|
||||
|
||||
// Print group_rep in a hidden field to recover it from javascript.
|
||||
html_print_input_hidden('group_rep', (int) $group_rep);
|
||||
|
||||
@ -1227,7 +1307,7 @@ if ($get_extended_event) {
|
||||
|
||||
$general = events_page_general($event);
|
||||
|
||||
$comments = events_page_comments($event);
|
||||
$comments = '<div id="extended_event_comments_page" class="extended_event_pages"></div>';
|
||||
|
||||
$notifications = '<div id="notification_comment_error" style="display:none">'.ui_print_error_message(__('Error adding comment'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_comment_success" style="display:none">'.ui_print_success_message(__('Comment added successfully'), '', true).'</div>';
|
||||
@ -1238,6 +1318,18 @@ if ($get_extended_event) {
|
||||
|
||||
$loading = '<div id="response_loading" style="display:none">'.html_print_image('images/spinner.gif', true).'</div>';
|
||||
|
||||
$i = 0;
|
||||
$tab['general'] = $i++;
|
||||
$tab['details'] = $i++;
|
||||
if (!empty($related)) {
|
||||
$tab['related'] = $i++;
|
||||
}
|
||||
|
||||
$tab['custom_fields'] = $i++;
|
||||
$tab['comments'] = $i++;
|
||||
$tab['responses'] = $i++;
|
||||
$tab['custom_data'] = $i++;
|
||||
|
||||
$out = '<div id="tabs">'.$tabs.$notifications.$loading.$general.$details.$related.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'</div>';
|
||||
|
||||
$js = '<script>
|
||||
@ -1249,31 +1341,31 @@ if ($get_extended_event) {
|
||||
// Load the required tab.
|
||||
switch ($dialog_page) {
|
||||
case 'general':
|
||||
$js .= '$tabs.tabs( "option", "active", 0);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['general'].');';
|
||||
break;
|
||||
|
||||
case 'details':
|
||||
$js .= '$tabs.tabs( "option", "active", 1);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['details'].');';
|
||||
break;
|
||||
|
||||
case 'related':
|
||||
$js .= '$tabs.tabs( "option", "active", 2);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['related'].');';
|
||||
break;
|
||||
|
||||
case 'custom_fields':
|
||||
$js .= '$tabs.tabs( "option", "active", 3);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['custom_fields'].');';
|
||||
break;
|
||||
|
||||
case 'comments':
|
||||
$js .= '$tabs.tabs( "option", "active", 4);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['comments'].');';
|
||||
break;
|
||||
|
||||
case 'responses':
|
||||
$js .= '$tabs.tabs( "option", "active", 5);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['responses'].');';
|
||||
break;
|
||||
|
||||
case 'custom_data':
|
||||
$js .= '$tabs.tabs( "option", "active", 6);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['custom_data'].');';
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1283,6 +1375,24 @@ if ($get_extended_event) {
|
||||
|
||||
$js .= '});';
|
||||
|
||||
$js .= '
|
||||
$("#link_comments").click(function (){
|
||||
$.post ({
|
||||
url : "ajax.php",
|
||||
data : {
|
||||
page: "include/ajax/events",
|
||||
get_comments: 1,
|
||||
event: '.json_encode($event).',
|
||||
filter: '.json_encode($filter).'
|
||||
},
|
||||
dataType : "html",
|
||||
success: function (data) {
|
||||
$("#extended_event_comments_page").empty();
|
||||
$("#extended_event_comments_page").html(data);
|
||||
}
|
||||
});
|
||||
});';
|
||||
|
||||
if (events_has_extended_info($event['id_evento']) === true) {
|
||||
$js .= '
|
||||
$("#link_related").click(function (){
|
||||
|
@ -1134,7 +1134,7 @@ if (check_login()) {
|
||||
urlencode(
|
||||
base64_encode($module['nombre'])
|
||||
)
|
||||
).'&refresh='.SECONDS_10MINUTES.'&'."draw_events=$draw_events', 'day_".$win_handle."', 1000, 650)";
|
||||
).'&refresh='.SECONDS_10MINUTES.'&'."draw_events=$draw_events', 'day_".$win_handle."', 1000, 700)";
|
||||
if (!is_snapshot_data($module['datos'])) {
|
||||
$data[8] .= '<a href="javascript:'.$link.'">'.html_print_image('images/chart_curve.png', true, ['border' => '0', 'alt' => '']).'</a> ';
|
||||
}
|
||||
|
@ -1257,11 +1257,8 @@ function fill_permissions_ldap($sr)
|
||||
global $config;
|
||||
$permissions = [];
|
||||
$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 = db_get_all_rows_filter(
|
||||
'tusuario_perfil',
|
||||
@ -1287,43 +1284,9 @@ function fill_permissions_ldap($sr)
|
||||
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) {
|
||||
$ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
|
||||
foreach ($ldap_adv_perms as $ldap_adv_perm) {
|
||||
$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;
|
||||
return get_advanced_permissions($ldap_adv_perms, $sr);
|
||||
}
|
||||
|
||||
if ($config['ldap_advanced_config'] == 1 && $config['ldap_save_profile'] == 0) {
|
||||
@ -1333,25 +1296,16 @@ function fill_permissions_ldap($sr)
|
||||
);
|
||||
if ($result == false) {
|
||||
$ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
|
||||
foreach ($ldap_adv_perms as $ldap_adv_perm) {
|
||||
$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;
|
||||
return get_advanced_permissions($ldap_adv_perms, $sr);
|
||||
}
|
||||
|
||||
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,
|
||||
];
|
||||
$permissions_profile[] = [
|
||||
'profile' => $perms['id_perfil'],
|
||||
'groups' => [$perms['id_grupo']],
|
||||
'tags' => $perms['tags'],
|
||||
'no_hierarchy' => (bool) $perms['no_hierarchy'] ? 1 : 0,
|
||||
];
|
||||
};
|
||||
|
||||
return $permissions_profile;
|
||||
@ -1365,22 +1319,43 @@ function fill_permissions_ldap($sr)
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
// Decode permissions in advanced mode
|
||||
$ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
$attributes = $ldap_adv_perm['groups_ldap'];
|
||||
foreach ($attributes as $attr) {
|
||||
$attr = explode('=', $attr, 2);
|
||||
foreach ($sr[$attr[0]] as $s_attr) {
|
||||
if (preg_match('/'.$attr[1].'/', $s_attr)) {
|
||||
$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,
|
||||
];
|
||||
if (!empty($attributes[0])) {
|
||||
foreach ($attributes as $attr) {
|
||||
$attr = explode('=', $attr, 2);
|
||||
foreach ($sr[$attr[0]] as $s_attr) {
|
||||
if (preg_match('/'.$attr[1].'/', $s_attr)) {
|
||||
$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,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC190625';
|
||||
$pandora_version = 'v7.0NG.735';
|
||||
$build_version = 'PC190704';
|
||||
$pandora_version = 'v7.0NG.736';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
$script_tz = @date_default_timezone_get();
|
||||
|
@ -146,7 +146,7 @@ define('COL_NOTINIT', '#4a83f3');
|
||||
define('COL_UNKNOWN', '#B2B2B2');
|
||||
define('COL_DOWNTIME', '#976DB1');
|
||||
define('COL_IGNORED', '#DDD');
|
||||
define('COL_ALERTFIRED', '#FFA631');
|
||||
define('COL_ALERTFIRED', '#F36201');
|
||||
define('COL_MINOR', '#B2B2B2');
|
||||
define('COL_MAJOR', '#C97A4A');
|
||||
define('COL_INFORMATIONAL', '#E4E4E4');
|
||||
|
@ -1836,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.
|
||||
*
|
||||
@ -1956,11 +2002,16 @@ function get_snmpwalk(
|
||||
exec($command_str, $output, $rc);
|
||||
}
|
||||
|
||||
// Parse the output of snmpwalk
|
||||
// Parse the output of snmpwalk.
|
||||
$snmpwalk = [];
|
||||
foreach ($output as $line) {
|
||||
// Separate the OID from the value
|
||||
$full_oid = explode(' = ', $line);
|
||||
// Separate the OID from the value.
|
||||
if (strpos($format, 'q') === false) {
|
||||
$full_oid = explode(' = ', $line, 2);
|
||||
} else {
|
||||
$full_oid = explode(' ', $line, 2);
|
||||
}
|
||||
|
||||
if (isset($full_oid[1])) {
|
||||
$snmpwalk[$full_oid[0]] = $full_oid[1];
|
||||
}
|
||||
|
@ -7494,63 +7494,62 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3)
|
||||
|
||||
|
||||
/**
|
||||
* Remove an agent from a policy.
|
||||
* Remove an agent from a policy by agent id.
|
||||
*
|
||||
* @param $id Id of the policy
|
||||
* @param $id2 Id of the agent policy
|
||||
* @param $trash1
|
||||
* @param $trash2
|
||||
* @param $thrash1 Don't use.
|
||||
* @param $other
|
||||
* @param $thrash2 Don't use.
|
||||
*
|
||||
* Example:
|
||||
* api.php?op=set&op2=remove_agent_from_policy&apipass=1234&user=admin&pass=pandora&id=11&id2=2
|
||||
*/
|
||||
function api_set_remove_agent_from_policy($id, $id2, $thrash2, $thrash3)
|
||||
function api_set_remove_agent_from_policy_by_id($id, $thrash1, $other, $thrash2)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (!check_acl($config['id_user'], 0, 'AW')) {
|
||||
returnError('forbidden', 'string');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($id == '' || !$id) {
|
||||
returnError('error_parameter', __('Error deleting agent from policy. Policy cannot be left blank.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if ($id2 == '' || !$id2) {
|
||||
if ($other['data'][0] == '' || !$other['data'][0]) {
|
||||
returnError('error_parameter', __('Error deleting agent from policy. Agent cannot be left blank.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$policy = policies_get_policy($id, false, false);
|
||||
$agent = db_get_row_filter('tagente', ['id_agente' => $id2]);
|
||||
$policy_agent = db_get_row_filter('tpolicy_agents', ['id_policy' => $id, 'id_agent' => $id2]);
|
||||
|
||||
if (empty($policy)) {
|
||||
returnError('error_policy', __('This policy does not exist.'));
|
||||
// Require node id if is metaconsole
|
||||
if (is_metaconsole() && $other['data'][1] == '') {
|
||||
returnError('error_add_agent_policy', __('Error deleting agent from policy. Node ID cannot be left blank.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($agent)) {
|
||||
returnError('error_agent', __('This agent does not exist.'));
|
||||
return remove_agent_from_policy($id, false, [$other['data'][0], $other['data'][1]]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove an agent from a policy by agent name.
|
||||
*
|
||||
* @param $id Id of the policy
|
||||
* @param $thrash1 Don't use.
|
||||
* @param $other
|
||||
* @param $thrash2 Don't use.
|
||||
*
|
||||
* Example:
|
||||
* api.php?op=set&op2=remove_agent_from_policy&apipass=1234&user=admin&pass=pandora&id=11&id2=2
|
||||
*/
|
||||
function api_set_remove_agent_from_policy_by_name($id, $thrash1, $other, $thrash2)
|
||||
{
|
||||
if ($id == '' || !$id) {
|
||||
returnError('error_parameter', __('Error deleting agent from policy. Policy cannot be left blank.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($policy_agent)) {
|
||||
returnError('error_policy_agent', __('This agent does not exist in this policy.'));
|
||||
if ($other['data'][0] == '' || !$other['data'][0]) {
|
||||
returnError('error_add_agent_policy', __('Error adding agent to policy. Agent name cannot be left blank.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$return = policies_change_delete_pending_agent($policy_agent['id']);
|
||||
$data = __('Successfully added to delete pending id agent %d to id policy %d.', $id2, $id);
|
||||
|
||||
if ($return === false) {
|
||||
returnError('error_delete_policy_agent', 'Could not be deleted id agent %d from id policy %d', $id2, $id);
|
||||
} else {
|
||||
returnData('string', ['type' => 'string', 'data' => $data]);
|
||||
}
|
||||
|
||||
return remove_agent_from_policy($id, true, [$other['data'][0]]);
|
||||
}
|
||||
|
||||
|
||||
@ -14209,28 +14208,6 @@ function api_get_all_event_filters($thrash1, $thrash2, $other, $thrash3)
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// AUX FUNCTIONS
|
||||
//
|
||||
function util_api_check_agent_and_print_error($id_agent, $returnType, $access='AR', $force_meta=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$check_agent = agents_check_access_agent($id_agent, $access, $force_meta);
|
||||
if ($check_agent === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($check_agent === false || !check_acl($config['id_user'], 0, $access)) {
|
||||
returnError('forbidden', $returnType);
|
||||
} else if ($check_agent === null) {
|
||||
returnError('id_not_found', $returnType);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function api_get_user_info($thrash1, $thrash2, $other, $returnType)
|
||||
{
|
||||
$separator = ';';
|
||||
@ -15047,3 +15024,94 @@ function api_set_add_permission_user_to_group($thrash1, $thrash2, $other, $retur
|
||||
returnData($returnType, $data, ';');
|
||||
|
||||
}
|
||||
|
||||
|
||||
// AUXILIARY FUNCTIONS
|
||||
|
||||
|
||||
/**
|
||||
* Auxiliary function to remove an agent from a policy. Used from API methods api_set_remove_agent_from_policy_by_id and api_set_remove_agent_from_policy_by_name.
|
||||
*
|
||||
* @param int ID of targeted policy.
|
||||
* @param boolean If true it will look for the agent we are targeting at based on its agent name, otherwise by agent id.
|
||||
* @param array Array containing agent's name or agent's id (and node id in case we are on metaconsole).
|
||||
*/
|
||||
function remove_agent_from_policy($id_policy, $use_agent_name, $params)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (!check_acl($config['id_user'], 0, 'AW')) {
|
||||
returnError('forbidden', 'string');
|
||||
return;
|
||||
}
|
||||
|
||||
$id_node = 0;
|
||||
$agent_table = 'tagente';
|
||||
|
||||
if ($use_agent_name === false) {
|
||||
$id_agent = $params[0];
|
||||
} else {
|
||||
$id_agent = db_get_value_filter('id_agente', 'tagente', ['nombre' => $params[0]]);
|
||||
}
|
||||
|
||||
$agent = db_get_row_filter('tagente', ['id_agente' => $id_agent]);
|
||||
|
||||
if (is_metaconsole()) {
|
||||
if ($use_agent_name === false) {
|
||||
$id_node = $params[1];
|
||||
$id_agent = db_get_value_filter('id_agente', 'tmetaconsole_agent', ['id_tagente' => $params[0], 'id_tmetaconsole_setup' => $id_node]);
|
||||
} else {
|
||||
$id_agent = db_get_value_filter('id_agente', 'tmetaconsole_agent', ['nombre' => $params[0]]);
|
||||
}
|
||||
|
||||
$agent = db_get_row_filter('tmetaconsole_agent', ['id_agente' => $id_agent]);
|
||||
}
|
||||
|
||||
$policy = policies_get_policy($id_policy, false, false);
|
||||
|
||||
$policy_agent = db_get_row_filter('tpolicy_agents', ['id_policy' => $id_policy, 'id_agent' => $id_agent]);
|
||||
|
||||
if (empty($policy)) {
|
||||
returnError('error_policy', __('This policy does not exist.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($agent)) {
|
||||
returnError('error_agent', __('This agent does not exist.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($policy_agent)) {
|
||||
returnError('error_policy_agent', __('This agent does not exist in this policy.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$return = policies_change_delete_pending_agent($policy_agent['id']);
|
||||
$data = __('Successfully added to delete pending id agent %d to id policy %d.', $id_agent, $id_policy);
|
||||
|
||||
if ($return === false) {
|
||||
returnError('error_delete_policy_agent', 'Could not be deleted id agent %d from id policy %d', $id_agent, $id_policy);
|
||||
} else {
|
||||
returnData('string', ['type' => 'string', 'data' => $data]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function util_api_check_agent_and_print_error($id_agent, $returnType, $access='AR', $force_meta=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$check_agent = agents_check_access_agent($id_agent, $access, $force_meta);
|
||||
if ($check_agent === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($check_agent === false || !check_acl($config['id_user'], 0, $access)) {
|
||||
returnError('forbidden', $returnType);
|
||||
} else if ($check_agent === null) {
|
||||
returnError('id_not_found', $returnType);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
439
pandora_console/include/functions_credential_store.php
Normal file
439
pandora_console/include/functions_credential_store.php
Normal 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;
|
||||
}
|
@ -184,7 +184,7 @@ function custom_graphs_search($id_group, $search)
|
||||
FROM tgraph_source
|
||||
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']]['name'] = $graph['name'];
|
||||
$graphs[$graph['id_graph']]['description'] = $graph['description'];
|
||||
|
@ -2023,3 +2023,58 @@ function db_check_minor_relase_available_to_um($package, $ent, $offline)
|
||||
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
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -34,6 +34,143 @@ enterprise_include_once('meta/include/functions_agents_meta.php');
|
||||
enterprise_include_once('meta/include/functions_modules_meta.php');
|
||||
|
||||
|
||||
/**
|
||||
* Translates a numeric value module_status into descriptive text.
|
||||
*
|
||||
* @param integer $status Module status.
|
||||
*
|
||||
* @return string Descriptive text.
|
||||
*/
|
||||
function events_translate_module_status($status)
|
||||
{
|
||||
switch ($status) {
|
||||
case AGENT_MODULE_STATUS_NORMAL:
|
||||
return __('NORMAL');
|
||||
|
||||
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||
return __('CRITICAL');
|
||||
|
||||
case AGENT_MODULE_STATUS_NO_DATA:
|
||||
return __('NOT INIT');
|
||||
|
||||
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
|
||||
case AGENT_MODULE_STATUS_NORMAL_ALERT:
|
||||
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||
return __('ALERT');
|
||||
|
||||
case AGENT_MODULE_STATUS_WARNING:
|
||||
return __('WARNING');
|
||||
|
||||
default:
|
||||
return __('UNKNOWN');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates a numeric value event_type into descriptive text.
|
||||
*
|
||||
* @param integer $event_type Event type.
|
||||
*
|
||||
* @return string Descriptive text.
|
||||
*/
|
||||
function events_translate_event_type($event_type)
|
||||
{
|
||||
// Event type prepared.
|
||||
switch ($event_type) {
|
||||
case EVENTS_ALERT_FIRED:
|
||||
case EVENTS_ALERT_RECOVERED:
|
||||
case EVENTS_ALERT_CEASED:
|
||||
case EVENTS_ALERT_MANUAL_VALIDATION:
|
||||
return __('ALERT');
|
||||
|
||||
case EVENTS_RECON_HOST_DETECTED:
|
||||
case EVENTS_SYSTEM:
|
||||
case EVENTS_ERROR:
|
||||
case EVENTS_NEW_AGENT:
|
||||
case EVENTS_CONFIGURATION_CHANGE:
|
||||
return __('SYSTEM');
|
||||
|
||||
case EVENTS_GOING_UP_WARNING:
|
||||
case EVENTS_GOING_DOWN_WARNING:
|
||||
return __('WARNING');
|
||||
|
||||
case EVENTS_GOING_DOWN_NORMAL:
|
||||
case EVENTS_GOING_UP_NORMAL:
|
||||
return __('NORMAL');
|
||||
|
||||
case EVENTS_GOING_DOWN_CRITICAL:
|
||||
case EVENTS_GOING_UP_CRITICAL:
|
||||
return __('CRITICAL');
|
||||
|
||||
case EVENTS_UNKNOWN:
|
||||
case EVENTS_GOING_UNKNOWN:
|
||||
default:
|
||||
return __('UNKNOWN');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates a numeric value event_status into descriptive text.
|
||||
*
|
||||
* @param integer $status Event status.
|
||||
*
|
||||
* @return string Descriptive text.
|
||||
*/
|
||||
function events_translate_event_status($status)
|
||||
{
|
||||
switch ($status) {
|
||||
case EVENT_STATUS_NEW:
|
||||
default:
|
||||
return __('NEW');
|
||||
|
||||
case EVENT_STATUS_INPROCESS:
|
||||
return __('IN PROCESS');
|
||||
|
||||
case EVENT_STATUS_VALIDATED:
|
||||
return __('VALIDATED');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates a numeric value criticity into descriptive text.
|
||||
*
|
||||
* @param integer $criticity Event criticity.
|
||||
*
|
||||
* @return string Descriptive text.
|
||||
*/
|
||||
function events_translate_event_criticity($criticity)
|
||||
{
|
||||
switch ($criticity) {
|
||||
case EVENT_CRIT_CRITICAL:
|
||||
return __('CRITICAL');
|
||||
|
||||
case EVENT_CRIT_MAINTENANCE:
|
||||
return __('MAINTENANCE');
|
||||
|
||||
case EVENT_CRIT_INFORMATIONAL:
|
||||
return __('INFORMATIONAL');
|
||||
|
||||
case EVENT_CRIT_MAJOR:
|
||||
return __('MAJOR');
|
||||
|
||||
case EVENT_CRIT_MINOR:
|
||||
return __('MINOR');
|
||||
|
||||
case EVENT_CRIT_NORMAL:
|
||||
return __('NORMAL');
|
||||
|
||||
case EVENT_CRIT_WARNING:
|
||||
return __('WARNING');
|
||||
|
||||
default:
|
||||
return __('UNKNOWN');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return all header string for each event field.
|
||||
*
|
||||
@ -151,6 +288,9 @@ function events_get_column_name($field)
|
||||
case 'options':
|
||||
return __('Options');
|
||||
|
||||
case 'mini_severity':
|
||||
return 'S';
|
||||
|
||||
default:
|
||||
return __($field);
|
||||
}
|
||||
@ -641,32 +781,35 @@ function events_get_all(
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($filter['id_group_filter']) && $filter['id_group_filter'] > 0) {
|
||||
$groups = $filter['id_group_filter'];
|
||||
if (isset($groups) && $groups > 0) {
|
||||
$propagate = db_get_value(
|
||||
'propagate',
|
||||
'tgrupo',
|
||||
'id_grupo',
|
||||
$filter['id_group_filter']
|
||||
$groups
|
||||
);
|
||||
|
||||
if (!$propagate) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND te.id_grupo = %d ',
|
||||
$filter['id_group_filter']
|
||||
' AND (te.id_grupo = %d OR tasg.id_group = %d)',
|
||||
$groups
|
||||
);
|
||||
} else {
|
||||
$groups = [ $filter['id_group_filter'] ];
|
||||
$childrens = groups_get_childrens($id_group, null, true);
|
||||
if (!empty($childrens)) {
|
||||
foreach ($childrens as $child) {
|
||||
$groups[] = (int) $child['id_grupo'];
|
||||
$children = groups_get_children($groups);
|
||||
$_groups = [ $groups ];
|
||||
if (!empty($children)) {
|
||||
foreach ($children as $child) {
|
||||
$_groups[] = (int) $child['id_grupo'];
|
||||
}
|
||||
}
|
||||
|
||||
$filter['id_group_filter'] = $groups;
|
||||
$groups = $_groups;
|
||||
|
||||
$sql_filters[] = sprintf(
|
||||
' AND id_group IN (%s) ',
|
||||
join(',', $filter['id_group_filter'])
|
||||
' AND (te.id_grupo IN (%s) OR tasg.id_group IN (%s))',
|
||||
join(',', $groups),
|
||||
join(',', $groups)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -702,8 +845,6 @@ function events_get_all(
|
||||
}
|
||||
}
|
||||
|
||||
$sg_active = enterprise_hook('agents_is_using_secondary_groups');
|
||||
|
||||
if (!$user_is_admin) {
|
||||
$ER_groups = users_get_groups($config['id_user'], 'ER', false);
|
||||
$EM_groups = users_get_groups($config['id_user'], 'EM', false, true);
|
||||
@ -713,7 +854,8 @@ function events_get_all(
|
||||
if (!$user_is_admin && !users_can_manage_group_all('ER')) {
|
||||
// Get groups where user have ER grants.
|
||||
$sql_filters[] = sprintf(
|
||||
' AND te.id_grupo IN ( %s )',
|
||||
' AND (te.id_grupo IN ( %s ) OR tasg.id_group IN (%s))',
|
||||
join(', ', array_keys($ER_groups)),
|
||||
join(', ', array_keys($ER_groups))
|
||||
);
|
||||
}
|
||||
@ -912,7 +1054,9 @@ function events_get_all(
|
||||
// Force_group_and_tag.
|
||||
true,
|
||||
// Table tag for id_grupo.
|
||||
'te.'
|
||||
'te.',
|
||||
// Alt table tag for id_grupo.
|
||||
'tasg.'
|
||||
);
|
||||
// FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
|
||||
} else if (check_acl($config['id_user'], 0, 'EW')) {
|
||||
@ -936,7 +1080,9 @@ function events_get_all(
|
||||
// Force_group_and_tag.
|
||||
true,
|
||||
// Table tag for id_grupo.
|
||||
'te.'
|
||||
'te.',
|
||||
// Alt table tag for id_grupo.
|
||||
'tasg.'
|
||||
);
|
||||
// FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
|
||||
} else if (check_acl($config['id_user'], 0, 'EM')) {
|
||||
@ -960,7 +1106,9 @@ function events_get_all(
|
||||
// Force_group_and_tag.
|
||||
true,
|
||||
// Table tag for id_grupo.
|
||||
'te.'
|
||||
'te.',
|
||||
// Alt table tag for id_grupo.
|
||||
'tasg.'
|
||||
);
|
||||
// FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
|
||||
}
|
||||
@ -1036,12 +1184,37 @@ function events_get_all(
|
||||
|
||||
$tgrupo_join = 'LEFT';
|
||||
$tgrupo_join_filters = [];
|
||||
if (isset($filter['id_group_filter']) && $filter['id_group_filter'] > 0) {
|
||||
if (isset($groups)
|
||||
&& (is_array($groups)
|
||||
|| $groups > 0)
|
||||
) {
|
||||
$tgrupo_join = 'INNER';
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' AND tg.id_grupo = %s',
|
||||
$filter['id_group_filter']
|
||||
);
|
||||
if (is_array($groups)) {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' AND (tg.id_grupo IN (%s) OR tasg.id_group IN (%s))',
|
||||
join(', ', $groups),
|
||||
join(', ', $groups)
|
||||
);
|
||||
} else {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' AND (tg.id_grupo = %s OR tasg.id_group = %s)',
|
||||
$groups,
|
||||
$groups
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$server_join = '';
|
||||
if (is_metaconsole()) {
|
||||
$server_join = ' LEFT JOIN tmetaconsole_setup ts
|
||||
ON ts.id = te.server_id';
|
||||
if (!empty($filter['server_id'])) {
|
||||
$server_join = sprintf(
|
||||
' LEFT JOIN tmetaconsole_setup ts
|
||||
ON ts.id = te.server_id AND ts.id= %d',
|
||||
$filter['server_id']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Secondary groups.
|
||||
@ -1076,6 +1249,7 @@ function events_get_all(
|
||||
%s JOIN tgrupo tg
|
||||
ON te.id_grupo = tg.id_grupo
|
||||
%s
|
||||
%s
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
@ -1094,6 +1268,7 @@ function events_get_all(
|
||||
join(' ', $agent_join_filters),
|
||||
$tgrupo_join,
|
||||
join(' ', $tgrupo_join_filters),
|
||||
$server_join,
|
||||
join(' ', $sql_filters),
|
||||
$group_by,
|
||||
$order_by,
|
||||
@ -4363,7 +4538,7 @@ function events_page_general($event)
|
||||
*
|
||||
* @return string HTML.
|
||||
*/
|
||||
function events_page_comments($event)
|
||||
function events_page_comments($event, $ajax=false)
|
||||
{
|
||||
// Comments.
|
||||
global $config;
|
||||
@ -4372,7 +4547,7 @@ function events_page_comments($event)
|
||||
|
||||
$comments = $event['user_comment'];
|
||||
if (isset($event['comments'])) {
|
||||
$comments = $event['comments'];
|
||||
$comments = explode('<br>', $event['comments']);
|
||||
}
|
||||
|
||||
$table_comments = new stdClass;
|
||||
@ -4383,100 +4558,102 @@ function events_page_comments($event)
|
||||
|
||||
$comments = str_replace(["\n", '
'], '<br>', $comments);
|
||||
|
||||
// If comments are not stored in json, the format is old.
|
||||
$comments_array = json_decode(io_safe_output($comments), true);
|
||||
if (!empty($comments) && json_last_error() != JSON_ERROR_NONE) {
|
||||
$comments_array = [
|
||||
[
|
||||
'comment' => 'Error retrieving comments',
|
||||
'action' => 'Internal message',
|
||||
'id_user' => 'SYSTEM',
|
||||
'utimestamp' => time(),
|
||||
],
|
||||
];
|
||||
}
|
||||
if (is_array($comments)) {
|
||||
foreach ($comments as $comm) {
|
||||
if (empty($comm)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Show the comments more recent first.
|
||||
if (is_array($comments_array)) {
|
||||
$comments_array = array_reverse($comments_array);
|
||||
}
|
||||
|
||||
if (empty($comments_array)) {
|
||||
$comments_format = 'old';
|
||||
$comments_array[] = json_decode(io_safe_output($comm), true);
|
||||
}
|
||||
} else {
|
||||
$comments_format = 'new';
|
||||
// If comments are not stored in json, the format is old.
|
||||
$comments_array = json_decode(io_safe_output($comments), true);
|
||||
}
|
||||
|
||||
switch ($comments_format) {
|
||||
case 'new':
|
||||
if (empty($comments_array)) {
|
||||
$table_comments->style[0] = 'text-align:center;';
|
||||
$table_comments->colspan[0][0] = 2;
|
||||
$data = [];
|
||||
$data[0] = __('There are no comments');
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
foreach ($comments_array as $comm) {
|
||||
// Show the comments more recent first.
|
||||
if (is_array($comm)) {
|
||||
$comm = array_reverse($comm);
|
||||
}
|
||||
|
||||
if (isset($comments_array) === true
|
||||
&& is_array($comments_array) === true
|
||||
) {
|
||||
foreach ($comments_array as $c) {
|
||||
$data[0] = '<b>'.$c['action'].' by '.$c['id_user'].'</b>';
|
||||
$data[0] .= '<br><br><i>'.date($config['date_format'], $c['utimestamp']).'</i>';
|
||||
$data[1] = $c['comment'];
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (empty($comm)) {
|
||||
$comments_format = 'old';
|
||||
} else {
|
||||
$comments_format = 'new';
|
||||
}
|
||||
|
||||
case 'old':
|
||||
$comments_array = explode('<br>', $comments);
|
||||
|
||||
// Split comments and put in table.
|
||||
$col = 0;
|
||||
$data = [];
|
||||
|
||||
foreach ($comments_array as $c) {
|
||||
switch ($col) {
|
||||
case 0:
|
||||
$row_text = preg_replace('/\s*--\s*/', '', $c);
|
||||
$row_text = preg_replace('/\<\/b\>/', '</i>', $row_text);
|
||||
$row_text = preg_replace('/\[/', '</b><br><br><i>[', $row_text);
|
||||
$row_text = preg_replace('/[\[|\]]/', '', $row_text);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$row_text = preg_replace("/[\r\n|\r|\n]/", '<br>', io_safe_output(strip_tags($c)));
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
$data[$col] = $row_text;
|
||||
|
||||
$col++;
|
||||
|
||||
if ($col == 2) {
|
||||
$col = 0;
|
||||
$table_comments->data[] = $data;
|
||||
switch ($comments_format) {
|
||||
case 'new':
|
||||
if (empty($comm)) {
|
||||
$table_comments->style[0] = 'text-align:center;';
|
||||
$table_comments->colspan[0][0] = 2;
|
||||
$data = [];
|
||||
$data[0] = __('There are no comments');
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($comments_array) == 1 && $comments_array[0] == '') {
|
||||
$table_comments->style[0] = 'text-align:center;';
|
||||
$table_comments->colspan[0][0] = 2;
|
||||
if (isset($comm) === true
|
||||
&& is_array($comm) === true
|
||||
) {
|
||||
foreach ($comm as $c) {
|
||||
$data[0] = '<b>'.$c['action'].' by '.$c['id_user'].'</b>';
|
||||
$data[0] .= '<br><br><i>'.date($config['date_format'], $c['utimestamp']).'</i>';
|
||||
$data[1] = $c['comment'];
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'old':
|
||||
$comm = explode('<br>', $comments);
|
||||
|
||||
// Split comments and put in table.
|
||||
$col = 0;
|
||||
$data = [];
|
||||
$data[0] = __('There are no comments');
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
foreach ($comm as $c) {
|
||||
switch ($col) {
|
||||
case 0:
|
||||
$row_text = preg_replace('/\s*--\s*/', '', $c);
|
||||
$row_text = preg_replace('/\<\/b\>/', '</i>', $row_text);
|
||||
$row_text = preg_replace('/\[/', '</b><br><br><i>[', $row_text);
|
||||
$row_text = preg_replace('/[\[|\]]/', '', $row_text);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$row_text = preg_replace("/[\r\n|\r|\n]/", '<br>', io_safe_output(strip_tags($c)));
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
$data[$col] = $row_text;
|
||||
|
||||
$col++;
|
||||
|
||||
if ($col == 2) {
|
||||
$col = 0;
|
||||
$table_comments->data[] = $data;
|
||||
$data = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($comm) == 1 && $comm[0] == '') {
|
||||
$table_comments->style[0] = 'text-align:center;';
|
||||
$table_comments->colspan[0][0] = 2;
|
||||
$data = [];
|
||||
$data[0] = __('There are no comments');
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (((tags_checks_event_acl(
|
||||
@ -4519,9 +4696,11 @@ function events_page_comments($event)
|
||||
);
|
||||
}
|
||||
|
||||
$comments = '<div id="extended_event_comments_page" class="extended_event_pages">'.$comments_form.html_print_table($table_comments, true).'</div>';
|
||||
if ($ajax) {
|
||||
return $comments_form.html_print_table($table_comments, true);
|
||||
}
|
||||
|
||||
return $comments;
|
||||
return '<div id="extended_event_comments_page" class="extended_event_pages">'.$comments_form.html_print_table($table_comments, true).'</div>';
|
||||
}
|
||||
|
||||
|
||||
@ -6449,10 +6628,6 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
|
||||
*/
|
||||
function events_get_secondary_groups_left_join($table)
|
||||
{
|
||||
if (users_is_admin()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($table == 'tevento') {
|
||||
return 'LEFT JOIN tagent_secondary_group tasg ON te.id_agente = tasg.id_agent';
|
||||
}
|
||||
|
@ -298,6 +298,52 @@ function groups_get_childrens_ids($parent, $groups=null)
|
||||
|
||||
|
||||
/**
|
||||
* Return a array of id_group of children of given parent.
|
||||
*
|
||||
* @param integer $parent The id_grupo parent to search its children.
|
||||
* @param array $ignorePropagate Ignore propagate.
|
||||
*/
|
||||
function groups_get_children($parent, $ignorePropagate=false)
|
||||
{
|
||||
static $groups;
|
||||
|
||||
if (empty($groups)) {
|
||||
$groups = db_get_all_rows_in_table('tgrupo');
|
||||
$groups = array_reduce(
|
||||
$groups,
|
||||
function ($carry, $item) {
|
||||
$carry[$item['id_grupo']] = $item;
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$return = [];
|
||||
foreach ($groups as $key => $g) {
|
||||
if ($g['id_grupo'] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($ignorePropagate || $parent == 0 || $groups[$parent]['propagate']) {
|
||||
if ($g['parent'] == $parent) {
|
||||
$return += [$g['id_grupo'] => $g];
|
||||
if ($g['propagate'] || $ignorePropagate) {
|
||||
$return += groups_get_children(
|
||||
$g['id_grupo'],
|
||||
$ignorePropagate
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* XXX: This is not working. Expects 'propagate' on CHILD not on PARENT!!!
|
||||
*
|
||||
* Return a array of id_group of childrens (to branches down)
|
||||
*
|
||||
* @param integer $parent The id_group parent to search the childrens.
|
||||
|
@ -3066,3 +3066,290 @@ function html_print_link_with_params($text, $params=[], $type='text', $style='')
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print input using functions html lib.
|
||||
*
|
||||
* @param array $data Input definition.
|
||||
*
|
||||
* @return string HTML code for desired input.
|
||||
*/
|
||||
function html_print_input($data)
|
||||
{
|
||||
if (is_array($data) === false) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$output = '';
|
||||
|
||||
if ($data['label']) {
|
||||
$output = '<div id="div-'.$data['name'].'" ';
|
||||
$output .= ' class="'.$data['input_class'].'">';
|
||||
$output .= '<label class="'.$data['label_class'].'">';
|
||||
$output .= $data['label'];
|
||||
$output .= '</label>';
|
||||
|
||||
if (!$data['return']) {
|
||||
echo $output;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($data['type']) {
|
||||
case 'text':
|
||||
$output .= html_print_input_text(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : true),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'image':
|
||||
$output .= html_print_input_image(
|
||||
$data['name'],
|
||||
$data['src'],
|
||||
$data['value'],
|
||||
((isset($data['style']) === true) ? $data['style'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['options']) === true) ? $data['options'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'text_extended':
|
||||
$output .= html_print_input_text_extended(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
$data['id'],
|
||||
$data['alt'],
|
||||
$data['size'],
|
||||
$data['maxlength'],
|
||||
$data['disabled'],
|
||||
$data['script'],
|
||||
$data['attributes'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['password']) === true) ? $data['password'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : '')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'password':
|
||||
$output .= html_print_input_password(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : '')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
$output .= html_print_input_text(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'image':
|
||||
$output .= html_print_input_image(
|
||||
$data['name'],
|
||||
$data['src'],
|
||||
$data['value'],
|
||||
((isset($data['style']) === true) ? $data['style'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['options']) === true) ? $data['options'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'hidden':
|
||||
$output .= html_print_input_hidden(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'hidden_extended':
|
||||
$output .= html_print_input_hidden_extended(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
$data['id'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'color':
|
||||
$output .= html_print_input_color(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['class']) === true) ? $data['class'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'file':
|
||||
$output .= html_print_input_file(
|
||||
$data['name'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['options']) === true) ? $data['options'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'select':
|
||||
$output .= html_print_select(
|
||||
$data['fields'],
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['modal']) === true) ? $data['modal'] : false),
|
||||
((isset($data['message']) === true) ? $data['message'] : ''),
|
||||
((isset($data['select_all']) === true) ? $data['select_all'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'select_from_sql':
|
||||
$output .= html_print_select_from_sql(
|
||||
$data['sql'],
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : '0'),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'select_groups':
|
||||
$output .= html_print_select_groups(
|
||||
((isset($data['id_user']) === true) ? $data['id_user'] : false),
|
||||
((isset($data['privilege']) === true) ? $data['privilege'] : 'AR'),
|
||||
((isset($data['returnAllGroup']) === true) ? $data['returnAllGroup'] : true),
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||
((isset($data['id_group']) === true) ? $data['id_group'] : false),
|
||||
((isset($data['keys_field']) === true) ? $data['keys_field'] : 'id_grupo'),
|
||||
((isset($data['strict_user']) === true) ? $data['strict_user'] : false),
|
||||
((isset($data['delete_groups']) === true) ? $data['delete_groups'] : false),
|
||||
((isset($data['include_groups']) === true) ? $data['include_groups'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['simple_multiple_options']) === true) ? $data['simple_multiple_options'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'submit':
|
||||
$output .= '<div class="action-buttons" style="width: 100%">'.html_print_submit_button(
|
||||
((isset($data['label']) === true) ? $data['label'] : 'OK'),
|
||||
((isset($data['name']) === true) ? $data['name'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false)
|
||||
).'</div>';
|
||||
break;
|
||||
|
||||
case 'checkbox':
|
||||
$output .= html_print_checkbox(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['checked']) === true) ? $data['checked'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['disabled_hidden']) === true) ? $data['disabled_hidden'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'switch':
|
||||
$output .= html_print_switch($data);
|
||||
break;
|
||||
|
||||
case 'interval':
|
||||
$output .= html_print_extended_select_for_time(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['style']) === true) ? $data['selected'] : false),
|
||||
((isset($data['unique']) === true) ? $data['unique'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'textarea':
|
||||
$output .= html_print_textarea(
|
||||
$data['name'],
|
||||
$data['rows'],
|
||||
$data['columns'],
|
||||
((isset($data['value']) === true) ? $data['value'] : ''),
|
||||
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : '')
|
||||
);
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
if ($data['label']) {
|
||||
$output .= '</div>';
|
||||
if (!$data['return']) {
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,6 +50,12 @@ function menu_print_menu(&$menu)
|
||||
|
||||
$sec = (string) get_parameter('sec');
|
||||
$sec2 = (string) get_parameter('sec2');
|
||||
if ($sec2 == 'operation/agentes/ver_agente') {
|
||||
$sec2 = 'godmode/agentes/configurar_agente';
|
||||
} else {
|
||||
$sec2 = (string) get_parameter('sec2');
|
||||
}
|
||||
|
||||
$menu_selected = false;
|
||||
|
||||
$allsec2 = explode('sec2=', $_SERVER['REQUEST_URI']);
|
||||
|
@ -383,7 +383,7 @@ function messages_get_count(
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT count(*) as "n" FROM (
|
||||
'SELECT count(distinct id_mensaje) as "n" FROM (
|
||||
SELECT
|
||||
tm.*,
|
||||
utimestamp_read > 0 as "read"
|
||||
|
@ -11138,21 +11138,38 @@ function reporting_get_stats_servers()
|
||||
$output = '<fieldset class="databox tactical_set">
|
||||
<legend>'.__('Server performance').'</legend>'.html_print_table($table_srv, true).'</fieldset>';
|
||||
|
||||
$output .= '<script type="text/javascript">';
|
||||
$output .= '$(document).ready(function () {';
|
||||
$output .= 'var parameters = {};';
|
||||
$output .= 'parameters["page"] = "include/ajax/events";';
|
||||
$output .= 'parameters["total_events"] = 1;';
|
||||
$public_hash = get_parameter('hash', false);
|
||||
if ($public_hash === false) {
|
||||
$output .= '<script type="text/javascript">';
|
||||
$output .= '$(document).ready(function () {';
|
||||
$output .= 'var parameters = {};';
|
||||
$output .= 'parameters["page"] = "include/ajax/events";';
|
||||
$output .= 'parameters["total_events"] = 1;';
|
||||
|
||||
$output .= '$.ajax({type: "GET",url: "/pandora_console/ajax.php",data: parameters,';
|
||||
$output .= 'success: function(data) {';
|
||||
$output .= '$("#total_events").text(data);';
|
||||
$output .= '}';
|
||||
$output .= '$.ajax({type: "GET",url: "/pandora_console/ajax.php",data: parameters,';
|
||||
$output .= 'success: function(data) {';
|
||||
$output .= '$("#total_events").text(data);';
|
||||
$output .= '}';
|
||||
$output .= '});';
|
||||
$output .= '});';
|
||||
$output .= '});';
|
||||
$output .= '</script>';
|
||||
$output .= '</script>';
|
||||
} else {
|
||||
// This is for public link on the dashboard
|
||||
$sql_count_event = 'SELECT SQL_NO_CACHE COUNT(id_evento) FROM tevento ';
|
||||
if ($config['event_view_hr']) {
|
||||
$sql_count_event .= 'WHERE utimestamp > (UNIX_TIMESTAMP(NOW()) - '.($config['event_view_hr'] * SECONDS_1HOUR).')';
|
||||
}
|
||||
|
||||
return $output;
|
||||
$system_events = db_get_value_sql($sql_count_event);
|
||||
|
||||
$output .= '<script type="text/javascript">';
|
||||
$output .= '$(document).ready(function () {';
|
||||
$output .= '$("#total_events").text("'.$system_events.'");';
|
||||
$output .= '});';
|
||||
$output .= '</script>';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
@ -597,7 +597,7 @@ function snmp_browser_print_oid(
|
||||
*
|
||||
* @return string The container div.
|
||||
*/
|
||||
function snmp_browser_print_container($return=false, $width='100%', $height='500px', $display='')
|
||||
function snmp_browser_print_container($return=false, $width='100%', $height='60%', $display='')
|
||||
{
|
||||
// Target selection
|
||||
$table = new stdClass();
|
||||
@ -773,7 +773,7 @@ function snmp_browser_print_container($return=false, $width='100%', $height='500
|
||||
|
||||
$output .= '<div id="search_results" style="display: none; padding: 5px; background-color: #EAEAEA; border: 1px solid #E2E2E2; border-radius: 4px;"></div>';
|
||||
$output .= '<div id="spinner" style="position: absolute; top:0; left:0px; display:none; padding: 5px;">'.html_print_image('images/spinner.gif', true).'</div>';
|
||||
$output .= '<div id="snmp_browser" style="height: 100%; overflow: auto; background-color: #F4F5F4; border: 1px solid #E2E2E2; border-radius: 4px; padding: 5px;"></div>';
|
||||
$output .= '<div id="snmp_browser" style="height: 100%; min-height:100px; overflow: auto; background-color: #F4F5F4; border: 1px solid #E2E2E2; border-radius: 4px; padding: 5px;"></div>';
|
||||
$output .= '<div class="databox" id="snmp_data" style="margin: 5px;"></div>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
|
@ -444,7 +444,7 @@ function tactical_monitor_fired_alerts($group_array, $strict_user=false, $id_gro
|
||||
WHERE tagente.id_grupo IN $group_clause_strict AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
|
||||
AND times_fired > 0 ";
|
||||
AND times_fired > 0 AND talert_template_modules.disabled = 0";
|
||||
|
||||
$count = db_get_sql($sql);
|
||||
return $count;
|
||||
@ -456,7 +456,7 @@ function tactical_monitor_fired_alerts($group_array, $strict_user=false, $id_gro
|
||||
WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
|
||||
AND times_fired > 0"
|
||||
AND times_fired > 0 AND talert_template_modules.disabled = 0"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -745,7 +745,8 @@ function tags_get_acl_tags(
|
||||
$meta=false,
|
||||
$childrens_ids=[],
|
||||
$force_group_and_tag=false,
|
||||
$id_grupo_table_pretag=''
|
||||
$id_grupo_table_pretag='',
|
||||
$alt_id_grupo_table_pretag=''
|
||||
) {
|
||||
global $config;
|
||||
|
||||
@ -820,7 +821,8 @@ function tags_get_acl_tags(
|
||||
$meta,
|
||||
$force_group_and_tag,
|
||||
false,
|
||||
$id_grupo_table_pretag
|
||||
$id_grupo_table_pretag,
|
||||
$alt_id_grupo_table_pretag
|
||||
);
|
||||
|
||||
if (!empty($condition)) {
|
||||
@ -917,7 +919,8 @@ function tags_get_acl_tags_event_condition(
|
||||
$meta=false,
|
||||
$force_group_and_tag=false,
|
||||
$force_equal=false,
|
||||
$id_grupo_table_pretag=''
|
||||
$id_grupo_table_pretag='',
|
||||
$alt_id_grupo_table_pretag=''
|
||||
) {
|
||||
global $config;
|
||||
$condition = [];
|
||||
@ -935,7 +938,7 @@ function tags_get_acl_tags_event_condition(
|
||||
|
||||
// Group condition (The module belongs to an agent of the group X)
|
||||
// $group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_id_recursive($group_id, true))));.
|
||||
$group_condition = '('.$id_grupo_table_pretag.'id_grupo = '.$group_id.' OR id_group = '.$group_id.')';
|
||||
$group_condition = '('.$id_grupo_table_pretag.'id_grupo = '.$group_id.' OR '.$alt_id_grupo_table_pretag.'id_group = '.$group_id.')';
|
||||
|
||||
// Tags condition (The module has at least one of the restricted tags).
|
||||
$tags_condition = '';
|
||||
@ -971,7 +974,7 @@ function tags_get_acl_tags_event_condition(
|
||||
}
|
||||
|
||||
$in_group = implode(',', $without_tags);
|
||||
$condition .= sprintf('('.$id_grupo_table_pretag.'id_grupo IN (%s) OR id_group IN (%s))', $in_group, $in_group);
|
||||
$condition .= sprintf('('.$id_grupo_table_pretag.'id_grupo IN (%s) OR '.$alt_id_grupo_table_pretag.'id_group IN (%s))', $in_group, $in_group);
|
||||
}
|
||||
|
||||
$condition = !empty($condition) ? "($condition)" : '';
|
||||
|
@ -760,6 +760,12 @@ function ui_print_os_icon(
|
||||
$subfolder .= '/so_big_icons';
|
||||
}
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$no_in_meta = true;
|
||||
} else {
|
||||
$no_in_meta = false;
|
||||
}
|
||||
|
||||
$icon = (string) db_get_value('icon_name', 'tconfig_os', 'id_os', (int) $id_os);
|
||||
$os_name = get_os_name($id_os);
|
||||
if (empty($icon)) {
|
||||
@ -770,7 +776,7 @@ function ui_print_os_icon(
|
||||
$options,
|
||||
true,
|
||||
$relative,
|
||||
false,
|
||||
$no_in_meta,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
@ -778,13 +784,13 @@ function ui_print_os_icon(
|
||||
}
|
||||
} else if ($apply_skin) {
|
||||
if ($only_src) {
|
||||
$output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, true, $relative, false, true);
|
||||
$output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, true, $relative, $no_in_meta, true);
|
||||
} else {
|
||||
if (!isset($options['title'])) {
|
||||
$options['title'] = $os_name;
|
||||
}
|
||||
|
||||
$output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, false, $relative, false, true);
|
||||
$output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, false, $relative, $no_in_meta, true);
|
||||
}
|
||||
} else {
|
||||
// $output = "<img src='images/os_icons/" . $icon . "' alt='" . $os_name . "' title='" . $os_name . "'>";
|
||||
@ -2907,8 +2913,10 @@ function ui_print_datatable(array $parameters)
|
||||
|
||||
if (isset($parameters['id'])) {
|
||||
$table_id = $parameters['id'];
|
||||
$form_id = 'form_'.$parameters['id'];
|
||||
} else {
|
||||
$table_id = uniqid('datatable_');
|
||||
$form_id = uniqid('datatable_filter_');
|
||||
}
|
||||
|
||||
if (!isset($parameters['columns']) || !is_array($parameters['columns'])) {
|
||||
@ -2936,15 +2944,15 @@ function ui_print_datatable(array $parameters)
|
||||
}
|
||||
|
||||
if (!isset($parameters['order']['field'])) {
|
||||
$order = 1;
|
||||
$order = 0;
|
||||
} else {
|
||||
$order = array_search(
|
||||
$parameters['order']['field'],
|
||||
$parameters['columns']
|
||||
);
|
||||
|
||||
if (empty($order)) {
|
||||
$order = 1;
|
||||
if ($order === false) {
|
||||
$order = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2995,8 +3003,6 @@ function ui_print_datatable(array $parameters)
|
||||
if (isset($parameters['form']) && is_array($parameters['form'])) {
|
||||
if (isset($parameters['form']['id'])) {
|
||||
$form_id = $parameters['form']['id'];
|
||||
} else {
|
||||
$form_id = uniqid('datatable_filter_');
|
||||
}
|
||||
|
||||
if (isset($parameters['form']['class'])) {
|
||||
@ -3026,27 +3032,35 @@ function ui_print_datatable(array $parameters)
|
||||
$filter .= $parameters['form']['html'];
|
||||
}
|
||||
|
||||
$filter .= '<ul class="content">';
|
||||
$filter .= '<ul class="datatable_filter content">';
|
||||
|
||||
foreach ($parameters['form']['inputs'] as $input) {
|
||||
$filter .= '<li>';
|
||||
$filter .= '<label>'.$input['label'].'</label>';
|
||||
if ($input['type'] != 'select') {
|
||||
$filter .= '<input type="'.$input['type'].'" ';
|
||||
$filter .= ' style="'.$input['style'].'" ';
|
||||
$filter .= ' class="'.$input['class'].'" ';
|
||||
$filter .= ' value="'.$input['value'].'" ';
|
||||
$filter .= ' name="'.$input['name'].'" id="'.$input['id'].'" />';
|
||||
} else {
|
||||
// Select.
|
||||
$filter .= '<select name="'.$input['name'].'" ';
|
||||
$filter .= '<select class="'.$input['class'].'"';
|
||||
$filter .= ' style="'.$input['style'].'" ';
|
||||
$filter .= ' name="'.$input['name'].'" ';
|
||||
$filter .= 'id="'.$input['id'].'">';
|
||||
|
||||
foreach ($input['options'] as $opt => $selected) {
|
||||
$filter .= '<option value="'.$opt['value'].'"';
|
||||
if ($selected) {
|
||||
$filter .= ' selected="yes" >';
|
||||
}
|
||||
foreach ($input['options'] as $key => $opt) {
|
||||
if (is_array($opt)) {
|
||||
$filter .= '<option value="'.$opt['value'].'"';
|
||||
if ($opt['selected']) {
|
||||
$filter .= ' selected="yes" >';
|
||||
}
|
||||
|
||||
$filter .= __($opt['text']).'</option>';
|
||||
$filter .= __($opt['text']).'</option>';
|
||||
} else {
|
||||
$filter .= '<option value="'.$key.'">'.$opt.'</option>';
|
||||
}
|
||||
}
|
||||
|
||||
$filter .= '</select>';
|
||||
@ -3074,7 +3088,7 @@ function ui_print_datatable(array $parameters)
|
||||
|
||||
$filter .= '</li>';
|
||||
|
||||
$filter .= '</ul></form>';
|
||||
$filter .= '</ul><div style="clear:both"></div></form>';
|
||||
$filter = ui_toggle(
|
||||
$filter,
|
||||
__('Filter'),
|
||||
@ -3220,8 +3234,10 @@ function ui_print_datatable(array $parameters)
|
||||
$.extend(data, {
|
||||
filter: values,'."\n";
|
||||
|
||||
foreach ($parameters['ajax_data'] as $k => $v) {
|
||||
$js .= $k.':'.json_encode($v).",\n";
|
||||
if (is_array($parameters['ajax_data'])) {
|
||||
foreach ($parameters['ajax_data'] as $k => $v) {
|
||||
$js .= $k.':'.json_encode($v).",\n";
|
||||
}
|
||||
}
|
||||
|
||||
$js .= 'page: "'.$parameters['ajax_url'].'"
|
||||
|
@ -293,7 +293,7 @@ function users_get_groups(
|
||||
}
|
||||
// Per-group permissions.
|
||||
else {
|
||||
$query = 'SELECT * FROM tgrupo ORDER BY parent,id_grupo DESC';
|
||||
$query = 'SELECT * FROM tgrupo ORDER BY nombre';
|
||||
$raw_groups = db_get_all_rows_sql($query);
|
||||
|
||||
$query = sprintf(
|
||||
|
@ -869,7 +869,7 @@ function pandoraFlotSlicebar(
|
||||
|
||||
var datas = new Array();
|
||||
|
||||
for (i = 0; i < values.length; i++) {
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
var serie = values[i].split(separator);
|
||||
|
||||
var aux = new Array();
|
||||
@ -1938,6 +1938,8 @@ function pandoraFlotArea(
|
||||
switch (type) {
|
||||
case "line":
|
||||
case 2:
|
||||
stacked = null;
|
||||
filled_s = false;
|
||||
break;
|
||||
case 3:
|
||||
stacked = "stack";
|
||||
|
@ -279,6 +279,12 @@ function flot_area_graph(
|
||||
// Trick to get translated string from javascript.
|
||||
$return .= html_print_input_hidden('unknown_text', __('Unknown'), true);
|
||||
|
||||
// To use the js document ready event or not. Default true.
|
||||
$document_ready = true;
|
||||
if (isset($params['document_ready']) === true) {
|
||||
$document_ready = $params['document_ready'];
|
||||
}
|
||||
|
||||
$values = json_encode($array_data);
|
||||
|
||||
$legend = json_encode($legend);
|
||||
@ -295,9 +301,28 @@ function flot_area_graph(
|
||||
}
|
||||
|
||||
$return .= "<script type='text/javascript'>";
|
||||
$return .= '$(document).ready( function () {';
|
||||
$return .= 'pandoraFlotArea('."'$graph_id', \n"."JSON.parse('$values'), \n"."JSON.parse('$legend'), \n"."JSON.parse('$series_type'), \n"."JSON.parse('$color'), \n"."'$watermark', \n"."JSON.parse('$date_array'), \n"."JSON.parse('$data_module_graph'), \n"."JSON.parse('$params'), \n"."JSON.parse('$array_events_alerts')".');';
|
||||
$return .= '});';
|
||||
|
||||
if ($document_ready === true) {
|
||||
$return .= '$(document).ready( function () {';
|
||||
}
|
||||
|
||||
$return .= "pandoraFlotArea(\n";
|
||||
$return .= "'".$graph_id."', \n";
|
||||
$return .= $values.", \n";
|
||||
$return .= $legend.", \n";
|
||||
$return .= $series_type.", \n";
|
||||
$return .= $color.", \n";
|
||||
$return .= $watermark.", \n";
|
||||
$return .= $date_array.", \n";
|
||||
$return .= $data_module_graph.", \n";
|
||||
$return .= $params.", \n";
|
||||
$return .= $array_events_alerts."\n";
|
||||
$return .= ');';
|
||||
|
||||
if ($document_ready === true) {
|
||||
$return .= '});';
|
||||
}
|
||||
|
||||
$return .= '</script>';
|
||||
|
||||
// Parent layer.
|
||||
@ -428,11 +453,9 @@ function flot_pie_chart(
|
||||
include_javascript_dependencies_flot_graph();
|
||||
|
||||
$return .= "<script type='text/javascript'>";
|
||||
$return .= '$(document).ready( function () {';
|
||||
$return .= "pandoraFlotPie('$graph_id', '$values', '$labels',
|
||||
'$series', '$width', $font_size, $water_mark, '$separator',
|
||||
'$legend_position', '$height', '$colors', ".json_encode($hide_labels).')';
|
||||
$return .= '});';
|
||||
$return .= '</script>';
|
||||
|
||||
return $return;
|
||||
@ -508,11 +531,9 @@ function flot_custom_pie_chart(
|
||||
$colors = implode($separator, $temp_colors);
|
||||
|
||||
$return .= "<script type='text/javascript'>";
|
||||
$return .= '$(document).ready( function () {';
|
||||
$return .= "pandoraFlotPieCustom('$graph_id', '$values', '$labels',
|
||||
'$width', $font_size, '$fontpath', $water_mark,
|
||||
'$separator', '$legend_position', '$height', '$colors','$legend','$background_color')";
|
||||
$return .= '});';
|
||||
$return .= '</script>';
|
||||
|
||||
return $return;
|
||||
@ -608,10 +629,8 @@ function flot_hcolumn_chart($graph_data, $width, $height, $water_mark, $font='',
|
||||
|
||||
// Javascript code
|
||||
$return .= "<script type='text/javascript'>";
|
||||
$return .= '$(document).ready( function () {';
|
||||
$return .= "pandoraFlotHBars('$graph_id', '$values', '$labels',
|
||||
false, $max, '$water_mark', '$separator', '$separator2', '$font', $font_size, '$background_color', '$tick_color', $val_min, $val_max)";
|
||||
$return .= '});';
|
||||
$return .= '</script>';
|
||||
|
||||
return $return;
|
||||
@ -701,7 +720,6 @@ function flot_vcolumn_chart($graph_data, $width, $height, $color, $legend, $long
|
||||
|
||||
// Javascript code
|
||||
$return .= "<script type='text/javascript'>";
|
||||
$return .= '$(document).ready( function () {';
|
||||
if ($from_ux) {
|
||||
if ($from_wux) {
|
||||
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, true, '$background_color', '$tick_color')";
|
||||
@ -712,7 +730,6 @@ function flot_vcolumn_chart($graph_data, $width, $height, $color, $legend, $long
|
||||
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, false, false, '$background_color', '$tick_color')";
|
||||
}
|
||||
|
||||
$return .= '});';
|
||||
$return .= '</script>';
|
||||
|
||||
return $return;
|
||||
@ -887,9 +904,7 @@ function flot_slicesbar_graph(
|
||||
// Javascript code
|
||||
$return .= "<script type='text/javascript'>";
|
||||
$return .= "//<![CDATA[\n";
|
||||
$return .= '$(document).ready( function () {';
|
||||
$return .= "pandoraFlotSlicebar('$graph_id','$values','$datacolor','$labels','$legend','$acumulate_data',$intervaltick,'$fontpath',$fontsize,'$separator','$separator2',$id_agent,'$full_legend_date',$not_interactive, '$show')";
|
||||
$return .= '});';
|
||||
$return .= "\n//]]>";
|
||||
$return .= '</script>';
|
||||
|
||||
|
@ -32,7 +32,7 @@ function clippy_module_unknow()
|
||||
$return_tours['tours']['module_unknow']['steps'] = [];
|
||||
$return_tours['tours']['module_unknow']['steps'][] = [
|
||||
'init_step_context' => true,
|
||||
'intro' => '<table>'.'<tr>'.'<td class="context_help_title">'.__('You have unknown modules in this agent.').'</td>'.'</tr>'.'<tr>'.'<td class="context_help_body">'.__('Unknown modules are modules which receive data normally at least in one occassion, but at this time are not receving data. Please check our troubleshoot help page to help you determine why you have unknown modules.').ui_print_help_icon('context_module_unknow', true, '', 'images/help.png').'</td>'.'</tr>'.'</table>',
|
||||
'intro' => '<table>'.'<tr>'.'<td class="context_help_title">'.__('You have unknown modules in this agent.').'</td>'.'</tr>'.'<tr>'.'<td class="context_help_body">'.__('Unknown modules are modules which receive data normally at least in one occassion, but at this time are not receving data. Please check our troubleshoot help page to help you determine why you have unknown modules.').'</td>'.'</tr>'.'</table>',
|
||||
];
|
||||
$return_tours['tours']['module_unknow']['conf'] = [];
|
||||
$return_tours['tours']['module_unknow']['conf']['autostart'] = false;
|
||||
|
@ -1,386 +1,405 @@
|
||||
(function($) {
|
||||
$.fn.check = function () {
|
||||
return this.each (function () {
|
||||
this.checked = true;
|
||||
});};
|
||||
$.fn.check = function() {
|
||||
return this.each(function() {
|
||||
this.checked = true;
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.uncheck = function () {
|
||||
return this.each (function () {
|
||||
this.checked = false;
|
||||
});};
|
||||
$.fn.uncheck = function() {
|
||||
return this.each(function() {
|
||||
this.checked = false;
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.enable = function () {
|
||||
return $(this).removeAttr ("disabled");
|
||||
};
|
||||
$.fn.enable = function() {
|
||||
return $(this).removeAttr("disabled");
|
||||
};
|
||||
|
||||
$.fn.disable = function () {
|
||||
return $(this).attr ("disabled", "disabled");
|
||||
};
|
||||
$.fn.disable = function() {
|
||||
return $(this).attr("disabled", "disabled");
|
||||
};
|
||||
|
||||
$.fn.pulsate = function () {
|
||||
var i = 0;
|
||||
for (i = 0; i <= 2; i++) {
|
||||
$(this).fadeOut ("slow").fadeIn ("slow");
|
||||
}
|
||||
};
|
||||
$.fn.pulsate = function() {
|
||||
var i = 0;
|
||||
for (i = 0; i <= 2; i++) {
|
||||
$(this)
|
||||
.fadeOut("slow")
|
||||
.fadeIn("slow");
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.showMessage = function (msg) {
|
||||
return $(this).hide ().empty ()
|
||||
// here, previously .text (msg)
|
||||
.html (msg)
|
||||
.slideDown ();
|
||||
};
|
||||
}) (jQuery);
|
||||
$.fn.showMessage = function(msg) {
|
||||
return (
|
||||
$(this)
|
||||
.hide()
|
||||
.empty()
|
||||
// here, previously .text (msg)
|
||||
.html(msg)
|
||||
.slideDown()
|
||||
);
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
$(document).ready (function () {
|
||||
$("a#show_messages_dialog").click (function () {
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page": "operation/messages/message_list"
|
||||
},
|
||||
function (data, status) {
|
||||
$("#dialog_messages").hide ()
|
||||
.empty ()
|
||||
.append (data)
|
||||
.dialog ({
|
||||
title: $("a#show_messages_dialog").attr ("title"),
|
||||
resizable: false,
|
||||
modal: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
width: 700,
|
||||
height: 300
|
||||
}).show ();
|
||||
},
|
||||
"html"
|
||||
);
|
||||
$(document).ready(function() {
|
||||
$("a#show_messages_dialog").click(function() {
|
||||
jQuery.post(
|
||||
"ajax.php",
|
||||
{
|
||||
page: "operation/messages/message_list"
|
||||
},
|
||||
function(data, status) {
|
||||
$("#dialog_messages")
|
||||
.hide()
|
||||
.empty()
|
||||
.append(data)
|
||||
.dialog({
|
||||
title: $("a#show_messages_dialog").attr("title"),
|
||||
resizable: false,
|
||||
modal: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
width: 700,
|
||||
height: 300
|
||||
})
|
||||
.show();
|
||||
},
|
||||
"html"
|
||||
);
|
||||
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$("a.show_systemalert_dialog").click (function () {
|
||||
$('body').append( "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>" );
|
||||
$("#opacidad").css('opacity', 0.5);
|
||||
$("a.show_systemalert_dialog").click(function() {
|
||||
$("body").append(
|
||||
"<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>"
|
||||
);
|
||||
$("#opacidad").css("opacity", 0.5);
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page": "operation/system_alert"},
|
||||
function (data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages").empty ().append (data);
|
||||
$("#alert_messages").css('opacity', 1);
|
||||
jQuery.post(
|
||||
"ajax.php",
|
||||
{
|
||||
page: "operation/system_alert"
|
||||
},
|
||||
function(data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages")
|
||||
.empty()
|
||||
.append(data);
|
||||
$("#alert_messages").css("opacity", 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
});
|
||||
|
||||
},
|
||||
"html"
|
||||
);
|
||||
});
|
||||
|
||||
$("a.modalpopup").click (function () {
|
||||
var elem = $(this).attr("id");
|
||||
$('body').append( "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>" );
|
||||
$("#opacidad").css('opacity', 0.5);
|
||||
$("a.modalpopup").click(function() {
|
||||
var elem = $(this).attr("id");
|
||||
$("body").append(
|
||||
"<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>"
|
||||
);
|
||||
$("#opacidad").css("opacity", 0.5);
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page": "general/alert_enterprise",
|
||||
"message": elem
|
||||
},
|
||||
function (data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages").empty ().append (data);
|
||||
$("#alert_messages").css('opacity', 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
jQuery.post(
|
||||
"ajax.php",
|
||||
{
|
||||
page: "general/alert_enterprise",
|
||||
message: elem
|
||||
},
|
||||
function(data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages")
|
||||
.empty()
|
||||
.append(data);
|
||||
$("#alert_messages").css("opacity", 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
|
||||
// Creacion de ventana modal y botones
|
||||
$(".publienterprise").click (function () {
|
||||
var elem = $(this).attr("id");
|
||||
$('body').append( "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>" );
|
||||
$("#opacidad").css('opacity', 0.5);
|
||||
// Creacion de ventana modal y botones
|
||||
$(".publienterprise").click(function() {
|
||||
var elem = $(this).attr("id");
|
||||
$("body").append(
|
||||
"<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>"
|
||||
);
|
||||
$("#opacidad").css("opacity", 0.5);
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page": "general/alert_enterprise",
|
||||
"message": elem
|
||||
},
|
||||
function (data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages").empty ().append (data);
|
||||
$("#alert_messages").css('opacity', 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$(".publienterprisehide").click (function () {
|
||||
var elem = $(this).attr("id");
|
||||
$('body').append( "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>" );
|
||||
$("#opacidad").css('opacity', 0.5);
|
||||
jQuery.post(
|
||||
"ajax.php",
|
||||
{
|
||||
page: "general/alert_enterprise",
|
||||
message: elem
|
||||
},
|
||||
function(data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages")
|
||||
.empty()
|
||||
.append(data);
|
||||
$("#alert_messages").css("opacity", 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page": "general/alert_enterprise",
|
||||
"message": elem
|
||||
},
|
||||
function (data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages").empty ().append (data);
|
||||
$("#alert_messages").css('opacity', 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
$(".publienterprisehide").click(function() {
|
||||
var elem = $(this).attr("id");
|
||||
$("body").append(
|
||||
"<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>"
|
||||
);
|
||||
$("#opacidad").css("opacity", 0.5);
|
||||
|
||||
jQuery.post(
|
||||
"ajax.php",
|
||||
{
|
||||
page: "general/alert_enterprise",
|
||||
message: elem
|
||||
},
|
||||
function(data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages")
|
||||
.empty()
|
||||
.append(data);
|
||||
$("#alert_messages").css("opacity", 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
|
||||
if ($("#license_error_msg_dialog").length) {
|
||||
if (typeof process_login_ok == "undefined") process_login_ok = 0;
|
||||
|
||||
if ($('#license_error_msg_dialog').length) {
|
||||
if (typeof(process_login_ok) == "undefined")
|
||||
process_login_ok = 0;
|
||||
if (typeof show_error_license == "undefined") show_error_license = 0;
|
||||
|
||||
if (typeof(show_error_license) == "undefined")
|
||||
show_error_license = 0;
|
||||
if (process_login_ok || show_error_license) {
|
||||
$("#license_error_msg_dialog").dialog({
|
||||
dialogClass: "no-close",
|
||||
closeOnEscape: false,
|
||||
resizable: false,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 470,
|
||||
width: 850,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
open: function() {
|
||||
var remaining = 30;
|
||||
|
||||
if (process_login_ok || show_error_license) {
|
||||
// Timeout counter.
|
||||
var count = function() {
|
||||
if (remaining > 0) {
|
||||
$("#license_error_remaining").text(remaining);
|
||||
remaining -= 1;
|
||||
} else {
|
||||
$("#license_error_remaining").hide();
|
||||
$("#ok_buttom").show();
|
||||
clearInterval(count);
|
||||
}
|
||||
};
|
||||
|
||||
$( "#license_error_msg_dialog" ).dialog({
|
||||
dialogClass: "no-close",
|
||||
closeOnEscape: false,
|
||||
resizable: false,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 450,
|
||||
width: 850,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
open: function() {
|
||||
var remaining = 30;
|
||||
setInterval(count, 1000);
|
||||
}
|
||||
});
|
||||
|
||||
// Timeout counter.
|
||||
var count = function() {
|
||||
if (remaining > 0) {
|
||||
$("#license_error_remaining").text(remaining);
|
||||
remaining -= 1;
|
||||
} else {
|
||||
$("#license_error_remaining").hide();
|
||||
$("#ok_buttom").show();
|
||||
clearInterval(count);
|
||||
}
|
||||
}
|
||||
$("#submit-hide-license-error-msg").click(function() {
|
||||
$("#license_error_msg_dialog").dialog("close");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(count, 1000);
|
||||
}
|
||||
});
|
||||
if ($("#msg_change_password").length) {
|
||||
$("#msg_change_password").dialog({
|
||||
resizable: false,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 450,
|
||||
width: 620,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("#submit-hide-license-error-msg").click (function () {
|
||||
$("#license_error_msg_dialog" ).dialog('close')
|
||||
});
|
||||
if ($("#login_blocked").length) {
|
||||
$("#login_blocked").dialog({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 200,
|
||||
width: 520,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if ($("#login_correct_pass").length) {
|
||||
$("#login_correct_pass").dialog({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 200,
|
||||
width: 520,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
forced_title_callback();
|
||||
|
||||
if ($('#msg_change_password').length) {
|
||||
$(document).on("scroll", function() {
|
||||
if (
|
||||
document.documentElement.scrollTop != 0 ||
|
||||
document.body.scrollTop != 0
|
||||
) {
|
||||
if ($("#head").css("position") == "fixed") {
|
||||
if ($("#menu").css("position") == "fixed") {
|
||||
$("#menu").css("top", "80px");
|
||||
} else {
|
||||
$("#menu").css("top", "60px");
|
||||
}
|
||||
} else {
|
||||
if ($("#menu").css("position") == "fixed") {
|
||||
$("#menu").css("top", "20px");
|
||||
} else {
|
||||
$("#menu").css("top", "80px");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($("#head").css("position") == "fixed") {
|
||||
if ($("#menu").css("position") == "fixed") {
|
||||
$("#menu").css("top", "80px");
|
||||
} else {
|
||||
$("#menu").css("top", "60px");
|
||||
}
|
||||
} else {
|
||||
if ($("#menu").css("position") == "fixed") {
|
||||
$("#menu").css("top", "80px");
|
||||
} else {
|
||||
$("#menu").css("top", "80px");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$( "#msg_change_password" ).dialog({
|
||||
resizable: false,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 350,
|
||||
width: 620,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
// if((document.documentElement.scrollTop != 0 || document.body.scrollTop != 0) && $('#menu').css('position') =='fixed'){
|
||||
// if($('#head').css('position') =='fixed'){
|
||||
// $('#menu').css('top','80px');
|
||||
// }
|
||||
// else{
|
||||
// $('#menu').css('top','20px');
|
||||
// }
|
||||
// }
|
||||
// else{
|
||||
// if($('#head').css('position') =='fixed'){
|
||||
// if(document.documentElement.scrollTop != 0 || document.body.scrollTop != 0){
|
||||
// $('#menu').css('top','60px');
|
||||
// }else{
|
||||
// $('#menu').css('top','80px');
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// else{
|
||||
// $('#menu').css('top','60px');
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if ($('#login_blocked').length) {
|
||||
|
||||
$( "#login_blocked" ).dialog({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 200,
|
||||
width: 520,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if ($('#login_correct_pass').length) {
|
||||
|
||||
$( "#login_correct_pass" ).dialog({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 200,
|
||||
width: 520,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
forced_title_callback();
|
||||
|
||||
|
||||
$(document).on("scroll", function(){
|
||||
|
||||
if(document.documentElement.scrollTop != 0 || document.body.scrollTop != 0){
|
||||
if($('#head').css('position') =='fixed'){
|
||||
if($('#menu').css('position') =='fixed'){
|
||||
$('#menu').css('top','80px');
|
||||
} else {
|
||||
$('#menu').css('top','60px');
|
||||
}
|
||||
} else {
|
||||
if($('#menu').css('position') =='fixed'){
|
||||
$('#menu').css('top','20px');
|
||||
} else {
|
||||
$('#menu').css('top','80px');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if($('#head').css('position') =='fixed'){
|
||||
if($('#menu').css('position') =='fixed'){
|
||||
$('#menu').css('top','80px');
|
||||
} else {
|
||||
$('#menu').css('top','60px');
|
||||
}
|
||||
} else {
|
||||
if($('#menu').css('position') =='fixed'){
|
||||
$('#menu').css('top','80px');
|
||||
} else {
|
||||
$('#menu').css('top','80px');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if((document.documentElement.scrollTop != 0 || document.body.scrollTop != 0) && $('#menu').css('position') =='fixed'){
|
||||
// if($('#head').css('position') =='fixed'){
|
||||
// $('#menu').css('top','80px');
|
||||
// }
|
||||
// else{
|
||||
// $('#menu').css('top','20px');
|
||||
// }
|
||||
// }
|
||||
// else{
|
||||
// if($('#head').css('position') =='fixed'){
|
||||
// if(document.documentElement.scrollTop != 0 || document.body.scrollTop != 0){
|
||||
// $('#menu').css('top','60px');
|
||||
// }else{
|
||||
// $('#menu').css('top','80px');
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// else{
|
||||
// $('#menu').css('top','60px');
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
$("#alert_messages").draggable();
|
||||
$("#alert_messages").css({'left':+parseInt(screen.width/2)-parseInt($("#alert_messages").css('width'))/2+'px'});
|
||||
|
||||
$("#alert_messages").draggable();
|
||||
$("#alert_messages").css({
|
||||
left:
|
||||
+parseInt(screen.width / 2) -
|
||||
parseInt($("#alert_messages").css("width")) / 2 +
|
||||
"px"
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
function forced_title_callback() {
|
||||
// Forced title code
|
||||
$('body').on('mouseenter', '.forced_title', function() {
|
||||
///////////////////////////////////////////
|
||||
// Put the layer in the left-top corner to fill it
|
||||
///////////////////////////////////////////
|
||||
$('#forced_title_layer').css('left', 0);
|
||||
$('#forced_title_layer').css('top', 0);
|
||||
// Forced title code
|
||||
$("body").on("mouseenter", ".forced_title", function() {
|
||||
///////////////////////////////////////////
|
||||
// Put the layer in the left-top corner to fill it
|
||||
///////////////////////////////////////////
|
||||
$("#forced_title_layer").css("left", 0);
|
||||
$("#forced_title_layer").css("top", 0);
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Get info of the image
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
// Get info of the image
|
||||
///////////////////////////////////////////
|
||||
|
||||
var img_top = $(this).offset().top;
|
||||
var img_width = $(this).width();
|
||||
var img_height = $(this).height();
|
||||
var img_id = $(this).attr('id');
|
||||
var img_left_mid = $(this).offset().left + (img_width / 2);
|
||||
var img_top = $(this).offset().top;
|
||||
var img_width = $(this).width();
|
||||
var img_height = $(this).height();
|
||||
var img_id = $(this).attr("id");
|
||||
var img_left_mid = $(this).offset().left + img_width / 2;
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Put title in the layer
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
// Put title in the layer
|
||||
///////////////////////////////////////////
|
||||
|
||||
// If the '.forced_title' element has 'use_title_for_force_title' = 1
|
||||
// into their 'data' prop, the element title will be used for the
|
||||
// content.
|
||||
if ($(this).data("use_title_for_force_title")) {
|
||||
var title = $(this).data("title");
|
||||
}
|
||||
else {
|
||||
var title = $('#forced_title_'+img_id).html();
|
||||
}
|
||||
// If the '.forced_title' element has 'use_title_for_force_title' = 1
|
||||
// into their 'data' prop, the element title will be used for the
|
||||
// content.
|
||||
if ($(this).data("use_title_for_force_title")) {
|
||||
var title = $(this).data("title");
|
||||
} else {
|
||||
var title = $("#forced_title_" + img_id).html();
|
||||
}
|
||||
|
||||
$('#forced_title_layer').html(title);
|
||||
$("#forced_title_layer").html(title);
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Get info of the layer
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
// Get info of the layer
|
||||
///////////////////////////////////////////
|
||||
|
||||
var layer_width = $('#forced_title_layer').width();
|
||||
var layer_height = $('#forced_title_layer').height();
|
||||
var layer_width = $("#forced_title_layer").width();
|
||||
var layer_height = $("#forced_title_layer").height();
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Obtain the new position of the layer
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
// Obtain the new position of the layer
|
||||
///////////////////////////////////////////
|
||||
|
||||
// Jquery doesnt know the padding of the layer
|
||||
var layer_padding = 4;
|
||||
// Jquery doesnt know the padding of the layer
|
||||
var layer_padding = 4;
|
||||
|
||||
// Deduct padding of both sides
|
||||
var layer_top = img_top - layer_height - (layer_padding * 2) - 5;
|
||||
if (layer_top < 0) {
|
||||
layer_top = img_top + img_height + (layer_padding * 2);
|
||||
}
|
||||
// Deduct padding of both sides
|
||||
var layer_top = img_top - layer_height - layer_padding * 2 - 5;
|
||||
if (layer_top < 0) {
|
||||
layer_top = img_top + img_height + layer_padding * 2;
|
||||
}
|
||||
|
||||
// Deduct padding of one side
|
||||
var layer_left = img_left_mid - (layer_width / 2) - layer_padding;
|
||||
if (layer_left < 0) {
|
||||
layer_left = 0;
|
||||
}
|
||||
// Deduct padding of one side
|
||||
var layer_left = img_left_mid - layer_width / 2 - layer_padding;
|
||||
if (layer_left < 0) {
|
||||
layer_left = 0;
|
||||
}
|
||||
|
||||
var real_layer_width = layer_width + (layer_padding * 2) + 5;
|
||||
var layer_right = layer_left + real_layer_width;
|
||||
var screen_width = $(window).width();
|
||||
if (screen_width < layer_right) {
|
||||
layer_left = screen_width - real_layer_width;
|
||||
}
|
||||
var real_layer_width = layer_width + layer_padding * 2 + 5;
|
||||
var layer_right = layer_left + real_layer_width;
|
||||
var screen_width = $(window).width();
|
||||
if (screen_width < layer_right) {
|
||||
layer_left = screen_width - real_layer_width;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Set the layer position and show
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
// Set the layer position and show
|
||||
///////////////////////////////////////////
|
||||
|
||||
$('#forced_title_layer').css('left', layer_left);
|
||||
$('#forced_title_layer').css('top', layer_top);
|
||||
$('#forced_title_layer').show();
|
||||
});
|
||||
$('body').on('mouseout', '.forced_title', function () {
|
||||
$('#forced_title_layer').hide().empty();
|
||||
});
|
||||
$("#forced_title_layer").css("left", layer_left);
|
||||
$("#forced_title_layer").css("top", layer_top);
|
||||
$("#forced_title_layer").show();
|
||||
});
|
||||
$("body").on("mouseout", ".forced_title", function() {
|
||||
$("#forced_title_layer")
|
||||
.hide()
|
||||
.empty();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,6 @@ function get_response(response_id) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
response = data;
|
||||
@ -255,7 +254,6 @@ function get_response_params(response_id) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
response_params = data;
|
||||
@ -279,7 +277,6 @@ function get_response_description(response_id) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
response_description = data;
|
||||
@ -305,7 +302,6 @@ function get_event_name(event_id, meta, history) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
name = data;
|
||||
@ -349,7 +345,6 @@ function get_response_target(
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
target = data;
|
||||
@ -394,7 +389,6 @@ function perform_response(target, response_id) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
var out = data.replace(/[\n|\r]/g, "<br>");
|
||||
@ -424,7 +418,6 @@ function perform_response_massive(target, response_id, out_iterator) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
var out = data.replace(/[\n|\r]/g, "<br>");
|
||||
@ -460,7 +453,6 @@ function event_change_status(event_ids) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
$("#button-status_button").removeAttr("disabled");
|
||||
@ -499,7 +491,6 @@ function event_change_owner() {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
$("#button-owner_button").removeAttr("disabled");
|
||||
@ -553,13 +544,11 @@ function event_comment() {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
$("#button-comment_button").removeAttr("disabled");
|
||||
$("#response_loading").show();
|
||||
dt_events.draw(false);
|
||||
show_event_dialog(current_event, "comments", data);
|
||||
$("#response_loading").hide();
|
||||
$("#link_comments").click();
|
||||
}
|
||||
});
|
||||
|
||||
@ -681,7 +670,6 @@ function update_event(table, id_evento, type, event_rep, row) {
|
||||
// Update events matching current filters and id_evento selected.
|
||||
$.ajax({
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
data: {
|
||||
@ -700,7 +688,7 @@ function update_event(table, id_evento, type, event_rep, row) {
|
||||
var diff_s = diff_g / 1000;
|
||||
if (processed >= $(".chk_val:checked").length) {
|
||||
// If operation takes less than 2 seconds, redraw.
|
||||
if (diff_s < 2) {
|
||||
if (diff_s < 2 || $(".chk_val:checked").length > 1) {
|
||||
redraw = true;
|
||||
}
|
||||
if (redraw) {
|
||||
@ -722,6 +710,7 @@ function validate_event(table, id_evento, event_rep, row) {
|
||||
var button = document.getElementById("val-" + id_evento);
|
||||
if (!button) {
|
||||
// Button does not exist. Ignore.
|
||||
processed += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -734,6 +723,7 @@ function in_process_event(table, id_evento, event_rep, row) {
|
||||
var button = document.getElementById("proc-" + id_evento);
|
||||
if (!button) {
|
||||
// Button does not exist. Ignore.
|
||||
processed += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -752,6 +742,7 @@ function delete_event(table, id_evento, event_rep, row) {
|
||||
var button = document.getElementById("del-" + id_evento);
|
||||
if (!button) {
|
||||
// Button does not exist. Ignore.
|
||||
processed += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1223,3 +1223,42 @@ function get_explanation_recon_script(id, id_rt, url) {
|
||||
|
||||
taskManager.addTask(xhr);
|
||||
}
|
||||
|
||||
// Filter modules in a select (bulk operations)
|
||||
function filterByText(selectbox, textbox, textNoData) {
|
||||
return selectbox.each(function() {
|
||||
var select = selectbox;
|
||||
var options = [];
|
||||
$(select)
|
||||
.find("option")
|
||||
.each(function() {
|
||||
options.push({ value: $(this).val(), text: $(this).text() });
|
||||
});
|
||||
$(select).data("options", options);
|
||||
$(textbox).bind("change keyup", function() {
|
||||
var options = $(select)
|
||||
.empty()
|
||||
.scrollTop(0)
|
||||
.data("options");
|
||||
var search = $(this).val();
|
||||
var regex = new RegExp(search, "gi");
|
||||
$.each(options, function(i) {
|
||||
var option = options[i];
|
||||
if (option.text.match(regex) !== null) {
|
||||
$(select).append(
|
||||
$("<option>")
|
||||
.text(option.text)
|
||||
.val(option.value)
|
||||
);
|
||||
}
|
||||
});
|
||||
if ($(select)[0].length == 0) {
|
||||
$(select).append(
|
||||
$("<option>")
|
||||
.text(textNoData)
|
||||
.val(textNoData)
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -417,3 +417,50 @@ function checkSNMPVersion() {
|
||||
$("#snmp3_browser_options").css("display", "none");
|
||||
}
|
||||
}
|
||||
|
||||
// Show the SNMP browser window
|
||||
function snmpBrowserWindow() {
|
||||
// Keep elements in the form and the SNMP browser synced
|
||||
$("#text-target_ip").val($("#text-ip_target").val());
|
||||
$("#text-community").val($("#text-snmp_community").val());
|
||||
$("#snmp_browser_version").val($("#snmp_version").val());
|
||||
$("#text-snmp3_browser_auth_user").val($("#text-snmp3_auth_user").val());
|
||||
$("#snmp3_browser_security_level").val($("#snmp3_security_level").val());
|
||||
$("#snmp3_browser_auth_method").val($("#snmp3_auth_method").val());
|
||||
$("#password-snmp3_browser_auth_pass").val(
|
||||
$("#password-snmp3_auth_pass").val()
|
||||
);
|
||||
$("#snmp3_browser_privacy_method").val($("#snmp3_privacy_method").val());
|
||||
$("#password-snmp3_browser_privacy_pass").val(
|
||||
$("#password-snmp3_privacy_pass").val()
|
||||
);
|
||||
|
||||
checkSNMPVersion();
|
||||
|
||||
$("#snmp_browser_container")
|
||||
.show()
|
||||
.dialog({
|
||||
title: "",
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
width: 920,
|
||||
height: 500
|
||||
});
|
||||
}
|
||||
|
||||
// Set the form OID to the value selected in the SNMP browser
|
||||
function setOID() {
|
||||
if ($("#snmp_browser_version").val() == "3") {
|
||||
$("#text-snmp_oid").val($("#table1-0-1").text());
|
||||
} else {
|
||||
$("#text-snmp_oid").val($("#snmp_selected_oid").text());
|
||||
}
|
||||
|
||||
// Close the SNMP browser
|
||||
$(".ui-dialog-titlebar-close").trigger("click");
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ function createVisualConsole(
|
||||
try {
|
||||
visualConsole = new VisualConsole(container, props, items);
|
||||
// VC Item clicked.
|
||||
visualConsole.onClick(function(e) {
|
||||
visualConsole.onItemClick(function(e) {
|
||||
// Override the link to another VC if it isn't on remote console.
|
||||
if (
|
||||
e.data &&
|
||||
@ -139,6 +139,94 @@ function createVisualConsole(
|
||||
updateVisualConsole(e.data.linkedLayoutId, updateInterval);
|
||||
}
|
||||
});
|
||||
// VC Item moved.
|
||||
visualConsole.onItemMoved(function(e) {
|
||||
var id = e.item.props.id;
|
||||
var data = {
|
||||
x: e.newPosition.x,
|
||||
y: e.newPosition.y,
|
||||
type: e.item.props.type
|
||||
};
|
||||
var taskId = "visual-console-item-move-" + id;
|
||||
|
||||
// Persist the new position.
|
||||
asyncTaskManager
|
||||
.add(taskId, function(done) {
|
||||
var abortable = updateVisualConsoleItem(
|
||||
baseUrl,
|
||||
visualConsole.props.id,
|
||||
id,
|
||||
data,
|
||||
function(error, data) {
|
||||
// if (!error && !data) return;
|
||||
if (error || !data) {
|
||||
console.log(
|
||||
"[ERROR]",
|
||||
"[VISUAL-CONSOLE-CLIENT]",
|
||||
"[API]",
|
||||
error ? error.message : "Invalid response"
|
||||
);
|
||||
|
||||
// Move the element to its initial position.
|
||||
e.item.move(e.prevPosition.x, e.prevPosition.y);
|
||||
}
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
cancel: function() {
|
||||
abortable.abort();
|
||||
}
|
||||
};
|
||||
})
|
||||
.init();
|
||||
});
|
||||
// VC Item resized.
|
||||
visualConsole.onItemResized(function(e) {
|
||||
var id = e.item.props.id;
|
||||
var data = {
|
||||
width: e.newSize.width,
|
||||
height: e.newSize.height,
|
||||
type: e.item.props.type
|
||||
};
|
||||
var taskId = "visual-console-item-resize-" + id;
|
||||
|
||||
// Persist the new size.
|
||||
asyncTaskManager
|
||||
.add(taskId, function(done) {
|
||||
var abortable = updateVisualConsoleItem(
|
||||
baseUrl,
|
||||
visualConsole.props.id,
|
||||
id,
|
||||
data,
|
||||
function(error, data) {
|
||||
// if (!error && !data) return;
|
||||
if (error || !data) {
|
||||
console.log(
|
||||
"[ERROR]",
|
||||
"[VISUAL-CONSOLE-CLIENT]",
|
||||
"[API]",
|
||||
error ? error.message : "Invalid response"
|
||||
);
|
||||
|
||||
// Resize the element to its initial Size.
|
||||
e.item.resize(e.prevSize.width, e.prevSize.height);
|
||||
}
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
cancel: function() {
|
||||
abortable.abort();
|
||||
}
|
||||
};
|
||||
})
|
||||
.init();
|
||||
});
|
||||
|
||||
if (updateInterval != null && updateInterval > 0) {
|
||||
// Start an interval to update the Visual Console.
|
||||
@ -266,6 +354,75 @@ function loadVisualConsoleData(baseUrl, vcId, callback) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a Visual Console's structure and its items.
|
||||
* @param {string} baseUrl Base URL to build the API path.
|
||||
* @param {number} vcId Identifier of the Visual Console.
|
||||
* @param {number} vcItemId Identifier of the Visual Console's item.
|
||||
* @param {Object} data Data we want to save.
|
||||
* @param {function} callback Function to be executed on request success or fail.
|
||||
* @return {Object} Cancellable. Object which include and .abort([statusText]) function.
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function updateVisualConsoleItem(baseUrl, vcId, vcItemId, data, callback) {
|
||||
// var apiPath = baseUrl + "/include/rest-api";
|
||||
var apiPath = baseUrl + "/ajax.php";
|
||||
var jqXHR = null;
|
||||
|
||||
// Cancel the ajax requests.
|
||||
var abort = function(textStatus) {
|
||||
if (textStatus == null) textStatus = "abort";
|
||||
|
||||
// -- XMLHttpRequest.readyState --
|
||||
// Value State Description
|
||||
// 0 UNSENT Client has been created. open() not called yet.
|
||||
// 4 DONE The operation is complete.
|
||||
|
||||
if (jqXHR.readyState !== 0 && jqXHR.readyState !== 4)
|
||||
jqXHR.abort(textStatus);
|
||||
};
|
||||
|
||||
// Failed request handler.
|
||||
var handleFail = function(jqXHR, textStatus, errorThrown) {
|
||||
abort();
|
||||
// Manually aborted or not.
|
||||
if (textStatus === "abort") {
|
||||
callback();
|
||||
} else {
|
||||
var error = new Error(errorThrown);
|
||||
error.request = jqXHR;
|
||||
callback(error);
|
||||
}
|
||||
};
|
||||
|
||||
// Function which handle success case.
|
||||
var handleSuccess = function(data) {
|
||||
callback(null, data);
|
||||
};
|
||||
|
||||
// Visual Console container request.
|
||||
jqXHR = jQuery
|
||||
// .get(apiPath + "/visual-consoles/" + vcId, null, "json")
|
||||
.get(
|
||||
apiPath,
|
||||
{
|
||||
page: "include/rest-api/index",
|
||||
updateVisualConsoleItem: 1,
|
||||
visualConsoleId: vcId,
|
||||
visualConsoleItemId: vcItemId,
|
||||
data: data
|
||||
},
|
||||
"json"
|
||||
)
|
||||
.done(handleSuccess)
|
||||
.fail(handleFail);
|
||||
|
||||
// Abortable.
|
||||
return {
|
||||
abort: abort
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Delete the functions below when you can.
|
||||
/**************************************
|
||||
These functions require jQuery library
|
||||
|
@ -13,6 +13,7 @@ use Models\VisualConsole\Container as VisualConsole;
|
||||
$visualConsoleId = (int) get_parameter('visualConsoleId');
|
||||
$getVisualConsole = (bool) get_parameter('getVisualConsole');
|
||||
$getVisualConsoleItems = (bool) get_parameter('getVisualConsoleItems');
|
||||
$updateVisualConsoleItem = (bool) get_parameter('updateVisualConsoleItem');
|
||||
|
||||
// Check groups can access user.
|
||||
$aclUserGroups = [];
|
||||
@ -44,6 +45,21 @@ if ($getVisualConsole === true) {
|
||||
} else if ($getVisualConsoleItems === true) {
|
||||
$vcItems = VisualConsole::getItemsFromDB($visualConsoleId, $aclUserGroups);
|
||||
echo '['.implode($vcItems, ',').']';
|
||||
} else if ($updateVisualConsoleItem === true) {
|
||||
$visualConsoleId = (integer) get_parameter('visualConsoleId');
|
||||
$visualConsoleItemId = (integer) get_parameter('visualConsoleItemId');
|
||||
$data = get_parameter('data');
|
||||
|
||||
$class = VisualConsole::getItemClass($data['type']);
|
||||
|
||||
$item_data = [];
|
||||
$item_data['id'] = $visualConsoleItemId;
|
||||
$item_data['id_layout'] = $visualConsoleId;
|
||||
|
||||
$item = $class::fromDB($item_data);
|
||||
$result = $item->save($data);
|
||||
|
||||
echo json_encode($result);
|
||||
}
|
||||
|
||||
exit;
|
||||
|
@ -47,6 +47,30 @@ abstract class Model
|
||||
abstract protected function decode(array $data): array;
|
||||
|
||||
|
||||
/**
|
||||
* Return a valid representation of a record in database.
|
||||
*
|
||||
* @param array $data Input data.
|
||||
*
|
||||
* @return array Data structure representing a record in database.
|
||||
*
|
||||
* @abstract
|
||||
*/
|
||||
abstract protected function encode(array $data): array;
|
||||
|
||||
|
||||
/**
|
||||
* Insert or update an item in the database
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return boolean The modeled element data structure stored into the DB.
|
||||
*
|
||||
* @abstract
|
||||
*/
|
||||
abstract public function save(array $data=[]);
|
||||
|
||||
|
||||
/**
|
||||
* Constructor of the model. It won't be public. The instances
|
||||
* will be created through factories which start with from*.
|
||||
@ -62,6 +86,12 @@ abstract class Model
|
||||
}
|
||||
|
||||
|
||||
public function setData(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instance the class with the unknown input data.
|
||||
*
|
||||
@ -69,7 +99,7 @@ abstract class Model
|
||||
*
|
||||
* @return self Instance of the model.
|
||||
*/
|
||||
public static function fromArray(array $data)
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
// The reserved word static refers to the invoked class at runtime.
|
||||
return new static($data);
|
||||
|
@ -92,6 +92,37 @@ final class Container extends Model
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a valid representation of a record in database.
|
||||
*
|
||||
* @param array $data Input data.
|
||||
*
|
||||
* @return array Data structure representing a record in database.
|
||||
*
|
||||
* @overrides Model::encode.
|
||||
*/
|
||||
protected function encode(array $data): array
|
||||
{
|
||||
$result = [];
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert or update an item in the database
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return boolean The modeled element data structure stored into the DB.
|
||||
*
|
||||
* @overrides Model::save.
|
||||
*/
|
||||
public function save(array $data=[]): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a group Id value.
|
||||
*
|
||||
|
@ -240,7 +240,7 @@ class Item extends CachedModel
|
||||
private static function extractX(array $data): int
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['x', 'pos_x']),
|
||||
static::issetInArray($data, ['x', 'pos_x', 'posX', 'startX']),
|
||||
0
|
||||
);
|
||||
}
|
||||
@ -256,7 +256,7 @@ class Item extends CachedModel
|
||||
private static function extractY(array $data): int
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['y', 'pos_y']),
|
||||
static::issetInArray($data, ['y', 'pos_y', 'posY', 'startY']),
|
||||
0
|
||||
);
|
||||
}
|
||||
@ -272,7 +272,7 @@ class Item extends CachedModel
|
||||
private static function extractAclGroupId(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id_group', 'aclGroupId']),
|
||||
static::issetInArray($data, ['id_group', 'aclGroupId', 'idGroup']),
|
||||
null
|
||||
);
|
||||
}
|
||||
@ -288,7 +288,7 @@ class Item extends CachedModel
|
||||
private static function extractParentId(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['parentId', 'parent_item']),
|
||||
static::issetInArray($data, ['parentId', 'parent_item', 'parentItem']),
|
||||
null
|
||||
);
|
||||
}
|
||||
@ -304,7 +304,7 @@ class Item extends CachedModel
|
||||
private static function extractIsOnTop(array $data): bool
|
||||
{
|
||||
return static::parseBool(
|
||||
static::issetInArray($data, ['isOnTop', 'show_on_top'])
|
||||
static::issetInArray($data, ['isOnTop', 'show_on_top', 'showOnTop'])
|
||||
);
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ class Item extends CachedModel
|
||||
private static function extractIsLinkEnabled(array $data): bool
|
||||
{
|
||||
return static::parseBool(
|
||||
static::issetInArray($data, ['isLinkEnabled', 'enable_link'])
|
||||
static::issetInArray($data, ['isLinkEnabled', 'enable_link', 'enableLink'])
|
||||
);
|
||||
}
|
||||
|
||||
@ -376,7 +376,23 @@ class Item extends CachedModel
|
||||
private static function extractAgentId(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['agentId', 'id_agent', 'id_agente']),
|
||||
static::issetInArray($data, ['agentId', 'id_agent', 'id_agente', 'idAgent', 'idAgente']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a custom id graph value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Valid identifier of an agent.
|
||||
*/
|
||||
private static function extractIdCustomGraph(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id_custom_graph', 'idCustomGraph', 'customGraphId']),
|
||||
null
|
||||
);
|
||||
}
|
||||
@ -398,6 +414,9 @@ class Item extends CachedModel
|
||||
'moduleId',
|
||||
'id_agente_modulo',
|
||||
'id_modulo',
|
||||
'idModulo',
|
||||
'idAgenteModulo',
|
||||
'idAgentModule',
|
||||
]
|
||||
),
|
||||
null
|
||||
@ -1187,4 +1206,468 @@ class Item extends CachedModel
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a valid representation of a record in database.
|
||||
*
|
||||
* @param array $data Input data.
|
||||
*
|
||||
* @return array Data structure representing a record in database.
|
||||
*
|
||||
* @overrides Model::encode.
|
||||
*/
|
||||
protected function encode(array $data): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$id = static::getId($data);
|
||||
if ($id) {
|
||||
$result['id'] = $id;
|
||||
}
|
||||
|
||||
$id_layout = static::getIdLayout($data);
|
||||
if ($id_layout) {
|
||||
$result['id_layout'] = $id_layout;
|
||||
}
|
||||
|
||||
$pos_x = static::parseIntOr(
|
||||
static::issetInArray($data, ['x', 'pos_x', 'posX']),
|
||||
null
|
||||
);
|
||||
if ($pos_x !== null) {
|
||||
$result['pos_x'] = $pos_x;
|
||||
}
|
||||
|
||||
$pos_y = static::parseIntOr(
|
||||
static::issetInArray($data, ['y', 'pos_y', 'posY']),
|
||||
null
|
||||
);
|
||||
if ($pos_y !== null) {
|
||||
$result['pos_y'] = $pos_y;
|
||||
}
|
||||
|
||||
$height = static::getHeight($data);
|
||||
if ($height !== null) {
|
||||
$result['height'] = $height;
|
||||
}
|
||||
|
||||
$width = static::getWidth($data);
|
||||
if ($width !== null) {
|
||||
$result['width'] = $width;
|
||||
}
|
||||
|
||||
$label = static::extractLabel($data);
|
||||
if ($label !== null) {
|
||||
$result['label'] = $label;
|
||||
}
|
||||
|
||||
$image = static::getImageSrc($data);
|
||||
if ($image !== null) {
|
||||
$result['image'] = $image;
|
||||
}
|
||||
|
||||
$type = static::parseIntOr(
|
||||
static::issetInArray($data, ['type']),
|
||||
null
|
||||
);
|
||||
if ($type !== null) {
|
||||
$result['type'] = $type;
|
||||
}
|
||||
|
||||
$period = static::parseIntOr(
|
||||
static::issetInArray($data, ['period', 'maxTime']),
|
||||
null
|
||||
);
|
||||
if ($period !== null) {
|
||||
$result['period'] = $period;
|
||||
}
|
||||
|
||||
$id_agente_modulo = static::extractModuleId($data);
|
||||
if ($id_agente_modulo !== null) {
|
||||
$result['id_agente_modulo'] = $id_agente_modulo;
|
||||
}
|
||||
|
||||
$id_agent = static::extractAgentId($data);
|
||||
if ($id_agent !== null) {
|
||||
$result['id_agent'] = $id_agent;
|
||||
}
|
||||
|
||||
$id_layout_linked = static::parseIntOr(
|
||||
static::issetInArray($data, ['linkedLayoutId', 'id_layout_linked', 'idLayoutLinked']),
|
||||
null
|
||||
);
|
||||
if ($id_layout_linked !== null) {
|
||||
$result['id_layout_linked'] = $id_layout_linked;
|
||||
}
|
||||
|
||||
$parent_item = static::extractParentId($data);
|
||||
if ($parent_item !== null) {
|
||||
$result['parent_item'] = $parent_item;
|
||||
}
|
||||
|
||||
$enable_link = static::issetInArray($data, ['isLinkEnabled', 'enable_link', 'enableLink']);
|
||||
if ($enable_link !== null) {
|
||||
$result['enable_link'] = static::parseBool($enable_link);
|
||||
}
|
||||
|
||||
$id_metaconsole = static::extractMetaconsoleId($data);
|
||||
if ($id_metaconsole !== null) {
|
||||
$result['id_metaconsole'] = $id_metaconsole;
|
||||
}
|
||||
|
||||
$id_group = static::extractAclGroupId($data);
|
||||
if ($id_group !== null) {
|
||||
$result['id_group'] = $id_group;
|
||||
}
|
||||
|
||||
$id_custom_graph = static::extractIdCustomGraph($data);
|
||||
if ($id_custom_graph !== null) {
|
||||
$result['id_custom_graph'] = $id_custom_graph;
|
||||
}
|
||||
|
||||
$border_width = static::getBorderWidth($data);
|
||||
if ($border_width !== null) {
|
||||
$result['border_width'] = $border_width;
|
||||
}
|
||||
|
||||
$type_graph = static::getTypeGraph($data);
|
||||
if ($type_graph !== null) {
|
||||
$result['type_graph'] = $type_graph;
|
||||
}
|
||||
|
||||
$label_position = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['labelPosition', 'label_position']),
|
||||
null
|
||||
);
|
||||
if ($label_position !== null) {
|
||||
$result['label_position'] = $label_position;
|
||||
}
|
||||
|
||||
$border_color = static::getBorderColor($data);
|
||||
if ($border_color !== null) {
|
||||
$result['border_color'] = $border_color;
|
||||
}
|
||||
|
||||
$fill_color = static::getFillColor($data);
|
||||
if ($fill_color !== null) {
|
||||
$result['fill_color'] = $fill_color;
|
||||
}
|
||||
|
||||
$show_statistics = static::issetInArray($data, ['showStatistics', 'show_statistics']);
|
||||
if ($show_statistics !== null) {
|
||||
$result['show_statistics'] = static::parseBool($show_statistics);
|
||||
}
|
||||
|
||||
$linked_layout_node_id = static::parseIntOr(
|
||||
static::issetInArray(
|
||||
$data,
|
||||
[
|
||||
'linkedLayoutAgentId',
|
||||
'linked_layout_node_id',
|
||||
]
|
||||
),
|
||||
null
|
||||
);
|
||||
if ($linked_layout_node_id !== null) {
|
||||
$result['linked_layout_node_id'] = $linked_layout_node_id;
|
||||
}
|
||||
|
||||
$linked_layout_status_type = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['linkedLayoutStatusType', 'linked_layout_status_type']),
|
||||
null
|
||||
);
|
||||
if ($linked_layout_status_type !== null) {
|
||||
$result['linked_layout_status_type'] = $linked_layout_status_type;
|
||||
}
|
||||
|
||||
$id_layout_linked_weight = static::parseIntOr(
|
||||
static::issetInArray($data, ['linkedLayoutStatusTypeWeight', 'id_layout_linked_weight']),
|
||||
null
|
||||
);
|
||||
if ($id_layout_linked_weight !== null) {
|
||||
$result['id_layout_linked_weight'] = $id_layout_linked_weight;
|
||||
}
|
||||
|
||||
$linked_layout_status_as_service_warning = static::parseIntOr(
|
||||
static::issetInArray(
|
||||
$data,
|
||||
[
|
||||
'linkedLayoutStatusTypeWarningThreshold',
|
||||
'linked_layout_status_as_service_warning',
|
||||
]
|
||||
),
|
||||
null
|
||||
);
|
||||
if ($linked_layout_status_as_service_warning !== null) {
|
||||
$result['linked_layout_status_as_service_warning'] = $linked_layout_status_as_service_warning;
|
||||
}
|
||||
|
||||
$linked_layout_status_as_service_critical = static::parseIntOr(
|
||||
static::issetInArray(
|
||||
$data,
|
||||
[
|
||||
'linkedLayoutStatusTypeCriticalThreshold',
|
||||
'linked_layout_status_as_service_critical',
|
||||
]
|
||||
),
|
||||
null
|
||||
);
|
||||
if ($linked_layout_status_as_service_critical !== null) {
|
||||
$result['linked_layout_status_as_service_critical'] = $linked_layout_status_as_service_critical;
|
||||
}
|
||||
|
||||
$element_group = static::parseIntOr(
|
||||
static::issetInArray($data, ['elementGroup', 'element_group']),
|
||||
null
|
||||
);
|
||||
if ($element_group !== null) {
|
||||
$result['element_group'] = $element_group;
|
||||
}
|
||||
|
||||
$show_on_top = static::issetInArray($data, ['isOnTop', 'show_on_top', 'showOnTop']);
|
||||
if ($show_on_top !== null) {
|
||||
$result['show_on_top'] = static::parseBool($show_on_top);
|
||||
}
|
||||
|
||||
$clock_animation = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['clockType', 'clock_animation', 'clockAnimation']),
|
||||
null
|
||||
);
|
||||
if ($clock_animation !== null) {
|
||||
$result['clock_animation'] = $clock_animation;
|
||||
}
|
||||
|
||||
$time_format = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['clockFormat', 'time_format', 'timeFormat']),
|
||||
null
|
||||
);
|
||||
if ($time_format !== null) {
|
||||
$result['time_format'] = $time_format;
|
||||
}
|
||||
|
||||
$timezone = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['timezone', 'timeZone', 'time_zone', 'clockTimezone']),
|
||||
null
|
||||
);
|
||||
if ($timezone !== null) {
|
||||
$result['timezone'] = $timezone;
|
||||
}
|
||||
|
||||
$show_last_value = static::parseIntOr(
|
||||
static::issetInArray($data, ['show_last_value', 'showLastValue']),
|
||||
null
|
||||
);
|
||||
if ($show_last_value !== null) {
|
||||
$result['show_last_value'] = $show_last_value;
|
||||
}
|
||||
|
||||
$cache_expiration = static::parseIntOr(
|
||||
static::issetInArray($data, ['cache_expiration', 'cacheExpiration']),
|
||||
null
|
||||
);
|
||||
if ($cache_expiration !== null) {
|
||||
$result['cache_expiration'] = $cache_expiration;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract item id.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item id. 0 by default.
|
||||
*/
|
||||
private static function getId(array $data): int
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id', 'itemId']),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract layout id.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item id. 0 by default.
|
||||
*/
|
||||
private static function getIdLayout(array $data): int
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id_layout', 'idLayout', 'layoutId']),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract item width.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item width. 0 by default.
|
||||
*/
|
||||
private static function getWidth(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['width', 'endX']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract item height.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item height. 0 by default.
|
||||
*/
|
||||
private static function getHeight(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['height', 'endY']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a image src value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return mixed String representing the image url (not empty) or null.
|
||||
*/
|
||||
protected static function getImageSrc(array $data)
|
||||
{
|
||||
$imageSrc = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['image', 'imageSrc', 'backgroundColor', 'backgroundType', 'valueType']),
|
||||
null
|
||||
);
|
||||
|
||||
return $imageSrc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a border width value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Valid border width.
|
||||
*/
|
||||
private static function getBorderWidth(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['border_width', 'borderWidth']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a type graph value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return string One of 'vertical' or 'horizontal'. 'vertical' by default.
|
||||
*/
|
||||
private static function getTypeGraph(array $data)
|
||||
{
|
||||
return static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['typeGraph', 'type_graph', 'graphType']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a border color value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return mixed String representing the border color (not empty) or null.
|
||||
*/
|
||||
private static function getBorderColor(array $data)
|
||||
{
|
||||
return static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['borderColor', 'border_color', 'gridColor', 'color', 'legendBackgroundColor']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a fill color value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return mixed String representing the fill color (not empty) or null.
|
||||
*/
|
||||
private static function getFillColor(array $data)
|
||||
{
|
||||
return static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['fillColor', 'fill_color', 'labelColor']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert or update an item in the database
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return boolean The modeled element data structure stored into the DB.
|
||||
*
|
||||
* @overrides Model::save.
|
||||
*/
|
||||
public function save(array $data=[]): bool
|
||||
{
|
||||
if (empty($data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$dataModelEncode = $this->encode($this->toArray());
|
||||
$dataEncode = $this->encode($data);
|
||||
|
||||
$save = \array_merge($dataModelEncode, $dataEncode);
|
||||
|
||||
if (!empty($save)) {
|
||||
if (empty($save['id'])) {
|
||||
// Insert.
|
||||
$result = \db_process_sql_insert('tlayout_data', $save);
|
||||
if ($result) {
|
||||
$item = static::fromDB(['id' => $result]);
|
||||
}
|
||||
} else {
|
||||
// Update.
|
||||
$result = \db_process_sql_update('tlayout_data', $save, ['id' => $save['id']]);
|
||||
// Invalidate the item's cache.
|
||||
if ($result !== false && $result > 0) {
|
||||
db_process_sql_delete(
|
||||
'tvisual_console_elements_cache',
|
||||
[
|
||||
'vc_item_id' => (int) $save['id'],
|
||||
]
|
||||
);
|
||||
|
||||
$item = static::fromDB(['id' => $save['id']]);
|
||||
// Update the model.
|
||||
if (!empty($item)) {
|
||||
$this->setData($item->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -206,4 +206,203 @@ final class Line extends Model
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a valid representation of a record in database.
|
||||
*
|
||||
* @param array $data Input data.
|
||||
*
|
||||
* @return array Data structure representing a record in database.
|
||||
*
|
||||
* @overrides Model::encode.
|
||||
*/
|
||||
protected function encode(array $data): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$id = static::getId($data);
|
||||
if ($id) {
|
||||
$result['id'] = $id;
|
||||
}
|
||||
|
||||
$id_layout = static::getIdLayout($data);
|
||||
if ($id_layout) {
|
||||
$result['id_layout'] = $id_layout;
|
||||
}
|
||||
|
||||
$pos_x = static::parseIntOr(
|
||||
static::issetInArray($data, ['x', 'pos_x', 'posX']),
|
||||
null
|
||||
);
|
||||
if ($pos_x !== null) {
|
||||
$result['pos_x'] = $pos_x;
|
||||
}
|
||||
|
||||
$pos_y = static::parseIntOr(
|
||||
static::issetInArray($data, ['y', 'pos_y', 'posY']),
|
||||
null
|
||||
);
|
||||
if ($pos_y !== null) {
|
||||
$result['pos_y'] = $pos_y;
|
||||
}
|
||||
|
||||
$height = static::getHeight($data);
|
||||
if ($height !== null) {
|
||||
$result['height'] = $height;
|
||||
}
|
||||
|
||||
$width = static::getWidth($data);
|
||||
if ($width !== null) {
|
||||
$result['width'] = $width;
|
||||
}
|
||||
|
||||
$type = static::parseIntOr(
|
||||
static::issetInArray($data, ['type']),
|
||||
null
|
||||
);
|
||||
if ($type !== null) {
|
||||
$result['type'] = $type;
|
||||
}
|
||||
|
||||
$border_width = static::getBorderWidth($data);
|
||||
if ($border_width !== null) {
|
||||
$result['border_width'] = $border_width;
|
||||
}
|
||||
|
||||
$border_color = static::extractBorderColor($data);
|
||||
if ($border_color !== null) {
|
||||
$result['border_color'] = $border_color;
|
||||
}
|
||||
|
||||
$show_on_top = static::issetInArray($data, ['isOnTop', 'show_on_top', 'showOnTop']);
|
||||
if ($show_on_top !== null) {
|
||||
$result['show_on_top'] = static::parseBool($show_on_top);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract item id.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item id. 0 by default.
|
||||
*/
|
||||
private static function getId(array $data): int
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id', 'itemId']),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract layout id.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item id. 0 by default.
|
||||
*/
|
||||
private static function getIdLayout(array $data): int
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id_layout', 'idLayout', 'layoutId']),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract item width.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item width. 0 by default.
|
||||
*/
|
||||
private static function getWidth(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['width', 'endX']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract item height.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item height. 0 by default.
|
||||
*/
|
||||
private static function getHeight(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['height', 'endY']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a border width value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Valid border width.
|
||||
*/
|
||||
private static function getBorderWidth(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['border_width', 'borderWidth']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert or update an item in the database
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return boolean The modeled element data structure stored into the DB.
|
||||
*
|
||||
* @overrides Model::save.
|
||||
*/
|
||||
public function save(array $data=[]): bool
|
||||
{
|
||||
$data_model = $this->encode($this->toArray());
|
||||
$newData = $this->encode($data);
|
||||
|
||||
$save = \array_merge($data_model, $newData);
|
||||
|
||||
if (!empty($save)) {
|
||||
if (empty($save['id'])) {
|
||||
// Insert.
|
||||
$result = \db_process_sql_insert('tlayout_data', $save);
|
||||
} else {
|
||||
// Update.
|
||||
$result = \db_process_sql_update('tlayout_data', $save, ['id' => $save['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the model.
|
||||
if ($result) {
|
||||
if (empty($save['id'])) {
|
||||
$item = static::fromDB(['id' => $result]);
|
||||
} else {
|
||||
$item = static::fromDB(['id' => $save['id']]);
|
||||
}
|
||||
|
||||
if (!empty($item)) {
|
||||
$this->setData($item->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -211,13 +211,14 @@ final class ModuleGraph extends Item
|
||||
|
||||
$params = [
|
||||
'period' => $period,
|
||||
'width' => $data['width'],
|
||||
'width' => (int) $data['width'],
|
||||
'height' => ($data['height'] - 30),
|
||||
'title' => '',
|
||||
'unit_name' => null,
|
||||
'show_alerts' => false,
|
||||
'only_image' => $imageOnly,
|
||||
'vconsole' => true,
|
||||
'document_ready' => false,
|
||||
'backgroundColor' => $backgroundType,
|
||||
];
|
||||
|
||||
@ -244,7 +245,7 @@ final class ModuleGraph extends Item
|
||||
'agent_module_id' => $moduleId,
|
||||
'period' => $period,
|
||||
'show_events' => false,
|
||||
'width' => $data['width'],
|
||||
'width' => (int) $data['width'],
|
||||
'height' => ($data['height'] - 30),
|
||||
'title' => \modules_get_agentmodule_name($moduleId),
|
||||
'unit' => \modules_get_unit($moduleId),
|
||||
@ -253,6 +254,7 @@ final class ModuleGraph extends Item
|
||||
'backgroundColor' => $backgroundType,
|
||||
'type_graph' => $graphType,
|
||||
'vconsole' => true,
|
||||
'document_ready' => false,
|
||||
];
|
||||
|
||||
$data['html'] = \grafico_modulo_sparse($params);
|
||||
|
@ -119,8 +119,8 @@ a#qr_code_agent_view {
|
||||
border-bottom-right-radius: 0px;
|
||||
}
|
||||
|
||||
.adv_right,
|
||||
.adv_left,
|
||||
.agent_av_opt_right,
|
||||
.agent_av_opt_left,
|
||||
.secondary_groups_list {
|
||||
flex: 1;
|
||||
}
|
||||
@ -150,8 +150,8 @@ a#qr_code_agent_view {
|
||||
margin: 1em;
|
||||
}
|
||||
|
||||
.adv_left input,
|
||||
.adv_left select {
|
||||
.agent_av_opt_left input,
|
||||
.agent_av_opt_left select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user