#####  INCM plug-in for Microsoft
 ####                                Ver0.25 　2004/01/30 by GETWILD'74

package Microsoft;

# モジュールのパス設定
$_=$0; s/[^\\]+$//; s/data\\.*$/Plugins\\/;
# モジュールの読み込み
require ($_.'INCM_MODULE.PM');

#####  フォルダプロパティの設定  ###########################################

$Dialog= <<"#[/IniDIALOG]";
#[IniDIALOG]
 #URL=1\nUPURL=1\nNAME=1\nEMAIL=1\nHP=1\nKEY=1
 #USER=1\nPASS=1\nPARAM1=1\nPARAM2=1
 #_URL=掲示板のアドレス(URL)(&A):
 #_UPURL=書き込み先のアドレス(URL)
 #_NAME=名前:
 #_EMAIL=メールアドレス:
 #_HP=ホームページ(URL)
 #_KEY=削除キー
 #_USER=User
 #_PASS=Pass
 #_PARAM1=
 #_PARAM2=
 #L000=L,,----- 掲示板の情報 -----
 #L000=TS,L_BBS_Name,掲示板の種類
 #L000=TS,L_BBS_Ver,掲示板のバージョン
 #L001=L,,  -- 項目選択 --
 #L002=C,L_Room1,項目1
 #L003=TS,L_Point1,未読ポインタ
 #L004=C,L_Room2,項目2
 #L005=TS,L_Point2,未読ポインタ
 #L006=C,L_Room3,項目3
 #L007=TS,L_Point3,未読ポインタ
 #L008=C,L_Room4,項目4
 #L009=TS,L_Point4,未読ポインタ
 #L010=C,L_Room5,項目5
 #L011=TS,L_Point5,未読ポインタ
 #L012=C,L_Room6,項目6
 #L013=TS,L_Point6,未読ポインタ
 #L014=C,L_Room7,項目7
 #L015=TS,L_Point7,未読ポインタ
 #L016=C,L_Room8,項目8
 #L017=TS,L_Point8,未読ポインタ
 #L018=C,L_Room9,項目9
 #L019=TS,L_Point9,未読ポインタ
 #L020=C,L_Room10,項目10
 #L021=TS,L_Point10,未読ポインタ
 #L022=C,L_Room11,項目11
 #L023=TS,L_Point11,未読ポインタ
 #L024=C,L_Room12,項目12
 #L025=TS,L_Point12,未読ポインタ
 #L026=C,L_Room13,項目13
 #L027=TS,L_Point13,未読ポインタ
 #L028=C,L_Room14,項目14
 #L029=TS,L_Point14,未読ポインタ
 #L030=C,L_Room15,項目15
 #L031=TS,L_Point15,未読ポインタ
 #L032=L,,----- 正規表\現解析の設定 -----
 #L033=L,,  -- 記事全般 --
 #L033=TS,L_PrmMain:HeadBody,記事ヘッダと本文の区切り.
 #L033=TS,L_PrmMain:Found,記事と判断する部分.
 #L033=TS,L_PrmMain:PassFound,無条件に記事とする正規表\現.
 #L034=L,,  -- 記事情報(親記事) --
 #L035=TS,L_RegMain:Num,記事番号.
 #L036=TS,L_RegMain:ResNum,レス元記事番号.
 #L037=TS,L_RegMain:Title,題名.
 #L038=TS,L_RegMain:Name,発言者名.
 #L039=TS,L_RegMain:Date,記事の日付書式.
 #L040=TS,L_RegMain:Url,ＵＲＬ.
 #L041=TS,L_RegMain:Mail,メールアドレス.
 #L042=TS,L_RegMain:Comment,本文.
 #L043=TS,L_RegMain:Attachment,添付ファイル.
 #L044=L,,  -- トピック解析 --
 #L044=TS,L_PrmTopic1:Found,記事と判断する部分.
 #L044=TS,L_RegTopic1:Num,記事番号.
 #L044=TS,L_RegTopic1:ResNum,レス元記事番号.
 #L044=TS,L_RegTopic1:List,記事のURLリスト.
 #L044=TS,L_RegMain:PullList,URLリストの取出方法.
 #L044=TS,L_PrmTopic1:Step,記事区切り.
 #L044=TS,L_PrmTopic1:StepTop,ページ頭読み飛ばし.
 #L044=TS,L_PrmTopic1:StepBottom,ページ末尾読み飛ばし.
 #L044=TS,L_PrmPages:Topic1:NextPage,ページめくり.
 #L044=TS,L_PrmTopic1:Fram,フレームの引数.
 #L044=TS,L_PrmTopic1:Mode,CGIモードの引数.
 #L045=L,,  -- 記事の読込定義 --
 #L045=TS,L_PrmMain:Step,記事の区切り.
 #L045=TS,L_PrmMain:StepTop,ページ頭読み飛ばし.
 #L045=TS,L_PrmMain:StepBottom,ページ末尾読み飛ばし.
 #L045=TS,L_PrmPages:Main:NextPage,ページめくり.
 #L045=TS,L_PrmMain:Fram,フレームの引数.
 #L045=TS,L_PrmMain:Mode,CGIモードの引数.
 #L046=L,,----- プラグインデバッグ用設定 -----
 #L046=C,DEBUG=1,動作ログを保存する
 #L046=.
