deformed-offering

Weather station scripts

They're free, but use at your own risk

The scripts referenced here are used in the operation of this weather station, and may be freely copied and used to support your station. Please note that you use these scripts at your own risk. No warranty is expressed or implied. I accept no liability for any damages that may ensue from their use.
You will need to configure them for your own particular weather station website.
RSS feed for Scripts Updates A RSS Feed is available to help keep you informed on updates to the scripts.

If you find one or more of the scripts useful to you, please consider making a donation to help offset the routine expenses of operation of this website.
Thanks for your kind support!

A Version History is available -- check back from time to time to see if there are updates to scripts you have downloaded earlier. Announcements of version updates and new scripts are made on WXForum.net and Weather-Watch forums and saratogaWXPHP Twitter account as they become available.

This page was updated Friday, 25-Sep-2009 10:21 AM

PHP Scripts (run on webserver)

These scripts have run on PHP 4.1.2, and PHP 4.4.1. I don't have access to PHP 3.x, so it is not known if they will work on versions below PHP 4.1.2. If you try them and they work (or not) on earlier versions of PHP, please send me a message at webmaster[at]saratoga-weather.org and let me know the results.

Great PHP scripts from others...

I've used several scripts from other folks and they have my greatful thanks for sharing their developments! Here are the links:


Testing to see if PHP is available on your website

PHP scripts require PHP-capable web hosting to run. You can compare features and base prices for many hosting providers at Web Hosting Search. I do recommend that you use a Linux/Apache web host -- the scripts seem to run better on that platform and require fewer adjustments to get working correctly.

If you are using a website provided free by your internet service provider as part of your ISP subscription, it's unlikely that PHP will be available. I recommend that you avoid 'free' PHP hosting services -- they tend to add HTML/JavaScript code to each of your pages which will render them not valid XHTML, and may prevent the scripts that generate images from working at all. If you pay $5 to $15/month for a website, then it's likely that PHP would be available and these and other scripts should work fine.

To check your website out, just copy the following code and paste into a new .php page, upload it to your website, and view it with your browser. The name of the file is not important, but the .php extension is: it tells the server to invoke the PHP engine and parse the page, so don't expect this to work if you upload it as a .htm or .html file. You can see my example working here and failing here (failing beause I made .html the extension for this example).

<html>
<head>
<title>PHP test</title>
</head>
<body>
<h1>Does PHP work?</h1>

<?php echo "<h2>Yes, it does.  PHP Version " phpversion() ."</h2>"
  echo 
"<p>To run the WXGRAPHIC script, you need GD enabled in PHP.\n";
  echo 
"<br />Current GD status:</p>\n";
  echo 
describeGDdyn();
  
// Retrieve information about the currently installed GD library
// script by phpnet at furp dot com (08-Dec-2004 06:59)
//   from the PHP usernotes about gd_info
function describeGDdyn() {
 echo 
"\n<ul><li>GD support: ";
 if(
function_exists("gd_info")){
  echo 
"<font color=\"#00ff00\">yes</font>";
  
$info gd_info();
  
$keys array_keys($info);
  for(
$i=0$i<count($keys); $i++) {
if(
is_bool($info[$keys[$i]])) echo "</li>\n<li>" $keys[$i] .": " yesNo($info[$keys[$i]]);
else echo 
"</li>\n<li>" $keys[$i] .": " $info[$keys[$i]];
  }
 } else { echo 
"<font color=\"#ff0000\">NO</font>"; }
 echo 
"</li></ul>";
}
function 
yesNo($bool){
 if(
$bool) return "<font color=\"#00ff00\"> yes</font>";
 else return 
"<font color=\"#ff0000\"> no</font>";
}
?>

<p>If you don't see "Yes, it does." in large font above, then PHP is not enabled.</p>
</body>
</html>

If it returns something like this:

Does PHP work?

Yes, it does. PHP Version 4.4.2

To run the WXGRAPHIC script, you need GD enabled in PHP.
Current GD status:

  • GD support: yes
  • GD Version: 2.0 or higher
  • FreeType Support: yes
  • FreeType Linkage: with freetype
  • T1Lib Support: no
  • GIF Read Support: yes
  • GIF Create Support: yes
  • JPG Support: yes
  • PNG Support: yes
  • WBMP Support: yes
  • XBM Support: no
  • JIS-mapped Japanese Font Support: no

If you don't see "Yes, it does." in large font above, then PHP is not enabled

Then you're good to go with PHP scripts! If, however, it returns something like this:

Does PHP work?

