58 | | foreach($data as $line) { |
59 | | if(strpos($line, 'this.sw') === false) |
60 | | continue; |
61 | | if(strpos($line, 'swTempCel') !== false) |
62 | | continue; |
63 | | |
64 | | $line = trim($line); |
65 | | list($name, $value) = explode(' = "', $line); |
66 | | $name = substr($name, 7); |
67 | | $value = substr($value, 0, strlen($value) - 2); |
68 | | |
69 | | switch ($name) { |
70 | | case 'City': $this->city = $value; break; |
71 | | case 'SubDiv': $this->subdiv = $value; break; |
72 | | case 'Country': $this->country = $value; break; |
73 | | case 'Region': $this->region = $value; break; |
74 | | case 'Temp': $this->Temperature = $value; break; |
75 | | case 'CIcon': $this->CIcon = $value; break; |
76 | | case 'WindS': $this->WindSpeed = $value; break; |
77 | | case 'WindD': $this->WindDirection = $value; break; |
78 | | case 'Baro': $this->BarometricPressure = $value; break; |
79 | | case 'Humid': $this->Humidity = $value; break; |
80 | | case 'Real': $this->Real = $value; break; |
81 | | case 'UV': $this->UV = $value; break; |
82 | | case 'Vis': $this->Visibility = $value; break; |
83 | | case 'LastUp': $this->LastUpdated = $value; break; |
84 | | case 'ConText': $this->ConText = $value; break; |
85 | | case 'Fore': $this->Forecast = $this->readForecast($value); break; |
86 | | default: /* Weird, unknown type */ break; |
87 | | } |
88 | | } |
| 75 | // |
| 76 | // Technically we should include the partner id and key |
| 77 | // if this stops working, change to the following: |
| 78 | // http://xoap.weather.com/weather/local/".$this->acid."?cc=*&unit=F&dayf=5&prod=xoap&par=1036905921&key=f68c2657a4fd3e2e" |
| 79 | // may need to get a new one from http://www.weather.com/services/xmloap.html |
| 80 | // |
| 81 | $this->LastUpdated=$this->in("<lsup>","</lsup>",$data); |
| 82 | $dnaminfo = $this->in("<dnam>","</dnam>",$data); |
| 83 | $sep = strpos($dnaminfo, ','); |
| 84 | if($sep != false) { |
| 85 | $this->city = substr($dnaminfo, 0, $sep); |
| 86 | $this->country = substr($dnaminfo, $sep + 1, strlen($dnaminfo) - $sep - 1); |
| 87 | } |
| 88 | $cc = $this->in("<cc>","</cc>",$data); |
| 89 | $this->Temperature=$this->in("<tmp>","</tmp>",$cc); |
| 90 | $this->Real=$this->in("<flik>","</flik>",$cc); |
| 91 | $barinfo = $this->in("<bar>","</bar>",$cc); |
| 92 | $this->BarometricPressure=$this->in("<r>","</r>",$barinfo); |
| 93 | $windinfo = $this->in("<wind>","</wind>",$cc); |
| 94 | $this->WindSpeed = $this->in("<s>","</s>",$windinfo); |
| 95 | $this->WindDirection = $this->in("<t>","</t>",$windinfo); |
| 96 | $this->Humidity = $this->in("<hmid>","</hmid>",$cc); |
| 97 | $this->Visibility = $this->in("<vis>","</vis>",$cc); |
| 98 | $uvinfo = $this->in("<uv>","</uv>",$cc); |
| 99 | $this->UV = $this->in("<i>","</i>",$uvinfo); |
| 100 | $this->CIcon = $this->in("<icon>","</icon>", $cc); |
| 101 | $this->ConditionText = $this->in("<t>","</t>",$cc); |
| 102 | $this->Forecast = $this->readForecast($data); |
144 | | // mktime uses 0-6; msnbc gives us 1-7; adjust msnbc to match mktime |
145 | | $dayofweek = $data[$i] - 1; |
146 | | $forecast = new Forecast($data[5 + $i],$dayofweek); |
147 | | $forecast->dayofweek = $dayofweek; |
148 | | list($forecast->DescImage,$forecast->DescText) = $Weather_Types[$data[15 + $i]]; |
149 | | $forecast->DescImage = (strlen($forecast->DescImage) > 0) ? $forecast->DescImage : 'unknown.png'; |
150 | | $forecast->DescText = (strlen($forecast->DescText) > 0) ? $forecast->DescText : t('Unknown') . ' (' . $data[15+$i] . ')'; |
151 | | if($this->use_metric == 'YES') { |
152 | | $forecast->HighTemperature = round((5/9) * ($data[20 + $i] - 32)); |
153 | | $forecast->LowTemperature = round((5/9) * ($data[40 + $i] -32 )); |
154 | | } else { |
155 | | $forecast->HighTemperature = $data[20 + $i]; |
156 | | $forecast->LowTemperature = $data[40 + $i]; |
| 144 | $data1 = $this->in("<day d=\"".$i,"</day>",$data); |
| 145 | $day = $this->in("<day d=\"".$i."\" t=\"","\" dt",$data); |
| 146 | $forecast = new Forecast($this->LastUpdated, $i); |
| 147 | switch ($day) { |
| 148 | case 'Sunday': $forecast->dayofweek = 0; break; |
| 149 | case 'Monday': $forecast->dayofweek = 1; break; |
| 150 | case 'Tuesday': $forecast->dayofweek = 2; break; |
| 151 | case 'Wednesday': $forecast->dayofweek = 3; break; |
| 152 | case 'Thursday': $forecast->dayofweek = 4; break; |
| 153 | case 'Friday': $forecast->dayofweek = 5; break; |
| 154 | case 'Saturday': $forecast->dayofweek = 6; break; |
| 156 | // $forecast->dayofweek = $i; |
| 157 | |
| 158 | $fc = $this->in("<part p=\"d\">","</part>",$data1); |
| 159 | $forecast->DescText = $this->in("<t>","</t>",$fc); |
| 160 | $icon = $this->in("<icon>","</icon>",$fc); |
| 161 | $forecast->DescImage = $icon.".png"; |
| 162 | |
| 163 | $forecast->HighTemperature = $this->in("<hi>","</hi>",$data1); |
| 164 | $forecast->LowTemperature = $this->in("<low>","</low>",$data1); |
| 165 | |
| 166 | if($this->use_metric == 'YES') { |
| 167 | if ($forecast->HighTemperature != 'N/A') { |
| 168 | $forecast->HighTemperature = round((5/9) * ($forecast->HighTemperature - 32)); |
| 169 | } |
| 170 | if ($forecast->LowTemperature != 'N/A') { |
| 171 | $forecast->LowTemperature = round((5/9) * ($forecast->LowTemperature -32 )); |
| 172 | } |
| 173 | } |