#!/usr/local/bin/perl
$dbfile= "realdb.dat";
########## Win-NT チェック
if( $ENV{"OS"} eq "Windows_NT" ){
$px = $ENV{"SCRIPT_NAME"};
$dx = substr( $px, 0, rindex( $px, "/" ) )."/";
$dbfile= "d:$dx$dbfile";
}
##########
print <<"END_OF_HTML";
Content-type: text/html
END_OF_HTML
open( DB, $dbfile ) || die "データベースが開けませんでした。";
@data = ;
close( DB );
$buffer = $ENV{'QUERY_STRING'};
if ($buffer eq "") {
print "該当するデータが存在しません。";
} else {
@pairs = split(/&/,$buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
$FORM{ "ID" } =~ s/[^0-9]//g;
$match = "false";
foreach $dd ( @data )
{
if( $match ne "true" ){
( $id, $shop, $name, $no, $staff, $address, $tel, $fax, $open, $email, $url, $comment, $topics, $time, $rest ) = split( /\t/ , $dd );
# ($telchk, $dummy) = split( "/", $tel );
# $telchk =~ s/[^0-9]//g;
if( $id eq $FORM{"ID" } ){ $match = "true"; break; }
}
}
if( $match ne "true" ){
print "該当するデータが存在しません。";
} else {
####################
# 略号を正式表記に変換
$shop =~ s/\(有\)/有限会社/;
$shop =~ s/\(株\)/株式会社/;
$shop =~ s/\(資\)/合資会社/;
# 表示上のフォーマット変換
$no =~ s/^\(/福島県知事\(/;
$no =~ s/\)-/\)第/;
$no = $no."号";
if( $open ne "" ){
( $oy, $om, $od ) = split( /\//, $open );
$open = $oy."年".$om."月";
}
$comment =~ s/[\x0a\x0b\x0d\n]/
/g;
$topics =~ s/[\x0a\x0b\x0d\n]/
/g;
$time =~ s/[\x0a\x0b\x0d\n]/
/g;
$rest =~ s/[\x0a\x0b\x0d\n]/
/g;
####################
print '';
print '';
print '| 社 名 | '.$shop.' | ';
print '免許番号 | '.$no.' | ';
print '
';
print '';
print '| 代表者名 | '.$name.' | ';
print '創 業 | '.$open.' | ';
print '
';
print '';
print '| 住 所 | ';
print ' '.$address.' | ';
print '
';
print '';
print '| TEL | '.$tel.' | ';
print 'FAX | '.$fax.' | ';
print '
';
print '';
print '| 事業内容 | '.$comment.' | ';
print '
';
if( $topics ne "" ){
print '';
print '| トピックス | '.$topics.' | ';
print '
';
}
print '';
print '| 営業時間 | '.$time.' | ';
print '休 日 | '.$rest.' | ';
print '
';
if( ($email ne "") && ($email =~ /^[^!]/ ) ){
print '';
print '| E-Mail | '.$email.' | ';
print '
';
}
if( ($url ne "") && ($url =~ /^[^!]/ ) ){
print '';
print '| ホームページ | '.$url.' | ';
print '
';
}
print "
\n";
print '';
print '';
print '';
####################
}
}