PHP script by Mike Challis, www.carmosaic.com/weather mesomap-update-utility.php North American Weather Network mesomap, php, and image control file updater Note: distribution of this program is limited to members of the North American Weather Network (http://www.northamericanweather.net) and all it regional network's members. Distribution outside of the membership is prohibited. Copyright 2006-2008, Mike Challis and Ken True - Saratoga-weather.org ################ # Why use it: # ############## Most network members run a copy of the network map PHP script on their weather web site. It used to be that whenever a new member was added to the map at the parent network server, all the member sites had to download a zip file and manually replace the files or their map would not display the newest members. By using this utility, the map image, map control file, and map php script can self update from the parent network server. When using this utility, the network member sites only have to install the map files once. ################ # What does it do?: # ############## It updates the XXXX_meso.jpg, XXXX-stations-cc.txt, and the XXXX-mesomap.php It reads the *-mesomap-config.txt file on your web server and uses that info to check out the 'freshness' of the map graphic, control file and PHP code, then automatically updates if needed. Tip: This script can be manually run from the web browser or from a cron schedule. No parameters are required for the script. ################ # How to use it: # ############## 1) Set your settings in the "Settings" section below, the most important one is the first one, your network initials 2) Upload this file as mesomap-update-utility.php file in the same directory as your network mesomap files XXXX_meso.jpg, XXXX-stations-cc.txt, XXXX-mesomap.php and XXXX-mesomap-config.txt in this example XXXX is the prefix of the network files, ie: SWN, NWWN, NEWN, etc. mesomap-update-utility.php will pick up other needed settings from the XXXX-mesomap-config.txt 3) Test the script by visiting your site URL to the php file like this: http://www.yoursite.com/mesomap-update-utility.php Sample output when no updates were needed: ./NWWN_meso.jpg does not need to be updated ./NWWN-stations-cc.txt does not need to be updated ./NWWN-mesomap.php does not need to be updated nothing was updated done Sample output when all 3 updates were needed: downloading a newer ./NWWN_meso.jpg downloading a newer ./NWWN-stations-cc.txt downloading a newer ./NWWN-mesomap.php 3 files were updated done 4) Visit the mesomap-update-utility.php URL regularly to make sure your map stays up to date with new WX stations that are added. Once a day is probably enough. 5)OPTIONAL, Schedule automatic timed updates: There are many ways to do this, method 1 is probably easiest. Method 1: Use a program like System scheduler to ping the URL http://www.yourwebsite.com/mesomap-update-utility.php once a day, or whenever you want System scheduler: http://www.splinterware.com/products/wincron.htm Method 2: If you already have weather-display software click on Control Panel | FTP & Connections | HTTP Download tab Click on #1,#2 or #3 setup button | switch on the button for "downloads on | enter your mesomap-update-utility.php url in the box called "URL of file to be downloaded" | click "add to list" | check the tick that says "Tick if text file" | enter mesomap-update-utility.txt in the box that says "Local filename to be downloaded" | click "add to list" | click "download hourly" (or for once a day, click "clear all" then click the 00:00 in the right column so it then shows in the left column) | click "save now" | click OK Method 3: Schedule a server cron job to run this php file five minutes after midnight, every day. Example using crontab -e: (change /path/to/ to your server path) 5 0 * * * php /path/to/mesomap-update-utility.php 2>&1 > /dev/null If your site uses a control panel you may have a different method of setting up cron jobs. see also http://en.wikipedia.org/wiki/Cron NOTE!! if you get PHP warning errors during an update: warning: fopen(./XXXX_meso.jpg) "failed to open stream: Permission denied" try changing the folder permissions CHMOD to 755, or on some servers 777 NOTE, you may not find out there is a permissions problem until an update occurs. How to Change File Permissions (chmod) with FTP... http://www.stadtaus.com/en/tutorials/chmod-ftp-file-permissions.php Tip: If you change a setting you might not know if the setting works until new map files are available for update. Tip: changes are logged to a file if you set $use_log_file = true; (default) mesomap-update-log.txt Anytime after an update, view the log at http://www.yourwebsite.com/mesomap-update-log.txt If you find any bugs, or can think of other possible settings/features for future releases: Post in this forum: http://www.northamericanweather.net/forum/index.php?topic=29.0 Contact Mike - http://www.carmosaic.com/weather/contact_us.php