⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialoutbound.agi

📁 Astercon2 开源软交换 2.2.0
💻 AGI
字号:
#!/astercon2/perl/bin/perl# scperl /astercon2/perl (project info don't remove or modify)#!/usr/bin/perl#--------------------------------------------------------------##	Astercon -- An open source softswitch and ippbx system.##	Copyright (C) 2005 - 2008, Sun bing.##	Sun bing <hoowa.sun@gmail.com>##	See http://astercon.0420.com for more information about#	the Astercon project.##   license#   The astercon project is licensed under the GNU 2.0 GPL. #   astercon carries no restrictions on re-branding and #   people are free to commercially re-distribute it.##   any questions?#   Please do not directly contact any of the maintainers of#   this project for assistance;#	the project provides a web site, bugs tracker,really chat.##--------------------------------------------------------------# ------------------------------------------------------------------------------# HEADER OF SCRIPTS# ------------------------------------------------------------------------------use FindBin qw($Bin);use strict "vars";use astercon::common;use astercon::database;use Asterisk::AGI;$|=1;#------------------------------------------------------------------------------# INIT SECTION#------------------------------------------------------------------------------# AUTO FLASH$|=1;# GET OUT COMMONmy	$common = new astercon::common;my	($astcon_conf) = $common->{rc}->load_config(filename=>'/astercon2/etc/astcon.conf');# GET DATABASE SUPPORTmy	$astodm = new astercon::database(				dbuser=>$astcon_conf->{'general'}{'dbuser'}[0],dbpasswd=>$astcon_conf->{'general'}{'dbpasswd'}[0],				dbhost=>$astcon_conf->{'general'}{'dbhost'}[0],dbname=>$astcon_conf->{'general'}{'dbname'}[0],				dbport=>$astcon_conf->{'general'}{'dbport'}[0],dbsock=>$astcon_conf->{'general'}{'dbsock'}[0],				conn=>1			);# GET AGI OBJECTmy	$AGI = new Asterisk::AGI;my	%input = $AGI->ReadParse();# IF RUN IN MACRO GIVE ARGV[0]$input{extension} = $ARGV[0] if ($input{extension} eq 's' && $ARGV[0] ne '');#------------------------------BASIC CHECKING# BILLING PREFIX MATCHEDmy	($prefix_matched,$caller_matched,$callee_matched);#foreach  (split(/\,/,$astcon_conf->{'billing'}{'outbound_billing_prefix'}[0])) {#	chomp($_);#	if ($input{extension} =~ /^$_/){		$prefix_matched++;		last;;	}#}#&todie('5') if (!$prefix_matched);# CALLER DISABLED MATCHEDforeach  (split(/\,/,$astcon_conf->{'billing'}{'outbound_disabled_caller'}[0])) {	chomp($_);	if ($input{callerid} =~ /^$_/){		$caller_matched++;		last;;	}}&todie('3') if ($caller_matched);# CALLEE DISABLED MATCHEDforeach  (split(/\,/,$astcon_conf->{'billing'}{'outbound_disabled_callee'}[0])) {	chomp($_);	if ($input{extension} =~ /^$_/){		$callee_matched++;		last;;	}}&todie('3') if ($callee_matched);#------------------------------ACCOUNT CHECKING# CHECK ACCOUNTCODE EXISTSmy	($exists_account,$accountref) = $astodm->exten_exists_accountcode($input{'accountcode'});&todie('1') if ($exists_account != 2);# CHECK EXPIRY OR (FREE AND CREDIT)my	($check_expiry,$check_free);if ($accountref->{'Billing_expiry'} ne '' && $accountref->{'Billing_expiry'} ne '0000-00-00 00:00:00') {my	@dt=localtime();	$dt[5] +=1900;	$dt[4]++;	my	($exists_account) = $astodm->exten_exists_accountcode($input{'accountcode'},"$dt[5]-$dt[4]-$dt[3] $dt[2]:$dt[1]:$dt[0]");	if ($exists_account == 2) {$check_expiry++;}}$check_free++ 	if (($accountref->{'Billing_credit'}+$accountref->{'Billing_free'}) > 		$astcon_conf->{'billing'}{'outbound_disabled_freemoney'}[0]);&todie('2') if (!$check_expiry && !$check_free);#------------------------------CALL CHECKING# GET RATEmy	($perseconds,$cost,$max_call_sec);&todie('4') if ($accountref->{'Billing_rate_id'} eq '');my	$ratelist = $astodm->billing_list_ratelist(Rate_id=>$accountref->{'Billing_rate_id'});foreach  (@$ratelist) {#	if ($_->{'Callee_prefix'} ne '' && $_->{'Callee_length'} ne '' &&#		$input{extension} =~ /^$_->{'Callee_prefix'}/ && length($input{extension}) eq $_->{'Callee_length'}) {#		$perseconds = $_->{'Perseconds'};	$cost = $_->{'Cost'};last#	} elsif ($_->{'Callee_prefix'} ne '' && $input{extension} =~ /^$_->{'Callee_prefix'}/) {#		$perseconds = $_->{'Perseconds'};	$cost = $_->{'Cost'};last#	} elsif ($_->{'Callee_length'} ne '' && length($input{extension}) eq $_->{'Callee_length'}) {#		$perseconds = $_->{'Perseconds'};	$cost = $_->{'Cost'};last#	}	if ($_->{'Callee_prefix'} ne '' && $input{extension} =~ /^$_->{'Callee_prefix'}/) {		$perseconds = $_->{'Perseconds'};	$cost = $_->{'Cost'};last	}}&todie('4') if ($perseconds eq '' || $cost eq '');# IF CHECKFREE OK SET MAX CALL SEC, IF MAX CALL THAN DEFAULT (OR CHECK_FREE NOT OK) SET DEFAULT ON#$max_call_sec = ($accountref->{'Billing_credit'}+$accountref->{'Billing_free'}) * $perseconds / $cost #	if ($check_free);#$max_call_sec = $astcon_conf->{'billing'}{'max_call_sec'}[0] #	if (!$check_free || $max_call_sec > $astcon_conf->{'billing'}{'max_call_sec'}[0]);if (($perseconds != 0 && $cost != 0 && $check_free)) {	$max_call_sec = ($accountref->{'Billing_credit'}+$accountref->{'Billing_free'}) * $perseconds / $cost;	}if (!defined $max_call_sec || $max_call_sec > $astcon_conf->{'billing'}{'max_call_sec'}[0]) {	$max_call_sec = $astcon_conf->{'billing'}{'max_call_sec'}[0];}&todie('2') if ($max_call_sec < $perseconds);#------------------------------RESPONSE$AGI->set_variable('ASTERCON_VALIDSTATUS','0');$AGI->set_variable('ASTERCON_DIALTIMEOUT',($max_call_sec*1000));if ($astcon_conf->{'billing'}{'say_balance_before_call'}[0] eq 'yes') {	$AGI->set_variable('ASTERCON_PLAYFREE','1');} else {	$AGI->set_variable('ASTERCON_PLAYFREE','0');}$AGI->set_variable('ASTERCON_OUTGROUP',$accountref->{'Billing_rate_id'});# SET CALLERID REPLACE$AGI->set_variable('CALLERID(num)',$accountref->{'SendCallerid'}) if ($accountref->{'SendCallerid'} ne '');sub todie{	$AGI->set_variable('ASTERCON_VALIDSTATUS',shift);	$AGI->exec('Playback',"astercon/account-no-enough-credit|noanswer")		if ($astcon_conf->{'billing'}{'say_nomoney_before_disabled'}[0] eq 'yes');	exit;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -