From 3ce891c7d31cc813da11be7d50375962329caca0 Mon Sep 17 00:00:00 2001 From: tony baldwin Date: Mon, 11 Feb 2013 05:24:21 -0500 Subject: [PATCH] fixed with Fabio's assistance --- curtemp.tgz | Bin 30720 -> 30720 bytes curtemp/curtemp.php | 41 ++--- curtemp/getweather.php | 338 +++++++++++++++++++++-------------------- curtemp/test.php | 5 + 4 files changed, 200 insertions(+), 184 deletions(-) create mode 100644 curtemp/test.php diff --git a/curtemp.tgz b/curtemp.tgz index 6d5084beb9b40eb1d839d5d7a97c512abcf2556f..36f1230e9a6389791631b7bebe228bc5a8428f3d 100644 GIT binary patch delta 4968 zcmahNT})fo8B>~qOG48Sf@8pk%eAj<{BMIB@Fk=M0u4!<|79%lF7`3L!uIv9uLHEo z2%6SS>i)u!_Bw5QnzX1((cW4qmG)3+t2U|9w3lew`mj~nsy=NG)3lv)|IfAS93k%c z{(sM(AAI3@@P+F~QY@LBN%SNV3FC{W>gY+Pl8M=5CY?y7dlJcHDx2&9GbrgQ4Yrz! zAOp~&NcFvkC&&887d>A8%lfqU~ zS&RaSu2%Lz?tG)t0LR@j{6(HP_C{q+OaVQ=TmWz*@T znYmOVi(^V>Nani7blCS%9$aWC6-k~0E5fEIfxJ{})kTmi3!AdIyIWh_7Uk_NS!y+6 zMX9#n24Vacr*aTPzjBX1$A#vPe%F_C9l>KOF7)vD2m<{lPY2lYc0p(~A^~thwV#kk7SYL} zSI()xGm@=(z$&oT!1d4*y@9U2cxsxvJFgM-a@y$J?d1zMR+q0CENI9*t6C!#jgc#f z_du~KG@Cr5h)NX#MUtuv&Y5GNlAGJtOch(Q>Pn0UoY5J8;Xn+#rZozla!hVh2Jv=9 z;06u@$^yv6bfF<^!3|DmiY3V1C9&&b zvCbUxZd_zP`rq@9#8FV5%NcNs-NB-P<#$(rK`lBlUz{|z$R4sDV zLAVQx#ABRMTIRprIBh06Hgm|JB|h*aX!*~55gOqIJdL;m=4r$U<_!8JIDJfu27L&+ zdGJ?|rlm(FXKB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* Author: Fabio Comuni * */ +require_once('addon/curtemp/getweather.php'); function curtemp_install() { register_hook('network_mod_init', 'addon/curtemp/curtemp.php', 'curtemp_network_mod_init'); @@ -22,30 +24,31 @@ function curtemp_uninstall() { } -function curtemp_network_mod_init($a,$b) { +function curtemp_network_mod_init(&$fk_app,&$b) { - if(! intval(get_pconfig(local_user(),'curtemp','curtemp_enable'))) - return; + if(! intval(get_pconfig(local_user(),'curtemp','curtemp_enable'))) + return; - $a->page['htmlhead'] .= '' . "\r\n"; + $fk_app->page['htmlhead'] .= '' . "\r\n"; - // the getweather file does all the work here - // the $rpt value is needed for location - // which getweather uses to fetch the weather data for weather and temp - $curtemp_loc = get_pconfig(local_user(), 'curtemp', 'curtemp_loc'); - $curtemp = '
-
-

'.t("Current Temp").'

'; - $curtemp .= ' - Weather:
- Temperature: '; + // the getweather file does all the work here + // the $rpt value is needed for location + // which getweather uses to fetch the weather data for weather and temp + $rpt = get_pconfig(local_user(), 'curtemp', 'curtemp_loc'); + $wxdata = GetWeather::get($rpt); + $temp = $wxdata['TEMPERATURE_STRING']; + $weather = $wxdata['WEATHER']; + $curtemp = '
+
+

'.t("Current Temp").'

