back to
software
index
BUYCD   
   web- and mail-based CD seller   

Want to share (sell) music or whatever other data via Compact Disc?
Download BUYCD, make some adjustments and put it on your website!


BUYCD is open-source freeware, initially developed for the Schreck Ensemble in the Netherlands, to distribute some of her music around the world.

Briefly, it works as follows: visitors of the website may choose to buy individual CD-tracks and/or complete CD's. After the customer has filled in her name, address, etc. and agrees with the costs and way of payment, the server will send an order-e-mail to the CD-distributer.
If the customer supplied her e-mail address, the server will also send a conformation/ reminder-e-mail to the customer (mentioning all relevant info). Besides that, the CGI logs all orders to a plain-textfile on the server, so there's no problem when the CD-distributer looses all his mail.

This web- and mail-tool is written in C and meant to run as a CGI under UNIX. The Schreck Ensemble developed and debugged it on Silicon Graphics computers (Indy) under IRIX 6.2, running with Apache- and NCSA- webservers. It won't be much trouble porting it to LINUX or any other platform.

This CGI, does NOT make use of annoying cookies!
And it even works properly when JavaScript is switched off in the client's browser!
Furthermore, no frames and no Java!
Click to download BUYCD BUYCD0.16dist.tar.gz 216 kB gzipped tar-file containing all source-files plus some example-files.

Installation and configutarion guidelines:
            BUYCD 0.16 open source distribution
            by Pieter Suurmond, july 14, 2000.

Unpack the downloaded file by typing 
"gunzip BUYCD0.16dist.tar.gz", and then "tar xf BUYCD0.16dist.tar".
After unpacking the download, one should have te following files in the 
directory which I will call source-dir:
                            
    BUYCD.cgi.h             Configure here your defines and constants.
    BUYCD.err.c             What to show when something goes wrong.
    BUYCD.formOrder.c       Generates the first html-form.
    BUYCD.formConfirm.c     Generates the second html-page.
    BUYCD.formThanks.c      Generates the final html-page.
    BUYCD.getTV.c           Parsing of incoming CGI data.
    BUYCD.mail.c            To mail customer and shop-owner.
    BUYCD.orderID.c         To generate "unique" order-ID's.
    BUYCD.theList.c         To parse datafile containing items for sale.
    BUYCD.tools.c           Some handy routines.
    nph-BUYCD.cgi.c         The main() for the CGI executable.

    README                  Plain ASCII-manual.
    cgi-bin                 Dir containing files to place next to your CGI.
    htdocs                  Dir containing some .html and .gif files.

Before compiling the source files, one should first configure BUYCD by 
editing the header-file "BUYCD.cgi.h". All important names, URL's, e-mail 
addresses, etc. are mentioned there.

For this very small CGI, I did not provide any makefiles. You will have to 
complile and install manually, under UNIX of course:

    1: Go to the source directory by typing "cd source-dir" and stay there.
    2: Compile by typing "make nph-BUYCD.cgi".
    3: If there were no errors, continue by typing "strip nph-BUYCD.cgi".
    4: Now create an executable-directory (let's call it exec-dir),
       for example in YOUR own cgi-bin. Then move the stripped executable
       there by typing for example "mv nph-BUYCD.cgi exec-dir".
    5: Then also copy (or move) the files which I provided in my cgi-bin 
       to your executable-directory (type "cp cgi-bin/*.* exec-dir").
    6: Make sure the executable and the accompanying plain-text-files 
       have the correct access-privileges. Apart from the executable, there 
       are 3 plain ASCII files, their actual filenames are defined in the 
       headerfile "BUYCD.cgi.h":
       char *gItemFileName  = "forSale";  MUST be readable by the CGI.
       char *gOrderFileName = "myAkku";   BOTH readable and writable by CGI.
       char *gCountFileName = "kountID";  BOTH readable and writable by CGI.
       Also make sure your exec-dir is not open to any "hackers"
       (use the chmod and chown commands to protect yourself)!
       You are also strongly advised to choose filenames that differ from 
       the the ones I just mentioned above!
    7: Finally create a static-html-directory (html-dir) for BUYCD and copy
       the files in "htdocs" to there. The web-adres of this directory is  
       mentioned in "BUYCD.cgi.h"!!! But you probably want to edit the 
       .html-files (as well as "forSale") first.
       (to copy, you may type "cp htdocs/* html-dir".)
       In this directory, one could also place some .mp3, .aif, .mov, or 
       .whatever files to provide some samples for the customer.

    Viewing "myAkku" from a web-browser:
    When nothing is filled in on the first form, except the magic e-mail-
    address (see global variable "gMagicMailAddress" in file "BUYCD.cgi.h"), 
    all accumulated CD-orders so far will be shown.

If you really want to change these sources, be carefull: the costs-formula 
is applied at both client- and server-side, and both versions must give the 
same result! In this distribution-version it is:

    * + Dfl 15.00 starting costs.
    * For single tracks only:
      + Dfl  1.00 per individual track (i.e. piece, composition) selected.
      And for complete instant-CD's only:
      + Individual extra (or less) charge for this individual CD 
        (defined in "forSale", in last field of line).
    * + Dfl 13.00 per CD.
    * For delivering outside the Netherlands only:
      + Dfl  1.00 extra posting-charge per CD.
      For international money transactions only:
      + Dfl  5.00 for international bank bookings.
      + Dfl 20.00 for international cheques.
      + No extra charge for cash. (supply some disclaimer regarding 
        the risk of sending cash-money by regular mail).

The CGI will warn (in red) when the JavaScript-calculation disagrees with 
the C-calculation.

Well, hope you will be able to re-use this (somewhat spaghetti-like) code. 
Unfortunately I will NOT be able to answer e-mails regarding this stuff, 
BUG-REPORTS however, and usefull improvements of the C-code, are of course 
very welcome, please e-mail those to pieter@kmt.hku.nl and I might put them 
on my website. Please do not e-mail me just to tell me this is NO good 
educational example-code or that these C-sources are a mess,... for, 
I am aware of that!

If you want to try the (less messy) outside of this CGI install your own copy
or take a look at http://knorretje.hku.nl/~schreck/cgi-bin/nph-BUYCD.cgi 
and buy some nice CD's from my friends!
    

Pieter Suurmond, summer 2000