Weather Display Conditions Messenger PHP Script by Mike Challis
More Info        - www.642weather.com/weather/scripts-wd-conditions-messenger.php
Download         - www.642weather.com/weather/scripts/wd-conditions-messenger.zip
Live Demo        - www.642weather.com/weather/wd-conditions-messenger.php
Free PHP Scripts - www.642weather.com/weather/scripts.php
Contact Mike     - www.642weather.com/weather/contact_us.php
Donate:          https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2319642  

Version: 2.02 - 16-Jun-2013 - release  see changelog.txt for changes

Support thread at weather-watch forum:
http://www.weather-watch.com/smf/index.php/topic,40862.0.html

You are free to use and modify the code

Partially based on a variation of the following scripts:
NOAA Top Weather Advisory Alerter PHP Script by Mike Challis
http://www.642weather.com/weather/scripts-noaa-top-weather-alerter.php
RSS Top Warning PHP Script by Ken True http://saratoga-weather.org/scripts.php
PHP NOAA Advisory Text by Tom Chaplin http://www.carterlake.org/weatherphp.php
Twitter Code by http://morethanseven.net/2007/01/20/posting-to-twitter-using-php/
Includes some of the features of the NWS Weather Forecast Messenger PHP Script by Mike Challis
www.642weather.com/weather/scripts-nws-forecast-messenger.php


This php code provided "as is", and Long Beach Weather (Michael Challis)
disclaims any and all warranties, whether express or implied, including
(without limitation) any implied warranties of merchantability or
fitness for a particular purpose.


################
# What does it do?
# ##############

Ever want to receive current weather conditions from your personal weather station by cell phone, blackberry, Twitter, or email? Now you can. 

This PHP script is used to check the Weather Display Conditions on a timed schedule,
then send a message.
Uses Weather Display Conditions data from your own personal weather station's testtags.php.
The message is short enough to send to cell phone, blackberry, Twitter, or email.
Supports sending messages by Email and Twitter, each method can be enabled or disabled.
Messages can be customized in the script settings.


################
# What do I need?
# ##############

PHP 5 with CURL support is required
.. Personal weather station with weather-display software uploading testtags.php to your web site
.. Web server hosting account with PHP support and ability to send emails from PHP
.. Ability to schedule a cron job or a scheduler program on your PC that can request a URL every 1 hour.
.. Your PHP server MUST allow PHP scripts permission to write files.
.. PHP safe_mode is recommended to be off

################
# How to use it:
# ##############

1) Set your settings in the "settings" of the wd-conditions-messenger.php PHP script.
Be sure to set your email address and the optional twitter user password.
Also set the settings for Email and Twitter to customize the messages, each method can be enabled or disabled.

2) Upload the wd-conditions-messenger.php PHP file to your web server.

3) Test from a URL, see if you can see the HTML output:
Example: http://www.yoursite.com/wd-conditions-messenger.php

4) It is recommended that you test an email/twitter to make sure the script is working.
   Enable the email or twitter setting. 
   Click the URL, example: http://www.yoursite.com/wd-conditions-messenger.php
   Check if you receive your message or not.

5) After testing if you receive your message or not, 
   you need to secure the script because you do not want people clicking the URL and flooding you with emails and twitters!
   There are 3 ways to secure it... make sure you do this step, don't just "set it and forget it":

   Method 1) (recommended) Use the setting $require_post to require post authentication to send messages.
             This method will allow the script to be clicked on, but it will only send the messages on your schedule.

   Method 2) Use the setting $flood_filter_enabled.
             This method will allow the script to be clicked on, but it will only send the messages on your schedule.

   Method 3) Move it to a private non-public web server folder, then the only way you can call it is from a cron job.
         

6) Schedule automatic timed message sending: 
There are a few ways to do this, I use method 1 but not every web host allows it.
Log into your web server control panel, find the "cron" settings.
Wiki page for cron: http://en.wikipedia.org/wiki/Cron
Schedule a server cron job to run this PHP file every 1 hour. The following methods correspond to the method you select in step 5 above.

Method 1: (recommended)
Example using cron and CURL with post authentication: (be sure to set 'your_username' and 'your_password' same as in PHP script settings)
00 * * * /usr/bin/curl -d 'username=your_username&password=your_password' http://www.642weather.com/weather/wd-conditions-messenger.php >/dev/null 2>&1 

Method 2:
Example using cron and CURL:
00 * * * /usr/bin/curl http://www.642weather.com/weather/wd-conditions-messenger.php >/dev/null 2>&1

Method 3:
Example using cron and PHP: (change '/path/to/' to your server path)
00 * * * php /path/to/wd-conditions-messenger.php 2>&1 > /dev/null

Method 4: 
Use Windows Task Scheduler and a Scheduled HTTP Request 
to the URL http://www.yourwebsite.com/wd-conditions-messenger.php every 1 hour.
Instructions here:
http://www.642weather.com/weather/wxblog/php-scripts/scheduled-http-request-windows-task-scheduler/


Note:
Some users have file permissions problems with the cache files:
Here are some tips:
(Do this only if you are having file permissions errors!)
Create the file in Notepad or similar text editor. The file can be empty. 
wd-conditions-messenger-flood.txt
Upload it to your server and CHMOD it to 666
You may continue to have problems if your server has "safe_mode on" or other restrictions on file create, file write functions.
In that case, please consult your web host tech support.


Twitter usage:
See readme.txt inside TweetWX folder


-----------------------------------------
Live Example
-----------------------------------------
You can see my script in use here: (it will not email you though, because it only emails me.)
http://www.642weather.com/weather/wd-conditions-messenger.php 


-----------------------------------------
Donate
-----------------------------------------
A paypal donate button is on my scripts page
www.642weather.com.com/weather/scripts.php
or use this direct link:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2319642


