http://sv3.mbx.jp/macavity/contents/bbs/mbdall.cgi
#!/usr/local/bin/perl
$max_msgs = 9999;
$utd_msgs = 10;
$emsg = "";
$ENV{'TZ'} = "JST-9";
@wdays = (
"<font color=\"#ff0000\">(日)</font>",
"(月)","(火)","(水)","(木)","(金)",
"<font color=\"#0000ff\">(土)</font>",
"<font color=\"#ff0000\">(日)</font>",
);
require "jcode.pl";
$code = ord(substr("漢", 0, 1));
if ($code == 0xb4) {
$ccode = "euc";
} elsif ($code == 0x1b) {
$ccode = "jis";
} else {
$ccode = "sjis";
}
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $query_string, $ENV{'CONTENT_LENGTH'});
@a = split(/&/, $query_string);
foreach $x (@a) {
($name, $value) = split(/=/, $x);
$value =~ tr/+/ /;
$value =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C", hex($1))/eg;
&jcode'convert(*value, "euc");
$value =~ s/&/&/g;
$value =~ s/"/"/g;
$value =~ s/</</g;
$value =~ s/>/>/g;
&jcode'convert(*value, $ccode);
$FORM{$name} = $value;
}
}
foreach $i ( 1, 2, 3, 4, 5, 6 ) {
if(open(LOCK,"+< mbd.loc")){
if(flock(LOCK, 6)){ last; }
else { close(LOCK); }
}
if ($i < 6) { sleep(2); }
else {
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>Message Board</TITLE></HEAD>\n";
print "<BODY BGCOLOR=\"#d0ffff\" TEXT=\"#000000\"><BASEFONT SIZE=\"2\">\n";
print "<A HREF=\"http://sv3.mbx.jp/macavity/\">[Home]</A>\n";
print "<center><font size=\"6\" color=\"#006666\"><B>Message Board</B>\n";
print "</font></center><HR>只今、掲示板が混雑しております。\n";
print "しばらくお待ちの上、再度アクセスお願いします。<HR></BODY></HTML>\n";
exit(1);
}
}
#########
# START #
#########
if ($FORM{'MESSAGE'} ne "") {
if ($FORM{'FROM'} ne "") {
$head = $FORM{'FROM'};
if ($FORM{'URL'} ne "") {
if ($FORM{'URL'} =~ /(.*)\@(.*)\.(.*)/) {
$head = "<A HREF=\"mailto:$FORM{'URL'}\">$head</a>";
} elsif ($FORM{'URL'} =~ /^http:/) {
$head = "<A HREF=\"$FORM{'URL'}\">$head</a>";
} else {
$emsg = "連絡先の入力が変です。確認してください。";
}
}
} else { $emsg = "名前を入れないと投稿できないよ〜。"; }
if ($emsg eq "") {
($sec, $min, $hour, $mday, $mon, $year, $wday) = localtime(time);
$date = sprintf("%02d月%02d日%s%02d時%02d分",
$mon + 1, $mday, $wdays[$wday], $hour, $min);
$FORM{'MESSAGE'} =~ s/\r*$//g;
$FORM{'MESSAGE'} =~ s/\r/<BR>/g;
$FORM{'MESSAGE'} =~ s/([^=^\"]|^)(s?https?:\/\/[-_.!~*'\(\)a-zA-Z0-9;\/?:\@&=+\$,%#]+)/$1<a href=\"$2\" target='_top'>$2<\/a>/g;
open(OUT, "> mbd.tmp");
print OUT "<!--start-->\n";
print OUT "<font size=\"4\" color=\"#ff0000\"><b>$head";
print OUT "</b></FONT> $date<blockquote><tt><font size=\"3\">";
print OUT "$FORM{'MESSAGE'}</font></TT><p></p></blockquote><HR>\n";
open(IN, "log/mbdutd.txt");
while (<IN>) {
print OUT;
}
close(IN);
open(IN, "log/mbdold.txt");
while (<IN>) {
print OUT;
}
close(IN);
close(OUT);
open(IN, "mbd.tmp");
open(OUT, "> log/mbdutd.txt");
$msgs = 0;
while (<IN>) {
if ($_ =~ /^<!--start-->/) {
if ($utd_msgs != 0) {
if ($msgs++ >= $utd_msgs) {
last;
}
}
}
print OUT;
}
close(OUT);
open(OUT, "> log/mbdold.txt");
while (<IN>) {
if ($_ =~ /^<!--start-->/) {
if ($max_msgs != 0) {
if ($msgs++ >= $max_msgs) {
last;
}
}
}
print OUT;
}
close(IN);
close(OUT);
$FORM{'MESSAGE'} ="";
}
}
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>WEB SHINSHIBA - Message Board</TITLE></HEAD>\n";
print "<BODY BGCOLOR=\"#d0ffff\" TEXT=\"#000000\"><BASEFONT SIZE=\"2\">\n";
print "<A HREF=\"http://sv3.mbx.jp/macavity/\">[Home]</A>\n";
print "<A HREF=\"http://sv3.mbx.jp/macavity/contents/bbs/mbd.cgi\">[Last 10]</A>\n";
print "<center><font size=\"6\" color=\"#006666\"><B>Message Board</B>\n";
print "</font></center><HR><FORM METHOD=POST ACTION=\"mbdall.cgi\">\n";
print "<TABLE BORDER=0><TR><TD>名前:</TD><TD>\n";
print "<INPUT TYPE=text NAME=FROM SIZE=20 VALUE=\"$FORM{'FROM'}\"></TD></TR><TR><TD>\n";
print "連絡先:</TD><TD><INPUT TYPE=text NAME=URL SIZE=54 VALUE=\"$FORM{'URL'}\"></TD>\n";
print "</TR><TR><TD COLSPAN=2><SMALL>連絡先にはメアドか";
print "URLを入れてください。省略可。</SMALL></TD></TR>\n";
print "<TR><TD COLSPAN=2><TEXTAREA ROWS=5 COLS=70 NAME=MESSAGE>$FORM{'MESSAGE'}</TEXTAREA></TD></TR>\n";
print "</TABLE><P><INPUT TYPE=submit VALUE=\"投稿 / 更新\"></FORM><HR>\n";
if ($emsg ne "") {
print "<font size=\"4\" color=\"#ff0000\"><b>$emsg</b></FONT><HR>\n";
}
open(IN, "log/mbdutd.txt");
while (<IN>) {
print;
}
close(IN);
print "<A NAME=\"old\"></A>\n";
open(IN, "log/mbdold.txt");
while (<IN>) {
print;
}
close(IN);
print "<BR><A HREF=\"http://sv3.mbx.jp/macavity/\">[Home]</A>\n";
print "<A HREF=\"http://sv3.mbx.jp/macavity/contents/bbs/mbdall.cgi\">[Top]</A>\n";
print "<A HREF=\"http://sv3.mbx.jp/macavity/contents/bbs/mbd.cgi\">[Last 10]</A>\n";
print "</BODY></HTML>\n";
close(LOCK);
#######
# END #
#######