$id_plugin]);
$preload = io_safe_output($description);
$preload = str_replace("\n", '
', $preload);
echo $preload;
return;
}
if ($get_list_modules_and_component_locked_plugin) {
$id_plugin = (int) get_parameter('id_plugin', 0);
$network_components = db_get_all_rows_filter(
'tnetwork_component',
['id_plugin' => $id_plugin]
);
if (empty($network_components)) {
$network_components = [];
}
$modules = db_get_all_rows_filter(
'tagente_modulo',
[
'delete_pending' => 0,
'id_plugin' => $id_plugin,
]
);
if (empty($modules)) {
$modules = [];
}
$table = new stdClass();
$table->width = '100%';
$table->head[0] = __('Network Components');
$table->data = [];
foreach ($network_components as $net_comp) {
$table->data[] = [$net_comp['name']];
}
if (!empty($table->data)) {
html_print_table($table);
echo '
';
}
$table = new stdClass();
$table->width = '100%';
$table->head[0] = __('Agent');
$table->head[1] = __('Module');
foreach ($modules as $mod) {
$agent_name = ''.modules_get_agentmodule_agent_alias(
$mod['id_agente_modulo']
).'';
$table->data[] = [
$agent_name,
$mod['nombre'],
];
}
if (!empty($table->data)) {
html_print_table($table);
}
return;
}
}
require_once $config['homedir'].'/include/functions_filemanager.php';
check_login();
if (! check_acl($config['id_user'], 0, 'PM') && ! check_acl($config['id_user'], 0, 'AW')) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Plugin Management'
);
include 'general/noaccess.php';
return;
}
enterprise_include_once('meta/include/functions_components_meta.php');
$view = get_parameter('view', '');
$create = get_parameter('create', '');
$filemanager = (bool) get_parameter('filemanager', false);
$edit_file = get_parameter('edit_file', false);
$update_file = get_parameter('update_file', false);
$plugin_command = get_parameter('plugin_command', '');
$tab = get_parameter('tab', '');
if ($view != '') {
$form_id = $view;
$plugin = db_get_row('tplugin', 'id', $form_id);
$form_name = $plugin['name'];
$form_description = $plugin['description'];
$form_max_timeout = $plugin['max_timeout'];
$form_max_retries = $plugin['max_retries'];
if (empty($plugin_command)) {
$form_execute = $plugin['execute'];
} else {
$form_execute = $plugin_command;
}
$form_plugin_type = $plugin['plugin_type'];
$macros = $plugin['macros'];
$parameters = $plugin['parameters'];
}
if ($create != '') {
$form_id = 0;
$form_name = '';
$form_description = '';
$form_max_timeout = 15;
$form_max_retries = 1;
$form_execute = $plugin_command;
$form_plugin_type = 0;
$form_parameters = '';
$macros = '';
$parameters = '';
}
// END LOAD VALUES
// =====================================================================
// INIT FILEMANAGER
// =====================================================================
if ($filemanager) {
if ($edit_file) {
$location_file = get_parameter('location_file', '');
$filename = array_pop(explode('/', $location_file));
$file = file_get_contents($location_file);
echo '
'.__('Edit file').' '.$filename.'
';
// echo "" . __('Back to file explorer') . "";
echo "';
} else {
if ($update_file) {
$location_file = get_parameter('location_file', '');
$contentFile = io_safe_output(get_parameter('content_file', ''));
$compatibility = get_parameter('compatibility', 'unix');
$is_win_compatible = strpos($contentFile, "\r\n");
// If is win compatible and the compatibility must be unix
if ($is_win_compatible !== false && $compatibility == 'unix') {
$contentFile = str_replace("\r\n", "\n", $contentFile);
} else if ($is_win_compatible === false && $compatibility == 'windows') {
// If is unix compatible and the compatibility must be win
$contentFile = str_replace("\n", "\r\n", $contentFile);
}
$result = file_put_contents($location_file, $contentFile);
}
$id_plugin = (int) get_parameter('id_plugin', 0);
// Add custom directories here.
$fallback_directory = 'attachment/plugin';
// Get directory.
$directory = (string) get_parameter('directory');
if (empty($directory) === true) {
$directory = $fallback_directory;
} else {
$directory = str_replace('\\', '/', $directory);
$directory = filemanager_safe_directory($directory, $fallback_directory);
}
$real_directory = realpath($config['homedir'].'/'.$directory);
echo ''.__('Index of %s', $directory).'
';
$chunck_url = '&view='.$id_plugin;
if ($id_plugin == 0) {
$chunck_url = '&create=1';
}
$upload_file_or_zip = (bool) get_parameter('upload_file_or_zip');
$create_text_file = (bool) get_parameter('create_text_file');
$default_real_directory = realpath($config['homedir'].'/'.$fallback_directory);
if ($upload_file_or_zip === true) {
upload_file($upload_file_or_zip, $default_real_directory, $real_directory);
}
if ($create_text_file === true) {
create_text_file($default_real_directory, $real_directory);
}
filemanager_file_explorer(
$real_directory,
$directory,
'index.php?sec=gservers&sec2=godmode/servers/plugin&filemanager=1&id_plugin='.$id_plugin,
$fallback_directory,
true,
false,
'index.php?sec=gservers&sec2=godmode/servers/plugin'.$chunck_url.'&plugin_command=[FILE_FULLPATH]&id_plugin='.$id_plugin,
true,
0775,
false,
['all' => true]
);
}
return;
}
// =====================================================================
// END FILEMANAGER
// =====================================================================
// =====================================================================
// SHOW THE FORM
// =====================================================================
$sec = 'gservers';
if (($create != '') || ($view != '')) {
enterprise_hook('open_meta_frame');
$management_allowed = is_management_allowed();
if (defined('METACONSOLE')) {
components_meta_print_header();
$sec = 'advanced';
if ($management_allowed === false) {
ui_print_warning_message(__('To manage plugin you must activate centralized management'));
}
} else {
if ($create != '') {
ui_print_page_header(
__('Plugin registration'),
'images/gm_servers.png',
false,
'',
true
);
} else {
ui_print_page_header(
__('Plugin update'),
'images/gm_servers.png',
false,
'',
true
);
}
if ($management_allowed === false) {
ui_print_warning_message(
__(
'This console is not manager of this environment,
please manage this feature from centralized manager console (Metaconsole).'
)
);
}
}
if ($create == '') {
$plugin_id = get_parameter('view', '');
echo "