<%doc> Search and create addresses and blocks of addresses % <%attr> title => 'Address Tasks' % % %####################################################################### %# %# Args section %# %####################################################################### <%args> $search_address => undef $search_regex => undef $search_other => undef $search => undef $search_live => undef $user => $ui->get_current_user($r); $submit => undef $show_tasks => undef $showheader => 1 $task => 'search' $dowindow => undef $view => 'search' % % % %####################################################################### %# %# INIT section %# %####################################################################### % <%init> my $DEBUG = 0; print '%ARGS is
', Dumper(%ARGS), '

' if $DEBUG; $show_tasks = $show_tasks || $user->getAttribute("SHOW_TASKS"); if ( $show_tasks eq "" ) { $user->setAttribute($r, "SHOW_TASKS", "show"); $show_tasks = "show"; } *print_showtaskslink = $m->comp('SELF:.sub_print_showtaskslink'); my $hideheader = 'style="display:none"' if ( !$showheader ); my $covering_block; my @list; my $live_info; my $manager = $ui->get_permission_manager($r);
>
Address Space Tasks
% if ( $manager && $manager->can($user, 'access_admin_section', 'address_tasks:new') ){ % my @views = qw(search new tree); % foreach my $v ( @views ){ % next if $v eq $view; % my $arg = "&onload=focus-ipblock" if $v eq "new"; [<% $v %>] % } % } % print_showtaskslink($show_tasks);
">
% if ( $view eq 'search' ){
Search

% }elsif ( $view eq 'new' ){ % unless ( $manager && $manager->can($user, 'access_admin_section', 'address_tasks.html:new') ){ % $m->comp('/generic/error.mhtml', error => "You do not have permission to add new blocks here"); % }
Add IP Block

[new]

[new]

% }elsif ( $view eq 'tree' ){
Rebuild IP tree

% }
<%perl> ####################################################################################### # Search # ####################################################################################### if ( $submit ){ if ( $search_address ){ $search = $search_address; # Remove trailing and leading spaces $search = $ui->rem_lt_sp($search); # These might throw exceptions eval { @list = Ipblock->search(address=>$search) }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>$e); } if ( !@list ){ # Return next existing higher block in the tree if not found $covering_block = Ipblock->get_covering_block(address=>$search); } }elsif ( $search_regex ){ $search_regex =~ s/\s+//g; # Remove spaces eval { qr/$search_regex/i }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>"Your regular expression doesn't seem valid: $e"); } $search = $search_regex; @list = Ipblock->search_like(address=>$search); }elsif ( $search_other ){ $search = $search_other; $search = $ui->rem_lt_sp($search); @list = Ipblock->keyword_search($search); }elsif( $search_live ){ eval { $live_info = Device->search_address_live(ip=>$search_live) }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>$e); } }elsif( $submit eq "Search" ){ $m->comp('/generic/no_search_criteria.html'); } }
% if ( $search ){ % if ( @list ){
Query <% $search %> returned: <% scalar(@list) %> matches
<& ipblock_list.mhtml, objects => \@list, parent=>0 &> % }else{
<% $search %> not found
% if ( $covering_block ){

Closest Covering Block:
<& ipblock_list.mhtml, objects =>[$covering_block], parent=>0 &>
% } % if ($search_address){ % # We do not want to offer a live search unless it's an end-node address % my $nip = NetAddr::IP->new($search_address); % if ( defined($nip) && % (($nip->version == 4 && $nip->masklen == 32) || % ($nip->version == 6 && $nip->masklen == 128)) ){

Live Search:

Would you like to perform a "live" search in the network? (It might take a while).

% } % } % } % }
% if ( $search_live && $live_info ){ <& live_results.mhtml, info=>$live_info &> % }