%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/rappan/www/cgi_bbs_puk/
Upload File :
Create Path :
Current File : /home/rappan/www/cgi_bbs_puk/sayaka.cgi

#!/usr/bin/perl

#==========================================================
# BBS CGI - SAYAKA - ver.1.12
# last update 2007/07/31
# parauni@hotmail.co.jp
#==========================================================
#----------------------------------------------------------
# 外部ファイル
require './jcode.pl';
require './common.pl';
require './sayaka_ini.cgi';
#----------------------------------------------------------

$version = '1.12';

&decode;
&initialize;
&setting_file_check;
&pass_in_check;
&pass_write_check;
&log_read;

if($in{'act'} eq 'management')		{ &management; }
elsif($in{'act'} eq 'contribution')	{ &contribution; }
elsif($in{'act'} eq 'response')		{ &response(0); }
elsif($in{'act'} eq 'edit')			{ &edit; }
elsif($in{'act'} eq 'retrieval')	{ &retrieval; }
elsif($in{'act'} eq 'readme')		{ &readme; }
elsif($in{'act'} eq 'icon_list')	{ &icon_list; }
&top_page;
exit;


#==========================================================
# デコード
#==========================================================
sub decode
{
	my $key,$val,$line,$work,@PAIRS;

	if($ENV{'REQUEST_METHOD'} eq 'POST')
	{
		$g_f_post = 1;
		read(STDIN,$work,$ENV{'CONTENT_LENGTH'});
	}
	else
	{
		$g_f_post = 0;
		$work = $ENV{'QUERY_STRING'};
	}
	@PAIRS = split(/&/,$work);

	foreach $line(@PAIRS)
	{
		($key, $val) = split(/=/,$line);
		$val =~ tr/+/ /;
		$val =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
		$val =~ s/&/&/g;
		$val =~ s/"/"/g;
		$val =~ s/</&lt;/g;
		$val =~ s/>/&gt;/g;
		$val =~ s/\n//g;
		$val =~ s/\,/,/g;
		&jcode'convert(*value,'sjis');
		if(($key eq 'key') && ($val ne ''))
		{
			# 記事検索
			$in{$key} = $val;
			$val =~ s/ / /g;
			@KEY = split(/ /,$val);
		}
		elsif($key eq 'del')
		{
			# 管理削除
			push(@DEL, $val);
		}
		else
		{
			$in{$key} = $val;
		}
	}
}


#==========================================================
# 初期化
#==========================================================
sub initialize
{
	$flag_error  = 0;		# エラー		0/1 = No/Yes
	$flag_header = 0;		# ヘッダ表示	0/1 = 無し/有り
	$flag_pass_in = 0;		# 入場用パスワード	0/1 = NG/OK
	$flag_pass_write = 0;	# 投稿用パスワード	0/1 = NG/OK
	$flag_climit = 0;		# 文字数制限	0/1 = 無し/有り
	$flag_input  = 0;		# 入力			0/1/2 = 無し/入力中/入力終了

	if($flag_secret == 0) { $flag_secret_res = 0; }

	# ログファイルの選択
	$l_no = $in{'l_no'};
	if($l_no eq '') { $l_no = 0; }
	if(!open(NOTE,"$log_file[$l_no]")) { $l_no = 0; }

	$title_name = $title_name[$l_no];
	$title_img  = $title_img[$l_no];
	$home       = $home[$l_no];
	$log_file   = $log_file[$l_no];
	$lock_file  = $lock_file[$l_no];
	$pass_in    = $pass_in[$l_no];
	$pass_write = $pass_write[$l_no];
	$password   = $password[$l_no];

	$cgi_top = $cgi;
	$cgi .= "?l_no=$l_no";

	# 親記事の取得
	$m_no = $in{'m_no'};
	if($m_no eq '') { $m_no = 0; }
	$m_res = $in{'m_res'};
	if($m_res eq '') { $m_res = 0; }

	# ページ数の取得
	if($in{'page'} eq '') { $in{'page'} = 1; }

	# 設定ミスの補正
	if($article_max < 1) { $article_max = 1; }
	if($thread_page < 1) { $thread_page = 1; }
	if($res_max < 0) 				{ $res_max = 0; }
	elsif($res_max >= $article_max) { $res_max = $article_max - 1; }
	if($name_max < 0) { $name_max = 0;}
	if($mail_max < 0) { $mail_max = 0;}
	if($hp_max < 0) { $hp_max = 0;}
	if($title_max < 0) { $title_max = 0;}
	if($comment_max < 0) { $comment_max = 0;}

	# 文字数制限の有無の確認
	if($name_max + $mail_max + $hp_max + $title_max + $comment_max > 0) { $flag_climit = 1; }

	# タイトル
	$title_header = $title_name;
	if($title_img ne '') { $title_name = "<img src=\"$title_img\" alt=\"$title_name\">"; }

	# 背景画像
	$main_bimg_attachment = &common'css_background_attachment($main_bimg_attachment);
	$main_bimg_repeat = &common'css_background_repeat($main_bimg_repeat);
	$main_bimg_position = &common'css_background_position($main_bimg_position_h,$main_bimg_position_w);

	# スタイル
	$link_line = &common'css_border_style($link_line);
	$linkh_line = &common'css_border_style($linkh_line);
	$itable_line = &common'css_border_style($itable_line);
	$itableh_line = &common'css_border_style($itableh_line);

	$title_fweight = &common'css_font_weight($title_fweight);
	$ptitle_fweight = &common'css_font_weight($ptitle_fweight);

	$label_position = &common'css_text_align($label_position);
}


#==========================================================
# 設定ファイルバージョンの確認
#==========================================================
sub setting_file_check
{
	my $version;

	$version = '1.08';
	if($setting_version == $version) { return; }

	error_end("設定ファイルのバージョンが対応していません。<br>設定ファイルver.$versionを使用して下さい。");
}


#==========================================================
# 入場用パスワードの確認
#==========================================================
sub pass_in_check
{
	if(($in{'p_in'} eq $pass_in) || ($in{'p_in'} eq $password))
	{
		$flag_pass_in = 1;
		if($pass_in ne '') { $cgi .= "&amp;p_in=$pass_in"; }
		return;
	}

	# 入場用パスワード
	&html_header;

	print <<"HERE";
<h2><a name="skip_page_title">入場用パスワード入力フォーム</a></h2>
<p>本掲示板に入るにはパスワードが必要となります。<br>
下記入力欄にパスワードを入力して下さい。</p>
<form method="POST" action="$cgi_top">
<input type="hidden" name="l_no" value="$l_no">
<input type="password" name="p_in" size="$form_pass" maxlength="8"><br>
<input type="submit" class="button" value="認証">
</form>
HERE

	&html_footer;
	exit;
}


#==========================================================
# 投稿用パスワードの確認
#==========================================================
sub pass_write_check
{
	if(($in{'p_write'} eq $pass_write) || ($in{'p_write'} eq $password))
	{
		$flag_pass_write = 1;
		if($pass_write ne '') { $cgi .= "&amp;p_write=$pass_write"; }
	}
}


