cloudy cloudy

Author Topic: WxSim Temperature Forecast Comparison Script  (Read 174346 times)

0 Members and 1 Guest are viewing this topic.

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,799
  • Mauston, WI, USA
    • Juneau County Weather
WxSim Temperature Forecast Comparison Script
« on: February 10, 2009, 09:07:54 PM »
I've created a new script that will record and display comparisons of WxSim temperatures with those of another system.  Other systems supported are the National Weather Service, Weather Underground and Environment Canada.  The required plaintext-parser.php as well as all the scripts to parse the others were created by, and are available from Ken True at http://saratoga-weather.org/scripts-WXSIM.php.

You can see a Demo Page with lotsa data here, see the installation on my site and download a copy here.

Please let me know if you have any problems or questions.

- Jim

Edited to remove the Demo link since it's no longer maintained.
« Last Edit: April 19, 2009, 12:27:01 PM by jmcmurry »
Forum Search and Google can be your best friends

 Home of NSLog NexStorm Lightning Data Manager

Offline BfdWx

  • Posts: 1,605
  • Branford Connecticut
    • Southern CT Weather
Re: WxSim Temperature Forecast Comparison Script
« Reply #1 on: February 10, 2009, 09:33:25 PM »
Excellent script Jim, I've been wanting to track this for a while but never have the time! This will make things really easy.

Thanks for sharing!

Jack

Offline jwwd

  • WML testers
  • Posts: 3,692
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: WxSim Temperature Forecast Comparison Script
« Reply #2 on: February 10, 2009, 10:15:47 PM »
Hi Jim

Thank you very much for another great script.

It was very easy to get running:

www.silkeborg-vejret.dk/sammenlign.php

Best regards,

Henrik
« Last Edit: May 06, 2013, 05:24:04 AM by jwwd »

Offline saratogaWX

  • Global Moderator
  • Posts: 5,685
  • Ken True
  • Saratoga, CA, USA 37:16:28N, 122:01:23W - Elev: 374ft.
    • Saratoga Weather
Re: WxSim Temperature Forecast Comparison Script
« Reply #3 on: February 11, 2009, 01:28:35 AM »
This is fantastic, Jim!  What a great script set to allow us to compare actuals v.s. our own and a reference forecast.

I have one suggestion to help keep the scripts safe from abuse by miscreants .. use an allowed-file name for the config param so it won't be vulnerable.   Something like
Code: [Select]
<?php
$allowed 
= array (
  
'am' => 'fc-configAM.php',
  
'pm' => 'fc-configPM.php'
);

$configfile "fc-config.php";

if (isset(
$_REQUEST['config']) and isset($allowed[$_REQUEST['config'])) {
  
$configfile $allowed[$_REQUEST['config']);
}
?>


That way, no bad juju can be jammed into the script :)

Best regards,
Ken
Ken True
Saratoga Weather
CWOP: CW1792
WeatherUnderground: KCASARAT1
Free weather website PHP scripts and WD website AJAX templates

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,799
  • Mauston, WI, USA
    • Juneau County Weather
Re: WxSim Temperature Forecast Comparison Script
« Reply #4 on: February 11, 2009, 01:39:45 AM »
Ken,

Thanks for that, with all the discussion on security these past couple days you'd think I'd have noticed that.  Would an alternative be to check whether the file exists on the server and only include those?  That would leave folks the option of creating many more, for instance in different languages etc.

- Jim
Forum Search and Google can be your best friends

 Home of NSLog NexStorm Lightning Data Manager

Offline saratogaWX

  • Global Moderator
  • Posts: 5,685
  • Ken True
  • Saratoga, CA, USA 37:16:28N, 122:01:23W - Elev: 374ft.
    • Saratoga Weather
Re: WxSim Temperature Forecast Comparison Script
« Reply #5 on: February 11, 2009, 01:43:54 AM »
The safest way is to use the associative lookup for allowed filenames .. anything else would allow them to substitute an URL for the value (or backrefs to system files) .. better to have the 'authorized list' be in the script, then no funny-business can be done with the parameter :)
Ken True
Saratoga Weather
CWOP: CW1792
WeatherUnderground: KCASARAT1
Free weather website PHP scripts and WD website AJAX templates

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,799
  • Mauston, WI, USA
    • Juneau County Weather
Re: WxSim Temperature Forecast Comparison Script
« Reply #6 on: February 11, 2009, 02:29:37 AM »
Thanks Ken,

I'll do it that way, they'll have to do some editing at the beginning of the main file, but I guess that's ok.  I think I'll add a language file to the mix too just in case they want to serve it up in different languages.

- Jim
Forum Search and Google can be your best friends

 Home of NSLog NexStorm Lightning Data Manager

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,799
  • Mauston, WI, USA
    • Juneau County Weather
Re: WxSim Temperature Forecast Comparison Script
« Reply #7 on: February 11, 2009, 05:47:06 PM »
The .zip file has been updated with the following changes:

Version 1.0 - 02-10-09 - Initial release
           1.1 - 02-11-09 - Removed language vars from the config and created fc-language.php to make multiple languages easier to maintain.
                                  Added a more secure file inclusion method as recommended by Ken True.

