#!/usr/bin/perl #┌───────────────────────────────── #│ [ YY-BOARD ] #│ yybbs.cgi - 2007/09/17 #│ Copyright (c) KentWeb #│ webmaster@kent-web.com #│ http://www.kent-web.com/ #│ #│ YY-BOARD Antispam Version Modified by isso. #│ http://swanbay-web.hp.infoseek.co.jp/index.html #└───────────────────────────────── # 外部ファイル取込 require './init.cgi'; require $jcode; #------------------------------------------------- # 設定チェック #------------------------------------------------- if(!$writevalue || !$postvalue) { &error("init.cgiファイルが正しく転送されていないか設定値が正しくありません。"); } if($writevalue eq $postvalue) { &error("\$writevalueと\$postvalueの文字は同じにしないでください"); } # データ用ディレクトリ unless(-d "./data/") { mkdir ("./data/", 0707) || die "ディレクトリを作成できません : $!"; } # ログファイル unless(-e "$logfile") { &error("ログファイル $logfile がありません。"); } # 過去ログデータファイル if($pastkey) { unless(-e "$nofile") { &error("過去ログデータファイル $nofile がありません。"); } } # カウンターデータファイル unless(-e "$cntfile") { &error("カウンターデータファイル $cntfile がありません。"); } # Webmail認証用ディレクトリ if($webmail){ unless(-d "$mailchk") { mkdir ($mailchk, 0707) || die "ディレクトリを作成できません : $!"; } # ディレクトリ内を掃除 opendir DIR, $mailchk; my @files = grep { !m/^(\.|\.\.|$sendmaillog)$/g } readdir DIR; close DIR; foreach (@files) { my $wt = (stat "$mailchk$_")[9]; if (time - $wt > $maxtime) { unlink ("$mailchk$_"); } } } # カラーデータファイル if($boardmode) { unless(-e "$colorfile") { open(OUT,">>$colorfile"); print OUT "0"; close(OUT); } unless(-e "$colordata") { &error("カラーデータファイル $colordata がありません。"); } } # 表示モード設定 if ($boardmode && -s "$colordata") { &read_color; } # 投稿キー暗号用パスワードチェック if ($regist_key) { if (!$pcp_passwd) { &error("投稿キー暗号用パスワード \$pcp_passwd が設定されていません。"); } } #------------------------------------------------- # メイン処理 #------------------------------------------------- &agent; &decode; &axsCheck; # 自動閉鎖 if ($clday) { my $last = (stat $logfile)[9]; if (abs(time - $last) > $clday*24*3600) { &header; &pseudo; &autoclose; } } if ($mode eq "find") { &find; } elsif ($mode eq "image") { ℑ } elsif ($mode eq "form") { require $formpl; &postform; } elsif ($mode eq "past") { require $pastlogpl; &past_log; } elsif ($mode eq "howto") { require $howtopl; &howto; } elsif ($mode eq "check") { require $checkpl; ✓ } elsif ($mode eq "noscript") { require $howtopl; &noscript; } elsif ($mode eq "writemail") { require $webmailpl; &writemail; } elsif ($mode eq "sendmail") { require $webmailpl; &sendmail; } elsif ($mode eq "postform") { require $formpl; &postform; } elsif ($mode eq "wana") { &wana; } # 携帯対応改造 elsif ($keitai ne 'p' && $mode eq "knew") { &k_new; } elsif ($keitai ne 'p' && $mode eq "klist") { &k_list; } elsif ($keitai ne 'p' && $mode eq "klview") { &k_view; } elsif ($keitai ne 'p' && $mode eq "kaview") { &k_msg; } elsif ($keitai ne 'p' && $mode eq "kmsgview") { &k_msg; } elsif ($keitai ne 'p' && $mode eq "k_admin") { &k_new; } elsif ($keitai ne 'p' && $mode eq "newpost") { &k_form; } elsif ($keitai ne 'p' && $mode eq "admin" && $in{'no'}) { &k_dele; } &log_view; #------------------------------------------------- # 記事表示部 #------------------------------------------------- sub log_view { # 携帯モード if (-e "$kscript" && $keitai ne 'p') { &k_list; } # ページ繰越 local($resfm); foreach ( keys(%in) ) { if (/^page_(\d+)$/) { $page = $1; } if (/^res_(\d+)$/) { $resfm = $1; last; } } # 返信フォーム押下 if ($resfm) { &res_form; } # クッキー取得 local($cnam,$ceml,$curl,$cpwd,$cico,$ccol,$csmail,$caikotoba,$cref) = &get_cookie; &set_cookie($cnam,$ceml,$curl,$cpwd,$cico,$ccol,$csmail,$caikotoba,$cref); # ヘッダを出力 if ($ImageView == 1) { &header('ImageUp'); } else { &header; } # カウンタ処理 if ($counter) { &counter; } # ダミー &pseudo; # 投稿キー local($str_plain,$str_crypt); if ($regist_key) { require $regkeypl; ($str_plain,$str_crypt) = &pcp_makekey; } # タイトル部 print qq|
\n|; if ($banner1 ne "") { print "$banner1

\n"; } if ($t_img eq '') { print qq|$title\n|; } else { print qq|$title\n|; } # 表示ヘッダ print qq|$header
\n|; # スパムログチェック if (-s $spamlogfile) { open(IN,"<$spamlogfile"); eval { flock(IN, 2); }; my @spmlog = ; close(IN); if ($#spmlog >= $spamlog_max) { print qq|
\n
\n|; print qq||; print qq|$postmodeログが許容数を超えました。管理モードから$postmodeログを削除して下さい。|; print qq|
\n
\n|; } } # 表示初期設定 if (!$in{'list'}) { $in{'list'} = $list_ini; } # メニュー部 if ($boardmode) { if (!defined($list_type{$in{'list'}})) { if (defined($list_type{$view_type})) { $in{'list'} = $view_type; } else { $in{'list'} = 'thread'; } } print qq|\n|; if ($in{'action'} eq "past") { print qq|\n\n\n|; } else { print qq|\n|; print qq|\n\n\n|; } # 投稿フォームリンク if (($referercheck && !$ENV{'HTTP_REFERER'}) || !$postform) { if ($in{'list'} ne "pickup") { print qq|\n\n\n|; } } foreach ( 'thread', 'tree', 'topic', 'new' ) { next if ($in{'list'} eq $_); print qq|\n\n\n|; } print qq|\n\n\n|; print qq|\n\n\n|; print qq|\n\n\n| if ($pastkey); print qq|\n\n\n|; print qq|
\n|; print qq|\n
\n|; print qq|\n
\n|; print qq|\n|; print qq|\n|; print qq|\n
\n|; print qq|\n|; print qq|\n
\n|; print qq|\n|; print qq|\n|; print qq|\n
\n|; print qq|\n|; print qq|\n|; print qq|\n
\n|; print qq|\n|; print qq|\n|; print qq|\n
\n|; print qq|\n|; print qq|\n
\n|; print qq|

