Done! With fair warning to the reader I might add :)
 
-----Original Message-----
From: Ernest W. Lessenger [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 05, 2003 3:14 PM
To: [EMAIL PROTECTED]
Subject: RE: [SAtalk] Re: Creating rule for time accepted

Thanks for assuming that I'm a more ept Perl coder than other readers ;) You may certainly add it to the emporium... with the weak assumption below noted, please. I've tested and debugged this code on my own server, and it seems to work as advertised.

I wrote a quick eval function that work as a proof-of-concept. It doesn't look at the headers at all... instead it uses the current system time and *assumes* that the email is being scanned within a few minutes of being received by the local server. I am aware that this is a weak assumption in many (most?) cases, but this code has the advantage of being absolutely immune to forged Date: or Received: headers.

** Append to EvalTests.pm
# This function expects $min and $max strings in "HHMM" format WITHOUT A LEADING "0"
# $min < $max : Returns 1 if the CURRENT time is between $min and $max
# $min > $max : Returns 1 if the CURRENT time is NOT between $min and $max ; this
#               corresponds to the situation when a time-span includes midnight
# You can use META rules to create more complicated time spans if you need them
sub received_between {
  my ($self, $min, $max) = @_;
  local ($_);
  my ($sec,$minute,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
  my $timeVal = ($hour * 100) + $minute;

  if ($min <= $max) {
    return 1 if (($timeVal > $min) && ($timeVal < $max));
  }
  else {
    return 1 if (($timeVal > $min) || ($timeVal < $max));
  }

  return 0;
}

** Append to 20_head_tests.cf
header RECVD_OUTSIDE_BUS_HOURS  eval:received_between("1900","800")
describe RECVD_OUTSIDE_BUS_HOURS The CURRENT time is outside of business hours

header RECVD_BUS_HOURS  eval:received_between("800","1900")
describe RECVD_BUS_HOURS The CURRENT time is inside of business hours

** Append to 50_scores.cf  or local.cf (I'm an ISP, and prefer false-negatives over false-positives within reason)
score RECVD_BUS_HOURS -0.33
# score RECVD_OUTSIDE_BUS_HOURS 0.33

--Ernest


At 09:36 AM 8/5/2003 -0400, you wrote:
> -----Original Message-----
> From: Ernest W. Lessenger [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 05, 2003 3:36 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [SAtalk] Re: Creating rule for time accepted
>
>
> At 12:40 AM 8/5/2003 -0500, you wrote:
> >     my $timeString = sprintf("%02d%02d", $hour, $min);
> >
> >This is some really great work, by the way.  :)
>
> Thanks and thanks :) Hope it comes in useful.
>
> --Ernest
>
>

Cool! For the perl inepdt, can you post a fixed version of the code?

Can I add this to a section of the Emporium? After tested of course :)

Chris Santerre
System Admin and SA Custom Rules Emporium keeper
http://www.merchantsoverseas.com/wwwroot/gorilla/sa_rules.htm
"A little nonsense now and then, is relished by the wisest men." - Willy
Wonka

Reply via email to