From: David R. <da...@pi...> - 2004-11-29 14:44:26
|
Okay. What I'm including in this e-mail is a diff of the original FormMail.pl file and what I've changed. I didn't want to include the full body of the changes just because it seems rather large for an e-mail. A new optional field can be specified in the HTML to set the cutoff date/time. The form field is called "cutoff_datetime" and the field value is of the form "MM/DD/YYYY-HH:MM:SS". The changes were made to version 3.14c1 FormMail compatibility package. Command "diff FormMailJDR.pl FormMail.pl". --- BEGIN DIFF 2096,2099d2095 < # JDR - Cutoff Date Enhancment - Begin CB1 < my $curdate = $self->current_date; < my $curtime = $self->current_time; < # JDR - Cutoff Date Enhancement - End CB1 2103,2108d2098 < # JDR - Cutoff Date Enhancement - Begin CB2 < if (scalar $self->check_date_time($curdate, $curtime)) { < $self->past_cutoff_time_output; < return; < } < # JDR - Cutoff Date Enhancement - End CB2 2129,2156d2118 < # JDR - Cutoff Date Enhancement - Begin CB3 < =item current_date () < < Returns current day of the year < < =cut < < sub current_date { < my ($self) = @_; < < return (localtime)[7]; < < } < < =item current_time () < < Returns current second of the day < < =cut < < sub current_time { < my ($self) = @_; < < return ((localtime)[0] + (localtime)[1]*60 + (localtime)[2]*60*60); < < } < # JDR - Cutoff Date Enhancement - End CB3 < 2353d2314 < # JDR - Cutoff Date Enhancement - Added cutoff_datetime var 2375d2335 < cutoff_datetime 2737,2910d2696 < < # JDR - Cutoff Date Enhancement - Begin CB4 < =item check_date_time () < < Checks current date and time against configured date and time. < If the configured date and time are exceeded, an error page is < generated < < =cut < < sub check_date_time { < my ($self, $curdate, $curtime) = @_; < < my ($cutdate) = $self->calc_cutoff_date; < my ($cuttime) = $self->calc_cutoff_time; < < if ($cutdate == 0) { < return 0; < } < < if ($curdate > $cutdate) { < return 1; < } < < if ($curdate == $cutdate) { < if($curtime > $cuttime) { < return 1; < } < } < < return 0; < < } < < =item calc_cutoff_date () < < Produces cutoff date from config string passed to script < < =cut < < sub calc_cutoff_date { < my ($self) = @_; < < my $cutdate = 0; < my $year = 0; < < if ($self->{FormConfig}{cutoff_datetime} =~ < /^\s*(\d{1,2})[\/](\d{1,2})[\/](\d{1,4})/) { < < if(scalar $3 < 100) { < $year = 2000 + scalar $3; < } < else { < $year = scalar $3; < } < < # Calculate day of year from month < if(scalar $1 > 1) { < $cutdate += 30; < } < if(scalar $1 > 2) { < if(($year) % 4 == 0) { < if(($year) % 100 == 0) { < if(($year) % 400 == 0) { < $cutdate += 29; < } < else { < $cutdate += 28; < } < } < else { < $cutdate += 29; < } < } < else { < $cutdate += 28; < } < } < if(scalar $1 > 3) { < $cutdate += 31; < } < if(scalar $1 > 4) { < $cutdate += 30; < } < if(scalar $1 > 5) { < $cutdate += 31; < } < if(scalar $1 > 6) { < $cutdate += 30; < } < if(scalar $1 > 7) { < $cutdate += 31; < } < if(scalar $1 > 8) { < $cutdate += 31; < } < if(scalar $1 > 9) { < $cutdate += 30; < } < if(scalar $1 > 10) { < $cutdate += 31; < } < if(scalar $1 > 11) { < $cutdate += 30; < } < if(scalar $1 > 12) { < # Bad date < return 0; < } < < # Calculate day of year from day of month < if(scalar $2 <= 31) { < $cutdate += scalar $2; < } < } < < return $cutdate; < < } < < =item calc_cutoff_time () < < Produces cutoff time from config string passed to script < < =cut < < sub calc_cutoff_time { < my ($self) = @_; < < my $cuttime = 0; < < if($self->{FormConfig}{cutoff_datetime} =~ < /-(\d{1,2}):(\d{1,2}):(\d{1,2})/ ) { < < if(scalar $1 < 24) { < if(scalar $2 < 60) { < if(scalar $3 < 60) { < $cuttime = $1*60*60 + $2*60 + $3; < } < } < } < } < < return $cuttime; < } < < =item past_cutoff_time_output () < < Produces error message indicating cutoff time has been exceeded < < =cut < < sub past_cutoff_time_output { < my ($self) = @_; < < # Don't really need these vars - was using them for debugging. < my $curdate = $self->current_date; < my $curtime = $self->current_time; < my $cutdate = $self->calc_cutoff_date; < my $cuttime = $self->calc_cutoff_time; < < $self->error_page( 'Error: Cutoff Time Exceeded', <<END ); < <p> < Sorry you missed the cutoff time. Too bad! < </p> < <p> < $self->{FormConfig}{cutoff_datetime} < </p> < <p> < ($curdate:$curtime $cutdate:$cuttime) < </p> < END < } < # JDR - Cutoff Date Enhancement - End CB4 --- END DIFF If there's anything else you want or need from me, please let me know. Currently I'm only subscribed to the end-user support list, not the developer list. You can feel free to chuckle at my Perl hacks. :) David Rosa --- Jonathan Stowe <jn...@ge...> wrote: > From Jonathan Stowe Mon Nov 29 04:36:56 2004 > Subject: Re: [Nms-cgi-support] New FormMail feature > From: Jonathan Stowe <jn...@ge...> > To: Da...@pi... > CC: NMS-CGI-Support <nms...@li...>, > NMS Devel <nms...@li...> > Date: Mon, 29 Nov 2004 12:36:56 +0000 > > On Sun, 2004-11-21 at 11:51, David Rosa wrote: > > I'm sending this to the end-user e-mail list namely because I > consider > > myself more of an end-user than a developer. > > > > I would like you to consider adding a new feature to FormMail. I > use > > FormMail on my website, but I need to prevent users from submitting > > information if a deadline has passed. I had considered using > client > > side scripting, but that seemed to easily spoofed, so instead I'd > like > > FormMail to check the submission date and time and if the > configured > > deadline is past, then provide an error message to the user. > > > > Since I couldn't wait for official support of this feature I've > > modified FormMail so that it supports it. I can submit my changes > if > > anyone is interested, I just didn't want to do it here because of > the > > potential e-mail clutter. > > > > Can you send your amended FormMail.pl to the developers list so we > can > take a look at it? Generally we are not adding new features to > FormMail > prefering instead to focus on our advanced mailer program TFmail, but > if > the change is useful and fits our criteria we could slip in before > the > next release of FOrmMail.pl > > /J\ > -- > > This e-mail is sponsored by http://www.integration-house.com/ > > |