@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | $from_archive = false; |
| 13 | 13 | if (isset($_GET['ident'])) { |
| 14 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
| 14 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
| 15 | 15 | if (isset($_GET['currenttime'])) { |
| 16 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
| 16 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
| 17 | 17 | $currenttime = round($currenttime/1000); |
| 18 | - $spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime); |
|
| 18 | + $spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident, $currenttime); |
|
| 19 | 19 | if (empty($spotter_array)) { |
| 20 | 20 | $from_archive = true; |
| 21 | - $spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime); |
|
| 21 | + $spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident, $currenttime); |
|
| 22 | 22 | } |
| 23 | 23 | } else { |
| 24 | 24 | $spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident); |
@@ -29,15 +29,15 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | if (isset($_GET['flightaware_id'])) { |
| 32 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
| 32 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
| 33 | 33 | if (isset($_GET['currenttime'])) { |
| 34 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
| 34 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
| 35 | 35 | $currenttime = round($currenttime/1000); |
| 36 | - $spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime); |
|
| 36 | + $spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id, $currenttime); |
|
| 37 | 37 | if (empty($spotter_array)) { |
| 38 | 38 | $from_archive = true; |
| 39 | 39 | // $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id); |
| 40 | - $spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime); |
|
| 40 | + $spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id, $currenttime); |
|
| 41 | 41 | } |
| 42 | 42 | } else { |
| 43 | 43 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
| 58 | 58 | { |
| 59 | 59 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
| 60 | - $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
| 60 | + $image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
| 61 | 61 | } else $image = $spotter_item['image_thumbnail']; |
| 62 | 62 | } |
| 63 | 63 | /* else { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 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']; |
| 78 | 78 | if (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') { |
| 79 | 79 | if ($spotter_item['departure_airport_time'] > 2460) { |
| 80 | - print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>'; |
|
| 80 | + print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>'; |
|
| 81 | 81 | } else { |
| 82 | 82 | print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>'; |
| 83 | 83 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country']; |
| 87 | 87 | if (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') { |
| 88 | 88 | if ($spotter_item['arrival_airport_time'] > 2460) { |
| 89 | - print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>'; |
|
| 89 | + print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>'; |
|
| 90 | 90 | } else { |
| 91 | 91 | print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>'; |
| 92 | 92 | } |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | print '<div id ="altitude"><span>'._("Altitude").'</span>'; |
| 112 | 112 | if (isset($globalGroundAltitude) && $globalGroundAltitude) { |
| 113 | 113 | try { |
| 114 | - $groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']); |
|
| 115 | - } catch(Exception $e) { |
|
| 114 | + $groundAltitude = $Elevation->getElevation($spotter_item['latitude'], $spotter_item['longitude']); |
|
| 115 | + } catch (Exception $e) { |
|
| 116 | 116 | // If catched not exist |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | print '</div>'; |
| 180 | 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 | 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>'; |
|
| 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 | 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>'; |
| 184 | 184 | print '</div>'; |
| 185 | 185 | } |
@@ -5,11 +5,11 @@ |
||
| 5 | 5 | |
| 6 | 6 | if (isset($_POST['aircraft_manufacturer']) && $_POST['aircraft_manufacturer'] != '') |
| 7 | 7 | { |
| 8 | - $aircraft_manufacturer = filter_input(INPUT_POST,'aircraft_manufacturer',FILTER_SANITIZE_STRING); |
|
| 8 | + $aircraft_manufacturer = filter_input(INPUT_POST, 'aircraft_manufacturer', FILTER_SANITIZE_STRING); |
|
| 9 | 9 | header('Location: '.$globalURL.'/manufacturer/'.$aircraft_manufacturer); |
| 10 | 10 | } elseif (isset($_GET['aircraft_manufacturer']) && $_GET['aircraft_manufacturer'] != '') |
| 11 | 11 | { |
| 12 | - $aircraft_manufacturer = filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING); |
|
| 12 | + $aircraft_manufacturer = filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING); |
|
| 13 | 13 | header('Location: '.$globalURL.'/manufacturer/'.$aircraft_manufacturer); |
| 14 | 14 | } else { |
| 15 | 15 | if ($globalURL == '') { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $Connection = new Connection(); |
| 55 | 55 | $sth = $Connection->db->prepare($query); |
| 56 | 56 | $sth->execute(); |
| 57 | - } catch(PDOException $e) { |
|
| 57 | + } catch (PDOException $e) { |
|
| 58 | 58 | return "error : ".$e->getMessage(); |
| 59 | 59 | } |
| 60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $Connection = new Connection(); |
| 71 | 71 | $sth = $Connection->db->prepare($query); |
| 72 | 72 | $sth->execute(); |
| 73 | - } catch(PDOException $e) { |
|
| 73 | + } catch (PDOException $e) { |
|
| 74 | 74 | return "error : ".$e->getMessage(); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | public function parse($data) { |
| 79 | 79 | //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
| 80 | 80 | $codes = implode('|', array_keys($this->texts)); |
| 81 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
| 81 | + $regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#'; |
|
| 82 | 82 | //$pieces = explode(' ',$data); |
| 83 | - $pieces = preg_split('/\s/',$data); |
|
| 83 | + $pieces = preg_split('/\s/', $data); |
|
| 84 | 84 | $pos = 0; |
| 85 | 85 | if ($pieces[0] == 'METAR') $pos++; |
| 86 | 86 | elseif ($pieces[0] == 'SPECI') $pos++; |
@@ -89,25 +89,25 @@ discard block |
||
| 89 | 89 | if (!isset($pieces[$pos])) return $result; |
| 90 | 90 | $result['location'] = $pieces[$pos]; |
| 91 | 91 | $pos++; |
| 92 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
| 93 | - $result['time'] = substr($pieces[$pos],2,4); |
|
| 92 | + $result['dayofmonth'] = substr($pieces[$pos], 0, 2); |
|
| 93 | + $result['time'] = substr($pieces[$pos], 2, 4); |
|
| 94 | 94 | $c = count($pieces); |
| 95 | - for($pos++; $pos < $c; $pos++) { |
|
| 95 | + for ($pos++; $pos < $c; $pos++) { |
|
| 96 | 96 | $piece = $pieces[$pos]; |
| 97 | 97 | if ($piece == 'RMK') break; |
| 98 | 98 | if ($piece == 'AUTO') $result['auto'] = true; |
| 99 | 99 | if ($piece == 'COR') $result['correction'] = true; |
| 100 | 100 | // Wind Speed |
| 101 | 101 | 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 | - $result['wind']['direction'] = (float)$matches[1]; |
|
| 102 | + $result['wind']['direction'] = (float) $matches[1]; |
|
| 103 | 103 | $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); |
|
| 107 | - $result['wind']['gust'] = (float)$matches[3]; |
|
| 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); |
|
| 107 | + $result['wind']['gust'] = (float) $matches[3]; |
|
| 108 | 108 | $result['wind']['unit'] = $matches[4]; |
| 109 | - $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
|
| 110 | - $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
|
| 109 | + $result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0; |
|
| 110 | + $result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
@@ -128,14 +128,14 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | // Temperature |
| 130 | 130 | if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
| 131 | - $temp = (float)$matches[1]; |
|
| 131 | + $temp = (float) $matches[1]; |
|
| 132 | 132 | if ($matches[1]{0} == 'M') { |
| 133 | - $temp = ((float)substr($matches[1], 1)) * -1; |
|
| 133 | + $temp = ((float) substr($matches[1], 1))*-1; |
|
| 134 | 134 | } |
| 135 | 135 | $result['temperature'] = $temp; |
| 136 | - $dew = (float)$matches[2]; |
|
| 136 | + $dew = (float) $matches[2]; |
|
| 137 | 137 | if ($matches[2]{0} == 'M') { |
| 138 | - $dew = ((float)substr($matches[2], 1)) * -1; |
|
| 138 | + $dew = ((float) substr($matches[2], 1))*-1; |
|
| 139 | 139 | } |
| 140 | 140 | $result['dew'] = $dew; |
| 141 | 141 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $result['QNH'] = $matches[2]; |
| 148 | 148 | } else { |
| 149 | 149 | // inHg |
| 150 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
| 150 | + $result['QNH'] = round(($matches[2]/100)*33.86389, 2); |
|
| 151 | 151 | } |
| 152 | 152 | /* |
| 153 | 153 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
@@ -168,12 +168,12 @@ discard block |
||
| 168 | 168 | // Visibility |
| 169 | 169 | if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
| 170 | 170 | if (isset($matches[3]) && strlen($matches[3]) > 0) { |
| 171 | - $result['visibility'] = (float)$matches[3] * 1609.34; |
|
| 171 | + $result['visibility'] = (float) $matches[3]*1609.34; |
|
| 172 | 172 | } else { |
| 173 | 173 | if ($matches[1] == '9999') { |
| 174 | 174 | $result['visibility'] = '> 10000'; |
| 175 | 175 | } else { |
| 176 | - $result['visibility'] = (float)$matches[1]; |
|
| 176 | + $result['visibility'] = (float) $matches[1]; |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | if (preg_match('#^CAVOK$#', $piece, $matches)) { |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
| 196 | 196 | elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
| 197 | 197 | $cloud['type_code'] = $type; |
| 198 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
| 198 | + $cloud['level'] = round(((float) $matches[2])*100*0.3048); |
|
| 199 | 199 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
| 200 | 200 | $result['cloud'][] = $cloud; |
| 201 | 201 | } |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | $rvr['runway'] = $matches[1]; |
| 206 | 206 | $rvr['assessment'] = $matches[2]; |
| 207 | 207 | $rvr['rvr'] = $matches[3]; |
| 208 | - $rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0; |
|
| 209 | - $rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : ''; |
|
| 208 | + $rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0; |
|
| 209 | + $rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : ''; |
|
| 210 | 210 | $result['RVR'] = $rvr; |
| 211 | 211 | } |
| 212 | 212 | //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | $result['RVR']['friction'] = $matches[5]; |
| 220 | 220 | } |
| 221 | 221 | 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'); |
|
| 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'); |
|
| 224 | 224 | if (isset($matches[3])) { |
| 225 | 225 | $range = Array( |
| 226 | - 'from' => (float)$matches[2], |
|
| 227 | - 'to' => (float)$matches[4], |
|
| 226 | + 'from' => (float) $matches[2], |
|
| 227 | + 'to' => (float) $matches[4], |
|
| 228 | 228 | 'unit' => $matches[5] ? 'FT' : 'M' |
| 229 | 229 | ); |
| 230 | 230 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | try { |
| 273 | 273 | $sth = $this->db->prepare($query); |
| 274 | 274 | $sth->execute($query_values); |
| 275 | - } catch(PDOException $e) { |
|
| 275 | + } catch (PDOException $e) { |
|
| 276 | 276 | return "error : ".$e->getMessage(); |
| 277 | 277 | } |
| 278 | 278 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -282,19 +282,19 @@ discard block |
||
| 282 | 282 | return $all; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - public function addMETAR($location,$metar,$date) { |
|
| 285 | + public function addMETAR($location, $metar, $date) { |
|
| 286 | 286 | global $globalDBdriver; |
| 287 | - $date = date('Y-m-d H:i:s',strtotime($date)); |
|
| 287 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 288 | 288 | if ($globalDBdriver == 'mysql') { |
| 289 | 289 | $query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar"; |
| 290 | 290 | } else { |
| 291 | 291 | $query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
| 292 | 292 | } |
| 293 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
| 293 | + $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar)); |
|
| 294 | 294 | try { |
| 295 | 295 | $sth = $this->db->prepare($query); |
| 296 | 296 | $sth->execute($query_values); |
| 297 | - } catch(PDOException $e) { |
|
| 297 | + } catch (PDOException $e) { |
|
| 298 | 298 | return "error : ".$e->getMessage(); |
| 299 | 299 | } |
| 300 | 300 | } |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | try { |
| 306 | 306 | $sth = $this->db->prepare($query); |
| 307 | 307 | $sth->execute($query_values); |
| 308 | - } catch(PDOException $e) { |
|
| 308 | + } catch (PDOException $e) { |
|
| 309 | 309 | return "error : ".$e->getMessage(); |
| 310 | 310 | } |
| 311 | 311 | } |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | try { |
| 316 | 316 | $sth = $this->db->prepare($query); |
| 317 | 317 | $sth->execute(); |
| 318 | - } catch(PDOException $e) { |
|
| 318 | + } catch (PDOException $e) { |
|
| 319 | 319 | return "error : ".$e->getMessage(); |
| 320 | 320 | } |
| 321 | 321 | } |
@@ -326,27 +326,27 @@ discard block |
||
| 326 | 326 | date_default_timezone_set("UTC"); |
| 327 | 327 | $Common = new Common(); |
| 328 | 328 | if (isset($globalIVAO) && $globalIVAO) { |
| 329 | - $Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
| 330 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
| 329 | + $Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
| 330 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r"); |
|
| 331 | 331 | } else { |
| 332 | - $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
| 333 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
| 332 | + $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
| 333 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r"); |
|
| 334 | 334 | } |
| 335 | 335 | if ($handle) { |
| 336 | 336 | if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
| 337 | 337 | $date = ''; |
| 338 | 338 | if ($globalTransaction) $this->db->beginTransaction(); |
| 339 | - while(($line = fgets($handle,4096)) !== false) { |
|
| 340 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
| 339 | + while (($line = fgets($handle, 4096)) !== false) { |
|
| 340 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
| 341 | 341 | $date = $line; |
| 342 | 342 | } elseif ($line != '') { |
| 343 | 343 | if ($date == '') $date = date('Y/m/d H:m'); |
| 344 | 344 | $pos = 0; |
| 345 | - $pieces = preg_split('/\s/',$line); |
|
| 345 | + $pieces = preg_split('/\s/', $line); |
|
| 346 | 346 | if ($pieces[0] == 'METAR') $pos++; |
| 347 | 347 | if (strlen($pieces[$pos]) != 4) $pos++; |
| 348 | 348 | $location = $pieces[$pos]; |
| 349 | - echo $this->addMETAR($location,$line,$date); |
|
| 349 | + echo $this->addMETAR($location, $line, $date); |
|
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | 352 | fclose($handle); |
@@ -360,22 +360,22 @@ discard block |
||
| 360 | 360 | if ($globalMETARurl == '') return array(); |
| 361 | 361 | date_default_timezone_set("UTC"); |
| 362 | 362 | $Common = new Common(); |
| 363 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
| 363 | + $url = str_replace('{icao}', $icao, $globalMETARurl); |
|
| 364 | 364 | $cycle = $Common->getData($url); |
| 365 | 365 | $date = ''; |
| 366 | - foreach(explode("\n",$cycle) as $line) { |
|
| 367 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
| 366 | + foreach (explode("\n", $cycle) as $line) { |
|
| 367 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
| 368 | 368 | $date = $line; |
| 369 | 369 | } |
| 370 | 370 | if ($line != '') { |
| 371 | 371 | if ($date == '') $date = date('Y/m/d H:m'); |
| 372 | 372 | $pos = 0; |
| 373 | - $pieces = preg_split('/\s/',$line); |
|
| 373 | + $pieces = preg_split('/\s/', $line); |
|
| 374 | 374 | if ($pieces[0] == 'METAR') $pos++; |
| 375 | 375 | if (strlen($pieces[$pos]) != 4) $pos++; |
| 376 | 376 | $location = $pieces[$pos]; |
| 377 | 377 | if (strlen($location == 4)) { |
| 378 | - $this->addMETAR($location,$line,$date); |
|
| 378 | + $this->addMETAR($location, $line, $date); |
|
| 379 | 379 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 380 | 380 | } else return array(); |
| 381 | 381 | } |