WXforum.net

Web Weather => Weather Website PHP/AJAX scripting => Topic started by: jmcmurry on February 18, 2008, 05:50:53 PM

Title: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 18, 2008, 05:50:53 PM
I have created a PHP script that displays a station's Wunderground historical data in a fashion similar to how they do.  It reads and displays the CSV data that is available and also shows the charts that have been mentioned in other threads.  You can view demos, see a couple sites utilizing it, and download WU-History.zip by visiting http://jcweather.us/scripts.php .

Please let me know if you have any trouble or see need for improvement.  Also please let me know if you decide to utilize the script so I can place a link on the scripts page.

As mentioned on that page, many thanks to Tom Chaplin, Ken True and Kevin Reed for the code that they've made available over the years.  Also thanks to Henrik (JWWD) for his ideas and thorough testing.
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: BfdWx on February 18, 2008, 07:43:40 PM
Jim has put an incredible amount of work on this script and it is an excellent historical reference for your site. Nice work Jim and thanks for sharing! =D>

I have the script running here...http://www.branfordfire.com/weather/wu.php if you would like to see another example.

Regards,

Jack
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: dnicho77 on February 18, 2008, 09:13:27 PM
 :grin: Excellent work! I have it running here http://www.southsoundweather.com/WUHistory.php (http://www.southsoundweather.com/WUHistory.php)

Working on the spacing to match my website templates

Thanks
Dale
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: weatherforyou on February 19, 2008, 12:47:32 AM
Very good job.  weatherforyou.com/HAMweather also has archived historical data going back to around 2002.  I contracted with someone to write an interface for it, which will be available in about a month.  But we'd very much appreciate any volunteer help such as this and would gladly acknowledge it since we don't exactly have the resources of WU.  :)
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: anchorageweather on February 19, 2008, 02:23:15 AM
Wow, thats GREAT!!!  Looks like I've got something to do this weekend!
Title: A minor Change
Post by: jmcmurry on February 19, 2008, 07:28:02 AM
There is a bad link to Wunderground that slipped by me ... test, test, and you still miss something.  If you'll search for

Code: [Select]
<td><?php echo $Lthanks ' '?><a href="/about/background.asp"> Weather Underground</a></td>
and replace it with

Code: [Select]
<td><?php echo $Lthanks ' '?><a href="http://www.wunderground.com"> Weather Underground</a></td>
that will fix it up.  Thanks to Jozef (Pinto) for finding this and letting me know.  The download .zip file has been updated.

- Jim
Title: A New Feature
Post by: jmcmurry on February 19, 2008, 02:45:19 PM
Henrik (jwwd) asked if it would be possible to select other stations that may be of interest.  I've added that capability as an option and it's kind of growing on me.  The .zip has been updated.  To see it in action view the demos at

http://jcweather.us/scripts.php?mitem=130

It's really nice to see that so many folks are finding this useful ... much more satisfying that just seeing it on my site.

Thanks!  - Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: up10ad N9RJH on February 19, 2008, 09:33:33 PM
This is so nice I am tempted to turn off my VWSql and VWSphp since I mainly use them to display historical graphs.  Here is my page. (http://deltaweathercam.com/wu-hist.php)
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: WeatherBeacon on February 20, 2008, 01:24:34 PM

That's really cool, Jim! Thanks!

I haven't added it to my site yet, but I hope to in the next month or so.

Kevin...
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jwyman on February 20, 2008, 03:06:01 PM
Ok, Ok, i'm going to play devil's advocate here..   :evil: Don't shoot me, just yet.. lol.

Can someone explaing to me the benefits of doing this when most programs already have graphing capabilities and you also run the risk of multiple points of failure (i.e you not sending data to WU or WU being down).

BTW, nice work. Just trying to decide if I really want to include this.... OK. Now someone can sell me on the point!    :grin: :grin: :grin:

Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: BfdWx on February 20, 2008, 04:17:25 PM
Quote
Just trying to decide if I really want to include this.... OK. Now someone can sell me on the point!

One stop shopping! Visitors to my site can see my WU data without leaving my site, plus they can check other area historical data and stay on my site. If the data is down for some reason it should be no big deal, if it's WU problem they will get it fixed if it'd WD's problem I'll know long before too much data is lost. I realize that most visitors to a weather web page are looking for something specific so I try to make a variety of areas that of interest to a broad audience, this is just one more page that may interest just one person! In fact just today I e-mailed one of the other hosters in my area and he was amazed at what the program was capable of. Now he can check his data from my site!
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: WeatherBeacon on February 20, 2008, 05:12:56 PM

Ok, Ok, i'm going to play devil's advocate here..   :evil: Don't shoot me, just yet.. lol.

Can someone explaing to me the benefits of doing this when most programs already have graphing capabilities and you also run the risk of multiple points

Sure.

The main reasons I like this include:

Secondary reasons include:

Regards,

Kevin...

p.s.  You're ever the devil's advocate, eh Jim? ;) O:)   I'll [-o&lt; for you. ;)
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: WeatherBeacon on February 20, 2008, 05:38:39 PM

