2009-03-18 16:42:15 +01:00
< ? php
2021-02-12 11:28:13 +01:00
/**
* View for edit modules in Massive Operations
*
* @ category Configuration
* @ package Pandora FMS
* @ subpackage Massive Operations
* @ version 1.0 . 0
* @ license See below
*
* ______ ___ _______ _______ ________
* | __ \ .-----.--.--.--| |.-----.----.-----. | ___ | | | __ |
* | __ /| _ | | _ || _ | _ | _ | | ___ | | __ |
* | ___ | | ___ . _ | __ | __ | _____ || _____ | __ | | ___ . _ | | ___ | | __ | _ | __ | _______ |
*
* ============================================================================
* Copyright ( c ) 2005 - 2021 Artica Soluciones Tecnologicas
* Please see http :// pandorafms . org for full contribution list
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
* ============================================================================
*/
// Begin.
2019-02-06 17:00:15 +01:00
check_login ();
if ( ! check_acl ( $config [ 'id_user' ], 0 , 'AW' )) {
db_pandora_audit (
'ACL Violation' ,
'Trying to access massive module update'
);
include 'general/noaccess.php' ;
return ;
2009-03-18 16:42:15 +01:00
}
2019-02-06 17:00:15 +01:00
require_once 'include/functions_modules.php' ;
require_once $config [ 'homedir' ] . '/include/functions_agents.php' ;
require_once $config [ 'homedir' ] . '/include/functions_groups.php' ;
require_once $config [ 'homedir' ] . '/include/functions_users.php' ;
require_once $config [ 'homedir' ] . '/include/functions_categories.php' ;
2009-03-18 16:42:15 +01:00
2019-02-06 17:00:15 +01:00
$module_type = ( int ) get_parameter ( 'module_type' );
2009-09-09 12:39:24 +02:00
$idGroupMassive = ( int ) get_parameter ( 'id_group_massive' );
$idAgentMassive = ( int ) get_parameter ( 'id_agent_massive' );
$group_select = get_parameter ( 'groups_select' );
2010-10-04 17:58:05 +02:00
2019-02-06 17:00:15 +01:00
$module_name = get_parameter ( 'module_name' );
$agents_select = get_parameter ( 'agents' , []);
2010-10-04 17:58:05 +02:00
$agents_id = get_parameter ( 'id_agents' );
$modules_select = get_parameter ( 'module' );
$selection_mode = get_parameter ( 'selection_mode' , 'modules' );
2011-09-03 06:31:36 +02:00
$recursion = get_parameter ( 'recursion' );
2017-08-28 15:47:16 +02:00
$modules_selection_mode = get_parameter ( 'modules_selection_mode' );
2009-03-18 16:42:15 +01:00
2019-02-06 17:00:15 +01:00
$update = ( bool ) get_parameter_post ( 'update' );
2009-03-18 16:42:15 +01:00
2012-06-18 13:22:13 +02:00
if ( $update ) {
2019-02-06 17:00:15 +01:00
$agents_ = '' ;
2020-12-01 15:50:52 +01:00
$module_status = get_parameter ( 'status_module' );
2019-02-06 17:00:15 +01:00
if ( $selection_mode == 'modules' ) {
$agents_ = [];
2018-07-16 18:14:18 +02:00
2019-02-06 17:00:15 +01:00
$force = get_parameter ( 'force_type' , false );
2018-07-16 18:14:18 +02:00
2019-02-06 17:00:15 +01:00
if ( $agents_select == false ) {
$agents_select = [];
}
2018-12-24 08:59:23 +01:00
2019-02-06 17:00:15 +01:00
$agents_ = $agents_select ;
$modules_ = $module_name ;
} else if ( $selection_mode == 'agents' ) {
$force = get_parameter ( 'force_group' , false );
2018-07-16 18:14:18 +02:00
2019-02-06 17:00:15 +01:00
$agents_ = $agents_id ;
$modules_ = $modules_select ;
}
2018-12-24 08:59:23 +01:00
2019-02-06 17:00:15 +01:00
$success = 0 ;
$count = 0 ;
2018-12-24 08:59:23 +01:00
2019-02-06 17:00:15 +01:00
if ( $agents_ == false ) {
$agents_ = [];
}
2018-12-24 08:59:23 +01:00
2019-02-06 17:00:15 +01:00
// If the option to select all of one group or module type is checked
if ( $force ) {
if ( $force == 'type' ) {
$type_condition = '' ;
if ( $module_type != 0 ) {
$type_condition = " AND tam.id_tipo_modulo = $module_type " ;
}
2018-12-24 08:59:23 +01:00
2019-02-06 17:00:15 +01:00
$sql = " SELECT ta.id_agente
2015-07-06 11:49:48 +02:00
FROM tagente ta
INNER JOIN tagente_modulo tam
ON ta . id_agente = tam . id_agente
AND tam . delete_pending = 0
$type_condition
GROUP BY ta . id_agente " ;
2019-02-06 17:00:15 +01:00
$agents_ = db_get_all_rows_sql ( $sql );
if ( $agents_ === false ) {
$agents_ = [];
}
// Create an array of agent ids
$agents_ = extract_column ( $agents_ , 'id_agente' );
foreach ( $agents_ as $id_agent ) {
$filter = [
'id_agente' => $id_agent ,
'delete_pending' => 0 ,
];
if ( $module_type != 0 ) {
$filter [ 'id_tipo_modulo' ] = $module_type ;
}
$module_name = db_get_all_rows_filter ( 'tagente_modulo' , $filter , 'nombre' );
if ( $module_name === false ) {
$module_name = [];
}
foreach ( $module_name as $mod_name ) {
2020-11-18 16:48:49 +01:00
$result = process_manage_edit ( $mod_name [ 'nombre' ], $id_agent , $module_status , $modules_selection_mode );
2019-02-06 17:00:15 +01:00
$count ++ ;
$success += ( int ) $result ;
}
}
if ( $success == 0 ) {
$error_msg = __ ( 'Error updating the modules from a module type' );
}
} else if ( $force == 'group' ) {
$agents_ = array_keys ( agents_get_group_agents ( $group_select , false , 'none' ));
foreach ( $agents_ as $id_agent ) {
$filter = [
'id_agente' => $id_agent ,
'delete_pending' => 0 ,
];
$module_name = db_get_all_rows_filter ( 'tagente_modulo' , $filter , 'nombre' );
if ( $module_name === false ) {
$module_name = [];
}
foreach ( $module_name as $mod_name ) {
2020-11-18 16:48:49 +01:00
$result = process_manage_edit ( $mod_name [ 'nombre' ], $id_agent , $module_status , $modules_selection_mode );
2019-02-06 17:00:15 +01:00
$count ++ ;
$success += ( int ) $result ;
}
}
if ( $success == 0 ) {
$error_msg = __ ( 'Error updating the modules from an agent group' );
}
}
} else {
// Standard procedure.
foreach ( $agents_ as $agent_ ) {
if ( $modules_ == false ) {
$modules_ = [];
}
foreach ( $modules_ as $module_ ) {
2020-11-18 16:48:49 +01:00
$result = process_manage_edit ( $module_ , $agent_ , $module_status , $modules_selection_mode );
2019-02-06 17:00:15 +01:00
$count ++ ;
$success += ( int ) $result ;
}
}
if ( $success == 0 ) {
$error_msg = __ ( 'Error updating the modules (maybe there was no field to update)' );
}
}
ui_print_result_message (
$success > 0 ,
__ ( 'Successfully updated' ) . '(' . $success . '/' . $count . ')' ,
$error_msg
);
$info = '{"Modules":"' . implode ( ',' , $modules_ ) . '","Agents":"' . implode ( ',' , $agents_ ) . '"}' ;
if ( $success > 0 ) {
db_pandora_audit ( 'Massive management' , 'Edit module' , false , false , $info );
} else {
db_pandora_audit ( 'Massive management' , 'Fail try to edit module' , false , false , $info );
}
2009-03-18 16:42:15 +01:00
}
2018-11-02 10:18:33 +01:00
$table = new stdClass ();
2009-03-18 16:42:15 +01:00
$table -> id = 'delete_table' ;
2015-06-15 15:50:28 +02:00
$table -> class = 'databox filters' ;
$table -> width = '100%' ;
2019-02-06 17:00:15 +01:00
$table -> data = [];
$table -> style = [];
2015-06-15 15:50:28 +02:00
$table -> style [ 0 ] = 'font-weight: bold;' ;
2009-03-18 16:42:15 +01:00
$table -> style [ 2 ] = 'font-weight: bold' ;
2019-02-06 17:00:15 +01:00
$table -> rowstyle = [];
$table -> size = [];
2009-03-18 16:42:15 +01:00
$table -> size [ 0 ] = '15%' ;
2011-09-03 06:31:36 +02:00
$table -> size [ 1 ] = '35%' ;
2009-03-18 16:42:15 +01:00
$table -> size [ 2 ] = '15%' ;
$table -> size [ 3 ] = '35%' ;
2009-03-23 16:22:19 +01:00
if ( ! $module_type ) {
2019-02-06 17:00:15 +01:00
$table -> rowstyle [ 'edit1' ] = 'display: none' ;
$table -> rowstyle [ 'edit0' ] = 'display: none' ;
$table -> rowstyle [ 'edit1_1' ] = 'display: none' ;
$table -> rowstyle [ 'edit2' ] = 'display: none' ;
$table -> rowstyle [ 'edit3' ] = 'display: none' ;
$table -> rowstyle [ 'edit35' ] = 'display: none' ;
$table -> rowstyle [ 'edit4' ] = 'display: none' ;
$table -> rowstyle [ 'edit5' ] = 'display: none' ;
$table -> rowstyle [ 'edit6' ] = 'display: none' ;
$table -> rowstyle [ 'edit7' ] = 'display: none' ;
2009-03-23 16:22:19 +01:00
}
2019-02-06 17:00:15 +01:00
$agents = agents_get_group_agents (
array_keys ( users_get_groups ()),
false ,
'none'
);
switch ( $config [ 'dbtype' ]) {
case 'mysql' :
$module_types = db_get_all_rows_filter (
'tagente_modulo,ttipo_modulo' ,
[ 'tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo' ,
'id_agente' => array_keys ( $agents ),
'disabled' => 0 ,
'order' => 'ttipo_modulo.nombre'
],
[
'DISTINCT(id_tipo)' ,
'CONCAT(ttipo_modulo.descripcion," (",ttipo_modulo.nombre,")") AS description' ,
]
);
break ;
case 'oracle' :
$module_types = db_get_all_rows_filter (
'tagente_modulo,ttipo_modulo' ,
[ 'tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo' ,
'id_agente' => array_keys ( $agents ),
'disabled' => 0 ,
'order' => 'ttipo_modulo.nombre'
],
[
'id_tipo' ,
'ttipo_modulo.descripcion || \' (\' || ttipo_modulo.nombre || \')\' AS description' ,
]
);
break ;
case 'postgresql' :
$module_types = db_get_all_rows_filter (
'tagente_modulo,ttipo_modulo' ,
[ 'tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo' ,
'id_agente' => array_keys ( $agents ),
'disabled' => 0 ,
'order' => 'description'
],
[
'DISTINCT(id_tipo)' ,
'ttipo_modulo.descripcion || \' (\' || ttipo_modulo.nombre || \')\' AS description' ,
]
);
break ;
2012-04-08 14:43:18 +02:00
}
2009-03-23 16:22:19 +01:00
2019-02-06 17:00:15 +01:00
if ( $module_types === false ) {
$module_types = [];
}
2009-03-23 16:22:19 +01:00
2019-02-06 17:00:15 +01:00
$types = [];
2009-03-23 16:22:19 +01:00
foreach ( $module_types as $type ) {
2019-02-06 17:00:15 +01:00
$types [ $type [ 'id_tipo' ]] = $type [ 'description' ];
2009-03-18 16:42:15 +01:00
}
2011-04-14 16:51:46 +02:00
$snmp_versions [ '1' ] = 'v. 1' ;
$snmp_versions [ '2' ] = 'v. 2' ;
$snmp_versions [ '2c' ] = 'v. 2c' ;
$snmp_versions [ '3' ] = 'v. 3' ;
2015-04-10 09:43:44 +02:00
$table -> width = '100%' ;
2019-02-06 17:00:15 +01:00
$table -> data = [];
2012-08-22 16:09:05 +02:00
2014-03-25 13:39:26 +01:00
$table -> data [ 'selection_mode' ][ 0 ] = __ ( 'Selection mode' );
2021-03-11 15:40:23 +01:00
$table -> data [ 'selection_mode' ][ 1 ] = '<span class="massive_span">' . __ ( 'Select modules first ' ) . '</span>' . html_print_radio_button_extended ( 'selection_mode' , 'modules' , '' , $selection_mode , false , '' , 'class="mrgn_right_40px"' , true ) . '<br>' ;
$table -> data [ 'selection_mode' ][ 1 ] .= '<span class="massive_span">' . __ ( 'Select agents first ' ) . '</span>' . html_print_radio_button_extended ( 'selection_mode' , 'agents' , '' , $selection_mode , false , '' , 'class="mrgn_right_40px"' , true );
2014-03-25 13:39:26 +01:00
$table -> rowclass [ 'form_modules_1' ] = 'select_modules_row' ;
$table -> data [ 'form_modules_1' ][ 0 ] = __ ( 'Module type' );
2018-11-02 10:18:33 +01:00
2010-10-04 17:58:05 +02:00
$types [ 0 ] = __ ( 'All' );
2014-03-25 13:39:26 +01:00
$table -> colspan [ 'form_modules_1' ][ 1 ] = 2 ;
2019-02-06 17:00:15 +01:00
$table -> data [ 'form_modules_1' ][ 1 ] = html_print_select (
$types ,
'module_type' ,
'' ,
false ,
__ ( 'Select' ),
- 1 ,
true ,
false ,
true
);
$table -> data [ 'form_modules_1' ][ 3 ] = __ ( 'Select all modules of this type' ) . ' ' . html_print_checkbox_extended (
'force_type' ,
'type' ,
'' ,
'' ,
false ,
2021-03-11 15:40:23 +01:00
'class="mrgn_right_40px"' ,
2019-02-06 17:00:15 +01:00
true ,
''
);
$modules = [];
2009-03-23 16:22:19 +01:00
if ( $module_type != '' ) {
2019-02-06 17:00:15 +01:00
$filter = [ 'id_tipo_modulo' => $module_type ];
} else {
$filter = false ;
2009-09-08 17:38:43 +02:00
}
2018-10-03 13:02:51 +02:00
2019-02-06 17:00:15 +01:00
$names = agents_get_modules (
array_keys ( $agents ),
'tagente_modulo.nombre' ,
$filter ,
false
);
2009-09-08 17:38:43 +02:00
foreach ( $names as $name ) {
2019-02-06 17:00:15 +01:00
$modules [ $name [ 'nombre' ]] = $name [ 'nombre' ];
2009-03-23 16:22:19 +01:00
}
2009-09-08 17:38:43 +02:00
2014-03-25 13:39:26 +01:00
$table -> rowclass [ 'form_agents_1' ] = 'select_agents_row' ;
$table -> data [ 'form_agents_1' ][ 0 ] = __ ( 'Agent group' );
2011-04-27 15:43:31 +02:00
$groups = groups_get_all ( true );
2010-10-04 17:58:05 +02:00
$groups [ 0 ] = __ ( 'All' );
2014-03-25 13:39:26 +01:00
$table -> colspan [ 'form_agents_1' ][ 1 ] = 2 ;
2019-02-06 17:00:15 +01:00
$table -> data [ 'form_agents_1' ][ 1 ] = html_print_select_groups (
false ,
'AW' ,
true ,
'groups_select' ,
'' ,
false ,
'' ,
'' ,
true
) . ' ' . __ ( 'Group recursion' ) . ' ' . html_print_checkbox ( 'recursion' , 1 , false , true , false );
$table -> data [ 'form_agents_1' ][ 3 ] = __ ( 'Select all modules of this group' ) . ' ' . html_print_checkbox_extended (
'force_group' ,
'group' ,
'' ,
'' ,
false ,
'' ,
2021-03-11 15:40:23 +01:00
'class="mrgn_right_40px"'
2019-02-06 17:00:15 +01:00
);
2014-03-25 13:39:26 +01:00
2016-11-17 12:55:29 +01:00
$table -> rowclass [ 'form_modules_3' ] = '' ;
$table -> data [ 'form_modules_3' ][ 0 ] = __ ( 'Module Status' );
$table -> colspan [ 'form_modules_3' ][ 1 ] = 2 ;
2019-02-06 17:00:15 +01:00
$status_list = [];
2016-11-17 12:55:29 +01:00
$status_list [ AGENT_MODULE_STATUS_NORMAL ] = __ ( 'Normal' );
$status_list [ AGENT_MODULE_STATUS_WARNING ] = __ ( 'Warning' );
$status_list [ AGENT_MODULE_STATUS_CRITICAL_BAD ] = __ ( 'Critical' );
$status_list [ AGENT_MODULE_STATUS_UNKNOWN ] = __ ( 'Unknown' );
$status_list [ AGENT_MODULE_STATUS_NOT_NORMAL ] = __ ( 'Not normal' );
$status_list [ AGENT_MODULE_STATUS_NOT_INIT ] = __ ( 'Not init' );
2019-02-06 17:00:15 +01:00
$table -> data [ 'form_modules_3' ][ 1 ] = html_print_select (
$status_list ,
'status_module' ,
'selected' ,
'' ,
__ ( 'All' ),
AGENT_MODULE_STATUS_ALL ,
true
);
2016-11-17 12:55:29 +01:00
$table -> data [ 'form_modules_3' ][ 3 ] = '' ;
2014-03-25 13:39:26 +01:00
2017-05-16 16:37:48 +02:00
$tags = tags_get_user_tags ();
$table -> rowstyle [ 'form_modules_4' ] = 'vertical-align: top;' ;
$table -> rowclass [ 'form_modules_4' ] = 'select_modules_row select_modules_row_2' ;
$table -> data [ 'form_modules_4' ][ 0 ] = __ ( 'Tags' );
2019-02-06 17:00:15 +01:00
$table -> data [ 'form_modules_4' ][ 1 ] = html_print_select (
$tags ,
'tags[]' ,
$tags_name ,
false ,
__ ( 'Any' ),
- 1 ,
true ,
true ,
true
);
2017-05-16 16:37:48 +02:00
2019-06-19 17:36:55 +02:00
$table -> rowstyle [ 'form_modules_filter' ] = 'vertical-align: top;' ;
$table -> rowclass [ 'form_modules_filter' ] = 'select_modules_row select_modules_row_2' ;
$table -> data [ 'form_modules_filter' ][ 0 ] = __ ( 'Filter Modules' );
$table -> data [ 'form_modules_filter' ][ 1 ] = html_print_input_text ( 'filter_modules' , '' , '' , 20 , 255 , true );
2014-03-25 13:39:26 +01:00
$table -> rowstyle [ 'form_modules_2' ] = 'vertical-align: top;' ;
$table -> rowclass [ 'form_modules_2' ] = 'select_modules_row select_modules_row_2' ;
$table -> data [ 'form_modules_2' ][ 0 ] = __ ( 'Modules' );
2019-02-06 17:00:15 +01:00
$table -> data [ 'form_modules_2' ][ 1 ] = html_print_select (
$modules ,
'module_name[]' ,
$module_name ,
false ,
__ ( 'Select' ),
- 1 ,
true ,
true ,
true
2020-09-11 14:35:32 +02:00
) . ' ' . __ ( 'Select all modules' ) . ' ' . html_print_checkbox ( 'select_all_modules' , 1 , false , true , false , '' , false , " class='static' " );
2014-03-25 13:39:26 +01:00
$table -> data [ 'form_modules_2' ][ 2 ] = __ ( 'When select modules' );
$table -> data [ 'form_modules_2' ][ 2 ] .= '<br>' ;
2019-02-06 17:00:15 +01:00
$table -> data [ 'form_modules_2' ][ 2 ] .= html_print_select (
[
'common' => __ ( 'Show common agents' ),
'all' => __ ( 'Show all agents' ),
],
'agents_selection_mode' ,
'common' ,
false ,
'' ,
'' ,
true
);
$table -> data [ 'form_modules_2' ][ 3 ] = html_print_select (
[],
'agents[]' ,
$agents_select ,
false ,
__ ( 'None' ),
0 ,
true ,
true ,
false
);
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* install.php, operation/reporting/reporting_xml.php,
operation/netflow/nf_live_view.php, operation/netflow/nf_view.php,
operation/tree.php, operation/agentes/gis_view.php,
operation/agentes/estado_monitores.php,
operation/agentes/networkmap.php,
operation/agentes/datos_agente.php,
operation/agentes/alerts_status.php, operation/menu.php,
operation/snmpconsole/snmp_view.php, operation/users/user_edit.php,
godmode/groups/configure_group.php,
godmode/groups/configure_modu_group.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/servers/manage_recontask.php,
godmode/alerts/alert_compounds.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_special_days.php, godmode/setup/links.php,
godmode/setup/os.php, godmode/users/configure_profile.php,
godmode/events/events.php,
godmode/massive/massive_delete_modules.php,
godmode/massive/massive_edit_modules.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_add_action_alerts.php,
godmode/massive/massive_enable_disable_alerts.php,
godmode/massive/massive_operations.php,
godmode/massive/massive_delete_profiles.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php,
godmode/reporting/graph_builder.php,
godmode/reporting/reporting_builder.item_editor.php,
include/functions_menu.php, include/functions_visual_map.php,
include/functions_db.php: cleaned source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6759 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-10 12:38:02 +02:00
2014-03-25 13:39:26 +01:00
$table -> rowclass [ 'form_agents_2' ] = 'select_agents_row' ;
2016-11-17 12:55:29 +01:00
$table -> data [ 'form_agents_2' ][ 0 ] = __ ( 'Agent Status' );
2014-03-25 13:39:26 +01:00
$table -> colspan [ 'form_agents_2' ][ 1 ] = 2 ;
2019-02-06 17:00:15 +01:00
$status_list = [];
2015-06-08 13:13:09 +02:00
$status_list [ AGENT_STATUS_NORMAL ] = __ ( 'Normal' );
2014-03-25 13:39:26 +01:00
$status_list [ AGENT_STATUS_WARNING ] = __ ( 'Warning' );
$status_list [ AGENT_STATUS_CRITICAL ] = __ ( 'Critical' );
$status_list [ AGENT_STATUS_UNKNOWN ] = __ ( 'Unknown' );
2015-06-08 13:13:09 +02:00
$status_list [ AGENT_STATUS_NOT_NORMAL ] = __ ( 'Not normal' );
2014-03-25 13:39:26 +01:00
$status_list [ AGENT_STATUS_NOT_INIT ] = __ ( 'Not init' );
2019-02-06 17:00:15 +01:00
$table -> data [ 'form_agents_2' ][ 1 ] = html_print_select (
$status_list ,
'status_agents' ,
'selected' ,
'' ,
__ ( 'All' ),
AGENT_STATUS_ALL ,
true
);
2014-03-25 13:39:26 +01:00
$table -> data [ 'form_agents_2' ][ 3 ] = '' ;
2017-05-17 10:41:30 +02:00
$tags = tags_get_user_tags ();
$table -> rowstyle [ 'form_agents_4' ] = 'vertical-align: top;' ;
$table -> rowclass [ 'form_agents_4' ] = 'select_agents_row select_agents_row_2' ;
$table -> data [ 'form_agents_4' ][ 0 ] = __ ( 'Tags' );
2019-02-06 17:00:15 +01:00
$table -> data [ 'form_agents_4' ][ 1 ] = html_print_select (
$tags ,
'tags[]' ,
$tags_name ,
false ,
__ ( 'Any' ),
- 1 ,
true ,
true ,
true
);
2014-03-25 13:39:26 +01:00
2019-07-08 17:57:23 +02:00
$table -> rowstyle [ 'form_agents_filter' ] = 'vertical-align: top;' ;
$table -> rowclass [ 'form_agents_filter' ] = 'select_agents_row select_agents_row_2' ;
$table -> data [ 'form_agents_filter' ][ 0 ] = __ ( 'Filter agents' );
$table -> data [ 'form_agents_filter' ][ 1 ] = html_print_input_text ( 'filter_agents' , '' , '' , 20 , 255 , true );
2014-03-25 13:39:26 +01:00
$table -> rowstyle [ 'form_agents_3' ] = 'vertical-align: top;' ;
$table -> rowclass [ 'form_agents_3' ] = 'select_agents_row select_agents_row_2' ;
$table -> data [ 'form_agents_3' ][ 0 ] = __ ( 'Agents' );
2019-02-06 17:00:15 +01:00
$table -> data [ 'form_agents_3' ][ 1 ] = html_print_select (
$agents ,
'id_agents[]' ,
$agents_id ,
false ,
'' ,
'' ,
true ,
true ,
false
2020-09-11 14:35:32 +02:00
) . ' ' . __ ( 'Select all agents' ) . ' ' . html_print_checkbox ( 'select_all_agents' , 1 , false , true , false , '' , false , " class='static' " );
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* install.php, operation/reporting/reporting_xml.php,
operation/netflow/nf_live_view.php, operation/netflow/nf_view.php,
operation/tree.php, operation/agentes/gis_view.php,
operation/agentes/estado_monitores.php,
operation/agentes/networkmap.php,
operation/agentes/datos_agente.php,
operation/agentes/alerts_status.php, operation/menu.php,
operation/snmpconsole/snmp_view.php, operation/users/user_edit.php,
godmode/groups/configure_group.php,
godmode/groups/configure_modu_group.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/servers/manage_recontask.php,
godmode/alerts/alert_compounds.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_special_days.php, godmode/setup/links.php,
godmode/setup/os.php, godmode/users/configure_profile.php,
godmode/events/events.php,
godmode/massive/massive_delete_modules.php,
godmode/massive/massive_edit_modules.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_add_action_alerts.php,
godmode/massive/massive_enable_disable_alerts.php,
godmode/massive/massive_operations.php,
godmode/massive/massive_delete_profiles.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php,
godmode/reporting/graph_builder.php,
godmode/reporting/reporting_builder.item_editor.php,
include/functions_menu.php, include/functions_visual_map.php,
include/functions_db.php: cleaned source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6759 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-10 12:38:02 +02:00
2014-03-25 13:39:26 +01:00
$table -> data [ 'form_agents_3' ][ 2 ] = __ ( 'When select agents' );
$table -> data [ 'form_agents_3' ][ 2 ] .= '<br>' ;
2019-02-06 17:00:15 +01:00
$table -> data [ 'form_agents_3' ][ 2 ] .= html_print_select (
[
'common' => __ ( 'Show common modules' ),
'all' => __ ( 'Show all modules' ),
'unknown' => __ ( 'Show unknown and not init modules' ),
],
'modules_selection_mode' ,
'common' ,
false ,
'' ,
'' ,
true
);
$table -> data [ 'form_agents_3' ][ 3 ] = html_print_select (
[],
'module[]' ,
$modules_select ,
false ,
'' ,
'' ,
true ,
true ,
false
);
2009-09-09 12:39:24 +02:00
2016-10-14 10:16:21 +02:00
$table -> data [ 'edit0' ][ 0 ] = __ ( 'Dynamic Interval' );
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit0' ][ 1 ] = html_print_extended_select_for_time ( 'dynamic_interval' , '' , '' , 'None' , '0' , 10 , true , 'width:150px' , false );
$table -> data [ 'edit0' ][ 2 ] = '<table width="100%"><tr><td><em>' . __ ( 'Dynamic Min.' ) . '</em></td>' ;
$table -> data [ 'edit0' ][ 2 ] .= '<td align="right">' . html_print_input_text ( 'dynamic_min' , '' , '' , 10 , 255 , true ) . '</td></tr>' ;
$table -> data [ 'edit0' ][ 2 ] .= '<tr><td><em>' . __ ( 'Dynamic Max.' ) . '</em></td>' ;
$table -> data [ 'edit0' ][ 2 ] .= '<td align="right">' . html_print_input_text ( 'dynamic_max' , '' , '' , 10 , 255 , true ) . '</td></tr></table>' ;
2016-10-14 10:16:21 +02:00
$table -> data [ 'edit0' ][ 3 ] = __ ( 'Dynamic Two Tailed: ' );
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit0' ][ 3 ] .= html_print_checkbox ( 'dynamic_two_tailed' , 1 , '' , true );
2014-03-25 13:39:26 +01:00
2009-03-18 16:42:15 +01:00
$table -> data [ 'edit1' ][ 0 ] = __ ( 'Warning status' );
2013-02-25 11:29:52 +01:00
$table -> data [ 'edit1' ][ 1 ] = '<table width="100%">' ;
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit1' ][ 1 ] .= " <tr id='edit1-1-min'> " ;
$table -> data [ 'edit1' ][ 1 ] .= '<td>' ;
$table -> data [ 'edit1' ][ 1 ] .= '<em>' . __ ( 'Min.' ) . '</em>' ;
$table -> data [ 'edit1' ][ 1 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 1 ] .= '<td align="right">' ;
$table -> data [ 'edit1' ][ 1 ] .= html_print_input_text (
'min_warning' ,
'' ,
'' ,
5 ,
255 ,
true
);
$table -> data [ 'edit1' ][ 1 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 1 ] .= '</tr>' ;
$table -> data [ 'edit1' ][ 1 ] .= " <tr id='edit1-1-max'> " ;
$table -> data [ 'edit1' ][ 1 ] .= '<td>' ;
$table -> data [ 'edit1' ][ 1 ] .= '<em>' . __ ( 'Max.' ) . '</em>' ;
$table -> data [ 'edit1' ][ 1 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 1 ] .= '<td align="right">' ;
$table -> data [ 'edit1' ][ 1 ] .= html_print_input_text (
'max_warning' ,
'' ,
'' ,
5 ,
255 ,
true
);
$table -> data [ 'edit1' ][ 1 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 1 ] .= '</tr>' ;
$table -> data [ 'edit1' ][ 1 ] .= " <tr id='edit1-1-str'> " ;
$table -> data [ 'edit1' ][ 1 ] .= '<td>' ;
$table -> data [ 'edit1' ][ 1 ] .= '<em>' . __ ( 'Str.' ) . '</em>' ;
$table -> data [ 'edit1' ][ 1 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 1 ] .= '<td align="right">' ;
$table -> data [ 'edit1' ][ 1 ] .= html_print_input_text (
'str_warning' ,
'' ,
'' ,
5 ,
2019-03-01 13:36:38 +01:00
1024 ,
2019-02-06 17:00:15 +01:00
true
);
$table -> data [ 'edit1' ][ 1 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 1 ] .= '</tr>' ;
$table -> data [ 'edit1' ][ 1 ] .= '<tr>' ;
$table -> data [ 'edit1' ][ 1 ] .= '<td>' ;
$table -> data [ 'edit1' ][ 1 ] .= '<em>' . __ ( 'Inverse interval' ) . '</em>' ;
$table -> data [ 'edit1' ][ 1 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 1 ] .= '<td align="right">' ;
$table -> data [ 'edit1' ][ 1 ] .= html_print_select (
[
'' => __ ( 'No change' ),
'1' => __ ( 'Yes' ),
'0' => __ ( 'No' ),
],
'warning_inverse' ,
'' ,
'' ,
'' ,
'' ,
true
);
$table -> data [ 'edit1' ][ 1 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 1 ] .= '</tr>' ;
$table -> data [ 'edit1' ][ 1 ] .= '</table>' ;
$table -> data [ 'edit1' ][ 2 ] = __ ( 'Critical status' );
$table -> data [ 'edit1' ][ 3 ] = '<table width="100%">' ;
$table -> data [ 'edit1' ][ 3 ] .= " <tr id='edit1-3-min'> " ;
$table -> data [ 'edit1' ][ 3 ] .= '<td>' ;
$table -> data [ 'edit1' ][ 3 ] .= '<em>' . __ ( 'Min.' ) . '</em>' ;
$table -> data [ 'edit1' ][ 3 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 3 ] .= '<td align="right">' ;
$table -> data [ 'edit1' ][ 3 ] .= html_print_input_text (
'min_critical' ,
'' ,
'' ,
5 ,
255 ,
true
);
$table -> data [ 'edit1' ][ 3 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 3 ] .= '</tr>' ;
$table -> data [ 'edit1' ][ 3 ] .= " <tr id='edit1-3-max'> " ;
$table -> data [ 'edit1' ][ 3 ] .= '<td>' ;
$table -> data [ 'edit1' ][ 3 ] .= '<em>' . __ ( 'Max.' ) . '</em>' ;
$table -> data [ 'edit1' ][ 3 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 3 ] .= '<td align="right">' ;
$table -> data [ 'edit1' ][ 3 ] .= html_print_input_text (
'max_critical' ,
'' ,
'' ,
5 ,
255 ,
true
);
$table -> data [ 'edit1' ][ 3 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 3 ] .= '</tr>' ;
$table -> data [ 'edit1' ][ 3 ] .= " <tr id='edit1-3-str'> " ;
$table -> data [ 'edit1' ][ 3 ] .= '<td>' ;
$table -> data [ 'edit1' ][ 3 ] .= '<em>' . __ ( 'Str.' ) . '</em>' ;
$table -> data [ 'edit1' ][ 3 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 3 ] .= '<td align="right">' ;
$table -> data [ 'edit1' ][ 3 ] .= html_print_input_text (
'str_critical' ,
'' ,
'' ,
5 ,
2019-03-01 13:36:38 +01:00
1024 ,
2019-02-06 17:00:15 +01:00
true
);
$table -> data [ 'edit1' ][ 3 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 3 ] .= '</tr>' ;
$table -> data [ 'edit1' ][ 3 ] .= '<tr>' ;
$table -> data [ 'edit1' ][ 3 ] .= '<td>' ;
$table -> data [ 'edit1' ][ 3 ] .= '<em>' . __ ( 'Inverse interval' ) . '</em>' ;
$table -> data [ 'edit1' ][ 3 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 3 ] .= '<td align="right">' ;
$table -> data [ 'edit1' ][ 3 ] .= html_print_select (
[
'' => __ ( 'No change' ),
'1' => __ ( 'Yes' ),
'0' => __ ( 'No' ),
],
'critical_inverse' ,
'' ,
'' ,
'' ,
'' ,
true
);
$table -> data [ 'edit1' ][ 3 ] .= '</td>' ;
$table -> data [ 'edit1' ][ 3 ] .= '</tr>' ;
$table -> data [ 'edit1' ][ 3 ] .= '</table>' ;
$table -> data [ 'edit1_1' ][ 0 ] = '<b>' . __ ( 'Description' ) . '</b>' ;
$table -> data [ 'edit1_1' ][ 1 ] = html_print_textarea (
'descripcion' ,
2 ,
50 ,
'' ,
'' ,
true
);
$table -> colspan [ 'edit1_1' ][ 1 ] = 3 ;
$table -> data [ 'edit2' ][ 0 ] = __ ( 'Interval' );
$table -> data [ 'edit2' ][ 1 ] = html_print_extended_select_for_time (
'module_interval' ,
0 ,
'' ,
__ ( 'No change' ),
'0' ,
10 ,
true ,
'width: 150px'
);
$table -> data [ 'edit2' ][ 2 ] = __ ( 'Disabled' );
$table -> data [ 'edit2' ][ 3 ] = html_print_select (
[
'' => __ ( 'No change' ),
'1' => __ ( 'Yes' ),
'0' => __ ( 'No' ),
],
'disabled' ,
'' ,
'' ,
'' ,
'' ,
true
);
2019-05-24 14:26:28 +02:00
$table -> data [ 'edit3' ][ 0 ] = __ ( 'Post process' );
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit3' ][ 1 ] = html_print_extended_select_for_post_process (
'post_process' ,
- 1 ,
'' ,
'' ,
0 ,
false ,
true ,
'width:150px;' ,
true ,
false ,
1
);
$table -> data [ 'edit3' ][ 2 ] = __ ( 'SMNP community' );
$table -> data [ 'edit3' ][ 3 ] = html_print_input_text (
'snmp_community' ,
'' ,
'' ,
10 ,
100 ,
true
);
$table -> data [ 'edit15' ][ 2 ] = __ ( 'SNMP OID' );
$table -> data [ 'edit15' ][ 3 ] = html_print_input_text (
'snmp_oid' ,
'' ,
'' ,
80 ,
80 ,
true
);
$target_ip_values = [];
$target_ip_values [ 'auto' ] = __ ( 'Auto' );
$target_ip_values [ 'force_pri' ] = __ ( 'Force primary key' );
$target_ip_values [ 'custom' ] = __ ( 'Custom' );
$table -> data [ 'edit35' ][ 0 ] = __ ( 'Target IP' );
$table -> data [ 'edit35' ][ 1 ] = html_print_select (
$target_ip_values ,
'ip_target' ,
'' ,
'' ,
__ ( 'No change' ),
'' ,
true ,
false ,
false ,
'' ,
false ,
'width:200px;'
);
$table -> data [ 'edit35' ][ 1 ] .= html_print_input_text ( 'custom_ip_target' , '' , '' , 15 , 60 , true );
$table -> data [ 'edit35' ][ 2 ] = __ ( 'SNMP version' );
$table -> data [ 'edit35' ][ 3 ] = html_print_select (
$snmp_versions ,
2020-09-01 17:39:25 +02:00
'snmp_version' ,
2019-02-06 17:00:15 +01:00
'' ,
'' ,
__ ( 'No change' ),
'' ,
true ,
false ,
false ,
''
);
$table -> data [ 'edit36' ][ 0 ] = __ ( 'Auth user' );
$table -> data [ 'edit36' ][ 1 ] = html_print_input_text (
'plugin_user_snmp' ,
'' ,
'' ,
15 ,
60 ,
true
);
$table -> data [ 'edit36' ][ 2 ] = __ ( 'Auth password' ) . ui_print_help_tip ( __ ( 'The pass length must be eight character minimum.' ), true );
2021-03-16 17:41:54 +01:00
$table -> data [ 'edit36' ][ 3 ] = html_print_input_password ( 'plugin_pass_snmp' , '' , '' , 15 , 60 , true );
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit37' ][ 0 ] = __ ( 'Privacy method' );
2021-03-16 17:41:54 +01:00
$table -> data [ 'edit37' ][ 1 ] = html_print_select ([ 'DES' => __ ( 'DES' ), 'AES' => __ ( 'AES' )], 'snmp3_privacy_method' , '' , '' , __ ( 'No change' ), '' , true );
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit37' ][ 2 ] = __ ( 'Privacy pass' ) . ui_print_help_tip ( __ ( 'The pass length must be eight character minimum.' ), true );
2021-03-16 17:41:54 +01:00
$table -> data [ 'edit37' ][ 3 ] = html_print_input_password ( 'snmp3_privacy_pass' , '' , '' , 15 , 60 , true );
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit38' ][ 0 ] = __ ( 'Auth method' );
$table -> data [ 'edit38' ][ 1 ] = html_print_select ([ 'MD5' => __ ( 'MD5' ), 'SHA' => __ ( 'SHA' )], 'plugin_parameter' , '' , '' , __ ( 'No change' ), '' , true );
$table -> data [ 'edit38' ][ 2 ] = __ ( 'Security level' );
$table -> data [ 'edit38' ][ 3 ] = html_print_select (
[
'noAuthNoPriv' => __ ( 'Not auth and not privacy method' ),
'authNoPriv' => __ ( 'Auth and not privacy method' ),
'authPriv' => __ ( 'Auth and privacy method' ),
],
'custom_string_3' ,
'' ,
'' ,
__ ( 'No change' ),
'' ,
true
);
$table -> data [ 'edit4' ][ 0 ] = __ ( 'Value' );
$table -> data [ 'edit4' ][ 1 ] = '<em>' . __ ( 'Min.' ) . '</em>' ;
$table -> data [ 'edit4' ][ 1 ] .= html_print_input_text ( 'min' , '' , '' , 5 , 15 , true );
$table -> data [ 'edit4' ][ 1 ] .= '<br /><em>' . __ ( 'Max.' ) . '</em>' ;
$table -> data [ 'edit4' ][ 1 ] .= html_print_input_text ( 'max' , '' , '' , 5 , 15 , true );
$table -> data [ 'edit4' ][ 2 ] = __ ( 'Module group' );
// Create module groups values for select
$module_groups = modules_get_modulegroups ();
$module_groups [ 0 ] = __ ( 'Not assigned' );
$table -> data [ 'edit4' ][ 3 ] = html_print_select (
$module_groups ,
'id_module_group' ,
'' ,
'' ,
__ ( 'No change' ),
'' ,
true ,
false ,
false
);
$table -> data [ 'edit5' ][ 0 ] = __ ( 'Username' );
$table -> data [ 'edit5' ][ 1 ] = html_print_input_text ( 'plugin_user' , '' , '' , 15 , 60 , true );
$table -> data [ 'edit5' ][ 2 ] = __ ( 'Password' );
$table -> data [ 'edit5' ][ 3 ] = html_print_input_password ( 'plugin_pass' , '' , '' , 15 , 60 , true );
// Export target
$table -> data [ 'edit6' ][ 0 ] = __ ( 'Export target' );
$targets2 = db_get_all_rows_sql ( 'SELECT id, name FROM tserver_export ORDER by name' );
if ( $targets2 === false ) {
$targets2 = [];
}
$targets = [];
$targets [ 0 ] = __ ( 'None' );
foreach ( $targets2 as $t ) {
$targets [ $t [ 'id' ]] = $t [ 'name' ];
}
$table -> data [ 'edit6' ][ 1 ] = html_print_select ( $targets , 'id_export' , '' , '' , __ ( 'No change' ), '' , true , false , false );
$table -> data [ 'edit6' ][ 2 ] = __ ( 'Unit' );
$table -> data [ 'edit6' ][ 3 ] = html_print_extended_select_for_unit ( 'unit' , '-1' , '' , '' , '0' , '15' , true , false , false , false , 1 );
2019-03-29 14:59:31 +01:00
// FF stands for Flip-flop.
$table -> data [ 'edit7' ][ 0 ] = __ ( 'FF threshold' ) . ' ' ;
2019-02-06 17:00:15 +01:00
$table -> colspan [ 'edit7' ][ 1 ] = 3 ;
2019-03-29 14:59:31 +01:00
$table -> data [ 'edit7' ][ 1 ] = __ ( 'Mode' ) . ' ' ;
$table -> data [ 'edit7' ][ 1 ] .= html_print_select (
[
'' => __ ( 'No change' ),
'1' => __ ( 'Each state changing' ),
'0' => __ ( 'All state changing' ),
],
'each_ff' ,
'' ,
'' ,
'' ,
'' ,
true ,
false ,
true ,
'' ,
false ,
'width: 400px;'
) . '<br />' ;
$table -> data [ 'edit7' ][ 1 ] .= __ ( 'All state changing' ) . ' : ' ;
$table -> data [ 'edit7' ][ 1 ] .= html_print_input_text (
'min_ff_event' ,
'' ,
'' ,
5 ,
15 ,
true
) . '<br />' ;
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit7' ][ 1 ] .= __ ( 'Each state changing' ) . ' : ' ;
2019-03-29 14:59:31 +01:00
$table -> data [ 'edit7' ][ 1 ] .= __ ( 'To normal' ) . ' ' ;
$table -> data [ 'edit7' ][ 1 ] .= html_print_input_text (
'min_ff_event_normal' ,
'' ,
'' ,
5 ,
15 ,
true
) . ' ' ;
$table -> data [ 'edit7' ][ 1 ] .= __ ( 'To warning' ) . ' ' ;
$table -> data [ 'edit7' ][ 1 ] .= html_print_input_text (
'min_ff_event_warning' ,
'' ,
'' ,
5 ,
15 ,
true
) . ' ' ;
$table -> data [ 'edit7' ][ 1 ] .= __ ( 'To critical' ) . ' ' ;
$table -> data [ 'edit7' ][ 1 ] .= html_print_input_text (
'min_ff_event_critical' ,
'' ,
'' ,
5 ,
15 ,
true
) . '<br>' ;
$table -> data [ 'edit7' ][ 1 ] .= __ ( 'Keep counters' ) . ' ' ;
2019-04-02 16:01:24 +02:00
$table -> data [ 'edit7' ][ 1 ] .= html_print_select (
[
'' => __ ( 'No change' ),
'1' => __ ( 'Active Counters' ),
'0' => __ ( 'Inactive Counters' ),
],
2019-03-29 14:59:31 +01:00
'ff_type' ,
2019-04-02 16:01:24 +02:00
'' ,
'' ,
'' ,
'' ,
true ,
false ,
true ,
'' ,
false ,
'width: 400px;'
2019-03-29 14:59:31 +01:00
);
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit8' ][ 0 ] = __ ( 'FF interval' );
2019-03-29 14:59:31 +01:00
$table -> data [ 'edit8' ][ 1 ] = html_print_input_text (
'module_ff_interval' ,
'' ,
'' ,
5 ,
10 ,
true
);
$table -> data [ 'edit8' ][ 1 ] .= ui_print_help_tip (
__ ( 'Module execution flip flop time interval (in secs).' ),
true
);
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit8' ][ 2 ] = __ ( 'FF timeout' );
2019-03-29 14:59:31 +01:00
$table -> data [ 'edit8' ][ 3 ] = html_print_input_text (
'ff_timeout' ,
'' ,
'' ,
5 ,
10 ,
true
);
$table -> data [ 'edit8' ][ 3 ] .= ui_print_help_tip (
__ ( 'Timeout in secs from start of flip flop counting. If this value is exceeded, FF counter is reset. Set to 0 for no timeout.' ),
true
);
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit9' ][ 0 ] = __ ( 'Historical data' );
$table -> data [ 'edit9' ][ 1 ] = html_print_select ([ '' => __ ( 'No change' ), '1' => __ ( 'Yes' ), '0' => __ ( 'No' )], 'history_data' , '' , '' , '' , '' , true );
// Tags avalaible
$id_tag = [];
$table -> data [ 'edit10' ][ 0 ] = __ ( 'Tags' );
$table -> data [ 'edit10' ][ 1 ] = html_print_select_from_sql (
'SELECT id_tag, name FROM ttag ORDER BY name' ,
'id_tag[]' ,
$id_tag ,
'' ,
__ ( 'None' ),
'0' ,
true ,
true ,
false ,
false
);
$table -> data [ 'edit10' ][ 2 ] = __ ( 'Category' );
$table -> data [ 'edit10' ][ 3 ] = html_print_select ( categories_get_all_categories ( 'forselect' ), 'id_category' , '' , '' , __ ( 'No change' ), '' , true , false , false );
if ( enterprise_installed ()) {
$table -> rowspan [ 'edit10' ][ 0 ] = $table -> rowspan [ 'edit10' ][ 1 ] = 2 ;
$table -> data [ 'edit101' ][ 2 ] = __ ( 'Policy linking status' ) . ui_print_help_tip ( __ ( 'This field only has sense in modules adopted by a policy.' ), true );
$table -> data [ 'edit101' ][ 3 ] = html_print_select ([ MODULE_PENDING_LINK => __ ( 'Linked' ), MODULE_PENDING_UNLINK => __ ( 'Unlinked' )], 'policy_linked' , '' , '' , __ ( 'No change' ), '' , true , false , false );
}
if ( $table -> rowspan [ 'edit10' ][ 0 ] == 2 ) {
$table -> rowspan [ 'edit10' ][ 0 ] = $table -> rowspan [ 'edit10' ][ 1 ] = 3 ;
} else {
$table -> rowspan [ 'edit10' ][ 0 ] = $table -> rowspan [ 'edit10' ][ 1 ] = 2 ;
}
$table -> data [ 'edit102' ][ 2 ] = __ ( 'Discard unknown events' );
$table -> data [ 'edit102' ][ 3 ] = html_print_select (
[
'' => __ ( 'No change' ),
'1' => __ ( 'Yes' ),
'0' => __ ( 'No' ),
],
'throw_unknown_events' ,
'' ,
'' ,
'' ,
'' ,
true
);
$table -> data [ 'edit12' ][ 0 ] = '<b>' . __ ( 'Critical instructions' ) . '</b>' . ui_print_help_tip ( __ ( 'Instructions when the status is critical' ), true );
$table -> data [ 'edit12' ][ 1 ] = html_print_textarea ( 'critical_instructions' , 2 , 50 , '' , '' , true );
$table -> colspan [ 'edit12' ][ 1 ] = 3 ;
$table -> data [ 'edit13' ][ 0 ] = '<b>' . __ ( 'Warning instructions' ) . '</b>' . ui_print_help_tip ( __ ( 'Instructions when the status is warning' ), true );
$table -> data [ 'edit13' ][ 1 ] = html_print_textarea ( 'warning_instructions' , 2 , 50 , '' , '' , true );
$table -> colspan [ 'edit13' ][ 1 ] = 3 ;
$table -> data [ 'edit14' ][ 0 ] = '<b>' . __ ( 'Unknown instructions' ) . '</b>' . ui_print_help_tip ( __ ( 'Instructions when the status is unknown' ), true );
$table -> data [ 'edit14' ][ 1 ] = html_print_textarea ( 'unknown_instructions' , 2 , 50 , '' , '' , true );
$table -> colspan [ 'edit14' ][ 1 ] = 3 ;
$table -> data [ 'edit11' ][ 0 ] = __ ( 'Quiet' );
$table -> data [ 'edit11' ][ 0 ] .= ui_print_help_tip ( __ ( 'The module still store data but the alerts and events will be stop' ), true );
$table -> data [ 'edit11' ][ 1 ] = html_print_select (
[
- 1 => __ ( 'No change' ),
1 => __ ( 'Yes' ),
0 => __ ( 'No' ),
],
'quiet_select' ,
- 1 ,
'' ,
'' ,
0 ,
true
);
$table -> data [ 'edit11' ][ 2 ] = __ ( 'Timeout' );
$table -> data [ 'edit11' ][ 3 ] = html_print_input_text (
'max_timeout' ,
'' ,
'' ,
5 ,
10 ,
true
) . ' ' . ui_print_help_tip (
__ ( 'Seconds that agent will wait for the execution of the module.' ),
true
);
$table -> data [ 'edit16' ][ 0 ] = __ ( 'Retries' );
$table -> data [ 'edit16' ][ 1 ] = html_print_input_text ( 'max_retries' , '' , '' , 5 , 10 , true ) . ' ' . ui_print_help_tip (
__ ( 'Number of retries that the module will attempt to run.' ),
true
);
2019-05-24 14:26:28 +02:00
$table -> data [ 'edit22' ][ 0 ] = __ ( 'Web checks' );
2019-02-06 17:00:15 +01:00
;
$table -> data [ 'edit22' ][ 1 ] = '<textarea id="textarea_plugin_parameter" name="plugin_parameter_text" cols="65" rows="15"></textarea>' ;
$table -> data [ 'edit16' ][ 2 ] = __ ( 'Port' );
$table -> data [ 'edit16' ][ 3 ] = html_print_input_text ( 'tcp_port' , '' , '' , 5 , 20 , true );
2019-05-24 14:26:28 +02:00
$table -> data [ 'edit17' ][ 0 ] = __ ( 'TCP send' );
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit17' ][ 1 ] = html_print_textarea ( 'tcp_send2' , 2 , 65 , '' , '' , true );
$table -> data [ 'edit17' ][ 2 ] = __ ( 'TCP receive' );
$table -> data [ 'edit17' ][ 3 ] = html_print_textarea ( 'tcp_rcv' , 2 , 65 , '' , '' , true );
2019-05-24 14:26:28 +02:00
$table -> data [ 'edit18' ][ 0 ] = __ ( 'WMI query' );
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit18' ][ 1 ] = html_print_input_text ( 'wmi_query' , '' , '' , 35 , 255 , true );
$table -> data [ 'edit18' ][ 2 ] = __ ( 'Key string' );
$table -> data [ 'edit18' ][ 3 ] = html_print_input_text ( 'key_string' , '' , '' , 20 , 60 , true );
2019-05-24 14:26:28 +02:00
$table -> data [ 'edit19' ][ 0 ] = __ ( 'Field number' );
2019-02-06 17:00:15 +01:00
$table -> data [ 'edit19' ][ 1 ] = html_print_input_text ( 'field_number' , '' , '' , 5 , 15 , true );
$table -> data [ 'edit20' ][ 0 ] = __ ( 'Plugin' ) . ui_print_help_icon ( 'plugin_macros' , true );
$table -> data [ 'edit20' ][ 1 ] = html_print_select_from_sql (
'SELECT id, name FROM tplugin ORDER BY name' ,
'id_plugin' ,
'' ,
'changePluginSelect();' ,
__ ( 'None' ),
0 ,
true ,
false ,
false
);
// Store the macros in base64 into a hidden control to move between pages
$table -> data [ 'edit21' ][ 0 ] = html_print_input_hidden ( 'macros' , base64_encode ( $macros ), true );
2019-11-19 12:35:52 +01:00
$table -> colspan [ 'edit23' ][ 1 ] = 3 ;
$table -> data [ 'edit23' ][ 0 ] = __ ( 'Command' );
$table -> data [ 'edit23' ][ 1 ] = html_print_input_text_extended (
'tcp_send' ,
'' ,
'command_text' ,
'' ,
100 ,
10000 ,
false ,
'' ,
'' ,
true
);
require_once $config [ 'homedir' ] . '/include/class/CredentialStore.class.php' ;
$array_credential_identifier = CredentialStore :: getKeys ( 'CUSTOM' );
$table -> data [ 'edit24' ][ 0 ] = __ ( 'Credential identifier' );
$table -> data [ 'edit24' ][ 1 ] = html_print_select (
$array_credential_identifier ,
'custom_string_1' ,
'' ,
'' ,
__ ( 'None' ),
'' ,
true ,
false ,
false
);
$array_os = [
2020-11-24 14:08:37 +01:00
'' => __ ( 'No change' ),
2019-11-19 12:35:52 +01:00
'inherited' => __ ( 'Inherited' ),
'linux' => __ ( 'Linux' ),
'windows' => __ ( 'Windows' ),
];
$table -> data [ 'edit24' ][ 2 ] = __ ( 'Target OS' );
$table -> data [ 'edit24' ][ 3 ] = html_print_select (
$array_os ,
'custom_string_2' ,
'' ,
'' ,
'' ,
'' ,
true ,
false ,
false ,
''
);
2021-02-12 11:28:13 +01:00
if ( empty ( $id_plugin ) === false ) {
$preload = db_get_sql (
sprintf (
'SELECT description FROM tplugin WHERE id = %s' ,
$id_plugin
)
);
2019-02-06 17:00:15 +01:00
$preload = io_safe_output ( $preload );
$preload = str_replace ( " \n " , '<br>' , $preload );
} else {
$preload = '' ;
}
2021-02-12 11:28:13 +01:00
$table -> data [ 'edit21' ][ 1 ] = sprintf (
2021-03-11 15:40:23 +01:00
'<span class="normal" id="plugin_description">%s</span>' ,
2021-02-12 11:28:13 +01:00
$preload
);
2019-02-06 17:00:15 +01:00
2021-02-12 11:28:13 +01:00
echo '<form method="post" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=edit_modules" id="form_edit">' ;
2019-02-06 17:00:15 +01:00
html_print_table ( $table );
2021-02-12 11:28:13 +01:00
attachActionButton ( 'update' , 'update' , $table -> width );
2019-02-06 17:00:15 +01:00
echo '</form>' ;
echo '<h3 class="error invisible" id="message"> </h3>' ;
2021-02-12 11:28:13 +01:00
// Hack to translate text "none" in PHP to javascript.
2021-03-11 15:40:23 +01:00
echo '<span id ="none_text" class="invisible">' . __ ( 'None' ) . '</span>' ;
echo '<span id ="select_agent_first_text" class="invisible">' . __ ( 'Please, select an agent first' ) . '</span>' ;
2021-02-12 11:28:13 +01:00
// Load JS files.
ui_require_javascript_file ( 'pandora_modules' );
2019-02-06 17:00:15 +01:00
ui_require_jquery_file ( 'pandora.controls' );
if ( $selection_mode == 'modules' ) {
$modules_row = '' ;
$agents_row = 'none' ;
} else {
$modules_row = 'none' ;
$agents_row = '' ;
}
?>
2009-03-18 16:42:15 +01:00
< script type = " text/javascript " >
/* <![CDATA[ */
2021-02-12 11:28:13 +01:00
flag_load_plugin_component = false ;
2015-02-04 11:18:34 +01:00
2009-03-18 16:42:15 +01:00
$ ( document ) . ready ( function () {
2020-09-11 14:35:32 +02:00
$ ( " #checkbox-select_all_modules " ) . change ( function () {
if ( $ ( '#checkbox-select_all_modules' ) . prop ( 'checked' )) {
$ ( " #module_name option " ) . prop ( 'selected' , 'selected' );
$ ( " #module_name " ) . trigger ( 'change' );
} else {
$ ( " #module_name option " ) . prop ( 'selected' , false );
$ ( " #module_name " ) . trigger ( 'change' );
}
});
$ ( " #module_name " ) . change ( function () {
var options_length = $ ( " #module_name option " ) . length ;
var options_selected_length = $ ( " #module_name option:selected " ) . length ;
if ( options_selected_length < options_length ) {
$ ( '#checkbox-select_all_modules' ) . prop ( " checked " , false );
}
});
$ ( " #checkbox-select_all_agents " ) . change ( function () {
if ( $ ( '#checkbox-select_all_agents' ) . prop ( 'checked' )) {
$ ( " #id_agents option " ) . prop ( 'selected' , 'selected' );
$ ( " #id_agents " ) . trigger ( 'change' );
} else {
$ ( " #id_agents option " ) . prop ( 'selected' , false );
$ ( " #id_agents " ) . trigger ( 'change' );
}
});
$ ( " #id_agents " ) . change ( function () {
var options_length = $ ( " #id_agents option " ) . length ;
var options_selected_length = $ ( " #id_agents option:selected " ) . length ;
if ( options_selected_length < options_length ) {
$ ( '#checkbox-select_all_agents' ) . prop ( " checked " , false );
}
});
2019-02-06 17:00:15 +01:00
$ ( " #text-custom_ip_target " ) . hide ();
$ ( " #id_agents " ) . change ( agent_changed_by_multiple_agents );
$ ( " #module_name " ) . change ( module_changed_by_multiple_modules );
clean_lists ();
$ ( " .select_modules_row " ) . css ( 'display' , '<?php echo $modules_row; ?>' );
$ ( " .select_agents_row " ) . css ( 'display' , '<?php echo $agents_row; ?>' );
$ ( " .select_modules_row_2 " ) . css ( 'display' , 'none' );
// Trigger change to refresh selection when change selection mode
$ ( " #agents_selection_mode " ) . change ( function () {
$ ( " #module_name " ) . trigger ( 'change' );
});
$ ( " #modules_selection_mode " ) . change ( function () {
$ ( " #id_agents " ) . trigger ( 'change' );
});
$ ( " #module_type " ) . change ( function () {
$ ( 'input[type=checkbox]' ) . attr ( 'checked' , false );
if ( this . value < 0 ) {
clean_lists ();
$ ( " .select_modules_row_2 " ) . css ( 'display' , 'none' );
return ;
}
else {
$ ( " #module " ) . html ( '<?php echo __(' None '); ?>' );
$ ( " #module_name " ) . html ( '' );
$ ( 'input[type=checkbox]' ) . removeAttr ( 'disabled' );
$ ( " .select_modules_row_2 " ) . css ( 'display' , '' );
}
$ ( " tr#delete_table-edit1, " +
" tr#delete_table-edit0, " +
" tr#delete_table-edit1_1, " +
" tr#delete_table-edit2, " +
" tr#delete_table-edit3, " +
" tr#delete_table-edit35, " +
" tr#delete_table-edit4, " +
" tr#delete_table-edit5, " +
" tr#delete_table-edit6, " +
" tr#delete_table-edit7, " +
" tr#delete_table-edit8, " +
" tr#delete_table-edit9, " +
" tr#delete_table-edit10, " +
" tr#delete_table-edit101, " +
" tr#delete_table-edit102, " +
" tr#delete_table-edit11, " +
" tr#delete_table-edit12, " +
" tr#delete_table-edit13, " +
" tr#delete_table-edit14, " +
" tr#delete_table-edit16, " +
" tr#delete_table-edit17, " +
" tr#delete_table-edit18, " +
" tr#delete_table-edit19, " +
" tr#delete_table-edit20, " +
" tr#delete_table-edit21, " +
" tr#delete_table-edit22, " +
2019-11-19 12:35:52 +01:00
" tr#delete_table-edit23, " +
" tr#delete_table-edit24, " +
2019-02-06 17:00:15 +01:00
" tr#delete_table-edit15 " ) . hide ();
var params = {
" page " : " operation/agentes/ver_agente " ,
" get_agent_modules_json " : 1 ,
" get_distinct_name " : 1 ,
2021-08-19 12:57:16 +02:00
" indexed " : 0 ,
" safe_name " : 1
2019-02-06 17:00:15 +01:00
};
2021-08-19 12:57:16 +02:00
2019-02-06 17:00:15 +01:00
if ( this . value != '0' )
params [ 'id_tipo_modulo' ] = this . value ;
2021-08-19 12:57:16 +02:00
2019-02-06 17:00:15 +01:00
var status_module = $ ( '#status_module' ) . val ();
if ( status_module != '-1' )
params [ 'status_module' ] = status_module ;
var tags_to_search = $ ( '#tags' ) . val ();
if ( tags_to_search != null ) {
if ( tags_to_search [ 0 ] != - 1 ) {
params [ 'tags' ] = tags_to_search ;
}
}
2021-08-19 12:57:16 +02:00
2021-02-12 11:28:13 +01:00
showSpinner ();
2019-02-06 17:00:15 +01:00
$ ( " tr#delete_table-edit1, tr#delete_table-edit0, tr#delete_table-edit2 " ) . hide ();
$ ( " #module_name " ) . attr ( " disabled " , " disabled " )
2021-08-19 12:57:16 +02:00
$ ( " #module_name option[value!=0] " ) . remove ();
2019-02-06 17:00:15 +01:00
jQuery . post ( " ajax.php " ,
params ,
function ( data , status ) {
jQuery . each ( data , function ( id , value ) {
2021-08-19 12:57:16 +02:00
option = $ ( " <option></option> " ) . attr ( " value " , value [ " nombre " ]) . html ( value [ " safe_name " ]);
2019-02-06 17:00:15 +01:00
$ ( " #module_name " ) . append ( option );
});
2021-02-12 11:28:13 +01:00
hideSpinner ();
2019-02-06 17:00:15 +01:00
$ ( " #module_name " ) . removeAttr ( " disabled " );
2019-06-19 17:36:55 +02:00
//Filter modules. Call the function when the select is fully loaded.
var textNoData = " <?php echo __('None'); ?> " ;
filterByText ( $ ( '#module_name' ), $ ( " #text-filter_modules " ), textNoData );
2019-02-06 17:00:15 +01:00
},
" json "
);
});
function show_form () {
$ ( " td#delete_table-0-1, " +
" td#delete_table-edit1-1, " +
" td#delete_table-edit2-1 " ) . css ( " width " , " 300px " );
$ ( " #form_edit input[type=text] " ) . attr ( " value " , " " );
$ ( " #form_edit input[type=checkbox] " ) . not ( " #checkbox-recursion " ) . removeAttr ( " checked " );
$ ( " tr#delete_table-edit1, " +
" tr#delete_table-edit0, " +
" tr#delete_table-edit1_1, " +
" tr#delete_table-edit2, " +
" tr#delete_table-edit3, " +
" tr#delete_table-edit35, " +
" tr#delete_table-edit4, " +
" tr#delete_table-edit5, " +
" tr#delete_table-edit6, " +
" tr#delete_table-edit7, " +
" tr#delete_table-edit8, " +
" tr#delete_table-edit9, " +
" tr#delete_table-edit10, " +
" tr#delete_table-edit101, " +
" tr#delete_table-edit102, " +
" tr#delete_table-edit11, " +
" tr#delete_table-edit12, " +
" tr#delete_table-edit13, " +
" tr#delete_table-edit14, " +
" tr#delete_table-edit16, " +
" tr#delete_table-edit17, " +
" tr#delete_table-edit18, " +
" tr#delete_table-edit19, " +
" tr#delete_table-edit20, " +
" tr#delete_table-edit21, " +
" tr#delete_table-edit22, " +
2019-11-19 12:35:52 +01:00
" tr#delete_table-edit23, " +
" tr#delete_table-edit24, " +
2019-02-06 17:00:15 +01:00
" tr#delete_table-edit15 " ) . show ();
switch ( $ ( '#module_type' ) . val ()) {
case '3' :
case '23' :
case '33' :
$ ( " #edit1-1-min,#edit1-1-max,#edit1-3-min,#edit1-3-max,#delete_table-edit15, " +
" #delete_table-edit3-2,#delete_table-edit3-3,#delete_table-edit35 " ) . hide ();
$ ( " #edit1-1-str,#edit1-3-str " ) . show ();
break ;
case '6' :
case '7' :
$ ( " #edit1-1-min,#edit1-1-max,#edit1-3-min,#edit1-3-max " ) . show ();
$ ( " #edit1-1-str,#edit1-3-str,#delete_table-edit15,#delete_table-edit3-2, " +
" #delete_table-edit3-3,#delete_table-edit35-2,#delete_table-edit35-3, " +
" #delete_table-edit5 " ) . hide ();
break ;
case '8' :
case '9' :
case '11' :
$ ( " #edit1-1-min,#edit1-1-max,#edit1-3-min,#edit1-3-max " ) . show ();
$ ( " #edit1-1-str,#edit1-3-str,#delete_table-edit15,#delete_table-edit3-2, " +
" #delete_table-edit3-3,#delete_table-edit35-2,#delete_table-edit35-3, " +
" #delete_table-edit5 " ) . hide ();
break ;
case '10' :
$ ( " #edit1-1-str,#edit1-3-str " ) . show ();
$ ( " #edit1-1-str,#edit1-3-str,#delete_table-edit15,#delete_table-edit3-2, " +
" #delete_table-edit3-3,#delete_table-edit35-2,#delete_table-edit35-3, " +
" #delete_table-edit5 " ) . hide ();
break ;
case '15' :
case '16' :
case '18' :
$ ( " #edit1-1-min,#edit1-1-max,#edit1-3-min,#edit1-3-max " ) . show ();
$ ( " #edit1-1-str,#edit1-3-str,#delete_table-edit5 " ) . hide ();
break ;
case '17' :
$ ( " #edit1-1-str,#edit1-3-str " ) . show ();
$ ( " #edit1-1-min,#edit1-1-max,#edit1-3-min,#edit1-3-max,#delete_table-edit5 " ) . hide ();
break ;
case '1' :
case '2' :
case '4' :
case '5' :
case '21' :
case '22' :
case '24' :
case '25' :
case '30' :
case '31' :
case '32' :
case '100' :
$ ( " #edit1-1-min,#edit1-1-max,#edit1-3-min,#edit1-3-max " ) . show ();
$ ( " #edit1-1-str,#edit1-3-str,#delete_table-edit15,#delete_table-edit3-2, " +
" #delete_table-edit3-3,#delete_table-edit35 " ) . hide ();
break ;
2019-11-19 12:35:52 +01:00
case '34' :
case '35' :
case '36' :
case '37' :
$ ( " #edit1-1-min,#edit1-1-max,#edit1-3-min,#edit1-3-max " ) . show ();
$ ( " #edit1-1-str,#edit1-3-str,#delete_table-edit5 " ) . hide ();
break ;
2019-02-06 17:00:15 +01:00
default :
}
}
function clean_lists () {
$ ( " #id_agents " ) . html ( '<?php echo __(' None '); ?>' );
$ ( " #module_name " ) . html ( '<?php echo __(' None '); ?>' );
$ ( " #agents " ) . html ( '<?php echo __(' None '); ?>' );
$ ( " #module " ) . html ( '<?php echo __(' None '); ?>' );
$ ( " tr#delete_table-edit1, " +
" tr#delete_table-edit0, " +
" tr#delete_table-edit1_1, " +
" tr#delete_table-edit2, " +
" tr#delete_table-edit3, " +
" tr#delete_table-edit35, " +
" tr#delete_table-edit36, " +
" tr#delete_table-edit37, " +
" tr#delete_table-edit38, " +
" tr#delete_table-edit4, " +
" tr#delete_table-edit5, " +
" tr#delete_table-edit6, " +
" tr#delete_table-edit7, " +
" tr#delete_table-edit8, " +
" tr#delete_table-edit9, " +
" tr#delete_table-edit10, " +
" tr#delete_table-edit101, " +
" tr#delete_table-edit102, " +
" tr#delete_table-edit11, " +
" tr#delete_table-edit12, " +
" tr#delete_table-edit13, " +
" tr#delete_table-edit14, " +
" tr#delete_table-edit16, " +
" tr#delete_table-edit17, " +
" tr#delete_table-edit18, " +
" tr#delete_table-edit19, " +
" tr#delete_table-edit20, " +
" tr#delete_table-edit21, " +
" tr#delete_table-edit22, " +
2019-11-19 12:35:52 +01:00
" tr#delete_table-edit23, " +
" tr#delete_table-edit24, " +
2019-02-06 17:00:15 +01:00
" tr#delete_table-edit15 " ) . hide ();
$ ( 'input[type=checkbox]' ) . attr ( 'checked' , false );
$ ( 'input[type=checkbox]' ) . attr ( 'disabled' , true );
$ ( '#module_type' ) . val ( - 1 );
$ ( '#groups_select' ) . val ( - 1 );
}
2020-09-11 14:35:32 +02:00
$ ( 'input[type=checkbox]' ) . not ( " .static " ) . change (
2019-02-06 17:00:15 +01:00
function () {
if ( this . id == " checkbox-force_type " ) {
if ( this . checked ) {
$ ( " .select_modules_row_2 " ) . css ( 'display' , 'none' );
$ ( " tr#delete_table-edit1, " +
" tr#delete_table-edit0, " +
" tr#delete_table-edit1_1, " +
" tr#delete_table-edit2, " +
" tr#delete_table-edit3, " +
" tr#delete_table-edit35, " +
" tr#delete_table-edit4, " +
" tr#delete_table-edit5, " +
" tr#delete_table-edit6, " +
" tr#delete_table-edit7, " +
" tr#delete_table-edit8, " +
" tr#delete_table-edit9, " +
" tr#delete_table-edit10 " ) . show ();
}
else {
$ ( " .select_modules_row_2 " ) . css ( 'display' , '' );
if ( $ ( '#module_name option:selected' ) . val () == undefined ) {
$ ( " tr#delete_table-edit1, " +
" tr#delete_table-edit0, " +
" tr#delete_table-edit1_1, " +
" tr#delete_table-edit2, " +
" tr#delete_table-edit3, " +
" tr#delete_table-edit35, " +
" tr#delete_table-edit4, " +
" tr#delete_table-edit5, " +
" tr#delete_table-edit6, " +
" tr#delete_table-edit7, " +
" tr#delete_table-edit8, " +
" tr#delete_table-edit9, " +
" tr#delete_table-edit10, " +
" tr#delete_table-edit101, " +
" tr#delete_table-edit102, " +
" tr#delete_table-edit11, " +
" tr#delete_table-edit12, " +
" tr#delete_table-edit13, " +
" tr#delete_table-edit14, " +
" tr#delete_table-edit16, " +
" tr#delete_table-edit17, " +
" tr#delete_table-edit18, " +
" tr#delete_table-edit19, " +
" tr#delete_table-edit20, " +
" tr#delete_table-edit21, " +
" tr#delete_table-edit22, " +
2019-11-19 12:35:52 +01:00
" tr#delete_table-edit23, " +
" tr#delete_table-edit24, " +
2019-02-06 17:00:15 +01:00
" tr#delete_table-edit15 " ) . hide ();
}
}
}
else if ( this . id == " checkbox-recursion " ) {
$ ( " #checkbox-force_group " ) . prop ( " checked " , false );
$ ( " #groups_select " ) . trigger ( " change " );
}
else if ( this . id == " checkbox-warning_inverse " ) {
return ; //Do none
}
else if ( this . id == " checkbox-critical_inverse " ) {
return ; //Do none
}
else if ( this . id == " checkbox-dynamic_two_tailed " ) {
return ; //Do none
}
else {
if ( this . id == " checkbox-force_group " ) {
$ ( " #checkbox-recursion " ) . prop ( " checked " , false );
}
if ( this . checked ) {
$ ( " .select_agents_row_2 " ) . css ( 'display' , 'none' );
$ ( " tr#delete_table-edit1, " +
" tr#delete_table-edit0, " +
" tr#delete_table-edit1_1, " +
" tr#delete_table-edit2, " +
" tr#delete_table-edit3, " +
" tr#delete_table-edit35, " +
" tr#delete_table-edit4, " +
" tr#delete_table-edit5, " +
" tr#delete_table-edit6, " +
" tr#delete_table-edit7, " +
" tr#delete_table-edit8, " +
" tr#delete_table-edit9, " +
" tr#delete_table-edit10, " +
" tr#delete_table-edit101, " +
" tr#delete_table-edit102, " +
" tr#delete_table-edit11, " +
" tr#delete_table-edit12, " +
" tr#delete_table-edit13, " +
" tr#delete_table-edit14, " +
" tr#delete_table-edit16, " +
" tr#delete_table-edit17, " +
" tr#delete_table-edit18, " +
" tr#delete_table-edit19, " +
" tr#delete_table-edit20, " +
" tr#delete_table-edit21, " +
" tr#delete_table-edit22, " +
2019-11-19 12:35:52 +01:00
" tr#delete_table-edit23, " +
" tr#delete_table-edit24, " +
2019-02-06 17:00:15 +01:00
" tr#delete_table-edit15 " ) . show ();
}
else {
$ ( " .select_agents_row_2 " ) . css ( 'display' , '' );
if ( $ ( '#id_agents option:selected' ) . val () == undefined ) {
$ ( " tr#delete_table-edit1, " +
" tr#delete_table-edit0, " +
" tr#delete_table-edit1_1, " +
" tr#delete_table-edit2, " +
" tr#delete_table-edit3, " +
" tr#delete_table-edit35, " +
" tr#delete_table-edit4, " +
" tr#delete_table-edit5, " +
" tr#delete_table-edit6, " +
" tr#delete_table-edit7, " +
" tr#delete_table-edit8, " +
" tr#delete_table-edit9, " +
" tr#delete_table-edit10, " +
" tr#delete_table-edit101, " +
" tr#delete_table-edit102, " +
" tr#delete_table-edit11, " +
" tr#delete_table-edit12, " +
" tr#delete_table-edit13, " +
" tr#delete_table-edit14, " +
" tr#delete_table-edit16, " +
" tr#delete_table-edit17, " +
" tr#delete_table-edit18, " +
" tr#delete_table-edit19, " +
" tr#delete_table-edit20, " +
" tr#delete_table-edit21, " +
" tr#delete_table-edit22, " +
2019-11-19 12:35:52 +01:00
" tr#delete_table-edit23, " +
" tr#delete_table-edit24, " +
2019-02-06 17:00:15 +01:00
" tr#delete_table-edit15 " ) . hide ();
}
}
}
}
);
$ ( " #module_name " ) . change ( show_form );
$ ( " #id_agents " ) . change ( show_form );
$ ( " #form_edit input[name=selection_mode] " ) . change ( function () {
selector = $ ( " #form_edit input[name=selection_mode]:checked " ) . val ();
clean_lists ();
if ( selector == 'agents' ) {
$ ( " .select_modules_row " ) . hide ();
$ ( " .select_agents_row " ) . show ();
$ ( " #groups_select " ) . trigger ( " change " );
}
else if ( selector == 'modules' ) {
$ ( " .select_agents_row " ) . hide ();
$ ( " .select_modules_row " ) . show ();
$ ( " #module_type " ) . trigger ( " change " );
}
});
2021-03-16 17:41:54 +01:00
$ ( '#snmp_version' ) . change ( function () {
2019-02-06 17:00:15 +01:00
if ( $ ( this ) . val () == 3 ) {
$ ( " tr#delete_table-edit36, tr#delete_table-edit37, tr#delete_table-edit38 " ) . show ();
}
else {
$ ( " tr#delete_table-edit36, tr#delete_table-edit37, tr#delete_table-edit38 " ) . hide ();
}
});
$ ( '#ip_target' ) . change ( function () {
if ( $ ( this ) . val () == 'custom' ) {
$ ( " #text-custom_ip_target " ) . show ();
}
else {
$ ( " #text-custom_ip_target " ) . hide ();
}
});
var recursion ;
$ ( " #checkbox-recursion " ) . click ( function () {
recursion = this . checked ? 1 : 0 ;
});
$ ( " #groups_select " ) . change (
function () {
if ( this . value < 0 ) {
clean_lists ();
$ ( " .select_agents_row_2 " ) . css ( 'display' , 'none' );
return ;
}
else {
$ ( " #module " ) . html ( '<?php echo __(' None '); ?>' );
$ ( " #id_agents " ) . html ( '' );
$ ( 'input[type=checkbox]' ) . removeAttr ( 'disabled' );
$ ( " .select_agents_row_2 " ) . css ( 'display' , '' );
}
$ ( " tr#delete_table-edit1, " +
" tr#delete_table-edit0, " +
" tr#delete_table-edit1_1, " +
" tr#delete_table-edit2, " +
" tr#delete_table-edit3, " +
" tr#delete_table-edit35, " +
" tr#delete_table-edit4, " +
" tr#delete_table-edit5, " +
" tr#delete_table-edit6, " +
" tr#delete_table-edit7, " +
" tr#delete_table-edit8, " +
" tr#delete_table-edit9, " +
" tr#delete_table-edit10, " +
" tr#delete_table-edit101, " +
" tr#delete_table-edit102, " +
" tr#delete_table-edit11, " +
" tr#delete_table-edit12, " +
" tr#delete_table-edit13, " +
" tr#delete_table-edit14, " +
" tr#delete_table-edit16, " +
" tr#delete_table-edit17, " +
" tr#delete_table-edit18, " +
" tr#delete_table-edit19, " +
" tr#delete_table-edit20, " +
" tr#delete_table-edit21, " +
" tr#delete_table-edit22, " +
2019-11-19 12:35:52 +01:00
" tr#delete_table-edit23, " +
" tr#delete_table-edit24, " +
2019-02-06 17:00:15 +01:00
" tr#delete_table-edit15 " ) . hide ();
jQuery . post ( " ajax.php " ,
{ " page " : " operation/agentes/ver_agente " ,
" get_agents_group_json " : 1 ,
" recursion " : recursion ,
" id_group " : this . value ,
status_agents : function () {
return $ ( " #status_agents " ) . val ();
},
// Add a key prefix to avoid auto sorting in js object conversion
" keys_prefix " : " _ "
},
function ( data , status ) {
$ ( " #id_agents " ) . html ( '' );
jQuery . each ( data , function ( id , value ) {
// Remove keys_prefix from the index
id = id . substring ( 1 );
option = $ ( " <option></option> " )
. attr ( " value " , value [ " id_agente " ])
. html ( value [ " alias " ]);
$ ( " #id_agents " ) . append ( option );
});
2019-07-08 17:57:23 +02:00
//Filter agents. Call the function when the select is fully loaded.
var textNoData = " <?php echo __('None'); ?> " ;
filterByText ( $ ( '#id_agents' ), $ ( " #text-filter_agents " ), textNoData );
2019-02-06 17:00:15 +01:00
},
" json "
);
}
);
$ ( " #status_agents " ) . change ( function () {
$ ( " #groups_select " ) . trigger ( " change " );
});
if ( " <?php echo $update ; ?> " ){
if ( " <?php echo $selection_mode ; ?> " == 'agents' ){
$ ( " #groups_select " ) . trigger ( " change " );
}
}
$ ( " #status_module " ) . change ( function () {
selector = $ ( " #form_edit input[name=selection_mode]:checked " ) . val ();
if ( selector == 'agents' ) {
$ ( " #id_agents " ) . trigger ( " change " );
}
else if ( selector == 'modules' ) {
$ ( " #module_type " ) . trigger ( " change " );
}
});
$ ( " #tags " ) . change ( function () {
selector = $ ( " #form_edit input[name=selection_mode]:checked " ) . val ();
$ ( " #module_type " ) . trigger ( " change " );
});
$ ( " #tags1 " ) . change ( function () {
selector = $ ( " #form_edit input[name=selection_mode]:checked " ) . val ();
$ ( " #id_agents " ) . trigger ( " change " );
});
$ ( '#agents' ) . change ( function ( e ){
for ( var i = 0 ; i < document . forms [ " form_edit " ] . agents . length ; i ++ ) {
if ( document . forms [ " form_edit " ] . agents [ 0 ] . selected == true ){
var any = true ;
}
if ( i != 0 && document . forms [ " form_edit " ] . agents [ i ] . selected ){
var others = true ;
}
if ( any && others ){
document . forms [ " form_edit " ] . agents [ 0 ] . selected = false ;
}
}
});
$ ( '#module' ) . change ( function ( e ){
for ( var i = 0 ; i < document . forms [ " form_edit " ] . module . length ; i ++ ) {
if ( document . forms [ " form_edit " ] . module [ 0 ] . selected == true ){
var any = true ;
}
if ( i != 0 && document . forms [ " form_edit " ] . module [ i ] . selected ){
var others = true ;
}
if ( any && others ){
document . forms [ " form_edit " ] . module [ 0 ] . selected = false ;
}
}
});
2009-03-18 16:42:15 +01:00
});
2016-10-14 10:16:21 +02:00
2018-02-13 12:29:55 +01:00
function changePluginSelect () {
2019-02-06 17:00:15 +01:00
if ( flag_load_plugin_component ) {
flag_load_plugin_component = false ;
return ;
}
load_plugin_description ( $ ( " #id_plugin " ) . val ());
load_plugin_macros_fields_massive ( 'simple-macro' );
forced_title_callback ();
}
function load_plugin_macros_fields_massive ( row_model_id ) {
// Get plugin macros when selected and load macros fields
var id_plugin = $ ( '#id_plugin' ) . val ();
var params = [];
params . push ( " page=include/ajax/module " );
params . push ( " get_plugin_macros=1 " );
params . push ( " id_plugin= " + id_plugin );
jQuery . ajax ({
data : params . join ( " & " ),
type : 'POST' ,
url : action = get_php_value ( 'absolute_homeurl' ) + " ajax.php " ,
dataType : 'json' ,
success : function ( data ) {
// Delete all the macro fields
$ ( '.macro_field' ) . remove ();
if ( data [ 'array' ] != null ) {
$ ( '#hidden-macros' ) . val ( data [ 'base64' ]);
jQuery . each ( data [ 'array' ], function ( i , macro ) {
if ( macro [ 'desc' ] != '' ) {
2021-03-11 15:40:23 +01:00
$ ( " #delete_table-edit21 " ) . after ( " <tr class='macro_field' id='delete_table-edit " + ( 80 + parseInt ( i )) + " '><td class='bolder'> " + macro [ 'desc' ] + " <input type='hidden' name='desc " + macro [ 'macro' ] + " ' value=' " + macro [ 'desc' ] + " '></td><td><input type='text' name=' " + macro [ 'macro' ] + " '></td></tr> " );
2019-02-06 17:00:15 +01:00
}
});
//Plugin text can be larger
$ ( " .macro_field " ) . find ( " :input " ) . attr ( " maxlength " , 1023 );
// Add again the hover event to the 'force_callback' elements
forced_title_callback ();
}
}
});
}
2018-02-13 12:29:55 +01:00
2016-10-14 10:16:21 +02:00
function disabled_status () {
2019-02-06 17:00:15 +01:00
if ( $ ( '#dynamic_interval_select' ) . val () != 0 ){
$ ( '#text-min_warning' ) . prop ( 'readonly' , true );
$ ( '#text-min_warning' ) . addClass ( 'readonly' );
$ ( '#text-max_warning' ) . prop ( 'readonly' , true );
$ ( '#text-max_warning' ) . addClass ( 'readonly' );
$ ( '#text-min_critical' ) . prop ( 'readonly' , true );
$ ( '#text-min_critical' ) . addClass ( 'readonly' );
$ ( '#text-max_critical' ) . prop ( 'readonly' , true );
$ ( '#text-max_critical' ) . addClass ( 'readonly' );
} else {
$ ( '#text-min_warning' ) . prop ( 'readonly' , false );
$ ( '#text-min_warning' ) . removeClass ( 'readonly' );
$ ( '#text-max_warning' ) . prop ( 'readonly' , false );
$ ( '#text-max_warning' ) . removeClass ( 'readonly' );
$ ( '#text-min_critical' ) . prop ( 'readonly' , false );
$ ( '#text-min_critical' ) . removeClass ( 'readonly' );
$ ( '#text-max_critical' ) . prop ( 'readonly' , false );
$ ( '#text-max_critical' ) . removeClass ( 'readonly' );
}
2016-10-14 10:16:21 +02:00
}
2009-03-18 16:42:15 +01:00
/* ]]> */
</ script >
2012-07-24 Miguel de Dios <miguel.dedios@artica.es>
* godmode/setup/file_manager.php, godmode/setup/news.php,
godmode/users/configure_user.php, godmode/users/user_list.php,
godmode/massive/massive_copy_modules.php,
godmode/massive/massive_enable_disable_alerts.php,
godmode/massive/massive_delete_action_alerts.php,
godmode/massive/massive_delete_alerts.php,
godmode/modules/manage_network_templates_form.php,
godmode/modules/manage_nc_groups.php,
godmode/modules/manage_nc_groups_form.php,
godmode/modules/manage_network_templates.php,
godmode/netflow/nf_edit.php, godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php, godmode/netflow/nf.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/agentes/estado_agente.php, operation/agentes/sla_view.php,
operation/agentes/tactical.php,
operation/agentes/estado_generalagente.php,
operation/snmpconsole/snmp_view.php, operation/users/user_edit.php,
operation/integria_incidents/incident_detail.php,
operation/gis_maps/index.php, operation/events/events_list.php,
operation/events/events.php, operation/messages/message_edit.php,
operation/messages/message_list.php,
operation/reporting/graph_viewer.php, operation/search_reports.php,
operation/netflow/nf_view.php: cleaned source code.
* godmode/massive/massive_operations.php,
godmode/massive/massive_edit_modules.php: fixed the massive edition
of "any" module in agents.
Fixes: #3543484
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6806 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-24 18:38:48 +02:00
< ? php
2020-12-01 15:50:52 +01:00
function process_manage_edit ( $module_name , $agents_select = null , $module_status = '-1' , $selection_mode = 'all' )
2019-02-06 17:00:15 +01:00
{
if ( is_int ( $module_name ) && $module_name < 0 ) {
ui_print_error_message ( __ ( 'No modules selected' ));
return false ;
}
if ( ! is_array ( $agents_select )) {
$agents_select = [ $agents_select ];
}
2019-03-29 14:59:31 +01:00
// List of fields which can be updated.
2019-02-06 17:00:15 +01:00
$fields = [
'dynamic_interval' ,
'dynamic_max' ,
'dynamic_min' ,
'dynamic_two_tailed' ,
'min_warning' ,
'max_warning' ,
'str_warning' ,
'min_critical' ,
'max_critical' ,
'str_critical' ,
'min_ff_event' ,
'module_interval' ,
'disabled' ,
'post_process' ,
'unit_select' ,
'snmp_community' ,
'snmp_oid' ,
'tcp_send' ,
'custom_string_1' ,
'plugin_parameter' ,
'custom_string_2' ,
'custom_string_3' ,
'min' ,
'max' ,
'id_module_group' ,
'plugin_user' ,
'plugin_pass' ,
'id_export' ,
'history_data' ,
'critical_inverse' ,
'warning_inverse' ,
'critical_instructions' ,
'warning_instructions' ,
'unknown_instructions' ,
'policy_linked' ,
'id_category' ,
'disabled_types_event' ,
'ip_target' ,
'custom_ip_target' ,
'descripcion' ,
'min_ff_event_normal' ,
'min_ff_event_warning' ,
'min_ff_event_critical' ,
2019-03-29 14:59:31 +01:00
'ff_type' ,
2019-02-06 17:00:15 +01:00
'each_ff' ,
'module_ff_interval' ,
'ff_timeout' ,
'max_timeout' ,
'tcp_port' ,
'max_retries' ,
'tcp_rcv' ,
'id_plugin' ,
'wmi_query' ,
'key_string' ,
'field_number' ,
'tcp_send2' ,
'plugin_parameter_text' ,
2019-11-19 12:35:52 +01:00
'command_text' ,
'command_credential_identifier' ,
'command_os' ,
2020-09-01 17:39:25 +02:00
'snmp_version' ,
2019-02-06 17:00:15 +01:00
];
$values = [];
foreach ( $fields as $field ) {
$value = get_parameter ( $field , '' );
switch ( $field ) {
case 'id_plugin' :
if ( $value != 0 ) {
$value_field_1 = get_parameter ( '_field1_' , '' );
$value_field_1_desc = get_parameter ( 'desc_field1_' , '' );
$value_field_2 = get_parameter ( '_field2_' , '' );
$value_field_2_desc = get_parameter ( 'desc_field2_' , '' );
$value_field_3 = get_parameter ( '_field3_' , '' );
$value_field_3_desc = get_parameter ( 'desc_field3_' , '' );
$value_field_4 = get_parameter ( '_field4_' , '' );
$value_field_4_desc = get_parameter ( 'desc_field4_' , '' );
$value_field_5 = get_parameter ( '_field5_' , '' );
$value_field_5_desc = get_parameter ( 'desc_field5_' , '' );
$values [ 'macros' ] = '{"1":{"macro":"_field1_","desc":"' . io_safe_input ( $value_field_1_desc ) . '","help":"' . io_safe_input ( $value_field_1_desc ) . '","value":"' . $value_field_1 . '"}' ;
if ( $value_field_2_desc != '' ) {
$values [ 'macros' ] .= ',"2":{"macro":"_field2_","desc":"' . io_safe_input ( $value_field_2_desc ) . '","help":"' . io_safe_input ( $value_field_2_desc ) . '","value":"' . $value_field_2 . '"}' ;
if ( $value_field_3_desc != '' ) {
$values [ 'macros' ] .= ',"3":{"macro":"_field3_","desc":"' . io_safe_input ( $value_field_3_desc ) . '","help":"' . io_safe_input ( $value_field_3_desc ) . '","value":"' . $value_field_3 . '"}' ;
if ( $value_field_4_desc != '' ) {
$values [ 'macros' ] .= ',"4":{"macro":"_field4_","desc":"' . io_safe_input ( $value_field_4_desc ) . '","help":"' . io_safe_input ( $value_field_4_desc ) . '","value":"' . $value_field_4 . '"}' ;
if ( $value_field_5_desc != '' ) {
$values [ 'macros' ] .= ',"5":{"macro":"_field5_","desc":"' . io_safe_input ( $value_field_5_desc ) . '","help":"' . io_safe_input ( $value_field_5_desc ) . '","value":"' . $value_field_5 . '"}' ;
} else {
$values [ 'macros' ] .= '}' ;
}
} else {
$values [ 'macros' ] .= '}' ;
}
} else {
$values [ 'macros' ] .= '}' ;
}
} else {
$values [ 'macros' ] .= '}' ;
}
}
break ;
case 'module_interval' :
if ( $value != 0 ) {
$values [ $field ] = $value ;
}
break ;
case 'plugin_pass' :
if ( $value != '' ) {
$values [ 'plugin_pass' ] = io_input_password ( $value );
}
break ;
case 'post_process' :
if ( $value !== '-1' ) {
$values [ 'post_process' ] = $value ;
}
break ;
case 'unit_select' :
if ( $value != - 1 ) {
2019-08-27 12:21:00 +02:00
$values [ 'unit' ] = ( string ) get_parameter ( 'unit' );
2019-02-06 17:00:15 +01:00
}
break ;
case 'wmi_query' :
if ( $value != '' ) {
$values [ 'snmp_oid' ] = $value ;
}
break ;
case 'key_string' :
if ( $value != '' ) {
$values [ 'snmp_community' ] = $value ;
}
break ;
case 'field_number' :
if ( $value != '' ) {
$values [ 'tcp_port' ] = $value ;
}
break ;
case 'tcp_send2' :
2020-09-01 17:39:25 +02:00
$tcp_send2 = $value ;
2019-02-06 17:00:15 +01:00
break ;
case 'plugin_parameter_text' :
if ( $value != '' ) {
$values [ 'plugin_parameter' ] = $value ;
}
break ;
2020-09-01 17:39:25 +02:00
case 'snmp_version' :
$snmp_version = $value ;
break ;
2019-02-06 17:00:15 +01:00
default :
if ( $value != '' ) {
$values [ $field ] = $value ;
}
break ;
}
}
// Specific snmp reused fields
2021-03-16 17:41:54 +01:00
if ( get_parameter ( 'snmp_version' , '' ) == 3 ) {
2019-02-06 17:00:15 +01:00
$plugin_user_snmp = get_parameter ( 'plugin_user_snmp' , '' );
if ( $plugin_user_snmp != '' ) {
$values [ 'plugin_user' ] = $plugin_user_snmp ;
}
$plugin_pass_snmp = get_parameter ( 'plugin_pass_snmp' , '' );
if ( $plugin_pass_snmp != '' ) {
$values [ 'plugin_pass' ] = io_input_password ( $plugin_pass_snmp );
}
2021-03-16 17:41:54 +01:00
$snmp3_privacy_method = get_parameter ( 'snmp3_privacy_method' , '' );
if ( $snmp3_privacy_method != '' ) {
$values [ 'custom_string_1' ] = io_input_password ( $snmp3_privacy_method );
}
$snmp3_privacy_pass = get_parameter ( 'snmp3_privacy_pass' , '' );
2019-02-06 17:00:15 +01:00
if ( $snmp3_privacy_pass != '' ) {
$values [ 'custom_string_2' ] = io_input_password ( $snmp3_privacy_pass );
}
}
$throw_unknown_events = get_parameter ( 'throw_unknown_events' , '' );
if ( $throw_unknown_events !== '' ) {
// Set the event type that can show.
$disabled_types_event = [
EVENTS_GOING_UNKNOWN => ( int ) $throw_unknown_events ,
];
$values [ 'disabled_types_event' ] = json_encode ( $disabled_types_event );
}
if ( strlen ( get_parameter ( 'history_data' )) > 0 ) {
$values [ 'history_data' ] = get_parameter ( 'history_data' );
}
if ( get_parameter ( 'quiet_select' , - 1 ) != - 1 ) {
$values [ 'quiet' ] = get_parameter ( 'quiet_select' );
}
$filter_modules = false ;
if ( ! is_numeric ( $module_name ) or ( $module_name != 0 )) {
$filter_modules [ 'nombre' ] = $module_name ;
}
// Whether to update module tag info
$update_tags = get_parameter ( 'id_tag' , false );
if ( array_search ( 0 , $agents_select ) !== false ) {
// Apply at All agents.
$modules = db_get_all_rows_filter (
'tagente_modulo' ,
$filter_modules ,
2020-09-01 17:39:25 +02:00
[
'id_agente_modulo' ,
'id_tipo_modulo' ,
]
2019-02-06 17:00:15 +01:00
);
} else {
if ( $module_name == '0' ) {
// Any module
$modules = db_get_all_rows_filter (
'tagente_modulo' ,
[ 'id_agente' => $agents_select ],
2020-09-01 17:39:25 +02:00
[
'id_agente_modulo' ,
'id_tipo_modulo' ,
]
2019-02-06 17:00:15 +01:00
);
} else {
$modules = db_get_all_rows_filter (
'tagente_modulo' ,
[
'id_agente' => $agents_select ,
'nombre' => $module_name ,
],
2020-09-01 17:39:25 +02:00
[
'id_agente_modulo' ,
'id_tipo_modulo' ,
]
2019-02-06 17:00:15 +01:00
);
}
}
if ( $modules === false ) {
return false ;
}
if (( $module_status == 'unknown' ) && ( $module_name == '0' )) {
$modules_to_delete = [];
foreach ( $modules as $mod_id ) {
$mod_status = ( int ) db_get_value_filter ( 'estado' , 'tagente_estado' , [ 'id_agente_modulo' => $mod_id ]);
// Unknown, not init and no data modules
if ( $mod_status == 3 || $mod_status == 4 || $mod_status == 5 ) {
$modules_to_delete [ $mod_id ] = $mod_id ;
}
}
$modules = $modules_to_delete ;
}
foreach ( $modules as $module ) {
2020-12-01 15:50:52 +01:00
if ( $module_status !== '-1' ) {
2020-11-18 16:48:49 +01:00
if ( modules_is_not_init ( $module [ 'id_agente_modulo' ]) === true ) {
if ( $module_status != AGENT_MODULE_STATUS_NO_DATA && $module_status != AGENT_MODULE_STATUS_NOT_INIT ) {
continue ;
}
} else {
$status = modules_get_agentmodule_status ( $module [ 'id_agente_modulo' ]);
if ( $module_status !== $status ) {
continue ;
}
}
}
2020-09-01 17:39:25 +02:00
// Set tcp_send value according to module type since the purpose of this field in database varies in case of SNMP modules.
2021-03-16 17:41:54 +01:00
if ( $module [ 'id_tipo_modulo' ] == MODULE_TYPE_REMOTE_SNMP
|| $module [ 'id_tipo_modulo' ] == MODULE_TYPE_REMOTE_SNMP_INC
|| $module [ 'id_tipo_modulo' ] == MODULE_TYPE_REMOTE_SNMP_STRING
|| $module [ 'id_tipo_modulo' ] <= MODULE_TYPE_REMOTE_SNMP_PROC
) {
2020-09-01 17:39:25 +02:00
if ( $snmp_version != '' ) {
$values [ 'tcp_send' ] = $snmp_version ;
} else {
unset ( $values [ 'tcp_send' ]);
}
} else {
if ( $tcp_send2 != '' ) {
$values [ 'tcp_send' ] = $tcp_send2 ;
} else {
unset ( $values [ 'tcp_send' ]);
}
}
2019-02-06 17:00:15 +01:00
$result = modules_update_agent_module (
$module [ 'id_agente_modulo' ],
$values ,
true ,
$update_tags
);
if ( is_error ( $result )) {
return false ;
}
}
return true ;
2012-07-24 Miguel de Dios <miguel.dedios@artica.es>
* godmode/setup/file_manager.php, godmode/setup/news.php,
godmode/users/configure_user.php, godmode/users/user_list.php,
godmode/massive/massive_copy_modules.php,
godmode/massive/massive_enable_disable_alerts.php,
godmode/massive/massive_delete_action_alerts.php,
godmode/massive/massive_delete_alerts.php,
godmode/modules/manage_network_templates_form.php,
godmode/modules/manage_nc_groups.php,
godmode/modules/manage_nc_groups_form.php,
godmode/modules/manage_network_templates.php,
godmode/netflow/nf_edit.php, godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php, godmode/netflow/nf.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/agentes/estado_agente.php, operation/agentes/sla_view.php,
operation/agentes/tactical.php,
operation/agentes/estado_generalagente.php,
operation/snmpconsole/snmp_view.php, operation/users/user_edit.php,
operation/integria_incidents/incident_detail.php,
operation/gis_maps/index.php, operation/events/events_list.php,
operation/events/events.php, operation/messages/message_edit.php,
operation/messages/message_list.php,
operation/reporting/graph_viewer.php, operation/search_reports.php,
operation/netflow/nf_view.php: cleaned source code.
* godmode/massive/massive_operations.php,
godmode/massive/massive_edit_modules.php: fixed the massive edition
of "any" module in agents.
Fixes: #3543484
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6806 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-24 18:38:48 +02:00
}