From ff37d1e362b7c77d9c832e24cd33616c9ba67610 Mon Sep 17 00:00:00 2001 From: guruevi Date: Wed, 10 Dec 2008 20:15:38 +0000 Subject: [PATCH] 2008-12-10 Evi Vanoost * include/functions.php: format_for_graph is now much simpler and uses format_numeric. * include/functions_db.php: give_note_author, give_incident_author, dame_numero_notas, borrar_incidencia, event_insert and return_event_description are now in their respective functions_*.php files but under a new name. Fixed delete_agent transaction error detection * include/functions_events.php: Added get_event_description and create_event (formerly return_event_description and event_insert) * include/functions_html.php: print_timestamp attributes should be default empty, not required. Added print_username for a consistent username print * operation/agentes/ver_agente.php: Function renaming (create_event) * operation/incidents/incident.php: Partial rewrite. Uses new functions. Also added some of feature request #2264838 * operation/incidents/incident_detail.php: Partial rewrite. Uses new functions. Added some of feature request #2264838 functionality. * operation/incidents/incident_search.php, operation/incidents/incident_statistics.php: Minor style update * pandoradb.sql: New tincidencia and tnota layout. No use for tnota_inc * include/functions_incidents.php: All incidents functions. Documentation will be online soon. Also includes an upgrade mechanism for SVN users. Mechanism should be removed for a stable version and integrated into install/upgrade tool. * lib/PandoraFMS/DB.pm: New table layout doesn't require timestamp anymore git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1285 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 34 ++ pandora_console/include/functions.php | 28 +- pandora_console/include/functions_db.php | 107 +----- pandora_console/include/functions_events.php | 37 +++ pandora_console/include/functions_html.php | 19 +- .../operation/agentes/ver_agente.php | 6 +- .../operation/incidents/incident.php | 267 +++++++-------- .../operation/incidents/incident_detail.php | 313 ++++++++---------- .../operation/incidents/incident_search.php | 4 +- .../incidents/incident_statistics.php | 6 +- pandora_console/pandoradb.sql | 31 +- 11 files changed, 378 insertions(+), 474 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 968712401f..f479f8e9af 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,37 @@ +2008-12-10 Evi Vanoost + + * include/functions.php: format_for_graph is now much simpler and uses + format_numeric. + + * include/functions_db.php: give_note_author, give_incident_author, + dame_numero_notas, borrar_incidencia, event_insert and + return_event_description are now in their respective functions_*.php files + but under a new name. Fixed delete_agent transaction error detection + + * include/functions_events.php: Added get_event_description and + create_event (formerly return_event_description and event_insert) + + * include/functions_html.php: print_timestamp attributes should be default + empty, not required. Added print_username for a consistent username print + + * operation/agentes/ver_agente.php: Function renaming (create_event) + + * operation/incidents/incident.php: Partial rewrite. Uses new functions. + Also added some of feature request #2264838 + + * operation/incidents/incident_detail.php: Partial rewrite. Uses new + functions. Added some of feature request #2264838 functionality. + + * operation/incidents/incident_search.php, + operation/incidents/incident_statistics.php: Minor style update + + * pandoradb.sql: New tincidencia and tnota layout. No use for tnota_inc + + * include/functions_incidents.php: All incidents functions. Documentation + will be online soon. Also includes an upgrade mechanism for SVN users. + Mechanism should be removed for a stable version and integrated into + install/upgrade tool. + 2008-12-03 Raul Mateos * include/functions_db.php: Now if no event, table shows "no event" text. diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 4d6057d2d4..176da3236e 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -428,26 +428,16 @@ function format_numeric ($number, $decimals = 1) { * @return A number rendered to be displayed gently on a graph. */ function format_for_graph ($number , $decimals = 1, $dec_point = ".", $thousands_sep = ",") { - if ($number > 1000000000) { - if (fmod ($number, 1000000000) > 0){ - return number_format ($number / 1000000000, $decimals, $dec_point, $thousands_sep)." G"; - } - } - if ($number > 1000000) { - if (fmod ($number, 1000000) > 0) - return number_format ($number / 1000000, $decimals, $dec_point, $thousands_sep)." M"; - return number_format ($number / 1000000, 0, $dec_point, $thousands_sep)." M"; - } + $shorts = array("","K","M","G","T","P"); + $pos = 0; + while ($number>=1000) { //as long as the number can be divided by 1000 + $pos++; //Position in array starting with 0 + $number = $number/1000; + } - if ($number > 1000) { - if (fmod ($number, 1000) > 0) - return number_format ($number / 1000, $decimals, $dec_point, $thousands_sep )." K"; - return number_format ($number / 1000, 0, $dec_point, $thousands_sep )." K"; - } - /* If it has decimals */ - if (fmod ($number, 1)) - return number_format ($number, $decimals, $dec_point, $thousands_sep); - return number_format ($number, 0, $dec_point, $thousands_sep); + $number = $number . $shorts[$pos]; + + return format_numeric ($number, $decimals); //This will actually do the rounding and the decimals } /** diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 75fdf4c832..6a40b5feed 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -397,28 +397,7 @@ function dame_agente_id ($agent_name) { return (int) get_db_value ('id_agente', 'tagente', 'nombre', $agent_name); } -/** - * Get user id of a note. - * - * @param id_note Note id. - * - * @return User id of the given note. - */ -function give_note_author ($id_note) { - return (int) get_db_value ('id_usuario', 'tnota', 'id_nota', (int) $id_note); -} - -/** - * Get description of an event. - * - * @param id_event Event id. - * - * @return Description of the given event. - */ -function return_event_description ($id_event) { - return (string) get_db_value ('evento', 'tevento', 'id_evento', (int) $id_event); -} - + /** * DEPRECATED: Use get_agent_name instead * @@ -803,17 +782,6 @@ function get_alert_last_fire_timestamp_in_period ($id_agent_module, $period, $da return get_db_sql ($sql); } -/** - * Get the author of an incident. - * - * @param id_incident Incident id. - * - * @return The author of an incident - */ -function give_incident_author ($id_incident) { - return (string) get_db_value ('id_usuario', 'tincidencia', 'id_incidencia', (int) $id_incident); -} - /** * Get the server name. * @@ -858,17 +826,6 @@ function dame_id_grupo ($id_agent) { return (int) get_db_value ('id_grupo', 'tagente', 'id_agente', $id_agent); } -/** - * Get the number of notes in a incident. - * - * @param id_incident Incident id - * - * @return The number of notes in given incident. - */ -function dame_numero_notas ($id_incident) { - return (int) get_db_value ('COUNT(*)', 'tnota_inc', 'id_incidencia', $id_incident); -} - /** * Get the number of pandora data in the database. * @@ -900,40 +857,6 @@ function dame_generic_string_data ($id) { return (string) get_db_value ('datos', 'tagente_datos_string', 'id_tagente_datos_string', $id); } -/** - * Delete an incident of the database. - * - * @param id_inc Incident id - */ -function borrar_incidencia ($id_inc) { - global $config; - - $sql = sprintf ("DELETE FROM `tincidencia` WHERE `id_incidencia` = %d", $id_inc); - process_sql ($sql); - $sql = sprintf ("SELECT `id_nota` FROM `tnota_inc` WHERE `id_incidencia` = %d ", $id_inc); - $rows = get_db_all_rows_sql ($sql); - if ($rows){ - foreach ($rows as $row) { - $sql = sprintf ("DELETE FROM `tnota` WHERE `id_nota` = %d",$row["id_nota"]); - process_sql ($sql); - } - $sql = "DELETE FROM `tnota_inc` WHERE `id_incidencia` = $id_inc"; - process_sql ($sql); - } - - // Delete attachments - $sql = sprintf ("SELECT `id_attachment`,`filename` FROM `tattachment` WHERE `id_incidencia` = %d", $id_inc); - $rows = get_db_all_rows_sql ($sql); - if (!empty ($rows)){ - foreach ($rows as $row) { - // Unlink all attached files for this incident - unlink ($config["attachment_store"]."/pand".$row["id_attachment"]."_".$row["filename"]); - } - $sql = sprintf ("DELETE FROM `tattachment` WHERE `id_incidencia` = %d",$id_inc); - process_sql ($sql); - } -} - /** * Get the operating system name. * @@ -1037,32 +960,6 @@ function existe ($id_user) { return true; } -/** - * Insert a event in the event log system. - * - * @param event - * @param id_group - * @param id_agent - * @param status - * @param id_user - * @param event_type - * @param priority - * @param id_agent_module - * @param id_aam - */ -function event_insert ($event, $id_group, $id_agent, $status = 0, - $id_user = '', $event_type = "unknown", $priority = 0, - $id_agent_module = 0, $id_aam = 0) { - $sql = sprintf ('INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, - estado, utimestamp, id_usuario, event_type, criticity, - id_agentmodule, id_alert_am) - VALUES (%d, %d, "%s", NOW(), %d, NOW(), "%s", "%s", %d, %d, %d)', - $id_agent, $id_group, $event, $status, $id_user, $event_type, - $priority, $id_agent_module, $id_aam); - - process_sql ($sql); -} - /** * Get the interval value of an agent module. * @@ -2342,7 +2239,7 @@ function delete_agent ($id_agents) { temp_sql_delete ("tagente", "id_agente", $id_agent); } - if ($errors > 1) { + if ($errors > 0) { process_sql ("ROLLBACK;"); process_sql ("SET AUTOCOMMIT = 1;"); return false; diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index dabd4fe04a..7012bb388b 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -102,4 +102,41 @@ function process_event_validate ($id_event) { function get_event_group ($id_event) { return (int) get_db_value ('id_grupo', 'tevento', 'id_evento', (int) $id_event); } + +/** + * Get description of an event. + * + * @param id_event Event id. + * + * @return Description of the given event. + */ +function get_event_description ($id_event) { + return (string) get_db_value ('evento', 'tevento', 'id_evento', (int) $id_event); +} + +/** + * Insert a event in the event log system. + * + * @param event + * @param id_group + * @param id_agent + * @param status + * @param id_user + * @param event_type + * @param priority + * @param id_agent_module + * @param id_aam + * + * @return 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) { + $sql = sprintf ('INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, + estado, utimestamp, id_usuario, event_type, criticity, + id_agentmodule, id_alert_am) + VALUES (%d, %d, "%s", NOW(), %d, NOW(), "%s", "%s", %d, %d, %d)', + $id_agent, $id_group, $event, $status, $id_user, $event_type, + $priority, $id_agent_module, $id_aam); + + return (int) process_sql ($sql, "insert_id"); +} ?> \ No newline at end of file diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 1e816a1e08..3945ec659d 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -627,7 +627,7 @@ function print_error_message ($result, $good = '', $bad = '', $attributes = '', * @param string $tag: If it should be in a different tag than span * @param bool $return whether to output the string or return it */ -function print_timestamp ($unixtime, $attributes, $tag = "span", $return = false) { +function print_timestamp ($unixtime, $attributes = "", $tag = "span", $return = false) { global $config; if (!is_numeric ($unixtime)) { @@ -660,4 +660,21 @@ function print_timestamp ($unixtime, $attributes, $tag = "span", $return = false } return $output; } + +/** + * Prints a username with real name, link to the user_edit page etc. + * + * @param username (string) The username + * @param return (bool) Whether to return or print + * + * @return (string) The full '.dame_nombre_real ($username).''; + if ($return === false) { + echo $string; + } + return $string; +} ?> \ No newline at end of file diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 83e7d8c01b..ea485c7228 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -18,6 +18,8 @@ // Load global vars require_once ("include/config.php"); +require_once ("include/functions_events.php"); + enterprise_include ('operation/agentes/ver_agente.php'); check_login (); @@ -154,10 +156,10 @@ if ($validate_alert != ""){ // Single alerts if ($alert_row["id_agente_modulo"] != 0){ - event_insert("Manual validation of alert for '$alert_name'", $ag_row["id_grupo"], $am_row["id_agente"], 1, $config["id_user"], "alert_manual_validation", 1, $alert_row["id_agente_modulo"], $validate_alert); + create_event ("Manual validation of alert for '$alert_name'", $ag_row["id_grupo"], $am_row["id_agente"], 1, $config["id_user"], "alert_manual_validation", 1, $alert_row["id_agente_modulo"], $validate_alert); // Combined alerts } else { - event_insert("Manual validation of alert for '$alert_name'", $ag_row["id_grupo"], $alert_row ["id_agent"], 1, $config["id_user"], "alert_manual_validation", 1, 0, $validate_alert); + create_event ("Manual validation of alert for '$alert_name'", $ag_row["id_grupo"], $alert_row ["id_agent"], 1, $config["id_user"], "alert_manual_validation", 1, 0, $validate_alert); } $sql='UPDATE talerta_agente_modulo SET times_fired = 0, internal_counter = 0 WHERE id_aam = '.$validate_alert; $result=mysql_query($sql); diff --git a/pandora_console/operation/incidents/incident.php b/pandora_console/operation/incidents/incident.php index a795777833..a8e819d09b 100644 --- a/pandora_console/operation/incidents/incident.php +++ b/pandora_console/operation/incidents/incident.php @@ -16,14 +16,13 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - -require ("include/config.php"); +require_once ("include/config.php"); +require_once ("include/functions_incidents.php"); check_login (); if (! give_acl ($config['id_user'], 0, "IR")) { - audit_db($config['id_user'],$REMOTE_ADDR, "ACL Violation","Trying to access incident viewer"); + audit_db($config['id_user'],$config["remote_addr"], "ACL Violation","Trying to access incident viewer"); require ("general/noaccess.php"); exit; } @@ -37,78 +36,87 @@ if (isset($_GET["offset"])) { $offset = 0; } -// Delete incident -if (isset($_GET["quick_delete"])){ - $id_inc = get_parameter_get ("quick_delete"); - $sql = "SELECT id_usuario, id_grupo FROM tincidencia WHERE id_incidencia=".$id_inc; - $result = get_db_row_sql ($sql); - $usuario = give_incident_author ($id_inc); - - if ($result !== false) { - if (give_acl ($config['id_user'], $result["id_grupo"], "IM") || $config["id_user"] == $result["id_usuario"]) { - borrar_incidencia ($id_inc); - echo '

