#webliberty::App::Admin.pm (2006/03/26)
#Copyright(C) 2002-2006 Knight, All rights reserved.

package webliberty::App::Admin;

use strict;
use base qw(webliberty::Basis Exporter);
use webliberty::String;
use webliberty::File;
use webliberty::Host;
use webliberty::Cookie;
use webliberty::Lock;
use webliberty::Skin;
use webliberty::Trackback;
use webliberty::Ping;
use webliberty::App::Init;
use webliberty::App::Diary;

our @EXPORT_OK = qw(check_password check_access check regist edit del);

### ã‚³ãƒ³ã‚¹ãƒˆãƒ©ã‚¯ã‚¿
sub new {
	my $class = shift;

	my $self = {
		init    => shift,
		config  => shift,
		query   => shift,
		html    => undef,
		message => undef
	};
	bless $self, $class;

	return $self;
}

### ãƒ¡ã‚¤ãƒ³å‡¦ç†
sub run {
	my $self = shift;

	if ($self->check_password) {
		if ($self->{query}->{work} eq 'new') {
			if ($self->{query}->{exec_regist}) {
				$self->check;
				$self->regist;
				$self->output_edit;
			} elsif ($self->{query}->{exec_preview}) {
				$self->check;
				$self->output_preview;
			} else {
				$self->output_form;
			}
		} elsif ($self->{query}->{work} eq 'edit') {
			if ($self->{query}->{exec_regist}) {
				$self->check;
				$self->edit;
			} elsif ($self->{query}->{exec_del}) {
				$self->del;
			}
			if ($self->{query}->{exec_preview}) {
				$self->check;
				$self->output_preview;
			} elsif ($self->{query}->{exec_form}) {
				$self->output_form;
			} elsif ($self->{query}->{exec_confirm}) {
				$self->output_confirm;
			} else {
				$self->output_edit;
			}
		} elsif ($self->{query}->{work} eq 'comment') {
			require webliberty::App::Edit;
			my $app_ins = new webliberty::App::Edit($self->{init}, $self->{config}, $self->{query});
			if ($self->{query}->{exec_regist}) {
				$app_ins->edit;
				$self->{message} = $app_ins->{message};
			} elsif ($self->{query}->{exec_del}) {
				$app_ins->del;
				$self->{message} = $app_ins->{message};
			}
			if ($self->{query}->{exec_preview}) {
				$app_ins->output_preview;
			} elsif ($self->{query}->{exec_form}) {
				$app_ins->output_form;
			} elsif ($self->{query}->{exec_confirm}) {
				$self->output_confirm;
			} else {
				$self->output_comment;
			}
		} elsif ($self->{query}->{work} eq 'trackback') {
			if ($self->{query}->{exec_del}) {
				$self->del_trackback;
			}
			if ($self->{query}->{exec_confirm}) {
				$self->output_confirm;
			} else {
				$self->output_trackback;
			}
		} elsif ($self->{query}->{work} eq 'field') {
			if ($self->{query}->{exec_add}) {
				$self->add_field;
			} elsif ($self->{query}->{exec_edit}) {
				$self->edit_field;
			}
			$self->output_field;
		} elsif ($self->{query}->{work} eq 'env') {
			if ($self->{query}->{exec_env} or $self->{query}->{exec_default}) {
				$self->env;
			}
			$self->output_env;
		} elsif ($self->{query}->{work} eq 'icon') {
			if ($self->{query}->{exec_add}) {
				$self->add_icon;
			} elsif ($self->{query}->{exec_del}) {
				$self->del_icon;
			}
			$self->output_icon;
		} elsif ($self->{query}->{work} eq 'menu') {
			if ($self->{query}->{exec_add}) {
				$self->add_menu;
			} elsif ($self->{query}->{exec_edit}) {
				$self->edit_menu;
			}
			$self->output_menu;
		} elsif ($self->{query}->{work} eq 'link') {
			if ($self->{query}->{exec_add}) {
				$self->add_link;
			} elsif ($self->{query}->{exec_edit}) {
				$self->edit_link;
			}
			$self->output_link;
		} elsif ($self->{query}->{work} eq 'profile') {
			if ($self->{query}->{exec_profile}) {
				$self->profile;
			}
			$self->output_profile;
		} elsif ($self->{query}->{work} eq 'pwd') {
			if ($self->{query}->{exec_pwd}) {
				$self->pwd;
			}
			$self->output_pwd;
		} elsif ($self->{query}->{work} eq 'paint') {
			if ($self->{query}->{exec_del}) {
				$self->del_paint;
			}
			if ($self->{query}->{exec_paint}) {
				$self->output_canvas;
			} elsif ($self->{query}->{exec_view}) {
				$self->output_view;
			} elsif ($self->{query}->{exec_confirm}) {
				$self->output_confirm;
			} else {
				$self->output_paint;
			}
		} elsif ($self->{query}->{work} eq 'build') {
			if ($self->{query}->{exec_build}) {
				$self->build;
			}
			$self->output_build;
		} elsif ($self->{query}->{work} eq 'logout') {
			$self->logout;
			$self->output_login;
		} else {
			$self->output_status;
		}
	} else {
		$self->output_login;
	}

	return;
}

### ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰èªè¨¼
sub check_password {
	my $self = shift;

	my $cookie_ins = new webliberty::Cookie($self->{config}->{cookie_admin});

	my %query;
	if ($self->{query}) {
		%query = %{$self->{query}};
	}

	my $admin_pwd;
	if (exists $query{'admin_pwd'}) {
		$admin_pwd = $self->{query}->{admin_pwd};
	} else {
		$admin_pwd = $cookie_ins->get_cookie('admin_pwd');
	}

	my $flag;

	if ($admin_pwd) {
		my %user;

		open(FH, "$self->{init}->{data_dir}$self->{init}->{data_user}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_user}");
		while (<FH>) {
			chomp;
			my($user, $pwd, $authority) = split(/\t/);

			$user{$user} = $pwd;
		}
		close(FH);

		my $pwd_ins = new webliberty::String($admin_pwd);
		if (!$pwd_ins->get_string or !$pwd_ins->check_password($user{'admin'})) {
			return $flag;
		}

		if ($self->{query}->{admin_pwd}) {
			if ($self->{query}->{hold}) {
				$cookie_ins->set_holddays(3650);
			}
			$cookie_ins->set_cookie(
				admin_pwd => $admin_pwd
			);
		}

		$flag = 1;
	}

	return $flag;
}

### ã‚¢ã‚¯ã‚»ã‚¹ãƒã‚§ãƒƒã‚¯
sub check_access {
	my $self = shift;

	my $flag;

	if ($ENV{'REQUEST_METHOD'} ne 'POST') {
		$flag = 1;
	}
	if ($ENV{'HTTP_REFERER'} and $self->{config}->{base_url} and $ENV{'HTTP_REFERER'} !~ $self->{config}->{base_url}) {
		$flag = 1;
	}
	if (!$self->{config}->{proxy_mode} and ($ENV{'HTTP_VIA'} or $ENV{'HTTP_FORWARDED'} or $ENV{'HTTP_X_FORWARDED_FOR'})) {
		$flag = 1;
	}

	my $host_ins = new webliberty::Host;
	foreach (split(/<>/, $self->{config}->{black_list})) {
		if ($host_ins->get_host =~ /$_/i) {
			$flag = 1;
			last;
		}
	}

	if ($flag) {
		$self->error('ä¸æ£ãªã‚¢ã‚¯ã‚»ã‚¹ã§ã™ã€‚');
	}

	return;
}

### å…¥åŠ›å†…å®¹ãƒã‚§ãƒƒã‚¯
sub check {
	my $self = shift;

	my $subj_ins = new webliberty::String($self->{query}->{subj});
	my $text_ins = new webliberty::String($self->{query}->{text});

	my $year_ins   = new webliberty::String($self->{query}->{year});
	my $month_ins  = new webliberty::String($self->{query}->{month});
	my $day_ins    = new webliberty::String($self->{query}->{day});
	my $hour_ins   = new webliberty::String($self->{query}->{hour});
	my $minute_ins = new webliberty::String($self->{query}->{minute});

	my $init_ins = new webliberty::App::Init;
	my %label = %{$init_ins->get_label};

	if (!$subj_ins->get_string) {
		$self->error("$label{'pc_subj'}ãŒå…¥åŠ›ã•ã‚Œã¦ã„ã¾ã›ã‚“ã€‚");
	}
	if (!$text_ins->get_string) {
		$self->error("$label{'pc_text'}ãŒå…¥åŠ›ã•ã‚Œã¦ã„ã¾ã›ã‚“ã€‚");
	}

	if (!($year_ins->get_string =~ /^\d\d\d\d$/)) {
		$self->error("$label{'pc_date'}ã®å¹´ãŒæ£ã—ãæŒ‡å®šã•ã‚Œã¦ã„ã¾ã›ã‚“ã€‚");
	}
	if (!($month_ins->get_string =~ /^\d\d$/)) {
		$self->error("$label{'pc_date'}ã®æœˆãŒæ£ã—ãæŒ‡å®šã•ã‚Œã¦ã„ã¾ã›ã‚“ã€‚");
	}
	if (!($day_ins->get_string =~ /^\d\d$/)) {
		$self->error("$label{'pc_date'}ã®æ—¥ãŒæ£ã—ãæŒ‡å®šã•ã‚Œã¦ã„ã¾ã›ã‚“ã€‚");
	}
	if (!($hour_ins->get_string =~ /^\d\d$/)) {
		$self->error("$label{'pc_date'}ã®æ™‚é–“ãŒæ£ã—ãæŒ‡å®šã•ã‚Œã¦ã„ã¾ã›ã‚“ã€‚");
	}
	if (!($minute_ins->get_string =~ /^\d\d$/)) {
		$self->error("$label{'pc_date'}ã®åˆ†ãŒæ£ã—ãæŒ‡å®šã•ã‚Œã¦ã„ã¾ã›ã‚“ã€‚");
	}

	return;
}

### æ–°è¦ç™»éŒ²
sub regist {
	my $self = shift;

	$self->check_access;

	my $stat_ins  = new webliberty::String($self->{query}->{stat});
	my $break_ins = new webliberty::String($self->{query}->{break});
	my $comt_ins  = new webliberty::String($self->{query}->{comt});
	my $tb_ins    = new webliberty::String($self->{query}->{tb});
	my $subj_ins  = new webliberty::String($self->{query}->{subj});
	my $text_ins  = new webliberty::String($self->{query}->{text});
	my $icon_ins  = new webliberty::String($self->{query}->{icon});
	my $tburl_ins = new webliberty::String($self->{query}->{tb_url});

	$stat_ins->create_number;
	$break_ins->create_number;
	$comt_ins->create_number;
	$tb_ins->create_number;
	$subj_ins->create_line;
	$text_ins->create_text;
	$icon_ins->create_line;
	$tburl_ins->create_text;

	my $log_file = "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{query}->{year}$self->{query}->{month}\.$self->{init}->{data_ext}";
	my $now      = "$self->{query}->{year}$self->{query}->{month}$self->{query}->{day}$self->{query}->{hour}$self->{query}->{minute}";
	my @logs;

	my $lock_ins = new webliberty::Lock("$self->{init}->{data_dir}$self->{init}->{data_lock}");
	if (!$lock_ins->file_lock) {
		$self->error('ãƒ•ã‚¡ã‚¤ãƒ«ãŒãƒãƒƒã‚¯ã•ã‚Œã¦ã„ã¾ã™ã€‚æ™‚é–“ã‚’ãŠã„ã¦ã‚‚ã†ä¸€åº¦æŠ•ç¨¿ã—ã¦ãã ã•ã„ã€‚');
	}

	#è¨˜äº‹è¨˜éŒ²ãƒ•ã‚¡ã‚¤ãƒ«ã‚ªãƒ¼ãƒ—ãƒ³
	if (-e $log_file) {
		open(FH, $log_file) or $self->error("Read Error : $log_file");
		@logs = <FH>;
		close(FH);
	} else {
		open(FH, ">$log_file") or $self->error("Write Error : $log_file");
		close(FH);

		if ($self->{init}->{chmod_mode}) {
			if ($self->{init}->{suexec_mode}) {
				chmod(0600, "$log_file") or $self->error("Chmod Error : $log_file");
			} else {
				chmod(0606, "$log_file") or $self->error("Chmod Error : $log_file");
			}
		}
	}

	#è¨˜éŒ²æ¸ˆã¿ãƒ‡ãƒ¼ã‚¿èªã¿è¾¼ã¿
	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}");
	my @index = <FH>;
	close(FH);

	my @numbers = map { (split(/\t/))[1] } @index;
	@index = @index[sort { $numbers[$b] <=> $numbers[$a] } (0 .. $#numbers)];

	my $new_no   = (split(/\t/, $index[0]))[1] + 1;
	my $host_ins = new webliberty::Host;

	my($new_field, $i);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_field}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_field}");
	while (<FH>) {
		chomp;

		if ($self->{query}->{field} == ++$i) {
			$new_field = $_;
		}
	}
	close(FH);

	#ã‚¢ãƒƒãƒ—ãƒãƒ¼ãƒ‰ãƒ•ã‚¡ã‚¤ãƒ«ä¿å˜
	my(%file, $files, $flag);

	foreach (1 .. 5) {
		if ($self->{query}->{'file' . $_} or $self->{query}->{'ext' . $_}) {
			$flag = 1;
		}
	}
	if ($flag) {
		foreach (1 .. 5) {
			if ($self->{query}->{'file' . $_}) {
				my $file_ins = new webliberty::File($self->{query}->{'file' . $_}->{file_name});
				$file{$_} = "$new_no\-$_\." . $file_ins->get_ext;

				open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_upfile_dir}$file{$_}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_upfile_dir}$file{$_}");
				binmode(FH);
				print FH $self->{query}->{'file' . $_}->{file_data};
				close(FH);
			} elsif ($self->{query}->{'ext' . $_}) {
				$file{$_} = "$new_no\-$_\.$self->{query}->{'ext' . $_}";
				rename("$self->{init}->{data_dir}$self->{init}->{data_upfile_dir}$self->{init}->{data_upfile_tmp}$_", "$self->{init}->{data_dir}$self->{init}->{data_upfile_dir}$file{$_}");
			}
		}

		foreach (1 .. 5) {
			if ($files) {
				$files .= '<>';
			}
			$files .= "$file{$_}";
		}
	}

	#è¨˜éŒ²ç”¨ãƒ‡ãƒ¼ã‚¿ä½œæˆ
	my $diary = "$new_no\t\t" . $stat_ins->get_string . "\t" . $break_ins->get_string . "\t" . $comt_ins->get_string . "\t" . $tb_ins->get_string . "\t$new_field\t$now\t\t" . $subj_ins->get_string . "\t" . $text_ins->get_string . "\t\t" . $icon_ins->get_string . "\t$files\t" . $host_ins->get_host;

	my($new_data, $flag);

	open(FH, $log_file) or $self->error("Read Error : $log_file");
	while (<FH>) {
		chomp;
		my($no, $id, $stat, $break, $comt, $tb, $field, $date, $name, $subj, $text, $color, $icon, $file, $host) = split(/\t/);

		if (!$flag and $now > $date) {
			$new_data .= "$diary\n";
			$flag      = 1;
		}
		$new_data .= "$_\n";
	}
	if (!$flag) {
		$new_data .= "$diary\n";
	}
	close(FH);

	#è¨˜äº‹ç™»éŒ²
	open(FH, ">$log_file") or $self->error("Write Error : $log_file");
	print FH $new_data;
	close(FH);

	#ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ç”¨ãƒ‡ãƒ¼ã‚¿ä½œæˆ
	my $index = "$now\t$new_no\t\t" . $stat_ins->get_string . "\t$new_field\t";

	my($new_index, $flag);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}");
	while (<FH>) {
		chomp;
		my($date, $no, $id, $stat, $field, $name) = split(/\t/);

		if (!$flag and $now > $date) {
			$new_index .= "$index\n";
			$flag       = 1;
		}
		$new_index .= "$_\n";
	}
	if (!$flag) {
		$new_index .= "$index\n";
	}
	close(FH);

	#ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ç™»éŒ²
	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}");
	print FH $new_index;
	close(FH);

	$lock_ins->file_unlock;

	my $alert_message;

	#ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯é€ä¿¡
	if ($tburl_ins->get_string) {
		my $article_url;
		if ($self->{config}->{html_archive_mode}) {
			if ($self->{init}->{archive_dir} =~ /([^\/\\]*\/)$/) {
				$article_url = "$self->{config}->{site_url}$1$new_no\.$self->{init}->{archive_ext}";
			}
		} else {
			if ($self->{init}->{script_file} =~ /([^\/\\]*)$/) {
				$article_url = "$self->{config}->{site_url}$1?no=$new_no";
			}
		}

		my $trackback_ins = new webliberty::Trackback;
		foreach (split(/<br \/>/, $tburl_ins->get_string)) {
			if (!$_) {
				next;
			}
			my($flag, $message) = $trackback_ins->send_trackback(
				trackback_url => $_,
				title         => $subj_ins->get_string,
				url           => $article_url,
				excerpt       => $text_ins->get_string,
				blog_name     => $self->{config}->{site_title}
			);
			if (!$flag) {
				$alert_message .= "<strong>ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯ã®é€ä¿¡ã«å¤±æ•—ã—ã¾ã—ãŸã€‚$message</strong>";
			}
		}
	}

	#æ›´æ–°PINGé€ä¿¡
	if ($self->{config}->{ping_mode}) {
		my $ping_ins = new webliberty::Ping;
		foreach (split(/<>/, $self->{config}->{ping_list})) {
			if (!$_) {
				next;
			}
			my($flag, $message) = $ping_ins->send_ping(
				ping_url  => $_,
				url       => $self->{config}->{site_url},
				blog_name => $self->{config}->{site_title}
			);
			if (!$flag) {
				$alert_message .= "<strong>æ›´æ–°PINGã®é€ä¿¡ã«å¤±æ•—ã—ã¾ã—ãŸã€‚$message</strong>";
			}
		}
	}

	#ãƒ‡ãƒ¼ã‚¿æ›´æ–°
	my $dammy;
	$dammy->{query}->{no} = $new_no;

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $dammy->{query});
	$diary_ins->update;

	$self->{message} = 'è¨˜äº‹ã‚’æ–°è¦ã«æŠ•ç¨¿ã—ã¾ã—ãŸã€‚';

	return;
}

