Merge branch 'develop' into ent-12745-falta-un-campo-en-la-tabla-tncm_agent_data

This commit is contained in:
Jonathan 2024-01-19 13:15:01 +01:00
commit 30e0ed912a
107 changed files with 2761 additions and 656 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.775-240117
Version: 7.0NG.775-240119
Architecture: all
Priority: optional
Section: admin

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.775
%define release 240117
%define release 240119
%define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.775
%define release 240117
%define release 240119
%define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.775
%define release 240117
%define release 240119
Summary: Pandora FMS Linux agent, binary version
Name: %{name}

View File

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

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.775"
PI_BUILD="240117"
PI_BUILD="240119"
OS_NAME=`uname -s`
FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{240117}
{240119}
ViewReadme
{Yes}

View File

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

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Pandora FMS"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.775(Build 240117))"
VALUE "ProductVersion", "(7.0NG.775(Build 240119))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.775-240117
Version: 7.0NG.775-240119
Architecture: all
Priority: optional
Section: admin

View File

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

View File

@ -3,4 +3,6 @@ START TRANSACTION;
ALTER TABLE `tncm_agent_data`
ADD COLUMN `id_agent_data` int not null default 0 AFTER `script_type`;
ALTER TABLE `tusuario` CHANGE COLUMN `metaconsole_data_section` `metaconsole_data_section` TEXT NOT NULL DEFAULT '' ;
COMMIT;

View File

@ -397,21 +397,23 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
$modal_box .= '<a href="https://discord.com/invite/xVt2ruSxmr" target="_blank">'.__('Join discord community').'</a>';
$modal_box .= '</div>';
$modal_help = html_print_div(
[
'id' => 'modal-help-content',
'content' => html_print_image(
'images/help@header.svg',
true,
[
'title' => __('Help'),
'class' => 'main_menu_icon bot invert_filter',
'alt' => 'user',
]
).$modal_box,
],
true,
);
if ($config['activate_feedback'] === '1') {
$modal_help = html_print_div(
[
'id' => 'modal-help-content',
'content' => html_print_image(
'images/help@header.svg',
true,
[
'title' => __('Help'),
'class' => 'main_menu_icon bot invert_filter',
'alt' => 'user',
]
).$modal_box,
],
true,
);
}
// User.

View File

@ -399,12 +399,12 @@ if ($new_agent === true) {
// Ip adress.
$tableAgent->data['caption_ip_address'] = __('IP Address');
$tableAgent->rowclass['ip_address'] = 'w540px';
$tableAgent->rowclass['ip_address'] = 'w400px';
$tableAgent->data['ip_address'][0] = html_print_input_text('direccion', $direccion_agente, '', 16, 100, true, false, false, '', 'w540px');
$tableAgent->data['ip_address'][1] = html_print_button(__('Check unique IP'), 'check_unique_ip', false, '', ['class' => 'secondary w130px'], true);
$tableAgent->data['message_check_ip'][0] = html_print_div(['id' => 'message_check_ip'], true);
$tableAgent->rowclass['additional_ip_address'] = 'subinput';
$tableAgent->data['additional_ip_address'][0] = html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true);
$tableAgent->data['additional_ip_address'][1] = __('Unique IP');
$tableAgent->cellclass['additional_ip_address'][1] = 'w120px';
$tableAgent->data['additional_ip_address'][2] = html_print_input(
[
@ -1130,17 +1130,12 @@ foreach ($fields as $field) {
}
if ((bool) $field['is_password_type'] === true) {
$customContent = html_print_input_text_extended(
$customContent = html_print_input_password(
'customvalue_'.$field['id_field'],
$custom_value,
'customvalue_'.$field['id_field'],
'',
30,
100,
$view_mode,
'',
'',
true,
45,
255,
true
);
} else if ($field['is_link_enabled']) {
@ -1301,6 +1296,7 @@ ui_require_jquery_file('bgiframe');
?>
<script type="text/javascript">
let unique_ip_trigger = false;
// Show/Hide custom field row.
function show_custom_field_row(id){
if( $('#field-'+id).css('display') == 'none'){
@ -1464,23 +1460,40 @@ ui_require_jquery_file('bgiframe');
$("#text-agente").prop('readonly', true);
// Disable fixed ip button if empty.
if($("#text-direccion").val() == '') {
$("#fixed_ip").prop('disabled',true);
}
$("#text-direccion").on('input',function(e){
if($("#text-direccion").val() == '') {
$("#fixed_ip").prop('disabled',true);
} else {
$("#fixed_ip").prop('disabled',false);
$("#text-direccion").on('change',function(e){
const unique_ip_token = '<?php echo $config['unique_ip']; ?>';
unique_ip_trigger = false;
if (unique_ip_token == 1) {
check_unique_ip();
}
});
check_basic_options();
$('#id_os').on('change', function(){
check_basic_options();
})
});
$('#button-check_unique_ip').on('click', function() {
check_unique_ip();
});
$('#form_agent').on('submit', function(e) {
if (unique_ip_trigger) {
e.preventDefault();
const form = this;
confirmDialog(
{
title: '<?php echo __('Are you sure?'); ?>',
message: '<?php echo __('This IP address is in use. Are you sure you want to save it?'); ?>',
ok: '<?php echo __('Yes'); ?>',
cancel: '<?php echo __('Cancel'); ?>',
onAccept: function() {
form.submit();
}
}
);
}
});
});
function check_basic_options(){
@ -1490,4 +1503,40 @@ ui_require_jquery_file('bgiframe');
$('#basic_options').addClass('invisible');
}
}
function check_unique_ip() {
const direccion = $('#text-direccion').val();
let ip_all = <?php echo json_encode($ip_all); ?>;
if (ip_all) {
ip_all = Object.keys(ip_all);
}
$.ajax({
method: "POST",
url: "<?php echo ui_get_full_url('ajax.php'); ?>",
dataType: 'json',
data: {
page: "include/ajax/agent",
check_unique_ip: 1,
direccion,
ip_all
},
success: function(data) {
if (data.success) {
$('#message_check_ip').attr('class', 'success');
} else {
$('#message_check_ip').attr('class', 'error');
}
if(data.exist_ip) {
unique_ip_trigger = true;
} else {
unique_ip_trigger = false;
}
$('#message_check_ip').html(data.message);
}
});
}
</script>

View File

@ -102,7 +102,6 @@ $alias_as_name = 0;
$direccion_agente = get_parameter('direccion', '');
$direccion_agente = trim(io_safe_output($direccion_agente));
$direccion_agente = io_safe_input($direccion_agente);
$unique_ip = 0;
$intervalo = SECONDS_5MINUTES;
$ff_interval = 0;
$quiet_module = 0;
@ -186,7 +185,6 @@ if ($create_agent) {
$alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output)));
$alias_as_name = (int) get_parameter_post('alias_as_name', 0);
$direccion_agente = (string) get_parameter_post('direccion', '');
$unique_ip = (int) get_parameter_post('unique_ip', 0);
// Safe_output only validate ip.
$direccion_agente = trim(io_safe_output($direccion_agente));
@ -269,12 +267,7 @@ if ($create_agent) {
$nombre_agente = $alias;
}
if ($unique_ip && $direccion_agente != '') {
$sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"';
$exists_ip = db_get_row_sql($sql);
}
if (!$exists_alias && !$exists_ip) {
if (!$exists_alias) {
$id_agente = db_process_sql_insert(
'tagente',
[
@ -371,8 +364,6 @@ if ($create_agent) {
$agent_creation_error = __('Could not be created');
if ($exists_alias) {
$agent_creation_error = __('Could not be created, because name already exists');
} else if ($exists_ip) {
$agent_creation_error = __('Could not be created, because IP already exists');
}
}
}
@ -962,7 +953,6 @@ if ($update_agent) {
$alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output)));
$alias_as_name = (int) get_parameter_post('alias_as_name', 0);
$direccion_agente = (string) get_parameter_post('direccion', '');
$unique_ip = (int) get_parameter_post('unique_ip', 0);
// Safe_output only validate ip.
$direccion_agente = trim(io_safe_output($direccion_agente));
@ -1097,18 +1087,11 @@ if ($update_agent) {
// If there is an agent with the same name, but a different ID.
}
if ($direccion_agente !== $address_list && (bool) $unique_ip === true && $direccion_agente != '') {
$sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"';
$exists_ip = db_get_row_sql($sql);
}
$old_group = agents_get_agent_group($id_agente);
if ($grupo <= 0) {
ui_print_error_message(__('The group id %d is incorrect.', $grupo));
} else if ($old_group !== $grupo && group_allow_more_agents($grupo, true, 'update') === false) {
ui_print_error_message(__('Agent cannot be updated due to the maximum agent limit for this group'));
} else if ($exists_ip) {
ui_print_error_message(__('Duplicate main IP address'));
} else {
// If different IP is specified than previous, add the IP.
if ($direccion_agente != ''

View File

@ -275,21 +275,27 @@ $(document).ready (function () {
$('#configure_field-3').show();
dialog_message("#message_no_set_password");
$('#configure_field-1').hide();
$('#configure_field-2-0').hide();
}
else{
$('#configure_field-3').hide();
$('#configure_field-1').show();
$('#configure_field-2-0').show();
}
});
$('input[type=checkbox][name=is_password_type]').change(function () {
if( $('input[type=checkbox][name=is_password_type]').prop('checked')){
$('#configure_field-1').hide();
dialog_message("#message_no_set_combo");
$('#configure_field-3').hide();
$('#configure_field-2-1').hide();
}
else{
if($('input[type=checkbox][name=is_combo_enable]').prop('checked') === true) {
$('#configure_field-3').show();
}
$('#configure_field-1').show();
$('#configure_field-2-1').show();
}
});
});

View File

@ -1131,13 +1131,13 @@ if (isset($id_agente) === true && (int) $moduletype === MODULE_DATA) {
$tableCron->data['cron_to_select'][0] = html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, $disabledBecauseInPolicy, true);
}
$table_advanced->rowclass['cron_section'] = 'table_section full_section';
$table_advanced->rowclass['cron_section'] = 'table_section full_section mrgn_top_mod_0px';
$table_advanced->data['cron_section'] = html_print_table($tableCron, true);
$table_advanced->data['title_3'] = html_print_subtitle_table(__('Thresholds and state changes'));
$table_advanced->rowclass['caption_min_max_values'] = 'w50p pdd_t_10px';
$table_advanced->rowclass['min_max_values'] = 'w50p';
$table_advanced->rowclass['min_max_values'] = 'w50p pdd_b_10px';
$table_advanced->data['caption_min_max_values'][0] = __('Min. Value');
$table_advanced->data['caption_min_max_values'][1] = __('Max. Value');
@ -1214,7 +1214,7 @@ $tableDynamicThreshold->data['adv_dynamic_threshold_twotailed'][0] = html_print_
$disabledBecauseInPolicy
);
$table_advanced->rowclass['dynamic_threshold_table'] = 'table_section full_section';
$table_advanced->rowclass['dynamic_threshold_table'] = 'table_section full_section mrgn_top_mod_0px';
$table_advanced->data['dynamic_threshold_table'] = html_print_table($tableDynamicThreshold, true);
$tableFFThreshold = new stdClass();
@ -1304,10 +1304,15 @@ $tableFFThreshold->data['ff_thresholds_each'][2] = html_print_input_text(
$classdisabledBecauseInPolicy
);
$table_advanced->rowclass['gap_flipflop'] = 'mrgn_top_btn_10px_imp';
$table_advanced->data['gap_flipflop'] = html_print_input_hidden('gap_flipflop', 0);
$table_advanced->rowclass['flipflop_thresholds_table'] = 'table_section full_section';
$table_advanced->rowclass['flipflop_thresholds_table'] = 'table_section full_section mrgn_top_mod_0px';
$table_advanced->data['flipflop_thresholds_table'] = html_print_table($tableFFThreshold, true);
$table_advanced->rowclass['gap_ff'] = 'mrgn_top_btn_10px_imp';
$table_advanced->data['gap_ff'] = html_print_input_hidden('gap_ff', 0);
$table_advanced->rowclass['caption_ff_interval_timeout'] = 'w50p';
$table_advanced->rowclass['ff_interval_timeout'] = 'w50p';
$table_advanced->cellclass['caption_ff_interval_timeout'][0] = 'w50p';

View File

