#!/usr/local/bin/perl # edit_shared.cgi # Edit or create a shared network require './dhcpd-lib.pl'; require './params-lib.pl'; &ReadParse(); $conf = &get_config(); ($par, $sha) = &get_branch('sha'); $sconf = $sha->{'members'}; # check acls %access = &get_module_acl(); &error_setup($text{'eacl_aviol'}); if ($in{'new'} ) { &error("$text{'eacl_np'} $text{'eacl_pin'}") unless &can('c', \%access, $sha) && &can('rw', \%access, $par); } else { &error("$text{'eacl_np'} $text{'eacl_psn'}") if !&can('r', \%access, $sha); } # display &ui_print_header(undef, $in{'new'} ? $text{'esh_crheader'} : $text{'esh_eheader'}, ""); print &ui_form_start("save_shared.cgi", "post"); print &ui_table_start($text{'esh_tabhdr'}, "width=100%", 4); print "
| $text{'esh_hosts'} | \n"; print ""; my @esh_hosts; foreach $h (@host) { next if !&can('r', \%access, $h); push(@esh_hosts, [$h->{'index'}.",".$inshar{$h}, $h->{'values'}->[0], ( (!$in{'new'}) && $inshar{$h} eq $sha->{'index'} ? "selected" : "" ) ] ); } print &ui_select("hosts", undef, \@esh_hosts, 3, 1); print " | \n"; print "$text{'esh_groups'} | \n"; print ""; my @esh_groups_sel; foreach $g (@group) { my $gm = 0; next if !&can('r', \%access, $g); foreach $h (@{$g->{'members'}}) { if ($h->{'name'} eq "host") { $gm++; } } push(@esh_groups_sel, [$g->{'index'}.",".$inshar{$g}, &group_name($gm, $g), ( (!$in{'new'}) && $inshar{$g} eq $sha->{'index'} ? "selected" : "" ) ] ); } print &ui_select("groups", undef, \@esh_groups_sel, 3, 1); print " | \n"; print "$text{'esh_subn'} | \n"; print ""; my @esh_subn_sel; foreach $s (@subn) { next if !&can('r', \%access, $s); push(@esh_subn_sel, [$s->{'index'}.",".$inshar{$s}, $s->{'values'}->[0], ( (!$in{'new'}) && $inshar{$s} eq $sha->{'index'} ? "selected" : "" ) ] ); } print &ui_select("subnets", undef, \@esh_subn_sel, 3, 1); print " | \n"; if (!$in{'new'}) { # inaccessible hosts in this shared network foreach $h (@host) { if (!&can('r', \%access, $h) && $inshar{$h} eq $sha->{'index'}) { print &ui_hidden("hosts","$h->{'index'},$sha->{'index'}"); } } # inaccessible groups in this shared network foreach $g (@group) { if (!&can('r', \%access, $g) && $inshar{$g} eq $sha->{'index'}) { print &ui_hidden("groups","$g->{'index'},$sha->{'index'}"); } } # inaccessible subnets in this shared network foreach $s (@subn) { if (!&can('r', \%access, $s) && $inshar{$s} eq $sha->{'index'}) { print &ui_hidden("subnets","$s->{'index'},$sha->{'index'}"); } } } print "
| "; print &ui_submit($text{'save'}) if &can('rw', \%access, $sha); print " | "; print ""; print &ui_submit( (&can('rw', \%access, $sha) ? $text{'butt_eco'} : $text{'butt_vco'} ), "options"); print " | "; print ""; print &ui_submit($text{'delete'}, "delete") if &can('rw', \%access, $sha, 1); print " | "; print "
\n";
}
else {
&icons_table(\@links, \@titles, \@icons, 5);
}
print &ui_link("edit_pool.cgi?uidx=$in{'idx'}&new=1",$text{'esub_pooladd'});
print "
";
}
print &ui_form_end();
&ui_print_footer("", $text{'esh_return'});