### è¨˜äº‹ç·¨é›†
sub edit {
	my $self = shift;

	$self->check_access;

	my $edit_ins  = new webliberty::String($self->{query}->{edit});
	my $stat_ins  = new webliberty::String($self->{query}->{stat});
	my $break_ins = new webliberty::String($self->{query}->{break});
	my $comt_ins  = new webliberty::String($self->{query}->{comt});
	my $tb_ins    = new webliberty::String($self->{query}->{tb});
	my $subj_ins  = new webliberty::String($self->{query}->{subj});
	my $text_ins  = new webliberty::String($self->{query}->{text});
	my $icon_ins  = new webliberty::String($self->{query}->{icon});
	my $tburl_ins = new webliberty::String($self->{query}->{tb_url});

	$edit_ins->create_number;
	$stat_ins->create_number;
	$break_ins->create_number;
	$comt_ins->create_number;
	$tb_ins->create_number;
	$subj_ins->create_line;
	$text_ins->create_text;
	$icon_ins->create_line;
	$tburl_ins->create_text;

	if (!$edit_ins->get_string) {
		$self->error('ç·¨é›†ã—ãŸã„è¨˜äº‹ã‚’é¸æŠžã—ã¦ãã ã•ã„ã€‚');
	}

	my $lock_ins = new webliberty::Lock("$self->{init}->{data_dir}$self->{init}->{data_lock}");
	if (!$lock_ins->file_lock) {
		$self->error('ãƒ•ã‚¡ã‚¤ãƒ«ãŒãƒãƒƒã‚¯ã•ã‚Œã¦ã„ã¾ã™ã€‚æ™‚é–“ã‚’ãŠã„ã¦ã‚‚ã†ä¸€åº¦æŠ•ç¨¿ã—ã¦ãã ã•ã„ã€‚');
	}

	#è¨˜éŒ²ç”¨ãƒ‡ãƒ¼ã‚¿ä½œæˆ
	my($new_field, $i);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_field}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_field}");
	while (<FH>) {
		chomp;

		if ($self->{query}->{field} == ++$i) {
			$new_field = $_;
		}
	}
	close(FH);

	my $new_date = "$self->{query}->{year}$self->{query}->{month}$self->{query}->{day}$self->{query}->{hour}$self->{query}->{minute}";

	#ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ç”¨ãƒ‡ãƒ¼ã‚¿ä½œæˆ
	my(@new_index, $edit_date);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}");
	while (<FH>) {
		chomp;
		my($date, $no, $id, $stat, $field, $name) = split(/\t/);

		if ($edit_ins->get_string == $no) {
			$edit_date  = $date;
			push(@new_index, "$new_date\t$no\t\t" . $stat_ins->get_string . "\t$new_field\t\n");
		} else {
			push(@new_index, "$_\n");
		}
	}
	close(FH);

	#ç·¨é›†ãƒ‡ãƒ¼ã‚¿æ¤œç´¢
	my $edit_file;
	if ($edit_date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
		$edit_file = "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$1$2\.$self->{init}->{data_ext}";
	}

	my($new_data, $org_files, $flag);

	open(FH, $edit_file) or $self->error("Read Error : $edit_file");
	while (<FH>) {
		chomp;
		my($no, $id, $stat, $break, $comt, $tb, $field, $date, $name, $subj, $text, $color, $icon, $file, $host) = split(/\t/);

		if ($edit_ins->get_string == $no) {
			$org_files = $file;
			$flag      = 1;
		} else {
			$new_data .= "$_\n";
		}
	}
	close(FH);

	if (!$flag) {
		$self->error('æŒ‡å®šã•ã‚ŒãŸè¨˜äº‹ã¯å˜åœ¨ã—ã¾ã›ã‚“ã€‚');
	}

	#ã‚¢ãƒƒãƒ—ãƒãƒ¼ãƒ‰ãƒ•ã‚¡ã‚¤ãƒ«ä¿å˜
	my(%file, $files);
	$flag = '';

	foreach (1 .. 5) {
		if ($self->{query}->{'file' . $_} or $self->{query}->{'ext' . $_} or $self->{query}->{'delfile' . $_}) {
			$flag = 1;
		}
	}
	if ($flag) {
		my @org_files = split(/<>/, $org_files);

		foreach (1 .. 5) {
			my $file;

			if ($self->{query}->{'delfile' . $_}) {
				if (-e "$self->{init}->{data_dir}$self->{init}->{data_thumbnail_dir}" . $org_files[$_ - 1]) {
					unlink("$self->{init}->{data_dir}$self->{init}->{data_thumbnail_dir}" . $org_files[$_ - 1]);
				}
				unlink("$self->{init}->{data_dir}$self->{init}->{data_upfile_dir}" . $org_files[$_ - 1]);
			} elsif ($self->{query}->{'file' . $_}) {
				if (-e "$self->{init}->{data_dir}$self->{init}->{data_thumbnail_dir}" . $org_files[$_ - 1]) {
					unlink("$self->{init}->{data_dir}$self->{init}->{data_thumbnail_dir}" . $org_files[$_ - 1]);
				}

				my $file_ins = new webliberty::File($self->{query}->{'file' . $_}->{file_name});
				$file{$_} = "$self->{query}->{edit}\-$_\." . $file_ins->get_ext;

				open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_upfile_dir}$file{$_}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_upfile_dir}$file{$_}");
				binmode(FH);
				print FH $self->{query}->{'file' . $_}->{file_data};
				close(FH);
			} elsif ($self->{query}->{'ext' . $_}) {
				$file{$_} = "$self->{query}->{edit}\-$_\.$self->{query}->{'ext' . $_}";
				rename("$self->{init}->{data_dir}$self->{init}->{data_upfile_dir}$self->{init}->{data_upfile_tmp}$_", "$self->{init}->{data_dir}$self->{init}->{data_upfile_dir}$file{$_}");
			} elsif ($org_files[$_ - 1]) {
				$file{$_} = $org_files[$_ - 1];
			}
		}

		foreach (1 .. 5) {
			if ($files) {
				$files .= '<>';
			}
			$files .= "$file{$_}";
		}
	} else {
		$files = $org_files;
	}

	#ç·¨é›†ãƒ‡ãƒ¼ã‚¿ç™»éŒ²
	open(FH, ">$edit_file") or $self->error("Write Error : $edit_file");
	print FH $new_data;
	close(FH);

	#è¨˜éŒ²ç”¨ãƒ‡ãƒ¼ã‚¿ä½œæˆ
	my $host_ins = new webliberty::Host;

	my $diary  = $edit_ins->get_string . "\t\t" . $stat_ins->get_string . "\t" . $break_ins->get_string . "\t" . $comt_ins->get_string . "\t" . $tb_ins->get_string . "\t$new_field\t$new_date\t\t" . $subj_ins->get_string . "\t" . $text_ins->get_string . "\t\t" . $icon_ins->get_string . "\t$files\t" . $host_ins->get_host;
	$edit_file = "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{query}->{year}$self->{query}->{month}\.$self->{init}->{data_ext}";

	if (!-e $edit_file) {
		open(FH, ">$edit_file") or $self->error("Write Error : $edit_file");
		close(FH);

		if ($self->{init}->{chmod_mode}) {
			if ($self->{init}->{suexec_mode}) {
				chmod(0600, "$edit_file") or $self->error("Chmod Error : $edit_file");
			} else {
				chmod(0606, "$edit_file") or $self->error("Chmod Error : $edit_file");
			}
		}
	}

	my $record_data;
	$flag = '';

	open(FH, $edit_file) or $self->error("Read Error : $edit_file");
	while (<FH>) {
		chomp;
		my($no, $id, $stat, $break, $comt, $tb, $field, $date, $name, $subj, $text, $color, $icon, $file, $host) = split(/\t/);

		if (!$flag and (($new_date == $date and $edit_ins->get_string < $no) or $new_date > $date)) {
			$record_data .= "$diary\n";
			$flag         = 1;
		}
		$record_data .= "$_\n";
	}
	if (!$flag) {
		$record_data .= "$diary\n";
	}

	#è¨˜äº‹ç™»éŒ²
	open(FH, ">$edit_file") or $self->error("Write Error : $edit_file");
	print FH $record_data;
	close(FH);

	#ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ç™»éŒ²
	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}");
	print FH sort { $b <=> $a } @new_index;
	close(FH);

	$lock_ins->file_unlock;

	my $alert_message;

	#ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯é€ä¿¡
	if ($tburl_ins->get_string) {
		my $article_url;
		if ($self->{config}->{html_archive_mode}) {
			if ($self->{init}->{archive_dir} =~ /([^\/\\]*\/)$/) {
				$article_url = "$self->{config}->{site_url}$1" . $edit_ins->get_string . "\.$self->{init}->{archive_ext}";
			}
		} else {
			if ($self->{init}->{script_file} =~ /([^\/\\]*)$/) {
				$article_url = "$self->{config}->{site_url}$1?no=" . $edit_ins->get_string;
			}
		}

		my $trackback_ins = new webliberty::Trackback;
		foreach (split(/<br \/>/, $tburl_ins->get_string)) {
			if (!$_) {
				next;
			}
			my($flag, $message) = $trackback_ins->send_trackback(
				trackback_url => $_,
				title         => $subj_ins->get_string,
				url           => $article_url,
				excerpt       => $text_ins->get_string,
				blog_name     => $self->{config}->{site_title}
			);
			if (!$flag) {
				$alert_message .= "<strong>ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯ã®é€ä¿¡ã«å¤±æ•—ã—ã¾ã—ãŸã€‚$message</strong>";
			}
		}
	}

	#æ›´æ–°PINGé€ä¿¡
	if ($self->{config}->{ping_mode}) {
		my $ping_ins = new webliberty::Ping;
		foreach (split(/<>/, $self->{config}->{ping_list})) {
			if (!$_) {
				next;
			}
			my($flag, $message) = $ping_ins->send_ping(
				ping_url  => $_,
				url       => $self->{config}->{site_url},
				blog_name => $self->{config}->{site_title}
			);
			if (!$flag) {
				$alert_message .= "<strong>æ›´æ–°PINGã®é€ä¿¡ã«å¤±æ•—ã—ã¾ã—ãŸã€‚$message</strong>";
			}
		}
	}

	#ãƒ‡ãƒ¼ã‚¿æ›´æ–°
	my $dammy;
	$dammy->{query}->{no} = $edit_ins->get_string;

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $dammy->{query});
	$diary_ins->update;

	$self->{message} = "No." . $edit_ins->get_string . "ã®è¨˜äº‹ã‚’ç·¨é›†ã—ã¾ã—ãŸã€‚$alert_message";

	return;
}

### è¨˜äº‹å‰Šé™¤
sub del {
	my $self = shift;

	$self->check_access;

	if (!$self->{query}->{del}) {
		$self->error('å‰Šé™¤ã—ãŸã„è¨˜äº‹ã‚’é¸æŠžã—ã¦ãã ã•ã„ã€‚');
	}

	my $lock_ins = new webliberty::Lock("$self->{init}->{data_dir}$self->{init}->{data_lock}");
	if (!$lock_ins->file_lock) {
		$self->error('ãƒ•ã‚¡ã‚¤ãƒ«ãŒãƒãƒƒã‚¯ã•ã‚Œã¦ã„ã¾ã™ã€‚æ™‚é–“ã‚’ãŠã„ã¦ã‚‚ã†ä¸€åº¦æŠ•ç¨¿ã—ã¦ãã ã•ã„ã€‚');
	}

	#å‰Šé™¤ãƒ‡ãƒ¼ã‚¿æ¤œç´¢
	my($new_index, %del_file);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}");
	while (<FH>) {
		chomp;
		my($date, $no, $id, $stat, $field, $name) = split(/\t/);

		if ($self->{query}->{del} =~ /(^|\n)$no(\n|$)/) {
			if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
				$del_file{"$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$1$2\.$self->{init}->{data_ext}"} = 1;
			}
		} else {
			$new_index .= "$_\n";
		}
	}
	close(FH);

	#è¨˜äº‹å‰Šé™¤
	my $flag;

	foreach my $entry (keys %del_file) {
		my $new_data;

		open(FH, $entry) or $self->error("Read Error : $entry");
		while (<FH>) {
			chomp;
			my($no, $id, $stat, $break, $comt, $tb, $field, $date, $name, $subj, $text, $color, $icon, $file, $host) = split(/\t/);

			if ($self->{query}->{del} =~ /(^|\n)$no(\n|$)/) {
				if ($file) {
					foreach my $del_file (split(/<>/, $file)) {
						if ($del_file) {
							if (-e "$self->{init}->{data_dir}$self->{init}->{data_thumbnail_dir}$del_file") {
								unlink("$self->{init}->{data_dir}$self->{init}->{data_thumbnail_dir}$del_file");
							}
							unlink("$self->{init}->{data_dir}$self->{init}->{data_upfile_dir}$del_file");
						}
					}
				}

				$flag = 1;
			} else {
				$new_data .= "$_\n";
			}
		}
		close(FH);

		open(FH, ">$entry") or $self->error("Write Error : $entry");
		print FH $new_data;
		close(FH);
	}

	if (!$flag) {
		$self->error('æŒ‡å®šã•ã‚ŒãŸè¨˜äº‹ã¯å˜åœ¨ã—ã¾ã›ã‚“ã€‚');
	}

	#ã‚³ãƒ¡ãƒ³ãƒˆå‰Šé™¤
	if (-e "$self->{init}->{data_dir}$self->{init}->{data_comt_dir}$self->{query}->{del}\.$self->{init}->{data_ext}") {
		my $index_data;

		open(FH, "$self->{init}->{data_dir}$self->{init}->{data_comt_dir}$self->{init}->{data_comt_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_comt_dir}$self->{init}->{data_comt_index}");
		while (<FH>) {
			chomp;
			my($no, $pno, $stat, $date, $name, $subj, $host) = split(/\t/);

			if ($self->{query}->{del} != $pno) {
				$index_data .= "$_\n";
			}
		}
		close(FH);

		open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_comt_dir}$self->{init}->{data_comt_index}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_comt_dir}$self->{init}->{data_comt_index}");
		print FH $index_data;
		close(FH);

		unlink("$self->{init}->{data_dir}$self->{init}->{data_comt_dir}$self->{query}->{del}\.$self->{init}->{data_ext}");
	}
	#ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯å‰Šé™¤
	if (-e "$self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{query}->{del}\.$self->{init}->{data_ext}") {
		my $index_data;

		open(FH, "$self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{init}->{data_tb_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{init}->{data_tb_index}");
		while (<FH>) {
			chomp;
			my($no, $pno, $stat, $date, $blog, $title, $url) = split(/\t/);

			if ($self->{query}->{del} != $pno) {
				$index_data .= "$_\n";
			}
		}
		close(FH);

		open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{init}->{data_tb_index}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{init}->{data_tb_index}");
		print FH $index_data;
		close(FH);

		unlink("$self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{query}->{del}\.$self->{init}->{data_ext}");
	}

	#ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ç™»éŒ²
	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}");
	print FH $new_index;
	close(FH);

	$lock_ins->file_unlock;

	#ãƒ‡ãƒ¼ã‚¿æ›´æ–°
	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config});
	$diary_ins->update;

	my $del_list;
	foreach (split(/\n/, $self->{query}->{del})) {
		$del_list .= "No.$_ ";
	}

	if ($self->{config}->{html_archive_mode}) {
		unlink("$self->{init}->{archive_dir}$self->{query}->{del}\.$self->{init}->{archive_ext}");
	}

	$self->{message} = "$del_listã®è¨˜äº‹ã‚’å‰Šé™¤ã—ã¾ã—ãŸã€‚";

	return;
}

### ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯å‰Šé™¤
sub del_trackback {
	my $self = shift;

	$self->check_access;

	if (!$self->{query}->{del}) {
		$self->error('å‰Šé™¤ã—ãŸã„ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯ã‚’é¸æŠžã—ã¦ãã ã•ã„ã€‚');
	}

	my $lock_ins = new webliberty::Lock("$self->{init}->{data_dir}$self->{init}->{data_lock}");
	if (!$lock_ins->file_lock) {
		$self->error('ãƒ•ã‚¡ã‚¤ãƒ«ãŒãƒãƒƒã‚¯ã•ã‚Œã¦ã„ã¾ã™ã€‚æ™‚é–“ã‚’ãŠã„ã¦ã‚‚ã†ä¸€åº¦æŠ•ç¨¿ã—ã¦ãã ã•ã„ã€‚');
	}

	my($new_index, $diary_no, %del_file);

	#å‰Šé™¤ãƒ‡ãƒ¼ã‚¿æ¤œç´¢
	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{init}->{data_tb_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{init}->{data_tb_index}");
	while (<FH>) {
		chomp;
		my($no, $pno, $stat, $date, $blog, $title, $url) = split(/\t/);

		if ($self->{query}->{del} =~ /(^|\n)$no(\n|$)/) {
			$del_file{"$self->{init}->{data_dir}$self->{init}->{data_tb_dir}$pno\.$self->{init}->{data_ext}"} = 1;
		} else {
			$new_index .= "$_\n";
		}
	}
	close(FH);

	#ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯å‰Šé™¤
	my $flag;

	foreach my $entry (keys %del_file) {
		my $new_data;

		open(FH, $entry) or $self->error("Read Error : $entry");
		while (<FH>) {
			chomp;
			my($no, $pno, $stat, $date, $blog, $title, $url, $excerpt) = split(/\t/);

			if ($self->{query}->{del} =~ /(^|\n)$no(\n|$)/) {
				$diary_no = $pno;
				$flag = 1;
			} else {
				$new_data .= "$_\n";
			}
		}
		close(FH);

		open(FH, ">$entry") or $self->error("Write Error : $entry");
		print FH $new_data;
		close(FH);
	}

	if (!$flag) {
		$self->error('æŒ‡å®šã•ã‚ŒãŸè¨˜äº‹ã¯å˜åœ¨ã—ã¾ã›ã‚“ã€‚');
	}

	#ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ç™»éŒ²
	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{init}->{data_tb_index}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{init}->{data_tb_index}");
	print FH $new_index;
	close(FH);

	$lock_ins->file_unlock;

	#ãƒ‡ãƒ¼ã‚¿æ›´æ–°
	my $dammy;
	$dammy->{query}->{no} = $diary_no;

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $dammy->{query});
	$diary_ins->update;

	my $del_list;
	foreach (split(/\n/, $self->{query}->{del})) {
		$del_list .= "No.$_ ";
	}

	$self->{message} = "$del_listã®ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯ã‚’å‰Šé™¤ã—ã¾ã—ãŸã€‚";

	return;
}

### åˆ†é¡žè¿½åŠ
sub add_field {
	my $self = shift;

	$self->check_access;

	my $field_ins  = new webliberty::String($self->{query}->{field});
	my $parent_ins = new webliberty::String($self->{query}->{parent});

	$field_ins->create_line;
	$parent_ins->create_line;

	if ($parent_ins->get_string) {
		my($new_data, $flag);

		open(FH, "$self->{init}->{data_dir}$self->{init}->{data_field}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_field}");
		while (<FH>) {
			chomp;
			my($field, $child) = split(/<>/);

			if ($parent_ins->get_string eq $field) {
				$flag = 1;
			} elsif ($flag and $parent_ins->get_string ne $field) {
				$new_data .= $parent_ins->get_string . '<>' . $field_ins->get_string . "\n";
				$flag = 0;
			}

			$new_data .= "$_\n";
		}
		if ($flag) {
			$new_data .= $parent_ins->get_string . '<>' . $field_ins->get_string . "\n";
		}
		close(FH);

		open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_field}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_field}");
		print FH $new_data;
		close(FH);
	} else {
		open(FH, ">>$self->{init}->{data_dir}$self->{init}->{data_field}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_field}");
		print FH "$self->{query}->{parent}$self->{query}->{field}\n";
		close(FH);
	}

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config});
	$diary_ins->update;

	$self->{message} = 'åˆ†é¡žã‚’è¿½åŠ ã—ã¾ã—ãŸã€‚';

	return;
}

### åˆ†é¡žç·¨é›†
sub edit_field {
	my $self = shift;

	$self->check_access;

	my(@fields, $new_data, $parent);
	my $i = 0;

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_field}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_field}");
	while (<FH>) {
		push(@fields, $_);
	}
	seek(FH, 0, 0);
	while (<FH>) {
		chomp;
		my($field, $child) = split(/<>/);

		if ($self->{query}->{from} ne '' and $self->{query}->{to} ne '') {
			if ($self->{query}->{to} == $i) {
				$new_data .= $fields[$self->{query}->{from}];
			}
			if ($self->{query}->{from} != $i) {
				$new_data .= "$_\n";
			}
		} elsif (!$self->{query}->{'del' . $i}) {
			my $field_ins  = new webliberty::String($self->{query}->{'field' . $i});
			my $parent_ins = new webliberty::String($self->{query}->{'parent' . $i});

			$field_ins->create_line;
			$parent_ins->create_line;

			if ($parent and $child) {
				$new_data .= $parent_ins->get_string . "<>" . $field_ins->get_string . "\n";
			} else {
				$parent    = $field_ins->get_string;
				$new_data .= "$parent\n";
			}
		}

		$i++;
	}
	close(FH);

	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_field}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_field}");
	print FH $new_data;
	close(FH);

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config});
	$diary_ins->update;

	$self->{message} = 'åˆ†é¡žã‚’ç·¨é›†ã—ã¾ã—ãŸã€‚';

	return;
}

### ç’°å¢ƒè¨å®š
sub env {
	my $self = shift;

	$self->check_access;

	my $new_data;
	if ($self->{query}->{exec_default}) {
		my $init_ins = new webliberty::App::Init;
		my %default = %{$init_ins->get_config};

		foreach (keys %default) {
			$new_data .= "$_=$default{$_}\n";
		}
	} else {
		foreach (keys %{$self->{query}}) {
			if ($_ =~ /^env_/) {
				my $key   = $_;
				my $value = $self->{query}->{$_};

				$key   =~ s/^env_//;
				$value =~ s/\r?\n/\r/g;
				$value =~ s/\r/<>/g;

				$new_data .= "$key=$value\n";
			}
		}
	}

	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_config}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_config}");
	print FH $new_data;
	close(FH);

	my $config_ins = new webliberty::Configure("$self->{init}->{data_dir}$self->{init}->{data_config}");
	$self->{config} = $config_ins->get_config;

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config});
	$diary_ins->update;

	$self->{message} = 'ç’°å¢ƒè¨å®šã‚’å®Ÿè¡Œã—ã¾ã—ãŸã€‚';
	if ($self->{config}->{html_index_mode} or $self->{config}->{html_archive_mode}) {
		$self->{message} .= '<em>å¤–è¦³ã«é–¢ã™ã‚‹è¨å®šã‚’å¤‰æ›´ã—ãŸå ´åˆã€ã‚µã‚¤ãƒˆã®å†æ§‹ç¯‰ã‚’è¡Œã£ã¦ãã ã•ã„ã€‚</em>';
	}

	return;
}

### ã‚¢ã‚¤ã‚³ãƒ³è¿½åŠ
sub add_icon {
	my $self = shift;

	$self->check_access;

	my $init_ins = new webliberty::App::Init;
	my %label = %{$init_ins->get_label};

	my $file_ins = new webliberty::File($self->{query}->{file}->{file_name});
	my $name_ins = new webliberty::String($self->{query}->{name});

	$name_ins->create_line;

	my $file = $file_ins->get_name . '.' . $file_ins->get_ext;

	open(FILE, ">$self->{init}->{data_dir}$self->{init}->{data_icon_dir}$file") or $self->error("ã‚¢ãƒƒãƒ—ãƒãƒ¼ãƒ‰ãƒ•ã‚¡ã‚¤ãƒ«ãŒä¿å˜ã§ãã¾ã›ã‚“ã€‚");
	binmode(FILE);
	print FILE $self->{query}->{file}->{file_data};
	close(FILE);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_icon}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_icon}");
	my @icon = <FH>;
	close(FH);

	push(@icon, "$file\t" . $name_ins->get_string . "\t\t\t\n");

	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_icon}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_icon}");
	print FH $self->_sort_icon(@icon);
	close(FH);

	$self->{message} = "$label{'pc_icon'}ã‚’æ–°è¦ã«ç™»éŒ²ã—ã¾ã—ãŸã€‚";

	return;
}

### ã‚¢ã‚¤ã‚³ãƒ³å‰Šé™¤
sub del_icon {
	my $self = shift;

	$self->check_access;

	my $init_ins = new webliberty::App::Init;
	my %label = %{$init_ins->get_label};

	if (!$self->{query}->{edit}) {
		$self->error("å‰Šé™¤ã—ãŸã„$label{'pc_icon'}ã‚’é¸æŠžã—ã¦ãã ã•ã„ã€‚");
	}

	my $new_data;

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_icon}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_icon}");
	while (<FH>) {
		chomp;
		my($file, $name, $field, $user, $pwd) = split(/\t/);

		if ($self->{query}->{edit} eq $file) {
			unlink("$self->{init}->{data_dir}$self->{init}->{data_icon_dir}$file") or $self->error('ã‚¢ã‚¤ã‚³ãƒ³ç”»åƒãŒå‰Šé™¤ã§ãã¾ã›ã‚“ã€‚');
		} else {
			$new_data .= "$_\n";
		}
	}
	close(FH);

	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_icon}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_icon}");
	print FH $new_data;
	close(FH);

	$self->{message} = "$label{'pc_icon'}$self->{query}->{edit}ã‚’å‰Šé™¤ã—ã¾ã—ãŸã€‚";

	return;
}

### ã‚³ãƒ³ãƒ†ãƒ³ãƒ„è¿½åŠ
sub add_menu {
	my $self = shift;

	$self->check_access;

	my $field_ins = new webliberty::String($self->{query}->{field});
	my $name_ins  = new webliberty::String($self->{query}->{name});
	my $url_ins   = new webliberty::String($self->{query}->{url});

	$field_ins->create_line;
	$name_ins->create_line;
	$url_ins->create_line;

	my($new_data, $flag);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_menu}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_menu}");
	my @menus = <FH>;
	close(FH);

	push(@menus, $field_ins->get_string . "\t" . $name_ins->get_string . "\t" . $url_ins->get_string . "\n");

	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_menu}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_menu}");
	print FH sort { $a cmp $b } @menus;
	close(FH);

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config});
	$diary_ins->update;

	$self->{message} = 'ã‚³ãƒ³ãƒ†ãƒ³ãƒ„ã‚’è¿½åŠ ã—ã¾ã—ãŸã€‚';

	return;
}

### ã‚³ãƒ³ãƒ†ãƒ³ãƒ„ç·¨é›†
sub edit_menu {
	my $self = shift;

	$self->check_access;

	my(@menus, $new_data, $field);
	my $i = 0;

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_menu}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_menu}");
	while (<FH>) {
		push(@menus, $_);
	}
	seek(FH, 0, 0);
	while (<FH>) {
		chomp;
		my($field, $name, $url) = split(/\t/);

		if ($self->{query}->{from} ne '' and $self->{query}->{to} ne '') {
			if ($self->{query}->{to} == $i) {
				$new_data .= $menus[$self->{query}->{from}];
			}
			if ($self->{query}->{from} != $i) {
				$new_data .= "$_\n";
			}
		} elsif (!$self->{query}->{'del' . $i}) {
			my $field_ins = new webliberty::String($self->{query}->{'field' . $i});
			my $name_ins  = new webliberty::String($self->{query}->{'name' . $i});
			my $url_ins   = new webliberty::String($self->{query}->{'url' . $i});

			$name_ins->create_line;
			$field_ins->create_line;
			$url_ins->create_line;

			$new_data .= $field_ins->get_string . "\t" . $name_ins->get_string . "\t" . $url_ins->get_string . "\n";
		}

		$i++;
	}
	close(FH);

	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_menu}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_menu}");
	print FH $new_data;
	close(FH);

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config});
	$diary_ins->update;

	$self->{message} = 'ã‚³ãƒ³ãƒ†ãƒ³ãƒ„ã‚’ç·¨é›†ã—ã¾ã—ãŸã€‚';

	return;
}

### ãƒªãƒ³ã‚¯è¿½åŠ
sub add_link {
	my $self = shift;

	$self->check_access;

	my $field_ins = new webliberty::String($self->{query}->{field});
	my $name_ins  = new webliberty::String($self->{query}->{name});
	my $url_ins   = new webliberty::String($self->{query}->{url});

	$field_ins->create_line;
	$name_ins->create_line;
	$url_ins->create_line;

	my($new_data, $flag);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_link}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_link}");
	my @links = <FH>;
	close(FH);

	push(@links, $field_ins->get_string . "\t" . $name_ins->get_string . "\t" . $url_ins->get_string . "\n");

	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_link}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_link}");
	print FH sort { $a cmp $b } @links;
	close(FH);

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config});
	$diary_ins->update;

	$self->{message} = 'ã‚µã‚¤ãƒˆã‚’è¿½åŠ ã—ã¾ã—ãŸã€‚';

	return;
}

### ãƒªãƒ³ã‚¯ç·¨é›†
sub edit_link {
	my $self = shift;

	$self->check_access;

	my(@links, $new_data, $field);
	my $i = 0;

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_link}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_link}");
	while (<FH>) {
		push(@links, $_);
	}
	seek(FH, 0, 0);
	while (<FH>) {
		chomp;
		my($field, $name, $url) = split(/\t/);

		if ($self->{query}->{from} ne '' and $self->{query}->{to} ne '') {
			if ($self->{query}->{to} == $i) {
				$new_data .= $links[$self->{query}->{from}];
			}
			if ($self->{query}->{from} != $i) {
				$new_data .= "$_\n";
			}
		} elsif (!$self->{query}->{'del' . $i}) {
			my $field_ins = new webliberty::String($self->{query}->{'field' . $i});
			my $name_ins  = new webliberty::String($self->{query}->{'name' . $i});
			my $url_ins   = new webliberty::String($self->{query}->{'url' . $i});

			$name_ins->create_line;
			$field_ins->create_line;
			$url_ins->create_line;

			$new_data .= $field_ins->get_string . "\t" . $name_ins->get_string . "\t" . $url_ins->get_string . "\n";
		}

		$i++;
	}
	close(FH);

	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_link}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_link}");
	print FH $new_data;
	close(FH);

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config});
	$diary_ins->update;

	$self->{message} = 'ãƒªãƒ³ã‚¯é›†ã‚’ç·¨é›†ã—ã¾ã—ãŸã€‚';

	return;
}

### ãƒ—ãƒãƒ•ã‚£ãƒ¼ãƒ«è¨å®š
sub profile {
	my $self = shift;

	$self->check_access;

	my $name_ins = new webliberty::String($self->{query}->{name});
	my $text_ins = new webliberty::String($self->{query}->{text});

	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_profile}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_profile}");
	print FH "admin\t" . $name_ins->create_line . "\t" . $text_ins->create_text . "\n";
	close(FH);

	$self->{message} = 'ãƒ—ãƒãƒ•ã‚£ãƒ¼ãƒ«ã‚’è¨å®šã—ã¾ã—ãŸã€‚';

	return;
}

