#!/usr/local/bin/perl

#ooooooooooooooooooooooooooooooooooooooooooooooooo
#  ダウンロードかうんた v1.02 (2006/02/23)
#  Copyright(c) 2005-2006 シリウス, All rights reserved.
#  URL    : http://www.speena.net/OnTheWind/
#  E-mail : http://www.speena.net/OnTheWind/formmail/index.html
#ooooooooooooooooooooooooooooooooooooooooooooooooo
$ver = 'ダウンロードかうんた v1.02';


#+++++++++++++++++++
#更新履歴
#+++++++++++++++++++
#○v1.02 (2006/02/23)
#・入力チェック時の不具合修正
#
#○v1.01 (2006/02/09)
#・ランキング順位表示機能追加
#・自サーバ以外のファイルも登録可能に
#
#○v1.00 (2005/12/02)
#・公開


#=======================================
#ファイル
#=======================================
#スクリプトファイル(フルパス指定は http:// から)
$script_file = './dlcnt.cgi';

#ライブラリファイル
$lib_file = './dlcnt_lib.cgi';

#設定ファイル
$ini_file = './dlcnt_ini.cgi';

#データファイル
$log_file = './data.txt';

#カテゴリファイル
$kate_file = './kate.txt';

#CSSファイル
$css_file = './dlcnt.css';


#=======================================
#外部ファイル取込
#=======================================
require './jcode.pl';
require './cgi-lib.pl';

require $lib_file;
require $ini_file;

#=======================================
#メイン処理
#=======================================
#デコード処理
&decode;

#---------------------------------------
#モードによって処理を分ける
#---------------------------------------
#ダウンロードカウント
if ($file ne "") {
	&dl_cnt;
#管理モード
} elsif ($mode eq "admin") {
	&show_admin;
#処理実行
} elsif (($mode eq "add") || ($mode eq "edit02") || ($mode eq "del") || ($mode eq "kate")) {
	&exec;
#修正データ表示
} elsif ($mode eq "edit01") {
	&show_edit;
#一覧表示
} else {
	&show_list;
}

#***************************************
# 関数ID   ：show_list
# 関数名   ：一覧表示
#***************************************
sub show_list {
	#=======================================
	#ヘッダ表示
	#=======================================
	&header;
	
	#=======================================
	#リスト作成
	#=======================================
	&make_list;

	#=======================================
	#フッタ表示
	#=======================================
	&footer;
}

#***************************************
# 関数ID   ：show_admin
# 関数名   ：管理モード表示
#***************************************
sub show_admin {
	#---------------------------------------
	#パスワード認証
	#---------------------------------------
	if ($in{'pass'} ne "" && $in{'pass'} ne $pass) {
		&error("パスワードが間違っています");
	}

	#=======================================
	#ヘッダ表示
	#=======================================
	&header;
	
	#=======================================
	#管理モード作成
	#=======================================
	&make_admin;

	#=======================================
	#フッタ表示
	#=======================================
	&footer;
}

