#!/usr/bin/perl # FlasH BBS Pro version 1.40 # # Script written by Shigeto Nakazawa.(1997/1/17) # < http://www7.big.or.jp/~jawa/ > # This script is free. # ////////////////////////////////////////////////////////// # // Option settings // # ////////////////////////////////////////////////////////// # ---------------------------------------------------------- # setting the number of max articles # ---------------------------------------------------------- $max_size = 300 *1024; # article deletion file size (min 1500) $max_tree = 15; # number of list under each tree $max_msg = 8000; # number of words per mesg $new_kiji = 10; # how many "new"s to put # ---------------------------------------------------------- # My info as the administrator # ---------------------------------------------------------- $admin_name = 'Kaboom!'; # admin name $admin_email = 'kaboom@kaboom.orion.tj'; # admin email # ---------------------------------------------------------- # custimizing this BBS # ---------------------------------------------------------- $title = "Saryrn Guild BBS Pro v1.40"; # BBS title $body = '
'; #Body $backurl = "http://www.csua.berkeley.edu/~hosaka/EQ/"; # Back URL $date = "year/mon/day hour:min"; # time & date format $date_type = 1; # fix one line to 2 lines? # no=0, yes=1, all=2 $em_color = "#EE0033"; # color for emphasis $kiji_title_color = "#EEEEFF"; # article title color $kiji_title_bgcolor = "#261B10"; # title background color $form_bgcolor = "#EED155"; # submit form background color $res_color = "#444499"; # response color $gif_allnews = '../../all_news.gif'; # GIF IMAGE for read all at once $gif_news = '../../news.gif'; # GIF IMAGE for regular reading $gif_new_news = '../../new_news.gif'; # GIF IMAGE for newest article $gif_space = '../../space.gif'; # clear GIF IMAGE for dummy purpose $gif_width = 20; # GIF IMAGE width $gif_height = 14; # GIF IMAGE height $tree_width = 30; # Tree Width $html_title=<<"_EOF_"; # HTML setting_EOF_ # this _EOF_ is necessary $html_info=<<"_EOF_"; # HTML setting
_EOF_ # this _EOF_ is necessary # ---------------------------------------------------------- # Cookie file and security # do not change unless necessary # ---------------------------------------------------------- $base_url = ""; # by writing the URL for CGI-bin, the illegal # submissions are elminiated $cookie_name = 'fbbspro'; # cookie ID $jcode = './jcode.pl'; # jcode.pl location (NOT URL) $logfile = './flashbbs.log'; # record file (NOT URL) $countfile = './flashbbs.cnt'; # counter file (NOT URL) $lock1 = './fbbs1.lock'; # lock file (1) (NOT URL) $lock2 = './fbbs2.lock'; # lock file (2) (NOT URL) $lock_flag = 1; # use lock file: 1=yes, 0=no # ////////////////////////////////////////////////////////// # // option changes end here // # ////////////////////////////////////////////////////////// # [main body] # $ID = $FORM{'id'}; &check_code; &read_form; &get_cookie; &check_cookie; @logs = &read_file($logfile); if ($FORM{'md'} eq 'reg') { ®ist; } elsif ($FORM{'md'} eq 'del') { &delete; } elsif ($FORM{'md'} eq 'viw') { &view; } elsif ($FORM{'md'} eq 'new') { &html_header("New Thread");print"
$html_title
_EOF_ } # [Showing the Author (make sure to do it)] # sub html_footer { print<<"_EOF_";
\n";
$end_tree = $tree + $max_tree;
if ($end_tree > @logs) { $end_tree = @logs; }
for ($i=$tree;$i<$end_tree;$i++) {
print"
";
@datas = ÷_log($logs[$i]);
foreach (@datas) {
local($no,$res,$lx,$tn,$title,$name,$email,$date,$act) = ÷_data($_);
if ($res eq 'root') {
print "
";
} else {
local($space_width) = $gif_width+$tree_width*$lx;
print "
";
}
print "";
if ($no > $count - $new_kiji) {
print "
";
} else {
print "
";
}
print "$title : ";
if ($COOKIE{'name'} eq $name) {
print "$name";
} else { print $name; }
print " ($date)\n";
}
}
print"\n";
}
# [Show each of the articles ]
#
sub view {
&html_header("Article:($FORM{'no'})");
@kiji_datas = ÷_log(&search_no2data($FORM{'tn'},@logs));
$kiji_data = &search_no2data($FORM{'no'},@kiji_datas);
print"[This is the root article]$parent
[Response to this article]$children
_EOF_
@kiji_datas = ÷_log(&search_no2data($FORM{'tn'},@logs));
foreach (@kiji_datas) {
local($no,$res,$lx,$tn,$title,$name,$email,$date,$act) = ÷_data($_);
$no = int($no);
$reply[$res] .= "$no-";
if ($res eq 'root') {
print "
";
} else {
local($space_width) = $gif_width+$tree_width*$lx;
print "
";
}
print "
$title : $name($date)\n";
}
foreach $data (@kiji_datas) {
local($no,$res,$lx,$tn,$title,$name,$email,$date,$act,$pwd,$rhost,$ipad,$comment) = ÷_data($data);
$no = int($no);
print<<"_EOF_";
| $no | _EOF_ if ($res eq 'root') { print" Root\n"; } else { $res = int($res); print"-[$res]\n"; } print" | \n"; if (!$reply[$no]) { print"None\n"; } else { chop($reply[$no]); local(@replys) = split(/-/,$reply[$no]); foreach (@replys) { print"\>[$_]\n"; } } print" |
| \n"; &kiji_view($data); print<<"_EOF_"; | ||
Reply this Article|Display by set
| _EOF_ &kiji_view($data); print<<"_EOF_"; |
| $title |
|
$name($date)
$comment
|
If there are response articles following the deleted article, it may not be deleted completely.
If you want it to be completely removed, please contact the BBS Administrator.
_EOF_
}
# [ Data Handle]
#
sub divide_log {
local($data) = $_[0];
chop($data);
return split(/<#>/,$data);
}
sub divide_data {
return split(/<>/,$_[0]);
}
sub search_no2data {
local($no,@datas) = @_;
local($data);
foreach $data (@datas) {
if ($no == (split(/<>/,$data))[0]) { return $data; }
}
return 0;
}
# [Getting Data from Form]
#
sub read_form {
local($pair,$buffer);
if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; }
local(@pairs) = split(/&/,$buffer);
foreach $pair (@pairs) {
local($name,$value) = split(/=/,$pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$FORM{$name} = &change_code($value);
}
}
# [ Dealing with Cookies ]
#
sub check_cookie {
local($text);
foreach $text ('font','sort','tree','form','new_mail','res_mail') {
if (($FORM{$text} ne '') && ($COOKIE{$text} ne $FORM{$text})) { $COOKIE{$text} = $FORM{$text}; }
}
}
sub get_cookie {
local($pair,%DUMMY);
local($cookies) = $ENV{'HTTP_COOKIE'};
local(@pairs) = split(/;/,$cookies);
foreach $pair (@pairs) {
local($name,$value) = split(/=/,$pair);
$name =~ s/ //g;
$DUMMY{$name} = $value;
}
@pairs = split(/,/,$DUMMY{$cookie_name});
foreach $pair (@pairs) {
local($name,$value) = split(/:/,$pair);
$COOKIE{$name} = &change_code($value);
}
}
sub set_cookie {
local($cook) = "name\:$COOKIE{'name'}\,email\:$COOKIE{'email'}\,pwd\:$COOKIE{'pwd'}\,font\:$COOKIE{'font'}\,sort\:$COOKIE{'sort'}\,tree\:$COOKIE{'tree'}\,form\:$COOKIE{'form'}\,new_mail\:$COOKIE{'new_mail'}\,res_mail\:$COOKIE{'res_mail'}";
$ENV{'TZ'} = "GMT"; # International standard time
local($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime(time + 30*24*60*60);
if ($sec < 10) { $sec = "0$sec"; }
if ($min < 10) { $min = "0$min"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($mday < 10) { $mday = "0$mday"; }
if ($year < 10) { $year = "0$year"; }
$mon = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')[$mon];
$youbi = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')[$wday];
$date_gmt = "$youbi, $mday\-$mon\-$year $hour:$min:$sec GMT";
print "Set-Cookie: $cookie_name=$cook; expires=$date_gmt\n";
}
# [Word codes]
#
sub check_code {
if (!(-r $jcode)) { &error(1,"jcode.pl is missing"); }
require $jcode;
local($text) = ord(substr("中澤重人=じゃわ(^-^;;",0,1));
if ($text == 0xc3) { $mojicode = "euc"; $charset_code = "x-euc-jp"; }
elsif ($text == 0x92) { $mojicode = "sjis";$charset_code = "x-sjis"; }
else { &error(1,"This language is not supported"); }
}
sub change_code {
local($text)=$_[0];
&jcode'convert(*text,$mojicode);
if ($mojicode eq 'sjis') { &jcode'h2z_sjis(*text); }
if ($mojicode eq 'euc') { &jcode'h2z_euc(*text); }
$text =~ s/</g;
$text =~ s/>/>/g;
return $text;
}
# [Getting Date]
#
sub get_date {
$ENV{'TZ'} = "JST-9"; # TimeZone (japan time =International Standard Time (JST) - 9hours)
# (pacific time = JST-16)
local($sec,$min,$hour,$day,$mon,$year) = localtime();
$mon++;
if ($date_type) {
if ($sec < 10) { $sec = "0$sec"; } # seconds
if ($min < 10) { $min = "0$min"; } # minutes
if ($hour > 12) { $min = "$min PM";
$hour = $hour-12} #changed...does it work?
if ($date_type > 1) {
if ($mon < 10) { $mon = "0$mon"; } # month
if ($day < 10) { $day = "0$day"; } # day
}
}
$year += 1900;
$date =~ s/year/$year/ig;
$date =~ s/mon/$mon/ig;
$date =~ s/day/$day/ig;
$date =~ s/hour/$hour/ig;
$date =~ s/min/$min/ig;
$date =~ s/sec/$sec/ig;
}
# [ Log files ]
#
sub read_file {
local($logfile) = $_[0];
&lock_file($lock1);&lock_file($lock2);
if ($lock_error) { &error(1,"Locked file was found. Please try again later"); }
if (!open(IN,$logfile)) { &unlock_file; &error(1,"Unable to write to the log file"); }
local(@files) =
_EOF_
exit;
}
ERROR:$err_msg