function plugin_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'] = " (plugin.name LIKE '%{$search}%' OR plugin.description LIKE '%{$search}%')"; } try { list($plugins, $total) = Asset_host_scan::get_all_plugins($conn, '', $filters, TRUE); } catch (Exception $e) { $return['error'] = TRUE; $return['msg'] = $e->getMessage(); return $return; } if ($total > 0) { $selected = get_selected_values(25); } $list = array(); // Special filter "No Plugin Enabled" PID = 0 if (count($plugins) > 0 && $search == '') { $_chk = $selected[0] != '' ? TRUE : FALSE; $_plugin = array('id' => 0, 'name' => _('No Plugin Enabled'), 'class' => 'italic exclusive', 'checked' => $_chk); $list[] = $_plugin; } //Going through the list to format the elements properly: foreach ($plugins as $p_id => $p_data) { $_chk = $selected[$p_id] != '' ? TRUE : FALSE; $_plugin = array('id' => $p_id, 'name' => ucwords($p_data['name']), 'title' => $p_data['description'], 'checked' => $_chk); $list[] = $_plugin; } $data['total'] = intval($total); $data['list'] = $list; $return['error'] = FALSE; $return['data'] = $data; return $return; }
function service_list($conn, $page, $search) { $return['error'] = TRUE; $return['msg'] = ''; $filters = array(); $filters['limit'] = get_query_limits($page); $filters['order_by'] = 'port'; if ($search != '') { $search = utf8_decode($search); $search = escape_sql($search, $conn); $filters['where'] = " (s.port LIKE '%{$search}%' OR p.name LIKE '%{$search}%' OR s.service LIKE '%{$search}%') "; } try { list($services, $total) = Asset_host_services::get_services_available($conn, $filters, TRUE); } catch (Exception $e) { $return['error'] = TRUE; $return['msg'] = $e->getMessage(); return $return; } if ($total > 0) { $selected = get_selected_values(10); } $list = array(); //Going through the list to format the elements properly: foreach ($services as $service) { $_serv = array(); $id = $service['port'] . ';' . $service['protocol'] . ';' . $service['service']; $md5 = md5($id); $name = $service['port'] . '/' . $service['prot_name'] . ' (' . $service['service'] . ')'; $_chk = $selected[$md5] != '' ? TRUE : FALSE; $_serv = array('id' => $id, 'name' => Util::utf8_encode2($name), 'checked' => $_chk); $list[$md5] = $_serv; } $data['total'] = intval($total); $data['list'] = $list; $return['error'] = FALSE; $return['data'] = $data; return $return; }