#[/IniDIALOG]

#####  初期化と巡回  #######################################################

# INCM_MODULEクラスのインスタンス生成(生成時に初期化も行う)
if ($INCM = new INCM_MODULE) {

	# 巡回処理
	$INCM->Main;

}
exit;

#####  フォルダプロパティの定義  ###########################################
sub SetProperty {
	my ($BBS_Name, $BBS_Ver) = @_;
	my %Property;

	# フォルダプロパティ書き換え用の定義
	# Moug
	if ($BBS_Name eq 'Moug') {
		$Property{PARAM1} = 1;
		$Property{PARAM2} = 1;
		$Property{L000} = 1;
		$Property{L002} = 'Excel初級';
		$Property{L003} = '巡回ページ数1';
		$Property{L004} = 'Excel一般機能\';
		$Property{L005} = '巡回ページ数2';
		$Property{L006} = 'Excel VBA';
		$Property{L007} = '巡回ページ数3';
		$Property{L008} = 'Access初級';
		$Property{L009} = '巡回ページ数4';
		$Property{L010} = 'Access一般機能\';
		$Property{L011} = '巡回ページ数5';
		$Property{L012} = 'Access VBA';
		$Property{L013} = '巡回ページ数6';
		$Property{L014} = 'Word初級';
		$Property{L015} = '巡回ページ数7';
		$Property{L016} = 'Word一般機能\';
		$Property{L017} = '巡回ページ数8';
		$Property{L018} = 'Word VBA';
		$Property{L019} = '巡回ページ数9';
		$Property{L020} = 'PowerPoint全般';
		$Property{L021} = '巡回ページ数10';
		$Property{L022} = 'Outlook全般';
		$Property{L023} = '巡回ページ数11';
		$Property{L024} = 'その他のOffice製品';
		$Property{L025} = '巡回ページ数12';
		$Property{L026} = 'MOS(MOUS)';
		$Property{L027} = '巡回ページ数13';
		$Property{L028} = 'Windows全般';
		$Property{L029} = '巡回ページ数14';
		$Property{L032} = 1;
		$Property{L033} = 1;
		$Property{L034} = 1;
		$Property{L035} = 1;
		$Property{L036} = 1;
		$Property{L037} = 1;
		$Property{L038} = 1;
		$Property{L039} = 1;
		$Property{L040} = 1;
		$Property{L041} = 1;
		$Property{L042} = 1;
		$Property{L043} = 1;
		$Property{L044} = 1;
		$Property{L045} = 1;
		$Property{L046} = 1;

	# Shinken Housing
#	} elsif ($BBS_Name eq 'Shinken Housing') {

	# ETC
	} else {
		$Property{L000} = 1;
		$Property{L046} = 1;
	}

	# 掲示板ごとのフォルダプロパティ定義の連想配列リファレンスを返す
	return \%Property;
}

#####  掲示板自動判別  #####################################################
sub AutoSelect {
	my %AutoHOST;
	my %AutoURL;
	my %AutoHTML;

	# URLから判断するための定義
	$AutoURL{'Moug'}					= sub {
		my $STR = shift;
		if ($STR =~ m#http://www.moug.net/# || $STR =~ m#http://www2.moug.net/#) {
			return 'Moug', 1;
		}
	};

	# 自動判別定義を返す
	return ( HTML => \%AutoHTML, URL => \%AutoURL, HOST => \%AutoHOST );
}

