■スレッドリストへ戻る■ 全部 1- 101- 201- 301- 401- 501- 601- 701- 801- 901- 最新50

【スレッド】2ch型掲示板 14 【フロート型】

615 :nobodyさん :2006/09/28(木) 08:35:21 ID:???
#!/usr/bin/perl -w

use strict;
use POSIX qw(strftime);
use File::stat;
use Time::Local qw(timegm);

if ($#ARGV != 1 || $ARGV[0] =~ /\W/ || $ARGV[1] =~ /\D/) {
    print <<EOT;
Status: 400 Bad Request
Content-Type: text/plain

400 Bad Request
EOT
    exit;
}

my $fname = "../$ARGV[0]/dat/$ARGV[1].dat";
my $st;
if (!($st = stat($fname))) {
    print <<EOT;
Status: 404 Not Found
Content-Type: text/plain

404 Not Found
EOT
    exit;
}

616 :nobodyさん :2006/09/28(木) 08:36:06 ID:???
my $ims = !$ENV{HTTP_IF_MODIFIED_SINCE}
          ? 0
          : $ENV{HTTP_IF_MODIFIED_SINCE} =~ /^\w{3,}, {1,2}(\d{1,2})[ -](Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[ -](\d{2,4}) {1,2}(\d{1,2}):(\d{2}):(\d{2}) GMT$/
            ? timegm($6, $5, $4, $1, index('JanFebMarAprMayJunJulAugSepOctNovDec', $2) / 3, $3)
            : $ENV{HTTP_IF_MODIFIED_SINCE} =~ /^\w{3} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) {1,2}(\d{1,2}) {1,2}(\d{1,2}):(\d{2}):(\d{2}) (\d{4})$/
              ? timegm($5, $4, $3, $2, index('JanFebMarAprMayJunJulAugSepOctNovDec', $1) / 3, $6)
              : 0;
if ($ims ge $st->mtime) {
    print "Status: 304 Not Modified\n\n";
    exit;
}
my $mtime = strftime('%a, %d %b %Y %T GMT', gmtime($st->mtime));

print <<EOT;
Content-Type: application/xml; charset=Shift_JIS
Last-Modified: $mtime
Cache-Control: max-age=5

<?xml version="1.0" encoding="Shift_JIS"?>
<text><![CDATA[
EOT
if (open(DAT, $fname)) {
    while (<DAT>) {
        print;
    }
    close(DAT);
}
print "]]></text>\n";

226KB
新着レスの表示

スレッドリストへ戻る 全部 前100 次100 最新50

0ch BBS 2004-10-30