1. <?
  2. include('functions.php');
  3. global $set;
  4.  
  5. $lat = 33.777444;
  6. $lon = -84.405116;
  7. $zip = 30332;
  8.  
  9. $timezone = get_time_zone("US","GA");
  10. date_default_timezone_set($timezone);
  11. $zenith = 96;
  12. $tzoffset = date("Z")/60 / 60;
  13.  
  14. $set = day_or_night($lat,$lon,$tzoffset,$zenith);
  15.  
  16. $data = get_cached_file('http://api.wunderground.com/api/84ca38f278f3d8b2/conditions/q/GA/Atlanta.json');
  17. $data2 = get_cached_file('http://api.wunderground.com/api/84ca38f278f3d8b2/forecast/q/GA/Atlanta.json');
  18. $data = json_decode($data);
  19. $data2 = json_decode($data2);
  20.  
  21. //print_r($data2->forecast->simpleforecast->forecastday);
  22.  
  23. //  Get icon # from data
  24.  
  25.  
  26. $current = $data->current_observation;
  27.  
  28. $current_json = array(
  29.                 'update_time'=>date('g:i a',$current->observation_epoch),
  30.                 'temperature'=>((int)$current->temp_f).'&deg;',
  31.                 'wind'=>((int)$current->wind_mph).'mph',
  32.                 'weather'=>$current->weather,
  33.                 'icon'=>get_icon($current->icon),
  34.                 'precip'=>$data2->forecast->simpleforecast->forecastday[0]->pop.'%'
  35.             );
  36.            
  37.            
  38. $forecast_array = array();
  39. foreach($data2->forecast->simpleforecast->forecastday as $forecast)
  40. {
  41.     $data = array(
  42.         'day'=>$forecast->date->weekday_short,
  43.         'high'=>$forecast->high->fahrenheit.'&deg;',
  44.         'low'=>$forecast->low->fahrenheit.'&deg;',
  45.         'icon'=>get_icon($forecast->icon,true),
  46.         'precip'=>$forecast->pop
  47.     );
  48.    
  49.     array_push($forecast_array,$data);
  50. }
  51.  
  52. $json =
  53. json_encode(
  54.     array(
  55.         'place'=>$current->display_location->full,
  56.         'current_conditions'=>$current_json,
  57.         'forecast'=>$forecast_array
  58.     )
  59. );
  60.  
  61.  
  62. echo 'weather('.$json.');';