#!/usr/local/bin/perl
##############################################################################
# shiromuku(mt)BBS version 4.20
# Created 05/12/2002
# Copyright 2002 Shiromuku
# Available at http://www.t-okada.com/cgi/
###############################################################################
# COPYRIGHT NOTICE （著作権の告示）  
# Copyright 2002 Shiromuku All Rights Reserved.
# This script can be used and modified free of charge as long as you don't change this header or any of the parts that give me credit for writing this. （このスクリプトは無償で使用または改変できます。ただしこの著作権の告知と上記のコメント、及びCGIにより生成されるHTML表示下部にある著作権表示部は変えないで下さい。）
# By using this script you agree to indemnify me from any liability that might arise from its use.  In simple English, if this script somehow makes your computer run amuck and kill the pope, it's not my fault.（このスクリプトを使用することにより、使用者はその使用によって起こる可能性のあるいかなる事柄に対する責務についても、私Shiromukuに免責の保証を与えることに同意したものとします。）
# Redistributing and selling the code for this program without prior written consent is expressly forbidden.（前もって書面での承諾を得ることなくこのプログラムのコードを再配布したり売ったりすることは 明確に禁じられています。）

#######################
require './jcode.pl';
require './smt_bbs_lib.pl';

#######################
use strict;
my $gl = &get_globals("smt_bbs_gl.pl");
$gl->{version} = "version 4.20";

my $form;
my $config = &open_config ($gl);
if ($ENV{'CONTENT_LENGTH'} || $ENV{'QUERY_STRING'}) {
	$form = &parse_data($gl,$config);
	#if ($form->{t_type} eq "") {$form->{t_type} = $gl->{t_type};}
	$gl->{txtnumfile} = "$form->{cat}$gl->{txtnumfile}";
	$gl->{c_numfile} = "$form->{cat}$gl->{c_numfile}";
	$gl->{lockfile} = "$form->{cat}$gl->{lockfile}";
	$gl->{tempfile} = "$form->{cat}$gl->{tempfile}";
	$gl->{iconfile} = "$form->{cat}$gl->{iconfile}";
}
$config = &open_config ($gl, $form);

my %HoD = ();
@HoD{"gl", "config", "form"} = ($gl, $config, $form);

if (-e "$gl->{basedir}/$gl->{passfile}") {
if ($config->{use_view_pass}) {
	my %boardname = split(/\,/,$HoD{gl}{boardname});
	my $cookie = &get_cookie (\%boardname);
	#print "Content-type: text/html\n\n";
	#print "cookie/$cookie->{view_password}\n";
	if ($HoD{form}{view_password}) {
		&check_view_pass (\%HoD,"view_pass");
	}
	else {
		if ($cookie->{view_password}) {
			$HoD{form}{view_password} = $cookie->{view_password};
			&check_view_pass (\%HoD,"view_pass");
		}
		else {&return_login(\%HoD); exit (0) ;}
	}
}
if ($ENV{'REQUEST_METHOD'} eq "POST") {
	if ($form->{action} eq "admin_enter") {&return_admin_enter (\%HoD); exit (0) ;}
	elsif ($form->{action} eq "search_all") {&search_all (\%HoD); exit (0) ;}
	elsif ($form->{action} eq "sort") {&sort (\%HoD); exit (0) ;}
	elsif ($form->{action} eq "user") {&user (\%HoD); exit (0) ;}
	elsif ($form->{action} eq "user_a") {&user (\%HoD); exit (0) ;}
	elsif ($form->{action} eq "view_all_t") {&view_all_t (\%HoD); exit (0) ;}
}
if ($form->{action} eq "showlast") {
	if ($form->{cat} eq "") {&error("BBSを選択して下さい。\n", \%HoD);}
	unless (-e "$HoD{gl}{basedir}/$form->{cat}$gl->{configfile}") {
		&error("BBSがありません。\n", \%HoD);
	}
	&return_html (\%HoD);
}
elsif ($form->{action} eq "show_titles") {&show_titles (\%HoD);}
elsif ($form->{action} eq "show_top") {&show_top (\%HoD);}
elsif ($form->{action} eq "return_main") {&return_main (\%HoD);}
elsif ($form->{action} eq "show_all") {&show_all (\%HoD);}
elsif ($form->{action} eq "show") {&show (\%HoD);}
elsif ($form->{action} eq "reply") {&return_html (\%HoD);}
elsif ($form->{action} eq "show_icon") {&show_icon (\%HoD);}
elsif ($form->{action} eq "key_img") {&key_image (\%HoD);}
else {&show_top (\%HoD);}
}
else {
	&head("管理用ページ", \%HoD);
	print "<BR><CENTER><H4>IDとパスワードの設定をする</H4></CENTER>\n";
	print "<BR><CENTER>まず最初にIDとパスワードの設定をして下さい<BR></CENTER>\n";
	print "<BR><form METHOD=\"POST\"  ACTION=\"$gl->{cgi_a}\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"make_pass\">\n";
	print "<CENTER><TABLE BORDER=1 CELLPADDING=5 CELLSPACING=0>\n";
	print "<TR><TD>ユーザID</TD><TD><INPUT TYPE=\"text\" NAME=\"username\" maxlength=8><BR>（半角英数字で８文字以内にして下さい。）</TD></TR>\n";
	print "<TR><TD>パスワード</TD><TD><INPUT TYPE=\"password\" NAME=\"password\" maxlength=8><BR>（半角英数字で８文字以内にして下さい。）</TD></TR>\n";
	print "<TR><TD>パスワード</TD><TD><INPUT TYPE=\"password\" NAME=\"password1\" maxlength=8><BR>（確認のためもう一度）</TD></TR></TABLE></CENTER>\n";
	print "<BR><CENTER><INPUT TYPE=\"SUBMIT\" NAME=\"config\" VALUE=\"設定をする\"></CENTER>\n";
	print "</form>\n";
	print "</BODY></HTML>\n";
}
exit (0) ;

############################
sub parse_data {
	my ($gl,$config) = @_;
	my ($buffer, @pairs, $pair, $name, %form, $value); 
	if ($ENV{'REQUEST_METHOD'} eq "POST") {
		if ($config->{check_referer} == 1) {&check_referer($gl,$config);}
		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;
		 if (($value =~ /\W/) && ($ENV{'REQUEST_METHOD'} ne "POST")) {
			&error("エラーです。\n");
		}
		$value =~ s/\|\|\|//g;
		$value =~ s/</&lt;/ig; 
		$value =~ s/>/&gt;/ig;
		$value =~ s/\r\n/<BR>/g;
		$value =~ s/\r/<BR>/g;
		$value =~ s/\n/<BR>/g;
		if (($name eq "email") && ($value !~ /^[\w\.\-]+\@[\w\.\-\_]+\.[a-zA-Z]+$/)) {
			$value = "";
		}
		if (($name eq "url") && ($value eq "http://")) {$value = "";}
		jcode::convert(\$value,$gl->{mycode});
		if ($gl->{mycode} eq 'sjis') {jcode::h2z_sjis(\$value); }
		if ($gl->{mycode} eq 'euc')  {jcode::h2z_euc(\$value); }
		$form{$name} = $value;
	}
	return \%form;
}

############################
#トップページ
sub show_top{
	my $HoD = shift;
	print "Content-type: text/html\n\n";
	print "<HTML>\n";
	print "<HEAD>\n";
	print "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;charset=EUC-JP\">\n";
	#print "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n";
	print "<TITLE>$HoD->{config}{c1_image}</TITLE></HEAD>\n";
	print "<FRAMESET cols=\"$HoD->{config}{cols},*\" frameborder=\"no\">\n";
	print "<FRAME SRC=\"$HoD->{gl}{cgi}?action=show_titles\" name=\"frame\">\n";
	print "<FRAME SRC=\"$HoD->{gl}{cgi}?action=return_main\" name=\"main\">\n";
	print "<NOFRAMES><BODY><P>このページをご覧いただくにはフレーム対応のブラウザが必要です。</P></BODY></NOFRAMES>\n";
	print "</FRAMESET>\n";
	print "</HTML>\n";
}

############################
#メインページ
sub show_titles {
	my $HoD = shift;
	my ($page_maxs, $p, $ps, $p_flag, $new_mark, @data, $yearn1, $monn1, $dayn1, $hourn1, $minn1, $secn1, $week1, $date1, $time1, $timex1, $pp_flag, %last);
	my ($yearn, $monn, $dayn, $hourn, $minn, $secn, $week, $date, $time, $timex) = &date_time;
	if (($HoD->{config}{img_n_mark} eq "") || ($HoD->{config}{img_n_mark} eq "http://")) {$HoD->{config}{img_n_mark} = $HoD->{config}{c1_n_comment};}
	else {$HoD->{config}{img_n_mark} = "<IMG SRC=\"$HoD->{config}{img_n_mark}\">";}
	if (($HoD->{config}{img_n_mark1} eq "") || ($HoD->{config}{img_n_mark1} eq "http://")) {$HoD->{config}{img_n_mark1} = $HoD->{config}{c1_n_comment1};}
	else {$HoD->{config}{img_n_mark1} = "<IMG SRC=\"$HoD->{config}{img_n_mark1}\">";}
	my $file = &file_open("$HoD->{gl}{basedir}/$HoD->{gl}{catfile}",1);
	&head_html(\*STDOUT,$HoD);
	print "$HoD->{config}{c2_title}\n";
	print "$HoD->{config}{c2_introduction}\n";
	$HoD->{config}{n_page_max} = $HoD->{config}{n_page_max2};
	if (@{$file}) {
		if (!$HoD->{form}{next_page}) { $page_maxs = $HoD->{config}{n_page_max}; $p = 0; $HoD->{form}{next_page} = 0; $ps = 0;}
		else { $page_maxs = $HoD->{form}{next_page} + $HoD->{config}{n_page_max}; $p = 0; $ps = $HoD->{form}{next_page};}
		#print "<CENTER><TABLE WIDTH=\"$HoD->{config}{t_width1}\"><TR><TD><FONT SIZE=2>\n";
		#print "※$HoD->{config}{n_show_new_time}時間以内に新規投稿されたBBSには$HoD->{config}{n_mark}マークが付いています。\n";
		#print "</FONT></TD></TR></TABLE></CENTER>\n";
		if ($HoD->{config}{table_color1}) {
			if ($HoD->{config}{border_color1}) {
				print "<CENTER><TABLE WIDTH=\"$HoD->{config}{t_width1}\" BORDER=1 CELLSPACING=0 CELLPADDING=5 BORDERCOLOR=\"$HoD->{config}{border_color1}\" BGCOLOR=\"$HoD->{config}{table_color1}\">\n";
			}
			else {
				print "<CENTER><TABLE WIDTH=\"$HoD->{config}{t_width1}\" BORDER=0 CELLSPACING=0 CELLPADDING=5 BGCOLOR=\"$HoD->{config}{table_color1}\">\n";
			}
		}
		else {
			if ($HoD->{config}{border_color1}) {
				print "<CENTER><TABLE WIDTH=\"$HoD->{config}{t_width1}\" BORDER=1 CELLSPACING=0 CELLPADDING=5 BORDERCOLOR=\"$HoD->{config}{border_color1}\">\n";
			}
			else {
				print "<CENTER><TABLE WIDTH=\"$HoD->{config}{t_width1}\" BORDER=0 CELLSPACING=0 CELLPADDING=1>\n";
			}
		}
		foreach (@{$file}) {
			@data = split(/\|\|\|/,$_);
			if  ($p >= $page_maxs) {
				$pp_flag = 1;
				last;
			}
			if  (($p < $page_maxs) && ($p >= $HoD->{form}{next_page})) {
				if (($timex - $data[6]) > ($HoD->{config}{n_show_new_time} * 3600)) {$new_mark ="";}
				else {$new_mark = $HoD->{config}{img_n_mark};}
				$date1 = "";
				if ($data[6]) {
					($yearn1, $monn1, $dayn1, $hourn1, $minn1, $secn1, $week1, $date1, $time1, $timex1) = &date_time($data[6]);
				}
				if ($date1 eq $date) {$date1 = $HoD->{config}{img_n_mark1};}
				elsif (!$date1) {$date1 = "未登録";}
####### これがカウンター表示部かも
				print "<TR><TD NOWRAP><A HREF=\"$HoD->{gl}{cgi}?action=showlast&cat=$data[1]&txtnumber=log\" style=\"text-decoration:none\" TARGET=main>\n";
####### これがカウンター表示部かも
				if ($data[4] && ($data[4] ne 'http://')) {
					print "<IMG SRC=$data[4] BORDER=0 ALIGN=\"middle\">&nbsp;";
				}
				print "$data[2]</A>\n";
				if ($data[3]) {print "($data[3])\n";}
				print "（$date1)$new_mark\n";
				print "</TD></TR>\n";
				$ps++;
			}
			$p++;
		}
		print "</TABLE></CENTER>\n";
	}
	$last{ps} = $ps;
	$last{page_maxs} = $page_maxs;
	$last{p_flag} = $pp_flag;
	$HoD->{last} = {%last};
	&last_html ($HoD);
	print "$HoD->{config}{c2_back1}\n";
	$HoD->{form}{cat} = "";
	&foot_html1 (\*STDOUT,$HoD);
}