Plus, I discovered that I didn't get the best copy of forecast-compare-include.php in there yesterday either.  To upgrade, save your fc-config.php for reference then upload a whole new set of files.  Edit the new config and the fc-language.php files as required.

Sorry for the inconvenience.  - Jim
Forum Search and Google can be your best friends

 Home of NSLog NexStorm Lightning Data Manager

Offline BfdWx

  • Posts: 1,605
  • Branford Connecticut
    • Southern CT Weather
Re: WxSim Temperature Forecast Comparison Script
« Reply #8 on: February 11, 2009, 08:27:20 PM »
I'm having a little issue/trouble mainly with my mind and a little with the script. Trying to do an am/pm log and for now using the poor man's method of using the web address to update the log. I've made two fc-configs, one am one pm with corresponding logs and uploaded them. This morning's upload went smoothly but this afternoon' wiped this mornings data and said 'this forecast has already been run". I did run a new WXSIM forecast which now shows in both charts as 2:35pm.

So am I calling the script incorrectly? Here is a snippet of the code I'm using;

Code: [Select]
$_REQUEST['config'] = 'fc-configam.php';       // It will default to this one if this isn't included
$_REQUEST['lang'] = 'en';                   // This will default to English if not included
include("forecast-compare-include.php");

$_REQUEST['config'] = 'fc-configpm.php';       // It will default to this one if this isn't included
$_REQUEST['lang'] = 'en';                   // This will default to English if not included
include("forecast-compare-include.php");

So am I improperly calling the script or improperly calling the wrong web addresses?

Thanks,

Jack

Here is where the script is running....http://stillweather.com/nuforecast_compare.php



Offline Elderberry

  • Mike
  • Posts: 167
  • USA - Louisiana
    • SoHiWeather
Re: WxSim Temperature Forecast Comparison Script
« Reply #9 on: February 11, 2009, 09:31:40 PM »
Great script Jim!

Mike

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,799
  • Mauston, WI, USA
    • Juneau County Weather
Re: WxSim Temperature Forecast Comparison Script
« Reply #10 on: February 11, 2009, 10:21:04 PM »
So am I improperly calling the script or improperly calling the wrong web addresses?

Jack,

The code you posted looks fine, you're calling the script twice, once with each config file.  I suspect the problem is in the logging portion and I would check to make sure that you have a different log name in each of the configs.  Looks like you are logging to the same one.  If you want, you can turn the debug on (in both configs) and do one and then the other to make sure they are logging to the right place.  The display portion is working fine and looks very nice.

- Jim
Forum Search and Google can be your best friends

 Home of NSLog NexStorm Lightning Data Manager

Offline BfdWx

  • Posts: 1,605
  • Branford Connecticut
    • Southern CT Weather
Re: WxSim Temperature Forecast Comparison Script
« Reply #11 on: February 11, 2009, 11:19:39 PM »
Hmmm.....getting worse now  #-o

Decided to get one right first so put just one chart in. Take a look at the chart now, the data is in several times and it is wrong. If "forecast day" is today my high was 60 and wxsim was right on the mark. Where is 43 coming from and why is it populating across the fields. Sorry to be a pain but I really like this script!

Thx

Jack

Edit: OK, I think it is ok now, so did I miss today's comparison? And if I run wxsim 3 times a day I should get data 3 times for the same day?
« Last Edit: February 11, 2009, 11:30:57 PM by firewall »

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,799
  • Mauston, WI, USA
    • Juneau County Weather
Re: WxSim Temperature Forecast Comparison Script
« Reply #12 on: February 11, 2009, 11:43:06 PM »
Jack,

You only want it to run once each day, shortly after your WxSim forecast is run.  It will capture the forecast temperatures just like you see on your page.  Tomorrow when you run it, it will fill in the ACT (actual) temperature that happened on that line, and build a new line for that next forecast.  If you look at my page, you'll see that the actual temperatures get filled in and stagger down and to the right because those forecasts were for xx days out.

If you want to track both am and pm forecasts, you're just doing that same thing twice but with different config and log files.

- Jim
Forum Search and Google can be your best friends

 Home of NSLog NexStorm Lightning Data Manager

Offline BfdWx

  • Posts: 1,605
  • Branford Connecticut
    • Southern CT Weather
Re: WxSim Temperature Forecast Comparison Script
« Reply #13 on: February 11, 2009, 11:47:03 PM »
OK, thanks Jim, I think (usually when I get in trouble) I found my errors so I should be able to get the two tables back up properly. Thanks for the help!

Jack

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,799
  • Mauston, WI, USA
    • Juneau County Weather
Re: WxSim Temperature Forecast Comparison Script
« Reply #14 on: February 12, 2009, 12:19:32 AM »
Good news Jack.  You can mess around with it tonight with debug on and then upload blank logs when you're done.  That way you'll be all set to go for tomorrows forecasts.

I know Henrik has it working ok in Denmark, I wonder if anyone has tried yet in Canada.

- Jim
Forum Search and Google can be your best friends

 Home of NSLog NexStorm Lightning Data Manager