#==========================================================
# HTMLヘッダ
#==========================================================
sub html_header
{
	if($flag_header != 0) { return; }
	$flag_header = 1;

	print <<"HERE";
Content-type: text/html
$set_cookie

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>$title_header</title>
<link rel="next" href="$home">
<LINK rel="shortcut icon" href="../favicon.ico">
<style type="text/css">
<!--
*
{
	padding:0;
	margin:0;
}
body
{
	font-size:$main_fsize;
	color:$main_fcolor;
	line-height:$main_fline;
	background:$main_bgcolor url($main_bimg);
	background-attachment:$main_bimg_attachment;
	background-repeat:$main_bimg_repeat;
	background-position:$main_bimg_position;
	text-align:center;
	margin:10px 20px;
}
a
{
	text-decoration:none;
}
a:link
{
	color:$link_color;
	border-bottom:1px $link_line $link_color;
}
a:visited
{
	color:$linkv_color;
	border-bottom:1px $link_line $linkv_color;
}
a:hover,a:active
{
	color:$linkh_color;
	border-bottom:1px $linkh_line $linkh_color;
}
h1
{
	font-size:$title_fsize;
	color:$title_fcolor;
	font-weight:$title_fweight;
	line-height:$title_fsize;
}
h2
{
	font-size:$ptitle_fsize;
	color:$ptitle_fcolor;
	font-weight:$ptitle_fweight;
	line-height:$ptitle_fsize;
	margin:20px 0;
}

div#menu
{
	border-top:1px solid $hr_color;
	border-bottom:1px solid $hr_color;
	padding:3px;
	margin:10px 0;
}
div#footer
{
	text-align:right;
	margin-top:30px;
}
.skip_navi
{
	position:absolute;
	top:0px;
	left:-9999px;
}

hr
{
	height:$hr_height;
	color:$hr_color;
	background-color:$hr_color;
	border-width:0;
	width:$hr_width;
	margin:auto;
	margin-top:10px;
	margin-bottom:10px;
}
em
{
	color:$note_fcolor;
	font-style:normal;
}
strong.lv1
{
	color:$note_fcolor;
}

form
{
	margin:20px 0;
}

input, textarea
{
	border:1px solid $form_bcolor;
	background-color:$form_bgcolor;
	padding:1px 2px;
}
input.none
{
	border:0px;
	background-color:transparent;
}
input.button
{
	border:1px solid #000000;
	background-color:#cccccc;
	margin:20px 0px;
}
input.button_no_margin
{
	border:1px solid #000000;
	background-color:#cccccc;
}

table
{
	border-collapse:collapse;
	margin:auto;
}
th
{
	white-space:nowrap;
	padding:5px;
}
td
{
	text-align:left;
	padding:5px;
}

table.table,table.table_icon
{
	border:1px solid $atable_bcolor;
	background-color:$atable_bgcolor;
}
table.table_thread
{
	border:1px solid $atable_bcolor;
	background-color:$atable_bgcolor;
	width:$atable_width;
	margin-bottom:20px;
}
.table td,.table th,.table_icon td
{
	color:$amain_fcolor;
	border:1px solid $atable_bcolor;
}
.table_icon td
{
	text-align:center;
}
.table_icon img
{
	margin-bottom:5px;
}

table.form
{
	border:1px $itable_line $itable_bcolor;
}
.form th
{
	background-color:$label_bgcolor;
	color:$label_fcolor;
	font-weight:normal;
	border:1px $itableh_line $itable_bcolor;
	text-align:$label_position;
	padding:3px 5px;
}
.form td
{
	background-color:$fill_bgcolor;
	padding:3px 5px;
}

table.article_mother
{
	color:$amain_fcolor;
	border:1px solid $atable_bcolor;
	background-color:$atable_bgcolor;
	width:$atable_width;
	margin-top:40px;
	margin-bottom:40px;
}
table.article_response
{
	border:1px solid $atable_bcolor;
	width:$atable_res_width;
	margin-top:20px;
	margin-left:auto;
	margin-right:0px;
}
td.article_mother,td.article_response
{
	color:$amain_fcolor;
}
table.comment
{
	margin-top:30px;
	margin-left:0px;
}
.comment td
{
	padding-left:20px;
}
.article_mother div
{
	margin:0px 0px 6px 0px;
	padding:5px 3px 3px;
	color:$atitle_fcolor;
	font-weight:bold;
	background-color:$atitle_bgcolor;
	line-height:100%;
}
.article_response div
{
	margin:0px 0px 6px 0px;
	padding:5px 3px 3px;
	color:$atitle_res_fcolor;
	font-weight:bold;
	background-color:$atitle_res_bgcolor;
	line-height:100%;
}
table.page_info
{
	width:100%;
}
.page_info td
{
	text-align:center;
}

ul
{
	text-align:left;
	margin-left:20px;
}
li
{
	margin-bottom:20px;
}

span.name
{
	color:$aname_fcolor;
}
-->
</style>
</head>
<body>
<img src="http://m.from.tv/cgi_access/hana_page.cgi?id=pukbbs&type=main">

<TABLE border="0" width="680">
  <TBODY>
    <TR>
      <TD width="680" align="right"><img src="../cgi_hicnt200/hicnt.cgi?pid=puk_bbs&img=05&len=6" border="0"></TD>
    </TR>
  </TBODY>
</TABLE>
<h1><a name="page_top">$title_name</a></h1>
<p class="skip_navi"><a href="#skip_page_title">本文へ移動</a></p>
<p>自由なテーマで書いていただいて結\構\です。何でもどうぞ。<BR><font color="red">※当然ですが、人を中傷するような内容、卑猥な内容、いたずらと思われる内容等については、<BR>管理人の判断で削除させていただくことがあります。</font></p>
<div id="menu">
[<a href="$home" target="_top">トップページへ</a>] 
[<a href="$cgi">この掲示板トップ</a>] 
HERE

	if($flag_pass_in == 1)
	{
		print <<"HERE";
[<a href="$cgi&amp;act=readme">使い方</a>] 
[<a href="$cgi&amp;act=retrieval">記事検索</a>] 
[<a href="$cgi&amp;act=management">管理用</a>]
HERE
	}
	print "</div>\n";
}
#==========================================================
# HTMLフッタ
#==========================================================
sub html_footer
{
	print "<div id=\"footer\">SAYAKA ver.$version - (C) <a href=\"http://parauni.hp.infoseek.co.jp/\" target=\"_blank\">Parallel Universes</a></div>\n";
	print "</body></html>";
}
#==========================================================
# トップページ
#==========================================================
sub top_page
{
	$m_no = 0;
	&html_header;
	&new_form;
	&thread_list;
	&article_list;
	&page_info;
	&html_footer;
	exit;
}
#==========================================================
# 新規入力フォーム
#==========================================================
sub new_form
{
	my $work;

	if($flag_contribution == 1) { return; }
	if($m_no != 0) { $flag_secret = 0; }
	if($flag_pass_write == 1)
	{
		# 投稿用パスワードOK
		if(($m_no == 0) && ($m_res == 0))	{ $work = '投稿フォーム'; }
		else								{ $work = 'このスレッドにレスをする'; }
		print "<h2><a name=\"skip_page_title\">$work</a></h2>\n";
		if($m_no == 0)
		{
			if(($flag_thread_list == 1) && ($m_no == 0))
			{
				print "<p class=\"skip_navi\"><a href=\"#skip_thread_list\">スレッド一覧へ移動</a></p>\n";
			}
		}
		print <<"HERE";
<form method="POST" action="$cgi_top">
<input type="hidden" name="l_no" value="$l_no">
<input type="hidden" name="p_in" value="$pass_in">
<input type="hidden" name="p_write" value="$in{'p_write'}">
<input type="hidden" name="act" value="contribution">
<input type="hidden" name="m_no" value="$m_no">
<input type="hidden" name="m_res" value="$m_res">
HERE

		$button = $LABEL[9];
		if($flag_input == 0)
		{
			&get_cookie;
			$in{'title'} = $mother_title;
			$in{'comment'} = '';
		}
		elsif($flag_input == 2)
		{
			$in{'title'} = '';
			$in{'comment'} = '';
		}
		&form;
	}
	else
	{
		# 投稿用パスワードNG
		print <<"HERE";
<h2><a name="skip_page_title">投稿用パスワード入力フォーム</a></h2>
<p>投稿するにはパスワードが必要となります。<br>
下記入力欄にパスワードを入力して下さい。</p>
<form method="POST" action="$cgi_top">
<input type="hidden" name="l_no" value="$l_no">
<input type="hidden" name="p_in" value="$pass_in">
<input type="password" name="p_write" size="$form_pass" maxlength="8"><br>
<input type="submit" class="button" value="認証">
</form>
HERE
	}

	if($m_no == 0) { print "<hr>\n"; }
}
#==========================================================
# 編集フォーム
#==========================================================
sub edit_form
{
	$flag_secret = 0;

	print <<"HERE";
<h2><a name="skip_page_title">編集フォーム</a></h2>
<form method="POST" action="$cgi_top">
<input type="hidden" name="l_no" value="$l_no">
<input type="hidden" name="p_in" value="$pass_in">
<input type="hidden" name="p_write" value="$in{'p_write'}">
<input type="hidden" name="act" value="edit">
<input type="hidden" name="pass" value="$in{'pass'}">
<input type="hidden" name="process" value="$in{'process'}">
<input type="hidden" name="no" value="$in{'no'}">
<input type="hidden" name="edit_no" value="$in{'no'}">
HERE

	$button = $LABEL[10];
	&form;
}
#==========================================================
# 入力フォーム
#==========================================================
sub form
{
	my $work,$work_name,$work_mail,$work_hp,$work_title,$chk_secret;

	# 文字数制限の設定
	if($flag_climit == 1)
	{
		if($name_max > 0)	{ $work_name = "maxlength=\"$name_max\""; }
		if($mail_max > 0)	{ $work_mail = "maxlength=\"$mail_max\""; }
		if($hp_max > 0)		{ $work_hp = "maxlength=\"$hp_max\""; }
		if($title_max > 0)	{ $work_title = "maxlength=\"$title_max\""; }
	}

	if($flag_secret == 1)
	{
		$chk_secret = " <input type=\"checkbox\" name=\"secret\" id=\"secret\" value=\"on\" class=\"none\"><label for=\"secret\">$LABEL[11]</label>";
	}

	print <<"HERE";
<table summary="入力フォーム" class="form">
<tr><th><label for="name">$LABEL[0]</label></th>
<td><input type="text" name="name" id="name" size="$form_name" $work_name value="$in{'name'}"></td></tr>
HERE

	if($flag_mail_input == 1)
	{
		print "<tr><th><label for=\"mail\">$LABEL[1]</label></th>\n";
		print "<td><input type=\"text\" name=\"mail\" id=\"mail\" size=\"$form_mail\" $work_mail value=\"$in{'mail'}\"></td></tr>\n";
	}
	if($flag_hp_input == 1)
	{
		print "<tr><th><label for=\"hp\">$LABEL[2]</label></th>\n";
		print "<td><input type=\"text\" name=\"hp\" id=\"hp\" size=\"$form_hp\" $work_hp value=\"$in{'hp'}\">$chk_secret</td></tr>\n";
	}
	print <<"HERE";
<tr><th><label for="title">$LABEL[3]</label></th>
<td><input type="text" name="title" id="title" size="$form_title" $work_title value="$in{'title'}"> 
 <input type="submit" value="$button" class="button_no_margin"></td></tr>
<tr valign="top"><th><label for="comment">$LABEL[4]</label></th>
<td><textarea name="comment" id="comment" rows="$form_comment_row" cols="$form_comment_col">$in{'comment'}</textarea>
</td></tr>
HERE

	if($flag_color == 1)
	{
		# 文字色設定
		if($in{'color'} eq '') { $in{'color'} = $COLOR[0]; }
		print "<tr><th>$LABEL[5]</th><td>\n";
		foreach (0 .. $#COLOR)
		{
			if($in{'color'} eq $COLOR[$_])	{ $work = ' checked'; }
			else							{ $work = ''; }
			print "<input type=\"radio\" name=\"color\" id=\"color$_\" class=\"none\" value=\"$COLOR[$_]\"$work>\n";
			print "<label for=\"color$_\"><font color=\"$COLOR[$_]\">■</font></label>\n";
		}
		print "</td></tr>\n";
	}

	if($flag_icon == 1)
	{
		# アイコン設定
		if($in{'icon'} eq '') { $in{'icon'} = $ICONF[0]; }
		print "<tr><th>$LABEL[6]</th>\n";
		print "<td><select name=\"icon\">\n";
		foreach (0 .. $#ICON)
		{
			if($in{'icon'} eq $ICONF[$_])	{ $work = ' selected'; }
			else							{ $work = ''; }
			print "<option value=\"$ICONF[$_]\"$work>$ICON[$_]\n";
		}
		# 管理者用アイコン
		if($my_icon ne '')
		{
			if($in{'icon'} eq $my_icon)	{ $work = ' selected'; }
			else						{ $work = ''; }
			print "<option value=\"$my_icon\"$work>管理者用\n";
		}
		print "</select> 【<a href=\"$cgi&amp;act=icon_list\" target=\"_blank\">$LABEL[7]</a>】</td></tr>\n";
	}

	print <<"HERE";
<tr><th><label for="pass">$LABEL[8]</label></th>
<td><input type="password" name="pass" id="pass" size="$form_pass" maxlength="8" value="$in{'pass'}"> 
(<em>記事の編集・削除時に使用。半角英数字で8文字以内</em>)</td></tr>
HERE

	if($regist_key ne '')
	{
		print "<tr><th><label for=\"regist_key\">$LABEL[12]</label></th>";
		print "<td><input type=\"text\" name=\"regist_key\" id=\"regist_key\" size=\"$form_regist_key\" value=\"$in{'regist_key'}\"> ";
		if($flag_regist_key == 1)
		{
			print "(左の入力欄に「<em>$regist_key</em>」と入力してください)";
		}
		else
		{
			print "(管理人から$LABEL[12]を入手してください)";
		}
		print "</td></tr>\n";
	}

	print "</table></form>\n";
}
#==========================================================
# スレッド一覧
#==========================================================
sub thread_list
{
	if($flag_thread_list != 1) { return; }

	print "<h2><a name=\"skip_thread_list\">スレッド一覧</a></h2>\n";
	print "<table border=\"1\" summary=\"スレッドのタイトル一覧\" class=\"table_thread\">\n";
	print "<tr><td>\n";

	foreach $line(@DATA)
	{
		&val_r($line);
		if($res == 0)
		{
			if(length($title) > 30) { $title = substr($title,0,28) . '...'; }
			print "<a href=\"$cgi&amp;act=response&amp;m_no=$no\">$title</a> ($sno) / \n";
		}
	}
	print "</td></tr></table>\n<hr>\n";
}
#==========================================================
# 記事一覧
#==========================================================
sub article_list
{
	my $flag,$start,$end,$work;

	$thread_number = 0;
	if($data_number == 0) { return; }

	# スレッドの表示範囲
	$start = ($in{'page'}-1)*$thread_page + 1;
	$end   = $start + $thread_page - 1;

	$flag = 0;
	foreach $line(@DATA)
	{
		&val_r($line);
		if(($res < 0) || ($sno < 0)) { next; }

		if($res == 0) { $thread_number++; }
		if($thread_number > $end) { next; }
		if($thread_number < $start) { next; }
		if($res == 0)
		{
			if($flag == 1) { print "</td></tr></table>\n"; }
			&article(0,0);
			$flag = 1;
		}
		else
		{
			&article(1,0);
			print "</td></tr></table>\n";
		}
	}
	if($flag == 1) { print "</td></tr></table>\n"; }
}
#==========================================================
# 記事の表示
#
# input  : 0 = 0/1/2/3 = 親/レス/検索結果
#          1 = 0/1 = 通常/管理人に送る
#==========================================================
sub article
{
	my $style,$work;

	if($_[0] != 1)	{ $style = 'article_mother'; }
	else			{ $style = 'article_response'; }
	if(($mail ne '') && ($flag_mail_input == 1))	{ $name = "<a href=\"mailto:$mail\">$name</a>"; }
	else											{ $name = "<span class=\"name\">$name</span>"; }

	print "<table border=\"1\" class=\"$style\" summary=\"$noの記事\">\n";
	print "<tr><td class=\"$style\"><div>No.$no - $title </div>\n投稿者:";
	print "<strong>$name</strong> 投稿日:$date \n";
	if(($hp ne '') && ($flag_hp_input == 1)) { print " <strong><a href=\"$hp\" target=\"_blank\">HP</a></strong>\n"; }

	if($_[0] == 0)
	{
		if($sno < $res_max )
		{
			if($_[1] == 0)
			{
				print " [ <a href=\"$cgi&amp;act=response&amp;m_no=$no\">返信</a> ]\n";
			}
			else
			{
				print " [ <a href=\"$cgi&amp;act=edit&amp;no=$no&amp;pass=$password&amp;process=secret_res\">スレッド一覧</a> ] (res : $sno)\n";
			}
		}
	}
	elsif(($_[0] == 2) && ($_[1] == 0))
	{
		if($res <= 0)	{ $work = $no; }
		else			{ $work = $res; }
		print " [ <a href=\"$cgi&amp;act=response&amp;m_no=$work\">スレッド一覧</a> ]\n";
	}

	if($flag_url_link == 1) { &common'auto_link($comment,1); }
	if($flag_color != 1)	{ $color = $amain_fcolor; }
	elsif($color eq '')		{ $color = $COLOR[0]; }
	print "<table summary=\"コメント\" class=\"comment\"><tr valign=\"top\">\n";
	if($flag_icon == 1)
	{
		if($icon eq '') { $icon = $ICONF[0]; }
		print "<th><img src=\"$icon_dir$icon\" alt=\"\"></th>\n";
	}
	print "<td><font color=\"$color\">\n$comment\n</font></td></tr></table>\n";
}
#==========================================================
# ページ情報
#==========================================================
sub page_info
{
	my $start,$p,$page,$label,$input;

	# コメント総数・ページ数の表示
	print <<"HERE";
<hr>
<table summary="ページ情報" class="page_info">
<tr valign="middle"><td>
現在 <strong class="lv1">$data_number</strong> 件の書込みがあります<br>
ページ数 :
HERE

	if($thread_number == 0)
	{
		print "<strong class=\"lv1\">1</strong> /\n";
	}
	else
	{
		$p = 0;
		$start = 1;
		while($start <= $thread_number)
		{
			if(++$p != $in{'page'})	{ $page = "<a href=\"$cgi&amp;page=$p\">$p</a>"; }
			else					{ $page = "<em>$p</em>"; }
			print "<strong>$page</strong> / ";
			$start += $thread_page;
		}
	}
	print "</td><td width=\"10\"> </td><td>\n";
	$label = "記事の編集・削除";
	if($flag_secret_res == 1)
	{
		$label .= "/管理人からのレスの確認";
		$input = "<input type=\"radio\" name=\"process\" id=\"secret_res\" value=\"secret\" class=\"none\"><label for=\"secret_res\">管理人からのレスの確認</label> ";
	}

	# コメントの編集・削除フォーム
	print <<"HERE";
<form method="POST" action="$cgi_top">
<input type="hidden" name="l_no" value="$l_no">
<input type="hidden" name="p_in" value="$pass_in">
<input type="hidden" name="p_write" value="$in{'p_write'}">
<input type="hidden" name="act" value="edit">
【$label】<br>
<label for="no">No:</label>
<input type="text" name="no" id="no" size="4"> 
<label for="pass_edit">$LABEL[8]:</label>
<input type="password" name="pass" id="pass_edit" size="$form_pass" maxlength="8"><br>
<input type="radio" name="process" id="edit" value="edit" class="none" checked><label for="edit">編集</label> 
<input type="radio" name="process" id="delete" value="delete" class="none"><label for="delete">削除</label> 
$input
<input type="submit" class="button_no_margin" value="認証">
</form>
</td></tr></table>
HERE
}


#==========================================================
# レスの投稿ページ
# input : 0 = 0/1 = 通常/管理人に送る
#==========================================================
sub response
{
	my $flag,$sno_buf;

	&html_header;
	&thread_list;

	$flag = 0;
	foreach $line(@DATA)
	{
		&val_r($line);
		if($no == $m_no)
		{
			if($_[0] == 0)
			{
				if(($res < 0) || ($sno < 0))
				{
					&error_end("この記事を参照することはできません。");
				}
			}
			else
			{
				if($res >= 0) { &error_end("この記事を参照することはできません。"); }
				if(($pass ne crypt($in{'pass'},"xx")) && ($in{'pass'} ne $password))
				{
					&error_input("パスワードが違います。",0);
				}
			}
			&article(0,$_[0]);
			$sno_buf = $sno;
			$mother_title = "Re:$title";
			$flag = 1;
		}
		elsif(($flag == 1) && ($res == $m_no))
		{
			&article(1,$_[0]);
			print "</td></tr></table>\n";
		}
		elsif(($flag == 1) && ($no != $m_no))
		{
			last;
		}
	}
	print "</td></tr></table><hr>\n";

	if(($sno_buf >= $res_max) && ($res_max != 0))	{ &error_end("レスの数が最大数に達しているため、これ以上のレスはできません。"); }
	else											{ &new_form; }
	&html_footer;
	exit;
}

#==========================================================
# 投稿
#==========================================================
sub contribution
{
	my $new_no,$flag,$k_no,$new_val,$work;

	if($m_no == 0)	{ $flag = 0; }
	else			{ $flag = 1; }
	&input_check($flag);
	&file_lock($flag);

	# 記事ナンバーの取得と、2重投稿の確認
	$new_no = 1;
	$work = $in{'comment'};
	$work =~ s/\r/<br>/g;
	if(@DATA != '')
	{
		foreach $line(@DATA)
		{
			&val_r($line);
			if($no > $new_no) { $new_no = $no; }
			if($comment eq $work)
			{
				$flag_input = 2;
				&file_unlock;
				&log_read;
				return;
			}
			if($no == $m_no)
			{
				if(($sno >= $res_max) && ($res_max > 0))
				{
					&error_end("レスの数が最大数に達しているため、これ以上のレスはできません");
				}
				else
				{
					$sno++;
					$line = &val_w;
				}
			}
		}
		$new_no++;
	}

	$no = $new_no;
	$res = $m_no;
	if($m_res == 0)	{ $sno = 0; }
	else			{ $sno = -1; }
	$name = $in{'name'};
	$mail = $in{'mail'};
	$hp = $in{'hp'};
	$title = $in{'title'};
	$comment = $in{'comment'};
	$comment =~ s/\r/<br>/g;
	$color = $in{'color'};
	$icon = $in{'icon'};
	$pass = crypt($in{'pass'},"xx");
	$ip = $ENV{'REMOTE_ADDR'};
	$host = &common'get_host($ip);
	$date = &common'get_datetime(1,1,1);
	if($in{'secret'} eq 'on') { $res = -1; }
	$new_val = &val_w;

	# 記事の追加
	if($m_no == 0)
	{
		unshift(@DATA,$new_val);
	}
	else
	{
		if($flag_res_top == 1)
		{
			# レスのついた記事をトップに移動
			$flag = 0;
			foreach $line(@DATA)
			{
				&val_r($line);
				if(($no == $m_no) || ($res == $m_no))
				{
					$flag = 1;
					push(@DATA2,$line);
					$line = '';
				}
				elsif($flag == 1)
				{
					last;
				}
			}
			push(@DATA2,$new_val);
			@DATA = (@DATA2,@DATA);
		}
		else
		{
			@DATA = reverse @DATA;
			foreach $line(@DATA)
			{
				&val_r($line);
				if(($no == $m_no) || ($res == $m_no))
				{
					$line .= $new_val;
					last;
				}
			}
			@DATA = reverse @DATA;
		}
	}

	# コメント記録数の確認
	if(@DATA > $article_max)
	{
		@DATA2 = reverse @DATA;
		&val_r($DATA2[0]);
		$k_no = $res;
		if($res <= 0)
		{
			pop @DATA;
		}
		else
		{
			foreach $line(@DATA2)
			{
				&val_r($line);
				if(($no == $k_no) || ($res == $k_no))	{ pop @DATA; }
				else									{ last; }
			}
		}
	}
	&log_write;
	&file_unlock;
	&set_cookie;
	$flag_input = 2;
	&log_read;

	&html_header;
	if($m_res != 0)
	{
		$m_res = 0;
		$in{'secret'} = 'on';
	}
	if($in{'secret'} eq 'on')
	{
		print "<p><strong class=\"lv1\">管理人にメッセージを送信しました</strong></p>\n";
		if(($flag_secret_res == 1) && ($m_no == 0))
		{
			print "<br><p>管理人からのレスを掲示板下部より確認することができます。<br>\n";
			print "下記No.と $LABEL[8] を忘れないように控えておいてください。<br><br>\n";
			print "No. <strong class=\"lv1\">$no</strong> 、 $LABEL[8] : <strong class=\"lv1\">$in{'pass'}</strong></p>\n";
		}
	}
}
#==========================================================
# 入力内容の確認
#
# input  : 0 = 0/1/2 = 新規/レス/編集
#==========================================================
sub input_check
{
	my $len, $flag, $mode, $mail_regex, $url_regex;
	local($ref);

	$mode = $_[0];

	if(($flag_contribution == 1) && ($mode != 2)) { &error_end("現在投稿禁止になっています。"); }
	if(($flag_method == 1) && ($g_f_post == 0)) { &error_end("不正なアクセスです。"); }
	if($baseUrl ne '')
	{
		$ref = $ENV{'HTTP_REFERER'};
		$ref =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("H2", $1)/eg;
		$baseUrl =~ s/(\W)/\\$1/g;
		if($ref && $ref !~ /$baseUrl/i) { &error_end("不正なアクセスです"); }
	}

	# 禁止ホスト確認
	$flag = 0;
	$ip = $ENV{'REMOTE_ADDR'};
	$host = &common'get_host($ip);
	if($nuisance_host ne '')
	{
		foreach(split(/\s+/, $nuisance_host))
		{
			s/\./\\\./g;
			s/\*/\.\*/g;
			if($host =~ /$_$/i)
			{
				$flag = 1;
				last;
			}
		}
		if($flag) { &error_end("アクセスを許可されていません。"); }
	}
	# 禁止IPアドレス確認
	if($nuisance_ip ne '')
	{
		foreach(split(/\s+/, $nuisance_ip))
		{
			s/\./\\\./g;
			s/\*/\.\*/g;
			if($ip =~ /^$_/i)
			{
				$flag = 1;
				last;
			}
		}
		if($flag) { &error_end("アクセスを許可されていません。"); }
	}

	# 入力確認
	$flag_input = 1;

	if(($none_name ne '') && ($in{'name'} eq '')) { $in{'name'} = $none_name; }

	if($in{'name'} eq '')		{ &error_input("$LABEL[0]を入力してください。",$mode); }
	if($in{'title'} eq '')		{ &error_input("$LABEL[3]を入力してください。",$mode); }
	if($in{'comment'} eq '')	{ &error_input("$LABEL[4]を入力してください。",$mode); }
	if(($in{'pass'} eq '') && ($in{'secret'} eq 'on')) { &error_input("$LABEL[8]を入力してください。",$mode); }

	if((length($in{'name'}) > $name_max) && ($name_max > 0))	{ &error_input("$LABEL[0]は半角$name_max文字以内で記入してください。",$mode); }
	if((length($in{'mail'}) > $mail_max) && ($mail_max > 0))	{ &error_input("$LABEL[1]は半角$mail_max文字以内で記入してください。",$mode); }
	if((length($in{'hp'}) > $hp_max) && ($hp_max > 0))			{ &error_input("$LABEL[2]は半角$hp_max文字以内で記入してください。",$mode); }
	if((length($in{'title'}) > $title_max) && ($title_max > 0))	{ &error_input("$LABEL[3]は半角$title_max文字以内で記入してください。",$mode); }
	if((length($in{'comment'}) > $comment_max) && ($comment_max > 0))	{ &error_input("$LABEL[4]は半角$comment_max文字以内で記入してください。",$mode); }
	if($flag_icon == 1)
	{
		if(($in{'icon'} eq $my_icon) && ($in{'pass'} ne $password)) { &error_input("管理者用$LABEL[6]には管理パスワードが必要です。",$mode); }
	}

	# 投稿キーの確認
	if($regist_key ne '')
	{
		if($in{'regist_key'} ne $regist_key)
		{
			&error_input("$LABEL[12]が違います。入力しなおしてください。",$mode);
		}
	}

	# メールアドレスの確認
	$mail_regex =
		q{(?:[^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\\} .
		q{\[\]\000-\037\x80-\xff])|"[^\\\\\x80-\xff\n\015"]*(?:\\\\[^\x80-\xff][} .
		q{^\\\\\x80-\xff\n\015"]*)*")(?:\.(?:[^(\040)<>@,;:".\\\\\[\]\000-\037\x} .
		q{80-\xff]+(?![^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff])|"[^\\\\\x80-} .
		q{\xff\n\015"]*(?:\\\\[^\x80-\xff][^\\\\\x80-\xff\n\015"]*)*"))*@(?:[^(} .
		q{\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\\\[\]\0} .
		q{00-\037\x80-\xff])|\[(?:[^\\\\\x80-\xff\n\015\[\]]|\\\\[^\x80-\xff])*} .
		q{\])(?:\.(?:[^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,} .
		q{;:".\\\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\\\x80-\xff\n\015\[\]]|\\\\[} .
		q{^\x80-\xff])*\]))*};
	if(($in{'mail'} ne '') && ($flag_input_mail == 1) && ($in{'mail'} !~ /^$mail_regex$/o)) { &error_input("$LABEL[1]の入力が不正です。",$mode); }


	# URLの確認
	$url_regex =
		q{\b(?:https?|shttp)://(?:(?:[-_.!~*'()a-zA-Z0-9;:&=+$,]|%[0-9A-Fa-f} .
		q{][0-9A-Fa-f])*@)?(?:(?:[a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.)} .
		q{*[a-zA-Z](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.?|[0-9]+\.[0-9]+\.[0-9]+\.} .
		q{[0-9]+)(?::[0-9]*)?(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f]} .
		q{[0-9A-Fa-f])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-} .
		q{Fa-f])*)*(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f} .
		q{])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)*)} .
		q{*)?(?:\?(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])} .
		q{*)?(?:#(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*} .
		q{)?};
	if(($in{'hp'} ne '') && ($flag_input_url == 1) && ($in{'hp'} !~ /^$url_regex$/o)) { &error_input("$LABEL[2]の入力が不正です。",$mode); }


	# 禁止ワードの確認
	foreach(0 .. $#PROHIBITION_WORD)
	{
		if($PROHIBITION_WORD[$_] eq '') { last; }
		if(index($in{'name'}, $PROHIBITION_WORD[$_]) >= 0) { &error_input("$LABEL[0]に禁止ワードが含まれています。",$mode); }
		if(index($in{'title'}, $PROHIBITION_WORD[$_]) >= 0) { &error_input("$LABEL[3]に禁止ワードが含まれています。",$mode); }
		if(index($in{'comment'}, $PROHIBITION_WORD[$_]) >= 0) { &error_input("$LABEL[4]に禁止ワードが含まれています。",$mode); }
	}

	# コメントの確認
	if(($flag_url_filter == 1) && ($in{'hp'} ne ''))
	{
		if(index($in{'comment'}, $in{'hp'}) >= 0)
		{
			&error_input("$LABEL[2]に記入したURLを$LABEL[4]内に記入しないでください。",$mode);
		}
	}
	if($flag_url_filter2 == 1)
	{
		if(index($in{'comment'}, 'ttp://') >= 0)
		{
			&error_input("$LABEL[4]内にURLを記入しないでください。",$mode);
		}
	}

	# コメントの確認2
	if($comment_2byte > 0)
	{
		local($ems) = $in{'comment'};
		$ems =~ s/,//g;
		&jcode'convert(*ems, "euc");
		$len = $ems =~ tr/\xa1-\xfe/\xa1-\xfe/;
		$len /= 2;
		if($len < $comment_2byte) { &error_input("全角文字を$comment_2byte文字以上入力してください。",$mode); }
	}
}


