# Weather Watcher
# Version 1.0
# README File
# By Mike Calabrese
# http://www.mikecalabrese.com
# 08/24/2004

# This program is available 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.
 
MySQL 3.23.36 or higher and PHP 4.0.6 are required to successfully run 
this app.  It can be modified to work with a Microsoft(R) SQL Server 
database.  This information is available on the php.net web site.

Weather Wather is an application designed to display various weather  
conditions to end users and administrators. It can be used by TV, radio 
stations and newspapers to display reports from Weather Watchers in the field 
showing local weather conditions.  The app consists of 4 major areas:

Weather Watcher Spreadsheet and Input Form-  This is the main componant of 
this application.  It displays an online spreadsheet showing local weather 
conditions as well as a user input form that Weather Watchers can use to 
submit their local weather conditions to the Weather Watcher spreadsheet.

Groundcover Spreadsheet- This is a secondary componant of the app showing 
how much snow or rain a given area has received over a predetermined period 
of time.

Archive Page-  This is a web page where data containing links to previous 
Weather Watcher spreadsheets or Ground Cover Spreadsheets.

Admin Tools- This is an administrative area where various maintenance 
procedures can be performed on the various spreadsheets,  databases and web 
pages. 

Basically, the way this application works is that data is inserted, altered 
or deleted from one of 3 databases called weatherwatcher, ground_cover or 
weatherwatcher_archive.  The following paragraphs will explain how to 
configure the app.

First, we will set up the databases.  I'm not going to dwell alot on the 
databases themselves.  2 very good books in this area are:  MySQL by Paul 
DuBois and PHP and MySQL Web Development by Luke Welling and Laura Thomson. 
That said, create the following databases with the following attributes:

1) weatherwatcher

+---------------------+--------------+------+-----+------------+-------+
| Field               | Type         | Null | Key | Default    | Extra |
+---------------------+--------------+------+-----+------------+-------+
| process_id          | int(11)      |      |     | 0          |       |
| date                | date         |      |     | 0000-00-00 |       |
| city                | varchar(50)  |      |     |            |       |
| state               | char(2)      | YES  |     | NULL       |       |
| temperature         | mediumint(9) | YES  |     | NULL       |       |
| inches              | decimal(5,2) | YES  |     | NULL       |       |
| primary_condition   | varchar(30)  | YES  |     | NULL       |       |
| secondary_condition | varchar(30)  | YES  |     | NULL       |       |
| observation_time    | time         | YES  |     | NULL       |       |
| spotter             | varchar(10)  | YES  |     | NULL       |       |
| name                | varchar(50)  | YES  |     | NULL       |       |
+---------------------+--------------+------+-----+------------+-------+

2) ground_cover

+------------+--------------+------+-----+------------+-------+
| Field      | Type         | Null | Key | Default    | Extra |
+------------+--------------+------+-----+------------+-------+
| process_id | int(11)      |      | PRI | 0          |       |
| date       | date         |      |     | 0000-00-00 |       |
| city       | varchar(50)  |      |     |            |       |
| state      | char(2)      |      |     |            |       |
| current    | decimal(5,2) | YES  |     | NULL       |       |
| cumulative | decimal(5,2) | YES  |     | NULL       |       |
| comment    | varchar(50)  | YES  |     | NULL       |       |
+------------+--------------+------+-----+------------+-------+

3) weatherwatcher_archive

+-------------+--------------+------+-----+------------+-------+
| Field       | Type         | Null | Key | Default    | Extra |
+-------------+--------------+------+-----+------------+-------+
| process_id  | int(11)      |      |     | 0          |       |
| date        | date         |      |     | 0000-00-00 |       |
| url         | varchar(255) |      |     |            |       |
| description | varchar(255) |      |     |            |       |
+-------------+--------------+------+-----+------------+-------+

Next, we will go through each of the files and explain their function:

If you received this app via CD, the directory structure should be as follows:

weatherwatcher/
README
admin/
  add_groundcover1.php
  add_groundcover2.php
  add_special_txt1.php
  add_special_txt2.php
  archive_groundcover1.php
  archive_groundcover2.php
  archive_groundcover3.php
  delete_archive1.php
  delete_archive2.php
  delete_archive3.php
  delete_groundcover1.php
  delete_groundcover2.php
  delete_groundcover3.php
  delete_wx_db1.php
  delete_wx_db2.php
  delete_wx_db3.php
  edit_archive1.php
  edit_archive2.php
  edit_archive3.php
  edit_groundcover1.php
  edit_groundcover2.php
  edit_groundcover3.php
  edit_wx_db1.php
  edit_wx_db2.php
  edit_wx_db3.php
  link_webpage1.php
  link_webpage2.php
  login.php
  login_ok.php
  main.php
  make_webpage1.php
  rarrowd.jpg
  rarrowu.jpg
  view_days1.php
  view_days2.php
archive/   
  main.php
  rarrowd.jpg
  rarrowu.jpg
config_file.php
groundcover.php
groundcover_special.txt
index.php
rarrowd.jpg
rarrowu.jpg
user_submit1.php
user_submit2.php
weatherwatcher.php
weatherwatcher_special.txt

Simply install the files on your server so that they look like the above 
structure.  Windows servers use a backslash instead of a forward slash.
As far as permissions go, all files and directories should be chmodded to 
755.  If you have problems with the database logins or the special.txt files, 
chmod the weatherwatcher and archive directories to 777.

The file config_file.php is where you configure the various variables that 
are used through out this app. The important ones are the login, password and 
name of your database as well as the login and password for the admin areas. 
It is critical that these are set up properly or the app won't work.  Please 
refer to the comments within this file for further information. 

What follows is a brief explanation of each file: 


Within the admin directory-

