WXforum.net

Web Weather => Weather Website PHP/AJAX scripting => Custom Website Templates => Topic started by: saratogaWX on June 10, 2020, 08:34:50 PM

Title: Saratoga Base-USA updated index.php maps
Post by: saratogaWX on June 10, 2020, 08:34:50 PM
I've added the NWS Regional Radar animated images to replace the (now, non-functioning) Weather Underground Regional Radar images on the homepage just above the ajax-dashboard display. 

A new script (USA-regional-maps-inc.php) now generates the table containing the two images (left=NWS Regional Radar, right=WU Regional IR Satellite).  It will honor custom graphic display for the left or right image with optional links to detailed pages if you'd prefer to use your own stuff instead of the NWS and/or WU images (like a webcam image or Blitzortung Lightning display).  See the README file for more information.

Be careful in the installation, as an updated wxindex.php and Settings.php are included.  There's a README file also on how to do MANUAL installation if you'd rather -- the new entries for Settings.php and the change to (wx)index.php are detailed there.
Just upload the new USA-regional-maps-inc.php and you'll be set after a manual installation.

Update from the update tool (https://saratoga-weather.org/wxtemplates/updates.php) with query Base-USA, Plugin-*, 10-Jun-2020

Attached is the README file for more info...
Title: Re: Saratoga Base-USA updated index.php maps
Post by: user3162 on June 11, 2020, 09:39:26 AM
I like the new animated images, thanks Ken! But I have a problem in Settings. I had to comment this out,
/*
SITE['NWSalertsCodes'] = array(
  "Lancaster County|PAZ066|PAC071"
//  "Santa Cruz Mtns|CAZ512|CAC081|CAC085|CAC087",
//  "Santa Cruz|CAZ529|CAC087",
//  "Monterey|CAZ530|CAC053",
//  "South/East Bay|CAZ508|CAC081",
//  "San Mateo Coast|CAZ509|CAC081",
//  "San Francisco|CAZ006|CAC075"
);
*/
I get the error:
 Parse error: syntax error, unexpected '=' in /home/nhpaweat/public_html/Settings.php on line 205

What did I do wrong?
https://nhpaweather.com/wxindex.php
Thanks
Title: Re: Saratoga Base-USA updated index.php maps
Post by: Jasiu on June 11, 2020, 09:53:46 AM
Missing the dollar sign ($) before SITE.
Title: Re: Saratoga Base-USA updated index.php maps
Post by: user3162 on June 11, 2020, 09:57:50 AM
That did it! Thanks
Title: Re: Saratoga Base-USA updated index.php maps
Post by: miraculon on June 11, 2020, 11:13:57 AM
Thanks so much for this fix! It looked like a big effort on your part, Ken.

 [tup] [tup] [tup]

At first I put the wrong "region" codes for NWSregion and WUsatellite and wound up with California. I was too accustomed to "mw" instead of "nc" for these items.

Other than that, it went very well.

 =D> =D> =D>

Greg H.
Title: Re: Saratoga Base-USA updated index.php maps
Post by: Silversword on June 11, 2020, 06:50:49 PM
Hi All,

Is this an issue with the Settings.php on about line 133 that shows:

$SITE['timeOnlyFormat'] = 'g:ia';          // USA format h:mm[am|pm\

Should the last "\" be a "]" without the quotes?

Had some time to do some catching up with updates.

Aloha,

--Stan Y.
   Maui, Hawaii
 
Title: Re: Saratoga Base-USA updated index.php maps
Post by: saratogaWX on June 11, 2020, 11:33:06 PM
Hi Stan,
Yes, it should be a ] but... it's in a comment (after a // ) so it doesn't matter to the code at all, only to us humans :)
Title: Re: Saratoga Base-USA updated index.php maps
Post by: Jasiu on June 12, 2020, 08:12:49 AM
so it doesn't matter to the code at all, only to us humans :)

 [ You are not allowed to view attachments ]
