#!/usr/bin/perl
########################################
# #
# BBS LOG File List Maker ver0.10 #
# Last update is 04/05/19 #
# #
# This script is written by KL. #
# #
########################################
use CGI;
#----------#
# Perl #
#----------#
#---subroutine---#
sub filestat {
my($filename) = @_;
open(F, $filename);
@stats = stat(F);
close(F);
($sec,$min,$hour,$day,$mon,$year,$wday,$yday) = localtime($stats[9]);
$year += 1900;
$year = substr($year,-2,2);
@week = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
$mon++;
$date = sprintf("%02d\/%02d\/%02d(%s) %02d\:%02d:%02d",$year,$mon,$day,$week[$wday],$hour,$min,$sec);
if ($stats[7]<1024) {
$Fsize = $stats[7] . "Byte";
} else {
$Fsize = ($stats[7]>>10) . "KB";
}
print "$filename [保管日:$date] [容量:$Fsize]
\n";
}
#---main task---#
#---from HTML---
$q = new CGI;
$mode = $q->param('mode');
#---check $mode---
if ($mode =~ /\D+/g || $mode == "") {
$mode = 0;
}
#---open directry---
opendir(DIR, "./");
@entry = readdir DIR;
closedir(DIR);
#---make a file list---
foreach $line (@entry) {
if ($line =~ /\.html+/g) {
unshift @result, $line;
}
}
#----------#
# HTML #
#----------#
print "Content-type: text/html \n\n";
print <
過去ログ一覧
HEAD $i = 0; while ($i<20 && $mode*20+$i<=$#result) { &filestat($result[$mode*20+$i]); $i++; } print " |