### ç®¡ç†è€…ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰è¨å®š
sub pwd {
	my $self = shift;

	$self->check_access;

	my $admin_pwd_ins = new webliberty::String($self->{query}->{admin_pwd});
	my $new_pwd_ins   = new webliberty::String($self->{query}->{new_pwd});
	my $cfm_pwd_ins   = new webliberty::String($self->{query}->{cfm_pwd});
	my $pwd_ins       = new webliberty::String($self->{query}->{new_pwd});

	if (!$admin_pwd_ins->get_string) {
		$self->error('ä»¥å‰ã®ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ã‚’å…¥åŠ›ã—ã¦ãã ã•ã„ã€‚');
	}
	if (!$new_pwd_ins->get_string) {
		$self->error('æ–°ã—ãè¨å®šã—ãŸã„ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ã‚’å…¥åŠ›ã—ã¦ãã ã•ã„ã€‚');
	}
	if (!$cfm_pwd_ins->get_string) {
		$self->error('ç¢ºèªç”¨ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ã‚’å…¥åŠ›ã—ã¦ãã ã•ã„ã€‚');
	}
	if ($new_pwd_ins->get_string ne $cfm_pwd_ins->get_string) {
		$self->error('æ–°ã—ã„ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ã¨ç¢ºèªç”¨ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ã¯ã€åŒã˜ã‚‚ã®ã‚’å…¥åŠ›ã—ã¦ãã ã•ã„ã€‚');
	}
	if ($new_pwd_ins->check_length < 4) {
		$self->error('ç®¡ç†è€…ç”¨ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ã¯4æ–‡å—ä»¥ä¸Šã‚’æŒ‡å®šã—ã¦ãã ã•ã„ã€‚');
	}

	open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_user}") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_user}");
	print FH "admin\t" . $new_pwd_ins->create_password . "\troot\n";
	close(FH);

	my $cookie_ins = new webliberty::Cookie($self->{config}->{cookie_admin});
	$cookie_ins->set_cookie(
		admin_pwd => $cfm_pwd_ins->get_string
	);

	$self->{message} = 'ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ã‚’è¨å®šã—ã¾ã—ãŸã€‚';

	return;
}

### ã‚¤ãƒ©ã‚¹ãƒˆå‰Šé™¤
sub del_paint {
	my $self = shift;

	$self->check_access;

	opendir(DIR, "$self->{init}->{data_dir}$self->{init}->{paint_dir}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{paint_dir}");
	my @files = sort { $a <=> $b } grep { m/\w+\.\w+/g } readdir(DIR);
	close(DIR);

	my $flag;
	foreach (@files) {
		my $file_ins = new webliberty::File("$self->{init}->{data_dir}$self->{init}->{paint_dir}$_");

		if ($self->{query}->{del} eq $file_ins->get_name) {
			unlink("$self->{init}->{data_dir}$self->{init}->{paint_dir}" . $file_ins->get_name . '.' . $file_ins->get_ext);
			$flag = 1;
		}
	}
	if (!$flag) {
		$self->error('æŒ‡å®šã•ã‚ŒãŸã‚¤ãƒ©ã‚¹ãƒˆã¯å˜åœ¨ã—ã¾ã›ã‚“ã€‚');
	}

	opendir(DIR, "$self->{init}->{data_dir}$self->{init}->{pch_dir}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{pch_dir}");
	@files = sort { $a <=> $b } grep { m/\w+\.\w+/g } readdir(DIR);
	close(DIR);

	$flag = 0;
	foreach (@files) {
		my $file_ins = new webliberty::File("$self->{init}->{data_dir}$self->{init}->{pch_dir}$_");

		if ($self->{query}->{del} eq $file_ins->get_name) {
			unlink("$self->{init}->{data_dir}$self->{init}->{pch_dir}" . $file_ins->get_name . '.' . $file_ins->get_ext);
			$flag = 1;
		}
	}
	if (!$flag) {
		$self->error('æŒ‡å®šã•ã‚ŒãŸPCHãƒ•ã‚¡ã‚¤ãƒ«ã¯å˜åœ¨ã—ã¾ã›ã‚“ã€‚');
	}

	$self->{message} = "No.$self->{query}->{del}ã®ã‚¤ãƒ©ã‚¹ãƒˆã‚’å‰Šé™¤ã—ã¾ã—ãŸã€‚";

	return;
}

### ã‚µã‚¤ãƒˆå†æ§‹ç¯‰
sub build {
	my $self = shift;

	$self->check_access;

	require webliberty::App::List;
	my $stdout = *STDOUT;

	#ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’æ§‹ç¯‰
	if ($self->{query}->{build} eq 'index' or $self->{query}->{build} eq 'all') {
		open(HTML, ">$self->{init}->{html_file}") or $self->error("Write Error : $self->{init}->{html_file}");
		*STDOUT = *HTML;
		my $app_ins = new webliberty::App::List($self->{init}, $self->{config});
		$app_ins->run;
		close(HTML);
	}
	#ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–ã‚’æ§‹ç¯‰
	if ($self->{config}->{html_archive_mode} and ($self->{query}->{build} =~ /^\d+$/ or $self->{query}->{build} eq 'all')) {
		my($from, $to);
		if ($self->{query}->{build} =~ /^(\d+)$/) {
			$from = $1;
			$to   = $from + 50 - 1;
		}

		open(FH, "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}");
		while (<FH>) {
			chomp;
			my($date, $no, $id, $stat, $field, $name) = split(/\t/);

			if ($self->{query}->{build} ne 'all' and ($no < $from or $no > $to)) {
				next;
			}

			my $dammy;
			$dammy->{query}->{no} = $no;

			open(HTML, ">$self->{init}->{archive_dir}$dammy->{query}->{no}\.$self->{init}->{archive_ext}") or $self->error("Write Error : $self->{init}->{archive_dir}$dammy->{query}->{no}\.$self->{init}->{archive_ext}");
			*STDOUT = *HTML;
			my $app_ins = new webliberty::App::List($self->{init}, $self->{config}, $dammy->{query});
			$app_ins->run;
			close(HTML);

			if ($self->{init}->{chmod_mode}) {
				if ($self->{init}->{suexec_mode}) {
					chmod(0604, "$self->{init}->{archive_dir}$dammy->{query}->{no}\.$self->{init}->{archive_ext}") or $self->error("Chmod Error : $self->{init}->{archive_dir}$dammy->{query}->{no}\.$self->{init}->{archive_ext}");
				} else {
					chmod(0606, "$self->{init}->{archive_dir}$dammy->{query}->{no}\.$self->{init}->{archive_ext}") or $self->error("Chmod Error : $self->{init}->{archive_dir}$dammy->{query}->{no}\.$self->{init}->{archive_ext}");
				}
			}
		}
	}

	*STDOUT = $stdout;

	$self->{message} = 'ã‚µã‚¤ãƒˆã‚’å†æ§‹ç¯‰ã—ã¾ã—ãŸã€‚';

	return;
}

### ãƒã‚°ã‚¢ã‚¦ãƒˆ
sub logout {
	my $self = shift;

	my $cookie_ins = new webliberty::Cookie($self->{config}->{cookie_admin});
	$cookie_ins->set_cookie(
		admin_pwd => ''
	);

	return;
}

### æŠ•ç¨¿ãƒ•ã‚©ãƒ¼ãƒ è¡¨ç¤º
sub output_form {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'è¨˜äº‹ã‚’å…¥åŠ›ã—ã€<em>æŠ•ç¨¿ãƒœã‚¿ãƒ³</em>ã‚’æŠ¼ã—ã¦ãã ã•ã„ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_form}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	my(%form, $form_label);

	if ($self->{query}->{work} eq 'edit') {
		if (!$self->{query}->{edit}) {
			$self->error('ç·¨é›†ã—ãŸã„è¨˜äº‹ã‚’é¸æŠžã—ã¦ãã ã•ã„ã€‚');
		}

		my $edit_date;
		open(FH, "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}");
		while (<FH>) {
			chomp;
			my($date, $no, $id, $stat, $field, $name) = split(/\t/);

			if ($self->{query}->{edit} == $no) {
				$edit_date = $date;

				last;
			}
		}
		close(FH);

		my $edit_file;
		if ($edit_date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
			$edit_file = "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$1$2\.$self->{init}->{data_ext}";
		}

		open(FH, "$edit_file") or $self->error("Read Error : $edit_file");
		while (<FH>) {
			chomp;
			my($no, $id, $stat, $break, $comt, $tb, $field, $date, $name, $subj, $text, $color, $icon, $file, $host) = split(/\t/);

			if ($self->{query}->{edit} == $no) {
				%form = $diary_ins->diary_form($no, $id, $stat, $break, $comt, $tb, $field, $date, $name, $subj, $text, $color, $icon, $file, $host);
			}
		}
		close(FH);

		$form_label = 'è¨˜äº‹ç·¨é›†';
	} else {
		my($sec, $min, $hour, $day, $mon, $year) = localtime(time);
		my $date = sprintf("%04d%02d%02d%02d%02d", $year + 1900, $mon + 1, $day, $hour, $min);

		%form = $diary_ins->diary_form('', '', $self->{config}->{default_stat}, $self->{config}->{default_break}, $self->{config}->{default_comt}, $self->{config}->{default_tb}, '', $date, '', '', '', '', '', '', '');

		$form_label = 'æ–°è¦æŠ•ç¨¿';
	}

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');
	print $skin_ins->get_replace_data(
		'form',
		%form,
		FORM_LABEL => $form_label,
		FORM_WORK  => $self->{query}->{work},
		FORM_EXT1  => '',
		FORM_EXT2  => '',
		FORM_EXT3  => '',
		FORM_EXT4  => '',
		FORM_EXT5  => '',
		FORM_TBURL => $self->{query}->{tb_url}
	);
	print $skin_ins->get_data('footer');

	return;
}

### ãƒ—ãƒ¬ãƒ“ãƒ¥ãƒ¼è¡¨ç¤º
sub output_preview {
	my $self = shift;

	my $date = "$self->{query}->{year}$self->{query}->{month}$self->{query}->{day}$self->{query}->{hour}$self->{query}->{minute}";

	my($new_field, $i);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_field}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_field}");
	while (<FH>) {
		chomp;

		if ($self->{query}->{field} == ++$i) {
			$new_field = $_;
		}
	}
	close(FH);

	my(%file, %ext, $files, $flag);

	foreach (1 .. 5) {
		if ($self->{query}->{work} eq 'edit' or $self->{query}->{'file' . $_} or $self->{query}->{'ext' . $_}) {
			$flag = 1;
		}
	}

	if ($flag) {
		my $org_files;

		if ($self->{query}->{work} eq 'edit') {
			my $edit_file;
			if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
				$edit_file = "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$1$2\.$self->{init}->{data_ext}";
			}

			open(FH, $edit_file) or $self->error("Read Error : $edit_file");
			while (<FH>) {
				chomp;
				my($no, $id, $stat, $break, $comt, $tb, $field, $date, $name, $subj, $text, $color, $icon, $file, $host) = split(/\t/);

				if ($self->{query}->{edit} == $no) {
					$org_files = $file;
					last;
				}
			}
			close(FH);
		}

		foreach (1 .. 5) {
			my @org_files = split(/<>/, $org_files);

			if ($self->{query}->{'file' . $_}) {
				my $file_ins = new webliberty::File($self->{query}->{'file' . $_}->{file_name});
				$file{$_} = $self->{init}->{data_upfile_tmp};
				$ext{$_}  = $file_ins->get_ext;

				open(FH, ">$self->{init}->{data_dir}$self->{init}->{data_upfile_dir}$self->{init}->{data_upfile_tmp}$_") or $self->error("Write Error : $self->{init}->{data_dir}$self->{init}->{data_upfile_dir}$self->{init}->{data_upfile_tmp}$_");
				binmode(FH);
				print FH $self->{query}->{'file' . $_}->{file_data};
				close(FH);
			} elsif ($self->{query}->{'ext' . $_}) {
				$file{$_} = $self->{init}->{data_upfile_tmp};
				$ext{$_}  = $self->{query}->{'ext' . $_};
			} elsif ($org_files[$_ - 1]) {
				$file{$_} = $org_files[$_ - 1];
			}
		}

		foreach (1 .. 5) {
			if ($files) {
				$files .= '<>';
			}
			$files .= "$file{$_}";
		}
	}

	if (!$self->{message}) {
		$self->{message} = 'ã“ã®å†…å®¹ã§æŠ•ç¨¿ã—ã¾ã™ã€‚ã‚ˆã‚ã—ã‘ã‚Œã°<em>æŠ•ç¨¿ãƒœã‚¿ãƒ³</em>ã‚’æŠ¼ã—ã¦ãã ã•ã„ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_form}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_diary}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	my $subj_ins = new webliberty::String($self->{query}->{subj});
	my $text_ins = new webliberty::String($self->{query}->{text});

	$subj_ins->create_line;
	$text_ins->create_text;

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');
	print $skin_ins->get_replace_data(
		'form',
		$diary_ins->diary_form($self->{query}->{edit}, '', $self->{query}->{stat}, $self->{query}->{break}, $self->{query}->{comt}, $self->{query}->{tb}, $self->{query}->{field}, $date, '', $subj_ins->get_string, $text_ins->get_string, '', $self->{query}->{icon}, $files, ''),
		FORM_LABEL => 'ãƒ—ãƒ¬ãƒ“ãƒ¥ãƒ¼',
		FORM_WORK  => $self->{query}->{work},
		FORM_EXT1  => $ext{'1'},
		FORM_EXT2  => $ext{'2'},
		FORM_EXT3  => $ext{'3'},
		FORM_EXT4  => $ext{'4'},
		FORM_EXT5  => $ext{'5'},
		FORM_TBURL => $self->{query}->{tb_url}
	);
	print $skin_ins->get_data('diary_head');
	print $skin_ins->get_replace_data(
		'diary',
		$diary_ins->diary_article(0, '', $self->{query}->{stat}, $self->{query}->{break}, $self->{query}->{comt}, $self->{query}->{tb}, $new_field, $date, '', $subj_ins->get_string, $text_ins->get_string, '', $self->{query}->{icon}, '', '')
	);
	print $skin_ins->get_data('diary_foot');
	print $skin_ins->get_data('footer');

	return;
}

### æŠ•ç¨¿è¨˜äº‹ä¸€è¦§è¡¨ç¤º
sub output_edit {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'è¨˜äº‹ã‚’é¸æŠžã—ã€<em>ç·¨é›†ãƒœã‚¿ãƒ³</em>ã‹<em>å‰Šé™¤ãƒœã‚¿ãƒ³</em>ã‚’æŠ¼ã—ã¦ãã ã•ã„ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_edit}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	$self->{html}->{header}    = $skin_ins->get_data('header');
	$self->{html}->{work_head} = $skin_ins->get_data('work_head');
	$self->{html}->{work}      = $self->work_navi($skin_ins);
	$self->{html}->{work_foot} = $skin_ins->get_data('work_foot');
	$self->{html}->{contents}  = $skin_ins->get_data('contents');

	my($index_size, $index_date, $index_no);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}");
	while (<FH>) {
		chomp;
		my($date, $no, $id, $stat, $field, $name) = split(/\t/);

		if ($index_size == $self->{query}->{page} * $self->{config}->{page_size}) {
			$index_date = $date;
			$index_no   = $no;
		}

		$index_size++;
	}
	close(FH);

	my $start_file;
	if ($index_date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
		$start_file = "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$1$2\.$self->{init}->{data_ext}";
	}

	opendir(DIR, "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}");
	my @dir = sort { $b <=> $a } readdir(DIR);
	closedir(DIR);

	my($dir_flag, $file_flag, $i);

	$self->{html}->{diary_head} = $skin_ins->get_data('diary_head');
	foreach my $entry (@dir) {
		if ($entry !~ /^\d\d\d\d\d\d\.$self->{init}->{data_ext}$/) {
			next;
		}
		if ($start_file eq "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$entry") {
			$dir_flag = 1;
		}
		if ($dir_flag) {
			open(FH, "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$entry") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$entry");
			while (<FH>) {
				chomp;
				my($no, $id, $stat, $break, $comt, $tb, $field, $date, $name, $subj, $text, $color, $icon, $file, $host) = split(/\t/);

				if ($no == $index_no) {
					$file_flag = 1;
				}
				if ($file_flag) {
					$i++;
					if ($i > $self->{config}->{page_size}) {
						$file_flag = 0;
						last;
					}

					$self->{html}->{diary} .= $skin_ins->get_replace_data(
						'diary',
						$diary_ins->diary_article($no, $id, $stat, $break, $comt, $tb, $field, $date, $name, $subj, $text, $color, $icon, $file, $host)
					);
				}
			}
			close(FH);
		}
	}
	$self->{html}->{diary_foot} = $skin_ins->get_data('diary_foot');

	my $page_list;
	foreach (0 .. int(($index_size - 1) / $self->{config}->{page_size})) {
		if ($_ == $self->{query}->{page}) {
			$page_list .= "<option value=\"$_\" lang=\"ja\" selected=\"selected\">ãƒšãƒ¼ã‚¸" . ($_ + 1) . "</option>";
		} else {
			$page_list .= "<option value=\"$_\" lang=\"ja\">ãƒšãƒ¼ã‚¸" . ($_ + 1) . "</option>";
		}
	}
	$self->{html}->{page} = $skin_ins->get_replace_data(
		'page',
		PAGE_LIST => $page_list
	);

	$self->{html}->{footer} = $skin_ins->get_data('footer');

	print $self->header;
	foreach ($skin_ins->get_list) {
		print $self->{html}->{$_};
	}

	return;
}

