diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7a39b65a0d..6f9481c895 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2011-08-17 Juan Manuel Ramon + + * include/db/oracle.php + include/functions_config.php + operation/agentes/estado_ultimopaquete.php + godmode/agentes/agent_manager.php: Changed some queries in order to make + them compatible with Oracle. + 2011-08-17 Dario Rodriguez * pandoradb_data.sql, images/os_icons/so_vmware.png, diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 45f6adc96e..f0d809e6c8 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -14,6 +14,9 @@ // GNU General Public License for more details. if (is_ajax ()) { + + global $config; + $search_parents = (bool) get_parameter ('search_parents'); if ($search_parents) { @@ -23,7 +26,16 @@ if (is_ajax ()) { $string = (string) get_parameter ('q'); /* q is what autocomplete plugin gives */ $filter = array (); - $filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")'; + + switch ($config['db_type']){ + case "mysql": + case "postgresql": + $filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")'; + break; + case "oracle": + $filter[] = '(upper(nombre) LIKE upper("%'.$string.'%") OR upper(direccion) LIKE upper("%'.$string.'%") OR upper(comentarios) LIKE upper("%'.$string.'%"))'; + break; + } $filter[] = 'id_agente != '.$id_agent; $agents = agents_get_agents ($filter, array ('nombre', 'direccion')); diff --git a/pandora_console/include/db/oracle.php b/pandora_console/include/db/oracle.php index b1752c09b7..e2ff875c8f 100644 --- a/pandora_console/include/db/oracle.php +++ b/pandora_console/include/db/oracle.php @@ -468,7 +468,6 @@ function oracle_db_get_value_filter ($field, $table, $filter, $where_join = 'AND $sql = sprintf ("SELECT * FROM (SELECT %s FROM %s WHERE %s) WHERE rownum < 2", $field, $table, db_format_array_where_clause_sql ($filter, $where_join)); - $result = db_get_all_rows_sql ($sql); if ($result === false) @@ -570,12 +569,24 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi $i = 1; $max = count ($values); - foreach ($values as $field => $value) { + foreach ($values as $field => $value) { if ($i == 1) { $query .= ' ( '; - } - - if (is_numeric ($field)) { + } + if ($field == '1' AND $value == '1'){ + $query .= sprintf("'%s' = '%s'", $field, $value); + + if ($i < $max) { + $query .= ' '.$join.' '; + } + if ($i == $max) { + $query .= ' ) '; + } + $i++; + continue; + + } + else if (is_numeric ($field)) { /* User provide the exact operation to do */ $query .= $value; @@ -592,7 +603,7 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi if (is_null ($value)) { $query .= sprintf ("%s IS NULL", $field); } - elseif (is_int ($value) || is_bool ($value)) { + elseif (is_int ($value) || is_bool ($value)) { $query .= sprintf ("%s = %d", $field, $value); } else if (is_float ($value) || is_double ($value)) { @@ -619,7 +630,7 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi else if ($value[0] == '%') { $query .= sprintf ("%s LIKE '%s'", $field, $value); } - else { + else{ $query .= sprintf ("%s = '%s'", $field, $value); } } @@ -632,7 +643,6 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi } $i++; } - return (! empty ($query) ? $prefix: '').$query.$limit.$group.$order; } @@ -688,7 +698,6 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi * clause of an SQL sentence. **/ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) { - $fields = array (); if (! is_array ($values) || empty($sql)) { @@ -806,7 +815,7 @@ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) { $i++; } - $result = $pre_query.$sql.$query.$limit.$group.$order.$post_query; + $result = $pre_query.$sql.$query.$limit.$group.$order.$post_query; if ($return){ return $result; } diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index c9f283da96..084e14d9f3 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -679,7 +679,8 @@ function config_check (){ } // Get remote file dir. - $remote_config = db_get_sql ("SELECT `value` FROM tconfig WHERE `token` = 'remote_config'"); + $remote_config = db_get_value_filter('value', 'tconfig', array('token' => 'remote_config')); + if (defined ('PANDORA_ENTERPRISE')){ if (!is_writable ($remote_config)){ @@ -711,8 +712,7 @@ function config_check (){ } // Check database maintance - - $db_maintance = db_get_sql ("SELECT `value` FROM tconfig WHERE `token` = 'db_maintance'"); + $db_maintance = db_get_value_filter ('value', 'tconfig', array('token' => 'db_maintance')); $now = date("U"); // First action in order to know if it's a new installation or db maintenance never have been executed @@ -727,7 +727,7 @@ function config_check (){ $_SESSION["alert_msg"] .= __('Your database is not well maintained. Seems that it have more than 48hr without a proper maintance. Please review Pandora FMS documentation about how to execute this maintance process (pandora_db.pl) and enable it as soon as possible').''; } - $fontpath = db_get_sql ("SELECT `value` FROM tconfig WHERE `token` = 'fontpath'"); + $fontpath = db_get_value_filter('value', 'tconfig', array('token' => 'fontpath')); if (($fontpath == "") OR (!file_exists ($fontpath))) { $config["alert_cnt"]++; $_SESSION["alert_msg"] .= '

'.__("Default font doesnt exist").'

'; diff --git a/pandora_console/operation/agentes/estado_ultimopaquete.php b/pandora_console/operation/agentes/estado_ultimopaquete.php index 8ac5fce03f..7f5f918cbb 100644 --- a/pandora_console/operation/agentes/estado_ultimopaquete.php +++ b/pandora_console/operation/agentes/estado_ultimopaquete.php @@ -342,6 +342,9 @@ foreach ($modules as $module) { } echo ""; } + else{ + echo ""; + } if ($module["id_tipo_modulo"] == 24) { // Log4x echo " "; @@ -394,7 +397,6 @@ foreach ($modules as $module) { $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=3600&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=60','hour_".$win_handle."')"; echo '' . html_print_image("images/grafica_h.png", true, array("border" => '0', "alt" => "")) . ''; - }