ui-lib conversion -> dhcpd

This commit is contained in:
Nawawi Jamili 2013-12-18 21:11:14 +08:00
parent 2ca7c21e46
commit 1a7dc5842c
12 changed files with 291 additions and 354 deletions

View File

@ -80,19 +80,19 @@ foreach $s (@shar) {
} }
} }
print "<form action=save_group.cgi method=post>\n"; print &ui_form_start("save_group.cgi", "post");
print "<input name=ret value=\"$in{'ret'}\" type=hidden>\n"; print &ui_hidden("ret",$in{'ret'});
print "<table border width=100%>\n"; print &ui_table_start($text{'egroup_tblhdr'}, "width=100%", 4);
print "<tr $tb> <td><b>$text{'egroup_tblhdr'}</b></td> </tr>\n";
print "<tr $cb> <td><table width=100%>\n";
print "<tr> <td><b>$text{'egroup_desc'}</b></td>\n"; print "<tr><td valign=middle><b>$text{'egroup_desc'}</b></td>\n";
printf "<td colspan=3><input name=desc size=60 value='%s'></td> </tr>\n", print "<td valign=middle colspan=3>";
&html_escape($group->{'comment'}); print &ui_textbox("desc", &html_escape($group->{'comment'}), 60);
print "</td>";
print "</tr>";
$rws = "rowspan=2" if (defined($in{'ret'})); $rws = (defined($in{'ret'}) ? " rowspan=2 " : " ");
print "<tr> <td $rws valign=top><b>$text{'egroup_hosts'}</b></td>\n"; print "<tr><td".$rws."valign=top><b>$text{'egroup_hosts'}</b></td>\n";
print "<td $rws><select name=hosts size=5 multiple>\n"; print "<td".$rws."valign=top>";
foreach $h (&find("host", $mems)) { foreach $h (&find("host", $mems)) {
push(@host, $h); push(@host, $h);
# if &can('r', \%access, $h); # if &can('r', \%access, $h);
@ -105,20 +105,19 @@ foreach $g (&find("group", $mems)) {
} }
} }
@host = sort { $a->{'values'}->[0] cmp $b->{'values'}->[0] } @host; @host = sort { $a->{'values'}->[0] cmp $b->{'values'}->[0] } @host;
my @hosts_sel;
foreach $h (@host) { foreach $h (@host) {
next if !&can('r', \%access, $h); next if !&can('r', \%access, $h);
printf "<option value=\"%s,%s\" %s>%s</option>\n", push(@hosts_sel, ["$h->{'index'},$ingroup{$h}", $h->{'values'}->[0], ((!$in{'new'}) && $ingroup{$h} eq $group->{'index'} ? "selected" : "") ] );
$h->{'index'}, $ingroup{$h},
(!$in{'new'}) && $ingroup{$h} eq $group->{'index'} ? "selected" : "",
$h->{'values'}->[0];
} }
print "</select></td>\n"; print &ui_select("hosts", undef, \@hosts_sel, 5, 1);
print "</td>\n";
if (!$in{'new'}) { if (!$in{'new'}) {
# inaccessible hosts in this group # inaccessible hosts in this group
foreach $h (@host) { foreach $h (@host) {
if (!&can('r', \%access, $h) && $ingroup{$h} eq $group->{'index'}) { if (!&can('r', \%access, $h) && $ingroup{$h} eq $group->{'index'}) {
print "<input name=hosts value=\"$h->{'index'},$group->{'index'}\" type=hidden>\n"; print &ui_hidden("hosts","$h->{'index'},$group->{'index'}");
} }
} }
} }
@ -126,7 +125,7 @@ if (!$in{'new'}) {
$assign = $in{'uidx'} ne "" ? "2" : $assign = $in{'uidx'} ne "" ? "2" :
$in{'sidx'} ne "" ? "1" : "0"; $in{'sidx'} ne "" ? "1" : "0";
if (!defined($in{'ret'})) { if (!defined($in{'ret'})) {
local @labels = ( $text{'ehost_toplevel'}, $text{'ehost_inshared'}, my @labels = ( $text{'ehost_toplevel'}, $text{'ehost_inshared'},
$text{'ehost_insubnet'} ); $text{'ehost_insubnet'} );
print "<td colspan=2><table><tr>"; print "<td colspan=2><table><tr>";
print "<td colspan=2>$text{'ehost_nojavascr'}</td></tr>\n<tr>" if ($in{'assign'}); print "<td colspan=2>$text{'ehost_nojavascr'}</td></tr>\n<tr>" if ($in{'assign'});
@ -134,48 +133,44 @@ if (!defined($in{'ret'})) {
if ($in{'assign'}) { if ($in{'assign'}) {
$assign = $in{'assign'}; $assign = $in{'assign'};
print "$labels[$assign]</td>\n"; print "$labels[$assign]</td>\n";
print "<input name=assign type=hidden value=$assign>\n"; print &ui_hidden("assign",$assign);
print "<input name=jsquirk type=hidden value=1>\n"; print &ui_hidden("jsquirk",1);
} }
else { else {
print "<select name=assign onChange='setparent(0)'>\n"; my @assign_sel;
for ($i = 0; $i <= 2; $i++) { for ($i = 0; $i <= 2; $i++) {
printf "<option value=$i %s>%s</option>\n", push(@assign_sel, [$i, $labels[$i], ( $assign == $i ? "selected" : "" ) ]);
$assign == $i ? "selected" : "",
$labels[$i];
} }
print "</select></td>\n"; print &ui_select("assign", undef, \@assign_sel, 1, undef, undef, undef, "onChange='setparent(0)'" );
print "</td>";
} }
print "<td><select name=parent size=5 width=120>\n"; print "<td>";
my @parent_sel;
if ($assign == 2) { if ($assign == 2) {
$iu = 0; $iu = 0;
foreach $u (@subn) { foreach $u (@subn) {
printf "<option value=\"%s\" %s>%s</option>\n", my $val1 = defined($shared{$u}) ? "$shared{$u},$u->{'index'}" : $u->{'index'};
defined($shared{$u}) ? "$shared{$u},$u->{'index'}" : $u->{'index'}, my $txt1 = $subn_desc[$iu] if &can('rw', \%access, $u);
$iu == $sel_parent ? "selected" : "", push(@parent_sel, [$val1, $txt1, ($iu == $sel_parent ? "selected" : "") ] );
$subn_desc[$iu] $iu++;
if &can('rw', \%access, $u);
$iu ++;
} }
} }
elsif ($assign == 1) { elsif ($assign == 1) {
$is = 0; $is = 0;
foreach $s (@shar) { foreach $s (@shar) {
printf "<option value=\"%s\" %s>%s</option>\n", my $txt2 = $shar_desc[$is] if &can('rw', \%access, $s);
$s->{'index'}, push(@parent_sel, [$s->{'index'}, $txt1, ($is == $sel_parent ? "selected" : "") ] );
$is == $sel_parent ? "selected" : "", $is++;
$shar_desc[$is]
if &can('rw', \%access, $s);
$is ++;
} }
} }
print "</select></td></tr>\n"; print &ui_select("parent", undef, \@parent_sel, 5, undef, undef, undef, "width=120");
print "</td></tr>\n";
print "</table></td>\n"; print "</table></td>\n";
print "</tr> <tr>\n"; print "</tr><tr>\n";
} }
else { else {
print "<input name=assign type=hidden value=$assign>\n", print &ui_hidden("assign",$assign);
print "<input name=parent type=hidden value=$currpar>\n"; print &ui_hidden("parent",$currpar);
} }
print &choice_input($text{'egroup_nchoice'}, "use-host-decl-names", print &choice_input($text{'egroup_nchoice'}, "use-host-decl-names",
@ -184,30 +179,26 @@ print &choice_input($text{'egroup_nchoice'}, "use-host-decl-names",
print "</tr> <tr>\n" if (defined($in{'ret'})); print "</tr> <tr>\n" if (defined($in{'ret'}));
&display_params($gconf, "group"); &display_params($gconf, "group");
print "</table></td></tr></table>\n"; print "</table>";
print "<input type=hidden name=sidx value=\"$in{'sidx'}\">\n"; print &ui_table_end();
print "<input type=hidden name=uidx value=\"$in{'uidx'}\">\n";
print &ui_hidden("sidx",$in{'sidx'});
print &ui_hidden("uidx",$in{'uidx'});
if (!$in{'new'}) { if (!$in{'new'}) {
print "<input type=hidden name=idx value=\"$in{'idx'}\">\n"; print &ui_hidden("idx",$in{'idx'});
print "<table width=100%><tr>\n"; print "<table width=100%><tr>\n";
print "<td><input type=submit value=\"$text{'save'}\"></td>\n" print "<td>".&ui_submit($text{'save'})."</td>" if &can('rw', \%access, $group);
if &can('rw', \%access, $group); print "<td align=center>".&ui_submit(( &can('rw', \%access, $group) ? $text{'butt_eco'} : $text{'butt_vco'} ),"options")."</td>";
print "<td align=center><input type=submit name=options value=\"", print "<td align=right>".&ui_submit($text{'delete'},"delete")."</td>" if &can('rw', \%access, $group, 1);
&can('rw', \%access, $group) ? $text{'butt_eco'} : $text{'butt_vco'},
"\"></td>\n";
print "<td align=right><input type=submit name=delete ",
"value=\"$text{'delete'}\"></td>\n"
if &can('rw', \%access, $group, 1);
print "</tr></table>\n"; print "</tr></table>\n";
print "<a href=\"edit_host.cgi?new=1&sidx=".$in{'sidx'}."&uidx=".$in{'uidx'} print &ui_link("edit_host.cgi?new=1&sidx=".$in{'sidx'}."&uidx=".$in{'uidx'}."&gidx=".$in{'idx'}."&ret=group",$text{'index_addhst'}) if &can('rw', \%access, $group);
."&gidx=".$in{'idx'}."&ret=group\">"
.$text{'index_addhst'}."</a><p>\n" if &can('rw', \%access, $group);
} }
else { else {
print "<input type=hidden name=new value=1>\n"; print &ui_hidden("new",1);
print "<input type=submit value=\"$text{'create'}\">\n"; print &ui_submit($text{'create'});
} }
print "</form>\n"; print &ui_form_end();
print &script_fn() if (!defined($in{'ret'})); print &script_fn() if (!defined($in{'ret'}));
if ($in{'ret'} eq "subnet") { if ($in{'ret'} eq "subnet") {
&ui_print_footer("edit_subnet.cgi?sidx=$in{'sidx'}&idx=$in{'uidx'}", &ui_print_footer("edit_subnet.cgi?sidx=$in{'sidx'}&idx=$in{'uidx'}",

View File

@ -23,7 +23,7 @@ else {
# display # display
if ($in{'uidx'} ne '') { if ($in{'uidx'} ne '') {
local $s = $in{'sidx'} eq '' ? $conf->[$in{'uidx'}] : my $s = $in{'sidx'} eq '' ? $conf->[$in{'uidx'}] :
$conf->[$in{'sidx'}]->{'members'}->[$in{'uidx'}]; $conf->[$in{'sidx'}]->{'members'}->[$in{'uidx'}];
$desc = &text('ehost_subnet', $s->{'values'}->[0], $s->{'values'}->[2]); $desc = &text('ehost_subnet', $s->{'values'}->[0], $s->{'values'}->[2]);
} }
@ -153,132 +153,122 @@ foreach $s (@shar) {
} }
$is ++; $is ++;
} }
print &ui_form_start("save_host.cgi", "post");
print &ui_hidden("ret",$in{'ret'});
print &ui_table_start($text{'ehost_tabhdr'}, "width=100%", 4);
print "<form action=save_host.cgi method=post>\n"; print "<tr><td valign=middle><b>$text{'ehost_desc'}</b></td>\n";
print "<input name=ret value=\"$in{'ret'}\" type=hidden>\n"; print "<td valign=middle colspan=3>";
print "<table border width=100%>\n"; print &ui_textbox("desc", &html_escape($host->{'comment'}), 60);
print "<tr $tb> <td><b>$text{'ehost_tabhdr'}</b></td> </tr>\n"; print "</td>";
print "<tr $cb> <td><table width=100%>\n"; print "</tr>";
print "<tr> <td><b>$text{'ehost_desc'}</b></td>\n"; print "<tr><td valign=middle><b>$text{'ehost_hname'}</b></td>\n";
printf "<td colspan=3><input name=desc size=60 value='%s'></td> </tr>\n", print "<td valign=middle>";
&html_escape($host->{'comment'}); print &ui_textbox("name", ( $host ? $host->{'values'}->[0] : "" ), 20);
print "</td>\n";
print "<tr> <td><b>$text{'ehost_hname'}</b></td>\n";
printf "<td><input name=name size=20 value=\"%s\"></td>\n",
$host ? $host->{'values'}->[0] : "";
$assign = $in{'gidx'} ne "" ? "3" : $assign = $in{'gidx'} ne "" ? "3" :
$in{'uidx'} ne "" ? "2" : $in{'uidx'} ne "" ? "2" :
$in{'sidx'} ne "" ? "1" : "0"; $in{'sidx'} ne "" ? "1" : "0";
if (!defined($in{'ret'})) { if (!defined($in{'ret'})) {
local @labels = ( $text{'ehost_toplevel'}, $text{'ehost_inshared'}, my @labels = ( $text{'ehost_toplevel'}, $text{'ehost_inshared'},
$text{'ehost_insubnet'}, $text{'ehost_ingroup'} ); $text{'ehost_insubnet'}, $text{'ehost_ingroup'} );
print "<td colspan=2 rowspan=2><table><tr>"; print "<td valign=top colspan=2 rowspan=2><table><tr>";
print "<td colspan=2>$text{'ehost_nojavascr'}</td></tr>\n<tr>" if ($in{'assign'}); print "<td colspan=2>$text{'ehost_nojavascr'}</td></tr>\n<tr>" if ($in{'assign'});
print "<td valign=top><b>$text{'ehost_assign'}</b><br>\n"; print "<td valign=top><b>$text{'ehost_assign'}</b><br>\n";
if ($in{'assign'}) { if ($in{'assign'}) {
$assign = $in{'assign'}; $assign = $in{'assign'};
print "$labels[$assign]</td>\n"; print "$labels[$assign]</td>\n";
print "<input name=assign type=hidden value=$assign>\n"; print &ui_hidden("assign",$assign);
print "<input name=jsquirk type=hidden value=1>\n"; print &ui_hidden("jsquirk",1);
} }
else { else {
print "<select name=assign onChange='setparent(0)'>\n"; my @assign_sel;
for ($i = 0; $i <= 3; $i++) { for ($i = 0; $i <= 3; $i++) {
printf "<option value=$i %s>%s</option>\n", push(@assign_sel, [$i, $labels[$i], ( $assign == $i ? "selected" : "" ) ]);
$assign == $i ? "selected" : "",
$labels[$i];
} }
print "</select></td>\n"; print &ui_select("assign", undef, \@assign_sel, 1, undef, undef, undef, "onChange='setparent(0)'" );
print "</td>\n";
} }
print "<td><select name=parent size=5 width=120>\n"; print "<td>";
my @parent_sel;
if ($assign == 3) { if ($assign == 3) {
$ig = 0; $ig = 0;
foreach $g (@group) { foreach $g (@group) {
printf "<option value=\"%s\" %s>%s</option>\n", my $val = (defined($shared{$g}) ? "$shared{$g}," : "").(defined($subnet{$g}) ? "$subnet{$g}," : "").$g->{'index'};
(defined($shared{$g}) ? "$shared{$g}," : ""). my $txt = $group_desc[$ig] if &can('rw', \%access, $g);
(defined($subnet{$g}) ? "$subnet{$g}," : ""). push(@parent_sel, [$val, $txt, ($ig == $sel_parent ? "selected" : "") ] );
$g->{'index'}, $ig++;
$ig == $sel_parent ? "selected" : "",
$group_desc[$ig]
if &can('rw', \%access, $g);
$ig ++;
} }
} }
elsif ($assign == 2) { elsif ($assign == 2) {
$iu = 0; $iu = 0;
foreach $u (@subn) { foreach $u (@subn) {
printf "<option value=\"%s\" %s>%s</option>\n", my $val1 = defined($shared{$u}) ? "$shared{$u},$u->{'index'}" : $u->{'index'};
defined($shared{$u}) ? "$shared{$u},$u->{'index'}" : $u->{'index'}, my $txt1 = $subn_desc[$iu] if &can('rw', \%access, $u);
$iu == $sel_parent ? "selected" : "", push(@parent_sel, [$val1, $txt1, ($iu == $sel_parent ? "selected" : "") ] );
$subn_desc[$iu] $iu++;
if &can('rw', \%access, $u);
$iu ++;
} }
} }
elsif ($assign == 1) { elsif ($assign == 1) {
$is = 0; $is = 0;
foreach $s (@shar) { foreach $s (@shar) {
printf "<option value=\"%s\" %s>%s</option>\n", my $txt2 = $shar_desc[$is] if &can('rw', \%access, $s);
$s->{'index'}, push(@parent_sel, [$s->{'index'}, $txt1, ($is == $sel_parent ? "selected" : "") ] );
$is == $sel_parent ? "selected" : "", $is++;
$shar_desc[$is]
if &can('rw', \%access, $s);
$is ++;
} }
} }
print "</select></td></tr>\n"; print &ui_select("parent", undef, \@parent_sel, 5, undef, undef, undef, "width=120");
print "</td></tr>\n";
print "</table></td>\n"; print "</table></td>\n";
print "</tr><tr>\n";
print "</tr> <tr>\n";
} }
else { else {
print "<input name=assign type=hidden value=$assign>\n"; print &ui_hidden("assign",$assign);
print "<input name=parent type=hidden value=$currpar>\n"; print &ui_hidden("parent",$currpar);
} }
$hard = $hconf ? &find("hardware", $hconf) : undef; $hard = $hconf ? &find("hardware", $hconf) : undef;
print "<td><b>$text{'ehost_hwaddr'}</b></td>\n"; print "<td valign=middle><b>$text{'ehost_hwaddr'}</b></td>\n";
print "<td nowrap><select name=hardware_type>\n"; print "<td valign=middle nowrap>";
printf "<option %s>ethernet</option>\n", my @hardware_type_sel;
$hard && $hard->{'values'}->[0] eq "ethernet" ? "selected" : ""; my @hardware = ("ethernet","token-ring","fddi");
printf "<option %s>token-ring</option>\n", foreach my $hv (@hardware) {
$hard && $hard->{'values'}->[0] eq "token-ring" ? "selected" : ""; push(@hardware_type_sel, [$hv,$hv, ($hard && $hard->{'values'}->[0] eq $hv ? "selected" : "")] );
printf "<option %s>fddi</option>\n", }
$hard && $hard->{'values'}->[0] eq "fddi" ? "selected" : ""; print &ui_select("hardware_type", undef, \@hardware_type_sel, 1);
print "</select>"; print &ui_textbox("hardware", ( $hard ? $hard->{'values'}->[1] : "" ), 18);
printf "<input name=hardware size=18 value=\"%s\"></td> </tr>\n", print "</td></tr>\n";
$hard ? $hard->{'values'}->[1] : "";
$fixed = $host ? &find("fixed-address", $hconf) : ""; $fixed = $host ? &find("fixed-address", $hconf) : "";
print "<tr> <td><b>$text{'ehost_fixedip'}</b></td> <td>\n"; print "<tr><td><b>$text{'ehost_fixedip'}</b></td><td>\n";
printf "<input name=fixed-address size=20 value=\"%s\"></td>\n", print &ui_textbox("fixed-address", ( $fixed ? join(" ", grep { $_ ne "," } @{$fixed->{'values'}}) : "" ), 20);
$fixed ? join(" ", grep { $_ ne "," } @{$fixed->{'values'}}) : ""; print "</td>\n";
&display_params($hconf, "host"); &display_params($hconf, "host");
print "</table></td></tr></table>\n"; print &ui_table_end();
print "<input type=hidden name=gidx value=\"$in{'gidx'}\">\n";
print "<input type=hidden name=uidx value=\"$in{'uidx'}\">\n"; print &ui_hidden("gidx",$in{'gidx'});
print "<input type=hidden name=sidx value=\"$in{'sidx'}\">\n"; print &ui_hidden("uidx",$in{'uidx'});
print &ui_hidden("sidx",$in{'sidx'});
if (!$in{'new'}) { if (!$in{'new'}) {
print "<input type=hidden name=idx value=\"$in{'idx'}\">\n"; print &ui_hidden("idx",$in{'idx'});
print "<table width=100%><tr>\n"; print "<table width=100%><tr>\n";
print "<td><input type=submit value=\"$text{'save'}\"></td>\n" print "<td>".&ui_submit($text{'save'})."</td>" if &can('rw', \%access, $host);
if &can('rw', \%access, $host); print "<td align=center>".&ui_submit(( &can('rw', \%access, $host) ? $text{'butt_eco'} : $text{'butt_vco'} ),"options")."</td>";
print "<td align=center><input type=submit name=options value=\"", print "<td align=right>".&ui_submit($text{'delete'},"delete")."</td>" if &can('rw', \%access, $host, 1);
&can('rw', \%access, $host) ? $text{'butt_eco'} : $text{'butt_vco'},
"\"></td>\n";
print "<td align=right><input type=submit name=delete ",
"value=\"$text{'delete'}\"></td>\n"
if &can('rw', \%access, $host, 1);
print "</tr></table>\n"; print "</tr></table>\n";
} }
else { else {
print "<input type=hidden name=new value=1>\n"; print &ui_hidden("new",1);
print "<input type=submit value=\"$text{'butt_create'}\">\n"; print &ui_submit($text{'butt_create'});
} }
print "</form>\n";
print &ui_form_end();
print &script_fn() if (!defined($in{'ret'})); print &script_fn() if (!defined($in{'ret'}));
if ($in{'ret'} eq "group") { if ($in{'ret'} eq "group") {
&ui_print_footer("edit_group.cgi?sidx=$in{'sidx'}&uidx=$in{'uidx'}&idx=$in{'gidx'}", &ui_print_footer("edit_group.cgi?sidx=$in{'sidx'}&uidx=$in{'uidx'}&idx=$in{'gidx'}",
@ -298,7 +288,7 @@ else {
sub script_fn sub script_fn
{ {
return <<EOF return <<EOF
<script> <script type='text/javascript'>
function setparent(sel) function setparent(sel)
{ {
var idx = document.forms[0].assign.selectedIndex; var idx = document.forms[0].assign.selectedIndex;
@ -325,3 +315,4 @@ setparent($sel_parent);
EOF EOF
} }

View File

@ -89,27 +89,28 @@ else {
&ui_print_header(undef, $text{'iface_title'}, ""); &ui_print_header(undef, $text{'iface_title'}, "");
print "$text{'iface_desc'}<p>\n"; print "$text{'iface_desc'}<p>\n";
print "<form action=save_iface.cgi>\n"; print &ui_form_start("save_iface.cgi", "post");
print "<table><tr>\n"; print &ui_table_start(undef, undef, 2);
print "<td valign=top><b>$text{'iface_listen'}</b></td>\n"; my $val;
if (&foreign_check("net")) { if (&foreign_check("net")) {
%got = map { $_, 1 } split(/\s+/, $iface); %got = map { $_, 1 } split(/\s+/, $iface);
&foreign_require("net", "net-lib.pl"); &foreign_require("net", "net-lib.pl");
@ifaces = grep { $_->{'virtual'} eq '' } &net::active_interfaces(); @ifaces = grep { $_->{'virtual'} eq '' } &net::active_interfaces();
$sz = scalar(@ifaces); $sz = scalar(@ifaces);
print "<td><select name=iface multiple size=$sz>\n"; my @iface_sel;
foreach $i (@ifaces) { foreach $i (@ifaces) {
$n = $i->{'fullname'}; $n = $i->{'fullname'};
printf "<option value=%s %s>%s (%s)</option>\n", push(@iface_sel,[$n,$n." (".&net::iface_type($n).")", ($got{$n} ? 'selected' : '') ]);
$n, $got{$n} ? 'selected' : '', $n, &net::iface_type($n);
} }
print "</select></td>\n"; $val = &ui_select("iface",undef,\@iface_sel,$sz,1);
} }
else { else {
print "<td><input name=iface size=30 value='$iface'></td>\n"; $val = &ui_textbox("iface",$iface,30);
} }
print "</tr></table>\n"; print &ui_table_row($text{'iface_listen'}, $val);
print "<input type=submit value='$text{'save'}'></form>\n"; print &ui_table_end();
print &ui_submit($text{'save'});
print &ui_form_end(undef,undef,1);
&ui_print_footer("", $text{'listl_return'}); &ui_print_footer("", $text{'listl_return'});

View File

@ -25,33 +25,31 @@ else {
$key = $sub->{'members'}->[$in{'idx'}]; $key = $sub->{'members'}->[$in{'idx'}];
} }
print "<form action=save_keys.cgi>\n"; print &ui_form_start("save_keys.cgi", "post");
print "<table border>\n"; print &ui_columns_start([$text{'keys_id'}, $text{'keys_alg'}, $text{'keys_secret'}]);
print "<tr $tb> <td><b>$text{'keys_id'}</b></td> ",
"<td><b>$text{'keys_alg'}</b></td> ",
"<td><b>$text{'keys_secret'}</b></td> </tr>\n";
for($i=0; $i<@keys; $i++) { for($i=0; $i<@keys; $i++) {
$k = $keys[$i]; $k = $keys[$i];
print "<tr $cb>\n"; my @column_row;
printf "<td><input name=id_$i size=15 value='%s'></td>\n", push(@column_row, &ui_textbox("id_".$i, $k->{'value'}, 15) );
$k->{'value'};
@algs = ( "hmac-md5" ); my @algs = ( "hmac-md5" );
$alg = &find_value("algorithm", $k->{'members'}); $alg = &find_value("algorithm", $k->{'members'});
print "<td><select name=alg_$i>\n"; my @algs_sel;
local $found;
my $found;
foreach $a (@algs) { foreach $a (@algs) {
printf "<option %s>%s</option>\n", $alg eq $a ? "selected" : "", $a; push(@algs_sel, [$a, $a, ($alg eq $a ? "selected" : "") ] );
$found++ if ($alg eq $a); $found++ if ($alg eq $a);
} }
print "<option selected>$alg</option>\n" if (!$found && $alg); push(@algs_sel,[$alg, $alg, ""]) if (!$found && $alg);
print "</select></td>\n"; push(@column_row, &ui_select("alg_".$i, undef, \@algs_sel, 1) );
push(@column_row, &ui_textbox("secret_".$i, &find_value("secret", $k->{'members'}), 64) );
printf "<td><input name=secret_$i size=64 value='%s'></td> </tr>\n", print &ui_columns_row(\@column_row);
&find_value("secret", $k->{'members'});
} }
print "</table>\n"; print &ui_columns_end();
print "<input type=submit value=\"$text{'save'}\"></form>\n"; print &ui_submit($text{'save'});
print &ui_form_end(undef,undef,1);
&ui_print_footer("", $text{'index_return'}); &ui_print_footer("", $text{'index_return'});

View File

@ -54,16 +54,13 @@ $backlink .= "?idx=".$in{'idx'}."&gidx=".$in{'gidx'}."&uidx=".$in{'uidx'}.
"&sidx=".$in{'sidx'} if (backlink); "&sidx=".$in{'sidx'} if (backlink);
&ui_print_header($title, $text{'eopt_header'}, ""); &ui_print_header($title, $text{'eopt_header'}, "");
print "<form action=save_options.cgi method=post>\n"; print &ui_form_start("save_options.cgi", "post");
printf "<input type=hidden name=level value='%s'>\n", print &ui_hidden("level",($in{'global'} ? "global" : $client->{'name'}) );
$in{'global'} ? "global" : $client->{'name'}; print &ui_hidden("idx", $in{'idx'});
print "<input type=hidden name=idx value='$in{'idx'}'>\n"; print &ui_hidden("gidx", $in{'gidx'});
print "<input type=hidden name=gidx value='$in{'gidx'}'>\n"; print &ui_hidden("uidx", $in{'uidx'});
print "<input type=hidden name=uidx value='$in{'uidx'}'>\n"; print &ui_hidden("sidx", $in{'sidx'});
print "<input type=hidden name=sidx value='$in{'sidx'}'>\n"; print &ui_table_start($text{'eopt_tabhdr'}, "width=100%", 4);
print "<table border width=100%>\n";
print "<tr $tb> <td><b>$text{'eopt_tabhdr'}</b></td> </tr>\n";
print "<tr $cb> <td><table width=100%>\n";
@opts = &find("option", $client->{'members'}); @opts = &find("option", $client->{'members'});
print "<tr>\n"; print "<tr>\n";
@ -136,25 +133,22 @@ print "</tr>\n";
if ($config{'dhcpd_version'} >= 3) { if ($config{'dhcpd_version'} >= 3) {
# Show option definitions # Show option definitions
print "<tr> <td colspan=4><hr></td> </tr>\n"; print "<tr><td colspan=4><hr></td></tr>\n";
@defs = grep { $_->{'values'}->[1] eq 'code' && @defs = grep { $_->{'values'}->[1] eq 'code' &&
$_->{'values'}->[3] eq '=' } @opts; $_->{'values'}->[3] eq '=' } @opts;
push(@defs, undef); push(@defs, undef);
for($i=0; $i<@defs; $i++) { for($i=0; $i<@defs; $i++) {
$o = $defs[$i]; $o = $defs[$i];
print "<tr>\n"; print "<tr>\n";
print "<td><b>$text{'eopt_def'}</b></td> <td nowrap colspan=3>\n"; print "<td><b>$text{'eopt_def'}</b></td><td nowrap colspan=3>\n";
print "$text{'eopt_dname'}\n"; print "$text{'eopt_dname'}\n";
printf "<input name=dname_$i size=15 value='%s'>\n", print &ui_textbox("dname_".$i, $o->{'values'}->[0], 15);
$o->{'values'}->[0];
print "$text{'eopt_dnum'}\n"; print "$text{'eopt_dnum'}\n";
printf "<input name=dnum_$i size=4 value='%s'>\n", print &ui_textbox("dnum_".$i, $o->{'values'}->[2], 4);
$o->{'values'}->[2];
print "$text{'eopt_dtype'}\n"; print "$text{'eopt_dtype'}\n";
my $a=scalar(@{$o->{'values'}})-1; my $a=scalar(@{$o->{'values'}})-1;
printf "<input name=dtype_$i size=40 value='%s'>\n", print &ui_textbox("dtype_".$i, join(" ",@{$o->{'values'}}[4..$a]), 40);
join(" ",@{$o->{'values'}}[4..$a]); print "</td></tr>\n";
print "</td> </tr>\n";
} }
# Find option definitions at higher levels # Find option definitions at higher levels
@ -177,7 +171,7 @@ if ($config{'dhcpd_version'} >= 3) {
push(@custom, undef) if (@custom%2 == 1); push(@custom, undef) if (@custom%2 == 1);
for($i=0; $i<@custom; $i++) { for($i=0; $i<@custom; $i++) {
$o = $custom[$i]; $o = $custom[$i];
print "<tr> <td><b>$text{'eopt_custom'}</b></td>\n"; print "<tr><td><b>$text{'eopt_custom'}</b></td>\n";
print "<td nowrap colspan=3>$text{'eopt_cname'}\n"; print "<td nowrap colspan=3>$text{'eopt_cname'}\n";
local ($ov, @v) = @{$o->{'values'}}; local ($ov, @v) = @{$o->{'values'}};
print &ui_select("cname_$i", $ov, print &ui_select("cname_$i", $ov,
@ -186,13 +180,13 @@ if ($config{'dhcpd_version'} >= 3) {
1, 0, $ov ? 1 : 0); 1, 0, $ov ? 1 : 0);
print "$text{'eopt_cval'}\n"; print "$text{'eopt_cval'}\n";
print &ui_textbox("cval_$i", join(" ", @v), 40); print &ui_textbox("cval_$i", join(" ", @v), 40);
print "</td> </tr>\n"; print "</td></tr>\n";
} }
} }
} }
else { else {
# Show custom numeric options # Show custom numeric options
print "<tr> <td colspan=4><hr></td> </tr>\n"; print "<tr><td colspan=4><hr></td></tr>\n";
@custom = grep { $_->{'values'}->[0] =~ /^option-(\S+)$/ && @custom = grep { $_->{'values'}->[0] =~ /^option-(\S+)$/ &&
$_->{'values'}->[1] ne 'code' } @opts; $_->{'values'}->[1] ne 'code' } @opts;
push(@custom, undef); push(@custom, undef);
@ -202,19 +196,17 @@ else {
print "<tr>\n" if ($i%2 == 0); print "<tr>\n" if ($i%2 == 0);
print "<td><b>$text{'eopt_custom'}</b></td>\n"; print "<td><b>$text{'eopt_custom'}</b></td>\n";
print "<td nowrap>$text{'eopt_cnum'}\n"; print "<td nowrap>$text{'eopt_cnum'}\n";
local ($ov, @v) = @{$o->{'values'}}; my ($ov, @v) = @{$o->{'values'}};
printf "<input name=cnum_$i size=4 value='%s'>\n", print &ui_textbox("cnum_".$i, ( $ov =~ /^option-(\S+)$/ ? $1 : '' ), 4);
$ov =~ /^option-(\S+)$/ ? $1 : '';
print "$text{'eopt_cval'}\n"; print "$text{'eopt_cval'}\n";
printf "<input name=cval_$i size=15 value='%s'></td>\n", print &ui_textbox("cval_".$i, join(" ", @v), 15);
join(" ", @v);
print "</tr>\n" if ($i%2 != 0); print "</tr>\n" if ($i%2 != 0);
} }
} }
if ($in{'global'}) { if ($in{'global'}) {
# Display options for subnets and hosts too # Display options for subnets and hosts too
print "<tr> <td colspan=4><hr></td> </tr>\n"; print "<tr><td colspan=4><hr></td></tr>\n";
print "<tr>\n"; print "<tr>\n";
print &choice_input($text{'egroup_nchoice'}, "use-host-decl-names", print &choice_input($text{'egroup_nchoice'}, "use-host-decl-names",
$conf, $text{'yes'}, "on", $text{'no'}, "off", $conf, $text{'yes'}, "on", $text{'no'}, "off",
@ -222,9 +214,13 @@ if ($in{'global'}) {
&display_params($conf, "global"); &display_params($conf, "global");
} }
print "</table></td></tr></table>\n"; print &ui_table_end();
print "<input type=submit value=\"$text{'save'}\"></form>\n" print &ui_submit($text{'save'});
if &can('rw',\%access,$client); print &ui_form_end();
#print "<input type=submit value=\"$text{'save'}\"></form>\n"
# if &can('rw',\%access,$client);
&ui_print_footer($backlink, $back); &ui_print_footer($backlink, $back);
# option_input(text, name, &config, type, [initial-boolean]) # option_input(text, name, &config, type, [initial-boolean])
@ -237,7 +233,7 @@ print "<input type=submit value=\"$text{'save'}\"></form>\n"
# 6 - String list # 6 - String list
sub option_input sub option_input
{ {
local($rv, $v, $i); my($rv, $v, $i);
for($i=0; $i<@{$_[2]}; $i++) { for($i=0; $i<@{$_[2]}; $i++) {
if ($_[2]->[$i]->{'values'}->[0] eq $_[1]) { if ($_[2]->[$i]->{'values'}->[0] eq $_[1]) {
$v = $_[2]->[$i]; $v = $_[2]->[$i];
@ -247,48 +243,48 @@ for($i=0; $i<@{$_[2]}; $i++) {
$rv = "<td><b>$_[0]</b></td>\n"; $rv = "<td><b>$_[0]</b></td>\n";
if ($_[3] == 5 || $_[3] == 6 || $_[4]) { $rv .= "<td colspan=3 nowrap>"; } if ($_[3] == 5 || $_[3] == 6 || $_[4]) { $rv .= "<td colspan=3 nowrap>"; }
else { $rv .= "<td nowrap>"; } else { $rv .= "<td nowrap>"; }
$rv .= sprintf "<input type=radio name=$_[1]_def value=1 %s> $text{'default'}\n",
$v ? "" : "checked"; $rv .= &ui_radio($_[1]."_def", ( $v ? 0 : 1 ),
$rv .= sprintf "<input type=radio name=$_[1]_def value=0 %s> ", [ [ 1, $text{'default'} ],
$v ? "checked" : ""; [ 0, "&nbsp;" ] ]);
local @vl = $v ? @{$v->{'values'}} : ();
my @vl = $v ? @{$v->{'values'}} : ();
@vl = @vl[1..$#vl]; @vl = @vl[1..$#vl];
local $bool; my $bool;
if ($_[4]) { if ($_[4]) {
$bool = shift(@vl); $bool = shift(@vl);
} }
if ($_[3] == 0) { if ($_[3] == 0) {
$rv .= "<input name=$_[1] size=15 value=\"$vl[0]\">\n"; $rv .= &ui_textbox($_[1], $vl[0], 15);
} }
elsif ($_[3] == 1) { elsif ($_[3] == 1) {
$rv .= "<input name=$_[1] size=4 value=\"$vl[0]\">\n"; $rv .= &ui_textbox($_[1], $vl[0], 4);
} }
elsif ($_[3] == 2) { elsif ($_[3] == 2) {
@vl = map { s/,//g; $_ } grep { $_ ne "," } @vl; @vl = map { s/,//g; $_ } grep { $_ ne "," } @vl;
$rv .= "<input name=$_[1] size=20 value=\"".join(" ", @vl)."\">\n"; $rv .= &ui_textbox($_[1], join(" ", @vl), 20);
} }
elsif ($_[3] == 3) { elsif ($_[3] == 3) {
local $str = &oct_to_string($vl[0]); my $str = &oct_to_string($vl[0]);
$rv .= "<input name=$_[1] size=20 value=\"$str\">\n"; $rv .= &ui_textbox($_[1], $str, 20);
} }
elsif ($_[3] == 4) { elsif ($_[3] == 4) {
$rv .= sprintf "<input name=$_[1] value=1 %s> Yes\n", $rv .= &ui_radio($_[1], $vl[0],
$vl[0] eq "1" ? "checked" : ""; [ [ 1, $text{'yes'} ],
$rv .= sprintf "<input name=$_[1] value=0 %s> No\n", [ 0, $text{'no'} ] ]);
$vl[0] eq "0" ? "checked" : "";
} }
elsif ($_[3] == 5) { elsif ($_[3] == 5) {
@vl = grep { $_ ne "," } @vl; @vl = grep { $_ ne "," } @vl;
$rv .= "<input name=$_[1] size=50 value=\""; my $val;
for($i=0; $i<@vl; $i+=2) { for($i=0; $i<@vl; $i+=2) {
$rv .= " " if ($i); $val .= " " if ($i);
$rv .= $vl[$i].",".$vl[$i+1]; $val .= $vl[$i].",".$vl[$i+1];
} }
$rv .= "\">\n"; $rv .= &ui_textbox($_[1], $val, 50);
} }
elsif ($_[3] == 6) { elsif ($_[3] == 6) {
@vl = map { s/,//g; $_ } grep { $_ ne "," } @vl; @vl = map { s/,//g; $_ } grep { $_ ne "," } @vl;
$rv .= "<input name=$_[1] size=50 value=\"".join(" ", @vl)."\">\n"; $rv .= &ui_textbox($_[1], join(" ", @vl), 50);
} }
if ($_[4]) { if ($_[4]) {
$rv .= &ui_checkbox($_[1]."_bool", 1, $_[4], lc($bool) eq "true"); $rv .= &ui_checkbox($_[1]."_bool", 1, $_[4], lc($bool) eq "true");
@ -299,8 +295,8 @@ return $rv;
sub oct_to_string sub oct_to_string
{ {
local @b = split(/:/, $_[0]); my @b = split(/:/, $_[0]);
local $rv; my $rv;
foreach $b (@b) { foreach $b (@b) {
if ($b !~ /^[A-z0-9]{1,2}$/) { if ($b !~ /^[A-z0-9]{1,2}$/) {
# Wasn't actually in octet format after all. # Wasn't actually in octet format after all.

View File

@ -39,7 +39,7 @@ print "</td>";
&display_params($sconf, "shared-network"); &display_params($sconf, "shared-network");
print "<tr><td colspan=4><table border=0 width=100%>\n"; print "<tr><td valign=top colspan=4><table border=0 width=100%>\n";
foreach $h (&find("host", $conf)) { foreach $h (&find("host", $conf)) {
push(@host, $h) if &can('r', \%access, $h); push(@host, $h) if &can('r', \%access, $h);
} }
@ -71,59 +71,56 @@ foreach $sh (&find("shared-network", $conf)) {
@subn = sort { $a->{'values'}->[0] cmp $b->{'values'}->[0] } @subn; @subn = sort { $a->{'values'}->[0] cmp $b->{'values'}->[0] } @subn;
print "<td valign=top align=right><b>$text{'esh_hosts'}</b></td>\n"; print "<td valign=top align=right><b>$text{'esh_hosts'}</b></td>\n";
print "<td><select name=hosts size=3 multiple>\n"; print "<td valign=top>";
my @esh_hosts;
foreach $h (@host) { foreach $h (@host) {
next if !&can('r', \%access, $h); next if !&can('r', \%access, $h);
printf "<option value=\"%s,%s\" %s>%s</option>\n", push(@esh_hosts, [$h->{'index'}.",".$inshar{$h}, $h->{'values'}->[0], ( (!$in{'new'}) && $inshar{$h} eq $sha->{'index'} ? "selected" : "" ) ] );
$h->{'index'}, $inshar{$h},
(!$in{'new'}) && $inshar{$h} eq $sha->{'index'} ? "selected" : "",
$h->{'values'}->[0];
} }
print "</select></td>\n"; print &ui_select("hosts", undef, \@esh_hosts, 3, 1);
print "</td>\n";
print "<td valign=top align=right><b>$text{'esh_groups'}</b></td>\n"; print "<td valign=top align=right><b>$text{'esh_groups'}</b></td>\n";
print "<td><select name=groups size=3 multiple>\n"; print "<td valign=top>";
my @esh_groups_sel;
foreach $g (@group) { foreach $g (@group) {
local $gm = 0; my $gm = 0;
next if !&can('r', \%access, $g); next if !&can('r', \%access, $g);
foreach $h (@{$g->{'members'}}) { foreach $h (@{$g->{'members'}}) {
if ($h->{'name'} eq "host") { $gm++; } if ($h->{'name'} eq "host") { $gm++; }
} }
printf "<option value=\"%s,%s\" %s>%s</option>\n", push(@esh_groups_sel, [$g->{'index'}.",".$inshar{$g}, &group_name($gm, $g), ( (!$in{'new'}) && $inshar{$g} eq $sha->{'index'} ? "selected" : "" ) ] );
$g->{'index'}, $inshar{$g},
(!$in{'new'}) && $inshar{$g} eq $sha->{'index'} ? "selected" : "",
&group_name($gm, $g);
} }
print "</select></td>\n"; print &ui_select("groups", undef, \@esh_groups_sel, 3, 1);
print "</td>\n";
print "<td valign=top align=right><b>$text{'esh_subn'}</b></td>\n"; print "<td valign=top align=right><b>$text{'esh_subn'}</b></td>\n";
print "<td><select name=subnets size=3 multiple>\n"; print "<td valign=top>";
my @esh_subn_sel;
foreach $s (@subn) { foreach $s (@subn) {
next if !&can('r', \%access, $s); next if !&can('r', \%access, $s);
printf "<option value=\"%s,%s\" %s>%s</option>\n", push(@esh_subn_sel, [$s->{'index'}.",".$inshar{$s}, $s->{'values'}->[0], ( (!$in{'new'}) && $inshar{$s} eq $sha->{'index'} ? "selected" : "" ) ] );
$s->{'index'}, $inshar{$s},
(!$in{'new'}) && $inshar{$s} eq $sha->{'index'} ? "selected" : "",
$s->{'values'}->[0];
} }
print "</select></td>\n"; print &ui_select("subnets", undef, \@esh_subn_sel, 3, 1);
print "</td>\n";
if (!$in{'new'}) { if (!$in{'new'}) {
# inaccessible hosts in this shared network # inaccessible hosts in this shared network
foreach $h (@host) { foreach $h (@host) {
if (!&can('r', \%access, $h) && $inshar{$h} eq $sha->{'index'}) { if (!&can('r', \%access, $h) && $inshar{$h} eq $sha->{'index'}) {
print "<input name=hosts value=\"$h->{'index'},$sha->{'index'}\" type=hidden>\n"; print &ui_hidden("hosts","$h->{'index'},$sha->{'index'}");
} }
} }
# inaccessible groups in this shared network # inaccessible groups in this shared network
foreach $g (@group) { foreach $g (@group) {
if (!&can('r', \%access, $g) && $inshar{$g} eq $sha->{'index'}) { if (!&can('r', \%access, $g) && $inshar{$g} eq $sha->{'index'}) {
print "<input name=groups value=\"$g->{'index'},$sha->{'index'}\" type=hidden>\n"; print &ui_hidden("groups","$g->{'index'},$sha->{'index'}");
} }
} }
# inaccessible subnets in this shared network # inaccessible subnets in this shared network
foreach $s (@subn) { foreach $s (@subn) {
if (!&can('r', \%access, $s) && $inshar{$s} eq $sha->{'index'}) { if (!&can('r', \%access, $s) && $inshar{$s} eq $sha->{'index'}) {
print "<input name=subnets value=\"$s->{'index'},$sha->{'index'}\" type=hidden>\n"; print &ui_hidden("subnets","$s->{'index'},$sha->{'index'}");
} }
} }
} }
@ -132,37 +129,34 @@ print "</table></td></tr>\n";
print &ui_table_end(); print &ui_table_end();
if (!$in{'new'}) { if (!$in{'new'}) {
print "<input type=hidden name=idx value=\"$in{'idx'}\">\n"; print &ui_hidden("idx", $in{'idx'});
print "<table width=100%><tr>\n"; print "<table width=100%><tr>\n";
print "<td><input type=submit value=\"$text{'save'}\"></td>\n" print "<td>";
if &can('rw', \%access, $sha); print &ui_submit($text{'save'}) if &can('rw', \%access, $sha);
print "<td align=center><input type=submit name=options value=\"", print "</td>";
&can('rw', \%access, $sha) ? $text{'butt_eco'} : $text{'butt_vco'}, print "<td align=center>";
"\"></td>\n"; print &ui_submit( (&can('rw', \%access, $sha) ? $text{'butt_eco'} : $text{'butt_vco'} ), "options");
print "<td align=right><input type=submit name=delete ", print "</td>";
"value=\"$text{'delete'}\"></td>\n" print "<td align=right>";
if &can('rw', \%access, $sha, 1); print &ui_submit($text{'delete'}, "delete") if &can('rw', \%access, $sha, 1);
print "</td>";
print "</tr></table>\n"; print "</tr></table>\n";
print "<a href=\"edit_host.cgi?new=1&sidx=$in{'idx'}" if ( &can('rw', \%access, $sha) ) {
."&ret=shared\">$text{'index_addhst'}</a>&nbsp;&nbsp;\n" print &ui_link("edit_host.cgi?new=1&sidx=$in{'idx'}&ret=shared",$text{'index_addhst'})."&nbsp;&nbsp;";
if &can('rw', \%access, $sha); print &ui_link("edit_group.cgi?new=1&sidx=$in{'idx'}&ret=shared",$text{'index_addhstg'})."&nbsp;&nbsp;";
print "<a href=\"edit_group.cgi?new=1&sidx=$in{'idx'}" print &ui_link("edit_subnet.cgi?new=1&sidx=$in{'idx'}&ret=shared",$text{'index_addsub'})."&nbsp;&nbsp;";
."&ret=shared\">$text{'index_addhstg'}</a>&nbsp;&nbsp;\n" }
if &can('rw', \%access, $sha);
print "<a href=\"edit_subnet.cgi?new=1&sidx=$in{'idx'}"
."&ret=shared\">$text{'index_addsub'}</a><p>\n"
if &can('rw', \%access, $sha);
} }
else { else {
print "<input type=hidden name=new value=1>\n"; print &ui_hidden("new",1);
print "<input type=submit value=\"$text{'create'}\">\n"; print &ui_submit($text{'create'});
} }
if ($config{'dhcpd_version'} >= 3 && !$in{'new'}) { if ($config{'dhcpd_version'} >= 3 && !$in{'new'}) {
# Display address pools # Display address pools
print &ui_hr(); print &ui_hr();
print &ui_subheading($text{'esh_pools'}); print &ui_subheading($text{'esh_pools'});
local $pn = 1; my $pn = 1;
foreach $p (&find('pool', $sconf)) { foreach $p (&find('pool', $sconf)) {
push(@links, "edit_pool.cgi?uidx=$in{'idx'}&idx=$p->{'index'}"); push(@links, "edit_pool.cgi?uidx=$in{'idx'}&idx=$p->{'index'}");
push(@titles, &text('esub_pool', $pn)); push(@titles, &text('esub_pool', $pn));
@ -175,8 +169,8 @@ if ($config{'dhcpd_version'} >= 3 && !$in{'new'}) {
else { else {
&icons_table(\@links, \@titles, \@icons, 5); &icons_table(\@links, \@titles, \@icons, 5);
} }
print "<a href='edit_pool.cgi?uidx=$in{'idx'}&new=1'>", print &ui_link("edit_pool.cgi?uidx=$in{'idx'}&new=1",$text{'esub_pooladd'});
"$text{'esub_pooladd'}</a><br>\n"; print "<br>";
} }
print &ui_form_end(); print &ui_form_end();

View File

@ -139,14 +139,12 @@ if (!$in{'new'}) {
foreach $h (@host) { foreach $h (@host) {
if (!&can('r', \%access, $h) && $insubn{$h} eq $sub->{'index'}) { if (!&can('r', \%access, $h) && $insubn{$h} eq $sub->{'index'}) {
print &ui_hidden("hosts","$h->{'index'},$sub->{'index'}"); print &ui_hidden("hosts","$h->{'index'},$sub->{'index'}");
#print "<input name=hosts value=\"$h->{'index'},$sub->{'index'}\" type=hidden>\n";
} }
} }
# inaccessible groups in this subnet # inaccessible groups in this subnet
foreach $g (@group) { foreach $g (@group) {
if (!&can('r', \%access, $g) && $insubn{$g} eq $sub->{'index'}) { if (!&can('r', \%access, $g) && $insubn{$g} eq $sub->{'index'}) {
print &ui_hidden("groups","$g->{'index'},$sub->{'index'}"); print &ui_hidden("groups","$g->{'index'},$sub->{'index'}");
#print "<input name=groups value=\"$g->{'index'},$sub->{'index'}\" type=hidden>\n";
} }
} }
} }
@ -187,7 +185,7 @@ if ($config{'dhcpd_version'} >= 3 && !$in{'new'}) {
# Display address pools # Display address pools
print &ui_hr(); print &ui_hr();
print &ui_subheading($text{'esub_pools'}); print &ui_subheading($text{'esub_pools'});
local $pn = 1; my $pn = 1;
foreach $p (&find('pool', $sconf)) { foreach $p (&find('pool', $sconf)) {
push(@links, "edit_pool.cgi?uidx=$in{'idx'}&sidx=$in{'sidx'}&idx=$p->{'index'}"); push(@links, "edit_pool.cgi?uidx=$in{'idx'}&sidx=$in{'sidx'}&idx=$p->{'index'}");
push(@titles, &text('esub_pool', $pn)); push(@titles, &text('esub_pool', $pn));

View File

@ -20,12 +20,10 @@ if (!$access{'ro'}) {
print &text('text_desc', "<tt>$file</tt>"),"<p>\n"; print &text('text_desc', "<tt>$file</tt>"),"<p>\n";
} }
print "<form action=save_text.cgi method=post enctype=multipart/form-data>\n"; print &ui_form_start("save_text.cgi", "form-data");
print "<textarea name=text rows=20 cols=80>", print &ui_textarea("text", join("", @lines), 20, 80);
join("", @lines),"</textarea><p>\n"; print "<p>";
print "<input type=submit value=\"$text{'save'}\"> ", print &ui_submit($text{'save'})."&nbsp;".&ui_reset($text{'text_undo'});
"<input type=reset value=\"$text{'text_undo'}\">\n" print &ui_form_end(undef,undef,1);
if (!$access{'ro'});
print "</form>\n";
&ui_print_footer("",$text{'text_return'}); &ui_print_footer("",$text{'text_return'});

View File

@ -8,6 +8,7 @@
require './dhcpd-lib.pl'; require './dhcpd-lib.pl';
require './params-lib.pl'; require './params-lib.pl';
&ReadParse(); &ReadParse();
%access = &get_module_acl();
$access{'zones'} || &error($text{'zone_ecannot'}); $access{'zones'} || &error($text{'zone_ecannot'});
$conf = &get_config(); $conf = &get_config();
$in{'new'} || (($par, $zone) = &get_branch('zone')); $in{'new'} || (($par, $zone) = &get_branch('zone'));
@ -16,55 +17,34 @@ $sconf = $zone->{'members'};
# display # display
&ui_print_header(undef, $in{'new'} ? $text{'zone_crheader'} : $text{'zone_eheader'}, ""); &ui_print_header(undef, $in{'new'} ? $text{'zone_crheader'} : $text{'zone_eheader'}, "");
print "<form action=save_zones.cgi method=post>\n"; print &ui_form_start("save_zones.cgi", "post");
print "<table border width=100%>\n"; print &ui_table_start($text{'zone_tabhdr'}, "width=100%", 2);
print "<tr $tb> <td><b>$text{'zone_tabhdr'}</b></td> </tr>\n"; print &ui_table_row($text{'zone_desc'}, &ui_textbox("desc", ($zone ? &html_escape($zone->{'comment'}) : ""), 60) );
print "<tr $cb> <td><table width=100%>\n"; print &ui_table_row($text{'zone_name'}, &ui_textbox("name", ($zone ? &html_escape($zone->{'value'}) : ""), 60) );
print &ui_table_row($text{'zone_primary'}, &ui_textbox("primary", ($zone ? &html_escape(find_value("primary",$zone->{'members'})) : ""), 15) );
print "<tr> <td><b>$text{'zone_desc'}</b></td>\n"; my @keys = sort { $a->{'values'}->[0] cmp $b->{'values'}->[0] } (find("key", $conf));
printf "<td colspan=3><input name=desc size=60 value='%s'></td> </tr>\n", my $keyname=find_value("key",$zone->{'members'});
$zone ? &html_escape($zone->{'comment'}) : ""; my @key_sel;
print "<tr> <td><b>$text{'zone_name'}</b></td>\n";
printf "<td colspan=3><input name=name size=60 value='%s'></td> </tr>\n",
$zone ? &html_escape($zone->{'value'}) : "";
print "<tr> <td><b>$text{'zone_primary'}</b></td>\n";
printf "<td colspan=3><input name=primary size=15 value='%s'></td> </tr>\n",
$zone ? &html_escape(find_value("primary",$zone->{'members'})) : "";
print "<tr>\n";
@keys = sort { $a->{'values'}->[0] cmp $b->{'values'}->[0] } (find("key", $conf));
print "<td valign=top align=left><b>$text{'zone_tsigkey'}</b></td>\n";
print "<td><select name=key size=1>\n";
local $keyname=find_value("key",$zone->{'members'});
foreach $k (@keys) { foreach $k (@keys) {
$curkeyname=$k->{'values'}->[0]; $curkeyname=$k->{'values'}->[0];
printf "<option value=\"%s\" %s>%s</option>\n", push(@key_sel, [$curkeyname, $curkeyname, (!$in{'new'} && $curkeyname eq $keyname ? "selected" : "") ] );
$curkeyname,
(!$in{'new'} && $curkeyname eq $keyname ? "selected" : ""),
$curkeyname;
} }
print "</select></td>\n";
print &ui_table_row($text{'zone_tsigkey'}, &ui_select("key", undef, \@key_sel, 1) );
print &ui_table_end();
print "</table></td></tr>\n";
print "</table>\n";
print "<table width=100%><tr>\n";
if (!$in{'new'}) { if (!$in{'new'}) {
print "<input type=hidden name=idx value=\"$in{'idx'}\">\n"; print &ui_hidden("idx", $in{'idx'});
print "<td align=left><input type=submit value=\"$text{'save'}\"></td>\n"; print &ui_submit($text{'save'})."&nbsp;".&ui_submit($text{'delete'},"delete");
print "<td align=right><input type=submit name=delete ", "value=\"$text{'delete'}\"></td>\n";
} }
else { else {
print "<td align=left><input type=hidden name=new value=1>\n"; print &ui_hidden("new",1);
print "<input type=submit value=\"$text{'create'}\"></td>\n"; print &ui_submit($text{'create'});
} }
print "</tr></table>\n";
print "</form>\n"; print &ui_form_end();
&ui_print_footer("", $text{'zone_return'}); &ui_print_footer("", $text{'zone_return'});

View File

@ -595,7 +595,7 @@ for ($i = $_[1]; $i < $_[2]; $i++) {
$sp = "\&nbsp;\&nbsp;"; $sp = "\&nbsp;\&nbsp;";
} }
if ($_[3]->[$i]) { if ($_[3]->[$i]) {
$firstcol .= "<a href=$_[3]->[$i]>$_[4]->[$i]</a>"; $firstcol .= &ui_link($_[3]->[$i], $_[4]->[$i]);
} }
else { else {
$firstcol .= $_[4]->[$i]; $firstcol .= $_[4]->[$i];
@ -643,7 +643,7 @@ for ($i = $_[1]; $i < $_[2]; $i++) {
$sp = "\&nbsp;\&nbsp;"; $sp = "\&nbsp;\&nbsp;";
} }
if ($_[3]->[$i]) { if ($_[3]->[$i]) {
$first .= "<a href=$_[3]->[$i]>$_[4]->[$i]</a>"; $first .= &ui_link($_[3]->[$i],$_[4]->[$i]);
} }
else { else {
$first .= $_[4]->[$i]; $first .= $_[4]->[$i];
@ -677,9 +677,9 @@ if ($show_subnet_delete) {
push(@links, &select_all_link("d"), push(@links, &select_all_link("d"),
&select_invert_link("d")); &select_invert_link("d"));
} }
push(@links, "<a href='edit_subnet.cgi?new=1'>$text{'index_addsub'}</a>") push(@links, &ui_link("edit_subnet.cgi?new=1",$text{'index_addsub'}) )
if $access{'c_sub'}; if $access{'c_sub'};
push(@links, "<a href='edit_shared.cgi?new=1'>$text{'index_addnet'}</a>") push(@links, &ui_link("edit_shared.cgi?new=1",$text{'index_addnet'}) )
if $access{'c_sha'}; if $access{'c_sha'};
print &ui_links_row(\@links); print &ui_links_row(\@links);
} }
@ -691,9 +691,9 @@ if ($show_host_delete) {
push(@links, &select_all_link("d", 1), push(@links, &select_all_link("d", 1),
&select_invert_link("d", 1)); &select_invert_link("d", 1));
} }
push(@links, "<a href='edit_host.cgi?new=1'>$text{'index_addhst'}</a>") push(@links, &ui_link("edit_host.cgi?new=1",$text{'index_addhst'}) )
if $access{'c_hst'}; if $access{'c_hst'};
push(@links, "<a href='edit_group.cgi?new=1'>$text{'index_addhstg'}</a>") push(@links, &ui_link("edit_group.cgi?new=1",$text{'index_addhstg'}) )
if $access{'c_grp'}; if $access{'c_grp'};
print &ui_links_row(\@links); print &ui_links_row(\@links);
} }

View File

@ -86,8 +86,7 @@ else {
foreach $m (0, 1) { foreach $m (0, 1) {
$msg = $text{'listl_mode_'.$m}; $msg = $text{'listl_mode_'.$m};
if ($m != $in{'bysubnet'}) { if ($m != $in{'bysubnet'}) {
$msg = "<a href='list_leases.cgi?bysubnet=$m'>". $msg = &ui_link("list_leases.cgi?bysubnet=$m",$msg);
"$msg</a>";
} }
push(@links, $msg); push(@links, $msg);
} }
@ -173,8 +172,7 @@ else {
$links = "<table width=100%><tr><td>". $links = "<table width=100%><tr><td>".
&ui_links_row(\@links). &ui_links_row(\@links).
"</td><td align=right>". "</td><td align=right>".
&ui_links_row([ "<a href='list_leases.cgi?$in'>". &ui_links_row([ &ui_link("list_leases.cgi?$in",$text{'listl_refresh'}) ]).
"$text{'listl_refresh'}</a>" ]).
"</td></tr></table>\n"; "</td></tr></table>\n";
print $links; print $links;
print &ui_columns_start([ print &ui_columns_start([
@ -282,7 +280,7 @@ if ($in{'sort'} eq $c) {
return $text{'listl_'.$c}; return $text{'listl_'.$c};
} }
else { else {
return "<a href='list_leases.cgi?all=$in{'all'}&network=$in{'network'}&netmask=$in{'netmask'}&sort=$c'>".$text{'listl_'.$c}."</a>"; return &ui_link("list_leases.cgi?all=$in{'all'}&network=$in{'network'}&netmask=$in{'netmask'}&sort=$c",$text{'listl_'.$c});
} }
} }

View File

@ -58,16 +58,13 @@ if ($config{'dhcpd_version'} >= 3) {
$vals{$a->{'values'}->[0]} = $a; $vals{$a->{'values'}->[0]} = $a;
} }
local $uc = $vals{'unknown-clients'}->{'name'}; local $uc = $vals{'unknown-clients'}->{'name'};
print "<tr> <td><b>$text{'plib_unclients'}</b></td> <td colspan=3>\n"; print "<tr><td><b>$text{'plib_unclients'}</b></td><td colspan=3>\n";
printf "<input type=radio name=unclients value=allow %s> %s\n", print &ui_radio("unclients", $uc,
$uc eq 'allow' ? "checked" : "", $text{'plib_allow'}; [ [ "allow", $text{'plib_allow'} ],
printf "<input type=radio name=unclients value=deny %s> %s\n", [ "deny", $text{'plib_deny'} ],
$uc eq 'deny' ? "checked" : "", $text{'plib_deny'}; [ "ignore", $text{'plib_ignore'} ],
printf "<input type=radio name=unclients value=ignore %s> %s\n", [ "", $text{'default'} ] ]);
$uc eq 'ignore' ? "checked" : "", $text{'plib_ignore'}; print "</td></tr>\n";
printf "<input type=radio name=unclients value='' %s> %s\n",
$uc ? "" : "checked", $text{'default'};
print "</td> </tr>\n";
######## START CLIENT-UPDATES ##### ######## START CLIENT-UPDATES #####
@ -80,15 +77,13 @@ if ($config{'dhcpd_version'} >= 3) {
$vals{$a->{'values'}->[0]} = $a; $vals{$a->{'values'}->[0]} = $a;
} }
local $cu = $vals{'client-updates'}->{'name'}; local $cu = $vals{'client-updates'}->{'name'};
print "<tr> <td><b>$text{'plib_clientupdates'}</b></td> <td colspan=3>\n"; print "<tr><td valign=middle><b>$text{'plib_clientupdates'}</b></td><td valign=middle colspan=3>\n";
printf "<input type=radio name=clientupdates value=allow %s> %s\n", print &ui_radio("clientupdates", $cu,
$cu eq 'allow' ? "checked" : "", $text{'plib_allow'}; [ [ "allow", $text{'plib_allow'} ],
printf "<input type=radio name=clientupdates value=deny %s> %s\n", [ "deny", $text{'plib_deny'} ],
$cu eq 'deny' ? "checked" : "", $text{'plib_deny'}; [ "ignore", $text{'plib_ignore'} ],
printf "<input type=radio name=clientupdates value=ignore %s> %s\n", [ "", $text{'default'} ] ]);
$cu eq 'ignore' ? "checked" : "", $text{'plib_ignore'};
printf "<input type=radio name=clientupdates value='' %s> %s\n",
$cu ? "" : "checked", $text{'default'};
print "</td> </tr>\n"; print "</td> </tr>\n";
} }
@ -97,14 +92,11 @@ if ($config{'dhcpd_version'} >= 3) {
if ($_[1] eq 'subnet' || $_[1] eq 'shared-network' || if ($_[1] eq 'subnet' || $_[1] eq 'shared-network' ||
$_[1] eq 'global') { $_[1] eq 'global') {
# Inputs for authoratative # Inputs for authoratative
local $auth = &find("authoritative", $_[0]); my $auth = &find("authoritative", $_[0]);
print "<tr> <td><b>",$text{'plib_auth_'.$_[1]},"</b></td>\n"; print "<tr><td><b>",$text{'plib_auth_'.$_[1]},"</b></td>\n";
printf "<td><input type=radio name=auth value=1 %s> %s\n", print "<td>";
$auth ? "checked" : "", $text{'yes'}; print &ui_yesno_radio("auth", ( $auth ? 1: 0 ), 1, 0);
printf "<input type=radio name=auth value=0 %s> %s (%s)</td>\n", print "</td></tr>\n";
$auth ? "" : "checked", $text{'default'}, $text{'no'};
print "</tr>\n";
} }
} }