From a751d0d5bc05bcdb2452591ba8aad3348b8658cf Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Sat, 7 Dec 2013 20:03:14 +0800 Subject: [PATCH 1/3] ui-lib conversion -> mysql/index.cgi --- mysql/index.cgi | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mysql/index.cgi b/mysql/index.cgi index 03d7fd203..e56cd5202 100755 --- a/mysql/index.cgi +++ b/mysql/index.cgi @@ -75,13 +75,10 @@ if ($r == 0) { if ($access{'stop'} && &is_mysql_local()) { print &ui_hr(); - print "
\n"; - print "\n"; - print "
\n"; - print "",&text('index_startmsg', - "$config{'start_cmd'}"),"
\n"; - print "
\n"; + print &ui_buttons_start(); + print &ui_buttons_row("start.cgi", + $text{'index_start'}, &text('index_startmsg',"$config{'start_cmd'}")); + print &ui_buttons_end(); } } elsif ($r == -1) { From a752f2738d5f46af7817d57226c905391f237656 Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Sat, 7 Dec 2013 20:03:26 +0800 Subject: [PATCH 2/3] ui-lib conversion -> stunnel/index.cgi --- stunnel/index.cgi | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/stunnel/index.cgi b/stunnel/index.cgi index 714cd4494..3ef8d47f5 100755 --- a/stunnel/index.cgi +++ b/stunnel/index.cgi @@ -34,6 +34,7 @@ $ver = &get_stunnel_version(\$out); # } # List all tunnels currently setup in inetd +$hasconfig = 1; @tunnels = &list_stunnels(); @links = ( &select_all_link("d"), &select_invert_link("d"), @@ -118,22 +119,24 @@ if (@tunnels) { else { print "$text{'index_none'}

\n"; print &ui_links_row([ $links[2] ]); + $hasconfig = 0; } -print &ui_hr(); -print "\n"; -print "\n"; -print "\n"; -if ($has_inetd && $has_xinetd) { - print "\n"; - } -elsif ($has_inetd) { - print "\n"; - } -else { - print "\n"; - } -print "
$text{'index_applymsg1'}$text{'index_applymsg2'}$text{'index_applymsg3'}
\n"; +if ( $hasconfig ) { + my $xmsg = ""; + if ($has_inetd && $has_xinetd) { + $xmsg .= $text{'index_applymsg1'}; + } elsif ($has_inetd) { + $xmsg .= $text{'index_applymsg2'}; + } else { + $xmsg .= $text{'index_applymsg3'}; + } + print &ui_hr(); + print &ui_buttons_start(); + print &ui_buttons_row("apply.cgi", + $text{'index_apply'}, $xmsg); + print &ui_buttons_end(); +} &ui_print_footer("/", $text{'index'}); From ce8649c46d25f5477e93a90a423421a710ce4a68 Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Sun, 8 Dec 2013 00:16:40 +0800 Subject: [PATCH 3/3] ui-lib conversion -> stunnel/edit_stunnel.cgi --- stunnel/edit_stunnel.cgi | 198 ++++++++++++++++----------------------- 1 file changed, 81 insertions(+), 117 deletions(-) diff --git a/stunnel/edit_stunnel.cgi b/stunnel/edit_stunnel.cgi index 84d12d1eb..5d67aeb69 100755 --- a/stunnel/edit_stunnel.cgi +++ b/stunnel/edit_stunnel.cgi @@ -15,45 +15,26 @@ else { $st = $stunnels[$in{'idx'}]; } -print "

\n"; -print "\n"; -print "\n"; - -print "\n"; -print "\n"; -print "
$text{'edit_header1'}
\n"; - -print "\n"; -printf "\n", - $st->{'name'}; - -print "\n"; -printf "\n", - $st->{'port'}; - -print "\n"; -printf "\n", - $st->{'active'} ? "" : "checked", $text{'no'}; - -if (!$in{'new'}) { - print "\n"; - print "\n"; - } -elsif ($has_inetd && $has_xinetd) { - print "\n"; - print "\n"; - } -print "\n"; - -print "
$text{'edit_name'}$text{'edit_port'}
$text{'edit_active'} %s\n", - $st->{'active'} ? "checked" : "", $text{'yes'}; -printf " %s$text{'edit_type'}$st->{'type'}$text{'edit_type'}

\n"; -print "\n"; -print "\n"; -print "
$text{'edit_header2'}
\n"; +print &ui_form_start("save_stunnel.cgi", "post"); +print &ui_hidden("new",$in{'new'}); +print &ui_hidden("idx",$in{'idx'}); +print &ui_table_start($text{'edit_header1'}, "width=80%", 4); +print &ui_columns_row([ + "$text{'edit_name'} ", + &ui_textbox("name", $text{'edit_name'}, 15), + " $text{'edit_port'} ", + &ui_textbox("port", $st->{'port'}, 6) + ]); +print &ui_columns_row([ + "$text{'edit_active'}", + &ui_oneradio("active","1", $text{'yes'}, ($st->{'active'} ? 1 : 0) ). + " ".&ui_oneradio("active","0", $text{'no'}, ($st->{'active'} ? 0 : 1) ), + "$text{'edit_type'}", + ( !$in{'new'} ? "$st->{'type'}" : + ( $has_inetd && $has_xinetd ? &ui_select("type", undef,[["xinetd","xinetd","selected"],["inetd","inetd",""]]) : "") ) + ]); +print ui_table_end(); +print "
"; if ($in{'new'}) { $ptymode = 'l'; @@ -108,89 +89,72 @@ else { } } -printf "\n", - $ptymode eq 'l' ? 'checked' : '', $text{'edit_mode0'}; -printf "\n", - $text{'edit_args'}, $ptymode eq 'l' ? $args : ''; +print &ui_table_start($text{'edit_header2'}, "width=80%", 5); +print &ui_columns_row([ + &ui_oneradio("mode","0", $text{'edit_mode0'}, ($ptymode eq 'l' ? 1 : 0) ), + "$text{'edit_cmd'}", &ui_textbox("cmd0", ( $ptymode eq 'l' ? $cmd : "" ), 20), + "$text{'edit_args'}", &ui_textbox("args0", ( $ptymode eq 'l' ? $args : "" ), 20) + ]); +print &ui_columns_row([ + &ui_oneradio("mode","1", $text{'edit_mode1'}, ($ptymode eq 'L' ? 1 : 0) ), + "$text{'edit_cmd'}", &ui_textbox("cmd1", ( $ptymode eq 'L' ? $cmd : "" ), 20), + "$text{'edit_args'}", &ui_textbox("args1", ( $ptymode eq 'L' ? $args : "" ), 20) + ]); +print &ui_columns_row([ + &ui_oneradio("mode","2", $text{'edit_mode2'}, ($rport ? 1 : 0) ), + "$text{'edit_rhost'}", &ui_textbox("rhost", ( !$rport ? "" : ( $rhost ? $rhost : "localhost" ) ), 20), + "$text{'edit_rport'}", &ui_textbox("rport", $rport, 6) + ]); +print ui_table_end(); +print "
"; -printf "\n", - $ptymode eq 'L' ? 'checked' : '', $text{'edit_mode1'}; -printf "\n", - $text{'edit_args'}, $ptymode eq 'L' ? $args : ''; - -printf "\n", - $rport ? 'checked' : '', $text{'edit_mode2'}; -printf "\n", - $text{'edit_rport'}, $rport; - -print "
%s%s \n", - $text{'edit_cmd'}, $ptymode eq 'l' ? $cmd : ''; -printf "%s
%s%s \n", - $text{'edit_cmd'}, $ptymode eq 'L' ? $cmd : ''; -printf "%s
%s%s \n", - $text{'edit_rhost'}, !$rport ? '' : $rhost ? $rhost : 'localhost'; -printf "%s

\n"; -print "\n"; -print "\n"; -print "
$text{'edit_header3'}
\n"; - -print "\n", - $haspem ? $config{'pem_path'} : "", &file_chooser_button("pem"); - } -else { - local $pmode = $pem eq $webmin_pem ? 1 : - $pem ? 2 : 0; - printf " %s\n", - $pmode == 0 ? "checked" : "", $text{'edit_pem0'}; - printf " %s\n", - $pmode == 1 ? "checked" : "", $text{'edit_pem1'}; - printf " %s\n", - $pmode == 2 ? "checked" : "", $text{'edit_pem2'}; - printf " %s\n", - $pmode == 2 ? $pem : "", &file_chooser_button("pem"); - } + print &ui_columns_row([ + "$text{'edit_pem'}", + &ui_oneradio("pmode","0", $text{'edit_pem0'})." ". + &ui_oneradio("pmode","1", $text{'edit_pem1'}, ( $haspem ? 0 : 1) )." ". + &ui_oneradio("pmode","2", $text{'edit_pem2'}, ( $haspem ? 1 : 0) )." ". + &ui_filebox("pem", ( $haspem ? $config{'pem_path'} : "" ), 25) + ]); +} else { + local $pmode = $pem eq $webmin_pem ? 1 : $pem ? 2 : 0; + print &ui_columns_row([ + "$text{'edit_pem'}", + &ui_oneradio("pmode","0", $text{'edit_pem0'}, ( $pmode == 0 ? 1 : 0 ) )." ". + &ui_oneradio("pmode","1", $text{'edit_pem1'}, ( $pmode == 1 ? 1 : 0 ) )." ". + &ui_oneradio("pmode","2", $text{'edit_pem2'}, ( $pmode == 2 ? 1 : 0) )." ". + &ui_filebox("pem", ( $pmode == 2 ? $pem : "" ), 25) + ]); +} +print &ui_columns_row([ + "$text{'edit_tcpw'}", + &ui_oneradio("tcpw_def","1", $text{'edit_auto'}, ( $tcpw ? 0 : 1 ) )." ". + &ui_oneradio("tcpw_def","0", undef, ( $tcpw ? 1 : 0 ) )." ". + &ui_textbox("tcpw", $tcpw, 25) + ]); +print &ui_columns_row([ + "$text{'edit_cmode'}", + &ui_oneradio("cmode","0", $text{'edit_cmode0'}, ( $cmode ? 0 : 1 ) )." ". + &ui_oneradio("cmode","1", $text{'edit_cmode1'}, ( $cmode ? 1 : 0 ) ) + ]); +print &ui_columns_row([ + "$text{'edit_iface'}", + &ui_oneradio("iface_def","1", $text{'edit_auto'}, ( $iface ? 0 : 1 ) )." ". + &ui_oneradio("iface_def","0", undef, ( $iface ? 1 : 0 ) )." ". + &ui_textbox("iface", $iface, 25) + ]); +print ui_table_end(); -print "\n", $tcpw; - -print "\n", - $cmode ? "checked" : "", $text{'edit_cmode1'}; - -print "\n", $iface; - -print "
$text{'edit_pem'} \n"; $haspem = $config{'pem_path'} && -r $config{'pem_path'}; +print &ui_table_start($text{'edit_header3'}, "width=80%", 2); if ($in{'new'}) { - printf " %s\n", - "", $text{'edit_pem0'}; - printf " %s\n", - $haspem ? "" : "checked", $text{'edit_pem1'}; - printf " %s\n", - $haspem ? "checked" : "", $text{'edit_pem2'}; - printf " %s
$text{'edit_tcpw'} \n"; -printf " %s\n", - $tcpw ? "" : "checked", $text{'edit_auto'}; -printf "\n", - $tcpw ? "checked" : ""; -printf "
$text{'edit_cmode'} \n"; -printf " %s\n", - $cmode ? "" : "checked", $text{'edit_cmode0'}; -printf " %s
$text{'edit_iface'} \n"; -printf " %s\n", - $iface ? "" : "checked", $text{'edit_auto'}; -printf "\n", - $iface ? "checked" : ""; -printf "
\n"; -print "\n"; -print "\n"; +print &ui_hidden("args",$st->{'args'}); +print "
"; if ($in{'new'}) { - print "\n"; - } -else { - print "\n"; - print "\n"; - } -print "
\n"; + print &ui_submit($text{'create'}); +} else { + print &ui_submit($text{'save'})." ".&ui_submit($text{'delete'},"delete"); +} +print &ui_form_end(); &ui_print_footer("", $text{'index_return'});