#==========================================================================#
# ■ B.Forum Ver.1.01                                                      #
# ■ プラグインSDK(create)                                                 #
# □ Encode = EUC                                                          #
# □ Hiroaki,Sakuma (sakuma@beetas.org)                                    #
#                                                                          #
# このアプリケーションはオープンソースウェアです.                          #
# 無料で使用することができます.                                            #
# なお, 詳細な使用条件/最新情報については下記サイトをご覧下さい.           #
# http://www.beetas.org/                                                   #
#                                                                          #
# ------------------------------------------------------------------------ #
# Copyright 2001-2002 Hiroaki,Sakuma All Rights Reserved.                  #
# Copyright 2001-2002 BEETAS.org All Rights Reserved.                      #
#                                                                          #
#==========================================================================#
package create;

use Exporter;
use strict;

@ISA = qw(Exporter);
@EXPORT = qw(version status require_min require_max main);

my (%in %SET);

sub version {
	# バージョン(要変更)
	$version = "Plugin SDK(create) 1.01(0055-0058)";
	return $version;
}

sub status {
	return 1;
}

sub require_min {
	# 最低動作バージョン(要変更)
	$require_min = "0055";
	return $require_min;
}

sub require_max {
	# 最高動作バージョン(要変更)
	$require_max = "0058";
	return $require_max;
}

sub main ($$$@) {

	# 変更の必要なし
	my $head = $_[0];
	my $foot = $_[1];
	%in = %{$_[2]};
	splice (@_,0,3);
	%SET = %Bforum::SET;



	# ここから変更

	if (-d "$SET{'USER_DIR'}/$in{'id'}" && -z "$SET{'USER_DIR'}/$in{'id'}/index") {
		$in{'t'} = time;
		&Bforum::_analysis(\%create,&Bforum::_open(undef,"$SET{'USER_DIR'}/.default")) || &Bforum::error;
		$create{'message'} =~ s/\n<br>\n/\n/go;
		chomp ($create{'message'});
		$create{'new'} = "Author: $create{'author'}\n";
		$create{'new'} .= "Email: $create{'email'}\n";
		$create{'new'} .= "Title: $create{'title'}\n";
		$create{'new'} .= "No: 1\n";
		$create{'new'} .= "Host: System\n";
		$create{'new'} .= "Agent: System\n";
		$create{'new'} .= "Date: $in{'t'}\n\n";
		$create{'new'} .= $create{'message'};

		$no = 1;

		if (&Bforum::_lock) {

			&Bforum::_write("$SET{'USER_DIR'}/$in{'id'}/$in{'t'}/1",$create{'new'});
			&Bforum::_write("$SET{'USER_DIR'}/$in{'id'}/index","$in{'t'}\n");
			&Bforum::_write("$SET{'USER_DIR'}/$in{'id'}/last",$create{'new'});
			&Bforum::_write("$SET{'USER_DIR'}/$in{'id'}/0",$create{'new'});
			&Bforum::_flush("$SET{'USER_DIR'}/$in{'id'}/0");
			&Bforum::mknmz;
			if (-f "$SET{'USER_DIR'}/$in{'id'}/0") { unlink ("$SET{'USER_DIR'}/$in{'id'}/0") || &Bforum::error; }

			&Bforum::status;
			&Bforum::_unlock;

		}

		return ("$in{'t'}\n");

	} else {

		&about;

	}

}

sub about {
	close (NULL);
	&Bforum::about((caller)[2] . '@' . &version);
}

1;

