Created the viciagi.pm library and moved the agi functions out of vicidial.pm.
Updated the vicilib-testcode.pl to test both libraries. Removed the GMT_USA_zip.txt and phone_codes_GMT.txt files as they are not downloaded from phonecodes.vicidial.com Changed ADMIN_area_code_populate.pl so that it pulls the GMT_USA_zip.txt and phone_codes_GMT.txt files rom phonecodes.vicidial.com so we can update the data after a release incase area code data changes. This means that users do not need to update to the latest vicidial code to get changes to the area code data. git-svn-id: svn://192.168.202.10@836 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -12,11 +12,14 @@
|
|||||||
# 60807-1003 - Changed to DBI
|
# 60807-1003 - Changed to DBI
|
||||||
# - changed to use /etc/astguiclient.conf for configs
|
# - changed to use /etc/astguiclient.conf for configs
|
||||||
# 61122-1902 - Added GMT_USA_zip.txt data import for USA postal GMT data
|
# 61122-1902 - Added GMT_USA_zip.txt data import for USA postal GMT data
|
||||||
#
|
# 80416-1017 -
|
||||||
|
|
||||||
|
|
||||||
# default path to astguiclient configuration file:
|
# default path to astguiclient configuration file:
|
||||||
$PATHconf = '/etc/astguiclient.conf';
|
$PATHconf = "/etc/astguiclient.conf";
|
||||||
|
$domain = "http://phonecodes.vicidial.com";
|
||||||
|
$URL1 = "$domain/phone_codes_GMT-latest.txt";
|
||||||
|
$URL2 = "$domain/GMT_USA_zip-latest.txt";
|
||||||
|
|
||||||
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
|
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
|
||||||
@conf = <conf>;
|
@conf = <conf>;
|
||||||
@@ -67,9 +70,16 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
|
|||||||
|
|
||||||
$slash_star = '\*';
|
$slash_star = '\*';
|
||||||
|
|
||||||
|
#### download the latest phone code table ####
|
||||||
|
chdir("$PATHhome");
|
||||||
|
|
||||||
|
print STDERR "Downloading latest phone codes tables\n";
|
||||||
|
|
||||||
|
`wget $URL1`;
|
||||||
|
`wget $URL2`;
|
||||||
|
|
||||||
#### BEGIN vicidial_phone_codes population from phone_codes_GMT.txt file ####
|
#### BEGIN vicidial_phone_codes population from phone_codes_GMT.txt file ####
|
||||||
open(codefile, "$PATHhome/phone_codes_GMT.txt") || die "can't open $PATHhome/phone_codes_GMT.txt: $!\n";
|
open(codefile, "$PATHhome/phone_codes_GMT-latest.txt") || die "can't open $PATHhome/phone_codes_GMT-latest.txt: $!\n";
|
||||||
@codefile = <codefile>;
|
@codefile = <codefile>;
|
||||||
close(codefile);
|
close(codefile);
|
||||||
$pc=0;
|
$pc=0;
|
||||||
@@ -110,7 +120,7 @@ print STDERR "$pc\n";
|
|||||||
|
|
||||||
|
|
||||||
#### BEGIN vicidial_postal_codes population from GMT_USA_zip.txt file ####
|
#### BEGIN vicidial_postal_codes population from GMT_USA_zip.txt file ####
|
||||||
open(zipfile, "$PATHhome/GMT_USA_zip.txt") || die "can't open $PATHhome/GMT_USA_zip.txt: $!\n";
|
open(zipfile, "$PATHhome/GMT_USA_zip-latest.txt") || die "can't open $PATHhome/GMT_USA_zip-latest.txt: $!\n";
|
||||||
@zipfile = <zipfile>;
|
@zipfile = <zipfile>;
|
||||||
close(zipfile);
|
close(zipfile);
|
||||||
$pc=0;
|
$pc=0;
|
||||||
@@ -145,4 +155,4 @@ print STDERR "$pc\n";
|
|||||||
|
|
||||||
$dbhA->disconnect();
|
$dbhA->disconnect();
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
-41750
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,62 @@
|
|||||||
|
package vicidial;
|
||||||
|
|
||||||
|
# viciagi.pm version 2.0.5
|
||||||
|
#
|
||||||
|
# Experimental library for general vicidial things
|
||||||
|
#
|
||||||
|
# This library has not been tested in a production level enviroment.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2008 VICIDIAL-GROUP <info@vicidial-group.com> LICENSE: AGPLv2
|
||||||
|
#
|
||||||
|
# CHANGELOG:
|
||||||
|
# 80326-1115 - First test build
|
||||||
|
|
||||||
|
# Export our symbols
|
||||||
|
require Exporter;
|
||||||
|
@ISA = qw(Exporter);
|
||||||
|
@EXPORT = qw(agi_log);
|
||||||
|
|
||||||
|
# USE FLAGS
|
||||||
|
use 5.008;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use Asterisk::AGI;
|
||||||
|
|
||||||
|
# function to perform logging for agi scripts
|
||||||
|
# ARG0 is the logging level of the script (0-3)
|
||||||
|
# ARG1 is the time stamp to go along with this log
|
||||||
|
# ARG2 is the name of the script that is currently logging
|
||||||
|
# ARG3 is the stage that script is currently in
|
||||||
|
# ARG4 is the log file's name
|
||||||
|
# ARG5 is the string that is going into the log
|
||||||
|
# this function does not return a value
|
||||||
|
sub agi_output {
|
||||||
|
my $agi_log_level = $_[0];
|
||||||
|
my $now_date = $_[1];
|
||||||
|
my $script_name = $_[2];
|
||||||
|
my $process_stage = $_[3];
|
||||||
|
my $log_file_name = $_[4];
|
||||||
|
my $log_string = $_[5];
|
||||||
|
|
||||||
|
my $write_string = "$now_date|$script_name|$process_stage|$log_string";
|
||||||
|
|
||||||
|
# loggin to STDERR
|
||||||
|
if ( ( $agi_log_level == '1' ) || ( $agi_log_level == '3' ) ) {
|
||||||
|
print STDERR "$write_string\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# logging to file
|
||||||
|
if ( $agi_log_level >= 2 ) {
|
||||||
|
|
||||||
|
# open the log file for writing
|
||||||
|
my $file_opened = 1;
|
||||||
|
(open( Lout, ">>$log_file_name" )) || ($file_opened = 0);
|
||||||
|
if ( $file_opened ) { # if the file was opened print to it and then close
|
||||||
|
print Lout "$write_string\n";
|
||||||
|
close(Lout);
|
||||||
|
} else { # else print a message to STDERR
|
||||||
|
print STDERR "Can't open $log_file_name to write $write_string: $!\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+94
-42
@@ -11,11 +11,12 @@ package vicidial;
|
|||||||
# CHANGELOG:
|
# CHANGELOG:
|
||||||
# 80311-1611 - First test build
|
# 80311-1611 - First test build
|
||||||
# 80324-1435 - Fixed minor issues and tested all functions.
|
# 80324-1435 - Fixed minor issues and tested all functions.
|
||||||
|
# 80326-1113 - Moved agi_log to the new viciagi.pm library
|
||||||
|
|
||||||
# Export our symbols
|
# Export our symbols
|
||||||
require Exporter;
|
require Exporter;
|
||||||
@ISA = qw(Exporter);
|
@ISA = qw(Exporter);
|
||||||
@EXPORT = qw(agi_output get_date_hash_current get_date_hash_value get_now_date load_config_file load_sys_config_db load_server_config_db load_all_servers_config_db);
|
@EXPORT = qw(get_date_hash_current get_date_hash_value get_now_date load_config_file load_sys_config_db load_server_config_db load_all_servers_config_db);
|
||||||
|
|
||||||
# USE FLAGS
|
# USE FLAGS
|
||||||
use 5.008;
|
use 5.008;
|
||||||
@@ -24,44 +25,6 @@ use warnings;
|
|||||||
use Switch;
|
use Switch;
|
||||||
use DBI;
|
use DBI;
|
||||||
|
|
||||||
# function to perform logging for agi scripts
|
|
||||||
# ARG0 is the logging level of the script (0-3)
|
|
||||||
# ARG1 is the time stamp to go along with this log
|
|
||||||
# ARG2 is the name of the script that is currently logging
|
|
||||||
# ARG3 is the stage that script is currently in
|
|
||||||
# ARG4 is the log file's name
|
|
||||||
# ARG5 is the string that is going into the log
|
|
||||||
# this function does not return a value
|
|
||||||
sub agi_output {
|
|
||||||
my $agi_log_level = $_[0];
|
|
||||||
my $now_date = $_[1];
|
|
||||||
my $script_name = $_[2];
|
|
||||||
my $process_stage = $_[3];
|
|
||||||
my $log_file_name = $_[4];
|
|
||||||
my $log_string = $_[5];
|
|
||||||
|
|
||||||
my $write_string = "$now_date|$script_name|$process_stage|$log_string";
|
|
||||||
|
|
||||||
# loggin to STDERR
|
|
||||||
if ( ( $agi_log_level == '1' ) || ( $agi_log_level == '3' ) ) {
|
|
||||||
print STDERR "$write_string\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
# logging to file
|
|
||||||
if ( $agi_log_level >= 2 ) {
|
|
||||||
# open the log file for writing
|
|
||||||
my $file_opened = 1;
|
|
||||||
(open( Lout, ">>$log_file_name" )) || ($file_opened = 0);
|
|
||||||
if ( $file_opened ) { # if the file was opened print to it and then close
|
|
||||||
print Lout "$write_string\n";
|
|
||||||
close(Lout);
|
|
||||||
} else { # else print a message to STDERR
|
|
||||||
print STDERR "Can't open $log_file_name to write $write_string: $!\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# function to get a date hash that represents the current time
|
# function to get a date hash that represents the current time
|
||||||
# this function does not take any arguments
|
# this function does not take any arguments
|
||||||
# this function returns a reference to a hash with the localtime in it
|
# this function returns a reference to a hash with the localtime in it
|
||||||
@@ -204,13 +167,30 @@ sub load_config_file {
|
|||||||
$config_hash{ 'sounds_path' } = "";
|
$config_hash{ 'sounds_path' } = "";
|
||||||
$config_hash{ 'monitor_path' } = "";
|
$config_hash{ 'monitor_path' } = "";
|
||||||
$config_hash{ 'done_monitor_path' } = "";
|
$config_hash{ 'done_monitor_path' } = "";
|
||||||
|
$config_hash{ 'fagi_log_server-port' } = "4577";
|
||||||
$config_hash{ 'fagi_log_min_servers' } = "";
|
$config_hash{ 'fagi_log_min_servers' } = "";
|
||||||
$config_hash{ 'fagi_log_max_servers' } = "";
|
$config_hash{ 'fagi_log_max_servers' } = "";
|
||||||
$config_hash{ 'fagi_log_min_spare_servers' } = "";
|
$config_hash{ 'fagi_log_min_spare_servers' } = "";
|
||||||
$config_hash{ 'fagi_log_max_spare_servers' } = "";
|
$config_hash{ 'fagi_log_max_spare_servers' } = "";
|
||||||
$config_hash{ 'fagi_log_max_requests' } = "";
|
$config_hash{ 'fagi_log_max_requests' } = "";
|
||||||
$config_hash{ 'fagi_log_checkfordead' } = "";
|
$config_hash{ 'fagi_log_checkfordead' } = "";
|
||||||
$config_hash{ 'fastagi_log_checkforwait' } = "";
|
$config_hash{ 'fagi_log_checkforwait' } = "";
|
||||||
|
$config_hash{ 'fagi_in_server_port' } = "4578";
|
||||||
|
$config_hash{ 'fagi_in_min_servers' } = "";
|
||||||
|
$config_hash{ 'fagi_in_max_servers' } = "";
|
||||||
|
$config_hash{ 'fagi_in_min_spare_servers' } = "";
|
||||||
|
$config_hash{ 'fagi_in_max_spare_servers' } = "";
|
||||||
|
$config_hash{ 'fagi_in_max_requests' } = "";
|
||||||
|
$config_hash{ 'fagi_in_checkfordead' } = "";
|
||||||
|
$config_hash{ 'fagi_in_checkforwait' } = "";
|
||||||
|
$config_hash{ 'fagi_out_server-port' } = "4579";
|
||||||
|
$config_hash{ 'fagi_out_min_servers' } = "";
|
||||||
|
$config_hash{ 'fagi_out_max_servers' } = "";
|
||||||
|
$config_hash{ 'fagi_out_min_spare_servers' } = "";
|
||||||
|
$config_hash{ 'fagi_out_max_spare_servers' } = "";
|
||||||
|
$config_hash{ 'fagi_out_max_requests' } = "";
|
||||||
|
$config_hash{ 'fagi_out_checkfordead' } = "";
|
||||||
|
$config_hash{ 'fagi_out_checkforwait' } = "";
|
||||||
$config_hash{ 'server_ip' } = "";
|
$config_hash{ 'server_ip' } = "";
|
||||||
$config_hash{ 'active_keepalives' } = "";
|
$config_hash{ 'active_keepalives' } = "";
|
||||||
$config_hash{ 'db_server' } = "";
|
$config_hash{ 'db_server' } = "";
|
||||||
@@ -274,6 +254,10 @@ sub load_config_file {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# FAGI log server settings
|
# FAGI log server settings
|
||||||
|
case qr/^VARfastagi_log_server_port/ {
|
||||||
|
$config_hash{ 'fagi_log_server_port' } = $line;
|
||||||
|
$config_hash{ 'fagi_log_server_port' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
case qr/^VARfastagi_log_min_servers/ {
|
case qr/^VARfastagi_log_min_servers/ {
|
||||||
$config_hash{ 'fagi_log_min_servers' } = $line;
|
$config_hash{ 'fagi_log_min_servers' } = $line;
|
||||||
$config_hash{ 'fagi_log_min_servers' } =~ s/.*=//gi;
|
$config_hash{ 'fagi_log_min_servers' } =~ s/.*=//gi;
|
||||||
@@ -299,8 +283,76 @@ sub load_config_file {
|
|||||||
$config_hash{ 'fagi_log_checkfordead' } =~ s/.*=//gi;
|
$config_hash{ 'fagi_log_checkfordead' } =~ s/.*=//gi;
|
||||||
}
|
}
|
||||||
case qr/^VARfastagi_log_checkforwait/ {
|
case qr/^VARfastagi_log_checkforwait/ {
|
||||||
$config_hash{ 'fastagi_log_checkforwait' } = $line;
|
$config_hash{ 'fagi_log_checkforwait' } = $line;
|
||||||
$config_hash{ 'fastagi_log_checkforwait' } =~ s/.*=//gi;
|
$config_hash{ 'fagi_log_checkforwait' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
|
||||||
|
# FAGI inbound server settings
|
||||||
|
case qr/^VARfastagi_in_server_port/ {
|
||||||
|
$config_hash{ 'fagi_in_server_port' } = $line;
|
||||||
|
$config_hash{ 'fagi_in_server_port' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_in_min_servers/ {
|
||||||
|
$config_hash{ 'fagi_in_min_servers' } = $line;
|
||||||
|
$config_hash{ 'fagi_in_min_servers' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_in_max_servers/ {
|
||||||
|
$config_hash{ 'fagi_in_max_servers' } = $line;
|
||||||
|
$config_hash{ 'fagi_in_max_servers' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_in_min_spare_servers/ {
|
||||||
|
$config_hash{ 'fagi_in_min_spare_servers' } = $line;
|
||||||
|
$config_hash{ 'fagi_in_min_spare_servers' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_in_max_spare_servers/ {
|
||||||
|
$config_hash{ 'fagi_in_max_spare_servers' } = $line;
|
||||||
|
$config_hash{ 'fagi_in_max_spare_servers' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_in_max_requests/ {
|
||||||
|
$config_hash{ 'fagi_in_max_requests' } = $line;
|
||||||
|
$config_hash{ 'fagi_in_max_requests' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_in_checkfordead/ {
|
||||||
|
$config_hash{ 'fagi_in_checkfordead' } = $line;
|
||||||
|
$config_hash{ 'fagi_in_checkfordead' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_in_checkforwait/ {
|
||||||
|
$config_hash{ 'fagi_in_checkforwait' } = $line;
|
||||||
|
$config_hash{ 'fagi_in_checkforwait' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
|
||||||
|
# FAGI outbound server settings
|
||||||
|
case qr/^VARfastagi_out_server_port/ {
|
||||||
|
$config_hash{ 'fagi_out_server_port' } = $line;
|
||||||
|
$config_hash{ 'fagi_out_server_port' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_out_min_servers/ {
|
||||||
|
$config_hash{ 'fagi_out_min_servers' } = $line;
|
||||||
|
$config_hash{ 'fagi_out_min_servers' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_out_max_servers/ {
|
||||||
|
$config_hash{ 'fagi_out_max_servers' } = $line;
|
||||||
|
$config_hash{ 'fagi_out_max_servers' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_out_min_spare_servers/ {
|
||||||
|
$config_hash{ 'fagi_out_min_spare_servers' } = $line;
|
||||||
|
$config_hash{ 'fagi_out_min_spare_servers' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_out_max_spare_servers/ {
|
||||||
|
$config_hash{ 'fagi_out_max_spare_servers' } = $line;
|
||||||
|
$config_hash{ 'fagi_out_max_spare_servers' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_out_max_requests/ {
|
||||||
|
$config_hash{ 'fagi_out_max_requests' } = $line;
|
||||||
|
$config_hash{ 'fagi_out_max_requests' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_out_checkfordead/ {
|
||||||
|
$config_hash{ 'fagi_out_checkfordead' } = $line;
|
||||||
|
$config_hash{ 'fagi_out_checkfordead' } =~ s/.*=//gi;
|
||||||
|
}
|
||||||
|
case qr/^VARfastagi_out_checkforwait/ {
|
||||||
|
$config_hash{ 'fagi_out_checkforwait' } = $line;
|
||||||
|
$config_hash{ 'fagi_out_checkforwait' } =~ s/.*=//gi;
|
||||||
}
|
}
|
||||||
|
|
||||||
# general server settings
|
# general server settings
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use vicidial;
|
use vicidial;
|
||||||
|
use viciagi;
|
||||||
use DBI;
|
use DBI;
|
||||||
|
|
||||||
# Test if get_date_hash_current is working
|
# Test if get_date_hash_current is working
|
||||||
|
|||||||
Reference in New Issue
Block a user