#!/usr/bin/perl ## patio.cgi v0.8 ## Copyright (C) Kent Web 2002 # 外部ファイル取り込み require './init.cgi'; &decode; &axs_check; if ($mode eq "form") { &form; } elsif ($mode eq "find") { &find; } elsif ($mode eq "view") { &view; } elsif ($mode eq "view2") { &view2; } elsif ($mode eq "past") { &past; } elsif ($mode eq "check") { ✓ } &indexview; #------------------# # メニュー部表示 # #------------------# sub indexview { local($i, $data, $count, $x, $y); # アラーム数定義 $alarm = int($m_max*0.9); &header(); print <<"EOM";
| 新規スレッド | ホームに戻る | 留意事項 | ワード検索 | 過去ログ | 管理用 |   

EOM # スレッド表示 if ($p eq "") { $p=0; } $i=0; open(IN,"$nowfile") || &error("Open Error : $nowfile"); $top = ; while () { $i++; next if ($i < $p + 1); next if ($i > $p + $menu1); ($num,$sub,$res,$nam,$date,$na2,$key) = split(/<>/); # 参照カウンタ読み込み open(NO,"$logdir$num\.dat"); $data = ; close(NO); ($count) = split(/:/, $data); # アイコン定義 if ($key eq '0') { $icon = 'fold3.gif'; } elsif ($res >= $alarm) { $icon = 'fold5.gif'; } else { $icon = 'fold1.gif'; } print "", "", "", "", "", "\n"; } close(IN); print "
スレッド一覧

トピックス 作成者 返信 参照 最終更新
", "", "$sub$nam$res$count$date
", "by $na2
\n"; # ページ移動ボタン表示 if ($p - $menu1 >= 0 || $p + $menu1 < $i) { print "

\n"; print "
Page: "; $x=1; $y=0; while ($i > 0) { if ($p == $y) { print "[$x]\n"; } else { print "[$x]\n"; } $x++; $y = $y + $menu1; $i = $i - $menu1; } print "
\n"; } # 著作権表示(削除不可) print <<"EOM";

標準スレッド    ロック中(書込不可)   アラーム(返信数$alarm件以上)


- Web Patio -

