optimized all AST_CRON_audio handling scripts to be more efficient

added new minicsv file format for CLI lead loader script
in trunk, added new non-agent API script(add a new lead)

git-svn-id: svn://192.168.202.10@930 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2008-08-01 04:52:26 +00:00
parent d61908ad1a
commit 60abdae402
15 changed files with 2573 additions and 765 deletions
@@ -29,6 +29,7 @@
#
#
# 80302-1958 - First Build
# 80731-2253 - Changed size comparisons for more efficiency
#
### begin parsing run-time options ###
@@ -127,6 +128,7 @@ foreach(@conf)
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
@@ -137,25 +139,39 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
$dir1 = "$PATHmonitor";
$dir2 = "$PATHDONEmonitor";
opendir(FILE, "$dir1/");
@FILES = readdir(FILE);
opendir(FILE, "$dir1/");
@FILES = readdir(FILE);
### Loop through files first to gather filesizes
$i=0;
foreach(@FILES)
{
$size1 = 0;
$size2 = 0;
$FILEsize1[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$FILEsize1[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize1[$i]\n";}
}
$i++;
}
sleep(5);
### Loop through files a second time to gather filesizes again 5 seconds later
$i=0;
foreach(@FILES)
{
$FILEsize2[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$size1 = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size1\n";}
sleep(1);
$size2 = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size2\n\n";}
$FILEsize2[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize2[$i]\n\n";}
if ( ($FILES[$i] !~ /out\.wav|out\.gsm|lost\+found/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
if ( ($FILES[$i] !~ /out\.wav|out\.gsm|lost\+found/i) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
{
$INfile = $FILES[$i];
$OUTfile = $FILES[$i];
@@ -195,6 +211,9 @@ foreach(@FILES)
if($DBX){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
### sleep for twenty hundredths of a second to not flood the server with disk activity
usleep(1*200*1000);
}
}
$i++;
@@ -28,6 +28,7 @@
#
#
# 80302-1958 - First Build
# 80731-2253 - Changed size comparisons for more efficiency
#
### begin parsing run-time options ###
@@ -126,6 +127,7 @@ foreach(@conf)
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
@@ -158,25 +160,39 @@ else
$dir1 = "$PATHmonitor";
$dir2 = "$PATHDONEmonitor";
opendir(FILE, "$dir1/");
@FILES = readdir(FILE);
opendir(FILE, "$dir1/");
@FILES = readdir(FILE);
### Loop through files first to gather filesizes
$i=0;
foreach(@FILES)
{
$size1 = 0;
$size2 = 0;
$FILEsize1[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$FILEsize1[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize1[$i]\n";}
}
$i++;
}
sleep(5);
### Loop through files a second time to gather filesizes again 5 seconds later
$i=0;
foreach(@FILES)
{
$FILEsize2[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$size1 = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size1\n";}
sleep(1);
$size2 = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size2\n\n";}
$FILEsize2[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize2[$i]\n\n";}
if ( ($FILES[$i] !~ /out\.wav|out\.gsm|lost\+found/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
if ( ($FILES[$i] !~ /out\.wav|out\.gsm|lost\+found/i) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
{
$INfile = $FILES[$i];
$OUTfile = $FILES[$i];
@@ -213,6 +229,9 @@ foreach(@FILES)
`mv -f "$dir1/$INfile" "$dir2/ORIG/$INfile"`;
`mv -f "$dir1/$OUTfile" "$dir2/ORIG/$OUTfile"`;
}
### sleep for twenty hundredths of a second to not flood the server with disk activity
usleep(1*200*1000);
}
}
$i++;
@@ -29,6 +29,7 @@
#
#
# 80302-1958 - First Build
# 80731-2253 - Changed size comparisons for more efficiency
#
$GSM=0; $MP3=0; $OGG=0;
@@ -151,6 +152,7 @@ foreach(@conf)
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
@@ -194,25 +196,39 @@ if ($MP3 > 0)
### directory where -all recordings are
$dir2 = "$PATHDONEmonitor";
opendir(FILE, "$dir2/");
@FILES = readdir(FILE);
opendir(FILE, "$dir2/");
@FILES = readdir(FILE);
### Loop through files first to gather filesizes
$i=0;
foreach(@FILES)
{
$size1 = 0;
$size2 = 0;
$FILEsize1[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$FILEsize1[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize1[$i]\n";}
}
$i++;
}
sleep(5);
### Loop through files a second time to gather filesizes again 5 seconds later
$i=0;
foreach(@FILES)
{
$FILEsize2[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$size1 = (-s "$dir2/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size1\n";}
sleep(1);
$size2 = (-s "$dir2/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size2\n\n";}
$FILEsize2[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize2[$i]\n\n";}
if ( ($FILES[$i] !~ /out\.|in\.|lost\+found/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
if ( ($FILES[$i] !~ /out\.|in\.|lost\+found/i) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
{
$recording_id='';
$ALLfile = $FILES[$i];
@@ -279,6 +295,9 @@ foreach(@FILES)
{
`mv -f "$dir2/$ALLfile" "$dir2/ORIG/$ALLfile"`;
}
### sleep for twenty hundredths of a second to not flood the server with disk activity
usleep(1*200*1000);
}
}
$i++;
@@ -34,6 +34,7 @@
#
# 80302-1958 - First Build
# 80317-2349 - Added FTP debug if debugX
# 80731-2253 - Changed size comparisons for more efficiency
#
$GSM=0; $MP3=0; $OGG=0; $WAV=0; $NODATEDIR=0;
@@ -178,6 +179,7 @@ foreach(@conf)
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
@@ -192,25 +194,38 @@ if ($MP3 > 0) {$dir2 = "$PATHDONEmonitor/MP3";}
if ($GSM > 0) {$dir2 = "$PATHDONEmonitor/GSM";}
if ($OGG > 0) {$dir2 = "$PATHDONEmonitor/OGG";}
opendir(FILE, "$dir2/");
@FILES = readdir(FILE);
opendir(FILE, "$dir2/");
@FILES = readdir(FILE);
### Loop through files first to gather filesizes
$i=0;
foreach(@FILES)
{
$size1 = 0;
$size2 = 0;
$FILEsize1[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$FILEsize1[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize1[$i]\n";}
}
$i++;
}
sleep(5);
### Loop through files a second time to gather filesizes again 5 seconds later
$i=0;
foreach(@FILES)
{
$FILEsize2[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$size1 = (-s "$dir2/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size1\n";}
sleep(1);
$size2 = (-s "$dir2/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size2\n\n";}
$FILEsize2[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize2[$i]\n\n";}
if ( ($FILES[$i] !~ /out\.|in\.|lost\+found/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
if ( ($FILES[$i] !~ /out\.|in\.|lost\+found/i) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
{
$recording_id='';
$ALLfile = $FILES[$i];
@@ -266,6 +281,10 @@ foreach(@FILES)
}
}
### END Remote file transfer
### sleep for twenty hundredths of a second to not flood the server with disk activity
usleep(1*200*1000);
}
}
$i++;
@@ -27,6 +27,7 @@
# 70815-2128 - Added entry_date to import leads format (field 26)
# 80128-0105 - Fixed bugs in file loading
# 80428-0320 - UTF8 update
# 80730-1607 - added minicsv format
#
$secX = time();
@@ -42,7 +43,7 @@ if ($mday < 10) {$mday = "0$mday";}
$pulldate0 = "$year-$mon-$mday $hour:$min:$sec";
$inSD = $pulldate0;
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
$MT[0]='';
# default path to astguiclient configuration file:
@@ -109,6 +110,7 @@ if (length($ARGV[0])>1)
print " [-t] = test\n";
print " [--forcegmt] = forces gmt value of column after comments column\n";
print " [--debug] = debug output\n";
print " [--format=standard] = ability to define a format, standard is default, formats allowed shown in examples\n";
print " [--forcelistid=1234] = overrides the listID given in the file with the 1234\n";
print " [--forcephonecode=44] = overrides the phone_code given in the lead with the 44\n";
print " [--duplicate-check] = checks for the same phone number in the same list id before inserting lead\n";
@@ -117,9 +119,13 @@ if (length($ARGV[0])>1)
print " [--postal-code-gmt] = checks for the time zone based on the postal code given where available\n";
print " [-h] = this help screen\n\n";
print "\n";
print "This script takes in lead files in the following order when they are placed in the $PATHhome/LEADS_IN directory to be imported into the vicidial_list table:\n\n";
print "vendor_lead_code|source_code|list_id|phone_code|phone_number|title|first_name|middle|last_name|address1|address2|address3|city|state|province|postal_code|country|gender|date_of_birth|alt_phone|email|security_phrase|COMMENTS|called_count|status|entry_date\n\n";
print "This script takes in lead files in the following order when they are placed in the $PATHhome/LEADS_IN directory to be imported into the vicidial_list table (examples):\n\n";
print "standard:\n";
print "vendor_lead_code|source_code|list_id|phone_code|phone_number|title|first_name|middle|last_name|address1|address2|address3|city|state|province|postal_code|country|gender|date_of_birth|alt_phone|email|security_phrase|COMMENTS|called_count|status|entry_date\n";
print "3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS|2|B|2007-08-09 00:00:00\n\n";
print "minicsv:\n";
print "address1,city,name,phone_number,state,postal_code\n";
print "\"105 Fifth St\",\"Steinhatchee\",\"Frank Smith\",\"3525556601\",\"FL\",\"32359\"\n\n";
exit;
}
@@ -160,6 +166,16 @@ if (length($ARGV[0])>1)
else
{$forcelistid = '';}
if ($args =~ /-format=/i)
{
@data_in = split(/-format=/,$args);
$format = $data_in[1];
$format =~ s/ .*//gi;
print "\n----- FORMAT OVERRIDE: $format -----\n\n";
}
else
{$format = 'standard';}
if ($args =~ /--forcephonecode=/i)
{
@data_in = split(/--forcephonecode=/,$args);
@@ -198,6 +214,7 @@ print "no command line options set\n";
$args = "";
$i=0;
$forcelistid = '';
$format='standard';
}
### end parsing run-time options ###
@@ -300,7 +317,7 @@ if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOC
#if ($DB)
while (<infile>)
{
@m=@MT;
# print "$a| $number\n";
$number = $_;
chomp($number);
@@ -318,10 +335,44 @@ if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOC
$number =~ s/\"//gi;
@m = split(/\|/, $number);
# This is the format for the lead files
# This is the format for the minicsv lead files
#"105 Fifth St","Steinhatchee","Frank Smith","3525556601","FL","32359"
if ($format=='minicsv')
{
@name=@MT;
$vendor_lead_code = '';
$source_code = '';
$list_id = '995';
$phone_code = '1';
$phone_number = $m[3]; chomp($phone_number); $phone_number =~ s/\D//gi;
$USarea = substr($phone_number, 0, 3);
$title = '';
$full_name = $m[2]; @name = split(/ /, $full_name);
$first_name = $name[1]; chomp($first_name);
$last_name = "$name[0] $name[2]"; chomp($first_name);
$middle_initial = '';
$address1 = $m[0]; chomp($address1);
$address2 = '';
$address3 = '';
$city = $m[1]; chomp($city);
$state = $m[4]; chomp($state);
$province = '';
$postal_code = $m[5]; chomp($postal_code);
$country = 'USA';
$gender = 'U';
$date_of_birth = '0000-00-00';
$alt_phone = '';
$email = '';
$security_phrase = '';
$comments = '';
$called_count = 0;
$status = 'NEW';
}
# This is the format for the standard lead files
#3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS
else
{
$vendor_lead_code = $m[0]; chomp($vendor_lead_code);
$source_code = $m[1]; chomp($source_code); $source_id = $source_code;
$list_id = $m[2]; chomp($list_id);
@@ -356,361 +407,362 @@ if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOC
$iD[1] = sprintf("%02d", $iD[1]);
$insert_date = "$iD[2]-$iD[0]-$iD[1]";
}
}
if (length($forcelistid) > 0)
{
$list_id = $forcelistid; # set list_id to override value
}
if (length($forcephonecode) > 0)
{
$phone_code = $forcephonecode; # set phone_code to override value
}
if (length($forcelistid) > 0)
{
$list_id = $forcelistid; # set list_id to override value
}
if (length($forcephonecode) > 0)
{
$phone_code = $forcephonecode; # set phone_code to override value
}
##### Check for duplicate phone numbers in vicidial_list table entire database #####
if ($dupchecksys > 0)
##### Check for duplicate phone numbers in vicidial_list table entire database #####
if ($dupchecksys > 0)
{
$dup_lead=0;
$stmtA = "select count(*) from vicidial_list where phone_number='$phone_number';";
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)
{
$dup_lead=0;
$stmtA = "select count(*) from vicidial_list where phone_number='$phone_number';";
@aryA = $sthA->fetchrow_array;
$dup_lead = $aryA[0];
$dup_lead_list=$list_id;
}
$sthA->finish();
if ($dup_lead < 1)
{
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
}
##### Check for duplicate phone numbers in vicidial_list table for one list_id #####
if ($dupcheck > 0)
{
$dup_lead=0;
$stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' 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;
$dup_lead_list = $aryA[0];
$dup_lead++;
}
$sthA->finish();
if ($dup_lead < 1)
{
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
}
##### Check for duplicate phone numbers in vicidial_list table for all lists in a campaign #####
if ($dupcheckcamp > 0)
{
$dup_lead=0;
$dup_lists='';
$stmtA = "select count(*) from vicidial_lists where 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;
$ci_recs = $aryA[0];
$sthA->finish();
if ($ci_recs > 0)
{
$stmtA = "select campaign_id from vicidial_lists where 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_camp = $aryA[0];
$sthA->finish();
$stmtA = "select list_id from vicidial_lists where campaign_id='$dup_camp';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$dup_lead = $aryA[0];
$dup_lead_list=$list_id;
$dup_lists .= "'$aryA[0]',";
$rec_count++;
}
$sthA->finish();
if ($dup_lead < 1)
{
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
}
##### Check for duplicate phone numbers in vicidial_list table for one list_id #####
if ($dupcheck > 0)
{
$dup_lead=0;
$stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' limit 1;";
if($DBX){print STDERR "\n|$stmtA|\n";}
chop($dup_lists);
$stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$dup_lead_list = $aryA[0];
$dup_lead++;
$dup_lead_list = "'$aryA[0]',";
$rec_count++;
$dup_lead=1;
}
$sthA->finish();
if ($dup_lead < 1)
{
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
}
##### Check for duplicate phone numbers in vicidial_list table for all lists in a campaign #####
if ($dupcheckcamp > 0)
if ($dup_lead < 1)
{
$dup_lead=0;
$dup_lists='';
$stmtA = "select count(*) from vicidial_lists where 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;
$ci_recs = $aryA[0];
$sthA->finish();
if ($ci_recs > 0)
{
$stmtA = "select campaign_id from vicidial_lists where 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_camp = $aryA[0];
$sthA->finish();
$stmtA = "select list_id from vicidial_lists where campaign_id='$dup_camp';";
$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;
$dup_lists .= "'$aryA[0]',";
$rec_count++;
}
$sthA->finish();
chop($dup_lists);
$stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;";
$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;
$dup_lead_list = "'$aryA[0]',";
$rec_count++;
$dup_lead=1;
}
$sthA->finish();
}
if ($dup_lead < 1)
{
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
}
if ( (length($phone_number)>6) && ($dup_lead < 1) )
if ( (length($phone_number)>6) && ($dup_lead < 1) )
{
$phone_list .= "$phone_number$US$list_id|";
# set default values
$modify_date = "";
$user = "";
$called_since_last_reset='N';
$gmt_offset = '0';
if ($forcegmt > 0)
{
$phone_list .= "$phone_number$US$list_id|";
# set default values
$modify_date = "";
$user = "";
$called_since_last_reset='N';
$gmt_offset = '0';
if ($forcegmt > 0)
{
$gmt_offset = $m[23]; # set GMT offset value to 24th field value
}
else
{
$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$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
### MEXICO ###
if ($phone_code =~ /^52$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
### AUSTRALIA ###
if ($phone_code =~ /^61$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';";
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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
### ALL OTHER COUNTRY CODES ###
if (!$PC_processed)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
}
### Find out if DST to raise the gmt offset ###
$AC_GMT_diff = ($area_GMT - $LOCAL_GMT_OFF_STD);
$AC_localtime = ($secX + (3600 * $AC_GMT_diff));
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime);
$year = ($year + 1900);
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
$AC_processed=0;
if ( (!$AC_processed) && ($dst_range =~ /SSM-FSN/) )
{
if ($DBX) {print " Second Sunday March to First Sunday November\n";}
&USACAN_dstcalc;
if ($DBX) {print " DST: $USACAN_DST\n";}
if ($USACAN_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) )
{
if ($DBX) {print " First Sunday April to Last Sunday October\n";}
&NA_dstcalc;
if ($DBX) {print " DST: $NA_DST\n";}
if ($NA_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) )
{
if ($DBX) {print " Last Sunday March to Last Sunday October\n";}
&GBR_dstcalc;
if ($DBX) {print " DST: $GBR_DST\n";}
if ($GBR_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) )
{
if ($DBX) {print " Last Sunday October to Last Sunday March\n";}
&AUS_dstcalc;
if ($DBX) {print " DST: $AUS_DST\n";}
if ($AUS_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) )
{
if ($DBX) {print " First Sunday October to Last Sunday March\n";}
&AUST_dstcalc;
if ($DBX) {print " DST: $AUST_DST\n";}
if ($AUST_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) )
{
if ($DBX) {print " First Sunday October to Third Sunday March\n";}
&NZL_dstcalc;
if ($DBX) {print " DST: $NZL_DST\n";}
if ($NZL_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /TSO-LSF/) )
{
if ($DBX) {print " Third Sunday October to Last Sunday February\n";}
&BZL_dstcalc;
if ($DBX) {print " DST: $BZL_DST\n";}
if ($BZL_DST) {$gmt_offset++;}
$AC_processed++;
}
if (!$AC_processed)
{
if ($DBX) {print " No DST Method Found\n";}
if ($DBX) {print " DST: 0\n";}
$AC_processed++;
}
}
if ($multi_insert_counter > 8)
{
### insert good deal into pending_transactions table ###
$stmtZ = "INSERT INTO vicidial_list values$multistmt('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count');";
if (!$T) {$affected_rows = $dbhA->do($stmtZ); } # or die "Couldn't execute query: |$stmtZ|\n";
if($DB){print STDERR "\n|$affected_rows|$stmtZ|\n";}
$multistmt='';
$multi_insert_counter=0;
$c++;
}
else
{
$multistmt .= "('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count'),";
$multi_insert_counter++;
}
$b++;
$gmt_offset = $m[23]; # set GMT offset value to 24th field value
}
else
{
if ($dup_lead > 0)
{print "DUPLICATE: $phone|$list_id|$dup_lead_list|"; $f++;}
else
{print "BAD Home_Phone: $phone|$vendor_id"; $e++;}
$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$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
### MEXICO ###
if ($phone_code =~ /^52$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
### AUSTRALIA ###
if ($phone_code =~ /^61$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';";
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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
### ALL OTHER COUNTRY CODES ###
if (!$PC_processed)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
}
### Find out if DST to raise the gmt offset ###
$AC_GMT_diff = ($area_GMT - $LOCAL_GMT_OFF_STD);
$AC_localtime = ($secX + (3600 * $AC_GMT_diff));
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime);
$year = ($year + 1900);
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
$AC_processed=0;
if ( (!$AC_processed) && ($dst_range =~ /SSM-FSN/) )
{
if ($DBX) {print " Second Sunday March to First Sunday November\n";}
&USACAN_dstcalc;
if ($DBX) {print " DST: $USACAN_DST\n";}
if ($USACAN_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) )
{
if ($DBX) {print " First Sunday April to Last Sunday October\n";}
&NA_dstcalc;
if ($DBX) {print " DST: $NA_DST\n";}
if ($NA_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) )
{
if ($DBX) {print " Last Sunday March to Last Sunday October\n";}
&GBR_dstcalc;
if ($DBX) {print " DST: $GBR_DST\n";}
if ($GBR_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) )
{
if ($DBX) {print " Last Sunday October to Last Sunday March\n";}
&AUS_dstcalc;
if ($DBX) {print " DST: $AUS_DST\n";}
if ($AUS_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) )
{
if ($DBX) {print " First Sunday October to Last Sunday March\n";}
&AUST_dstcalc;
if ($DBX) {print " DST: $AUST_DST\n";}
if ($AUST_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) )
{
if ($DBX) {print " First Sunday October to Third Sunday March\n";}
&NZL_dstcalc;
if ($DBX) {print " DST: $NZL_DST\n";}
if ($NZL_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /TSO-LSF/) )
{
if ($DBX) {print " Third Sunday October to Last Sunday February\n";}
&BZL_dstcalc;
if ($DBX) {print " DST: $BZL_DST\n";}
if ($BZL_DST) {$gmt_offset++;}
$AC_processed++;
}
if (!$AC_processed)
{
if ($DBX) {print " No DST Method Found\n";}
if ($DBX) {print " DST: 0\n";}
$AC_processed++;
}
}
if ($multi_insert_counter > 8)
{
### insert good deal into pending_transactions table ###
$stmtZ = "INSERT INTO vicidial_list values$multistmt('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count');";
if (!$T) {$affected_rows = $dbhA->do($stmtZ); } # or die "Couldn't execute query: |$stmtZ|\n";
if($DB){print STDERR "\n|$affected_rows|$stmtZ|\n";}
$multistmt='';
$multi_insert_counter=0;
$c++;
}
else
{
$multistmt .= "('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count'),";
$multi_insert_counter++;
}
$a++;
$b++;
}
else
{
if ($dup_lead > 0)
{print "DUPLICATE: $phone|$list_id|$dup_lead_list|"; $f++;}
else
{print "BAD Home_Phone: $phone|$vendor_id"; $e++;}
}
if ($a =~ /100$/i) {print STDERR "0 $a\r";}
if ($a =~ /200$/i) {print STDERR "+ $a\r";}
if ($a =~ /300$/i) {print STDERR "| $a\r";}
if ($a =~ /400$/i) {print STDERR "\\ $a\r";}
if ($a =~ /500$/i) {print STDERR "- $a\r";}
if ($a =~ /600$/i) {print STDERR "/ $a\r";}
if ($a =~ /700$/i) {print STDERR "| $a\r";}
if ($a =~ /800$/i) {print STDERR "+ $a\r";}
if ($a =~ /900$/i) {print STDERR "0 $a\r";}
if ($a =~ /000$/i) {print "$a|$b|$c|$d|$e|$phone_number|\n";}
$a++;
if ($a =~ /100$/i) {print STDERR "0 $a\r";}
if ($a =~ /200$/i) {print STDERR "+ $a\r";}
if ($a =~ /300$/i) {print STDERR "| $a\r";}
if ($a =~ /400$/i) {print STDERR "\\ $a\r";}
if ($a =~ /500$/i) {print STDERR "- $a\r";}
if ($a =~ /600$/i) {print STDERR "/ $a\r";}
if ($a =~ /700$/i) {print STDERR "| $a\r";}
if ($a =~ /800$/i) {print STDERR "+ $a\r";}
if ($a =~ /900$/i) {print STDERR "0 $a\r";}
if ($a =~ /000$/i) {print "$a|$b|$c|$d|$e|$phone_number|\n";}
}
@@ -29,6 +29,7 @@
#
#
# 80302-1958 - First Build
# 80731-2253 - Changed size comparisons for more efficiency
#
### begin parsing run-time options ###
@@ -127,6 +128,7 @@ foreach(@conf)
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
@@ -137,25 +139,39 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
$dir1 = "$PATHmonitor";
$dir2 = "$PATHDONEmonitor";
opendir(FILE, "$dir1/");
@FILES = readdir(FILE);
opendir(FILE, "$dir1/");
@FILES = readdir(FILE);
### Loop through files first to gather filesizes
$i=0;
foreach(@FILES)
{
$size1 = 0;
$size2 = 0;
$FILEsize1[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$FILEsize1[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize1[$i]\n";}
}
$i++;
}
sleep(5);
### Loop through files a second time to gather filesizes again 5 seconds later
$i=0;
foreach(@FILES)
{
$FILEsize2[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$size1 = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size1\n";}
sleep(1);
$size2 = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size2\n\n";}
$FILEsize2[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize2[$i]\n\n";}
if ( ($FILES[$i] !~ /out\.wav|out\.gsm|lost\+found/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
if ( ($FILES[$i] !~ /out\.wav|out\.gsm|lost\+found/i) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
{
$INfile = $FILES[$i];
$OUTfile = $FILES[$i];
@@ -195,6 +211,9 @@ foreach(@FILES)
if($DBX){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
### sleep for twenty hundredths of a second to not flood the server with disk activity
usleep(1*200*1000);
}
}
$i++;
+29 -10
View File
@@ -28,6 +28,7 @@
#
#
# 80302-1958 - First Build
# 80731-2253 - Changed size comparisons for more efficiency
#
### begin parsing run-time options ###
@@ -126,6 +127,7 @@ foreach(@conf)
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
@@ -158,25 +160,39 @@ else
$dir1 = "$PATHmonitor";
$dir2 = "$PATHDONEmonitor";
opendir(FILE, "$dir1/");
@FILES = readdir(FILE);
opendir(FILE, "$dir1/");
@FILES = readdir(FILE);
### Loop through files first to gather filesizes
$i=0;
foreach(@FILES)
{
$size1 = 0;
$size2 = 0;
$FILEsize1[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$FILEsize1[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize1[$i]\n";}
}
$i++;
}
sleep(5);
### Loop through files a second time to gather filesizes again 5 seconds later
$i=0;
foreach(@FILES)
{
$FILEsize2[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$size1 = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size1\n";}
sleep(1);
$size2 = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size2\n\n";}
$FILEsize2[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize2[$i]\n\n";}
if ( ($FILES[$i] !~ /out\.wav|out\.gsm|lost\+found/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
if ( ($FILES[$i] !~ /out\.wav|out\.gsm|lost\+found/i) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
{
$INfile = $FILES[$i];
$OUTfile = $FILES[$i];
@@ -213,6 +229,9 @@ foreach(@FILES)
`mv -f "$dir1/$INfile" "$dir2/ORIG/$INfile"`;
`mv -f "$dir1/$OUTfile" "$dir2/ORIG/$OUTfile"`;
}
### sleep for twenty hundredths of a second to not flood the server with disk activity
usleep(1*200*1000);
}
}
$i++;
+29 -10
View File
@@ -29,6 +29,7 @@
#
#
# 80302-1958 - First Build
# 80731-2253 - Changed size comparisons for more efficiency
#
$GSM=0; $MP3=0; $OGG=0;
@@ -151,6 +152,7 @@ foreach(@conf)
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
@@ -194,25 +196,39 @@ if ($MP3 > 0)
### directory where -all recordings are
$dir2 = "$PATHDONEmonitor";
opendir(FILE, "$dir2/");
@FILES = readdir(FILE);
opendir(FILE, "$dir2/");
@FILES = readdir(FILE);
### Loop through files first to gather filesizes
$i=0;
foreach(@FILES)
{
$size1 = 0;
$size2 = 0;
$FILEsize1[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$FILEsize1[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize1[$i]\n";}
}
$i++;
}
sleep(5);
### Loop through files a second time to gather filesizes again 5 seconds later
$i=0;
foreach(@FILES)
{
$FILEsize2[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$size1 = (-s "$dir2/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size1\n";}
sleep(1);
$size2 = (-s "$dir2/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size2\n\n";}
$FILEsize2[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize2[$i]\n\n";}
if ( ($FILES[$i] !~ /out\.|in\.|lost\+found/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
if ( ($FILES[$i] !~ /out\.|in\.|lost\+found/i) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
{
$recording_id='';
$ALLfile = $FILES[$i];
@@ -279,6 +295,9 @@ foreach(@FILES)
{
`mv -f "$dir2/$ALLfile" "$dir2/ORIG/$ALLfile"`;
}
### sleep for twenty hundredths of a second to not flood the server with disk activity
usleep(1*200*1000);
}
}
$i++;
+29 -10
View File
@@ -34,6 +34,7 @@
#
# 80302-1958 - First Build
# 80317-2349 - Added FTP debug if debugX
# 80731-2253 - Changed size comparisons for more efficiency
#
$GSM=0; $MP3=0; $OGG=0; $WAV=0; $NODATEDIR=0;
@@ -178,6 +179,7 @@ foreach(@conf)
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
@@ -192,25 +194,38 @@ if ($MP3 > 0) {$dir2 = "$PATHDONEmonitor/MP3";}
if ($GSM > 0) {$dir2 = "$PATHDONEmonitor/GSM";}
if ($OGG > 0) {$dir2 = "$PATHDONEmonitor/OGG";}
opendir(FILE, "$dir2/");
@FILES = readdir(FILE);
opendir(FILE, "$dir2/");
@FILES = readdir(FILE);
### Loop through files first to gather filesizes
$i=0;
foreach(@FILES)
{
$size1 = 0;
$size2 = 0;
$FILEsize1[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$FILEsize1[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize1[$i]\n";}
}
$i++;
}
sleep(5);
### Loop through files a second time to gather filesizes again 5 seconds later
$i=0;
foreach(@FILES)
{
$FILEsize2[$i] = 0;
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
{
$size1 = (-s "$dir2/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size1\n";}
sleep(1);
$size2 = (-s "$dir2/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $size2\n\n";}
$FILEsize2[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize2[$i]\n\n";}
if ( ($FILES[$i] !~ /out\.|in\.|lost\+found/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
if ( ($FILES[$i] !~ /out\.|in\.|lost\+found/i) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
{
$recording_id='';
$ALLfile = $FILES[$i];
@@ -266,6 +281,10 @@ foreach(@FILES)
}
}
### END Remote file transfer
### sleep for twenty hundredths of a second to not flood the server with disk activity
usleep(1*200*1000);
}
}
$i++;
+396 -344
View File
@@ -28,6 +28,7 @@
# 80128-0105 - Fixed bugs in file loading
# 80428-0320 - UTF8 update
# 80713-0023 - added last_local_call_time field default of 2008-01-01
# 80730-1607 - added minicsv format
#
$secX = time();
@@ -43,7 +44,7 @@ if ($mday < 10) {$mday = "0$mday";}
$pulldate0 = "$year-$mon-$mday $hour:$min:$sec";
$inSD = $pulldate0;
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
$MT[0]='';
# default path to astguiclient configuration file:
@@ -110,6 +111,7 @@ if (length($ARGV[0])>1)
print " [-t] = test\n";
print " [--forcegmt] = forces gmt value of column after comments column\n";
print " [--debug] = debug output\n";
print " [--format=standard] = ability to define a format, standard is default, formats allowed shown in examples\n";
print " [--forcelistid=1234] = overrides the listID given in the file with the 1234\n";
print " [--forcephonecode=44] = overrides the phone_code given in the lead with the 44\n";
print " [--duplicate-check] = checks for the same phone number in the same list id before inserting lead\n";
@@ -118,9 +120,13 @@ if (length($ARGV[0])>1)
print " [--postal-code-gmt] = checks for the time zone based on the postal code given where available\n";
print " [-h] = this help screen\n\n";
print "\n";
print "This script takes in lead files in the following order when they are placed in the $PATHhome/LEADS_IN directory to be imported into the vicidial_list table:\n\n";
print "vendor_lead_code|source_code|list_id|phone_code|phone_number|title|first_name|middle|last_name|address1|address2|address3|city|state|province|postal_code|country|gender|date_of_birth|alt_phone|email|security_phrase|COMMENTS|called_count|status|entry_date\n\n";
print "This script takes in lead files in the following order when they are placed in the $PATHhome/LEADS_IN directory to be imported into the vicidial_list table (examples):\n\n";
print "standard:\n";
print "vendor_lead_code|source_code|list_id|phone_code|phone_number|title|first_name|middle|last_name|address1|address2|address3|city|state|province|postal_code|country|gender|date_of_birth|alt_phone|email|security_phrase|COMMENTS|called_count|status|entry_date\n";
print "3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS|2|B|2007-08-09 00:00:00\n\n";
print "minicsv:\n";
print "address1,city,name,phone_number,state,postal_code\n";
print "\"105 Fifth St\",\"Steinhatchee\",\"Frank Smith\",\"3525556601\",\"FL\",\"32359\"\n\n";
exit;
}
@@ -161,6 +167,16 @@ if (length($ARGV[0])>1)
else
{$forcelistid = '';}
if ($args =~ /-format=/i)
{
@data_in = split(/-format=/,$args);
$format = $data_in[1];
$format =~ s/ .*//gi;
print "\n----- FORMAT OVERRIDE: $format -----\n\n";
}
else
{$format = 'standard';}
if ($args =~ /--forcephonecode=/i)
{
@data_in = split(/--forcephonecode=/,$args);
@@ -199,6 +215,7 @@ print "no command line options set\n";
$args = "";
$i=0;
$forcelistid = '';
$format='standard';
}
### end parsing run-time options ###
@@ -301,7 +318,7 @@ if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOC
#if ($DB)
while (<infile>)
{
@m=@MT;
# print "$a| $number\n";
$number = $_;
chomp($number);
@@ -319,10 +336,44 @@ if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOC
$number =~ s/\"//gi;
@m = split(/\|/, $number);
# This is the format for the lead files
# This is the format for the minicsv lead files
#"105 Fifth St","Steinhatchee","Frank Smith","3525556601","FL","32359"
if ($format=='minicsv')
{
@name=@MT;
$vendor_lead_code = '';
$source_code = '';
$list_id = '995';
$phone_code = '1';
$phone_number = $m[3]; chomp($phone_number); $phone_number =~ s/\D//gi;
$USarea = substr($phone_number, 0, 3);
$title = '';
$full_name = $m[2]; @name = split(/ /, $full_name);
$first_name = $name[1]; chomp($first_name);
$last_name = "$name[0] $name[2]"; chomp($first_name);
$middle_initial = '';
$address1 = $m[0]; chomp($address1);
$address2 = '';
$address3 = '';
$city = $m[1]; chomp($city);
$state = $m[4]; chomp($state);
$province = '';
$postal_code = $m[5]; chomp($postal_code);
$country = 'USA';
$gender = 'U';
$date_of_birth = '0000-00-00';
$alt_phone = '';
$email = '';
$security_phrase = '';
$comments = '';
$called_count = 0;
$status = 'NEW';
}
# This is the format for the standard lead files
#3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS
else
{
$vendor_lead_code = $m[0]; chomp($vendor_lead_code);
$source_code = $m[1]; chomp($source_code); $source_id = $source_code;
$list_id = $m[2]; chomp($list_id);
@@ -357,376 +408,377 @@ if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOC
$iD[1] = sprintf("%02d", $iD[1]);
$insert_date = "$iD[2]-$iD[0]-$iD[1]";
}
}
if (length($forcelistid) > 0)
{
$list_id = $forcelistid; # set list_id to override value
}
if (length($forcephonecode) > 0)
{
$phone_code = $forcephonecode; # set phone_code to override value
}
if (length($forcelistid) > 0)
{
$list_id = $forcelistid; # set list_id to override value
}
if (length($forcephonecode) > 0)
{
$phone_code = $forcephonecode; # set phone_code to override value
}
##### Check for duplicate phone numbers in vicidial_list table entire database #####
if ($dupchecksys > 0)
##### Check for duplicate phone numbers in vicidial_list table entire database #####
if ($dupchecksys > 0)
{
$dup_lead=0;
$stmtA = "select count(*) from vicidial_list where phone_number='$phone_number';";
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)
{
$dup_lead=0;
$stmtA = "select count(*) from vicidial_list where phone_number='$phone_number';";
@aryA = $sthA->fetchrow_array;
$dup_lead = $aryA[0];
$dup_lead_list=$list_id;
}
$sthA->finish();
if ($dup_lead < 1)
{
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
}
##### Check for duplicate phone numbers in vicidial_list table for one list_id #####
if ($dupcheck > 0)
{
$dup_lead=0;
$stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' 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;
$dup_lead_list = $aryA[0];
$dup_lead++;
}
$sthA->finish();
if ($dup_lead < 1)
{
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
}
##### Check for duplicate phone numbers in vicidial_list table for all lists in a campaign #####
if ($dupcheckcamp > 0)
{
$dup_lead=0;
$dup_lists='';
$stmtA = "select count(*) from vicidial_lists where 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;
$ci_recs = $aryA[0];
$sthA->finish();
if ($ci_recs > 0)
{
$stmtA = "select campaign_id from vicidial_lists where 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_camp = $aryA[0];
$sthA->finish();
$stmtA = "select list_id from vicidial_lists where campaign_id='$dup_camp';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$dup_lead = $aryA[0];
$dup_lead_list=$list_id;
$dup_lists .= "'$aryA[0]',";
$rec_count++;
}
$sthA->finish();
if ($dup_lead < 1)
{
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
}
##### Check for duplicate phone numbers in vicidial_list table for one list_id #####
if ($dupcheck > 0)
{
$dup_lead=0;
$stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' limit 1;";
if($DBX){print STDERR "\n|$stmtA|\n";}
chop($dup_lists);
$stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$dup_lead_list = $aryA[0];
$dup_lead++;
$dup_lead_list = "'$aryA[0]',";
$rec_count++;
$dup_lead=1;
}
$sthA->finish();
if ($dup_lead < 1)
{
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
}
##### Check for duplicate phone numbers in vicidial_list table for all lists in a campaign #####
if ($dupcheckcamp > 0)
if ($dup_lead < 1)
{
$dup_lead=0;
$dup_lists='';
$stmtA = "select count(*) from vicidial_lists where 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;
$ci_recs = $aryA[0];
$sthA->finish();
if ($ci_recs > 0)
{
$stmtA = "select campaign_id from vicidial_lists where 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_camp = $aryA[0];
$sthA->finish();
$stmtA = "select list_id from vicidial_lists where campaign_id='$dup_camp';";
$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;
$dup_lists .= "'$aryA[0]',";
$rec_count++;
}
$sthA->finish();
chop($dup_lists);
$stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;";
$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;
$dup_lead_list = "'$aryA[0]',";
$rec_count++;
$dup_lead=1;
}
$sthA->finish();
}
if ($dup_lead < 1)
{
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
}
if ( (length($phone_number)>6) && ($dup_lead < 1) )
if ( (length($phone_number)>6) && ($dup_lead < 1) )
{
$phone_list .= "$phone_number$US$list_id|";
# set default values
$modify_date = "";
$user = "";
$called_since_last_reset='N';
$gmt_offset = '0';
if ($forcegmt > 0)
{
$phone_list .= "$phone_number$US$list_id|";
# set default values
$modify_date = "";
$user = "";
$called_since_last_reset='N';
$gmt_offset = '0';
if ($forcegmt > 0)
{
$gmt_offset = $m[23]; # set GMT offset value to 24th field value
}
else
{
$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$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
### MEXICO ###
if ($phone_code =~ /^52$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
### AUSTRALIA ###
if ($phone_code =~ /^61$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';";
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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
### ALL OTHER COUNTRY CODES ###
if (!$PC_processed)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
}
### Find out if DST to raise the gmt offset ###
$AC_GMT_diff = ($area_GMT - $LOCAL_GMT_OFF_STD);
$AC_localtime = ($secX + (3600 * $AC_GMT_diff));
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime);
$year = ($year + 1900);
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
$AC_processed=0;
if ( (!$AC_processed) && ($dst_range =~ /SSM-FSN/) )
{
if ($DBX) {print " Second Sunday March to First Sunday November\n";}
&USACAN_dstcalc;
if ($DBX) {print " DST: $USACAN_DST\n";}
if ($USACAN_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) )
{
if ($DBX) {print " First Sunday April to Last Sunday October\n";}
&NA_dstcalc;
if ($DBX) {print " DST: $NA_DST\n";}
if ($NA_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) )
{
if ($DBX) {print " Last Sunday March to Last Sunday October\n";}
&GBR_dstcalc;
if ($DBX) {print " DST: $GBR_DST\n";}
if ($GBR_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) )
{
if ($DBX) {print " Last Sunday October to Last Sunday March\n";}
&AUS_dstcalc;
if ($DBX) {print " DST: $AUS_DST\n";}
if ($AUS_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) )
{
if ($DBX) {print " First Sunday October to Last Sunday March\n";}
&AUST_dstcalc;
if ($DBX) {print " DST: $AUST_DST\n";}
if ($AUST_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) )
{
if ($DBX) {print " First Sunday October to Third Sunday March\n";}
&NZL_dstcalc;
if ($DBX) {print " DST: $NZL_DST\n";}
if ($NZL_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /TSO-LSF/) )
{
if ($DBX) {print " Third Sunday October to Last Sunday February\n";}
&BZL_dstcalc;
if ($DBX) {print " DST: $BZL_DST\n";}
if ($BZL_DST) {$gmt_offset++;}
$AC_processed++;
}
if (!$AC_processed)
{
if ($DBX) {print " No DST Method Found\n";}
if ($DBX) {print " DST: 0\n";}
$AC_processed++;
}
}
if ($multi_insert_counter > 8)
{
### insert good deal into pending_transactions table ###
$stmtZ = "INSERT INTO vicidial_list values$multistmt('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count','2008-01-01 00:00:00');";
if (!$T) {$affected_rows = $dbhA->do($stmtZ); } # or die "Couldn't execute query: |$stmtZ|\n";
if($DB){print STDERR "\n|$affected_rows|$stmtZ|\n";}
$multistmt='';
$multi_insert_counter=0;
$c++;
}
else
{
$multistmt .= "('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count','2008-01-01 00:00:00'),";
$multi_insert_counter++;
}
$b++;
$gmt_offset = $m[23]; # set GMT offset value to 24th field value
}
else
{
if ($dup_lead > 0)
{print "DUPLICATE: $phone|$list_id|$dup_lead_list|"; $f++;}
else
{print "BAD Home_Phone: $phone|$vendor_id"; $e++;}
$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$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
### MEXICO ###
if ($phone_code =~ /^52$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
### AUSTRALIA ###
if ($phone_code =~ /^61$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';";
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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
### ALL OTHER COUNTRY CODES ###
if (!$PC_processed)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_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[4]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[5];
$dst_range = $aryA[6];
$PC_processed++;
$rec_count++;
}
$sthA->finish();
}
}
### Find out if DST to raise the gmt offset ###
$AC_GMT_diff = ($area_GMT - $LOCAL_GMT_OFF_STD);
$AC_localtime = ($secX + (3600 * $AC_GMT_diff));
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime);
$year = ($year + 1900);
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
$AC_processed=0;
if ( (!$AC_processed) && ($dst_range =~ /SSM-FSN/) )
{
if ($DBX) {print " Second Sunday March to First Sunday November\n";}
&USACAN_dstcalc;
if ($DBX) {print " DST: $USACAN_DST\n";}
if ($USACAN_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) )
{
if ($DBX) {print " First Sunday April to Last Sunday October\n";}
&NA_dstcalc;
if ($DBX) {print " DST: $NA_DST\n";}
if ($NA_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) )
{
if ($DBX) {print " Last Sunday March to Last Sunday October\n";}
&GBR_dstcalc;
if ($DBX) {print " DST: $GBR_DST\n";}
if ($GBR_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) )
{
if ($DBX) {print " Last Sunday October to Last Sunday March\n";}
&AUS_dstcalc;
if ($DBX) {print " DST: $AUS_DST\n";}
if ($AUS_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) )
{
if ($DBX) {print " First Sunday October to Last Sunday March\n";}
&AUST_dstcalc;
if ($DBX) {print " DST: $AUST_DST\n";}
if ($AUST_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) )
{
if ($DBX) {print " First Sunday October to Third Sunday March\n";}
&NZL_dstcalc;
if ($DBX) {print " DST: $NZL_DST\n";}
if ($NZL_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /TSO-LSF/) )
{
if ($DBX) {print " Third Sunday October to Last Sunday February\n";}
&BZL_dstcalc;
if ($DBX) {print " DST: $BZL_DST\n";}
if ($BZL_DST) {$gmt_offset++;}
$AC_processed++;
}
if (!$AC_processed)
{
if ($DBX) {print " No DST Method Found\n";}
if ($DBX) {print " DST: 0\n";}
$AC_processed++;
}
}
if ($multi_insert_counter > 8)
{
### insert good deal into pending_transactions table ###
$stmtZ = "INSERT INTO vicidial_list values$multistmt('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count','2008-01-01 00:00:00');";
if (!$T) {$affected_rows = $dbhA->do($stmtZ); } # or die "Couldn't execute query: |$stmtZ|\n";
if($DB){print STDERR "\n|$affected_rows|$stmtZ|\n";}
$multistmt='';
$multi_insert_counter=0;
$c++;
}
else
{
$multistmt .= "('','$insert_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','$called_count','2008-01-01 00:00:00'),";
$multi_insert_counter++;
}
$a++;
$b++;
}
else
{
if ($dup_lead > 0)
{print "DUPLICATE: $phone|$list_id|$dup_lead_list|"; $f++;}
else
{print "BAD Home_Phone: $phone|$vendor_id"; $e++;}
}
if ($a =~ /100$/i) {print STDERR "0 $a\r";}
if ($a =~ /200$/i) {print STDERR "+ $a\r";}
if ($a =~ /300$/i) {print STDERR "| $a\r";}
if ($a =~ /400$/i) {print STDERR "\\ $a\r";}
if ($a =~ /500$/i) {print STDERR "- $a\r";}
if ($a =~ /600$/i) {print STDERR "/ $a\r";}
if ($a =~ /700$/i) {print STDERR "| $a\r";}
if ($a =~ /800$/i) {print STDERR "+ $a\r";}
if ($a =~ /900$/i) {print STDERR "0 $a\r";}
if ($a =~ /000$/i) {print "$a|$b|$c|$d|$e|$phone_number|\n";}
$a++;
if ($a =~ /100$/i) {print STDERR "0 $a\r";}
if ($a =~ /200$/i) {print STDERR "+ $a\r";}
if ($a =~ /300$/i) {print STDERR "| $a\r";}
if ($a =~ /400$/i) {print STDERR "\\ $a\r";}
if ($a =~ /500$/i) {print STDERR "- $a\r";}
if ($a =~ /600$/i) {print STDERR "/ $a\r";}
if ($a =~ /700$/i) {print STDERR "| $a\r";}
if ($a =~ /800$/i) {print STDERR "+ $a\r";}
if ($a =~ /900$/i) {print STDERR "0 $a\r";}
if ($a =~ /000$/i) {print "$a|$b|$c|$d|$e|$phone_number|\n";}
}
if (length($multistmt) > 10)
{
chop($multistmt);
### insert good deal into pending_transactions table ###
$stmtZ = "INSERT INTO vicidial_list values$multistmt;";
if (!$T) {$affected_rows = $dbhA->do($stmtZ); } # or die "Couldn't execute query: |$stmtZ|\n";
if($DB){print STDERR "\n|$affected_rows|$stmtZ|\n";}
if (length($multistmt) > 10)
{
chop($multistmt);
### insert good deal into pending_transactions table ###
$stmtZ = "INSERT INTO vicidial_list values$multistmt;";
if (!$T) {$affected_rows = $dbhA->do($stmtZ); } # or die "Couldn't execute query: |$stmtZ|\n";
if($DB){print STDERR "\n|$affected_rows|$stmtZ|\n";}
$multistmt='';
$multi_insert_counter=0;
$c++;
}
$multistmt='';
$multi_insert_counter=0;
$c++;
}
### open the stats out file for writing ###
open(Sout, ">>$VDHLOGfile")
+3
View File
@@ -4,6 +4,9 @@ This document describes the functions of an API(Application Programming Interfac
for the VICIDIAL Agent screen. This functionality will be rather limited at first
and will be built upon as critical functions are identified and programmed into it.
There is also a new NON-agent API script, for more information on that, please
read the NON-AGENT_API.txt document.
API functions:
+213
View File
@@ -0,0 +1,213 @@
PROCESS FOR LIST SUGGESTIONS FOR ROOM MANAGERS Started: 2008-07-14
This document goes over the process for making suggestions of what lists to use at what time in a special report linked from the vicidial Administration web site(vicidial/admin.php).
The suggestions would group lists usage into eight 3-hour periods for each day according to server time. The actual number of 3-hour periods shown for each list would be restricted depending on the local call time scheme selected for the campaign and the area that the leads were present in.
The list suggestion process would most likely not be real-time, although at companies with small lists that might be possible. Instead, a server process running after-hours will generate statistics and scores for each list for each of the 3-hour periods. Something like the following will be viewable after the stats have been run:
LIST TIME TZ-DIAL% HA-SCORE SALE-SCORE
101 9AM-12PM 100 15 15
101 12PM-3PM 100 25 35 *
101 3PM-6PM 100 35 30
101 6PM-9PM 100 25 20
In the above example, the best time for a manager to call the list, for the highest rate of Human-Answered CONTACT, would be from 3-6PM. Or to maximixe SALEs they might want to call the list earlier at 12PM-3PM. the reason that you only see four 3-hour periods is that this specific list has only US Eastern time-zone leads in it and the campaign time scheme is set to 9AM-9PM so there is no possibility of calling past 9PM server time since the server is located in US Eastern Timezone, but a list with central or mountain time zone leads in it would show a fifth period(9PM-12AM) that would have score next to it(see example below). The Asterisk * is next to the time period that is happening right now, in the actual report that line would be highlighted with a different color.
LIST TIME TZ-DIAL% HA-SCORE SALE-SCORE
102 9AM-12PM 67 20 15
102 12PM-3PM 100 15 15 *
102 3PM-6PM 100 20 25
102 6PM-9PM 100 15 10
102 9PM-12AM 33 30 35
In this example you get some indication of how the TZ-DIAL % will work. In the real application it might be better to use some kind of graph or filled-in sections of the table that would indicate the time ranges and lead percentage covered in each of the time periods to give a better visual of when the leads are able to be dialed.
There will also be the ability to see a comparison of the available lists for the current time period so that a manager can make a decision as to which of those lists to make active.
Factors to be taken into account by the scoring process:
- number of leads in the list
- number of leads in a callable time zone in the list
- number of sales and the sales ratio in each time period
- number of attempts by leads in the list in each time period
- the amount of dead leads(leads that cannot be called anymore) in the list
- the number of calls placed yesterday in the same time period
- the number of Human-Answered leads for each period
Needed database changes:
!!! IMPORTANT !!!
THESE ARE FOR REFERENCE ONLY, DO NOT RUN THEM!!!
ALTER TABLE vicidial_status_categories ADD sale_category ENUM('Y','N') default 'N';
ALTER TABLE vicidial_status_categories ADD dead_lead_category ENUM('Y','N') default 'N';
CREATE TABLE vicidial_lists_suggestions (
list_id BIGINT(14) UNSIGNED PRIMARY KEY NOT NULL,
last_update_time DATETIME,
leads_count INT(9) UNSIGNED,
calls_count INT(9) UNSIGNED,
sales_count INT(9) UNSIGNED,
contacts_count INT(9) UNSIGNED,
period_1_dialable MEDIUMINT(7) UNSIGNED,
period_1_tz_dial_pct TINYINT(3),
period_1_calls MEDIUMINT(7) UNSIGNED,
period_1_sales MEDIUMINT(7) UNSIGNED,
period_1_contacts MEDIUMINT(7) UNSIGNED,
period_1_avg_attempts TINYINT(3) UNSIGNED,
period_1_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_1_score_sale TINYINT(3),
period_1_score_contact TINYINT(3),
period_2_dialable MEDIUMINT(7) UNSIGNED,
period_2_tz_dial_pct TINYINT(3),
period_2_calls MEDIUMINT(7) UNSIGNED,
period_2_sales MEDIUMINT(7) UNSIGNED,
period_2_contacts MEDIUMINT(7) UNSIGNED,
period_2_avg_attempts TINYINT(3) UNSIGNED,
period_2_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_2_score_sale TINYINT(3),
period_2_score_contact TINYINT(3),
period_3_dialable MEDIUMINT(7) UNSIGNED,
period_3_tz_dial_pct TINYINT(3),
period_3_calls MEDIUMINT(7) UNSIGNED,
period_3_sales MEDIUMINT(7) UNSIGNED,
period_3_contacts MEDIUMINT(7) UNSIGNED,
period_3_avg_attempts TINYINT(3) UNSIGNED,
period_3_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_3_score_sale TINYINT(3),
period_3_score_contact TINYINT(3),
period_4_dialable MEDIUMINT(7) UNSIGNED,
period_4_tz_dial_pct TINYINT(3),
period_4_calls MEDIUMINT(7) UNSIGNED,
period_4_sales MEDIUMINT(7) UNSIGNED,
period_4_contacts MEDIUMINT(7) UNSIGNED,
period_4_avg_attempts TINYINT(3) UNSIGNED,
period_4_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_4_score_sale TINYINT(3),
period_4_score_contact TINYINT(3),
period_5_dialable MEDIUMINT(7) UNSIGNED,
period_5_tz_dial_pct TINYINT(3),
period_5_calls MEDIUMINT(7) UNSIGNED,
period_5_sales MEDIUMINT(7) UNSIGNED,
period_5_contacts MEDIUMINT(7) UNSIGNED,
period_5_avg_attempts TINYINT(3) UNSIGNED,
period_5_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_5_score_sale TINYINT(3),
period_5_score_contact TINYINT(3),
period_6_dialable MEDIUMINT(7) UNSIGNED,
period_6_tz_dial_pct TINYINT(3),
period_6_calls MEDIUMINT(7) UNSIGNED,
period_6_sales MEDIUMINT(7) UNSIGNED,
period_6_contacts MEDIUMINT(7) UNSIGNED,
period_6_avg_attempts TINYINT(3) UNSIGNED,
period_6_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_6_score_sale TINYINT(3),
period_6_score_contact TINYINT(3),
period_7_dialable MEDIUMINT(7) UNSIGNED,
period_7_tz_dial_pct TINYINT(3),
period_7_calls MEDIUMINT(7) UNSIGNED,
period_7_sales MEDIUMINT(7) UNSIGNED,
period_7_contacts MEDIUMINT(7) UNSIGNED,
period_7_avg_attempts TINYINT(3) UNSIGNED,
period_7_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_7_score_sale TINYINT(3),
period_7_score_contact TINYINT(3),
period_8_dialable MEDIUMINT(7) UNSIGNED,
period_8_tz_dial_pct TINYINT(3),
period_8_calls MEDIUMINT(7) UNSIGNED,
period_8_sales MEDIUMINT(7) UNSIGNED,
period_8_contacts MEDIUMINT(7) UNSIGNED,
period_8_avg_attempts TINYINT(3) UNSIGNED,
period_8_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_8_score_sale TINYINT(3),
period_8_score_contact TINYINT(3)
);
CREATE TABLE vicidial_lists_suggestion_log (
list_id BIGINT(14) UNSIGNED NOT NULL,
campaign_id VARCHAR(20) NOT NULL,
log_datetime DATETIME NOT NULL,
leads_count INT(9) UNSIGNED,
calls_count INT(9) UNSIGNED,
sales_count INT(9) UNSIGNED,
contacts_count INT(9) UNSIGNED,
period_1_dialable MEDIUMINT(7) UNSIGNED,
period_1_tz_dial_pct TINYINT(3),
period_1_calls MEDIUMINT(7) UNSIGNED,
period_1_sales MEDIUMINT(7) UNSIGNED,
period_1_contacts MEDIUMINT(7) UNSIGNED,
period_1_avg_attempts TINYINT(3) UNSIGNED,
period_1_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_1_score_sale TINYINT(3),
period_1_score_contact TINYINT(3),
period_2_dialable MEDIUMINT(7) UNSIGNED,
period_2_tz_dial_pct TINYINT(3),
period_2_calls MEDIUMINT(7) UNSIGNED,
period_2_sales MEDIUMINT(7) UNSIGNED,
period_2_contacts MEDIUMINT(7) UNSIGNED,
period_2_avg_attempts TINYINT(3) UNSIGNED,
period_2_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_2_score_sale TINYINT(3),
period_2_score_contact TINYINT(3),
period_3_dialable MEDIUMINT(7) UNSIGNED,
period_3_tz_dial_pct TINYINT(3),
period_3_calls MEDIUMINT(7) UNSIGNED,
period_3_sales MEDIUMINT(7) UNSIGNED,
period_3_contacts MEDIUMINT(7) UNSIGNED,
period_3_avg_attempts TINYINT(3) UNSIGNED,
period_3_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_3_score_sale TINYINT(3),
period_3_score_contact TINYINT(3),
period_4_dialable MEDIUMINT(7) UNSIGNED,
period_4_tz_dial_pct TINYINT(3),
period_4_calls MEDIUMINT(7) UNSIGNED,
period_4_sales MEDIUMINT(7) UNSIGNED,
period_4_contacts MEDIUMINT(7) UNSIGNED,
period_4_avg_attempts TINYINT(3) UNSIGNED,
period_4_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_4_score_sale TINYINT(3),
period_4_score_contact TINYINT(3),
period_5_dialable MEDIUMINT(7) UNSIGNED,
period_5_tz_dial_pct TINYINT(3),
period_5_calls MEDIUMINT(7) UNSIGNED,
period_5_sales MEDIUMINT(7) UNSIGNED,
period_5_contacts MEDIUMINT(7) UNSIGNED,
period_5_avg_attempts TINYINT(3) UNSIGNED,
period_5_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_5_score_sale TINYINT(3),
period_5_score_contact TINYINT(3),
period_6_dialable MEDIUMINT(7) UNSIGNED,
period_6_tz_dial_pct TINYINT(3),
period_6_calls MEDIUMINT(7) UNSIGNED,
period_6_sales MEDIUMINT(7) UNSIGNED,
period_6_contacts MEDIUMINT(7) UNSIGNED,
period_6_avg_attempts TINYINT(3) UNSIGNED,
period_6_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_6_score_sale TINYINT(3),
period_6_score_contact TINYINT(3),
period_7_dialable MEDIUMINT(7) UNSIGNED,
period_7_tz_dial_pct TINYINT(3),
period_7_calls MEDIUMINT(7) UNSIGNED,
period_7_sales MEDIUMINT(7) UNSIGNED,
period_7_contacts MEDIUMINT(7) UNSIGNED,
period_7_avg_attempts TINYINT(3) UNSIGNED,
period_7_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_7_score_sale TINYINT(3),
period_7_score_contact TINYINT(3),
period_8_dialable MEDIUMINT(7) UNSIGNED,
period_8_tz_dial_pct TINYINT(3),
period_8_calls MEDIUMINT(7) UNSIGNED,
period_8_sales MEDIUMINT(7) UNSIGNED,
period_8_contacts MEDIUMINT(7) UNSIGNED,
period_8_avg_attempts TINYINT(3) UNSIGNED,
period_8_calls_yesterday MEDIUMINT(7) UNSIGNED,
period_8_score_sale TINYINT(3),
period_8_score_contact TINYINT(3),
index (list_id),
index (campaign_id),
index (log_datetime)
);
+84
View File
@@ -0,0 +1,84 @@
NON-AGENT API DOCUMENT 2008-07-24
This document describes the functions of an API(Application Programming Interface)
for all functions NOT relating to the VICIDIAL Agent screen. This functionality
will be rather limited at first and will be built upon as critical functions are
identified and programmed into it.
There is also a new agent API script, for more information on that, please read
the AGENT_API.txt document.
New scripts:
/vicidial/non_agent_api.php - the script that is accessed to execute commands
API Functions:
NOTE: Just as with the Agent API, the non-agent API requires the user and pass of a
valid api-enabled vicidial_users account to execute actions.
add_lead - adds a new lead to the vicidial_list table with several fields and options
NOTE: api user for this function must have modify_leads set to 1
REQUIRED FIELDS-
phone_number - must be all numbers, 6-16 digits
phone_code - must be all numbers, 1-4 digits, defaults to 1 if not set
list_id - must be all numbers, 3-12 digits, defaults to 999 if not set
SETTINGS FIELDS-
dnc_check - Y or N, default is N
add_to_hopper - Y or N, default is N
hopper_priority - 99 to -99, the higher number the higher priority, default is 0
hopper_local_call_time_check - Y or N, default is N. Validate the local call time before inserting lead in the hopper
OPTIONAL FIELDS-
vendor_lead_code - 1-20 characters
source_id - 1-50 characters
gmt_offset_now - overridden by auto-lookup of phone_code and area_code portion of phone number if applicable
title - 1-4 characters
first_name - 1-30 characters
middle_initial - 1 character
last_name - 1-30 characters
address1 - 1-100 characters
address2 - 1-100 characters
address3 - 1-100 characters
city - 1-50 characters
state - 2 characters
province - 1-50 characters
postal_code - 1-10 characters
country_code - 3 characters
gender - U, M, F (Undefined, Male, Female) - defaults to 'U'
date_of_birth - YYYY-MM-DD
alt_phone - 1-12 characters
email - 1-70 characters
security_phrase - 1-100 characters
comments - 1-255 characters
Example URL strings for API calls:
http://server/vicidial/non_agent_api.php?user=6666&pass=1234&function=add_lead&phone_number=7275551111
http://server/vicidial/non_agent_api.php?user=6666&pass=1234&function=add_lead&phone_number=7275551212&phone_code=1&list_id=999&dnc_check=N&first_name=Bob&last_name=Wilson
http://server/vicidial/non_agent_api.php?user=6666&pass=1234&function=add_lead&phone_number=7275551111&phone_code=1&list_id=999&dnc_check=N&first_name=Bob&last_name=Wilson&add_to_hopper=Y&hopper_local_call_time_check=Y
Example responses:
SUCCESS: add_lead LEAD HAS BEEN ADDED - 7275551111|6666|999|193715|-4
NOTICE: add_lead ADDED TO HOPPER - 7275551111|6666|193715|1677922
SUCCESS: add_lead LEAD HAS BEEN ADDED - 7275551111|6666|999|193716|-4
NOTICE: add_lead NOT ADDED TO HOPPER, OUTSIDE OF LOCAL TIME - 7275551111|6666|193716|-4|0
ERROR: add_lead INVALID PHONE NUMBER - 72755|6666
ERROR: add_lead USER DOES NOT HAVE PERMISSION TO ADD LEADS TO THE SYSTEM - 6666|0
+4
View File
@@ -66,6 +66,10 @@ if ($non_latin < 1)
$user=ereg_replace("[^0-9a-zA-Z]","",$user);
$pass=ereg_replace("[^0-9a-zA-Z]","",$pass);
$agent_user=ereg_replace("[^0-9a-zA-Z]","",$agent_user);
$function = ereg_replace("[^-\_0-9a-zA-Z]","",$function);
$value = ereg_replace("[^-\_0-9a-zA-Z]","",$value);
$extra_value = ereg_replace("[^-\_0-9a-zA-Z]","",$extra_value);
$format = ereg_replace("[^0-9a-zA-Z]","",$format);
}
$StarTtime = date("U");
File diff suppressed because it is too large Load Diff