#!/usr/bin/perl
# full path of Perl after "#!".
# Copyright (C) 2004 Infotechnica Corporation, All rights reserved.
use strict;
use lib '.';
use CGI::Carp qw(fatalsToBrowser);
# jcode.pl required.
require 'jcode.pl';
# httmpl.pl required.
require 'httmpl.pl';
# --- define ---
# Configuration file name
my $config_file = 'config_h.txt';
# Key name
my %form_key = (
id => 'id',
query1 => 'q1',
query2 => 'q2',
query3 => 'q3',
query4 => 'q4',
query5 => 'q5',
query6 => 'q6',
query7 => 'q7',
query8 => 'q8',
query9 => 'q9',
school => 'qs',
page => 'page',
);
my %form_value = (
id => '',
query1 => '',
query2 => '',
query3 => '',
query4 => '',
query5 => '',
query6 => '',
query7 => '',
query8 => '',
query9 => '',
school => '',
page => '',
ERROR => '',
);
my %Didx = (
id => 0,
zone => 1,
s_layout => 2,
s_price => 3,
el_school => 4,
type => 5,
address1 => 6,
address2 => 7,
layout => 8,
price => 9,
land_area => 10,
land_tsubo => 11,
bldg_area => 12,
bldg_tsubo => 13,
frame => 14,
aspect => 15,
parking => 16,
elapsed => 17,
purpose => 18,
ratio => 19,
drainage => 20,
gas => 21,
jh_school => 22,
remarks => 23,
transaction => 24,
agency => 25,
regdate => 26,
image1 => 27,
image2 => 28,
);
# Template file name
my $template_file = '';
# CSV-file path
my $CSVFilePath = '';
# Kanji code for display
my $disp_code = 'sjis';
my $html_charset = 'Shift_JIS';
# Max selection
my $MaxSelection = 1;
# Max rows per page
my $MaxRow = 10;
# term of What's new (day)
my $WhatsnewTerm = 30;
# Tag
my %tags = (
ERROR => '',
);
# --- main ---
$| = 1;
# get configure
my $configure = &GetConfigure($config_file);
$MaxRow = $configure->{PAGE_LIMMIT} if $configure->{PAGE_LIMMIT};
$MaxSelection = $configure->{MAX_SELECTION} if $configure->{MAX_SELECTION};
$WhatsnewTerm = $configure->{WHATSNEW_DAY} if $configure->{WHATSNEW_DAY};
$template_file = $configure->{SYSTEM_TEMPLATE_SEARCH} if $configure->{SYSTEM_TEMPLATE_SEARCH};
$CSVFilePath = $configure->{SYSTEM_CSV_FILE_PATH} if $configure->{SYSTEM_CSV_FILE_PATH};
my $query_string;
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
$query_string = $ENV{'QUERY_STRING'};
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $query_string, $ENV{'CONTENT_LENGTH'});
} else {
&error("Request method is NOT 'GET' or 'POST'.");
}
if ($query_string) {
my @elements = split(/&/, $query_string);
my $element;
foreach ( keys %form_key ) {
&jcode::convert(\$form_key{$_}, 'euc') if ($form_key{$_});
}
foreach $element ( @elements ) {
my($idx, $buf) = split(/=/, $element);
$idx =~ tr/+/ /;
$idx =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("H2", $1)/eg;
&jcode::convert(\$idx, 'euc') if ($idx);
$buf =~ tr/+/ /;
$buf =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("H2", $1)/eg;
&jcode::convert(\$buf, 'euc') if ($buf);
foreach ( keys %form_key ) {
if ($idx eq $form_key{$_}) {
my $temp_val = $buf;
if ($temp_val) {
&jcode::tr(\$temp_val,
"\xa3\xb0-\xa3\xb9\x8e\xb0\xa1\xbc\xa1\xbd\xa1\xbe\xa1\xdd",
'0-9--------', '');
$temp_val =~ s/[^0-9A-Za-z_-]//g;
$form_value{$_} = $temp_val;
}
}
}
}
}
# get current time
my $currentUTC = time;
# page num
my $PageNum = 1;
$PageNum = $form_value{'page'} if ($form_value{'page'});
# get table data
my $TableData = &GetTableData($config_file);
my @tbl_query = ();
# search
my ($Results, $Results_num) = &searchData();
# show page
my $lists = {};
$lists->{CHAR_SET} = $html_charset;
$lists->{RESULT_NUM} = $Results_num;
$lists->{EXIST_RESULT} = ($Results_num > 0);
my $qidx = 0;
foreach $qidx ( 1 .. $MaxSelection ) {
$lists->{'QUERY' . $qidx} = $form_value{'query' . $qidx}
if ($form_value{'query' . $qidx});
# option
$tbl_query[$qidx] = &makeTable($TableData, 'TBL_Q' . $qidx);
my $tmp_html = '';
my $no_cond = '(No condition)';
$no_cond = $configure->{JP_OPT_NO_CONDITION} if $configure->{JP_OPT_NO_CONDITION};
$tmp_html .= "