AJAXMethods); } /** * Generates a JSON error. * * @param string $msg Error message. * * @return void */ public function error($msg) { echo json_encode( ['error' => $msg] ); } /** * Minor function to dump json message as ajax response. * * @param string $type Type: result || error. * @param string $msg Message. * @param boolean $delete Deletion messages. * * @return void */ private function ajaxMsg($type, $msg, $delete=false) { if ($type === 'error') { $msg_title = ($delete === true) ? 'Failed while removing' : 'Failed while saving'; } else { $msg_title = ($delete === true) ? 'Successfully deleted' : 'Successfully saved into keystore'; } echo json_encode( [ $type => __($msg_title).':
'.$msg ] ); exit; } /** * Initializes object and validates user access. * * @param string $ajax_controller Path of ajaxController, is the 'page' * variable sent in ajax calls. * * @return object */ public function __construct($ajax_controller) { global $config; // Check access. check_login(); if ((bool) check_acl($config['id_user'], 0, 'AR') === false) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access agent deploy wizard' ); if (is_ajax()) { echo json_encode(['error' => 'noaccess']); } else { include 'general/noaccess.php'; } exit; } $this->ajaxController = $ajax_controller; return $this; } /** * Prints inputs for modal "Deploy agents". * * @return void */ public function loadModal() { ob_start(); echo '
'; echo $this->getModalContent(); echo '
'; echo ob_get_clean(); } /** * Run AgentDeployWizard. * * @return void */ public function run() { global $config; if (check_acl($config['id_user'], 0, 'AR') === false) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access agent deploy.' ); include 'general/noaccess.php'; return; } ui_require_css_file('agent_deploy_wizard'); // Auxiliar div for agent deploy modal. echo ''; echo $this->loadJS(); } /** * Generates content of modal. * * @return string Modal content. */ public function getModalContent() { global $config; ob_start(); $inputs = []; // Container div for stepper. $stepper_container = html_print_div( [ 'id' => 'stepper_container', 'class' => 'stepper', ], true ); html_print_div( [ 'id' => 'modal_header', 'class' => 'margin-bottom-10', 'content' => $stepper_container, ] ); // Deploy configuration. $tableConfiguration = new stdClass(); $tableConfiguration->class = 'filter-table-adv w100p'; $tableConfiguration->data = []; $tableConfiguration->style = []; $tableConfiguration->cellclass = []; $tableConfiguration->colspan = []; $tableConfiguration->rowclass['os'] = 'margin-bottom-5'; $tableConfiguration->rowstyle['block2'] = 'display: flex; justify-content: space-between;'; $tableConfiguration->rowspan = []; $windows_label_img = html_print_image( '/images/windows-grey@svg.svg', true, ['class' => 'installer-title-icon main_menu_icon'] ); $windows_label = html_print_div( [ 'style' => 'display: flex;align-items: center; margin-top: 5px;margin-bottom: 5px;', 'content' => $windows_label_img.'Windows', ], true ); $linux_label_img = html_print_image( '/images/linux-grey@svg.svg', true, ['class' => 'installer-title-icon main_menu_icon'] ); $linux_label = html_print_div( [ 'style' => 'display: flex;align-items: center; margin-top: 5px;margin-bottom: 5px;', 'content' => $linux_label_img.'Unix / Linux', ], true ); $mac_label_img = html_print_image( '/images/apple-grey@svg.svg', true, ['class' => 'installer-title-icon main_menu_icon'] ); $mac_label = html_print_div( [ 'style' => 'display: flex;align-items: center; margin-top: 5px;margin-bottom: 5px;', 'content' => $mac_label_img.'Mac OS', ], true ); // Operating System switch buttons. $switchButtons = []; $switchButtons[] = html_print_radio_button_extended( 'os', 0, $windows_label, 0, false, '', '', true ); $switchButtons[] = html_print_radio_button_extended( 'os', 1, $linux_label, 0, false, '', '', true ); $switchButtons[] = html_print_radio_button_extended( 'os', 2, $mac_label, 0, false, '', '', true ); $sub_tip = ''.__('Please note that all OS must be 64-bit based architecture').''; $tableConfiguration->data['os'][] = html_print_label_input_block( __('Choose your OS'), html_print_div( [ 'id' => 'os_selector', 'class' => 'switch_radio_button custom-switch-radio-button', 'content' => implode('', $switchButtons), ], true ).$sub_tip ); $server_add_help_tip = ui_print_help_tip( __('Use your %s Data Server IP address here. It must be possible to establish a connection from the agent to port 41121/tcp of this address.', get_product_name()), true ); $tableConfiguration->data['block2'][0] = html_print_label_input_block( __('Server address').$server_add_help_tip, html_print_input_text( 'server_addr', $_SERVER['SERVER_ADDR'], '', 16, 100, true, false, true, '', 'w260px' ) ); $tableConfiguration->data['block2'][1] = html_print_label_input_block( __('Group'), html_print_select_groups( false, 'AR', false, 'group', $group, '', '', 0, true, false, true, 'w260px', false, '', '', false, 'id_grupo', false, false, false, '260px', false, true, ) ); echo '
'; echo '
'; if ($config['language'] === 'es') { $instructions_url = 'https://pandorafms.com/manual/es/documentation/pandorafms/installation/05_configuration_agents'; } else { $instructions_url = 'https://pandorafms.com/manual/en/documentation/pandorafms/installation/05_configuration_agents'; } $instructions_link = ''.__('view the following instructions').''; $more_info_link = html_print_div( [ 'id' => 'config_form_more_info', 'class' => 'warn-box', 'content' => __('If you need more information regarding agents').', '.$instructions_link, ], true ); $table_config = html_print_div( [ 'style' => 'flex: 1;', 'content' => html_print_table($tableConfiguration, true), ], true ); html_print_div( [ 'id' => 'config_form', 'class' => 'white_table_flex agent_details_col modal-content', 'content' => $table_config.$more_info_link, ] ); html_print_div( ['id' => 'footer_separator'] ); html_print_div( [ 'id' => 'config_buttonset', 'class' => 'ui-dialog-buttonset', 'content' => html_print_submit_button( __('Generate installer'), 'generate_installer', false, [], true, ), ] ); echo '
'; echo '
'; echo '
'; echo ''; html_print_div( [ 'id' => 'installer_buttonset', 'class' => 'flex-row', 'style' => '', 'content' => html_print_button( __('Change configuration'), 'change_configuration', false, '', ['class' => 'secondary'], true, ).html_print_button( __('Done'), 'done', false, '', ['style' => 'min-width: 0;'], true ), ] ); echo '
'; return ob_get_clean(); } /** * Loads JS content. * * @return string JS content. */ public function loadJS() { ob_start(); ui_require_javascript_file('stepper', 'include/javascript/', true); // Javascript content. ?>