#!/usr/local/bin/perl --
;#------------------------------------------------------------------------------
$root_path = "";
$server_path = $ENV{'DOCUMENT_ROOT'};
;#------------------------------------------------------------------------------
use Fcntl qw(:flock);
push(@INC,$server_path.$root_path.'/common/lib/pl/');
require 'jcode.pl';
require 'fold.pl-1.6.pl';
require 'str.pl';
require 'text.pl';
require 'imgsize.pl';
require 'jtime.pl';
require 'iodata.pl';
require 'backup.pl';
require 'cookie.pl';
;#------------------------------------------------------------------------------
$data_path = '../../dat/main/info/';
if(!-e $data_path){umask(0);mkdir($data_path,0777)};
if(!-e $data_path."backup/"){umask(0);mkdir($data_path."backup/",0777)};
if(!-e $data_path."data/"){umask(0);mkdir($data_path."data/",0777)};


$h1title1="インフォメーション検索";
$index_name = 'index.dat';
$index_path = $data_path.$index_name;
$backup_path = $data_path."backup/".$index_name;

$category_name = 'category.dat';
$category_path = $data_path.$category_name;
$category_ancestor = 'Top';

$kind_name = 'kind.dat';
$kind_path = $data_path.$kind_name;

$group_name = 'group.dat';
$group_path = $data_path.$group_name;

$count_name = 'count.dat';
$count_path = $data_path.$count_name;

