2012-02-06 12:05:35 +01:00
< ? php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config ;
check_login ();
2016-09-08 16:06:12 +02:00
if ( ! check_acl ( $config [ 'id_user' ], 0 , " PM " )) {
2012-02-06 12:05:35 +01:00
db_pandora_audit ( " ACL Violation " ,
2013-06-06 15:54:39 +02:00
" Trying to access Custom events Management " );
2012-02-06 12:05:35 +01:00
require ( " general/noaccess.php " );
return ;
}
2012-02-09 13:39:11 +01:00
$update = get_parameter ( 'upd_button' , '' );
$default = ( int ) get_parameter ( 'default' , 0 );
2012-02-07 19:11:12 +01:00
2015-04-10 00:58:24 +02:00
2012-02-09 13:39:11 +01:00
if ( $default != 0 ) {
2012-02-08 18:56:32 +01:00
$event_fields = io_safe_input ( 'evento,id_agente,estado,timestamp' );
$fields_selected = explode ( ',' , $event_fields );
2012-07-26 Miguel de Dios <miguel.dedios@artica.es>
* operation/users/user_edit.php,
operation/events/events_validate.php, operation/search_graphs.php,
godmode/events/event_filter.php, godmode/events/custom_events.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_copy_modules.php, godmode/tag/tag.php,
godmode/netflow/nf_report.php, godmode/agentes/configure_field.php,
godmode/agentes/agent_manager.php,
godmode/agentes/agent_template.php,
godmode/agentes/fields_manager.php,
godmode/servers/recon_script.php, godmode/servers/plugin.php,
include/functions_modules.php: improved the source structure.
* operation/search_modules.php: fixed the search when the modules
haven't inicialiced.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6814 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-26 13:05:05 +02:00
}
else if ( $update != '' ) {
2012-02-07 19:11:12 +01:00
$fields_selected = ( array ) get_parameter ( 'fields_selected' );
if ( $fields_selected [ 0 ] == '' ) {
2012-02-08 18:21:16 +01:00
$event_fields = io_safe_input ( 'evento,id_agente,estado,timestamp' );
2012-02-07 19:11:12 +01:00
$fields_selected = explode ( ',' , $event_fields );
2012-07-26 Miguel de Dios <miguel.dedios@artica.es>
* operation/users/user_edit.php,
operation/events/events_validate.php, operation/search_graphs.php,
godmode/events/event_filter.php, godmode/events/custom_events.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_copy_modules.php, godmode/tag/tag.php,
godmode/netflow/nf_report.php, godmode/agentes/configure_field.php,
godmode/agentes/agent_manager.php,
godmode/agentes/agent_template.php,
godmode/agentes/fields_manager.php,
godmode/servers/recon_script.php, godmode/servers/plugin.php,
include/functions_modules.php: improved the source structure.
* operation/search_modules.php: fixed the search when the modules
haven't inicialiced.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6814 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-26 13:05:05 +02:00
}
else {
2012-02-07 19:11:12 +01:00
$event_fields = implode ( ',' , $fields_selected );
}
2012-07-26 Miguel de Dios <miguel.dedios@artica.es>
* operation/users/user_edit.php,
operation/events/events_validate.php, operation/search_graphs.php,
godmode/events/event_filter.php, godmode/events/custom_events.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_copy_modules.php, godmode/tag/tag.php,
godmode/netflow/nf_report.php, godmode/agentes/configure_field.php,
godmode/agentes/agent_manager.php,
godmode/agentes/agent_template.php,
godmode/agentes/fields_manager.php,
godmode/servers/recon_script.php, godmode/servers/plugin.php,
include/functions_modules.php: improved the source structure.
* operation/search_modules.php: fixed the search when the modules
haven't inicialiced.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6814 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-26 13:05:05 +02:00
2012-02-07 19:11:12 +01:00
$values = array (
'token' => 'event_fields' ,
'value' => $event_fields
);
//update 'event_fields' in tconfig table to keep the value at update.
2015-03-23 15:42:12 +01:00
$result = db_process_sql_update ( 'tconfig' , $values ,
array ( 'token' => 'event_fields' ));
$config [ 'event_fields' ] = $event_fields ;
2012-02-07 19:11:12 +01:00
}
2015-03-23 15:42:12 +01:00
$fields_selected = array ();
$event_fields = '' ;
$fields_selected = explode ( ',' , $config [ 'event_fields' ]);
2012-02-07 19:11:12 +01:00
$result_selected = array ();
2012-02-08 18:21:16 +01:00
2012-02-08 18:56:32 +01:00
//show list of fields selected.
2012-02-07 19:11:12 +01:00
if ( $fields_selected [ 0 ] != '' ) {
foreach ( $fields_selected as $field_selected ) {
2012-02-08 18:21:16 +01:00
switch ( $field_selected ) {
case 'id_evento' :
$result = __ ( 'Event id' );
break ;
case 'evento' :
$result = __ ( 'Event name' );
break ;
case 'id_agente' :
$result = __ ( 'Agent name' );
break ;
case 'id_usuario' :
$result = __ ( 'User' );
break ;
case 'id_grupo' :
$result = __ ( 'Group' );
break ;
case 'estado' :
$result = __ ( 'Status' );
break ;
case 'timestamp' :
$result = __ ( 'Timestamp' );
break ;
case 'event_type' :
$result = __ ( 'Event type' );
break ;
case 'id_agentmodule' :
$result = __ ( 'Agent module' );
break ;
case 'id_alert_am' :
$result = __ ( 'Alert' );
break ;
case 'criticity' :
2015-01-20 09:09:27 +01:00
$result = __ ( 'Severity' );
2012-02-08 18:21:16 +01:00
break ;
case 'user_comment' :
$result = __ ( 'Comment' );
break ;
case 'tags' :
$result = __ ( 'Tags' );
break ;
case 'source' :
$result = __ ( 'Source' );
break ;
case 'id_extra' :
$result = __ ( 'Extra id' );
break ;
2012-10-09 18:05:32 +02:00
case 'owner_user' :
$result = __ ( 'Owner' );
break ;
case 'ack_utimestamp' :
$result = __ ( 'ACK Timestamp' );
break ;
2013-03-06 18:53:17 +01:00
case 'instructions' :
$result = __ ( 'Instructions' );
break ;
2012-12-18 12:54:22 +01:00
case 'server_name' :
2012-12-18 13:16:26 +01:00
$result = __ ( 'Server name' );
2012-12-18 12:54:22 +01:00
break ;
2012-02-08 18:21:16 +01:00
}
$result_selected [ $field_selected ] = $result ;
2012-02-07 19:11:12 +01:00
}
}
2012-02-06 12:05:35 +01:00
$event = array ();
2012-02-09 13:39:11 +01:00
echo '<h3>' . __ ( 'Show event fields' );
echo ' <a href="index.php?sec=geventos&sec2=godmode/events/events§ion=fields&default=1">' ;
html_print_image ( 'images/clean.png' , false , array ( 'title' => __ ( 'Load default event fields' ), 'onclick' => " if (! confirm (' " . __ ( 'Default event fields will be loaded. Do you want to continue?' ) . " ')) return false " ));
echo '</a></h3>' ;
2012-02-08 18:21:16 +01:00
2015-06-25 10:07:53 +02:00
$table = new stdClass ();
2015-06-16 16:09:50 +02:00
$table -> width = '100%' ;
$table -> class = 'databox filters' ;
2012-02-06 12:05:35 +01:00
$table -> size = array ();
2012-10-09 18:05:32 +02:00
//~ $table->size[0] = '20%';
$table -> size [ 1 ] = '10px' ;
//~ $table->size[2] = '20%';
$table -> style [ 0 ] = 'text-align:center;' ;
$table -> style [ 2 ] = 'text-align:center;' ;
2012-02-06 12:05:35 +01:00
$table -> data = array ();
2012-02-07 19:11:12 +01:00
$fields_available = array ();
2012-02-08 18:21:16 +01:00
$fields_available [ 'id_evento' ] = __ ( 'Event id' );
$fields_available [ 'evento' ] = __ ( 'Event name' );
$fields_available [ 'id_agente' ] = __ ( 'Agent name' );
$fields_available [ 'id_usuario' ] = __ ( 'User' );
$fields_available [ 'id_grupo' ] = __ ( 'Group' );
$fields_available [ 'estado' ] = __ ( 'Status' );
$fields_available [ 'timestamp' ] = __ ( 'Timestamp' );
$fields_available [ 'event_type' ] = __ ( 'Event type' );
$fields_available [ 'id_agentmodule' ] = __ ( 'Agent module' );
$fields_available [ 'id_alert_am' ] = __ ( 'Alert' );
2015-09-14 14:07:21 +02:00
$fields_available [ 'criticity' ] = __ ( 'Severity' );
2012-02-08 18:21:16 +01:00
$fields_available [ 'user_comment' ] = __ ( 'Comment' );
$fields_available [ 'tags' ] = __ ( 'Tags' );
$fields_available [ 'source' ] = __ ( 'Source' );
$fields_available [ 'id_extra' ] = __ ( 'Extra id' );
2012-10-09 18:05:32 +02:00
$fields_available [ 'owner_user' ] = __ ( 'Owner' );
$fields_available [ 'ack_utimestamp' ] = __ ( 'ACK Timestamp' );
2013-03-06 18:53:17 +01:00
$fields_available [ 'instructions' ] = __ ( 'Instructions' );
2012-12-18 12:54:22 +01:00
$fields_available [ 'server_name' ] = __ ( 'Server name' );
2012-02-08 18:21:16 +01:00
2012-02-07 19:11:12 +01:00
//remove fields already selected
2012-02-08 18:21:16 +01:00
foreach ( $fields_available as $key => $available ) {
2012-02-07 19:11:12 +01:00
foreach ( $result_selected as $selected ) {
if ( $selected == $available ) {
2012-02-08 18:21:16 +01:00
unset ( $fields_available [ $key ]);
2012-02-07 19:11:12 +01:00
}
}
}
2012-02-06 12:05:35 +01:00
2012-10-09 18:05:32 +02:00
$table -> data [ 0 ][ 0 ] = '<b>' . __ ( 'Fields available' ) . '</b>' ;
$table -> data [ 1 ][ 0 ] = html_print_select ( $fields_available , 'fields_available[]' , true , '' , '' , '' , true , true , false , '' , false , 'width: 200px' );
2015-06-08 13:13:09 +02:00
$table -> data [ 1 ][ 1 ] = '<a href="javascript:">' .
html_print_image ( 'images/darrowright.png' , true ,
array ( 'id' => 'right' , 'title' => __ ( 'Add fields to select' ))) .
'</a>' ;
$table -> data [ 1 ][ 1 ] .= '<br><br><br><br><a href="javascript:">' .
html_print_image ( 'images/darrowleft.png' , true ,
array ( 'id' => 'left' , 'title' => __ ( 'Delete fields to select' ))) .
'</a>' ;
2012-07-26 Miguel de Dios <miguel.dedios@artica.es>
* operation/users/user_edit.php,
operation/events/events_validate.php, operation/search_graphs.php,
godmode/events/event_filter.php, godmode/events/custom_events.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_copy_modules.php, godmode/tag/tag.php,
godmode/netflow/nf_report.php, godmode/agentes/configure_field.php,
godmode/agentes/agent_manager.php,
godmode/agentes/agent_template.php,
godmode/agentes/fields_manager.php,
godmode/servers/recon_script.php, godmode/servers/plugin.php,
include/functions_modules.php: improved the source structure.
* operation/search_modules.php: fixed the search when the modules
haven't inicialiced.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6814 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-26 13:05:05 +02:00
2012-10-09 18:05:32 +02:00
$table -> data [ 0 ][ 1 ] = '' ;
$table -> data [ 0 ][ 2 ] = '<b>' . __ ( 'Fields selected' ) . '</b>' ;
2015-06-08 13:13:09 +02:00
$table -> data [ 1 ][ 2 ] = html_print_select ( $result_selected ,
'fields_selected[]' , true , '' , '' , '' , true , true , false , '' , false , 'width: 200px' );
2012-02-06 12:05:35 +01:00
2012-12-20 19:00:00 +01:00
echo '<form id="custom_events" method="post" action="index.php?sec=geventos&sec2=godmode/events/events§ion=fields&pure=' . $config [ 'pure' ] . '">' ;
2012-02-06 12:05:35 +01:00
html_print_table ( $table );
echo '<div class="action-buttons" style="width: ' . $table -> width . '">' ;
2012-07-26 Miguel de Dios <miguel.dedios@artica.es>
* operation/users/user_edit.php,
operation/events/events_validate.php, operation/search_graphs.php,
godmode/events/event_filter.php, godmode/events/custom_events.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_copy_modules.php, godmode/tag/tag.php,
godmode/netflow/nf_report.php, godmode/agentes/configure_field.php,
godmode/agentes/agent_manager.php,
godmode/agentes/agent_template.php,
godmode/agentes/fields_manager.php,
godmode/servers/recon_script.php, godmode/servers/plugin.php,
include/functions_modules.php: improved the source structure.
* operation/search_modules.php: fixed the search when the modules
haven't inicialiced.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6814 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-26 13:05:05 +02:00
html_print_submit_button ( __ ( 'Update' ), 'upd_button' , false , 'class="sub upd"' );
2012-02-08 18:56:32 +01:00
echo '</form>' ;
2012-02-06 12:05:35 +01:00
echo '</div>' ;
?>
2012-02-07 19:11:12 +01:00
< script type = " text/javascript " >
/* <![CDATA[ */
$ ( document ) . ready ( function () {
2013-04-25 Miguel de Dios <miguel.dedios@artica.es>
* godmode/events/custom_events.php,
godmode/massive/massive_enable_disable_alerts.php,
godmode/massive/massive_edit_agents.php,
godmode/massive/massive_delete_modules.php,
godmode/massive/massive_add_action_alerts.php,
godmode/massive/massive_delete_profiles.php,
godmode/massive/massive_delete_alerts.php,
godmode/groups/modu_group_list.php, godmode/groups/group_list.php,
godmode/reporting/graph_builder.php, godmode/reporting/graphs.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_action.php, include/functions_ui.php,
include/functions_graph.php: improved the source code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8057 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-04-25 12:16:41 +02:00
2012-02-07 19:11:12 +01:00
$ ( " #right " ) . click ( function () {
jQuery . each ( $ ( " select[name='fields_available[]'] option:selected " ), function ( key , value ) {
field_name = $ ( value ) . html ();
2013-04-25 Miguel de Dios <miguel.dedios@artica.es>
* godmode/events/custom_events.php,
godmode/massive/massive_enable_disable_alerts.php,
godmode/massive/massive_edit_agents.php,
godmode/massive/massive_delete_modules.php,
godmode/massive/massive_add_action_alerts.php,
godmode/massive/massive_delete_profiles.php,
godmode/massive/massive_delete_alerts.php,
godmode/groups/modu_group_list.php, godmode/groups/group_list.php,
godmode/reporting/graph_builder.php, godmode/reporting/graphs.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_action.php, include/functions_ui.php,
include/functions_graph.php: improved the source code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8057 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-04-25 12:16:41 +02:00
if ( field_name != < ? php echo " ' " . __ ( 'None' ) . " ' " ; ?> ) {
2012-02-07 19:11:12 +01:00
id_field = $ ( value ) . attr ( 'value' );
2012-02-09 11:15:03 +01:00
$ ( " select[name='fields_selected[]'] " ) . append ( $ ( " <option></option> " ) . html ( field_name ) . attr ( " value " , id_field ));
2012-02-07 19:11:12 +01:00
$ ( " #fields_available " ) . find ( " option[value=' " + id_field + " '] " ) . remove ();
}
2012-07-26 Miguel de Dios <miguel.dedios@artica.es>
* operation/users/user_edit.php,
operation/events/events_validate.php, operation/search_graphs.php,
godmode/events/event_filter.php, godmode/events/custom_events.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_copy_modules.php, godmode/tag/tag.php,
godmode/netflow/nf_report.php, godmode/agentes/configure_field.php,
godmode/agentes/agent_manager.php,
godmode/agentes/agent_template.php,
godmode/agentes/fields_manager.php,
godmode/servers/recon_script.php, godmode/servers/plugin.php,
include/functions_modules.php: improved the source structure.
* operation/search_modules.php: fixed the search when the modules
haven't inicialiced.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6814 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-26 13:05:05 +02:00
});
2012-02-07 19:11:12 +01:00
});
2012-07-26 Miguel de Dios <miguel.dedios@artica.es>
* operation/users/user_edit.php,
operation/events/events_validate.php, operation/search_graphs.php,
godmode/events/event_filter.php, godmode/events/custom_events.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_copy_modules.php, godmode/tag/tag.php,
godmode/netflow/nf_report.php, godmode/agentes/configure_field.php,
godmode/agentes/agent_manager.php,
godmode/agentes/agent_template.php,
godmode/agentes/fields_manager.php,
godmode/servers/recon_script.php, godmode/servers/plugin.php,
include/functions_modules.php: improved the source structure.
* operation/search_modules.php: fixed the search when the modules
haven't inicialiced.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6814 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-26 13:05:05 +02:00
2012-02-07 19:11:12 +01:00
$ ( " #left " ) . click ( function () {
jQuery . each ( $ ( " select[name='fields_selected[]'] option:selected " ), function ( key , value ) {
field_name = $ ( value ) . html ();
2015-06-08 11:05:19 +02:00
if ( field_name != < ? php echo " ' " . __ ( 'None' ) . " ' " ; ?> ) {
2012-02-07 19:11:12 +01:00
id_field = $ ( value ) . attr ( 'value' );
2012-10-09 18:05:32 +02:00
$ ( " select[name='fields_available[]'] " ) . append ( $ ( " <option></option> " ) . val ( id_field ) . html ( '<i>' + field_name + '</i>' ));
2012-02-07 19:11:12 +01:00
$ ( " #fields_selected " ) . find ( " option[value=' " + id_field + " '] " ) . remove ();
}
2012-07-26 Miguel de Dios <miguel.dedios@artica.es>
* operation/users/user_edit.php,
operation/events/events_validate.php, operation/search_graphs.php,
godmode/events/event_filter.php, godmode/events/custom_events.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_copy_modules.php, godmode/tag/tag.php,
godmode/netflow/nf_report.php, godmode/agentes/configure_field.php,
godmode/agentes/agent_manager.php,
godmode/agentes/agent_template.php,
godmode/agentes/fields_manager.php,
godmode/servers/recon_script.php, godmode/servers/plugin.php,
include/functions_modules.php: improved the source structure.
* operation/search_modules.php: fixed the search when the modules
haven't inicialiced.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6814 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-26 13:05:05 +02:00
});
2012-02-07 19:11:12 +01:00
});
2012-02-09 11:15:03 +01:00
$ ( " #submit-upd_button " ) . click ( function () {
2012-07-26 Miguel de Dios <miguel.dedios@artica.es>
* operation/users/user_edit.php,
operation/events/events_validate.php, operation/search_graphs.php,
godmode/events/event_filter.php, godmode/events/custom_events.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_copy_modules.php, godmode/tag/tag.php,
godmode/netflow/nf_report.php, godmode/agentes/configure_field.php,
godmode/agentes/agent_manager.php,
godmode/agentes/agent_template.php,
godmode/agentes/fields_manager.php,
godmode/servers/recon_script.php, godmode/servers/plugin.php,
include/functions_modules.php: improved the source structure.
* operation/search_modules.php: fixed the search when the modules
haven't inicialiced.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6814 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-26 13:05:05 +02:00
$ ( '#fields_selected option' ) . map ( function () {
2015-07-14 11:11:22 +02:00
$ ( this ) . prop ( 'selected' , true );
2012-02-09 11:15:03 +01:00
});
});
2012-02-07 19:11:12 +01:00
});
2012-10-09 18:05:32 +02:00
</ script >