Added --query-count-test flag option to cold-storage script

Added archive_type option to admin_search_lead.php script
Updated documentation

git-svn-id: svn://192.168.202.10@3845 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2024-07-05 13:57:21 +00:00
parent f2eb9b4bec
commit ac5036ee15
3 changed files with 260 additions and 702 deletions
+21 -560
View File
@@ -20,11 +20,13 @@
#
# CHANGES
# 240704-1815 - First version
# 250705-0954 - Added --query-count-test flag option
#
$DB=0;
$DBX=0;
$CALC_TEST=0;
$QUERY_COUNT_TEST=0;
$T=0; $TEST=0;
$only_trim_archive=0;
$recording_log_archive=0;
@@ -52,6 +54,7 @@ if (length($ARGV[0])>1)
print " [--days=XX] = number of days to archive past, default is 1461(4 years)\n";
print " [--quiet] = quiet\n";
print " [--calc-test] = date calculation test only\n";
print " [--query-count-test] = run archive counts test only\n";
print " [--test] = test\n";
print " [--debug] = debug output for some options\n";
print " [--debugX] = extra debug output for some options\n";
@@ -82,7 +85,12 @@ if (length($ARGV[0])>1)
if ($args =~ /--calc-test/i)
{
$CALC_TEST=1;
print "\n-----DATE CALCULATION TESTING ONLY-----\n\n";
print "\n-----DATE CALCULATION TESTING ONLY: $CALC_TEST-----\n\n";
}
if ($args =~ /--query-count-test/i)
{
$QUERY_COUNT_TEST=1;
print "\n-----ARCHIVE TABLES QUERY COUNT TESTING ONLY: $QUERY_COUNT_TEST-----\n\n";
}
if ($args =~ /--days=/i)
{
@@ -265,7 +273,7 @@ if (!$T)
if (!$Q) {print "\nAnalyzing call_log_archive table... ($call_log_archive_count|$call_log_CS_count)\n";}
if ($call_log_archive_count < 1)
if ( ($call_log_archive_count < 1) || ($QUERY_COUNT_TEST > 0) )
{
if (!$Q) {print "call_log_archive has no records to send to cold-storage, skipping this table...\n";}
}
@@ -420,7 +428,7 @@ if (!$T)
if (!$Q) {print "\nAnalyzing vicidial_log_archive table... ($vicidial_log_archive_count|$call_log_CS_count)\n";}
if ($vicidial_log_archive_count < 1)
if ( ($vicidial_log_archive_count < 1) || ($QUERY_COUNT_TEST > 0) )
{
if (!$Q) {print "vicidial_log_archive has no records to send to cold-storage, skipping this table...\n";}
}
@@ -575,7 +583,7 @@ if (!$T)
if (!$Q) {print "\nAnalyzing vicidial_log_extended_archive table... ($vicidial_log_extended_archive_count|$call_log_CS_count)\n";}
if ($vicidial_log_extended_archive_count < 1)
if ( ($vicidial_log_extended_archive_count < 1) || ($QUERY_COUNT_TEST > 0) )
{
if (!$Q) {print "vicidial_log_extended_archive has no records to send to cold-storage, skipping this table...\n";}
}
@@ -730,7 +738,7 @@ if (!$T)
if (!$Q) {print "\nAnalyzing vicidial_dial_log_archive table... ($vicidial_dial_log_archive_count|$call_log_CS_count)\n";}
if ($vicidial_dial_log_archive_count < 1)
if ( ($vicidial_dial_log_archive_count < 1) || ($QUERY_COUNT_TEST > 0) )
{
if (!$Q) {print "vicidial_dial_log_archive has no records to send to cold-storage, skipping this table...\n";}
}
@@ -885,7 +893,7 @@ if (!$T)
if (!$Q) {print "\nAnalyzing vicidial_carrier_log_archive table... ($vicidial_carrier_log_archive_count|$call_log_CS_count)\n";}
if ($vicidial_carrier_log_archive_count < 1)
if ( ($vicidial_carrier_log_archive_count < 1) || ($QUERY_COUNT_TEST > 0) )
{
if (!$Q) {print "vicidial_carrier_log_archive has no records to send to cold-storage, skipping this table...\n";}
}
@@ -1040,7 +1048,7 @@ if (!$T)
if (!$Q) {print "\nAnalyzing vicidial_dial_cid_log_archive table... ($vicidial_dial_cid_log_archive_count|$call_log_CS_count)\n";}
if ($vicidial_dial_cid_log_archive_count < 1)
if ( ($vicidial_dial_cid_log_archive_count < 1) || ($QUERY_COUNT_TEST > 0) )
{
if (!$Q) {print "vicidial_dial_cid_log_archive has no records to send to cold-storage, skipping this table...\n";}
}
@@ -1195,7 +1203,7 @@ if (!$T)
if (!$Q) {print "\nAnalyzing vicidial_amd_log_archive table... ($vicidial_amd_log_archive_count|$call_log_CS_count)\n";}
if ($vicidial_amd_log_archive_count < 1)
if ( ($vicidial_amd_log_archive_count < 1) || ($QUERY_COUNT_TEST > 0) )
{
if (!$Q) {print "vicidial_amd_log_archive has no records to send to cold-storage, skipping this table...\n";}
}
@@ -1350,7 +1358,7 @@ if (!$T)
if (!$Q) {print "\nAnalyzing vicidial_agent_log_archive table... ($vicidial_agent_log_archive_count|$call_log_CS_count)\n";}
if ($vicidial_agent_log_archive_count < 1)
if ( ($vicidial_agent_log_archive_count < 1) || ($QUERY_COUNT_TEST > 0) )
{
if (!$Q) {print "vicidial_agent_log_archive has no records to send to cold-storage, skipping this table...\n";}
}
@@ -1505,7 +1513,7 @@ if (!$T)
if (!$Q) {print "\nAnalyzing vicidial_api_log_archive table... ($vicidial_api_log_archive_count|$call_log_CS_count)\n";}
if ($vicidial_api_log_archive_count < 1)
if ( ($vicidial_api_log_archive_count < 1) || ($QUERY_COUNT_TEST > 0) )
{
if (!$Q) {print "vicidial_api_log_archive has no records to send to cold-storage, skipping this table...\n";}
}
@@ -1660,7 +1668,7 @@ if (!$T)
if (!$Q) {print "\nAnalyzing vicidial_api_urls_archive table... ($vicidial_api_urls_archive_count|$call_log_CS_count)\n";}
if ($vicidial_api_urls_archive_count < 1)
if ( ($vicidial_api_urls_archive_count < 1) || ($QUERY_COUNT_TEST > 0) )
{
if (!$Q) {print "vicidial_api_urls_archive has no records to send to cold-storage, skipping this table...\n";}
}
@@ -1815,7 +1823,7 @@ if (!$T)
if (!$Q) {print "\nAnalyzing vicidial_agent_visibility_log_archive table... ($vicidial_agent_visibility_log_archive_count|$call_log_CS_count)\n";}
if ($vicidial_agent_visibility_log_archive_count < 1)
if ( ($vicidial_agent_visibility_log_archive_count < 1) || ($QUERY_COUNT_TEST > 0) )
{
if (!$Q) {print "vicidial_agent_visibility_log_archive has no records to send to cold-storage, skipping this table...\n";}
}
@@ -1945,12 +1953,6 @@ if (!$T)
if ($SSsip_event_logging > 0)
{
##### BEGIN vicidial_log_extended_sip_archive cold-storage processing #####
@@ -1980,7 +1982,7 @@ if (!$T)
if (!$Q) {print "\nAnalyzing vicidial_log_extended_sip_archive table... ($vicidial_log_extended_sip_archive_count|$call_log_CS_count)\n";}
if ($vicidial_log_extended_sip_archive_count < 1)
if ( ($vicidial_log_extended_sip_archive_count < 1) || ($QUERY_COUNT_TEST > 0) )
{
if (!$Q) {print "vicidial_log_extended_sip_archive has no records to send to cold-storage, skipping this table...\n";}
}
@@ -2108,547 +2110,6 @@ if (!$T)
##### END vicidial_log_extended_sip_archive cold-storage processing #####
}
### calculate time to run script ###
$secY = time();
$secZ = ($secY - $secX);
$secZm = ($secZ /60);
if (!$Q) {print "\nscript execution time in seconds: $secZ minutes: $secZm\n";}
exit;
if ($SSsip_event_logging > 0)
{
##### BEGIN vicidial_log_extended_sip DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_log_extended_sip;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_log_extended_sip_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_log_extended_sip_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_log_extended_sip_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_log_extended_sip table... ($vicidial_log_extended_sip_count|$vicidial_log_extended_sip_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_log_extended_sip_archive SELECT * from vicidial_log_extended_sip;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_log_extended_sip_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_log_extended_sip WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_log_extended_sip table \n";}
$stmtA = "optimize table vicidial_log_extended_sip;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_log_extended_sip DAILY processing #####
}
##### BEGIN vicidial_drop_log DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_drop_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_drop_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_drop_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_drop_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_drop_log table... ($vicidial_drop_log_count|$vicidial_drop_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_drop_log_archive SELECT * from vicidial_drop_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_drop_log_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_drop_log WHERE drop_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_drop_log table \n";}
$stmtA = "optimize table vicidial_drop_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_drop_log DAILY processing #####
##### BEGIN vicidial_dial_log DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_dial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_dial_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_dial_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_dial_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_dial_log table... ($vicidial_dial_log_count|$vicidial_dial_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_dial_log_archive SELECT * from vicidial_dial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_dial_log_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_dial_log WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_dial_log table \n";}
$stmtA = "optimize table vicidial_dial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_dial_log DAILY processing #####
##### BEGIN vicidial_user_dial_log DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_user_dial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_user_dial_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_user_dial_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_user_dial_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_user_dial_log table... ($vicidial_user_dial_log_count|$vicidial_user_dial_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_user_dial_log_archive SELECT * from vicidial_user_dial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_user_dial_log_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_user_dial_log WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_user_dial_log table \n";}
$stmtA = "optimize table vicidial_user_dial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_user_dial_log DAILY processing #####
##### BEGIN vicidial_dial_cid_log DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_dial_cid_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_dial_cid_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_dial_cid_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_dial_cid_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_dial_cid_log table... ($vicidial_dial_cid_log_count|$vicidial_dial_cid_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_dial_cid_log_archive SELECT * from vicidial_dial_cid_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_dial_cid_log_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_dial_cid_log WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_dial_cid_log table \n";}
$stmtA = "optimize table vicidial_dial_cid_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_dial_cid_log DAILY processing #####
##### BEGIN vicidial_api_log DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_api_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_api_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_api_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_api_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_api_log table... ($vicidial_api_log_count|$vicidial_api_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_api_log_archive SELECT * from vicidial_api_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_api_log_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_api_log WHERE api_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_api_log table \n";}
$stmtA = "optimize table vicidial_api_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$stmtA = "optimize table vicidial_api_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_api_log DAILY processing #####
##### BEGIN vicidial_api_urls DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_api_urls;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_api_urls_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_api_urls_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_api_urls_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_api_urls table... ($vicidial_api_urls_count|$vicidial_api_urls_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_api_urls_archive SELECT * from vicidial_api_urls;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_api_urls_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_api_urls WHERE api_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_api_urls table \n";}
$stmtA = "optimize table vicidial_api_urls;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$stmtA = "optimize table vicidial_api_urls_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_api_urls DAILY processing #####
if ($carrier_daily)
{
##### BEGIN vicidial_carrier_log DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_carrier_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_carrier_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_carrier_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_carrier_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_carrier_log table... ($vicidial_carrier_log_count|$vicidial_carrier_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_carrier_log_archive SELECT * from vicidial_carrier_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_carrier_log_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_carrier_log WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_carrier_log table \n";}
$stmtA = "optimize table vicidial_carrier_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$stmtA = "optimize table vicidial_carrier_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_carrier_log DAILY processing #####
}
if ($vlog_daily)
{
##### BEGIN vicidial_log DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_log table... ($vicidial_log_count|$vicidial_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_log_archive SELECT * from vicidial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_log_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_log WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_log table \n";}
$stmtA = "optimize table vicidial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$stmtA = "optimize table vicidial_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_log DAILY processing #####
##### BEGIN vicidial_amd_log DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_amd_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_amd_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_amd_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_amd_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_amd_log table... ($vicidial_amd_log_count|$vicidial_amd_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_amd_log_archive SELECT * from vicidial_amd_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_amd_log_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_amd_log WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_amd_log table \n";}
$stmtA = "optimize table vicidial_amd_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$stmtA = "optimize table vicidial_amd_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_amd_log DAILY processing #####
}
### calculate time to run script ###
$secY = time();
$secZ = ($secY - $secX);
$secZm = ($secZ /60);
if (!$Q) {print "\nscript execution time in seconds: $secZ minutes: $secZm\n";}
exit;
}
+78 -2
View File
@@ -1,4 +1,4 @@
LOG ARCHIVING AND COLD STORAGE DOC Started: 2024-07-04 Updated: 2024-07-04
LOG ARCHIVING AND COLD STORAGE DOC Started: 2024-07-04 Updated: 2024-07-05
This document covers the options for archiving of specific log tables and the new "Cold Storage" features
@@ -51,6 +51,8 @@ allowed run time options:
Here are some example crorntab entries for this script to perform certain log archiving and purging:
(these should only be active on a single server on your VICIdial cluster)
WARNING! Do not schedule any ADMIN_archive_log_tables.pl processes to be running at the same time as any ADMIN_cold_storage_log_tables.pl processes!
### archive logs weekly on Saturday morning at 1am, keep only 2 years of logs in the active log tables, archive older log records
20 1 * * 6 /usr/share/astguiclient/ADMIN_archive_log_tables.pl --months=24
@@ -86,7 +88,6 @@ Admin access to cold-storage logs is currently available through the following p
The "ADMIN_cold_storage_log_tables.pl" script was added to move archived log records from the primary database to a separate "cold storage" database server. This "cold storage" database server should have the standard vicidial log tables loaded on it, BUT it should NEVER have any live agents or calls running through it, the purpose of this "cold storage" database server is ONLY for storage of old log records. The archived log records on the "cold storage" database server will be stored in the same "_archive" log tables that they were on the primary database server, the reasons for this are: to make programming these features easier, to allow for easier integration of cold-storage logs into existing reporting and admin utilities, and to possibly allow for multiple-level cold-storage in the future.
We added new settings to the /etc/astguiclient.conf file that will run the "ADMIN_cold_storage_log_tables.pl" script, these credentials should allow for read-write access(see example "GRANT" statement below):
@@ -124,11 +125,17 @@ allowed run time options:
[--days=XX] = number of days to archive past, default is 1461(4 years)
[--quiet] = quiet
[--calc-test] = date calculation test only
[--query-count-test] = run archive counts test only
[--test] = test
[--debug] = debug output for some options
[--debugX] = extra debug output for some options
WARNING! Do not schedule any ADMIN_cold_storage_log_tables.pl processes to be running at the same time as any ADMIN_archive_log_tables.pl processes!
NOTE: If you have never run the "ADMIN_cold_storage_log_tables.pl" script before, we strongly recommend running it manually and with the "--query-count-test" flag first so you can see how many archive records will be affected, and if the server you are running the script on has enough memory to allow it to run. If there are too many records to be sent to cold-storage in any single table, then the script will die with only the message "Killed" on the screen when it happens. For example, if you are running the script on a server with only 8GB of RAM, then moving more than 25,000,000 records to cold-storage in any single table will most likely be too many, so you'll have to adjust the "--days=X" flag to lower the number so it can run to completion. After getting to the level you want to maintain in the archive tables, you can schedule this script to run in your crontab perhaps once a week or once a month during low system utilization periods.
Here is a list of the archive tables that are currently moved by the "ADMIN_cold_storage_log_tables.pl" script:
call_log_archive
@@ -143,3 +150,72 @@ vicidial_dial_log_archive
vicidial_log_archive
vicidial_log_extended_archive
vicidial_log_extended_sip_archive
Here is example output of this script being run on one of our test development systems:
# /usr/share/astguiclient/ADMIN_cold_storage_log_tables.pl --debug --days=1600 --query-count-test
-----DEBUG-----
-----ARCHIVE TABLES QUERY COUNT TESTING ONLY: 1-----
----- DAYS OVERRIDE: 1600 -----
-- ADMIN_cold_storage_log_tables.pl --
This script is designed take records of a specific age from call_log_archive,
vicidial_log_archive, vicidial_log_extended_archive and
other _archive tables and move them to the cold-storage log database, then
delete the records in original tables older than X days
1600 days ( 2020-02-17 07:26:25 [2020-02-17]|1581942385 ) from current date
Cold-Storage Database test: 1
Starting cold-storage process...
Analyzing call_log_archive table... (2|7544031)
call_log_archive has no records to send to cold-storage, skipping this table...
Analyzing vicidial_log_archive table... (21762085|27201201)
vicidial_log_archive has no records to send to cold-storage, skipping this table...
Analyzing vicidial_log_extended_archive table... (11188151|0)
vicidial_log_extended_archive has no records to send to cold-storage, skipping this table...
Analyzing vicidial_dial_log_archive table... (11370308|0)
vicidial_dial_log_archive has no records to send to cold-storage, skipping this table...
Analyzing vicidial_carrier_log_archive table... (11148895|0)
vicidial_carrier_log_archive has no records to send to cold-storage, skipping this table...
Analyzing vicidial_dial_cid_log_archive table... (0|0)
vicidial_dial_cid_log_archive has no records to send to cold-storage, skipping this table...
Analyzing vicidial_amd_log_archive table... (13|0)
vicidial_amd_log_archive has no records to send to cold-storage, skipping this table...
Analyzing vicidial_agent_log_archive table... (92743|270581)
vicidial_agent_log_archive has no records to send to cold-storage, skipping this table...
Analyzing vicidial_api_log_archive table... (74|0)
vicidial_api_log_archive has no records to send to cold-storage, skipping this table...
Analyzing vicidial_api_urls_archive table... (74|0)
vicidial_api_urls_archive has no records to send to cold-storage, skipping this table...
Analyzing vicidial_agent_visibility_log_archive table... (0|0)
vicidial_agent_visibility_log_archive has no records to send to cold-storage, skipping this table...
Analyzing vicidial_log_extended_sip_archive table... (524953|0)
vicidial_log_extended_sip_archive has no records to send to cold-storage, skipping this table...
script execution time in seconds: 19 minutes: 0.316666666666667
+161 -140
View File
@@ -56,6 +56,7 @@
# 220303-0124 - Fix for Issue #1353
# 220331-0926 - Small fix for $phone variable filtering
# 240704-2358 - Added cold-storage archive logs search option
# 240705-0849 - Added archive_type option
#
require("dbconnect_mysqli.php");
@@ -105,6 +106,8 @@ if (isset($_GET["archive_search"])) {$archive_search=$_GET["archive_search"];}
elseif (isset($_POST["archive_search"])) {$archive_search=$_POST["archive_search"];}
if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];}
elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];}
if (isset($_GET["archive_type"])) {$archive_type=$_GET["archive_type"];}
elseif (isset($_POST["archive_type"])) {$archive_type=$_POST["archive_type"];}
$report_name = 'Search Leads Logs';
@@ -172,6 +175,7 @@ $owner = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$owner);
$alt_phone_search = preg_replace('/[^-_0-9a-zA-Z]/', '', $alt_phone_search);
$archive_search = preg_replace('/[^-_0-9a-zA-Z]/', '', $archive_search);
$called_count = preg_replace('/[^0-9]/','',$called_count);
$archive_type = preg_replace('/[^-_0-9a-zA-Z]/', '', $archive_type);
if ($non_latin < 1)
{
@@ -464,8 +468,22 @@ if ( (!$vendor_id) and (!$phone) and (!$lead_id) and (!$log_phone) and (!$log_
echo "</TR>";
echo "<TR bgcolor=#$SSmenu_background>";
echo "<TD colspan=3 align=center><font color=#FFFFFF><b>"._QXZ("Archived Log Search Options").":</b></font></TD>";
echo "</TR><TR bgcolor=#$SSstd_row2_background>";
if ( (strlen($SScoldstorage_server_ip) > 1) and (strlen($SScoldstorage_login) > 0) and (strlen($SScoldstorage_pass) > 0) )
{
if (strlen($archive_type) < 1) {$archive_type = 'ARCHIVE';}
echo "</TR><TR bgcolor=#$SSstd_row2_background>";
echo "<TD ALIGN=right>"._QXZ("Archive Type").": &nbsp; </TD><TD ALIGN=left><select size=1 name=archive_type><option value='ARCHIVE'>"._QXZ("Archive Only")."</option><option value='COLDSTORAGE'>"._QXZ("Cold-Storage Only")."</option><option value='ARCHIVE_AND_COLDSTORAGE'>"._QXZ("Archive and Cold-Storage")."</option><option SELECTED value='$archive_type'>"._QXZ("$archive_type")."</option></select></TD>";
echo "</TR><TR bgcolor=#$SSmenu_background>";
echo "<TD colspan=3 align=center height=1></TD>";
}
else
{
echo "</TR><TR>";
echo "<TD ALIGN=right></TD><TD ALIGN=left><input type=hidden name=archive_type value='ARCHIVE'></TD>";
}
echo "</TR><TR bgcolor=#$SSstd_row2_background>";
echo "<TD ALIGN=right>"._QXZ("Lead ID").": &nbsp; </TD><TD ALIGN=left><input type=text name=log_lead_id_archive size=10 maxlength=10></TD>";
echo "<TD><INPUT TYPE=SUBMIT NAME=SUBMIT VALUE='"._QXZ("SUBMIT")."'></TD>\n";
echo "</TR><TR bgcolor=#$SSmenu_background>";
@@ -736,7 +754,7 @@ else
##### BEGIN Log archive search #####
if ( (strlen($log_lead_id_archive)>0) or (strlen($log_phone_archive)>0) )
{
if ( (strlen($SScoldstorage_server_ip) > 1) and (strlen($SScoldstorage_login) > 0) and (strlen($SScoldstorage_pass) > 0) )
if ( (strlen($SScoldstorage_server_ip) > 1) and (strlen($SScoldstorage_login) > 0) and (strlen($SScoldstorage_pass) > 0) and (preg_match("/COLDSTORAGE/",$archive_type)) )
{
$linkCS = mysqli_connect("$SScoldstorage_server_ip", "$SScoldstorage_login", "$SScoldstorage_pass", "$SScoldstorage_dbname", $SScoldstorage_port);
if (!$linkCS) {echo "MySQL Cold-Storage connect ERROR: " . mysqli_connect_error();}
@@ -764,156 +782,31 @@ else
echo "<!-- Using slave server $slave_db_server $db_source -->\n";
}
$rslt=mysql_to_mysqli("$stmtA", $link);
$results_to_print = mysqli_num_rows($rslt);
if ( ($results_to_print < 1) and ($results_to_printX < 1) )
if (preg_match("/ARCHIVE/",$archive_type))
{
echo "\n<br><br><center>\n";
echo "<b>"._QXZ("There are no archived outbound calls matching your search criteria")."</b><br><br>\n";
echo "</center>\n";
}
else
{
echo "<BR><b>"._QXZ("OUTBOUND ARCHIVED LOG RESULTS").": $results_to_print</b><BR>\n";
echo "<TABLE BGCOLOR=WHITE CELLPADDING=1 CELLSPACING=0 WIDTH=770>\n";
echo "<TR BGCOLOR=BLACK>\n";
echo "<TD ALIGN=LEFT VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>#</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("LEAD ID")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("PHONE")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("CAMPAIGN")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("CALL DATE")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("STATUS")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("USER")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("LIST ID")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("LENGTH")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("DIAL")."</B></FONT></TD>\n";
echo "</TR>\n";
$o=0;
while ($results_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($LOGadmin_hide_phone_data != '0')
{
if ($DB > 0) {echo "HIDEPHONEDATA|$row[1]|$LOGadmin_hide_phone_data|\n";}
$phone_temp = $row[1];
if (strlen($phone_temp) > 0)
{
if ($LOGadmin_hide_phone_data == '4_DIGITS')
{$row[1] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);}
elseif ($LOGadmin_hide_phone_data == '3_DIGITS')
{$row[1] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);}
elseif ($LOGadmin_hide_phone_data == '2_DIGITS')
{$row[1] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);}
else
{$row[1] = preg_replace("/./",'X',$phone_temp);}
}
}
$o++;
$search_lead = $row[0];
if (preg_match('/1$|3$|5$|7$|9$/i', $o))
{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';}
else
{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
echo "<TR $bgcolor>\n";
echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$o</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1><A HREF=\"admin_modify_lead.php?lead_id=$row[0]&archive_search=$archive_search&archive_log=$log_archive_link\" onclick=\"javascript:window.open('admin_modify_lead.php?lead_id=$row[0]&archive_search=$archive_search&archive_log=$log_archive_link', '_blank');return false;\">$row[0]</A></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[1]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[2]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[3]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[4]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[5]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[6]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[7]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[8]</FONT></TD>\n";
echo "</TR>\n";
}
echo "</TABLE>\n";
}
$rslt=mysql_to_mysqli("$stmtB", $link);
$results_to_print = mysqli_num_rows($rslt);
if ( ($results_to_print < 1) and ($results_to_printX < 1) )
{
echo "\n<br><br><center>\n";
echo "<b>"._QXZ("There are no archived inbound calls matching your search criteria")."</b><br><br>\n";
echo "</center>\n";
}
else
{
echo "<BR><b>"._QXZ("INBOUND ARCHIVED LOG RESULTS").": $results_to_print</b><BR>\n";
echo "<TABLE BGCOLOR=WHITE CELLPADDING=1 CELLSPACING=0 WIDTH=770>\n";
echo "<TR BGCOLOR=BLACK>\n";
echo "<TD ALIGN=LEFT VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>#</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("LEAD ID")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("PHONE")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("INGROUP")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("CALL DATE")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("STATUS")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("USER")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("LIST ID")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("LENGTH")."</B> &nbsp;</FONT></TD>\n";
echo "</TR>\n";
$o=0;
while ($results_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($LOGadmin_hide_phone_data != '0')
{
if ($DB > 0) {echo "HIDEPHONEDATA|$row[1]|$LOGadmin_hide_phone_data|\n";}
$phone_temp = $row[1];
if (strlen($phone_temp) > 0)
{
if ($LOGadmin_hide_phone_data == '4_DIGITS')
{$row[1] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);}
elseif ($LOGadmin_hide_phone_data == '3_DIGITS')
{$row[1] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);}
elseif ($LOGadmin_hide_phone_data == '2_DIGITS')
{$row[1] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);}
else
{$row[1] = preg_replace("/./",'X',$phone_temp);}
}
}
$o++;
$search_lead = $row[0];
if (preg_match('/1$|3$|5$|7$|9$/i', $o))
{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';}
else
{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
echo "<TR $bgcolor>\n";
echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$o</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1><A HREF=\"admin_modify_lead.php?lead_id=$row[0]&archive_search=$archive_search&archive_log=$log_archive_link\" onclick=\"javascript:window.open('admin_modify_lead.php?lead_id=$row[0]&archive_search=$archive_search&archive_log=$log_archive_link', '_blank');return false;\">$row[0]</A></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[1]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[2]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[3]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[4]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[5]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[6]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[7]</FONT></TD>\n";
echo "</TR>\n";
}
echo "</TABLE>\n";
}
if (strlen($stmtC) > 10)
{
$rslt=mysql_to_mysqli("$stmtC", $link);
$rslt=mysql_to_mysqli("$stmtA", $link);
$results_to_print = mysqli_num_rows($rslt);
if ( ($results_to_print < 1) and ($results_to_printX < 1) )
{
echo "\n<br><br><center>\n";
echo "<b>"._QXZ("There are no archived inbound did calls matching your search criteria")."</b><br><br>\n";
echo "<b>"._QXZ("There are no archived outbound calls matching your search criteria")."</b><br><br>\n";
echo "</center>\n";
}
else
{
echo "<BR><b>"._QXZ("INBOUND DID ARCHIVED LOG RESULTS").": $results_to_print</b><BR>\n";
echo "<BR><b>"._QXZ("OUTBOUND ARCHIVED LOG RESULTS").": $results_to_print</b><BR>\n";
echo "<TABLE BGCOLOR=WHITE CELLPADDING=1 CELLSPACING=0 WIDTH=770>\n";
echo "<TR BGCOLOR=BLACK>\n";
echo "<TD ALIGN=LEFT VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>#</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("DID")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("LEAD ID")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("PHONE")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("DID ID")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("CAMPAIGN")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("CALL DATE")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("STATUS")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("USER")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("LIST ID")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("LENGTH")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("DIAL")."</B></FONT></TD>\n";
echo "</TR>\n";
$o=0;
while ($results_to_print > $o)
@@ -943,18 +836,146 @@ else
{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
echo "<TR $bgcolor>\n";
echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$o</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[0]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1><A HREF=\"admin_modify_lead.php?lead_id=$row[0]&archive_search=$archive_search&archive_log=$log_archive_link\" onclick=\"javascript:window.open('admin_modify_lead.php?lead_id=$row[0]&archive_search=$archive_search&archive_log=$log_archive_link', '_blank');return false;\">$row[0]</A></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[1]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[2]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[3]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[4]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[5]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[6]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[7]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[8]</FONT></TD>\n";
echo "</TR>\n";
}
echo "</TABLE>\n";
}
$rslt=mysql_to_mysqli("$stmtB", $link);
$results_to_print = mysqli_num_rows($rslt);
if ( ($results_to_print < 1) and ($results_to_printX < 1) )
{
echo "\n<br><br><center>\n";
echo "<b>"._QXZ("There are no archived inbound calls matching your search criteria")."</b><br><br>\n";
echo "</center>\n";
}
else
{
echo "<BR><b>"._QXZ("INBOUND ARCHIVED LOG RESULTS").": $results_to_print</b><BR>\n";
echo "<TABLE BGCOLOR=WHITE CELLPADDING=1 CELLSPACING=0 WIDTH=770>\n";
echo "<TR BGCOLOR=BLACK>\n";
echo "<TD ALIGN=LEFT VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>#</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("LEAD ID")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("PHONE")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("INGROUP")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("CALL DATE")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("STATUS")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("USER")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("LIST ID")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("LENGTH")."</B> &nbsp;</FONT></TD>\n";
echo "</TR>\n";
$o=0;
while ($results_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($LOGadmin_hide_phone_data != '0')
{
if ($DB > 0) {echo "HIDEPHONEDATA|$row[1]|$LOGadmin_hide_phone_data|\n";}
$phone_temp = $row[1];
if (strlen($phone_temp) > 0)
{
if ($LOGadmin_hide_phone_data == '4_DIGITS')
{$row[1] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);}
elseif ($LOGadmin_hide_phone_data == '3_DIGITS')
{$row[1] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);}
elseif ($LOGadmin_hide_phone_data == '2_DIGITS')
{$row[1] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);}
else
{$row[1] = preg_replace("/./",'X',$phone_temp);}
}
}
$o++;
$search_lead = $row[0];
if (preg_match('/1$|3$|5$|7$|9$/i', $o))
{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';}
else
{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
echo "<TR $bgcolor>\n";
echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$o</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1><A HREF=\"admin_modify_lead.php?lead_id=$row[0]&archive_search=$archive_search&archive_log=$log_archive_link\" onclick=\"javascript:window.open('admin_modify_lead.php?lead_id=$row[0]&archive_search=$archive_search&archive_log=$log_archive_link', '_blank');return false;\">$row[0]</A></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[1]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[2]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[3]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[4]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[5]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[6]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[7]</FONT></TD>\n";
echo "</TR>\n";
}
echo "</TABLE>\n";
}
if (strlen($stmtC) > 10)
{
$rslt=mysql_to_mysqli("$stmtC", $link);
$results_to_print = mysqli_num_rows($rslt);
if ( ($results_to_print < 1) and ($results_to_printX < 1) )
{
echo "\n<br><br><center>\n";
echo "<b>"._QXZ("There are no archived inbound did calls matching your search criteria")."</b><br><br>\n";
echo "</center>\n";
}
else
{
echo "<BR><b>"._QXZ("INBOUND DID ARCHIVED LOG RESULTS").": $results_to_print</b><BR>\n";
echo "<TABLE BGCOLOR=WHITE CELLPADDING=1 CELLSPACING=0 WIDTH=770>\n";
echo "<TR BGCOLOR=BLACK>\n";
echo "<TD ALIGN=LEFT VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>#</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("DID")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("PHONE")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("DID ID")."</B> &nbsp;</FONT></TD>\n";
echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>"._QXZ("CALL DATE")."</B> &nbsp;</FONT></TD>\n";
echo "</TR>\n";
$o=0;
while ($results_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($LOGadmin_hide_phone_data != '0')
{
if ($DB > 0) {echo "HIDEPHONEDATA|$row[1]|$LOGadmin_hide_phone_data|\n";}
$phone_temp = $row[1];
if (strlen($phone_temp) > 0)
{
if ($LOGadmin_hide_phone_data == '4_DIGITS')
{$row[1] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);}
elseif ($LOGadmin_hide_phone_data == '3_DIGITS')
{$row[1] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);}
elseif ($LOGadmin_hide_phone_data == '2_DIGITS')
{$row[1] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);}
else
{$row[1] = preg_replace("/./",'X',$phone_temp);}
}
}
$o++;
$search_lead = $row[0];
if (preg_match('/1$|3$|5$|7$|9$/i', $o))
{$bgcolor='bgcolor="#'. $SSstd_row2_background .'"';}
else
{$bgcolor='bgcolor="#'. $SSstd_row1_background .'"';}
echo "<TR $bgcolor>\n";
echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$o</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[0]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[1]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[2]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[3]</FONT></TD>\n";
echo "</TR>\n";
}
echo "</TABLE>\n";
}
}
}
// Search through cold-storage archive logs
if ($linkCS)
if ( ($linkCS) and (preg_match("/COLDSTORAGE/",$archive_type)) )
{
$rslt=mysql_to_mysqli("$stmtA", $linkCS);
$results_to_print = mysqli_num_rows($rslt);