#!/usr/bin/perl

########## Confixx(R) 3.0 Professional ############
####### Copyright SWsoft, Inc. 2004-2005 ##########
#### http://www.sw-soft.com - info@sw-soft.com ####


use File::Basename;

$wDir = dirname($0);
$subs_include_writeConfig = "$wDir/subs_include_writeConfig.pl";
unless (-f $subs_include_writeConfig){
  $wDir =~ s/\/[^\/]+$/\/subs/;
  $subs_include_writeConfig = "$wDir/subs_include_writeConfig.pl";
	unless ( -f $subs_include_writeConfig ) {
		if ( -d $installDir ) {
			$wDir = "$installDir/admin/subs";
  		$subs_include_writeConfig = "$wDir/subs_include_writeConfig.pl";
		}
	}
}
do $subs_include_writeConfig;
$subs_include_modules = "$wDir/subs_include_modules.pl";
do $subs_include_modules;
&ReadMainConfigFile;

$wDir =~ s/\/[^\/]+$//;

&loadConfFile;
&modulesCheck;


## Unterprogramme
sub loadConfFile{
  my ($file, $base);
  if(-T "/root/confixx/confixx_main.conf"){
    $file = "/root/confixx/confixx_main.conf";
  }
  else{

    $use_module_File_Basename = 1;
    $base = dirname($0);
    $file = "$base/../../confixx_main.conf";
    unless(-T $file){
      die("Couldn't find confixx_main.conf");
    }
  }
  do $file;
}


sub ltext {
  my $text_name = shift;
  if (!%lang_text) {
    my $langFile = "$installDir/admin/languages/$language/scripts.local";
    do $langFile;
  }
  if (!defined($lang_text{$text_name})) {
    return "Sorry, text $text_name not found!";
  }
  else {
    my @VAR = @_;
    my $text = $lang_text{$text_name};
    $text =~ s/\$VAR\[(\d+)\]/$VAR[$1]/g;
    if ($text) {
      return $text;
    }
    else {
      return "Sorry, localizing text $text_name failed!";
    }
  }
}
## /UNTERPROGRAMME
