<%doc> User Interface for Hosts <%args> $id => undef $user => $ui->get_current_user($r) $rr => undef $ipblock => undef $action => undef $zone => undef $submit => undef $add_ptr => undef $add_alias => undef $add_dhcp => undef $editattr => undef $editipblock => undef <%init> my $DEBUG = 0; print '%ARGS is

    ', Dumper(%ARGS), '

' if $DEBUG; my @rraddrs; my %rrs; my $edit; my $deleted_label; my $manager = $ui->get_permission_manager($r); if ($id) { $rr = RR->retrieve($id); $m->comp('/generic/error.mhtml', error=>"Could not retrieve RR id $id") unless $id; }elsif ( $rr ){ if ( ref($rr) eq 'ARRAY' ){ # We somehow got an arrayref. Ignore this. undef($rr); }elsif ( !ref($rr) ) { $rr = RR->retrieve($rr); $m->comp('/generic/error.mhtml', error=>"Could not retrieve RR id $rr") unless $rr; $id = $rr->id; } } # Check if user can view this object if ( $rr ){ unless ( $manager && $manager->can($user, "view", $rr) ){ $m->comp('/generic/error.mhtml', error=>"You don't have permission to view this object"); } $rrs{$rr->id} = $rr; } if ($ipblock && !ref $ipblock) { $ipblock = Ipblock->retrieve($ipblock); unless ( $manager && $manager->can($user, "view", $ipblock) ){ $m->comp('/generic/error.mhtml', error=>"You don't have permission to view this object"); } if (my @arecords = $ipblock->arecords()) { foreach my $arecord (@arecords) { $rrs{$arecord->rr->id} = $arecord->rr; } } } if ( $submit ){ if ( $rr && $action eq 'delete_confirm' ){ # Check if user can delete this object unless ( $manager && $manager->can($user, "delete", $rr) ){ $m->comp('/generic/error.mhtml', error=>"You don't have permission to delete this object"); } eval { Netdot::Model->do_transaction(sub{ my @ips = map { $_->ipblock } $rr->arecords(); $deleted_label = $rr->get_label(); delete $rrs{$rr->id}; $rr->delete(); undef $rr; $action = 'deleted'; }); }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>"$e"); } }elsif ($rr || $id || $ipblock || $action eq 'new') { # insert/update eval{ Netdot::Model->do_transaction(sub{ my $user_type = $user->getAttribute('USER_TYPE'); # For unprivileged users, we apply restrictions # on RR names if ( $user_type eq 'user' ){ foreach my $key ( %ARGS ){ if ( $key =~ /RR__(?:NEW|\d+)__(.*)$/ ){ my $name = $1; RR->validate_name($name); } } } my %ret = $ui->form_to_db(%ARGS); print 'form_to_db returned:

    ', Dumper(%ret), '

' if $DEBUG; if ( exists $ret{RR} ) { my $newid = (keys %{$ret{RR}{id}})[0]; defined $newid || die "Could not get record ID"; if ( $ret{RR}{id}{$newid}{action} eq 'INSERTED' ){ if(! $id){ $id = $newid; } if(! $rr){ $rr = $newid; } if (defined $ipblock) { RRADDR->insert({rr=>$newid, ipblock=>$ipblock}); } } # Add new RR to %rrs hash # Also, if RR was just updated, this re-reads it from the DB # to avoid the old values from showing up my $newrr = RR->retrieve($id); defined $newrr || $m->comp('/generic/error.mhtml', error=>"Could not retrieve RR id $id"); ; $rrs{$newrr->id} = $newrr; } }) }; if ( my $e = $@ ){ if ($e =~ /Error while inserting RRCNAME: Some values are duplicated./ ){ my $name = $ARGS{'RR__NEW__name'}; $e = "Alias ". $name . " already exists in the database."; } $m->comp('/generic/error.mhtml', error=>"$e"); } else { $submit = 0; $action = ""; } } } <%perl> print ''; print '
'; if ( $rr && $action eq 'delete' ){ print '
'; print '
Delete Records
'; print '
'; print '

'; print 'Are you sure you want to delete the records below?'; print '

'; print '

'; print ''; print ''; print ' '; print ''; print '

'; print '
'; print '

'; } print '

