@@ -58,7 +58,9 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
| 60 | 60 | $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 61 | - } else $image = $spotter_item['image_thumbnail']; |
|
| 61 | + } else { |
|
| 62 | + $image = $spotter_item['image_thumbnail']; |
|
| 63 | + } |
|
| 62 | 64 | } |
| 63 | 65 | /* else { |
| 64 | 66 | $image = "images/placeholder_thumb.png"; |
@@ -70,8 +72,12 @@ discard block |
||
| 70 | 72 | } |
| 71 | 73 | print '<div class="right">'; |
| 72 | 74 | print '<div class="callsign-details">'; |
| 73 | - if ($spotter_item['ident'] != 'Not Available') print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>'; |
|
| 74 | - if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') print '<div class="airline">'.$spotter_item['airline_name'].'</div>'; |
|
| 75 | + if ($spotter_item['ident'] != 'Not Available') { |
|
| 76 | + print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>'; |
|
| 77 | + } |
|
| 78 | + if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') { |
|
| 79 | + print '<div class="airline">'.$spotter_item['airline_name'].'</div>'; |
|
| 80 | + } |
|
| 75 | 81 | print '</div>'; |
| 76 | 82 | if ($spotter_item['departure_airport'] != 'NA' && $spotter_item['arrival_airport'] != 'NA') { |
| 77 | 83 | print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country']; |
@@ -103,10 +109,16 @@ discard block |
||
| 103 | 109 | print '</div>'; |
| 104 | 110 | print '<div id="aircraft">'; |
| 105 | 111 | print '<span>'._("Aircraft").'</span>'; |
| 106 | - if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>'; |
|
| 107 | - if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
| 108 | - elseif (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>'; |
|
| 109 | - else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name']; |
|
| 112 | + if (isset($spotter_item['aircraft_wiki'])) { |
|
| 113 | + print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>'; |
|
| 114 | + } |
|
| 115 | + if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') { |
|
| 116 | + print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
| 117 | + } elseif (isset($spotter_item['aircraft_type'])) { |
|
| 118 | + print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>'; |
|
| 119 | + } else { |
|
| 120 | + print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name']; |
|
| 121 | + } |
|
| 110 | 122 | print '</div>'; |
| 111 | 123 | print '<div id ="altitude"><span>'._("Altitude").'</span>'; |
| 112 | 124 | if (isset($globalGroundAltitude) && $globalGroundAltitude) { |
@@ -118,11 +130,17 @@ discard block |
||
| 118 | 130 | } |
| 119 | 131 | |
| 120 | 132 | if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
| 121 | - if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')'; |
|
| 122 | - else print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')'; |
|
| 133 | + if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') { |
|
| 134 | + print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')'; |
|
| 135 | + } else { |
|
| 136 | + print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')'; |
|
| 137 | + } |
|
| 123 | 138 | } else { |
| 124 | - if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')'; |
|
| 125 | - else print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')'; |
|
| 139 | + if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') { |
|
| 140 | + print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')'; |
|
| 141 | + } else { |
|
| 142 | + print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')'; |
|
| 143 | + } |
|
| 126 | 144 | } |
| 127 | 145 | |
| 128 | 146 | if (isset($groundAltitude) && $groundAltitude < $spotter_item['altitude']*30.48) { |
@@ -136,7 +154,9 @@ discard block |
||
| 136 | 154 | print '</i>'; |
| 137 | 155 | } |
| 138 | 156 | print '</div>'; |
| 139 | - if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>'; |
|
| 157 | + if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') { |
|
| 158 | + print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>'; |
|
| 159 | + } |
|
| 140 | 160 | print '<div id="speed"><span>'._("Speed").'</span>'; |
| 141 | 161 | if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) { |
| 142 | 162 | print round($spotter_item['ground_speed']*1.15078).' mph'; |
@@ -150,8 +170,11 @@ discard block |
||
| 150 | 170 | print '<div id="heading"><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>'; |
| 151 | 171 | if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') { |
| 152 | 172 | print '<div id="pilot"><span>'._("Pilot").'</span>'; |
| 153 | - if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
| 154 | - else print $spotter_item['pilot_name']; |
|
| 173 | + if (isset($spotter_item['pilot_id'])) { |
|
| 174 | + print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
| 175 | + } else { |
|
| 176 | + print $spotter_item['pilot_name']; |
|
| 177 | + } |
|
| 155 | 178 | print '</div>'; |
| 156 | 179 | } |
| 157 | 180 | if (isset($spotter_item['aircraft_owner']) && $spotter_item['aircraft_owner'] != '') { |
@@ -177,10 +200,18 @@ discard block |
||
| 177 | 200 | } |
| 178 | 201 | print '</div>'; |
| 179 | 202 | print '</div>'; |
| 180 | - if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
|
| 181 | - if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
|
| 182 | - if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
| 183 | - if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
|
| 203 | + if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') { |
|
| 204 | + print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
|
| 205 | + } |
|
| 206 | + if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') { |
|
| 207 | + print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
|
| 208 | + } |
|
| 209 | + if (isset($spotter_item['acars']['message'])) { |
|
| 210 | + print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
| 211 | + } |
|
| 212 | + if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) { |
|
| 213 | + print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
|
| 214 | + } |
|
| 184 | 215 | print '</div>'; |
| 185 | 216 | } |
| 186 | 217 | ?> |
@@ -59,8 +59,11 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 61 | 61 | $sth->closeCursor(); |
| 62 | - if ($row['nb'] > 0) return false; |
|
| 63 | - else return true; |
|
| 62 | + if ($row['nb'] > 0) { |
|
| 63 | + return false; |
|
| 64 | + } else { |
|
| 65 | + return true; |
|
| 66 | + } |
|
| 64 | 67 | } |
| 65 | 68 | |
| 66 | 69 | public static function insert_last_update() { |
@@ -82,11 +85,18 @@ discard block |
||
| 82 | 85 | //$pieces = explode(' ',$data); |
| 83 | 86 | $pieces = preg_split('/\s/',$data); |
| 84 | 87 | $pos = 0; |
| 85 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 86 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
| 87 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 88 | + if ($pieces[0] == 'METAR') { |
|
| 89 | + $pos++; |
|
| 90 | + } elseif ($pieces[0] == 'SPECI') { |
|
| 91 | + $pos++; |
|
| 92 | + } |
|
| 93 | + if (strlen($pieces[$pos]) != 4) { |
|
| 94 | + $pos++; |
|
| 95 | + } |
|
| 88 | 96 | $result = array(); |
| 89 | - if (!isset($pieces[$pos])) return $result; |
|
| 97 | + if (!isset($pieces[$pos])) { |
|
| 98 | + return $result; |
|
| 99 | + } |
|
| 90 | 100 | $result['location'] = $pieces[$pos]; |
| 91 | 101 | $pos++; |
| 92 | 102 | $result['dayofmonth'] = substr($pieces[$pos],0,2); |
@@ -94,16 +104,26 @@ discard block |
||
| 94 | 104 | $c = count($pieces); |
| 95 | 105 | for($pos++; $pos < $c; $pos++) { |
| 96 | 106 | $piece = $pieces[$pos]; |
| 97 | - if ($piece == 'RMK') break; |
|
| 98 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
| 99 | - if ($piece == 'COR') $result['correction'] = true; |
|
| 107 | + if ($piece == 'RMK') { |
|
| 108 | + break; |
|
| 109 | + } |
|
| 110 | + if ($piece == 'AUTO') { |
|
| 111 | + $result['auto'] = true; |
|
| 112 | + } |
|
| 113 | + if ($piece == 'COR') { |
|
| 114 | + $result['correction'] = true; |
|
| 115 | + } |
|
| 100 | 116 | // Wind Speed |
| 101 | 117 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
| 102 | 118 | $result['wind']['direction'] = (float)$matches[1]; |
| 103 | 119 | $result['wind']['unit'] = $matches[4]; |
| 104 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 105 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 106 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 120 | + if ($result['wind']['unit'] == 'KT') { |
|
| 121 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 122 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
| 123 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 124 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
| 125 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 126 | + } |
|
| 107 | 127 | $result['wind']['gust'] = (float)$matches[3]; |
| 108 | 128 | $result['wind']['unit'] = $matches[4]; |
| 109 | 129 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -186,14 +206,23 @@ discard block |
||
| 186 | 206 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
| 187 | 207 | $type = $matches[1]; |
| 188 | 208 | $cloud = array(); |
| 189 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
| 190 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 191 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
| 192 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
| 193 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
| 194 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
| 195 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 196 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
| 209 | + if ($type == 'SKC') { |
|
| 210 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
| 211 | + } elseif ($type == 'CLR') { |
|
| 212 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 213 | + } elseif ($type == 'NSC') { |
|
| 214 | + $cloud['type'] = 'No significant cloud'; |
|
| 215 | + } elseif ($type == 'FEW') { |
|
| 216 | + $cloud['type'] = 'Few'; |
|
| 217 | + } elseif ($type == 'SCT') { |
|
| 218 | + $cloud['type'] = 'Scattered'; |
|
| 219 | + } elseif ($type == 'BKN') { |
|
| 220 | + $cloud['type'] = 'Broken'; |
|
| 221 | + } elseif ($type == 'OVC') { |
|
| 222 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 223 | + } elseif ($type == 'VV') { |
|
| 224 | + $cloud['type'] = 'Vertical visibility'; |
|
| 225 | + } |
|
| 197 | 226 | $cloud['type_code'] = $type; |
| 198 | 227 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
| 199 | 228 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
@@ -219,8 +248,11 @@ discard block |
||
| 219 | 248 | $result['RVR']['friction'] = $matches[5]; |
| 220 | 249 | } |
| 221 | 250 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
| 222 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 223 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 251 | + if (isset($matches[5])) { |
|
| 252 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 253 | + } else { |
|
| 254 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 255 | + } |
|
| 224 | 256 | if (isset($matches[3])) { |
| 225 | 257 | $range = Array( |
| 226 | 258 | 'from' => (float)$matches[2], |
@@ -253,8 +285,11 @@ discard block |
||
| 253 | 285 | if (isset($matches[3])) { |
| 254 | 286 | $text[] = $this->texts[$matches[3]]; |
| 255 | 287 | } |
| 256 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
| 257 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 288 | + if (!isset($result['weather'])) { |
|
| 289 | + $result['weather'] = implode(' ', $text); |
|
| 290 | + } else { |
|
| 291 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 292 | + } |
|
| 258 | 293 | } |
| 259 | 294 | } |
| 260 | 295 | return $result; |
@@ -265,8 +300,11 @@ discard block |
||
| 265 | 300 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
| 266 | 301 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
| 267 | 302 | } else { |
| 268 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 269 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 303 | + if ($globalDBdriver == 'mysql') { |
|
| 304 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 305 | + } else { |
|
| 306 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 307 | + } |
|
| 270 | 308 | } |
| 271 | 309 | $query_values = array(':icao' => $icao); |
| 272 | 310 | try { |
@@ -322,7 +360,9 @@ discard block |
||
| 322 | 360 | |
| 323 | 361 | public function addMETARCycle() { |
| 324 | 362 | global $globalDebug, $globalIVAO, $globalTransaction; |
| 325 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
| 363 | + if (isset($globalDebug) && $globalDebug) { |
|
| 364 | + echo "Downloading METAR cycle..."; |
|
| 365 | + } |
|
| 326 | 366 | date_default_timezone_set("UTC"); |
| 327 | 367 | $Common = new Common(); |
| 328 | 368 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -333,31 +373,47 @@ discard block |
||
| 333 | 373 | $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
| 334 | 374 | } |
| 335 | 375 | if ($handle) { |
| 336 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
| 376 | + if (isset($globalDebug) && $globalDebug) { |
|
| 377 | + echo "Done - Updating DB..."; |
|
| 378 | + } |
|
| 337 | 379 | $date = ''; |
| 338 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
| 380 | + if ($globalTransaction) { |
|
| 381 | + $this->db->beginTransaction(); |
|
| 382 | + } |
|
| 339 | 383 | while(($line = fgets($handle,4096)) !== false) { |
| 340 | 384 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
| 341 | 385 | $date = $line; |
| 342 | 386 | } elseif ($line != '') { |
| 343 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 387 | + if ($date == '') { |
|
| 388 | + $date = date('Y/m/d H:m'); |
|
| 389 | + } |
|
| 344 | 390 | $pos = 0; |
| 345 | 391 | $pieces = preg_split('/\s/',$line); |
| 346 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 347 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 392 | + if ($pieces[0] == 'METAR') { |
|
| 393 | + $pos++; |
|
| 394 | + } |
|
| 395 | + if (strlen($pieces[$pos]) != 4) { |
|
| 396 | + $pos++; |
|
| 397 | + } |
|
| 348 | 398 | $location = $pieces[$pos]; |
| 349 | 399 | echo $this->addMETAR($location,$line,$date); |
| 350 | 400 | } |
| 351 | 401 | } |
| 352 | 402 | fclose($handle); |
| 353 | - if ($globalTransaction) $this->db->commit(); |
|
| 403 | + if ($globalTransaction) { |
|
| 404 | + $this->db->commit(); |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + if (isset($globalDebug) && $globalDebug) { |
|
| 408 | + echo "Done\n"; |
|
| 354 | 409 | } |
| 355 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
| 356 | 410 | } |
| 357 | 411 | |
| 358 | 412 | public function downloadMETAR($icao) { |
| 359 | 413 | global $globalMETARurl; |
| 360 | - if ($globalMETARurl == '') return array(); |
|
| 414 | + if ($globalMETARurl == '') { |
|
| 415 | + return array(); |
|
| 416 | + } |
|
| 361 | 417 | date_default_timezone_set("UTC"); |
| 362 | 418 | $Common = new Common(); |
| 363 | 419 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -368,16 +424,24 @@ discard block |
||
| 368 | 424 | $date = $line; |
| 369 | 425 | } |
| 370 | 426 | if ($line != '') { |
| 371 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 427 | + if ($date == '') { |
|
| 428 | + $date = date('Y/m/d H:m'); |
|
| 429 | + } |
|
| 372 | 430 | $pos = 0; |
| 373 | 431 | $pieces = preg_split('/\s/',$line); |
| 374 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 375 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 432 | + if ($pieces[0] == 'METAR') { |
|
| 433 | + $pos++; |
|
| 434 | + } |
|
| 435 | + if (strlen($pieces[$pos]) != 4) { |
|
| 436 | + $pos++; |
|
| 437 | + } |
|
| 376 | 438 | $location = $pieces[$pos]; |
| 377 | 439 | if (strlen($location == 4)) { |
| 378 | 440 | $this->addMETAR($location,$line,$date); |
| 379 | 441 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 380 | - } else return array(); |
|
| 442 | + } else { |
|
| 443 | + return array(); |
|
| 444 | + } |
|
| 381 | 445 | } |
| 382 | 446 | } |
| 383 | 447 | return array(); |