I use the following code for the fire weather discussion:
<?php
$forecasthtml = fetchUrlWithoutHanging('http://www.crh.noaa.gov/product.php?site=NWS&issuedby=OKX&product=FWF&format=CI&version=1&glossary=1&highlight=off');
$RawFile = explode("$$",$forecasthtml);
$RawChunk = explode("000",$RawFile[0]);
if ( strlen( $RawChunk[1] ) > 5 ) {
$NOAAForecast = '000' . $RawChunk[1];
} else {
$NOAAForecast = 'Regional Summary Currently not Available';
}
echo "<pre>${NOAAForecast}</pre>";
exit;
function fetchUrlWithoutHanging($url)
{
// Set maximum number of seconds (can have floating-point) to wait for feed before displaying page without feed
$numberOfSeconds=4;
// Suppress error reporting so Web site visitors are unaware if the feed fails
error_reporting(0);
// Extract resource path and domain from URL ready for fsockopen
$url = str_replace("http://","",$url);
$urlComponents = explode("/",$url);
$domain = $urlComponents[0];
$resourcePath = str_replace($domain,"",$url);
// Establish a connection
$socketConnection = fsockopen($domain, 80, $errno, $errstr, $numberOfSeconds);
if (!$socketConnection)
{
// You may wish to remove the following debugging line on a live Web site
print("<!-- Network error: $errstr ($errno) -->");
} // end if
else {
$xml = '';
fputs($socketConnection, "GET $resourcePath HTTP/1.0\r\nHost: $domain\r\n\r\n");
// Loop until end of file
while (!feof($socketConnection))
{
$xml .= fgets($socketConnection, 128);
} // end while
fclose ($socketConnection);
} // end else
return($xml);
} // end function
?>
<table align="center" width="680" border="0" cellpadding="3" cellspacing="1" style="border:solid; border-color: #000000;">
<pre>
<? echo $NOAAForecast[0]; ?>
</pre>
</table>
It works but I’m sure somebody could make a better code! You will have to find your NWS url for the local conditions, mine is the OKX region. Then the “Smokey” image is from the script found here…Fire Danger graphic by the Southwestern Weather Network
Regards,
Jack