Forget waiting a month or two. :roll: I just added it to my site. Thanks, Jim! =D&gt;

Regards,

Kevin...
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jwyman on February 20, 2008, 06:37:36 PM
Ok,Ok , so did I ! Very easy to do and man does it look nice! THanks Jim - From Jim  \:D/ \:D/ \:D/
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: WeatherBeacon on February 20, 2008, 07:15:53 PM

Ok,Ok , so did I ! Very easy to do and man does it look nice! THanks Jim - From Jim  \:D/ \:D/ \:D/

He he he! :lol:
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jwyman on February 20, 2008, 08:53:15 PM
BTW, if you'd like to see,  www.espwxctr.com/graphs.php

 \:D/

Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: BfdWx on February 20, 2008, 09:20:10 PM
Jim,

You've got such a great looking site....you should give the link to the historical page, it really looks good "within" your site. Nice job!

Jack
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jwyman on February 20, 2008, 09:26:09 PM
Thanks for hte very kind words.. There are so many people out there with super great ideas. It's just getting the feel of what your users would benefit from the most. That's what I love about this hobby/profession/advocation.....

Are you talking about the "On This Day" link?


Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: BfdWx on February 20, 2008, 09:42:49 PM
Quote
Are you talking about the "On This Day" link?

No, it's just when I clicked on the link you posted it brought me to a stand alone page of the Historical data as opposed to the one "embedded" in your site....http://espwxctr.com/index.htm (under "historical>graphs").

Jack
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: weatherforyou on February 21, 2008, 02:52:59 AM
Are you talking about the "On This Day" link?
I originally compiled that data about seven years ago and have been updating it recently with events after 1989.  It's available to any personal weather station site that wants to use it.  Of course a link back to weatherforyou.com from any site that uses it would be nice.   :?
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 21, 2008, 06:55:06 AM
Thanks to all for the kind words about the script.  It sure is gratifying to know that folks find it useful and that they've found no major problems with implementing it (so far).  My site was sadly lacking in the "historical data" department, so that was my motivation for the project.

I've added links to my scripts page for the folks who have posted above, but would very much like to hear from anyone else who is finding the script useful.  It makes me feel good.  If you'll either post a link here, PM or EMail me, I'll make those additions.

Thanks again.  - Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: up10ad N9RJH on February 21, 2008, 10:17:06 AM
I originally compiled that data about seven years ago and have been updating it recently with events after 1989.  It's available to any personal weather station site that wants to use it.  Of course a link back to weatherforyou.com from any site that uses it would be nice.   :?
Joe,

I used to have a Today page but dropped it a while back because most of the data was really old.  Is there a link to the one you use on your pages with the search form?  I'd like to give it a look if you don't mind.

Thanks.
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: DaculaWeather on February 21, 2008, 12:17:15 PM
Jim, I'm using the script on my site and love it! Thanks a million!
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jwyman on February 21, 2008, 12:56:12 PM
Hey bruecksteve,
  Did your town/city drop an "R" from it's name?  :lol: :lol:

Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: WeatherBeacon on February 21, 2008, 01:39:43 PM

Hey bruecksteve,
  Did your town/city drop an "R" from it's name?  :lol: :lol:

Jim

He he! Yeah, I think so, too! Even if not, I think you should add one, Steve. :mrgreen:  Where is that fang emoticon when I need one? Oh yeah ... I lost my fangs.

Kevin...
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: weatherforyou on February 21, 2008, 02:25:17 PM
I used to have a Today page but dropped it a while back because most of the data was really old.  Is there a link to the one you use on your pages with the search form?  I'd like to give it a look if you don't mind.
http://www.weatherforyou.com/history/

I could use some help bringing it up to date.  ;)
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: up10ad N9RJH on February 21, 2008, 09:10:06 PM
I used to have a Today page but dropped it a while back because most of the data was really old.  Is there a link to the one you use on your pages with the search form?  I'd like to give it a look if you don't mind.
http://www.weatherforyou.com/history/

