From 5a730ea177798132654f3210012cc74618a45371 Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 28 Nov 2006 17:52:02 +0000 Subject: [PATCH] added postal code search and duplicate options to super listloader web lead loader scripts git-svn-id: svn://192.168.202.10@412 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/www/vicidial/listloader.php | 3 +- agc_2-X/trunk/www/vicidial/listloader.pl | 60 +++- .../www/vicidial/listloader_rowdisplay.pl | 6 + .../trunk/www/vicidial/listloader_super.pl | 66 +++- .../www/vicidial/new_listloader_superL.php | 309 +++++++++++++----- 5 files changed, 347 insertions(+), 97 deletions(-) diff --git a/agc_2-X/trunk/www/vicidial/listloader.php b/agc_2-X/trunk/www/vicidial/listloader.php index 6861e623..c6512ba0 100644 --- a/agc_2-X/trunk/www/vicidial/listloader.php +++ b/agc_2-X/trunk/www/vicidial/listloader.php @@ -120,7 +120,7 @@ function openNewWindow(url) { } function ShowProgress(good, bad, total, dup, post) { parent.lead_count.document.open(); - parent.lead_count.document.write('
Current file status:
Good:'+good+'
Bad:'+bad+'
Total:'+total+'
   
Duplicate:'+dup+'Postal Match:'+post+''); + parent.lead_count.document.write('
Current file status:
Good:'+good+'
Bad:'+bad+'
Total:'+total+'
   