'.__('Incident successfully deleted').'

'; - audit_db ($usuario,$REMOTE_ADDR,"Incident deleted","User ".$config['id_user']." deleted incident #".$id_inc); - } else { - audit_db ($usuario,$REMOTE_ADDR,"ACL Forbidden","User ".$_SESSION["id_usuario"]." tried to delete incident"); - echo '

'.__('There was a problem deleting incident').'

'; - no_permission (); - } - } -} +// Check action. Try to get author and group +$action = get_parameter_get ("action"); -// UPDATE incident -if ((isset ($_GET["action"])) AND ($_GET["action"] == "update")) { - $id_inc = get_parameter_post ("id_inc"); - $usuario = give_incident_author ($id_inc); - $grupo = get_parameter_post ("grupo_form"); +if ($action == "mass") { + $id_inc = get_parameter_post ("id_inc", array ()); + $delete_btn = get_parameter_post ("delete_btn", -1); + $own_btn = get_parameter_post ("own_btn", -1); - if (give_acl ($config['id_user'], $grupo, "IM") || $usuario == $config['id_user']) { // Only admins (manage incident) or owners can modify incidents - $titulo = get_parameter_post ("titulo"); - $descripcion = get_parameter_post ("descripcion"); - $origen = get_parameter_post ("origen_form"); - $prioridad = get_parameter_post ("prioridad_form"); - $estado = get_parameter_post ("estado_form"); - $ahora = date ("Y/m/d H:i:s"); - - $sql = sprintf ("UPDATE tincidencia SET actualizacion = '%s', titulo = '%s', origen = '%s', estado = %d, id_grupo = %d, id_usuario = '%s', prioridad = %d, descripcion = '%s' WHERE id_incidencia = %d", - $ahora, $titulo, $origen, $estado, $grupo, $usuario, $prioridad, $descripcion, $id_inc); - $result = process_sql ($sql); - - if ($result !== false) { - audit_db($usuario,$REMOTE_ADDR,"Incident updated","User ".$config['id_user']." updated incident #".$id_inc); - echo '

