#!/usr/bin/perl require './jcode.pl'; require './setup.pl'; require './passsend.pl'; require './error.pl'; # メイン画面の色 sub body { print "$body_main\n"; } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); if ($year > 99) { $year = $year - 100; } if ($year < 10) { $year = "0$year"; } if ($sec < 10) { $sec = "0$sec"; } if ($min < 10) { $min = "0$min"; } if ($hour < 10) { $hour = "0$hour"; } $month = ($mon + 1); if ($month < 10) { $month = "0$month"; } if ($mday < 10) { $mday = "0$mday"; } $date_now = "$year/$month/$mday/$hour/$min/$sec"; # <-変更しないこと $date_fmt = "$seireki$year年$month月$mday日 $hour時$min分$sec秒"; # クッキーの消去設定 # 最終書き込みから 30日後 30*24*60*60 # 1日後 24*60*60 # 10時間後 10*60*60 $ENV{'TZ'} = "GMT"; ($secg,$ming,$hourg,$mdayg,$mong,$yearg,$wdayg,$ydayg,$isdstg) = localtime(time + 30*24*60*60); $yearg = $yearg + 1900; if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/,$buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; &jcode'convert(*value,'sjis'); if (substr($value,-1,1) eq "\n" || substr($value,-1,1) eq "\r") { chop($value); } if ($use_tag != 1) { $value =~ s//>/g; $value =~ s/"/"/g; } $FORM{$name} = $value; } $ccount = 0; $rn = "bak"; #管理用パスワードのチェック if (!open(IN,"$base_pwd")) { &error(2); } $admin_pass = ; close(IN); if ($FORM{'root'} eq "set") { require './root.pl'; &root_set; } $pass = 'off'; if ($admin_pass eq '') { require './root.pl'; &root_error; } if ($FORM{'pass'} ne '') { $encode_pwd = $admin_pass; $plain_text = $FORM{'pass'}; &passwd_decode; if ($super eq "yes") { $pass = 'on'; } } if ($FORM{'root'} eq 'change') { require './root.pl'; if ($pass ne 'on') { &error(not_root); } if ($FORM{'reset'} ne '') { &root_reset; } else { &root_change; } } if ($FORM{'action'} eq 'search') { if ($FORM{'string'} eq '') { &disp; exit; } else { &search; exit; } } if ($FORM{'action'} eq "reg") { require './regist.pl'; ®ist; exit; } if ($FORM{'action'} eq "delete") { &delete; exit; } if ($FORM{'action'} eq "undo") { &undo; exit; } if ($FORM{'action'} eq "pwd") { &makepwd; exit; } &disp; exit; sub header { print <<"EOF";

$title


