From: ivan Date: Wed, 11 Jan 2012 09:57:54 +0000 (+0000) Subject: fix OpenSIPS import for +1 style numbers, add -c cdrtypenum RT#16019 X-Git-Tag: freeside_2_3_1~32 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=01071982e44782ec6ede8fa83d0b97db3e7c6b65;hp=c1fa2b017e4f7d79e47e4e2257f17cf8a3d0c84b fix OpenSIPS import for +1 style numbers, add -c cdrtypenum RT#16019 --- diff --git a/bin/cdr-opensips.import b/bin/cdr-opensips.import index 54f06824c..489fac6d6 100755 --- a/bin/cdr-opensips.import +++ b/bin/cdr-opensips.import @@ -10,7 +10,7 @@ use DBI; use Getopt::Std; my %opt; -getopts('H:U:P:D:T:s:e:', \%opt); +getopts('H:U:P:D:T:s:e:c:', \%opt); my $user = shift or die &usage; my $dsn = 'dbi:mysql'; @@ -79,8 +79,21 @@ while ( $row = $sth->fetchrow_hashref ) { warn $row->{'time'} . ": no callid, skipped.\n"; next; } - my ($src) = $row->{'caller_id'} =~ /^sip:(\d+)@/; - my ($dst) = $row->{'callee_id'} =~ /^sip:(\d+)@/; + + #i guess now we're NANPA-centric, but at least we warn on non-numeric numbers + my $src = ''; + if ( $row->{'caller_id'} =~ /^sip:(\+1)?(\d+)@/ ) { + $src = $2; + } else { + warn "unparseable caller_id ". $row->{'caller_id'}. "\n"; + } + + my $dst = ''; + if ( $row->{'callee_id'} =~ /^sip:(\+1)?(\d+)@/ ) { + $dst = $2; + } else { + warn "unparseable callee_id ". $row->{'callee_id'}. "\n"; + } my $cdr = $cdrs{$callid}; if ( !$cdr ) { @@ -88,6 +101,7 @@ while ( $row = $sth->fetchrow_hashref ) { uniqueid => $callid, cdrbatchnum => $cdrbatchnum, }); + $cdr->cdrtypenum($opt{c}) if $opt{c}; } my $date = str2time($row->{'time'}); if ( $row->{'method'} eq 'INVITE' ) { @@ -132,7 +146,7 @@ if ( keys(%cdrs) ) { $mysql->disconnect; sub usage { - "Usage: \n cdr-opensips.import\n\t[ -H host ]\n\t-D database\n\t-U user\n\t-P password\n\t[ -s start ] [ -e end ]\n\tfreesideuser\n"; + "Usage: \n cdr-opensips.import\n\t[ -H host ]\n\t-D database\n\t-U user\n\t-P password\n\t[ -s start ] [ -e end ] [ -c cdrtypenum ] \n\tfreesideuser\n"; } sub check_cdr {