#!/usr/bin/perl use CGI; require 'jcode.pl'; use Time::Local; ############################################################################## # # EasyBBS PX ver 1.0.2 # Copyright(C) 2001 by Junnama Noda(junnama@alfasado.net). # # This Program is FREE to use, but I Don't support about this prgram at all. # # Original Version(for Mac OS) are witten by Motoyuki Tanaka. # http://mtlab.ecn.fpu.ac.jp/ # # このBBSは、田中求之氏のEasyBBS DX IIIを野田純生がPerlに移植したものです。 # 再配布、公開、改造等自由に行って構いませんが、このプログラムを実行した # 結果生じたいかなる問題についても作者は責任を負いません。 # ################################# 更新履歴 ################################# # Friday, August 17, 2001 1.0.0 # Sunday, August 19, 2001 1.0.1 # Monday, August 20, 2001 1.0.2 ################################# 初期設定 ################################# # 改行コードはデフォルトではCR、文字コードはsjisになっています。 # 環境によってLF,EUC等に変更する必要があるかもしれません。 # FTPクライアントやエディタによっては変換する機能があると思います。 # その場合、各発言やRecent関係のファイル、テンプレートについても変更するように # して下さい。 # top_recent でファイル名を決めておきます。ここで決めたのと同じ名前のファイルを # bbs.acgi と同じフォルダーの中に作っておく必要があります。 # ファイル名を _ で始めると、BBS の Recent は未公開として処理します # (マニュアルで URL を指定しないとアクセスできない) $top_recent = "BBS_recent"; # Recent ページを呼び出すためのコマンドを決めておきます。 # BBS の Recent を未公開にしたときには、ここで決めたコマンドを # 含めた URL を使ってアクセスすることになります。 # たとえば以下のように "myRecent" にしたときには # http://your.host/BBS/bbs.cgi?myRecent # というのが URL になります。つまり bbs.cgi?<コマンド名> # で呼び出すわけです。 # オリジナルソース:$recent_cmd = "myRecent"; $recent_cmd = "http://www.powerbook.org/rikibon/bbs/bbs.cgi?BBS_recent"; # CGI.pmを利用して得たデータをjcode.plで文字コード統一 # デフォルトはsjis $query=new CGI; &jcode'convert($query,'sjis'); # パスの取得 $myInfomation=$ENV{'PATH_INFO'}; $myHost=$ENV{'SERVER_NAME'}; # BBSのパス(自動的に取得) # うまく得られない場合は環境に合わせて設定(例 $myLocation="http://youehost/bbs/bbs.acgi") # オリジナルソース:$myLocation="http://$myHost$myInfomation"; $myLocation="http://www.powerbook.org/rikibon/bbs/bbs.cgi"; # BBSのフォルダ(自動的に取得) # うまく得られない場合は環境に合わせて設定(例 $myFLocation="http://youehost/bbs/") # オリジナルソース:$myFLocation=replaceAll($myLocation,"bbs.cgi",""); $myFLocation=replaceAll($myLocation,"http://www.powerbook.org/rikibon/bbs/bbs.cgi",""); ########################## ここからが CGI 処理の本番 ######################### $http_search_args = $ENV{'QUERY_STRING'}; $http_if_mod = $ENV{'HTTP_IF_MODIFIED_SINCE'};#Conditional GETのチェック if ($http_search_args eq ""){ #### 指定が空の場合--全体のトップページ $myModDateRFC_1123= pickFileModGMT("$top_recent"); $http_if_mod_Str = getDateString($http_if_mod); $myModDateStr=getDateString($myModDateRFC_1123); if ($http_if_mod eq "" or $http_if_mod_Str < $myModDateStr){ print "Status: 200 OK\n"; print "Last-modified: $myModDateRFC_1123\n"; print "content-type: text/html\n\n"; print BBS_top(); }else{ print "Status: 304 Not Modified\n\n"; } }elsif($http_search_args eq $recent_cmd){ #### 会議室全体のリーセント $myModDateRFC_1123= pickFileModGMT("$top_recent"); $http_if_mod_Str = getDateString($http_if_mod); $myModDateStr=getDateString($myModDateRFC_1123); if ($http_if_mod eq "" or $http_if_mod_Str < $myModDateStr){ print "Status: 200 OK\n"; print "Last-modified: $myModDateRFC_1123\n"; print "content-type: text/html\n\n"; print BBS_Recent(); }else{ print "Status: 304 Not Modified\n\n"; } }else{ $myKind=""; if ($http_search_args =~ /r=/){ $myRoom="$'" if ($http_search_args =~ /r=/); $myRoom="$`" if ($myRoom =~ /&/); $myKind="show"; }elsif($http_search_args =~ /rx=/){ $myRoom="$'" if ($http_search_args =~ /rx=/); $myKind="post_new"; } $BBS_param="$'" if ($http_search_args =~ /&/); $BBS_File="$'" if ($BBS_param =~ /_/); $BBS_File="$`" if ($BBS_param =~ /_/); $AD_File="$'" if ($BBS_param =~ /_/); $PickUpExs=getEx($BBS_param); $CheckRO=substr($myRoom,0,2); $myExs=$PickUpExs; if($BBS_param eq "" and $myKind eq "show"){ #### ファイル指定が空の場合--各会議室トップページ $myModDateRFC_1123= pickFileModGMT("./$myRoom/ROOM_recent"); $http_if_mod_Str = getDateString($http_if_mod); $myModDateStr=getDateString($myModDateRFC_1123); if ($http_if_mod eq "" or $http_if_mod_Str < $myModDateStr){ print "Status: 200 OK\n"; print "Last-modified: $myModDateRFC_1123\n"; print "content-type: text/html\n\n"; print ROOM_Top($myRoom); }else{ print "Status: 304 Not Modified\n\n"; } }elsif($BBS_File eq "BBS"){ #### 各発言 if ($CheckRO eq "R_"){ #リードオンリー $myRDPath="$myFLocation$myRoom/$BBS_param"; print "Location: $myRDPath \n\n"; }else{ $myModDateRFC_1123= pickFileModGMT("./$myRoom/$BBS_param"); $http_if_mod_Str = getDateString($http_if_mod); $myModDateStr=getDateString($myModDateRFC_1123); if ($http_if_mod eq "" or $http_if_mod_Str < $myModDateStr){ print "Status: 200 OK\n"; print "Last-modified: $myModDateRFC_1123\n"; print "content-type: text/html\n\n"; print show_page($myRoom,$BBS_param); }else{ print "Status: 304 Not Modified\n\n"; } } }elsif($BBS_param eq "recent"){ #### 各会議室リーセント $myModDateRFC_1123= pickFileModGMT("./$myRoom/ROOM_recent"); $http_if_mod_Str = getDateString($http_if_mod); $myModDateStr=getDateString($myModDateRFC_1123); if ($http_if_mod eq "" or $http_if_mod_Str < $myModDateStr){ print "Status: 200 OK\n"; print "Last-modified: $myModDateRFC_1123\n"; print "content-type: text/html\n\n"; print ROOM_recent($myRoom); }else{ print "Status: 304 Not Modified\n\n"; } }elsif($BBS_param eq "post"){ #### 新規発言 print "content-type: text/html\n\n"; if ($CheckRO eq "R_"){ #リードオンリー my($roomTitle)=pickTitle("./$myRoom/ROOM_header"); $myErrMsg="
"; $myErrMsg.="メッセージを投稿することはできません
"; $myErrMsg.="「$roomTitle」のトップページへ戻る"; print $myErrMsg; }else{ print ROOM_new_page($myRoom) } }elsif($BBS_param =~ /=/){ #### 検索処理 $myRes = room_search($myRoom,$BBS_param); if ($myRes eq "Error"){ print "Location: $myLocation?r=$myRoom \n\n"; }else{ print "content-type: text/html\n\n"; print $myRes; } }elsif($myKind eq "post_new"){ $myPostTitle=$query->param('title'); $myPostName=$query->param('name'); $myPostComment=$query->param('comment'); $myPostRef=$query->param('Ref'); $myPostURL=$query->param('URL'); if ($CheckRO eq "R_"){ #リードオンリー my($roomTitle)=pickTitle("./$myRoom/ROOM_header"); print "content-type: text/html\n\n"; $myErrMsg="
"; $myErrMsg.="メッセージを投稿することはできません
"; $myErrMsg.="「$roomTitle」のトップページへ戻る"; print $myErrMsg; }else{ if ($myPostName eq "" or $myPostTitle eq "" or $myPostComment eq ""){ print "Location: $myLocation?r=$myRoom \n\n"; }else{ $myResult = Post_new_msg($myRoom,$myPostTitle,$myPostName,$myPostComment,$myPostRef,$myPostURL);#投稿 print "Location: $myLocation?r=$myRoom&$myResult \n\n"; } } }elsif($BBS_File eq "ADD"){ ####コメントの追加 $myPostName=$query->param('name'); $myPostComment=$query->param('comt'); $myPostRef=$query->param('Ref'); $myPostURL=$query->param('URL'); $AddRoomName = "$`" if ($http_search_args =~ /&/); $AddRoomName = "$'" if ($AddRoomName =~ /=/); if ($CheckRO eq "R_"){ #リードオンリー my($roomTitle)=pickTitle("./$AddRoomName/ROOM_header"); print "content-type: text/html\n\n"; $myErrMsg="
"; $myErrMsg.="メッセージを投稿することはできません
";
$myErrMsg.="「$roomTitle」のトップページへ戻る";
print $myErrMsg;
}else{
if ($myPostName eq "" or $myPostComment eq ""){
print "Location: $myLocation?r=$AddRoomName&$AD_File \n\n";
}else{
####投稿
$myResult = Add_comment($AddRoomName,$myPostName,$myPostComment,$myPostRef,$myPostURL,$AD_File);
print "Location: $myLocation?r=$AddRoomName&$myResult \n\n";
}
}
}else{
if ($CheckRO eq "R_"){
#リードオンリー
$myRDPath="$myFLocation$myRoom/$BBS_param";
print "Location: $myRDPath \n\n";
}else{
#### デバック用
print "content-type: text/html\n\n";
print "$http_search_args
\n";
print "$myRoom
\n";
print "$BBS_param
\n";
print "$BBS_File
\n";
print "$AD_File
\n";
print "$PickUpExs\n";
}
}
}
####### 以下、処理内容毎に分けられたハンドラー ######
#### コメント追加
sub Add_comment{
my($theRoom,$PostName,$PostComment,$PostRef,$PostURL,$myTfile)=@_;
my($myTtitle)=pickUpRoomName($theRoom);
my($myFtitle)=pickTitle("./$theRoom/$myTfile");
my($cDate)=dateToString();
$cDate=substr($cDate,2,12);
$PostComment=replaceToHTML($PostComment);
$PostComment=replaceToBR($PostComment);
$PostName=replaceToHTML($PostName);
$PostURL=replaceToHTML($PostURL);
$PostRef=replaceToHTML($PostRef);
my($CreDate)=dateToJPString();
my($ShortDate)=dateToJString();
# ページに書き込むデータを作成する
my($myText)="$PostName さんからのコメント
$CreDate
$PostComment"; if ($PostRef ne "" and $PostURL ne "http://" and $PostURL ne ""){ $myText.="\n
→ $PostRef\n"; } $myText.="
";
$WResult=writeAddFile("./$theRoom/$myTfile",$myText);
my($myBBSReacent)="$ShortDate 「$myTtitle」で $PostName さんが
\n
\n";
my($myReacentMessage)="$ShortDate $PostName さんが
\n
\n";
# 保存
open(TEMPFILERR, "<./$theRoom/ROOM_recent") || die "Error.";
my(@myTextRR)= \n";
$myText.=" \n";
$myText.="$PostComment";
if ($PostRef ne "" and $PostURL ne "http://" and $PostURL ne ""){
$myText.="\n \n";
my($myBBSReacent)="$ShortDate 「$myTtitle」で $PostName さんが \n";
my($myReacentMessage)="$ShortDate $PostName さんが \n";
# 保存
$CountArray=0;
$WResult=writeToFile("./$theRoom/$cFileName",$myText);
open(TEMPFILERR, "<./$theRoom/ROOM_recent") || die "Error.";
my(@myTextRR)= \n";
####
#### 配列に一度読み込んでソートしてから表示
push(@farray,$entry);
}
}
@farray = sort @farray;
foreach $value(@farray){
my($Title)=pickUpRoomName($value);
my($msgNum)=countMsgNum($value);
$myText.= " \n";
}
####
$myText.=" \n";
$myText.=readFromFile("$top_recent");
$myText.="\n \n";
$myText.=readFromFile("./$myTdir/ROOM_recent");
$myText.="\n $TopDate ";
$myReturnString.="*** この会議室はリードオンリーです ***以下のメッセージが登録されています $TopDate 最近7日間に投稿/コメントされたものはありません$myFoot";
}else{
$myReturnString = "$myHead $TopDate 最近7日間に投稿/コメントされたメッセージ:$PostTitle
\n";
$myText.="発言者:$PostName
\n";
$myText.="$CreDate→ $PostRef
\n"
}
$myText.="
\n";
$myBBSReacent.="「$PostTitle」 をポストしました
\n";
$myReacentMessage.="「$PostTitle」 をポストしました
以下の会議室が開催されています。
";
#@farray=("room_2","R_room_3","room_1");
opendir( DIR, ".") or die "opendir $path失敗: $!\n";
while($entry =readdir DIR){
my($type)= -d "./$entry" ? "Dir" : "File";
if ($type eq "Dir" and $entry ne "." and $entry ne ".."){
#### 配列に読み込ませないでそのまま処理
#my($Title)=pickUpRoomName($entry);
#my($msgNum)=countMsgNum($entry);
#$myText.= "
";
if (substr($top_recent,0,1) ne "_"){
$myText.="
";
}
$myText.=readFromFile("BBS_footer");
return $myText
}
#### BBS 全体の Recent ページの表示
sub BBS_Recent{
my($myText)=readFromFile("BBS_header");
$myText.="最近の発言状況です
";
$myText.=readFromFile("BBS_footer");
return $myText;
}
#### 各会議室の Recent ページの表示
sub ROOM_recent{
my($myTdir)=@_;
my($myTtitle)=pickUpRoomName($myTdir);
my($myText)=readFromFile("BBS_header");
$myText.="
最近の発言状況です
";
return $myText;
}
#### 各会議室のトップページ
sub ROOM_Top{
my($myTdir)=@_;
my($CheckReadOnly)=substr($myTdir,0,2);
# ヘッダとフッタの読み込み
my($myHead)=readFromFile("./$myTdir/ROOM_header");
my($myFoot)=readFromFile("./$myTdir/ROOM_footer");
if ($CheckReadOnly eq "R_"){# リードオンリーの処理
# 登録されているメッセージの数を調べる
my($myCount)=countMsgNum($myTdir);
my($pickUpMessage)=pickAllMessages($myTdir,"RO");
my($TopDate)=dateToTPString();
my($myReturnString) = "$myHead\n
現在$myCountのメッセージが登録されています
$pickUpMessage
$myFoot";
$myReturnString = replaceAll($myReturnString,"<\@R>",$myTdir);
}else{
my($myCount)=countMsgNum($myTdir);
my($pickUpMessage)=pickMessages($myTdir);
my($TopDate)=dateToTPString();
if ($myCount == 0 ){
$myReturnString = "$myHead現在$myCountのメッセージが登録されています
現在$myCountのメッセージが登録されています
$pickUpMessage
$myFoot";
}
$myReturnString = replaceAll($myReturnString,"<\@R>",$myTdir);
}
}
#### 新規投稿ページ
sub ROOM_new_page{
my($myTdir)=@_;
my($myTtitle) = pickUpRoomName($myTdir);
my($myReturnString) = readFromFile("post_base");
$myReturnString = replaceAll($myReturnString,"<\@RN>",$myTtitle);
$myReturnString = replaceAll($myReturnString,"<\@R>",$myTdir);
return $myReturnString;
}
#### 各ページ表示
sub show_page{
my($theRoom,$theFile)=@_;
my($myTtitle)=pickUpRoomName($theRoom);
my($myReturnString)=readFromFile("./$theRoom/$theFile");
$myReturnString.=readFromFile("coment_base");
$myReturnString.="\n
";
my($myFormTag)="\n