#! /usr/bin/perl use strict; use Compress::Zlib; use File::Temp qw(tempfile); # ここを書きかえる: our $CACHE_DIR = '/some/where/apache2/has/write-access'; my $request_uri = $ENV{'REQUEST_URI'}; my $rewrite = 0; my $board = ''; my $server = ''; if ($request_uri =~ m,^http://([a-z0-9]+\.2ch\.net)/([^/]+)/subback\.html$,) { $server = $1; $board = $2; } else { my $buf; while (read(STDIN,$buf,4096)) { print $buf; } exit 0; } my ($fh, $filename) = tempfile("tmpXXXXXXX", DIR=>$CACHE_DIR); my $gz = gzopen(\*STDIN, "rb"); my $buffer; print $fh $buffer while $gz->gzread($buffer) > 0; $gz->gzclose; close $fh; open IN, $filename; $gz = gzopen(\*STDOUT, "wb"); $gz->gzwrite("$board\@2ch"); $gz->gzwrite("\n\n"); while () { chop if /\n$/; chop if /\r$/; if (m,^(.*),) { my $out = "$_
\n"; $gz->gzwrite($out); } } $gz->gzwrite("\n\n"); $gz->gzclose; unlink $filename; exit 0;