#!/usr/bin/perl
use lib '../sys-perl/lib';
require '../sys-perl/require.pl';

our %http = (    # URLの設定
    'htdocs'            => '..',
    'ajax'              => '../ajax',
    'css'               => '../css_new',
    'js'                => '../js_new',
    'image-tochi'       => '../upload/tochi',
    'image-old_mansion' => '../upload/old_mansion',
    'image-old_home'    => '../upload/old_home',
    'image-new_home'    => '../upload/new_home',
    'image-com_index'   => '../upload/com_index',
    'image-com_info'    => '../upload/com_info',
);

#------------------
# 動作ｺﾏﾝﾄﾞ読み込み
#------------------
our %cmd;
hash_IO( \%cmd, "$dir{'script'}/web/company/cmd.ini", 'e' );
require "$dir{'script'}/web/lib.pl";

#---------------
# ﾃﾞｰﾀﾍﾞｰｽに接続
#---------------
connectDB();

#------------------
# ﾌｫｰﾑﾃﾞｰﾀ読み込み
#------------------
our %in;
Parse();

#---------------
# ｺﾏﾝﾄﾞ実行
#---------------
our %replace;
our $TMPL;

exe( $in{'c'} );

#------------------
# ﾃﾞｰﾀﾍﾞｰｽから切断
#------------------
disconnectDB();

#------------------
# HTMLの出力
#------------------
$replace{'css'}         = $http{'css'};
$replace{'js'}          = $http{'js'};
$replace{'domain_http'} = $domain{'http'};
$replace{'domain_ssl'}  = $domain{'ssl'};

use HTML::Template;

my $template = HTML::Template->new(
    loop_context_vars => 1,
    die_on_bad_params => 0,
    filename          => "$dir{'template'}/company/$TMPL",
);

for my $key ( keys %replace ) {
    $template->param( $key => $replace{$key} );
}

print "Content-Type: text/html\n\n";
print $template->output;
exit;
1;