EOM exit; } #----------------# # スレッド閲覧 # #----------------# sub view { local($no,$sub,$res,$key,$no2,$nam,$eml,$com,$dat,$ho,$pw,$url,$resub,$pno); local($job) = @_; # アラームを定義 local($alarm) = int($m_max * 0.9); # スマイルアイコン定義 if ($smile) { @s1 = split(/\s+/, $smile1); @s2 = split(/\s+/, $smile2); } # 汚染チェック $in{'no'} =~ s/\D//g; # 過去ログ if ($job eq "past") { $bbsback="mode=past"; $guid = "過去ログ > 記事閲覧"; # 現行ログ } else { # ロック開始 &lock($in{'no'}) if ($lockkey); # 参照数カウント open(IN,"$logdir$in{'no'}\.dat") || &error("Open Error : $in{'no'}\.dat"); $data = ; close(IN); ($count,$ip) = split(/:/, $data); if ($addr ne $ip) { $count++; open(OUT,">$logdir$in{'no'}\.dat") || &error("Write Error : $in{'no'}\.dat"); print OUT "$count\:$addr"; close(OUT); } # ロック解除 &unlock($in{'no'}) if ($lockkey); $bbsback = ""; $guid = "記事閲覧"; } # スレッド読み込み open(IN,"$logdir$in{'no'}\.cgi") || &error("Open Error : $in{'no'}\.cgi"); $top1 = ; $top2 = ; chop($top2); ($no,$sub,$res,$key) = split(/<>/, $top1); ($no2,$sub,$nam,$eml,$com,$dat,$ho,$pw,$url) = split(/<>/, $top2); $com = &auto_link($com, $no); $resub = "Re: $sub"; $pno = $no; # アイコン定義 if ($job ne "past" && $key eq '0') { $icon = 'fold3.gif'; } elsif ($job ne "past" && $res >= $alarm) { $icon = 'fold5.gif'; } else { $icon = 'fold1.gif'; } # ヘッダ if ($job eq "past") { &header($sub); } else { &header($sub, "js"); if ($key eq '0') { print "", "
", "このスレッドはロックされています。", "記事の閲覧のみとなります。
\n"; } elsif ($alarm <= $res) { print "", "
", "返信記事数が$res件あります。", "$m_max件を超えると書き込みができなくなります。", "
\n"; } } print <<"EOM";
トップページ > $guid
$sub
日時: $dat
名前: $nam EOM if ($eml) { print "  <$eml>\n"; } if ($url) { print "
参照: $url\n"; } print "

\n
$com
\n"; # ロックボタン if ($job ne "past" && $key ne '0') { print "
", "", "スレッド終了
\n"; } print "
\n"; # ページ繰越ボタン if ($p eq "") { $p=1; } if ($res > 0) { $end = $res / $t_max; if ($end != int($end)) { $end++; } } else { $end=1; } &pagelink($end, $p); print <<"EOM";

EOM # 表示範囲を定義 $from = $res - ($t_max * $p); $to = $from + $t_max; $i=0; while () { $i++; if ($i <= $from) { next; } if ($i > $to) { last; } chop; ($no,$sub,$nam,$eml,$com,$dat,$ho,$pw,$url) = split(/<>/); $com = &auto_link($com, $in{'no'}); print "", "\n"; } close(IN); if (!$i) { print ""; } print "
", " $sub ", "( No.$no )
\n", "
日時: $dat
名前: $nam"; if ($eml) { print "  <$eml>"; } if ($url) { print "
参照: $url\n"; } print "

\n
$com
\n"; if ($job ne "past") { print "
", "", "削除
"; } print "

\n"; &pagelink($end, $p) if ($i > $t_max); &form2 if ($job ne "past" && $key ne '0'); print "

\n\n"; exit; } #----------------# # 個別記事閲覧 # #----------------# sub view2 { local($top,$flag,$no,$sub,$nam,$eml,$com,$dat); # スマイルアイコン定義 if ($smile) { @s1 = split(/\s+/, $smile1); @s2 = split(/\s+/, $smile2); } # 汚染チェック $in{'f'} =~ s/\D//g; # 記事No認識 if ($in{'no'} =~ /^\d+$/) { $ptn=1; $start=$in{'no'}; } elsif ($in{'no'} =~ /^(\d+)\-$/) { $ptn=2; $start=$1; } elsif ($in{'no'} =~ /^(\d+)\-(\d+)$/) { $ptn=3; $start=$1; $end=$2; } else { &error("記事Noが不正です"); } &header($sub); print <<"EOM";
EOM $flag=0; open(IN,"$logdir$in{'f'}\.cgi") || &error("スレッドが見当たりません"); $top = ; while () { ($no,$sub,$nam,$eml,$com,$dat,$ho,$pw,$url) = split(/<>/); if ($start == $no) { $flag=1; } if (!$flag) { next; } # 記事表示 print "\n", "\n"; if (($ptn == 3 && $end == $no) || ($flag && $ptn == 1)) { last; } } close(IN); if (!$flag) { &error("記事が見当たりません"); } print <<"EOM";
", " $sub ", "( No.$no )
", "
日時: $dat
名前: $nam"; if ($eml) { print "  <$eml>\n"; } if ($url) { print "
参照: $url\n"; } $com = &auto_link($com, $in{'f'}); print "

$com



EOM exit; } #--------------------# # ページ繰越ボタン # #--------------------# sub pagelink { local($end, $p) = @_; print "
Page: "; foreach (1 .. $end) { if ($p == $_) { print "[$_]\n"; } else { print "[$_]\n"; } } print "
\n"; } #----------------# # 新規フォーム # #----------------# sub form { if ($smile) { &header("", "js"); } else { &header(); } print <<"EOM";
トップページ > 新規スレッド作成フォーム
  新規スレッド作成フォーム
EOM &form2("new"); print "
\n"; exit; } #----------------# # フォーム内容 # #----------------# sub form2 { local($job) = @_; local($cname, $cmail, $cpwd, $curl, $submit); # クッキーを取得 ($cname, $cmail, $cpwd, $curl) = &get_cookie; if ($curl eq "") { $curl = "http://"; } print <<"EOM";

題名 EOM if ($job eq "new") { $submit = 'スレッドを生成'; } else { $submit = ' 返信する '; print "\n", "", "スレッドをトップへソ\ート\n"; } print <<"EOM";
名前
E-Mail
URL
パスワード (記事メンテ時に使用)
コメント EOM # アイコン if ($smile) { @s1 = split(/\s+/, $smile1); @s2 = split(/\s+/, $smile2); foreach (0 .. $#s1) { print "", "\n"; } print "
\n"; } print <<"EOM";

   クッキー保存
EOM } #--------------# # ワード検索 # #--------------# sub find { local($word, $code); # 検索語句のコード変換 if ($in{'word'}) { $word = $in{'word'}; # コード判別(半角カナ対策) $code = "sjis"; if ($in{'code'} =~ /\x24\x22\x24\x22/) { $code = "jis"; } elsif ($in{'code'} =~ /\xA4\xA2\xA4\xA2/i) { $code = "euc"; } if ($code ne "sjis") { if (-e $jcode) { require $jcode; } else { &error("$jcodeがありません"); } &jcode'convert(*word, 'sjis', $code); } } else { $word = ''; } &header(); print <<"EOM";
トップページ > ワード検索
 ワード検索

キーワード   条件   表\示
検索範囲 "; if ($in{'log'} eq "") { $in{'log'} = 0; } @log1 = ($nowfile, $pastfile); @log2 = ("現行ログ", "過去ログ"); @log3 = ("view", "past"); foreach (0,1) { if ($in{'log'} == $_) { print "$log2[$_]\n"; } else { print "$log2[$_]\n"; } } print "
検索項目 "; if ($in{'s'} eq "") { $in{'s'} = 1; } if ($in{'s'} == 1) { print "トピックス\n"; } else { print "トピックス\n"; } if ($in{'n'} eq "") { $in{'n'} = 0; } if ($in{'n'} == 1) { print "名前\n"; } else { print "名前\n"; } print "   ", "
\n"; # 検索実行 if ($word && ($in{'s'} || $in{'n'})) { # アラーム数定義 $alarm = int($m_max*0.9); print "