#==========================================================
# ユーザー処理
#==========================================================
sub edit
{
	if($in{'no'} eq '')			{ &error_input("編集・削除する記事のNoが記入されていません。",0); }
	elsif($in{'pass'} eq '')	{ &error_input("パスワードが記入されていません。",0); }
	if($in{'process'} eq 'edit')		{ &user_edit; }
	elsif($in{'process'} eq 'delete')	{ &user_delete; }
	else								{ &secret_res; }
}
#==========================================================
# 記事の編集
#==========================================================
sub user_edit
{
	my $flag,$edit_value;

	if($in{'edit_no'} ne '')
	{
		&input_check(2);
		&file_lock(2);
		foreach $line(@DATA)
		{
			&val_r($line);
			if($no == $in{'edit_no'})
			{
				$name = $in{'name'};
				$mail = $in{'mail'};
				$hp = $in{'hp'};
				$title = $in{'title'};
				$comment = $in{'comment'};
				$comment =~ s/\r/<br>/g;
				$color = $in{'color'};
				$icon = $in{'icon'};
				$pass = crypt($in{'pass'},"xx");
				$ip = $ENV{'REMOTE_ADDR'};
				$host = &common'get_host($ip);
				$date = &common'get_datetime(1,1,1);

				$line = &val_w;
				&log_write;
				&file_unlock;
				&set_cookie;
				$flag_input = 2;
				&top_page;
			}
		}
		&file_unlock;
		&error_input("指定した記事はすでに削除されています。",0);
	}

	$flag = 0;
	foreach $line(@DATA)
	{
		&val_r($line);
		if($no == $in{'no'})
		{
			$flag = 1;
			if(($pass ne crypt($in{'pass'},"xx")) && ($password ne $in{'pass'})) { $flag = 2; }
			last;
		}
	}
	if($flag == 0)		{ &error_input("指定したNoの記事はありません。",0); }
	elsif($flag == 2)	{ &error_input("パスワードが違います。",0); }

	$in{'name'} = $name;
	$in{'mail'} = $mail;
	$in{'hp'} = $hp;
	$in{'title'} = $title;
	$in{'comment'} = $comment;
	$in{'color'} = $color;
	$in{'icon'} = $icon;
	$in{'comment'} =~ s/<br>/\r/g;

	&html_header;
	&edit_form;
	&html_footer;
	exit;
}