Title: Re: Saratoga Base-USA updated index.php maps
Post by: ed2kayak on June 14, 2020, 08:04:30 PM
Thanks Ken.
Basic setting work fine, I'll investigate custom settings later.
You make it easy. [tup]
Title: Re: Saratoga Base-USA updated index.php maps
Post by: floodcaster on June 16, 2020, 01:49:46 PM
Many thanks for the update on this Ken! And a reminder that Ken does have a PayPal donate link on his scripts page. Just sayin'   ;)
Title: Re: Saratoga Base-USA updated index.php maps
Post by: Bill714 on June 17, 2020, 12:52:12 PM
Ok need some help. I installed this and now all I get is a blue screen, can someone help  www.fallriverweather.com
Title: Re: Saratoga Base-USA updated index.php maps
Post by: saratogaWX on June 17, 2020, 01:40:59 PM
You seem to have a lot of scripts that need updates http://www.fallriverweather.com/check-fetch-times.php?show=versions

Your page(s) seem to stop generation just after the
Quote
<!-- end of top -->
</head>
<body>
are emitted.
In a wx...php page that corresponds to
Code: [Select]
include("top.php");
############################################################################
?>
</head>
<body>
<?php
############################################################################
include("header.php");
############################################################################
include("menubar.php");
############################################################################
?>

Since the first HTML emitted by header.php should be
Code: [Select]
<div id="page"><!-- page wrapper -->
<!-- header -->
    <div id="header">
the header is not even getting that far before fatal exit (leaving you with a blue screen).

The php code above that in header.php has
Code: [Select]
// add support for noCron=true fetch of nws-alerts to get current alerts
    if(isset($SITE['NWSalertsCodes']) and count($SITE['NWSalertsCodes']) > 0) {
        include_once("nws-alerts-config.php"); // load the configuration for nws-alerts
        if(isset($noCron) and $noCron) {
            print "<!-- nws-alerts noCron=true .. running nws-alerts.php inline -->\n";
            include_once("nws-alerts.php");
        }
    }

Looking at the show=versions reveals
Quote
USA   nws-all-zones-inc.php   File not installed   V1.01 - 2019-11-08      nws-all-zones-inc.php file not found.
so the missing nws-all-zones-inc.php file is likely the cause of the blue screen.  Upload that file and your site should run again.
Title: Re: Saratoga Base-USA updated index.php maps
Post by: Bill714 on June 17, 2020, 02:08:10 PM
Nope I found the file uploaded it and the same blue screen :sad: I downloaded all the updates and I start going through them. thanks for any help
Title: Re: Saratoga Base-USA updated index.php maps
Post by: saratogaWX on June 17, 2020, 03:06:44 PM
I think the problem is in your nws-alerts-config.php file.. copy that to a .txt and post it please.

I see the same failure to load when using check-fetch-times.php?show=info .. it seems to stop when trying to include_once() that file, so there's likely a PHP syntax error in it causing all PHP to stop loading.  You can also check the error_log for your site for PHP error messages.

Also, you should be able to use nws-alerts-config.php?sce=view to show the source, and since that fails, it means a syntax error in the file is preventing the full loading of it.
Title: Re: Saratoga Base-USA updated index.php maps
Post by: Bill714 on June 17, 2020, 03:23:11 PM
Hi Ken thanks for your help, here the file. I look for any PHP error messages


Code: [Select]
<?php 
/*################################

 NWS Public Weather Alerts
 
 Settings for nws-alerts

*/################################
// Version: 1.02  03-Aug-2016 - Add and modify switches for nws-alerts V1.37 base

$Version "nws-alerts-config.php - V1.02 - 03-Aug-2016"

// *** denotes settings are overridden by the Settings.php file if using Saratoga Base-USA template set

// ZONE CODES & COUNTY CODES CAN BE FOUND AT https://alerts.weather.gov/
// LOCATION|Z CODE|C CODE
// Note: this array will be overridden by the Settings.php $SITE['NWSalertsCodes'] entry if using the Saratoga Base-USA template set

$myZC = array("Bristol|MAC005l|MAZ020

); 


## MAIN SETTINGS
// time zone
$ourTZ         = 'America/NewYork';        // *** Time Zone     http://www.php.net/manual/en/timezones.america.php

// folders
$cacheFileDir  = './cache/';                // *** default cache file directory
$icons_folder  = './alert-images';          // folder that contains the icons. No slash on end

