Merge branch 'ent-9662-Restyling-fuentes-colores-botones' of brutus.artica.es:artica/pandorafms into ent-9662-Restyling-fuentes-colores-botones

This commit is contained in:
Jonathan 2023-03-03 10:12:28 +01:00
commit e5cbe07a86
48 changed files with 1970 additions and 94 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.769-230302
Version: 7.0NG.769-230303
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.769-230302"
pandora_version="7.0NG.769-230303"
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

@ -1023,7 +1023,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.769';
use constant AGENT_BUILD => '230302';
use constant AGENT_BUILD => '230303';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.769
%define release 230302
%define release 230303
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.769
%define release 230302
%define release 230303
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.769"
PI_BUILD="230302"
PI_BUILD="230303"
OS_NAME=`uname -s`
FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{230302}
{230303}
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.769 Build 230302")
#define PANDORA_VERSION ("7.0NG.769 Build 230303")
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.769(Build 230302))"
VALUE "ProductVersion", "(7.0NG.769(Build 230303))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.769-230302
Version: 7.0NG.769-230303
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.769-230302"
pandora_version="7.0NG.769-230303"
package_pear=0
package_pandora=1

View File

@ -60,7 +60,31 @@ UPDATE `ttipo_modulo` SET `icon` = 'remote-execution-incremental-data@svg.svg' W
UPDATE `ttipo_modulo` SET `icon` = 'server-web@svg.svg' WHERE `id_tipo` = 38;
UPDATE `ttipo_modulo` SET `icon` = 'keepalive@svg.svg' WHERE `id_tipo` = 100;
CREATE TABLE IF NOT EXISTS `tagent_filter` (
`id_filter` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_name` VARCHAR(600) NOT NULL,
`id_group_filter` INT NOT NULL DEFAULT 0,
`group_id` INT NOT NULL DEFAULT 0,
`recursion` TEXT,
`status` INT NOT NULL DEFAULT -1,
`search` TEXT,
`id_os` INT NOT NULL DEFAULT 0,
`policies` TEXT,
`search_custom` TEXT,
`ag_custom_fields` TEXT,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
CREATE TABLE `tevent_sound` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` TEXT NULL,
`sound` TEXT NULL,
`active` TINYINT NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX agente_modulo_estado ON tevento (estado, id_agentmodule);
CREATE INDEX idx_disabled ON talert_template_modules (disabled);
INSERT INTO `treport_custom_sql` (`name`, `sql`) VALUES ('Agent safe mode not enable', 'select alias from tagente where safe_mode_module = 0');
COMMIT;

View File

@ -1,5 +0,0 @@
START TRANSACTION;
INSERT INTO `treport_custom_sql` (`name`, `sql`) VALUES ('Agent safe mode not enable', 'select alias from tagente where safe_mode_module = 0');
COMMIT;

View File

@ -0,0 +1,71 @@
<?php
/**
* Audit log View.
*
* @category Audit log
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
global $config;
require_once $config['homedir'].'/include/class/EventSound.class.php';
$ajaxPage = 'godmode/events/configuration_sounds';
// Control call flow.
try {
// User access and validation is being processed on class constructor.
$controller = new EventSound($ajaxPage);
} catch (Exception $e) {
if ((bool) is_ajax() === true) {
echo json_encode(['error' => '[EventSound]'.$e->getMessage() ]);
exit;
} else {
echo '[EventSound]'.$e->getMessage();
}
// Stop this execution, but continue 'globally'.
return;
}
// AJAX controller.
if ((bool) is_ajax() === true) {
$method = get_parameter('method');
if (method_exists($controller, $method) === true) {
if ($controller->ajaxMethod($method) === true) {
$controller->{$method}();
} else {
$controller->error('Unavailable method.');
}
} else {
$controller->error('Method not found. ['.$method.']');
}
// Stop any execution.
exit;
} else {
// Run.
$controller->run();
}

View File

@ -438,6 +438,10 @@ if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) check_acl($
}
}
$sub['godmode/events/configuration_sounds']['text'] = __('Accoustic console setup');
$sub['godmode/events/configuration_sounds']['id'] = 'Accoustic console setup';
$sub['godmode/events/configuration_sounds']['pages'] = ['godmode/events/configuration_sounds'];
$menu_godmode['gextensions']['sub'] = $sub;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

View File

@ -31,6 +31,15 @@ $get_agents_interfaces = (bool) get_parameter('get_agents_interfaces');
$id_agents = get_parameter('id_agents', []);
$get_agents_group = (bool) get_parameter('get_agents_group', false);
$force_local = (bool) get_parameter('force_local', false);
// Agent detail filter.
$load_filter_modal = get_parameter('load_filter_modal', 0);
$save_filter_modal = get_parameter('save_filter_modal', 0);
$get_agent_filters = get_parameter('get_agent_filters', 0);
$save_agent_filter = get_parameter('save_agent_filter', 0);
$update_agent_filter = get_parameter('update_agent_filter', 0);
$delete_agent_filter = get_parameter('delete_agent_filter', 0);
if (https_is_running()) {
header('Content-type: application/json');
}
@ -345,4 +354,656 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
return;
}
// Saves an event filter.
if ($save_agent_filter) {
$values = [];
$values['id_name'] = get_parameter('id_name');
$values['group_id'] = get_parameter('group_id');
$values['recursion'] = get_parameter('recursion');
$values['status'] = get_parameter('status');
$values['search'] = get_parameter('search');
$values['id_os'] = get_parameter('id_os');
$values['policies'] = json_encode(get_parameter('policies'));
$values['search_custom'] = get_parameter('search_custom');
$values['ag_custom_fields'] = get_parameter('ag_custom_fields');
$values['id_group_filter'] = get_parameter('id_group_filter');
$exists = (bool) db_get_value_filter(
'id_filter',
'tagent_filter',
$values
);
if ($exists === true) {
echo 'duplicate';
} else {
$result = db_process_sql_insert('tagent_filter', $values);
if ($result === false) {
echo 'error';
} else {
echo $result;
}
}
}
if ($update_agent_filter) {
$values = [];
$id = get_parameter('id');
$values['group_id'] = get_parameter('group_id');
$values['recursion'] = get_parameter('recursion');
$values['status'] = get_parameter('status');
$values['search'] = get_parameter('search');
$values['id_os'] = get_parameter('id_os');
$values['policies'] = json_encode(get_parameter('policies'));
$values['search_custom'] = get_parameter('search_custom');
$values['ag_custom_fields'] = get_parameter('ag_custom_fields');
$result = db_process_sql_update(
'tagent_filter',
$values,
['id_filter' => $id]
);
if ($result === false) {
echo 'error';
} else {
echo 'ok';
}
}
if ($delete_agent_filter) {
$id = get_parameter('id');
$user_groups = users_get_groups(
$config['id_user'],
'AW',
users_can_manage_group_all('AW'),
true
);
$sql = 'DELETE
FROM tagent_filter
WHERE id_filter = '.$id.' AND id_group_filter IN ('.implode(',', array_keys($user_groups)).')';
$agent_filters = db_process_sql($sql);
if ($agent_filters === false) {
echo 'error';
} else {
echo 'ok';
}
}
if ($get_agent_filters) {
$user_groups = users_get_groups(
$config['id_user'],
'AR',
users_can_manage_group_all('AR'),
true
);
$sql = 'SELECT id_filter, id_name
FROM tagent_filter
WHERE id_group_filter IN ('.implode(',', array_keys($user_groups)).')';
$agent_filters = db_get_all_rows_sql($sql);
$result = [];
if ($agent_filters !== false) {
foreach ($agent_filters as $agent_filter) {
$result[$agent_filter['id_filter']] = $agent_filter['id_name'];
}
}
echo io_json_mb_encode($result);
}
if ((int) $load_filter_modal === 1) {
$user_groups = users_get_groups(
$config['id_user'],
'AR',
users_can_manage_group_all('AR'),
true
);
$sql = 'SELECT id_filter, id_name
FROM tagent_filter
WHERE id_group_filter IN ('.implode(',', array_keys($user_groups)).')';
$agent_filters = db_get_all_rows_sql($sql);
$filters = [];
foreach ($agent_filters as $agent_filter) {
$filters[$agent_filter['id_filter']] = $agent_filter['id_name'];
}
echo '<div id="load-filter-select" class="load-filter-modal">';
echo '<form method="post" id="form_load_filter" action="index.php?sec=view&sec2=operation/agentes/estado_agente&pure=">';
$table = new StdClass;
$table->id = 'load_filter_form';
$table->width = '100%';
$table->cellspacing = 4;
$table->cellpadding = 4;
$table->class = 'databox';
if (is_metaconsole()) {
$table->cellspacing = 0;
$table->cellpadding = 0;
$table->class = 'databox filters';
}
$table->styleTable = 'font-weight: bold; color: #555; text-align:left;';
$filter_id_width = '200px';
if (is_metaconsole()) {
$filter_id_width = '150px';
}
$data = [];
$table->rowid[3] = 'update_filter_row1';
$data[0] = __('Load filter').$jump;
$data[0] .= html_print_select(
$filters,
'filter_id',
$current,
'',
__('None'),
0,
true,
false,
true,
'',
false,
'margin-left:5px; width:'.$filter_id_width.';'
);
$data[1] = html_print_submit_button(
__('Load filter'),
'load_filter',
false,
'class="sub upd"',
true
);
$data[1] .= html_print_input_hidden('load_filter', 1, true);
$table->data[] = $data;
$table->rowclass[] = '';
html_print_table($table);
echo '</form>';
echo '</div>';
?>
<script type="text/javascript">
function show_filter() {
$("#load-filter-select").dialog({
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true,
width: 450
});
}
$(document).ready(function() {
show_filter();
});
</script>
<?php
return;
}
if ($save_filter_modal) {
echo '<div id="save-filter-select">';
if (check_acl($config['id_user'], 0, 'AW')) {
echo '<div id="#info_box"></div>';
$table = new StdClass;
$table->id = 'save_filter_form';
$table->width = '100%';
$table->cellspacing = 4;
$table->cellpadding = 4;
$table->class = 'databox';
if (is_metaconsole() === true) {
$table->class = 'databox filters';
$table->cellspacing = 0;
$table->cellpadding = 0;
}
$table->styleTable = 'font-weight: bold; text-align:left;';
if (is_metaconsole() === true) {
$table->style[0] = 'width: 50%; width:50%;';
}
$data = [];
$table->rowid[0] = 'update_save_selector';
$data[0] = html_print_radio_button(
'filter_mode',
'new',
'',
true,
true
).__('New filter').'';
$data[1] = html_print_radio_button(
'filter_mode',
'update',
'',
false,
true
).__('Update/delete filter').'';
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$table->rowid[1] = 'save_filter_row1';
$data[0] = __('Filter name').$jump;
$data[0] .= html_print_input_text('id_name', '', '', 15, 255, true);
if (is_metaconsole() === true) {
$data[1] = __('Save in Group').$jump;
} else {
$data[1] = __('Filter group').$jump;
}
$user_groups_array = users_get_groups_for_select(
$config['id_user'],
'AW',
users_can_manage_group_all('AW'),
true
);
$data[1] .= html_print_select(
$user_groups_array,
'id_group_filter_dialog',
$id_group_filter,
'',
'',
0,
true,
false,
false,
'w130'
);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$table->rowid[2] = 'save_filter_row2';
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$table->rowid[3] = 'update_filter_row1';
$data[0] = __('Filter').$jump;
$user_groups = users_get_groups(
$config['id_user'],
'AW',
users_can_manage_group_all('AW'),
true
);
$sql = 'SELECT id_filter, id_name
FROM tagent_filter
WHERE id_group_filter IN ('.implode(',', array_keys($user_groups)).')';
$agent_filters = db_get_all_rows_sql($sql);
$_filters_update = [];
if ($agent_filters !== false) {
foreach ($agent_filters as $agent_filter) {
$_filters_update[$agent_filter['id_filter']] = $agent_filter['id_name'];
}
}
$data[0] .= html_print_select(
$_filters_update,
'overwrite_filter',
'',
'',
'',
0,
true
);
$table->data[] = $data;
$table->rowclass[] = '';
html_print_table($table);
echo '<div id="update_delete_row"><br>';
echo html_print_submit_button(
__('Update filter'),
'update_filter',
false,
'class="sub upd" onclick="save_update_filter();"',
true
);
echo html_print_submit_button(
__('Delete filter'),
'delete_filter',
false,
'class="sub delete float-right" onclick="save_delete_filter();"',
true
);
echo '</div>';
echo '<div><br>';
echo html_print_submit_button(
__('Save current filter'),
'save_filter',
false,
'class="sub upd float-right" onclick="save_new_filter();"',
true
);
echo '</div>';
} else {
include 'general/noaccess.php';
}
echo '</div>';
?>
<script type="text/javascript">
function show_save_filter() {
$('#save_filter_row1').show();
$('#save_filter_row2').show();
$('#update_filter_row1').hide();
$('#update_delete_row').hide();
// Filter save mode selector
$("[name='filter_mode']").click(function() {
if ($(this).val() == 'new') {
$('#save_filter_row1').show();
$('#save_filter_row2').show();
$('#submit-save_filter').show();
$('#update_filter_row1').hide();
$('#update_delete_row').hide();
}
else {
$('#save_filter_row1').hide();
$('#save_filter_row2').hide();
$('#update_filter_row1').show();
$('#submit-save_filter').hide();
$('#update_delete_row').show();
}
});
$("#save-filter-select").dialog({
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true
});
}
function save_new_filter() {
// If the filter name is blank show error
if ($('#text-id_name').val() == '') {
$('#show_filter_error').html("<h3 class='error'><?php echo __('Filter name cannot be left blank'); ?></h3>");
// Close dialog
$('.ui-dialog-titlebar-close').trigger('click');
return false;
}
var custom_fields_values = $('input[name^="ag_custom_fields"]').map(function() {
return this.value;
}).get();
var custom_fields_ids = $("input[name^='ag_custom_fields']").map(function() {
var name = $(this).attr("name");
var number = name.match(/\[(.*?)\]/)[1];
return number;
}).get();
var ag_custom_fields = custom_fields_ids.reduce(function(result, custom_fields_id, index) {
result[custom_fields_id] = custom_fields_values[index];
return result;
}, {});
var id_filter_save;
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
{
"page" : "include/ajax/agent",
"save_agent_filter" : 1,
"id_name": $("#text-id_name").val(),
"id" : $("#overwrite_filter").val(),
"group_id" : $("#group_id").val(),
"recursion" : $("#checkbox-recursion").is(':checked'),
"status" : $("#status").val(),
"search" : $("#text-search").val(),
"id_os" : $("#os").val(),
"policies" : $("#policies").val(),
"search_custom" : $("#text-search_custom").val(),
"ag_custom_fields": JSON.stringify(ag_custom_fields),
"id_group_filter": $("#id_group_filter_dialog").val(),
},
function (data) {
$("#info_box").hide();
if (data == 'error') {
$("#info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "error_create_filter") {
return true;
}
else
return false;
}).show();
}
else if (data == 'duplicate') {
$("#info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "duplicate_create_filter") {
return true;
}
else
return false;
}).show();
}
else {
id_filter_save = data;
$("#info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "success_create_filter") {
return true;
}
else
return false;
}).show();
}
// First remove all options of filters select.
$('#filter_id').find('option').remove().end();
// Add 'none' option.
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('None')."'"; ?> ).attr ("value", 0));
// Reload filters select.
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
{
"page" : "include/ajax/agent",
"get_agent_filters" : 1
},
function (data) {
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
$('#filter_id').append($('<option></option>').html (s).attr("value", i));
});
},
"json"
);
// Close dialog.
$("#save-filter-select").dialog('close');
}
);
}
function save_update_filter() {
var id_filter_update = $("#overwrite_filter").val();
var name_filter_update = $("#overwrite_filter option[value='"+id_filter_update+"']").text();
var custom_fields_values = $('input[name^="ag_custom_fields"]').map(function() {
return this.value;
}).get();
var custom_fields_ids = $("input[name^='ag_custom_fields']").map(function() {
var name = $(this).attr("name");
var number = name.match(/\[(.*?)\]/)[1];
return number;
}).get();
var ag_custom_fields = custom_fields_ids.reduce(function(result, custom_fields_id, index) {
result[custom_fields_id] = custom_fields_values[index];
return result;
}, {});
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
{
"page" : "include/ajax/agent",
"update_agent_filter" : 1,
"id" : $("#overwrite_filter").val(),
"group_id" : $("#group_id").val(),
"recursion" : $("#checkbox-recursion").is(':checked'),
"status" : $("#status").val(),
"search" : $("#text-search").val(),
"id_os" : $("#os").val(),
"policies" : $("#policies").val(),
"search_custom" : $("#text-search_custom").val(),
"ag_custom_fields": JSON.stringify(ag_custom_fields),
},
function (data) {
$(".info_box").hide();
if (data == 'ok') {
$(".info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "success_update_filter") {
return true;
}
else
return false;
}).show();
}
else {
$(".info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "error_create_filter") {
return true;
}
else
return false;
}).show();
}
});
// First remove all options of filters select.
$('#filter_id').find('option').remove().end();
// Add 'none' option.
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('None')."'"; ?> ).attr ("value", 0));
// Reload filters select.
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
{
"page" : "include/ajax/agent",
"get_agent_filters" : 1
},
function (data) {
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
if (i == id_filter_update) {
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
}
else {
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
}
});
},
"json"
);
// Close dialog
$('.ui-dialog-titlebar-close').trigger('click');
// Update the info with the loaded filter
$("#hidden-id_name").val($('#text-id_name').val());
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + name_filter_update);
return false;
}
function save_delete_filter() {
var id_filter_update = $("#overwrite_filter").val();
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
{
"page" : "include/ajax/agent",
"delete_agent_filter" : 1,
"id" : $("#overwrite_filter").val(),
},
function (data) {
$(".info_box").hide();
if (data == 'ok') {
$(".info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "success_update_filter") {
return true;
}
else
return false;
}).show();
}
else {
$(".info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "error_create_filter") {
return true;
}
else
return false;
}).show();
}
});
// First remove all options of filters select.
$('#filter_id').find('option').remove().end();
// Add 'none' option.
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('None')."'"; ?> ).attr ("value", 0));
// Reload filters select.
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
{
"page" : "include/ajax/agent",
"get_agent_filters" : 1
},
function (data) {
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
if (i == id_filter_update) {
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
}
else {
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
}
});
},
"json"
);
// Close dialog
$('.ui-dialog-titlebar-close').trigger('click');
return false;
}
$(document).ready(function() {
show_save_filter();
});
</script>
<?php
return;
}
return;

View File

@ -2400,6 +2400,11 @@ if ($drawConsoleSound === true) {
'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation',
];
$eventsounds = mysql_db_get_all_rows_sql('SELECT * FROM tevent_sound WHERE active = 1');
foreach ($eventsounds as $key => $row) {
$sounds[$row['sound']] = $row['name'];
}
$inputs[] = [
'class' => 'test-sounds',
'direct' => 1,

View File

@ -73,6 +73,7 @@ if (check_login()) {
$get_monitor_filters = get_parameter('get_monitor_filters', 0);
$save_monitor_filter = get_parameter('save_monitor_filter', 0);
$update_monitor_filter = get_parameter('update_monitor_filter', 0);
$delete_monitor_filter = get_parameter('delete_monitor_filter', 0);
if ($get_agent_modules_json_by_name === true) {
$agent_name = get_parameter('agent_name');
@ -1766,6 +1767,29 @@ if (check_login()) {
}
}
if ($delete_monitor_filter) {
$id = get_parameter('id');
$user_groups = users_get_groups(
$config['id_user'],
'AW',
users_can_manage_group_all('AW'),
true
);
$sql = 'DELETE
FROM tmonitor_filter
WHERE id_filter = '.$id.' AND id_group_filter IN ('.implode(',', array_keys($user_groups)).')';
$monitor_filters = db_process_sql($sql);
if ($monitor_filters === false) {
echo 'error';
} else {
echo 'ok';
}
}
if ($get_monitor_filters) {
$sql = 'SELECT id_filter, id_name FROM tmonitor_filter';
@ -1786,7 +1810,7 @@ if (check_login()) {
$user_groups = users_get_groups(
$config['id_user'],
'AR',
users_can_manage_group_all(),
users_can_manage_group_all('AR'),
true
);
@ -1898,7 +1922,7 @@ if (check_login()) {
);
$data[0][1] = html_print_label_input_block(
__('Update filter'),
__('Update/delete filter'),
html_print_radio_button(
'filter_mode',
'update',
@ -1922,7 +1946,7 @@ if (check_login()) {
$user_groups_array = users_get_groups_for_select(
$config['id_user'],
'AW',
users_can_manage_group_all(),
users_can_manage_group_all('AW'),
true
);
@ -1975,7 +1999,7 @@ if (check_login()) {
'id' => 'submit-save_filter',
'class' => 'action-buttons',
'content' => html_print_submit_button(
__('Save filter'),
__('Save current filter'),
'srcbutton',
false,
[
@ -1989,21 +2013,35 @@ if (check_login()) {
false
);
$input_actions = html_print_submit_button(
__('Delete filter'),
'delete_filter',
false,
[
'icon' => 'delete',
'mode' => 'mini',
'onclick' => 'save_delete_filter();',
],
true
);
$input_actions .= html_print_submit_button(
__('Update filter'),
'srcbutton',
false,
[
'icon' => 'update',
'mode' => 'mini',
'onclick' => 'save_update_filter();',
],
true
);
html_print_div(
[
'id' => 'update_filter_row',
'class' => 'action-buttons',
'content' => html_print_submit_button(
__('Update filter'),
'srcbutton',
false,
[
'icon' => 'search',
'mode' => 'mini',
'onclick' => 'save_update_filter();',
],
true
),
'content' => $input_actions,
],
false
);
@ -2017,17 +2055,20 @@ if (check_login()) {
function show_save_filter() {
$('#save_filter_row2').hide();
$('#update_filter_row').hide();
$('#update_delete_row').hide();
// Filter save mode selector
$("[name='filter_mode']").click(function() {
if ($(this).val() == 'new') {
$('#save_filter_row2').hide();
$('#submit-save_filter').show();
$('#update_filter_row').hide();
$('#update_delete_row').hide();
}
else {
$('#save_filter_row2').show();
$('#update_filter_row').show();
$('#submit-save_filter').hide();
$('#update_delete_row').show();
}
});
$("#save-filter-select").dialog({
@ -2220,6 +2261,69 @@ if (check_login()) {
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + name_filter_update);
return false;
}
function save_delete_filter() {
var id_filter_update = $("#overwrite_filter").val();
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
{
"page" : "include/ajax/module",
"delete_monitor_filter" : 1,
"id" : $("#overwrite_filter").val(),
},
function (data) {
$(".info_box").hide();
if (data == 'ok') {
$(".info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "success_update_filter") {
return true;
}
else
return false;
}).show();
}
else {
$(".info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "error_create_filter") {
return true;
}
else
return false;
}).show();
}
});
// First remove all options of filters select.
$('#filter_id').find('option').remove().end();
// Add 'none' option.
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('None')."'"; ?> ).attr ("value", 0));
// Reload filters select.
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
{
"page" : "include/ajax/module",
"get_monitor_filters" : 1
},
function (data) {
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
if (i == id_filter_update) {
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
}
else {
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
}
});
},
"json"
);
// Close dialog
$('.ui-dialog-titlebar-close').trigger('click');
return false;
}
$(document).ready(function() {
show_save_filter();

View File

@ -0,0 +1,495 @@
<?php
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
/**
* Controller for Audit Logs
*
* @category Controller
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
global $config;
// Necessary classes for extends.
require_once $config['homedir'].'/include/class/HTML.class.php';
enterprise_include_once('godmode/admin_access_logs.php');
/**
* Class EventSound
*/
class EventSound extends HTML
{
/**
* Allowed methods to be called using AJAX request.
*
* @var array
*/
public $AJAXMethods = ['draw'];
/**
* Ajax page.
*
* @var string
*/
private $ajaxController;
/**
* Table id.
*
* @var mixed
*/
private $tableId;
/**
* Class constructor
*
* @param string $ajaxController Ajax controller.
*/
public function __construct(string $ajaxController)
{
global $config;
check_login();
if (check_acl($config['id_user'], 0, 'PM') === false
&& is_user_admin($config['id_user']) === true
) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Event Sound'
);
include 'general/noaccess.php';
return;
}
// Set the ajax controller.
$this->ajaxController = $ajaxController;
}
/**
* Run view
*
* @return void
*/
public function run()
{
global $config;
$tab = get_parameter('tab', '');
$action = get_parameter('action', '');
$message_ok = 0;
$error_msg = __('Name already exist');
$ok_msg = __('Successfully created');
if ($action == 'create') {
$name = get_parameter('name', '');
$sound = get_parameter('file', '');
$exist = db_get_all_rows_sql(sprintf('SELECT * FROM tevent_sound WHERE name = "%s"', $name));
if ($exist === false) {
$uploadMaxFilesize = config_return_in_bytes(ini_get('upload_max_filesize'));
$upload_status = get_file_upload_status('file');
$upload_result = translate_file_upload_status($upload_status);
if ($uploadMaxFilesize < $sound['size']) {
$error_msg = __('File is too large to upload. Check the configuration in php.ini.');
} else {
$pathname = $config['homedir'].'/include/sounds/';
$nameSound = str_replace(' ', '_', $_FILES['file']['name']);
$target_file = $pathname.basename($nameSound);
if (file_exists($target_file)) {
$error_msg = __('Sound already are exists.');
} else {
if (move_uploaded_file($_FILES['file']['tmp_name'], $target_file)) {
$insert = db_process_sql_insert(
'tevent_sound',
[
'name' => $name,
'sound' => $nameSound,
]
);
$ok_msg = __('Successfully created');
} else {
$error_msg = __('Fail uploading the sound');
}
}
}
if ($insert > 0) {
$tab = '';
$message_ok = 1;
}
} else {
$error_msg = __('Sound already are exists');
}
} else if ($action == 'change_action') {
$id = get_parameter('id', '');
$new_action = (int) get_parameter('set_action', '1');
$exist = db_get_all_rows_sql(sprintf('SELECT * FROM tevent_sound WHERE id = "%s"', $id));
if ($exist !== false) {
$result = db_process_sql_update(
'tevent_sound',
['active' => $new_action],
['id' => $id]
);
if (false === (bool) $result) {
$error_msg = __('Error on update status');
} else {
$message_ok = 1;
}
} else {
$error_msg = __('Sound not exist');
}
}
if ($action) {
ui_print_result_message(
$message_ok,
$ok_msg,
$error_msg,
'',
false
);
}
$base_url = 'index.php?sec=eventos&sec2=godmode/events/configuration_sounds';
$setup_url = $base_url.'&tab=add';
$tabs = [
'list' => [
'text' => '<a href="'.$base_url.'">'.html_print_image(
'images/eye_show.png',
true,
[
'title' => __('Sounds'),
'class' => 'invert_filter',
]
).'</a>',
'active' => (bool) ($tab != 'add'),
],
'options' => [
'text' => '<a href="'.$setup_url.'">'.html_print_image(
'images/pen.png',
true,
[
'title' => __('Create'),
'class' => 'invert_filter',
]
).'</a>',
'active' => (bool) ($tab == 'add'),
],
];
if ($tab === 'add') {
$helpHeader = '';
$titleHeader = __('Add new sound');
} else {
$helpHeader = 'servers_ha_clusters_tab';
$titleHeader = __('Accoustic console sound list');
}
// Header.
ui_print_standard_header(
$titleHeader,
'images/gm_servers.png',
false,
$helpHeader,
false,
$tabs,
[
[
'link' => '',
'label' => __('Admin tools'),
],
[
'link' => '',
'label' => __('Accoustic console setup'),
],
]
);
// Javascript.
ui_require_jquery_file('pandora');
// CSS.
ui_require_css_file('wizard');
ui_require_css_file('discovery');
if ($tab === 'add') {
echo '<form method="post" enctype="multipart/form-data" action="index.php?sec=eventos&sec2=godmode/events/configuration_sounds&tab=add&action=create">';
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->data = [];
$table->data[0][0] = __('Name:');
$table->data[0][1] = html_print_input_text(
'name',
'',
'',
80,
100,
true,
false,
true
);
$table->data[1][0] = __('WAV Sound');
$table->data[1][1] = html_print_input_file('file', true, ['required' => true]);
html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(
__('Create'),
'save_sound',
false,
'class="sub wand"'
);
echo '</div>';
echo '</form>';
// Load own javascript file.
echo $this->loadJS();
} else {
// Datatables list.
try {
$columns = [
'name',
'sound',
[
'text' => 'options',
'class' => 'action_buttons mw120px',
],
];
$column_names = [
__('Name'),
__('Sound'),
__('Options'),
];
$this->tableId = 'event_sounds';
if (is_metaconsole() === true) {
// Only in case of Metaconsole, format the frame.
open_meta_frame();
}
// Load datatables user interface.
ui_print_datatable(
[
'id' => $this->tableId,
'class' => 'info_table',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $this->ajaxController,
'ajax_data' => ['method' => 'draw'],
'no_sortable_columns' => [-1],
'order' => [
'field' => 'id',
'direction' => 'asc',
],
'search_button_class' => 'sub filter',
'form' => [
'inputs' => [
[
'label' => __('Free search').ui_print_help_tip(__('Search filter by Name or Sound fields content'), true),
'type' => 'text',
'class' => 'w200px',
'id' => 'filter_text',
'name' => 'filter_text',
],
[
'label' => __('Active'),
'type' => 'select',
'fields' => [
'' => __('All'),
'0' => __('No'),
'1' => __('Yes'),
],
'class' => 'w100px',
'id' => 'active',
'name' => 'active',
],
],
],
]
);
} catch (Exception $e) {
echo $e->getMessage();
}
if (is_metaconsole() === true) {
// Close the frame.
close_meta_frame();
}
// Load own javascript file.
echo $this->loadJS();
}
}
/**
* Get the data for draw the table.
*
* @return void.
*/
public function draw()
{
global $config;
// Initialice filter.
$filter = '1=1';
// Init data.
$data = [];
// Count of total records.
$count = 0;
// Catch post parameters.
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
// There is a limit of (2^32)^2 (18446744073709551615) rows in a MyISAM table, show for show all use max nrows.
$length = ($length != '-1') ? $length : '18446744073709551615';
$order = get_datatable_order();
$filters = get_parameter('filter', []);
$filterText = $filters['filter_text'];
$filterActive = $filters['active'];
if (empty($filterText) === false) {
$filter .= sprintf(
" AND (name LIKE '%%%s%%' OR sound LIKE '%%%s%%')",
$filterText,
$filterText
);
}
if (in_array($filterActive, [0, 1])) {
$filter .= sprintf(
' AND active = %s',
$filterActive,
);
}
$count = (int) db_get_value_sql(sprintf('SELECT COUNT(*) as "total" FROM tevent_sound WHERE %s', $filter));
$sql = sprintf(
'SELECT *
FROM tevent_sound
WHERE %s
ORDER BY %s
LIMIT %d, %d',
$filter,
$order,
$start,
$length
);
$data = db_get_all_rows_sql($sql);
foreach ($data as $key => $row) {
if ($row['active'] === '1') {
$img = 'images/lightbulb.png';
$action = __('Disable sound');
$new_action = 0;
} else {
$img = 'images/lightbulb_off.png';
$action = __('Enable sound');
$new_action = 1;
}
$options = '<a href="index.php?sec=eventos&sec2=godmode/events/configuration_sounds';
$options .= '&action=change_action&id='.$row['id'].'&set_action='.$new_action.'">';
$options .= html_print_image(
$img,
true,
[
'title' => $action,
'class' => 'invert_filter',
]
);
$options .= '</a>';
$data[$key]['options'] = $options;
}
echo json_encode(
[
'data' => $data,
'recordsTotal' => $count,
'recordsFiltered' => $count,
]
);
}
/**
* Checks if target method is available to be called using AJAX.
*
* @param string $method Target method.
*
* @return boolean True allowed, false not.
*/
public function ajaxMethod(string $method)
{
return in_array($method, $this->AJAXMethods);
}
/**
* Load Javascript code.
*
* @return string.
*/
public function loadJS()
{
// Nothing for this moment.
ob_start();
// Javascript content.
?>
<script type="text/javascript">
$(document).ready(function() {
$('#file-sound').change(function(){
var ext = $('#file-sound').val().split('.').pop().toLowerCase();
if($.inArray(ext, ['wav']) == -1) {
alert('<?php __('invalid extension'); ?>');
$('#file-sound').val('');
}
});
$('#submit-save_sound').click(function(){
console.log("a");
});
});
</script>
<?php
// EOF Javascript content.
return ob_get_clean();
}
}

