Handle hostnames with upper-case letters
[webmin.git] / file / index.cgi.bak
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Output HTML for the file manager applet
4
5 require './file-lib.pl';
6 &ReadParse();
7 $theme_no_table = 1;
8 if ($access{'uid'} < 0 && !defined(getpwnam($remote_user))) {
9         &error(&text('index_eremote', $remote_user));
10         }
11
12 # Display header, depending on how many modules the user has
13 &read_acl(undef, \%acl);
14 $mc = @{$acl{$base_remote_user}} == 1;
15 $nolo = $ENV{'ANONYMOUS_USER'} ||
16       $ENV{'SSL_USER'} || $ENV{'LOCAL_USER'} ||
17       $ENV{'HTTP_USER_AGENT'} =~ /webmin/i;
18 if ($gconfig{'gotoone'} && $mc == 1 && !$nolo) {
19         &header($text{'index_title'}, "", undef, 0, 1);
20         $w = 100;
21         $h = 80;
22         }
23 else {
24         &header($text{'index_title'});
25         $w = 100;
26         $h = 100;
27         }
28
29 if ($gconfig{'referers_none'}) {
30         # Because java applet HTTP requests don't always include a referer:
31         # header, we need to use a DBM of trust keys to identify trusted applets
32         if (defined(&seed_random)) { &seed_random(); }
33         else { srand(time() ^ $$); }
34         $trust = int(rand(1000000000));
35         local $now = time();
36         &open_trust_db();
37         foreach $k (keys %trustdb) {
38                 if ($now - $trustdb{$k} > 30*24*60*60) {
39                         delete($trustdb{$k});
40                         }
41                 }
42         $trustdb{$trust} = $now;
43         dbmclose(%trustdb);
44         }
45
46
47 $sharing = $access{'uid'} ? 0 : 1;
48 &read_acl(undef, \%acl);
49 $mc = @{$acl{$base_remote_user}};
50 if (!$gconfig{'gotoone'} || $mc > 1) {
51         %minfo = &get_module_info();
52         $return = "<param name=return value=\"$gconfig{'webprefix'}/?cat=$minfo{'category'}\">";
53         }
54 if ($in{'open'}) {
55         $open = "<param name=open value=\"$in{'open'}\">\n";
56         }
57 print <<EOF;
58 <script>
59 function upload(dir)
60 {
61 open("upform.cgi?dir="+dir+"&trust=$trust", "upload", "toolbar=no,menubar=no,scrollbar=no,width=450,height=200");
62 }
63 </script>
64
65 <applet code=FileManager name=FileManager width=$w% height=$h% MAYSCRIPT>
66 <param name=root value="$access{'root'}">
67 <param name=follow value="$access{'follow'}">
68 <param name=ro value="$access{'ro'}">
69 <param name=sharing value="$sharing">
70 <param name=trust value="$trust">
71 <param name=goto value="$access{'goto'}">
72 $open
73 $return
74 $text{'index_nojava'} <p>
75 </applet>
76 EOF
77 &footer();
78
79