", "
", "", "", "", "\n"; $word =~ s/\x81\x40/ /g; @wd = split(/\s+/, $word); $i=0; open(IN,"$log1[$in{'log'}]") || &error("Open Error : $log1[$in{'log'}]"); $top = if (!$in{'log'}); while () { ($no,$sub,$res,$nam,$date,$na2,$key) = split(/<>/); $target .= $sub if ($in{'s'}); $target .= $nam if ($in{'n'}); $flag=0; foreach $wd (@wd) { if (index($target,$wd) >= 0) { $flag=1; if ($in{'op'} eq 'OR') { last; } } else { if ($in{'op'} eq 'AND') { $flag=0; last; } } } if ($flag) { $i++; if ($i < $p + 1) { next; } if ($i > $p + $in{'vw'}) { next; } # アイコン定義 if ($key eq '0') { $icon = 'fold3.gif'; } elsif ($res >= $alarm) { $icon = 'fold5.gif'; } else { $icon = 'fold1.gif'; } print "", "", "", "\n"; } $target=''; } close(IN); print "", "
トピックス作成者返信最終更新
", "
", "", "$sub$nam$res$date
", "by $na2

検索結果:$i件   "; $next = $p + $in{'vw'}; $back = $p - $in{'vw'}; $enwd = &url_enc($word); if ($back >= 0) { print "[前の$in{'vw'}件]\n"; } if ($next < $i) { print "[次の$in{'vw'}件]\n"; } print "
\n"; } print "

\n\n"; exit; } #-----------------# # URLエンコード # #-----------------# sub url_enc { local($_) = @_; s/(\W)/'%' . unpack('H2', $1)/eg; s/\s/+/g; $_; } #----------------# # 過去ログ閲覧 # #----------------# sub past { # 記事閲覧 if ($in{'no'}) { &view("past"); } &header(); print <<"EOM";
トップページ > 過去ログ
 過去ログ

EOM # スレッド展開 $i=0; if ($p eq "") { $p=0; } open(IN,"$pastfile") || &error("Open Error : $pastfile"); while () { $i++; next if ($i < $p + 1); next if ($i > $p + $menu2); ($no,$sub,$res,$name,$date) = split(/<>/); print "", "", "", "", "\n"; } close(IN); if (!$i) { print "", "\n"; } print "

スレッド 投稿者 返信数 最終更新
", "", "$sub$name$res$date
- 現在過去ログはありません -
\n"; # ページ移動ボタン表示 if ($p - $menu2 >= 0 || $p + $menu2 < $i) { print "

\n"; print "
Page: "; $x=1; $y=0; while ($i > 0) { if ($p == $y) { print "[$x]\n"; } else { print "[$x]\n"; } $x++; $y = $y + $menu2; $i = $i - $menu2; } print "
\n"; } print "

\n\n"; exit; } #------------------# # クッキーを取得 # #------------------# sub get_cookie { local($key, $val, *cook); # クッキー取得 $cook = $ENV{'HTTP_COOKIE'}; # 情報を抽出 foreach (split(/;/, $cook)) { ($key, $val) = split(/=/); $key =~ s/\s//g; $cook{$key} = $val; } @cook = split(/<>/, $cook{'WebPatio'}); return @cook; } #--------------# # リンク処理 # #--------------# sub auto_link { local($msg, $f) = @_; $msg =~ s/([^=^\"]|^)(http\:[\w\.\~\-\/\?\&\+\=\:\@\%\;\#\%]+)/$1$2<\/a>/g; $msg =~ s/>>(\d)([\d\-]*)/>>$1$2<\/a>/gi; # スマイル画像変換 if ($smile) { local($tmp); foreach (0 .. $#s1) { $tmp = $s2[$_]; $tmp =~ s/([\+\*\.\?\^\$\[\-\]\|\(\)\\])/\\$1/g; $msg =~ s/$tmp/ /g; } } $msg; } #------------------# # チェックモード # #------------------# sub check { &header(); print "

チェックモード

\n", "
    \n"; @chk1 = ($logdir, $lockdir); @chk2 = ("データディレクトリ", "ロックディレクトリ"); foreach (0,1) { if (-d $chk1[$_]) { print "
  • $chk2[$_]のパス : OK!\n"; if (-w $chk1[$_] && -r $chk1[$_] && -x $chk1[$_]) { print "
  • $chk2[$_]のパーミッション : OK!\n"; } else { print "
  • $chk2[$_]のパーミッション : NG → $chk1[$_]\n"; } } else { print "
  • $chk2[$_]のパス : NG → $chk1[$_]\n"; } } print "
\n\n"; exit; } __END__