############################
#ページ移動
sub last_html {
	my $HoD = shift;
	my ($page, $i, $k);
	my $next_pages = $HoD->{last}{ps};
	my $prev_page = $HoD->{form}{next_page} - $HoD->{config}{n_page_max};
	print "<CENTER><TABLE><TR>\n";
	if (($prev_page >= 0) && ($HoD->{last}{page_maxs} != $HoD->{config}{n_page_max})) {
		print "<form METHOD=\"POST\" ACTION=\"$HoD->{gl}{cgi}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"cat\" VALUE=\"$HoD->{form}{cat}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"$HoD->{form}{action}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"txtnumber\" VALUE=\"$HoD->{form}{txtnumber}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"mynum\" VALUE=\"$HoD->{form}{mynum}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"t_type\" VALUE=\"$HoD->{form}{t_type}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"searchword\" VALUE=\"$HoD->{form}{searchword}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"searchword_a\" VALUE=\"$HoD->{form}{searchword_a}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"searchword_b\" VALUE=\"$HoD->{form}{searchword_b}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"s\" VALUE=\"$HoD->{form}{s}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"next_page\" VALUE=\"$prev_page\">\n";
		print "<TD ALIGN=\"center\"><INPUT TYPE=\"SUBMIT\" VALUE=\"Prev\"></TD></form>\n";
	}
	if ($HoD->{last}{p_flag} == 1) {
		print "<form METHOD=\"POST\" ACTION=\"$HoD->{gl}{cgi}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"cat\" VALUE=\"$HoD->{form}{cat}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"$HoD->{form}{action}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"txtnumber\" VALUE=\"$HoD->{form}{txtnumber}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"mynum\" VALUE=\"$HoD->{form}{mynum}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"t_type\" VALUE=\"$HoD->{form}{t_type}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"searchword\" VALUE=\"$HoD->{form}{searchword}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"searchword_a\" VALUE=\"$HoD->{form}{searchword_a}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"searchword_b\" VALUE=\"$HoD->{form}{searchword_b}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"s\" VALUE=\"$HoD->{form}{s}\">\n";
		print "<INPUT TYPE=\"HIDDEN\" NAME=\"next_page\" VALUE=\"$next_pages\">\n";
		print "<TD ALIGN=\"center\"><INPUT TYPE=\"SUBMIT\" VALUE=\"Next\"></TD></form>\n";
	}
	if ($HoD->{form}{txtnumber} && $HoD->{last}{p1}) {
		print "<TD>\n";
		if ($HoD->{form}{txtnumber} eq "log") {print "<B>現行ログ</B>/\n";}
		else {print "Log<B>$HoD->{form}{txtnumber}</B>/\n";}
		if ($HoD->{last}{p1}) {
			$page = int($HoD->{last}{p1}/$HoD->{config}{n_page_max});
			if ((($HoD->{last}{p1} % $HoD->{config}{n_page_max}) > 0) || ($HoD->{config}{n_page_max} == 0)) {++$page;}
			$i = 1; $k = 0;
			while ($i <= $page) {
				if ($HoD->{form}{next_page} == $k) {
					print "[<B>$i</B>]\n";
				}
				else {
					print "<A HREF=\"$HoD->{gl}{cgi}?action=$HoD->{form}{action}&cat=$HoD->{form}{cat}&txtnumber=$HoD->{form}{txtnumber}&next_page=$k&t_type=$HoD->{form}{t_type}&mynum=$HoD->{form}{mynum}\" style=\"text-decoration:none\">[<B>$i</B>]</A>\n";
				}
				++$i; $k += $HoD->{config}{n_page_max};
			}
		}
		print "</TD>\n";
	}
	print "</TR></TABLE></CENTER>\n";
}

############################
#トップページ
sub return_main{
	my $HoD = shift;
	$HoD->{config}{img_bkgd_img} = $HoD->{config}{img_bkgd_img2};
	$HoD->{config}{bgcolor} = $HoD->{config}{bgcolor2};
	$HoD->{config}{c2_stylesheet} = $HoD->{config}{c2_stylesheet2};
	$HoD->{config}{text_color} = $HoD->{config}{text_color2};
	$HoD->{config}{link_color} = $HoD->{config}{link_color6};
	$HoD->{config}{link_color2} = $HoD->{config}{link_color7};
	$HoD->{config}{link_color3} = $HoD->{config}{link_color8};
	&head_html(\*STDOUT,$HoD);
	print "$HoD->{config}{c2_top}\n";
	#print "$HoD->{config}{c2_back}\n";
	&foot_html1 (\*STDOUT, $HoD);
}

