Author Topic: New PHP Scripts for VORTEX Message And HDOB Messages  (Read 10301 times)

0 Members and 1 Guest are viewing this topic.

jwyman

  • Guest
New PHP Scripts for VORTEX Message And HDOB Messages
« on: August 22, 2007, 02:13:06 PM »
ALL,
  I have finished creating 2 PHP scripts for decoding VORTEX messages and HDOB message for hurricanes and tropical storms. Below are the links:

www.espwxctr.com/vortex.php

www.espwxctr.com/hdob.php

Enjoy!

Jim

Offline capeweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 1309
    • http://www.capeweather.com
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #1 on: August 22, 2007, 04:15:35 PM »
Nice job. Where do you download the script at though?

Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net

jwyman

  • Guest
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #2 on: August 22, 2007, 04:19:27 PM »
Cape,
  That is one thing I haven't worked out yet. I need to find a way to make them available to people..... Clues?



jim :wink:

Offline capeweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 1309
    • http://www.capeweather.com
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #3 on: August 22, 2007, 04:29:21 PM »
You could take your scripts and rename them to .txt instead of .php and provide a link. That should do the trick.  :D

Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9296
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #4 on: August 22, 2007, 04:46:05 PM »
I'd recommend you include a bit of code at the top of the script to support downloading like this
Code: [Select]
if (isset($_REQUEST['sce']) && strtolower($_REQUEST['sce']) == 'view' ) {
//--self downloader --
   $filenameReal = $_SERVER["SCRIPT_FILENAME"];
   $download_size = filesize($filenameReal);
   header('Pragma: public');
   header('Cache-Control: private');
   header('Cache-Control: no-cache, must-revalidate');
   header("Content-type: text/plain");
   header("Accept-Ranges: bytes");
   header("Content-Length: $download_size");
   header('Connection: close');
   readfile($filenameReal);
   exit;
}


Then folks can view the script (and download it) by executing the script with a ?sce=view parameter.  Makes it easy to get, and as a bonus, you never have to maintain a separate .txt file just so folks can download.

I use this with pretty much all of my scripts ;-)

BTW... nice job on the scripts!!

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

jwyman

  • Guest
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #5 on: August 22, 2007, 06:04:24 PM »
These so-called scripts I have have embeeded html to "pretty" them up on my site. So how would you suggest doing that?


Jim

Offline WeatherBeacon

  • Chief
  • Forecaster
  • *****
  • Posts: 1369
    • http://www.wxbeacon.com
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #6 on: August 22, 2007, 07:45:53 PM »
Jim:

It appears that you have a typo. Instead of

http://www.espwxctr.com/vortext.php

did you mean:

http://www.espwxctr.com/vortex.php ?

Regards,

Kevin...
Mae govannen!
Kevin  (Member AMS) http://www.wxbeacon.com               Genesee County, Michigan
Hardware:  Davis Vantage Pro Wireless, Midland WR-300
Software: VWS 14.01p43, WeatherFlash, & GRLevel3

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9296
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #7 on: August 22, 2007, 08:12:12 PM »
I'd put it at the top of the page, below the doctype and above the <html> so it looks like
Code: [Select]
<?php
if &#40;isset&#40;$_REQUEST['sce'&#93;&#41; && strtolower&#40;$_REQUEST['sce'&#93;&#41; == 'view' &#41; &#123;
//--self downloader --
   
$filenameReal $_SERVER["SCRIPT_FILENAME"&#93;;
   
$download_size filesize&#40;$filenameReal&#41;;
   
header&#40;'Pragma&#58; public'&#41;;
   
header&#40;'Cache-Control&#58; private'&#41;;
   
header&#40;'Cache-Control&#58; no-cache, must-revalidate'&#41;;
   
header&#40;"Content-type&#58; text/plain"&#41;;
   
header&#40;"Accept-Ranges&#58; bytes"&#41;;
   
header&#40;"Content-Length&#58; $download_size"&#41;;
   
header&#40;'Connection&#58; close'&#41;;
   
readfile&#40;$filenameReal&#41;;
   
exit;
&
#125;
?>


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

jwyman

  • Guest
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #8 on: August 23, 2007, 09:56:15 AM »
Ken,
  I tried your suggestions and i see all sorts of odd stuff coming across...

Errors, mixed HTMLwith PHP output..... nothing clean.....


Clues?


Jim

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9296
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #9 on: August 23, 2007, 10:19:15 AM »
Jim,
I'd move it to the first line in the file (so the <?php is the first line in the file)
 :oops:  I don't know what I was thinking by saying it should be after the doctype.. it should be the first line in the file.


Depending on your PHP installation, you may have to use
  SCRIPT_FILENAME or PATH_TRANSLATED or ORIG_PATH_TRANSLATED in the $filenameReal = $_SERVER['...']; statement to get it to work.

PHP installations vary a bit (particularly on Windoze servers).

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

jwyman

  • Guest
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #10 on: August 23, 2007, 10:23:03 AM »
Ken, I have the script with the patch you gave me. You can see for yourself what is happening..

BTW, my host is using APACHE....FYI.


Thanks,

Jim

jwyman

  • Guest
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #11 on: August 23, 2007, 10:25:59 AM »
It Worked!!!!! Thanks..

Also, how do you handle credits as such? what do you do for compensation/credits/copyright/etc?


Jim

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9296
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #12 on: August 23, 2007, 10:26:56 AM »
Jim,
It looks like it's working:
http://www.espwxctr.com/hdob.php?sce=view  shows the complete source

http://www.espwxctr.com/hdob.php  runs the page normally

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

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9296
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #13 on: August 23, 2007, 10:38:36 AM »
For my scripts, I just include a credit line in the PHP source and don't bother with copyright or GNU copyleft -- all my stuff is free.  Contributions are welcomed if script users are so moved, but are never required -- this is my hobby, not an income source for my retirement.

Your mileage may vary ;-)

