Author Topic: New Weather Alert Program  (Read 32722 times)

0 Members and 1 Guest are viewing this topic.

Offline CNYWeather

  • Forecaster
  • *****
  • Posts: 2143
    • http://www.cnyweather.com
Re: New Weather Alert Program
« Reply #25 on: July 30, 2012, 08:25:40 PM »
Just 1 thing Curly. Trying to center the text "No Watches, Warnings or Advisories in Effect for Central New York"
within the alert box. I'm striking out so far. Changed some of the wording like I had in the SWSP Alert Program.

http://www.cnyweather.com/index2.php

Code: [Select]
// alert box conditions for NO alerts
  if($useAlertBox and empty($atData)) {                                                      // IF using alert box and no alerts
    get_scc('150');                                                                          //   set alert box backgound color and text color
    $box .= "\n<!-- nws-alerts box -->\n"
         .'<div style="width:'.$aBox_Width
         .'; border:solid thin #000; margin:0px auto 0px auto;">'."\n";
    if($showNone) {                                                                          //   IF showing "NONE', create alert box with No Alert
      $box .= ' <div style=" '.$bc.' '.$ct.' '.$tc.' '.'padding:4px 8px 4px 8px"><a href="'
           .$summaryURL.'" title=" &nbsp;View current watches or warnings" style="text-decoration:none; text-align: center; '.$tc
           .'">No Watches, Warnings or Advisories in Effect for Central New York</a></div>
</div>

text-align: center in the wrong spot?

THANKS!!
 :grin:
Tony


Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: New Weather Alert Program
« Reply #26 on: July 30, 2012, 09:04:57 PM »
To center the text in the alert box, open nws-alerts-config.php
Change  $centerText  from false to true

$centerText switches $ct to left align when false or center when true.

If you want to permanently have that the text centered for the no alerts condition, find this line:
Code: [Select]
$box .= ' <div style=" '.$bc.' '.$ct.' '.$tc.' '.'padding:4px 8px 4px 8px"><a href="'
Change it to this:
Code: [Select]
$box .= ' <div style=" '.$bc.' '.$tc.' padding:4px 8px 4px 8px; text-align: center"><a href="'
And then remove the  text-align: center;  where you inserted it after  decoration:none;
« Last Edit: July 30, 2012, 09:52:55 PM by Curly »

Offline CNYWeather

  • Forecaster
  • *****
  • Posts: 2143
    • http://www.cnyweather.com
Re: New Weather Alert Program
« Reply #27 on: July 31, 2012, 09:35:32 AM »
Perfect. Thanks Curly.

There will be no HWO or Short Term with this setup, right?
Tony


Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: New Weather Alert Program
« Reply #28 on: July 31, 2012, 09:58:46 AM »
There will be no HWO or Short Term with this setup, right?

Right.
The NWS does not include those in the CAP/ATOM feeds.
« Last Edit: July 31, 2012, 10:01:40 AM by Curly »

Offline jay_hoehn

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 655
    • Jay's Woodcrafts
Re: New Weather Alert Program
« Reply #29 on: July 31, 2012, 08:49:06 PM »
Curly,

Great work on the script.  Love the Google Maps.

Jay
Davis Vantage Pro2 Plus
VVP
Weather Display


Offline jahuff

  • Member
  • *
  • Posts: 46
    • johnsnhweather
Re: New Weather Alert Program
« Reply #30 on: July 31, 2012, 10:34:39 PM »
Hi Curly,

I have the cron job set up but it's not working correctly.

I might not have the permissions correct on the files.

Code: [Select]
PHP Warning:  fopen(./cache/nws-alertsMainData.php): failed to open stream: No such file or directory in /home/johnsnh/public_html/nws-alerts.php on line 263 PHP Warning:  fopen(./cache/nws-alertsBoxData.php): failed to open stream: No such file or directory in /home/johnsnh/public_html/nws-alerts.php on line 425 PHP Warning:  fopen(./cache/nws-alertsIconData.php): failed to open stream: No such file or directory in /home/johnsnh/public_html/nws-alerts.php on line 514 PHP Warning:  fopen(nws-rssfeed.xml): failed to open stream: Permission denied in /home/johnsnh/public_html/nws-alerts.php on line 581
<!-- nws-alerts.php - 1.13 - 29-July-2012 - NWS Public Alerts -->
<!-- Cron job enabled -->
<!-- Preliminary codes checked: 4 -->
<!-- Preliminary data cull: 0.8956 seconds -->
<!-- Average cull per code: 0.2239 seconds -->
<!-- Primary alerts downloaded: 0 -->
<!-- Primary data cull: 0.0000 seconds -->
<!-- unable to open cache file -->
<!-- unable to open cache file -->
<!-- unable to open big icon cache file -->
<!-- unable to open rss feed cache file -->
<!-- Total script process time: 0.8962 seconds --> PHP Warning:  fopen(./cache/nws-notes.txt): failed to open stream: No such file or directory in /home/johnsnh/public_html/nws-alerts.php on line 931 PHP Warning:  fputs(): supplied argument is not a valid stream resource in /home/johnsnh/public_html/nws-alerts.php on line 932 PHP Warning:  fclose(): supplied argument is not a valid stream resource in /home/johnsnh/public_html/nws-alerts.php on line 933


Obviously I'm not good with cron jobs.

Thanks,

John
« Last Edit: July 31, 2012, 10:38:02 PM by jahuff »

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: New Weather Alert Program
« Reply #31 on: July 31, 2012, 10:51:46 PM »
Quote
I have the cron job set up but it's not working correctly.

I can manually call the file without errors and all of the files update.
Did you set up a cron job in cpanel?

EDIT - There hasn't been an update in 30 minutes. What time span is the cron?
« Last Edit: July 31, 2012, 11:37:27 PM by Curly »

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: New Weather Alert Program
« Reply #32 on: July 31, 2012, 10:56:05 PM »
Quote
Great work on the script.  Love the Google Maps.

Thanks!
Ah, you have an alert with a shape file.
It can get quite colorful when there are more alerts.

Offline jahuff

  • Member
  • *
  • Posts: 46
    • johnsnhweather
Re: New Weather Alert Program
« Reply #33 on: August 01, 2012, 07:26:34 AM »
Hi Curly,

The cron job was setup in cpanel and runs every 5 minutes.

I just checked and it's running.

Thanks for getting back to me.

John

I just ran it manually also and it did run so  the problem must be with the cron job.
« Last Edit: August 01, 2012, 07:39:01 AM by jahuff »

Offline jahuff

  • Member
  • *
  • Posts: 46
    • johnsnhweather
Re: New Weather Alert Program
« Reply #34 on: August 01, 2012, 07:21:20 PM »
Hi Curly,

I might be making some progress -- I think  :shock: -- when my cron job run I get this in the cron job email.

Code: [Select]
PHP Warning:  fopen(nws-rssfeed.xml): failed to open stream: Permission denied in /home/johnsnh/public_html/nws-alerts.php on line 581
<!-- nws-alerts.php - 1.13 - 29-July-2012 - NWS Public Alerts -->
<!-- Cron job enabled -->

<!-- cURL error: Operation timed out after 2000 milliseconds with 0 bytes received -->
<!-- http://alerts.weather.gov/cap/wwaatmget.php?x=CAC085  -->
<!-- First attempt in getting preliminary URL failed -->
<!-- Second attempt successful -->
<!-- http://alerts.weather.gov/cap/wwaatmget.php?x=CAC085 -->


<!-- cURL error: Operation timed out after 2000 milliseconds with 0 bytes received -->
<!-- http://alerts.weather.gov/cap/wwaatmget.php?x=CAZ529  -->
<!-- First attempt in getting preliminary URL failed -->
<!-- Second attempt successful -->
<!-- http://alerts.weather.gov/cap/wwaatmget.php?x=CAZ529 -->

<!-- Preliminary codes checked: 4 -->
<!-- Preliminary data cull: 4.5999 seconds -->
<!-- Average cull per code: 1.15 seconds -->
<!-- Primary alerts downloaded: 0 -->
<!-- Primary data cull: 0.0000 seconds -->
<!-- Cache file updated: Wed 4:15 pm -->
<!-- Alert box data file updated -->
<!-- Icon data file updated -->
<!-- unable to open rss feed cache file -->
<!-- Total script process time: 4.6006 seconds -->

To get this far i removed the trailing / from $cacheFileDir  = './cache';                // default cache file directory

Look like I have a permission problem???

Thanks,

John
« Last Edit: August 01, 2012, 07:23:40 PM by jahuff »

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: New Weather Alert Program
« Reply #35 on: August 01, 2012, 07:43:22 PM »
Quote
PHP Warning:  fopen(nws-rssfeed.xml): failed to open stream: Permission denied in /home/johnsnh/public_html/nws-alerts.php on line 581
nws-alerts.php is denied permission to open the file and write the data.
You will have to set the permission level higher. I would set the permission level to at least 664 on nws-rssfeed.xml and also on nws-alerts.php.

Quote
<!-- cURL error: Operation timed out after 2000 milliseconds with 0 bytes received -->
<!-- http://alerts.weather.gov/cap/wwaatmget.php?x=CAC085  -->
<!-- First attempt in getting preliminary URL failed -->
<!-- Second attempt successful -->
<!-- http://alerts.weather.gov/cap/wwaatmget.php?x=CAC085 -->
This is expected.
With all of the downloading, there's a point in time when that particular file is getting updated by the NWS and the script wants it at that time. If the first attempt fails the download for a code, it will wait a half second and then will try a second time to download it again.

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: New Weather Alert Program
« Reply #36 on: August 01, 2012, 07:49:57 PM »
Quote
To get this far i removed the trailing / from $cacheFileDir  = './cache'; 
If you removed it from the nws-alerts-config.php file, it wouldn't have any affect. The Settings.php file has this setting in there and that overrides what is in the config file.

Offline jahuff

  • Member
  • *
  • Posts: 46
    • johnsnhweather
Re: New Weather Alert Program
« Reply #37 on: August 01, 2012, 09:39:52 PM »
Hi,

I set the permission level to 664 on nws-rssfeed.xml and 774 on nws-alerts.php. I still get

Code: [Select]
PHP Warning:  fopen(nws-rssfeed.xml): failed to open stream: Permission denied in /home/johnsnh/public_html/nws-alerts.php on line 581
<!-- nws-alerts.php - 1.13 - 29-July-2012 - NWS Public Alerts -->
<!-- Cron job enabled -->
<!-- Preliminary codes checked: 48 -->
<!-- Preliminary data cull: 6.4546 seconds -->
<!-- Average cull per code: 0.1345 seconds -->
<!-- Primary alerts downloaded: 0 -->
<!-- Primary data cull: 0.0000 seconds -->
<!-- Cache file updated: Wed 6:25 pm -->
<!-- Alert box data file updated -->
<!-- Icon data file updated -->
<!-- unable to open rss feed cache file -->
<!-- Total script process time: 6.4559 seconds -->

Is the cron job running to completion?  :oops: This is my first time using this type of job.

The time stamp on the server files is not updating, do they only update if the file changes?

Now when I try and run nws-alerts.php manually I get a 404 message, not sure what that is all about.

I appreciate all of your help.

Thanks,

John
« Last Edit: August 01, 2012, 09:42:11 PM by jahuff »

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: New Weather Alert Program
« Reply #38 on: August 01, 2012, 09:44:10 PM »
Hi,

I set the permission level to 664 on nws-rssfeed.xml and 774 on nws-alerts.php. I still get

Code: [Select]
PHP Warning:  fopen(nws-rssfeed.xml): failed to open stream: Permission denied in /home/johnsnh/public_html/nws-alerts.php on line 581
<!-- nws-alerts.php - 1.13 - 29-July-2012 - NWS Public Alerts -->
<!-- Cron job enabled -->
<!-- Preliminary codes checked: 48 -->
<!-- Preliminary data cull: 6.4546 seconds -->
<!-- Average cull per code: 0.1345 seconds -->
<!-- Primary alerts downloaded: 0 -->
<!-- Primary data cull: 0.0000 seconds -->
<!-- Cache file updated: Wed 6:25 pm -->
<!-- Alert box data file updated -->
<!-- Icon data file updated -->
<!-- unable to open rss feed cache file -->
<!-- Total script process time: 6.4559 seconds -->

Is the cron job running to completion?  :oops: This is my first time using this type of job.

The time stamp on the server files is not updating, do they only update if the file changes?

Now when I try and run nws-alerts.php manually I get a 404 message, not sure what that is all about.

I appreciate all of your help.

Thanks,

John

I went to manually run nws-alerts.php and got a 404.
And also the config file isn't there.
« Last Edit: August 01, 2012, 09:48:11 PM by Curly »

Offline jahuff

  • Member
  • *
  • Posts: 46
    • johnsnhweather
Re: New Weather Alert Program
« Reply #39 on: August 01, 2012, 10:03:14 PM »
Hi Curly,

The config file is in /public_html/, something has gone ape $%#@. nws-alerts.php is also in that directory.

Not sure what is going on.

John
« Last Edit: August 01, 2012, 10:11:58 PM by jahuff »

Offline jahuff

  • Member
  • *
  • Posts: 46
    • johnsnhweather
Re: New Weather Alert Program
« Reply #40 on: August 01, 2012, 10:15:18 PM »
Hi, I think I need to walk away and start fresh tomorrow.
Thanks for all your help.
John

Offline jahuff

  • Member
  • *
  • Posts: 46
    • johnsnhweather
Re: New Weather Alert Program
« Reply #41 on: August 03, 2012, 08:31:27 AM »
Hi Curly,

Thanks so much for your support, the problem was the cron job.

Everything is working perfectly, can be seen at www.johnsnhweather.com

John

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: New Weather Alert Program
« Reply #42 on: August 03, 2012, 09:29:05 AM »
Sorry to see that you had a struggle setting up the cron job.

Happy to hear that your persistence did get it working!

Offline DaculaWeather

  • It's a Jeep thing... you wouldn't understand.
  • WxElement panel
  • Forecaster
  • *****
  • Posts: 3153
  • SCCA EM #156
    • North Georgia and US Weather
Re: New Weather Alert Program
« Reply #43 on: August 03, 2012, 09:43:48 AM »
Crap... yes the Google map is nice. I HATE changing things... what a PITA.

Nice script as usually Curly, not sure how much customizing I'm going to have to do.

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: New Weather Alert Program
« Reply #44 on: August 03, 2012, 10:13:47 AM »
Crap... yes the Google map is nice. I HATE changing things... what a PITA.
The AtomFeed program was inefficient and I thought that needed a major change.
With 200 hours in developing a new program, I considered it to be a challenge instead of a PITA to make an improvement.

Quote
Nice script as usually Curly, not sure how much customizing I'm going to have to do.
Thanks!
I try to code pages so that everything is grouped together so customizing is a little easier.

Offline DaculaWeather

  • It's a Jeep thing... you wouldn't understand.
  • WxElement panel
  • Forecaster
  • *****
  • Posts: 3153
  • SCCA EM #156
    • North Georgia and US Weather
Re: New Weather Alert Program
« Reply #45 on: August 03, 2012, 10:16:24 AM »
Thanks Curly! I wasn't giving you a hard time, I know it took way more work for you than it will for me! And yes, it is ALWAYS a challenge to go modify someone else's code to work on my pages!  :grin:

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: New Weather Alert Program
« Reply #46 on: August 03, 2012, 10:44:30 AM »
Thanks Curly! I wasn't giving you a hard time, I know it took way more work for you than it will for me! And yes, it is ALWAYS a challenge to go modify someone else's code to work on my pages!  :grin:

I didn't take it that you were giving me a hard time Steve...  Just expressing that a PITA can be also be thought as a rewarding challenge.

I am guilty of changing code. My web site is a Saratoga Base-USA template but doesn't look like one.
« Last Edit: August 03, 2012, 10:49:33 AM by Curly »

Offline jahuff

  • Member
  • *
  • Posts: 46
    • johnsnhweather
Re: New Weather Alert Program
« Reply #47 on: August 05, 2012, 07:08:41 AM »
Hi Curly,

I am having a formatting issue. I have this setting -- $aBox_Width    = '692px'; --. I have attached a screenshot. What can I change to correct this.

The formatting problem only shows up in Firefox, IE works fine.

Thanks,

John

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: New Weather Alert Program
« Reply #48 on: August 05, 2012, 08:13:18 AM »
I've updated the nws-alerts.php to fix that spacing issue in the alert box.

You can download just the needed file here  http://www.weather.ricksturf.com/scripts/nws-alertsFILE.zip
After downloading, extract the file and upload it. The changes won't take affect until the next update.
You can manually update it by running    nws-alerts.php?mu=1

Offline jahuff

  • Member
  • *
  • Posts: 46
    • johnsnhweather
Re: New Weather Alert Program
« Reply #49 on: August 05, 2012, 06:48:50 PM »
Quote
I've updated the nws-alerts.php to fix that spacing issue in the alert box.

Thanks Curly,

I have downloaded and installed the new program. All is well at johnsnhweather.com.

Thanks,

John