I could use some help bringing it up to date.  ;)

I wasn't very clear on that, sorry Joe.  I found your page, but was taking you up on your offer ... you said "It's available to any personal weather station site that wants to use it."  Is it available for download?
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 22, 2008, 05:29:57 PM
Sorry all, but there was a parsing error for the daily rain in the daily summary section.  I have that fixed now and have also added the option to omit cloud conditions from the tabular listing for those who don't wish to display those two columns.

I also updated all the .css files to include Ken True's idea to isolate all the styles that the script uses.  If you're having any issues along those lines you may want to update that too.

Everything has been updated in the .zip file at http://jcweather.us/scripts.php?mitem=130

Thanks.  - Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: WeatherBeacon on February 22, 2008, 08:29:00 PM

Jim:

Which file(s) do we need to update?

Thanks!

Kevin...
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 22, 2008, 08:52:05 PM
I'm sorry, the parsing error was in the WU-History.php file.  I'd standby though because I'm working up a couple other small fixes that I hope to have done soon.

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: WeatherBeacon on February 22, 2008, 08:55:35 PM

I'm sorry, the parsing error was in the WU-History.php file.  I'd standby though because I'm working up a couple other small fixes that I hope to have done soon.

- Jim

Very good. Thanks for the "heads up".

Kevin...
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 22, 2008, 10:19:01 PM
I fixed a few more things ... I guess these things are never done.  Here's the current status of WU-History.php:

Version 1.0 February 18, 2008
        1.1 February 19, 2008 - Fixed a broken link to WU & added optional selection of other stations
        1.2 February 20, 2008 - Fixed an obscure link bug dealing with the new "other station" option
        1.3 February 22, 2008 - Added option to omit cloud conditions from tabular listing.  Fixed solar & rain issue in the summary section
        1.4 February 22, 2008 - Suppressed Solar & UV graphs in monthly & longer modes. Suppressed current conditions in the summary except when viewing the current day

The .zip download is current.

Thanks.  - Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 23, 2008, 11:58:16 AM
Sorry for all the changes, but we're adding some nice features along with fixing my knuckleheaded mistakes.  A new WU-History.php:

//        1.5 February 23, 2008 - Fixed precip error when viewing previous individual days.  Added optional top link in header to return to "today" when off somewhere else.

The .zip file has been updated.

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: anchorageweather on February 23, 2008, 12:16:12 PM
Sorry for all the changes, but we're adding some nice features along with fixing my knuckleheaded mistakes.  A new WU-History.php:

//        1.5 February 23, 2008 - Fixed precip error when viewing previous individual days.  Added optional top link in header to return to "today" when off somewhere else.

The .zip file has been updated.

- Jim


Can you copy and paste the settings between:

Code: [Select]
//settings ----------------------------- */
and

Code: [Select]
// end of settings
//------------------------------------------------

from one version to the next?
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 23, 2008, 01:59:42 PM
No, but perhaps take them in groups of 5 or so until you see where I've added something.  I was trying to keep things in some sort of logical order so they'd be easier to find. 

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: racenet on February 23, 2008, 02:26:26 PM
Jim,

Was working on this last night and had some problems. First, had problems reading the page with the install instructions. Menus or whatever, were overlaping, covering the text.

In short, what, exactly needs to be done to include this script into a standard HTML page?
I looked at other PHP scripts I have included in standard HTML pages and this one doesn't seem to want to follow the same include rules.

Thanks.


Bob


 
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 23, 2008, 03:18:52 PM
Bob,

Do you mean that my scripts page is what you were having trouble reading?  If so, I wonder what that could be.

Anyway, you'll need to rename your .html page to .php so PHP will parse and process it.  Then within the <head> portion of the page add

<link rel="stylesheet" type="text/css" href="./WU-History.css" />

and in the body of the page add

<php
    include("WU-History.php");
?>

and that should be it unless you need to adjust paths to where those files are located.  Is that what you're asking?

Thanks.  - Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: racenet on February 23, 2008, 03:40:06 PM
Humm, it doesn't seem to want to parse anything.

http://www.nhweatherdata.com/wu/wu.php

Any suggestions?


Bob
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 23, 2008, 04:26:12 PM
Sorry Bob, that's because I have a stupid typo on my page.  :oops:

Should be <?php instead of <php

I'm very sorry.  - Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: racenet on February 23, 2008, 04:40:22 PM
LOL

