#!/usr/bin/perl # # ########################################################################### # # This simple script is for actually sending the mails that # reserve the videos. They already had an expensive system in place for # tracking reservations, so we didn't replicate this system here in cgis # ...we'll just send them some email and let them use the tracking system # they have. # Filename: mail.cgi # -Neil Doane ########################################################################### # Uses Time::Local... push(@INC,"/var/lib/httpd/cgi-bin"); use Time::Local; #use diagnostics; $mailto = "reserve\@localhost"; require "cgi-lib.pl"; &ReadParse(*input); $mailaction = $input{'mailaction'}; $id = $input{'id'}; $title = $input{'title'}; $runtime = $input{'runtime'}; $catalogno = $input{'catalogno'}; $language = $input{'language'}; $annotation = $input{'annotation'}; $rsmonth = $input{'rsmonth'}; $rsday = $input{'rsday'}; $rsyear = $input{'rsyear'}; $rshour = $input{'rshour'}; $rsmin = $input{'rsmin'}; $firstname = $input{'firstname'}; $lastname = $input{'lastname'}; $email = $input{'email'}; $tele = $input{'tele'}; $snailmail = $input{'snailmail'}; $course = $input{'course'}; $building = $input{'building'}; $room = $input{'room'}; $totime = $input{'totime'}; $fromtime = $input{'fromtime'}; $AP1 = $input{'AP1'}; $AP2 = $input{'AP2'}; $Service = $input{'Service'}; $Mon = $input{'Mon'}; $Tue = $input{'Tue'}; $Wed = $input{'Wed'}; $Thu = $input{'Thu'}; $Fri = $input{'Fri'}; $remarks = $input{'remarks'}; $dept = $input{'dept'}; $rtmonth = $input{'rtmonth'}; $rtday = $input{'rtday'}; $rtyear = $input{'rtyear'}; $rthour = $input{'rthour'}; $rtmin = $input{'rtmin'}; print "Content-type:text/html\n"; if ( $mailaction eq "prepare" ) { # Set up the mail form for them. $title =~ s/"/"\;/g; print "\n"; print <Film/Video Reservation Form
  Film/Video Reservation Form
Title: $title
Catalog #:   $catalogno   Runtime:    $runtime minutes     Language:    $language    
Information:
      $annotation
   

Required Information Optional Information
First Name:
Last Name:
Department:
Telephone:
Email Address:
Mailing Address:

Course#:
Building:
Room#:
From:
To:
Service Type
Days Class Meet
M T W Th F
Remarks:

Reservation Details
Reservation Date
Reservation Time
:
Please note: Reservations for the day specified will not be authenticated unless submitted before 12 noon of the previous day.
Return Details
Return Date
Return Time
:



 


[Go back to search results]

PS: If your browser is not JavaScript capable then click the Back button on your browser window twice to take you to the search results.

[ Back To Main Page ]

