--- okuchuu/piclist.ja.cgi 2005/02/25 17:08:30 1.4 +++ okuchuu/piclist.ja.cgi 2007/11/22 12:50:09 1.8 @@ -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,19 @@ } } +my $dirpath = escape $ENV{REQUEST_URI}; +$dirpath =~ s/\#.*$//; +$dirpath =~ s/\?.*$//; +$dirpath =~ s/,[^,]*$//g; +unless (-d $dir) { + $dir =~ s#/+[^/]+$##; + $dirpath =~ s#/[^/]+$#/#; + $dirpath ||= '/'; +} else { + $dirpath =~ s#/LIST$##; + $dirpath =~ s#/?$#/#; +} + opendir DIR, $dir or die "$dir: $!"; my @all_files = sort grep {not /^\./ and /^[A-Za-z0-9._-]+$/} (readdir DIR)[0..1000]; @@ -73,11 +85,25 @@ return 0; } +sub preview_uri ($) { + my $original_file_name = shift; + $original_file_name =~ s/\..*$//; + my $file_name = $original_file_name; + if ($file_name =~ /-small$/) { + return $file_name; + } else { + $file_name =~ s/-large$//; + if (has_file $file_name . '-small') { + return $file_name . '-small'; + } elsif (has_file $file_name) { + return $file_name; + } else { + return $original_file_name; + } + } +} + my $title = '画像一覧'; -my $dirpath = escape $ENV{REQUEST_URI}; -$dirpath =~ s/\?.*$//; -$dirpath =~ s#/LIST$##; -$dirpath ||= '/'; print STDOUT "Content-Type: text/html; charset=euc-jp\n\n"; @@ -88,31 +114,59 @@
-