$conf = $host->{'members'};
}
-print "<form action=save_host.cgi>\n";
-print "<input type=hidden name=idx value='$in{'idx'}'>\n";
-print "<input type=hidden name=new value='$in{'new'}'>\n";
-print "<table border width=100%>\n";
-print "<tr $tb> <td><b>$text{'host_header'}</b></td> </tr>\n";
-print "<tr $cb> <td><table width=100%>\n";
-
-&scmd(1);
-print "<td><b>$text{'host_name'}</b></td> <td colspan=3>\n";
-printf "<input type=radio name=name_def value=1 %s> %s\n",
- $host->{'values'}->[0] eq '*' ? 'checked' : '', $text{'hosts_all'};
-printf "<input type=radio name=name_def value=0 %s>\n",
- $host->{'values'}->[0] eq '*' ? '' : 'checked';
-printf "<input name=name size=40 value='%s'></td>\n",
- $host->{'values'}->[0] eq '*' ? '' : $host->{'values'}->[0];
-&ecmd();
-
-&scmd();
+print &ui_form_start("save_host.cgi", "post");
+print &ui_hidden("idx", $in{'idx'});
+print &ui_hidden("new", $in{'new'});
+print &ui_table_start($text{'host_header'}, "width=100%", 2);
+
+# Name for this host
+print &ui_table_row($text{'host_name'},
+ &ui_opt_textbox("name", $host->{'values'}->[0] eq '*' ? '' :
+ $host->{'values'}->[0],
+ 50, $text{'hosts_all'}));
+
+# Default user to login as
$user = &find_value("User", $conf);
-print "<td><b>$text{'host_user'}</b></td> <td nowrap>\n";
-printf "<input type=radio name=user_def value=1 %s> %s\n",
- $user ? "" : "checked", $text{'host_user_def'};
-printf "<input type=radio name=user_def value=0 %s>\n",
- $user ? "checked" : "";
-print "<input name=user size=13 value='$user'></td>\n";
-&ecmd();
+print &ui_table_row($text{'host_user'},
+ &ui_opt_textbox("user", $user, 20, $text{'host_user_def'}));
-&scmd();
+# Send keep-alive packets?
$keep = &find_value("KeepAlive", $conf);
-print "<td><b>$text{'host_keep'}</b></td> <td>\n";
-printf "<input type=radio name=keep value=1 %s> %s\n",
- lc($keep) eq 'yes' ? "checked" : "", $text{'yes'};
-printf "<input type=radio name=keep value=0 %s> %s\n",
- lc($keep) eq 'no' ? "checked" : "", $text{'no'};
-printf "<input type=radio name=keep value=2 %s> %s</td>\n",
- !$keep ? "checked" : "", $text{'default'};
-&ecmd();
+print &ui_table_row($text{'host_keep'},
+ &yes_no_default_radio("keep", $keep));
-&scmd();
+# Real hostname to connect to
$hostname = &find_value("HostName", $conf);
-print "<td><b>$text{'host_hostname'}</b></td> <td nowrap>\n";
-printf "<input type=radio name=hostname_def value=1 %s> %s\n",
- $hostname ? "" : "checked", $text{'host_hostname_def'};
-printf "<input type=radio name=hostname_def value=0 %s>\n",
- $hostname ? "checked" : "";
-print "<input name=hostname size=20 value='$hostname'></td>\n";
-&ecmd();
-
-&scmd();
-$batch = &find_value("BatchMode", $conf);
-print "<td><b>$text{'host_batch'}</b></td> <td>\n";
-printf "<input type=radio name=batch value=0 %s> %s\n",
- lc($batch) eq 'no' ? "checked" : "", $text{'yes'};
-printf "<input type=radio name=batch value=1 %s> %s\n",
- lc($batch) eq 'yes' ? "checked" : "", $text{'no'};
-printf "<input type=radio name=batch value=2 %s> %s</td>\n",
- !$batch ? "checked" : "", $text{'default'};
-&ecmd();
+print &ui_table_row($text{'host_hostname'},
+ &ui_opt_textbox("hostname", $hostname, 30, $text{'host_hostname_def'}));
-&scmd();
+# Port to use
$port = &find_value("Port", $conf);
-print "<td><b>$text{'host_port'}</b></td> <td nowrap>\n";
-printf "<input type=radio name=port_def value=1 %s> %s\n",
- $port ? "" : "checked", $text{'default'};
-printf "<input type=radio name=port_def value=0 %s>\n",
- $port ? "checked" : "";
-print "<input name=port size=6 value='$port'></td>\n";
-&ecmd();
+print &ui_table_row($text{'host_port'},
+ &ui_opt_textbox("port", $port, 6, $text{'default'}." (22)"));
+
+# Ask for password if needed, or fail fast?
+$batch = &find_value("BatchMode", $conf);
+print &ui_table_row($text{'host_batch'},
+ &yes_no_default_radio("batch", $batch));
-&scmd();
+# Compress SSH?
$comp = &find_value("Compression", $conf);
-print "<td><b>$text{'host_comp'}</b></td> <td>\n";
-printf "<input type=radio name=comp value=1 %s> %s\n",
- lc($comp) eq 'yes' ? "checked" : "", $text{'yes'};
-printf "<input type=radio name=comp value=0 %s> %s\n",
- lc($comp) eq 'no' ? "checked" : "", $text{'no'};
-printf "<input type=radio name=comp value=2 %s> %s</td>\n",
- !$comp ? "checked" : "", $text{'default'};
-&ecmd();
+print &ui_table_row($text{'host_comp'},
+ &yes_no_default_radio("comp", $comp));
-&scmd();
+# Escape character in session
$escape = &find_value("EscapeChar", $conf);
-print "<td><b>$text{'host_escape'}</b></td> <td nowrap>\n";
-printf "<input type=radio name=escape_def value=1 %s> %s\n",
- $escape eq "" ? "checked" : "", $text{'default'};
-printf "<input type=radio name=escape_def value=2 %s> %s\n",
- $escape eq "none" ? "checked" : "", $text{'host_escape_none'};
-printf "<input type=radio name=escape_def value=0 %s>\n",
- $escape eq "" || $escape eq "none" ? "" : "checked";
-printf "<input name=escape size=2 value='%s'></td>\n",
- $escape eq "" || $escape eq "none" ? "" : $escape;
-&ecmd();
+print &ui_table_row($text{'host_escape'},
+ &ui_radio("escape_def", $escape eq "" ? 1 :
+ $escape eq "none" ? 2 : 0,
+ [ [ 1, $text{'default'}." (~.)" ],
+ [ 2, $text{'host_escape_none'} ],
+ [ 0, &ui_textbox("escape",
+ $escape eq "none" ? "" : $escape, 4) ] ]));
if ($version{'type'} ne 'ssh' || $version{'number'} < 3) {
- &scmd();
+ # SSH compression level
$clevel = &find_value("CompressionLevel", $conf);
- print "<td><b>$text{'host_clevel'}</b></td> <td nowrap>\n";
- printf "<input type=radio name=clevel_def value=1 %s> %s\n",
- $clevel ? "" : "checked", $text{'default'};
- printf "<input type=radio name=clevel_def value=0 %s>\n",
- $clevel ? "checked" : "";
- print "<select name=clevel>\n";
- foreach $l (1 .. 9) {
- printf "<option %s value=%s>%s %s\n", $clevel == $l ? 'selected' : '',
- $l, $l, $text{"host_clevel_$l"};
- }
- print "</select></td>\n";
- &ecmd();
-
- &scmd();
+ print &ui_table_row($text{'host_clevel'},
+ &ui_radio("clevel_def", $clevel ? 0 : 1,
+ [ [ 1, $text{'default'} ],
+ [ 0, &ui_select("clevel", $clevel,
+ [ map { [ $_, $text{"host_clevel_".$_} ] }
+ (1 .. 9) ]) ] ]));
+
+ # Number of times to attempt connection
$attempts = &find_value("ConnectionAttempts", $conf);
- print "<td><b>$text{'host_attempts'}</b></td> <td nowrap>\n";
- printf "<input type=radio name=attempts_def value=1 %s> %s\n",
- $attempts ? "" : "checked", $text{'default'};
- printf "<input type=radio name=attempts_def value=0 %s>\n",
- $attempts ? "checked" : "";
- print "<input name=attempts size=2 value='$attempts'></td>\n";
- &ecmd();
+ print &ui_table_row($text{'host_attempts'},
+ &ui_opt_textbox("attempts", $attempts, 5, $text{'default'}));
- &scmd();
+ # Use local privileged port?
$priv = &find_value("UsePrivilegedPort", $conf);
- print "<td><b>$text{'host_priv'}</b></td> <td>\n";
- printf "<input type=radio name=priv value=1 %s> %s\n",
- lc($priv) eq 'yes' ? "checked" : "", $text{'yes'};
- printf "<input type=radio name=priv value=0 %s> %s\n",
- lc($priv) eq 'no' ? "checked" : "", $text{'no'};
- printf "<input type=radio name=priv value=2 %s> %s</td>\n",
- !$priv ? "checked" : "", $text{'default'};
- &ecmd();
+ print &ui_table_row($text{'host_priv'},
+ &yes_no_default_radio("priv", $priv));
- &scmd();
+ # Try RSH if SSH fails?
$rsh = &find_value("FallBackToRsh", $conf);
- print "<td><b>$text{'host_rsh'}</b></td> <td>\n";
- printf "<input type=radio name=rsh value=1 %s> %s\n",
- lc($rsh) eq 'yes' ? "checked" : "", $text{'yes'};
- printf "<input type=radio name=rsh value=0 %s> %s\n",
- lc($rsh) eq 'no' ? "checked" : "", $text{'no'};
- printf "<input type=radio name=rsh value=2 %s> %s</td>\n",
- !$rsh ? "checked" : "", $text{'default'};
- &ecmd();
+ print &ui_table_row($text{'host_rsh'},
+ &yes_no_default_radio("rsh", $rsh));
- &scmd();
+ # Use RSH only?
$usersh = &find_value("UseRsh", $conf);
- print "<td><b>$text{'host_usersh'}</b></td> <td>\n";
- printf "<input type=radio name=usersh value=1 %s> %s\n",
- lc($usersh) eq 'yes' ? "checked" : "", $text{'yes'};
- printf "<input type=radio name=usersh value=0 %s> %s\n",
- lc($usersh) eq 'no' ? "checked" : "", $text{'no'};
- printf "<input type=radio name=usersh value=2 %s> %s</td>\n",
- !$usersh ? "checked" : "", $text{'default'};
- &ecmd();
+ print &ui_table_row($text{'host_usersh'},
+ &yes_no_default_radio("usersh", $usersh));
}
-&scmd();
+# Forward SSH agent?
$agent = &find_value("ForwardAgent", $conf);
-print "<td><b>$text{'host_agent'}</b></td> <td>\n";
-printf "<input type=radio name=agent value=1 %s> %s\n",
- lc($agent) eq 'yes' ? "checked" : "", $text{'yes'};
-printf "<input type=radio name=agent value=0 %s> %s\n",
- lc($agent) eq 'no' ? "checked" : "", $text{'no'};
-printf "<input type=radio name=agent value=2 %s> %s</td>\n",
- !$agent ? "checked" : "", $text{'default'};
-&ecmd();
+print &ui_table_row($text{'host_agent'},
+ &yes_no_default_radio('agent', $agent));
-&scmd();
+# Forward X connection?
$x11 = &find_value("ForwardX11", $conf);
-print "<td><b>$text{'host_x11'}</b></td> <td>\n";
-printf "<input type=radio name=x11 value=1 %s> %s\n",
- lc($x11) eq 'yes' ? "checked" : "", $text{'yes'};
-printf "<input type=radio name=x11 value=0 %s> %s\n",
- lc($x11) eq 'no' ? "checked" : "", $text{'no'};
-printf "<input type=radio name=x11 value=2 %s> %s</td>\n",
- !$x11 ? "checked" : "", $text{'default'};
-&ecmd();
+print &ui_table_row($text{'host_x11'},
+ &yes_no_default_radio('x11', $x11));
-&scmd();
+# Strictly check host keys?
$strict = &find_value("StrictHostKeyChecking", $conf);
-print "<td><b>$text{'host_strict'}</b></td> <td>\n";
-printf "<input type=radio name=strict value=0 %s> %s\n",
- lc($strict) eq 'no' ? "checked" : "", $text{'yes'};
-printf "<input type=radio name=strict value=1 %s> %s\n",
- lc($strict) eq 'yes' ? "checked" : "", $text{'no'};
-printf "<input type=radio name=strict value=3 %s> %s\n",
- lc($strict) eq 'ask' ? "checked" : "", $text{'host_ask'};
-printf "<input type=radio name=strict value=2 %s> %s</td>\n",
- !$strict ? "checked" : "", $text{'default'};
-&ecmd();
+print &ui_table_row($text{'host_strict'},
+ &ui_radio('strict', lc($strict) eq 'no' ? 0 :
+ lc($strict) eq 'yes' ? 1 :
+ lc($strict) eq 'ask' ? 3 : 2,
+ [ [ 0, $text{'yes'} ], [ 1, $text{'no'} ],
+ [ 3, $text{'host_ask'} ], [ 2, $text{'default'} ] ]));
if ($version{'type'} eq 'openssh') {
- &scmd();
+ # Double-check remote host IP?
$checkip = &find_value("CheckHostIP", $conf);
- print "<td><b>$text{'host_checkip'}</b></td> <td>\n";
- printf "<input type=radio name=checkip value=1 %s> %s\n",
- lc($checkip) eq 'yes' ? "checked" : "", $text{'yes'};
- printf "<input type=radio name=checkip value=0 %s> %s\n",
- lc($checkip) eq 'no' ? "checked" : "", $text{'no'};
- printf "<input type=radio name=checkip value=2 %s> %s</td>\n",
- !$checkip ? "checked" : "", $text{'default'};
- &ecmd();
+ print &ui_table_row($text{'host_checkip'},
+ &yes_no_default_radio('checkip', $checkip));
- &scmd(1);
+ # SSH protocols to try
$prots = &find_value("Protocol", $conf);
- @prots = split(/,/, $prots);
- print "<td><b>$text{'host_prots'}</b></td> <td colspan=3>\n";
- printf "<input type=radio name=prots_def value=1 %s> %s\n",
- $prots ? '' : 'checked', $text{'default'};
- printf "<input type=radio name=prots_def value=0 %s> %s\n",
- $prots ? 'checked' : '', $text{'host_prots_sel'};
- foreach $p (1, 2) {
- printf "<input type=checkbox name=prots value=%s %s> %s\n",
- $p, &indexof($p, @prots) >= 0 ? "checked" : "",
- $text{"net_prots_$p"};
- }
- print "</td>\n";
- &ecmd();
+ print &ui_table_row($text{'host_prots'},
+ &ui_select("prots", $prots,
+ [ [ '', $text{'default'} ],
+ [ 1, $text{'host_prots1'} ],
+ [ 2, $text{'host_prots2'} ],
+ [ '1,2', $text{'host_prots12'} ],
+ [ '2,1', $text{'host_prots21'} ] ], 1, 0, 1));
}
-&scmd(1);
-print "<td colspan=4><hr></td>\n";
-&ecmd();
+print &ui_table_hr();
-&scmd(1);
-print "<td valign=top><b>$text{'host_lforward'}</b></td>\n";
-print "<td colspan=3><table border>\n";
-print "<tr $tb> <td><b>$text{'host_llport'}</b></td> ",
- "<td><b>$text{'host_lrhost'}</b></td> ",
- "<td><b>$text{'host_lrport'}</b></td> </tr>\n";
+# Local ports to forward
@lforward = &find("LocalForward", $conf);
+@ltable = ( );
$i = 0;
foreach $l (@lforward, { }) {
local ($lp, $rh, $rp) = ( $l->{'values'}->[0],
split(/:/, $l->{'values'}->[1]) );
- print "<tr>\n";
- print "<td><input name=llport_$i size=8 value='$lp'></td>\n";
- print "<td><input name=lrhost_$i size=40 value='$rh'></td>\n";
- print "<td><input name=lrport_$i size=8 value='$rp'></td>\n";
- print "</tr>\n";
+ push(@ltable, [ &ui_textbox("llport_$i", $lp, 8),
+ &ui_textbox("lrhost_$i", $rh, 8),
+ &ui_textbox("lrport_$i", $rp, 8) ]);
$i++;
}
-print "</table></td>\n";
-&ecmd();
+print &ui_table_row($text{'host_lforward'},
+ &ui_columns_table([ $text{'host_llport'}, $text{'host_lrhost'},
+ $text{'host_lrport'} ],
+ 100, \@ltable));
-&scmd(1);
-print "<td colspan=4><hr></td>\n";
-&ecmd();
+print &ui_table_hr();
-&scmd(1);
-print "<td valign=top><b>$text{'host_rforward'}</b></td>\n";
-print "<td colspan=3><table border>\n";
-print "<tr $tb> <td><b>$text{'host_rrport'}</b></td> ",
- "<td><b>$text{'host_rlhost'}</b></td> ",
- "<td><b>$text{'host_rlport'}</b></td> </tr>\n";
+# Remote ports to forward
@rforward = &find("RemoteForward", $conf);
+@rtable = ( );
$i = 0;
foreach $r (@rforward, { }) {
local ($rp, $lh, $lp) = ( $r->{'values'}->[0],
split(/:/, $r->{'values'}->[1]) );
- print "<tr>\n";
- print "<td><input name=rrport_$i size=8 value='$rp'></td>\n";
- print "<td><input name=rlhost_$i size=40 value='$lh'></td>\n";
- print "<td><input name=rlport_$i size=8 value='$lp'></td>\n";
- print "</tr>\n";
+ push(@rtable, [ &ui_textbox("rrport_$i", $rp, 8),
+ &ui_textbox("rlhost_$i", $lh, 40),
+ &ui_textbox("rlport_$i", $lp, 8) ]);
$i++;
}
-print "</table></td>\n";
-&ecmd();
+print &ui_table_row($text{'host_rforward'},
+ &ui_columns_table([ $text{'host_rrport'}, $text{'host_rlhost'},
+ $text{'host_rlport'} ],
+ 100, \@rtable));
-print "</table></td></tr></table>\n";
-print "<table width=100%><tr>\n";
-print "<td><input type=submit value='$text{'save'}'></td>\n";
-print "<td align=right><input type=submit name=delete ",
- "value='$text{'delete'}'></td>\n";
-print "</tr></table>\n";
+print &ui_table_end();
+if ($in{'new'}) {
+ print &ui_form_end([ [ undef, $text{'create'} ] ]);
+ }
+else {
+ print &ui_form_end([ [ undef, $text{'save'} ],
+ [ 'delete', $text{'delete'} ] ]);
+ }
&ui_print_footer("list_hosts.cgi", $text{'hosts_return'},
- "", $text{'index_return'});
+ "", $text{'index_return'});