'.__('Incident successfully updated').'

'; - } else { - echo '

'.__('There was a problem updating the incident').'

'; + foreach ($id_inc as $incident) { + if (give_acl ($config['id_user'], get_incidents_group ($incident), "IM") || get_incidents_author ($incident) == $config["id_user"] || get_incidents_owner ($incident) == $config["id_user"]) { + continue; } - } else { - audit_db ($usuario,$REMOTE_ADDR,"ACL Forbidden","User ".$config['id_user']." try to update incident"); - no_permission(); + audit_db ($config["id_user"],$config["remote_addr"],"ACL Forbidden","Mass-update or deletion of incident"); + require ("general/noaccess.php"); + exit; + } + + if ($delete_btn != -1) { + $result = delete_incidents ($id_inc); + print_error_message ($result, __('Incident successfully deleted'), __('There was a problem deleting incident')); + } + if ($own_btn != -1) { + $result = process_incidents_chown ($id_inc, $config["id_user"]); + print_error_message ($result, __('Incident successfully owned'), __('There was a problem becoming owner of incident')); } -} -// INSERT incident -if ((isset ($_GET["action"])) AND ($_GET["action"] == "insert")) { +} elseif ($action == "update") { + $id_inc = get_parameter ("id_inc", 0); + $author = get_incidents_author ($id_inc); + $owner = get_incidents_owner ($id_inc); + $grupo = get_incidents_group ($id_inc); + + if ($author != $config["id_user"] && $owner != $config["id_user"] && !give_acl ($config['id_user'], $grupo, "IM")) { // Only admins (manage incident) or owners/creators can modify incidents + audit_db ($author, $config["remote_addr"], "ACL Forbidden", "Update incident #".$id_inc); + require ("general/noaccess.php"); + exit; + } + + $titulo = get_parameter_post ("titulo"); + $descripcion = get_parameter_post ("descripcion"); + $origen = get_parameter_post ("origen_form"); + $prioridad = get_parameter_post ("prioridad_form", 0); + $estado = get_parameter_post ("estado_form", 0); $grupo = get_parameter_post ("grupo_form", 1); - if (give_acl ($config['id_user'], $grupo, "IM")) { - // Read input variables - $titulo = get_parameter_post ("titulo"); - $descripcion = get_parameter_post ("descripcion"); - $origen = get_parameter_post ("origen_form"); - $prioridad = get_parameter_post ("prioridad_form"); - $id_creator = $config['id_user']; - $estado = get_parameter_post ("estado_form"); - $sql = sprintf ("INSERT INTO tincidencia (inicio, actualizacion, titulo, descripcion, id_usuario, origen, estado, prioridad, id_grupo, id_creator) VALUES (NOW(), NOW(), '%s', '%s', '%s', '%s', %d, %d, '%s', '%s')", $titulo, $descripcion, $config["id_user"], $origen, $estado, $prioridad, $grupo, $config["id_user"]); - $id_inc = process_sql ($sql, "insert_id"); + $usuario = get_parameter_post ("usuario_form", $config["id_user"]); + + $sql = sprintf ("UPDATE tincidencia SET titulo = '%s', origen = '%s', estado = %d, id_grupo = %d, id_usuario = '%s', prioridad = %d, descripcion = '%s', id_lastupdate = '%s' WHERE id_incidencia = %d", + $titulo, $origen, $estado, $grupo, $usuario, $prioridad, $descripcion, $config["id_user"], $id_inc); + $result = process_sql ($sql); - if ($id_inc === false) { - echo '

