From 77df8cbf22eec1004d2ec646d36f7e91908f94ac Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 10 Nov 2006 17:39:28 +0000 Subject: [PATCH] added time zone scheme for Brazil to CLI and web lead loaders script fixed country field in CLI and web lead loaders git-svn-id: svn://192.168.202.10@380 3d104415-ff17-0410-8863-d5cf3c621b8a --- .../trunk/bin/ADMIN_adjust_GMTnow_on_leads.pl | 2 +- .../trunk/bin/VICIDIAL_IN_new_leads_file.pl | 4 +- agc_2-X/trunk/www/vicidial/listloader.php | 207 ++++++++++++++--- agc_2-X/trunk/www/vicidial/listloader.pl | 219 ++++++++++++++++-- .../trunk/www/vicidial/listloader_super.pl | 219 ++++++++++++++++-- .../www/vicidial/new_listloader_superL.php | 175 +++++++++++++- 6 files changed, 739 insertions(+), 87 deletions(-) diff --git a/agc_2-X/trunk/bin/ADMIN_adjust_GMTnow_on_leads.pl b/agc_2-X/trunk/bin/ADMIN_adjust_GMTnow_on_leads.pl index d5ce00db..360bb2d0 100644 --- a/agc_2-X/trunk/bin/ADMIN_adjust_GMTnow_on_leads.pl +++ b/agc_2-X/trunk/bin/ADMIN_adjust_GMTnow_on_leads.pl @@ -835,7 +835,7 @@ sub NZL_dstcalc { sub BZL_dstcalc { #********************************************************************** -# LSO-LSF +# TSO-LSF # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. Brazil # Based on Third Sunday October to Last Sunday February at 1 am. diff --git a/agc_2-X/trunk/bin/VICIDIAL_IN_new_leads_file.pl b/agc_2-X/trunk/bin/VICIDIAL_IN_new_leads_file.pl index 4c6d5d90..b9a2669b 100644 --- a/agc_2-X/trunk/bin/VICIDIAL_IN_new_leads_file.pl +++ b/agc_2-X/trunk/bin/VICIDIAL_IN_new_leads_file.pl @@ -466,7 +466,7 @@ if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOC if ($multi_insert_counter > 8) { ### insert good deal into pending_transactions table ### - $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_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_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','0');"; + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_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','0');"; if (!$T) {$affected_rows = $dbhA->do($stmtZ); } # or die "Couldn't execute query: |$stmtZ|\n"; if($DB){print STDERR "\n|$affected_rows|$stmtZ|\n";} @@ -476,7 +476,7 @@ if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOC } else { - $multistmt .= "('','$entry_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_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','0'),"; + $multistmt .= "('','$entry_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','0'),"; $multi_insert_counter++; } diff --git a/agc_2-X/trunk/www/vicidial/listloader.php b/agc_2-X/trunk/www/vicidial/listloader.php index 9cf8a548..efe3afd3 100644 --- a/agc_2-X/trunk/www/vicidial/listloader.php +++ b/agc_2-X/trunk/www/vicidial/listloader.php @@ -13,12 +13,13 @@ # 60619-1652 - Added variable filtering to eliminate SQL injection attack threat # 60822-1105 - fixed for nonwritable directories # 60906-1059 - added filter of non-digits in alt_phone field +# 61110-1222 - added new USA-Canada DST scheme and Brazil DST scheme # # make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. # -$version = '2.0.1'; -$build = '60822-1105'; +$version = '2.0.2'; +$build = '61110-1222'; header ("Content-type: text/html; charset=utf-8"); @@ -300,14 +301,14 @@ if ($leadfile and filesize($LF_path)<=8388608) { $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); $AC_processed=0; - if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + if ( (!$AC_processed) and ($dst_range == 'SSM-FSN') ) { - if ($DBX) {print " First Sunday April to Last Sunday October\n";} + if ($DBX) {print " Second Sunday March to First Sunday November\n";} #********************************************************************** - # FSA-LSO + # SSM-FSN # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. - # Based on first Sunday in April and last Sunday in October at 2 am. + # Based on Second Sunday March to First Sunday November at 2 am. # INPUTS: # mm INTEGER Month. # dd INTEGER Day of the month. @@ -321,64 +322,147 @@ if ($leadfile and filesize($LF_path)<=8388608) { # and 9:00 UTC in October # OUTPUT: # INTEGER 1 = DST, 0 = not DST + # + # S M T W T F S + # 1 2 3 4 5 6 7 + # 8 9 10 11 12 13 14 + #15 16 17 18 19 20 21 + #22 23 24 25 26 27 28 + #29 30 31 + # + # S M T W T F S + # 1 2 3 4 5 6 + # 7 8 9 10 11 12 13 + #14 15 16 17 18 19 20 + #21 22 23 24 25 26 27 + #28 29 30 31 + # + #********************************************************************** + + $USACAN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 11) { + $USACAN_DST=0; + } elseif ($mm >= 4 and $mm <= 10) { + $USACAN_DST=1; + } elseif ($mm == 3) { + if ($dd > 13) { + $USACAN_DST=1; + } elseif ($dd >= ($dow+8)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USACAN_DST=0; + } else { + $USACAN_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USACAN_DST=0; + } else { + $USACAN_DST=1; + } + } + } else { + $USACAN_DST=0; + } + } elseif ($mm == 11) { + if ($dd > 7) { + $USACAN_DST=0; + } elseif ($dd < ($dow+1)) { + $USACAN_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USACAN_DST=1; + } else { + $USACAN_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USACAN_DST=1; + } else { + $USACAN_DST=0; + } + } + } else { + $USACAN_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $USACAN_DST\n";} + if ($USACAN_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. #********************************************************************** - $USA_DST=0; + $NA_DST=0; $mm = $mon; $dd = $mday; $ns = $dsec; $dow= $wday; if ($mm < 4 || $mm > 10) { - $USA_DST=0; + $NA_DST=0; } elseif ($mm >= 5 and $mm <= 9) { - $USA_DST=1; + $NA_DST=1; } elseif ($mm == 4) { if ($dd > 7) { - $USA_DST=1; + $NA_DST=1; } elseif ($dd >= ($dow+1)) { if ($timezone) { if ($dow == 0 and $ns < (7200+$timezone*3600)) { - $USA_DST=0; + $NA_DST=0; } else { - $USA_DST=1; + $NA_DST=1; } } else { if ($dow == 0 and $ns < 7200) { - $USA_DST=0; + $NA_DST=0; } else { - $USA_DST=1; + $NA_DST=1; } } } else { - $USA_DST=0; + $NA_DST=0; } } elseif ($mm == 10) { if ($dd < 25) { - $USA_DST=1; + $NA_DST=1; } elseif ($dd < ($dow+25)) { - $USA_DST=1; + $NA_DST=1; } elseif ($dow == 0) { if ($timezone) { # UTC calculations if ($ns < (7200+($timezone-1)*3600)) { - $USA_DST=1; + $NA_DST=1; } else { - $USA_DST=0; + $NA_DST=0; } } else { # local time calculations if ($ns < 7200) { - $USA_DST=1; + $NA_DST=1; } else { - $USA_DST=0; + $NA_DST=0; } } } else { - $USA_DST=0; + $NA_DST=0; } } # end of month checks - if ($DBX) {print " DST: $USA_DST\n";} - if ($USA_DST) {$gmt_offset++;} + if ($DBX) {print " DST: $NA_DST\n";} + if ($NA_DST) {$gmt_offset++;} $AC_processed++; } @@ -652,6 +736,77 @@ if ($leadfile and filesize($LF_path)<=8388608) { if ($NZL_DST) {$gmt_offset++;} $AC_processed++; } + + if ( (!$AC_processed) and ($dst_range == 'TSO-LSF') ) + { + if ($DBX) {print " Third Sunday October to Last Sunday February\n";} + #********************************************************************** + # TSO-LSF + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. Brazil + # Based on Third Sunday October to Last Sunday February at 1 am. + #********************************************************************** + + $BZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 2 || $mm > 10) { + $BZL_DST=1; + } elseif ($mm >= 3 and $mm <= 9) { + $BZL_DST=0; + } elseif ($mm == 2) { + if ($dd < 22) { + $BZL_DST=1; + } elseif ($dd < ($dow+22)) { + $BZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=1; + } else { + $BZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=1; + } else { + $BZL_DST=0; + } + } + } else { + $BZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 22) { + $BZL_DST=0; + } elseif ($dd < ($dow+22)) { + $BZL_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=0; + } else { + $BZL_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=0; + } else { + $BZL_DST=1; + } + } + } else { + $BZL_DST=1; + } + } # end of month checks + 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";} @@ -662,7 +817,7 @@ if ($leadfile and filesize($LF_path)<=8388608) { if ($multi_insert_counter > 8) { ### insert good deal into pending_transactions table ### - $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_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_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_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',0);"; $rslt=mysql_query($stmtZ, $link); if ($WeBRooTWritablE > 0) {fwrite($stmt_file, $stmtZ."\r\n");} @@ -670,7 +825,7 @@ if ($leadfile and filesize($LF_path)<=8388608) { $multi_insert_counter=0; } else { - $multistmt .= "('','$entry_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_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multistmt .= "('','$entry_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',0),"; $multi_insert_counter++; } diff --git a/agc_2-X/trunk/www/vicidial/listloader.pl b/agc_2-X/trunk/www/vicidial/listloader.pl index cec67de0..1151f0b8 100644 --- a/agc_2-X/trunk/www/vicidial/listloader.pl +++ b/agc_2-X/trunk/www/vicidial/listloader.pl @@ -13,6 +13,7 @@ # 60811-1329 - changed to use /etc/astguiclient.conf for configs # 60822-1121 - fixed for nonwritable directories # 60906-1058 - added filter of non-digits in alt_phone field +# 61110-1229 - added new USA-Canada DST scheme and Brazil DST scheme # ### begin parsing run-time options ### @@ -317,12 +318,21 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { $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) {$area_GMT++;} + $AC_processed++; + } if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) ) { if ($DBX) {print " First Sunday April to Last Sunday October\n";} - &USA_dstcalc; - if ($DBX) {print " DST: $USA_DST\n";} - if ($USA_DST) {$gmt_offset++;} + &NA_dstcalc; + if ($DBX) {print " DST: $NA_DST\n";} + if ($NA_DST) {$area_GMT++;} $AC_processed++; } if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) ) @@ -357,6 +367,14 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { 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) {$area_GMT++;} + $AC_processed++; + } if (!$AC_processed) { if ($DBX) {print " No DST Method Found\n";} @@ -406,12 +424,12 @@ exit; -sub USA_dstcalc { +sub USACAN_dstcalc { #********************************************************************** -# FSA-LSO +# SSM-FSN # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. -# Based on first Sunday in April and last Sunday in October at 2 am. +# Based on Second Sunday March to First Sunday November at 2 am. # INPUTS: # mm INTEGER Month. # dd INTEGER Day of the month. @@ -425,59 +443,140 @@ sub USA_dstcalc { # and 9:00 UTC in October # OUTPUT: # INTEGER 1 = DST, 0 = not DST +# +# S M T W T F S +# 1 2 3 4 5 6 7 +# 8 9 10 11 12 13 14 +#15 16 17 18 19 20 21 +#22 23 24 25 26 27 28 +#29 30 31 +# +# S M T W T F S +# 1 2 3 4 5 6 +# 7 8 9 10 11 12 13 +#14 15 16 17 18 19 20 +#21 22 23 24 25 26 27 +#28 29 30 31 +# +#********************************************************************** + + $USACAN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 11) { + $USACAN_DST=0; return 0; + } elsif ($mm >= 4 && $mm <= 10) { + $USACAN_DST=1; return 1; + } elsif ($mm == 3) { + if ($dd > 13) { + $USACAN_DST=1; return 1; + } elsif ($dd >= ($dow+8)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $USACAN_DST=0; return 0; + } else { + $USACAN_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $USACAN_DST=0; return 0; + } else { + $USACAN_DST=1; return 1; + } + } + } else { + $USACAN_DST=0; return 0; + } + } elsif ($mm == 11) { + if ($dd > 7) { + $USACAN_DST=0; return 0; + } elsif ($dd < ($dow+1)) { + $USACAN_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USACAN_DST=1; return 1; + } else { + $USACAN_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 7200) { + $USACAN_DST=1; return 1; + } else { + $USACAN_DST=0; return 0; + } + } + } else { + $USACAN_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub NA_dstcalc { +#********************************************************************** +# FSA-LSO +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in April and last Sunday in October at 2 am. #********************************************************************** - $USA_DST=0; + $NA_DST=0; $mm = $mon; $dd = $mday; $ns = $dsec; $dow= $wday; if ($mm < 4 || $mm > 10) { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } elsif ($mm >= 5 && $mm <= 9) { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } elsif ($mm == 4) { if ($dd > 7) { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } elsif ($dd >= ($dow+1)) { if ($timezone) { if ($dow == 0 && $ns < (7200+$timezone*3600)) { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } else { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } } else { if ($dow == 0 && $ns < 7200) { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } else { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } } } else { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } } elsif ($mm == 10) { if ($dd < 25) { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } elsif ($dd < ($dow+25)) { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } elsif ($dow == 0) { if ($timezone) { # UTC calculations if ($ns < (7200+($timezone-1)*3600)) { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } else { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } } else { # local time calculations if ($ns < 7200) { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } else { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } } } else { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } } # end of month checks } # end of subroutine dstcalc @@ -487,6 +586,7 @@ sub USA_dstcalc { sub GBR_dstcalc { #********************************************************************** +# LSM-LSO # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. # Based on last Sunday in March and last Sunday in October at 1 am. @@ -554,6 +654,7 @@ sub GBR_dstcalc { sub AUS_dstcalc { #********************************************************************** +# LSO-LSM # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. # Based on last Sunday in October and last Sunday in March at 1 am. @@ -622,6 +723,7 @@ sub AUS_dstcalc { sub AUST_dstcalc { #********************************************************************** +# FSO-LSM # TASMANIA ONLY # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. @@ -661,7 +763,7 @@ sub AUST_dstcalc { $AUST_DST=0; return 0; } } elsif ($mm == 10) { - if ($dd > 7) { + if ($dd >= 8) { $AUST_DST=1; return 1; } elsif ($dd >= ($dow+1)) { if ($timezone) { @@ -689,6 +791,7 @@ sub AUST_dstcalc { sub NZL_dstcalc { #********************************************************************** +# FSO-TSM # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. # Based on first Sunday in October and third Sunday in March at 1 am. @@ -727,7 +830,7 @@ sub NZL_dstcalc { $NZL_DST=0; return 0; } } elsif ($mm == 10) { - if ($dd > 7) { + if ($dd >= 8) { $NZL_DST=1; return 1; } elsif ($dd >= ($dow+1)) { if ($timezone) { @@ -748,3 +851,71 @@ sub NZL_dstcalc { } } # end of month checks } # end of subroutine dstcalc + + + + +sub BZL_dstcalc { +#********************************************************************** +# TSO-LSF +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. Brazil +# Based on Third Sunday October to Last Sunday February at 1 am. +#********************************************************************** + + $BZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 2 || $mm > 10) { + $BZL_DST=1; return 1; + } elsif ($mm >= 3 && $mm <= 9) { + $BZL_DST=0; return 0; + } elsif ($mm == 2) { + if ($dd < 22) { + $BZL_DST=1; return 1; + } elsif ($dd < ($dow+22)) { + $BZL_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=1; return 1; + } else { + $BZL_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=1; return 1; + } else { + $BZL_DST=0; return 0; + } + } + } else { + $BZL_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 22) { + $BZL_DST=0; return 0; + } elsif ($dd < ($dow+22)) { + $BZL_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=0; return 0; + } else { + $BZL_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=0; return 0; + } else { + $BZL_DST=1; return 1; + } + } + } else { + $BZL_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc diff --git a/agc_2-X/trunk/www/vicidial/listloader_super.pl b/agc_2-X/trunk/www/vicidial/listloader_super.pl index d2868bf4..d2fe23c8 100644 --- a/agc_2-X/trunk/www/vicidial/listloader_super.pl +++ b/agc_2-X/trunk/www/vicidial/listloader_super.pl @@ -12,6 +12,7 @@ # 60811-1232 - Changed to DBI # 60811-1329 - changed to use /etc/astguiclient.conf for configs # 60906-1056 - added filter of non-digits in alt_phone field +# 61110-1229 - added new USA-Canada DST scheme and Brazil DST scheme # ### begin parsing run-time options ### @@ -317,12 +318,21 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { $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) {$area_GMT++;} + $AC_processed++; + } if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) ) { if ($DBX) {print " First Sunday April to Last Sunday October\n";} - &USA_dstcalc; - if ($DBX) {print " DST: $USA_DST\n";} - if ($USA_DST) {$gmt_offset++;} + &NA_dstcalc; + if ($DBX) {print " DST: $NA_DST\n";} + if ($NA_DST) {$area_GMT++;} $AC_processed++; } if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) ) @@ -357,6 +367,14 @@ foreach $oWkS (@{$oBook->{Worksheet}}) { 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) {$area_GMT++;} + $AC_processed++; + } if (!$AC_processed) { if ($DBX) {print " No DST Method Found\n";} @@ -406,12 +424,12 @@ exit; -sub USA_dstcalc { +sub USACAN_dstcalc { #********************************************************************** -# FSA-LSO +# SSM-FSN # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. -# Based on first Sunday in April and last Sunday in October at 2 am. +# Based on Second Sunday March to First Sunday November at 2 am. # INPUTS: # mm INTEGER Month. # dd INTEGER Day of the month. @@ -425,59 +443,140 @@ sub USA_dstcalc { # and 9:00 UTC in October # OUTPUT: # INTEGER 1 = DST, 0 = not DST +# +# S M T W T F S +# 1 2 3 4 5 6 7 +# 8 9 10 11 12 13 14 +#15 16 17 18 19 20 21 +#22 23 24 25 26 27 28 +#29 30 31 +# +# S M T W T F S +# 1 2 3 4 5 6 +# 7 8 9 10 11 12 13 +#14 15 16 17 18 19 20 +#21 22 23 24 25 26 27 +#28 29 30 31 +# +#********************************************************************** + + $USACAN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 11) { + $USACAN_DST=0; return 0; + } elsif ($mm >= 4 && $mm <= 10) { + $USACAN_DST=1; return 1; + } elsif ($mm == 3) { + if ($dd > 13) { + $USACAN_DST=1; return 1; + } elsif ($dd >= ($dow+8)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $USACAN_DST=0; return 0; + } else { + $USACAN_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $USACAN_DST=0; return 0; + } else { + $USACAN_DST=1; return 1; + } + } + } else { + $USACAN_DST=0; return 0; + } + } elsif ($mm == 11) { + if ($dd > 7) { + $USACAN_DST=0; return 0; + } elsif ($dd < ($dow+1)) { + $USACAN_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USACAN_DST=1; return 1; + } else { + $USACAN_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 7200) { + $USACAN_DST=1; return 1; + } else { + $USACAN_DST=0; return 0; + } + } + } else { + $USACAN_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub NA_dstcalc { +#********************************************************************** +# FSA-LSO +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in April and last Sunday in October at 2 am. #********************************************************************** - $USA_DST=0; + $NA_DST=0; $mm = $mon; $dd = $mday; $ns = $dsec; $dow= $wday; if ($mm < 4 || $mm > 10) { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } elsif ($mm >= 5 && $mm <= 9) { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } elsif ($mm == 4) { if ($dd > 7) { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } elsif ($dd >= ($dow+1)) { if ($timezone) { if ($dow == 0 && $ns < (7200+$timezone*3600)) { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } else { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } } else { if ($dow == 0 && $ns < 7200) { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } else { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } } } else { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } } elsif ($mm == 10) { if ($dd < 25) { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } elsif ($dd < ($dow+25)) { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } elsif ($dow == 0) { if ($timezone) { # UTC calculations if ($ns < (7200+($timezone-1)*3600)) { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } else { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } } else { # local time calculations if ($ns < 7200) { - $USA_DST=1; return 1; + $NA_DST=1; return 1; } else { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } } } else { - $USA_DST=0; return 0; + $NA_DST=0; return 0; } } # end of month checks } # end of subroutine dstcalc @@ -487,6 +586,7 @@ sub USA_dstcalc { sub GBR_dstcalc { #********************************************************************** +# LSM-LSO # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. # Based on last Sunday in March and last Sunday in October at 1 am. @@ -554,6 +654,7 @@ sub GBR_dstcalc { sub AUS_dstcalc { #********************************************************************** +# LSO-LSM # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. # Based on last Sunday in October and last Sunday in March at 1 am. @@ -622,6 +723,7 @@ sub AUS_dstcalc { sub AUST_dstcalc { #********************************************************************** +# FSO-LSM # TASMANIA ONLY # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. @@ -661,7 +763,7 @@ sub AUST_dstcalc { $AUST_DST=0; return 0; } } elsif ($mm == 10) { - if ($dd > 7) { + if ($dd >= 8) { $AUST_DST=1; return 1; } elsif ($dd >= ($dow+1)) { if ($timezone) { @@ -689,6 +791,7 @@ sub AUST_dstcalc { sub NZL_dstcalc { #********************************************************************** +# FSO-TSM # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. # Based on first Sunday in October and third Sunday in March at 1 am. @@ -727,7 +830,7 @@ sub NZL_dstcalc { $NZL_DST=0; return 0; } } elsif ($mm == 10) { - if ($dd > 7) { + if ($dd >= 8) { $NZL_DST=1; return 1; } elsif ($dd >= ($dow+1)) { if ($timezone) { @@ -748,3 +851,71 @@ sub NZL_dstcalc { } } # end of month checks } # end of subroutine dstcalc + + + + +sub BZL_dstcalc { +#********************************************************************** +# TSO-LSF +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. Brazil +# Based on Third Sunday October to Last Sunday February at 1 am. +#********************************************************************** + + $BZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 2 || $mm > 10) { + $BZL_DST=1; return 1; + } elsif ($mm >= 3 && $mm <= 9) { + $BZL_DST=0; return 0; + } elsif ($mm == 2) { + if ($dd < 22) { + $BZL_DST=1; return 1; + } elsif ($dd < ($dow+22)) { + $BZL_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=1; return 1; + } else { + $BZL_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=1; return 1; + } else { + $BZL_DST=0; return 0; + } + } + } else { + $BZL_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 22) { + $BZL_DST=0; return 0; + } elsif ($dd < ($dow+22)) { + $BZL_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=0; return 0; + } else { + $BZL_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=0; return 0; + } else { + $BZL_DST=1; return 1; + } + } + } else { + $BZL_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc 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 6e4922b0..94919350 100644 --- a/agc_2-X/trunk/www/vicidial/new_listloader_superL.php +++ b/agc_2-X/trunk/www/vicidial/new_listloader_superL.php @@ -15,11 +15,12 @@ # 60619-1651 - Added variable filtering to eliminate SQL injection attack threat # 60822-1121 - fixed for nonwritable directories # 60906-1100 - added filter of non-digits in alt_phone field +# 61110-1222 - added new USA-Canada DST scheme and Brazil DST scheme # # make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. -$version = '2.0.1'; -$build = '60906-1100'; +$version = '2.0.2'; +$build = '61110-1222'; require("dbconnect.php"); @@ -368,7 +369,7 @@ function ParseFileName() { $state = $row[$state_field]; $province = $row[$province_field]; $postal_code = $row[$postal_code_field]; - $country_code = $row[$country_code_field]; + $country_code = $row[$country_code_field]; $gender = $row[$gender_field]; $date_of_birth = $row[$date_of_birth_field]; $alt_phone = eregi_replace("[^0-9]", "", $row[$alt_phone_field]); @@ -477,7 +478,7 @@ function ParseFileName() { $state = $row[$state_field]; $province = $row[$province_field]; $postal_code = $row[$postal_code_field]; - $country_code = $row[$country_code_field]; + $country_code = $row[$country_code_field]; $gender = $row[$gender_field]; $date_of_birth = $row[$date_of_birth_field]; $alt_phone = eregi_replace("[^0-9]", "", $row[$alt_phone_field]); @@ -605,7 +606,7 @@ if ($leadfile && filesize($LF_path)<=8388608) { $state = $row[13]; $province = $row[14]; $postal_code = $row[15]; - $country_code = $row[16]; + $country_code = $row[16]; $gender = $row[17]; $date_of_birth = $row[18]; $alt_phone = eregi_replace("[^0-9]", "", $row[19]); @@ -730,7 +731,7 @@ if ($leadfile && filesize($LF_path)<=8388608) { $state = $row[13]; $province = $row[14]; $postal_code = $row[15]; - $country_code = $row[16]; + $country_code = $row[16]; $gender = $row[17]; $date_of_birth = $row[18]; $alt_phone = eregi_replace("[^0-9]", "", $row[19]); @@ -1086,14 +1087,14 @@ $AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Sy $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); $AC_processed=0; -if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) +if ( (!$AC_processed) and ($dst_range == 'SSM-FSN') ) { - if ($DBX) {print " First Sunday April to Last Sunday October\n";} + if ($DBX) {print " Second Sunday March to First Sunday November\n";} #********************************************************************** - # FSA-LSO + # SSM-FSN # This is returns 1 if Daylight Savings Time is in effect and 0 if # Standard time is in effect. - # Based on first Sunday in April and last Sunday in October at 2 am. + # Based on Second Sunday March to First Sunday November at 2 am. # INPUTS: # mm INTEGER Month. # dd INTEGER Day of the month. @@ -1107,6 +1108,89 @@ if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) # and 9:00 UTC in October # OUTPUT: # INTEGER 1 = DST, 0 = not DST + # + # S M T W T F S + # 1 2 3 4 5 6 7 + # 8 9 10 11 12 13 14 + #15 16 17 18 19 20 21 + #22 23 24 25 26 27 28 + #29 30 31 + # + # S M T W T F S + # 1 2 3 4 5 6 + # 7 8 9 10 11 12 13 + #14 15 16 17 18 19 20 + #21 22 23 24 25 26 27 + #28 29 30 31 + # + #********************************************************************** + + $USACAN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 11) { + $USACAN_DST=0; + } elseif ($mm >= 4 and $mm <= 10) { + $USACAN_DST=1; + } elseif ($mm == 3) { + if ($dd > 13) { + $USACAN_DST=1; + } elseif ($dd >= ($dow+8)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USACAN_DST=0; + } else { + $USACAN_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USACAN_DST=0; + } else { + $USACAN_DST=1; + } + } + } else { + $USACAN_DST=0; + } + } elseif ($mm == 11) { + if ($dd > 7) { + $USACAN_DST=0; + } elseif ($dd < ($dow+1)) { + $USACAN_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USACAN_DST=1; + } else { + $USACAN_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USACAN_DST=1; + } else { + $USACAN_DST=0; + } + } + } else { + $USACAN_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $USACAN_DST\n";} + if ($USACAN_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. #********************************************************************** $USA_DST=0; @@ -1438,6 +1522,77 @@ if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) if ($NZL_DST) {$gmt_offset++;} $AC_processed++; } + +if ( (!$AC_processed) and ($dst_range == 'TSO-LSF') ) + { + if ($DBX) {print " Third Sunday October to Last Sunday February\n";} + #********************************************************************** + # TSO-LSF + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. Brazil + # Based on Third Sunday October to Last Sunday February at 1 am. + #********************************************************************** + + $BZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 2 || $mm > 10) { + $BZL_DST=1; + } elseif ($mm >= 3 and $mm <= 9) { + $BZL_DST=0; + } elseif ($mm == 2) { + if ($dd < 22) { + $BZL_DST=1; + } elseif ($dd < ($dow+22)) { + $BZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=1; + } else { + $BZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=1; + } else { + $BZL_DST=0; + } + } + } else { + $BZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 22) { + $BZL_DST=0; + } elseif ($dd < ($dow+22)) { + $BZL_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=0; + } else { + $BZL_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=0; + } else { + $BZL_DST=1; + } + } + } else { + $BZL_DST=1; + } + } # end of month checks + 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";}