function network_list($conn, $page, $search) { $filters = array(); $filters['limit'] = get_query_limits($page); if ($search != '') { $search = utf8_decode($search); $search = escape_sql($search, $conn); $filters['where'] = " name LIKE '%{$search}%' OR ips LIKE '%{$search}%'"; } $filters['order_by'] = 'name ASC'; try { list($nets, $total) = Asset_net::get_list($conn, '', $filters, TRUE); } catch (Exception $e) { $return['error'] = TRUE; $return['msg'] = $e->getMessage(); return $return; } //If we have at least one element... if ($total > 0) { //Getting the nets already selected in the filter. $selected = get_selected_values(7); } $list = array(); //Going through the list to format the elements properly: foreach ($nets as $id => $net) { $_chk = $selected[$id] != '' ? TRUE : FALSE; $_net = array('id' => $id, 'name' => $net['name'], 'extra' => $net['ips'], 'checked' => $_chk); $list[$id] = $_net; } $data['total'] = intval($total); $data['list'] = $list; $return['error'] = FALSE; $return['data'] = $data; return $return; }
function get_allowed_nets($conn, $tables = '', $filters = array()) { $filters['order'] = 'name ASC'; $_net_list = Asset_net::get_list($conn, $tables, $filters); $nets = $_net_list[0]; return $nets; }
$_list_data = Asset_net::get_list($conn); $_net_aux = array_keys($_list_data[0]); foreach ($_net_aux as $n_id) { $assets_aux[] = Util::uuid_format($n_id); } $_GET["from_list"] = implode(",", $assets_aux); } if ((Session::get_host_where() != "" || Session::get_net_where() != "") && (GET('to') == "ANY" || GET('to_list') == "")) { $_GET["to"] = "LIST"; $assets_aux = array(); $_list_data = Asset_host::get_basic_list($conn); $_host_aux = array_keys($_list_data[1]); foreach ($_host_aux as $h_id) { $assets_aux[] = Util::uuid_format($h_id); } $_list_data = Asset_net::get_list($conn); $_net_aux = array_keys($_list_data[0]); foreach ($_net_aux as $n_id) { $assets_aux[] = Util::uuid_format($n_id); } $_GET["to_list"] = implode(",", $assets_aux); } if (GET("from") == "LIST") { $_GET["from"] = GET("from_list"); } if (GET("port_from") == "LIST") { $_GET["port_from"] = GET("port_from_list"); } if (GET("to") == "LIST") { $_GET["to"] = GET("to_list"); }
$order = 'name'; } //Order direction $torder = $torder == 1 ? 'ASC' : 'DESC'; //Limit $maxrows = $maxrows > 50 ? 50 : $maxrows; // Search where if ($search != '') { $search = escape_sql($search, $conn); $filters['where'] = " name LIKE '%{$search}%' OR owner LIKE '%{$search}%'"; } $filters['order_by'] = $order . ' ' . $torder; $filters['limit'] = $from . ', ' . $maxrows; try { // Get Networks list($nets, $total) = Asset_net::get_list($conn, '', $filters, TRUE); } catch (Exception $e) { $response = array(); $response['sEcho'] = intval($sec); $response['iTotalRecords'] = 0; $response['iTotalDisplayRecords'] = 0; $response['aaData'] = array(); $response['iDisplayStart'] = 0; echo json_encode($response); die; } $detail = "<img class='detail_img' src='" . AV_PIXMAPS_DIR . "/show_details.png'/>"; $results = array(); foreach ($nets as $_id => $net_data) { // Alarms $alarms = Asset_net::has_alarms($conn, $_id);
?> <script type="text/javascript"> parent.$("#pbar").progressBar(0); </script> <?php } else { ?> <script type="text/javascript"> parent.$("#pbar").progressBar(); </script> <?php } // Get networks and already hosts $db = new ossim_db(); $conn_aux = $db->connect(); list($nets, $total) = Asset_net::get_list($conn_aux); $i = 1; // Search new hosts by networks foreach ($nets as $net) { session_write_close(); usleep(500000); ob_flush(); ?> <script type="text/javascript"> parent.$("#pbar").progressBar(<?php echo floor($i * 100 / $total); ?> ); var n_msg = "<?php
$db = new ossim_db(); $conn = $db->connect(); $assets .= '<tr> <td style="text-align:left;width:25mm;font-size:10px;color:#535353;" valign="top">' . "Assets Selected:" . '</td> <td class="nobborder" style="padding-left:5px;font-size:10px" valign="top"> <table class="w100" cellpadding="0" cellspacing="0">'; if ($_SESSION['_user_vision']['host_where'] && !Session::only_ff_host()) { $_host_list = Asset_host::get_basic_list($conn); $hosts = $_host_list[1]; foreach ($hosts as $host) { $assets .= '<tr><td class="nobborder" style="text-align:left;" valign="top">' . _('Host') . ': ' . $host['name'] . ' [' . $host['ips'] . ']</td></tr>'; } } if ($_SESSION['_user_vision']['net_where'] && !Session::only_ff_net()) { $nets = Asset_net::get_list($conn); $_net_list = Asset_net::get_list($conn); $nets = $_net_list[0]; foreach ($nets as $net) { $assets .= '<tr><td class="nobborder" style="text-align:left;" valign="top">' . _('Net') . ': ' . $net['name'] . ' [' . $net['ips'] . ']</td></tr>'; } } $assets .= ' </table> </td> </tr>'; $db->close(); } else { $assets .= '<tr> <td style="text-align:left;width:25mm;font-size:10px;color:#535353;">' . _('Assets Selected:') . '</td> <td class="nobborder" style="padding-left:5px;text-align:left;font-size:10px" valign="top">' . _('All Assets') . '</td> </tr>'; }
Session::logcheck('environment-menu', 'PolicyNetworks'); //Export all nets if (isset($_GET['get_data'])) { //Setting up a high time limit. $db = new ossim_db(); $conn = $db->connect(); //Setting up the file name with the nets info $file = uniqid('/tmp/export_all_net_' . date('Ymd_H-i-s') . '_'); $_SESSION['_csv_file_nets'] = $file; session_write_close(); //Export a filtered list $filters = array(); $session = session_id(); $tables = ', user_component_filter f'; $filters = array('where' => "f.asset_id=net.id AND f.asset_type='network' AND f.session_id = '{$session}'", 'order_by' => 'net.name ASC'); $_net_list = Asset_net::get_list($conn, $tables, $filters); $n_data = array(); foreach ($_net_list[0] as $net) { $descr = $net['descr']; $n_data[] = '"' . $net['name'] . '";"' . $net['ips'] . '";"' . $descr . '";"' . $net['asset_value'] . '";"' . $net['id'] . '"'; } $csv_data = implode("\r\n", $n_data); file_put_contents($file, $csv_data); exit; } elseif (isset($_GET['download_data'])) { $output_name = _('Networks') . '__' . gmdate('Y-m-d', time()) . '.csv'; //Retrieving the file name $file = $_SESSION['_csv_file_nets']; unset($_SESSION['_csv_file_nets']); $csv_data = '"Netname";"CIDRs";"Description";"Asset Value";"Net ID"' . "\r\n"; if (file_exists($file)) {
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'; } } } if (GET('id') != '' || GET('clone') == 1) { $action = 'modifynetgroup.php'; } else { $action = 'newnetgroup.php'; } $paths = Asset::get_path_url(FALSE); ?>
//Limit $maxrows = $maxrows > 50 ? 50 : $maxrows; //Session ID $session = session_id(); //list params $filters = array(); $tables = ''; $filters['order_by'] = $order . ' ' . $torder; $filters['limit'] = $from . ', ' . $maxrows; if (!$all_list) { $tables = ', user_host_filter hf'; $filters['where'] = "hf.asset_id=net.id AND hf.session_id='{$session}'"; } try { // Get Networks list($nets, $total) = Asset_net::get_list($conn, $tables, $filters); } catch (Exception $e) { $response = array(); $response['sEcho'] = intval($sec); $response['iTotalRecords'] = 0; $response['iTotalDisplayRecords'] = 0; $response['aaData'] = array(); $response['iDisplayStart'] = 0; echo json_encode($response); die; } $detail = "<img class='detail_img' src='" . AV_PIXMAPS_DIR . "/show_details.png'/>"; $results = array(); foreach ($nets as $_id => $net_data) { // Alarms $alarms = Asset_net::has_alarms($conn, $_id);