[21762] in Perl-Users-Digest
Perl-Users Digest, Issue: 3966 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 14 11:09:44 2002
Date: Mon, 14 Oct 2002 08:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 14 Oct 2002 Volume: 10 Number: 3966
Today's topics:
New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
Newbie: How can I download a file and after that redire <m.moolenaar@mdc-international.com>
Re: Newbie: How can I download a file and after that re <bernard.el-hagin@DODGE_THISlido-tech.net>
RE (R.Noory)
Re: RE <pinyaj@rpi.edu>
Re: RE <mniederlechner@gmx.net>
Re: RE <nobody@dev.null>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 14 Oct 2002 13:14:05 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <uqlgot2gl30f10@corp.supernews.com>
Following is a summary of articles from new posters spanning a 7 day
period, beginning at 07 Oct 2002 13:57:28 GMT and ending at
14 Oct 2002 12:29:40 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" email address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Find the News-Scan distribution on the CPAN!
<URL:http://www.perl.com/CPAN/modules/by-module/News/>
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
- Copyright (c) 2002 Greg Bacon.
Verbatim copying and redistribution is permitted without royalty;
alteration is not permitted. Redistribution and/or use for any
commercial purpose is prohibited.
Totals
======
Posters: 90 (34.2% of all posters)
Articles: 137 (17.2% of all articles)
Volume generated: 234.9 kb (14.6% of total volume)
- headers: 109.6 kb (2,220 lines)
- bodies: 123.8 kb (4,086 lines)
- original: 91.1 kb (3,139 lines)
- signatures: 1.4 kb (36 lines)
Original Content Rating: 0.736
Averages
========
Posts per poster: 1.5
median: 1.0 post
mode: 1 post - 62 posters
s: 2.7 posts
Message size: 1756.0 bytes
- header: 819.1 bytes (16.2 lines)
- body: 925.7 bytes (29.8 lines)
- original: 681.2 bytes (22.9 lines)
- signature: 10.2 bytes (0.3 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
7 12.1 ( 5.5/ 6.6/ 2.3) some guy <yoman@dude.com>
4 4.3 ( 2.7/ 1.6/ 1.0) kit <manutd_kit@yahoo.com>
4 4.9 ( 2.0/ 2.8/ 2.1) AGoodGuyGoneBad <agoodguygonebad@aol.com>
4 5.1 ( 2.7/ 2.5/ 1.9) Robert Brooks <Use-Author-Supplied-Address-Header@[127.1]>
3 5.9 ( 2.8/ 3.2/ 0.8) "Chuck" <junk.kingsley@sympatico.ca>
3 3.2 ( 2.5/ 0.7/ 0.7) "Rick Hedin" <rhedin@aquifer.geology.uiuc.edu>
3 7.7 ( 2.5/ 5.1/ 3.8) Tennant <tennant2NOSPAM@theforge.demon.co.uk>
3 4.3 ( 2.7/ 1.6/ 0.8) "Me" <ignore@nobody.com>
3 6.0 ( 3.1/ 2.9/ 1.9) "J. Dawson" <nospam@fakedomain.com>
3 4.7 ( 3.1/ 1.6/ 1.2) Matt Eberts <zoips@eesoft.org>
These posters accounted for 4.6% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
12.1 ( 5.5/ 6.6/ 2.3) 7 some guy <yoman@dude.com>
11.2 ( 0.9/ 10.4/ 10.3) 1 rtm <mclay@cfdlab.ae.utexas.edu>
7.7 ( 2.5/ 5.1/ 3.8) 3 Tennant <tennant2NOSPAM@theforge.demon.co.uk>
6.6 ( 2.3/ 4.3/ 2.3) 3 jend <dejen321@yahoo.com>
6.2 ( 1.6/ 4.6/ 1.4) 2 Jeremy Miller <piranha@602.org>
6.0 ( 3.1/ 2.9/ 1.9) 3 "J. Dawson" <nospam@fakedomain.com>
5.9 ( 2.8/ 3.2/ 0.8) 3 "Chuck" <junk.kingsley@sympatico.ca>
5.4 ( 1.3/ 4.1/ 1.8) 2 "Kevin Vaughn" <binabik1@mail.com>
5.1 ( 2.7/ 2.5/ 1.9) 4 Robert Brooks <Use-Author-Supplied-Address-Header@[127.1]>
5.0 ( 1.7/ 3.3/ 2.2) 2 "V. Sanath D. Jayasena" <jayasena@cs.uiuc.edu>
These posters accounted for 4.4% of the total volume.
Top 10 Posters by OCR (minimum of three posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
1.000 ( 0.7 / 0.7) 3 "Rick Hedin" <rhedin@aquifer.geology.uiuc.edu>
0.780 ( 1.9 / 2.5) 4 Robert Brooks <Use-Author-Supplied-Address-Header@[127.1]>
0.756 ( 2.1 / 2.8) 4 AGoodGuyGoneBad <agoodguygonebad@aol.com>
0.746 ( 1.2 / 1.6) 3 Matt Eberts <zoips@eesoft.org>
0.739 ( 3.8 / 5.1) 3 Tennant <tennant2NOSPAM@theforge.demon.co.uk>
0.653 ( 1.0 / 1.6) 4 kit <manutd_kit@yahoo.com>
0.651 ( 1.9 / 2.9) 3 "J. Dawson" <nospam@fakedomain.com>
0.533 ( 2.3 / 4.3) 3 jend <dejen321@yahoo.com>
0.470 ( 0.8 / 1.6) 3 "Me" <ignore@nobody.com>
0.349 ( 2.3 / 6.6) 7 some guy <yoman@dude.com>
Bottom 10 Posters by OCR (minimum of three posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.756 ( 2.1 / 2.8) 4 AGoodGuyGoneBad <agoodguygonebad@aol.com>
0.746 ( 1.2 / 1.6) 3 Matt Eberts <zoips@eesoft.org>
0.739 ( 3.8 / 5.1) 3 Tennant <tennant2NOSPAM@theforge.demon.co.uk>
0.653 ( 1.0 / 1.6) 4 kit <manutd_kit@yahoo.com>
0.651 ( 1.9 / 2.9) 3 "J. Dawson" <nospam@fakedomain.com>
0.533 ( 2.3 / 4.3) 3 jend <dejen321@yahoo.com>
0.470 ( 0.8 / 1.6) 3 "Me" <ignore@nobody.com>
0.349 ( 2.3 / 6.6) 7 some guy <yoman@dude.com>
0.284 ( 0.4 / 1.5) 3 "Andrew V. Tkachenko" <pobugfix@peterlink.ru>
0.250 ( 0.8 / 3.2) 3 "Chuck" <junk.kingsley@sympatico.ca>
12 posters (13%) had at least three posts.
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
5 comp.lang.perl.modules
5 alt.perl
3 de.comp.lang.perl.misc
3 comp.lang.perl
3 comp.unix.shell
2 comp.lang.perl.moderated
2 alt.comp.perlcgi.freelance
1 alt.disasters.misc
1 comp.answers
1 comp.programming
Top 10 Crossposters
===================
Articles Address
-------- -------
6 "E.D.G." <edgrsprj@ix.netcom.com>
2 kit <manutd_kit@yahoo.com>
2 "Sojourneer" <david.hawley@acm.org>
1 capraro@inotech.de
1 Oliver =?iso-8859-1?Q?S=F6der?= <osoeder@gmx.de>
1 "Dave Butler" <davebutlerREMOVE@hotmail.com>
0 "Kevin Vaughn" <binabik1@mail.com>
0 "gbd" <asg779e@earthlink.net>
0 Rob <rob835@hotmail.com>
0 John Clutterbuck <john.clutterbuck@siemens.com>
------------------------------
Date: Mon, 14 Oct 2002 13:19:40 GMT
From: "Maurice Moolenaar" <m.moolenaar@mdc-international.com>
Subject: Newbie: How can I download a file and after that redirect the page to a new html
Message-Id: <Mvzq9.1859403$oa7.64767797@Flipper>
Please help me, I going nuts.
Eclosed you find the entire Perlscipt.
It is a script that has become available throught my Hosting company.
What is does, is it sends an email to a user and then redirectes to another
page.
That works.
But now I want it to do a download first, before it redirects to the other
page.
Is that possible, if yes can anyone help me and look at this code.
Thanks already for any kind of help.
Maurice Moolenaar
#!/usr/bin/perl
############################################################################
##
# FormMail Version 1.9
#
# Copyright 1995-2001 Matt Wright mattw@worldwidemart.com
#
# Created 06/09/95 Last Modified 08/03/01
#
# Matt's Script Archive, Inc.: http://www.worldwidemart.com/scripts/
#
############################################################################
##
# COPYRIGHT NOTICE
#
# Copyright 1995-2001 Matthew M. Wright All Rights Reserved.
#
#
#
# FormMail may be used and modified free of charge by anyone so long as this
#
# copyright notice and the comments above remain intact. By using this
#
# code you agree to indemnify Matthew M. Wright from any liability that
#
# might arise from its use.
#
#
#
# Selling the code for this program without prior written consent is
#
# expressly forbidden. In other words, please ask first before you try and
#
# make money off of my program.
#
#
#
# Obtain permission before redistributing this software over the Internet or
#
# in any other medium. In all cases copyright and header must remain intact
#
############################################################################
##
# ACCESS CONTROL FIX: Peter D. Thompson Yezek
#
# http://www.securityfocus.com/archive/1/62033
#
############################################################################
##
# Define Variables
#
# Detailed Information Found In README File. #
# $mailprog defines the location of your sendmail program on your unix
#
# system.
#
$mailprog = '/usr/sbin/sendmail';
# @referers allows forms to be located only on servers which are defined
#
# in this field. This security fix from the last version which allowed
#
# anyone on any server to use your FormMail script on their web site.
#
@referers = ('theaddressoftheweb.com');
# @recipients defines the e-mail addresses or domain names that e-mail can
#
# be sent to. This must be filled in correctly to prevent SPAM and allow
#
# valid addresses to receive e-mail. Read the documentation to find out how
#
# this variable works!!! It is EXTREMELY IMPORTANT.
#
@recipients = @referers;
# ACCESS CONTROL FIX: Peter D. Thompson Yezek
#
# @valid_ENV allows the sysadmin to define what environment variables can
#
# be reported via the env_report directive. This was implemented to fix
#
# the problem reported at http://www.securityfocus.com/bid/1187
#
@valid_ENV = ('REMOTE_HOST','REMOTE_ADDR','REMOTE_USER','HTTP_USER_AGENT');
# Done
#
############################################################################
##
# Check Referring URL
&check_url;
# Retrieve Date
&get_date;
# Parse Form Contents
&parse_form;
# Check Required Fields
&check_required;
# Send E-Mail
&send_mail;
# Download file before Redirect User
&download_file;
# Return HTML Page or Redirect User
&return_html;
sub check_url {
# Localize the check_referer flag which determines if user is valid.
#
local($check_referer) = 0;
# If a referring URL was specified, for each valid referer, make sure
#
# that a valid referring URL was passed to FormMail.
#
if ($ENV{'HTTP_REFERER'}) {
foreach $referer (@referers) {
if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
$check_referer = 1;
last;
}
}
}
else {
$check_referer = 1;
}
# If the HTTP_REFERER was invalid, send back an error.
#
if ($check_referer != 1) { &error('bad_referer') }
}
sub get_date {
# Define arrays for the day of the week and month of the year.
#
@days = ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
@months = ('January','February','March','April','May','June','July',
'August','September','October','November','December');
# Get the current time and format the hour, minutes and seconds. Add
#
# 1900 to the year to get the full 4 digit year.
#
($sec,$min,$hour,$mday,$mon,$year,$wday) =
(localtime(time))[0,1,2,3,4,5,6];
$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
$year += 1900;
# Format the date.
#
$date = "$days[$wday], $months[$mon] $mday, $year at $time";
}
sub parse_form {
# Define the configuration associative array.
#
%Config = ('recipient','', 'subject','',
'email','', 'realname','',
'redirect','', 'bgcolor','',
'background','', 'link_color','',
'vlink_color','', 'text_color','',
'alink_color','', 'title','',
'sort','', 'print_config','',
'required','', 'env_report','',
'return_link_title','', 'return_link_url','',
'print_blank_fields','', 'missing_fields_redirect','',
'cc','', 'cc_visitor','',
'download','' );
# Determine the form's REQUEST_METHOD (GET or POST) and split the form
#
# fields up into their name-value pairs. If the REQUEST_METHOD was
#
# not GET or POST, send an error.
#
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
# Split the name-value pairs
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
}
else {
&error('request_method');
}
# For each name-value pair:
#
foreach $pair (@pairs) {
# Split the pair up into individual variables.
#
local($name, $value) = split(/=/, $pair);
# Decode the form encoding on the name and value variables.
#
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# If they try to include server side includes, erase them, so they
# aren't a security risk if the html gets returned. Another
# security hole plugged up.
$value =~ s/<!--(.|\n)*-->//g;
# If the field name has been specified in the %Config array, it will
#
# return a 1 for defined($Config{$name}}) and we should associate
#
# this value with the appropriate configuration variable. If this
#
# is not a configuration form field, put it into the associative
#
# array %Form, appending the value with a ', ' if there is already a
#
# value present. We also save the order of the form fields in the
#
# @Field_Order array so we can use this order for the generic sort.
#
if (defined($Config{$name})) {
$Config{$name} = $value;
}
else {
if ($Form{$name} && $value) {
$Form{$name} = "$Form{$name}, $value";
}
elsif ($value) {
push(@Field_Order,$name);
$Form{$name} = $value;
}
}
}
# The next six lines remove any extra spaces or new lines from the
#
# configuration variables, which may have been caused if your editor
#
# wraps lines after a certain length or if you used spaces between field
#
# names or environment variables.
#
$Config{'required'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'required'} =~ s/(\s+)?\n+(\s+)?//g;
$Config{'env_report'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'env_report'} =~ s/(\s+)?\n+(\s+)?//g;
$Config{'print_config'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'print_config'} =~ s/(\s+)?\n+(\s+)?//g;
# Split the configuration variables into individual field names.
#
@Required = split(/,/,$Config{'required'});
@Env_Report = split(/,/,$Config{'env_report'});
@Print_Config = split(/,/,$Config{'print_config'});
# ACCESS CONTROL FIX: Only allow ENV variables in @valid_ENV in
#
# @Env_Report for security reasons.
#
foreach $env_item (@Env_Report) {
foreach $valid_item (@valid_ENV) {
if ( $env_item eq $valid_item ) { push(@temp_array, $env_item) }
}
}
@Env_Report = @temp_array;
}
sub check_required {
# Localize the variables used in this subroutine.
#
local($require, @error);
if ($Config{'subject'} =~ /(\n|\r)/m ||
$Config{'recipient'} =~ /(\n|\r)/m) {
&error('no_recipient');
}
if (!$Config{'recipient'}) {
if (!defined(%Form)) { &error('bad_referer') }
else { &error('no_recipient') }
}
else {
# This block of code requires that the recipient address end with
#
# a valid domain or e-mail address as defined in @recipients.
#
$valid_recipient = 0;
foreach $send_to (split(/,/,$Config{'recipient'})) {
foreach $recipient (@recipients) {
if ($send_to =~ /$recipient$/i) {
push(@send_to,$send_to); last;
}
}
}
if ($#send_to < 0) { &error('no_recipient') }
$Config{'recipient'} = join(',',@send_to);
}
# For each require field defined in the form:
#
foreach $require (@Required) {
# If the required field is the email field, the syntax of the email
#
# address if checked to make sure it passes a valid syntax.
#
if ($require eq 'email' && !&check_email($Config{$require})) {
push(@error,$require);
}
# Otherwise, if the required field is a configuration field and it
#
# has no value or has been filled in with a space, send an error.
#
elsif (defined($Config{$require})) {
if (!$Config{$require}) {
push(@error,$require);
}
}
# If it is a regular form field which has not been filled in or
#
# filled in with a space, flag it as an error field.
#
elsif (!$Form{$require}) {
push(@error,$require);
}
}
# If any error fields have been found, send error message to the user.
#
if (@error) { &error('missing_fields', @error) }
}
sub download_file {
# Local variables used in this subroutine initialized.
#
local($key,$sort_order,$sorted_field);
# If redirect option is used, print the redirectional location header.
#
if ($Config{'download'}) {
print ("Location: $Config{'download'}\n\n");
print ("Location: $Config{'redirect'}\n\n");
}
# Otherwise, begin printing the response page.
#
else {
# Print HTTP header and opening HTML tags.
#
print "Content-type: text/html\n\n";
print "<html>\n <head>\n";
# Print out title of page
#
if ($Config{'title'}) { print "
<title>$Config{'title'}</title>\n" }
else { print " <title>Thank
tle>\n" }
print " </head>\n <body";
# Get Body Tag Attributes
#
&body_attributes;
# Close Body Tag
#
print ">\n <center>\n";
# Print custom or generic title.
#
if ($Config{'title'}) { print " <h1>$Config{'title'}</h1>\n" }
else { print " <h1>Thank You For Filling Out This Form</h1>\n" }
print "</center>\n";
print "Below is what you submitted to $Config{'recipient'} on ";
print "$date<p><hr size=1 width=75\%><p>\n";
# Sort alphabetically if specified:
#
if ($Config{'sort'} eq 'alphabetic') {
foreach $field (sort keys %Form) {
# If the field has a value or the print blank fields option
#
# is turned on, print out the form field and value.
#
if ($Config{'print_blank_fields'} || $Form{$field}) {
print "<b>$field:</b> $Form{$field}<p>\n";
}
}
}
# If a sort order is specified, sort the form fields based on that.
#
elsif ($Config{'sort'} =~ /^order:.*,.*/) {
# Set the temporary $sort_order variable to the sorting order,
#
# remove extraneous line breaks and spaces, remove the order:
#
# directive and split the sort fields into an array.
#
$sort_order = $Config{'sort'};
$sort_order =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$sort_order =~ s/(\s+)?\n+(\s+)?//g;
$sort_order =~ s/order://;
@sorted_fields = split(/,/, $sort_order);
# For each sorted field, if it has a value or the print blank
#
# fields option is turned on print the form field and value.
#
foreach $sorted_field (@sorted_fields) {
if ($Config{'print_blank_fields'} || $Form{$sorted_field}) {
print "<b>$sorted_field:</b> $Form{$sorted_field}<p>\n";
}
}
}
# Otherwise, default to the order in which the fields were sent.
#
else {
# For each form field, if it has a value or the print blank
#
# fields option is turned on print the form field and value.
#
foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field}) {
print "<b>$field:</b> $Form{$field}<p>\n";
}
}
}
print "<p><hr size=1 width=75%><p>\n";
# Check for a Return Link and print one if found.
#
if ($Config{'return_link_url'} && $Config{'return_link_title'}) {
print "<ul>\n";
print "<li><a
href=\"$Config{'return_link_url'}\">$Config{'return_link_title'}</a>\n";
print "</ul>\n";
}
# Print the page footer.
#
print <<"(END HTML FOOTER)";
<hr size=1 width=75%><p>
<center><font size=-1><a
href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.9
© 1995 - 2001 Matt Wright<br>
A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's
Script Archive, Inc.</a></font></center>
</body>
</html>
(END HTML FOOTER)
}
}
sub return_html {
# Local variables used in this subroutine initialized.
#
local($key,$sort_order,$sorted_field);
# If redirect option is used, print the redirectional location header.
#
if ($Config{'redirect'}) {
print ("Location: $Config{'redirect'}\n\n");
}
# Otherwise, begin printing the response page.
#
else {
# Print HTTP header and opening HTML tags.
#
print "Content-type: text/html\n\n";
print "<html>\n <head>\n";
# Print out title of page
#
if ($Config{'title'}) { print "
<title>$Config{'title'}</title>\n" }
else { print " <title>Thank
tle>\n" }
print " </head>\n <body";
# Get Body Tag Attributes
#
&body_attributes;
# Close Body Tag
#
print ">\n <center>\n";
# Print custom or generic title.
#
if ($Config{'title'}) { print " <h1>$Config{'title'}</h1>\n" }
else { print " <h1>Thank You For Filling Out This Form</h1>\n" }
print "</center>\n";
print "Below is what you submitted to $Config{'recipient'} on ";
print "$date<p><hr size=1 width=75\%><p>\n";
# Sort alphabetically if specified:
#
if ($Config{'sort'} eq 'alphabetic') {
foreach $field (sort keys %Form) {
# If the field has a value or the print blank fields option
#
# is turned on, print out the form field and value.
#
if ($Config{'print_blank_fields'} || $Form{$field}) {
print "<b>$field:</b> $Form{$field}<p>\n";
}
}
}
# If a sort order is specified, sort the form fields based on that.
#
elsif ($Config{'sort'} =~ /^order:.*,.*/) {
# Set the temporary $sort_order variable to the sorting order,
#
# remove extraneous line breaks and spaces, remove the order:
#
# directive and split the sort fields into an array.
#
$sort_order = $Config{'sort'};
$sort_order =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$sort_order =~ s/(\s+)?\n+(\s+)?//g;
$sort_order =~ s/order://;
@sorted_fields = split(/,/, $sort_order);
# For each sorted field, if it has a value or the print blank
#
# fields option is turned on print the form field and value.
#
foreach $sorted_field (@sorted_fields) {
if ($Config{'print_blank_fields'} || $Form{$sorted_field}) {
print "<b>$sorted_field:</b> $Form{$sorted_field}<p>\n";
}
}
}
# Otherwise, default to the order in which the fields were sent.
#
else {
# For each form field, if it has a value or the print blank
#
# fields option is turned on print the form field and value.
#
foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field}) {
print "<b>$field:</b> $Form{$field}<p>\n";
}
}
}
print "<p><hr size=1 width=75%><p>\n";
# Check for a Return Link and print one if found.
#
if ($Config{'return_link_url'} && $Config{'return_link_title'}) {
print "<ul>\n";
print "<li><a
href=\"$Config{'return_link_url'}\">$Config{'return_link_title'}</a>\n";
print "</ul>\n";
}
# Print the page footer.
#
print <<"(END HTML FOOTER)";
<hr size=1 width=75%><p>
<center><font size=-1><a
href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.9
© 1995 - 2001 Matt Wright<br>
A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's
Script Archive, Inc.</a></font></center>
</body>
</html>
(END HTML FOOTER)
}
}
sub send_mail {
# Localize variables used in this subroutine.
#
local($print_config,$key,$sort_order,$sorted_field,$env_report);
# Open The Mail Program
open(MAIL,"|$mailprog -t");
print MAIL "To: $Config{'recipient'}$Form{'E-mail'}\n";
print MAIL "From: $Config{'email'} ($Config{'realname'})\n";
if ($Config{'cc'} && check_email($Config{'cc'}))
{ print MAIL "Cc: $Config{'cc'}\n" };
# if ($Config{'cc_visitor'})
# {
# foreach $field (@Field_Order) {
# if ($field eq 'E_mail') {
# print MAIL "Cc: ($Form{$field}) ($Form{$field})\n"};
# }
# }
# Check for Message Subject
if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n" }
else { print MAIL "Subject: WWW Form
Submission\n\n" }
print MAIL "$date\n";
print MAIL "-" x 75 . "\n\n";
if (@Print_Config) {
foreach $print_config (@Print_Config) {
if ($Config{$print_config}) {
print MAIL "$print_config: $Config{$print_config}\n\n";
}
}
}
# Sort alphabetically if specified:
#
if ($Config{'sort'} eq 'alphabetic') {
foreach $field (sort keys %Form) {
# If the field has a value or the print blank fields option
#
# is turned on, print out the form field and value.
#
if ($Config{'print_blank_fields'} || $Form{$field} ||
$Form{$field} eq '0') {
print MAIL "$field: $Form{$field}\n\n";
}
}
}
# If a sort order is specified, sort the form fields based on that.
#
elsif ($Config{'sort'} =~ /^order:.*,.*/) {
# Remove extraneous line breaks and spaces, remove the order:
#
# directive and split the sort fields into an array.
#
$Config{'sort'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'sort'} =~ s/(\s+)?\n+(\s+)?//g;
$Config{'sort'} =~ s/order://;
@sorted_fields = split(/,/, $Config{'sort'});
# For each sorted field, if it has a value or the print blank
#
# fields option is turned on print the form field and value.
#
foreach $sorted_field (@sorted_fields) {
if ($Config{'print_blank_fields'} || $Form{$sorted_field} ||
$Form{$sorted_field} eq '0')
{
print MAIL "$sorted_field: $Form{$sorted_field}\n\n";
}
}
}
# Otherwise, default to the order in which the fields were sent.
#
else {
# For each form field, if it has a value or the print blank
#
# fields option is turned on print the form field and value.
#
foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field} ||
$Form{$field} eq '0')
{
if ($field ne 'commit') {
if ($field eq 'postcode1')
{
print MAIL "$field: $Form{$field}";
}
else {
if ($field eq 'postcode2') {
print MAIL " $Form{$field}\n\n";
}
else {
print MAIL "$field: $Form{$field}\n\n";
}
}
}
}
}
}
print MAIL "-" x 75 . "\n\n";
close (MAIL);
}
sub check_email {
# Initialize local email variable with input to subroutine.
#
$email = $_[0];
# If the e-mail address contains:
#
if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
# the e-mail address contains an invalid syntax. Or, if the
#
# syntax does not match the following regular expression pattern
#
# it fails basic syntax verification.
#
$email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z0-9]+)(\]?)$/) {
# Basic syntax requires: one or more characters before the @ sign,
#
# followed by an optional '[', then any number of letters, numbers,
#
# dashes or periods (valid domain/IP characters) ending in a period
#
# and then 2 or 3 letters (for domain suffixes) or 1 to 3 numbers
#
# (for IP addresses). An ending bracket is also allowed as it is
#
# valid syntax to have an email address like: user@[255.255.255.0]
#
# Return a false value, since the e-mail address did not pass valid
#
# syntax.
#
return 0;
}
else {
# Return a true value, e-mail verification passed.
#
return 1;
}
}
sub body_attributes {
# Check for Background Color
if ($Config{'bgcolor'}) { print " bgcolor=\"$Config{'bgcolor'}\"" }
# Check for Background Image
if ($Config{'background'}) { print "
background=\"$Config{'background'}\"" }
# Check for Link Color
if ($Config{'link_color'}) { print " link=\"$Config{'link_color'}\"" }
# Check for Visited Link Color
if ($Config{'vlink_color'}) { print "
vlink=\"$Config{'vlink_color'}\"" }
# Check for Active Link Color
if ($Config{'alink_color'}) { print "
alink=\"$Config{'alink_color'}\"" }
# Check for Body Text Color
if ($Config{'text_color'}) { print " text=\"$Config{'text_color'}\"" }
}
sub error {
# Localize variables and assign subroutine input.
#
local($error,@error_fields) = @_;
local($host,$missing_field,$missing_field_list);
if ($error eq 'bad_referer') {
if ($ENV{'HTTP_REFERER'} =~ m|^https?://([\w\.]+)|i) {
$host = $1;
print <<"(END ERROR HTML)";
Content-type: text/html
<html>
<head>
<title>Bad Referrer - Access Denied</title>
</head>
<body bgcolor=#FFFFFF text=#000000>
<center>
<table border=0 width=600 bgcolor=#9C9C9C>
<tr><th><font size=+2>Bad Referrer - Access Denied</font></th></tr>
</table>
<table border=0 width=600 bgcolor=#CFCFCF>
<tr><td>The form attempting to use
<a
href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a>
resides at <tt>$ENV{'HTTP_REFERER'}</tt>, which is not allowed to
access
this cgi script.<p>
If you are attempting to configure FormMail to run with this form, you
need
to add the following to \@referers, explained in detail in the README
file.<p>
Add <tt>'$host'</tt> to your <tt><b>\@referers</b></tt> array.<hr
size=1>
<center><font size=-1>
<a
href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.9
© 1995 - 2001 Matt Wright<br>
A Free Product of <a
href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a>
</font></center>
</td></tr>
</table>
</center>
</body>
</html>
(END ERROR HTML)
}
else {
print <<"(END ERROR HTML)";
Content-type: text/html
<html>
<head>
<title>FormMail v1.9</title>
</head>
<body bgcolor=#FFFFFF text=#000000>
<center>
<table border=0 width=600 bgcolor=#9C9C9C>
<tr><th><font size=+2>FormMail</font></th></tr>
</table>
<table border=0 width=600 bgcolor=#CFCFCF>
<tr><th><tt><font size=+1>Copyright 1995 - 2001 Matt Wright<br>
Version 1.9 - Released August 3, 2001<br>
A Free Product of <a
href="http://www.worldwidemart.com/scripts/">Matt's Script Archive,
Inc.</a></font></tt></th></tr>
</table>
</center>
</body>
</html>
(END ERROR HTML)
}
}
elsif ($error eq 'request_method') {
print <<"(END ERROR HTML)";
Content-type: text/html
<html>
<head>
<title>Error: Request Method</title>
</head>
<body bgcolor=#FFFFFF text=#000000>
<center>
<table border=0 width=600 bgcolor=#9C9C9C>
<tr><th><font size=+2>Error: Request Method</font></th></tr>
</table>
<table border=0 width=600 bgcolor=#CFCFCF>
<tr><td>The Request Method of the Form you submitted did not match
either <tt>GET</tt> or <tt>POST</tt>. Please check the form and make
sure the
<tt>method=</tt> statement is in upper case and matches <tt>GET</tt> or
<tt>POST</tt>.<p>
<center><font size=-1>
<a
href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.9
© 1995 - 2001 Matt Wright<br>
A Free Product of <a
href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a>
</font></center>
</td></tr>
</table>
</center>
</body>
</html>
(END ERROR HTML)
}
elsif ($error eq 'no_recipient') {
print <<"(END ERROR HTML)";
Content-type: text/html
<html>
<head>
<title>Error: Bad/No Recipient</title>
</head>
<body bgcolor=#FFFFFF text=#000000>
<center>
<table border=0 width=600 bgcolor=#9C9C9C>
<tr><th><font size=+2>Error: Bad/No Recipient</font></th></tr>
</table>
<table border=0 width=600 bgcolor=#CFCFCF>
<tr><td>There was no recipient or an invalid recipient specified in the
data sent to FormMail. Please
make sure you have filled in the <tt>recipient</tt> form field with an
e-mail
address that has been configured in <tt>\@recipients</tt>. More
information on filling in <tt>recipient</tt> form fields and variables can
be
found in the README file.<hr size=1>
<center><font size=-1>
<a
href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.9
© 1995 - 2001 Matt Wright<br>
A Free Product of <a
href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a>
</font></center>
</td></tr>
</table>
</center>
</body>
</html>
(END ERROR HTML)
}
elsif ($error eq 'missing_fields') {
if ($Config{'missing_fields_redirect'}) {
print "Location: $Config{'missing_fields_redirect'}\n\n";
}
else {
foreach $missing_field (@error_fields) {
$missing_field_list .= " <li>$missing_field\n";
}
print <<"(END ERROR HTML)";
Content-type: text/html
<html>
<head>
<title>Error: Blank Fields</title>
</head>
<center>
<table border=0 width=600 bgcolor=#9C9C9C>
<tr><th><font size=+2>Error: Blank Fields</font></th></tr>
</table>
<table border=0 width=600 bgcolor=#CFCFCF>
<tr><td>The following fields were left blank in your submission form:<p>
<ul>
$missing_field_list
</ul><br>
These fields must be filled in before you can successfully submit the
form.<p>
Please use your browser's back button to return to the form and try
again.<hr size=1>
<center><font size=-1>
<a
href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.9
© 1995 - 2001 Matt Wright<br>
A Free Product of <a
href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a>
</font></center>
</td></tr>
</table>
</center>
</body>
</html>
(END ERROR HTML)
}
}
exit;
}
------------------------------
Date: Mon, 14 Oct 2002 13:42:25 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Newbie: How can I download a file and after that redirect the page to a new html
Message-Id: <slrnaqliac.7rm.bernard.el-hagin@gdndev25.lido-tech>
In article <Mvzq9.1859403$oa7.64767797@Flipper>, Maurice Moolenaar wrote:
> Please help me, I going nuts.
>
> Eclosed you find the entire Perlscipt.
> It is a script that has become available throught my Hosting company.
Good grief, Charlie Brown, did you have to post so much crap to the
group? And Matt Wright's crap, no less!
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: 14 Oct 2002 07:10:56 -0700
From: rnoory@videotron.ca (R.Noory)
Subject: RE
Message-Id: <8fec9af1.0210140610.171ff136@posting.google.com>
Hello,
How with one rule can I transform my many words input to many words output ?
Input
buy
againbuy
overbuy
rebuy
output
bought
againbought
overbought
rebought
Thanks
------------------------------
Date: Mon, 14 Oct 2002 10:31:43 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: "R.Noory" <rnoory@videotron.ca>
Subject: Re: RE
Message-Id: <Pine.SGI.3.96.1021014103021.14742A-100000@vcmr-64.server.rpi.edu>
[posted & mailed]
On 14 Oct 2002, R.Noory wrote:
>How with one rule can I transform my many words input to many words output ?
>
>buy
>againbuy
>overbuy
>rebuy
>
>bought
>againbought
>overbought
>rebought
I'd say s/buy/bought/, but that's a very simplistic way of doing it, and
it might work when you don't expect it to. But if you have a known set of
input words, then I guess there's no problem.
--
Jeff "japhy" Pinyan RPI Acacia Brother #734 2002 Acacia Senior Dean
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Mon, 14 Oct 2002 16:35:08 +0200
From: Markus Niederlechner <mniederlechner@gmx.net>
Subject: Re: RE
Message-Id: <aoekms$fv6$04$1@news.t-online.com>
In article <8fec9af1.0210140610.171ff136@posting.google.com>, R.Noory wrote:
> How with one rule can I transform my many words input to many words output?
Use the map function to transform the elements in one array into a second array.
perldoc -f map
CODE:
#!/usr/bin/perl
use strict;
use warnings;
my @input = <DATA>;
my @output = map((s/buy$/bought/ and $_), @input);
# Note: @output only contains lines that have buy at the end. Other lines
# are ignored.
print @output;
__DATA__
buy
againbuy
overbuy
rebuy
OUTPUT:
bought
againbought
overbought
rebought
------------------------------
Date: Mon, 14 Oct 2002 14:49:41 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: RE
Message-Id: <3DAAD9D0.40108@dev.null>
Jeff 'japhy' Pinyan wrote:
> [posted & mailed]
>
> On 14 Oct 2002, R.Noory wrote:
>
>
>>How with one rule can I transform my many words input to many words output ?
>>
>>buy
>>againbuy
>>overbuy
>>rebuy
>>
>>bought
>>againbought
>>overbought
>>rebought
>>
>
> I'd say s/buy/bought/, but that's a very simplistic way of doing it, and
> it might work when you don't expect it to. But if you have a known set of
> input words, then I guess there's no problem.
>
>
Perhaps do s/buy$/bought/ to avoid stuff like "boughter" in your output.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 3966
***************************************