#####  掲示板毎の設定  #####################################################
sub SetBBSdef {
	my ($BBS_Name, $BBS_Ver) = @_;
	my (%Basic, %CMT, %Reg, %Prm);
	$CMT{Head}{Mode} = 'ALL';
	@{$Prm{Type}} = ('Date');
	$Prm{Main}{Found} = 'Date';
	%{$Reg{Main}{Date}} = (Value => 'AUTO', No => 4);
	$Prm{Pages}{Main}{Method} = 'GET';

# スクリプト種別ごとの解析用定義
	# Moug
	if ($BBS_Name eq 'Moug') {

		$INCM_MODULE::DATA->CallObj('HTTP')->SetUrl('www2.moug.net');

		%{$Prm{Pages}{Topic1}{NextPage}} = (Found => '\[\d+\] \n \[<a href="thread\.php\?([^\"]+)">\d+<\/a>\]', Type => 'Anchor', Match => 1);
		$Prm{Pages}{Topic1}{NextPage}{Url}{Uri} = '/app/bbs/thread.php';

		$CMT{Head}{NumMode} = 'String';

		if ($INCM->GetParam('Room1', 'L')) {
			%{$CMT{Files}{'001'}{Title}} = (Value => '01-Excel初級', Mode => 'Fix');
			$CMT{Files}{'001'}{Point} = $INCM->GetParam('Point1', 'L');
		}
		if ($INCM->GetParam('Room2', 'L')) {
			%{$CMT{Files}{'002'}{Title}} = (Value => '02-Excel一般機能\', Mode => 'Fix');
			$CMT{Files}{'002'}{Point} = $INCM->GetParam('Point2', 'L');
		}
		if ($INCM->GetParam('Room3', 'L')) {
			%{$CMT{Files}{'003'}{Title}} = (Value => '03-Excel VBA', Mode => 'Fix');
			$CMT{Files}{'003'}{Point} = $INCM->GetParam('Point3', 'L');
		}
		if ($INCM->GetParam('Room4', 'L')) {
			%{$CMT{Files}{'004'}{Title}} = (Value => '04-Access初級', Mode => 'Fix');
			$CMT{Files}{'004'}{Point} = $INCM->GetParam('Point4', 'L');
		}
		if ($INCM->GetParam('Room5', 'L')) {
			%{$CMT{Files}{'005'}{Title}} = (Value => '05-Access一般機能\', Mode => 'Fix');
			$CMT{Files}{'005'}{Point} = $INCM->GetParam('Point5', 'L');
		}
		if ($INCM->GetParam('Room6', 'L')) {
			%{$CMT{Files}{'006'}{Title}} = (Value => '06-Access VBA', Mode => 'Fix');
			$CMT{Files}{'006'}{Point} = $INCM->GetParam('Point6', 'L');
		}
		if ($INCM->GetParam('Room7', 'L')) {
			%{$CMT{Files}{'007'}{Title}} = (Value => '07-Word初級', Mode => 'Fix');
			$CMT{Files}{'007'}{Point} = $INCM->GetParam('Point7', 'L');
		}
		if ($INCM->GetParam('Room8', 'L')) {
			%{$CMT{Files}{'008'}{Title}} = (Value => '08-Word一般機能\', Mode => 'Fix');
			$CMT{Files}{'008'}{Point} = $INCM->GetParam('Point8', 'L');
		}
		if ($INCM->GetParam('Room9', 'L')) {
			%{$CMT{Files}{'009'}{Title}} = (Value => '09-Word VBA', Mode => 'Fix');
			$CMT{Files}{'009'}{Point} = $INCM->GetParam('Point9', 'L');
		}
		if ($INCM->GetParam('Room10', 'L')) {
			%{$CMT{Files}{'010'}{Title}} = (Value => '10-PowerPoint全般', Mode => 'Fix');
			$CMT{Files}{'010'}{Point} = $INCM->GetParam('Point10', 'L');
		}
		if ($INCM->GetParam('Room11', 'L')) {
			%{$CMT{Files}{'011'}{Title}} = (Value => '11-Outlook全般', Mode => 'Fix');
			$CMT{Files}{'011'}{Point} = $INCM->GetParam('Point11', 'L');
		}
		if ($INCM->GetParam('Room12', 'L')) {
			%{$CMT{Files}{'012'}{Title}} = (Value => '12-その他のOffice製品', Mode => 'Fix');
			$CMT{Files}{'012'}{Point} = $INCM->GetParam('Point12', 'L');
		}
		if ($INCM->GetParam('Room13', 'L')) {
			%{$CMT{Files}{'013'}{Title}} = (Value => '13-MOS(MOUS)', Mode => 'Fix');
			$CMT{Files}{'013'}{Point} = $INCM->GetParam('Point13', 'L');
		}
		if ($INCM->GetParam('Room14', 'L')) {
			%{$CMT{Files}{'014'}{Title}} = (Value => '14-Windows全般', Mode => 'Fix');
			$CMT{Files}{'014'}{Point} = $INCM->GetParam('Point14', 'L');
		}

		@{$Prm{Type}} = ('Topic1', 'Thread');
		$Prm{Topic1}{ReadPoint} = 'None';
		$Prm{Main}{ReadPoint} = 'None';
		$Prm{Topic1}{Step}   = '<!-- list:';
		$Prm{Topic1}{StepTop} = '<!-- CGI-HERE -->';
		$Prm{Topic1}{Uri} = 'my @T = (\'b_exopr\',\'exopr\',\'exvba\',\'b_acopr\',\'acopr\',\'acm_v\',\'b_wordopr\',\'wordopr\',\'wordvba\',\'powerpoint\',\'outlook\',\'office\',\'mous\',\'win\'); \'/app/bbs/thread.php?cat=\'.$T[($DATA->GetRound(\'CMT\', \'No\') - 1)]';
		$Prm{Topic1}{Found} = 'List';
		%{$Reg{Topic1}{List}} = (Value => '<a href="\/([^\"]+)" target="_self">', Match => 1, No => 1, Opt => 'm');
		$Prm{Main}{Root}     = '<input type="hidden" name="mid" value="1">';
		$Prm{Main}{Step} = '<!--';
		$Prm{Main}{StepTop} = '<!-- CGI-HERE -->';
#		$Prm{Main}{StepBottom} = '/CENTER -->';
		$Prm{Main}{Found} = 'Name';
		$Prm{Main}{List} = 'Topic1';
		$Prm{Main}{PullList} = 'Shift';
		%{$Reg{Main}{Num}}    = (Value => '<input type="hidden" name="id" value="(.*?)">\n\n', Match => 1, No => 1, Eval => '$Text =~ s/\n//g; $Text =~ s/"><input type="hidden" name="mid" value="(\d+)/-$1/g; $Text');
		%{$Reg{Main}{Title}}  = (Value => '<font size="\+1" color="#333399"><b>(.*?)</b></font>', Match => 1, No => 2);
		%{$Reg{Main}{Name}}  = (Value => '    <td( bgcolor="#FFFFFF")? width="180">\n    ([^\n]+)\n    (<br>|</td>)\n', Match => 2, No => 3);
		%{$Reg{Main}{Comment}} = (Value => '    <td bgcolor="#[^\"]+" colspan="4">(.*)</pre>', Match => 1, No => 4);
		%{$Reg{Main}{Mail}} = (Value => 'AUTO');
		%{$Reg{Main}{Url}} = (Value => '\[<a href="([^"]+)" target="_new"><font', Match => 1);

		$Prm{Topic1}{InfoMes} = '#FixTitle# GetTopic#Page#:';
		$Prm{Main}{InfoMes} = '#FixTitle# Reading#Page#:';

	# 範囲指定
#		my $TopicUri = $Prm{Topic1}{Uri};
		for (my $i = 1; $i < 15; $i++) {
			if ($INCM->GetParam('Room'.$i, 'L') && $INCM->GetParam('Point'.$i, 'L') =~ /^(\d+)-(\d+)$/) {
				my $ls = $1; my $le = $2;
				my $length = length($i);
				my $CmtNo = substr('00'. $i, $length - 1, 3);
				my %h = %{$Prm{Topic1}};
				%{$Prm{$CmtNo}{Topic1}} = %h;
				$Prm{$CmtNo}{Main} = $Prm{Main};
				$Prm{$CmtNo}{Pages} = $Prm{Pages};
				$Prm{$CmtNo}{Type} = $Prm{Type};
				$Prm{$CmtNo}{Topic1}{Uri} = $Prm{Topic1}{Uri} . '.\'&offset=' . (1 + 30 * ($ls - 1)) . '\'';
				$CMT{Files}{$CmtNo}{Point} = $le - $ls + 1;
				$INCM->SetParam('Point'.$i, 'L', '');
			}
		}

	# Shinken Housing
#	} elsif ($BBS_Name eq 'Shinken Housing') {

	}

	# 解析用定義を返す
	return ( Basic => \%Basic, CMT => \%CMT, Reg => \%Reg, Prm => \%Prm);
}

1;