### ã‚³ãƒ¡ãƒ³ãƒˆä¸€è¦§è¡¨ç¤º
sub output_comment {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'ã‚³ãƒ¡ãƒ³ãƒˆã‚’é¸æŠžã—ã€<em>ç·¨é›†ãƒœã‚¿ãƒ³</em>ã‹<em>å‰Šé™¤ãƒœã‚¿ãƒ³</em>ã‚’æŠ¼ã—ã¦ãã ã•ã„ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_comment}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	$self->{html}->{header}    = $skin_ins->get_data('header');
	$self->{html}->{work_head} = $skin_ins->get_data('work_head');
	$self->{html}->{work}      = $self->work_navi($skin_ins);
	$self->{html}->{work_foot} = $skin_ins->get_data('work_foot');
	$self->{html}->{contents}  = $skin_ins->get_data('contents');

	$self->{html}->{diary_head} = $skin_ins->get_data('diary_head');

	my($index_size, $i);

	my $comt_start = $self->{config}->{page_size} * $self->{query}->{page};
	my $comt_end   = $comt_start + $self->{config}->{page_size};

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_comt_dir}$self->{init}->{data_comt_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_comt_dir}$self->{init}->{data_comt_index}");
	while (<FH>) {
		$index_size++;
	}
	seek(FH, 0, 0);
	while (<FH>) {
		chomp;
		my($no, $pno, $stat, $date, $name, $subj, $host) = split(/\t/);

		$i++;
		if ($i <= $comt_start) {
			next;
		} elsif ($i > $comt_end) {
			last;
		}

		$self->{html}->{comment} .= $skin_ins->get_replace_data(
			'comment',
			$diary_ins->comment_article($no, $pno, $stat, $date, $name, '', '', $subj, '', '', '', '', '', '', $host)
		);
	}
	close(FH);

	$self->{html}->{diary_foot} = $skin_ins->get_data('diary_foot');

	my $page_list;
	foreach (0 .. int(($index_size - 1) / $self->{config}->{page_size})) {
		if ($_ == $self->{query}->{page}) {
			$page_list .= "<option value=\"$_\" lang=\"ja\" selected=\"selected\">ãƒšãƒ¼ã‚¸" . ($_ + 1) . "</option>";
		} else {
			$page_list .= "<option value=\"$_\" lang=\"ja\">ãƒšãƒ¼ã‚¸" . ($_ + 1) . "</option>";
		}
	}
	$self->{html}->{page} = $skin_ins->get_replace_data(
		'page',
		PAGE_LIST => $page_list
	);

	$self->{html}->{footer} = $skin_ins->get_data('footer');

	print $self->header;
	foreach ($skin_ins->get_list) {
		print $self->{html}->{$_};
	}

	return;
}

### ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯ä¸€è¦§è¡¨ç¤º
sub output_trackback {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯ã‚’é¸æŠžã—ã€<em>å‰Šé™¤ãƒœã‚¿ãƒ³</em>ã‚’æŠ¼ã—ã¦ãã ã•ã„ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_trackback}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	$self->{html}->{header}    = $skin_ins->get_data('header');
	$self->{html}->{work_head} = $skin_ins->get_data('work_head');
	$self->{html}->{work}      = $self->work_navi($skin_ins);
	$self->{html}->{work_foot} = $skin_ins->get_data('work_foot');
	$self->{html}->{contents}  = $skin_ins->get_data('contents');

	$self->{html}->{trackback_head} = $skin_ins->get_data('trackback_head');

	my($index_size, $i);

	my $tb_start = $self->{config}->{page_size} * $self->{query}->{page};
	my $tb_end   = $tb_start + $self->{config}->{page_size};

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{init}->{data_tb_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{init}->{data_tb_index}");
	while (<FH>) {
		$index_size++;
	}
	seek(FH, 0, 0);
	while (<FH>) {
		chomp;
		my($no, $pno, $stat, $date, $blog, $title, $url) = split(/\t/);

		$i++;
		if ($i <= $tb_start) {
			next;
		} elsif ($i > $tb_end) {
			last;
		}

		$self->{html}->{trackback} .= $skin_ins->get_replace_data(
			'trackback',
			$diary_ins->trackback_article($no, $pno, $stat, $date, $blog, $title, $url, '')
		);
	}
	close(FH);

	$self->{html}->{trackback_foot} = $skin_ins->get_data('trackback_foot');

	my $page_list;
	foreach (0 .. int(($index_size - 1) / $self->{config}->{page_size})) {
		if ($_ == $self->{query}->{page}) {
			$page_list .= "<option value=\"$_\" lang=\"ja\" selected=\"selected\">ãƒšãƒ¼ã‚¸" . ($_ + 1) . "</option>";
		} else {
			$page_list .= "<option value=\"$_\" lang=\"ja\">ãƒšãƒ¼ã‚¸" . ($_ + 1) . "</option>";
		}
	}
	$self->{html}->{page} = $skin_ins->get_replace_data(
		'page',
		PAGE_LIST => $page_list
	);

	$self->{html}->{footer} = $skin_ins->get_data('footer');

	print $self->header;
	foreach ($skin_ins->get_list) {
		print $self->{html}->{$_};
	}

	return;
}

### å‰Šé™¤ç¢ºèªè¡¨ç¤º
sub output_confirm {
	my $self = shift;

	my($info_heading, $info_delete);
	if ($self->{query}->{work} eq 'comment') {
		$info_heading = 'ã‚³ãƒ¡ãƒ³ãƒˆå‰Šé™¤';
		$info_delete  = 'ã‚³ãƒ¡ãƒ³ãƒˆ';
	} elsif ($self->{query}->{work} eq 'trackback') {
		$info_heading = 'ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯å‰Šé™¤';
		$info_delete  = 'ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯';
	} elsif ($self->{query}->{work} eq 'paint') {
		$info_heading = 'ã‚¤ãƒ©ã‚¹ãƒˆå‰Šé™¤';
		$info_delete  = 'ã‚¤ãƒ©ã‚¹ãƒˆ';
		$self->{query}->{del} = $self->{query}->{pch};
	} elsif ($self->{query}->{work} eq 'edit') {
		$info_heading = 'è¨˜äº‹å‰Šé™¤';
		$info_delete  = 'è¨˜äº‹';
	}

	if (!$self->{query}->{del}) {
		$self->error("å‰Šé™¤ã—ãŸã„$info_deleteã‚’é¸æŠžã—ã¦ãã ã•ã„ã€‚");
	}

	if (!$self->{message}) {
		my $del_list;
		foreach (split(/\n/, $self->{query}->{del})) {
			$del_list .= "No.$_ ";
		}

		$self->{message} = "$del_listã®$info_deleteã‚’å‰Šé™¤ã—ã¾ã™ã€‚ã‚ˆã‚ã—ã‘ã‚Œã°ã€<em>å‰Šé™¤ãƒœã‚¿ãƒ³</em>ã‚’æŠ¼ã—ã¦ãã ã•ã„ã€‚";
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_confirm}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	my $del_list;
	foreach (split(/\n/, $self->{query}->{del})) {
		$del_list .= "<input type=\"hidden\" name=\"del\" value=\"$_\" />";
	}

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	$self->{html}->{header}    = $skin_ins->get_data('header');
	$self->{html}->{work_head} = $skin_ins->get_data('work_head');
	$self->{html}->{work}      = $self->work_navi($skin_ins);
	$self->{html}->{work_foot} = $skin_ins->get_data('work_foot');

	$self->{html}->{contents} = $skin_ins->get_replace_data(
		'contents',
		INFO_HEADING => $info_heading,
		INFO_WORK    => $self->{query}->{work},
		INFO_LIST    => $del_list
	);

	$self->{html}->{footer} = $skin_ins->get_data('footer');

	print $self->header;
	foreach ($skin_ins->get_list) {
		print $self->{html}->{$_};
	}

	return;
}

### åˆ†é¡žè¨å®šç”»é¢
sub output_field {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'æŠ•ç¨¿æ™‚ã®è¨˜äº‹åˆ†é¡žã‚’è¨å®šã™ã‚‹äº‹ãŒã§ãã¾ã™ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_field}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');

	my @parents;

	my $form_parent;
	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_field}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_field}");
	while (<FH>) {
		chomp;
		my($field, $child) = split(/<>/);

		if (!$child) {
			$form_parent .= "<option value=\"$field\" lang=\"ja\">$field</option>";

			push(@parents, $field);
		}
	}
	close(FH);

	print $skin_ins->get_replace_data(
		'contents',
		FORM_PARENT => $form_parent
	);
	print $skin_ins->get_data('field_head');

	my $i = 0;

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_field}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_field}");
	while (<FH>) {
		chomp;
		my($field, $child) = split(/<>/);

		if ($child) {
			my $field_list;
			foreach (@parents) {
				if ($field eq $_) {
					$field_list .= "<option value=\"$_\" lang=\"ja\" selected=\"selected\">$_</option>";
				} else {
					$field_list .= "<option value=\"$_\" lang=\"ja\">$_</option>";
				}
			}
			$field_list = "<select name=\"parent$i\"><option value=\"\" lang=\"ja\">ãªã—</option>$field_list</select>";

			print $skin_ins->get_replace_data(
				'child',
				FIELD_NAME   => $child,
				FIELD_PARENT => $field_list,
				FIELD_NO     => $i
			);
		} else {
			print $skin_ins->get_replace_data(
				'parent',
				FIELD_NAME => $field,
				FIELD_NO   => $i
			);
		}

		$i++;
	}
	close(FH);

	print $skin_ins->get_data('field_foot');
	print $skin_ins->get_data('footer');

	return;
}

