Vend allows customers to select items to buy from catalog pages. The program tracks which products they have selected and the quantity desired. From the ordering page they may complete the ordering process by entering their name and address, or return to browsing and select more items.
Vend 0.1 does not support secure transmission of credit card numbers. Vendors should contact customers separately for payment.
Vend keeps track of who is ordering what by including in the URL a session id: a random string which is different for each customer browsing the catalog.
So that the session id can be included in URL's within catalog pages, every page in the catalog is served up by Vend running as a cgi-bin program. Here is an example of such a URL:
http://xyzcorp.com/cgi-bin/vend/shirts?WehUkATn;;1An explanation of each part:
xyzcorp.com
cgi-bin
vend
shirts
WehUkATn;;1
svend
as a cgi-bin program.
svend
is a small C program which is setuid to the
account which owns the catalog files.
svend
executes the Vend Perl script
vend.pl
.
ftp://gray.maine.com/pub/awilcox/vend-0.1.tar.gz
ftp://ftp.biddeford.com/pub/awilcox/vend-0.1.tar.gz
IdentityCheck
directive:
IdentityCheck OnUnless changed by the
UserId
directive, the CERN
httpd
server will run programs as the user
"nobody
". To ensure that svend
is only run
as a cgi-bin program and not by other users on the system,
svend
will only run under this user account. If other
programs on the system use the nobody
account, you may
want to change the UserId
to an account which is only
used by httpd
.
UserId hguestYou will also need rules to map URLs to your public HTML files and your cgi-bin directory. These may be already set up in the
httpd
configuration file. Here is an example:
Exec /xyzcorp/cgi-bin/* /home/xyzcorp/cgi-bin/* Pass /xyzcorp/* /home/xyzcorp/WWW/*The first line specifies that a URL such as "
http://machine.com/xyzcorp/cgi-bin/svend
" will run the
program svend
located in the
/home/xyzcorp/cgi-bin
directory.
The second line specifies that files in the
/home/xyzcorp/WWW
directory can be retrieved with a URL
such as http://machine.com/xyzcorp/file
.
The mapping described by Exec
will always require two
parts in the URL: one to specify the cgi-bin directory and another to
specify the program to run. You can shorten the URL by specifying an
additional mapping such as:
Map /catalog/* /xyzcorp/cgi-bin/svend/*This will allow a URL such as "
http://machine.com/catalog/shirts
" to be used.
In the Vend configuration file, vend.conf
, set the
VendURL
directive to the URL which runs
svend
in the cgi-bin directory.
VendURL http://machine.com/catalog
You will want a public WWW directory for inline image graphic files.
You will need a cgi-bin directory in which to put the
svend
program.
gzip -d vend-0.1.tar.gz tar xfv vend-0.1.tarIf you have GNU tar, you can combine these steps:
tar xfvz vend-0.1.tar.gzThe
samples
directory contains a sample product file and
order report, and sample catalog pages. If you would like to use them
as a starting point for your own catalog, you can copy the sample
files into the Vend directory:
cd /usr/vend # wherever your vend directory is cp sample/pages/* pages cp sample/products/* products cp sample/report .Edit
vend.pl
and set VendRoot
to the
vend directory which you just unpacked.
testcgi
" and change the first line to refer
to your Perl version 5 (or higher) executable.
#!/usr/bin/perlCopy "
testcgi
" into your cgi-bin directory, and make it
executable.
cp testcgi /your/cgi-bin/directory chmod a+rx /your/cgi-bin/directory/testcgiTry running
testcgi
from your shell command line to make
sure that everything is working.
/your/cgi-bin/directory/testcgi
testcgi
should respond with the version of Perl that you
are running and your numeric user id.
Now try running testcgi
from your browser. Write down
the numeric user id which you get there, as you will need it later for
svend
.
svend
is a small C program which is setuid to the user
account which can access the catalog data files. The following defines at
the beginning of svend.c
should be set:
vend.pl
, typically in the
vend
directory.
svend.c
with your C compiler:
cc svend.c -o svendOn some systems you can make the executable smaller with the
strip
program. But don't worry about it if
strip
is not on your system.
strip svendIf you want Vend to run under a different user account than your own, make that user the owner of
svend
. (You probably need to
be root to do this). Do not make svend
owned by root,
because making svend
setuid root is an unnecessary
security risk.
chown vendacct svendMake
svend
setuid:
chmod u+s svendMove the
svend
executable to your cgi-bin directory:
mv svend /the/cgi-bin/directory
vend.pl
and specify the root directory which
contains the Vend distribution.
$Config::VendRoot = '/usr/vend';
products
" file is a simple Ascii comma-delimited
list of all the product codes, a short description, and the price.
Here is an example of a products file:
SH543,Men's fine cotton shirt,14.95 PA776,Elegant pants,29.00
The first page displayed in the catalog is
"catalog.html
". This page will contain links to other
catalog pages with the [page]
element. Individual
products can be ordered by the [order]
element, which
brings up the order page "order.html
". The order page
contains input boxes for the customer to type in their name and
address. Once the order has been sent the
"confirmation.html
" page is displayed.
You will normally not want to include regular hypertext links to pages outside of the catalog. Such links will not include the session id, which means that if the customer follows an external link back to the catalog the list of products ordered so far will have been lost.
Inline images, on the other hand, are served in the normal fashion.
You should include a regular <img src="URL">
element, where the URL refers to a graphic image.
The following elements can be used in catalog pages:
[page shirts]
will expand into
<a
href="http://xyzcorp.com/cgi-bin/vend/shirts?WehUkATn;;1>
.
The catalog page displayed will come from
"shirts.html
" in the pages directory.
</a>
. Used with the page
element, such as: [page shirts]Our shirt
collection[/page]
.
<a
href="http://xyzcorp.com/cgi-bin/vend/finish;WehUkATn;;1">
Finish Incomplete Order</a>
products
" file.
</a>
. Used with the order element, such
as: Buy a [order TK112]Toaster[/order] today.
[item-list]
element shows a
list of all the items ordered by the customer so far. It works by
repeating the source between [item-list]
and
[/item-list]
once for each item ordered. Between the
item-list markers the following elements will return information for
the current item:
order.html
, you will have a number of
input fields allowing customer to enter information such as their name
and address. You can add more fields simply by putting more input
elements on the order.html
page, and the information will
automatically be included in the order report. Input elements should
be written in this way:
<input type="text" name="town" value="[value town]" size=30>The
type
attribute should be set to "text"
,
which is the only input type supported by this version of Vend.
Choose a name for this input field such as "email" for an email
address. Set the name
attribute to the name you have
choosen.
The value
attribute specifies the default value
to give the field when the page is displayed. Because the customer
may enter information on the order page, return to browsing, and come
back to the order page, you want the default value to be what was
entered the first time. This is done with the [value]
element, which returns the last value of an input field. Thus,
value="[value name]"will evaluate to the name entered on the previous order screen, such as:
value="Jane Smith"which will be displayed by the browser.
The size
attributes specifies how many characters wide
the input field should be on the browser. You do not need to set this
to fit the lengthiest possible value since the browser will scroll the
field, but you should set it large enough to be comfortable for the
customer.
report
", defines the layout of
the order report which gets mailed on the completion of the order.
For example,
Order Date: $date Name: $name Email address: $email Shipping address: $addr Town, State, Zip: $town, $state $zip Country: $countryAny input field from the order page can be included using the dollar sign notation.
vend.pl
, is the
default location of all of the Vend files. Unless changed in
vend.pl
, the Vend configuration file will be
vend.conf
in the VendRoot directory.In the configuration file, these directives are required:
svend
as a cgi-bin
program.
VendURL http://machine.com/xyzcorp/cgi-bin/svend
MailOrderTo orders@xyzcorp.com
pages
subdirectory in the VendRoot
directory.
PageDir /data/catalog/pages
products
file. Defaults to the
products
subdirectory of the VendRoot
directory.
ProductDir /data/catalog/for-sale
report
.
OrderReport /data/order-form
DisplayErrors Yes
.pag
,
.dir
, or .gdbm
(depending on the DBM
implementation used) will be appended.
SessionDatabase session-data
svend
) can read and write files
created by Vend. WritePermission
and
ReadPermission
can be set to 'user
',
'group
', or 'world
'.
WritePermission group ReadPermission group
SessionExpire
specifies the minimum time to keep track of
session information. Defaults to one day.
SessionExpire 4 hours
SendMailProgram /bin/mailer
[shipping]
element in the order page. Defaults to 0.
Shipping 5.00
pages
directory. See the sample
subdirectory for examples.
failed.html
page is
displayed. (Sadly we don't know if the email was successfully
delivered).
.html
file in
the pages
directory. This can happen if the
customer saved a bookmark to a page that was later removed.
products
file.
-expire
option to vend.pl
to do this:
/usr/vend/vend.pl -expireYou could add a crontab entry such as the following:
# once a day at 6:10 am 10 6 * * * /usr/vend/vend.pl -expire