#!/usr/local/bin/perl # dengon v0.1 by 1999 Deihaz require 'jcode.pl'; # 設定 $title = '一行伝言板'; $homepage = 'http://www.biwa.ne.jp/~fagott/'; $max = 10; $method = 'POST'; $script = 'dengon.cgi'; $logfile = 'dengon.log'; # 設定終わり if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } &decode; if (($form{'mode'} eq 'msg') and $form{'name'} and $form{'comm'}) { ®ist; &viewlog; } else { &viewlog; } sub viewlog { &header; print <<"EOH";

$title

何かの伝言に使って下さい。

お名前:
内容:


EOH open LOG, "$logfile" or &error('Logfile cannot be opened'); @lines = ; close LOG; foreach $line (@lines) { ($date, $name, $comm) = split(/\"/, $line); print qq([$name] $comm \($date\)
\n); print qq(
\n); } print qq(トップへ戻る\n); print qq(
\n\n\n); } sub regist { ($sec, $min, $hour, $mday, $mon, $year) = localtime(time); $mon++; if ($hour < 10) { $hour= "0$hour"; } if ($min < 10) { $min = "0$min"; } if ($sec < 10) { $sec = "0$sec"; } $date = "$mon/$mday $hour:$min:$sec"; $logname = "$form{'name'}"; open LOG ,"$logfile" or &error('Logfile cannot be opened'); @lines = ; close LOG; @newlines = @lines; unshift (@newlines, "$date\"$logname\"$form{'comm'}\"$ENV{'REMOTE_HOST'}\n"); if (@newlines > $max) { pop (@newlines); } open LOG, ">$logfile" or &error('Logfile cannot be written'); eval 'flock(LOG, 2);'; print LOG @newlines; close LOG; } sub header { print qq(Content-type: text/html\n\n); print qq(\n\n); print qq($title\n\n); print qq(\n); } sub decode { @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\"//g; $value =~ s///g; $value =~ s///ig; $value =~ s///ig; $value =~ s///ig; $value =~ s///ig; $value =~ s///ig; $value =~ s///ig; $value =~ s/\r\n//g; $value =~ s/\r|\n//g; &jcode'convert(*value, 'sjis'); $form{$name} = $value; } } sub error { &header; print qq(

システムエラーが発生しました!

\n); print qq(

$_[0]

\n); print qq(\n\n); exit; }