#!/usr/bin/perl
#Web Board Professional CGI Library (2004/05/02)
$ver = '2.27';
#
#Copyright(C) Knight 2002-2004
#Mail ... knight@big.or.jp
#Home ... http://www.big.or.jp/~knight/
### HTML出力
sub html {
if ($mini_counter != 0) {
if ($ENV{'REQUEST_METHOD'} ne 'POST' && $ENV{'QUERY_STRING'} eq '') {
&count_up();
}
open(COUNT, "$count_log") || &error("カウントログファイルを読み出せません");
$data = ;
close(COUNT);
($sum, $today, $yesterday, $key) = split(/\t/, $data);
}
open(FILE, "$log_file") || &error("ログファイルを読み出せません");
@logs = ;
close(FILE);
$no = 0;
$parent = 0;
$date = '';
$name = '';
%child_logs = ();
foreach (@logs) {
if ($show_last_post == 1 && $_ + 0 > $no) {
($no, $reno, $date, $name) = (split(/\t/))[0, 1, 2, 3];
}
if ((split(/\t/))[1] == 0) {
$parent++;
} else {
$child_logs{(split(/\t/))[1]}++;
}
}
&header();
print <<"_HTML_";
▲戻る /
使い方 /
_HTML_
if ($rank_mode == 1) {
print qq|
ランキング / \n|;
}
print <<"_HTML_";
ログ検索 /
記事編集 /
_HTML_
if ($make_past == 1) {
print qq|
過去ログ / \n|;
}
print <<"_HTML_";
管理者用
_HTML_
if ($show_last_post == 1) {
($sec, $min, $hour, $day, $mon, $year, $week) = localtime($date);
$date = sprintf("%02d/%02d-%02d:%02d", $mon + 1, $day, $hour, $min);
print qq|LastPost $date $name\n|;
}
if ($mini_counter == 1) {
$counter = sprintf("%0${count_figure}d", $sum);
if ($count_img == 1) {
$counter =~ s/(.)/

/g;
}
print qq|Access $counter\n|;
}
print <<"_HTML_";
_HTML_
if ($title_img ne '') {
print qq|

\n|;
} else {
print qq|
$title
\n|;
}
print <<"_HTML_";
$top_message
_HTML_
&form();
&navigator();
&showlog();
&navigator();
print qq|ページ移動 /|;
foreach (0 .. int(($parent - 1) / $page_size)) {
$page_info = $_ + 1;
if ($in{'page'} == 0 && $page_info > $max_page_info) {
print qq| [
ShowNext]|;
last;
}
if ($in{'page'} == $_) {
print qq| [$page_info]|;
} else {
print qq| [
$page_info]|;
}
}
print qq|
\n|;
&footer();
}
### 投稿フォーム表示
sub form {
if ($ENV{'REQUEST_METHOD'} ne 'POST') {
%cookie = &get_cookie($cookie_id);
if ($cookie{'url'} eq '') {
$cookie{'url'} = 'http://';
}
if ($cookie{'color'} eq '') {
$cookie{'color'} = $color[0];
}
}
if ($in{'mode'} eq 'res') {
$subj = 'Re:' . (split(/\t/, $logs[0]))[6];
$text = '';
$mode = 'regist';
$submit = '返信する';
} elsif ($in{'mode'} eq 'userdel') {
%cookie = &get_cookie($cookie_id);
$in{'no'} = $reno;
$cookie{'name'} = $name;
$cookie{'mail'} = $mail;
$cookie{'url'} = $url;
$text =~ s/
/\n/g;
$cookie{'color'} = $color;
$cookie{'icon'} = $icon;
$cookie{'pwd'} = $in{'user_pwd'};
$mode = 'userdel';
$submit = '修正する';
} elsif ($in{'mode'} eq 'admin') {
$in{'no'} = $reno;
$cookie{'name'} = $name;
$cookie{'mail'} = $mail;
$cookie{'url'} = $url;
$text =~ s/
/\n/g;
$cookie{'color'} = $color;
$cookie{'icon'} = $icon;
$in{'user_pwd'} = $pwd;
$mode = 'admin';
$submit = '修正する';
} else {
$subj = '';
$in{'no'} = 0;
$text = '';
$mode = 'regist';
$submit = '投稿する';
}
if ($script_mode == 1) {
$check_form = qq| onSubmit="return checkForm()" onReset="return checkReset()"|;
}
if ($cookie_save_mode == 1) {
print <<"_HTML_";
_HTML_
}
print <<"_HTML_";
_HTML_
return;
}
### 投稿記事表示
sub showlog {
$start = $in{'page'} * $page_size;
$end = $start + $page_size;
$i = 0;
$flag = 0;
foreach (@logs) {
($no, $reno, $date, $name, $mail, $url, $subj, $text, $color, $icon, $file, $rank, $pwd, $host) = split(/\t/);
if ($in{'mode'} eq 'search' || $reno == 0) {
$i++;
}
if ($i <= $start) {
next;
}
if ($i > $end) {
last;
}
if ($new_date != 0 && time() - $date < $new_date * 24 * 60 * 60 && $in{'preview'} ne 'on') {
$new = $new_mark;
} else {
$new = '';
}
($sec, $min, $hour, $day, $mon, $year, $week) = localtime($date);
@week = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
$date = sprintf("%04d/%02d/%02d/%s/%02d:%02d", $year + 1900, $mon + 1, $day, $week[$week], $hour, $min);
if ($mail ne '') {
$mail = qq|/ Eメール|;
}
if ($url ne '') {
$url = qq|/ URL|;
}
if ($replace_mode == 1) {
$text =~ s/\/\+([^+]+)\+\//$1<\/big>/gi;
$text =~ s/\/\-([^-]+)\-\//$1<\/small>/gi;
$text =~ s/\/\!([^!]+)\!\//$1<\/b>/gi;
$text =~ s/\/i([^i]+)i\//$1<\/i>/gi;
$text =~ s/\/s([^s]+)s\//$1<\/s>/gi;
$text =~ s/\/\'([^']+)\'\//$1<\/span>/gi;
$text =~ s/\/h\//♥<\/span>/gi;
}
if ($refer_mode == 1 && $in{'mode'} eq 'res') {
$ref_text = $text;
$ref_text =~ s/
/\\n> /g;
$ref_text =~ s/<[^<]*>//gi;
$ref_text =~ s/"/”/g;
$ref_text =~ s/<(script|\/script)(\s*)([^&]*)\s*>/<$1$2$3>/gi;
$ref_text =~ s/♥/\/h\//gi;
$ref_text = '> ' . $ref_text;
$ref_text =~ s/<//g;
print <<"_HTML_";
_HTML_
$ref = qq|/ 引用|;
}
if ($auto_link == 1) {
$text = &auto_link($text);
}
if ($color_mode == 1) {
if ($color eq '') {
$color = $color[0];
}
$text = qq|$text|;
}
if ($ref_color ne '') {
$text =~ s/([\>]|^)(>|>)([^<]*)/$1$2$3<\/span>/g;
}
if ($icon_mode == 1 && $icon ne '') {
$icon = qq|
|;
} else {
$icon = ' ';
}
if ($rank_mode == 1 && $in{'preview'} ne 'on') {
$j = 0;
foreach (0 .. (($#class - 1) / 2)) {
$class_cont = $class[$j];
$now_rank = '';
$j++;
if ($rank < $class_cont) {
if ($rank_show == 1 && $rank ne '' && $rank != 0) {
$now_rank = " … $rank回";
}
$class = " ($class_name$now_rank)";
last;
}
$class_name = $class[$j];
$j++;
}
} else {
$class = '';
}
chop($host);
if (($in{'mode'} eq 'search' && $in{'no'} eq '' && $flag == 1) || ($flag == 1 && $reno == 0)) {
if ($quick_link == 1) {
print $quick_bar;
}
print <<"_HTML_";
_HTML_
}
if (($in{'mode'} eq 'search' && $in{'no'} eq '') || $reno == 0) {
$flag = 1;
$resno = 0;
if ($in{'mode'} eq '') {
if ($max_res_size != 0 && ($child_logs{"$no"} + 0) >= $max_res_size) {
$res = '';
$max_res_info = '[これ以上返信できません]';
} else {
$res = qq|/ 返信|;
$max_res_info = '';
}
if ($quick_link == 1 && $reno == 0) {
$quick_bar = <<"_HTML_";
|
_HTML_
if ($show_res_size != 0) {
$quick_bar .= qq|/ 全レスを表\示する\n|;
}
if ($max_res_info eq '') {
$quick_bar .= qq|/ 返信する\n|;
}
$quick_bar .= <<"_HTML_";
/ 戻る
|
_HTML_
}
}
if ($show_res_size != 0 && $in{'mode'} eq '' && $child_logs{"$no"} > $show_res_size) {
$all_show_info = qq|[全レス表\示]|;
} elsif ($in{'mode'} eq 'search' && $in{'no'} eq '') {
if ($reno == 0) {
$show = $no;
} else {
$show = $reno;
}
$all_show_info = qq|[関連記事を表\示]|;
} else {
$all_show_info = '';
}
if ($in{'mode'} ne 'new' && $in{'mode'} ne 'search') {
$threadno = '[' . ($resno + 1) . ']';
}
print <<"_HTML_";
| ■ $subj |
$res |
$threadno $name$class $mail $url / $date (No.$no) $ref $new
$max_res_info $all_show_info
|
_HTML_
} else {
$resno++;
if ($show_res_size != 0 && $child_logs{"$reno"}-- > $show_res_size) {
next;
}
if ($show_res_size != 0) {
$res_show_info = "[Re:$resno]";
}
if ($in{'mode'} ne 'new' && $in{'mode'} ne 'search') {
$threadno = '[' . ($resno + 1) . ']';
}
print <<"_HTML_";
$threadno $name$class $mail $url / $date (No.$no) $ref $new
|
_HTML_
}
}
if ($quick_link == 1) {
print $quick_bar;
}
print <<"_HTML_";
_HTML_
return;
}
### ページナビゲーター表示
sub navigator {
$new = '最新の投稿';
$prev = '↑前のページ';
$next = '↓次のページ';
if ($in{'page'} > 0) {
$new = qq|$new|;
}
if ($in{'page'} > 0) {
$n = $in{'page'} - 1;
$prev = qq|$prev|;
}
if (int(($parent - 1) / $page_size) > $in{'page'}) {
$n = $in{'page'} + 1;
$next = qq|$next|;
}
print qq|$new / $prev / $next
\n|;
return;
}
1;