# DB Based Appalachian Trail Distance Calculator
# Version 2.3
# README File
# By Mike Calabrese
# http://www.mikecalabrese.com/index.shtml
# 2-3-2008

# This program is available for free on an AS-IS basis.  I am not
# responsible for consequential damages, loss of income or whatever
# else that may happen as a result  of the use of this program.

This program is designed to calculate the approxamate distance in miles
on the Appalachian Trail between two given points. It is based on the 
original Appalachian Trail Distance Calculator.  However, this version 
pulls it's data from a MySQL database as opposed to flat files.  Please 
note that you must have access to a database, preferably a MySQL data-
base, to properly run this application.  If you don't, then you need to 
obtain the original flat file based Appalachian Trail Distance Calculator, 
which is available at http://www.mikecalabrese.com.
The 4 files included are this README file, the Perl script dbatdist.pl,
the HTML page that points to this script called dbatdist.html and a  
data file called points that contain the various distances along the trail.

The way the script works is that the starting and ending point are passed
to the Perl script.  The appropriate distances for these points are then 
selected from the data base.  The starting point is then 
subtracted from the ending point and the absolute value of the difference
is then passed to the user. This script has been tested in Linux
environments successfully.

The following configuration changes need to be made in order to successfully 
run this program:

1) Place the HTML page dbatdist.html on your server where your other HTML 
documents reside.  Be sure to change the "FORM ACTION" line to point to 
the url location of dbatdist.pl.  (For example- 
<FORM ACTION="http://www.yourdomain.com/cgi-bin/dbatdist/dbatdist.pl"> )

2) Place the perl script dbatdist.pl in your cgi-bin directory within it's 
own directory called dbatdist.  Be sure to chmod dbatdist.pl 
to 755 and the dbatdist directory to 755.  On some servers 
you will have to chgrp these files to the proper ownership name for your site.
The following configuration changes need to be made to this file:
a) Make sure that your path to Perl is correct (typing "which perl" at the 
command line will answer that. Be sure that your Perl path is the first line
of the dbatdist.pl script.
b) Make sure that the $refurl variable is set to the exact url path to your 
dbatdist.html file.  The bad referer subroutine keeps others from copying your 
html form and pointing to your cgi.  Please note that on some servers you have 
to change the extension of the Perl script from .pl to .cgi.
c) Replace the word databasename with the name of the database 
that you intend to load the various points and distances into.
d) Replace the word "username" (keep the quotes here) with the 
user name that you use to access your database.
e) Replace the word "userpwd" (again keep the quotes here) with 
the password that you use to access your database.

3) Place the points.dat file within the atdist directory and chmod it to 
755.  On some sites, you will have to chgrp them to the proper group name.

4) In your MySQL database create a table called points.  Within that table 
create a column called location_point whose attributes are varchar and 
whose length is 50.  Then create a column called location_distance whose 
attributes are decimal, 6 digits total and 1 digit to the right of the 
decimal.  Any MySQL questions should be directed to either your database 
administrator, or refer to the book MySQL by Paul DuBois.  This is a 
fantastic reference for MySQL that I highly recommend.  Lastly, load the 
data from the points.dat file into this data base.  Since it is tab 
delimited, it should load with no problem using the load data local 
statement.

If the following instructions are followed, this application should work 
with no problems.  Please do not remove the code that references the
Appalachian Trail Conservancy on the html page as well as in the Perl script.
This is the permission clause to use the numbers that are computed for this
application.         

For 2008, the following changes were made to this app and should be
reflected in the file dbatdist.html if you are upgrading this app:

Added Wayah Shelter, NC- This is a new shelter.
Added Clingmans Dome, TN- I decided that since this is the highest point on
the AT, it should be listed here.
Modified Hurricane Shelter Side Trail, VA to Hurricane Shelter, VA- It looks
like they decided that this shelter was less than .1 mile from the AT.
Deleted Lost Pond Shelter, VT- Someone burned this one down again.  Camping
only available at this site.

Please note that the flat file based version of this app (called atdist.html
and atdist.pl) is no longer being updated.