#! /usr/local/bin/perl #################################################### #BooTreeBBS v1.08 / This program is value software.# #(C) BooBooClub 1999-2005 # #################################################### #set data $vmax = '30'; $nmax = '150'; $cgi = './btbbs.cgi'; $dat = './bdata.dat'; $admin = './btadmin.cgi'; $bbstitle = 'BooTreeBBS'; $head = '

BooTreeBBS

'; $linkname = 'Back'; $linkurl = './'; $back = 'bgcolor="#ffffff"'; $linkc= 'text="#000000" link="#0000ff" vlink="#880088"'; $nomail = '#555555'; $rmvc = '#555555'; $type = 'b'; $autolink = 'off'; $pmark = ''; $cmark = '・ '; $timetext = 'size=-1'; $new = 2; $newtext = 'color="#ff0000"'; $topnew = 'off'; $rmnews = 'Admin Removed'; #read_lib require './jcode.pl'; #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/%([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; #prevent chr error &jcode'convert(*value,'sjis'); $FORM{$name} = $value; } #branch if($FORM{'rev'}){ &lock; &rev; } elsif ($FORM{'submit'} eq '書き込み') { ✓ &lock; &write; &html; } else { &lock; &html; } sub rev { open (DAT,"<$dat"); @bbsdats = ; close (DAT); $FORM{'rev'} =~ s/_/ /ig; foreach $bbsdat (@bbsdats) { chomp $bbsdat; ($re,$name,$mail,$title,$txt,$time) = split(/,/,$bbsdat); if($FORM{'rev'} eq $time){ last; } } print "Content-type: text/html\n\n"; print "$bbstitle\n"; print "\n"; print "
\n"; print ""; if ($re > 0){ if($re == 1){ print "Re: "; } else{ print "Re[$re]: "; } } print "$title
\n"; if ($mail){ print "$name"; } else{ print "$name"; } print " [$time]
\n"; print "$txt

\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 "
\n"; print "     "; print " \n"; print "
\n"; print "
\n"; print "
"; print "
Produced by BooBooClub

\n"; print "\n"; unlink("$lockfile"); exit 0; } sub check { if ($FORM{'name'} eq ""||$FORM{'title'} eq ""||$FORM{'txt'} eq ""){ &error_ww; } } sub lock { $lockfile = './lock/lockfile'; #lock check $retry = 1; until (symlink("$dat", "$lockfile")){ if (++$retry >= 30){ unlink("$lockfile"); exit 0; } sleep(1); } } sub write { open (DAT,"$dat"); @bbsdats = ; close (DAT); if($autolink eq 'on'){ $FORM{'txt'} =~ s/(http:[\w\.\/\~\+\-\?%=&^]+)/$1<\/a>/g; $FORM{'txt'} =~ s/([\w\.\-]+@[\w\.\-]+)/$1<\/a>/g; } elsif($autolink eq 'onw'){ $FORM{'txt'} =~ s/(http:[\w\.\/\~\+\-\?%=&^]+)/$1<\/a>/g; $FORM{'txt'} =~ s/([\w\.\-]+@[\w\.\-]+)/$1<\/a>/g; } if($FORM{'re'} || ($FORM{'re'} eq "0")){ if($FORM{'title'} =~ /^Re/){ $cl = length "$FORM{'rel'}"; $title = substr ($FORM{'title'},$cl); } else{ $title = $FORM{'title'}; } $re = ($FORM{'re'} + 1); $wrt = "$re\,$FORM{'name'}\,$FORM{'mail'}\,$title\,$FORM{'txt'}\,$time\n"; foreach $bbsdat (@bbsdats){ ($re,$name,$mail,$title,$txt,$time) = split(/,/,$bbsdat); if($re == 0){ $tmpparent = $time; } if($time =~ /$FORM{'ret'}/){ $parent = $tmpparent; push (@ndat,"$bbsdat"); push (@ndat,"$wrt"); } else{ push (@ndat,"$bbsdat"); } } if($topnew eq 'on'){ @bbsdat = @ndat; @ndat = (); $nflag = 0; foreach $bbsdat(@bbsdat){ ($re,$name,$mail,$title,$txt,$time) = split(/,/,$bbsdat); if($nflag == 1 && $re == 0){ $nflag = 0; push(@otherdat,$bbsdat); } elsif($nflag == 1 || ($re == 0 && $time eq $parent)){ $nflag = 1; push(@topdat,$bbsdat); } else{ push(@otherdat,$bbsdat); } } @ndat = (@topdat,@otherdat); } } else{ $re = 0; $wrt = "$re\,$FORM{'name'}\,$FORM{'mail'}\,$FORM{'title'}\,$FORM{'txt'}\,$time\n"; unshift(@bbsdats,$wrt); @ndat = @bbsdats; } #over $i = 0; foreach $odat (@ndat) { $i++; if ($i > $nmax) { last; } push (@wdat,$odat); } #write new data open (DAT,">$dat"); print DAT @wdat; close (DAT); } sub html { #get dat open (DAT,"<$dat"); @bbsdats = ; close (DAT); #html print "Content-type: text/html\n\n"; print "$bbstitle\n"; print "\n"; print "
\n"; print "$head\n"; print "
\n"; print "
\n"; if ($type eq "t"){ &form; &view; } else { &view; &form; } print "\n"; print "\n"; print "
"; if ($FORM{'page'}){ $pcv = ($FORM{'pc'} + 1); } elsif ($FORM{'rpage'}){ $pcv = ($FORM{'pc'} - 1); } else{ $pcv = 1; } print "
\n"; print "\n"; print "  "; if (($vmax < $mc) && ((!$FORM{'pc'}) || ($pcv * $vmax < $mc))){ print "  \n"; } if (($FORM{'pc'} && $FORM{'page'}) || (($FORM{'pc'} != 2) && $FORM{'rpage'})){ print "\n"; } print "
"; print "
\n"; print "
Produced by BooBooClub
\n"; print "For Admin
\n"; print "

