#!/usr/local/bin/perl

#******************************************
# 新規作成: 2009/01/07 (HRS) T.Furuta
# 機能: 
# 改訂履歴: 
#******************************************


# 外部ファイル読込
require './subset.cgi';
require './sub.cgi';
require $jcode;

# 参照logファイル指定
$logfile = './data/date.cgi';

&decode;
&htmlview2;



#******************************************
#  記事表示
#******************************************
sub htmlview2 {
	# 繰越ページ
	my $page = 0;
	foreach ( keys(%in) ) {
		if (/^page:(\d+)$/) {
			$page = $1;
			last;
		}
	}

	# クッキー取得
	my ($cnam, $ceml, $curl, $cpwd) = &get_cookie;
	if (!$curl) { $curl = 'http://'; }

	# レス処理
	$in{'res'} =~ s/\D//g;
	my ($r_sub, $r_com);
	if ($in{'res'}) {
		my ($flg, $no, $dat, $nam, $eml, $sub, $com);

		open(IN,"$logfile");
		while (<IN>) {
			($no,$dat,$nam,$eml,$sub,$com) = split(/<>/);

			if ($in{'res'} == $no) {
				$flg = 1;
				last;
			}
		}
		close(IN);

		if (!$flg) { &error("該当記事が見つかりません"); }

		$sub =~ s/^Re://g;
		$sub =~ s/\[\d+\]\s?//g;
		$r_sub = "Re:[$no] $sub";
		$r_com = "&gt; $com";
		$r_com =~ s/<br>/\n&gt; /ig;
	}

	&html_head2;
	print qq|<div align="center">\n|;
	print "<p>$banner1</p>\n" if ($banner1 ne "<!-- 上部 -->");
	print <<EOM;


	</div>


EOM

# 表示部分　希望日付順に表示
	$number="";
	$dey="00000000";
	$title="";
	$main="";
	$j=0;
	$i = 0;
	$flg=0;

	#データの取得
	open(IN,"$logfile") || &error_view("Open Error: $logfile");
	while (<IN>) {
		$i++;
		my ($no,$date,$nam,$eml,$sub,$com,$url,$dummy1,$dummy2,$dummy3,$cb) = split(/<>/);
		
		@tmp = split(/<>/);
		
		#移行前PIDの救済措置
		if(length($no) != 7){
			$no = "1" . sprintf("%06d",$no);
		}
		
		#ソート用キー設定
		$su=substr($no,-1);
		if(($su eq "4")||($su eq "8")||($su eq "7")||($su eq "9")){
			$sub=$nam;
		}

		$sortStr = $sub.$no;
		$sortStr =~ s/\///g;
		@tmp[99] = $sortStr;
		
		#データを配列に退避
		push @file, [ @tmp ];
	}
	close(IN);
	

	#投稿希望日順にソート
	@file = sort {$b->[99] <=> $a->[99]} @file;
	

#記事の表示

	#システム日付を取得
	$a=datetring();

	#件数初期化
	$r_su = 0;
	
	foreach my $i ( 0 .. $#file ){
	
		#表示する値を指定
		$no=$file[$i][0];
		$su=substr($no,-1);
		if(($su eq "4")||($su eq "8")||($su eq "7")||($su eq "9")){
			$dey=$file[$i][2];
			$cb=$file[$i][4];
		}else{
			$dey=$file[$i][4];
			$cb=$file[$i][10];
		}
		$title  = $file[$i][2];
		$midasi = $file[$i][11];
		$main   = $file[$i][5];
		$b=$dey;
		# /を取り除く
		$a =~ s/\///g;
		$b =~ s/\///g;
		
		#未入力なら表示しない
		if(($su eq "2")||($su eq "5")){
			next if ($title eq "");
		}elsif(($su eq "6")||($su eq "3")){
			next if ($midasi eq "");
		}else{
			next if ($main eq "");
		}

		#公開チェック
		if (($a >= $b)&&($cb eq "on")) {

			$r_su++;
		
			#更新情報の表示
			
			$pid=substr($no,-2);
			
			if($pid eq "99"){
				$r_su--;
			}elsif($pid eq "05"){
				#会社概要
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub1/indexSub1_2.html" target="_top">$title</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "06"){
				#会社沿革
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub1/indexSub1_3.html" target="_top">$midasi</a><hr size="1" style="border:1px #dddddd dashed">|;

			}elsif($pid eq "04"){
				#焙煎工場
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub2/indexSub2_2.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "84"){
				#焙煎工場
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub2/indexSub2_8.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "14"){
				#業務案内
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub2/indexSub2_3.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "24"){
				#業務案内
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub2/indexSub2_4.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "34"){
				#業務案内
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub2/indexSub2_5.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "44"){
				#業務案内
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub2/indexSub2_6.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "54"){
				#業務案内
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub2/indexSub2_7.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;

			}elsif($pid eq "09"){
				#ストレートコーヒー 
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_1_1.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "19"){
				#ブレンドコーヒー 
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_1_2.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "29"){
				#限定商品
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_1_3.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "39"){
				#オリジナル 
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_1_4.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "49"){
				#紅茶 
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_1_5.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "59"){
				#輸入菓子 
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_1_6.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "69"){
				#キッチン用品 
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_1_7.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "79"){
				#器具 
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_1_8.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;


			}elsif($pid eq "17"){
				#業務案内（製品） 
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_2_1.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "27"){
				#業務案内（製品） 
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_2_2.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "37"){
				#業務案内（製品） 
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_2_3.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "47"){
				#業務案内（製品） 
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_2_4.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "57"){
				#業務案内（製品） 
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub3/indexSub3_2_5.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;


			}elsif($pid eq "08"){
				#イベントのお知らせ
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub4/indexSub4_1.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "18"){
				#スタッフブログ
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub4/indexSub4_2.html" target="_top">$main</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "02"){
				#採用情報
				print qq|$dey&nbsp;&nbsp;&nbsp;&nbsp;<a href="./../../../../sub/sub4/indexSub4_3.html" target="_top">$title</a><hr size="1" style="border:1px #dddddd dashed">|;
			}elsif($pid eq "03"){
				if($rink eq ""){
					print qq|$dey&nbsp&nbsp&nbsp&nbsp$midasi<hr size="1" color="#dddddd" style="border-style:dashed">|;
				}else{
					print qq|$dey&nbsp&nbsp&nbsp&nbsp<a href="$rink"  target="_blank">$midasi</a><hr size="1" color="#dddddd" style="border-style:dashed">|;
				}
			}else{
				print qq|$title<hr size="1" color="#dddddd" style="border-style:dashed">|;
			}
		
		}
		
		#最大表示件数に達したら終了
		last if( $r_su == $su1 );
			
	}

	print <<EOM;
	
</body>
</html>
EOM

	exit;
}