No problem Jim. Yeah, that made a difference. Working much better now.  =D&gt;
Now, just gotta figure out how to tweak it.

Thanks


Bob


Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: WeatherBeacon on March 07, 2008, 02:09:53 PM
Jim:

I downloaded Version 1.4 a day or two after you posted it and placed it on my server. (I already had the previous version running).

Just now I was looking at my precip on previous days, and I noticed that it shows 0 precip even on days in which it rained (and the "rainfall rate" graph shows precip, too). I thought this was a bug that you corrected. Or am I seeing a different issue?

If you happen to go to my site, click "Graphs" and look at Feb 17 or March 3, for example. I actually rec'd 0.42 inches on Feb 17.

Thanks, Jim!

Kevin...


EDIT:  Oops! Was this bug was fixed after Version 1.4? I'll give 1.6 a try.

That fixed it! Sorry folks. Just got over the flu ... bad mojo.
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 10, 2009, 06:12:55 PM
I've updated this script again, now to version 2.3.  This puts a better fix on the average wind problem (thanks to Paul Gogan for that) and adds a variable so we can turn this off if/when Wunderground fixes the problem.

Paul discovered that they were sending that figure in mph whether you were receiving data in english or metric.  I put a ticket in, but haven't heard back yet and am tired of waiting.  I'll get the word out if they ever fix that and we'll turn that variable to false.

This will affect those who receive the data in metric format which seems to be most everyone outside the US.  The new variable is at the top of the list, so be careful to not overwrite it when transferring your settings over.   Download the .zip here (http://jcweather.us/scripts.php)

Thanks.  - Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on April 18, 2009, 05:26:50 PM
New script update to Version 2.4 available at http://jcweather.us/scripts.php (http://jcweather.us/scripts.php)

Changed a column heading that was mis-labeled cm when it should have been mm (when units "both" was selected).

Noticed that Wunderground added solar, so the script will now optionally show that in the daily mode tabular data.

Please let me know if you have any problems.

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Maroney on April 19, 2009, 12:01:15 PM
Jim,

Unfortunately, I can't get the data to come across.
1) I'm using the latest revision 2.4
2) Initially, I was getting error codes till I changed the server settings to PHP 5 (from PHP 4)
3) If I put basic php code... echo 3+2; in the TestHistory.php, I'll get the result (PHP is working)
4) If I put the same basic code in the first line of WU-History.php, I'll get the result (WU-History.php is working)

other than that it's a big nothing.  I really like the work you've done, I hope I can get this working.
If you have any ideas, I'd appreciate it!

Thanks in advance
Paul
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: sam2004gp on April 19, 2009, 12:24:07 PM
Jim,

Unfortunately, I can't get the data to come across.
1) I'm using the latest revision 2.4
2) Initially, I was getting error codes till I changed the server settings to PHP 5 (from PHP 4)
3) If I put basic php code... echo 3+2; in the TestHistory.php, I'll get the result (PHP is working)
4) If I put the same basic code in the first line of WU-History.php, I'll get the result (WU-History.php is working)

other than that it's a big nothing.  I really like the work you've done, I hope I can get this working.
If you have any ideas, I'd appreciate it!

Thanks in advance
Paul


FYI:
Wunderground is having some issues today, so you might check and see if those are related to some of your problems. 
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on April 19, 2009, 05:23:02 PM
Paul,

First I've heard of anything like that.  I can see where if Wunderground doesn't serve up the csv file, it would stall.  If it continues, perhaps provide us a link so we can see it first hand.

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Maroney on April 19, 2009, 08:32:07 PM

Jim,

Thanks for the response, here's what I've found.

I took your files and put them on my other website I have hosted with yahoo, and poof, no problem. Everything was perfect.

Seems as though my other hosting company supports PHP, but something is missing, or a configuration file is set incorrectly.
Does my PHP.ini need to be configured a certain way? Here's what it looks like.
Thanks again for a great product!

Paul




[PHP]
display_errors = Off

; This is the default PHP 5-style version of the php.ini settings file.
; It is based on /usr/local/etc/php5/php.ini-recommended. For full reference
; of all possible configuration directives and their default values,
; please visit http://www.php.net/manual/en/print/ini.php

allow_call_time_pass_reference = Off   ; Code cleanliness
magic_quotes_gpc = Off         ; Performance
output_buffering = 4096         ; Performance
register_argc_argv = Off      ; Performance
register_globals = Off         ; Security, Performance [default]
register_long_arrays = Off      ; Performance
variables_order = "GPCS"      ; Performance
zlib.output_compression = On      ; Performance
allow_url_fopen = Off
allow_url_include = Off

