#!/usr/bin/perl #┌───────────────────────────────── #│ Web Forum v5 #│ wforum.cgi - 2007/02/14 #│ Copyright (c) KentWeb #│ webmaster@kent-web.com #│ http://www.kent-web.com/ #└───────────────────────────────── # 外部ファイル取込み require './init.cgi'; require $jcodepl; require $foldpl; # 基本処理を定義 &decode; &axsCheck; if ($mode eq "msgview") { &msgview; } elsif ($mode eq "allread") { &allread; } elsif ($mode eq "newsort") { &newsort; } elsif ($mode eq "find") { &find; } elsif ($mode eq "note") { ¬e; } elsif ($mode eq "past") { &past_view; } elsif ($mode eq "check") { ✓ } &list_view; #------------------------------------------------- # リスト表示 #------------------------------------------------- sub list_view { &header; print "
\n"; # タイトル部 if ($t_img) { print "\"$title\"\n"; } else { print "$title\n"; } print < [トップに戻る] [留意事項] [新規投稿] EOM if ($in{'list'} ne "new") { print "[新規順表\示]\n"; } else { print "[ツリー表\示]\n"; } $in{'list'} ||= 'tree'; print <新着記事] [ワード検索] EOM print "[過去ログ]\n" if ($pastkey); print <管理用]
  • $new_time時間以内の記事は $newmark で表\示されます。

  • EOM if ($in{'list'} eq "new") { print "
  • 以下は新規投稿順のリスト表\示です。

  • \n"; } else { print "
  • ツリー先頭部の $treehead をクリックすると関連記事を一括表\示します。

  • \n"; } print "
    \n"; # ログを開く if ($in{'list'} eq "new") { &ListNewOpen; } else { &ListTreeOpen; } # ページ移動フォーム &move_list; # メッセージ投稿フォ−ムを表示 &msg_form; # 著作権表示(削除禁止) print <
    - Web Forum -
    EOM exit; } #------------------------------------------------- # リストツリー表示 #------------------------------------------------- sub ListTreeOpen { local($no,$reno,$lx,$sub,$email,$url,$name,$dat,$msg,$t,$h,$pw,$w,$oya); # 時間取得 $time = time; if ($mode ne "past") { print "
    \n"; } print "\n"; $x--; } while ($x < $lx) { print "\n"; $x--; } } # 所定時間以内の投稿は[NEWマーク]表示 if ($time - $t > $new_time * 3600) { $newsign = ""; } else { $newsign = $newmark; } # 記事タイトル長調整 $sub = &cut_subject($sub); # 過去記事 if ($mode eq "past") { print "
  • $sub - $name $dat No\.$no $newsign\n"; # 削除記事 } elsif ($pw eq 'DEL') { if ($lx == 0) { print "

    $treehead - "; print "$sub - $dat No\.$no\n"; } else { print "
  • $sub - $dat No\.$no\n"; } # レス記事 } elsif ($lx != 0) { print "
  • $sub - $name $dat No\.$no $newsign\n"; # 親記事 } else { print "

    $treehead - "; print "$sub - $name $dat No\.$no $newsign\n"; } } close(IN); while ($x > 0) { print "\n"; $x--; } print "\n"; if ($mode ne "past") { print "
  • \n"; } } #------------------------------------------------- # リスト新着順 #------------------------------------------------- sub ListNewOpen { local($no,$reno,$xl,$sub,$email,$url,$name,$date,$msg,$tim,$h,$pw,$wrap,$oya); # 時間取得 $time = time; open(IN,"$logfile") || &error("Open Error: $logfile"); $top = ; while () { ($no,$reno,$xl,$sub,$email,$url,$name,$date,$msg,$tim,$h,$pw,$wrap,$oya) = split(/<>/); $cnt{$no} = $tim; $rno{$no} = $reno; $dat{$no} = $date; $nam{$no} = $name; $sub{$no} = $sub; $oya{$no} = $oya; } close(IN); print "
      \n"; # ソート処理 $i=0; $x=0; $p_tree *= 3; foreach (sort { ($cnt{$b} <=> $cnt{$a}) } keys(%cnt)) { $i++; if ($i < $page + 1) { next; } if ($i > $page + $p_tree) { next; } # 所定時間以内の投稿は[NEWマーク]表示 if ($time - $cnt{$_} > $new_time * 3600) { $newsign = ""; } else { $newsign = $newmark; } if ($sub{$_} eq '投稿者削除') { print "
    • $sub{$_} - $dat{$_} No\.$_ $newsign\n"; } else { print "
    • $sub{$_} - $nam{$_} $dat{$_} No\.$_ $newsign\n"; } } print "
    \n"; } #------------------------------------------------- # 記事閲覧 #------------------------------------------------- sub msgview { local($no,$re,$lx,$sub,$eml,$url,$nam,$dat,$msg,$lt,$ho,$pw,$wrap,$oya,$sml,$v_dat,$v_nam,$v_eml,$v_url,$v_msg,$v_tim,$v_sub,$v_wrp,$v_sml,$date); $flag = 0; @new = (); open(IN,"$logfile") || &error("Open Error: $logfile"); $top = ; while () { ($no,$re,$lx,$sub,$eml,$url,$nam,$dat,$msg,$lt,$ho,$pw,$wrap,$oya,$sml) = split(/<>/); if ($in{'oya'} == $oya) { push(@new,$_); } elsif ($flag && $in{'oya'} != $oya) { last; } if ($in{'no'} == $no) { $flag=1; $v_dat = $dat; $v_nam = $nam; $v_eml = $eml; $v_url = $url; $v_msg = $msg; $v_tim = $lt; $v_sub = $sub; $v_wrp = $wrap; $v_sml = $sml; } } close(IN); # レスメッセージ $res_msg = "\n> $v_msg"; $res_msg =~ s/"/"/g; $res_msg =~ s/
    /\r> /g; # レスタイトル $res_sub = $v_sub; if ($res_sub =~ /^Re\^(\d+)\:(.*)/) { $renum = $1 + 1; $res_sub = "Re\^$renum\:$2"; } elsif ($res_sub =~ /^Re\:(.*)/) { $res_sub = "Re\^2:$1"; } else { $res_sub = "Re: $res_sub"; } # HTMLを出力 &header; print "
    \n"; if ($t_img) { print "\"$title\"\n"; } else { print "$title\n"; } print < [記事リスト] [新着記事] [ワード検索] EOM print "[過去ログ]\n" if ($pastkey); print "[管理用]
    \n"; # 自動リンク if ($autolink) { $v_msg = &auto_link($v_msg); } # $v_msg =~ s/"/"/g; # 引用部色変更 if ($refcol) { $v_msg =~ s/([\>]|^)(>[^<]*)/$1$2<\/font>/g; } # PREタグ if ($v_wrp eq 'pre') { $v_msg =~ s/
    /\n/g; $v_msg = "
    $v_msg
    "; } # 投稿日時 $date = &get_time($v_tim); print <\n"; if ($v_url) { unless ($v_url =~ m|https?://|) { $v_url = "http://$v_url"; } print "\n"; } print "
    タイトル $v_sub
    投稿日: $date
    投稿者$v_nam EOM if ($v_eml && $v_sml eq '0') { print "  <$v_eml>"; } print "
    参照先: "; print "$v_url
    $v_msg

    \n"; if (@new > 1) { print "


    - 関連一覧ツリー\n"; print "($treehead をクリックするとツリー全体を一括表\示します)
    \n"; $x=0; print "
      \n"; foreach (@new) { ($no,$re,$lx,$sub,$eml,$url,$nam,$dat,$msg,$lt,$ho,$pw,$wrap,$oya,$sml) = split(/<>/); while ($x > $lx) { print "
    \n"; $x--; } while ($x < $lx) { print "
      \n"; $x++; } # 記事タイトル長調整 $sub = &cut_subject($sub); if ($lx != 0) { print "
    • $sub - $nam $dat "; } else { print "$treehead - $sub - $nam $dat"; } if ($in{'no'} == $no) { print "No\.$no\n"; } else { print "No\.$no\n"; } } while ($x > 0) { print "
    \n"; $x--; } print "\n"; } # 返信フォーム &msg_form; print "\n\n"; exit; } #------------------------------------------------- # 一括表示 #------------------------------------------------- sub allread { local($no,$re,$lx,$sub,$eml,$url,$nam,$dat,$msg,$t,$ho,$pw,$wrap,$oya,$sml,$date); # HTMLを出力 &header; print <リストへもどる]
    一括表\示
    EOM # 過去ログの場合 if ($in{'act'} eq "past") { # ログファイルを定義 if ($in{'pastlog'}) { $count = $in{'pastlog'}; } else { open(NO,"$nofile") || &error("Open Error: $nofile"); $count = ; close(NO); } $logfile = sprintf("%s%04d\.cgi", $pastdir,$count); } # 親記事を出力 $x=0; print "
      \n"; open(IN,"$logfile") || &error("Open Error: $logfile"); $top = if ($in{'act'} ne "past"); $flag = 0; while () { ($no,$re,$lx,$sub,$eml,$url,$nam,$dat,$msg,$t,$ho,$pw,$wrap,$oya) = split(/<>/); if ($in{'no'} == $oya) { $flag=1; push(@new,$_); while ($x > $lx) { print "
    \n"; $x--; } while ($x < $lx) { print "
      \n"; $x++; } # 記事タイトル長調整 $sub = &cut_subject($sub); if ($pw eq 'DEL') { print "
    • $sub - $dat No\.$no\n"; } else { print "
    • $sub - $nam $dat No\.$no\n"; } } elsif ($flag && $in{'no'} != $oya) { last; } } close(IN); while ($x > 0) { print "
    \n"; $x--; } print "
    \n"; foreach (@new) { ($no,$re,$lx,$sub,$eml,$url,$nam,$dat,$msg,$t,$ho,$pw,$wrap,$oya,$sml) = split(/<>/); if ($pw eq 'DEL') { next; } # 自動リンク if ($autolink) { $msg = &auto_link($msg); } # $msg =~ s/"/"/g; # 引用部色変更 if ($refcol) { $msg =~ s/([\>]|^)(>[^<]*)/$1$2<\/font>/g; } # 図表モード if ($wrap eq 'pre') { $msg =~ s/
    /\n/g; $msg = "
    $msg
    "; } $date = &get_time($t); print "\n"; print "\n"; print "
    "; print "\n"; print "\n"; print "\n"; print "\n"; if ($url) { unless ($url =~ m|https?://|) { $url = "http://$url"; } print "\n"; } print "
    タイトル: "; print "$sub
    記事No$no
    投稿日: $date
    投稿者$nam "; if ($eml && $sml eq '0') { print "  <$eml>"; } print "
    参照先: "; print ""; print "$url
    $msg
    \n"; if ($in{'act'} ne "past") { print "
    \n"; print "
    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
    \n"; } print "

    \n"; } print "
    \n\n\n"; exit; } #------------------------------------------------- # 新着順ソート表示 #------------------------------------------------- sub newsort { local($no,$re,$x,$sub,$eml,$url,$nam,$dat,$msg,$tim,$ho,$pw,$wrp,$oya,$sml,$date); &header; print <リストへもどる]
    新着記事

    EOM # 記事展開 open(IN,"$logfile") || &error("Open Error: $logfile"); $top = ; while () { ($no,$re,$x,$sub,$eml,$url,$nam,$dat,$msg,$tim,$ho,$pw,$wrp,$oya,$sml) = split(/<>/); if ($pw eq 'DEL') { next; } # 連想配列化 $cnt{$no} = $tim; $nam{$no} = $nam; $eml{$no} = $eml; $url{$no} = $url; $rno{$no} = $re; $sub{$no} = $sub; $oya{$no} = $oya; $msg{$no} = $msg; $wrp{$no} = $wrp; $sml{$no} = $sml; } close(IN); # ソート処理 $i=0; foreach (sort { ($cnt{$b} <=> $cnt{$a}) } keys(%cnt)) { $i++; if ($i > $sortcnt) { last; } # ループを抜ける if ($autolink) { $msg{$_} = &auto_link($msg{$_}); } # $msg{$_} =~ s/"/"/g; if ($refcol) { $msg{$_} =~ s/([\>]|^)(>[^<]*)/$1$2<\/font>/g; } # PRE機能 if ($wrp{$_} eq "pre") { $msg{$_} =~ s/
    /\n/g; $msg{$_} = "
    $msg{$_}
    "; } $date = &get_time($cnt{$_}); print "\n"; print "
    \n"; print ""; print ""; print "\n"; print "\n"; print "\n"; if ($url{$_}) { unless ($url{$_} =~ m|https?://|) { $url{$_} = "http://$url{$_}"; } print "\n"; } print "
    タイトル: "; print "$sub{$_}
    記事No$_   "; print "[関連記事]
    投稿日: $date
    投稿者$nam{$_} "; if ($eml{$_} && $sml{$_} eq '0') { print "  <"; print "$eml{$_}>"; } print "
    参照先: "; print ""; print "$url{$_}
    $msg{$_}
    \n"; print "
    \n"; print "
    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
    \n"; print "

    \n"; } print "
    \n\n\n"; exit; } #------------------------------------------------- # 留意事項 #------------------------------------------------- sub note { &header; print < 留意事項

    - 投稿する上での注意事項 -

    • 投稿する上での必須入力項目は「おなまえ」「メールアドレス」「タイトル」「メッセージ」です。その他の項目は任意となります。
    • 投稿時に「暗証キー」を入力しておくと、その暗証キーを使って自分の記事を修正・削除することができます。
    • メールアドレスの入力時に、「非表\示」にチェックを入れておくことで、メールアドレスを非表\示とすることができます。(管理者のみにしか分かりません)
    • 投稿記事の最大保持件数は $max件で、それを超えると古い記事から削除されます。
    • 投稿メッセージでは、HTMLタグの使用はできません。
    • 管理者が著しく不利益と判断する記事や他人を誹謗中傷する記事は予\告なく削除することがあります。

    - 掲示板の使い方 -

    • この掲示板はツリー式掲示板です。どなたかが投稿した記事に対し、簡単に返信メッセージを付けることができます。
    • 新規の記事投稿はリスト下の「投稿フォーム」から送信して下さい。
    • 記事を読むには、リスト部にある「題名」をクリックすると内容が表\示されます。またその記事にレスを付けるには、「メッセージ表\示画面」下部の返信用投稿フォームから送信して下さい。
    • 投稿された記事は、$new_time時間以内はリスト部に $newmark で表\示されます。
    • リスト部にて、ツリー先頭部の ★ をクリックすると関連記事も同時に一括表\示されます。
    • メッセージフォーム内の投稿書式には以下の3方法があり、それぞれに適応するラジオボタンを選択します。
      「手動改行」
      フォーム内の改行位置は、ご自分で適宜改行します。
      「強制改行」
      フォーム内の改行位置は、フォーム枠の右端で強制的に改行処理します。
      「図表\モード」
      フォーム内の改行位置や半角スペース位置などをそのままの状態で表\示します。罫線等を使って簡易的な図表\を記述するのに便利です。(HTMLでの<PRE>タグで囲む機能\)

    EOM exit; } #------------------------------------------------- # 検索フォーム #------------------------------------------------- sub find { &header; print <リストへもどる]
    ワード検索

    • 検索したいキーワードを入力し、検索条件を選択して「検索」を押してください。
    • 複数のキーワードを入力するときはスペースで区切って下さい。
      キーワード: 条件: 表\示:\n
      \n
    \n"; # ワード検索の実行と結果表示 if ($in{'word'} ne "") { &search; } print "\n\n"; exit; } #------------------------------------------------- # 検索実行 #------------------------------------------------- sub search { local($no,$re,$lx,$sub,$eml,$url,$nam,$dat,$msg,$t,$ho,$pw,$wr,$oya,$sml,$back,$next); # 入力内容を整理 $in{'word'} =~ s/\x81\x40/ /g; @wd = split(/\s+/, $in{'word'}); # ファイルを読み込み $i = 0; @new = (); open(IN,"$logfile") || &error("Open Error: $logfile"); $top = if ($mode ne "past"); while () { $flag = 0; foreach $wd (@wd) { if (index($_,$wd) >= 0) { $flag = 1; if ($in{'cond'} eq 'OR') { last; } } else { if ($in{'cond'} eq 'AND') { $flag=0; last; } } } if ($flag) { $i++; next if ($i < $page + 1); next if ($i > $page + $in{'view'}); ($no,$re,$lx,$sub,$eml,$url,$nam,$dat,$msg,$t,$ho,$pw,$wr,$oya,$sml) = split(/<>/); if ($w eq "pre") { $msg =~ s/
    /\r/g; $msg = "
    $msg
    "; } if ($autolink) { $msg = &auto_link($msg); } # $msg =~ s/"/"/g; if ($refcol) { $msg =~ s/([\>]|^)(>[^<]*)/$1$2<\/font>/g; } $date = &get_time($t); print "
    \n"; print "\n"; print "\n"; } else { print "[関連記事]\n"; } print "\n"; print "\n"; if ($url) { unless ($url =~ m|https?://|) { $url = "http://$url"; } print "\n"; } print "
    タイトル: "; print "$sub
    記事No$no   "; if ($in{'pastlog'}) { print "[関連記事]
    投稿日: $date
    投稿者$nam "; if ($eml && $sml eq '0') { print "  <$eml>"; } print "
    参照先: "; print "$url
    $msg
    \n"; } } close(IN); # 検索終了 print "
    検索結果:$i件\n"; $next = $page + $in{'view'}; $back = $page - $in{'view'}; $enwd = &url_enc($in{'word'}); if ($back >= 0) { print "[前の$in{'view'}件]\n"; } if ($next < $i) { print "[次の$in{'view'}件]\n"; } if ($i) { print "

    ▲TOP\n"; } } #------------------------------------------------- # 自動リンク #------------------------------------------------- sub auto_link { local($_) = @_; s/([^=^\"]|^)(https?\:\/\/[\w\.\~\-\/\?\&\=\;\#\:\%\+\@]+)/$1$2<\/a>/g; $_; } #------------------------------------------------- # 過去ログ表示 #------------------------------------------------- sub past_view { open(IN,"$nofile") || &error("Open Error: $nofile"); $pastno = ; close(IN); $pastno = sprintf("%04d", $pastno); if (!$in{'pastlog'}) { $in{'pastlog'} = $pastno; } &header; print <<"EOM"; [掲示板に戻る]
    過去ログ [ $in{'pastlog'} ]

    \n"; print "
    過去ログ:\n\n"; print "
    \n"; print "\n"; print "\n"; print "ワード検索:\n"; print "条件: 表\示: "; print "
    \n"; # ファイルを定義 $logfile = "$pastdir$in{'pastlog'}\.cgi"; # ワード検索処理 if ($in{'word'} ne "") { &search; print "\n\n"; exit; } &ListTreeOpen('past'); &move_list; print "\n\n"; exit; } #------------------------------------------------- # 記事タイトル長調整 #------------------------------------------------- sub cut_subject { # 制限長に満たないものは戻す if (length($_[0]) <= $sub_length) { return $_[0]; } # カット処理 ($_[0], $folded) = &fold($_[0], $sub_length); $_[0] .= '..'; return $_[0]; } #------------------------------------------------- # ページ移動フォーム #------------------------------------------------- sub move_list { local($x,$y,$next,$back); $in{'list'} ||= 'tree'; $next = $page + $p_tree; $back = $page - $p_tree; print "

    \n"; if ($back >= 0) { print "\n"; } if ($next < $i) { print "\n"; } print "
    \n"; print "\n" if ($in{'pastlog'} ne ""); print "\n"; print "\n" if ($mode eq 'past'); print "\n"; print "
    \n"; print "\n" if ($in{'pastlog'} ne ""); print "\n"; print "\n" if ($mode eq 'past'); print "\n"; print "
    "; # ページ移動ボタン表示 $x=1; $y=0; $z=0; while ($i > 0) { if ($page eq $y) { $z++; print "| $x\n"; } elsif ($in{'pastlog'} ne "") { $z++; print "| $x\n"; } else { $z++; print "| $x\n"; } $x++; $y += $p_tree; $i -= $p_tree; } print "|" if ($z); print "

    \n"; } #------------------------------------------------- # URLエンコード #------------------------------------------------- sub url_enc { local($_) = @_; s/(\W)/'%' . unpack('H2', $1)/eg; s/\s/+/g; $_; } #------------------------------------------------- # チェックモード #------------------------------------------------- sub check { &header; print <Check Mode

      EOM # ログ print "
    • ログパス:"; if (-e $logfile) { print "OK\n"; # パーミッション print "
    • ログパーミッション:"; if (-r $logfile && -w $logfile) { print "OK\n"; } else { print "NG → $logfile\n"; } } else { print "NG → $logfile\n"; } # 過去ログ print "
    • 過去ログ:"; if ($pastkey == 0) { print "設定なし\n"; } else { print "設定あり\n"; # NOファイル if (-e $nofile) { print "
    • NOファイルパス:OK\n"; if (-r $nofile && -w $nofile) { print "
    • NOファイルパーミッション:OK\n"; } else { print "
    • NOファイルパーミッション:NG → $nofile\n"; } } else { print "
    • NOファイルのパス:NG → $nofile\n"; } # ディレクトリ if (-d $pastdir) { print "
    • 過去ログディレクトリパス:OK\n"; if (-r $pastdir && -w $pastdir && -x $pastdir) { print "
    • 過去ログディレクトリパーミッション:OK\n"; } else { print "
    • 過去ログディレクトリパーミッション:NG → $pastdir\n"; } } else { print "
    • 過去ログディレクトリのパス:NG → $pastdir\n"; } } print "\n"; exit; }