View File

@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC230302';
$build_version = 'PC230303';
$pandora_version = 'v7.0NG.769';
// Do not overwrite default timezone set if defined.

View File

@ -6399,11 +6399,34 @@ function getBearerToken()
}
/**
* Check whether an instance of pandora_db is running.
*
* @return boolean Result.
*/
function is_pandora_db_running()
{
// Get current DB name: useful for metaconsole connection to node.
$db_name = db_get_sql('SELECT DATABASE()');
$is_free_lock = mysql_db_process_sql(
'SELECT IS_FREE_LOCK("'.$db_name.'_pandora_db") AS "value"',
'affected_rows',
'',
false
);
$is_free_lock = (bool) $is_free_lock[0]['value'];
return !$is_free_lock;
}
/**
* Check nms license on api.
*
* @return boolean
*/
* @return boolean.
* */
function nms_check_api()
{
global $config;

View File

@ -519,6 +519,27 @@ function agents_get_agents(
$search_custom = '';
}
if (isset($filter['id_os'])) {
$id_os = $filter['id_os'];
unset($filter['id_os']);
} else {
$id_os = '';
}
if (isset($filter['policies'])) {
$policies = $filter['policies'];
unset($filter['policies']);
} else {
$policies = '';
}
if (isset($filter['other_condition'])) {
$other_condition = $filter['other_condition'];
unset($filter['other_condition']);
} else {
$other_condition = '';
}
if (isset($filter['offset'])) {
$offset = $filter['offset'];
unset($filter['offset']);
@ -692,25 +713,38 @@ function agents_get_agents(
$where_nogroup = '1 = 1';
}
$policy_join = '';
if ($policies !== '') {
$policy_join = 'INNER JOIN tpolicy_agents
ON tpolicy_agents.id_agent=tagente.id_agente';
}
if ($extra) {
$where = sprintf(
'(%s OR (%s)) AND (%s) AND (%s) %s AND %s',
'(%s OR (%s)) AND (%s) AND (%s) %s AND %s %s %s %s',
$sql_extra,
$where,
$where_nogroup,
$status_sql,
$search,
$disabled
$disabled,
$id_os,
$policies,
$other_condition
);
} else {
$where = sprintf(
'%s AND %s AND (%s) %s AND %s %s',
'%s AND %s AND (%s) %s AND %s %s %s %s %s',
$where,
$where_nogroup,
$status_sql,
$search,
$disabled,
$search_custom
$search_custom,
$id_os,
$policies,
$other_condition
);
}
@ -720,9 +754,11 @@ function agents_get_agents(
FROM `%s` tagente
LEFT JOIN tagent_secondary_group
ON tagent_secondary_group.id_agent=tagente.id_agente
%s
WHERE %s %s',
implode(',', $fields),
$table_name,
$policy_join,
$where,
$order
);

View File

@ -2412,14 +2412,17 @@ function events_create_event(
$source = get_product_name();
}
// Get Timestamp.
$timestamp = time();
$values = [
'id_agente' => $id_agent,
'id_usuario' => $id_user,
'id_grupo' => $id_group,
'estado' => $status,
'timestamp' => date('Y-m-d H:i:s'),
'timestamp' => date('Y-m-d H:i:s', $timestamp),
'evento' => $event,
'utimestamp' => time(),
'utimestamp' => $timestamp,
'event_type' => $event_type,
'id_agentmodule' => $id_agent_module,
'id_alert_am' => $id_aam,

View File

@ -84,6 +84,27 @@ function html_debug_print($var, $file='', $oneline=false)
}
/**
* Console log.
*/
function jslog($var)
{
$more_info = '';
if (is_string($var)) {
$more_info = 'size: '.strlen($var);
} else if (is_bool($var)) {
$more_info = 'val: '.($var ? 'true' : 'false');
} else if (is_null($var)) {
$more_info = 'is null';
} else if (is_array($var)) {
$more_info = count($var);
}
echo '<script>console.log("'.date('Y/m/d H:i:s').' ('.gettype($var).') '.$more_info.'");</script>'."\n";
echo '<script>console.log('.json_encode($var).');</script>';
}
// Alias for "html_debug_print"
function html_debug($var, $file='', $oneline=false)
{

View File

@ -7557,3 +7557,22 @@ function ui_print_fullscreen_bar(array $options, bool $return=false)
);
}
function ui_print_status_div($status)
{
switch ((int) $status) {
case 0:
$return = '<div class="status_rounded_rectangles forced_title" style="display: inline-block; background: #82b92e;" title="OK" data-title="OK" data-use_title_for_force_title="1">&nbsp;</div>';
break;
case 1:
$return = '<div class="status_rounded_rectangles forced_title" style="display: inline-block; background: #e63c52;" title="FAILED" data-title="FAILED" data-use_title_for_force_title="1">&nbsp;</div>';
break;
default:
$return = '<div class="status_rounded_rectangles forced_title" style="display: inline-block; background: #fff;" title="UNDEFINED" data-title="UNDEFINED" data-use_title_for_force_title="1">&nbsp;</div>';
break;
}
return $return;
}

View File

@ -144,6 +144,8 @@ class View extends \HTML
tinyMCE.init({
selector: "#textarea_label",
theme: "advanced",
convert_urls:false,
relative_urls:false,
content_css: "'.ui_get_full_url(false, false, false, false).'include/styles/pandora.css",
theme_advanced_font_sizes:
"4pt=.visual_font_size_4pt, " +

View File

@ -131,7 +131,7 @@
<div style='padding-bottom: 50px'>
<?php
$version = '7.0NG.769';
$build = '230302';
$build = '230303';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -36,6 +36,7 @@ require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_users.php';
require_once $config['homedir'].'/include/functions_modules.php';
enterprise_include_once('include/functions_config_agents.php');
enterprise_include_once('include/functions_policies.php');
ui_require_css_file('tables');
@ -149,6 +150,9 @@ $offset = (int) get_parameter('offset', 0);
$refr = get_parameter('refr', 0);
$recursion = get_parameter('recursion', 0);
$status = (int) get_parameter('status', -1);
$os = (int) get_parameter('os', 0);
$policies = (array) get_parameter('policies', []);
$ag_custom_fields = (array) get_parameter('ag_custom_fields', []);
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$agent_a = (bool) check_acl($config['id_user'], 0, 'AR');
@ -157,6 +161,52 @@ $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR');
$onheader = [];
$load_filter_id = (int) get_parameter('filter_id', 0);
if ($load_filter_id > 0) {
$user_groups_fl = users_get_groups(
$config['id_user'],
'AR',
users_can_manage_group_all('AR'),
true
);
$sql = sprintf(
'SELECT id_filter, id_name
FROM tagent_filter
WHERE id_filter = %d AND id_group_filter IN (%s)',
$load_filter_id,
implode(',', array_keys($user_groups_fl))
);
$loaded_filter = db_get_row_sql($sql);
}
if ($loaded_filter['id_filter'] > 0) {
$query_filter['id_filter'] = $load_filter_id;
$filter = db_get_row_filter('tagent_filter', $query_filter, false);
if ($filter !== false) {
$group_id = (int) $filter['group_id'];
$recursion = $filter['recursion'];
$status = $filter['status'];
$search = $filter['search'];
$os = $filter['id_os'];
$policies = json_decode($filter['policies'], true);
$search_custom = $filter['search_custom'];
$ag_custom_fields = $filter['ag_custom_fields'];
}
if (is_array($ag_custom_fields) === false) {
$ag_custom_fields = json_decode(io_safe_output($ag_custom_fields), true);
}
if (is_array($policies) === false) {
$policies = json_decode(io_safe_output($policies), true);
}
}
if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
// Prepare the tab system to the future.
$tab = 'setup';
@ -312,6 +362,118 @@ $table->data['search_fields'][1] = html_print_label_input_block(
)
);
/*
$table->data[1][0] = __('Operating System').'&nbsp;';
$pre_fields = db_get_all_rows_sql(
'select distinct(tagente.id_os),tconfig_os.name from tagente,tconfig_os where tagente.id_os = tconfig_os.id_os'
);
$fields = [];
foreach ($pre_fields as $key => $value) {
$fields[$value['id_os']] = $value['name'];
}
$table->data[1][0] .= html_print_select($fields, 'os', $os, '', 'All', 0, true);
$table->data[1][1] = __('Policies').'&nbsp;';
$pre_fields = policies_get_policies(false, ['id', 'name']);
$fields = [];
foreach ($pre_fields as $value) {
$fields[$value['id']] = $value['name'];
}
$table->data[1][1] .= html_print_select($fields, 'policies[]', $policies, '', 'All', 0, true, true);
$table->data[1][2] = __('Search in custom fields').'&nbsp;'.'&nbsp;'.'&nbsp;';
$table->data[1][2] .= html_print_input_text('search_custom', $search_custom, '', 15, 255, true);
$custom_fields = db_get_all_fields_in_table('tagent_custom_fields');
if ($custom_fields === false) {
$custom_fields = [];
}
$div_custom_fields = '<div class="flex-row">';
foreach ($custom_fields as $custom_field) {
$custom_field_value = '';
if (empty($ag_custom_fields) === false) {
$custom_field_value = $ag_custom_fields[$custom_field['id_field']];
if (empty($custom_field_value) === true) {
$custom_field_value = '';
}
}
$div_custom_fields .= '<div class="div-col">';
$div_custom_fields .= '<div class="div-span">';
$div_custom_fields .= '<span >'.$custom_field['name'].'</span>';
$div_custom_fields .= '</div>';
$div_custom_fields .= '<div class="div-input">';
$div_custom_fields .= html_print_input_text(
'ag_custom_fields['.$custom_field['id_field'].']',
$custom_field_value,
'',
0,
300,
true,
false,
false,
'',
'div-input'
);
$div_custom_fields .= '</div></div>';
}
$table->colspan[2][0] = 7;
$table->cellstyle[2][0] = 'padding-left: 10px;';
$table->data[2][0] = ui_toggle(
$div_custom_fields,
__('Agent custom fields'),
'',
'',
true,
true,
'',
'white-box-content',
'white_table_graph'
);
$table->colspan[4][0] = 4;
$table->cellstyle[4][0] = 'padding-top: 0px;';
$table->data[4][0] = html_print_button(
__('Load filter'),
'load-filter',
false,
'',
'class="float-left margin-right-2 sub config"',
true
);
$table->cellstyle[4][0] .= 'padding-top: 0px;';
$table->data[4][0] .= html_print_button(
__('Manage filter'),
'save-filter',
false,
'',
'class="float-left margin-right-2 sub wand"',
true
);
$table->cellstyle[4][2] = 'padding-top: 0px;';
$table->data[4][2] = html_print_submit_button(
__('Search'),
'srcbutton',
'',
['class' => 'sub search'],
true
);
*/
$searchForm .= html_print_table($table, true);
$searchForm .= html_print_div(
[
@ -367,6 +529,8 @@ $selectLastContactUp = false;
$selectLastContactDown = false;
$selectRemoteUp = false;
$selectRemoteDown = false;
$selectLastStatusChangeUp = false;
$selectLastStatusChangeDown = false;
$order = null;
switch ($sortField) {
@ -526,6 +690,32 @@ switch ($sortField) {
}
break;
case 'last_status_change':
switch ($sort) {
case 'up':
$selectLastStatusChangeUp = $selected;
$order = [
'field' => 'last_status_change',
'field2' => 'alias',
'order' => 'ASC',
];
break;
case 'down':
$selectLastStatusChangeDown = $selected;
$order = [
'field' => 'last_status_change',
'field2' => 'alias',
'order' => 'DESC',
];
break;
default:
// Default.
break;
}
break;
case 'description':
switch ($sort) {
case 'up':
@ -565,6 +755,8 @@ switch ($sortField) {
$selectDescriptionDown = false;
$selectLastContactUp = false;
$selectLastContactDown = false;
$selectLastStatusChangeUp = false;
$selectLastStatusChangeDown = false;
$order = [
'field' => 'alias',
'field2' => 'alias',
@ -624,6 +816,24 @@ if (empty($search_custom) === false) {
$search_sql_custom = '';
}
// Filter by agent custom fields.
$sql_conditions_custom_fields = '';
if (empty($ag_custom_fields) === false) {
$cf_filter = [];
foreach ($ag_custom_fields as $field_id => $value) {
if (empty($value) === false) {
$cf_filter[] = '(tagent_custom_data.id_field = '.$field_id.' AND tagent_custom_data.description LIKE \'%'.$value.'%\')';
}
}
if (empty($cf_filter) === false) {
$sql_conditions_custom_fields = ' AND tagente.id_agente IN (
SELECT tagent_custom_data.id_agent
FROM tagent_custom_data
WHERE '.implode(' AND ', $cf_filter).')';
}
}
// Show only selected groups.
if ($group_id > 0) {
$groups = [$group_id];
@ -636,23 +846,41 @@ if ($group_id > 0) {
$groups = array_keys($user_groups);
}
$all_policies = in_array(0, ($policies ?? []));
$id_os_sql = '';
$policies_sql = '';
if ($os > 0) {
$id_os_sql = ' AND id_os = '.$os;
}
if ($all_policies === false && is_array($policies) && count($policies) > 0) {
$policies_sql = ' AND tpolicy_agents.id_policy IN ('.implode(',', $policies).')';
}
if ($strict_user) {
$count_filter = [
// 'order' => 'tagente.nombre ASC',
'order' => 'tagente.nombre ASC',
'disabled' => 0,
'status' => $status,
'search' => $search,
'order' => 'tagente.nombre ASC',
'disabled' => 0,
'status' => $status,
'search' => $search,
'id_os' => $id_os_sql,
'policies' => $policies_sql,
'other_condition' => $sql_conditions_custom_fields,
];
$filter = [
// 'order' => 'tagente.nombre ASC',
'order' => 'tagente.nombre ASC',
'disabled' => 0,
'status' => $status,
'search' => $search,
'offset' => (int) get_parameter('offset'),
'limit' => (int) $config['block_size'],
'order' => 'tagente.nombre ASC',
'disabled' => 0,
'status' => $status,
'search' => $search,
'offset' => (int) get_parameter('offset'),
'limit' => (int) $config['block_size'],
'id_os' => $id_os_sql,
'policies' => $policies_sql,
'other_condition' => $sql_conditions_custom_fields,
];
if ($group_id > 0) {
@ -691,28 +919,48 @@ if ($strict_user) {
$agents = tags_get_all_user_agents(false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
} else {
$count_filter = [
'disabled' => 0,
'id_grupo' => $groups,
'search' => $search_sql,
'search_custom' => $search_sql_custom,
'status' => $status,
'id_os' => $id_os_sql,
'policies' => $policies_sql,
'other_condition' => $sql_conditions_custom_fields,
];
$filter = [
'order' => 'nombre ASC',
'id_grupo' => $groups,
'disabled' => 0,
'status' => $status,
'search_custom' => $search_sql_custom,
'search' => $search_sql,
'offset' => (int) get_parameter('offset'),
'limit' => (int) $config['block_size'],
'id_os' => $id_os_sql,
'policies' => $policies_sql,
'other_condition' => $sql_conditions_custom_fields,
];
$total_agents = agents_count_agents_filter(
[
'disabled' => 0,
'id_grupo' => $groups,
'search' => $search_sql,
'search_custom' => $search_sql_custom,
'status' => $status,
],
$count_filter,
$access
);
$query_order = $order;
if ($order['field'] === 'last_status_change') {
$query_order = [
'field' => 'alias',
'field2' => 'alias',
'order' => 'ASC',
];
}
$agents = agents_get_agents(
[
'order' => 'nombre ASC',
'id_grupo' => $groups,
'disabled' => 0,
'status' => $status,
'search_custom' => $search_sql_custom,
'search' => $search_sql,
'offset' => (int) get_parameter('offset'),
'limit' => (int) $config['block_size'],
],
$filter,
[
'id_agente',
'id_grupo',
@ -735,7 +983,7 @@ if ($strict_user) {
'agent_version',
],
$access,
$order
$query_order
);
}
@ -769,6 +1017,14 @@ $url_up_group = 'index.php?sec=view&amp;sec2=operation/agentes/estado_agente&amp
$url_down_group = 'index.php?sec=view&amp;sec2=operation/agentes/estado_agente&amp;refr='.$refr.'&amp;offset='.$offset.'&amp;group_id='.$group_id.'&amp;recursion='.$recursion.'&amp;search='.$search.'&amp;status='.$status.'&amp;sort_field=group&amp;sort=down';
$url_up_last = 'index.php?sec=view&amp;sec2=operation/agentes/estado_agente&amp;refr='.$refr.'&amp;offset='.$offset.'&amp;group_id='.$group_id.'&amp;recursion='.$recursion.'&amp;search='.$search.'&amp;status='.$status.'&amp;sort_field=last_contact&amp;sort=up';
$url_down_last = 'index.php?sec=view&amp;sec2=operation/agentes/estado_agente&amp;refr='.$refr.'&amp;offset='.$offset.'&amp;group_id='.$group_id.'&amp;recursion='.$recursion.'&amp;search='.$search.'&amp;status='.$status.'&amp;sort_field=last_contact&amp;sort=down';
$url_up_last_status_change = 'index.php?sec=view&amp;sec2=operation/agentes/estado_agente&amp;refr='.$refr.'&amp;offset='.$offset.'&amp;group_id='.$group_id.'&amp;recursion='.$recursion.'&amp;search='.$search.'&amp;status='.$status.'&amp;sort_field=last_status_change&amp;sort=up';
$url_down_last_status_change = 'index.php?sec=view&amp;sec2=operation/agentes/estado_agente&amp;refr='.$refr.'&amp;offset='.$offset.'&amp;group_id='.$group_id.'&amp;recursion='.$recursion.'&amp;search='.$search.'&amp;status='.$status.'&amp;sort_field=last_status_change&amp;sort=down';
// Prepare pagination.
ui_pagination(
$total_agents,
ui_get_url_refresh(['group_id' => $group_id, 'recursion' => $recursion, 'search' => $search, 'sort_field' => $sortField, 'sort' => $sort, 'status' => $status])
);
// Show data.
$tableAgents = new stdClass();
@ -818,6 +1074,13 @@ $tableAgents->head[9] = '<span>'.__('Last contact').'</span>';
$tableAgents->head[9] .= ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastContactUp, $selectLastContactDown);
$tableAgents->size[9] = '15%';
$tableAgents->head[10] = '<span>'.__('Last status change').'</span>';
$tableAgents->head[10] .= ui_get_sorting_arrows($url_up_last_status_change, $url_down_last_status_change, $selectLastStatusChangeUp, $selectLastStatusChangeDown);
$tableAgents->size[10] = '10%';
$tableAgents->head[11] = '<span>'.__('Agent events').'</span>';
$tableAgents->head[11] = '4%';
$tableAgents->align = [];
$tableAgents->align[2] = 'left';
@ -828,6 +1091,8 @@ $tableAgents->align[6] = 'left';
$tableAgents->align[7] = 'left';
$tableAgents->align[8] = 'left';
$tableAgents->align[9] = 'left';
$tableAgents->align[10] = 'left';
$tableAgents->align[11] = 'left';
$tableAgents->style = [];
$tableAgents->data = [];
@ -935,7 +1200,7 @@ foreach ($agents as $agent) {
$data[1] = '<span class="'.$custom_font_size.'">'.ui_print_truncate_text($agent['description'], 'description', false, true, true, '[&hellip;]').'</span>';
$data[10] = '';
$data[12] = '';
if (enterprise_installed()) {
enterprise_include_once('include/functions_config_agents.php');
@ -993,6 +1258,27 @@ foreach ($agents as $agent) {
$data[9] = agents_get_interval_status($agent);
$last_status_change_agent = agents_get_last_status_change($agent['id_agente']);
$time_elapsed = !empty($last_status_change_agent) ? human_time_comparation($last_status_change_agent) : '<em>'.__('N/A').'</em>';
$data[10] = $time_elapsed;
$agent_event_filter = [
'id_agent' => $agent['id_agente'],
'event_view_hr' => 48,
'status' => -1,
];
$fb64 = base64_encode(json_encode($agent_event_filter));
$data[11] = '<a href="index.php?sec=eventos&sec2=operation/events/events&fb64='.$fb64.'">'.html_print_image(
'images/lightning.png',
true,
[
'align' => 'middle',
'title' => __('Agent events'),
'class' => 'invert_filter',
]
).'</a>';
// This old code was returning "never" on agents without modules, BAD !!
// And does not print outdated agents in red. WRONG !!!!
// $data[7] = ui_print_timestamp ($agent_info["last_contact"], true);
@ -1000,6 +1286,20 @@ foreach ($agents as $agent) {
}
if (empty($tableAgents->data) === false) {
if ($order['field'] === 'last_status_change') {
$order_direction = $order['order'];
usort(
$table->data,
function ($a, $b) use ($order_direction) {
if ($order_direction === 'ASC') {
return strtotime($a[10]) > strtotime($b[10]);
} else {
return strtotime($a[10]) < strtotime($b[10]);
}
}
);
}
html_print_table($tableAgents);
$tablePagination = ui_pagination(
@ -1046,10 +1346,68 @@ if ((bool) check_acl($config['id_user'], 0, 'AW') === true || (bool) check_acl($
echo '</form>';
}
// Load filter div for dialog.
echo '<div id="load-modal-filter" style="display:none"></div>';
echo '<div id="save-modal-filter" style="display:none"></div>';
?>
<script type="text/javascript">
$(document).ready (function () {
var loading = 0;
/* Filter management */
$('#button-load-filter').click(function (event) {
if($('#load-filter-select').length) {
$('#load-filter-select').dialog();
} else {
if (loading == 0) {
loading = 1
$.ajax({
method: 'POST',
url: '<?php echo ui_get_full_url('ajax.php'); ?>',
data: {
page: 'include/ajax/agent',
load_filter_modal: 1
},
success: function (data) {
$('#load-modal-filter')
.empty()
.html(data);
loading = 0;
}
});
}
}
});
$('#button-save-filter').click(function (){
// event.preventDefault();
if($('#save-filter-select').length) {
$('#save-filter-select').dialog();
} else {
if (loading == 0) {
loading = 1
$.ajax({
method: 'POST',
url: '<?php echo ui_get_full_url('ajax.php'); ?>',
data: {
page: 'include/ajax/agent',
save_filter_modal: 1,
current_filter: $('#latest_filter_id').val()
},
success: function (data){
$('#save-modal-filter')
.empty()
.html(data);
loading = 0;
}
});
}
}
});
$("[class^='left']").mouseenter (function () {
$(".agent"+$(this)[0].className).css('visibility', '');
}).mouseleave(function () {

View File

@ -734,6 +734,7 @@ $last_incident = db_get_row_sql(
);
if ($last_incident != false) {
$table_incident = new stdClass();
$table_incident->id = 'agent_incident_main';
$table_incident->width = '100%';
$table_incident->cellspacing = 0;

View File

@ -227,7 +227,7 @@ if ($load_filter_id > 0) {
$user_groups_fl = users_get_groups(
$config['id_user'],
'AR',
users_can_manage_group_all(),
users_can_manage_group_all('AR'),
true
);
@ -287,6 +287,8 @@ if ($loaded_filter['id_filter'] > 0) {
}
}
$all_groups = [];
// Agent group selector.
if (is_metaconsole() === false) {
if ($ag_group > 0 && check_acl($config['id_user'], $ag_group, 'AR')) {
@ -996,7 +998,7 @@ $buttons .= html_print_button(
);
$buttons .= html_print_button(
__('Save filter'),
__('Manage filter'),
'save-filter',
false,
'',

View File

@ -36,6 +36,7 @@ require_once $config['homedir'].'/include/functions_groups.php';
require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_users.php';
enterprise_include_once('include/functions_metaconsole.php');
enterprise_include_once('include/functions_omnishell.php');
ui_require_javascript_file('openlayers.pandora');
ui_require_css_file('agent_view');
@ -1478,6 +1479,17 @@ if ($policyTab === ENTERPRISE_NOT_HOOK) {
$policyTab = '';
}
// Omnishell.
$tasks = count_tasks_agent($id_agente);
if ($tasks === true) {
$omnishellTab = enterprise_hook('omnishell_tab');
if ($omnishellTab == -1) {
$omnishellTab = '';
}
}
// WUX Console.
$modules_wux = enterprise_hook('get_wux_modules', [$id_agente]);
if ((bool) $modules_wux === true) {
@ -1722,6 +1734,7 @@ $onheader = [
'ncm_view' => ($ncm_tab ?? null),
'external_tools' => ($external_tools ?? null),
'incident' => ($incidenttab ?? null),
'omnishell' => ($omnishellTab ?? null),
];
@ -1846,6 +1859,10 @@ switch ($tab) {
$tab_name = __('Policies');
break;
case 'omnishell':
$tab_name = 'Omnishell';
break;
case 'ux_console_tab':
$tab_name = __('UX Console');
break;
@ -1986,6 +2003,10 @@ switch ($tab) {
enterprise_include('operation/agentes/policy_view.php');
break;
case 'omnishell':
enterprise_include('operation/agentes/omnishell_view.php');
break;
case 'ux_console_tab':
enterprise_include('operation/agentes/ux_console_view.php');
break;

View File

@ -1477,7 +1477,7 @@ if ($pure) {
]
).'</a>';
// Sound events.
// Accoustic console.
$sound_event['active'] = false;
// Sound Events.
@ -1500,7 +1500,7 @@ if ($pure) {
'images/sound_console@svg.svg',
true,
[
'title' => __('Sound events'),
'title' => __('Accoustic console'),
'class' => 'invert_filter main_menu_icon',
]
).'</a>';
@ -1550,7 +1550,7 @@ if ($pure) {
switch ($section) {
case 'sound_event':
$onheader['sound_event']['active'] = true;
$section_string = __('Sound events');
$section_string = __('Accoustic console');
break;
case 'history':

View File

@ -60,7 +60,7 @@ ob_start();
echo '<html>';
echo '<head>';
echo '<title>'.__('Sound Events').'</title>';
echo '<title>'.__('Accoustic console').'</title>';
ui_require_css_file('wizard');
ui_require_css_file('discovery');
?>
@ -161,7 +161,7 @@ if ($config['style'] === 'pandora_black' && !is_metaconsole()) {
echo '</head>';
echo "<body class='sound_events'>";
echo "<h1 class='modalheaderh1'>".__('Sound console').'</h1>';
echo "<h1 class='modalheaderh1'>".__('Accoustic console').'</h1>';
// Connection lost alert.
ui_require_css_file('register', 'include/styles/', true);
@ -252,6 +252,11 @@ $sounds = [
'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation',
];
$eventsounds = mysql_db_get_row_sql('SELECT * FROM tevent_sound WHERE active = 1');
foreach ($eventsounds as $key => $row) {
$sounds[$row['sound']] = $row['name'];
}
$inputs[] = [
'label' => \__('Sounds'),
'class' => 'flex-row',

View File

@ -577,11 +577,11 @@ if ($access_console_node === true) {
$sub['operation/events/events_rss.php?user='.$config['id_user'].'&amp;hashup='.$hashup.'&fb64='.$fb64]['type'] = 'direct';
}
// Sound Events.
// Accoustic console.
$data_sound = base64_encode(
json_encode(
[
'title' => __('Sound Console'),
'title' => __('Accoustic console'),
'start' => __('Start'),
'stop' => __('Stop'),
'noAlert' => __('No alert'),
@ -594,8 +594,8 @@ if ($access_console_node === true) {
);
$javascript = 'javascript: openSoundEventModal(`'.$data_sound.'`);';
$sub[$javascript]['text'] = __('Sound Events');
$sub[$javascript]['id'] = 'Sound Events Modal';
$sub[$javascript]['text'] = __('Accoustic console');
$sub[$javascript]['id'] = 'Accoustic console Modal';
$sub[$javascript]['type'] = 'direct';
echo '<div id="modal-sound" style="display:none;"></div>';
@ -750,7 +750,6 @@ if ($access_console_node === true) {
}
}
if (!empty($sub)) {
$menu_operation['extensions']['text'] = __('Tools');
$menu_operation['extensions']['sec2'] = 'operation/extensions';

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.769
%define release 230302
%define release 230303
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.769
%define release 230302
%define release 230303
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.769
%define release 230302
%define release 230303
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

@ -4179,3 +4179,30 @@ CREATE TABLE IF NOT EXISTS `tmonitor_filter` (
`ag_custom_fields` TEXT,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
-- ---------------------------------------------------------------------
-- Table `tagent_filter`
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tagent_filter` (
`id_filter` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_name` VARCHAR(600) NOT NULL,
`id_group_filter` INT NOT NULL DEFAULT 0,
`group_id` INT NOT NULL DEFAULT 0,
`recursion` TEXT,
`status` INT NOT NULL DEFAULT -1,
`search` TEXT,
`id_os` INT NOT NULL DEFAULT 0,
`policies` TEXT,
`search_custom` TEXT,
`ag_custom_fields` TEXT,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
-- Table `tevent_sound`
-- ---------------------------------------------------------------------
CREATE TABLE `tevent_sound` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` TEXT NULL,
`sound` TEXT NULL,
`active` TINYINT NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.769-230302
Version: 7.0NG.769-230303
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.769-230302"
pandora_version="7.0NG.769-230303"
package_cpan=0
package_pandora=1

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.769";
my $pandora_build = "230302";
my $pandora_build = "230303";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.769";
my $pandora_build = "230302";
my $pandora_build = "230303";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_server
%define version 7.0NG.769
%define release 230302
%define release 230303
Summary: Pandora FMS Server
Name: %{name}

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_server
%define version 7.0NG.769
%define release 230302
%define release 230303
Summary: Pandora FMS Server
Name: %{name}

View File

@ -9,7 +9,7 @@
# **********************************************************************
PI_VERSION="7.0NG.769"
PI_BUILD="230302"
PI_BUILD="230303"
MODE=$1
if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
my $version = "7.0NG.769 Build 230302";
my $version = "7.0NG.769 Build 230303";
# Pandora server configuration
my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "7.0NG.769 Build 230302";
my $version = "7.0NG.769 Build 230303";
# save program name for logging
my $progname = basename($0);