#!/usr/bin/perl #┌───────────────────────────────── #│ TOPICS BOARD : topics.cgi - 2011/11/23 #│ Copyright (c) KentWeb #│ http://www.kent-web.com/ #└───────────────────────────────── # モジュール宣言 use strict; use CGI::Carp qw(fatalsToBrowser); use lib "./lib"; use CGI::Minimal; use Jcode; # 設定ファイル認識 require "./init.cgi"; my %cf = &init; # データ受理 CGI::Minimal::max_read_size($cf{maxdata}); my $cgi = CGI::Minimal->new; &error('容量オーバー') if ($cgi->truncated); my %in = &parse_form($cgi); # 処理分岐 if ($in{mode} eq 'find') { &find_log; } if ($in{poptag}) { &poptag; } &bbs_list; #----------------------------------------------------------- # 記事表示 #----------------------------------------------------------- sub bbs_list { # ページ数 my $pg = $in{pg} || 0; # データ認識 my ($i,@log); open(IN,"$cf{logfile}") or &error("open err: $cf{logfile}"); while() { $i++; next if ($i < $pg + 1); next if ($i > $pg + $cf{pg_max}); push(@log,$_); } close(IN); # 繰越ボタン作成 my $pg_btn = &make_pgbtn($i, $pg); # テンプレート読み込み open(IN,"$cf{tmpldir}/bbs.html") or &error("open err: bbs.html"); my $tmpl = join('', ); close(IN); # テンプレート分割 my ($head,$loop,$foot); if ($tmpl =~ /(.+)(.+)(.+)/s) { ($head,$loop,$foot) = ($1,$2,$3); } else { &error("テンプレートが不正です"); } # 文字置換 foreach ($head,$foot) { s/!bbs_title!/$cf{bbs_title}/g; s/!([a-z]+_cgi)!/$cf{$1}/g; s/!page_btn!/$pg_btn/g; s/!homepage!/$cf{homepage}/g; } # ヘッダ表示 print "Content-type: text/html\n\n"; print $head; # 記事展開 foreach (@log) { my ($no,$date,$sub,$com,$e1,$w1,$h1,$e2,$w2,$h2,$e3,$w3,$h3,$tag,$clip,$tube) = split(/<>/); if ($tag == 1) { $com = &tag($com); } elsif ($cf{autolink}) { $com = &autolink($com); } # YouTube my $att; if ($clip eq 't') { $att = &tag($tube) if ($tube); # 画像 } else { if ($e1) { my ($w,$h) = &resize($w1,$h1); $att .= qq|\n|; } if ($e2) { my ($w,$h) = &resize($w2,$h2); $att .= qq|\n|; } if ($e3) { my ($w,$h) = &resize($w3,$h3); $att .= qq|\n|; } } # 文字置換 my $tmp = $loop; $tmp =~ s/!date!/$date/g; $tmp =~ s/!subject!/$sub/g; $tmp =~ s/!comment!/$com/g; $tmp =~ s//$att/g; print $tmp; } # フッタ(著作権表記は削除・改変を禁止) my $copy = ©right; if ($foot =~ /(.+)(<\/body[^>]*>.*)/si) { print "$1$copy$2\n"; } else { print "$foot$copy\n"; print "\n"; } exit; } #----------------------------------------------------------- # ワード検索 #----------------------------------------------------------- sub find_log { # 条件 $in{cond} =~ s/\D//g; # 検索条件プルダウン my %op = (1 => 'AND', 0 => 'OR'); my $op_cond; foreach (1,0) { if ($in{cond} eq $_) { $op_cond .= qq|