\n"; } // IF there are reports if(!$nonereported){ // Version, or page numbers preg_match_all('|
|Uis', $html, $past); // gets the NOAA versions if(isset($past[1][0])){ // IF the Versions were found in the page $pastreports = $past[1][0]; // get versions $pastreports = explode("$$",$pastreports); // split reports $pastreport = $pastreports[0]; // get whats needed $pastreport = preg_replace("/\/Uis", $html, $string); // get the report data $data = array_shift($string[0]); // remove junk $data1 = preg_replace('/(\n\d{4}\s[A|P]M)/', "@@@$1", $data); // set a marker $data1 = preg_replace('/\$\$.*/is', '', $data1); // remove $$ when && is not in the page $data1 = preg_replace('/&&.*/is', '', $data1); // remove junk $filterData = preg_split("/@@@/", $data1); // split up data at marker array_shift($filterData); // remove junk foreach($filterData as $kv) { // FOR EACH pice of data, separate it $tm = trim(strip_tags(substr($kv, 1,12))); // time $evt = trim(strip_tags(substr($kv, 13,17))); // event $cit = trim(strip_tags(substr($kv, 30,24))); // city $ll = trim(strip_tags(substr($kv, 54,14))); // lat & lon $dt = trim(strip_tags(substr($kv, 68,12))); // date $mag = trim(strip_tags(substr($kv, 80,17))); // magnitude $loc = trim(strip_tags(substr($kv, 97,19))); // location $ste = trim(strip_tags(substr($kv, 116,5))); // state $src = trim(strip_tags(substr($kv, 121,18))); // source $fixll = preg_replace("/[N|W]/", '', $ll); // remove N & W from lat & lon $fixll = preg_replace("/\s+/", ' ', $fixll); // remove multiple spaces from lat & lon $latlon = explode(' ',$fixll); // split up lat & lon $latndp = preg_replace('/\./', '', $latlon[0]); // no decimal point for latitude $lonndp = preg_replace('/\./', '', $latlon[1]); // no decimal point for longitude $timefix = preg_replace("/(\d{2})(\d{2})/", '$1:$2', $tm); // add colon to time $timefix = preg_replace("/0(\d:)/", '$1', $timefix); // remove time leading zero $ts = strtotime($timefix.' '.$dt); // convert time and date to time stamp $cit = mi_convert($cit); // convert abbreviated direction to long name $rem = ''; // set variable $ste = preg_replace('/XX/', '', $ste); // IF XX is found for state, change to blank if(preg_match("/TORNADO/", $evt)) {$evt = ''.$evt.'';} // change TORNADO text to red if(preg_match("/F\d/", $mag)) {$mag = ' - '.$mag.'';} // change TORNADO magnitude to red if(preg_match("/E\d/", $kv)) {$mag = preg_replace('/E(\d)/', 'ESTIMATED $1', $mag);} // replace abbreviated measument if(preg_match("/M\d/", $kv)) {$mag = preg_replace('/M(\d)/', 'MEASURED $1', $mag);} // replace abbreviated measument if(preg_match("/U\d/", $kv)) {$mag = preg_replace('/U(\d)/', 'UNDER $1', $mag);} // replace abbreviated measument if(preg_match("/TSTM/", $evt)) {$evt = preg_replace('/TSTM/', 'THUNDERSTORM', $evt);} // replace abbreviated measument if(preg_match("/DMG/", $evt)) {$evt = preg_replace('/DMG/', 'DAMAGE', $evt);} // replace abbreviated measument if(preg_match("/GST/", $evt)) {$evt = preg_replace('/GST/', 'GUST', $evt);} // replace abbreviated measument if(preg_match("/\n\s{11,}\W+/", $kv)) { // IF a remark is found preg_match('/\n\s{11,}\W+.*/is', $kv, $matches); // get remark $rem = trim(strip_tags($matches[0])); // trim remark $rem = preg_replace("/\s{2,}/", " ", $rem); // remove multiple spaces } if(preg_match('/ INJ /', $rem)) {$rem = preg_replace('/ INJ /', ' INJURED ', $rem);} // replace abbreviation if(preg_match('/\*\*\* .* \*\*\*/', $rem)) {$rem = preg_replace('/\*\*\* (.*) \*\*\*/', "• • • $1 • • •
\n", $rem);} // set injuries or fatalities to bold text if(preg_match('/ \d FATAL /', $rem)) {$rem = preg_replace('/ FATAL /', ' FATALITIES ', $rem);} // set plural or singular if(preg_match('/ 1 FATALITIES /', $rem)) {$rem = preg_replace('/ 1 FATALITIES /', ' 1 FATALITY ', $rem);} // set plural or singular if($ste == '' and preg_match("/GMZ/", $loc)){ // IF a marine zone is listed $loc = 'MARINE ZONE '.$loc; // add 'MARINE ZONE CODE" to the COUNTY } // create data array $lsrData["$ts$latndp$lonndp"] = array('time'=>$timefix, 'date'=>$dt, 'utime'=>$ts, 'location'=>$cit, 'county'=>$loc, 'state'=>$ste, 'event'=>$evt, 'magnitude'=>$mag, 'remark'=>$rem, 'source'=>$src, 'lat'=>$latlon[0], 'lon'=>$latlon[1], 'latlon'=>$ll, ); } $creps = count($lsrData); // count the reports ($creps == 1) ? $treport = $creps . " storm report" : $treport = $creps . " storm reports"; // set plural or singular } // End IF report is supplied // FUNCTIONS // get the data by cURL function curl_get_ws($URL) { $sn = $_SERVER['SCRIPT_NAME']; $sn = str_replace("/","",$sn); $url = str_replace("http://","",$URL); $urlComponents = explode("/",$url); $domain = $urlComponents[0]; $sourcepath = str_replace($domain,"",$url); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$URL); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $domain\r\nCache-Control: no-cache, must-revalidate\r\nCache-control: max-age=0\r\nConnection: close\r\nUser-agent: $sn loader\r\nContent-Type: text/html\r\n\r\n") ); curl_setopt($ch, CURLOPT_FAILONERROR,true); curl_setopt($ch, CURLOPT_NOBODY, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 4); (curl_exec($ch) === false) ? $wsdata = 'NOT AVAILABLE' : $wsdata = curl_exec($ch); curl_close ($ch); return $wsdata; } function mi_convert($wv) { // Abbreviated direction array $ds[0] = "/(\d{1,2})\sN /"; $ds[1] = "/(\d{1,2})\sE /"; $ds[2] = "/(\d{1,2})\sNE /"; $ds[3] = "/(\d{1,2})\sSE /"; $ds[4] = "/(\d{1,2})\sS /"; $ds[5] = "/(\d{1,2})\sSW /"; $ds[6] = "/(\d{1,2})\sW /"; $ds[7] = "/(\d{1,2})\sNW /"; $ds[8] = "/(\d{1,2})\sENE /"; $ds[9] = "/(\d{1,2})\sSSW /"; $ds[10] = "/(\d{1,2})\sNNW /"; $ds[11] = "/(\d{1,2})\sESE /"; $ds[12] = "/(\d{1,2})\sNNE /"; $ds[13] = "/(\d{1,2})\sSSE /"; $ds[14] = "/(\d{1,2})\sWSW /"; $ds[15] = "/(\d{1,2})\sWNW /"; $dl[15] = '${1}${2} MILES NORTH OF '; $dl[14] = '${1}${2} MILES EAST OF '; $dl[13] = '${1}${2} MILES NORTHEAST OF '; $dl[12] = '${1}${2} MILES SOUTHEAST OF '; $dl[11] = '${1}${2} MILES SOUTH OF '; $dl[10] = '${1}${2} MILES SOUTHWEST OF '; $dl[9] = '${1}${2} MILES WEST OF '; $dl[8] = '${1}${2} MILES NORTHWEST OF '; $dl[7] = '${1}${2} MILES EAST-NORTHEAST OF '; $dl[6] = '${1}${2} MILES SOUTH-SOUTHWEST OF '; $dl[5] = '${1}${2} MILES NORTH-NORTHWEST OF '; $dl[4] = '${1}${2} MILES EAST-SOUTHEAST OF '; $dl[3] = '${1}${2} MILES NORTH-NORTHEAST OF '; $dl[2] = '${1}${2} MILES SOUTH-SOUTHEAST OF '; $dl[1] = '${1}${2} MILES WEST-SOUTHWEST OF '; $dl[0] = '${1}${2} MILES WEST-NORTHWEST OF '; // Change abbreviation to a long name $str = preg_replace($ds, $dl, $wv); $fixedDir = $str; $str = preg_replace('/^1 MILES /', '1 MILE ', $str); return $str; } ?>
NWS Local Storm Reports |
To Select Another NWS Office Click on Map or Choose from List
'.$lv['location'].' | |||||
'.$lv['event'].' '.$lv['magnitude'].' '.$lv['remark'].' |
|||||
DATE '. $lv['date'].' |
TIME '. $lv['time'].' |
COUNTY '. $lv['county'].' |
STATE '. $lv['state'].' |
SOURCE '. $lv['source'].' |
GEOGRAPHIC '. $lv['latlon'].' |
'; } print_r($rt); // print the report tables ?>