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:
Pablo Aragon 2023-03-03 12:43:35 +01:00
commit f3b9d73855
52 changed files with 2422 additions and 279 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.769-230302 Version: 7.0NG.769-230303
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{230302} {230303}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.769 Build 230302") #define PANDORA_VERSION ("7.0NG.769 Build 230303")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.769-230302 Version: 7.0NG.769-230303
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.769-230302" pandora_version="7.0NG.769-230303"
package_pear=0 package_pear=0
package_pandora=1 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` = 'server-web@svg.svg' WHERE `id_tipo` = 38;
UPDATE `ttipo_modulo` SET `icon` = 'keepalive@svg.svg' WHERE `id_tipo` = 100; 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 agente_modulo_estado ON tevento (estado, id_agentmodule);
CREATE INDEX idx_disabled ON talert_template_modules (disabled); 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; 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; $menu_godmode['gextensions']['sub'] = $sub;
} }

View File

@ -235,8 +235,18 @@ if ($count_module_array > 0) {
echo '<table><tr>'; echo '<table><tr>';
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&tab=graph_editor&change_label=1&id=".$id_graph.'&graph='.$idgs_array[$a]."'>"; echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&tab=graph_editor&change_label=1&id=".$id_graph.'&graph='.$idgs_array[$a]."'>";
echo '<div class="flex">';
html_print_input_text('label', $label_array[$a], '', 30, 80, false, false); html_print_input_text('label', $label_array[$a], '', 30, 80, false, false);
html_print_submit_button('Ok', 'btn', false, '', false); html_print_submit_button(
__('Ok'),
'btn',
false,
[
'mode' => 'mini',
'class' => 'inputbuton',
]
);
echo '</div>';
echo '</form>'; echo '</form>';
echo '</tr></table>'; echo '</tr></table>';
@ -246,14 +256,24 @@ if ($count_module_array > 0) {
echo '<table><tr>'; echo '<table><tr>';
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&tab=graph_editor&change_weight=1&id=".$id_graph.'&graph='.$idgs_array[$a]."'>"; echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&tab=graph_editor&change_weight=1&id=".$id_graph.'&graph='.$idgs_array[$a]."'>";
echo '<div class="flex">';
html_print_input_text('weight', $weight_array[$a], '', 20, 10, false, false); html_print_input_text('weight', $weight_array[$a], '', 20, 10, false, false);
html_print_submit_button('Ok', 'btn', false, '', false); html_print_submit_button(
__('Ok'),
'btn',
false,
[
'mode' => 'mini',
'class' => 'inputbuton',
]
);
echo '</div>';
echo '</form>'; echo '</form>';
echo '</tr></table>'; echo '</tr></table>';
echo '</td>'; echo '</td>';
echo "<td class='$tdcolor' align=''>"; echo "<td class='$tdcolor' align=''>";
echo "<a href='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&tab=graph_editor&delete_module=1&id=".$id_graph.'&delete='.$idgs_array[$a]."'>".html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']).'</a>'; echo "<a href='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&tab=graph_editor&delete_module=1&id=".$id_graph.'&delete='.$idgs_array[$a]."'>".html_print_image('images/delete.svg', true, ['title' => __('Delete'), 'class' => 'invert_filter main_menu_icon']).'</a>';
echo '</td>'; echo '</td>';
@ -275,21 +295,25 @@ $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->colspan[0][0] = 3; $table->colspan[0][0] = 3;
$table->size = []; $table->size = [];
$table->size[0] = '25%';
$table->size[1] = '25%';
$table->size[2] = '25%';
$table->size[3] = '25%';
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$table->class = 'databox data'; $table->class = 'databox data';
$table->head[0] = __('Sort items'); $table->head[0] = __('Sort items');
$table->head_colspan[0] = 4; $table->head_colspan[0] = 4;
$table->headstyle[0] = 'text-align: center'; $table->headstyle[0] = 'text-align: center';
$table->size[0] = '25%';
$table->size[1] = '25%';
$table->size[2] = '25%';
$table->size[3] = '25%';
} else { } else {
$table->data[0][0] = '<b>'.__('Sort items').'</b>'; $table->class = 'filter-table-adv';
$table->size[0] = '50%';
$table->size[1] = '50%';
} }
$table->data[1][0] = __('Sort selected items'); $table->data[0][0] = html_print_label_input_block(
$table->data[1][1] = html_print_select_style( __('Sort selected items'),
html_print_select_style(
[ [
'before' => __('before to'), 'before' => __('before to'),
'after' => __('after to'), 'after' => __('after to'),
@ -301,8 +325,11 @@ $table->data[1][1] = html_print_select_style(
'', '',
0, 0,
true true
)
); );
$table->data[1][2] = html_print_input_text_extended( $table->data[0][1] = html_print_label_input_block(
__('Position'),
html_print_input_text_extended(
'position_to_sort', 'position_to_sort',
1, 1,
'text-position_to_sort', 'text-position_to_sort',
@ -313,16 +340,33 @@ $table->data[1][2] = html_print_input_text_extended(
"only_numbers('position_to_sort');", "only_numbers('position_to_sort');",
'', '',
true true
).html_print_input_hidden('ids_items_to_sort', '', true)
); );
$table->data[1][2] .= html_print_input_hidden('ids_items_to_sort', '', true);
$table->data[1][3] = html_print_submit_button(__('Sort'), 'sort_submit', false, 'class="sub upd"', true);
$table->data[1][4] = html_print_input_hidden('action', 'sort_items', true);
echo "<form action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&tab=graph_editor&edit_graph=1&id=".$id_graph."' method='post' onsubmit='return added_ids_sorted_items_to_hidden_input();'>";
html_print_table($table);
echo '</form>';
echo '<br>'; $SortItems = "<form action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&tab=graph_editor&edit_graph=1&id=".$id_graph."' method='post' onsubmit='return added_ids_sorted_items_to_hidden_input();'>";
$SortItems .= html_print_table($table, true);
$SortItems .= html_print_input_hidden('action', 'sort_items', true);
$SortItems .= html_print_div(
[
'class' => 'action-buttons',
'content' => html_print_submit_button(
__('Sort'),
'srcbutton',
false,
[
'class' => 'mini',
'icon' => 'search',
'mode' => 'secondary',
],
true
),
],
true
);
$SortItems .= '</form>';
ui_toggle($SortItems, __('Sort items'), '', '', false);
// Configuration form. // Configuration form.
@ -349,7 +393,20 @@ echo '</td>';
echo '</tr><tr>'; echo '</tr><tr>';
echo "<td colspan='3' align='right'></td>"; echo "<td colspan='3' align='right'></td>";
echo '</tr></table>'; echo '</tr></table>';
echo "<div class='w100p'><input id='submit-add' type=submit name='store' class='sub add right' value='".__('Add')."'></div></form>"; $ActionButtons[] = html_print_submit_button(
__('Add'),
'submit-add',
false,
[
'class' => 'sub ok',
'icon' => 'next',
],
true
);
html_print_action_buttons(
implode('', $ActionButtons),
['type' => 'form_action']
);
ui_require_jquery_file('pandora.controls'); ui_require_jquery_file('pandora.controls');
ui_require_jquery_file('ajaxqueue'); ui_require_jquery_file('ajaxqueue');
@ -361,8 +418,7 @@ ui_require_jquery_file('autocomplete');
$(document).ready (function () { $(document).ready (function () {
$(document).data('text_for_module', $("#none_text").html()); $(document).data('text_for_module', $("#none_text").html());
$("#button-submit-add").click(function() {
$("#submit-add").click(function() {
if($('#filtered-module-modules-modules')[0].value == "" || $('#filtered-module-modules-modules')[0].value == "0") { if($('#filtered-module-modules-modules')[0].value == "" || $('#filtered-module-modules-modules')[0].value == "0") {
alert("<?php echo __('Please, select a module'); ?>"); alert("<?php echo __('Please, select a module'); ?>");
return false; return false;
@ -405,7 +461,6 @@ function added_ids_sorted_items_to_hidden_input() {
if (ids == '') { if (ids == '') {
alert("<?php echo __('Please select any item to order'); ?>"); alert("<?php echo __('Please select any item to order'); ?>");
return false; return false;
} }
else { else {

View File

@ -204,22 +204,84 @@ $urlFilter = '&agent_filter='.$agentFilter.'&module_filter='.$moduleFilter.'&typ
if (!defined('METACONSOLE')) { if (!defined('METACONSOLE')) {
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->class = 'databox filters mrgn_btn_0'; $table->class = 'filter-table-adv';
$table->data[0][0] = __('Agents'); $table->size[0] = '33%';
$table->data[0][0] .= html_print_select($agents, 'agent_filter', $agentFilter, '', __('All'), 0, true); $table->size[1] = '33%';
$table->data[0][1] = __('Modules'); $table->size[1] = '33%';
$table->data[0][1] .= html_print_select($modules, 'module_filter', $moduleFilter, '', __('All'), 0, true); $table->data[0][0] = html_print_label_input_block(
$table->data[0][2] = __('Type'); __('Agents'),
$table->data[0][2] .= html_print_select($types, 'type_filter', $typeFilter, '', __('All'), 0, true); html_print_select(
$agents,
'agent_filter',
$agentFilter,
'',
__('All'),
0,
true,
false,
true,
'',
false,
'width:100%'
)
);
$table->data[0][1] = html_print_label_input_block(
__('Modules'),
html_print_select(
$modules,
'module_filter',
$moduleFilter,
'',
__('All'),
0,
true,
false,
true,
'',
false,
'width:100%'
)
);
$table->data[0][2] = html_print_label_input_block(
__('Type'),
html_print_select(
$types,
'type_filter',
$typeFilter,
'',
__('All'),
0,
true,
false,
true,
'',
false,
'width:100%'
)
);
$form = '<form method="post" action ="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=filter&id_report='.$idReport.'">'; $form = '<form method="post" action ="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=filter&id_report='.$idReport.'">';
$form .= html_print_table($table, true); $form .= html_print_table($table, true);
$form .= '<div class="action-buttons" style="width: '.$table->width.'">'; $form .= html_print_div(
$form .= html_print_submit_button(__('Filter'), 'filter', false, 'class="sub upd"', true); [
'class' => 'action-buttons',
'content' => html_print_submit_button(
__('Filter'),
'filter',
false,
[
'class' => 'mini',
'icon' => 'search',
'mode' => 'secondary',
],
true
),
],
true
);
$form .= html_print_input_hidden('action', 'filter', true); $form .= html_print_input_hidden('action', 'filter', true);
$form .= '</div>';
$form .= '</form>'; $form .= '</form>';
ui_toggle($form, __('Filters')); ui_toggle($form, __('Filters'), '', '', false);
} else { } else {
$table = new stdClass(); $table = new stdClass();
$table->width = '96%'; $table->width = '96%';
@ -618,15 +680,17 @@ foreach ($items as $item) {
if (check_acl($config['id_user'], $item['id_group'], 'RM')) { if (check_acl($config['id_user'], $item['id_group'], 'RM')) {
$table->cellclass[][6] = 'table_action_buttons'; $table->cellclass[][6] = 'table_action_buttons';
$row[6] .= '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=edit&id_report='.$idReport.'&id_item='.$item['id_rc'].'">'.html_print_image( $row[6] .= '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=edit&id_report='.$idReport.'&id_item='.$item['id_rc'].'">'.html_print_image(
'images/config.png', 'images/edit.svg',
true, true,
[ [
'title' => __('Edit'), 'title' => __('Edit'),
'class' => 'invert_filter', 'class' => 'invert_filter main_menu_icon',
'form' => 'form_delete',
'data-value' => $item['id_rc'],
] ]
).'</a>'; ).'</a>';
$row[6] .= '&nbsp;'; $row[6] .= '&nbsp;';
$row[6] .= '<a onClick="if (!confirm (\'Are you sure?\')) return false;" href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=delete&id_report='.$idReport.'&id_item='.$item['id_rc'].$urlFilter.'">'.html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']).'</a>'; $row[6] .= '<a onClick="if (!confirm (\'Are you sure?\')) return false;" href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=delete&id_report='.$idReport.'&id_item='.$item['id_rc'].$urlFilter.'">'.html_print_image('images/delete.svg', true, ['title' => __('Delete'), 'class' => 'invert_filter main_menu_icon']).'</a>';
$row[6] .= '&nbsp;'; $row[6] .= '&nbsp;';
$row[6] .= html_print_checkbox_extended( $row[6] .= html_print_checkbox_extended(
'delete_multiple[]', 'delete_multiple[]',
@ -682,12 +746,25 @@ if (defined('METACONSOLE')) {
'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=edit&id_report='.$idReport.$urlFilter 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=edit&id_report='.$idReport.$urlFilter
); );
echo "<form action='index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=delete_items&id_report=".$idReport."' echo "<form id='form_delete' action='index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=delete_items&id_report=".$idReport."'
method='post' onSubmit='return added_ids_deleted_items_to_hidden_input();'>"; method='post' onSubmit='return added_ids_deleted_items_to_hidden_input();'>";
echo "<div class='pdd_b_20px right; w100p'>";
echo '<div class="action-buttons w100p">';
html_print_input_hidden('ids_items_to_delete', ''); html_print_input_hidden('ids_items_to_delete', '');
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete right mrgn_btn_15px mrgn_right_20px"'); $ActionButtons[] = html_print_submit_button(
__('Delete'),
'delete_btn',
false,
[
'class' => 'sub ok',
'icon' => 'next',
],
true
);
html_print_action_buttons(
implode('', $ActionButtons),
['type' => 'form_action']
);
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
} }
@ -695,23 +772,22 @@ if (defined('METACONSOLE')) {
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->colspan[0][0] = 3;
$table->size = [];
$table->size[0] = '25%';
$table->size[1] = '25%';
$table->size[2] = '25%';
$table->size[3] = '25%';
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$table->colspan[0][0] = 3;
$table->size = [];
$table->size[0] = '25%';
$table->size[1] = '25%';
$table->size[2] = '25%';
$table->size[3] = '25%';
$table->class = 'databox data'; $table->class = 'databox data';
$table->head[0] = __('Sort items'); $table->head[0] = __('Sort items');
$table->head_colspan[0] = 4; $table->head_colspan[0] = 4;
$table->headstyle[0] = 'text-align: center'; $table->headstyle[0] = 'text-align: center';
} else {
$table->data[0][0] = '<b>'.__('Sort items').'</b>';
}
$table->data[1][0] = __('Sort selected items from position: '); $table->data[1][0] = __('Sort selected items from position: ');
$table->data[1][1] = html_print_select_style( $table->data[1][1] = html_print_select_style(
[ [
'before' => __('Move before to'), 'before' => __('Move before to'),
'after' => __('Move after to'), 'after' => __('Move after to'),
@ -723,8 +799,8 @@ $table->data[1][1] = html_print_select_style(
'', '',
0, 0,
true true
); );
$table->data[1][2] = html_print_input_text_extended( $table->data[1][2] = html_print_input_text_extended(
'position_to_sort', 'position_to_sort',
1, 1,
'text-position_to_sort', 'text-position_to_sort',
@ -735,34 +811,93 @@ $table->data[1][2] = html_print_input_text_extended(
"only_numbers('position_to_sort');", "only_numbers('position_to_sort');",
'', '',
true true
); );
$table->data[1][2] .= html_print_input_hidden('ids_items_to_sort', '', true); $table->data[1][2] .= html_print_input_hidden('ids_items_to_sort', '', true);
$table->data[1][3] = html_print_submit_button(__('Sort'), 'sort_submit', false, 'class="sub upd"', true); $table->data[1][3] = html_print_submit_button(__('Sort'), 'sort_submit', false, 'class="sub upd"', true);
echo "<form action='index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=sort_items&id_report=".$idReport."' echo "<form action='index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=sort_items&id_report=".$idReport."'
method='post' onsubmit='return added_ids_sorted_items_to_hidden_input();'>"; method='post' onsubmit='return added_ids_sorted_items_to_hidden_input();'>";
html_print_table($table); html_print_table($table);
echo '</form>'; echo '</form>';
} else {
$table->class = 'filter-table-adv';
$table->size[0] = '50%';
$table->size[1] = '50%';
$table->data[1][0] = html_print_label_input_block(
__('Sort selected items from position: '),
html_print_select_style(
[
'before' => __('Move before to'),
'after' => __('Move after to'),
],
'move_to',
'',
'width:100%',
'',
'',
0,
true,
)
);
$table->data[1][2] = html_print_label_input_block(
__('Position'),
html_print_input_text_extended(
'position_to_sort',
1,
'text-position_to_sort',
'',
3,
10,
false,
"only_numbers('position_to_sort');",
'',
true
).html_print_input_hidden('ids_items_to_sort', '', true)
);
$form = "<form action='index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=sort_items&id_report=".$idReport."' method='post' onsubmit='return added_ids_sorted_items_to_hidden_input();'>";
$form .= html_print_table($table, true);
$form .= html_print_div(
[
'class' => 'action-buttons',
'content' => html_print_submit_button(
__('Sort'),
'sort_submit',
false,
[
'class' => 'mini',
'icon' => 'search',
'mode' => 'secondary',
],
true
),
],
true
);
$form .= html_print_input_hidden('action', 'filter', true);
$form .= '</form>';
ui_toggle($form, __('Sort items'), '', '', false);
}
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->colspan[0][0] = 3;
$table->size = [];
$table->size[0] = '25%';
$table->size[1] = '25%';
$table->size[2] = '25%';
$table->size[3] = '25%';
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$table->colspan[0][0] = 3;
$table->size = [];
$table->size[0] = '25%';
$table->size[1] = '25%';
$table->size[2] = '25%';
$table->size[3] = '25%';
$table->class = 'databox data'; $table->class = 'databox data';
$table->head[0] = __('Delete items'); $table->head[0] = __('Delete items');
$table->head_colspan[0] = 4; $table->head_colspan[0] = 4;
$table->headstyle[0] = 'text-align: center'; $table->headstyle[0] = 'text-align: center';
} else {
$table->data[0][0] = '<b>'.__('Delete items').'</b>';
}
$table->data[1][0] = __('Delete selected items from position: '); $table->data[1][0] = __('Delete selected items from position: ');
$table->data[1][1] = html_print_select_style( $table->data[1][1] = html_print_select_style(
[ [
'above' => __('Delete above to'), 'above' => __('Delete above to'),
'below' => __('Delete below to'), 'below' => __('Delete below to'),
@ -774,8 +909,8 @@ $table->data[1][1] = html_print_select_style(
'', '',
0, 0,
true true
); );
$table->data[1][2] = html_print_input_text_extended( $table->data[1][2] = html_print_input_text_extended(
'position_to_delete', 'position_to_delete',
1, 1,
'text-position_to_delete', 'text-position_to_delete',
@ -786,24 +921,85 @@ $table->data[1][2] = html_print_input_text_extended(
"only_numbers('position_to_delete');", "only_numbers('position_to_delete');",
'', '',
true true
); );
$table->data[1][2] .= html_print_input_hidden('ids_items_to_delete', '', true); $table->data[1][2] .= html_print_input_hidden('ids_items_to_delete', '', true);
$table->data[1][3] = html_print_submit_button(__('Delete'), 'delete_submit', false, 'class="sub upd"', true); $table->data[1][3] = html_print_submit_button(__('Delete'), 'delete_submit', false, 'class="sub upd"', true);
echo "<form action='index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=delete_items_pos&id_report=".$idReport."' echo "<form action='index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=delete_items_pos&id_report=".$idReport."'
method='post'>"; method='post'>";
html_print_table($table); html_print_table($table);
echo '</form>'; echo '</form>';
} else {
$table->class = 'filter-table-adv';
$table->size[0] = '50%';
$table->size[1] = '50%';
$table->data[0][0] = html_print_label_input_block(
__('Delete selected items from position: '),
html_print_select_style(
[
'above' => __('Delete above to'),
'below' => __('Delete below to'),
],
'delete_m',
'',
'',
'',
'',
0,
true
)
);
$table->data[0][1] = html_print_label_input_block(
__('Poisition'),
html_print_input_text_extended(
'position_to_delete',
1,
'text-position_to_delete',
'',
3,
10,
false,
"only_numbers('position_to_delete');",
'',
true
)
);
$form = "<form action='index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=delete_items_pos&id_report=".$idReport."'
method='post'>";
$form .= html_print_input_hidden('ids_items_to_delete', '', true);
$form .= html_print_table($table, true);
$form .= html_print_div(
[
'class' => 'action-buttons',
'content' => html_print_submit_button(
__('Delete'),
'delete_submit',
false,
[
'class' => 'mini',
'icon' => 'delete',
'mode' => 'secondary',
],
true
),
],
true
);
$form .= '</form>';
ui_toggle($form, __('Delete items'), '', '', false);
}
?> ?>
<script type="text/javascript"> <script type="text/javascript">
function check_all_checkboxes() { function check_all_checkboxes() {
if ($("input[name=all_delete]").prop("checked")) { if ($("input[name=all_delete]").prop("checked")) {
$(".check_delete").prop("checked", true); $("[name^='delete_multiple']").prop("checked", true);
} }
else { else {
$(".check_delete").prop("checked", false); $("[name^='delete_multiple']").prop("checked", false);
} }
} }
@ -830,12 +1026,14 @@ function added_ids_sorted_items_to_hidden_input() {
var ids = ''; var ids = '';
var first = true; var first = true;
$("input.selected_check:checked").each(function(i, val) { $("[name^='sorted_items']").each(function(i, val) {
if($(this).prop('checked')){
if (!first) if (!first)
ids = ids + '|'; ids = ids + '|';
first = false; first = false;
ids = ids + $(val).val(); ids = ids + $(val).val();
}
}); });
$("input[name='ids_items_to_sort']").val(ids); $("input[name='ids_items_to_sort']").val(ids);
@ -887,19 +1085,19 @@ function added_ids_deleted_items_to_hidden_input() {
var ids = ''; var ids = '';
var first = true; var first = true;
$("input.check_delete:checked").each(function(i, val) { $("[name^='delete_multiple']").each(function(i, val) {
if($(this).prop('checked')){
if (!first) if (!first)
ids = ids + ','; ids = ids + ',';
first = false; first = false;
ids = ids + $(val).val(); ids = ids + $(val).val();
}
}); });
$("input[name='ids_items_to_delete']").val(ids); $("#hidden-ids_items_to_delete").val(ids);
if (ids == '') { if (ids == '') {
alert("<?php echo __('Please select any item to delete'); ?>"); alert("<?php echo __('Please select any item to delete'); ?>");
return false; return false;
} }
else { else {

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', []); $id_agents = get_parameter('id_agents', []);
$get_agents_group = (bool) get_parameter('get_agents_group', false); $get_agents_group = (bool) get_parameter('get_agents_group', false);
$force_local = (bool) get_parameter('force_local', 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()) { if (https_is_running()) {
header('Content-type: application/json'); header('Content-type: application/json');
} }
@ -345,4 +354,656 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
return; 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; return;

View File

@ -2400,6 +2400,11 @@ if ($drawConsoleSound === true) {
'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation', '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[] = [ $inputs[] = [
'class' => 'test-sounds', 'class' => 'test-sounds',
'direct' => 1, 'direct' => 1,

View File

@ -73,6 +73,7 @@ if (check_login()) {
$get_monitor_filters = get_parameter('get_monitor_filters', 0); $get_monitor_filters = get_parameter('get_monitor_filters', 0);
$save_monitor_filter = get_parameter('save_monitor_filter', 0); $save_monitor_filter = get_parameter('save_monitor_filter', 0);
$update_monitor_filter = get_parameter('update_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) { if ($get_agent_modules_json_by_name === true) {
$agent_name = get_parameter('agent_name'); $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) { if ($get_monitor_filters) {
$sql = 'SELECT id_filter, id_name FROM tmonitor_filter'; $sql = 'SELECT id_filter, id_name FROM tmonitor_filter';
@ -1786,7 +1810,7 @@ if (check_login()) {
$user_groups = users_get_groups( $user_groups = users_get_groups(
$config['id_user'], $config['id_user'],
'AR', 'AR',
users_can_manage_group_all(), users_can_manage_group_all('AR'),
true true
); );
@ -1898,7 +1922,7 @@ if (check_login()) {
); );
$data[0][1] = html_print_label_input_block( $data[0][1] = html_print_label_input_block(
__('Update filter'), __('Update/delete filter'),
html_print_radio_button( html_print_radio_button(
'filter_mode', 'filter_mode',
'update', 'update',
@ -1922,7 +1946,7 @@ if (check_login()) {
$user_groups_array = users_get_groups_for_select( $user_groups_array = users_get_groups_for_select(
$config['id_user'], $config['id_user'],
'AW', 'AW',
users_can_manage_group_all(), users_can_manage_group_all('AW'),
true true
); );
@ -1975,7 +1999,7 @@ if (check_login()) {
'id' => 'submit-save_filter', 'id' => 'submit-save_filter',
'class' => 'action-buttons', 'class' => 'action-buttons',
'content' => html_print_submit_button( 'content' => html_print_submit_button(
__('Save filter'), __('Save current filter'),
'srcbutton', 'srcbutton',
false, false,
[ [
@ -1989,21 +2013,35 @@ if (check_login()) {
false false
); );
html_print_div( $input_actions = html_print_submit_button(
__('Delete filter'),
'delete_filter',
false,
[ [
'id' => 'update_filter_row', 'icon' => 'delete',
'class' => 'action-buttons', 'mode' => 'mini',
'content' => html_print_submit_button( 'onclick' => 'save_delete_filter();',
],
true
);
$input_actions .= html_print_submit_button(
__('Update filter'), __('Update filter'),
'srcbutton', 'srcbutton',
false, false,
[ [
'icon' => 'search', 'icon' => 'update',
'mode' => 'mini', 'mode' => 'mini',
'onclick' => 'save_update_filter();', 'onclick' => 'save_update_filter();',
], ],
true true
), );
html_print_div(
[
'id' => 'update_filter_row',
'class' => 'action-buttons',
'content' => $input_actions,
], ],
false false
); );
@ -2017,17 +2055,20 @@ if (check_login()) {
function show_save_filter() { function show_save_filter() {
$('#save_filter_row2').hide(); $('#save_filter_row2').hide();
$('#update_filter_row').hide(); $('#update_filter_row').hide();
$('#update_delete_row').hide();
// Filter save mode selector // Filter save mode selector
$("[name='filter_mode']").click(function() { $("[name='filter_mode']").click(function() {
if ($(this).val() == 'new') { if ($(this).val() == 'new') {
$('#save_filter_row2').hide(); $('#save_filter_row2').hide();
$('#submit-save_filter').show(); $('#submit-save_filter').show();
$('#update_filter_row').hide(); $('#update_filter_row').hide();
$('#update_delete_row').hide();
} }
else { else {
$('#save_filter_row2').show(); $('#save_filter_row2').show();
$('#update_filter_row').show(); $('#update_filter_row').show();
$('#submit-save_filter').hide(); $('#submit-save_filter').hide();
$('#update_delete_row').show();
} }
}); });
$("#save-filter-select").dialog({ $("#save-filter-select").dialog({
@ -2221,6 +2262,69 @@ if (check_login()) {
return false; 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() { $(document).ready(function() {
show_save_filter(); 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 * Pandora build version and version
*/ */
$build_version = 'PC230302'; $build_version = 'PC230303';
$pandora_version = 'v7.0NG.769'; $pandora_version = 'v7.0NG.769';
// Do not overwrite default timezone set if defined. // 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. * Check nms license on api.
* *
* @return boolean * @return boolean.
*/ * */
function nms_check_api() function nms_check_api()
{ {
global $config; global $config;

View File

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

View File

@ -2412,14 +2412,17 @@ function events_create_event(
$source = get_product_name(); $source = get_product_name();
} }
// Get Timestamp.
$timestamp = time();
$values = [ $values = [
'id_agente' => $id_agent, 'id_agente' => $id_agent,
'id_usuario' => $id_user, 'id_usuario' => $id_user,
'id_grupo' => $id_group, 'id_grupo' => $id_group,
'estado' => $status, 'estado' => $status,
'timestamp' => date('Y-m-d H:i:s'), 'timestamp' => date('Y-m-d H:i:s', $timestamp),
'evento' => $event, 'evento' => $event,
'utimestamp' => time(), 'utimestamp' => $timestamp,
'event_type' => $event_type, 'event_type' => $event_type,
'id_agentmodule' => $id_agent_module, 'id_agentmodule' => $id_agent_module,
'id_alert_am' => $id_aam, '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" // Alias for "html_debug_print"
function html_debug($var, $file='', $oneline=false) 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({ tinyMCE.init({
selector: "#textarea_label", selector: "#textarea_label",
theme: "advanced", theme: "advanced",
convert_urls:false,
relative_urls:false,
content_css: "'.ui_get_full_url(false, false, false, false).'include/styles/pandora.css", content_css: "'.ui_get_full_url(false, false, false, false).'include/styles/pandora.css",
theme_advanced_font_sizes: theme_advanced_font_sizes:
"4pt=.visual_font_size_4pt, " + "4pt=.visual_font_size_4pt, " +

View File

@ -11481,3 +11481,18 @@ div[role="dialog"] {
font-size: 11pt; font-size: 11pt;
line-height: 28px; line-height: 28px;
} }
input[type="text"] + .inputbuton {
height: 38px;
border-end-start-radius: 0px;
border-start-start-radius: 0px;
width: 40px;
min-width: 40px;
padding-left: 7px;
}
input[type="text"]:has(+ .inputbuton) {
border-end-end-radius: 0px;
border-start-end-radius: 0px;
border-right: 0px;
}

View File

@ -131,7 +131,7 @@
<div style='padding-bottom: 50px'> <div style='padding-bottom: 50px'>
<?php <?php
$version = '7.0NG.769'; $version = '7.0NG.769';
$build = '230302'; $build = '230303';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); 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_users.php';
require_once $config['homedir'].'/include/functions_modules.php'; require_once $config['homedir'].'/include/functions_modules.php';
enterprise_include_once('include/functions_config_agents.php'); enterprise_include_once('include/functions_config_agents.php');
enterprise_include_once('include/functions_policies.php');
ui_require_css_file('tables'); ui_require_css_file('tables');
@ -149,6 +150,9 @@ $offset = (int) get_parameter('offset', 0);
$refr = get_parameter('refr', 0); $refr = get_parameter('refr', 0);
$recursion = get_parameter('recursion', 0); $recursion = get_parameter('recursion', 0);
$status = (int) get_parameter('status', -1); $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']); $strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$agent_a = (bool) check_acl($config['id_user'], 0, 'AR'); $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 = []; $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) { if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
// Prepare the tab system to the future. // Prepare the tab system to the future.
$tab = 'setup'; $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_table($table, true);
$searchForm .= html_print_div( $searchForm .= html_print_div(
[ [
@ -367,6 +529,8 @@ $selectLastContactUp = false;
$selectLastContactDown = false; $selectLastContactDown = false;
$selectRemoteUp = false; $selectRemoteUp = false;
$selectRemoteDown = false; $selectRemoteDown = false;
$selectLastStatusChangeUp = false;
$selectLastStatusChangeDown = false;
$order = null; $order = null;
switch ($sortField) { switch ($sortField) {
@ -526,6 +690,32 @@ switch ($sortField) {
} }
break; 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': case 'description':
switch ($sort) { switch ($sort) {
case 'up': case 'up':
@ -565,6 +755,8 @@ switch ($sortField) {
$selectDescriptionDown = false; $selectDescriptionDown = false;
$selectLastContactUp = false; $selectLastContactUp = false;
$selectLastContactDown = false; $selectLastContactDown = false;
$selectLastStatusChangeUp = false;
$selectLastStatusChangeDown = false;
$order = [ $order = [
'field' => 'alias', 'field' => 'alias',
'field2' => 'alias', 'field2' => 'alias',
@ -624,6 +816,24 @@ if (empty($search_custom) === false) {
$search_sql_custom = ''; $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. // Show only selected groups.
if ($group_id > 0) { if ($group_id > 0) {
$groups = [$group_id]; $groups = [$group_id];
@ -636,6 +846,18 @@ if ($group_id > 0) {
$groups = array_keys($user_groups); $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) { if ($strict_user) {
$count_filter = [ $count_filter = [
@ -644,6 +866,9 @@ if ($strict_user) {
'disabled' => 0, 'disabled' => 0,
'status' => $status, 'status' => $status,
'search' => $search, 'search' => $search,
'id_os' => $id_os_sql,
'policies' => $policies_sql,
'other_condition' => $sql_conditions_custom_fields,
]; ];
$filter = [ $filter = [
// 'order' => 'tagente.nombre ASC', // 'order' => 'tagente.nombre ASC',
@ -653,6 +878,9 @@ if ($strict_user) {
'search' => $search, 'search' => $search,
'offset' => (int) get_parameter('offset'), 'offset' => (int) get_parameter('offset'),
'limit' => (int) $config['block_size'], 'limit' => (int) $config['block_size'],
'id_os' => $id_os_sql,
'policies' => $policies_sql,
'other_condition' => $sql_conditions_custom_fields,
]; ];
if ($group_id > 0) { if ($group_id > 0) {
@ -691,19 +919,18 @@ if ($strict_user) {
$agents = tags_get_all_user_agents(false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true); $agents = tags_get_all_user_agents(false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
} else { } else {
$total_agents = agents_count_agents_filter( $count_filter = [
[
'disabled' => 0, 'disabled' => 0,
'id_grupo' => $groups, 'id_grupo' => $groups,
'search' => $search_sql, 'search' => $search_sql,
'search_custom' => $search_sql_custom, 'search_custom' => $search_sql_custom,
'status' => $status, 'status' => $status,
], 'id_os' => $id_os_sql,
$access 'policies' => $policies_sql,
); 'other_condition' => $sql_conditions_custom_fields,
];
$agents = agents_get_agents( $filter = [
[
'order' => 'nombre ASC', 'order' => 'nombre ASC',
'id_grupo' => $groups, 'id_grupo' => $groups,
'disabled' => 0, 'disabled' => 0,
@ -712,7 +939,28 @@ if ($strict_user) {
'search' => $search_sql, 'search' => $search_sql,
'offset' => (int) get_parameter('offset'), 'offset' => (int) get_parameter('offset'),
'limit' => (int) $config['block_size'], '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(
$count_filter,
$access
);
$query_order = $order;
if ($order['field'] === 'last_status_change') {
$query_order = [
'field' => 'alias',
'field2' => 'alias',
'order' => 'ASC',
];
}
$agents = agents_get_agents(
$filter,
[ [
'id_agente', 'id_agente',
'id_grupo', 'id_grupo',
@ -735,7 +983,7 @@ if ($strict_user) {
'agent_version', 'agent_version',
], ],
$access, $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_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_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_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. // Show data.
$tableAgents = new stdClass(); $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->head[9] .= ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastContactUp, $selectLastContactDown);
$tableAgents->size[9] = '15%'; $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 = [];
$tableAgents->align[2] = 'left'; $tableAgents->align[2] = 'left';
@ -828,6 +1091,8 @@ $tableAgents->align[6] = 'left';
$tableAgents->align[7] = 'left'; $tableAgents->align[7] = 'left';
$tableAgents->align[8] = 'left'; $tableAgents->align[8] = 'left';
$tableAgents->align[9] = 'left'; $tableAgents->align[9] = 'left';
$tableAgents->align[10] = 'left';
$tableAgents->align[11] = 'left';
$tableAgents->style = []; $tableAgents->style = [];
$tableAgents->data = []; $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[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()) { if (enterprise_installed()) {
enterprise_include_once('include/functions_config_agents.php'); enterprise_include_once('include/functions_config_agents.php');
@ -993,6 +1258,27 @@ foreach ($agents as $agent) {
$data[9] = agents_get_interval_status($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 !! // This old code was returning "never" on agents without modules, BAD !!
// And does not print outdated agents in red. WRONG !!!! // And does not print outdated agents in red. WRONG !!!!
// $data[7] = ui_print_timestamp ($agent_info["last_contact"], true); // $data[7] = ui_print_timestamp ($agent_info["last_contact"], true);
@ -1000,6 +1286,20 @@ foreach ($agents as $agent) {
} }
if (empty($tableAgents->data) === false) { 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); html_print_table($tableAgents);
$tablePagination = ui_pagination( $tablePagination = ui_pagination(
@ -1046,10 +1346,68 @@ if ((bool) check_acl($config['id_user'], 0, 'AW') === true || (bool) check_acl($
echo '</form>'; 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"> <script type="text/javascript">
$(document).ready (function () { $(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 () { $("[class^='left']").mouseenter (function () {
$(".agent"+$(this)[0].className).css('visibility', ''); $(".agent"+$(this)[0].className).css('visibility', '');
}).mouseleave(function () { }).mouseleave(function () {

View File

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

View File

@ -227,7 +227,7 @@ if ($load_filter_id > 0) {
$user_groups_fl = users_get_groups( $user_groups_fl = users_get_groups(
$config['id_user'], $config['id_user'],
'AR', 'AR',
users_can_manage_group_all(), users_can_manage_group_all('AR'),
true true
); );
@ -287,6 +287,8 @@ if ($loaded_filter['id_filter'] > 0) {
} }
} }
$all_groups = [];
// Agent group selector. // Agent group selector.
if (is_metaconsole() === false) { if (is_metaconsole() === false) {
if ($ag_group > 0 && check_acl($config['id_user'], $ag_group, 'AR')) { if ($ag_group > 0 && check_acl($config['id_user'], $ag_group, 'AR')) {
@ -996,7 +998,7 @@ $buttons .= html_print_button(
); );
$buttons .= html_print_button( $buttons .= html_print_button(
__('Save filter'), __('Manage filter'),
'save-filter', 'save-filter',
false, 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_modules.php';
require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_users.php';
enterprise_include_once('include/functions_metaconsole.php'); enterprise_include_once('include/functions_metaconsole.php');
enterprise_include_once('include/functions_omnishell.php');
ui_require_javascript_file('openlayers.pandora'); ui_require_javascript_file('openlayers.pandora');
ui_require_css_file('agent_view'); ui_require_css_file('agent_view');
@ -1478,6 +1479,17 @@ if ($policyTab === ENTERPRISE_NOT_HOOK) {
$policyTab = ''; $policyTab = '';
} }
// Omnishell.
$tasks = count_tasks_agent($id_agente);
if ($tasks === true) {
$omnishellTab = enterprise_hook('omnishell_tab');
if ($omnishellTab == -1) {
$omnishellTab = '';
}
}
// WUX Console. // WUX Console.
$modules_wux = enterprise_hook('get_wux_modules', [$id_agente]); $modules_wux = enterprise_hook('get_wux_modules', [$id_agente]);
if ((bool) $modules_wux === true) { if ((bool) $modules_wux === true) {
@ -1722,6 +1734,7 @@ $onheader = [
'ncm_view' => ($ncm_tab ?? null), 'ncm_view' => ($ncm_tab ?? null),
'external_tools' => ($external_tools ?? null), 'external_tools' => ($external_tools ?? null),
'incident' => ($incidenttab ?? null), 'incident' => ($incidenttab ?? null),
'omnishell' => ($omnishellTab ?? null),
]; ];
@ -1846,6 +1859,10 @@ switch ($tab) {
$tab_name = __('Policies'); $tab_name = __('Policies');
break; break;
case 'omnishell':
$tab_name = 'Omnishell';
break;
case 'ux_console_tab': case 'ux_console_tab':
$tab_name = __('UX Console'); $tab_name = __('UX Console');
break; break;
@ -1986,6 +2003,10 @@ switch ($tab) {
enterprise_include('operation/agentes/policy_view.php'); enterprise_include('operation/agentes/policy_view.php');
break; break;
case 'omnishell':
enterprise_include('operation/agentes/omnishell_view.php');
break;
case 'ux_console_tab': case 'ux_console_tab':
enterprise_include('operation/agentes/ux_console_view.php'); enterprise_include('operation/agentes/ux_console_view.php');
break; break;

View File

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

View File

@ -60,7 +60,7 @@ ob_start();
echo '<html>'; echo '<html>';
echo '<head>'; echo '<head>';
echo '<title>'.__('Sound Events').'</title>'; echo '<title>'.__('Accoustic console').'</title>';
ui_require_css_file('wizard'); ui_require_css_file('wizard');
ui_require_css_file('discovery'); ui_require_css_file('discovery');
?> ?>
@ -161,7 +161,7 @@ if ($config['style'] === 'pandora_black' && !is_metaconsole()) {
echo '</head>'; echo '</head>';
echo "<body class='sound_events'>"; echo "<body class='sound_events'>";
echo "<h1 class='modalheaderh1'>".__('Sound console').'</h1>'; echo "<h1 class='modalheaderh1'>".__('Accoustic console').'</h1>';
// Connection lost alert. // Connection lost alert.
ui_require_css_file('register', 'include/styles/', true); ui_require_css_file('register', 'include/styles/', true);
@ -252,6 +252,11 @@ $sounds = [
'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation', '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[] = [ $inputs[] = [
'label' => \__('Sounds'), 'label' => \__('Sounds'),
'class' => 'flex-row', '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'; $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( $data_sound = base64_encode(
json_encode( json_encode(
[ [
'title' => __('Sound Console'), 'title' => __('Accoustic console'),
'start' => __('Start'), 'start' => __('Start'),
'stop' => __('Stop'), 'stop' => __('Stop'),
'noAlert' => __('No alert'), 'noAlert' => __('No alert'),
@ -594,8 +594,8 @@ if ($access_console_node === true) {
); );
$javascript = 'javascript: openSoundEventModal(`'.$data_sound.'`);'; $javascript = 'javascript: openSoundEventModal(`'.$data_sound.'`);';
$sub[$javascript]['text'] = __('Sound Events'); $sub[$javascript]['text'] = __('Accoustic console');
$sub[$javascript]['id'] = 'Sound Events Modal'; $sub[$javascript]['id'] = 'Accoustic console Modal';
$sub[$javascript]['type'] = 'direct'; $sub[$javascript]['type'] = 'direct';
echo '<div id="modal-sound" style="display:none;"></div>'; echo '<div id="modal-sound" style="display:none;"></div>';
@ -750,7 +750,6 @@ if ($access_console_node === true) {
} }
} }
if (!empty($sub)) { if (!empty($sub)) {
$menu_operation['extensions']['text'] = __('Tools'); $menu_operation['extensions']['text'] = __('Tools');
$menu_operation['extensions']['sec2'] = 'operation/extensions'; $menu_operation['extensions']['sec2'] = 'operation/extensions';

View File

@ -423,8 +423,7 @@ if ($view_graph) {
); );
if ($graph_return) { if ($graph_return) {
echo "<table id='graph-container' class='databox filters' cellpadding='0' cellspacing='0' style='height:100%;width:100%;overflow:hidden;'>"; echo '<div style="background-color: white;height: 700px;overflow-y: auto;padding-top:20px;">';
echo '<tr><td>';
if (!is_ajax()) { if (!is_ajax()) {
echo '<div id="spinner_loading" class="loading invisible" style="display:flex;flex-direction:column-reverse;justify-content:center;align-items:center">'; echo '<div id="spinner_loading" class="loading invisible" style="display:flex;flex-direction:column-reverse;justify-content:center;align-items:center">';
echo html_print_image('images/spinner.gif', true, ['width' => '20px']); echo html_print_image('images/spinner.gif', true, ['width' => '20px']);
@ -442,7 +441,7 @@ if ($view_graph) {
echo '</div>'; echo '</div>';
echo '</td></tr></table>'; echo '</div>';
} else { } else {
ui_print_info_message([ 'no_close' => true, 'message' => __('No data.') ]); ui_print_info_message([ 'no_close' => true, 'message' => __('No data.') ]);
} }

View File

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

View File

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

View File

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

View File

@ -4179,3 +4179,30 @@ CREATE TABLE IF NOT EXISTS `tmonitor_filter` (
`ag_custom_fields` TEXT, `ag_custom_fields` TEXT,
PRIMARY KEY (`id_filter`) PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ) 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 package: pandorafms-server
Version: 7.0NG.769-230302 Version: 7.0NG.769-230303
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.769-230302" pandora_version="7.0NG.769-230303"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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