From cd334b3244ba463a77db150d8910e4f267ed9c32 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 28 Feb 2011 16:49:44 +0000 Subject: [PATCH] 2011-02-28 Miguel de Dios * include/functions_db.php: cleaned source code, and erased the deprecated function "dame_id_grupo". *extensions/update_manager.php, operation/agentes/export_csv.php, godmode/agentes/module_manager.php, godmode/agentes/modificar_agente.php, godmode/agentes/configurar_agente.php: replaced obsolete "dame_id_grupo" to "get_agent_group". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4027 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 ++++ pandora_console/extensions/update_manager.php | 4 +- .../godmode/agentes/configurar_agente.php | 2 +- .../godmode/agentes/modificar_agente.php | 2 +- .../godmode/agentes/module_manager.php | 2 +- pandora_console/include/functions_db.php | 41 ++++++++----------- .../operation/agentes/export_csv.php | 2 +- 7 files changed, 33 insertions(+), 29 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 1e99f5d124..22482a7146 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2011-02-28 Miguel de Dios + * include/functions_db.php: cleaned source code, and erased the deprecated + function "dame_id_grupo". + + *extensions/update_manager.php, operation/agentes/export_csv.php, + godmode/agentes/module_manager.php, godmode/agentes/modificar_agente.php, + godmode/agentes/configurar_agente.php: replaced obsolete "dame_id_grupo" to + "get_agent_group". + 2011-02-28 Miguel de Dios * extensions/update_manager.php: replaced obsolete "give_acl" to "check_acl" and erased the "give_acl". diff --git a/pandora_console/extensions/update_manager.php b/pandora_console/extensions/update_manager.php index 9cf48646b3..49ad444e15 100644 --- a/pandora_console/extensions/update_manager.php +++ b/pandora_console/extensions/update_manager.php @@ -69,7 +69,7 @@ function pandora_update_manager_main () { global $config; global $db; - if (! give_acl ($config['id_user'], 0, "PM")) { + if (! check_acl($config['id_user'], 0, "PM")) { require ("general/noaccess.php"); return; } @@ -124,7 +124,7 @@ function pandora_update_manager_godmode () { } if(isset($config['id_user'])) { - if (give_acl ($config['id_user'], 0, "PM")) { + if (check_acl($config['id_user'], 0, "PM")) { add_operation_menu_option (__('Update manager')); add_godmode_menu_option (__('Update manager settings'), 'PM','gsetup'); add_extension_main_function ('pandora_update_manager_main'); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 2ebf172da9..20729cc7b1 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -750,7 +750,7 @@ if ($create_module) { if ($delete_module) { // DELETE agent module ! $id_borrar_modulo = (int) get_parameter_get ("delete_module",0); $module_data = get_db_row ('tagente_modulo', 'id_agente_modulo', $id_borrar_modulo); - $id_grupo = (int) dame_id_grupo ($id_agente); + $id_grupo = (int) get_agent_group($id_agente); if (! check_acl ($config["id_user"], $id_grupo, "AW")) { pandora_audit("ACL Violation", diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index a80cfa9069..794c731a8b 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -45,7 +45,7 @@ $agent_to_delete = (int)get_parameter('borrar_agente'); if (!empty($agent_to_delete)) { $id_agente = $agent_to_delete; $agent_name = get_agent_name ($id_agente); - $id_grupo = dame_id_grupo ($id_agente); + $id_grupo = get_agent_group($id_agente); if (check_acl ($config["id_user"], $id_grupo, "AW")==1) { $id_agentes[0] = $id_agente; delete_agent($id_agentes); diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 90140cb9f6..02b148937e 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -81,7 +81,7 @@ if ($multiple_delete) { $id_agent_modules_delete = (array)get_parameter('id_delete'); foreach($id_agent_modules_delete as $id_agent_module_del) { - $id_grupo = (int) dame_id_grupo ($id_agente); + $id_grupo = (int) get_agent_group($id_agente); if (! check_acl ($config["id_user"], $id_grupo, "AW")) { pandora_audit("ACL Violation", diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 7c8447ceb2..b98be1db90 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -71,7 +71,7 @@ function check_login () { } if ((isset($_SESSION["id_usuario"])) AND ($_SESSION["id_usuario"] != "")) { - if (is_user($_SESSION["id_usuario"])) { + if (is_user ($_SESSION["id_usuario"])) { return 0; } } @@ -314,7 +314,8 @@ function safe_acl_group ($id_user, $id_groups, $access) { if ($id_groups == 0) return array_keys (get_user_groups ($id_user, $access)); return array ($id_groups); - } elseif (!is_array ($id_groups)) { + } + elseif (!is_array ($id_groups)) { return array (); } @@ -340,7 +341,7 @@ function safe_acl_group ($id_user, $id_groups, $access) { * * @return int Return the id of row in tsesion or false in case of fail. */ -function pandora_audit ($accion, $descripcion, $user_id = false, $ip = false, $info = '') { +function pandora_audit($accion, $descripcion, $user_id = false, $ip = false, $info = '') { global $config; if ($ip !== false) { @@ -894,15 +895,15 @@ function get_agent_name ($id_agent, $case = "none") { // Version 3.0 has enforced case sensitive agent names // so we always should show real case names. switch ($case) { - case "upper": - return mb_strtoupper ($agent,"UTF-8"); - break; - case "lower": - return mb_strtolower ($agent,"UTF-8"); - break; - case "none": - default: - return ($agent); + case "upper": + return mb_strtoupper ($agent,"UTF-8"); + break; + case "lower": + return mb_strtolower ($agent,"UTF-8"); + break; + case "none": + default: + return ($agent); } } @@ -1343,7 +1344,7 @@ function get_alerts_fired ($alerts, $period = 0, $date = 0) { $agents = array (); foreach ($alerts as $alert) { - if (isset($alert['id'])){ + if (isset($alert['id'])) { $fires = get_alert_fires_in_period ($alert['id'], $period, $date); if (! $fires) { continue; @@ -1426,7 +1427,8 @@ function get_moduletypes ($type = "all", $rows = "nombre") { $row_cnt = count ($rows); if ($type == "remote") { return array_merge (range (6,18), (array) 100); - } elseif ($type == "agent") { + } + elseif ($type == "agent") { return array_merge (range (1,4), range (19,24)); } @@ -1439,7 +1441,8 @@ function get_moduletypes ($type = "all", $rows = "nombre") { foreach ($result as $type) { if ($row_cnt > 1) { $return[$type["id_tipo"]] = $type; - } else { + } + else { $return[$type["id_tipo"]] = $type[reset ($rows)]; } } @@ -1447,14 +1450,6 @@ function get_moduletypes ($type = "all", $rows = "nombre") { } -/** - * @deprecated Use get_agent_group ($id) now (fully compatible) - */ -function dame_id_grupo ($id_agent) { - return get_agent_group ($id_agent); -} - - /** * Get the number of pandora data packets in the database. * diff --git a/pandora_console/operation/agentes/export_csv.php b/pandora_console/operation/agentes/export_csv.php index 240b3c1133..b9f13dc4eb 100644 --- a/pandora_console/operation/agentes/export_csv.php +++ b/pandora_console/operation/agentes/export_csv.php @@ -29,7 +29,7 @@ if (isset ($_GET["agentmodule"]) && isset ($_GET["agent"]) ){ $id_agentmodule = $_GET["agentmodule"]; $id_agent = $_GET["agent"]; $agentmodule_name = get_agentmodule_name ($id_agentmodule); - if (! check_acl ($config['id_user'], dame_id_grupo ($id_agent), "AR")) { + if (! check_acl ($config['id_user'], get_agent_group($id_agent), "AR")) { pandora_audit("ACL Violation", "Trying to access Agent Export Data"); require ("../../general/noaccess.php");