add_groundcover1.php- This form is for the initial creation of a groundcover 
entry.

add_groundcover2.php- This form receives the information from the initial 
form and inserts that information into the ground_cover database.

add_special_txt1.php- This form allows one to add a 60 charactor comment 
that is appended to the header of either the Weather Watcher or Ground Cover 
spreadsheets.

add_special_txt2.php- This form receives the data from add_apecial_txt1.php 
and writes it to the proper files.

archive_groundcover1.php- This form allows one to archive the current 
Ground Cover Spreadsheet.

archive_groundcover2.php- This form receives the data from 
archive_groundcover1.php, writes it to a file, creates a name for that file 
and allows one the opportunity to append special header text or comments to 
the header of that file.

archive_groundcover3.php- This form creates a link from the Archive Page to 
the Groundcover Archive that was just created.
 
delete_archive1.php- This form brings up a list of Archive Links and asks 
which one that you want to delete.

delete_archive2.php- This form brings up the record that you selected and 
verifies that this is the link that you want to delete.

delete_archive3.php- This form deletes the link from the database, which, 
in turn, deletes it from the Archive Page.

delete_groundcover1.php- This form allows you to delete an entry on the 
Ground Cover spreadsheet.

delete_groundcover2.php- This form brings up the record that you selected and
verifies that this is the entry that you want to delete.

delete_groundcover3.php- This form deletes the record from the database, which,
in turn, deletes it from the Ground Cover Spreadsheet.

delete_wx_db1.php- This form brings up a list of entries in the Weather 
Watcher database and asks which one that you want to delete.

delete_wx_db2.php- This form brings up the record that you selected and
verifies that this is the entry that you want to delete.
 
delete_wx_db3.php-  This form deletes the record from the database, which,
in turn, deletes it from the Weather Watcher Spreadsheet.

edit_archive1.php- This form brings up a list of links on the Archive Page 
and asks you which description that you would like to modify.

edit_archive2.php- This form has an input field that allows one to change the 
description for a given link on the Archive Page. 

edit_archive3.php- This form does the actual updating of the description link 
on the Archive Page.

edit_groundcover1.php- This form allows you to choose a location to add  
ground cover for the current Ground Cover spreadsheet.

edit_groundcover2.php- This is the form where you enter the amount for a 
given location to add to the Ground Cover spreadsheet. 

edit_groundcover3.php- This form does the math and updates the current 
Ground Cover spreadsheet with the information that you supplied.

edit_wx_db1.php- This form allows you to pick an entry in the weatherwatcher 
database to edit.

edit_wx_db2.php- This form allows you to edit the record that you picked in 
edit_wx_db1.php .

edit_wx_db3.php- This form does the actual editing of the record that you 
edited in edit_wx_db2.php . 

link_webpage1.php- This form allows you to link the Weather Watcher 
spreadsheet archive that you created in make_webpage1.php from the Archive 
Page

link_webpage2.php- This form inserts the Ground Cover spreadsheet information 
for the date range Weather Watcher spreadsheet you created back in 
make_webpage1.php to the weatherwatcher_archive database, which, in turn,  
makes it show up on the Archive Page.

login.php- The initial screen one gets when entering the admin area.

login_ok.php- This screen verifies the login info and redirects the user to 
the main admin screen.

main.php- This is the page where the various tools for this app are located.

make_webpage1.php- This form creates a file for a Weather Watch speadsheet 
created for a specific date range.

rarrowd.jpg and rarrowu.jpg- These are the red arrow pieces of art that are
used on the Weather Watcher and Ground Cover spreadsheets.



Within the archive directory-

main.php- This file is where the archive Ground Cover and Weather Watcher 
spreadsheets are linked from. The files that write these are 
archive_groundcover3.php and link_webpage2.php.

Also, the actual archive pages themselves are stored in this directory.  They 
are created by archive_groundcover3.php and link_webpage2.php.  The file names 
have a "g" at the beginning of them for Ground Cover spreadsheets and a "w" 
at the beginning of them for Weather Watcher spreadsheets.  The numbers 
following those names are the year, month, day, hour and second that they were 
created.  The chance of a duplicate file, though possible, is highly 
unlikely.



groundcover.php- This file shows accumulated ground cover for various cities. 
It also allows different views of the data according to which of the red 
arrows are clicked.

groundcover_special.txt-  This file is written to by the file
add_special_text2.php .  It is text that is placed to the right of the header
of the Ground Cover Spreadsheet.

index.php- This is basically a launch pad for the app.  One could easilly 
eliminate this page and integrate the app into an existing web site.
 
rarrowd.jpg and rarrowu.jpg- These are the red arrow pieces of art that are 
used on the Weather Watcher and Ground Cover spreadsheets.

user_submit1.php- This is the file that Weather Watchers use to submit their 
current weather conditions.  As long as you maintain the default directory 
structure, no further configuration is required for this file. If you do 
decide to add additional list box items such as additional temperature 
ranges or weather conditions, you must add corresponding logic to the 
file edit_wx_db2.php to support these additional entries.

user_submit2.php- This file receives the post from user_submit1.php, inserts 
the information just posted into the database, then presents a success screen 
as well as a button that links to the Weather Watcher spreadsheet. 

weatherwatcher.php- This is the 'meat' of the app, the from that everything 
else revolves around.  It gives retrieves the Weather Watcher data from the 
database. It also allows different views of the data according to which of 
the red arrows are clicked. 

weatherwatcher_special.txt- This file is written to by the file 
add_special_text2.php  .  It is text that is placed to the right of the header 
of the Weather Watcher Spreadsheet.

If config_file.php has been properly set up, the app should work with no 
problems.  If you have questions or problems, please contact me at:

http://www.mikecalabrese.com/users/mikec/feedback/feedback.html