#!/usr/local/bin/perl #------------------------------------------------------------------------------------------------------------------ # logbbs.cgi Ver 1.06 # an-donut 2003/05/16 #------------------------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------------------------ # logbbs.cgiの設定 #------------------------------------------------------------------------------------------------------------------ $amezo = 'Donut Shoppe'; #掲示板名称 $urlbase = 'http://www.an-donut.com/'; #掲示板のURL $cgi = "logbbs.cgi"; #このcgiの名前 $amezocgi = 'amezo.cgi'; #amezo.cgiの名前 $chatcgi = 'chat.cgi'; #chat.cgiの名前 $icgi = 'i.cgi'; #i.cgiの名前 $blisturl = 'blist.txt'; #blist.txtの名前 $delresurl = 'delres.cgi'; #delres.cgiの名前 $logbbsfile = 'logbbs.dat'; #loglist.dat(logbbsモード設定ファイル) $cgipath = '../'; #掲示板から見たCGIが在るフォルダ(相対パスで) $bbspath = './'; #このCGIから見た掲示板フォルダの在るフォルダ(相対パスで) $icon_on = 1; #一つ以上の板でアイコンを使う(1=yes,0=no) $upload_on = 1; #一つ以上の板でアップロード機能を使う(1=yes,0=no) $upfilesize = '300'; #アップできるファイルの最大サイズ(キロバイト数) $rows = 4; #内容欄の行数 $logbbs_bgcolor = '#f7f8ff'; #掲示板の背景色 $logbbs_title_color = '#ffa500'; #掲示板タイトル色 $logbbs_title_font_size = '5'; #掲示板タイトルのフォントサイズ $logbbs_text_color = '#224455'; #掲示板のテキスト色 $logbbs_kores_color = '#9999FF'; #一言レスのテキスト色 #------------------------------------------------------------------------------------------------------------------ # フォームでコード #------------------------------------------------------------------------------------------------------------------ if ($ENV{PATH_INFO}) { my $p = undef; (undef,$dir,$res,$p) = split '/',$ENV{PATH_INFO}; $dir =~ tr/-_.!~'()a-zA-Z0-9+//cd; foreach ($p) { /-/ and do { ($st,$to) = $p =~ /(\d+)?-(\d+)?/; $st||=1; $to||=100000; last }; /^next/ and do { ($next) = $p =~ /(\d+)/; last }; /^r/ and do { ($re) = $p =~ /(\d+)/; last }; /^k/ and do { ($ko) = $p =~ /(\d+)/; last }; ($at) = $p =~ /(\d+)/; } } else { 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; $FORM{$name} = $value; } $res = $FORM{'res'}; $dir = $FORM{'dir'}; $next = $FORM{'next'}; $st = $FORM{'st'}; $to = $FORM{'to'}; $at = $FORM{'at'}; $re = $FORM{'re'}; $ko = $FORM{'ko'}; } #------------------------------------------------------------------------------------------------------------------ # メインスタート #------------------------------------------------------------------------------------------------------------------ $ls && &lson; $st && &ston; $at && &aton; $re && &reon; $ko && &koresu; $res && &logbbs; $dir && &jumpdir; #####logbbs.cgi/の時(logbbs.cgiの内容表示) print "Content-type: text/plain\n\n"; open(R, "$cgi"); print while ; close(R); exit; #####logbbs.cgi/$dir/の時($dir/index.htmlへの移動) sub jumpdir { print "Content-type: text/html; charset=Shift_JIS\n\n"; print < jump to bbs EOM exit; } #####logbbs.cgi/$dir/$res/の時(積み上げ式掲示板としての表示) sub logbbs { open(IN, "$bbspath$dir/$res.html") || &error('スレッドが見つかりません.'); $fast = ; while(read IN, $unko, 1024) { $resukazu += ($unko =~ tr/\n//); } seek (IN,0,0); $fast =~ /(.+)<\/title>/; $thtitle = $1; $fast =~ /<dd>(.+)<\/dl>/; $thsubtitle = $1; $thsubtitle =~ s/<table><tr><td><img(.*)\"><\/td><td>//; $thsubtitle =~ s/<font color="#000000">//; $thsubtitle =~ s/<\/font><\/td><\/tr><\/table>//; $thsubtitle =~ s/<BR><img(.*)\">//; $thsubtitle =~ s/<BR><IFRAME(.*)<\/IFRAME>//; $thsubtitle =~ s/<BR>画像(.*)KB\)//; $thsubtitle =~ s/<BR>ファイル(.*)KB\)//; $thsubtitle =~ s/<!-- ko -->(.*)<!-- ko_end --><\/dl>//; if($thsubtitle =~ /<form (.*)<\/form>/){$delpass =1;} $thsubtitle =~ s/<form (.*)<\/form>//; ($heoka, $keji) = split /<\/td><td><\/td><\/tr><\/table>/, $fast;#記事取得 if($delpass == 1){&settei;} if($logbbs_title_image){ $bbstitle = "<image src=\"$logbbs_title_image\">"; }else{ $bbstitle = "<font size=\"$logbbs_title_font_size\" color=\"$logbbs_title_color\"><b>$thtitle </b></font>"; } &jyunbi; #上部表示 print "Content-type: text/html; charset=Shift_JIS\n\n"; print <<EOM; <html><head> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <title>$thtitle<\/title> <body bgcolor="$logbbs_bgcolor" text="$logbbs_text_color"$logbbs_background$logbbs_link_color$logbbs_alink_color$logbbs_vlink_color> <div align="center">$bbstitle<br><br>$thsubtitle<br><br> <table width="100%"><tr> <td align="left" valign="top">   </td> <td align="center" valign="top"><font size="-1"> [ <a href="../../../">$amezo</a> ] [ <a href="../../../$dir/index.html">$title @ $amezo</a> ] [ <a href="../../$cgipath$chatcgi/$dir/$res/">Log chat</a> ] [ <a href="../../$cgipath$cgi/$dir/$res/">LogBBS Top</a> ] </font></td> <td align="right" valign="top"><font size="-1"><A href="../../$cgipath$cgi/$dir/$res/">Reload</A></font><BR>  </td> </tr></table> <font size="-1"> <a href="http://www.amazon.co.jp/b?%5Fencoding=UTF8&site-redirect=&node=3210981&tag=donutshoppe-22&linkCode=ur2&camp=247&creative=1211">大手量販店に負けない安さを追求 Amazon「エレクトロニクス」ストア</a><img src="http://www.assoc-amazon.jp/e/ir?t=donutshoppe-22&l=ur2&o=9" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> </font> </div><br><HR> <form method=post action="../../$cgipath$amezocgi"$imecolu> <table border="0" cellpadding="0" cellspacing="2"> <tr><td> <div align="right">投稿者 </div> </td><td> <input type=text name="name" size=20> </td></tr> <tr><td> <div align="right">メール </div> </td><td> <input type=text name="mail" size=30> </td></tr>$iconsyori</table> <table border="0" cellpadding="0" cellspacing="2"> <tr><td><br><div align="left">内容<font size="3"><i>(自動改行します。<a href="http://www.an-donut.com/info03.html#2" target=_blank>利用可能\タグ一覧</a>)</i></font></div> <textarea name="comm" rows=5 cols=82 ></textarea> </td></tr>$imecolu2 <tr><td><br> <input type=submit value=" 投稿 " name="submit" ><input type=reset value="消す"> <input type=hidden name="res" value="$res"><input type=hidden name=\"folder\" value=$dir><input type=hidden name=\"logbbs\" value=$res> </td></tr></table> </form><dl> <font size="-1">[<a href="../../$cgipath$icgi?dir=$dir&log=$res">i-mode/J-sky/EZweb対応</a>]</font> <hr> <font size=-1><i>新しい記事から表\示します。最高$maxrescnt件の記事が記録され、それを超えると書き込みできなくなります。<br> 1回の表\示で10件を越える場合は、下のボタンを押すことで次の画面の記事を表\示します。</i></font> <hr> EOM #ログ表示 foreach (reverse <IN>) { if($ii and $ii > $next){ $ii eq $resukazu and $_ = $keji; s/<dl>//; s/<a href="$cgipath/<a href="..\/..\/$cgipath/g; s/res.cgi/logbbs.cgi/g; #s/<dt>(\d+) 投稿者/<dt>投稿者/; s/style="background:black ;text:black;"/style="background:$logbbs_text_color ;text:$logbbs_text_color;"/g; s/<font color=white>/<font color=$logbbs_bgcolor>/g; s/<font color="#000000">/<font color="$logbbs_text_color">/g; s/<!-- ko --><dl><dd>/<br>/; s/<br><font color="(.*?)">/<br><font color="$logbbs_kores_color">/g; s/<!-- ko_end --><\/dl>//; s/<dd>/<dd><br>/; s/<form (.*)<\/form>//; print "$_<dl><HR>"; $ii > ($next + 9) and last; } $ii++; } close(IN); #次(前)のページへのリンク $nextlink1 = $next + 1; $next = $next + 10; if($next > 11){#前のぺーじ $nextb = $next - 20; $nextlink5 = "<form method\=post action\=\"../../$cgipath$cgi/$dir/$res/next$nextb\"><input type\=submit value\=\"前のページ\" name\=\"submit\" ></form>\n"; } if($resukazu > $next){#次のページ $nextlink2 = "$next"; $nextlink4 = "<form method\=post action\=\"../../$cgipath$cgi/$dir/$res/next$next\"><input type\=submit value\=\"次のページ\" name\=\"submit\" ></form>\n"; }else{ $nextlink2 = "$resukazu"; $nextlink3 = " これ以下の記事はありません。"; } if($resukazu =~ /1$/ && $resukazu < $next){ $nextlink6 = "$resukazu番目"; }else{ $nextlink6 = "$nextlink1番目から$nextlink2番目まで"; } print <<EOM; <font size=-1><i>以上は、新着順$nextlink6の記事です。 $nextlink3</i></font><br><br> <div align="center"> <iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=donutshoppe-22&o=9&p=13&l=ur1&category=amazongeneral&banner=1DMBQ816JJSP1D9P7802&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe><br><br> <font size="-1"> [ <a href="http://www.amazon.co.jp/b?%5Fencoding=UTF8&site-redirect=&node=561958&tag=donutshoppe-22&linkCode=ur2&camp=247&creative=1211">Amazon ベストセラーDVD</a><img src="http://www.assoc-amazon.jp/e/ir?t=donutshoppe-22&l=ur2&o=9" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> ] [ <a href="http://www.amazon.co.jp/b?%5Fencoding=UTF8&site-redirect=&node=202765011&tag=donutshoppe-22&linkCode=ur2&camp=247&creative=1211">Amazon ベストセラーミュージック</a><img src="http://www.assoc-amazon.jp/e/ir?t=donutshoppe-22&l=ur2&o=9" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> ] [ <a href="http://www.amazon.co.jp/b?%5Fencoding=UTF8&site-redirect=&node=202188011&tag=donutshoppe-22&linkCode=ur2&camp=247&creative=1211"> Amazon ベストセラー本</a><img src="http://www.assoc-amazon.jp/e/ir?t=donutshoppe-22&l=ur2&o=9" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> ] </font> </div> $nextlink4 $nextlink5$logbbs_hp_url EOM if($delpass == 1){ $delmode = "<form method=post action=../../$cgipath$delresurl>パスワード <input type=text name=pass size=10> <input type=submit value='管理者メニュー'><input type=hidden name='dir' value=$dir><input type=hidden name='res' value=$res><input type=hidden name=\"logbbs\" value=yes><\/form>"; } #下部表示 print <<EOM; <div align="center"><font size="-1"> [ <a href="../../../">$amezo</a> ] [ <a href="../../../$dir/index.html">$title @ $amezo</a> ] [ <a href="../../$cgipath$chatcgi/$dir/$res/">Log chat</a> ] [ <a href="../../$cgipath$cgi/$dir/$res/">LogBBS Top</a> ] </font></div> <hr size=3>$delmode$logbbs_mailto<div align="right"><i><b><a href=\"http://www.an-donut.com/index.html\" target=\"_blank\">Donut Shoppe</a></b></i></div> </body></html> EOM exit; } #####logbbs.cgi/$dir/$res/$reの時(返信時の表示) sub reon { open(R, "$bbspath$dir/$res.html") || &error('スレッドが見つかりません.'); print "Content-type: text/html; charset=Shift_JIS\n\n"; $rows = 20; foreach (<R>) { $i++; if($re eq $i){ s/<a href="$cgipath/<a href="..\/..\/$cgipath/g; s/res.cgi/logbbs.cgi/g; #s/<dt>(\d+) 投稿者/<dt>投稿者/; if($re eq 1){ s/<table(.*) <\/font><\/td><td><\/td><\/tr><\/table>//; s/<form (.*)<\/form>//; print; /<dd>(.+)<\/dl>/; $recom = ">$1"; $recom =~ s/<BR><img(.*)\">//; $recom =~ s/<BR><IFRAME(.*)\<\/IFRAME>//; $recom =~ s/<BR>画像(.*)KB\)//; $recom =~ s/<BR>ファイル(.*)KB\)//; $recom =~ s/<!-- ko --><dl><dd>(.*)<!-- ko_end --><\/dl>//; #$recom =~ s/<form (.*)<\/form>//; if ($recom =~ "<table>"){ $recom =~ m/<\/td><td>(.+)<\/td><\/tr>/; $recom = ">$1"; $recom =~ s/<font color=\"#000000\">//; } $recom =~ s/<br>/\n/g; $recom =~ s/\n(?!$)/\n>/g; $recom =~ s/<a(.+?)>(.+?)<\/a>/$2/g; $recom =~ s/<img(.*)\">/はあとはあと/g; &saigo; } print; /<dd>(.+)<\/dl>/; $recom = ">$1"; $recom =~ s/<BR><img(.*)\">//; $recom =~ s/<BR><IFRAME(.*)\<\/IFRAME>//; $recom =~ s/<BR>画像(.*)KB\)//; $recom =~ s/<BR>ファイル(.*)KB\)//; $recom =~ s/<!-- ko --><dl><dd>(.*)<!-- ko_end --><\/dl>//; if ($recom =~ "<table>"){ $recom =~ m/<\/td><td>(.+)<\/td><\/tr>/; $recom = ">$1"; $recom =~ s/<font color=\"#000000\">//; } $recom =~ s/<br>/\n/g; $recom =~ s/\n(?!$)/\n>/g; $recom =~ s/<a(.+?)>(.+?)<\/a>/$2/g; $recom =~ s/<img(.*)\">/はあとはあと/g; &saigo; } if ($i eq 1){ /(.+)<table(.+)<\/td><td><\/td><\/tr><\/table>(.+)/; print $1; } } exit; } #####logbbs.cgi/$dir/$res/$atの時(レス"$at"の表示) sub aton { open(R, "$bbspath$dir/$res.html") || &error('スレッドが見つかりません.'); print "Content-type: text/html; charset=Shift_JIS\n\n"; foreach (<R>) { $i++; if($at eq $i){ s/<a href="$cgipath/<a href="..\/..\/$cgipath/g; s/res.cgi/logbbs.cgi/g; if($at eq 1){ s/<table(.*) <\/font><\/td><td><\/td><\/tr><\/table>//; s/<form (.*)<\/form>//; } print; } if ($i eq 1){ /(.+)<table(.+)<\/td><td><\/td><\/tr><\/table>(.+)/; print $1; } } exit; } #####logbbs.cgi/$dir/$res/$st-$toの時("$st"番目から"$to"番目のレスを表示) sub ston { open(R, "$bbspath$dir/$res.html") || &error('スレッドが見つかりません.'); while(read R, $unko, 1024) { $resukazu += ($unko =~ tr/\n//); } seek (R,0,0); print "Content-type: text/html; charset=Shift_JIS\n\n"; foreach (<R>) { $i++; s/<a href="$cgipath/<a href="..\/..\/$cgipath/g; s/res.cgi/logbbs.cgi/g; if($st == 1){ $i eq 1 && &saisyo; } else { $i eq 1 && &saisyo2; } $resukazu eq $i && &saigo3; $st <= $i && print; $to <= $i && &saigo3; } close(R); exit; } #####logbbs.cgi/$dir/$res/$koの時(一言レス時の表示) sub koresu { open(R, "$bbspath$dir/$res.html") || &error('スレッドが見つかりません.'); print "Content-type: text/html; charset=Shift_JIS\n\n"; foreach (<R>) { $i++; if($ko eq $i){ s/<a href="$cgipath/<a href="..\/..\/$cgipath/g; s/res.cgi/logbbs.cgi/g; #s/<dt>(\d+) 投稿者/<dt>投稿者/; if($ko eq 1){ s/<table(.*) <\/font><\/td><td><\/td><\/tr><\/table>//; s/<form (.*)<\/form>//; print; &saigo2; } print; &saigo2; } if ($i eq 1){ /(.+)<table(.+)<\/td><td><\/td><\/tr><\/table>(.+)/; print $1; } } exit; } #####レス1の修正(タイトルテーブルの削除) sub saisyo { s/<table(.*) <\/font><\/td><td><\/td><\/tr><\/table>//; s/<form (.*)<\/form>//; print; next; } #####レス1の修正2(レス1の削除) sub saisyo2 { s/<table(.*)<\/dl>//; print; next; } #####最後の投稿フォーム sub saigo { &jyunbi; print <<EOM; <form method=post action="../../$cgipath$amezocgi"$imecolu> <table border="0" cellpadding="0" cellspacing="2"> <tr><td> <div align="right"><input type=hidden name="res" value="$res">投稿者 </div> </td><td> <input type=text name="name" size=30> </td></tr> <tr><td> <div align="right">メール </div> </td><td> <input type=text name="mail" size=30> </td></tr>$iconsyori <tr><td valign="top"><div align="right">内容</div></td> <td><textarea name="comm" rows=$rows cols=50 >$recom</textarea> </td></tr>$imecolu3 <tr><td></td><td> <input type=submit value="投稿する" name="submit" > <a href="../../$cgipath$cgi/$dir/$res/">掲示板に戻る</a> <a href="#top">上へ</a> </td></tr></table> <input type=hidden name=\"folder\" value=$dir><input type=hidden name=\"logbbs\" value=$res> </form></html> EOM last; } #####最後の投稿フォームその2(一言レス時の投稿フォーム) sub saigo2 { print <<EOM; <form method=post action="../../$cgipath$amezocgi"><input type=submit value="ヽ(´▽`)/"> <input type=text size=60 maxlength=80 name=comm><input type=hidden name=res value="$res.$ko"><input type=hidden name="folder" value="$dir"><input type=hidden name=\"logbbs\" value=$res> </form></html> EOM last; } #####最後の投稿フォームその3(投稿フォームの非表示) sub saigo3 { print <<EOM; </html> EOM last; } #####投稿フォーム用設定 sub jyunbi { open(R, "$blisturl"); while(<R>){ chop; ($fol, $color, $title, $subtitle, $pass, $logo, $maxrescnt, $threadcnt, $pagethread, $logmax, $bbsdefname, $iconchek, $imecolumn, $idchek) = split(/,/); last if $fol eq $dir; } close(R); #アイコン欄処理 $icon_on_name ="$bbspath$dir/icon.cgi"; if($iconchek eq '1' && $icon_on eq '1' && -e "$icon_on_name"){ require "$icon_on_name"; &iconselect; $iconsyori = "<tr><td><div align=\"right\">アイコン<\/div><\/td><td>$iselect <a href=\"../../../$dir/iconlist\.html\" target=\"\_blank\">アイコンリスト<\/a><\/td><\/tr>"; }else{ $iconsyori = ''; } #画像URL欄&ファイル欄処理 if($imecolumn eq '1'){ $imecolu = ''; $imecolu2 = "<tr><td><br><div align=\"left\">画像URL<font size=\"2\">(表\示したい画像がある場合はここに記入します)</font></div><input type=text name=\"img\" size=70 value=\"http://\"></td></tr>"; $imecolu3 = "<tr><td><div align\=\"right\">画像URL</div></td><td><input type=text name=\"img\" size=71 value=\"http://\"></td></tr>"; }elsif($imecolumn eq '2'){ if($upload_on eq '1'){ $imecolu = " enctype\=\"multipart\/form\-data\""; $imecolu2 = "<tr><td><br><div align=\"left\">ファイル<font size=\"2\">(アップしたいファイルがある場合はここに記入します。$upfilesize\KBまで)</font></div><input type=file name=\"file\" size=70></td></tr>"; $imecolu3 = "<tr><td><div align=\"right\">ファイル </div></td><td><input type=file name=\"file\" size=60></td></tr>"; }else{ $imecolu = ''; $imecolu2 = ''; $imecolu3 = ''; } }else{ $imecolu = ''; $imecolu2 = ''; $imecolu3 = ''; } } #####設定取得 sub settei { open(R, "$bbspath$dir/$logbbsfile"); while(<R>){ chop; ($bbsres, $pass, $bg, $bground, $text, $link, $alink, $vlink, $kores, $title, $titlesize, $titleimg, $hpurl, $mailto) = split(/,/); last if $bbsres eq $res; } close(R); $logbbs_bgcolor = "$bg" if $bg; $logbbs_background = " background=\"$bground\"" if $bground; $logbbs_text_color = "$text" if $text; $logbbs_link_color = " link=\"$link\"" if $link; $logbbs_alink_color = " alink=\"$alink\"" if $alink; $logbbs_vlink_color = " vlink=\"$vlink\"" if $vlink; $logbbs_title_color = "$title" if $title; $logbbs_title_font_size = "$titlesize" if $titlesize; $logbbs_hp_url = "<form action=\"$hpurl\" target=\"_top\" onSubmit=\"top.location.href=this.action\; return false\"><input type=submit value=\"ホームページへ\"></form>" if $hpurl; $logbbs_mailto = "<br>管理者:<a href=\"mailto:$mailto\">$mailto</a>" if $mailto; $logbbs_title_image = "$titleimg" if $titleimg; $logbbs_kores_color = "$kores" if $kores; } #####エラー表示 sub error { print "Content-type: text/html\n\n<html><body><h2>$_[0]</h2></body></html>"; exit; }