############################
#書き込みと最新記事表示用のメインページ
sub return_html{
	my $HoD = shift;
	my (@i_data, %DATA, @titles, $page_maxs, $p, $next_page1, $ps, $mt_number, $title, $p_flag, $cnt, $p1, $ps1, $p_flag1, $mt_cnt, $t_flag, $t_cnt, @last_data, $res_num, $page_maxs4, @pp_data, @child_data, @data, $c_num, $marktop_pp, %last, $p_flag_mt, @titles1,%DATA1,$r_flag,%DATA2);
	if (!$HoD->{form}{cat}) {&error("BBSが選択されていません。\n", $HoD);}
	my $cookie;
	my %boardname = split(/\,/,$HoD->{gl}{boardname});
	if ($HoD->{form}{action} ne "reply") {
	if ($HoD->{config}{use_type1} && $HoD->{config}{remember_type}) {
		if ($HoD->{config}{usepasscookie} == 1) {
			if ($HoD->{form}{t_type}) {
				$HoD->{cookie} = ();
				$HoD->{cookie}{t_type} = $HoD->{form}{t_type};
				&set_cookie ($boardname{"type"}, $HoD);
			}
			else {
				$cookie = &get_cookie (\%boardname);
				$HoD->{form}{t_type} = $cookie->{t_type};
			}
		}
	}
	}
	if ($HoD->{form}{t_type} eq "") {$HoD->{form}{t_type} = $HoD->{config}{t_type};}
	if ($HoD->{form}{txtnumber} eq "") {$HoD->{form}{txtnumber} = "log";}
	if ($HoD->{form}{action} eq "") {$HoD->{form}{action} = "showlast";}
	if ($HoD->{form}{action} ne "reply") {
		if ($HoD->{config}{show_counter}) {$c_num = &counter ($HoD);}
	}
	my $cat_data = &get_catname ($HoD->{form}{cat}, $HoD);
	my $cat_name_j_t = $cat_data->[2];
	$cat_name_j_t =~ s/<([^>]|\n)*>//g;
	my ($yearn, $monn, $dayn, $hourn, $minn, $secn, $week, $x, $y, $timex) = &date_time();
	if ($HoD->{config}{n_page_max_tp1} eq "") {
		$HoD->{config}{n_page_max_tp1} = $HoD->{config}{n_page_max1};
	}
	if ($HoD->{form}{action} eq "reply") {$HoD->{config}{n_page_max} = $HoD->{config}{n_page_max_tp1};}
	else {
	if ($HoD->{form}{t_type} eq "normal") {$HoD->{config}{n_page_max} = $HoD->{config}{n_page_max1};}
	elsif ($HoD->{form}{t_type} eq "mt") {$HoD->{config}{n_page_max} = $HoD->{config}{n_page_max_mt};}
	elsif ($HoD->{form}{t_type} eq "topic") {$HoD->{config}{n_page_max} = $HoD->{config}{n_page_max_tp};}
	}
	if (($HoD->{config}{img_c_mark} eq "") || ($HoD->{config}{img_c_mark} eq "http://")) {$HoD->{config}{img_c_mark} = $HoD->{config}{c1_c_comment};}
	else {$HoD->{config}{img_c_mark} = "<IMG SRC=\"$HoD->{config}{img_c_mark}\">";}
	if (($HoD->{config}{img_n_mark2} eq "") || ($HoD->{config}{img_n_mark2} eq "http://")) {$HoD->{config}{img_n_mark2} = $HoD->{config}{c1_n_comment2};}
	else {$HoD->{config}{img_n_mark2} = "<IMG SRC=\"$HoD->{config}{img_n_mark2}\">";}
	if ($HoD->{form}{action} ne "reply") {
	if ($HoD->{form}{txtnumber} ne "log") {
		$HoD->{config}{c1_image} = "$cat_name_j_t/Log$HoD->{form}{txtnumber}";
		&head_html(\*STDOUT,$HoD);
		print "<CENTER><H3>$cat_name_j_t/Log$HoD->{form}{txtnumber}</H3></CENTER>\n";
		&top_html ($HoD);
	}
	else {
		$HoD->{config}{c1_image} = $cat_name_j_t;
		&head_html(\*STDOUT,$HoD);
		if ($HoD->{config}{show_counter}) {
			print "<FONT COLOR=\"$HoD->{config}{title_color}\" SIZE=2>$c_num</FONT>\n";
		}
		if ($HoD->{config}{c2_title1}) {print "$HoD->{config}{c2_title1}\n";}
		else {print "<CENTER><H3>$cat_name_j_t</H3></CENTER>\n";}
######## 追加
	print "　　　　　　<script language=\"javascript\">sID='set';writePM\(sID\)</script><script language=\"javascript\">startA\('s'\+sID\)</script><script language=\"javascript\">endA\(\)</script>←時計<div id=\"sset\"><script language=\"javascript\">chkHide\('s'\+sID\);</script><div class=\"expandoIndent\">\n<div id=\"clock1\" class=\"drag\" lang=\"ja\" style=\"left: 30px; top: 80px; width: 220px;\"><p>\n";
	print "<h2 onmousedown=\"startDrag\(event, 'clock1'\)\">\n";
	print "<script src=\"http://www.clocklink.com/embed.js\"></script><script type=\"text/javascript\" language=\"JavaScript\">obj=new Object;obj.clockfile=\"0001p-blue.swf\";obj.TimeZone=\"JST\";obj.width=150;obj.height=150;obj.Place=\"JAPAN\";obj.wmode=\"transparent\";showClock\(obj\);</script>\n";
	print "</h2>\n";
	print "</div></div></div>\n";
######## 追加
		&top_html ($HoD);
	}
	print "$HoD->{config}{c2_introduction}\n";
#	print "<BR>\n";
#	if (($HoD->{form}{txtnumber} eq "log") && !$HoD->{config}{read_only}){
####### 追加▽
	if ($HoD->{form}{txtnumber} eq "log"){
####### 追加△
		&add_form_html ("main", $HoD);
#		print "<BR>\n";
	}
	if ($HoD->{form}{t_type} eq "tree") {
		print "<FONT SIZE=2>\n";
		if ($HoD->{config}{img_all_icon}) {
			print "<IMG SRC=\"$HoD->{config}{img_all_icon}\" BORDER=0>をクリックすると、ツリー内全記事内容一括表示。\n";
		}
		else {
			print "<FONT $HoD->{config}{c1_titles_color}>▼</FONT>をクリックすると、ツリー記事が一括して表示されます。\n";
		}
#		print "<BR>※$HoD->{config}{n_show_new_time1}時間以内の投稿記事には$HoD->{config}{img_n_mark2}マークが付きます。\n";
####### 追加
		print "※$HoD->{config}{n_show_new_time1}時間以内の投稿記事には$HoD->{config}{img_n_mark2}マークが付きます。\n";
####### 追加
#		print "</FONT><BR><BR>\n";
####### 追加
		print "</FONT>\n";
####### 追加
	}
	}
####### Replyだった時
	else {
	$HoD->{config}{c1_t_comment} ="<FONT SIZE=-1><B>Reply to the Message&nbsp;[$HoD->{form}{mynum}]</B></FONT>";
	$HoD->{config}{c1_image} = "Reply to the Message&nbsp;[$HoD->{form}{mynum}]";
	&head_html(\*STDOUT,$HoD);
	print "<CENTER><H3>Reply to the Message&nbsp;[$HoD->{form}{mynum}]</H3></CENTER>\n";
	if ($HoD->{config}{border_color}) {
#		print "<BR><HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2 COLOR=\"$HoD->{config}{border_color}\">\n";
		print "<HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2 COLOR=\"$HoD->{config}{border_color}\">\n";
	}
	else {
#		print "<BR><HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2>\n";
		print "<HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2>\n";
	}
#	print "<CENTER><FONT SIZE=2>\n";
	print "<CENTER><FONT SIZE=1>\n";
	if ($HoD->{config}{img_back_url}) {
		print "[<A HREF=\"$HoD->{config}{img_back_url}\" TARGET=_top>HOME</A>]&nbsp;\n";
	}
	if ($HoD->{form}{txtnumber} ne "log") {
		print "[<A HREF=$HoD->{gl}{cgi}?action=showlast&cat=$HoD->{form}{cat}&txtnumber=log&t_type=$HoD->{form}{t_type} style=\"text-decoration:none\">BBS TOP</A>]&nbsp;\n";
	}
	print "[<A HREF=$HoD->{gl}{cgi}?action=showlast&cat=$HoD->{form}{cat}&txtnumber=$HoD->{form}{txtnumber}&t_type=$HoD->{form}{t_type} style=\"text-decoration:none\">BACK</A>]&nbsp;\n";
	if ($HoD->{form}{txtnumber} eq "log") {
		print "[<A HREF=$HoD->{gl}{cgi}?action=reply&mynum=$HoD->{form}{mynum}&txtnumber=$HoD->{form}{txtnumber}&cat=$HoD->{form}{cat}&t_type=$HoD->{form}{t_type}#r_form>返信を書き込む</A>]&nbsp;\n";
	}
	print "[<A HREF=\"$HoD->{gl}{cgi_u}?action=show_search&cat=$HoD->{form}{cat}\">記事検索</A>]&nbsp;\n";
	print "[<A HREF=\"$HoD->{gl}{cgi_u}?action=admin_enter&txtnumber=$HoD->{form}{txtnumber}&cat=$HoD->{form}{cat}\">管理用</A>]\n";
	print "</FONT></CENTER>\n";
	if ($HoD->{config}{border_color}) {
#		print "<HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2 COLOR=\"$HoD->{config}{border_color}\"><BR>\n";
		print "<HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2 COLOR=\"$HoD->{config}{border_color}\">\n";
	}
	else {
#		print "<HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2><BR>\n";
		print "<HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2>\n";
	}
	}
	if (!$HoD->{form}{next_page}) { $page_maxs = $HoD->{config}{n_page_max}; $p1 = 0; $HoD->{form}{next_page} = 0; $ps1 = 0;}
	else { $page_maxs = $HoD->{form}{next_page} + $HoD->{config}{n_page_max}; $p1 = 0; $ps1 = $HoD->{form}{next_page};}
	open(LOG,"<$HoD->{gl}{basedir}/$HoD->{form}{cat}_$HoD->{form}{txtnumber}\.pl");
	while (<LOG>) {
		chomp;
		next if /^\d+$/;
		my@i_data = split(/\|\|\|/,$_);
		if ($HoD->{form}{action} eq "reply") {
			unless ((($i_data[2] eq "") && ($i_data[3] == $HoD->{form}{mynum})) || (($i_data[2])  && ($i_data[1] == $HoD->{form}{mynum}))) {next;}
		}
		if ($HoD->{form}{action} ne "reply") {
		if  ($p1 >= $page_maxs) {$p_flag1 = 1;}
		if  ($p1 >= $HoD->{config}{n_page_max3}) {$p_flag_mt = 1;}
		}
		if ($HoD->{form}{action} ne "reply") {
		if ((!$i_data[2] && ($p1 < $page_maxs) && ($p1 >= $HoD->{form}{next_page})) || ($i_data[2] && ($p1 <= $page_maxs) && ($p1 > $HoD->{form}{next_page}))) {
			if (!$i_data[2]) {
				push @titles, $i_data[1];
				if ($HoD->{form}{action} ne "reply") {$ps1++;}
			}
			#else {
				#if ($HoD->{form}{action} eq "reply") {$ps1++;}
			#}
			push @{$DATA{$i_data[1]}}, $_;
		}
		}
		else {
			if (!$i_data[2]) {
				push @titles, $i_data[1];
				push @{$DATA2{$i_data[1]}}, $_;
			}
			else {
				#if ((!$i_data[2] && ($p1 < $page_maxs) && ($p1 >= $HoD->{form}{next_page})) || ($i_data[2] && ($p1 <= $page_maxs) && ($p1 > $HoD->{form}{next_page}))) {
					#$ps1++;
					push @{$DATA2{$i_data[1]}}, $_;
				#}
			}
		}
		if ($HoD->{form}{action} ne "reply") {
		if ($HoD->{form}{t_type} eq "mt") {
			if  ((($p1 < $HoD->{config}{n_page_max3}) && ($p1 >= 0)) && !$i_data[2]){
				push @titles1, $i_data[1];
				push @{$DATA1{$i_data[1]}}, $_;
			}
			if  ((($p1 <= $HoD->{config}{n_page_max3}) && ($p1 >= 0)) && $i_data[2]){
				push @{$DATA1{$i_data[1]}}, $_;
			}
		}
		}
		if (!$i_data[2]) {
			if ($HoD->{form}{action} ne "reply") {$p1++;}
		}
		#else {
			#if ($HoD->{form}{action} eq "reply") {$p1++;}
		#}
	}
	close(LOG);
	if ($HoD->{form}{action} eq "reply") {
		my $temp = shift @{$DATA2{$HoD->{form}{mynum}}};
		if ($HoD->{config}{move_article_t}) {
			@{$DATA2{$HoD->{form}{mynum}}} = reverse @{$DATA2{$HoD->{form}{mynum}}};
		}
		foreach (@{$DATA2{$HoD->{form}{mynum}}}) {
			if  ($p1 >= $page_maxs) {$p_flag1 = 1;}
			if  (($p1 < $page_maxs) && ($p1 >= $HoD->{form}{next_page})) {
			#if ((!$i_data[2] && ($p1 < $page_maxs) && ($p1 >= $HoD->{form}{next_page})) || ($i_data[2] && ($p1 <= $page_maxs) && ($p1 > $HoD->{form}{next_page}))) {
				$ps1++;
				push @{$DATA{$HoD->{form}{mynum}}}, $_;
			}
			$p1++;
		}
		unshift @{$DATA{$HoD->{form}{mynum}}}, $temp;
	}
	#print "$p1/$ps1/!!\n";
####### 新規投稿で表示形式がトピックの時
	if ($HoD->{form}{action} ne "reply") {
	if ($HoD->{form}{t_type} eq "topic") {
		print "<CENTER>\n";
		if ($HoD->{config}{table_color}) {
			if ($HoD->{config}{border_color}) {
				print "<TABLE WIDTH=\"$HoD->{config}{t_width}\" BORDER=1 CELLSPACING=0 CELLPADDING=4 BORDERCOLOR=\"$HoD->{config}{border_color}\" BGCOLOR=\"$HoD->{config}{table_color}\">\n";
			}
			else {
				print "<TABLE WIDTH=\"$HoD->{config}{t_width}\" BORDER=0 CELLSPACING=0 CELLPADDING=4 BGCOLOR=\"$HoD->{config}{table_color}\">\n";
			}
		}
		else {
			if ($HoD->{config}{border_color}) {
				print "<TABLE WIDTH=\"$HoD->{config}{t_width}\" BORDER=1 CELLSPACING=0 CELLPADDING=4 BORDERCOLOR=\"$HoD->{config}{border_color}\">\n";
			}
			else {
				print "<TABLE WIDTH=\"$HoD->{config}{t_width}\" BORDER=0 CELLSPACING=0 CELLPADDING=4>\n";
			}
		}
		if ($HoD->{config}{td_color}) {print "<TR BGCOLOR=$HoD->{config}{td_color}>\n";}
		else {print "<TR>\n";}
		if ($HoD->{config}{use_topic_icon}) {
			print "<TD ALIGN=\"CENTER\" NOWRAP>アイコン</TD>\n";
		}
		print "<TD ALIGN=\"CENTER\" NOWRAP>記事No.</FONT>\n";
		print "<TD ALIGN=\"CENTER\" NOWRAP>タイトル</TD>\n";
		print "<TD ALIGN=\"CENTER\" NOWRAP>トピック作成者</TD>\n";
		print "<TD ALIGN=\"CENTER\" NOWRAP>最終発言者</TD>\n";
		print "<TD ALIGN=\"CENTER\" NOWRAP>返信数</TD>\n";
		print "<TD ALIGN=\"CENTER\" NOWRAP>更新情報</TD>\n";
		if ($HoD->{config}{use_check}) {
			print "<TD ALIGN=\"CENTER\" NOWRAP>解決</TD>\n";
		}
		print "</TR>\n";
	}
####### 新規投稿で表示形式がスレッドの時
	if ($HoD->{form}{t_type} eq "mt") {
		#print "<CENTER>\n";
		&table_html ($HoD);
		#print "<CENTER><TABLE WIDTH=\"$HoD->{config}{t_width}\" BORDER=1 CELLSPACING=0 CELLPADDING=2><TR><TD><TABLE><TR><TD>\n";
		print "スレッド一覧（かっこ内の数字は記事数）<BR>\n";
		#$page_maxs = $HoD->{config}{n_page_max3}; $p = 0; $next_page1 = 0; $ps = 0;
		$mt_number = 1;
		foreach $title (@titles1) {
			#if  ($p >= $page_maxs) {
				#$p_flag = 1;
				#last;
			#}
			#if  (($p < $page_maxs) && ($p >= $next_page1)) {
				@data = split(/\|\|\|/,$DATA1{$title}[0]);
				$cnt = @{$DATA1{$title}};
				if ($mt_number <= $HoD->{config}{n_page_max_mt}) {
					print "<B>$mt_number</B>:<A HREF=$HoD->{gl}{cgi}?action=showlast&cat=$HoD->{form}{cat}&txtnumber=$HoD->{form}{txtnumber}&t_type=$HoD->{form}{t_type}#$data[1]>$data[9]</A>($cnt)&nbsp;\n";
				}
				else {
					print "$mt_number:&nbsp;<A HREF=$HoD->{gl}{cgi}?action=show_all&txtnumber=$HoD->{form}{txtnumber}&pp_num=$data[1]&cat=$HoD->{form}{cat}&t_type=$HoD->{form}{t_type}>$data[9]</A>($cnt)\n";
				}
				#$ps++;  
				++$mt_number;
			#}
			#$p++;
		}
		print "</TD></TR>\n";
		if ($p_flag_mt) {&last_html_mt ($HoD);}
		print "</TABLE></CENTER></TD></TR></TABLE></CENTER><BR>\n";
	}
	}
	#if ($HoD->{form}{t_type} eq "mt") {
		#if (!$HoD->{form}{next_page}) { $page_maxs = $HoD->{config}{n_page_max}; $p1 = 0; $HoD->{form}{next_page} = 0; $ps1 = 0;}
		#else { $page_maxs = $HoD->{form}{next_page} + $HoD->{config}{n_page_max}; $p1 = 0; $ps1 = $HoD->{form}{next_page};}
	#}
	foreach $title (@titles) {	#記事を展開
		#if  (($p1 >= $page_maxs) && ($HoD->{form}{t_type} eq "mt")) {
			#$p_flag1 = 1;
			#last;
		#}
		#if  (($HoD->{form}{t_type} ne "mt") || (($p1 < $page_maxs) && ($p1 >= $HoD->{form}{next_page}))) {
			$mt_cnt = 0;
			@pp_data = split(/\|\|\|/,$DATA{$title}[0]);	#元記事
			$marktop_pp = $pp_data[0]; ++$marktop_pp;
			if (($timex - $pp_data[17]) > ($HoD->{config}{n_show_new_time1} * 3600)) {
				$HoD->{form}{new_mark} ="";
			}
			else {$HoD->{form}{new_mark} = $HoD->{config}{img_n_mark2};}	#新着マーク
			if ($HoD->{form}{action} ne "reply") {
			if ($HoD->{form}{t_type} eq "tree") {	#リスト表示
				&list_html(\@pp_data, $HoD);
				$t_flag = 1;
			}
			elsif ($HoD->{form}{t_type} eq "topic") {	#トピック表示
				$t_cnt = @{$DATA{$title}}; --$t_cnt;
				@last_data = split(/\|\|\|/,$DATA{$title}[$t_cnt]);
				$HoD->{form}{t_cnt} = $t_cnt;
				&topic_html (\@pp_data, \@last_data, $HoD);
			}
			else {	#その他
				#if ($HoD->{form}{t_type} eq "normal") {print "<CENTER>\n";}
				print "<A NAME=$pp_data[1]>\n";
				&table_html ($HoD);
				&subj_date_name_hp_html ("main", \@pp_data, $HoD);
				$t_flag = 1;
			}
			}
			else {
				&table_html ($HoD);
				&subj_date_name_hp_html ("main", \@pp_data, $HoD);
				print "</TD></TR></TABLE></CENTER></TD></TR></TABLE><BR>\n";
				$r_flag = 1;
				print "<CENTER><TABLE WIDTH=\"$HoD->{config}{t_width}\" BORDER=0 CELLSPACING=0 CELLPADDING=5><TR><TD>\n";
			}
			if ($HoD->{form}{action} ne "reply") {
			if ($HoD->{form}{t_type} ne "topic") {	#子記事表示
				shift @{$DATA{$title}};	#元記事を除く
				$res_num = @{$DATA{$title}};	#レスの数
				if ($HoD->{form}{t_type} eq "mt") {	#スレッドでは最新子記事のみ表示
					#@{$DATA{$title}} = reverse @{$DATA{$title}};
					if ($res_num > $HoD->{config}{n_page_max4}) {$page_maxs4 = $res_num - $HoD->{config}{n_page_max4};}
					else {$page_maxs4 = 0;}
				}
				foreach (@{$DATA{$title}}) {	#子記事展開
					@child_data = split(/\|\|\|/,$_);
					if (($timex - $child_data[17]) > ($HoD->{config}{n_show_new_time1} * 3600)) {
						$HoD->{form}{new_mark} ="";
					}
					else {$HoD->{form}{new_mark} = $HoD->{config}{img_n_mark2};}
					if (($HoD->{form}{t_type} eq "mt") && ($mt_cnt < $page_maxs4)){
						next;
					}
					else {
						if ($HoD->{form}{t_type} eq "tree") {&list_html(\@child_data, $HoD);}	#リスト表示
						else {
							#print "<BR>\n";
							if ((!$child_data[9]) || ($HoD->{form}{t_type} eq "mt")) {
								if ($HoD->{form}{t_type} eq "mt") {
									if ($HoD->{config}{border_color}) {
										print "<HR SIZE=\"1\" WIDTH=\"100%\" COLOR=\"$HoD->{config}{border_color}\">\n";
									}
									else {
										print "<HR SIZE=\"1\" WIDTH=\"100%\" COLOR=\"$HoD->{config}{text_color}\">\n";
									}
								}
								else {
									if ($HoD->{config}{border_color}) {
										print "<HR SIZE=\"1\" WIDTH=\"95%\" COLOR=\"$HoD->{config}{border_color}\">\n";
									}
									else {
										print "<HR SIZE=\"1\" WIDTH=\"95%\" COLOR=\"$HoD->{config}{text_color}\">\n";
									}
								}
							}
							&subj_date_name_hp_html ("reply", \@child_data, $HoD);
						}
						$t_flag = 1;
					}
				}continue{
					++$mt_cnt;
				}
				if ($HoD->{form}{t_type} ne "tree") {
					if ($HoD->{form}{t_type} eq "mt") {
						if (($HoD->{form}{txtnumber} eq "log") && ($res_num < $HoD->{config}{n_r_max1}) && !$HoD->{config}{read_only}){
							if ($HoD->{config}{border_color}) {
								print "<HR SIZE=\"1\" WIDTH=\"100%\" COLOR=\"$HoD->{config}{border_color}\">\n";
							}
							else {
								print "<HR SIZE=\"1\" WIDTH=\"100%\" COLOR=\"$HoD->{config}{text_color}\">\n";
							}
							print "<form ENCTYPE=\"multipart/form-data\" METHOD=\"POST\" ACTION=\"$HoD->{gl}{cgi_r}\">\n";
							print "<INPUT TYPE=\"HIDDEN\" NAME = \"marktop\" VALUE=\"$marktop_pp\">\n";
							print "<INPUT TYPE=\"HIDDEN\" NAME = \"pp_num\" value=\"$pp_data[1]\">\n";
							print "<INPUT TYPE=\"HIDDEN\" NAME = \"p_num\" value=\"$pp_data[3]\">\n";
							print "<INPUT TYPE=\"HIDDEN\" NAME = \"cat\" value=\"$HoD->{form}{cat}\">\n";
							print "<INPUT TYPE=\"HIDDEN\" NAME = \"action\" VALUE=\"add\">\n";
							$HoD->{form}{point} = 1;
							&add_html ($HoD,\@pp_data);
							print "</form>\n";
						}
						else {
							print "<BR>このスレッドにはこれ以上返信出来ません。\n";
						}
						print "<DIV ALIGN=right><A HREF=$HoD->{gl}{cgi}?action=show_all&txtnumber=$HoD->{form}{txtnumber}&pp_num=$pp_data[1]&cat=$HoD->{form}{cat}&t_type=$HoD->{form}{t_type}>スレッドの全記事</A></DIV>\n";
					}
					print "</TD></TR></TABLE></CENTER></TD></TR></TABLE></CENTER>\n";
					#print "<BR>\n";
					if ($HoD->{config}{img_line_url} && ($HoD->{config}{img_line_url} ne 'http://')) {
						print "<CENTER><IMG SRC=\"$HoD->{config}{img_line_url}\"></CENTER>\n";
					}
					if ((!$HoD->{config}{img_line_url}) && (!$HoD->{config}{border_color}) && (!$HoD->{config}{table_color})) {
						print "<HR SIZE=\"1\" WIDTH=\"80%\" COLOR=\"$HoD->{config}{text_color}\">\n";
					}
					print "<BR>\n";
				}
			}
			}
			else {
				shift @{$DATA{$title}};	#元記事を除く
				#if ($HoD->{config}{move_article_t}) {
					#@{$DATA{$title}} = reverse @{$DATA{$title}};
				#}
				#$res_num = @{$DATA{$title}};	#レスの数
				$res_num = @{$DATA2{$title}};
				foreach (@{$DATA{$title}}) {	#子記事展開
					@child_data = split(/\|\|\|/,$_);
					if (($timex - $child_data[17]) > ($HoD->{config}{n_show_new_time1} * 3600)) {
						$HoD->{form}{new_mark} ="";
					}
					else {$HoD->{form}{new_mark} = $HoD->{config}{img_n_mark2};}
					&subj_date_name_hp_html ("reply", \@child_data, $HoD);
					if ($HoD->{config}{border_color}) {
						print "<HR SIZE=\"1\" WIDTH=\"100%\" COLOR=\"$HoD->{config}{border_color}\">\n";
					}
					else {
						print "<HR SIZE=\"1\" WIDTH=\"100%\" COLOR=\"$HoD->{config}{text_color}\">\n";
					}
				}
				print "</TD></TR></TABLE></CENTER><BR>\n";
				$last{ps} = $ps1;
				$last{p1} = $p1;
				$last{page_maxs} = $page_maxs;
				$last{p_flag} = $p_flag1;
				$HoD->{last} = {%last};
				&last_html ($HoD);
				print "<BR>\n";
				if (($HoD->{form}{txtnumber} eq "log") && !$HoD->{config}{read_only}){
					if ($res_num < $HoD->{config}{n_r_max1}) {
						print "<BR><BR><A NAME=r_form>\n";
						&add_form_html("reply", $HoD, \@pp_data);
					}
					else {
						print "このトピックにはこれ以上返信出来ません。\n";
					}
					print "<BR><BR>\n";
				}
			}
			#if ($HoD->{form}{t_type} eq "mt") {$ps1++;}
		#}
		#if ($HoD->{form}{t_type} eq "mt") {$p1++;}
	}
	if ($HoD->{form}{action} ne "reply") {
	if (($HoD->{form}{t_type} eq "normal") || ($HoD->{form}{t_type} eq "mt")) {
		print "</TD></TR></TABLE></CENTER></TD></TR></TABLE></CENTER><BR>\n";
	}
	elsif ($HoD->{form}{t_type} eq "tree") {
		if ($HoD->{config}{border_color}) {
			print "<HR SIZE=2 COLOR=\"$HoD->{config}{border_color}\">\n";
		}
		else {
			print "<HR SIZE=2>\n";
		}
	}
	elsif ($HoD->{form}{t_type} eq "topic") {
		print "</TABLE></CENTER><BR>\n";
	}
	}
	else {
		if (!$r_flag) {print "<CENTER>該当記事がありません。</CENTER>\n";}
		&form_html ($HoD);
		&foot_html (\*STDOUT, $HoD);
	}
	if ($HoD->{form}{action} ne "reply") {
	$last{ps} = $ps1;
	$last{p1} = $p1;
	$last{page_maxs} = $page_maxs;
	$last{p_flag} = $p_flag1;
	$HoD->{last} = {%last};
	&last_html ($HoD);
	if ($HoD->{config}{use_oldlog}) {
		my $txtnum = &get_number ($HoD->{gl}{txtnumfile}, '1', $HoD);
		if (-e "$HoD->{gl}{basedir}/$HoD->{gl}{yourname}_$txtnum\.pl") {
			&last_html1($txtnum, $HoD);
		}
	}
	}
	if ($HoD->{form}{action} ne "reply") {
	if ($HoD->{form}{t_type} ne "tree") {
		if (($HoD->{form}{action} ne "selectadmin") && ($HoD->{form}{action} ne "reply") && ($HoD->{form}{action} ne "search_all")) {
			&form_html ($HoD);
		}
	}
	print "<CENTER>\n";
	&search_html ($HoD);
####### 追加
#	&sort_html ($HoD);
####### 追加
	print "</CENTER>\n";
	print "$HoD->{config}{c2_back}\n";
	&foot_html1 (\*STDOUT, $HoD);
	}
}