LUCKY } elsif ($mailaction eq "sendit") { print "Content-type:text/html\n\n"; print ""; $today = time(); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($today); $ressec="00"; $resdate= timelocal($rssec,$rsmin,$rshour,$rsday,$rsmonth,$rsyear) || &ErrBadDate; ($rstsec,$rstmin,$rsthour,$rstmday,$rstmon,$rstyear,$rstwday,$rstyday,$rstisdst) = localtime($resdate); $retdate=timelocal($rssec,$rtmin,$rthour,$rtday,$rtmonth,$rtyear); if(($lastname eq "") || ($firstname eq "") || ($dept eq "")|| ($tele eq "") || ($email eq "")) { print "\n"; &NoData; # End first case for 'no required data'. exit(1); #die } else { print""; if(($rsyear%4)==0) #Decision structure for a leap year { if(($rsyear%100)==0) { if(($rsyear%400)==0) { $leap_year="yes"; } else { $leap_year="no"; } } else { $leap_year="yes"; } } else { $leap_year="no" } # End Decision Structure for leap year # Decision structure for checking for an invalid date, e.g : November 31st, etc. if((($rsmonth==3)||($rsmonth==5)||($rsmonth==8)||($rsmonth))&&($rsday==31)) { print"\n"; &ErrBadDate; } elsif($rsmonth==1) #Decision loop to check the validity of dates in the month of Febraury { if(($leap_year eq "yes") && ($rsday>29)) { print "\n"; &ErrBadDate; } elsif(($leap_year eq "no") && ($rsday>28)) { print "\n"; &ErrBadDate; } else { print "\n"; &GoodDate; } } # End decision structure for an invalid date else { print "\n"; &GoodDate; } exit(1); } #end else } # end elsif else { # Do nothing. exit (0); } #-------------BEGIN SUBROUTINES------------# sub NoData { $refer = $ENV{'HTTP_REFERER'}; print < Film/Video Library - DATA ERROR
Data Error

There has been an error processing your request. The most likely reason this has happened is that you have not entered data in the required fields.

Please keep this in mind:

  1. Please enter the appropriate data in the all the Required Datafields

Please go back and try again. PS: If your browser doesnot support JavaScript then click the Backbutton once to take you to the desired location.

DATAMORON &HtmlBot; } sub GoodDate { $tomorrow=$today+86400; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($today); ($tsec,$tmin,$thour,$tmday,$tmon,$tyear,$twday,$tyday,$tisdst) = localtime($tomorrow); $startomorrow=timelocal(00,00,00,$tmday,$tmon,$tyear); $noontoday= timelocal(00,00,12,$mday,$mon,$year); $ressec="00"; $resdate= timelocal($rssec,$rsmin,$rshour,$rsday,$rsmonth,$rsyear) || &ErrBadDate; ($rstsec,$rstmin,$rsthour,$rstmday,$rstmon,$rstyear,$rstwday,$rstyday,$rstisdst) = localtime($resdate); $retdate=timelocal($rssec,$rtmin,$rthour,$rtday,$rtmonth,$rtyear); #Check if the reservation day is a sunday or a saturday if(($rstwday==6) || ($rstwday==0)) { print "\n"; &ErrWeekend; exit(0); } else{} #Check if the day of request for reservation is a saturday or a sunday and # the reservation day is the following monday. if((($wday==6)||($wday==0)) && ($rstwday==1)) { print "\n"; &ErrWeekend; exit(1); } #Check if the date for request for reservation day and reservation day are #consecutive and if the time of reserving is before noon. if((($resdate-$startomorrow)<86400) && (($resdate-$startomorrow)>0)) { if($noontoday>$today) { print "\n"; &Success; } else { print "\n"; &ErrBadDate; } } elsif(($resdate-$startomorrow)>=86400) { if(($wday==5) && ( $rstwday==1)) { if($noontoday>$today) { print " \n"; &CheckRetDate; # &Success; } else { print "\n"; &ErrWeekend; } } else { print "\n "; &CheckRetDate; # &Success; } } else { print "\n"; &ErrBadDate; } &HtmlBot; } sub CheckRetDate { $rssec=00; $resdate= timelocal($rssec,$rsmin,$rshour,$rsday,$rsmonth,$rsyear); $retdate=timelocal($rssec,$rtmin,$rthour,$rtday,$rtmonth,$rtyear); ($rttsec,$rttmin,$rtthour,$rttmday,$rttmon,$rttyear,$rttwday,$rttyday,$rttisdst) = localtime($retdate); if(($rttwday==6)||($rttwday==0)) { print "\n"; &ErrWeekend; exit(1); } else { #Do Nothing } if($retdate<=$resdate) { print "\n"; &ErrRetDate; } else { print "\n"; &Success; } } sub ErrBadDate { $refer = $ENV{'HTTP_REFERER'}; # print "Content-type:text/html\n\n"; print < Film/Video Library - Date Error : Bad Date
Date Error

There has been an error processing your request. The most likely reason this has happened is that you have either attempted to reserve the items on a date that is prior to today's or have not given us enough time to authenticate your request.

Please keep the following in mind:

  1. Select a date for reservation which is later than today.
  2. Submit your reservations before noon of the day previous to the reservation date
  3. Please donot enter invalid dates like 31st of November.

Please go back and try again. PS: If your browser doesnot support JavaScript then click the Backbutton once to take you to the desired location.

GREAT &HtmlBot; } sub ErrRetDate { $refer = $ENV{'HTTP_REFERER'}; # print "Content-type:text/html\n\n"; print < Film/Video Library -Return Date Error
Return Date Error

There has been an error processing your request. The most likely reason this has happened is that you have either attempted to return the items on a date that is prior to the date you want to reserve the item.

Please keep the following in mind:

  1. Submit your return date that is later than the reservation date
  2. Please donot enter invalid dates like 31st of November.

Please go back and try again. PS: If your browser doesnot support JavaScript then click the Backbutton once to take you to the desired location.

GREAT &HtmlBot; } sub ErrWeekend { $refer = $ENV{'HTTP_REFERER'}; # print "Content-type:text/html\n\n"; print < Film/Video Library - Weekend Error
Weekend Error

There has been an error processing your request. The most likely reason this has happened is that you have either attempted to reserve/return the items on a a weekend or you are sending this request on a Friday.

Please keep the following in mind:

  1. Select a reservation date that does not fall on a Saturday or a Sunday.
  2. If you are sending this request on a Friday please note that we cannot process your request for the following Monday unless we recieve your request before noon.

Please go back and try again. PS: If your browser doesnot support JavaScript then click the Backbutton once to take you to the desired location.

GREAT &HtmlBot; } sub Success { $newrsmon = $rsmonth+1; $newrtmon = $rtmonth+1; $title =~ s/"/"\;/g; $refer = $ENV{'HTTP_REFERER'}; $realdate = localtime(time); open(MAIL,"| mail $mailto"); print MAIL < Film/Video Library - Reservation Request Sent
Reservation Request Sent

Your request has been sent. you should be recieving an e-mail confirming your reservation within 24 hours.
Back to browsing section
PS: If your browser doesnot support JavaScript then click on your browser's Back button three times to take you to the desired location.
KITTY &HtmlBot; } sub HtmlBot { return "\n\n"; }