North American Weather Network
September 07, 2010, 04:23:00 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to the NAWN forum, est. May 08
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Self Updating Maps: mesomap-update-utility.php - Release version  (Read 3934 times)
0 Members and 1 Guest are viewing this topic.
mchallis
Regional Admin
Full Member
*****
Offline Offline

Posts: 132



View Profile WWW
« on: May 19, 2008, 04:29:08 PM »

Version 1.04 05-19-2008  First Release: added user selectable log file feature
Version 1.05 05-20-2008  updated the "How to use it" section in this file and the readme. (no code changes)
Version 1.06 05-20-2008  added error trap for failed fsockopen when checking new file times.
Version 1.07 05-21-2008  fixed remote location of mesomap graphic for SWN members - K. True
Version 1.08 05-21-2008  added many error traps with descriptive errors for files not found, not readable, etc.
                         The program should exit on all the new error traps instead of trying to plow forward with warnings.
Version 1.09 05-21-2008  fixed the error check for HTTP/1.* 200 OK - K. True


The file is attached to this message below, be sure to check back here for future updates

################
# 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 in the script header,
the most important one is the first one, your network initials

2) Upload the 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)
# run five minutes after midnight, every day
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

« Last Edit: July 28, 2008, 05:06:47 PM by mchallis » Logged


Long Beach, WA Weather
mchallis
Regional Admin
Full Member
*****
Offline Offline

Posts: 132



View Profile WWW
« Reply #1 on: May 19, 2008, 09:07:29 PM »

Distribution methods:
mesomap-update-utility.php should be included in all the networks zips, a readme is built into the top of the mesomap-update-utility.php
mesomap-update-README.txt should also be included in the zip.

Each regional admin should announce about the new mesomap-update-utility.php in their regional forums map code categories and on their member email list. Point them to this thread in this forum for the support.

Each regional admin should periodically check this forum for release version updates, then include the updates in your zips.

I would like to only have to provide support in one place, so I will provide support here in this forum. Thanks for your understanding.

Note to network admins: (network members can ignore)

A copy of XXXX-mesomap.php must be named XXXX-mesomap.txt on the remote network (regional server)
or it will NEVER be downloaded. Severs do not allow .php files to be "downloaded".
Do not even name it XXXX-mesomap.php.txt because it will not work either.

ie: when I update NWWN-mesomap.php, I also save it as NWWN-mesomap.txt to northwesternweather.net/NWWN-mesomap.txt
« Last Edit: May 20, 2008, 01:05:43 PM by mchallis » Logged


Long Beach, WA Weather
mchallis
Regional Admin
Full Member
*****
Offline Offline

Posts: 132



View Profile WWW
« Reply #2 on: May 20, 2008, 12:28:54 PM »

Version 1.05 05-20-2008  updated the "How to use it" section in this file and the readme.

I modified the section where it explains how to schedule updates.
Using a program like System scheduler to ping the URL is probably the easiest for everyone.

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

There could be path issues if you use Method 3 (server cron job), Method 1 or Method 2 will work for sure.
« Last Edit: May 20, 2008, 12:31:12 PM by mchallis » Logged


Long Beach, WA Weather
mchallis
Regional Admin
Full Member
*****
Offline Offline

Posts: 132



View Profile WWW
« Reply #3 on: May 20, 2008, 02:18:57 PM »

Updated the version after Budgie reported an error:

Version 1.06 05-20-2008  added error trap for failed fsockopen when checking new file times.

In the rare cases where the fsockopen command fails, the script will now exit with an error instead of trying to continue with just warnings.
Some servers may have fsockopen command disabled in the server setup, or the connection could just fail from a temporary connection issue.
« Last Edit: May 20, 2008, 02:38:14 PM by mchallis » Logged


Long Beach, WA Weather
Tim Hanko
Regional Admin
Jr. Member
*****
Offline Offline

Posts: 51