############################
#topic
sub topic_html {
	my($pp_data, $last_data, $HoD) = @_;
	if ($HoD->{config}{n_letters1} eq "") {$HoD->{config}{n_letters1} = 15;}
	if(!$last_data->[6]) {
		$last_data->[6] = $pp_data->[6];
		$last_data->[7] = $pp_data->[7];
	}
	#if(!$last_data->[7]) {$last_data->[7] = $pp_data->[7];}
	my ($origisubject1, $s_length);
	my$letters = $HoD->{config}{n_letters1} * 2;
	my$letters1 = $letters-1;
	$origisubject1 = $pp_data->[9];
	$s_length = length($pp_data->[9]);
	if ($s_length > $letters) {
		$origisubject1 = substr $pp_data->[9],0,$letters;
		if ($origisubject1 =~ /\x8F$/ or $origisubject1 =~ tr/\x8E\xA1-\xFE// % 2) {
			$origisubject1 = substr $pp_data->[9],0,$letters1;
		}
		$origisubject1 = "${origisubject1}..";
	}
	print "<TR>\n";
	print "<TD ALIGN=center><FONT SIZE=2><B>$pp_data->[3]</B></FONT></TD>\n";
	print "<TD ALIGN=\"CENTER\"><A HREF=$HoD->{gl}{cgi}?action=reply&mynum=$pp_data->[3]&txtnumber=$HoD->{form}{txtnumber}&cat=$HoD->{form}{cat}&t_type=$HoD->{form}{t_type}><B>$origisubject1</B></A>\n";
	print "&nbsp;$HoD->{form}{new_mark}";
	print "</TD>\n";
	if ($pp_data->[7]){
			print "<TD ALIGN=\"CENTER\"><A HREF=\"mailto:$pp_data->[7]\"><B>$pp_data->[6]</B></A></TD>\n";
	}
	else {
		print "<TD ALIGN=\"CENTER\"><B>$pp_data->[6]</B></TD>\n";
	}
	if ($last_data->[7]){
		print "<TD ALIGN=\"CENTER\"><A HREF=\"mailto:$last_data->[7]\"><B>$last_data->[6]</B></A></TD>\n";
	}
	else {
		print "<TD ALIGN=\"CENTER\"><B>$last_data->[6]</B></TD>\n";
	}
	print "<TD ALIGN=\"CENTER\" NOWRAP><B>$HoD->{form}{t_cnt}</B></TD>\n";
	print "<TD ALIGN=\"CENTER\" NOWRAP>投稿日時$pp_data->[4]/$pp_data->[5]<BR>\n";
	print "最終更新$last_data->[4]/$last_data->[5]</TD>\n";
	if ($HoD->{config}{use_check}) {
		if ($last_data->[18] eq "on") {
			print "<TD ALIGN=\"CENTER\" NOWRAP>$HoD->{config}{img_c_mark}</TD>\n";
		}
		else {
			print "<TD>&nbsp;</TD>\n";
		}
	}
	print "</TR>\n";
}