\n
\n|; } else { print qq|
\n|; print qq|[ホームに戻る]\n|; # 投稿フォームリンク if (($referercheck && !$ENV{'HTTP_REFERER'}) || !$postform) { if ($in{'list'} ne "pickup") { print qq|[新規投稿]\n|; } } if (!defined($list_type{$in{'list'}})) { if (defined($list_type{$view_type})) { $in{'list'} = $view_type; } else { $in{'list'} = 'thread'; } } if ($in{'list'} ne "thread") { print qq|[新規投稿]\n|; } foreach ( 'thread', 'tree', 'topic', 'new' ) { next if ($in{'list'} eq $_); print qq|[$list_type{$_}]\n|; } print <留意事項] [ワード検索] EOM # 過去ログのリンク部を表示 if ($pastkey) { print qq|[過去ログ]\n|; } print <管理用]
EOM } # タイトル一覧表示 if (-s $logfile) { if ($alltitle) { if ($in{'list'} eq 'thread' || $in{'list'} eq 'new') { &SubjectList; } } } # 投稿フォーム if ($in{'list'} eq 'thread' || $in{'list'} eq 'new') { if ($postform) { if ($adminchk && $nam eq $a_name) { $nam = $admin_id; } print qq|
\n|; print qq|
\n|; print qq|\n|; print < // --> EOM if ($allowmode) { print qq|\n\n\n\n
\n|; print qq| 投稿内容は管理者が許可するまで表\示されません。 |; print qq|
\n
\n|; } if (!$re_box) { $cref = 0; } require $formpl; if (!$referercheck || $ENV{'HTTP_REFERER'}) { &form($cnam,$ceml,$curl,$cpwd,$cico,$ccol,'',$inputform,$csmail,$caikotoba,$cref); print qq|\n
\n|; } else { print qq|\n
\n
\n|; print qq|
\n|; print qq|\n|; print qq|
\n

\n|; } } print qq|
\n
\n|; } # 新着順表示 if ($in{'list'} eq "new") { require $newsortpl; &newsort; } # 関連記事表示 elsif ($in{'list'} eq "pickup") { require $pickuppl; &pickup; } else { # 件数チェック if ($pglog{$in{'list'}} <= 0) { $pglog{$in{'list'}} = 10; } # 記事を展開 my $i = 0; open(IN,"$logfile") || &error("Open Error: $logfile"); my $top = ; while () { my ($no,$reno,$dat,$nam,$eml,$sub,$com,$url,$hos,$pw,$col,$ico,$tm,$sml) = split(/<>/); if ($reno eq "") { $i++; } if ($i < $page + 1) { next; } if ($i > $page + $pglog{$in{'list'}}) { next; } # 親記事 if (!$reno) { push(@view,$no); # レス記事 } else { $res{$reno} .= "$no,"; } # 題名の長さ if (length($sub) > $sub_len*2) { $sub = substr($sub, 0, $sub_len*2) . "..."; } $author = $nam; require $messagepl; $nam = &emailscript($nam,$no,$eml,$sml,$col); $author{$no} = $author; $no{$no} = $no; $re{$no} = $reno; $nam{$no} = $nam; $eml{$no} = $eml; $sub{$no} = $sub; $dat{$no} = $dat; $com{$no} = $com; $col{$no} = $col; $url{$no} = $url; $ico{$no} = $ico; $pw{$no} = $pw; $tm{$no} = $tm; $sml{$no} = $sml; } close(IN); # 記事表示 if ($in{'list'} eq "tree") { require $list_log_tree; &list_log_tree; } elsif ($in{'list'} eq "topic") { require $list_log_topic; &list_log_topic; } else { require $list_log_thread; &list_log_thread; } # ページ移動ボタン表示 if ($page - $pglog{$in{'list'}} >= 0 || $page + $pglog{$in{'list'}} < $i) { print qq|

