BIS Postcard

Web postcard system. Try it out! or Download the source. Better docs with an index coming once the program is done.


DESCRIPTION

Send a picture postcard to your frends. Cards are stored in a flat file back end. Old cards are automatically expired. Soon to come, hopefully, is a commercial version with features like dbm back end and file uploading.

Others have installed this script on NT and used sendmail.exe in place of sendmail. More specific NT info will be added once I receive it. If you use this script on NT please drop me a line at postcard@bewley.net>.

If you use this script at all send me a note and I will add you to the list of sites below.


INSTALLATION INSTRUCTIONS.

1. This program requires you to have CGI.pm installed on your system. See: http://www-genome.wi.mit.edu/ftp/pub/software/WWW/#installation 2. Make sure the line at the top points to perl on your system. You might find out if you type "which perl" on the UNIX command line. 3. Edit the user configurable variables near the top of the script. 4. Ask your ISP where you can run CGI from. Sometimes you must call it through a wrapper and locate it in a cgi-bin directory. Sometimes it is sufficient to give it a name ending in .cgi. This is the case on bewley.net. Install as they direct. 5. Make sure the CGI has write permission to $DATA_FILE. If you use a wrapper it will. If not you may have to make the file and directory containing it to world writable. Ask your ISP for help. 6. Create your index page. Sample at: http://www.bewley.net/postcard/

Tips for index page

Sample index page
<html> <head><title>BIS Postcard Sample</title></head> <body> <form action=/cgi-bin/postcard.cgi method=POST> <input type=image name="r-baskt.jpg" src="/photos/thumbnails/r-baskt.jpg" width=75 height=75> <input type=image name="pickle.jpg" src="/photos/thumbnails/pickle.jpg" width=75 height=75> </form> <h2>Here to pickup a postcard?</h2> <form action="/cgi-bin/postcard.cgi" method=GET> Enter your code: <input type=text name=code> <input type=submit> </form> </body> </html>

Thumbnails
Your postcard implimentation will be most attractive if you create a thumbnail version of each image that you plan to use for your postcards. To create thumbnails on UNIX seek out ImageMagick on Windows find ThumbsPlus.

In the Sample index page above, notice that the src is pointed to a thumbnails directory while the name is simply the image name. The script will use the name attribute, ``r-baskt.jpg'', and the $IMG_URL variable to deduce the location of the full sized image for use on the actual postcard.

Note that the full sized image and the thumbnail image must have the same name! Therefore they must also be in seperate directories of course.

Card Racks
If you would like to split up your cards by category, for instance: flowers, cities, ocean, art... Simply make index pages just like the one above for each category. Then create an overview page that links to each card rack (index page). An example of this is visible at http://www.epicurus.com/postcards/

.


User Configurable Variables

You will need to configure the following variables for your site.

$BASE_REF
default 'http://www.bewley.net/postcard/'

Full URL to your postcard homepage

$CARD_LIFE
default 7

Number of days to keep a card in the database before removing it.

$DATA_FILE
default '/httpd/htdocs/bewley/postcard/postcard.dat'

Full path to postcard data file. The program will create this file. Keep in mind that the postcard program must have write permissions to the directory containing the file. Ideally, postcard.cgi will run with your userid, but it may not. Speak to your admin.

$IMG_URL
default '/photos/'

Full or relative URL location of images. Postcard will read the filename from the name of the <input type=image name=``foo.gif'' src=``/photos/foo.gif''> tag.

The reason for this is you may instead have a tag like so $IMG_URL directory. Make sense?

$MAIL_FROM
default 'postcard@bewley.net'

This is the return address users get their postcard notice from. You may or may not want it to be a valid address.

$POSTMASTER
This address receives any error messages, such as failed lockfile creation. This should be your email address.

$NT
Set this to '1' if you are on windows.

$MAIL_PROG
default '/usr/lib/sendmail -oi -t'

On UNIX, ask your admin or type ``which sendmail'' to find out if this is the correct path to sendmail. Sometimes it is /usr/sbin/sendmail.

Most likely this is correct if you are on a unix system, but On NT or Win95 you'll need to find something like sendmail.exe ftp://ftp.microsoft.com/developr/drg/unix-to-windows/ports/sendmail/ or blat.exe http://gepasi.dbs.aber.ac.uk/softw/Blat.html . I just found this page which might help you solve email troubles on NT as well http://www.geocities.com/SiliconValley/Park/8312/mail.htm

If on NT you may have to make a change ti sub notifyRcpt .

$SMTP
default 'localhost'

This is only necessary for Windows machines. UNIX sendmails are smart enough to figure this out on their own. If you don't know what to put here ask your internet provider.

$TEMP_DIR
default '/windows/temp'

This is only used by NT. We write the email temp file here.

$ENABLE_SNOOP
default ''

Set to a non zero value to enable admin to snoop on postcards.

$PASSWORD
default 'snoop'

Password to be used by the admin to snoop on postcards.

$PICKUP_URL
default 'http://bewley.net/postcard/postcard.cgi'

Location users come to for claiming a card. ``?code=____'' will be added automatically by notifyRcpt .

Hint: This also matches your action atribute of your index form and will probably have /cgi-bin/ in it.

Before this URL is given to the user the script will tag the pickup code to it. Example: http://www.bewley.net/psotcard/postcard.cgi will be shown to the user (in their notification mail) as http://www.bewley.net/postcard/postcard.cgi?code=8756611dale@bewley.net

$SUBJECT
default 'Bewley.net Postcard for you!'

The subject of email notifications sent to users by notifyRcpt .

$THUMB_DIR
default 'thumbs/'

Location of thumbnails relative to images. This is unused right now, but makeIndex will use it eventually.

.


Subroutines

solicitMsg
Print form for mailer to fill in. Later add template support so this form will be customized based on what postcard is being sent.

makeIndex
Not done yet, but this will create the html index like the one seen at http://www.bewley.net/postcard/

lockFile
Creates a lock file.

unlockFile
Removes lock file.

executeCards
Deletes expired cards from the data file.

badCode
This is called when user enters an invalid postcard pickup code.

displayCard
Expects a code, calles selectCard to pick out the card and parse out the fileds and then displays it for the recipient.

Given a second argument sub will not print the http header for the postcard. This is usefull when snooping with sub snoop .

Later, add template support.

validPassword
Used to enable snooping. Will return 1 if user entered password matches $PASSWORD and 0 otherwise.

selectCard
Given a possible pickup code, this sub will search the data file and return the card values to the calling sub, displayCard .

snoop
Lets the admin snoop on all the postcards found in the database. Currently shows all cards from newset to oldest. Will later allow browsing of cards. To enable snooping set $ENABLE_SNOOP to a non zero value. Default is disabled.

notifyRcpt
Sends an email to the postcard recipient informing them they have a card waiting for them at the $PICKUP_URL .

If $NT is non-zero email is first written to a temp file and then mailed using $MAIL_PROG .

makeCard
Adds new postcard to database.

.

Other Postcard Sites

Do you use postcard.cgi? Let me know.

Examples of sites using BIS Postcard.cgi

Below is a list of similar scripts.

Todo


Bewley Internet Solutions perl page - sales@bewley.net