#! /usr/local/bin/perl #はじあや@ふぁみーるのパソヲタさん、本当にありがとう #-------------------- $body = ''; $bbstitle ="あやしいわーるどREMIX"; $logdir = './log/'; $cgiurl = 'getlog_m.cgi'; $action ='getlog'; $bbsurl = './bbs.cgi'; # 日本語コード変換ライブラリjocde.plのパス require './jcode.pl'; # キーワードの最大文字数(半角) $keylength = 64; # 時差 サーバの時計がずれてる時や日本時間以外にしたい時に使う $tim = 0; $\ = "\n"; #-------------------- #if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } #else { $buffer = $ENV{'QUERY_STRING'}; } $buffer = $ENV{'QUERY_STRING'}; @argv = split(/&/,$buffer); foreach (@argv) { ($name, $value) = split(/=/); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; &jcode'convert(*value,'sjis'); $COMMAND{$name} = $value; } &error(2) if (length($COMMAND{'keyword'}) > $keylength); &viewlog if ($COMMAND{'action'} eq "$action"); &list; sub list { &error(0) if(!opendir(DIR, $logdir)); @files=readdir(DIR); closedir(DIR); @files = sort by_number @files; $end = @files; $end--; print "Content-type: text/html\n\n"; print "$bbstitle 過去ログ\n"; print "$body\n"; print "
\n"; print ""; print "
$bbstitle 過去ログ一覧
"; print "
"; print ""; print ""; print ""; foreach (0 .. $end) { if (!($files[$_] eq "." or $files[$_] eq "..")) { ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat "$logdir$files[$_]"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($mtime + 32400 + $tim); $mon++; $mon = "0$mon" if ($mon < 10); if ($mday < 10) { $mday = "0$mday"; } if ($min < 10) { $min = "0$min"; } if ($hour < 10) { $hour = "0$hour"; } $checked = ' checked' if ($_ == $end); print ""; print ""; print ""; } } print "\n"; print "
"; print " "; print "
"; print "
ファイル名サイズ日付
$files[$_]$size$mon/$mday $hour:$min
※ラジオボタンでファイル名を指定してください。
日時指定:時から"; print "時まで"; print "
 検索 :"; print "
"; print "
"; print "

掲示板へ

"; print "

Getlog Ver0.3b4 月単位保存ログ対応版

"; print ""; } sub viewlog { if (!open(DB,"$logdir$COMMAND{'logfile'}")) { &error(1); } @lines = ; close(DB); $COMMAND{'last'} = $COMMAND{'first'} + 1 if ($COMMAND{'first'} >= $COMMAND{'last'}); $first = "$COMMAND{'day1'}日$COMMAND{'hour1'}時"; $last = "$COMMAND{'day2'}日$COMMAND{'hour2'}時"; if ($COMMAND{'searchmode'} eq 'name') { $keyword = "投稿者:.*>${COMMAND{'keyword'}}<"; } elsif ($COMMAND{'searchmode'} eq 'subject') { $keyword = "color=\"#ffffee\">${COMMAND{'keyword'}}"; } elsif ($COMMAND{'searchmode'} eq 'bbs') { $keyword = "秒 .*>${COMMAND{'keyword'}}<"; } else { $keyword = $COMMAND{'keyword'}; } if ($keyword ne '') { $keyword =~ s/\\/\\\\/; $keyword =~ s/\[/\\[/; } print "Content-type: text/html\n"; print "$bbstitle 過去ログ $COMMAND{'logfile'}"; print "$body"; print "

$COMMAND{'logfile'} $first〜$last

"; $end = @lines; $end--; foreach (0 .. $end) { # MiniBBS7.5あやしいわーるど仕様 if ($lines[$_] =~ / 投稿日:/) { substr( $hour = substr( $lines[$_], 28, 12 ), 4, 4 ) = "" ; last if ($hour ge "$first"); } $skip++; } $skip--; # print"
"; $\ = ''; foreach ($skip .. $end) { # MiniBBS7.5あやしいわーるど仕様 if ($lines[$_] =~ / 投稿日:/) { substr( $hour = substr( $lines[$_], 28, 12 ), 4, 4 ) = "" ; last if ($hour ge "$last"); } if ($keyword ne '') { if ($lines[$_] =~ /$keyword/) { $flag = 1; $hit++; } push( @article, $lines[$_] ); if ($lines[$_] =~ /<\/blockquote>/) { print @article if ($flag > 0); splice( @article, 0 ); $flag = 0; } } else { print $lines[$_]; } } $\ = "\n"; if ($COMMAND{'keyword'} ne '') { print "
"; if ( $hit > 0 ) { print "

「$COMMAND{'keyword'}」は $hit件見つかりました。

"; } else { print "

「$COMMAND{'keyword'}」は見つかりませんでした。

"; } } print ""; exit; } sub error { $error = $_[0]; if ($error == 0) { $errmsg = 'ディレクトリが開けませんでした。'; } if ($error == 1) { $errmsg = 'ファイルが開けませんでした。'; } if ($error == 2) { $errmsg = 'キーワードが長すぎます。'; } print "Content-type: text/html\n"; print "エラー"; print "$body"; print "

$errmsg

"; print ""; exit; } sub by_number { $a <=> $b; }