#! /usr/local/bin/perl ########################################## #BooBBS-tt- v1.76 / this program is free.# #(C) BooBooClub 1998-2008 # ########################################## #set data $cgi = "./bbbst.cgi"; $dat = "./btdata.dat"; $ttl = "BBS"; $title = '

BooBBS -TableType-

'; $linkname = "back"; $linkurl = "./linkto_url"; $back = 'bgcolor="#d0d0ee"'; $linkc = 'text="#000000" link="#0000ff" vlink="880088"'; $tpmt = 'border="3"'; $adpass = 'pass'; $max = '30'; #read_lib require 'jcode.pl'; #lock check &lock; sub lock{ $lockfile = "./lock/lockfile"; $retry = 1; until (symlink("$dat", "$lockfile")){ if (++$retry >= 7){ unlink("$lockfile"); exit(0); } sleep(5); } } #time $ENV{'TZ'}='JST-9'; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year = ($year + 1900); $mon++; if ($sec < 10) { $sec = "0$sec";} if ($min < 10) { $min = "0$min";} if ($hour < 10){ $hour = "0$hour";} if ($mon < 10) { $mon = "0$mon";} if ($mday < 10){ $mday = "0$mday";} $time = "$year/$mon/$mday $hour:$min:$sec"; #read if ($ENV{'REQUEST_METHOD'} eq "POST"){ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else{ $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/,$buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/\cM\n//g; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\,//g; $value =~ s//>/ig; $value =~ s/\r\n|[\r\n]/
/ig; &jcode'convert(*value,'sjis'); $FORM{$name} = $value; } #branch if (!$FORM{'submit'}) { &html; } else { if ($FORM{'submit'} eq "投稿") { ✓ &write; &html; } elsif ($FORM{'submit'} eq "削除") { if ($FORM{'cpass'} eq "") { &error; } if ($FORM{'no'} eq "") { &error; } if ($FORM{'cpass'} eq $adpass){ &adchg; } else{ &change; } &html; } else { &error; } } sub check { if ($FORM{'name'} eq "") { &error; } if ($FORM{'msg'} eq "") { &error; } if ($FORM{'txt'} eq "") { &error; } } sub write { open (DAT,"$dat"); @bbsdats = ; close (DAT); #cnt open (OFC,"fc.dat"); $fn = ; close (OFC); $fn = ++$fn; if ($fn eq "10001"){ $fn = "1"; } open (NFC,">fc.dat"); print NFC $fn; close (NFC); if ($FORM{'npass'} eq "") { $FORM{'npass'} = "dummy_for_nopass"; } $wrt = "$fn\,$FORM{'npass'}\,$FORM{'name'}\,$FORM{'mail'}\,$time\,$FORM{'msg'}\,$FORM{'txt'}\n"; #over $i = 0; foreach $bbsdat (@bbsdats) { $i++; if ($i >= $max) { last; } push (@ndat,$bbsdat); } unshift(@ndat,$wrt); #write new dat open (DAT,">$dat"); print DAT @ndat; close (DAT); } sub adchg { open (DAT,"$dat"); @bbsdats = ; close (DAT); if ($FORM{'submit'} eq "削除"){ foreach $bbsdat (@bbsdats) { ($fn,$pass,$name,$mail,$time,$msg,$txt) = split(/,/,$bbsdat); if ($FORM{'no'} ne "$fn"){ push (@nd,$bbsdat); } } open (ND,">$dat"); print ND @nd; close (ND); } } sub change { open (DAT,"$dat"); @bbsdats = ; close (DAT); if ($FORM{'submit'} eq "削除"){ $d = "0"; foreach $bbsdat (@bbsdats) { ($fn,$pass,$name,$mail,$time,$msg,$txt) = split(/,/,$bbsdat); if (($FORM{'no'} ne "$fn")||($FORM{'cpass'} ne "$pass")){ push (@nd,$bbsdat); } elsif (($FORM{'no'} eq "$fn")&&($FORM{'cpass'} eq "$pass")){ $d = "1"; } } if ($d eq "0"){ print "Content-type: text/html\n\n"; print "Error\n"; print "\n"; print "

Error!



\n"; print "不正なパスワードです\n"; print "
リロードしてください
\n"; unlink("$lockfile"); exit 0; } open (ND,">$dat"); print ND @nd; close (ND); } } sub html { #get dat open (DAT,"$dat"); @bbsdats = ; close (DAT); #html print "Content-type: text/html\n\n"; print "\n"; print "$ttl\n"; print "\n"; print "
\n"; print "$title\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
名 前:\n"; print "  \n"; print "\n"; print "E-mail:\n"; print "\n"; print "
件 名:
\n"; print "内 容:\n"; print " \n"; print "
\n"; print "[Password:]   
\n"; print "  \n"; print "
\n"; print "[Password:\n"; print "No.:]
\n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; print "\n"; print "\n"; print "$linkname

\n"; print "


\n"; print "\n\n"; print "
\n"; foreach $bbsdat (@bbsdats) { ($fn,$pass,$name,$mail,$time,$msg,$txt) = split(/,/,$bbsdat); print ""; print ""; print "
"; print "$msg
$fn
投稿者:"; if ($mail ne "") { print "$name"; } else{ print "$name"; } print "   [$time]
"; print "$txt

\n\n"; } print "
\n"; print "
\n"; print "[CGI Produced by BooBooClub]\n"; print "
\n"; print "\n"; unlink("$lockfile"); exit 0; } sub error { print "Content-type: text/html\n\n"; print "$bbstitle\n"; print "\n"; print "

Error!



\n"; print "未記入欄があります\n"; print "
リロードしてください。
\n"; unlink("$lockfile"); exit 0; }