#!/usr/bin/perl -w
# Abills configuretion file

$PROGRAM='~AsmodeuS~ Billing System';

#DB configuration
$conf{dbhost}='localhost';
$conf{dbname}='abills';
$conf{dbuser}='abills';
$conf{dbpasswd}='sqlpassword';
$conf{dbtype}='mysql';
#For MySQL 5 and highter
#$conf{dbcharset}='cp1251';

#Mail configuration
$conf{ADMIN_MAIL}='admin@yourhost.com';
$conf{USERS_MAIL_DOMAIN}='yourhost.com';
$conf{MAIL_CHARSET}='windows-1251';
$conf{default_language}='english';
$conf{default_charset}='windows-1251';



@MODULES = ('Dv',
            'Voip',
            'Docs', 
            'Mail',
            'Sqlcmd');


%ACCT = ();
#For VoIP GNU Gatekeeper accounting
$ACCT{gnugk} = 'Voip_aaa';

%AUTH = ();
#For VoIP GNU Gatekeeper Auth
$AUTH{gnugk} = 'Voip_aaa';



#Technical works
#$conf{tech_works}='Technical works';

#Periodic functions
$conf{p_admin_mails}=1;  # Send periodic admin reports
$conf{p_users_mails}=1;  # Send user warning  messages

# chap encryption decription key
$conf{secretkey}="test12345678901234567890";
$conf{s_detalization}='yes'; #make session detalization recomended for vpn leathed lines
#Check periodic deposit and session. hangup after get negative result
$conf{periodic_check}='no';

$conf{version}='0.36b'; #16.06.2006

#Octets direction
# server - Count octets from server side
# user   - Count octets from user side (default)
$conf{octets_direction}='user';

#Check web interface brute force
$conf{wi_bruteforce}=10;

#Minimum session costs
$conf{MINIMUM_SESSION_TIME}=10; # minimum session time for push session to db
$conf{MINIMUM_SESSION_TRAF}=200; # minimum session trafic for push session to db

#System admin id
#ID for system operation, periodic procces
$conf{SYSTEM_ADMIN_ID}=1;

#Web interface
$conf{PASSWD_LENGTH}=6;
$conf{MAX_USERNAME_LENGTH}=15;
# User name expration
$conf{USERNAMEREGEXP}="^[a-z0-9_][a-z0-9_-]*\$";
$conf{list_max_recs}=25;
$conf{web_session_timeout} = 1800;
$conf{user_chg_passwd}='no';
#Max session traffic Mb
$conf{MAX_SESSION_TRAFFIC} = 2048; 


# Exppp options
$conf{DV_EXPPP_NETFILES}='/usr/local/abills/cgi-bin/admin/nets/';
#Auto assigning MAC in first connect
$conf{MAC_AUTO_ASSIGN}=1;
$conf{KBYTE_SIZE} = 1024;
# Check script rannig time
$conf{time_check}=1;

# Debug mod 
$conf{debug}=10;
$conf{foreground}=0;
$conf{debugmods}='LOG_ALERT LOG_WARNING LOG_ERR LOG_INFO';
#show auth and accounting time need Time::HiRes module (available from CPAN)
# Log levels
%log_levels = ('LOG_EMERG' => 0,
'LOG_ALERT' => 0,
'LOG_CRIT' => 0,
'LOG_ERR' => 1,
'LOG_WARNING' => 0, 
'LOG_NOTICE' => 0,
'LOG_INFO' => 1,
'LOG_DEBUG' => 7,
'LOG_SQL' => 6);


#Check password from radius or FTP servers for web interface
#Radius
#$conf{check_access} = { NAS_IP        => '192.168.101.17:1812',
#                        NAS_FRAMED_IP => '192.168.101.17',
#                        NAS_SECRET    => 'test'
#                       };
# FTP
#  $conf{check_access} = { NAS_IP      => '192.168.101.17:21'
#                         };

#Firewall start rule numbers
# (GLobal, Class 1, Class 2)
@START_FW = (3000, 2000, 1000);


# Backup SQL data
$conf{BACKUP_DIR}='/usr/local/abills/backup';


# Folders and files
$base_dir='/usr/local/abills/';
$lang_path=$base_dir . 'language/';
$lib_path=$base_dir .'libexec/';
$var_dir=$base_dir .'var/';
$conf{SPOOL_DIR}=$base_dir.'var/q';

# Template folder
$conf{TPL_DIR}   = $base_dir . 'Abills/templates/';
$conf{LOG_DEBUG} = $base_dir . 'var/log/abills.debug';
$conf{WEB_LOGFILE} = 'weblog.log';
$conf{LOGFILE}   = $base_dir . 'var/log/abills.log';
$conf{LOG_ACCT}  = $base_dir . 'var/log/acct.log';

#For file auth type allow file
$conf{extern_acct_dir}=$base_dir.'libexec/ext_acct/';

$conf{MAILBOX_PATH}='/var/mail/';
# Low bounds

use POSIX qw(strftime);
$DATE = strftime "%Y-%m-%d", localtime(time);

$TIME = strftime "%H:%M:%S", localtime(time);
$curtime = strftime("%F %H.%M.%S", localtime(time));
$year = strftime("%Y", localtime(time));











#*******************************************************************
# log_print ($level, $text)
# 
#*******************************************************************
sub log_print  {
 my ($level, $text) = @_;

 if ($conf{debugmods} =~ /$level/) {
   if (defined($conf{foreground}) && $conf{foreground} == 1) {
     print "$DATE $TIME $level: $text\n";
    }
   else {
     open(FILE, ">>$conf{LOGFILE}") || die "Can't open file '$conf{LOGFILE}' $!\n";
      print FILE "$DATE $TIME $level: $text\n";
     close(FILE);
    }
  }

#elsif($conf{debug} < $log_levels{$level}) {
#  print "level \n";
#  return 0;	
# }

#   write_log("$logfile", "$level", $text);


}