// file names
$cacheFileName = 'nws-alertsMainData.php';  // main data cache file name
$aboxFileName  = 'nws-alertsBoxData.php';   // alert box cache file name
$iconFileName  = 'nws-alertsIconData.php';  // big icons cache file
$alertURL      = 'wxnws-details.php';       // web page file name for complete details - Used with Saratoga Base USA template
$summaryURL    = 'wxadvisory.php';       // web page for the alert summary - Used with Saratoga Base USA template
//
$alertURL      = 'nws-details.php';       // web page file name for complete details - Used for standard web pages
//
$summaryURL    = 'nws-summary.php';       // web page for the alert summary - Used for standard web pages

## GENERAL SETTINGS
$noCron        = false;                     // true=not using cron, update data when cache file expires   false=use cron to update data
$updateTime    = 600;                       // IF $noCron=true - time span in seconds to retain cache file before updating
$floodType     = true;                      // true=add prefix 'Areal' or 'River' to Flood alert title   false=no prefix to Flood alert
$noAlertText   = 'No Warnings, Watches, or Advisories';  // Text to display for no alerts.

## ALERT LOGGING
$logAlerts     = true;         // true=log alerts    false=don't log alerts
$log_folder    = './alertlog'; // folder that contains the log files. No slash on end

## ALERT BOX SETTINGS
$useAlertBox   = true;         // true=use alert box & write data file   false= not using alert box & don't write file
$titleNewline  = true;         // true=new line for each title   false=string titles with other titles
$aBox_Width    = '99%';        // width of box  examples - $aBox_Width = '80%';  $aBox_Width = '850px';
$centerText    = true;         // true=center text in alert box    false=left align text
$showNone      = true;         // true=show 'NONE' if no alerts in alert box   false=don't show alert box if no alerts
$locSort       = 1;            // location name sort - use number listed below
//                                0 = sort location as listed in 
$myZC array
//                                1 = sort location alphabetically

$sortbyEvent   = 3;            // sort titles by severity in alert box & then by number listed below
//                                0 = location - duplicate events will be displayed
//                                1 = location - duplicate events removed
//                                2 = event - duplicate events will be displayed
//                                3 = event - duplicate events removed


## BIG ICONS
$iconLimit     = 0;            // the number of icons to display  0=show all
$addNone       = false;        // true=add NONE foreach location with no alerts        false= don't show any NONE
$shoNone       = true;         // true=show one 'NONE' if no alerts for all location   false=don't show one 'NONE' if no alerts for all location
$useIcons      = 3;            // select number below
//                                0 = don't use icons - the cache file will not be written
//                                1 = sort by alert - duplicate events will be displayed
//                                2 = sort by alert - duplicate events removed
//                                3 = single top alert icon for each location
//                                4 = sort by location - duplicate removed
//                                5 = sort by location - duplicate events will be displayed


## XML PAGE
$useXML   = false;                          // true=create XML RSS feed   false=not using RSS feed
$rssTitle = 'Area Weather Alerts';          // title for the RSS/XML page 


## GOOGLE MAP
$googleAPI  = '-replace-this-with-your-API-key-here-';  // *** your Google API key
$zoomLevel  = '7';            // default zoom level
$displaymap = '1';            // map display on details page
//                               0 = do not display map
//                               1 = display map only when polygon coordinates are provided in alert
$mapStyle   = '3';            // google map style
//                               1 = ROADMAP displays the normal, default 2D tiles of Google Maps.
//                               2 = SATELLITE displays photographic tiles.
//                               3 = HYBRID displays a mix of photographic tiles and a tile layer for prominent features (roads, city names).
//                               4 = TERRAIN displays physical relief tiles for displaying elevation and water features (mountains, rivers, etc.).

###   END OF SETTINGS   ###