Duplicate:'+dup+'
Postal Match:'+post+'
'); parent.lead_count.document.close(); } @@ -250,6 +250,7 @@ if ($leadfile and filesize($LF_path)<=8388608) { if ( (strlen($phone_number)>6) and ($dup_lead<1) ) { + $US='_'; $entry_date = "$pulldate"; $modify_date = ""; $status = "NEW"; diff --git a/agc_2-X/trunk/www/vicidial/listloader.pl b/agc_2-X/trunk/www/vicidial/listloader.pl index 1151f0b8..b15bfbb8 100644 --- a/agc_2-X/trunk/www/vicidial/listloader.pl +++ b/agc_2-X/trunk/www/vicidial/listloader.pl @@ -14,6 +14,7 @@ # 60822-1121 - fixed for nonwritable directories # 60906-1058 - added filter of non-digits in alt_phone field # 61110-1229 - added new USA-Canada DST scheme and Brazil DST scheme +# 61128-1215 - added postal code GMT lookup and duplicate check options # ### begin parsing run-time options ### @@ -29,9 +30,15 @@ if (length($ARGV[0])>1) if ($args =~ /--help|-h/i) { print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n"; + + exit; } else { + if ($args =~ /-duplicate-check/i) + {$dupcheck=1;} + if ($args =~ /-postal-code-gmt/i) + {$postalgmt=1;} if ($args =~ /--forcelistid=/i) { @data_in = split(/--forcelistid=/,$args); @@ -216,12 +223,56 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { if ($oWkC) {$comments=$oWkC->Value; } $comments=~s/^\s*(.*?)\s*$/$1/; - if (length($phone_number)>6) { - if (length($forcelistid) > 0) + if (length($forcelistid) > 0) + { + $list_id = $forcelistid; # set list_id to override value + } + if ($dupcheck > 0) + { + $dup_lead=0; + $stmtA = "select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + @aryA = $sthA->fetchrow_array; + $dup_lead = $aryA[0]; + $sthA->finish(); + if ($dup_lead < 1) { - $list_id = $forcelistid; # set list_id to override value + if ($phone_list =~ /\|$phone_number$US$list_id\|/) + {$dup_lead++;} } - + } + if ( (length($phone_number)>6) && ($dup_lead < 1) ) + { + $phone_list .= "$phone_number$US$list_id|"; + $postalgmt_found=0; + if ( ($postalgmt > 0) && (length($postal_code)>4) ) + { + if ($phone_code =~ /^1$/) + { + $stmtA = "select * from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";"; + 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; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[2]; $gmt_offset =~ s/\+| //gi; + $dst = $aryA[3]; + $dst_range = $aryA[4]; + $PC_processed++; + $rec_count++; + $postalgmt_found++; + if ($DBX) {print " Postal GMT record found for $postal_code: |$gmt_offset|$dst|$dst_range|\n";} + } + $sthA->finish(); + } + } + if ($postalgmt_found < 1) + { $PC_processed=0; ### UNITED STATES ### if ($phone_code =~ /^1$/) @@ -303,6 +354,7 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { } $sthA->finish(); } + } ### Find out if DST to raise the gmt offset ### $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); diff --git a/agc_2-X/trunk/www/vicidial/listloader_rowdisplay.pl b/agc_2-X/trunk/www/vicidial/listloader_rowdisplay.pl index fad44122..3f8695c0 100644 --- a/agc_2-X/trunk/www/vicidial/listloader_rowdisplay.pl +++ b/agc_2-X/trunk/www/vicidial/listloader_rowdisplay.pl @@ -24,9 +24,15 @@ if (length($ARGV[0])>1) if ($args =~ /--help|-h/i) { print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n"; + + exit; } else { + if ($args =~ /-duplicate-check/i) + {$dupcheck=1;} + if ($args =~ /-postal-code-gmt/i) + {$postalgmt=1;} if ($args =~ /--lead-file=/i) { @data_in = split(/--lead-file=/,$args); diff --git a/agc_2-X/trunk/www/vicidial/listloader_super.pl b/agc_2-X/trunk/www/vicidial/listloader_super.pl index d2fe23c8..704e06b7 100644 --- a/agc_2-X/trunk/www/vicidial/listloader_super.pl +++ b/agc_2-X/trunk/www/vicidial/listloader_super.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -### listloader_super.pl version 0.2 *DBI-version* +### listloader_super.pl version 0.3 *DBI-version* ### ### Copyright (C) 2006 Matt Florell,Joe Johnson LICENSE: GPLv2 ### @@ -13,6 +13,7 @@ # 60811-1329 - changed to use /etc/astguiclient.conf for configs # 60906-1056 - added filter of non-digits in alt_phone field # 61110-1229 - added new USA-Canada DST scheme and Brazil DST scheme +# 61128-1207 - added postal code GMT lookup and duplicate check options # ### begin parsing run-time options ### @@ -28,9 +29,15 @@ if (length($ARGV[0])>1) if ($args =~ /--help|-h/i) { print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n"; + + exit; } else { + if ($args =~ /-duplicate-check/i) + {$dupcheck=1;} + if ($args =~ /-postal-code-gmt/i) + {$postalgmt=1;} if ($args =~ /--forcelistid=/i) { @data_in = split(/--forcelistid=/,$args); @@ -216,12 +223,58 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { if ($oWkC) {$comments=$oWkC->Value; } $comments=~s/^\s*(.*?)\s*$/$1/; - if (length($phone_number)>6) { - if (length($forcelistid) > 0) - { - $list_id = $forcelistid; # set list_id to override value - } + + if (length($forcelistid) > 0) + { + $list_id = $forcelistid; # set list_id to override value + } + if ($dupcheck > 0) + { + $dup_lead=0; + $stmtA = "select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + @aryA = $sthA->fetchrow_array; + $dup_lead = $aryA[0]; + $sthA->finish(); + if ($dup_lead < 1) + { + if ($phone_list =~ /\|$phone_number$US$list_id\|/) + {$dup_lead++;} + } + } + if ( (length($phone_number)>6) && ($dup_lead < 1) ) + { + $phone_list .= "$phone_number$US$list_id|"; + $postalgmt_found=0; + if ( ($postalgmt > 0) && (length($postal_code)>4) ) + { + if ($phone_code =~ /^1$/) + { + $stmtA = "select * from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";"; + 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; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[2]; $gmt_offset =~ s/\+| //gi; + $dst = $aryA[3]; + $dst_range = $aryA[4]; + $PC_processed++; + $rec_count++; + $postalgmt_found++; + if ($DBX) {print " Postal GMT record found for $postal_code: |$gmt_offset|$dst|$dst_range|\n";} + } + $sthA->finish(); + } + } + if ($postalgmt_found < 1) + { $PC_processed=0; ### UNITED STATES ### if ($phone_code =~ /^1$/) @@ -303,6 +356,7 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { } $sthA->finish(); } + } ### Find out if DST to raise the gmt offset ### $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); diff --git a/agc_2-X/trunk/www/vicidial/new_listloader_superL.php b/agc_2-X/trunk/www/vicidial/new_listloader_superL.php index 94919350..1f8b74aa 100644 --- a/agc_2-X/trunk/www/vicidial/new_listloader_superL.php +++ b/agc_2-X/trunk/www/vicidial/new_listloader_superL.php @@ -16,11 +16,12 @@ # 60822-1121 - fixed for nonwritable directories # 60906-1100 - added filter of non-digits in alt_phone field # 61110-1222 - added new USA-Canada DST scheme and Brazil DST scheme +# 61128-1149 - added postal code GMT lookup and duplicate check options # # make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. $version = '2.0.2'; -$build = '61110-1222'; +$build = '61128-1149'; require("dbconnect.php"); @@ -99,6 +100,10 @@ if (isset($_GET["list_id_override"])) {$list_id_override=$_GET["list_id_overr $list_id_override = (preg_replace("/\D/","",$list_id_override)); if (isset($_GET["lead_file"])) {$lead_file=$_GET["lead_file"];} elseif (isset($_POST["lead_file"])) {$lead_file=$_POST["lead_file"];} +if (isset($_GET["dupcheck"])) {$dupcheck=$_GET["dupcheck"];} + elseif (isset($_POST["dupcheck"])) {$dupcheck=$_POST["dupcheck"];} +if (isset($_GET["postalgmt"])) {$postalgmt=$_GET["postalgmt"];} + elseif (isset($_POST["postalgmt"])) {$postalgmt=$_POST["postalgmt"];} # $country_field=$_GET["country_field"]; if (!$country_field) {$country_field=$_POST["country_field"];} @@ -262,9 +267,9 @@ A.employee_standard { font-family: garamond, sans-serif; font-size: ".macfontfi function openNewWindow(url) { window.open (url,"",'width=500,height=300,scrollbars=yes,menubar=yes,address=yes'); } -function ShowProgress(good, bad, total) { +function ShowProgress(good, bad, total, dup, post) { parent.lead_count.document.open(); - parent.lead_count.document.write('
Current file status:
Good:'+good+'
Bad:'+bad+'
Total:'+total+'
'); + parent.lead_count.document.write('
Current file status:
Good:'+good+'
Bad:'+bad+'
Total:'+total+'
   