############################
#記事を見る
sub show {
	my $HoD = shift;
	my (@data, $cookie);
	my ($yearn, $monn, $dayn, $hourn, $minn, $secn, $week, $x, $y, $timex) = &date_time();
	my %boardname = split(/\,/,$HoD->{gl}{boardname});
	if ($HoD->{gl}{usepasscookie} == 1) {$cookie = &get_cookie (\%boardname);}
	my $mynumx = $HoD->{form}{mynum};
	if (!$HoD->{config}{t_width}) {$HoD->{config}{t_width} = '90%';}
	if (($HoD->{config}{img_c_mark} eq "") || ($HoD->{config}{img_c_mark} eq "http://")) {$HoD->{config}{img_c_mark} = $HoD->{config}{c1_c_comment};}
	else {$HoD->{config}{img_c_mark} = "<IMG SRC=\"$HoD->{config}{img_c_mark}\">";}
	if (($HoD->{config}{img_n_mark2} eq "") || ($HoD->{config}{img_n_mark2} eq "http://")) {$HoD->{config}{img_n_mark2} = $HoD->{config}{c1_n_comment2};}
	else {$HoD->{config}{img_n_mark2} = "<IMG SRC=\"$HoD->{config}{img_n_mark2}\">";}
	$HoD->{config}{c1_image} = "記事表示";
	&head_html(\*STDOUT,$HoD);
	#if ($HoD->{form}{txtnumber} eq "log") {print "$title \n";}
########▼ 追加
	my $cat_data = &get_catname ($HoD->{form}{cat}, $HoD);
	my $cat_name_j_t = $cat_data->[2];
	$cat_name_j_t =~ s/<([^>]|\n)*>//g;
########▲ 追加
#	print "<CENTER><H4>記事表示</H4></CENTER>\n";
########▼ 変更
	print "<CENTER><H4>“$cat_name_j_t”の記事表示\n";
########▲ 変更
######## 追加
	print "　　　　　　<script language=\"javascript\">sID='set';writePM\(sID\)</script><script language=\"javascript\">startA\('s'\+sID\)</script><script language=\"javascript\">endA\(\)</script>←時計<div id=\"sset\"><script language=\"javascript\">chkHide\('s'\+sID\);</script><div class=\"expandoIndent\">\n<div id=\"clock1\" class=\"drag\" lang=\"ja\" style=\"left: 30px; top: 80px; width: 220px;\"><p>\n";
	print "<h2 onmousedown=\"startDrag\(event, 'clock1'\)\">\n";
	print "<script src=\"http://www.clocklink.com/embed.js\"></script><script type=\"text/javascript\" language=\"JavaScript\">obj=new Object;obj.clockfile=\"0001p-blue.swf\";obj.TimeZone=\"JST\";obj.width=150;obj.height=150;obj.Place=\"JAPAN\";obj.wmode=\"transparent\";showClock\(obj\);</script>\n";
	print "</h2>\n";
	print "</div></div></div></H4></CENTER>\n";
######## 追加
	&top_html ($HoD);
	open(LOG,"<$HoD->{gl}{basedir}/$HoD->{form}{cat}_$HoD->{form}{txtnumber}\.pl");
	while (<LOG>) {
		next if /^\d+$/;
		chomp;
		@data = split(/\|\|\|/,$_);
		if (($timex - $data[17]) > ($HoD->{config}{n_show_new_time1} * 3600)) {
			$HoD->{form}{new_mark} ="";
		}
		else {$HoD->{form}{new_mark} = $HoD->{config}{img_n_mark2};}
		if ($mynumx eq $data[3]) {
			my$marktopl = $data[0]; ++$marktopl;
			print " <TABLE WIDTH=95%><TR><TD><FONT SIZE=2>記事タイトル:&nbsp;<B>$data[9]</B></FONT></TD>\n";
			print "<TD ALIGN=right><A HREF=$HoD->{gl}{cgi}?action=show_all&txtnumber=$HoD->{form}{txtnumber}&pp_num=$data[1]&cat=$HoD->{form}{cat}&t_type=$HoD->{form}{t_type}><FONT SIZE=2>関連記事一覧へ</FONT></A></TD></TR></TABLE><BR>";
			&table_html ($HoD);
			&subj_date_name_hp_html ("main", \@data, $HoD);
			print "</TD></TR></TABLE></CENTER></TD></TR></TABLE>\n";
			if ($HoD->{config}{img_line_url}) {
				print "<BR><IMG SRC=\"$HoD->{config}{img_line_url}\">\n";
			}
			if ($data[15] ne "deleted") {
#			if (($HoD->{form}{txtnumber} eq "log") && !$HoD->{config}{read_only}) {
########▼ 変更
			if ($HoD->{form}{txtnumber} eq "log") {
########▲ 変更
				print " <BR><BR><A NAME=forms></A><FONT SIZE=2>▼このメッセージに返信を書く</FONT><BR>\n";
				print "<form ENCTYPE=\"multipart/form-data\" METHOD=\"POST\" ACTION=\"$HoD->{gl}{cgi_r}\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME = \"marktop\" VALUE=\"$marktopl\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME = \"pp_num\" value=\"$data[1]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME = \"p_num\" value=\"$data[3]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME = \"cat\" value=\"$HoD->{form}{cat}\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME = \"action\" VALUE=\"add\">\n";
				&add_html ($HoD, \@data);
				print "</form>\n";
			}
			}
			print " <BR><BR><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=1><TR><form METHOD=\"POST\" ACTION=\"$HoD->{gl}{cgi}\">\n";
			print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"user\">\n";
			print "<INPUT TYPE=\"HIDDEN\" NAME=\"txtnumber\" VALUE=\"$HoD->{form}{txtnumber}\">\n";
			print "<INPUT TYPE=\"HIDDEN\" NAME = \"cat\" value=\"$HoD->{form}{cat}\">\n";
			print "<INPUT TYPE=\"HIDDEN\" NAME=\"mynum\" VALUE=\"$data[3]\">\n";
			print "<INPUT TYPE=\"HIDDEN\" NAME=\"t_type\" VALUE=\"$HoD->{form}{t_type}\">\n";
			print "<TD><FONT SIZE=2>PASS</FONT></TD><TD><INPUT TYPE=\"password\" NAME=\"pass\" SIZE=10 maxlength=10 VALUE=\"$cookie->{pass}\"></TD>\n";
			print "<TD><INPUT TYPE=\"SUBMIT\" VALUE=\"修正・削除\"></TD></form>\n";
			print "<form METHOD=\"POST\" ACTION=\"$HoD->{gl}{cgi}\">\n";
			print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"user_a\">\n";
			print "<INPUT TYPE=\"HIDDEN\" NAME=\"txtnumber\" VALUE=\"$HoD->{form}{txtnumber}\">\n";
			print "<INPUT TYPE=\"HIDDEN\" NAME = \"cat\" value=\"$HoD->{form}{cat}\">\n";
			print "<INPUT TYPE=\"HIDDEN\" NAME=\"mynum\" VALUE=\"$data[3]\">\n";
			print "<INPUT TYPE=\"HIDDEN\" NAME=\"t_type\" VALUE=\"$HoD->{form}{t_type}\">\n";
			print "<TD><FONT SIZE=2>USER</FONT></TD><TD><INPUT TYPE=\"text\" NAME=\"username\" value=\"$cookie->{username}\" size=10></TD>\n";
			print "<TD><FONT SIZE=2>PASS</FONT></TD><TD><INPUT TYPE=\"password\" NAME=\"password\" value=\"$cookie->{password}\" size=10></TD>\n";
			print "<TD><INPUT TYPE=\"SUBMIT\" VALUE=\"管理者専用\"></TD></TR></TABLE></form>\n";
			print "</TD></TR></TABLE>\n";
			print "<BR>\n";
			print "<BR><FONT SIZE=2>▼関連記事</FONT>\n";
			&show_tree ($HoD, \@data);
			last;
		}
	}
	if ($HoD->{config}{img_line_url}) {
		print "<BR><IMG SRC=\"$HoD->{config}{img_line_url}\"><BR>\n";
	}
	&back_html ($HoD);
	&foot_html (\*STDOUT, $HoD);
}

############################
#ツリーをすべて見る
sub show_tree {
	my ($HoD, $data) = @_;
	my ($yearn, $monn, $dayn, $hourn, $minn, $secn, $week, $x, $y, $timex) = &date_time();
	my@t_data;
	if (!$data->[1]) {$data->[1] = $HoD->{form}{pp_numx};}
	open(LOG,"<$HoD->{gl}{basedir}/$HoD->{form}{cat}_$HoD->{form}{txtnumber}\.pl");
	while (<LOG>) {
		next if /^\d+$/;
		chomp;
		@t_data = split(/\|\|\|/,$_);
		if (($timex - $t_data[17]) > ($HoD->{config}{n_show_new_time1} * 3600)) {
			$HoD->{form}{new_mark} ="";
		}
		else {$HoD->{form}{new_mark} = $HoD->{config}{img_n_mark2};}
		if ($data->[1] eq $t_data[1]) {&list_html(\@t_data, $HoD);}
	}
	close(LOG);
	if ($HoD->{form}{t_type} ne "normal") {
		if ($HoD->{config}{border_color}) {
			print "<HR SIZE=2 COLOR=\"$HoD->{config}{border_color}\">\n";
		}
		else {print "<HR SIZE=2>\n";}
	}
}

