@@ -20,20 +20,27 @@ discard block |
||
| 20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 22 | 22 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
| 23 | - if (isset($source['source'])) $filter['source'][] = $source['source']; |
|
| 23 | + if (isset($source['source'])) { |
|
| 24 | + $filter['source'][] = $source['source']; |
|
| 25 | + } |
|
| 24 | 26 | } |
| 25 | 27 | } else { |
| 26 | 28 | $filter = $globalStatsFilters[$globalFilterName]; |
| 27 | 29 | } |
| 28 | 30 | } |
| 29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 31 | + if (is_array($globalFilter)) { |
|
| 32 | + $filter = array_merge($filter,$globalFilter); |
|
| 33 | + } |
|
| 30 | 34 | $filter_query_join = ''; |
| 31 | 35 | $filter_query_where = ''; |
| 32 | 36 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 33 | 37 | $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
| 34 | 38 | } |
| 35 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 36 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 39 | + if ($filter_query_where == '' && $where) { |
|
| 40 | + $filter_query_where = ' WHERE'; |
|
| 41 | + } elseif ($filter_query_where != '' && $and) { |
|
| 42 | + $filter_query_where .= ' AND'; |
|
| 43 | + } |
|
| 37 | 44 | $filter_query = $filter_query_join.$filter_query_where; |
| 38 | 45 | return $filter_query; |
| 39 | 46 | } |
@@ -57,7 +64,9 @@ discard block |
||
| 57 | 64 | $info = str_replace('^','<br />',$info); |
| 58 | 65 | $info = str_replace('&sect;','',$info); |
| 59 | 66 | $info = str_replace('"','',$info); |
| 60 | - if ($type == '') $type = NULL; |
|
| 67 | + if ($type == '') { |
|
| 68 | + $type = NULL; |
|
| 69 | + } |
|
| 61 | 70 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
| 62 | 71 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
| 63 | 72 | try { |
@@ -28,7 +28,9 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | // $output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
| 30 | 30 | $output .= ',"clock": {"currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"'; |
| 31 | -if (!isset($_GET['now'])) $output .= ',"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z"'; |
|
| 31 | +if (!isset($_GET['now'])) { |
|
| 32 | + $output .= ',"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z"'; |
|
| 33 | +} |
|
| 32 | 34 | $output .= '}'; |
| 33 | 35 | //$output .= ',"clock": {"currentTime" : "'.date("c",time()).'","multiplier" : 300,"range" : "UNBOUNDED","step": "TICK_DEPENDENT"}'; |
| 34 | 36 | //$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
@@ -37,7 +39,9 @@ discard block |
||
| 37 | 39 | $output .= '},'; |
| 38 | 40 | $output .= '{'; |
| 39 | 41 | $output .= '"id": "santaclaus",'; |
| 40 | -if (!isset($_GET['now'])) $output .= '"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z",'; |
|
| 42 | +if (!isset($_GET['now'])) { |
|
| 43 | + $output .= '"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z",'; |
|
| 44 | +} |
|
| 41 | 45 | $output .= '"properties": {'; |
| 42 | 46 | // Not yet supported in CZML with Cesium |
| 43 | 47 | $output .= '},'; |
@@ -36,8 +36,12 @@ |
||
| 36 | 36 | if (!empty($spotter_array)) { |
| 37 | 37 | include('table-output.php'); |
| 38 | 38 | print '<div class="pagination">'; |
| 39 | - if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
| 40 | - if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
| 39 | + if ($limit_previous_1 >= 0) { |
|
| 40 | + print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
| 41 | + } |
|
| 42 | + if ($spotter_array[0]['query_number_rows'] == $absolute_difference) { |
|
| 43 | + print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
| 44 | + } |
|
| 41 | 45 | print '</div>'; |
| 42 | 46 | } |
| 43 | 47 | print '</div>'; |
@@ -38,8 +38,12 @@ |
||
| 38 | 38 | if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) { |
| 39 | 39 | include('table-output.php'); |
| 40 | 40 | print '<div class="pagination">'; |
| 41 | - if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
| 42 | - if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
| 41 | + if ($limit_previous_1 >= 0) { |
|
| 42 | + print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
| 43 | + } |
|
| 44 | + if ($spotter_array[0]['query_number_rows'] == $absolute_difference) { |
|
| 45 | + print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
| 46 | + } |
|
| 43 | 47 | print '</div>'; |
| 44 | 48 | } |
| 45 | 49 | print '</div>'; |
@@ -6,8 +6,11 @@ |
||
| 6 | 6 | $Spotter = new Spotter(); |
| 7 | 7 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
| 8 | 8 | $date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
| 9 | -if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
| 10 | -else $spotter_array = ''; |
|
| 9 | +if (isset($_GET['date'])) { |
|
| 10 | + $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
| 11 | +} else { |
|
| 12 | + $spotter_array = ''; |
|
| 13 | +} |
|
| 11 | 14 | |
| 12 | 15 | if (!empty($spotter_array)) |
| 13 | 16 | { |
@@ -8,8 +8,11 @@ |
||
| 8 | 8 | $date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
| 9 | 9 | |
| 10 | 10 | $Spotter = new Spotter(); |
| 11 | -if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
| 12 | -else $spotter_array = array(); |
|
| 11 | +if (isset($_GET['date'])) { |
|
| 12 | + $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
| 13 | +} else { |
|
| 14 | + $spotter_array = array(); |
|
| 15 | +} |
|
| 13 | 16 | |
| 14 | 17 | if (!empty($spotter_array)) |
| 15 | 18 | { |
@@ -38,8 +38,12 @@ |
||
| 38 | 38 | if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) { |
| 39 | 39 | include('table-output.php'); |
| 40 | 40 | print '<div class="pagination">'; |
| 41 | - if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
| 42 | - if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
| 41 | + if ($limit_previous_1 >= 0) { |
|
| 42 | + print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
| 43 | + } |
|
| 44 | + if ($spotter_array[0]['query_number_rows'] == $absolute_difference) { |
|
| 45 | + print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
| 46 | + } |
|
| 43 | 47 | print '</div>'; |
| 44 | 48 | } |
| 45 | 49 | print '</div>'; |
@@ -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() { |
@@ -84,9 +87,14 @@ discard block |
||
| 84 | 87 | //$pieces = explode(' ',$data); |
| 85 | 88 | $pieces = preg_split('/\s/',$data); |
| 86 | 89 | $pos = 0; |
| 87 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 88 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
| 89 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 90 | + if ($pieces[0] == 'METAR') { |
|
| 91 | + $pos++; |
|
| 92 | + } elseif ($pieces[0] == 'SPECI') { |
|
| 93 | + $pos++; |
|
| 94 | + } |
|
| 95 | + if (strlen($pieces[$pos]) != 4) { |
|
| 96 | + $pos++; |
|
| 97 | + } |
|
| 90 | 98 | $result = array(); |
| 91 | 99 | $result['location'] = $pieces[$pos]; |
| 92 | 100 | $pos++; |
@@ -95,16 +103,26 @@ discard block |
||
| 95 | 103 | $c = count($pieces); |
| 96 | 104 | for($pos++; $pos < $c; $pos++) { |
| 97 | 105 | $piece = $pieces[$pos]; |
| 98 | - if ($piece == 'RMK') break; |
|
| 99 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
| 100 | - if ($piece == 'COR') $result['correction'] = true; |
|
| 106 | + if ($piece == 'RMK') { |
|
| 107 | + break; |
|
| 108 | + } |
|
| 109 | + if ($piece == 'AUTO') { |
|
| 110 | + $result['auto'] = true; |
|
| 111 | + } |
|
| 112 | + if ($piece == 'COR') { |
|
| 113 | + $result['correction'] = true; |
|
| 114 | + } |
|
| 101 | 115 | // Wind Speed |
| 102 | 116 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
| 103 | 117 | $result['wind']['direction'] = (float)$matches[1]; |
| 104 | 118 | $result['wind']['unit'] = $matches[4]; |
| 105 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 106 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 107 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 119 | + if ($result['wind']['unit'] == 'KT') { |
|
| 120 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 121 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
| 122 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 123 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
| 124 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 125 | + } |
|
| 108 | 126 | $result['wind']['gust'] = (float)$matches[3]; |
| 109 | 127 | $result['wind']['unit'] = $matches[4]; |
| 110 | 128 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -186,14 +204,23 @@ discard block |
||
| 186 | 204 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
| 187 | 205 | $type = $matches[1]; |
| 188 | 206 | $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'; |
|
| 207 | + if ($type == 'SKC') { |
|
| 208 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
| 209 | + } elseif ($type == 'CLR') { |
|
| 210 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 211 | + } elseif ($type == 'NSC') { |
|
| 212 | + $cloud['type'] = 'No significant cloud'; |
|
| 213 | + } elseif ($type == 'FEW') { |
|
| 214 | + $cloud['type'] = 'Few'; |
|
| 215 | + } elseif ($type == 'SCT') { |
|
| 216 | + $cloud['type'] = 'Scattered'; |
|
| 217 | + } elseif ($type == 'BKN') { |
|
| 218 | + $cloud['type'] = 'Broken'; |
|
| 219 | + } elseif ($type == 'OVC') { |
|
| 220 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 221 | + } elseif ($type == 'VV') { |
|
| 222 | + $cloud['type'] = 'Vertical visibility'; |
|
| 223 | + } |
|
| 197 | 224 | $cloud['type_code'] = $type; |
| 198 | 225 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
| 199 | 226 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
@@ -223,8 +250,11 @@ discard block |
||
| 223 | 250 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
| 224 | 251 | //echo $piece; |
| 225 | 252 | //print_r($matches); |
| 226 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 227 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 253 | + if (isset($matches[5])) { |
|
| 254 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 255 | + } else { |
|
| 256 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 257 | + } |
|
| 228 | 258 | if (isset($matches[3])) { |
| 229 | 259 | $range = Array( |
| 230 | 260 | 'from' => (float)$matches[2], |
@@ -257,8 +287,11 @@ discard block |
||
| 257 | 287 | if (isset($matches[3])) { |
| 258 | 288 | $text[] = $this->texts[$matches[3]]; |
| 259 | 289 | } |
| 260 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
| 261 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 290 | + if (!isset($result['weather'])) { |
|
| 291 | + $result['weather'] = implode(' ', $text); |
|
| 292 | + } else { |
|
| 293 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 294 | + } |
|
| 262 | 295 | } |
| 263 | 296 | } |
| 264 | 297 | return $result; |
@@ -270,8 +303,11 @@ discard block |
||
| 270 | 303 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
| 271 | 304 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
| 272 | 305 | } else { |
| 273 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 274 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 306 | + if ($globalDBdriver == 'mysql') { |
|
| 307 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 308 | + } else { |
|
| 309 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 310 | + } |
|
| 275 | 311 | } |
| 276 | 312 | $query_values = array(':icao' => $icao); |
| 277 | 313 | try { |
@@ -326,7 +362,9 @@ discard block |
||
| 326 | 362 | |
| 327 | 363 | public function addMETARCycle() { |
| 328 | 364 | global $globalDebug, $globalIVAO; |
| 329 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
| 365 | + if (isset($globalDebug) && $globalDebug) { |
|
| 366 | + echo "Downloading METAR cycle..."; |
|
| 367 | + } |
|
| 330 | 368 | date_default_timezone_set("UTC"); |
| 331 | 369 | $Common = new Common(); |
| 332 | 370 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -339,7 +377,9 @@ discard block |
||
| 339 | 377 | $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
| 340 | 378 | } |
| 341 | 379 | if ($handle) { |
| 342 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
| 380 | + if (isset($globalDebug) && $globalDebug) { |
|
| 381 | + echo "Done - Updating DB..."; |
|
| 382 | + } |
|
| 343 | 383 | $date = ''; |
| 344 | 384 | //foreach(explode("\n",$cycle) as $line) { |
| 345 | 385 | while(($line = fgets($handle,4096)) !== false) { |
@@ -347,23 +387,33 @@ discard block |
||
| 347 | 387 | $date = $line; |
| 348 | 388 | } elseif ($line != '') { |
| 349 | 389 | //$this->parse($line); |
| 350 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 390 | + if ($date == '') { |
|
| 391 | + $date = date('Y/m/d H:m'); |
|
| 392 | + } |
|
| 351 | 393 | $pos = 0; |
| 352 | 394 | $pieces = preg_split('/\s/',$line); |
| 353 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 354 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 395 | + if ($pieces[0] == 'METAR') { |
|
| 396 | + $pos++; |
|
| 397 | + } |
|
| 398 | + if (strlen($pieces[$pos]) != 4) { |
|
| 399 | + $pos++; |
|
| 400 | + } |
|
| 355 | 401 | $location = $pieces[$pos]; |
| 356 | 402 | echo $this->addMETAR($location,$line,$date); |
| 357 | 403 | } |
| 358 | 404 | } |
| 359 | 405 | fclose($handle); |
| 360 | 406 | } |
| 361 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
| 407 | + if (isset($globalDebug) && $globalDebug) { |
|
| 408 | + echo "Done\n"; |
|
| 409 | + } |
|
| 362 | 410 | |
| 363 | 411 | } |
| 364 | 412 | public function downloadMETAR($icao) { |
| 365 | 413 | global $globalMETARurl; |
| 366 | - if ($globalMETARurl == '') return array(); |
|
| 414 | + if ($globalMETARurl == '') { |
|
| 415 | + return array(); |
|
| 416 | + } |
|
| 367 | 417 | date_default_timezone_set("UTC"); |
| 368 | 418 | $Common = new Common(); |
| 369 | 419 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -377,16 +427,24 @@ discard block |
||
| 377 | 427 | if ($line != '') { |
| 378 | 428 | //$this->parse($line); |
| 379 | 429 | //echo $line; |
| 380 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 430 | + if ($date == '') { |
|
| 431 | + $date = date('Y/m/d H:m'); |
|
| 432 | + } |
|
| 381 | 433 | $pos = 0; |
| 382 | 434 | $pieces = preg_split('/\s/',$line); |
| 383 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 384 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 435 | + if ($pieces[0] == 'METAR') { |
|
| 436 | + $pos++; |
|
| 437 | + } |
|
| 438 | + if (strlen($pieces[$pos]) != 4) { |
|
| 439 | + $pos++; |
|
| 440 | + } |
|
| 385 | 441 | $location = $pieces[$pos]; |
| 386 | 442 | if (strlen($location == 4)) { |
| 387 | 443 | $this->addMETAR($location,$line,$date); |
| 388 | 444 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 389 | - } else return array(); |
|
| 445 | + } else { |
|
| 446 | + return array(); |
|
| 447 | + } |
|
| 390 | 448 | } |
| 391 | 449 | //echo $line."\n"; |
| 392 | 450 | } |
@@ -9,7 +9,9 @@ discard block |
||
| 9 | 9 | if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { |
| 10 | 10 | exec("ps ux", $output, $result); |
| 11 | 11 | $j = 0; |
| 12 | - foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++; |
|
| 12 | + foreach ($output as $line) { |
|
| 13 | + if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++; |
|
| 14 | + } |
|
| 13 | 15 | if ($j > 1) { |
| 14 | 16 | echo "Script is already runnning..."; |
| 15 | 17 | die(); |
@@ -29,14 +31,18 @@ discard block |
||
| 29 | 31 | $update_db->update_notam(); |
| 30 | 32 | } |
| 31 | 33 | $update_db->insert_last_notam_update(); |
| 32 | - } elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n"; |
|
| 34 | + } elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) { |
|
| 35 | + echo "NOTAM are only updated once a day.\n"; |
|
| 36 | + } |
|
| 33 | 37 | if ($update_db->check_last_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
| 34 | 38 | $update_db->update_all(); |
| 35 | 39 | // require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 36 | 40 | // $Spotter = new Spotter(); |
| 37 | 41 | // $Spotter->updateFieldsFromOtherTables(); |
| 38 | 42 | $update_db->insert_last_update(); |
| 39 | - } elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n"; |
|
| 43 | + } elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) { |
|
| 44 | + echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n"; |
|
| 45 | + } |
|
| 40 | 46 | if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) { |
| 41 | 47 | echo "Check if new airspace version exist..."; |
| 42 | 48 | echo $update_db->update_airspace_fam(); |
@@ -51,7 +57,9 @@ discard block |
||
| 51 | 57 | $update_db->delete_duplicateowner(); |
| 52 | 58 | } |
| 53 | 59 | $update_db->insert_last_owner_update(); |
| 54 | - } elseif (isset($globalDebug) && $globalDebug && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n"; |
|
| 60 | + } elseif (isset($globalDebug) && $globalDebug && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
| 61 | + echo "Owner are only updated every 15 days.\n"; |
|
| 62 | + } |
|
| 55 | 63 | |
| 56 | 64 | if (isset($globalAccidents) && $globalAccidents && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
| 57 | 65 | require_once(dirname(__FILE__).'/../require/class.Accident.php'); |
@@ -60,7 +68,9 @@ discard block |
||
| 60 | 68 | if ($Accident->check_last_accidents_update()) { |
| 61 | 69 | $Accident->download_update(); |
| 62 | 70 | $Accident->insert_last_accidents_update(); |
| 63 | - } else echo "Accidents are updated once a day.\n"; |
|
| 71 | + } else { |
|
| 72 | + echo "Accidents are updated once a day.\n"; |
|
| 73 | + } |
|
| 64 | 74 | } |
| 65 | 75 | |
| 66 | 76 | } |
@@ -73,15 +83,19 @@ discard block |
||
| 73 | 83 | if ($METAR->check_last_update()) { |
| 74 | 84 | $METAR->addMETARCycle(); |
| 75 | 85 | $METAR->insert_last_update(); |
| 76 | - } else echo "METAR are only updated every 30 minutes.\n"; |
|
| 77 | -} |
|
| 86 | + } else { |
|
| 87 | + echo "METAR are only updated every 30 minutes.\n"; |
|
| 88 | + } |
|
| 89 | + } |
|
| 78 | 90 | |
| 79 | 91 | if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
| 80 | 92 | echo "Updating schedules..."; |
| 81 | 93 | //$update_db->update_oneworld(); |
| 82 | 94 | $update_db->update_skyteam(); |
| 83 | 95 | $update_db->insert_last_schedules_update(); |
| 84 | -} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n"; |
|
| 96 | +} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
| 97 | + echo "Schedules are only updated every 15 days.\n"; |
|
| 98 | +} |
|
| 85 | 99 | |
| 86 | 100 | if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) { |
| 87 | 101 | echo "Updating statistics and archive old data..."; |