'; my (@field_headers, @cell_data); print '
DNS Records
'; print '
'; if ($action eq 'new') { if ($ipblock) { print ''; } print ''; print ''; print ''; } elsif ($ipblock) { print '[new]'; } elsif (!($id || $rr || $ipblock)) { print '[add]'; }else{ print ' ' } print '
'; #close containderheadright print '
'; my %comphash = (field_headers=>\@field_headers, data=>\@cell_data, headercolwidth=>"15%", datacolwidth=>"85%"); if ($action eq 'new') { print '
'; print '
New Record
'; print '
'; $ui->add_to_fields(edit=>1, table=>'RR', fields=>['name'], field_headers=>\@field_headers, cell_data=>\@cell_data); if ( defined $zone ){ unless ( ref($zone) ){ $zone = Zone->retrieve($zone); } }elsif ( $ipblock ){ unless ( ref($ipblock) ){ $ipblock = Ipblock->retrieve($ipblock); } $zone = $ipblock->forward_zone(); } if ( $zone ){ print ''; push @field_headers, 'Zone:'; push @cell_data, $zone->get_label; }else{ my %args = (edit=>1, table=>'RR', fields=>['zone'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['zone.html']); $ui->add_to_fields(%args); } $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); print '
'; #close containerbody of 'new' print '
'; #close container of 'new' }elsif ( $action eq 'deleted' ){ print '

'; print 'Record '.$deleted_label.' has been deleted'; print '

'; print '
'; print '

