Skip to content

Commit

Permalink
More ui-lib conversion for ipnodes, plus mass deletion button
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Aug 18, 2008
1 parent 50fa599 commit cb4aae5
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 48 deletions.
22 changes: 22 additions & 0 deletions net/delete_ipnodes.cgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/local/bin/perl
# Delete several IPv6 host file entries

require './net-lib.pl';
&error_setup($text{'idelete_err'});
$access{'ipnodes'} == 2 || &error($text{'hosts_ecannot'});
&ReadParse();
@d = split(/\0/, $in{'d'});
@d || &error($text{'hdelete_enone'});

# Do the deletions
&lock_file($config{'ipnodes_file'});
@hosts = &list_ipnodes();
foreach $d (sort { $b <=> $a } @d) {
$host = $hosts[$d];
&delete_ipnode($host);
}

&unlock_file($config{'ipnodes_file'});
&webmin_log("delete", "ipnodes", scalar(@d));
&redirect("list_ipnodes.cgi");

36 changes: 19 additions & 17 deletions net/edit_ipnode.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,29 @@ else {
$h = $ipnodes[$in{'idx'}];
}

print "<form action=save_ipnode.cgi>\n";
print "<input type=hidden name=new value=\"$in{'new'}\">\n";
print "<input type=hidden name=idx value=\"$in{'idx'}\">\n";
print "<table border>\n";
print "<tr $tb> <td><b>$text{'ipnodes_detail'}</b></td> </tr>\n";
print "<tr $cb> <td><table>\n";
print "<tr> <td><b>$text{'ipnodes_ip'}</b></td>\n";
print "<td><input name=address size=30 value=\"$h->{'address'}\"></td> </tr>\n";
print "<tr $cb> <td valign=top><b>$text{'ipnodes_host'}</b></td>\n";
print "<td><textarea cols=30 rows=5 name=ipnodes>",
join("\n", @{$h->{'ipnodes'}}),"</textarea></td> </tr>\n";
print "<tr> <td colspan=2 align=right>\n";
# Form start
print &ui_form_start("save_ipnode.cgi");
print &ui_hidden("new", $in{'new'});
print &ui_hidden("idx", $in{'idx'});
print &ui_table_start($text{'ipnodes_detail'}, undef, 2);

# IPv6 address
print &ui_table_row($text{'ipnodes_ip'},
&ui_textbox("address", $h->{'address'}, 30));

# Hostnames for address
print &ui_table_row($text{'ipnodes_host'},
&ui_textarea("ipnodes", join("\n", @{$h->{'ipnodes'}}), 5, 50));

# End of the form
print &ui_table_end();
if ($in{'new'}) {
print "<input type=submit value=\"$text{'create'}\">\n";
print &ui_form_end([ [ undef, $text{'create'} ] ]);
}
else {
print "<input type=submit value=\"$text{'save'}\">\n";
print "<input type=submit name=delete value=\"$text{'delete'}\">\n";
print &ui_form_end([ [ undef, $text{'save'} ],
[ "delete", $text{'delete'} ] ]);
}
print "</table></td></tr></table>\n";
print "</form>\n";

&ui_print_footer("list_ipnodes.cgi", $text{'ipnodes_return'});

7 changes: 7 additions & 0 deletions net/lang/en
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ ipnodes_create=Create IPv6 Host Address
ipnodes_detail=Host and Addresses
ipnodes_return=IPv6 host addresses list
ipnodes_ecannot=You are not allowed to edit IPv6 host addresses
ipnodes_none=No IPv6 host addresses have been defined yet.
ipnodes_delete=Delete Selected IPv6 Host Addresses

log_create_host=Created host address $1
log_delete_host=Deleted host address $1
Expand All @@ -211,6 +213,7 @@ log_modify_bifc=Modified interface $1 address $2
log_delete_bifc=Deleted interface $1 address $2
log_dyn=dynamic
log_delete_hosts=Deleted $1 host addresses
log_delete_ipnodes=Deleted $1 IPv6 host addresses
log_delete_afics=Deleting $1 active interfaces
log_delete_bfics=Deleting $1 boot-time interfaces
log_apply_bfics=Activated $1 boot-time interfaces
Expand Down Expand Up @@ -283,3 +286,7 @@ daifcs_egone=Interface no longer exists!
dbifcs_err=Failed to delete interfaces
dbifcs_err2=Failed to activate interfaces

hdelete_err=Failed to delete host addresses
hdelete_enone=None selected
idelete_err=Failed to delete IPv6 host addresses

