ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/diridx.pl
(Generate patch)

Comparing Coro/myhttpd/diridx.pl (file contents):
Revision 1.33 by root, Sun May 19 21:00:47 2002 UTC vs.
Revision 1.34 by root, Sat Dec 2 03:29:29 2006 UTC

31 } 31 }
32 $data->{path} = $path; 32 $data->{path} = $path;
33 } 33 }
34 34
35 sub read_file { 35 sub read_file {
36 local ($/, *X); 36 local $/;
37 (open X, "<$_[0]\x00") ? <X> : (); 37 (open my $fh, "<$_[0]\x00") ? <$fh> : ()
38 } 38 }
39 39
40 { 40 {
41 my $path = $self->{path}; 41 my $path = $self->{path};
42 do { 42 do {
45 $path =~ s/[^\/]*\/+$// 45 $path =~ s/[^\/]*\/+$//
46 or die "malformed path: $path"; 46 or die "malformed path: $path";
47 } while $path ne ""; 47 } while $path ne "";
48 } 48 }
49 49
50 local *DIR;
51 if (opendir DIR, $self->{path}) { 50 if (opendir my $dir, $self->{path}) {
52 my $dlen = 0; 51 my $dlen = 0;
53 my $flen = 0; 52 my $flen = 0;
54 my $slen = 0; 53 my $slen = 0;
55 for (sort readdir DIR) { 54 for (sort readdir $dir) {
56 next if /$ignore/; 55 next if /$ignore/;
57 stat "$self->{path}$_"; 56 stat "$self->{path}$_";
58 if (-d _) { 57 if (-d _) {
59 next unless 0555 == ((stat _)[2] & 0555); 58 next unless 0555 == ((stat _)[2] & 0555);
60 $dlen = length $_ if length $_ > $dlen; 59 $dlen = length $_ if length $_ > $dlen;
101 $$statdata; 100 $$statdata;
102} 101}
103 102
104sub handle_redirect { # unused 103sub handle_redirect { # unused
105 if (-f ".redirect") { 104 if (-f ".redirect") {
106 if (open R, "<.redirect") { 105 if (open my $fh, "<.redirect") {
107 while (<R>) { 106 while (<$fh>) {
108 if (/^(?:$host$port)$uri([^ \tr\n]*)[ \t\r\n]+(.*)$/) { 107 if (/^(?:$host$port)$uri([^ \tr\n]*)[ \t\r\n]+(.*)$/) {
109 my $rem = $1; 108 my $rem = $1;
110 my $url = $2; 109 my $url = $2;
111 print $nph ? "HTTP/1.0 302 Moved\n" : "Status: 302 Moved\n"; 110 print $nph ? "HTTP/1.0 302 Moved\n" : "Status: 302 Moved\n";
112 print <<EOF; 111 print <<EOF;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines