#!/usr/bin/perl -w

# lastchanged 2008-05-13 fr

use strict;
#use warnings;
use lib qw(./lib /kunden/65911_09123/webseiten/tsg/b2b_new.tsg-group.de/cgi-bin/lib);
use CGI::Carp qw(fatalsToBrowser);

package main;

use DBI;
use Data::Dumper;
use CCS::Application;
use CCS::Config;
use CCS::FrontEndPhrases;
use CCS::BackEndPhrases;

# Mandant
$CCS::mid = 1;
#if ($ENV{SERVER_NAME} =~ /xxx/ ) {
#	$CCS::mid = 2;
#}
#elsif ($ENV{SERVER_NAME} =~ /yyy/ ) {
#	$CCS::mid = 3;
#}

eval qq(use CCS::Mandant$CCS::mid );
warn $@ if ($@);

my $dispatch = undef;
my $config = undef;
require 'conndb.pl';

###################################################################################

# load globals, dispatch, modul and modul config
$config = CCS::Config::getConfig('config',"id=$CCS::mid");

my $sth = $CCS::dbh->prepare("SELECT name,mid,dispatch,config FROM csmodulconf WHERE (mid=0 OR mid=$CCS::mid) AND status=1 ORDER BY prio");
$sth->execute() or die $DBI::errstr;
while ( my ($modul,$mand,$disp,$conf) = ($sth->fetchrow_array) ) {
    eval qq(use CCS::$modul; ) if $mand;
warn $@ if ($@);
    my $md = eval($disp);
warn $@ if ($@);
    $dispatch->{$_}=$md->{$_} foreach (keys %$md);
    $config->{$modul} = eval($conf) if $conf;
    $config->{installedModules}->{$modul} = 1;
}

our $app = CCS::Application->new(  config => $config, globals => CCS::Config::getConfig('globals',"id=$CCS::mid"), dispatch => $dispatch );

eval qq( CCS::Mandant${CCS::mid}::init(); );
warn $@ if ($@);

$app->run;


#####################################################
1;
__END__


to split autoload modules: (./lib)
autosplit_lib_modules(@modules);

