NWS Public Alert Messenger PHP Script

Im sure my problem is host related. But can you take a look please…

http://www.snoqualmieweather.com/rss-weather-alerter.php

Ive added a .txt file called “adv-alert-message-WAZ505.txt” Set the permissions too 666 but the file is still empty. I installed this yesterday afternoon. Thanks.

I used the login from the last time I helped you. I just looked and your PHP server has safe_mode on.
That is the reason you continually have problems like this.
I wonder if you can access the php.ini to turn safe_mode off?

I cant find that file anywhere. I’ll open a ticket with them and ask If it can be turned off. Thanks for looking Mike.

Version: 1.07 - 11-Jul-2009 - fixed another bug where the email message had the zone title added twice.

  • added feature setting: $message_resend_enabled to allow resending alert messages at pre-determined intervals
    some areas can have an active alert like a “High Wind Warning” for more than a day or two.
    This feature allows resending the active alert messages like every 12 hours or so

Great script again there. But a few questions:

  1. This is the type of twitter and phone text message it does: NWS issued: Severe Weather Statement - Cambria (Pennsylvania) for Cambria (Pennsylvania)

Is there a way to modify it in a easy way for us users to make changes to it to say to twitter something like:

NWS issued: Severe Weather Statement - For Cambria County (Pennsylvania)

this way it is not repeating after pa with cambira county again.

thanks!

What version is doing that double zone title? I thought I fixed that in version 1.07

My luck sheesh! let me grab 1.07 lol

Version: 1.06 - 10-Jul-2009

Ok 1.07 is up there now!

I’m not sure why but I cannot get it to work entirely correctly.

Of course, there’s nothing for weather now to give you an example but let me try to describe.

Yesterday for example, it was saying for the em the initial special weather advisory but would not have any other details. Ie:

Subject:
Message Body:
“Alert: Special Weather Statement”

Any thoughts? The advisory text only had “Special Weather Statement” and the rss file had all the info. My goal is to have a twitter with the advisory and pertinent advisory info

Cheers and thanks!
Mike

The script only alerts about the advisory title, it does not display the contents of the alert.
Twitters cannot be more than 140 characters. If I tried to parse the contents of the “Special Weather Statement”, it would not fit in a twitter anyway.

For this reason, my twitters have a URL on them, if they click on the URL they can see the full alert on my web site.
http://twitter.com/642weather

That is one of the drawbacks of twitter. The messages are so short #-o

I had a twitter alert this morning (there was a local thunderstorm):
NWS issued: Short Term Forecast for South Washington Coast (Washington) #fb #funbeach #weather http://642weather.com

If you need short URLs for the twitter message, you can use tinyurl.com or http://bit.ly/

I installed this without a problem - a fine piece of work as always from Mike!

One little thing I noticed… A short term forecast was issued around 3:00pm MDT in the Denver area (COZ040). This was replaced with a new short term forcast at 6:47pm MDT. The script did not send out the updated short term forecast instead saying “resend timer prevention timer is in effect” in the cron log the next time it was processed.

I am guessing this is because they both had the same title? Just want to check and make sure all is well as it should be.

Thank you as always for your work!

Tony

That is working the way I designed it Tony. If the alert title is the same, it will not resend unless the resend timer is enabled and timed out.

Message Sending Activity: (No messages sent because the advisory status did not change since the last time it was checked)

Is anybody interested in a log file feature for this script?
It could append to a log file every time there is an alert.
You could include the log file in a Advisory History page.

I was thinking something like this:





Mike,

I think a log would be really cool. Would it be a running log that showed the last “X” number of alerts or something like all alerts for a week, or month, etc. and was self maintaining?

Derek

It should be self maintaining or the log would grow continuously.
Maybe it could auto purge oldest alerts after x amount of alerts are built up.
The x amount of alerts to store could be a setting that can be changed.
Also the logging feature can be enabled or disabled with a setting.

Does this sound good?
I might not do this for a few days, I have programmed so many hours this week I feel tired.
Right now, I am working on two computers at once, and writing a seminar: Internet and Computer Safety - “How to stay clear of viruses, adware, spyware, spam, and scams when using the Internet”.