### ç’°å¢ƒè¨å®šç”»é¢è¡¨ç¤º
sub output_env {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'è¨å®šã‚’å¤‰æ›´ã—ã€<em>è¨å®šãƒœã‚¿ãƒ³</em>ã‚’æŠ¼ã—ã¦ãã ã•ã„ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_env}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	my $use_field;
	if ($self->{config}->{use_field} eq '1') {
		$use_field = '<option value="1" lang="ja" selected="selected">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja">è¡¨ç¤ºã—ãªã„</option>';
	} else {
		$use_field = '<option value="1" lang="ja">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja" selected="selected">è¡¨ç¤ºã—ãªã„</option>';
	}

	my $use_icon;
	if ($self->{config}->{use_icon} eq '1') {
		$use_icon = '<option value="1" lang="ja" selected="selected">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja">è¡¨ç¤ºã—ãªã„</option>';
	} else {
		$use_icon = '<option value="1" lang="ja">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja" selected="selected">è¡¨ç¤ºã—ãªã„</option>';
	}

	my $use_file;
	if ($self->{config}->{use_file} eq '1') {
		$use_file = '<option value="1" lang="ja" selected="selected">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja">è¡¨ç¤ºã—ãªã„</option>';
	} else {
		$use_file = '<option value="1" lang="ja">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja" selected="selected">è¡¨ç¤ºã—ãªã„</option>';
	}

	my $use_tburl;
	if ($self->{config}->{use_tburl} eq '1') {
		$use_tburl = '<option value="1" lang="ja" selected="selected">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja">è¡¨ç¤ºã—ãªã„</option>';
	} else {
		$use_tburl = '<option value="1" lang="ja">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja" selected="selected">è¡¨ç¤ºã—ãªã„</option>';
	}

	my $default_stat;
	if ($self->{config}->{default_stat} eq '1') {
		$default_stat = '<option value="1" lang="ja" selected="selected">å…¬é–‹ã™ã‚‹</option><option value="0" lang="ja">å…¬é–‹ã—ãªã„</option>';
	} else {
		$default_stat = '<option value="1" lang="ja">å…¬é–‹ã™ã‚‹</option><option value="0" lang="ja" selected="selected">å…¬é–‹ã—ãªã„</option>';
	}

	my $default_break;
	if ($self->{config}->{default_break} eq '1') {
		$default_break = '<option value="1" lang="ja" selected="selected">å¤‰æ›ã™ã‚‹</option><option value="0" lang="ja">å¤‰æ›ã—ãªã„</option>';
	} else {
		$default_break = '<option value="1" lang="ja">å¤‰æ›ã™ã‚‹</option><option value="0" lang="ja" selected="selected">å¤‰æ›ã—ãªã„</option>';
	}

	my $default_comt;
	if ($self->{config}->{default_comt} eq '1') {
		$default_comt = '<option value="1" lang="ja" selected="selected">å—ã‘ä»˜ã‘ã‚‹</option><option value="0" lang="ja">å—ã‘ä»˜ã‘ãªã„</option>';
	} else {
		$default_comt = '<option value="1" lang="ja">å—ã‘ä»˜ã‘ã‚‹</option><option value="0" lang="ja" selected="selected">å—ã‘ä»˜ã‘ãªã„</option>';
	}

	my $default_tb;
	if ($self->{config}->{default_tb} eq '1') {
		$default_tb = '<option value="1" lang="ja" selected="selected">å—ã‘ä»˜ã‘ã‚‹</option><option value="0" lang="ja">å—ã‘ä»˜ã‘ãªã„</option>';
	} else {
		$default_tb = '<option value="1" lang="ja">å—ã‘ä»˜ã‘ã‚‹</option><option value="0" lang="ja" selected="selected">å—ã‘ä»˜ã‘ãªã„</option>';
	}

	my $autolink_mode;
	if ($self->{config}->{autolink_mode} eq '1') {
		$autolink_mode = '<option value="1" lang="ja" selected="selected">ãƒªãƒ³ã‚¯ã™ã‚‹</option><option value="0" lang="ja">ãƒªãƒ³ã‚¯ã—ãªã„</option>';
	} else {
		$autolink_mode = '<option value="1" lang="ja">ãƒªãƒ³ã‚¯ã™ã‚‹</option><option value="0" lang="ja" selected="selected">ãƒªãƒ³ã‚¯ã—ãªã„</option>';
	}

	my $thumbnail_mode;
	if ($self->{config}->{thumbnail_mode} eq '1') {
		$thumbnail_mode = '<option value="1" lang="ja" selected="selected">ä½œæˆã™ã‚‹</option><option value="0" lang="ja">ä½œæˆã—ãªã„</option>';
	} else {
		$thumbnail_mode = '<option value="1" lang="ja">ä½œæˆã™ã‚‹</option><option value="0" lang="ja" selected="selected">ä½œæˆã—ãªã„</option>';
	}

	my $show_calendar;
	if ($self->{config}->{show_calendar} eq '1') {
		$show_calendar = '<option value="1" lang="ja" selected="selected">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja">è¡¨ç¤ºã—ãªã„</option>';
	} else {
		$show_calendar = '<option value="1" lang="ja">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja" selected="selected">è¡¨ç¤ºã—ãªã„</option>';
	}

	my $show_field;
	if ($self->{config}->{show_field} eq '1') {
		$show_field = '<option value="1" lang="ja" selected="selected">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja">è¡¨ç¤ºã—ãªã„</option>';
	} else {
		$show_field = '<option value="1" lang="ja">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja" selected="selected">è¡¨ç¤ºã—ãªã„</option>';
	}

	my $show_search;
	if ($self->{config}->{show_search} eq '1') {
		$show_search = '<option value="1" lang="ja" selected="selected">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja">è¡¨ç¤ºã—ãªã„</option>';
	} else {
		$show_search = '<option value="1" lang="ja">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja" selected="selected">è¡¨ç¤ºã—ãªã„</option>';
	}

	my $show_past;
	if ($self->{config}->{show_past} eq '1') {
		$show_past = '<option value="1" lang="ja" selected="selected">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja">è¡¨ç¤ºã—ãªã„</option>';
	} else {
		$show_past = '<option value="1" lang="ja">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja" selected="selected">è¡¨ç¤ºã—ãªã„</option>';
	}

	my $show_menu;
	if ($self->{config}->{show_menu} eq '1') {
		$show_menu = '<option value="1" lang="ja" selected="selected">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja">è¡¨ç¤ºã—ãªã„</option>';
	} else {
		$show_menu = '<option value="1" lang="ja">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja" selected="selected">è¡¨ç¤ºã—ãªã„</option>';
	}

	my $show_link;
	if ($self->{config}->{show_link} eq '1') {
		$show_link = '<option value="1" lang="ja" selected="selected">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja">è¡¨ç¤ºã—ãªã„</option>';
	} else {
		$show_link = '<option value="1" lang="ja">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja" selected="selected">è¡¨ç¤ºã—ãªã„</option>';
	}

	my $show_profile;
	if ($self->{config}->{show_profile} eq '1') {
		$show_profile = '<option value="1" lang="ja" selected="selected">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja">è¡¨ç¤ºã—ãªã„</option>';
	} else {
		$show_profile = '<option value="1" lang="ja">è¡¨ç¤ºã™ã‚‹</option><option value="0" lang="ja" selected="selected">è¡¨ç¤ºã—ãªã„</option>';
	}

	my $sendmail_cmt_mode;
	if ($self->{config}->{sendmail_cmt_mode} eq '1') {
		$sendmail_cmt_mode = '<option value="1" lang="ja" selected="selected">é€šçŸ¥ã™ã‚‹</option><option value="0" lang="ja">é€šçŸ¥ã—ãªã„</option>';
	} else {
		$sendmail_cmt_mode = '<option value="1" lang="ja">é€šçŸ¥ã™ã‚‹</option><option value="0" lang="ja" selected="selected">é€šçŸ¥ã—ãªã„</option>';
	}

	my $sendmail_tb_mode;
	if ($self->{config}->{sendmail_tb_mode} eq '1') {
		$sendmail_tb_mode = '<option value="1" lang="ja" selected="selected">é€šçŸ¥ã™ã‚‹</option><option value="0" lang="ja">é€šçŸ¥ã—ãªã„</option>';
	} else {
		$sendmail_tb_mode = '<option value="1" lang="ja">é€šçŸ¥ã™ã‚‹</option><option value="0" lang="ja" selected="selected">é€šçŸ¥ã—ãªã„</option>';
	}

	my $ping_mode;
	if ($self->{config}->{ping_mode} eq '1') {
		$ping_mode = '<option value="1" lang="ja" selected="selected">é€šçŸ¥ã™ã‚‹</option><option value="0" lang="ja">é€šçŸ¥ã—ãªã„</option>';
	} else {
		$ping_mode = '<option value="1" lang="ja">é€šçŸ¥ã™ã‚‹</option><option value="0" lang="ja" selected="selected">é€šçŸ¥ã—ãªã„</option>';
	}

	my $html_index_mode;
	if ($self->{config}->{html_index_mode} eq '1') {
		$html_index_mode = '<option value="1" lang="ja" selected="selected">ON</option><option value="0" lang="ja">OFF</option>';
	} else {
		$html_index_mode = '<option value="1" lang="ja">ON</option><option value="0" lang="ja" selected="selected">OFF</option>';
	}

	my $html_archive_mode;
	if ($self->{config}->{html_archive_mode} eq '1') {
		$html_archive_mode = '<option value="1" lang="ja" selected="selected">ON</option><option value="0" lang="ja">OFF</option>';
	} else {
		$html_archive_mode = '<option value="1" lang="ja">ON</option><option value="0" lang="ja" selected="selected">OFF</option>';
	}

	my $js_title_mode;
	if ($self->{config}->{js_title_mode} eq '1') {
		$js_title_mode = '<option value="1" lang="ja" selected="selected">ON</option><option value="0" lang="ja">OFF</option>';
	} else {
		$js_title_mode = '<option value="1" lang="ja">ON</option><option value="0" lang="ja" selected="selected">OFF</option>';
	}

	my $js_text_mode;
	if ($self->{config}->{js_text_mode} eq '1') {
		$js_text_mode = '<option value="1" lang="ja" selected="selected">ON</option><option value="0" lang="ja">OFF</option>';
	} else {
		$js_text_mode = '<option value="1" lang="ja">ON</option><option value="0" lang="ja" selected="selected">OFF</option>';
	}

	my $proxy_mode;
	if ($self->{config}->{proxy_mode} eq '1') {
		$proxy_mode = '<option value="1" lang="ja" selected="selected">è¨±å¯</option><option value="0" lang="ja">ç¦æ¢</option>';
	} else {
		$proxy_mode = '<option value="1" lang="ja">è¨±å¯</option><option value="0" lang="ja" selected="selected">ç¦æ¢</option>';
	}

	my $ng_word = $self->{config}->{ng_word};
	$ng_word =~ s/<>/\n/g;

	my $menu_list = $self->{config}->{menu_list};
	$menu_list =~ s/<>/\n/g;

	my $link_list = $self->{config}->{link_list};
	$link_list =~ s/<>/\n/g;

	my $sendmail_list = $self->{config}->{sendmail_list};
	$sendmail_list =~ s/<>/\n/g;

	my $sendmail_admin = $self->{config}->{sendmail_admin};
	$sendmail_admin =~ s/<>/\n/g;

	my $ping_list = $self->{config}->{ping_list};
	$ping_list =~ s/<>/\n/g;

	my $black_list = $self->{config}->{black_list};
	$black_list =~ s/<>/\n/g;

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');
	print $skin_ins->get_data('contents_head');

	my @envlist = (
		'env_basic',       'åŸºæœ¬è¨å®š',
		'env_log',         'ãƒã‚°ã®è¡¨ç¤ºè¨å®š',
		'env_form',        'æŠ•ç¨¿ç”»é¢ã®è¡¨ç¤ºè¨å®š',
		'env_default',     'æŠ•ç¨¿è¨˜äº‹ã®åˆæœŸè¨å®š',
		'env_show',        'æŠ•ç¨¿è¨˜äº‹ã®è¡¨ç¤ºè¨å®š',
		'env_upload',      'ãƒ•ã‚¡ã‚¤ãƒ«ã‚¢ãƒƒãƒ—ãƒãƒ¼ãƒ‰ã®è¨å®š',
		'env_restriction', 'ã‚³ãƒ¡ãƒ³ãƒˆæŠ•ç¨¿åˆ¶é™ã®è¨å®š',
		'env_layout',      'ãƒ¬ã‚¤ã‚¢ã‚¦ãƒˆã®è¨å®š',
		'env_menu',        'ã‚³ãƒ³ãƒ†ãƒ³ãƒ„ã®è¨å®š',
		'env_link',        'ãƒªãƒ³ã‚¯é›†ã®è¨å®š',
		'env_sendmail',    'ãƒ¡ãƒ¼ãƒ«é€šçŸ¥ã®è¨å®š',
		'env_ping',        'æ›´æ–°PINGã®è¨å®š',
		'env_cookie',      'Cookieã®è¨å®š',
		'env_html',        'HTMLãƒ•ã‚¡ã‚¤ãƒ«æ›¸ãå‡ºã—ã®è¨å®š',
		'env_js',          'JSãƒ•ã‚¡ã‚¤ãƒ«æ›¸ãå‡ºã—ã®è¨å®š',
		'env_access',      'ã‚¢ã‚¯ã‚»ã‚¹åˆ¶é™ã®è¨å®š'
	);

	print $skin_ins->get_data('envlist_head');
	my $i = 0;
	foreach (0 .. ($#envlist / 2)) {
		print $skin_ins->get_replace_data(
			'envlist',
			ENV_ID    => $envlist[$i++],
			ENV_TITLE => $envlist[$i++]
		);
	}
	print $skin_ins->get_data('envlist_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'åŸºæœ¬è¨å®š',
		ENV_ID    => 'env_basic'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ—¥è¨˜å¸³ã‚¿ã‚¤ãƒˆãƒ«ï¼ˆ<em>å¿…ãšè¨å®šã—ã¦ãã ã•ã„</em>ï¼‰',
		ENV_VALUE => "<input type=\"text\" name=\"env_site_title\" size=\"30\" value=\"$self->{config}->{site_title}\" />"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ—¥è¨˜å¸³ã‹ã‚‰ã®æˆ»ã‚Šå…ˆ',
		ENV_VALUE => "<input type=\"text\" name=\"env_back_url\" size=\"50\" value=\"$self->{config}->{back_url}\" style=\"ime-mode:disabled;\" />"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ—¥è¨˜å¸³ã‚¿ã‚¤ãƒˆãƒ«ï¼ˆæºå¸¯ãƒ¢ãƒ¼ãƒ‰æ™‚ï¼‰',
		ENV_VALUE => "<input type=\"text\" name=\"env_mobile_site_title\" size=\"30\" value=\"$self->{config}->{mobile_site_title}\" />"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ—¥è¨˜å¸³ã‹ã‚‰ã®æˆ»ã‚Šå…ˆï¼ˆæºå¸¯ãƒ¢ãƒ¼ãƒ‰æ™‚ï¼‰',
		ENV_VALUE => "<input type=\"text\" name=\"env_mobile_back_url\" size=\"50\" value=\"$self->{config}->{mobile_back_url}\" style=\"ime-mode:disabled;\" />"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ã‚µã‚¤ãƒˆã®æ¦‚è¦',
		ENV_VALUE => "<input type=\"text\" name=\"env_site_description\" size=\"50\" value=\"$self->{config}->{site_description}\" />"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ã‚µã‚¤ãƒˆã®URLï¼ˆ<em>å¿…ãšè¨å®šã—ã¦ãã ã•ã„</em>ï¼‰',
		ENV_VALUE => "<input type=\"text\" name=\"env_site_url\" size=\"50\" value=\"$self->{config}->{site_url}\" />"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'ãƒã‚°ã®è¡¨ç¤ºè¨å®š',
		ENV_ID    => 'env_log'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => '1ãƒšãƒ¼ã‚¸ã®è¨˜äº‹è¡¨ç¤ºä»¶æ•°',
		ENV_VALUE => "<input type=\"text\" name=\"env_page_size\" size=\"5\" value=\"$self->{config}->{page_size}\" style=\"ime-mode:disabled;\" />ä»¶"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ–°ç€è¨˜äº‹ã®è¡¨ç¤ºä»¶æ•°ï¼ˆ0ã«ã™ã‚‹ã¨éžè¡¨ç¤ºï¼‰',
		ENV_VALUE => "<input type=\"text\" name=\"env_list_size\" size=\"5\" value=\"$self->{config}->{list_size}\" style=\"ime-mode:disabled;\" />ä»¶"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ–°ç€ã‚³ãƒ¡ãƒ³ãƒˆã®è¡¨ç¤ºä»¶æ•°ï¼ˆ0ã«ã™ã‚‹ã¨éžè¡¨ç¤ºï¼‰',
		ENV_VALUE => "<input type=\"text\" name=\"env_cmtlist_size\" size=\"5\" value=\"$self->{config}->{cmtlist_size}\" style=\"ime-mode:disabled;\" />ä»¶"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ–°ç€ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯ã®è¡¨ç¤ºä»¶æ•°ï¼ˆ0ã«ã™ã‚‹ã¨éžè¡¨ç¤ºï¼‰',
		ENV_VALUE => "<input type=\"text\" name=\"env_tblist_size\" size=\"5\" value=\"$self->{config}->{tblist_size}\" style=\"ime-mode:disabled;\" />ä»¶"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => '1ãƒšãƒ¼ã‚¸ã®è¨˜äº‹è¡¨ç¤ºä»¶æ•°ï¼ˆæºå¸¯ãƒ¢ãƒ¼ãƒ‰æ™‚ï¼‰',
		ENV_VALUE => "<input type=\"text\" name=\"env_mobile_page_size\" size=\"5\" value=\"$self->{config}->{mobile_page_size}\" style=\"ime-mode:disabled;\" />ä»¶"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ–°ç€ã‚³ãƒ¡ãƒ³ãƒˆã®è¡¨ç¤ºä»¶æ•°ï¼ˆæºå¸¯ãƒ¢ãƒ¼ãƒ‰æ™‚ï¼‰',
		ENV_VALUE => "<input type=\"text\" name=\"env_mobile_cmtlist_size\" size=\"5\" value=\"$self->{config}->{mobile_cmtlist_size}\" style=\"ime-mode:disabled;\" />ä»¶"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ–°ç€ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯ã®è¡¨ç¤ºä»¶æ•°ï¼ˆæºå¸¯ãƒ¢ãƒ¼ãƒ‰æ™‚ï¼‰',
		ENV_VALUE => "<input type=\"text\" name=\"env_mobile_tblist_size\" size=\"5\" value=\"$self->{config}->{mobile_tblist_size}\" style=\"ime-mode:disabled;\" />ä»¶"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'æŠ•ç¨¿ç”»é¢ã®è¡¨ç¤ºè¨å®š',
		ENV_ID    => 'env_form'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'åˆ†é¡žé¸æŠžé …ç›®ã®è¡¨ç¤º',
		ENV_VALUE => "<select name=\"env_use_field\">$use_field</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ã‚¢ã‚¤ã‚³ãƒ³é¸æŠžé …ç›®ã®è¡¨ç¤º',
		ENV_VALUE => "<select name=\"env_use_icon\">$use_icon</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ãƒ•ã‚¡ã‚¤ãƒ«é¸æŠžé …ç›®ã®è¡¨ç¤º',
		ENV_VALUE => "<select name=\"env_use_file\">$use_file</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯URLå…¥åŠ›é …ç›®ã®è¡¨ç¤º',
		ENV_VALUE => "<select name=\"env_use_tburl\">$use_tburl</select>"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'æŠ•ç¨¿è¨˜äº‹ã®åˆæœŸè¨å®š',
		ENV_ID    => 'env_default'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'è¨˜äº‹ã®å…¬é–‹',
		ENV_VALUE => "<select name=\"env_default_stat\">$default_stat</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ”¹è¡Œã®å¤‰æ›',
		ENV_VALUE => "<select name=\"env_default_break\">$default_break</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ã‚³ãƒ¡ãƒ³ãƒˆã®å—ä»˜',
		ENV_VALUE => "<select name=\"env_default_comt\">$default_comt</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯ã®å—ä»˜',
		ENV_VALUE => "<select name=\"env_default_tb\">$default_tb</select>"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'æŠ•ç¨¿è¨˜äº‹ã®è¡¨ç¤ºè¨å®š',
		ENV_ID    => 'env_show'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ–°ç€ãƒžãƒ¼ã‚¯è¡¨ç¤ºæ—¥æ•°',
		ENV_VALUE => "<input type=\"text\" name=\"env_new_days\" size=\"5\" value=\"$self->{config}->{new_days}\" style=\"ime-mode:disabled;\" />æ—¥é–“"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æœ¬æ–‡ã®URLã¨ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã«è‡ªå‹•çš„ã«ãƒªãƒ³ã‚¯',
		ENV_VALUE => "<select name=\"env_autolink_mode\">$autolink_mode</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'å¼•ç”¨æ–‡å—è‰²',
		ENV_VALUE => "<input type=\"text\" name=\"env_quotation_color\" size=\"10\" value=\"$self->{config}->{quotation_color}\" style=\"ime-mode:disabled;\" />"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'ãƒ•ã‚¡ã‚¤ãƒ«ã‚¢ãƒƒãƒ—ãƒãƒ¼ãƒ‰ã®è¨å®š',
		ENV_ID    => 'env_upload'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ã‚¢ãƒƒãƒ—ãƒãƒ¼ãƒ‰ãƒ•ã‚¡ã‚¤ãƒ«ã®æœ€å¤§æ¨ªå¹…',
		ENV_VALUE => "<input type=\"text\" name=\"env_img_maxwidth\" size=\"5\" value=\"$self->{config}->{img_maxwidth}\" style=\"ime-mode:disabled;\" />px"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ã‚µãƒ ãƒã‚¤ãƒ«ç”»åƒã‚’è‡ªå‹•çš„ã«ä½œæˆï¼ˆ<em>ImageMagickå¿…é ˆ</em>ï¼‰',
		ENV_VALUE => "<select name=\"env_thumbnail_mode\">$thumbnail_mode</select>"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'ã‚³ãƒ¡ãƒ³ãƒˆæŠ•ç¨¿åˆ¶é™ã®è¨å®š',
		ENV_ID    => 'env_restriction'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æŠ•ç¨¿ç¦æ¢ãƒ¯ãƒ¼ãƒ‰ï¼ˆæ”¹è¡ŒåŒºåˆ‡ã‚Šã§è¤‡æ•°æŒ‡å®šå¯èƒ½ï¼‰',
		ENV_VALUE => "<textarea name=\"env_ng_word\" cols=\"30\" rows=\"5\">$ng_word</textarea>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'é€£ç¶šæŠ•ç¨¿ã‚’æ‹’å¦ã™ã‚‹æ™‚é–“',
		ENV_VALUE => "<input type=\"text\" name=\"env_wait_time\" size=\"5\" value=\"$self->{config}->{wait_time}\" style=\"ime-mode:disabled;\" />ç§’"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'ãƒ¬ã‚¤ã‚¢ã‚¦ãƒˆã®è¨å®š',
		ENV_ID    => 'env_layout'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ã‚«ãƒ¬ãƒ³ãƒ€ãƒ¼ã®è¡¨ç¤º',
		ENV_VALUE => "<select name=\"env_show_calendar\">$show_calendar</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'åˆ†é¡žä¸€è¦§ã®è¡¨ç¤º',
		ENV_VALUE => "<select name=\"env_show_field\">$show_field</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ¤œç´¢ãƒ•ã‚©ãƒ¼ãƒ ã®è¡¨ç¤º',
		ENV_VALUE => "<select name=\"env_show_search\">$show_search</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'éŽåŽ»ãƒã‚°ä¸€è¦§ã®è¡¨ç¤º',
		ENV_VALUE => "<select name=\"env_show_past\">$show_past</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ã‚³ãƒ³ãƒ†ãƒ³ãƒ„ã®è¡¨ç¤º',
		ENV_VALUE => "<select name=\"env_show_menu\">$show_menu</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ãƒªãƒ³ã‚¯é›†ã®è¡¨ç¤º',
		ENV_VALUE => "<select name=\"env_show_link\">$show_link</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ãƒ—ãƒãƒ•ã‚£ãƒ¼ãƒ«ã®è¡¨ç¤º',
		ENV_VALUE => "<select name=\"env_show_profile\">$show_profile</select>"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'ã‚³ãƒ³ãƒ†ãƒ³ãƒ„ã®è¨å®š',
		ENV_ID    => 'env_menu'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ã‚³ãƒ³ãƒ†ãƒ³ãƒ„ã®åˆ†é¡žï¼ˆæ”¹è¡ŒåŒºåˆ‡ã‚Šã§è¤‡æ•°æŒ‡å®šå¯èƒ½ï¼‰',
		ENV_VALUE => "<textarea name=\"env_menu_list\" cols=\"30\" rows=\"5\">$menu_list</textarea>"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'ãƒªãƒ³ã‚¯é›†ã®è¨å®š',
		ENV_ID    => 'env_link'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ãƒªãƒ³ã‚¯é›†ã®åˆ†é¡žï¼ˆæ”¹è¡ŒåŒºåˆ‡ã‚Šã§è¤‡æ•°æŒ‡å®šå¯èƒ½ï¼‰',
		ENV_VALUE => "<textarea name=\"env_link_list\" cols=\"30\" rows=\"5\">$link_list</textarea>"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'ãƒ¡ãƒ¼ãƒ«é€šçŸ¥ã®è¨å®š',
		ENV_ID    => 'env_sendmail'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ã‚³ãƒ¡ãƒ³ãƒˆã‚’å—ä¿¡ã™ã‚‹ã¨ãƒ¡ãƒ¼ãƒ«ã§é€šçŸ¥',
		ENV_VALUE => "<select name=\"env_sendmail_cmt_mode\">$sendmail_cmt_mode</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯ã‚’å—ä¿¡ã™ã‚‹ã¨ãƒ¡ãƒ¼ãƒ«ã§é€šçŸ¥',
		ENV_VALUE => "<select name=\"env_sendmail_tb_mode\">$sendmail_tb_mode</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'Sendmailã®ãƒ‘ã‚¹',
		ENV_VALUE => "<input type=\"text\" name=\"env_sendmail_path\" size=\"30\" value=\"$self->{config}->{sendmail_path}\" style=\"ime-mode:disabled;\" />"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ãƒ¡ãƒ¼ãƒ«ã®é€šçŸ¥å…ˆï¼ˆæ”¹è¡ŒåŒºåˆ‡ã‚Šã§è¤‡æ•°æŒ‡å®šå¯èƒ½ï¼‰',
		ENV_VALUE => "<textarea name=\"env_sendmail_list\" cols=\"50\" rows=\"5\" style=\"ime-mode:disabled;\">$sendmail_list</textarea>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'é€šçŸ¥ã—ãªã„ã‚³ãƒ¡ãƒ³ãƒˆæŠ•ç¨¿è€…åï¼ˆæ”¹è¡ŒåŒºåˆ‡ã‚Šã§è¤‡æ•°æŒ‡å®šå¯èƒ½ï¼‰',
		ENV_VALUE => "<textarea name=\"env_sendmail_admin\" cols=\"30\" rows=\"5\">$sendmail_admin</textarea>"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'æ›´æ–°PINGã®è¨å®š',
		ENV_ID    => 'env_ping'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ›´æ–°PINGã®é€ä¿¡',
		ENV_VALUE => "<select name=\"env_ping_mode\">$ping_mode</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æ›´æ–°PINGã®é€šçŸ¥å…ˆï¼ˆæ”¹è¡ŒåŒºåˆ‡ã‚Šã§è¤‡æ•°æŒ‡å®šå¯èƒ½ï¼‰',
		ENV_VALUE => "<textarea name=\"env_ping_list\" cols=\"50\" rows=\"5\" style=\"ime-mode:disabled;\">$ping_list</textarea>"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'Cookieã®è¨å®š',
		ENV_ID    => 'env_cookie'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æŠ•ç¨¿è€…æƒ…å ±Cookieã®è˜åˆ¥å',
		ENV_VALUE => "<input type=\"text\" name=\"env_cookie_id\" size=\"30\" value=\"$self->{config}->{cookie_id}\" style=\"ime-mode:disabled;\" />"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æŠ•ç¨¿è€…æƒ…å ±ã®ä¿å˜æ—¥æ•°',
		ENV_VALUE => "<input type=\"text\" name=\"env_cookie_holddays\" size=\"5\" value=\"$self->{config}->{cookie_holddays}\" style=\"ime-mode:disabled;\" />æ—¥é–“"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ç®¡ç†è€…æƒ…å ±Cookieã®è˜åˆ¥å',
		ENV_VALUE => "<input type=\"text\" name=\"env_cookie_admin\" size=\"30\" value=\"$self->{config}->{cookie_admin}\" style=\"ime-mode:disabled;\" />"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'HTMLãƒ•ã‚¡ã‚¤ãƒ«æ›¸ãå‡ºã—ã®è¨å®š',
		ENV_ID    => 'env_html'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ãƒˆãƒƒãƒ—ãƒšãƒ¼ã‚¸ã‚’HTMLãƒ•ã‚¡ã‚¤ãƒ«ã«æ›¸ãå‡ºã—',
		ENV_VALUE => "<select name=\"env_html_index_mode\">$html_index_mode</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'å„è¨˜äº‹ã‚’HTMLãƒ•ã‚¡ã‚¤ãƒ«ã«æ›¸ãå‡ºã—',
		ENV_VALUE => "<select name=\"env_html_archive_mode\">$html_archive_mode</select>"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'JSãƒ•ã‚¡ã‚¤ãƒ«æ›¸ãå‡ºã—ã®è¨å®š',
		ENV_ID    => 'env_js'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'é¡Œåä¸€è¦§ã‚’JSãƒ•ã‚¡ã‚¤ãƒ«ã«æ›¸ãå‡ºã—',
		ENV_VALUE => "<select name=\"env_js_title_mode\">$js_title_mode</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'é¡Œåä¸€è¦§ã‚’JSãƒ•ã‚¡ã‚¤ãƒ«ã«æ›¸ãå‡ºã™ä»¶æ•°',
		ENV_VALUE => "<input type=\"text\" name=\"env_js_title_size\" size=\"5\" value=\"$self->{config}->{js_title_size}\" style=\"ime-mode:disabled;\" />ä»¶"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æœ€è¿‘ã®è¨˜äº‹ã‚’JSãƒ•ã‚¡ã‚¤ãƒ«ã«æ›¸ãå‡ºã—',
		ENV_VALUE => "<select name=\"env_js_text_mode\">$js_text_mode</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'æœ€è¿‘ã®è¨˜äº‹ã‚’JSãƒ•ã‚¡ã‚¤ãƒ«ã«æ›¸ãå‡ºã™ä»¶æ•°',
		ENV_VALUE => "<input type=\"text\" name=\"env_js_text_size\" size=\"5\" value=\"$self->{config}->{js_text_size}\" style=\"ime-mode:disabled;\" />ä»¶"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_replace_data(
		'env_title',
		ENV_TITLE => 'ã‚¢ã‚¯ã‚»ã‚¹åˆ¶é™ã®è¨å®š',
		ENV_ID    => 'env_access'
	);
	print $skin_ins->get_data('env_head');
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ã‚¢ã‚¯ã‚»ã‚¹åˆ¶é™å¯¾è±¡ãƒ›ã‚¹ãƒˆï¼ˆæ”¹è¡ŒåŒºåˆ‡ã‚Šã§è¤‡æ•°æŒ‡å®šå¯èƒ½ï¼‰',
		ENV_VALUE => "<textarea name=\"env_black_list\" cols=\"30\" rows=\"5\" style=\"ime-mode:disabled;\">$black_list</textarea>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'ProxyçµŒç”±ã®ã‚¢ã‚¯ã‚»ã‚¹',
		ENV_VALUE => "<select name=\"env_proxy_mode\">$proxy_mode</select>"
	);
	print $skin_ins->get_replace_data(
		'env',
		ENV_TITLE => 'è‡ªã‚µã‚¤ãƒˆã®URL(ã“ã®URLã‚’å«ã¾ãªã„ã‚µã‚¤ãƒˆã‹ã‚‰ã®æŠ•ç¨¿ã‚’æ‹’å¦)',
		ENV_VALUE => "<input type=\"text\" name=\"env_base_url\" size=\"50\" value=\"$self->{config}->{base_url}\" style=\"ime-mode:disabled;\" />"
	);
	print $skin_ins->get_data('env_foot');

	print $skin_ins->get_data('contents_foot');
	print $skin_ins->get_data('footer');

	return;
}

### ã‚¢ã‚¤ã‚³ãƒ³è¨å®šç”»é¢è¡¨ç¤º
sub output_icon {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'ã‚¢ã‚¤ã‚³ãƒ³ã‚’ç™»éŒ²ã™ã‚‹äº‹ãŒã§ãã¾ã™ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_icon}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');

	print $skin_ins->get_replace_data(
		'contents',
		FORM_EDIT => '',
		FORM_FILE => '',
		FORM_NAME => '',
		FORM_USER => ''
	);
	print $skin_ins->get_data('icon_head');

	my $i = 0;

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_icon}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_icon}");
	while (<FH>) {
		chomp;
		my($file, $name, $field, $user, $pwd) = split(/\t/);

		my $image = "<img src=\"$self->{init}->{data_dir}$self->{init}->{data_icon_dir}$file\" alt=\"$file\" />";

		print $skin_ins->get_replace_data(
			'icon',
			ICON_FILE  => $file,
			ICON_IMAGE => $image,
			ICON_NAME  => $name,
			ICON_USER  => $user
		);
	}
	close(FH);

	print $skin_ins->get_data('icon_foot');
	print $skin_ins->get_data('footer');

	return;
}