$strange = 0;# 機種依存文字置換(0:なし,1:あり)
$code_key = "彩";# デフォルト文字コードキー
;#------------------------------------------------------------------------------
if($ENV{'REQUEST_METHOD'} eq 'POST'){
read(STDIN,$key,$ENV{'CONTENT_LENGTH'});
}else{$key = $ENV{'QUERY_STRING'};}
;#------------------------------------------------------------------------------
# 文字コードキー取得
if($strange == 1){&text'strange_table_init();}
@pairs = split(/&/, $key,-1);
foreach $pair (@pairs){
	($field, $value) = split(/=/, $pair,-1);
	$field =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/ge;
	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/ge;
	if($field eq "code_key"){$code_key = $value;}
}
$code = &jcode'getcode(*code_key);

@pairs = split(/&/, $key,-1);
foreach $pair (@pairs){
	($field, $value) = split(/=/, $pair,-1);
	$field =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/ge;
	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/ge;
	if($code eq "sjis"){&jcode'sjis2euc(*field);&jcode'sjis2euc(*value);}
	if($code eq "jis"){&jcode'jis2euc(*field);&jcode'jis2euc(*value);}
	if($strange == 1){&text'strange_replace($value);}
	$value =~ s/\</&lt;/g;
	$value =~ s/\>/&gt;/g;
	$value =~ s/(\x0D\x0A|\x0D|\x0A)/\n/g;
	$value =~ s/\n+$//g;
	$value =~ s/\n/\<br\>/g;
	$value =~ s/\t/　/g;

	$FORM{$field} = $value;
	$mode = $FORM{'mode'};
	$res = $FORM{'res'};
	$number = $FORM{'number'};
	$exto = $FORM{'exto'};

	$cflg = $FORM{'cflg'};
	$kflg = $FORM{'kflg'};
	$gflg = $FORM{'gflg'};
	$sflg = $FORM{'sflg'};
	$mflg = $FORM{'mflg'};
	$word = $FORM{'word'};
}

;#------------------------------------------------------------------------------
$getstr = "";
if($code_key ne ""){$getstr .= "&code_key=".&text'urlEncode($code_key)};
if($cflg ne ""){$getstr .= "&cflg=".$cflg};
if($kflg ne ""){$getstr .= "&kflg=".$kflg};
if($gflg ne ""){$getstr .= "&gflg=".$gflg};
if($sflg ne ""){$getstr .= "&sflg=".$sflg};
if($mflg ne ""){$getstr .= "&mflg=".$mflg};
if($word ne ""){$getstr .= "&word=".&text'urlEncode($word)};
;#------------------------------------------------------------------------------
$tmp_krow=0;
open(IN, "< $kind_path");
flock IN,LOCK_SH;
while(<IN>){
	chomp $_;
	($tmpkstatus,$tmpksort,$tmpkregdate,$tmpkupdate,$tmpkhost,$tmpkaddr,$tmpktotal,$tmpkshowtotal,$tmpkmarktotal,$tmpkshowmarktotal,$tmpktitle) = split("	",$_,-1);
	$tmp_kindex[$tmpksort][0]=$tmpkstatus;
	$tmp_kindex[$tmpksort][1]=$tmp_krow;
	$tmp_kindex[$tmpksort][2]=$tmpkregdate;
	$tmp_kindex[$tmpksort][3]=$tmpkupdate;
	$tmp_kindex[$tmpksort][4]=$tmpkhost;
	$tmp_kindex[$tmpksort][5]=$tmpkaddr;
	$tmp_kindex[$tmpksort][6]=$tmpktotal;
	$tmp_kindex[$tmpksort][7]=$tmpkshowtotal;
	$tmp_kindex[$tmpksort][8]=$tmpkmarktotal;
	$tmp_kindex[$tmpksort][9]=$tmpkshowmarktotal;
	$tmp_kindex[$tmpksort][10]=$tmpktitle;
	$tmp_krow=$tmp_krow + 1;
}
close(IN);

$krow=0;
for($i=0;$i<$tmp_krow;$i++){
	if($tmp_kindex[$i][0]>0){
		$kindex[$krow][0] = $tmp_kindex[$i][0];
		$kindex[$krow][1] = $tmp_kindex[$i][1];
		$kindex[$krow][2] = $tmp_kindex[$i][2];
		$kindex[$krow][3] = $tmp_kindex[$i][3];
		$kindex[$krow][4] = $tmp_kindex[$i][4];
		$kindex[$krow][5] = $tmp_kindex[$i][5];
		$kindex[$krow][6] = $tmp_kindex[$i][6];
		$kindex[$krow][7] = $tmp_kindex[$i][7];
		$kindex[$krow][8] = $tmp_kindex[$i][8];
		$kindex[$krow][9] = $tmp_kindex[$i][9];
		$kindex[$krow][10] = $tmp_kindex[$i][10];

		$krow++;
	};
};

;#------------------------------------------------------------------------------
$tmp_grow=0;
open(IN, "< $group_path");
flock IN,LOCK_SH;
while(<IN>){
	chomp $_;
	($tmpgstatus,$tmpgsort,$tmpgregdate,$tmpgupdate,$tmpghost,$tmpgaddr,$tmpgtotal,$tmpgshowtotal,$tmpgmarktotal,$tmpgshowmarktotal,$tmpgtitle,$tmpggroup) = split("	",$_,-1);

	$tmp_gindex[$tmpgsort][0]=$tmpgstatus;
	$tmp_gindex[$tmpgsort][1]=$tmp_grow;
	$tmp_gindex[$tmpgsort][2]=$tmpgregdate;
	$tmp_gindex[$tmpgsort][3]=$tmpgupdate;
	$tmp_gindex[$tmpgsort][4]=$tmpghost;
	$tmp_gindex[$tmpgsort][5]=$tmpgaddr;
	$tmp_gindex[$tmpgsort][6]=$tmpgtotal;
	$tmp_gindex[$tmpgsort][7]=$tmpgshowtotal;
	$tmp_gindex[$tmpgsort][8]=$tmpgmarktotal;
	$tmp_gindex[$tmpgsort][9]=$tmpgshowmarktotal;
	$tmp_gindex[$tmpgsort][10]=$tmpgtitle;
	$tmp_gindex[$tmpgsort][11]=$tmpggroup;
	$tmp_grow=$tmp_grow + 1;
}
close(IN);

$grow=0;
for($i=0;$i<$tmp_grow;$i++){
	if($tmp_gindex[$i][0]>0){
		$gindex[$grow][0] = $tmp_gindex[$i][0];
		$gindex[$grow][1] = $tmp_gindex[$i][1];
		$gindex[$grow][2] = $tmp_gindex[$i][2];
		$gindex[$grow][3] = $tmp_gindex[$i][3];
		$gindex[$grow][4] = $tmp_gindex[$i][4];
		$gindex[$grow][5] = $tmp_gindex[$i][5];
		$gindex[$grow][6] = $tmp_gindex[$i][6];
		$gindex[$grow][7] = $tmp_gindex[$i][7];
		$gindex[$grow][8] = $tmp_gindex[$i][8];
		$gindex[$grow][9] = $tmp_gindex[$i][9];
		$gindex[$grow][10] = $tmp_gindex[$i][10];
		$gindex[$grow][11] = $tmp_gindex[$i][11];
		$grow++;
	};
};
;#------------------------------------------------------------------------------
&iodata'existFile($index_path,0666);
;#------------------------------------------------------------------------------
;# 読み込み

$tmp_row = 0;
open(IN, "< $index_path");
flock IN,LOCK_SH;
while(<IN>){
	chomp $_;
	$detail[$tmp_row] = $_;

	($tmpstatus,$tmpsort,$tmpregdate,$tmpupdate,$tmphost,$tmpaddr,$tmpcount,$tmpmark,$tmpcategory,$tmpkind,$tmpgroup,$tmpdate,$tmptitle,$tmpurltitle,$tmpurl,$tmplinktype,$tmpname,$tmppost,$tmpoffice) = split("	",$_,-1);

	$tmp_index[$tmpsort][0]=$tmpstatus;
	$tmp_index[$tmpsort][1]=$tmp_row;
	$tmp_index[$tmpsort][2]=$tmpregdate;
	$tmp_index[$tmpsort][3]=$tmpupdate;
	$tmp_index[$tmpsort][4]=$tmphost;
	$tmp_index[$tmpsort][5]=$tmpaddr;
	$tmp_index[$tmpsort][6]=$tmpcount;
	$tmp_index[$tmpsort][7]=$tmpmark;
	$tmp_index[$tmpsort][8]=$tmpcategory;
	$tmp_index[$tmpsort][9]=$tmpkind;
	$tmp_index[$tmpsort][10]=$tmpgroup;
	$tmp_index[$tmpsort][11]=$tmpdate;
	$tmp_index[$tmpsort][12]=$tmptitle;
	$tmp_index[$tmpsort][13]=$tmpurltitle;
	$tmp_index[$tmpsort][14]=$tmpurl;
	$tmp_index[$tmpsort][15]=$tmplinktype;
	$tmp_index[$tmpsort][16]=$tmpname;
	$tmp_index[$tmpsort][17]=$tmppost;
	$tmp_index[$tmpsort][18]=$tmpoffice;

	$tmp_row=$tmp_row + 1;

}
close(IN);
;#------------------------------------------------------------------------------
($status,$sort,$regdate,$update,$host,$addr,$count,$mark,$category,$kind,$group,$date,$title,$urltitle,$url,$linktype,$name,$post,$office) = split("	",$detail[$number],-1);

*data = &cookie'getCookie($ENV{'HTTP_COOKIE'});
$check = $data{"info$number"};
if($check != 1){
	open(REG, ">> $count_path");
	flock REG,LOCK_EX;
	print REG $number."\n";
	close(REG);
	chmod (0666, "$count_path");
}
;#------------------------------------------------------------------------------

$row=0;
for($i=0;$i<$tmp_row;$i++){
	if($tmp_index[$i][0]>1){
		if($tmp_index[$i][1] ne $number && $kind ne "" && $tmp_index[$i][8] eq $kind){
			$index[$row][0] = $tmp_index[$i][0];
			$index[$row][1] = $tmp_index[$i][1];
			$index[$row][2] = $tmp_index[$i][2];
			$index[$row][3] = $tmp_index[$i][3];
			$index[$row][4] = $tmp_index[$i][4];
			$index[$row][5] = $tmp_index[$i][5];
			$index[$row][6] = $tmp_index[$i][6];
			$index[$row][7] = $tmp_index[$i][7];
			$index[$row][8] = $tmp_index[$i][8];
			$index[$row][9] = $tmp_index[$i][9];
			$index[$row][10] = $tmp_index[$i][10];
			$index[$row][11] = $tmp_index[$i][11];
			$index[$row][12] = $tmp_index[$i][12];
			$index[$row][13] = $tmp_index[$i][13];
			$index[$row][14] = $tmp_index[$i][14];
			$index[$row][15] = $tmp_index[$i][15];
			$index[$row][16] = $tmp_index[$i][16];
			$index[$row][17] = $tmp_index[$i][17];
			$index[$row][18] = $tmp_index[$i][18];
			$row++;
		};
	};
}

@index_rev=reverse @index;

$filename = $regdate.".dat";
$file_path = $data_path."data/".$filename;

open(IN, "< $file_path");
flock IN,LOCK_SH;
$data = <IN>;
chomp $data;
close(IN);
@data_array = split("	",$data,-1);
$comment = $data_array[16];
$datatitle = $data_array[17];
$datafilename = $data_array[18];
$datalocalfilename = $data_array[19];
$img1title = $data_array[20];
$img1filename = $data_array[21];
$thum1filename = $data_array[22];
$img2title = $data_array[23];
$img2filename = $data_array[24];
$thum2filename = $data_array[25];
$img3title = $data_array[26];
$img3filename = $data_array[27];
$thum3filename = $data_array[28];
$img4title = $data_array[29];
$img4filename = $data_array[30];
$thum4filename = $data_array[31];
$img5title = $data_array[32];
$img5filename = $data_array[33];
$thum5filename = $data_array[34];
$img6title = $data_array[35];
$img6filename = $data_array[36];
$thum6filename = $data_array[37];
$img7title = $data_array[38];
$img7filename = $data_array[39];
$thum7filename = $data_array[40];
$img8title = $data_array[41];
$img8filename = $data_array[42];
$thum8filename = $data_array[43];
$img9title = $data_array[44];
$img9filename = $data_array[45];
$thum9filename = $data_array[46];
$img10title = $data_array[47];
$img10filename = $data_array[48];
$thum10filename = $data_array[49];

;#------------------------------------------------------------------------------
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($date);
$yyyy = $year + 1900;
$mm = $mon + 1;
$dd = $mday;
$h1title2 = $yyyy."/".$mm."/".$dd."";
;#------------------------------------------------------------------------------
print <<"END_OF_HTML";
Content-type: text/html; charset=EUC-JP

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ja"><!-- InstanceBegin template="/Templates/index.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!--彩-->
<meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
<meta http-equiv="Content-Language" content="ja">
<meta name="robots" content="index,follow,archive">
<link rel="alternate" type="application/rss+xml" title="RSS 1.0" href="/rss/index.rdf">
<!-- ■タイトル開始■ -->
<link rel="alternate" type="application/rss+xml" title="RSS 1.0" href="/support/sitemap/rss/index.rdf" />
<!-- InstanceParam name="pageid" type="text" value="main_info" -->
<meta name="Description" content="暗渠管洗浄システム「クローンロボ・きょうごく」　農業用暗渠排水、生活廃水、工場・事務所等の配水管の検査・洗浄は、京極町・川崎建設にお任せ下さい。">
<meta name="Keywords" content="暗渠,管,暗渠管洗浄システム,クローンロボ・きょうごく,農業用暗渠排水,生活廃水,工場,事務所,配水管,検査,洗浄,京極町,川崎建設">
<title>暗渠管洗浄システム「クローンロボ・きょうごく」　配水管の検査・洗浄は、京極町・川崎建設</title>
<!-- ■タイトル終了■ -->
<link rel="stylesheet" type="text/css" href="/common/css/main.css">
<link rel="stylesheet" type="text/css" href="/common/css/import.css" media="all">
<link rel="stylesheet" href="/common/css/size-default.css" type="text/css" title="default">
<link rel="alternate stylesheet" href="/common/css/size-big.css" type="text/css" title="big">
<link rel="alternate stylesheet" href="/common/css/size-small.css" type="text/css" title="small">
<script type="text/javascript" src="/common/lib/js/csschange.js"></script>
<!-- InstanceBeginEditable name="header" -->
<script type="text/javascript" src="/common/lib/js/body.js"></script>
<script type="text/javascript" src="/common/lib/js/mm.js"></script>
<script type="text/JavaScript">
<!--
window.onload = function(e){
 importOnLoad();
}
//-->
</script>
<link href="/common/css/main.css" rel="stylesheet" type="text/css">
<link href="/common/css/import.css" rel="stylesheet" type="text/css">
<!-- InstanceEndEditable -->
<!--#config errmsg=""-->
</head>
<body>
<!-- ■コンテンツ開始■ -->
<!-- InstanceBeginEditable name="EditRegion1" -->

END_OF_HTML
#<!--#include virtual="/common/ssi/static/header.html" -->
open(IN,"$server_path/common/ssi/static/header.html" );
flock IN,LOCK_SH;
#while(<IN>){if($_ eq "\n"){last;}}
while(<IN>){print $_;}
close(IN);
print <<"END_OF_HTML";

<table width="774" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="12" rowspan="3" background="/common/img/shadow_left.jpg"><img src="/common/img/spacer.gif" width="1" height="1" align="left"></td>
<td width="750" align="center"><table width="750" height="40" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="24"><img src="/common/img/menu_1.jpg" width="24" height="40"></td>
<td width="177"><a href="/sub/overview/" onMouseOver="MM_swapImage('Image1','','/common/img/menu_overview2.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="/common/img/menu_overview1.jpg" alt="会社案内" name="Image1" width="177" height="40" border="0" id="Image1"></a></td>
<td width="173"><a href="/main/product/" onMouseOver="MM_swapImage('Image2','','/common/img/menu_product2.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="/common/img/menu_product1.jpg" alt="ロボット紹介" name="Image2" width="173" height="40" border="0" id="Image2"></a></td>
<td width="376"><img src="/common/img/menu_2.jpg" width="376" height="40"></td>
</tr>
</table></td>
<td width="12" rowspan="3" background="/common/img/shadow_right.jpg"><img src="/common/img/spacer.gif" width="1" height="1" align="right"></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><br><h3><img src="/main/img/info_title.jpg" alt="お知らせ" width="600" height="36"></h3><br>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="380" rowspan="3" align="left" valign="top"><table width="380" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>

<!-- タイトル --><!-- 日付 -->
<strong><span class="f14l125">$title</span>　<span class="f12">$h1title2</span><strong>

</td>
</tr>
<tr>
<td><br>

<!-- 内容 -->
<span class="f12l150">$comment</span>

<!-- 関連リンクここから -->
END_OF_HTML

if($url ne ""){
	print '<br>';
	print '<br>';
	if($urltitle ne ""){
		print '<span class="fc_01_b">▼関連リンク</span><br><a href="'.$url.'" target="'.$linktype.'">'.$urltitle.'</a>';
	}else{
		print '<span class="fc_01_b">▼関連リンク</span><br><a href="'.$url.'" target="'.$linktype.'">'.$url.'</a>';
	}
}

if($datafilename ne ''){
	print '<br>';
	print '<br>';
	print '<span class="fc_01_b">▼PDFダウンロードはこちら</span>';
	print '<br>';
	print '<a href="'.$data_path.'data/'.$datafilename.'">';
	if($datatitle ne ""){print $datatitle;}else{print 'download';}
	print '</a>';
}

if($name ne ""||$post ne ""||$office ne ""){
	print '<br>';
	if($post ne ""){print $post."&nbsp;";}
	if($office ne ""){print $office."&nbsp;";}
	if($name ne ""){print $name."&nbsp;";}
}

print <<"END_OF_HTML";

</td>
</tr>
</table></td>


<td width="220" align="right" valign="top">
END_OF_HTML

# <!-- 画像 -->
if($thum1filename ne ''||$thum2filename ne ''||$thum3filename ne ''||$thum4filename ne ''||$thum5filename ne ''||$thum6filename ne ''||$thum7filename ne ''||$thum8filename ne ''||$thum9filename ne ''||$thum10filename ne ''){

#	print '<td width="220" align="right" valign="top">';

	if($thum1filename ne ''){
		undef @tmpimg1,@tmpimg2;
		@tmpimg1 = split("_",$thum1filename,-1);
		@tmpimg2 = split('\.',$tmpimg1[$#tmpimg1],-1);
		($imgW,$imgH) = split("x",$tmpimg2[0],-1);

		print '<div style="padding-bottom:4px;">';
		print '<a href="'.$data_path.'data/'.$img1filename.'" target="_blank"><img border="0" src="'.$data_path.'data/'.$thum1filename.'" width="'.$imgW.'" height="'.$imgH.'"></a>';
		if($img1title ne ""){print '<br>'.$img1title;}
		print '</div>';
		print '<img src="/common/img/spacer.gif" width="200" height="5"><br>';
	}

	if($thum2filename ne ''){
		undef @tmpimg1,@tmpimg2;
		@tmpimg1 = split("_",$thum2filename,-1);
		@tmpimg2 = split('\.',$tmpimg1[$#tmpimg1],-1);
		($imgW,$imgH) = split("x",$tmpimg2[0],-1);

		print '<div style="padding-bottom:4px;">';
		print '<a href="'.$data_path.'data/'.$img2filename.'" target="_blank"><img border="0" src="'.$data_path.'data/'.$thum2filename.'" width="'.$imgW.'" height="'.$imgH.'"></a>';
		if($img2title ne ""){print '<br>'.$img2title;}
		print '</div>';
		print '<img src="/common/img/spacer.gif" width="200" height="5"><br>';
	}

	if($thum3filename ne ''){
		undef @tmpimg1,@tmpimg2;
		@tmpimg1 = split("_",$thum3filename,-1);
		@tmpimg2 = split('\.',$tmpimg1[$#tmpimg1],-1);
		($imgW,$imgH) = split("x",$tmpimg2[0],-1);

		print '<div style="padding-bottom:4px;">';
		print '<a href="'.$data_path.'data/'.$img3filename.'" target="_blank"><img border="0" src="'.$data_path.'data/'.$thum3filename.'" width="'.$imgW.'" height="'.$imgH.'"></a>';
		if($img3title ne ""){print '<br>'.$img3title;}
		print '</div>';
		print '<img src="/common/img/spacer.gif" width="200" height="5"><br>';
	}

#	print '</td>';
}

print <<"END_OF_HTML";
</td>
</tr>
</table>

<br></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right"><a href="#pagetop"><img src="/main/img/pagetop.gif" alt="ページトップへ" width="100" height="19" border="0"></a></td>
</tr>
</table></td>
</tr>
</table>

END_OF_HTML
#<!--#include virtual="/common/ssi/static/footer.html" -->
open(IN,"$server_path/common/ssi/static/footer.html" );
flock IN,LOCK_SH;
#while(<IN>){if($_ eq "\n"){last;}}
while(<IN>){print $_;}
close(IN);
print <<"END_OF_HTML";

<!-- InstanceEndEditable -->

<!-- ■コンテンツ終了■ -->
</body>
<!-- InstanceEnd --></html>

END_OF_HTML