View Profile WWW
« Reply #4 on: May 20, 2008, 08:33:22 PM »

Here comes me, bringing up the rear again...  Sad

Do users run this utility from their site? I would suppose but want to be sure.
Logged
mchallis
Regional Admin
Full Member
*****
Offline Offline

Posts: 132



View Profile WWW
« Reply #5 on: May 20, 2008, 08:35:11 PM »

Here comes me, bringing up the rear again...  Sad

Do users run this utility from their site? I would suppose but want to be sure.

Yes they do, it makes their site fetch it fresh from the regional site
Logged


Long Beach, WA Weather
SLOweather
Newbie
*
Offline Offline

Posts: 48


Notes from the outpost...


View Profile WWW
« Reply #6 on: May 20, 2008, 09:37:32 PM »


If everyone on a regional network that uses the new "self-updating" script were to send their update url to one person, that person could put them on a "secret" web page, and then just hit that page once after a map update. That would update everyone at once.
Logged

Tim Hanko
Regional Admin
Jr. Member
*****
Offline Offline

Posts: 51


View Profile WWW
« Reply #7 on: May 20, 2008, 09:38:14 PM »

Good idea, Chris.
Logged
Budgie
SCWN Admin
Regional Admin
Full Member
*****
Offline Offline

Posts: 182



View Profile WWW
« Reply #8 on: May 21, 2008, 07:20:30 AM »

I'm not going to do all the work for them!!  Cheesy
Logged

mchallis
Regional Admin
Full Member
*****
Offline Offline

Posts: 132



View Profile WWW
« Reply #9 on: May 21, 2008, 11:54:43 AM »


If everyone on a regional network that uses the new "self-updating" script were to send their update url to one person, that person could put them on a "secret" web page, and then just hit that page once after a map update. That would update everyone at once.


I could write a script for that, hee hee  Grin
Logged


Long Beach, WA Weather
mchallis
Regional Admin
Full Member
*****
Offline Offline

Posts: 132



View Profile WWW
« Reply #10 on: May 21, 2008, 02:23:49 PM »

New version with more robust error handling. All users should update.

Version 1.07 05-21-2008  fixed remote location of mesomap graphic for SWN members - K. True
Version 1.08 05-21-2008  added many error traps with descritive errors for files not found, not readable, etc.
                         The program should exit on all the new error traps instead of trying to plow forward with warnings.

Logged


Long Beach, WA Weather
mchallis
Regional Admin
Full Member
*****
Offline Offline

Posts: 132



View Profile WWW
« Reply #11 on: May 21, 2008, 04:40:17 PM »

Ken found a problem with a part of the code and fixed it.

Version 1.09 05-21-2008  fixed the error check for HTTP/1.* 200 OK - K. True

download from attachment in first message of this thread.
Logged


Long Beach, WA Weather
mchallis
Regional Admin
Full Member
*****
Offline Offline

Posts: 132



View Profile WWW
« Reply #12 on: June 04, 2008, 02:49:29 PM »

This must be working good, I have not had any reports of trouble.

Here is some more explanation of how it works in Ken's words:

The mesomap-update-utility.php relies on three files on the main (distribution) website for the network

[mainsiteURL]/[net]_meso.jpg
[mainsiteURL]/[net]-stations-cc.txt and
[mainsiteURL]/[net]-mesomap.txt  (which is a copy of the [net]-mesomap.php

The updater will do a HEAD request for each of the three files, and if the local copy is older, update:

[net]_meso.jpg -> [net]_meso.jpg
[net]-stations-cc.txt -> [net]-stations-cc.txt
[net]-mesomap.txt -> [net]-mesomap.php

It's expected that folks will customize their mesomap by making changes in the [net]-mesomap-config.txt file on their website instead of the [net]-mesomap.php.  That way, the [net]-mesomap.php can be replaced, and the local settings remain intact.


Logged


Long Beach, WA Weather
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!