diff --git a/docs/DNC-dot-COM_integration.txt b/docs/DNC-dot-COM_integration.txt
index 34e197ec..6c494762 100644
--- a/docs/DNC-dot-COM_integration.txt
+++ b/docs/DNC-dot-COM_integration.txt
@@ -202,9 +202,16 @@ For this script to work, you must have the same DNCDOTCOM settings container cre
# For inbound filtering,
# USADNC will block federal DNC numbers
+# PROJDNC will block internal project DNC numbers
# LITIGATOR will block the litigator list, if subscribed
# INVALID will block invalid numbers
-INBOUND_FILTER => USADNC,LITIGATOR,INVALID
+INBOUND_FILTER => USADNC,PROJDNC,LITIGATOR,INVALID
+
+# to reduce load for redundant requests, you can enable
+# searching of the recent query cache to DNC.com. Set this
+# to the number of days' results you want to search through.
+# Default is 0 for disabled.
+INBOUND_CACHE => 0
Here is an example of what to put in the "Filter URL" field of the DID entry that you will be using this for.
NOTES:
diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql
index f7c7b697..fcd7ebbb 100644
--- a/extras/MySQL_AST_CREATE_tables.sql
+++ b/extras/MySQL_AST_CREATE_tables.sql
@@ -3801,6 +3801,7 @@ phone_number VARCHAR(18),
scrub_date DATETIME NOT NULL,
flag_invalid ENUM('','0','1') default '',
flag_dnc ENUM('','0','1') default '',
+flag_projdnc ENUM('','0','1') default '',
flag_litigator ENUM('','0','1') default '',
full_response VARCHAR(255) default '',
index(phone_number),
@@ -4084,4 +4085,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version';
UPDATE system_settings set vdc_agent_api_active='1';
-UPDATE system_settings SET db_schema_version='1517',db_schema_update_date=NOW(),reload_timestamp=NOW();
+UPDATE system_settings SET db_schema_version='1518',db_schema_update_date=NOW(),reload_timestamp=NOW();
diff --git a/extras/upgrade_2.14.sql b/extras/upgrade_2.14.sql
index 53754667..a811cfd6 100644
--- a/extras/upgrade_2.14.sql
+++ b/extras/upgrade_2.14.sql
@@ -389,3 +389,7 @@ index(scrub_date)
) ENGINE=MyISAM;
UPDATE system_settings SET db_schema_version='1517',db_schema_update_date=NOW() where db_schema_version < 1517;
+
+ALTER TABLE vicidial_dnccom_scrub_log ADD flag_projdnc ENUM('','0','1') default '' AFTER flag_dnc;
+
+UPDATE system_settings SET db_schema_version='1518',db_schema_update_date=NOW() where db_schema_version < 1518;
diff --git a/www/vicidial/DNCcom_inbound_filter.php b/www/vicidial/DNCcom_inbound_filter.php
index 44d86a86..a438c584 100644
--- a/www/vicidial/DNCcom_inbound_filter.php
+++ b/www/vicidial/DNCcom_inbound_filter.php
@@ -11,15 +11,22 @@
# This script REQUIRES a Settings Container in the system with ID of: DNCDOTCOM
# For inbound filtering, use the below variable in the settings container:
# USADNC will block federal DNC numbers
+# PROJDNC will block internal project DNC numbers
# LITIGATOR will block the litigator list, if subscribed
# INVALID will block invalid numbers
+#INBOUND_FILTER => USADNC,PROJDNC,LITIGATOR,INVALID
#
-#INBOUND_FILTER => USADNC,LITIGATOR,INVALID
+# to reduce load for redundant requests, you can enable
+# searching of the recent query cache to DNC.com. Set this
+# to the number of days' results you want to search through.
+# Default is 0 for disabled.
+#INBOUND_CACHE => 0
#
# This code is tested against DNC.COM scrub utility version 2.12
#
# CHANGES
# 170923-1905 - First Build
+# 170926-1016 - Added in_filter_override option and cache searching option
#
header ("Content-type: text/html; charset=utf-8");
@@ -31,6 +38,8 @@ if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
+if (isset($_GET["in_filter_override"])) {$in_filter_override=$_GET["in_filter_override"];}
+ elseif (isset($_POST["in_filter_override"])) {$in_filter_override=$_POST["in_filter_override"];}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
@@ -55,6 +64,7 @@ else
{
$phone = preg_replace("/'|\"|\\\\|;/","",$phone);
}
+$in_filter_override=preg_replace('/[^-_0-9a-zA-Z]/','',$in_filter_override);
$filter_count=0;
$ENTRYdate = date("mdHis");
@@ -83,6 +93,7 @@ if ($SC_count > 0)
$scrub_url='';
$flag_invalid=0;
$flag_dnc=0;
+ $flag_projdnc=0;
$flag_litigator=0;
$container_ct = count($container_ARY);
while ($p <= $container_ct)
@@ -99,57 +110,80 @@ if ($SC_count > 0)
{$campaign_id = $line; $campaign_id = trim(preg_replace("/.*=>/",'',$campaign_id));}
if (preg_match("/^INBOUND_FILTER/",$line))
{$in_filter = $line; $in_filter = trim(preg_replace("/.*=>/",'',$in_filter));}
+ if (preg_match("/^INBOUND_CACHE/",$line))
+ {$in_cache = $line; $in_cache = trim(preg_replace("/.*=>/",'',$in_cache));}
$p++;
}
-
+ if (strlen($in_filter_override)>5) {$in_filter = $in_filter_override;}
$scrub_url .= "?version=2&loginId=" . $login_id . "&phoneList=" . $phone;
if (strlen($project_id)>0) {$scrub_url .= "&projId=" . $project_id;}
if (strlen($campaign_id)>0) {$scrub_url .= "&campaignId=" . $campaign_id;}
- ### insert a new url log entry
- $uniqueid = $ENTRYdate . '.' . $phone;
- $SQL_log = "$scrub_url";
- $SQL_log = preg_replace('/;|\n/','',$SQL_log);
- $SQL_log = addslashes($SQL_log);
- $stmt = "INSERT INTO vicidial_url_log SET uniqueid='$uniqueid',url_date=NOW(),url_type='DNCcom',url='$SQL_log',url_response='';";
- if ($DB) {echo "$stmt\n";}
- $rslt=mysql_to_mysqli($stmt, $link);
- $affected_rows = mysqli_affected_rows($link);
- $url_id = mysqli_insert_id($link);
-
- $URLstart_sec = date("U");
-
- if ($DB > 0) {echo "$scrub_url
\n";}
- $SCUfile = file("$scrub_url");
- if ( !($SCUfile) )
+ ### BEGIN if inbound cache check is enabled, search the scrub logs for this phone number within last X days
+ $cache_found=0;
+ if ( (strlen($in_cache)>0) and ($in_cache > 0) )
{
- $error_array = error_get_last();
- $error_type = $error_array["type"];
- $error_message = $error_array["message"];
- $error_line = $error_array["line"];
- $error_file = $error_array["file"];
+ $stmt = "SELECT full_response,scrub_date FROM vicidial_dnccom_scrub_log where phone_number='$phone' and scrub_date > CONCAT(DATE_ADD(CURDATE(), INTERVAL -$in_cache DAY),' ',CURTIME()) order by scrub_date desc limit 1;";
+ $rslt=mysql_to_mysqli($stmt, $link);
+ if ($DB) {echo "$stmt\n";}
+ $vdsl_ct = mysqli_num_rows($rslt);
+ if ($vdsl_ct > 0)
+ {
+ $row=mysqli_fetch_row($rslt);
+ $SCUfile_contents = $row[0];
+ $cache_found++;
+ if ($DB) {echo "CACHE FOUND: $row[1]|$vdsl_ct|$stmt\n";}
+ }
}
+ ### END if inbound cache check is enabled, search the scrub logs for this phone number within last X days
- if ($DB > 0) {echo "$SCUfile[0]
\n";}
+ if ($cache_found < 1)
+ {
+ ### insert a new url log entry
+ $uniqueid = $ENTRYdate . '.' . $phone;
+ $SQL_log = "$scrub_url";
+ $SQL_log = preg_replace('/;|\n/','',$SQL_log);
+ $SQL_log = addslashes($SQL_log);
+ $stmt = "INSERT INTO vicidial_url_log SET uniqueid='$uniqueid',url_date=NOW(),url_type='DNCcom',url='$SQL_log',url_response='';";
+ if ($DB) {echo "$stmt\n";}
+ $rslt=mysql_to_mysqli($stmt, $link);
+ $affected_rows = mysqli_affected_rows($link);
+ $url_id = mysqli_insert_id($link);
- ### update url log entry
- $URLend_sec = date("U");
- $URLdiff_sec = ($URLend_sec - $URLstart_sec);
- if ($SCUfile)
- {
- $SCUfile_contents = implode("", $SCUfile);
- $SCUfile_contents = preg_replace("/;|\n/",'',$SCUfile_contents);
- $SCUfile_contents = addslashes($SCUfile_contents);
+ $URLstart_sec = date("U");
+
+ if ($DB > 0) {echo "$scrub_url
\n";}
+ $SCUfile = file("$scrub_url");
+ if ( !($SCUfile) )
+ {
+ $error_array = error_get_last();
+ $error_type = $error_array["type"];
+ $error_message = $error_array["message"];
+ $error_line = $error_array["line"];
+ $error_file = $error_array["file"];
+ }
+
+ if ($DB > 0) {echo "$SCUfile[0]
\n";}
+
+ ### update url log entry
+ $URLend_sec = date("U");
+ $URLdiff_sec = ($URLend_sec - $URLstart_sec);
+ if ($SCUfile)
+ {
+ $SCUfile_contents = implode("", $SCUfile);
+ $SCUfile_contents = preg_replace("/;|\n/",'',$SCUfile_contents);
+ $SCUfile_contents = addslashes($SCUfile_contents);
+ }
+ else
+ {
+ $SCUfile_contents = "PHP ERROR: Type=$error_type - Message=$error_message - Line=$error_line - File=$error_file";
+ }
+ $stmt = "UPDATE vicidial_url_log SET response_sec='$URLdiff_sec',url_response='$SCUfile_contents' where url_log_id='$url_id';";
+ if ($DB) {echo "$stmt\n";}
+ $rslt=mysql_to_mysqli($stmt, $link);
+ $affected_rows = mysqli_affected_rows($link);
}
- else
- {
- $SCUfile_contents = "PHP ERROR: Type=$error_type - Message=$error_message - Line=$error_line - File=$error_file";
- }
- $stmt = "UPDATE vicidial_url_log SET response_sec='$URLdiff_sec',url_response='$SCUfile_contents' where url_log_id='$url_id';";
- if ($DB) {echo "$stmt\n";}
- $rslt=mysql_to_mysqli($stmt, $link);
- $affected_rows = mysqli_affected_rows($link);
$result_details = explode(',',$SCUfile_contents);
if ($result_details[1] == 'D')
@@ -165,17 +199,25 @@ if ($SC_count > 0)
$filter_count++;
}
}
- if ( ($result_details[1] == 'I') or ( (preg_match("/not a valid number/",$SCUfile_contents)) and (preg_match("/INVALID/",$in_filter)) ) )
+ if ( ($result_details[1] == 'P') and (preg_match("/PROJDNC/",$in_filter)) )
+ {
+ $flag_projdnc++;
+ $filter_count++;
+ }
+ if ( ( ($result_details[1] == 'I') or (preg_match("/\D/",$phone)) or (preg_match("/not a valid number/",$SCUfile_contents)) ) and (preg_match("/INVALID/",$in_filter)) )
{
$flag_invalid++;
$filter_count++;
}
- $stmt = "INSERT INTO vicidial_dnccom_scrub_log SET phone_number='$phone',scrub_date=NOW(),flag_invalid='$flag_invalid',flag_dnc='$flag_dnc',flag_litigator='$flag_litigator',full_response='$SCUfile_contents';";
- if ($DB) {echo "$stmt\n";}
- $rslt=mysql_to_mysqli($stmt, $link);
- $affected_rows = mysqli_affected_rows($link);
- if ($DB) {echo "$affected_rows|$stmt\n";}
+ if ($cache_found < 1)
+ {
+ $stmt = "INSERT INTO vicidial_dnccom_scrub_log SET phone_number='$phone',scrub_date=NOW(),flag_invalid='$flag_invalid',flag_dnc='$flag_dnc',flag_projdnc='$flag_projdnc',flag_litigator='$flag_litigator',full_response='$SCUfile_contents';";
+ if ($DB) {echo "$stmt\n";}
+ $rslt=mysql_to_mysqli($stmt, $link);
+ $affected_rows = mysqli_affected_rows($link);
+ if ($DB) {echo "$affected_rows|$stmt\n";}
+ }
}
}