[Astpp-commit] SF.net SVN: astpp: [2127] trunk
Brought to you by:
darrenkw
From: <dar...@us...> - 2007-09-19 01:37:31
|
Revision: 2127 http://astpp.svn.sourceforge.net/astpp/?rev=2127&view=rev Author: darrenkw Date: 2007-09-18 18:37:31 -0700 (Tue, 18 Sep 2007) Log Message: ----------- 1. Removed the old "enh-config" support as this is no longer needed. 2. Added support to refill regular accounts with a calling card. Modified Paths: -------------- trunk/Makefile trunk/astpp-admin.cgi trunk/astpp-ani-map.agi trunk/astpp-authorize.agi trunk/astpp-auto-admin.cgi trunk/astpp-callback-register.agi trunk/astpp-callback.agi trunk/astpp-callback.cgi trunk/astpp-callingcards-daily.pl trunk/astpp-callingcards.agi trunk/astpp-common.pl trunk/astpp-device-monitor.pl trunk/astpp-did-map.agi trunk/astpp-email-incoming.pl trunk/astpp-generate-invoices.pl trunk/astpp-ip-map.agi trunk/astpp-lcr.agi trunk/astpp-low-balance.pl trunk/astpp-manager-variables.agi trunk/astpp-pricelist.cgi trunk/astpp-rate-engine.pl trunk/astpp-refill.agi trunk/astpp-refill.cgi trunk/astpp-update-balance.pl trunk/astpp-users.cgi Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/Makefile 2007-09-19 01:37:31 UTC (rev 2127) @@ -42,9 +42,9 @@ install -m 644 -o $(OWNER) -g $(GROUP) style.css $(DESTDIR)$(WWWDIR)/html/_astpp/ install -m 644 -o $(OWNER) -g $(GROUP) menu.js $(DESTDIR)$(WWWDIR)/html/_astpp/ # Install Sample Configuration Files - install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.reseller-config.conf $(DESTDIR)$(ASTPPDIR)/sample.reseller-config.conf +# install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.reseller-config.conf $(DESTDIR)$(ASTPPDIR)/sample.reseller-config.conf install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-config.conf $(DESTDIR)$(ASTPPDIR)/sample.astpp-config.conf - install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-enh-config.conf $(DESTDIR)$(ASTPPDIR)/sample.astpp-enh-config.conf +# install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-enh-config.conf $(DESTDIR)$(ASTPPDIR)/sample.astpp-enh-config.conf install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-dialplan.conf $(DESTDIR)$(ASTERISKDIR)/sample.astpp-dialplan.conf install_samples: Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/astpp-admin.cgi 2007-09-19 01:37:31 UTC (rev 2127) @@ -58,7 +58,7 @@ print STDERR "Interface language is set to: " . $ENV{LANGUAGE} . "\n"; bindtextdomain( "astpp", "/usr/local/share/locale" ); textdomain("astpp"); -use vars qw(@output $astpp_db $params $enh_config +use vars qw(@output $astpp_db $params $config $status $config $limit $accountinfo $freepbx_db $rt_db $openser_db); my $starttime = [gettimeofday]; @@ -142,7 +142,7 @@ my @timezones = DateTime::TimeZone->all_names; @timezones = sort(@timezones); my ( - $rt_db, $astpp_db, $config, $enh_config, $params, + $rt_db, $astpp_db, $config, $config, $params, $param, $cdr_db, $agile_db, $body, $menu, $status, $msg, $loginstat, @modes, $openser_db ); @@ -185,7 +185,7 @@ $accountinfo = &get_account( $astpp_db, $params->{username} ); $params->{logintype} = $accountinfo->{type}; } - if ( !$params->{username} && $enh_config->{auth} eq $params->{password} ) { + if ( !$params->{username} && $config->{auth} eq $params->{password} ) { $status .= gettext("Successful Login!") . "<br>"; $count = 1; print header( -cookie => [ $cookie, $cookie1 ] ); @@ -205,7 +205,7 @@ if $config->{debug} == 1; print STDERR gettext("ASTPP-PASS:") . " $params->{password}\n" if $config->{debug} == 1; - print STDERR gettext("ASTPP-AUTHCODE:") . " $enh_config->{auth}\n" + print STDERR gettext("ASTPP-AUTHCODE:") . " $config->{auth}\n" if $config->{debug} == 1; print STDERR gettext("ASTPP-USER-COUNT:") . " $count" if $config->{debug} == 1; @@ -239,7 +239,7 @@ $params->{logintype} = $accountinfo->{type}; } } - if ( !$params->{username} && $enh_config->{auth} eq $params->{password} ) { + if ( !$params->{username} && $config->{auth} eq $params->{password} ) { $count = 1; $params->{logintype} = 2; } @@ -257,7 +257,7 @@ if $config->{debug} == 1 && $params->{username}; print STDERR gettext("ASTPP-PASS:") . " $params->{password}\n" if $config->{debug} == 1 && $params->{password}; - print STDERR gettext("ASTPP-AUTHCODE:") . " $enh_config->{auth}\n" + print STDERR gettext("ASTPP-AUTHCODE:") . " $config->{auth}\n" if $config->{debug} == 1; print STDERR gettext("ASTPP-USER-COUNT:") . " $count" if $config->{debug} == 1; @@ -651,7 +651,7 @@ sub build_reporting() { my ($body); return gettext("ASTPP Database Not Available!") . "<br>" unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Asterisk CDR Database Not Available!") . "<br>" unless $cdr_db; @@ -699,7 +699,7 @@ my ( $body, $id ); return gettext("Cannot display stats until database is configured") unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Cannot display stats until database is configured") unless $cdr_db; my ( undef, undef, undef, $day, $mnth, $yr ) = localtime(); @@ -919,11 +919,11 @@ ); return gettext("Cannot display stats until database is configured") unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Cannot display stats until database is configured") unless $cdr_db; if ( $params->{limit} < 1 || !$params->{limit} ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } my ( undef, undef, undef, $day, $mnth, $yr ) = localtime(); @@ -1341,7 +1341,7 @@ return gettext("Cannot view account until pricelists configured") unless @pricelists; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - $results_per_page = $enh_config->{results_per_page}; + $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( $params->{logintype} == 1 || $params->{logintype} == 5 @@ -1451,7 +1451,7 @@ $number = $params->{numberlist}; } $status .= - &remove_did( $astpp_db, $config, $enh_config, $params->{DID}, + &remove_did( $astpp_db, $config, $params->{DID}, $number ); $params->{action} = gettext("Information..."); } @@ -1463,7 +1463,7 @@ $number = $params->{numberlist}; } $status .= - &purchase_did( $astpp_db, $config, $enh_config, $params->{did_list}, + &purchase_did( $astpp_db, $config, $params->{did_list}, $number ); $params->{action} = gettext("Information..."); } @@ -2181,14 +2181,14 @@ } sub generatecallingcards() { - my ( $params, $config, $enh_config ) = @_; + my ( $params, $config ) = @_; my ( $status, $description, $pricelistdata, $number, $count ); $status = ""; $description = gettext("Account Setup"); $count = 0; if ( $config->{email} eq "YES" ) { - open( EMAIL, "| $enh_config->{mailprog} -t" ) - || die "Error - could not write to $enh_config->{mailprog}\n"; + open( EMAIL, "| $config->{mailprog} -t" ) + || die "Error - could not write to $config->{mailprog}\n"; print EMAIL"From: $config->{company_email}\n"; print EMAIL "Subject: $config->{company_name} New Account Created\n"; print EMAIL"To: $config->{emailadd}\n"; @@ -2200,7 +2200,7 @@ print STDERR "BRAND: $params->{brand}\n" if $config->{debug} == 1; while ( $count < $params->{count} ) { my ( $number, $pin ) = - &add_callingcard( $astpp_db, $config, $enh_config, $brandinfo, + &add_callingcard( $astpp_db, $config, $config, $brandinfo, $params->{status}, $params->{value} * 100, $params->{account}, $brandinfo->{pin} ); $count++; @@ -2218,26 +2218,26 @@ } sub generate_accounts() { - my ( $params, $config, $enh_config ) = @_; + my ( $params, $config ) = @_; my ( $status, $description, $pricelistdata, $cardlist ); $description = gettext("Account Setup"); $cardlist = &get_account_including_closed( $astpp_db, $params->{number} ); if ( !$cardlist->{number} ) { - &addaccount( $astpp_db, $config, $enh_config, $params ); + &addaccount( $astpp_db, $config, $params ); if ( $params->{accounttype} == 1 ) { &add_pricelist( $astpp_db, $params->{number}, 6, 0, $params->{number} ); - &add_reseller( $astpp_db, $config, $enh_config, $params->{number}, + &add_reseller( $astpp_db, $config, $params->{number}, $params->{posttoexternal} ); } if ( $params->{accounttype} == 5 ) { &add_pricelist( $astpp_db, $params->{number}, 6, 0, $params->{number} ); - &add_reseller( $astpp_db, $config, $enh_config, $params->{number}, + &add_reseller( $astpp_db, $config, $params->{number}, $params->{posttoexternal} ); } if ( $config->{email} == 1 && $params->{accounttype} == 0 ) { - &email_add_user( $astpp_db, '', $config, $params, $enh_config ); + &email_add_user( $astpp_db, '', $config, $params ); } my $timestamp = &prettytimestamp; $astpp_db->do( @@ -2283,7 +2283,7 @@ } if ( $config->{email} == 1 ) { &email_reactivate_account( $astpp_db, '', $config, $params, - $enh_config ); + ); } } else { @@ -2319,30 +2319,30 @@ $params->{count} = 1; $params->{pennies} = 0; $params->{number} = $params->{customnum}; - $status .= &generate_accounts( $params, $config, $enh_config ); + $status .= &generate_accounts( $params, $config ); my $accountinfo = &get_account( $astpp_db, $params->{number} ); ### Here we add support to add IAX and SIP devices at account creation. if ( $params->{SIP} ) { - $enh_config->{rt_sip_type} = $params->{devicetype}; + $config->{rt_sip_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniquesip_rt( $params->{number} ); $status .= &add_sip_user_rt( $rt_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; } - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { my $name = - &finduniquesip_freepbx( $freepbx_db, $config, $enh_config, + &finduniquesip_freepbx( $freepbx_db, $config, $params->{number} ); $status .= &add_sip_user_freepbx( $freepbx_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} @@ -2352,7 +2352,7 @@ if ( $config->{openser} == 1 ) { $status .= $status .= &add_sip_user_openser( $openser_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params ); @@ -2360,26 +2360,26 @@ } } if ( $params->{IAX2} ) { - $enh_config->{rt_iax_type} = $params->{devicetype}; + $config->{rt_iax_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { my $name = - &finduniqueiax_freepbx( $freepbx_db, $config, $enh_config, + &finduniqueiax_freepbx( $freepbx_db, $config, $params->{number} ); $status .= &add_iax_user_freepbx( $freepbx_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; } - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniqueiax_rt( $params->{number} ); $status .= &add_iax_user_rt( $rt_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} @@ -2455,7 +2455,7 @@ return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0; } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); } @@ -2953,7 +2953,7 @@ elsif ( $params->{status} eq gettext("DELETED") ) { $params->{status} = 2; } - $status .= &generatecallingcards( $params, $config, $enh_config ); + $status .= &generatecallingcards( $params, $config ); } $body = start_multipart_form; $body .= "<table class=\"default\">"; @@ -3289,7 +3289,7 @@ my $inactive = gettext("INACTIVE"); my $deleted = gettext("DELETED"); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; - $results_per_page = $enh_config->{results_per_page}; + $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } $body = "<table class=\"default\"><tr class=\"header\"><td>"; $body .= @@ -3879,11 +3879,11 @@ sub build_list_errors() { my ( $results, $body, $status, $count, $pageno, $pagesrequired ); $count = 0; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Cannot list errors until database is configured!") . "\n" unless $cdr_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } my $sql = $cdr_db->prepare( "SELECT * FROM cdr WHERE cost = 'error' OR " @@ -4698,7 +4698,7 @@ return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { @@ -5629,7 +5629,7 @@ my ( $sql, $record, $valid, $count, $tmp, $pagesrequired, $pageno ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -6018,7 +6018,7 @@ @providerlist ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -6838,7 +6838,7 @@ @providerlist ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -7486,7 +7486,7 @@ } return gettext("Pricelists Do NOT Exist!") . "\n" unless @pricelists; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { @@ -7987,7 +7987,7 @@ my $template = HTML::Template->new( filename => '/var/lib/astpp/templates/counters-list.tpl' ); - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" || $results_per_page < 2 ) { $results_per_page = 25; } @@ -8085,7 +8085,7 @@ my ( $sql, $record, $count, $tmp, $pageno, $pagesrequired ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -8377,7 +8377,7 @@ my @providerlist = &list_providers($astpp_db); return gettext("No Providers Exist!") . "\n" unless @providerlist; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { @@ -8733,7 +8733,7 @@ $count++; $body .= "<td>$trunkinfo->{name}" . "</td><td>$trunkinfo->{tech}"; if ( $trunkinfo->{tech} eq "SIP" - && $enh_config->{users_dids_rt} == 1 ) + && $config->{users_dids_rt} == 1 ) { $body .= "</td><td><a href=\"astpp-admin.cgi?mode=" @@ -8817,7 +8817,7 @@ my ( $sql, $record, $count, $tmp, $pageno, $pagesrequired ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -8830,7 +8830,7 @@ $params->{count} = 1; $params->{pennies} = 0; $params->{number} = $params->{customnum}; - $status .= &generate_accounts( $params, $config, $enh_config ); + $status .= &generate_accounts( $params, $config ); $params->{action} = gettext("Information..."); } if ( $params->{action} eq gettext("Information...") ) { @@ -8944,7 +8944,7 @@ @trunklist ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -9597,24 +9597,20 @@ sub initialize() { $config = &load_config(); $status .= gettext("Main Configuration Unavailable!") unless $config; - $enh_config = &load_config_enh(); - $status .= gettext("Enhanced Configuration Unavailable!") - unless $enh_config; - $astpp_db = &connect_db( $config, $enh_config, @output ); + $astpp_db = &connect_db( $config, @output ); $status .= gettext("ASTPP Database Unavailable!") unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); - $status .= gettext("Asterisk CDR Database Unavailable!") unless $cdr_db; $config = &load_config_db( $astpp_db, $config ) if $astpp_db; - $enh_config = &load_config_enh_db( $astpp_db, $enh_config ); + $cdr_db = &cdr_connect_db( $config, @output ); + $status .= gettext("Asterisk CDR Database Unavailable!") unless $cdr_db; if ( $config->{enablelcr} == 1 ) { push @modes, gettext("LCR"); } - if ( $enh_config->{users_dids_rt} == 1 ) { - $rt_db = &rt_connect_db( $config, $enh_config, @output ); + if ( $config->{users_dids_rt} == 1 ) { + $rt_db = &rt_connect_db( $config, @output ); push @modes, gettext("Switch Config"); } - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @modes = sort @modes; @@ -9630,7 +9626,7 @@ my ( $deviceinfo, $sql ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); } @@ -9642,17 +9638,17 @@ $number = param('numberlist'); } my $name = &finduniquesip_rt($number); - $enh_config->{rt_sip_type} = $params->{devicetype}; + $config->{rt_sip_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { $status .= - &add_sip_user_rt( $rt_db, $config, $enh_config, $name, + &add_sip_user_rt( $rt_db, $config, $name, $params->{secret}, $params->{context}, $number, $params ); $status .= "<br>"; } if ( $config->{openser} == 1 ) { $status .= - &add_sip_user_openser( $openser_db, $config, $enh_config, $name, + &add_sip_user_openser( $openser_db, $config, $name, $params->{secret}, $params->{context}, $number, $params ); $status .= "<br>"; } @@ -9661,7 +9657,7 @@ elsif ( $params->{action} eq gettext("Delete...") ) { if ( &del_sip_user_rt( - $rt_db, $config, $enh_config, $params->{devicename} + $rt_db, $config, $params->{devicename} ) ) { @@ -9678,7 +9674,7 @@ } elsif ( $params->{action} eq gettext("Save...") ) { my $tmp = - "UPDATE $enh_config->{rt_sip_table} SET" + "UPDATE $config->{rt_sip_table} SET" . " callerid=" . $rt_db->quote( $params->{clid} ) . ", " . " accountcode=" @@ -9703,7 +9699,7 @@ . " secret=" . $rt_db->quote( $params->{secret} ) . ", " . " type=" - . $rt_db->quote( $enh_config->{rt_sip_type} ) . ", " + . $rt_db->quote( $config->{rt_sip_type} ) . ", " . " name=" . $rt_db->quote( $params->{name} ) . ", " . " username=" @@ -9763,7 +9759,7 @@ . popup_menu( -name => "devicetype", -values => \@devicetypes, - -default => $enh_config->{rt_sip_type} + -default => $config->{rt_sip_type} ) . "</td><td>" . textfield( @@ -9782,7 +9778,7 @@ my @accountlist = &list_accounts($astpp_db); $sql = $rt_db->prepare( - "SELECT * FROM $enh_config->{rt_sip_table} WHERE name = " + "SELECT * FROM $config->{rt_sip_table} WHERE name = " . $rt_db->quote( $params->{devicename} ) ); $sql->execute || return gettext("Something is wrong with the SIP users database!") @@ -9982,7 +9978,7 @@ . gettext("Action") . "</td></tr> "; - my $tmp = "SELECT name FROM " . $enh_config->{rt_sip_table}; + my $tmp = "SELECT name FROM " . $config->{rt_sip_table}; $sql = $rt_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the SIP users database!") @@ -9994,7 +9990,7 @@ $sql->finish; $sql = $rt_db->prepare( -"SELECT * FROM $enh_config->{rt_sip_table} ORDER BY accountcode limit $params->{limit} , $results_per_page" +"SELECT * FROM $config->{rt_sip_table} ORDER BY accountcode limit $params->{limit} , $results_per_page" ); $sql->execute || return gettext("Something is wrong with the SIP users database!") @@ -10095,7 +10091,7 @@ print STDERR "SIPID: $sipid\n" if $config->{debug} == 1; $sql = $rt_db->prepare( - "SELECT COUNT(*) FROM $enh_config->{rt_sip_table} WHERE name = " + "SELECT COUNT(*) FROM $config->{rt_sip_table} WHERE name = " . $rt_db->quote($sipid) ); $sql->execute; $record = $sql->fetchrow_hashref; @@ -10113,7 +10109,7 @@ my ( $deviceinfo, $sql ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); } @@ -10125,17 +10121,17 @@ $number = param('numberlist'); } my $name = &finduniqueiax_rt($number); - $enh_config->{rt_iax_type} = $params->{devicetype}; + $config->{rt_iax_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; $status .= - &add_iax_user_rt( $rt_db, $config, $enh_config, $name, + &add_iax_user_rt( $rt_db, $config, $name, $params->{secret}, $params->{context}, $number, $params ); $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Delete...") ) { if ( &del_sip_user_rt( - $rt_db, $config, $enh_config, $params->{devicename} + $rt_db, $config, $params->{devicename} ) ) { @@ -10149,7 +10145,7 @@ } elsif ( $params->{action} eq gettext("Save...") ) { my $tmp = - "UPDATE $enh_config->{rt_iax_table} SET" + "UPDATE $config->{rt_iax_table} SET" . " callerid=" . $rt_db->quote( $params->{clid} ) . ", " . " accountcode=" @@ -10228,7 +10224,7 @@ . popup_menu( -name => "devicetype", -values => \@devicetypes, - -default => $enh_config->{rt_iax_type} + -default => $config->{rt_iax_type} ) . "</td><td>" . textfield( @@ -10247,7 +10243,7 @@ my @accountlist = &list_accounts($astpp_db); $sql = $rt_db->prepare( - "SELECT * FROM $enh_config->{rt_iax_table} WHERE name = " + "SELECT * FROM $config->{rt_iax_table} WHERE name = " . $rt_db->quote( $params->{devicename} ) ); $sql->execute || return gettext("Something is wrong with the IAX users database!") @@ -10413,7 +10409,7 @@ . gettext("Action") . "</td></tr> "; - my $tmp = "SELECT name FROM " . $enh_config->{rt_iax_table}; + my $tmp = "SELECT name FROM " . $config->{rt_iax_table}; $sql = $rt_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the IAX users database!") @@ -10425,7 +10421,7 @@ $sql->finish; $sql = $rt_db->prepare( -"SELECT * FROM $enh_config->{rt_iax_table} ORDER BY accountcode limit $params->{limit} , $results_per_page" +"SELECT * FROM $config->{rt_iax_table} ORDER BY accountcode limit $params->{limit} , $results_per_page" ); $sql->execute || return gettext("Something is wrong with the IAX users database!") @@ -10523,7 +10519,7 @@ print STDERR "IAXID: $iaxid\n" if $config->{debug} == 1; $sql = $rt_db->prepare( - "SELECT COUNT(*) FROM $enh_config->{rt_iax_table} WHERE name = " + "SELECT COUNT(*) FROM $config->{rt_iax_table} WHERE name = " . $rt_db->quote($iaxid) ); $sql->execute; $record = $sql->fetchrow_hashref; @@ -10541,13 +10537,13 @@ ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - $results_per_page = $enh_config->{results_per_page}; + $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); } if ( $params->{action} eq gettext("Insert...") ) { my $tmp = - "INSERT INTO $enh_config->{rt_extensions_table} (context," + "INSERT INTO $config->{rt_extensions_table} (context," . "exten,priority,app,appdata) VALUES (" . $rt_db->quote( $params->{context} ) . ", " . $rt_db->quote( $params->{exten} ) . ", " @@ -10568,7 +10564,7 @@ } elsif ( $params->{action} eq gettext("Delete...") ) { my $tmp = - "DELETE FROM $enh_config->{rt_extensions_table} WHERE " . "id = " + "DELETE FROM $config->{rt_extensions_table} WHERE " . "id = " . $rt_db->quote( $params->{id} ); if ( $rt_db->do($tmp) ) { $status .= @@ -10581,7 +10577,7 @@ } elsif ( $params->{action} eq gettext("Save...") ) { my $tmp = - "UPDATE $enh_config->{rt_extensions_table} SET" + "UPDATE $config->{rt_extensions_table} SET" . " context=" . $rt_db->quote( $params->{context} ) . ", " . " exten=" @@ -10657,7 +10653,7 @@ elsif ( $params->{action} eq gettext("Edit...") ) { $sql = $rt_db->prepare( - "SELECT * FROM $enh_config->{rt_extensions_table} WHERE id = " + "SELECT * FROM $config->{rt_extensions_table} WHERE id = " . $rt_db->quote( $params->{id} ) ); $sql->execute || return gettext("Something is wrong with the dialplan database!") @@ -10749,7 +10745,7 @@ . gettext("Action") . "</td></tr> "; - my $tmp = "SELECT id FROM " . $enh_config->{rt_extensions_table}; + my $tmp = "SELECT id FROM " . $config->{rt_extensions_table}; $sql = $rt_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the SIP users database!") @@ -10761,7 +10757,7 @@ $sql->finish; $sql = $rt_db->prepare( -"SELECT * FROM $enh_config->{rt_extensions_table} ORDER BY context, exten, priority " +"SELECT * FROM $config->{rt_extensions_table} ORDER BY context, exten, priority " . "limit $params->{limit} , $results_per_page" ); $sql->execute || return gettext("Something is wrong with the dialplan database!") @@ -10852,7 +10848,7 @@ } $params->{accounttype} = 5; $params->{number} = $params->{callshop_name}; - $status .= &generate_accounts( $params, $config, $enh_config ); + $status .= &generate_accounts( $params, $config ); my $callshop_data = $astpp_db->do( "SELECT * FROM callshops WHERE name = " . $astpp_db->quote( $params->{callshop_name} ) ); @@ -10983,33 +10979,33 @@ $status .= gettext("No Reseller Name Set! Error!"); } elsif ( $params->{action} eq gettext("Generate Booth") ) { - $status .= &generate_accounts( $params, $config, $enh_config ); + $status .= &generate_accounts( $params, $config ); my $accountinfo = &get_account( $astpp_db, $params->{number} ); $astpp_db->do( "UPDATE cdrs SET status = 1 WHERE cardnum = " . $astpp_db->quote( $params->{number} ) . " LIMIT 1" ); if ( $params->{SIP} ) { print STDERR gettext("Adding SIP Device!") if $config->{debug} == 1; - $enh_config->{rt_sip_type} = "friend"; #$params->{devicetype}; + $config->{rt_sip_type} = "friend"; #$params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniquesip_rt( $params->{number} ); $status .= &add_sip_user_rt( $rt_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; } - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { my $name = - &finduniquesip_freepbx( $freepbx_db, $config, $enh_config, + &finduniquesip_freepbx( $freepbx_db, $config, $params->{number} ); &add_sip_user_freepbx( $freepbx_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} @@ -11019,7 +11015,7 @@ if ( $config->{openser} == 1 ) { $status .= &add_sip_user_openser( $openser_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params ); @@ -11029,26 +11025,26 @@ if ( $params->{IAX2} ) { print STDERR gettext("Adding IAX2 Device!") if $config->{debug} == 1; - $enh_config->{rt_iax_type} = "friend"; #$params->{devicetype}; + $config->{rt_iax_type} = "friend"; #$params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { my $name = - &finduniqueiax_freepbx( $freepbx_db, $config, $enh_config, + &finduniqueiax_freepbx( $freepbx_db, $config, $config, $params->{number} ); $status .= &add_iax_user_freepbx( $freepbx_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; } - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniqueiax_rt( $params->{number} ); $status .= &add_iax_user_rt( $rt_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} @@ -11166,49 +11162,49 @@ #If this account doesn't exist we don't go through the rest if ( $accountinfo->{number} ) { - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { print STDERR "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}" if $config->{debug} == 1; my @iax_devicelist = - &list_iax_account_rt( $rt_db, $config, $enh_config, + &list_iax_account_rt( $rt_db, $config, $accountinfo->{number}, $accountinfo->{cc} ); foreach my $name (@iax_devicelist) { - &del_iax_user_rt( $rt_db, $config, $enh_config, $name ); + &del_iax_user_rt( $rt_db, $config, $name ); $status .= gettext("Removing IAX device:") . " " . $name . "<br>"; } my @sip_devicelist = - &list_sip_account_rt( $rt_db, $config, $enh_config, + &list_sip_account_rt( $rt_db, $config, $accountinfo->{number}, $accountinfo->{cc} ); foreach my $name (@sip_devicelist) { - &del_sip_user_rt( $rt_db, $config, $enh_config, $name ); + &del_sip_user_rt( $rt_db, $config, $name ); $status .= gettext("Removing SIP device:") . " " . $name . "<br>"; } } - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { print STDERR "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}" if $config->{debug} == 1; my @iax_devicelist = - &list_iax_account_amp( $freepbx_db, $config, $enh_config, + &list_iax_account_amp( $freepbx_db, $config, $accountinfo->{number}, $accountinfo->{cc} ); foreach my $name (@iax_devicelist) { - &del_iax_user_rt( $freepbx_db, $config, $enh_config, + &del_iax_user_rt( $freepbx_db, $config, $name ); $status .= gettext("Removing IAX device:") . " " . $name . "<br>"; } my @sip_devicelist = - &list_sip_account_amp( $freepbx_db, $config, $enh_config, + &list_sip_account_amp( $freepbx_db, $config, $accountinfo->{number}, $accountinfo->{cc} ); foreach my $name (@sip_devicelist) { - &del_sip_user_rt( $freepbx_db, $config, $enh_config, + &del_sip_user_rt( $freepbx_db, $config, $name ); $status .= gettext("Removing SIP device:") . " " . $name . "<br>"; @@ -11259,10 +11255,10 @@ $row{call_count} = $record->{"COUNT(*)"}; $row{currency} = $boothinfo->{currency}; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $tmp = "SELECT name FROM " - . $enh_config->{rt_sip_table} + . $config->{rt_sip_table} . " WHERE accountcode = " . $rt_db->quote( $boothinfo->{cc} ) . " LIMIT 1"; @@ -11273,7 +11269,7 @@ $sql->finish; $tmp = "SELECT name FROM " - . $enh_config->{rt_iax_table} + . $config->{rt_iax_table} . " WHERE accountcode = " . $rt_db->quote( $boothinfo->{cc} ) . " LIMIT 1"; @@ -11408,19 +11404,19 @@ my $accountinfo = &get_account( $astpp_db, $params->{booth_name} ); my ( $invoiceno, $callshop_data ); $callshop_data = &get_callshop( $astpp_db, $accountinfo->{reseller} ); - $enh_config->{osc_db} = $callshop_data->{osc_dbname}; - $enh_config->{osc_user} = $callshop_data->{osc_dbuser}; - $enh_config->{osc_host} = $callshop_data->{osc_dbhost}; - $enh_config->{osc_pass} = $callshop_data->{osc_dbpass}; + $config->{osc_db} = $callshop_data->{osc_dbname}; + $config->{osc_user} = $callshop_data->{osc_dbuser}; + $config->{osc_host} = $callshop_data->{osc_dbhost}; + $config->{osc_pass} = $callshop_data->{osc_dbpass}; $params->{action} = gettext("View Booths"); - if ( $enh_config->{externalbill} eq "oscommerce" ) { + if ( $config->{externalbill} eq "oscommerce" ) { if ( $accountinfo->{posttoexternal} == 1 ) { print STDERR gettext("Connecting to OSCommerce."); - my $osc_db = &osc_connect_db( $config, $enh_config ); + my $osc_db = &osc_connect_db( $config ); print STDERR gettext("Generating Invoice"); $invoiceno = - &osc_charges( $astpp_db, $osc_db, $config, $enh_config, + &osc_charges( $astpp_db, $osc_db, $config, $params->{booth_name} ); } } @@ -11454,10 +11450,10 @@ } if ( $params->{action} eq gettext("View Booth") ) { my $accountinfo = &get_account( $astpp_db, $params->{booth_name} ); - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $tmp = "SELECT name,secret FROM " - . $enh_config->{rt_sip_table} + . $config->{rt_sip_table} . " WHERE accountcode = " . $rt_db->quote( $accountinfo->{cc} ) . " LIMIT 1"; @@ -11468,7 +11464,7 @@ $sql->finish; $tmp = "SELECT name,secret FROM " - . $enh_config->{rt_iax_table} + . $config->{rt_iax_table} . " WHERE accountcode = " . $rt_db->quote( $accountinfo->{cc} ) . " LIMIT 1"; @@ -11480,7 +11476,7 @@ } my @chargelist = &list_cdrs_account( $cdr_db, $accountinfo->{number}, $accountinfo->{cc} ); - &processlist( $astpp_db, $cdr_db, $enh_config, $config, @chargelist ) + &processlist( $astpp_db, $cdr_db, $config, @chargelist ) ; # Bill as many calls as we can. $status .= gettext("We rated as many CDRS as we could") . "<br>"; $tmp = @@ -11581,13 +11577,10 @@ # reload databases other than the astpp one. $config = &load_config_reseller_db( $astpp_db, $config, $params->{username} ); - $enh_config = - &load_config_reseller_db( $astpp_db, $enh_config, - $params->{username} ); - $freepbx_db = &freepbx_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_amp} == 1; - $rt_db = &rt_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_rt} == 1; + $freepbx_db = &freepbx_connect_db( $config, @output ) + if $config->{users_dids_amp} == 1; + $rt_db = &rt_connect_db( $config, @output ) + if $config->{users_dids_rt} == 1; print STDERR "ASTPP RESELLER LOGIN\n" if $config->{debug} == 1; @modes = ( gettext("Accounts"), gettext("Rates"), @@ -11605,7 +11598,7 @@ ); my @DIDs = ( gettext("Manage DIDs") ); - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @modes = sort @modes; @@ -11625,10 +11618,10 @@ if ( $config->{enablelcr} == 1 ) { push @modes, gettext("LCR"); } - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { push @modes, gettext("Switch Config"); } - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @@ -11660,7 +11653,7 @@ gettext("Accounts"), gettext("DIDs"), gettext("Statistics"), gettext("Home") ); - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @modes = sort @modes; @@ -11676,21 +11669,18 @@ elsif ( $params->{logintype} == 5 ) { # CallShop Login $config = &load_config_reseller_db( $astpp_db, $config, $params->{username} ); - $enh_config = - &load_config_reseller_db( $astpp_db, $enh_config, - $params->{username} ); - $freepbx_db = &freepbx_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_amp} == 1; - $rt_db = &rt_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_rt} == 1; - $osc_db = &osc_connect_db( $config, $enh_config, @output ) - if $enh_config->{externalbill} eq "oscommerce"; + $freepbx_db = &freepbx_connect_db( $config, @output ) + if $config->{users_dids_amp} == 1; + $rt_db = &rt_connect_db( $config, @output ) + if $config->{users_dids_rt} == 1; + $osc_db = &osc_connect_db( $config, $config, @output ) + if $config->{externalbill} eq "oscommerce"; print STDERR "ASTPP CALLSHOP LOGIN\n" if $config->{debug} == 1; @modes = ( gettext("Booths"), gettext("Home"), gettext("Routes"), gettext("Pricelists") ); - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @modes = sort @modes; @@ -11710,7 +11700,7 @@ $body = &build_body( $params->{mode} ); $menu = &build_menu_ts( @modes, $params->{mode} ); $menu .= start_form; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { $status .= gettext("Realtime Database Unavailable!") unless $rt_db; } } Modified: trunk/astpp-ani-map.agi =================================================================== --- trunk/astpp-ani-map.agi 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/astpp-ani-map.agi 2007-09-19 01:37:31 UTC (rev 2127) @@ -19,7 +19,7 @@ use POSIX qw(ceil floor); use POSIX qw(strftime); use strict; -use vars qw(@output $verbose $SIG $astpp_db $config $enh_config $AGI); +use vars qw(@output $verbose $SIG $astpp_db $config $AGI); @output = ( "STDERR", "LOGFILE" ); $verbose = 2; require "/usr/local/astpp/astpp-common.pl"; @@ -28,10 +28,8 @@ sub initialize() { $SIG{HUP} = 'ignore_hup'; $config = &load_config(); - $enh_config = &load_config_enh(); - $astpp_db = &connect_db( $config, $enh_config, @output ); + $astpp_db = &connect_db( $config, @output ); $config = &load_config_db($astpp_db,$config); - $enh_config = &load_config_enh_db($astpp_db,$enh_config); } sub ignore_hup { Modified: trunk/astpp-authorize.agi =================================================================== --- trunk/astpp-authorize.agi 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/astpp-authorize.agi 2007-09-19 01:37:31 UTC (rev 2127) @@ -79,7 +79,7 @@ use DBI; use Asterisk::AGI; use strict; -use vars qw(@output $config $enh_config $astpp_db $verbosity $AGI); +use vars qw(@output $config $astpp_db $verbosity $AGI); use Locale::gettext_pp qw(:locale_h); require "/usr/local/astpp/astpp-common.pl"; $ENV{LANGUAGE} = "en"; # de, es, br - whatever @@ -96,10 +96,8 @@ $AGI->set_variable( 'ASTPP', '1' ); $AGI->verbose( "$accountcode, $phoneno", $verbosity ); $config = &load_config(); -$enh_config = &load_config_enh(); -$astpp_db = &connect_db( $config, $enh_config, @output ); +$astpp_db = &connect_db( $config, @output ); $config = &load_config_db($astpp_db,$config); -$enh_config = &load_config_enh_db($astpp_db,$enh_config); my $carddata = &get_account( $astpp_db, $accountcode ); # Fetch all the account info from the db. if ( !$carddata->{number} ) { # Check to see if the account exists. If not then exit. @@ -124,7 +122,7 @@ } print STDERR "\nFINDING LIMIT FOR: $carddata->{number}\n" if $config->{debug} == 1; -($callstatus, $maxlength) = &max_length($astpp_db, $config, $enh_config, $carddata, $phoneno); +($callstatus, $maxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); print STDERR "Minimum Charge on call = $routeinfo->{cost}" if $config->{debug} == 1; my $minimumcharge = $routeinfo->{cost}; @@ -135,7 +133,7 @@ $carddata = &get_account( $astpp_db, $carddata->{reseller} ); push @reseller_list, $carddata->{number}; print STDERR "ADDING $carddata->{number} to the list of resellers for this account\n" if $config->{debug} == 1; - my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $enh_config, $carddata, $phoneno); + my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); if ($resellercallstatus != 1) { $carddata->{reseller} = ""; Modified: trunk/astpp-auto-admin.cgi =================================================================== --- trunk/astpp-auto-admin.cgi 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/astpp-auto-admin.cgi 2007-09-19 01:37:31 UTC (rev 2127) @@ -105,7 +105,7 @@ use Asterisk::Manager; use lib './lib', '../lib'; use strict; -use vars qw($enh_config $config $astpp_db $agile_db $params @output +use vars qw($config $astpp_db $agile_db $params @output $rt_db $freepbx_db $status); require "/usr/local/astpp/astpp-common.pl"; $ENV{LANGUAGE} = "en"; # de, es, br - whatever @@ -161,8 +161,8 @@ $params->{sweep} = $sweep; $params->{credit_limit} = $creditlimit; $params->{password} = $password; - &addaccount( $astpp_db, $config, $enh_config, $params ); - &email_add_user($astpp_db,'', $config, $params, $enh_config); + &addaccount( $astpp_db, $config, $params ); + &email_add_user($astpp_db,'', $config, $params); } else { $astpp_db->do( "UPDATE accounts SET status = 1 WHERE number = " @@ -171,7 +171,7 @@ . $astpp_db->quote($customnum) . " WHERE number = " . $astpp_db->quote($customnum) ); - &email_refill_account($astpp_db,'', $config, $params, $enh_config); + &email_refill_account($astpp_db,'', $config, $params); } my $timestamp = &prettytimestamp; $astpp_db->do( @@ -188,16 +188,13 @@ sub initialize() { my ($reseller) = @_; $config = &load_config; - $enh_config = &load_config_enh; - $astpp_db = &connect_db( $config, $enh_config, @output ); + $astpp_db = &connect_db( $config, @output ); $config = &load_config_db($astpp_db,$config); - $enh_config = &load_config_enh_db($astpp_db,$enh_config); $config = &load_config_reseller_db($astpp_db,$config,$params->{username}) if ($reseller); - $enh_config = $config if ($reseller); - $freepbx_db = &freepbx_connect_db($config, $enh_config, @output) - if $enh_config->{users_dids_amp} == 1; - $rt_db = &rt_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_rt} == 1; + $freepbx_db = &freepbx_connect_db($config, @output) + if $config->{users_dids_amp} == 1; + $rt_db = &rt_connect_db( $config, @output ) + if $config->{users_dids_rt} == 1; } ############## Asterisk Manager Handling ############ sub astmanager_reload() { @@ -239,7 +236,7 @@ $params->{quantity} = 1; } if ( $params->{prepend} ne "" ) { - $enh_config->{service_prepend} = $params->{prepend}; + $config->{service_prepend} = $params->{prepend}; } if ( $params->{brand} ne "" ) { $config->{default_brand} = $params->{brand}; @@ -254,7 +251,7 @@ $params->{language} = $config->{language}; } # OSCommerce specific adjustments -if ($enh_config->{externalbill} eq "oscommerce") { +if ($config->{externalbill} eq "oscommerce") { $params->{service} = $params->{invoice}; $params->{email} = $params->{emailadd}; } @@ -270,14 +267,14 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); } -if ( $enh_config->{service_prepend} eq "" ) { +if ( $config->{service_prepend} eq "" ) { my $passedlength = length( $params->{service} ); - my $requiredchars = $enh_config->{service_length} - $passedlength; - my $prepend = substr( $enh_config->{service_filler}, 0, $requiredchars ); + my $requiredchars = $config->{service_length} - $passedlength; + my $prepend = substr( $config->{service_filler}, 0, $requiredchars ); $params->{extension} = $prepend . $params->{service}; } else { - $params->{extension} = $enh_config->{service_prepend} . $params->{service}; + $params->{extension} = $config->{service_prepend} . $params->{service}; } # We use a random number 5 digis long for a password @@ -296,7 +293,7 @@ $config->{default_context} = $config_reseller->{default_context}; $config->{default_brand} = $config_reseller->{new_user_brand}; $params->{user} = $config_reseller->{account_prepend} . $params->{user}; - $enh_config->{auth} = $config_reseller->{auth}; + $config->{auth} = $config_reseller->{auth}; $config->{company_email} = $config_reseller->{company_name}; $config->{company_name} = $config_reseller->{company_name}; $config->{company_website} = $config_reseller->{company_website}; @@ -312,7 +309,7 @@ } ########## Check for the correct Auth Code########### -if ( $params->{auth} ne $enh_config->{auth} ) { +if ( $params->{auth} ne $config->{auth} ) { print STDERR gettext("INVALID AUTH KEY"); print "/n" . gettext("Received Authkey:") . "'" . $params->{auth} . "'"; exit(0); @@ -325,81 +322,82 @@ if ( $params->{function} eq "add_device" ) { while ( $count < $params->{quantity} ) { $count++; - if ($enh_config->{users_dids_rt} == 1) { - &add_sip_user_rt( $rt_db, $config, $enh_config, $params->{extension}, + if ($config->{users_dids_rt} == 1) { + &add_sip_user_rt( $rt_db, $config, $params->{extension}, $params->{secret}, $config->{default_context}, $params->{user}, $params ) if $params->{type} eq "SIP"; - &add_iax_user_rt( $rt_db, $config, $enh_config, + &add_iax_user_rt( $rt_db, $config, $params->{extension}, $params->{secret}, $config->{default_context}, $params->{user} ) if $params->{type} eq "IAX"; - } elsif ($enh_config->{users_dids_amp} == 1) { - &add_sip_user_freepbx( $freepbx_db, $config, $enh_config, $params->{extension}, + } elsif ($config->{users_dids_amp} == 1) { + &add_sip_user_freepbx( $freepbx_db, $config, $params->{extension}, $params->{secret}, $config->{default_context}, $params->{user}, $params ) if $params->{type} eq "SIP"; - &add_iax_user_freepbx($freepbx_db, $config, $enh_config, + &add_iax_user_freepbx($freepbx_db, $config, $params->{extension}, $params->{secret}, $config->{default_context}, $params->{user} ) if $params->{type} eq "IAX"; } - &email_add_user($astpp_db, '', $config, $params, $enh_config, $params->{type}, + &email_add_user($astpp_db, '', $config, $params, $params->{type}, $params->{secret}, $params->{extension} ) if $config->{user_email} == 1; } } elsif ( $params->{function} eq "unsuspend" ) { - if ($enh_config->{users_dids_rt} == 1) { - &update_context_sip_user_rt( $rt_db, $enh_config, $params->{extension}, + if ($config->{users_dids_rt} == 1) { + &update_context_sip_user_rt( $rt_db, $config, $params->{extension}, +i $config->{default_context} ) if $params->{type} eq "SIP"; - &update_context_iax_user_rt( $rt_db, $enh_config, $params->{extension}, + &update_context_iax_user_rt( $rt_db, $config, $params->{extension}, $config->{default_context} ) if $params->{type} eq "IAX"; - } elsif ($enh_config->{users_dids_amp} == 1) { - &update_context_sip_user_freepbx( $freepbx_db, $enh_config, $params->{extension}, + } elsif ($config->{users_dids_amp} == 1) { + &update_context_sip_user_freepbx( $freepbx_db, $config, $params->{extension}, $config->{default_context} ) if $params->{type} eq "SIP"; - &update_context_iax_user_freepbx( $freepbx_db, $enh_config, $params->{extension}, + &update_context_iax_user_freepbx( $freepbx_db, $config, $params->{extension}, $config->{default_context} ) if $params->{type} eq "IAX"; } } elsif ( $params->{function} eq "delete" ) { - if ($enh_config->{users_dids_rt} == 1) { - &del_sip_user_rt( $rt_db, $enh_config, $params->{extension} ) + if ($config->{users_dids_rt} == 1) { + &del_sip_user_rt( $rt_db, $config, $params->{extension} ) if $params->{type} eq "SIP"; - &del_iax_user_rt( $rt_db, $enh_config, $params->{extension} ) + &del_iax_user_rt( $rt_db, $config, $params->{extension} ) if $params->{type} eq "IAX"; - } elsif ($enh_config->{users_dids_amp} == 1) { - &del_sip_user_freepbx( $freepbx_db, $enh_config, $params->{extension} ) + } elsif ($config->{users_dids_amp} == 1) { + &del_sip_user_freepbx( $freepbx_db, $config, $params->{extension} ) if $params->{type} eq "SIP"; - &del_iax_user_freepbx( $freepbx_db, $enh_config, $params->{extension} ) + &del_iax_user_freepbx( $freepbx_db, $config, $params->{extension} ) if $params->{type} eq "IAX"; } - &email_del_user($astpp_db, '', $config, $params, $enh_config ) + &email_del_user($astpp_db, '', $config, $params ) if $config->{user_email} == 1; } elsif ( $params->{function} eq "suspend" ) { - if ($enh_config->{users_dids_rt} == 1) { - &update_context_sip_user_rt( $rt_db, $config, $enh_config, + if ($config->{users_dids_rt} == 1) { + &update_context_sip_user_rt( $rt_db, $config, $params->{extension}, "suspended" ) if $params->{type} eq "SIP"; - &update_context_iax_user_rt( $rt_db, $config, $enh_config, + &update_context_iax_user_rt( $rt_db, $config, $params->{extension}, "suspended" ) if $params->{type} eq "IAX"; - } elsif ($enh_config->{users_dids_amp} == 1) { - &update_context_sip_user_freepbx( $freepbx_db, $config, $enh_config, + } elsif ($config->{users_dids_amp} == 1) { + &update_context_sip_user_freepbx( $freepbx_db, $config, $params->{extension}, "suspended" ) if $params->{type} eq "SIP"; - &update_context_iax_user_freepbx( $freepbx_db, $config, $enh_config, + &update_context_iax_user_freepbx( $freepbx_db, $config, $params->{extension}, "suspended" ) if $params->{type} eq "IAX"; } - &email_del_user($astpp_db, '', $config, $params, $enh... [truncated message content] |