#!/usr/bin/perl5 -w
# 漢字コード EUC

use DB_File::Lock;
use SIC;
use SICX::Commander;
use SICX::Edit::Unit::login;

my $comm = SICX::Commander->new();

my $siteid = $comm->{cgi}->param('siteid');
unless($siteid){
    print $comm->{http}->header();
    print $comm->{html}->header();
    print "システムエラー";
    print $comm->{cgi}->end_html();
    exit;
}

my $dbm = join '/', '/home/SIC/sites',  $siteid, 'system/main.dbm';
my %maindbm = ();
if ( tie %maindbm, 'DB_File::Lock', $dbm, O_RDWR|O_CREAT, 0644, $DB_HASH, 'write' ){
    if ( ( $maindbm{'maintenance'} || 0) eq '1' ){
        print $comm->{http}->header();
        print $comm->{html}->header();
        print $maindbm{'maintenance_message'} || 'ただいま、システムのメンテナンス中です。';
        print $comm->{cgi}->end_html();
        exit;
    }
}

my $proc = SICX::Edit::Unit::login->new($comm);

unless ($proc->start()) {
    $comm->error();
}

$comm->finish();

exit(0);