\n|; print qq|
Page:\n|; &mvbtn("$bbscgi?page=", $i, $pglog{$in{'list'}}); print qq|
\n|; } print qq|

\n|; } # ユーザメンテフォーム(トピック表示以外) if ($in{'list'} ne "topic" && $mode ne "past" && $in{'action'} ne "past") { if ($boardmode) { print qq|\n\n\n
\n|; } print qq|
\n|; print qq|\n|; print qq|投稿者\n|; print qq|No.\n|; print qq|削除キー\n|; print qq||; if ($boardmode) { print qq|
\n\n|; } } # 著作権表示(削除不可) print < - YY-BOARD EOM # --------------------------------ここから-------------------------------- # MakiMakiさんの画像を使用しない場合に限り、下記MakiMakiさんのリンクを外すことは可能です。 print qq| - icon:MakiMaki
- |; # --------------------------------ここまで-------------------------------- # 著作権表示(削除不可) print <Antispam Version -

$footer
EOM exit; } #------------------------------------------------- # 返信フォーム #------------------------------------------------- sub res_form { # 投稿キー local($str_plain,$str_crypt); if ($regist_key) { require $regkeypl; ($str_plain,$str_crypt) = &pcp_makekey; } $in{'no'} = $resfm; # クッキーを取得 local($cnam,$ceml,$curl,$cpwd,$cico,$ccol,$csmail,$caikotoba,$cref) = &get_cookie; # 元記事引用 my $refcom = ''; my $resub = ''; open(REF,"$logfile") || &error("Open Error: $logfile"); my $tp = ; while () { chomp; my ($n,$r,$d,$na,$em,$sb,$c) = split(/<>/); if ($in{'refnum'} eq $n) { $resub = $sb; if ($in{'refmode'} eq "on") { $refcom = $c; last; } } } close(REF); # ログを読み込み my $flg; open(IN,"$logfile") || &error("Open Error: $logfile"); my $top = ; # ヘッダを出力 if ($ImageView == 1) { &header('ImageUp'); } else { &header; } # 関連記事出力 print < ▽以下は記事No.$in{'no'} に関する返信フォームです。
EOM print "

\n"; print "