cgi.fix_pathinfo = 1
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT
fastcgi.log = 0
max_execution_time = 15
max_input_time = 60
memory_limit = 32M
safe_mode_exec_dir =
upload_max_filesize = 10M
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

;include_path = ".:/usr/local/share/pear"

[Session]
session.bug_compat_42 = 0
session.gc_divisor = 1000
session.hash_bits_per_character = 5

;[eaccelerator]            ; *broken* (does not cope well with PHP5 yet)
;;extension="eaccelerator.so"      ; [Performance]
;eaccelerator.cache_dir="/tmp"
;eaccelerator.shm_size="4"
;eaccelerator.shm_only="1"

; All PHP5 extensions are dynamic and could be loaded on demand.
; The following ones used to be pre-loaded by default in PHP4,
; so we keep these enabled for backward compatibility:
extension=ctype.so
; extension=xslt.so

extension=mysql.so
extension=pcre.so
extension=posix.so
extension=session.so
extension=tokenizer.so
extension=xml.so
extension=zlib.so
;extension=simplexml.so
;extension=spl.so
;extension=sqlite.so

; In order to pre-load some of the following extensions,
; you would need to uncomment the appropriate line(s) below.
; extension=curl.so
 extension=ftp.so
; extension=gd.so
;extension=gettext.so
;extension=iconv.so
; extension=imap.so
;extension=mbstring.so
;extension=mcrypt.so
;extension=mhash.so
;extension=openssl.so
;extension=sockets.so
;extension=dom.so
;extension=xsl.so
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: saratogaWX on April 19, 2009, 08:35:10 PM
It's most likely the

allow_url_fopen = Off

that causes a problem.  Change it to

allow_url_fopen = on

and the script should work fine :)

Best regards,
Ken
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Maroney on April 19, 2009, 09:16:56 PM

Ken,

Thanks for the response.

Unfortunately, it didn't work. I'm not sure what's different with yahoo hosting vs. my other company. (aplus.net)
I prefer aplus.net, trying to get anything done with yahoo is ridiculous.

Again, thanks for the help.
Paul
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: saratogaWX on April 22, 2009, 02:00:44 PM
I'd tried Yahoo hosting, but found it too restrictive (forced safe_mode and allow_url_fopen turned off)
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Russell797 on April 23, 2009, 11:04:17 PM
The script returns a single digit "0" for all daily total rainfall regardless of date. The other time frames are working fine. This seems specific to my data which is uploaded  by WeatherLink using the old upload module version #1 produced by Davis for the Monitor II station I still have in operation. Other sites I have tried work fine save for one other I checked. On the WU site my daily rain is presented as expected.

You can see my page here: http://www.lowellhighlandsweather.com/WU_History/index.php (http://www.lowellhighlandsweather.com/WU_History/index.php)

And the WU page: http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KMALOWEL2 (http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KMALOWEL2)

As an aside check out the number of "hits" my data gets on the WU page!  :shock:

Is this problem a known issue with the script? Can it be fixed?

Thanks,

Russ



Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on April 24, 2009, 08:58:25 AM
Russ,

I just checked my data (some rain today) and it matches perfectly with WU.  When I look at your .csv data which is what the script reads, you have -99.99 in the second to last column (dailyrainin) so that is the problem.  I looked at yesterday, April 23rd.

So obviously WU is receiving your data and displaying it correctly, but for some reason the .csv file they produce isn't correct.  I don't know what that could be, perhaps someone else here has an idea.

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: LeomaTNWX on April 25, 2009, 04:01:27 PM
I have never used PHP could someone give me some help on how to add this to my site?

Thanks
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on April 26, 2009, 07:23:36 AM
There are instructions here http://jcweather.us/scripts.php (http://jcweather.us/scripts.php) and in the .zip file a file named TestHistory.php that demonstrates how to do it.  The file that you include it in must have a .php extension.

Good Luck.  - Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: George Richardson on April 27, 2009, 03:03:50 PM
Jim,

I've been looking forward to adding your script to my site ever since you offered it but my lack of knowledge of Web Site programming in general and Scripting in particular made me procrastinate for the last year and a half. This morning I just DID IT and it really wasn't too painful.

Thank you again for the effort.

George

Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: spweather on April 27, 2009, 03:13:55 PM
Great script Jim, Thank You.