#***************************************
# 関数ID   ：make_list
# 関数名   ：リンクリスト作成
#***************************************
sub make_list {
	#---------------------------------------
	#タイトル表示
	#---------------------------------------
	#タイトル画像を表示する場合
	if ($title_img) {
		print "<div align=\"center\">\n";
		print "	<img src=\"$title_img\" alt=\"$title_name\" height=\"$title_img_h\" width=\"$title_img_w\">\n";
		print "</div>\n\n";
	} else {
		print "<h3 class=\"title\">$title_name</h3>\n\n";
	}

	print <<"EOM";
<!-- リンク -->
<a href="$home">HOME</a> / <a href="$script_file?sort=1">カテゴリ別表\示</a> / <a href="$script_file?sort=0">全ランキング表\示</a>

<br>
<br>

<!-- 前書き -->
<div align="center">
$precomment
</div>

<br>

<!-- ファイル一覧表\示開始 -->
<table align="center" border="0" cellspacing="0" cellpadding="3">
<tr>
	<td>

EOM

	#---------------------------------------
	#リスト表示
	#---------------------------------------
	#変数初期化
	local($tbl_strt_flg) = 0;
	local($sv_kate_no) = -1;
	@kate_total = ();

	#=======================================
	#ファイル読込み
	#=======================================
	&read_file($log_file);

	#合計取得
	$top = shift(@lines);
	local($total) = split(/<>/, $top);

	#---------------------------------------
	#配列をソート
	#---------------------------------------
	#全ランキングの場合
	if (!$print_kate) {
		#配列初期化
		@tmp1 = ();

		@tmp1 = map {(split /<>/)[$cnt_index]} @lines;
		@lines = @lines[sort {$tmp1[$b] <=> $tmp1[$a]} 0 .. $#tmp1];

	#カテゴリ別の場合
	} else {
		#---------------------------------------
		#カテゴリ読込み
		#---------------------------------------
		#カテゴリファイルオープン
		open(IN, "$kate_file") || &error("Open Error : $kate_file");
		@katelist = <IN>;
		close(IN);

		#配列初期化
		@tmp1 = ();
		@tmp2 = ();

		#ソート対象項目を格納
		foreach (@lines) {
			(undef, $kate_no, $cnt) = split(/<>/);
			push(@tmp1, $kate_no);
			push(@tmp2, $cnt);
		}

		@lines = @lines[sort {$tmp1[$a] <=> $tmp1[$b] or $tmp2[$b] <=> $tmp2[$a]} 0 .. $#tmp1];

		#---------------------------------------
		#カテゴリごとに合計数算出
		#---------------------------------------
		#変数初期化
		local($kate_cnt) = 0;
		$sv_kate_no = 0;
		foreach (@lines) {
			(undef, $kate_no, $cnt) = split(/<>/);

			#前データとカテゴリが違う場合
			if ($sv_kate_no != $kate_no) {
				#配列格納
				push(@kate_total, $kate_cnt);

				#変数初期化
				$kate_cnt = 0;
			}

			#合計数加算
			$kate_cnt += $cnt;

			#カテゴリを保存
			$sv_kate_no = $kate_no;
		}
		#配列格納
		push(@kate_total, $kate_cnt);

		#変数再初期化
		$sv_kate_no = -1;
	}

	#変数初期化
	local($rank_no) = 1;

	foreach (@lines) {
		($id, $kate_no, $cnt, undef, $file_name, $link_path) = split(/<>/);

		#---------------------------------------
		#テーブル表示
		#---------------------------------------
		#---------------------------------------
		#全ランキングの場合
		#---------------------------------------
		if (!$print_kate) {
			#1つ目のデータの場合のみ、テーブル新規作成
			if ($tbl_strt_flg == 0) {
				#テーブル表示開始フラグを立てる
				$tbl_strt_flg = 1;

				print <<"EOM";
	<div class="kate">■全ランキング</div>
	<table align="center" border="0" cellspacing="3" cellpadding="1" class="list">
	<tr>
EOM

				#ランキングNoを表示する場合
				if ($print_rank_no) {
					print "		<th class=\"head\">No\n";
					print "		</th>\n";
				}

				print <<"EOM";
		<th class="head">ファイル名
		</th>
		<th class="head">$cnt_title
		</th>
EOM

				#グラフを表示する場合
				if ($print_graph) {
					$colspan++;

					print "		<th class=\"head\">グラフ\n";
					print "		</th>\n";
				}

				print "	</tr>\n";
			}

		#---------------------------------------
		#カテゴリ別の場合
		#---------------------------------------
		} else {
			#前データとカテゴリが違う場合、テーブル新規作成
			if ($sv_kate_no != $kate_no) {
				#1つ目のテーブルの場合
				if ($tbl_strt_flg == 0){
					#テーブル表示開始フラグを立てる
					$tbl_strt_flg = 1;

				#2つ目以降のテーブルの場合
				} else {
					#=======================================
					#合計数をカンマ編集
					#=======================================
					local($wk_kate_total) = &edit_comma($kate_total[$sv_kate_no]);

					#---------------------------------------
					#合計数表示
					#---------------------------------------
					print "	<tr>\n";

					#ランキングNoを表示する場合
					if ($print_rank_no) {
						print "		<td colspan=\"2\" class=\"list01\"><b>Total</b></td>\n";
					} else {
						print "		<td class=\"list01\"><b>Total</b></td>\n";
					}

					print "		<td align=\"right\" class=\"list02\">$wk_kate_total</td>\n";

					#グラフを表示する場合
					if ($print_graph) {
						print "				<td class=\"list03\">　</td>\n";
					}

					print <<"EOM";
	</tr>
	</table>
	<!-- $katelist[$sv_kate_no]終了 -->

	<br>

EOM

					#ランキングNo変数初期化
					$rank_no = 1;
				}

				print <<"EOM";
	<!-- $katelist[$kate_no]開始 -->
	<div class="kate">■$katelist[$kate_no]</div>
	<table align="center" border="0" cellspacing="3" cellpadding="1" class="list">
	<tr>
EOM

				#ランキングNoを表示する場合
				if ($print_rank_no) {
					print "		<th class=\"head\">No\n";
					print "		</th>\n";
				}

				print <<"EOM";
		<th class="head">ファイル名
		</th>
		<th class="head">$cnt_title
		</th>
EOM

				#グラフを表示する場合
				if ($print_graph) {
					print "		<th class=\"head\">グラフ\n";
					print "		</th>\n";
				}

				print "	</tr>\n";
			}
		}

		#=======================================
		#合計数をカンマ編集
		#=======================================
		local($wk_cnt) = &edit_comma($cnt);

		#---------------------------------------
		#リスト表示
		#---------------------------------------
		print "	<tr>\n";

		#ランキングNoを表示する場合
		if ($print_rank_no) {
			print "		<td align=\"right\" class=\"list00\">$rank_no</td>\n";
			$rank_no++;
		}

		print <<"EOM";
		<td class="list01"><a href="$link_path">$file_name</a></td>
		<td align="right" class="list02">$wk_cnt</td>
EOM

		#---------------------------------------
		#グラフを表示する場合
		#---------------------------------------
		if ($print_graph) {
			local($par) = "0.0%";
			local($width) = 0;

			#---------------------------------------
			#全ランキングの場合
			#---------------------------------------
			if (!$print_kate) {
				#合計が 0 以上の場合
				if ($total > 0) {
					#割合算出
					$par = sprintf("%.1f%", $cnt / $total * 100);

					#グラフ幅算出
					$width = sprintf("%d", $graph_width * ($cnt / $total));
				}

			#---------------------------------------
			#カテゴリ別の場合
			#---------------------------------------
			} else {
				#合計が 0 以上の場合
				if ($kate_total[$kate_no] > 0) {
					#割合算出
					$par = sprintf("%.1f%", $cnt / $kate_total[$kate_no] * 100);

					#グラフ幅算出
					$width = sprintf("%d", $graph_width * ($cnt / $kate_total[$kate_no]));
				}
			}

			print <<"EOM";
		<!-- グラフ表\示 -->
		<td width="$graph_width" class="list03">
		<table>
		<tr>
EOM

			#グラフ幅が 0 でなかった場合
			if ($width) {
				print "			<td width=\"$width\" class=\"graph\"></td>\n";
			}

			print <<"EOM";
			<td class="parcent">$par</td>
		</tr>
		</table>
		</td>
		<!-- グラフ表\示終了 -->
EOM
		}

		print "	</tr>\n";

		#カテゴリを保存
		$sv_kate_no = $kate_no;
	}

	#---------------------------------------
	#合計数表示
	#---------------------------------------
	local($last_total) = 0;

	#全ランキングの場合
	if (!$print_kate) {
		$last_total = $total;
	#カテゴリ別の場合
	} else {
		$last_total = $kate_total[$sv_kate_no];
	}

	#=======================================
	#合計数をカンマ編集
	#=======================================
	local($wk_total) = &edit_comma($last_total);

	print "	<tr>\n";

	#ランキングNoを表示する場合
	if ($print_rank_no) {
		print "		<td colspan=\"2\" class=\"list01\"><b>Total</b></td>\n";
	} else {
		print "		<td class=\"list01\"><b>Total</b></td>\n";
	}

	print "		<td align=\"right\" class=\"list02\">$wk_total</td>\n";

	#グラフを表示する場合
	if ($print_graph) {
		print "				<td class=\"list03\">　</td>\n";
	}

	print "	</tr>\n";

	#---------------------------------------
	#リスト表示終了
	#---------------------------------------
	print "	</table>\n";

	#カテゴリ別の場合
	if ($print_kate) {
		print "	<!-- $katelist[$sv_kate_no]終了 -->\n";
	}

	print <<"EOM";

	</td>
</tr>
</table>
<!-- ファイル一覧表\示終了 -->

<br>

<!-- 管理用 -->
<div align="right">
	<form action="$script_file" method="post">
		<input type="hidden" name="mode" value="admin">
		パスワード：<input type="password" name="pass" size="8" maxlength="8" class="text">
		<input type="submit" value="管理モード" class="button" onMouseOver="this.style.background='$btnbg_on'" onMouseOut="this.style.background='$btnbg_off'">
	</form>
</div>

EOM
}

#***************************************
# 関数ID   ：make_admin
# 関数名   ：管理モード作成
#***************************************
sub make_admin {
	print <<"EOM";
<h3 class=\"title\">管理モード</h3>

<!-- リンク -->
<a href="$home">HOME</a> / <a href="$script_file">TOP</a>

<br>

EOM

	#---------------------------------------
	#パスワードが未入力だった場合
	#---------------------------------------
	if ($in{'pass'} eq "") {
		print <<"EOM";
<center>
	<form action="$script_file" method="post">
		<b>パスワードを入力してください。</b><br>

		<input type="hidden" name="mode" value="admin">
		パスワード：<input type="password" name="pass" size="8" maxlength="8" class="text">
		<input type="submit" value="管理モード" class="button" onMouseOver="this.style.background='$btnbg_on'" onMouseOut="this.style.background='$btnbg_off'">
	</form>
</center>
EOM

	#---------------------------------------
	#管理モード作成
	#---------------------------------------
	} else {
		print <<"EOM";
<!-- メニュー開始 -->
<table align="center" border="0" cellspacing="0" cellpadding="3">

<!-- データ登録開始 -->
<tr>
	<td>
	<div class="ad_head">■データ登録</div>
	<form action="$script_file" method="post">
		<input type="hidden" name="pass" value="$in{'pass'}">
		<input type="hidden" name="mode" value="add">

		<div class="small">
		<span class="input_mark">*</span>マークは必須入力です。<br>
		各項目については、ページ下部の<a href="#explain">項目説明</a>をご覧ください。
		</div>

		<br>

		<table align="left" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td class="ad01">ID<span class="input_mark">*</span></td>
			<td>f_
			<input type="text" value="" name="id" size="20" maxlength="20" class="text" style="ime-mode: disabled;">
			</td>
		</tr>
		<tr>
			<td class="ad01">ファイル名<span class="input_mark">*</span></td>
			<td>
			<input type="text" value="" name="file_name" size="30" maxlength="50" class="text">
			</td>
		</tr>
		<tr>
			<td class="ad01">リンク先</td>
			<td>
			<input type="text" value="" name="link_path" size="30" maxlength="256" class="text" style="ime-mode: disabled;">
			</td>
		</tr>
		<tr>
			<td class="ad01">対象ファイル<span class="input_mark">*</span></td>
			<td>
			<input type="text" value="" name="file_path" size="30" maxlength="256" class="text" style="ime-mode: disabled;">
			</td>
		</tr>
		<tr>
			<td class="ad01">カテゴリ</td>
			<td>
EOM

		#---------------------------------------
		#カテゴリ読込み
		#---------------------------------------
		#カテゴリファイルオープン
		open(IN,"$kate_file") || &error("Open Error : $kate_file");
		@katelist = <IN>;
		close(IN);

		#select作成
		print "			<select name=\"kate_no\">\n";
		for ($icnt=0; $icnt<=$#katelist; $icnt++) {
			print "				<option value=\"$icnt\">No.$icnt $katelist[$icnt]\n";
		}
		print "			</select>\n";

		#---------------------------------------
		#残りのメニューを表示
		#---------------------------------------
		print <<"EOM";
			</td>
		</tr>
		<tr>
			<td colspan="2">
			<input type="submit" value="登録" class="button" onMouseOver="this.style.background='$btnbg_on'" onMouseOut="this.style.background='$btnbg_off'">
			<input type="reset" value="クリア" class="button" onMouseOver="this.style.background='$btnbg_on'" onMouseOut="this.style.background='$btnbg_off'">
			</td>
		</tr>
		</table>
			
	</form>
	</td>
</tr>
<!-- データ登録終了 -->

<!-- データ修正・削除開始 -->
<tr>
	<td>
	<div class="ad_head">■データ修正・削除</div>
	<form action="$script_file" method="post">
		<input type="hidden" name="pass" value="$in{'pass'}">

		<select name="mode">
			<option value="edit01">修正
			<option value="del">削除
		</select>

		<input type="submit" value="送信" class="button" onMouseOver="this.style.background='$btnbg_on'" onMouseOut="this.style.background='$btnbg_off'">

		<hr>

		<!-- リスト開始 -->
		<table align="left" border="0" cellspacing="3" cellpadding="3">
		<tr>
			<th class="head" colspan="2">ID</th>
			<th class="head">ファイル名</th>
			<th class="head">対象ファイル</th>
			<th class="head">カテゴリ</th>
			<th class="head">$cnt_title</th>
		</tr>
EOM

		#ログファイルオープン
		open(IN,"$log_file") || &error("Open Error : $log_file");

		$top = <IN>;
		local($strt_flg) = 0;
		while (<IN>) {
			($id, $kate, $cnt, $file_path, $file_name, $link_path) = split(/<>/);

			#---------------------------------------
			#リスト表示
			#---------------------------------------
			print <<"EOM";
		<tr>
			<td class="ad01">
EOM

			#2番目以降のデータの場合
			if ($strt_flg != 0) {
				print "			<input type=\"radio\" name=\"id\" value=\"$id\">\n";
			} else {
				print "			<input type=\"radio\" name=\"id\" value=\"$id\" checked>\n";
				$strt_flg = 1;
			}

			#表示文字数調整
			local($wk_file_path) = substr($file_path, $edit_file_len);

			print <<"EOM";
			</td>
			<td class="ad01">$id</td>
			<td class="ad01"><a href="$link_path" target="_blank">$file_name</a></td>
			<td class="ad01">$wk_file_path</td>
			<td class="ad01">$katelist[$kate]</td>
			<td align="right" class="ad01">$cnt</td>
		</tr>
EOM
		}
		close(IN);

		print <<"EOM";
		</table>
		<!-- リスト終了 -->

	</form>
	</td>
</tr>
<!-- データ修正・削除終了 -->

<!-- カテゴリ編集 -->
<tr>
	<td>
	<div class="ad_head">■カテゴリ編集</div>
	<form action="$script_file" method="post">
		<input type="hidden" name="pass" value="$in{'pass'}">
		<input type="hidden" name="mode" value="kate">

		<div class="small">
		No.0から順に表\示されます。
		</div>

		<br>

		<input type="submit" value="編集" class="button" onMouseOver="this.style.background='$btnbg_on'" onMouseOut="this.style.background='$btnbg_off'">

		<hr>

		<!-- リスト開始 -->
		<table align="left" border="0" cellspacing="3" cellpadding="3">
		<tr>
			<th class="head">No.</th>
			<th class="head">カテゴリ名</th>
		</tr>

EOM

		#---------------------------------------
		#カテゴリ表示
		#---------------------------------------
		for ($icnt=0; $icnt<$max_kate; $icnt++) {
			print <<"EOM";
		<tr>
			<td align="right" class="ad01">$icnt</td>
			<td class="ad01">
			<input type=\"text\" value=\"$katelist[$icnt]\" name=\"kate_name$icnt\" size=\"30\" maxlength=\"50\" class=\"text\">
			</td>
		</tr>
EOM

		}

		#---------------------------------------
		#表示終了
		#---------------------------------------
		print <<"EOM";
		</table>
		<!-- リスト終了 -->

	</form>
	</td>
</tr>
<!-- カテゴリ編集 -->

EOM

		#=======================================
		#項目説明作成
		#=======================================
		&make_explain;

		print <<"EOM";
</table>
<!-- メニュー終了 -->

<br>

EOM
	}
}

#***************************************
# 関数ID   ：exec
# 関数名   ：処理実行
#***************************************
sub exec {
	#=======================================
	#POST判定
	#=======================================
	&chk_post;

	#=======================================
	#ファイルロック
	#=======================================
	if ($lockkey) { &lock; }

	#=======================================
	#処理分岐
	#=======================================
	#データ登録
	if ($mode eq "add") {
		&data_add;
	#データ修正
	} elsif ($mode eq "edit02") {
		&data_edit;
	#データ削除
	} elsif ($mode eq "del") {
		&data_del;
	#カテゴリ編集
	} elsif ($mode eq "kate") {
		&kate_edit;
	}

	#=======================================
	#ロック解除
	#=======================================
	if ($lockkey) { &unlock; }

	#---------------------------------------
	#正常終了
	#---------------------------------------
	&info_msg
}

#***************************************
# 関数ID   ：dl_cnt
# 関数名   ：ダウンロードカウント
#***************************************
sub dl_cnt {
	#=======================================
	#ファイルロック
	#=======================================
	if ($lockkey) { &lock; }

	#=======================================
	#ファイル読込み
	#=======================================
	&read_file($log_file);

	#---------------------------------------
	#書込みデータ作成
	#---------------------------------------
	$top = shift(@lines);
	local($total) = split(/<>/, $top);

	local($sv_file_path) = "";
	@new = ();
	foreach (@lines) {
		($id, $kate_no, $cnt, $file_path, $file_name, $link_path) = split(/<>/);

		#該当データでない場合
		if ($id ne $file) {
			push(@new, $_);

		} else {
			#カウントアップ
			$cnt++;
			$total++;

			#ファイルパスを保存
			$sv_file_path = $file_path;

			push(@new, "$id<>$kate_no<>$cnt<>$file_path<>$file_name<>$link_path<>\n");
		}
	}

	#該当データが存在した場合
	if ($sv_file_path ne "") {
		#ヘッダ情報作成
		unshift(@new, "$total<>\n");

		#=======================================
		#ファイル書込み
		#=======================================
		&write_file($log_file);

		#=======================================
		#ロック解除
		#=======================================
		if ($lockkey) { &unlock; }

		#---------------------------------------
		#ダウンロード開始
		#---------------------------------------
		#Locationを使用する場合
		if ($use_loca) {
			print "Location: $sv_file_path\n\n";

		} else {
			print <<"EOM";
content-type: text/html

<html>
<head>
	<meta http-equiv="refresh" content="0; url=$sv_file_path">
</head>
</html>
EOM
		}

	#該当データが存在しない場合
	} else {

		#☆☆☆とりあえず、無視する仕様☆☆☆

		#=======================================
		#ロック解除
		#=======================================
		if ($lockkey) { &unlock; }
	}
}

#***************************************
# 関数ID   ：edit_comma
# 関数名   ：カンマ編集
# 引数     ：$in_data   <i> 編集前データ
#          ：$out_data  <o> 編集後データ
#***************************************
sub edit_comma {
	#引数を受け取る
	local($out_data) = @_;

	if ($out_data =~ /^[-+]?\d\d\d\d+/g) {
		for ($icnt=pos($out_data)-3, $jcnt=$out_data =~ /^[-+]/; $icnt>$jcnt; $icnt-=3) {
			substr($out_data, $icnt, 0) = ',';
		}
	}

	return ($out_data);
}

#***************************************
# 関数ID   ：decode
# 関数名   ：デコード処理
#***************************************
sub decode {
	local($key, $val);

	#=======================================
	#データ変換
	#=======================================
	&ReadParse;

	while (($key,$val) = each %in) {
		if ($key ne "upfile") {
			#文字コードをシフトJIS変換
			&jcode'convert(*val, "sjis", "", "z");

			#タグ処理
			$val =~ s/</&lt;/g;
			$val =~ s/>/&gt;/g;
			$val =~ s/\"/&quot;/g;
		}
		$in{$key} = $val;
	}

	#変数格納
	$mode = $in{'mode'};
	$file = $in{'file'};

	if ($in{'sort'} ne "") {
		$print_kate = $in{'sort'};
	}
}

#***************************************
# 関数ID   ：header
# 関数名   ：ヘッダ表示
#***************************************
sub header {
	$head_flg=1;
	print <<"EOM";
content-type: text/html

<?php echo "2";	?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=shift_jis">
	<meta name="robots" content="noindex, nofollow">
	<link rel="stylesheet" type="text/css" href="$css_file">

	<title>$title_name</title>
</head>

<body>

EOM
}

#***************************************
# 関数ID   ：footer
# 関数名   ：フッタ表示
#***************************************
sub footer {
	#著作権表示は削除しないでください。
	print <<"EOM";
<div align="right">
	<a href="http://www.speena.net/OnTheWind/" title="On The Wind" target="_blank">$ver</a>
</div>

</body>
</html>
EOM
}

#***************************************
# 関数ID   ：error
# 関数名   ：エラー処理
#***************************************
sub error {
	if ($lockflg) { &unlock; }
	&header if (!$head_flg);

	print "<center><h3>ERROR !</h3>\n\n";
	print "<font color=red>$_[0]</font>\n\n";
	print "</center>\n";

	&footer;

	exit;
}


__END__
