From c44922da0cd4a6dfcecfbe6442d63fa696e37968 Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 25 May 2012 18:36:19 +0000 Subject: [PATCH] issue with concurrency checks fixed bug fixes for file upload scripts git-svn-id: svn://192.168.202.10@1822 3d104415-ff17-0410-8863-d5cf3c621b8a --- .../agc_2.4/bin/AST_CRON_audio_2_compress.pl | 2 +- .../agc_2.4/bin/AST_CRON_audio_3_ftp.pl | 2 +- .../agc_2.4/bin/AST_CRON_audio_3_newftp.pl | 2 +- .../agc_2.4/bin/AST_CRON_audio_4_ftp2.pl | 2 +- .../agc_2.4/bin/AST_cleanup_agent_log.pl | 145 +++++++++++++++++- .../www/vicidial/AST_LISTS_campaign_stats.php | 20 ++- .../vicidial/admin_listloader_fourth_gen.php | 7 +- .../vicidial/admin_listloader_third_gen.php | 7 +- .../agc_2.4/www/vicidial/audio_store.php | 11 +- .../vicidial/leadloader_template_display.php | 3 + .../www/vicidial/new_listloader_superL.php | 15 +- .../trunk/bin/AST_CRON_audio_2_compress.pl | 2 +- agc_2-X/trunk/bin/AST_CRON_audio_3_ftp.pl | 2 +- agc_2-X/trunk/bin/AST_CRON_audio_3_newftp.pl | 2 +- agc_2-X/trunk/bin/AST_CRON_audio_4_ftp2.pl | 2 +- agc_2-X/trunk/bin/AST_cleanup_agent_log.pl | 2 +- .../www/vicidial/AST_LISTS_campaign_stats.php | 21 ++- .../vicidial/admin_listloader_fourth_gen.php | 7 +- .../vicidial/admin_listloader_third_gen.php | 7 +- agc_2-X/trunk/www/vicidial/audio_store.php | 11 +- .../vicidial/leadloader_template_display.php | 3 + .../www/vicidial/new_listloader_superL.php | 15 +- 22 files changed, 249 insertions(+), 41 deletions(-) diff --git a/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_2_compress.pl b/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_2_compress.pl index 1b899cb7..abe639bd 100644 --- a/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_2_compress.pl +++ b/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_2_compress.pl @@ -177,7 +177,7 @@ foreach(@conf) ### concurrency check if ($run_check > 0) { - my $grepout = `/bin/ps ax | grep $0 | grep -v grep`; + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; my $grepnum=0; $grepnum++ while ($grepout =~ m/\n/g); if ($grepnum > 1) diff --git a/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_3_ftp.pl b/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_3_ftp.pl index 0ffdfe5b..44cd964c 100644 --- a/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_3_ftp.pl +++ b/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_3_ftp.pl @@ -300,7 +300,7 @@ foreach(@conf) ### concurrency check if ($run_check > 0) { - my $grepout = `/bin/ps ax | grep $0 | grep -v grep`; + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; my $grepnum=0; $grepnum++ while ($grepout =~ m/\n/g); if ($grepnum > 1) diff --git a/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_3_newftp.pl b/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_3_newftp.pl index f239a61f..1f7504c2 100644 --- a/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_3_newftp.pl +++ b/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_3_newftp.pl @@ -383,7 +383,7 @@ if ($ingrp_check) { ### concurrency check if ($run_check > 0) { - my $grepout = `/bin/ps ax | grep $0 | grep -v grep`; + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; my $grepnum=0; $grepnum++ while ($grepout =~ m/\n/g); if ($grepnum > 1) diff --git a/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_4_ftp2.pl b/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_4_ftp2.pl index d95296a3..8aae9756 100644 --- a/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_4_ftp2.pl +++ b/agc_2-X/branches/agc_2.4/bin/AST_CRON_audio_4_ftp2.pl @@ -245,7 +245,7 @@ foreach(@conf) ### concurrency check if ($run_check > 0) { - my $grepout = `/bin/ps ax | grep $0 | grep -v grep`; + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; my $grepnum=0; $grepnum++ while ($grepout =~ m/\n/g); if ($grepnum > 1) diff --git a/agc_2-X/branches/agc_2.4/bin/AST_cleanup_agent_log.pl b/agc_2-X/branches/agc_2.4/bin/AST_cleanup_agent_log.pl index 2b33e991..80bb0d33 100644 --- a/agc_2-X/branches/agc_2.4/bin/AST_cleanup_agent_log.pl +++ b/agc_2-X/branches/agc_2.4/bin/AST_cleanup_agent_log.pl @@ -36,6 +36,7 @@ # 110504-0737 - Small bug fix in agent log corrections # 111208-0627 - Added concurrency check option # 120123-0925 - Added vicidial_log duplicate check +# 120426-1622 - Added agent log park fix # # constants @@ -69,6 +70,7 @@ if (length($ARGV[0])>1) print " [-only-qm-live-call-check] = will only check the queue_log calls that report as live, in ViciDial\n"; print " [-only-fix-old-lagged] = will go through old lagged entries and add a new entry after\n"; print " [-only-dedupe-vicidial-log] = will look for duplicate vicidial_log and extended entries\n"; + print " [-only-hold-cleanup] = will look for hold entries and correct agent log wait/talk times\n"; print " [-run-check] = concurrency check, die if another instance is running\n"; print " [-q] = quiet, no output\n"; print " [-test] = test\n"; @@ -169,6 +171,11 @@ if (length($ARGV[0])>1) $fix_old_lagged_entries=1; if ($Q < 1) {print "\n----- FIX OLD LAGGED ENTRIES ONLY -----\n\n";} } + if ($args =~ /-only-hold-cleanup/i) + { + $hold_cleanup=1; + if ($Q < 1) {print "\n----- FIX HOLD ENTRIES ONLY -----\n\n";} + } if ($args =~ /-run-check/i) { $run_check=1; @@ -220,6 +227,7 @@ if ($Tsec < 10) {$Tsec = "0$Tsec";} $VDAD_SQL_time = "and event_time > \"$TDSQLdate\" and event_time < \"$FDSQLdate\""; $VDCL_SQL_time = "and call_date > \"$TDSQLdate\" and call_date < \"$FDSQLdate\""; $VDCL_SQL_time_where = "where call_date > \"$TDSQLdate\" and call_date < \"$FDSQLdate\""; +$VDP_SQL_time = "and parked_time > \"$TDSQLdate\" and parked_time < \"$FDSQLdate\""; $QM_SQL_time = "and time_id > $TDtarget and time_id < $FDtarget"; $QM_SQL_time_H = "and time_id > $TDtarget and time_id < $HDtarget"; @@ -246,6 +254,7 @@ if ($ONE_MINUTE > 0) $VDAD_SQL_time = "and event_time < \"$MDSQLdate\" and event_time > \"$TDSQLdate\""; $VDCL_SQL_time = "and call_date < \"$MDSQLdate\" and call_date > \"$TDSQLdate\""; $VDCL_SQL_time_where = "where call_date < \"$MDSQLdate\" and call_date > \"$TDSQLdate\""; + $VDP_SQL_time = "and parked_time > \"$TDSQLdate\" and parked_time < \"$MDSQLdate\""; $QM_SQL_time = "and time_id < $MDtarget and time_id > $TDtarget"; $QM_SQL_time_H = "and time_id < $MDtarget and time_id > $TDtarget"; } @@ -265,6 +274,7 @@ if ($TWENTYFOUR_HOURS > 0) $VDAD_SQL_time = "and event_time > \"$TDSQLdate\" and event_time < \"$FDSQLdate\""; $VDCL_SQL_time = "and call_date > \"$TDSQLdate\" and call_date < \"$FDSQLdate\""; $VDCL_SQL_time_where = "where call_date > \"$TDSQLdate\" and call_date < \"$FDSQLdate\""; + $VDP_SQL_time = "and parked_time > \"$TDSQLdate\" and parked_time < \"$FDSQLdate\""; $QM_SQL_time = "and time_id > $TDtarget and time_id < $FDtarget"; $QM_SQL_time_H = "and time_id > $TDtarget and time_id < $HDtarget"; } @@ -295,6 +305,7 @@ if ($ONEDAYAGO > 0) $VDAD_SQL_time = "and event_time > \"$KDSQLdate\" and event_time < \"$TDSQLdate\""; $VDCL_SQL_time = "and call_date > \"$KDSQLdate\" and call_date < \"$TDSQLdate\""; $VDCL_SQL_time_where = "where call_date > \"$KDSQLdate\" and call_date < \"$TDSQLdate\""; + $VDP_SQL_time = "and parked_time > \"$KDSQLdate\" and parked_time < \"$TDSQLdate\""; $QM_SQL_time = "and time_id > $KDtarget and time_id < $TDtarget"; $QM_SQL_time_H = "and time_id > $KDtarget and time_id < $TDtarget"; } @@ -314,6 +325,7 @@ if ($TWENTYFOUR_OLDER > 0) $VDAD_SQL_time = "and event_time < \"$TDSQLdate\""; $VDCL_SQL_time = "and call_date < \"$TDSQLdate\""; $VDCL_SQL_time_where = "where call_date < \"$TDSQLdate\""; + $VDP_SQL_time = "and parked_time < \"$TDSQLdate\""; $QM_SQL_time = "and time_id < $TDtarget"; $QM_SQL_time_H = "and time_id < $TDtarget"; } @@ -333,6 +345,7 @@ if ($THIRTY_DAYS > 0) $VDAD_SQL_time = "and event_time > \"$TDSQLdate\" and event_time < \"$FDSQLdate\""; $VDCL_SQL_time = "and call_date > \"$TDSQLdate\" and call_date < \"$FDSQLdate\""; $VDCL_SQL_time_where = "where call_date > \"$TDSQLdate\" and call_date < \"$FDSQLdate\""; + $VDP_SQL_time = "and parked_time > \"$TDSQLdate\" and parked_time < \"$FDSQLdate\""; $QM_SQL_time = "and time_id > $TDtarget and time_id < $FDtarget"; $QM_SQL_time_H = "and time_id > $TDtarget and time_id < $HDtarget"; } @@ -378,7 +391,7 @@ foreach(@conf) ### concurrency check if ($run_check > 0) { - my $grepout = `/bin/ps ax | grep $0 | grep -v grep`; + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; my $grepnum=0; $grepnum++ while ($grepout =~ m/\n/g); if ($grepnum > 1) @@ -424,6 +437,136 @@ $sthA->finish(); ########################################### +##### BEGIN hold entries process (not recurring process, only run once) ##### +### NOTE: after running with this flag, you need to run without this flag to recalculate wait_sec and talk_sec of affected records +if ($hold_cleanup > 0) + { + if ($DBX) {print "\n\n";} + if ($DB) {print " - starting validation of on-hold entries\n";} + $total_corrected_records=0; + $total_scanned_records=0; + $total_bad_records=0; + $total_good=0; + $total_pause=0; + $total_wait=0; + $total_talk=0; + $total_dispo=0; + $total_dead=0; + + ### Gather distinct users in vicidial_agent_log during time period + $stmtA = "SELECT user,parked_time,UNIX_TIMESTAMP(parked_time),parked_sec,lead_id,uniqueid from park_log where parked_sec > 0 $VDP_SQL_time;"; + if ($DBX) {print "$stmtA\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArowsU=$sthA->rows; + + $i=0; + while ($sthArowsU > $i) + { + @aryA = $sthA->fetchrow_array; + $Vuser[$i] = $aryA[0]; + $Vpark_time[$i] = $aryA[1]; + $Vpark_epoch[$i] = $aryA[2]; + $Vpark_sec[$i] = $aryA[3]; + $Vlead_id[$i] = $aryA[4]; + $Vuniqueid[$i] = $aryA[5]; + $i++; + } + $sthA->finish(); + + $i=0; + while ($sthArowsU > $i) + { + ### Gather distinct users in vicidial_agent_log during time period + $stmtA = "SELECT talk_epoch,agent_log_id from vicidial_agent_log where lead_id='$Vlead_id[$i]' and uniqueid='$Vuniqueid[$i]' and user='$Vuser[$i]' and talk_epoch >= '$Vpark_epoch[$i]' $VDAD_SQL_time;"; + if ($DBX) {print "$stmtA\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $VCL_bad_records=$sthA->rows; + if ($VCL_bad_records < 1) + { + if ($DBX) {print " VAL record good: $Vlead_id[$i]|$Vuser[$i]|$Vpark_epoch[$i]|$Vpark_time[$i]|$Vuniqueid[$i]\n";} + $val_good++; + } + else + { + @aryAbad = $sthA->fetchrow_array; + $Vold_talk_epoch[$i] = $aryAbad[0]; + $Vagent_log_id[$i] = $aryAbad[1]; + if ($DB) {print " VAL record BAD: $Vlead_id[$i]|$Vuser[$i]|$Vpark_epoch[$i]|$Vpark_time[$i]|$Vuniqueid[$i]|$Vold_talk_epoch[$i]\n";} + + ### check inbound log ### + $stmtA = "SELECT start_epoch,length_in_sec,queue_seconds from vicidial_closer_log where lead_id='$Vlead_id[$i]' and uniqueid='$Vuniqueid[$i]' and user='$Vuser[$i]' $VDCL_SQL_time;"; + if ($DBX) {print "$stmtA\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $VCL_records=$sthA->rows; + if ($DBX) {print "vicidial_closer_log record: $VCL_records|$stmtA|\n\n";} + $h=0; + while ($VCL_records > $h) + { + @aryA = $sthA->fetchrow_array; + $Vagent_talk_epoch[$i] = ($aryA[0] + $aryA[2]); + + $h++; + } + if ($h < 1) + { + ### check outbound log ### + $stmtA = "SELECT start_epoch,length_in_sec from vicidial_log where lead_id='$Vlead_id[$i]' and uniqueid='$Vuniqueid[$i]' and user='$Vuser[$i]' $VDCL_SQL_time;"; + if ($DBX) {print "$stmtA\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $VCL_records=$sthA->rows; + if ($DBX) {print "vicidial_closer_log record: $VCL_records|$stmtA|\n\n";} + $h=0; + while ($VCL_records > $h) + { + @aryA = $sthA->fetchrow_array; + $Vagent_talk_epoch[$i] = $aryA[0]; + + $h++; + } + if ($h < 1) + { + if ($DBX) {print "ERROR: No call record found!\n\n";} + $total_dead++; + } + } + if ($h > 0) + { + $Vagent_talk_epochROUND[$i] = int($Vagent_talk_epoch[$i] + 0.5); + if ($DBX) {print "UPDATE $Vagent_log_id[$i] --- $Vold_talk_epoch[$i]($Vpark_epoch[$i]) with $Vagent_talk_epoch[$i]($Vagent_talk_epochROUND[$i])\n";} + + ##### insert vicidial_agent_log record + $stmtAX = "UPDATE vicidial_agent_log SET talk_epoch='$Vagent_talk_epochROUND[$i]' where agent_log_id='$Vagent_log_id[$i]';"; + if ($TEST < 1) + {$VALaffected_rows = $dbhA->do($stmtAX);} + if ($DB) {print " BAD VAL record updated: $VALaffected_rows|$stmtAX|\n";} + + $total_corrected_records++; + } + + $total_bad_records++; + } + + $i++; + } + + if ($DB) {print " - finished hold scan:\n";} + if ($DB) {print " records scanned: $i\n";} + if ($DB) {print " records good: $total_good\n";} + if ($DB) {print " records bad: $total_bad_records\n";} + if ($DB) {print " records not found: $total_dead\n";} + if ($DB) {print " records corrected: $total_corrected_records\n";} + + if ($DB) {print "process completed, exiting...\n";} + + exit; + } +##### END hold entries process (not recurring process, only run once) ##### + + ##### BEGIN fix_old_lagged_entries process (not recurring process, only run once) ##### if ($fix_old_lagged_entries > 0) { diff --git a/agc_2-X/branches/agc_2.4/www/vicidial/AST_LISTS_campaign_stats.php b/agc_2-X/branches/agc_2.4/www/vicidial/AST_LISTS_campaign_stats.php index 8f29c959..5f6b47c3 100644 --- a/agc_2-X/branches/agc_2.4/www/vicidial/AST_LISTS_campaign_stats.php +++ b/agc_2-X/branches/agc_2.4/www/vicidial/AST_LISTS_campaign_stats.php @@ -10,6 +10,7 @@ # 100916-0928 - First build # 110703-1815 - Added download option # 120224-0910 - Added HTML display option with bar graphs +# 120524-1754 - Fixed status categories issue # header ("Content-type: text/html; charset=utf-8"); @@ -180,7 +181,7 @@ else $stmt="select vsc_id,vsc_name from vicidial_status_categories;"; $rslt=mysql_query($stmt, $link); -if ($DB) {$MAIN.="$stmt\n";} +if ($DB) {echo "$stmt\n";} $statcats_to_print = mysql_num_rows($rslt); $i=0; while ($i < $statcats_to_print) @@ -188,7 +189,22 @@ while ($i < $statcats_to_print) $row=mysql_fetch_row($rslt); $vsc_id[$i] = $row[0]; $vsc_name[$i] = $row[1]; - $vsc_count[$i] = 0; + + $category_statuses=""; + $status_stmt="select distinct status from vicidial_statuses where category='$row[0]' UNION select distinct status from vicidial_campaign_statuses where category='$row[0]' $group_SQLand"; + if ($DB) {echo "$status_stmt\n";} + $status_rslt=mysql_query($status_stmt, $link); + while ($status_row=mysql_fetch_row($status_rslt)) + { + $category_statuses.="'$status_row[0]',"; + } + $category_statuses=substr($category_statuses, 0, -1); + + $category_stmt="select count(*) from vicidial_list where status in ($category_statuses) and list_id IN( SELECT list_id from vicidial_lists where active IN('Y','N') $group_SQLand)"; + if ($DB) {echo "$category_stmt\n";} + $category_rslt=mysql_query($category_stmt, $link); + $category_row=mysql_fetch_row($category_rslt); + $vsc_count[$i] = $category_row[0]; $i++; } diff --git a/agc_2-X/branches/agc_2.4/www/vicidial/admin_listloader_fourth_gen.php b/agc_2-X/branches/agc_2.4/www/vicidial/admin_listloader_fourth_gen.php index db265ad0..78ae0849 100644 --- a/agc_2-X/branches/agc_2.4/www/vicidial/admin_listloader_fourth_gen.php +++ b/agc_2-X/branches/agc_2.4/www/vicidial/admin_listloader_fourth_gen.php @@ -45,10 +45,11 @@ # 120221-0140 - Added User Group restrictions # 120223-2318 - Removed logging of good login passwords if webroot writable is enabled # 120402-2128 - Added template options +# 120525-1038 - Added uploaded filename filtering # -$version = '2.4-44'; -$build = '120402-2128'; +$version = '2.4-45'; +$build = '120525-1038'; require("dbconnect.php"); @@ -153,6 +154,8 @@ if ( $phone_code_override == "in_file" ) { $phone_code_override = ""; } ### REGEX to prevent weird characters from ending up in the fields $field_regx = "['\"`\\;]"; +$lead_file = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$lead_file); +$leadfile_name = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$leadfile_name); $vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|entry_list_id|'; diff --git a/agc_2-X/branches/agc_2.4/www/vicidial/admin_listloader_third_gen.php b/agc_2-X/branches/agc_2.4/www/vicidial/admin_listloader_third_gen.php index 8ad792d9..acb8d374 100644 --- a/agc_2-X/branches/agc_2.4/www/vicidial/admin_listloader_third_gen.php +++ b/agc_2-X/branches/agc_2.4/www/vicidial/admin_listloader_third_gen.php @@ -44,10 +44,11 @@ # 110705-1947 - Added USACAN check for prefix and areacode # 120221-0140 - Added User Group restrictions # 120223-2318 - Removed logging of good login passwords if webroot writable is enabled +# 120525-1037 - Added uploaded filename filtering # -$version = '2.4-43'; -$build = '120223-2318'; +$version = '2.4-44'; +$build = '120525-1037'; require("dbconnect.php"); @@ -150,6 +151,8 @@ if ( $phone_code_override == "in_file" ) { $phone_code_override = ""; } ### REGEX to prevent weird characters from ending up in the fields $field_regx = "['\"`\\;]"; +$lead_file = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$lead_file); +$leadfile_name = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$leadfile_name); $vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|entry_list_id|'; diff --git a/agc_2-X/branches/agc_2.4/www/vicidial/audio_store.php b/agc_2-X/branches/agc_2.4/www/vicidial/audio_store.php index ad441c1a..f93ebd37 100644 --- a/agc_2-X/branches/agc_2.4/www/vicidial/audio_store.php +++ b/agc_2-X/branches/agc_2.4/www/vicidial/audio_store.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2012 Matt Florell LICENSE: AGPLv2 # # Central Audio Storage script # @@ -11,10 +11,11 @@ # 100401-1037 - remove spaces and special characters from filenames, admin log uploads # 110922-2331 - Added modify_audiostore user option for access # 111122-1332 - Added more filename filtering +# 120525-0739 - Added yet more filename filtering # -$version = '2.4-5'; -$build = '111122-1332'; +$version = '2.4-6'; +$build = '120525-0739'; $MT[0]=''; @@ -206,6 +207,7 @@ if ($action == "AUTOUPLOAD") $AF_path = preg_replace("/\!/",'\!',$AF_path); $AF_path = preg_replace("/\%/",'\%',$AF_path); $AF_path = preg_replace("/\^/",'\^',$AF_path); + $AF_path = preg_replace("/;|:|\/|\[|\]|\"|\'/",'',$AF_path); $audiofile_name = preg_replace("/ /",'',$audiofile_name); $audiofile_name = preg_replace("/@/",'',$audiofile_name); $audiofile_name = preg_replace("/\(/",'',$audiofile_name); @@ -216,6 +218,7 @@ if ($action == "AUTOUPLOAD") $audiofile_name = preg_replace("/\!/",'',$audiofile_name); $audiofile_name = preg_replace("/\%/",'',$audiofile_name); $audiofile_name = preg_replace("/\^/",'',$audiofile_name); + $audiofile_name = preg_replace("/;|:|\/|\[|\]|\"|\'/",'',$audiofile_name); copy($AF_path, "$WeBServeRRooT/$sounds_web_directory/$audiofile_name"); chmod("$WeBServeRRooT/$sounds_web_directory/$audiofile_name", 0766); @@ -310,6 +313,7 @@ if ($action == "MANUALUPLOAD") $AF_path = preg_replace("/\!/",'\!',$AF_path); $AF_path = preg_replace("/\%/",'\%',$AF_path); $AF_path = preg_replace("/\^/",'\^',$AF_path); + $AF_path = preg_replace("/;|:|\/|\[|\]|\"|\'/",'',$AF_path); $audiofile_name = preg_replace("/ /",'',$audiofile_name); $audiofile_name = preg_replace("/@/",'',$audiofile_name); $audiofile_name = preg_replace("/\(/",'',$audiofile_name); @@ -320,6 +324,7 @@ if ($action == "MANUALUPLOAD") $audiofile_name = preg_replace("/\!/",'',$audiofile_name); $audiofile_name = preg_replace("/\%/",'',$audiofile_name); $audiofile_name = preg_replace("/\^/",'',$audiofile_name); + $audiofile_name = preg_replace("/;|:|\/|\[|\]|\"|\'/",'',$audiofile_name); copy($AF_path, "$WeBServeRRooT/$sounds_web_directory/$audiofile_name"); chmod("$WeBServeRRooT/$sounds_web_directory/$audiofile_name", 0766); diff --git a/agc_2-X/branches/agc_2.4/www/vicidial/leadloader_template_display.php b/agc_2-X/branches/agc_2.4/www/vicidial/leadloader_template_display.php index 8c80474c..4415e014 100644 --- a/agc_2-X/branches/agc_2.4/www/vicidial/leadloader_template_display.php +++ b/agc_2-X/branches/agc_2.4/www/vicidial/leadloader_template_display.php @@ -5,6 +5,7 @@ # # CHANGES # 120402-2238 - First Build +# 120525-1039 - Added uploaded filename filtering # require("dbconnect.php"); @@ -45,6 +46,8 @@ if (isset($_GET["buffer"])) {$buffer=$_GET["buffer"];} ### REGEX to prevent weird characters from ending up in the fields $field_regx = "['\"`\\;]"; +$sample_template_file_name = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$sample_template_file_name); + if ($form_action=="prime_file" && $sample_template_file_name) { $delim_set=0; diff --git a/agc_2-X/branches/agc_2.4/www/vicidial/new_listloader_superL.php b/agc_2-X/branches/agc_2.4/www/vicidial/new_listloader_superL.php index a9bb278d..c0be85a6 100644 --- a/agc_2-X/branches/agc_2.4/www/vicidial/new_listloader_superL.php +++ b/agc_2-X/branches/agc_2.4/www/vicidial/new_listloader_superL.php @@ -35,11 +35,12 @@ # 100705-1507 - Added custom fields to field chooser, only when liast_id_override is used and only with TXT and CSV file formats # 100712-1416 - Added entry_list_id field to vicidial_list to preserve link to custom fields if any # 120223-2148 - Removed logging of good login passwords if webroot writable is enabled +# 120525-0731 - Added uploaded filename filtering # # make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. -$version = '2.4-38'; -$build = '120223-2148'; +$version = '2.4-39'; +$build = '120525-0731'; require("dbconnect.php"); @@ -139,6 +140,8 @@ if (isset($_GET["DB"])) {$DB=$_GET["DB"];} ### REGEX to prevent weird characters from ending up in the fields $field_regx = "['\"`\\;]"; +$lead_file = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$lead_file); +$leadfile_name = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$leadfile_name); $vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|entry_list_id|'; @@ -205,10 +208,10 @@ $browser = getenv("HTTP_USER_AGENT"); { $office_no=strtoupper($PHP_AUTH_USER); $password=strtoupper($PHP_AUTH_PW); - $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); - $LOGload_leads =$row[0]; + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads = $row[0]; if ($LOGload_leads < 1) { diff --git a/agc_2-X/trunk/bin/AST_CRON_audio_2_compress.pl b/agc_2-X/trunk/bin/AST_CRON_audio_2_compress.pl index 1b899cb7..abe639bd 100644 --- a/agc_2-X/trunk/bin/AST_CRON_audio_2_compress.pl +++ b/agc_2-X/trunk/bin/AST_CRON_audio_2_compress.pl @@ -177,7 +177,7 @@ foreach(@conf) ### concurrency check if ($run_check > 0) { - my $grepout = `/bin/ps ax | grep $0 | grep -v grep`; + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; my $grepnum=0; $grepnum++ while ($grepout =~ m/\n/g); if ($grepnum > 1) diff --git a/agc_2-X/trunk/bin/AST_CRON_audio_3_ftp.pl b/agc_2-X/trunk/bin/AST_CRON_audio_3_ftp.pl index 0ffdfe5b..44cd964c 100644 --- a/agc_2-X/trunk/bin/AST_CRON_audio_3_ftp.pl +++ b/agc_2-X/trunk/bin/AST_CRON_audio_3_ftp.pl @@ -300,7 +300,7 @@ foreach(@conf) ### concurrency check if ($run_check > 0) { - my $grepout = `/bin/ps ax | grep $0 | grep -v grep`; + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; my $grepnum=0; $grepnum++ while ($grepout =~ m/\n/g); if ($grepnum > 1) diff --git a/agc_2-X/trunk/bin/AST_CRON_audio_3_newftp.pl b/agc_2-X/trunk/bin/AST_CRON_audio_3_newftp.pl index f239a61f..1f7504c2 100644 --- a/agc_2-X/trunk/bin/AST_CRON_audio_3_newftp.pl +++ b/agc_2-X/trunk/bin/AST_CRON_audio_3_newftp.pl @@ -383,7 +383,7 @@ if ($ingrp_check) { ### concurrency check if ($run_check > 0) { - my $grepout = `/bin/ps ax | grep $0 | grep -v grep`; + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; my $grepnum=0; $grepnum++ while ($grepout =~ m/\n/g); if ($grepnum > 1) diff --git a/agc_2-X/trunk/bin/AST_CRON_audio_4_ftp2.pl b/agc_2-X/trunk/bin/AST_CRON_audio_4_ftp2.pl index d95296a3..8aae9756 100644 --- a/agc_2-X/trunk/bin/AST_CRON_audio_4_ftp2.pl +++ b/agc_2-X/trunk/bin/AST_CRON_audio_4_ftp2.pl @@ -245,7 +245,7 @@ foreach(@conf) ### concurrency check if ($run_check > 0) { - my $grepout = `/bin/ps ax | grep $0 | grep -v grep`; + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; my $grepnum=0; $grepnum++ while ($grepout =~ m/\n/g); if ($grepnum > 1) diff --git a/agc_2-X/trunk/bin/AST_cleanup_agent_log.pl b/agc_2-X/trunk/bin/AST_cleanup_agent_log.pl index 93b4eed4..80bb0d33 100644 --- a/agc_2-X/trunk/bin/AST_cleanup_agent_log.pl +++ b/agc_2-X/trunk/bin/AST_cleanup_agent_log.pl @@ -391,7 +391,7 @@ foreach(@conf) ### concurrency check if ($run_check > 0) { - my $grepout = `/bin/ps ax | grep $0 | grep -v grep`; + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; my $grepnum=0; $grepnum++ while ($grepout =~ m/\n/g); if ($grepnum > 1) diff --git a/agc_2-X/trunk/www/vicidial/AST_LISTS_campaign_stats.php b/agc_2-X/trunk/www/vicidial/AST_LISTS_campaign_stats.php index 8f29c959..bb039004 100644 --- a/agc_2-X/trunk/www/vicidial/AST_LISTS_campaign_stats.php +++ b/agc_2-X/trunk/www/vicidial/AST_LISTS_campaign_stats.php @@ -10,6 +10,7 @@ # 100916-0928 - First build # 110703-1815 - Added download option # 120224-0910 - Added HTML display option with bar graphs +# 120524-1754 - Fixed status categories issue # header ("Content-type: text/html; charset=utf-8"); @@ -180,7 +181,7 @@ else $stmt="select vsc_id,vsc_name from vicidial_status_categories;"; $rslt=mysql_query($stmt, $link); -if ($DB) {$MAIN.="$stmt\n";} +if ($DB) {echo "$stmt\n";} $statcats_to_print = mysql_num_rows($rslt); $i=0; while ($i < $statcats_to_print) @@ -188,13 +189,27 @@ while ($i < $statcats_to_print) $row=mysql_fetch_row($rslt); $vsc_id[$i] = $row[0]; $vsc_name[$i] = $row[1]; - $vsc_count[$i] = 0; + + $category_statuses=""; + $status_stmt="select distinct status from vicidial_statuses where category='$row[0]' UNION select distinct status from vicidial_campaign_statuses where category='$row[0]' $group_SQLand"; + if ($DB) {echo "$status_stmt\n";} + $status_rslt=mysql_query($status_stmt, $link); + while ($status_row=mysql_fetch_row($status_rslt)) + { + $category_statuses.="'$status_row[0]',"; + } + $category_statuses=substr($category_statuses, 0, -1); + + $category_stmt="select count(*) from vicidial_list where status in ($category_statuses) and list_id IN( SELECT list_id from vicidial_lists where active IN('Y','N') $group_SQLand)"; + if ($DB) {echo "$category_stmt\n";} + $category_rslt=mysql_query($category_stmt, $link); + $category_row=mysql_fetch_row($category_rslt); + $vsc_count[$i] = $category_row[0]; $i++; } - ### BEGIN gather all statuses that are in status flags ### $human_answered_statuses=''; $sale_statuses=''; diff --git a/agc_2-X/trunk/www/vicidial/admin_listloader_fourth_gen.php b/agc_2-X/trunk/www/vicidial/admin_listloader_fourth_gen.php index db265ad0..78ae0849 100644 --- a/agc_2-X/trunk/www/vicidial/admin_listloader_fourth_gen.php +++ b/agc_2-X/trunk/www/vicidial/admin_listloader_fourth_gen.php @@ -45,10 +45,11 @@ # 120221-0140 - Added User Group restrictions # 120223-2318 - Removed logging of good login passwords if webroot writable is enabled # 120402-2128 - Added template options +# 120525-1038 - Added uploaded filename filtering # -$version = '2.4-44'; -$build = '120402-2128'; +$version = '2.4-45'; +$build = '120525-1038'; require("dbconnect.php"); @@ -153,6 +154,8 @@ if ( $phone_code_override == "in_file" ) { $phone_code_override = ""; } ### REGEX to prevent weird characters from ending up in the fields $field_regx = "['\"`\\;]"; +$lead_file = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$lead_file); +$leadfile_name = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$leadfile_name); $vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|entry_list_id|'; diff --git a/agc_2-X/trunk/www/vicidial/admin_listloader_third_gen.php b/agc_2-X/trunk/www/vicidial/admin_listloader_third_gen.php index 8ad792d9..acb8d374 100644 --- a/agc_2-X/trunk/www/vicidial/admin_listloader_third_gen.php +++ b/agc_2-X/trunk/www/vicidial/admin_listloader_third_gen.php @@ -44,10 +44,11 @@ # 110705-1947 - Added USACAN check for prefix and areacode # 120221-0140 - Added User Group restrictions # 120223-2318 - Removed logging of good login passwords if webroot writable is enabled +# 120525-1037 - Added uploaded filename filtering # -$version = '2.4-43'; -$build = '120223-2318'; +$version = '2.4-44'; +$build = '120525-1037'; require("dbconnect.php"); @@ -150,6 +151,8 @@ if ( $phone_code_override == "in_file" ) { $phone_code_override = ""; } ### REGEX to prevent weird characters from ending up in the fields $field_regx = "['\"`\\;]"; +$lead_file = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$lead_file); +$leadfile_name = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$leadfile_name); $vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|entry_list_id|'; diff --git a/agc_2-X/trunk/www/vicidial/audio_store.php b/agc_2-X/trunk/www/vicidial/audio_store.php index ad441c1a..f93ebd37 100644 --- a/agc_2-X/trunk/www/vicidial/audio_store.php +++ b/agc_2-X/trunk/www/vicidial/audio_store.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2012 Matt Florell LICENSE: AGPLv2 # # Central Audio Storage script # @@ -11,10 +11,11 @@ # 100401-1037 - remove spaces and special characters from filenames, admin log uploads # 110922-2331 - Added modify_audiostore user option for access # 111122-1332 - Added more filename filtering +# 120525-0739 - Added yet more filename filtering # -$version = '2.4-5'; -$build = '111122-1332'; +$version = '2.4-6'; +$build = '120525-0739'; $MT[0]=''; @@ -206,6 +207,7 @@ if ($action == "AUTOUPLOAD") $AF_path = preg_replace("/\!/",'\!',$AF_path); $AF_path = preg_replace("/\%/",'\%',$AF_path); $AF_path = preg_replace("/\^/",'\^',$AF_path); + $AF_path = preg_replace("/;|:|\/|\[|\]|\"|\'/",'',$AF_path); $audiofile_name = preg_replace("/ /",'',$audiofile_name); $audiofile_name = preg_replace("/@/",'',$audiofile_name); $audiofile_name = preg_replace("/\(/",'',$audiofile_name); @@ -216,6 +218,7 @@ if ($action == "AUTOUPLOAD") $audiofile_name = preg_replace("/\!/",'',$audiofile_name); $audiofile_name = preg_replace("/\%/",'',$audiofile_name); $audiofile_name = preg_replace("/\^/",'',$audiofile_name); + $audiofile_name = preg_replace("/;|:|\/|\[|\]|\"|\'/",'',$audiofile_name); copy($AF_path, "$WeBServeRRooT/$sounds_web_directory/$audiofile_name"); chmod("$WeBServeRRooT/$sounds_web_directory/$audiofile_name", 0766); @@ -310,6 +313,7 @@ if ($action == "MANUALUPLOAD") $AF_path = preg_replace("/\!/",'\!',$AF_path); $AF_path = preg_replace("/\%/",'\%',$AF_path); $AF_path = preg_replace("/\^/",'\^',$AF_path); + $AF_path = preg_replace("/;|:|\/|\[|\]|\"|\'/",'',$AF_path); $audiofile_name = preg_replace("/ /",'',$audiofile_name); $audiofile_name = preg_replace("/@/",'',$audiofile_name); $audiofile_name = preg_replace("/\(/",'',$audiofile_name); @@ -320,6 +324,7 @@ if ($action == "MANUALUPLOAD") $audiofile_name = preg_replace("/\!/",'',$audiofile_name); $audiofile_name = preg_replace("/\%/",'',$audiofile_name); $audiofile_name = preg_replace("/\^/",'',$audiofile_name); + $audiofile_name = preg_replace("/;|:|\/|\[|\]|\"|\'/",'',$audiofile_name); copy($AF_path, "$WeBServeRRooT/$sounds_web_directory/$audiofile_name"); chmod("$WeBServeRRooT/$sounds_web_directory/$audiofile_name", 0766); diff --git a/agc_2-X/trunk/www/vicidial/leadloader_template_display.php b/agc_2-X/trunk/www/vicidial/leadloader_template_display.php index 8c80474c..4415e014 100644 --- a/agc_2-X/trunk/www/vicidial/leadloader_template_display.php +++ b/agc_2-X/trunk/www/vicidial/leadloader_template_display.php @@ -5,6 +5,7 @@ # # CHANGES # 120402-2238 - First Build +# 120525-1039 - Added uploaded filename filtering # require("dbconnect.php"); @@ -45,6 +46,8 @@ if (isset($_GET["buffer"])) {$buffer=$_GET["buffer"];} ### REGEX to prevent weird characters from ending up in the fields $field_regx = "['\"`\\;]"; +$sample_template_file_name = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$sample_template_file_name); + if ($form_action=="prime_file" && $sample_template_file_name) { $delim_set=0; diff --git a/agc_2-X/trunk/www/vicidial/new_listloader_superL.php b/agc_2-X/trunk/www/vicidial/new_listloader_superL.php index a9bb278d..c0be85a6 100644 --- a/agc_2-X/trunk/www/vicidial/new_listloader_superL.php +++ b/agc_2-X/trunk/www/vicidial/new_listloader_superL.php @@ -35,11 +35,12 @@ # 100705-1507 - Added custom fields to field chooser, only when liast_id_override is used and only with TXT and CSV file formats # 100712-1416 - Added entry_list_id field to vicidial_list to preserve link to custom fields if any # 120223-2148 - Removed logging of good login passwords if webroot writable is enabled +# 120525-0731 - Added uploaded filename filtering # # make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. -$version = '2.4-38'; -$build = '120223-2148'; +$version = '2.4-39'; +$build = '120525-0731'; require("dbconnect.php"); @@ -139,6 +140,8 @@ if (isset($_GET["DB"])) {$DB=$_GET["DB"];} ### REGEX to prevent weird characters from ending up in the fields $field_regx = "['\"`\\;]"; +$lead_file = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$lead_file); +$leadfile_name = preg_replace("/;|:|\/|\^|\[|\]|\"|\'|\*/","",$leadfile_name); $vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|entry_list_id|'; @@ -205,10 +208,10 @@ $browser = getenv("HTTP_USER_AGENT"); { $office_no=strtoupper($PHP_AUTH_USER); $password=strtoupper($PHP_AUTH_PW); - $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); - $LOGload_leads =$row[0]; + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads = $row[0]; if ($LOGload_leads < 1) {