Got it - thanks, Mike. I figured as much. I will just adjust the timing in the script accordingly as our local NWS oftentimes sends out three or four short term forecasts in a row, each spanning a couple of hours.

As for a log file, that might be kind of nice. Ideally it would be like you say where it gets overwritten after a period of time.

T

Mike,

I think all that sounds great.

I don’t doubt you’re tired, with what you’ve done here over the last few days alone, not to mention all the other stuff you’re doing. We all really appreciate everything but for sure you should take a break!!!

Derek

Here is a good question!

Using the script i took notice that if you are with a hosting company with the emails going out it never goes out with the correct email information. Sample say you place in the script $email_address_sent_from = ‘[email protected]’;

So when the message comes down it shows it is from [email protected]
Now they had me edit my php.ini files to have this:
sendmail_path = /usr/sbin/sendmail -t -i -f [email protected];

And it still with go back to [email protected]. Now one thing they said that would correct that problem is if the script used SMTP Authentication This way the email that is generated by the script would have the correct sent from email address as in [email protected].

Is there an easy way of adding that?

What host is causing all this trouble? is it windows or Linux?

First, just try this code in the settings section of the script after the $email_address_sent_from:

ini_set('sendmail_from', $email_address_sent_from); // needed for some windows servers

if that did not work, try adding this:


// OPTIONAL: You can change the default SMTP settings below...
// NOTE most servers do not need these settings changed!!!
$ctf_ini_set       = "yes";        // "yes" to enable this feature (ONLY if needed)
$ctf_smtp          = "localhost"; // sometimes mail.yourdomain.com Confirm with your host
$ctf_smtp_port     = "25";        // Confirm with your host
$ctf_smtp_username = "you";       // your mail username. If you do not know, ask your host
$ctf_smtp_password = "123456";    // your mail password. If you do not know, ask your host
$ctf_sendmail_from = "[email protected]";   // Your email
$ctf_sendmail_path = "/usr/sbin/sendmail -t -i"; // If different, ask host


if(strtolower($ctf_ini_set) == "yes") {
       ini_set("SMTP", $ctf_smtp);
       ini_set("smtp_port", $ctf_smtp_port);
       ini_set("smtp_password", $ctf_smtp_password);
       ini_set("smtp_username", $ctf_smtp_username);
       ini_set("sendmail_from", $ctf_sendmail_from);
       ini_set("sendmail_path", $ctf_sendmail_path);
}
    

let me know if it worked.

they are all Linux box’s. going to try this one in this location in the script:

<?php error_reporting(E_ALL ^ E_NOTICE); // Report all errors except E_NOTICE warnings ini_set('display_errors', 1); // turn error reporting on //ini_set('log_errors', 1); // log errors //ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); // where to log errors /* NOAA Top Weather Advisory Alerter PHP Script by Mike Challis More Info - www.642weather.com/weather/scripts-noaa-top-weather-alerter.php Download - www.642weather.com/weather/scripts/noaa-top-weather-alerter.zip Live Demo - www.642weather.com/weather/rss-weather-alerter.php Free PHP Scripts - www.642weather.com/weather/scripts.php Contact Mike - www.642weather.com/weather/contact_us.php Donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2319642 // Mail Settings // OPTIONAL: You can change the default SMTP settings below... // NOTE most servers do not need these settings changed!!! $ctf_ini_set = "yes"; // "yes" to enable this feature (ONLY if needed) $ctf_smtp = "localhost"; // sometimes mail.yourdomain.com Confirm with your host $ctf_smtp_port = "25"; // Confirm with your host $ctf_smtp_username = "you"; // your mail username. If you do not know, ask your host $ctf_smtp_password = "123456"; // your mail password. If you do not know, ask your host $ctf_sendmail_from = "[email protected]"; // Your email $ctf_sendmail_path = "/usr/sbin/sendmail -t -i"; // If different, ask host if(strtolower($ctf_ini_set) == "yes") { ini_set("SMTP", $ctf_smtp); ini_set("smtp_port", $ctf_smtp_port); ini_set("smtp_password", $ctf_smtp_password); ini_set("smtp_username", $ctf_smtp_username); ini_set("sendmail_from", $ctf_sendmail_from); ini_set("sendmail_path", $ctf_sendmail_path); }