--- okuchuu/piclist.ja.cgi 2005/02/26 04:15:33 1.5 +++ 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; @@ -56,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]; @@ -77,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"; @@ -102,8 +104,8 @@ if ($Opt{cframe}) { my $LISTqt = ($LISTq eq 'LIST' ? $LISTq . '?' : $LISTq . ';') . 'target=view'; print qq{ - - + + }; } @@ -130,7 +132,7 @@ shift @cls; print q{<div class="image-with-desc">}; print qq{<a href="$uri"$viewtarget>}; - print qq{<img src="$uri" alt="" class="@{[join ' ', @cls, 's']}"></a>}; + print qq{<img src="$uri" alt="" class="@{[join ' ', @cls, 's']}" /></a>}; print qq{<dl><dt>URI</dt><dd>}; print qq{<code class="uri">&lt;<a href="$uri"$viewtarget>$uri</a>&gt;</code></dd>}; print qq{<dt>ファイル名</dt><dd>}; @@ -148,7 +150,7 @@ my $uri = $efile; $uri =~ s/\..+//g; print q{<div class="image-with-desc">}; - print qq{<a href="$uri"$viewtarget><img src="/~wakaba/archive/2005/movie-1" alt=""></a>}; + print qq{<a href="$uri"$viewtarget><img src="/~wakaba/archive/2005/movie-1" alt="" /></a>}; print qq{<dl><dt>URI</dt><dd>}; print qq{<code class="uri">&lt;<a href="$uri"$viewtarget>$uri</a>&gt;</code></dd>}; print qq{<dt>ファイル名</dt><dd>}; @@ -168,9 +170,9 @@ print q{<div class="dir dir-with-desc">}; if (-f $dir . '/' . $dir_name . '/favicon.png' or -f $dir . '/' . $dir_name . '/favicon.ico') { - print qq{<img src="$edir/favicon" alt="" class="mini-icon">}; + print qq{<img src="$edir/favicon" alt="" class="mini-icon" />}; } else { - print qq{<img src="/icons/folder" alt="" class="mini-icon">}; + print qq{<img src="/icons/folder" alt="" class="mini-icon" />}; } print qq{<code class="file"><a href="$edir/$LISTq"$listtarget>$edir/</a></code>}; print q{</div>}; @@ -188,14 +190,14 @@ ['current', '現行版']) { if (has_file $_->[0]) { print q{<div class="file file-with-desc">}; - print q{<img src="/icons/layout" alt="" class="mini-icon">}; + print q{<img src="/icons/layout" alt="" class="mini-icon" />}; print qq{<a href="$_->[0]" rel="$_->[2]"$viewtarget>$_->[1]</a>}; print q{</div>}; } } print q{<div class="dir-up dir-with-desc">}; - print q{<img src="/icons/forward" alt="" class="mini-icon">}; + print q{<img src="/icons/forward" alt="" class="mini-icon" />}; print qq{<a href="../$LISTq" rel="up"$listtarget>上の階層</a>}; print q{</div>}; @@ -231,7 +233,7 @@ if (-d $dir . '/CVS') { if (-f $dir . '/CVS/Root') { open my $root, '<', $dir . '/CVS/Root'; - if (<$root> =~ m#^(/home/cvs|/home/wakaba/pub/cvs)$#) { + if (<$root> =~ m#^(/home/cvs|/home/wakaba/pub/cvs)/?$#) { my $rpath = $1; if (-f $dir . '/CVS/Repository') { open my $repo, '<', $dir . '/CVS/Repository'; @@ -300,4 +302,4 @@ =cut -# $Date: 2005/02/26 04:15:33 $ +# $Date: 2005/03/11 11:51:48 $