Merge branch 'ent-1668-update-manager' into 'develop'

Ent 1668 update manager

See merge request artica/pandorafms!2420
This commit is contained in:
Daniel Rodriguez 2019-05-22 15:25:49 +02:00
commit 979f11ca8f
22 changed files with 1931 additions and 1754 deletions

View File

@ -1,3 +1,3 @@
/godmode/servers/recon_script.php
/godmode/servers/manage_recontask_form.php
/godmode/servers/manage_recontask.php
/general/login_identification_wizard.php
/general/login_required.php
/godmode/update_manager/update_manager.messages.php

View File

@ -12,5 +12,8 @@ DELETE FROM `tevent_response` WHERE `name` LIKE 'Create Integria IMS&#
INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (1,'admin','Welcome to Pandora FMS Console', '<p style="text-align: center; font-size: 13px;">Hello, congratulations, if you've arrived here you already have an operational monitoring console. Remember that our forums and online documentation are available 24x7 to get you out of any trouble. You can replace this message with a personalized one at Admin tools -> Site news.</p> ',NOW());
INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="Official communication"), "admin", 1, 0);
UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System status' OR `description` = 'Official communication';
UPDATE `tnotification_source` SET `icon`="icono_logo_pandora.png" WHERE `description` = 'Official communication';
COMMIT;
COMMIT;

View File