45 changes: 26 additions & 19 deletions net/list_ipnodes.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,34 @@ require './net-lib.pl';
$access{'ipnodes'} || &error($text{'ipnodes_ecannot'});
&ui_print_header(undef, $text{'ipnodes_title'}, "");

print "<a href=\"edit_ipnode.cgi?new=1\">$text{'ipnodes_add'}</a><br>\n"
if ($access{'ipnodes'} == 2);
print "<table border cellpadding=3>\n";
print "<tr $tb> <td><b>$text{'ipnodes_ip'}</b></td> ",
"<td><b>$text{'ipnodes_ipnode'}</b></td> </tr>\n";
# Build table contents
@table = ( );
foreach $h (&list_ipnodes()) {
print "<tr $cb>\n";
if ($access{'ipnodes'} == 2) {
print "<td><a href=\"edit_ipnode.cgi?idx=$h->{'index'}\">",
&html_escape($h->{'address'}),"</a></td>\n";
}
else {
print "<td>",&html_escape($h->{'address'}),"</td>\n";
}
print "<td>",join(" , ", map { &html_escape($_) }
@{$h->{'ipnodes'}}),"</td> </tr>\n";
push(@table, [ $access{'ipnodes'} == 2 ?
( { 'type' => 'checkbox', 'name' => 'd',
'value' => $h->{'index'} },
"<a href=\"edit_ipnode.cgi?idx=$h->{'index'}\">".
&html_escape($h->{'address'})."</a>" ) :
( &html_escape($h->{'address'}) ),
join(" , ", map { &html_escape($_) }
@{$h->{'ipnodes'}}),
]);
}
print "</table>\n";
print "<a href=\"edit_ipnode.cgi?new=1\">$text{'ipnodes_add'}</a>\n"
if ($access{'ipnodes'} == 2);
print "<p>\n";

# Show the table
print &ui_form_columns_table(
$access{'ipnodes'} == 2 ?
( "delete_ipnodes.cgi",
[ [ undef, $text{'ipnodes_delete'} ] ], 1 ) :
( undef, undef, 0 ),
$access{'ipnodes'} == 2 ?
[ [ "edit_ipnode.cgi?new=1", $text{'ipnodes_add'} ] ] : [ ],
undef,
[ $access{'ipnodes'} == 2 ? ( "" ) : ( ),
$text{'ipnodes_ip'}, $text{'ipnodes_ipnode'} ],
undef,
\@table,
undef, 1, undef, $text{'ipnodes_none'});

&ui_print_footer("", $text{'index_return'});

3 changes: 2 additions & 1 deletion net/log_parser.pl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ sub parse_webmin_log
elsif ($type eq 'ipnode') {
return &text("log_${action}_ipnode", "<tt>$object</tt>");
}
elsif ($type eq 'hosts' || $type eq 'aifcs' || $type eq 'bifcs') {
elsif ($type eq 'hosts' || $type eq 'ipnodes' ||
$type eq 'aifcs' || $type eq 'bifcs') {
return &text("log_${action}_${type}", $object);
}
elsif ($action eq 'dns') {
Expand Down
19 changes: 8 additions & 11 deletions net/solaris-lib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -359,21 +359,18 @@ sub routing_input
{
# show default router(s) input
local @defrt = &get_defaultrouters();
print "<tr> <td valign=top><b>$text{'routes_defaults'}</b></td>\n";
print "<td><textarea name=defrt rows=3 cols=40>",
join("\n", @defrt),"</textarea></td> </tr>\n";
print &ui_table_row($text{'routes_defaults'},
&ui_textarea("defrt", join("\n", @defrt), 3, 40));

# show router input
local $notrt = (-r "/etc/notrouter");
local $gatew = (-r "/etc/gateways");
print "<tr> <td><b>Act as router?</b></td> <td>\n";
printf "<input type=radio name=router value=0 %s> $text{'yes'}\n",
$gatew && !$notrt ? "checked" : "";
printf "<input type=radio name=router value=1 %s> $text{'routes_possible'}\n",
!$gatew && !$notrt ? "checked" : "";
printf "<input type=radio name=router value=2 %s> $text{'no'}\n",
$notrt ? "checked" : "";
print "</td> </tr>\n";
print &ui_table_row($text{'routes_forward'},
&ui_radio("router", $gatew && !$notrt ? 0 :
!$gatew && !$notrt ? 1 : 2,
[ [ 0, $text{'yes'} ],
[ 1, $text{'routes_possible'} ],
[ 2, $text{'no'} ] ]));
}

sub parse_routing
Expand Down

0 comments on commit cb4aae5

Please sign in to comment.