\n"; while () { my ($no,$reno,$dat,$nam,$eml,$sub,$com,$url,$hos,$pw,$col) = split(/<>/); if ($in{'no'} == $no && $reno) { $flg++; } if ($in{'no'} == $no || $in{'no'} == $reno) { if ($in{'no'} == $no) { $resub = $sub; } if ($url) { $url = "<Home>"; } if ($reno) { print "
"; } if ($reno) { print '  '; } if ($nam_col) { $nam = "$nam"; } if ($refcol) { $com =~ s/([\>]|^)(>[^<]*)/$1$2<\/font>/g; } # URLリンク if ($autolink) { $com = &auto_link($com); } print "$sub\n"; if ($boardmode) { print "投稿者:$nam $url "; } else { print "投稿者:$nam 投稿日:$dat $url "; print "No.$no
\n"; } print "
$com
\n"; if ($boardmode) { print "
$dat \[No.$no\]\n
\n"; } } } close(IN); print "

\n"; if ($flg) { &error("不正な返信要求です"); } # タイトル名 if ($resub !~ /^Re\:/) { $resub = "Re: $resub"; } if ($adminchk && $nam eq $a_name) { $nam = $admin_id; } print "
"; print "
"; print < // --> EOM if ($allowmode) { print "\n\n\n\n
\n", " 投稿内容は管理者が許可するまで表\示されません。 ", "
\n
\n"; } print ""; # コメント引用 if ($refcom) { $refcom = "\n> $refcom"; $refcom =~ s/
/\r> /g; } if (!$re_box) { $cref = 0; } require $formpl; &form($cnam,$ceml,$curl,$cpwd,$cico,$ccol,$resub,$refcom,$csmail,$caikotoba,$cref); print <
EOM exit; } #------------------------------------------------- # ワード検索 #------------------------------------------------- sub find { &header; print < EOM if ($in{'list'} ne "pickup") { print qq|\n|; } print <
  • キーワードを入力し、「条件」「表\示」を選択して検索ボタンを押して下さい。
  • キーワードはスペースで区切って複数指定することができます。

    キーワード 条件 表\示
EOM # 検索実行 require $searchpl; if ($in{'word'} ne "") { ($i,$next,$back) = &search($logfile,$in{'word'},$in{'view'},$in{'cond'}); $enwd = &url_enc($in{'word'}); if ($back >= 0) { print "[前の$in{'view'}件]\n"; } if ($next < $i) { print "[次の$in{'view'}件]\n"; } } print "\n"; exit; } #------------------------------------------------- # 投稿画面 #------------------------------------------------- sub form_disp { # 投稿キー local($str_plain,$str_crypt); if ($regist_key) { require $regkeypl; ($str_plain,$str_crypt) = &pcp_makekey; } if ($adminchk && $nam eq $a_name) { $nam = $admin_id; } # クッキーを取得 local($cnam,$ceml,$curl,$cpwd,$cico,$ccol,$csmail,$caikotoba,$cref) = &get_cookie; # ヘッダを出力 if ($ImageView == 1) { &header('ImageUp'); } else { &header; } # 関連記事出力 print < ▼新規投稿フォーム
EOM print "
\n"; print < // --> EOM if ($allowmode) { print "\n\n\n\n
\n", " 投稿内容は管理者が許可するまで表\示されません。 ", "
\n
\n"; } if (!$re_box) { $cref = 0; } require $formpl; &form($cnam,$ceml,$curl,$cpwd,$cico,$ccol,'',$inputform,$csmail,$caikotoba,$cref); print < EOM exit; } #------------------------------------------------- # カウンタ処理 #------------------------------------------------- sub counter { local($count, $cntup, @count); # 閲覧時のみカウントアップ if ($mode eq '') { $cntup = 1; } else { $cntup = 0; } # カウントファイルを読みこみ open(LOG,"+< $cntfile") || &error("Open Error: $cntfile"); eval "flock(LOG, 2);"; $count = ; # IPチェックとログ破損チェック local($cnt, $ip) = split(/:/, $count); if ($addr eq $ip || $cnt eq "") { $cntup = 0; } # カウントアップ if ($cntup) { $cnt++; truncate(LOG, 0); seek(LOG, 0, 0); print LOG "$cnt:$addr"; } close(LOG); # 桁数調整 while(length($cnt) < $mini_fig) { $cnt = '0' . $cnt; } @count = split(//, $cnt); # GIFカウンタ表示 if ($counter == 2) { foreach (0 .. $#count) { print "\"$count[$_]\""; } # テキストカウンタ表示 } else { print "$cnt
\n"; } } #------------------------------------------------- # 画像イメージ表示 #------------------------------------------------- sub image { my @ico1 = split(/\s+/, $ico1); my @ico2 = split(/\s+/, $ico2); &header; print <

