diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index c0666434e6..5bbf8e4dfb 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,20 @@ +2011-04-20 Juan Manuel Ramon + + * include/functions_events.php + include/functions_reporting.php + include/functions_alerts.php + operation/incidents/incident_detail.php + operation/agentes/status_events.php + operation/agentes/tactical.php + operation/integria_incidents/incident_detail.php + operation/events/events_validate.php + operation/events/events_list.php + operation/events/events.php + operation/reporting/reporting_xml.php: Functions in functions_events.php have "events_" + prefix. + * index.php: Added some "db_" prefixes that I forgot in my last commit. Functions in + functions_events.php have "events_" prefix. + 2011-04-19 Juan Manuel Ramon * Changelog: Forget to update the Changelog in my last commit. diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index a6470b6f4a..090224f98d 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1124,7 +1124,7 @@ function alerts_validate_alert_agent_module ($id_alert_agent_module) { array ('id' => $id)); if ($result > 0) { - create_event ("Manual validation of alert for ". + events_create_event ("Manual validation of alert for ". alerts_get_alert_template_description ($alert["id_alert_template"]), $group_id, $agent_id, 1, $config["id_user"], "alert_manual_validation", 1, $alert["id_agent_module"], @@ -1480,7 +1480,7 @@ function alerts_validate_alert_compound ($id_alert_compound) { array ('id' => $id)); if ($result > 0) { - create_event ("Manual validation of compound alert for ". + events_create_event ("Manual validation of compound alert for ". $alert["name"], $group_id, $agent_id, 1, $config["id_user"], "alert_manual_validation", 1, $alert["id"], diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 966023f616..24ea712241 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -42,11 +42,11 @@ * * @return mixed False in case of error or invalid values passed. Affected rows otherwise */ -function get_events ($filter = false, $fields = false) { +function events_get_events ($filter = false, $fields = false) { return db_get_all_rows_filter ('tevento', $filter, $fields); } -function get_event ($id, $fields = false) { +function events_get_event ($id, $fields = false) { if (empty ($id)) return false; global $config; @@ -72,9 +72,9 @@ function get_event ($id, $fields = false) { * * @return array A list of events ids. */ -function get_similar_events_ids ($id) { +function events_get_similar_ids ($id) { $ids = array (); - $event = get_event ($id, array ('evento', 'id_agentmodule')); + $event = events_get_event ($id, array ('evento', 'id_agentmodule')); if ($event === false) return $ids; @@ -99,7 +99,7 @@ function get_similar_events_ids ($id) { * * @return bool Whether or not it was successful */ -function delete_event ($id_event, $similar = true) { +function events_delete_event ($id_event, $similar = true) { global $config; //Cleans up the selection for all unwanted values also casts any single values as an array @@ -108,7 +108,7 @@ function delete_event ($id_event, $similar = true) { /* We must delete all events like the selected */ if ($similar) { foreach ($id_event as $id) { - $id_event = array_merge ($id_event, get_similar_events_ids ($id)); + $id_event = array_merge ($id_event, events_get_similar_ids ($id)); } } @@ -118,7 +118,7 @@ function delete_event ($id_event, $similar = true) { foreach ($id_event as $event) { $ret = db_process_sql_delete('tevento', array('id_evento' => $event)); - if (check_acl ($config["id_user"], get_event_group ($event), "IM") == 0) { + if (check_acl ($config["id_user"], events_get_group ($event), "IM") == 0) { //Check ACL db_pandora_audit("ACL Violation", "Attempted deleting event #".$event); } @@ -150,7 +150,7 @@ function delete_event ($id_event, $similar = true) { * * @return bool Whether or not it was successful */ -function validate_event ($id_event, $similars = true, $comment = '', $new_status = 1) { +function events_validate_event ($id_event, $similars = true, $comment = '', $new_status = 1) { global $config; //Cleans up the selection for all unwanted values also casts any single values as an array @@ -159,7 +159,7 @@ function validate_event ($id_event, $similars = true, $comment = '', $new_status /* We must validate all events like the selected */ if ($similars) { foreach ($id_event as $id) { - $id_event = array_merge ($id_event, get_similar_events_ids ($id)); + $id_event = array_merge ($id_event, events_get_similar_ids ($id)); } } @@ -186,7 +186,7 @@ function validate_event ($id_event, $similars = true, $comment = '', $new_status $comment = '-- '.$new_status_string.' '.__('by').' '.$config['id_user'].' '.'['.date ($config["date_format"]).'] --
'.$commentbox; foreach ($id_event as $event) { - $fullevent = get_event($event); + $fullevent = events_get_event($event); if($fullevent['user_comment'] != ''){ $commentbox = '
'.$fullevent['user_comment'].'
'; @@ -200,7 +200,7 @@ function validate_event ($id_event, $similars = true, $comment = '', $new_status $ret = db_process_sql_update('tevento', $values, array('id_evento' => $event), 'AND', false); - if (check_acl ($config["id_user"], get_event_group ($event), "IW") == 0) { + if (check_acl ($config["id_user"], events_get_group ($event), "IW") == 0) { //Check ACL db_pandora_audit("ACL Violation", "Attempted updating event #".$event); } @@ -233,7 +233,7 @@ function validate_event ($id_event, $similars = true, $comment = '', $new_status * * @return int Group id of the given event. */ -function get_event_group ($id_event) { +function events_get_group ($id_event) { return (int) db_get_value ('id_grupo', 'tevento', 'id_evento', (int) $id_event); } @@ -244,7 +244,7 @@ function get_event_group ($id_event) { * * @return string Description of the given event. */ -function get_event_description ($id_event) { +function events_get_description ($id_event) { return (string) db_get_value ('evento', 'tevento', 'id_evento', (int) $id_event); } @@ -263,7 +263,7 @@ function get_event_description ($id_event) { * * @return int event id */ -function create_event ($event, $id_group, $id_agent, $status = 0, $id_user = "", $event_type = "unknown", $priority = 0, $id_agent_module = 0, $id_aam = 0) { +function events_create_event ($event, $id_group, $id_agent, $status = 0, $id_user = "", $event_type = "unknown", $priority = 0, $id_agent_module = 0, $id_aam = 0) { global $config; switch ($config["dbtype"]) { @@ -306,7 +306,7 @@ function create_event ($event, $id_group, $id_agent, $status = 0, $id_user = "", * * @return string HTML with table element */ -function print_events_table ($filter = "", $limit = 10, $width = 440, $return = false) { +function events_print_event_table ($filter = "", $limit = 10, $width = 440, $return = false) { global $config; switch ($config["dbtype"]) { @@ -416,7 +416,7 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return = "title" => get_priority_name ($event["criticity"]))); /* Event type */ - $data[2] = print_event_type_img ($event["event_type"], true); + $data[2] = events_print_type_img ($event["event_type"], true); // Event description wrap around by default at 44 or ~3 lines (10 seems to be a good ratio to wrap around for most sizes. Smaller number gets longer strings) $wrap = floor ($width / 10); @@ -467,56 +467,56 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return = * * @return string HTML with img */ -function print_event_type_img ($type, $return = false) { +function events_print_type_img ($type, $return = false) { $output = ''; switch ($type) { case "alert_recovered": $output .= print_image ("images/error.png", true, - array ("title" => print_event_type_description($type, true))); + array ("title" => events_print_type_description($type, true))); break; case "alert_manual_validation": $output .= print_image ("images/eye.png", true, - array ("title" => print_event_type_description($type, true))); + array ("title" => events_print_type_description($type, true))); break; case "going_up_warning": $output .= print_image ("images/b_yellow.png", true, - array ("title" => print_event_type_description($type, true))); + array ("title" => events_print_type_description($type, true))); break; case "going_down_critical": case "going_up_critical": //This is to be backwards compatible $output .= print_image ("images/b_red.png", true, - array ("title" => print_event_type_description($type, true))); + array ("title" => events_print_type_description($type, true))); break; case "going_up_normal": case "going_down_normal": //This is to be backwards compatible $output .= print_image ("images/b_green.png", true, - array ("title" => print_event_type_description($type, true))); + array ("title" => events_print_type_description($type, true))); break; case "going_down_warning": $output .= print_image ("images/b_yellow.png", true, - array ("title" => print_event_type_description($type, true))); + array ("title" => events_print_type_description($type, true))); break; case "alert_fired": $output .= print_image ("images/bell.png", true, - array ("title" => print_event_type_description($type, true))); + array ("title" => events_print_type_description($type, true))); break; case "system"; $output .= print_image ("images/cog.png", true, - array ("title" => print_event_type_description($type, true))); + array ("title" => events_print_type_description($type, true))); break; case "recon_host_detected"; $output .= print_image ("images/network.png", true, - array ("title" => print_event_type_description($type, true))); + array ("title" => events_print_type_description($type, true))); break; case "new_agent"; $output .= print_image ("images/wand.png", true, - array ("title" => print_event_type_description($type, true))); + array ("title" => events_print_type_description($type, true))); break; case "unknown": default: $output .= print_image ("images/err.png", true, - array ("title" => print_event_type_description($type, true))); + array ("title" => events_print_type_description($type, true))); break; } @@ -533,7 +533,7 @@ function print_event_type_img ($type, $return = false) { * * @return string HTML with img */ -function print_event_type_description ($type, $return = false) { +function events_print_type_description ($type, $return = false) { $output = ''; switch ($type) { @@ -591,7 +591,7 @@ function print_event_type_description ($type, $return = false) { * * @return array An array with all the events happened. */ -function get_group_events ($id_group, $period, $date) { +function events_get_group ($id_group, $period, $date) { global $config; $id_group = safe_acl_group ($config["id_user"], $id_group, "AR"); @@ -623,7 +623,7 @@ function get_group_events ($id_group, $period, $date) { * * @return array An array with all the events happened. */ -function get_agent_events ($id_agent, $period, $date = 0) { +function events_get_agent ($id_agent, $period, $date = 0) { if (!is_numeric ($date)) { $date = strtotime ($date); } @@ -654,7 +654,7 @@ function get_agent_events ($id_agent, $period, $date = 0) { * * @return array An array with all the events happened. */ -function get_module_events ($id_agent_module, $period, $date = 0) { +function events_get_module ($id_agent_module, $period, $date = 0) { if (!is_numeric ($date)) { $date = strtotime ($date); } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index ba9e73f4c8..8dad782f73 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -921,7 +921,7 @@ function event_reporting ($id_group, $period, $date = 0, $return = false) { $table->head[2] = __('User ID'); $table->head[3] = __('Timestamp'); - $events = get_group_events ($id_group, $period, $date); + $events = events_get_group ($id_group, $period, $date); if (empty ($events)) { $events = array (); } @@ -1600,7 +1600,7 @@ function get_agents_detailed_event_reporting ($id_agents, $period = 0, $date = 0 $events = array (); foreach ($id_agents as $id_agent) { - $event = get_agent_events ($id_agent, (int) $period, (int) $date); + $event = events_get_agent ($id_agent, (int) $period, (int) $date); if (!empty ($event)) { array_push ($events, $event); } @@ -1651,7 +1651,7 @@ function get_group_detailed_event_reporting ($id_group, $period = 0, $date = 0, $table->head[2] = __('Criticity'); $table->head[3] = __('Timestamp'); - $events = get_group_events($id_group, $period, $date); + $events = events_get_group($id_group, $period, $date); if ($events) { foreach ($events as $event) { @@ -1715,7 +1715,7 @@ function get_module_detailed_event_reporting ($id_modules, $period = 0, $date = $events = array (); foreach ($id_modules as $id_module) { - $event = get_module_events ($id_module, (int) $period, (int) $date); + $event = events_get_module ($id_module, (int) $period, (int) $date); if (!empty ($event)) { array_push ($events, $event); } diff --git a/pandora_console/index.php b/pandora_console/index.php index bbcb5bc3fd..f44456e9a7 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -145,13 +145,13 @@ if (! isset ($config['id_user']) && isset ($_GET["loginhash"])) { $loginhash_user = get_parameter("loginhash_user", ""); if ($config["loginhash_pwd"] != "" && $loginhash_data == md5($loginhash_user.$config["loginhash_pwd"])) { - logon_db ($loginhash_user, $_SERVER['REMOTE_ADDR']); + db_logon ($loginhash_user, $_SERVER['REMOTE_ADDR']); $_SESSION['id_usuario'] = $loginhash_user; $config["id_user"] = $loginhash_user; } else { require_once ('general/login_page.php'); - pandora_audit("Logon Failed (loginhash", "", "system"); + db_pandora_audit("Logon Failed (loginhash", "", "system"); while (@ob_end_flush ()); exit (""); } @@ -162,8 +162,8 @@ elseif (! isset ($config['id_user']) && isset ($_GET["login"])) { $config["auth_error"] = ""; //Set this to the error message from the authorization mechanism $nick = get_parameter_post ("nick"); //This is the variable with the login $pass = get_parameter_post ("pass"); //This is the variable with the password - $nick = escape_string_sql($nick); - $pass = escape_string_sql($pass); + $nick = db_escape_string_sql($nick); + $pass = db_escape_string_sql($pass); // process_user_login is a virtual function which should be defined in each auth file. // It accepts username and password. The rest should be internal to the auth file. // The auth file can set $config["auth_error"] to an informative error output or reference their internal error messages to it @@ -173,7 +173,7 @@ elseif (! isset ($config['id_user']) && isset ($_GET["login"])) { if ($nick_in_db !== false) { unset ($_GET["sec2"]); $_GET["sec"] = "general/logon_ok"; - logon_db ($nick_in_db, $_SERVER['REMOTE_ADDR']); + db_logon ($nick_in_db, $_SERVER['REMOTE_ADDR']); $_SESSION['id_usuario'] = $nick_in_db; $config['id_user'] = $nick_in_db; //Remove everything that might have to do with people's passwords or logins @@ -195,7 +195,7 @@ elseif (! isset ($config['id_user']) && isset ($_GET["login"])) { // User not known $login_failed = true; require_once ('general/login_page.php'); - pandora_audit("Logon Failed", "Invalid login: ".$nick, $nick); + db_pandora_audit("Logon Failed", "Invalid login: ".$nick, $nick); while (@ob_end_flush ()); exit (""); } @@ -211,7 +211,7 @@ elseif (! isset ($config['id_user'])) { if (isset ($_GET["bye"])) { include ("general/logoff.php"); $iduser = $_SESSION["id_usuario"]; - logoff_db ($iduser, $_SERVER['REMOTE_ADDR']); + db_logoff ($iduser, $_SERVER['REMOTE_ADDR']); // Unregister Session (compatible with 5.2 and 6.x, old code was deprecated unset($_SESSION['id_usuario']); unset($iduser); @@ -290,7 +290,7 @@ if ($config["pure"] == 0) { } while (@ob_end_flush ()); -print_database_debug (); +db_print_database_debug (); echo ''; $run_time = format_numeric (microtime (true) - $config['start_time'], 3); diff --git a/pandora_console/operation/agentes/status_events.php b/pandora_console/operation/agentes/status_events.php index 9e7d9687d5..d0aa02df6b 100644 --- a/pandora_console/operation/agentes/status_events.php +++ b/pandora_console/operation/agentes/status_events.php @@ -25,6 +25,6 @@ if (!isset($id_agente)){ require_once ("include/functions_events.php"); echo "

".__('Latest events for this agent')."

"; -print_events_table ("WHERE id_agente = $id_agente", $limit = 10, $width=750); +events_print_event_table ("WHERE id_agente = $id_agente", $limit = 10, $width=750); ?> diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index f2f2dbcaaa..08aa8d42f0 100644 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -226,7 +226,7 @@ echo '
'; // Last events information // -------------------------------------------------------------------------- -print_events_table ("WHERE estado<>1 ", 10, "100%"); +events_print_event_table ("WHERE estado<>1 ", 10, "100%"); // -------------------------------------------------------------------------- diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index ffb8ac44d3..6c81a88fde 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -39,14 +39,14 @@ if (is_ajax ()) { if ($get_event_tooltip) { $id = (int) get_parameter ('id'); - $event = get_event ($id); + $event = events_get_event ($id); if ($event === false) return; echo '

'.__('Event').'

'; echo ''.__('Type').':
'; - print_event_type_img ($event["event_type"]); + events_print_type_img ($event["event_type"]); echo ' '; if ($event["event_type"] == "system") { echo __('System'); @@ -71,7 +71,7 @@ if (is_ajax ()) { if ($standby_alert) { $id = (int) get_parameter ('id'); - $event = get_event ($id); + $event = events_get_event ($id); if ($event === false) return; @@ -87,11 +87,11 @@ if (is_ajax ()) { // Set off the standby mode when close an event if($new_status == 1) { - $event = get_event ($id); + $event = events_get_event ($id); alerts_agent_module_standby ($event['id_alert_am'], 0); } - $return = validate_event ($id, $similars, $comment, $new_status); + $return = events_validate_event ($id, $similars, $comment, $new_status); if ($return) echo 'ok'; else @@ -103,7 +103,7 @@ if (is_ajax ()) { $id = (array) get_parameter ("id"); $similars = (bool) get_parameter ('similars'); - $return = delete_event ($id, $similars); + $return = events_delete_event ($id, $similars); if ($return) echo 'ok'; else @@ -243,14 +243,14 @@ if ($validate) { // Avoid to re-set inprocess events if($new_status == 2) { foreach($ids as $key => $id) { - $event = get_event($id); + $event = events_get_event($id); if($event['estado'] == 2) { unset($ids[$key]); } } } if(isset($ids[0]) && $ids[0] != -1){ - $return = validate_event ($ids, ($group_rep == 1), $comment, $new_status); + $return = events_validate_event ($ids, ($group_rep == 1), $comment, $new_status); if($new_status == 1) { ui_print_result_message ($return, __('Successfully validated'), @@ -269,7 +269,7 @@ if ($delete) { $ids = (array) get_parameter ("eventid", -1); if ($ids[0] != -1) { - $return = delete_event ($ids, ($group_rep == 1)); + $return = events_delete_event ($ids, ($group_rep == 1)); ui_print_result_message ($return, __('Successfully deleted'), __('Could not be deleted')); diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 10efbc353a..16457030c5 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -533,7 +533,7 @@ foreach ($result as $event) { $string .= ''; $string .= ''; $string .= '' . __('Type') . ':'; - $string .= print_event_type_img ($event["event_type"], true).' '.print_event_type_description($event["event_type"], true); + $string .= events_print_type_img ($event["event_type"], true).' '.events_print_type_description($event["event_type"], true); $string .= ''; $string .= ''; $string .= '' . __('Agent name') . ':'; diff --git a/pandora_console/operation/events/events_validate.php b/pandora_console/operation/events/events_validate.php index 2060067ca1..2689b5b536 100644 --- a/pandora_console/operation/events/events_validate.php +++ b/pandora_console/operation/events/events_validate.php @@ -60,7 +60,7 @@ $table->align[0] = 'center'; $table->data = array(); foreach($ids as $key => $id) { - $event = get_event($id); + $event = events_get_event($id); // Colored box switch($event["estado"]) { case 0: diff --git a/pandora_console/operation/incidents/incident_detail.php b/pandora_console/operation/incidents/incident_detail.php index 04db1d38f4..2329aa958c 100755 --- a/pandora_console/operation/incidents/incident_detail.php +++ b/pandora_console/operation/incidents/incident_detail.php @@ -171,8 +171,8 @@ elseif (isset ($_GET["insert_form"])) { if (isset ($_GET["from_event"])) { $event = get_parameter_get ("from_event"); - $titulo = get_event_description ($event); - $id_grupo = get_event_group ($event); + $titulo = events_get_description ($event); + $id_grupo = events_get_group ($event); $origen = "Pandora FMS event"; unset ($event); } diff --git a/pandora_console/operation/integria_incidents/incident_detail.php b/pandora_console/operation/integria_incidents/incident_detail.php index 04db1d38f4..2329aa958c 100755 --- a/pandora_console/operation/integria_incidents/incident_detail.php +++ b/pandora_console/operation/integria_incidents/incident_detail.php @@ -171,8 +171,8 @@ elseif (isset ($_GET["insert_form"])) { if (isset ($_GET["from_event"])) { $event = get_parameter_get ("from_event"); - $titulo = get_event_description ($event); - $id_grupo = get_event_group ($event); + $titulo = events_get_description ($event); + $id_grupo = events_get_group ($event); $origen = "Pandora FMS event"; unset ($event); } diff --git a/pandora_console/operation/reporting/reporting_xml.php b/pandora_console/operation/reporting/reporting_xml.php index 88b9446c09..4ab64377a1 100644 --- a/pandora_console/operation/reporting/reporting_xml.php +++ b/pandora_console/operation/reporting/reporting_xml.php @@ -346,7 +346,7 @@ foreach ($contents as $content) { $date = get_system_time (); - $events = get_agent_events ($content['id_agent'], $content['period'], $date ); + $events = events_get_agent ($content['id_agent'], $content['period'], $date ); if (empty ($events)) { $events = array (); }