function GetOssimNetworkGroups() { require_once "classes/Net_group.inc"; require_once 'ossim_db.inc'; $db = new ossim_db(); $conn = $db->connect(); $pg = array(); $groups = Net_group::get_list($conn, "", " ORDER BY name"); foreach ($groups as $ng) { $pg[] = $ng->get_name(); } $conn->disconnect(); return $pg; }
} $j++; } if ($j > $to) { $li = "key:'{$key}', page:'{$nextpage}', isFolder:true, isLazy:true, icon:'../../pixmaps/theme/net.png', title:'" . _("next") . " {$maxresults} " . _("nets") . "'"; $buffer .= ",{ {$li} }\n"; } $buffer .= "]"; } if ($buffer == "[]" || $buffer == "") { $buffer = "[{title:'" . _("No Networks Found") . "', noLink:true}]"; } } else { if ($key == "netgroup") { $whereng = $filter == "" ? "" : "name like '%{$filter}%'"; if ($net_group_list = Net_group::get_list($conn, $whereng)) { $j = 0; $buffer .= "["; foreach ($net_group_list as $net_group) { if ($j >= $from && $j < $to) { $ng_name = $net_group->get_name(); $ng_title = Util::htmlentities(utf8_encode($ng_name)); $ng_key = "netgroup_" . base64_encode($ng_name); $title = strlen($ng_name) > $length_name ? substr($ng_name, 0, $length_name) . "..." : $ng_name; $title = Util::htmlentities(utf8_encode($title)); $tooltip = $ng_title; $li = "key:'{$ng_key}', isLazy:true , icon:'../../pixmaps/theme/net_group.png', title:'{$title}', tooltip:'{$tooltip}'\n"; $buffer .= ($j > $from ? "," : "") . "{ {$li} }\n"; } $j++; }
if ($k > $to) { $html .= "{ key:'{$key}', page:'{$nextpage}', isFolder:true, isLazy:true, icon:'../../pixmaps/theme/host.png', title:'" . _("next") . " {$maxresults} " . _("hosts") . "' }"; } if ($html != "") { $buffer .= preg_replace("/,\$/", "", $html); } $buffer .= "]"; if ($buffer == "" || $buffer == "[]") { echo "[{title:'" . _("No Hosts Found") . "', noLink:true}]"; } else { echo $buffer; } } else { if ($key == "netgroup") { $buffer .= "["; if ($net_group_list = Net_group::get_list($conn)) { $j = 0; foreach ($net_group_list as $net_group) { if ($j >= $from && $j < $to) { $ng_name = $net_group->get_name(); $ng_key = "netgroup_" . base64_encode($ng_name); $ng_title = Util::htmlentities($ng_name); $title = strlen($ng_name) > $length_name ? substr($ng_name, 0, $length_name) . "..." : $ng_name; $title = Util::htmlentities($title); $tooltip = $ng_title; $li = "key:'{$ng_key}', isLazy:true , url:'NODES:{$ng_title}', icon:'../../pixmaps/theme/net_group.png', title:'{$title}', tooltip:'{$tooltip}'\n"; $buffer .= ($j > $from ? "," : "") . "{ {$li} }\n"; } $j++; } if ($j > $to) {
$buffer = "[{title:'" . _("No Sensors Found") . "', noLink:true}]"; } echo $buffer; } else { if (preg_match("/u_(.*)/", $key, $found)) { echo "["; echo "{ key:'u_" . $found[1] . "_net', isFolder:true, isLazy:true, icon:'../../pixmaps/theme/net.png', title:'" . _("Networks") . "'},"; echo "{ key:'u_" . $found[1] . "_sensor', isFolder:true, isLazy:true, icon:'../../pixmaps/theme/server.png', title:'" . _("Sensors") . "'},"; echo "{ key:'u_" . $found[1] . "_netgroup', isFolder:true, isLazy:true, icon:'../../pixmaps/theme/net_group.png', title:'" . _("Network Groups") . "'}"; echo "]"; } else { if (preg_match("/e_(.*)_netgroup/", $key, $found)) { $entityPerms = Acl::entityPerms($conn, $found[1]); $all = count($entityPerms["assets"]); $nets_allowed = array_keys($entityPerms["assets"]); $net_groups = Net_group::get_list($conn); $netgroup_list = array(); foreach ($net_groups as $net_group) { $allowed = 0; $nets = $net_group->get_networks($conn, $net_group->get_name()); foreach ($nets as $net) { $net_ips = explode(",", $net->get_net_ips($conn)); if (!$all || Acl::cidrs_allowed($net_ips, $entityPerms["assets"])) { $allowed = 1; } } if ($allowed) { $netgroup_list[] = $net_group->get_name(); } } $buffer .= "[";
function GetOssimNetworkGroups() { $db = new ossim_db(); $conn = $db->connect(); $pg = array(); $groups = Net_group::get_list($conn, "", " ORDER BY name"); foreach ($groups as $ng) { $pg[$ng->get_id()] = $ng->get_name(); } $db->close($conn); return $pg; }
function draw_members_select($form_data) { global $conn, $id; $resp = new xajaxResponse(); $type = $form_data['member_type']; // The user selected the empty type if (!$type) { $resp->AddAssign("members_select", "innerHTML", _("Please select a type")); return $resp; } // // Get the list of members of the given type // $options = array(); switch ($type) { case 'host': include_once 'classes/Host.inc'; $list = Host::get_list($conn, "", 'ORDER BY hostname'); print_r($list); foreach ($list as $obj) { $descr = $obj->get_descr(); if (strlen($descr) > 50) { $descr = substr($descr, 0, 47) . '...'; } $options[$obj->get_ip()] = $obj->get_hostname() . ' ' . $obj->get_ip() . ' - ' . $descr; } break; case 'net': include_once 'classes/Net.inc'; $list = Net::get_list($conn, "", 'ORDER BY name'); foreach ($list as $obj) { $descr = $obj->get_descr(); if (strlen($descr) > 50) { $descr = substr($descr, 0, 47) . '...'; } $options[$obj->get_name()] = $obj->get_name() . ' ' . $obj->get_ips() . ' - ' . $descr; } break; case 'host_group': include_once 'classes/Host_group.inc'; $list = Host_group::get_list($conn, "", 'ORDER BY name'); foreach ($list as $obj) { $descr = $obj->get_descr(); if (strlen($descr) > 50) { $descr = substr($descr, 0, 47) . '...'; } $options[$obj->get_name()] = $obj->get_name() . ' - ' . $descr; } break; case 'net_group': include_once 'classes/Net_group.inc'; $list = Net_group::get_list($conn, '', 'ORDER BY name'); foreach ($list as $obj) { $descr = $obj->get_descr(); if (strlen($descr) > 50) { $descr = substr($descr, 0, 47) . '...'; } $options[$obj->get_name()] = $obj->get_name() . ' - ' . $descr; } break; } // // Build the SELECT tag // $html = '<select name="member_name">'; foreach ($options as $name => $description) { $html .= "<option value='{$name}'>{$description}</option>"; } $html .= '</select>'; $resp->AddAssign("members_select", "innerHTML", $html); return $resp; }
* */ require_once 'av_init.php'; Session::logcheck('environment-menu', 'PolicyNetworks'); $db = new ossim_db(); $conn = $db->connect(); $id = GET('id'); $msg = GET('msg'); ossim_valid($id, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _('Network Group ID')); if (ossim_error()) { die(ossim_error()); } $networks = array(); $descr = ''; if ($id != '') { if ($net_group_list = Net_group::get_list($conn, " g.id = UNHEX('{$id}')")) { $net_group = $net_group_list[0]; $ngname = $net_group->get_name(); $ctx = $net_group->get_ctx(); $descr = $net_group->get_descr(); $obj_networks = Net_group::get_networks($conn, $net_group->get_id()); foreach ($obj_networks as $net) { $net_id = $net->get_net_id(); $filters = array('where' => "id = UNHEX('" . $net_id . "')"); $_aux_net_list = Asset_net::get_list($conn, '', $filters); $networks[$net->get_net_id()] = $_aux_net_list[0][$net_id]; } $rrd_profile = $net_group->get_rrd_profile(); if (!$rrd_profile) { $rrd_profile = 'None'; }
$descr = $_SESSION['_netgroup']['descr']; $threshold_a = $_SESSION['_netgroup']['threshold_a']; $threshold_c = $_SESSION['_netgroup']['threshold_c']; $rrd_profile = $_SESSION['_netgroup']['rrd_profile']; unset($_SESSION['_netgroup']); } else { $conf = $GLOBALS["CONF"]; $threshold_a = $threshold_c = $conf->get_conf("threshold"); $descr = ""; $networks = array(); if ($ngname != '') { ossim_valid($ngname, OSS_ALPHA, OSS_SPACE, OSS_PUNC, OSS_NULLABLE, OSS_SQL, 'illegal:' . _(" Network Group Name")); if (ossim_error()) { die(ossim_error()); } if ($net_group_list = Net_group::get_list($conn, "name = '{$ngname}'")) { $net_group = $net_group_list[0]; $descr = $net_group->get_descr(); $threshold_c = $net_group->get_threshold_c(); $threshold_a = $net_group->get_threshold_a(); $obj_networks = $net_group->get_networks($conn); foreach ($obj_networks as $net) { $networks[] = $net->get_net_name(); } $rrd_profile = $net_group->get_rrd_profile(); if (!$rrd_profile) { $rrd_profile = "None"; } } } }
if (isset($_GET['numnets']) && is_numeric($_GET['numnets'])) { $numnets = $_GET['numnets']; } else { $numnets = "10"; } //Refresh interval if (isset($_GET['refresh']) && is_numeric($_GET['refresh'])) { $refresh = $_GET['refresh']; } else { $refresh = 2; } $db = new ossim_db(); $conn = $db->connect(); // net groups $netgroups = array(); $ngs = Net_group::get_list($conn, "", ""); // get only allowed net_groups foreach ($ngs as $ng) { $rns = $ng->get_networks($conn); foreach ($rns as $rn) { $netgroups[$rn->get_net_group_name()][] = $rn->get_net_name(); } } // $nets_where = ""; if (Session::allowedNets() != "") { $nets = explode(",", Session::allowedNets()); foreach ($nets as $net) { $nets_where .= $nets_where != "" ? " OR net_name=\"" . Net::get_name_by_ip($conn, $net) . "\"" : " WHERE net_name=\"" . Net::get_name_by_ip($conn, $net) . "\""; } }
} } if (ossim_error()) { $db->close(); echo "<rows>\n<page>1</page>\n<total>0</total>\n</rows>\n"; exit; } if (!empty($order)) { $order .= POST('sortorder') == "asc" ? "" : " desc"; } else { $order = "name"; } $start = ($page - 1) * $rp; $limit = "LIMIT {$start}, {$rp}"; $xml = ''; $net_group_list = Net_group::get_list($conn, $where, "ORDER BY {$order} {$limit}"); if ($net_group_list[0]) { $total = $net_group_list[0]->get_foundrows(); if ($total == 0) { $total = count($net_group_list); } } else { $total = 0; } $xml .= "<rows>\n"; $xml .= "<page>{$page}</page>\n"; $xml .= "<total>{$total}</total>\n"; foreach ($net_group_list as $net_group) { $name = $net_group->get_name(); $id = $net_group->get_id(); $xml .= "<row id='" . $id . "'>";