#!/usr/local/bin/perl # The first line should be where perl resides on the local system. $company = "chang\@cs.pitt.edu"; $webmaster = "chang\@cs.pitt.edu"; # You can have a list of e-mail addresses in the memberlist. $memberlist = "chang\@cs.pitt.edu ganesh\@cs.pitt.edu clausej\@cs.pitt.edu epavlak\@cs.pitt.edu anjana24\@cs.pitt.edu rnataraj\@cs.pitt.edu danlyker\@hotmail.com cbryant\@alumni.pitt.edu pgandra\@cs.pitt.edu sureshrangan\@hotmail.com zysxqn\@cs.pitt.edu rvillsal\@cs.pitt.edu jmisurda\@cs.pitt.edu garman\@cs.pitt.edu bps\@cs.pitt.edu beamt\@cs.pitt.edu annst13\@cs.pitt.edu cjsst55\@cs.pitt.edu giu\@cs.pitt.edu "; $memberlist = $memberlist . " hling\@cs.pitt.edu "; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $mon = $mon + 1; if ($ENV{'REQUEST_METHOD'} eq 'POST') { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); # Load the FORM variables foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } # Open the email message to send the data to webmaster if($FORM{comm1} ne "") { open (MESSAGE, "| mail $webmaster "); # The mail utility is in mail so you need to change that if different. # Format email header information print MESSAGE "To: $company\n"; if ($FORM{email} ne "") { print MESSAGE "Reply-To: $FORM{email}\n"; } # Write the actual email message print MESSAGE "Subject: CS2310 Message from $ENV{'REMOTE_HOST'}\n\n"; print MESSAGE "Name: $FORM{name}\n"; print MESSAGE "Address: $FORM{address}\n"; print MESSAGE "Telephone: $FORM{tel}\n"; print MESSAGE "Fax: $FORM{fax}\n"; print MESSAGE "Email: $FORM{email}\n"; print MESSAGE "Message to Host: $FORM{comm1}\n"; close (MESSAGE); } # Open the email message to send the data to a list of members if($FORM{comm2} ne "") { open (MESSAGE, "| mail $memberlist "); # Format email header information print MESSAGE "To: $company\n"; if ($FORM{email} ne "") { print MESSAGE "Reply-To: $FORM{email}\n"; } # Write the actual email message print MESSAGE "Subject: CS2310 Message from $ENV{'REMOTE_HOST'}\n\n"; print MESSAGE "Name: $FORM{name}\n"; print MESSAGE "Address: $FORM{address}\n"; print MESSAGE "Telephone: $FORM{tel}\n"; print MESSAGE "Fax: $FORM{fax}\n"; print MESSAGE "Email: $FORM{email}\n"; print MESSAGE "Message to All: $FORM{comm2}\n"; close (MESSAGE); # Also post this message # If you use a different directory, you may need to change to full_path_name. open (MESSAGE, "> t1"); print MESSAGE "

\n"; print MESSAGE " Message from $ENV{'REMOTE_HOST'}
"; print MESSAGE "Name: $FORM{name}
"; print MESSAGE "Email: $FORM{email}
"; print MESSAGE "Time/Date:$hour:$min:$sec / $mon-$mday-$year,
"; print MESSAGE "Posted Message: $FORM{comm2}


"; close (MESSAGE); # The bulletin bu.html and two temporary files t1 and t2, are in local directory. # We use local files t1 and t2 so that a new message appears at the top of bulletin. $ans=`cat t1 bu.html > t2`; $ans=`cp t2 bu.html`; } # Post message to the bulletin board only if( $FORM{comm3} ne "") { open (MESSAGE, "> t1"); print MESSAGE "

\n"; print MESSAGE " CS2310 Message from $ENV{'REMOTE_HOST'}
"; print MESSAGE "Name: $FORM{name}
"; print MESSAGE "Email: $FORM{email}
"; print MESSAGE "Time/Date:$hour:$min:$sec / $mon-$mday-$year,
"; print MESSAGE "Posted Message: $FORM{comm3}


"; close (MESSAGE); $ans=`cat t1 bu.html > t2`; $ans=`cp t2 bu.html`; } # Thank the user and acknowledge the order &thank_you; } else { # Format an error message for the user print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "Message Form Error\n"; print "\n"; print "\n"; print "

CS2310 Message Form Error

\n"; print "
\n"; print "

\n"; print "Form input was not processed. Please mail your "; print "remarks to $company\n"; print "\n"; print "\n"; } sub thank_you { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "Thank You\n"; print "\n"; print "\n"; print "

Thank You

\n"; print "
\n"; print "

\n"; print "Your CS2310 message have been emailed to host, or emailed to other members, or posted on the bulletin board.\n"; print "\n"; print "\n"; }