--- okuchuu/piclist.ja.cgi 2005/02/25 17:08:30 1.4 +++ okuchuu/piclist.ja.cgi 2005/03/11 11:51:48 1.6 @@ -8,14 +8,12 @@ =cut -unless ($main::ENV{PATH_TRANSLATED}) { - die "BAD PATH_TRANSLATED"; -} +my $dir = $main::ENV{PATH_TRANSLATED} + or die "BAD PATH_TRANSLATED: $ENV{PATH_TRANSLATED}"; my %Opt; -my $dir = $main::ENV{PATH_TRANSLATED}; -if ($dir =~ s#/LIST$##) { +if ($dir =~ s#/[^/]+$##) { for (split /[&;]/, $ENV{QUERY_STRING}) { my ($name, $val) = split /=/, $_, 2; $Opt{$name} = defined $val ? $val : 1; @@ -31,6 +29,7 @@ $s =~ s/</g; $s =~ s/>/>/g; $s =~ s/"/"/g; + $s =~ s/'/'/g; $s; } @@ -55,6 +54,10 @@ } } +unless (-d $dir) { +# $dir =~ s#/+[^/]+$##; +} + opendir DIR, $dir or die "$dir: $!"; my @all_files = sort grep {not /^\./ and /^[A-Za-z0-9._-]+$/} (readdir DIR)[0..1000]; @@ -76,7 +79,7 @@ my $title = '画像一覧'; my $dirpath = escape $ENV{REQUEST_URI}; $dirpath =~ s/\?.*$//; -$dirpath =~ s#/LIST$##; +$dirpath =~ s#/[^/]+$##; $dirpath ||= '/'; print STDOUT "Content-Type: text/html; charset=euc-jp\n\n"; @@ -88,15 +91,38 @@
-