Merge branch 'ent-4461-Configuracion-integracion-integria' into 'develop'

Ent 4461 configuracion integracion integria

See merge request artica/pandorafms!2732
This commit is contained in:
Daniel Rodriguez 2019-09-26 14:34:50 +02:00
commit c9cfbf0bf2
23 changed files with 3180 additions and 73 deletions

View File

@ -15,9 +15,30 @@ UPDATE `tlayout_data` SET `height` = 70 , `width` = 70 WHERE `height` = 0 && `wi
(`type` = 10 && `image` IS NOT NULL && `image` != '' && `image` != 'none') ||
(`type` = 11 && `image` IS NOT NULL && `image` != '' && `image` != 'none' && `show_statistics` = 0));
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_enabled', 0);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_user', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_pass', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_hostname', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_api_pass', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_req_timeout', 5);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_group', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_criticity', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_creator', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_owner', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_type', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_status', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_title', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_content', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_group', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_criticity', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_creator', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_owner', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_type', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_status', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_title', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_content', '');
ALTER TABLE `treport_content` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0';
ALTER TABLE `treport_content_template` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0';
COMMIT;

View File

@ -1256,10 +1256,30 @@ DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '737');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
UPDATE `tconfig` SET `value` = 'mini_severity,evento,id_agente,estado,timestamp' WHERE `token` LIKE 'event_fields';
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_enabled';
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_api_password';
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_inventory';
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_url';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_user', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_pass', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_hostname', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_api_pass', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_req_timeout', 5);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_group', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_criticity', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_creator', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('default_owner', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_type', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_status', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_title', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('incident_content', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_group', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_criticity', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_creator', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_default_owner', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_type', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_status', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_title', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_content', '');
-- ---------------------------------------------------------------------
-- Table `tconfig_os`

View File

@ -295,6 +295,9 @@ if (check_acl($config['id_user'], 0, 'PM')) {
$sub2['godmode/setup/setup&section=ehorus']['text'] = __('eHorus');
$sub2['godmode/setup/setup&section=ehorus']['refr'] = 0;
$sub2['godmode/setup/setup&section=integria']['text'] = __('Integria IMS');
$sub2['godmode/setup/setup&section=integria']['refr'] = 0;
$sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications');
$sub2['godmode/setup/setup&section=notifications']['refr'] = 0;

View File

@ -117,6 +117,11 @@ if (check_acl($config['id_user'], 0, 'AW')) {
}
}
$buttons['integria'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=integria').'">'.html_print_image('images/integria.png', true, ['title' => __('Integria IMS')]).'</a>',
];
$buttons['ehorus'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=ehorus').'">'.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'</a>',
@ -167,6 +172,12 @@ switch ($section) {
$help_header = 'setup_ehorus_tab';
break;
case 'integria':
$buttons['integria']['active'] = true;
$subpage = ' &raquo '.__('Integria IMS');
$help_header = 'setup_integria_tab';
break;
case 'notifications':
$buttons['notifications']['active'] = true;
$subpage = ' &raquo '.__('Notifications');
@ -228,6 +239,10 @@ switch ($section) {
include_once $config['homedir'].'/godmode/setup/setup_ehorus.php';
break;
case 'integria':
include_once $config['homedir'].'/godmode/setup/setup_integria.php';
break;
case 'notifications':
include_once $config['homedir'].'/godmode/setup/setup_notifications.php';
break;

View File

@ -0,0 +1,702 @@
<?php
/**
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* 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.
* ============================================================================
*/
global $config;
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;
}
require_once $config['homedir'].'/include/functions_integriaims.php';
if (is_ajax()) {
$integria_user = get_parameter('integria_user', '');
$integria_pass = get_parameter('integria_pass', '');
$integria_api_hostname = get_parameter('api_hostname', '');
$integria_api_pass = get_parameter('api_pass', '');
$login_result = integria_api_call($integria_api_hostname, $integria_user, $integria_pass, $integria_api_pass, 'get_login', []);
if ($login_result != false) {
echo json_encode(['login' => 1]);
} else {
echo json_encode(['login' => 0]);
}
return;
}
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []);
if ($has_connection === false && $config['integria_enabled']) {
ui_print_error_message(__('Integria IMS API is not reachable'));
}
if (get_parameter('update_config', 0) == 1) {
// Try to retrieve event response 'Create incident in IntegriaIMS from event' to check if it exists.
$event_response_exists = db_get_row_filter('tevent_response', ['name' => io_safe_input('Create ticket in IntegriaIMS from event')]);
// Try to retrieve command 'Integia IMS Ticket' to check if it exists.
$command_exists = db_get_row_filter('talert_commands', ['name' => io_safe_input('Integria IMS Ticket')]);
if ($config['integria_enabled'] == 1) {
if ($event_response_exists === false) {
// Create 'Create incident in IntegriaIMS from event' event response only when user enables IntegriaIMS integration and it does not exist in database.
db_process_sql_insert(
'tevent_response',
[
'name' => io_safe_input('Create ticket in IntegriaIMS from event'),
'description' => io_safe_input('Create a ticket in Integria IMS from an event'),
'target' => io_safe_input('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&from_event=_event_id_'),
'type' => 'url',
'id_group' => '0',
'modal_width' => '0',
'modal_height' => '0',
'new_window' => '1',
'params' => '',
'server_to_exec' => '0',
]
);
}
if ($command_exists === false) {
// Create 'Integria IMS Ticket' command only when user enables IntegriaIMS integration and it does not exist in database.
$id_command_inserted = db_process_sql_insert(
'talert_commands',
[
'name' => io_safe_input('Integria IMS Ticket'),
'command' => io_safe_input('Internal type'),
'internal' => 1,
'description' => io_safe_input('Create a ticket in Integria IMS'),
'fields_descriptions' => '["'.io_safe_input('Ticket title').'","'.io_safe_input('Ticket group ID').'","'.io_safe_input('Ticket priority').'","'.io_safe_input('Ticket owner').'","'.io_safe_input('Ticket type').'","'.io_safe_input('Ticket status').'","'.io_safe_input('Ticket description').'"]',
]
);
// Create 'Create Integria IMS Ticket' action only when user enables IntegriaIMS integration and command exists in database.
$action_values = [
'field1' => io_safe_input($config['incident_title']),
'field1_recovery' => io_safe_input($config['incident_title']),
'field2' => io_safe_input($config['default_group']),
'field2_recovery' => io_safe_input($config['default_group']),
'field3' => io_safe_input($config['default_criticity']),
'field3_recovery' => io_safe_input($config['default_criticity']),
'field4' => io_safe_input($config['default_owner']),
'field4_recovery' => io_safe_input($config['default_owner']),
'field5' => io_safe_input($config['incident_type']),
'field5_recovery' => io_safe_input($config['incident_type']),
'field6' => io_safe_input($config['incident_status']),
'field6_recovery' => io_safe_input($config['incident_status']),
'field7' => io_safe_input($config['incident_content']),
'field7_recovery' => io_safe_input($config['incident_content']),
'id_group' => 0,
'action_threshold' => 0,
];
alerts_create_alert_action(io_safe_input('Create Integria IMS ticket'), $id_command_inserted, $action_values);
} else {
// Update 'Create Integria IMS Ticket' action when setup data is updated, user enables IntegriaIMS integration and command does exist in database.
db_process_sql_update(
'talert_actions',
[
'field1' => io_safe_input($config['incident_title']),
'field1_recovery' => io_safe_input($config['incident_title']),
'field2' => io_safe_input($config['default_group']),
'field2_recovery' => io_safe_input($config['default_group']),
'field3' => io_safe_input($config['default_criticity']),
'field3_recovery' => io_safe_input($config['default_criticity']),
'field4' => io_safe_input($config['default_owner']),
'field4_recovery' => io_safe_input($config['default_owner']),
'field5' => io_safe_input($config['incident_type']),
'field5_recovery' => io_safe_input($config['incident_type']),
'field6' => io_safe_input($config['incident_status']),
'field6_recovery' => io_safe_input($config['incident_status']),
'field7' => io_safe_input($config['incident_content']),
'field7_recovery' => io_safe_input($config['incident_content']),
],
['name' => io_safe_input('Create Integria IMS ticket')]
);
}
} else {
if ($event_response_exists != false) {
// Delete 'Create incident in IntegriaIMS from event' event response if it does exist and IntegriaIMS integration is disabled.
db_process_sql_delete('tevent_response', ['name' => io_safe_input('Create ticket in IntegriaIMS from event')]);
}
if ($command_exists != false) {
// Delete 'Integria IMS Ticket' command if it does exist and IntegriaIMS integration is disabled.
db_process_sql_delete('talert_commands', ['name' => io_safe_input('Integria IMS Ticket')]);
// Delete 'Create Integria IMS Ticket' action if command exists and IntegriaIMS integration is disabled.
db_process_sql_delete('talert_actions', ['name' => io_safe_input('Create Integria IMS ticket')]);
}
}
}
// Get parameters from Integria IMS API.
$integria_group_values = [];
$integria_criticity_values = [];
$integria_users_values = [];
$integria_types_values = [];
$integria_status_values = [];
$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', []);
get_array_from_csv_data_pair($integria_groups_csv, $integria_group_values);
$integria_status_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status', []);
get_array_from_csv_data_pair($integria_status_csv, $integria_status_values);
$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', []);
get_array_from_csv_data_pair($integria_criticity_levels_csv, $integria_criticity_values);
$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users', []);
$csv_array = explode("\n", $integria_users_csv);
foreach ($csv_array as $csv_line) {
if (!empty($csv_line)) {
$integria_users_values[$csv_line] = $csv_line;
}
}
$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', []);
get_array_from_csv_data_pair($integria_types_csv, $integria_types_values);
// Enable table.
$table_enable = new StdClass();
$table_enable->data = [];
$table_enable->width = '100%';
$table_enable->id = 'integria-enable-setup';
$table_enable->class = 'databox filters';
$table_enable->size['name'] = '30%';
$table_enable->style['name'] = 'font-weight: bold';
// Enable Integria.
$row = [];
$row['name'] = __('Enable Integria IMS');
$row['control'] = html_print_checkbox_switch('integria_enabled', 1, $config['integria_enabled'], true);
$table_enable->data['integria_enabled'] = $row;
// Remote config table.
$table_remote = new StdClass();
$table_remote->data = [];
$table_remote->width = '100%';
$table_remote->styleTable = 'margin-bottom: 10px;';
$table_remote->id = 'integria-remote-setup';
$table_remote->class = 'databox filters';
$table_remote->size['name'] = '30%';
$table_remote->style['name'] = 'font-weight: bold';
// Integria user.
$row = [];
$row['name'] = __('User');
$row['control'] = html_print_input_text('integria_user', $config['integria_user'], '', 30, 100, true);
$table_remote->data['integria_user'] = $row;
// Integria password.
$row = [];
$row['name'] = __('Password');
$row['control'] = html_print_input_password('integria_pass', io_output_password($config['integria_pass']), '', 30, 100, true);
$table_remote->data['integria_pass'] = $row;
// Integria hostname.
$row = [];
$row['name'] = __('API Hostname');
$row['control'] = html_print_input_text('integria_hostname', $config['integria_hostname'], '', 30, 100, true);
$row['control'] .= ui_print_help_tip(__('Hostname of Integria IMS\' API (scheme must be specified. Example: http://192.168.0.0)'), true);
$table_remote->data['integria_hostname'] = $row;
// API password.
$row = [];
$row['name'] = __('API Password');
$row['control'] = html_print_input_password('integria_api_pass', io_output_password($config['integria_api_pass']), '', 30, 100, true);
$row['control'] .= ui_print_help_tip(__('Password of Integria IMS\' API'), true);
$table_remote->data['integria_api_pass'] = $row;
// Request timeout.
$row = [];
$row['name'] = __('Request timeout');
$row['control'] = html_print_input_text('integria_req_timeout', $config['integria_req_timeout'], '', 3, 10, true);
$row['control'] .= ui_print_help_tip(__('Time in seconds to set the maximum time of the requests to the Integria API').'. '.__('0 to disable'), true);
$table_remote->data['integria_req_timeout'] = $row;
// Alert settings.
$table_alert_settings = new StdClass();
$table_alert_settings->data = [];
$table_alert_settings->width = '100%';
$table_alert_settings->styleTable = 'margin-bottom: 10px;';
$table_alert_settings->id = 'integria-cr-settings-setup';
$table_alert_settings->class = 'databox filters';
$table_alert_settings->size['name'] = '30%';
$table_alert_settings->style['name'] = 'font-weight: bold';
// Alert incident title.
$row = [];
$row['name'] = __('Title');
$row['control'] = html_print_input_text(
'incident_title',
$config['incident_title'],
__('Name'),
50,
100,
true,
false,
false
).ui_print_help_icon('alert_macros', true);
$table_alert_settings->data['custom_response_incident_title'] = $row;
// Alert incident description.
$row = [];
$row['name'] = __('Description');
$row['control'] = html_print_input_text(
'incident_content',
$config['incident_content'],
'',
50,
100,
true,
false,
false
).ui_print_help_icon('alert_macros', true);
$table_alert_settings->data['custom_response_incident_content'] = $row;
// Alert default group.
$row = [];
$row['name'] = __('Group');
$row['control'] = html_print_select(
$integria_group_values,
'default_group',
$config['default_group'],
'',
__('Select'),
0,
true,
false,
true,
'',
false
);
$table_alert_settings->data['custom_response_def_group'] = $row;
// Alert default criticity.
$row = [];
$row['name'] = __('Priority');
$row['control'] = html_print_select(
$integria_criticity_values,
'default_criticity',
$config['default_criticity'],
'',
__('Select'),
0,
true,
false,
true,
'',
false
);
$table_alert_settings->data['custom_response_def_criticity'] = $row;
// Alert default owner.
$row = [];
$row['name'] = __('Owner');
$row['control'] = html_print_autocomplete_users_from_integria(
'default_owner',
$config['default_owner'],
true
);
$table_alert_settings->data['custom_response_def_owner'] = $row;
// Alert default incident type.
$row = [];
$row['name'] = __('Type');
$row['control'] = html_print_select(
$integria_types_values,
'incident_type',
$config['incident_type'],
'',
__('Select'),
0,
true,
false,
true,
'',
false
);
$table_alert_settings->data['custom_response_incident_type'] = $row;
// Alert default incident status.
$row = [];
$row['name'] = __('Status');
$row['control'] = html_print_select(
$integria_status_values,
'incident_status',
$config['incident_status'],
'',
__('Select'),
0,
true,
false,
true,
'',
false
);
$table_alert_settings->data['custom_response_incident_status'] = $row;
// Custom response settings.
$table_cr_settings = new StdClass();
$table_cr_settings->data = [];
$table_cr_settings->width = '100%';
$table_cr_settings->styleTable = 'margin-bottom: 10px;';
$table_cr_settings->id = 'integria-cr-settings-setup';
$table_cr_settings->class = 'databox filters';
$table_cr_settings->size['name'] = '30%';
$table_cr_settings->style['name'] = 'font-weight: bold';
// Custom response incident title.
$row = [];
$row['name'] = __('Title');
$row['control'] = html_print_input_text(
'cr_incident_title',
$config['cr_incident_title'],
__('Name'),
50,
100,
true,
false,
false
).ui_print_help_icon('response_macros', true);
$table_cr_settings->data['custom_response_incident_title'] = $row;
// Custom response incident description.
$row = [];
$row['name'] = __('Description');
$row['control'] = html_print_input_text(
'cr_incident_content',
$config['cr_incident_content'],
'',
50,
100,
true,
false,
false
).ui_print_help_icon('response_macros', true);
$table_cr_settings->data['custom_response_incident_content'] = $row;
// Custom response default group.
$row = [];
$row['name'] = __('Group');
$row['control'] = html_print_select(
$integria_group_values,
'cr_default_group',
$config['cr_default_group'],
'',
__('Select'),
0,
true,
false,
true,
'',
false
);
$table_cr_settings->data['custom_response_def_group'] = $row;
// Custom response default criticity.
$row = [];
$row['name'] = __('Priority');
$row['control'] = html_print_select(
$integria_criticity_values,
'cr_default_criticity',
$config['cr_default_criticity'],
'',
__('Select'),
0,
true,
false,
true,
'',
false
);
$table_cr_settings->data['custom_response_def_criticity'] = $row;
// Custom response default owner.
$row = [];
$row['name'] = __('Owner');
$row['control'] = html_print_autocomplete_users_from_integria(
'cr_default_owner',
$config['cr_default_owner'],
true
);
$table_cr_settings->data['custom_response_def_owner'] = $row;
// Custom response default incident type.
$row = [];
$row['name'] = __('Type');
$row['control'] = html_print_select(
$integria_types_values,
'cr_incident_type',
$config['cr_incident_type'],
'',
__('Select'),
0,
true,
false,
true,
'',
false
);
$table_cr_settings->data['custom_response_incident_type'] = $row;
// Custom response default incident status.
$row = [];
$row['name'] = __('Status');
$row['control'] = html_print_select(
$integria_status_values,
'cr_incident_status',
$config['cr_incident_status'],
'',
__('Select'),
0,
true,
false,
true,
'',
false
);
$table_cr_settings->data['custom_response_incident_status'] = $row;
// Test.
$row = [];
$row['name'] = __('Test');
$row['control'] = html_print_button(__('Start'), 'test-integria', false, '', 'class="sub next"', true);
$row['control'] .= '<span id="test-integria-spinner" style="display:none;">&nbsp;'.html_print_image('images/spinner.gif', true).'</span>';
$row['control'] .= '<span id="test-integria-success" style="display:none;">&nbsp;'.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
$row['control'] .= '<span id="test-integria-failure" style="display:none;">&nbsp;'.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
$row['control'] .= '&nbsp;<span id="test-integria-message" style="display:none;"></span>';
$table_remote->data['integria_test'] = $row;
// Print.
echo '<div style="text-align: center; padding-bottom: 20px;">';
echo '<a target="_blank" rel="noopener noreferrer" href="http://ehorus.com">';
html_print_image('images/integria_logo.png');
echo '</a>';
echo '<br />';
echo '<div style="font-family: lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: #515151;">';
echo __('Integria IMS');
echo '</div>';
echo '<a target="_blank" rel="noopener noreferrer" href="https://integriaims.com">';
echo 'https://integriaims.com';
echo '</a>';
echo '</div>';
echo "<form method='post'>";
html_print_input_hidden('update_config', 1);
// Form enable.
echo '<div id="form_enable">';
html_print_table($table_enable);
echo '</div>';
// Form remote.
echo '<div id="form_remote">';
echo '<fieldset>';
echo '<legend>'.__('Integria API settings').'</legend>';
html_print_table($table_remote);
echo '</fieldset>';
echo '</div>';
if ($has_connection != false) {
// Form alert default settings.
echo '<div id="form_alert_settings">';
echo '<fieldset>';
echo '<legend>'.__('Alert default values').'</legend>';
html_print_table($table_alert_settings);
echo '</fieldset>';
echo '</div>';
// Form custom response default settings.
echo '<div id="form_custom_response_settings">';
echo '<fieldset>';
echo '<legend>'.__('Event custom response default values').'</legend>';
html_print_table($table_cr_settings);
echo '</fieldset>';
echo '</div>';
echo '<div class="action-buttons" style="width: '.$table_remote->width.'">';
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');
echo '</div>';
} else {
echo '<div class="action-buttons" style="width: '.$table_remote->width.'">';
html_print_submit_button(__('Update and continue'), 'update_button', false, 'class="sub next"');
echo '</div>';
}
echo '</form>';
?>
<script type="text/javascript">
if(!$('input:checkbox[name="integria_enabled"]').is(':checked')) {
$('#form_remote').hide();
$('#form_custom_response_settings').hide();
} else {
$('#form_remote').show();
$('#form_custom_response_settings').show();
}
$('#form_enable').css('margin-bottom','20px');
var showFields = function () {
$('#form_remote').show();
$('#form_custom_response_settings').show();
}
var hideFields = function () {
$('#form_remote').hide();
$('#form_custom_response_settings').hide();
}
var hideUserPass = function () {
$('#integria-remote-setup-integria_user').hide();
$('#integria-remote-setup-integria_pass').hide();
}
var showUserPass = function () {
$('#integria-remote-setup-integria_user').show();
$('#integria-remote-setup-integria_pass').show();
}
var handleEnable = function (event) {
var is_checked = $('input:checkbox[name="integria_enabled"]').is(':checked');
if (event.target.value == '1' && is_checked) {
showFields();
$('input:checkbox[name="integria_enabled"]').attr('checked', true);
}
else {
hideFields();
$('input:checkbox[name="integria_enabled"]').attr('checked', false);
};
}
$('input:checkbox[name="integria_enabled"]').change(handleEnable);
var handleTest = function (event) {
var user = $('input#text-integria_user').val();
var pass = $('input#password-integria_pass').val();
var host = $('input#text-integria_hostname').val();
var timeout = Number.parseInt($('input#text-integria_req_timeout').val(), 10);
var timeoutMessage = '<?php echo __('Connection timeout'); ?>';
var badRequestMessage = '<?php echo __('Empty user or password'); ?>';
var notFoundMessage = '<?php echo __('User not found'); ?>';
var invalidPassMessage = '<?php echo __('Invalid password'); ?>';
var hideLoadingImage = function () {
$('span#test-integria-spinner').hide();
}
var showLoadingImage = function () {
$('span#test-integria-spinner').show();
}
var hideSuccessImage = function () {
$('span#test-integria-success').hide();
}
var showSuccessImage = function () {
$('span#test-integria-success').show();
}
var hideFailureImage = function () {
$('span#test-integria-failure').hide();
}
var showFailureImage = function () {
$('span#test-integria-failure').show();
}
var hideMessage = function () {
$('span#test-integria-message').hide();
}
var showMessage = function () {
$('span#test-integria-message').show();
}
var changeTestMessage = function (message) {
$('span#test-integria-message').text(message);
}
hideSuccessImage();
hideFailureImage();
hideMessage();
showLoadingImage();
var integria_user = $('input[name=integria_user]').val();
var integria_pass = $('input[name=integria_pass]').val();
var api_hostname = $('input[name=integria_hostname]').val();
var api_pass = $('input[name=integria_api_pass]').val();
var data = {
page: "godmode/setup/setup_integria",
check_api_access: 1,
integria_user: integria_user,
integria_pass: integria_pass,
api_hostname: api_hostname,
api_pass: api_pass,
}
// AJAX call to check API connection.
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "json",
timeout: timeout ? timeout * 1000 : 0,
data: data
})
.done(function(data, textStatus, xhr) {
if (data.login == '1') {
showSuccessImage();
} else {
showFailureImage();
showMessage();
}
})
.fail(function(xhr, textStatus, errorThrown) {
showFailureImage();
showMessage();
})
.always(function(xhr, textStatus) {
hideLoadingImage();
});
}
$('input#button-test-integria').click(handleTest);
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,60 @@
<?php
/**
* Integria incidents management.
*
* @category Ajax library.
* @package Pandora FMS
* @subpackage Modules.
* @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.
* ============================================================================
*/
if (check_login()) {
global $config;
include_once $config['homedir'].'/include/functions_integriaims.php';
$get_users = get_parameter('get_users');
$search_term = get_parameter('search_term', '');
if ($get_users) {
$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users', []);
$csv_array = explode("\n", $integria_users_csv);
foreach ($csv_array as $csv_line) {
if (!empty($csv_line)) {
$integria_users_values[$csv_line] = $csv_line;
}
}
$integria_users_filtered_values = array_filter(
$integria_users_values,
function ($item) use ($search_term) {
if (strpos($item, $search_term) !== false) {
return true;
}
}
);
echo json_encode($integria_users_filtered_values);
return;
}
}

View File

@ -4095,7 +4095,7 @@ function mask2cidr($mask)
function get_help_info($section_name)
{
global $config;
// hd($section_name);
$user_language = get_user_language($id_user);
$es = false;
@ -5421,7 +5421,6 @@ function get_help_info($section_name)
break;
}
// hd($result);
return $result;
}

View File

@ -1434,6 +1434,92 @@ function config_update_config()
}
break;
case 'integria':
if (!config_update_value('integria_enabled', (int) get_parameter('integria_enabled', 0))) {
$error_update[] = __('Enable Integria IMS');
}
if (!config_update_value('integria_user', (string) get_parameter('integria_user', $config['integria_user']))) {
$error_update[] = __('Integria user');
}
if (!config_update_value('integria_pass', io_input_password((string) get_parameter('integria_pass', $config['integria_pass'])))) {
$error_update[] = __('Integria password');
}
if (!config_update_value('integria_hostname', (string) get_parameter('integria_hostname', $config['integria_hostname']))) {
$error_update[] = __('integria API hostname');
}
if (!config_update_value('integria_api_pass', io_input_password((string) get_parameter('integria_api_pass', $config['integria_api_pass'])))) {
$error_update[] = __('Integria API password');
}
if (!config_update_value('integria_req_timeout', (int) get_parameter('integria_req_timeout', $config['integria_req_timeout']))) {
$error_update[] = __('Integria request timeout');
}
if (!config_update_value('default_group', (int) get_parameter('default_group', $config['default_group']))) {
$error_update[] = __('Integria default group');
}
if (!config_update_value('cr_default_group', (int) get_parameter('cr_default_group', $config['cr_default_group']))) {
$error_update[] = __('Integria custom response default group');
}
if (!config_update_value('default_criticity', (int) get_parameter('default_criticity', $config['default_criticity']))) {
$error_update[] = __('Integria default priority');
}
if (!config_update_value('cr_default_criticity', (int) get_parameter('cr_default_criticity', $config['cr_default_criticity']))) {
$error_update[] = __('Integria custom response default priority');
}
if (!config_update_value('default_creator', (string) get_parameter('default_creator', $config['default_creator']))) {
$error_update[] = __('Integria default creator');
}
if (!config_update_value('default_owner', (string) get_parameter('default_owner', $config['default_owner']))) {
$error_update[] = __('Integria default owner');
}
if (!config_update_value('cr_default_owner', (string) get_parameter('cr_default_owner', $config['cr_default_owner']))) {
$error_update[] = __('Integria custom response default owner');
}
if (!config_update_value('incident_type', (int) get_parameter('incident_type', $config['incident_type']))) {
$error_update[] = __('Integria default ticket type');
}
if (!config_update_value('cr_incident_type', (int) get_parameter('cr_incident_type', $config['cr_incident_type']))) {
$error_update[] = __('Integria custom response default ticket type');
}
if (!config_update_value('incident_status', (int) get_parameter('incident_status', $config['incident_status']))) {
$error_update[] = __('Integria default ticket status');
}
if (!config_update_value('cr_incident_status', (int) get_parameter('cr_incident_status', $config['cr_incident_status']))) {
$error_update[] = __('Integria custom response default ticket status');
}
if (!config_update_value('incident_title', (string) get_parameter('incident_title', $config['incident_title']))) {
$error_update[] = __('Integria default ticket title');
}
if (!config_update_value('cr_incident_title', (string) get_parameter('cr_incident_title', $config['cr_incident_title']))) {
$error_update[] = __('Integria custom response default ticket title');
}
if (!config_update_value('incident_content', (string) get_parameter('incident_content', $config['incident_content']))) {
$error_update[] = __('Integria default ticket content');
}
if (!config_update_value('cr_incident_content', (string) get_parameter('cr_incident_content', $config['cr_incident_content']))) {
$error_update[] = __('Integria custom response default ticket content');
}
break;
default:
// Ignore.
break;
@ -2847,6 +2933,19 @@ function config_process_config()
}
}
// Integria.
if (!isset($config['integria_enabled'])) {
config_update_value('integria_enabled', 0);
}
if (!isset($config['integria_req_timeout'])) {
config_update_value('integria_req_timeout', 5);
}
if (!isset($config['integria_hostname'])) {
config_update_value('integria_hostname', '');
}
// Finally, check if any value was overwritten in a form.
config_update_config();
}

View File

@ -6638,3 +6638,244 @@ function events_get_secondary_groups_left_join($table)
return 'LEFT JOIN tmetaconsole_agent_secondary_group tasg
ON te.id_agente = tasg.id_tagente AND te.server_id = tasg.id_tmetaconsole_setup';
}
/**
* Replace macros in any string given an event id.
* If server_id > 0, it's a metaconsole query.
*
* @param integer $event_id Event identifier.
* @param integer $value String value in which we want to apply macros.
*
* @return string The response text with the macros applied.
*/
function events_get_field_value_by_event_id(
int $event_id,
$value
) {
global $config;
$meta = false;
$event = db_get_row('tevento', 'id_evento', $event_id);
// Replace each macro.
if (strpos($value, '_agent_address_') !== false) {
if ($meta) {
$agente_table_name = 'tmetaconsole_agent';
$filter = [
'id_tagente' => $event['id_agente'],
'id_tmetaconsole_setup' => $server_id,
];
} else {
$agente_table_name = 'tagente';
$filter = ['id_agente' => $event['id_agente']];
}
$ip = db_get_value_filter('direccion', $agente_table_name, $filter);
// If agent does not have an IP, display N/A.
if ($ip === false) {
$ip = __('N/A');
}
$value = str_replace('_agent_address_', $ip, $value);
}
if (strpos($value, '_agent_id_') !== false) {
$value = str_replace('_agent_id_', $event['id_agente'], $value);
}
if (strpos($value, '_module_address_') !== false) {
if ($event['id_agentmodule'] != 0) {
if ($meta) {
$server = metaconsole_get_connection_by_id($server_id);
metaconsole_connect($server);
}
$module = db_get_row('tagente_modulo', 'id_agente_modulo', $event['id_agentmodule']);
if (empty($module['ip_target'])) {
$module['ip_target'] = __('N/A');
}
$value = str_replace('_module_address_', $module['ip_target'], $value);
if (empty($module['nombre'])) {
$module['nombre'] = __('N/A');
}
if ($meta) {
metaconsole_restore_db();
}
} else {
$value = str_replace('_module_address_', __('N/A'), $value);
}
}
if (strpos($value, '_module_name_') !== false) {
if ($event['id_agentmodule'] != 0) {
if ($meta) {
$server = metaconsole_get_connection_by_id($server_id);
metaconsole_connect($server);
}
$module = db_get_row('tagente_modulo', 'id_agente_modulo', $event['id_agentmodule']);
if (empty($module['ip_target'])) {
$module['ip_target'] = __('N/A');
}
$value = str_replace(
'_module_name_',
io_safe_output($module['nombre']),
$value
);
if ($meta) {
metaconsole_restore_db();
}
} else {
$value = str_replace('_module_name_', __('N/A'), $value);
}
}
if (strpos($value, '_event_id_') !== false) {
$value = str_replace('_event_id_', $event['id_evento'], $value);
}
if (strpos($value, '_user_id_') !== false) {
if (!empty($event['id_usuario'])) {
$value = str_replace('_user_id_', $event['id_usuario'], $value);
} else {
$value = str_replace('_user_id_', __('N/A'), $value);
}
}
if (strpos($value, '_group_id_') !== false) {
$value = str_replace('_group_id_', $event['id_grupo'], $value);
}
if (strpos($value, '_group_name_') !== false) {
$value = str_replace(
'_group_name_',
groups_get_name($event['id_grupo'], true),
$value
);
}
if (strpos($value, '_event_utimestamp_') !== false) {
$value = str_replace(
'_event_utimestamp_',
$event['utimestamp'],
$value
);
}
if (strpos($value, '_event_date_') !== false) {
$value = str_replace(
'_event_date_',
date($config['date_format'], $event['utimestamp']),
$value
);
}
if (strpos($value, '_event_text_') !== false) {
$value = str_replace(
'_event_text_',
events_display_name($event['evento']),
$value
);
}
if (strpos($value, '_event_type_') !== false) {
$value = str_replace(
'_event_type_',
events_print_type_description($event['event_type'], true),
$value
);
}
if (strpos($value, '_alert_id_') !== false) {
$value = str_replace(
'_alert_id_',
empty($event['is_alert_am']) ? __('N/A') : $event['is_alert_am'],
$value
);
}
if (strpos($value, '_event_severity_id_') !== false) {
$value = str_replace('_event_severity_id_', $event['criticity'], $value);
}
if (strpos($value, '_event_severity_text_') !== false) {
$value = str_replace(
'_event_severity_text_',
get_priority_name($event['criticity']),
$value
);
}
if (strpos($value, '_module_id_') !== false) {
$value = str_replace('_module_id_', $event['id_agentmodule'], $value);
}
if (strpos($value, '_event_tags_') !== false) {
$value = str_replace('_event_tags_', $event['tags'], $value);
}
if (strpos($value, '_event_extra_id_') !== false) {
if (empty($event['id_extra'])) {
$value = str_replace('_event_extra_id_', __('N/A'), $value);
} else {
$value = str_replace('_event_extra_id_', $event['id_extra'], $value);
}
}
if (strpos($value, '_event_source_') !== false) {
$value = str_replace('_event_source_', $event['source'], $value);
}
if (strpos($value, '_event_instruction_') !== false) {
$value = str_replace(
'_event_instruction_',
events_display_instructions($event['event_type'], $event, false),
$value
);
}
if (strpos($value, '_owner_user_') !== false) {
if (empty($event['owner_user'])) {
$value = str_replace('_owner_user_', __('N/A'), $value);
} else {
$value = str_replace('_owner_user_', $event['owner_user'], $value);
}
}
if (strpos($value, '_event_status_') !== false) {
$event_st = events_display_status($event['estado']);
$value = str_replace('_event_status_', $event_st['title'], $value);
}
if (strpos($value, '_group_custom_id_') !== false) {
$group_custom_id = db_get_value_sql(
sprintf(
'SELECT custom_id FROM tgrupo WHERE id_grupo=%s',
$event['id_grupo']
)
);
$event_st = events_display_status($event['estado']);
$value = str_replace('_group_custom_id_', $group_custom_id, $value);
}
// Parse the event custom data.
if (!empty($event['custom_data'])) {
$custom_data = json_decode(base64_decode($event['custom_data']));
foreach ($custom_data as $key => $val) {
$value = str_replace('_customdata_'.$key.'_', $val, $value);
}
}
// This will replace the macro with the current logged user.
if (strpos($value, '_current_user_') !== false) {
$value = str_replace('_current_user_', $config['id_user'], $value);
}
return $value;
}

View File

@ -3383,3 +3383,116 @@ function html_print_input($data, $wrapper='div', $input_only=false)
return $output;
}
/**
* Print an autocomplete input filled out with Integria IMS users.
*
* @param string $name The name of ajax control, by default is "users".
* @param string $default The default value to show in the ajax control.
* @param boolean $return If it is true return a string with the output instead to echo the output.
* @param string $size Size.
*
* @return mixed If the $return is true, return the output as string.
*/
function html_print_autocomplete_users_from_integria(
$name='users',
$default='',
$return=false,
$size='30',
$disable=false,
$required=false
) {
global $config;
ob_start();
$attrs = ['style' => 'background: url(images/user_green.png) no-repeat right;'];
if ($required) {
$attrs['required'] = 'required';
}
html_print_input_text_extended(
$name,
$default,
'text-'.$name,
'',
$size,
100,
$disable,
'',
$attrs
);
html_print_input_hidden($name.'_hidden', $id_agent_module);
ui_print_help_tip(__('Type at least two characters to search the user.'), false);
$javascript_ajax_page = ui_get_full_url('ajax.php', false, false, false, false);
?>
<script type="text/javascript">
function escapeHTML (str)
{
var div = document.createElement('div');
var text = document.createTextNode(str);
div.appendChild(text);
return div.innerHTML;
}
$(document).ready (function () {
$("#text-<?php echo $name; ?>").autocomplete({
minLength: 2,
source: function( request, response ) {
var term = request.term; //Word to search
data_params = {
page: "include/ajax/integria_incidents.ajax",
search_term: term,
get_users: 1,
};
jQuery.ajax ({
data: data_params,
async: false,
type: "POST",
url: action="<?php echo $javascript_ajax_page; ?>",
timeout: 10000,
dataType: "json",
success: function (data) {
temp = [];
$.each(data, function (id, module) {
temp.push({
'value' : id,
'label' : module});
});
response(temp);
}
});
},
change: function( event, ui ) {
if (!ui.item)
$("input[name='<?php echo $name; ?>_hidden']")
.val(0);
return false;
},
select: function( event, ui ) {
$("input[name='<?php echo $name; ?>_hidden']")
.val(ui.item.value);
$("#text-<?php echo $name; ?>").val( ui.item.label );
return false;
}
}
);
});
</script>
<?php
$output = ob_get_clean();
if ($return) {
return $output;
} else {
echo $output;
}
}

View File

@ -0,0 +1,420 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 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 Lesser 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 Include
* @subpackage Incidents
*/
global $config;
require_once $config['homedir'].'/include/functions_ui.php';
require_once $config['homedir'].'/include/functions_html.php';
require_once $config['homedir'].'/include/functions.php';
/**
* Show header tabs.
*
* @param string $active_tab Current tab or false for View page.
* @param number $view Id of incident. Show View tab.
*
* @return html Print tabs in header.
*/
function integriaims_tabs($active_tab, $view=false)
{
global $config;
$url_tabs = ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/');
$setup_tab['text'] = '<a href="'.ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=integria').'">'.html_print_image('images/setup.png', true, ['title' => __('Configure Integria IMS')]).'</a>';
$list_tab['text'] = '<a href="'.$url_tabs.'list_integriaims_incidents">'.html_print_image('images/list.png', true, ['title' => __('Ticket list')]).'</a>';
$create_tab['text'] = '<a href="'.$url_tabs.'configure_integriaims_incident">'.html_print_image('images/pencil.png', true, ['title' => __('New ticket')]).'</a>';
switch ($active_tab) {
case 'setup_tab':
$setup_tab['active'] = true;
$list_tab['active'] = false;
$create_tab['active'] = false;
break;
case 'list_tab':
$setup_tab['active'] = false;
$list_tab['active'] = true;
$create_tab['active'] = false;
break;
case 'create_tab':
$setup_tab['active'] = false;
$list_tab['active'] = false;
$create_tab['active'] = true;
break;
default:
$setup_tab['active'] = false;
$list_tab['active'] = false;
$create_tab['active'] = false;
break;
}
if ($view) {
$create_tab['text'] = '<a href="'.$url_tabs.'configure_integriaims_incident&incident_id='.$view.'">'.html_print_image('images/pencil.png', true, ['title' => __('Edit ticket')]).'</a>';
$view_tab['text'] = '<a href="'.$url_tabs.'dashboard_detail_integriaims_incident&incident_id='.$view.'">'.html_print_image('images/operation.png', true, ['title' => __('View ticket')]).'</a>';
// When the current page is the View page.
if (!$active_tab) {
$view_tab['active'] = true;
}
}
$onheader = [];
if (check_acl($config['id_user'], 0, 'IR') && $view) {
$onheader['view'] = $view_tab;
}
if (check_acl($config['id_user'], 0, 'PM')) {
$onheader['configure'] = $setup_tab;
}
if (check_acl($config['id_user'], 0, 'IR')) {
$onheader['list'] = $list_tab;
}
if (check_acl($config['id_user'], 0, 'IW')) {
$onheader['create'] = $create_tab;
}
return $onheader;
}
/**
* Gets all the details of Integria IMS API
*
* @param string $details Type of API call.
* @param number $detail_index Send index if you want return the text.
*
* @return string or array with result of API call.
*/
function integriaims_get_details($details, $detail_index=false)
{
global $config;
switch ($details) {
case 'status':
$operation = 'get_incidents_status';
break;
case 'group':
$operation = 'get_groups';
break;
case 'priority':
$operation = 'get_incident_priorities';
break;
case 'resolution':
$operation = 'get_incidents_resolutions';
break;
case 'type':
$operation = 'get_types';
break;
default:
// code...
break;
}
$api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], $operation);
$result = [];
get_array_from_csv_data_pair($api_call, $result);
if ($detail_index !== false) {
if ($result[$detail_index] == '' || $result[$detail_index] === null) {
return __('None');
} else {
return $result[$detail_index];
}
} else {
return $result;
}
}
/**
* Perform an API call to Integria IMS.
*
* @param string API host URL.
* @param string User name.
* @param string User password.
* @param string API password.
* @param string API Operation.
* @param array Array with parameters required by the API function.
*
* @return boolean True if API request succeeded, false if API request failed.
*/
function integria_api_call($api_hostname, $user, $user_pass, $api_pass, $operation, $params_array=[], $show_credentials_error_msg=false)
{
$params_string = implode(',', $params_array);
$url_data = [
'user' => $user,
'user_pass' => $user_pass,
'pass' => $api_pass,
'op' => $operation,
'params' => html_entity_decode($params_string),
];
// Build URL for API request.
$url = $api_hostname.'/integria/include/api.php';
// ob_start();
// $out = fopen('php://output', 'w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $url_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, $out);
$result = curl_exec($ch);
// fclose($out);
// $debug = ob_get_clean();
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = false;
if ($result === false) {
$error = curl_error($ch);
}
curl_close($ch);
if ($error === true || $http_status !== 200) {
if ($show_credentials_error_msg === true) {
ui_print_error_message(__('API request failed. Please check Integria IMS\' access credentials in Pandora setup.'));
}
return false;
} else {
return $result;
}
}
// Parse CSV consisting of one or more lines of the form key-value pair into an array.
function get_array_from_csv_data_pair($csv_data, &$array_values)
{
$csv_array = explode("\n", $csv_data);
foreach ($csv_array as $csv_value) {
if (empty($csv_value)) {
continue;
}
$new_csv_value = str_getcsv($csv_value);
$array_values[$new_csv_value[0]] = $new_csv_value[1];
}
}
/**
* Parse CSV consisting of all lines into an array.
*
* @param string $csv_data Data returned of csv api call.
* @param string $array_values Returned array.
* @param array $index Array to create an associative index (opcional).
*/
function get_array_from_csv_data_all($csv_data, &$array_values, $index=false)
{
$csv_array = explode("\n", $csv_data);
foreach ($csv_array as $csv_value) {
if (empty($csv_value)) {
continue;
}
$new_csv_value = str_getcsv($csv_value);
if ($index !== false) {
foreach ($new_csv_value as $key => $value) {
$new_csv_value_index[$index[$key]] = str_replace(':::', ',', $value);
;
}
$array_values[$new_csv_value[0]] = $new_csv_value_index;
} else {
$new_csv_value_comma = array_map(
function ($item) {
return str_replace(':::', ',', $item);
},
$new_csv_value
);
$array_values[$new_csv_value[0]] = $new_csv_value_comma;
}
}
}
/**
* Print priority for Integria IMS with colors.
*
* @param string $priority value of priority in Integria IMS.
* @param string $priority_label text shown in color box.
*
* @return HTML code to print the color box.
*/
function ui_print_integria_incident_priority($priority, $priority_label)
{
global $config;
$output = '';
switch ($priority) {
case 0:
$color = COL_UNKNOWN;
break;
case 1:
$color = COL_NORMAL;
break;
case 10:
$color = COL_NOTINIT;
break;
case 2:
$color = COL_WARNING;
break;
case 3:
$color = COL_ALERTFIRED;
break;
case 4:
$color = COL_CRITICAL;
break;
}
$output = '<div class="priority" style="background: '.$color.'">';
$output .= $priority_label;
$output .= '</div>';
return $output;
}
/**
* Get tickets from Integria IMS.
*
* @param array $tickets_filters Filters to send to API.
*
* @return array Tickets returned by API call.
*/
function get_tickets_integriaims($tickets_filters)
{
global $config;
// Filters.
$incident_text = $tickets_filters['incident_text'];
$incident_status = $tickets_filters['incident_status'];
$incident_group = $tickets_filters['incident_group'];
$incident_owner = $tickets_filters['incident_owner'];
$incident_creator = $tickets_filters['incident_creator'];
$incident_priority = $tickets_filters['incident_priority'];
$incident_resolution = $tickets_filters['incident_resolution'];
$created_from = $tickets_filters['created_from'];
$created_to = $tickets_filters['created_to'];
// API call.
$result_api_call_list = integria_api_call(
$config['integria_hostname'],
$config['integria_user'],
$config['integria_pass'],
$config['integria_api_pass'],
'get_incidents',
[
$incident_text,
$incident_status,
$incident_group,
$incident_priority,
'0',
$incident_owner,
$incident_creator,
]
);
// Return array of api call 'get_incidents'.
$array_get_incidents = [];
get_array_from_csv_data_all($result_api_call_list, $array_get_incidents);
// Modify $array_get_incidents if filter for resolution exists.
$filter_resolution = [];
foreach ($array_get_incidents as $key => $value) {
if ($incident_resolution !== '' && ($array_get_incidents[$key][12] == $incident_resolution)) {
$filter_resolution[$key] = $array_get_incidents[$key];
continue;
}
}
if ($incident_resolution !== '') {
$array_get_incidents = $filter_resolution;
}
// Modify $array_get_incidents if filter for date is selected.
if ($created_from !== '' && $created_to !== '') {
$date = [];
$date_utimestamp = [];
foreach ($array_get_incidents as $key => $value) {
// Change format date / to -.
$date[$key] = date('Y-m-d', strtotime($array_get_incidents[$key][9]));
// Covert date to utimestamp.
$date_utimestamp[$key] = strtotime($date[$key]);
}
// Change format date / to -.
$created_from_date = date('Y-m-d', strtotime($created_from));
$created_to_date = date('Y-m-d', strtotime($created_to));
// Covert date to utimestamp.
$created_from_timestamp = strtotime($created_from_date);
$created_to_timestamp = strtotime($created_to_date);
// Dates within the selected period.
$selected_period = array_filter(
$date_utimestamp,
function ($value) use ($created_from_timestamp, $created_to_timestamp) {
return ($value >= $created_from_timestamp && $value <= $created_to_timestamp);
}
);
// Return incidents with the correct dates.
$filter_date = [];
foreach ($array_get_incidents as $key => $value) {
foreach ($selected_period as $index => $value) {
if ($array_get_incidents[$key][0] == $index) {
$filter_date[$key] = $array_get_incidents[$key];
continue;
}
}
}
$array_get_incidents = $filter_date;
}
return $array_get_incidents;
}

View File

@ -0,0 +1,125 @@
/* --- Integria IMS --- */
div.priority {
width: 80px;
color: #fff;
text-align: center;
border-radius: 5px;
padding: 5px;
display: table-cell;
vertical-align: middle;
}
/* Details view */
div.integria_details {
display: grid;
grid-column-gap: 10px;
grid-template-columns: repeat(3, minmax(min-content, auto));
grid-auto-rows: 1fr;
}
div.integria_details div.box-shadow.white_table_graph {
box-shadow: none;
}
div.integria_details div.priority {
display: inline-block;
}
div.integriaims_details_row {
display: grid;
grid-gap: 10px;
text-align: center;
margin-top: 8px;
margin-bottom: 8px;
}
div.integriaims_details_titles {
font-weight: bold;
}
div.integria_details_row_five {
grid-template-columns: repeat(5, 1fr);
}
div.integria_details_row_three {
grid-template-columns: repeat(3, 1fr);
}
div.integria_details_description {
width: 100%;
}
div.integria_details_description textarea {
width: 100%;
background-color: #fbfbfb;
resize: vertical;
}
.integriaims_details_box {
display: grid;
grid-column-gap: 10px;
grid-row-gap: 5px;
align-items: center;
width: 100%;
text-align: center;
}
.integriaims_details_box_five {
grid-template-rows: repeat(3, 1fr);
grid-template-columns: repeat(5, 1fr);
}
.integriaims_details_box_three {
grid-template-rows: repeat(3, 1fr);
grid-template-columns: repeat(3, 1fr);
}
/* ui_toggles */
.integria_details_shadow {
background-color: #fff;
border-bottom: 1px solid #e2e2e2;
border-left: 1px solid #e2e2e2;
border-top-left-radius: 5px;
border-right: 1px solid #e2e2e2;
border-top-right-radius: 5px;
}
.integria_details_shadow .white_table_graph_header {
border-left: none;
border-right: none;
}
.integria_details_content {
border-bottom: none;
border-left: none;
border-right: none;
}
/* Inputs type text shown as a black line */
.integria_incidents_options input[type="text"] {
background-color: transparent;
border: none;
border-radius: 0;
border-bottom: 1px solid #ccc;
font-family: "lato-bolder", "Open Sans", sans-serif;
font-size: 10pt;
padding: 2px 5px;
box-sizing: border-box;
background-repeat: no-repeat;
background-position: left bottom 2px;
margin-bottom: 4px;
}
.integria_incident_options input[readonly] {
color: #848484;
}
.comment_title {
padding: 5px 10px 5px 20px;
background-color: rgba(130, 185, 46, 0.16);
border-radius: 3px;
}
.comment_body {
padding: 15px 20px 15px 20px;
}

View File

@ -0,0 +1,325 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 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.
// Load global vars
global $config;
check_login();
if (!(check_acl($config['id_user'], 0, 'IW') && check_acl($config['id_user'], 0, 'IR'))) {
// Doesn't have access to this page.
db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation');
include 'general/noaccess.php';
exit;
}
require_once $config['homedir'].'/include/functions_integriaims.php';
$update = (isset($_GET['incident_id']) === true);
// Header tabs.
$onheader = integriaims_tabs('create_tab', $_GET['incident_id']);
if ($update) {
ui_print_page_header(__('Update Integria IMS Ticket'), '', false, '', false, $onheader);
} else {
ui_print_page_header(__('Create Integria IMS Ticket'), '', false, '', false, $onheader);
}
// Check if Integria integration enabled.
if ($config['integria_enabled'] == 0) {
ui_print_error_message(__('Integria integration must be enabled in Pandora setup'));
return;
}
// Check connection to Integria IMS API.
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []);
if ($has_connection === false) {
ui_print_error_message(__('Integria IMS API is not reachable'));
return;
}
// Styles.
ui_require_css_file('integriaims');
// If everything OK, get parameters from Integria IMS API in order to populate combos.
$integria_group_values = [];
$integria_criticity_values = [];
$integria_users_values = [];
$integria_types_values = [];
$integria_status_values = [];
$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', []);
get_array_from_csv_data_pair($integria_groups_csv, $integria_group_values);
$integria_status_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status', []);
get_array_from_csv_data_pair($integria_status_csv, $integria_status_values);
$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', []);
get_array_from_csv_data_pair($integria_criticity_levels_csv, $integria_criticity_values);
$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users', []);
$csv_array = explode("\n", $integria_users_csv);
foreach ($csv_array as $csv_line) {
if (!empty($csv_line)) {
$integria_users_values[$csv_line] = $csv_line;
}
}
$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', []);
get_array_from_csv_data_pair($integria_types_csv, $integria_types_values);
$event_id = (int) get_parameter('from_event');
$incident_id_edit = (int) get_parameter('incident_id');
$create_incident = (bool) get_parameter('create_incident', 0);
$update_incident = (bool) get_parameter('update_incident', 0);
$incident_group_id = (int) get_parameter('group');
$incident_criticity_id = (int) get_parameter('criticity');
$incident_owner = get_parameter('owner');
$incident_type = (int) get_parameter('type');
$incident_creator = get_parameter('creator');
$incident_status = (int) get_parameter('status');
$incident_title = events_get_field_value_by_event_id($event_id, get_parameter('incident_title'));
$incident_content = events_get_field_value_by_event_id($event_id, get_parameter('incident_content'));
// Separator conversions.
$incident_title = str_replace(',', ':::', $incident_title);
$incident_content = str_replace(',', ':::', $incident_content);
// Perform action.
if ($create_incident === true) {
// Call Integria IMS API method to create an incident.
$result_api_call = integria_api_call($config['integria_hostname'], $incident_creator, $config['integria_pass'], $config['integria_api_pass'], 'create_incident', [$incident_title, $incident_group_id, $incident_criticity_id, $incident_content, '', $incident_type, '', $incident_owner, '0', $incident_status]);
// Necessary to explicitly set true if not false because function returns api call result in case of success instead of true value.
$incident_created_ok = ($result_api_call != false) ? true : false;
ui_print_result_message(
$incident_created_ok,
__('Successfully created in Integria IMS'),
__('Could not be created in Integria IMS')
);
} else if ($update_incident === true) {
// Call Integria IMS API method to update an incident.
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'update_incident', [$incident_id_edit, $incident_title, $incident_content, '', $incident_group_id, $incident_criticity_id, 0, $incident_status, $incident_owner, 0, $incident_type]);
// Necessary to explicitly set true if not false because function returns api call result in case of success instead of true value.
$incident_updated_ok = ($result_api_call != false) ? true : false;
ui_print_result_message(
$incident_updated_ok,
__('Successfully updated in Integria IMS'),
__('Could not be updated in Integria IMS')
);
}
// If incident id is specified, retrieve incident values from api to populate combos with such values.
if ($update) {
// Call Integria IMS API method to get details of an incident given its id.
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_details', [$incident_id_edit]);
// API call does not return indexes, therefore future modifications of API function in Integria IMS may lead to inconsistencies when accessing resulting array in this file.
$incident_details_separator = explode(',', $result_api_call);
$incident_details = array_map(
function ($item) {
return str_replace(':::', ',', $item);
},
$incident_details_separator
);
}
// Main table.
$table = new stdClass();
$table->width = '100%';
$table->id = 'add_alert_table';
$table->class = 'databox filters integria_incidents_options';
$table->head = [];
$table->data = [];
$table->size = [];
$table->size = [];
$table->style[0] = 'width: 33%; padding-right: 50px; padding-left: 100px;';
$table->style[1] = 'width: 33%; padding-right: 50px; padding-left: 50px;';
$table->style[2] = 'width: 33%; padding-right: 100px; padding-left: 50px;';
$table->colspan[0][0] = 2;
$table->colspan[3][0] = 3;
$help_macros = isset($_GET['from_event']) ? ui_print_help_icon('response_macros', true) : '';
if (isset($_GET['from_event'])) {
if ($update) {
$input_value_title = $incident_details[3];
$input_value_type = $incident_details[17];
$input_value_status = $incident_details[6];
$input_value_group = $incident_details[8];
$input_value_criticity = $incident_details[7];
$input_value_owner = $incident_details[5];
$input_value_content = $incident_details[4];
} else if (isset($_GET['from_event'])) {
$input_value_title = $config['cr_incident_title'];
$input_value_type = $config['cr_incident_type'];
$input_value_status = $config['cr_incident_status'];
$input_value_group = $config['cr_default_group'];
$input_value_criticity = $config['cr_default_criticity'];
$input_value_owner = $config['cr_default_owner'];
$input_value_content = $config['cr_incident_content'];
} else {
$input_value_title = '';
$input_value_type = '';
$input_value_status = '';
$input_value_group = '';
$input_value_criticity = '';
$input_value_owner = '';
$input_value_content = '';
}
}
$table->data[0][0] = '<div class="label_select"><p class="input_label">'.__('Title').':&nbsp'.$help_macros.'</p>';
$table->data[0][0] .= '<div class="label_select_parent">'.html_print_input_text(
'incident_title',
$input_value_title,
__('Name'),
50,
100,
true,
false,
true,
'',
'w100p'
).'</div>';
$table->data[0][2] = html_print_image('images/integria_logo_gray.png', true, ['style' => 'width: 70%; float: right;'], false);
$table->data[1][0] = '<div class="label_select"><p class="input_label">'.__('Type').': </p>';
$table->data[1][0] .= '<div class="label_select_parent">'.html_print_select(
$integria_types_values,
'type',
$input_value_type,
'',
__('Select'),
0,
true,
false,
true,
'',
false,
'width: 100%;'
).'</div>';
$table->data[2][0] = '<div class="label_select"><p class="input_label">'.__('Status').': </p>';
$table->data[2][0] .= '<div class="label_select_parent">'.html_print_select(
$integria_status_values,
'status',
$input_value_status,
'',
__('Select'),
1,
true,
false,
true,
'',
false,
'width: 100%;'
).'</div>';
$table->data[1][1] = '<div class="label_select"><p class="input_label">'.__('Group').': </p>';
$table->data[1][1] .= '<div class="label_select_parent">'.html_print_select(
$integria_group_values,
'group',
$input_value_group,
'',
'',
0,
true,
false,
true,
'',
false,
'width: 100%;'
).'</div>';
$table->data[2][1] = '<div class="label_select"><p class="input_label">'.__('Creator').': </p>';
$table->data[2][1] .= '<div class="label_select_parent">'.html_print_input_text(
'creator',
$config['integria_user'],
'',
'30',
100,
true,
true,
false,
'',
'w100p'
).ui_print_help_tip(__('This field corresponds to the Integria IMS user specified in Integria IMS setup'), true).'</div>';
$table->data[1][2] = '<div class="label_select"><p class="input_label">'.__('Priority').': </p>';
$table->data[1][2] .= '<div class="label_select_parent">'.html_print_select(
$integria_criticity_values,
'criticity',
$input_value_criticity,
'',
__('Select'),
0,
true,
false,
true,
'',
false,
'width: 100%;'
).'</div>';
$table->data[2][2] = '<div class="label_select"><p class="input_label">'.__('Owner').': </p>';
$table->data[2][2] .= '<div class="label_select_parent">'.html_print_autocomplete_users_from_integria(
'owner',
$input_value_owner,
true
).'</div>';
$table->data[3][0] = '<div class="label_select"><p class="input_label">'.__('Description').':&nbsp'.$help_macros.'</p>';
$table->data[3][0] .= '<div class="label_select_parent">'.html_print_textarea(
'incident_content',
3,
20,
$input_value_content,
'',
true
).'</div>';
// Print forms and stuff.
echo '<form id="create_integria_incident_form" name="create_integria_incident_form" method="POST">';
html_print_table($table);
if (!$update) {
html_print_input_hidden('create_incident', 1);
} else {
html_print_input_hidden('update_incident', 1);
}
echo '</form>';
echo '<div style="width: 100%; text-align:right;">';
if ($update) {
html_print_submit_button(__('Update'), 'accion', false, 'form="create_integria_incident_form" class="sub wand"');
} else {
html_print_submit_button(__('Create'), 'accion', false, 'form="create_integria_incident_form" class="sub wand"');
}
echo '</div>';

View File

@ -0,0 +1,488 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 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.
// Load global vars
global $config;
require_once 'include/functions_integriaims.php';
check_login();
if (!check_acl($config['id_user'], 0, 'IR')) {
// Doesn't have access to this page.
db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation');
include 'general/noaccess.php';
exit;
}
// Check if Integria integration enabled.
if ($config['integria_enabled'] == 0) {
ui_print_error_message(__('Integria integration must be enabled in Pandora setup'));
return;
}
// Check connection to Integria IMS API.
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []);
if ($has_connection === false) {
ui_print_error_message(__('Integria IMS API is not reachable'));
return;
}
// Styles.
ui_require_css_file('integriaims');
// Get id incident.
$incident_id = (int) get_parameter('incident_id');
// API call.
$result_api_call_list = integria_api_call(
$config['integria_hostname'],
$config['integria_user'],
$config['integria_pass'],
$config['integria_api_pass'],
'get_incident_details',
[$incident_id]
);
// Return array of api call 'get_incidents'.
$array_get_incidents = [];
get_array_from_csv_data_all($result_api_call_list, $array_get_incidents);
// Remove index (id)
$array_get_incidents = $array_get_incidents[$incident_id];
// Header tabs.
$onheader = integriaims_tabs(false, $incident_id);
ui_print_page_header($array_get_incidents[3].' - '.__('Details'), '', false, '', false, $onheader);
// Data.
$status = $array_get_incidents[6];
$resolution = $array_get_incidents[12];
$group = $array_get_incidents[8];
$priority = $array_get_incidents[7];
$type = $array_get_incidents[17];
$description = $array_get_incidents[4];
$creator = $array_get_incidents[10];
$owner = $array_get_incidents[5];
$closed_by = $array_get_incidents[23];
$created_at = $array_get_incidents[1];
$updated_at = $array_get_incidents[9];
$closed_at = $array_get_incidents[2];
if ($closed_at == '0000-00-00 00:00:00') {
$closed_at = __('Not yet');
}
if ($closed_by == '') {
$closed_by = __('Not closed yet');
}
// API calls.
$status_text = integriaims_get_details('status', $status);
$group_text = integriaims_get_details('group', $group);
$priority_text = integriaims_get_details('priority', $priority);
$resolution_text = integriaims_get_details('resolution', $resolution);
$type_text = integriaims_get_details('type', $type);
// Incident file management.
$upload_file = get_parameter('upload_file');
$delete_file_id = get_parameter('delete_file');
$download_file_id = get_parameter('download_file');
$download_file_name = get_parameter('download_file_name');
// Files section table.
$table_files_section = new stdClass();
$table_files_section->width = '100%';
$table_files_section->id = 'files_section_table';
$table_files_section->class = 'databox filters';
$table_files_section->head = [];
$table_files_section->data = [];
$table_files_section->size = [];
$table_files_section->colspan[2][0] = 3;
// Files list table.
$table_files = new stdClass();
$table_files->width = '100%';
$table_files->class = 'info_table';
$table_files->head = [];
$table_files->head[0] = __('Filename');
$table_files->head[1] = __('Timestamp');
$table_files->head[2] = __('Description');
$table_files->head[3] = __('User');
$table_files->head[4] = __('Size');
if (check_acl($config['id_user'], 0, 'IW')) {
$table_files->head[5] = __('Delete');
}
$table_files->data = [];
// Upload file.
if ($upload_file && ($_FILES['userfile']['name'] != '')) {
$filedescription = get_parameter('file_description', __('No description available'));
$filename = io_safe_input($_FILES['userfile']['name']);
$filesize = io_safe_input($_FILES['userfile']['size']);
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$invalid_extensions = '/^(bat|exe|cmd|sh|php|php1|php2|php3|php4|php5|pl|cgi|386|dll|com|torrent|js|app|jar|iso|
pif|vb|vbscript|wsf|asp|cer|csr|jsp|drv|sys|ade|adp|bas|chm|cpl|crt|csh|fxp|hlp|hta|inf|ins|isp|jse|htaccess|
htpasswd|ksh|lnk|mdb|mde|mdt|mdw|msc|msi|msp|mst|ops|pcd|prg|reg|scr|sct|shb|shs|url|vbe|vbs|wsc|wsf|wsh)$/i';
if (!preg_match($invalid_extensions, $extension)) {
// The following is if you have clamavlib installed.
// (php5-clamavlib) and enabled in php.ini
// http://www.howtoforge.com/scan_viruses_with_php_clamavlib
if (extension_loaded('clamav')) {
cl_setlimits(5, 1000, 200, 0, 10485760);
$malware = cl_scanfile($_FILES['file']['tmp_name']);
if ($malware) {
$error = 'Malware detected: '.$malware.'<br>ClamAV version: '.clam_get_version();
die($error);
// On malware, we die because it's not good to handle it
}
}
$filecontent = base64_encode(file_get_contents($_FILES['userfile']['tmp_name']));
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'attach_file', [$incident_id, $filename, $filesize, $filedescription, $filecontent]);
// API method returns '0' string if success.
$file_added = ($result_api_call === '0') ? true : false;
ui_print_result_message(
$file_added,
__('File successfully added'),
__('File could not be added')
);
} else {
ui_print_error_message(__('File has an invalid extension'));
}
}
// Delete file.
if (isset($_GET['delete_file'])) {
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'delete_file', [$delete_file_id]);
$file_deleted = false;
if ($result_api_call === '0') {
$file_deleted = true;
}
ui_print_result_message(
$file_deleted,
__('File successfully deleted'),
__('File could not be deleted')
);
}
// Download file.
if (isset($_GET['download_file'])) {
$file_base64 = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'download_file', [$download_file_id]);
ob_end_clean();
$decoded = base64_decode($file_base64);
file_put_contents($download_file_name, $decoded);
ob_end_clean();
if (file_exists($download_file_name)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($download_file_name).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: '.filesize($download_file_name));
ob_end_clean();
readfile($download_file_name);
unlink($download_file_name);
exit;
}
header('Location: index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$incident_id);
}
// Retrieve files belonging to incident and create list table.
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_files', [$incident_id]);
if ($result_api_call != false && strlen($result_api_call) > 0) {
$files = [];
$csv_array = explode("\n", $result_api_call);
foreach ($csv_array as $csv_line) {
if (!empty($csv_line)) {
$files[] = explode(',', $csv_line);
}
}
}
$i = 0;
foreach ($files as $key => $value) {
$table_files->data[$i][0] = '<a id="link_delete_file" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$incident_id.'&download_file='.$value[0]).'&download_file_name='.$value[11].'">'.$value[11].'</a>';
$table_files->data[$i][1] = $value[14];
$table_files->data[$i][2] = $value[12];
$table_files->data[$i][3] = $value[8];
$table_files->data[$i][4] = $value[13];
if (check_acl($config['id_user'], 0, 'IW')) {
$table_files->data[$i][5] .= '<a id="link_delete_file" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$incident_id.'&delete_file='.$value[0]).'"
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">';
$table_files->data[$i][5] .= html_print_image('images/cross.png', true, ['title' => __('Delete')]);
}
$table_files->data[$i][5] .= '</a>';
$i++;
}
$table_files_section->data[0][0] = '<div class="label_select"><p class="input_label">'.__('File name').':</p>';
$table_files_section->data[0][0] .= html_print_input_file('userfile', true);
$table_files_section->data[1][0] = '<div class="label_select"><p class="input_label">'.__('Description').':</p>';
$table_files_section->data[1][0] .= html_print_textarea(
'file_description',
3,
20,
'',
'',
true
);
$table_files_section->data[2][0] .= '<div style="width: 100%; text-align:right;">'.html_print_submit_button(__('Upload'), 'accion', false, 'class="sub wand"', true).'</div>';
$upload_file_form = '<div>';
if (check_acl($config['id_user'], 0, 'IW')) {
$upload_file_form .= '<form method="post" id="file_control" enctype="multipart/form-data">'.'<h4>'.__('Add attachment').'</h4>'.html_print_table($table_files_section, true).html_print_input_hidden('upload_file', 1, true);
}
$upload_file_form .= '<h4>'.__('Attached files').'</h4>'.html_print_table($table_files, true).'</form></div>';
// Incident comments management.
$upload_comment = get_parameter('upload_comment');
$comment_description = get_parameter('comment_description');
// Comments section table.
$table_comments_section = new stdClass();
$table_comments_section->width = '100%';
$table_comments_section->id = 'files_section_table';
$table_comments_section->class = 'databox filters';
$table_comments_section->head = [];
$table_comments_section->data = [];
$table_comments_section->size = [];
// Comments list table.
$table_comments = new stdClass();
$table_comments->width = '100%';
$table_comments->class = 'info_table';
$table_comments->head = [];
$table_comments->head[0] = __('Filename');
$table_comments->head[1] = __('Timestamp');
$table_comments->head[2] = __('Description');
$table_comments->head[3] = __('User');
$table_comments->head[4] = __('Size');
$table_comments->head[5] = __('Delete');
$table_comments->data = [];
$comment_disabled = ($array_get_incidents[6] == 7);
if ($comment_disabled === true) {
$attribute = 'disabled=disabled';
}
$table_comments_section->data[0][0] = '<div class="label_select"><p class="input_label">'.__('Description').':</p>';
$table_comments_section->data[0][0] .= html_print_textarea(
'comment_description',
3,
20,
'',
$attribute,
true
);
$table_comments_section->data[1][1] .= '<div style="width: 100%; text-align:right;">'.html_print_submit_button(__('Add'), 'accion', $comment_disabled, 'class="sub wand"', true).'</div>';
// Upload comment. If ticket is closed, this action cannot be performed.
if ($upload_comment && $array_get_incidents[6] != 7) {
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'create_workunit', [$incident_id, $comment_description, '0.00', 0, 1, '0']);
// API method returns id of new comment if success.
$comment_added = ($result_api_call >= '0') ? true : false;
ui_print_result_message(
$comment_added,
__('Comment successfully added'),
__('Comment could not be added')
);
}
// Retrieve comments belonging to incident and create comments table.
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_workunits', [$incident_id]);
if ($result_api_call != false && strlen($result_api_call) > 0) {
$comments = [];
$csv_array = explode("\n", $result_api_call);
foreach ($csv_array as $csv_line) {
if (!empty($csv_line)) {
$comments[] = explode(',', $csv_line);
}
}
}
$comment_table = '';
if (!empty($comments)) {
foreach ($comments as $key => $value) {
$comment_table .= '<div class="comment_title">'.$value[3].'<span>&nbspsaid&nbsp</span>'.$value[1].'<span style="float: right;">'.$value[2].'&nbspHours</span></div>';
$comment_table .= '<div class="comment_body">'.$value[4].'</div>';
}
} else {
$comment_table = __('No comments found');
}
$upload_comment_form = '<div>';
if (check_acl($config['id_user'], 0, 'IW')) {
$upload_comment_form .= '<form method="post" id="comment_form" enctype="multipart/form-data"><h4>'.__('Add comment').'</h4>'.html_print_table($table_comments_section, true).html_print_input_hidden('upload_comment', 1, true).'</form>';
}
$upload_comment_form .= '<h4>'.__('Comments').'</h4>'.$comment_table.'</div>';
// Details box.
$details_box = '<div class="integriaims_details_box integriaims_details_box_five">';
$details_box .= '
<div class="integriaims_details_titles">'.__('Status').'</div>
<div class="integriaims_details_titles">'.__('Resolution').'</div>
<div class="integriaims_details_titles">'.__('Group').'</div>
<div class="integriaims_details_titles">'.__('Priority').'</div>
<div class="integriaims_details_titles">'.__('Type').'</div>';
$details_box .= '
<div>'.html_print_image('images/heart.png', true).'</div>
<div>'.html_print_image('images/builder.png', true).'</div>
<div>'.html_print_image('images/user_green.png', true).'</div>
<div>'.ui_print_integria_incident_priority($priority, $priority_text).'</div>
<div>'.html_print_image('images/incidents.png', true).'</div>';
$details_box .= '
<div>'.$status_text.'</div>
<div>'.$resolution_text.'</div>
<div>'.$group_text.'</div>
<div>'.$priority_text.'</div>
<div>'.$type_text.'</div>';
$details_box .= '</div>';
// People box.
$people_box = '<div class="integriaims_details_box integriaims_details_box_three">';
$people_box .= '
<div>'.html_print_image('images/header_user_green.png', true, ['width' => '21']).'</div>
<div>'.html_print_image('images/header_user_green.png', true, ['width' => '21']).'</div>
<div>'.html_print_image('images/header_user_green.png', true, ['width' => '21']).'</div>';
$people_box .= '
<div class="integriaims_details_titles">'.__('Created by').':</div>
<div class="integriaims_details_titles">'.__('Owned by').':</div>
<div class="integriaims_details_titles">'.__('Closed by').':</div>';
$people_box .= '
<div>'.$creator.'</div>
<div>'.$owner.'</div>
<div>'.$closed_by.'</div>';
$people_box .= '</div>';
// Dates box.
$dates_box = '<div class="integriaims_details_box integriaims_details_box_three">';
$dates_box .= '
<div>'.html_print_image('images/tick.png', true).'</div>
<div>'.html_print_image('images/update.png', true, ['width' => '21']).'</div>
<div>'.html_print_image('images/mul.png', true).'</div>';
$dates_box .= '
<div class="integriaims_details_titles">'.__('Created at').':</div>
<div class="integriaims_details_titles">'.__('Updated at').':</div>
<div class="integriaims_details_titles">'.__('Closed at').':</div>';
$dates_box .= '
<div>'.$created_at.'</div>
<div>'.$updated_at.'</div>
<div>'.$closed_at.'</div>';
$dates_box .= '</div>';
// Show details, people and dates.
echo '<div class="integria_details">';
ui_toggle($details_box, __('Details'), '', 'details_box', false, false, '', 'integria_details_content white-box-content', 'integria_details_shadow box-shadow white_table_graph');
ui_toggle($people_box, __('People'), '', 'people_box', false, false, '', 'integria_details_content white-box-content', 'integria_details_shadow box-shadow white_table_graph');
ui_toggle($dates_box, __('Dates'), '', 'dates_box', false, false, '', 'integria_details_content white-box-content', 'integria_details_shadow box-shadow white_table_graph');
echo '</div>';
// Show description.
$description_box = '<div class="integria_details_description">'.html_print_textarea(
'integria_details_description',
3,
0,
$description,
'disabled="disabled"',
true
).'</div>';
ui_toggle($description_box, __('Description'), '', '', false);
echo '<div class="ui_toggle">';
ui_toggle(
$upload_file_form,
__('Attached files'),
'',
'',
true,
false,
'white_box white_box_opened',
'no-border flex'
);
echo '</div>';
echo '<div class="ui_toggle">';
ui_toggle(
$upload_comment_form,
__('Comments'),
'',
'',
true,
false,
'white_box white_box_opened',
'no-border flex'
);
echo '</div>';
?>
<script type="text/javascript">
$(document).ready (function () {
$('#details_box .white_table_graph_header').click(function(){
$('div#details_box').toggleClass('integria_details_shadow');
});
$('#people_box .white_table_graph_header').click(function(){
$('div#people_box').toggleClass('integria_details_shadow');
});
$('#dates_box .white_table_graph_header').click(function(){
$('div#dates_box').toggleClass('integria_details_shadow');
});
});
</script>

View File

@ -0,0 +1,129 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// 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.
// Load global vars
global $config;
require_once '../../include/config.php';
require_once '../../include/functions.php';
require_once '../../include/functions_integriaims.php';
check_login();
if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], 0, 'IW') && ! check_acl($config['id_user'], 0, 'IM')) {
// Doesn't have access to this page.
db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation');
include 'general/noaccess.php';
exit;
}
// API calls.
$status_incident = integriaims_get_details('status');
$group_incident = integriaims_get_details('group');
$priority_incident = integriaims_get_details('priority');
$resolution_incident = integriaims_get_details('resolution');
// Get data to export.
$tickets_filters = json_decode(
base64_decode(
get_parameter('tickets_filters', '')
),
true
);
$tickets_csv_array = get_tickets_integriaims($tickets_filters);
// Build a new array to show only the fields in the table.
$tickets_csv_array_filter = [];
foreach ($tickets_csv_array as $key => $value) {
// Status.
if ($tickets_csv_array[$key][6] == 0) {
$tickets_csv_array[$key][6] = 'None';
} else {
$tickets_csv_array[$key][6] = $status_incident[$tickets_csv_array[$key][6]];
}
// Priority.
$tickets_csv_array[$key][7] = $priority_incident[$tickets_csv_array[$key][7]];
// Group.
$tickets_csv_array[$key][8] = $group_incident[$tickets_csv_array[$key][8]];
// Resolution.
if ($tickets_csv_array[$key][12] == 0) {
$tickets_csv_array[$key][12] = 'None';
} else {
$tickets_csv_array[$key][12] = $resolution_incident[$tickets_csv_array[$key][12]];
}
$tickets_csv_array_filter[$key] = [
'id_incidencia' => $tickets_csv_array[$key][0],
'titulo' => $tickets_csv_array[$key][3],
'id_grupo' => $tickets_csv_array[$key][8],
'estado' => $tickets_csv_array[$key][6],
'resolution' => $tickets_csv_array[$key][12],
'prioridad' => $tickets_csv_array[$key][7],
'actualizacion' => $tickets_csv_array[$key][9],
'inicio' => $tickets_csv_array[$key][1],
'id_creator' => $tickets_csv_array[$key][10],
'owner' => $tickets_csv_array[$key][5],
];
}
// Header for CSV file.
$header = [
__('ID Ticket'),
__('Title'),
__('Group/Company'),
__('Status'),
__('Resolution'),
__('Priority'),
__('Updated'),
__('Started'),
__('Creator'),
__('Owner'),
];
$header_csv = '';
foreach ($header as $key => $value) {
$header_csv .= $value.',';
}
$header_csv = io_safe_output($header_csv).PHP_EOL;
// Join header and content.
$tickets_csv = '';
foreach ($tickets_csv_array_filter as $key => $value) {
$tickets_csv .= implode(',', $tickets_csv_array_filter[$key]).PHP_EOL;
}
$tickets_csv = $header_csv.$tickets_csv;
// Create csv file.
$filename = 'tickets_export-'.date('Ymd').'-'.date('His').'.csv';
ob_clean();
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename='.$filename);
// BOM.
echo pack('C*', 0xEF, 0xBB, 0xBF);
// CSV file.
echo io_safe_output($tickets_csv);

View File

@ -0,0 +1,335 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 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.
// Load global vars
global $config;
require_once 'include/functions_integriaims.php';
check_login();
if (! check_acl($config['id_user'], 0, 'IR')) {
// Doesn't have access to this page.
db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation');
include 'general/noaccess.php';
exit;
}
// Header tabs.
$onheader = integriaims_tabs('list_tab');
ui_print_page_header(__('Integria IMS Tickets'), '', false, '', false, $onheader);
// Check if Integria integration enabled.
if ($config['integria_enabled'] == 0) {
ui_print_error_message(__('Integria integration must be enabled in Pandora setup'));
return;
}
// Check connection to Integria IMS API.
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []);
if ($has_connection === false) {
ui_print_error_message(__('Integria IMS API is not reachable'));
return;
}
// Styles.
ui_require_css_file('integriaims');
// Get parameters for filters.
$incident_text = (string) get_parameter('incident_text', '');
$incident_status = (int) get_parameter('incident_status', 0);
$incident_group = (int) get_parameter('incident_group', 1);
$incident_owner = (string) get_parameter('incident_owner', '');
$incident_creator = (string) get_parameter('incident_creator', '');
$incident_priority = (int) get_parameter('incident_priority', -1);
$incident_resolution = (string) get_parameter('incident_resolution', '');
$created_from = (string) get_parameter('created_from', '');
$created_to = (string) get_parameter('created_to', '');
$offset = (int) get_parameter('offset');
$delete_incident = get_parameter('delete_incident');
if ($delete_incident) {
// Call Integria IMS API method to delete an incident.
$result_api_call_delete = integria_api_call(
$config['integria_hostname'],
$config['integria_user'],
$config['integria_pass'],
$config['integria_api_pass'],
'delete_incident',
[$delete_incident]
);
$incident_deleted_ok = ($result_api_call_delete !== false) ? true : false;
ui_print_result_message(
$incident_deleted_ok,
__('Successfully deleted'),
__('Could not be deleted')
);
}
// Full url with all filters.
$url = ui_get_full_url(
'index.php?sec=incident&sec2=operation/incidents/list_integriaims_incidents&incident_text='.$incident_text.'&incident_status='.$incident_status.'&incident_group='.$incident_group.'&incident_owner='.$incident_owner.'&incident_creator='.$incident_creator.'&incident_priority='.$incident_priority.'&incident_resolution='.$incident_resolution.'&created_from='.$created_from.'&created_to='.$created_to.'&offset='.$offset
);
// ---- FILTERS ----
// API calls to fill the filters.
$status_incident = integriaims_get_details('status');
$group_incident = integriaims_get_details('group');
$priority_incident = integriaims_get_details('priority');
$resolution_incident = integriaims_get_details('resolution');
// TABLE FILTERS.
$table = new StdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->styleTable = 'margin-bottom:0px';
$table->cellpadding = '0';
$table->cellspacing = '0';
$table->data = [];
$table->data[0][0] = __('Text filter');
$table->data[0][1] = html_print_input_text('incident_text', $incident_text, '', 30, 100, true);
$table->data[0][2] = __('Status');
$table->data[0][3] = html_print_select(
$status_incident,
'incident_status',
$incident_status,
'',
__('All'),
0,
true
);
$table->data[0][4] = __('Group');
$table->data[0][5] = html_print_select(
$group_incident,
'incident_group',
$incident_group,
'',
__('All'),
1,
true
);
$table->data[1][0] = __('Owner');
$table->data[1][1] = html_print_autocomplete_users_from_integria('incident_owner', $incident_owner, true);
$table->data[1][2] = __('Creator');
$table->data[1][3] = html_print_autocomplete_users_from_integria('incident_creator', $incident_creator, true);
$table->data[1][4] = __('Priority');
$table->data[1][5] = html_print_select(
$priority_incident,
'incident_priority',
$incident_priority,
'',
__('All'),
-1,
true
);
$table->data[2][0] = __('Resolution');
$table->data[2][1] = html_print_select(
$resolution_incident,
'incident_resolution',
$incident_resolution,
'',
__('All'),
'',
true
);
// TODO: field type date.
$table->data[2][2] = __('Date');
$table->data[2][3] = html_print_input_text_extended(
'created_from',
$created_from,
'created_from',
'',
12,
50,
false,
'',
'placeholder="'.__('Created from').'"',
true
);
$table->data[2][3] .= html_print_input_text_extended(
'created_to',
$created_to,
'created_to',
'',
12,
50,
false,
'',
'style="margin-left:5px;" placeholder="'.__('Created to').'"',
true
);
// TODO: image of Integria IMS.
$table->data[2][4] = '';
$table->data[2][5] = '';
// Send filters to get_tickets_integriaims().
$tickets_filters = [
'incident_text' => $incident_text,
'incident_status' => $incident_status,
'incident_group' => $incident_group,
'incident_owner' => $incident_owner,
'incident_creator' => $incident_creator,
'incident_priority' => $incident_priority,
'incident_resolution' => $incident_resolution,
'created_from' => $created_from,
'created_to' => $created_to,
];
// Data to export to csv file.
$decode_csv = base64_encode(json_encode($tickets_filters));
// ---- PRINT TABLE FILTERS ----
$integria_incidents_form = '<form method="post" action="'.$url.'" style="padding:0px;">';
$integria_incidents_form .= html_print_table($table, true);
$integria_incidents_form .= '<div style="width:100%; text-align:right;">';
$integria_incidents_form .= '<div style="float:right; margin-left: 5px;">'.html_print_button(
__('Export to CSV'),
'csv_export',
false,
"location.href='operation/incidents/integriaims_export_csv.php?tickets_filters=$decode_csv'",
'class="sub next"',
true
).'</div>';
$integria_incidents_form .= '<div>'.html_print_submit_button(__('Filter'), 'filter_button', false, 'class="sub filter"', true).'</div>';
$integria_incidents_form .= '</div>';
$integria_incidents_form .= '</form>';
ui_toggle($integria_incidents_form, __('Filter'), '', '', false);
/*
* Order api call 'get_incidents'.
*
* resolution = $array_get_incidents[$key][12]
* id_incidencia = $array_get_incidents[$key][0]
* titulo = $array_get_incidents[$key][3]
* id_grupo = $array_get_incidents[$key][8]
* estado = $array_get_incidents[$key][6]
* prioridad = $array_get_incidents[$key][7]
* actualizacion = $array_get_incidents[$key][9]
* id_creator = $array_get_incidents[$key][10]
*
*/
// ---- LIST OF INCIDENTS ----
// Get list of incidents.
$array_get_incidents = get_tickets_integriaims($tickets_filters);
// Prepare pagination.
$incidents_limit = $config['block_size'];
$incidents_paginated = array_slice($array_get_incidents, $offset, $incidents_limit, true);
// TABLE INCIDENTS.
$table = new stdClass();
$table->width = '100%';
$table->class = 'info_table';
$table->head = [];
$table->head[0] = __('ID');
$table->head[1] = __('Ticket');
$table->head[2] = __('Group/Company');
$table->head[3] = __('Status/Resolution');
$table->head[4] = __('Prior');
$table->head[5] = __('Updated/Started');
$table->head[6] = __('Creator');
$table->head[7] = __('Owner');
if (check_acl($config['id_user'], 0, 'IW') || check_acl($config['id_user'], 0, 'IM')) {
$table->head[8] = '';
}
$table->data = [];
$i = 0;
foreach ($incidents_paginated as $key => $value) {
if ($array_get_incidents[$key][6] == 0) {
$status_incident[$array_get_incidents[$key][6]] = __('None');
}
if ($array_get_incidents[$key][12] == 0) {
$resolution_incident[$array_get_incidents[$key][12]] = __('None');
}
$table->data[$i][0] = '#'.$array_get_incidents[$key][0];
$table->data[$i][1] = '<a href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$array_get_incidents[$key][0]).'">';
$table->data[$i][1] .= $array_get_incidents[$key][3];
$table->data[$i][1] .= '</a>';
$table->data[$i][2] = $group_incident[$array_get_incidents[$key][8]];
$table->data[$i][3] = $status_incident[$array_get_incidents[$key][6]].' / '.$resolution_incident[$array_get_incidents[$key][12]];
$table->data[$i][4] = ui_print_integria_incident_priority($array_get_incidents[$key][7], $priority_incident[$array_get_incidents[$key][7]]);
$table->data[$i][5] = $array_get_incidents[$key][9].' / '.$array_get_incidents[$key][1];
$table->data[$i][6] = $array_get_incidents[$key][10];
$table->data[$i][7] = $array_get_incidents[$key][5];
$table->data[$i][8] = '';
$table->cellclass[$i][8] = 'action_buttons';
if (check_acl($config['id_user'], 0, 'IW')) {
$table->data[$i][8] .= '<a href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&incident_id='.$array_get_incidents[$key][0]).'">';
$table->data[$i][8] .= html_print_image('images/config.png', true, ['title' => __('Edit')]);
$table->data[$i][8] .= '</a>';
}
if (check_acl($config['id_user'], 0, 'IM')) {
$table->data[$i][8] .= '<a id="link_delete_incident" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/list_integriaims_incidents&delete_incident='.$array_get_incidents[$key][0]).'"
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">';
$table->data[$i][8] .= html_print_image('images/cross.png', true, ['title' => __('Delete')]);
$table->data[$i][8] .= '</a>';
}
$i++;
}
// Show table incidents.
ui_pagination(count($array_get_incidents), $url, $offset);
if (empty($table->data) === true) {
ui_print_info_message(['no_close' => true, 'message' => __('No tickets to show').'.' ]);
} else {
html_print_table($table);
ui_pagination(count($array_get_incidents), $url, $offset, 0, false, 'offset', true, 'pagination-bottom');
}
// Show button to create incident.
if (check_acl($config['id_user'], 0, 'IR')) {
echo '<form method="POST" action="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident').'">';
echo '<div style="width: 100%; text-align:right;">';
html_print_submit_button(__('Create'), 'create_new_incident', false, 'class="sub next"');
echo '</div>';
echo '</form>';
}
// Datapicker library for show calendar.
ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/');
?>
<script language="javascript" type="text/javascript">
$(document).ready( function() {
$("#created_from, #created_to").datepicker({
dateFormat: "<?php echo DATE_FORMAT_JS; ?>"
});
});
</script>

View File

@ -479,6 +479,7 @@ if (check_acl($config['id_user'], 0, 'IR')
$sub2 = [];
$sub2['operation/incidents/incident']['text'] = __('List of Incidents');
$sub2[$sec2sub]['text'] = __('Statistics');
$sub2['operation/incidents/list_integriaims_incidents']['text'] = __('Integria IMS Tickets');
$sub[$sec2]['sub2'] = $sub2;
$sec2 = $temp_sec2;

View File

@ -116,7 +116,29 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.0009765625":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'),
('custom_docs_logo', 'default_docs.png'),
('custom_support_logo', 'default_support.png'),
('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');
('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'),
('integria_enabled', 0),
('integria_user', ''),
('integria_pass', ''),
('integria_hostname', ''),
('integria_api_pass', ''),
('integria_req_timeout', 5),
('default_group', ''),
('default_criticity', ''),
('default_creator', ''),
('default_owner', ''),
('incident_type', ''),
('incident_status', ''),
('incident_title', ''),
('incident_content', ''),
('cr_default_group', ''),
('cr_default_criticity', ''),
('cr_default_creator', ''),
('cr_default_owner', ''),
('cr_incident_type', ''),
('cr_incident_status', ''),
('cr_incident_title', ''),
('cr_incident_content', '');
UNLOCK TABLES;
--

View File

@ -1137,7 +1137,9 @@ sub pandora_execute_action ($$$$$$$$$;$) {
load_module_macros ($module->{'module_macros'}, \%macros);
}
# User defined alerts
#logger($pa_config, "Clean name ".$clean_name, 10);
# User defined alert
if ($action->{'internal'} == 0) {
$macros{_field1_} = subst_alert_macros ($field1, \%macros, $pa_config, $dbh, $agent, $module);
$macros{_field2_} = subst_alert_macros ($field2, \%macros, $pa_config, $dbh, $agent, $module);
@ -1442,55 +1444,70 @@ sub pandora_execute_action ($$$$$$$$$;$) {
# Integria IMS Ticket
} elsif ($clean_name eq "Integria IMS Ticket") {
my $config_api_path = pandora_get_tconfig_token ($dbh, 'integria_hostname', '');
my $config_api_pass = pandora_get_tconfig_token ($dbh, 'integria_api_pass', '');
my $config_integria_user = pandora_get_tconfig_token ($dbh, 'integria_user', '');
my $config_integria_user_pass = pandora_get_tconfig_token ($dbh, 'integria_pass', '');
$field1 = subst_alert_macros ($field1, \%macros, $pa_config, $dbh, $agent, $module);
$field2 = subst_alert_macros ($field2, \%macros, $pa_config, $dbh, $agent, $module);
$field3 = subst_alert_macros ($field3, \%macros, $pa_config, $dbh, $agent, $module);
$field4 = subst_alert_macros ($field4, \%macros, $pa_config, $dbh, $agent, $module);
$field5 = subst_alert_macros ($field5, \%macros, $pa_config, $dbh, $agent, $module);
$field6 = subst_alert_macros ($field6, \%macros, $pa_config, $dbh, $agent, $module);
$field7 = subst_alert_macros ($field7, \%macros, $pa_config, $dbh, $agent, $module);
$field8 = subst_alert_macros ($field8, \%macros, $pa_config, $dbh, $agent, $module);
$field9 = subst_alert_macros ($field9, \%macros, $pa_config, $dbh, $agent, $module);
$field10 = subst_alert_macros ($field10, \%macros, $pa_config, $dbh, $agent, $module);
# Field 1 (Integria IMS API path)
my $api_path = $field1;
my $api_path = $config_api_path . "/integria/include/api.php";
# Field 2 (Integria IMS API pass)
my $api_pass = $field2;
my $api_pass = $config_api_pass;
# Field 3 (Integria IMS user)
my $integria_user = $field3;
my $integria_user = $config_integria_user;
# Field 4 (Integria IMS user password)
my $integria_user_pass = $field4;
my $integria_user_pass = $config_integria_user_pass;
# Field 5 (Ticket name)
my $ticket_name = $field5;
# Field 1 (Ticket name)
my $ticket_name = safe_output($field1);
if ($ticket_name eq "") {
$ticket_name = $pa_config->{'rb_product_name'} . " alert action created by API";
}
# Field 6 (Ticket group ID)
my $ticket_group_id = $field6;
# Field 2 (Ticket group ID)
my $ticket_group_id = $field2;
if ($ticket_group_id eq '') {
$ticket_group_id = 0;
}
# Field 7 (Ticket priority);
my $ticket_priority = $field7;
if ($ticket_priority eq '') {
$ticket_priority = 0;
# Field 3 (Ticket priority);
my $ticket_priority = $field3;
if ($ticket_priority eq '0') {
$ticket_priority = 1;
}
# Field 4 (Ticket owner)
my $ticket_owner = $field4;
if ($ticket_owner eq '') {
$ticket_owner = 'admin';
}
# Field 8 (Ticket email)
my $ticket_email = $field8;
# Field 9 (Ticket owner)
my $ticket_owner = $field9;
# Field 10 (Ticket description);
my $ticket_description = $field10;
# Field 5 (Ticket type)
my $ticket_type = $field5;
if ($ticket_type eq '') {
$ticket_type = 0;
}
pandora_create_integria_ticket($pa_config, $api_path, $api_pass, $integria_user, $integria_user_pass, $ticket_name, $ticket_group_id, $ticket_priority, $ticket_email, $ticket_owner, $ticket_description);
# Field 6 (Ticket status)
my $ticket_status = $field6;
if ($ticket_status eq '0') {
$ticket_status = 1;
}
# Field 7 (Ticket description);
my $ticket_description = safe_output($field7);
pandora_create_integria_ticket($pa_config, $api_path, $api_pass, $integria_user, $integria_user_pass, $ticket_name, $ticket_group_id, $ticket_priority, $ticket_owner, $ticket_type, $ticket_status, $ticket_description);
# Generate notification
} elsif ($clean_name eq "Generate Notification") {
@ -5849,55 +5866,21 @@ sub pandora_edit_custom_graph ($$$$$$$$$$$) {
}
sub pandora_create_integria_ticket ($$$$$$$$$$$) {
my ($pa_config,$api_path,$api_pass,$integria_user,$user_pass,$ticket_name,$group_id,$ticket_priority,$ticket_email,$ticket_owner,$ticket_description) = @_;
my ($pa_config,$api_path,$api_pass,$integria_user,$user_pass,$ticket_name,$ticket_group_id,$ticket_priority,$ticket_owner,$ticket_type,$ticket_status,$ticket_description) = @_;
my $data_ticket;
my $call_api;
if ($api_path eq "") {
return 0;
}
if ($user_pass eq "") {
return 0;
}
if ($integria_user eq "") {
$integria_user = "admin";
}
if ($ticket_name eq "") {
$ticket_name = "Ticket created by " . $pa_config->{'rb_product_name'};
}
if ($group_id eq "") {
$group_id = 1;
}
if ($ticket_priority eq "") {
$ticket_priority = 1;
}
if ($ticket_owner eq "") {
$ticket_owner = "admin";
}
#~ $data_ticket = $ticket_name .
#~ "|;|" . $group_id .
#~ "|;|" . $ticket_priority .
#~ "|;|" . $ticket_description .
#~ "|;|" . #Id inventory
#~ "|;|" . #Id incident type
#~ "|;|" . $ticket_email .
#~ "|;|" . $ticket_owner .
#~ "|;|" . #Father ticket id
#~ "|;|" . #Status
#~ "|;|" . #Extra info
#~ "|;|"; #Resolution
$data_ticket = $ticket_name .
"|;|" . $group_id .
"|;|" . $ticket_group_id .
"|;|" . $ticket_priority .
"|;|" . $ticket_description .
"|;|" .
"|;|" .
"|;|" . $ticket_email .
"|;|" . $ticket_type .
"|;|" .
"|;|" . $ticket_owner .
"|;|" .
"|;|" . '1' .
"|;|" . $ticket_status .
"|;|" .
"|;|";
@ -5908,9 +5891,9 @@ sub pandora_create_integria_ticket ($$$$$$$$$$$) {
'op=create_incident&' .
'params=' . $data_ticket .'&' .
'token=|;|';
logger($pa_config, "Integria ticket call:" . $call_api . "", 3);
my $content = get($call_api);
logger($pa_config, "Integria ticket res:" . $content . "", 3);
if (is_numeric($content) && $content ne "-1") {
return $content;
}

View File

@ -38,6 +38,7 @@ Where options:
Optional parameters:
[-priority <priority>] : 10 Maintance, 0 Informative, 1 Low, 2 Medium, 3 Serious, 4 Very serious
[-owner <owner>] : Free text
[-desc <description>] : Free text
[-type <ticket_type>] : Type ID (must exist in Integria IMS)
[-inventory <inventory_id>] : Inventory ID (must exist in Integria IMS)
@ -94,6 +95,7 @@ sub tool_api_main () {
my $ticket_name = "";
my $group_id = -1;
my $ticket_priority = 0;
my $ticket_owner = '';
my $ticket_description = '';
my $ticket_type = '';
my $ticket_inventory = '';
@ -155,6 +157,9 @@ sub tool_api_main () {
if ($line eq '-priority') {
$ticket_priority = $ARGV[$i + 1];
}
if ($line eq '-owner') {
$ticket_owner = $ARGV[$i + 1];
}
if ($line eq '-desc') {
$ticket_description = $ARGV[$i + 1];
}
@ -193,6 +198,7 @@ sub tool_api_main () {
$data_ticket = $ticket_name .
"|;|" . $group_id .
"|;|" . $ticket_priority .
"|;|" . $ticket_owner .
"|;|" . $ticket_description .
"|;|" . $ticket_inventory .
"|;|" . $ticket_type .