\n"; print "\n"; unlink("$lockfile"); exit 0; } sub form{ print "
\n"; print "
\n"; print "名前 :\n"; print "
\n"; print "E-mail:\n"; print "
\n"; print "件名 :\n"; print "
\n"; print "内容 :\n"; print "
\n"; print "     "; print " \n"; if($type eq "t"){ print "  $linkname"; } print "
\n"; print "
\n"; if(@bbsdats){ print "
\n"; } } sub view{ print "
\n\n"; if ($type eq "b"){ print "[書き込み]\n"; print "  [$linkname]

"; } $mc = 0; $mcc = 0; if ($FORM{'page'}){ $miv = (($FORM{'pc'} * $vmax) + 1); $mav = (($FORM{'pc'} + 1) * $vmax); } elsif ($FORM{'rpage'}){ $miv = ((($FORM{'pc'} - 2) * $vmax) + 1); $mav = (($FORM{'pc'} - 1) * $vmax); } else{ $miv = 1; $mav = $vmax; } foreach $bbsdat (@bbsdats) { $mc++; if ($miv <= $mc && $mc <= $mav){ $mcc++; chomp $bbsdat; ($re,$name,$mail,$title,$txt,$time) = split(/,/,$bbsdat); $dtime = $time; $dtime =~ s/ /_/ig; $spc = (' ') x $re; print "$spc"; if ($re eq 0){ print "
$pmark"; } else{ print "$cmark"; } if ($title ne $rmnews){ print ""; if ($re ne 0){ print "Re"; if ($re >= 2){ print "[$re]"; } print ": "; } print "$title"; print " "; } else{ print "$title "; } if($mail eq ""){ print "[$name]"; } else{ print '[',"$name",']'; } @ntime = localtime(time - (60*60*24*$new)); $ntime[5] +=1900; $ntime[4]++; if($ntime[4] < 10){ $ntime[4] = '0'.$ntime[4]; } if($ntime[3] < 10){ $ntime[3] = '0'.$ntime[3]; } $ntime = $ntime[5].$ntime[4].$ntime[3]; $ttime = $time; ($ttime,$d) = split(/ /,$ttime); $ttime =~ s/\///g; $timefont = ''; if($ntime < $ttime){ $timefont = $timetext.' '.$newtext; } else{ $timefont = $timetext; } print " $time"; if ($title eq $rmnews){ print ""; } print "
\n"; } } print "

\n"; print "
"; } sub error_ww { print "Content-type: text/html\n\n"; print "$bbstitle\n"; print "\n"; print "

error



\n"; print "未記入欄があります。\n"; print "

ブラウザのバックボタンで戻ってください。\n"; print "
\n"; exit 0; }