Thanks to the inspiration of Tom at CarterLake.org and Larry at Anole Computing, I’ve decided to stray (once again) into PHP programming.
This time, it’s a PHP script that will read the United States Geological Survey (USGS) recent earthquakes sites and format selected (by magnitude and distance from your station) results to include in your website.
I know, it’s a California thing probably… we have a lot of small quakes (and a few big ones), so I was thinking that other folks “on shaky ground” might like to have this data too.
There are three versions of the script available:
A California/Nevada version (magnitude 1.0+ in CA/NV)
A USA (lower-48 states, Alaska, Hawaii, Puerto Rico and parts of lower Canada and upper Mexico) (magnitude 1.0+ USA)
A World script (magnitude 4.0+ non-USA, and 2.5+ USA earthquakes)
Documentation on how to customize the script is in comments contained in the source. You have to change $myLat and $myLong to your station’s decimal latitude and longitude.
For the USA and WORLD scripts, you also have to set the $ourTZ to the timezone for your local area (it’s used to convert from UTC to local time for the displays). A timezone table is available at http://saratoga-weather.org/timezone.txt , and should work for your PHP webserver hosting your website.
The output of the scripts is XHTML 1.0-Strict compliant.
If you’re interested, please visit the scripts page at http://saratoga-weather.org/scripts.php for additional documentation, demos and to download the script(s) – they’re all free of charge. 8)
Let me know if you find them useful, or if you’d like fixes/improvements… your comments are welcome!
Good stuff, Ken. What’s the target version of PHP? My ISP is running an older version on the server I’m hosted on, and some of the scripts I’ve tried won’t run properly.
My ISP (1and1) is running PHP Version 4.4.2. I also tried them on a different provider running PHP 4.4.1 and all three ran without modifications or error messages.
Can you let me know what version you’re running and where (script name, line number) the script barfs? I might be able to retrofit it to an earlier version of PHP.
This wasn’t a “how do I fix this” question - it was a “should I bother to try” question. I haven’t had time to tweak and incorporate this script on my website yet. I will, but if a version higher than 4.1.2 is needed, I would wait until I get moved to a different server (in the works but not done). The one I had problems with was anole’s weathersticker - needs version 4.3 with GD support.
Sorry Bill, I misunderstood your question. I guess all I know about PHP versions for the script is that it runs on PHP 4.4.1 and up. I’d still be interested in knowing where in the code PHP 4.1.2 is having a problem.
If anyone else has problems with earlier versions of PHP, I’d like to hear about the issues.
I have anole’s excellent weather sticker script running, and it’s well worth the effort.
been working well, that NZ one, but earthquakes gone quite here at the moment…
there is a guy here who thinks the MOON causes more earthquakes (perigee/apogee and planetary aligments)
what you do you think ken?
Since NZ is on an active part of the “Ring of Fire”, I’m sure you’ll have earthquake data to view in the future
I agree with the USGS assessment (from their FAQ) on moon/planet influence:
Question: Can the position of the moon or the planets affect seismicity?
Answer:
The moon, sun, and other planets have an influence on the earth in the form of perturbations to the gravitational field. The relative amount of influence is proportional to the objects mass, and inversely proportional to the square of its distance from the earth. No significant correlations have been identified between the rate of earthquake occurrence and the semi-diurnal tides when using large earthquake catalogs. There have, however, been some small but significant correlations reported between the semi-diurnal tides and the rate of occurrence of aftershocks in some volcanic regions, such as Mammoth Lakes. (UC Berkeley)
Then details on relative gravitational effects from UC Berkeley:
The relative influences of object in the solar system, in order of magnitude. are:
Object Mass Distance Relative Influence
(Earth=1) (Million km) (Moon=1)
Moon 0.01228 0.38 1.00
Sun 329390 149 0.45
Venus 0.8073 41 0.000052
Jupiter 314.5 629 0.0000056
Mars 0.1065 79 0.00000096
Mercury 0.0549 91 0.00000033
Saturn 94.07 1277 0.00000020
Uranus 14.40 2720 0.000000004
The combined influence of the rest of the objects in the solar system is less than 10 billionths of the influence if the moon. The combined influence of all objects in the solar system, other than the moon and the sun, is at most 0.000059 or only 1/24500 the combined influence of the moon and the sun. Thus even when all the planets are lined up, their combined influence is relatively small.
This is a small bump to this thread to announce a minor rev to the quake-WORLD-test.php script to fix a missing “Near By” display. Thanks to pinto for alerting me to the problem. A one character change to one of the regexes was the solution – spotting it was a two-hour effort #-o :oops:
My thanks to Peter of http://www.leesburgweather.info/ for spotting a problem with the display of the Updated time in the headings of the quake-USA-test.php script (and it was also a problem in the quake-WORLD-test.php script).
The line in error was:
$updated = "Update time = " . date($timeFormat,$UTCdate+$timediff);
which should read
$updated = "Update time = " . date($timeFormat,$UTCdate);
A small HTML change in the USGS website caused one of the regexes to not split off the location correctly in the quake-USA-test.php script. The quake-WORLD-test.php script was not effected, so no update is necessary.
New copies of the quake-USA-test.php script (Version 1.03) are available at
You’re very welcome! Love your three pages and the included USGS maps. Makes it very easy to see ‘"what’s shakin’" around the world. Great presentation!!
The quake-USA-test.php script has a one-line change to fix the date problem (the USGS site changed a bit leading to a change in a regex for the script).
A small bump on this thread.
The USGS recently changed the World Earthquake list on it’s website, so there’s a new quake-WORLD-test.php script (V1.04) that allows the script to work with the new USGS layout.
Thanks for the use of the scripts. I will have to check it out later this weekend and perhaps add another page to my site containing the earthquake data. they not a big deal , here in the northeast, as we have not had many earthqaukes here in my life time, but it would only take one big one to reak havoc.
hi Ken
Other one nice script…
i have a problem with my time…
i did try…Europe/Athens, Greece, GR and i did use all places you have in testloc…
every time i got
my time is +2 and summer time is +3
my settings: Time format HH:mm:ss, time Zone GTM+02:00 and Automatically adjust clock for daylight saving changes
what is wrong?
thanks
Hi Panos,
Sorry I’d missed this message earlier (thanks for the ‘ping’ via PM).
It is very strange, as
$ourTZ = "Europe/Athens";
should set the time zone correctly for PHP on your webserver (according to the PHP manual).
Your Server: Microsoft-IIS/5.1 has it’s clock set just a bit slow (about 14 minutes behind GMT) (based on the response header Date: from your website and local GMT).
I’d suggest your contact your webhoster and ask them about it. It appears your default local time on the server is set to CEST not EEST as it’s only 1 hour forward of GMT.