'.__('Error creating incident').'

'; - } else { - audit_db ($config["id_user"], $REMOTE_ADDR, "Incident created", "User ".$config["id_user"]." created incident #".$id_inc); - } + if ($result !== false) { + audit_db ($config["id_user"], $config["remote_addr"], "Incident updated","User ".$config['id_user']." updated incident #".$id_inc); + } + + print_error_message ($result, __('Incident successfully updated'), __('There was a problem updating incident')); + +} elseif ($action == "insert") { + //Create incident + $grupo = get_parameter_post ("grupo_form", 1); + + if (!give_acl ($config['id_user'], $grupo, "IW")) { + audit_db ($config["id_user"], $config["remote_addr"], "ACL Forbidden", "User ".$config["id_user"]." tried to update incident"); + require ("general/noaccess.php"); + exit; + } + + // Read input variables + $titulo = get_parameter_post ("titulo"); + $descripcion = get_parameter_post ("descripcion"); + $origen = get_parameter_post ("origen_form"); + $prioridad = get_parameter_post ("prioridad_form"); + $id_creator = $config['id_user']; + $estado = get_parameter_post ("estado_form"); + $sql = sprintf ("INSERT INTO tincidencia (inicio, actualizacion, titulo, descripcion, id_usuario, origen, estado, prioridad, id_grupo, id_creator) VALUES + (NOW(), NOW(), '%s', '%s', '%s', '%s', %d, %d, '%s', '%s')", $titulo, $descripcion, $config["id_user"], $origen, $estado, $prioridad, $grupo, $config["id_user"]); + $id_inc = process_sql ($sql, "insert_id"); + + if ($id_inc === false) { + echo '

'.__('Error creating incident').'

'; } else { - audit_db ($config["id_user"],$REMOTE_ADDR,"ACL Forbidden","User tried to create incident"); - no_permission (); + audit_db ($config["id_user"], $config["remote_addr"], "Incident created", "User ".$config["id_user"]." created incident #".$id_inc); } } @@ -131,7 +139,7 @@ $grupo = (int) get_parameter ("grupo", 1); if ($grupo != 1) { $filter .= sprintf (" AND id_grupo = %d", $grupo); if (give_acl ($config['id_user'], $grupo, "IM") == 0) { - audit_db ($config["id_user"],$REMOTE_ADDR,"ACL Forbidden","User tried to read incidents from group without access"); + audit_db ($config["id_user"],$config["remote_addr"],"ACL Forbidden","User tried to read incidents from group without access"); no_permission (); } } @@ -143,7 +151,6 @@ if ($prioridad != -1) //-1 = All $offset = (int) get_parameter ("offset", 0); $groups = get_user_groups ($config["id_user"], "IR"); - //Select incidencts where the user has access to ($groups from //get_user_groups), array_keys for the id, implode to pass to SQL $sql = "SELECT * FROM tincidencia WHERE @@ -164,43 +171,31 @@ echo '

'.__('Incident management').' > '.__('Manage incidents').'

'.__('Filter').'

'; -$fields = array(); //Reset empty array +$fields = get_incidents_status (); $fields[-1] = __('All incidents'); -$fields[0] = __('Active incidents'); -$fields[2] = __('Rejected incidents'); -$fields[3] = __('Expired incidents'); -$fields[13] = __('Closed incidents'); print_select ($fields, "estado", $estado, 'javascript:this.form.submit();', '', '', false, false, false, 'w155'); //Legend echo ' -

'.__('Status').'

- - '.__('Active incidents').'
- - '.__('Active incidents, with comments').'
- - '.__('Rejected incidents').'
- - '.__('Closed incidents').'
- - '.__('Expired incidents').' -

'.__('Priority').'

- - '.__('Very Serious').'
- - '.__('Serious').'
- - '.__('Medium').'
- - '.__('Low').'
- - '.__('Informative').'
- - '.__('Maintenance').'
- - '; -$fields = array(); //Reset empty array +echo '

'.__('Status').'

'; +foreach (get_incidents_status () as $id => $str) { + print_incidents_status_img ($id); + echo ' - ' . $str . '
'; +} + +echo '

'.__('Priority').'

