Author Topic: question about my weather sticker in my sig  (Read 1920 times)

0 Members and 1 Guest are viewing this topic.

Offline Fox_Of_The_Wind

  • Forecaster
  • *****
  • Posts: 483
  • Hi there!
    • http://www.desotowiwx.com
question about my weather sticker in my sig
« on: May 28, 2017, 08:20:39 AM »
I see my weather sticker in my siq is not updating the weather warnings anymore. Does any one out there still use the weather sticker with warnings? I know the script that it is useing is to old but I am unable to fig out how to get it to work again.

Anthony

Offline hymrog

  • Senior Member
  • **
  • Posts: 52
    • Gahanna Weather
Re: question about my weather sticker in my sig
« Reply #1 on: June 04, 2017, 10:59:30 AM »
Hey -

Starting on line 49 try adding the following code to your wxgrahic.php page.  The basic code remains the same with exception of the changes for allowing curl.

Code: [Select]
//get adisory information



if ( ! isset($_REQUEST['warnzone']) )
        $_REQUEST['warnzone']="YOUR WARN ZONE";
if ( ! isset($_REQUEST['warncounty']) )
        $_REQUEST['warncounty']="YOUR COUNTY ZONE";
if ( ! isset($_REQUEST['warnlocal']) )
        $_REQUEST['warnlocal']="City+State";

//You can pass data to this script with:
// http://www.carterlake.org/testadvisory.php?warnzone=XXXXXX&warncounty=XXXXXX&warnlocal=YOURCITYNAME
//Where the zone is your zone and the county is your county and location is your location
//using pluses in place of spaces

$warnzone = $_REQUEST['warnzone'];
$warncounty = $_REQUEST['warncounty'];
$warnlocal = $_REQUEST['warnlocal'];

$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($curl, CURLOPT_URL, "http://forecast.weather.gov/showsigwx.php?warnzone=${warnzone}&warncounty=${warncounty}");
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, true);

$html = curl_exec($curl);
curl_close ($curl);


//import NOAA Advisory info
//data can be altered by changing the zone and county numbers
//Target data ends up in $targetwarn and $targettext[0]

//$html = implode('', file("http://www.crh.noaa.gov/showsigwx.php?warnzone=${warnzone}&warncounty=${warncounty}"));

//Get the advisory headers and put them in an array

preg_match_all('|<h3>(.*)</h3>|', $html, $headers);
$warnheaders = $headers[1];

//Get the advisory text and put them into an array as well

preg_match_all('|<pre>(.*)</pre>|Uis', $html, $headers);
$warntext = $headers[1];

//If there is more than one advisory, we need to set its priority

if (count($warnheaders) >= 1) {

$i = 0;
$flag = 0;

//First, around here tornados are the biggest danger. A warning is critical information.
//Display this one first no matter what!

while ($i < count($warnheaders)):
if (preg_match("/Tornado Warning/i", $warnheaders[$i])) { 
$targetwarn = $warnheaders[$i];
$targettext = $warntext[$i];
$targettext = explode("$$",$targettext);
$flag = 1;
break;
}
$i++;
endwhile;

//Next if there are none of the above found. Display the first warning message.

if ($flag == 0) {
$i = 0;
while ($i < count($warnheaders)):
if (preg_match("/Warning/i", $warnheaders[$i])) { 
$targetwarn = $warnheaders[$i];
$targettext = $warntext[$i];
$targettext = explode("$$",$targettext);
$flag = 1;
break;
}
$i++;
endwhile;
}

//Next if there are none of the above found. Display the first watch message.

if ($flag == 0) {
$i = 0;
while ($i < count($warnheaders)):
if (preg_match("/Watch/i", $warnheaders[$i])) { 
$targetwarn = $warnheaders[$i];
$targettext = $warntext[$i];
$targettext = explode("$$",$targettext);
$flag = 1;
break;
}
$i++;
endwhile;
}

//Next if there are none of the above found. Display the first advisory message.

if ($flag == 0) {
$i = 0;
while ($i < count($warnheaders)):
if (preg_match("/Advisory/i", $warnheaders[$i])) { 
$targetwarn = $warnheaders[$i];
$targettext = $warntext[$i];
$targettext = explode("$$",$targettext);
$flag = 1;
break;
}
$i++;
endwhile;
}

//Next if there are none of the above found. Display the first statement message.

if ($flag == 0) {
$i = 0;
while ($i < count($warnheaders)):
if (preg_match("/Statement/i", $warnheaders[$i])) { 
$targetwarn = $warnheaders[$i];
$targettext = $warntext[$i];
$targettext = explode("$$",$targettext);
$flag = 1;
break;
}
$i++;
endwhile;
}

//Next if there are none of the above found. Set the advisory to default message.

if ($targetwarn == "Hazardous Weather Outlook") {
$targetwarn = "NO CURRENT ADVISORIES";
$targettext[0] = "THERE ARE NO ACTIVE WATCHES, WARNINGS OR ADVISORIES";
} else if ($targetwarn == "No Active Hazardous Weather Conditions Found") {
$targetwarn = "NO CURRENT ADVISORIES";
$targettext[0] = "THERE ARE NO ACTIVE WATCHES, WARNINGS OR ADVISORIES";
} else if (empty($targetwarn)) {
$targetwarn = "NO CURRENT ADVISORIES";
$targettext[0] = "THERE ARE NO ACTIVE WATCHES, WARNINGS OR ADVISORIES";
} else if ($targetwarn == "Short Term Forecast") {
$targetwarn = "NO CURRENT ADVISORIES";
$targettext[0] = "THERE ARE NO ACTIVE WATCHES, WARNINGS OR ADVISORIES";
}

if ($targetwarn <> "NO CURRENT ADVISORIES") {

$warnlist = 'ALL CURRENT ADVISORIES:';

for ($i = 0; $i <= count($warnheaders); $i++) {
    $warnheaderplus = preg_replace( '| |', '+', $warnheaders[$i] );
    $warnlist = $warnlist . '<br><a href="http://www.crh.noaa.gov/showsigwx.php?warnzone=' . $warnzone. '&warncounty=' . $warncounty . '&local_place1=' . $warnlocal . '&product1=' . $warnheaderplus . '" target="_new">' . $warnheaders[$i] . '</a>';
}
}

}

