Author Topic: Clickable NWS National Advisory Maps Legend  (Read 383 times)

0 Members and 1 Guest are viewing this topic.

Offline andro700

  • Chuck
  • Forecaster
  • *****
  • Posts: 304
Clickable NWS National Advisory Maps Legend
« on: May 05, 2020, 02:37:52 PM »
For some reason the dropdown detail alerts and the legend are not showing up on my Advisory Maps page. Any help would be great.

Quote
https://www.goblesweather.com/wxusalerts.php

I believe these are the areas of the script that control the areas in question.

Quote
$fileName = 'https://www.weather.gov/';
$html = fetchUrlWithoutHanging($fileName);

$startgrab = strpos($html, "<div id=\"wwa\">");
$finish = strpos($html, "</ul></div></div>",$startgrab);
$length = $finish-$startgrab;
$wwa = substr($html, $startgrab, $length);

Quote
<div class="center" style="padding-left:12px">
<?php echo $wwa;?> <!-- Display Current Legend -->
</ul></div></div>   <!-- Add back the terminal string we searched for in $finish -->
</div>

Thanks,
Chuck

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2306
    • SouthEast Lincoln, NE Weather
Re: Clickable NWS National Advisory Maps Legend
« Reply #1 on: May 05, 2020, 11:03:10 PM »
It's a 'Headers Already Sent' problem, I think.

Here's what shows up when you query the source of this script on my site:
https://www.gwwilkins.org/wxusalerts.php?sce=view

This is what the same request obtains on your site:
https://www.goblesweather.com/wxusalerts.php?sce=view

Ken might have to jump in here when our beleaguered host and guru gets a chance...
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 7912
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Clickable NWS National Advisory Maps Legend
« Reply #2 on: May 06, 2020, 01:05:37 AM »
Well, Gerry's script works fine on my localhost (PHP 7.4.5) and his PHP 7.3.14 but not on Chuck's PHP 7.3.16.

Gerry's Curl info is:
cURL version: 7.62.0
cURL SSL version: OpenSSL/1.0.2k
cURL libz version: 1.2.3
SSL is available
LIBZ is available
cURL protocols supported: dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp

Chuck's is:
cURL version: 7.52.1
cURL SSL version: OpenSSL/1.0.2u
cURL libz version: 1.2.8
SSL is available
LIBZ is available
cURL protocols supported: dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp

both on Linux servers (AFAIK).

I suspect that the curl request is failing for some reason on Chuck's system, but the internal get_data() function, doesn't have any reporting for error conditions.

Chuck, you'll need to post your wxusalerts.php version (renamed as wxusalerts.txt) for me to look further.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline andro700

  • Chuck
  • Forecaster
  • *****
  • Posts: 304
Re: Clickable NWS National Advisory Maps Legend
« Reply #3 on: May 06, 2020, 01:16:46 AM »
Will do Ken. When I get home I will post it and you can take a look at it when you get a chance.

Thanks,
Chuck

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 7912
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Clickable NWS National Advisory Maps Legend
« Reply #4 on: May 06, 2020, 11:09:06 AM »
You might try replacing the get_data() function with this
Code: [Select]
function get_data($url)
{
  $ch = curl_init();
  $timeout = 5;
  curl_setopt($ch, CURLOPT_USERAGENT,'AlertsFetch/1.1 (Web Application, www.gwwilkins.org)');
  curl_setopt($ch,CURLOPT_URL,$url);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't verify peer certificate
  $data = curl_exec($ch);
if (curl_error($ch) <> '') { // IF there is an error
    print "<!-- curl Error: " . curl_error($ch) . " -->\n"; //  display error notice
  }
  curl_close($ch);
  return $data;
}
  It adds a curl param to not verify the peer SSL cert (that has failed with some older GoDaddy servers), and adds a diagnostic error notice if curl had a problem.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline andro700

  • Chuck
  • Forecaster
  • *****
  • Posts: 304
Re: Clickable NWS National Advisory Maps Legend
« Reply #5 on: May 06, 2020, 11:57:16 AM »
Where is that located? I am with ICDSoft and they run Linux.

Chuck

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 7912
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Clickable NWS National Advisory Maps Legend
« Reply #6 on: May 06, 2020, 12:49:24 PM »
Ok, your wxusalerts script is very old, and uses the old fetchUrlWithoutHanging() function which was HTTP only (doesn't handle https).

The best thing to do is download a fresh copy from Gerry or use this slightly modified version of mine (with the diagnostics added).

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline andro700

  • Chuck
  • Forecaster
  • *****
  • Posts: 304
Re: Clickable NWS National Advisory Maps Legend
« Reply #7 on: May 06, 2020, 01:00:13 PM »
Thanks Ken works like a champ. Very much appreciated.

Chuck

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2306
    • SouthEast Lincoln, NE Weather
Re: Clickable NWS National Advisory Maps Legend
« Reply #8 on: May 07, 2020, 10:08:04 AM »
Thanks, Ken for the error-trapping revision.  I've incorporated your changes into the script which is now available on my site and versioned 20200507.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Silversword

  • --Stan Y.
  • Forecaster
  • *****
  • Posts: 466
    • Up Country Maui Weather
Re: Clickable NWS National Advisory Maps Legend
« Reply #9 on: May 26, 2020, 05:06:12 PM »
Hi All,

Has been awhile that I have to do some catch up with updating my scripts with my page.  Slow progress but getting there. On this note, I noticed that the current update on my site as well as others, that Hawaii map does not come up like others on CONUS and Alaska.  It seems that Hawaii Honolulu one is not working for some reason.  Either the script is not pointing to the right place or this server is down.

Hope that a solution can be found.

Aloha and be safe out there.

We are doing fine over in the isolated part of this pandemic times.

--Stan Y.
  Isolated, Maui, Hawai'i
Stan Y. - KH6HHG - Maui, Hawaii --- Blitzortung ID: 993 --- FlightRadar24 ID: F-PHOG1
Weather Display 10.37s Build 70
WDL 6.05
MS Windows 7 Pro
Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM
Davis Vantage Pro 2+ Wireless
1-Wire Lighting
Webcam: Axis 211

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2306
    • SouthEast Lincoln, NE Weather
Re: Clickable NWS National Advisory Maps Legend
« Reply #10 on: May 26, 2020, 06:47:43 PM »
You're right, Stan!  The links have changed.

Updated zips are available for the Clickable National Advisory Maps scripts.

The links for American Samoa and Guam had also changed.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Silversword

  • --Stan Y.
  • Forecaster
  • *****
  • Posts: 466
    • Up Country Maui Weather
Re: Clickable NWS National Advisory Maps Legend
« Reply #11 on: May 26, 2020, 09:27:47 PM »
Thanks Jerry for the prompt fix.  Will try to get mine up as time permits.

Aloha,

--Stan Y.
  Isolated, Maui, Hawai'i
Stan Y. - KH6HHG - Maui, Hawaii --- Blitzortung ID: 993 --- FlightRadar24 ID: F-PHOG1
Weather Display 10.37s Build 70
WDL 6.05
MS Windows 7 Pro
Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM
Davis Vantage Pro 2+ Wireless
1-Wire Lighting
Webcam: Axis 211