login
|
register
>Quick Links
Main Page
Asterisk
Open Source VOIP Software
VOIP Service Providers
VOIP Phones
What is VOIP?
VOIP Event Calendar
>Home
Main Page
>Forums
List Forums
Asterisk
FreeSWITCH
GrandStream
Polycom Phones
VOIP Questions and Help
Hardware For Sale
Minutes For Sale or Wanted
Zycoo Tech
>About
About Voip-info.org
Voip-Info.org Mirrors
>VOIP Quote
Search:
3CX Phone System for Windows Download the Free Edition
View
Discussion (1)
History
ScopServ LCA Map
This script extracts information about the telephone
NPA-NXX
for a given phone number and then produces a block for
Asterisk
extensions.conf file that will route all calls for the LCA via a specific macro.
One use for this is to allow 7 and 10-digit dialing for the entire US/Canada, where free local calls are routed via a POTS line and long-distance calls are routed via a VoIP provider.
This script is available under
LGPL license
.
Copyright (c) 2005 by
ScopServ
Inc.
Step 1 - Copy the text below into Notepad and name it lca-map.pl
#!/usr/bin/perl
$npa = shift || 819;
$nxx = shift || 473;
$page = shift || 0;
$astout = shift || 0;
my $result;
$cache = "/tmp/npanxx-$npa$nxx.map";
if (-f $cache) {
($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime,
$ctime, $blksize, $blocks) = stat($cache);
$max = ( 3600 * 24 * 7);
$diff = time() - $mtime;
if ($diff < $max && $size > 0) {
open(CACHE, $cache);
while(<CACHE>) {
print $_;
}
close (CACHE);
exit;
}
}
open(CACHE, ">/tmp/npanxx-$npa$nxx.map");
&fetchPrefix($npa, $nxx, $page);
sub fetchPrefix($npa, $nxx, $page) {
my $respage = '';
if ($page > 1) {
$respage = "-dresultpage=$page";
}
my $start = 0;
my $oknext = 0;
my $cmd = sprintf("curl http://members.dandy.net/~czg/lca_prefix.php -m 15 -G -s -dnpa=%s -dnxx=%s %s", $npa, $nxx, $respage);
open(IN, "$cmd |");
while(my $line = <IN>) {
if ($line =~ /<tr class=\"rc.\">/) {
$start = 1;
$oknext = 1;
next;
}
if ($start == 1) {
# <td headers="npanxx"><a href="lprefix.php?exch=174680">819-383</a></td>
if ($line =~ /lprefix.php\?exch=(\d+).*?\">(.*?)<\/a>/) {
$exch_id = $1;
$exchange = $2;
}
# <td headers="exchange"><a href="lca.php?exch=174680">Trois-Rivières, QC</a></td>
if ($line =~ /lca.php\?exch=(\d+).*?\">(.*?)<\/a>/) {
$location = $2;
}
# <td headers="switch"><a href="/~czg/prefix.php?switch=TSRVPQAFDMD">TSRVPQAFDMD</a></td>
if ($line =~ /prefix.php\?switch=(.*?).*?\">(.*?)<\/a>/) {
$switch = $2;
}
# <td headers="ocn"><a href="/~czg/prefix.php?ocn=8821">8821 ROGERS WIRELESS</a></td>
if ($line =~ /prefix.php\?ocn=(.*?).*?\">(.*?)<\/a>/) {
$ocn_id = $1;
$ocn = $2;
}
}
if ($start == 1 && $line =~ /<\/tr>/) {
if ($exchange eq "$npa-$nxx") {
$oknext = 0;
$result .= "$exchange ";
if ($astout) {
print "; Location : $location\n";
print "; Switch : $switch\n";
print "; OCN : $ocn\n\n";
} else {
print CACHE "INFO|$location|$switch|$ocn\n";
print "INFO|$location|$switch|$ocn\n";
}
fetchExchange($exch_id);
}
$start = 0;
next;
}
if ($oknext == 1 && $line =~ /resultpage=(\d+)&npa=...\">Next<\/a>/) {
$page = $1;
&fetchPrefix($npa, $nxx, $page);
}
}
close(IN);
return $result;
}
sub fetchExchange($exch_id) {
local $cmd = sprintf("curl http://members.dandy.net/~czg/lprefix.php -m 15 -G -s -dexch=%s", $exch_id);
my $exc_7 = '';
my $exc_10 = '';
my $start = 0;
open(IN, "$cmd |");
while(my $line = <IN>) {
if ($line =~ /<pre>/) {
$start = 1 ;
next;
}
if ($start == 1 && $line =~ /<\/pre>/) {
$start = 0;
next;
}
if ($start == 1) {
if ($line =~ /^(\d\d\d);(\d\d\d);(.*?);/) {
$l_npa = $1;
$l_nxx = $2;
$l_loc = $3;
if ($astout) {
$exc_10 .= sprintf("exten => _%d
NaV
s) ; # %s\n", $l_npa, $l_nxx, $astout, $l_loc);
$exc_10 .= sprintf("exten => _%d%dXXXX,2,Congestion\n", $l_npa, $l_nxx);
} else {
print CACHE "DATA|$l_npa|$l_nxx|$l_loc\n";
print "DATA|$l_npa|$l_nxx|$l_loc\n";
}
}
}
}
if ($astout) {
print $exc_10;
}
}
close(CACHE);
Created by:
joel_vandal
,Last modification on Tue 16 of Aug, 2005 [18:46 UTC]
Links to this page...
Asterisk addons
ScopServ
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here:
Register
Thanks! -
support@voip-info.org
Page Changes
|
Comments
Search:
Ads
Last modif pages
remote computer repair
IAXtel.com
AT-620
AX-400P
Grandstream GXP 2100
Xorcom Astribank
chan_mobile
VOIP Service Providers Residential
voip server monitoring
Asterisk Consultants France
Show More…
Free
3CX VoIP phone - free softphone for Windows
Whitepaper - 10 advantages of a Windows PBX
Free VOIP Publications
Ads
Server stats
Execution time: 0.44s
Memory usage: 2.43MB
Database queries: 39
DB time: 0.279s 63.1%
GZIP: Disabled
Server load: 3.19
Get Help
Ask a question
Re: How to place ad?
by
admin
Fri 05 of Aug, 2011
You can contact: support@voip-info.org
Re: Asterisk/Altigen Sip connection One way audio
by
jimmywag
Wed 03 of Aug, 2011
I am not sure why then, maybe you should contact a tech guy. I only have limited knowledge when it comes to these kinda stuff. Good luck
Re: Asterisk/Altigen Sip connection One way audio
by
siselin
Wed 03 of Aug, 2011
My codecs are matching. ulaw. 711 , also would i get audio from asterisk to altigen if the codecs were not matching?
View More...
Google Ads