Yes, it does. PHP Version " . phpversion() .""; echo "

To run the WXGRAPHIC script, you need GD enabled in PHP.\n"; echo "
Current GD status:

"; echo describeGDdyn(); // Retrieve information about the currently installed GD library // script by phpnet at furp dot com (08-Dec-2004 06:59) // from the PHP usernotes about gd_info function describeGDdyn() { echo "

  • GD support: "; if(function_exists("gd_info")){ echo "yes"; $info = gd_info(); $keys = array_keys($info); for($i=0; $i
  • " . $keys[$i] .": " . yesNo($info[$keys[$i]]); else echo "
  • " . $keys[$i] .": " . $info[$keys[$i]]; } } else { echo "NO"; } echo "
"; } function yesNo($bool){ if($bool) return " yes"; else return " no"; } ?>

If you don't see "Yes, it does." in large font above, then PHP is not enabled.

Then your current hoster doesn't support PHP, and you should look for a new hoster which does support PHP in order to use these scripts.


PHP Weather-Display tags

Please note that there are (at least) two different ways of using PHP tags with Weather-Display. The first method is using carterlake's wx30.html/getraw.php method which is quite popular. For that method, please see Tom's site.
The second method was my own development and is documented below. You only need one method to use for your site, so pick either one as you prefer. Both methods allow for upload of a single WD-substituted file whereby you can include weather variables for display on any of the pages of your website by simple PHP include and print/echo statements.

When designing this website, I wanted to use weather data on every page, and since the data was from both Weather-Link and Weather-Display 10.37R-(b81), there was the issue of potentially having two weather programs trying to upload the same page. I took a different method to relieve this issue, and used the weather programs to upload PHP files with current data, then use PHP on the pages to display that data as needed. I created a Perl program to convert the Weather-Display tagslist.txt into a PHP variables file, naming the PHP variables what the WD variables were named (within reason.. some of the WD variables were not proper PHP names for variables, and a few variables were renamed to prevent conflicts).

Perl program: gen-PHP-tagslist.pl.txt
WD Full tags: testtags-full.txt (repeating tags removed)
WD tags I use: testtags.txt can be seen in processed form testtags.php?sce=view
(the latter two files are located in the \wdisplay\webfiles directory and are uploaded by the custom file upload facility of WD.. I don't use the FULL tags because it's BIG, and I don't need all the tags.

I also have WeatherLink upload a snippet for me to pick up tags that WD left off (like Moon Phase Name)
WeatherLinktags.htx.txt uploaded from the WeatherLink templates directory as WeatherLinktags.php.

So, for any page on the website that needs weather station data displayed, I just have to include either (or both of the following statements in the page:

<?php include("testtags.php"); ?>
<?php include("WeatherLinktags.php"); ?>

to be able to use/display the data on the page.


References for programmers

When you code, you like to have a few references and sources handy to help the coding project along. The following are my favorite items, which you may find useful.

HTML and CSS

The Web Design Group offers both HTML 4.0 and Cascading Style Sheet Windows HTML Help, Apple Help files for free. I frequently use the offline versions above to check out the syntax of my code. For final checking, the W3 validators are very useful (http://validator.w3.org/ ). An online reference for XHTML 1.0-Strict is also very useful.

JavaScript and DHTML

The JavaScript language offline documentation is hard to find (now that the Netscape source site is decommissioned), but I use the PDF versions of the JavaScript Client Guide and JavaScript Client Reference, which you can download from the links. My favorite DHTML/JavaScript source is http://www.dynamicdrive.com/.

Testing HTML/PHP generated pages and JavaScript

My favorite browser is FireFox V3.5 with it's tabbed window. Two must-have plugins for FireFox are the Web Developer and FireBug tools. Together they provide extensive information on web pages and allow you debug JavaScript interactively. For general use, I found the NoScript, Netcraft, and ForecastFox plugins very useful too. My pages are tested on Internet Explorer 8, Safari (Windows), and Opera 10.

PHP

The offline documentation on PHP is excellent from http://www.php.net/download-docs.php . I use the Windows Extended HTML help version very often! It is packed with user notes and code snippets showing how to use various features, and allows me to stick to a PHP 4.x version feature set for my code.

Perl

While the source for Perl documentation is http://perldoc.perl.org/ , I like to use an ancient (Perl 4) Windows Help file to just look up the syntax. I don't think it's available any more, but you can download my copy here. For general Perl modules and scripts, the CPAN (http://search.cpan.org/ ) is the definitive source.

deformed-offering