3 # Display the vnc applet
5 BEGIN { push(@INC, ".."); };
10 &ui_print_header(undef, $text{'index_title'}, "", undef, &get_product_name() eq 'webmin', 1);
12 if ($config{'program'}) {
13 # Check if Xvnc is installed
14 if (!&has_command("Xvnc")) {
15 &error_exit(&text('index_ecmd', "<tt>Xvnc</tt>"));
18 # Pick a free VNC number
19 for($num=1; $num<1000; $num++) {
25 # Generate a password using vncpasswd
28 # Start Xvnc in a background process, and kill it after one client
32 local $pid = open(VNC, "Xvnc :$num 2>&1 |");
34 if (/Client\s+(\S+)\s+gone/i) {
43 # Run the specified program, using the selected display
44 $ENV{'DISPLAY'} = "localhost:$num";
45 system("$config{'program'} >/dev/null 2>&1 </dev/null &");
47 # XXX what about security?
48 # XXX how to ensure exit? -rfbwait
49 # XXX what about window manager? or none?
50 # XXX what user to run program as? need option for current user
51 # XXX need to generate random password, and pass to java
54 $addr = $config{'host'} ? $config{'host'} :
55 $ENV{'SERVER_NAME'} ? $ENV{'SERVER_NAME'} :
56 &to_ipaddress(&get_system_hostname());
57 $SIG{ALRM} = "connect_timeout";
59 &open_socket($addr, $port, STEST, \$err);
61 $err && &error_exit(&text('index_esocket', $addr, $config{'port'}));
62 $port = $config{'port'};
65 if ($ENV{'HTTPS'} eq 'ON') {
66 print "<center><font color=#ff0000>$text{'index_warn'}",
67 "</font></center><br>\n";
70 print "<center><applet archive=vncviewer.jar code=vncviewer.class ",
71 "width=$config{'width'} height=$config{'height'}>\n";
72 print "<param name=port value='$port'>\n";
73 if ($config{'host'}) {
74 print "<param name=host value='$config{'host'}'>\n";
76 print "$text{'index_nojava'} <p>\n";
77 print "</applet><br>\n";
78 print "$text{'index_credits'}</center>\n";
80 &ui_print_footer("/", $text{'index'});
88 print "<p>",@_,"<p>\n";
89 &ui_print_footer("/", $text{'index'});