'nombre COLLATE utf8_general_ci ASC', 'id_grupo' => $id, 'disabled' => 0, 'status' => $statusSel, 'search' => $search_sql), array ('*'), 'AR', false, true); break; case 'os': //Skip agents which only have not init modules $search_sql .= " AND id_agente NOT IN (SELECT tagente_estado.id_agente FROM tagente_estado GROUP BY id_agente HAVING SUM(utimestamp) = 0)"; $sql = agents_get_agents(array ( 'order' => 'nombre COLLATE utf8_general_ci ASC', 'id_os' => $id, 'disabled' => 0, 'status' => $statusSel, 'search' => $search_sql), array ('*'), 'AR', false, true); break; case 'module_group': //Skip agents which only have not init modules $search_sql .= " AND id_agente NOT IN (SELECT tagente_estado.id_agente FROM tagente_estado WHERE id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_module_group = $id) GROUP BY id_agente HAVING SUM(utimestamp) = 0)"; $sql = agents_get_agents(array ( 'order' => 'nombre COLLATE utf8_general_ci ASC', 'disabled' => 0, 'status' => $statusSel, 'search' => $search_sql), array ('*'), 'AR', false, true); // Skip agents without modules $sql .= ' AND id_agente IN (SELECT tagente.id_agente FROM tagente, tagente_modulo WHERE tagente.id_agente = tagente_modulo.id_agente AND id_module_group = ' . $id . ' AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 group by tagente.id_agente having COUNT(*) > 0)'; break; case 'policies': $sql = agents_get_agents(array ( 'order' => 'nombre COLLATE utf8_general_ci ASC', 'disabled' => 0, 'search' => $search_sql), array ('*'), 'AR', false, true); if ($id != 0) { // Skip agents without modules $sql .= ' AND tagente.id_agente IN (SELECT tagente.id_agente FROM tagente, tagente_modulo, tagente_estado, tpolicy_modules WHERE tagente.id_agente = tagente_modulo.id_agente AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.id_policy_module = tpolicy_modules.id AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_policy_module != 0 AND tpolicy_modules.id_policy = ' . $id . ' group by tagente.id_agente having COUNT(*) > 0)'; } else if ($statusSel == 0) { // If status filter is NORMAL add void agents $sql .= " UNION SELECT * FROM tagente WHERE tagente.disabled = 0 AND tagente.id_agente NOT IN (SELECT tagente_estado.id_agente FROM tagente_estado)"; } break; case 'module': //Replace separator token "articapandora_32_pandoraartica_" for " " //example: //"Load_articapandora_32_pandoraartica_Average" //result -> "Load Average" $name = str_replace(array('_articapandora_'.ord(' ').'_pandoraartica_', '_articapandora_'.ord('#').'_pandoraartica_','_articapandora_'.ord('/').'_pandoraartica_'),array(' ','#','/'),$id); $name = io_safe_input($name); $sql = agents_get_agents(array ( 'order' => 'nombre COLLATE utf8_general_ci ASC', 'disabled' => 0, 'status' => $statusSel, 'search' => $search_sql), array ('*'), 'AR', false, true); $sql .= sprintf('AND id_agente IN ( SELECT id_agente FROM tagente_modulo WHERE nombre = \'%s\' AND disabled = 0 ) ', $name); break; } $sql .= ' AND tagente.disabled = 0'. $search_sql; $countRows = db_get_num_rows($sql); } //Empty Branch if ($countRows === 0) { echo ""; return; } //Branch with items $new = true; $count = 0; echo "\n"; break; //also aknolegment as second subtree/branch case 'agent_group': case 'agent_module_group': case 'agent_os': case 'agent_policies': case 'agent_module': $fatherType = str_replace('agent_', '', $type); switch ($fatherType) { case 'group': $sql = 'SELECT * FROM tagente_modulo AS t1 INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo WHERE t1.id_agente = ' . $id; break; case 'os': $sql = 'SELECT * FROM tagente_modulo AS t1 INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo WHERE t1.id_agente = ' . $id; break; case 'module_group': $sql = 'SELECT * FROM tagente_modulo AS t1 INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo WHERE t1.id_agente = ' . $id . ' AND id_module_group = ' . $id_father; break; case 'policies': $whereQuery = ''; if ($id_father != 0) $whereQuery = ' AND t1.id_policy_module IN (SELECT id FROM tpolicy_modules WHERE id_policy = ' . $id_father . ')'; else $whereQuery = ' AND t1.id_policy_module = 0 '; $sql = 'SELECT * FROM tagente_modulo AS t1 INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo WHERE t1.id_agente = ' . $id . $whereQuery; break; case 'module': $name = str_replace(array('_articapandora_'.ord(' ').'_pandoraartica_', '_articapandora_'.ord('#').'_pandoraartica_','_articapandora_'.ord('/').'_pandoraartica_'),array(' ','#','/'),$id_father); switch ($config["dbtype"]) { case "mysql": $sql = 'SELECT * FROM tagente_modulo AS t1 INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo WHERE t1.id_agente = ' . $id . ' AND nombre = \'' . io_safe_input($name) . '\''; break; case "postgresql": case "oracle": $sql = 'SELECT * FROM tagente_modulo AS t1 INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo WHERE t1.id_agente = ' . $id . ' AND nombre = \'' . io_safe_input($name) . '\''; break; } break; } // This line checks for initializated modules or (non-initialized) asyncronous modules $sql .= ' AND disabled = 0 AND (utimestamp > 0 OR id_tipo_modulo IN (21,22,23))'; $countRows = db_get_num_rows($sql); if ($countRows === 0) { echo ""; return; } $new = true; $count = 0; echo "\n"; break; } return; } //End of AJAX code. include_once($config['homedir'] . "/include/functions_groups.php"); include_once($config['homedir'] . "/include/functions_os.php"); include_once($config['homedir'] . "/include/functions_modules.php"); include_once($config['homedir'] . "/include/functions_servers.php"); include_once($config['homedir'] . "/include/functions_reporting.php"); include_once($config['homedir'] . "/include/functions_ui.php"); global $config; $enterpriseEnable = false; if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) { $enterpriseEnable = true; } ///////// INI MENU AND TABS ///////////// $img_style = array ("class" => "top", "width" => 16); $activeTab = get_parameter('sort_by','group'); $os_tab = array('text' => "" . html_print_image ("images/computer.png", true, array ("title" => __('OS'))) . "", 'active' => $activeTab == "os"); $group_tab = array('text' => "" . html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "", 'active' => $activeTab == "group"); $module_group_tab = array('text' => "" . html_print_image ("images/agents_group.png", true, array ("title" => __('Module groups'))) . "", 'active' => $activeTab == "module_group"); if ($enterpriseEnable) { $policies_tab = array('text' => "" . html_print_image ("images/policies.png", true, array ("title" => __('Policies'))) . "", 'active' => $activeTab == "policies"); } else { $policies_tab = ''; } $module_tab = array('text' => "" . html_print_image ("images/brick.png", true, array ("title" => __('Modules'))) . "", 'active' => $activeTab == "module"); $onheader = array('os' => $os_tab, 'group' => $group_tab, 'module_group' => $module_group_tab, 'policies' => $policies_tab, 'module' => $module_tab); switch ($activeTab) { case 'group': $order = __('groups'); break; case 'module_group': $order = __('module groups'); break; case 'policies': $order = __('policies'); break; case 'module': $order = __('modules'); break; case 'os': $order = __('OS'); break; } ui_print_page_header (__('Tree view')." - ".__('Sort the agents by ') .$order, "images/extensions.png", false, "", false, $onheader); echo "
"; echo '"; echo "
"; echo "
"; echo "
"; ///////// END MENU AND TABS ///////////// treeview_printTree($activeTab); ?>