diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index c59c4aa0b3..0845e63870 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -516,10 +516,10 @@ $filter = array (); if ($search_id_group) $filter['id_group'] = $search_id_group; if ($search_string != '') - $filter[] = '(name LIKE "%' . $search_string . '%" ' . - 'OR description LIKE "%'. $search_string . '%" ' . - 'OR tcp_send LIKE "%' . $search_string . '%" ' . - 'OR tcp_rcv LIKE "%' . $search_string . '%")'; + $filter[] = '(name LIKE ' . "'%" . $search_string . "%'" . + 'OR description LIKE ' . "'%". $search_string . "%'" . + 'OR tcp_send LIKE ' . "'%" . $search_string . "%'" . + 'OR tcp_rcv LIKE ' . "'%" . $search_string . "%'" . ')'; $total_components = network_components_get_network_components (false, $filter, 'COUNT(*) AS total'); $total_components = $total_components[0]['total']; diff --git a/pandora_console/include/functions_network_components.php b/pandora_console/include/functions_network_components.php index 26aebb6a1b..9426d75664 100644 --- a/pandora_console/include/functions_network_components.php +++ b/pandora_console/include/functions_network_components.php @@ -123,31 +123,50 @@ function network_components_get_network_components ($id_module, $filter = false, $filter = array (); if (! empty ($id_module)) $filter['id_modulo'] = (int) $id_module; + if (isset($filter['offset'])) { + $offset = $filter['offset']; + unset($filter['offset']); + } + + if (isset($filter['limit'])) { + $limit = $filter['limit']; + unset($filter['limit']); + } + + $sql = @db_get_all_rows_filter ('tnetwork_component', $filter, $fields, 'AND', false, true); switch ($config["dbtype"]) { case "mysql": + $limit_sql = ''; + if (isset($offset) && isset($limit)) { + $limit_sql = " LIMIT $offset, $limit "; + } + $sql = sprintf("%s %s", $sql, $limit_sql); + + $components = db_get_all_rows_sql($sql); + break; case "postgresql": - $components = db_get_all_rows_filter ('tnetwork_component', - $filter, $fields); + $limit_sql = ''; + if (isset($offset) && isset($limit)) { + $limit_sql = " OFFSET $offset LIMIT $limit "; + } + $sql = sprintf("%s %s", $sql, $limit_sql); + + $components = db_get_all_rows_sql($sql); + break; case "oracle": - if (count ($fields) > 1) { - $fields = implode(',',$fields); - } - if (isset($filter['offset'])) { - $components = oracle_recode_query ('SELECT ' . $fields . ' FROM tnetwork_component', $filter, 'AND', false); - if ($components != false) { - for ($i=0; $i < count($components); $i++) { - unset($components[$i]['rnum']); - } - } - } - else { - $components = db_get_all_rows_filter ('tnetwork_component', - $filter, $fields); + $set = array(); + if (isset($offset) && isset($limit)) { + $set['limit'] = $limit; + $set['offset'] = $offset; } + + $components = oracle_recode_query ($sql, $set, 'AND', false); + break; } + if ($components === false) return array ();