@ -497,7 +497,12 @@ foreach ($actions as $action) {
$pagination = '';
if (isset($data)) {
html_print_table($table);
$pagination = ui_pagination($total_actions, $url, 0, 0, true, 'offset', false, '');
$show_count = false;
if (is_metaconsole() === true) {
$show_count = true;
}
$pagination = ui_pagination($total_actions, $url, 0, 0, true, 'offset', $show_count, '');
} else {
ui_print_info_message(['no_close' => true, 'message' => __('No alert actions configured') ]);
}

View File

@ -1080,7 +1080,12 @@ foreach ($commands as $command) {
if (isset($data) === true && count($table->data) > 0) {
html_print_table($table);
$pagination = ui_pagination($total_commands, $url, 0, 0, true, 'offset', false, '');
$show_count = false;
if (is_metaconsole() === true) {
$show_count = true;
}
$pagination = ui_pagination($total_commands, $url, 0, 0, true, 'offset', $show_count, '');
} else {
ui_print_info_message(
[

View File

@ -493,6 +493,11 @@ foreach ($templates as $template) {
$pagination = '';
if (isset($data) === true) {
$show_count = false;
if (is_metaconsole() === true) {
$show_count = true;
}
html_print_table($table);
$pagination = ui_pagination(
$total_templates,
@ -501,7 +506,7 @@ if (isset($data) === true) {
0,
true,
'offset',
false,
$show_count,
''
);
} else {

View File

@ -88,7 +88,17 @@ if ($multiple_delete) {
['id_filter' => $id]
);
if ($result === false) {
if ($result !== false) {
db_process_sql_delete(
'tfavmenu_user',
[
'id_element' => $id,
'section' => 'Events',
'id_user' => $config['id_user'],
]
);
$result = true;
} else {
break;
}
}
@ -210,7 +220,7 @@ foreach ($filters as $filter) {
true,
[
'title' => __('Delete'),
'class' => 'invert_filter',
'class' => 'invert_filter main_menu_icon',
]
).'</a>';
}

View File

@ -1529,7 +1529,7 @@ $array_os = [
'windows' => __('Windows'),
];
$table->data[40][0] = html_print_label_input_block(
__('rget OS'),
__('Target OS'),
html_print_select(
$array_os,
'custom_string_2',

View File

@ -770,11 +770,14 @@ $("#conf_wizard").click(function() {
modal: {
title: "<?php echo __('Welcome to').' '.io_safe_output(get_product_name()); ?>",
cancel: '<?php echo __('Do not show anymore'); ?>',
ok: '<?php echo __('Close'); ?>'
ok: '<?php echo __('Close wizard'); ?>',
overlay: true,
overlayExtraClass: 'welcome-overlay',
},
onshow: {
page: 'include/ajax/welcome_window',
method: 'loadWelcomeWindow',
width: 1000,
},
oncancel: {
page: 'include/ajax/welcome_window',
@ -792,6 +795,34 @@ $("#conf_wizard").click(function() {
}
})
}
},
onload: () => {
$(document).ready(function () {
var buttonpane = $("div[aria-describedby='welcome_modal_window'] .ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix");
$(buttonpane).append(`
<div class="welcome-wizard-buttons">
<label>
<input type="checkbox" class="welcome-wizard-do-not-show" value="1" />
<?php echo __('Do not show anymore'); ?>
</label>
<button class="close-wizard-button"><?php echo __('Close wizard'); ?></button>
</div>
`);
var closeWizard = $("button.close-wizard-button");
$(closeWizard).click(function (e) {
var close = $("div[aria-describedby='welcome_modal_window'] button.sub.ok.submit-next.ui-button");
var cancel = $("div[aria-describedby='welcome_modal_window'] button.sub.upd.submit-cancel.ui-button");
var checkbox = $("div[aria-describedby='welcome_modal_window'] .welcome-wizard-do-not-show:checked").length;
if (checkbox === 1) {
$(cancel).click();
} else {
$(close).click()
}
});
});
}
});
});

View File

@ -394,11 +394,11 @@ html_print_action_buttons(
$('[id^=checkbox-all_delete]').change(function(){
if ($("#checkbox-all_delete").prop("checked")) {
$('[id^=checkbox-delete_multiple]').parent().parent().addClass('checkselected');
$(".check_delete").prop("checked", true);
$(".custom_checkbox_input").prop("checked", true);
}
else{
$('[id^=checkbox-delete_multiple]').parent().parent().removeClass('checkselected');
$(".check_delete").prop("checked", false);
$(".custom_checkbox_input").prop("checked", false);
}
});
});

View File

@ -30,7 +30,7 @@ if (!$report_w && !$report_m) {
require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_groups.php';
ui_require_css_file('custom_graph');
$editGraph = (bool) get_parameter('edit_graph', 0);
$action = get_parameter('action', '');
@ -41,113 +41,6 @@ if (isset($_GET['get_agent'])) {
}
}
switch ($action) {
case 'sort_items':
$resultOperationDB = null;
$position_to_sort = (int) get_parameter('position_to_sort', 1);
$ids_serialize = (string) get_parameter('ids_items_to_sort', '');
$move_to = (string) get_parameter('move_to', 'after');
$countItems = db_get_sql(
'
SELECT COUNT(id_gs)
FROM tgraph_source
WHERE id_graph = '.$id_graph
);
if (($countItems < $position_to_sort) || ($position_to_sort < 1)) {
$resultOperationDB = false;
} else if (!empty($ids_serialize)) {
$ids = explode('|', $ids_serialize);
$items = db_get_all_rows_sql(
'SELECT id_gs, `field_order`
FROM tgraph_source
WHERE id_graph = '.$id_graph.'
ORDER BY `field_order`'
);
if ($items === false) {
$items = [];
}
// Clean the repeated order values.
$order_temp = 1;
foreach ($items as $item) {
db_process_sql_update(
'tgraph_source',
['`field_order`' => $order_temp],
['id_gs' => $item['id_rc']]
);
$order_temp++;
}
$items = db_get_all_rows_sql(
'SELECT id_gs, `field_order`
FROM tgraph_source
WHERE id_graph = '.$id_graph.'
ORDER BY `field_order`'
);
if ($items === false) {
$items = [];
}
$temp = [];
$temp = [];
foreach ($items as $item) {
// Remove the contents from the block to sort.
if (array_search($item['id_gs'], $ids) === false) {
$temp[$item['field_order']] = $item['id_gs'];
}
}
$items = $temp;
$sorted_items = [];
foreach ($items as $pos => $id_unsort) {
if ($pos == $position_to_sort) {
if ($move_to == 'after') {
$sorted_items[] = $id_unsort;
}
foreach ($ids as $id) {
$sorted_items[] = $id;
}
if ($move_to != 'after') {
$sorted_items[] = $id_unsort;
}
} else {
$sorted_items[] = $id_unsort;
}
}
$items = $sorted_items;
foreach ($items as $order => $id) {
db_process_sql_update(
'tgraph_source',
['`field_order`' => ($order + 1)],
['id_gs' => $id]
);
}
$resultOperationDB = true;
} else {
$resultOperationDB = false;
}
break;
}
if ($editGraph) {
$graphRows = db_get_all_rows_sql(
'SELECT t1.*,
@ -257,41 +150,6 @@ $table->data[0][1] = html_print_label_input_block(
);
$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,
'<span class="subsection_header_title">'.__('Sort items').'</span>',
'',
'',
false,
false,
'',
'white-box-content no_border',
'filter-datatable-main box-flat white_table_graph max_floating_element_size'
);
// Configuration form.
echo '<span id ="none_text" class="invisible">'.__('None').'</span>';
echo "<form id='agentmodules' method='post' action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&tab=graph_editor&add_module=1&edit_graph=1&id=".$id_graph."'>";
@ -300,10 +158,11 @@ echo "<table width='100%' cellpadding='4' cellpadding='4' class='databox filters
echo '<tr>';
echo '<td class="w50p pdd_50px" id="select_multiple_modules_filtered">'.html_print_input(
[
'type' => 'select_multiple_modules_filtered',
'uniqId' => 'modules',
'class' => 'flex flex-row',
'searchBar' => true,
'type' => 'select_multiple_modules_filtered',
'uniqId' => 'modules',
'class' => 'flex flex-row',
'searchBar' => false,
'placeholderAgents' => __('Search agent name'),
]
).'</td>';
echo '</tr><tr>';
@ -340,6 +199,7 @@ echo '</form>';
// Modules table.
if ($count_module_array > 0) {
echo "<table width='100%' cellpadding=4 cellpadding=4 class='databox filters info_table'>";
echo '<thead>';
echo '<tr>
<th>'.__('P.').'</th>
<th>'.__('Agent').'</th>
@ -348,6 +208,8 @@ if ($count_module_array > 0) {
<th>'.__('Weight').'</th>
<th>'.__('Delete').'</th>
<th>'.__('Sort').'</th>';
echo '</thead>';
echo '<tbody>';
$color = 0;
for ($a = 0; $a < $count_module_array; $a++) {
// Calculate table line color.
@ -359,7 +221,7 @@ if ($count_module_array > 0) {
$color = 1;
}
echo "<tr><td class='$tdcolor'>$position_array[$a]</td>";
echo "<tr><td class='position $tdcolor'>$position_array[$a]</td>";
echo "<td class='$tdcolor'>".$agent_array[$a].'</td>';
echo "<td class='$tdcolor'>";
echo modules_get_agentmodule_name($module_array[$a]).'</td>';
@ -410,9 +272,30 @@ if ($count_module_array > 0) {
echo '</td>';
echo '<td>';
echo '<td style="display: grid;">';
echo html_print_checkbox_extended('sorted_items[]', $idgs_array[$a], false, false, '', 'class="selected_check"', true);
echo html_print_input_image(
'up',
'images/arrow-up-white.png',
'up',
($config['style'] !== 'pandora_black') ? 'filter: invert(100%)' : '',
true,
[
'class' => 'invert_filter main_menu_icon',
'onclick' => 'reorder(\'up\', \''.$idgs_array[$a].'\', this)',
],
);
echo html_print_input_image(
'down',
'images/arrow-down-white.png',
'down',
($config['style'] !== 'pandora_black') ? 'filter: invert(100%)' : '',
true,
[
'class' => 'invert_filter main_menu_icon',
'onclick' => 'reorder(\'down\', \''.$idgs_array[$a].'\', this)',
]
);
echo '</td>';
@ -420,6 +303,8 @@ if ($count_module_array > 0) {
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
}
@ -464,7 +349,7 @@ function added_ids_sorted_items_to_hidden_input() {
var ids = '';
var first = true;
$("input.selected_check:checked").each(function(i, val) {
$("input.custom_checkbox_input:checked").each(function(i, val) {
if (!first)
ids = ids + '|';
first = false;
@ -482,4 +367,65 @@ function added_ids_sorted_items_to_hidden_input() {
return true;
}
}
function reorder(action, idElement, element) {
var tr = $(element).parent().parent();
switch (action) {
case "up":
changePosition(action, idElement)
.then((data) => {
if(data.success) {
$(tr).find('.position').html(parseInt($(tr).find('.position').html()) - 1);
$($(tr).prev()).find('.position').html(parseInt($($(tr).prev()).find('.position').html()) + 1);
$(tr).prev().insertAfter(tr);
}
})
.catch((err) => {
console.log(err);
})
break;
case "down":
changePosition(action, idElement)
.then((data) => {
if(data.success) {
$(tr).find('.position').html(parseInt($(tr).find('.position').html()) + 1);
$($(tr).next()).find('.position').html(parseInt(($(tr).next()).find('.position').html()) - 1);
$(tr).next().insertBefore(tr);
}
})
.catch((err) => {
console.log(err);
})
break;
default:
break;
}
}
function changePosition(order, idElement) {
return new Promise(function(resolve, reject) {
$.ajax({
method: "POST",
url: "<?php echo ui_get_full_url('ajax.php'); ?>",
dataType: "json",
data: {
page: "include/ajax/graph.ajax",
sort_items: 1,
order,
id_graph: <?php echo $id_graph; ?>,
id: idElement
},
success: function(data) {
resolve(data);
},
error: function(error) {
reject(error);
}
});
});
}
</script>

View File

@ -247,7 +247,7 @@ if ($add_module === true) {
$id_agent_modules = db_get_all_rows_sql($sql);
if (count($id_agent_modules) > 0 && $id_agent_modules != '') {
if (is_array($id_agent_modules) === true && count($id_agent_modules) > 0 && $id_agent_modules != '') {
$sql_order = sprintf(
'SELECT `field_order`
FROM tgraph_source

View File

@ -1259,6 +1259,10 @@ switch ($action) {
$reports_table .= html_print_table($table, true);
$reports_table .= '<br></div>';
echo $reports_table;
$show_count = false;
if (is_metaconsole() === true) {
$show_count = true;
}
$tablePagination = ui_pagination(
$total_reports,
@ -1267,7 +1271,7 @@ switch ($action) {
$pagination,
true,
'offset',
false
$show_count
);
} else {
ui_print_info_message(

View File

@ -521,7 +521,7 @@ $(document).ready (function () {
function (data) {
$(".white-box-content").html(data);
$("#submit-add").click(function (e) {
$("#button-add").click(function (e) {
add_credential_boxes();
});
@ -550,7 +550,7 @@ $(document).ready (function () {
$(".white-box-content").html(data2);
// Insert credential
$("#submit-add").click(function (e) {
$("#button-add").click(function (e) {
save_credential_boxes();
})
},
@ -609,7 +609,7 @@ $(document).ready (function () {
function (data) {
$(".white-box-content").html(data);
$("#submit-update").click(function (e) {
$("#button-update").click(function (e) {
update_credential_boxes(datas);
});
},

View File

@ -559,7 +559,7 @@ $table_cr_settings->data[4][0] = html_print_label_input_block(
// Print.
echo '<div class="center pdd_b_10px mrgn_btn_20px white_box max_floating_element_size">';
echo '<a target="_blank" rel="noopener noreferrer" href="https://pandorafms.com/es/itsm/">';
echo '<a target="_blank" rel="noopener noreferrer" href="https://pandorafms.com/itsm/">';
html_print_image(
'images/pandoraITSM_logo.png',
false,
@ -570,8 +570,8 @@ echo '<br />';
echo '<div class="ITSM_title">';
echo __('Pandora ITSM');
echo '</div>';
echo '<a target="_blank" rel="noopener noreferrer" href="https://pandorafms.com/es/itsm/">';
echo 'https://pandorafms.com/es/itsm/';
echo '<a target="_blank" rel="noopener noreferrer" href="https://pandorafms.com/itsm/">';
echo 'https://pandorafms.com/itsm/';
echo '</a>';
echo '</div>';

View File

@ -527,9 +527,12 @@ $table->data[$i++][] = html_print_label_input_block(
true
)
);
$help_tip = ui_print_help_tip(
__('No events or alerts will be generated, but data will still be received.'),
true
);
$table->data[$i][] = html_print_label_input_block(
__('Event storm protection'),
__('Event storm protection').$help_tip,
html_print_checkbox_switch(
'event_storm_protection',
1,

View File

@ -424,10 +424,13 @@ if ($create_user === true) {
$values['data_section'] = $dashboard;
} else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) {
$values['data_section'] = $visual_console;
} else if ($values['section'] === HOME_SCREEN_OTHER) {
$values['data_section'] = get_parameter('data_section_other');
} else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) {
$values['data_section'] = get_parameter('data_section_external');
} else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) {
$values['data_section'] = get_parameter('data_section');
}
if (is_metaconsole() === true) {
$values['metaconsole_section'] = $values['section'];
$values['metaconsole_data_section'] = $values['data_section'];
}
// $values['section'] = $homeScreenValues[$values['section']];
@ -724,10 +727,8 @@ if ($update_user) {
$values['data_section'] = $dashboard;
} else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) {
$values['data_section'] = $visual_console;
} else if ($values['section'] === HOME_SCREEN_OTHER) {
$values['data_section'] = get_parameter('data_section_other');
} else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) {
$values['data_section'] = get_parameter('data_section_external');
} else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) {
$values['data_section'] = get_parameter('data_section');
}
// $values['section'] = $homeScreenValues[$values['section']];

View File

@ -689,7 +689,7 @@ foreach ($info as $user_id => $user_info) {
// User profiles.
if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) {
$user_profiles = db_get_all_rows_sql(
'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'" LIMIT 5'
'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'"'
);
} else {
$user_profiles_aux = users_get_user_profile($user_id, 'LIMIT 5');
@ -778,17 +778,25 @@ foreach ($info as $user_id => $user_info) {
if ($user_profiles !== false) {
$total_profile = 0;
$data[4] .= '<div class="text_end">';
$data[4] .= '<div class="flex-column-start">';
foreach ($user_profiles as $row) {
$total_profile++;
if ($total_profile > 5) {
$data[4] .= "<div class='invisible checkhide_".str_replace(' ', '_', io_safe_output($row['id_usuario']))."'>";
}
$data[4] .= "<div class='float-left'>";
$data[4] .= profile_get_name($row['id_perfil']);
$data[4] .= ' / </div>';
$data[4] .= "<div class='float-left pdd_l_5px'>";
$data[4] .= ' / ';
$data[4] .= groups_get_name($row['id_grupo'], true);
$data[4] .= '</div>';
if ($total_profile == 0 && count($user_profiles) >= 5) {
$data[4] .= '<span onclick="showGroups(`'.$row['id_usuario'].'`)">'.html_print_image(
if ($total_profile > 5) {
$data[4] .= '</div>';
}
if ($total_profile == 1 && count($user_profiles) > 5) {
$data[4] .= '<span class="show-profiles" onclick="showGroups(`'.str_replace(' ', '_', io_safe_output($row['id_usuario'])).'`)">'.html_print_image(
'images/zoom.png',
true,
[
@ -803,10 +811,6 @@ foreach ($info as $user_id => $user_info) {
true
);
}
$data[4] .= '<br/>';
$total_profile++;
}
if (isset($user_info['not_delete']) === true) {
@ -1023,8 +1027,13 @@ foreach ($info as $user_id => $user_info) {
array_push($table->data, $data);
}
$show_count = false;
if (is_metaconsole() === true) {
$show_count = true;
}
html_print_table($table);
$tablePagination = ui_pagination(count($info), false, 0, 0, true, 'offset', false, 'dataTables_paginate paging_simple_numbers');
$tablePagination = ui_pagination(count($info), false, 0, 0, true, 'offset', $show_count, 'dataTables_paginate paging_simple_numbers');
unset($table);
if ($is_management_allowed === true) {
if ($config['admin_can_add_user'] !== false) {
@ -1052,43 +1061,13 @@ if ($is_management_allowed === true) {
?>
<script type="text/javascript">
function showGroups(id_user) {
if ($(`#hidden-show_groups_${id_user}`).val() === '-1') {
var request = $.ajax({
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
type: 'GET',
dataType: 'json',
data: {
page: 'godmode/users/user_list',
get_user_profile_group: 1,
id_user: id_user
},
success: function (data, textStatus, xhr) {
let count = 1;
data.forEach( function(valor, indice, array) {
if (count >= 6) {
let main_div = $(`#profiles_${id_user}`);
main_div.append(
`<div id="left_${id_user}_${count}" class='float-left'>${valor.id_perfil} / </div>`,
`<div id="right_${id_user}_${count}" class='float-left pdd_l_5px'>${valor.id_grupo}</div>`,
`<br/><br/>`
);
}
count ++;
});
},
error: function (e, textStatus) {
console.error(textStatus);
}
});
$(`#hidden-show_groups_${id_user}`).val('1');
$(`#profiles_${id_user}`).show();
} else if ($(`#hidden-show_groups_${id_user}`).val() === '1') {
$(`#hidden-show_groups_${id_user}`).val('0');
$(`#profiles_${id_user}`).hide();
} else {
$(`#hidden-show_groups_${id_user}`).val('1');
$(`#profiles_${id_user}`).show();
}
$('.checkhide_'+id_user).each(function(){
if ($(this).hasClass('invisible') === true) {
$(this).removeClass('invisible');
} else {
$(this).addClass('invisible');
}
});
}
</script>

View File

@ -84,8 +84,7 @@ $customHomeScreenAddition[HOME_SCREEN_DASHBOARD] = html_print_select(
// Home screen. Visual consoles.
$customHomeScreenAddition[HOME_SCREEN_VISUAL_CONSOLE] = html_print_select($layouts_aux, 'visual_console', $user_info['data_section'], '', '', '', true, false, true, 'w100p', false, 'width: 100%');
// Home screen. External link and Other.
$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section_external', $user_info['data_section'], '', 60, 255, true);
$customHomeScreenAddition[HOME_SCREEN_OTHER] = html_print_input_text('data_section_other', $user_info['data_section'], '', 60, 255, true);
$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section', $user_info['data_section'], '', 60, 400, true);
$layouts = visual_map_get_user_layouts($config['id_user'], true);
$layouts_aux = [];
@ -118,7 +117,7 @@ $customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text(
$user_info['data_section'],
'',
60,
255,
999,
true
);
$customHomeScreenDataField = '';

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="12px" viewBox="0 0 16 12" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>F1630B1D-C694-489C-8C8F-E98AF57D4F04</title>
<g id="Welcome-wizard" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Pandora-FMS---Welcome-Wizard-2023---1a-Welcome-wizard" transform="translate(-905, -629)" fill="#FFFFFF">
<g id="Popup" transform="translate(460, 200)">
<g id="Content" transform="translate(20, 96)">
<g id="Form" transform="translate(0, 292)">
<g id="Principal-por-defecto" transform="translate(305, 26)">
<g id="Group-2" transform="translate(38, 11)">
<g id="check" transform="translate(82, 4)">
<path d="M6,12 C5.5,12 5,11.8 4.6,11.4 L0.6,7.4 C-0.2,6.6 -0.2,5.4 0.6,4.6 C1.4,3.8 2.7,3.8 3.4,4.6 L6,7.2 L12.6,0.6 C13.4,-0.2 14.6,-0.2 15.4,0.6 C16.2,1.4 16.2,2.6 15.4,3.4 L7.4,11.4 C7,11.8 6.5,12 6,12 Z"></path>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 KiB

View File

@ -39,6 +39,7 @@ $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);
$check_unique_ip = (bool) get_parameter('check_unique_ip', 0);
if (https_is_running()) {
header('Content-type: application/json');
@ -1020,4 +1021,29 @@ $(document).ready(function() {
return;
}
if ($check_unique_ip === true) {
$direccion_agente = (string) get_parameter_post('direccion', '');
$ip_all = get_parameter_post('ip_all', '');
if (empty($direccion_agente) === true) {
echo json_encode(['success' => false, 'message' => __('Please enter an IP address.')]);
return;
}
$sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"';
$exists_ip = db_get_row_sql($sql);
if ($exists_ip !== false) {
if (is_array($ip_all) === true && in_array($direccion_agente, $ip_all) === true) {
echo json_encode(['success' => true, 'message' => __('Success! but this IP is already in the list.')]);
} else {
echo json_encode(['success' => false, 'message' => __('This IP is already being used'), 'exist_ip' => true]);
}
} else {
echo json_encode(['success' => true, 'message' => __('Success! this IP is available to be used.')]);
}
return;
}
return;

View File

@ -41,7 +41,20 @@ if ($method === 'draw') {
$length = get_parameter('length', $config['block_size']);
$orderBy = get_datatable_order(true);
$sort_field = $orderBy['field'];
switch ($orderBy['field']) {
case 'groups':
$sort_field = 'nombre';
break;
case 'favorite':
$sort_field = 'active';
break;
default:
$sort_field = $orderBy['field'];
break;
}
$order = $orderBy['direction'];
$pagination = '';
@ -121,7 +134,7 @@ if ($method === 'draw') {
);
}
$sql = 'SELECT * FROM tdashboard '.$where.' ORDER BY id '.$pagination;
$sql = 'SELECT * FROM tdashboard LEFT JOIN tgrupo ON tgrupo.id_grupo = tdashboard.id_group '.$where.' ORDER BY '.$sort_field.' '.$order.$pagination;
$dashboards = db_get_all_rows_sql($sql);
$count = db_get_value_sql('SELECT COUNT(*) FROM tdashboard '.$where);
foreach ($dashboards as $dashboard) {

View File

@ -98,6 +98,8 @@ $draw_events_graph = get_parameter('drawEventsGraph', false);
// User private filter.
$current_filter = get_parameter('current_filter', 0);
$private_filter_event = get_parameter('private_filter_event', 0);
// Asteroids.
$playAsteroids = (bool) get_parameter('playAsteroids', false);
if ($get_comments === true) {
global $config;
@ -2763,6 +2765,17 @@ if ($draw_row_response_info === true) {
return;
}
// Asteroids.
if ($playAsteroids === true) {
echo ui_require_css_file('asteroids', 'include/styles/', true);
echo ui_require_javascript_file('asteroids', 'include/asteroids/', true);
$output = '<div id="asteroids">Asteroids game goes here!</div>';
echo $output;
return;
}
if ($update_event_custom_id) {
$event_custom_id = get_parameter('event_custom_id');
$event_id = get_parameter('event_id');
@ -2814,4 +2827,4 @@ if ((bool) $draw_events_graph === true) {
$output = event_print_graph($filter);
echo $output;
return;
}
}

View File

@ -17,6 +17,8 @@ $save_custom_graph = (bool) get_parameter('save_custom_graph');
$print_custom_graph = (bool) get_parameter('print_custom_graph', false);
$print_sparse_graph = (bool) get_parameter('print_sparse_graph');
$get_graphs = (bool) get_parameter('get_graphs_container');
$sort_items = (bool) get_parameter('sort_items');
$width = get_parameter('width', 0);
$height = get_parameter('height', 0);
@ -337,3 +339,104 @@ if ($get_graphs) {
return;
}
}
if ($sort_items === true) {
$order = (string) get_parameter('order');
$id = (string) get_parameter('id', '');
$idGraph = (string) get_parameter('id_graph', '');
$total = db_get_num_rows('SELECT * FROM tgraph_source WHERE id_graph = '.$idGraph.'');
$item = db_get_row_sql(
'SELECT id_gs, field_order
FROM tgraph_source
WHERE id_gs = '.$id.'
ORDER BY field_order'
);
switch ($order) {
case 'up':
if (($item['field_order'] - 1) < 1) {
echo json_encode(['success' => false]);
return;
}
$prevItem = db_get_row_sql(
'SELECT id_gs, field_order
FROM tgraph_source
WHERE id_graph = '.$idGraph.'
AND field_order = '.($item['field_order'] - 1).'
ORDER BY field_order'
);
db_process_sql_begin();
$resultItem = db_process_sql_update(
'tgraph_source',
['field_order' => ($item['field_order'] - 1)],
['id_gs' => $item['id_gs']],
false
);
$resultPrevItem = db_process_sql_update(
'tgraph_source',
['field_order' => ($prevItem['field_order'] + 1)],
['id_gs' => $prevItem['id_gs']],
false
);
if ($resultItem !== false && $resultPrevItem !== false) {
db_process_sql_commit();
echo json_encode(['success' => true]);
return;
} else {
db_process_sql_rollback();
echo json_encode(['success' => false]);
return;
}
break;
case 'down':
if (($item['field_order'] + 1) > $total) {
echo json_encode(['success' => false]);
return;
}
$nextItem = db_get_row_sql(
'SELECT id_gs, field_order
FROM tgraph_source
WHERE id_graph = '.$idGraph.'
AND field_order = '.($item['field_order'] + 1).'
ORDER BY field_order'
);
db_process_sql_begin();
$resultItem = db_process_sql_update(
'tgraph_source',
['field_order' => ($item['field_order'] + 1)],
['id_gs' => $item['id_gs']],
false
);
$resultNextItem = db_process_sql_update(
'tgraph_source',
['field_order' => ($nextItem['field_order'] - 1)],
['id_gs' => $nextItem['id_gs']],
false
);
if ($resultItem !== false && $resultNextItem !== false) {
db_process_sql_commit();
echo json_encode(['success' => true]);
return;
} else {
db_process_sql_rollback();
echo json_encode(['success' => false]);
return;
}
break;
default:
echo json_encode(['success' => false]);
break;
}
}

View File

@ -0,0 +1,25 @@
Copyright (c) 2023, James Socol <me@jamessocol.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,46 @@
=========
ASTEROIDS
=========
Last week, at work, we joked about creating an Asteroids clone where every
asteroid had a bug number in it, as a bit of a joke. (Ha ha, every bug you
kill spawns two more!)
I was bored this afternoon, so here's a port of Asteroids to JS/Canvas.
Now all I need to do is hook in the bug numbers.
Gameplay
========
You're the triangle in the middle. You want to destroy the circles. You have
a gun (spacebar), some thrusters to turn (left and right arrow keys) and an
engine (up arrow key).
Remember, it's kill or be killed out there.
Rights
======
The name *Asteroids* is, as far as I know, still property of Atari. I mean no
ill-will towards Atari by releasing this code. Frankly, it's a poor
substitute for anything resembling a real game. I just wanted to see if I
could do it.
If anyone from Atari asks, I will gladly rename and/or remove this code. But
since there are so many *Asteroids* clones as it is, and the original was
released in 1979, and it was kind of a copy of *Spacewar!*, I doubt they'll
mind too much.
Strikes me as funny...
======================
The original *Spacewar!*, one of the earliest (if not the original) computer
games, took `200 hours to code <http://en.wikipedia.org/wiki/Spacewar!>`_.
This probably took me 6.
I am so glad we've moved past the PDP-1.

View File

@ -0,0 +1,840 @@
// Asteroids.js
// Copyright (c) 20102023 James Socol <me@jamessocol.com>
// See LICENSE.txt for license terms.
// Game settings
GAME_HEIGHT = 480;
GAME_WIDTH = 640;
FRAME_PERIOD = 60; // 1 frame / x frames/sec
LEVEL_TIMEOUT = 2000; // How long to wait after clearing a level.
// Player settings
ROTATE_SPEED = Math.PI / 10; // How fast do players turn? (radians)
MAX_SPEED = 15; // Maximum player speed
THRUST_ACCEL = 1;
DEATH_TIMEOUT = 2000; // milliseconds
INVINCIBLE_TIMEOUT = 1500; // How long to stay invincible after resurrecting?
PLAYER_LIVES = 3;
POINTS_PER_SHOT = 1; // How many points does a shot cost? (Should be >= 0.)
POINTS_TO_EXTRA_LIFE = 1000; // How many points to get a 1-up?
// Bullet settings
BULLET_SPEED = 20;
MAX_BULLETS = 3;
MAX_BULLET_AGE = 25;
// Asteroid settings
ASTEROID_COUNT = 2; // This + current level = number of asteroids.
ASTEROID_GENERATIONS = 3; // How many times to they split before dying?
ASTEROID_CHILDREN = 2; // How many does each death create?
ASTEROID_SPEED = 3;
ASTEROID_SCORE = 10; // How many points is each one worth?
var Asteroids = function(home) {
// Constructor
// Order matters.
// Set up logging.
this.log_level = Asteroids.LOG_DEBUG;
this.log = Asteroids.logger(this);
// Create the info pane, player, and playfield.
home.innerHTML = "";
this.info = Asteroids.infoPane(this, home);
this.playfield = Asteroids.playfield(this, home);
this.player = Asteroids.player(this);
// Set up the event listeners.
this.keyState = Asteroids.keyState(this);
this.listen = Asteroids.listen(this);
// Useful functions.
this.asteroids = Asteroids.asteroids(this);
this.overlays = Asteroids.overlays(this);
this.highScores = Asteroids.highScores(this);
this.level = Asteroids.level(this);
this.gameOver = Asteroids.gameOver(this);
// Play the game.
Asteroids.play(this);
return this;
};
Asteroids.infoPane = function(game, home) {
var pane = document.createElement("div");
pane.innerHTML = "ASTEROIDS";
var lives = document.createElement("span");
lives.className = "lives";
lives.innerHTML = "LIVES: " + PLAYER_LIVES;
var score = document.createElement("span");
score.className = "score";
score.innerHTML = "SCORE: 0";
var level = document.createElement("span");
level.className = "level";
level.innerHTML = "LEVEL: 1";
pane.appendChild(lives);
pane.appendChild(score);
pane.appendChild(level);
home.appendChild(pane);
return {
setLives: function(game, l) {
lives.innerHTML = "LIVES: " + l;
},
setScore: function(game, s) {
score.innerHTML = "SCORE: " + s;
},
setLevel: function(game, _level) {
level.innerHTML = "LEVEL: " + _level;
},
getPane: function() {
return pane;
}
};
};
Asteroids.playfield = function(game, home) {
var canvas = document.createElement("canvas");
canvas.width = GAME_WIDTH;
canvas.height = GAME_HEIGHT;
home.appendChild(canvas);
return canvas;
};
Asteroids.logger = function(game) {
if (typeof console != "undefined" && typeof console.log != "undefined") {
return {
info: function(msg) {
if (game.log_level <= Asteroids.LOG_INFO) console.log(msg);
},
debug: function(msg) {
if (game.log_level <= Asteroids.LOG_DEBUG) console.log(msg);
},
warning: function(msg) {
if (game.log_level <= Asteroids.LOG_WARNING) console.log(msg);
},
error: function(msg) {
if (game.log_level <= Asteroids.LOG_ERROR) console.log(msg);
},
critical: function(msg) {
if (game.log_level <= Asteroids.LOG_CRITICAL) console.log(msg);
}
};
} else {
return {
info: function(msg) {},
debug: function(msg) {},
warning: function(msg) {},
error: function(msg) {},
critical: function(msg) {}
};
}
};
Asteroids.asteroids = function(game) {
var asteroids = [];
return {
push: function(obj) {
return asteroids.push(obj);
},
pop: function() {
return asteroids.pop();
},
splice: function(i, j) {
return asteroids.splice(i, j);
},
get length() {
return asteroids.length;
},
getIterator: function() {
return asteroids;
},
generationCount: function(_gen) {
var total = 0;
for (var i = 0; i < asteroids.length; i++) {
if (asteroids[i].getGeneration() == _gen) total++;
}
game.log.debug("Found " + total + " asteroids in generation " + _gen);
return total;
}
};
};
/**
* Creates an overlays controller.
*/
Asteroids.overlays = function(game) {
var overlays = [];
return {
draw: function(ctx) {
for (var i = 0; i < overlays.length; i++) {
overlays[i].draw(ctx);
}
},
add: function(obj) {
if (-1 == overlays.indexOf(obj) && typeof obj.draw != "undefined") {
overlays.push(obj);
return true;
}
return false;
},
remove: function(obj) {
var i = overlays.indexOf(obj);
if (-1 != i) {
overlays.splice(i, 1);
return true;
}
return false;
}
};
};
/**
* Creates a player object.
*/
Asteroids.player = function(game) {
// implements IScreenObject
var position = [GAME_WIDTH / 2, GAME_HEIGHT / 2],
velocity = [0, 0],
direction = -Math.PI / 2,
dead = false,
invincible = false,
lastRez = null,
lives = PLAYER_LIVES,
score = 0,
radius = 3,
path = [
[10, 0],
[-5, 5],
[-5, -5],
[10, 0]
];
return {
getPosition: function() {
return position;
},
getVelocity: function() {
return velocity;
},
getSpeed: function() {
return Math.sqrt(Math.pow(velocity[0], 2) + Math.pow(velocity[1], 2));
},
getDirection: function() {
return direction;
},
getRadius: function() {
return radius;
},
getScore: function() {
return score;
},
addScore: function(pts) {
score += pts;
},
lowerScore: function(pts) {
score -= pts;
if (score < 0) {
score = 0;
}
},
getLives: function() {
return lives;
},
rotate: function(rad) {
if (!dead) {
direction += rad;
game.log.info(direction);
}
},
thrust: function(force) {
if (!dead) {
velocity[0] += force * Math.cos(direction);
velocity[1] += force * Math.sin(direction);
if (this.getSpeed() > MAX_SPEED) {
velocity[0] = MAX_SPEED * Math.cos(direction);
velocity[1] = MAX_SPEED * Math.sin(direction);
}
game.log.info(velocity);
}
},
move: function() {
Asteroids.move(position, velocity);
},
draw: function(ctx) {
let color = "#fff";
if (invincible) {
const dt = (new Date() - lastRez) / 200;
const c = Math.floor(Math.cos(dt) * 16).toString(16);
color = `#${c}${c}${c}`;
}
Asteroids.drawPath(ctx, position, direction, 1, path, color);
},
isDead: function() {
return dead;
},
isInvincible: function() {
return invincible;
},
extraLife: function(game) {
game.log.debug("Woo, extra life!");
lives++;
},
die: function(game) {
if (!dead) {
game.log.info("You died!");
dead = true;
invincible = true;
lives--;
position = [GAME_WIDTH / 2, GAME_HEIGHT / 2];
velocity = [0, 0];
direction = -Math.PI / 2;
if (lives > 0) {
setTimeout(
(function(player, _game) {
return function() {
player.resurrect(_game);
};
})(this, game),
DEATH_TIMEOUT
);
} else {
game.gameOver();
}
}
},
resurrect: function(game) {
if (dead) {
dead = false;
invincible = true;
lastRez = new Date();
setTimeout(function() {
invincible = false;
game.log.debug("No longer invincible!");
}, INVINCIBLE_TIMEOUT);
game.log.debug("You ressurrected!");
}
},
fire: function(game) {
if (!dead) {
game.log.debug("You fired!");
var _pos = [position[0], position[1]],
_dir = direction;
this.lowerScore(POINTS_PER_SHOT);
return Asteroids.bullet(game, _pos, _dir);
}
}
};
};
Asteroids.bullet = function(game, _pos, _dir) {
// implements IScreenObject
var position = [_pos[0], _pos[1]],
velocity = [0, 0],
direction = _dir,
age = 0,
radius = 1,
path = [
[0, 0],
[-4, 0]
];
velocity[0] = BULLET_SPEED * Math.cos(_dir);
velocity[1] = BULLET_SPEED * Math.sin(_dir);
return {
getPosition: function() {
return position;
},
getVelocity: function() {
return velocity;
},
getSpeed: function() {
return Math.sqrt(Math.pow(velocity[0], 2) + Math.pow(velocity[1], 2));
},
getRadius: function() {
return radius;
},
getAge: function() {
return age;
},
birthday: function() {
age++;
},
move: function() {
Asteroids.move(position, velocity);
},
draw: function(ctx) {
Asteroids.drawPath(ctx, position, direction, 1, path);
}
};
};
Asteroids.keyState = function(_) {
var state = {
[Asteroids.LEFT]: false,
[Asteroids.UP]: false,
[Asteroids.RIGHT]: false,
[Asteroids.DOWN]: false,
[Asteroids.FIRE]: false
};
return {
on: function(key) {
state[key] = true;
},
off: function(key) {
state[key] = false;
},
getState: function(key) {
if (typeof state[key] != "undefined") return state[key];
return false;
}
};
};
Asteroids.listen = function(game) {
const keyMap = {
ArrowLeft: Asteroids.LEFT,
KeyA: Asteroids.LEFT,
ArrowRight: Asteroids.RIGHT,
KeyD: Asteroids.RIGHT,
ArrowUp: Asteroids.UP,
KeyW: Asteroids.UP,
Space: Asteroids.FIRE
};
window.addEventListener(
"keydown",
function(e) {
const state = keyMap[e.code];
if (state) {
e.preventDefault();
e.stopPropagation();
game.keyState.on(state);
return false;
}
return true;
},
true
);
window.addEventListener(
"keyup",
function(e) {
const state = keyMap[e.code];
if (state) {
e.preventDefault();
e.stopPropagation();
game.keyState.off(state);
return false;
}
return true;
},
true
);
};
Asteroids.asteroid = function(game, _gen) {
// implements IScreenObject
var position = [0, 0],
velocity = [0, 0],
direction = 0,
generation = _gen,
radius = 7,
path = [
[1, 7],
[5, 5],
[7, 1],
[5, -3],
[7, -7],
[3, -9],
[-1, -5],
[-4, -2],
[-8, -1],
[-9, 3],
[-5, 5],
[-1, 3],
[1, 7]
];
return {
getPosition: function() {
return position;
},
setPosition: function(pos) {
position = pos;
},
getVelocity: function() {
return velocity;
},
setVelocity: function(vel) {
velocity = vel;
direction = Math.atan2(vel[1], vel[0]);
},
getSpeed: function() {
return Math.sqrt(Math.pow(velocity[0], 2) + Math.pow(velocity[1], 2));
},
getRadius: function() {
return radius * generation;
},
getGeneration: function() {
return generation;
},
move: function() {
Asteroids.move(position, velocity);
},
draw: function(ctx) {
Asteroids.drawPath(ctx, position, direction, generation, path);
// ctx.setTransform(1, 0, 0, 1, position[0], position[1]);
// ctx.beginPath();
// ctx.arc(0, 0, radius*generation, 0, Math.PI*2, false);
// ctx.stroke();
// ctx.closePath();
}
};
};
Asteroids.collision = function(a, b) {
// if a.getPosition() inside b.getBounds?
var a_pos = a.getPosition(),
b_pos = b.getPosition();
function sq(x) {
return Math.pow(x, 2);
}
var distance = Math.sqrt(sq(a_pos[0] - b_pos[0]) + sq(a_pos[1] - b_pos[1]));
if (distance <= a.getRadius() + b.getRadius()) return true;
return false;
};
Asteroids.level = function(game) {
var level = 0,
speed = ASTEROID_SPEED,
hspeed = ASTEROID_SPEED / 2;
return {
getLevel: function() {
return level;
},
levelUp: function(game) {
level++;
game.log.debug("Congrats! On to level " + level);
while (
game.asteroids.generationCount(ASTEROID_GENERATIONS) <
level + ASTEROID_COUNT
) {
var a = Asteroids.asteroid(game, ASTEROID_GENERATIONS);
a.setPosition([
Math.random() * GAME_WIDTH,
Math.random() * GAME_HEIGHT
]);
a.setVelocity([
Math.random() * speed - hspeed,
Math.random() * speed - hspeed
]);
game.asteroids.push(a);
}
}
};
};
Asteroids.gameOver = function(game) {
return function() {
game.log.debug("Game over!");
if (game.player.getScore() > 0) {
game.highScores.addScore("Player", game.player.getScore());
}
game.overlays.add({
// implements IOverlay
draw: function(ctx) {
ctx.font = "30px System, monospace";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.fillText("GAME OVER", GAME_WIDTH / 2, GAME_HEIGHT / 2);
var scores = game.highScores.getScores();
ctx.font = "12px System, monospace";
for (var i = 0; i < scores.length; i++) {
ctx.fillText(
scores[i].name + " " + scores[i].score,
GAME_WIDTH / 2,
GAME_HEIGHT / 2 + 20 + 14 * i
);
}
}
});
};
};
Asteroids.highScores = function(game) {
var scores = [];
if ((t = localStorage.getItem("high-scores"))) {
scores = JSON.parse(t);
}
return {
getScores: function() {
return scores;
},
addScore: function(_name, _score) {
scores.push({ name: _name, score: _score });
scores.sort(function(a, b) {
return b.score - a.score;
});
if (scores.length > 10) {
scores.length = 10;
}
game.log.debug("Saving high scores.");
var str = JSON.stringify(scores);
localStorage.setItem("high-scores", str);
}
};
};
Asteroids.drawPath = function(ctx, position, direction, scale, path, color) {
if (!color) {
color = "#fff";
}
ctx.strokeStyle = color;
ctx.setTransform(
Math.cos(direction) * scale,
Math.sin(direction) * scale,
-Math.sin(direction) * scale,
Math.cos(direction) * scale,
position[0],
position[1]
);
ctx.beginPath();
ctx.moveTo(path[0][0], path[0][1]);
for (i = 1; i < path.length; i++) {
ctx.lineTo(path[i][0], path[i][1]);
}
ctx.stroke();
ctx.closePath();
ctx.strokeStyle = "#fff";
};
Asteroids.move = function(position, velocity) {
position[0] += velocity[0];
if (position[0] < 0) position[0] = GAME_WIDTH + position[0];
else if (position[0] > GAME_WIDTH) position[0] -= GAME_WIDTH;
position[1] += velocity[1];
if (position[1] < 0) position[1] = GAME_HEIGHT + position[1];
else if (position[1] > GAME_HEIGHT) position[1] -= GAME_HEIGHT;
};
Asteroids.stars = function() {
var stars = [];
for (var i = 0; i < 50; i++) {
stars.push([Math.random() * GAME_WIDTH, Math.random() * GAME_HEIGHT]);
}
return {
draw: function(ctx) {
var ii = stars.length;
for (var i = 0; i < ii; i++) {
ctx.fillRect(stars[i][0], stars[i][1], 1, 1);
}
}
};
};
Asteroids.play = function(game) {
var ctx = game.playfield.getContext("2d");
ctx.fillStyle = "white";
ctx.strokeStyle = "white";
var speed = ASTEROID_SPEED,
hspeed = ASTEROID_SPEED / 2;
game.level.levelUp(game);
var bullets = [],
last_fire_state = false,
last_asteroid_count = 0;
var extra_lives = 0;
// Add a star field.
game.overlays.add(Asteroids.stars());
game.pulse = setInterval(function() {
var kill_asteroids = [],
new_asteroids = [],
kill_bullets = [];
ctx.save();
ctx.clearRect(0, 0, GAME_WIDTH, GAME_HEIGHT);
// Be nice and award extra lives first.
var t_extra_lives = game.player.getScore() / POINTS_TO_EXTRA_LIFE;
t_extra_lives = Math.floor(t_extra_lives);
if (t_extra_lives > extra_lives) {
game.player.extraLife(game);
}
extra_lives = t_extra_lives;
if (game.keyState.getState(Asteroids.UP)) {
game.player.thrust(THRUST_ACCEL);
}
if (game.keyState.getState(Asteroids.LEFT)) {
game.player.rotate(-ROTATE_SPEED);
}
if (game.keyState.getState(Asteroids.RIGHT)) {
game.player.rotate(ROTATE_SPEED);
}
var fire_state = game.keyState.getState(Asteroids.FIRE);
if (
fire_state &&
fire_state != last_fire_state &&
bullets.length < MAX_BULLETS
) {
var b = game.player.fire(game);
bullets.push(b);
}
last_fire_state = fire_state;
if (!game.player.isDead()) {
game.player.move();
game.player.draw(ctx);
}
for (var k = 0; k < bullets.length; k++) {
if (!bullets[k]) continue;
if (bullets[k].getAge() > MAX_BULLET_AGE) {
kill_bullets.push(k);
continue;
}
bullets[k].birthday();
bullets[k].move();
bullets[k].draw(ctx);
}
for (var r = kill_bullets.length - 1; r >= 0; r--) {
bullets.splice(r, 1);
}
var asteroids = game.asteroids.getIterator();
for (var i = 0; i < game.asteroids.length; i++) {
var killit = false;
asteroids[i].move();
asteroids[i].draw(ctx);
// Destroy the asteroid
for (var j = 0; j < bullets.length; j++) {
if (!bullets[j]) continue;
if (Asteroids.collision(bullets[j], asteroids[i])) {
game.log.debug("You shot an asteroid!");
// Destroy the bullet.
bullets.splice(j, 1);
killit = true; // JS doesn't have "continue 2;"
continue;
}
}
// Kill the asteroid?
if (killit) {
var _gen = asteroids[i].getGeneration() - 1;
if (_gen > 0) {
// Create children ;)
for (var n = 0; n < ASTEROID_CHILDREN; n++) {
var a = Asteroids.asteroid(game, _gen);
var _pos = [
asteroids[i].getPosition()[0],
asteroids[i].getPosition()[1]
];
a.setPosition(_pos);
a.setVelocity([
Math.random() * speed - hspeed,
Math.random() * speed - hspeed
]);
new_asteroids.push(a);
}
}
game.player.addScore(ASTEROID_SCORE);
kill_asteroids.push(i);
continue;
}
// Kill the player?
if (
!game.player.isDead() &&
!game.player.isInvincible() &&
Asteroids.collision(game.player, asteroids[i])
) {
game.player.die(game);
}
}
kill_asteroids.sort(function(a, b) {
return a - b;
});
for (var m = kill_asteroids.length - 1; m >= 0; m--) {
game.asteroids.splice(kill_asteroids[m], 1);
}
for (var o = 0; o < new_asteroids.length; o++) {
game.asteroids.push(new_asteroids[o]);
}
ctx.restore();
// Do we need to level up?
if (0 == game.asteroids.length && last_asteroid_count != 0) {
setTimeout(function() {
game.level.levelUp(game);
}, LEVEL_TIMEOUT);
}
last_asteroid_count = game.asteroids.length;
// Draw overlays.
game.overlays.draw(ctx);
// Update the info pane.
game.info.setLives(game, game.player.getLives());
game.info.setScore(game, game.player.getScore());
game.info.setLevel(game, game.level.getLevel());
}, FRAME_PERIOD);
};
// Some boring constants.
Asteroids.LOG_ALL = 0;
Asteroids.LOG_INFO = 1;
Asteroids.LOG_DEBUG = 2;
Asteroids.LOG_WARNING = 3;
Asteroids.LOG_ERROR = 4;
Asteroids.LOG_CRITICAL = 5;
Asteroids.LOG_NONE = 6;
Asteroids.LEFT = 37;
Asteroids.UP = 38;
Asteroids.RIGHT = 39;
Asteroids.DOWN = 40;
Asteroids.FIRE = 32;
// Load it up!
window.onload = Asteroids(document.getElementById("asteroids"));

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta http-equiv="Content-type" content="text/html;charset=utf-8" />
<title>Asteroids</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="asteroids">Asteroids game goes here!</div>
<script src="asteroids.js" type="text/ecmascript"></script>
</body>
</html>

View File

@ -0,0 +1,46 @@
/* Style for Asteroids.js
* Copyright (c) 2010 James Socol <me@jamessocol.com>
* See LICENSE.txt for license.
*/
body {
background-color: #000;
color: #fff;
font-family: "Calibri", "System", monospace;
font-size: 14px;
}
div#asteroids {
margin: 50px auto;
width: 640px;
border: 1px solid #fff;
padding: 5px;
}
div#asteroids > * {
color: #fff;
}
div#asteroids > div {
font-family: "System", monospace;
font-size: 11px;
padding-bottom: 5px;
}
div#asteroids > div > span {
float: right;
padding-left: 20px;
}
div#instructions {
width: 640px;
margin: 20px auto;
}
h1 {
font-size: 18px;
}
h2 {
font-size: 16px;
}

View File

@ -816,8 +816,6 @@ function update_user(string $id_user, array $values)
$values['metaconsole_data_section'] = $values['data_section'];
$values['metaconsole_default_event_filter'] = $values['default_event_filter'];
unset($values['id_skin']);
unset($values['section']);
unset($values['data_section']);
unset($values['default_event_filter']);
}
}

View File

@ -123,7 +123,7 @@ class AuditLog extends HTML
],
[
'text' => 'action',
'class' => 'w80px table_action_buttons show_extended_info',
'class' => 'w80px show_extended_info',
]
);
@ -187,7 +187,7 @@ class AuditLog extends HTML
'no_sortable_columns' => [-1],
'order' => [
'field' => 'date',
'direction' => 'asc',
'direction' => 'desc',
],
'search_button_class' => 'sub filter float-right',
'form' => [
@ -441,7 +441,7 @@ class AuditLog extends HTML
$(document).ready(function() {
// Add event listener for opening and closing details
$('#audit_logs tbody').on('click', 'td.show_extended_info', function() {
$(document).on('click', '#audit_logs tbody tr:has(td.show_extended_info)', function() {
var tr = $(this).closest('tr');
var table = $("#<?php echo $this->tableId; ?>").DataTable();
var row = table.row(tr);

View File

@ -928,7 +928,9 @@ class ConsoleSupervisor
false
);
if ($prev !== false
if ($data['type'] === 'NOTIF.LOG.ALERT' && $prev !== false) {
return;
} else if ($prev !== false
&& (time() - $prev['timestamp']) > $max_age
) {
// Clean previous notification.

View File

@ -388,26 +388,40 @@ class SatelliteAgent extends HTML
$tmp->actions = '';
if ($delete === false) {
$tmp->actions .= html_print_image(
($disable === true) ? 'images/lightbulb_off.png' : 'images/lightbulb.png',
true,
$tmp->actions .= html_print_anchor(
[
'border' => '0',
'class' => 'main_menu_icon mrgn_lft_05em invert_filter',
'onclick' => 'disable_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $disable.'\',\''.$id_agente.'\')',
]
'href' => '#',
'content' => html_print_image(
($disable === true) ? 'images/lightbulb_off.png' : 'images/lightbulb.png',
true,
[
'title' => ($disable === true) ? __('Enable') : __('Disable'),
'border' => '0',
'class' => 'main_menu_icon mrgn_lft_05em invert_filter',
'onclick' => 'disable_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $disable.'\',\''.$id_agente.'\')',
]
),
],
true
);
}
if ($disable === false) {
$tmp->actions .= html_print_image(
($delete === true) ? 'images/add.png' : 'images/delete.svg',
true,
$tmp->actions .= html_print_anchor(
[
'border' => '0',
'class' => 'main_menu_icon mrgn_lft_05em invert_filter',
'onclick' => 'delete_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $delete.'\',\''.$id_agente.'\')',
]
'href' => '#',
'content' => html_print_image(
($delete === true) ? 'images/add.png' : 'images/delete.svg',
true,
[
'title' => ($delete === true) ? __('Add') : __('Delete'),
'border' => '0',
'class' => 'main_menu_icon mrgn_lft_05em invert_filter',
'onclick' => 'delete_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $delete.'\',\''.$id_agente.'\')',
]
),
],
true
);
}

View File

@ -995,6 +995,11 @@ class Tree
}
}
}
// Quiet name on agent.
if (isset($agent['quiet']) && $agent['quiet']) {
$agent['alias'] .= ' '.__('(Quiet)');
}
}

View File

@ -156,11 +156,14 @@ class WelcomeWindow extends Wizard
modal: {
title: "<?php echo __('Welcome to').' '.io_safe_output(get_product_name()); ?>",
cancel: '<?php echo __('Do not show anymore'); ?>',
ok: '<?php echo __('Close'); ?>'
ok: '<?php echo __('Close wizard'); ?>',
overlay: true,
overlayExtraClass: 'welcome-overlay',
},
onshow: {
page: '<?php echo $this->ajaxController; ?>',
method: 'loadWelcomeWindow',
width: 1000,
},
oncancel: {
page: '<?php echo $this->ajaxController; ?>',
@ -178,6 +181,34 @@ class WelcomeWindow extends Wizard
}
})
}
},
onload: () => {
$(document).ready(function () {
var buttonpane = $("div[aria-describedby='welcome_modal_window'] .ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix");
$(buttonpane).append(`
<div class="welcome-wizard-buttons">
<label>
<input type="checkbox" class="welcome-wizard-do-not-show" value="1" />
<?php echo __('Do not show anymore'); ?>
</label>
<button class="close-wizard-button"><?php echo __('Close wizard'); ?></button>
</div>
`);
var closeWizard = $("button.close-wizard-button");
$(closeWizard).click(function (e) {
var close = $("div[aria-describedby='welcome_modal_window'] button.sub.ok.submit-next.ui-button");
var cancel = $("div[aria-describedby='welcome_modal_window'] button.sub.upd.submit-cancel.ui-button");
var checkbox = $("div[aria-describedby='welcome_modal_window'] .welcome-wizard-do-not-show:checked").length;
if (checkbox === 1) {
$(cancel).click();
} else {
$(close).click()
}
});
});
}
});
@ -412,11 +443,11 @@ class WelcomeWindow extends Wizard
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_diagnosis',
'class' => 'flex-row flex-items-center w98p ',
'class' => 'flex-row flex-items-center ',
'direct' => 1,
'block_content' => [
[
'label' => __('Post-installation status diagnostic'),
'label' => __('This is your post-installation status diagnostic:'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_diagnosis',
@ -434,7 +465,7 @@ class WelcomeWindow extends Wizard
'direct' => 1,
'block_content' => [
[
'label' => __('Warp Update registration'),
'label' => '<span class="status"></span>'.__('Warp Update registration'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_update_manager',
@ -443,7 +474,7 @@ class WelcomeWindow extends Wizard
],
[
'arguments' => [
'label' => '',
'label' => __('Cancel'),
'type' => 'button',
'attributes' => [
'class' => (empty($btn_update_manager_class) === false) ? $btn_update_manager_class : 'invisible_important',
@ -462,7 +493,7 @@ class WelcomeWindow extends Wizard
'direct' => 1,
'block_content' => [
[
'label' => __('Default mail to send alerts'),
'label' => '<span class="status"></span>'.__('Default mail to send alerts'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_create_agent',
@ -471,7 +502,7 @@ class WelcomeWindow extends Wizard
],
[
'arguments' => [
'label' => '',
'label' => __('Cancel'),
'type' => 'button',
'attributes' => [
'class' => (empty($btn_configure_mail_class) === false) ? $btn_configure_mail_class : 'invisible_important',
@ -490,7 +521,7 @@ class WelcomeWindow extends Wizard
'direct' => 1,
'block_content' => [
[
'label' => __('All servers running'),
'label' => '<span class="status"></span>'.__('All servers running'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_servers_up',
@ -499,7 +530,7 @@ class WelcomeWindow extends Wizard
],
[
'arguments' => [
'label' => '',
'label' => __('Cancel'),
'type' => 'button',
'attributes' => [
'class' => (empty($btn_servers_up_class) === false) ? $btn_servers_up_class : 'invisible_important',
@ -518,7 +549,7 @@ class WelcomeWindow extends Wizard
'direct' => 1,
'block_content' => [
[
'label' => __('Enterprise licence valid'),
'label' => '<span class="status"></span>'.__('Enterprise licence valid'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_license_valid',
@ -527,7 +558,7 @@ class WelcomeWindow extends Wizard
],
[
'arguments' => [
'label' => '',
'label' => __('Cancel'),
'type' => 'button',
'attributes' => [
'class' => (empty($btn_license_valid_class) === false) ? $btn_license_valid_class : 'invisible_important',
@ -567,7 +598,7 @@ class WelcomeWindow extends Wizard
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_task_todo',
'class' => 'flex-row flex-items-center w98p',
'class' => 'flex-row flex-items-center',
'direct' => 1,
'block_content' => [
[
@ -591,7 +622,7 @@ class WelcomeWindow extends Wizard
$inputs[] = [
'wrapper' => 'div',
'block_id' => 'div_wizard_agent',
'class' => 'flex space-between w98p',
'class' => 'flex space-between',
'direct' => 1,
'block_content' => [
[
@ -599,7 +630,7 @@ class WelcomeWindow extends Wizard
'type' => 'select',
'fields' => $fields,
'name' => 'task_to_perform',
'selected' => '',
'selected' => 'check_net',
'return' => true,
'nothing' => \__('Please select one'),
'nothing_value' => '',
@ -630,6 +661,24 @@ class WelcomeWindow extends Wizard
$output .= $this->loadJS($flag_task);
echo $output;
echo '
<div class="welcome-wizard-right-content">
<ul class="welcome-circles">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<img src="images/welcome-wizard-image.png" />
</div>
';
?>
<div id="dialog_goliat" class="invisible">
<?php

View File

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

View File

@ -2016,7 +2016,7 @@ function api_set_new_agent($id_node, $thrash2, $other, $trhash3, $return=false,
}
returnError('No agent alias specified');
} else if (agents_get_agent_id($nombre_agente)) {
} else if (agents_get_agent_id($agent->nombre())) {
if ($message === true) {
return 'The agent name already exists in DB.';
}
@ -2064,7 +2064,7 @@ function api_set_new_agent($id_node, $thrash2, $other, $trhash3, $return=false,
}
}
if ($return === false) {
if ($return !== true) {
returnData(
'string',
[

View File

@ -383,6 +383,13 @@ function cron_task_run(
$nameday = strtolower($datetime->format('l'));
}
}
} else if (empty($old_args['first_execution']) === false) {
$datetime = new DateTime();
$datetime->setTimestamp($old_args['first_execution']);
$datetime->modify('+7 day');
$weekly_date = $datetime->format('Y-m-d');
$weekly_time = $datetime->format('H:i:s');
$old_args['first_execution'] = strtotime($weekly_date.' '.$weekly_time);
}
} else {
// Add it to next execution.

View File

@ -1318,7 +1318,7 @@ function events_get_all(
if ($tags[0] === $id_tag) {
$_tmp .= ' AND (( ';
} else {
$_tmp .= ' OR ( ';
$_tmp .= ' AND ( ';
}
$_tmp .= sprintf(
@ -1969,7 +1969,7 @@ function events_get_all(
// -1 For pagination 'All'.
((int) $limit === -1)
? $end = count($data)
: $end = ((int) $offset !== 0) ? ($offset + $limit) : $limit;
: $end = $limit;
$finally = array_slice($data, $offset, $end, true);
$return = [
'buffers' => $buffers,

View File

@ -774,7 +774,8 @@ function html_print_select(
$select2_multiple_enable_all=false,
$form='',
$order=false,
$custom_id=null
$custom_id=null,
$placeholder='',
) {
$output = "\n";
@ -1013,7 +1014,8 @@ function html_print_select(
$output .= '<script type="text/javascript">';
$output .= '$("#'.$id.'").select2({
closeOnSelect: '.(($select2_multiple_enable === true) ? 'false' : 'true').'
closeOnSelect: '.(($select2_multiple_enable === true) ? 'false' : 'true').',
placeholder: "'.$placeholder.'",
});';
if ($required !== false) {
@ -1758,6 +1760,7 @@ function html_print_select_multiple_modules_filtered(array $data):string
'multiple' => true,
'style' => 'min-width: 200px;max-width:200px;',
'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
'placeholder' => (isset($data['placeholderAgents']) === true) ? $data['placeholderAgents'] : '',
]
);
} else {
@ -1773,6 +1776,7 @@ function html_print_select_multiple_modules_filtered(array $data):string
'multiple' => true,
'style' => 'min-width: 200px;max-width:200px;',
'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
'placeholder' => (isset($data['placeholderAgents']) === true) ? $data['placeholderAgents'] : '',
]
);
}
@ -1888,7 +1892,8 @@ function html_print_select_from_sql(
$size=false,
$truncate_size=GENERIC_SIZE_TEXT,
$class='',
$required=false
$required=false,
$placeholder='',
) {
global $config;
@ -1931,7 +1936,12 @@ function html_print_select_from_sql(
$required,
$truncate_size,
true,
true
true,
false,
'',
false,
null,
$placeholder
);
}
@ -5680,7 +5690,9 @@ function html_print_input($data, $wrapper='div', $input_only=false)
((isset($data['select2_multiple_enable']) === true) ? $data['select2_multiple_enable'] : false),
((isset($data['select2_multiple_enable_all']) === true) ? $data['select2_multiple_enable_all'] : false),
((isset($data['form']) === true) ? $data['form'] : ''),
((isset($data['order']) === true) ? $data['order'] : false)
((isset($data['order']) === true) ? $data['order'] : false),
((isset($data['custom_id']) === true) ? $data['custom_id'] : null),
((isset($data['placeholder']) === true) ? $data['placeholder'] : null),
);
break;
@ -5700,7 +5712,8 @@ function html_print_input($data, $wrapper='div', $input_only=false)
((isset($data['size']) === true) ? $data['size'] : false),
((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT),
((isset($data['class']) === true) ? $data['class'] : ''),
((isset($data['required']) === true) ? $data['required'] : false)
((isset($data['required']) === true) ? $data['required'] : false),
((isset($data['placeholder']) === true) ? $data['placeholder'] : null),
);
break;

View File

@ -923,40 +923,7 @@ if (is_ajax()) {
);
}
$image_about = ui_get_full_url('/images/custom_logo/logo-default-pandorafms.png', false, false, false);
if (enterprise_installed() === false) {
if ($config['style'] === 'pandora_black') {
$image_about = 'images/custom_logo/'.HEADER_LOGO_BLACK_CLASSIC;
} else if ($config['style'] === 'pandora') {
$image_about = 'images/custom_logo/'.HEADER_LOGO_DEFAULT_CLASSIC;
}
} else {
if ($config['style'] === 'pandora_black' && $config['custom_logo'] === HEADER_LOGO_DEFAULT_CLASSIC) {
$config['custom_logo'] = HEADER_LOGO_BLACK_CLASSIC;
} else if ($config['style'] === 'pandora' && $config['custom_logo'] === HEADER_LOGO_BLACK_CLASSIC) {
$config['custom_logo'] = HEADER_LOGO_DEFAULT_CLASSIC;
}
$image_about = 'images/custom_logo/'.$config['custom_logo'];
if (file_exists(ENTERPRISE_DIR.'/'.$image_about) === true) {
$image_about = ENTERPRISE_DIR.'/'.$image_about;
}
}
if (is_metaconsole() === true) {
$image_about = ui_get_full_url('/enterprise/images/custom_logo/pandoraFMS_metaconsole_full.svg', false, false, false);
if ($config['meta_custom_logo'] === 'pandoraFMS_metaconsole_full.svg') {
$image_about = 'images/custom_logo/'.$config['meta_custom_logo'];
} else {
$image_about = '../images/custom_logo/'.$config['meta_custom_logo'];
}
if (file_exists(ENTERPRISE_DIR.'/'.$image_about) === true) {
$image_about = $image_about;
}
}
$image_about = ui_get_full_url('/images/custom_logo/logo-default-pandorafms-collapsed.svg', false, false, false);
$dialog = '
<div id="about-tabs" class="invisible overflow-hidden">
@ -977,8 +944,8 @@ if (is_ajax()) {
<tbody>
<tr>
<th style="width: 40%; border: 0px;">
<a href="https://pandorafms.com/" target="_blank">
<img src="'.$image_about.'" alt="logo" width="70%">
<a href="https://pandorafms.com/" target="_blank" class="header_center">
<img src="'.$image_about.'" alt="logo" width="50%">
</a>
</th>
<th style="width: 60%; text-align: left; border: 0px;">
@ -1290,42 +1257,7 @@ if (is_ajax()) {
$lts_name = ' <i>'.$config['lts_name'].'</i>';
}
$image_about = ui_get_full_url('/images/custom_logo/logo-default-pandorafms.png', false, false, false);
if (enterprise_installed() === false) {
if ($config['style'] === 'pandora_black') {
$image_about = 'images/custom_logo/'.HEADER_LOGO_BLACK_CLASSIC;
} else if ($config['style'] === 'pandora') {
$image_about = 'images/custom_logo/'.HEADER_LOGO_DEFAULT_CLASSIC;
}
} else {
if ($config['style'] === 'pandora_black' && $config['custom_logo'] === HEADER_LOGO_DEFAULT_CLASSIC) {
$config['custom_logo'] = HEADER_LOGO_BLACK_CLASSIC;
} else if ($config['style'] === 'pandora' && $config['custom_logo'] === HEADER_LOGO_BLACK_CLASSIC) {
$config['custom_logo'] = HEADER_LOGO_DEFAULT_CLASSIC;
}
$image_about = 'images/custom_logo/'.$config['custom_logo'];
if (file_exists(ENTERPRISE_DIR.'/'.$image_about) === true) {
$image_about = ENTERPRISE_DIR.'/'.$image_about;
}
}
if (is_metaconsole() === true) {
$image_about = ui_get_full_url('/enterprise/images/custom_logo/pandoraFMS_metaconsole_full.svg', false, false, false);
if ($config['meta_custom_logo'] === 'pandoraFMS_metaconsole_full.svg') {
$image_about = 'images/custom_logo/'.$config['meta_custom_logo'];
} else {
$image_about = '../images/custom_logo/'.$config['meta_custom_logo'];
}
if (file_exists(ENTERPRISE_DIR.'/'.$image_about) === true) {
$image_about = $image_about;
}
}
$image_about = ui_get_full_url('/images/custom_logo/logo-default-pandorafms-collapsed.svg', false, false, false);
$dialog = '
<div id="about-tabs" class="invisible overflow-hidden">
<ul>
@ -1339,7 +1271,7 @@ if (is_ajax()) {
<tr>
<th style="width: 40%; border: 0px;">
<a href="javascript:christmas_click('.$config['eastern_eggs_disabled'].')">
<img src="'.$image_about.'" alt="logo" width="70%">
<img src="'.$image_about.'" alt="logo" width="50%">
<input id="count_click" type="hidden" value="0" />
</a>
</th>

View File

@ -636,13 +636,15 @@ function notifications_get_user_label_status($source, $user, $label)
);
// Clean default common groups error for mesagges.
$group_enable = true;
if ($common_groups[0] === 0) {
unset($common_groups[0]);
$group_enable = false;
}
// No group found, return no permissions.
$value = empty($common_groups) ? false : $source[$label];
return notifications_build_user_enable_return($value, false);
return notifications_build_user_enable_return($value, $group_enable);
}
@ -674,14 +676,34 @@ function notifications_set_user_label_status($source, $user, $label, $value)
return false;
}
return (bool) db_process_sql_update(
'tnotification_source_user',
[$label => $value],
[
'id_user' => $user,
'id_source' => $source,
]
);
$exists = db_process_sql(sprintf('SELECT * FROM tnotification_source_user WHERE id_user = "%s" AND id_source = "%s"', $user, $source));
if (empty($exists['enabled']) && empty($exists['also_mail'])) {
$sql = sprintf('DELETE FROM tnotification_source_user WHERE id_user = "%s" AND id_source = "%s"', $user, $source);
db_process_sql($sql);
$exists = false;
}
if ($exists === false) {
db_process_sql_insert(
'tnotification_source_user',
[
'id_user' => $user,
'id_source' => $source,
'enabled' => '1',
'also_mail' => '1',
]
);
return true;
} else {
return (bool) db_process_sql_update(
'tnotification_source_user',
[$label => $value],
[
'id_user' => $user,
'id_source' => $source,
]
);
}
}
@ -1137,6 +1159,15 @@ function notifications_print_dropdown()
$mess = [];
}
$redirection_notifications = html_print_menu_button(
[
'href' => 'javascript:',
'class' => 'notification_menu_actions',
'text' => __('View all messages'),
'onClick' => "window.location='".ui_get_full_url('index.php?sec=message_list&sec2=operation/messages/message_list')."'",
],
true
);
$notification_menu = html_print_menu_button(
[
'href' => 'javascript:',
@ -1154,6 +1185,7 @@ function notifications_print_dropdown()
<div class='notificaion_menu_container'>
<div class='menu_tab filter_notification'>%s</div>
<div class='menu_tab notification_menu'>%s</div>
<div class='menu_tab notification_menu'>%s</div>
</div>
%s
</div>
@ -1166,6 +1198,7 @@ function notifications_print_dropdown()
",
$notification_filter,
$notification_menu,
$redirection_notifications,
array_reduce(
$mess,
function ($carry, $message) {

View File

@ -806,6 +806,10 @@ function edit_node(data_node, dblClick) {
var flag_edit_node = true;
var edit_node = null;
if (networkmap_write === 0) {
return false;
}
//Only select one node
var selection = d3_nm.selectAll(".node_selected");
var id;
@ -1950,6 +1954,10 @@ function init_minimap() {
// Context menu
////////////////////////////////////////////////////////////////////////
function show_menu(item, data) {
if (networkmap_write === 0) {
return false;
}
mouse = [];
mouse[0] = d3_nm.event.pageX;
mouse[1] = d3_nm.event.pageY;
@ -2819,6 +2827,10 @@ function cancel_set_parent() {
// OWN CODE FOR TO DRAG
////////////////////////////////////////////////////////////////////////
function init_drag_and_drop() {
if (networkmap_write === 0) {
return false;
}
window.dragables = svg.selectAll(".dragable_node");
window.drag_start = [0, 0];

View File

@ -1,3 +1,4 @@
/* global $ */
// Droppable options.
var droppableOptions = {
accept: ".draggable",
@ -422,12 +423,38 @@ $("[data-button=new]").click(function(e) {
});
});
function updateSelect(element, fields, selected) {
if (typeof fields === "object") {
$(element)
.find("select option[value!=0]")
.remove();
$(element)
.find(".select2-container .select2-selection__rendered")
.empty();
Object.keys(fields).forEach(function(key) {
if (key === selected) {
$(element)
.find(".select2-container .select2-selection__rendered")
.append(`${fields[key]}`);
$(element)
.find("select")
.append(`<option value="${key}" selected>${fields[key]}</option>`);
} else {
$(element)
.find("select")
.append(`<option value="${key}">${fields[key]}</option>`);
}
});
}
}
// Save graps modal.
$("[data-button=save]").click(function(e) {
// Filter save mode selector
$("#save_filter_row1").show();
$("#save_filter_row2").show();
$("#update_filter_row1").hide();
$("#delete_filter_row2").hide();
$("#radiobtn0002").prop("checked", false);
$("#radiobtn0001").prop("checked", true);
$("#text-id_name").val("");
@ -438,20 +465,43 @@ $("[data-button=save]").click(function(e) {
$("#save_filter_row2").show();
$("#submit-save_filter").show();
$("#update_filter_row1").hide();
} else {
$("#delete_filter_row2").hide();
} else if ($(this).val() == "update") {
$("#save_filter_row1").hide();
$("#save_filter_row2").hide();
$("#update_filter_row1").show();
$("#submit-save_filter").hide();
$("#delete_filter_row2").hide();
} else {
$("#save_filter_row1").hide();
$("#save_filter_row2").hide();
$("#update_filter_row1").hide();
$("#submit-save_filter").hide();
$("#delete_filter_row2").show();
}
});
$("#save-filter-select").dialog({
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true,
width: 350
$.ajax({
method: "POST",
url: "ajax.php",
dataType: "json",
data: {
page: "operation/reporting/graph_analytics",
load_list_filters: 1
},
success: function(data) {
if (data) {
updateSelect("#save_filter_form", data, 0);
$("#save-filter-select").dialog({
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true,
width: 350,
title: titleModalActions
});
}
}
});
});
@ -535,14 +585,67 @@ function save_update_filter() {
});
}
// Delete filter.
function delete_filter() {
confirmDialog({
title: titleDelete,
message: messageDelete,
onAccept: function() {
$.ajax({
method: "POST",
url: "ajax.php",
dataType: "html",
data: {
page: "operation/reporting/graph_analytics",
delete_filter: $("#delete_filter").val()
},
success: function(data) {
if (data == "deleted") {
confirmDialog({
title: titleDeleteConfirm,
message: messageDeleteConfirm,
hideCancelButton: true,
onAccept: function() {
$(
"button.ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close"
).click();
}
});
} else {
confirmDialog({
title: titleDeleteError,
message: messageDeleteError,
hideCancelButton: true
});
}
}
});
}
});
}
// Load graps modal.
$("[data-button=load]").click(function(e) {
$("#load-filter-select").dialog({
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true,
width: "auto"
$.ajax({
method: "POST",
url: "ajax.php",
dataType: "json",
data: {
page: "operation/reporting/graph_analytics",
load_list_filters: 1
},
success: function(data) {
if (data) {
updateSelect("#load_filter_form", data, 0);
$("#load-filter-select").dialog({
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true,
width: "auto"
});
}
}
});
});
@ -618,12 +721,26 @@ function loadFilter(url, filterId, homeurl, id) {
// Share button.
$("[data-button=share]").click(function(e) {
$("#share-select").dialog({
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true,
width: "auto"
$.ajax({
method: "POST",
url: "ajax.php",
dataType: "json",
data: {
page: "operation/reporting/graph_analytics",
load_list_filters: 1
},
success: function(data) {
if (data) {
updateSelect("#share_form-0-0", data, 0);
$("#share-select").dialog({
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true,
width: "auto"
});
}
}
});
});
@ -643,13 +760,27 @@ $("#button-share-modal").click(function(e) {
// Export button.
$("[data-button=export]").click(function(e) {
$("#export-select").dialog({
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true,
width: "auto",
title: titleExport
$.ajax({
method: "POST",
url: "ajax.php",
dataType: "json",
data: {
page: "operation/reporting/graph_analytics",
load_list_filters: 1
},
success: function(data) {
if (data) {
updateSelect("#export_form-0-0", data, 0);
$("#export-select").dialog({
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true,
width: "auto",
title: titleExport
});
}
}
});
});
@ -669,10 +800,10 @@ function exportCustomGraph() {
group
},
success: function(data) {
if (data) {
if (data === "created") {
confirmDialog({
title: titleExportConfirm,
message: data + " " + messageExportConfirm,
message: messageExportConfirm,
hideCancelButton: true,
onAccept: function() {
$(

View File

@ -2366,7 +2366,7 @@ $(document).ready(function() {
// Hidden tips modal.
$(".window").css("display", "none");
var type_about = "about_operation";
var type_about = "about";
if ($(this).attr("id") === "icon_about") {
type_about = "about";
}

View File

@ -8,7 +8,8 @@ function show_option_dialog(settings) {
modal: {
title: settings.title,
cancel: settings.btn_cancel,
ok: settings.btn_text
ok: settings.btn_text,
overlay: true
},
onshow: {
page: settings.url,
@ -22,6 +23,12 @@ function show_option_dialog(settings) {
method: "updateDashboard",
dataType: "json"
},
oncancel: {
reload: true
},
onclose: {
reload: true
},
ajax_callback: update_dashboard
});
}
@ -458,6 +465,12 @@ function initialiceLayout(data) {
}*/
function configurationWidget(cellId, widgetId, size) {
var reload = 0;
var overlay = false;
if (widgetId == 46) {
reload = 1;
overlay = true;
}
title = $("#hidden-widget_name_" + cellId).val();
load_modal({
target: $("#modal-config-widget"),
@ -466,7 +479,8 @@ function initialiceLayout(data) {
modal: {
title: "Configure widget " + title,
cancel: "Cancel",
ok: "Ok"
ok: "Ok",
overlay: overlay
},
onshow: {
page: data.page,
@ -484,8 +498,12 @@ function initialiceLayout(data) {
method: "saveWidgetIntoCell",
dataType: "json"
},
oncancel: {
reload: reload
},
ajax_callback: update_widget_to_cell,
onsubmitClose: 1
onsubmitClose: 1,
onsubmitReload: reload
});
}
@ -528,7 +546,7 @@ function initialiceLayout(data) {
$(".add-widget").show();
$(".new-widget-message").hide();
$("#container-layout").addClass("container-layout");
$("#add-widget").removeClass("invisible");
$("#add-widget").removeClass("invisible_important");
} else {
grid.movable(".grid-stack-item", false);
grid.resizable(".grid-stack-item", false);
@ -537,7 +555,7 @@ function initialiceLayout(data) {
$(".add-widget").hide();
$(".new-widget-message").show();
$("#container-layout").removeClass("container-layout");
$("#add-widget").addClass("invisible");
$("#add-widget").addClass("invisible_important");
}
});
@ -948,6 +966,11 @@ function processTreeSearch(settings) {
recipient: $("div#tree-controller-recipient_" + settings.cellId),
detailRecipient: {
render: function(element, data) {
let title = "Module information";
if ($(data).find("#tree_view_agent_detail-name").length > 0) {
title = "Agent information";
}
return {
open: function() {
$("#module_details_window")
@ -958,7 +981,7 @@ function processTreeSearch(settings) {
resizable: true,
draggable: true,
modal: true,
title: "Info module",
title: title,
overlay: {
opacity: 0.5,
background: "black"

View File

@ -1783,3 +1783,49 @@ function openEvents(severity) {
$('input[name="filter[severity]"]').val(severity);
$("#event_redirect").submit();
}
// Load Asteroids game.
$(window).on("load", function() {
let counter = 0;
$("#button-sound_events_button")
.off("click")
.on("click", function(e) {
counter++;
let flagEasternEgg = $("#flagEasternEgg").val();
if (counter == 12 && flagEasternEgg == true) {
$("#modal-asteroids")
.dialog({
title: "Asteroids",
resizable: true,
modal: true,
width: 900,
height: 700,
open: function() {
$.ajax({
method: "post",
url: getUrlAjax(),
data: {
page: "include/ajax/events",
playAsteroids: 1
},
dataType: "html",
success: function(data) {
$("#modal-asteroids").html(data);
$(".ui-widget-content").css("background", "#222");
$(".ui-dialog-title").css("color", "#fff");
},
error: function(error) {
console.error(error);
}
});
},
close: function() {
counter = 0;
$(".ui-widget-content").css("background", "#fff");
$(".ui-dialog-title").css("color", "rgb(51, 51, 51)");
}
})
.show();
}
});
});

View File

@ -160,6 +160,7 @@ function configure_modules_form() {
}
$("#id_module_group").val(data["id_module_group"]);
$("#id_module_group").trigger("change");
if (data["history_data"]) $("#checkbox-history_data").check();
else $("#checkbox-history_data").uncheck();

View File

@ -105,7 +105,16 @@ function load_modal(settings) {
}
if (settings.modal.overlay === true) {
$("body").append("<div id='modal_overlay'class='ui-widget-overlay'></div>");
var extraClass = "";
if (typeof settings.modal.overlayExtraClass !== "undefined") {
extraClass = " " + settings.modal.overlayExtraClass;
}
$("body").append(
"<div id='modal_overlay'class='ui-widget-overlay" +
extraClass +
"'></div>"
);
}
if (settings.beforeClose == undefined) {
@ -165,6 +174,8 @@ function load_modal(settings) {
if (typeof settings.oncancel.confirm == "function") {
//receive function
settings.oncancel.confirm(cancelModal);
} else if (settings.oncancel.reload == true) {
location.reload();
} else if (settings.oncancel != undefined) {
cancelModal();
}
@ -344,6 +355,13 @@ function load_modal(settings) {
AJAX_RUNNING = 0;
}
});
if (
settings.onsubmitReload != undefined &&
settings.onsubmitReload == true
) {
location.reload();
}
} else {
AJAX_RUNNING = 0;
}

View File

@ -1056,6 +1056,7 @@ class Manager implements PublicLogin
'name' => $name,
'id_user' => $id_user,
'id_group' => $id_group,
'cells' => 1,
'cells_slideshow' => $slideshow,
'active' => $favourite,
'date_range' => $dateRange,
@ -1367,6 +1368,7 @@ class Manager implements PublicLogin
global $config;
$items = \get_parameter('items', []);
$totalCells = 0;
// Class Dashboard.
if (empty($items) === false) {
@ -1398,8 +1400,15 @@ class Manager implements PublicLogin
return false;
}
}
if (is_array($items) === true) {
$totalCells = count($items);
}
}
$values = ['cells' => $totalCells];
$this->put($values);
echo json_encode($result);
}

View File

@ -246,6 +246,10 @@ class EventsListWidget extends Widget
$values['groupRecursion'] = $decoder['groupRecursion'];
}
if (isset($decoder['secondaryGroup']) === true) {
$values['secondaryGroup'] = $decoder['secondaryGroup'];
}
if (isset($decoder['customFilter']) === true) {
$values['customFilter'] = $decoder['customFilter'];
}
@ -456,6 +460,18 @@ class EventsListWidget extends Widget
],
];
// Secondary group.
$inputs['inputs']['row2'][] = [
'label' => \__('Secondary group'),
'arguments' => [
'type' => 'switch',
'name' => 'secondaryGroup',
'class' => 'event-widget-input',
'value' => $values['secondaryGroup'],
'return' => true,
],
];
// Group recursion.
$inputs['inputs']['row2'][] = [
'label' => \__('Group recursion'),
@ -537,6 +553,7 @@ class EventsListWidget extends Widget
$values['groupId'] = \get_parameter_switch('groupId', []);
$values['tagsId'] = \get_parameter_switch('tagsId', []);
$values['groupRecursion'] = \get_parameter_switch('groupRecursion', 0);
$values['secondaryGroup'] = \get_parameter('secondaryGroup', 0);
$values['customFilter'] = \get_parameter('customFilter', -1);
$values['columns_events_widget'] = \get_parameter('columns_events_widget', []);
@ -721,6 +738,7 @@ class EventsListWidget extends Widget
$this->values['limit'] = $config['block_size'];
}
$filter['search_secondary_groups'] = $this->values['secondaryGroup'];
// Print datatable.
$output .= ui_print_datatable(
[

View File

@ -293,6 +293,8 @@ class GroupsStatusWidget extends Widget
(bool) $this->values['groupRecursion']
);
$style = 'min-width:200px; min-height:460px;';
$data = '<div class="widget-groups-status"><span>';
$data .= ui_print_group_icon(
$this->values['groupId'],
@ -541,9 +543,9 @@ class GroupsStatusWidget extends Widget
$table->data[1][0] = __('Not agents in this group');
$data .= html_print_table($table, true);
$data .= '</div>';
$style .= 'justify-content: start; margin-top: 20px';
}
$style = 'min-width:200px; min-height:460px;';
$output = '<div class="container-center" style="'.$style.'">';
$output .= $data;
$output .= '</div>';

View File

@ -177,6 +177,9 @@ class InventoryWidget extends Widget
// Must be configured before using.
$this->configurationRequired = false;
if (isset($this->values['idGroup']) === false) {
$this->configurationRequired = true;
}
}
@ -296,9 +299,12 @@ class InventoryWidget extends Widget
];
$fields = [];
array_unshift($fields, __('All'));
if (isset($values['inventoryModuleId']) === false) {
$values['inventoryModuleId'] = 0;
}
$inputs[] = [
'label' => __('Module'),
'arguments' => [
@ -316,31 +322,6 @@ class InventoryWidget extends Widget
],
];
// Agent select.
if ($is_metaconsole === false) {
$agents = [];
$sql = 'SELECT id_agente, nombre FROM tagente';
if ($inventory_id_group > 0) {
$sql .= ' WHERE id_grupo = '.$inventory_id_group;
} else {
$user_groups = implode(',', array_keys(users_get_groups($config['id_user'])));
// Avoid errors if there are no groups.
if (empty($user_groups) === true) {
$user_groups = '"0"';
}
$sql .= ' WHERE id_grupo IN ('.$user_groups.')';
}
$result = db_get_all_rows_sql($sql);
if ($result) {
foreach ($result as $row) {
$agents[$row['id_agente']] = $row['nombre'];
}
}
}
// Date filter.
if (is_metaconsole() === false) {
$inputs[] = [

View File

@ -252,7 +252,7 @@ class SecurityHardening extends Widget
];
$inputs[] = [
'label' => __('Ingore skipped'),
'label' => __('Ignore skipped'),
'id' => 'row_ignore_skipped',
'class' => 'row_input',
'arguments' => [
@ -274,9 +274,9 @@ class SecurityHardening extends Widget
'name' => 'range',
'type' => 'date_range',
'selected' => 'chose_range',
'date_init' => date('Y-m-d', $values['date_init']),
'date_init' => date('Y/m/d', $values['date_init']),
'time_init' => date('H:i:s', $values['date_init']),
'date_end' => date('Y-m-d', $values['date_end']),
'date_end' => date('Y/m/d', $values['date_end']),
'time_end' => date('H:i:s', $values['date_end']),
'return' => true,
],

View File

@ -436,12 +436,16 @@ class Agents extends Element
$percentages = [];
$total = array_sum($data);
foreach ($data as $key => $value) {
$percentage = (($value / $total) * 100);
if ($percentage < 1 && $percentage > 0) {
$percentage = 1;
}
if ($total > 0) {
$percentage = (($value / $total) * 100);
if ($percentage < 1 && $percentage > 0) {
$percentage = 1;
}
$percentages[$key] = format_numeric($percentage, 0);
$percentages[$key] = format_numeric($percentage, 0);
} else {
$percentages[$key] = '0%';
}
}
$data = $percentages;

View File

@ -113,8 +113,9 @@ class Groups extends Element
$id_groups = implode(',', $id_groups);
$modules = modules_get_modules_in_group($id_groups);
$total_groups = count($modules);
$total_groups = ($modules !== false) ? count($modules) : 0;
if ($total_groups === 0) {
include_once $config['homedir'].'/include/functions_graph.php';
return graph_nodata_image(['width' => '400']);
}
@ -484,7 +485,7 @@ class Groups extends Element
$y = 0;
$cont = 1;
foreach ($groups as $key => $value) {
if ($value['_name_'] === 'All') {
if ($value['_name_'] === __('All')) {
continue;
}

View File

@ -156,13 +156,15 @@ class ScheduledDowntime extends Element
'cron_interval_from',
'cron_interval_to',
];
$groups = implode(',', array_keys(users_get_groups($config['user'])));
$columns_str = implode(',', $columns);
$sql = sprintf(
'SELECT %s
FROM tplanned_downtime
WHERE id_group IN (%s)
%s %s',
$columns_str,
$groups,
$order,
$pagination,
);

View File

@ -0,0 +1,65 @@
/**
*
* Name: Default theme
* Pandora Stylesheet
*
* @category Stylesheet
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 Pandora FMS
* Please see https://pandorafms.com 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.
* ============================================================================
*/
div#asteroids {
background-color: #000;
color: #fff;
margin: 50px auto;
width: 640px;
border: 1px solid #fff;
padding: 5px;
}
div#asteroids > * {
color: #fff;
}
div#asteroids > div {
font-family: "System", monospace;
font-size: 11px;
padding-bottom: 5px;
}
div#asteroids > div > span {
float: right;
padding-left: 20px;
}
div#instructions {
width: 640px;
margin: 20px auto;
}
h1 {
font-size: 18px;
}
h2 {
font-size: 16px;
}

View File

@ -0,0 +1,16 @@
#div-filtered-module-group-modules,
#div-filtered-module-module-group-modules,
#div-filtered-module-agents-modules,
#div-filtered-module-modules-modules {
width: 37% !important;
}
#div-filtered-module-modules-modules select {
width: 100% !important;
max-width: 100% !important;
}
#select_multiple_modules_filtered > div > div > .select2 {
width: 100% !important;
}
#select_multiple_modules_filtered > div {
flex-wrap: nowrap !important;
}

View File

@ -129,6 +129,12 @@ table#table_events > tbody > tr > td.column-estado {
padding: 0px !important;
text-align: center;
}
@-moz-document url-prefix() {
table#table_events > tbody > tr,
table#table_events > tbody > tr > td {
height: 100%;
}
}
.sorting_desc {
background: url(../../images/sort_down_green.png) no-repeat;
background-position-x: left;
@ -544,7 +550,7 @@ div#main_pure:has(.events-pure) {
margin-bottom: 50px !important;
}
div#sunburst > svg {
#main > #container_servicemap > div#sunburst > svg {
width: 750px;
height: 750px;
}

View File

@ -80,7 +80,7 @@
}
#welcome_form li.hole {
margin-bottom: 0.8em;
margin-bottom: 10px;
}
#welcome_form li.extra {
@ -98,17 +98,424 @@
font-weight: bold;
}
button.buttonButton.onlyIcon.fail,
button.submitButton.onlyIcon.fail {
mask: url(../../images/fail@svg.svg) no-repeat center / contain;
-webkit-mask: url(../../images/fail@svg.svg) no-repeat center / contain;
}
.select2-container .select2-container--default .select2-container--open {
z-index: 2000;
}
#div_wizard_agent > .select2 {
width: 75% !important;
max-width: 75% !important;
.ui-widget-overlay.welcome-overlay {
background-color: rgba(19, 23, 39, 0.8) !important;
opacity: 1 !important;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"] {
background-color: #131727;
border-radius: 8px !important;
border: 0;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"] * {
color: #fff;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"]
.ui-dialog-titlebar {
margin: 0;
padding-top: 25px;
padding-bottom: 0px;
padding-left: 20px;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"]
.ui-dialog-title {
font-size: 40px;
line-height: 48px;
margin: 0;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"]
.ui-dialog-titlebar-close {
background-color: #95a3bf !important;
right: 20px !important;
}
div#welcome_modal_window {
padding: 0px 0px 0px 20px;
display: flex !important;
flex-direction: row;
flex-wrap: nowrap;
align-items: flex-end;
justify-content: space-between;
}
div#welcome_modal_window[style=""] {
display: none !important;
}
div#welcome_modal_window .wizard * {
font-weight: bold;
}
div#welcome_modal_window .wizard li#li-div_diagnosis,
div#welcome_modal_window .wizard li#li-div_task_todo,
div#welcome_modal_window .wizard li#li-div_wizard_agent {
padding-left: 0;
}
/* div#welcome_modal_window .wizard li#li-div_diagnosis {
top: 0;
position: absolute;
} */
div#welcome_modal_window .wizard li#li-div_diagnosis label {
font-size: 17px;
line-height: 20px;
color: #c1ccdc;
padding: 20px 0px;
font-weight: normal;
}
div#welcome_modal_window
.wizard
li:not(:nth-child(1)):not(:nth-last-child(1)):not(:nth-last-child(2)) {
padding: 14px 15px;
box-sizing: border-box;
background-color: rgba(0, 0, 0, 0.2);
border: 1px solid #c1ccdc;
border-radius: 6px;
width: 480px;
height: 50px;
}
div#welcome_modal_window
.wizard
li:not(:nth-child(1)):not(:nth-last-child(1)):not(:nth-last-child(2))
label {
font-size: 17px;
line-height: 20px;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
}
div#welcome_modal_window
.wizard
li:not(:nth-child(1)):not(:nth-last-child(1)):not(:nth-last-child(2))
label {
font-size: 17px;
line-height: 20px;
font-weight: normal;
}
div#welcome_modal_window .wizard .status {
background-color: #c1ccdc;
opacity: 0.2;
display: block;
width: 20px;
height: 20px;
margin-right: 15px;
border-radius: 14px / 7px;
}
div#welcome_modal_window .wizard li.row_green .status {
background-color: #82b92e;
opacity: 1;
}
div#welcome_modal_window .wizard .fail.onlyIcon.buttonButton {
background-color: unset;
width: unset !important;
}
div#welcome_modal_window .wizard .fail.onlyIcon.buttonButton span {
color: #26b1b5;
font-size: 15px;
line-height: 20px;
}
div#welcome_modal_window .wizard .fail.onlyIcon.buttonButton:hover span {
color: #3bdce1;
}
div#welcome_modal_window .wizard #li-div_all_correct {
height: 100%;
margin-bottom: 145px;
}
div#welcome_modal_window .wizard #li-div_all_correct * {
font-size: 10pt;
}
div#welcome_modal_window .wizard #li-div_task_todo {
padding-bottom: 2px;
}
div#welcome_modal_window .wizard #li-div_task_todo label {
font-size: 13px;
line-height: 16px;
color: #c1ccdc;
}
div#welcome_modal_window .wizard #li-div_wizard_agent {
width: 480px;
}
div#welcome_modal_window .wizard #li-div_wizard_agent > div {
width: 100%;
}
div#welcome_modal_window .wizard #li-div_wizard_agent .select2-selection {
background-color: #f6f7fb !important;
border: 1px solid #c0ccdc !important;
border-radius: 6px !important;
width: 290px;
height: 42px !important;
font-weight: normal !important;
}
div#welcome_modal_window .wizard #li-div_wizard_agent .select2 {
width: 290px !important;
}
div#welcome_modal_window
.wizard
#li-div_wizard_agent
.select2-selection
.select2-selection__rendered {
font-weight: normal !important;
line-height: 38px !important;
}
div#welcome_modal_window .wizard #button-go_wizard {
background-color: #82b92e;
border: 0;
border-radius: 8px;
padding-top: 11px;
padding-bottom: 11px;
padding-left: 38px;
height: 42px;
width: 175px;
}
div#welcome_modal_window .wizard #button-go_wizard:hover {
background-color: #8ac531;
}
div#welcome_modal_window .wizard #button-go_wizard span {
font-size: 15px;
line-height: 20px;
text-wrap: nowrap;
}
div#welcome_modal_window .wizard #button-go_wizard div.next {
mask: url(../../images/check-white.svg) no-repeat center / contain;
-webkit-mask: url(../../images/check-white.svg) no-repeat center / contain;
background-color: #fff !important;
height: 12px;
margin-left: 12px;
margin-right: 20px;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"]
.ui-dialog-buttonpane.ui-widget-content {
background-color: #131727;
padding: 10px 10px 10px 20px !important;
margin: 0;
border-top: 1px solid #8190ad;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"]
.ui-dialog-buttonpane.ui-widget-content
.ui-dialog-buttonset {
justify-content: space-between;
display: none;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"]
.welcome-wizard-buttons,
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"]
.welcome-wizard-buttons
label {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
flex-wrap: nowrap;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"]
.welcome-wizard-buttons
label {
font-size: 15px;
line-height: 18px;
cursor: pointer;
font-weight: normal;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"]
.welcome-wizard-buttons
label
input[type="checkbox"] {
margin-right: 10px;
width: 20px;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"]
.ui-dialog-buttonpane.ui-widget-content
.ui-dialog-buttonset {
justify-content: space-between;
display: none;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"]
.ui-dialog-buttonpane.ui-widget-content
button {
background-color: #313b62;
box-shadow: none;
border: 0;
border-radius: 8px;
height: 42px;
width: unset;
padding: 10px 20px;
font-size: 15px;
line-height: 20px;
font-weight: bold;
margin: 0;
}
div.ui-widget.ui-widget-content[aria-describedby="welcome_modal_window"]
.ui-dialog-buttonpane.ui-widget-content
button:hover {
background-color: #384372;
}
.welcome-wizard-right-content {
background-image: linear-gradient(225deg, #731dd8 0%, #2eb9b8 100%);
border-radius: 100px 0 0;
width: 432px;
height: 375px;
margin-bottom: 8px;
}
.welcome-wizard-right-content img {
width: 348px;
height: 260px;
position: absolute;
right: 43px;
bottom: 65px;
filter: drop-shadow(0 0 10px #0000005b);
}
/* Background bubbles */
.welcome-circles {
overflow: hidden;
position: absolute;
right: 0;
position: absolute;
bottom: 8px;
width: 430px;
height: 373px;
overflow: hidden;
border-top-left-radius: 100px;
}
.welcome-circles li {
position: absolute;
display: block;
list-style: none;
width: 20px;
height: 20px;
background: rgba(255, 255, 255, 0.2);
animation: animate 10s linear infinite;
bottom: -150px;
}
.welcome-circles li:nth-child(1) {
left: 25%;
width: 10px;
height: 10px;
animation-delay: 0s;
}
.welcome-circles li:nth-child(2) {
left: 10%;
width: 20px;
height: 20px;
animation-delay: 2s;
animation-duration: 12s;
}
.welcome-circles li:nth-child(3) {
left: 70%;
width: 15px;
height: 15px;
animation-delay: 4s;
}
.welcome-circles li:nth-child(4) {
left: 40%;
width: 60px;
height: 60px;
animation-delay: 3s;
animation-duration: 6s;
}
.welcome-circles li:nth-child(5) {
left: 65%;
width: 15px;
height: 15px;
animation-delay: 0s;
}
.welcome-circles li:nth-child(6) {
left: 75%;
width: 30px;
height: 30px;
animation-delay: 3s;
}
.welcome-circles li:nth-child(7) {
left: 35%;
width: 50px;
height: 50px;
animation-delay: 7s;
}
.welcome-circles li:nth-child(8) {
left: 50%;
width: 25px;
height: 25px;
animation-delay: 15s;
animation-duration: 45s;
}
.welcome-circles li:nth-child(9) {
left: 20%;
width: 15px;
height: 15px;
animation-delay: 2s;
animation-duration: 35s;
}
.welcome-circles li:nth-child(10) {
left: 85%;
width: 50px;
height: 50px;
animation-delay: 0s;
animation-duration: 11s;
}
@keyframes animate {
0% {
transform: translateY(0) rotate(0deg);
opacity: 1;
border-radius: 0;
}
100% {
transform: translateY(-1000px) rotate(720deg);
opacity: 0;
border-radius: 50%;
}
}

View File

@ -481,6 +481,11 @@ select:-internal-list-box {
max-width: 120px;
}
.w130px {
width: 130px;
max-width: 130px;
}
.w200px {
width: 200px;
max-width: 200px;
@ -598,6 +603,10 @@ select:-internal-list-box {
min-width: 120px;
}
.mw130px {
min-width: 130px;
}
.mw180px {
min-width: 180px;
}
@ -985,6 +994,12 @@ select:-internal-list-box {
justify-content: flex-start !important;
}
.flex-column-start {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.padding-2 {
padding: 2em;
}
@ -5530,6 +5545,11 @@ input:checked + .p-slider:before {
color: #4d4d4d;
}
.show-profiles {
position: absolute;
margin-left: 15%;
}
/* Tables to upload files */
#table_filemanager tr:first-child th span {
font-weight: bold;
@ -7056,6 +7076,10 @@ div.graph div.legend table {
margin: 0 1em 0 2em;
}
.mrgn_top_btn_10px_imp {
margin: 10px 0 10px 0 !important;
}
/*
* MARGIN LEFT
*/
@ -7217,6 +7241,10 @@ div.graph div.legend table {
margin-top: 0px;
}
.mrgn_top_mod_0px {
margin-top: 0px !important;
}
.mrgn_top_5px {
margin-top: 5px;
}
@ -11843,7 +11871,7 @@ p.trademark-copyright {
}
.show-hide-pass {
position: fixed;
position: absolute;
border: 0;
outline: none;
margin-left: -50px;
@ -12062,6 +12090,10 @@ div.relative > div > div#ui-datepicker-div {
left: 5px !important;
}
#ui-datepicker-div .ui-datepicker-header {
background-color: white;
}
.ui-widget-overlay {
background: #aaa;
opacity: 0.3 !important;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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

View File

@ -1061,19 +1061,20 @@ $buttons .= html_print_button(
],
true
);
$buttons .= html_print_button(
__('Manage filter'),
'save-filter',
false,
'',
[
'icon' => 'wand',
'mode' => 'mini secondary',
'class' => 'float-left margin-right-2 sub wand',
],
true
);
if (check_acl($config['id_user'], 0, 'AW')) {
$buttons .= html_print_button(
__('Manage filter'),
'save-filter',
false,
'',
[
'icon' => 'wand',
'mode' => 'mini secondary',
'class' => 'float-left margin-right-2 sub wand',
],
true
);
}
$filters .= html_print_div(
[
@ -1450,7 +1451,12 @@ if ($autosearch) {
}
if ($count_modules > $config['block_size']) {
$tablePagination = ui_pagination($count_modules, false, $offset, 0, true, 'offset', false);
$show_count = false;
if (is_metaconsole() === true) {
$show_count = true;
}
$tablePagination = ui_pagination($count_modules, false, $offset, 0, true, 'offset', $show_count);
}
// Get number of elements of the pagination.
@ -2346,11 +2352,19 @@ if (empty($result) === false) {
array_push($table->data, $data);
}
echo '<div class="total_pages">'.sprintf(__('Total items: %s'), $count).'</div>';
if (!defined('METACONSOLE')) {
echo '<div class="total_pages">'.sprintf(__('Total items: %s'), $count).'</div>';
}
html_print_table($table);
if ($count_modules > $config['block_size']) {
$tablePagination = ui_pagination($count_modules, false, $offset, 0, true, 'offset', false);
$show_count = false;
if (is_metaconsole() === true) {
$show_count = true;
}
$tablePagination = ui_pagination($count_modules, false, $offset, 0, true, 'offset', $show_count);
}
} else {
ui_print_info_message(['no_close' => true, 'message' => __('Please apply a filter to display the data')]);

View File

@ -641,32 +641,17 @@ if (is_ajax() === true) {
}
if (empty($user_timezone) === true) {
if (date_default_timezone_get() !== $config['timezone']) {
$timezone = timezone_open(date_default_timezone_get());
$datetime_eur = date_create('now', timezone_open($config['timezone']));
$dif = timezone_offset_get($timezone, $datetime_eur);
date($config['date_format'], $dif);
if (!date('I')) {
// For summer -3600sec.
$dif -= 3600;
}
$total_sec = strtotime($tmp->timestamp);
$total_sec += $dif;
$last_contact = date($config['date_format'], $total_sec);
$last_contact_value = ui_print_timestamp($last_contact, true, $options);
} else {
$title = date($config['date_format'], strtotime($tmp->timestamp));
$value = ui_print_timestamp(strtotime($tmp->timestamp), true, $options);
$last_contact_value = '<span title="'.$title.'">'.$value.'</span>';
$user_timezone = $config['timezone'];
if (empty($user_timezone) === true) {
$user_timezone = date_default_timezone_get();
}
} else {
date_default_timezone_set($user_timezone);
$title = date($config['date_format'], strtotime($tmp->timestamp));
$value = ui_print_timestamp(strtotime($tmp->timestamp), true, $options);
$last_contact_value = '<span title="'.$title.'">'.$value.'</span>';
}
date_default_timezone_set($user_timezone);
$title = date($config['date_format'], $tmp->utimestamp);
$value = ui_print_timestamp($tmp->utimestamp, true, $options);
$last_contact_value = '<span title="'.$title.'">'.$value.'</span>';
$tmp->timestamp = $last_contact_value;
if (is_numeric($tmp->data) === true) {

View File

@ -603,6 +603,7 @@ if ($access_console_node === true) {
$sub[$javascript]['type'] = 'direct';
echo '<div id="modal-sound" style="display:none;"></div>';
echo '<div id="modal-asteroids" style="display:none;"></div>';
ui_require_javascript_file('pandora_events');

View File

@ -45,8 +45,10 @@ if (is_ajax()) {
$save_filter = get_parameter('save_filter');
$load_filter = get_parameter('load_filter');
$update_filter = get_parameter('update_filter');
$delete_filter = get_parameter('delete_filter');
$get_new_values = get_parameter('get_new_values');
$export_filter = get_parameter('export_filter');
$load_list_filters = get_parameter('load_list_filters');
if (empty($search_left) === false) {
$output = [];
@ -289,6 +291,11 @@ if (is_ajax()) {
return;
}
if (empty($delete_filter) === false) {
$result = db_process_sql_delete('tgraph_analytics_filter', ['id' => $delete_filter]);
echo ((bool) $result === true) ? 'deleted' : '';
}
// Get new values.
if (empty($get_new_values) === false) {
$data = [];
@ -322,19 +329,19 @@ if (is_ajax()) {
$graphs = json_decode(db_get_value('graph_modules', 'tgraph_analytics_filter', 'id', $filter));
$interval = db_get_value('tgraph_analytics_filter.interval', 'tgraph_analytics_filter', 'id', $filter);
foreach ($graphs as $graph) {
$id_graph = db_process_sql_insert(
'tgraph',
[
'id_user' => $config['id_user'],
'id_group' => $group,
'name' => $filter_name.' ('.__('Graph').' '.($counter + 1).')',
'description' => __('Created from Graph analytics. Filter:').' '.$filter_name.'. '.__('Graph').' '.($counter + 1),
'period' => $interval,
'stacked' => 2,
]
);
$id_graph = db_process_sql_insert(
'tgraph',
[
'id_user' => $config['id_user'],
'id_group' => $group,
'name' => $filter_name.' ('.__('Graph').') ',
'description' => __('Created from Graph analytics. Filter:').' '.$filter_name.'. '.__('Graph'),
'period' => $interval,
'stacked' => 2,
]
);
foreach ($graphs as $graph) {
if ($id_graph > 0) {
$counter++;
$field_order = 1;
@ -357,7 +364,16 @@ if (is_ajax()) {
}
}
echo $counter;
if ($id_graph > 0) {
echo 'created';
} else {
echo '';
}
}
if (empty($load_list_filters) === false) {
$filters = graph_analytics_filter_select();
echo json_encode($filters);
}
return;
@ -384,7 +400,7 @@ if (check_acl($config['id_user'], 0, 'RW') === 1 || check_acl($config['id_user']
'content' => html_print_radio_button(
'filter_mode',
'new',
__('New filter'),
__('Create'),
true,
true
),
@ -398,7 +414,21 @@ if (check_acl($config['id_user'], 0, 'RW') === 1 || check_acl($config['id_user']
'content' => html_print_radio_button(
'filter_mode',
'update',
__('Update filter'),
__('Update'),
false,
true
),
],
true
);
$data[2] = html_print_div(
[
'style' => 'display: flex;',
'content' => html_print_radio_button(
'filter_mode',
'delete',
__('Delete'),
false,
true
),
@ -466,7 +496,37 @@ if (check_acl($config['id_user'], 0, 'RW') === 1 || check_acl($config['id_user']
);
$table->data[] = $data;
$table->rowclass[] = '';
$table->rowclass[] = 'display-grid';
$data = [];
$table->rowid[4] = 'delete_filter_row2';
$data[0] = __('Delete filter');
$select_filters_delete = graph_analytics_filter_select();
$data[0] .= html_print_select(
$select_filters_delete,
'delete_filter',
'',
'',
'',
0,
true
);
$data[1] = html_print_submit_button(
__('Delete filter'),
'delete_filter',
false,
[
'class' => 'mini ',
'icon' => 'delete',
'style' => 'margin-left: 155px; width: 145px;',
'onclick' => 'delete_filter();',
],
true
);
$table->data[] = $data;
html_print_table($table);
} else {
@ -583,7 +643,7 @@ echo '</div>';
echo '<div id="export-select" class="load-filter-modal invisible">';
$table = new StdClass;
$table->id = 'share_form';
$table->id = 'export_form';
$table->width = '100%';
$table->cellspacing = 4;
$table->cellpadding = 4;
@ -771,30 +831,31 @@ $left_content .= '
</div>
<div class="filters-div-submain">
<div class="filter-div filters-left-div">
<span><b>'.__('Agents').'</b></span>
<input id="search-left" name="search-left" placeholder="Enter keywords to search" type="search" class="search-graph-analytics">
<br>
'.ui_toggle(
'',
__('Agents'),
'agents-toggle',
'agents-toggle',
true,
true,
'',
'white-box-content',
'box-flat white_table_graph',
'images/arrow@svg.svg',
'images/arrow@svg.svg',
false,
false,
false,
'',
'',
null,
null,
false,
false,
'static'
'',
__('Agents'),
'agents-toggle',
'agents-toggle',
true,
true,
'',
'white-box-content',
'box-flat white_table_graph',
'images/arrow@svg.svg',
'images/arrow@svg.svg',
false,
false,
false,
'',
'',
null,
null,
false,
false,
'static'
).ui_toggle(
'',
__('Groups'),
@ -842,6 +903,7 @@ $left_content .= '
).'
</div>
<div class="filter-div filters-right-div ">
<span><b>'.__('Modules').'</b></span>
<input id="search-right" placeholder="Enter keywords to search" type="search" class="search-graph-analytics">
<input id="search-agent" type="hidden" value="">
<input id="search-group" type="hidden" value="">
@ -920,6 +982,15 @@ const titleError = "<?php echo __('Error'); ?>";
const titleUpdate = "<?php echo __('Override filter?'); ?>";
const messageUpdate = "<?php echo __('Do you want to overwrite the filter?'); ?>";
const titleDelete = "<?php echo __('Delete filter?'); ?>";
const messageDelete = "<?php echo __('Do you want to delete the filter?'); ?>";
const titleDeleteConfirm = "<?php echo __('Deleted successfully'); ?>";
const messageDeleteConfirm = "<?php echo __('The filter has been deleted successfully'); ?>";
const titleDeleteError = "<?php echo __('Error'); ?>";
const messageDeleteError = "<?php echo __('It is not possible delete the filter'); ?>";
const titleUpdateConfirm = "<?php echo __('Updated successfully'); ?>";
const messageUpdateConfirm = "<?php echo __('The filter has been updated successfully'); ?>";
@ -935,7 +1006,7 @@ const messageLoadConfirm = "<?php echo __('Error loading filter'); ?>";
const titleExport = "<?php echo __('Export to custom graph'); ?>";
const titleExportConfirm = "<?php echo __('Exported successfully'); ?>";
const messageExportConfirm = "<?php echo __('graphs have been created in Custom graphs'); ?>";
const messageExportConfirm = "<?php echo __('Graph have been created in Custom graphs'); ?>";
const titleExportError = "<?php echo __('Error to export'); ?>";
const messageExportError = "<?php echo __('Filter cannot be None'); ?>";
@ -943,4 +1014,6 @@ const messageExportError = "<?php echo __('Filter cannot be None'); ?>";
const titleRemoveConfirm = "<?php echo __('Delete graph'); ?>";
const messageRemoveConfirm = "<?php echo __('Do you want to delete the graph? Remember to save the changes.'); ?>";
const titleModalActions = "<?php echo __('Filter actions'); ?>"
</script>

View File

@ -170,12 +170,26 @@ if ($searchAgents) {
}
foreach ($agents as $key => $agent) {
$agent_quiet = '';
if ((bool) $agent['quiet'] === true) {
$agent_quiet = html_print_image(
'images/dot_blue.png',
true,
[
'border' => '0',
'title' => __('Quiet'),
'alt' => '',
'class' => 'mrgn_lft_5px',
]
);
}
if ($agent['disabled']) {
$agents[$key]['agent'] = '<em><a style href=index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'
title="'.$agent['id_agente'].'"><b><span style>'.ucfirst(strtolower($agent['alias'])).'</span></b></a>'.ui_print_help_tip(__('Disabled'), true).'</em>';
title="'.$agent['id_agente'].'"><b><span style>'.ucfirst(strtolower($agent['alias'])).'</span></b></a>'.ui_print_help_tip(__('Disabled'), true).'</em>'.$agent_quiet;
} else {
$agents[$key]['agent'] = '<a style href=index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'
title='.$agent['nombre'].'><b><span style>'.ucfirst(strtolower($agent['alias'])).'</span></b></a>';
title='.$agent['nombre'].'><b><span style>'.ucfirst(strtolower($agent['alias'])).'</span></b></a>'.$agent_quiet;
}
$agents[$key]['os'] = ui_print_os_icon($agent['id_os'], false, true);

View File

@ -33,7 +33,7 @@ foreach ($arrayKeywords as $keyword) {
array_push($temp, '%'.$keyword.'%');
}
$stringSearchSQL = implode('&#x20;', $temp);
$stringSearchSQL = implode('', $temp);
$stringSearchSQL = str_replace('_', '\_', $stringSearchSQL);
$_SESSION['stringSearchSQL'] = $stringSearchSQL;
@ -206,7 +206,7 @@ ui_print_standard_header(
);
$only_count = false;
hd(io_safe_input($_SESSION['stringSearchSQL']), true);
switch ($searchTab) {
case 'main':
$only_count = true;

View File

@ -6,7 +6,7 @@
%define debug_package %{nil}
%define name pandorafms_console
%define version 7.0NG.775
%define release 240117
%define release 240119
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -6,7 +6,7 @@
%define debug_package %{nil}
%define name pandorafms_console
%define version 7.0NG.775
%define release 240117
%define release 240119
# User and Group under which Apache is running
%define httpd_name httpd

View File

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

View File

@ -1294,7 +1294,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` (
`section` TEXT,
`data_section` TEXT,
`metaconsole_section` VARCHAR(255) NOT NULL DEFAULT 'Default',
`metaconsole_data_section` VARCHAR(255) NOT NULL DEFAULT '',
`metaconsole_data_section` TEXT,
`force_change_pass` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`last_pass_change` DATETIME,
`last_failed_login` DATETIME,

View File

@ -2841,8 +2841,8 @@ INSERT INTO `treport_content` (`id_rc`,`id_report`,`id_gs`,`id_agent_module`,`ty
(2,1,0,0,'top_n',28800,0,2,'Top&#x20;CPU&#x20;per&#x20;agent','',0,'&lt;p&gt;This&#x20;type&#x20;of&#x20;report&#x20;implies&#x20;loading&#x20;a&#x20;lot&#x20;of&#x20;data.&#x20;Therefore&#x20;it&#x20;is&#x20;recommended&#x20;for&#x20;scheduled&#x20;reports,&#x20;not&#x20;real-time&#x20;view.&lt;/p&gt;',NULL,0,'','','','00:00:00','00:00:00',1,1,1,1,1,1,1,0,3,10,0,10,0,1,1,0,'{&quot;show_in_same_row&quot;:0,&quot;hide_notinit_agents&quot;:0,&quot;priority_mode&quot;:&quot;1&quot;,&quot;dyn_height&quot;:&quot;250&quot;,&quot;text_agent&quot;:&quot;Lio=&quot;,&quot;text_agent_module&quot;:&quot;Y3B1Lio=&quot;}',0,0,'',0,0,300,0,0,NULL,NULL,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,NULL,NULL,1,0,0,NULL),
(3,1,0,0,'event_report_group',21600,0,3,'General&#x20;event&#x20;report','This&#x20;is&#x20;a&#x20;sample&#x20;of&#x20;not&#x20;normal&#x20;events&#x20;for&#x20;any&#x20;agent&#x20;available&#x20;in&#x20;the&#x20;last&#x20;6&#x20;hours',0,'&lt;p&gt;This&#x20;type&#x20;of&#x20;report&#x20;implies&#x20;loading&#x20;a&#x20;lot&#x20;of&#x20;data.&#x20;Therefore&#x20;it&#x20;is&#x20;recommended&#x20;for&#x20;scheduled&#x20;reports,&#x20;not&#x20;real-time&#x20;view.&lt;/p&gt;',NULL,0,'','','','00:00:00','00:00:00',1,1,1,1,1,1,1,0,0,10,0,10,0,0,0,0,'{&quot;show_in_same_row&quot;:0,&quot;hide_notinit_agents&quot;:0,&quot;priority_mode&quot;:&quot;1&quot;,&quot;dyn_height&quot;:&quot;250&quot;,&quot;server_multiple&quot;:&quot;&#92;&quot;&#92;&quot;&quot;,&quot;show_summary_group&quot;:0,&quot;filter_event_severity&quot;:&quot;[&#92;&quot;20&#92;&quot;]&quot;,&quot;filter_event_type&quot;:&quot;[&#92;&quot;all&#92;&quot;]&quot;,&quot;filter_event_status&quot;:&quot;[&#92;&quot;-1&#92;&quot;]&quot;,&quot;event_graph_by_agent&quot;:&quot;1&quot;,&quot;event_graph_by_user_validator&quot;:&quot;1&quot;,&quot;event_graph_by_criticity&quot;:&quot;1&quot;,&quot;event_graph_validated_vs_unvalidated&quot;:0,&quot;event_filter_search&quot;:&quot;&quot;,&quot;event_filter_exclude&quot;:&quot;&quot;,&quot;custom_data_events&quot;:&quot;1&quot;,&quot;label&quot;:&quot;&quot;}',0,0,'',0,0,300,0,0,NULL,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,NULL,NULL,1,0,0,NULL);
INSERT INTO `tdashboard` (`id`,`name`,`id_user`,`id_group`,`active`,`cells`,`cells_slideshow`) VALUES
(1,'Sample&#x20;Dashboard&#x20;#1','',0,0,0,0),
(2,'Sample&#x20;Dashboard&#x20;#2','',0,0,0,0);
(1,'Sample&#x20;Dashboard&#x20;#1','',0,0,7,0),
(2,'Sample&#x20;Dashboard&#x20;#2','',0,0,10,0);
INSERT INTO `twidget_dashboard` (`id`,`position`,`options`,`order`,`id_dashboard`,`id_widget`,`prop_width`,`prop_height`) VALUES
(1,'{\"x\":\"0\",\"y\":\"0\",\"width\":\"4\",\"height\":\"4\"}','{\"title\":\"Agents&#x20;hive\",\"background\":\"#ffffff\",\"groups\":[\"12,8,4,9,2,10,13,11\"]}',0,1,1,0.32,0.32),
(2,'{\"x\":\"4\",\"y\":\"0\",\"width\":\"3\",\"height\":\"4\"}','{\"title\":\"Clock\",\"background\":\"#ffffff\",\"clockType\":\"analogic\"}',1,1,12,0.32,0.32),

View File

@ -214,7 +214,7 @@ $enable_disable['text'] = html_print_div(
);
// New Widget.
$newWidget['text'] = '<a href="#" id="add-widget" class="invisible">';
$newWidget['text'] = '<a href="#" id="add-widget" class="invisible_important">';
$newWidget['text'] .= html_print_image(
'images/plus@svg.svg',
true,

View File

@ -112,7 +112,11 @@ if (empty($dashboards) === true) {
'manageDashboards' => $manageDashboards,
],
'default_pagination' => $config['block_size'],
'no_sortable_columns' => [],
'no_sortable_columns' => [
4,
5,
6,
],
'order' => [
'field' => 'name',
'direction' => 'desc',

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.775-240117
Version: 7.0NG.775-240119
Architecture: all
Priority: optional
Section: admin

View File

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

View File

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

View File

@ -1662,9 +1662,6 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
$os_id = $self->guess_os($data->{'agent'}{'direccion'});
}
if (is_empty($data->{'agent'}{'os_version'})) {
$data->{'agent'}{'os_version'} = $self->guess_os($data->{'agent'}{'direccion'}, undef, 1);
}
$self->call('message', "Agent accepted: ".$data->{'agent'}{'nombre'}, 5);
@ -2022,8 +2019,14 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
# Retrieve target agent OS.
$self->{'agents_found'}->{$addr}{'agent'}{'id_os'} = $self->guess_os($addr);
my $os_version = $self->get_os_version($addr);
if (is_empty($os_version)) {
$os_version = $self->guess_os($addr, undef, 1);
}
# Retrieve target agent OS version.
$self->{'agents_found'}->{$addr}{'agent'}{'os_version'} = $self->get_os_version($addr);
$self->{'agents_found'}->{$addr}{'agent'}{'os_version'} = $os_version;
$self->call('update_progress', $progress);
$progress += $step;

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