Handle hostnames with upper-case letters
[webmin.git] / ssh2 / index.cgi
1 #!/usr/local/bin/perl
2 # Show the SSH 2 applet
3
4 BEGIN { push(@INC, ".."); };
5 use WebminCore;
6 use Socket;
7
8 &init_config();
9 $theme_no_table = 1 if ($config{'sizemode'} == 1);
10 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
11
12 if ($config{'no_test'}) {
13         # Just assume that the telnet server is running
14         $rv = 1;
15         }
16 else {
17         # Check if the telnet server is running
18         $addr = $config{'host'} ? $config{'host'} :
19                 $ENV{'SERVER_NAME'} ? $ENV{'SERVER_NAME'} :
20                                       &to_ipaddress(&get_system_hostname());
21         $ip = &to_ipaddress($addr) || &to_ip6address($addr);
22         $port = $config{'port'} ? $config{'port'} : 22;
23         if ($ip) {
24                 $SIG{ALRM} = "connect_timeout";
25                 alarm(10);
26                 &open_socket($ip, $port, STEST, \$err);
27                 close(STEST);
28                 $rv = !$err;
29                 }
30         }
31 if (!$rv) {
32         if ($ip) {
33                 print "<p>",&text('index_esocket2', $addr, $port),"<p>\n";
34                 }
35         else {
36                 print "<p>",&text('index_elookup', $addr),"<p>\n";
37                 }
38         }
39 else {
40         print "<center>\n";
41         if ($config{'detach'}) {
42                 $w = 100; $h = 50;
43                 }
44         elsif ($config{'sizemode'} == 2 &&
45             $config{'size'} =~ /^(\d+)\s*x\s*(\d+)$/) {
46                 $w = $1; $h = $2;
47                 }
48         elsif ($config{'sizemode'} == 1) {
49                 $w = "100%"; $h = "80%";
50                 }
51         else {
52                 $w = 800; $h = 420;
53                 }
54         print "<applet archive=\"mindterm.jar\" code=com.mindbright.application.MindTerm.class ",
55               "width=$w height=$h>\n";
56         if ($config{'port'}) {
57                 print "<param name=port value=$config{'port'}>\n";
58                 }
59         if ($config{'sizemode'}) {
60                 print "<param name=Terminal.resize value='screen'>\n";
61                 }
62         if ($config{'fontsize'}) {
63                 print "<param name=Terminal.fontSize value='$config{'fontsize'}'>\n";
64                 }
65         if ($config{'detach'}) {
66                 print "<param name=sepframe value='true'>\n";
67                 }
68         if ($config{'foreground'}) {
69                 print "<param name=fg-color ",
70                       "value='$config{'foreground'}'>\n";
71                 }
72         if ($config{'background'}) {
73                 print "<param name=bg-color ",
74                       "value='$config{'background'}'>\n";
75                 }
76         if ($config{'term'}) {
77                 print "<param name=term-type value='$config{'term'}'>\n";
78                 }
79         if ($config{'encoding'}) {
80                 print "<param name=encoding ",
81                       "value='$config{'encoding'}'>\n";
82                 }
83         print "$text{'index_nojava'} <p>\n";
84         print "</applet><br>\n";
85
86         print &text('index_credits',
87                     "http://www.appgate.com/products/80_MindTerm/"),"<br>\n";
88         print "</center>\n";
89         }
90
91 &ui_print_footer("/", $text{'index'});
92
93 sub connect_timeout
94 {
95 }
96