############################
#記事をすべて見る
sub show_all {
	my $HoD = shift;
	my@data;
	my ($yearn, $monn, $dayn, $hourn, $minn, $secn, $week, $x, $y, $timex) = &date_time();
	$HoD->{form}{pp_numx} = $HoD->{form}{pp_num};
	if (!$HoD->{config}{t_width}) {$HoD->{config}{t_width} = '90%';}
	if (($HoD->{config}{img_c_mark} eq "") || ($HoD->{config}{img_c_mark} eq "http://")) {$HoD->{config}{img_c_mark} = $HoD->{config}{c1_c_comment};}
	else {$HoD->{config}{img_c_mark} = "<IMG SRC=\"$HoD->{config}{img_c_mark}\">";}
	if (($HoD->{config}{img_n_mark2} eq "") || ($HoD->{config}{img_n_mark2} eq "http://")) {$HoD->{config}{img_n_mark2} = $HoD->{config}{c1_n_comment2};}
	else {$HoD->{config}{img_n_mark2} = "<IMG SRC=\"$HoD->{config}{img_n_mark2}\">";}
	$HoD->{config}{c1_image} = "“関連記事一括表示";
	&head_html(\*STDOUT,$HoD);
########▼ 追加
	my $cat_data = &get_catname ($HoD->{form}{cat}, $HoD);
	my $cat_name_j_t = $cat_data->[2];
	$cat_name_j_t =~ s/<([^>]|\n)*>//g;
########▲ 追加
	print "<CENTER><H4>“$cat_name_j_t”の関連記事一括表示</H4></CENTER>\n";
	&top_html ($HoD);
	print "<BR>\n";
	&show_tree ($HoD);
	print "<BR>\n";
	open(LOG,"<$HoD->{gl}{basedir}/$HoD->{form}{cat}_$HoD->{form}{txtnumber}\.pl");
	while (<LOG>) {
		next if /^\d+$/;
		chomp;
		@data = split(/\|\|\|/,$_);
		if (($timex - $data[17]) > ($HoD->{config}{n_show_new_time1} * 3600)) {
			$HoD->{form}{new_mark} ="";
		}
		else {$HoD->{form}{new_mark} = $HoD->{config}{img_n_mark2};}
		if ($HoD->{form}{pp_numx} eq $data[1]) {
			&table_html ($HoD);
			&subj_date_name_hp_html ("main", \@data, $HoD);
			if ($HoD->{form}{txtnumber} eq "log") {
				print "<DIV ALIGN=right>\n";
				&r_form_html ($HoD, \@data);
				print "</DIV>\n";
			}
			print "</TD></TR></TABLE></CENTER></TD></TR></TABLE><BR>\n";
			if ($HoD->{config}{img_line_url}) {
				print "<IMG SRC=\"$HoD->{config}{img_line_url}\">\n";
			}
			if ((!$HoD->{config}{img_line_url}) && (!$HoD->{config}{border_color}) && (!$HoD->{config}{table_color}) && (!$HoD->{config}{bg_url})) {
				print "<HR WIDTH=\"95%\">\n";
			}
		}
	}
	&form_html ($HoD);
	&back_html ($HoD);
	&foot_html (\*STDOUT, $HoD);
}

############################
#修正・削除画面
sub user {
	my $HoD = shift;
	my(@u_data, $test_pass, $flag);
	if ($HoD->{form}{cat} eq "") {&error("BBSを選択して下さい。\n", $HoD);}
	if ($HoD->{form}{mynum} eq "") {&error("番号を入力して下さい。\n", $HoD);}
	if ($HoD->{form}{action} eq "user_a") {&check_pass ($HoD);}
	if ($HoD->{form}{action} eq "user") {
		if ($HoD->{form}{pass} eq "") {&error("パスワードを入力して下さい。\n", $HoD);}
		$test_pass = &crypt ($HoD->{form}{pass}, 'aa', $HoD);
	}
	open(LOG,"<$HoD->{gl}{basedir}/$HoD->{form}{cat}_$HoD->{form}{txtnumber}\.pl") || &error("ファイルがオープンできません。\n", $HoD);
	while (<LOG>) {
		next if /^\d+$/;
		chomp;
		@u_data = split(/\|\|\|/,$_);
		if ($HoD->{form}{mynum} == $u_data[3]) {
			if ((($HoD->{form}{action} eq "user") && ($u_data[12] eq $test_pass) && ($HoD->{form}{pass} ne '') && ($u_data[15] ne "deleted")) || ($HoD->{form}{action} eq "user_a")) {
				$HoD->{config}{c1_image} = "記事[$HoD->{form}{mynum}]の修正・削除";
				&head_html(\*STDOUT,$HoD);
########▼ 追加
	my $cat_data = &get_catname ($HoD->{form}{cat}, $HoD);
	my $cat_name_j_t = $cat_data->[2];
	$cat_name_j_t =~ s/<([^>]|\n)*>//g;
########▲ 追加
########▼ 変更
#				print "<CENTER><H3>記事[$HoD->{form}{mynum}]の修正・削除</H3></CENTER>\n";
				print "<CENTER><H3>$cat_name_j_tの記事[$HoD->{form}{mynum}]の修正・削除</H3></CENTER>\n";
########▲ 変更
				if ($HoD->{form}{action} eq "user_a") {
					print "<CENTER><FONT SIZE=2>投稿者情報&nbsp;$u_data[14]</FONT></CENTER><BR>\n";
				}
####### $u_data[24]以降を追加
				if ($u_data[13] || $u_data[21] || $u_data[22] || $u_data[23] || $u_data[24] || $u_data[25] || $u_data[26] || $u_data[27] || $u_data[28] || $u_data[29] || $u_data[30] || $u_data[31] || $u_data[32] || $u_data[33] || $u_data[34] || $u_data[35]) {
####### $u_data[24]以降を追加
					print "<CENTER><TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"5\"><TR>\n";
					print "<TD VALIGN=bottom ALIGN=center>\n";
					if ($u_data[13]) {&img_html($u_data[13],$HoD);}
					if ($u_data[21]) {&img_html($u_data[21],$HoD);}
					if ($u_data[22]) {&img_html($u_data[22],$HoD);}
					if ($u_data[23]) {&img_html($u_data[23],$HoD);}
####### 追加
					if ($u_data[24]) {&img_html($u_data[24],$HoD);}
					if ($u_data[25]) {&img_html($u_data[25],$HoD);}
					if ($u_data[26]) {&img_html($u_data[26],$HoD);}
					if ($u_data[27]) {&img_html($u_data[27],$HoD);}
					if ($u_data[28]) {&img_html($u_data[28],$HoD);}
					if ($u_data[29]) {&img_html($u_data[29],$HoD);}
					if ($u_data[30]) {&img_html($u_data[30],$HoD);}
					if ($u_data[31]) {&img_html($u_data[31],$HoD);}
					if ($u_data[32]) {&img_html($u_data[32],$HoD);}
					if ($u_data[33]) {&img_html($u_data[33],$HoD);}
					if ($u_data[34]) {&img_html($u_data[34],$HoD);}
					if ($u_data[35]) {&img_html($u_data[35],$HoD);}
####### 追加
					print "<TD>\n";
					print "</TR></TABLE></CENTER><BR>\n";
				}
				$u_data[10] =~ s/<BR>/\n/g;
####### コメント化
#				if ($HoD->{config}{use_html} != 1) {
#					$u_data[10] =~ s/<([^>]|\n)*>//g;
#				}
####### コメント化
				if ($HoD->{config}{use_html} == 1) {
					$u_data[10] =~ s/<B>(.*?)<\/B>/&lt;B&gt;$1&lt;\/B&gt;/ig;
					$u_data[10] =~ s/<FONT (.*?)>(.*?)<\/FONT>/&lt;FONT $1&gt;$2&lt;\/FONT&gt;/ig;
					$u_data[10] =~ s/<a href=([^>]+)>(.*?)<\/a>/&lt;a href=$1&gt;$2&lt;\/a&gt;/ig;
####### コメント化
#					$u_data[10] =~ s/<([^>]|\n)*>//g;
####### コメント化
				}
				print "<form ENCTYPE=\"multipart/form-data\" METHOD=\"POST\" ACTION=\"$HoD->{gl}{cgi_r}\">\n";
				if ($HoD->{form}{action} eq "user") {
					print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"modify_u\">\n";
					print "<INPUT TYPE=\"HIDDEN\" NAME=\"pass\" VALUE=\"$HoD->{form}{pass}\">\n";
				}
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"cat\" VALUE=\"$HoD->{form}{cat}\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"txtnumber\" VALUE=\"$HoD->{form}{txtnumber}\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"t_type\" VALUE=\"$HoD->{form}{t_type}\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"mynum\" VALUE=\"$u_data[3]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"marktop\" VALUE=\"$u_data[0]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file1\" VALUE=\"$u_data[13]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file2\" VALUE=\"$u_data[21]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file3\" VALUE=\"$u_data[22]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file4\" VALUE=\"$u_data[23]\">\n";
####### 追加
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file5\" VALUE=\"$u_data[24]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file6\" VALUE=\"$u_data[25]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file7\" VALUE=\"$u_data[26]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file8\" VALUE=\"$u_data[27]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file9\" VALUE=\"$u_data[28]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file10\" VALUE=\"$u_data[29]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file11\" VALUE=\"$u_data[30]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file12\" VALUE=\"$u_data[31]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file13\" VALUE=\"$u_data[32]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file14\" VALUE=\"$u_data[33]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file15\" VALUE=\"$u_data[34]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"u_file16\" VALUE=\"$u_data[35]\">\n";
####### 追加
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"width1\" VALUE=\"$u_data[15]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"height1\" VALUE=\"$u_data[16]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"p_num\" VALUE=\"$u_data[2]\">\n";
				if (($HoD->{form}{t_type} eq "mt") && $u_data[2]){$HoD->{form}{point} = 1;}
				&add_html ($HoD, \@u_data);
				if ($HoD->{form}{action} eq "user_a") {
					&id_html1($HoD);
					print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"modify\">\n";
					print "<INPUT TYPE=\"HIDDEN\" NAME=\"pass\" VALUE=\"$u_data[12]\">\n";
				}
				print "<BR><CENTER><INPUT TYPE=\"SUBMIT\" VALUE=\"修正\">\n";
				print "<INPUT TYPE=\"RESET\" VALUE=\"リセット\"></CENTER></form>\n";
				print "<HR WIDTH=\"60%\">\n";
				print "<form METHOD=\"POST\" ACTION=\"$HoD->{gl}{cgi_a}\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"img_url\" VALUE=\"$u_data[13]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"marktop\" VALUE=\"$u_data[0]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"mynum\" VALUE=\"$u_data[3]\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"cat\" VALUE=\"$HoD->{form}{cat}\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"txtnumber\" VALUE=\"$HoD->{form}{txtnumber}\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"t_type\" VALUE=\"$HoD->{form}{t_type}\">\n";
				print "<INPUT TYPE=\"HIDDEN\" NAME=\"p_num\" VALUE=\"$u_data[2]\">\n";
				if ($HoD->{form}{action} eq "user") {
					print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"remove_u\">\n";
					print "<INPUT TYPE=\"HIDDEN\" NAME=\"pass\" VALUE=\"$HoD->{form}{pass}\">\n";
				}
				if ($HoD->{form}{action} eq "user_a") {
					&id_html1($HoD);
					print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"removemaingo\">\n";
					print "<INPUT TYPE=\"HIDDEN\" NAME=\"pass\" VALUE=\"$u_data[12]\">\n";
				}
				print "<CENTER><INPUT TYPE=\"SUBMIT\" VALUE=\"削除\"></CENTER>\n";
				print "</form>\n";
				&foot_html (\*STDOUT, $HoD);
				$flag = 1;
				last;
			}
			else {
				&error("ID・パスワードに間違いがあります。\n", $HoD);
			}
		}
		else { 
			$flag = 0;
		}
	}
	close(LOG);
	if ($flag == 0) {
		&error("正しい番号を入力して下さい。\n", $HoD);
	}
}

