A Complete Guide to Web Design

(やまだぃちぅ) #1
Demystifying CGI 249

Forms

Demystifying CGI

Web Design in a Nutshell, eMatter Edition

that certain portions of this script have been omitted where indicated for
purposes of fitting it in this chapter).


The FormMail program only requires three variables to be changed (high-
lighted in bold type in this example):



  • the pathname of the Perl interpreter on your server (in the first line of
    script)

  • the pathname of your server’s sendmail program (after$mailprogin the
    sample below)

  • the list of domains on which you will allow forms to reside and use your
    FormMail script (following@referers in the sample below).


These variables are clearly explained in the ReadMe file and are presented
with labels in the beginning of the script for ease of customization. Further-
more, each section of the script is clearly labeled as to its function, if you are
interested.


#!/usr/bin/perl
########################################################################


FormMail Version 1.6


Copyright 1995-1997 Matt Wright [email protected]


Created 06/09/95 Last Modified 05/02/97


Matt's Script Archive, Inc.: http://www.worldwidemart.com/scripts/#


########################################################################


COPYRIGHT NOTICE


Copyright 1995-1997 Matthew M. Wright All Rights Reserved.


[full copyright notice omitted]


########################################################################


Define Variables


Detailed Information Found In README File.


$mailprog defines the location of your sendmail program on your unix


system.


$mailprog ='/usr/lib/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 = ('worldwidemart.com','206.31.72.203');


Done


########################################################################


[section omitted]


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;

Free download pdf