@ -2005,7 +2005,7 @@ INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `
("Message", "icono_info_mr.png", 86400, 1, 1, 0),
("Pending task", "icono_info_mr.png", 86400, 1, 1, 0),
("Advertisement", "icono_info_mr.png", 86400, 1, 1, 0),
("Official communication", "icono_info_mr.png", 86400, 1, 1, 0),
("Official communication", "icono_logo_pandora.png", 86400, 1, 1, 0),
("Sugerence", "icono_info_mr.png", 86400, 1, 1, 0);
-- -----------------------------------------------------
@ -2102,6 +2102,9 @@ INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fi
INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0);
INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Message";
INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != '';
INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="Official communication"), "admin", 1, 0);
UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System status' OR `description` = 'Official communication';
-- ----------------------------------------------------------------------
-- Add custom internal recon scripts
-- ----------------------------------------------------------------------

View File

@ -1,455 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
/**
* @package General
*/
global $config;
function display_register($data)
{
if ($data['instance_registered'] == 1) {
return false;
}
if ($data['force_register'] == 1) {
return true;
}
if ($data['force_register'] == 0) {
return false;
}
if ($data['identification_reminder'] == 0) {
return false;
}
if (!isset($data['identification_reminder_timestamp'])) {
return true;
}
if ($data['identification_reminder_timestamp'] < time()) {
return true;
}
return false;
}
function display_newsletter($data)
{
if ($data['newsletter_subscribed'] == 1) {
return false;
}
if ($data['force_newsletter'] == 1) {
return true;
}
if ($data['force_newsletter'] == 0) {
return false;
}
if ($data['newsletter_reminder'] === 0) {
return false;
}
if (!isset($data['newsletter_reminder_timestamp'])) {
return true;
}
if (!is_numeric($data['newsletter_reminder_timestamp'])) {
return true;
}
if ($data['newsletter_reminder_timestamp'] < time()) {
return true;
}
return false;
}
if (is_ajax()) {
include_once $config['homedir'].'/include/functions_update_manager.php';
$open_wizard = get_parameter('open_wizard', 0);
$not_return = get_parameter('not_return', 0);
$reset_initial_wizard = get_parameter('reset_initial_wizard', 0);
if ($reset_initial_wizard) {
config_update_value('initial_wizard', 0);
}
if ($open_wizard) {
$register_pandora = get_parameter('register_pandora', 0);
$newsletter = get_parameter('newsletter', 0);
$forced = get_parameter('forced', 0);
$future_8_days = (time() + 8 * SECONDS_1DAY);
$ui_feedback = [
'status' => true,
'message' => '',
];
if ($register_pandora) {
// Pandora register update
$um_message = update_manager_register_instance();
$ui_feedback['message'] .= $um_message['message'].'<br><br>';
if ($um_message['success']) {
config_update_value('instance_registered', 1);
$ui_feedback['status'] = true && $ui_feedback['status'];
} else {
$ui_feedback['status'] = false;
}
} else if (!$forced) {
config_update_value('identification_reminder_timestamp', $future_8_days);
}
if ($newsletter) {
// Pandora newsletter update
$email = get_parameter('email', '');
$um_message = update_manager_insert_newsletter($email);
$ui_feedback['message'] .= $um_message['message'];
if ($um_message['success']) {
db_process_sql_update('tusuario', ['middlename' => 1], ['id_user' => $config['id_user']]);
$ui_feedback['status'] = true && $ui_feedback['status'];
} else {
$ui_feedback['status'] = false;
}
} else if (!$forced) {
db_process_sql_update('tusuario', ['lastname' => $future_8_days], ['id_user' => $config['id_user']]);
}
// Form answer JSON
$ui_feedback['status'] = $ui_feedback['status'] ? 1 : 0;
echo io_json_mb_encode($ui_feedback);
}
if (!$not_return) {
return;
}
}
// Check if user is admin
if (!license_free()) {
return;
}
if (!users_is_admin($config['id_user'])) {
return;
}
// Get data to display properly the wizard
$wizard_data = [];
$wizard_data['newsletter_subscribed'] = db_get_value('middlename', 'tusuario', 'id_user', $config['id_user']);
// force_* = 1 -> force show
// force_* = 0 -> force hide
// force_* = -1 -> show or hide depends reminder and timestamp
$wizard_data['force_newsletter'] = get_parameter('force_newsletter', -1);
$wizard_data['newsletter_reminder'] = db_get_value('firstname', 'tusuario', 'id_user', $config['id_user']);
$wizard_data['newsletter_reminder_timestamp'] = db_get_value('lastname', 'tusuario', 'id_user', $config['id_user']);
$wizard_data['instance_registered'] = $config['instance_registered'];
$wizard_data['force_register'] = get_parameter('force_register', -1);
$wizard_data['identification_reminder'] = $config['identification_reminder'];
$wizard_data['identification_reminder_timestamp'] = $config['identification_reminder_timestamp'];
$display_newsletter = display_newsletter($wizard_data);
$display_register = display_register($wizard_data);
$display_forced = ($wizard_data['force_newsletter'] != -1) || ($wizard_data['force_register'] != -1);
// Return if it is fully completed
if ((!$display_register) && (!$display_newsletter)) {
return false;
}
$return_button = get_parameter('return_button', 0) == 1;
$email = db_get_value('email', 'tusuario', 'id_user', $config['id_user']);
// Avoid to show default email
if ($email == 'admin@example.com') {
$email = '';
}
// Prints accept register license
echo '<div id="login_accept_register" title="'.__('The %s community wizard', get_product_name()).'" style="">';
echo '<div style="margin: 5px 0 10px; float: left; padding-left: 15px;">';
echo html_print_image('images/pandora_circle_big.png', true);
echo '</div>';
echo '<div style="font-size: 12pt; margin: 5px 20px; float: left; padding-top: 23px;">';
echo __('Stay up to date with the %s community', get_product_name()).'.';
echo '</div>';
echo '<div id="license_newsletter">';
echo '<p>'.__('When you subscribe to the %s Update Manager service, you accept that we register your %s instance as an identifier on the database owned by Artica TS. This data will solely be used to provide you with information about %s and will not be conceded to third parties. You can unregister from said database at any time from the Update Manager options.', get_product_name(), get_product_name(), get_product_name()).'</p>';
echo '<p>'.__('In the same fashion, when subscribed to the newsletter you accept that your email will pass on to a database property of Artica TS. This data will solely be used to provide you with information about %s and will not be conceded to third parties. You can unregister from said database at any time from the newsletter subscription options.', get_product_name()).'</p>';
echo '</div>';
echo '<div style="position:absolute; margin: 0 auto; bottom: 0px; padding-top:10px; position:relative; border: 1px solid #FFF;">';
echo '<div style="float: right;">';
html_print_submit_button(__('Finish'), 'finish_dialog_button', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok" style="width:100px;"');
echo '</div>';
$display_status_return = $return_button ? 'block' : 'none';
echo '<div style="float: right; width: 20%; display: '.$display_status_return.';">';
html_print_submit_button(__('Return'), 'return_dialog_button', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd" style="width:100px;"');
echo '</div>';
echo '<div style="float: left; margin-left: 0px; width: 50%; text-align: left;">';
html_print_checkbox('register', 1, false, false, false, 'cursor: \'pointer\'');
echo '&nbsp;<span style="font-size: 12px;" id="label-register">'.__('Join the %s community!', get_product_name()).'!</span><br>';
html_print_checkbox('newsletter', 1, false, false, false, 'cursor: \'pointer\'');
echo '&nbsp;<span style="font-size: 12px;" id="label-newsletter">'.__('Subscribe to our newsletter').'</span>';
echo '<br>';
echo '<div id="email_container">';
echo '&nbsp;<span id="label-email-newsletter"style="font-size: 12px; display: none">'.__('Email').': </span>';
html_print_input_text_extended('email-newsletter', $email, 'text-email-newsletter', '', 30, 255, false, '', ['style' => 'display:none; width: 200px;']);
echo '&nbsp;<span id="label-email-newsletter"style="font-size: 12px; display: none">'.__('Email').': </span>';
echo '&nbsp;<span id="required-email-newsletter">*'.__('Required').' </span>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
// Print yes or not dialog
echo '<div id="login_registration_yesno" title="'.__('%s instance identification wizard', get_product_name()).'" style="">';
echo '<div style="font-size: 12pt; margin: 20px;">';
echo __('Do you want to continue without any registration').'?';
echo '</div>';
echo '<div style="float: left; padding-left: 15px; padding-top: 20px;">';
html_print_submit_button(__('No'), 'no_registration', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub cancel" style="width:100px;"');
echo '</div>';
echo '<div style="float: right; padding-right: 15px; padding-top: 20px;">';
html_print_submit_button(__('Yes'), 'yes_registration', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd" style="width:100px;"');
echo '</div>';
echo '</div>';
// Print feedback user dialog
echo '<div id="ui_messages_feedback" style="">';
echo '<div style="float: left; margin: 15px; margin-left: 5px;">';
echo html_print_image('images/success_circle_big.png', true);
echo '</div>';
echo '<div id="feedback_message" style="font-size: 13pt; margin: 15px 20px; padding-left:80px;"></div>';
echo '</div>';
?>
<script type="text/javascript" language="javascript">
/* <![CDATA[ */
//Show newsletter and register checkboxes
var display_register = <?php echo json_encode($display_register); ?>;
var display_newsletter = <?php echo json_encode($display_newsletter); ?>;
var display_forced = <?php echo json_encode($display_forced); ?>;
var return_button = <?php echo json_encode($return_button); ?>;
////////////////////////////////////////////////////////////////////////
//HELPER FUNCTIONS
function submit_open_wizard (register, newsletter, email, forced) {
register = register;
newsletter = newsletter ? 1 : 0;
forced = forced ? 1 : 0;
var feedback_message = '';
var feedback_status = 1;
jQuery.post ("ajax.php",
{"page": "general/login_identification_wizard",
"open_wizard": 1,
"register_pandora": register,
"newsletter": newsletter,
"email": email,
"forced": forced},
function (data) {
var feedback_message = '';
var feedback_status = 1;
jQuery.each (data, function (i, val) {
if (i == 'message') feedback_message = val;
if (i == 'status') feedback_status = val;
});
if (feedback_status == 0) {
$("#ui_messages_feedback img").attr("src", "images/fail_circle_big.png");
} else {
$("#ui_messages_feedback img").attr("src", "images/success_circle_big.png");
}
$("#feedback_message").html(feedback_message);
},
"json"
);
}
////////////////////////////////////////////////////////////////////////
//EVENT FUNCTIONS
$("#submit-return_dialog_button").click (function () {
$("#login_accept_register" ).dialog('close');
$("#all-required").hide();
$("#login_id_dialog" ).dialog('open');
jQuery.post ("ajax.php",
{"page": "general/login_identification_wizard",
"reset_initial_wizard": 1},
function (data) {}
);
});
$("#submit-finish_dialog_button").click (function () {
var newsletter = $("#checkbox-newsletter").is(':checked') ? 1 : 0;
var register = $("#checkbox-register").is(':checked');
var email = $("#text-email-newsletter").val();
if (email == '' && newsletter) {
$("#label-email-newsletter").show();
$("#text-email-newsletter").show();
$("#required-email-newsletter").show();
return;
}
if (!register && display_register && !display_forced) {
$("#login_registration_yesno").dialog('open');
} else {
var register_forced = register ? 1 : 0;
submit_open_wizard (register_forced, newsletter, email, display_forced);
$("#login_accept_register" ).dialog('close');
if (register || newsletter) {
$("#ui_messages_feedback").dialog('open');
}
}
});
$("#submit-no_registration").click (function () {
$("#login_registration_yesno").dialog('close');
});
$("#submit-yes_registration").click (function () {
var newsletter = $("#checkbox-newsletter").is(':checked') ? 1 : 0;
var email = $("#text-email-newsletter").val();
submit_open_wizard (0, newsletter, email, display_forced);
$("#login_registration_yesno").dialog('close');
$("#login_accept_register" ).dialog('close');
});
$("#checkbox-newsletter").click (function () {
var newsletter = $("#checkbox-newsletter").is(':checked') ? 1 : 0;
if (!return_button && newsletter) {
$("#label-email-newsletter").show();
$("#text-email-newsletter").show();
}
if (!newsletter) {
$("#label-email-newsletter").hide();
$("#text-email-newsletter").hide();
$("#required-email-newsletter").hide();
}
});
////////////////////////////////////////////////////////////////////////
//DISPLAY
$(document).ready (function () {
$("#login_accept_register").dialog({
resizable: false,
draggable: true,
modal: true,
height: 320,
width: 750
});
$("#login_registration_yesno").dialog({
resizable: false,
draggable: true,
modal: true,
width: 320,
overlay: {
opacity: 1,
background: "black"
},
autoOpen: false
});
$("#ui_messages_feedback").dialog({
resizable: false,
draggable: true,
modal: true,
width: 300,
overlay: {
opacity: 1,
background: "black"
},
autoOpen: false
});
//Display return button if required
if (return_button) {
$("#submit-return_dialog_button").show ();
}
// Remove the completed parts
if (!display_register) {
$("#checkbox-register").attr ('style', 'display: none !important');
$("#label-register").hide ();
}
if (!display_newsletter) {
$("#checkbox-newsletter").attr ('style', 'display: none !important');
$("#label-newsletter").hide ();
}
});
/* ]]> */
</script>
<style type="text/css">
#required-email-newsletter{
font-size : 9px;
color: red;
margin-left: -2px;
margin-top: 3px;
position: absolute;
display: none;
}
#email_container{
margin-top: 3px;
width: 500px;
}
#license_newsletter {
height: 100px;
width: 100%;
overflow-y: scroll;
border: 1px solid #E4E4E4;
border-radius: 3px;
}
#license_newsletter p{
padding: 0 3px;
}
.ui-widget-overlay {
background: #000;
opacity: .6;
}
.ui-draggable {
cursor: inherit;
}
</style>

View File

@ -1,273 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
/**
* @package General
*/
global $config;
if (is_ajax()) {
$save_identification = get_parameter('save_required_wizard', 0);
$change_language = get_parameter('change_language', 0);
$cancel_wizard = get_parameter('cancel_wizard', 0);
// Updates the values get on the identification wizard
if ($save_identification) {
$email = get_parameter('email', false);
$timezone = get_parameter('timezone', false);
$language = get_parameter('language', false);
if ($email !== false) {
config_update_value('language', $language);
}
if ($timezone !== false) {
config_update_value('timezone', $timezone);
}
if ($email !== false) {
db_process_sql_update(
'tusuario',
['email' => $email],
['id_user' => $config['id_user']]
);
}
// Update the alert action Mail to XXX/Administrator if it is set to default
$mail_check = 'yourmail@domain.es';
$mail_alert = alerts_get_alert_action_field1(1);
if ($mail_check === $mail_alert && $email !== false) {
alerts_update_alert_action(
1,
[
'field1' => $email,
'field1_recovery' => $email,
]
);
}
config_update_value('initial_wizard', 1);
}
// Change the language if is change in checkbox
if ($change_language !== 0) {
config_update_value('language', $change_language);
}
if ($cancel_wizard !== 0) {
config_update_value('initial_wizard', 1);
}
return;
}
$email = db_get_value('email', 'tusuario', 'id_user', $config['id_user']);
// Avoid to show default email
if ($email == 'admin@example.com') {
$email = '';
}
// Prints first step pandora registration
echo '<div id="login_id_dialog" title="'.__('%s instance identification wizard', get_product_name()).'" style="display: none;">';
echo '<div style="font-size: 10pt; margin: 20px;">';
echo __('Please fill the following information in order to configure your %s instance successfully', get_product_name()).'.';
echo '</div>';
echo '<div style="">';
$table = new StdClass();
$table->class = 'databox filters';
$table->width = '100%';
$table->data = [];
$table->size = [];
$table->size[0] = '40%';
$table->style[0] = 'font-weight:bold';
$table->size[1] = '60%';
$table->border = '5px solid';
$table->data[0][0] = __('Language code');
$table->data[0][1] = html_print_select_from_sql(
'SELECT id_language, name FROM tlanguage',
'language',
$config['language'],
'',
'',
'',
true
);
$zone_name = [
'Africa' => __('Africa'),
'America' => __('America'),
'Antarctica' => __('Antarctica'),
'Arctic' => __('Arctic'),
'Asia' => __('Asia'),
'Atlantic' => __('Atlantic'),
'Australia' => __('Australia'),
'Europe' => __('Europe'),
'Indian' => __('Indian'),
'Pacific' => __('Pacific'),
'UTC' => __('UTC'),
];
if ($zone_selected == '') {
if ($config['timezone'] != '') {
$zone_array = explode('/', $config['timezone']);
$zone_selected = $zone_array[0];
} else {
$zone_selected = 'Europe';
}
}
$timezones = timezone_identifiers_list();
foreach ($timezones as $timezone) {
if (strpos($timezone, $zone_selected) !== false) {
$timezone_country = preg_replace('/^.*\//', '', $timezone);
$timezone_n[$timezone] = $timezone_country;
}
}
$table->data[2][0] = __('Timezone setup').' '.ui_print_help_tip(
__('Must have the same time zone as the system or database to avoid mismatches of time.'),
true
);
$table->data[2][1] = html_print_select($zone_name, 'zone', $zone_selected, 'show_timezone()', '', '', true);
$table->data[2][1] .= '&nbsp;&nbsp;'.html_print_select($timezone_n, 'timezone', $config['timezone'], '', '', '', true);
$table->data[4][0] = __('E-mail for receiving alerts');
$table->data[4][1] = html_print_input_text('email', $email, '', 50, 255, true);
html_print_table($table);
echo '</div>';
echo '<div style="position:absolute; margin: 0 auto; bottom: 0px; right: 10px; border: 1px solid #FFF; width: 570px">';
echo '<div style="float: right; width: 20%;">';
html_print_submit_button(__('Register'), 'id_dialog_button', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok" style="width:100px;"');
echo '</div>';
echo '<div style="float: right; width: 20%;">';
html_print_button(__('Cancel'), 'cancel', false, '', 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok" style="width:100px;"');
echo '</div>';
echo '<div id="all-required" style="float: right; margin-right: 30px; display: none; color: red;">';
echo __('All fields required');
echo '</div>';
echo '</div>';
echo '</div>';
?>
<script type="text/javascript" language="javascript">
/* <![CDATA[ */
var default_language_displayed;
////////////////////////////////////////////////////////////////////////
//HELPER FUNCTIONS
function show_timezone () {
zone = $("#zone").val();
$.ajax({
type: "POST",
url: "ajax.php",
data: "page=godmode/setup/setup&select_timezone=1&zone=" + zone,
dataType: "json",
success: function(data) {
$("#timezone").empty();
jQuery.each (data, function (id, value) {
timezone = value;
var timezone_country = timezone.replace (/^.*\//g, "");
$("select[name='timezone']").append($("<option>").val(timezone).html(timezone_country));
});
}
});
}
////////////////////////////////////////////////////////////////////////
//EVENT FUNCTIONS
$("#submit-id_dialog_button").click (function () {
//All fields required
if ($("#text-email").val() == '') {
$("#all-required").show();
} else {
var timezone = $("#timezone").val();
var language = $("#language").val();
var email_identification = $("#text-email").val();
jQuery.post ("ajax.php",
{"page": "general/login_required",
"save_required_wizard": 1,
"email": email_identification,
"language": language,
"timezone": timezone},
function (data) {}
);
$("#login_id_dialog").dialog('close');
first_time_identification ();
}
});
$("#language").click(function () {
var change_language = $("#language").val();
if (change_language === default_language_displayed) return;
jQuery.post ("ajax.php",
{"page": "general/login_required",
"change_language": change_language},
function (data) {}
).done(function () {
location.reload();
});
});
////////////////////////////////////////////////////////////////////////
//DISPLAY
$(document).ready (function () {
$("#login_id_dialog").dialog({
resizable: true,
draggable: true,
modal: true,
height: 280,
width: 630,
overlay: {
opacity: 0.5,
background: "black"
},
closeOnEscape: false,
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); }
});
default_language_displayed = $("#language").val();
$(".ui-widget-overlay").css("background", "#000");
$(".ui-widget-overlay").css("opacity", 0.6);
$(".ui-draggable").css("cursor", "inherit");
$("#button-cancel").click (function () {
jQuery.post ("ajax.php",
{"page": "general/login_required",
"cancel_wizard": 1},
function (data) {}
);
$("#login_id_dialog" ).dialog('close');
});
});
/* ]]> */
</script>

View File

@ -218,58 +218,6 @@ if (!empty($all_data)) {
// END OF NEWS BOARD.
}
$nots = messages_get_overview('utimestamp', 'DESC', false);
if (!empty($nots)) {
// Notifications board.
echo '<div id="notifications_board">';
echo '<table cellpadding="0" width=100% cellspacing="0" class="databox filters">';
echo '<tr><th style="text-align:center;"><span >'.__('Pending notifications').'</span></th></tr>';
if ($config['prominent_time'] == 'timestamp') {
$comparation_suffix = '';
} else {
$comparation_suffix = __('ago');
}
foreach ($nots as $msg) {
$conversation = io_safe_output(
messages_get_conversation($msg)
);
if (is_array($conversation)) {
$text = array_pop($conversation)['message'];
} else {
// Skip empty message.
continue;
}
$url = ui_get_full_url(
'index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$msg['id_mensaje']
);
if ($msg['url'] != '') {
$url = $msg['url'];
}
echo '<tr><th class="green_title">'.$msg['subject'].'</th></tr>';
echo '<tr><td><a href="'.$url.'">';
if ($msg['id_usuario_origen'] != '') {
echo '<b>'.get_user_fullname($msg['id_usuario_origen']).'</b> ';
}
echo '<i>'.ui_print_timestamp($msg['timestamp'], true).'</i> '.$comparation_suffix.'</a></td></tr>';
echo '<tr><td class="datos">';
echo nl2br($text);
echo '</td></tr>';
}
echo '</table>';
echo '</div>';
echo '<br><br>';
// EO Notifications board.
}
// LAST ACTIVITY.
// Show last activity from this user.
echo '<div id="activity">';

View File

@ -0,0 +1,181 @@
<?php
/**
* Update Manager registration process client controller.
*
* @category Client controller
* @package Pandora FMS
* @subpackage Update manager
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
global $config;
require_once $config['homedir'].'/include/functions_update_manager.php';
if (is_ajax()) {
// Parse responses, flow control.
$configuration_wizard = get_parameter('save_required_wizard', 0);
$change_language = get_parameter('change_language', 0);
$cancel_wizard = get_parameter('cancel_wizard', 0);
// Console registration.
$cancel_registration = get_parameter('cancel_registration', 0);
$register_console = get_parameter('register_console', 0);
// Newsletter.
$cancel_newsletter = get_parameter('cancel_newsletter', 0);
$register_newsletter = get_parameter('register_newsletter', 0);
// Load wizards.
$load_wizards = get_parameter('load_wizards', '');
$feedback = [];
// Load wizards.
if ($load_wizards != '') {
switch ($load_wizards) {
case 'initial':
return config_wiz_modal(false, false);
case 'registration':
return registration_wiz_modal(false, false);
case 'newsletter':
return newsletter_wiz_modal(false, false);
case 'all':
config_wiz_modal(false, false);
registration_wiz_modal(false, false);
newsletter_wiz_modal(false, false);
return;
default:
// Ignore.
break;
}
}
// Configuration wizard process.
if ($configuration_wizard) {
$feedback = config_wiz_process();
}
if ($change_language) {
// Change the language if is change in checkbox.
config_update_value('language', $change_language);
}
if ($cancel_wizard) {
config_update_value('initial_wizard', 1);
}
// Update Manager registration.
if ($cancel_registration) {
config_update_value('pandora_uid', 'OFFLINE');
}
if ($register_console) {
$feedback = registration_wiz_process();
}
// Newsletter.
if ($cancel_newsletter) {
db_process_sql_update(
'tusuario',
['middlename' => -1],
['id_user' => $config['id_user']]
);
// XXX: Also notify UpdateManager.
}
if ($register_newsletter) {
$feedback = newsletter_wiz_process();
}
if (is_array($feedback)) {
echo json_encode($feedback);
}
// Ajax calls finish here.
exit();
}
ui_require_css_file('register');
$initial = isset($config['initial_wizard']) !== true
|| $config['initial_wizard'] != '1';
$newsletter = db_get_value(
'middlename',
'tusuario',
'id_user',
$config['id_user']
);
$show_newsletter = $newsletter == '0' || $newsletter == '';
$registration = isset($config['pandora_uid']) !== true
|| $config['pandora_uid'] == '';
if ($initial) {
// Show all forms in order.
// 1- Ask for email, timezone, etc. Fullfill alerts and user mail.
config_wiz_modal(
false,
true,
(($registration === true) ? 'show_registration_wizard()' : null)
);
}
if ($registration) {
// Prepare registration wizard, not launch. leave control to flow.
registration_wiz_modal(
false,
// Launch only if not being launch from 'initial'.
!$initial,
(($show_newsletter === true) ? 'force_run_newsletter()' : null)
);
} else {
if ($show_newsletter) {
// Show newsletter wizard for current user.
newsletter_wiz_modal(
false,
// Launch only if not being call from 'registration'.
!$registration && !$initial
);
}
}
?>
<script type="text/javascript">
$(document).ready (function () {
});
</script>

View File

@ -457,19 +457,6 @@ if (check_acl($config['id_user'], 0, 'PM') && $config['enable_update_manager'])
$sub['godmode/update_manager/update_manager&tab=setup']['text'] = __('Update Manager options');
$sub['godmode/update_manager/update_manager&tab=setup']['id'] = 'Options';
if (license_free() && is_user_admin($config['id_user'])) {
include_once 'include/functions_update_manager.php';
// If there are unread messages, display the notification icon
$number_total_messages;
$number_unread_messages = update_manager_get_unread_messages();
if ($number_unread_messages > 0) {
$menu_godmode['messages']['notification'] = $number_unread_messages;
}
$sub['godmode/update_manager/update_manager&tab=messages']['text'] = __('Messages');
$sub['godmode/update_manager/update_manager&tab=messages']['id'] = 'Messages';
}
$menu_godmode['messages']['sub'] = $sub;
}

View File

@ -102,30 +102,37 @@ if (enterprise_installed()) {
echo '</div>';
}
echo '</form>';
echo '<div id="code_license_dialog" style="display: none; text-align: left;" title="'.__('Request new license').'">';
echo '<div id="logo">';
html_print_image(ui_get_custom_header_logo(true));
echo '</div>';
echo ''.__('To get your <b>%s Enterprise License</b>:', get_product_name()).'<br />';
echo '<ul>';
echo '<li>';
echo ''.sprintf(__('Go to %s'), '<a target="_blank" href="https://licensing.artica.es/pandoraupdate7/index.php?section=generate_key_client">https://licensing.artica.es/pandoraupdate7/index.php?section=generate_key_client</a>');
echo '</li>';
echo '<li>';
echo ''.__('Enter the <b>auth key</b> and the following <b>request key</b>:');
echo '</li>';
echo '</ul>';
echo '<div id="code"></div>';
echo '<ul>';
echo '<li>';
echo ''.__('Enter your name (or a company name) and a contact email address.');
echo '</li>';
echo '<li>';
echo ''.__('Click on <b>Generate</b>.');
echo '</li>';
echo '<li>';
echo ''.__('Click <a href="javascript: close_code_license_dialog();">here</a>, enter the generated license key and click on <b>Validate</b>.');
echo '</li>';
echo '</ul>';
echo '</div>';
if (enterprise_installed()) {
echo '<link rel="stylesheet" href="'.ui_get_full_url(false, false, false, false).'include/styles/pandora.css" type="text/css">';
echo '<link rel="stylesheet" href="'.ui_get_full_url(false, false, false, false).'enterprise/include/styles/pandora_enterprise.css" type="text/css">';
}
if (enterprise_hook('print_activate_licence_dialog') == ENTERPRISE_NOT_HOOK) {
echo '</form>';
echo '<div id="code_license_dialog" style="display: none; text-align: left;" title="'.__('Request new license').'">';
echo '<div id="logo">';
html_print_image(ui_get_custom_header_logo(true));
echo '</div>';
echo ''.__('To get your <b>%s Enterprise License</b>:', get_product_name()).'<br />';
echo '<ul>';
echo '<li>';
echo ''.sprintf(__('Go to %s'), '<a target="_blank" href="https://licensing.artica.es/pandoraupdate7/index.php?section=generate_key_client">https://licensing.artica.es/pandoraupdate7/index.php?section=generate_key_client</a>');
echo '</li>';
echo '<li>';
echo ''.__('Enter the <b>auth key</b> and the following <b>request key</b>:');
echo '</li>';
echo '</ul>';
echo '<div id="code"></div>';
echo '<ul>';
echo '<li>';
echo ''.__('Enter your name (or a company name) and a contact email address.');
echo '</li>';
echo '<li>';
echo ''.__('Click on <b>Generate</b>.');
echo '</li>';
echo '<li>';
echo ''.__('Click <a href="javascript: close_code_license_dialog();">here</a>, enter the generated license key and click on <b>Validate</b>.');
echo '</li>';
echo '</ul>';
echo '</div>';
}

View File

@ -160,6 +160,20 @@ if (get_parameter('get_notifications_dropdown', 0)) {
return;
}
if (get_parameter('get_notification', 0)) {
$msg_id = get_parameter('id', 0);
if ($msg_id > 0) {
$msg = messages_get_message($msg_id);
$msg['mensaje'] = io_safe_output($msg['mensaje']);
$msg['subject'] = io_safe_output($msg['subject']);
echo json_encode($msg);
}
return;
}
// Notification table. It is just a wrapper.
$table_content = new StdClass();
$table_content->data = [];

View File

@ -1,340 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
require_once 'include/functions_update_manager.php';
check_login();
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
db_pandora_audit('ACL Violation', 'Trying to access Setup Management');
include 'general/noaccess.php';
return;
}
if (is_ajax()) {
$not_read_single = get_parameter('not_read_single', 0);
if ($not_read_single) {
$message_id = get_parameter('message_id', 0);
update_manger_set_read_message($message_id, 1);
update_manager_remote_read_messages($message_id);
}
return;
}
$not_read_action = get_parameter('not_read_button', false);
$read_action = get_parameter('read_button', false);
$delete_action = get_parameter('delete_button', false);
if ($not_read_action !== false) {
$selected = get_parameter('select_multiple', false);
foreach ($selected as $k => $message_id) {
update_manger_set_read_message($message_id, 0);
}
}
if ($read_action !== false) {
$selected = get_parameter('select_multiple', false);
foreach ($selected as $k => $message_id) {
update_manger_set_read_message($message_id, 1);
}
}
if ($delete_action !== false) {
$selected = get_parameter('select_multiple', false);
foreach ($selected as $k => $message_id) {
update_manger_set_deleted_message($message_id);
}
}
$offset = (int) get_parameter('offset', 0);
$total_messages = update_manager_get_not_deleted_messages();
if ($total_messages) {
// Get all messages
$sql = 'SELECT data, svn_version, filename, data_rollback, db_field_value FROM tupdate ';
$sql .= 'WHERE description NOT LIKE \'%"'.$config['id_user'].'":1%\' ';
$sql .= 'OR description IS NULL ';
$sql .= 'ORDER BY svn_version DESC ';
$sql .= 'LIMIT '.$offset.','.$config['block_size'].' ';
$um_messages = [];
$um_messages = db_get_all_rows_sql($sql);
echo '<form method="post" action="index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=setup">';
html_print_input_hidden('tab', 'messages');
html_print_input_hidden('offset', $offset);
echo '<div class="action-buttons" style="float:right; padding: 10px 5px">';
html_print_submit_button(
__('Delete'),
'delete_button',
false,
'class="sub delete"'
);
echo '</div>';
echo '<div class="action-buttons" style="float:right; padding: 10px 5px">';
html_print_submit_button(
__('Mark as not read'),
'not_read_button',
false,
'class="sub wand"'
);
echo '</div>';
echo '<div class="action-buttons" style="float:right; padding: 10px 5px">';
html_print_submit_button(
__('Mark as read'),
'read_button',
false,
'class="sub upd"'
);
echo '</div>';
// Pagination
if ($total_messages > $config['block_size']) {
ui_pagination(update_manager_get_total_messages(), false, 0);
}
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox data';
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->head = [];
$table->data = [];
$table->align = [];
$table->size = [];
$table->id = 'um_messages_table';
$table->align[0] = 'left';
$table->align[1] = 'left';
$table->align[2] = 'left';
$table->align[3] = 'left';
$table->align[4] = 'left';
$table->size[0] = '30px';
$table->size[1] = '100px';
$table->size[3] = '80px';
$table->size[4] = '60px';
$table->style[0] = 'padding-left: 20px';
$table->style[1] = 'display: none';
$table->head[0] = html_print_checkbox_extended('all_selection[]', 0, false, false, '', '', true);
$table->head[2] = __('Subject');
$i = 0;
foreach ($um_messages as $message) {
$data[0] = html_print_checkbox_extended('select_multiple[]', $message['svn_version'], false, false, '', 'class="check_selection"', true);
$table->cellclass[count($table->data)][0] = 'um_individual_check';
$data[1] = $message['svn_version'];
$table->cellclass[count($table->data)][1] = 'um_individual_info';
$data[2] = io_safe_output($message['db_field_value']);
$table->cellclass[count($table->data)][2] = 'um_individual_subject';
// Change row class if message is read or not by this user
if (update_manger_get_read_message($message['svn_version'], $message['data_rollback'])) {
$table->rowclass[count($table->data)] = 'um_read_message';
} else {
$table->rowclass[count($table->data)] = 'um_not_read_message';
}
array_push($table->data, $data);
}
html_print_table($table);
echo '<div class="action-buttons" style="float:right; padding: 0 5px;">';
html_print_submit_button(
__('Delete'),
'delete_button',
false,
'class="sub delete"'
);
echo '</div>';
echo '<div class="action-buttons" style="float:right; padding: 0 5px;">';
html_print_submit_button(
__('Mark as not read'),
'not_read_button',
false,
'class="sub wand"'
);
echo '</div>';
echo '<div class="action-buttons" style="float:right; padding: 0 5px;">';
html_print_submit_button(
__('Mark as read'),
'read_button',
false,
'class="sub upd"'
);
echo '</div>';
echo '</form>';
// Get unread messages to update the notification ball.
// Clean the cache because the unread messages can be different.
db_clean_cache();
$total_unread_messages = update_manager_get_unread_messages();
} else {
ui_print_info_message([ 'no_close' => true, 'message' => __('There is not any update manager messages.') ]);
}
?>
<script type="text/javascript">
var total_unread_messages = <?php echo json_encode($total_unread_messages); ?>;
$("#checkbox-all_selection").click( function() {
if ($("#checkbox-all_selection").is(':checked')) {
$(".check_selection").prop('checked', true);
$(".check_selection").parent().parent().css('background', "#FFFFEE");
} else {
$(".check_selection").prop('checked', false);
$(".check_selection").parent().parent().css('background', "inherit");
}
});
$("#um_messages_table").click( function (event) {
//Get all position information required
var target = (event.target.id);
//If header is clicked, return
if (target == '') return;
var raw_position = (event.target.id).replace(/.*table-/ig,"");
var row = raw_position.replace(/-.*/ig, "");
var column = raw_position.replace(/.*-/ig, "");
// Delete and mark as not read column will do not open the message
if (column == 0) return;
// Class where object will be displayed
var current_class = ".um_message_" + row;
var message_id = $("#"+target).parent().find(":nth-child(2)").html();
var className = $("#"+target).parent().attr('class');
if (className == 'um_not_read_message'){
jQuery.post ("ajax.php",
{"page": "godmode/update_manager/update_manager.messages",
"not_read_single": 1,
"message_id": message_id},
function (data) {}
);
$("#"+target).parent().children().each(function(){
var full_class = $(this).attr('class');
full_class = full_class.replace (/um_not_read_message/g, "um_read_message");
$(this).attr('class', full_class);
});
var unread = $("#icon_god-um_messages").find(".notification_ball").html();
unread--;
if (unread == 0) {
$("#icon_god-um_messages").find(".notification_ball").hide();
}
else {
$("#icon_god-um_messages").find(".notification_ball").html(unread);
}
}
// Display message
$("#container").append('<div class="id_wizard"></div>');
jQuery.get ("ajax.php",
{"page": "general/last_message",
"message_id": message_id},
function (data) {
$(".id_wizard").hide ()
.empty ()
.append (data);
},
"html"
);
});
$(".check_selection").click(function (event) {
if ($("#" + event.target.id).is(':checked')) {
$("#" + event.target.id).parent().parent().css('background', "#FFFFEE");
} else {
$("#" + event.target.id).parent().parent().css('background', 'inherit');
}
});
$(".um_individual_info, .um_individual_subject").hover(
function () {
$(this).parent().css('background', '#F2F2F2');
},
function () {
if ($(this).parent().find(":first-child").is(':checked')) {
$(this).parent().css('background', "#FFFFEE");
} else {
$(this).parent().css('background', 'inherit');
}
}
);
$(document).ready (function () {
// Rewrite the notification ball
if (total_unread_messages == 0) {
$("#icon_god-um_messages").find(".notification_ball").hide();
}
else {
$("#icon_god-um_messages").find(".notification_ball").html(total_unread_messages);
}
});
</script>
<style type="text/css">
.um_not_read_message{
font-weight: 900;
}
.um_read_message{
font-weight: 500;
color: #909090;
}
.um_individual_info, .um_individual_subject {
cursor: pointer;
}
.databox td {
padding-top: 15px;
padding-bottom: 15px;
}
td input[type=checkbox] {
ms-transform: scale(1);
moz-transform: scale(1);
o-transform: scale(1);
webkit-transform: scale(1);
transform: scale(1);
}
.c0 {
padding-left: 17px !important;
}
</style>

View File

@ -1,22 +1,32 @@
<?php
/**
Pandora FMS - http://pandorafms.com
* ==================================================
* Extension to self monitor Pandora FMS Console
*
* @category Update Manager
* @package Pandora FMS
* @subpackage Update Manager Online
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* @package category
* @subpackage category
* ============================================================================
*/
// Begin.
global $config;
check_login();
@ -36,146 +46,189 @@ if (!is_metaconsole()) {
enterprise_include_once('include/functions_update_manager.php');
$current_package = update_manager_get_current_package();
require_once 'include/functions_config.php';
if (!enterprise_installed()) {
$open = true;
}
$memory_limit_min = '500M';
$post_max_size_min = '800M';
$upload_max_filesize_min = '800M';
$memory_limit = ini_get('memory_limit');
$memory_limit = str_replace('M', '', $memory_limit);
$memory_limit = (int) $memory_limit;
if ($memory_limit < 500) {
$PHPmemory_limit_min = config_return_in_bytes($memory_limit_min);
$PHPpost_max_size_min = config_return_in_bytes($post_max_size);
$PHPupload_max_filesize_min = config_return_in_bytes($upload_max_filesize_min);
$php_settings_fine = 0;
$PHP_SETTINGS_REQUIRED = 3;
$memory_limit = config_return_in_bytes(ini_get('memory_limit'));
if ($memory_limit < $PHPmemory_limit_min) {
ui_print_error_message(
sprintf(__('Your PHP has set memory limit in %s. For avoid problems with big updates please set to 500M'), ini_get('memory_limit'))
sprintf(
__('Your PHP has set memory limit in %s. To use Update Manager Online, please set it to %s'),
ini_get('memory_limit'),
$memory_limit_min
)
);
}
$post_max_size = ini_get('post_max_size');
$post_max_size = str_replace('M', '', $post_max_size);
if ($memory_limit < 100) {
ui_print_error_message(
sprintf(__('Your PHP has set post parameter max size limit in %s. For avoid problems with big updates please set to 100M'), ini_get('post_max_size'))
);
}
$upload_max_filesize = ini_get('upload_max_filesize');
$upload_max_filesize = str_replace('M', '', $upload_max_filesize);
if ($memory_limit < 100) {
ui_print_error_message(
sprintf(__('Your PHP has set maximum allowed size for uploaded files limit in %s. For avoid problems with big updates please set to 100M'), ini_get('upload_max_filesize'))
);
}
// Translators: Do not translade Update Manager, it's the name of the program.
if (is_metaconsole()) {
echo "<style type='text/css' media='screen'>
@import 'styles/meta_pandora.css';
</style>";
}
if (is_metaconsole()) {
$baseurl = ui_get_full_url(false, false, false, false);
echo ' <link rel="stylesheet" type="text/css" href="'.$baseurl.'/godmode/update_manager/update_manager.css">';
echo "<div id='box_online' class='box_online_meta'>";
} else {
echo "<div id='box_online'>";
$php_settings_fine++;
}
echo "<span class='loading' style='font-size:18pt;'>";
echo "<img src='images/wait.gif' />";
echo '</span>';
echo '<p style="font-weight: 600;">'.__('The latest version of package installed is:').'</p>';
if ($open) {
echo '<div id="pkg_version" style="font-size:40pt;">'.$build_version.'</div>';
$post_max_size = config_return_in_bytes(ini_get('post_max_size'));
if ($post_max_size < $PHPpost_max_size_min) {
ui_print_error_message(
sprintf(
__('Your PHP has post_max_size limited to %s. To use Update Manager Online, please set it to %s'),
ini_get('post_max_size'),
$post_max_size_min
)
);
} else {
echo '<div id="pkg_version">'.$current_package.'</div>';
$php_settings_fine++;
}
echo "<div class='checking_package' style='font-size:18pt;width:100%; display: none;'>";
echo __('Checking for the newest package.');
echo '</div>';
$upload_max_filesize = config_return_in_bytes(ini_get('upload_max_filesize'));
if ($upload_max_filesize < $PHPupload_max_filesize_min) {
ui_print_error_message(
sprintf(
__('Your PHP has set maximum allowed size for uploaded files limit in %s. To use Update Manager Online, please set it to %s'),
ini_get('upload_max_filesize'),
$upload_max_filesize_min
)
);
} else {
$php_settings_fine++;
}
echo "<div class='downloading_package' style='font-size:18pt;width:100%; display: none;'>";
echo __('Downloading for the newest package.');
echo '</div>';
// Verify registry.
if (update_manager_verify_registration() === false) {
ui_require_css_file('register');
registration_wiz_modal(false, true, 'location.reload()');
ui_print_error_message(
__('Update Manager Online requires registration')
);
} else {
// Console registered.
$current_package = update_manager_get_current_package();
echo "<div class='content'></div>";
if (!enterprise_installed()) {
$open = true;
}
echo "<div class='progressbar' style='display: none;'><img class='progressbar_img' src='' /></div>";
// Translators: Do not translade Update Manager, it's the name of the program.
if (is_metaconsole()) {
echo "<style type='text/css' media='screen'>
@import 'styles/meta_pandora.css';
</style>";
}
if (is_metaconsole()) {
$baseurl = ui_get_full_url(false, false, false, false);
echo ' <link rel="stylesheet" type="text/css" href="'.$baseurl.'/godmode/update_manager/update_manager.css">';
echo "<div id='box_online' class='box_online_meta'>";
} else {
echo "<div id='box_online'>";
}
if ($php_settings_fine >= $PHP_SETTINGS_REQUIRED) {
echo "<span class='loading' style='font-size:18pt;'>";
echo "<img src='images/wait.gif' />";
echo '</span>';
}
echo '<p style="font-weight: 600;">'.__('The latest version of package installed is:').'</p>';
if ($open) {
echo '<div id="pkg_version" style="font-size:40pt;">'.$build_version.'</div>';
} else {
echo '<div id="pkg_version">'.$current_package.'</div>';
}
echo "<div class='checking_package' style='font-size:18pt;width:100%; display: none;'>";
echo __('Checking for the newest package.');
echo '</div>';
echo "<div class='downloading_package' style='font-size:18pt;width:100%; display: none;'>";
echo __('Downloading for the newest package.');
echo '</div>';
echo "<div class='content'></div>";
echo "<div class='progressbar' style='display: none;'><img class='progressbar_img' src='' /></div>";
/*
-------------------------------------------------------------------------
* -------------------------------------------------------------------------
* Hello there! :)
* We added some of what seems to be "buggy" messages to the openSource
* version recently. This is not to force open-source users to move to the
* enterprise version, this is just to inform people using Pandora FMS open
* source that it requires skilled people to maintain and keep it running
* smoothly without professional support. This does not imply open-source
* version is limited in any way. If you check the recently added code, it
* contains only warnings and messages, no limitations except one:
* we removed the option to add custom logo in header.
*
* In the Update Manager section, it warns about the 'danger of applying
* automated updates without a proper backup, remembering in the process
* that the Enterprise version comes with a human-tested package.
*
* Maintaining an OpenSource version with more than 500 agents is not so
* easy, that's why someone using a Pandora with 8000 agents should consider
* asking for support. It's not a joke, we know of many setups with a huge
* number of agents, and we hate to hear that “its becoming unstable and
* slow” :(
*
* You can of course remove the warnings, that's why we include the source
* and do not use any kind of trick. And that's why we added here this
* comment, to let you know this does not reflect any change in our
* opensource mentality of does the last 14 years.
* -------------------------------------------------------------------------
*/
Hello there! :)
if ($open) {
echo "<div class='update_manager_open'>
<div class='update_manager_warning'>
<div><img src='images/icono_info.png'></div>
<div><p>".__('WARNING: You are just one click away from an automated update. This may result in a damaged system, including loss of data and operativity. Check you have a recent backup. OpenSource updates are automatically created packages, and there is no WARRANTY or SUPPORT. If you need professional support and warranty, please upgrade to Enterprise Version.')."</p></div>
</div>
<div style='text-align:center; margin-top:10px;'>
<a class='update_manager_button_open' href='https://pandorafms.com/pandora-fms-enterprise/' target='_blank'>About Enterprise</a>
</div>
</div>";
}
We added some of what seems to be "buggy" messages to the openSource version
recently. This is not to force open-source users to move to the enterprise
version, this is just to inform people using Pandora FMS open source that it
requires skilled people to maintain and keep it running smoothly without
professional support. This does not imply open-source version is limited
in any way. If you check the recently added code, it contains only warnings
and messages, no limitations except one: we removed the option to add custom
logo in header. In the Update Manager section, it warns about the 'danger
of applying automated updates without a proper backup, remembering in the
process that the Enterprise version comes with a human-tested package.
Maintaining an OpenSource version with more than 500 agents is not so
easy, that's why someone using a Pandora with 8000 agents should consider
asking for support. It's not a joke, we know of many setups with a huge
number of agents, and we hate to hear that “its becoming unstable and slow” :(
You can of course remove the warnings, that's why we include the source and
do not use any kind of trick. And that's why we added here this comment, to
let you know this does not reflect any change in our opensource mentality of
does the last 14 years.
if ($php_settings_fine >= $PHP_SETTINGS_REQUIRED) {
$enterprise = enterprise_hook('update_manager_enterprise_main');
-------------------------------------------------------------------------
*/
if ($enterprise == ENTERPRISE_NOT_HOOK) {
// Open view.
update_manager_main();
}
?>
if ($open) {
echo "<div class='update_manager_open'>
<div class='update_manager_warning'>
<div><img src='images/icono_info.png'></div>
<div><p>".__('WARNING: You are just one click away from an automated update. This may result in a damaged system, including loss of data and operativity. Check you have a recent backup. OpenSource updates are automatically created packages, and there is no WARRANTY or SUPPORT. If you need professional support and warranty, please upgrade to Enterprise Version.')."</p></div>
</div>
<div style='text-align:center; margin-top:10px;'>
<a class='update_manager_button_open' href='https://pandorafms.com/pandora-fms-enterprise/' target='_blank'>About Enterprise</a>
</div>
</div>";
<script type="text/javascript">
var isopen = "<?php echo $open; ?>";
if(isopen){
$(document).ready(function() {
$('body').append( "<div id='opacidad' style='position:fixed;background:black;opacity:0.6;z-index:1'></div>" );
jQuery.post ("ajax.php",
{
"page": "general/alert_enterprise",
"message":"infomodal"},
function (data, status) {
$("#alert_messages").hide ()
.css ("opacity", 1)
.empty ()
.append (data)
.show ();
},
"html"
);
return false;
});
}
</script>
<?php
}
}
$enterprise = enterprise_hook('update_manager_enterprise_main');
if ($enterprise == ENTERPRISE_NOT_HOOK) {
// Open view.
update_manager_main();
}
?>
<script>
var isopen = "<?php echo $open; ?>";
if(isopen){
$(document).ready(function() {
$('body').append( "<div id='opacidad' style='position:fixed;background:black;opacity:0.6;z-index:1'></div>" );
jQuery.post ("ajax.php",
{
"page": "general/alert_enterprise",
"message":"infomodal"},
function (data, status) {
$("#alert_messages").hide ()
.css ("opacity", 1)
.empty ()
.append (data)
.show ();
},
"html"
);
return false;
});
}
</script>

View File

@ -45,12 +45,6 @@ $buttons = [
],
];
if (license_free()) {
$buttons['messages'] = [
'active' => ($tab == 'messages') ? true : false,
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=messages">'.html_print_image('images/email_mc.png', true, ['title' => __('Update manager messages')]).'</a>',
];
}
switch ($tab) {
case 'setup':
@ -66,10 +60,6 @@ switch ($tab) {
$title = __('Update manager » Online');
$help_header = 'update_manager_online_tab';
break;
case 'messages':
$title = __('Update manager » Messages');
break;
}
ui_print_page_header(
@ -90,10 +80,6 @@ switch ($tab) {
include $config['homedir'].'/godmode/update_manager/update_manager.offline.php';
break;
case 'messages':
include $config['homedir'].'/godmode/update_manager/update_manager.messages.php';
break;
case 'online':
default:
include $config['homedir'].'/godmode/update_manager/update_manager.online.php';

View File

@ -194,6 +194,20 @@ class ConsoleSupervisor
$this->checkCronRunning();
}
/*
* Check if instance is registered.
* NOTIF.UPDATEMANAGER.REGISTRATION
*/
$this->checkUpdateManagerRegistration();
/*
* Check if there're new messages in UM.
* NOTIF.UPDATEMANAGER.MESSAGES
*/
$this->getUMMessages();
}
@ -406,6 +420,20 @@ class ConsoleSupervisor
$this->checkCronRunning();
}
/*
* Check if instance is registered.
* NOTIF.UPDATEMANAGER.REGISTRATION
*/
$this->checkUpdateManagerRegistration();
/*
* Check if there're new messages in UM.
* NOTIF.UPDATEMANAGER.MESSAGES
*/
$this->getUMMessages();
}
@ -571,6 +599,7 @@ class ConsoleSupervisor
case 'NOTIF.UPDATEMANAGER.OPENSETUP':
case 'NOTIF.UPDATEMANAGER.UPDATE':
case 'NOTIF.UPDATEMANAGER.MINOR':
case 'NOTIF.UPDATEMANAGER.MESSAGES':
case 'NOTIF.CRON.CONFIGURED':
default:
// NOTIF.SERVER.STATUS.
@ -1913,25 +1942,15 @@ class ConsoleSupervisor
global $config;
$login = get_parameter('login', false);
if (license_free() === true
&& users_is_admin($config['id_user']) === true
) {
$login = get_parameter('login', false);
// Registration advice.
if ((isset($config['instance_registered']) === true
|| ($config['instance_registered'] != 1)) && ($login === false)
) {
$this->notify(
[
'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION',
'title' => __('This instance is not registered in the Update manager section'),
'message' => __('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_register();"> here</a> to start the registration process'),
'url' => 'javascript: force_run_register();',
]
);
} else {
$this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION');
}
if (update_manager_verify_registration() === false) {
$this->notify(
[
'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION',
'title' => __('This instance is not registered in the Update manager section'),
'message' => __('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_register();"> here</a> to start the registration process'),
'url' => 'javascript: force_run_register();',
]
);
} else {
$this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION');
}
@ -2217,4 +2236,70 @@ class ConsoleSupervisor
}
/**
* Search for messages.
*
* @return void
*/
public function getUMMessages()
{
global $config;
if (update_manager_verify_registration() === false) {
// Console not subscribed.
return;
}
// Avoid contact for messages too much often.
if (isset($config['last_um_check'])
&& time() < $config['last_um_check']
) {
return;
}
// Only ask for messages once a day.
$future = (time() + 2 * SECONDS_1HOUR);
config_update_value('last_um_check', $future);
include_once $config['homedir'].'/include/functions_update_manager.php';
$params = [
'pandora_uid' => $config['pandora_uid'],
'timezone' => $config['timezone'],
'language' => $config['language'],
];
$result = update_manager_curl_request('get_messages', $params);
try {
if ($result['success'] === true) {
$messages = json_decode($result['update_message'], true);
}
} catch (Exception $e) {
error_log($e->getMessage());
};
if (is_array($messages)) {
$source_id = get_notification_source_id(
'Official&#x20;communication'
);
foreach ($messages as $message) {
if (!isset($message['url'])) {
$message['url'] = '#';
}
$this->notify(
[
'type' => 'NOTIF.UPDATEMANAGER.MESSAGES.'.$message['id'],
'title' => $message['subject'],
'message' => base64_decode($message['message_html']),
'url' => $message['url'],
],
$source_id
);
}
}
}
}

View File

@ -442,14 +442,15 @@ function messages_get_count_sent(string $user='')
/**
* Get message overview in array
*
* @param string $order How to order them valid:
* (status (default), subject, timestamp, sender).
* @param string $order_dir Direction of order
* (ASC = Ascending, DESC = Descending).
* @param boolean $incl_read Include read messages in return.
* @param boolean $incl_source_info Include source info.
* @param integer $limit Maximum number of result in the query.
* @param array $other_filter Add a filter on main query.
* @param string $order How to order them valid:
* (status (default), subject, timestamp, sender).
* @param string $order_dir Direction of order
* (ASC = Ascending, DESC = Descending).
* @param boolean $incl_read Include read messages in return.
* @param boolean $incl_source_info Include source info.
* @param integer $limit Maximum number of result in the query.
* @param array $other_filter Add a filter on main query.
* @param string $join_other_filter How to join filter on main query.
*
* @return integer The number of messages this user has
*/
@ -459,7 +460,8 @@ function messages_get_overview(
bool $incl_read=true,
bool $incl_source_info=false,
int $limit=0,
array $other_filter=[]
array $other_filter=[],
string $join_other_filter='AND'
) {
global $config;
@ -529,7 +531,11 @@ function messages_get_overview(
$config['id_user'],
$config['id_user'],
$read,
db_format_array_where_clause_sql($other_filter, 'AND', ' AND '),
db_format_array_where_clause_sql(
$other_filter,
$join_other_filter,
' AND '
),
$order,
($limit !== 0) ? ' LIMIT '.$limit : ''
);

View File

@ -972,13 +972,32 @@ function notifications_print_dropdown()
*/
function notifications_print_dropdown_element($message_info)
{
$action = '';
switch ($message_info['description']) {
case 'Official&#x20;communication':
$action = 'show_modal(this.id);';
$target = '';
$body_preview = __('Click here to get more information');
break;
default:
$action = '';
$target = '_blank';
$body_preview = strip_tags(
io_safe_output($message_info['mensaje']),
'<br><pre>'
);
break;
}
return sprintf(
"<a
class='notification-item'
onclick='click_on_notification_toast(event)'
onclick='%s'
id='notification-item-id-%s'
href='%s'
target='_blank'
target='%s'
>
%s
<div class='notification-info'>
@ -990,10 +1009,12 @@ function notifications_print_dropdown_element($message_info)
</p>
</div>
</a>",
$action.';click_on_notification_toast(event)',
$message_info['id_mensaje'],
messages_get_url($message_info['id_mensaje']),
$target,
html_print_image('images/'.$message_info['icon'], true),
io_safe_output($message_info['subject']),
strip_tags(io_safe_output($message_info['mensaje']), '<br><pre>')
$body_preview
);
}

File diff suppressed because it is too large Load Diff

View File

@ -70,13 +70,13 @@
float: right;
}
.ui-dialog .ui-dialog-buttonpane button {
margin: 0.5em 1em 0.5em 0 !important;
cursor: pointer !important;
background: white !important;
background-color: white !important;
border: 1px solid #82b92e !important;
height: 30px !important;
width: 90px !important;
margin: 0.5em 1em 0.5em 0;
cursor: pointer;
background: white;
background-color: white;
border: 1px solid #82b92e;
height: 30px;
width: 90px;
}
.ui-widget-header .ui-icon {
background-image: url(../images/ui-icons_444444_256x240.png) !important;

View File

@ -4586,14 +4586,14 @@ div#dialog_messages table th:last-child {
}
.notification-item:hover {
border: #ccc solid 1px;
text-decoration: none;
}
.notification-item > * {
padding-left: 15px;
pointer-events: none;
}
.notification-item:hover {
text-decoration: none;
.notification-item > img {
width: 75px;
}
.notification-info {

View File

@ -0,0 +1,57 @@
input[type="submit"].submit-cancel,
button.submit-cancel {
color: #fb4444 !important;
border: 1px solid #fb4444 !important;
background: #fff !important;
padding: 5px;
font-size: 1.3em;
margin: 0.5em 1em 0.5em 0 !important;
cursor: pointer !important;
text-align: center !important;
height: 30px !important;
width: 90px !important;
}
input[type="submit"].submit-cancel:hover,
button.submit-cancel:hover {
color: #fff !important;
background: #fb4444 !important;
}
input[type="submit"].submit-next,
button.submit-next,
input[type="button"].submit-next {
color: #82b92e !important;
border: 1px solid #82b92e !important;
background: #fff !important;
padding: 5px;
font-size: 1.3em;
margin: 0.5em 1em 0.5em 0 !important;
cursor: pointer !important;
text-align: center !important;
height: 30px !important;
}
input[type="submit"].submit-next:hover,
button.submit-next:hover,
input[type="button"].submit-next:hover {
color: #fff !important;
background: #82b92e !important;
}
div.submit_buttons_container {
position: absolute;
margin: 10px auto 0px;
bottom: 0px;
width: 90%;
position: relative;
clear: both;
height: 4em;
}
.license_text {
width: 95%;
overflow-y: auto;
text-align: justify;
margin: 1em auto;
}

View File

@ -902,15 +902,6 @@ clear_pandora_error_for_header();
$config['logged'] = false;
extensions_load_extensions($process_login);
// Check for update manager messages
if (license_free() && is_user_admin($config['id_user'])
&& (($config['last_um_check'] < time())
|| (!isset($config['last_um_check'])))
) {
include_once 'include/functions_update_manager.php';
update_manager_download_messages();
}
if ($process_login) {
// Call all extensions login function
extensions_call_login_function();
@ -986,31 +977,9 @@ if ($old_global_counter_chat != $now_global_counter_chat) {
}
}
// Pop-ups display order:
// 1) login_required (timezone and email)
// 2) identification (newsletter and register)
// 3) last_message (update manager message popup
// 4) login_help (online help, enterpirse version, forums, documentation)
if (is_user_admin($config['id_user'])
&& (!isset($config['initial_wizard']) || $config['initial_wizard'] != 1)
) {
include_once 'general/login_required.php';
}
require_once 'general/register.php';
if (get_parameter('login', 0) !== 0) {
// Display news dialog
include_once 'general/news_dialog.php';
// Display login help info dialog
// If it's configured to not skip this
$display_previous_popup = false;
if (license_free() && is_user_admin($config['id_user']) && $config['initial_wizard'] == 1) {
$display_previous_popup = include_once 'general/login_identification_wizard.php';
if ($display_previous_popup === false) {
$display_previous_popup = include_once 'general/last_message.php';
}
}
if ((!isset($config['skip_login_help_dialog']) || $config['skip_login_help_dialog'] == 0)
&& $display_previous_popup === false
&& $config['initial_wizard'] == 1
@ -1223,6 +1192,11 @@ if ($config['pure'] == 0) {
// main_pure
}
echo '<div id="wiz_container">';
echo '</div>';
echo '<div id="um_msg_receiver">';
echo '</div>';
if ($config['pure'] == 0) {
echo '</div>';
@ -1277,8 +1251,6 @@ require 'include/php_to_js_values.php';
$("HTML, BODY").animate({ scrollTop: 0 }, 500);
}
//Initial load of page
$(document).ready(adjustFooter);
@ -1303,66 +1275,109 @@ require 'include/php_to_js_values.php';
})();
function force_run_register () {
run_identification_wizard (1, 0, 0);
jQuery.post ("ajax.php",
{
"page": "general/register",
"load_wizards": 'registration'
},
function (data) {
$('#wiz_container').empty ()
.html (data);
show_registration_wizard();
},
"html"
);
}
function force_run_newsletter () {
run_identification_wizard (0, 1, 0);
jQuery.post ("ajax.php",
{
"page": "general/register",
"load_wizards": 'newsletter'
},
function (data) {
$('#wiz_container').empty ()
.html (data);
show_newsletter_wizard ();
},
"html"
);
}
function first_time_identification () {
run_identification_wizard (-1, -1, 1);
jQuery.post ("ajax.php",
{
"page": "general/register",
"load_wizards": 'initial'
},
function (data) {
$('#wiz_container').empty ()
.html (data);
run_configuration_wizard ();
},
"html"
);
}
var times_fired_register_wizard = 0;
function run_identification_wizard (register, newsletter , return_button) {
if (times_fired_register_wizard) {
$(".ui-dialog-titlebar-close").show();
//Reset some values
$("#label-email-newsletter").hide();
$("#text-email-newsletter").hide();
$("#required-email-newsletter").hide();
$("#checkbox-register").removeAttr('checked');
$("#checkbox-newsletter").removeAttr('checked');
// Hide or show parts
if (register == 1) {
$("#checkbox-register").show();
$("#label-register").show ();
}
if (register == 0) {
$("#checkbox-register").attr ('style', 'display: none !important');
$("#label-register").hide ();
}
if (newsletter == 1) {
$("#checkbox-newsletter").show();
$("#label-newsletter").show ();
}
if (newsletter == 0) {
$("#checkbox-newsletter").attr ('style', 'display: none !important');
$("#label-newsletter").hide ();
}
$("#login_accept_register").dialog('open');
}
else {
$(".ui-dialog-titlebar-close").show();
$("#container").append('<div class="id_wizard"></div>');
jQuery.post ("ajax.php",
{"page": "general/login_identification_wizard",
"not_return": 1,
"force_register": register,
"force_newsletter": newsletter,
"return_button": return_button},
function (data) {
$(".id_wizard").hide ()
.empty ()
.append (data);
},
"html"
function show_modal(id) {
var match = /notification-(.*)-id-([0-9]+)/.exec(id);
if (!match) {
console.error(
"Cannot handle toast click event. Id not valid: ",
event.target.id
);
return;
}
times_fired_register_wizard++;
return false;
jQuery.post ("ajax.php",
{
"page": "godmode/setup/setup_notifications",
"get_notification": 1,
"id": match[2]
},
function (data) {
notifications_hide();
try {
var json = JSON.parse(data);
$('#um_msg_receiver')
.empty ()
.html (json.mensaje);
$('#um_msg_receiver').prop('title', json.subject);
// Launch modal.
$("#um_msg_receiver").dialog({
resizable: true,
draggable: true,
modal: true,
width: 800,
buttons: [
{
text: "OK",
click: function() {
$( this ).dialog( "close" );
}
}
],
overlay: {
opacity: 0.5,
background: "black"
},
closeOnEscape: false,
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); }
});
$(".ui-widget-overlay").css("background", "#000");
$(".ui-widget-overlay").css("opacity", 0.6);
$(".ui-draggable").css("cursor", "inherit");
} catch (error) {
console.log(error);
}
},
"html"
);
}
//Dynamically assign footer position and width.

View File

@ -1303,7 +1303,7 @@ INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `
("Message", "icono_info_mr.png", 86400, 1, 1, 0),
("Pending&#x20;task", "icono_info_mr.png", 86400, 1, 1, 0),
("Advertisement", "icono_info_mr.png", 86400, 1, 1, 0),
("Official&#x20;communication", "icono_info_mr.png", 86400, 1, 1, 0),
("Official&#x20;communication", "icono_logo_pandora.png", 86400, 1, 1, 0),
("Sugerence", "icono_info_mr.png", 86400, 1, 1, 0);
--
@ -1314,4 +1314,8 @@ INSERT INTO `tnotification_source_user`(`id_source`,`id_user`,`enabled`,`also_ma
INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Message";
INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES
((SELECT `id` FROM `tnotification_source` WHERE `description`="Official&#x20;communication"), "admin", 1, 0);
UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System&#x20;status' OR `description` = 'Official&#x20;communication';