############################
#返信書き込み用ページ
sub return_reply{
	my $HoD = shift;
	my (@r_data, @r_datax, $res_num,$t_flag,$r_flag);
	$HoD->{config}{c1_t_comment} ="<FONT SIZE=-1><B>Reply to the Message&nbsp;[$HoD->{form}{mynum}]</B></FONT>";
	$HoD->{config}{c1_image} = "Reply to the Message&nbsp;[$HoD->{form}{mynum}]";
	&head_html(\*STDOUT,$HoD);
	print "<CENTER><H3>Reply to the Message&nbsp;[$HoD->{form}{mynum}]</H3></CENTER>\n";
	if ($HoD->{config}{border_color}) {
#		print "<BR><HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2 COLOR=\"$HoD->{config}{border_color}\">\n";
		print "<HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2 COLOR=\"$HoD->{config}{border_color}\">\n";
	}
	else {
#		print "<BR><HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2>\n";
		print "<HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2>\n";
	}
#	print "<CENTER><FONT SIZE=2>\n";
	print "<CENTER><FONT SIZE=1>\n";
	if ($HoD->{config}{img_back_url}) {
		print "[<A HREF=\"$HoD->{config}{img_back_url}\" TARGET=_top>HOME</A>]&nbsp;\n";
	}
	if ($HoD->{form}{txtnumber} ne "log") {
		print "[<A HREF=$HoD->{gl}{cgi}?action=showlast&cat=$HoD->{form}{cat}&txtnumber=log&t_type=$HoD->{form}{t_type} style=\"text-decoration:none\">BBS TOP</A>]&nbsp;\n";
	}
	print "[<A HREF=$HoD->{gl}{cgi}?action=showlast&cat=$HoD->{form}{cat}&txtnumber=$HoD->{form}{txtnumber}&t_type=$HoD->{form}{t_type} style=\"text-decoration:none\">BACK</A>]&nbsp;\n";
	if ($HoD->{form}{txtnumber} eq "log") {
		print "[<A HREF=$HoD->{gl}{cgi}?action=reply&mynum=$HoD->{form}{mynum}&txtnumber=$HoD->{form}{txtnumber}&cat=$HoD->{form}{cat}&t_type=$HoD->{form}{t_type}#r_form>返信を書き込む</A>]&nbsp;\n";
	}
	print "[<A HREF=\"$HoD->{gl}{cgi_u}?action=show_search&cat=$HoD->{form}{cat}\">記事検索</A>]&nbsp;\n";
	print "[<A HREF=\"$HoD->{gl}{cgi_u}?action=admin_enter&txtnumber=$HoD->{form}{txtnumber}&cat=$HoD->{form}{cat}\">管理用</A>]\n";
	print "</FONT></CENTER>\n";
	if ($HoD->{config}{border_color}) {
#		print "<HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2 COLOR=\"$HoD->{config}{border_color}\"><BR>\n";
		print "<HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2 COLOR=\"$HoD->{config}{border_color}\">\n";
	}
	else {
#		print "<HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2><BR>\n";
		print "<HR WIDTH=\"$HoD->{config}{t_width}\" SIZE=2>\n";
	}
	print "<CENTER><H3>Reply to the Message&nbsp;[$HoD->{form}{mynum}]</H3></CENTER>\n";
	open(LOG,"<$HoD->{gl}{basedir}/$HoD->{form}{cat}_$HoD->{form}{txtnumber}\.pl") || &error("ファイルがオープンできません。\n", $HoD);
	while (<LOG>) {
		chomp;
		@r_data = split(/\|\|\|/,$_);
		if (($r_data[2] eq "") && ($r_data[3] == $HoD->{form}{mynum})) {
			@r_datax = @r_data;
			&table_html ($HoD);
			&subj_date_name_hp_html ("main", \@r_data, $HoD);
			print "</TD></TR></TABLE></CENTER></TD></TR></TABLE><BR>\n";
			$r_flag = 1;
		}
		elsif (($r_data[2])  && ($r_data[1] == $HoD->{form}{mynum})) {
			if ($t_flag != 1) {
				print "<CENTER><TABLE WIDTH=\"$HoD->{config}{t_width}\" BORDER=0 CELLSPACING=0 CELLPADDING=5><TR><TD>\n";
			}
			&subj_date_name_hp_html ("reply", \@r_data, $HoD);
			if ($HoD->{config}{border_color}) {
				print "<HR SIZE=\"1\" WIDTH=\"100%\" COLOR=\"$HoD->{config}{border_color}\">\n";
			}
			else {
				print "<HR SIZE=\"1\" WIDTH=\"100%\" COLOR=\"$HoD->{config}{text_color}\">\n";
			}
			$res_num++;
			$t_flag = 1;
		}
	}
	close(LOG);
	if (!$r_flag) {print "<CENTER>該当記事がありません。</CENTER>\n";}
	if ($t_flag) {print "</TD></TR></TABLE></CENTER>\n";}
	if (($HoD->{form}{txtnumber} eq "log") && !$HoD->{config}{read_only}){
	if ($res_num < $HoD->{config}{n_r_max1}) {
		print "<BR><BR><A NAME=r_form>\n";
		&add_form_html("reply", $HoD, \@r_datax);
	}
	else {
		print "このトピックにはこれ以上返信出来ません。\n";
	}
	}
	print "<BR><BR>\n";
	&form_html ($HoD);
	&foot_html (\*STDOUT, $HoD);
}

############################
#全記事検索処理
sub search_all {
	my $HoD = shift;
	my ($filename, $i, @match, $page_maxs, $p, $ps, $lines, @s_data, $cat_data, $cat_name_j,$lastnumx,$pp,$s_num, $p_flag, %last); 
	if ($HoD->{form}{cat} eq "") {&error("BBSを選択して下さい。\n", $HoD);}
	if (($HoD->{config}{img_c_mark} eq "") || ($HoD->{config}{img_c_mark} eq "http://")) {$HoD->{config}{img_c_mark} = $HoD->{config}{c1_c_comment};}
	else {$HoD->{config}{img_c_mark} = "<IMG SRC=\"$HoD->{config}{img_c_mark}\">";}
	my $searchword = $HoD->{form}{searchword}; 
	my $next_page = $HoD->{form}{next_page};
	my $cat = $HoD->{form}{cat};
	if ($searchword eq '') {&error("キーワードを記入して下さい。\n", $HoD);}
	$searchword =~ s/　/ /g;
	my @searchword = split(' ', $searchword);
	$HoD->{config}{c1_image} = "Search";
	&head_html(\*STDOUT,$HoD);
	print "<CENTER><H3>Search</H3></CENTER>\n";
	print "<BR><B>【$searchword】</B>の検索結果です\n";
	open (LFILE,">$HoD->{gl}{basedir}/$HoD->{gl}{lockfile}") or &error("ファイルがオープンできません。\n", $HoD);
	eval("flock(LFILE, 2)");
	opendir (DIR, "$HoD->{gl}{basedir}");
	foreach $filename ( readdir (DIR) ) {
		if ($filename =~ /^$cat\_(\w+)\.pl$/o) {
			$cat_data = &get_catname ($cat, $HoD);
			$cat_name_j = $cat_data->[2];
			$lastnumx = $1;
			open(FILE,"<$HoD->{gl}{basedir}/$filename") or &error("ファイルがオープンできません。\n", $HoD);
			while (<FILE>) {
				next if /^\d+$/;
				$pp = 0;
				foreach $i (@searchword) {
					if (index($_,$i) >= 0) {
						$pp++;
						if ($HoD->{form}{s} eq 'or') {
							last;
						}
					}
					else {
						$pp = 0;
						if ($HoD->{form}{s} eq 'and') {
							last;
						}
					}
				}
				$_ .= $lastnumx . "\n"; $_ .= $cat_name_j . "\n";
				push (@match, $_) if ($pp > 0);
			}
			$s_num = @match;
			close(FILE);
		}
	}
	closedir (DIR);
	eval("flock(LFILE, 8)");
	close(LFILE);
	if ($s_num) {
		print "---&nbsp;該当記事: <B>$s_num</B>件<BR><BR>\n";
		if ($HoD->{config}{img_all_icon}) {
			print "<BR><BR><FONT SIZE=2><IMG SRC=\"$HoD->{config}{img_all_icon}\" BORDER=0>をクリックすると、関連記事が一括して表示されます。</FONT><BR><BR>\n";
		}
		else {
			print "<BR><BR><FONT SIZE=2><FONT $HoD->{config}{c1_titles_color}>▼</FONT>をクリックすると、関連記事が一括して表示されます。</FONT><BR><BR>\n";
		}
		if (!$HoD->{form}{next_page}) { $page_maxs = $HoD->{config}{n_page_max}; $p = 0; $HoD->{form}{next_page} = 0; $ps = 0;}
		else { $page_maxs = $HoD->{form}{next_page} + $HoD->{config}{n_page_max}; $p = 0; $ps = $HoD->{form}{next_page};}
		foreach $lines (@match) {
			my @line = split(/\n/,$lines);
			chomp $line[0];
			@s_data = split(/\|\|\|/,$line[0]);
			$HoD->{form}{txtnumber} = $line[1];
			my $cat_name_j = $line[2];
			if  ($p >= $page_maxs) {
				$p_flag = 1;
				last;
			}
			if  (($p < $page_maxs) && ($p >= $HoD->{form}{next_page})) {
				print "<CENTER><FONT SIZE=2>カテゴリー: $cat_name_j</FONT></CENTER>\n";
				&list_html1(\@s_data, $HoD);
				&table_html ($HoD);
				&subj_date_name_hp_html ("main", \@s_data, $HoD);
				&back_html ($HoD);
				print "</TD></TR></TABLE></CENTER></TD></TR></TABLE></CENTER><BR>\n";
				$ps++;
			}
			$p++;
		}
		$last{ps} = $ps;
		$last{page_maxs} = $page_maxs;
		$last{p_flag} = $p_flag;
		$HoD->{last} = {%last};
		&last_html ($HoD);
	}
	else {
		print "<BR><FONT SIZE=2>該当する記事はありませんでした。</FONT><BR>\n";
	}
	&search_html ($HoD);
####### 追加
#	&sort_html ($HoD);
####### 追加
	&foot_html (\*STDOUT, $HoD);
}

############################
#SORT処理
sub sort {
	my $HoD = shift;
	my ($filename_s, $i_s, @match_s, $page_maxs_s, $p_s, $ps_s, $lines_s, @s_data_s, $cat_data_s, $cat_name_j_s, $lastnumx_s, $pp_s, $s_num_s, $p_flag_s, %last_s, $no1, $no2, $no3, $no4, $no5, $nm1, $nm2, $nm3, $nm4, $file_d, $fnct_nm, $cnf1, $cnf2, $cnf3, $cnf4); 
	if ($HoD->{form}{cat} eq "") {&error("BBSを選択して下さい。\n", $HoD);}
	if (($HoD->{config}{img_c_mark} eq "") || ($HoD->{config}{img_c_mark} eq "http://")) {$HoD->{config}{img_c_mark} = $HoD->{config}{c1_c_comment};}
	else {$HoD->{config}{img_c_mark} = "<IMG SRC=\"$HoD->{config}{img_c_mark}\">";}
	my $next_page = $HoD->{form}{next_page};
	my $cat = $HoD->{form}{cat};
	$HoD->{config}{c1_image} = "Sort";
	&head_html(\*STDOUT,$HoD);
	print "<CENTER><H3>Sort</H3></CENTER>\n";
	open (LFILE,">$HoD->{gl}{basedir}/$HoD->{gl}{lockfile}") or &error("ファイルがオープンできません。\n", $HoD);
	eval("flock(LFILE, 2)");
	opendir (DIR, "$HoD->{gl}{basedir}");
	if ($HoD->{form}{sort} eq 'sorta')
	{
		$fnct_nm = "昇順SORT（全発言）";
		foreach $filename_s ( readdir (DIR) ) {
			if ($filename_s =~ /^(\d+)\_(\w+)\.pl$/o) {
				my $cat = $1;
				open(FILE,"<$HoD->{gl}{basedir}/$filename_s") or &error("ファイルがオープンできません。\n", $HoD);
				while (<FILE>) {
					next if /^\d+$/;
					($no1, $no2, $no3, $no4, $no5) = split (/\|\|\|/, $_, 5);
					$no5 = $_;
					open (CNTFILE,">$HoD->{gl}{basedir}/$cat\_$no4") or &error("ファイルがオープンできません。\n", $HoD);
					$no1 = <CNTFILE>;
					close(CNTFILE);
					$_ .= $no1 . "<>" . $cat . "<>" . $no4 . "<>" . $no5 . "\n";
					push (@match_s, $_);
				}
				$s_num_s = scalar @match_s;
				@match_s = sort @match_s;
				close(FILE);
			}
		}
	}
	elsif ($HoD->{form}{sort} eq 'sortz')
	{
		$fnct_nm = "降順SORT（全発言）";
		@match_s = sort @match_s;
		@match_s = reverse @match_s;
	}
	elsif ($HoD->{form}{sort} eq 'sort1')
	{
		$fnct_nm = "昇順SORT（当板）";
		@match_s = sort @match_s;
	}
	elsif ($HoD->{form}{sort} eq 'sort2')
	{
		$fnct_nm = "降順SORT（当板）";
		@match_s = sort @match_s;
		@match_s = reverse @match_s;
	}
	print "<BR><B>【$fnct_nm】</B>の結果です\n";
	closedir (DIR);
	eval("flock(LFILE, 8)");
	close(LFILE);
	if ($s_num_s) {
		print "---&nbsp;該当記事: <B>$s_num_s</B>件<BR><BR>\n";
		if ($HoD->{config}{img_all_icon}) {
			print "<BR><BR><FONT SIZE=2><IMG SRC=\"$HoD->{config}{img_all_icon}\" BORDER=0>をクリックすると、関連記事が一括して表示されます。</FONT><BR><BR>\n";
		}
		else {
			print "<BR><BR><FONT SIZE=2><FONT $HoD->{config}{c1_titles_color}>▼</FONT>をクリックすると、関連記事が一括して表示されます。</FONT><BR><BR>\n";
		}
		if (!$HoD->{form}{next_page}) { $page_maxs_s = $HoD->{config}{n_page_max}; $p_s = 0; $HoD->{form}{next_page} = 0; $ps_s = 0;}
		else { $page_maxs_s = $HoD->{form}{next_page} + $HoD->{config}{n_page_max}; $p_s = 0; $ps_s = $HoD->{form}{next_page};}
		foreach $lines_s (@match_s) {
			chomp $lines_s;
			($nm1, $nm2, $nm3, $nm4) = split (/<>/, $lines_s, 4);
			@s_data_s = split(/\|\|\|/,$nm4);
			my $file = &file_open("$HoD->{gl}{basedir}/$HoD->{gl}{catfile}", 1);
			my @file_d = @{$file};
			foreach $file_d (@file_d){
				($cnf1, $cnf2, $cnf3, $cnf4) = split (/\|\|\|/, $file_d, 4);
				if ($nm2 eq $cnf2)
				{
					my $cat_name_j_s = $cnf3;
				}
			}
			$HoD->{form}{txtnumber} = 'log';
			if  ($p_s >= $page_maxs_s) {
				$p_flag_s = 1;
				last;
			}
			if  (($p_s < $page_maxs_s) && ($p_s >= $HoD->{form}{next_page})) {
				&list_html2(\@s_data_s, $HoD, $cat_name_j_s);
#				&table_html ($HoD);
#				&subj_date_name_hp_html ("main", \@s_data_s, $HoD);
				&back_html ($HoD);
				print "</TD></TR></TABLE></CENTER></TD></TR></TABLE></CENTER><BR>\n";
				$ps_s++;
			}
			$p_s++;
		}
		$last_s{ps} = $ps_s;
		$last_s{page_maxs} = $page_maxs_s;
		$last_s{p_flag} = $p_flag_s;
		$HoD->{last} = {%last_s};
		&last_html ($HoD);
	}
	else {
		print "<BR><FONT SIZE=2>該当する記事はありませんでした。</FONT><BR>\n";
	}
	&search_html ($HoD);
####### 追加
	&sort_html ($HoD);
####### 追加
	&foot_html (\*STDOUT, $HoD);
}