Hope this helps

Greg

Offline Fox_Of_The_Wind

  • Forecaster
  • *****
  • Posts: 483
  • Hi there!
    • http://www.desotowiwx.com
Re: question about my weather sticker in my sig
« Reply #2 on: June 04, 2017, 01:18:08 PM »
I believe that did help. I will not know for sure till we get a warning again (or a watch)

thank you!

Anthony

Offline hymrog

  • Senior Member
  • **
  • Posts: 52
    • Gahanna Weather
Re: question about my weather sticker in my sig
« Reply #3 on: June 05, 2017, 07:58:41 AM »
Hello

You can go out to the NWS site https://alerts.weather.gov which will give a list of states, zone and county codes.  Click on a state or use the map on the NWS site and substitute an active alert in your script to test. 

For example at the time of this post, Boone county in Missouri has an active dense fog advisory.  So to test the warnzone would be MOZ041  warncounty would be MOC019 and the local_place1 would be Boone.

example:

Code: [Select]
if ( ! isset($_REQUEST['warnzone']) )
$_REQUEST['warnzone']="MOZ041";
if ( ! isset($_REQUEST['warncounty']) )
$_REQUEST['warncounty']="MOC019";
if ( ! isset($_REQUEST['local_place1']) )
$_REQUEST['local_place1']="Boone";



Greg

Offline Fox_Of_The_Wind

  • Forecaster
  • *****
  • Posts: 483
  • Hi there!
    • http://www.desotowiwx.com
Re: question about my weather sticker in my sig
« Reply #4 on: June 06, 2017, 08:20:13 PM »
Smart. That worked. Thanks!

Anthony

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: question about my weather sticker in my sig
« Reply #5 on: June 27, 2017, 11:56:55 PM »
Cant get mine to work.
« Last Edit: June 28, 2017, 12:17:37 PM by cospringswx »




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: question about my weather sticker in my sig
« Reply #6 on: June 29, 2017, 10:22:57 PM »
Does anyone know. I have attached my wxgraphic and config file.




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline hymrog

  • Senior Member
  • **
  • Posts: 52
    • Gahanna Weather
Re: question about my weather sticker in my sig
« Reply #7 on: June 30, 2017, 07:53:09 AM »
Hi -

Have you checked to see if you have cURL enabled for you website?  If you have not already done so, use the following code:

Code: [Select]
<?php  phpinfo() ; ?>
and save the file using something like phpinfo.php. Go to your website http://www.cospringsweather.com/phpinfo.php and from there you can see if cURL is enabled.

I did look at your attachments and all looks good.

Hope this helps

Greg

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: question about my weather sticker in my sig
« Reply #8 on: June 30, 2017, 12:10:39 PM »
Thanks for the response. I'll give it a try this afternoon.




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: question about my weather sticker in my sig
« Reply #9 on: June 30, 2017, 08:23:39 PM »
cURL is enabled and its not working.




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline hymrog

  • Senior Member
  • **
  • Posts: 52
    • Gahanna Weather
Re: question about my weather sticker in my sig
« Reply #10 on: June 30, 2017, 10:45:58 PM »
Hi -

Good to hear cURL is enabled -  Try this

change:

Code: [Select]
if ( ! isset($_REQUEST['warnzone']) )
        $_REQUEST['warnzone']="COZ085";
if ( ! isset($_REQUEST['warncounty']) )
        $_REQUEST['warncounty']="COCO41";
if ( ! isset($_REQUEST['warnlocal']) )
        $_REQUEST['warnlocal']="COLORADO SPRINGS, CO";