// self downloader code
if (isset(
$_REQUEST['sce']) && ( strtolower($_REQUEST['sce']) == 'view' or
   strtolower(
$_REQUEST['sce']) == 'show') ) {
   //--self downloader --
   
$filenameReal = __FILE__;
   
$download_size = filesize($filenameReal);
   header('Pragma: public');
   header('Cache-Control: private');
   header('Cache-Control: no-cache, must-revalidate');
   header("
Content-typetext/plain");
   header("
Accept-Rangesbytes");
   header("
Content-Length$download_size");
   header('Connection: close');
   readfile(
$filenameReal);
   exit;

?>
Title: Re: Saratoga Base-USA updated index.php maps
Post by: saratogaWX on June 17, 2020, 03:43:06 PM
The syntax error is this line
Code: [Select]
$myZC = array("Bristol|MAC005l|MAZ020
it's missing the closing double-quote mark
Code: [Select]
$myZC = array("Bristol|MAC005l|MAZ020"
Keep in mind that with the template, you don't have to modify the nws-alerts-config.php file.. it can be configured in Settings.php with
Code: [Select]
$SITE['NWSalertsCodes'] = array(
  "Santa Clara Valley|CAZ513|CAC085",
//  "Santa Cruz Mtns|CAZ512|CAC081|CAC085|CAC087",
  "Santa Cruz|CAZ529|CAC087",
//  "Monterey|CAZ530|CAC053",
//  "South/East Bay|CAZ508|CAC081",
//  "San Mateo Coast|CAZ509|CAC081",
//  "San Francisco|CAZ006|CAC075"
);
which will OVERRIDE anything you have in nws-alerts-config.php.  Fix the nws-alerts-config.php file as per above and change your Settings.php file to
Code: [Select]
$SITE['NWSalertsCodes'] = array(
 "Bristol|MAC005l|MAZ020",
);
Title: Re: Saratoga Base-USA updated index.php maps
Post by: Bill714 on June 17, 2020, 03:59:16 PM
Thank you Ken that got the site back up but it looks like I missing the alt dashboard add on. Could it be because I have the AltAjaxDashboardConfig6.php and the ajax-dashboard.php  loaded up at the same site
Title: Re: Saratoga Base-USA updated index.php maps
Post by: saratogaWX on June 17, 2020, 04:24:34 PM
Using the alternative dashboard should be done by changing Settings-weather.php from
Code: [Select]
$SITE['ajaxDashboard'] = './ajax-dashboard.php'; to
Code: [Select]
$SITE['ajaxDashboard'] = './ajax-dashboard6.php';then upload the ajax-dashboard.php from the distribution (so the version checker can remain 'happy').

Change your index.php from
Code: [Select]
<?php include_once("ajax-dashboard.php"); ?> to
Code: [Select]
<?php if(isset($SITE['ajaxDashboard']) and file_exists($SITE['ajaxDashboard']))
 { include_once($SITE['ajaxDashboard']);
   } else {
print "<p>&nbsp;</p>\n";
print "<p>&nbsp;</p>\n";
print "<p>Note: ajax-dashboard not included since weather station not yet specified.</p>\n";
        for (
$i=0;$i<5;$i++) { print "<p>&nbsp;</p>\n"; }
}?>

Title: Re: Saratoga Base-USA updated index.php maps
Post by: saratogaWX on June 17, 2020, 04:39:46 PM
Also, you need to upload thermometer-blank.png and thermometer-blank-black.png to your document root so the thermometer.php will work correctly.
Title: Re: Saratoga Base-USA updated index.php maps
Post by: Johnmac on June 24, 2020, 11:36:23 AM
I've added the NWS Regional Radar animated images to replace the (now, non-functioning) Weather Underground Regional Radar images on the homepage just above the ajax-dashboard display. 

A new script (USA-regional-maps-inc.php) now generates the table containing the two images (left=NWS Regional Radar, right=WU Regional IR Satellite).  It will honor custom graphic display for the left or right image with optional links to detailed pages if you'd prefer to use your own stuff instead of the NWS and/or WU images (like a webcam image or Blitzortung Lightning display).  See the README file for more information.

Be careful in the installation, as an updated wxindex.php and Settings.php are included.  There's a README file also on how to do MANUAL installation if you'd rather -- the new entries for Settings.php and the change to (wx)index.php are detailed there.
Just upload the new USA-regional-maps-inc.php and you'll be set after a manual installation.

Update from the update tool (https://saratoga-weather.org/wxtemplates/updates.php) with query Base-USA, Plugin-*, 10-Jun-2020

Attached is the README file for more info...

I am attempting to make this update and everything seems to be working OK, but I want to change my RightMap to my webcam. This is what I had before - "<img src="./webcam/image.jpg" alt="Skycam" width="335" height="240" style="margin: 0px; padding: 0px; border: none;"/>" Not sure what file to put the Site[rightmap] instruction in and what it should look like. Does it go in setings.php or elsewhere?
Title: Re: Saratoga Base-USA updated index.php maps
Post by: saratogaWX on June 24, 2020, 12:51:15 PM
I'd suggest adding to Settings.php
Code: [Select]
$SITE['rightMap'] = 'Skycam|./webcam/image.jpg||';
If you have an additional page on your site to display the webcam, then you can have a link added like
Code: [Select]
$SITE['rightMap'] = 'Skycam|./webcam/image.jpg|skycam.php|'; (assuming skycam.php is the page)

You can test out your selection display by just browsing to USA-regional-maps-inc.php on your site and you'll see the two images.
Title: Re: Saratoga Base-USA updated index.php maps
Post by: Johnmac on June 25, 2020, 05:34:50 AM
I'd suggest adding to Settings.php
Code: [Select]
$SITE['rightMap'] = 'Skycam|./webcam/image.jpg||';
If you have an additional page on your site to display the webcam, then you can have a link added like
Code: [Select]
$SITE['rightMap'] = 'Skycam|./webcam/image.jpg|skycam.php|'; (assuming skycam.php is the page)

That worked fine - Thanks for the help

John

You can test out your selection display by just browsing to USA-regional-maps-inc.php on your site and you'll see the two images.

Title: Re: Saratoga Base-USA updated index.php maps
Post by: miraculon on August 10, 2020, 08:22:24 AM
I think that when I applied some general updates, this special NWS radar depiction was lost. My main page has now reverted to the old June 2 radar and a Feb 18 (? hard to see) satellite image.

I can apply the same fix from here (https://www.wxforum.net/index.php?topic=39647), but I was wondering if there was a recent update that I missed.

I probably won't be able to get to this for a while, so I put something in my announcement to use the side Nav bar Radar links.

Not sure why this reverted to the old maps...

Greg H.
Title: Re: Saratoga Base-USA updated index.php maps
Post by: saratogaWX on August 10, 2020, 12:15:00 PM
The fix was available June 10, 2020 (discussed here (https://www.wxforum.net/index.php?topic=39688.msg407710;topicseen#msg407710).  The readme attached to the first post (and included in the update) shows the changes needed to your index.php ..
hope this helps...
Title: Re: Saratoga Base-USA updated index.php maps
Post by: miraculon on August 10, 2020, 02:03:25 PM
Thanks, Ken. I forgot about using wxindex.php instead of the default index.php. The wxindex.php is working fine.

I think that I copied the wxindex.php over to index.php the last time back in June when this first cropped up.

I could do that again, but maybe a redirect would be better for the future...  :-k

Greg H.
Title: Re: Saratoga Base-USA updated index.php maps
Post by: saratogaWX on August 10, 2020, 02:16:01 PM
I'd just copy wxindex.php to index.php and be done.  I never update index.php with the automated updates.  The wx...php scripts may be updated as auxiliary scripts are updated, so it's safer to have your site 'home' to index.php.
Title: Re: Saratoga Base-USA updated index.php maps
Post by: miraculon on August 10, 2020, 02:45:12 PM
I did both, belts and suspenders.

The redirect is working fine, so I will leave it for now. I have the corrected index.php there if needed as a backup.

Greg H.
Title: Re: Saratoga Base-USA updated index.php maps
Post by: mldenison on September 13, 2020, 11:56:43 AM
Hi Ken,

I'm not sure how/if the radar images can be resized.

Here's my site: https://www.m82a1.us/index.php#header (https://www.m82a1.us/index.php#header)

I'd like to make the right WU map larger to fill the frame.

Is it possible?

Thanks
Title: Re: Saratoga Base-USA updated index.php maps
Post by: saratogaWX on September 13, 2020, 05:32:07 PM
In USA-regional-maps-inc.php, change
Code: [Select]
    <img src="<?php echo $rightURL?>" alt="<?php echo $rightTitle?>" title="<?php echo $rightTitle?>"
      width="320" height="240" style="margin: 0px; padding: 0px; border: none"
to adjust the width= and height= values to make the displayed image larger.
Since the NWS Radar has a different aspect ratio than the WU Satellite map, you won't be able to make them the same height, but you can make the image larger (remember to preserve aspect ratio so it doesn't get distorted).

Try using width="480" and removing the height="240" .. that seems to work.
Title: Re: Saratoga Base-USA updated index.php maps
Post by: mldenison on September 13, 2020, 05:59:20 PM
Perfect.  And thanks.