I am having trouble with the font size that has me at witt's end. The URL is http://www.sandpointweather.com/WU-History.php I tried removing the link to my spweather.css even temporarily deleted the file and it didn't change.

I had the same problem when I first installed Ken's (and Tom's) advforecast2.php on my home page, in fact I'm still not pleased with my attempt to fix it.

Any help will be appreciated,
Thanks, Dennis
http://www.sandpointweather.com
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on April 27, 2009, 03:35:33 PM
Dennis,

I remember when the script first came out, Bashy had the same issue.  Obviously some kind of conflict.  I was never able to figure it out for him, but perhaps he eventually did?

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: LeomaTNWX on April 28, 2009, 08:12:35 AM
I keep getting these errors. Every time I try and re-do it the error changes lines. I have never used php so I am lost. I have been copy and pasting the WU history file into the HTML section of front page. Is this the correct way to do this or am I making it harder than it really is?


Parse error: syntax error, unexpected T_VARIABLE, expecting ';' in /virtual/users/e16105-17163/web/history.php on line 1084
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on April 28, 2009, 09:06:02 AM
The error makes it impossible to see any of the code on that page, so we'll have to guess a little bit.  FrontPage sometimes causes problems for folks, so let's try this:

Open your history.php file in notepad and re-do the include using that as the editor.  If that doesn't help, next go through the configuration section of WU-History.php where you've made changes and make sure each of the options that you've changed ends with a semi-colon ... you may have inadvertently over-written one which could throw everything out of sync.  You wouldn't think it would get to line 1084 though .....

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: LeomaTNWX on April 28, 2009, 06:14:30 PM
I use notepad and re did it all and no change. So I tried again and the error went from line 1086 to line 1088 and all I did was copy and past the same file. Everything looks good in the config area.
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on April 28, 2009, 06:50:25 PM
Let's try this next.  Download a new .zip file from http://jcweather.us/scripts.php (http://jcweather.us/scripts.php) and place all of the contents into a folder on your server.  Then run the TestHistory.php file that's in there.  If it works and you see the data for my station come up, then that's a good copy of the script and we'll go from there.

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: LeomaTNWX on April 28, 2009, 07:34:10 PM
I am at work now so it will be late tonight before I can do that. Thanks for all the help.
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: LeomaTNWX on April 29, 2009, 03:26:14 AM
I got it working. Thanks for the help.
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on April 29, 2009, 07:04:28 AM
Great News!  Did you figure out what the problem was?

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: LeomaTNWX on April 29, 2009, 01:49:57 PM
I downloaded a new copy of the zip file and then used notepad to edit it. Front page was messing it up. Again thanks for the help.
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Russell797 on May 18, 2009, 08:57:51 AM
THIS IS SERIOUS:

My WU History page generated by this script has been attacked by a robot "spider". I was checking the stats on my hosting server and noticed my bandwidth usage for the month had risen to over 3.5 gigabytes in just over half a month. My typical usage is less than 1/2 gigabyte per month.

