Merge remote-tracking branch 'origin/develop' into fix/styles

This commit is contained in:
fbsanchez 2019-05-29 12:24:28 +02:00
commit 5131c24772
13 changed files with 477 additions and 114 deletions

View File

@ -16,4 +16,10 @@ INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `als
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';
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_user` VARCHAR(60);
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_pass` VARCHAR(45);
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_enabled` TINYINT(1) DEFAULT '1';
COMMIT;

View File

@ -1288,6 +1288,11 @@ alter table tusuario add autorefresh_white_list text not null default '';
ALTER TABLE tusuario ADD COLUMN `time_autorefresh` int(5) unsigned NOT NULL default '30';
ALTER TABLE `tusuario` DROP COLUMN `flash_chart`;
ALTER TABLE `tusuario` ADD COLUMN `default_custom_view` int(10) unsigned NULL default '0';
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_user` VARCHAR(60);
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_pass` VARCHAR(45);
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_enabled` TINYINT(1);
-- ---------------------------------------------------------------------
-- Table `tagente_modulo`

View File

@ -140,7 +140,7 @@ $registration = isset($config['pandora_uid']) !== true
|| $config['pandora_uid'] == '';
if ($initial) {
if ($initial && users_is_admin()) {
// Show all forms in order.
// 1- Ask for email, timezone, etc. Fullfill alerts and user mail.
config_wiz_modal(
@ -150,7 +150,7 @@ if ($initial) {
);
}
if ($registration) {
if ($registration && users_is_admin()) {
// Prepare registration wizard, not launch. leave control to flow.
registration_wiz_modal(
false,

View File

@ -66,6 +66,12 @@ $table_remote->class = 'databox filters';
$table_remote->size['name'] = '30%';
$table_remote->style['name'] = 'font-weight: bold';
// Enable eHorus user configuration.
$row = [];
$row['name'] = ('eHorus configuration at user level');
$row['control'] = html_print_checkbox_switch('ehorus_user_level_conf', 1, $config['ehorus_user_level_conf'], true);
$table_remote->data['ehorus_user_level_conf'] = $row;
// User.
$row = [];
$row['name'] = __('User');
@ -163,9 +169,19 @@ echo '</div>';
?>
<script type="text/javascript">
if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
$('#form_remote').hide();
if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked'))
{
$('#form_remote').hide();
}
if($('input:checkbox[name="ehorus_user_level_conf"]').is(':checked'))
{
$('#ehorus-remote-setup-ehorus_user').hide();
$('#ehorus-remote-setup-ehorus_pass').hide()
}
$('#form_enable').css('margin-bottom','20px');
var showFields = function () {
$('#form_remote').show();
@ -173,6 +189,17 @@ if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
var hideFields = function () {
$('#form_remote').hide();
}
var hideUserPass = function () {
$('#ehorus-remote-setup-ehorus_user').hide();
$('#ehorus-remote-setup-ehorus_pass').hide();
}
var showUserPass = function () {
$('#ehorus-remote-setup-ehorus_user').show();
$('#ehorus-remote-setup-ehorus_pass').show();
}
var handleEnable = function (event) {
var is_checked = $('input:checkbox[name="ehorus_enabled"]').is(':checked');
if (event.target.value == '1' && is_checked) {
@ -184,15 +211,32 @@ if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
$('input:checkbox[name="ehorus_enabled"]').attr('checked', false);
};
}
var handleUserLevel = function(event) {
var is_checked = $('input:checkbox[name="ehorus_enabled"]').is(':checked');
var is_checked_userlevel = $('input:checkbox[name="ehorus_user_level_conf"]').is(':checked');
if (event.target.value == '1' && is_checked && !is_checked_userlevel) {
showUserPass();
$('input:checkbox[name="ehorus_user_level_conf"]').attr('checked', true);
}
else {
hideUserPass();
$('input:checkbox[name="ehorus_user_level_conf"]').attr('checked', false);
};
}
$('input:checkbox[name="ehorus_enabled"]').change(handleEnable);
$('input:checkbox[name="ehorus_user_level_conf"]').change(handleUserLevel);
var handleTest = function (event) {
var user = $('input#text-ehorus_user').val();
var pass = $('input#password-ehorus_pass').val();
var host = $('input#text-ehorus_hostname').val();
var port = $('input#text-ehorus_port').val();
var timeout = Number.parseInt($('input#text-ehorus_req_timeout').val(), 10);
var is_checked_user_level = $('input:checkbox[name="ehorus_user_level_conf"]').is(':checked');
var timeoutMessage = '<?php echo __('Connection timeout'); ?>';
var badRequestMessage = '<?php echo __('Empty user or password'); ?>';
var notFoundMessage = '<?php echo __('User not found'); ?>';
@ -230,7 +274,7 @@ if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
hideFailureImage();
hideMessage();
showLoadingImage();
$.ajax({
url: 'https://' + host + ':' + port + '/login',
type: 'POST',
@ -245,9 +289,11 @@ if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
showSuccessImage();
})
.fail(function(xhr, textStatus, errorThrown) {
showFailureImage();
if (xhr.status === 400) {
if((xhr.status === 400 || xhr.status === 403) && is_checked_user_level)
{
showSuccessImage();
return;
}else if (xhr.status === 400) {
changeTestMessage(badRequestMessage);
}
else if (xhr.status === 401 || xhr.status === 403) {
@ -262,6 +308,8 @@ if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
else {
changeTestMessage(errorThrown);
}
showFailureImage();
showMessage();
})
.always(function(xhr, textStatus) {
@ -269,4 +317,7 @@ if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
});
}
$('input#button-test-ehorus').click(handleTest);
</script>

View File

@ -1,18 +1,36 @@
<?php
/**
* Update manager client options.
*
* @category Update Manager
* @package Pandora FMS
* @subpackage Community
* @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.
* ============================================================================
*/
// 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.
// Begin.
global $config;
require_once __DIR__.'/../../include/functions_users.php';
check_login();
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
@ -27,12 +45,38 @@ $action_update_url_update_manager = (bool) get_parameter(
0
);
if (users_is_admin()) {
$update_manager_disconnect = get_parameter(
'um_disconnect_console',
0
);
if ($update_manager_disconnect) {
config_update_value(
'pandora_uid',
'OFFLINE'
);
}
}
if (!$action_update_url_update_manager) {
$url_update_manager = get_parameter('url_update_manager', $config['url_update_manager']);
$update_manager_proxy_server = get_parameter('update_manager_proxy_server', $config['update_manager_proxy_server']);
$update_manager_proxy_port = get_parameter('update_manager_proxy_port', $config['update_manager_proxy_port']);
$update_manager_proxy_user = get_parameter('update_manager_proxy_user', $config['update_manager_proxy_user']);
$update_manager_proxy_password = get_parameter('update_manager_proxy_password', $config['update_manager_proxy_password']);
$update_manager_proxy_server = get_parameter(
'update_manager_proxy_server',
$config['update_manager_proxy_server']
);
$update_manager_proxy_port = get_parameter(
'update_manager_proxy_port',
$config['update_manager_proxy_port']
);
$update_manager_proxy_user = get_parameter(
'update_manager_proxy_user',
$config['update_manager_proxy_user']
);
$update_manager_proxy_password = get_parameter(
'update_manager_proxy_password',
$config['update_manager_proxy_password']
);
if ($action_update_url_update_manager) {
@ -69,7 +113,10 @@ if (!$action_update_url_update_manager) {
}
if ($result && license_free()) {
$result = config_update_value('identification_reminder', $identification_reminder);
$result = config_update_value(
'identification_reminder',
$identification_reminder
);
}
ui_print_result_message(
@ -189,11 +236,26 @@ $table->data[4][1] = html_print_input_password(
true
);
$table->data[5][0] = __('Registration ID:');
$table->data[5][1] = '<i>'.$config['pandora_uid'].'</i>';
if (update_manager_verify_registration() === true && users_is_admin()) {
$table->data[6][0] = __('Cancel registration:');
$table->data[6][1] = '<a href="';
$table->data[6][1] .= ui_get_full_url(
'index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=setup&um_disconnect_console=1'
);
$table->data[6][1] .= '" onclick="if(confirm(\'Are you sure?\')) {return true;} else { return false; }">'.__('Unregister').'</a>';
}
if (license_free()) {
$config['identification_reminder'] = isset($config['identification_reminder']) ? $config['identification_reminder'] : 1;
$table->data[6][0] = __('Pandora FMS community reminder').ui_print_help_tip(__('Every 8 days, a message is displayed to admin users to remember to register this Pandora instance'), true);
$table->data[6][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('identification_reminder', 1, '', $config['identification_reminder'], true).'&nbsp;&nbsp;';
$table->data[6][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('identification_reminder', 0, '', $config['identification_reminder'], true);
$table->data[7][0] = __('Pandora FMS community reminder').ui_print_help_tip(__('Every 8 days, a message is displayed to admin users to remember to register this Pandora instance'), true);
$table->data[7][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('identification_reminder', 1, '', $config['identification_reminder'], true).'&nbsp;&nbsp;';
$table->data[7][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('identification_reminder', 0, '', $config['identification_reminder'], true);
}
html_print_input_hidden('action_update_url_update_manager', 1);

View File

@ -151,6 +151,12 @@ if ($new_user && $config['admin_can_add_user']) {
$user_info['metaconsole_assigned_server'] = '';
$user_info['metaconsole_access_node'] = 0;
}
if ($config['ehorus_user_level_conf']) {
$user_info['ehorus_user_level_user'] = '';
$user_info['ehorus_user_level_pass'] = '';
$user_info['ehorus_user_level_enabled'] = true;
}
}
if ($create_user) {
@ -215,6 +221,19 @@ if ($create_user) {
$values['strict_acl'] = (bool) get_parameter('strict_acl', false);
$values['session_time'] = (int) get_parameter('session_time', 0);
// eHorus user level conf
if ($config['ehorus_user_level_conf']) {
$values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false);
if ($values['ehorus_user_level_enabled'] === true) {
$values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user');
$values['ehorus_user_level_pass'] = (string) get_parameter('ehorus_user_level_pass');
} else {
$values['ehorus_user_level_user'] = null;
$values['ehorus_user_level_pass'] = null;
}
}
if ($id == '') {
ui_print_error_message(__('User ID cannot be empty'));
$user_info = $values;
@ -298,6 +317,13 @@ if ($update_user) {
$values['timezone'] = (string) get_parameter('timezone');
$values['default_event_filter'] = (int) get_parameter('default_event_filter');
$values['default_custom_view'] = (int) get_parameter('default_custom_view');
// eHorus user level conf
$values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false);
$values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user');
$values['ehorus_user_level_pass'] = (string) get_parameter('ehorus_user_level_pass');
$dashboard = get_parameter('dashboard', '');
$visual_console = get_parameter('visual_console', '');
@ -760,6 +786,7 @@ if (enterprise_installed() && !is_metaconsole()) {
$values['Dashboard'] = __('Dashboard');
}
$table->data[12][1] = html_print_select($values, 'section', io_safe_output($user_info['section']), 'show_data_section();', '', -1, true, false, false);
if (enterprise_installed()) {
@ -842,6 +869,16 @@ foreach ($event_filter_data as $filter) {
$table->data[16][0] = __('Default event filter');
$table->data[16][1] = html_print_select($event_filter, 'default_event_filter', $user_info['default_event_filter'], '', '', __('None'), true, false, false);
if ($config['ehorus_user_level_conf']) {
$table->data[17][0] = __('eHorus user acces enabled');
$table->data[17][1] = html_print_checkbox('ehorus_user_level_enabled', 1, $user_info['ehorus_user_level_enabled'], true);
$table->data[18][0] = __('eHorus user');
$table->data[19][0] = __('eHorus password');
$table->data[18][1] = html_print_input_text('ehorus_user_level_user', $user_info['ehorus_user_level_user'], '', 15, 45, true);
$table->data[19][1] = html_print_input_password('ehorus_user_level_pass', io_output_password($user_info['ehorus_user_level_pass']), '', 15, 45, true);
}
if ($meta) {
enterprise_include_once('include/functions_metaconsole.php');
@ -933,6 +970,11 @@ $(document).ready (function () {
$('#checkbox-metaconsole_agents_manager').trigger('change');
show_data_section();
$('#checkbox-ehorus_user_level_enabled').change(function () {
switch_ehorus_conf();
});
$('#checkbox-ehorus_user_level_enabled').trigger('change');
});
function show_data_section () {
@ -987,5 +1029,21 @@ function show_data_section () {
}
}
function switch_ehorus_conf()
{
if(!$('#checkbox-ehorus_user_level_enabled').prop('checked'))
{
$("#user_configuration_table-18").hide();
$("#user_configuration_table-19").hide();
}else
{
$("#user_configuration_table-18").show();
$("#user_configuration_table-19").show()
}
}
/* ]]> */
</script>

View File

@ -1353,6 +1353,10 @@ function config_update_config()
$error_update[] = __('Enable eHorus');
}
if (!config_update_value('ehorus_user_level_conf', (int) get_parameter('ehorus_user_level_conf', 0))) {
$error_update[] = __('eHorus user login');
}
if (!config_update_value('ehorus_user', (string) get_parameter('ehorus_user', $config['ehorus_user']))) {
$error_update[] = __('eHorus user');
}

View File

@ -865,50 +865,63 @@ function show_newsletter_wizard() {
var language = $("#language").val();
var email_identification = $("#text-email-newsletter").val();
jQuery.post (
"ajax.php",
{
"page": "general/register",
"register_newsletter": 1,
"email": email_identification
},
function (data) {
cl = '';
msg = 'no response';
try {
json = JSON.parse(data);
cl = json.status
msg = json.message;
} catch (error) {
msg = 'Failed: ' + error;
cl = 'error';
}
if (!cl || cl == 'error') {
cl = 'error';
} else {
// Success.
}
$('#news_result_content').html(msg);
$('#news_result').addClass(cl);
$('#news_result').dialog({
buttons: {
'Ok': function() {
$(this).dialog('close');
$("#newsletter_wizard").dialog('close');
<?php
if (isset($callback) && $callback != '') {
echo $callback;
}
?>
}
if (email_identification == '') {
msg = '<?php echo __('You must specify an email'); ?>';
$('#news_result_content').html(msg);
$('#news_result').dialog({
buttons: {
'Ok': function() {
$(this).dialog('close');
}
});
}
);
}
});
} else {
jQuery.post (
"ajax.php",
{
"page": "general/register",
"register_newsletter": 1,
"email": email_identification
},
function (data) {
cl = '';
msg = 'no response';
try {
json = JSON.parse(data);
cl = json.status
msg = json.message;
} catch (error) {
msg = 'Failed: ' + error;
cl = 'error';
}
if (!cl || cl == 'error') {
cl = 'error';
} else {
// Success.
}
$('#news_result_content').html(msg);
$('#news_result').addClass(cl);
$('#news_result').dialog({
buttons: {
'Ok': function() {
$(this).dialog('close');
$("#newsletter_wizard").dialog('close');
<?php
if (isset($callback) && $callback != '') {
echo $callback;
}
?>
}
}
});
}
);
}
}
});
}
@ -1570,15 +1583,20 @@ function update_manager_register_instance()
global $config;
$email = db_get_value('email', 'tusuario', 'id_user', $config['id_user']);
$um_config_values = update_manager_get_config_values();
$params = [
'language' => $config['language'],
'timezone' => $config['timezone'],
'email' => $email,
'license' => db_get_value_filter(
'value',
'tupdate_settings',
['key' => 'customer_key']
),
'action' => 'newest_package',
'license' => $um_config_values['license'],
'limit_count' => $um_config_values['limit_count'],
'current_package' => $um_config_values['current_update'],
'version' => $um_config_values['version'],
'build' => $um_config_values['build'],
'puid' => $um_config_values['puid'],
'email' => $email,
'language' => $config['language'],
'timezone' => $config['timezone'],
];
$result = update_manager_curl_request('new_register', $params);

View File

@ -4965,7 +4965,8 @@ input:checked + .p-slider:before {
}
.user_edit_first_row,
.user_edit_second_row {
.user_edit_second_row,
.user_edit_third_row {
margin-bottom: 20px;
}

View File

@ -58,6 +58,12 @@ $curl_timeout = $config['ehorus_req_timeout'];
$base_url = 'https://'.$hostname.':'.$port;
// If user login is enabled, fetch user and pass from user info
if ($config['ehorus_user_level_conf']) {
$user = $user_info['ehorus_user_level_user'];
$password = io_safe_output(io_output_password($user_info['ehorus_user_level_pass']));
}
// Get the login auth token
$login_path = '/api/login';
$body = [

View File

@ -1261,38 +1261,47 @@ if (enterprise_installed() && $config['log_collector']) {
// EHorus tab.
if ($config['ehorus_enabled'] && !empty($config['ehorus_custom_field'])
&& (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || is_user_admin($config['id_user']))
&& (check_acl_one_of_groups(
$config['id_user'],
$all_groups,
'AW'
) || is_user_admin($config['id_user']))
) {
$ehorus_agent_id = agents_get_agent_custom_field($id_agente, $config['ehorus_custom_field']);
if (!empty($ehorus_agent_id)) {
$tab_url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=ehorus&id_agente='.$id_agente;
$ehorus_tab['text'] = '<a href="'.$tab_url.'" class="ehorus_tab">'.html_print_image('images/ehorus/ehorus.png', true, [ 'title' => __('eHorus')]).'</a>';
$user_info = users_get_user_by_id($config['id_user']);
if ($config['ehorus_user_level_conf'] && !$user_info['ehorus_user_level_enabled']) {
// If ehorus user configuration is enabled, and userr acces level is disabled do not show eHorus tab.
} else {
$ehorus_agent_id = agents_get_agent_custom_field($id_agente, $config['ehorus_custom_field']);
if (!empty($ehorus_agent_id)) {
$tab_url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=ehorus&id_agente='.$id_agente;
$ehorus_tab['text'] = '<a href="'.$tab_url.'" class="ehorus_tab">'.html_print_image('images/ehorus/ehorus.png', true, [ 'title' => __('eHorus')]).'</a>';
// Hidden subtab layer.
$ehorus_tab['sub_menu'] = '<ul class="mn subsubmenu" style="float:none;">';
$ehorus_tab['sub_menu'] .= '<a class="tab_terminal" href="'.$tab_url.'&client_tab=terminal">';
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/terminal.png', true, [ 'title' => __('Terminal')]);
$ehorus_tab['sub_menu'] .= '</li>';
$ehorus_tab['sub_menu'] .= '</a>';
$ehorus_tab['sub_menu'] .= '<a class="tab_display" href="'.$tab_url.'&client_tab=display">';
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/vnc.png', true, [ 'title' => __('Display')]);
$ehorus_tab['sub_menu'] .= '</li>';
$ehorus_tab['sub_menu'] .= '</a>';
$ehorus_tab['sub_menu'] .= '<a class="tab_processes" href="'.$tab_url.'&client_tab=processes">';
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/processes.png', true, [ 'title' => __('Processes')]);
$ehorus_tab['sub_menu'] .= '</li>';
$ehorus_tab['sub_menu'] .= '</a>';
$ehorus_tab['sub_menu'] .= '<a class="tab_services" href="'.$tab_url.'&client_tab=services">';
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/services.png', true, [ 'title' => __('Services')]);
$ehorus_tab['sub_menu'] .= '</li>';
$ehorus_tab['sub_menu'] .= '</a>';
$ehorus_tab['sub_menu'] .= '<a class="tab_files" href="'.$tab_url.'&client_tab=files">';
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/files.png', true, [ 'title' => __('Files')]);
$ehorus_tab['sub_menu'] .= '</li>';
$ehorus_tab['sub_menu'] .= '</a>';
$ehorus_tab['sub_menu'] .= '</ul>';
// Hidden subtab layer.
$ehorus_tab['sub_menu'] = '<ul class="mn subsubmenu" style="float:none;">';
$ehorus_tab['sub_menu'] .= '<a class="tab_terminal" href="'.$tab_url.'&client_tab=terminal">';
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/terminal.png', true, [ 'title' => __('Terminal')]);
$ehorus_tab['sub_menu'] .= '</li>';
$ehorus_tab['sub_menu'] .= '</a>';
$ehorus_tab['sub_menu'] .= '<a class="tab_display" href="'.$tab_url.'&client_tab=display">';
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/vnc.png', true, [ 'title' => __('Display')]);
$ehorus_tab['sub_menu'] .= '</li>';
$ehorus_tab['sub_menu'] .= '</a>';
$ehorus_tab['sub_menu'] .= '<a class="tab_processes" href="'.$tab_url.'&client_tab=processes">';
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/processes.png', true, [ 'title' => __('Processes')]);
$ehorus_tab['sub_menu'] .= '</li>';
$ehorus_tab['sub_menu'] .= '</a>';
$ehorus_tab['sub_menu'] .= '<a class="tab_services" href="'.$tab_url.'&client_tab=services">';
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/services.png', true, [ 'title' => __('Services')]);
$ehorus_tab['sub_menu'] .= '</li>';
$ehorus_tab['sub_menu'] .= '</a>';
$ehorus_tab['sub_menu'] .= '<a class="tab_files" href="'.$tab_url.'&client_tab=files">';
$ehorus_tab['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'.html_print_image('images/ehorus/files.png', true, [ 'title' => __('Files')]);
$ehorus_tab['sub_menu'] .= '</li>';
$ehorus_tab['sub_menu'] .= '</a>';
$ehorus_tab['sub_menu'] .= '</ul>';
$ehorus_tab['active'] = $tab == 'ehorus';
$ehorus_tab['active'] = $tab == 'ehorus';
}
}
}

View File

@ -113,6 +113,7 @@ if (isset($_GET['modified']) && !$view_mode) {
$dashboard = get_parameter('dashboard', '');
$visual_console = get_parameter('visual_console', '');
// Save autorefresh list.
$autorefresh_list = get_parameter_post('autorefresh_list');
if (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) {
@ -122,6 +123,11 @@ if (isset($_GET['modified']) && !$view_mode) {
}
$upd_info['time_autorefresh'] = (int) get_parameter('time_autorefresh', 0);
$upd_info['ehorus_user_level_user'] = get_parameter('ehorus_user_level_user');
$upd_info['ehorus_user_level_pass'] = get_parameter('ehorus_user_level_pass');
$upd_info['ehorus_user_level_enabled'] = get_parameter('ehorus_user_level_enabled', 0);
$is_admin = db_get_value('is_admin', 'tusuario', 'id_user', $id);
@ -624,6 +630,8 @@ echo '<form name="user_mod" method="post" action="'.ui_get_full_url('index.php?s
<div class="edit_user_options">'.$language.$size_pagination.$skin.$home_screen.$event_filter.$newsletter.$newsletter_reminder.$double_authentication.'</div>
<div class="edit_user_timezone">'.$timezone;
if (!is_metaconsole()) {
echo '<div id="timezone-picker">
<img id="timezone-image" src="'.$local_file.'" width="'.$map_width.'" height="'.$map_height.'" usemap="#timezone-map" />
@ -639,7 +647,61 @@ if (!is_metaconsole()) {
</div>
</div>';
echo '<div class="edit_user_button">';
if ($config['ehorus_enabled'] && $config['ehorus_user_level_conf']) {
// eHorus user remote login
$table_remote = new StdClass();
$table_remote->data = [];
$table_remote->width = '100%';
$table_remote->id = 'ehorus-remote-setup';
$table_remote->class = 'white_box';
$table_remote->size['name'] = '30%';
$table_remote->style['name'] = 'font-weight: bold';
// Title
$row = [];
$row['control'] = '<p class="edit_user_labels">'.__('eHorus user configuration').': </p>';
$table_remote->data['ehorus_user_level_conf'] = $row;
// Enable/disable eHorus for this user
$row = [];
$row['name'] = __('eHorus user acces enabled');
$row['control'] = html_print_checkbox_switch('ehorus_user_level_enabled', 1, $user_info['ehorus_user_level_enabled'], true);
$table_remote->data['ehorus_user_level_enabled'] = $row;
// User.
$row = [];
$row['name'] = __('User');
$row['control'] = html_print_input_text('ehorus_user_level_user', $user_info['ehorus_user_level_user'], '', 30, 100, true);
$table_remote->data['ehorus_user_level_user'] = $row;
// Pass.
$row = [];
$row['name'] = __('Password');
$row['control'] = html_print_input_password('ehorus_user_level_pass', io_output_password($user_info['ehorus_user_level_pass']), '', 30, 100, true);
$table_remote->data['ehorus_user_level_pass'] = $row;
// Test.
$ehorus_port = db_get_value('value', 'tconfig', 'token', 'ehorus_port');
$ehorus_host = db_get_value('value', 'tconfig', 'token', 'ehorus_hostname');
$row = [];
$row['name'] = __('Test');
$row['control'] = html_print_button(__('Start'), 'test-ehorus', false, 'ehorus_connection_test(&quot;'.$ehorus_host.'&quot;,'.$ehorus_port.')', 'class="sub next"', true);
$row['control'] .= '&nbsp;<span id="test-ehorus-spinner" style="display:none;">&nbsp;'.html_print_image('images/spinner.gif', true).'</span>';
$row['control'] .= '&nbsp;<span id="test-ehorus-success" style="display:none;">&nbsp;'.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
$row['control'] .= '&nbsp;<span id="test-ehorus-failure" style="display:none;">&nbsp;'.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
$row['control'] .= '<span id="test-ehorus-message" style="display:none;"></span>';
$table_remote->data['ehorus_test'] = $row;
echo '<div class="ehorus_user_conf">';
html_print_table($table_remote);
echo '</div>';
}
echo '<div class="edit_user_button">';
if (!$config['user_can_update_info']) {
echo '<i>'.__('You can not change your user info under the current authentication scheme').'</i>';
} else {
@ -648,8 +710,7 @@ if (!$config['user_can_update_info']) {
}
echo '</div>';
echo '</form>';
echo '</form>';
echo '<div id="edit_user_profiles" class="white_box">';
if (!defined('METACONSOLE')) {
@ -748,13 +809,13 @@ if (!defined('METACONSOLE')) {
});
});
</script>
<?php
// Include OpenLayers and timezone user map library.
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/timezonepicker/lib/jquery.timezone-picker.min.js').'"></script>'."\n\t";
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/timezonepicker/lib/jquery.maphilight.min.js').'"></script>'."\n\t";
// Closes no meta condition.
}
?>
<script language="javascript" type="text/javascript">
@ -1079,4 +1140,83 @@ function show_double_auth_deactivation () {
})
.show();
}
function ehorus_connection_test(host, port) {
var user = $('input#text-ehorus_user_level_user').val();
var pass = $('input#password-ehorus_user_level_pass').val();
debugger;
var badRequestMessage = '<?php echo __('Empty user or password'); ?>';
var notFoundMessage = '<?php echo __('User not found'); ?>';
var invalidPassMessage = '<?php echo __('Invalid password'); ?>';
var hideLoadingImage = function () {
$('#test-ehorus-spinner').hide();
}
var showLoadingImage = function () {
$('#test-ehorus-spinner').show();
}
var hideSuccessImage = function () {
$('#test-ehorus-success').hide();
}
var showSuccessImage = function () {
$('#test-ehorus-success').show();
}
var hideFailureImage = function () {
$('#test-ehorus-failure').hide();
}
var showFailureImage = function () {
$('#test-ehorus-failure').show();
}
var hideMessage = function () {
$('#test-ehorus-message').hide();
}
var showMessage = function () {
$('#test-ehorus-message').show();
}
var changeTestMessage = function (message) {
$('#test-ehorus-message').text(message);
}
hideSuccessImage();
hideFailureImage();
hideMessage();
showLoadingImage();
$.ajax({
url: 'https://' + host + ':' + port + '/login',
type: 'POST',
dataType: 'json',
data: {
user: user,
pass: pass
}
})
.done(function(data, textStatus, xhr) {
showSuccessImage();
})
.fail(function(xhr, textStatus, errorThrown) {
showFailureImage();
if (xhr.status === 400) {
changeTestMessage(badRequestMessage);
}
else if (xhr.status === 401 || xhr.status === 403) {
changeTestMessage(invalidPassMessage);
}
else if (xhr.status === 404) {
changeTestMessage(notFoundMessage);
}
else if (errorThrown === 'timeout') {
changeTestMessage(timeoutMessage);
}
else {
changeTestMessage(errorThrown);
}
showMessage();
})
.always(function(xhr, textStatus) {
hideLoadingImage();
});
}
</script>

View File

@ -1146,6 +1146,9 @@ CREATE TABLE IF NOT EXISTS `tusuario` (
`autorefresh_white_list` text not null default '',
`time_autorefresh` int(5) unsigned NOT NULL default '30',
`default_custom_view` int(10) unsigned NULL default '0',
`ehorus_user_level_user` VARCHAR(60),
`ehorus_user_level_pass` VARCHAR(45),
`ehorus_user_level_enabled` TINYINT(1),
CONSTRAINT `fk_filter_id` FOREIGN KEY (`id_filter`) REFERENCES tevent_filter (`id_filter`) ON DELETE SET NULL,
UNIQUE KEY `id_user` (`id_user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;