#!/var/spool/perl/perl # # Requires: lib nrc # $spath_real: the path of the script on the server $spath_real = '/var/spool/perl/W2/'; # Obtain the subroutines needed require "${spath_real}lib"; require "${spath_real}nrc"; # $fromname: real name of email to requestor # $frommail: "sender" of email to requestor # $fromphone: phone number to call in case of problems $fromname = "Weekeditie Administratie"; $frommail = "admin\@nrc.nl"; $fromphone = "010-4067000"; # $requestdir: directory in which request should be stored $requestdir = "/var/spool/requests/"; $requestfile = "proefnummer.new"; # $topfile: file to be inserted at top of document # $bottomfile: file to be inserted at bottom of document $topfile = "${insertdir}proefnummer.begin"; $bottomfile = "${insertdir}proefnummer.eind"; # Print HTTP header &HTTPHeader; # Check if POST data available, return if not # Check if all fields are entered, return if not # Check if adapting request, return if so # Check if final request, return if so exit if &FirstTime; exit if &Missing; exit if &Editing; exit if &NotFinal; # Add data to requests file, return if failed # Check if mail sent, return if not exit unless &AddRequest; exit unless &SendMail; &Title( "Service: proefnummer weekeditie aanvraag in behandeling" ); &Top; print <
EOD

&ShowFields( "","" );

print <
Tevens is een kopie van uw aanvraag naar uw email-adres
toegestuurd.
EOD

&Bottom;
&End;

#----------------------------------------------------------
sub FirstTime {
return undef if &ReadParse;

&Title( "Service: proefnummer weekeditie" );
&Top;

&Form;

print "
"; &EndForm( "Stuur mijn verzoek op" ); print "
"; &Bottom; &End; } #---------------------------------------------------------- sub Missing { local( $missing ); local( %musthave ); %musthave = ( "name","Naam","address","Adres", "zip","Postcode","place","Plaats", "email","Email" ); $in{'email'} = '' unless $in{'email'} =~ m#\@#; foreach( sort keys( %musthave ) ) { unless( $in{$_} ) { unless( $missing++ ) { &Title( "Een of meer velden niet (juist) ingevuld" ); &Top; print "
U heeft de volgende velden niet of niet juist ingevuld:
\n"; } print "| $musthave{$_} |\n"; } } return undef unless $missing; print <Vul ook deze velden (juist) in!

EOD &Form; print "
"; &EndForm( "Ja, ik heb de ontbrekende velden ingevuld" ); print "
"; &Bottom; &End; } #---------------------------------------------------------- sub Editing { return undef if $in{"type"} ne "edit"; &Title( "Service: proefnummer weekeditie" ); &Top; &Form; print "
"; &EndForm( "Stuur mijn verzoek op" ); print "
"; &Bottom; &End; } #---------------------------------------------------------- sub NotFinal { return undef if $in{"type"}; &Title( "Service: proefnummer weekeditie bevestigen" ); &Top; print <
EOD

&ShowFields( "","" );

print <
EOD &StartForm; $in{"type"} = "final"; &HideFields( "type","name","sex","address","zip","place", "state","country","email" ); &EndForm( "Ja, ik ben zeker" ); &StartForm; $in{"type"} = "edit"; &HideFields( "type","name","sex","address","zip","place", "state","country","email" ); &EndForm( "Nee, ik wil nog veranderen" ); print "
"; &Bottom; &End; } #---------------------------------------------------------- sub AddRequest { local( $filename ) = $requestdir.$requestfile; &ErrorOpen( $filename ) unless open( REQUEST,"+>>$filename"); local( $date ) = `date`; chop( $date ); local( $sex ) = "($in{'sex'})" if $in{'sex'}; print REQUEST < $date $IP $in{"name"} $sex $in{"address"} $in{"zip"} $in{"place"} $in{"state"} $in{"country"} $in{"email"} EOD close( REQUEST ); } #---------------------------------------------------------- sub SendMail { local( $mail ) = "|$sendmail -odb -t -f$frommail -F\"$fromname\""; &ErrorOpen( $mail ) unless open( MAIL,$mail ); local( $OLD ) = select( MAIL ); print < IP: $IP To: $in{"name"} <$in{"email"}> Bcc: liz\@xxlink.nl,adj\@nrc.nl Subject: Bevestiging Proefnummer Weekeditie Dit is een bevestiging van een aanvraag voor een proefnummer van de weekeditie van NRC Handelsblad. Waarvoor onze dank. De volgende gegevens zijn gebruikt bij de aanvraag van uw proefnummer: EOD &ShowFields; print <Ja, ik wil graag een gratis proefnummer van NRC Weekeditie. U kunt het proefnummer sturen aan:
EOD

print "       Naam: ";
print "M ";
print "V\n";

print <
   Postcode: 
     Plaats: 
Prov./Staat: 
       Land: 

      Email:  (voor bevestiging)
EOD }