'; - $curtemp .= '
'; + $curtemp .= 'Weather: "' . $weather . '"
+ Temperature: "' . $temp . '"'; + + $curtemp .= '
'; + + $fk_app->page['aside'] = $curtemp.$fk_app->page['aside']; - $a->page['aside'] = $curtemp . $a->page['aside']; } diff --git a/curtemp/getweather.php b/curtemp/getweather.php index eb8890fc..b4660b9e 100644 --- a/curtemp/getweather.php +++ b/curtemp/getweather.php @@ -28,195 +28,203 @@ Complete list of Weather stations available at http://weather.gov/data/current_obs/index.xml */ +class GetWeather { -// URL for the XML file -$xmlurl="http://www.weather.gov/data/current_obs/$rpt.xml"; + // Initialize some variables + static $itemdata; + static $itemname; + static $wxdata; -// Base url for the icons -$imgpath="http://weather.gov/weather/images/fcicons"; -// Get the icons as an array -$icons=defineIcons(); + function get($rpt) { + + // URL for the XML file + $xmlurl="http://www.weather.gov/data/current_obs/$rpt.xml"; -// Initialize some variables -$itemdata=""; -$itemname=""; -$wxdata=array(); -$data=""; -$report=""; -$icon=""; + // Base url for the icons + $imgpath="http://weather.gov/weather/images/fcicons"; -// create a new CURL resource -if($ch = curl_init()) { + + self::$itemdata=""; + self::$itemname=""; + self::$wxdata=array(); + + $icons=self::defineIcons(); + $icon=""; + $data=""; + $report=""; + + // create a new CURL resource + if($ch = curl_init()) { - // set URL and other appropriate options - curl_setopt($ch, CURLOPT_URL, $xmlurl); - curl_setopt($ch, CURLOPT_HEADER, trus); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - - // grab URL and pass it to the browser - $data=curl_exec($ch); + // set URL and other appropriate options + curl_setopt($ch, CURLOPT_URL, $xmlurl); + curl_setopt($ch, CURLOPT_HEADER, trus); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + + // grab URL and pass it to the browser + $data=curl_exec($ch); - $r=curl_getinfo($ch); //,CURLINFO_HTTP_CODE); + $r=curl_getinfo($ch); //,CURLINFO_HTTP_CODE); - // close CURL resource, and free up system resources - curl_close($ch); + // close CURL resource, and free up system resources + curl_close($ch); - // Create an XML parser - $xml_parser = xml_parser_create(); - - // Use case-folding so we are sure to find the tag in $map_array - // This will force all tags to upper case so we don't have to worry - // about matching the case of the original in our tests. - xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); - - // Assign the element starting and ending event handlers - xml_set_element_handler($xml_parser, "startElement", "endElement"); - - // Assign a function to handle character data - xml_set_character_data_handler($xml_parser, "characterData"); - - // Parse the file. This will place the data into an associative - // array assigned to the $wxdata variable - xml_parse($xml_parser,$data,true); - - // Free the parser object - xml_parser_free($xml_parser); - - // The OBSERVATION_TIME field of the returned XML will be in the - // format "Last Updated on May 18, 8:53 am CDT" - // We're going to change the format a bit. + // Create an XML parser + $xml_parser = xml_parser_create(); + + // Use case-folding so we are sure to find the tag in $map_array + // This will force all tags to upper case so we don't have to worry + // about matching the case of the original in our tests. + xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); + + // Assign the element starting and ending event handlers + xml_set_element_handler($xml_parser, array(self,"startElement"), array(self,"endElement")); + + // Assign a function to handle character data + xml_set_character_data_handler($xml_parser, array(self,"characterData")); + + // Parse the file. This will place the data into an associative + // array assigned to the self::$wxdata variable + xml_parse($xml_parser,$data,true); + + // Free the parser object + xml_parser_free($xml_parser); + + // The OBSERVATION_TIME field of the returned XML will be in the + // format "Last Updated on May 18, 8:53 am CDT" + // We're going to change the format a bit. - // Strip out the "Last Updated on " portion of the date/time - // so we can display that separately in our tabular output - $datetime=str_replace("Last Updated on ","",$wxdata['OBSERVATION_TIME']); - - // We now have the format as "May 18, 8:53 am CDT" - // Now, get the time zone. It will be everything from - // the last space character to the end of the string. - $z=strrchr($datetime," "); + // Strip out the "Last Updated on " portion of the date/time + // so we can display that separately in our tabular output + $datetime=str_replace("Last Updated on ","",self::$wxdata['OBSERVATION_TIME']); + + // We now have the format as "May 18, 8:53 am CDT" + // Now, get the time zone. It will be everything from + // the last space character to the end of the string. + $z=strrchr($datetime," "); - // Get the current year - $year=date("Y"); + // Get the current year + $year=date("Y"); - // Now, we stuff the year into the string, following the comma. - $datetime=str_replace(",",", $year",$datetime); + // Now, we stuff the year into the string, following the comma. + $datetime=str_replace(",",", $year",$datetime); - // This does leave a small potential issue where, if you get a - // report between midnight and 1 a.m. on January 1, or the server - // is in a significantly different time zone than the report it - // could be as late as 4 a.m. the year will be wrong because the - // report will be from the previous year. I suppose it would be - // possible to correct for that, but for that little bit, I'm - // not going to worry about it. + // This does leave a small potential issue where, if you get a + // report between midnight and 1 a.m. on January 1, or the server + // is in a significantly different time zone than the report it + // could be as late as 4 a.m. the year will be wrong because the + // report will be from the previous year. I suppose it would be + // possible to correct for that, but for that little bit, I'm + // not going to worry about it. - // Now, strip out the time zone - $datetime=str_replace($z,"",$datetime); + // Now, strip out the time zone + $datetime=str_replace($z,"",$datetime); - // Format the date and time the way we want it and add - // back the time zone - $datetime=date("l F j, Y g:i A",strtotime($datetime)).$z; - $wxdata['OBSERVATION_TIME']=$datetime; - - // Get the WEATHER element - $wx=trim($wxdata['WEATHER']); + // Format the date and time the way we want it and add + // back the time zone + $datetime=date("l F j, Y g:i A",strtotime($datetime)).$z; + self::$wxdata['OBSERVATION_TIME']=$datetime; + + // Get the WEATHER element + $wx=trim(self::$wxdata['WEATHER']); - // Now, get the icon to match the weather - foreach($icons as $k=>$i){ - $a=explode(" | ",$i); - if(is_numeric(array_search($wx,$a))){ - $wxdata['ICON']="$imgpath/$k.jpg"; - break; - } - } + // Now, get the icon to match the weather + foreach($icons as $k=>$i){ + $a=explode(" | ",$i); + if(is_numeric(array_search($wx,$a))){ + self::$wxdata['ICON']="$imgpath/$k.jpg"; + break; + } + } - // Replace any null elements with "Not available" - foreach(array_keys($wxdata) as $key){ - $wxdata[$key]=$wxdata[$key]=="NULL"?"Not available":$wxdata[$key]; - } + // Replace any null elements with "Not available" + foreach(array_keys(self::$wxdata) as $key){ + self::$wxdata[$key]=self::$wxdata[$key]=="NULL"?"Not available":self::$wxdata[$key]; + } - // If we got humidity - if(is_numeric($wxdata['RELATIVE_HUMIDITY'])) - // Append a percent sign - $wxdata['RELATIVE_HUMIDITY'].="%"; + // If we got humidity + if(is_numeric(self::$wxdata['RELATIVE_HUMIDITY'])) + // Append a percent sign + self::$wxdata['RELATIVE_HUMIDITY'].="%"; - // Do some formatting to make the output a little friendlier - if($wxdata['VISIBILITY_MI']=="NA") - $wxdata['VISIBILITY']="Not available"; - if($wxdata['VISIBILITY']!="Not available") - $wxdata['VISIBILITY']=(1*$wxdata['VISIBILITY_MI'])." miles"; + // Do some formatting to make the output a little friendlier + if(self::$wxdata['VISIBILITY_MI']=="NA") + self::$wxdata['VISIBILITY']="Not available"; + if(self::$wxdata['VISIBILITY']!="Not available") + self::$wxdata['VISIBILITY']=(1*self::$wxdata['VISIBILITY_MI'])." miles"; - // If we got wind data - if(is_numeric($wxdata['WIND_MPH'])){ - // We're going to output wind data as both MPH from a cardinal direction - // and as Knots from a direction in degrees + // If we got wind data + if(is_numeric(self::$wxdata['WIND_MPH'])){ + // We're going to output wind data as both MPH from a cardinal direction + // and as Knots from a direction in degrees - // Calculate the value for Knots - $wxdata['WIND_KNOTS']=$wxdata['WIND_MPH']/1.15; + // Calculate the value for Knots + self::$wxdata['WIND_KNOTS']=self::$wxdata['WIND_MPH']/1.15; - // Format the output - $wind=sprintf("From the %s at %d mph (%03.0f° at %d knots)",$wxdata['WIND_DIR'],$wxdata['WIND_MPH'],$wxdata['WIND_DEGREES'],$wxdata['WIND_KNOTS']); + // Format the output + $wind=sprintf("From the %s at %d mph (%03.0f° at %d knots)",self::$wxdata['WIND_DIR'],self::$wxdata['WIND_MPH'],self::$wxdata['WIND_DEGREES'],self::$wxdata['WIND_KNOTS']); - // If we got a value for wind gusts - if(is_numeric($wxdata['WIND_GUST_MPH']) && $wxdata['WIND_GUST_MPH']>0){ - // add it into the wind string - $wind=str_replace("mph","gusting to ".$wxdata['WIND_GUST_MPH']." mph
", $wind); - $knots=sprintf("%d",$wxdata['WIND_GUST_MPH']/1.15); - $wind=str_replace("knots","gusting to $knots knots",$wind); - } - } else { - // Otherwise, if wind is zero, we'll show "Calm" - $wind=$wxdata['WIND_MPH']=="Not available"?"Not available":"Calm"; - } // Done with wind - $wxdata['WIND_STRING']=$wind; + // If we got a value for wind gusts + if(is_numeric(self::$wxdata['WIND_GUST_MPH']) && self::$wxdata['WIND_GUST_MPH']>0){ + // add it into the wind string + $wind=str_replace("mph","gusting to ".self::$wxdata['WIND_GUST_MPH']." mph
", $wind); + $knots=sprintf("%d",self::$wxdata['WIND_GUST_MPH']/1.15); + $wind=str_replace("knots","gusting to $knots knots",$wind); + } + } else { + // Otherwise, if wind is zero, we'll show "Calm" + $wind=self::$wxdata['WIND_MPH']=="Not available"?"Not available":"Calm"; + } // Done with wind + self::$wxdata['WIND_STRING']=$wind; -} // Done getting and formatting the data + } // Done getting and formatting the data + return self::$wxdata; + } + + function startElement($parser, $name, $attrs) { + self::$itemname=$name; + self::$itemdata=""; + } -function startElement($parser, $name, $attrs) { - global $itemname,$itemdata,$wxdata; - $itemname=$name; - $itemdata=""; + function endElement($parser, $name) { + self::$wxdata[self::$itemname]=self::$itemdata; + self::$itemdata=""; + } + + function characterData($parser, $data) { + self::$itemdata.=$data; + } + + function defineIcons(){ + // See http://weather.gov/data/current_obs/weather.php for source data for this function + $retVal['bkn']="Mostly Cloudy | Mostly Cloudy with Haze | Mostly Cloudy and Breezy"; + $retVal['skc']="Fair | Clear | Fair with Haze | Clear with Haze | Fair and Breezy | Clear and Breezy"; + $retVal['few']="A Few Clouds | A Few Clouds with Haze | A Few Clouds and Breezy"; + $retVal['sct']="Partly Cloudy | Party Cloudy with Haze | Partly Cloudy and Breezy"; + $retVal['ovc']="Overcast | Overcast with Haze | Overcast and Breezy"; + $retVal['nfg']="Fog/Mist | Fog | Freezing Fog | Shallow Fog | Partial Fog | Patches of Fog | Fog in Vicinity | Freezing Fog in Vicinity | Shallow Fog in Vicinity | Partial Fog in Vicinity | Patches of Fog in Vicinity | Showers in Vicinity Fog | Light Freezing Fog | Heavy Freezing Fog"; + $retVal['smoke']="Smoke"; + $retVal['fzra']="Freezing Rain | Freezing Drizzle | Light Freezing Rain | Light Freezing Drizzle | Heavy Freezing Rain | Heavy Freezing Drizzle | Freezing Rain in Vicinity | Freezing Drizzle in Vicinity"; + $retVal['ip']="Ice Pellets | Light Ice Pellets | Heavy Ice Pellets | Ice Pellets in Vicinity | Showers Ice Pellets | Thunderstorm Ice Pellets | Ice Crystals | Hail | Small Hail/Snow Pellets | Light Small Hail/Snow Pellets | Heavy Small Hail/Snow Pellets | Showers Hail | Hail Showers"; + $retVal['mix']="Freezing Rain Snow | Light Freezing Rain Snow | Heavy Freezing Rain Snow | Freezing Drizzle Snow | Light Freezing Drizzle Snow | Heavy Freezing Drizzle Snow | Snow Freezing Rain| Light Snow Freezing Rain | Heavy Snow Freezing Rain | Snow Freezing Drizzle | Light Snow Freezing Drizzle | Heavy Snow Freezing Drizzle"; + $retVal['raip']="Rain Ice Pellets | Light Rain Ice Pellets | Heavy Rain Ice Pellets | Drizzle Ice Pellets | Light Drizzle Ice Pellets | Heavy Drizzle Ice Pellets | Ice Pellets Rain | Light Ice Pellets Rain | Heavy Ice Pellets Rain | Ice Pellets Drizzle | Light Ice Pellets Drizzle | Heavy Ice Pellets Drizzle"; + $retVal['rasn']="Rain Snow | Light Rain Snow | Heavy Rain Snow | Snow Rain | Light Snow Rain | Heavy Snow Rain | Drizzle Snow | Light Drizzle Snow | Heavy Drizzle Snow | Snow Drizzle | Light Snow Drizzle | Heavy Snow Drizzle"; + $retVal['shra']="Rain Showers | Light Rain Showers | Heavy Rain Showers | Rain Showers in Vicinity | Light Showers Rain | Heavy Showers Rain | Showers Rain | Showers Rain in Vicinity | Rain Showers Fog/Mist | Light Rain Showers Fog/Mist | Heavy Rain Showers Fog/Mist | Rain Showers in Vicinity Fog/Mist | Light Showers Rain Fog/Mist | Heavy Showers Rain Fog/Mist | Showers Rain Fog/Mist | Showers Rain in Vicinity Fog/Mist"; + $retVal['tsra']="Thunderstorm | Light Thunderstorm Rain | Heavy Thunderstorm Rain | Thunderstorm Rain Fog/Mist | Light Thunderstorm Rain Fog/Mist | Heavy Thunderstorm Rain Fog/Mist | Thunderstorm Showers in Vicinity | | Light Thunderstorm Rain Haze | Heavy Thunderstorm Rain Haze | Thunderstorm Fog | Light Thunderstorm Rain Fog | Heavy Thunderstorm Rain Fog | Thunderstorm Light Rain | Thunderstorm Heavy Rain | Thunderstorm Rain Fog/Mist | Thunderstorm Light Rain Fog/Mist | Thunderstorm Heavy Rain Fog/Mist | Thunderstorm in Vicinity Fog/Mist | Thunderstorm Showers in Vicinity | Thunderstorm in Vicinity | Thunderstorm in Vicinity Haze | Thunderstorm Haze in Vicinity | Thunderstorm Light Rain Haze | Thunderstorm Heavy Rain Haze | Thunderstorm Fog | Thunderstorm Light Rain Fog | Thunderstorm Heavy Rain Fog | Thunderstorm Hail | Light Thunderstorm Rain Hail | Heavy Thunderstorm Rain Hail | Thunderstorm Rain Hail Fog/Mist | Light Thunderstorm Rain Hail Fog/Mist | Heavy Thunderstorm Rain Hail Fog/Mist | Thunderstorm Showers in Vicinity Hail | | Light Thunderstorm Rain Hail Haze | Heavy Thunderstorm Rain Hail Haze | Thunderstorm Hail Fog | Light Thunderstorm Rain Hail Fog | Heavy Thunderstorm Rain Hail Fog | Thunderstorm Light Rain Hail | Thunderstorm Heavy Rain Hail | Thunderstorm Rain Hail Fog/Mist | Thunderstorm Light Rain Hail Fog/Mist | Thunderstorm Heavy Rain Hail Fog/Mist | Thunderstorm in Vicinity Hail Fog/Mist | Thunderstorm Showers in Vicinity Hail | Thunderstorm in Vicinity Hail | Thunderstorm in Vicinity Hail Haze | Thunderstorm Haze in Vicinity Hail | Thunderstorm Light Rain Hail Haze | Thunderstorm Heavy Rain Hail Haze | Thunderstorm Hail Fog | Thunderstorm Light Rain Hail Fog | Thunderstorm Heavy Rain Hail Fog | Thunderstorm Small Hail/Snow Pellets | Thunderstorm Rain Small Hail/Snow Pellets | Light Thunderstorm Rain Small Hail/Snow Pellets | Heavy Thunderstorm Rain Small Hail/Snow Pellets"; + $retVal['sn']="Snow | Light Snow | Heavy Snow | Snow Showers | Light Snow Showers | Heavy Snow Showers | Showers Snow | Light Showers Snow | Heavy Showers Snow | Snow Fog/Mist | Light Snow Fog/Mist | Heavy Snow Fog/Mist | Snow Showers Fog/Mist | Light Snow Showers Fog/Mist | Heavy Snow Showers Fog/Mist | Showers Snow Fog/Mist | Light Showers Snow Fog/Mist | Heavy Showers Snow Fog/Mist | Snow Fog | Light Snow Fog | Heavy Snow Fog | Snow Showers Fog | Light Snow Showers Fog | Heavy Snow Showers Fog | Showers Snow Fog | Light Showers Snow Fog | Heavy Showers Snow Fog | Showers in Vicinity Snow | Snow Showers in Vicinity | Snow Showers in Vicinity Fog/Mist | Snow Showers in Vicinity Fog | Low Drifting Snow | Blowing Snow | Snow Low Drifting Snow | Snow Blowing Snow | Light Snow Low Drifting Snow | Light Snow Blowing Snow | Heavy Snow Low Drifting Snow | Heavy Snow Blowing Snow | Thunderstorm Snow | Light Thunderstorm Snow | Heavy Thunderstorm Snow | Snow Grains | Light Snow Grains | Heavy Snow Grains | Heavy Blowing Snow | Blowing Snow in Vicinity"; + $retVal['wind']="Windy | Fair and Windy | A Few Clouds and Windy | Partly Cloudy and Windy | Mostly Cloudy and Windy | Overcast and Windy"; + $retVal['hi_shwrs']="Showers in Vicinity | Showers in Vicinity Fog/Mist | Showers in Vicinity Fog | Showers in Vicinity Haze"; + $retVal['fzrara']="Freezing Rain Rain | Light Freezing Rain Rain | Heavy Freezing Rain Rain | Rain Freezing Rain | Light Rain Freezing Rain | Heavy Rain Freezing Rain | Freezing Drizzle Rain | Light Freezing Drizzle Rain | Heavy Freezing Drizzle Rain | Rain Freezing Drizzle | Light Rain Freezing Drizzle | Heavy Rain Freezing Drizzle"; + $retVal['hi_tsra']="Thunderstorm in Vicinity | Thunderstorm in Vicinity Fog/Mist | Thunderstorm in Vicinity Fog | Thunderstorm Haze in Vicinity | Thunderstorm in Vicinity Haze"; + $retVal['ra1']="Light Rain | Drizzle | Light Drizzle | Heavy Drizzle | Light Rain Fog/Mist | Drizzle Fog/Mist | Light Drizzle Fog/Mist | Heavy Drizzle Fog/Mist | Light Rain Fog | Drizzle Fog | Light Drizzle Fog | Heavy Drizzle Fog"; + $retVal['ra']="Rain | Heavy Rain | Rain Fog/Mist | Heavy Rain Fog/Mist | Rain Fog | Heavy Rain Fog"; + $retVal['nsvrtsra']="Funnel Cloud | Funnel Cloud in Vicinity | Tornado/Water Spout"; + $retVal['dust']="Dust | Low Drifting Dust | Blowing Dust | Sand | Blowing Sand | Low Drifting Sand | Dust/Sand Whirls | Dust/Sand Whirls in Vicinity | Dust Storm | Heavy Dust Storm | Dust Storm in Vicinity | Sand Storm | Heavy Sand Storm | Sand Storm in Vicinity"; + $retVal['mist']="Haze"; + return $retVal; + } +// end CLASS } - -function endElement($parser, $name) { - global $itemname,$itemdata,$wxdata; - $wxdata[$itemname]=($itemdata); - $itemdata=""; -} - -function characterData($parser, $data) { - global $itemname,$itemdata,$wxdata; - $itemdata.=$data; -} - -function defineIcons(){ - // See http://weather.gov/data/current_obs/weather.php for source data for this function - $retVal['bkn']="Mostly Cloudy | Mostly Cloudy with Haze | Mostly Cloudy and Breezy"; - $retVal['skc']="Fair | Clear | Fair with Haze | Clear with Haze | Fair and Breezy | Clear and Breezy"; - $retVal['few']="A Few Clouds | A Few Clouds with Haze | A Few Clouds and Breezy"; - $retVal['sct']="Partly Cloudy | Party Cloudy with Haze | Partly Cloudy and Breezy"; - $retVal['ovc']="Overcast | Overcast with Haze | Overcast and Breezy"; - $retVal['nfg']="Fog/Mist | Fog | Freezing Fog | Shallow Fog | Partial Fog | Patches of Fog | Fog in Vicinity | Freezing Fog in Vicinity | Shallow Fog in Vicinity | Partial Fog in Vicinity | Patches of Fog in Vicinity | Showers in Vicinity Fog | Light Freezing Fog | Heavy Freezing Fog"; - $retVal['smoke']="Smoke"; - $retVal['fzra']="Freezing Rain | Freezing Drizzle | Light Freezing Rain | Light Freezing Drizzle | Heavy Freezing Rain | Heavy Freezing Drizzle | Freezing Rain in Vicinity | Freezing Drizzle in Vicinity"; - $retVal['ip']="Ice Pellets | Light Ice Pellets | Heavy Ice Pellets | Ice Pellets in Vicinity | Showers Ice Pellets | Thunderstorm Ice Pellets | Ice Crystals | Hail | Small Hail/Snow Pellets | Light Small Hail/Snow Pellets | Heavy Small Hail/Snow Pellets | Showers Hail | Hail Showers"; - $retVal['mix']="Freezing Rain Snow | Light Freezing Rain Snow | Heavy Freezing Rain Snow | Freezing Drizzle Snow | Light Freezing Drizzle Snow | Heavy Freezing Drizzle Snow | Snow Freezing Rain| Light Snow Freezing Rain | Heavy Snow Freezing Rain | Snow Freezing Drizzle | Light Snow Freezing Drizzle | Heavy Snow Freezing Drizzle"; - $retVal['raip']="Rain Ice Pellets | Light Rain Ice Pellets | Heavy Rain Ice Pellets | Drizzle Ice Pellets | Light Drizzle Ice Pellets | Heavy Drizzle Ice Pellets | Ice Pellets Rain | Light Ice Pellets Rain | Heavy Ice Pellets Rain | Ice Pellets Drizzle | Light Ice Pellets Drizzle | Heavy Ice Pellets Drizzle"; - $retVal['rasn']="Rain Snow | Light Rain Snow | Heavy Rain Snow | Snow Rain | Light Snow Rain | Heavy Snow Rain | Drizzle Snow | Light Drizzle Snow | Heavy Drizzle Snow | Snow Drizzle | Light Snow Drizzle | Heavy Snow Drizzle"; - $retVal['shra']="Rain Showers | Light Rain Showers | Heavy Rain Showers | Rain Showers in Vicinity | Light Showers Rain | Heavy Showers Rain | Showers Rain | Showers Rain in Vicinity | Rain Showers Fog/Mist | Light Rain Showers Fog/Mist | Heavy Rain Showers Fog/Mist | Rain Showers in Vicinity Fog/Mist | Light Showers Rain Fog/Mist | Heavy Showers Rain Fog/Mist | Showers Rain Fog/Mist | Showers Rain in Vicinity Fog/Mist"; - $retVal['tsra']="Thunderstorm | Light Thunderstorm Rain | Heavy Thunderstorm Rain | Thunderstorm Rain Fog/Mist | Light Thunderstorm Rain Fog/Mist | Heavy Thunderstorm Rain Fog/Mist | Thunderstorm Showers in Vicinity | | Light Thunderstorm Rain Haze | Heavy Thunderstorm Rain Haze | Thunderstorm Fog | Light Thunderstorm Rain Fog | Heavy Thunderstorm Rain Fog | Thunderstorm Light Rain | Thunderstorm Heavy Rain | Thunderstorm Rain Fog/Mist | Thunderstorm Light Rain Fog/Mist | Thunderstorm Heavy Rain Fog/Mist | Thunderstorm in Vicinity Fog/Mist | Thunderstorm Showers in Vicinity | Thunderstorm in Vicinity | Thunderstorm in Vicinity Haze | Thunderstorm Haze in Vicinity | Thunderstorm Light Rain Haze | Thunderstorm Heavy Rain Haze | Thunderstorm Fog | Thunderstorm Light Rain Fog | Thunderstorm Heavy Rain Fog | Thunderstorm Hail | Light Thunderstorm Rain Hail | Heavy Thunderstorm Rain Hail | Thunderstorm Rain Hail Fog/Mist | Light Thunderstorm Rain Hail Fog/Mist | Heavy Thunderstorm Rain Hail Fog/Mist | Thunderstorm Showers in Vicinity Hail | | Light Thunderstorm Rain Hail Haze | Heavy Thunderstorm Rain Hail Haze | Thunderstorm Hail Fog | Light Thunderstorm Rain Hail Fog | Heavy Thunderstorm Rain Hail Fog | Thunderstorm Light Rain Hail | Thunderstorm Heavy Rain Hail | Thunderstorm Rain Hail Fog/Mist | Thunderstorm Light Rain Hail Fog/Mist | Thunderstorm Heavy Rain Hail Fog/Mist | Thunderstorm in Vicinity Hail Fog/Mist | Thunderstorm Showers in Vicinity Hail | Thunderstorm in Vicinity Hail | Thunderstorm in Vicinity Hail Haze | Thunderstorm Haze in Vicinity Hail | Thunderstorm Light Rain Hail Haze | Thunderstorm Heavy Rain Hail Haze | Thunderstorm Hail Fog | Thunderstorm Light Rain Hail Fog | Thunderstorm Heavy Rain Hail Fog | Thunderstorm Small Hail/Snow Pellets | Thunderstorm Rain Small Hail/Snow Pellets | Light Thunderstorm Rain Small Hail/Snow Pellets | Heavy Thunderstorm Rain Small Hail/Snow Pellets"; - $retVal['sn']="Snow | Light Snow | Heavy Snow | Snow Showers | Light Snow Showers | Heavy Snow Showers | Showers Snow | Light Showers Snow | Heavy Showers Snow | Snow Fog/Mist | Light Snow Fog/Mist | Heavy Snow Fog/Mist | Snow Showers Fog/Mist | Light Snow Showers Fog/Mist | Heavy Snow Showers Fog/Mist | Showers Snow Fog/Mist | Light Showers Snow Fog/Mist | Heavy Showers Snow Fog/Mist | Snow Fog | Light Snow Fog | Heavy Snow Fog | Snow Showers Fog | Light Snow Showers Fog | Heavy Snow Showers Fog | Showers Snow Fog | Light Showers Snow Fog | Heavy Showers Snow Fog | Showers in Vicinity Snow | Snow Showers in Vicinity | Snow Showers in Vicinity Fog/Mist | Snow Showers in Vicinity Fog | Low Drifting Snow | Blowing Snow | Snow Low Drifting Snow | Snow Blowing Snow | Light Snow Low Drifting Snow | Light Snow Blowing Snow | Heavy Snow Low Drifting Snow | Heavy Snow Blowing Snow | Thunderstorm Snow | Light Thunderstorm Snow | Heavy Thunderstorm Snow | Snow Grains | Light Snow Grains | Heavy Snow Grains | Heavy Blowing Snow | Blowing Snow in Vicinity"; - $retVal['wind']="Windy | Fair and Windy | A Few Clouds and Windy | Partly Cloudy and Windy | Mostly Cloudy and Windy | Overcast and Windy"; - $retVal['hi_shwrs']="Showers in Vicinity | Showers in Vicinity Fog/Mist | Showers in Vicinity Fog | Showers in Vicinity Haze"; - $retVal['fzrara']="Freezing Rain Rain | Light Freezing Rain Rain | Heavy Freezing Rain Rain | Rain Freezing Rain | Light Rain Freezing Rain | Heavy Rain Freezing Rain | Freezing Drizzle Rain | Light Freezing Drizzle Rain | Heavy Freezing Drizzle Rain | Rain Freezing Drizzle | Light Rain Freezing Drizzle | Heavy Rain Freezing Drizzle"; - $retVal['hi_tsra']="Thunderstorm in Vicinity | Thunderstorm in Vicinity Fog/Mist | Thunderstorm in Vicinity Fog | Thunderstorm Haze in Vicinity | Thunderstorm in Vicinity Haze"; - $retVal['ra1']="Light Rain | Drizzle | Light Drizzle | Heavy Drizzle | Light Rain Fog/Mist | Drizzle Fog/Mist | Light Drizzle Fog/Mist | Heavy Drizzle Fog/Mist | Light Rain Fog | Drizzle Fog | Light Drizzle Fog | Heavy Drizzle Fog"; - $retVal['ra']="Rain | Heavy Rain | Rain Fog/Mist | Heavy Rain Fog/Mist | Rain Fog | Heavy Rain Fog"; - $retVal['nsvrtsra']="Funnel Cloud | Funnel Cloud in Vicinity | Tornado/Water Spout"; - $retVal['dust']="Dust | Low Drifting Dust | Blowing Dust | Sand | Blowing Sand | Low Drifting Sand | Dust/Sand Whirls | Dust/Sand Whirls in Vicinity | Dust Storm | Heavy Dust Storm | Dust Storm in Vicinity | Sand Storm | Heavy Sand Storm | Sand Storm in Vicinity"; - $retVal['mist']="Haze"; - return $retVal; -} - ?> diff --git a/curtemp/test.php b/curtemp/test.php new file mode 100644 index 00000000..cd51c23c --- /dev/null +++ b/curtemp/test.php @@ -0,0 +1,5 @@ +