Duplicate:'+dup+'
Postal Match:'+post+'
'); parent.lead_count.document.close(); } function ParseFileName() { @@ -296,8 +301,16 @@ function ParseFileName() { File layout to use: Standard VICIDIAL    Custom layout + + + Lead Duplicate Check: + + Lead Timezone Lookup: + + +          CLICK HERE TO GO TO THE BASIC LEAD LOADER         BACK TO ADMIN @@ -310,7 +323,7 @@ function ParseFileName() { if ($OK_to_process) { print ""; flush(); - $total=0; $good=0; $bad=0; + $total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list=''; if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { # copy($leadfile, "./vicidial_temp_file.txt"); @@ -377,16 +390,38 @@ function ParseFileName() { $security_phrase = $row[$security_phrase_field]; $comments = trim($row[$comments_field]); - if (strlen($phone_number)>6) { + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } - - if (strlen($list_id_override)>0) + ##### Check for duplicate phone numbers in vicidial_list table ##### + if (eregi("DUP",$dupcheck)) + { + $dup_lead=0; + $stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) { - # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; - $list_id = $list_id_override; + $row=mysql_fetch_row($rslt); + $dup_lead = $row[0]; } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } - $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + if ( (strlen($phone_number)>6) and ($dup_lead<1) ) + { + + $US='_'; + $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); if ($multi_insert_counter > 8) { ### insert good deal into pending_transactions table ### @@ -404,12 +439,12 @@ function ParseFileName() { $good++; } else { - if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead\n";} $bad++; } $total++; if ($total%100==0) { - print ""; + print ""; usleep(1000); flush(); } @@ -437,7 +472,10 @@ function ParseFileName() { print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