'; +foreach (get_incidents_priorities () as $id => $str) { + print_incidents_priority_img ($id); + echo ' - ' . $str . '
'; +} + +echo ''; + +$fields = get_incidents_priorities (); $fields[-1] = __('All priorities'); -$fields[0] = __('Informative'); -$fields[1] = __('Low'); -$fields[2] = __('Medium'); -$fields[3] = __('Serious'); -$fields[4] = __('Very Serious'); -$fields[10] = __('Maintenance'); print_select ($fields, "prioridad", $prioridad, 'javascript:this.form.submit();', '','',false,false,false,'w155'); @@ -262,7 +257,7 @@ if ($count < 1) { $table->head[5] = __('Updated'); $table->head[6] = __('Source'); $table->head[7] = __('Owner'); - $table->head[8] = __('Delete'); + $table->head[8] = 'X'; $table->size[0] = 43; $table->size[7] = 50; @@ -276,66 +271,27 @@ if ($count < 1) { $data = array(); $data[0] = ''.$row["id_incidencia"].''; - $attnum = get_db_value ('COUNT(*)', 'tattachment', 'id_incidencia', $row["id_incidencia"]); - $notenum = dame_numero_notas ($row["id_incidencia"]); + $attach = get_incidents_attach ($row["id_incidencia"]); - if ($attnum > 0) + if (!empty ($attach)) $data[0] .= '  '; - - if ($notenum > 0 && $row["estado"] == 0) - $row["estado"] = 1; - - switch ($row["estado"]) { - case 0: - $data[1] = ''; - break; - case 1: - $data[1] = ''; - break; - case 2: - $data[1] = ''; - break; - case 3: - $data[1] = ''; - break; - case 13: - $data[1] = ''; - break; - } + + $data[1] = print_incidents_status_img ($row["estado"], true); $data[2] = ''.safe_input (substr ($row["titulo"],0,45)).''; - - switch ($row["prioridad"]) { - case 4: - $data[3] = ''; - break; - case 3: - $data[3] = ''; - break; - case 2: - $data[3] = ''; - break; - case 1: - $data[3] = ''; - break; - case 0: - $data[3] = ''; - break; - case 10: - $data[3] = ''; - break; - } + + $data[3] = print_incidents_priority_img ($row["prioridad"], true); $data[4] = ''; - $data[5] = human_time_comparation ($row["actualizacion"]); + $data[5] = print_timestamp ($row["actualizacion"], "", "span", true); $data[6] = $row["origen"]; - $data[7] = ''.$row["id_usuario"].''; + $data[7] = print_username ($row["id_usuario"], true); - if (give_acl ($config["id_user"], $row["id_grupo"], "IM") || $config["id_user"] == $row["id_usuario"]) { - $data[8] = ''; + if (give_acl ($config["id_user"], $row["id_grupo"], "IM") || $config["id_user"] == $row["id_usuario"] || $config["id_user"] == $row["id_creator"]) { + $data[8] = print_checkbox ("id_inc[]", $row["id_incidencia"], false, true); } else { $data[8] = ''; } @@ -343,13 +299,24 @@ if ($count < 1) { array_push ($table->data, $data); } + echo '
'; print_table ($table); + if (give_acl ($config["id_user"], 0, "IM")) { + echo '
'; + print_submit_button (__('Delete incidents'), 'delete_btn', false, 'class="sub delete"'); + print_submit_button (__('Become owner'), 'own_btn', false, 'class="sub upd"'); + echo '
'; + } + echo '
'; unset ($table); } if (give_acl ($config["id_user"], 0, "IW")) { - echo '
'; + echo '
'; + echo ''; print_submit_button (__('Create incident'), 'crt', false, 'class="sub next"'); - echo '
'; + echo ''; + echo '
'; } +echo '
 
'; ?> diff --git a/pandora_console/operation/incidents/incident_detail.php b/pandora_console/operation/incidents/incident_detail.php index df8fff459d..d3410c141c 100644 --- a/pandora_console/operation/incidents/incident_detail.php +++ b/pandora_console/operation/incidents/incident_detail.php @@ -19,23 +19,25 @@ // Load global vars -require("include/config.php"); +require_once ("include/config.php"); +require_once ("include/functions_incidents.php"); +require_once ("include/functions_events.php"); //To get events group information check_login (); if (! give_acl ($config["id_user"], 0, "IR")) { // Doesn't have access to this page - audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation", "Trying to access incident details"); - include ("general/noaccess.php"); + audit_db ($config["id_user"], $config["remote_addr"], "ACL Violation", "Trying to access incident details"); + require ("general/noaccess.php"); exit; } -$inicio = date('Y-m-d H:i:s'); -$actualizacion = date('Y-m-d H:i:s'); +$inicio = time (); //Just inits the variable +$actualizacion = time (); // EDITION MODE if (isset ($_GET["id"])) { - $id_inc = get_parameter_get ("id"); + $id_inc = get_parameter_get ("id", 0); // Obtain group of this incident $row = get_db_row ("tincidencia","id_incidencia",$id_inc); @@ -43,86 +45,65 @@ if (isset ($_GET["id"])) { // Get values $titulo = $row["titulo"]; $texto = $row["descripcion"]; - $inicio = $row["inicio"]; - $actualizacion = $row["actualizacion"]; + $inicio = strtotime ($row["inicio"]); + $actualizacion = strtotime ($row["actualizacion"]); $estado = $row["estado"]; $prioridad = $row["prioridad"]; $origen = $row["origen"]; - $usuario = $row["id_usuario"]; + $usuario = $row["id_usuario"]; //owner $id_grupo = $row["id_grupo"]; - $id_creator = $row["id_creator"]; - $upd_sql = sprintf ("UPDATE tincidencia SET actualizacion = NOW(), id_usuario = '%s' WHERE id_incidencia = %d", $usuario, $id_inc); + $id_creator = $row["id_creator"]; //creator + $id_lastupdate = $row["id_lastupdate"]; //last updater + // Note add - everybody that can read incidents, can add notes if (isset ($_GET["insertar_nota"])) { $nota = get_parameter_post ("nota"); - $sql = sprintf ("INSERT INTO tnota (id_usuario, timestamp, nota) VALUES ('%s',NOW(),'%s')",$config["id_user"],$nota); + $sql = sprintf ("INSERT INTO tnota (id_usuario, id_incident, nota) VALUES ('%s', %d, '%s')",$config["id_user"],$id_inc, $nota); $id_nota = process_sql ($sql, "insert_id"); if ($id_nota !== false) { - echo '

