From 2fa3c71cc307f6e811d938b4737ffef89fed374f Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 13 Mar 2012 22:20:49 -0700 Subject: [PATCH] Use new UI for samba networking page --- samba/conf_net.cgi | 123 +++++++++++++++++---------------------------- samba/lang/en | 1 + 2 files changed, 48 insertions(+), 76 deletions(-) diff --git a/samba/conf_net.cgi b/samba/conf_net.cgi index 2596c1736..79d716104 100755 --- a/samba/conf_net.cgi +++ b/samba/conf_net.cgi @@ -13,111 +13,82 @@ require './samba-lib.pl'; &get_share("global"); -print "
\n"; -print "\n"; -print "\n"; -print "
$text{'net_title'}
\n"; -print "\n"; -printf "\n", - &getval("deadtime"); +print &ui_form_start("save_net.cgi", "post"); +print &ui_table_start($text{'net_title'}, undef, 2); -print "\n"; -printf "\n"; +print &ui_table_row($text{'net_idle'}, + &ui_opt_textbox("dead_time", &getval("deadtime"), 5, + $text{'config_never'})." ".$text{'config_mins'}); -print "\n"; -print "\n"; +$itable .= &ui_columns_end(); +print &ui_table_row($text{'net_netinterface'}, + &ui_radio("interfaces_def", $ifaces ? 0 : 1, + [ [ 1, $text{'net_auto'} ], + [ 0, $text{'net_uselist'} ] ])."
\n". + $itable); -print "\n"; -printf "\n", - &getval("keepalive"); +print &ui_table_row($text{'net_keepalive'}, + &ui_opt_textbox("keepalive", &getval("keepalive"), 5, + $text{'net_notsend'})." ".$text{'config_secs'}); -print "\n"; -printf "\n", - &getval("max xmit"); +print &ui_table_row($text{'net_maxpacket'}, + &ui_opt_textbox("max_xmit", &getval("max xmit"), 5, + $text{'default'})." ".$text{'config_bytes'}); -print "\n"; -printf "\n", - &getval("socket address"); +print &ui_table_row($text{'net_listen'}, + &ui_opt_textbox("socket_address", &getval("socket address"), 15, + $text{'config_all'}, $text{'net_ip'})); -print "\n"; -print "\n"; +print &ui_table_row($text{'net_socket'}, + &ui_grid_table(\@grid, 2)); -print "
$text{'net_idle'} $text{'config_never'}\n", - &getval("deadtime") eq "" ? "checked" : ""; -printf "\n", - &getval("deadtime") eq "" ? "" : "checked"; -printf " $text{'config_mins'}
$text{'net_trustlist'} $text{'config_none'}\n", - &getval("hosts equiv") eq "" ? "checked" : ""; -printf "", - &getval("hosts equiv") eq "" ? "" : "checked"; -printf "\n", - &getval("hosts equiv"); -print &file_chooser_button("hosts_equiv", 0); -print "
$text{'net_netinterface'}\n"; -printf " $text{'net_auto'} \n", - &getval("interfaces") ? "" : "checked"; -printf " $text{'net_uselist'}
\n", - &getval("interfaces") ? "checked" : ""; -print "\n"; -print "\n"; -@iflist = split(/\s+/, &getval("interfaces")); +print &ui_table_row($text{'net_trustlist'}, + &ui_opt_textbox("hosts_equiv", &getval("hosts equiv"), 40, + $text{'config_none'})." ". + &file_chooser_button("hosts_equiv", 0)); + +$ifaces = &getval("interfaces"); +$itable = &ui_columns_start([ $text{'net_interface'}, $text{'net_netmask'} ]); +@iflist = split(/\s+/, $ifaces); $len = @iflist ? @iflist+1 : 2; for($i=0; $i<$len; $i++) { - print "\n"; + my ($ip, $nm); if ($iflist[$i] =~ /^([0-9\.]+)\/([0-9]+)$/) { + $ip = $1; for($j=0; $j<$2; $j++) { $pw += 2**(31-$j); } - $n = sprintf "%u.%u.%u.%u", + $nm = sprintf "%u.%u.%u.%u", ($pw>>24)&0xff, ($pw>>16)&0xff, ($pw>>8)&0xff, ($pw)&0xff; - print "\n"; - print "\n"; } elsif ($iflist[$i] =~ /^([0-9\.]+)\/([0-9\.]+)$/) { - print "\n"; - print "\n"; + $ip = $1; + $nm = $2; } elsif ($iflist[$i] =~ /^(\S+)$/) { - print "\n"; - print "\n"; + $ip = $1; + $nm = ""; } - else { - print "\n"; - print "\n"; - } - print "\n"; + $itable .= &ui_columns_row([ + &ui_textbox("interface_ip$i", $ip, 15), + &ui_textbox("interface_nm$i", $nm, 15), + ]); } -print "
$text{'net_interface'} $text{'net_netmask'}
$text{'net_keepalive'} $text{'net_notsend'}\n", - &getval("keepalive") eq "" ? "checked" : ""; -printf "\n", - &getval("keepalive") eq "" ? "" : "checked"; -print "$text{'net_every'}\n"; -printf "$text{'config_secs'}
$text{'net_maxpacket'} $text{'default'}\n", - &getval("max xmit") eq "" ? "checked" : ""; -printf "\n", - &getval("max xmit") eq "" ? "" : "checked"; -printf " $text{'config_bytes'}
$text{'net_listen'} $text{'config_all'}\n", - &getval("socket address") eq "" ? "checked" : ""; -printf "\n", - &getval("socket address") eq "" ? "" : "checked"; -printf "
$text{'net_socket'}\n"; foreach (split(/\s+/, &getval("socket options"))) { if (/^([A-Z\_]+)=(.*)/) { $sopts{$1} = $2; } else { $sopts{$_} = ""; } } +@grid = ( ); for($i=0; $i<@sock_opts; $i++) { $sock_opts[$i] =~ /^([A-Z\_]+)(.*)$/; - if ($i%2 == 0) { print "\n"; } - printf "\n"; - if ($i%2 == 1) { print "\n"; } } -print "
$1\n", - defined($sopts{$1}) ? "checked" : ""; + $f = &ui_checkbox("$1", 1, "$1", defined($sopts{$1})); if ($2 eq "*") { - printf "\n", - $sopts{$1}; + $f .= " ".&ui_textbox("${1}_val", $sopts{$1}, 5); } + push(@grid, $f); print "

\n"; -print "

\n"; +print &ui_table_end(); +print &ui_form_end([ [ undef, $text{'save'} ] ]); &ui_print_footer("", $text{'index_sharelist'}); diff --git a/samba/lang/en b/samba/lang/en index e6bde98d8..0f2399ae8 100644 --- a/samba/lang/en +++ b/samba/lang/en @@ -120,6 +120,7 @@ net_notsend=Don't send any net_every=Send every net_maxpacket=Maximum packet size net_listen=Listen on address +net_ip=IP address net_socket=Socket options passwd_title=Password Options