/[hydra]/hydra/src/webindex.pl
ViewVC logotype

Annotation of /hydra/src/webindex.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Sat Sep 21 13:53:38 2002 UTC (21 years, 6 months ago) by nmav
Branch: boas, MAIN
CVS Tags: hydra_0_1_6_without_hic, BOAS_WITH_RANGES_AND_CGI, hydra_0_0_10, start, hydra_0_0_8, hydra_0_0_9, hydra_0_0_2, hydra_0_0_3, hydra_0_0_6, hydra_0_0_7, hydra_0_0_4, hydra_0_0_5, hydra_0_1_3, hydra_0_1_2, hydra_0_1_1, hydra_0_1_0, hydra_0_1_7, hydra_0_1_6, hydra_0_1_4, hydra_0_1_8, HEAD
Branch point for: hydra_0_1_0_patches
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
Imported sources

1 nmav 1.1 #!/usr/bin/perl
2    
3     # webindex, a world wide web directory generating program
4     # Copyright (C) 1997 Larry Doolittle <ldoolitt@jlab.org>
5     #
6     # This program is free software; you can redistribute it and/or modify
7     # it under the terms of the GNU General Public License as published by
8     # the Free Software Foundation; either version 1, or (at your option)
9     # any later version.
10     #
11     # This program is distributed in the hope that it will be useful,
12     # but WITHOUT ANY WARRANTY; without even the implied warranty of
13     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     # GNU General Public License for more details.
15     #
16     # You should have received a copy of the GNU General Public License
17     # along with this program; if not, write to the Free Software
18     # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19    
20     # likely future additions:
21     # incorporate user-supplied README files
22     # use config file to supply icons
23     # other formats and sort options, including one giving dates
24     # more robust handling of GCOS field
25     # nicer date format in footer
26    
27     # usable as it stands, 11-Feb-1997 lrd
28     # $Id: webindex.pl,v 1.2 1999/10/12 14:49:08 jon Exp $
29    
30    
31     # *****configure me******
32     $index="INDEX.html";
33     # ^^^^^^^^^^
34     # The line above defines the output file name from webindex.
35     # You should make sure it lines up with the configuration of
36     # the web server on your system, i.e., the DirectoryIndex
37     # directive in NCSA, Apache, or Boa.
38    
39     $magic="This file is unmodified webindex output";
40    
41     ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell)
42     =getpwuid($<);
43    
44     # Title of the page - there is no unique mapping from the unix
45     # filename to URL space. Take an easy way out and just give
46     # the name of the directory.
47     # Even this can be confused, look what happens if user joe
48     # makes a public_html/foo directory, and runs webindex on it.
49     # Now user bill makes a symbolic link from his public_html/bar
50     # ~joe/public_html/foo. This directory now has two URLs,
51     # http://some.server/~joe/foo/ and http://some.server/~bill/bar/ .
52     # The name that we generate is foo, which is only half right :-(
53    
54     @A=split("/",`pwd`);
55     $here=pop(@A);
56    
57     # We will happily create a new $index file, or overwrite
58     # one if it has the magic comment in it. We won't overwrite
59     # a carefully hand-crafted one, though.
60    
61     if (open CHK,"<$index") {
62     while (<CHK>) {
63     last if ($found = / $magic /);
64     }
65     close(CHK);
66     die "existing $index not overwritten" if (!$found);
67     }
68    
69     opendir DIR, "." || die "opendir";
70     open OUT,">$index" || die "fopen";
71    
72     print OUT "<html><head>\n<title>Index of $here</title>\n</head>\n\n";
73    
74     # This comment syntax should be compatible with all HTML versions
75     print OUT "<!-- $magic -->\n";
76    
77     print OUT "<body>\n\n<h2>Index of $here</h2>\n\n";
78    
79     @A=sort(readdir(DIR));
80    
81     print OUT "<h3>Directories</h3>\n<ul>\n";
82     print OUT "<li><A HREF=\"../\">Parent Directory</a>\n";
83     for $a (@A) {
84     next if ($a eq ".");
85     next if ($a eq "..");
86     ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
87     $atime,$mtime,$ctime,$blksize,$blocks) = stat($a);
88     if ( -d _) {
89     print OUT "<li><A HREF=\"$a/\">$a</A>\n";
90     }
91     }
92     print OUT "</ul>\n";
93    
94     $found=0;
95     for $a (@A) {
96     next if ($a eq ".");
97     next if ($a eq "..");
98     next if ($a eq $index);
99     ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
100     $atime,$mtime,$ctime,$blksize,$blocks) = stat($a);
101     if (! -d _) {
102     if (!$found) {
103     $found=1;
104     print OUT "<h3>Files</h3><ul>\n";
105     }
106     print OUT "<li><A HREF=\"$a\">$a</A> ($size bytes)\n";
107     }
108     }
109     print OUT "</ul>\n" if $found;
110    
111     closedir(DIR);
112     $now=localtime();
113     ($who)=split(/,/,$gcos);
114     print OUT "<hr>Index created by <a href=\"/~$name/\">$who</a>
115     with <a href=\"http://recycle.jlab.org/webindex/\">webindex</a> at $now<br>\n";
116    
117     print OUT "</body>\n</html>\n";
118    
119     close OUT;

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26