to:

Code: [Select]
if ( ! isset($_REQUEST['warnzone']) )
        $_REQUEST['warnzone']="COZ085";
if ( ! isset($_REQUEST['warncounty']) )
        $_REQUEST['warncounty']="COC041";
if ( ! isset($_REQUEST['warnlocal']) )
        $_REQUEST['warnlocal']="Colorado+Springs+CO";

This should do the trick

Greg

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: question about my weather sticker in my sig
« Reply #11 on: July 06, 2017, 09:42:10 PM »
  UU    Thanks.      UU
« Last Edit: July 06, 2017, 10:01:27 PM by cospringswx »




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline mldenison

  • Contributor
  • ***
  • Posts: 111
    • York, PA Weather
Re: question about my weather sticker in my sig
« Reply #12 on: July 06, 2017, 11:13:04 PM »
Hello folks,

I'm in the middle of setting up wxgraphic.  It's supposed to be v6.3 but doesn't have the code in it for the warnings.  Can someone point me to a complete downloadable package with the warnings built into it?

With the version I'm running, the displayed weather icon is not transparent and I'm not sure why.  I've tried an icon that has a transparent background, but the background is either white or black.  There's some RGB values but only 0,0,0 or 255.255.255 toggle the background.  Any other value has no color effect.

Also, the icon always shows sunny no matter the actual sky condition, using Weather Display.

I think I found the issue.  I've been unable to get the wxgraphic program to display the correct icon from the clientraw.txt file.  It uses element 48 (the icon type record) to choose the correct icon to display.  Here's a partial code snippet:

Code: [Select]
   // CURRENT CONDITIONS ICONS FOR clientraw.txt
   // create array for icons. There are 35 possible values in clientraw.txt
   // It would be simpler to do this with array() but to make it easier to
   // modify each element is defined individually. Each index [#] corresponds
   // to the value provided in clientraw.txt
   $icon_array[0] = "./icons/day_clear.$image_format";            // imagesunny.visible
   $icon_array[1] = "./icons/night_clear.$image_format";          // imageclearnight.visible
   $icon_array[2] = "./icons/day_partly_cloudy.$image_format";    // imagecloudy.visible
   $icon_array[3] = "./icons/day_partly_cloudy.$image_format";    // imagecloudy2.visible
   $icon_array[4] = "./icons/night_partly_cloudy.$image_format";  // imagecloudynight.visible

Currently, that element displays '4 (Cloudy Night)'.  I believe the code is expecting just a '4', so it's displaying the default 'Sunny' icon always since there's a number followed by text in that field.

Except right now it's displaying a cloud symbol with the icon type record containing '13 (Night Overcast)'. Weird.

Any comments or help is appreciated!

Mort
« Last Edit: July 06, 2017, 11:19:24 PM by mldenison »
Windows 7 x64
Weather PC: Intel NUC
Davis Vantage Pro 2
Weather Underground: KPAYORK30
York, PA Weather (Saratoga)
York, PA Weather (Leuven)
York, PA PWS Station

Offline mldenison

  • Contributor
  • ***
  • Posts: 111
    • York, PA Weather
Re: question about my weather sticker in my sig
« Reply #13 on: July 07, 2017, 12:24:56 PM »
Never mind - I found the files, added the severe weather part, and replaced the icon with sky verbiage.
Windows 7 x64
Weather PC: Intel NUC
Davis Vantage Pro 2
Weather Underground: KPAYORK30
York, PA Weather (Saratoga)
York, PA Weather (Leuven)
York, PA PWS Station

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: question about my weather sticker in my sig
« Reply #14 on: July 07, 2017, 04:36:51 PM »
Never mind - I found the files, added the severe weather part, and replaced the icon with sky verbiage.

Nice.




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline mldenison

  • Contributor
  • ***
  • Posts: 111
    • York, PA Weather
Re: question about my weather sticker in my sig
« Reply #15 on: July 07, 2017, 04:56:43 PM »
All except the temperature.  I thought I was done.  I like your background.
Windows 7 x64
Weather PC: Intel NUC
Davis Vantage Pro 2
Weather Underground: KPAYORK30
York, PA Weather (Saratoga)
York, PA Weather (Leuven)
York, PA PWS Station

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: question about my weather sticker in my sig
« Reply #16 on: July 07, 2017, 09:43:04 PM »
All except the temperature.  I thought I was done.  I like your background.

Thanks. Whats wrong with the temp?




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline mldenison

  • Contributor
  • ***
  • Posts: 111
    • York, PA Weather
Re: question about my weather sticker in my sig
« Reply #17 on: July 07, 2017, 10:44:03 PM »
Nothing now.  A typing error in the code  :grin:
Windows 7 x64
Weather PC: Intel NUC
Davis Vantage Pro 2
Weather Underground: KPAYORK30
York, PA Weather (Saratoga)
York, PA Weather (Leuven)
York, PA PWS Station

 

anything