### ã‚³ãƒ³ãƒ†ãƒ³ãƒ„è¨å®šç”»é¢è¡¨ç¤º
sub output_menu {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'ã‚³ãƒ³ãƒ†ãƒ³ãƒ„ã‚’è¨å®šã™ã‚‹äº‹ãŒã§ãã¾ã™ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_menu}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');

	my $form_field;
	foreach (split(/<>/, $self->{config}->{menu_list})) {
		$form_field .= "<option value=\"$_\" lang=\"ja\">$_</option>";
	}

	print $skin_ins->get_replace_data(
		'contents',
		FORM_FIELD => $form_field
	);
	print $skin_ins->get_data('menu_head');

	my $i = 0;

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_menu}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_menu}");
	while (<FH>) {
		chomp;
		my($field, $name, $url) = split(/\t/);

		my $field_list;
		foreach (split(/<>/, $self->{config}->{menu_list})) {
			if ($field eq $_) {
				$field_list .= "<option value=\"$_\" lang=\"ja\" selected=\"selected\">$_</option>";
			} else {
				$field_list .= "<option value=\"$_\" lang=\"ja\">$_</option>";
			}
		}
		$field_list = "<select name=\"field$i\"><option value=\"\" lang=\"ja\">ãªã—</option>$field_list</select>";

		print $skin_ins->get_replace_data(
			'menu',
			MENU_FIELD => $field_list,
			MENU_NAME  => $name,
			MENU_URL   => $url,
			MENU_NO    => $i
		);

		$i++;
	}
	close(FH);

	print $skin_ins->get_data('menu_foot');
	print $skin_ins->get_data('footer');

	return;
}

### ãƒªãƒ³ã‚¯é›†è¨å®šç”»é¢è¡¨ç¤º
sub output_link {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'ãƒªãƒ³ã‚¯é›†ã‚’è¨å®šã™ã‚‹äº‹ãŒã§ãã¾ã™ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_link}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');

	my $form_field;
	foreach (split(/<>/, $self->{config}->{link_list})) {
		$form_field .= "<option value=\"$_\" lang=\"ja\">$_</option>";
	}

	print $skin_ins->get_replace_data(
		'contents',
		FORM_FIELD => $form_field
	);
	print $skin_ins->get_data('link_head');

	my $i = 0;

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_link}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_link}");
	while (<FH>) {
		chomp;
		my($field, $name, $url) = split(/\t/);

		my $field_list;
		foreach (split(/<>/, $self->{config}->{link_list})) {
			if ($field eq $_) {
				$field_list .= "<option value=\"$_\" lang=\"ja\" selected=\"selected\">$_</option>";
			} else {
				$field_list .= "<option value=\"$_\" lang=\"ja\">$_</option>";
			}
		}
		$field_list = "<select name=\"field$i\"><option value=\"\" lang=\"ja\">ãªã—</option>$field_list</select>";

		print $skin_ins->get_replace_data(
			'link',
			LINK_FIELD => $field_list,
			LINK_NAME  => $name,
			LINK_URL   => $url,
			LINK_NO    => $i
		);

		$i++;
	}
	close(FH);

	print $skin_ins->get_data('link_foot');
	print $skin_ins->get_data('footer');

	return;
}

### ãƒ—ãƒãƒ•ã‚£ãƒ¼ãƒ«è¨å®šç”»é¢
sub output_profile {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'ãƒ—ãƒãƒ•ã‚£ãƒ¼ãƒ«ã‚’è¨å®šã—ã¾ã™ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_profile}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	my(%name, %text);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_profile}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_profile}");
	while (<FH>) {
		chomp;
		my($user, $name, $text) = split(/\t/);

		$name{$user} = $name;
		$text{$user} = $text;
	}
	close(FH);

	my $name_ins = new webliberty::String($name{'admin'});
	my $text_ins = new webliberty::String($text{'admin'});

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');
	print $skin_ins->get_replace_data(
		'contents',
		FORM_NAME => $name_ins->create_plain,
		FORM_TEXT => $text_ins->create_plain
	);
	print $skin_ins->get_data('footer');

	return;
}

### ç®¡ç†è€…ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰è¨å®šç”»é¢
sub output_pwd {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'ç®¡ç†è€…ç”¨ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ã‚’è¨å®šã—ã¾ã™ã€‚ä»¥å‰ã®ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ã¨æ–°ã—ãè¨å®šã—ãŸã„ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ã‚’å…¥åŠ›ã—ã¦ãã ã•ã„ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_pwd}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');
	print $skin_ins->get_data('contents');
	print $skin_ins->get_data('footer');

	return;
}

### ã‚ãƒ£ãƒ³ãƒã‚¹è¡¨ç¤º
sub output_canvas {
	my $self = shift;

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_paint}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		INFO_RES => $self->{init}->{res_dir},
		$diary_ins->info
	);

	my $pch;
	if ($self->{query}->{pch}) {
		$pch = "$self->{init}->{data_dir}$self->{init}->{pch_dir}$self->{query}->{pch}\.spch";
	} else {
		$pch = '';
	}

	my $cookie_ins = new webliberty::Cookie($self->{config}->{cookie_admin});

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');
	print $skin_ins->get_replace_data(
		'canvas',
		CANVAS_PWD    => $cookie_ins->get_cookie('admin_pwd'),
		CANVAS_NO     => $self->{query}->{pch},
		CANVAS_PCH    => $pch,
		CANVAS_WIDTH  => $self->{query}->{width},
		CANVAS_HEIGHT => $self->{query}->{height}
	);
	print $skin_ins->get_data('footer');

	return;
}