Since you have started sharing your scripts, I'd suggest you establish a scripts area on your website to hold the documentation and links to download the scripts from your site.  I think it also helps to put the key documentation in the script itself (along with a back-link to the scripts page) so that the script contains enough information in comments to install and customize it.

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

jwyman

  • Guest
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #14 on: August 23, 2007, 11:51:28 AM »
Ken,
  I am having trouble with

http://www.espwxctr.com/convreport.php?sce=view

I have it set up just like the other 2 scripts...


Jim

jwyman

  • Guest
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #15 on: August 23, 2007, 01:17:48 PM »
Everyone,
  All the scripts are now available through these links. You can view and dowload them......

http://espwxctr.com/convreport.php?sce=view
http://espwxctr.com/vortex.php?sce=view
http://espwxctr.com/hdob.php?sce=view

I am having some trouble with the convreport one and I am still trying to resolve that...


Jim

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9296
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #16 on: August 23, 2007, 02:38:57 PM »
Jim,
Just make sure the first line in the file is
Code: [Select]
<?php with no blank lines before that line and no leading spaces before the <?php -- if PHP finds a blank line or leading spaces, it will output headers expecting that HTML will be following.  That's why the script complains with
Code: [Select]
Warning: Cannot modify header information - headers already sent by (output started at /home/espwxctr/www/www/convreport.php:1) in /home/espwxctr/www/www/convreport.php on line 21

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

jwyman

  • Guest
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #17 on: August 23, 2007, 02:53:29 PM »
Still the same.  Can I email you the script so you can take a look at it?

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9296
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #18 on: August 23, 2007, 06:16:39 PM »
Sure... please zip it and mail to me .. webmaster[at]saratoga-weather.org

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

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9296
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #19 on: August 24, 2007, 02:27:24 AM »
Got the script and found the issue.

Somehow the script itself was saved in UTF-8, so unseen to us there was 'stuff' in front of the <?php that looked like this (when viewed in iso-8859-1 font)
Code: [Select]
<?php

That bit of unseen stuff caused the webserver to send these headers
Code: [Select]
Date: Fri, 24 Aug 2007 06:12:00 GMT
Server: Apache/1.3.33 (Unix)
X-Powered-By: PHP/4.4.7
Keep-Alive: timeout=2, max=198
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

200 OK
so the page was sent as text/html, instead of using the text/plain headers in the script.

I opened the convreport.php with notepad, selected all and copied to the clipboard.  Closed the file, opened a new file (convreport1.php) with notepad and pasted the contents there, then uploaded the file.

Without the extra few marker bytes in the file, it now works as expected and gives the headers
Code: [Select]
Date: Fri, 24 Aug 2007 06:15:03 GMT
Server: Apache/1.3.33 (Unix)
Accept-Ranges: bytes
Cache-Control: no-cache, must-revalidate
Connection: close
Pragma: public
X-Powered-By: PHP/4.4.7
Content-Length: 34847
Content-Type: text/plain
X-Pad: avoid browser bug

200 OK
which are what the script said to use (in the header() lines).

Working version at
http://saratoga-weather.org/jwyman/convreport1.php?sce=view

Demo at
http://saratoga-weather.org/jwyman/convreport1.php

Whew, I thought I was going crazy.. sometime what you CAN'T see can make a difference in the output ;-)

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

jwyman

  • Guest
Re: New PHP Scripts for VORTEXT Message ANd HDOB Messages
« Reply #20 on: August 24, 2007, 08:49:48 AM »
Ken,
  Great Work, Thanks!  I was able to go to your site and download the script and repost it here. Now it works!  Tnanks again for all your help....


V/R,


Jim  :D