EOF } sub disp { if (!open(IN,"$file")) { &error(disp_1); } @BUKKEN = ; $index_name = shift(@BUKKEN); close(IN); if (!($index_name eq "webboard v10 \'s index\n")) { &error(idx); } $accesses = @BUKKEN; $accesses2 = $accesses - 1; print "Content-type: text/html\n\n"; print "$title\n"; &body; @BUKKEN = reverse @BUKKEN; if ($accesses != 0) { if ($FORM{'def'} eq '') { $def = $FORM{'def'} = 10; } else { $def = $FORM{'def'}; } if ($FORM{'pg'} eq '') { $FORM{'pg'} = 0; } $accesses = @BUKKEN; $accesses = $accesses - 1; if ($FORM{'fwd'} eq 'next' || $FORM{'fwd'} eq '') { $pg = $FORM{'pg'}; $pg_end = $FORM{'pg'} + $def - 1; if ($pg_end > $accesses) { $pg_end = $accesses; } } elsif ($FORM{'fwd'} eq 'adj') { if (!open(IN,"$base_data")) { &error(disp_2); } $num = ; close(IN); if ($FORM{'pg'} < 1000) { &error(start); } $pg = $num - $FORM{'pg'}; if ($pg < 0) { &error(start); } $pg_end = $pg + $def - 1; if ($pg_end > $accesses) { $pg_end = $accesses; } } else { $pg = $FORM{'pg'} - $def; if ($pg < 0) { $pg = 0; } $pg_end = $FORM{'pg'} -1; } $pg_next = $pg_end + 1; $pg_back = $pg; &header; print "\n"; print "\n"; foreach ($pg .. $pg_end) { ($date,$name,$email,$page,$keywd,$subject) = split(/\,/, $BUKKEN[$_]); &count; $df = 0; if ($ref_flug == 1) { $subject = '[管理者削除]'; $df = 1; } elsif ($ref_flug == 2) { $subject = '[投稿者削除]'; $df = 1; } elsif ($ref_err == 1) { $subject = '[データ管理ファイルの破損] 管理者に復旧を依頼ください'; $df = 1; } if ($date =~ m#(.*)/(.*)/(.*)/(.*)/(.*)/(.*)#) { $date1 = "$1\/$2\/$3 $4\:$5"; } &disp2; } print "
番号投稿日投稿者返信元参照返信題名

\n"; print "\n"; &paac; print "

\n"; } else { &header; print "記事はありません。

\n"; } print "

ABOUT

\n"; print "

\n"; } sub paac { print "\n"; if ($pg_end ne $accesses) { print "\n"; } } elsif ($pg_end ne $accesses2 || $pg != 0) { print "\n"; } print "\n"; print "\n"; print "
\n"; print "' . "\n"; print '' . "\n"; print "
\n"; print '
 ' . "\n"; &paac_def; print '
\n"; if ($pg != 0) { print "
\n"; print "' . "\n"; print '' . "\n"; print "
\n"; print '
 ' . "\n"; &paac_def; print '
\n"; print "' . "\n"; print '' . "\n"; print "
\n"; print '
 ' . "\n"; &paac_def; print '
\n"; print "' . "\n"; print "
\n"; print '
  '; print 'から' . "\n"; &paac_def; print '
\n"; print "' . "\n"; print "
\n"; print '
 から' . "\n"; &paac_def; print '

\n"; } sub paac_def { if ($FORM{'def'} eq '1' || $res_disp == 1) { $FORM{'def'} = '10'; } print "件\n"; } sub disp2 { $ccount++; $ccount2 = substr($ccount,-1,1); if ($target == $page && $tcolor == 1) { $font = "bgcolor=\"#$line_color0\""; } elsif ('24680' =~ /$ccount2/) { $font = "bgcolor=\"#$line_color1\""; } else { $font = "bgcolor=\"#$line_color2\""; } $f1 = "$page"; $f2 = "$date1"; if (length($name) > 16) { $name = substr($name,0,16); } $f3 = "$name"; $f4 = "$res"; if ($f4 eq '') { $f4 = "...."; } if ($df == 0) { if (length($subject) > 46) { $subject = substr($subject,0,46); } if ($target == $page && $tcolor == 1) { $f5 = "$subject"; } else { $f5 = $subject; } } else { $f5 = "$subject"; } $f6 = "$ref"; if ($df == 0) { print "$f1"; } else { print "$f1"; } if ($df == 0) { print "

$f2
\n"; print "$f3\n"; } else { print "
$f2
\n"; print "$f3\n"; } if ($df == 0) { print "
$f4
\n"; print "
$f6
\n"; } else { print "\n"; } if ($df == 0) { print "
\n"; } else { print "\n"; } if ($df == 0) { print "$f5\n"; } else { print "$f5\n"; } } sub search { $st = $FORM{'string'}; $st =~ s/ / /g; $st =~ s//>/g; $st =~ s/"/"/g; if ($st =~ /\*/ || $st =~ /\+/) { &error(bad_chr); } @terms = split(/ /, $st); $i = 0; if (!open(IN,"$file")) { &error(4); } @lines = ; $all_msg = @lines; $all_msg --; close(IN); foreach $line (@lines) { $match = "0"; ($date,$name,$email,$page,$keywd,$subject) = split(/\,/,$line); if (!($date =~ m#(.*)/(.*)/(.*)/(.*)/(.*)/(.*)#)) { next; } &count; if ($ref_flug != 0) { next; } if ($ref_err == 1) { next; } if ($date =~ m#(.*)/(.*)/(.*)/(.*)/(.*)/(.*)#) { $date1 = "$1\/$2\/$3 $4\:$5"; } &jcode'convert(*line,'euc'); foreach $term (@terms) { &jcode'convert(*term,'euc'); if ($FORM{'just'} eq 'ON') { if ($FORM{'how'} eq 'AND') { if (!($line =~ /$term/i)) { $match = "1"; last; } else { $match = '0'; } } else { if ($line =~ /$term/i) { $match = "0"; last; } else { $match = '1'; } } } else { if ($FORM{'how'} eq 'AND') { if (!($line =~ /$term/i)) { $match = "0"; last; } else { $match = '1'; } } else { if ($line =~ /$term/i) { $match = "1"; last; } else { $match = '0'; } } } } if ($match eq "0") { &jcode'convert(*line,'sjis'); push(@BUKKEN,$line); } } $accesses = @BUKKEN; if ($FORM{'sort'} eq "k") { @BUKKEN = reverse @BUKKEN; } print "Content-type: text/html\n\n"; print "$title\n"; &body; &header; $def = $FORM{'def'}; if ($FORM{'sort'} eq "s") { $sr = '昇順'; } else { $sr = '降順'; } if ($FORM{'how'} eq 'OR') { $how = 'または'; } else { $how = 'かつ'; } if ($FORM{'just'} eq 'ON') { $just = '正規'; } else { $just = '排他'; } print "\n"; print "\n"; print "\n"; print "
指定
条件
検索文字列検索方法絞込方法ソ\ート
$st$just$how$sr

\n"; if ($accesses != 0) { if ($accesses > $def) { print "全$all_msg件の記事の中から、指定の条件では全部で$accesses件のデータが抽出されましたので$def件ずつ表\示します。

\n"; } else { print "全$all_msg件の記事の中から、指定の条件では全部で$accesses件のデータが抽出されました。

\n"; } print "\n"; print "\n"; if ($FORM{'pg'} eq '') { $pg = 0; } else { $pg = $FORM{'pg'}; } $accesses = @BUKKEN; $accesses = $accesses - 1; $pg_end = $pg + $def - 1; if ($pg_end > $accesses) { $pg_end = $accesses; } foreach ($pg .. $pg_end) { ($date,$name,$email,$page,$keywd,$subject) = split(/\,/, $BUKKEN[$_]); if ($date =~ m#(.*)/(.*)/(.*)/(.*)/(.*)/(.*)#) { $date1 = "$1\/$2\/$3 $4\:$5"; } &count; &disp2; } print "
番号投稿日投稿者返信元参照返信題名

\n"; $pg_next = $pg_end + 1; $ip = $pg + 1; $jp = $pg_end + 1; if ($pg_end ne $accesses) { print "抽出されたデータのうち、$srで$ip番目から$jp番目までの一覧です。

\n"; print "

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print '' . "\n"; print '
' . "\n"; } else { print "抽出されたデータのうち、$srで$ip番目から最後までの一覧です。

\n"; } } else { print "指定の条件では該当がありませんでした。

\n"; } print "

\n"; } sub delete { if (!open(IN,"$axs\/$FORM{'remove'}\.dat")) { &error(no_kiji); } $ref_info = ; close(IN); ($ref_flug,$ref,$res,$pwd,$tr) = split(/:/, $ref_info); $plain_text = $FORM{'pwd'}; $encode_pwd = $pwd; &passwd_decode; if ($super ne "yes" && $pass ne "on") { &error(pw_not_same); } if ($ref_flug != 0) { &error(deleted); } if ($super eq "yes") { $ref_flug = 2; } else { $ref_flug = 1; } $filename = "$base/$FORM{'remove'}\.msg"; if (-e $filename) { rename("$base/$FORM{'remove'}\.msg","$base/$FORM{'remove'}\.$rn") || push(@RN,$FORM{'remove'}); } if (!open(OUT,">$axs\/$FORM{'remove'}\.dat")) { &error(D1); } print OUT "$ref_flug\:$ref\:$res\:$pwd\:$tr"; close(OUT); if (!open(IN,"$base_data")) { &error(14); } $num2 = ; close(IN); $target = $FORM{'pg'} = $FORM{'remove'}; $FORM{'def'} = '1'; $FORM{'fwd'} = 'adj'; $tcolor = 1; &disp; } sub undo { if (!open(IN,"$axs\/$FORM{'undo'}\.dat")) { &error(no_kiji); } $ref_info = ; close(IN); ($ref_flug,$ref,$res,$pwd,$tr) = split(/:/, $ref_info); $plain_text = $FORM{'pwd'}; $encode_pwd = $pwd; &passwd_decode; if ($super ne "yes" && $pass ne "on") { &error(pw_not_same); } if ($ref_flug eq '0') { &error(undo_yet); } if ($ref_flug eq '1' && $super eq "yes") { &error(no_undo); } $ref_flug = 0; $filename = "$base/$FORM{'undo'}\.$rn"; if (-e $filename) { rename("$base/$FORM{'undo'}\.$rn","$base/$FORM{'undo'}\.msg") || push(@RN,$FORM{'undo'}); } else { &error(U2); } if (!open(OUT,">$axs\/$FORM{'undo'}\.dat")) { &error(U1); } print OUT "$ref_flug\:$ref\:$res\:$pwd\:$tr"; close(OUT); if (!open(IN,"$base_data")) { &error(14); } $num2 = ; close(IN); $target = $FORM{'pg'} = $FORM{'undo'}; $FORM{'def'} = '1'; $FORM{'fwd'} = 'adj'; $tcolor = 1; &disp; } sub root_reset { if (!(-e "$base\/$FORM{'reset'}\.msg")) { &error(rr_err); } if (!open(OUT,">$axs\/$FORM{'reset'}\.dat")) { &error(RR1); } print OUT "0\:0\:管理者管理\:xxxxxxxxxxxxx\:"; close(OUT); print "Content-type: text/html\n\n"; print "$title\n"; &body; print "

OK

\n"; print "$FORM{'reset'}番の管理ファイルをリセットしました。今後この記事の削除と復活は管理者にのみ可能\です。

\n"; print "[記事一覧]

\n"; print "

\n"; exit; } sub count { $ref_err = 0; if (!open(IN,"$axs\/$page\.dat")) { $ref_err = 1; return; } $ref_info = ; close(IN); ($ref_flug,$ref,$res,$pwd,$tr) = split(/:/, $ref_info); if ($ref_flug eq '' || $ref_info eq '' || $pwd eq '') { $ref_err = 1; } } sub count_res { if (!open(IN,"$axs\/$fup_num\.dat")) { &error(12); } $ref_info = ; close(IN); ($ref_flug,$ref,$res,$pwd2,$tr) = split(/:/, $ref_info); if ($res eq '') { $res = '返信あり'; } if (!open(OUT,">$axs\/$fup_num\.dat")) { &error(12); } print OUT "$ref_flug\:$ref\:$res\:$pwd2\:$tr"; close(OUT); if (!open(OUT,">$axs\/$num\.dat")) { &error(12); } print OUT "0\:0\:$fup_num\:$pwd\:$tr"; close(OUT); } sub tree1 { if (!open(OUT,">$tree\/$num\.dat")) { return; } print OUT "

\n"; print OUT "
 <$num>\n"; print OUT "
"; print OUT "\n"; print OUT "
\n"; close(OUT); } sub tree2 { if (!open(IN,"$tree\/$tr\.dat")) { return; } @tr_file = ; close(IN); if (!open(OUT,">$tree\/$tr\.dat")) { return; } foreach $line (@tr_file) { if ($line =~ /
/) { print OUT "
\n"; print OUT "
`--$num\n"; print OUT "
"; print OUT "\n"; print OUT "
\n"; print OUT "
\n"; } else { print OUT $line; } } close(OUT); }