Added NANPA areacode and prefix phone number validation and timezone setting options to the admin web lead loader, the Non-Agent API and the CLI lead loader.

git-svn-id: svn://192.168.202.10@1967 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2013-04-21 01:43:34 +00:00
parent 5aa6d396e8
commit cd6c0cbc05
5 changed files with 276 additions and 25 deletions
+7
View File
@@ -255,6 +255,13 @@ OTHER CHANGES:
43. Added option to the AST_DB_dead_cb_purge.pl script to remove duplicate
callback entries for a single lead, keeping the newest one only.
44. Added NANPA areacode and prefix phone number validation and timezone setting
options to the admin web lead loader, the Non-Agent API and the CLI lead
loader. The NANPA prefix list will give you more accurate time zone
encoding of your USA and Canadian lead files within ViciDial. The NANPA
list is available for purchase at the vicidial.org web store:
http://www.vicidial.org/store.php#NANPA
+100 -5
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# VICIDIAL_IN_new_leads_file.pl version 2.4
# VICIDIAL_IN_new_leads_file.pl version 2.6
#
# DESCRIPTION:
# script lets you insert leads into the vicidial_list table from a TAB-delimited
@@ -10,7 +10,7 @@
#
# NOTE: the machine this is run on must have a servers entry in the database
#
# Copyright (C) 2012 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
#
# CHANGES
@@ -56,9 +56,10 @@
# 120713-1009 - Added new --duplicate-tnm-delete option to check for a duplicate phone with different title and delete existing if found in same list
# 120907-1109 - Added vote17csv format
# 121005-0728 - Added twotab format
# 130419-2138 - Added --NANPA-ac-prefix-check and --nanpa-gmt options using add-on NANPA prefix database
#
$version = '121005-0728';
$version = '130419-2138';
$secX = time();
$MT[0]='';
@@ -171,6 +172,7 @@ if (length($ARGV[0])>1)
print " [--new-list-tz-setting=X] = COUNTRY_AND_AREA_CODE|POSTAL_CODE|NANPA_PREFIX|OWNER_TIME_ZONE_CODE default COUNTRY_AND_AREA_CODE\n";
print " [--USACAN-prefix-check] = check for the 4th digit 2-9, USA and Canada validation\n";
print " [--USACAN-areacode-check] = check for the valid phone code 1 areacodes, USA and Canada validation\n";
print " [--NANPA-ac-prefix-check] = check for the valid areacode and prefix from the NANPA prefix database, if loaded\n";
print " [--duplicate-check] = checks for the same phone number in the same list id before inserting lead\n";
print " [--duplicate-campaign-check] = checks for the same phone number in the same campaign before inserting lead\n";
print " [--duplicate-system-check] = checks for the same phone number in the entire system before inserting lead\n";
@@ -181,6 +183,7 @@ if (length($ARGV[0])>1)
print " [--dob-ddmmyyy] = checks for slashes in the date of birth field and formats from DD/MM/YYYY to MySQL\n";
print " [--postal-code-gmt] = checks for the time zone based on the postal code given where available\n";
print " [--time-zone-code-gmt] = checks for the time zone based on the owner field time zone code given where available\n";
print " [--nanpa-gmt] = checks for the time zone based on the NANPA prefix database, if loaded\n";
print " [--ftp-pull] = grabs lead files from a remote FTP server, uses REPORTS FTP login information\n";
print " [--ftp-dir=leads_in] = remote FTP server directory to grab files from, should have a DONE sub-directory\n";
print " [--email-list=test@test.com:test2@test.com] = send email results for each file to these addresses\n";
@@ -313,6 +316,11 @@ if (length($ARGV[0])>1)
$usacan_areacode_check=1;
if ($q < 1) {print "\n----- USACAN AREACODE CHECK -----\n\n";}
}
if ($args =~ /--NANPA-ac-prefix-check/i)
{
$nanpa_ac_prefix_check=1;
if ($q < 1) {print "\n----- NANPA AREACODE AND PREFIX CHECK -----\n\n";}
}
if ($args =~ /-duplicate-check/i)
{
$dupcheck=1;
@@ -363,6 +371,11 @@ if (length($ARGV[0])>1)
$tzcodegmt=1;
if ($q < 1) {print "\n----- TZ CODE TIMEZONE -----\n\n";}
}
if ($args =~ /--nanpa-gmt/i)
{
$nanpagmt=1;
if ($q < 1) {print "\n----- NANPA AC-PREFIX TIMEZONE -----\n\n";}
}
if ($args =~ /-new-list-for-each-file/i)
{
@@ -499,12 +512,45 @@ $sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$non_latin = "$aryA[0]";
$non_latin = $aryA[0];
}
$sthA->finish();
##### END SETTINGS LOOKUP #####
###########################################
if ( ($nanpa_ac_prefix_check > 0) || ($nanpagmt > 0) )
{
$vicidial_nanpa_prefix_codes_count=0;
$stmtA = "SELECT count(*) FROM vicidial_nanpa_prefix_codes;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_nanpa_prefix_codes_count = $aryA[0];
}
$sthA->finish();
if ($vicidial_nanpa_prefix_codes_count < 10)
{
if ($q < 1)
{
print "NANPA options disabled! NANPA prefix data not loaded: $vicidial_nanpa_prefix_codes_count\n\n";
}
$nanpa_ac_prefix_check=0;
$nanpagmt=0;
}
else
{
if ($q < 1)
{
print "NANPA prefix records: $vicidial_nanpa_prefix_codes_count\n\n";
}
}
}
if ($non_latin > 0) {$affected_rows = $dbhA->do("SET NAMES 'UTF8'");}
$suf = '.txt';
@@ -1811,7 +1857,29 @@ foreach(@FILES)
$valid_lead = $aryA[0];
if ($valid_lead < 1)
{
if ($DBX) {print " Invalid USACAN areacode: |$USprefix|$phone_number|\n";}
if ($DBX) {print " Invalid USACAN areacode: |$USarea|$phone_number|\n";}
}
}
$sthA->finish();
}
##### Check for valid NANPA USA and Canada areacodes and prefixes #####
if ( ($nanpa_ac_prefix_check > 0) && ($valid_lead > 0) )
{
$USarea = substr($phone_number, 0, 3);
$USprefix = substr($phone_number, 3, 3);
$stmtA="SELECT count(*) from vicidial_nanpa_prefix_codes where areacode='$USarea' and prefix='$USprefix' limit 1;";
if($DBX){print STDERR "\n|$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$valid_lead = $aryA[0];
if ($valid_lead < 1)
{
if ($DBX) {print " Invalid NANPA areacode-prefix: |$USarea|$USprefix|$phone_number|\n";}
}
}
$sthA->finish();
@@ -2068,6 +2136,33 @@ foreach(@FILES)
}
$sthA->finish();
}
if ($nanpagmt > 0)
{
$dst_range='';
$dst='N';
$gmt_offset=0;
$USarea = substr($phone_number, 0, 3);
$USprefix = substr($phone_number, 3, 3);
$stmtA="SELECT GMT_offset,DST from vicidial_nanpa_prefix_codes where areacode='$USarea' and prefix='$USprefix' limit 1;";
if($DBX){print STDERR "\n|$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$gmt_offset = $aryA[0]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[1];
if ($dst =~ /Y/)
{$dst_range = 'SSM-FSN';}
$PC_processed++;
$postalgmt_found++;
if ($DBX) {print " NANPA AC-Prefix GMT record found for $USarea|$USprefix: |$gmt_offset|$dst|$dst_range|\n";}
}
$sthA->finish();
}
if ($postalgmt_found < 1)
{
$PC_processed=0;
+8 -3
View File
@@ -1,4 +1,4 @@
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2013-04-05
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2013-04-20
This document describes the functions of an API(Application Programming
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
@@ -81,7 +81,7 @@ Changes:
121125-2210 - Added Other Campaign DNC option and list expiration date option
130328-0949 - Added update_phone_number option to update_lead function
130405-1538 - Added agent_status function
130420-1938 - Added NANPA prefix validation and timezone options
API Functions use the 'function' variable
@@ -491,12 +491,14 @@ duplicate_check - Check for duplicate records in the system, can select more tha
DUPNAMEPHONESYS - check for duplicate first_name, last_name and phone_number in entire system
usacan_prefix_check - Y or N, default is N. Check for a valid 4th digit for USA and Canada phone numbers (cannot be 0 or 1)
usacan_areacode_check - Y or N, default is N. Check for a valid areacode for USA and Canada phone numbers
nanpa_ac_prefix_check - Y or N, default is N. Check for a valid NANPA areacode and prefix, if optional NANPA data is on the system
custom_fields - Y or N, default is N. Defines whether the API will accept custom field data when inserting leads into the vicidial_list table
For custom fields to be inserted, just add the field label as a variable to the URL string
For example, if the field_label is "favorite_color" you would add "&favorite_color=blue"
tz_method - <empty>, POSTAL or TZCODE, default is <empty> which will use the country code and areacode for time zone lookups
tz_method - <empty>, POSTAL, TZCODE or NANPA, default is <empty> which will use the country code and areacode for time zone lookups
POSTAL relies on the postal_code field
TZCODE relies on the owner field being populated with a proper time zone code
NANPA relies on the optional NANPA areacode prefix data being loaded on your system
callback - Y or N, default is N. Set this lead as a scheduled callback. campaign_id field is REQUIRED for callbacks
callback_status - 1-6 Character, callback status to use, default is CALLBK (vicidial_list status will be set to CBHOLD to lock)
callback_datetime - YYYY-MM-DD+HH:MM:SS, date and time of scheduled callback. REQUIRED if callback is set. NOW can be used for current datetime.
@@ -571,9 +573,12 @@ NOTICE: add_lead SCHEDULED CALLBACK ADDED - 1234|2011-09-29 12:00:01|TESTCAMP|66
NOTICE: add_lead SCHEDULED CALLBACK NOT ADDED, USER NOT VALID - 1234|TESTCAMP|6|
NOTICE: add_lead SCHEDULED CALLBACK NOT ADDED, CAMPAIGN NOT VALID - 1234|XYZ
NOTICE: add_lead NANPA options disabled, NANPA prefix data not loaded - 0|6666
ERROR: add_lead INVALID PHONE NUMBER LENGTH - 72755|6666
ERROR: add_lead INVALID PHONE NUMBER PREFIX - 72755|6666
ERROR: add_lead INVALID PHONE NUMBER AREACODE - 72755|6666
ERROR: add_lead INVALID PHONE NUMBER NANPA AREACODE PREFIX - 7275551212|6666
ERROR: add_lead USER DOES NOT HAVE PERMISSION TO ADD LEADS TO THE SYSTEM - 6666|0
@@ -1,8 +1,8 @@
<?php
# admin_listloader_fourth_gen.php - version 2.4
# admin_listloader_fourth_gen.php - version 2.6
# (based upon - new_listloader_superL.php script)
#
# Copyright (C) 2012 Matt Florell,Joe Johnson <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2013 Matt Florell,Joe Johnson <vicidial@gmail.com> LICENSE: AGPLv2
#
# ViciDial web-based lead loader from formatted file
#
@@ -47,10 +47,11 @@
# 120402-2128 - Added template options
# 120525-1038 - Added uploaded filename filtering
# 120529-1348 - Filename filter fix
# 130420-2056 - Added NANPA prefix validation and timezone options
#
$version = '2.4-46';
$build = '120529-1348';
$version = '2.6-47';
$build = '130420-2056';
require("dbconnect.php");
@@ -408,6 +409,22 @@ require("admin_header.php");
echo "<TABLE CELLPADDING=4 CELLSPACING=0><TR><TD>";
if ( (preg_match("/NANPA/",$usacan_check)) or (preg_match("/NANPA/",$tz_method)) )
{
$stmt="SELECT count(*) from vicidial_nanpa_prefix_codes;";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$vicidial_nanpa_prefix_codes_count = $row[0];
if ($vicidial_nanpa_prefix_codes_count < 10)
{
$usacan_check = preg_replace("/NANPA/",'',$usacan_check);
$tz_method = preg_replace("/NANPA/",'',$tz_method);
echo "NOTICE: NANPA options disabled, NANPA prefix data not loaded: $vicidial_nanpa_prefix_codes_count<BR>\n";
}
}
if ( (!$OK_to_process) or ( ($leadfile) and ($file_layout!="standard" && $file_layout!="template") ) )
{
?>
@@ -503,11 +520,17 @@ if ( (!$OK_to_process) or ( ($leadfile) and ($file_layout!="standard" && $file_l
<option value="PREFIX">CHECK FOR VALID PREFIX</option>
<option value="AREACODE">CHECK FOR VALID AREACODE</option>
<option value="PREFIX_AREACODE">CHECK FOR VALID PREFIX and AREACODE</option>
<option value="NANPA">CHECK FOR VALID NANPA PREFIX and AREACODE</option>
</select></td>
</tr>
<tr>
<td align=right width="25%"><font face="arial, helvetica" size=2>Lead Time Zone Lookup: </font></td>
<td align=left width="75%"><font face="arial, helvetica" size=1><select size=1 name=postalgmt><option selected value="AREA">COUNTRY CODE AND AREA CODE ONLY</option><option value="POSTAL">POSTAL CODE FIRST</option><option value="TZCODE">OWNER TIME ZONE CODE FIRST</option></select></td>
<td align=left width="75%"><font face="arial, helvetica" size=1><select size=1 name=postalgmt>
<option selected value="AREA">COUNTRY CODE AND AREA CODE ONLY</option>
<option value="POSTAL">POSTAL CODE FIRST</option>
<option value="TZCODE">OWNER TIME ZONE CODE FIRST</option>
<option value="NANPA">NANPA AREACODE PREFIX FIRST</option>
</select></td>
</tr>
<tr>
<td align=center colspan=2><input type=submit value="SUBMIT" name='submit_file'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=button onClick="javascript:document.location='admin_listloader_fourth_gen.php'" value="START OVER" name='reload_page'></td>
@@ -707,6 +730,7 @@ if ($OK_to_process)
$owner = eregi_replace($field_regx, "", $owner);
$USarea = substr($phone_number, 0, 3);
$USprefix = substr($phone_number, 3, 3);
if (strlen($list_id_override)>0)
{
@@ -887,6 +911,7 @@ if ($OK_to_process)
}
$valid_number=1;
$invalid_reason='';
if ( (strlen($phone_number)<6) || (strlen($phone_number)>16) )
{
$valid_number=0;
@@ -915,6 +940,20 @@ if ($OK_to_process)
$invalid_reason = "INVALID PHONE NUMBER AREACODE";
}
}
if ( (preg_match("/NANPA/",$usacan_check)) and ($valid_number > 0) )
{
$phone_areacode = substr($phone_number, 0, 3);
$phone_prefix = substr($phone_number, 3, 3);
$stmt = "SELECT count(*) from vicidial_nanpa_prefix_codes where areacode='$phone_areacode' and prefix='$phone_prefix';";
if ($DB>0) {echo "DEBUG: usacan nanpa query - $stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$valid_number=$row[0];
if ($valid_number < 1)
{
$invalid_reason = "INVALID PHONE NUMBER NANPA AREACODE PREFIX";
}
}
if ( ($valid_number>0) and ($dup_lead<1) and ($list_id >= 100 ))
{
@@ -925,7 +964,7 @@ if ($OK_to_process)
else
{$phone_list .= "$phone_number$US$list_id|";}
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code,$owner);
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code,$owner,$USprefix);
if (strlen($custom_SQL)>3)
{
@@ -975,7 +1014,7 @@ if ($OK_to_process)
{
if ($valid_number < 1)
{
print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]| INV: $phone_number</font><b>\n";
print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]| INV($invalid_reason): $phone_number</font><b>\n";
}
else
{
@@ -1209,6 +1248,7 @@ if (($leadfile) && ($LF_path))
$owner = eregi_replace($field_regx, "", $owner);
$USarea = substr($phone_number, 0, 3);
$USprefix = substr($phone_number, 3, 3);
if (strlen($list_id_override)>0)
{
@@ -1344,6 +1384,7 @@ if (($leadfile) && ($LF_path))
}
$valid_number=1;
$invalid_reason='';
if ( (strlen($phone_number)<6) || (strlen($phone_number)>16) )
{
$valid_number=0;
@@ -1372,6 +1413,20 @@ if (($leadfile) && ($LF_path))
$invalid_reason = "INVALID PHONE NUMBER AREACODE";
}
}
if ( (preg_match("/NANPA/",$usacan_check)) and ($valid_number > 0) )
{
$phone_areacode = substr($phone_number, 0, 3);
$phone_prefix = substr($phone_number, 3, 3);
$stmt = "SELECT count(*) from vicidial_nanpa_prefix_codes where areacode='$phone_areacode' and prefix='$phone_prefix';";
if ($DB>0) {echo "DEBUG: usacan nanpa query - $stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$valid_number=$row[0];
if ($valid_number < 1)
{
$invalid_reason = "INVALID PHONE NUMBER NANPA AREACODE PREFIX";
}
}
if ( ($valid_number>0) and ($dup_lead<1) and ($list_id >= 100 ))
{
@@ -1382,7 +1437,7 @@ if (($leadfile) && ($LF_path))
else
{$phone_list .= "$phone_number$US$list_id|";}
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code,$owner);
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code,$owner,$USprefix);
/* if ($multi_insert_counter > 8)
# {
@@ -1459,7 +1514,7 @@ if (($leadfile) && ($LF_path))
{
if ($valid_number < 1)
{
print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]| INV: $phone_number</font><b>\n";
print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]| INV($invalid_reason): $phone_number</font><b>\n";
}
else
{
@@ -1655,6 +1710,7 @@ if (($leadfile) && ($LF_path))
$owner = eregi_replace($field_regx, "", $owner);
$USarea = substr($phone_number, 0, 3);
$USprefix = substr($phone_number, 3, 3);
if (strlen($list_id_override)>0)
{
@@ -1790,6 +1846,7 @@ if (($leadfile) && ($LF_path))
}
$valid_number=1;
$invalid_reason='';
if ( (strlen($phone_number)<6) || (strlen($phone_number)>16) )
{
$valid_number=0;
@@ -1818,6 +1875,20 @@ if (($leadfile) && ($LF_path))
$invalid_reason = "INVALID PHONE NUMBER AREACODE";
}
}
if ( (preg_match("/NANPA/",$usacan_check)) and ($valid_number > 0) )
{
$phone_areacode = substr($phone_number, 0, 3);
$phone_prefix = substr($phone_number, 3, 3);
$stmt = "SELECT count(*) from vicidial_nanpa_prefix_codes where areacode='$phone_areacode' and prefix='$phone_prefix';";
if ($DB>0) {echo "DEBUG: usacan nanpa query - $stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$valid_number=$row[0];
if ($valid_number < 1)
{
$invalid_reason = "INVALID PHONE NUMBER NANPA AREACODE PREFIX";
}
}
if ( ($valid_number>0) and ($dup_lead<1) and ($list_id >= 100 ))
{
@@ -1828,7 +1899,7 @@ if (($leadfile) && ($LF_path))
else
{$phone_list .= "$phone_number$US$list_id|";}
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code,$owner);
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code,$owner,$USprefix);
if ($multi_insert_counter > 8)
{
@@ -1859,7 +1930,7 @@ if (($leadfile) && ($LF_path))
{
if ($valid_number < 1)
{
print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]| INV: $phone_number</font><b>\n";
print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]| INV($invalid_reason): $phone_number</font><b>\n";
}
else
{
@@ -2082,7 +2153,7 @@ exit;
function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code,$owner)
function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code,$owner,$USprefix)
{
global $link;
@@ -2134,6 +2205,24 @@ function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$
if (strlen($dst_range)>2) {$dst = 'Y';}
}
}
if ( (eregi("NANPA",$tz_method)) && (strlen($USarea)>2) && (strlen($USprefix)>2) )
{
$stmt="select GMT_offset,DST from vicidial_nanpa_prefix_codes where areacode='$USarea' and prefix='$USprefix';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[0]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[1];
$dst_range = '';
if ($dst == 'Y')
{$dst_range = 'SSM-FSN';}
$PC_processed++;
$postalgmt_found++;
$post++;
}
}
if ($postalgmt_found < 1)
{
+60 -5
View File
@@ -74,10 +74,11 @@
# 130328-0949 - Added update_phone_number option to update_lead function, issue #653
# 130405-1539 - Added agent_status function
# 130414-0311 - Added report logging for blind_monitor function
# 130420-1938 - Added NANPA prefix validation and timezone options
#
$version = '2.6-52';
$build = '130414-0311';
$version = '2.6-53';
$build = '130420-1938';
$api_url_log = 0;
$startMS = microtime();
@@ -327,6 +328,8 @@ if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["expiration_date"])) {$expiration_date=$_GET["expiration_date"];}
elseif (isset($_POST["expiration_date"])) {$expiration_date=$_POST["expiration_date"];}
if (isset($_GET["nanpa_ac_prefix_check"])) {$nanpa_ac_prefix_check=$_GET["nanpa_ac_prefix_check"];}
elseif (isset($_POST["nanpa_ac_prefix_check"])) {$nanpa_ac_prefix_check=$_POST["nanpa_ac_prefix_check"];}
header ("Content-type: text/html; charset=utf-8");
@@ -481,6 +484,7 @@ if ($non_latin < 1)
$call_id = ereg_replace("[^0-9a-zA-Z]","",$call_id);
$group = ereg_replace("[^-\|\_0-9a-zA-Z]","",$group);
$expiration_date = ereg_replace("[^-_0-9a-zA-Z]","",$expiration_date);
$nanpa_ac_prefix_check = ereg_replace("[^A-Z]","",$nanpa_ac_prefix_check);
}
else
{
@@ -490,6 +494,7 @@ else
}
$USarea = substr($phone_number, 0, 3);
$USprefix = substr($phone_number, 3, 3);
if (strlen($hopper_priority)<1) {$hopper_priority=0;}
if ($hopper_priority < -99) {$hopper_priority=-99;}
if ($hopper_priority > 99) {$hopper_priority=99;}
@@ -4585,6 +4590,24 @@ if ($function == 'add_lead')
if (strlen($rank)<1) {$rank='0';}
if (strlen($list_id)<3) {$list_id='999';}
if (strlen($phone_code)<1) {$phone_code='1';}
if ( ($nanpa_ac_prefix_check == 'Y') or (eregi("NANPA",$tz_method)) )
{
$stmt="SELECT count(*) from vicidial_nanpa_prefix_codes;";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$vicidial_nanpa_prefix_codes_count = $row[0];
if ($vicidial_nanpa_prefix_codes_count < 10)
{
$nanpa_ac_prefix_check='N';
$tz_method = preg_replace("/NANPA/",'',$tz_method);
$result = 'NOTICE';
$result_reason = "add_lead NANPA options disabled, NANPA prefix data not loaded";
echo "$result: $result_reason - $vicidial_nanpa_prefix_codes_count|$user\n";
$data = "$inserted_alt_phones|$lead_id";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
}
$valid_number=1;
if ( (strlen($phone_number)<6) || (strlen($phone_number)>16) )
@@ -4615,6 +4638,20 @@ if ($function == 'add_lead')
$result_reason = "add_lead INVALID PHONE NUMBER AREACODE";
}
}
if ( ($nanpa_ac_prefix_check=='Y') and ($valid_number > 0) )
{
$phone_areacode = substr($phone_number, 0, 3);
$phone_prefix = substr($phone_number, 3, 3);
$stmt = "SELECT count(*) from vicidial_nanpa_prefix_codes where areacode='$phone_areacode' and prefix='$phone_prefix';";
if ($DB>0) {echo "DEBUG: add_lead areacode check query - $stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$valid_number=$row[0];
if ($valid_number < 1)
{
$result_reason = "add_lead INVALID PHONE NUMBER NANPA AREACODE PREFIX";
}
}
if ($valid_number < 1)
{
$result = 'ERROR';
@@ -4945,7 +4982,7 @@ if ($function == 'add_lead')
### get current gmt_offset of the phone_number
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$tz_method,$postal_code,$owner);
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$tz_method,$postal_code,$owner,$USprefix);
$new_status='NEW';
if ($callback == 'Y')
@@ -5809,7 +5846,7 @@ if ($function == 'update_lead')
else
{
### get current gmt_offset of the phone_number
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$tz_method,$postal_code,$owner);
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$tz_method,$postal_code,$owner,$USprefix);
if (strlen($status)<1)
{$status='NEW';}
@@ -6023,7 +6060,7 @@ exit;
##### LOOKUP GMT, FINDS THE CURRENT GMT OFFSET FOR A PHONE NUMBER #####
function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$tz_method,$postal_code,$owner)
function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$tz_method,$postal_code,$owner,$USprefix)
{
require("dbconnect.php");
@@ -6075,6 +6112,24 @@ if ( ($tz_method=="TZCODE") && (strlen($owner)>1) )
if (strlen($dst_range)>2) {$dst = 'Y';}
}
}
if ( (eregi("NANPA",$tz_method)) && (strlen($USarea)>2) && (strlen($USprefix)>2) )
{
$stmt="select GMT_offset,DST from vicidial_nanpa_prefix_codes where areacode='$USarea' and prefix='$USprefix';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[0]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[1];
$dst_range = '';
if ($dst == 'Y')
{$dst_range = 'SSM-FSN';}
$PC_processed++;
$postalgmt_found++;
$post++;
}
}
if ($postalgmt_found < 1)
{
$PC_processed=0;