#==========================================================
# 記事の削除
#==========================================================
sub user_delete
{
	my $flag;

	&file_lock(0);
	$in{'pass'} = crypt($in{'pass'},"xx");

	$flag = 0;
	foreach $line(@DATA)
	{
		&val_r($line);
		if($no == $in{'no'})
		{
			if($pass eq ($in{'pass'}) || ($in{'pass'} eq crypt($password,"xx")))
			{
				$flag = 1;
				$line = '';
				if($sno == 0) {	last; }
			}
			else
			{
				&file_unlock;
				&error_input("パスワードが違います。",0);
			}
		}
		elsif(($res == $in{'no'}) && ($flag == 1))
		{
			$line = '';
		}
		elsif(($res != $in{'no'}) && ($flag == 1))
		{
			last;
		}
	}

	if($flag == 1)
	{
		&log_write;
		&res_count_set;
		&file_unlock;
		&top_page;
	}
	else
	{
		&file_unlock;
		&error_input("指定したNoの記事はありません。",0);
	}
}


#==========================================================
# 管理人からのレスの確認
#==========================================================
sub secret_res
{
	$m_no = $in{'no'};
	$m_res = -1;

	&response(-1);
}


#==========================================================
# 記事検索
#
# 検索は投稿者名、タイトル、コメントから行う
#==========================================================
sub retrieval
{
	my $i,$flag,$check_and,$check_or,$key,$key_line;

	$check_and = '';
	$check_or  = '';
	if($in{'mode'} eq 'OR')	{ $check_or = ' checked'; }
	else					{ $check_and = ' checked'; }

	&html_header;
	print <<"HERE";
<h2><a name="skip_page_title">記事検索</a></h2>
<p>検索は$LABEL[0]、$LABEL[3]、$LABEL[4]から行われます。<br>
検索文字列はスペースで区切って複数入力ができます。</p>

<form method="POST" action="$cgi_top">
<input type="hidden" name="l_no" value="$l_no">
<input type="hidden" name="p_in" value="$pass_in">
<input type="hidden" name="p_write" value="$in{'p_write'}">
<input type="hidden" name="act" value="retrieval">
<input type="text" size="40" name="key" value="$in{'key'}"> 
<input type="submit" class="button_no_margin" value="検索"><br>
検索タイプ:
<input type="radio" name="mode" id="and" value="AND" class="none"$check_and><label for="and">AND</label> 
<input type="radio" name="mode" id="or" value="OR" class="none"$check_or><label for="or">OR</label>
</form>
<hr>
HERE

	if($in{'key'} eq '')
	{
		print "<p>キーワードを入力して下さい。</p>\n";
	}
	else
	{
		$i = 0;
		$key = '';
		foreach $key_line(@KEY)
		{
			$key .= "<em>" . $key_line . "</em>";
			if($i++ < $#KEY) { $key .= ","; }
		}
		print "<p>キーワード : $key [$in{'mode'}検索]</p>\n";

		foreach $line(@DATA)
		{
			&val_r($line);
			if(($res < 0) || ($sno < 0)) { next; }

			$key = join(',', $name,$title,$comment) . "\n";
			$key =~ tr/[a-z]/[A-Z]/;
			if($in{'mode'} eq 'OR')
			{
				# OR検索
				$flag = 0;
				foreach $key_line(@KEY)
				{
					$key_line =~ tr/[a-z]/[A-Z]/;
					if(index($key, $key_line) >= 0)
					{
						$flag = 1;
						last;
					}
				}
			}
			else
			{
				# AND検索
				foreach $key_line(@KEY)
				{
					$flag = 0;
					$key_line =~ tr/[a-z]/[A-Z]/;
					if(index($key, $key_line) >= 0)	{ $flag = 1; }
					else							{ last; }
				}
			}
			if($flag == 1) { push(@MATCH,$line); }
		}

		$i = @MATCH;
		print "<p>ヒット件数 : $i件</p>\n";
		if($i != 0)
		{
			foreach $line(@MATCH)
			{
				&val_r($line);
				&article(2,0);
				print "</td></tr></table>\n";
			}
		}
    }

	&html_footer;
	exit;
}


#==========================================================
# 使い方
#==========================================================
sub readme
{
	if($flag_url_link == 1) { $flag_url_link = 'on'; }
	else					{ $flag_url_link = 'off'; }

	&html_header;
	print <<"HERE";
<h2><a name="skip_page_title">使い方</a></h2>

<ul>
<li><strong class="lv1">投稿する</strong><br>
掲示板上部の投稿フォームから投稿できます。<br>
「PASS」は自分で投稿した記事の編集・削除に使用します。<br>
「PASS」の入力は必須ではありませんが、未入力だと自分での編集・削除が行えなくなります。<br>
入力項目については下記「入力制限」を参照下さい。</li>
HERE

	if($flag_secret == 1)
	{
		print <<"HERE";
<li><strong class="lv1">$LABEL[11]</strong><br>
「$LABEL[11]」にチェックを付けて投稿した記事は管理人にしか見る事ができません。<br>
簡易メールの代わりとして、管理人にだけメッセージを送りたい場合に使用してください。<br>
HERE

		if($flag_secret_res == 1)
		{
			print "掲示板下部より管理人からレスがついているかを確認することができます。\n";
		}
		print "</li>\n";
	}

	print <<"HERE";
<li><strong class="lv1">レスをする</strong><br>
各スレッドの親記事にある「返信」リンクを押すと返信フォームに移動します。<br>
親記事に「返信」リンクがない場合、すでにレスの数が満タンになっておりそれ以上レスをすることはできません。</li>

<li><strong class="lv1">記事を編集する</strong><br>
掲示板下部の「記事の編集・削除」フォームから編集フォームに移動できます。<br>
「No」に編集したい記事の番号、「PASS」に投稿時に時入力したPASSを入力します。<br>
そして「編集」にチェックが付いている事を確認し「認証」ボタンを押して下さい。<br>
すると編集フォームに移動できます。<br>
<br>
管理人は管理パスワードを入力することで、強制的に編集することが可能\です。<br>
一度管理パスワードで編集した記事は、その後管理人にしか編集できません。</li>

<li><strong class="lv1">記事を削除する</strong><br>
掲示板下部の「記事の編集・削除」フォームから削除できます。<br>
「No」に削除したい記事の番号、「PASS」に投稿時に時入力したPASSを入力します。<br>
そして「削除」にチェックが付いている事を確認し「認証」ボタンを押して下さい。<br>
すると指定した番号の記事が削除されます。<br>
<br>
管理人は管理パスワードを入力することで、強制的に削除することが可能\です。</li>

<li><strong class="lv1">検索する</strong><br>
掲示板上部の「記事検索」リンクを押すと検索フォームへ移動します。<br>
検索したいキーワードを入力して「検索」ボタンを押して下さい。<br>
キーワードは半角、または全角スペースで区切る事で複数入力できます。<br>
複数入力する場合は「検索タイプ」を指定して下さい。<br>
それぞれ下記の条件で検索します。<br>
<br>
AND:全てのキーワードに一致する記事を検索する。<br>
OR:キーワードのどれか1つでも一致する記事を検索する。</li>

<li><strong class="lv1">設定情報</strong><br>
最大記事記録数 : <strong>$article_max</strong> 件<br>
最大表\示スレッド数 : <strong>$thread_page</strong> 件<br>
最大レス可能\件数 : <strong>$res_max</strong> 件<br>
コメント内のURLへの自動リンク : <strong>$flag_url_link</strong></li>

<li><strong class="lv1">入力制限</strong><br>
HERE

	if($none_name eq '')	{ print "$LABEL[0] : 必須、"; }
	else					{ print "$LABEL[0] : 任意、"; }
	if($name_max == 0)	{ print "制限無し"; }
	else				{ print "半角 <strong>$name_max</strong> 文字まで"; }
	if($flag_mail_input == 1)
	{
		print "<br>\n$LABEL[1] : 任意、";
		if($mail_max == 0)	{ print "制限無し"; }
		else				{ print "半角 <strong>$mail_max</strong> 文字まで"; }
	}
	if($flag_hp_input == 1)
	{
		print "<br>\n$LABEL[2] : 任意、";
		if($hp_max == 0)	{ print "制限無し"; }
		else				{ print "半角 <strong>$hp_max</strong> 文字まで"; }
	}
	print "<br>\n$LABEL[3] : 必須、";
	if($title_max == 0)	{ print "制限無し"; }
	else				{ print "半角 <strong>$title_max</strong> 文字まで"; }
	print "<br>\n$LABEL[4] : 必須、";
	if($comment_max == 0)	{ print "制限無し"; }
	else					{ print "半角 <strong>$comment_max</strong> 文字まで"; }
	if($comment_2byte > 0) { print "、2バイト文字を <strong>$comment_2byte</strong> 文字以上入力する必要あり。"; }

	print "<br>\n<br>また、HTMLタグは一切使用できません。</li>\n</ul>\n";
	&html_footer;
	exit;
}


#==========================================================
# アイコン画像の一覧
#==========================================================
sub icon_list
{
	my $i;

	&html_header;
	print "<h2>アイコン画像の一覧</h2>\n";
	print "<table border=\"1\" summary=\"アイコン画像の一覧\" class=\"table_icon\">\n";
	print "<tr valign=\"top\" height=\"$icon_height\">\n";
	$i = 0;
	foreach (0 .. $#ICON)
	{
		if($i++ == 5)
		{
			print "</tr><tr valign=\"top\" height=\"$icon_height\">\n";
			$i = 1;
		}
		print "<td width=\"$icon_width\"><img src=\"$icon_dir$ICONF[$_]\"><br>$ICON[$_]</td>\n";
	}
	for($i=$i;$i<5;$i++) { print "<td width=\"$icon_width\"></td>\n"; }
	print "</tr></table>\n";
	&html_footer;
	exit;
}


#==========================================================
# 管理モード
#==========================================================
sub management
{
	if($in{'pass'} ne '')
	{
		if(($in{'pass'} eq $password) || ($in{'pass'} eq crypt($password,"xx")))
		{
			$in{'pass'} = crypt($password,"xx");
			&management_delete;
		}
		else
		{
			&error("パスワードが違います。");
		}
	}

	&html_header;
	print <<"HERE";
<h2><a name="skip_page_title">管理モード</a></h2>
<p>パスワードを入力して下さい。</p>
<form method="POST" action="$cgi_top">
<input type="hidden" name="l_no" value="$l_no">
<input type="hidden" name="p_in" value="$pass_in">
<input type="hidden" name="p_write" value="$in{'p_write'}">
<input type="hidden" name="act" value="management">
<input type="password" name="pass"><br>
<input type="submit" class="button" value="認証">
</form>
HERE
	&html_footer;
	exit;
}
#==========================================================
# 管理モード(削除)
#==========================================================
sub management_delete
{
	my $line,$del;

	unless(@DEL == '')
	{
		&file_lock(0);
		foreach $line(@DATA)
		{
			&val_r($line);
			foreach $del(@DEL)
			{
				if(($no == $del) || ($res == $del)) { $line = ''; }
			}
		}
		&log_write;
		&res_count_set;
		&file_unlock;
	}

	&html_header;
	print "<h2><a name=\"skip_page_title\">管理モード</h2>\n";
	print "<p>「$LABEL[11]」の記事</p>\n";
	foreach $line(@DATA)
	{
		&val_r($line);
		if($res < 0)
		{
			&article(0,1);
			print "</td></tr></table>\n";
		}
	}

	print <<"HERE";
<hr>
<p>削除したい記事にチェックを入れて削除ボタンを押して下さい。<br>
親記事を削除すると、レスも全て削除されます。<br>
注:resが「-1」は「$LABEL[11]」の記事です。</p>

<form method="POST" action="$cgi_top">
<input type="hidden" name="l_no" value="$l_no">
<input type="hidden" name="p_in" value="$pass_in">
<input type="hidden" name="p_write" value="$pass_write">
<input type="hidden" name="act" value="management">
<input type="hidden" name="pass" value="$in{'pass'}">
<input type="submit" class="button" value="削除"><br>

<table border="1" class="table" summary="ログ一覧">
<tr><th>削除</th><th>No(res)</th><th>投稿者</th><th>タイトル</th>
<th>投稿日</th><th>コメント</th><th>ホスト</th><th>IP</th></tr>
HERE

	foreach $line(@DATA)
	{
		&val_r($line);
		if(length($name) > 20) { $name = substr($name, 0, 18) . '...'; }
		if(length($title) > 20) { $title = substr($title, 0, 18) . '...'; }
		$comment =~ s/<br>//g;
		if(length($comment) > 40) { $comment = substr($comment, 0, 38) . '...'; }
		if($res != 0)	{ $res = " ( $res )"; }
		else			{ $res = ""; }
		$date = substr($date, 0, 10);

		print "<tr><td><input type=\"checkbox\" name=\"del\" value=\"$no\" class=\"none\"></td>\n";
		print "<td>$no$res</td><td>$name</td>\n";
		print "<td>$title</td><td>$date</td><td>$comment</td>\n";
		print "<td>$host</td><td>$ip</td></tr>\n";
	}
	print "</table></form>\n";
	&html_footer;
	exit;
}


#==========================================================
# レス数のカウント
#==========================================================
sub res_count_set
{
	my $count;

	&log_read;
	@DATA = reverse @DATA;

	$count = 0;
	foreach $line(@DATA)
	{
		&val_r($line);
		if($res > 0)
		{
			$count++;
		}
		else
		{
			$sno = $count;
			$line = &val_w;
			$count = 0;
		}
	}

	@DATA = reverse @DATA;
	&log_write;
}


#==========================================================
# cookieの読込み
#==========================================================
sub get_cookie
{
	($in{'name'},$in{'mail'},$in{'hp'},$in{'color'},$in{'icon'},$in{'pass'}) = split(/\,/,&common'get_cookie('sayaka'));
}
#==========================================================
# cookieの書込み
#==========================================================
sub set_cookie
{
	local($data);

	$data = "$in{'name'}\,$in{'mail'}\,$in{'hp'}\,$in{'color'}\,$in{'icon'}\,$in{'pass'}";
	$set_cookie = &common'set_cookie('sayaka',30,$data);
}


#==========================================================
# ファイルのロック
#
# input  : 0 = 0/1/2 = 新規/レス/編集
#==========================================================
sub file_lock
{
	if($flag_lock == 1)
	{
		if(&common'file_lock($lock_file) == 1)
		{
			&error_input('アクセスが集中しているため処理を続行できません。<br>しばらく待ってから再度行ってください。',$_[0]);
		}
	}
	return;
}
#==========================================================
# ファイルロックの解除
#==========================================================
sub file_unlock
{
	&common'file_unlock($lock_file);
}


#==========================================================
# value
#
# $res = 親記事 : 負の値なら管理人への投稿
#        レス   : 親記事のNo
# $sno = 親記事 : レスの数
#        レス  : 負の値なら管理人からのレス
#==========================================================
sub val_r
{
	($date,$no,$res,$sno,$name,$mail,$title,$color,$icon,$hp,$comment,$host,$ip,$pass) = split(/\,/,$_[0]);
}
sub val_w
{
	return(join(',', $date,$no,$res,$sno,$name,$mail,$title,$color,$icon,$hp,$comment,$host,$ip,$pass,"\n"));
}


#==========================================================
# ログデータの読込み
#==========================================================
sub log_read
{
	if(!open(NOTE,"$log_file")) { &error_end("ログファイルを開けません。<br>ログファイルが存在しないか、パスの設定を間違っている可能性があります。"); }
	@DATA = <NOTE>;
	close(NOTE);
	$data_number = @DATA;
}
#==========================================================
# ログデータの書込み
#==========================================================
sub log_write
{
	if(!open(NOTE,">$log_file")) { &error_end("ログファイルを開けません。<br>ログファイルが存在しないか、パスの設定を間違っている可能性があります。"); }
	print NOTE @DATA;
	close(NOTE);
	$data_number = @DATA;
}


#==========================================================
# エラーメッセージの表示
#
# input  : 0 = メッセージ
#==========================================================
sub error
{
	$flag_error = 1;
	&html_header;
	print "<p><strong><em>error:</em>$_[0]</strong></p>\n";
}
#==========================================================
# エラーメッセージの表示(入力エラー)
#
# input  : 0 = メッセージ
#     1 = 0/1/2 = 新規/レス/編集
#==========================================================
sub error_input
{
	&error($_[0]);
	if($_[1] == 1)
	{
		&response($m_res);
	}
	elsif($_[1] == 2)
	{
		&html_header;
		&edit_form;
		&html_footer;
		exit;
	}
	else
	{
		&top_page;
	}
}
#==========================================================
# エラーメッセージの表示(復帰無し)
#
# input  : 0 = メッセージ
#==========================================================
sub error_end
{
	&error($_[0]);
	&html_footer;
	exit;
}

Zerion Mini Shell 1.0