画像イメージ

EOM my $i = 0; foreach (0 .. $#ico1) { $i++; if ($i % 5 == 1) { print "\n"; } print qq|\n|; if ($i % 5 == 0) { print "\n"; } } while ( $i % 5 != 0 ) { print qq||; $i++; } print <
EOM exit; } #------------------------------------------------- # 移動ボタン #------------------------------------------------- sub mvbtn { local($link,$i,$view) = @_; local($start,$end,$x,$y,$bk_bl,$fw_bl); if ($in{'bl'}) { $start = $in{'bl'}*10 + 1; $end = $start + 9; } else { $in{'bl'} = 0; $start = 1; $end = 10; } $x = 1; $y = 0; while ($i > 0) { # 当ページ if ($page == $y) { print qq {| $x\n}; # 切替ページ } elsif ($x >= $start && $x <= $end) { print "| $x\n"; # 前ブロック } elsif ($x == $start-1) { $bk_bl = $in{'bl'}-1; print "| \n"; # 次ブロック } elsif ($x == $end+1) { $fw_bl = $in{'bl'}+1; print "| \n"; } $x++; $y += $view; $i -= $view; } print "|\n"; } #------------------------------------------------- # URLエンコード #------------------------------------------------- sub url_enc { local($_) = @_; s/(\W)/'%' . unpack('H2', $1)/eg; s/\s/+/g; $_; } #------------------------------------------------- # タイトル一覧表示 #------------------------------------------------- sub SubjectList { my (%oyano,%oyasub,%date,%name,%tm,$k); my $i = 0; my $j = 1; my @i = (); open(IN,"$logfile"); my $top = ; while () { my ($no,$reno,$date,$name,$e,$sub,$m,$u,$h,$p,$c,$ic,$tm) = split(/<>/); if (!$reno) { $oyano{$j} = $no; $oyasub{$j} = $sub; $i++; $j++; } else { $i[$j]++; } $date{$i} = $date; $name{$i} = $name; $tm{$i} = $tm; } close(IN); if ($j > $alltitle) { $j = $alltitle + 1; } if ($i) { print qq|
\n|; print qq|
$ico1[$_]$ico2[$_]

\n|; print qq|\n
\n|; } for ($k = 1; $k < $j; $k++){ my $co = sprintf("%01d",$i[$k+1]); print qq|$k: $oyasub{$k} ($co)|; # 所定時間以内の投稿は[NEWマーク]表示 if (time - $tm{$k} < $new_time * 3600) { print qq| $newmark \n|; } print qq| /\n|; } print qq|
\n
\n|; if (!$boardmode) { print qq|
\n|; } } #------------------------------------ # Trap #------------------------------------ sub wana { # IPアドレス取得 if (!$addr) { $addr = $ENV{'REMOTE_ADDR'}; } my $flag = 0; if(-e "$denyfile"){ # アクセス制限ファイルが存在 open(IN, "$denyfile"); eval { flock(IN, 1); }; my $deny = ; close (IN); # 旧アクセス制限IPファイル対応 if ($deny =~ /\,/) { $deny =~ s/\,/\n/g; open (OUT,">$denyfile"); eval { flock(OUT, 2); }; print OUT "$deny\n"; close OUT; } # アクセス制限IPを検索 open(IN, "$denyfile"); eval { flock(IN, 1); }; my @denyip = ; my @newip = @denyip; my $i = $#denyip; close (IN); foreach (@denyip) { if( $_ =~ /^\s*(\S+)/ ){ my $part = $1; if( $part =~ /\d+\.\d+\.\d+\.\d+/ ){ if($part && index( $addr, $part ) >= $[ ){ $flag = 1; last; } } } } if (!$flag) { # 新規のアクセス制限IPを追加 push(@newip,"$addr\n"); while ($i >= $denynum) { # 古いアクセス制限IPを削除 shift(@newip); $i--; } open (OUT,"+>$denyfile"); eval { flock(OUT, 2); }; print OUT @newip; close OUT; } } else { # アクセス制限ファイルを新たに作成 open (OUT,">$denyfile"); eval { flock(OUT, 2); }; chmod (0606,"$denyfile"); print OUT "$addr\n"; close OUT; $flag = 1; } # Internal Server Error &cgi_error; exit; } __END__