diff -Naru wiki3_6_4_orig/plugin/_ex_attach/AttachHandler.pm wiki3_6_4/plugin/_ex_attach/AttachHandler.pm --- wiki3_6_4_orig/plugin/_ex_attach/AttachHandler.pm 2015-02-13 18:03:58.000000000 +0900 +++ wiki3_6_4/plugin/_ex_attach/AttachHandler.pm 2016-04-17 18:50:21.000000000 +0900 @@ -75,7 +75,29 @@ binmode(DATA); while(read($hundle,$_,16384)){ print DATA $_; } close(DATA); + + if ($cgi->param("decompress")) { + if ($filename =~ /\.zip$/) { + eval 'use Archive::Zip'; + if ($@) { + return $wiki->error("Archive::Zip が読み込めないため、ZIP ファイルを解凍して添付することができません。詳細: " . Util::escapeHTML($@)); + } + my $zip = Archive::Zip->new($uploadfile); + foreach my $member ($zip->members()) { + if (! $member->isDirectory()) { + my $contents = $member->contents(); + open my $fh, '<', \$contents; + push(@files, $member->fileName()); + push(@handles, $fh); + } + } + unlink($uploadfile); + next; + } + # elsif ($filename =~ /\.tar$/) { ... } + } + # attachプラグインから添付された場合 if(defined($cgi->param("count"))){ my @lines = split(/\n/,$wiki->get_page($pagename)); @@ -157,6 +179,47 @@ $wiki->redirect($pagename); #------------------------------------------------------- + # ZIP でダウンロード + } elsif($cgi->param("ZIP") ne ""){ + eval 'use Archive::Zip'; + if ($@) { + return $wiki->error("Archive::Zip が読み込めないため、この機能は使用できません。詳細: " . Util::escapeHTML($@)); + } + + my (@files) = (); + push(@files, $cgi->param("file")); + if(!defined(@files)){ + return $wiki->error("ファイルが指定されていません。"); + } + unless($wiki->page_exists($pagename)){ + return $wiki->error("ページが存在しません。"); + } + unless($wiki->can_show($pagename)){ + return $wiki->error("ページの参照権限がありません。"); + } + + my $zip = Archive::Zip->new(); + for (my $i=0; $i<=$#files; $i++) { + my $filename = $files[$i]; + my $filepath = ($wiki->config('attach_dir')."/".&Util::url_encode($pagename).".".&Util::url_encode($filename)); + unless(-e $filepath) { + return $wiki->error("ファイル " . Util::escapeHTML($files[$i]) . " がみつかりません。"); + } + &Jcode::convert(\$filename, 'utf8'); + $zip->addFile($filepath, $filename); + } + + my $stdout = IO::File->new->fdopen(fileno(STDOUT), "w") || croak($!); + $stdout->print("Content-Type: application/zip\n"); + $stdout->print(&Util::make_content_disposition($pagename . ".zip", "attachment")); + $zip->writeToFileHandle($stdout, 0); + + # ログの記録 + &write_log($wiki,"DOWNLOAD-ZIP",$pagename); + + exit(); + + #------------------------------------------------------- # ダウンロード } else { my $file = $cgi->param("file"); diff -Naru wiki3_6_4_orig/tmpl/attach.tmpl wiki3_6_4/tmpl/attach.tmpl --- wiki3_6_4_orig/tmpl/attach.tmpl 2006-07-31 12:03:38.000000000 +0900 +++ wiki3_6_4/tmpl/attach.tmpl 2016-04-17 18:47:57.000000000 +0900 @@ -24,6 +24,8 @@
" method="post" enctype="multipart/form-data"> + "> - + +