Merge remote-tracking branch 'origin/develop' into pandora_enterprise#2987

Conflicts:
	pandora_console/include/functions_events.php


Former-commit-id: 2c85907168c27c3707955668209ae5df2af4f4a7
This commit is contained in:
Kike 2019-01-03 13:10:10 +01:00
commit 133a5dc13e
217 changed files with 8081 additions and 35707 deletions

View File

@ -247,4 +247,11 @@ button h3 {
}
.sev-Maintenance {
background: #A8A8A8;
}
.sev-Minor {
background: #F099A2;
color: #333;
}
.sev-Major {
background: #C97A4A;
}

View File

@ -3,7 +3,7 @@ var isFetching = null;
var storedEvents = new Array();
var notVisited = {};
$(window).load(function() {
$(window).on('load', function() {
initilise();
// Wait some ms to throw main function
var delay = setTimeout(main, 100);
@ -29,11 +29,13 @@ function main() {
if (isFetching) return;
isFetching = true;
var feedUrl = localStorage["ip_address"]+'/include/api.php?op=get&op2=events&return_type=csv&apipass='+localStorage["api_pass"]+'&user='+localStorage["user_name"]+'&pass='+localStorage["pass"];
var feedUrl = localStorage["ip_address"]+'/include/api.php?op=get&op2=events&return_type=json&apipass='+localStorage["api_pass"]+'&user='+localStorage["user_name"]+'&pass='+localStorage["pass"];
req = new XMLHttpRequest();
req.onload = handleResponse;
req.onerror = handleError;
req.open("GET", feedUrl, true);
req.withCredentials = true
req.send(null);
}
@ -132,25 +134,23 @@ function fetchNewEvents(A,B){
function parseReplyEvents (reply) {
// Split the API response
var e_array = reply.split("\n");
var data = JSON.parse(reply)
var e_array = JSON.parse(reply).data;
// Form a properly object
var fetchedEvents=new Array();
for(var i=0;i<e_array.length;i++){
// Avoid to parse empty lines
if (e_array[i].length == 0) continue;
var event=e_array[i].split(";");
var event=e_array[i];
fetchedEvents.push({
'id' : event[0],
'agent_name' : event[1],
'agent' : event[2],
'date' : event[5],
'title' : event[6],
'module' : event[9],
'type' : event[14],
'source' : event[17],
'severity' : event[28],
'id' : event.id_evento,
'agent_name' : event.agent_name,
'agent' : event.id_agente,
'date' : event.timestamp,
'title' : event.evento,
'module' : event.id_agentmodule,
'type' : event.event_type,
'source' : event.source,
'severity' : event.criticity_name,
'visited' : false
});
}
@ -215,7 +215,7 @@ function getNotification(pEvent){
if(pEvent['module'] != 0) even += " in the module with Id "+ pEvent['module'];
even += ".";
var url = (pEvent['agent']=="")
var url = (pEvent['agent'] == 0)
? localStorage["ip_address"]+"/index.php?sec=eventos&sec2=operation/events/events"
: localStorage["ip_address"]+"/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=" + pEvent['agent'];

View File

@ -1,17 +1,14 @@
console.log("hola");
var url = window.location.href;
var re = /\?event=(\d+)/;
console.log("hola");
if(re.exec(url)) {
if(!isNaN(RegExp.$1)) {
var eventId = RegExp.$1;
document.write(chrome.extension.getBackgroundPage().getNotification(eventId));
}
}
console.log("hola");
window.onload = function () {
setTimeout(function() {
window.close();
}, 10000);
}
console.log("hola");

View File

@ -91,12 +91,12 @@ function showEvents(){
var a = document.createElement('a');
var temp_style;
var agent_url = (allEvents[i]["agent_name"] == 0)
var agent_url = (allEvents[i]["agent"] == 0)
? localStorage["ip_address"]
+ "/index.php?sec=eventos&sec2=operation/events/events"
: localStorage["ip_address"]
+ "/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente="
+ allEvents[i]['agent_name'];
+ allEvents[i]['agent'];
a.setAttribute("href",agent_url);
a.target = "_blank";
a.className = 'a_2_mo';

View File

@ -1,6 +1,6 @@
{
"name": "__MSG_name__",
"version": "2.0",
"version": "2.1",
"manifest_version": 2,
"description": "Pandora FMS Event viewer Chrome extension",
"homepage_url": "http://pandorafms.com",
@ -23,6 +23,7 @@
"tabs",
"notifications",
"http://*/*",
"https://*/*",
"background"
],
"default_locale": "en"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2010 Artica Soluciones Tecnologicas
# Version 7.0NG.728
# Version 7.0NG.729
# 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

View File

@ -58,8 +58,17 @@ use strict;
use File::Basename;
use Getopt::Std;
use IO::Select;
use IO::Compress::Zip qw(zip $ZipError);
use IO::Uncompress::Unzip qw(unzip $UnzipError);
my $zlib_available = 1;
eval {
eval "use IO::Compress::Zip qw(zip);1" or die($@);
eval "use IO::Uncompress::Unzip qw(unzip);1" or die($@);
};
if ($@) {
print_log ("Zip transfer not available, required libraries not found (IO::Compress::Zip, IO::Uncompress::Unzip).");
$zlib_available = 0;
}
use Socket (qw(SOCK_STREAM AF_INET AF_INET6));
my $SOCKET_MODULE =
eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
@ -324,7 +333,9 @@ sub parse_options {
# Compress data
if (defined ($opts{'z'})) {
$t_zip = 1;
if ($zlib_available == 1) {
$t_zip = 1;
}
}
}
@ -622,7 +633,7 @@ sub zrecv_file {
# Receive file
$zdata = recv_data_block ($size);
if (!unzip(\$zdata => \$data)) {
print_log ("Uncompress error: $UnzipError");
print_log ("Uncompress error: $IO::Uncompress::Unzip::UnzipError");
send_data ("ZRECV ERR\n");
return;
}
@ -705,7 +716,7 @@ sub zsend_file {
# Read the file and compress its contents
if (! zip($file => \$data)) {
send_data ("QUIT\n");
error ("Compression error: $ZipError");
error ("Compression error: $IO::Compress::Zip::ZipError");
return;
}
@ -725,7 +736,7 @@ sub zsend_file {
error ("Server responded $response.");
}
print_log ("Server responded SEND OK");
print_log ("Server responded ZSEND OK");
send_data ($data);
# Wait for server response

View File

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

View File

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

View File

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

View File

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

View File

@ -58,8 +58,17 @@ use strict;
use File::Basename;
use Getopt::Std;
use IO::Select;
use IO::Compress::Zip qw(zip $ZipError);
use IO::Uncompress::Unzip qw(unzip $UnzipError);
my $zlib_available = 1;
eval {
eval "use IO::Compress::Zip qw(zip);1" or die($@);
eval "use IO::Uncompress::Unzip qw(unzip);1" or die($@);
};
if ($@) {
print_log ("Zip transfer not available, required libraries not found (IO::Compress::Zip, IO::Uncompress::Unzip).");
$zlib_available = 0;
}
use Socket (qw(SOCK_STREAM AF_INET AF_INET6));
my $SOCKET_MODULE =
eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
@ -324,7 +333,9 @@ sub parse_options {
# Compress data
if (defined ($opts{'z'})) {
$t_zip = 1;
if ($zlib_available == 1) {
$t_zip = 1;
}
}
}
@ -622,7 +633,7 @@ sub zrecv_file {
# Receive file
$zdata = recv_data_block ($size);
if (!unzip(\$zdata => \$data)) {
print_log ("Uncompress error: $UnzipError");
print_log ("Uncompress error: $IO::Uncompress::Unzip::UnzipError");
send_data ("ZRECV ERR\n");
return;
}
@ -705,7 +716,7 @@ sub zsend_file {
# Read the file and compress its contents
if (! zip($file => \$data)) {
send_data ("QUIT\n");
error ("Compression error: $ZipError");
error ("Compression error: $IO::Compress::Zip::ZipError");
return;
}
@ -725,7 +736,7 @@ sub zsend_file {
error ("Server responded $response.");
}
print_log ("Server responded SEND OK");
print_log ("Server responded ZSEND OK");
send_data ($data);
# Wait for server response

View File

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

View File

@ -58,8 +58,17 @@ use strict;
use File::Basename;
use Getopt::Std;
use IO::Select;
use IO::Compress::Zip qw(zip $ZipError);
use IO::Uncompress::Unzip qw(unzip $UnzipError);
my $zlib_available = 1;
eval {
eval "use IO::Compress::Zip qw(zip);1" or die($@);
eval "use IO::Uncompress::Unzip qw(unzip);1" or die($@);
};
if ($@) {
print_log ("Zip transfer not available, required libraries not found (IO::Compress::Zip, IO::Uncompress::Unzip).");
$zlib_available = 0;
}
use Socket (qw(SOCK_STREAM AF_INET AF_INET6));
my $SOCKET_MODULE =
eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
@ -324,7 +333,9 @@ sub parse_options {
# Compress data
if (defined ($opts{'z'})) {
$t_zip = 1;
if ($zlib_available == 1) {
$t_zip = 1;
}
}
}
@ -622,7 +633,7 @@ sub zrecv_file {
# Receive file
$zdata = recv_data_block ($size);
if (!unzip(\$zdata => \$data)) {
print_log ("Uncompress error: $UnzipError");
print_log ("Uncompress error: $IO::Uncompress::Unzip::UnzipError");
send_data ("ZRECV ERR\n");
return;
}
@ -705,7 +716,7 @@ sub zsend_file {
# Read the file and compress its contents
if (! zip($file => \$data)) {
send_data ("QUIT\n");
error ("Compression error: $ZipError");
error ("Compression error: $IO::Compress::Zip::ZipError");
return;
}
@ -725,7 +736,7 @@ sub zsend_file {
error ("Server responded $response.");
}
print_log ("Server responded SEND OK");
print_log ("Server responded ZSEND OK");
send_data ($data);
# Wait for server response

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.728-181029
Version: 7.0NG.729-181211
Architecture: all
Priority: optional
Section: admin

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.728
%define release 181029
%define version 7.0NG.729
%define release 181211
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}
@ -95,7 +95,8 @@ if [ ! -e /etc/pandora/plugins ]; then
fi
if [ ! -e /etc/pandora/collections ]; then
mkdir -p /etc/pandora/collections
mkdir -p /usr/share/pandora_agent/collections
ln -s /usr/share/pandora_agent/collections /etc/pandora
fi
mkdir -p /var/spool/pandora/data_out

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.728
%define release 181029
%define version 7.0NG.729
%define release 181211
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

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

View File

@ -25,12 +25,33 @@
###############################################################################
use strict;
use warnings;
# Retrieve information from all filesystems
my $all_filesystems = 0;
# Regex flag
my $regex_mode = 0;
my $inode_mode = 0;
# Exclusion
my @exclude_fs = ();
my $cmd = undef;
sub in_array {
my ($array, $value) = @_;
if (!defined($value)) {
return 0;
}
my %params = map { $_ => 1 } @{$array};
if (exists($params{$value})) {
return 1;
}
return 0;
}
sub check_re($$){
my $item = shift;
@ -65,10 +86,24 @@ if ($#ARGV < 0) {
$all_filesystems = 1;
}
# Check if regex mode is enabled
if ($ARGV[0] eq "-r") {
$regex_mode = 1;
shift @ARGV;
while ($#ARGV >= 0) {
my $param = shift @ARGV;
if ($param eq '-r') {
$regex_mode = 1;
shift @ARGV;
}
elsif ($param eq '-i') {
$inode_mode = 1;
}
elsif ($param eq '-exclude_fs') {
my $_tmp = shift @ARGV;
chomp ($_tmp);
@exclude_fs = split /,/, $_tmp;
}
elsif ($param eq '-custom_cmd') {
$cmd = shift @ARGV;
chomp ($cmd);
}
}
# Parse command line parameters
@ -90,7 +125,15 @@ if ($onlyexclude) {
# Retrieve filesystem information
# -P use the POSIX output format for portability
my @df = `df -P`;
$cmd = 'df -PT' unless defined($cmd);
if ($inode_mode > 0) {
$cmd = 'df -PTi';
}
my @df = `$cmd`;
shift (@df);
# No filesystems? Something went wrong.
@ -102,9 +145,13 @@ my %out;
# Parse filesystem usage
foreach my $row (@df) {
my @columns = split (' ', $row);
exit 1 if ($#columns < 4);
if (check_in (\%filesystems,$columns[0]) || ($all_filesystems == 1 && !check_in(\%excluded_filesystems,$columns[0]) )) {
$out{$columns[0]} = $columns[4] ;
exit 1 if ($#columns < 5);
next if (in_array(\@exclude_fs, $columns[1]) > 0);
if (check_in (\%filesystems,$columns[0])
|| ($all_filesystems == 1 && !check_in(\%excluded_filesystems,$columns[0])) ){
$out{$columns[0]} = $columns[5] ;
}
}
@ -115,7 +162,7 @@ while (my ($filesystem, $use) = each (%out)) {
# Print module output
print "<module>\n";
print "<name><![CDATA[" . $filesystem . "]]></name>\n";
print "<name><![CDATA[" . ($inode_mode > 0 ? 'Inodes:' : '') . $filesystem . "]]></name>\n";
print "<type><![CDATA[generic_data]]></type>\n";
print "<data><![CDATA[" . $use . "]]></data>\n";
print "<description><![CDATA[% of usage in this volume]]></description>\n";

View File

@ -58,8 +58,17 @@ use strict;
use File::Basename;
use Getopt::Std;
use IO::Select;
use IO::Compress::Zip qw(zip $ZipError);
use IO::Uncompress::Unzip qw(unzip $UnzipError);
my $zlib_available = 1;
eval {
eval "use IO::Compress::Zip qw(zip);1" or die($@);
eval "use IO::Uncompress::Unzip qw(unzip);1" or die($@);
};
if ($@) {
print_log ("Zip transfer not available, required libraries not found (IO::Compress::Zip, IO::Uncompress::Unzip).");
$zlib_available = 0;
}
use Socket (qw(SOCK_STREAM AF_INET AF_INET6));
my $SOCKET_MODULE =
eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
@ -324,7 +333,9 @@ sub parse_options {
# Compress data
if (defined ($opts{'z'})) {
$t_zip = 1;
if ($zlib_available == 1) {
$t_zip = 1;
}
}
}
@ -622,7 +633,7 @@ sub zrecv_file {
# Receive file
$zdata = recv_data_block ($size);
if (!unzip(\$zdata => \$data)) {
print_log ("Uncompress error: $UnzipError");
print_log ("Uncompress error: $IO::Uncompress::Unzip::UnzipError");
send_data ("ZRECV ERR\n");
return;
}
@ -705,7 +716,7 @@ sub zsend_file {
# Read the file and compress its contents
if (! zip($file => \$data)) {
send_data ("QUIT\n");
error ("Compression error: $ZipError");
error ("Compression error: $IO::Compress::Zip::ZipError");
return;
}
@ -725,7 +736,7 @@ sub zsend_file {
error ("Server responded $response.");
}
print_log ("Server responded SEND OK");
print_log ("Server responded ZSEND OK");
send_data ($data);
# Wait for server response

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2017 Artica Soluciones Tecnologicas
# Version 7.0NG.728
# Version 7.0NG.729
# 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

View File

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

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.728(Build 181029)")
#define PANDORA_VERSION ("7.0NG.729(Build 181211)")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.728(Build 181029))"
VALUE "ProductVersion", "(7.0NG.729(Build 181211))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,10 +1,10 @@
package: pandorafms-console
Version: 7.0NG.728-181029
Version: 7.0NG.729-181211
Architecture: all
Priority: optional
Section: admin
Installed-Size: 42112
Maintainer: Artica ST <deptec@artica.es>
Homepage: http://pandorafms.org/
Depends: php5.6 | php5, php5.6-snmp | php5-snmp, php5.6-gd | php5-gd, php5.6-mysql | php5-mysql, php-db, php5.6-xmlrpc | php5-xmlrpc, php-gettext, php5.6-curl | php5-curl, graphviz, dbconfig-common, php5.6-ldap | php5-ldap, mysql-client | virtual-mysql-client
Depends: php | php7.2, php7.2-snmp | php-snmp, php7.2-gd | php-gd, php7.2-mysqlnd | php-mysqlnd, php-db, php7.2-xmlrpc | php-xmlrpc, php-gettext, php7.2-curl | php-curl, graphviz, dbconfig-common, php7.2-ldap | php-ldap, mysql-client | virtual-mysql-client, php-xmlrpc, php7.2-zip | php-zip
Description: Pandora FMS is an Open Source monitoring tool. It monitor your systems and applications, and allows you to control the status of any element of them. The web console is the graphical user interface (GUI) to manage the pool and to generate reports and graphs from the Pandora FMS monitoring process.

View File

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

View File

@ -18,9 +18,8 @@ if ((! file_exists("include/config.php")) || (! is_readable("include/config.php"
exit;
}
// Real start
session_start();
// Don't start a session before this import.
// The session is configured and started inside the config process.
require_once ('include/config.php');
require_once ('include/functions.php');
require_once ('include/functions_db.php');
@ -82,7 +81,6 @@ if (isset($config['metaconsole'])) {
if ($config['metaconsole'])
define ('METACONSOLE', true);
}
session_write_close ();
if (file_exists ($page)) {
require_once ($page);

View File

@ -50,7 +50,7 @@ function dbmanager_query ($sql, &$error, $dbconnection) {
}
if($config["mysqli"]){
while ($row = mysqli_fetch_array ($result)) {
while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) {
array_push ($retval, $row);
}
}

View File

@ -16,14 +16,14 @@
if (isset($_GET['get_ptr'])) {
if ($_GET['get_ptr'] == 1) {
session_start ();
session_write_close ();
$ownDir = dirname(__FILE__) . '/';
$ownDir = str_replace("\\", "/", $ownDir);
// Don't start a session before this import.
// The session is configured and started inside the config process.
require_once ($ownDir.'../include/config.php');
// Login check
if (!isset($_SESSION["id_usuario"])) {
$config['id_user'] = null;

View File

@ -1,7 +1,22 @@
START TRANSACTION;
ALTER TABLE `talert_commands` ADD COLUMN `id_group` mediumint(8) unsigned NULL default 0;
ALTER TABLE `tusuario` DROP COLUMN `flash_chart`;
ALTER TABLE `tusuario` ADD COLUMN `default_custom_view` int(10) unsigned NULL default '0';
ALTER TABLE tlayout_template MODIFY `name` varchar(600) NOT NULL;
CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(600) NOT NULL,
`id_group` int(10) unsigned default '0',
`id_custom_field` varchar(600) default '',
`id_custom_fields_data` varchar(600) default '',
`id_status` varchar(600) default '',
`module_search` varchar(600) default '',
PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
COMMIT;

View File

@ -0,0 +1,9 @@
START TRANSACTION;
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `group_search` int(10) unsigned default '0';
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `module_status` varchar(600) default '';
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `recursion` int(1) unsigned default '0';
COMMIT;

View File

@ -54,7 +54,7 @@ $rows = db_get_all_rows_in_table('tupdate_settings');
$settings = new StdClass;
foreach ($rows as $row) {
$settings->$row['key'] = $row['value'];
$settings->{$row['key']} = $row['value'];
}
echo '<script type="text/javascript">';

View File

@ -1159,8 +1159,8 @@ ALTER TABLE talert_actions ADD COLUMN `field15_recovery` TEXT NOT NULL DEFAULT "
-- Table `talert_commands`
-- ---------------------------------------------------------------------
UPDATE `talert_commands` SET `fields_descriptions` = '[\"Integria&#x20;IMS&#x20;API&#x20;path\",\"Integria&#x20;IMS&#x20;API&#x20;pass\",\"Integria&#x20;IMS&#x20;user\",\"Integria&#x20;IMS&#x20;user&#x20;pass\",\"Ticket&#x20;title\",\"Ticket&#x20;group&#x20;ID\",\"Ticket&#x20;priority\",\"Email&#x20;copy\",\"Ticket&#x20;owner\",\"Ticket&#x20;description\"]', `fields_values` = '[\"\",\"\",\"\",\"\",\"\",\"\",\"10,Maintenance;0,Informative;1,Low;2,Medium;3,Serious;4,Very&#x20;Serious\",\"\",\"\",\"\"]' WHERE `id` = 11 AND `name` = 'Integria&#x20;IMS&#x20;Ticket';
UPDATE `talert_commands` SET `description` = 'This&#x20;alert&#x20;send&#x20;an&#x20;email&#x20;using&#x20;internal&#x20;Pandora&#x20;FMS&#x20;Server&#x20;SMTP&#x20;capabilities&#x20;&#40;defined&#x20;in&#x20;each&#x20;server,&#x20;using:&#x0d;&#x0a;_field1_&#x20;as&#x20;destination&#x20;email&#x20;address,&#x20;and&#x0d;&#x0a;_field2_&#x20;as&#x20;subject&#x20;for&#x20;message.&#x20;&#x0d;&#x0a;_field3_&#x20;as&#x20;text&#x20;of&#x20;message.&#x20;&#x0d;&#x0a;_field4_&#x20;as&#x20;content&#x20;type&#x20;&#40;text/plain&#x20;or&#x20;html/text&#41;.', `fields_descriptions` = '[\"Destination&#x20;address\",\"Subject\",\"Text\",\"Content&#x20;Type\",\"\",\"\",\"\",\"\",\"\",\"\"]', `fields_values` = '[\"\",\"\",\"_html_editor_\",\"_content_type_\",\"\",\"\",\"\",\"\",\"\",\"\"]' WHERE id=1;
ALTER TABLE `talert_commands` ADD COLUMN `id_group` mediumint(8) unsigned NULL default 0;
UPDATE `talert_actions` SET `field4` = 'text/html', `field4_recovery` = 'text/html' WHERE id = 1;
@ -1180,13 +1180,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', 22);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 23);
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', '729');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '730');
-- ---------------------------------------------------------------------
-- Table `tconfig_os`
@ -1231,6 +1231,7 @@ ALTER TABLE tusuario ADD COLUMN `session_time` int(10) signed NOT NULL default '
alter table tusuario add autorefresh_white_list text not null default '';
ALTER TABLE tusuario ADD COLUMN `time_autorefresh` int(5) unsigned NOT NULL default '30';
ALTER TABLE `tusuario` DROP COLUMN `flash_chart`;
ALTER TABLE `tusuario` ADD COLUMN `default_custom_view` int(10) unsigned NULL default '0';
-- ---------------------------------------------------------------------
-- Table `tagente_modulo`
@ -1811,3 +1812,23 @@ ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_method` varchar(25) NOT NULL def
ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_method` varchar(25) NOT NULL default '';
ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_pass` varchar(255) NOT NULL default '';
ALTER TABLE `trecon_task` ADD COLUMN `snmp_security_level` varchar(25) NOT NULL default '';
-- ---------------------------------------------------------------------
-- Table `tagent_custom_fields_filter`
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(600) NOT NULL,
`id_group` int(10) unsigned default '0',
`id_custom_field` varchar(600) default '',
`id_custom_fields_data` varchar(600) default '',
`id_status` varchar(600) default '',
`module_search` varchar(600) default '',
PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `module_status` varchar(600) default '';
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `recursion` int(1) unsigned default '0';
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `group_search` int(10) unsigned default '0';

View File

@ -32,9 +32,7 @@ if (!$config["MR"]) {
echo '<a class="white_bold footer" target="_blank" href="' . $config["homeurl"] . $license_file. '">';
if(enterprise_installed()){
enterprise_include_once("../include/functions_update_manager.php");
}
include_once ($config["homedir"]."/include/functions_update_manager.php");
$current_package = update_manager_get_current_package();
@ -48,7 +46,7 @@ else{
echo sprintf(__('%s %s - Build %s - MR %s', get_product_name(), $pandora_version, $build_package_version, $config["MR"]));
echo '</a><br />';
echo '<a class="white footer">'. __('Page generated at') . ' '. date('F j, Y h:i a'); //Always use timestamp here
echo '<a class="white footer">'. __('Page generated at') . ' '. date($config["date_format"]);
echo '</a><br /><span style="color:#eff">&reg; '.get_copyright_notice().'</span>';
if (isset ($config['debug'])) {

View File

@ -484,8 +484,8 @@ if($login_screen == 'error_authconfig' || $login_screen == 'error_emptyconfig' |
}
ui_require_css_file ('dialog');
ui_require_css_file ('jquery-ui-1.10.0.custom');
ui_require_jquery_file('jquery-ui-1.10.0.custom');
ui_require_css_file ('jquery-ui.min');
ui_require_jquery_file('jquery-ui.min');
?>
<?php

View File

@ -335,11 +335,8 @@ $(document).ready( function() {
handsIn = 0;
handsIn2 = 0;
//Daniel maya 02/06/2016 Display menu with click --INI
if(!click_display){
//Daniel barbero 10/08/2016 Display menu with click --INI
if (autohidden_menu) {
//Daniel barbero 10/08/2016 Display menu with click --END
$('.menu_icon').mouseenter(function() {
table_hover = $(this);
handsIn = 1;
@ -359,37 +356,10 @@ $(document).ready( function() {
}
}, 2500);
});
//Daniel barbero 10/08/2016 Display menu with click --INI
} else {
$('.menu_icon').mouseenter(function() {
table_hover = $(this);
handsIn = 1;
openTime = new Date().getTime();
$("ul#sub"+table_hover[0].id).show();
if( typeof(table_noHover) != 'undefined')
if ( "ul#sub"+table_hover[0].id != "ul#sub"+table_noHover[0].id )
$("ul#sub"+table_noHover[0].id).hide();
}).mouseleave(function() {
table_noHover = $(this);
handsIn = 0;
$("ul#sub"+table_hover[0].id).hide();
/*
setTimeout(function() {
opened = new Date().getTime() - openTime;
if(opened > 3000 && handsIn == 0) {
openTime = 4000;
$("ul#sub"+table_hover[0].id).hide();
}
}, 2500);
*/
});
}
//Daniel barbero 10/08/2016 Display menu with click --END
}else{
$(document).ready(function() {
//Daniel barbero 10/08/2016 Display menu with click --INI
if (autohidden_menu) {
//Daniel barbero 10/08/2016 Display menu with click --END
$('.menu_icon').on("click", function() {
if( typeof(table_hover) != 'undefined'){
$("ul#sub"+table_hover[0].id).hide();
@ -409,7 +379,6 @@ $(document).ready( function() {
}
}, 5500);
});
//Daniel barbero 10/08/2016 Display menu with click --INI
} else {
$('.menu_icon').on("click", function() {
if( typeof(table_hover) != 'undefined'){
@ -421,10 +390,8 @@ $(document).ready( function() {
$("ul#sub"+table_hover[0].id).show();
});
}
//Daniel barbero 10/08/2016 Display menu with click --END
});
}
//Daniel maya 02/06/2016 Display menu with click --END
- $('.has_submenu').mouseenter(function() {
table_hover2 = $(this);

View File

@ -14,8 +14,10 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Don't start a session before this import.
// The session is configured and started inside the config process.
require_once ("../include/config.php");
require_once ("../include/functions.php");
require_once ("../include/functions_html.php");
?>
@ -33,11 +35,6 @@ require_once ("../include/functions_html.php");
$id = get_parameter ('id');
$id_user = get_parameter ('id_user');
if (! isset($_SESSION['id_usuario'])) {
session_start();
session_write_close();
}
$user_language = get_user_language ($id_user);
if (file_exists ('../include/languages/'.$user_language.'.mo')) {

View File

@ -0,0 +1,67 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// 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; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
/**
* @package General
*/
global $config;
if ($config['language'] == 'es') {
$url_help = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Instalaci%C3%B3n_y_actualizaci%C3%B3n_PHP_7';
}
else{
$url_help = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:_PHP_7';
}
// Prints help dialog information
echo '<div id="login_help_dialog" title="PHP UPDATE REQUIRED" style="display: none;">';
echo '<div style="width:70%; font-size: 10pt; margin: 20px; float:left">';
echo "<p><b style='font-size: 10pt;'>" . __('For a correct operation of PandoraFMS, PHP must be updated to version 7.0 or higher.') . "</b></p>";
echo "<p style='font-size: 10pt;'><b>" . __('Otherwise, functionalities will be lost.') . "</b></p>";
echo "<ul>";
echo "<li style='padding:5px;'>" . __('Report download in PDF format') . "</li>";
echo "<li style='padding:5px;'>" . __('Emails Sending') . "</li>";
echo "<li style='padding:5px;'>" . __('Metaconsole Collections') . "</li>";
echo "<li style='padding:5px;'>" . '...' . "</li>";
echo "</ul>";
echo '<p><a target="blank" href="' . $url_help . '"><b>'.__('Access Help').'</b></a></p>';
echo '</div>';
echo "<div style='margin-top: 80px;'>";
echo html_print_image('images/icono_warning_mr.png', true, array("alt" => __('Warning php version'), "border" => 0));
echo "</div>";
echo '</div>';
?>
<script type="text/javascript" language="javascript">
/* <![CDATA[ */
$(document).ready (function () {
$("#login_help_dialog").dialog({
resizable: true,
draggable: true,
modal: true,
height: 320,
width: 550,
overlay: {
opacity: 0.5,
background: "black"
}
});
});
/* ]]> */
</script>

View File

@ -228,11 +228,11 @@ foreach ($result as $row) {
$rowPair = !$rowPair;
$data = array();
$data[0] = $row["id_usuario"];
$data[0] = io_safe_output($row["id_usuario"]);
$data[1] = ui_print_session_action_icon($row["accion"], true) . $row["accion"];
$data[2] = ui_print_help_tip(date($config["date_format"], $row["utimestamp"]), true)
. ui_print_timestamp($row["utimestamp"], true);
$data[3] = $row["ip_origen"];
$data[3] = io_safe_output($row["ip_origen"]);
$data[4] = io_safe_output($row["descripcion"]);
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {

View File

@ -261,7 +261,7 @@ if ($snmpwalk) {
}
if ($create_modules) {
$modules = get_parameter("module", array());
$modules = io_safe_output(get_parameter("module", array()));
$devices = array();
$processes = array();

View File

@ -924,9 +924,8 @@ if ($update_agent) { // if modified some agent paramenter
enterprise_hook ('update_agent', array ($id_agente));
ui_print_success_message (__('Successfully updated'));
$unsafe_alias = io_safe_output($alias);
db_pandora_audit("Agent management",
"Updated agent $unsafe_alias", false, false, $info);
"Updated agent $alias", false, false, $info);
}
}
@ -1427,7 +1426,7 @@ if ($update_module) {
$edit_module = true;
db_pandora_audit("Agent management",
"Fail to try update module '".io_safe_output($name)."' for agent " . io_safe_output($agent["alias"]));
"Fail to try update module '$name' for agent " . $agent["alias"]);
}
else {
if ($prediction_module == 3) {
@ -1445,7 +1444,7 @@ if ($update_module) {
$agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management",
"Updated module '".io_safe_output($name)."' for agent ". io_safe_output($agent["alias"]), false, false, io_json_mb_encode($values));
"Updated module '$name' for agent ".$agent["alias"], false, false, io_json_mb_encode($values));
}
}
@ -1586,7 +1585,7 @@ if ($create_module) {
$edit_module = true;
$moduletype = $id_module;
db_pandora_audit("Agent management",
"Fail to try added module '".io_safe_output($name)."' for agent ".io_safe_output($agent["alias"]));
"Fail to try added module '$name' for agent ".$agent["alias"]);
}
else {
if ($prediction_module == 3) {
@ -1604,7 +1603,7 @@ if ($create_module) {
$agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management",
"Added module '".io_safe_output($name)."' for agent ".io_safe_output($agent["alias"]), false, true, io_json_mb_encode($values));
"Added module '$name' for agent ".$agent["alias"], false, true, io_json_mb_encode($values));
}
}
@ -1727,7 +1726,7 @@ if ($delete_module) { // DELETE agent module !
$agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management",
"Deleted module '".io_safe_output($module_data["nombre"])."' for agent ".io_safe_output($agent["alias"]));
"Deleted module '".$module_data["nombre"]."' for agent ".$agent["alias"]);
}
@ -1760,11 +1759,11 @@ if (!empty($duplicate_module)) { // DUPLICATE agent module !
if ($result) {
db_pandora_audit("Agent management",
"Duplicate module '".$id_duplicate_module."' for agent " . io_safe_output($agent["alias"]) . " with the new id for clon " . $result);
"Duplicate module '".$id_duplicate_module."' for agent " . $agent["alias"] . " with the new id for clon " . $result);
}
else {
db_pandora_audit("Agent management",
"Fail to try duplicate module '".$id_duplicate_module."' for agent " . io_safe_output($agent["alias"]));
"Fail to try duplicate module '".$id_duplicate_module."' for agent " . $agent["alias"]);
}
}
@ -1943,7 +1942,7 @@ switch ($tab) {
var aget_id_os = '<?php echo agents_get_os(modules_get_agentmodule_agent(get_parameter("id_agent_module"))); ?>';
if('<?php echo modules_get_agentmodule_name(get_parameter("id_agent_module")); ?>' != $('#text-name').val() &&
if('<?php echo html_entity_decode(modules_get_agentmodule_name(get_parameter("id_agent_module"))); ?>' != $('#text-name').val() &&
'<?php echo agents_get_os(modules_get_agentmodule_agent(get_parameter("id_agent_module"))); ?>' == 19){
event.preventDefault();
@ -1977,7 +1976,7 @@ switch ($tab) {
var module_type_snmp = '<?php echo modules_get_agentmodule_type(get_parameter("id_agent_module")); ?>';
if('<?php echo modules_get_agentmodule_name(get_parameter("id_agent_module")); ?>' != $('#text-name').val() && (
if('<?php echo html_entity_decode(modules_get_agentmodule_name(get_parameter("id_agent_module"))); ?>' != $('#text-name').val() && (
module_type_snmp == 15 || module_type_snmp == 16 || module_type_snmp == 17 || module_type_snmp == 18)){
event.preventDefault();

View File

@ -481,15 +481,14 @@ if ($agents !== false) {
if($agent["id_os"] == 100){
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']);
echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.$agent['nombre'].'</a>';
echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.$agent['alias'].'</a>';
}else{
echo "<a alt =".$agent["nombre"]." href='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=$main_tab&
id_agente=" . $agent["id_agente"] . "'>" .
'<span style="font-size: 7pt" title="' . $agent["nombre"] . '">'.$agent["alias"].'</span>' .
"</a>";
}
}
echo "</strong>";
$in_planned_downtime = db_get_sql('SELECT executed FROM tplanned_downtime

View File

@ -13,9 +13,10 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
session_start ();
// Don't start a session before this import.
// The session is configured and started inside the config process.
require_once ("../../include/config.php");
require_once ("../../include/functions.php");
require_once ("../../include/functions_db.php");
require_once ("../../include/functions_users.php");

View File

@ -57,7 +57,7 @@ else {
$sec = 'galertas';
}
if ((!$copy_action) && (!$delete_action) && (!$update_action)) {
if ((!$copy_action) && (!$delete_action)) {
// Header
if (defined('METACONSOLE')) {
alerts_meta_print_header ();
@ -141,135 +141,8 @@ if ($copy_action) {
__('Could not be copied'));
}
if ($create_action) {
$name = (string) get_parameter ('name');
$id_alert_command = (int) get_parameter ('id_command');
$fields_descriptions = array();
$fields_values = array();
$info_fields = '';
$values = array();
for($i=1;$i<=$config['max_macro_fields'];$i++) {
$values['field'.$i] = (string) get_parameter ('field'.$i.'_value');
$info_fields .= ' Field'.$i.': ' . $values['field'.$i];
$values['field'.$i.'_recovery'] = (string) get_parameter ('field'.$i.'_recovery_value');
$info_fields .= ' Field'.$i.'Recovery: ' . $values['field'.$i.'_recovery'];
}
$values['id_group'] = (string) get_parameter ('group');
$values['action_threshold'] = (int) get_parameter ('action_threshold');
$name_check = db_get_value ('name', 'talert_actions', 'name', $name);
if ($name_check) {
$result = '';
}
else {
$result = alerts_create_alert_action ($name, $id_alert_command,
$values);
$info = '{"Name":"'.$name.'", "ID alert Command":"'.$id_alert_command.'", "Field information":"'.$info_fields.'", "Group":"'.$values['id_group'].'",
"Action threshold":"'.$values['action_threshold'].'"}';
}
if ($result) {
db_pandora_audit("Command management", "Create alert action #" . $result, false, false, $info);
}
else {
db_pandora_audit("Command management", "Fail try to create alert action", false, false);
}
/* Show errors */
if (!isset($messageAction)) {
$messageAction = __('Could not be created');
}
if ($name == "") {
$messageAction = __('No name specified');
}
if ($id_alert_command == "") {
$messageAction = __('No command specified');
}
$messageAction = ui_print_result_message ($result,
__('Successfully created'),
$messageAction);
}
if ($update_action) {
$id = (string) get_parameter ('id');
$al_action = alerts_get_alert_action ($id);
if ($al_action !== false) {
if ($al_action['id_group'] == 0) {
if (! check_acl ($config['id_user'], 0, "PM")) {
db_pandora_audit("ACL Violation",
"Trying to access Alert Management");
require ("general/noaccess.php");
exit;
}
else {
// Header
if (defined('METACONSOLE')) {
alerts_meta_print_header ();
}
else {
ui_print_page_header (__('Alerts').' &raquo; '.__('Alert actions'), "images/gm_alerts.png", false, "alerts_config", true);
}
}
}
}
else {
// Header
if (defined('METACONSOLE')) {
alerts_meta_print_header ();
}
else {
ui_print_page_header (__('Alerts').' &raquo; '.__('Alert actions'), "images/gm_alerts.png", false, "alerts_config", true);
}
}
$name = (string) get_parameter ('name');
$id_alert_command = (int) get_parameter ('id_command');
$group = get_parameter ('group');
$action_threshold = (int) get_parameter ('action_threshold');
$info_fields = '';
$values = array();
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
$values['field'.$i] = (string) get_parameter ('field'.$i.'_value');
$info_fields .= ' Field1: ' . $values['field'.$i];
$values['field'.$i.'_recovery'] = (string) get_parameter ('field'.$i.'_recovery_value');
$info_fields .= ' Field'.$i.'Recovery: ' . $values['field'.$i.'_recovery'];
}
$values['name'] = $name;
$values['id_alert_command'] = $id_alert_command;
$values['id_group'] = $group;
$values['action_threshold'] = $action_threshold;
if (!$name) {
$result = '';
}
else {
$result = alerts_update_alert_action ($id, $values);
}
if ($result) {
db_pandora_audit("Command management", "Update alert action #" . $id, false, false, json_encode($values));
}
else {
db_pandora_audit("Command management", "Fail try to update alert action #" . $id, false, false, json_encode($values));
}
ui_print_result_message ($result,
__('Successfully updated'),
__('Could not be updated'));
if ($update_action || $create_action) {
alerts_ui_update_or_create_actions($update_action);
}
if ($delete_action) {
@ -342,6 +215,7 @@ if ($delete_action) {
__('Could not be deleted'));
}
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox data';
$table->data = array ();
@ -363,9 +237,13 @@ $table->align[3] = 'left';
$filter = array();
if (!is_user_admin($config['id_user']))
$filter['id_group'] = array_keys(users_get_groups(false, "LM"));
$filter['talert_actions.id_group'] = array_keys(users_get_groups(false, "LM"));
$actions = db_get_all_rows_filter ('talert_actions', $filter);
$actions = db_get_all_rows_filter (
'talert_actions INNER JOIN talert_commands ON talert_actions.id_alert_command = talert_commands.id',
$filter,
'talert_actions.* , talert_commands.id_group AS command_group'
);
if ($actions === false)
$actions = array ();
@ -380,11 +258,19 @@ foreach ($actions as $action) {
$iterator++;
$data = array ();
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&id='.$action['id'].'&pure='.$pure.'">'.
$action['name'].'</a>';
$data[1] = ui_print_group_icon ($action["id_group"], true) .'&nbsp;';
if (!alerts_validate_command_to_action($action["id_group"], $action["command_group"])) {
$data[1].= html_print_image(
"images/error.png",
true,
// FIXME: Translation.
array("title" => __("The action and the command associated with it do not have the same group. Please contact an administrator to fix it.")
));
}
if (check_acl($config['id_user'], $action["id_group"], "LM")) {
$data[2] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions&amp;copy_action=1&amp;id='.$action['id'].'&pure='.$pure.'"
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">' .
@ -393,7 +279,7 @@ foreach ($actions as $action) {
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.
html_print_image("images/cross.png", true) . '</a>';
}
array_push ($table->data, $data);
}
if (isset($data)) {

View File

@ -38,6 +38,7 @@ $pure = (int)get_parameter('pure', 0);
$update_command = (bool) get_parameter ('update_command');
$create_command = (bool) get_parameter ('create_command');
$delete_command = (bool) get_parameter ('delete_command');
$copy_command = (bool) get_parameter ('copy_command');
if (is_ajax ()) {
$get_alert_command = (bool) get_parameter ('get_alert_command');
@ -57,37 +58,13 @@ if (is_ajax ()) {
if (isset($command['description'])) {
$command['description'] = io_safe_input(str_replace("\r\n","<br>", io_safe_output($command['description'])));
}
// Get the html rows of the fields form
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
// Descriptions are stored in json
$fields_descriptions = empty($command['fields_descriptions']) ?
'' : json_decode(io_safe_output($command['fields_descriptions']), true);
// Fields values are stored in json
$fields_values = empty($command['fields_values']) ?
'' : io_safe_output(json_decode($command['fields_values'], true));
break;
case "oracle":
// Descriptions are stored in json
$description_field = str_replace("\\\"","\"",$command['fields_descriptions']);
$description_field = str_replace("\\","",$description_field);
$fields_descriptions = empty($command['fields_descriptions']) ?
'' : json_decode(io_safe_output($description_field), true);
// Fields values are stored in json
$values_fields = str_replace("\\\"","\"",$command['fields_values']);
$values_fields = str_replace("\\","",$values_fields);
$fields_values = empty($command['fields_values']) ?
'' : io_safe_output(json_decode($values_fields, true));
break;
}
// Descriptions are stored in json
$fields_descriptions = empty($command['fields_descriptions']) ?
'' : json_decode(io_safe_output($command['fields_descriptions']), true);
// Fields values are stored in json
$fields_values = empty($command['fields_values']) ?
'' : io_safe_output(json_decode($command['fields_values'], true));
$fields_rows = array();
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
@ -266,13 +243,11 @@ if (defined('METACONSOLE'))
else
ui_print_page_header (__('Alerts').' &raquo; '.__('Alert commands'), "images/gm_alerts.png", false, "alerts_config", true);
if ($create_command) {
$name = (string) get_parameter ('name');
$command = (string) get_parameter ('command');
$description = (string) get_parameter ('description');
$id_group = (string) get_parameter ('id_group', 0);
$fields_descriptions = array();
$fields_values = array();
@ -287,7 +262,8 @@ if ($create_command) {
$values['fields_values'] = io_json_mb_encode($fields_values);
$values['fields_descriptions'] = io_json_mb_encode($fields_descriptions);
$values['description'] = $description;
$values['id_group'] = $id_group;
$name_check = db_get_value ('name', 'talert_commands', 'name', $name);
if (!$name_check) {
@ -349,8 +325,27 @@ if ($delete_command) {
ui_print_result_message ($result,
__('Successfully deleted'),
__('Could not be deleted'));
}
if ($copy_command) {
$id = (int) get_parameter ('id');
// Get the info from the source command
$command_to_copy = db_get_row('talert_commands', 'id', $id);
if ($command_to_copy === false) {
ui_print_error_message(__("Command with id $id does not found."));
} else {
// Prepare to insert the copy with same values
unset ($command_to_copy['id']);
$command_to_copy['name'].= __(' (copy)');
$result = db_process_sql_insert('talert_commands', $command_to_copy);
// Print the result
ui_print_result_message ($result,
__('Successfully copied'),
__('Could not be copied')
);
}
}
$table->width = '100%';
@ -358,45 +353,54 @@ $table->class = 'databox data';
$table->data = array ();
$table->head = array ();
$table->head[0] = __('Name');
$table->head[1] = __('ID');
$table->head[2] = __('Description');
$table->head[3] = __('Delete');
$table->head['name'] = __('Name');
$table->head['id'] = __('ID');
$table->head['group'] = __('Group');
$table->head['description'] = __('Description');
$table->head['action'] = __('Actions');
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->style['name'] = 'font-weight: bold';
$table->size = array ();
$table->size[3] = '40px';
$table->size['action'] = '40px';
$table->align = array ();
$table->align[3] = 'left';
$table->align['action'] = 'left';
$commands = db_get_all_rows_in_table ('talert_commands');
if ($commands === false)
$commands = array ();
$commands = db_get_all_rows_filter(
'talert_commands',
array('id_group' => array_keys(users_get_groups(false, "LM")))
);
if ($commands === false) $commands = array ();
foreach ($commands as $command) {
$data = array ();
$data[0] = '<span style="font-size: 7.5pt">';
$data['name'] = '<span style="font-size: 7.5pt">';
if (! $command['internal'])
$data[0] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&id='.$command['id'].'&pure='.$pure.'">'.
$data['name'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&id='.$command['id'].'&pure='.$pure.'">'.
$command['name'].'</a>';
else
$data[0] .= $command['name'];
$data[0] .= '</span>';
$data[1] = $command['id'];
$data[2] = str_replace("\r\n","<br>",
$data['name'] .= $command['name'];
$data['name'] .= '</span>';
$data['id'] = $command['id'];
$data['group'] = ui_print_group_icon ($command["id_group"], true);
$data['description'] = str_replace("\r\n","<br>",
io_safe_output($command['description']));
$data[3] = '';
$data['action'] = '';
if (! $command['internal']) {
$data[3] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&delete_command=1&id='.$command['id'].'&pure='.$pure.'"
$data['action'] = '<span style="display: inline-flex">';
$data['action'].= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&amp;copy_command=1&id='.$command['id'].'&pure='.$pure.'"
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.
html_print_image("images/copy.png", true) . '</a>';
$data['action'].= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&delete_command=1&id='.$command['id'].'&pure='.$pure.'"
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.
html_print_image("images/cross.png", true) . '</a>';
$data['action'].= '</span>';
}
array_push ($table->data, $data);
}
if (isset($data)) {
if (count($table->data) > 0) {
html_print_table ($table);
}
else {

View File

@ -102,16 +102,8 @@ if ($groups_user === false) {
$groups_id = implode(',', array_keys($groups_user));
$form_filter .= "<tr>";
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$temp = db_get_all_rows_sql("SELECT id, name FROM talert_actions WHERE id_group IN ($groups_id);");
break;
case "oracle":
$temp = db_get_all_rows_sql("SELECT id, name FROM talert_actions WHERE id_group IN ($groups_id)");
break;
}
$temp = db_get_all_rows_sql("SELECT id, name FROM talert_actions WHERE id_group IN ($groups_id);");
$arrayActions = array();
if (is_array($temp)) {
foreach ($temp as $actionElement) {
@ -186,23 +178,10 @@ if ($searchFlag) {
field3_recovery LIKE '%" . trim($fieldContent) . "%')";
if (strlen(trim($moduleName)) > 0)
$where .= " AND id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE '%" . trim($moduleName) . "%')";
//if ($agentID != -1)
//$where .= " AND id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = " . $agentID . ")";
if (strlen(trim($agentName)) > 0) {
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo
FROM tagente t1 INNER JOIN tagente_modulo t2 ON t1.id_agente = t2.id_agente
WHERE t1.alias LIKE '" . trim($agentName) . "')";
break;
case "oracle":
$where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo
FROM tagente t1 INNER JOIN tagente_modulo t2 ON t1.id_agente = t2.id_agente
WHERE t1.alias LIKE '" . trim($agentName) . "')";
break;
}
$where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo
FROM tagente t1 INNER JOIN tagente_modulo t2 ON t1.id_agente = t2.id_agente
WHERE t1.alias LIKE '" . trim($agentName) . "')";
}
if ($actionID != -1 && $actionID != '')
$where .= " AND talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action = " . $actionID . ")";
@ -212,17 +191,7 @@ if ($searchFlag) {
$where .= " AND talert_template_modules.standby = " . $standby;
}
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$id_agents = array_keys ($agents);
break;
case "oracle":
$id_agents = false;
break;
}
$id_agents = array_keys ($agents);
$total = agents_get_alerts_simple ($id_agents, false,
false, $where, false, false, false, true);
@ -704,27 +673,32 @@ foreach ($simple_alerts as $alert) {
// To manage alert is necessary LW permissions in the agent group
if(check_acl_one_of_groups ($config['id_user'], $all_groups, "LW")) {
$data[4] .= '&nbsp;&nbsp;<form class="delete_alert_form" action="' . $url . '" method="post" style="display: inline;">';
if ($alert['disabled']) {
}
else {
$data[4] .= '<a href="javascript:show_add_action(\'' . $alert['id'] . '\');">';
$data[4] .= '</a>';
$is_cluster = (bool)get_parameter('id_cluster');
if (!$is_cluster) {
if ($alert['disabled']) {
$data[4] .= html_print_image('images/add.disabled.png',
true, array('title' => __("Add action")));
}
else {
$data[4] .= '<a href="javascript:show_add_action(\'' . $alert['id'] . '\');">';
$data[4] .= html_print_image('images/add.png', true, array('title' => __("Add action")));
$data[4] .= '</a>';
}
}
$data[4] .= html_print_input_image ('delete', 'images/cross.png', 1, '', true, array('title' => __('Delete')));
$data[4] .= html_print_input_hidden ('delete_alert', 1, true);
$data[4] .= html_print_input_hidden ('id_alert', $alert['id'], true);
$data[4] .= '</form>';
$data[4] .= '<form class="view_alert_form" method="post" style="display: inline;">';
if ($is_cluster) {
$data[4] .= '<form class="view_alert_form" method="post" style="display: inline;">';
$data[4] .= html_print_input_image ('update', 'images/builder.png', 1, '', true, array('title' => __('Update')));
$data[4] .= html_print_input_hidden ('upd_alert', 1, true);
$data[4] .= html_print_input_hidden ('id_alert', $alert['id'], true);
$data[4] .= html_print_input_image ('update', 'images/builder.png', 1, '', true, array('title' => __('Update')));
$data[4] .= html_print_input_hidden ('upd_alert', 1, true);
$data[4] .= html_print_input_hidden ('id_alert', $alert['id'], true);
$data[4] .= '</form>';
$data[4] .= '</form>';
}
}
if(check_acl_one_of_groups ($config['id_user'], $all_groups, "LM")) {

View File

@ -122,7 +122,6 @@ $table->colspan[0][1] = 2;
$table->data[1][0] = __('Group');
$groups = users_get_groups ();
$own_info = get_user_info ($config['id_user']);
// Only display group "All" if user is administrator or has "PM" privileges
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM"))
@ -133,9 +132,17 @@ $table->data[1][1] = html_print_select_groups(false, "LW", $display_all_group, '
$table->colspan[1][1] = 2;
$table->data[2][0] = __('Command');
$table->data[2][1] = html_print_select_from_sql ('SELECT id, name
FROM talert_commands',
'id_command', $id_command, '', __('None'), 0, true);
$commands_sql = db_get_all_rows_filter(
'talert_commands',
array('id_group' => array_keys(users_get_groups(false, "LW"))),
array('id', 'name'),
'AND',
false,
true
);
$table->data[2][1] = html_print_select_from_sql ($commands_sql, 'id_command', $id_command,
'', __('None'), 0, true
);
$table->data[2][1] .= ' ';
if (check_acl ($config['id_user'], 0, "PM")) {
$table->data[2][1] .= html_print_image ('images/add.png', true);
@ -282,6 +289,19 @@ $(document).ready (function () {
var max_fields = parseInt('<?php echo $config["max_macro_fields"]; ?>');
// Change the selected group
$("#group option").each(function(index, value) {
var current_group = $(value).val();
if (data.id_group != 0 && current_group != 0 && current_group != data.id_group) {
$(value).hide();
} else {
$(value).show();
}
});
if (data.id_group != 0 && $("#group").val() != data.id_group) {
$("#group").val(0);
}
for (i = 1; i <= max_fields; i++) {
var old_value = '';
var old_recovery_value = '';

View File

@ -54,6 +54,7 @@ if ($update_command) {
$name = (string) get_parameter ('name');
$command = (string) get_parameter ('command');
$description = (string) get_parameter ('description');
$id_group = (string) get_parameter ('id_group', 0);
$fields_descriptions = array();
$fields_values = array();
@ -71,7 +72,8 @@ if ($update_command) {
$values['name'] = $name;
$values['command'] = $command;
$values['description'] = $description;
$values['id_group'] = $id_group;
//Check it the new name is used in the other command.
$id_check = db_get_value ('id', 'talert_commands', 'name', $name);
if (($id_check != $id) && (!empty($id_check))) {
@ -100,12 +102,13 @@ $command = '';
$description = '';
$fields_descriptions = '';
$fields_values = '';
$id_group = 0;
if ($id) {
$alert = alerts_get_alert_command ($id);
$name = $alert['name'];
$command = $alert['command'];
$description = $alert['description'];
$id_group = $alert['id_group'];
$fields_descriptions = $alert['fields_descriptions'];
$fields_values = $alert['fields_values'];
}
@ -123,13 +126,7 @@ $table->width = '100%';
$table->class = 'databox filters';
if (defined('METACONSOLE')) {
if ($id) {
$table->head[0] = __('Update Command');
}
else {
$table->head[0] = __('Create Command');
}
$table->head[0] = ($id) ? __('Update Command') : __('Create Command');
$table->head_colspan[0] = 4;
$table->headstyle[0] = 'text-align: center';
}
@ -142,18 +139,25 @@ $table->size = array ();
$table->size[0] = '20%';
$table->data = array ();
$table->colspan[0][1] = 3;
$table->data[0][0] = __('Name');
$table->data[0][2] = html_print_input_text ('name', $name, '', 35, 255, true);
$table->colspan['name'][1] = 3;
$table->data['name'][0] = __('Name');
$table->data['name'][2] = html_print_input_text ('name', $name, '', 35, 255, true);
$table->colspan[1][1] = 3;
$table->data[1][0] = __('Command');
$table->data[1][0] .= ui_print_help_icon ('alert_macros', true);
$table->data[1][1] = html_print_textarea ('command', 8, 30, $command, '', true);
$table->colspan['command'][1] = 3;
$table->data['command'][0] = __('Command');
$table->data['command'][0] .= ui_print_help_icon ('alert_macros', true);
$table->data['command'][1] = html_print_textarea ('command', 8, 30, $command, '', true);
$table->colspan['group'][1] = 3;
$table->data['group'][0] = __('Group');
$table->data['group'][1] = html_print_select_groups(false, "LM",
true, 'id_group', $id_group, false,
'', 0, true);
$table->colspan['description'][1] = 3;
$table->data['description'][0] = __('Description');
$table->data['description'][1] = html_print_textarea ('description', 10, 30, $description, '', true);
$table->colspan[2][1] = 3;
$table->data[2][0] = __('Description');
$table->data[2][1] = html_print_textarea ('description', 10, 30, $description, '', true);
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {

View File

@ -12,19 +12,17 @@
$ownDir = dirname(__FILE__) . '/';
$ownDir = str_replace("\\", "/", $ownDir);
require_once($ownDir . "../include/config.php");
require_once($config["homedir"] . "/include/functions.php");
require_once($config["homedir"] . "/include/functions_db.php");
require_once($config["homedir"] . "/include/auth/mysql.php");
// Don't start a session before this import.
// The session is configured and started inside the config process.
require_once ($ownDir . "../include/config.php");
require_once ($config["homedir"] . "/include/functions.php");
require_once ($config["homedir"] . "/include/functions_db.php");
require_once ($config["homedir"] . "/include/auth/mysql.php");
global $config;
if (! isset($_SESSION["id_usuario"])) {
session_start();
session_write_close();
}
// Login check
if (!isset($_SESSION["id_usuario"])) {
$config['id_user'] = null;

View File

@ -229,15 +229,31 @@ $(document).ready (function () {
});
$("#left").click (function () {
var current_fields_size = ($('#fields_selected option').length);
var selected_fields = [];
var selected_fields_total = '';
jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) {
field_name = $(value).html();
if (field_name != <?php echo "'".__('None')."'"; ?>) {
id_field = $(value).attr('value');
$("select[name='fields_available[]']").append($("<option></option>").val(id_field).html('<i>' + field_name + '</i>'));
$("#fields_selected").find("option[value='" + id_field + "']").remove();
$("#fields_available").find("option[value='0']").remove();
}
field_name = $(value).html();
selected_fields.push(field_name);
selected_fields_total = selected_fields.length;
});
if(selected_fields_total === current_fields_size){
display_confirm_dialog(
"<?php echo '<span style=text-transform:none;font-size:9.5pt;>'.__('There must be at least one custom field. Timestamp will be set by default').'</span>'; ?>",
"<?php echo __('Confirm'); ?>",
"<?php echo __('Cancel'); ?>",
function () {
move_left();
$("#fields_available").find("option[value='timestamp']").remove();
$("select[name='fields_selected[]']").append($("<option></option>").val('timestamp').html('<i>' + 'Timestamp' + '</i>'));
}
);
}
else{
move_left();
}
});
$("#submit-upd_button").click(function () {
@ -247,4 +263,16 @@ $(document).ready (function () {
});
});
});
function move_left(){
jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) {
field_name = $(value).html();
if (field_name != <?php echo "'".__('None')."'"; ?>) {
id_field = $(value).attr('value');
$("select[name='fields_available[]']").append($("<option></option>").val(id_field).html('<i>' + field_name + '</i>'));
$("#fields_selected").find("option[value='" + id_field + "']").remove();
$("#fields_available").find("option[value='0']").remove();
}
});
}
</script>

View File

@ -16,6 +16,8 @@
global $config;
include_once($config['homedir'] . "/include/functions_event_responses.php");
check_login ();
if (! check_acl($config['id_user'], 0, "PM")) {
@ -25,14 +27,7 @@ if (! check_acl($config['id_user'], 0, "PM")) {
return;
}
if (!is_user_admin($config['id_user'])) {
$id_groups = array_keys(users_get_groups(false, "PM"));
$event_responses = db_get_all_rows_filter('tevent_response',
array('id_group' => $id_groups));
}
else {
$event_responses = db_get_all_rows_in_table('tevent_response');
}
$event_responses = event_responses_get_responses();
if(empty($event_responses)) {
ui_print_info_message ( array('no_close'=>true, 'message'=> __('No responses found') ) );

View File

@ -16,6 +16,8 @@
global $config;
include_once($config['homedir'] . "/include/functions_event_responses.php");
check_login ();
if (! check_acl($config['id_user'], 0, "PM")) {
@ -40,24 +42,9 @@ switch($action) {
$values['modal_height'] = get_parameter('modal_height');
$values['new_window'] = get_parameter('new_window');
$values['params'] = get_parameter('params');
if (enterprise_installed()) {
if ($values['type'] == 'command') {
$values['server_to_exec'] = get_parameter('server_to_exec');
}
else {
$values['server_to_exec'] = 0;
}
}
else {
$values['server_to_exec'] = 0;
}
if($values['new_window'] == 1) {
$values['modal_width'] = 0;
$values['modal_height'] = 0;
}
$result = db_process_sql_insert('tevent_response', $values);
$values['server_to_exec'] = get_parameter('server_to_exec');
$result = event_responses_create_response($values);
if($result) {
ui_print_success_message(__('Response added succesfully'));
@ -78,26 +65,10 @@ switch($action) {
$values['modal_height'] = get_parameter('modal_height');
$values['new_window'] = get_parameter('new_window');
$values['params'] = get_parameter('params');
if (enterprise_installed()) {
if ($values['type'] == 'command') {
$values['server_to_exec'] = get_parameter('server_to_exec');
}
else {
$values['server_to_exec'] = 0;
}
}
else {
$values['server_to_exec'] = 0;
}
if($values['new_window'] == 1) {
$values['modal_width'] = 0;
$values['modal_height'] = 0;
}
$values['server_to_exec'] = get_parameter('server_to_exec');
$response_id = get_parameter('id_response',0);
$result = db_process_sql_update('tevent_response', $values, array('id' => $response_id));
$result = event_responses_update_response($response_id, $values);
if($result) {
ui_print_success_message(__('Response updated succesfully'));

View File

@ -48,7 +48,7 @@ if ($create_profiles) {
// If the profile doesnt exist, we create it
if ($profile_data === false) {
db_pandora_audit("User management",
"Added profile for user ".io_safe_output($user));
"Added profile for user ".io_safe_input($user));
$return = profile_create_user_profile ($user, $profile, $group);
if ($return !== false) {
$n_added ++;

View File

@ -245,11 +245,12 @@ $module_types = db_get_all_rows_filter (
if ($module_types === false)
$module_types = array ();
$types = '';
$types = array();
foreach ($module_types as $type) {
$types[$type['id_tipo']] = $type['description'];
}
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->data = array ();

View File

@ -175,6 +175,7 @@ if ($update) {
}
}
$table = new stdClass();
$table->id = 'delete_table';
$table->class = 'databox filters';
$table->width = '100%';
@ -235,7 +236,7 @@ switch ($config["dbtype"]) {
if ($module_types === false)
$module_types = array ();
$types = '';
$types = array();
foreach ($module_types as $type) {
$types[$type['id_tipo']] = $type['description'];
}
@ -248,22 +249,18 @@ $snmp_versions['3'] = 'v. 3';
$table->width = '100%';
$table->data = array ();
$table->data['selection_mode'][0] = __('Selection mode');
$table->data['selection_mode'][1] = '<span style="width:110px;display:inline-block;">'.__('Select modules first ') . '</span>' .
html_print_radio_button_extended ("selection_mode", 'modules', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true).'<br>';
$table->data['selection_mode'][1] .= '<span style="width:110px;display:inline-block;">'.__('Select agents first ') . '</span>' .
html_print_radio_button_extended ("selection_mode", 'agents', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true);
$table->rowclass['form_modules_1'] = 'select_modules_row';
$table->data['form_modules_1'][0] = __('Module type');
$table->data['form_modules_1'][0] .= '<span id="module_loading" class="invisible">';
$table->data['form_modules_1'][0] .= html_print_image('images/spinner.png', true);
$table->data['form_modules_1'][0] .= '</span>';
$types[0] = __('All');
$table->colspan['form_modules_1'][1] = 2;
$table->data['form_modules_1'][1] = html_print_select ($types,

View File

@ -120,7 +120,9 @@ if (check_acl ($config['id_user'], 0, "AW")) {
$sub2["godmode/massive/massive_operations&amp;tab=massive_users"]["text"] = __('Users operations');
}
$sub2["godmode/massive/massive_operations&amp;tab=massive_alerts"]["text"] = __('Alerts operations');
enterprise_hook('massivepolicies_submenu');
if ($config["centralized_management"] != 1) {
enterprise_hook('massivepolicies_submenu');
}
enterprise_hook('massivesnmp_submenu');
enterprise_hook('massivesatellite_submenu');

View File

@ -49,7 +49,7 @@ You can of course remove the warnings, that's why we include the source and do n
ui_print_page_header (__('Module management') . ' &raquo; ' .
__('Network component management'), "", false,
"network_component", true,"",true,"modulemodal");
"network_component", true,"",false,"modulemodal");
$sec = 'gmodules';
}

View File

@ -1574,7 +1574,8 @@ You can of course remove the warnings, that's why we include the source and do n
<tr id="row_historical_db_check" style="" class="datos">
<td style="font-weight:bold;">
<?php echo __('Query History Database'); ?>
<?php echo __('Query History Database')
. ui_print_help_tip(__('With the token enabled the query will affect the Historical Database, which may mean a small drop in performance.'), true); ?>
</td>
<td style="">
<?php
@ -1615,16 +1616,6 @@ You can of course remove the warnings, that's why we include the source and do n
?>
</td>
</tr>
<tr id="row_hide_notinit_agents" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Hide not init agents');?></td>
<td>
<?php
html_print_checkbox('hide_notinit_agents', 1,
$hide_notinit_agents, false, false);
?>
</td>
</tr>
<tr id="row_priority_mode" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Priority mode');?></td>

View File

@ -1869,7 +1869,7 @@ switch ($action) {
break;
}
metaconsole_restore_db_force();
metaconsole_restore_db();
$temp_sort[$report_item['id_rc']] = $element_name;

View File

@ -195,10 +195,10 @@ html_print_submit_button ($textButtonSubmit, 'update_layout', false,
echo '</div>';
echo "</form>";
ui_require_css_file ("color-picker");
ui_require_jquery_file ("colorpicker");
?>
<script src="include/javascript/jquery.colorpicker.js"></script>
<script type="text/javascript">
$(document).ready (function () {

View File

@ -50,10 +50,10 @@ function toggle_advance_options_palette(close) {
function visual_map_main() {
img_handler_start = "images/dot_red.png";
img_handler_end = "images/dot_green.png";
get_image_url(img_handler_start).success(function (data) {
get_image_url(img_handler_start).done(function (data) {
img_handler_start = data;
});
get_image_url(img_handler_end).success(function (data) {
get_image_url(img_handler_end).done(function (data) {
img_handler_end = data;
});
@ -65,9 +65,7 @@ function visual_map_main() {
eventsItems();
//Fixed to wait the load of images.
$(window).load(function() {
$(window).on('load', function() {
$('#module').change(function(){
var txt = $("#module").val();
if(selectedItem == 'simple_value' || creationItem == 'simple_value'){
@ -153,8 +151,7 @@ function visual_map_main() {
draw_user_lines("", 0, 0, 0 , 0, 0, true);
//~ center_labels();
}
);
});
obj_js_user_lines = new jsGraphics("background");
@ -223,12 +220,11 @@ function update_button_palette_callback() {
// TODO VALIDATE DATA
switch (selectedItem) {
case 'background':
if(values['width'] < 1024 || values['height'] < 768){
alert('Min allowed size is 1024x768');
return false;
alert('Min allowed size is 1024x768');
return false;
}
if(values['width'] == 0 && values['height'] == 0) {
values['width'] =
$("#hidden-background_original_width").val();
@ -238,7 +234,6 @@ function update_button_palette_callback() {
$("#background").css('width', values['width']);
$("#background").css('height', values['height']);
//$("#background").css('background', 'url(images/console/background/' + values['background'] + ')');
var image = values['background'];
$("#background_img").attr('src', "images/spinner.gif");
set_image("background", null, image);
@ -246,7 +241,6 @@ function update_button_palette_callback() {
idElement = 0;
break;
case 'box_item':
if($('input[name=width_box]').val() == ''){
alert('Undefined width');
return false;
@ -255,11 +249,11 @@ function update_button_palette_callback() {
alert('Undefined height');
return false;
}
$("#" + idItem + " div").css('background-color', values['fill_color']);
$("#" + idItem + " div").css('border-color', values['border_color']);
$("#" + idItem + " div").css('border-width', values['border_width'] + "px");
if(values['height_box']==0 || values['width_box']==0){
$("#" + idItem + " div").css('width', "300px");
$("#" + idItem + " div").css('height', "180px");
@ -274,54 +268,43 @@ function update_button_palette_callback() {
alert('Undefined image');
return false;
}
$("#text_" + idItem).html(values['label']);
if(values['show_statistics'] == 1){
if (!$('#image_'+idItem).length) {
if(values['label_position'] == 'left'){
var $image = $('<img></img>')
.attr('id', 'image_' + idItem)
.attr('class', 'image')
.attr('src', 'images/console/icons/'+values["image"]+".png")
.attr('style','float:right;');
}
else if(values['label_position'] == 'right'){
var $image = $('<img></img>')
.attr('id', 'image_' + idItem)
.attr('class', 'image')
.attr('src', 'images/console/icons/'+values["image"]+".png")
.attr('style','float:left;');
}
else{
var $image = $('<img></img>')
.attr('id', 'image_' + idItem)
.attr('class', 'image')
.attr('src', 'images/console/icons/'+values["image"]+".png");
}
$('#'+idItem).append($image);
}
if ((values['width'] == 0) || (values['height'] == 0)) {
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
$("#image_" + idItem).attr('width', 520);
$("#image_" + idItem).attr('height', 80);
$("#image_" + idItem).css('width', '520px');
$("#image_" + idItem).css('height', '80px');
$("#image_" + idItem).attr('src', 'images/console/signes/group_status.png');
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
$("#image_" + idItem).attr('width', 520);
$("#image_" + idItem).attr('height', 80);
$("#image_" + idItem).css('width', '520px');
$("#image_" + idItem).css('height', '80px');
$("#image_" + idItem).attr('src', 'images/console/signes/group_status.png');
}
else {
$("#image_" + idItem).removeAttr('width');
@ -331,49 +314,36 @@ function update_button_palette_callback() {
$("#image_" + idItem).css('width', values['width'] + 'px');
$("#image_" + idItem).css('height', values['height'] + 'px');
$("#image_" + idItem).attr('src', 'images/console/signes/group_status.png');
}
}
}
else{
if ((values['width'] == 0) || (values['height'] == 0)) {
if(values['image'] != '' && values['image'] != 'none'){
if (!$('#image_'+idItem).length) {
if(values['label_position'] == 'left'){
var $image = $('<img></img>')
.attr('id', 'image_' + idItem)
.attr('class', 'image')
.attr('src', 'images/console/icons/'+values["image"]+".png")
.attr('style','float:right;');
}
else if(values['label_position'] == 'right'){
var $image = $('<img></img>')
.attr('id', 'image_' + idItem)
.attr('class', 'image')
.attr('src', 'images/console/icons/'+values["image"]+".png")
.attr('style','float:left;');
}
else{
var $image = $('<img></img>')
.attr('id', 'image_' + idItem)
.attr('class', 'image')
.attr('src', 'images/console/icons/'+values["image"]+".png");
}
$('#'+idItem).append($image);
}
if($('#preview > img').prop('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
@ -385,15 +355,11 @@ function update_button_palette_callback() {
else{
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
$("#image_" + idItem).attr('width', $('#preview > img')[0].naturalHeight);
$("#image_" + idItem).attr('height', $('#preview > img')[0].naturalHeight);
$("#image_" + idItem).css('width', $('#preview > img')[0].naturalHeight+'px');
$("#image_" + idItem).css('height', $('#preview > img')[0].naturalHeight+'px');
$("#image_" + idItem).css('height', $('#preview > img')[0].naturalHeight+'px');
}
}
else{
$("#image_" + idItem).removeAttr('width');
@ -404,7 +370,6 @@ function update_button_palette_callback() {
$("#image_" + idItem).css('height', '70px');
$("#image_" + idItem).remove();
}
}
else {
$("#image_" + idItem).removeAttr('width');
@ -414,14 +379,9 @@ function update_button_palette_callback() {
$("#image_" + idItem).css('width', values['width'] + 'px');
$("#image_" + idItem).css('height', values['height'] + 'px');
}
}
break;
case 'static_graph':
if($('input[name=width]').val() == ''){
alert('Undefined width');
return false;
@ -436,10 +396,8 @@ function update_button_palette_callback() {
}
$("#text_" + idItem).html(values['label']);
if(values['show_statistics'] == 1){
if ((values['width'] == 0) || (values['height'] == 0)) {
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
@ -448,7 +406,6 @@ function update_button_palette_callback() {
$("#image_" + idItem).css('width', '520px');
$("#image_" + idItem).css('height', '80px');
$("#image_" + idItem).attr('src', 'images/console/signes/group_status.png');
}
else {
$("#image_" + idItem).removeAttr('width');
@ -458,50 +415,35 @@ function update_button_palette_callback() {
$("#image_" + idItem).css('width', values['width'] + 'px');
$("#image_" + idItem).css('height', values['height'] + 'px');
$("#image_" + idItem).attr('src', 'images/console/signes/group_status.png');
}
}
}
else{
if ((values['width'] == 0) || (values['height'] == 0)) {
if(values['image'] != '' && values['image'] != 'none'){
if (!$('#image_'+idItem).length) {
if(values['label_position'] == 'left'){
var $image = $('<img></img>')
.attr('id', 'image_' + idItem)
.attr('class', 'image')
.attr('src', 'images/console/icons/'+values["image"]+".png")
.attr('style','float:right;');
}
else if(values['label_position'] == 'right'){
var $image = $('<img></img>')
.attr('id', 'image_' + idItem)
.attr('class', 'image')
.attr('src', 'images/console/icons/'+values["image"]+".png")
.attr('style','float:left;');
}
else{
var $image = $('<img></img>')
.attr('id', 'image_' + idItem)
.attr('class', 'image')
.attr('src', 'images/console/icons/'+values["image"]+".png");
}
$('#'+idItem).append($image);
}
if($('#preview > img').prop('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
@ -513,15 +455,11 @@ function update_button_palette_callback() {
else{
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
$("#image_" + idItem).attr('width', $('#preview > img')[0].naturalHeight);
$("#image_" + idItem).attr('height', $('#preview > img')[0].naturalHeight);
$("#image_" + idItem).css('width', $('#preview > img')[0].naturalHeight+'px');
$("#image_" + idItem).css('height', $('#preview > img')[0].naturalHeight+'px');
$("#image_" + idItem).css('height', $('#preview > img')[0].naturalHeight+'px');
}
}
else{
$("#image_" + idItem).removeAttr('width');
@ -532,7 +470,6 @@ function update_button_palette_callback() {
$("#image_" + idItem).css('height', '70px');
$("#image_" + idItem).remove();
}
}
else {
$("#image_" + idItem).removeAttr('width');
@ -542,9 +479,7 @@ function update_button_palette_callback() {
$("#image_" + idItem).css('width', values['width'] + 'px');
$("#image_" + idItem).css('height', values['height'] + 'px');
}
}
break;
case 'percentile_bar':
case 'percentile_item':
@ -552,13 +487,15 @@ function update_button_palette_callback() {
alert('Undefined width');
return false;
}
if($('input[name=height_percentile]').val() == ''){
alert('Undefined height');
return false;
}
$("#text_" + idItem).html(values['label']);
$("#image_" + idItem).attr("src", "images/spinner.gif");
if (values['type_percentile'] == 'bubble') {
setPercentileBubble(idItem, values);
}
@ -571,7 +508,7 @@ function update_button_palette_callback() {
else {
setPercentileBar(idItem, values);
}
break;
case 'module_graph':
if($('#dir_items').html() == 'horizontal'){
@ -804,6 +741,12 @@ function readFields() {
values['label'] = $("input[name=label]").val();
var text = tinymce.get('text-label').getContent();
values['label'] = text;
if ($("input[name=percentile_label]").val().length > 0) {
values['percentile_label_color'] = $("input[name=percentile_label_color]").val();
values['label'] = "<span style='color:"+values['percentile_label_color']+";'>" + $("input[name=percentile_label]").val() + "</span>";
}
values['line-height'] = $("#text-label_ifr").contents().find("p").css('line-height');
values['type_graph'] = $("select[name=type_graph]").val();
values['image'] = $("select[name=image]").val();
@ -843,7 +786,6 @@ function readFields() {
values['event_max_time_row'] = $("select[name=event_max_time_row]").val();
values['type_percentile'] = $("select[name=type_percentile]").val();
values['percentile_color'] = $("input[name=percentile_color]").val();
values['percentile_label_color'] = $("input[name=percentile_label_color]").val();
values['percentile_label'] = $("input[name=percentile_label]").val();
values['value_show'] = $("select[name=value_show]").val();
@ -1978,14 +1920,14 @@ function cleanFields(item) {
$("select[name=period]").val('');
$("input[name=width]").val(0);
$("input[name=height]").val(0);
$("select[name=parent]").val('');
$("select[name=parent]").val(0);
$("select[name=linked_map_status_calculation_type]").val('default').change();
$("select[name=map_linked]").val('').change();
$("select[name=map_linked]").val(0).change();
$("input[name=linked_map_node_id]").val(0);
$("input[name=map_linked_weight]").val('');
$("input[name=linked_map_status_service_critical]").val('');
$("input[name=linked_map_status_service_warning]").val('');
$("select[name=element_group]").val('');
$("select[name=element_group]").val(0);
$("input[name=width_module_graph]").val(300);
$("input[name=height_module_graph]").val(180);
$("input[name='width_box']").val(300);
@ -2482,7 +2424,6 @@ function setPercentileCircular (id_data, values) {
width_percentile = values['width_percentile'];
var parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "get_module_value"});
parameter.push ({name: "id_element", value: id_data});
@ -2517,7 +2458,7 @@ function setPercentileCircular (id_data, values) {
else {
value_text = module_value + " " + unit_text;
}
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/circular-progress-bar.png');
if($('#text-width_percentile').val() == 0){
$("#" + id_data + " img").css('width', '130px');
@ -2527,12 +2468,12 @@ function setPercentileCircular (id_data, values) {
$("#" + id_data + " img").css('width', $('#text-width_percentile').val()+'px');
$("#" + id_data + " img").css('height', $('#text-width_percentile').val()+'px');
}
if($('#'+id_data+' table').css('float') == 'right' || $('#'+id_data+ ' table').css('float') == 'left'){
$('#'+id_data+ ' img').css('margin-top', parseInt($('#'+id_data).css('height'))/2 - parseInt($('#'+id_data+ ' img').css('height'))/2);
$('#'+id_data+ ' img').css('margin-top', parseInt($('#'+id_data).css('height'))/2 - parseInt($('#'+id_data+ ' img').css('height'))/2);
}
else{
$('#'+id_data+ ' img').css('margin-left',parseInt($('#'+id_data).css('width'))/2 - parseInt($('#'+id_data+ ' img').css('width'))/2);
$('#'+id_data+ ' img').css('margin-left',parseInt($('#'+id_data).css('width'))/2 - parseInt($('#'+id_data+ ' img').css('width'))/2);
}
}
});
@ -2619,7 +2560,7 @@ function setEventsBar(id_data, values) {
parameter.push ({name: "id_agent", value: values['id_agent']});
parameter.push ({name: "id_agent_module", value: values['module']});
if (is_metaconsole()) {
parameter.push ({name: "id_metaconsole", value: id_metaconsole});
parameter.push ({name: "id_metaconsole", value: values['server_id']});
}
parameter.push ({name: "period", value: values['event_max_time_row']});
parameter.push ({name: "id_visual_console", value: id_visual_console});
@ -3838,14 +3779,12 @@ function updateDB_visual(type, idElement , values, event, top, left) {
case 'clock':
case 'auto_sla_graph':
case 'donut_graph':
if ((typeof(values['mov_left']) != 'undefined') &&
(typeof(values['mov_top']) != 'undefined')) {
if ((typeof(values['absolute_left']) != 'undefined') &&
(typeof(values['absolute_top']) != 'undefined')) {
$("#" + idElement).css('top', '0px').css('top', top + 'px');
$("#" + idElement).css('left', '0px').css('left', left + 'px');
}
else if ((typeof(values['absolute_left']) != 'undefined') &&
(typeof(values['absolute_top']) != 'undefined')) {
else{
$("#" + idElement).css('top', '0px').css('top', top + 'px');
$("#" + idElement).css('left', '0px').css('left', left + 'px');
}
@ -3955,7 +3894,6 @@ function updateDB(type, idElement , values, event) {
parameter.push({name: key, value: val});
});
switch (type) {
// -- line_item --
case 'handler_start':

View File

@ -152,11 +152,9 @@ echo "<div id='delete_in_progress_dialog' style='display: none; text-align: cent
//CSS
ui_require_css_file ('color-picker');
ui_require_css_file ('jquery-ui-1.8.17.custom');
ui_require_css_file ('jquery-ui.min');
//Javascript
//ui_require_jquery_file('jquery-ui-1.8.17.custom.min');
ui_require_jquery_file('colorpicker');
ui_require_javascript_file('wz_jsgraphics');
ui_require_javascript_file('pandora_visual_console');

View File

@ -45,7 +45,7 @@ $rows = db_get_all_rows_in_table('tupdate_settings');
$settings = new StdClass;
foreach ($rows as $row) {
$settings->$row['key'] = $row['value'];
$settings->{$row['key']} = $row['value'];
}
echo '<script type="text/javascript">';

View File

@ -865,7 +865,7 @@ $row++;
$table_other->data[$row][0] = __('Show only the group name');
$table_other->data[$row][0] .= ui_print_help_tip(
__('Show the group name instead the group icon.'), true);
html_print_checkbox('show_group_name', 1,
$table_other->data[$row][1] = html_print_checkbox('show_group_name', 1,
$config['show_group_name'], true);
$row++;
@ -1208,21 +1208,21 @@ $(".logo_preview").click (function(e) {
switch (e.target.id) {
case 'button-custom_logo_preview':
icon_name = $("select#custom_logo option:selected").val();
icon_path = "<?php echo $config['homeurl']; if(enterprise_installed){ echo 'enterprise/'; } ?>images/custom_logo/" + icon_name;
icon_path = "<?php echo $config['homeurl']; if(enterprise_installed()){ echo 'enterprise/'; } ?>images/custom_logo/" + icon_name;
options.grayed = true;
break;
case 'button-custom_logo_white_bg_preview':
icon_name = $("select#custom_logo_white_bg option:selected").val();
icon_path = "<?php echo $config['homeurl']; if(enterprise_installed){ echo 'enterprise/'; } ?>images/custom_logo/" + icon_name;
icon_path = "<?php echo $config['homeurl']; if(enterprise_installed()){ echo 'enterprise/'; } ?>images/custom_logo/" + icon_name;
break;
case 'button-custom_logo_login_preview':
icon_name = $("select#custom_logo_login option:selected").val();
icon_path = "<?php echo $config['homeurl']; if(enterprise_installed){ echo 'enterprise/'; } ?>images/custom_logo_login/" + icon_name;
icon_path = "<?php echo $config['homeurl']; if(enterprise_installed()){ echo 'enterprise/'; } ?>images/custom_logo_login/" + icon_name;
options.grayed = true;
break;
case 'button-custom_splash_login_preview':
icon_name = $("select#custom_splash_login option:selected").val();
icon_path = "<?php echo $config['homeurl']; if(enterprise_installed){ echo 'enterprise/'; } ?>images/custom_splash_login/" + icon_name;
icon_path = "<?php echo $config['homeurl']; if(enterprise_installed()){ echo 'enterprise/'; } ?>images/custom_splash_login/" + icon_name;
options.title = "<?php echo __('Splash Preview'); ?>";
break;
case 'button-custom_docs_logo_preview':

View File

@ -26,6 +26,12 @@ if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_us
return;
}
$php_version = phpversion();
$php_version_array = explode('.', $php_version);
if($php_version_array[0] < 7){
include_once("general/php7_message.php");
}
$tab = get_parameter('tab', 'online');
$buttons = array(

View File

@ -175,7 +175,7 @@ if ($id_profile || $new_profile) {
$vconsole_management = (bool) $profile["vconsole_management"];
$id_audit = db_pandora_audit("User management",
"Edit profile ". $name);
"Edit profile ". io_safe_output($name));
enterprise_include_once('include/functions_audit.php');
$info = 'Name: ' . $name .

View File

@ -24,6 +24,7 @@ include_once($config['homedir'] . "/include/functions_profile.php");
include_once($config['homedir'] . '/include/functions_users.php');
include_once ($config['homedir'] . '/include/functions_groups.php');
include_once ($config['homedir'] . '/include/functions_visual_map.php');
include_once($config['homedir'] . '/include/functions_custom_fields.php');
enterprise_include_once('include/functions_profile.php');
$meta = false;
@ -169,6 +170,7 @@ if ($create_user) {
$values['language'] = get_parameter ('language', 'default');
$values['timezone'] = (string) get_parameter('timezone');
$values['default_event_filter'] = (int) get_parameter('default_event_filter');
$values['default_custom_view'] = (int) get_parameter('default_custom_view');
$dashboard = get_parameter('dashboard', '');
$visual_console = get_parameter('visual_console', '');
@ -240,7 +242,7 @@ if ($create_user) {
}
db_pandora_audit("User management",
"Created user ".io_safe_output($id), false, false, $info);
"Created user ".io_safe_input($id), false, false, $info);
ui_print_result_message ($result,
__('Successfully created'),
@ -281,6 +283,7 @@ if ($update_user) {
$values['language'] = (string) get_parameter ('language');
$values['timezone'] = (string) get_parameter('timezone');
$values['default_event_filter'] = (int) get_parameter('default_event_filter');
$values['default_custom_view'] = (int) get_parameter('default_custom_view');
$dashboard = get_parameter('dashboard', '');
$visual_console = get_parameter('visual_console', '');
@ -389,7 +392,7 @@ if ($update_user) {
}
db_pandora_audit("User management", "Updated user ".io_safe_output($id),
db_pandora_audit("User management", "Updated user ".io_safe_input($id),
false, false, $info);
ui_print_result_message ($res1,
@ -447,7 +450,7 @@ if ($add_profile) {
$tags = implode(',', $tags);
db_pandora_audit("User management",
"Added profile for user ".io_safe_output($id2), false, false, 'Profile: ' . $profile2 . ' Group: ' . $group2 . ' Tags: ' . $tags);
"Added profile for user ".io_safe_input($id2), false, false, 'Profile: ' . $profile2 . ' Group: ' . $group2 . ' Tags: ' . $tags);
$return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy);
ui_print_result_message ($return,
__('Profile added successfully'),
@ -463,7 +466,7 @@ if ($delete_profile) {
$perfil = db_get_row('tperfil', 'id_perfil', $id_perfil);
db_pandora_audit("User management",
"Deleted profile for user ".io_safe_output($id2), false, false, 'The profile with id ' . $id_perfil . ' in the group ' . $perfilUser['id_grupo']);
"Deleted profile for user ".io_safe_input($id2), false, false, 'The profile with id ' . $id_perfil . ' in the group ' . $perfilUser['id_grupo']);
$return = profile_delete_user_profile ($id2, $id_up);
ui_print_result_message ($return,
@ -570,7 +573,16 @@ if (!$meta) {
}
}
$table->data[11][0] = __('Interactive charts').' '.ui_print_help_tip(__('Whether to use Javascript or static PNG graphs'), true) ;
if($meta){
$array_filters = get_filters_custom_fields_view(0, true);
$table->data[11][0] = __('Search custom field view').' '.ui_print_help_tip(__('Load by default the selected view in custom field view'), true);
$table->data[11][1] =html_print_select(
$array_filters, 'default_custom_view',
$user_info['default_custom_view'], '', __('None'), 0,
true, false, true, '', false
);
}
$values = array(-1 => __('Use global conf'), 1 => __('Yes'), 0 => __('No'));
$table->data[12][0] = __('Home screen').
@ -721,11 +733,14 @@ $(document).ready (function () {
if($('#radiobtn0002').prop('checked')) {
$('#user_configuration_table-metaconsole_agents_manager').show();
$('#user_configuration_table-metaconsole_access_node').show();
if($('#checkbox-metaconsole_agents_manager').prop('checked')) {
$('#user_configuration_table-metaconsole_assigned_server').show();
}
}
else {
$('#user_configuration_table-metaconsole_agents_manager').hide();
$('#user_configuration_table-metaconsole_assigned_server').show();
$('#user_configuration_table-metaconsole_access_node').hide();
$('#user_configuration_table-metaconsole_assigned_server').hide();
}
});

View File

@ -66,40 +66,19 @@ $id_profile = (int) get_parameter ('id');
// Profile deletion
if ($delete_profile) {
$count_users_admin_in_profile = db_get_value_sql("
SELECT COUNT(*)
FROM tusuario
WHERE is_admin = 1 AND id_user IN (
SELECT id_usuario
FROM tusuario_perfil
WHERE id_perfil = " . $id_profile . ")");
if ($count_users_admin_in_profile >= 1) {
ui_print_error_message(
__('Unsucessful delete profile. Because the profile is used by some admin users.'));
// Delete profile
$profile = db_get_row('tperfil', 'id_perfil', $id_profile);
$ret = profile_delete_profile_and_clean_users ($id_profile);
if ($ret === false) {
ui_print_error_message(__('There was a problem deleting the profile'));
}
else {
// Delete profile
$profile = db_get_row('tperfil', 'id_perfil', $id_profile);
$sql = sprintf ('DELETE FROM tperfil WHERE id_perfil = %d', $id_profile);
$ret = db_process_sql ($sql);
if ($ret === false) {
ui_print_error_message(__('There was a problem deleting the profile'));
}
else {
db_pandora_audit("Profile management",
"Delete profile ". $profile['name']);
ui_print_success_message(__('Successfully deleted'));
}
//Delete profile from user data
$sql = sprintf ('DELETE FROM tusuario_perfil WHERE id_perfil = %d', $id_profile);
db_process_sql ($sql);
$id_profile = 0;
db_pandora_audit("Profile management",
"Delete profile ". io_safe_output($profile['name']));
ui_print_success_message(__('Successfully deleted'));
}
$id_profile = 0;
}
// Store the variables when create or update
@ -208,7 +187,7 @@ if ($update_profile) {
"'.get_product_name().' Management":"'.$pandora_management.'"}';
db_pandora_audit("User management",
"Update profile ". $name, false, false, $info);
"Update profile ".io_safe_output($name), false, false, $info);
ui_print_success_message(__('Successfully updated'));
}
@ -255,7 +234,7 @@ if ($create_profile) {
"'.get_product_name().' Management":"'.$pandora_management.'"}';
db_pandora_audit("User management",
"Created profile ". $name, false, false, $info);
"Created profile ". io_safe_output($name), false, false, $info);
}
else {
ui_print_error_message(__('There was a problem creating this profile'));

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

View File

@ -0,0 +1,727 @@
<?php
if(check_login()){
//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 Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
include_once($config['homedir'] . "/include/functions_agents.php");
include_once($config['homedir'] . "/include/functions_modules.php");
include_once($config['homedir'] . "/include/functions_ui.php");
include_once($config['homedir'] . '/include/functions_custom_fields.php');
enterprise_include_once ('include/functions_metaconsole.php');
$get_custom_fields_data = (bool) get_parameter('get_custom_fields_data', 0);
$build_table_custom_fields = (bool)get_parameter('build_table_custom_fields', 0);
$build_table_child_custom_fields = (bool)get_parameter('build_table_child_custom_fields', 0);
$build_table_save_filter = (bool)get_parameter('build_table_save_filter', 0);
$append_tab_filter = (bool)get_parameter('append_tab_filter', 0);
$create_filter_cf = (bool)get_parameter('create_filter_cf', 0);
$update_filter_cf = (bool)get_parameter('update_filter_cf', 0);
$delete_filter_cf = (bool)get_parameter('delete_filter_cf', 0);
$change_name_filter = (bool)get_parameter('change_name_filter', 0);
if ($get_custom_fields_data){
$name_custom_fields = get_parameter("name_custom_fields", 0);
$array_custom_fields_data = get_custom_fields_data($name_custom_fields);
echo json_encode($array_custom_fields_data);
return;
}
if($build_table_custom_fields){
$order = get_parameter("order", '');
$length = get_parameter("length", 20);
$start = get_parameter("start", 0);
$draw = get_parameter("draw", 0);
$search = get_parameter("search", '');
$indexed_descriptions = json_decode(io_safe_output(get_parameter("indexed_descriptions", '')), true);
//order query
$order_column = $order[0]['column'];
$type_order = $order[0]['dir'];
switch ($order_column) {
default:
case '1':
$order_by = "ORDER BY temp.name_custom_fields " . $type_order;
break;
case '4':
$order_by = "ORDER BY tma.server_name " . $type_order;
break;
case '2':
$order_by = "ORDER BY tma.alias " . $type_order;
break;
case '3':
$order_by = "ORDER BY tma.direccion " . $type_order;
break;
}
//table temporary for save array in table by order and search custom_field data
$table_temporary = "CREATE TEMPORARY TABLE temp_custom_fields (
id_server int(10),
id_agent int(10),
name_custom_fields varchar(2048),
`status` int(2),
KEY `data_index_temp_1` (`id_server`, `id_agent`)
)";
db_process_sql($table_temporary);
//insert values array in table temporary
$values_insert = array();
foreach ($indexed_descriptions as $key => $value) {
$values_insert[] = "(".$value['id_server'].", ".$value['id_agente'].", '".$value['description']."', ".$value['status'].")";
}
$values_insert_implode = implode(",", $values_insert);
$query_insert ="INSERT INTO temp_custom_fields VALUES ". $values_insert_implode;
db_process_sql($query_insert);
//search table for alias, custom field data, server_name, direction
$search_query = "";
if($search['value'] != ''){
$search_query = ' AND (tma.alias LIKE "%' . $search['value']. '%"';
$search_query .= ' OR tma.server_name LIKE "%' . $search['value']. '%"';
$search_query .= ' OR tma.direccion LIKE "%' . $search['value']. '%"';
$search_query .= ' OR temp.name_custom_fields LIKE "%' . $search['value']. '%" ) ';
}
//query all fields result
$query = sprintf("SELECT
tma.id_agente,
tma.id_tagente,
tma.id_tmetaconsole_setup,
tma.alias,
tma.direccion,
tma.server_name,
temp.name_custom_fields,
temp.status
FROM tmetaconsole_agent tma
INNER JOIN temp_custom_fields temp
ON temp.id_agent = tma.id_tagente
AND temp.id_server = tma.id_tmetaconsole_setup
WHERE tma.disabled = 0
%s
%s
LIMIT %d OFFSET %d
",
$search_query,
$order_by,
$length,
$start
);
$result = db_get_all_rows_sql($query);
//query count
$query_count = sprintf("SELECT
COUNT(tma.id_agente) AS `count`
FROM tmetaconsole_agent tma
INNER JOIN temp_custom_fields temp
ON temp.id_agent = tma.id_tagente
AND temp.id_server = tma.id_tmetaconsole_setup
WHERE tma.disabled = 0
%s
",
$search_query
);
$count = db_get_sql($query_count);
//for link nodes.
$array_nodes = metaconsole_get_connections();
if(isset($array_nodes) && is_array($array_nodes)){
$hash_array_nodes = array();
foreach ($array_nodes as $key => $server) {
$pwd = $server['auth_token'];
$auth_serialized = json_decode($pwd,true);
if (is_array($auth_serialized)) {
$pwd = $auth_serialized['auth_token'];
$api_password = $auth_serialized['api_password'];
$console_user = $auth_serialized['console_user'];
$console_password = $auth_serialized['console_password'];
}
$user = $config['id_user'];
$user_rot13 = str_rot13($config['id_user']);
$hashdata = $user.$pwd;
$hashdata = md5($hashdata);
$url_hash = '&amp;' .
'loginhash=auto&amp;' .
'loginhash_data=' . $hashdata . '&amp;' .
'loginhash_user=' . $user_rot13;
$hash_array_nodes[$server['id']]['hashurl'] = $url_hash;
$hash_array_nodes[$server['id']]['server_url'] = $server['server_url'];
}
}
//prepare rows for table dinamic
$data = array();
foreach ($result as $values) {
$image_status = agents_get_image_status($values['status']);
//link nodes
$agent_link = '<a href="'.
$hash_array_nodes[$values['id_tmetaconsole_setup']]['server_url'] . '/' .
'index.php?' .
'sec=estado&amp;' .
'sec2=operation/agentes/ver_agente&amp;' .
'id_agente='. $values['id_tagente'] .
$hash_array_nodes[$values['id_tmetaconsole_setup']]['hashurl'] . '">'
;
$agent_alias = ui_print_truncate_text($values['alias'],
'agent_small', false, true, false, '[&hellip;]',
'font-size:7.5pt;'
);
if (can_user_access_node ()) {
$agent = $agent_link . '<b>' . $agent_alias . '</b></a>';
}
else {
$agent = $agent_alias;
}
$data[] = array(
"ref" => $referencia,
"data_custom_field" => $values['name_custom_fields'],
"server" => $values['server_name'],
"agent" => $agent,
"IP" => $values['direccion'],
"status" => "<div id='reload_status_agent_" . $values['id_tmetaconsole_setup'] . "_" . $values['id_tagente'] ."'>" . $image_status . "</div>",
"id_agent" => $values['id_tagente'],
"id_server" => $values['id_tmetaconsole_setup']
);
}
$result = array(
"draw" => $draw,
"recordsTotal" => count($data),
"recordsFiltered" => $count,
"data" => $data
);
echo json_encode($result);
return;
}
if($build_table_child_custom_fields){
$id_agent = get_parameter("id_agent", 0);
$id_server = get_parameter("id_server", 0);
$module_search = str_replace('amp;', '',get_parameter("module_search", ''));
$module_status = get_parameter("module_status", 0);
if(!$id_server || !$id_agent){
return false;
}
if($module_search != ''){
$name_where = " AND tam.nombre LIKE '%" . $module_search . "%'";
}
//filter by status module
$and_module_status = "";
if(is_array($module_status)){
if(!in_array(-1, $module_status)){
if(!in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $module_status)){
if(count($module_status) > 0){
$and_module_status = " AND ( ";
foreach ($module_status as $key => $value) {
$and_module_status .= ($key != 0)
? " OR ("
: " (";
switch ($value) {
default:
case AGENT_STATUS_NORMAL:
$and_module_status .= " tae.estado = 0 OR tae.estado = 300 ) ";
break;
case AGENT_STATUS_CRITICAL:
$and_module_status .= " tae.estado = 1 OR tae.estado = 100 ) ";
break;
case AGENT_STATUS_WARNING:
$and_module_status .= " tae.estado = 2 OR tae.estado = 200 ) ";
break;
case AGENT_STATUS_UNKNOWN:
$and_module_status .= " tae.estado = 3 ) ";
break;
case AGENT_STATUS_NOT_INIT:
$and_module_status .= " tae.estado = 4 OR tae.estado = 5 ) ";
break;
}
}
$and_module_status .= " ) ";
}
}
else{
//not normal
$and_module_status = "AND tae.estado <> 0 AND tae.estado <> 300 ";
}
}
}
if (is_metaconsole()) {
$server = metaconsole_get_connection_by_id ($id_server);
metaconsole_connect($server);
}
$query = sprintf("SELECT tam.nombre,
tam.min_warning, tam.max_warning,
tam.min_critical, tam.max_critical,
tam.str_warning, tam.str_critical,
tam.id_tipo_modulo,
tae.estado, tae.current_interval,
tae.utimestamp, tae.datos
FROM tagente_modulo tam
INNER JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo
WHERE tam.id_agente = %d
%s %s",
$id_agent,
$name_where,
$and_module_status
);
$modules = db_get_all_rows_sql ($query);
$table_modules = new stdClass();
$table_modules->width = "100%";
$table_modules->class="databox data";
$table_modules->head = array();
$table_modules->head[0] = __('Module name');
$table_modules->head[1] = __('Data');
$table_modules->head[2] = __('Treshold');
$table_modules->head[3] = __('Current interval');
$table_modules->head[4] = __('Timestamp');
$table_modules->head[5] = __('Status');
$table_modules->data = array();
if(isset($modules) && is_array($modules)){
foreach ($modules as $key => $value) {
$table_modules->data[$key][0] = $value['nombre'];
if($value["id_tipo_modulo"] != 3 &&
$value["id_tipo_modulo"] != 10 &&
$value["id_tipo_modulo"] != 17 &&
$value["id_tipo_modulo"] != 23 &&
$value["id_tipo_modulo"] != 33 ){
$table_modules->data[$key][1] = remove_right_zeros(number_format($value["datos"], $config['graph_precision']));
}
else{
$table_modules->data[$key][1] = $value["datos"];
}
$table_modules->data[$key][2] = ui_print_module_warn_value (
$value["max_warning"],
$value["min_warning"],
$value["str_warning"],
$value["max_critical"],
$value["min_critical"],
$value["str_critical"]
);
$table_modules->data[$key][3] = $value['current_interval'];
$table_modules->data[$key][4] = ui_print_timestamp($value['utimestamp'], true);
switch ($value['estado']) {
case 0:
case 300:
$table_modules->data[$key][5] = html_print_image(
'images/status_sets/default/severity_normal.png',
true,
array(
'title' => __('Modules normal')
)
);
break;
case 1:
case 100:
$table_modules->data[$key][5] = html_print_image(
'images/status_sets/default/severity_critical.png',
true,
array(
'title' => __('Modules critical')
)
);
break;
case 2:
case 200:
$table_modules->data[$key][5] = html_print_image(
'images/status_sets/default/severity_warning.png',
true,
array(
'title' => __('Modules warning')
)
);
break;
case 3:
$table_modules->data[$key][5] = html_print_image(
'images/status_sets/default/severity_maintenance.png',
true,
array(
'title' => __('Modules unknown')
)
);
break;
case 4:
case 5:
$table_modules->data[$key][5] = html_print_image(
'images/status_sets/default/severity_informational.png',
true,
array(
'title' => __('Modules no init')
)
);
break;
default:
$table_modules->data[$key][5] = html_print_image(
'images/status_sets/default/severity_normal.png',
true,
array(
'title' => __('Modules normal')
)
);
break;
}
}
}
//status agents from tagente
$sql_info_agents = "SELECT * fROM tagente WHERE id_agente =" . $id_agent;
$info_agents = db_get_row_sql($sql_info_agents);
$status_agent = agents_get_status_from_counts($info_agents);
if (is_metaconsole()) {
metaconsole_restore_db();
}
$data['modules_table'] = html_print_table($table_modules, true);
$data['img_status_agent'] = agents_get_image_status($status_agent);
echo json_encode($data);
return;
}
if($build_table_save_filter){
$type_form = get_parameter("type_form", '');
if($type_form == 'save'){
$tabs = '<div id="tabs" style="height:95%;">';
$tabs .= "<ul class='tab_save_filter'>";
$tabs .= "<li>";
$tabs .= "<a href='#extended_create_filter' id='link_create'>";
$tabs .= html_print_image('images/lightning_go.png',true);
$tabs .= "<span>". __('New Filter') . "</span>";
$tabs .= "</a>";
$tabs .= "</li>";
$tabs .= "<li>";
$tabs .= "<a href='#extended_update_filter' id='link_update'>";
$tabs .= html_print_image('images/zoom.png',true);
$tabs .= "<span>".__('Existing Filter')."</span>";
$tabs .= "</a>";
$tabs .= "</li>";
$tabs .= "</ul>";
$tabs .= '<div id="extended_create_filter">';
$tabs .= '</div>';
$tabs .= '<div id="extended_update_filter">';
$tabs .= '</div>';
$tabs .= "</div>";
echo $tabs;
}
else{
$table = new StdClass;
$table->id = 'save_filter_form';
$table->width = '100%';
$table->class = 'databox';
$array_filters = get_filters_custom_fields_view(0, true);
$table->data[0][0] = __('Filter name');
$table->data[0][1] = html_print_select(
$array_filters, 'id_name',
'', '', '', '',
true, false, true, '', false
);
$table->data[0][3] = html_print_submit_button (__('Load filter'), 'load_filter', false, 'class="sub upd"', true);
echo "<form action='' method='post'>";
html_print_table($table);
echo "</form>";
}
return;
}
if($append_tab_filter){
$filters = json_decode(io_safe_output(get_parameter("filters", '')), true);
$table = new StdClass;
$table->id = 'save_filter_form';
$table->width = '100%';
$table->class = 'databox';
$table->rowspan = array();
if($filters['id'] == 'extended_create_filter'){
echo "<div id='msg_error_create'></div>";
$table->data[0][0] = __('Filter name');
$table->data[0][1] = html_print_input_text('id_name', '', '', 15, 255, true);
$table->data[1][0] = __('Group');
$table->data[1][1] = html_print_select_groups(
$config['id_user'], 'AR', true, 'group_search_cr',
0, '', '', '0', true, false,
false, '', false, 'width:180px;', false, false,
'id_grupo', false
);
$table->rowspan[0][2] = 2;
$table->data[0][2] = html_print_submit_button (__('Create filter'), 'create_filter', false, 'class="sub upd"', true);
}
else{
echo "<div id='msg_error_update'></div>";
echo "<div id='msg_error_delete'></div>";
$array_filters = get_filters_custom_fields_view(0, true);
$table->data[0][0] = __('Filter name');
$table->data[0][1] = html_print_select(
$array_filters, 'id_name', '',
'filter_name_change_group(this.value)',
__('None'), -1, true, false, true,
'', false
);
$table->data[1][0] = __('Group');
$table->data[1][1] = html_print_select_groups(
$config['id_user'], 'AR', true, 'group_search_up',
$group, '', '', '0', true, false,
false, '', false, 'width:180px;', false, false,
'id_grupo', false
);
$table->data[0][2] = html_print_submit_button (__('Delete filter'), 'delete_filter', false, 'class="sub upd"', true);
$table->data[1][2] = html_print_submit_button (__('Update filter'), 'update_filter', false, 'class="sub upd"', true);
}
html_print_table($table);
return;
}
if($create_filter_cf){
//initialize result
$result_array = array();
$result_array['error'] = 0;
$result_array['msg'] = '';
//initialize vars
$filters = json_decode(io_safe_output(get_parameter("filters", '')), true);
$name_filter = get_parameter("name_filter", '');
$group_search = get_parameter("group_search", 0);
//check that the name is not empty
if($name_filter == ''){
$result_array['error'] = 1;
$result_array['msg'] = ui_print_error_message(
__('The name must not be empty'),
'', true
);
echo json_encode($result_array);
return;
}
$name_exists = get_filters_custom_fields_view(0, false, $name_filter);
if($name_exists){
$result_array['error'] = 1;
$result_array['msg'] = ui_print_error_message(
__('Filter name already exists in the bbdd'),
'', true
);
echo json_encode($result_array);
return;
}
//check custom field is not empty
if($filters['id_custom_fields'] == ''){
$result_array['error'] = 1;
$result_array['msg'] = ui_print_error_message(
__('Please, select a custom field'),
'', true
);
echo json_encode($result_array);
return;
}
//insert
$values = array();
$values['name'] = $name_filter;
$values['group_search'] = $group_search;
$values['id_group'] = $filters['group'];
$values['id_custom_field'] = $filters['id_custom_fields'];
$values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']);
$values['id_status'] = json_encode($filters['id_status']);
$values['module_search'] = $filters['module_search'];
$values['module_status'] = json_encode($filters['module_status']);
$values['recursion'] = $filters['recursion'];
$insert = db_process_sql_insert('tagent_custom_fields_filter', $values);
//check error insert
if($insert) {
$result_array['error'] = 0;
$result_array['msg'] = ui_print_success_message(
__("Success create filter."),
'', true
);
} else {
$result_array['error'] = 1;
$result_array['msg'] = ui_print_error_message(
__("Error create filter."),
'', true
);
}
echo json_encode($result_array);
return;
}
if($update_filter_cf){
//initialize result
$result_array = array();
$result_array['error'] = 0;
$result_array['msg'] = '';
//initialize vars
$filters = json_decode(io_safe_output(get_parameter("filters", '')), true);
$id_filter = get_parameter("id_filter", '');
$group_search = get_parameter("group_search", 0);
//check selected filter
if($id_filter == -1){
$result_array['error'] = 1;
$result_array['msg'] = ui_print_error_message(
__('please, select a filter'),
'', true
);
echo json_encode($result_array);
return;
}
//array condition update
$condition = array();
$condition['id'] = $id_filter;
//check selected custom fields
if($filters['id_custom_fields'] == ''){
$result_array['error'] = 1;
$result_array['msg'] = ui_print_error_message(
__('please, select a custom field'),
'', true
);
echo json_encode($result_array);
return;
}
//array values update
$values = array();
$values['id_group'] = $filters['group'];
$values['group_search'] = $group_search;
$values['id_custom_field'] = $filters['id_custom_fields'];
$values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']);
$values['id_status'] = json_encode($filters['id_status']);
$values['module_search'] = $filters['module_search'];
$values['module_status'] = json_encode($filters['module_status']);
$values['recursion'] = $filters['recursion'];
//update
$update = db_process_sql_update('tagent_custom_fields_filter', $values, $condition);
//check error insert
if($update) {
$result_array['error'] = 0;
$result_array['msg'] = ui_print_success_message(
__("Success update filter."),
'', true
);
} else {
$result_array['error'] = 1;
$result_array['msg'] = ui_print_error_message(
__("Error update filter."),
'', true
);
}
echo json_encode($result_array);
return;
}
if($delete_filter_cf){
//Initialize result
$result_array = array();
$result_array['error'] = 0;
$result_array['msg'] = '';
//Initialize vars
$filters = json_decode(io_safe_output(get_parameter("filters", '')), true);
$id_filter = get_parameter("id_filter", '');
//Check selected filter
if($id_filter == -1){
$result_array['error'] = 1;
$result_array['msg'] = ui_print_error_message(
__('please, select a filter'),
'', true
);
echo json_encode($result_array);
return;
}
//Array condition update
$condition = array();
$condition['id'] = $id_filter;
//Delete
$delete = db_process_sql_delete('tagent_custom_fields_filter', $condition);
//Check error insert
if($delete) {
$result_array['error'] = 0;
$result_array['msg'] = ui_print_success_message(
__("Success delete filter."),
'', true
);
} else {
$result_array['error'] = 1;
$result_array['msg'] = ui_print_error_message(
__("Error delete filter."),
'', true
);
}
echo json_encode($result_array);
return;
}
if($change_name_filter){
$id_filter = get_parameter("id_filter", 0);
if(isset($id_filter)){
$res = get_group_filter_custom_field_view($id_filter);
echo json_encode($res);
return;
}
return json_encode(false);
}
}

View File

@ -415,7 +415,7 @@ if ($get_extended_event) {
$custom_data = events_page_custom_data($event);
if ($meta) {
metaconsole_restore_db_force();
metaconsole_restore_db();
}
$general = events_page_general($event);

View File

@ -18,7 +18,6 @@ if(check_login()){
global $config;
include_once($config['homedir'] . "/include/functions_agents.php");
include_once($config['homedir'] . "/include/functions_modules.php");
include_once($config['homedir'] . "/include/functions_ui.php");
@ -36,7 +35,6 @@ $get_type = (bool) get_parameter('get_type', 0);
$list_modules = (bool) get_parameter('list_modules', 0);
$get_agent_modules_json_by_name = (bool) get_parameter('get_agent_modules_json_by_name', 0);
if ($get_agent_modules_json_by_name) {
$agent_name = get_parameter('agent_name');
@ -474,16 +472,17 @@ if ($list_modules) {
$sort = get_parameter('sort', 'none');
$selected = 'border: 1px solid black;';
$order[] = array('field' => 'tmodule_group.name', 'order' => 'ASC');
switch ($sortField) {
case 'type':
switch ($sort) {
case 'up':
$selectTypeUp = $selected;
$order = array('field' => 'tagente_modulo.id_modulo', 'order' => 'ASC');
$order[] = array('field' => 'tagente_modulo.id_modulo', 'order' => 'ASC');
break;
case 'down':
$selectTypeDown = $selected;
$order = array('field' => 'tagente_modulo.id_modulo', 'order' => 'DESC');
$order[] = array('field' => 'tagente_modulo.id_modulo', 'order' => 'DESC');
break;
}
break;
@ -491,11 +490,11 @@ if ($list_modules) {
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
break;
case 'down':
$selectNameDown = $selected;
$order = array('field' => 'tagente_modulo.nombre', 'order' => 'DESC');
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'DESC');
break;
}
break;
@ -503,11 +502,11 @@ if ($list_modules) {
switch ($sort) {
case 'up':
$selectStatusUp = $selected;
$order = array('field' => 'tagente_estado.estado=0 DESC,tagente_estado.estado=3 DESC,tagente_estado.estado=2 DESC,tagente_estado.estado=1 DESC', 'order' => '');
$order[] = array('field' => 'tagente_estado.estado=0 DESC,tagente_estado.estado=3 DESC,tagente_estado.estado=2 DESC,tagente_estado.estado=1 DESC', 'order' => '');
break;
case 'down':
$selectStatusDown = $selected;
$order = array('field' => 'tagente_estado.estado=1 DESC,tagente_estado.estado=2 DESC,tagente_estado.estado=3 DESC,tagente_estado.estado=0 DESC', 'order' => '');
$order[] = array('field' => 'tagente_estado.estado=1 DESC,tagente_estado.estado=2 DESC,tagente_estado.estado=3 DESC,tagente_estado.estado=0 DESC', 'order' => '');
break;
}
break;
@ -515,11 +514,11 @@ if ($list_modules) {
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = array('field' => 'tagente_estado.utimestamp', 'order' => 'ASC');
$order[] = array('field' => 'tagente_estado.utimestamp', 'order' => 'ASC');
break;
case 'down':
$selectLastContactDown = $selected;
$order = array('field' => 'tagente_estado.utimestamp', 'order' => 'DESC');
$order[] = array('field' => 'tagente_estado.utimestamp', 'order' => 'DESC');
break;
}
break;
@ -535,15 +534,7 @@ if ($list_modules) {
$selectLastContactUp = '';
$selectLastContactDown = '';
$order = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
break;
}
switch ($config["dbtype"]) {
case "oracle":
if (isset($order['field']) && $order['field'] == 'tagente_modulo.nombre') {
$order['field'] = 'dbms_lob.substr(tagente_modulo.nombre,4000,1)';
}
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
break;
}
@ -598,9 +589,21 @@ if ($list_modules) {
}
//Count monitors/modules
$order_sql = $order['field'] . " " . $order['order'];
$sql = "SELECT COUNT(*)
FROM tagente_modulo
// Build the order sql
$first = true;
foreach ($order as $ord) {
if ($first) {
$first = false;
}
else {
$order_sql .= ',';
}
$order_sql .= $ord['field'].' '.$ord['order'];
}
$sql_condition = "FROM tagente_modulo
$tags_join
INNER JOIN tagente_estado
ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
@ -609,13 +612,15 @@ if ($list_modules) {
WHERE tagente_modulo.id_agente = $id_agente
AND nombre LIKE '$status_text_monitor_sql'
AND delete_pending = 0
AND disabled = 0
AND $status_filter_sql
AND $status_module_group_filter
$tags_sql
AND tagente_estado.estado != $monitor_filter
GROUP BY tagente_modulo.id_agente_modulo
";
$count_modules = db_get_all_rows_sql($sql);
$count_modules = db_get_all_rows_sql('SELECT COUNT(DISTINCT tagente_modulo.id_agente_modulo)' . $sql_condition);
if (isset($count_modules[0]))
$count_modules = reset($count_modules[0]);
else
@ -623,22 +628,9 @@ if ($list_modules) {
//Get monitors/modules
// Get all module from agent
$sql = "SELECT tagente_estado.*, tagente_modulo.*, tmodule_group.*
FROM tagente_modulo
$tags_join
INNER JOIN tagente_estado
ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_modulo.id_agente = $id_agente
AND nombre LIKE '$status_text_monitor_sql'
AND delete_pending = 0
AND $status_filter_sql
$tags_sql
AND tagente_estado.estado != $monitor_filter
GROUP BY tagente_modulo.id_agente_modulo
ORDER BY tmodule_group.name, $order_sql
";
$sql_modules_info = "SELECT tagente_estado.*, tagente_modulo.*, tmodule_group.*
$sql_condition
GROUP BY tagente_modulo.id_agente_modulo ORDER BY $order_sql";
if ($monitors_change_filter) {
$limit = " LIMIT " . $config['block_size'] . " OFFSET 0";
@ -651,10 +643,10 @@ if ($list_modules) {
$paginate_module = $config['paginate_module'];
if ($paginate_module) {
$modules = db_get_all_rows_sql ($sql . $limit);
$modules = db_get_all_rows_sql ($sql_modules_info . $limit);
}
else {
$modules = db_get_all_rows_sql ($sql);
$modules = db_get_all_rows_sql ($sql_modules_info);
}
if (empty ($modules)) {
$modules = array ();
@ -1104,6 +1096,7 @@ if ($get_type) {
echo $graph_type;
return;
}
}
?>

View File

@ -25,13 +25,12 @@ if ($get_image_path_status){
$only_src = get_parameter("only_src", 0);
$result = array();
$result['bad'] = html_print_image($img_src . '_bad.png', true, '', $only_src);
$result['ok'] = html_print_image($img_src . '_ok.png', true, '', $only_src);
$result['warning'] = html_print_image($img_src . '_warning.png', true, '', $only_src);
$result['ok'] = html_print_image($img_src . '_ok.png', true, '', $only_src);
$result['normal'] = html_print_image($img_src . '.png', true, '', $only_src);
echo json_encode($result);
return;
}
@ -328,8 +327,19 @@ switch ($action) {
case 'get_layout_data':
if(is_metaconsole()){
$server_data = metaconsole_get_connection_by_id($server_id);
// Establishes connection
if (metaconsole_load_external_db($server_data) !== NOERR) continue;
}
$layoutData = db_get_row_filter('tlayout_data',
array('id' => $id_element));
if(is_metaconsole()){
metaconsole_restore_db();
}
$layoutData['height'] = $layoutData['height'];
$layoutData['width'] = $layoutData['width'];
echo json_encode($layoutData);
@ -726,6 +736,14 @@ switch ($action) {
if ($id_custom_graph !== null) {
$values['id_custom_graph'] = $id_custom_graph;
}
if(is_metaconsole()){
if($values['id_custom_graph'] != 0){
$explode_id = explode("|", $values['id_custom_graph']);
$values['id_custom_graph'] = $explode_id[0];
$values['id_metaconsole'] = $explode_id[1];
}
}
break;
case 'bars_graph':
if ($width_percentile !== null) {
@ -1208,9 +1226,11 @@ switch ($action) {
$values['type'] = MODULE_GRAPH;
if(is_metaconsole()){
$explode_id = explode("|", $values['id_custom_graph']);
$values['id_custom_graph'] = $explode_id[0];
$values['id_metaconsole'] = $explode_id[1];
if($values['id_custom_graph'] != 0){
$explode_id = explode("|", $values['id_custom_graph']);
$values['id_custom_graph'] = $explode_id[0];
$values['id_metaconsole'] = $explode_id[1];
}
}
if ($values['id_custom_graph'] > 0 ) {

View File

@ -72,18 +72,14 @@ switch($info) {
if (isInACL($ipOrigin)) {
if (empty($apiPassword) || (!empty($apiPassword) && $api_password === $apiPassword)) {
$user_in_db = process_user_login($user, $password, true);
if ($user_in_db !== false) {
$config['id_user'] = $user_in_db;
$correctLogin = true;
//XXXX
session_start();
if (session_status() === PHP_SESSION_NONE) session_start();
$_SESSION["id_usuario"] = $user;
session_write_close();
file_put_contents(session_save_path() . DIRECTORY_SEPARATOR . "pansess_" . session_id(), $user);
}
else {
$no_login_msg = "Incorrect user credentials";
@ -186,11 +182,6 @@ if ($correctLogin) {
returnError('no_exist_operation', $returnType);
}
}
//XXXXX
if (file_exists(session_save_path() . DIRECTORY_SEPARATOR . "pansess_" . session_id())) {
unlink(session_save_path() . DIRECTORY_SEPARATOR . "pansess_" . session_id());
}
}
else {
// TODO: Implement a new switch in config to enable / disable

View File

@ -1,160 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
/**
* @package Include/auth
*/
if (!isset ($config)) {
die ('
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Pandora FMS - The Flexible Monitoring System - Console error</title>
<meta http-equiv="expires" content="0">
<meta http-equiv="content-type" content="text/html; charset=utf8">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="author" content="Artica ST">
<meta name="copyright" content="(c) Artica ST">
<meta name="robots" content="index, follow">
<link rel="icon" href="../../images/pandora.ico" type="image/ico">
<link rel="stylesheet" href="../styles/pandora.css" type="text/css">
</head>
<body>
<div id="main" style="float:left; margin-left: 100px">
<div align="center">
<div id="login_f">
<h1 id="log_f" class="error">You cannot access this file</h1>
<div>
<img src="../../images/pandora_logo.png" border="0"></a>
</div>
<div class="msg">
<span class="error"><b>ERROR:</b>
You can\'t access this file directly!</span>
</div>
</div>
</div>
</body>
</html>
');
}
$config["user_can_update_password"] = false;
$config["admin_can_add_user"] = false;
$config["admin_can_delete_user"] = false;
$config["admin_can_disable_user"] = false;
global $dev_cache; //This variable needs to be globalized because this file is called from within a function and thus local
//DON'T USE THIS IF YOU DON'T KNOW WHAT YOU'RE DOING
die ("This is a very dangerous authentication scheme. Only use for programming in case you should uncomment this line");
/**
* process_user_login accepts $login and $pass and handles it according to current authentication scheme
*
* @param string $login
* @param string $pass
*
* @return mixed False in case of error or invalid credentials, the username in case it's correct.
*/
function process_user_login ($login, $pass) {
return false; //Error
return $login; //Good
}
/**
* Checks if a user is administrator.
*
* @param string User id.
*
* @return bool True is the user is admin
*/
function is_user_admin ($user) {
return true; //User is admin
return false; //User isn't
}
/**
* Check is a user exists in the system
*
* @param string User id.
*
* @return bool True if the user exists.
*/
function is_user ($id_user) {
return true;
return false;
}
/**
* Gets the users real name
*
* @param string User id.
*
* @return string The users full name
*/
function get_user_fullname ($id_user) {
return "admin";
return "";
return false;
}
/**
* Gets the users email
*
* @param string User id.
*
* @return string The users email address
*/
function get_user_email ($id_user) {
return "test@example.com";
return "";
return false;
}
/**
* Get a list of all users in an array [username] => real name
*
* @param string Field to order by (id_usuario, nombre_real or fecha_registro)
*
* @return array An array of users
*/
function get_users ($order = "nombre_real") {
return array ("admin" => "Admini Strator");
}
/**
* Sets the last login for a user
*
* @param string User id
*/
function process_user_contact ($id_user) {
//void
}
/**
* Deletes the user
*
* @param string User id
*/
function delete_user ($id_user) {
return true;
return false;
}
//Reference the global use authorization error to last ldap error.
$config["auth_error"] = &$dev_cache["auth_error"];
?>

View File

@ -13,17 +13,8 @@
// GNU General Public License for more details.
// Global & session manageme
session_id($_REQUEST["session_id"]);
if (file_exists(session_save_path() . "/pansess_" . session_id()) ) {
$user = file_get_contents(session_save_path() . "/pansess_" . session_id());
}
session_start();
if (isset($user)) {
$_SESSION["id_usuario"] = $user;
}
session_write_close();
require_once ('config.php');
require_once ($config['homedir'] . '/include/auth/mysql.php');
@ -74,11 +65,11 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
<title>Pandora FMS Graph (<?php echo agents_get_alias($agent_id) . ' - ' . $interface_name; ?>)</title>
<link rel="stylesheet" href="styles/pandora.css" type="text/css" />
<link rel="stylesheet" href="styles/pandora_minimal.css" type="text/css" />
<link rel="stylesheet" href="styles/jquery-ui-1.10.0.custom.css" type="text/css" />
<link rel="stylesheet" href="styles/jquery-ui.min.css" type="text/css" />
<script language="javascript" type='text/javascript' src='javascript/pandora.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery-1.9.0.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery-3.3.1.min.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery.pandora.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery.jquery-ui-1.10.0.custom.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery-ui.min.js'></script>
<script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.min.js"></script>
<script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.time.js"></script>
@ -132,7 +123,7 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
$params['height'],
$params['water_mark_url'],
$params['font'],
$params['font_size'],
$config['font_size'],
$params['legend_position'],
$params['colors'],
$params['hide_labels']
@ -151,7 +142,7 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
$params['water_mark_url'],
$params['homedir'],
$params['font'],
$params['font_size'],
$config['font_size'],
$params['from_ux'],
$params['from_wux'],
$params['backgroundColor'],
@ -165,7 +156,7 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
$params['height'],
$params['water_mark_url'],
$params['font'],
$params['font_size'],
$config['font_size'],
$params['backgroundColor'],
$params['tick_color'],
$params['val_min'],
@ -185,7 +176,7 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
'',
$params['water_mark'],
$params['font'],
$params['font_size'],
$config['font_size'],
$params['unit'],
$params['ttl'],
$params['homeurl'],
@ -211,7 +202,9 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
$params['id_agent'],
$params['full_legend_daterray'],
$params['not_interactive'],
1
$params['ttl'],
$params['widgets'],
$params['show']
);
break;
default:
@ -222,6 +215,16 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
$config['font_size'] = $aux_font_size;
?>
<script type="text/javascript">
$('document').ready(function () {
setTimeout(function () {
if (typeof window.callPhantom === 'function') {
window.callPhantom("loaded");
}
}, 10);
});
</script>
</body>
</html>

View File

@ -22,8 +22,8 @@
/**
* Pandora build version and version
*/
$build_version = 'PC181029';
$pandora_version = 'v7.0NG.728';
$build_version = 'PC181211';
$pandora_version = 'v7.0NG.729';
// Do not overwrite default timezone set if defined.
$script_tz = @date_default_timezone_get();
@ -171,19 +171,21 @@ require_once ($ownDir. 'functions_config.php');
date_default_timezone_set("Europe/Madrid");
//////////////////////////////////////
//// PLEASE DO NOT CHANGE ORDER //////
//////////////////////////////////////
require_once ($config["homedir"].'/include/load_session.php');
if (session_status() === PHP_SESSION_NONE) session_start();
config_process_config();
config_prepare_session();
require_once ($config["homedir"].'/include/load_session.php');
if(session_id() == '') {
$resultado = session_start();
}
// Set a the system timezone default
// Set a the system timezone default
if ((!isset($config["timezone"])) OR ($config["timezone"] == "")) {
$config["timezone"] = "Europe/Berlin";
}
////////////////////////////////////////
date_default_timezone_set($config["timezone"]);

View File

@ -14,7 +14,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
function mysql_connect_db($host = null, $db = null, $user = null, $pass = null, $port = null, $charset = "utf8") {
function mysql_connect_db($host = null, $db = null, $user = null, $pass = null, $port = null, $charset = null) {
global $config;
if ($host === null)
@ -42,7 +42,9 @@ function mysql_connect_db($host = null, $db = null, $user = null, $pass = null,
}
db_change_cache_id ($db, $host);
mysqli_set_charset($connect_id, $charset);
if (isset($charset)) {
mysqli_set_charset($connect_id, $charset);
}
mysqli_select_db($connect_id, $db);
}
@ -54,7 +56,9 @@ function mysql_connect_db($host = null, $db = null, $user = null, $pass = null,
db_change_cache_id ($db, $host);
@mysql_set_charset($connect_id, $charset);
if (isset($charset)) {
@mysql_set_charset($connect_id, $charset);
}
mysql_select_db($db, $connect_id);
}

View File

@ -1377,7 +1377,7 @@ function is_management_allowed($hkey = '') {
global $config;
return ( (is_metaconsole() && $config["centralized_management"])
|| (!is_metaconsole() && !$config["centralized_management"])
|| (!is_metaconsole() && $config["centralized_management"]) && $hkey == hash('sha256', db_get_value ('value', 'tupdate_settings', 'token', 'customer_key')));
|| (!is_metaconsole() && $config["centralized_management"]) && $hkey == generate_hash_to_api());
}
/**
@ -1787,10 +1787,7 @@ function check_login ($output = true) {
}
else {
require_once($config["homedir"].'/mobile/include/user.class.php');
if(session_id() == '') {
session_start ();
}
session_write_close ();
if (isset($_SESSION['user'])) {
$user = $_SESSION['user'];
$id_user = $user->getIdUser();
@ -3323,12 +3320,13 @@ function generator_chart_to_pdf($type_graph_pdf, $params, $params_combined = fal
. ' "' . $session_id . '"'
. ' "' . $params['return_img_base_64'] . '"';
$result = exec($cmd);
exec($cmd, $result);
$img_content = join("\n", $result);
if($params['return_img_base_64']){
// To be used in alerts
$width_img = 500;
return $result;
return $img_content;
}
else{
// to be used in PDF files
@ -3372,7 +3370,7 @@ function get_copyright_notice () {
*/
function generate_csrf_code() {
// Start session to make this var permanent
session_start();
if (session_status() === PHP_SESSION_NONE) session_start();
$_SESSION['csrf_code'] = md5(uniqid(mt_rand(), true));
session_write_close();
return $_SESSION['csrf_code'];
@ -3388,4 +3386,8 @@ function validate_csrf_code() {
return isset($code) && isset($_SESSION['csrf_code'])
&& $_SESSION['csrf_code'] == $code;
}
function generate_hash_to_api(){
hash('sha256', db_get_value ('value', 'tupdate_settings', '`key`', 'customer_key'));
}
?>

View File

@ -361,11 +361,13 @@ function agents_get_agents ($filter = false, $fields = false,
break;
case AGENT_STATUS_NOT_NORMAL:
$status_sql = "(
critical_count > 0
OR warning_count > 0
OR unknown_count > 0
OR total_count = 0
normal_count <> total_count
OR total_count = notinit_count)";
//The AGENT_STATUS_NOT_NORMAL filter must show all agents that are not in normal status
/*"(
normal_count <> total_count
AND
(normal_count + notinit_count) <> total_count)";*/
break;
case AGENT_STATUS_NOT_INIT:
$status_sql = "(
@ -921,6 +923,10 @@ function agents_get_group_agents (
unset ($search["alias"]);
}
if (isset($search['id_os'])) {
$filter['id_os'] = $search['id_os'];
}
if (isset($search['status'])) {
switch ($search['status']) {
case AGENT_STATUS_NORMAL:
@ -1310,7 +1316,7 @@ function agents_get_name ($id_agent, $case = "none") {
}
/**
* Get alias of an agent.
* Get alias of an agent (cached function).
*
* @param int $id_agent Agent id.
* @param string $case Case (upper, lower, none)
@ -1319,6 +1325,13 @@ function agents_get_name ($id_agent, $case = "none") {
*/
function agents_get_alias ($id_agent, $case = 'none') {
global $config;
// Prepare cache
static $cache = array();
if (empty($case)) $case = 'none';
// Check cache
if (isset($cache[$case][$id_agent])) return $cache[$case][$id_agent];
if($config['dbconnection_cache'] == null && is_metaconsole()){
$alias = (string) db_get_value ('alias', 'tmetaconsole_agent', 'id_tagente', (int) $id_agent);
} else {
@ -1327,13 +1340,15 @@ function agents_get_alias ($id_agent, $case = 'none') {
switch ($case) {
case 'upper':
return mb_strtoupper($alias, 'UTF-8');
$alias = mb_strtoupper($alias, 'UTF-8');
break;
case 'lower':
return mb_strtolower($alias, 'UTF-8');
case 'none':
default:
return ($alias);
$alias = mb_strtolower($alias, 'UTF-8');
break;
}
$cache[$case][$id_agent] = $alias;
return $alias;
}
function agents_get_alias_by_name ($name, $case = 'none') {
@ -2774,4 +2789,67 @@ function agents_get_status_clause($state, $show_not_init = true) {
// If the state is not an expected state, return no condition
return "1=1";
}
?>
function agents_get_image_status($status){
switch ($status) {
case AGENT_STATUS_NORMAL:
$image_status = html_print_image(
'images/status_sets/default/agent_ok.png',
true,
array(
'title' => __('Agents ok')
)
);
break;
case AGENT_STATUS_CRITICAL:
$image_status = html_print_image(
'images/status_sets/default/agent_critical.png',
true,
array(
'title' => __('Agents critical')
)
);
break;
case AGENT_STATUS_WARNING:
$image_status = html_print_image(
'images/status_sets/default/agent_warning.png',
true,
array(
'title' => __('Agents warning')
)
);
break;
case AGENT_STATUS_UNKNOWN:
$image_status = html_print_image(
'images/status_sets/default/agent_down.png',
true,
array(
'title' => __('Agents unknown')
)
);
break;
case AGENT_STATUS_ALERT_FIRED:
$image_status = 'alert';
break;
case AGENT_STATUS_NOT_INIT:
$image_status = html_print_image(
'images/status_sets/default/agent_no_data.png',
true,
array(
'title' => __('Agents not init')
)
);
break;
default:
$image_status= html_print_image(
'images/status_sets/default/agent_ok.png',
true,
array(
'title' => __('Agents ok')
)
);
break;
}
return $image_status;
}
?>

View File

@ -1845,9 +1845,9 @@ function get_group_alerts($id_group, $filter = '', $options = false,
}
}
$selectText = 'talert_template_modules.*, t2.nombre AS agent_module_name, t3.alias AS agent_name, t4.name AS template_name';
$selectText = 'DISTINCT talert_template_modules.*, t2.nombre AS agent_module_name, t3.alias AS agent_name, t4.name AS template_name';
if ($count !== false) {
$selectText = 'COUNT(talert_template_modules.id) AS count';
$selectText = 'COUNT(DISTINCT talert_template_modules.id) AS count';
}
$sql = sprintf ("SELECT %s
@ -1871,7 +1871,7 @@ function get_group_alerts($id_group, $filter = '', $options = false,
return $alerts[0]['count'];
}
else {
return $alerts;
return $alerts;
}
}
@ -2268,5 +2268,121 @@ function alerts_normalize_actions_escalation($escalation) {
return $escalation;
}
/**
* Check if a command can be added to an action.
*
* @param int Action group id
* @param int Command group id
*
* @return False if command group and alert group are distint of 0 and they are not equal
*/
function alerts_validate_command_to_action($action_group, $command_group) {
// If action group or command group is All, all commands can be applicated.
if ($action_group == 0 || $command_group == 0) return true;
return $action_group == $command_group;
}
/**
* Print the UI update actions
*
* @param bool Update or create
*/
function alerts_ui_update_or_create_actions($update = true) {
global $config;
$id = (string) get_parameter ('id');
// Check ACL of existing aler action
if($update) {
$al_action = alerts_get_alert_action ($id);
if ($al_action !== false) {
if ($al_action['id_group'] == 0) {
if (! check_acl ($config['id_user'], 0, "PM")) {
db_pandora_audit("ACL Violation",
"Trying to access Alert Management");
require ("general/noaccess.php");
exit;
}
}
}
}
$name = (string) get_parameter ('name');
$id_alert_command = (int) get_parameter ('id_command');
$group = get_parameter ('group');
$action_threshold = (int) get_parameter ('action_threshold');
// Validate some values
if (!$id_alert_command) {
ui_print_error_message(__('No command specified'));
return;
}
if (!$name) {
ui_print_error_message(__('No name specified'));
return;
}
$comamnd_group = db_get_value('id_group', 'talert_commands', 'id', $id_alert_command);
if(!alerts_validate_command_to_action($group, $comamnd_group)) {
ui_print_error_message(__("Alert and command group does not match"));
return;
}
// Fill fields info
$info_fields = '';
$values = array();
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
$values['field'.$i] = (string) get_parameter ('field'.$i.'_value');
$info_fields .= ' Field'.$i.': ' . $values['field'.$i];
$values['field'.$i.'_recovery'] = (string) get_parameter ('field'.$i.'_recovery_value');
$info_fields .= ' Field'.$i.'Recovery: ' . $values['field'.$i.'_recovery'];
}
$values['id_group'] = $group;
$values['action_threshold'] = $action_threshold;
if ($update) {
$values['name'] = $name;
$values['id_alert_command'] = $id_alert_command;
$result = (!$name) ? '' : alerts_update_alert_action ($id, $values);
} else {
$name_check = db_get_value ('name', 'talert_actions', 'name', $name);
if ($name_check) {
$result = '';
}
else {
$result = alerts_create_alert_action ($name, $id_alert_command,
$values);
$values = array(
"Name" => $name,
"ID alert Command" => $id_alert_command,
"Field information" => $info_fields,
"Group" => $values['id_group'],
"Action threshold" => $values['action_threshold']
);
}
}
if ($result) {
db_pandora_audit(
"Command management",
$update ? "Update alert action #" . $id : "Create alert action #" . $result,
false,
false,
json_encode($values)
);
}
else {
db_pandora_audit(
"Command management",
$update ? "Fail try to update alert action #" . $id : "Fail try to create alert action",
false,
false,
$update ? json_encode($values) : ''
);
}
ui_print_result_message ($result,
$update ? __('Successfully updated') : __('Successfully created'),
$update ? __('Could not be updated') : __('Could not be created')
);
}
?>

View File

@ -30,6 +30,8 @@ include_once($config['homedir'] . "/include/functions_network_components.php");
include_once($config['homedir'] . "/include/functions_netflow.php");
include_once($config['homedir'] . "/include/functions_servers.php");
include_once($config['homedir'] . "/include/functions_planned_downtimes.php");
include_once($config['homedir'] . "/include/functions_db.php");
include_once($config['homedir'] . "/include/functions_event_responses.php");
enterprise_include_once ('include/functions_local_components.php');
enterprise_include_once ('include/functions_events.php');
enterprise_include_once ('include/functions_agents.php');
@ -1410,10 +1412,6 @@ function api_set_create_os($thrash1, $thrash2, $other, $thrash3) {
returnError('forbidden', 'string');
return;
}
if (defined ('METACONSOLE')) {
return;
}
$values = array();
@ -1429,6 +1427,11 @@ function api_set_create_os($thrash1, $thrash2, $other, $thrash3) {
$resultOrId = false;
if ($other['data'][0] != '') {
$resultOrId = db_process_sql_insert('tconfig_os', $values);
if ($resultOrId)
echo __('Success creating OS');
else
echo __('Error creating OS');
}
}
@ -1436,10 +1439,6 @@ function api_set_create_os($thrash1, $thrash2, $other, $thrash3) {
function api_set_update_os($id_os, $thrash2, $other, $thrash3) {
global $config;
if (defined ('METACONSOLE')) {
return;
}
if (!check_acl($config['id_user'], 0, "AW")) {
returnError('forbidden', 'string');
return;
@ -1457,7 +1456,10 @@ function api_set_update_os($id_os, $thrash2, $other, $thrash3) {
if ($other['data'][0] != '') {
$result = db_process_sql_update('tconfig_os', $values, array('id_os' => $id_os));
if (db_process_sql_update('tconfig_os', $values, array('id_os' => $id_os)))
echo __('Success updating OS');
else
echo __('Error updating OS');
}
}
@ -5411,7 +5413,8 @@ function api_set_planned_downtimes_created ($id, $thrash1, $other, $thrash3) {
'periodically_day_to' => $other['data'][14],
'type_downtime' => $other['data'][15],
'type_execution' => $other['data'][16],
'type_periodicity' => $other['data'][17]
'type_periodicity' => $other['data'][17],
'id_user' => $other['data'][18]
);
$returned = planned_downtimes_created($values);
@ -8720,9 +8723,213 @@ function api_set_delete_user_profile($id, $thrash1, $other, $thrash2) {
returnData('string', array('type' => 'string', 'data' => __('Delete user profile.')));
}
/**
* List all user profiles.
*
* @param Reserved $thrash1
* @param Reserved $thrash2
* @param Reserved $thrash3
* @param string Return type (csv, json, string...)
*
* api.php?op=get&op2=user_profiles_info&return_type=json&apipass=1234&user=admin&pass=pandora
*/
function api_get_user_profiles_info ($thrash1, $thrash2, $thrash3, $returnType) {
global $config;
if (!check_acl($config['id_user'], 0, "PM")){
returnError('forbidden', 'string');
return;
}
$profiles = db_get_all_rows_filter(
'tperfil',
array(),
array(
"id_perfil",
"name",
"incident_view as IR",
"incident_edit as IW",
"incident_management as IM",
"agent_view as AR",
"agent_edit as AW",
"agent_disable as AD",
"alert_edit as LW",
"alert_management as LM",
"user_management as UM",
"db_management as DM",
"event_view as ER",
"event_edit as EW",
"event_management as EM",
"report_view as RR",
"report_edit as RW",
"report_management as RM",
"map_view as MR",
"map_edit as MW",
"map_management as MM",
"vconsole_view as VR",
"vconsole_edit as VW",
"vconsole_management as VM",
"pandora_management as PM"
)
);
if ($profiles === false) {
returnError('error_list_profiles', __('Error retrieving profiles'));
} else {
returnData($returnType, array('type' => 'array', 'data' => $profiles));
}
}
/**
* Create an user profile.
*
* @param Reserved $thrash1
* @param Reserved $thrash2
* @param array parameters in array: name|IR|IW|IM|AR|AW|AD|LW|LM|UM|DM|ER|EW|EM|RR|RW|RM|MR|MW|MM|VR|VW|VM|PM
* @param string Return type (csv, json, string...)
*
* api.php?op=set&op2=create_user_profile_info&return_type=json&other=API_profile%7C1%7C0%7C0%7C1%7C0%7C0%7C0%7C0%7C0%7C0%7C1%7C0%7C0%7C1%7C0%7C0%7C1%7C0%7C0%7C1%7C0%7C0%7C0&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
*/
function api_set_create_user_profile_info ($thrash1, $thrash2, $other, $returnType) {
global $config;
if (!check_acl($config['id_user'], 0, "PM")){
returnError('forbidden', 'string');
return;
}
$values = array(
'name' => (string)$other['data'][0],
'incident_view' => (bool)$other['data'][1] ? 1 : 0,
'incident_edit' => (bool)$other['data'][2] ? 1 : 0,
'incident_management' => (bool)$other['data'][3] ? 1 : 0,
'agent_view' => (bool)$other['data'][4] ? 1 : 0,
'agent_edit' => (bool)$other['data'][5] ? 1 : 0,
'agent_disable' => (bool)$other['data'][6] ? 1 : 0,
'alert_edit' => (bool)$other['data'][7] ? 1 : 0,
'alert_management' => (bool)$other['data'][8] ? 1 : 0,
'user_management' => (bool)$other['data'][9] ? 1 : 0,
'db_management' => (bool)$other['data'][10] ? 1 : 0,
'event_view' => (bool)$other['data'][11] ? 1 : 0,
'event_edit' => (bool)$other['data'][12] ? 1 : 0,
'event_management' => (bool)$other['data'][13] ? 1 : 0,
'report_view' => (bool)$other['data'][14] ? 1 : 0,
'report_edit' => (bool)$other['data'][15] ? 1 : 0,
'report_management' => (bool)$other['data'][16] ? 1 : 0,
'map_view' => (bool)$other['data'][17] ? 1 : 0,
'map_edit' => (bool)$other['data'][18] ? 1 : 0,
'map_management' => (bool)$other['data'][19] ? 1 : 0,
'vconsole_view' => (bool)$other['data'][20] ? 1 : 0,
'vconsole_edit' => (bool)$other['data'][21] ? 1 : 0,
'vconsole_management' => (bool)$other['data'][22] ? 1 : 0,
'pandora_management' => (bool)$other['data'][23] ? 1 : 0
);
$return = db_process_sql_insert('tperfil', $values);
if ($return === false) {
returnError('error_create_user_profile_info', __('Error creating user profile'));
} else {
returnData($returnType, array('type' => 'array', 'data' => 1));
}
}
/**
* Update an user profile.
*
* @param int Profile id
* @param Reserved $thrash1
* @param array parameters in array: name|IR|IW|IM|AR|AW|AD|LW|LM|UM|DM|ER|EW|EM|RR|RW|RM|MR|MW|MM|VR|VW|VM|PM
* @param string Return type (csv, json, string...)
*
* api.php?op=set&op2=update_user_profile_info&return_type=json&id=6&other=API_profile_updated%7C%7C%7C%7C1%7C1%7C1%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
*/
function api_set_update_user_profile_info ($id_profile, $thrash1, $other, $returnType) {
global $config;
if (!check_acl($config['id_user'], 0, "PM")){
returnError('forbidden', 'string');
return;
}
$profile = db_get_row ('tperfil', 'id_perfil', $id_profile);
if ($profile === false) {
returnError('id_not_found', 'string');
return;
}
$values = array(
'name' => $other['data'][0] == '' ? $profile['name'] : (string)$other['data'][0],
'incident_view' => $other['data'][1] == '' ? $profile['incident_view'] : (bool)$other['data'][1] ? 1 : 0,
'incident_edit' => $other['data'][2] == '' ? $profile['incident_edit'] : (bool)$other['data'][2] ? 1 : 0,
'incident_management' => $other['data'][3] == '' ? $profile['incident_management'] : (bool)$other['data'][3] ? 1 : 0,
'agent_view' => $other['data'][4] == '' ? $profile['agent_view'] : (bool)$other['data'][4] ? 1 : 0,
'agent_edit' => $other['data'][5] == '' ? $profile['agent_edit'] : (bool)$other['data'][5] ? 1 : 0,
'agent_disable' => $other['data'][6] == '' ? $profile['agent_disable'] : (bool)$other['data'][6] ? 1 : 0,
'alert_edit' => $other['data'][7] == '' ? $profile['alert_edit'] : (bool)$other['data'][7] ? 1 : 0,
'alert_management' => $other['data'][8] == '' ? $profile['alert_management'] : (bool)$other['data'][8] ? 1 : 0,
'user_management' => $other['data'][9] == '' ? $profile['user_management'] : (bool)$other['data'][9] ? 1 : 0,
'db_management' => $other['data'][10] == '' ? $profile['db_management'] : (bool)$other['data'][10] ? 1 : 0,
'event_view' => $other['data'][11] == '' ? $profile['event_view'] : (bool)$other['data'][11] ? 1 : 0,
'event_edit' => $other['data'][12] == '' ? $profile['event_edit'] : (bool)$other['data'][12] ? 1 : 0,
'event_management' => $other['data'][13] == '' ? $profile['event_management'] : (bool)$other['data'][13] ? 1 : 0,
'report_view' => $other['data'][14] == '' ? $profile['report_view'] : (bool)$other['data'][14] ? 1 : 0,
'report_edit' => $other['data'][15] == '' ? $profile['report_edit'] : (bool)$other['data'][15] ? 1 : 0,
'report_management' => $other['data'][16] == '' ? $profile['report_management'] : (bool)$other['data'][16] ? 1 : 0,
'map_view' => $other['data'][17] == '' ? $profile['map_view'] : (bool)$other['data'][17] ? 1 : 0,
'map_edit' => $other['data'][18] == '' ? $profile['map_edit'] : (bool)$other['data'][18] ? 1 : 0,
'map_management' => $other['data'][19] == '' ? $profile['map_management'] : (bool)$other['data'][19] ? 1 : 0,
'vconsole_view' => $other['data'][20] == '' ? $profile['vconsole_view'] : (bool)$other['data'][20] ? 1 : 0,
'vconsole_edit' => $other['data'][21] == '' ? $profile['vconsole_edit'] : (bool)$other['data'][21] ? 1 : 0,
'vconsole_management' => $other['data'][22] == '' ? $profile['vconsole_management'] : (bool)$other['data'][22] ? 1 : 0,
'pandora_management' => $other['data'][23] == '' ? $profile['pandora_management'] : (bool)$other['data'][23] ? 1 : 0
);
$return = db_process_sql_update('tperfil', $values, array('id_perfil' => $id_profile));
if ($return === false) {
returnError('error_update_user_profile_info', __('Error updating user profile'));
} else {
returnData($returnType, array('type' => 'array', 'data' => 1));
}
}
/**
* Delete an user profile.
*
* @param int Profile id
* @param Reserved $thrash1
* @param Reserved $thrash2
* @param string Return type (csv, json, string...)
*
* api.php?op=set&op2=delete_user_profile_info&return_type=json&id=7&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
*/
function api_set_delete_user_profile_info ($id_profile, $thrash1, $thrash2, $returnType) {
global $config;
if (!check_acl($config['id_user'], 0, "PM")){
returnError('forbidden', 'string');
return;
}
$profile = db_get_value ('id_perfil', 'tperfil', 'id_perfil', $id_profile);
if ($profile === false) {
returnError('id_not_found', 'string');
return;
}
$return = profile_delete_profile_and_clean_users($id_profile);
if ($return === false) {
returnError('error_delete_user_profile_info', __('Error deleting user profile'));
} else {
returnData($returnType, array('type' => 'array', 'data' => 1));
}
}
/**
* Create new incident in Pandora.
*
*
* @param $thrash1 Don't use.
* @param $thrash2 Don't use.
* @param array $other it's array, $other as param is <title>;<description>;
@ -10013,6 +10220,11 @@ function api_set_enable_disable_agent ($id, $thrash2, $other, $thrash3) {
}
$disabled = ( $other['data'][0] ? 0 : 1 );
enterprise_hook(
'config_agents_update_config_token',
array($id, 'standby', $disabled ? "1" : "0")
);
$result = db_process_sql_update('tagente',
array('disabled' => $disabled), array('id_agente' => $id));
@ -10869,12 +11081,17 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) {
else
db_pandora_audit("Report management", "Failed to create cluster agent $name");
returnData('string',
array('type' => 'string', 'data' => (int)$id_cluster));
if ($id_cluster !== false)
returnData('string',
array('type' => 'string', 'data' => (int)$id_cluster));
else
returnError('error_set_new_cluster', __('Failed to create cluster.'));
} else {
returnError('error_set_new_cluster', __('Agent name cannot be empty.'));
return;
}
return;
}
function api_set_add_cluster_agent($thrash1, $thrash2, $other, $thrash3) {
@ -11457,6 +11674,159 @@ function api_get_modules_id_name_by_cluster_name ($cluster_name){
}
/**
* @param $trash1
* @param $trash2
* @param mixed $trash3
* @param $returnType
* Example:
* api.php?op=get&op2=event_responses&return_type=csv&apipass=1234&user=admin&pass=pandora
*/
function api_get_event_responses($trash1, $trash2, $trash3, $returnType) {
global $config;
// Error if user cannot read event responses.
if (!check_acl($config['id_user'], 0, "PM")) {
returnError('forbidden', $returnType);
return;
}
$responses = event_responses_get_responses();
if (empty($responses)) {
returnError('no_data_to_show', $returnType);
return;
}
returnData ($returnType, array('type' => 'array', 'data' => $responses));
}
/**
* @param $id_response
* @param $trash2
* @param mixed $trash3
* @param $returnType
* Example:
* api.php?op=set&op2=delete_event_response&id=7&apipass=1234&user=admin&pass=pandora
*/
function api_set_delete_event_response($id_response, $trash1, $trash2, $returnType) {
global $config;
// Error if user cannot read event responses.
if (!check_acl($config['id_user'], 0, "PM")) {
returnError('forbidden', $returnType);
return;
}
// Check if id exists
$event_group = db_get_value('id_group', 'tevent_response','id', $id_response);
if ($event_group === false) {
returnError('id_not_found', $returnType);
return;
}
// Check user if can edit the module
if (!check_acl($config['id_user'], $event_group, "PM")) {
returnError('forbidden', $returnType);
return;
}
$result = db_process_sql_delete('tevent_response', array('id' => $id_response));
returnData ($returnType, array('type' => 'string', 'data' => $result));
}
/**
* @param $trash1
* @param $trash2
* @param mixed $other. Serialized params
* @param $returnType
* Example:
* api.php?op=set&op2=create_event_response&other=response%7Cdescription%20response%7Ctouch%7Ccommand%7C0%7C650%7C400%7C0%7Cresponse%7C0&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
*/
function api_set_create_event_response($trash1, $trash2, $other, $returnType) {
global $config;
// Error if user cannot read event responses.
if (!check_acl($config['id_user'], 0, "PM")) {
returnError('forbidden', $returnType);
return;
}
$values = array();
$values['name'] = $other['data'][0];
$values['description'] = $other['data'][1];
$values['target'] = $other['data'][2];
$values['type'] = $other['data'][3];
$values['id_group'] = $other['data'][4];
$values['modal_width'] = $other['data'][5];
$values['modal_height'] = $other['data'][6];
$values['new_window'] = $other['data'][7];
$values['params'] = $other['data'][8];
$values['server_to_exec'] = $other['data'][9];
// Error if user has not permission for the group.
if (!check_acl($config['id_user'], $values['id_group'], "PM")) {
returnError('forbidden', $returnType);
return;
}
$return = event_responses_create_response($values) ? 1 : 0;
returnData ($returnType, array('type' => 'string', 'data' => $return));
}
/**
* @param $id_response
* @param $trash2
* @param mixed $other. Serialized params
* @param $returnType
* Example:
* api.php?op=set&op2=update_event_response&id=7&other=response%7Cdescription%20response%7Ctouch%7Ccommand%7C0%7C650%7C400%7C0%7Cresponse%7C0&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
*/
function api_set_update_event_response($id_response, $trash1, $other, $returnType) {
global $config;
// Error if user cannot read event responses.
if (!check_acl($config['id_user'], 0, "PM")) {
returnError('forbidden', $returnType);
return;
}
// Check if id exists
$event_response = db_get_row('tevent_response','id', $id_response);
if ($event_response === false) {
returnError('id_not_found', $returnType);
return;
}
// Check user if can edit the module
if (!check_acl($config['id_user'], $event_response['id_group'], "PM")) {
returnError('forbidden', $returnType);
return;
}
$values = array();
$values['name'] = $other['data'][0] == '' ? $event_response['name'] : $other['data'][0];
$values['description'] = $other['data'][1] == '' ? $event_response['description'] : $other['data'][1];
$values['target'] = $other['data'][2] == '' ? $event_response['target'] : $other['data'][2];
$values['type'] = $other['data'][3] == '' ? $event_response['type'] : $other['data'][3];
$values['id_group'] = $other['data'][4] == '' ? $event_response['id_group'] : $other['data'][4];
$values['modal_width'] = $other['data'][5] == '' ? $event_response['modal_width'] : $other['data'][5];
$values['modal_height'] = $other['data'][6] == '' ? $event_response['modal_height'] : $other['data'][6];
$values['new_window'] = $other['data'][7] == '' ? $event_response['new_window'] : $other['data'][7];
$values['params'] = $other['data'][8] == '' ? $event_response['params'] : $other['data'][8];
$values['server_to_exec'] = $other['data'][9] == '' ? $event_response['server_to_exec'] : $other['data'][9];
// Error if user has not permission for the group.
if (!check_acl($config['id_user'], $values['id_group'], "PM")) {
returnError('forbidden', $returnType);
return;
}
$return = event_responses_update_response($id_response, $values) ? 1 : 0;
returnData ($returnType, array('type' => 'string', 'data' => $return));
}
function api_get_cluster_items ($cluster_id){
global $config;
@ -11501,8 +11871,142 @@ function util_api_check_agent_and_print_error($id_agent, $returnType, $access =
return false;
}
function api_set_validate_traps ($id, $thrash2, $other, $thrash3) {
if (defined ('METACONSOLE')) {
return;
}
if($id == 'all'){
$result = db_process_sql_update('ttrap',array('status' => 1));
}
else{
$result = db_process_sql_update('ttrap',
array('status' => 1), array('id_trap' => $id));
}
if (is_error($result)) {
// TODO: Improve the error returning more info
returnError('error_update_trap', __('Error in trap update.'));
}
else {
returnData('string',
array('type' => 'string',
'data' => __('Validated traps.')));
}
}
function api_set_delete_traps ($id, $thrash2, $other, $thrash3) {
if (defined ('METACONSOLE')) {
return;
}
if($id == 'all'){
$result = db_process_sql ('delete from ttrap');
}
else{
$result = db_process_sql_delete('ttrap',array('id_trap' => $id));
}
if (is_error($result)) {
// TODO: Improve the error returning more info
returnError('error_delete_trap', __('Error in trap delete.'));
}
else {
returnData('string',
array('type' => 'string',
'data' => __('Deleted traps.')));
}
}
function api_get_group_id_by_name($thrash1, $thrash2, $other, $thrash3) {
if (defined ('METACONSOLE')) {
return;
}
$sql = sprintf('SELECT id_grupo
FROM tgrupo WHERE nombre = "'.$other['data'].'"');
$group_id = db_get_all_rows_sql($sql);
if (count($group_id) > 0 and $group_id !== false) {
$data = array('type' => 'array', 'data' => $group_id);
returnData('csv', $data, ';');
}
else {
returnError('error_group_name', 'No groups retrieved.');
}
}
function api_get_timezone($thrash1, $thrash2, $other, $thrash3) {
if (defined ('METACONSOLE')) {
return;
}
$sql = sprintf('SELECT value
FROM tconfig WHERE token = "timezone"');
$timezone = db_get_all_rows_sql($sql);
if (count($timezone) > 0 and $timezone !== false) {
$data = array('type' => 'string', 'data' => $timezone);
returnData('string',array('type' => 'string','data' => $data['data'][0]['value']));
}
else {
returnError('error_timezone', 'No timezone retrieved.');
}
}
function api_get_language($thrash1, $thrash2, $other, $thrash3) {
if (defined ('METACONSOLE')) {
return;
}
$sql = sprintf('SELECT value
FROM tconfig WHERE token = "language"');
$language = db_get_all_rows_sql($sql);
if (count($language) > 0 and $language !== false) {
$data = array('type' => 'string', 'data' => $language);
returnData('string',array('type' => 'string','data' => $data['data'][0]['value']));
}
else {
returnError('error_language', 'No language retrieved.');
}
}
function api_get_session_timeout($thrash1, $thrash2, $other, $thrash3) {
if (defined ('METACONSOLE')) {
return;
}
$sql = sprintf('SELECT value
FROM tconfig WHERE token = "session_timeout"');
$language = db_get_all_rows_sql($sql);
if (count($language) > 0 and $language !== false) {
$data = array('type' => 'string', 'data' => $language);
returnData('string',array('type' => 'string','data' => $data['data'][0]['value']));
}
else {
returnError('error_session_timeout', 'No session timeout retrieved.');
}
}
?>

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