= 1 And $length <= 10)) $length = 10; $forecast_url = "http://xoap.weather.com/weather/local/$loc_id?cc=*&dayf=$length&prod=xoap&par=$partner_ID&key=$license_key&unit=$units"; $checkurl = $forecast_url; $xml_url = md5($checkurl); $ttl = 60*60; $cachefilename = "./elements/weather/weather/cache/$xml_url"; if (file_exists($cachefilename) && (time() - $ttl < filemtime($cachefilename))) { $url = $cachefilename; $xml = file_get_contents($url"); }else{ $url = $forecast_url; $xml = file_get_contents($url"); } $parser = xml_parser_create( ); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parse_into_struct($parser,$xml,$values,$index); xml_parser_free($parser); $city = htmlspecialchars($values[$index[dnam][0]][value]); $unit_temp = $values[$index[ut][0]][value]; $unit_speed = $values[$index[us][0]][value]; $unit_pressure = $values[$index[up][0]][value]; $unit_precip = $values[$index[ur][0]][value]; $unit_visib = $values[$index[ud][0]][value]; $sunrise = $values[$index[sunr][0]][value]; $sunset = $values[$index[suns][0]][value]; $hmid = $values[$index[hmid][0]][value]; $lat = $values[$index[lat][0]][value]; $lon = $values[$index[lon][0]][value]; $press = $values[$index[r][0]][value]; $press_desc = $values[$index[d][0]][value]; $vis = $values[$index[vis][0]][value]; $speed_wind = $values[$index[s][0]][value]; $speed_deg = $values[$index[d][1]][value]; $speed_ang = $values[$index[t][1]][value]; $uv_ind = $values[$index[i][0]][value]; $uv_desc = $values[$index[t][2]][value]; $timezone = $values[$index[tzone][0]][value]; $last_update = $values[$index[lsup][0]][value]; $curr_temp = $values[$index[tmp][0]][value]; $curr_flik = $values[$index[flik][0]][value]; $curr_text = $values[$index[t][0]][value]; $curr_icon = $values[$index[icon][0]][value]; $counter = 0; $row_counter = 2; $xml=""; function convert_to_24_hr($time, $ampm){ /* Make sure it's lower case */ $ampm=strtolower($ampm); /* Split the time */ list($hour, $min)=split(":", $time); switch($ampm){ case "am": if ($hour == 12) { $hour = 0; $hour = fill_time($hour); } else { $hour = fill_time($hour); } // $hour = fill_time($hour); break; case "pm": if ($hour == 12) { $hour = 12; } else { $hour = $hour + 12; } break; } $min = fill_time($min); return $hour . ":" . $min; } function fill_time($string){ if(strlen($string)==1){ $string="0" . $string; } return $string; } function ita_date($string){ list($month, $mday, $year)=split("/", $string); return fill_time($mday)."/".$month."/".$year; } ?>