#!/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 "
\n"; print "\n"; print "\n"; print "
$text{'esh_tabhdr'}
\n"; print "\n"; printf "\n", $sha ? &html_escape($sha->{'comment'}) : ""; print "\n"; printf "\n", $sha ? $sha->{'values'}->[0] : ""; &display_params($sconf, "shared-network"); print "\n"; print "
$text{'esh_desc'}
$text{'esh_netname'}
\n"; foreach $h (&find("host", $conf)) { push(@host, $h) if &can('r', \%access, $h); } foreach $g (&find("group", $conf)) { push(@group, $g) if &can('r', \%access, $g); } foreach $s (&find("subnet", $conf)) { push(@subn, $s) if &can('r', \%access, $s); } foreach $sh (&find("shared-network", $conf)) { foreach $h (&find("host", $sh->{'members'})) { push(@host, $h); # if &can('r', \%access, $h); $inshar{$h} = $sh->{'index'}; } foreach $g (&find("group", $sh->{'members'})) { push(@group, $g); # if &can('r', \%access, $g); $inshar{$g} = $sh->{'index'}; } foreach $s (&find("subnet", $sh->{'members'})) { push(@subn, $s); # if &can('r', \%access, $s); $inshar{$s} = $sh->{'index'}; } } @host = sort { $a->{'values'}->[0] cmp $b->{'values'}->[0] } @host; # @group = sort { @{$a->{'members'}} <=> @{$b->{'members'}} } @group; @subn = sort { $a->{'values'}->[0] cmp $b->{'values'}->[0] } @subn; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; 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 "{'index'},$sha->{'index'}\" type=hidden>\n"; } } # inaccessible groups in this shared network foreach $g (@group) { if (!&can('r', \%access, $g) && $inshar{$g} eq $sha->{'index'}) { print "{'index'},$sha->{'index'}\" type=hidden>\n"; } } # inaccessible subnets in this shared network foreach $s (@subn) { if (!&can('r', \%access, $s) && $inshar{$s} eq $sha->{'index'}) { print "{'index'},$sha->{'index'}\" type=hidden>\n"; } } } print "
$text{'esh_hosts'}$text{'esh_groups'}$text{'esh_subn'}
\n"; if (!$in{'new'}) { print "\n"; print "\n"; print "\n" if &can('rw', \%access, $sha); print "\n"; print "\n" if &can('rw', \%access, $sha, 1); print "
\n"; print "$text{'index_addhst'}  \n" if &can('rw', \%access, $sha); print "$text{'index_addhstg'}  \n" if &can('rw', \%access, $sha); print "$text{'index_addsub'}

\n" if &can('rw', \%access, $sha); } else { print "\n"; print "\n"; } if ($config{'dhcpd_version'} >= 3 && !$in{'new'}) { # Display address pools print "


\n"; print &ui_subheading($text{'esh_pools'}); local $pn = 1; foreach $p (&find('pool', $sconf)) { push(@links, "edit_pool.cgi?uidx=$in{'idx'}&idx=$p->{'index'}"); push(@titles, &text('esub_pool', $pn)); push(@icons, "images/pool.gif"); $pn++; } if ($pn == 1) { print "$text{'esub_poolnone'}

\n"; } else { &icons_table(\@links, \@titles, \@icons, 5); } print "", "$text{'esub_pooladd'}
\n"; } print "

\n"; &ui_print_footer("", $text{'esh_return'});