'.__('Note successfully added').'

'; - $sql = sprintf ("INSERT INTO tnota_inc (id_incidencia, id_nota) VALUES (%d,%d)", $id_inc, $id_nota); - process_sql ($sql); - process_sql ($upd_sql); //Update tincidencia - } else { - echo '

'.__('Error adding note').'

'; + process_incidents_touch ($id_inc); } + print_error_message ($id_nota, __('Note successfully added'), __('Error adding note')); } // Delete note - if (isset ($_GET["id_nota"])) { - $id_nota = get_parameter_get ("id_nota"); - $note_user = give_note_author ($id_nota); - if (((give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($note_user == $config["id_user"])) OR ($id_creator == $config["id_user"]) ) { + if (isset ($_POST["delete_nota"])) { + $id_nota = get_parameter_post ("delete_nota", 0); + $note_user = get_incidents_notes_author ($id_nota); + if (((give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($note_user == $config["id_user"])) OR ($id_owner == $config["id_user"])) { // Only admins (manage incident) or owners can modify - // incidents, including their notes. note authors are + // incidents notes. note authors are // able to delete their own notes - $sql = sprintf ("DELETE FROM tnota WHERE id_nota = %d",$id_nota); - $result = process_sql ($sql); //Result is 0 or false if the note wasn't deleted, therefore check with empty + $result = delete_incidents_note ($id_nota); if (!empty ($result)) { - $sql = sprintf ("DELETE FROM tnota_inc WHERE id_nota = %d",$id_nota); - $result = process_sql ($sql); - } - - if (!empty ($result)) { - process_sql ($upd_sql); //Update tincidencia - echo '

'.__('Note successfully deleted').'

'; - } else { - echo '

'.__('Error deleting note').'

'; + process_incidents_touch ($id_inc); } + print_error_message ($id_nota, __('Note successfully deleted'), __('Error deleting note')); } } // Delete file - if (((give_acl ($config["id_user"], $id_grupo, "IM")==1) OR ($id_creator == $config["id_user"])) AND isset ($_GET["delete_file"])) { - $file_id = get_parameter_get ("delete_file"); - $sql = sprintf ("SELECT filename FROM tattachment WHERE id_attachment = %d",$file_id); - $filename = get_db_sql ($sql); - if (!empty ($filename)) { - $sql = sprintf ("DELETE FROM tattachment WHERE id_attachment = %d",$file_id); - $result = process_sql ($sql); - } else { - echo '

'.__('Could not find file in database').'

'; - $result = false; - } + if (((give_acl ($config["id_user"], $id_grupo, "IM")==1) OR ($id_owner == $config["id_user"])) AND isset ($_POST["delete_file"])) { + $file_id = (int) get_parameter_post ("delete_file", 0); + $filename = get_db_value ("filename", "tattachment", "id_attachment", $file_id); + $sql = sprintf ("DELETE FROM tattachment WHERE id_attachment = %d",$file_id); + $result = process_sql ($sql); if (!empty ($result)) { unlink ($config["attachment_store"]."/pand".$file_id."_".$filename); - process_sql ($upd_sql); //Update tincidencia - echo '

'.__('File successfully deleted from database').'

'; - } else { - echo '

'; + process_incidents_touch ($id_inc); } + + print_error_message ($result, __('File successfully deleted from database'), __('Unable to delete file')); } // Upload file - if ((give_acl ($config["id_user"], $id_grupo, "IW") == 1) AND isset ($_GET["upload_file"]) AND ($_FILES['userfile']['name'] != "")) { //if file - if (isset ($_POST["file_description"])) { - $description = get_parameter_post ("file_description"); - } else { - $description = __("No description available"); - } + if ((give_acl ($config["id_user"], $id_grupo, "IW") == 1) AND isset ($_GET["upload_file"]) AND ($_FILES['userfile']['name'] != "")) { + $description = get_parameter_post ("file_description", __('No description available')); + // Insert into database $filename = safe_input ($_FILES['userfile']['name']); $filesize = safe_input ($_FILES['userfile']['size']); @@ -130,7 +111,7 @@ if (isset ($_GET["id"])) { //The following is if you have clamavlib installed //(php5-clamavlib) and enabled in php.ini //http://www.howtoforge.com/scan_viruses_with_php_clamavlib - if(extension_loaded ('clamav')) { + if (extension_loaded ('clamav')) { cl_setlimits (5, 1000, 200, 0, 10485760); $malware = cl_scanfile ($_FILES['file']['tmp_name']); if ($malware) { @@ -155,12 +136,12 @@ if (isset ($_GET["id"])) { if ($result !== false) { unlink ($_FILES['userfile']['tmp_name']); - process_sql ($upd_sql); //Update tincidencia - echo '

'.__('File uploaded').'

'; + process_incidents_touch ($id_inc); } else { - echo '

'.__('File could not be saved. Contact the Pandora Administrator for more information').'

'; process_sql ("DELETE FROM tattachment WHERE id_attachment = ".$id_attachment); } + + print_error_message ($result, __('File uploaded'), __('File could not be saved. Contact the Pandora Administrator for more information')); } } // else Not given id // Create incident from event... read event data @@ -175,18 +156,19 @@ elseif (isset ($_GET["insert_form"])) { $usuario = $config["id_user"]; $id_creator = $config["id_user"]; - if (isset($_GET["from_event"])) { + if (isset ($_GET["from_event"])) { $event = get_parameter_get ("from_event"); - $titulo = return_event_description ($event); - $descripcion = ""; + $titulo = get_event_description ($event); + $id_grupo = get_event_group ($event); $origen = "Pandora FMS event"; unset ($event); } $prioridad = 0; $id_grupo = 0; } else { - audit_db ($config['id_user'],$REMOTE_ADDR, "HACK","Trying to get to incident details in an unusual way"); - no_permission (); + audit_db ($config['id_user'],$config["remote_addr"], "HACK","Trying to get to incident details in an unusual way"); + require ("general/noaccess.php"); + exit; } @@ -235,8 +217,8 @@ if ((give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $confi echo ''; -echo ''.__('Opened at').''.date ($config['date_format'],strtotime ($inicio)).''; -echo ''.__('Updated at').''.date ($config['date_format'],strtotime ($actualizacion)).''; +echo ''.__('Opened at').''.date ($config['date_format'], $inicio).''; +echo ''.__('Updated at').''.date ($config['date_format'], $actualizacion).''; echo ''.__('Owner').''; @@ -247,16 +229,10 @@ if ((give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $confi } echo ''.__('Status').''; -$fields = array (); -$fields[0] = __('Open and Active'); -$fields[2] = __('Not valid'); -$fields[3] = __('Out of date'); -$fields[13] = __('Closed'); - if ((give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { - print_select ($fields, "estado_form", $estado, '', '', '', false, false, false, 'w135'); + print_select (get_incidents_status (), "estado_form", $estado, '', '', '', false, false, false, 'w135'); } else { - print_select ($fields, "estado_form", $estado, '', '', '', false, false, false, 'w135', true); + print_select (get_incidents_status (), "estado_form", $estado, '', '', '', false, false, false, 'w135', true); } echo ''; @@ -288,18 +264,10 @@ if ((give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $confi echo ''.__('Priority').''; -$fields = array(); -$fields[0] = __('Informative'); -$fields[1] = __('Low'); -$fields[2] = __('Medium'); -$fields[3] = __('Serious'); -$fields[4] = __('Very serious'); -$fields[10] = __('Maintenance'); - if ((give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { - print_select ($fields, "prioridad_form", $prioridad, '', '', '', false, false, false, 'w135'); + print_select (get_incidents_priorities (), "prioridad_form", $prioridad, '', '', '', false, false, false, 'w135'); } else { - print_select ($fields, "prioridad_form", $prioridad, '', '', '', false, false, false, 'w135', true); + print_select (get_incidents_priorities (), "prioridad_form", $prioridad, '', '', '', false, false, false, 'w135', true); } echo ''.__('Creator').''; @@ -319,8 +287,7 @@ if ((give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $confi echo '
'; // Only if user is the used who opened incident or (s)he is admin - -if (isset ($id_inc) AND (give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { +if (isset ($id_inc) AND ((give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"]))) { print_submit_button (__('Update incident'), "accion", false, 'class="sub upd"'); } elseif (give_acl ($config["id_user"], $id_grupo, "IW")) { print_submit_button (__('Create'), "accion", false, 'class="sub wand"'); @@ -329,7 +296,12 @@ if (isset ($id_inc) AND (give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR } echo "
"; +//If we're actually working on an incident if (isset ($id_inc)) { + // ******************************************************************** + // Notes + // ******************************************************************** + echo '
'; print_submit_button (__('Add note'), "note_control", false, 'class="sub next"'); echo '
'; @@ -339,101 +311,96 @@ if (isset ($id_inc)) {
'; - // ******************************************************************** - // Notes - // ******************************************************************** - - if (isset ($id_inc)) { - $sql = sprintf ("SELECT tnota.* FROM tnota, tnota_inc WHERE tnota_inc.id_incidencia = '%d' AND tnota.id_nota = tnota_inc.id_nota",$id_inc); - $result = get_db_all_rows_sql ($sql); - } else { - $result = array (); - } - - if (empty ($result)) { - $result = array (); - } else { - echo "

".__('Notes attached to incident').'

'; - } - - echo ''; + $result = get_incidents_notes ($id_inc); + + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->class = "databox"; + $table->width = 600; + $table->data = array (); + $table->head = array (); + foreach ($result as $row) { - echo ''; - echo ''; - echo ''; + $data[1] = safe_input ($row["nota"]); + array_push ($table->data, $data); } - echo '
'.__('Author').': '.dame_nombre_real ($row["id_usuario"]).' ('.date ($config['date_format'],strtotime ($row["timestamp"])).')
'; + $data = array (); + $data[0] = ''; + $data[1] = __('Author').': '.print_username ($row["id_usuario"], true).' ('.print_timestamp ($row["timestamp"], "", "span", true).')'; + array_push ($table->data, $data); + + $data = array (); + $data[0] = ''; if ((give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($row["id_usuario"] == $config["id_user"])) { - echo ''; + $data[0] .= print_input_image ("delete_nota", "images/cross.png", $row["id_nota"], 'border:0px;" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;', true); } - echo ''.safe_input ($row["nota"]).'
'; -} - -// ************************************************************ -// Files attached to this incident -// ************************************************************ - -// Attach head if there's attach for this incident -if (isset ($id_inc)) { - $result = get_db_all_rows_field_filter ("tattachment", "id_incidencia", $id_inc, "filename"); -} else { - $result = array (); -} - -if (empty ($result)) { - $result = array (); -} else { - echo "

".__('Attached files')."

"; -} - -$table->cellpadding = 4; -$table->cellspacing = 4; -$table->class = "databox"; -$table->width = 650; -$table->head = array (); -$table->data = array (); - -$table->head[0] = __('Filename'); -$table->head[1] = __('Description'); -$table->head[2] = __('Size'); -$table->head[3] = __('Delete'); - -$table->align[2] = "center"; -$table->align[3] = "center"; - -foreach ($result as $row) { - $data[0] = '  '.$row["filename"].''; - $data[1] = $row["description"]; - $data[2] = $row["size"]." KB"; - if ((give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { - $data[3] = ''; - } else { - $data[3] = ''; + + if (!empty ($table->data)) { + echo "

".__('Notes attached to incident').'

'; + echo '
'; + print_table ($table); + echo '
'; } - array_push ($table->data, $data); -} + unset ($table); + -if (!empty ($table->data)) { - print_table ($table); -} -unset ($table); + // ************************************************************ + // Files attached to this incident + // ************************************************************ -// ************************************************************ -// Upload control -// ************************************************************ + $result = get_incidents_attach ($id_inc); + + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->class = "databox"; + $table->width = 650; + $table->head = array (); + $table->data = array (); + + $table->head[0] = __('Filename'); + $table->head[1] = __('Description'); + $table->head[2] = __('Size'); + $table->head[3] = __('Delete'); + + $table->align[2] = "center"; + $table->align[3] = "center"; + + foreach ($result as $row) { + $data[0] = '  '.$row["filename"].''; + $data[1] = $row["description"]; + $data[2] = format_for_graph ($row["size"])."B"; + if ((give_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { + $data[3] = print_input_image ("delete_file", "images/cross.png", $row["id_attachment"], 'border:0px;" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;', true); + } else { + $data[3] = ''; + } + array_push ($table->data, $data); + } + + if (!empty ($table->data)) { + echo "

".__('Attached files')."

"; + echo '
'; + print_table ($table); + echo '
'; + } + unset ($table); + + // ************************************************************ + // Upload control + // ************************************************************ -// Upload control -if ((give_acl($config["id_user"], $id_grupo, "IW")==1) AND (isset ($id_inc))) { - echo '
'; - print_submit_button (__('Add attachment'), "attachment", false, 'class="sub next"'); - echo '
'; - echo '
'; - echo ' - - - -
'.__('Filename').'
'.__('Description').'
'; - + // Upload control + if ((give_acl($config["id_user"], $id_grupo, "IW")==1)) { + echo '
'; + print_submit_button (__('Add attachment'), "attachment", false, 'class="sub next"'); + echo '
'; + echo '
'; + echo ' + + + +
'.__('Filename').'
'.__('Description').'
'; + } } ?> diff --git a/pandora_console/operation/incidents/incident_search.php b/pandora_console/operation/incidents/incident_search.php index 5c027c4d67..767bc11fbf 100644 --- a/pandora_console/operation/incidents/incident_search.php +++ b/pandora_console/operation/incidents/incident_search.php @@ -18,12 +18,12 @@ // Load global vars -require("include/config.php"); +require_once ("include/config.php"); check_login (); if (give_acl ($config['id_user'], 0, "IR") != 1) { - audit_db($config['id_user'],$REMOTE_ADDR, "ACL Violation","Trying to access incident search"); + audit_db($config['id_user'],$config["remote_addr"], "ACL Violation","Trying to access incident search"); require ("general/noaccess.php"); exit; } diff --git a/pandora_console/operation/incidents/incident_statistics.php b/pandora_console/operation/incidents/incident_statistics.php index e17813a410..005fd6aa07 100644 --- a/pandora_console/operation/incidents/incident_statistics.php +++ b/pandora_console/operation/incidents/incident_statistics.php @@ -18,14 +18,14 @@ // Load global vars -require("include/config.php"); +require_once ("include/config.php"); check_login (); if (! give_acl ($config['id_user'], 0, "IR") == 1) { + audit_db ($config['id_user'], $config["remote_addr"], "ACL Violation", "Trying to access Incident section"); require ("general/noaccess.php"); - audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access Incident section"); - return; + exit; } echo "

".__('Incident management')." > ".__('Statistics')."

"; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index fb7e5fedad..173b56f53c 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -318,9 +318,8 @@ CREATE TABLE IF NOT EXISTS `tgrupo` ( PRIMARY KEY (`id_grupo`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - CREATE TABLE IF NOT EXISTS `tincidencia` ( - `id_incidencia` bigint(20) unsigned NOT NULL auto_increment, + `id_incidencia` bigint(6) unsigned zerofill NOT NULL auto_increment, `inicio` datetime NOT NULL default '0000-00-00 00:00:00', `cierre` datetime NOT NULL default '0000-00-00 00:00:00', `titulo` varchar(100) NOT NULL default '', @@ -330,14 +329,16 @@ CREATE TABLE IF NOT EXISTS `tincidencia` ( `estado` int(10) NOT NULL default '0', `prioridad` int(10) NOT NULL default '0', `id_grupo` mediumint(4) unsigned NOT NULL default '0', - `actualizacion` datetime NOT NULL default '0000-00-00 00:00:00', + `actualizacion` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `id_creator` varchar(60) default NULL, + `id_lastupdate` varchar(60) default NULL, + `id_agente_modulo` bigint(100) NOT NULL, `notify_email` tinyint(3) unsigned NOT NULL default '0', PRIMARY KEY (`id_incidencia`), - KEY `incident_index_1` (`id_usuario`,`id_incidencia`) + KEY `incident_index_1` (`id_usuario`,`id_incidencia`), + KEY `id_agente_modulo` (`id_agente_modulo`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - CREATE TABLE IF NOT EXISTS`tlanguage` ( `id_language` varchar(6) NOT NULL default '', `name` varchar(100) NOT NULL default '', @@ -418,23 +419,15 @@ CREATE TABLE IF NOT EXISTS `tnetwork_profile_component` ( KEY `id_np` (`id_np`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - CREATE TABLE IF NOT EXISTS `tnota` ( - `id_nota` mediumint(8) unsigned NOT NULL auto_increment, + `id_nota` bigint(6) unsigned zerofill NOT NULL auto_increment, + `id_incident` bigint(6) unsigned zerofill NOT NULL, `id_usuario` varchar(100) NOT NULL default '0', - `timestamp` tinyblob NOT NULL, + `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, `nota` mediumtext NOT NULL, - PRIMARY KEY (`id_nota`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -CREATE TABLE IF NOT EXISTS `tnota_inc` ( - `id_nota_inc` mediumint(8) unsigned NOT NULL auto_increment, - `id_incidencia` mediumint(9) NOT NULL default '0', - `id_nota` mediumint(9) NOT NULL default '0', - PRIMARY KEY (`id_nota_inc`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - + PRIMARY KEY (`id_nota`), + KEY `id_incident` (`id_incident`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `torigen` ( `origen` varchar(100) NOT NULL default ''