Brenno J.S.A.A.F. de Winter [EMAIL PROTECTED] writes:
Yes, it would be nice to have a cron-script that would update the
database every 40 minutes or so. But unfortunately that's not
available to everybody... (I don't have access to it at
gimpster.com)
For those cases you then can put it the load of the data in a
different routine and describe in you README how to call the
script.--
Well, I think it should work like this:
1) You call print-pretty (or some other function that produces some
output)
2) The function checks whether or not there's a decoded metar. If so,
it will use that, otherwise it calls decode_metar()
3) decode_metar gets its METAR from get_metar()
4) get_metar uses the current METAR, if any, or else it tries to get
one by calling get_metar_from_db().
5) get_metar_from_db() uses the database, or calls
get_metar_from_web() if the METAR wasn't in the database or if it
was too old.
The idea with this is, that you should only call one function
(print_pretty()) - the rest is handled by lower-level functions. PHP
Weather is my first shot at object-oriented programming, so it might
not be the best solution, but on the other hand, I think it works
quite well.
It's get_metar_from_web() that uses a lot of time to figure out,
whether or not the file is available. If anybody know how to quickly
check if a host is alive, then please tell me.
If you set 'always_use_db' to true, then get_metar_from_db() will use
the METAR is finds in the db, even if it's too old. If it can't find
the METAR, then it has to contact NOAA anyway.
make dep make install make modules make modules_install,
Was that line part of your signature? :-)
Brenno J.S.A.A.F. de Winter
De Winter Information Solutions.
--
Best regards,
Martin Geisler
Checkout http://www.gimpster.com for:
PHP Weather = Shows the current weather on your webpages.
PHP Shell = A telnet-connection (almost :-) in a PHP page.