#******************************************
#  HTMLヘッダ
#******************************************
sub html_head2 {
	if ($headflag) { return; }

	print "Content-type: text/html\n\n";
	print <<"EOM";
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
	<html lang="ja">
	<head>
	<meta http-equiv="content-type" content="text/html; charset=shift_jis">
	<meta http-equiv="content-style-type" content="text/css">
	<meta name="robots" content="noindex,nofollow">
	<LINK href="./../img/aap.css" type=text/css rel=stylesheet>
	<style type="text/css">
	<!--
	body,td,th { font-size:$bSize; font-family:$bFace }
	.tbl { background-color:#ffffff; color:#000000; }
	-->
	</style>
	<title>$title</title>
	</head>
	$body
EOM
	$headflag = 1;
}

#******************************************
#  エラー処理
#******************************************
sub error_view {
	my $msg = shift;

	&html_head2;
	print <<EOM;
	<div align="center">
	<hr width="400">
	<h3>error</h3>
	$msg
	<br>
	<form action="./bbs_main.cgi" method="post">
	<input type="submit" value="　\TOPへ戻る　">
	</form>
	</form>
	<hr width="400">
	</div>
	</body>
	</html>
EOM
	exit;
}






#******************************************
#  時間取得
#******************************************
sub datetring
{
    local(@Time) = localtime(time);
    $Time[5] += 1900;
    $Time[4]++;
    for($i=0;$i<=5;$i++){
        $Time[$i] = ($Time[$i] < 10) ? "0$Time[$i]" : "$Time[$i]";
    }
    return "$Time[5]/$Time[4]/$Time[3]";
}



#**************************************************************************************************************************************************************************************************************************************************************************************************************************
# 著作権について
#
# 1. このソースのすべての著作権は、アワーズ株式会社(以降、当社)が保有します。
# 2. このソースに記載されている情報は、各国の著作権法、各種条約及びその他の法律で保護されています。私的使用その他法律によって明示的に認められる範囲を超えて、これらの情報を使用（複製、改変、アップロード、掲示、送信、頒布、ライセンス、販売、出版等を含む）をすることは、事前に当社の文書による許諾がないかぎり、禁止します。
# 3. このソースに記載されている商品名・会社名・団体名及びそれらのロゴは、各社・各団体等の商標または意匠登録されているものは、法令その他で保護されています。
# 4. このソースの利用、商標権・特許権・意匠権その他の知的財産権に基づく如何なる権利の許諾、及び複製・翻案・公衆送信・送信可能化等も含めて、できませんのでご注意ください。なお、個々の著作物に個別の利用条件が付されている場合は、当該条件が優先されます。
# 5. このソースから提供されるソフトウエアは、当該ソフトウエアに関する権利者の著作物です。それぞれのソフトウエアの提供に際して権利者から提示されるソフトウエア使用許諾契約書の規定及び著作権法、各種条約その他の法律に従ってご使用ください。
#
#**************************************************************************************************************************************************************************************************************************************************************************************************************************
