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

BooThreadBBS

'; $linkname = 'Back'; $linkurl = './'; $back = 'bgcolor="#ffffff"'; $linkc= 'text="#000000" link="#0000ff" vlink="#880088"'; $nomail = '#555555'; $rmvc = '#555555'; $type = 'b'; $autolink = 'on'; #def_set require './jcode.pl'; $rmnews = 'Admin Removed'; #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; } #allow 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; $h = 0; foreach $bbsdat (@bbsdats) { chomp $bbsdat; ($re,$name,$mail,$title,$txt,$time) = split(/,/,$bbsdat); if($h ne 0 && $re eq 0){ last; } if($FORM{'rev'} eq $time){ $thtitle = $title; $h++; } if($h ne 0){ push(@nvdat, $bbsdat); } } print "Content-type: text/html\n\n"; print "$bbstitle\n"; print "\n"; print "
\n"; print "$thtitle

\n"; print "[Back]\n"; print "
\n"; foreach $vdats(@nvdat){ ($re,$name,$mail,$title,$txt,$time) = split(/,/,$vdats); if($title ne $rmnews){ 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"; } else{ print ""; print "$title
\n"; print "$name"; print " [$time]\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 "
\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($time =~ /$FORM{'ret'}/){ push (@ndat,"$bbsdat"); push (@ndat,"$wrt"); } else{ push (@ndat,"$bbsdat"); } } } 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; } @ddats = reverse (@bbsdats); foreach $ddats (@ddats){ @ddat = split(/,/, $ddats); if($ddat[0] ne 0){ if($dr < $ddat[0]){ $nt = $ddat[5]; $rn = $ddat[0] } $dr = $ddat[0]; } else{ if($nt ne ''){ $ddat[6] = $ddat[5]; $ddat[5] = $nt; } else{ $ddat[6] = $ddat[5]; } $ddat[7] = $rn; $dr = 0; $nt = ''; $rn = 0; ($ldate,$ltime) = split(/ /,$ddat[5]); ($ye,$mo,$da) = split(/\//,$ldate); ($ho,$mi,$se) = split(/:/,$ltime); $ddat[8] = "$ye"."$mo"."$da"."$ho"."$mi"."$se"; } $nddat = join (',', @ddat); push (@nddats, $nddat); } @bbsdats = map{$_->[0]} sort{$b->[1] <=> $a->[1]} map{[ $_ , (split /,/)[8] ]}@nddats; $mc++; foreach $bbsdat (@bbsdats) { $mcc++; chomp $bbsdat; ($re,$name,$mail,$title,$txt,$time,$dtime,$rn) = split(/,/,$bbsdat); $dtime =~ s/ /_/ig; unless ($rn){ $rn = 0; } if ($re == 0){ $mc++; if($rn < 10){ $rn = '0'."$rn"; } if($rn == 0){ $rn = '--'; } if ($miv <= $mc && $mc <= $mav){ print "
[Re$rn] ・ "; 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",']'; } 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"; unlink("$lockfile"); exit 0; }