Looking deeper into the current usage I found this "bot" accessing my WU page every 4 seconds around the clock!

    Http Code: 200     Date: May 18 07:20:39     Http Version: HTTP/1.1     Size in Bytes: 4523
   Referer:
   Agent: Mozilla/5.0 (compatible; YodaoBot/1.0; http://www.youdao.com/help/webmaster/spider/; ) 
   
       /WU_History/index.php?ID=KMALOWEL2&day=22&mode=4&month=8&units=B&year=1989

------------------------

I blocked the IP address of this "robot" which temporarily halted the activity, but this morning I noticed it was back at work using a new IP address.

Unfortunately I will be forced to remove the script from my site.

Use this as an alert to check if this is happening to you. I have 25 gigs of server bandwidth/month but can not allow this to continue, the gigs add up fast at the rate they are using.
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Axelvold on May 18, 2009, 09:53:31 AM
THIS IS SERIOUS:

My WU History page generated by this script has been attacked by a robot "spider". I was checking the stats on my hosting server and noticed my bandwidth usage for the month had risen to over 3.5 gigabytes in just over half a month. My typical usage is less than 1/2 gigabyte per month.

Looking deeper into the current usage I found this "bot" accessing my WU page every 4 seconds around the clock!

    Http Code: 200     Date: May 18 07:20:39     Http Version: HTTP/1.1     Size in Bytes: 4523
   Referer:
   Agent: Mozilla/5.0 (compatible; YodaoBot/1.0; http://www.youdao.com/help/webmaster/spider/; ) 
   
       /WU_History/index.php?ID=KMALOWEL2&day=22&mode=4&month=8&units=B&year=1989

------------------------

I blocked the IP address of this "robot" which temporarily halted the activity, but this morning I noticed it was back at work using a new IP address.

Unfortunately I will be forced to remove the script from my site.

Use this as an alert to check if this is happening to you. I have 25 gigs of server bandwidth/month but can not allow this to continue, the gigs add up fast at the rate they are using.

Do you have the robots.txt file in your root?
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Russell797 on May 18, 2009, 11:16:01 PM
Axelvold,

No robots.txt file in my server's root directory. The robot is still pounding away in an attempt to access my now non-existent WU_History file. There are actually 2 apparently independent robots looking to download the page. I wonder if the Weather Underground is behind this outrageous affront to my bandwidth allotment in a reciprocal action in retaliation to my pulling down data from their site? Am I the only one experiencing this? :mad:
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Axelvold on May 19, 2009, 01:15:40 AM
Make a robots.txt and write the following in it

User-agent: *
Disallow: /WU_History/
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on May 19, 2009, 07:10:08 AM
Yes, that will happen with any script that calls itself with different parameters such as this one does.  I will have to add that to the documentation.  Thanks Axelvold!

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Axelvold on May 19, 2009, 07:20:33 AM
The best to do is to enter all the folders that the robots dont should have access to.

And if you have some files in the root that you want to hide from the robot, just write the file name in the files as well.

User-agent: *
Disallow: /WU_History/
Disallow: /filename.php




Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Russell797 on May 19, 2009, 08:48:31 AM
I uploaded the robot.txt file to the server root, copied the WU_History files into their folder and check the results with hopeful anticipation, but this is what I observed  :???:

I tried:

User-agent: *
Disallow: /WU_History/

and then:

User-agent: *
Disallow: /WU_History/index.php


Neither stopped the onslaught.


    
   

    * 

   
/WU_History/index.php?ID=KMALOWEL2&day=23&mode=4&month=1&units=M&year=1990
   Http Code: 200    Date: May 19 07:31:44    Http Version: HTTP/1.1    Size in Bytes: 4510
   Referer:
   Agent: Mozilla/5.0 (compatible; YodaoBot/1.0; http://www.youdao.com/help/webmaster/spider/; )   
    *     
/WU_History/index.php?ID=KMALOWEL2&day=27&mode=4&month=11&units=B&year=2026
   Http Code: 200    Date: May 19 07:31:48    Http Version: HTTP/1.1    Size in Bytes: 4542
   Referer:
   Agent: Mozilla/5.0 (compatible; YodaoBot/1.0; http://www.youdao.com/help/webmaster/spider/; )   
    *     
/WU_History/index.php?ID=KMALOWEL2&day=31&mode=5&month=7&units&units=M&year=2024
   Http Code: 200    Date: May 19 07:31:52    Http Version: HTTP/1.1    Size in Bytes: 4608
   Referer:
   Agent: Mozilla/5.0 (compatible; YodaoBot/1.0; http://www.youdao.com/help/webmaster/spider/; )   
    *     
/WU_History/index.php?ID=KMALOWEL2&day=9&mode=5&month=12&units=B&year=1989
   Http Code: 200    Date: May 19 07:31:56    Http Version: HTTP/1.1    Size in Bytes: 90405
   Referer:
   Agent: Mozilla/5.0 (compatible; YodaoBot/1.0; http://www.youdao.com/help/webmaster/spider/; )
   
   
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Axelvold on May 19, 2009, 08:57:39 AM
check the name on the file, it should be robots.txt

And see to that it is placed in the www root not the server root that i did write in a earlier post, sorry.

If this dont work, try to black list the IP in the server configuration file
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Russell797 on May 19, 2009, 09:38:05 AM
Ok, the big bad guy has stopped downloading. The second one continued, but seems to have a static IP address so I bocked it. (66.249.71.48)

    *     
/WU_History/index.php?ID=KMALOWEL2&month=7-&day=4&year=2008&units=B&mode=2
   Http Code: 404    Date: May 19 08:40:36    Http Version: HTTP/1.1    Size in Bytes: -
   Referer: -
   Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

-------------------

The robots.txt file has been successfully read by:

    * 

   
/robots.txt
   Http Code: 200    Date: May 19 08:28:04    Http Version: HTTP/1.1    Size in Bytes: 56
   Referer: -
   Agent: msnbot-media/1.1 (+http://search.msn.com/msnbot.htm)


---------------------

It seems by looking about the net that the robots.txt file is a request to cease robot activity, but some rogue robots can refuse to comply.

http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40360 (http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40360)
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: xmas111 on April 15, 2011, 06:26:43 PM
I know this thread is old but I just installed the Wu-History.php and have a quick question.

It's seems to be working fine except it won't show the sky condition.

I have the "sky conditions" turned on in the script, (set to false so it doesn't hide the sky conditions.

On my wunderground page the sky conditions show but not on my page with the script.

here's my wunderground page: http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KMAROCKL1 (http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KMAROCKL1)
and here's my page with the script: http://johnsweather.com/wunder/wunder.php (http://johnsweather.com/wunder/wunder.php)

anyone have any idea what I may have done wrong setting up the script?

Thanks,
John
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 03, 2012, 10:02:05 AM
And now this thread is even older. :lol: 

Several people have found that the script is being blocked by Wunderground and in corresponding with them, if the script requested a date in the future it caused them problems.  This could happen with bot activity or being selected by one of your users, so if you're using the script please get a new copy at http://jcweather.us/scripts.php (http://jcweather.us/scripts.php) and update.  Dates selected in the future will be kicked back to the current date.

If you find you are now being blocked you'll have to contact them to get unblocked, and tell them you've updated the script.  An Email to support@wunderground.com will do it.  Sorry for any inconvenience.

Thanks.  - Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jay_hoehn on February 03, 2012, 01:13:56 PM
Jim,

This fix doesn't seem to be applied to the template plugin on Ken's site.  I guess that will come with the next updates.  I was able to make the addition on my own.

Thanks,

Jay
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: gwwilk on February 03, 2012, 01:59:26 PM
Jim,

This fix doesn't seem to be applied to the template plugin on Ken's site.  I guess that will come with the next updates.  I was able to make the addition on my own.

Thanks,

Jay

Likewise.  It's a pretty straightforward cut and paste.

Thanks Jim & Jay!
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Curly on February 03, 2012, 03:12:18 PM
Thanks for the update Jim!
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Stetson1 on February 03, 2012, 03:20:06 PM
Can someone share the code change needed? Can I simply edit the wu-history.php file or do I need to go through the entire install process again?

Todd
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 03, 2012, 04:14:51 PM
Sure, if you have a fairly recent version just insert lines 233-237 in your copy right after

$isToday = strtotime($reqdate) == strtotime(date("d-m-Y"));

whatever that line is on.

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: ctccbc on February 03, 2012, 04:56:08 PM
I tried that fix here and it still doesn't work. The graphs appear, but the table is blank.

Chris
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: jmcmurry on February 03, 2012, 05:15:40 PM
Check out the posts a little ways above.  You'll need to contact Wunderground to get unblocked.  The script change is at their request and to prevent future problems.

- Jim
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: dasman on February 04, 2012, 10:32:30 AM
Jim

Thanks for the update!  Seems to work perfectly.  I selected a date later in the month and it kicked back to today.

Thanks again.

Dave
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: mth on February 04, 2012, 02:27:13 PM
I too applied the latest version and am getting no data.  I've submitted a request to WU.

Michael
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: Stetson1 on February 04, 2012, 04:54:09 PM
Submitted a request to WU Support. They are probably backlogged so I'll give it a few days.

Todd
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: saratogaWX on February 04, 2012, 05:33:17 PM
I've updated the wxwuhistory.php page and the WU-History-inc.php from Jim's V2.7 WU-History script.

Corrections in wxwuhistory.php for older PHP syntax, and added a

<meta name="robots" content="index, nofollow" />

to the page to (hopefully) prevent search bots from running amok with links in the first place.

The WU-History-inc.php file does have Jim's code to prevent browsing to future dates.

Note: this script is currently English-only and translation functions are not currently in the code.

Thanks Jim for keeping the script alive :)  I see you added a User-agent: string in the request also .. that should help WU know where the requests come from like my update to WU-forecast does :)

Best regards,
Ken
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: ctccbc on February 04, 2012, 10:06:28 PM
Ken,

Is this script available somewhere?

Regards,
Chris
moreheadcityweather.com
Title: Re: PHP Script to Display Your Wunderground Historical Data
Post by: saratogaWX on February 04, 2012, 10:08:59 PM
Hi Chris,
If you mean the WU-History script 'template-ized', then yes...

http://saratoga-weather.org/wxtemplates/plugins.php#wxwuhistory