\n"; } # print "|$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override --lead_file=$lead_file|"; - passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override --lead-file=$lead_file"); + $dupcheckCLI=''; $postalgmtCLI=''; + if (eregi("DUP",$dupcheck)) {$dupcheckCLI='--duplicate-check';} + if (eregi("POSTAL",$postalgmt)) {$postalgmtCLI='--postal-code-gmt';} + passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override --lead-file=$lead_file $postalgmtCLI $dupcheckCLI"); } else { # copy($leadfile, "./vicidial_temp_file.csv"); $file=fopen("$lead_file", "r"); @@ -486,15 +524,38 @@ function ParseFileName() { $security_phrase = $row[$security_phrase_field]; $comments = trim($row[$comments_field]); - if (strlen($phone_number)>6) { - if (strlen($list_id_override)>0) { # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; $list_id = $list_id_override; } - $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + ##### Check for duplicate phone numbers in vicidial_list table ##### + if (eregi("DUP",$dupcheck)) + { + $dup_lead=0; + $stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_lead = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + if ( (strlen($phone_number)>6) and ($dup_lead<1) ) + { + + $US='_'; + $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); if ($multi_insert_counter > 8) { @@ -513,12 +574,12 @@ function ParseFileName() { $good++; } else { - if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead\n";} $bad++; } $total++; if ($total%100==0) { - print ""; + print ""; usleep(1000); flush(); } @@ -535,7 +596,7 @@ function ParseFileName() { } if ($leadfile && filesize($LF_path)<=8388608) { - $total=0; $good=0; $bad=0; + $total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list=''; if ($file_layout=="standard") { print ""; @@ -567,7 +628,7 @@ if ($leadfile && filesize($LF_path)<=8388608) { if (count($field_check)>=5) { flush(); $file=fopen("$lead_file", "r"); - $total=0; $good=0; $bad=0; + $total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list=''; print "
Processing $delim_name-delimited file... ($tab_count|$pipe_count)\n"; if (strlen($list_id_override)>0) { @@ -614,15 +675,38 @@ if ($leadfile && filesize($LF_path)<=8388608) { $security_phrase = $row[21]; $comments = trim($row[22]); - if (strlen($phone_number)>6) { + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } - if (strlen($list_id_override)>0) + ##### Check for duplicate phone numbers in vicidial_list table ##### + if (eregi("DUP",$dupcheck)) + { + $dup_lead=0; + $stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) { - # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; - $list_id = $list_id_override; + $row=mysql_fetch_row($rslt); + $dup_lead = $row[0]; } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } - $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + if ( (strlen($phone_number)>6) and ($dup_lead<1) ) + { + + $US='_'; + $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); if ($multi_insert_counter > 8) { @@ -641,12 +725,12 @@ if ($leadfile && filesize($LF_path)<=8388608) { $good++; } else { - if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead\n";} $bad++; } $total++; if ($total%100==0) { - print ""; + print ""; usleep(1000); flush(); } @@ -679,7 +763,10 @@ if ($leadfile && filesize($LF_path)<=8388608) { $file=fopen("$lead_file", "r"); # echo "|$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override --lead-file=$lead_file|"; - passthru("$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override --lead-file=$lead_file"); + $dupcheckCLI=''; $postalgmtCLI=''; + if (eregi("DUP",$dupcheck)) {$dupcheckCLI='--duplicate-check';} + if (eregi("POSTAL",$postalgmt)) {$postalgmtCLI='--postal-code-gmt';} + passthru("$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override --lead-file=$lead_file $postalgmtCLI $dupcheckCLI"); } else @@ -739,15 +826,38 @@ if ($leadfile && filesize($LF_path)<=8388608) { $security_phrase = $row[21]; $comments = trim($row[22]); - if (strlen($phone_number)>6) { - if (strlen($list_id_override)>0) { # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; $list_id = $list_id_override; } - $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + ##### Check for duplicate phone numbers in vicidial_list table ##### + if (eregi("DUP",$dupcheck)) + { + $dup_lead=0; + $stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_lead = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + if ( (strlen($phone_number)>6) and ($dup_lead<1) ) + { + + $US='_'; + $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); if ($multi_insert_counter > 8) { @@ -766,12 +876,12 @@ if ($leadfile && filesize($LF_path)<=8388608) { $good++; } else { - if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead\n";} $bad++; } $total++; if ($total%100==0) { - print ""; + print ""; usleep(1000); flush(); } @@ -900,7 +1010,10 @@ if ($leadfile && filesize($LF_path)<=8388608) { } # echo "|$WeBServeRRooT/vicidial/listloader_rowdisplay.pl --lead-file=$lead_file|"; - passthru("$WeBServeRRooT/vicidial/listloader_rowdisplay.pl --lead-file=$lead_file"); + $dupcheckCLI=''; $postalgmtCLI=''; + if (eregi("DUP",$dupcheck)) {$dupcheckCLI='--duplicate-check';} + if (eregi("POSTAL",$postalgmt)) {$postalgmtCLI='--postal-code-gmt';} + passthru("$WeBServeRRooT/vicidial/listloader_rowdisplay.pl --lead-file=$lead_file $postalgmtCLI $dupcheckCLI"); } else { @@ -926,7 +1039,7 @@ if ($leadfile && filesize($LF_path)<=8388608) { print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; } - $total=0; $good=0; $bad=0; + $total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list=''; $row=fgetcsv($file, 1000, ","); for ($i=0; $i\r\n"; @@ -980,6 +1093,8 @@ if ($leadfile && filesize($LF_path)<=8388608) { } } print " \r\n"; + print " \r\n"; + print " \r\n"; print " \r\n"; print " \r\n"; print "         \r\n"; @@ -1006,71 +1121,93 @@ exit; -function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear) +function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code) { require("dbconnect.php"); - -$PC_processed=0; -### UNITED STATES ### -if ($phone_code =='1') +$postalgmt_found=0; +if ( (eregi("POSTAL",$postalgmt)) && (strlen($postal_code)>4) ) { - $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; - $rslt=mysql_query($stmt, $link); - $pc_recs = mysql_num_rows($rslt); - if ($pc_recs > 0) + if (preg_match('/^1$/', $phone_code)) { - $row=mysql_fetch_row($rslt); - $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); - $dst = $row[5]; - $dst_range = $row[6]; - $PC_processed++; + $stmt="select * from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[2]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[3]; + $dst_range = $row[4]; + $PC_processed++; + $postalgmt_found++; + $post++; + } } } -### MEXICO ### -if ($phone_code =='52') +if ($postalgmt_found < 1) { - $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; - $rslt=mysql_query($stmt, $link); - $pc_recs = mysql_num_rows($rslt); - if ($pc_recs > 0) + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =='1') { - $row=mysql_fetch_row($rslt); - $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); - $dst = $row[5]; - $dst_range = $row[6]; - $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } } - } -### AUSTRALIA ### -if ($phone_code =='61') - { - $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; - $rslt=mysql_query($stmt, $link); - $pc_recs = mysql_num_rows($rslt); - if ($pc_recs > 0) + ### MEXICO ### + if ($phone_code =='52') { - $row=mysql_fetch_row($rslt); - $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); - $dst = $row[5]; - $dst_range = $row[6]; - $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } } - } -### ALL OTHER COUNTRY CODES ### -if (!$PC_processed) - { - $PC_processed++; - $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; - $rslt=mysql_query($stmt, $link); - $pc_recs = mysql_num_rows($rslt); - if ($pc_recs > 0) + ### AUSTRALIA ### + if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) { - $row=mysql_fetch_row($rslt); - $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); - $dst = $row[5]; - $dst_range = $row[6]; $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } } }