$agent['id_agente'], 'name' => io_safe_output($agent['nombre']), 'ip' => io_safe_output($agent['direccion'])); } echo json_encode($data); return; } elseif ($search_agents_2 && ($config['metaconsole'] == 1)) { $servers = db_get_all_rows_sql ("SELECT * FROM tmetaconsole_setup"); if (!isset($servers)) { return; } foreach ($servers as $server) { if (metaconsole_load_external_db ($server) != NOERR) { continue; } $id_agent = (int) get_parameter ('id_agent'); $string = (string) get_parameter ('q'); /* q is what autocomplete plugin gives */ $id_group = (int) get_parameter('id_group'); $addedItems = html_entity_decode((string) get_parameter('add')); $addedItems = json_decode($addedItems); if ($addedItems != null) { foreach ($addedItems as $item) { echo $item . "|\n"; } } $filter = array (); switch ($config["dbtype"]) { 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_grupo'] = $id_group; $agents = agents_get_agents ($filter, array ('id_agente','nombre', 'direccion')); if ($agents === false) continue; $data = array(); foreach ($agents as $agent) { $data[] = array('id' => $agent['id_agente'], 'name' => io_safe_output($agent['nombre']) . " (" . io_safe_output($server['server_name']) . ") ", 'ip' => io_safe_output($agent['direccion'])); } //Restore db connection metaconsole_restore_db(); echo json_encode($data); } return; } ?>