############################
#過去の記事を見る部分のHTML
sub last_html1 {
	my($txtnum, $HoD) = @_;
	print "<CENTER><TABLE WIDTH=\"30%\"><TR>\n";
	print "<form METHOD=\"POST\" ACTION=\"$HoD->{gl}{cgi}\" TARGET=_self>\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"cat\" VALUE=\"$HoD->{form}{cat}\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"$HoD->{form}{action}\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"t_type\" VALUE=\"$HoD->{form}{t_type}\">\n";
	print "<TD ALIGN=\"center\"><SELECT NAME=\"txtnumber\">\n";
	if ($HoD->{form}{txtnumber} eq "log") {
		print "<OPTION VALUE=\"log\" SELECTED>現行ログ\n";
	}
	else {
		print "<OPTION VALUE=\"log\">現行ログ\n";
	}
	while (1<=$txtnum) {
		if ($txtnum == $HoD->{form}{txtnumber}) {
			print "<OPTION VALUE=\"$txtnum\" SELECTED>Log${txtnum}\n";
		}
		else {
			print "<OPTION VALUE=\"$txtnum\">Log${txtnum}\n";
		}
		--$txtnum;
	}
	print "</SELECT>\n";
	print "<INPUT TYPE=\"SUBMIT\" VALUE=\"GO\"></TD></form>\n";
	print "</TR></TABLE></CENTER>\n";
	#print "<BR>\n";
}

############################
#過去の記事を見る部分のHTML
sub last_html_mt {
	my $HoD = shift;
	print "<form METHOD=\"POST\" ACTION=\"$HoD->{gl}{cgi}\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"cat\" VALUE=\"$HoD->{form}{cat}\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"txtnumber\" VALUE=\"$HoD->{form}{txtnumber}\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"view_all_t\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"t_type\" VALUE=\"$HoD->{form}{t_type}\">\n";
	print "<TR><TD><INPUT TYPE=\"SUBMIT\" VALUE=\"スレッドをすべて見る\"></TD></TR></form>\n";
}

############################
#アイコンの表示
sub show_icon {
	my $HoD = shift;
	my @icon_data;
	my $file = &file_open("$HoD->{gl}{basedir}/$HoD->{gl}{iconfile}");
	$HoD->{config}{c1_image} = "Icon";
	&head_html(\*STDOUT,$HoD);
	print "<CENTER><H3>Icon</H3></CENTER>\n";
	print "<CENTER><TABLE BORDER=1 WIDTH=\"60%\" CELLSPACING=\"0\" CELLPADDING=\"5\">\n";
	foreach (@{$file}) {
		@icon_data = split(/\|\|\|/,$_);
		if (-e "$HoD->{gl}{basedir_h}/$HoD->{form}{cat}") {
			print "<TR><TH><IMG SRC=\"$HoD->{gl}{icon_dir_url}/$HoD->{form}{cat}/$icon_data[2]\"></TH><TH><FONT SIZE=2>$icon_data[3]</FONT></TH><TR>\n";
		}
		else {
			print "<TR><TH><IMG SRC=\"$HoD->{gl}{icon_dir_url}/$icon_data[2]\"></TH><TH><FONT SIZE=2>$icon_data[3]</FONT></TH><TR>\n";
		}
	}
	print "</TABLE></CENTER>\n";
	print "<BR><CENTER><FONT SIZE=2>ブラウザを閉じて戻って下さい。</FONT></CENTER>\n";
	print "</BODY></HTML>\n";
}

############################
#修正・削除フォーム
sub form_html {
	my $HoD = shift;
	my $cookie;
	my %boardname = split(/\,/,$HoD->{gl}{boardname});
	if ($HoD->{gl}{usepasscookie} == 1) {$cookie = &get_cookie (\%boardname);}
	print " <form METHOD=\"POST\" ACTION=\"$HoD->{gl}{cgi}\">\n";
	print " <CENTER><TABLE BORDER=0 CELLPADDING=1 CELLSPACING=1>\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"user\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"cat\" VALUE=\"$HoD->{form}{cat}\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"t_type\" VALUE=\"$HoD->{form}{t_type}\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"txtnumber\" VALUE=\"$HoD->{form}{txtnumber}\">\n";
	print "<TR><TD><FONT SIZE=2>No.</FONT></TD><TD><INPUT TYPE=\"text\" NAME=\"mynum\" SIZE=3 maxlength=10></TD>\n";
	print "<TD><FONT SIZE=2>PASS</FONT></TD><TD><INPUT TYPE=\"password\" NAME=\"pass\" SIZE=10 maxlength=10 VALUE=\"$cookie->{pass}\"></TD>\n";
	print "<TD><INPUT TYPE=\"SUBMIT\" VALUE=\"修正・削除\"></TD></form>\n";
	print "<form METHOD=\"POST\" ACTION=\"$HoD->{gl}{cgi}\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"user_a\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"cat\" VALUE=\"$HoD->{form}{cat}\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"t_type\" VALUE=\"$HoD->{form}{t_type}\">\n";
	print "<INPUT TYPE=\"HIDDEN\" NAME=\"txtnumber\" VALUE=\"$HoD->{form}{txtnumber}\">\n";
	print "<TD><FONT SIZE=2>No.</FONT></TD><TD><INPUT TYPE=\"text\" NAME=\"mynum\" SIZE=3 maxlength=10></TD>\n";
	print "<TD><FONT SIZE=2>USER</FONT></TD><TD><INPUT TYPE=\"text\" NAME=\"username\" value=\"$cookie->{username}\" size=10></TD>\n";
	print "<TD><FONT SIZE=2>PASS</FONT></TD><TD><INPUT TYPE=\"password\" NAME=\"password\" value=\"$cookie->{password}\" size=10></TD>\n";
	print "<TD><INPUT TYPE=\"SUBMIT\" VALUE=\"管理者専用\"></TD></TR></TABLE></form>\n";
	print "</TD></TR></TABLE></CENTER>\n";
}

############################
# 掲示板毎のcounter
sub counter {
	my $HoD = shift;
	my $c_num = &get_number ($HoD->{gl}{c_numfile}, '1', $HoD);
	if ($HoD->{form}{txtnumber} eq "log") {
		&increment_num ($HoD->{gl}{c_numfile},$c_num, $HoD);
	}
	if (length $c_num < $HoD->{config}{n_figure1}) {
		$c_num = &make_figure ($c_num,length $c_num,$HoD->{config}{n_figure1});
	}
	return $c_num;
}

############################
# 各発言毎のcounter
sub counter1 {
	my ($say_no, $HoD)= @_;
	my $bbsno = $HoD->{gl}{c_numfile};
	$bbsno =~ s/c_num.txt//g;
	$bbsno = "$bbsno"."_"."$say_no";
	my $c_kakunum = &get_number ($bbsno, '1', $HoD);
	if ($HoD->{form}{txtnumber} eq "log") {
		&increment_num ($bbsno,$c_kakunum, $HoD);
	}
	if (length $c_kakunum < $HoD->{config}{n_figure1}) {
		$c_kakunum = &make_figure ($c_kakunum,length $c_kakunum,$HoD->{config}{n_figure1});
	}
	return $c_kakunum;
}

############################
#桁数調整
sub make_figure {
	my ($num, $length, $figure) = @_;
	my $keta = $figure - $length;
	my $i = 0;
	while ($i < $keta) {
		$num = "0$num";
		$i++;
	}
	return $num;
}

############################
#スレッド一覧
sub view_all_t {
	my $HoD = shift;
	if ($HoD->{form}{cat} eq "") {&error("BBSを選択して下さい。\n", $HoD);}
	my (%DATA, @titles, $title, @data, @data1, $cnt,$number);
	my $cat_data = &get_catname ($HoD->{form}{cat}, $HoD);
	my $cat_name_j = $cat_data->[2];
	if ($HoD->{form}{txtnumber} eq "log") {$number = "現行ログ";}
	else {$number = "Log$HoD->{form}{txtnumber}";}
	$HoD->{config}{c1_image} = "【$cat_name_j】$numberスレッド一覧";
	&head_html(\*STDOUT,$HoD);
	print "<CENTER><H3>【$cat_name_j】$numberスレッド一覧</H3></CENTER>\n";
	open(LOG,"<$HoD->{gl}{basedir}/$HoD->{form}{cat}_$HoD->{form}{txtnumber}\.pl");
	while (<LOG>) {
		chomp;
		next if /^\d+$/;
		@data1 = split(/\|\|\|/,$_);
		if ($DATA{$data1[1]} eq "") {push @titles, $data1[1];}
		push @{$DATA{$data1[1]}}, $_;
	}
	close(LOG);
	my $mt_number = 1;
	foreach $title (@titles) {
		@data = split(/\|\|\|/,$DATA{$title}[0]);
		$cnt = @{$DATA{$title}};
		print "<B>$mt_number</B>:<A HREF=$HoD->{gl}{cgi}?action=show_all&txtnumber=$HoD->{form}{txtnumber}&pp_num=$data[1]&cat=$HoD->{form}{cat}&t_type=$HoD->{form}{t_type}>$data[9]</A>($cnt)&nbsp;\n";
		++ $mt_number;
	}
	&back_html ($HoD);
	&foot_html (\*STDOUT, $HoD);
}