### ã‚¤ãƒ©ã‚¹ãƒˆè¡¨ç¤º
sub output_view {
	my $self = shift;

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_image}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info
	);

	opendir(DIR, "$self->{init}->{data_dir}$self->{init}->{paint_dir}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{paint_dir}");
	my @files = sort { $a <=> $b } grep { m/\w+\.\w+/g } readdir(DIR);
	close(DIR);

	my($file_image, $file_name, $file_width, $file_height, $flag);

	foreach (@files) {
		my $file_ins  = new webliberty::File("$self->{init}->{data_dir}$self->{init}->{paint_dir}$_");
		$file_name = $file_ins->get_name . '.' . $file_ins->get_ext;

		if ($self->{query}->{pch} eq $file_ins->get_name) {
			($file_width, $file_height) = $file_ins->get_size;

			$flag = 1;

			last;
		}
	}
	if (!$flag) {
		$self->error('æŒ‡å®šã•ã‚ŒãŸã‚¤ãƒ©ã‚¹ãƒˆã¯å˜åœ¨ã—ã¾ã›ã‚“ã€‚');
	}

	my $file_image = "<img src=\"$self->{init}->{data_dir}$self->{init}->{paint_dir}$file_name\" alt=\"ãƒšã‚¤ãƒ³ãƒˆãƒ•ã‚¡ã‚¤ãƒ« $file_name\" width=\"$file_width\" height=\"$file_height\" />";

	print $self->header;
	print $skin_ins->get_replace_data(
		'_all',
		INFO_IMAGE      => $file_image,
		INFO_FILENAME   => $file_name,
		INFO_FILEWIDTH  => $file_width,
		INFO_FILEHEIGHT => $file_height
	);

	return;
}

### ã‚¤ãƒ©ã‚¹ãƒˆä¸€è¦§è¡¨ç¤º
sub output_paint {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'ã‚¤ãƒ©ã‚¹ãƒˆã‚’æŠ•ç¨¿ã™ã‚‹ã«ã¯ã€ä½œæ¥å¯¾è±¡ã‚’é¸æŠžã—ã¦<em>ãƒšã‚¤ãƒ³ãƒˆãƒœã‚¿ãƒ³</em>ã‚’æŠ¼ã—ã¦ãã ã•ã„ã€‚';
	}

	opendir(DIR, "$self->{init}->{data_dir}$self->{init}->{pch_dir}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{pch_dir}");
	my @dir = sort { $b <=> $a } readdir(DIR);
	closedir(DIR);

	my $pch_list;
	foreach my $entry (@dir) {
		if ($entry =~ /^(\d+)\.\w+$/) {
			$pch_list .= "<option value=\"$1\" lang=\"ja\">No.$1ã®ã‚¤ãƒ©ã‚¹ãƒˆ</option>";
		}
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_paint}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_PCH     => $pch_list,
		INFO_MESSAGE => $self->{message}
	);

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');
	print $skin_ins->get_data('contents');
	print $skin_ins->get_data('footer');

	return;
}

### å†æ§‹ç¯‰è¨å®šè¡¨ç¤º
sub output_build {
	my $self = shift;

	if (!$self->{message}) {
		$self->{message} = 'ä½œæ¥å†…å®¹ã‚’é¸æŠžã—ã€<em>å®Ÿè¡Œãƒœã‚¿ãƒ³</em>ã‚’æŠ¼ã—ã¦ãã ã•ã„ã€‚';
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_build}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}");
	my @index = <FH>;
	close(FH);

	my @numbers = map { (split(/\t/))[1] } @index;
	@index = @index[sort { $numbers[$b] <=> $numbers[$a] } (0 .. $#numbers)];
	my $max_no = (split(/\t/, $index[0]))[1];

	my $form_list = "<option value=\"all\" lang=\"ja\">ã™ã¹ã¦ã‚’æ§‹ç¯‰</option><option value=\"index\" lang=\"ja\">ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’æ§‹ç¯‰</option>";
	if ($self->{config}->{html_archive_mode}) {
		foreach (0 .. int(($max_no - 1) / 50)) {
			my $from = $_ * 50 + 1;
			my $to;
			if ($_ == int(($max_no - 1) / 50)) {
				$to = $from + ($max_no - 1) % 50;
			} else {
				$to = $from + 50 - 1;
			}
			$form_list .= "<option value=\"$from\" lang=\"ja\">ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–ï¼ˆNo.$fromï½žNo.$toï¼‰ã‚’æ§‹ç¯‰</option>";
		}
	}

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');
	print $skin_ins->get_replace_data(
		'contents',
		FORM_LIST => $form_list
	);
	print $skin_ins->get_data('footer');

	return;
}

### ã‚¹ãƒ†ãƒ¼ã‚¿ã‚¹ç”»é¢
sub output_status {
	my $self = shift;

	my($diary_size, $diary_show_size, $diary_hidden_size);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}$self->{init}->{data_diary_index}");
	while (<FH>) {
		chomp;
		my($date, $no, $id, $stat, $field, $name) = split(/\t/);

		if ($stat) {
			$diary_show_size++;
		} else {
			$diary_hidden_size++;
		}
		$diary_size++;
	}
	close(FH);

	my($comt_size, $comt_show_size, $comt_hidden_size);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_comt_dir}$self->{init}->{data_comt_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_comt_dir}$self->{init}->{data_comt_index}");
	while (<FH>) {
		chomp;
		my($no, $pno, $stat, $date, $name, $subj, $host) = split(/\t/);

		if ($stat) {
			$comt_show_size++;
		} else {
			$comt_hidden_size++;
		}
		$comt_size++;
	}
	close(FH);

	my($tb_size, $tb_show_size, $tb_hidden_size);

	open(FH, "$self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{init}->{data_tb_index}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_tb_dir}$self->{init}->{data_tb_index}");
	while (<FH>) {
		chomp;
		my($no, $pno, $stat, $date, $blog, $title, $url) = split(/\t/);

		if ($stat) {
			$tb_show_size++;
		} else {
			$tb_hidden_size++;
		}
		$tb_size++;
	}
	close(FH);

	my($diary_file_size, $comt_file_size, $tb_file_size, $upfile_file_size, $archive_file_size, $paint_file_size, $pch_file_size);

	opendir(DIR, "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_diary_dir}");
	foreach my $file (readdir(DIR)) {
		if ($file ne '.' and $file ne '..') {
			$diary_file_size += (-s "$self->{init}->{data_dir}$self->{init}->{data_diary_dir}$file");
		}
	}
	closedir(DIR);
	opendir(DIR, "$self->{init}->{data_dir}$self->{init}->{data_comt_dir}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_comt_dir}");
	foreach my $file (readdir(DIR)) {
		if ($file ne '.' and $file ne '..') {
			$comt_file_size += (-s "$self->{init}->{data_dir}$self->{init}->{data_comt_dir}$file");
		}
	}
	closedir(DIR);

	opendir(DIR, "$self->{init}->{data_dir}$self->{init}->{data_tb_dir}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_tb_dir}");
	foreach my $file (readdir(DIR)) {
		if ($file ne '.' and $file ne '..') {
			$tb_file_size += (-s "$self->{init}->{data_dir}$self->{init}->{data_tb_dir}$file");
		}
	}
	closedir(DIR);

	opendir(DIR, "$self->{init}->{data_dir}$self->{init}->{data_upfile_dir}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{data_upfile_dir}");
	foreach my $file (readdir(DIR)) {
		if ($file ne '.' and $file ne '..') {
			$upfile_file_size += (-s "$self->{init}->{data_dir}$self->{init}->{data_upfile_dir}$file");
		}
	}
	closedir(DIR);

	opendir(DIR, "$self->{init}->{archive_dir}") or $self->error("Read Error : $self->{init}->{archive_dir}");
	foreach my $file (readdir(DIR)) {
		if ($file ne '.' and $file ne '..') {
			$archive_file_size += (-s "$self->{init}->{archive_dir}$file");
		}
	}
	closedir(DIR);

	opendir(DIR, "$self->{init}->{data_dir}$self->{init}->{paint_dir}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{paint_dir}");
	foreach my $file (readdir(DIR)) {
		if ($file ne '.' and $file ne '..') {
			$paint_file_size += (-s "$self->{init}->{data_dir}$self->{init}->{paint_dir}$file");
		}
	}
	closedir(DIR);

	opendir(DIR, "$self->{init}->{data_dir}$self->{init}->{pch_dir}") or $self->error("Read Error : $self->{init}->{data_dir}$self->{init}->{pch_dir}");
	foreach my $file (readdir(DIR)) {
		if ($file ne '.' and $file ne '..') {
			$pch_file_size += (-s "$self->{init}->{data_dir}$self->{init}->{pch_dir}$file");
		}
	}
	closedir(DIR);

	$diary_file_size   = sprintf("%.1f", $diary_file_size / 1024);
	$comt_file_size    = sprintf("%.1f", $comt_file_size / 1024);
	$tb_file_size      = sprintf("%.1f", $tb_file_size / 1024);
	$upfile_file_size  = sprintf("%.1f", $upfile_file_size / 1024);
	$archive_file_size = sprintf("%.1f", $archive_file_size / 1024);
	$paint_file_size   = sprintf("%.1f", $paint_file_size / 1024);
	$pch_file_size     = sprintf("%.1f", $pch_file_size / 1024);

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_status}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info,
		INFO_MESSAGE => $self->{message}
	);

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('work_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('work_foot');

	print $skin_ins->get_replace_data(
		'contents',
		STATUS_DIARY_SIZE        => $diary_size || 0,
		STATUS_DIARY_SHOW_SIZE   => $diary_show_size || 0,
		STATUS_DIARY_HIDDEN_SIZE => $diary_hidden_size || 0,
		STATUS_DIARY_FILE_SIZE   => $diary_file_size || 0,
		STATUS_COMT_SIZE         => $comt_size || 0,
		STATUS_COMT_SHOW_SIZE    => $comt_show_size || 0,
		STATUS_COMT_HIDDEN_SIZE  => $comt_hidden_size || 0,
		STATUS_COMT_FILE_SIZE    => $comt_file_size || 0,
		STATUS_TB_SIZE           => $tb_size || 0,
		STATUS_TB_SHOW_SIZE      => $tb_show_size || 0,
		STATUS_TB_HIDDEN_SIZE    => $tb_hidden_size || 0,
		STATUS_TB_FILE_SIZE      => $tb_file_size || 0,
		STATUS_UPFILE_FILE_SIZE  => $upfile_file_size || 0,
		STATUS_ARCHIVE_FILE_SIZE => $archive_file_size || 0,
		STATUS_PAINT_FILE_SIZE   => $paint_file_size || 0,
		STATUS_PCH_FILE_SIZE     => $pch_file_size || 0
	);

	print $skin_ins->get_data('footer');

	return;
}

### èªè¨¼ç”»é¢è¡¨ç¤º
sub output_login {
	my $self = shift;

	if ($self->{query}->{admin_pwd}) {
		$self->error('ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ãŒé•ã„ã¾ã™ã€‚');
	}

	my $skin_ins = new webliberty::Skin;
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin}");
	$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

	$skin_ins->replace_skin(
		$diary_ins->info
	);

	print $self->header;
	print $skin_ins->get_data('header');
	print $skin_ins->get_data('contents_head');
	print $self->work_navi($skin_ins);
	print $skin_ins->get_data('contents_foot');
	print $skin_ins->get_data('footer');

	return;
}

### ä½œæ¥å†…å®¹ä¸€è¦§
sub work_navi {
	my $self     = shift;
	my $skin_ins = shift;

	my $work_data;

	$work_data  = "\tæŠ•ç¨¿\n";
	$work_data .= "new\tæ–°è¦æŠ•ç¨¿\n";
	$work_data .= "edit\tè¨˜äº‹ç·¨é›†\n";
	$work_data .= "\tã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£\n";
	$work_data .= "comment\tã‚³ãƒ¡ãƒ³ãƒˆç®¡ç†\n";
	$work_data .= "trackback\tãƒˆãƒ©ãƒƒã‚¯ãƒãƒƒã‚¯ç®¡ç†\n";

	$work_data .= "\tå„ç¨®è¨å®š\n";
	if ($self->{config}->{use_field}) {
		$work_data .= "field\tåˆ†é¡žè¨å®š\n";
	}
	$work_data .= "env\tç’°å¢ƒè¨å®š\n";
	if ($self->{config}->{use_icon}) {
		$work_data .= "icon\tã‚¢ã‚¤ã‚³ãƒ³è¨å®š\n";
	}
	if ($self->{config}->{show_menu}) {
		$work_data .= "menu\tã‚³ãƒ³ãƒ†ãƒ³ãƒ„ç®¡ç†\n";
	}
	if ($self->{config}->{show_link}) {
		$work_data .= "link\tãƒªãƒ³ã‚¯é›†ç®¡ç†\n";
	}
	if ($self->{config}->{show_profile}) {
		$work_data .= "profile\tãƒ—ãƒãƒ•ã‚£ãƒ¼ãƒ«è¨å®š\n";
	}
	$work_data .= "pwd\tãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰è¨å®š\n";

	$work_data .= "\tãƒ¦ãƒ¼ãƒ†ã‚£ãƒªãƒ†ã‚£\n";
	if (-e $self->{init}->{paint_jar}) {
		$work_data .= "paint\tã‚¤ãƒ©ã‚¹ãƒˆç®¡ç†\n";
	}
	if ($self->{config}->{html_index_mode} or $self->{config}->{html_archive_mode}) {
		$work_data .= "build\tã‚µã‚¤ãƒˆå†æ§‹ç¯‰\n";
	}
	$work_data .= "status\tã‚¹ãƒ†ãƒ¼ã‚¿ã‚¹è¡¨ç¤º\n";

	my($work_list, $flag);

	foreach (split(/\n/, $work_data)) {
		my($work_id, $work_name) = split(/\t/);

		if ($work_id) {
			if ($self->{query}->{work} eq $work_id) {
				$work_list .= $skin_ins->get_replace_data(
					'work_selected',
					WORK_ID   => $work_id,
					WORK_NAME => $work_name
				);
			} else {
				$work_list .= $skin_ins->get_replace_data(
					'work',
					WORK_ID   => $work_id,
					WORK_NAME => $work_name
				);
			}
		} else {
			if ($flag) {
				$work_list .= $skin_ins->get_data('work_delimiter');
				$flag = 0;
			}

			$work_list .= $skin_ins->get_replace_data(
				'work_title',
				WORK_NAME => $work_name
			);

			$flag = 1;
		}
	}
	if ($flag) {
		$work_list .= $skin_ins->get_data('work_delimiter');
	}

	return $work_list;
}

### ã‚¨ãƒ©ãƒ¼å‡ºåŠ›
sub error {
	my $self    = shift;
	my $message = shift;

	if ($self->{query}->{exec_regist} or $self->{query}->{exec_preview}) {
		$self->{message} = $message;

		my $skin_ins = new webliberty::Skin;
		$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_header}");
		$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_work}");
		$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_admin_form}");
		$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_diary}");
		$skin_ins->parse_skin("$self->{init}->{skin_dir}$self->{init}->{skin_footer}");

		my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});

		$skin_ins->replace_skin(
			$diary_ins->info,
			INFO_MESSAGE => $self->{message}
		);

		my $subj_ins = new webliberty::String($self->{query}->{subj});
		my $text_ins = new webliberty::String($self->{query}->{text});

		$subj_ins->create_line;
		$text_ins->create_text;

		my $date = "$self->{query}->{year}$self->{query}->{month}$self->{query}->{day}$self->{query}->{hour}$self->{query}->{minute}";

		print $self->header;
		print $skin_ins->get_data('header');
		print $skin_ins->get_data('work_head');
		print $self->work_navi($skin_ins);
		print $skin_ins->get_data('work_foot');
		print $skin_ins->get_replace_data(
			'form',
			$diary_ins->diary_form($self->{query}->{edit}, '', $self->{query}->{stat}, $self->{query}->{break}, $self->{query}->{comt}, $self->{query}->{tb}, '', $date, '', $subj_ins->get_string, $text_ins->get_string, '', '', '', ''),
			FORM_LABEL => 'ã‚¨ãƒ©ãƒ¼',
			FORM_WORK  => $self->{query}->{work},
			FORM_EXT1  => '',
			FORM_EXT2  => '',
			FORM_EXT3  => '',
			FORM_EXT4  => '',
			FORM_EXT5  => '',
			FORM_TBURL => $self->{query}->{tb_url}
		);
		print $skin_ins->get_data('footer');

		exit;
	}

	my $diary_ins = new webliberty::App::Diary($self->{init}, $self->{config}, $self->{query});
	$diary_ins->error($message);

	exit;
}

### ã‚¢ã‚¤ã‚³ãƒ³ä¸¦ã³æ›¿ãˆ
sub _sort_icon {
	my $self = shift;

	my(@normal, @personal, @names);

	foreach (@_) {
		chomp;
		my($file, $name, $field, $user, $pwd) = split(/\t/);

		if ($user) {
			push(@personal, "$_\n");
		} else {
			push(@normal, "$_\n");
		}
	}

	@names  = map { (split(/\t/))[1] } @normal;
	@normal = @normal[sort { $names[$a] cmp $names[$b] } (0 .. $#names)];

	@names    = map { (split(/\t/))[1] } @personal;
	@personal = @personal[sort { $names[$a] cmp $names[$b] } (0 .. $#names)];

	return(@normal, @personal);
}

1;