'; }
<%perl> foreach my $o ( values %rrs ) { if ($action eq 'edit' && $rr->id == $o->id) { $edit = 1; } else { $edit = 0; } print ''; print '

'; print '
'.$o->get_label.'
'; print '
'; if ( $edit ) { print ''; print ''; } else { print '[refresh] '; if ( $manager && $manager->can($user, 'edit', $o) ){ print '[edit] '; } if ( $manager && $manager->can($user, "delete", $o) ){ print '[delete]'; } } print '
'; $ui->add_to_fields(edit=>$edit, o=>$o, fields=>['name', 'zone', 'expiration', 'active'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['', 'zone.html', '']); if ( $manager && $manager->can($user, "access_section", 'host.html:auto_update') ){ if ( my $device = ($o->devices)[0] ){ push @field_headers, 'Device:'; push @cell_data, ''.$device->get_label.''; } $ui->add_to_fields(edit=>$edit, o=>$o, fields=>['auto_update'], field_headers=>\@field_headers, cell_data=>\@cell_data, ); } $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); my @arecs = $o->arecords(); my @ips; ##################################################################################################### #RRADDR if ( $o->name eq '@' || $o->name eq $o->zone->name || (!$o->cnames && !$o->ptr_records) ){ print '
'; print '
Address '.$ui->table_descr_link('RRADDR', '(A/AAAA)').'
'; print '
'; if ( $manager && $manager->can($user, "access_section", 'host.html:add_rraddr') ){ push( @field_headers, ("IP:", "TTL") ); push( @cell_data, "" ); push( @cell_data, "" ); my $newrraddr = $m->scomp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); $newrraddr =~ s/\n//g; $newrraddr =~ s/<script.*?<\/script>//g; $newrraddr =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } }else{ print ' '; } print '
'; #close containerheadright #display/edit rraddr print '
'; foreach my $arecord (sort { $a->ipblock->address_numeric <=> $b->ipblock->address_numeric } @arecs) { my $ipblock = $arecord->ipblock; if ( int($ipblock) == 0 ){ # This record should not exist then $arecord->delete; next; } push @ips, $ipblock; push( @field_headers, "IP:"); push( @cell_data, "".$ipblock->address.""); $ui->add_to_fields(o=>$arecord, edit=>$edit, fields=>['ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>[''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } print '
'; print '
'; ################################################################ # DHCP host scopes # Do not show ethernet field unless the subnet has DHCP enabled foreach my $ipblock ( @ips ){ my $gscope; # global scope if ( int($ipblock->parent) != 0 && $ipblock->parent->dhcp_scopes ) { # Subnet is in DHCP $gscope = $ipblock->parent->dhcp_scopes->first->get_global; $m->comp('/generic/error.mhtml', error=>"Could not determine global scope for IP ".$ipblock->get_label) unless $gscope; }else{ next; } print '
'; print '
DHCP for '.$ipblock->address.'
'; print '
'; my $scope; if ( ($scope = $ipblock->dhcp_scopes->first) && ($scope->physaddr() != 0) ){ print ' '; }else{ if ( $add_dhcp ){ print ''; print ''; }else{ # Let user add a scope print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '[add]'; } } } } print '
'; print '
'; if ( $scope ){ # Show the MAC address my $phys = $scope->physaddr(); push @field_headers, ('Ethernet: '); push( @cell_data, ''.$phys->address.'' ); if ( $edit ){ push @field_headers, 'Delete'; push @cell_data, ''; } $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); }else{ if ( $add_dhcp == $ipblock->id ){ # User wants to add a scope with this ip push @field_headers, ('Ethernet: '); print ''; print ''; print ''; print ''; push( @cell_data, '' ); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } } print '
'; } ##################################################################################################### #RRHINFO print '
'; print '
Hardware Information '.$ui->table_descr_link('RRHINFO', '(HINFO)').'
'; print '
'; my $cpu_defaults = $ui->config->get('DEFAULT_HINFO_CPU_VALUES'); my $os_defaults = $ui->config->get('DEFAULT_HINFO_OS_VALUES'); my $defaults = [ $cpu_defaults, $os_defaults ]; if ( !$o->hinfo_records ){ #new rrhinfo $ui->add_to_fields(table=>'RRHINFO', edit=>1, fields=>['cpu', 'os', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, defaults =>$defaults, linkpages=>['view.html','view.html','']); my $newhinfo = $m->scomp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); $newhinfo =~ s/\n//g; $newhinfo =~ s/<script.*?<\/script>//g; $newhinfo =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } }else{ print ' '; } print '
'; #close containerheadright #display/edit print '
'; if (my @hinfos = $o->hinfo_records()) { foreach my $hinfo (@hinfos) { $ui->add_to_fields(o=>$hinfo, edit=>$edit, fields=>['cpu', 'os', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, defaults =>$defaults, linkpages=>['view.html','view.html',''], with_delete=>1 ); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; ##################################################################################################### #RRTXT print '
'; print '
Text Records '.$ui->table_descr_link('RRTXT', '(TXT)').'
'; print '
'; #new rrtxt $ui->add_to_fields(table=>'RRTXT', edit=>1, fields=>['txtdata', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','']); my $newtxt = $m->scomp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); $newtxt =~ s/\n//g; $newtxt =~ s/<script.*?<\/script>//g; $newtxt =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @txts = $o->txt_records()) { foreach my $txt (@txts) { $ui->add_to_fields(o=>$txt, edit=>$edit, fields=>['txtdata', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html',''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; ##################################################################################################### #RRMX print '
'; print '
Mail Exchangers '.$ui->table_descr_link('RRMX', '(MX)').'
'; print '
'; #new rrmx $ui->add_to_fields(table=>'RRMX', edit=>1, fields=>['preference', 'exchange', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['', 'view.html','']); my $newmx = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newmx =~ s/\n//g; $newmx =~ s/<script.*?<\/script>//g; $newmx =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @mxs = sort { $a->preference <=> $b->preference } $o->mx_records()) { foreach my $mx (@mxs) { $ui->add_to_fields(o=>$mx, edit=>$edit, fields=>['preference', 'exchange', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['','view.html',''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; ##################################################################################################### #RRCNAME for somewhere pointing to $o print '
'; print '
Aliases of '.$o->get_label.' '.$ui->table_descr_link('RRCNAME', '(CNAME)').'
'; print '
'; if ( $add_alias ){ print ''; print ''; }else{ print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '[add]'; } } } print '
'; #close containerheadright #new rrcname if ( $add_alias ){ push( @field_headers, ("Name", "TTL") ); print ''; print ''; print ''; print ''; push( @cell_data, '' ); push( @cell_data, '' ); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } #display/edit print '
'; if ( my @cnames = RRCNAME->search(cname=>$o->get_label) ){ foreach my $cname ( sort { $a->rr->name cmp $b->rr->name } @cnames ) { $ui->add_to_fields(o=>$cname, edit=>0, fields=>['rr'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['host.html']); $ui->add_to_fields(o=>$cname, edit=>$edit, fields=>['ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } } print '
'; } ##################################################################################################### #RRCNAME for aliases of $o ($o pointing to somewhere) # cannot have an A/AAAA record at the same time # the $o is unique in the cname table if ( !$o->arecords && !$o->ptr_records && !$o->ns_records ) { print '
'; print '
'.$o->get_label.' is an alias of '.$ui->table_descr_link('RRCNAME', '(CNAME)').'
'; print '
'; my @cnames = $o->cnames(); if ( !@cnames ){ #new rrcname (only add if there isn't one) $ui->add_to_fields(table=>'RRCNAME', edit=>1, fields=>['cname', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','']); my $newcname = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newcname =~ s/\n//g; $newcname =~ s/<script.*?<\/script>//g; $newcname =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } }else{ print ' '; } print '
'; #close containerheadright #display/edit print '
'; if ( @cnames ) { my $cname = $cnames[0]; # shouldn't be more than one, right? # Deal with cname field # The trick here is that the cname is a varchar field, so it could or # could not be referencing a record which exists in Netdot. # We let the user edit the text, but when not editing, we'll try # to find an existing RR and provide a hyperlink if found. if ( $edit ){ # Edit cname field $ui->add_to_fields(o=>$cname, edit=>1, fields=>['cname'], field_headers=>\@field_headers, cell_data=>\@cell_data); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); }else{ if ( my $cnamerr = RR->search(name=>$cname->cname)->first ){ push @field_headers, "Canonical Name:"; push @cell_data, "".$cnamerr->get_label.""; }else{ push @field_headers, "Canonical Name:"; push @cell_data, $cname->cname; } } # Add TTL $ui->add_to_fields(o=>$cname, edit=>$edit, fields=>['ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } if (!$o->arecords()) { print '
'; } print '
'; } ##################################################################################################### # Restrict access to the following records # Unpriviledged users can only work on these records if they have permissions on the whole zone ##################################################################################################### if ( !$o->cnames && ($manager && ($manager->can($user, "edit", $o->zone) || $manager->can($user, "access_section", 'host.html:extra_records')) )){ ##################################################################################################### #RRPTR foreach my $arecord ( @arecs ) { next if int($arecord->ipblock) == 0; my $ipblock = $arecord->ipblock; # We can assume there is only one per IP my $ptr = $ipblock->ptr_records->first; print '
'; print '
Reverse for '.$ipblock->get_label.' '.$ui->table_descr_link('RRPTR', '(PTR)').'
'; print '
'; print ' '; if ( !$ptr ){ if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '[add]'; } } } print '
'; #close containerheadright print '
'; if ( $add_ptr == $ipblock->id ){ # new rrptr my $rzone; if ( ($ipblock->parent != 0) && $ipblock->parent->reverse_zone ){ $rzone = $ipblock->parent->reverse_zone; } push( @field_headers, ("Name", "Zone", "Domain Name", "TTL") ); print ''; print ''; if ( $rzone ){ my $name = RRPTR->get_name(ipblock=>$ipblock, zone=>$rzone); push( @cell_data, '' ); }else{ push( @cell_data, '' ); } my $zone_select = '
"; push( @cell_data, $zone_select ); push( @cell_data, '' ); push( @cell_data, '' ); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); print ''; print ''; } # display/edit if ( $ptr ) { $ui->add_to_fields(o=>$ptr, edit=>0, fields=>['rr', 'ptrdname', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['host.html', '', ''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } print '
'; } ##################################################################################################### #RRNS if ( $o->name eq '@' || $o->name eq $o->zone->name || (!$o->arecords && !$o->ptr_records) ){ print '
'; print '
Name Servers '.$ui->table_descr_link('RRNS', '(NS)').'
'; print '
'; #new rrns $ui->add_to_fields(table=>'RRNS', edit=>1, fields=>['nsdname', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','']); my $newns = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newns =~ s/\n//g; $newns =~ s/<script.*?<\/script>//g; $newns =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @nss = $o->ns_records()) { foreach my $ns (@nss) { $ui->add_to_fields(o=>$ns, edit=>$edit, fields=>['nsdname', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html',''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; } ##################################################################################################### #RRDS if ( !$o->arecords && !$o->ptr_records ){ print '
'; print '
Delegation Signers '.$ui->table_descr_link('RRDS', '(DS)').'
'; print '
'; my @field_names = ('key_tag', 'algorithm', 'digest_type', 'digest', 'ttl'); #new rrds $ui->add_to_fields(table=>'RRDS', edit=>1, fields=>\@field_names, field_headers=>\@field_headers, cell_data=>\@cell_data, ); my $newds = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newds =~ s/\n//g; $newds =~ s/<script.*?<\/script>//g; $newds =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @dss = $o->ds_records()) { foreach my $ds (@dss) { $ui->add_to_fields(o=>$ds, edit=>$edit, fields=>\@field_names, field_headers=>\@field_headers, cell_data=>\@cell_data, with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; } ##################################################################################################### #RRNAPTR if ( !$o->arecords && !$o->ptr_records && !$o->ns_records ){ print '
'; print '
Name Authority Pointer '.$ui->table_descr_link('RRNAPTR', '(NAPTR)').'
'; print '
'; #new rrnaptr $ui->add_to_fields(table=>'RRNAPTR', edit=>1, fields=>['order_field', 'preference', 'flags', 'services', 'regexpr', 'replacement', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','']); my $newnaptr = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newnaptr =~ s/\n//g; $newnaptr =~ s/<script.*?<\/script>//g; $newnaptr =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @naptrs = $o->naptr_records()) { foreach my $naptr (@naptrs) { $ui->add_to_fields(o=>$naptr, edit=>$edit, fields=>['order_field', 'preference', 'flags', 'services', 'regexpr', 'replacement', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','view.html',''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; } ##################################################################################################### #RRPTR (when the name is the PTR record's name) if ( !$o->arecords && !$o->ns_records ){ print '
'; print '
Pointer Records '.$ui->table_descr_link('RRPTR', '(PTR)').'
'; print '
'; #new rrptr push( @field_headers, "IP"); push( @cell_data, ""); $ui->add_to_fields(table=>'RRPTR', edit=>1, fields=>['ptrdname', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['']); my $newptr = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newptr =~ s/\n//g; $newptr =~ s/<script.*?<\/script>//g; $newptr =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @ptrs = $o->ptr_records()) { foreach my $ptr (@ptrs) { push( @field_headers, "IP"); if ($edit) { push( @cell_data, "" ); } else { push( @cell_data, "".$ptr->ipblock->address.""); } $ui->add_to_fields(o=>$ptr, edit=>$edit, fields=>['ptrdname', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['', ''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; } ##################################################################################################### #RRLOC if ( 1 ){ # Should this be omitted in some cases? print '
'; print '
Location Records '.$ui->table_descr_link('RRLOC', '(LOC)').'
'; print '
'; #new $ui->add_to_fields(table=>'RRLOC', edit=>1, fields=>['latitude', 'longitude', 'altitude', 'size', 'horiz_pre', 'vert_pre', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html', 'view.html', 'view.html', 'view.html', 'view.html', 'view.html', ''], ); my $newloc = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newloc =~ s/\n//g; $newloc =~ s/<script.*?<\/script>//g; $newloc =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @locs = $o->loc_records()) { foreach my $loc (@locs) { $ui->add_to_fields(o=>$loc, edit=>$edit, fields=>['latitude', 'longitude', 'altitude', 'size', 'horiz_pre', 'vert_pre', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html', 'view.html', 'view.html', 'view.html', 'view.html', 'view.html', ''], with_delete=>1 ); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; } ##################################################################################################### #RRSRV # Only show this part if owner name follows valid format if ( $o->name =~ /^_.+\._.+/ ){ print '
'; print '
Service Records '.$ui->table_descr_link('RRSRV', '(SRV)').'
'; print '
'; #new rrsrv $ui->add_to_fields(table=>'RRSRV', edit=>1, fields=>['priority', 'weight', 'port', 'target', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','view.html','view.html','view.html','']); my $newsrv = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newsrv =~ s/\n//g; $newsrv =~ s/<script.*?<\/script>//g; $newsrv =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @srvs = $o->srv_records()) { foreach my $srv (@srvs) { $ui->add_to_fields(o=>$srv, edit=>$edit, fields=>['priority', 'weight', 'port', 'target', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; } } # close restrict if print '
'; #close container } print ''; #close outer containerbody print ''; print ''; #close outer container