#!/usr/bin/perl #↑サーバーの設定に合わせてね #等幅でみてちょ(笑 (重要) #デザイン崩れてても文句いわないでね(^_^;) ############################################################## # # # readres.cgi ver1.69 by chiba # # <レスを全部読む部分> # # # ############################################################## $cgi="readres.cgi"; $ver="1.69-902"; ######クレジット################################################## # <ベース> # # 2ch-Type BBS 2.1 build 2 Home: http://around.tripod.co.jp/ # # Mail: mono@nihen.on.arena.ne.jp # ################################################################## #gzip圧縮送信を使う(管理CGIとかが真っ白に表示されたらこれを0にしてください) #(1=圧縮する、0=圧縮しない) $gzip=1; #gzip圧縮するときのgzipのパス $gzippath='/bin/gzip'; ###########目次########### #(01)目次 #(02)メインルーチン (本筋) #(03)レスプリント (&resprint) #(04)レスプリント(名前検索 (&nameprint) #(05)エラー処理 (&error) #(06)クッキーの取得 (&get_cookie) ################################################## ############☆(02)メインルーチン☆################ ################################################## #config.cgiの読み込み。 open(CONF,"./config.cgi")|| &error("config.cgiが開けません","no"); @conf=; close(CONF); foreach(@conf){tr/\x0D\x0A//d;} ($sitename,$subtitle,$nanashiname,$delmessage,$resusuu,$suresuu,$menusuu,$sureseigen,$hostrec,$wrescheck,$trescheck,$new,$lockkey,$delcheck,$mailing,$mailto,$sendmail,$ng,$ngword,$namecolor,$capcolor,$sagecolor,$titlecolor,$body,$rogo,$table,$table2,$table3,$table4,$table6,$readresbody,$koukoku,$readtitlebody,$itenmessage,$pass,$htmlpath,$htmlzpath,$cgizpath,$kaigyouseigen,$shouryakuseigen,$countzpath,$rogosita,$version,$imode,$ranking,$ipath,$head,$headsuu,$headbody,$headtable,$jst,$meta)=@conf; $|=1; if($ENV{'HTTP_ACCEPT_ENCODING'}=~/gzip/ && $gzip == 1){ print "Content-type: text/html\n"; print "Content-encoding: gzip\n\n"; open(STDOUT,"| $gzippath -1 -c"); }else{ print "Content-type: text/html\n\n"; } $HEAD=1; # jcode.plのパス require './jcode.pl'; &get_cookie; #クエリー表示・解析 if ($ENV{'REQUEST_METHOD'} eq "POST") {read(STDIN, $query_string, $ENV{'CONTENT_LENGTH'});} else {$query_string = $ENV{'QUERY_STRING'};} @a = split(/&/, $query_string); foreach $a (@a) { ($name, $value) = split(/=/, $a); $value =~ tr/+/ /; $value =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack('H2',$1)/eg; $FORM{$name} = $value; } if($FORM{res}){$FORM{rs}=$FORM{re}=$FORM{res};$FORM{fi}="no";} $logg=$FORM{vi}; $resmiru=$FORM{rm}; $resstart=$FORM{rs}-2; $resend=$FORM{re}-2; $readfirst=$FORM{fi}; $a1stfile="$htmlpath/$FORM{bo}/txt/$FORM{bo}_$FORM{vi}a.txt"; $b1stfile="$htmlpath/$FORM{bo}/txt/$FORM{bo}_$FORM{vi}b.txt"; $article="$FORM{bo} $FORM{vi}"; if ($FORM{rs} == 1){$readfirst="yes";} if($FORM{i} eq "on" && $FORM{rs} eq "" && $FORM{re} eq "" && $FORM{rm} eq ""){$resmiru=4;} open(LOG,$a1stfile) || &error("ログファイルが開けません!","no"); ($date,$name,$sub,$msg,$no,$email,$delmes) = split(/<>/, ); close(LOG); chomp($email); open(BBS,"./board/$FORM{bo}.txt"); ($bbstitle,$setumei,$nanasi,$bodybo,$oekaki,$sureddosuu,$menusureddosuu,$resusuubo,$sureseigenbo,$hostrec,$trescheck,$wrescheck,$rogobo,$tablebo,$table6bo,$table2bo,$table3bo,$table4bo,$koukokubo,$rogositabo,$newbo,$ibo,$nanashiita)=split(/<>/,); close(BBS); open CRYPT,"$htmlpath/$FORM{bo}/crypt.txt"; $boardcry=; close CRYPT; $boardcry=~tr/\n//d; # PC用を表示 if($FORM{i} ne "on"){ print <<"EOF"; $sub $readresbody ■$bbstitleに戻る■  最後のレスまで飛ぶ  レスを全部見る  最新レス100件を見る
$sub EOF if($delcheck ne "no"){ print <<"EOF";
EOF } }else{ # iの表示 print <<"EOF"; $sub 戻る レスを初めから見る
$sub
EOF } if($FORM{name} ne ""){ $fname=$FORM{name}; &jcode'convert(*fname,'euc'); $name2=$name; &jcode'convert(*name2,'euc'); unless($name2=~/$fname/){$dummy="1";} } if ($readfirst ne "no" && $dummy ne "1"){ if ($email ne "") {$name = "$name";} if ($delcheck ne "no" && $delmes !~/del/){$checkbox="\";} else{$checkbox="";} if($FORM{i} ne "on"){ print <<"EOF";
1  $name  $date$checkbox
$msg
EOF }else{ #iモードで番号リンクを省略 #print <<"EOF"; #1\  $name\  $date
#$msg
#EOF print <<"EOF";
1\  $name\  $date
$msg
EOF } } if($FORM{res} ne "1"){ if($FORM{i} eq "on"){$printmode="iprint";} elsif($FORM{name}){$printmode='nameprint';} else{$printmode='resprint';} &$printmode; } if($FORM{i} ne "on"){ if($delcheck ne "no"){ print <<"EOF";
EOF } print <<"EOF";
sage  pre  等幅 書き込み後もこのスレッドに留まる
EOF if($nanashiita ne "nanashi"){ print <<"EOF"; 名前: メール:
EOF } print <<"EOF";
■$bbstitleに戻る■  ページの先頭まで飛ぶ  レスを全部見る  最新レス100件を見る

$cgi ver.$ver
(c)megabbs
(original) EOF }else{ print <<"EOF";
EOF if($nanashiita ne "nanashi"){ print <<"EOF"; 名前: メール:
EOF } print <<"EOF";
stay sage tt
戻る レスを初めから見る EOF } # iでの書き込み欄は上のやつ。 ################################################## ##############☆(03)レスプリント☆################ ################################################## sub resprint { if (open(LOG,$b1stfile)){ while(read LOG, $_, 1024) { $resukazu += tr/\n//; } if($resmiru){$resstart=$resukazu-$resmiru;} if($resstart < 0){$resstart=0;} if($resend < 0){$resend=$resukazu;} seek(LOG,0,0); my($count)=0; while(){ tr/\n//d; if($count >= $resstart && $count <= $resend){ ($dater,$namer,$msg,$nor,$emailr,$delmes) = split /<>/; if($delmes eq "toumeidel"){next;} $printres=$nor; if ($emailr ne "") {$namer = "$namer"} if ($delcheck ne "no" && $delmes ne "del"){$checkbox="\";} else{$checkbox="";} print <<"EOF";
$nor  $namer  $dater$checkbox
$msg
EOF } $count++; } } close(LOG); } ################################################## ############☆(04)レスプリント(名前検索☆######## ################################################## sub nameprint { if (open(LOG,$b1stfile)){ while(read LOG, $_, 1024) { $resukazu += tr/\n//; } if($resmiru){$resstart=$resukazu-$resmiru;} if($resstart < 0){$resstart=0;} if($resend < 0){$resend=$resukazu;} seek(LOG,0,0); my($count)=0; while(){ tr/\n//d; if($count >= $resstart && $count <= $resend){ ($dater,$namer,$msg,$nor,$emailr,$delmes) = split(/<>/,$_); if($delmes eq "toumeidel"){next;} $namer2=$namer; &jcode'convert(*namer2,'euc'); &jcode'convert(*emailr,'euc'); if(index($namer2,$fname) > -1){ $printres=$nor; if ($emailr ne "") {$namer = "$namer"} if ($delcheck ne "no" && $delmes ne "del"){$checkbox="\";} else{$checkbox="";} print <<"EOF";
$nor  $namer  $dater$checkbox
$msg
EOF } } $count++; } } } ################################################## ##############☆(05)iレスプリント☆############### ################################################## sub iprint { $linkcheck=0; if (open(LOG,$b1stfile)){ while(read LOG, $_, 1024) { $resukazu += tr/\n//; } if($resmiru){$resstart=$resukazu-$resmiru;} if($resstart < 0){$resstart=0;} if($resend < 0){$resend=$resukazu;} seek(LOG,0,0); my($count)=0; while(){ tr/\n//d; if($count >= $resstart && $count <= $resend){ ($dater,$namer,$msg,$nor,$emailr,$delmes) = split /<>/; if($delmes eq "toumeidel"){next;} $emailr=~tr/\x0D\x0A//d; $printres=$nor; if ($emailr ne "") {$namer = "$namer"} #iではレス番号リンクは省略 #print <<"EOF"; #$nor\  $namer\  $dater
#$msg
#EOF #$msg の字数を128文字に。(1スレ表示除く) if ($resstart ne $resend) {&manglemessage} print <<"EOF";
$nor\  $namer\  $dater
$msg
EOF } elsif($count > $resend && $resstart > 0){ $btore=$resstart+1; $btors=$btore-3; $tors=$resend+3; $tore=$tors+3; print <<"EOF";
前の5件 次の5件 EOF $linkcheck=1; last; } elsif($count > $resend){ $tors=$resend+3; $tore=$tors+3; print <<"EOF";
次の5件 EOF $linkcheck=1; last; } $count++; } } if($linkcheck ne "1" && $resend > 4){ $btore=$resstart+1; $btors=$btore-3; print <<"EOF";
前の5件 EOF } close(LOG); } ################################################## ###############☆(05)エラー処理☆################# ################################################## sub error { if ($_[1] eq "lock"){foreach $lockfiles (@lockfile){if( -e $lockfiles){ unlink($lockfiles); }}} if (-e $tmpfile) { unlink($tmpfile); } if ($HEAD eq "") { print "Content-type: text/html\n\n";} print <<"_EOF_";
エラー
$_[0]
_EOF_ exit; } ################################################## #############☆(06)クッキーの取得☆############### ################################################## sub get_cookie { local($xx, $name, $value); for $xx (split(/; */, $ENV{'HTTP_COOKIE'})) { ($name, $value) = split(/=/, $xx); $COOKIE{$name} = $value; } } ################################################## #############☆(07)iモードでの省略表示############ ################################################## sub manglemessage { my $taihi = $_; my $maxmoji = 256; # 省略表示になる最大文字数です。 my $urlcut = 0; $_ = $msg; # 字数オーバーならURLをカット if (length($msg) > $maxmoji){ $urlcut = s/(.*?)<\/a>/$1/g; } $msg = substr $_,0,$maxmoji; # それでもオーバーしてると、ここで切られます $msg .= "\x20"; if (length ($_) >$maxmoji){$msg .= '[略'. (length($_) - $maxmoji) . ']'} elsif ($urlcut) { $msg .= '
[URL]'} $_ = $taihi; } ######################################################### ####################------終了-------#################### ######################################################### exit;